Commit graph

5958 commits

Author SHA1 Message Date
Alan Agius
4ed8781301
refactor(core): improve resource loading with async/await
Refactor  to use async/await for clearer asynchronous operations and enhanced error handling.
Simplify resource caching and streamline the resolution of component templates and styles.
Update  in the router to align with the new async resource resolution.
2025-11-11 12:50:16 -08:00
Leon Senft
d337cfb68f feat(forms): add debounce() rule for signal forms
The `debounce()` rule allows developers to control when changes to a
form control are synchronized to the form model.

This feature necessitated some changes to `FieldState`:

  * `controlValue` is a new signal property that represents the current
    value of a form field as it appears in its corresponding control.

  * `value` conceptually remains unchanged; however, its value may lag
    behind that of `controlValue` if a `debounce()` rule is applied.

The `debounce()` rule essentially manages when changes to `controlValue` are
synchronized to `value`. The intent is that an expensive or slow
validation rule can react to the debounced `value`, rather than a more
frequently changing `controlValue`.

Directly updating `value` immediately updates `controlValue`, and cancels any
pending debounced updates.

When multiple `debounce()` rules are applied to the same field, the last
currently active rule is used to debounce an update. These rules are
applied to child fields as well, unless they override them with their
own rule.
2025-11-11 12:00:09 -08:00
Doug Parker
490435bf76 fix(core): skip Angular formatting when formatting signals recursively
The flag `skipFormatting` got renamed to `ngSkipFormatting` during review of https://github.com/angular/angular/pull/64000, but a couple usages got missed, causing some unfortunate UI recursion.
2025-11-11 10:14:30 -08:00
Kristiyan Kostadinov
8277906455 refactor(compiler): remove unused code
The `fullInheritane` flag from the metadata and the `CopyDefinitionFeature` that it controls appear to no longer be used since `fullInheritance` is always false. The feature appears to have been there to support ngcc which was removed some time ago.
2025-11-11 10:04:29 -08:00
Matthieu Riegler
21ca49cf62 refactor(core): rename ExperimentalIsolatedShadowDom to IsolatedShadowDom
This API is still experimental
2025-11-11 08:46:06 -08:00
Matthieu Riegler
16e61f5dd0 docs(docs-infra): Add support for experimental enum entries 2025-11-11 08:46:06 -08:00
arturovt
7f95f02d05 refactor(core): tree-shake REF_EXTRACTOR_REGEXP (and dependencies)
`new RegExp()` with computed strings can't be analyzed statically. The bundler can't prove the template string evaluation has no side effects; as thus this expression is considered a side-effect.
2025-11-10 07:48:39 -08:00
Leon Senft
44cd18c183 refactor(forms): remove a TODO and simplify update on <select> mutations
Remove an unnecessary TODO comment. The native `<select>` tracks its
`value` by keeping track of the selected `<option>`. Thus if the value
was set *before* the corresponding option is created, the `<select>`
will ignore it, but the framework doesn't know that and will cache the
bound value anyways. Therefore, checking if the value changed since it
was last bound when the mutation that creates the selected `<option>`
occurs would in fact prevent a needed update, leaving the `<select>` and
field values out of sync.

Furthermore, we know the control type is a native `<select>` element, so
we can update its value directly instead of going through
`updateNativeControl()` which would perform a redundant input type
check.
2025-11-10 07:47:58 -08:00
Andrew Scott
1651908004
refactor(router): Add handler to NavigationInterceptOptions
This adds a handler to the `NavigationInterceptOptions` when we are
intercepting a `NavigateEvent`. This means that the scroll and focus
restoration will be delayed until the handler promise resolves. It also
means that we can provide better indication of an ongoing navigation
event.
2025-11-07 13:32:49 -08:00
Andrew Scott
8bccd8671c refactor(core): Extract NavigateEvent cancel steps based on recent spec update
This updates the cancel/abort steps of fake navigation to match the
current spec.

