static-injector 5.0.2 → 6.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.
- package/import/change_detection/scheduling/zoneless_scheduling.d.ts +37 -0
- package/import/change_detection/scheduling/zoneless_scheduling_impl.d.ts +16 -0
- package/import/core_reactivity_export_internal.d.ts +17 -0
- package/import/di/contextual.d.ts +36 -0
- package/{typings → import}/di/create_injector.d.ts +1 -1
- package/{typings → import}/di/forward_ref.d.ts +2 -2
- package/import/di/index.d.ts +3 -0
- package/{typings → import}/di/initializer_token.d.ts +8 -1
- package/{typings → import}/di/inject_switch.d.ts +2 -2
- package/{typings → import}/di/injectable.d.ts +2 -2
- package/{typings → import}/di/injection_token.d.ts +3 -4
- package/{typings → import}/di/injector.d.ts +1 -1
- package/{typings → import}/di/injector_compatibility.d.ts +1 -1
- package/{typings → import}/di/injector_marker.d.ts +1 -1
- package/{typings → import}/di/injector_token.d.ts +1 -1
- package/{typings → import}/di/interface/defs.d.ts +1 -1
- package/{typings → import}/di/interface/injector.d.ts +1 -1
- package/{typings → import}/di/interface/provider.d.ts +1 -1
- package/{typings → import}/di/internal_tokens.d.ts +1 -1
- package/{typings → import}/di/metadata.d.ts +5 -9
- package/{typings → import}/di/null_injector.d.ts +1 -1
- package/{typings → import}/di/provider_collection.d.ts +31 -3
- package/{typings → import}/di/provider_token.d.ts +1 -1
- package/{typings → import}/di/r3_injector.d.ts +2 -2
- package/{typings → import}/di/scope.d.ts +1 -1
- package/{typings → import}/di.d.ts +1 -1
- package/import/error_handler.d.ts +45 -0
- package/{typings → import}/errors.d.ts +9 -7
- package/import/index.d.ts +37 -0
- package/{typings → import}/interface/lifecycle_hooks.d.ts +1 -1
- package/{typings → import}/interface/type.d.ts +4 -9
- package/import/linker/destroy_ref.d.ts +44 -0
- package/import/pending_tasks.d.ts +78 -0
- package/{typings → import}/render3/definition_factory.d.ts +1 -1
- package/{typings → import}/render3/errors_di.d.ts +1 -1
- package/{typings → import}/render3/fields.d.ts +1 -1
- package/{typings → import}/render3/instructions/di.d.ts +1 -1
- package/import/render3/reactivity/api.d.ts +27 -0
- package/import/render3/reactivity/asserts.d.ts +16 -0
- package/import/render3/reactivity/computed.d.ts +25 -0
- package/import/render3/reactivity/effect.d.ts +121 -0
- package/import/render3/reactivity/linked_signal.d.ts +33 -0
- package/import/render3/reactivity/microtask_effect.d.ts +21 -0
- package/import/render3/reactivity/patch.d.ts +11 -0
- package/import/render3/reactivity/root_effect_scheduler.d.ts +54 -0
- package/import/render3/reactivity/signal.d.ts +61 -0
- package/import/render3/reactivity/untracked.d.ts +12 -0
- package/import/resource/api.d.ts +219 -0
- package/{es2022/di/injectable.js → import/resource/index.d.ts} +3 -2
- package/import/resource/resource.d.ts +89 -0
- package/import/util/callback_scheduler.d.ts +35 -0
- package/{typings → import}/util/closure.d.ts +1 -1
- package/{typings → import}/util/decorators.d.ts +3 -3
- package/{typings → import}/util/empty.d.ts +1 -1
- package/{es2022/di/provider_token.js → import/util/noop.d.ts} +2 -2
- package/{typings → import}/util/property.d.ts +1 -1
- package/{typings → import}/util/stringify.d.ts +1 -1
- package/index.js +2349 -0
- package/index.js.map +7 -0
- package/index.mjs +2258 -0
- package/index.mjs.map +7 -0
- package/package.json +22 -11
- package/primitives/signals/index.d.ts +15 -0
- package/primitives/signals/src/computed.d.ts +55 -0
- package/primitives/signals/src/equality.d.ts +15 -0
- package/primitives/signals/src/errors.d.ts +10 -0
- package/primitives/signals/src/graph.d.ts +182 -0
- package/primitives/signals/src/linked_signal.d.ts +72 -0
- package/primitives/signals/src/signal.d.ts +29 -0
- package/primitives/signals/src/watch.d.ts +43 -0
- package/{es2022/di/injector_marker.js → primitives/signals/src/weak_ref.d.ts} +2 -2
- package/readme.md +19 -15
- package/commonjs/index.js +0 -1586
- package/es2022/di/create_injector.js +0 -32
- package/es2022/di/forward_ref.js +0 -80
- package/es2022/di/index.js +0 -1
- package/es2022/di/initializer_token.js +0 -15
- package/es2022/di/inject_switch.js +0 -51
- package/es2022/di/injection_token.js +0 -93
- package/es2022/di/injector.js +0 -60
- package/es2022/di/injector_compatibility.js +0 -265
- package/es2022/di/injector_token.js +0 -20
- package/es2022/di/interface/defs.js +0 -110
- package/es2022/di/interface/injector.js +0 -26
- package/es2022/di/interface/provider.js +0 -10
- package/es2022/di/internal_tokens.js +0 -9
- package/es2022/di/metadata.js +0 -48
- package/es2022/di/null_injector.js +0 -19
- package/es2022/di/provider_collection.js +0 -104
- package/es2022/di/r3_injector.js +0 -449
- package/es2022/di/scope.js +0 -14
- package/es2022/di.js +0 -24
- package/es2022/errors.js +0 -44
- package/es2022/index.js +0 -19
- package/es2022/interface/lifecycle_hooks.js +0 -8
- package/es2022/interface/type.js +0 -21
- package/es2022/render3/definition_factory.js +0 -10
- package/es2022/render3/errors_di.js +0 -13
- package/es2022/render3/fields.js +0 -22
- package/es2022/render3/instructions/di.js +0 -23
- package/es2022/render3/util/stringify_utils.js +0 -38
- package/es2022/util/closure.js +0 -19
- package/es2022/util/decorators.js +0 -31
- package/es2022/util/empty.js +0 -18
- package/es2022/util/property.js +0 -15
- package/es2022/util/stringify.js +0 -45
- package/fesm2022/index.js +0 -1547
- package/typings/di/index.d.ts +0 -1
- package/typings/index.d.ts +0 -18
- package/typings/render3/util/stringify_utils.d.ts +0 -21
|
@@ -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.
|
|
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.
|
|
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.
|
|
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:
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
export declare function stringify(token: any): string;
|
|
9
9
|
/**
|