Commit graph

2982 commits

Author SHA1 Message Date
Thomas Nguyen
40fb81fd0e refactor(core): Add global event delegation provider (#56247)
This replaces all addEventListener calls with a stashing function,
and installs an event listener on the document body to retrieve
the stashed function;

PR Close #56247
2024-06-27 14:24:47 +00:00
Tom Wilkinson
1d28fbb84c refactor(core): Use ActionResolver in Dispatcher. (#56369) (#56369)
`EventContract` usages in Angular now use `false` for
`useActionResolver`. Tests have been updated, with functionality that
depends on `ActionResolver` moving to dispatcher_test.ts.

PR Close #56369

PR Close #56369
2024-06-26 08:49:30 -07:00
Kristiyan Kostadinov
7dfe302f47 refactor(core): support let declarations during hydration (#56527)
Updates the hydration logic to account for the fact that let declarations don't create a DOM node.

PR Close #56527
2024-06-26 08:48:31 -07:00
Kristiyan Kostadinov
bbe39c1738 refactor(core): integrate let instructions into the runtime (#56527)
Adds the implementation of the following new instructions:
* `declareLet` - creation-time instruction that initializes the slot for a let declaration.
* `storeLet` - update-time instruction that stores the current value of a let declaration.
* `readContextLet` - instruction that reads the stored value of a let declaration from a different view.

On top of the instructions, it also introduces a new `LetDeclaration` TNode type.
The new TNode is nececessary for DI to work correctly in pipes inside the let expression,
as well as for proper hydration support.

PR Close #56527
2024-06-26 08:48:31 -07:00
Matthieu Riegler
5be16d06bd fix(core): prevent calling devMode only function on @defer error. (#56559)
`getTemplateLocationDetails()` is a devMode only function and should guarded by `ngDevMode` or calling it will throw an error.

fixes #56558

PR Close #56559
2024-06-25 09:17:33 -07:00
Gerald Monaco
29ca6d10cc fix(core): improve support for i18n hydration of projected content (#56192)
When collecting nodes from the DOM for hydration, we need to treat nodes with paths (e.g. content projection) as the new root for all subsequent elements, not just the next one.

Additionally, when using content projection it's possible for translated content to become disconnected, e.g. when it doesn't match a selector and there isn't a default. We need to handle such cases by manipulating the disconnected node data associated with hydration as usual.

PR Close #56192
2024-06-20 14:59:57 -07:00
Andrew Kushnir
e20c6df65e refactor(core): use performance API for Event Replay (#56509)
This commit adds a standard performance marker that can be viewed in Chrome dev tools and other tooling.
See more info at https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark

PR Close #56509
2024-06-20 08:53:18 -07:00
Andrew Kushnir
bf6df6f186 fix(core): do not activate event replay when no events are registered (#56509)
This commit adds extra checks to handle a situation when an application has no events configured, but the Event Replay feature was enabled. This situation can happen when some routes in an application are mostly static, when other routes are more interactive.

Resolves #56423.

PR Close #56509
2024-06-20 08:53:18 -07:00
cexbrayat
86bcfd3e49 fix(core): improve docs on afterRender hooks (#56522)
This commit fixes a typo in the `AfterRenderPhase` deprecation warning and improves the documentation of the options parameter of the afterRender hooks (which are now all named `options` instead of being called `opts` in some functions and `options` in others).

PR Close #56522
2024-06-20 08:51:35 -07:00
arturovt
39df5fa9d2 refactor(core): missing space in zoneless warning (#56491)
There's currently a missing space in the zoneless warning, showing words together.

PR Close #56491
2024-06-20 08:49:39 -07:00
Kristiyan Kostadinov
64990a50ed refactor(compiler): integrate let declarations into the template pipeline (#56299)
These changes integrate let declarations into the template pipeline. This involves a few operations:
* Producing a `declareLet` instruction call at creation time to initialize the declaration.
* Producing a `storeLet` instruction call in the place of the let declaration, including the necessary `advance` calls beforehand.
* For let declarations used within their declaration view, moving the `const` to be placed right after the `storeLet` call to ensure the their value has been computed.
* For let declarations that are _only_ used in their declaration view, removing the `storeLet` call and inlining the expression into the constant statement.

PR Close #56299
2024-06-20 08:48:52 -07:00
Andrew Kushnir
088e6c73bf refactor(core): avoid exposing OutletInjector in injector resolution path (#56394)
Router's `OutletInjector` required a special handling in cases when `@defer` is used, see https://github.com/angular/angular/pull/55374 for additional info. As a result, the `ChainedInjector` that represents an `OutletInjector` instance is currently exposed via `getInjectorResolutionPath` function. This creates a problem, because other debug APIs used by DevTools can not interact with `ChainedInjector`s. This commit updates the logic around `getInjectorResolutionPath` utility to avoid exposing `OutletInjector`in the resolution path.

Resolves #56331.

PR Close #56394
2024-06-17 09:05:11 -07:00
Paul Gschwendtner
4bc99f0bdf refactor(core): ModelSignal should extend InputSignal (#56452)
This allows for helpers like the following to work intuitively for all
types of "input fields". It also establishes the intended mental
philosophy that a model is both an input and an output.

```ts
/** Unwraps all signal input properties. */
export type UnwrapSignalInputs<T> = {
  [K in keyof T]: T[K] extends InputSignalWithTransform<any, infer WriteT>
    ? WriteT
    : T[K];
};
```

PR Close #56452
2024-06-17 08:59:58 -07:00
Matthieu Riegler
ce8853e5af docs(core): remove the doc link for NG0952 (#56441)
We don't have any docs yet for that error, so I'm removing the minus sign which indicate that there is a dedicated error doc.

Fixes #56424

PR Close #56441
2024-06-14 10:05:00 -07:00
Andrew Kushnir
fca5764564 Revert "refactor(core): Use ActionResolver in Dispatcher. (#56369)" (#56440)
This reverts commit 4ebd2853fa.

PR Close #56440
2024-06-13 12:17:35 -07:00
Paul Gschwendtner
352e0782ec feat(core): expose signal input metadata in ComponentMirror (#56402)
This commit starts exposing `isSignal` for inputs in the
`ComponentMirror`. We initially had this as a draft when rolling out
signal inputs, but there were no good use-cases, so we skipped it.

Now, inside G3, for the testing infrastructure and rolling out
advancements for signal inputs, having this information is necessary and
allows identifying signal inputs without "accessing fields" on the class
that may cause side-effects (like triggering setters).

PR Close #56402
2024-06-13 10:12:06 -07:00
Tom Wilkinson
4ebd2853fa refactor(core): Use ActionResolver in Dispatcher. (#56369)
`EventContract` usages in Angular now use `false` for
`useActionResolver`. Tests have been updated, with functionality that
depends on `ActionResolver` moving to dispatcher_test.ts.

PR Close #56369
2024-06-13 08:50:45 -07:00
Andrew Kushnir
71c9609298 refactor(core): inject PendingTasks as optional in EventEmitter class (#56411)
This commit makes `PendingTasks` dependency in the `EventEmitter` class optional to make sure this code works with various test setups.

PR Close #56411
2024-06-12 13:10:40 -07:00
Andrew Scott
d5c6ee432f fix(core): async EventEmitter should contribute to app stability (#56308)
async `EventEmitter` should contribute to app stability.

fixes #56290

PR Close #56308
2024-06-11 15:10:21 -07:00
Andrew Scott
4c7d5d8acd fix(core): signals should be tracked when embeddedViewRef.detectChanges is called (#55719)
This commit fixes an issue where signals in embedded views are not
tracked if they are refreshed with `EmbeddedViewRef.detectChanges`
directly. We had previously assumed that embedded views were always
refreshed along with their hosts.

PR Close #55719
2024-06-11 12:35:02 -07:00
Miles Malerba
38effcc63e fix(core): Add back phase flag option as a deprecated API (#55648)
Adds back the ability to set the phase of an `afterRender` /
`afterNextRender` callback using the `phase` option. However, this API
is now deprecated, and the phase should instead be specified by passing
a spec object rather than a callback function.

PR Close #55648
2024-06-10 13:53:39 -07:00
Miles Malerba
a655e46447 feat(core): Redesign the afterRender & afterNextRender phases API (#55648)
Previously `afterRender` and `afterNextRender` allowed the user to pass
a phase to run the callback in as part of the `AfterRenderOptions`. This
worked, but made it cumbersome to coordinate work between phases.

```ts
let size: DOMRect|null = null;

afterRender(() => {
  size = nativeEl.getBoundingClientRect();
}, {phase: AfterRenderPhase.EarlyRead});

afterRender(() => {
  otherNativeEl.style.width = size!.width + 'px';
}, {phase: AfterRenderPhase.Write});
```

This PR replaces the old phases API with a new one that allows passing a
callback per phase in a single `afterRender` / `afterNextRender` call.
The return value of each phase's callback is passed to the subsequent
callbacks that were part of that `afterRender` call.

```ts
afterRender({
  earlyRead: () => nativeEl.getBoundingClientRect(),
  write: (rect) => {
    otherNativeEl.style.width = rect.width + 'px';
  }
});
```

This API also retains the ability to pass a single callback, which will
be run in the `mixedReadWrite` phase.

```ts
afterRender(() => {
  // read some stuff ...
  // write some stuff ...
});
```

PR Close #55648
2024-06-10 13:53:39 -07:00
Thomas Nguyen
6e89ef1ebf refactor(core): Refactor parts of event_replay into a shared library that will be used with global event delegation. (#56172)
This also moves the code that stashes the jsaction more closely to the code that actually sets the event listener.

PR Close #56172
2024-06-05 16:35:23 +00:00
Matthieu Riegler
73e84e2d22 refactor(core): Use Nullish coalescing assignment for view getters. (#56242)
Micro optim, this wasn't minified by the optimizer.

PR Close #56242
2024-06-03 20:10:35 +00:00
Andrew Scott
80f472f9f4 refactor(core): provide zone token in prod as well (#56197)
This allows us to make decisions based on whether zone is provided for
when zoneless is the default.

PR Close #56197
2024-05-30 19:24:23 -07:00
Andrew Kushnir
31f3975e4b fix(core): handle missing withI18nSupport() call for components that use i18n blocks (#56175)
This commit updates hydration serialization logic to handle a case when the `withI18nSupport()` call is not present for an application that has a component that uses i18n blocks. Note: the issue is only reproducible for components that also inject `ViewContainerRef`, since it triggers a special serialization code path.

Resolves #56074.

PR Close #56175
2024-05-30 18:36:58 +00:00
Andrew Kushnir
0529aac5e5 refactor(core): replace AIO link with ADEV one in hydration message (#56178)
This commit updates the content of hydration-related message and replaces AIO with ADEV domain.

PR Close #56178
2024-05-30 14:57:10 +00:00
Andrew Scott
d73127f48d refactor(core): privately export token that indicates if zone CD is provided (#56137)
This will allow us to internally decide how to configure things when the default is zoneless.

PR Close #56137
2024-05-30 13:48:08 +00:00
Kristiyan Kostadinov
e5a6f91722 feat(core): support TypeScript 5.5 (#56096)
Updates the repo to add support for TypeScript 5.5. Includes resolving some compilation errors and broken tests.

PR Close #56096
2024-05-29 15:33:33 +02:00
Thomas Nguyen
1223122080 refactor(core): Use event_dispatcher in event_replay code. (#56036)
This makes events bubble! This change also contains changes to
dispatcher and event_dispatcher to make replay synchronous,
so that we avoid odd timing issues. This can be split out though.

Lastly, we have one cleanup change to move the mapping from
event type to functions on the element itself.

PR Close #56036
2024-05-29 12:59:23 +02:00
Matthieu Riegler
b2445a0953 fix(core): link errors to ADEV (#55554) (#56038)
Console error links will now point to adev.

PR Close #55554

PR Close #56038
2024-05-28 12:50:53 +02:00
Andrew Kushnir
ae83646704 fix(core): handle elements with local refs in event replay serialization logic (#56076)
Previously, the event replay serialization logic was located before we verify that a `TNode` exists. `TNode`s may not exist in `tView.data` array in several cases, including cases when there is a local ref used on an element: in this case an extra slot in `LView` contains a reference to the same element and `TNode` is not needed. This commit moves the event replay serialization logic a bit lower, after we check for TNode presence.

Resolves #56073.

PR Close #56076
2024-05-27 13:50:09 +02:00
vladboisa
825023801b docs(core): change API link (#55688)
Fix url link for Button Change detection usage

Fixes #556687

PR Close #55688
2024-05-23 18:30:25 +02:00
Andrew Scott
3b4b05d2f7 refactor(core): Remove hybrid mode flag and move scheduler provider location (#55722)
The flag is not used anymore and, as a result, is easier to move the
scheduler provider.

PR Close #55722
2024-05-23 18:15:53 +02:00
Thomas Nguyen
690b0fb9af refactor(core): Create event types that are able to be serialized, captured, or are mouse events. (#55799)
Use these constants across jsaction and Angular.

PR Close #55799
2024-05-23 16:10:47 +02:00
Thomas Nguyen
ae9af9104f refactor(core): Make sure not to do anymore jsaction work once everything is replayed. (#55799)
Without this, I think subsequent renders will populate data structures.

PR Close #55799
2024-05-23 16:10:47 +02:00
Pawel Kozlowski
760207b254 Revert "fix(core): link errors to ADEV (#55554)" (#56031)
This reverts commit dd0700ff1d.
We will need G3 patch cleanup before this one can land.

PR Close #56031
2024-05-23 13:57:53 +02:00
Matthieu Riegler
dd0700ff1d fix(core): link errors to ADEV (#55554)
Console error links will now point to adev.

PR Close #55554
2024-05-23 11:58:54 +02:00
Matthieu Riegler
a0690fe19f refactor(core): remove unused preventDefault on listener (#55879)
`wrapListener` was only invoked with `wrapWithPreventDefault` set to `false`.

PR Close #55879
2024-05-22 16:08:39 -07:00
cexbrayat
6024d07559 fix(core): typo in zoneless warning (#55974)
The warning introduced in ae0baa25 mispelled `applications`.

PR Close #55974
2024-05-22 15:22:19 -07:00
Thomas Nguyen
d75adc5a25 refactor(core): Add additional cleanups to PR- Simplify event handler extraction logic. (#55752)
This should have been part of an earlier commit, but was not merged.

PR Close #55752
2024-05-20 23:37:34 -07:00
Kristiyan Kostadinov
ae0baa2522 fix(core): add warning when using zoneless but zone.js is still loaded (#55769)
Users may be using zoneless, but are still loading Zone.js in which case they won't get the full benefits like reduced bundle size. These changes detect such a case and log a warning.

PR Close #55769
2024-05-20 23:37:12 -07:00
Andrew Scott
cae0d3167d fix(core): exhaustive checkNoChanges should only do a single pass (#55839)
Because exhaustive checks traverse the whole tree regardless of the
dirty state, it breaks some expectations around how change detection
should be running. When a view has transplanted views, it
unconditionally marks all ancestors for traversal, assuming this is fine
because the loop will just traverse them and find nothing dirty.
However, exhaustive checkNoChanages actually refreshes everything during
traversal.

This update ensures the exhaustive check only does a single pass and
also prevents some unnecessary marking of transplanted views for
refresh since we know they're going to be reached.

PR Close #55839
2024-05-17 12:24:36 -07:00
cexbrayat
3d5c3d9fff fix(core): error about provideExperimentalCheckNoChangesForDebug uses wrong name (#55824)
The error about `provideExperimentalCheckNoChangesForDebug` mentions `provideCheckNoChangesForDebug` instead.

PR Close #55824
2024-05-16 09:02:28 -07:00
Andrew Scott
84b2351d50 refactor(core): Update error for both zone and zoneless to be only for apps (#55813)
Developers may want to enable zoneless for all tests by default by
adding the zoneless provider to `initTestEnvironment` and then
temporarily disabling it for individual tests with the zone provider
until they can be made zoneless compatible.

PR Close #55813
2024-05-15 13:27:26 -07:00
Alex Rickabaugh
f736bea8ee refactor(core): deprecate @Component.interpolation (#55778)
Angular has long had the ability to use different interpolation delimiters
(by default `{{` and `}}`). This concept was copied over from AngularJS,
where AngularJS syntax is included in HTML sent over the network to the
browser. Occasionally developers would use SSR frameworks which _also_ have
interpolation syntaxes of their own, so there was a need to change the
delimiters used by AngularJS to avoid conflicts.

Since Angular templates are always processed by our compiler and the
interpolation characters are never processed by other systems first, this
option is vestigial in Angular and only increases the complexity of our
parser.

DEPRECATED: `@Component.interpolation` is deprecated. Use Angular's
delimiters instead.

PR Close #55778
2024-05-14 11:48:12 -07:00
Thomas Nguyen
3ad120dfe8 refactor(core): Simplify event handler extraction logic. (#55747)
This reuses information already recorded during hydration to
remove jsaction attributes to also stash event handlers. This avoids
a tree walk and looku.

PR Close #55747
2024-05-14 09:38:43 -07:00
Thomas Nguyen
629b255ddb refactor(core): Add four tests and fix code to make tests pass. (#55747)
The first test asserts that bubbling does not work right now.

The second asserts that stopPropagation works, which should pass when test #1 passes too.

The third test asserts properties about the events passed to the event handler.

THe fourth test asserts that mouse events do not translate to jsaction nor help emit the jsaction binary. This required a change in code to make this pass.

PR Close #55747
2024-05-14 09:38:43 -07:00
Tom Wilkinson
0cb50317e1 refactor(core): Rename BaseDispatcher to Dispatcher. (#55721)
Rename `BaseDispatcher` to `Dispatcher` and `Dispatcher` to
`LegacyDispatcher`. The `GlobalHandler` type and `stopPropagation`
function needs to be left for now in dispatcher.ts as it was not
exported previously from legacy_dispatcher.ts.

PR Close #55721
2024-05-13 12:30:08 -07:00
Kristiyan Kostadinov
aa8df1d029 refactor(core): clean up clang comments and workarounds (#55750)
Since we aren't using clang anymore, we can remove the comments and the workarounds that were in place to prevent it from doing the wrong thing.

PR Close #55750
2024-05-13 11:10:36 -07:00