Commit graph

31195 commits

Author SHA1 Message Date
arturovt
da6970d2cb refactor(docs-infra): allow table of contents to be GCed (#58034)
This commit updates the table of contents functionality to clean up correctly whenever the user
navigates to other pages and nodes are removed from the DOM.

Currently, calling `renderComponent` with the `TableOfContents` keeps creating a new table of contents
component without removing the previous one, as they are created manually.

This leads to memory leaks because the components cannot be collected properly, even if the user
navigates to the home page where there is no TOC component.

PR Close #58034
2024-10-10 12:33:51 +00:00
Matthieu Riegler
57134dd344 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:50 +00:00
reosablo
410ed699a2 docs(core): fix description about signal value equality (#56472)
PR Close #56472
2024-10-10 10:24:32 +00:00
Jaime González Fábregas
b27045a124 docs(docs-infra): substitute string interpolation on json data with actual value (#57626)
substitute "${this.baseUrl}" with "https://angular.dev/assets/images/tutorials/common" in the photo url on the json data provided on the hands on tutorial in the webpage "https://angular.dev/tutorials/first-app/14-http". The previous json content caused the images to fail loading.

PR Close #57626
2024-10-10 10:22:34 +00:00
Paul Gschwendtner
6530c5ecb0 release: cut the v19.0.0-next.9 release 2024-10-10 12:16:51 +02:00
Paul Gschwendtner
dff03d2029 docs: release notes for the v18.2.8 release 2024-10-10 12:06:32 +02:00
Georgy Serga
46a6324c82 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:22 +00:00
Georgy Serga
69529d8873 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:22 +00:00
Georgy Serga
2374b87b64 fix(compiler): preserve attributes attached to :host selector (#57796)
keep attributes used to scope :host selectors

PR Close #57796
2024-10-10 08:13:22 +00:00
Georgy Serga
e8d1944999 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:22 +00:00
Georgy Serga
292ea4714f fix(compiler): fix comment typo (#57796)
fix spelling in the comment

PR Close #57796
2024-10-10 08:13:22 +00:00
Georgy Serga
82144b6d63 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:22 +00:00
Georgy Serga
bc5f1175e9 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:21 +00:00
Paul Gschwendtner
471afd20e8 refactor(migrations): detect ternary narrowing in input and query migrations (#58136)
We should skip inputs/queries that are part of ternary narrowing
expressions. Those would break builds and we can quickly avoid this in
the safe mode as detection is rather easy with the existing analysis
data we have.

PR Close #58136
2024-10-10 08:12:22 +00:00
Youssef El Houti
1479af978c feat(service-worker): finish implementation of refreshAhead feature (#53356)
Copy and document the refreshAhead option that allows to refresh cache entries before they expire.
This allows to mark cached entries as stale while still retruning them until maxAge in case of service outage.

Closes #46729

PR Close #53356
2024-10-10 06:21:57 +00:00
Julien Saguet
95bee15362 refactor(service-worker): remove backward compatibility code (#51246)
Remove backward compatibility code from service worker package.

Fixes #43403

PR Close #51246
2024-10-09 16:24:36 +00:00
Paul Gschwendtner
66cca86489 refactor(migrations): allow reuse of input incompatibility categorization in query migration (#58139)
This commit moves the incompatibility categorization into a more common
place, and renames it from Input incompatibilities to "field
incompatibilities". This construct can then be used in the queries
migration as well to give insight into why certain fields weren't
migrated.

PR Close #58139
2024-10-09 16:23:33 +00:00
Paul Gschwendtner
2d1131491a refactor(migrations): improve statistic tracking of signal input migration (#58137)
We should skip tracking information for inputs outside migration scope.

PR Close #58137
2024-10-09 15:23:33 +00:00
Paul Gschwendtner
c1aa411cf1 fix(migrations): properly resolve tsconfig paths on windows (#58137)
The Angular CLI devkit and Tsurge, as well as TypeScript only deal with
Posix paths. We also normalize paths into posix paths, and try to
implement a devkit compatible virtual file system for the compiler-cli.

This commit fixes an issue where we accidentally resolved `/` to the
system root on Windows. e.g. `C:/`. This broke the posix and devkit
paths throughout tsconfig parsing.

This commit fixes this.

Fixes #58132.

PR Close #58137
2024-10-09 15:23:33 +00:00
cexbrayat
e00775a0c9 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:31 +00:00
Krzysztof Platis
9e82559de4 fix(platform-server): destroy PlatformRef when error happens during the bootstrap() phase (#58112)
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`

fixes #58111

PR Close #58112
2024-10-09 12:12:34 +00:00
Paul Gschwendtner
22132639e2 refactor(migrations): fix unique name generation not marking generated identifiers (#58126)
The unique name generator did not properly work to avoid collisions with
previously generated unique names. This commit fixes this and also
improves type safety of the logic.

PR Close #58126
2024-10-09 08:57:57 +00:00
Angular Robot
306443dc7c build: update actions/cache digest to 3624ceb (#58125)
See associated pull request for more information.

PR Close #58125
2024-10-08 13:27:58 -07:00
Kristiyan Kostadinov
67db4305c2 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:06 -07:00
Matthieu Riegler
66c39804db 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:23 -07:00
Sumit Arora
f5cd8f7ab4 refactor(core): adding publish global utils function (#58086)
Angular DevTools uses globally available functions to provide debugging information to the framework. This commit adds a new function to the framework that will allow Angular DevTools to publish these functions to the global namespace.

Follow up PRs that will use this arg will:
- Add a new function in the router package to publish `getLoadedRoutes` function to the global namespace
- Implement the router graph in the Angular DevTools to view the routes that are loaded in the application

PR Close #58086
2024-10-08 13:24:46 -07:00
P4
97fb86d331 perf(core): set encapsulation to None for empty component styles (#57130)
Make it so that encapsulation for empty styles, styles containing only whitespace and comments, etc.
is handled the same way as with no styles at all.

Components without styles already have view encapsulation set to `None`
to avoid generating unnecessary attributes for style scoping, like `_ngcontent-ng-c1` (#27175)

If the component has an empty external styles file instead, the compiler would generate
a component definition without the `styles` field, but still using the default encapsulation.
This can result in runtime overhead if the developer forgets to delete the empty styles file
generated automatically for new components by Angular CLI.

Closes #16602

PR Close #57130
2024-10-08 09:30:01 -07:00
Sheik Althaf
1e50374d75 fix(devtools): avoid duplicate dependencies in injected services (#57564)
with latest signal apis there are duplicates dependencies are shown in injected services, this PR filters the depdencies by token and value

PR Close #57564
2024-10-08 09:29:18 -07:00
ColinJolivet
5e0029237c refactor(docs-infra): add tooltip to the download button in playground (#58065)
Add a material tooltip to the download button in the playground in order to clarify what this button does

PR Close #58065
2024-10-08 09:28:37 -07:00
Lang
749649a2a7 docs: complete the example in use InjectionToken section (#57839)
PR Close #57839
2024-10-08 09:27:22 -07:00
Dylan Hunn
09f589f000 fix(compiler): this.a should always refer to class property a (#55183)
Consider a template with a context variable `a`:
```
<ng-template let-a>{{this.a}}</ng-template>
```

t push -fAn interpolation inside that template to `this.a` should intuitively read the class variable `a`. However, today, it refers to the context variable `a`, both in the TCB and the generated code.

In this commit, the above interpolation now refers to the class field `a`.

BREAKING CHANGE: `this.foo` property reads no longer refer to template context variables. If you intended to read the template variable, do not use `this.`.
Fixes #55115

PR Close #55183
2024-10-08 16:02:18 +00:00
Paul Gschwendtner
bc83fc1e2e feat(language-service): support converting to signal queries in VSCode extension (#58106)
This commit adds support for converting decorator queries to signal queries
via the VSCode extension.

Note that this is not fully finished as we still need to add better
messaging when certain fields could not be migrated.

In addition, it's worth noting that the migration is not as safe as the
input migration because commonly query lists are passed around— this
quickly can break the build— but is an acceptable trade-off for the work
saved. A migration cannot be 100% correct in general; there are always
edge-cases.

PR Close #58106
2024-10-08 06:19:37 +00:00
Paul Gschwendtner
37483926ea refactor(migrations): speed up reference resolution in templates (#58106)
Instead of inspecting all types of property accesses, we can use a
similar optimization we did for TS references— leveraging the list of
known field names to minimize type checker calls.

PR Close #58106
2024-10-08 06:19:37 +00:00
Paul Gschwendtner
03af45540c refactor(compiler-cli): support specifying OptimizeFor when retrieving TCB information (#58106)
Whenever information is requested from the template checker right now,
the shim is only ensured to be generated for the single file/component.
This is slow in migrations where we don't want to collect diagnostics,
but rather request information from the component state.

This commit supports `OptimizeFor` in `checker#getTemplate`.

PR Close #58106
2024-10-08 06:19:37 +00:00
Paul Gschwendtner
754a857f8c refactor(migrations): support extra return info for TsurgeMigration#migrate (#58106)
This allows us to return extra properties along with `#migrate`
replacements. Useful for language service integration or other
integrations of Tsurge migrations in special runners.

PR Close #58106
2024-10-08 06:19:37 +00:00
Angular Robot
c77e0b2afb build: update scorecard action dependencies (#58116)
See associated pull request for more information.

PR Close #58116
2024-10-08 06:18:16 +00:00
Angular Robot
a762425e31 build: update actions/cache digest to 2cdf405 (#58107)
See associated pull request for more information.

PR Close #58107
2024-10-08 06:17:36 +00:00
Joey Perrott
5c63fc4468 ci: update renovate configuration to automatically run generated file updates (#58109)
Automatically update generated files when changes are made in renovate

PR Close #58109
2024-10-07 13:27:52 -07:00
Angular Robot
ce95449fe0 build: update actions/checkout digest to eef6144 (#58108)
See associated pull request for more information.

PR Close #58108
2024-10-07 13:26:52 -07:00
Angular Robot
cbf7995d9d build: update dependency @inquirer/prompts to v7 (#58099)
See associated pull request for more information.

PR Close #58099
2024-10-07 13:26:01 -07:00
AleksanderBodurri
837af44510 refactor(core): introduce debugName optional arg to ReactiveNode (#57710)
This commit contains the changes to core/primitives that used to be in https://github.com/angular/angular/pull/57073.

PR Close #57710
2024-10-07 09:25:28 -07:00
arturovt
69763491c3 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:53 -07:00
Kristiyan Kostadinov
8d8c03abc4 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
Alan Agius
5c61f46409 refactor(platform-browser): remove deprecated BrowserModule.withServerTransition method (#58062)
BREAKING CHANGE: The deprecated `BrowserModule.withServerTransition` method has been removed. Please use the `APP_ID` DI token to set the application id instead.

PR Close #58062
2024-10-07 08:23:53 -07:00
Luan Gong
109366e2fc docs: use correct heading in templates guide (#58101)
PR Close #58101
2024-10-07 08:22:45 -07:00
Matthieu Riegler
186b52449a 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:55 -07:00
Daniel Jancar
656b5d3e78 fix(core): Re-assign error codes to be within core bounds (<1000) (#53455)
`RUNTIME_DEPS_INVALID_IMPORTED_TYPE` is now 980
`RUNTIME_DEPS_ORPHAN_COMPONENT` is now 981

PR Close #53455
2024-10-07 08:21:13 -07:00
Charles Lyding
d9dc41a18c test(compiler-cli): add compliance tests for external runtime styles (#57613)
To ensure that the external runtime style component feature is correctly
emitted by the Angular compiler, compliance tests have been added for
file-based component styles. Additionally, the partial golden generator
has been updated to work with file-based component styles.

PR Close #57613
2024-10-07 08:20:22 -07:00
Charles Lyding
da250b2819 refactor(compiler-cli): add inline stylesheet external runtime style transformation support (#57613)
To provide support for HMR of inline component styles (`styles` decorator field), the AOT
compiler will now use the resource host transformation API with the Angular CLI to provide
external runtime stylesheet URLs when the `externalRuntimeStyles` compiler option is enabled.
This allows both a component's file-based and inline styles to be available for HMR when used
with a compatible development server such as with the Angular CLI. No behavioral change is
present if the `externalRuntimeStyles` option is not enabled or the resource host transformation
API is not used.
An `order` numeric field is also added to the transformation API which allows consumers such as
the Angular CLI to create identifiers for each inline style in a specific containing file.

PR Close #57613
2024-10-07 08:20:22 -07:00
Charles Lyding
c69371151a refactor(compiler): support external runtime component styles for file-based stylesheets (#57613)
The AOT compiler now has the capability to handle component stylesheet files as
external runtime files. External runtime files are stylesheets that are not embedded
within the component code at build time. Instead a URL path is emitted within a component's
metadata. When combined with separate updates to the shared style host and DOM renderer,
this will allow these stylesheet files to be fetched and processed by a development
server on-demand. This behavior is controlled by an internal compiler option `externalRuntimeStyles`.
The Angular CLI development server will also be updated to provide the serving functionality
once this capability is enabled. This capability enables upcoming features such as automatic
component style hot module replacement (HMR) and development server deferred stylesheet processing.
The current implementation does not affect the behavior of inline styles. Only the
behavior of stylesheet files referenced via component properties `styleUrl`/`styleUrls`
and relative template `link` elements are changed by enabling the internal option.

PR Close #57613
2024-10-07 08:20:22 -07:00