UNPKG

@angular/core

Version:

Angular - the core framework

1 lines • 41.6 kB
{"version":3,"file":"_resource-chunk.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/authoring/output/output_emitter_ref.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/reactivity/untracked.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/reactivity/computed.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/render3/reactivity/linked_signal.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/core/src/resource/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 {setActiveConsumer} from '../../../primitives/signals';\n\nimport {inject} from '../../di/injector_compatibility';\nimport {ErrorHandler} from '../../error_handler';\nimport {formatRuntimeError, RuntimeError, RuntimeErrorCode} from '../../errors';\nimport {DestroyRef} from '../../linker/destroy_ref';\n\nimport {OutputRef, OutputRefSubscription} from './output_ref';\n\n/**\n * An `OutputEmitterRef` is created by the `output()` function and can be\n * used to emit values to consumers of your directive or component.\n *\n * Consumers of your directive/component can bind to the output and\n * subscribe to changes via the bound event syntax. For example:\n *\n * ```html\n * <my-comp (valueChange)=\"processNewValue($event)\" />\n * ```\n *\n * @see [Custom events with outputs](guide/components/outputs)\n *\n * @publicAPI\n */\nexport class OutputEmitterRef<T> implements OutputRef<T> {\n private destroyed = false;\n private listeners: Array<(value: T) => void> | null = null;\n private errorHandler = inject(ErrorHandler, {optional: true});\n\n /** @internal */\n destroyRef: DestroyRef = inject(DestroyRef);\n\n constructor() {\n // Clean-up all listeners and mark as destroyed upon destroy.\n this.destroyRef.onDestroy(() => {\n this.destroyed = true;\n this.listeners = null;\n });\n }\n\n subscribe(callback: (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 (this.listeners ??= []).push(callback);\n\n return {\n unsubscribe: () => {\n const idx = this.listeners?.indexOf(callback);\n if (idx !== undefined && idx !== -1) {\n this.listeners?.splice(idx, 1);\n }\n },\n };\n }\n\n /** Emits a new value to the output. */\n emit(value: T): void {\n if (this.destroyed) {\n console.warn(\n formatRuntimeError(\n RuntimeErrorCode.OUTPUT_REF_DESTROYED,\n ngDevMode &&\n 'Unexpected emit for destroyed `OutputRef`. ' +\n 'The owning directive/component is destroyed.',\n ),\n );\n return;\n }\n\n if (this.listeners === null) {\n return;\n }\n\n const previousConsumer = setActiveConsumer(null);\n try {\n for (const listenerFn of this.listeners) {\n try {\n listenerFn(value);\n } catch (err: unknown) {\n this.errorHandler?.handleError(err);\n }\n }\n } finally {\n setActiveConsumer(previousConsumer);\n }\n }\n}\n\n/** Gets the owning `DestroyRef` for the given output. */\nexport function getOutputDestroyRef(ref: OutputRef<unknown>): DestroyRef | undefined {\n return ref.destroyRef;\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 {untracked as untrackedPrimitive} from '../../../primitives/signals';\n\n/**\n * Execute an arbitrary function in a non-reactive (non-tracking) context. The executed function\n * can, optionally, return a value.\n * @see [Reading without tracking dependencies](guide/signals#reading-without-tracking-dependencies)\n */\nexport function untracked<T>(nonReactiveReadsFn: () => T): T {\n return untrackedPrimitive(nonReactiveReadsFn);\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 {createComputed, SIGNAL} from '../../../primitives/signals';\n\nimport {Signal, ValueEqualityFn} from './api';\n\n/**\n * Options passed to the `computed` creation function.\n */\nexport interface CreateComputedOptions<T> {\n /**\n * A comparison function which defines equality for computed values.\n */\n equal?: ValueEqualityFn<T>;\n\n /**\n * A debug name for the computed signal. Used in Angular DevTools to identify the signal.\n */\n debugName?: string;\n}\n\n/**\n * Create a computed `Signal` which derives a reactive value from an expression.\n * @see [Computed signals](guide/signals#computed-signals)\n */\nexport function computed<T>(computation: () => T, options?: CreateComputedOptions<T>): Signal<T> {\n const getter = createComputed(computation, options?.equal);\n\n if (ngDevMode) {\n getter.toString = () => `[Computed: ${getter()}]`;\n getter[SIGNAL].debugName = options?.debugName;\n }\n\n return getter;\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 ComputationFn,\n createLinkedSignal,\n LinkedSignalGetter,\n LinkedSignalNode,\n linkedSignalSetFn,\n linkedSignalUpdateFn,\n SIGNAL,\n} from '../../../primitives/signals';\nimport {Signal, ValueEqualityFn} from './api';\nimport {signalAsReadonlyFn, WritableSignal} from './signal';\n\nconst identityFn = <T>(v: T) => v;\n\n/**\n * Creates a writable signal whose value is initialized and reset by the linked, reactive computation.\n *\n * @publicApi 20.0\n */\nexport function linkedSignal<D>(\n computation: () => D,\n options?: {equal?: ValueEqualityFn<NoInfer<D>>; debugName?: string},\n): WritableSignal<D>;\n\n/**\n * Creates a writable signal whose value is initialized and reset by the linked, reactive computation.\n * This is an advanced API form where the computation has access to the previous value of the signal and the computation result.\n *\n * Note: The computation is reactive, meaning the linked signal will automatically update whenever any of the signals used within the computation change.\n *\n * @publicApi 20.0\n * @see [Dependent state with linkedSignal](guide/signals/linked-signal)\n */\nexport function linkedSignal<S, D>(options: {\n source: () => S;\n computation: (source: NoInfer<S>, previous?: {source: NoInfer<S>; value: NoInfer<D>}) => D;\n equal?: ValueEqualityFn<NoInfer<D>>;\n debugName?: string;\n}): WritableSignal<D>;\n\nexport function linkedSignal<S, D>(\n optionsOrComputation:\n | {\n source: () => S;\n computation: ComputationFn<S, D>;\n equal?: ValueEqualityFn<D>;\n debugName?: string;\n }\n | (() => D),\n options?: {equal?: ValueEqualityFn<D>; debugName?: string},\n): WritableSignal<D> {\n if (typeof optionsOrComputation === 'function') {\n const getter = createLinkedSignal<D, D>(\n optionsOrComputation,\n identityFn<D>,\n options?.equal,\n ) as LinkedSignalGetter<D, D> & WritableSignal<D>;\n return upgradeLinkedSignalGetter(getter, options?.debugName);\n } else {\n const getter = createLinkedSignal<S, D>(\n optionsOrComputation.source,\n optionsOrComputation.computation,\n optionsOrComputation.equal,\n );\n return upgradeLinkedSignalGetter(getter, optionsOrComputation.debugName);\n }\n}\n\nfunction upgradeLinkedSignalGetter<S, D>(\n getter: LinkedSignalGetter<S, D>,\n debugName?: string,\n): WritableSignal<D> {\n if (ngDevMode) {\n getter.toString = () => `[LinkedSignal: ${getter()}]`;\n getter[SIGNAL].debugName = debugName;\n }\n\n const node = getter[SIGNAL] as LinkedSignalNode<S, D>;\n const upgradedGetter = getter as LinkedSignalGetter<S, D> & WritableSignal<D>;\n\n upgradedGetter.set = (newValue: D) => linkedSignalSetFn(node, newValue);\n upgradedGetter.update = (updateFn: (value: D) => D) => linkedSignalUpdateFn(node, updateFn);\n upgradedGetter.asReadonly = signalAsReadonlyFn.bind(getter as any) as () => Signal<D>;\n\n return upgradedGetter;\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 {untracked} from '../render3/reactivity/untracked';\nimport {computed} from '../render3/reactivity/computed';\nimport {signal, signalAsReadonlyFn, WritableSignal} from '../render3/reactivity/signal';\nimport {Signal, ValueEqualityFn} from '../render3/reactivity/api';\nimport {effect, EffectRef} from '../render3/reactivity/effect';\nimport {\n ResourceOptions,\n ResourceStatus,\n WritableResource,\n Resource,\n ResourceRef,\n ResourceStreamingLoader,\n StreamingResourceOptions,\n ResourceStreamItem,\n ResourceLoaderParams,\n ResourceSnapshot,\n} from './api';\n\nimport {Injector} from '../di/injector';\nimport {assertInInjectionContext} from '../di/contextual';\nimport {inject} from '../di/injector_compatibility';\nimport {PendingTasks} from '../pending_tasks';\nimport {linkedSignal} from '../render3/reactivity/linked_signal';\nimport {DestroyRef} from '../linker/destroy_ref';\n\n/**\n * Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by\n * a loader function, which exposes the result of the loading operation via signals.\n *\n * Note that `resource` is intended for _read_ operations, not operations which perform mutations.\n * `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new\n * request object becomes available, which could prematurely abort mutations.\n *\n * @see [Async reactivity with resources](guide/signals/resource)\n *\n * @experimental 19.0\n */\nexport function resource<T, R>(\n options: ResourceOptions<T, R> & {defaultValue: NoInfer<T>},\n): ResourceRef<T>;\n\n/**\n * Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by\n * a loader function, which exposes the result of the loading operation via signals.\n *\n * Note that `resource` is intended for _read_ operations, not operations which perform mutations.\n * `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new\n * request object becomes available, which could prematurely abort mutations.\n *\n * @experimental 19.0\n * @see [Async reactivity with resources](guide/signals/resource)\n */\nexport function resource<T, R>(options: ResourceOptions<T, R>): ResourceRef<T | undefined>;\nexport function resource<T, R>(options: ResourceOptions<T, R>): ResourceRef<T | undefined> {\n if (ngDevMode && !options?.injector) {\n assertInInjectionContext(resource);\n }\n\n const oldNameForParams = (\n options as ResourceOptions<T, R> & {request: ResourceOptions<T, R>['params']}\n ).request;\n const params = (options.params ?? oldNameForParams ?? (() => null)) as () => R;\n\n return new ResourceImpl<T | undefined, R>(\n params,\n getLoader(options),\n options.defaultValue,\n options.equal ? wrapEqualityFn(options.equal) : undefined,\n options.debugName,\n options.injector ?? inject(Injector),\n );\n}\n\ntype ResourceInternalStatus = 'idle' | 'loading' | 'resolved' | 'local';\n\n/**\n * Internal state of a resource.\n */\ninterface ResourceProtoState<T> {\n extRequest: WrappedRequest;\n\n // For simplicity, status is internally tracked as a subset of the public status enum.\n // Reloading and Error statuses are projected from Loading and Resolved based on other state.\n status: ResourceInternalStatus;\n}\n\ninterface ResourceState<T> extends ResourceProtoState<T> {\n previousStatus: ResourceStatus;\n stream: Signal<ResourceStreamItem<T>> | undefined;\n}\n\ntype WrappedRequest = {request: unknown; reload: number};\n\n/**\n * Base class which implements `.value` as a `WritableSignal` by delegating `.set` and `.update`.\n */\nabstract class BaseWritableResource<T> implements WritableResource<T> {\n readonly value: WritableSignal<T>;\n abstract readonly status: Signal<ResourceStatus>;\n abstract readonly error: Signal<Error | undefined>;\n\n abstract reload(): boolean;\n\n readonly isLoading: Signal<boolean>;\n\n constructor(value: Signal<T>, debugName: string | undefined) {\n this.value = value as WritableSignal<T>;\n this.value.set = this.set.bind(this);\n this.value.update = this.update.bind(this);\n this.value.asReadonly = signalAsReadonlyFn;\n\n this.isLoading = computed(\n () => this.status() === 'loading' || this.status() === 'reloading',\n ngDevMode ? createDebugNameObject(debugName, 'isLoading') : undefined,\n );\n }\n\n abstract set(value: T): void;\n\n private readonly isError = computed(() => this.status() === 'error');\n\n update(updateFn: (value: T) => T): void {\n this.set(updateFn(untracked(this.value)));\n }\n\n // Use a computed here to avoid triggering reactive consumers if the value changes while staying\n // either defined or undefined.\n private readonly isValueDefined = computed(() => {\n // Check if it's in an error state first to prevent the error from bubbling up.\n if (this.isError()) {\n return false;\n }\n\n return this.value() !== undefined;\n });\n\n private _snapshot: Signal<ResourceSnapshot<T>> | undefined;\n get snapshot(): Signal<ResourceSnapshot<T>> {\n return (this._snapshot ??= computed(() => {\n const status = this.status();\n if (status === 'error') {\n return {status: 'error', error: this.error()!};\n } else {\n return {status, value: this.value()};\n }\n }));\n }\n\n hasValue(): this is ResourceRef<Exclude<T, undefined>> {\n return this.isValueDefined();\n }\n\n asReadonly(): Resource<T> {\n return this;\n }\n}\n\n/**\n * Implementation for `resource()` which uses a `linkedSignal` to manage the resource's state.\n */\nexport class ResourceImpl<T, R> extends BaseWritableResource<T> implements ResourceRef<T> {\n private readonly pendingTasks: PendingTasks;\n\n /**\n * The current state of the resource. Status, value, and error are derived from this.\n */\n private readonly state: WritableSignal<ResourceState<T>>;\n\n /**\n * Combines the current request with a reload counter which allows the resource to be reloaded on\n * imperative command.\n */\n protected readonly extRequest: WritableSignal<WrappedRequest>;\n private readonly effectRef: EffectRef;\n\n private pendingController: AbortController | undefined;\n private resolvePendingTask: (() => void) | undefined = undefined;\n private destroyed = false;\n private unregisterOnDestroy: () => void;\n\n override readonly status: Signal<ResourceStatus>;\n override readonly error: Signal<Error | undefined>;\n\n constructor(\n request: () => R,\n private readonly loaderFn: ResourceStreamingLoader<T, R>,\n defaultValue: T,\n private readonly equal: ValueEqualityFn<T> | undefined,\n private readonly debugName: string | undefined,\n injector: Injector,\n ) {\n super(\n // Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a\n // `WritableSignal` that delegates to `ResourceImpl.set`.\n computed(\n () => {\n const streamValue = this.state().stream?.();\n\n if (!streamValue) {\n return defaultValue;\n }\n\n // Prevents `hasValue()` from throwing an error when a reload happened in the error state\n if (this.state().status === 'loading' && this.error()) {\n return defaultValue;\n }\n\n if (!isResolved(streamValue)) {\n throw new ResourceValueError(this.error()!);\n }\n\n return streamValue.value;\n },\n {equal, ...(ngDevMode ? createDebugNameObject(debugName, 'value') : undefined)},\n ),\n debugName,\n );\n\n // Extend `request()` to include a writable reload signal.\n this.extRequest = linkedSignal({\n source: request,\n computation: (request) => ({request, reload: 0}),\n ...(ngDevMode ? createDebugNameObject(debugName, 'extRequest') : undefined),\n });\n\n // The main resource state is managed in a `linkedSignal`, which allows the resource to change\n // state instantaneously when the request signal changes.\n this.state = linkedSignal<WrappedRequest, ResourceState<T>>({\n // Whenever the request changes,\n source: this.extRequest,\n // Compute the state of the resource given a change in status.\n computation: (extRequest, previous) => {\n const status = extRequest.request === undefined ? 'idle' : 'loading';\n if (!previous) {\n return {\n extRequest,\n status,\n previousStatus: 'idle',\n stream: undefined,\n };\n } else {\n return {\n extRequest,\n status,\n previousStatus: projectStatusOfState(previous.value),\n // If the request hasn't changed, keep the previous stream.\n stream:\n previous.value.extRequest.request === extRequest.request\n ? previous.value.stream\n : undefined,\n };\n }\n },\n ...(ngDevMode ? createDebugNameObject(debugName, 'state') : undefined),\n });\n\n this.effectRef = effect(this.loadEffect.bind(this), {\n injector,\n manualCleanup: true,\n ...(ngDevMode ? createDebugNameObject(debugName, 'loadEffect') : undefined),\n });\n\n this.pendingTasks = injector.get(PendingTasks);\n\n // Cancel any pending request when the resource itself is destroyed.\n this.unregisterOnDestroy = injector.get(DestroyRef).onDestroy(() => this.destroy());\n\n this.status = computed(\n () => projectStatusOfState(this.state()),\n ngDevMode ? createDebugNameObject(debugName, 'status') : undefined,\n );\n\n this.error = computed(\n () => {\n const stream = this.state().stream?.();\n return stream && !isResolved(stream) ? stream.error : undefined;\n },\n ngDevMode ? createDebugNameObject(debugName, 'error') : undefined,\n );\n }\n\n /**\n * Called either directly via `WritableResource.set` or via `.value.set()`.\n */\n override set(value: T): void {\n if (this.destroyed) {\n return;\n }\n\n const error = untracked(this.error);\n const state = untracked(this.state);\n\n if (!error) {\n const current = untracked(this.value);\n if (\n state.status === 'local' &&\n (this.equal ? this.equal(current, value) : current === value)\n ) {\n return;\n }\n }\n\n // Enter Local state with the user-defined value.\n this.state.set({\n extRequest: state.extRequest,\n status: 'local',\n previousStatus: 'local',\n stream: signal(\n {value},\n ngDevMode ? createDebugNameObject(this.debugName, 'stream') : undefined,\n ),\n });\n\n // We're departing from whatever state the resource was in previously, so cancel any in-progress\n // loading operations.\n this.abortInProgressLoad();\n }\n\n override reload(): boolean {\n // We don't want to restart in-progress loads.\n const {status} = untracked(this.state);\n if (status === 'idle' || status === 'loading') {\n return false;\n }\n\n // Increment the request reload to trigger the `state` linked signal to switch us to `Reload`\n this.extRequest.update(({request, reload}) => ({request, reload: reload + 1}));\n return true;\n }\n\n destroy(): void {\n this.destroyed = true;\n this.unregisterOnDestroy();\n this.effectRef.destroy();\n this.abortInProgressLoad();\n\n // Destroyed resources enter Idle state.\n this.state.set({\n extRequest: {request: undefined, reload: 0},\n status: 'idle',\n previousStatus: 'idle',\n stream: undefined,\n });\n }\n\n private async loadEffect(): Promise<void> {\n const extRequest = this.extRequest();\n\n // Capture the previous status before any state transitions. Note that this is `untracked` since\n // we do not want the effect to depend on the state of the resource, only on the request.\n const {status: currentStatus, previousStatus} = untracked(this.state);\n\n if (extRequest.request === undefined) {\n // Nothing to load (and we should already be in a non-loading state).\n return;\n } else if (currentStatus !== 'loading') {\n // We're not in a loading or reloading state, so this loading request is stale.\n return;\n }\n\n // Cancel any previous loading attempts.\n this.abortInProgressLoad();\n\n // Capturing _this_ load's pending task in a local variable is important here. We may attempt to\n // resolve it twice:\n //\n // 1. when the loading function promise resolves/rejects\n // 2. when cancelling the loading operation\n //\n // After the loading operation is cancelled, `this.resolvePendingTask` no longer represents this\n // particular task, but this `await` may eventually resolve/reject. Thus, when we cancel in\n // response to (1) below, we need to cancel the locally saved task.\n let resolvePendingTask: (() => void) | undefined = (this.resolvePendingTask =\n this.pendingTasks.add());\n\n const {signal: abortSignal} = (this.pendingController = new AbortController());\n\n try {\n // The actual loading is run through `untracked` - only the request side of `resource` is\n // reactive. This avoids any confusion with signals tracking or not tracking depending on\n // which side of the `await` they are.\n const stream = await untracked(() => {\n return this.loaderFn({\n params: extRequest.request as Exclude<R, undefined>,\n // TODO(alxhub): cleanup after g3 removal of `request` alias.\n request: extRequest.request as Exclude<R, undefined>,\n abortSignal,\n previous: {\n status: previousStatus,\n },\n } as ResourceLoaderParams<R>);\n });\n\n // If this request has been aborted, or the current request no longer\n // matches this load, then we should ignore this resolution.\n if (abortSignal.aborted || untracked(this.extRequest) !== extRequest) {\n return;\n }\n\n this.state.set({\n extRequest,\n status: 'resolved',\n previousStatus: 'resolved',\n stream,\n });\n } catch (err) {\n if (abortSignal.aborted || untracked(this.extRequest) !== extRequest) {\n return;\n }\n\n this.state.set({\n extRequest,\n status: 'resolved',\n previousStatus: 'error',\n stream: signal(\n {error: encapsulateResourceError(err)},\n ngDevMode ? createDebugNameObject(this.debugName, 'stream') : undefined,\n ),\n });\n } finally {\n // Resolve the pending task now that the resource has a value.\n resolvePendingTask?.();\n resolvePendingTask = undefined;\n }\n }\n\n private abortInProgressLoad(): void {\n untracked(() => this.pendingController?.abort());\n this.pendingController = undefined;\n\n // Once the load is aborted, we no longer want to block stability on its resolution.\n this.resolvePendingTask?.();\n this.resolvePendingTask = undefined;\n }\n}\n\n/**\n * Wraps an equality function to handle either value being `undefined`.\n */\nfunction wrapEqualityFn<T>(equal: ValueEqualityFn<T>): ValueEqualityFn<T | undefined> {\n return (a, b) => (a === undefined || b === undefined ? a === b : equal(a, b));\n}\n\nfunction getLoader<T, R>(options: ResourceOptions<T, R>): ResourceStreamingLoader<T, R> {\n if (isStreamingResourceOptions(options)) {\n return options.stream;\n }\n\n return async (params) => {\n try {\n return signal(\n {value: await options.loader(params)},\n ngDevMode ? createDebugNameObject(options.debugName, 'stream') : undefined,\n );\n } catch (err) {\n return signal(\n {error: encapsulateResourceError(err)},\n ngDevMode ? createDebugNameObject(options.debugName, 'stream') : undefined,\n );\n }\n };\n}\n\nfunction isStreamingResourceOptions<T, R>(\n options: ResourceOptions<T, R>,\n): options is StreamingResourceOptions<T, R> {\n return !!(options as StreamingResourceOptions<T, R>).stream;\n}\n\n/**\n * Project from a state with `ResourceInternalStatus` to the user-facing `ResourceStatus`\n */\nfunction projectStatusOfState(state: ResourceState<unknown>): ResourceStatus {\n switch (state.status) {\n case 'loading':\n return state.extRequest.reload === 0 ? 'loading' : 'reloading';\n case 'resolved':\n return isResolved(state.stream!()) ? 'resolved' : 'error';\n default:\n return state.status;\n }\n}\n\nfunction isResolved<T>(state: ResourceStreamItem<T>): state is {value: T} {\n return (state as {error: unknown}).error === undefined;\n}\n\n/**\n * Creates a debug name object for an internal signal.\n */\nfunction createDebugNameObject(\n resourceDebugName: string | undefined,\n internalSignalDebugName: string,\n): {debugName?: string} {\n return {\n debugName: `Resource${resourceDebugName ? '#' + resourceDebugName : ''}.${internalSignalDebugName}`,\n };\n}\n\nexport function encapsulateResourceError(error: unknown): Error {\n if (isErrorLike(error)) {\n return error;\n }\n\n return new ResourceWrappedError(error);\n}\n\nexport function isErrorLike(error: unknown): error is Error {\n return (\n error instanceof Error ||\n (typeof error === 'object' &&\n typeof (error as Error).name === 'string' &&\n typeof (error as Error).message === 'string')\n );\n}\n\nexport class ResourceValueError extends Error {\n constructor(error: Error) {\n super(\n ngDevMode\n ? `Resource is currently in an error state (see Error.cause for details): ${error.message}`\n : error.message,\n {cause: error},\n );\n }\n}\n\nclass ResourceWrappedError extends Error {\n constructor(error: unknown) {\n super(\n ngDevMode\n ? `Resource returned an error that's not an Error instance: ${String(error)}. Check this error's .cause for the actual error.`\n : String(error),\n {cause: error},\n );\n }\n}\n"],"names":["OutputEmitterRef","destroyed","listeners","errorHandler","inject","ErrorHandler","optional","destroyRef","DestroyRef","constructor","onDestroy","subscribe","callback","RuntimeError","ngDevMode","push","unsubscribe","idx","indexOf","undefined","splice","emit","value","console","warn","formatRuntimeError","previousConsumer","setActiveConsumer","listenerFn","err","handleError","getOutputDestroyRef","ref","untracked","nonReactiveReadsFn","untrackedPrimitive","computed","computation","options","getter","createComputed","equal","toString","SIGNAL","debugName","identityFn","v","linkedSignal","optionsOrComputation","createLinkedSignal","upgradeLinkedSignalGetter","source","node","upgradedGetter","set","newValue","linkedSignalSetFn","update","updateFn","linkedSignalUpdateFn","asReadonly","signalAsReadonlyFn","bind","resource","injector","assertInInjectionContext","oldNameForParams","request","params","ResourceImpl","getLoader","defaultValue","wrapEqualityFn","Injector","BaseWritableResource","isLoading","status","createDebugNameObject","isError","isValueDefined","_snapshot","snapshot","error","hasValue","loaderFn","pendingTasks","state","extRequest","effectRef","pendingController","resolvePendingTask","unregisterOnDestroy","streamValue","stream","isResolved","ResourceValueError","reload","previous","previousStatus","projectStatusOfState","effect","loadEffect","manualCleanup","get","PendingTasks","destroy","current","signal","abortInProgressLoad","currentStatus","add","abortSignal","AbortController","aborted","encapsulateResourceError","abort","a","b","isStreamingResourceOptions","loader","resourceDebugName","internalSignalDebugName","isErrorLike","ResourceWrappedError","Error","name","message","cause","String"],"mappings":";;;;;;;;;;MAgCaA,gBAAgB,CAAA;AACnBC,EAAAA,SAAS,GAAG,KAAK;AACjBC,EAAAA,SAAS,GAAqC,IAAI;AAClDC,EAAAA,YAAY,GAAGC,MAAM,CAACC,YAAY,EAAE;AAACC,IAAAA,QAAQ,EAAE;AAAK,GAAA,CAAC;AAG7DC,EAAAA,UAAU,GAAeH,MAAM,CAACI,UAAU,CAAC;AAE3CC,EAAAA,WAAAA,GAAA;AAEE,IAAA,IAAI,CAACF,UAAU,CAACG,SAAS,CAAC,MAAK;MAC7B,IAAI,CAACT,SAAS,GAAG,IAAI;MACrB,IAAI,CAACC,SAAS,GAAG,IAAI;AACvB,KAAC,CAAC;AACJ;EAEAS,SAASA,CAACC,QAA4B,EAAA;IACpC,IAAI,IAAI,CAACX,SAAS,EAAE;MAClB,MAAM,IAAIY,YAAY,CAAA,GAAA,EAEpBC,SAAS,IACP,oDAAoD,GAClD,8CAA8C,CACnD;AACH;IAEA,CAAC,IAAI,CAACZ,SAAS,KAAK,EAAE,EAAEa,IAAI,CAACH,QAAQ,CAAC;IAEtC,OAAO;MACLI,WAAW,EAAEA,MAAK;QAChB,MAAMC,GAAG,GAAG,IAAI,CAACf,SAAS,EAAEgB,OAAO,CAACN,QAAQ,CAAC;QAC7C,IAAIK,GAAG,KAAKE,SAAS,IAAIF,GAAG,KAAK,CAAC,CAAC,EAAE;UACnC,IAAI,CAACf,SAAS,EAAEkB,MAAM,CAACH,GAAG,EAAE,CAAC,CAAC;AAChC;AACF;KACD;AACH;EAGAI,IAAIA,CAACC,KAAQ,EAAA;IACX,IAAI,IAAI,CAACrB,SAAS,EAAE;AAClBsB,MAAAA,OAAO,CAACC,IAAI,CACVC,kBAAkB,MA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