static-injector 6.3.1 → 7.0.0

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 (55) hide show
  1. package/import/application/application_tokens.d.ts +58 -0
  2. package/import/application/stability_debug.d.ts +13 -0
  3. package/import/authoring/output/output_ref.d.ts +37 -0
  4. package/import/change_detection/scheduling/zoneless_scheduling.d.ts +0 -7
  5. package/import/core_reactivity_export_internal.d.ts +1 -1
  6. package/import/defer/idle_service.d.ts +42 -0
  7. package/import/di/create_injector.d.ts +2 -2
  8. package/import/di/forward_ref.d.ts +2 -2
  9. package/import/di/index.d.ts +5 -0
  10. package/import/di/inject_async.d.ts +91 -0
  11. package/import/di/injectable.d.ts +7 -1
  12. package/import/di/injection_token.d.ts +7 -0
  13. package/import/di/injector.d.ts +1 -1
  14. package/import/di/injector_compatibility.d.ts +0 -1
  15. package/import/di/interface/defs.d.ts +2 -2
  16. package/import/di/interface/provider.d.ts +0 -15
  17. package/import/document.d.ts +18 -0
  18. package/import/errors.d.ts +13 -9
  19. package/import/event_emitter.d.ts +101 -0
  20. package/import/hydration/cache.d.ts +14 -0
  21. package/import/index.d.ts +16 -0
  22. package/import/linker.d.ts +1 -0
  23. package/import/pending_tasks.d.ts +1 -24
  24. package/import/pending_tasks_internal.d.ts +31 -0
  25. package/import/render3/debug/injector_profiler.d.ts +139 -0
  26. package/import/render3/debug/special_providers.d.ts +17 -0
  27. package/import/render3/errors_di.d.ts +25 -0
  28. package/import/render3/reactivity/api.d.ts +15 -0
  29. package/import/render3/reactivity/asserts.d.ts +1 -0
  30. package/import/render3/reactivity/effect.d.ts +3 -1
  31. package/import/render3/reactivity/root_effect_scheduler.d.ts +1 -1
  32. package/import/render3/reactivity/signal.d.ts +0 -4
  33. package/import/render3/util/stringify_utils.d.ts +21 -0
  34. package/import/resource/api.d.ts +101 -15
  35. package/import/resource/debounce.d.ts +21 -0
  36. package/import/resource/from_snapshots.d.ts +16 -0
  37. package/import/resource/index.d.ts +2 -0
  38. package/import/resource/resource.d.ts +32 -8
  39. package/import/transfer_state.d.ts +89 -0
  40. package/import/util/array_utils.d.ts +132 -0
  41. package/import/util/assert.d.ts +28 -0
  42. package/import/util/default_export.d.ts +24 -0
  43. package/import/util/promise_with_resolvers.d.ts +38 -0
  44. package/import/zone/ng_zone.d.ts +261 -0
  45. package/index.js +2263 -1224
  46. package/index.js.map +4 -4
  47. package/index.mjs +2246 -1218
  48. package/index.mjs.map +4 -4
  49. package/package.json +2 -2
  50. package/primitives/signals/index.d.ts +1 -1
  51. package/primitives/signals/src/formatter.d.ts +2 -1
  52. package/primitives/signals/src/graph.d.ts +8 -1
  53. package/primitives/signals/src/linked_signal.d.ts +1 -1
  54. package/readme.md +1 -1
  55. /package/import/{interface → change_detection}/lifecycle_hooks.d.ts +0 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { Observable } from 'rxjs';
