Commit graph

36863 commits

Author SHA1 Message Date
Paul Gschwendtner
37e3b03b52 refactor(migrations): improve readability of strictness logic in input migration (#58168)
This commit improves readability/reasoning of the input converting logic
that does things differently based on strictness flags.

PR Close #58168
2024-10-13 16:47:03 +00:00
Paul Gschwendtner
7e785588a7 refactor(migrations): gracefully proceed migration if there is an invalid query (#58168)
In rare cases, there may be queries that fail Angular compiler-cli
extraction. This should not prevent migration of other queries and
instead be a graceful error.

PR Close #58168
2024-10-13 16:47:03 +00:00
Paul Gschwendtner
2cf88bba9a refactor(language-service): add support for running best-effort queries refactoring (#58168)
This is a follow-up to the VSCode queries code refactoring feature. This
commit adds support for running the refactoring with
`--best-effort-mode`.

PR Close #58168
2024-10-13 16:47:03 +00:00
Paul Gschwendtner
10d294c9d9 refactor(migrations): do not migrate .toArray, .first if query is skipped (#58168)
If a query is skipped for incompatibility reasons, we should not migrate
their `toArray`, `.first` references

PR Close #58168
2024-10-13 16:47:03 +00:00
Paul Gschwendtner
f48354af0b refactor(migrations): support inserting TODOs for queries migration (#58168)
Allows users to enable TODO insertion to see why certain queries did not
get migrated.

PR Close #58168
2024-10-13 16:47:03 +00:00
Paul Gschwendtner
4b089621be refactor(migrations): share TODO insertion logic of input migration (#58168)
This allows us to re-use the same logic in the queries migration.

PR Close #58168
2024-10-13 16:47:03 +00:00
Paul Gschwendtner
a141ee8fb2 refactor(migrations): add best-effort-mode for queries migration (#58168)
Allows users to ignore detected incompatibilities and migrate as much as
possible. Similar to the input migration.

PR Close #58168
2024-10-13 16:47:02 +00:00
Paul Gschwendtner
19369d78ba refactor(migrations): share best effort logic between input and query migration (#58168)
Allows us to easily implement a best effort mode for both migrations.

PR Close #58168
2024-10-13 16:47:02 +00:00
Paul Gschwendtner
349de49964 refactor(migrations): properly detect and skip queries with accessors (#58168)
Currently the migration does not detect queries declared on accessors.
This is fine as we cannot migrate them anyway.

We should still try to detect them and mark them as incompatible so that
we could insert TODOs.

PR Close #58168
2024-10-13 16:47:02 +00:00
Paul Gschwendtner
f84e8ddcd9 ci: disable bazel-saucelabs job (#58162)
Disables the `bazel-saucelabs` job in `main`, and re-uses the PR legacy
saucelabs job to run on `main` instead (which is much more stable and
reliable).

PR Close #58162
2024-10-11 14:07:35 +00:00
Paul Gschwendtner
a59dbb7cd6 refactor(migrations): assign incompatibility reasons for query migration (#58152)
Instead of skipping queries without any reasoning, we should categorize
fields that couldn't be migrated. This is also important for the VSCode
integration— similar to how it's done with the inputs migration.

We are fully sharing the problematic pattern detection etc. This means
we are also sharing the enum. Not super ideal, but enables the best
sharing of code.

PR Close #58152
2024-10-11 11:23:38 +00:00
Angular Robot
b1985932e7 build: update io_bazel_rules_sass digest to 583fc8c (#58155)
See associated pull request for more information.

PR Close #58155
2024-10-11 10:37:56 +00:00
Kristiyan Kostadinov
fc6c76ac67 refactor(core): add internal utility to resolve the component name of a node (#58148)
Adds a utility, meant for internal consumption, that will return the class name of the closest component node to an element.

PR Close #58148
2024-10-11 07:04:40 +00:00
Kristiyan Kostadinov
fb44323c51 fix(compiler-cli): incorrectly generating relative file paths on case-insensitive platforms (#58150)
We're using `path.relative` to compute a relative path between a `SourceFile` and the one of the `rootDirs`. The problem is that the `rootDirs` get passed through `getCanonicalFileName` which lowercases the path in some platforms, while `SourceFile.fileName` is always case-insensitive. This yields a path outside of the project which we were ignoring.

This change passes the `SourceFile.fileName` before passing it through `path.relative` to ensure that we get a valid result.

PR Close #58150
2024-10-11 07:03:15 +00:00
Kristiyan Kostadinov
852c042520 refactor(compiler-cli): output HMR initializer code (#58150)
Adds the logic to the compiler that will output the HMR initializer code for each component, if enabled.

PR Close #58150
2024-10-11 07:03:15 +00:00
Kristiyan Kostadinov
6f7803a3ff refactor(compiler): add logic to generate the HMR initializer (#58150)
Adds the logic that will generate the `import` expression that will initializer HMR for a specific component.

PR Close #58150
2024-10-11 07:03:15 +00:00
vladboisa
08b4a8af6e 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:35 +00:00
Steven Tucker
a89fd30690 docs: Updated event-listeners.md doc to use correct term, even -> every (#57964)
event time -> every time

PR Close #57964
2024-10-10 12:36:41 +00:00
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