Commit graph

5102 commits

Author SHA1 Message Date
Timon
1b6204dd2a docs(core): fix eventCoalescing comment (#57097)
PR Close #57097
2024-12-02 11:34:26 +01:00
Kristiyan Kostadinov
35165d152d fix(migrations): inject migration dropping code if everything except super is removed (#58959)
Fixes that in some cases the internal version of the migration was dropping code when all the statements after the `super` call are deleted.

PR Close #58959
2024-12-02 08:56:21 +01:00
Kristiyan Kostadinov
7191aa6e09 fix(migrations): don't migrate classes with parameters that can't be injected (#58959)
Updates the inject migrations to skip over classes that have uninjectable class parameters.

PR Close #58959
2024-12-02 08:56:21 +01:00
Kristiyan Kostadinov
68e5ba7a3a fix(migrations): preserve type literals and tuples in inject migrations (#58959)
Updates the inject migration to preserve type literals and tuple types, based on some internal feedback.

PR Close #58959
2024-12-02 08:56:21 +01:00
Kristiyan Kostadinov
a4924af6d5 fix(migrations): inject migration aggressively removing imports (#58959)
Fixes that the inject migration would remove imports even if they're still used by classes that aren't being migrated.

PR Close #58959
2024-12-02 08:56:21 +01:00
Kristiyan Kostadinov
508d3a1b3b fix(migrations): correctly strip away parameters surrounded by comments in inject migration (#58959)
Fixes that the inject migration was sometimes producing invalid code if there are comments around the parameters.

PR Close #58959
2024-12-02 08:56:21 +01:00
Kristiyan Kostadinov
e31e52e177 fix(migrations): class content being deleted in some edge cases (#58959)
Fixes that the inject migration was deleting the class' content if a property exists after the constructor that is being rewritten.

PR Close #58959
2024-12-02 08:56:20 +01:00
Gustav Blomqvist
d5f9d0284c docs(core): grammatical fix (#58204)
PR Close #58204
2024-11-28 17:38:35 +01:00
arturovt
a4b86b23cf refactor(core): preventing resolving renderer factory every tick (#58618)
Prevents the `RendererFactory2` from being resolved each time the tick runs, as it only needs to be requested once.

PR Close #58618
2024-11-28 15:17:28 +01:00
Kristiyan Kostadinov
f280467398 fix(compiler-cli): account for multiple generated namespace imports in HMR (#58924)
The current HMR compiler assumes that there will only be one namespace import in the generated code (`@angular/core`). This is incorrect, because the compiler may need to generate additional imports in some cases (e.g. importing directives through a module). These changes adjust the compiler to capture all the namespaces in an array and pass them along.

Fixes #58915.

PR Close #58924
2024-11-28 10:00:56 +01:00
arielbackenroth
3b765367f3 fix(core): Explicitly manage TracingSnapshot lifecycle and dispose of it once it's been used. (#58929)
Provide a callback to the TracingService implementation when a Snapshot can be disposed.
The underlying tracing implementation may use refcounting and needs to release resources
to enable the trace to complete.

While change detection uses the snapshot for exactly one callback, after render runs
multiple hooks in the sequence so we need a more predictable way to indicate that the snapshot
can be finalized.s

PR Close #58929
2024-11-27 18:11:13 +01:00
Jessica Janiuk
30891d8dec refactor(core): Consolidates shouldTrigger* methods down to one (#58833)
This cleans up the triggering code base and consolidates it down to one
function that outlines the logic. This also resolves the `hydrate when`
behavior issue.

fixes: #58709

PR Close #58833
2024-11-27 17:00:06 +01:00
Jessica Janiuk
38fe180d34 refactor(compiler): Adds ingest and flags for defer details (#58833)
This adds TDeferDetailsFlags to indicate the presence of hydration triggers, and any future flags we add to defer.

PR Close #58833
2024-11-27 17:00:05 +01:00
Vincent
4e4bbb00ad refactor(core): Make wording of effect-allowSignalWrites deprecation warning more accurate (#58792)
The previous warning contained a typo and also somewhat implied that allowSignalWrites did something. However, setting allowSignalWrites to false has no impact at all in Angular 19.

Closes #58790

PR Close #58792
2024-11-27 16:59:05 +01:00
Enea Jahollari
0c009077af refactor(docs-infra): use interpolation instead of innerHTML for better perf (#58913)
Using innerHTML will cause the browser to parse the HTML and then create a DOM tree instead of just using normal interpolation.

PR Close #58913
2024-11-27 10:59:18 +01:00
Alan Agius
0499e1b27d refactor(core): remove private whenStable (#58891)
The `@angular/ssr` package no longer depends on this symbol.

PR Close #58891
2024-11-26 18:10:50 +00:00
arielbackenroth
785c6116cc fix(core): Ensure _tick is always run within the TracingSnapshot. (#58881)
Fix a bug where calls to _tick are called without running through the snapshot.
This helps ensure that all snapshots that are requested are resumed.

PR Close #58881
2024-11-25 21:19:52 +00:00
Kristiyan Kostadinov
bd1f1294ae feat(core): support TypeScript 5.7 (#58609)
Updates the repo to allow for TypeScript 5.7 to be used.

PR Close #58609
2024-11-25 17:12:10 +00:00
Andrew Kushnir
c56ec5eef9 refactor(core): invoke setActiveConsumer in ɵɵdeferHydrateWhen at the right time (#58864)
This commit updates the code of the `ɵɵdeferHydrateWhen` function to invoke the `setActiveConsumer` function at the right time (currently, we invoke it in the `finally` block, which is too late).

PR Close #58864
2024-11-25 16:12:37 +00:00
Andrew Kushnir
f6a84f0224 refactor(core): remove unused field in ApplicationRef class (#58864)
This commit removes an unused field in the `ApplicationRef` class. Most likely the usage of the field was removed earlier.

PR Close #58864
2024-11-25 16:12:37 +00:00
Matthieu Riegler
901fd1c09b fix(core): Ensure resource sets an error (#58855)
Before this commit, a resource with a previous value wouldn't set the error state correctly.
This commit fixes this. A resource will set its status to error even when there was a previous valid value.

PR Close #58855
2024-11-25 15:28:17 +00:00
Matthieu Riegler
58c0b36d84 docs: add standalone example for ErrorHandler (#58859)
fixes #55579

PR Close #58859
2024-11-25 15:26:50 +00:00
Kristiyan Kostadinov
4f1f4a1728 refactor(migrations): skip TS version check in tsurge (#58866)
Skips the TS version check in tsurge since it's blocking some internal changes and generally isn't necessary since the app will be checked when it's built anyways.

PR Close #58866
2024-11-25 15:26:18 +00:00
Andrew Kushnir
7f6f5f95ea refactor(core): use ApplicationRef.whenStable instead of a custom util function (#58834)
This commit removes a custom `whenStable` util in favor of standard `ApplicationRef.whenStable` API.

There is also an important different between the custom `whenStable` function and `ApplicationRef.whenStable` implementation: the `whenStable` was caching the "stable" promise on per-ApplicationRef basis, which resulted in unexpected behavior with zoneless, when some code ended up getting a stale resolved promise, when an application was not stable yet, this causing order of operations issues. This commit also has an extra test that covers that case.

PR Close #58834
2024-11-25 15:25:10 +00:00
kirjs
15f07166eb refactor(core): make lView[Injector] non-nullable (#58805)
There actually no cases, where it can be null. Also update all usages.

PR Close #58805
2024-11-25 15:24:40 +00:00
Andrew Kushnir
834c7c3ccc fix(core): make component id generation more stable between client and server builds (#58813)
For components with i18n in templates, the `consts` array is generated by the compiler as a function. If client and server bundles were produced with different minification configurations, the serializable contents of the function body would be different on the client and on the server. This might result in different ids generated. To avoid this issue, this commit updates the logic to not take the `consts` contents into account if it's a function.

Resolves #58713.

PR Close #58813
2024-11-22 19:36:50 +00:00
Jessica Janiuk
bd08d1ddac fix(core): Prevents race condition of cleanup for incremental hydration (#58722)
When hydrating a tree of blocks, this prevents cleanup from firing more than once per tree. It also ensures the cleanup happens after hydration has finished.

fixes: #58690

PR Close #58722
2024-11-21 21:39:37 +00:00
Younes Jaaidi
1fe001e18b fix(migrations): fix provide-initializer migration when using useFactory (#58518)
Priori to this commit, initializer functions with dependencies were not migrated correctly.
With this commit, the function is executed in a injection context to allow the usage of `inject`.

PR Close #58518
2024-11-21 20:59:35 +00:00
Ryan Russell
3fc14ecc81 fix(migrations): Mark hoisted properties as removed in inject migration (#58804)
Before, in a situation like shown in the test, all of the initializers
would be dropped, as the code would try to insert it at the hoisted
property which is going to be deleted.

PR Close #58804
2024-11-21 20:58:26 +00:00
JoostK
21f757c1c4 fix(core): correctly perform lazy routes migration for components with additional decorators (#58796)
This fixes an issue where the lazy-routes migration would crash for component classes a
decorator without arguments in front of the `@Component` decorator (in particular, it needed
to be the first decorator).

Fixes #58793

PR Close #58796
2024-11-21 16:43:30 +00:00
Kristiyan Kostadinov
7eeae9f170 refactor(core): adjust tracing service (#58771)
Adjusts the tracing service based on internal requirements.

PR Close #58771
2024-11-21 16:34:53 +00:00
Alex Rickabaugh
d27f97ddab refactor(core): introduce TracingService for snapshot-based tracing (#58771)
This commit introduces a private API, the `TracingService` DI token. By
providing this token, Angular can be configured to capture tracing snapshots
for certain operations such as change detection notifications, and to run
downstream operations within the context of those snapshots.
`TracingService` abstracts this context propagation and makes it pluggable.

PR Close #58771
2024-11-21 16:34:53 +00:00
Mark Axisa
6ad30593b9 docs(core): add descriptive usage line for projectableNodes param in createComponent docs (#58727)
PR Close #58727
2024-11-20 08:12:32 -08:00
Kristiyan Kostadinov
18991d3210 fix(migrations): handle parameters with initializers in inject migration (#58769)
Adds some logic to the `inject()` migration that allows is to handle parameter declarations with initializers. This was omitted initially, because we don't officially support such cases, but it came up internally.

PR Close #58769
2024-11-20 08:07:39 -08:00
Charles Lyding
d33af5cba6 fix(core): correctly clear template HMR internal renderer cache (#58724)
The internal renderer cache within the renderer factory was not being
correctly cleared due to a type-casting error. This prevented template
HMR from correctly updating the component. A more explicity cast has
now been used to mitigate this problem.
Component template HMR is currently considered experimental.

PR Close #58724
2024-11-19 12:18:39 -08:00
Pawel Kozlowski
2a767a306e refactor(core): mark linkedSignal as developer preview (#58684)
This commit bumps up the stability status of the linkedSignal
to developer preview - clearly expressing our highier confidence
in this API.

PR Close #58684
2024-11-15 14:15:20 +01:00
cexbrayat
2eb4afe2b3 fix(migrations): do not migrate next calls in template if not an EventEmitter (#58631)
Fixes #58630

```html
<button (click)="someSubject.next()">Click</button>
```

was migrated to an `.emit` call, even if `someSubject` was not an `EventEmitter`.

The issue was the same in host listeners.

PR Close #58631
2024-11-15 14:13:52 +01:00
Andrew Kushnir
a55341b1ab refactor(core): add REQUEST, RESPONSE_INIT and REQUEST_CONTEXT tokens (#58669)
This commit introduces the `REQUEST`, `RESPONSE_INIT` and `REQUEST_CONTEXT` tokens, which will replace similar ones from 2850318623/packages/angular/ssr/tokens/src/tokens.ts, so those tokens would be imported in application code via `@angular/core` package.

PR Close #58669
2024-11-14 14:21:21 -08:00
Jessica Janiuk
0dc87575a0 refactor(core): add performance feature flag for incremental hydration (#58658)
This adds a flag for incremental hydration to get usage statistics.

PR Close #58658
2024-11-14 15:07:39 +00:00
Jessica Janiuk
292d819e92 fix(core): fixes issues with control flow and incremental hydration (#58644)
If a defer block is nested inside control flow while also being nested
underneath a defer block all using incremental hydration, timing issues
prevented the child nodes from being properly hydrated. This ensures
hydration happens on next render.

PR Close #58644
2024-11-14 14:59:53 +00:00
cexbrayat
ecd107b2e3 refactor(migrations): typos in signal migration incompatibility reasons (#58636)
A dot was appearing in the middle of the comment for `DerivedIsIncompatible`.
While at it, a dot was missing in `ClassManuallyInstantiated`.

PR Close #58636
2024-11-14 14:55:04 +00:00
Kristiyan Kostadinov
89256e6868 fix(migrations): replace removed NgModules in tests with their exports (#58627)
In #57684 the standalone migration was changed so that it replaces any leftover modules with their `exports`, in an attempt to preserve more working code. These changes expand that logic to also cover tests since it's somewhat common internally to only import a component's module without having any references to the component.

Note that tests are a bit of a special case, because we don't have access to the template type checker, so instead we copy over all of the `exports` of that module.

PR Close #58627
2024-11-13 18:04:31 +00:00
cexbrayat
579f613a58 fix(migrations): include the output migration in the defaults of the signal migration (#58635)
Running `ng g @angular/core:signals` prompts for the question on which migration to run and offers 3 options (inputs, outputs, queries).
Running with `--defaults` skips the prompts, but only runs 2 of them.
This fixes it by including the `outputs` migration in the default ones.

PR Close #58635
2024-11-13 18:03:58 +00:00
Jessica Janiuk
f3d9316275 refactor(core): moves incremental hydration codebase to better locations (#58616)
This eliminates the extra incremental.ts codepath and moves its functions to appropriate locations.

PR Close #58616
2024-11-12 22:25:27 +00:00
Kristiyan Kostadinov
c421ffdbfb fix(compiler): control flow nodes with root at the end projected incorrectly (#58607)
Fixes an edge case where a control flow node that has non-projectable nodes followed by an element node at the end would cause the entire control flow node to be project. For example if we have a projection target of `Main: <ng-content/> Slot: <ng-content select="[foo]"/>`, inserting a node of `@if (true) {Hello <span foo>world</span>}` would project the entire `Hello world` into the `[foo]` slot.

In the process of working on the issue, I also found that `@let` declarations at the root of the control flow node would prevent content projection as well.

PR Close #58607
2024-11-12 18:05:00 +00:00
Jessica Janiuk
f2bda8e3fc fix(core): prevent errors on contract cleanup (#58614)
If contract cleanup is called more than once, the assertion that the container manager will be present results in exceptions.

PR Close #58614
2024-11-12 17:25:50 +00:00
arturovt
4df352b77e fix(core): clean up event contract once hydration is done (#58174)
In this commit, we clean up the event contract once hydration is complete, which removes event
listeners registered through the container manager. If we do not clean up the contract, the listeners
will remain on the `document.body`. When incremental hydration is enabled, we cannot clean up the event
contract immediately; instead, we schedule its cleanup when the app is destroyed. This is because the
event contract is required for deferred blocks, of which we are unaware, that need to be hydrated.

PR Close #58174
2024-11-12 15:05:45 +00:00
Jessica Janiuk
e3343620b5 test(core): add incremental hydration tests (#58601)
This adds some additional tests for incremental hydration around registry and contract cleanup.

PR Close #58601
2024-11-12 14:49:06 +00:00
Kristiyan Kostadinov
7e5f705213 refactor(migrations): handle fake async catalyst (#58608)
Fixes that the standalone migration wasn't handling the `fake_async` path for Catalyst.

PR Close #58608
2024-11-12 14:45:40 +00:00
Jessica Janiuk
42c99763f5 refactor(core): reorganize defer codebase (#58598)
This moves all the helpers out of the instructions file, keeping the instructions limited to the actual instruction set. This adds files for defer block rendering functions and triggering functions, respectively.

PR Close #58598
2024-11-11 19:11:02 +00:00