9
+ import { OnDestroy } from './change_detection/lifecycle_hooks';
10
+ /**
11
+ * Internal implementation of the pending tasks service.
12
+ */
13
+ export declare class PendingTasksInternal implements OnDestroy {
14
+ private taskId;
15
+ private pendingTasks;
16
+ private destroyed;
17
+ private pendingTask;
18
+ private debugTaskTracker;
19
+ get hasPendingTasks(): boolean;
20
+ /**
21
+ * In case the service is about to be destroyed, return a self-completing observable.
22
+ * Otherwise, return the observable that emits the current state of pending tasks.
23
+ */
24
+ get hasPendingTasksObservable(): Observable<boolean>;
25
+ add(): number;
26
+ has(taskId: number): boolean;
27
+ remove(taskId: number): void;
28
+ ngOnDestroy(): void;
29
+ /** @nocollapse */
30
+ static ɵprov: import("./di/interface/defs").ɵɵInjectableDeclaration<PendingTasksInternal>;
31
+ }
@@ -0,0 +1,139 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import type { ProviderToken } from '../../di';
9
+ import type { Injector } from '../../di/injector';
10
+ import { InternalInjectFlags } from '../../di/interface/injector';
11
+ import type { SingleProvider } from '../../di/provider_collection';
12
+ import { Type } from '../../interface/type';
13
+ import type { EffectRefImpl } from '../reactivity/effect';
14
+ /**
15
+ * An enum describing the types of events that can be emitted from the injector profiler
16
+ */
17
+ export declare const enum InjectorProfilerEventType {
18
+ /**
19
+ * Emits when a service is injected.
20
+ */
21
+ Inject = 0,
22
+ /**
23
+ * Emits when an Angular class instance is created by an injector.
24
+ */
25
+ InstanceCreatedByInjector = 1,
26
+ /**
27
+ * Emits when an injector configures a provider.
28
+ */
29
+ ProviderConfigured = 2,
30
+ /**
31
+ * Emits when an effect is created.
32
+ */
33
+ EffectCreated = 3,
34
+ /**
35
+ * Emits when an after render effect phase is created.
36
+ */
37
+ AfterRenderEffectPhaseCreated = 4,
38
+ /**
39
+ * Emits when an Angular DI system is about to create an instance corresponding to a given token.
40
+ */
41
+ InjectorToCreateInstanceEvent = 5
42
+ }
43
+ /**
44
+ * An object that defines an injection context for the injector profiler.
45
+ */
46
+ export interface InjectorProfilerContext {
47
+ }
48
+ export interface InjectedServiceEvent {
49
+ }
50
+ export interface InjectorToCreateInstanceEvent {
51
+ }
52
+ export interface InjectorCreatedInstanceEvent {
53
+ }
54
+ export interface ProviderConfiguredEvent {
55
+ }
56
+ export interface EffectCreatedEvent {
57
+ }
58
+ export interface AfterRenderEffectPhaseCreatedEvent {
59
+ }
60
+ /**
61
+ * An object representing an event that is emitted through the injector profiler
62
+ */
63
+ export type InjectorProfilerEvent = InjectedServiceEvent | InjectorToCreateInstanceEvent | InjectorCreatedInstanceEvent | ProviderConfiguredEvent | EffectCreatedEvent | AfterRenderEffectPhaseCreatedEvent;
64
+ /**
65
+ * An object that contains information about a provider that has been configured
66
+ *
67
+ * TODO: rename to indicate that it is a debug structure eg. ProviderDebugInfo.
68
+ */
69
+ export interface ProviderRecord {
70
+ }
71
+ /**
72
+ * An object that contains information about a value that has been constructed within an injector
73
+ */
74
+ export interface InjectorCreatedInstance {
75
+ }
76
+ /**
77
+ * An object that contains information a service that has been injected within an
78
+ * InjectorProfilerContext
79
+ */
80
+ export interface InjectedService {
81
+ /**
82
+ * In NodeInjectors, the LView and TNode that serviced this injection.
83
+ */
84
+ injectedIn?: {};
85
+ }
86
+ export interface InjectorProfiler {
87
+ (event: InjectorProfilerEvent): void;
88
+ }
89
+ export declare function getInjectorProfilerContext(): InjectorProfilerContext;
90
+ export declare function setInjectorProfilerContext(context: InjectorProfilerContext): InjectorProfilerContext;
91
+ /**
92
+ * Adds a callback function which will be invoked during certain DI events within the
93
+ * runtime (for example: injecting services, creating injectable instances, configuring providers).
94
+ * Multiple profiler callbacks can be set: in this case profiling events are
95
+ * reported to every registered callback.
96
+ *
97
+ * Warning: this function is *INTERNAL* and should not be relied upon in application's code.
98
+ * The contract of the function might be changed in any release and/or the function can be removed
99
+ * completely.
100
+ *
101
+ * @param profiler function provided by the caller or null value to disable profiling.
102
+ * @returns a cleanup function that, when invoked, removes a given profiler callback.
103
+ */
104
+ export declare function setInjectorProfiler(injectorProfiler: InjectorProfiler | null): () => void;
105
+ /**
106
+ * Injector profiler function which emits on DI events executed by the runtime.
107
+ *
108
+ * @param event InjectorProfilerEvent corresponding to the DI event being emitted
109
+ */
110
+ export declare function injectorProfiler(event: InjectorProfilerEvent): void;
111
+ /**
112
+ * Emits an InjectorProfilerEventType.ProviderConfigured to the injector profiler. The data in the
113
+ * emitted event includes the raw provider, as well as the token that provider is providing.
114
+ *
115
+ * @param eventProvider A provider object
116
+ */
117
+ export declare function emitProviderConfiguredEvent(eventProvider: SingleProvider, isViewProvider?: boolean): void;
118
+ /**
119
+ * Emits an event to the injector profiler when an instance corresponding to a given token is about to be created be an injector. Note that
120
+ * the injector associated with this emission can be accessed by using getDebugInjectContext()
121
+ *
122
+ * @param instance an object created by an injector
123
+ */
124
+ export declare function emitInjectorToCreateInstanceEvent(token: ProviderToken<unknown>): void;
125
+ /**
126
+ * Emits an event to the injector profiler with the instance that was created. Note that
127
+ * the injector associated with this emission can be accessed by using getDebugInjectContext()
128
+ *
129
+ * @param instance an object created by an injector
130
+ */
131
+ export declare function emitInstanceCreatedByInjectorEvent(instance: unknown): void;
132
+ /**
133
+ * @param token DI token associated with injected service
134
+ * @param value the instance of the injected service (i.e the result of `inject(token)`)
135
+ * @param flags the flags that the token was injected with
136
+ */
137
+ export declare function emitInjectEvent(token: Type<unknown>, value: unknown, flags: InternalInjectFlags): void;
138
+ export declare function emitEffectCreatedEvent(effect: EffectRefImpl): void;
139
+ export declare function runInInjectorProfilerContext(injector: Injector, token: Type<unknown>, callback: () => void): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ /**
9
+ * Registers a class as a special provider for debug tooling.
10
+ *
11
+ * @param clazz The class to register
12
+ */
13
+ export declare function registerSpecialProvider(clazz: any): void;
14
+ /**
15
+ * Gets all special providers that have been registered.
16
+ */
17
+ export declare function getAllSpecialProviders(): ReadonlySet<any>;
@@ -6,10 +6,35 @@
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  import type { ProviderToken } from '../di';
9
+ import { Type } from '../interface/type';
9
10
  /** Creates a circular dependency runtime error. */
