Commit graph

29561 commits

Author SHA1 Message Date
Leonardo Ortiz
658ae699d8 docs: update content readme link (#53763)
PR Close #53763
2024-03-07 11:07:09 -08:00
Leonardo Ortiz
9cf6b9369e docs: readme from blossom (#53763)
PR Close #53763
2024-03-07 11:07:09 -08:00
Angular Robot
9ea0d69275 docs: update events (#54721)
Generated `events.json` with the latest events retrieved from the Firebase DB.

PR Close #54721
2024-03-07 11:05:39 -08:00
Gerald Monaco
f1991d49b0 refactor(core): don't hydrate detached nodes (#54723)
In preparation for hydration support, make sure that we don't attempt to hydrate detached nodes and instead, always newly create them.

PR Close #54723
2024-03-07 11:01:31 -08:00
Gerald Monaco
198f2ff5f2 refactor(core): add i18n AST to prepare for hydration (#54724)
In order to serialize and hydrate i18n blocks, we need to be able to walk an AST for the translated message. This AST is generated during normal parsing of the message.

PR Close #54724
2024-03-07 11:00:38 -08:00
Alan Agius
8d37ed035c fix(http): exclude caching for authenticated HTTP requests (#54746)
This update modifies the transfer cache logic to prevent caching of HTTP requests that require authorization.

Closes: #54745

PR Close #54746
2024-03-07 11:00:03 -08:00
Andrew Scott
365955322f refactor(core): Remove isInternal flag (#54740)
This is not needed any longer since the changes that used it have
landed.

PR Close #54740
2024-03-07 09:07:01 -08:00
Andrew Scott
d870856840 refactor(core): Fix internal test util types (#54736)
This fixes and error that has been seen recently where compilation fails
due to domino.impl type not being recognized

PR Close #54736
2024-03-06 13:34:55 -08:00
Pawel Kozlowski
7bfa3610c5 release: cut the v17.3.0-rc.0 release 2024-03-06 20:40:30 +01:00
Pawel Kozlowski
4be96326a7 docs: release notes for the v17.2.4 release 2024-03-06 20:34:37 +01:00
Matthieu Riegler
7243c704cf fix(core): return a readonly signal on asReadonly. (#54706)
Previous `asReadonly()` returned the signal value and not the signal itself.

Fixes #54704

PR Close #54706
2024-03-06 14:41:12 +01:00
Paul Gschwendtner
e5885fa6d4 build: update ng-dev to avoid node-fetch usages (#54715)
See: https://github.com/angular/dev-infra/pull/1829

PR Close #54715
2024-03-06 12:16:38 +00:00
Paul Gschwendtner
d4154f9e3c refactor(core): revert listener subscription typeof check (#54650)
For model signals we introduced some sniffing on the return type of a
`.subscribe` invocation- allowing for subscribe to _just_ return a
callback directly to unsubscribe.

This works in practice, but the positive `tCleanup` indices have more
meaning, especially in the context of `DebugElement`. A positive index
indicates a DOM event- so we need to revert this change. This now
surfaced as we made `EventEmitter` return a function + the subscription
via a proxy that ended up `typeof function` --> and broke some tests
where debug element incorrectly invoked non-dom outputs as dom
listeners. We don't need this change with current unsubscribe function
concept.

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
2df8584619 refactor(compiler-cli): speed up compiler tests by caching Angular (#54650)
Currently the `makeProgram` utility from `ngtsc/testing` does not use
the test host by default- optimizing for source file caching.

Additionally, the host can be updated to attempt caching of the `.d.ts`
files from `@angular/core`— whether that's fake core, or the real core-
is irrelevant. We are never caching if these changes between tests, so
correctness is guaranteed.

This commit reduces the type check test times form 80s to just 11
seconds, faster than what it was before with `fake_core`. The ngtsc
tests also run significantly faster. From 40s to 30s

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
8a8b682d05 test: integration test for output() api (#54650)
Adds an integration test for `output()` and `outputFromObservable()`.
The test verifies the JIT transform as well.

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
6b1401a370 test: add compiler ngtsc tests for new outputFromObservable API (#54650)
Adds additional ngtsc compiler tests for the `outputFromObservable` API.

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
ea03104aa6 test: fix global augmentation leaking into all source files (#54650)
The `inject` global augmentation from upgrade tests, leak into
all source files for IDEs, making it easy to run into issues
when actually trying to deal with `inject` from Angular core for DI.

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
400b739874 test: add language-service tests for outputFromObservable() (#54650)
Adds additional language-service tests for `outputFromObservable()`.
Existing tests already verify the behavior for `output()`.

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
500a13e77d refactor(core): enforce model() and output() is used in an injection context (#54650)
Technically `model()` and `output()` already need to be defined in an
injection context- because `OutputRef` requires this.

To improve the error messaging, this commit asserts this as part of the
top-level entry functions for `model()` and `output()`. Without this
change, the error would mention the `_createOutputRef` internal
function.

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
db7962adb2 test: add runtime tests for output() function API (#54650)
Adds runtime acceptance tests for `output()` and
`outputFromObservable()`.

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
866271a1c6 refactor(core): EventEmitter implements OutputRef. (#54650)
An `EventEmitter` is a construct owned by Angular that should be
used for outputs as of right now.

As we are introducing the new `OutputRef` interface for the new output
function APIs, we also think `EventEmitter` should implement
`OutputRef`— ensuring all "known" outputs follow the same contract.

This commit ensures `EventEmitter` implements an `OutputRef`

Note: An output ref captures the destroy ref from the current injection
context for clean-up purposes. This is also done for `EventEmitter` in a
backwards compatible way:

- not requiring an injection context. EventEmitter may be used
  elsewhere.
- not cleaning up subscriptions/completing the emitter when the
  directive/component is destroyed. This would be a change in behavior.

Note 2: The dependency on `DestroyRef` causes it to be retained in all
bundling examples because ironically `NgZone` uses `EventEmitter`- not
for outputs. The code is pretty minimal though, so that should be
acceptable.

`EventEmitter` will now always retain `NgZone. This increases the
payload size slightly around 800b for AIO. Note that the other increases
were coming from previous changes. This commit just pushed it over the
threshold.

PR Close #54650
2024-03-06 12:34:39 +01:00
Paul Gschwendtner
30355f6719 refactor(core): model() implements OutputRef (#54650)
A model signal is technically an output, at runtime and conceptually.

This commit re-uses the shared output ref logic and ensures the
interfaces match.

PR Close #54650
2024-03-06 12:34:38 +01:00
Paul Gschwendtner
e7ea6c0564 test: add compliance generated output tests for output() (#54650)
This commit adds compliance tests for the new output APIs.

PR Close #54650
2024-03-06 12:34:38 +01:00
Paul Gschwendtner
aff65fd1f4 feat(core): introduce outputToObservable interop helper (#54650)
This commit introduces an addition to `output()` and
`outputFromObservable`()` —called `outputToObservable()`.

The helper lives in the RxJS interop package and allows agnostic
programmatic subscriptions to `OutputRef`s by converting the output
to an observable with `.pipe` etc.

The function is ideally used in all places where you subscribe to an
output programmatically. Those outputs in the future, with the new APIs,
may not be actual RxJS constructs, but abstract `OutputRef`'s that
simply expose a `.subscribe` method. The helper allows you to
agnostically convert outputs to RxJS observables that you can safely
interact with.

The observables are also completed automatically, if possible, when the
owning directive/component is destroyed— Something that is not
guaranteed right now.

PR Close #54650
2024-03-06 12:34:38 +01:00
Paul Gschwendtner
c809069f21 feat(core): introduce outputFromObservable() interop function (#54650)
Introduces a second API in addition to the new `output()` function.

The new function `outputFromObservable()` can be used to declare outputs
using the new `OutputRef` API and `output()` API, while using a custom
RxJS observable as data source.

This is something that is currently possible in Angular and we would
like to keep possible- even though we never intended to support custom
observables aside from RxJS-based `EventEmitter`.

The interop bridges the gap and allows you to continue using
`Subject`, `ReplaySubject`, `BehaivorSubjct,` - or cold custom
observables for outputs. You can still trigger logic only when
the output is subscribed- unlike with imperative `emit`s of
`EventEmitter` or the new `OutputEmitterRef`.

A notable difference is that you need two class members where you
previously could access the `Subject` directly. This is an intentional
trade-off we've made to ensure that all new outputs implement the
`OutputRef` interface and we are exposing a minimal API surface to
consumers of components that currently access the output
programmatically.

PR Close #54650
2024-03-06 12:34:38 +01:00
Paul Gschwendtner
9b5129259e refactor(compiler-cli): support detecting initializer APIs from different modules (#54650)
This commit allows us to detect initializer APIs like
`outputFromObservable` that are declared in different modules- not
necessarily `@angular/core`.

PR Close #54650
2024-03-06 12:34:38 +01:00
Paul Gschwendtner
c687b8f453 feat(core): expose new output() API (#54650)
This commit exposes the new `output()` API with numerous benefits:

- Symmetrical API to `input()`, `model()` etc.
- Fixed types for `EventEmitter.emit`— current `emit` method of
  `EventEmitter` is broken and accepts `undefined` via `emit(value?: T)`
- Removal of RxJS specific concepts from outputs. error channels,
  completion channels etc. We now have a simple consistent
  interface.
- Automatic clean-up of subscribers upon directive/component destory-
  when subscribed programmatically.

```ts
@Directive({..})
export class MyDir {
  nameChange = output<string>();     // OutputEmitterRef<string>
  onClick = output();                // OutputEmitterRef<void>
}
```

Note: RxJS custom observable cases will be handled in future commits via
explicit helpers from the interop.

PR Close #54650
2024-03-06 12:34:38 +01:00
Paul Gschwendtner
9ce627746c refactor(core): create OutputRef runtime construct (#54650)
This commit creates the proposed `OutputRef` interface along
with `OutputEmitterRef`:

- `OutputRef` is the consistent interface for all Angular outputs.
- `OutputEmitterRef` is an extension for emitting values. Like
  `EventEmitter`.
- subscriptions are cleaned up automatically upon directive/component
  destroy.
- emitting is an error when destroyed
- subscribing programmatically is an error when already destroyed.

This commit will also implement the shared output ref runtime construct,
that can be used by `output()`, `outputFromObservable()` and `model()`.

We will manage subscriptions in a simple way, manually, without RxJS.

PR Close #54650
2024-03-06 12:34:38 +01:00
Paul Gschwendtner
2564b45b47 test: replace fake_core with real @angular/core output (#54650)
This commit replaces `fake_core` with the real `@angular/core`
output. See previous commit for reasons.

Overall, this commit:

* Replaces references of `fake_core`
* Fixes tests that were testing Angular compiler detection that _would_
  already be flagged by type-checking of TS directly. We keep these
  tests for now, and add `@ts-ignore` to verify the Angular checks, in
  case type checking is disabled in user applications- but it's worth
  considering to remove these tests. Follow-up question/non-priority.
* Adds `@ts-ignore` to the tests for `defer` 1P because the property is
  marked as `@internal` and now is (correctly) causing failures in the
  compiler test environment.
* Fixes a couple of tests with typos, wrong properties etc that
  previously weren't detected! A good sign.

PR Close #54650
2024-03-06 12:34:38 +01:00
Paul Gschwendtner
5afa4f0ec1 fix(compiler-cli): support ModuleWithProviders literal detection with typeof (#54650)
As part of improving test safety of the compiler, I've noticed that
we have a special pass for detecting external `ModuleWithProviders`
where we detect the module type from an object literal.

This literal is structured like the following: `{ngModule: T}`. The
detection currently takes `T` directly, but in practice it should be
`typeof T` to satisfy the `ModuleWithProviders` type that is accepted
as part of `Component#imports`.

This commit adds support for this, so that we can fix the unit test
in preparation for using the real Angular core types in ngtsc tests.

PR Close #54650
2024-03-06 12:34:38 +01:00
Angular Robot
bd60fb1f4e docs: update Angular CLI help [main] (#54712)
Updated Angular CLI help contents.

PR Close #54712
2024-03-06 10:34:11 +01:00
Alan Agius
4842eedd7e fix(docs-infra): do not delete BUILD.bazel in help directory during updates (#54697)
In https://github.com/angular/angular/pull/54591, a `BUILD.bazel` file was created in `aio/content/cli/help/BUILD.bazel`, this however breaks the automatic CLI help pages updates as prior to this change, the `help` directory was being deleted. See: 17346e89da

This commit, updates the process to delete only the JSON files and copying the new files.

PR Close #54697
2024-03-06 10:18:03 +01:00
Jessica Janiuk
755390ace3 docs: add process documentation to CARETAKER.md (#54664)
This adds documentation regarding the latest changes to framework merge tools. It specifically covers the requires: TGP label and separate sync for primitives.

PR Close #54664
2024-03-05 19:11:41 +01:00
Matthieu Riegler
d2ec5b6178 docs: fix clipped docs-code block in docs-reference-api-tab (#54621)
PR Close #54621
2024-03-05 18:35:09 +01:00
Matthieu Riegler
b5366f20d9 docs: fix tutorial preview size (#54621)
PR Close #54621
2024-03-05 18:35:06 +01:00
Matthieu Riegler
40424fc4b6 docs: fix label on API link. (#54621)
Remove the unecessary double quotes on a @see link.

PR Close #54621
2024-03-05 18:35:04 +01:00
Matthieu Riegler
70996ed8d3 docs(docs-infra): remove unwanted styling on API page. (#54621)
`box-sizing: border-box` prevents overflow caused by borders.

PR Close #54621
2024-03-05 18:35:02 +01:00
Jessica Janiuk
0ecf515798 ci: fix ng-dev build for pr merging (#54707)
This updates ng-dev to the latest hash fixing the merge files query.

PR Close #54707
2024-03-05 18:16:30 +01:00
Dylan Hunn
b40f1e5b86 refactor(compiler): Remove deep imports in the language service (#54695)
Previously, the language service relied on deep imports such as `@angular/compiler/render3/...`. This is bad form, because that creates a dependency on the package's internal structure. Additionally, this is not compatible with google3.

In this PR, I replace all the deep imports with shallow imports, in some cases adding the missing symbol to the `compiler.ts` exports.

PR Close #54695
2024-03-05 10:28:45 +01:00
Andrew Kushnir
33a6fab094 fix(core): apply TestBed provider overrides to @defer dependencies (#54667)
This commit updates TestBed logic to take into account situations when dependencies loaded within `@defer` blocks may import NgModules with providers. For such components, we invoke provider override function, which recursively inspects and applies the necessary changes.

PR Close #54667
2024-03-05 09:21:22 +01:00
Paul Gschwendtner
78e69117f0 fix(core): generic inference for signal inputs may break with --strictFunctionTypes (#54652)
This commit fixes that the generic inference for signal inputs may break
with `--strictFunctionTypes`.

We are not using --strictFunctionTypes` in all tests, so function parameters are always
checked bivariantly- while in 1P function parameters are checked contravariantly. This
breaks sub-typing and e.g. `InputSignal<number>` is not a subtype of `InputSignalWithTransform<unknown, number>`.

Root cause is that the input signal captures the equality function that
is exclusively concerned with the `ReadT`. And `ReadT` is never equal, or a
supertype of unknown.

https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgSSTAFcYBlBAcyUwBsB1BGACwBUpMkBndaAWwA8AJWCYAJqwA0celCbBWAPjgBvAFBw4Aei1xWACXxlEXOCzxQIEeNkzEuwAIRmAnmDxhMHPsFRRTXnjYzMDYANbAYnDYECgcAG5eCJwwtC7SAHIA8qxwAEYIALSJcilpAHQacMAAjsR0AFxwABSYTSLiUvntohIAlHAAvMp5VrSiSADcalUA+rNQvaw9ndOa8wDucqjLMtsK0wC+aqCQsIgoaFi4BESkFNR0wkuKVaCoSGKmhCTkVDQMJhsDjcXhQQQdCTSSFKVTHNQxbjwEBNH73f50RgsdicHj8ATEJBhJAQDZIaRIYh8PJoZSDKqU2i0ZyYb53P6PWgCSnU2nTKpaABUM00rDceAA5GiOQDuVSaVBFBKTHASfBWVwMXlxmYIK53HApeyHgCscDcWDBITiaTyar5bSJZVReLTBB0HAwJZ3LAXIbavVaMrAhcYnxPDAENrgM7NHpxYbWk0eQrpHlkw6oANhvkxhNlQhTGq4BqtTqYHqYAmJUm4NaSWS00167bsyM85wnVU4-H3G6PZ5vL40KYJZhg59DeOS4tQxBw5hI9HYz2XQaJS2yQWi9YS1xNY9o7r9ZKU2gnc0AEwzDTZVgAUSaABF7wAFe8ZF8ZXJZDJwAAGhSFFwMByNgMAAGKEuBCCxGKfb-nA6C0JglArqugpaEAA

PR Close #54652
2024-03-04 19:07:39 +01:00
cexbrayat
5e32a775d9 refactor(compiler): cleanup unused code in template builder pipeline (#54654)
This removes some unused code and fixes a few typos across the pipeline code.

PR Close #54654
2024-03-04 18:15:54 +01:00
Jessica Janiuk
6531e4c365 ci: Add primitives configurations for ng-dev tools (#54662)
This adds the configs to enable validators and google sync patterns for primitives sharing.

PR Close #54662
2024-03-04 17:41:17 +01:00
danieljancar
07d5e42dbb docs: revise documentation for @for control flow, 'track $index' performance issues explanation, and confusing 'trackBy' mention (#53806)
PR Close #53806
2024-03-04 11:37:37 +01:00
Pawel Kozlowski
0ddae16aac docs: queries as signals adev guide (#54505)
Add a angular.dev version of queries as signals guide.

PR Close #54505
2024-03-04 11:11:16 +01:00
Andrew Scott
07173fd011 refactor(core): Pending effects should make the application unstable (#53835)
In zone-full applications, this is already true because effects are
scheduled inside a microtask and tracked by ZoneJS. When not using
zones, this should stay consistent on principle and for testability
reasons. A general pattern with zoneless testing will be to update state
and `await` some promise (i.e. `fixture.whenStable`, which will be
linked to `ApplicationRef.isStable`).

PR Close #53835
2024-03-04 10:35:38 +01:00
Matthieu Riegler
0d98972cc6 docs(docs-infra): Update tutorial deps (#54677)
PR Close #54677
2024-03-04 10:03:14 +01:00
Hozefa Mangalorewala
3e703f55e0 docs: fix broken link on the tutorial page (#54669)
PR Close #54669
2024-03-03 13:59:02 +01:00
Andrew Scott
66d78a7dcc refactor(core): ComponentFixture autodetect should detect changes within ApplicationRef.tick (#54354)
The current behavior of `autoDetect` in `ComponentFixture` does not
match production very well. It has several flaws that make it an
insufficient change detection mechanism:

* It runs change detection for the component under test _after_ views
  attached to the `ApplicationRef`. This can cause real behavior
  differences that break in production, because tests can observe view
  refreshes in the incorrect order (for example, a dialog refreshing
  before the component which opened it).
* Because of the above ordering, render hooks registered during change
  detection of the fixture views _will not execute at all_ because
  `ApplicationRef.tick` already happen.
* It does not rerun change detection on the view tree if there are more
  dirty views to refresh after the render hooks complete.
* It effectively hides/swallows errors from change detection inside the
  `onMicrotaskEmpty` subscription by not reporting them to the error
  handler. Instead, this error ends up being unhandled in the
  subscription and rxjs throws these in a `setTimeout`.

All of the above are problematic but this commit _does not_ fix the
final point. Ideally, we can land this in a future change but this
requires additional internal fixes. In the meantime, we have to juggle
special-case handling of the component fixture views within
`ApplicationRef.tick` using some special events to retain current
behavior and avoid errors from the fixture propagating to the `ErrorHandler`.

breaking note for future when isG3 flag condition is removed for v18:
The `ComponentFixture.autoDetect` feature now executes
change detection for the fixture within `ApplicationRef.tick`. This more
closely matches the behavior of how a component would refresh in
production. The order of component refresh in tests may be slightly
affected as a result, especially when dealing with additional components
attached to the application, such as dialogs. Tests sensitive to this
type of change (such as screenshot tests) may need to be updated.

PR Close #54354
2024-02-29 20:53:09 -08:00
Swami
b3220795d5 refactor(core): remove unused EffectRef import statement (#53863)
Remove unused, leftover imports.

PR Close #53863
2024-02-29 14:54:50 +01:00