static-injector 5.0.1 → 6.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 (110) hide show
  1. package/import/change_detection/scheduling/zoneless_scheduling.d.ts +37 -0
  2. package/import/change_detection/scheduling/zoneless_scheduling_impl.d.ts +16 -0
  3. package/import/core_reactivity_export_internal.d.ts +17 -0
  4. package/import/di/contextual.d.ts +36 -0
  5. package/{typings → import}/di/create_injector.d.ts +1 -1
  6. package/{typings → import}/di/forward_ref.d.ts +2 -2
  7. package/import/di/index.d.ts +3 -0
  8. package/{typings → import}/di/initializer_token.d.ts +8 -1
  9. package/{typings → import}/di/inject_switch.d.ts +2 -2
  10. package/{typings → import}/di/injectable.d.ts +4 -4
  11. package/{typings → import}/di/injection_token.d.ts +3 -4
  12. package/{typings → import}/di/injector.d.ts +4 -4
  13. package/{typings → import}/di/injector_compatibility.d.ts +1 -1
  14. package/{typings → import}/di/injector_marker.d.ts +1 -1
  15. package/{typings → import}/di/injector_token.d.ts +1 -1
  16. package/{typings → import}/di/interface/defs.d.ts +1 -1
  17. package/{typings → import}/di/interface/injector.d.ts +1 -1
  18. package/{typings → import}/di/interface/provider.d.ts +16 -18
  19. package/{typings → import}/di/internal_tokens.d.ts +1 -1
  20. package/{typings → import}/di/metadata.d.ts +9 -13
  21. package/{typings → import}/di/null_injector.d.ts +1 -1
  22. package/{typings → import}/di/provider_collection.d.ts +32 -4
  23. package/{typings → import}/di/provider_token.d.ts +1 -1
  24. package/{typings → import}/di/r3_injector.d.ts +2 -2
  25. package/{typings → import}/di/scope.d.ts +1 -1
  26. package/{typings → import}/di.d.ts +1 -1
  27. package/import/error_handler.d.ts +45 -0
  28. package/{typings → import}/errors.d.ts +13 -7
  29. package/import/index.d.ts +37 -0
  30. package/{typings → import}/interface/lifecycle_hooks.d.ts +2 -2
  31. package/{typings → import}/interface/type.d.ts +4 -9
  32. package/import/linker/destroy_ref.d.ts +44 -0
  33. package/import/pending_tasks.d.ts +78 -0
  34. package/{typings → import}/render3/definition_factory.d.ts +1 -1
  35. package/{typings → import}/render3/errors_di.d.ts +1 -1
  36. package/{typings → import}/render3/fields.d.ts +1 -1
  37. package/{typings → import}/render3/instructions/di.d.ts +1 -1
  38. package/import/render3/reactivity/api.d.ts +27 -0
  39. package/import/render3/reactivity/asserts.d.ts +16 -0
  40. package/import/render3/reactivity/computed.d.ts +25 -0
  41. package/import/render3/reactivity/effect.d.ts +121 -0
  42. package/import/render3/reactivity/linked_signal.d.ts +33 -0
  43. package/import/render3/reactivity/microtask_effect.d.ts +21 -0
  44. package/import/render3/reactivity/patch.d.ts +11 -0
  45. package/import/render3/reactivity/root_effect_scheduler.d.ts +54 -0
  46. package/import/render3/reactivity/signal.d.ts +61 -0
  47. package/import/render3/reactivity/untracked.d.ts +12 -0
  48. package/import/resource/api.d.ts +219 -0
  49. package/{es2022/di/injectable.js → import/resource/index.d.ts} +3 -2
  50. package/import/resource/resource.d.ts +89 -0
  51. package/import/util/callback_scheduler.d.ts +35 -0
  52. package/{typings → import}/util/closure.d.ts +1 -1
  53. package/{typings → import}/util/decorators.d.ts +3 -3
  54. package/{typings → import}/util/empty.d.ts +1 -1
  55. package/{es2022/di/provider_token.js → import/util/noop.d.ts} +2 -2
  56. package/{typings → import}/util/property.d.ts +1 -1
  57. package/{typings → import}/util/stringify.d.ts +1 -1
  58. package/index.js +2349 -0
  59. package/index.js.map +7 -0
  60. package/index.mjs +2258 -0
  61. package/index.mjs.map +7 -0
  62. package/package.json +19 -10
  63. package/primitives/signals/index.d.ts +15 -0
  64. package/primitives/signals/src/computed.d.ts +55 -0
  65. package/primitives/signals/src/equality.d.ts +15 -0
  66. package/primitives/signals/src/errors.d.ts +10 -0
  67. package/primitives/signals/src/graph.d.ts +182 -0
  68. package/primitives/signals/src/linked_signal.d.ts +72 -0
  69. package/primitives/signals/src/signal.d.ts +29 -0
  70. package/primitives/signals/src/watch.d.ts +43 -0
  71. package/{es2022/di/injector_marker.js → primitives/signals/src/weak_ref.d.ts} +2 -2
  72. package/readme.md +18 -14
  73. package/commonjs/index.js +0 -1576
  74. package/es2022/di/create_injector.js +0 -32
  75. package/es2022/di/forward_ref.js +0 -80
  76. package/es2022/di/index.js +0 -1
  77. package/es2022/di/initializer_token.js +0 -15
  78. package/es2022/di/inject_switch.js +0 -51
  79. package/es2022/di/injection_token.js +0 -93
  80. package/es2022/di/injector.js +0 -60
  81. package/es2022/di/injector_compatibility.js +0 -265
  82. package/es2022/di/injector_token.js +0 -20
  83. package/es2022/di/interface/defs.js +0 -110
  84. package/es2022/di/interface/injector.js +0 -26
  85. package/es2022/di/interface/provider.js +0 -10
  86. package/es2022/di/internal_tokens.js +0 -9
  87. package/es2022/di/metadata.js +0 -49
  88. package/es2022/di/null_injector.js +0 -19
  89. package/es2022/di/provider_collection.js +0 -104
  90. package/es2022/di/r3_injector.js +0 -449
  91. package/es2022/di/scope.js +0 -14
  92. package/es2022/di.js +0 -24
  93. package/es2022/errors.js +0 -44
  94. package/es2022/index.js +0 -11
  95. package/es2022/interface/lifecycle_hooks.js +0 -8
  96. package/es2022/interface/type.js +0 -21
  97. package/es2022/render3/definition_factory.js +0 -10
  98. package/es2022/render3/errors_di.js +0 -13
  99. package/es2022/render3/fields.js +0 -22
  100. package/es2022/render3/instructions/di.js +0 -23
  101. package/es2022/render3/util/stringify_utils.js +0 -38
  102. package/es2022/util/closure.js +0 -19
  103. package/es2022/util/decorators.js +0 -31
  104. package/es2022/util/empty.js +0 -18
  105. package/es2022/util/property.js +0 -15
  106. package/es2022/util/stringify.js +0 -45
  107. package/fesm2022/index.js +0 -1539
  108. package/typings/di/index.d.ts +0 -1
  109. package/typings/index.d.ts +0 -11
  110. package/typings/render3/util/stringify_utils.d.ts +0 -21
