10213 Commits

Author SHA1 Message Date
Pawel Kozlowski 2820425e38 build: update babel dependencies to v7.23.2 (#52255)
16.2.x version of #52236

PR Close #52255
2023-10-18 15:56:47 +02:00
Paul Gschwendtner d75eaa7375 refactor(core): remove unused helper for setting LView for reactive consumer (#52192)
This code path is never hit because the assignment of the lview happens
in `commitLViewConsumerIfHasProducers`.

PR Close #52192
2023-10-13 14:08:34 +02:00
Miroslav Foltýn 630e906747 docs(router): add clarification for behavior of paramsInheritanceStrategy: 'emptyOnly' (#52170)
Follows up to the https://github.com/angular/angular/issues/52108 which was opened due to the confusion surrounding paramsInheritanceStrategy: 'emptyOnly'.

PR Close #52170
2023-10-13 11:14:22 +02:00
Pawel Kozlowski f52eee8eb2 Revert "refactor(compiler-cli): remove MethodIdentifier type (#49611)" (#52174)
This reverts commit c2b1a242e8.

PR Close #52174
2023-10-12 12:35:49 +02:00
Matthieu Riegler 5f2a33ac58 refactor(compiler-cli): remove MethodIdentifier type (#49611)
`MethodIdentifier` is unused as is `IdentifierKind.Method`. They both can be removed.

PR Close #49611
2023-10-11 12:34:50 -07:00
Matthieu Riegler 51a5baace3 fix(forms): reset() call with null values on nested group (#48830)
Non typed forms allow to pass null to nested groups when calling `formGroup.reset()`, this commit prevent an undefined access.

fixes #20509

PR Close #48830
2023-10-10 15:34:32 -07:00
Thabo 2bfd28c396 docs: correct wording for Directive's decorator host property key description (#51977)
PR Close #51977
2023-10-10 11:22:19 -07:00
Phalgun Vaddepalli d3c9e436a9 docs(core): add an example of configuring APP_INITIALIZER token in context of standalone components (#52084)
docs(core): fix formatting

PR Close #52084
2023-10-10 11:18:37 -07:00
Andrew Scott b732961fc3 fix(language-service): Retain correct language service when ts.Project reloads (#51912)
When the `ts.Project` creates the language service plugin (in this case,
the Angular Language Service), it sets the project's language service to
the new language service returned by the plugin create:
https://sourcegraph.com/github.com/microsoft/TypeScript@b12af0fa2bbd4b015e59adcfb49988cea7f919a1/-/blob/src/server/project.ts?L2035-2044

The project may be reloaded in response to various events, such as a
change to the tsconfig file, which then recreates the plugin. When this
happens, the language service that gets passed to the plugin `create`
function will not be the typescript language service, but rather the
previous instance of the new language service returned by the last call
to `create`.

This commit ensures that subsequent calls to `create` for the
`NgLanguageService` plugin for a project after the first call are able
to retrieve and hold on to the _TypeScript_ language service.

fixes https://github.com/angular/vscode-ng-language-service/issues/1923

PR Close #51912
2023-10-04 11:27:46 -07:00
Matthieu Riegler 966ce9790a fix(service-worker): throw a critical error when handleFetch fails (#51960)
#51885 patched a call site that threw an error but there were 2 others call that needed to be wrapped in the same way by a try/catch.

`initializeFully` is part of the calls in `responseWith(handleFetch)`.

Same #51885, throwing `SwCriticalError`allows the driver to fallback to `safeFetch` and ensure `responseWith` doesn't fail.

Fixes #50378

PR Close #51960
2023-10-04 08:51:07 -07:00
Andrew Scott 334fe60c17 refactor(core): Update view flags so only one number needs adjustment (#51839)
When adding a new view flag, you currently need to adjust the last number of the last
3 flags. All of these share the same number so the shifting ones can just use
the base-10 IndexWithinInitPhaseShift.

PR Close #51839
2023-10-04 07:29:16 -07:00
Joey Perrott 781bb91f43 build: lock file maintenance (#51838)
Update the lock file.

PR Close #51838
2023-10-02 08:15:28 -07:00
Pawel Kozlowski 39a3e34e03 fix(core): allow toSignal calls in reactive context (#51831) (#51892)
This PR moves the Observable subscription of toSignal outside of the
reactive context. As the result the toSignal calls are allowed in the
computed, effect and all other reactive consumers.

This is based on the reasoning that we already allow signals creation
in a reactive context. Plus a similar change was done to the async pipe
in the https://github.com/angular/angular/pull/50522

Fixes #51027

PR Close #51892
2023-09-27 10:30:15 -07:00
Andrew Kushnir 68648ee684 refactor(core): avoid an empty array allocation during hydration (#51917)
This commit updates hydration runtime code to avoid creating an empty array when we can avoid it. Instead, we just check whether the field is `null` directly (without using nullish coalescing).

PR Close #51917
2023-09-27 09:22:50 -07:00
Matthieu Riegler c3d901eacf fix(service-worker): throw a critical error when handleFetch fails (#51885)
On Safari, the cache might fail on methods like `match` with an `Internal error`. Critical errors allows to fallback to `safeFetch()` in the `Driver`.

fixes: #50378

PR Close #51885
2023-09-26 09:10:38 -07:00
Paul Gschwendtner 663703946e fix(bazel): allow setting _enabledBlockTypes angular compiler option (#51862)
We control most flags via Starlark and therefore limit configuration
options via `tsconfig` to a minimum. We do not intend to support the
enabled block types option via Starlark, so this commit allows for
the option to be picked up.

(This is useful for benchmarking the new control flow blocks).

PR Close #51862
2023-09-22 09:51:26 -07:00
Andrew Scott 4ccd845081 refactor(router): Refactor loadChildren callback execution and privately export for SSR (#51818)
This commit refactors the loadChildren callback execution of the router config loader
into a function that can be used with SSR for the purposes of route extraction.

PR Close #51818
2023-09-20 18:34:13 +02:00
Paul Gschwendtner 03127fc870 refactor(core): ensure reactive node constants are considered pure (#51809) (#51813)
Currently when ESBuild bundles an application importing from
`@angular/core`, the signals library will be discovered during
export analysis. ESBuild will come across the constants for the reactive
signal graph- and end up considering some of these as side-effects given
the pattern of using a spread assignment for extending from e.g.
`REACTIVE_NODE` (a similar issue may occur if we e.g. extend from the
computed reactive node).

See more details on the issue: https://github.com/evanw/esbuild/issues/3392

Even though, ESBuild preserves these constants now, and all of its
dependencies— Terser will consider these as side-effect free and
eliminate these constants. This may require multiple passes though, and
might not be sufficient, depending on the chain of reactive node
extensions. E.g. in the signals branch we noticed some constants
unnecessarily being preserved.

PR Close #51809

PR Close #51813
2023-09-18 15:37:13 +02:00
Kristiyan Kostadinov bf1f9a0897 test(compiler): attempt to deflake windows tests (#51804)
Another try at deflaking the tests on Windows. I'm trying a couple of fixes here:
1. I noticed that it's usually the indexer tests that fail during flaky runs. These tests also happen to be the only ones that don't pass in the `files` argument of `NgtscTestEnvironment.setup`. When `files` isn't passed in, we don't hit the file path that sets up the `MockFileSystem`. With these changes I make it so that we always initialize the mock file system.
2. The missing file system error usually comes from the `absoluteFrom` call that initializes the optional `workingDir` argument. My theory is that because it's a default value for an argument, it gets called too early before everything is initialized. These changes move the `absoluteFrom` call further down until it's needed.

PR Close #51804
2023-09-18 10:46:38 +02:00
Paul Gschwendtner 3b46066ff0 refactor: ensure top-level symbols are marked as side-effect free (#51776)
Terser does not treat `Symbol` as side-effect free- so if we end up with
a symbol export being loaded, it will result in the symbol being
retained.

We noticed this in the signals prototyping where symbols exported
from `computed` ended up appearing in symbol bundling tests.

PR Close #51776
2023-09-15 15:53:51 +02:00
JoostK 7b40d74fb4 refactor(core): let reactive node prototypes conform to their type (#51722) (#51772)
This commit adds explicit type annotations to the reactive node prototype objects,
such that the prototypes are type-checked against the interface they are supposed
to (partially) implement. This also allows IDEs to better track usages of reactive
node properties, improving code navigation.

PR Close #51722

PR Close #51772
2023-09-14 12:51:30 +02:00
JoostK 82712f80df fix(core): ensure a consumer drops all its stale producers (#51722) (#51772)
When a producer is no longer used, the consumer has to update its internal data structure
that keeps track of all producers. There used to be an issue where only half of the stale
producers would actually be removed from this data structure, as the intended upper bound
of the number of producers to remove would decrease with each removed producer, therefore
not reaching all producers that should be removed from the data structure.

This commit fixes the issue by truncating the arrays directly, without going through
individual `pop` operations. An assertion that would catch the inconsistent state in
the internal data structures of the signal graph has been introduced.

PR Close #51722

PR Close #51772
2023-09-14 12:51:30 +02:00
Gerald Monaco c700418ab8 refactor(core): delegate afterRender errors to an ErrorHandler (#51711)
Improves the error handling story for after*Render by delegating errors to an ErrorHandler, so that one failure does not break every callback.

PR Close #51711
2023-09-08 14:21:06 -07:00
Gerald Monaco 867b380f64 refactor(core): make AfterRenderEventManager tree-shakable (#51711)
In preparation for adding support for phases to after*Render, which will increase the implementation size, this commit splits out the optional logic so that it can be tree-shaken and dynamically loaded.

PR Close #51711
2023-09-08 14:21:06 -07:00
Kristiyan Kostadinov 975cb05819 build: attempt to deflake windows tests (#51701)
Adds some logic to try and deflake the tests on Windows.

PR Close #51701
2023-09-08 09:28:03 -07:00
Matthieu Riegler 4051930b8c docs: Add info about hydration caching. (#51648)
The docs was missing an important information about caching. Only GET/HEAD requests are cached until `isStable`

PR Close #51648
2023-09-06 15:31:36 +00:00
AleksanderBodurri 1122afd656 refactor(core): implement __ignore_ng_zone__ flag (#51339)
This flag allows message event listeners to prevent callbacks from executing within the NgZone if they contain a special `__ignore_ng_zone__` flag.

This functionality is built with Angular DevTools in mind, where it prevents an infinite change detection loop in inspecting applications that have message event listeners:

CD -> Inspected app emits componentTreeDirty event to DevTools -> DevTools emits event to get new component Tree from Inspected app -> Inspected app message event listener fires -> CD

PR Close #51339
2023-09-05 18:16:33 +00:00
hiepxanh 8ce22ebae3 docs: fix missing information in createComponent (#51493)
PR Close #51493
2023-09-01 16:15:13 +00:00
hiepxanh 137195cd26 docs: add viewContainerRef example (#51573)
PR Close #51573
2023-09-01 16:14:40 +00:00
Joey Perrott af9cd84c13 build: migrate to node 18 (#51609)
Migrate to use node version 18

PR Close #51609
2023-09-01 15:12:44 +00:00
Alex Rickabaugh f56b6555bd refactor(core): switch signals to a refcounting algorithm (#51226)
This commit switches the signals library from a bidirectional symmetric
dependency graph using weak references, to a bidirectional _asymmetric_
graph which uses strong references. This is made possible with a reference
counting algorithm which only tracks producer -> consumer references for
effect-like "live" consumers, preventing memory leaks.

The new algorithm should be simpler and faster than the previous
implementation as weak references are fairly slow to create and traverse.
A tradeoff is that non-live consumers must now poll their producers when
read, as they cannot rely on dirty notifications.

As part of this refactoring, the `ReactiveNode` class is replaced with an
interface instead, and methods are moved to standalone functions. This is
paired with instantiating individual signals/computeds via `Object.create`
against a prototype node which contains static or initial values. This
technique, in conjunction with the rest, greatly improves the performance
of node creation.

PR Close #51226
2023-09-01 14:18:41 +00:00
Pawel Kozlowski 7bb4f9126b refactor(core): remove duplicated access to TView (#51610)
Tiny refactoring to remove repeated field access to LView.

PR Close #51610
2023-09-01 14:18:06 +00:00
Matthieu Riegler b1a3925794 refactor(core): Use intersections on branded types. (#49702)
An Intersection on a branded type allows us to remove some unecessary type assertions.

PR Close #49702
2023-08-31 20:22:12 +00:00
Angular Robot ba46365abd build: update dependency google-closure-compiler to v20230802 (#51265)
See associated pull request for more information.

PR Close #51265
2023-08-31 16:34:50 +00:00
Luis Castro dc4f77c851 docs(core): clarify InjectionToken usage (#51386)
- Emphasized the importance of using the same InjectionToken instance for both provider and injection call.
- Added examples to illustrate correct usages to prevent NullInjectorError.

PR Close #51386
2023-08-30 15:53:24 +00:00
Joey Perrott 5c36fc784f fix(compiler-cli): remove unnecessary escaping in regex expressions (#51554)
Correct various Useless regular-expression character escape issues.

PR Close #51554
2023-08-29 21:52:34 +00:00
Joey Perrott 04c6574280 fix(animations): remove unnecessary escaping in regex expressions (#51554)
Correct various Useless regular-expression character escape issues.

PR Close #51554
2023-08-29 21:52:34 +00:00
Joey Perrott e6b301caa2 fix(core): remove unnecessary escaping in regex expressions (#51554)
Correct various Useless regular-expression character escape issues.

PR Close #51554
2023-08-29 21:52:34 +00:00
Joey Perrott dbd761f528 fix(compiler-cli): correct incomplete escaping (#51557)
Correct incomplete escaping and replace all instances of `

PR Close #51557
2023-08-29 19:48:26 +00:00
Joey Perrott dcd1add06f fix(core): correct incomplete escaping (#51557)
Correct incomplete escaping and replace all instances of comment delimiters

PR Close #51557
2023-08-29 19:48:26 +00:00
Joey Perrott 8081fdd22d fix(language-service): correct incomplete escaping (#51557)
Correct incomplete escaping and replace all instances of $

PR Close #51557
2023-08-29 19:48:25 +00:00
Gerald Monaco 0c7c852ee7 fix(core): run afterRender callbacks outside of the Angular zone (#51551)
afterRender should run outside of the Angular zone so that it does not trigger further CD cycles

PR Close #51551
2023-08-29 17:54:20 +00:00
Andrew Kushnir 20d62603c2 fix(core): handle hydration of view containers that use component hosts as anchors (#51456)
This commit fixes an issue where serialization of a view container fails in case it uses a component host as an anchor. This fix is similar to the fix from #51247, but for cases when we insert a component (that acts as a host for a view container) deeper in a hierarchy.

Resolves #51318.

PR Close #51456
2023-08-29 16:37:50 +00:00
Andrew Scott 157415831c refactor(router): Have router subscribe to transition events to update state (#48427)
Rather than the navigation transitions managing Router state, this
commit updates the Router to manage its own state based on ongoing
transition events. In the future, this can be abstracted even further to
have a totally separate class that manages the Router state. This would
allow the potential for swapping state manager implementations rather
than having to implement all types of state management in a single place.

One finding during tests was that unexpected errors thrown by the state management code moved
to the Router here will no longer be caught by the transition pipe's `catchError`.
This only includes calls to the following public Api methods:

* `go`, `replaceState`, `historyGo`, `isCurrentPathEqualTo` on `Location`
* `UrlSerializer.serialize`
* `UrlHandlingStrategy.merge`.

None of these methods should throw if the router is expected to function.
These might throw when tests include incomplete mocks, which is not
supported, or in cases where the actual browser methods like
`replaceState` would throw. This will already result in unexpected/unsupported
behavior. The failure case here is now arguably better - the navigation
itself still completes but the state update (either updating Router
internal state or updating the browser URL) fails separately and is
unhandled.

PR Close #48427
2023-08-22 08:04:01 -07:00
Andrew Scott b0396e7164 fix(router): Ensure canceledNavigationResolution: 'computed' works on first page (#51441)
Setting the page ID is currently broken for the first page because the
helper method's second parameter is optional, which allowed the initally
`undefined` page ID to be used again when the router performs its
initial navigation.

fixes #50983

PR Close #51441
2023-08-21 13:01:59 -07:00
Matthieu Riegler 36f434e49d fix(core): guard the jasmine hooks (#51394)
This commit fixes a regression introduced in #50063

Fixes #51382

PR Close #51394
2023-08-21 08:14:54 -07:00
JoostK 39ace8664b fix(compiler-cli): enforce a minimum version to be used when a library uses input transform (#51413)
Angular 16.1 introduced the input transform feature, requiring the partial compilation output to be extended
with a reference to the input transform function. This has resulted in a subtle breaking change, where older
versions of the Angular linker can no longer consume libraries that have started to use this feature.

We do try to support using a 16.1 library from an Angular 16.0 application, but if a library actually
adopts a new feature then this is no longer possible. In such cases, it is desirable to report a message
telling the user that their version of the Angular compiler is too old, as determined by the `"minVersion"`
property that is present in each partial declaration. This version would still indicate that the declaration
required at least Angular 14.0 to be compiled, but this is not accurate once input transforms are being
used. Consequently, this error would not be reported, causing a less informative error once the input transform
was being observed.

Fixes #51411

PR Close #51413
2023-08-18 07:58:54 -07:00
Matthieu Riegler 2c65ea9b40 refactor(platform-browser-dynamic): remove reexport of MetadataOverrider (#51412)
this commit removes an unnecessary re-export

PR Close #51412
2023-08-18 07:57:35 -07:00
Matthieu Riegler 3dbfabcafe docs: fix links in UpgradeAdapter (#51395)
PR Close #51395
2023-08-18 07:56:42 -07:00
Alex Castle a43c0772ea fix(common): Allow safeUrl for ngSrc in NgOptimizedImage (#51351)
Allow safeUrl and add transformer to immediately convert ngSrc to string

PR Close #51351
2023-08-17 10:20:36 -07:00