Commit graph

334 commits

Author SHA1 Message Date
Kristiyan Kostadinov
01722ee637 build: fix size failure (#54756)
Fixes a broken size CI check.

PR Close #54756
2024-03-07 16:13:44 -08:00
Paul Gschwendtner
866271a1c6 refactor(core): EventEmitter implements OutputRef. (#54650)
An `EventEmitter` is a construct owned by Angular that should be
used for outputs as of right now.

As we are introducing the new `OutputRef` interface for the new output
function APIs, we also think `EventEmitter` should implement
`OutputRef`— ensuring all "known" outputs follow the same contract.

This commit ensures `EventEmitter` implements an `OutputRef`

Note: An output ref captures the destroy ref from the current injection
context for clean-up purposes. This is also done for `EventEmitter` in a
backwards compatible way:

- not requiring an injection context. EventEmitter may be used
  elsewhere.
- not cleaning up subscriptions/completing the emitter when the
  directive/component is destroyed. This would be a change in behavior.

Note 2: The dependency on `DestroyRef` causes it to be retained in all
bundling examples because ironically `NgZone` uses `EventEmitter`- not
for outputs. The code is pretty minimal though, so that should be
acceptable.

`EventEmitter` will now always retain `NgZone. This increases the
payload size slightly around 800b for AIO. Note that the other increases
were coming from previous changes. This commit just pushed it over the
threshold.

PR Close #54650
2024-03-06 12:34:39 +01:00
Angular Robot
4a87a8ac10 build: update cross-repo angular dependencies (#53836)
See associated pull request for more information.

PR Close #53836
2024-01-08 11:31:57 -08:00
Andrew Scott
12181b9914 refactor(core): Use single source of truth for ApplicationRef.isStable (#53576)
This commit updates the `ApplicationRef.isStable` implementation to use
a single `Observable` to manage the state. This simplifies the mental
model quite a bit and removes the need for rx operators like
`distinctUntilChanged` and `combineLatest`.

PR Close #53576
2023-12-19 12:42:45 -08:00
Matthieu Riegler
d7e7409e81 refactor(animations): drop convertToMap & copyStyles and use native functions. (#52441)
`copyStyles` was side-effectful and also returned a value : not great.

PR Close #52441
2023-12-14 12:33:24 -08:00
Alan Agius
e8ad51aaed test: refactor platform-server integration tests to use application builder (#53205)
This commit updates the platform-server tests to use the new application builder, with this change we also have to remove the sizechecks since esbuild will do code motion and split the code into multiple chunks example `chunk-QUKLKPSE.js`.

PR Close #53205
2023-11-28 11:07:01 +01:00
Pawel Kozlowski
33ae659100 build: update aio to 17.0.0 (#52635)
This commit updates the Angular version for AIO and its examples to 17.0.0

PR Close #52635
2023-11-08 16:02:33 +01:00
Alex Rickabaugh
bdd61c768a fix(core): replace assertion with more intentional error (#52234)
Issue #50320 shows that in some cases, updating a signal that's a dependency
of a template during change detection of that template can have several
adverse effects. This can happen, for example, if the signal is set during
the lifecycle hook of a directive within the same template that reads the
signal.

This can cause a few things to happen:

* Straightforwardly, it can cause `ExpressionChanged` errors.
* Surprisingly, it can cause an assertion within the `ReactiveLViewConsumer`
  to fail.
* Very surprisingly, it can cause change detection for an `OnPush` component
  to stop working.

The root cause of these later behaviors is subtle, and is ultimately a
desync between the reactive graph and the view tree's notion of "dirty" for
a given view. This will be fixed with further work planned for change
detection to handle such updates directly. Until then, this commit improves
the DX through two changes:

1. The mechanism of "committing" `ReactiveLViewConsumer`s to a view is
   changed to use the `consumerOnSignalRead` hook from the reactive graph.
   This prevents the situation which required the assertion in the first
   place.

2. A `console.warn` warning is added when a view is marked dirty via a
   signal while it's still executing.

The warning informs users that they're pushing data against the direction of
change detection, risking `ExpressionChanged` or other issues. It's a
warning and not an error because the check is overly broad and captures
situations where the application would not actually break as a result, such
as if a `computed` marked the template dirty but still returned the same
value.

PR Close #52234
2023-10-27 11:41:20 -07:00
Jan Kuehle
ebbc7a27e8 refactor: change public const enums to enums (#51670)
Angular recently gained a local compilation mode (see commit
345dd6d81a). This is intended to be used
with the TypeScript compiler option isolatedModules, which bans imports
of const enums.

This changes all const enums tagged with @publicApi to regular enums.

Fixes #46240

PR Close #51670
2023-10-25 10:39:18 -07:00
Joey Perrott
1f66090378 build: update lockfile (#52270)
Update lockfiles throughout

PR Close #52270
2023-10-23 09:30:38 -07:00
Matthieu Riegler
1c4a3677eb refactor(animations): make AnimationBuilder tree-shakable (#52097)
This commit allows also to use the `AnimationBuilder` when using `provideAnimationsAsync()`

fixes #52096

PR Close #52097
2023-10-12 18:13:22 +02:00
Matthieu Riegler
a645ceca94 refactor(service-worker): Remove deprecated activated & available observables. (#49498)
`activated`and `available` were deprecated by #43535 in v13.

PR Close #49498
2023-10-10 11:54:07 -07:00
Andrew Kushnir
2eebd47733 refactor(core): make timer-related @defer logic tree-shakable (#52042)
This commit updates `@defer` logic related to handling `after` and `minimum` parameters tree-shakable.

If `after` or `minimum` was used on a `@loading` or `@placeholder` blocks, compiler generates an extra argument for the `ɵɵdefer` instruction. This extra argument is a reference to a function that brings timer-related code.

PR Close #52042
2023-10-09 15:57:59 -07:00
Andrew Kushnir
db3a90191f test(core): add an integration app for @defer feature (#52065)
This integration app also contains the size-tracking build setup to measure the payload size of `@defer` feature.

PR Close #52065
2023-10-06 12:11:29 -07:00
Paul Gschwendtner
7426948ff6 refactor(common): update NgTemplateOutlet to no longer rely on context swapping (#51887)
The context of an embedded view ref at some point was switched from a
getter to an actual assignable property. This is something we reverted
with the previous commit as it introduces additional complexity for our
generated code (in terms of closures capturing the `ctx`).

This change impacted the template outlet code because we actively relied
on swapping out the full context if the user changes it. Previousl,
before we allowed to swap out the context (in v16), we mutated the
initial view context if it didn't change structurally- and in other
cases the view was re-created. We improved this performance aspect with
the changes to allow for the context to be swapped out + actually also
fixed a bug where the initial context object was mutated and the user
could observe this change.

This commit adjusts for context not being replacable- while still
keeping the bugs fixed and preserving the performance wins of not
having to destroy/re-create the view whenever the context changes.

Benchmarks: https://hackmd.io/J0Ci_JzxQ0K1AA1omXhIQQ

PR Close #51887
2023-10-04 08:14:35 -07:00
Alan Agius
e9c3790b4e docs: update to latest version of material (#51996)
Update to the latest version of material

PR Close #51996
2023-10-03 08:07:48 -07:00
Matthieu Riegler
81e7f5be03 test(animations): update the integration test (#50738)
Let's have the same test app for async and eagerly loaded animations.

PR Close #50738
2023-09-29 10:49:41 -07:00
Matthieu Riegler
2c2ccf76e2 refactor(animations): Add integration test for animations/async. (#50738)
This integration test aims to cover that we do not break the code splitting of the animation module when we use `provideAnimationsAsync()`.

PR Close #50738
2023-09-29 10:49:40 -07:00
Joey Perrott
ba64e9c247 docs: update to latest version of material (#51785)
Update to the latest version of material

PR Close #51785
2023-09-19 18:39:10 +02:00
Angular Robot
a2681c7c9d build: update cross-repo angular dependencies (#51780)
See associated pull request for more information.

PR Close #51780
2023-09-14 19:35:45 +02:00
Andrew Scott
4555290d54 refactor(router): Add a state manager to manage router URL state (#48481)
This commit refactors the router internals to track state inside a separate
`StateManager`. This helps open the door to managing the state in
different, swappable providers. The current interface needed by the
Router is: `currentUrlTree`, `rawUrlTree`, `browserUrlTree`,
`routerState`, and `handleNavigationEvent` (other properties are because
some router properties are writeable when they shouldn't be). This is
a suprisingly small interface and can hopefully be made smaller in the
future (i.e. removing 1 or more of the 3 tracked of `UrlTree`s).

PR Close #48481
2023-09-01 16:12:35 +00:00
Alex Rickabaugh
201ab9d247 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
Alan Agius
edceb486dd fix(core): wait for HTTP in ngOnInit correctly before server render (#50573)
Previously, with `mergeMap` we did not cancel previous subscriptions to zoneIsStable which caused the application to be stablized before hand.

Closes: #50562

PR Close #50573
2023-06-06 14:12:34 -07:00
Jessica Janiuk
069498ca89 build: Fix size tracking test (#50531)
One of our goldens needed to be bumped.

PR Close #50531
2023-05-31 14:43:52 +00:00
Alan Agius
28c68f709c fix(core): update ApplicationRef.isStable to account for rendering pending tasks (#50425)
This commit updates the `ApplicationRef.isStable` API to account for
pending rendering task. This is needed as once a pending rendering task
is done, new macrotask and microtask could be created which previously caused these not
to be intercepted and thus ignored when doing SSR.

PR Close #50425
2023-05-30 12:58:22 -07:00
Paul Gschwendtner
da2efbcef5 test: update payload golden for AIO to reflect reduction in size (#50107)
The `main` bundle fell below the threshold. No actual investigation
was done here because it's a reduction in size, and the AIO size
matches the `AIO-local` size now. This is expected because the latest
RC closely matches the `main` branch (or even is equivalent at this
point).

PR Close #50107
2023-05-02 16:10:48 +02:00
Alan Agius
e40a640dfe test: remove unused size goldens (#49976)
These test has been deleted as such the size check golden here is redundant.
PR Close #49976
2023-04-24 11:56:37 -07:00
Jessica Janiuk
0b23ad7f56 test(core): add size tracking test for hydration apps (#49955)
This adds test to track size regressions when
hydration is enabled.

PR Close #49955
2023-04-24 09:57:52 -07:00
Angular Robot
f023020368 build: update cross-repo angular dependencies (#49887)
See associated pull request for more information.

PR Close #49887
2023-04-17 15:46:39 +00:00
Matthieu Riegler
ed8a595408 docs: Improve previous version navigation (#49063)
In archive mode the link to the current doc will now point to same page.
If the page doesn't exist anymore, it will show a contextualized warning message.

See #46850

PR Close #49063
2023-04-06 11:07:00 -07:00
Andrew Scott
0432d952a1 Revert "fix(router): Route matching should only happen once when navigating (#49163)" (#49634)
This reverts commit 1600687fe5.

PR Close #49634
2023-03-29 11:37:29 -07:00
Alex Rickabaugh
9e40250d27 refactor(core): unify signal producer/consumer into nodes (#49529)
Previously the signals implementation maintained separate interfaces for
`Producer` and `Consumer` nodes, with implementers choosing to implement
one or both interfaces. Operations defined against those interfaces were
exposed as importable functions to be called with the object implementing
the relevant contract as the first argument.

This commit refactors the implementation to merge both abstractions into a
single `ReactiveNode` base class, which represents both producers and
consumers in the graph. Implementers choose to interact with a subset of the
`ReactiveNode` API depending on their role in the graph. Operations are now
available as protected methods on the base class, instead of separate
functions.

PR Close #49529
2023-03-28 18:47:58 -07:00
Andrew Scott
1600687fe5 fix(router): Route matching should only happen once when navigating (#49163)
When navigating in the Router, the current approach does the redirects
and the creation of the `RouterStateSnapshot` in two separate steps
(applyRedirects and recognize). These two steps duplicate the route
matching logic, resulting in user code on routes being executing twice
(custom `UrlMatcher` and `canMatch` guards). This also duplicates the
complex matching logic in two places, which increases the bundle size
and maintenance burden.

This commit combines the `applyRedirects` and `recognize` steps into a
single matching algorithm.

fixes #26081

PR Close #49163
2023-03-28 13:53:57 -07:00
Andrew Scott
9b65b84cb9 feat(core): Mark components for check if they read a signal (#49153)
This commit updates the `LView` in Angular to be a `Consumer` of
signals. If a signal is read when executing a template, it marks the
view dirty. In addition, if a signal is read when executing host
bindings, it also marks views dirty.

One interesting thing about signal reads in host bindings
is that they perform a bit better than what we can do with today's
APIs. In order to re-execute host bindings for an `OnPush` component that
might have changed, you would probably inject `ChangeDetectorRef` and call
`markForCheck`. This will mark the _current component_ and parents
dirty. However, host bindings are executed as part of refreshing the
_parent_ so there is really no need to re-execute the current component
if the only thing that changed is the host bindings. When a signal is
read in host bindings, it marks the parent dirty and not the component
that defined the host binding.

Additionally, this commit avoids allocating a full consumer for each
`LView` by re-using a consumer until template execution results in a
signal read. At this point, we assign that consumer to the `LView` and
create a new consumer to "tentatively" use for the future `LView`
template executions.

Co-authored-by: Dylan Hunn <github@dylanhunn.com>

PR Close #49153
2023-03-27 11:19:06 -07:00
Andrew Scott
ff9d3b0f02 refactor(router): Remove legacy url creation code (#49360)
This commit removes code for the old way of creating a `UrlTree`.

PR Close #49360
2023-03-22 16:37:01 +01:00
Pawel Kozlowski
d1617c449d feat(core): allow removal of previously registered DestroyRef callbacks (#49493)
This change makes it possible to remove a previously registered destroy
callback - to do so it is enough to call the unregistration function
returned from the onDestroy method call.

PR Close #49493
2023-03-21 16:58:22 +01:00
Paul Gschwendtner
e2d3da5c71 test: update i18n size golden to reflect main (#49514)
The `i18n` integration size test golden has been updated with
an increase 20hrs ago, but now with the recent Angular update,
it seems back to the previous size, a decrease in size.

https://github.com/angular/angular/pull/49495.

PR Close #49514
2023-03-21 15:18:13 +01:00
Paul Gschwendtner
ac6715a5c6 test: update AIO size golden to account for main increase (#49514)
The AIO main bundle has increased a little due to the recently
added hydration logic into the core runtime.

e.g. code like this: https://screenshot.googleplex.com/8CvRNMdkT3LqXg3

PR Close #49514
2023-03-21 15:18:13 +01:00
Alan Agius
53b2ea9451 refactor(platform-browser): remove private DomSharedStylesHost workaround (#49482)
This workaround is no longer needed as all usage of `DomSharedStylesHost` have been removed from Google3.

PR Close #49482
2023-03-21 13:56:02 +01:00
Kristiyan Kostadinov
897a9e578d build: update size golden (#49495)
Fixes a size golden that was out of date.

PR Close #49495
2023-03-20 17:35:30 +01:00
Alan Agius
c934a8e72b fix(platform-browser): only add ng-app-id to style on server side (#49465)
This commit fixes an issue where it causes issues in G3 when we add `ng-app-id` on browser apps.

PR Close #49465
2023-03-17 17:26:27 +01:00
Andrew Kushnir
22b895a5b1 refactor(core): add hydration logic for view containers (#49382)
This commit implements hydration support for view containers, which should make `*ngIf`, `*ngFor` and other structural directive work with hydration.

The logic also respects the `ngSkipHydration` flag and skips hydration in such cases.

PR Close #49382
2023-03-14 14:22:09 -07:00
Andrew Scott
4e098fa8a7 refactor(core): move Zone providers to a single provider function (#49373)
This commit moves the providers for `NgZone`-based change detection to a
single provider function. This function is currently called by default
in all places where `NgZone` was provided
(`bootstrapApplication`, `bootstrapModule`, and `TestBed`).

When we want to make Angular applications zoneless by default, we
can make a public provider method that has to be used in order to enable
the zone change detection features. When this method is not called,
Angular would use `NoopNgZone` by default and not initialize any
subscriptions to the `NgZone` stability events.

Side note: There are actually two places that `NgZone` is provided for `TestBed`
(providers in `compileTestModule` and `BrowserTestingModule`). This
likely doesn't need to be in both locations.

PR Close #49373
2023-03-14 09:20:53 -07:00
Alan Agius
a50ff60bff build: update cross-repo angular dependencies (#49376)
See associated pull request for more information.

(cherry picked from commit ba630a3c65)

PR Close #49376
2023-03-09 11:32:03 -08:00
Alan Agius
9165ff2517 fix(platform-browser): reuse server generated component styles (#48253)
Prior to this change component styles generated on the server where removed prior to the client side component being rendered and attached it's own styles. In some cases this caused flickering. To mitigate this `initialNavigation: enabledBlocking'` was introduced which allowed the remove of server styles to be defer to a latter stage when the application has finished initialization.

This commit changes the need for this, by not removing the server generated component styles and reuse them for client side rendering.

PR Close #48253
2023-03-09 09:33:34 -08:00
Alan Agius
0e5f9ba6f4 fix(core): generate consistent component IDs (#48253)
Prior to this change the component IDs where generated based on a counter. This is problematic as there is no guarantee that a component will get the same ID that was assigned on the server when generated on the client side.

This is paramount to be able to re-use the component styles generated on the server.

PR Close #48253
2023-03-09 09:33:34 -08:00
Jessica Janiuk
5944f5d21e refactor(core): skip hydration annotation (#49345)
This adds the ngSkipHydration annotation, which allows users to
opt hydration boundaries out of hydration. This enables incremental
adoption of hydration by letting users skip hydration on components
that have implementation issues that conflict with hydration.

co-authored-by: AndrewKushnir <akushnir@google.com>

PR Close #49345
2023-03-08 17:56:43 +00:00
Andrew Kushnir
8e0a087674 refactor(core): hydration logic for <ng-container>s (#49303)
This commit incrementally builds on top of #49285 and adds the logic to hydrate <ng-container>s and their contents. This implementation supports simple <ng-container>s that don't have any Angular features (like *ngIf/*ngFor, etc) and are not content-projected.

The subsequent commits will extend the logic further to support more complex scenarios.

PR Close #49303
2023-03-07 23:56:45 +00:00
Jessica Janiuk
10ffd03e35 ci: update integration test size (#49339)
This updates the uncompressed main file size to fix the broken test status.

PR Close #49339
2023-03-06 18:44:00 +00:00
Matthieu Riegler
cc34d5b6ef refactor(core): Application ref/init code cleaning (#49206)
* With tsc improvements some types can be refined.
* Removing unnecessary non-null assertions.
* Using std native methods instand of custom functions
* Using @ts-expect-error instead of `any` type assertion to keep code navigation.

PR Close #49206
2023-03-02 20:01:39 +00:00