@@ -0,0 +1,54 @@
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
+ * Abstraction that encompasses any kind of effect that can be scheduled.
10
+ */
11
+ export interface SchedulableEffect {
12
+ run(): void;
13
+ zone: {
14
+ run<T>(fn: () => T): T;
15
+ } | null;
16
+ }
17
+ /**
18
+ * A scheduler which manages the execution of effects.
19
+ */
20
+ export declare abstract class EffectScheduler {
21
+ /**
22
+ * Schedule the given effect to be executed at a later time.
23
+ *
24
+ * It is an error to attempt to execute any effects synchronously during a scheduling operation.
25
+ */
26
+ abstract schedule(e: SchedulableEffect): void;
27
+ /**
28
+ * Run any scheduled effects.
29
+ */
30
+ abstract flush(): void;
31
+ /** Remove a scheduled effect */
32
+ abstract remove(e: SchedulableEffect): void;
33
+ /** @nocollapse */
34
+ static ɵprov: unknown;
35
+ }
36
+ /**
37
+ * A wrapper around `ZoneAwareQueueingScheduler` that schedules flushing via the microtask queue
38
+ * when.
39
+ */
40
+ export declare class ZoneAwareEffectScheduler implements EffectScheduler {
41
+ private queuedEffectCount;
42
+ private queues;
43
+ schedule(handle: SchedulableEffect): void;
44
+ remove(handle: SchedulableEffect): void;
45
+ private enqueue;
46
+ /**
47
+ * Run all scheduled effects.
48
+ *
49
+ * Execution order of effects within the same zone is guaranteed to be FIFO, but there is no
50
+ * ordering guarantee between effects scheduled in different zones.
51
+ */
52
+ flush(): void;
53
+ private flushQueue;
54
+ }
@@ -0,0 +1,61 @@
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 { SignalGetter } from '@angular/core/primitives/signals';
9
+ import { Signal, ValueEqualityFn } from './api';
10
+ /** Symbol used distinguish `WritableSignal` from other non-writable signals and functions. */
11
+ export declare const ɵWRITABLE_SIGNAL: unique symbol;
12
+ /**
13
+ * A `Signal` with a value that can be mutated via a setter interface.
14
+ */
15
+ export interface WritableSignal<T> extends Signal<T> {
16
+ [ɵWRITABLE_SIGNAL]: T;
17
+ /**
18
+ * Directly set the signal to a new value, and notify any dependents.
19
+ */
20
+ set(value: T): void;
21
+ /**
22
+ * Update the value of the signal based on its current value, and
23
+ * notify any dependents.
24
+ */
25
+ update(updateFn: (value: T) => T): void;
26
+ /**
27
+ * Returns a readonly version of this signal. Readonly signals can be accessed to read their value
28
+ * but can't be changed using set or update methods. The readonly signals do _not_ have
29
+ * any built-in mechanism that would prevent deep-mutation of their value.
30
+ */
31
+ asReadonly(): Signal<T>;
32
+ }
33
+ /**
34
+ * Utility function used during template type checking to extract the value from a `WritableSignal`.
35
+ * @codeGenApi
36
+ */
37
+ export declare function ɵunwrapWritableSignal<T>(value: T | {
38
+ [ɵWRITABLE_SIGNAL]: T;
39
+ }): T;
40
+ /**
41
+ * Options passed to the `signal` creation function.
42
+ */
43
+ export interface CreateSignalOptions<T> {
44
+ /**
45
+ * A comparison function which defines equality for signal values.
46
+ */
47
+ equal?: ValueEqualityFn<T>;
48
+ /**
49
+ * A debug name for the signal. Used in Angular DevTools to identify the signal.
50
+ */
51
+ debugName?: string;
52
+ }
53
+ /**
54
+ * Create a `Signal` that can be set or updated directly.
55
+ */
56
+ export declare function signal<T>(initialValue: T, options?: CreateSignalOptions<T>): WritableSignal<T>;
57
+ export declare function signalAsReadonlyFn<T>(this: SignalGetter<T>): Signal<T>;
58
+ /**
59
+ * Checks if the given `value` is a writeable signal.
60
+ */
61
+ export declare function isWritableSignal(value: unknown): value is WritableSignal<unknown>;
@@ -0,0 +1,12 @@
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
+ * Execute an arbitrary function in a non-reactive (non-tracking) context. The executed function
10
+ * can, optionally, return a value.
11
+ */
12
+ export declare function untracked<T>(nonReactiveReadsFn: () => T): T;
@@ -0,0 +1,219 @@
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 { Injector } from '../di/injector';
9
+ import { Signal, ValueEqualityFn } from '../render3/reactivity/api';
10
+ import { WritableSignal } from '../render3/reactivity/signal';
11
+ /**
12
+ * Status of a `Resource`.
13
+ *
14
+ * @experimental
15
+ */
16
+ export declare enum ResourceStatus {
17
+ /**
18
+ * The resource has no valid request and will not perform any loading.
19
+ *
20
+ * `value()` will be `undefined`.
21
+ */
22
+ Idle = 0,
23
+ /**
24
+ * Loading failed with an error.
25
+ *
26
+ * `value()` will be `undefined`.
27
+ */
28
+ Error = 1,
29
+ /**
30
+ * The resource is currently loading a new value as a result of a change in its `request`.
31
+ *
32
+ * `value()` will be `undefined`.
33
+ */
34
+ Loading = 2,
35
+ /**
36
+ * The resource is currently reloading a fresh value for the same request.
37
+ *
38
+ * `value()` will continue to return the previously fetched value during the reloading operation.
39
+ */
40
+ Reloading = 3,
41
+ /**
42
+ * Loading has completed and the resource has the value returned from the loader.
43
+ */
44
+ Resolved = 4,
45
+ /**
46
+ * The resource's value was set locally via `.set()` or `.update()`.
47
+ */
48
+ Local = 5
49
+ }
50
+ /**
51
+ * A Resource is an asynchronous dependency (for example, the results of an API call) that is
52
+ * managed and delivered through signals.
53
+ *
54
+ * The usual way of creating a `Resource` is through the `resource` function, but various other APIs
55
+ * may present `Resource` instances to describe their own concepts.
56
+ *
57
+ * @experimental
58
+ */
59
+ export interface Resource<T> {
60
+ /**
61
+ * The current value of the `Resource`, or `undefined` if there is no current value.
62
+ */
63
+ readonly value: Signal<T>;
64
+ /**
65
+ * The current status of the `Resource`, which describes what the resource is currently doing and
66
+ * what can be expected of its `value`.
67
+ */
68
+ readonly status: Signal<ResourceStatus>;
69
+ /**
70
+ * When in the `error` state, this returns the last known error from the `Resource`.
71
+ */
72
+ readonly error: Signal<unknown>;
73
+ /**
74
+ * Whether this resource is loading a new value (or reloading the existing one).
75
+ */
76
+ readonly isLoading: Signal<boolean>;
77
+ /**
78
+ * Whether this resource has a valid current value.
79
+ *
80
+ * This function is reactive.
81
+ */
82
+ hasValue(): this is Resource<Exclude<T, undefined>>;
83
+ /**
84
+ * Instructs the resource to re-load any asynchronous dependency it may have.
85
+ *
86
+ * Note that the resource will not enter its reloading state until the actual backend request is
87
+ * made.
88
+ *
89
+ * @returns true if a reload was initiated, false if a reload was unnecessary or unsupported
90
+ */
91
+ reload(): boolean;
92
+ }
93
+ /**
94
+ * A `Resource` with a mutable value.
95
+ *
96
+ * Overwriting the value of a resource sets it to the 'local' state.
97
+ *
98
+ * @experimental
99
+ */
100
+ export interface WritableResource<T> extends Resource<T> {
101
+ readonly value: WritableSignal<T>;
102
+ hasValue(): this is WritableResource<Exclude<T, undefined>>;
103
+ /**
104
+ * Convenience wrapper for `value.set`.
105
+ */
106
+ set(value: T): void;
107
+ /**
108
+ * Convenience wrapper for `value.update`.
109
+ */
110
+ update(updater: (value: T) => T): void;
111
+ asReadonly(): Resource<T>;
112
+ }
113
+ /**
114
+ * A `WritableResource` created through the `resource` function.
115
+ *
116
+ * @experimental
117
+ */
118
+ export interface ResourceRef<T> extends WritableResource<T> {
119
+ hasValue(): this is ResourceRef<Exclude<T, undefined>>;
120
+ /**
121
+ * Manually destroy the resource, which cancels pending requests and returns it to `idle` state.
122
+ */
123
+ destroy(): void;
124
+ }
125
+ /**
126
+ * Parameter to a `ResourceLoader` which gives the request and other options for the current loading
127
+ * operation.
128
+ *
129
+ * @experimental
130
+ */
131
+ export interface ResourceLoaderParams<R> {
132
+ request: Exclude<NoInfer<R>, undefined>;
133
+ abortSignal: AbortSignal;
134
+ previous: {
135
+ status: ResourceStatus;
136
+ };
137
+ }
138
+ /**
139
+ * Loading function for a `Resource`.
140
+ *
141
+ * @experimental
142
+ */
143
+ export type ResourceLoader<T, R> = (param: ResourceLoaderParams<R>) => PromiseLike<T>;
144
+ /**
145
+ * Streaming loader for a `Resource`.
146
+ *
147
+ * @experimental
148
+ */
149
+ export type ResourceStreamingLoader<T, R> = (param: ResourceLoaderParams<R>) => PromiseLike<Signal<ResourceStreamItem<T>>>;
150
+ /**
151
+ * Options to the `resource` function, for creating a resource.
152
+ *
153
+ * @experimental
154
+ */
155
+ export interface BaseResourceOptions<T, R> {
156
+ /**
157
+ * A reactive function which determines the request to be made. Whenever the request changes, the
158
+ * loader will be triggered to fetch a new value for the resource.
159
+ *
160
+ * If a request function isn't provided, the loader won't rerun unless the resource is reloaded.
161
+ */
162
+ request?: () => R;
163
+ /**
164
+ * The value which will be returned from the resource when a server value is unavailable, such as
165
+ * when the resource is still loading, or in an error state.
166
+ */
167
+ defaultValue?: NoInfer<T>;
168
+ /**
169
+ * Equality function used to compare the return value of the loader.
170
+ */
171
+ equal?: ValueEqualityFn<T>;
172
+ /**
173
+ * Overrides the `Injector` used by `resource`.
174
+ */
175
+ injector?: Injector;
176
+ }
177
+ /**
178
+ * Options to the `resource` function, for creating a resource.
179
+ *
180
+ * @experimental
181
+ */
182
+ export interface PromiseResourceOptions<T, R> extends BaseResourceOptions<T, R> {
183
+ /**
184
+ * Loading function which returns a `Promise` of the resource's value for a given request.
185
+ */
186
+ loader: ResourceLoader<T, R>;
187
+ /**
188
+ * Cannot specify `stream` and `loader` at the same time.
189
+ */
190
+ stream?: never;
191
+ }
192
+ /**
193
+ * Options to the `resource` function, for creating a resource.
194
+ *
195
+ * @experimental
196
+ */
197
+ export interface StreamingResourceOptions<T, R> extends BaseResourceOptions<T, R> {
198
+ /**
199
+ * Loading function which returns a `Promise` of a signal of the resource's value for a given
200
+ * request, which can change over time as new values are received from a stream.
201
+ */
202
+ stream: ResourceStreamingLoader<T, R>;
203
+ /**
204
+ * Cannot specify `stream` and `loader` at the same time.
205
+ */
206
+ loader?: never;
207
+ }
208
+ /**
209
+ * @experimental
210
+ */
211
+ export type ResourceOptions<T, R> = PromiseResourceOptions<T, R> | StreamingResourceOptions<T, R>;
212
+ /**
213
+ * @experimental
214
+ */
215
+ export type ResourceStreamItem<T> = {
216
+ value: T;
217
+ } | {
218
+ error: unknown;
219
+ };
@@ -3,6 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
- export {};
8
+ export * from './api';
9
+ export { resource } from './resource';
@@ -0,0 +1,89 @@
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 { WritableSignal } from '../render3/reactivity/signal';
9
+ import { Signal } from '../render3/reactivity/api';
10
+ import { ResourceOptions, ResourceStatus, WritableResource, Resource, ResourceRef, ResourceStreamingLoader } from './api';
11
+ import { ValueEqualityFn } from '@angular/core/primitives/signals';
12
+ import { Injector } from '../di/injector';
13
+ /**
14
+ * Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by
15
+ * a loader function, which exposes the result of the loading operation via signals.
16
+ *
17
+ * Note that `resource` is intended for _read_ operations, not operations which perform mutations.
18
+ * `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new
19
+ * request object becomes available, which could prematurely abort mutations.
20
+ *
21
+ * @experimental
22
+ */
23
+ export declare function resource<T, R>(options: ResourceOptions<T, R> & {
24
+ defaultValue: NoInfer<T>;
25
+ }): ResourceRef<T>;
26
+ /**
27
+ * Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by
28
+ * a loader function, which exposes the result of the loading operation via signals.
29
+ *
30
+ * Note that `resource` is intended for _read_ operations, not operations which perform mutations.
31
+ * `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new
32
+ * request object becomes available, which could prematurely abort mutations.
33
+ *
34
+ * @experimental
35
+ */
36
+ export declare function resource<T, R>(options: ResourceOptions<T, R>): ResourceRef<T | undefined>;
37
+ type WrappedRequest = {
38
+ request: unknown;
39
+ reload: number;
40
+ };
41
+ /**
42
+ * Base class which implements `.value` as a `WritableSignal` by delegating `.set` and `.update`.
43
+ */
44
+ declare abstract class BaseWritableResource<T> implements WritableResource<T> {
45
+ readonly value: WritableSignal<T>;
46
+ abstract readonly status: Signal<ResourceStatus>;
47
+ abstract readonly error: Signal<unknown>;
48
+ abstract reload(): boolean;
49
+ constructor(value: Signal<T>);
50
+ abstract set(value: T): void;
51
+ update(updateFn: (value: T) => T): void;
52
+ readonly isLoading: Signal<boolean>;
53
+ hasValue(): this is ResourceRef<Exclude<T, undefined>>;
54
+ asReadonly(): Resource<T>;
55
+ }
56
+ /**
57
+ * Implementation for `resource()` which uses a `linkedSignal` to manage the resource's state.
58
+ */
59
+ export declare class ResourceImpl<T, R> extends BaseWritableResource<T> implements ResourceRef<T> {
60
+ private readonly loaderFn;
61
+ private readonly defaultValue;
62
+ private readonly equal;
63
+ private readonly pendingTasks;
64
+ /**
65
+ * The current state of the resource. Status, value, and error are derived from this.
66
+ */
67
+ private readonly state;
68
+ /**
69
+ * Combines the current request with a reload counter which allows the resource to be reloaded on
70
+ * imperative command.
71
+ */
72
+ protected readonly extRequest: WritableSignal<WrappedRequest>;
73
+ private readonly effectRef;
74
+ private pendingController;
75
+ private resolvePendingTask;
76
+ private destroyed;
77
+ constructor(request: () => R, loaderFn: ResourceStreamingLoader<T, R>, defaultValue: T, equal: ValueEqualityFn<T> | undefined, injector: Injector);
78
+ readonly status: Signal<ResourceStatus>;
79
+ readonly error: Signal<unknown>;
80
+ /**
81
+ * Called either directly via `WritableResource.set` or via `.value.set()`.
82
+ */
83
+ set(value: T): void;
84
+ reload(): boolean;
85
+ destroy(): void;
86
+ private loadEffect;
87
+ private abortInProgressLoad;
88
+ }
89
+ export {};
@@ -0,0 +1,35 @@
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
+ * Gets a scheduling function that runs the callback after the first of setTimeout and
10
+ * requestAnimationFrame resolves.
11
+ *
12
+ * - `requestAnimationFrame` ensures that change detection runs ahead of a browser repaint.
13
+ * This ensures that the create and update passes of a change detection always happen
14
+ * in the same frame.
15
+ * - When the browser is resource-starved, `rAF` can execute _before_ a `setTimeout` because
16
+ * rendering is a very high priority process. This means that `setTimeout` cannot guarantee
17
+ * same-frame create and update pass, when `setTimeout` is used to schedule the update phase.
18
+ * - While `rAF` gives us the desirable same-frame updates, it has two limitations that
19
+ * prevent it from being used alone. First, it does not run in background tabs, which would
20
+ * prevent Angular from initializing an application when opened in a new tab (for example).
21
+ * Second, repeated calls to requestAnimationFrame will execute at the refresh rate of the
22
+ * hardware (~16ms for a 60Hz display). This would cause significant slowdown of tests that
23
+ * are written with several updates and asserts in the form of "update; await stable; assert;".
24
+ * - Both `setTimeout` and `rAF` are able to "coalesce" several events from a single user
25
+ * interaction into a single change detection. Importantly, this reduces view tree traversals when
26
+ * compared to an alternative timing mechanism like `queueMicrotask`, where change detection would
27
+ * then be interleaves between each event.
28
+ *
29
+ * By running change detection after the first of `setTimeout` and `rAF` to execute, we get the
30
+ * best of both worlds.
31
+ *
32
+ * @returns a function to cancel the scheduled callback
33
+ */
34
+ export declare function scheduleCallbackWithRafRace(callback: Function): () => void;
35
+ export declare function scheduleCallbackWithMicrotask(callback: Function): () => void;
@@ -3,7 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  /**
9
9
  * Convince closure compiler that the wrapped function has no side-effects.
@@ -3,14 +3,14 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  import { Type } from '../interface/type';
9
9
  /**
10
10
  * An interface implemented by all Angular type decorators, which allows them to be used as
11
11
  * decorators as well as Angular syntax.
12
12
  *
13
- * ```
13
+ * ```ts
14
14
  * @ng.Component({...})
15
15
  * class MyClass {...}
16
16
  * ```
@@ -22,7 +22,7 @@ export interface TypeDecorator {
22
22
  * Invoke as decorator.
23
23
  */
24
24
  <T extends Type<any>>(type: T): T;
25
- (target: Object, propertyKey?: string | symbol, parameterIndex?: number): void;
25
+ (target: object, propertyKey?: string | symbol, parameterIndex?: number): void;
26
26
  (target: unknown, context: unknown): void;
27
27
  }
28
28
  export declare const PARAMETERS = "__parameters__";
@@ -3,7 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  /**
9
9
  * This file contains reuseable "empty" symbols that can be used as default return values
@@ -3,6 +3,6 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
- export {};
8
+ export declare function noop(...args: any[]): any;
@@ -3,6 +3,6 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  export declare function getClosureSafeProperty<T>(objWithPropertyToExtract: T): string;
@@ -3,7 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  export declare function stringify(token: any): string;
9
9
  /**