Commit graph

1494 commits

Author SHA1 Message Date
Andrew Scott
4af408afcb Revert "feat(service-worker): notify clients about version failures (#62718)"
This reverts commit 6d011687ec.

issue #63500 reproduces at head on the main branch in the dev app.
Reverting this change along resolves it.

fixes https://github.com/angular/angular/issues/63500
2025-11-11 12:48:45 -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
Leon Senft
8866934334 refactor(forms): do not infer accumulated metadata type from initial value
This removes the need to specify type arguments for
`reducedMetadataKey()` when the value returned from the `getIntial`
callback is a subtype of the accumulated type.
2025-11-11 12:00:09 -08:00
Matthieu Riegler
21ca49cf62 refactor(core): rename ExperimentalIsolatedShadowDom to IsolatedShadowDom
This API is still experimental
2025-11-11 08:46:06 -08:00
Doug Parker
ec9dc94cee feat(platform-browser): add context to createApplication
This is necessary to use SSR safely with `createApplication` and avoid constraining users to `bootstrapApplication`. It is one more step towards feature parity between `createApplication` and `bootstrapApplication`.
2025-11-10 14:18:29 -08:00
arturovt
7724a9460d refactor(router): replace Optional with inject() flags
Replace `@Optional() link: RouterLink` constructor parameter with
`link = inject(RouterLink, {optional: true})` to enable tree-shaking
of the `Optional` decorator and its factory scaffolding.

Bundle size reduction: `Optional` is a runtime value created by
`makeParamDecorator()`. Even in production builds, ESBuild and other
bundlers must keep their factory code because it is referenced via
`Optional`. With `inject()`, this class is no longer referenced,
allowing it and the `makeParamDecorator` scaffolding to be tree-shaken
when unused elsewhere.

