Commit graph

29620 commits

Author SHA1 Message Date
Dylan Hunn
67f0cf5fc8 release: cut the v17.3.2 release 2024-03-28 09:56:43 -07:00
Kristiyan Kostadinov
2f9d94bc4a fix(migrations): account for variables in imports initializer (#55081)
Fixes that the control flow migration was throwing an error if the `imports` of a component are initialized to an identifier.

Fixes #55080.

PR Close #55081
2024-03-28 09:40:33 -07:00
Paul Gschwendtner
ee76001431 refactor(compiler-cli): support ignoring specific doc entries during extraction (#55053)
This commit adds support for ignoring specific doc entries when
extracting doc entries. This allows us to drop e.g. `InputFunction` from
the API docs, given that the `input` API entry holds all the relevant
information.

`InputFunction` only exists for type purposes in the `.d.ts`.

PR Close #55053
2024-03-28 09:38:43 -07:00
Paul Gschwendtner
b63afb9e93 refactor(core): improve API documentation for query initializer APIs (#55053)
Similar to `input`, `model`, `output`, the query initializer APIs are
also explicitly denoted as such. This allows angular.dev to display them
more readable and compactly.

PR Close #55053
2024-03-28 09:38:43 -07:00
Paul Gschwendtner
658fb0a17f refactor(core): improve API documentation for output (#55053)
This improves the API documentatino for `output` in angular.dev,
similar to how we improved the API for `input`.

Angular.dev can now show these documentation entries more
readable if annotated explicitly as initializer API.

Note: output API is short enough that we want to include
the types in the code snippet previews.

PR Close #55053
2024-03-28 09:38:42 -07:00
Paul Gschwendtner
f8aa778b70 refactor(core): improve API documentation for model (#55053)
Improves the API documentation for `model`, similarly to how
we updated the `input` function.

PR Close #55053
2024-03-28 09:38:41 -07:00
Paul Gschwendtner
60ed00a601 refactor(core): improve API documentation for input after angular.dev support (#55053)
This commit improves the API documentation for `input` after
we added support for initializer APIs in angular.dev docs generation.

Changes:

- Rename `ReadT` to `T`. This conceptually makes it easy to talk about
  inputs of type `T` if there is no transform involved. The common case.
- Rename `WriteT` to `TransformT`. This makes it clear that this is the
  type that the "transform" needs to handle.
- Improves the "overall" description of the input function so that it
  can be shown as a general overview for the API site.
- Improves usage notes to be a little more helpful, yielding more useful
  content in the API docs usage notes section.
- Add short JSDoc description for each individual overload.

PR Close #55053
2024-03-28 09:38:40 -07:00
Paul Gschwendtner
c7ff3d158a refactor(docs-infra): support initializer API functions (#55053)
This commit ensures that extracted initializer API functions are
showing up in angular.dev and can be filtered.

PR Close #55053
2024-03-28 09:38:39 -07:00
Paul Gschwendtner
aeb20f95d2 refactor(compiler-cli): support extracting initializer API functions (#55053)
This commit adds support for extracting initializer API functions.
Initialixer API functions are functions conceptually that can are
intended to be used as class member initializers.

Angular started introducing a few of these for the new signal
APIs, like `input`, `model` or signal-based queries.

These APIs are currently confusingly represented in the API docs because
the API extraction:

- does not properly account for call signatures of interfaces
- does not expose information about sub-property objects and call
  signatures (e.g. `input.required`)
- the docs rendering syntax highlighting is too bloated and confusing
  with all types being included.

This commit adds support for initializer API functions, namely two
variants:

- interface-based initializer APIs. e.g. `export const input:
  InputFunction`- which is a pattern for `input` and `input.required`.
- function-based simpler initializer APIs with overloads. e.g.
  `contentChildren` has many signatures but doesn't need to be an
  interface as there are no sub-property call signatures.

PR Close #55053
2024-03-28 09:38:38 -07:00
Andrew Kushnir
708ba8115f fix(core): establish proper injector resolution order for @defer blocks (#55079)
This commit updates the `@defer` logic to establish proper injector resolution order. More specifically:

- Makes node injectors to be inspected first, similar to how it happens when `@defer` block is not used.
- Adds extra handling for the Router's `OutletInjector`, until we replace it with an `EnvironmentInjector`.

Resolves #54864.
Resolves #55028.
Resolves #55036.

PR Close #55079
2024-03-28 09:23:42 -07:00
Matthieu Riegler
fb5a28858d refactor(devtools): prevent exeception on state serializer (#55061)
`Object.getPrototypeOf(obj)` returns `null` if `obj` is an empty object. `Object.getOwnPropertyDescriptors` throws on `null`/`undefined`

PR Close #55061
2024-03-28 09:14:25 -07:00
Paul Gschwendtner
5b67c94775 refactor(compiler-cli): improve error message for uncaught FatalDiagnosticError (#55070)
For `FatalDiagnosticError` we are currently hiding the `message` string
field in favor of the actual TS `diagnosticMessage`.

This works as expected, but makes these errors hard to debug in certain
environments (e.g. Jasmine). That is because `null` is the value of
`message` at runtime. We fix this by just overriding the type, like we
originally intended to do.

In addition, we properly render message chains in the `Error#message`
field— so that these errors, when uncaught, are somewhat reasonable and
can be useful.

PR Close #55070
2024-03-28 09:13:09 -07:00
Paul Gschwendtner
b478dfbfda fix(compiler-cli): report errors when initializer APIs are used on private fields (#55070)
This commit ensures that the new APIs like `input`, `model`, `output`,
or signal-based queries are not accidentally used on fields that have a
problematic visibility/access level that won't work.

For example, queries defined using a private identifier (e.g. `#bla`)
will not be accessible by the Angular runtime and therefore _dont_ work.

This commit ensures:

- `input` is only declared via public and protected fields.
- `output` is only declared via public and protected fields.
- `model` is only declared via public and protected fields.
- signal queries are only declared via public, protected and TS private
  fields (`private` works, while `#bla` does not).

Fixes #54863.

PR Close #55070
2024-03-28 09:13:08 -07:00
Paul Gschwendtner
75d1cae616 refactor(compiler-cli): support enforcing field access for initializer APIs (#55070)
An initializer API like `input`, `output`, or signal queries may not be
compatible with certain access levels. E.g. queries cannot work with ES
private class fields.

This commit introduces a check for access levels into the initializer
API recognition— enforcing that every initializer API *clearly*
specifies what type of access is allowed.

PR Close #55070
2024-03-28 09:13:07 -07:00
Paul Gschwendtner
53fe455630 refactor(compiler-cli): reflection should inspect ES private fields and visibility (#55070)
This commit changes the TypeScript reflection host to:

* inspect / process ES private fields. e.g. `#someField` — those are
  ignored right now and we would want to check them to issue
  diagnostics.

* determine an access level of a class member. E.g. a member may be
  public, may be private, may be ES private, or public readonly. This
  can then be used in various checks later.

PR Close #55070
2024-03-28 09:13:06 -07:00
Kristiyan Kostadinov
1470b7d40e refactor(compiler-cli): expand type of initializer parsing function (#55070)
Updates the function that parses initializer APIs to check any `Expression`, instead of expecting a class member. This will be useful for the upcoming changes.

PR Close #55070
2024-03-28 09:13:05 -07:00
Matthieu Riegler
76631995e1 docs: link to http security now at best-practices/security (#55060)
fixes #55058

PR Close #55060
2024-03-27 11:32:09 -07:00
Esteban Luchsinger
519e781701 docs: explain difference between @placeholder and @loading (#54779)
Add a sentence to the `@loading` block documentation that emphasizes more that the `@loading` block will replace the `@placeholder` block once the deferred view starts loading.

PR Close #54779
2024-03-27 11:09:17 -07:00
vladboisa
1af2be9b23 docs(docs-infra): replace link by HTTPsecurity tab (#55029)
Replace a broke link by content of HTTP Client Security Tab.

Fixes #54918 & #54922

PR Close #55029
2024-03-27 10:50:25 -07:00
JiaLiPassion
a893f0b60d fix(zone.js): should not clear onhandler when remove capture listener (#54602)
Close #54581

Should not clear `onHandler` when remove capture event listeners.

PR Close #54602
2024-03-27 10:40:06 -07:00
Paul Gschwendtner
93ce4d0483 refactor(compiler-cli): properly preserve file overview comments (#54983)
This commit updates the logic for preserving file overview comments
to be more reliable and less dependent on previous transforms.

Previously, with the old import manager, we had a utility called
`addImport` that always separated import statements and non-import
statements. This meant that the non-emitted statement from Tsickle
for the synthetic file-overview comments no longer lived at the
beginning of the file.

`addImports` tried to overcome this by adding another new non-emitted
statement *before* all imports. This then was later used by the
transform (or was assumed!) to attach the synthetic file overview
comments if the original tsickle AST Node is no longer at the top.

This logic can be improved, because the import manager shouldn't need to
bother about this fileoverview non-emitted statement, and the logic for
re-attaching the fileoverview comment should be local. This commit fixes
this and makes it a local transform.

PR Close #54983
2024-03-27 10:18:30 -07:00
Paul Gschwendtner
ed271ebb37 test(compiler-cli): add tests to verify import generation in TCB files/blocks (#54983)
This commit adds some unit tests verifying the import generation in TCB
files and inline blocks. We don't seem to have any unit tests for these
in general. This commit adds some, verifying some characteristics we
would like to guarantee.

PR Close #54983
2024-03-27 10:18:30 -07:00
Paul Gschwendtner
6734b59b35 refactor(compiler-cli): rename ImportManagerV2 to ImportManager (#54983)
To ease review and to allow for both instances to co-exist, `ImportManagerV2`
was introduced. This commit renames it to `ImportManager` now that we
deleted the older one.

PR Close #54983
2024-03-27 10:18:29 -07:00
Paul Gschwendtner
789326d483 refactor(compiler-cli): delete old unused ImportManager (#54983)
This commit deletes the older and now unused `ImportManager`.

PR Close #54983
2024-03-27 10:18:29 -07:00
Paul Gschwendtner
4b63716b4a test(compiler-cli): enable incremental re-use type checking with signal inputs (#54983)
Enables the incremental type-checking test that we never enabled when we
landed signal inputs. Now that we fixed incremental re-use by re-using
the existing user imports for inline type check blocks, the test is
passing and can be enabled.

PR Close #54983
2024-03-27 10:18:29 -07:00
Paul Gschwendtner
308b194ee3 refactor(compiler-cli): switch jit transforms to use new import manager (#54983)
Switches the JIT transforms to use the new import manager.

PR Close #54983
2024-03-27 10:18:29 -07:00
Paul Gschwendtner
62510a7b4d refactor(compiler-cli): update type check generation code to use new import manager (#54983)
Updates the type-check block generation code (also for inline type check
blocks) to use the new import manager.

This is now a requirement because the translator utilities from the
reference emit environment expect an import manager that follows the
new contract established via `ImportGenerator<TFile, TExpression>`.

For type check files, we can simply print new imports as we don't expect
existing imports to be updated. That is because type check files do not
have any _original_ source files (or in practice— those are empty).

For type check blocks inline, or constructors, imports _may_ be re-used.
This is great as it helps fixing some incrementality bugs that we were
seeing in the type check code. That is, sometimes the type check block
code may generate imports conditionally for e.g. `TemplateRef`, or
animations. Those then **prevent** incremental re-use if TCB code
switches between those continously. We tried to account for that with
signal inputs by always pre-generating such imports. This fixed the
issue for type-check files, but for inline type check blocks this is
different as we would introduce new imports in user code that would then
be changed back in subsequential edit iterations. See:
https://github.com/angular/angular/pull/53521#pullrequestreview-1778130879.

In practice, the assumption was that we would be fine since user code is
most likely containing imports to `@angular/core` already. That is a
true assumption, but unfortunately it doesn't help with incremental
re-use because TypeScript's structural change detection does not dedupe
and expects 1:1 exact imports from their old source files.

https://github.com/microsoft/TypeScript/pull/56845

To improve incremental re-use for the type check integration, we should
re-use original source file imports when possible. This commit enables
this.

To update imports and execute inline operations, we are now uisng
`magic-string` (which is then bundled) as it simplifies the string
manipulatuons.

PR Close #54983
2024-03-27 10:18:29 -07:00
Paul Gschwendtner
ece2deeab6 refactor(compiler-cli): use new import manager for ngtsc transforms (#54983)
This commit switches ngtsc's JS and DTS transform to use the new import
manager. This is a drop-in replacement as we've updated the translator
helpers in the previous commit to align with the new API suggested by
the `ImportManagerV2` (to be renamed then).

PR Close #54983
2024-03-27 10:18:29 -07:00
Paul Gschwendtner
4d8d324ea6 refactor(compiler-cli): update ImportGenerator abstraction for new manager (#54983)
`ImportGenerator` is the abstraction used by the translator functions to
insert imports for `ExternalExpr` in an AST-agnostic way.

This was built specifically for the linker which does not use any of the
complex import managers- but rather re-uses `ngImport` or uses
`ngImport.Bla`.

This commit also switches the linker AST-agnostic generator to follow
the new signatures. This was rather trivial.

PR Close #54983
2024-03-27 10:18:29 -07:00
Paul Gschwendtner
3253576db8 refactor(compiler-cli): introduce new implementation of ImportManager (#54983)
This commit introduces a new implementation of `ImportManager` that has
numerous benefits:

- It allows efficient re-use of original source file imports.
  * either fully re-using original imports if matching
  * updating existing import declarations to include new symbols.
- It allows efficient re-use of previous generated imports.
- The manager can be used for schematics and migrations.

The implementation is a rework of the import manager that we originally
built for schematics in Angular Material, but this commit improved it
to be more flexible, more readable, and "correct".

In follow-ups we can use this for schematics/migrations.

PR Close #54983
2024-03-27 10:18:29 -07:00
Andrew Scott
365fd50407 fix(router): RouterLinkActive will always remove active classes when links are not active (#54982)
Previously, `RouterLinkActive` would only add or remove the active classes when
its active state changed. This means that if you accidentally add one of
the active classes to the static class attribute, it won't get removed
until the link becomes active and then deactives (because the class is
added at creation time and never removed until the `RouterLinkActive`
state changes from active to inactive).

fixes #54978

PR Close #54982
2024-03-27 10:16:23 -07:00
Matthieu Riegler
d1d9f5569f docs: update compat table with 17.3 (#54882)
PR Close #54882
2024-03-27 09:58:11 -07:00
Ben Hong
7763387253 docs: reduce confusion on tutorial intro and reorder how resources are introduced (#55051)
PR Close #55051
2024-03-27 09:56:44 -07:00
Doug Parker
0ec68a2a40 release: bump Angular DevTools version to 1.0.12 (#55056)
Also fixes a typo in release docs for the Firefox `zip` command.

PR Close #55056
2024-03-27 09:55:41 -07:00
Paul Gschwendtner
2ad5dcf3f0
[17.3.x]: build: follow-up fixes for AIO lighthouse checks (#55065)
* build: follow-up fixes for AIO lighthouse checks

Looks like the latest versions of Lighthouse and puppeteer
are not compatible with our Chromium version from dev-infra.

This commit reverts the updates, and fixes the jobs.

Update payload size; now matching — seems expected
2024-03-27 15:46:46 +01:00
Paul Gschwendtner
9aff43b5e8 ci: fix build failures in patch branch (#55064)
This commit fixes various issues that seem to cause the 17.3.x patch
to be red for weeks:

- Eslint checking a file for aio/tools that is not part of a tsconfig—
  hence an error is being reported.

- Audit-web-app importing some Lighthouse APIs that aren't available
  under the given path.

PR Close #55064
2024-03-27 11:58:46 +00:00
AleksanderBodurri
fa46844f5c fix(devtools): issue where backendReady race condition causes Angular not detected error (#54805)
Previously, a race condition could cause DevTools to enter a state where it can't detect an application on reload. This was caused by a sequencing issue between the content script connection, the devtools panel connection and an event "backendReady" that lets DevTools know when a particular frame is ready to be inspected.

This commit replaces the previously stored backendReady boolean with a promise, so that the devtools panel can eventually run a callback to connect to a content script when that content script emits it's backendReady message.

PR Close #54805
2024-03-26 09:19:16 -07:00
AleksanderBodurri
cd00ec582b Revert "Revert "refactor(devtools): implement multiframe support in devtools page (#53934)" (#54629)" (#54805)
This reverts commit 133319eba0.

PR Close #54805
2024-03-26 09:19:14 -07:00
AleksanderBodurri
821012d0f7 Revert "Revert "refactor(devtools): implement iframe support for Angular DevTools' browser code (#53934)" (#54629)" (#54805)
This reverts commit dd9f9d7d44.

PR Close #54805
2024-03-26 09:19:14 -07:00
Alan Agius
8958e0bf70 Revert "fix(http): exclude caching for authenticated HTTP requests (#54746)" (#55033)
This reverts commit 2258ac7a32.

Closes: #55031

PR Close #55033
2024-03-26 09:16:34 -07:00
Matthieu Riegler
4bb332ef08 refactor(common): request low quality placeholder images (#54899)
For every built-in load, this commit adds a parameter to load low quality placeholder images. Using 20/100 as base value.

PR Close #54899
2024-03-25 11:17:34 -07:00
Alan Agius
64f202cab9 fix(http): manage different body types for caching POST requests (#54980)
This update enhances the encoding handling of request bodies to generate the necessary cache key for transfer cache functionality.

Closes #54956

PR Close #54980
2024-03-25 11:17:03 -07:00
Matthieu Riegler
cf34d2b87f docs: unescape html entities (#55016)
adev supports regular characters in place of entity. Let's use them to make the ease the work for the editors.

PR Close #55016
2024-03-25 11:16:35 -07:00
Andrea Canciani
ec4483c471 test(zone.js): fix zone.js test listener removal (#55017)
The test was checking the wrong set of listeners because of a typo.

PR Close #55017
2024-03-25 11:16:06 -07:00
Mahdi Lazraq
1f7e81aef9 refactor(http): use nullish coalescing operator in HttpRequest.clone() (#54939)
Refactor how boolean options are handled in HttpRequest.clone() method by using nullish coalescing operator

PR Close #54939
2024-03-21 22:13:45 -07:00
Mahdi Lazraq
cb433af0e1 fix(http): include transferCache when cloning HttpRequest (#54939)
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes #54924.

PR Close #54939
2024-03-21 22:13:44 -07:00
Joey Perrott
3cf70e26ba ci: change label set by renovate to be merge ready immediately (#54947)
Since the PR is always expected to be ready to merge as renovate won't make changes in response to any sort of comment, it should already be marked as merge ready

PR Close #54947
2024-03-21 22:11:10 -07:00
Kristiyan Kostadinov
2b7bad5151 fix(compiler): invoke method-based tracking function with context (#54960)
Previously we assumed that if a `for` loop tracking function is in the form of `someMethod($index, $item)`, it will be pure so we didn't pass the parameter to bind the context to it. This appears to be risky, because we don't know if the method is trying to access `this`.

These changes play it safe by always binding method-based tracking functions.

Fixes #53628.

PR Close #54960
2024-03-21 22:08:41 -07:00
Andrew Scott
78d4ad20e6 ci: temporarily disable failing test (#54970)
this test is failing after #54711

PR Close #54970
2024-03-20 13:31:35 -07:00
Andrew Scott
c2149dfaa8 release: cut the v17.3.1 release 2024-03-20 12:49:30 -07:00