Commit graph

12207 commits

Author SHA1 Message Date
Alan Agius
1c30234d24 ci: update dev-infra github actions to latest SHA (#63640)
This commit updates all usages of `angular/dev-infra/github-actions` to their latest SHA.
This is necessary to ensure that all workflows are using the most up-to-date versions of the actions,
which can include bug fixes, performance improvements, or new features.

PR Close #63640
2025-09-09 10:46:27 -07:00
Alan Agius
9d1fb33f5e fix(core): introduce BootstrapContext for improved server bootstrapping (#63640)
This commit introduces a number of changes to the server bootstrapping process to make it more robust and less error-prone, especially for concurrent requests.

Previously, the server rendering process relied on a module-level global platform injector. This could lead to issues in server-side rendering environments where multiple requests are processed concurrently, as they could inadvertently share or overwrite the global injector state.

The new approach introduces a `BootstrapContext` that is passed to the `bootstrapApplication` function. This context provides a platform reference that is scoped to the individual request, ensuring that each server-side render has an isolated platform injector. This prevents state leakage between concurrent requests and makes the overall process more reliable.

BREAKING CHANGE:
The server-side bootstrapping process has been changed to eliminate the reliance on a global platform injector.

Before:
```ts
const bootstrap = () => bootstrapApplication(AppComponent, config);
```

After:
```ts
const bootstrap = (context: BootstrapContext) =>
  bootstrapApplication(AppComponent, config, context);
```

A schematic is provided to automatically update `main.server.ts` files to pass the `BootstrapContext` to the `bootstrapApplication` call.

In addition, `getPlatform()` and `destroyPlatform()` will now return `null` and be a no-op respectively when running in a server environment.

(cherry picked from commit 8bf80c9d2314b4f2bcf3df83ae01552a6fc49834)

PR Close #63640
2025-09-09 10:46:27 -07:00
Matthieu Riegler
06d70a25ea fix(migrations): take care of tests that import both HttpClientModule & HttpClientTestingModule. (#58777)
While having both `HttpClientModule` & `HttpClientTestingModule` serves no real purpose (`HttpClientTestingModule` imports `HttpClientModule`), some code bases can have those 2 together and the migration can be quite breaking.

fixes #58536

PR Close #58777
2024-11-22 14:47:12 +00:00
Alan Agius
4c38160853 fix(compiler-cli): correct extraction of generics from type aliases (#58548)
**Before:**
```ts
type HttpEvent = | HttpSentEvent
  | HttpHeaderResponse
  | HttpResponse<T>
  | HttpProgressEvent
  | HttpUserEvent<T>
```

**After:**
```ts
type HttpEvent<T> = | HttpSentEvent
  | HttpHeaderResponse
  | HttpResponse<T>
  | HttpProgressEvent
  | HttpUserEvent<T>
```

PR Close #58548
2024-11-08 17:15:08 +00:00
Kristiyan Kostadinov
5f2d98a1b1 fix(core): avoid slow stringification when checking for duplicates in dev mode (#58521)
When we check for duplicates in dev mode, we end up stringifying an `LView` even if we don't report an error. This can be expensive in large views.

These changes work around the issue by only generating the string when we have an error to throw.

Fixes #58509.

PR Close #58521
2024-11-06 13:02:35 +01:00
Kristiyan Kostadinov
3aa45a2fa1 fix(core): resolve forward-referenced host directives during directive matching (#58492) (#58500)
When the compiler generates the `HostDirectivesFeature`, it generates either an eager call (`ɵɵHostDirectivesFeature([])`) or a lazy call (`ɵɵHostDirectivesFeature(() => [])`. The lazy call is necessary when there are forward references within the `hostDirectives` array. Currently we resolve the lazy variant when the component definition is created which has been enough for most cases, however if the host is injected by one of its host directives, we can run into a reference error because DI is synchronous and the host's class hasn't been defined yet.

These changes resolve the issue by pushing the lazy resolution later during directive matching when all classes are guanrateed to exist.

Fixes #58485.

PR Close #58492

PR Close #58500
2024-11-04 17:18:52 +01:00
Costin Sin
adbc27cac1 refactor(zone.js): Change the type of _taskCounts to an IndexSignature that can have keys (#51739)
named as the values of the `TaskType` type.

The Closure Compiler used at Google has a property renaming optimization
that can change the property names when minifying code. Having the
correct type helps the TSJS team that develops a tool to identfy
property renaming issues directly in TypeScript.

Signed-off-by: Costin Sin <sin.costinrobert@gmail.com>

PR Close #51739
2024-11-01 15:44:07 +00:00
Matthieu Riegler
69dce38e77 Revert fix(compiler): transform pseudo selectors correctly for the encapsulated view. (#58417)
This commit reverts #57796 for v18

PR Close #58417
2024-10-30 09:26:22 -07:00
Kristiyan Kostadinov
ddda3558ca refactor(core): remove globalApi tag (#58375)
`@globalApi` was an AIO implementation detail that isn't relevant anymore.

PR Close #58375
2024-10-28 12:33:53 -07:00
Daniel Payet
3b989ac5bd fix(localize): Adding arb format to the list of valid formats in the localization extractor cli (#58287)
Although the ARB format is supported, it's missing from the command's list of options.

Fix #58286

PR Close #58287
2024-10-24 16:41:48 -07:00
Néstor Sabater
e638b292f2 docs(router): document segment consumption during route evaluation (#58069)
PR Close #58069
2024-10-24 12:41:39 -07:00
TupiC
d1cfbb1f92 docs: removed typos of withHttpTransferCacheOptions description (#58244)
Removed two typos in the withHttpTransferCacheOptions function description.

- Corrected spelling of "whether"
- Changed spelling from "a an" to "an"
PR Close #58244
2024-10-18 10:14:10 +00:00
Kristiyan Kostadinov
b0ab653965 fix(compiler-cli): report when NgModule imports or exports itself (#58231)
Reports a diagnostic if an NgModule refers to itself in its `imports` or `exports`. Previously the compiler would go into an infinite loop.

Fixes #58224.

PR Close #58231
2024-10-18 09:26:45 +00:00
cexbrayat
37b921dcde refactor(core): test EventEmitter completion on destroy with outputToObservable (#58239)
A unit test has been added to check that `EventEmitter` properly completes upon component/directive destrouction when used with `outputToObservable`.
It explains why `destroyRef` has to be injected in `EventEmitter` in the first place.

PR Close #58239
2024-10-17 11:37:58 +00:00
Dzhavat Ushev
532bd11f41 docs(language-service): fix link URLs (#58143)
PR Close #58143
2024-10-16 14:48:13 +00:00
Matthieu Riegler
608a1511ca refactor(compiler-cli): Don't extract abstract overload multiple times (#57707)
Prior to this commit, each abstract method that was overloaded was extracted. With this commit it will be extracted only once. Every overload was and still will be supported by the signatures.

fixes #57693

PR Close #57707
2024-10-16 07:31:48 +00:00
vladboisa
47467949d8 docs: move JSDoc below constructor (#57187)
Move the JSDoc above transform signature for correct view

Fixes #56349

refactor: format file

PR Close #57187
2024-10-10 12:37:36 +00:00
Matthieu Riegler
a9e440d96b refactor(core): drop the Mutable utility type. (#58124)
The complexity of this type isn't necessary, `Writable` is well suited where it was used.

PR Close #58124
2024-10-10 10:47:51 +00:00
Georgy Serga
21be258be6 fix(compiler): scope :host-context inside pseudo selectors, do not decrease specificity (#57796)
parse constructions like `:where(:host-context(.foo))` correctly
revert logic which lead to decreased specificity if `:where` was applied
to another selector, for example `div` is transformed to `div[contenta]`
with specificity of (0,1,1) so `div:where(.foo)` should not decrease it
leading to `div[contenta]:where(.foo)` with the same specificity (0,1,1)
instead of `div:where(.foo[contenta])` with specificity equal to (0,0,1)

PR Close #57796
2024-10-10 08:13:23 +00:00
Georgy Serga
d325f9b55f fix(compiler): fix parsing of the :host-context with pseudo selectors (#57796)
fix regexp which is used to test for host inside pseudo selectors

PR Close #57796
2024-10-10 08:13:23 +00:00
Georgy Serga
aea747ab3b fix(compiler): preserve attributes attached to :host selector (#57796)
keep attributes used to scope :host selectors

PR Close #57796
2024-10-10 08:13:23 +00:00
Georgy Serga
11692c8dab fix(compiler): add multiple :host and nested selectors support (#57796)
add support for nested and deeply nested (up to three levels) selectors,
parse multiple :host selectors, scope selectors within pseudo functions

PR Close #57796
2024-10-10 08:13:23 +00:00
Georgy Serga
48a1437e77 fix(compiler): fix comment typo (#57796)
fix spelling in the comment

PR Close #57796
2024-10-10 08:13:23 +00:00
Georgy Serga
66dcc691f5 fix(compiler): allow combinators inside pseudo selectors (#57796)
allow css combinators within pseudo selector functions, parsing those
correctly. Similarly to previous version, don't break selectors
into part if combinators are within parenthesis, for example
`:where(.one > .two)`

PR Close #57796
2024-10-10 08:13:23 +00:00
Georgy Serga
7a6fd427d5 fix(compiler): transform pseudo selectors correctly for the encapsulated view (#57796)
fix scoping and transforming logic of the `shimCssText` for the
components with encapsulated view:
- add support for pseudo selector functions
- apply content scoping for inner selectors of `:is()` and `:where()`
- allow multiple comma separated selectors inside pseudo selectors

Fixes #45686

PR Close #57796
2024-10-10 08:13:22 +00:00
cexbrayat
31fb9d0d52 docs: mention autoDetectChanges parameter default value (#58092)
It was unclear whether the parameter was necessary, as its default value was not mentioned in the jdsoc.

PR Close #58092
2024-10-09 13:50:32 +00:00
Krzysztof Platis
b40875a2cc fix(platform-server): destroy PlatformRef when error happens during the bootstrap() phase (#58112) (#58135)
The `bootstrap()` phase might fail e.g. due to an rejected promise in some `APP_INIIALIZER`.
If `PlatformRef` is not destroyed, then the main app's injector is not destroyed and therefore `ngOnDestroy` hooks of singleton services is not called on the end (failure) of SSR.

This could lead to possible memory leaks in custom SSR apps, if their singleton services' `ngOnDestroy` hooks contained an important teardown logic (e.g. unsubscribing from RxJS observable).

Note: I needed to fix by the way another thing too: now we destroy `moduleRef` when `platformInjector` is destroyed - by setting a `PLATFORM_DESTROY_LISTENER`

Patch port of #58112

PR Close #58135
2024-10-09 13:50:02 +00:00
Kristiyan Kostadinov
46bafb0b0a fix(core): clean up afterRender after it is executed (#58119)
We stop tracking `afterRender` hooks as soon as they execute, but their on destroy callbacks stay registered until either the injector is destroyed or the user calls `destroy` manually. This was leading to memory leaks in the `@defer` triggers based on top of `afterRender` when placed inside long-lived views, because the callback would execute, but its destroy logic was waiting for the view to be destroyed.

These changes resolve the issue by destroying the `AfterRenderRef` once it is executed.

PR Close #58119
2024-10-08 13:27:07 -07:00
Matthieu Riegler
9ca9db4f74 refactor(core): drop ViewRefTracker in favor of ApplicationRef. (#58096)
We can leverage an `import type` to prevent the circular import.

PR Close #58096
2024-10-08 13:25:24 -07:00
arturovt
02de7fc731 fix(zone.js): remove abort listener once fetch is settled (#57882)
This commit updates the `fetch` patch for zone.js. Currently, we're attaching an
`abort` event listener on the signal (when it's provided) and never removing it.
We should be good citizens and remove event listeners whenever objects need to be
properly collected. In Firefox, when saving a heap snapshot and running it through
`fxsnapshot`, querying `AbortSignal` will print a so-called "CaptureMap" with a list
of "lambdas," indicating that the signal is not garbage collected because of the event
listener lambda function.

PR Close #57882
2024-10-07 08:27:54 -07:00
Kristiyan Kostadinov
f187c3abf8 fix(compiler-cli): defer symbols only used in types (#58104)
Currently we don't defer any symbols that have references outside of the `import` statement and the `imports` array. This is a bit too aggressive, because it's possible that the symbol is only used for types (e.g. `viewChild<SomeCmp>('ref')`) which will be stripped when emitting to JS.

These changes expand the logic so that references inside type nodes aren't considered.

**Note:** one special case is when the symbol used in constructor-based DI (e.g. `constructor(someCmp: SomeCmp)`, because these constructors will be compiled to `directiveInject` calls. We don't need to worry about them, because the compiler introduces an addition `import * as i1 from './some-cmp';` import that it uses to refer to the symbol.

Fixes #55991.

PR Close #58104
2024-10-07 08:26:07 -07:00
Matthieu Riegler
b35e7f8bb3 docs: add info on AbstractControl.source type. (#58094)
The source can be of any type and can't be inferred from `T`

fixes #58076

PR Close #58094
2024-10-07 08:21:56 -07:00
vladboisa
10081a9d7a docs: move JSDoc before functions (#58087)
Move the JSDoc before functions for correct view of params

PR Close #58087
2024-10-04 14:47:53 -07:00
Adrien Crivelli
ccf2c7f40e docs(common): Minor typo in code example (#58085)
PR Close #58085
2024-10-04 14:38:41 -07:00
Angular Robot
3fb696df96 refactor(compiler): update dependency chokidar to v4 (#57945)
This commit bump chokidar to the latest major and adjusts to the breaking changes.

PR Close #57945
2024-10-04 10:56:03 -07:00
arturovt
69702b17cc docs(zone.js): update docs to enable beforeunload (#57881)
In this commit, we update the documentation to reflect the property that allows
enabling the default browser `beforeunload` handling, which was added in a
previous commit.

Additionally, some cosmetic grammar changes have been made in this documentation,
as the previous text had some issues.

Closes #52256

PR Close #57881
2024-10-04 10:55:01 -07:00
Matthieu Riegler
1db1b3d6b8 refactor(compiler-cli): exclude private computed properties from class member extractions (#57596)
This will exclude properties like `[ɵWRITABLE_SIGNAL]` from the `WritableSignal` interface.

PR Close #57596
2024-10-04 13:29:52 +00:00
Jeevan Mahesha
42eb096b77 docs: update comments to use consistent code formatting for boolean values (#57619)
PR Close #57619
2024-10-02 18:00:52 +00:00
arturovt
46a2ad39f5 fix(common): prevent warning about oversize image twice (#58021)
I’ve noticed that there was a loop inside a loop. Since we’re already iterating through
`images` using `forEach`, it was running a `for` loop through `images` again. This was
probably a mistake made when the functionality was initially added. The test actually
verified that `logs.length` is `1`, but in the real environment, it logs twice
(which is quite obvious due to the code).

I’ve also added the missing file to the Bazel target.

PR Close #58021
2024-10-02 11:46:18 +00:00
Matthieu Riegler
7c16e70b20 build: Add LICENSE file to the generated packages (#58033)
This commit adds a parameter to `ng_package` to specify a license file that will be bundled with the generated packages.

fixes #58029

PR Close #58033
2024-10-01 16:34:27 +00:00
Andrew Scott
0e62b30989 docs(router): Document missing input for route binding (#57697)
This commit clearly documents the approach used by router input binding
when an input is not present in the route data.

resolves #52946

PR Close #57697
2024-10-01 08:09:33 +00:00
arturovt
ca637fe6a9 fix(http): cleanup JSONP script listeners once loading completed (#57877)
This commit removes event listeners from the `script` element once loading is
complete. If the element is not garbage collected properly, in Firefox, the script
element still appears in the memory tree view, captured by
`__zone_symbol__loadfalse -> HTMLScriptElement -> GC Roots`. We should always be good
citizens and clean up event listeners when we no longer need them, as browser's garbage
collectors work differently. Calling `remove()` on the node doesn't guarantee that the
node can be collected.

PR Close #57877
2024-10-01 08:08:40 +00:00
Kristiyan Kostadinov
b9d846dad7 fix(migrations): delete constructor if it only has super call (#58013)
Adds some logic to the `inject` migration that will remove constructors that are made up of only a `super` call after the migration.

PR Close #58013
2024-09-30 13:39:43 -07:00
arturovt
8f2b0ede59 fix(common): skip checking whether SVGs are oversized (#57966)
Prior to this commit, the `ImagePerformanceWarning` class was checking all `img`
elements in the DOM to determine whether they were oversized after the DOM loading
was complete. We should not check SVGs because they are vector-based and can scale
infinitely without losing quality.

Closes #57941

PR Close #57966
2024-09-30 13:28:46 -07:00
Kristiyan Kostadinov
2f347ef8fc fix(core): provide flag to opt into manual cleanup for after render hooks (#57917)
Adds a `manualCleanup` flag to `afterRender` and `afterNextRender`, similarly to `effect`. The reason is that currently if the hook is created outside of an injection context, it requires an injector to be passed in. In some cases that injector might be an injector that is never destroyed (e.g. `EnvironmentInjector`) which can give a false sense of security users thinking that the hook will be cleaned up automatically. We fell into this in the CDK which caused a memory leak (see https://github.com/angular/components/pull/29709). With the `manualCleanup` option users explicitly opt into cleaning the hook up themselves.

PR Close #57917
2024-09-26 14:20:55 -07:00
Swami
9d5b1eccff docs: correct HashLocationStrategy example url (#57908)
PR Close #57908
2024-09-26 14:20:01 -07:00
Thomas Nguyen
2e7cfcb2ef refactor(core): Remove global event delegation code. (#57893)
This is no longer needed since we are no longer experimenting with it.

PR Close #57893
2024-09-26 14:18:18 -07:00
Alex Rickabaugh
e40a4fa3c7 fix(upgrade): support input signal bindings (#57020)
`@angular/upgrade` writes to inputs when downgrading an Angular 2+ component
into an Angular.JS adapter. Previously, it wrote directly to the input
property, which isn't compatible with input signals. It also handles
`ngOnChanges` directly.

The correct way to support input signals would be to refactor upgrade to use
`ComponentRef.setInput`, which also handles `ngOnChanges` internally.
However, this refactoring might be more breaking since it would change the
timing of certain operations. Instead, this commit updates the code to
recognize `InputSignal` and write it through the `InputSignalNode`. This
avoids the above breaking changes for now, until a bigger refactoring can be
tested.

Fixes #56860.

PR Close #57020
2024-09-26 14:14:15 -07:00
Enea Jahollari
901c1e1a7f fix(compiler-cli): correctly get the type of nested function call expressions (#57010)
This PR fixes a bug where the type of a nested function call expression was incorrectly being returned as null.

PR Close #57010
2024-09-26 14:13:04 -07:00
arturovt
249d0260f9 fix(common): execute checks and remove placeholder when image is already loaded (#55444)
With this commit, we're now able to perform checks even when the image has already
been loaded (e.g., from the browser cache), and its `load` event would never be triggered.
We use the [complete](https://html.spec.whatwg.org/#dom-img-complete) property, as specified,
which indicates that the image state is fully available when the user agent has retrieved all
the image data. This approach effectively triggers checks, as we no longer solely rely on the
`load` event and consider that the image may already be loaded.

This will not remove the placeholder until the `load` event fires (and it won't fire if the
image is already "there").

This prevents memory leaks in development mode, as `load` and `error` event listeners are
still attached to the image element.

PR Close #55444
2024-09-26 14:12:01 -07:00