Commit graph

29561 commits

Author SHA1 Message Date
Miles Malerba
aa9223e067 refactor(compiler): Use ExtractedAttributeOp for const collection (#51258)
Refactors the const collection phase to populate ElementAttributes from
the newly added ExtractedAttributeOp.

PR Close #51258
2023-08-03 14:34:53 -04:00
Miles Malerba
8b646f57d0 refactor(compiler): Create temporary ops during attribute extraction (#51258)
Refactors the attribute extraction phase to create a new temporary op
called `ExtractedAttributeOp` rather than directly populating
`ElementAttributes`.

PR Close #51258
2023-08-03 14:34:52 -04:00
Alex Rickabaugh
5aeed1fff0 docs: release notes for the v16.2.0-rc.0 release 2023-08-02 13:23:40 -07:00
Alex Rickabaugh
e7281cc08b release: bump the next branch to v16.3.0-next.0 2023-08-02 13:23:40 -07:00
Alex Rickabaugh
9d88cd8e0e docs: release notes for the v16.1.8 release 2023-08-02 12:55:00 -07:00
Miles Malerba
2d52d5e62c refactor(compiler): support safe function calls (#51100)
Adds support for safe function calls in template pipeline compiler

PR Close #51100
2023-08-01 13:45:34 -07:00
Miles Malerba
42caeeef21 refactor(compiler): reuse temp vars when possible (#51100)
Updates the template pipeline's temporary variables phase to reuse
temporary variables within an expression. The algorithm implemented here
reuses variables more aggressively than TemplateDefinitionBuilder. This
change in behavior is acceptable, as it is unlikely to cause any
failures, and implementing the exact behavior observed in
TemplateDefinitionBuilder would be difficult.

PR Close #51100
2023-08-01 13:45:34 -07:00
Miles Malerba
b8ec182a2a test(compiler): allow alternate expected file for template pipeline (#51100)
In some cases it is not feasible to have the template pipeline produce
the exact same compiled output as the TemplateDefinitionBuilder. This
commit adds support to the testing infrastructure to have different
expected output files for each. This option should be used sparingly, as
we want the output to be as close as possible.

PR Close #51100
2023-08-01 13:45:34 -07:00
Gerald Monaco
e53d4ecf4c feat(core): add afterRender and afterNextRender (#50607)
Add and expose the after*Render functions as developer preview

PR Close #50607
2023-08-01 13:02:27 -07:00
Matthieu Riegler
8913d3e407 docs: fix warning about an unknown decorator (#51237)
dgeni was complaning about an unknown decorator (`@Input`)

PR Close #51237
2023-08-01 13:00:53 -07:00
aanchal
d86e637a75 docs: add lang attribute to html files (#51235)
PR Close #51235
2023-08-01 12:16:44 -07:00
aanchal
388d1db89d docs: add the title tag (#51233)
PR Close #51233
2023-08-01 12:15:11 -07:00
Matthieu Riegler
4602545fe6 refactor(core): remove useless hack (#51224)
This hack is remnant of the Ivy migration.

PR Close #51224
2023-08-01 12:12:52 -07:00
Matthieu Riegler
d81d125814 refactor(core): Remove dead unit test code (#51223)
This code is duplicated but unused.

PR Close #51223
2023-08-01 12:10:57 -07:00
Matthieu Riegler
9d59764ffc refactor(core): createInjector is a private function (#51221)
`createInjector` is not public.

PR Close #51221
2023-08-01 12:10:20 -07:00
Matthieu Riegler
737ed23e22 refactor(core): removing reflect-metadata from symbol tests. (#51217)
We were not reyling on it anymore.

PR Close #51217
2023-08-01 12:09:25 -07:00
Matthieu Riegler
a871e23857 docs: remove duplicate words. (#51215)
Using the `\b(\w+)\s+\1\b` we can find duplicate word. Let's remove them.

PR Close #51215
2023-08-01 12:08:33 -07:00
aanchal
2274d156dc docs: updated the doc files (#51204)
PR Close #51204
2023-08-01 12:07:21 -07:00
aanchal
a24830777f docs: fix typos (#51201)
PR Close #51201
2023-08-01 12:04:31 -07:00
aanchal
6691c497e2 docs: add lang attributes to the files (#51200)
PR Close #51200
2023-08-01 11:58:44 -07:00
aanchal
584a32d8e3 docs: add the title tag (#51199)
PR Close #51199
2023-08-01 11:54:36 -07:00
aanchal
63b7f52008 docs: update the html tags (#51198)
PR Close #51198
2023-08-01 11:53:30 -07:00
Aristeidis Bampakos
5c6d1bb6e3 docs: fix typos in component overview guide (#51197)
PR Close #51197
2023-08-01 11:53:00 -07:00
Aristeidis Bampakos
71e803a868 docs: add new edition of Angular Projects book (#51184)
PR Close #51184
2023-08-01 11:51:49 -07:00
Andrew Kushnir
efb486e8bc refactor(compiler): handle defer blocks in TemplateDefinitionBuilder (#51162)
Updates the TemplateDefinitionBuilder class to generate the `defer` instruction for `{#defer}` blocks. Also generates dependency function that would be invoked at runtime (with dynamic imports inside).

PR Close #51162
2023-08-01 11:50:05 -07:00
Andrew Kushnir
08992a5f2f refactor(compiler): compute the list of dependencies for defer blocks (#51162)
This commit brings the logic to calculate teh set of dependencies for each defer block. For each dependency we also identify whether it can be defer-loaded or not.

PR Close #51162
2023-08-01 11:50:05 -07:00
Andrew Kushnir
f5116e739e refactor(compiler): extracting helper function and types to the top level (#51162)
This is a minor refactoring of the ComponentHandler class logic to extract helper function and types to the top level for simplicity and reuse across other functions of the class.

PR Close #51162
2023-08-01 11:50:05 -07:00
Andrew Kushnir
553cbaed84 refactor(compiler): update TemplateBinder and DirectiveBinder to work with defer blocks (#51162)
This commit updates the logic of the TemplateBinder and DirectiveBinder classes to recognize defer blocks. The logic is updated to prevent Directive and Pipe matching inside the defer block. Instead, the scope for those blocks would be calculated separately.

PR Close #51162
2023-08-01 11:50:04 -07:00
Andrew Kushnir
256e6826bc refactor(compiler): add DeferredSymbolTracker class to keep track of symbol usages (#51162)
This commit adds a new class called `DeferredSymbolTracker` to keep track of all usages of a particular symbol within a source file and allow to detect whether a symbol can be defer loaded (i.e. if there are any references to a symbol).

PR Close #51162
2023-08-01 11:50:04 -07:00
Angular Robot
4d8cc709e2 build: update io_bazel_rules_sass digest to ded821e (#51139)
See associated pull request for more information.

PR Close #51139
2023-08-01 11:49:06 -07:00
AleksanderBodurri
c1dee4cfe3 test(core): unit tests for the injector profiler and injector debugging APIs (#48639)
Creates unit tests for the following APIs

    - setInjectorProfiler
    - getInjectorProviders
    - getInjectorResolutionPath
    - getDependenciesFromInjectable

    Modifies existing tests in

    - packages/examples/core/di/ts/injector_spec.ts
    - packages/core/test/render3/jit/declare_injectable_spec.ts
    - packages/core/test/render3/jit/declare_factory_spec.ts

    because they setup framework injector context manually.

    Exports setInjectorProfilerContext in packages/core/src/core_private_export.ts in order for use
    in the the modified tests above.

PR Close #48639
2023-08-01 11:44:40 -07:00
AleksanderBodurri
98d262fd27 feat(core): create injector debugging APIs (#48639)
This commit introduces 3 new APIs.

getDependenciesFromInstantiation:
- Given an injector and a token that was instantiated by that injector, discover all of the things were injected in the instance of that token
- This API is meant to enable recursive inspection of dependencies. Dependencies returned by this API include which injector they were providedIn, which enables the continous use of getDependenciesFromInstantiation to determine the dependencies of dependencies

getInjectorProviders:
- Given an injector, discover all of the providers that were configured in that injector.
- This API returns information on the configured providers of an injector, including the import path that leads to the container that the provider originated from (NgModule or standalone directive). This enables fine grained inspection to determine where a specific provider comes from.

getInjectorParent:
- Given an injector, discover the parent of that injector.
- This function is meant to be used recursively to discover the entire resolution path from a starting injector to the NullInjector.

These APIs were designed to be used together. For example, getInjectorParent can be used to discover the structure of an injector hierarchy. Once that's done, getInjectorProviders can be used to determine the providers of each injector in that hierarchy.

Another example: getDependenciesFromInstantiation can be used to discover the dependencies of a specific injector constructed instance. From there, we can use getInjectorParent to discover the injector resolution path and map each dependency to a path from the starting injector to the injector that it was provided in.

PR Close #48639
2023-08-01 11:44:40 -07:00
AleksanderBodurri
4d92080a80 refactor(core): convert walkProviderTree and processInjectorTypesWithProviders to callback style interfaces (#48639)
walkProviderTree and processInjectorTypesWithProviders both perform some generic traversal logic of the import graph of an input NgModule or Standalone component. Currently, these functions pass around a `providersOut` array that is used to collect providers at each step of the traversal.

This PR converts those functions to accept visitor callbacks instead of the `providersOut` array. This is done to make the traversal logic of these functions reusable, while leaving it up to the visitor to determine the logic that fires for each visited node.

This refactor would allow us to reuse `walkProviderTree` for injector debugging APIs that could support some cool features in DevTools, like tracing the injector resolution path of an injected property on a component instance all the way up to the specific imported module/standalone component.

PR Close #48639
2023-08-01 11:44:40 -07:00
AleksanderBodurri
ff4d1b4a0e feat(devtools): create profiler for DI and injector events (#48639)
Currently, understanding dependency injection in Angular requires a lot of context and has been sited in our surveys as one of the largest points of confusion that our users have with the framework. This commit is the beginning of our approach to make debugging dependency injection in Angular easier.

This commit introduces injector profiler callbacks in parts of the framework to emit injector events. It also introduces a default handler for these events. This default handler parses the stream of events to construct some data structures that will support new injector debug APIs.

We have implemented a similar pattern in the past to minimize overhead. There is also the possiblity of making the internal `setInjectorProfiler` function a public debug API in the future, so that users can implement their own handlers to debug DI events. Lastly DI in Angular maps nicely to a stream of events.

For production applications there is no runtime overhead. For applications in dev mode there is some additional overhead from the default profiler handling injector events and holding debug data in memory.

For production applications, dead code elimination should strip all of the code used by this PR.

PR Close #48639
2023-08-01 11:44:40 -07:00
Miles Malerba
c1052cf7a7 refactor(compiler): add support for sanitizing properties and attributes (#51156)
Sets sanitizer functions when attempting to set sensitive properties and attributes

PR Close #51156
2023-07-28 15:11:51 -07:00
Joey Perrott
e4ae634230 ci: remove migrated circleci jobs (#51194)
Remove test_angular_devtools and test_win jobs which were migrated to GHA

PR Close #51194
2023-07-28 14:43:03 -07:00
Jáchym Bambuch
f71851a523 docs: Change "ng run build:ssr" to "npm run build:ssr" in universal.md (#51192)
PR Close #51192
2023-07-28 14:42:30 -07:00
Kristiyan Kostadinov
72255288bf refactor(compiler): add utility to enable deferred blocks for testing (#51183)
Adds the `ɵsetEnabledBlockTypes` utility that can be used when writing JIT tests using `defer` blocks. Intended usage:

```ts
import {ɵsetEnabledBlockTypes as setEnabledBlockTypes} from '@angular/compiler/src/jit_compiler_facade';

describe('deferred tests', () => {
  beforeEach(() => setEnabledBlockTypes(['defer']));
  afterEach(() => setEnabledBlockTypes([]));

  it('should work', () => {
    // test goes here
  });
});
```

PR Close #51183
2023-07-28 14:42:04 -07:00
Miles Malerba
09bf32724f refactor(compiler): add support for animation listeners (#50975)
Adds support for binding animation listeners, e.g.

PR Close #50975
2023-07-28 14:40:13 -07:00
Miles Malerba
570bd67eae refactor(compiler): make listener instruction chainable (#50975)
Makes the `ɵɵlistener` instruction chainable in the template pipeline

PR Close #50975
2023-07-28 14:40:13 -07:00
Miles Malerba
7dd99cd843 refactor(compiler): add support for animation properties (#50975)
Adds support for binding animation properties, e.g.

PR Close #50975
2023-07-28 14:40:13 -07:00
Miles Malerba
88a5711b1f refactor(compiler): make element instruction chainable (#50975)
Makes the `ɵɵelement` instruction chainable in the template pipeline

PR Close #50975
2023-07-28 14:40:13 -07:00
P4
6755f5354c fix(compiler): return full spans for Comment nodes (#50855)
Change sourceSpan for Comment nodes to cover the whole comment
instead of just the opening token.

The primary motivation for this is the interaction between ESLint and
`@angular-eslint`. ESLint can detect unused `eslint-disable` directives
in comments and automatically remove them when running with `--fix`.
This is based on ranges computed from AST spans, and as a result
does not work inside Angular templates - right now all comments
claim to be 4 characters long so only the opening `<!--` is removed.

PR Close #50855
2023-07-28 14:39:18 -07:00
Andrew Kushnir
cdaa2a8a9e feat(core): support Provider type in Injector.create (#49587)
This commit updates the Injector.create function to accept the `Provider` type in addition to the `StaticProvider` type. This should make it easier to work with the Injector.create function and have less type casts if you have a list of `Provider`s available.

PR Close #49587
2023-07-28 14:38:05 -07:00
Dylan Hunn
50613117bd refactor(compiler): Ingest host attribute bindings in template pipeline (#51188)
Host property bindings beginning with `attr.` should have `Attribute` binding kind, and result in an `attribute` instruction.

This should really be handled in the parser in the future.

PR Close #51188
2023-07-28 11:47:57 -07:00
Dylan Hunn
a42c91e78b refactor(compiler): Generate temporaries in host bindings for template pipeline (#51188)
Add the ability to name and resolve generated temporary variables in host bindings, using the existing phase.

PR Close #51188
2023-07-28 11:47:57 -07:00
Dylan Hunn
72a59bdc4d refactor(compiler): Support svg and math namespace instructions in template pipeline (#51188)
Templates may contain special `svg` and `math` elements, as well as logical descendants of those elements (e.g. `svg` may contain `g`). These will be parsed with a special colon-prefixed *namespace identifier*, such as `:svg:svg`, or `:svg:g`, or `:math:infinity`.

The template pipeline now considers these namespace prefixes, and stores them specially on the Element and Template data structures, ultimately generating the appropriate runtime instructions to change namespaces when needed.

PR Close #51188
2023-07-28 11:47:57 -07:00
Dylan Hunn
c4b289ab8f refactor(compiler): Allow chaining of listeners in template pipeline (#51188)
Calls to the listener instruction can be chained.

PR Close #51188
2023-07-28 11:47:57 -07:00
Dylan Hunn
8f50385041 refactor(compiler): support ngNonBindable in the template pipeline (#51188)
When a container-like element has the `ngNonBindable` special attribute, bindings are disabled for it and its descendants. This requires emitting the `disableBindings` and `enableBindings` instructions when nested content exists.

PR Close #51188
2023-07-28 11:47:57 -07:00
Dylan Hunn
1c553ee915 refactor(compiler): Delete some redundant types in template pipeline. (#50899)
Previously we refactored the compilation to use the concepts of "jobs" and "units." However, old type aliases were provided to avoid changing all call-sites in bulk. Here, those aliases are deleted, and call sited updated:

1. `ComponentCompilation` becomes `ComponentCompilationJob`.
2. `ViewCompilation` becomes `ViewCompilationUnit`.

PR Close #50899
2023-07-27 15:08:05 -07:00