Relevant commit seems to be
* b0b40cca16
2025-11-07 12:54:14 -08:00
Andrew Scott
7a5ac69144 refactor(core): Update commit steps of PlatformNavigation fake to match spec updates
Brings commit steps in line with recent spec updates

* a3809244c0
* bd347bdfeb
2025-11-07 12:54:14 -08:00
Leon Senft
850f0d6b3d perf(forms): only update interop controls when bound field changes
https://github.com/angular/angular/pull/64590 implemented change
detection for field bindings, but only for those bound to native or
custom form controls. This change extends that optimization to apply to
field bindings on interoperable controls built using Reactive Forms as well.
2025-11-07 11:58:17 -08:00
Jessica Janiuk
e703433b4b Revert "feat(core): resource composition via snapshots"
This reverts commit 2a6fdda601.
2025-11-07 07:42:18 -08:00
Alex Rickabaugh
2a6fdda601 feat(core): resource composition via snapshots
* Define `ResourceSnapshot<T>` as a type union of possible states for a
`Resource<T>`.
* Add `Resource.snapshot()` to convert a `Resource` to a signal of its
  snapshot.
* Add `resourceFromSnapshots` to convert a reactive snapshot back into a
  `Resource`.

By converting resources from/to `Signal<ResourceSnapshot>`s, full
composition of resources is now possible on top of signal composition APIs
like `computed` and `linkedSignal`.

For example, a common feature request is to have a `Resource` which retains
its value when its reactive source (params) changes. This can now be built
as a utility, leveraging `linkedSignal`'s previous value capability:

```ts
function withPreviousValue<T>(input: Resource<T>): Resource<T> {
  const derived = linkedSignal({
    source: input.snapshot,
    computation: (snap, previous) => {
      if (snap.status === 'loading' && previous?.value) {
        // When the input resource enters loading state, we keep the value
        // from its previous state, if any.
        return {status: 'loading', value: previous.value.value};
      }

      // Otherwise we simply forward the state of the input resource.
      return snap;
    },
  });

  return resourceFromSnapshots(derived);
}

// In application code:

userId = input.required<number>();
user = withPreviousValue(httpResource(() => `/user/{this.userId()}`));
// if `userId()` switches, `user.value()` will keep the old value until
// the new one is ready!
```
2025-11-06 14:59:39 -08:00
tsc036
cf47ce2db9
refactor(core): move profile_types.ts to primtives
move profile_types.ts so the types can be used in Wiz code
2025-11-06 14:22:33 -08:00
SkyZeroZx
5343001835 refactor(platform-browser): remove unused Platform ID dependency from DomRendererFactory2
Eliminates the unnecessary injection and usage of Platform ID in the renderer factory logic, along with related test scaffolding cleanup
2025-11-06 12:00:46 -08:00
arturovt
9f76fb61df refactor(forms): tree-shake ngControlStatusHost and ngGroupStatusHost
This commit removes `ngGroupStatusHost` variable because it's a side-effect, ending up preserving `ngControlStatusHost` and `ngGroupStatusHost`.
2025-11-06 10:57:45 -08:00
Alan Agius
26fed34e0e
build: format md files
This commit configures prettier to format markdown files.
2025-11-06 10:03:05 -08:00
SkyZeroZx
ca3ef38143 refactor(common): Removes unused imports to clean up dependencies
Eliminates unnecessary imports to reduce clutter and improve maintainability
2025-11-06 08:35:28 -08:00
tsc036
104f7d57c1
refactor(core): export types from primitives
export Version type and a type for linkedSignal previous value so they can be used for the Wiz implementations
2025-11-06 08:34:54 -08:00
Miles Malerba
194b41199b refactor(forms): improved select support
When we set the `value` on a `<select>` element we're really just
setting the selected `<option>`. It treats the selected option as the
source of truth, rather than the actual value. This means that if
options are added or removed or their value changes, the `<select>` may
wind up with a different `value` than what's in our model.

