Commit graph

12909 commits

Author SHA1 Message Date
Kristiyan Kostadinov
ebfbaeba54 fix(core): capture stack for HMR errors (#60067)
Currently we send the `message` of an error thrown during HMR. That's usually not enough so now we also capture the stack trace.

Relates to https://github.com/angular/angular-cli/issues/29695.

PR Close #60067
2025-02-24 11:56:17 -05:00
Kristiyan Kostadinov
35d20cb4b4 refactor(core): do not store input/output public names (#60036)
Reworks the `TNode.inputs` and `TNode.outputs` to not store the public names of bindings. The only reason they were stored was for host directive re-aliasing which is handled through a different data structure now.

PR Close #60036
2025-02-21 14:07:35 -05:00
Kristiyan Kostadinov
352021e1d2 refactor(core): separate host directive inputs from selector-matched ones (#60036)
Currently `TNode.inputs`/`TNode.outputs` store all of the available bindings on that node, no matter if they came from a directive that the user applied directly or from a host directive. This has a couple of drawbacks:
1. We need to store more information that necessary. For example, the only reason we have strings in the arrays is to facilitate host directive aliasing.
2. It doesn't allow us to distinguish which host directives belong to which selector-matched directives.

These changes are a step towards resolving both issues by storing the host directive binding information in separate data structures.

PR Close #60036
2025-02-21 14:07:35 -05:00
Kristiyan Kostadinov
285abbb38f refactor(core): rework how inputs/outputs are initialized (#60036)
Reworks the functions that create the `initialInputs`, `inputs` and `outputs` structures to initilize them within the function, instead of returning them to be initialized later. This will simplify future refactors where they'll produce more than one piece of information.

PR Close #60036
2025-02-21 14:07:35 -05:00
Jessica Janiuk
3fd6551cae docs: remove todo from jsdoc (#60042)
This removes TODO from a JSDoc block that made it show up on adev.

PR Close #60042
2025-02-21 11:16:48 -05:00
Pawel Kozlowski
ea8662ab3e refactor(core): remove duplicated checks for ngNonBindable (#60048)
This refactoring consolidates logic around detecting ngNonBindable
mode - previously those checks were done in two separate places.
By doing the check in one place we can simplify the directive resolution
logic.

PR Close #60048
2025-02-21 11:08:50 -05:00
Jessica Janiuk
1d28a42815 refactor(core): clean up when blocks fail to fetch or hydrate (#59740)
There are cases where resources fail to fetch or the DOM has changed due to an if block. This should clean up the remaining promises and any registry references to those blocks in that case.

PR Close #59740
2025-02-21 11:08:04 -05:00
arturovt
21740846b5 refactor(core): drop platform check in ImagePerformanceWarning (#59809)
Replaces `PLATFORM_ID` checks with `ngServerMode`.

PR Close #59809
2025-02-20 12:32:23 -05:00
Trevor Florence
7a1bf0610e fix(benchpress): Ensure future-proof correct initialization order (#60025)
Future changes to initialization order can cause this previously OK code to start having compiler erroring like: `TS2729: Property 'foo' is used before its initialization.`

PR Close #60025
2025-02-20 11:21:55 -05:00
Miles Malerba
347c3d5761 build: remove circular deps goldens (#60021)
Removes the circular dependencies golden file and cleans up the
associated pullapprove group. All circular dependencies have been
removed and no new ones may be added.

PR Close #60021
2025-02-19 21:01:32 +00:00
Andrew Scott
f88ed8e470 refactor(core): Add fake navigation to primitives for code sharing (#59857)
This moves the `FakeNavigation` implementation to the primitives folder
so its implementation can be shared with Wiz. This class was initially
copied directly from the Wiz implementation, with some small modifications.
There will still need to be some work done to align the implementations
and fix anything internally that needs adjusting.

PR Close #59857
2025-02-19 20:09:10 +00:00
arturovt
40dc99da9c refactor(common): inline supports check in slice pipe (#59684)
The refactored version improves the original code by removing the `supports` method from the prototype and inlining the logic directly into the `transform` method. This reduces indirection and simplifies the class, especially since `supports` is not reused elsewhere. ESBuild can directly inline the condition into the `if` statement by removing the variable: `if (!("string" == typeof e || Array.isArray(e))) throw i(s, e);`.

PR Close #59684
2025-02-19 15:22:49 +00:00
arturovt
b2947e83f7 refactor(forms): remove _checkFormPresent and move directly to ngOnChanges (#59741)
In this commit, we remove `_checkFormPresent` because it is a no-op in production. We move its body directly into `ngOnChanges` to eliminate the redundant method from the prototype. Previously, `_checkFormPresent` was being called with no body in production each time `ngOnChanges` was executed.

PR Close #59741
2025-02-19 15:22:13 +00:00
arturovt
cf3a5073ec refactor(core): improve stringify (#59745)
In this commit, we improve branching in the `stringify` function, which is widely used by the framework, and add additional comments for clarification. Benchmark results of the old and new implementations (using `slice` makes it slightly faster) are as follows:
```
stringify (old version) x 117,945,419 ops/sec ±5.25% (55 runs sampled)
stringify (new version) x 136,692,820 ops/sec ±4.82% (56 runs sampled)
```

PR Close #59745
2025-02-19 15:21:36 +00:00
arturovt
967488247e refactor(common): simplify stripTrailingSlash (#59746)
The new version of the function is smaller, eliminating extra bytes. The refactor improves both code size and readability while optimizing the implementation. Benchmark results for the old and new implementations are as follows:

```
stripTrailingSlash_old x 15,446,602 ops/sec ±0.89% (66 runs sampled)
stripTrailingSlash_new x 19,694,523 ops/sec ±1.10% (61 runs sampled)
```

Thus, the new implementation is both smaller and faster.

PR Close #59746
2025-02-19 15:20:53 +00:00
Matthieu Riegler
cf36951f83 fix(forms): Fix typing on FormRecord. (#59993)
Priori to this change, `ɵRawValue` of a `FormRecord` returned a `Partial`. This commit fixes it.

fixes #59985

PR Close #59993
2025-02-18 19:28:36 +00:00
Kristiyan Kostadinov
f41437e6f5 refactor(core): simplify serialization of inputs and outputs (#59980)
Simplifies the functions that serialize inputs/outputs for the `ComponentFactory` type.

PR Close #59980
2025-02-18 19:28:00 +00:00
Kristiyan Kostadinov
86610f7bad build: update bundle goldens (#59980)
Updates the bundle goldens to account for the latest changes.

PR Close #59980
2025-02-18 19:28:00 +00:00
Kristiyan Kostadinov
9c6a0e5f01 refactor(core): add assertion to avoid writes to directive factories (#59980)
Attempting to write to directive inputs before the directive is created can lead to subtle issues that won't necessarily trigger errors. These changes add an assertion to catch such issues earlier.

PR Close #59980
2025-02-18 19:28:00 +00:00
Kristiyan Kostadinov
1b0fdc7eb1 refactor(core): avoid unnecessary lookup when writing inputs (#59980)
Currently we resolve the DOM node when writing inputs up-front, because it's necessary for the `ng-reflect-` attributes. Since the attributes are dev-mode-only, we can move the resolution into the function that writes them so we can avoid the resolution when it's not used.

PR Close #59980
2025-02-18 19:28:00 +00:00
Kristiyan Kostadinov
6a7fd11386 refactor(core): simplify InitialInputs data structure (#59980)
Reworks the `InitialInputs` data structure to only store a public name and initial value, resulting in less memory usage and making it easier to work with.

PR Close #59980
2025-02-18 19:28:00 +00:00
Kristiyan Kostadinov
5acdc6bd59 refactor(core): remove flags from TNode.inputs (#59980)
The input flags are already available on the definition so we don't need to store them on `TNode.inputs`.

PR Close #59980
2025-02-18 19:27:59 +00:00
Kristiyan Kostadinov
db530856a8 refactor(compiler): remove input transforms feature (#59980)
An earlier refactor made the `InputTransformsFeature` a no-op so these changes remove the code that was generating it.

PR Close #59980
2025-02-18 19:27:59 +00:00
Kristiyan Kostadinov
86086604f4 refactor(core): remove inputTransforms from definition (#59980)
Removes the `inputTransform` from the directive definition since this information is already available on the `inputs`.

PR Close #59980
2025-02-18 19:27:59 +00:00
Kristiyan Kostadinov
b8ad4c2117 refactor(core): simplify how inputs are stored in the directive definition (#59980)
Currently the values in `DirectiveDef.inputs` are either strings or arrays, depending if there are flags. This makes it a bit hard to work with, because each time it's read, the consumer needs to account for both cases.

These changes rework it so the values are always an arrays.

PR Close #59980
2025-02-18 19:27:59 +00:00
Enea Jahollari
1cd3a7db83 feat(migrations): add migration to convert templates to use self-closing tags (#57342)
This schematic helps developers to convert their templates to use self-closing tags mostly as a aesthetic change.

PR Close #57342
2025-02-18 17:33:59 +00:00
Pawel Kozlowski
c076b57986 refactor(core): move LContainer manipulation logic to its own file (#59856)
All the view in a container logic is in the
packages/core/src/render3/view/container.ts file
plus some other associated refactorings.

PR Close #59856
2025-02-18 15:41:42 +00:00
Angular Robot
3bfa85f5c8 build: lock file maintenance (#59836)
See associated pull request for more information.

PR Close #59836
2025-02-18 15:41:09 +00:00
arturovt
7bd4be0fa5 fix(common): clean up urlChanges subscribers when root scope is destroyed (#59703)
In this commit, the `urlChanges` subject is completed to release all active observers when the root scope is destroyed. Previously, subscribing to the `urlChanges` subject caused the subscriber to capture `this`, resulting in a memory leak after the root scope was destroyed.

PR Close #59703
2025-02-18 15:40:19 +00:00
Matthieu Riegler
5b20bab96d feat(compiler): Add Skip Hydration diagnostic. (#59576)
The diagnostic was created in #49512 but was never added to the list of diagnostic that run.

fixes #59569

PR Close #59576
2025-02-18 14:54:51 +00:00
Angular Robot
751dc4ad5b build: update babel dependencies to v7.26.9 (#59743)
See associated pull request for more information.

PR Close #59743
2025-02-14 19:15:15 +00:00
Alex Rickabaugh
3e39da593a feat(common): introduce experimental httpResource (#59876)
`httpResource` is a new frontend to the `HttpClient` infrastructure. It
declares a dependency on an HTTP endpoint. The request to be made can be
reactive, updating in response to signals for the URL, method, or otherwise.
The response is returned as an instance of `HttpResource`, a
`WritableResource` with some additional signals which represent parts of the
HTTP response metadata (status, headers, etc).

PR Close #59876
2025-02-14 18:40:37 +00:00
Andrew Scott
e7c6ecc955 refactor(benchpress): move initializer to constructor (#59960)
Move the initializer into the constructor for instance members that reference identifiers declared in the constructor.

When TypeScript outputs modern language features, the below case throws an TS error.

PR Close #59960
2025-02-14 18:39:58 +00:00
Jessica Janiuk
1ebf7bfb23 ci: fix flakey incremental hydration test (#59945)
This extends the test timeout for the two timer tests while shortening the actual hydrate on timer. This hopefully should result in more reliable CI.

PR Close #59945
2025-02-13 22:35:04 +00:00
iteriani
8b757bf35c refactor(core): Check in some interfaces for the DI package (#59921)
This will be the starting point of the DI package. We will first check in some interfaces and then make sure the existing DI package implements that interface. Afterwards, we'll slowly start moving injector implementation.

PR Close #59921
2025-02-13 20:19:29 +00:00
Matt Turco
2588985f43 feat(core): pass signal node to throwInvalidWriteToSignalErrorFn (#59600)
Updates the signature of the `throwInvalidWriteToSignalError` to take the signal node in question and pass it along to the throwInvalidWriteToSignalErrorFn handler function. This allows the handler to e.g. include the signal name in error messaging.

PR Close #59600
2025-02-13 17:56:14 +00:00
JoostK
973033abd2 fix(compiler-cli): avoid crash in isolated transform operations (#59869)
The CLI uses the `ts.transform` API to apply the Angular compiler's transformers
on the source files when `isolatedModules` is true (and various other constraints)
instead of going through a full `ts.Program.emit` operation. This results in the
transformers to operate in an environment where no emit resolver is available, which
was not previously accounted for. This commit reflects the possibility for the emit
resolver to be missing and handles this scenario accordingly.

Fixes #59837

PR Close #59869
2025-02-13 16:39:04 +00:00
arturovt
f34aeaeaad refactor(common): remove redundant transferCacheInterceptorFn dependencies (#59819)
The `transferCacheInterceptorFn` injects dependencies in itself; the `TransferCache` and cache options are redundant in the `deps` list.

PR Close #59819
2025-02-13 15:11:19 +00:00
arturovt
20f5dc5103 refactor(core): simplify concatStringsWithSpace (#59820)
The new version of the function is smaller, eliminating extra bytes. The refactor improves both code size and readability while optimizing the implementation. Benchmark results for the old and new implementations are as follows:

```
concatStringsWithSpace_old x 149,225,311 ops/sec ±8.54% (50 runs sampled)
concatStringsWithSpace_new x 160,206,834 ops/sec ±5.72% (54 runs sampled)
```

Thus, the new implementation is both smaller and faster.

PR Close #59820
2025-02-13 15:10:42 +00:00
Miles Malerba
6789c7ef94 fix(core): Defer afterRender until after first CD (#59455) (#59551)
This reverts commit ac2dbe3eb1.

PR Close #59551
2025-02-12 12:20:04 -08:00
Miles Malerba
c87e581dd9 fix(core): Don't run effects in check no changes pass (#59455) (#59551)
This reverts commit 21f1ba22a6.

PR Close #59551
2025-02-12 12:20:04 -08:00
Kristiyan Kostadinov
9e847fc60d fix(compiler): handle tracking expressions requiring temporary variables (#58520)
Currently when we generate the tracking expression for a `@for` block, we process its expression in the context of the creation block. This is incorrect, because the expression may require ops of its own for cases like nullish coalescing or safe reads. The result is that while we do generate the correct variable, they're added to the creation block rather than the tracking function which causes an error at runtime.

These changes address the issue by keeping track of a separate set of ops for the `track` expression that are prepended to the generated function, similarly to how we handle event listeners.

Fixes #56256.

PR Close #58520
2025-02-12 09:56:08 -08:00
Kristiyan Kostadinov
aa285c548c fix(migrations): account for let declarations in control flow migration (#59861)
Fixes that the control flow migration wasn't accounting for `@let` when determining which symbols are used.

PR Close #59861
2025-02-12 09:45:14 -08:00
Kristiyan Kostadinov
1119f85ca9 fix(migrations): count used dependencies inside existing control flow (#59861)
Fixes that the control flow migration wasn't checking the content of pre-existing control flow nodes for dependencies.

Fixes #59846.

PR Close #59861
2025-02-12 09:45:14 -08:00
Kristiyan Kostadinov
5cd26a9420 fix(compiler-cli): handle deferred blocks with shared dependencies correctly (#59926)
When the compiler analyzes the defer blocks in a component, it generates two sets of dependencies: ones specific for each block and others from all the deferred blocks within the component. The logic that combines all the defer block dependencies wasn't de-duplicating them which resulted in us producing `setClassMetadataAsync` calls where the callback can have multiple parameters with the same name. This was a problem both in full and partial compilation, but the latter was more visible, because Babel throws an error in such cases.

These changes add some logic to de-duplicate the dependencies so that we produce valid code.

Fixes #59922.

PR Close #59926
2025-02-12 09:15:53 -08:00
Kristiyan Kostadinov
b0266bda4a fix(core): invalidate HMR component if replacement throws an error (#59854)
Integrates https://github.com/angular/angular-cli/pull/29510 which allows us to invalidate the data in the dev server for a component if a replacement threw an error.

PR Close #59854
2025-02-12 09:05:30 -08:00
Kristiyan Kostadinov
e47c1e5abe refactor(compiler): pass more information to HMR replacement function (#59854)
Adjusts the code we generate for HMR so that it passes in the HMR ID and `import.meta` to the `replaceMetadata` call. This is necessary so we can do better logging of errors.

PR Close #59854
2025-02-12 09:05:30 -08:00
Alex Rickabaugh
b592b1b051 fix(core): fix race condition in resource() (#59851)
The refactoring of `resource()` to use `linkedSignal()` introduced the
potential for a race condition where resources would get stuck and not update
in response to a request change. This occurred under a specific condition:

1. The request changes while the resource is still in loading state
2. The resource resolves the previous load before its `effect()` reacts to the
   request change.

In practice, the window for this race is small, because the request change in
(1) will schedule the effect in (2) immediately. However, it's easier to
trigger this sequencing in tests, especially when one resource depends on the
output of another.

To fix the race condition, the resource impl is refactored to track the request
in its state, and ignore resolved values or streams for stale requests. This
refactoring actually makes the resource code simpler and easier to follow as
well.

Fixes #59842

PR Close #59851
2025-02-05 15:01:02 -08:00
Miles Malerba
a299e02e91 fix(core): preserve tracing snapshot until tick finishes (#59796)
This change waits until the end of `tick` to clear the tracing snapshot.
This ensures that if we notify the scheduler during `tick` the correct
tracing snapshot is used.

PR Close #59796
2025-02-05 09:00:49 -08:00
Jeremias Peier
fa0c3e3210 feat(forms): support type set in form validators (#45793)
Previously, using `Validators.required`, `Validators.minLength` and `Validators.maxLength` validators don't work with sets because a set has the `size` property instead of the `length` property. This change enables the validators to be working with sets.

PR Close #45793
2025-02-05 08:59:55 -08:00