@angular/core 19.2.4 → 19.2.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/{event_dispatcher.d-pVP0-wST.d.ts → event_dispatcher.d-DlbccpYq.d.ts} +3 -2
- package/fesm2022/core.mjs +103 -88
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/di.mjs +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -1
- package/fesm2022/primitives/signals.mjs +3 -3
- package/fesm2022/rxjs-interop.mjs +4 -3
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +148 -97
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/{untracked-CS7WUAzb.mjs → untracked-BKcld_ew.mjs} +3 -3
- package/fesm2022/{untracked-CS7WUAzb.mjs.map → untracked-BKcld_ew.mjs.map} +1 -1
- package/index.d.ts +23 -7
- package/{navigation_types.d-DgDrF5rp.d.ts → navigation_types.d-fAxd92YV.d.ts} +3 -2
- package/package.json +1 -1
- package/primitives/di/index.d.ts +3 -2
- package/primitives/event-dispatch/index.d.ts +3 -3
- package/primitives/signals/index.d.ts +5 -4
- package/rxjs-interop/index.d.ts +4 -3
- package/schematics/bundles/{apply_import_manager-BynuozbO.js → apply_import_manager-DFADpdFu.js} +3 -3
- package/schematics/bundles/{checker-DP-zos5Q.js → checker-DoX_7XCa.js} +20 -13
- package/schematics/bundles/cleanup-unused-imports.js +42 -64
- package/schematics/bundles/{compiler_host-DzM2hemp.js → compiler_host-BUKEE1cA.js} +2 -2
- package/schematics/bundles/control-flow-migration.js +3 -3
- package/schematics/bundles/explicit-standalone-flag.js +3 -3
- package/schematics/bundles/imports-CIX-JgAN.js +1 -1
- package/schematics/bundles/{program-BmLi-Vxz.js → index-B4b0V0Vo.js} +52 -26
- package/schematics/bundles/{index-CPpyW--c.js → index-CpZKzrqM.js} +6 -6
- package/schematics/bundles/inject-migration.js +25 -8
- package/schematics/bundles/leading_space-D9nQ8UQC.js +1 -1
- package/schematics/bundles/{migrate_ts_type_references-Ri-K4P_1.js → migrate_ts_type_references-DQVDid4G.js} +5 -5
- package/schematics/bundles/ng_decorators-DznZ5jMl.js +1 -1
- package/schematics/bundles/nodes-B16H9JUd.js +1 -1
- package/schematics/bundles/output-migration.js +115 -81
- package/schematics/bundles/pending-tasks.js +3 -3
- package/schematics/bundles/{project_paths-CXXqWSoY.js → project_paths-C3etOlgT.js} +88 -13
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.js +1 -1
- package/schematics/bundles/property_name-BBwFuqMe.js +1 -1
- package/schematics/bundles/provide-initializer.js +3 -3
- package/schematics/bundles/route-lazy-loading.js +3 -3
- package/schematics/bundles/self-closing-tags-migration.js +39 -64
- package/schematics/bundles/signal-input-migration.js +64 -87
- package/schematics/bundles/signal-queries-migration.js +82 -93
- package/schematics/bundles/signals.js +11 -11
- package/schematics/bundles/standalone-migration.js +5 -6
- package/testing/index.d.ts +7 -22
- package/{weak_ref.d-Bp6cSy-X.d.ts → weak_ref.d-DWHPG08n.d.ts} +3 -2
- package/schematics/bundles/index-BPqwMr5d.js +0 -30
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.2.
|
|
2
|
+
* @license Angular v19.2.6
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
export {
|
|
7
|
+
import { consumerMarkDirty, SIGNAL, consumerDestroy, isInNotificationPhase, consumerPollProducersForChange, consumerBeforeComputation, consumerAfterComputation, REACTIVE_NODE } from '../untracked-BKcld_ew.mjs';
|
|
8
|
+
export { SIGNAL_NODE, createComputed, createLinkedSignal, createSignal, defaultEquals, getActiveConsumer, isReactive, linkedSignalSetFn, linkedSignalUpdateFn, producerAccessed, producerIncrementEpoch, producerMarkClean, producerNotifyConsumers, producerUpdateValueVersion, producerUpdatesAllowed, runPostSignalSetFn, setActiveConsumer, setAlternateWeakRefImpl, setPostSignalSetFn, setThrowInvalidWriteToSignalError, signalSetFn, signalUpdateFn, untracked } from '../untracked-BKcld_ew.mjs';
|
|
9
9
|
|
|
10
10
|
function createWatch(fn, schedule, allowSignalWrites) {
|
|
11
11
|
const node = Object.create(WATCH_NODE);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.2.
|
|
2
|
+
* @license Angular v19.2.6
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -189,7 +189,8 @@ function toObservableMicrotask(source, options) {
|
|
|
189
189
|
* @developerPreview
|
|
190
190
|
*/
|
|
191
191
|
function toSignal(source, options) {
|
|
192
|
-
ngDevMode &&
|
|
192
|
+
typeof ngDevMode !== 'undefined' &&
|
|
193
|
+
ngDevMode &&
|
|
193
194
|
assertNotInReactiveContext(toSignal, 'Invoking `toSignal` causes new subscriptions every time. ' +
|
|
194
195
|
'Consider moving `toSignal` outside of the reactive context and read the signal value where needed.');
|
|
195
196
|
const requiresCleanup = !options?.manualCleanup;
|
|
@@ -255,7 +256,7 @@ function makeToSignalEqual(userEquality = Object.is) {
|
|
|
255
256
|
}
|
|
256
257
|
|
|
257
258
|
/**
|
|
258
|
-
* Operator which makes the application unstable until the observable emits,
|
|
259
|
+
* Operator which makes the application unstable until the observable emits, completes, errors, or is unsubscribed.
|
|
259
260
|
*
|
|
260
261
|
* Use this operator in observables whose subscriptions are important for rendering and should be included in SSR serialization.
|
|
261
262
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rxjs-interop.mjs","sources":["../../../../../../packages/core/rxjs-interop/src/take_until_destroyed.ts","../../../../../../packages/core/rxjs-interop/src/output_from_observable.ts","../../../../../../packages/core/rxjs-interop/src/output_to_observable.ts","../../../../../../packages/core/rxjs-interop/src/to_observable.ts","../../../../../../packages/core/rxjs-interop/src/to_signal.ts","../../../../../../packages/core/rxjs-interop/src/pending_until_event.ts","../../../../../../packages/core/rxjs-interop/src/rx_resource.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.dev/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/di/dependency-injection-context). Otherwise, the current `DestroyRef` is injected.\n *\n * @publicApi\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.dev/license\n */\n\nimport {\n assertInInjectionContext,\n DestroyRef,\n inject,\n OutputOptions,\n OutputRef,\n OutputRefSubscription,\n ɵRuntimeError,\n ɵRuntimeErrorCode,\n} from '@angular/core';\nimport {Observable} from 'rxjs';\n\nimport {takeUntilDestroyed} from './take_until_destroyed';\n\n/**\n * Implementation of `OutputRef` that emits values from\n * an RxJS observable source.\n *\n * @internal\n */\nclass OutputFromObservableRef<T> implements OutputRef<T> {\n private destroyed = false;\n\n destroyRef = inject(DestroyRef);\n\n constructor(private source: Observable<T>) {\n this.destroyRef.onDestroy(() => {\n this.destroyed = true;\n });\n }\n\n subscribe(callbackFn: (value: T) => void): OutputRefSubscription {\n if (this.destroyed) {\n throw new ɵRuntimeError(\n ɵRuntimeErrorCode.OUTPUT_REF_DESTROYED,\n ngDevMode &&\n 'Unexpected subscription to destroyed `OutputRef`. ' +\n 'The owning directive/component is destroyed.',\n );\n }\n\n // Stop yielding more values when the directive/component is already destroyed.\n const subscription = this.source.pipe(takeUntilDestroyed(this.destroyRef)).subscribe({\n next: (value) => callbackFn(value),\n });\n\n return {\n unsubscribe: () => subscription.unsubscribe(),\n };\n }\n}\n\n/**\n * Declares an Angular output that is using an RxJS observable as a source\n * for events dispatched to parent subscribers.\n *\n * The behavior for an observable as source is defined as followed:\n * 1. New values are forwarded to the Angular output (next notifications).\n * 2. Errors notifications are not handled by Angular. You need to handle these manually.\n * For example by using `catchError`.\n * 3. Completion notifications stop the output from emitting new values.\n *\n * @usageNotes\n * Initialize an output in your directive by declaring a\n * class field and initializing it with the `outputFromObservable()` function.\n *\n * ```ts\n * @Directive({..})\n * export class MyDir {\n * nameChange$ = <some-observable>;\n * nameChange = outputFromObservable(this.nameChange$);\n * }\n * ```\n *\n * @publicApi\n */\nexport function outputFromObservable<T>(\n observable: Observable<T>,\n opts?: OutputOptions,\n): OutputRef<T> {\n ngDevMode && assertInInjectionContext(outputFromObservable);\n return new OutputFromObservableRef<T>(observable);\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.dev/license\n */\n\nimport {OutputRef, ɵgetOutputDestroyRef} from '@angular/core';\nimport {Observable} from 'rxjs';\n\n/**\n * Converts an Angular output declared via `output()` or `outputFromObservable()`\n * to an observable.\n *\n * You can subscribe to the output via `Observable.subscribe` then.\n *\n * @publicApi\n */\nexport function outputToObservable<T>(ref: OutputRef<T>): Observable<T> {\n const destroyRef = ɵgetOutputDestroyRef(ref);\n\n return new Observable<T>((observer) => {\n // Complete the observable upon directive/component destroy.\n // Note: May be `undefined` if an `EventEmitter` is declared outside\n // of an injection context.\n destroyRef?.onDestroy(() => observer.complete());\n\n const subscription = ref.subscribe((v) => observer.next(v));\n return () => subscription.unsubscribe();\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.dev/license\n */\n\nimport {\n assertInInjectionContext,\n DestroyRef,\n effect,\n inject,\n Injector,\n Signal,\n untracked,\n ɵmicrotaskEffect as microtaskEffect,\n} 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/di/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>(source: Signal<T>, options?: ToObservableOptions): 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 () => {\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 },\n {injector, manualCleanup: true},\n );\n\n injector.get(DestroyRef).onDestroy(() => {\n watcher.destroy();\n subject.complete();\n });\n\n return subject.asObservable();\n}\n\nexport function toObservableMicrotask<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 = microtaskEffect(\n () => {\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 },\n {injector, manualCleanup: true},\n );\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.dev/license\n */\n\nimport {\n assertInInjectionContext,\n assertNotInReactiveContext,\n computed,\n DestroyRef,\n inject,\n Injector,\n signal,\n Signal,\n WritableSignal,\n ɵRuntimeError,\n ɵRuntimeErrorCode,\n} from '@angular/core';\nimport {ValueEqualityFn} from '@angular/core/primitives/signals';\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?: unknown;\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/di/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 * `toSignal`'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 * Whether `toSignal` should throw errors from the Observable error channel back to RxJS, where\n * they'll be processed as uncaught exceptions.\n *\n * In practice, this means that the signal returned by `toSignal` will keep returning the last\n * good value forever, as Observables which error produce no further values. This option emulates\n * the behavior of the `async` pipe.\n */\n rejectErrors?: boolean;\n\n /**\n * A comparison function which defines equality for values emitted by the observable.\n *\n * Equality comparisons are executed against the initial value if one is provided.\n */\n equal?: ValueEqualityFn<T>;\n}\n\n// Base case: no options -> `undefined` in the result type.\nexport function toSignal<T>(source: Observable<T> | Subscribable<T>): Signal<T | undefined>;\n// Options with `undefined` initial value and no `requiredSync` -> `undefined`.\nexport function toSignal<T>(\n source: Observable<T> | Subscribable<T>,\n options: NoInfer<ToSignalOptions<T | undefined>> & {\n initialValue?: undefined;\n requireSync?: false;\n },\n): Signal<T | undefined>;\n// Options with `null` initial value -> `null`.\nexport function toSignal<T>(\n source: Observable<T> | Subscribable<T>,\n options: NoInfer<ToSignalOptions<T | null>> & {initialValue?: null; requireSync?: false},\n): Signal<T | null>;\n// Options with `undefined` initial value and `requiredSync` -> strict result type.\nexport function toSignal<T>(\n source: Observable<T> | Subscribable<T>,\n options: NoInfer<ToSignalOptions<T>> & {initialValue?: undefined; requireSync: true},\n): Signal<T>;\n// Options with a more specific initial value type.\nexport function toSignal<T, const U extends T>(\n source: Observable<T> | Subscribable<T>,\n options: NoInfer<ToSignalOptions<T | U>> & {initialValue: U; requireSync?: false},\n): 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/di/dependency-injection-context) is destroyed. For example, when `toSignal` 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, U = undefined>(\n source: Observable<T> | Subscribable<T>,\n options?: ToSignalOptions<T | U> & {initialValue?: U},\n): Signal<T | U> {\n ngDevMode &&\n assertNotInReactiveContext(\n toSignal,\n 'Invoking `toSignal` causes new subscriptions every time. ' +\n 'Consider moving `toSignal` outside of the reactive context and read the signal value where needed.',\n );\n\n const requiresCleanup = !options?.manualCleanup;\n requiresCleanup && !options?.injector && assertInInjectionContext(toSignal);\n const cleanupRef = requiresCleanup\n ? (options?.injector?.get(DestroyRef) ?? inject(DestroyRef))\n : null;\n\n const equal = makeToSignalEqual(options?.equal);\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}, {equal});\n } else {\n // If an initial value was passed, use it. Otherwise, use `undefined` as the initial value.\n state = signal<State<T | U>>(\n {kind: StateKind.Value, value: options?.initialValue as U},\n {equal},\n );\n }\n\n // Note: This code cannot run inside a reactive context (see assertion above). If we'd support\n // this, we would subscribe to the observable outside of the current reactive context, avoiding\n // that side-effect signal reads/writes are attribute to the current consumer. The current\n // consumer only needs to be notified when the `state` signal changes through the observable\n // subscription. Additional context (related to async pipe):\n // https://github.com/angular/angular/pull/50522.\n const sub = source.subscribe({\n next: (value) => state.set({kind: StateKind.Value, value}),\n error: (error) => {\n if (options?.rejectErrors) {\n // Kick the error back to RxJS. It will be caught and rethrown in a macrotask, which causes\n // the error to end up as an uncaught exception.\n throw error;\n }\n state.set({kind: StateKind.Error, error});\n },\n // Completion of the Observable is meaningless to the signal. Signals don't have a concept of\n // \"complete\".\n });\n\n if (options?.requireSync && state().kind === StateKind.NoValue) {\n throw new ɵRuntimeError(\n ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\n '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.',\n );\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 () => {\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 throw new ɵRuntimeError(\n ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\n '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.',\n );\n }\n },\n {equal: options?.equal},\n );\n}\n\nfunction makeToSignalEqual<T>(\n userEquality: ValueEqualityFn<T> = Object.is,\n): ValueEqualityFn<State<T>> {\n return (a, b) =>\n a.kind === StateKind.Value && b.kind === StateKind.Value && userEquality(a.value, b.value);\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.dev/license\n */\n\nimport {assertInInjectionContext, PendingTasks, inject, Injector} from '@angular/core';\nimport {MonoTypeOperatorFunction, Observable} from 'rxjs';\n\n/**\n * Operator which makes the application unstable until the observable emits, complets, errors, or is unsubscribed.\n *\n * Use this operator in observables whose subscriptions are important for rendering and should be included in SSR serialization.\n *\n * @param injector The `Injector` to use during creation. If this is not provided, the current injection context will be used instead (via `inject`).\n *\n * @experimental\n */\nexport function pendingUntilEvent<T>(injector?: Injector): MonoTypeOperatorFunction<T> {\n if (injector === undefined) {\n assertInInjectionContext(pendingUntilEvent);\n injector = inject(Injector);\n }\n const taskService = injector.get(PendingTasks);\n\n return (sourceObservable) => {\n return new Observable<T>((originalSubscriber) => {\n // create a new task on subscription\n const removeTask = taskService.add();\n\n let cleanedUp = false;\n function cleanupTask() {\n if (cleanedUp) {\n return;\n }\n\n removeTask();\n cleanedUp = true;\n }\n\n const innerSubscription = sourceObservable.subscribe({\n next: (v) => {\n originalSubscriber.next(v);\n cleanupTask();\n },\n complete: () => {\n originalSubscriber.complete();\n cleanupTask();\n },\n error: (e) => {\n originalSubscriber.error(e);\n cleanupTask();\n },\n });\n innerSubscription.add(() => {\n originalSubscriber.unsubscribe();\n cleanupTask();\n });\n return innerSubscription;\n });\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.dev/license\n */\n\nimport {\n assertInInjectionContext,\n resource,\n ResourceLoaderParams,\n ResourceRef,\n Signal,\n signal,\n BaseResourceOptions,\n} from '@angular/core';\nimport {Observable, Subscription} from 'rxjs';\n\n/**\n * Like `ResourceOptions` but uses an RxJS-based `loader`.\n *\n * @experimental\n */\nexport interface RxResourceOptions<T, R> extends BaseResourceOptions<T, R> {\n loader: (params: ResourceLoaderParams<R>) => Observable<T>;\n}\n\n/**\n * Like `resource` but uses an RxJS based `loader` which maps the request to an `Observable` of the\n * resource's value.\n *\n * @experimental\n */\nexport function rxResource<T, R>(\n opts: RxResourceOptions<T, R> & {defaultValue: NoInfer<T>},\n): ResourceRef<T>;\n\n/**\n * Like `resource` but uses an RxJS based `loader` which maps the request to an `Observable` of the\n * resource's value.\n *\n * @experimental\n */\nexport function rxResource<T, R>(opts: RxResourceOptions<T, R>): ResourceRef<T | undefined>;\nexport function rxResource<T, R>(opts: RxResourceOptions<T, R>): ResourceRef<T | undefined> {\n opts?.injector || assertInInjectionContext(rxResource);\n return resource<T, R>({\n ...opts,\n loader: undefined,\n stream: (params) => {\n let sub: Subscription;\n\n // Track the abort listener so it can be removed if the Observable completes (as a memory\n // optimization).\n const onAbort = () => sub.unsubscribe();\n params.abortSignal.addEventListener('abort', onAbort);\n\n // Start off stream as undefined.\n const stream = signal<{value: T} | {error: unknown}>({value: undefined as T});\n let resolve: ((value: Signal<{value: T} | {error: unknown}>) => void) | undefined;\n const promise = new Promise<Signal<{value: T} | {error: unknown}>>((r) => (resolve = r));\n\n function send(value: {value: T} | {error: unknown}): void {\n stream.set(value);\n resolve?.(stream);\n resolve = undefined;\n }\n\n sub = opts.loader(params).subscribe({\n next: (value) => send({value}),\n error: (error) => send({error}),\n complete: () => {\n if (resolve) {\n send({error: new Error('Resource completed before producing a value')});\n }\n params.abortSignal.removeEventListener('abort', onAbort);\n },\n });\n\n return promise;\n },\n });\n}\n"],"names":["ɵRuntimeError","ɵgetOutputDestroyRef","microtaskEffect"],"mappings":";;;;;;;;;;AAYA;;;;;;;;;AASG;AACG,SAAU,kBAAkB,CAAI,UAAuB,EAAA;IAC3D,IAAI,CAAC,UAAU,EAAE;QACf,wBAAwB,CAAC,kBAAkB,CAAC;AAC5C,QAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;;IAGjC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAO,CAAC,QAAQ,KAAI;AACnD,QAAA,MAAM,YAAY,GAAG,UAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxE,QAAA,OAAO,YAAY;AACrB,KAAC,CAAC;IAEF,OAAO,CAAI,MAAqB,KAAI;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAC3C,KAAC;AACH;;ACdA;;;;;AAKG;AACH,MAAM,uBAAuB,CAAA;AAKP,IAAA,MAAA;IAJZ,SAAS,GAAG,KAAK;AAEzB,IAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAE/B,IAAA,WAAA,CAAoB,MAAqB,EAAA;QAArB,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,KAAA,CAAC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"rxjs-interop.mjs","sources":["../../../../../../packages/core/rxjs-interop/src/take_until_destroyed.ts","../../../../../../packages/core/rxjs-interop/src/output_from_observable.ts","../../../../../../packages/core/rxjs-interop/src/output_to_observable.ts","../../../../../../packages/core/rxjs-interop/src/to_observable.ts","../../../../../../packages/core/rxjs-interop/src/to_signal.ts","../../../../../../packages/core/rxjs-interop/src/pending_until_event.ts","../../../../../../packages/core/rxjs-interop/src/rx_resource.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.dev/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/di/dependency-injection-context). Otherwise, the current `DestroyRef` is injected.\n *\n * @publicApi\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.dev/license\n */\n\nimport {\n assertInInjectionContext,\n DestroyRef,\n inject,\n OutputOptions,\n OutputRef,\n OutputRefSubscription,\n ɵRuntimeError,\n ɵRuntimeErrorCode,\n} from '@angular/core';\nimport {Observable} from 'rxjs';\n\nimport {takeUntilDestroyed} from './take_until_destroyed';\n\n/**\n * Implementation of `OutputRef` that emits values from\n * an RxJS observable source.\n *\n * @internal\n */\nclass OutputFromObservableRef<T> implements OutputRef<T> {\n private destroyed = false;\n\n destroyRef = inject(DestroyRef);\n\n constructor(private source: Observable<T>) {\n this.destroyRef.onDestroy(() => {\n this.destroyed = true;\n });\n }\n\n subscribe(callbackFn: (value: T) => void): OutputRefSubscription {\n if (this.destroyed) {\n throw new ɵRuntimeError(\n ɵRuntimeErrorCode.OUTPUT_REF_DESTROYED,\n ngDevMode &&\n 'Unexpected subscription to destroyed `OutputRef`. ' +\n 'The owning directive/component is destroyed.',\n );\n }\n\n // Stop yielding more values when the directive/component is already destroyed.\n const subscription = this.source.pipe(takeUntilDestroyed(this.destroyRef)).subscribe({\n next: (value) => callbackFn(value),\n });\n\n return {\n unsubscribe: () => subscription.unsubscribe(),\n };\n }\n}\n\n/**\n * Declares an Angular output that is using an RxJS observable as a source\n * for events dispatched to parent subscribers.\n *\n * The behavior for an observable as source is defined as followed:\n * 1. New values are forwarded to the Angular output (next notifications).\n * 2. Errors notifications are not handled by Angular. You need to handle these manually.\n * For example by using `catchError`.\n * 3. Completion notifications stop the output from emitting new values.\n *\n * @usageNotes\n * Initialize an output in your directive by declaring a\n * class field and initializing it with the `outputFromObservable()` function.\n *\n * ```ts\n * @Directive({..})\n * export class MyDir {\n * nameChange$ = <some-observable>;\n * nameChange = outputFromObservable(this.nameChange$);\n * }\n * ```\n *\n * @publicApi\n */\nexport function outputFromObservable<T>(\n observable: Observable<T>,\n opts?: OutputOptions,\n): OutputRef<T> {\n ngDevMode && assertInInjectionContext(outputFromObservable);\n return new OutputFromObservableRef<T>(observable);\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.dev/license\n */\n\nimport {OutputRef, ɵgetOutputDestroyRef} from '@angular/core';\nimport {Observable} from 'rxjs';\n\n/**\n * Converts an Angular output declared via `output()` or `outputFromObservable()`\n * to an observable.\n *\n * You can subscribe to the output via `Observable.subscribe` then.\n *\n * @publicApi\n */\nexport function outputToObservable<T>(ref: OutputRef<T>): Observable<T> {\n const destroyRef = ɵgetOutputDestroyRef(ref);\n\n return new Observable<T>((observer) => {\n // Complete the observable upon directive/component destroy.\n // Note: May be `undefined` if an `EventEmitter` is declared outside\n // of an injection context.\n destroyRef?.onDestroy(() => observer.complete());\n\n const subscription = ref.subscribe((v) => observer.next(v));\n return () => subscription.unsubscribe();\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.dev/license\n */\n\nimport {\n assertInInjectionContext,\n DestroyRef,\n effect,\n inject,\n Injector,\n Signal,\n untracked,\n ɵmicrotaskEffect as microtaskEffect,\n} 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/di/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>(source: Signal<T>, options?: ToObservableOptions): 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 () => {\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 },\n {injector, manualCleanup: true},\n );\n\n injector.get(DestroyRef).onDestroy(() => {\n watcher.destroy();\n subject.complete();\n });\n\n return subject.asObservable();\n}\n\nexport function toObservableMicrotask<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 = microtaskEffect(\n () => {\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 },\n {injector, manualCleanup: true},\n );\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.dev/license\n */\n\nimport {\n assertInInjectionContext,\n assertNotInReactiveContext,\n computed,\n DestroyRef,\n inject,\n Injector,\n signal,\n Signal,\n WritableSignal,\n ɵRuntimeError,\n ɵRuntimeErrorCode,\n} from '@angular/core';\nimport {ValueEqualityFn} from '@angular/core/primitives/signals';\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?: unknown;\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/di/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 * `toSignal`'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 * Whether `toSignal` should throw errors from the Observable error channel back to RxJS, where\n * they'll be processed as uncaught exceptions.\n *\n * In practice, this means that the signal returned by `toSignal` will keep returning the last\n * good value forever, as Observables which error produce no further values. This option emulates\n * the behavior of the `async` pipe.\n */\n rejectErrors?: boolean;\n\n /**\n * A comparison function which defines equality for values emitted by the observable.\n *\n * Equality comparisons are executed against the initial value if one is provided.\n */\n equal?: ValueEqualityFn<T>;\n}\n\n// Base case: no options -> `undefined` in the result type.\nexport function toSignal<T>(source: Observable<T> | Subscribable<T>): Signal<T | undefined>;\n// Options with `undefined` initial value and no `requiredSync` -> `undefined`.\nexport function toSignal<T>(\n source: Observable<T> | Subscribable<T>,\n options: NoInfer<ToSignalOptions<T | undefined>> & {\n initialValue?: undefined;\n requireSync?: false;\n },\n): Signal<T | undefined>;\n// Options with `null` initial value -> `null`.\nexport function toSignal<T>(\n source: Observable<T> | Subscribable<T>,\n options: NoInfer<ToSignalOptions<T | null>> & {initialValue?: null; requireSync?: false},\n): Signal<T | null>;\n// Options with `undefined` initial value and `requiredSync` -> strict result type.\nexport function toSignal<T>(\n source: Observable<T> | Subscribable<T>,\n options: NoInfer<ToSignalOptions<T>> & {initialValue?: undefined; requireSync: true},\n): Signal<T>;\n// Options with a more specific initial value type.\nexport function toSignal<T, const U extends T>(\n source: Observable<T> | Subscribable<T>,\n options: NoInfer<ToSignalOptions<T | U>> & {initialValue: U; requireSync?: false},\n): 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/di/dependency-injection-context) is destroyed. For example, when `toSignal` 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, U = undefined>(\n source: Observable<T> | Subscribable<T>,\n options?: ToSignalOptions<T | U> & {initialValue?: U},\n): Signal<T | U> {\n typeof ngDevMode !== 'undefined' &&\n ngDevMode &&\n assertNotInReactiveContext(\n toSignal,\n 'Invoking `toSignal` causes new subscriptions every time. ' +\n 'Consider moving `toSignal` outside of the reactive context and read the signal value where needed.',\n );\n\n const requiresCleanup = !options?.manualCleanup;\n requiresCleanup && !options?.injector && assertInInjectionContext(toSignal);\n const cleanupRef = requiresCleanup\n ? (options?.injector?.get(DestroyRef) ?? inject(DestroyRef))\n : null;\n\n const equal = makeToSignalEqual(options?.equal);\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}, {equal});\n } else {\n // If an initial value was passed, use it. Otherwise, use `undefined` as the initial value.\n state = signal<State<T | U>>(\n {kind: StateKind.Value, value: options?.initialValue as U},\n {equal},\n );\n }\n\n // Note: This code cannot run inside a reactive context (see assertion above). If we'd support\n // this, we would subscribe to the observable outside of the current reactive context, avoiding\n // that side-effect signal reads/writes are attribute to the current consumer. The current\n // consumer only needs to be notified when the `state` signal changes through the observable\n // subscription. Additional context (related to async pipe):\n // https://github.com/angular/angular/pull/50522.\n const sub = source.subscribe({\n next: (value) => state.set({kind: StateKind.Value, value}),\n error: (error) => {\n if (options?.rejectErrors) {\n // Kick the error back to RxJS. It will be caught and rethrown in a macrotask, which causes\n // the error to end up as an uncaught exception.\n throw error;\n }\n state.set({kind: StateKind.Error, error});\n },\n // Completion of the Observable is meaningless to the signal. Signals don't have a concept of\n // \"complete\".\n });\n\n if (options?.requireSync && state().kind === StateKind.NoValue) {\n throw new ɵRuntimeError(\n ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\n '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.',\n );\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 () => {\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 throw new ɵRuntimeError(\n ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT,\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\n '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.',\n );\n }\n },\n {equal: options?.equal},\n );\n}\n\nfunction makeToSignalEqual<T>(\n userEquality: ValueEqualityFn<T> = Object.is,\n): ValueEqualityFn<State<T>> {\n return (a, b) =>\n a.kind === StateKind.Value && b.kind === StateKind.Value && userEquality(a.value, b.value);\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.dev/license\n */\n\nimport {assertInInjectionContext, PendingTasks, inject, Injector} from '@angular/core';\nimport {MonoTypeOperatorFunction, Observable} from 'rxjs';\n\n/**\n * Operator which makes the application unstable until the observable emits, completes, errors, or is unsubscribed.\n *\n * Use this operator in observables whose subscriptions are important for rendering and should be included in SSR serialization.\n *\n * @param injector The `Injector` to use during creation. If this is not provided, the current injection context will be used instead (via `inject`).\n *\n * @experimental\n */\nexport function pendingUntilEvent<T>(injector?: Injector): MonoTypeOperatorFunction<T> {\n if (injector === undefined) {\n assertInInjectionContext(pendingUntilEvent);\n injector = inject(Injector);\n }\n const taskService = injector.get(PendingTasks);\n\n return (sourceObservable) => {\n return new Observable<T>((originalSubscriber) => {\n // create a new task on subscription\n const removeTask = taskService.add();\n\n let cleanedUp = false;\n function cleanupTask() {\n if (cleanedUp) {\n return;\n }\n\n removeTask();\n cleanedUp = true;\n }\n\n const innerSubscription = sourceObservable.subscribe({\n next: (v) => {\n originalSubscriber.next(v);\n cleanupTask();\n },\n complete: () => {\n originalSubscriber.complete();\n cleanupTask();\n },\n error: (e) => {\n originalSubscriber.error(e);\n cleanupTask();\n },\n });\n innerSubscription.add(() => {\n originalSubscriber.unsubscribe();\n cleanupTask();\n });\n return innerSubscription;\n });\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.dev/license\n */\n\nimport {\n assertInInjectionContext,\n resource,\n ResourceLoaderParams,\n ResourceRef,\n Signal,\n signal,\n BaseResourceOptions,\n} from '@angular/core';\nimport {Observable, Subscription} from 'rxjs';\n\n/**\n * Like `ResourceOptions` but uses an RxJS-based `loader`.\n *\n * @experimental\n */\nexport interface RxResourceOptions<T, R> extends BaseResourceOptions<T, R> {\n loader: (params: ResourceLoaderParams<R>) => Observable<T>;\n}\n\n/**\n * Like `resource` but uses an RxJS based `loader` which maps the request to an `Observable` of the\n * resource's value.\n *\n * @experimental\n */\nexport function rxResource<T, R>(\n opts: RxResourceOptions<T, R> & {defaultValue: NoInfer<T>},\n): ResourceRef<T>;\n\n/**\n * Like `resource` but uses an RxJS based `loader` which maps the request to an `Observable` of the\n * resource's value.\n *\n * @experimental\n */\nexport function rxResource<T, R>(opts: RxResourceOptions<T, R>): ResourceRef<T | undefined>;\nexport function rxResource<T, R>(opts: RxResourceOptions<T, R>): ResourceRef<T | undefined> {\n opts?.injector || assertInInjectionContext(rxResource);\n return resource<T, R>({\n ...opts,\n loader: undefined,\n stream: (params) => {\n let sub: Subscription;\n\n // Track the abort listener so it can be removed if the Observable completes (as a memory\n // optimization).\n const onAbort = () => sub.unsubscribe();\n params.abortSignal.addEventListener('abort', onAbort);\n\n // Start off stream as undefined.\n const stream = signal<{value: T} | {error: unknown}>({value: undefined as T});\n let resolve: ((value: Signal<{value: T} | {error: unknown}>) => void) | undefined;\n const promise = new Promise<Signal<{value: T} | {error: unknown}>>((r) => (resolve = r));\n\n function send(value: {value: T} | {error: unknown}): void {\n stream.set(value);\n resolve?.(stream);\n resolve = undefined;\n }\n\n sub = opts.loader(params).subscribe({\n next: (value) => send({value}),\n error: (error) => send({error}),\n complete: () => {\n if (resolve) {\n send({error: new Error('Resource completed before producing a value')});\n }\n params.abortSignal.removeEventListener('abort', onAbort);\n },\n });\n\n return promise;\n },\n });\n}\n"],"names":["ɵRuntimeError","ɵgetOutputDestroyRef","microtaskEffect"],"mappings":";;;;;;;;;;AAYA;;;;;;;;;AASG;AACG,SAAU,kBAAkB,CAAI,UAAuB,EAAA;IAC3D,IAAI,CAAC,UAAU,EAAE;QACf,wBAAwB,CAAC,kBAAkB,CAAC;AAC5C,QAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;;IAGjC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAO,CAAC,QAAQ,KAAI;AACnD,QAAA,MAAM,YAAY,GAAG,UAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxE,QAAA,OAAO,YAAY;AACrB,KAAC,CAAC;IAEF,OAAO,CAAI,MAAqB,KAAI;QAClC,OAAO,MAA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C,KAAK,EAAC,CAAC;gBAC/B,QAAQ,EAAE,MAAK;oBACb,IAAI,OAAO,EAAE;wBACX,IAAI,CAAC,EAAC,KAAK,EAAE,IAAI,KAAK,CAAC,6CAA6C,CAAC,EAAC,CAAC;;oBAEzE,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC;iBACzD;AACF,aAAA,CAAC;AAEF,YAAA,OAAO,OAAO;SACf;AACF,KAAA,CAAC;AACJ;;;;"}
|
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.2.
|
|
2
|
+
* @license Angular v19.2.6
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -2431,7 +2431,7 @@ class FakeNavigation {
|
|
|
2431
2431
|
historyState: null,
|
|
2432
2432
|
});
|
|
2433
2433
|
const result = new InternalNavigationResult(this);
|
|
2434
|
-
this.userAgentNavigate(destination, result, {
|
|
2434
|
+
const intercepted = this.userAgentNavigate(destination, result, {
|
|
2435
2435
|
navigationType,
|
|
2436
2436
|
cancelable: true,
|
|
2437
2437
|
canIntercept: true,
|
|
@@ -2440,6 +2440,9 @@ class FakeNavigation {
|
|
|
2440
2440
|
hashChange,
|
|
2441
2441
|
info: options?.info,
|
|
2442
2442
|
});
|
|
2443
|
+
if (!intercepted) {
|
|
2444
|
+
this.updateNavigationEntriesForSameDocumentNavigation(this.navigateEvent);
|
|
2445
|
+
}
|
|
2443
2446
|
return {
|
|
2444
2447
|
committed: result.committed,
|
|
2445
2448
|
finished: result.finished,
|
|
@@ -2463,7 +2466,7 @@ class FakeNavigation {
|
|
|
2463
2466
|
historyState: data,
|
|
2464
2467
|
});
|
|
2465
2468
|
const result = new InternalNavigationResult(this);
|
|
2466
|
-
this.userAgentNavigate(destination, result, {
|
|
2469
|
+
const intercepted = this.userAgentNavigate(destination, result, {
|
|
2467
2470
|
navigationType,
|
|
2468
2471
|
cancelable: true,
|
|
2469
2472
|
canIntercept: true,
|
|
@@ -2471,6 +2474,10 @@ class FakeNavigation {
|
|
|
2471
2474
|
userInitiated: false,
|
|
2472
2475
|
hashChange,
|
|
2473
2476
|
});
|
|
2477
|
+
if (intercepted) {
|
|
2478
|
+
return;
|
|
2479
|
+
}
|
|
2480
|
+
this.updateNavigationEntriesForSameDocumentNavigation(this.navigateEvent);
|
|
2474
2481
|
}
|
|
2475
2482
|
/** Equivalent to `navigation.traverseTo()`. */
|
|
2476
2483
|
traverseTo(key, options) {
|
|
@@ -2515,7 +2522,7 @@ class FakeNavigation {
|
|
|
2515
2522
|
this.traversalQueue.set(entry.key, result);
|
|
2516
2523
|
this.runTraversal(() => {
|
|
2517
2524
|
this.traversalQueue.delete(entry.key);
|
|
2518
|
-
const
|
|
2525
|
+
const intercepted = this.userAgentNavigate(destination, result, {
|
|
2519
2526
|
navigationType: 'traverse',
|
|
2520
2527
|
cancelable: true,
|
|
2521
2528
|
canIntercept: true,
|
|
@@ -2524,8 +2531,9 @@ class FakeNavigation {
|
|
|
2524
2531
|
hashChange,
|
|
2525
2532
|
info: options?.info,
|
|
2526
2533
|
});
|
|
2527
|
-
|
|
2528
|
-
|
|
2534
|
+
if (!intercepted) {
|
|
2535
|
+
this.userAgentTraverse(this.navigateEvent);
|
|
2536
|
+
}
|
|
2529
2537
|
});
|
|
2530
2538
|
return {
|
|
2531
2539
|
committed: result.committed,
|
|
@@ -2595,7 +2603,7 @@ class FakeNavigation {
|
|
|
2595
2603
|
sameDocument: entry.sameDocument,
|
|
2596
2604
|
});
|
|
2597
2605
|
const result = new InternalNavigationResult(this);
|
|
2598
|
-
const
|
|
2606
|
+
const intercepted = this.userAgentNavigate(destination, result, {
|
|
2599
2607
|
navigationType: 'traverse',
|
|
2600
2608
|
cancelable: true,
|
|
2601
2609
|
canIntercept: true,
|
|
@@ -2603,8 +2611,9 @@ class FakeNavigation {
|
|
|
2603
2611
|
userInitiated: false,
|
|
2604
2612
|
hashChange,
|
|
2605
2613
|
});
|
|
2606
|
-
|
|
2607
|
-
|
|
2614
|
+
if (!intercepted) {
|
|
2615
|
+
this.userAgentTraverse(this.navigateEvent);
|
|
2616
|
+
}
|
|
2608
2617
|
});
|
|
2609
2618
|
}
|
|
2610
2619
|
/** Runs a traversal synchronously or asynchronously */
|
|
@@ -2648,7 +2657,10 @@ class FakeNavigation {
|
|
|
2648
2657
|
isDisposed() {
|
|
2649
2658
|
return this.disposed;
|
|
2650
2659
|
}
|
|
2651
|
-
/**
|
|
2660
|
+
/**
|
|
2661
|
+
* Implementation for all navigations and traversals.
|
|
2662
|
+
* @returns true if the event was intercepted, otherwise false
|
|
2663
|
+
*/
|
|
2652
2664
|
userAgentNavigate(destination, result, options) {
|
|
2653
2665
|
// The first navigation should disallow any future calls to set the initial
|
|
2654
2666
|
// entry.
|
|
@@ -2670,35 +2682,11 @@ class FakeNavigation {
|
|
|
2670
2682
|
result,
|
|
2671
2683
|
});
|
|
2672
2684
|
}
|
|
2673
|
-
/**
|
|
2674
|
-
* Implementation to commit a navigation.
|
|
2675
|
-
* https://whatpr.org/html/10919/nav-history-apis.html#navigateevent-commit
|
|
2676
|
-
* @internal
|
|
2677
|
-
*/
|
|
2678
|
-
commitNavigateEvent(navigateEvent) {
|
|
2679
|
-
navigateEvent.interceptionState = 'committed';
|
|
2680
|
-
const from = this.currentEntry;
|
|
2681
|
-
if (!from) {
|
|
2682
|
-
throw new Error('cannot commit navigation when current entry is null');
|
|
2683
|
-
}
|
|
2684
|
-
if (!navigateEvent.sameDocument) {
|
|
2685
|
-
const error = new Error('Cannot navigate to a non-same-document URL.');
|
|
2686
|
-
navigateEvent.cancel(error);
|
|
2687
|
-
throw error;
|
|
2688
|
-
}
|
|
2689
|
-
// "If navigationType is "push" or "replace", then run the URL and history update steps given document and event's destination's URL, with serialiedData set to event's classic history API state and historyHandling set to navigationType."
|
|
2690
|
-
if (navigateEvent.navigationType === 'push' || navigateEvent.navigationType === 'replace') {
|
|
2691
|
-
this.urlAndHistoryUpdateSteps(navigateEvent);
|
|
2692
|
-
}
|
|
2693
|
-
else if (navigateEvent.navigationType === 'reload') {
|
|
2694
|
-
this.updateNavigationEntriesForSameDocumentNavigation(navigateEvent);
|
|
2695
|
-
}
|
|
2696
|
-
else ;
|
|
2697
|
-
}
|
|
2698
2685
|
/**
|
|
2699
2686
|
* Implementation for a push or replace navigation.
|
|
2700
2687
|
* https://whatpr.org/html/10919/browsing-the-web.html#url-and-history-update-steps
|
|
2701
2688
|
* https://whatpr.org/html/10919/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation
|
|
2689
|
+
* @internal
|
|
2702
2690
|
*/
|
|
2703
2691
|
urlAndHistoryUpdateSteps(navigateEvent) {
|
|
2704
2692
|
this.updateNavigationEntriesForSameDocumentNavigation(navigateEvent);
|
|
@@ -2712,17 +2700,25 @@ class FakeNavigation {
|
|
|
2712
2700
|
* > If targetEntry's document is equal to displayedDocument, then perform updateDocument.
|
|
2713
2701
|
* https://whatpr.org/html/10919/browsing-the-web.html#update-document-for-history-step-application
|
|
2714
2702
|
* which then goes to https://whatpr.org/html/10919/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation
|
|
2703
|
+
* @internal
|
|
2715
2704
|
*/
|
|
2716
2705
|
userAgentTraverse(navigateEvent) {
|
|
2706
|
+
const oldUrl = this.currentEntry.url;
|
|
2717
2707
|
this.updateNavigationEntriesForSameDocumentNavigation(navigateEvent);
|
|
2718
2708
|
// Happens as part of "updating the document" steps https://whatpr.org/html/10919/browsing-the-web.html#updating-the-document
|
|
2719
2709
|
const popStateEvent = createPopStateEvent({
|
|
2720
2710
|
state: navigateEvent.destination.getHistoryState(),
|
|
2721
2711
|
});
|
|
2722
2712
|
this.window.dispatchEvent(popStateEvent);
|
|
2723
|
-
|
|
2713
|
+
if (navigateEvent.hashChange) {
|
|
2714
|
+
const hashchangeEvent = createHashChangeEvent(oldUrl, this.currentEntry.url);
|
|
2715
|
+
this.window.dispatchEvent(hashchangeEvent);
|
|
2716
|
+
}
|
|
2724
2717
|
}
|
|
2725
|
-
/**
|
|
2718
|
+
/**
|
|
2719
|
+
* https://whatpr.org/html/10919/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation
|
|
2720
|
+
* @internal
|
|
2721
|
+
*/
|
|
2726
2722
|
updateNavigationEntriesForSameDocumentNavigation({ destination, navigationType, result, }) {
|
|
2727
2723
|
const oldCurrentNHE = this.currentEntry;
|
|
2728
2724
|
const disposedNHEs = [];
|
|
@@ -2893,24 +2889,35 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
|
|
|
2893
2889
|
event.formData = null;
|
|
2894
2890
|
event.result = result;
|
|
2895
2891
|
event.sameDocument = sameDocument;
|
|
2896
|
-
|
|
2897
|
-
let
|
|
2898
|
-
|
|
2892
|
+
let precommitHandlers = [];
|
|
2893
|
+
let handlers = [];
|
|
2894
|
+
// https://whatpr.org/html/10919/nav-history-apis.html#dom-navigateevent-intercept
|
|
2899
2895
|
event.intercept = function (options) {
|
|
2900
2896
|
if (!this.canIntercept) {
|
|
2901
2897
|
throw new DOMException(`Cannot intercept when canIntercept is 'false'`, 'SecurityError');
|
|
2902
2898
|
}
|
|
2903
2899
|
this.interceptionState = 'intercepted';
|
|
2904
2900
|
event.sameDocument = true;
|
|
2901
|
+
const precommitHandler = options?.precommitHandler;
|
|
2902
|
+
if (precommitHandler) {
|
|
2903
|
+
if (!this.cancelable) {
|
|
2904
|
+
throw new DOMException(`Cannot use precommitHandler when cancelable is 'false'`, 'InvalidStateError');
|
|
2905
|
+
}
|
|
2906
|
+
precommitHandlers.push(precommitHandler);
|
|
2907
|
+
}
|
|
2908
|
+
if (event.interceptionState !== 'none' && event.interceptionState !== 'intercepted') {
|
|
2909
|
+
throw new Error('Event interceptionState should be "none" or "intercepted"');
|
|
2910
|
+
}
|
|
2911
|
+
event.interceptionState = 'intercepted';
|
|
2905
2912
|
const handler = options?.handler;
|
|
2906
2913
|
if (handler) {
|
|
2907
|
-
|
|
2914
|
+
handlers.push(handler);
|
|
2908
2915
|
}
|
|
2909
2916
|
// override old options with new ones. UA _may_ report a console warning if new options differ from previous
|
|
2910
|
-
event.commitOption = options?.commit ?? event.commitOption;
|
|
2911
|
-
event.scrollBehavior = options?.scroll ?? event.scrollBehavior;
|
|
2912
2917
|
event.focusResetBehavior = options?.focusReset ?? event.focusResetBehavior;
|
|
2918
|
+
event.scrollBehavior = options?.scroll ?? event.scrollBehavior;
|
|
2913
2919
|
};
|
|
2920
|
+
// https://whatpr.org/html/10919/nav-history-apis.html#dom-navigateevent-scroll
|
|
2914
2921
|
event.scroll = function () {
|
|
2915
2922
|
if (event.interceptionState !== 'committed') {
|
|
2916
2923
|
throw new DOMException(`Failed to execute 'scroll' on 'NavigateEvent': scroll() must be ` +
|
|
@@ -2918,43 +2925,54 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
|
|
|
2918
2925
|
}
|
|
2919
2926
|
processScrollBehavior(event);
|
|
2920
2927
|
};
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2928
|
+
// https://whatpr.org/html/10919/nav-history-apis.html#dom-navigationprecommitcontroller-redirect
|
|
2929
|
+
function redirect(url) {
|
|
2930
|
+
if (event.interceptionState === 'none') {
|
|
2931
|
+
throw new Error('cannot redirect when event is not intercepted');
|
|
2925
2932
|
}
|
|
2926
|
-
if (
|
|
2927
|
-
throw new DOMException(`
|
|
2928
|
-
`called if commit behavior is not "after-transition",.`, 'InvalidStateError');
|
|
2933
|
+
if (event.interceptionState !== 'intercepted') {
|
|
2934
|
+
throw new DOMException(`cannot redirect when event is not in 'intercepted' state`, 'InvalidStateError');
|
|
2929
2935
|
}
|
|
2930
|
-
if (
|
|
2931
|
-
throw new DOMException(`
|
|
2932
|
-
|
|
2936
|
+
if (event.navigationType !== 'push' && event.navigationType !== 'replace') {
|
|
2937
|
+
throw new DOMException(`cannot redirect when navigationType is not 'push' or 'replace`, 'InvalidStateError');
|
|
2938
|
+
}
|
|
2939
|
+
const toUrl = new URL(url, navigation.currentEntry.url);
|
|
2940
|
+
event.destination.url = toUrl.href;
|
|
2941
|
+
}
|
|
2942
|
+
// https://whatpr.org/html/10919/nav-history-apis.html#inner-navigate-event-firing-algorithm
|
|
2943
|
+
// "Let commit be the following steps:"
|
|
2944
|
+
function commit() {
|
|
2945
|
+
if (result.signal.aborted) {
|
|
2946
|
+
return;
|
|
2933
2947
|
}
|
|
2934
|
-
this.interceptionState = 'committed';
|
|
2935
|
-
result.navigation.commitNavigateEvent(event);
|
|
2936
|
-
};
|
|
2937
|
-
// Internal only.
|
|
2938
|
-
event.cancel = function (reason) {
|
|
2939
|
-
result.committedReject(reason);
|
|
2940
|
-
result.finishedReject(reason);
|
|
2941
|
-
};
|
|
2942
|
-
function dispatch() {
|
|
2943
|
-
navigation.navigateEvent = event;
|
|
2944
|
-
navigation.eventTarget.dispatchEvent(event);
|
|
2945
|
-
dispatchedNavigateEvent = true;
|
|
2946
2948
|
if (event.interceptionState !== 'none') {
|
|
2949
|
+
event.interceptionState = 'committed';
|
|
2950
|
+
if (!navigation.currentEntry) {
|
|
2951
|
+
throw new Error('from history entry should not be null');
|
|
2952
|
+
}
|
|
2947
2953
|
navigation.transition = new InternalNavigationTransition(navigation.currentEntry, navigationType);
|
|
2948
|
-
|
|
2949
|
-
|
|
2954
|
+
switch (event.navigationType) {
|
|
2955
|
+
case 'push':
|
|
2956
|
+
case 'replace': {
|
|
2957
|
+
navigation.urlAndHistoryUpdateSteps(event);
|
|
2958
|
+
break;
|
|
2959
|
+
}
|
|
2960
|
+
case 'reload': {
|
|
2961
|
+
navigation.updateNavigationEntriesForSameDocumentNavigation(event);
|
|
2962
|
+
break;
|
|
2963
|
+
}
|
|
2964
|
+
case 'traverse': {
|
|
2965
|
+
navigation.userAgentTraverse(event);
|
|
2966
|
+
break;
|
|
2967
|
+
}
|
|
2950
2968
|
}
|
|
2951
2969
|
}
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
event.commit(/** internal */ true);
|
|
2970
|
+
const promisesList = handlers.map((handler) => handler());
|
|
2971
|
+
if (promisesList.length === 0) {
|
|
2972
|
+
promisesList.push(Promise.resolve());
|
|
2956
2973
|
}
|
|
2957
|
-
Promise.all(
|
|
2974
|
+
Promise.all(promisesList)
|
|
2975
|
+
.then(() => {
|
|
2958
2976
|
// Follows steps outlined under "Wait for all of promisesList, with the following success steps:"
|
|
2959
2977
|
// in the spec https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigate-event-firing.
|
|
2960
2978
|
if (result.signal.aborted) {
|
|
@@ -2964,9 +2982,6 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
|
|
|
2964
2982
|
throw new Error("Navigation's ongoing event not equal to resolved event");
|
|
2965
2983
|
}
|
|
2966
2984
|
navigation.navigateEvent = null;
|
|
2967
|
-
if (event.interceptionState === 'intercepted') {
|
|
2968
|
-
navigation.commitNavigateEvent(event);
|
|
2969
|
-
}
|
|
2970
2985
|
finishNavigationEvent(event, true);
|
|
2971
2986
|
const navigatesuccessEvent = new Event('navigatesuccess', { bubbles: false, cancelable });
|
|
2972
2987
|
navigation.eventTarget.dispatchEvent(navigatesuccessEvent);
|
|
@@ -2975,39 +2990,66 @@ function dispatchNavigateEvent({ cancelable, canIntercept, userInitiated, hashCh
|
|
|
2975
2990
|
navigation.transition.finishedResolve();
|
|
2976
2991
|
}
|
|
2977
2992
|
navigation.transition = null;
|
|
2978
|
-
}
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2993
|
+
})
|
|
2994
|
+
.catch((reason) => event.cancel(reason));
|
|
2995
|
+
}
|
|
2996
|
+
// Internal only.
|
|
2997
|
+
// https://whatpr.org/html/10919/nav-history-apis.html#inner-navigate-event-firing-algorithm
|
|
2998
|
+
// "Let cancel be the following steps given reason"
|
|
2999
|
+
event.cancel = function (reason) {
|
|
3000
|
+
if (result.signal.aborted) {
|
|
3001
|
+
return;
|
|
3002
|
+
}
|
|
3003
|
+
if (event !== navigation.navigateEvent) {
|
|
3004
|
+
throw new Error("Navigation's ongoing event not equal to resolved event");
|
|
3005
|
+
}
|
|
3006
|
+
navigation.navigateEvent = null;
|
|
3007
|
+
if (event.interceptionState !== 'intercepted') {
|
|
2987
3008
|
finishNavigationEvent(event, false);
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
3009
|
+
}
|
|
3010
|
+
const navigateerrorEvent = new Event('navigateerror', { bubbles: false, cancelable });
|
|
3011
|
+
navigation.eventTarget.dispatchEvent(navigateerrorEvent);
|
|
3012
|
+
result.finishedReject(reason);
|
|
3013
|
+
if (navigation.transition !== null) {
|
|
3014
|
+
navigation.transition.finishedReject(reason);
|
|
3015
|
+
}
|
|
3016
|
+
navigation.transition = null;
|
|
3017
|
+
};
|
|
3018
|
+
function dispatch() {
|
|
3019
|
+
navigation.navigateEvent = event;
|
|
3020
|
+
navigation.eventTarget.dispatchEvent(event);
|
|
3021
|
+
if (precommitHandlers.length === 0) {
|
|
3022
|
+
commit();
|
|
3023
|
+
}
|
|
3024
|
+
else {
|
|
3025
|
+
const precommitController = { redirect };
|
|
3026
|
+
const precommitPromisesList = precommitHandlers.map((handler) => handler(precommitController));
|
|
3027
|
+
Promise.all(precommitPromisesList)
|
|
3028
|
+
.then(() => commit())
|
|
3029
|
+
.catch((reason) => event.cancel(reason));
|
|
3030
|
+
}
|
|
2996
3031
|
}
|
|
2997
3032
|
dispatch();
|
|
2998
|
-
return event;
|
|
3033
|
+
return event.interceptionState !== 'none';
|
|
2999
3034
|
}
|
|
3000
3035
|
/** https://whatpr.org/html/10919/nav-history-apis.html#navigateevent-finish */
|
|
3001
3036
|
function finishNavigationEvent(event, didFulfill) {
|
|
3002
|
-
if (event.interceptionState === '
|
|
3003
|
-
throw new Error('Attempting to finish navigation event that was
|
|
3037
|
+
if (event.interceptionState === 'finished') {
|
|
3038
|
+
throw new Error('Attempting to finish navigation event that was already finished');
|
|
3039
|
+
}
|
|
3040
|
+
if (event.interceptionState === 'intercepted') {
|
|
3041
|
+
if (didFulfill === true) {
|
|
3042
|
+
throw new Error('didFulfill should be false');
|
|
3043
|
+
}
|
|
3044
|
+
// assert precommit handlers is not empty
|
|
3045
|
+
event.interceptionState = 'finished';
|
|
3046
|
+
return;
|
|
3004
3047
|
}
|
|
3005
3048
|
if (event.interceptionState === 'none') {
|
|
3006
3049
|
return;
|
|
3007
3050
|
}
|
|
3051
|
+
potentiallyResetFocus(event);
|
|
3008
3052
|
if (didFulfill) {
|
|
3009
|
-
// TODO(atscott): https://github.com/whatwg/html/issues/11087 focus reset is not guarded by didFulfill in the spec
|
|
3010
|
-
potentiallyResetFocus(event);
|
|
3011
3053
|
potentiallyResetScroll(event);
|
|
3012
3054
|
}
|
|
3013
3055
|
event.interceptionState = 'finished';
|
|
@@ -3061,6 +3103,15 @@ function createPopStateEvent({ state }) {
|
|
|
3061
3103
|
event.state = state;
|
|
3062
3104
|
return event;
|
|
3063
3105
|
}
|
|
3106
|
+
function createHashChangeEvent(newURL, oldURL) {
|
|
3107
|
+
const event = new Event('hashchange', {
|
|
3108
|
+
bubbles: false,
|
|
3109
|
+
cancelable: false,
|
|
3110
|
+
});
|
|
3111
|
+
event.newURL = newURL;
|
|
3112
|
+
event.oldURL = oldURL;
|
|
3113
|
+
return event;
|
|
3114
|
+
}
|
|
3064
3115
|
/**
|
|
3065
3116
|
* Fake equivalent of `NavigationDestination`.
|
|
3066
3117
|
*/
|