Note: This updates the constructor signature but should not be
considered a breaking change. Angular's official guidance is that
directives, components, and pipes should be instantiated by the
framework, not by user code. Directly calling `new RouterLinkActive(...)`
is an unsupported pattern that goes against Angular's design principles.
2025-11-10 09:48:32 -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
Alan Agius
0f55443d9b refactor: exclude tsconfig.json from VSIX package contents (#64991)
The  file is no longer included in the VSCode extension package.
This change updates the golden file and the  file to reflect this exclusion.

PR Close #64991
2025-11-07 11:36:31 -08:00
Alan Agius
74a38f00a0 test: add golden file test for VSCode extension package contents (#64991)
This commit introduces a golden file test to verify the contents of the VSCode extension package.
The test ensures that the list of files included in the extension package remains consistent.

A new Bazel rule  is added to generate the list of files, and  is used to compare it against the golden file. A helper script  is also added to facilitate the generation of the golden file.

PR Close #64991
2025-11-07 11:36:31 -08:00
Miles Malerba
0efb3f6d1f refactor(forms): nicer type errors
By intersecting with `object` instead of `unknown` in the primitive and
`FormControl` cases, we get TypeScript to show nicer type errors that
mention `FieldTree<...>` insetad of `() => FieldState<...>`
2025-11-07 07:45:05 -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
Miles Malerba
faccf03ee0
refactor(forms): allow FieldTree of recursive type
Adjusts our typings to work better with recursive types and avoid
infinite recursion in the type system.
2025-11-06 13:43:43 -08:00
Miles Malerba
2fd8dc9195
refactor(forms): expose pathKeys as part of the API
Currently we maintain the pathKeys internally, but do not expose them
through the `FieldContext`, this PR updates the `FieldContext` to expose
this property.
2025-11-06 13:43:13 -08:00
Miles Malerba
c9058087ae
refactor(forms): support dynamic object logic
extends `applyEach` to work on objects as well, conditionally applying
logic to each property of the object.
2025-11-06 13:42:48 -08:00
kirjs
60447945bc refactor(forms): add compatForm
This allows using reactive form controls in signal forms
2025-11-06 10:51:28 -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
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
e87f423d90 refactor(forms): add better support for Object.keys and Symbol.iterator
Improves support for using `Object.keys` (and related methods) and
`Symbol.iterator` to work with a `FieldTree` of unknown shape.
2025-11-06 07:51:28 -08:00
Miles Malerba
96388b6d8a refactor(forms): improve discoverability of ValidationError flavors (#64747)
Improves discoverability by putting the WithField, WithoutField, etc as
subtypes of the main ValidationError type

PR Close #64747
2025-11-05 22:42:59 +00:00
Kristiyan Kostadinov
f20103a1d7 fix(compiler-cli): report invalid bindings on form controls
Adds validation that users don't bind to unsupported properties on nodes with the `Field` directive.
2025-11-05 17:35:43 +00:00
SkyZeroZx
44435ea97b refactor(http): simplifies destruction tracking using destroyed property
Replaces the manual destroyed state with destroyed property
2025-11-05 17:05:24 +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
Miles Malerba
662f0e5c00
feat(docs-infra): add support for namespaces
Adds support for generating docs for namespaces (and merged declarations
of namespace + type)
2025-10-29 20:22:21 +00:00
kirjs
c57bbaa87d refactor(forms): Allow returning plain values from validators
This makes the API nicer to use
2025-10-28 20:50:45 +01:00
kirjs
b5c29d0d0a refactor(forms): Allow returning plain values from validators
This makes the API nicer to use
2025-10-28 20:50:45 +01:00
csorrentino
a5678f6f2b refactor(forms): add onError callback to validateHttp for HTTP errors
Adds onError callback inside validateHttp validator in signal forms

PR-Close: #63949
2025-10-27 17:12:25 +01:00
Andrew Scott
a03c82564d feat(router): Add scroll behavior controls on router navigation
This commit adds the ability to control the behavior of scrolling in the
`NavigationBehaviorOptions`. The options directly correlate with the
intercept options of the Navigation API `NavigateEvent#intercept`:
https://developer.mozilla.org/en-US/docs/Web/API/NavigateEvent/intercept#scroll

While we do not currently have an integration with the navigation API,
this change would be necessary to provide the ability to configure that behavior
if/when we do. In the meantime, this option is also useful to control
the behavior of scrolling when the in memory scroller is enabled.

resolves #26744
2025-10-27 09:24:26 +01:00
Miles Malerba
ef34e39b2a refactor(forms): rename files related to metadata (#64603)
Renames some files to reflect the property => metadata name change

PR Close #64603
2025-10-23 18:13:16 +02:00
Jessica Janiuk
e039c6be02 refactor(compiler): Throw an error when old and new animations are used together (#64569)
This adds a new compilation error if someone attempts to put legacy animations and `animate.enter` or `animate.leave` in the same component.

PR Close #64569
2025-10-22 17:14:47 +00:00
Kristiyan Kostadinov
9d48e534e2 Revert "feat(router): allow router outlet to be set on ng-container (#64562)" (#64584)
This reverts commit 2bd764a3c4.

PR Close #64584
2025-10-22 16:35:38 +00:00
Kristiyan Kostadinov
2bd764a3c4 feat(router): allow router outlet to be set on ng-container (#64562)
Updates the selector for `RouterOutlet` to allow for it to be set on an `ng-container`. This allows it to not render the host node which can affect the layout.

Fixes #64553.

PR Close #64562
2025-10-21 16:49:06 +00:00
Kristiyan Kostadinov
196fa500a3 fix(common): properly type ngComponentOutlet (#64561)
Resolves an older TODO about properly typing the `ngComponentOutlet` input.

PR Close #64561
2025-10-21 15:25:13 +00:00
cexbrayat
bc9c814ca7 refactor(forms): remove Mutable from signal forms public API (#64436)
The `Mutable` type is only used internally in the `addDefaultField` function, so it can be avoided to be publicly exposed.

PR Close #64436
2025-10-20 21:20:11 +00:00
hawkgs
daaad1e6b0 refactor(core): narrow down ReactiveNode.kind type (#64127)
Use a string union type instead of a generic string.

PR Close #64127
2025-10-20 20:15:46 +00:00
Andrew Scott
f6a73f1913 fix(router): Respect custom UrlSerializer handling of query parameters (#64449)
Previously, query parameters passed to `router.createUrlTree` were simply converted to strings. This meant that any custom serialization logic in a custom `UrlSerializer` was not applied. This could lead to inconsistencies between navigations triggered from the URL bar (which are parsed by the serializer) and navigations triggered programmatically.

This change ensures that query parameters are normalized using the provided `UrlSerializer`. The values are serialized and then parsed to ensure they are in the same format as if they had come from a URL. This allows custom serializers to handle complex objects in query parameters consistently.

Fixes https://github.com/angular/angular/issues/47307

PR Close #64449
2025-10-20 18:42:56 +00:00
Andrew Scott
7fb7511124 fix(router): Surface parse errors in Router.parseUrl (#64503)
logs error in addition to fallback parse

fixes #54937

PR Close #64503
2025-10-20 17:51:29 +00:00
Kristiyan Kostadinov
c2d376b85a feat(core): make SimpleChanges generic (#64535)
Currently it's easy to make a mistake when accessing properties on `SimpleChanges`, because the keys aren't typed. These changes add an optional generic to the interface so that users can get a compilation error if they make a typo.

A few things to note:
1. The generic argument is optional and we revert to the old behavior if one isn't passed for backwards compatibility.
2. All of the keys are optional, because they aren't guaranteed to be present for any `ngOnChanges` invocation.
3. We unwrap the values of input signals to match the behavior at runtime.

Fixes #17560.

PR Close #64535
2025-10-20 17:49:39 +00:00
Leon Senft
a0f3960270 refactor(forms): prefix framework-private methods on Field with ɵ (#64471)
These methods are only intended to be used internally within framework
instructions. Prefix them with `ɵ` to indicate that they are
framework-private and should not be called from user code.

PR Close #64471
2025-10-20 15:35:42 +00:00
Leon Senft
94b0afec00 fix(forms): implement interoperability between signal forms and reactive forms (#64471)
Add support for interoperability between signal forms and reactive forms that
commit effccffde0 had removed.

A signal forms field can once again be bound to any element or component with a
`ControlValueAccessor`.

PR Close #64471
2025-10-20 15:35:42 +00:00
Jessica Janiuk
c60ab336c9 Revert "fix(router): Respect custom UrlSerializer handling of query parameters (#64449)" (#64511)
This reverts commit 46ae034c70.

PR Close #64511
2025-10-18 00:19:40 +00:00
Andrew Scott
46ae034c70 fix(router): Respect custom UrlSerializer handling of query parameters (#64449)
Previously, query parameters passed to `router.createUrlTree` were simply converted to strings. This meant that any custom serialization logic in a custom `UrlSerializer` was not applied. This could lead to inconsistencies between navigations triggered from the URL bar (which are parsed by the serializer) and navigations triggered programmatically.

This change ensures that query parameters are normalized using the provided `UrlSerializer`. The values are serialized and then parsed to ensure they are in the same format as if they had come from a URL. This allows custom serializers to handle complex objects in query parameters consistently.

Fixes https://github.com/angular/angular/issues/47307

PR Close #64449
2025-10-17 17:30:46 +00:00
Joey Perrott
13e18cafff build: migrate vscode extension into repo (#63924) (#64049)
Migrate the vscode extension for angular into this repository.

PR Close #63924

PR Close #64049
2025-10-15 10:37:02 -07:00
Andrew Kushnir
fc65107506 Revert "refactor(core): add debug name to resource (#64172)" (#64418)
This reverts commit 63180067aa.

PR Close #64418
2025-10-14 14:28:16 -07:00
hawkgs
63180067aa refactor(core): add debug name to resource (#64172)
Decorate `resource` (and `httpResource`) with `debugName`, along with all of its internal signals.

PR Close #64172
2025-10-14 09:31:41 -07:00
Andrew Scott
2a7a5de53f feat(core): Allow passing application providers in bootstrapModule options (#64354)
This commit adds `applicationProviders` to the `bootstrapModule` options
object. This allows specifying additional providers at the location of
bootstrap, which makes default providers much easier to accomplish.

Using this, we can refine the approach taken for downgrade_module to use
this more direct API rather than the additional provider variable dance.

PR Close #64354
2025-10-13 15:10:10 -07:00
Leon Senft
32f86d35f7 perf(forms): optimize [field] binding instructions (#64351)
Caches information about the kind of form control that a `TNode`
represents in `TNodeFlags`. This avoids redundant computations on
subsequent template create and update passes.

Renames the `INVALID_CONTROL_HOST` error code to
`INVALID_FIELD_DIRECTIVE_HOST` for clarity and adds a test for it.

PR Close #64351
2025-10-13 13:02:17 -07:00
SkyZeroZx
563dbd998c feat(compiler-cli): Adds diagnostic for misconfigured @defer triggers (#64069)
Warns when @defer blocks define unreachable or redundant triggers, such as multiple main triggers, ineffective prefetches, or timer delays not scheduled before rendering.

PR Close #64069
2025-10-13 11:06:01 -07:00
SkyZeroZx
2739b7975b feat(http): add referrerPolicy option to HttpResource (#64283)
Adds support for the `referrerPolicy` option in `HttpResource`, allowing developers to control how much referrer information is sent with each HTTP request.

PR Close #64283
2025-10-13 10:00:27 -07:00
Miles Malerba
2fdd4da2a8 refactor(forms): rename the control directive to the field directive (#64300)
Renames the control directive and the input that users set to bind a
field to a UI control.

Previously users would do:

```
<input [control]="someField">
```

Now users will do:

```
<input [filed]="someField">
```

PR Close #64300
2025-10-13 08:59:13 -07:00