Commit graph

29901 commits

Author SHA1 Message Date
Andrew Scott
e6425f7bc1 refactor(core): use patched timers in root zone for zoneless scheduler (#55367)
Rather than attempting to use the native timing functions, this commit
simplifies the logic significantly by using the global timer functions
as they are, either patched or unpatched. When Zone is defined, we run
the timers in the root zone. This has more predictable behavior and
timing than (a) using both patched and unpatched versions of timers in
different places (b) trying to get an unpatched timer and failing due to
environment specifics and patches that aren't ZoneJS.

We will try to update the coalescing behavior of ZoneJS in a future PR
to also just use the patched version of the timers instead of the
"fakeTopEvent" workaround with the native timers.

PR Close #55367
2024-04-16 16:31:19 -07:00
Andrew Scott
f09c5a7bc4 feat(core): Add zoneless change detection provider as experimental (#55329)
This commit adds the zoneless change detection provider function to the
public API surface as experimental.

PR Close #55329
2024-04-16 20:51:25 +02:00
Andrew Scott
785c3c1dd4 refactor(core): Calling ApplicationRef.tick should cancel scheduled change detections (#55290)
This commit ensures that manually calling ApplicationRef.tick will
result in any scheduled change detections being canceled. There is no
need for the scheduled one to run because it was manually done by the
`tick` already.

PR Close #55290
2024-04-16 20:50:35 +02:00
Andrew Scott
c3a5acb8cc refactor(core): change detection should not be scheduled during appRef.tick (#55290)
This commit ensures that change detection is not scheduled if the
scheduler is notified during an applicationRef.tick

PR Close #55290
2024-04-16 20:50:35 +02:00
arturovt
3bc63eaaf3 fix(service-worker): avoid running CDs on controllerchange (#54222)
This commit updates the implementation of `ngswAppInitializer` to configure
the `controllerchange` event listener outside of the Angular zone. This adjustment
is made to prevent unnecessary change detections, as the `controllerchange` event
is unrelated to view updates.

**NOTE**: This change may result in breaking unit tests that implicitly rely on a
specific number and sequence of change detections for their assertions to pass.

PR Close #54222
2024-04-16 17:29:59 +02:00
Matthieu Riegler
e606ac6023 refactor(core): transform Predicate from interface to type (#54566)
This interface should have been a type as there are no other properties

PR Close #54566
2024-04-16 17:26:53 +02:00
Kristiyan Kostadinov
4eb0165750 fix(compiler): remove support for unassignable expressions in two-way bindings (#55342)
Two-way bindings are meant to represent a property binding to an input and an event binding to an output, e.g. `[(ngModel)]="foo"` represents `[ngModel]="foo" (ngModelChange)="foo = $event"`. Previously due to a quirk in the template parser, we accidentally supported unassignable expressions in two-way bindings.

In #54154 the quirk was fixed, but we kept support or some common expression because of internal usages. Now the internal usages have been cleaned up so the backwards-compatibility code can be deleted.

Externally a migration was added in #54630 that will automatically fix any places that depended on the old behavior.

BREAKING CHANGE:
Angular only supports writable expressions inside of two-way bindings.

PR Close #55342
2024-04-16 17:26:09 +02:00
Thomas Nguyen
d28614b90e feat(core): Modify EventType from an enum to an object. (#55323)
This is needed to reduce the binary size of the event contract.

PR Close #55323
2024-04-16 15:36:45 +02:00
Thomas Nguyen
bce5e2344f feat(core): Add build target for jsaction contract binary. (#55319)
Right now this binary sits at 9.5kb. Additional changes to the library will
be done to reduce the binary size, such as converting event_type from
an enum to an object, and other code size reductions.

PR Close #55319
2024-04-16 12:09:08 +02:00
Kristiyan Kostadinov
7d5bc1c628 fix(compiler): remove container index from conditional instruction (#55190)
Stops passing in the `containerIndex` argument to the `conditional` instruction since it isn't being used anymore.

PR Close #55190
2024-04-16 10:23:30 +02:00
cexbrayat
32eb23defb refactor(compiler): duplicate instructions in template pipeline (#54776)
Both `textInterpolate` and `collateInterpolationArgs` were doing the same work.

PR Close #54776
2024-04-16 10:21:52 +02:00
Matthieu Riegler
9afa2ea345 refactor(compiler-cli): include filepath for DocEntry (#55201)
This is allow the API docs to provide a direct link to implementation on github.

PR Close #55201
2024-04-15 17:41:45 +02:00
Pawel Kozlowski
43cf23954e refactor(migrations): exit developer preview for built-in control flow (#55348)
This commit removes the warning about developer preview in our
built-in control flow migration.

PR Close #55348
2024-04-15 17:29:12 +02:00
Pawel Kozlowski
f17d0b414e docs: exit developer preview for built-in control flow (#55348)
This commit removes the warning about developer preview in our
built-in control flow documentation page.

PR Close #55348
2024-04-15 17:29:12 +02:00
Paul Gschwendtner
3471c41ca9 build(docs-infra): fix playground lezer parsing (#55349)
When we started fixing the version mismatch with local 1st-party
packages, we also re-routed all dependencies like `@lezer/javascript`
into `adev/node_modules`. This works fine, but results in a different
version mismatch because the codemirror dependencies may resolve the
Angular version from `/node_modules`- causing some subtle complex
runtime error.

This commit fixes this by only re-routing dependencies that have
dependency on e.g. `@angular/core` into `adev/node_modules`.

Fixes #55298.

PR Close #55349
2024-04-15 16:36:39 +02:00
Pawel Kozlowski
9f7b9ed87a refactor(core): warn about duplicated keys when using built-in @for (#55243)
This commit a new check that warn users about duplicated keys detected given
a tracking expression and a collection iterated over with @for. Duplicated keys
should be avoided as those are more expensive to manage and can result in
incorrect UI display.

PR Close #55243
2024-04-15 16:10:27 +02:00
Pawel Kozlowski
cfed97d2a9 docs: update public APIs golden after doc changes (#55346)
Build got broken after merging https://github.com/angular/angular/pull/54577
due to the missing golden files update for the public API.

PR Close #55346
2024-04-15 14:19:54 +02:00
hansi_reit
5eda3bf5f0 docs: add missing usage-notes (#54577)
Fixes #54228

PR Close #54577
2024-04-15 12:25:40 +02:00
Matthieu Riegler
3af54d5114 docs: fix links to output function (#55335)
fixes #55334

PR Close #55335
2024-04-15 11:09:33 +02:00
Andrew Scott
571a61beeb refactor(core): add the fakeTopEvent workaround to zoneless scheduler (#55324)
Add the same fix to the zoneless scheduler that was needed for zone
coalescing (#36839).

PR Close #55324
2024-04-12 16:10:06 -07:00
Andrew Scott
e41a52286f Revert "refactor: move example generation into adev, removing content from aio (#55263)" (#55326)
This reverts commit 9bc15994ce.

PR Close #55326
2024-04-12 14:57:05 -07:00
Matthieu Riegler
5cf5f04460 build: bump to node 18.20 to support v18 (#55162)
The v18 CLI requires node `^18.19.1`, so we need to bump the node version to be able to run ADEV with v18.

PR Close #55162
2024-04-12 14:51:44 -07:00
Andrew Scott
6534c035c0 fix(core): Remove deprecated Testability methods (#53768)
This commit removes the long-deprecated Testability methods that track
pending tasks. This is done by NgZone today and will be done by other
APIs in zoneless.

BREAKING CHANGE: Testability methods `increasePendingRequestCount`,
`decreasePendingRequestCount` and `getPendingRequestCount` have been
removed. This information is tracked with zones.

PR Close #53768
2024-04-12 14:49:23 -07:00
Andrew Scott
fdd560ea14 feat(core): Add ability to configure zone change detection to use zoneless scheduler (#55252)
This commit adds a configuration option to zone-based change detection
which allows applications to enable/disable the zoneless scheduler.
When the zoneless scheduler is enabled in zone-based applications,
updates that happen outside the Angular zone will still result in a
change detection being scheduled. Previously, Angular change detection
was solely based on the state of the Angular Zone.

PR Close #55252
2024-04-12 12:29:05 -07:00
Andrew Scott
c9abe775d0 docs: Simply redirect function example for router (#55317)
PR Close #55317
2024-04-12 10:43:26 -07:00
Andrew Scott
11523c1cb7 docs(router): Add some additional docs for new Router features (#55184)
This commit adds some additional documentation for recent router
features.

PR Close #55184
2024-04-12 10:22:04 -07:00
Angular Robot
c3e34f1822 build: update babel dependencies to v7.24.4 (#55257)
See associated pull request for more information.

PR Close #55257
2024-04-12 10:21:24 -07:00
Mo Ibrahim
f947dd5ba4 docs: fix repeated note in "Add an Input to the component" section (#55306)
PR Close #55306
2024-04-12 10:14:01 -07:00
Jeremy Elbourn
145356c22e docs: add team docs for when to use dev preview and experimental (#55308)
Adds a brief team doc for when to use developer preview and experimental
API tags.

PR Close #55308
2024-04-12 10:10:50 -07:00
Charles Lyding
5c29416d3e refactor(language-service): add a plugin factory initialize helper (#55264)
An implementation of a TypeScript server plugin module factory has
been added to the main plugin code which minimizes the amount of
infrastructure code necessary to directly setup the Angular plugin.
This is not yet used externally but can be integrated in the future.

PR Close #55264
2024-04-12 18:21:29 +02:00
Angular Robot
75a186e321 build: update io_bazel_rules_sass digest to c3f163f (#55307)
See associated pull request for more information.

PR Close #55307
2024-04-12 10:34:39 +02:00
Leon Senft
f2f2c2acc0 test(core): fix expectations that accidentally used incorrect matchers (#55294)
Expect that the number of template executions is `===` to a number, rather than expect that it
does not contain a number. As they were, these expectations would pass regardless of the expected
value.

PR Close #55294
2024-04-12 07:38:52 +02:00
Matthieu Riegler
ab910e2476 build(http): Mark the http tests as flaky because of one particular transferCache test. (#55255)
There is one particular transfer cache test that seldom fails. Let's mark it as flaky for now as this issue is non-obvious.

PR Close #55255
2024-04-11 20:50:19 +02:00
Thomas Nguyen
1ee9f32621 feat(core): Synchronize changes from internal JSAction codebase. (#55182)
1: Remove USE_EVENT_PATH, which has no users.

2: Create a new `EventActionInfo` object to represent actions, update all `EventInfoWrapper` users.

3: Fix `stopPropagation` behavior in JSAction Dispatcher - it should only `stopPropagation` if an action is found, which is only known during normal dispatch rather than global.

PR Close #55182
2024-04-11 17:27:39 +02:00
ehlemur
6fef658cc3 docs(core): add missing space (#55287)
Add missing space after period in section describing producers and consumers.

PR Close #55287
2024-04-11 17:25:33 +02:00
Chinthoorie
0a8c48e76e refactor(compiler-cli): move config initialization into constructor (#54975)
refactor(compiler-cli): move config initialization into constructor
PR Close #54975
2024-04-11 11:20:17 +02:00
Andrew Scott
aae062e8db release: cut the v18.0.0-next.4 release 2024-04-10 16:18:45 -07:00
Andrew Scott
69927ce103 docs: release notes for the v17.3.4 release 2024-04-10 15:17:39 -07:00
Andrew Scott
19a238dfee Revert "refactor(core): warn about duplicated keys when using built-in @for (#55243)" (#55293)
This reverts commit e3696ad0d6.
caused a test failure internally

PR Close #55293
2024-04-10 13:45:49 -07:00
Rahat Ahmed
92debf4476 ci: Merge primitives-shared and primitives-event-dispatch groups (#55273)
This simplifies the approvals necessary for the event dispatch directory

PR Close #55273
2024-04-10 10:59:43 -07:00
Angular Robot
66e8cd2f8a docs: update Angular CLI help [main] (#55267)
Updated Angular CLI help contents.

PR Close #55267
2024-04-10 10:51:43 -07:00
Angular Robot
bc9114a547 build: update github/codeql-action action to v3.24.10 (#55258)
See associated pull request for more information.

PR Close #55258
2024-04-10 10:50:50 -07:00
Paul Gschwendtner
28b3c9214c build: do not clear stdout of architect-cli when building adev (#55282)
Similar to what we did for aio, we should not clear the architect CLI
output in Bazel. This messes up with the output and makes debugging
hard.

PR Close #55282
2024-04-10 10:48:39 -07:00
Paul Gschwendtner
0ae7542d8c build(docs-infra): disable caching of adev inside bazel (#55282)
Similar to `aio`, disables caching inside Bazel as it would be discarded
anyway and is likely a source of slowness then.

PR Close #55282
2024-04-10 10:48:39 -07:00
Paul Gschwendtner
f82898436e build(docs-infra): fix version mismatch of local built packages (#55282)
There is quite some trickery going on with the adev build related to
local packages:

- Adev builds using npm packages from `/node_modules`
- At runtime, we are adding `HEAD` packages for e.g. `@angular/core` to
  the bundles.
- At build time, the CLI, or Angular devkit may accidentally resolve to
  `@angular/core` from `/node_modules/`— which is the core version from
  npm, transitively installed via `@angular/docs`.

This causes a version mismatch, leading to issues like:

- CLI throwing because of a mismatch. https://github.com/angular/angular/issues/54858#issuecomment-2047188739
- Compiler changes not being picked up. https://github.com/angular/angular/issues/54858#issuecomment-2041322427

This commit attempts to fix this by:

- Linking all Angular `HEAD` packages into `adev/node_modules`. The
  current logic attempts to link into `/node_modules`, but this does not
  override existing `@angular/core`!
- Linking all direct external NPM packages, like
  `@angular_devkit/build-angular` into `adev/node_modules` without their
  transitive deps. This allows proper resolution of e.g. compiler as
  node looks in `adev/node_modules` first, and falls back for the rest
  to the execroot `node_modules`, or symlink target destination (if
  `preserveSymlinks=false`).

Note: This is still not 100% ideal because a direct external NPM
dependency may have a transitive dependency that has another transitive
dependency on `@angular/core`. In those cases, the may be a conflict
that is not resolvable until we switch to a Bazel toolchain with better
first party resolution support.

PR Close #55282
2024-04-10 10:48:38 -07:00
Paul Gschwendtner
e742787c6f docs: add guide for the output() function (#54946)
Adds a guide for angular.io that introduces the new `output()` function
(and `outputFromObservable`).

PR Close #54946
2024-04-10 10:40:41 -07:00
Pawel Kozlowski
e3696ad0d6 refactor(core): warn about duplicated keys when using built-in @for (#55243)
This commit a new check that warn users about duplicated keys detected given
a tracking expression and a collection iterated over with @for. Duplicated keys
should be avoided as those are more expensive to manage and can result in
incorrect UI display.

PR Close #55243
2024-04-10 10:39:23 -07:00
Alan Agius
9b903c52d8 docs: remove ng doc link (#55284)
This command has been removed in version 18.

PR Close #55284
2024-04-10 10:38:41 -07:00
Andrew Scott
acf5f73a7b Revert "fix(core): TestBed should not override NgZone from initTestEnvironment (#55226)" (#55286)
This reverts commit e9a0c86766.
flakes and broken tests. needs more investigation.

PR Close #55286
2024-04-10 10:37:42 -07:00
Andrew Scott
6993146a25 refactor(http): Do not contribute to stability when using provideHttpClientTesting (#54974)
`HttpClient` uses the `PendingTasks` service to contribute to
application stability. This was added in v16 to support SSR without
relying on an infinite `setTimeout` with ZoneJS like it did pre-v16.
Prior to version 16, this was also only done on the server and did not
affect clients or unit tests (28c68f709c).

Today, `PendingTasks` contribute to `ApplicationRef.isStable` but do not
contribute to the stability of `ComponentFixture`. This divergence in
stability behavior was not intended and we plan to make these two
stability indicators the same again, like they were when it was solely
based on the state of the Zone.

By aligning the two behaviors again, this would include all pending
tasks in the stability of fixtures. After investigation, this seems
likely to be a pretty large breaking change. Tests appear to quite often use
`await fixture.whenStable` when there are unfinished requests that have
not been mocked or flushed.

This change prevents request in `HttpClient` from contributing to
stability through the `PendingTasks` automatically but only when using
`HttpClientTesting`. In this scenario, requests need to be expected and
flushed manually for them to resolve. When the test backend and controllers
aren't used, requests should resolve on their own so `await fixture.whenStable`
shouldn't be particularly affected or problematic.

PR Close #54974
2024-04-10 09:27:40 -07:00