@angular/core 16.0.0-next.5 → 16.0.0-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/rxjs-interop/index.mjs +9 -0
- package/esm2022/rxjs-interop/public_api.mjs +15 -0
- package/esm2022/rxjs-interop/rxjs-interop.mjs +5 -0
- package/esm2022/rxjs-interop/src/from_observable.mjs +46 -0
- package/esm2022/rxjs-interop/src/from_signal.mjs +36 -0
- package/esm2022/rxjs-interop/src/index.mjs +11 -0
- package/esm2022/rxjs-interop/src/take_until_destroyed.mjs +33 -0
- package/esm2022/src/application_ref.mjs +78 -19
- package/esm2022/src/change_detection/differs/iterable_differs.mjs +1 -1
- package/esm2022/src/core.mjs +2 -2
- package/esm2022/src/core_private_export.mjs +3 -4
- package/esm2022/src/core_reactivity_export_internal.mjs +1 -1
- package/esm2022/src/di/index.mjs +1 -4
- package/esm2022/src/errors.mjs +3 -2
- package/esm2022/src/hydration/annotate.mjs +4 -2
- package/esm2022/src/hydration/api.mjs +40 -38
- package/esm2022/src/hydration/cleanup.mjs +11 -19
- package/esm2022/src/hydration/error_handling.mjs +8 -8
- package/esm2022/src/linker/component_factory.mjs +1 -1
- package/esm2022/src/linker/query_list.mjs +1 -5
- package/esm2022/src/linker/template_ref.mjs +2 -2
- package/esm2022/src/linker/view_container_ref.mjs +2 -2
- package/esm2022/src/linker/view_ref.mjs +2 -2
- package/esm2022/src/metadata/ng_module.mjs +1 -2
- package/esm2022/src/render3/component_ref.mjs +18 -9
- package/esm2022/src/render3/hooks.mjs +32 -28
- package/esm2022/src/render3/instructions/element.mjs +2 -1
- package/esm2022/src/render3/instructions/element_container.mjs +1 -2
- package/esm2022/src/render3/instructions/shared.mjs +28 -16
- package/esm2022/src/render3/interfaces/view.mjs +16 -17
- package/esm2022/src/render3/ng_module_ref.mjs +9 -7
- package/esm2022/src/render3/pipe.mjs +2 -2
- package/esm2022/src/render3/reactive_lview_consumer.mjs +2 -1
- package/esm2022/src/render3/reactivity/effect.mjs +55 -45
- package/esm2022/src/sanitization/sanitization.mjs +3 -3
- package/esm2022/src/sanitization/url_sanitizer.mjs +7 -6
- package/esm2022/src/signals/index.mjs +5 -4
- package/esm2022/src/signals/src/api.mjs +1 -2
- package/esm2022/src/signals/src/computed.mjs +2 -1
- package/esm2022/src/signals/src/errors.mjs +18 -0
- package/esm2022/src/signals/src/graph.mjs +35 -8
- package/esm2022/src/signals/src/signal.mjs +26 -1
- package/esm2022/src/signals/src/watch.mjs +3 -2
- package/esm2022/src/signals/src/weak_ref.mjs +4 -1
- package/esm2022/src/util/decorators.mjs +6 -1
- package/esm2022/src/util/ng_dev_mode.mjs +2 -1
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/testing/src/fake_async.mjs +2 -2
- package/esm2022/testing/src/logger.mjs +3 -3
- package/esm2022/testing/src/ng_zone_mock.mjs +3 -3
- package/esm2022/testing/src/test_bed_compiler.mjs +3 -4
- package/fesm2022/core.mjs +9306 -9920
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +104 -0
- package/fesm2022/rxjs-interop.mjs.map +1 -0
- package/fesm2022/testing.mjs +2361 -2639
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +171 -450
- package/package.json +7 -1
- package/rxjs-interop/index.d.ts +95 -0
- package/schematics/migrations/guard-and-resolve-interfaces/bundle.js +13 -13
- package/schematics/migrations/remove-module-id/bundle.js +14 -14
- package/schematics/ng-generate/standalone-migration/bundle.js +1515 -1718
- package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
- package/testing/index.d.ts +2 -2
- package/esm2022/src/di/reflective_errors.mjs +0 -217
- package/esm2022/src/di/reflective_injector.mjs +0 -311
- package/esm2022/src/di/reflective_key.mjs +0 -73
- package/esm2022/src/di/reflective_provider.mjs +0 -209
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Angular v16.0.0-next.7
|
|
3
|
+
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { assertInInjectionContext, signal, inject, DestroyRef, computed, Injector, effect } from '@angular/core';
|
|
8
|
+
import { Observable } from 'rxjs';
|
|
9
|
+
import { takeUntil } from 'rxjs/operators';
|
|
10
|
+
|
|
11
|
+
function fromObservable(source, initialValue) {
|
|
12
|
+
assertInInjectionContext(fromObservable);
|
|
13
|
+
// Note: T is the Observable value type, and U is the initial value type. They don't have to be
|
|
14
|
+
// the same - the returned signal gives values of type `T`.
|
|
15
|
+
let state;
|
|
16
|
+
if (initialValue === undefined && arguments.length !== 2) {
|
|
17
|
+
// No initial value was passed, so initially the signal is in a `NoValue` state and will throw
|
|
18
|
+
// if accessed.
|
|
19
|
+
state = signal({ kind: 0 /* StateKind.NoValue */ });
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// An initial value was passed, so use it.
|
|
23
|
+
state = signal({ kind: 1 /* StateKind.Value */, value: initialValue });
|
|
24
|
+
}
|
|
25
|
+
const sub = source.subscribe({
|
|
26
|
+
next: value => state.set({ kind: 1 /* StateKind.Value */, value }),
|
|
27
|
+
error: error => state.set({ kind: 2 /* StateKind.Error */, error }),
|
|
28
|
+
// Completion of the Observable is meaningless to the signal. Signals don't have a concept of
|
|
29
|
+
// "complete".
|
|
30
|
+
});
|
|
31
|
+
// Unsubscribe when the current context is destroyed.
|
|
32
|
+
inject(DestroyRef).onDestroy(sub.unsubscribe.bind(sub));
|
|
33
|
+
// The actual returned signal is a `computed` of the `State` signal, which maps the various states
|
|
34
|
+
// to either values or errors.
|
|
35
|
+
return computed(() => {
|
|
36
|
+
const current = state();
|
|
37
|
+
switch (current.kind) {
|
|
38
|
+
case 1 /* StateKind.Value */:
|
|
39
|
+
return current.value;
|
|
40
|
+
case 2 /* StateKind.Error */:
|
|
41
|
+
throw current.error;
|
|
42
|
+
case 0 /* StateKind.NoValue */:
|
|
43
|
+
// TODO(alxhub): use a RuntimeError when we finalize the error semantics
|
|
44
|
+
throw new Error(`fromObservable() signal read before the Observable emitted`);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Exposes the value of an Angular `Signal` as an RxJS `Observable`.
|
|
51
|
+
*
|
|
52
|
+
* The signal's value will be propagated into the `Observable`'s subscribers using an `effect`.
|
|
53
|
+
*
|
|
54
|
+
* `fromSignal` must be called in an injection context.
|
|
55
|
+
*
|
|
56
|
+
* @developerPreview
|
|
57
|
+
*/
|
|
58
|
+
function fromSignal(source, options) {
|
|
59
|
+
!options?.injector && assertInInjectionContext(fromSignal);
|
|
60
|
+
const injector = options?.injector ?? inject(Injector);
|
|
61
|
+
// Creating a new `Observable` allows the creation of the effect to be lazy. This allows for all
|
|
62
|
+
// references to `source` to be dropped if the `Observable` is fully unsubscribed and thrown away.
|
|
63
|
+
return new Observable(observer => {
|
|
64
|
+
const watcher = effect(() => {
|
|
65
|
+
try {
|
|
66
|
+
observer.next(source());
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
observer.error(err);
|
|
70
|
+
}
|
|
71
|
+
}, { injector, manualCleanup: true });
|
|
72
|
+
return () => watcher.destroy();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Operator which completes the Observable when the calling context (component, directive, service,
|
|
78
|
+
* etc) is destroyed.
|
|
79
|
+
*
|
|
80
|
+
* @param destroyRef optionally, the `DestroyRef` representing the current context. This can be
|
|
81
|
+
* passed explicitly to use `takeUntilDestroyed` outside of an injection context. Otherwise, the
|
|
82
|
+
* current `DestroyRef` is injected.
|
|
83
|
+
*
|
|
84
|
+
* @developerPreview
|
|
85
|
+
*/
|
|
86
|
+
function takeUntilDestroyed(destroyRef) {
|
|
87
|
+
if (!destroyRef) {
|
|
88
|
+
assertInInjectionContext(takeUntilDestroyed);
|
|
89
|
+
destroyRef = inject(DestroyRef);
|
|
90
|
+
}
|
|
91
|
+
const destroyed$ = new Observable(observer => {
|
|
92
|
+
destroyRef.onDestroy(observer.next.bind(observer));
|
|
93
|
+
});
|
|
94
|
+
return (source) => {
|
|
95
|
+
return source.pipe(takeUntil(destroyed$));
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Generated bundle index. Do not edit.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
export { fromObservable, fromSignal, takeUntilDestroyed };
|
|
104
|
+
//# sourceMappingURL=rxjs-interop.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rxjs-interop.mjs","sources":["../../../../../../packages/core/rxjs-interop/src/from_observable.ts","../../../../../../packages/core/rxjs-interop/src/from_signal.ts","../../../../../../packages/core/rxjs-interop/src/take_until_destroyed.ts","../../../../../../packages/core/rxjs-interop/rxjs-interop.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {assertInInjectionContext, computed, DestroyRef, inject, signal, Signal, WritableSignal} from '@angular/core';\nimport {Observable} from 'rxjs';\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `fromObservable` returns a `Signal` which provides synchronous reactive access to values produced\n * by the given `Observable`, by subscribing to that `Observable`. The returned `Signal` will always\n * have the most recent value emitted by the subscription, and will throw an error if the\n * `Observable` errors.\n *\n * The subscription will last for the lifetime of the current injection context. That is, if\n * `fromObservable` is called from a component context, the subscription will be cleaned up when the\n * component is destroyed. When called outside of a component, the current `EnvironmentInjector`'s\n * lifetime will be used (which is typically the lifetime of the application itself).\n *\n * If the `Observable` does not produce a value before the `Signal` is read, the `Signal` will throw\n * an error. To avoid this, use a synchronous `Observable` (potentially created with the `startWith`\n * operator) or pass an initial value to `fromObservable` as the second argument.\n *\n * `fromObservable` must be called in an injection context.\n */\nexport function fromObservable<T>(source: Observable<T>): Signal<T>;\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `fromObservable` returns a `Signal` which provides synchronous reactive access to values produced\n * by the given `Observable`, by subscribing to that `Observable`. The returned `Signal` will always\n * have the most recent value emitted by the subscription, and will throw an error if the\n * `Observable` errors.\n *\n * The subscription will last for the lifetime of the current injection context. That is, if\n * `fromObservable` is called from a component context, the subscription will be cleaned up when the\n * component is destroyed. When called outside of a component, the current `EnvironmentInjector`'s\n * lifetime will be used (which is typically the lifetime of the application itself).\n *\n * Before the `Observable` emits its first value, the `Signal` will return the configured\n * `initialValue`. If the `Observable` is known to produce a value before the `Signal` will be read,\n * `initialValue` does not need to be passed.\n *\n * `fromObservable` must be called in an injection context.\n *\n * @developerPreview\n */\nexport function fromObservable<T, U extends T|null|undefined>(\n // fromObservable(Observable<Animal>) -> Signal<Cat>\n source: Observable<T>, initialValue: U): Signal<T|U>;\nexport function fromObservable<T, U = never>(source: Observable<T>, initialValue?: U): Signal<T|U> {\n assertInInjectionContext(fromObservable);\n\n // Note: T is the Observable value type, and U is the initial value type. They don't have to be\n // the same - the returned signal gives values of type `T`.\n let state: WritableSignal<State<T|U>>;\n if (initialValue === undefined && arguments.length !== 2) {\n // No initial value was passed, so initially the signal is in a `NoValue` state and will throw\n // if accessed.\n state = signal({kind: StateKind.NoValue});\n } else {\n // An initial value was passed, so use it.\n state = signal<State<T|U>>({kind: StateKind.Value, value: initialValue!});\n }\n\n const sub = source.subscribe({\n next: value => state.set({kind: StateKind.Value, value}),\n error: error => state.set({kind: StateKind.Error, error}),\n // Completion of the Observable is meaningless to the signal. Signals don't have a concept of\n // \"complete\".\n });\n\n // Unsubscribe when the current context is destroyed.\n inject(DestroyRef).onDestroy(sub.unsubscribe.bind(sub));\n\n // The actual returned signal is a `computed` of the `State` signal, which maps the various states\n // to either values or errors.\n return computed(() => {\n const current = state();\n switch (current.kind) {\n case StateKind.Value:\n return current.value;\n case StateKind.Error:\n throw current.error;\n case StateKind.NoValue:\n // TODO(alxhub): use a RuntimeError when we finalize the error semantics\n throw new Error(`fromObservable() signal read before the Observable emitted`);\n }\n });\n}\n\nconst enum StateKind {\n NoValue,\n Value,\n Error,\n}\n\ninterface NoValueState {\n kind: StateKind.NoValue;\n}\n\ninterface ValueState<T> {\n kind: StateKind.Value;\n value: T;\n}\n\ninterface ErrorState {\n kind: StateKind.Error;\n error: unknown;\n}\n\ntype State<T> = NoValueState|ValueState<T>|ErrorState;\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {assertInInjectionContext, effect, inject, Injector, Signal} from '@angular/core';\nimport {Observable} from 'rxjs';\n\n/**\n * Options for `fromSignal`.\n *\n * @developerPreview\n */\nexport interface FromSignalOptions {\n /**\n * The `Injector` to use when creating the effect.\n *\n * If this isn't specified, the current injection context will be used.\n */\n injector?: Injector;\n}\n\n/**\n * Exposes the value of an Angular `Signal` as an RxJS `Observable`.\n *\n * The signal's value will be propagated into the `Observable`'s subscribers using an `effect`.\n *\n * `fromSignal` must be called in an injection context.\n *\n * @developerPreview\n */\nexport function fromSignal<T>(\n source: Signal<T>,\n options?: FromSignalOptions,\n ): Observable<T> {\n !options?.injector && assertInInjectionContext(fromSignal);\n const injector = options?.injector ?? inject(Injector);\n\n // Creating a new `Observable` allows the creation of the effect to be lazy. This allows for all\n // references to `source` to be dropped if the `Observable` is fully unsubscribed and thrown away.\n return new Observable(observer => {\n const watcher = effect(() => {\n try {\n observer.next(source());\n } catch (err) {\n observer.error(err);\n }\n }, {injector, manualCleanup: true});\n return () => watcher.destroy();\n });\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {assertInInjectionContext, DestroyRef, inject} from '@angular/core';\nimport {MonoTypeOperatorFunction, Observable} from 'rxjs';\nimport {takeUntil} from 'rxjs/operators';\n\n/**\n * Operator which completes the Observable when the calling context (component, directive, service,\n * etc) is destroyed.\n *\n * @param destroyRef optionally, the `DestroyRef` representing the current context. This can be\n * passed explicitly to use `takeUntilDestroyed` outside of an injection context. Otherwise, the\n * current `DestroyRef` is injected.\n *\n * @developerPreview\n */\nexport function takeUntilDestroyed<T>(destroyRef?: DestroyRef): MonoTypeOperatorFunction<T> {\n if (!destroyRef) {\n assertInInjectionContext(takeUntilDestroyed);\n destroyRef = inject(DestroyRef);\n }\n\n const destroyed$ = new Observable<void>(observer => {\n destroyRef!.onDestroy(observer.next.bind(observer));\n });\n\n return <T>(source: Observable<T>) => {\n return source.pipe(takeUntil(destroyed$));\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAwDgB,SAAA,cAAc,CAAe,MAAqB,EAAE,YAAgB,EAAA;IAClF,wBAAwB,CAAC,cAAc,CAAC,CAAC;;;AAIzC,IAAA,IAAI,KAAiC,CAAC;IACtC,IAAI,YAAY,KAAK,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;;;QAGxD,KAAK,GAAG,MAAM,CAAC,EAAC,IAAI,EAAmB,CAAA,0BAAC,CAAC,CAAC;AAC3C,KAAA;AAAM,SAAA;;AAEL,QAAA,KAAK,GAAG,MAAM,CAAa,EAAC,IAAI,EAAA,CAAA,wBAAmB,KAAK,EAAE,YAAa,EAAC,CAAC,CAAC;AAC3E,KAAA;AAED,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC;AAC3B,QAAA,IAAI,EAAE,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,EAAC,IAAI,EAAA,CAAA,wBAAmB,KAAK,EAAC,CAAC;AACxD,QAAA,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,EAAC,IAAI,EAAA,CAAA,wBAAmB,KAAK,EAAC,CAAC;;;AAG1D,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