10
11
  export declare function cyclicDependencyError(token: string, path?: string[]): Error;
12
+ /** Creates a circular dependency runtime error including a dependency path in the error message. */
13
+ export declare function cyclicDependencyErrorWithDetails(token: string, path: string[]): Error;
14
+ export declare function throwMixedMultiProviderError(): void;
15
+ export declare function throwInvalidProviderError(ngModuleType?: Type<unknown>, providers?: any[], provider?: any): never;
11
16
  /** Throws an error when a token is not found in DI. */
12
17
  export declare function throwProviderNotFoundError(token: ProviderToken<unknown>, injectorName?: string): never;
18
+ /**
19
+ * Given an Error instance and the current token - update the monkey-patched
20
+ * dependency path info to include that token.
21
+ *
22
+ * @param error Current instance of the Error class.
23
+ * @param token Extra token that should be appended.
24
+ */
25
+ export declare function prependTokenToDependencyPath(error: any, token: ProviderToken<unknown> | {
26
+ multi: true;
27
+ provide: ProviderToken<unknown>;
28
+ }): void;
29
+ /**
30
+ * Modifies an Error instance with an updated error message
31
+ * based on the accumulated dependency path.
32
+ *
33
+ * @param error Current instance of the Error class.
34
+ * @param source Extra info about the injector which started
35
+ * the resolution process, which eventually failed.
36
+ */
37
+ export declare function augmentRuntimeError(error: any, source: string | null): Error;
13
38
  /**
14
39
  * Creates an initial RuntimeError instance when a problem is detected.
15
40
  * Monkey-patches extra info in the RuntimeError instance, so that it can
@@ -6,6 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  import { SIGNAL } from '../../../primitives/signals';
9
+ import type { WritableSignal } from './signal';
9
10
  /**
10
11
  * A reactive value which notifies consumers of any changes.
11
12
  *
@@ -14,6 +15,8 @@ import { SIGNAL } from '../../../primitives/signals';
14
15
  *
15
16
  * Ordinary values can be turned into `Signal`s with the `signal` function.
16
17
  *
18
+ * @see [What are signals?](guide/signals#what-are-signals)
19
+ *
17
20
  * @publicApi 17.0
18
21
  */
