Commit graph

5432 commits

Author SHA1 Message Date
Matthieu Riegler
36ae560765 refactor(core): remove the phase prop from AfterRenderOptions (#60641)
The `AfterRenderPhase` enum now becomes private, it isn't exported anymore.

PR Close #60641
2025-04-09 15:39:47 -07:00
Matthieu Riegler
0b69b61929 fix(core): Flush animations when no component has been checked (#58089)
When Angular runs application synchronization automatically, animations
are now guaranteed to be flushed, regardless of whether change detection
was run on any components attached to `ApplicationRef`. This most
frequently affects animations related to component removal where the DOM
element for the component would previously not be removed due to
animations not being flushed

BREAKING CHANGE: Animations are guaranteed to be flushed when Angular
runs automatic change detection or manual calls to `ApplicationRef.tick`.
Prior to this change, animations would not be flushed in some situations
if change detection did not run on any views attached to the
application. This change can affect tests which may rely on the old
behavior, often by making assertions on DOM elements that should have
been removed but weren't because DOM removal is delayed until animations
are flushed.

fixes #58075

PR Close #58089
2025-04-09 11:12:54 -07:00
Matthieu Riegler
e50f8a23dc Revert "refactor(core): use stream in rxResource instead of loader (#59910)" (#60803)
This reverts commit 98a584c1e8.

PR Close #60803
2025-04-09 09:33:26 -07:00
Pawel Kozlowski
2b4fd9b273 refactor(core): allow multiple DI profilers (#60562) (#60562)
This commit changes the DI profiler infrastructure to
allow multiple profilers running at the same time.

PR Close #60562

PR Close #60562
2025-04-09 09:16:40 -07:00
aparziale
39a4e00464 fix(core): fix ng generate @angular/core:output-migration. Fixes angular#58650 (#60763)
Fixes #58650 - Insert a TODO comment for empty emit (without parameter).

PR Close #60763
2025-04-08 16:10:03 -07:00
Andrew Scott
b8d9f95faa Revert "refactor(core): allow multiple DI profilers (#60562)" (#60793)
This reverts commit 56cc5fdb57.

CI tests are consistently timing out after this commit

PR Close #60793
2025-04-08 14:04:16 -07:00
cexbrayat
98a584c1e8 refactor(core): use stream in rxResource instead of loader (#59910)
With the changes in #59573, `resource` can now define a `stream` rather than a `loader`.
In the same PR, `rxResource` was updated to leverage this new functionality to handle multiple responses from the underlying observable,
rather than just the first one as it was previously.
This commit renames the `loader` option of `rxResource` into `stream` to be better aligned with its new behavior.

The previous version is temporarily kept and marked as deprecated to help migrating the current usage.

Before
```
usersResource = rxResource({
  request: () => ...,
  loader: ({ request }) => ...
});
```

After
```
usersResource = rxResource({
  request: () => ...,
  stream: ({ request }) => ...
});
```

PR Close #59910
2025-04-08 10:19:13 -07:00
Kristiyan Kostadinov
c0f41bc505 refactor(platform-browser): remove GenericBrowserDomAdapter (#60760)
The `GenericBrowserDomAdapter` wasn't don't anything so we can drop it and have the `BrowserDomAdapter` extend `DomAdapter` directly.

PR Close #60760
2025-04-08 10:14:54 -07:00
Matthieu Riegler
2c6b697e4c refactor(core): promote effect to stable. (#60773)
`effect` is promoted to stable in v20

PR Close #60773
2025-04-08 09:16:38 -07:00
Pawel Kozlowski
56cc5fdb57 refactor(core): allow multiple DI profilers (#60562)
This commit changes the DI profiler infrastructure to
allow multiple profilers running at the same time.

PR Close #60562
2025-04-08 08:56:30 -07:00
JoostK
3d85d9363c fix(core): reduce total memory usage of various migration schematics (#60774)
This commit changes Tsurge's operation within angular-devkit (i.e. the CLI) to
no longer retain all programs across all migrations. This isn't necessary for
so-called "funnel" migrations so not retaining the programs for those migrations
is a pure performance win. The "complex" migrations may see increased execution time
given that the program is now being recreated for the actual migration phase to run,
although reduced memory pressure may help alleviate this overhead. Since this new
approach should help prevent Node from running out of memory and failing entirely
this is preferred over a potentially increased execution time.

Fixes #59813

PR Close #60774
2025-04-07 13:13:33 -07:00
Doug Parker
0ae1889560 fix(core): run ApplicationRef.prototype.bootstrap in NgZone (#60720)
`bootstrapApplication` always creates the root component in the `NgZone`, however `ApplicationRef.prototype.bootstrap` historically did not, meaning that if users did not go out of their way to call `ngZone.run(() => appRef.bootstrap(SomeComp))`, components would not run change detection correctly.

This commit updates `ApplicationRef.prototype.bootstrap` to _always_ run within `NgZone`, removing this hazard and ensuring components always run CD as expected.

PR Close #60720
2025-04-07 11:32:31 -07:00
Jamie Couperwhite
a1a9f8c1a9 docs: fix typo in documentation for pendingUntilEvent (#60756)
PR Close #60756
2025-04-07 10:29:35 -07:00
Kristiyan Kostadinov
92c4123a74 refactor(compiler): integrate new AST nodes into visitors (#60724)
Updates the various visitors to add placeholders for the new AST nodes.

PR Close #60724
2025-04-04 11:28:47 -07:00
Pawel Kozlowski
8d050b5bfc feat(core): stabilize linkedSignal API (#60741)
The linkedSignal API is now considered stable.

PR Close #60741
2025-04-04 10:35:51 -07:00
Andrew Scott
189935810c refactor(common): Add hashchange event for traversals (#60682)
This commit adds the logic to emit the `hashchange` event for
traversals.

PR Close #60682
2025-04-03 16:54:56 -07:00
Andrew Scott
36b92367ae refactor(common): Update FakeNavigation deferred commit to use precommitHandler (#60652)
This commit updates the FakeNavigation implementation to match the
spec's new `precommitHandler` which replaces the old `commit: 'after-transition'`.

PR Close #60652
2025-04-03 16:53:06 -07:00
Andrew Kushnir
491818f51f docs: mark REQUEST and related symbols as stable (#60717)
This commit removes the `@developerPreview` annotation from the `REQUEST`, `RESPONSE_INIT` and `REQUEST_CONTEXT` symbols, making them stable.

PR Close #60717
2025-04-03 13:04:23 -07:00
Doug Parker
2348f26d8a refactor(core): add ApplicationRef.prototype.bootstrapImpl with an injector parameter (#60622)
This is a roll forward of commit d5a8a1c524. Nothing is meaningfully different, as we're trying again to see if the CI failure is reproducible.

PR Close #60622
2025-04-03 10:48:01 -07:00
Andrew Scott
866cea9a05 feat(core): Stabilize PendingTasks Injectable (#60716)
This PR marks `PendingTasks` as stable, though the `run` function
remains in dev preview. There are still questions around its return
value, error handling, and whether it will be replaced by a different
`task` API that would better track context through the
injector/injection context.

PR Close #60716
2025-04-03 10:11:15 -07:00
Alex Rickabaugh
4e88e18a8e feat(core): mark toObservable as stable (#60449)
`toObservable` graduates from developer preview and is now considered stable
API.

PR Close #60449
2025-04-02 13:38:49 -07:00
Alex Rickabaugh
45f909e8f9 Revert "refactor(core): support an opt-in sync version of toObservable (#60640)" (#60449)
This reverts commit 57a240b07e. We're no
longer attempting to convert `toObservable` to a synchronous API.

PR Close #60449
2025-04-02 13:38:49 -07:00
Matthieu Riegler
1c1ad12ad3 refactor(core): Instantiate the ErrorHandler lazily. (#58984)
This change prevents that user code in a custom `ErrorHandler` to run as part of `ApplicationRef`'s creation.

fixes #58970

PR Close #58984
2025-04-02 19:20:50 +00:00
arturovt
1c7b356625 fix(core): release hasPendingTasks observers (#59723)
In this commit, we unsubscribe the `hasPendingTasks` subject to remove all active observers and enable granular garbage collection, as users may forget to unsubscribe manually when subscribing to `isStable`.

PR Close #59723
2025-04-02 18:26:06 +00:00
Alex Rickabaugh
a611b234d7 fix(core): run root effects in creation order (#60534)
Previously, the order in which root effects were executed was
non-deterministic and relied on the order in which signal graph dirty
notifications were propagated. With this commit, root effects are always run
in creation order.

PR Close #60534
2025-04-02 18:24:40 +00:00
Andrew Scott
0bb4bd661e feat(router): Add ability to directly abort a navigation (#60380)
This commit adds the ability to directly abort a navigation through the
`Router.getCurrentNavigation()?.abort()` method. While there are no
feature requests for this, it is a feature that will be necessary for
integration with the navigation API. The API enables better tracking of
an ongoing navigation for SPAs and a site visitor can cancel a
navigation by clicking the stop button in the browser. While this could
technically be done on the transition with an internal jsdoc comment to
hide it from application developers, there's no need.

With this feature, I believe it would be possible to create somewhat of a shim
to integrate with the navigation API even before the router has full support
using the router events to control a deferred navigation that never
commits the URL and always aborts itself on navigation end.

PR Close #60380
2025-04-02 17:30:27 +00:00
arturovt
5f7f04634f fix(core): call DestroyRef on destroy callback if view is destroyed (#58008)
In this commit, we introduce the ability to check whether `lView` has already been
destroyed in `NodeInjectorDestroyRef`. If the `lView` is already destroyed, we call
the on-destroy callback immediately, without trying to register it to be called later.
This ensures that any necessary cleanup is handled gracefully and provides better
reliability in managing resources.

One of the use cases is `takeUntilDestroyed`, which aims to replace `takeUntil` in existing
applications. While `takeUntil` can be safely called once the view is destroyed—resulting
in no errors and finalizing the subscription depending on whether a subject or replay
subject is used—replacing it with `takeUntilDestroyed` introduces a breaking change, as
it throws an error if the `lView` is destroyed.

Related issue: #54527

PR Close #58008
2025-04-02 15:24:48 +00:00
aparziale
6acce7ca2a fix(core): fixes #592882 ng generate @angular/core:signal-queries-migration (#60688)
fixes #592882 - retain accessibility modifier if it's already present for signal migrations

PR Close #60688
2025-04-02 15:14:43 +00:00
Pawel Kozlowski
b6897bb8c3 refactor(core): extract directive inputs update logic (#60690)
This refactor extracts all the logic required to update a single
directive input while running the update pass of a template. It
also adds a number of TODOs that hint on subsequent reqfactorings.

PR Close #60690
2025-04-02 15:08:36 +00:00
aparziale
cdbc6e8ec1 fix(core): fix ng generate @angular/core:output-migration (#60626)
output-migration command not keep type if @output declaring without initializer

PR Close #60626
2025-04-02 14:26:05 +00:00
Andrew Kushnir
84ba1ad878 refactor(core): drop unused ngDevMode metrics (#60686)
This commit updates the code to drop unused `ngDevMode` metrics and removes some related (and now unused) utility functions.

PR Close #60686
2025-04-02 14:17:10 +00:00
Matthieu Riegler
def8bdd229 build: remove orphan bundling symbols (#60692)
Those targets where removed by #60591 but the symbols files were left behind.

PR Close #60692
2025-04-02 11:34:53 +00:00
Matthieu Riegler
a69f5c557a docs: add targets for the bundling debug (#60693)
PR Close #60693
2025-04-02 11:33:52 +00:00
iteriani
e9c5e46a60 refactor(core): Check for ngMetadataName instead of instanceof. Wiz doesn't extend InjectionToken. (#60572)
In cases such as Wiz, we avoid using the InjectionToken class since it comes from @angular/core.

PR Close #60572
2025-04-01 19:21:33 +00:00
Andrew Scott
7b819be83f fix(core): Ensure errors in listeners report to the application error handler (#60251)
Practically speaking, this change ensures that Angular is able to make
decisions about what to do when an uncaught error happens.

For tests, this will mean that, by default, the error either causes the
`fixture.whenStable` promise to reject if there is one or rethrow the
error. This ensures tests do not accidentally ignore errors. Opting out
of this can be done with the `rethrowApplicationErrors: false` option in
`TestBed`.

For SSR, there may be additional behaviors in the future that we want to
add, such as redirecting to an error page or responding with a 500
status code.

BREAKING CHANGE: Uncaught errors in listeners which were previously only reported to
`ErrorHandler` are now also reported to Angular's internal error
handling machinery. For tests, this means that the error will be
rethrown by default rather than only logging the error. Developers
should fix these errors, catch them in the test if the test is
intentionally covering an error case, or use `rethrowApplicationErrors:
false` in `configureTestingModule` as a last resort.

PR Close #60251
2025-04-01 17:03:08 +00:00
Alex Rickabaugh
57a240b07e refactor(core): support an opt-in sync version of toObservable (#60640)
This commit adds a flag `forceSyncFirstEmit` which opts in to the pending
new behavior for `toObservable`, which emits the first value synchronously.
This flag is only really meant for use during a short migration period
while we update g3, and is not meant for prolonged usage. As a result, it's
marked deprecated.

PR Close #60640
2025-04-01 15:56:39 +00:00
Enea Jahollari
5db7e4cabb refactor(core): improve the messaging on effect manualCleanup option (#60426)
We always needs to pass an injector to an effect if it's used outside the injection context, even when manualCleanup option is true.

PR Close #60426
2025-04-01 14:07:03 +00:00
arturovt
2fe8f1a9de refactor(core): drop component factory error in production (#60601)
Drops component factory error in production. Couldn't capture it before because of `throw Error` (without `new`).

PR Close #60601
2025-04-01 13:12:34 +00:00
Kristiyan Kostadinov
accc65c2c9 refactor(migrations): add a migration to move DOCUMENT imports (#60663)
Adds a migration that moves imports of `DOCUMENT` from `common` to `core`.

PR Close #60663
2025-04-01 12:48:06 +00:00
Kristiyan Kostadinov
7ccec1494f feat(core): move DOCUMENT token into core (#60663)
Moves the `DOCUMENT` token from `common` into `core` since it's relevant for lots of SSR use cases and users shouldn't have to install `common` for it. The token is still exported through `common` for backwards compatibility.

PR Close #60663
2025-04-01 12:48:06 +00:00
Jessica Janiuk
d5a8a1c524 Revert "refactor(core): add ApplicationRef.prototype.bootstrapImpl with an injector parameter (#60622)" (#60669)
This reverts commit 7cb8639da9.

PR Close #60669
2025-04-01 12:18:52 +00:00
Doug Parker
7cb8639da9 refactor(core): add ApplicationRef.prototype.bootstrapImpl with an injector parameter (#60622)
This allows any components individually bootstrapped to inherit from a unique `Injector`. This is useful when bootstrapping multiple root components with different providers.

For now, the function is private while we explore potential designs to consolidate it with the existing `ApplicationRef.prototype.bootstrap` method.

PR Close #60622
2025-04-01 12:01:00 +00:00
Matt Turco
a4bad8d361 feat(core): export signalGetFn from signal primitives (#60497)
This updates `createSignal` to use `signalGetFn` to define the signal getter and exports `signalGetFn` from the shared signal primitives.

PR Close #60497
2025-03-31 22:24:21 +00:00
Vincent
d29adcc0b7 refactor(core): Make unsupported styling type error message clearer (#59563)
The previous message would sound like a full sentence when using a signal without `()` (Example: Unsupported styling type function: [Input Signal: neutral]). The new formatting makes it a bit more obvious that the type itself is the problem.

PR Close #59563
2025-03-31 21:31:42 +00:00
Andrew Kushnir
1fed7dc5a7 refactor(router): drop special handling of the OutletInjector (#58351)
This commit updates the OutletInjector and related code to avoid special handling of that injector. The main code that had special handling was refactored to no longer require is in https://github.com/angular/angular/pull/56763, this commit completes the cleanup.

PR Close #58351
2025-03-31 20:46:01 +00:00
Alex Rickabaugh
43cbc58254 fix(core): remove forceRoot flag for effects (#60535)
This flag is effectively unused in Angular code that we've seen, and is only
serving to complicate the mental model of effects. It could be reintroduced
if needed.

PR Close #60535
2025-03-31 18:08:07 +00:00
Kristiyan Kostadinov
9c106f4401 refactor(core): introduce domProperty instruction (#60608)
Renames the `hostProperty` instruction to `domProperty` since it's not really host-specific and we can use it for other DOM-specific operations in the future.

PR Close #60608
2025-03-31 13:15:19 +00:00
Kristiyan Kostadinov
8562667b0e refactor(core): separate out DOM logic from property (#60608)
Includes the following moves.
* Moves the DOM-specific logic from `elementPropertyInternal` into a separate function so we can reuse it.
* Uses the DOM-specific code for the `hostProperty` instruction.
* Removes the `nativeOnly` parameter from `elementPropertyInternal`.
* Renames `elementPropertyInternal` to `setPropertyAndInputs` so it's a bit more clear what the function is doing.

PR Close #60608
2025-03-31 13:15:19 +00:00
Andrew Kushnir
cbd6ec8c6a build: remove obsolete bundling test apps (#60591)
This commit removes a few bundling test apps that do not provide any value, but require time on CI and during local development to update golden files.

The functionality that was tested in those apps is covered by various other tests that we have in a repository (either in the same `packages/core/test/bundling` folder or in other unit/integration tests).

PR Close #60591
2025-03-28 18:45:31 +00:00
Jessica Janiuk
d15fda3e03 Revert "refactor(core): allow multiple DI profilers (#60562)" (#60611)
This reverts commit b21c6e5ac5.

PR Close #60611
2025-03-28 17:25:43 +00:00