Commit graph

30805 commits

Author SHA1 Message Date
Matthieu Riegler
93bdbbc812 docs(docs-infra): Add dev-mode only mention for core/global (#57365)
PR Close #57365
2024-08-29 10:17:35 -07:00
Joey Perrott
07607716d4 ci: use version 13.15.1 of firebase-tools for deployment of doc sites (#57583)
Use 13.15.1 instead of tracking to latest to prevent unexpected and unbisectable changes.

PR Close #57583
2024-08-29 10:14:43 -07:00
Paul Gschwendtner
d9c1004a35 refactor(migrations): ensure control flow analysis of signal input migration works with all TS versions (#57566)
Ensures that the control flow analysis version of the signal input works
with all TS versions currently supported.

PR Close #57566
2024-08-29 07:51:39 -07:00
Paul Gschwendtner
bb29c8bbd7 refactor(migrations): cleanup TODOs in signal input migration (#57566)
Cleans up remaining TODOs in the signal input migration, and other
small clean ups.

PR Close #57566
2024-08-29 07:51:38 -07:00
Matthieu Riegler
8e1d6c71fc refactor(compiler-cli): extract function overload separatly (#56489)
in order for the docs to process function entry, this commit refactor function extraction by keeping the implementation as a the default entry and adds all the overloads into a separate array of entries.

PR Close #56489
2024-08-29 07:49:38 -07:00
Romain
98c6c05c6f docs(docs-infra): fix small mistake in inject-function.md (#57517)
PR Close #57517
2024-08-29 07:44:29 -07:00
Matthieu Riegler
3b7162d03c docs: Add mention to ENVIRONMENT_INITIALIZER (#57464)
Explicitly mention that `ENVIRONMENT_INITIALIZER` should not be async.

PR Close #57464
2024-08-29 07:43:48 -07:00
Vlad Boisa
3bc28678fa docs(docs-infra): remove hash before link (#57351)
Remove hash in link for correct view

Fixes #57349

docs(docs-infra): change the link

Change the link with name of class and method

docs: fix the link name

PR Close #57351
2024-08-29 07:42:13 -07:00
Matthieu Riegler
97fd311b6a docs(docs-infra): show usageNotes only for methods. (#57343)
Prior to this change, function and methods showed their usage notes which resulted in duplicate displays for functions.

Fixes #57339

PR Close #57343
2024-08-29 07:39:51 -07:00
Alex Rickabaugh
1853bbb061 release: cut the v18.2.2 release 2024-08-28 14:32:26 -07:00
Alex Rickabaugh
3ecf620cc5 Revert "fix(http): Dynamicaly call the global fetch implementation (#57531)" (#57571)
This reverts commit 21445a2932.

Reason: failing test

PR Close #57571
2024-08-28 12:42:27 -07:00
Paul Gschwendtner
36aa3af77b refactor(migrations): forward-fix conflicts with generic of ProgramInfo. (#57565)
One PR removed the generic of `ProgramInfo`, while another PR,
separately merged, introduced new instanes of `ProgramInfo`.

PR Close #57565
2024-08-28 09:17:34 -07:00
AleksanderBodurri
adf32746c2 fix(devtools): correctly set environment injector path in the case where there are no element injectors (#57442)
Previously, when "Hide injectors with no providers" was toggled, it is possible for the injector tree visualizer to have no Element injectors to visualize. This caused a bug in the slicing logic that splits apart the environment and element injectors from DI resolution paths within the injector tree component in Angular DevTools.

Now, this logic is correctly handled when there are no element injectors to visualize.

PR Close #57442
2024-08-28 08:49:34 -07:00
Matthieu Riegler
5501e9c8ed docs: remove @searchKeywords (#57560)
This tag is not supported.

fixes #57540

PR Close #57560
2024-08-28 08:49:05 -07:00
Paul Gschwendtner
389933f079 refactor(migrations): allow tsurge migrations to run with just NgCompiler (#57562)
This is important so that migrations can easily be wired up in the
language service where only `NgCompiler` is available.

PR Close #57562
2024-08-28 08:47:46 -07:00
Jeremy Elbourn
674aed5984 docs: cover time-based statements in docs authoring guide (#57536)
Adds some additional guidance on writing content that is tied to a
specific version or point in time.

PR Close #57536
2024-08-28 08:45:10 -07:00
Paul Gschwendtner
b14c864170 refactor(migrations): properly handle multi query migration (#57556)
Properly handles queries with multiple results, by extracting the
type from the `QueryList`.

Also adds more tests and handles imports.

PR Close #57556
2024-08-28 08:43:39 -07:00
Paul Gschwendtner
10fce207e0 refactor(migrations): initial migration logic for converting to signal queries (#57556)
Adds initial migration logic to convert decorator query declarations to
signal queries.

We will re-use more part of the signal input migration in follow-ups, to
properly migrate, and e.g. even handle control flow

PR Close #57556
2024-08-28 08:43:38 -07:00
Alex Rickabaugh
eba3a0ade0 Revert "refactor(migrations): initial migration logic for converting to signal queries (#57525)" (#57555)
This reverts commit 6f5b435a69.

Reason: breaks g3

PR Close #57555
2024-08-27 14:03:06 -07:00
Alex Rickabaugh
3d48a72193 Revert "refactor(migrations): properly handle multi query migration (#57525)" (#57555)
This reverts commit f454ad3bcf.

Reason: breaks g3

PR Close #57555
2024-08-27 14:03:06 -07:00
Matthieu Riegler
5d2e243c76 fix(http): Dynamicaly call the global fetch implementation (#57531)
Instead of using the reference that existing when `FetchBackend` is setup.

fixes #57527

PR Close #57531
2024-08-27 13:34:19 -07:00
Andrew Scott
5e9661d69c fix(docs-infra): Fix scrolling in application (#57554)
Since the change to the after render hooks, the "this" context must be
correct for the destroy to work.

fixes #57552

PR Close #57554
2024-08-27 13:32:14 -07:00
Kristiyan Kostadinov
df42d2be16 test: avoid leaking some LViews in tests (#57546)
We had some tests that were leaking LViews, because we were testing things like `createComponent`, but not destroying them afterwards. These changes clean up most of them, although there are a handful still left that I didn't have time to fully track down.

PR Close #57546
2024-08-27 13:29:09 -07:00
Kristiyan Kostadinov
106917af87 fix(core): avoid leaking memory if component throws during creation (#57546)
When we create the LView for a component, we track it in the `TRACKED_LVIEWS` map. It gets untracked when it is destroy, but if it throws during creation, the user won't have access to a `ComponentRef` in order to clean it up.

These changes automatically untrack the related LViews if the component couldn't be created.

PR Close #57546
2024-08-27 13:29:09 -07:00
Alan Agius
b74b5f0c06 build: remove Sourcemaps from Schematics bundles (#57545)
This commit reduces the bundle size of `@angular/core` by 19.5 MB by excluding sourcemaps from the schematics.

Since the `esbuild` rule doesn't allow disabling sourcemaps directly, we work around this by setting the sourcemaps to `external`. Afterward, we filter the output to include only the `.js` files.

PR Close #57545
2024-08-27 13:27:33 -07:00
Angular Robot
4231404065 build: update github/codeql-action action to v3.26.5 (#57543)
See associated pull request for more information.

PR Close #57543
2024-08-27 13:25:58 -07:00
Angular Robot
adcdfeca16 build: update dependency @babel/generator to v7.25.5 (#57542)
See associated pull request for more information.

PR Close #57542
2024-08-27 13:24:59 -07:00
Andrew Kushnir
4f8c406664 refactor(compiler): extend directive mock to avoid failing at matching logic (#57537)
This commit updates a directive mock instance to include an extra field that a compiler code was expecting, which caused issues while processing elements with local refs and exported directives.

PR Close #57537
2024-08-27 13:23:30 -07:00
Paul Gschwendtner
206b7be7f7 ci: fix fw-testing group triggering for schematics testing changes (#57526)
The `fw-testing` group should not trigger for schematic changes.

PR Close #57526
2024-08-27 13:21:48 -07:00
Andrew Scott
804925b114 fix(router): Do not unnecessarily run matcher twice on route matching (#57530)
This commit makes a small update to the route matching algorithm to
avoid running the matcher function of a route twice.

fixes #57511

PR Close #57530
2024-08-27 13:20:58 -07:00
Paul Gschwendtner
6a953c6ed4 refactor(migrations): properly handle multi query migration (#57525)
Properly handles queries with multiple results, by extracting the
type from the `QueryList`.

Also adds more tests and handles imports.

PR Close #57525
2024-08-27 13:20:19 -07:00
Paul Gschwendtner
01cae95596 refactor(migrations): initial migration logic for converting to signal queries (#57525)
Adds initial migration logic to convert decorator query declarations to
signal queries.

We will re-use more part of the signal input migration in follow-ups, to
properly migrate, and e.g. even handle control flow

PR Close #57525
2024-08-27 13:20:19 -07:00
AleksanderBodurri
371ad098d5 fix(devtools): ignore DOM Nodes from other frames when performing render tree detection (#57518)
Previously, if an application had DOM Nodes injected into it from other frames, DevTools would fail to parse component trees with the render tree strategy properly because of an instanceof Node check that the framework performs.

Now we check for instanceof Node before even calling framework debug APIs on DOM nodes so that we can skip nodes that come from other frames entirely.

PR Close #57518
2024-08-27 13:19:35 -07:00
Angular Robot
73ad6ea647 build: update dependency jsdom to v25 (#57514)
See associated pull request for more information.

PR Close #57514
2024-08-27 13:17:39 -07:00
Matthieu Riegler
d3366815ee refactor(animations): Add loading strategy for the Async Animations (#57493)
In some cases apps need to schedule a bit later the loading of the animation module. This private token will allow to investigate which other strategy could be useful.

PR Close #57493
2024-08-27 13:15:51 -07:00
Doug Parker
76ec60d73c refactor(compiler): ensure context is always provided for WhitespaceVisitor (#56507)
When disabling `i18nPreserveSignificantWhitespaceForLegacyExtraction` I was looking at a test case with ICU messages containing leading and trailing whitespace:

```angular
<div i18n>
  {apples, plural, =other {I have many apples.}}
</div>
```

This would historically generate two messages:

```javascript
const MSG_TMP = goog.getMsg('{apples, plural, =other {I have many apples.}}');
const MSG_FOO = goog.getMsg(' {$ICU} ', { 'ICU': MSG_TMP });
```

But I found that I was getting just one message:

```javascript
const MSG_TMP = goog.getMsg(' {apples, plural, =other {I have many apples.}} ');
```

This is arguably an improvement, but changed the messages and message IDs, which isn't desirable with this option. I eventually traced this back to the `isIcu` initialization in [`i18n_parser.ts`](/packages/compiler/src/i18n/i18n_parser.ts):

```typescript
const context: I18nMessageVisitorContext = {
  isIcu: nodes.length == 1 && nodes[0] instanceof html.Expansion,
  // ...
};
```

[`_I18nVisitor.prototype.visitExpansion`](/packages/compiler/src/i18n/i18n_parser.ts) uses this to decide whether or not to generate a sub-message for a given ICU expansion:

```typescript
if (context.isIcu || context.icuDepth > 0) {
  // Returns an ICU node when:
  // - the message (vs a part of the message) is an ICU message, or
  // - the ICU message is nested.
  const expPh = context.placeholderRegistry.getUniquePlaceholder(`VAR_${icu.type}`);
  i18nIcu.expressionPlaceholder = expPh;
  context.placeholderToContent[expPh] = {
    text: icu.switchValue,
    sourceSpan: icu.switchValueSourceSpan,
  };
  return context.visitNodeFn(icu, i18nIcu);
}

// Else returns a placeholder
// ICU placeholders should not be replaced with their original content but with the their
// translations.
// TODO(vicb): add a html.Node -> i18n.Message cache to avoid having to re-create the msg
const phName = context.placeholderRegistry.getPlaceholderName('ICU', icu.sourceSpan.toString());
context.placeholderToMessage[phName] = this.toI18nMessage([icu], '', '', '', undefined);
const node = new i18n.IcuPlaceholder(i18nIcu, phName, icu.sourceSpan);
return context.visitNodeFn(icu, node);
```

Note that `isIcu` is the key condition between these two cases and depends on whether or not the ICU expansion has any siblings. The introduction of `WhitespaceVisitor` to `I18nMetaVisitor` trims insignificant whitespace, including empty text nodes not adjacent to an ICU expansion (from [`WhitespaceVisitor.prototype.visitText`](/packages/compiler/src/ml_parser/html_whitespaces.ts)):

```typescript
const isNotBlank = text.value.match(NO_WS_REGEXP);
const hasExpansionSibling =
  context && (context.prev instanceof html.Expansion || context.next instanceof html.Expansion);

if (isNotBlank || hasExpansionSibling) {
  // Transform node by trimming it...
  return trimmedNode;
}

return null; // Drop node which is empty and has no ICU expansion sibling.
```

`hasExpansionSibling` was intended to retain empty text nodes leading or trailing an ICU expansion, however `context` was `undefined`, so this check failed and the leading / trailing text nodes were dropped. This resulted in trimming the ICU text by dropping the leading / trailing whitespace nodes. Having only a single ICU expansion with no leading / trailing text nodes caused `_I18nVisitor` to initialize `isIcu` incorrectly and caused it to generate one message instead of two.

`WhitespaceVisitor` is supposed to get this context from `visitAllWithSiblings`. So the fix here is to make sure `WhitespaceVisitor` is always visited via this function which provides the required context. I updated all usage sites to make sure this context is use consistently and implemented the `WhitespaceVisitor.prototype.visit` method to throw when the context is missing to make sure we don't encounter a similar mistake in the future.

Unfortunately this broke one compliance test. Specifically the [`icu_logic/icu_only.js`](/home/douglasparker/Source/ng/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_i18n/icu_logic/icu_only.js) test which changed from generating:

```javascript
function MyComponent_Template(rf, ctx) {
  if (rf & 1) {
    i0.ɵɵi18n(0, 0);
  }
  // ...
}
```

To now generating:

```javascript
function MyComponent_Template(rf, ctx) {
  if (rf & 1) {
    i0.ɵɵtext(0, " ");
    i0.ɵɵi18n(1, 0);
    i0.ɵɵtext(2, "\n");
  }
  // ...
}
```

This test uses the default value `preserveWhitespaces: false` (`i18nPreserveSignificantWhitespaceForLegacyExtraction` should not affect compiled JS output, we already retain significant whitespace there). So what this indicates to me is that ICU logic is already broken because it's not preserving significant whitespace in this case. My change is probably a bug fix, but one which would affect the compiled runtime, which is not in scope here. The root cause is because using `visitAllWithSiblings` everywhere means the context is retained correctly in this case and the whitespace is leading/trailing an ICU message, therefore it is retained per the logic of `WhitespaceVisitor.prototype.visitText` I mentioned eariler.

To address this, I left one usage of `WhitespaceVisitor` using `html.visitAll` instead of `visitAllWithSiblings` to retain this bug. I has to lossen the assertion I put in `WhitespaceVisitor.prototype.visit` to make this possible, but it should still throw by default when misused, which is the important part.

PR Close #56507
2024-08-27 13:13:57 -07:00
Doug Parker
7bfe81700b refactor(compiler): add i18nPreserveWhitespaceForLegacyExtraction (#56507)
This configures whether or not to preserve whitespace content when extracting messages from Angular templates in the legacy (View Engine) extraction pipeline.

This includes several bug fixes which unfortunately cannot be landed without changing message IDs in a breaking fashion and are necessary to properly trim whitespace. Instead these bug fixes are included only when the new flag is disabled.

PR Close #56507
2024-08-27 13:13:57 -07:00
Michael van der Luit
3067633bc7 docs(docs-infra): Add query as an url query param to the api reference (#57062)
add an url query param to perform a search on api references directly via the url

PR Close #57062
2024-08-27 12:58:00 -07:00
AleksanderBodurri
be82f282a4 fix(devtools): catch invalidated extension error to prevent devtools from spamming console (#55697)
When a browser extension is updated it becomes invalidated on currently open pages. If that extension then tries to send a message to those pages through `chrome.runtime.sendMessage(..)` then an error is thrown in the console

For Angular DevTools, this results in spamming the console with "Uncaught Error: Extension context invalidated." errors.

This commit catches that error and removes the event listener that triggers the `chrome.runtime.sendMessage(...)` call.

PR Close #55697
2024-08-27 12:54:44 -07:00
realstealthninja
03b35270b0 docs: fix typo in recommendations.ts (#57521)
PR Close #57521
2024-08-26 09:17:44 -07:00
Matthieu Riegler
fe9005ce8e docs: fix formating in class-binding (#57447)
fixes #57430

PR Close #57447
2024-08-26 09:12:55 -07:00
Bjarki
03ec620e31 fix(upgrade): Address Trusted Types violations in @angular/upgrade (#57454)
Angular applications that are AngularJS hybrids are currently unable to
adopt Trusted Types due to violations eminating from an innerHTML
assignment in the @angular/upgrade package. This commit allows
developers of such applications to optionally ignore this class of
violations by configuring the Trusted Types header to allow the new
angular#unsafe-upgrade policy.

Note that the policy is explicitly labeled as unsafe as it does not in
any way mitigate the security risk of using AngularJS in an Angular
application, but does unblock Trusted Types adoption enabling XSS
protection for other parts of the application.

The implementation follows the approach taken in @angular/core;
see packages/core/src/util/security.

PR Close #57454
2024-08-26 09:04:48 -07:00
Thomas Nguyen
6d3a2af146 fix(core): Do not bubble capture events. (#57476)
These should only fire if the target is the same as the targetElement. Also, delete an out of date test since capture/non-capture tests are separately covered.

PR Close #57476
2024-08-23 14:46:55 -07:00
Paul Gschwendtner
223b7857ef refactor(migrations): replacements in tsurge are always serializable (#57501)
This removes an unnecessary type wrapping that can be removed because
`Replacements` is expected to be serializable by default.

Similar to how it's done in `TsurgeComplexMigration`.

PR Close #57501
2024-08-23 13:49:31 -07:00
Angular Robot
5bdae0387f build: update dependency mermaid to v11 (#57499)
See associated pull request for more information.

PR Close #57499
2024-08-23 13:00:59 -07:00
Peter
034b32c133 docs: fix typo of ChangeDetectionStrategy in the zoneless guide (#57482)
PR Close #57482
2024-08-23 12:59:09 -07:00
Kristiyan Kostadinov
2a89e184e0 fix(zone.js): more robust check for promise-like objects (#57388)
Fixes that Zone.js wasn't checking properly if an object is promise-like.

Fixes #57385.

PR Close #57388
2024-08-23 12:58:29 -07:00
Santosh
9b6865ec03 docs: add test for i18n code block and fix rendering (#57210)
PR Close #57210
2024-08-23 12:57:15 -07:00
Alex Rickabaugh
6059ca8f1f refactor(core): restructure AfterRenderManager to connect related phases (#57453) (#57504)
The `afterRender` infrastructure was first implemented around the idea of
independent, singular hooks. It was later updated to support a spec of
multiple hooks that pass values from one to another as they execute, but the
implementation still worked in terms of singular hooks under the hood. This
creates a number of maintenance issues, and a few bugs. For example, when
one hook fails, further hooks in the pipeline should no longer execute, but
this was hard to ensure under the old design.

This refactoring restructures `afterRender` infrastructure significantly to
introduce the concept of a "sequence", a collection of hooks of different
phases that execute together. Overall, the implementation is simplified
while making it more resilient to issues and future use cases, such as the
upcoming `afterRenderEffect`.

As part of this refactoring, the `internalAfterNextRender` concept is
removed, as well as the unused `queueStateUpdate` concept which used it.

PR Close #57453

PR Close #57504
2024-08-23 12:48:01 -07:00
Alex Rickabaugh
800f6c8ca3 refactor(core): track dirtiness bits in ApplicationRef (#57453) (#57504)
Previously the zoneless scheduler had a concept of whether views needed to
be refreshed or not, based on the notification type that was received. It
tracked this information as a boolean.

This commit refactors things to track dirtiness in `ApplicationRef` itself,
as a `dirtyFlags` field with bits corresponding to either view tree
dirtiness or after-render hooks.

PR Close #57453

PR Close #57504
2024-08-23 12:48:01 -07:00