@angular/core 17.0.0-next.4 → 17.0.0-next.6
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/src/to_signal.mjs +13 -11
- package/esm2022/src/application_init.mjs +3 -3
- package/esm2022/src/application_module.mjs +3 -3
- package/esm2022/src/application_ref.mjs +23 -6
- package/esm2022/src/change_detection/differs/default_iterable_differ.mjs +1 -2
- package/esm2022/src/console.mjs +2 -2
- package/esm2022/src/core.mjs +2 -2
- package/esm2022/src/core_private_export.mjs +4 -2
- package/esm2022/src/core_render3_private_export.mjs +3 -2
- package/esm2022/src/errors.mjs +1 -1
- package/esm2022/src/hydration/api.mjs +7 -8
- package/esm2022/src/hydration/views.mjs +3 -3
- package/esm2022/src/initial_render_pending_tasks.mjs +2 -2
- package/esm2022/src/linker/compiler.mjs +2 -2
- package/esm2022/src/linker/query_list.mjs +7 -10
- package/esm2022/src/linker/view_container_ref.mjs +12 -10
- package/esm2022/src/metadata/ng_module_def.mjs +1 -1
- package/esm2022/src/render3/after_render_hooks.mjs +100 -13
- package/esm2022/src/render3/deps_tracker/api.mjs +1 -1
- package/esm2022/src/render3/deps_tracker/deps_tracker.mjs +16 -10
- package/esm2022/src/render3/index.mjs +2 -2
- package/esm2022/src/render3/instructions/control_flow.mjs +6 -4
- package/esm2022/src/render3/instructions/defer.mjs +495 -112
- package/esm2022/src/render3/instructions/defer_events.mjs +154 -0
- package/esm2022/src/render3/instructions/shared.mjs +1 -1
- package/esm2022/src/render3/instructions/template.mjs +9 -2
- package/esm2022/src/render3/interfaces/defer.mjs +64 -1
- package/esm2022/src/render3/interfaces/definition.mjs +1 -1
- package/esm2022/src/render3/local_compilation.mjs +8 -2
- package/esm2022/src/render3/metadata.mjs +2 -2
- package/esm2022/src/render3/reactive_lview_consumer.mjs +1 -1
- package/esm2022/src/render3/reactivity/effect.mjs +3 -15
- package/esm2022/src/render3/scope.mjs +10 -4
- package/esm2022/src/render3/state.mjs +2 -11
- package/esm2022/src/render3/util/view_utils.mjs +17 -3
- package/esm2022/src/signals/src/api.mjs +2 -2
- package/esm2022/src/signals/src/computed.mjs +50 -45
- package/esm2022/src/signals/src/graph.mjs +7 -2
- package/esm2022/src/signals/src/signal.mjs +11 -6
- package/esm2022/src/signals/src/watch.mjs +40 -12
- package/esm2022/src/testability/testability.mjs +5 -5
- package/esm2022/src/util/assert.mjs +6 -1
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/testing/src/component_fixture.mjs +19 -2
- package/esm2022/testing/src/defer.mjs +84 -0
- package/esm2022/testing/src/logger.mjs +4 -4
- package/esm2022/testing/src/test_bed.mjs +12 -2
- package/esm2022/testing/src/test_bed_common.mjs +1 -1
- package/esm2022/testing/src/test_bed_compiler.mjs +5 -2
- package/esm2022/testing/src/testing.mjs +3 -1
- package/fesm2022/core.mjs +1691 -930
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +13 -11
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +109 -3
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +279 -49
- package/package.json +3 -3
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/block-template-entities/bundle.js +23249 -0
- package/schematics/migrations/block-template-entities/bundle.js.map +7 -0
- package/schematics/migrations.json +4 -9
- package/schematics/ng-generate/standalone-migration/bundle.js +2867 -2021
- package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
- package/testing/index.d.ts +43 -1
- package/schematics/migrations/guard-and-resolve-interfaces/bundle.js +0 -694
- package/schematics/migrations/guard-and-resolve-interfaces/bundle.js.map +0 -7
- package/schematics/migrations/remove-module-id/bundle.js +0 -368
- package/schematics/migrations/remove-module-id/bundle.js.map +0 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v17.0.0-next.
|
|
2
|
+
* @license Angular v17.0.0-next.6
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -78,17 +78,19 @@ function toSignal(source, options) {
|
|
|
78
78
|
// If an initial value was passed, use it. Otherwise, use `undefined` as the initial value.
|
|
79
79
|
state = signal({ kind: 1 /* StateKind.Value */, value: options?.initialValue });
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
untracked(() => {
|
|
82
|
+
const sub = source.subscribe({
|
|
83
|
+
next: value => state.set({ kind: 1 /* StateKind.Value */, value }),
|
|
84
|
+
error: error => state.set({ kind: 2 /* StateKind.Error */, error }),
|
|
85
|
+
// Completion of the Observable is meaningless to the signal. Signals don't have a concept of
|
|
86
|
+
// "complete".
|
|
87
|
+
});
|
|
88
|
+
if (ngDevMode && options?.requireSync && state().kind === 0 /* StateKind.NoValue */) {
|
|
89
|
+
throw new ɵRuntimeError(601 /* ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT */, '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.');
|
|
90
|
+
}
|
|
91
|
+
// Unsubscribe when the current context is destroyed, if requested.
|
|
92
|
+
cleanupRef?.onDestroy(sub.unsubscribe.bind(sub));
|
|
86
93
|
});
|
|
87
|
-
if (ngDevMode && options?.requireSync && untracked(state).kind === 0 /* StateKind.NoValue */) {
|
|
88
|
-
throw new ɵRuntimeError(601 /* ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT */, '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.');
|
|
89
|
-
}
|
|
90
|
-
// Unsubscribe when the current context is destroyed, if requested.
|
|
91
|
-
cleanupRef?.onDestroy(sub.unsubscribe.bind(sub));
|
|
92
94
|
// The actual returned signal is a `computed` of the `State` signal, which maps the various states
|
|
93
95
|
// to either values or errors.
|
|
94
96
|
return computed(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rxjs-interop.mjs","sources":["../../../../../../packages/core/rxjs-interop/src/take_until_destroyed.ts","../../../../../../packages/core/rxjs-interop/src/to_observable.ts","../../../../../../packages/core/rxjs-interop/src/to_signal.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, 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\n * context](guide/dependency-injection-context). Otherwise, the 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 const unregisterFn = destroyRef!.onDestroy(observer.next.bind(observer));\n return unregisterFn;\n });\n\n return <T>(source: Observable<T>) => {\n return source.pipe(takeUntil(destroyed$));\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, effect, EffectRef, inject, Injector, Signal, untracked} from '@angular/core';\nimport {Observable, ReplaySubject} from 'rxjs';\n\n/**\n * Options for `toObservable`.\n *\n * @developerPreview\n */\nexport interface ToObservableOptions {\n /**\n * The `Injector` to use when creating the underlying `effect` which watches the signal.\n *\n * If this isn't specified, the current [injection context](guide/dependency-injection-context)\n * 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 * `toObservable` must be called in an injection context unless an injector is provided via options.\n *\n * @developerPreview\n */\nexport function toObservable<T>(\n source: Signal<T>,\n options?: ToObservableOptions,\n ): Observable<T> {\n !options?.injector && assertInInjectionContext(toObservable);\n const injector = options?.injector ?? inject(Injector);\n const subject = new ReplaySubject<T>(1);\n\n const watcher = effect(() => {\n let value: T;\n try {\n value = source();\n } catch (err) {\n untracked(() => subject.error(err));\n return;\n }\n untracked(() => subject.next(value));\n }, {injector, manualCleanup: true});\n\n injector.get(DestroyRef).onDestroy(() => {\n watcher.destroy();\n subject.complete();\n });\n\n return subject.asObservable();\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, computed, DestroyRef, inject, Injector, signal, Signal, untracked, WritableSignal, ɵRuntimeError, ɵRuntimeErrorCode} from '@angular/core';\nimport {Observable, Subscribable} from 'rxjs';\n\n/**\n * Options for `toSignal`.\n *\n * @publicApi\n */\nexport interface ToSignalOptions<T> {\n /**\n * Initial value for the signal produced by `toSignal`.\n *\n * This will be the value of the signal until the observable emits its first value.\n */\n initialValue?: T;\n\n /**\n * Whether to require that the observable emits synchronously when `toSignal` subscribes.\n *\n * If this is `true`, `toSignal` will assert that the observable produces a value immediately upon\n * subscription. Setting this option removes the need to either deal with `undefined` in the\n * signal type or provide an `initialValue`, at the cost of a runtime error if this requirement is\n * not met.\n */\n requireSync?: boolean;\n\n /**\n * `Injector` which will provide the `DestroyRef` used to clean up the Observable subscription.\n *\n * If this is not provided, a `DestroyRef` will be retrieved from the current [injection\n * context](/guide/dependency-injection-context), unless manual cleanup is requested.\n */\n injector?: Injector;\n\n /**\n * Whether the subscription should be automatically cleaned up (via `DestroyRef`) when\n * `toObservable`'s creation context is destroyed.\n *\n * If manual cleanup is enabled, then `DestroyRef` is not used, and the subscription will persist\n * until the `Observable` itself completes.\n */\n manualCleanup?: boolean;\n}\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `toSignal` 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 * Before the `Observable` emits its first value, the `Signal` will return `undefined`. To avoid\n * this, either an `initialValue` can be passed or the `requireSync` option enabled.\n *\n * By default, the subscription will be automatically cleaned up when the current [injection\n * context](guide/dependency-injection-context) is destroyed. For example, when `toObservable` is\n * called during the construction of a component, the subscription will be cleaned up when the\n * component is destroyed. If an [injection context](/guide/dependency-injection-context) is not\n * available, an explicit `Injector` can be passed instead.\n *\n * If the subscription should persist until the `Observable` itself completes, the `manualCleanup`\n * option can be specified instead, which disables the automatic subscription teardown. No injection\n * context is needed in this configuration as well.\n */\nexport function toSignal<T>(source: Observable<T>|Subscribable<T>): Signal<T|undefined>;\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `toSignal` 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 * Before the `Observable` emits its first value, the `Signal` will return the configured\n * `initialValue`, or `undefined` if no `initialValue` is provided. If the `Observable` is\n * guaranteed to emit synchronously, then the `requireSync` option can be passed instead.\n *\n * By default, the subscription will be automatically cleaned up when the current [injection\n * context](/guide/dependency-injection-context) is destroyed. For example, when `toObservable` is\n * called during the construction of a component, the subscription will be cleaned up when the\n * component is destroyed. If an injection context is not available, an explicit `Injector` can be\n * passed instead.\n *\n * If the subscription should persist until the `Observable` itself completes, the `manualCleanup`\n * option can be specified instead, which disables the automatic subscription teardown. No injection\n * context is needed in this configuration as well.\n *\n * @developerPreview\n */\nexport function toSignal<T>(\n source: Observable<T>|Subscribable<T>,\n options?: ToSignalOptions<undefined>&{requireSync?: false}): Signal<T|undefined>;\n\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `toSignal` 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 * Before the `Observable` emits its first value, the `Signal` will return the configured\n * `initialValue`. If the `Observable` is guaranteed to emit synchronously, then the `requireSync`\n * option can be passed instead.\n *\n * By default, the subscription will be automatically cleaned up when the current [injection\n * context](guide/dependency-injection-context) is destroyed. For example, when `toObservable` is\n * called during the construction of a component, the subscription will be cleaned up when the\n * component is destroyed. If an [injection context](/guide/dependency-injection-context) is not\n * available, an explicit `Injector` can be passed instead.\n *\n * If the subscription should persist until the `Observable` itself completes, the `manualCleanup`\n * option can be specified instead, which disables the automatic subscription teardown. No injection\n * context is needed in this configuration as well.\n *\n * @developerPreview\n */\nexport function toSignal<T, U extends T|null|undefined>(\n source: Observable<T>|Subscribable<T>,\n options: ToSignalOptions<U>&{initialValue: U, requireSync?: false}): Signal<T|U>;\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `toSignal` 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 * With `requireSync` set to `true`, `toSignal` will assert that the `Observable` produces a value\n * immediately upon subscription. No `initialValue` is needed in this case, and the returned signal\n * does not include an `undefined` type.\n *\n * By default, the subscription will be automatically cleaned up when the current [injection\n * context](/guide/dependency-injection-context) is destroyed. For example, when `toObservable` is\n * called during the construction of a component, the subscription will be cleaned up when the\n * component is destroyed. If an injection context is not available, an explicit `Injector` can be\n * passed instead.\n *\n * If the subscription should persist until the `Observable` itself completes, the `manualCleanup`\n * option can be specified instead, which disables the automatic subscription teardown. No injection\n * context is needed in this configuration as well.\n *\n * @developerPreview\n */\nexport function toSignal<T>(\n source: Observable<T>|Subscribable<T>,\n options: ToSignalOptions<undefined>&{requireSync: true}): Signal<T>;\nexport function toSignal<T, U = undefined>(\n source: Observable<T>|Subscribable<T>, options?: ToSignalOptions<U>): Signal<T|U> {\n const requiresCleanup = !options?.manualCleanup;\n requiresCleanup && !options?.injector && assertInInjectionContext(toSignal);\n const cleanupRef =\n requiresCleanup ? options?.injector?.get(DestroyRef) ?? inject(DestroyRef) : null;\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 (options?.requireSync) {\n // Initially the signal is in a `NoValue` state.\n state = signal({kind: StateKind.NoValue});\n } else {\n // If an initial value was passed, use it. Otherwise, use `undefined` as the initial value.\n state = signal<State<T|U>>({kind: StateKind.Value, value: options?.initialValue as U});\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 if (ngDevMode && options?.requireSync && untracked(state).kind === StateKind.NoValue) {\n throw new ɵRuntimeError(\n ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,\n '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.');\n }\n\n // Unsubscribe when the current context is destroyed, if requested.\n cleanupRef?.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 // This shouldn't really happen because the error is thrown on creation.\n // TODO(alxhub): use a RuntimeError when we finalize the error semantics\n throw new ɵRuntimeError(\n ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,\n '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.');\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 * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAYA;;;;;;;;;AASG;AACG,SAAU,kBAAkB,CAAI,UAAuB,EAAA;IAC3D,IAAI,CAAC,UAAU,EAAE;QACf,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;AAC7C,QAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AACjC,KAAA;AAED,IAAA,MAAM,UAAU,GAAG,IAAI,UAAU,CAAO,QAAQ,IAAG;AACjD,QAAA,MAAM,YAAY,GAAG,UAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzE,QAAA,OAAO,YAAY,CAAC;AACtB,KAAC,CAAC,CAAC;IAEH,OAAO,CAAI,MAAqB,KAAI;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;AAC5C,KAAC,CAAC;AACJ;;ACVA;;;;;;;;AAQG;AACa,SAAA,YAAY,CACxB,MAAiB,EACjB,OAA6B,EAAA;IAE/B,CAAC,OAAO,EAAE,QAAQ,IAAI,wBAAwB,CAAC,YAAY,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;AACvD,IAAA,MAAM,OAAO,GAAG,IAAI,aAAa,CAAI,CAAC,CAAC,CAAC;AAExC,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,MAAK;AAC1B,QAAA,IAAI,KAAQ,CAAC;QACb,IAAI;YACF,KAAK,GAAG,MAAM,EAAE,CAA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AC,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,KAAA,CAAC,CAAC;AAEH,IAAA,IAAI,SAAS,IAAI,OAAO,EAAE,WAAW,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,gCAAwB;AACpF,QAAA,MAAM,IAAI,aAAa,CAEnB,GAAA,yDAAA,qFAAqF,CAAC,CAAC;AAC5F,KAAA;;AAGD,IAAA,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;;IAIjD,OAAO,QAAQ,CAAC,MAAK;AACnB,QAAA,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;QACxB,QAAQ,OAAO,CAAC,IAAI;AAClB,YAAA,KAAA,CAAA;gBACE,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,YAAA,KAAA,CAAA;gBACE,MAAM,OAAO,CAAC,KAAK,CAAC;AACtB,YAAA,KAAA,CAAA;;;AAGE,gBAAA,MAAM,IAAI,aAAa,CAEnB,GAAA,yDAAA,qFAAqF,CAAC,CAAC;AAC9F,SAAA;AACH,KAAC,CAAC,CAAC;AACL;;AClNA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"rxjs-interop.mjs","sources":["../../../../../../packages/core/rxjs-interop/src/take_until_destroyed.ts","../../../../../../packages/core/rxjs-interop/src/to_observable.ts","../../../../../../packages/core/rxjs-interop/src/to_signal.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, 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\n * context](guide/dependency-injection-context). Otherwise, the 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 const unregisterFn = destroyRef!.onDestroy(observer.next.bind(observer));\n return unregisterFn;\n });\n\n return <T>(source: Observable<T>) => {\n return source.pipe(takeUntil(destroyed$));\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, effect, EffectRef, inject, Injector, Signal, untracked} from '@angular/core';\nimport {Observable, ReplaySubject} from 'rxjs';\n\n/**\n * Options for `toObservable`.\n *\n * @developerPreview\n */\nexport interface ToObservableOptions {\n /**\n * The `Injector` to use when creating the underlying `effect` which watches the signal.\n *\n * If this isn't specified, the current [injection context](guide/dependency-injection-context)\n * 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 * `toObservable` must be called in an injection context unless an injector is provided via options.\n *\n * @developerPreview\n */\nexport function toObservable<T>(\n source: Signal<T>,\n options?: ToObservableOptions,\n ): Observable<T> {\n !options?.injector && assertInInjectionContext(toObservable);\n const injector = options?.injector ?? inject(Injector);\n const subject = new ReplaySubject<T>(1);\n\n const watcher = effect(() => {\n let value: T;\n try {\n value = source();\n } catch (err) {\n untracked(() => subject.error(err));\n return;\n }\n untracked(() => subject.next(value));\n }, {injector, manualCleanup: true});\n\n injector.get(DestroyRef).onDestroy(() => {\n watcher.destroy();\n subject.complete();\n });\n\n return subject.asObservable();\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, computed, DestroyRef, inject, Injector, signal, Signal, untracked, WritableSignal, ɵRuntimeError, ɵRuntimeErrorCode} from '@angular/core';\nimport {Observable, Subscribable} from 'rxjs';\n\n/**\n * Options for `toSignal`.\n *\n * @publicApi\n */\nexport interface ToSignalOptions<T> {\n /**\n * Initial value for the signal produced by `toSignal`.\n *\n * This will be the value of the signal until the observable emits its first value.\n */\n initialValue?: T;\n\n /**\n * Whether to require that the observable emits synchronously when `toSignal` subscribes.\n *\n * If this is `true`, `toSignal` will assert that the observable produces a value immediately upon\n * subscription. Setting this option removes the need to either deal with `undefined` in the\n * signal type or provide an `initialValue`, at the cost of a runtime error if this requirement is\n * not met.\n */\n requireSync?: boolean;\n\n /**\n * `Injector` which will provide the `DestroyRef` used to clean up the Observable subscription.\n *\n * If this is not provided, a `DestroyRef` will be retrieved from the current [injection\n * context](/guide/dependency-injection-context), unless manual cleanup is requested.\n */\n injector?: Injector;\n\n /**\n * Whether the subscription should be automatically cleaned up (via `DestroyRef`) when\n * `toObservable`'s creation context is destroyed.\n *\n * If manual cleanup is enabled, then `DestroyRef` is not used, and the subscription will persist\n * until the `Observable` itself completes.\n */\n manualCleanup?: boolean;\n}\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `toSignal` 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 * Before the `Observable` emits its first value, the `Signal` will return `undefined`. To avoid\n * this, either an `initialValue` can be passed or the `requireSync` option enabled.\n *\n * By default, the subscription will be automatically cleaned up when the current [injection\n * context](guide/dependency-injection-context) is destroyed. For example, when `toObservable` is\n * called during the construction of a component, the subscription will be cleaned up when the\n * component is destroyed. If an [injection context](/guide/dependency-injection-context) is not\n * available, an explicit `Injector` can be passed instead.\n *\n * If the subscription should persist until the `Observable` itself completes, the `manualCleanup`\n * option can be specified instead, which disables the automatic subscription teardown. No injection\n * context is needed in this configuration as well.\n */\nexport function toSignal<T>(source: Observable<T>|Subscribable<T>): Signal<T|undefined>;\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `toSignal` 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 * Before the `Observable` emits its first value, the `Signal` will return the configured\n * `initialValue`, or `undefined` if no `initialValue` is provided. If the `Observable` is\n * guaranteed to emit synchronously, then the `requireSync` option can be passed instead.\n *\n * By default, the subscription will be automatically cleaned up when the current [injection\n * context](/guide/dependency-injection-context) is destroyed. For example, when `toObservable` is\n * called during the construction of a component, the subscription will be cleaned up when the\n * component is destroyed. If an injection context is not available, an explicit `Injector` can be\n * passed instead.\n *\n * If the subscription should persist until the `Observable` itself completes, the `manualCleanup`\n * option can be specified instead, which disables the automatic subscription teardown. No injection\n * context is needed in this configuration as well.\n *\n * @developerPreview\n */\nexport function toSignal<T>(\n source: Observable<T>|Subscribable<T>,\n options?: ToSignalOptions<undefined>&{requireSync?: false}): Signal<T|undefined>;\n\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `toSignal` 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 * Before the `Observable` emits its first value, the `Signal` will return the configured\n * `initialValue`. If the `Observable` is guaranteed to emit synchronously, then the `requireSync`\n * option can be passed instead.\n *\n * By default, the subscription will be automatically cleaned up when the current [injection\n * context](guide/dependency-injection-context) is destroyed. For example, when `toObservable` is\n * called during the construction of a component, the subscription will be cleaned up when the\n * component is destroyed. If an [injection context](/guide/dependency-injection-context) is not\n * available, an explicit `Injector` can be passed instead.\n *\n * If the subscription should persist until the `Observable` itself completes, the `manualCleanup`\n * option can be specified instead, which disables the automatic subscription teardown. No injection\n * context is needed in this configuration as well.\n *\n * @developerPreview\n */\nexport function toSignal<T, U extends T|null|undefined>(\n source: Observable<T>|Subscribable<T>,\n options: ToSignalOptions<U>&{initialValue: U, requireSync?: false}): Signal<T|U>;\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `toSignal` 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 * With `requireSync` set to `true`, `toSignal` will assert that the `Observable` produces a value\n * immediately upon subscription. No `initialValue` is needed in this case, and the returned signal\n * does not include an `undefined` type.\n *\n * By default, the subscription will be automatically cleaned up when the current [injection\n * context](/guide/dependency-injection-context) is destroyed. For example, when `toObservable` is\n * called during the construction of a component, the subscription will be cleaned up when the\n * component is destroyed. If an injection context is not available, an explicit `Injector` can be\n * passed instead.\n *\n * If the subscription should persist until the `Observable` itself completes, the `manualCleanup`\n * option can be specified instead, which disables the automatic subscription teardown. No injection\n * context is needed in this configuration as well.\n *\n * @developerPreview\n */\nexport function toSignal<T>(\n source: Observable<T>|Subscribable<T>,\n options: ToSignalOptions<undefined>&{requireSync: true}): Signal<T>;\nexport function toSignal<T, U = undefined>(\n source: Observable<T>|Subscribable<T>, options?: ToSignalOptions<U>): Signal<T|U> {\n const requiresCleanup = !options?.manualCleanup;\n requiresCleanup && !options?.injector && assertInInjectionContext(toSignal);\n const cleanupRef =\n requiresCleanup ? options?.injector?.get(DestroyRef) ?? inject(DestroyRef) : null;\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 (options?.requireSync) {\n // Initially the signal is in a `NoValue` state.\n state = signal({kind: StateKind.NoValue});\n } else {\n // If an initial value was passed, use it. Otherwise, use `undefined` as the initial value.\n state = signal<State<T|U>>({kind: StateKind.Value, value: options?.initialValue as U});\n }\n\n untracked(() => {\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 if (ngDevMode && options?.requireSync && state().kind === StateKind.NoValue) {\n throw new ɵRuntimeError(\n ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,\n '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.');\n }\n\n // Unsubscribe when the current context is destroyed, if requested.\n cleanupRef?.onDestroy(sub.unsubscribe.bind(sub));\n });\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 // This shouldn't really happen because the error is thrown on creation.\n // TODO(alxhub): use a RuntimeError when we finalize the error semantics\n throw new ɵRuntimeError(\n ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,\n '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.');\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 * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAYA;;;;;;;;;AASG;AACG,SAAU,kBAAkB,CAAI,UAAuB,EAAA;IAC3D,IA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AAA,MAAM,IAAI,aAAa,CAEnB,GAAA,yDAAA,qFAAqF,CAAC,CAAC;AAC5F,SAAA;;AAGD,QAAA,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACnD,KAAC,CAAC,CAAC;;;IAIH,OAAO,QAAQ,CAAC,MAAK;AACnB,QAAA,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;QACxB,QAAQ,OAAO,CAAC,IAAI;AAClB,YAAA,KAAA,CAAA;gBACE,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,YAAA,KAAA,CAAA;gBACE,MAAM,OAAO,CAAC,KAAK,CAAC;AACtB,YAAA,KAAA,CAAA;;;AAGE,gBAAA,MAAM,IAAI,aAAa,CAEnB,GAAA,yDAAA,qFAAqF,CAAC,CAAC;AAC9F,SAAA;AACH,KAAC,CAAC,CAAC;AACL;;ACpNA;;AAEG;;;;"}
|
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v17.0.0-next.
|
|
2
|
+
* @license Angular v17.0.0-next.6
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { getDebugNode, RendererFactory2, InjectionToken, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetAsyncClassMetadata, ɵgenerateStandaloneInDeclarationsError, ɵUSE_RUNTIME_DEPS_TRACKER_FOR_JIT, ɵdepsTracker, ɵgetInjectableDef, resolveForwardRef, ɵNG_COMP_DEF, ɵisComponentDefPendingResolution, ɵresolveComponentResources, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, ɵclearResolutionOfComponentResourcesQueue, ɵrestoreComponentResolutionQueue, provideZoneChangeDetection, Compiler, COMPILER_OPTIONS, Injector, ɵisEnvironmentProviders, ɵNgModuleFactory, ModuleWithComponentFactories, ɵconvertToBitFlags, InjectFlags, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode, ɵgetUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode, EnvironmentInjector, NgZone, ɵZoneAwareQueueingScheduler, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
|
|
7
|
+
import { ɵDeferBlockState, ɵtriggerResourceLoading, ɵrenderDeferBlockState, ɵCONTAINER_HEADER_OFFSET, ɵgetDeferBlocks, getDebugNode, RendererFactory2, InjectionToken, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetAsyncClassMetadata, ɵgenerateStandaloneInDeclarationsError, ɵDeferBlockBehavior, ɵUSE_RUNTIME_DEPS_TRACKER_FOR_JIT, ɵdepsTracker, ɵgetInjectableDef, resolveForwardRef, ɵNG_COMP_DEF, ɵisComponentDefPendingResolution, ɵresolveComponentResources, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, ɵclearResolutionOfComponentResourcesQueue, ɵrestoreComponentResolutionQueue, provideZoneChangeDetection, Compiler, ɵDEFER_BLOCK_CONFIG, COMPILER_OPTIONS, Injector, ɵisEnvironmentProviders, ɵNgModuleFactory, ModuleWithComponentFactories, ɵconvertToBitFlags, InjectFlags, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode, ɵgetUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode, EnvironmentInjector, NgZone, ɵZoneAwareQueueingScheduler, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
|
|
8
|
+
export { ɵDeferBlockBehavior as DeferBlockBehavior, ɵDeferBlockState as DeferBlockState } from '@angular/core';
|
|
8
9
|
import { ResourceLoader } from '@angular/compiler';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -50,12 +51,89 @@ function async(fn) {
|
|
|
50
51
|
return waitForAsync(fn);
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Represents an individual defer block for testing purposes.
|
|
56
|
+
*
|
|
57
|
+
* @publicApi
|
|
58
|
+
* @developerPreview
|
|
59
|
+
*/
|
|
60
|
+
class DeferBlockFixture {
|
|
61
|
+
/** @nodoc */
|
|
62
|
+
constructor(block, componentFixture) {
|
|
63
|
+
this.block = block;
|
|
64
|
+
this.componentFixture = componentFixture;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Renders the specified state of the defer fixture.
|
|
68
|
+
* @param state the defer state to render
|
|
69
|
+
*/
|
|
70
|
+
async render(state) {
|
|
71
|
+
if (!hasStateTemplate(state, this.block)) {
|
|
72
|
+
const stateAsString = getDeferBlockStateNameFromEnum(state);
|
|
73
|
+
throw new Error(`Tried to render this defer block in the \`${stateAsString}\` state, ` +
|
|
74
|
+
`but there was no @${stateAsString.toLowerCase()} block defined in a template.`);
|
|
75
|
+
}
|
|
76
|
+
if (state === ɵDeferBlockState.Complete) {
|
|
77
|
+
await ɵtriggerResourceLoading(this.block.tDetails, this.block.lView);
|
|
78
|
+
}
|
|
79
|
+
ɵrenderDeferBlockState(state, this.block.tNode, this.block.lContainer);
|
|
80
|
+
this.componentFixture.detectChanges();
|
|
81
|
+
return this.componentFixture.whenStable();
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves all nested child defer block fixtures
|
|
85
|
+
* in a given defer block.
|
|
86
|
+
*/
|
|
87
|
+
getDeferBlocks() {
|
|
88
|
+
const deferBlocks = [];
|
|
89
|
+
// An LContainer that represents a defer block has at most 1 view, which is
|
|
90
|
+
// located right after an LContainer header. Get a hold of that view and inspect
|
|
91
|
+
// it for nested defer blocks.
|
|
92
|
+
const deferBlockFixtures = [];
|
|
93
|
+
if (this.block.lContainer.length >= ɵCONTAINER_HEADER_OFFSET) {
|
|
94
|
+
const lView = this.block.lContainer[ɵCONTAINER_HEADER_OFFSET];
|
|
95
|
+
ɵgetDeferBlocks(lView, deferBlocks);
|
|
96
|
+
for (const block of deferBlocks) {
|
|
97
|
+
deferBlockFixtures.push(new DeferBlockFixture(block, this.componentFixture));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return Promise.resolve(deferBlockFixtures);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function hasStateTemplate(state, block) {
|
|
104
|
+
switch (state) {
|
|
105
|
+
case ɵDeferBlockState.Placeholder:
|
|
106
|
+
return block.tDetails.placeholderTmplIndex !== null;
|
|
107
|
+
case ɵDeferBlockState.Loading:
|
|
108
|
+
return block.tDetails.loadingTmplIndex !== null;
|
|
109
|
+
case ɵDeferBlockState.Error:
|
|
110
|
+
return block.tDetails.errorTmplIndex !== null;
|
|
111
|
+
case ɵDeferBlockState.Complete:
|
|
112
|
+
return true;
|
|
113
|
+
default:
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function getDeferBlockStateNameFromEnum(state) {
|
|
118
|
+
switch (state) {
|
|
119
|
+
case ɵDeferBlockState.Placeholder:
|
|
120
|
+
return 'Placeholder';
|
|
121
|
+
case ɵDeferBlockState.Loading:
|
|
122
|
+
return 'Loading';
|
|
123
|
+
case ɵDeferBlockState.Error:
|
|
124
|
+
return 'Error';
|
|
125
|
+
default:
|
|
126
|
+
return 'Main';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
53
130
|
/**
|
|
54
131
|
* Fixture for debugging and testing a component.
|
|
55
132
|
*
|
|
56
133
|
* @publicApi
|
|
57
134
|
*/
|
|
58
135
|
class ComponentFixture {
|
|
136
|
+
/** @nodoc */
|
|
59
137
|
constructor(componentRef, ngZone, effectRunner, _autoDetect) {
|
|
60
138
|
this.componentRef = componentRef;
|
|
61
139
|
this.ngZone = ngZone;
|
|
@@ -190,6 +268,21 @@ class ComponentFixture {
|
|
|
190
268
|
return this._promise;
|
|
191
269
|
}
|
|
192
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Retrieves all defer block fixtures in the component fixture.
|
|
273
|
+
*
|
|
274
|
+
* @developerPreview
|
|
275
|
+
*/
|
|
276
|
+
getDeferBlocks() {
|
|
277
|
+
const deferBlocks = [];
|
|
278
|
+
const lView = this.componentRef.hostView['_lView'];
|
|
279
|
+
ɵgetDeferBlocks(lView, deferBlocks);
|
|
280
|
+
const deferBlockFixtures = [];
|
|
281
|
+
for (const block of deferBlocks) {
|
|
282
|
+
deferBlockFixtures.push(new DeferBlockFixture(block, this));
|
|
283
|
+
}
|
|
284
|
+
return Promise.resolve(deferBlockFixtures);
|
|
285
|
+
}
|
|
193
286
|
_getRenderer() {
|
|
194
287
|
if (this._renderer === undefined) {
|
|
195
288
|
this._renderer = this.componentRef.injector.get(RendererFactory2, null);
|
|
@@ -674,6 +767,7 @@ class TestBedCompiler {
|
|
|
674
767
|
this.providerOverridesByToken = new Map();
|
|
675
768
|
this.scopesWithOverriddenProviders = new Set();
|
|
676
769
|
this.testModuleRef = null;
|
|
770
|
+
this.deferBlockBehavior = ɵDeferBlockBehavior.Manual;
|
|
677
771
|
class DynamicTestModule {
|
|
678
772
|
}
|
|
679
773
|
this.testModuleType = DynamicTestModule;
|
|
@@ -701,6 +795,7 @@ class TestBedCompiler {
|
|
|
701
795
|
if (moduleDef.schemas !== undefined) {
|
|
702
796
|
this.schemas.push(...moduleDef.schemas);
|
|
703
797
|
}
|
|
798
|
+
this.deferBlockBehavior = moduleDef.deferBlockBehavior ?? ɵDeferBlockBehavior.Manual;
|
|
704
799
|
}
|
|
705
800
|
overrideModule(ngModule, override) {
|
|
706
801
|
if (ɵUSE_RUNTIME_DEPS_TRACKER_FOR_JIT) {
|
|
@@ -1289,6 +1384,7 @@ class TestBedCompiler {
|
|
|
1289
1384
|
const providers = [
|
|
1290
1385
|
provideZoneChangeDetection(),
|
|
1291
1386
|
{ provide: Compiler, useFactory: () => new R3TestCompiler(this) },
|
|
1387
|
+
{ provide: ɵDEFER_BLOCK_CONFIG, useValue: { behavior: this.deferBlockBehavior } },
|
|
1292
1388
|
...this.providers,
|
|
1293
1389
|
...this.providerOverrides,
|
|
1294
1390
|
];
|
|
@@ -1498,6 +1594,11 @@ function getTestBed() {
|
|
|
1498
1594
|
*/
|
|
1499
1595
|
class TestBedImpl {
|
|
1500
1596
|
constructor() {
|
|
1597
|
+
/**
|
|
1598
|
+
* Defer block behavior option that specifies whether defer blocks will be triggered manually
|
|
1599
|
+
* or set to play through.
|
|
1600
|
+
*/
|
|
1601
|
+
this._instanceDeferBlockBehavior = ɵDeferBlockBehavior.Manual;
|
|
1501
1602
|
// Properties
|
|
1502
1603
|
this.platform = null;
|
|
1503
1604
|
this.ngModule = null;
|
|
@@ -1689,6 +1790,7 @@ class TestBedImpl {
|
|
|
1689
1790
|
this._instanceTeardownOptions = undefined;
|
|
1690
1791
|
this._instanceErrorOnUnknownElementsOption = undefined;
|
|
1691
1792
|
this._instanceErrorOnUnknownPropertiesOption = undefined;
|
|
1793
|
+
this._instanceDeferBlockBehavior = ɵDeferBlockBehavior.Manual;
|
|
1692
1794
|
}
|
|
1693
1795
|
}
|
|
1694
1796
|
return this;
|
|
@@ -1714,6 +1816,7 @@ class TestBedImpl {
|
|
|
1714
1816
|
this._instanceTeardownOptions = moduleDef.teardown;
|
|
1715
1817
|
this._instanceErrorOnUnknownElementsOption = moduleDef.errorOnUnknownElements;
|
|
1716
1818
|
this._instanceErrorOnUnknownPropertiesOption = moduleDef.errorOnUnknownProperties;
|
|
1819
|
+
this._instanceDeferBlockBehavior = moduleDef.deferBlockBehavior ?? ɵDeferBlockBehavior.Manual;
|
|
1717
1820
|
// Store the current value of the strict mode option,
|
|
1718
1821
|
// so we can restore it later
|
|
1719
1822
|
this._previousErrorOnUnknownElementsOption = ɵgetUnknownElementStrictMode();
|
|
@@ -1899,6 +2002,9 @@ class TestBedImpl {
|
|
|
1899
2002
|
TestBedImpl._environmentTeardownOptions?.destroyAfterEach ??
|
|
1900
2003
|
TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
|
|
1901
2004
|
}
|
|
2005
|
+
getDeferBlockBehavior() {
|
|
2006
|
+
return this._instanceDeferBlockBehavior;
|
|
2007
|
+
}
|
|
1902
2008
|
tearDownTestingModule() {
|
|
1903
2009
|
// If the module ref has already been destroyed, we won't be able to get a test renderer.
|
|
1904
2010
|
if (this._testModuleRef === null) {
|
|
@@ -2059,5 +2165,5 @@ const __core_private_testing_placeholder__ = '';
|
|
|
2059
2165
|
* Generated bundle index. Do not edit.
|
|
2060
2166
|
*/
|
|
2061
2167
|
|
|
2062
|
-
export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, async, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, MetadataOverrider as ɵMetadataOverrider };
|
|
2168
|
+
export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, DeferBlockFixture, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, async, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, MetadataOverrider as ɵMetadataOverrider };
|
|
2063
2169
|
//# sourceMappingURL=testing.mjs.map
|