This PR resolves this issue by adding a `MutationObserver` to the select
that is used to resync its value to the model whenever the options may
have changed.
2025-11-06 07:49:06 -08:00
Angular Robot
8315504d60 build: update cross-repo angular dependencies
See associated pull request for more information.
2025-11-06 07:47:07 -08:00
Kristiyan Kostadinov
4b68bddd62 refactor(core): add utility type for extracting the value of a custom control
Adds the `ɵExtractFormControlValue` type that we can use during template type checking to extract the type of a custom control.
2025-11-05 17:35:43 +00:00
Jessica Janiuk
373d263834 fix(core): skip leave animations on view swaps
We accounted for skipping leave animations during moves, but not swaps.
This accounts for the swap cases and updates how we deal with swaps and
moves. Now we always queue animations and then essentially dequeue them
if we attach them back in the same render pass.

fixes: #64818
fixes: #64730
2025-11-05 17:04:11 +00:00
Leon Senft
41be02da2f perf(forms): implement change detection for field control bindings
For each field state property, check if it has changed since the last
time it was checked before writing it the corresponding form control
property.

The `pattern` and `required` properties of the field state now return a
default value rather than `undefined` if not defined by metadata.
2025-11-05 00:11:22 +00:00
Lukas Matta
5b210e97af fix(migrations): Prevent removal of templates referenced with preceding whitespace characters
In https://github.com/angular/angular/pull/64745, a fix was introduced for templates referenced with a trailing semicolon. However, templates are still incorrectly removed when there are whitespace characters before the template name.

This commit updates the control flow migration logic to ensure templates referenced with preceding whitespace are not removed.