19
22
  export type Signal<T> = (() => T) & {
@@ -22,12 +25,24 @@ export type Signal<T> = (() => T) & {
22
25
  /**
23
26
  * Checks if the given `value` is a reactive `Signal`.
24
27
  *
28
+ * @see [Type checking signals](guide/signals#type-checking-signals)
29
+ *
25
30
  * @publicApi 17.0
26
31
  */
27
32
  export declare function isSignal(value: unknown): value is Signal<unknown>;
28
33
  /**
29
34
  * A comparison function which can determine if two values are equal.
30
35
  *
36
+ * @see [Signal equality functions](guide/signals#signal-equality-functions)
37
+ *
31
38
  * @publicApi 17.0
32
39
  */
33
40
  export type ValueEqualityFn<T> = (a: T, b: T) => boolean;
41
+ /**
42
+ * Checks if the given `value` is a writeable signal.
43
+ *
44
+ * @see [Type checking signals](guide/signals#type-checking-signals)
45
+ *
46
+ * @publicApi 21.1
47
+ */
48
+ export declare function isWritableSignal(value: unknown): value is WritableSignal<unknown>;
@@ -10,6 +10,7 @@
10
10
  * to disallow certain code from running inside a reactive context (see {@link /api/core/rxjs-interop/toSignal toSignal})
11
11
  *
12
12
  * @param debugFn a reference to the function making the assertion (used for the error message).
13
+ * @see [Asserts the reactive context](guide/signals#asserts-the-reactive-context)
13
14
  *
14
15
  * @publicApi
15
16
  */
@@ -13,6 +13,8 @@ import { EffectScheduler, SchedulableEffect } from './root_effect_scheduler';
13
13
  * A global reactive effect, which can be manually destroyed.
14
14
  *
15
15
  * @publicApi 20.0
16
+ *
17
+ * @see [Destroying effects](guide/signals/effect#destroying-effects)
16
18
  */
17
19
  export interface EffectRef {
18
20
  /**
@@ -100,7 +102,7 @@ export interface EffectNode extends BaseEffectNode, SchedulableEffect {
100
102
  cleanupFns: EffectCleanupFn[] | undefined;
101
103
  injector: Injector;
102
104
  notifier: ChangeDetectionScheduler;
103
- onDestroyFn: () => void;
105
+ onDestroyFns: (() => void)[] | null;
104
106
  }
105
107
  export interface RootEffectNode extends EffectNode {
106
108
  scheduler: EffectScheduler;
@@ -33,7 +33,7 @@ export declare abstract class EffectScheduler {
33
33
  /** Remove a scheduled effect */
34
34
  abstract remove(e: SchedulableEffect): void;
35
35
  /** @nocollapse */
36
- static ɵprov: unknown;
36
+ static ɵprov: import("../../di/interface/defs").ɵɵInjectableDeclaration<ZoneAwareEffectScheduler>;
37
37
  }
38
38
  /**
39
39
  * A wrapper around `ZoneAwareQueueingScheduler` that schedules flushing via the microtask queue
@@ -58,7 +58,3 @@ export interface CreateSignalOptions<T> {
58
58
  */
59
59
  export declare function signal<T>(initialValue: T, options?: CreateSignalOptions<T>): WritableSignal<T>;
60
60
  export declare function signalAsReadonlyFn<T>(this: SignalGetter<T>): Signal<T>;
61
- /**
62
- * Checks if the given `value` is a writeable signal.
63
- */
64
- export declare function isWritableSignal(value: unknown): value is WritableSignal<unknown>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ /**
9
+ * Used for stringify render output in Ivy.
10
+ * Important! This function is very performance-sensitive and we should
11
+ * be extra careful not to introduce megamorphic reads in it.
12
+ * Check `core/test/render3/perf/render_stringify` for benchmarks and alternate implementations.
13
+ */
14
+ export declare function renderStringify(value: unknown): string;
15
+ /**
16
+ * Used to stringify a value so that it can be displayed in an error message.
17
+ *
18
+ * Important! This function contains a megamorphic read and should only be
19
+ * used for error messages.
20
+ */
21
+ export declare function stringifyForError(value: any): string;
@@ -8,6 +8,37 @@
8
8
  import { Injector } from '../di/injector';
9
9
  import { Signal, ValueEqualityFn } from '../render3/reactivity/api';
10
10
  import { WritableSignal } from '../render3/reactivity/signal';
11
+ /** Error thrown when a `Resource` dependency of another resource errors. */
12
+ export declare class ResourceDependencyError extends Error {
13
+ /** The dependency that errored. */
14
+ readonly dependency: Resource<unknown>;
15
+ constructor(dependency: Resource<unknown>);
16
+ }
17
+ /**
18
+ * Special status codes that can be thrown from a resource's `params` or `request` function to
19
+ * indicate that the resource should transition to that status.
20
+ */
21
+ export declare class ResourceParamsStatus extends Error {
22
+ private readonly _brand;
23
+ private constructor();
24
+ /** Status code that transitions the resource to `idle` status. */
25
+ static readonly IDLE: ResourceParamsStatus;
26
+ /** Status code that transitions the resource to `loading` status. */
27
+ static readonly LOADING: ResourceParamsStatus;
28
+ }
29
+ /**
30
+ * Context received by a resource's `params` or `request` function.
31
+ *
32
+ * @see [Chaining resources](guide/signals/resource#chaining-resources)
33
+ */
34
+ export interface ResourceParamsContext {
35
+ /**
36
+ * Chains the current params off of the value of another resource, returning the value
37
+ * of the other resource if it is available, or propagating the status to the current resource by
38
+ * throwing the appropriate status code if the value is not available.
39
+ */
40
+ readonly chain: <T>(resource: Resource<T>) => T;
41
+ }
11
42
  /**
12
43
  * String value capturing the status of a `Resource`.
13
44
  *
@@ -29,7 +60,7 @@ import { WritableSignal } from '../render3/reactivity/signal';
29
60
  *
30
61
  * `local` - The resource's value was set locally via `.set()` or `.update()`.
31
62
  *
32
- * @experimental
63
+ * @publicApi 22.0
33
64
  */
34
65
  export type ResourceStatus = 'idle' | 'error' | 'loading' | 'reloading' | 'resolved' | 'local';
35
66
  /**
@@ -39,7 +70,7 @@ export type ResourceStatus = 'idle' | 'error' | 'loading' | 'reloading' | 'resol
39
70
  * The usual way of creating a `Resource` is through the `resource` function, but various other APIs
40
71
  * may present `Resource` instances to describe their own concepts.
41
72
  *
42
- * @experimental
73
+ * @publicApi 22.0
43
74
  */
44
75
  export interface Resource<T> {
45
76
  /**
@@ -59,6 +90,10 @@ export interface Resource<T> {
59
90
  * Whether this resource is loading a new value (or reloading the existing one).
60
91
  */
61
92
  readonly isLoading: Signal<boolean>;
93
+ /**
94
+ * The current state of this resource, represented as a `ResourceSnapshot`.
95
+ */
96
+ readonly snapshot: Signal<ResourceSnapshot<T>>;
62
97
  /**
63
98
  * Whether this resource has a valid current value.
64
99
  *
@@ -72,7 +107,7 @@ export interface Resource<T> {
72
107
  *
73
108
  * Overwriting the value of a resource sets it to the 'local' state.
74
109
  *
75
- * @experimental
110
+ * @publicApi 22.0
76
111
  */
77
112
  export interface WritableResource<T> extends Resource<T> {
78
113
  readonly value: WritableSignal<T>;
@@ -100,7 +135,7 @@ export interface WritableResource<T> extends Resource<T> {
100
135
  /**
101
136
  * A `WritableResource` created through the `resource` function.
102
137
  *
103
- * @experimental
138
+ * @publicApi 22.0
104
139
  */
105
140
  export interface ResourceRef<T> extends WritableResource<T> {
106
141
  hasValue(this: T extends undefined ? this : never): this is ResourceRef<Exclude<T, undefined>>;
@@ -114,7 +149,7 @@ export interface ResourceRef<T> extends WritableResource<T> {
114
149
  * Parameter to a `ResourceLoader` which gives the request and other options for the current loading
115
150
  * operation.
116
151
  *
117
- * @experimental
152
+ * @publicApi 22.0
118
153
  */
119
154
  export interface ResourceLoaderParams<R> {
120
155
  params: NoInfer<Exclude<R, undefined>>;
@@ -126,19 +161,19 @@ export interface ResourceLoaderParams<R> {
126
161
  /**
127
162
  * Loading function for a `Resource`.
128
163
  *
129
- * @experimental
164
+ * @publicApi 22.0
130
165
  */
131
166
  export type ResourceLoader<T, R> = (param: ResourceLoaderParams<R>) => PromiseLike<T>;
132
167
  /**
133
168
  * Streaming loader for a `Resource`.
134
169
  *
135
- * @experimental
170
+ * @publicApi 22.0
136
171
  */
137
- export type ResourceStreamingLoader<T, R> = (param: ResourceLoaderParams<R>) => PromiseLike<Signal<ResourceStreamItem<T>>>;
172
+ export type ResourceStreamingLoader<T, R> = (param: ResourceLoaderParams<R>) => Signal<ResourceStreamItem<T>> | PromiseLike<Signal<ResourceStreamItem<T>>> | undefined;
138
173
  /**
139
174
  * Options to the `resource` function, for creating a resource.
140
175
  *
141
- * @experimental
176
+ * @publicApi 22.0
142
177
  */
143
178
  export interface BaseResourceOptions<T, R> {
144
179
  /**
@@ -147,7 +182,7 @@ export interface BaseResourceOptions<T, R> {
147
182
  *
148
183
  * If a params function isn't provided, the loader won't rerun unless the resource is reloaded.
149
184
  */
150
- params?: () => R;
185
+ params?: (ctx: ResourceParamsContext) => R;
151
186
  /**
152
187
  * The value which will be returned from the resource when a server value is unavailable, such as
153
188
  * when the resource is still loading.
@@ -161,11 +196,16 @@ export interface BaseResourceOptions<T, R> {
161
196
  * Overrides the `Injector` used by `resource`.
162
197
  */
163
198
  injector?: Injector;
199
+ /**
200
+ * Identifier used to cache the resource data in the `TransferState` during server-side rendering and to retrieve it on the client side.
201
+ * This value value needs to be identical for both the client and server.
202
+ */
203
+ id?: string;
164
204
  }
165
205
  /**
166
206
  * Options to the `resource` function, for creating a resource.
167
207
  *
168
- * @experimental
208
+ * @publicApi 22.0
169
209
  */
170
210
  export interface PromiseResourceOptions<T, R> extends BaseResourceOptions<T, R> {
171
211
  /**
@@ -180,7 +220,7 @@ export interface PromiseResourceOptions<T, R> extends BaseResourceOptions<T, R>
180
220
  /**
181
221
  * Options to the `resource` function, for creating a resource.
182
222
  *
183
- * @experimental
223
+ * @publicApi 22.0
184
224
  */
185
225
  export interface StreamingResourceOptions<T, R> extends BaseResourceOptions<T, R> {
186
226
  /**
@@ -194,14 +234,60 @@ export interface StreamingResourceOptions<T, R> extends BaseResourceOptions<T, R
194
234
  loader?: never;
195
235
  }
196
236
  /**
197
- * @experimental
237
+ * @publicApi 22.0
198
238
  */
199
- export type ResourceOptions<T, R> = PromiseResourceOptions<T, R> | StreamingResourceOptions<T, R>;
239
+ export type ResourceOptions<T, R> = (PromiseResourceOptions<T, R> | StreamingResourceOptions<T, R>) & {
240
+ /**
241
+ * A debug name for the reactive node. Used in Angular DevTools to identify the node.
242
+ */
243
+ debugName?: string;
244
+ };
200
245
  /**
201
- * @experimental
246
+ * @publicApi 22.0
202
247
  */
203
248
  export type ResourceStreamItem<T> = {
204
249
  value: T;
205
250
  } | {
206
251
  error: Error;
207
252
  };
253
+ /**
254
+ * An explicit representation of a resource's state.
255
+ *
256
+ * @publicApi 22.0
257
+ * @see [Resource composition with snapshots](guide/signals/resource#resource-composition-with-snapshots)
258
+ */
259
+ export type ResourceSnapshot<T> = {
260
+ readonly status: 'idle';
261
+ readonly value: T;
262
+ } | {
263
+ readonly status: 'loading' | 'reloading';
264
+ readonly value: T;
265
+ } | {
266
+ readonly status: 'resolved' | 'local';
267
+ readonly value: T;
268
+ } | {
269
+ readonly status: 'error';
270
+ readonly error: Error;
271
+ };
272
+ /**
273
+ * Options for `debounced`.
274
+ *
275
+ * @see [Debouncing signals with `debounced`](guide/signals/debounced)
276
+ *
277
+ * @experimental 22.0
278
+ */
279
+ export interface DebouncedOptions<T> {
280
+ /** The `Injector` to use for the debounced resource. */
281
+ injector?: Injector;
282
+ /** The equality function to use for comparing values. */
283
+ equal?: ValueEqualityFn<T>;
284
+ }
285
+ /**
286
+ * Represents the wait condition for item debouncing.
287
+ * Can be a number of milliseconds or a function that returns a Promise.
288
+ *
289
+ * @see [Debouncing signals with `debounced`](guide/signals/debounced)
290
+ *
291
+ * @experimental 22.0
292
+ */
293
+ export type DebounceTimer<T> = number | ((value: T, lastValue: ResourceSnapshot<T>) => Promise<void> | void);
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { Resource, type DebounceTimer, type DebouncedOptions } from './api';
9
+ /**
10
+ * Creates a resource representing a debounced version of the source signal.
11
+ *
12
+ * @param source The source signal to debounce.
13
+ * @param wait The amount of time to wait before calling the source signal, or a function that
14
+ * returns a promise that resolves when the debounced value should be updated.
15
+ * @param options The options to use for the debounced signal.
16
+ * @returns A resource representing the debounced signal.
17
+ * @experimental 22.0
18
+ *
19
+ * @see [Debouncing signals with `debounced`](guide/signals/debounced)
20
+ */
21
+ export declare function debounced<T>(source: () => T, wait: NoInfer<DebounceTimer<T>>, options?: NoInfer<DebouncedOptions<T>>): Resource<T>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { Resource, ResourceSnapshot } from './api';
9
+ /**
10
+ * Creates a `Resource` driven by a source of `ResourceSnapshot`s.
11
+ *
12
+ * @see [Resource composition with snapshots](guide/signals/resource#resource-composition-with-snapshots)
13
+ *
14
+ * @experimental
15
+ */
16
+ export declare function resourceFromSnapshots<T>(source: () => ResourceSnapshot<T>): Resource<T>;
@@ -6,4 +6,6 @@
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  export * from './api';
9
+ export { debounced } from './debounce';
10
+ export { resourceFromSnapshots } from './from_snapshots';
9
11
  export { resource } from './resource';