Commit graph

5341 commits

Author SHA1 Message Date
Vlad Boisa
befa0faaef docs: change the broked link (#60436)
Change the wrong path of the link to a working one.
PR Close #60436
2025-03-18 18:09:31 +01:00
Matt Turco
22d3f0562c feat(core): add hook for producer creation side effects (#60333)
Adds a hook in the same style as `postSignalSetFn` for running side effects when a producer has been created. This hook will be passed the reactive node being created.

PR Close #60333
2025-03-18 15:10:01 +01:00
iteriani
69b688c7d1 refactor(core): Add an additional check for the name field for NotFoundError (#60322)
Inside g3, instanceof checks will fail. Instead, check the name field.

PR Close #60322
2025-03-18 15:05:52 +01:00
Andrew Scott
48974c3cf8 fix(core): remove rejectErrors option encourages uncaught exceptions (#60397)
This commit removes the previously added `rejectErrors` option from
`toSignal` which was meant to create similar behavior to what happens
with unhandled errors in `AsyncPipe`.

This option promotes unhandled exceptions and attaches behaviors that we
do not believe are desirable as an option offered by the framework:

* Unhandled errors that are thrown lose the context of where the error
  ocurred. Throwing the error where the signal is read allows error
  handling to be performed at the signal's usage location
* With this feature, the value of the signal remains set to the initial
  value or the previous successful value coming out of the `Observable`.
  We do not feel this is appropriate implicit behavior but should be an
  explicit choice by the application. Signals are built to represent
  state. When an observable stream is converted to a stateful
  representation, there should be a choice made about what state should
  be presented when an error occurs
* If an error occurs but the signal value is never read in its error
  state, this is not an application state error that should result in an
  unhandled exception.
* While Angular does not have error boundaries today, there is likely to
  be investigation in the near future to address increased risk of
  errors thrown from signals such as this in templates. Without
  pre-designing any specifics, it is possible that this type of feature
  would require the error to be thrown from the signal. We are subsequently
  not prepared to commit to stabilizing the `toSignal` API with the
  `rejectErrors` option and its current behavior.

Developers that desire similar behavior to `rejectErrors` have several
options, the simplest of which would be something similar to
`toSignal(myStream.pipe(catchError(() => EMPTY)))`.

PR Close #60397
2025-03-18 14:10:24 +01:00
Kristiyan Kostadinov
b154fb3911 feat(core): add support for two-way bindings on dynamically-created components (#60342)
Builds on the changes from #60137 to add support for two-way bindings on dynamically-created components. Example usage:

```typescript
import {createComponent, signal, twoWayBinding} from '@angular/core';

const value = signal('');

createComponent(MyCheckbox, {
  bindings: [
    twoWayBinding('value', value),
  ],
});
```

In the example above the value of `MyCheckbox` and the `value` signal will be kept in sync.

PR Close #60342
2025-03-17 14:29:52 +01:00
Matthieu Riegler
bb7e948bde refactor(core): Add recommendation for string tokens on @Inject (#60326)
While still being supported because of ngUpgrade, string tokens are not recommended. Developers should use InjectionTokens or classes as tokens instead.

PR Close #60326
2025-03-17 12:18:23 +01:00
Kristiyan Kostadinov
04d963c0a5 fix(core): remove unused parameter from listener instruction (#60406)
Removes the `useCapture` parameter from the `listener` instruction, because it's not used.

PR Close #60406
2025-03-17 12:16:03 +01:00
Kristiyan Kostadinov
8953e45a43 fix(core): include input name in error message (#60404)
Includes either the `debugName` or alias of an input in the error message about a value not being available.

Fixes #60199.

PR Close #60404
2025-03-17 12:15:02 +01:00
Jessica Janiuk
b8daf472d8 fix(core): execute timer trigger outside zone (#60392)
This should prevent defer timers from impacting app stability by executing them outside of the zone, similar to other defer triggers.

fixes: #60373

PR Close #60392
2025-03-14 17:01:02 +01:00
Kristiyan Kostadinov
c147a0d6de refactor(migrations): simplify integration of tsurge migrations into the CLI (#60386)
Currently when we reuse a Tsurge migration is reused externally, there's some glue code that needs to be executed in a specific order. The code gets copied between the different migrations which is error-prone and means that bugs may have to be fixed several times.

These changes move the common steps out into a separate function so that only the migration-specific logic (mostly instantiation and logging) is left in the schematic.

PR Close #60386
2025-03-14 14:44:26 +01:00
Rahat Ahmed
28459060a2 refactor(core): Support and document manually provided internal injections (#60347)
For internal framework values stored in injectors, they are manually
managed and inserted into injectors as needed. Therefore their tokens
don't provide a value or factory. This updates the type to reflect that
and updates the jsdocs a bit.

PR Close #60347
2025-03-14 13:40:40 +01:00
Pawel Kozlowski
adecf4c772 refactor(core): pass signal equal function to primitives (#60364)
The signals primitives package understands the equals option now
so we can pass it to the signal / computed creation methods instead
of manually assigning the equality function on a reactive node.

PR Close #60364
2025-03-13 17:24:17 +01:00
Pawel Kozlowski
72ef9ed4a3 refactor(core): prepare integration with Chrome DevTools (#60217)
This commit puts in place infrastructure capable of routing
performance-related, internal framework events directly to
the Chrome DevTools performance panel (custom track).

PR Close #60217
2025-03-12 12:26:27 -07:00
Pawel Kozlowski
817021b359 refactor(core): add equal option to the signal and computed creation (#60300)
This change moves more logic to the primitives package by pushing
the equal configuration on a reactive node to the signal and
computed creation utilities.

PR Close #60300
2025-03-12 10:38:27 -07:00
Taygan Caldwell
bc95edf240 refactor: cleanup untracked in core (#60150)
Re-export untracked in core from primitives

PR Close #60150
2025-03-12 10:37:51 -07:00
Andrew Kushnir
9657c7d699 test(core): reduce test flakiness by increasing time delta (#60338)
This commit updates an expected delta range for a duration of a view transition to reduce flakiness of that test.

PR Close #60338
2025-03-12 10:36:36 -07:00
arturovt
526268c262 refactor(core): inline standalone check to be dropped (#60305)
Inlines `standalone` check into the message to be dropped.

PR Close #60305
2025-03-11 13:01:43 -07:00
AlirezaEbrahimkhani
dcc1a61dfa docs: change xss doc url to angular new documentation (#59915)
PR Close #59915
2025-03-11 12:57:48 -07:00
Kristiyan Kostadinov
8be6e3888b refactor(core): replace internal usages of InjectFlags (#60318)
Replaces all the places where we use `InjectFlags` internally with the `InternalInjectFlags` which has the benefit of being a `const` enum and allowing us to consolidate the flags and object literal eventually.

PR Close #60318
2025-03-11 11:33:09 -07:00
Kristiyan Kostadinov
611baaf069 feat(core): remove InjectFlags from public API (#60318)
Removes the deprecated `InjectFlags` symbol from the `@angular/core` public API, as well as all the places that accept it. The previous commit includes an automated migration to switch over to the new way of passing in flags.

BREAKING CHANGE:
* `InjectFlags` has been removed.
* `inject` no longer accepts `InjectFlags`.
* `Injector.get` no longer accepts `InjectFlags`.
* `EnvironmentInjector.get` no longer accepts `InjectFlags`.
* `TestBed.get` no longer accepts `InjectFlags`.
* `TestBed.inject` no longer accepts `InjectFlags`.

PR Close #60318
2025-03-11 11:33:09 -07:00
Kristiyan Kostadinov
e170d24240 fix(core): add migration away from InjectFlags (#60318)
Adds an automated migration that will switch users from the deprecated `InjectFlags` API to its non-deprecated equivalent.

PR Close #60318
2025-03-11 11:33:09 -07:00
aparzi
de2bfc0913 fix(core): fix removal of a container reference used in the component file (#60210)
During migration a container reference was deleted even though it was used in the component file.

PR Close #60210
2025-03-11 09:26:13 -07:00
Matthieu Riegler
c73520bb74 refactor(compiler): remove empty empty string suffix from interpolation instructions (#60066)
With this change, interpolations that don't have a suffix will miss the last argument which was previously an empty string.

PR Close #60066
2025-03-10 16:31:34 -07:00
Matthieu Riegler
e3afa24089 refactor(core): log a warning instead of throwing error on OutputRef.emit when the directive is destroyed. (#60293)
This should not be a hard error, as nothing bad happens but the users should be warned that no event will be emitted.

fixes #60110

PR Close #60293
2025-03-10 16:08:52 -07:00
arturovt
f2a8006591 refactor(core): replace PLATFORM_ID in initTransferState (#60299)
Replaces `PLATFORM_ID` check with the `ngServerMode`.

PR Close #60299
2025-03-10 13:49:23 -07:00
Andrew Scott
ff772d7800 fix(core): fix typing on injector.get to omit 'any' (#60202)
This commit further restricts the deprecated type on injector.get to exclude
all but `string`. Progresses towards #48408

BREAKING CHANGE: The `any` overload has been removed from
`injector.get`. It now only supports `ProviderToken<T>` and (deprecated
since v4) `string`.

PR Close #60202
2025-03-10 13:48:18 -07:00
iteriani
e13f11db69 refactor(core): Create a function convertToInjectOptions and convert back to an options. This allows seamless back and forth from bitflags and options. (#60192)
Note that we do have to keep converting back and forth, but we'll see if that's a problem.

PR Close #60192
2025-03-10 11:38:13 -07:00
iteriani
92bb8d974b refactor(core): Use the retrieve method in the implementation of injectInjectorOnly (#60192)
This should keep the existing behavior intact. Right now retrieve never returns back NOT_FOUND. This should not be the case, but tests fail if I do add this behavior so itll have to be later.

PR Close #60192
2025-03-10 11:38:13 -07:00
Kristiyan Kostadinov
0e40a1c93f build: remove migrations for v19 (#60304)
Removes the migrations for v19 since they aren't relevant anymore.

PR Close #60304
2025-03-10 09:20:52 -07:00
Andrew Scott
338818ce89 fix(core): Surface errors from ApplicationRef.tick to callsite (#60102)
This commit ensures that errors during `ApplicationRef.tick` are
surfaced to the callsite rather than being caught and reported to the
`ErrorHandler`.

The current catch and report approach was originally
added in e263e19a2a
with the goal of preventing automatic change detection crashes due to
the error happening in the subscription. However, this results in hiding
a public API that can hide errors. Callers cannot assume that the tick
was successful and perform follow-up work.

This change now surfaces errors and adds the error handling directly to
the callsites.

BREAKING CHANGE: `ApplicationRef.tick` will no longer catch and report
errors to the appplication `ErrorHandler`. Errors will instead be thrown out of
the method and will allow callers to determine how to handle these
errors, such as aborting follow-up work or reporting the error and
continuing.

PR Close #60102
2025-03-10 08:17:14 -07:00
Alan Agius
9080fdf6f8 test: narrow down signal-input typescript tests (#60266)
Remove TS versions that are no longer supported.

PR Close #60266
2025-03-07 11:00:03 -08:00
Alan Agius
45f899a272 refactor: replace fast-glob usage with tinyglobby (#60264)
Usage of the `fast-glob` package has been replaced with the `tinyglobby` package. The change reduces the number of transitive dependencies related to these packages from 17 to 2 while also maintaining equivalent functionality. This was also changed in the Angular CLI packages.

PR Close #60264
2025-03-07 10:57:23 -08:00
Vlad Boisa
cc0bd25f3e docs: fix typo in desription (#60261)
Fix typos in description of `styleUrl`

Fixes #60258
PR Close #60261
2025-03-07 10:55:37 -08:00
Andrew Scott
02cb7e061a refactor(core): remove microtask effect (#60234)
This has been removed internally and was never exposed externally (it was a breaking change)

PR Close #60234
2025-03-06 12:48:55 -08:00
Jessica Janiuk
c82384104f fix(core): ensures immediate trigger fires properly with lazy loaded routes (#60203)
In the case that a route was lazy loaded, some triggers would never properly finish hydrating due to things firing before the route finished resolving.
This will find the topmost parent defer block and ensure the registry knows about it before trying to hydrate.
In the case that the registry does not yet know, just the affected triggers await app stability before initializing.
fixes #59997

PR Close #60203
2025-03-06 12:47:46 -08:00
Pawel Kozlowski
39b324de67 refactor(core): drop render-related perf counters (#60200)
It looks like we are not getting enough value from having
those counters. This is an exploratory PR to see if thsoe
could be removed.

PR Close #60200
2025-03-06 10:33:54 -08:00
Jessica Janiuk
cae1fe519b fix(router): update symbols (#60233)
This updates the goldens for the router.

PR Close #60233
2025-03-05 15:34:05 -08:00
arturovt
5c70a048a9 refactor(core): add token to missing injection context error message (#60009)
In this commit, we add injector token information to the error message to improve debugging and context awareness, because it is hard to capture the `inject()` stack trace in asynchronous contexts.

PR Close #60009
2025-03-05 14:44:43 -08:00
arturovt
79ae35577e fix(core): check whether application is destroyed before initializing event replay (#59789)
In this commit, we check whether the application is destroyed before initializing event replay. The application may be destroyed before it becomes stable, so when the `whenStable` resolves, the injector might already be in a destroyed state. As a result, calling `injector.get` would throw an error indicating that the injector has already been destroyed.

PR Close #59789
2025-03-05 14:43:47 -08:00
iteriani
ac94604ef2 refactor(core): Remove the optional flag from Injector and all casts. (#60154)
Note that this does NOT use the retrieve method yet. I believe we need to move the logic for notFoundValue into the inject implementation.

PR Close #60154
2025-03-05 13:43:59 -08:00
Taygan Caldwell
1d3b9148d3 refactor: add untracked to primitives (#60105)
add untracked to primitives to allow Wiz to use it

PR Close #60105
2025-03-05 12:11:40 -08:00
arturovt
1124b8ff0d refactor(core): inline isFactory within getNodeInjectable (#59824)
This commit inlines the `isFactory` function body directly within `getNodeInjectable` because it is only used once. ESBuild does not inline its body within the function, which can be observed when running the build with `NG_BUILD_MANGLE=0`. The results after inlining are as follows:

```
getNodeInjectable x 70,397,377 ops/sec ±3.88% (52 runs sampled)
getNodeInjectable_inlined x 77,834,432 ops/sec ±3.13% (60 runs sampled)
```

PR Close #59824
2025-03-05 17:24:52 +00:00
arturovt
aa8dff80ba refactor(core): drop getNgModuleDef error message in production (#60082)
Drops `getNgModuleDef` error message in production and replaces it with an error code.

PR Close #60082
2025-03-05 17:11:06 +00:00
Emil Rowland
7eb59d3887 fix(core): added @angular/compiler as a peer dependency (#55610)
This fixes an issue with packages managers likes pmpm
that will not link the @angular/compiler package to the @angular/core
package if it is not listed as a peer dependency.
I added it as optional peer dependency as it's only used in special cases.

Fixes #38096

PR Close #55610
2025-03-04 22:06:59 +00:00
Andrew Scott
fd12220a35 fix(core): defer block render failures should report to application error handler (#60149)
This commit updates error reporting of defer blocks to go to the
application root error handler rather than the `ErrorHandler` token that
may be provided by users. This ensures Angular has control over what
happens when these errors are reported.

PR Close #60149
2025-03-04 22:06:17 +00:00
Matthieu Riegler
e605433f74 refactor(core): extract dirty and markForRefresh from the private ViewRef. (#59122)
This allows better tree shaking from projects without the `element` package.

PR Close #59122
2025-03-04 22:05:40 +00:00
Samuel Perez
6dd8cce155 docs: fix all brokens links on the API pages (#59162)
This PR fix is for the broken links on the API
pages mentioned in issue #57591.

PR Close #59162
2025-03-04 20:07:23 +00:00
Alexis
6f6d9f1e8a docs: Remove misleading default value DEFAULT_CURRENCY_CODE (#59977)
PR Close #59977
2025-03-04 19:37:57 +00:00
Matthieu Riegler
4aeec9fa7d refactor(core): throw an Cyclic Dependency Error in prod mode (#60118)
Prior to this change, cyclic injection didn't trigger any error in prod mode, resulting into injecting the `CIRCULAR` object.
This could lead to strange errors where no method would be found on the token.

fixes #60074

PR Close #60118
2025-03-04 19:37:19 +00:00
naaajii
b4feeb5a7d docs: update license year (#59883)
updates the year in footer and placeholder for generated files

PR Close #59883
2025-03-04 19:36:47 +00:00