Fixes #64854
2025-11-04 23:25:59 +00:00
SkyZeroZx
2ad1b5979f refactor(core): Removes unused flag for onDestroy
Eliminates an unnecessary configuration flag
2025-11-04 04:20:54 +00:00
SkyZeroZx
64efbc53aa refactor(core): remove redundant providedIn: 'root' from injection tokens
Removes unnecessary `providedIn: 'root'` declarations from injection tokens
2025-11-04 00:31:52 +00:00
Matthieu Riegler
79b7ac722a refactor(core): Replace usages of the Function type for animations
`Function` is usually not recommended as its not specific enough.
2025-11-03 20:04:55 +00:00
Angular Robot
5c5353d1e5 build: update cross-repo angular dependencies (#64795)
See associated pull request for more information.

PR Close #64795
2025-10-30 19:22:04 +00:00
Andrew Scott
c84d372778 feat(router): Support wildcard params with segments trailing (#64737)
this adds support for both leading and trailing segments before/after wildcard
route. Exposig the segments in a new _splat param would require a
breaking change to the return value of the matchers.

fixes https://github.com/angular/angular/issues/60821

PR Close #64737
2025-10-30 15:44:16 +00:00
Angular Robot
b0c9c63784 build: update cross-repo angular dependencies
See associated pull request for more information.
2025-10-29 21:02:34 +00:00
Andrew Scott
fb569ef614 refactor(core): Move patch toggles inside functions to allow tree shaking
In general, global level const will cause DCE bailouts.
2025-10-29 20:57:47 +00:00
Matthieu Riegler
76adbbcd0a refactor(core): expose isWritableSignal to the publicApi
This is alongside the already exisiting isSignal()

fixes #64763
2025-10-29 20:31:41 +00:00
Lukas Matta
64cb08529d fix(migrations): Do not remove a template if it is referenced even with a trailing semilocon
This commit fixes a behavior where under certain conditions, the migration script ignored
a template reference with a trailing semicolon and incorrectly removed the definition
of a referenced template.

Fixes #64741
2025-10-29 10:50:56 +01:00
Alan Agius
b4e798ed87 refactor(migrations): exclude all @angular/* packages from schematics bundle
This change updates the rollup configuration for the core schematics to exclude all `@angular/*` packages from the bundle. This is possible following https://github.com/angular/angular/pull/64703

This significantly reduces the size of the `@angular/core` schematics bundle, resulting in a size reduction to 5.8mb.
2025-10-28 20:51:50 +01:00
Andrew Scott
5a93eeb6c0 Revert "feat(router): Support wildcard params with segments trailing"
This reverts commit 0a0cc27aea.
Causes internal failures with route matching. Should investigate and add
tests to prevent future regressions.
2025-10-28 18:35:27 +01:00
Matthieu Riegler
8e50cdb930 refactor(compiler-cli): Remove deep imports of compiler-cli in angular/core
migration schematics will pull from `compiler-cli/private/migrations`
core tests will pull from `compiler-cli/private/testing`
2025-10-28 15:58:56 +01:00
Andrew Scott
a253739ac8
refactor(core): Remove zone toggles for test and standalone
The migration is complete internally. All that remains is bootstrapModule
2025-10-28 15:57:58 +01:00
arielbackenroth
07b8e953f4 refactor(http): add hooks for propagating traces across XHR callbacks.
Enables propagating a trace across XHR callbacks by providing a hook for
wrapping the callback with a function bound to the send trace context.
2025-10-28 15:08:57 +01:00
tjshiu
763db3a70b docs: align adev best practices with llm-eval 2025-10-28 15:08:12 +01:00
Andrew Scott
0a0cc27aea feat(router): Support wildcard params with segments trailing
this adds support for both leading and trailing segments before/after wildcard
route. Exposig the segments in a new _splat param would require a
breaking change to the return value of the matchers.

fixes https://github.com/angular/angular/issues/60821
2025-10-28 10:23:58 +01:00
Matt Lewis
59e648913c fix(core): Clear lView from IcuIteratorState when stack is empty to prevent memory leak
If a component template contains an icu expression it is being retained until the next change detection cycle for that template. This results in a net retention of only ever a single copy of the given lView but that creates an opportunity for compounding leaks.

Change the icu i18n_icu_container_visitor to free the IcuIteratorState retained lView when the stack is empty so that garbage collection can occur when the view is discarded.
2025-10-27 19:42:18 +01:00
Matthieu Riegler
eec6669733 refactor(migrations): use the applicationProviders for the zoneless migration
PR #64354 introduced the `applicationProviders` for `bootstrapModule`, this allows a simpler migration output.
2025-10-27 19:41:29 +01:00
Alan Agius
9d00c6892f build: reduce package size of @angular/core
The schematics bundle size is reduced by externalizing @angular/compiler. This reduces the package size from 11mb to 9.1mb.
2025-10-27 17:12:48 +01:00
Alan Agius
25e8bcbdf6 build: refactor location of best-practices.md
This commit moves the best-practices.md file from adev/src/context to packages/core/resources. The BUILD.bazel files and other configuration files have been updated to reflect this change.
2025-10-27 09:31:36 +01:00
Alan Agius
620e2c4926 Revert "build: refactor location of best-practices.md"
This reverts commit 07a51872d5.
2025-10-24 19:02:37 +02:00
Alan Agius
07a51872d5
build: refactor location of best-practices.md
This commit moves the best-practices.md file from adev/src/context to packages/core/resources. The BUILD.bazel files and other configuration files have been updated to reflect this change.
2025-10-24 18:45:32 +02:00
Miles Malerba
55e1647e52 fix(core): ensure @for iteration over field is reactive (#64113)
When working with a proxy object such as signal forms' `Field`,
accessing the `lenght` or `Symbol.iterator` may trgger a reactive read.
This change ensures that `@for` properly captrues this before clearing
the active consumer.

PR Close #64113
2025-10-24 09:29:29 +02:00
Angular Robot
13d8ccc41b build: update cross-repo angular dependencies (#64622)
See associated pull request for more information.

PR Close #64622
2025-10-23 18:24:58 +02:00