@angular/core 21.0.0-rc.3 → 21.0.1

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.
Files changed (76) hide show
  1. package/fesm2022/_attribute-chunk.mjs +1 -1
  2. package/fesm2022/_attribute-chunk.mjs.map +1 -1
  3. package/fesm2022/_debug_node-chunk.mjs +254 -170
  4. package/fesm2022/_debug_node-chunk.mjs.map +1 -1
  5. package/fesm2022/_effect-chunk.mjs +1 -1
  6. package/fesm2022/_effect-chunk.mjs.map +1 -1
  7. package/fesm2022/_linked_signal-chunk.mjs +1 -1
  8. package/fesm2022/_linked_signal-chunk.mjs.map +1 -1
  9. package/fesm2022/_not_found-chunk.mjs +1 -1
  10. package/fesm2022/_not_found-chunk.mjs.map +1 -1
  11. package/fesm2022/_resource-chunk.mjs +33 -19
  12. package/fesm2022/_resource-chunk.mjs.map +1 -1
  13. package/fesm2022/_untracked-chunk.mjs +14 -6
  14. package/fesm2022/_untracked-chunk.mjs.map +1 -1
  15. package/fesm2022/_weak_ref-chunk.mjs +1 -1
  16. package/fesm2022/_weak_ref-chunk.mjs.map +1 -1
  17. package/fesm2022/core.mjs +27 -16
  18. package/fesm2022/core.mjs.map +1 -1
  19. package/fesm2022/primitives-di.mjs +1 -1
  20. package/fesm2022/primitives-di.mjs.map +1 -1
  21. package/fesm2022/primitives-event-dispatch.mjs +1 -1
  22. package/fesm2022/primitives-event-dispatch.mjs.map +1 -1
  23. package/fesm2022/primitives-signals.mjs +1 -1
  24. package/fesm2022/primitives-signals.mjs.map +1 -1
  25. package/fesm2022/rxjs-interop.mjs +12 -4
  26. package/fesm2022/rxjs-interop.mjs.map +1 -1
  27. package/fesm2022/testing.mjs +1 -1
  28. package/fesm2022/testing.mjs.map +1 -1
  29. package/package.json +3 -3
  30. package/resources/best-practices.md +0 -1
  31. package/schematics/bundles/add-bootstrap-context-to-server-main.cjs +1 -1
  32. package/schematics/bundles/application-config-core.cjs +1 -1
  33. package/schematics/bundles/apply_import_manager-1Zs_gpB6.cjs +1 -1
  34. package/schematics/bundles/bootstrap-options-migration.cjs +2 -1
  35. package/schematics/bundles/cleanup-unused-imports.cjs +1 -1
  36. package/schematics/bundles/common-to-standalone-migration.cjs +5 -3
  37. package/schematics/bundles/compiler_host-DBwYMlTo.cjs +1 -1
  38. package/schematics/bundles/control-flow-migration.cjs +1 -1
  39. package/schematics/bundles/imports-DP72APSx.cjs +1 -1
  40. package/schematics/bundles/index-B7I9sIUx.cjs +1 -1
  41. package/schematics/bundles/inject-migration.cjs +1 -1
  42. package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
  43. package/schematics/bundles/migrate_ts_type_references-UGIUl7En.cjs +1 -1
  44. package/schematics/bundles/ng_component_template-Dsuq1Lw7.cjs +1 -1
  45. package/schematics/bundles/ng_decorators-DSFlWYQY.cjs +1 -1
  46. package/schematics/bundles/ngclass-to-class-migration.cjs +1 -1
  47. package/schematics/bundles/ngstyle-to-style-migration.cjs +1 -1
  48. package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
  49. package/schematics/bundles/output-migration.cjs +1 -1
  50. package/schematics/bundles/parse_html-8VLCL37B.cjs +1 -1
  51. package/schematics/bundles/project_paths-DvD50ouC.cjs +1 -1
  52. package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +1 -1
  53. package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
  54. package/schematics/bundles/route-lazy-loading.cjs +1 -1
  55. package/schematics/bundles/router-current-navigation.cjs +1 -1
  56. package/schematics/bundles/router-last-successful-navigation.cjs +1 -1
  57. package/schematics/bundles/router-testing-module-migration.cjs +1 -1
  58. package/schematics/bundles/self-closing-tags-migration.cjs +1 -1
  59. package/schematics/bundles/signal-input-migration.cjs +1 -1
  60. package/schematics/bundles/signal-queries-migration.cjs +1 -1
  61. package/schematics/bundles/signals.cjs +1 -1
  62. package/schematics/bundles/standalone-migration.cjs +1 -1
  63. package/schematics/bundles/symbol-BObKoqes.cjs +1 -1
  64. package/types/_api-chunk.d.ts +7 -2
  65. package/types/_chrome_dev_tools_performance-chunk.d.ts +9 -1
  66. package/types/_discovery-chunk.d.ts +28 -21
  67. package/types/_effect-chunk.d.ts +1 -1
  68. package/types/_event_dispatcher-chunk.d.ts +1 -1
  69. package/types/_formatter-chunk.d.ts +1 -1
  70. package/types/_weak_ref-chunk.d.ts +1 -1
  71. package/types/core.d.ts +148 -138
  72. package/types/primitives-di.d.ts +1 -1
  73. package/types/primitives-event-dispatch.d.ts +1 -1
  74. package/types/primitives-signals.d.ts +1 -1
  75. package/types/rxjs-interop.d.ts +5 -1
  76. package/types/testing.d.ts +13 -1
@@ -1 +1 @@
1
- {"version":3,"file":"_resource-chunk.mjs","sources":["../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/core/src/authoring/output/output_emitter_ref.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/core/src/render3/reactivity/computed.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/core/src/render3/reactivity/linked_signal.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/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 {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} 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 return new ResourceImpl<T | undefined, R>(\n params,\n getLoader(options),\n options.defaultValue,\n options.equal ? wrapEqualityFn(options.equal) : undefined,\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 constructor(value: Signal<T>) {\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\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 readonly isLoading = computed(() => this.status() === 'loading' || this.status() === 'reloading');\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 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 constructor(\n request: () => R,\n private readonly loaderFn: ResourceStreamingLoader<T, R>,\n defaultValue: T,\n private readonly equal: ValueEqualityFn<T> | 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},\n ),\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 });\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 });\n\n this.effectRef = effect(this.loadEffect.bind(this), {\n injector,\n manualCleanup: true,\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\n override readonly status = computed(() => projectStatusOfState(this.state()));\n\n override readonly error = computed(() => {\n const stream = this.state().stream?.();\n return stream && !isResolved(stream) ? stream.error : undefined;\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({value}),\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({error: encapsulateResourceError(err)}),\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({value: await options.loader(params)});\n } catch (err) {\n return signal({error: encapsulateResourceError(err)});\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\nexport function encapsulateResourceError(error: unknown): Error {\n if (error instanceof Error) {\n return error;\n }\n\n return new ResourceWrappedError(error);\n}\n\nclass 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","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","isError","status","untracked","isLoading","isValueDefined","hasValue","loaderFn","pendingTasks","state","extRequest","effectRef","pendingController","resolvePendingTask","unregisterOnDestroy","streamValue","stream","error","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","Error","ResourceWrappedError","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,MA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Y2B,KAAK,EAAE;AAC1B,IAAA,OAAO3B,KAAK;AACd;AAEA,EAAA,OAAO,IAAI4B,oBAAoB,CAAC5B,KAAK,CAAC;AACxC;AAEA,MAAME,kBAAmB,SAAQyB,KAAK,CAAA;EACpC1G,WAAAA,CAAY+E,KAAY,EAAA;AACtB,IAAA,KAAK,CACH1E,SAAS,GACL,CAAA,uEAAA,EAA0E0E,KAAK,CAAC6B,OAAO,CAAA,CAAE,GACzF7B,KAAK,CAAC6B,OAAO,EACjB;AAACC,MAAAA,KAAK,EAAE9B;AAAM,KAAA,CACf;AACH;AACD;AAED,MAAM4B,oBAAqB,SAAQD,KAAK,CAAA;EACtC1G,WAAAA,CAAY+E,KAAc,EAAA;AACxB,IAAA,KAAK,CACH1E,SAAS,GACL,CAAA,yDAAA,EAA4DyG,MAAM,CAAC/B,KAAK,CAAC,CAAA,iDAAA,CAAmD,GAC5H+B,MAAM,CAAC/B,KAAK,CAAC,EACjB;AAAC8B,MAAAA,KAAK,EAAE9B;AAAM,KAAA,CACf;AACH;AACD;;;;"}
1
+ {"version":3,"file":"_resource-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/core/src/authoring/output/output_emitter_ref.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/core/src/render3/reactivity/computed.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/core/src/render3/reactivity/linked_signal.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/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 {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} 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 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 (error instanceof Error) {\n return error;\n }\n\n return new ResourceWrappedError(error);\n}\n\nclass 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","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","untracked","isValueDefined","hasValue","loaderFn","pendingTasks","state","extRequest","effectRef","pendingController","resolvePendingTask","unregisterOnDestroy","error","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","Error","ResourceWrappedError","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,MAEhBX,SAAS,IACP,6CAA6C,GAC3C,8CAA8C,CACnD,CACF;AACD,MAAA;AACF;AAEA,IAAA,IAAI,IAAI,CAACZ,SA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OAAO/B,KAAK;AACd;AAEA,EAAA,OAAO,IAAIgC,oBAAoB,CAAChC,KAAK,CAAC;AACxC;AAEA,MAAMI,kBAAmB,SAAQ2B,KAAK,CAAA;EACpC7G,WAAAA,CAAY8E,KAAY,EAAA;AACtB,IAAA,KAAK,CACHzE,SAAS,GACL,CAAA,uEAAA,EAA0EyE,KAAK,CAACiC,OAAO,CAAA,CAAE,GACzFjC,KAAK,CAACiC,OAAO,EACjB;AAACC,MAAAA,KAAK,EAAElC;AAAM,KAAA,CACf;AACH;AACD;AAED,MAAMgC,oBAAqB,SAAQD,KAAK,CAAA;EACtC7G,WAAAA,CAAY8E,KAAc,EAAA;AACxB,IAAA,KAAK,CACHzE,SAAS,GACL,CAAA,yDAAA,EAA4D4G,MAAM,CAACnC,KAAK,CAAC,CAAA,iDAAA,CAAmD,GAC5HmC,MAAM,CAACnC,KAAK,CAAC,EACjB;AAACkC,MAAAA,KAAK,EAAElC;AAAM,KAAA,CACf;AACH;AACD;;;;"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.0.0-rc.3
2
+ * @license Angular v21.0.1
3
3
  * (c) 2010-2025 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
@@ -23,7 +23,7 @@ class Version {
23
23
  this.patch = parts.slice(2).join('.');
24
24
  }
25
25
  }
26
- const VERSION = /* @__PURE__ */new Version('21.0.0-rc.3');
26
+ const VERSION = /* @__PURE__ */new Version('21.0.1');
27
27
 
28
28
  const ERROR_DETAILS_PAGE_BASE_URL = (() => {
29
29
  const versionSubDomain = VERSION.major !== '0' ? `v${VERSION.major}.` : '';
@@ -2834,7 +2834,7 @@ function effect(effectFn, options) {
2834
2834
  }
2835
2835
  node.injector = injector;
2836
2836
  if (destroyRef !== null) {
2837
- node.onDestroyFn = destroyRef.onDestroy(() => node.destroy());
2837
+ node.onDestroyFns = [destroyRef.onDestroy(() => node.destroy())];
2838
2838
  }
2839
2839
  const effectRef = new EffectRefImpl(node);
2840
2840
  if (ngDevMode) {
@@ -2855,7 +2855,7 @@ const EFFECT_NODE = /* @__PURE__ */(() => ({
2855
2855
  ...BASE_EFFECT_NODE,
2856
2856
  cleanupFns: undefined,
2857
2857
  zone: null,
2858
- onDestroyFn: noop,
2858
+ onDestroyFns: null,
2859
2859
  run() {
2860
2860
  if (ngDevMode && isInNotificationPhase()) {
2861
2861
  throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
@@ -2890,7 +2890,11 @@ const ROOT_EFFECT_NODE = /* @__PURE__ */(() => ({
2890
2890
  },
2891
2891
  destroy() {
2892
2892
  consumerDestroy(this);
2893
- this.onDestroyFn();
2893
+ if (this.onDestroyFns !== null) {
2894
+ for (const fn of this.onDestroyFns) {
2895
+ fn();
2896
+ }
2897
+ }
2894
2898
  this.cleanup();
2895
2899
  this.scheduler.remove(this);
2896
2900
  }
@@ -2904,7 +2908,11 @@ const VIEW_EFFECT_NODE = /* @__PURE__ */(() => ({
2904
2908
  },
2905
2909
  destroy() {
2906
2910
  consumerDestroy(this);
2907
- this.onDestroyFn();
2911
+ if (this.onDestroyFns !== null) {
2912
+ for (const fn of this.onDestroyFns) {
2913
+ fn();
2914
+ }
2915
+ }
2908
2916
  this.cleanup();
2909
2917
  this.view[EFFECTS]?.delete(this);
2910
2918
  }