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.
- package/import/application/application_tokens.d.ts +58 -0
- package/import/application/stability_debug.d.ts +13 -0
- package/import/authoring/output/output_ref.d.ts +37 -0
- package/import/change_detection/scheduling/zoneless_scheduling.d.ts +0 -7
- package/import/core_reactivity_export_internal.d.ts +1 -1
- package/import/defer/idle_service.d.ts +42 -0
- package/import/di/create_injector.d.ts +2 -2
- package/import/di/forward_ref.d.ts +2 -2
- package/import/di/index.d.ts +5 -0
- package/import/di/inject_async.d.ts +91 -0
- package/import/di/injectable.d.ts +7 -1
- package/import/di/injection_token.d.ts +7 -0
- package/import/di/injector.d.ts +1 -1
- package/import/di/injector_compatibility.d.ts +0 -1
- package/import/di/interface/defs.d.ts +2 -2
- package/import/di/interface/provider.d.ts +0 -15
- package/import/document.d.ts +18 -0
- package/import/errors.d.ts +13 -9
- package/import/event_emitter.d.ts +101 -0
- package/import/hydration/cache.d.ts +14 -0
- package/import/index.d.ts +16 -0
- package/import/linker.d.ts +1 -0
- package/import/pending_tasks.d.ts +1 -24
- package/import/pending_tasks_internal.d.ts +31 -0
- package/import/render3/debug/injector_profiler.d.ts +139 -0
- package/import/render3/debug/special_providers.d.ts +17 -0
- package/import/render3/errors_di.d.ts +25 -0
- package/import/render3/reactivity/api.d.ts +15 -0
- package/import/render3/reactivity/asserts.d.ts +1 -0
- package/import/render3/reactivity/effect.d.ts +3 -1
- package/import/render3/reactivity/root_effect_scheduler.d.ts +1 -1
- package/import/render3/reactivity/signal.d.ts +0 -4
- package/import/render3/util/stringify_utils.d.ts +21 -0
- package/import/resource/api.d.ts +101 -15
- package/import/resource/debounce.d.ts +21 -0
- package/import/resource/from_snapshots.d.ts +16 -0
- package/import/resource/index.d.ts +2 -0
- package/import/resource/resource.d.ts +32 -8
- package/import/transfer_state.d.ts +89 -0
- package/import/util/array_utils.d.ts +132 -0
- package/import/util/assert.d.ts +28 -0
- package/import/util/default_export.d.ts +24 -0
- package/import/util/promise_with_resolvers.d.ts +38 -0
- package/import/zone/ng_zone.d.ts +261 -0
- package/index.js +2263 -1224
- package/index.js.map +4 -4
- package/index.mjs +2246 -1218
- package/index.mjs.map +4 -4
- package/package.json +2 -2
- package/primitives/signals/index.d.ts +1 -1
- package/primitives/signals/src/formatter.d.ts +2 -1
- package/primitives/signals/src/graph.d.ts +8 -1
- package/primitives/signals/src/linked_signal.d.ts +1 -1
- package/readme.md +1 -1
- /package/import/{interface → change_detection}/lifecycle_hooks.d.ts +0 -0
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
|
-
import { WritableSignal } from '../render3/reactivity/signal';
|
|
9
8
|
import { Signal, ValueEqualityFn } from '../render3/reactivity/api';
|
|
10
|
-
import {
|
|
9
|
+
import { WritableSignal } from '../render3/reactivity/signal';
|
|
10
|
+
import { Resource, ResourceOptions, ResourceSnapshot, ResourceStatus, ResourceStreamingLoader, ResourceStreamItem, type ResourceParamsContext, type ResourceRef, type WritableResource } from './api';
|
|
11
11
|
import { Injector } from '../di/injector';
|
|
12
|
+
import { StateKey } from '../transfer_state';
|
|
12
13
|
/**
|
|
13
14
|
* Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by
|
|
14
15
|
* a loader function, which exposes the result of the loading operation via signals.
|
|
@@ -19,7 +20,7 @@ import { Injector } from '../di/injector';
|
|
|
19
20
|
*
|
|
20
21
|
* @see [Async reactivity with resources](guide/signals/resource)
|
|
21
22
|
*
|
|
22
|
-
* @
|
|
23
|
+
* @publicApi 22.0
|
|
23
24
|
*/
|
|
24
25
|
export declare function resource<T, R>(options: ResourceOptions<T, R> & {
|
|
25
26
|
defaultValue: NoInfer<T>;
|
|
@@ -32,13 +33,16 @@ export declare function resource<T, R>(options: ResourceOptions<T, R> & {
|
|
|
32
33
|
* `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new
|
|
33
34
|
* request object becomes available, which could prematurely abort mutations.
|
|
34
35
|
*
|
|
35
|
-
* @
|
|
36
|
+
* @publicApi 22.0
|
|
36
37
|
* @see [Async reactivity with resources](guide/signals/resource)
|
|
37
38
|
*/
|
|
38
39
|
export declare function resource<T, R>(options: ResourceOptions<T, R>): ResourceRef<T | undefined>;
|
|
40
|
+
type ResourceInternalStatus = 'idle' | 'loading' | 'resolved' | 'local';
|
|
39
41
|
type WrappedRequest = {
|
|
40
|
-
request
|
|
42
|
+
request?: unknown;
|
|
41
43
|
reload: number;
|
|
44
|
+
status?: ResourceInternalStatus;
|
|
45
|
+
error?: Error;
|
|
42
46
|
};
|
|
43
47
|
/**
|
|
44
48
|
* Base class which implements `.value` as a `WritableSignal` by delegating `.set` and `.update`.
|
|
@@ -48,12 +52,14 @@ declare abstract class BaseWritableResource<T> implements WritableResource<T> {
|
|
|
48
52
|
abstract readonly status: Signal<ResourceStatus>;
|
|
49
53
|
abstract readonly error: Signal<Error | undefined>;
|
|
50
54
|
abstract reload(): boolean;
|
|
51
|
-
|
|
55
|
+
readonly isLoading: Signal<boolean>;
|
|
56
|
+
constructor(value: Signal<T>, debugName: string | undefined);
|
|
52
57
|
abstract set(value: T): void;
|
|
53
58
|
private readonly isError;
|
|
54
59
|
update(updateFn: (value: T) => T): void;
|
|
55
|
-
readonly isLoading: Signal<boolean>;
|
|
56
60
|
private readonly isValueDefined;
|
|
61
|
+
private _snapshot;
|
|
62
|
+
get snapshot(): Signal<ResourceSnapshot<T>>;
|
|
57
63
|
hasValue(): this is ResourceRef<Exclude<T, undefined>>;
|
|
58
64
|
asReadonly(): Resource<T>;
|
|
59
65
|
}
|
|
@@ -63,6 +69,8 @@ declare abstract class BaseWritableResource<T> implements WritableResource<T> {
|
|
|
63
69
|
export declare class ResourceImpl<T, R> extends BaseWritableResource<T> implements ResourceRef<T> {
|
|
64
70
|
private readonly loaderFn;
|
|
65
71
|
private readonly equal;
|
|
72
|
+
private readonly debugName;
|
|
73
|
+
private transferCacheKey;
|
|
66
74
|
private readonly pendingTasks;
|
|
67
75
|
/**
|
|
68
76
|
* The current state of the resource. Status, value, and error are derived from this.
|
|
@@ -78,9 +86,10 @@ export declare class ResourceImpl<T, R> extends BaseWritableResource<T> implemen
|
|
|
78
86
|
private resolvePendingTask;
|
|
79
87
|
private destroyed;
|
|
80
88
|
private unregisterOnDestroy;
|
|
81
|
-
constructor(request: () => R, loaderFn: ResourceStreamingLoader<T, R>, defaultValue: T, equal: ValueEqualityFn<T> | undefined, injector: Injector);
|
|
82
89
|
readonly status: Signal<ResourceStatus>;
|
|
83
90
|
readonly error: Signal<Error | undefined>;
|
|
91
|
+
private readonly transferState;
|
|
92
|
+
constructor(request: (ctx: ResourceParamsContext) => R, loaderFn: ResourceStreamingLoader<T, R>, defaultValue: T, equal: ValueEqualityFn<T> | undefined, debugName: string | undefined, injector: Injector, transferCacheKey: StateKey<T> | undefined, getInitialStream?: (request: R) => Signal<ResourceStreamItem<T>> | undefined);
|
|
84
93
|
/**
|
|
85
94
|
* Called either directly via `WritableResource.set` or via `.value.set()`.
|
|
86
95
|
*/
|
|
@@ -91,4 +100,19 @@ export declare class ResourceImpl<T, R> extends BaseWritableResource<T> implemen
|
|
|
91
100
|
private abortInProgressLoad;
|
|
92
101
|
}
|
|
93
102
|
export declare function encapsulateResourceError(error: unknown): Error;
|
|
103
|
+
export declare function isErrorLike(error: unknown): error is Error;
|
|
104
|
+
export declare class ResourceValueError extends Error {
|
|
105
|
+
constructor(error: Error);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Chains the value of another resource into the params of the current resource, returning the value
|
|
109
|
+
* of the other resource if it is available, or propagating the status to the current resource if it
|
|
110
|
+
* is not.
|
|
111
|
+
*/
|
|
112
|
+
export declare function chain<T>(resource: Resource<T>): T;
|
|
113
|
+
export declare const paramsContext: ResourceParamsContext;
|
|
114
|
+
export declare function isInParamsFunction(): boolean;
|
|
115
|
+
export declare function setInParamsFunction(value: boolean): void;
|
|
116
|
+
export declare function invalidResourceCreationInParams(): Error;
|
|
117
|
+
export declare function rethrowFatalErrors(error: unknown): void;
|
|
94
118
|
export {};
|
|
@@ -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
|
+
/**
|
|
9
|
+
* A type-safe key to use with `TransferState`.
|
|
10
|
+
*
|
|
11
|
+
* Example:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const COUNTER_KEY = makeStateKey<number>('counter');
|
|
15
|
+
* let value = 10;
|
|
16
|
+
*
|
|
17
|
+
* transferState.set(COUNTER_KEY, value);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @publicApi
|
|
21
|
+
*/
|
|
22
|
+
export type StateKey<T> = string & {
|
|
23
|
+
__not_a_string: never;
|
|
24
|
+
__value_type?: T;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
|
|
28
|
+
*
|
|
29
|
+
* Example:
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* const COUNTER_KEY = makeStateKey<number>('counter');
|
|
33
|
+
* let value = 10;
|
|
34
|
+
*
|
|
35
|
+
* transferState.set(COUNTER_KEY, value);
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @publicApi
|
|
39
|
+
*/
|
|
40
|
+
export declare function makeStateKey<T = void>(key: string): StateKey<T>;
|
|
41
|
+
/**
|
|
42
|
+
* A key value store that is transferred from the application on the server side to the application
|
|
43
|
+
* on the client side.
|
|
44
|
+
*
|
|
45
|
+
* The `TransferState` is available as an injectable token.
|
|
46
|
+
* On the client, just inject this token using DI and use it, it will be lazily initialized.
|
|
47
|
+
* On the server it's already included if `renderApplication` function is used. Otherwise, import
|
|
48
|
+
* the `ServerTransferStateModule` module to make the `TransferState` available.
|
|
49
|
+
*
|
|
50
|
+
* The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
|
|
51
|
+
* boolean, number, string, null and non-class objects will be serialized and deserialized in a
|
|
52
|
+
* non-lossy manner.
|
|
53
|
+
*
|
|
54
|
+
* @publicApi
|
|
55
|
+
*/
|
|
56
|
+
export declare class TransferState {
|
|
57
|
+
/** @nocollapse */
|
|
58
|
+
static ɵprov: import("./di/interface/defs").ɵɵInjectableDeclaration<TransferState>;
|
|
59
|
+
private onSerializeCallbacks;
|
|
60
|
+
/**
|
|
61
|
+
* Get the value corresponding to a key. Return `defaultValue` if key is not found.
|
|
62
|
+
*/
|
|
63
|
+
get<T>(key: StateKey<T>, defaultValue: T): T;
|
|
64
|
+
/**
|
|
65
|
+
* Set the value corresponding to a key.
|
|
66
|
+
*/
|
|
67
|
+
set<T>(key: StateKey<T>, value: T): void;
|
|
68
|
+
/**
|
|
69
|
+
* Remove a key from the store.
|
|
70
|
+
*/
|
|
71
|
+
remove<T>(key: StateKey<T>): void;
|
|
72
|
+
/**
|
|
73
|
+
* Test whether a key exists in the store.
|
|
74
|
+
*/
|
|
75
|
+
hasKey<T>(key: StateKey<T>): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Indicates whether the state is empty.
|
|
78
|
+
*/
|
|
79
|
+
get isEmpty(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Register a callback to provide the value for a key when `toJson` is called.
|
|
82
|
+
*/
|
|
83
|
+
onSerialize<T>(key: StateKey<T>, callback: () => T): void;
|
|
84
|
+
/**
|
|
85
|
+
* Serialize the current state of the store to JSON.
|
|
86
|
+
*/
|
|
87
|
+
toJson(): string;
|
|
88
|
+
}
|
|
89
|
+
export declare function retrieveTransferredState(doc: Document, appId: string): Record<string, unknown | undefined>;
|
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
* Determines if the contents of two arrays is identical
|
|
10
|
+
*
|
|
11
|
+
* @param a first array
|
|
12
|
+
* @param b second array
|
|
13
|
+
* @param identityAccessor Optional function for extracting stable object identity from a value in
|
|
14
|
+
* the array.
|
|
15
|
+
*/
|
|
16
|
+
export declare function arrayEquals<T>(a: T[], b: T[], identityAccessor?: (value: T) => unknown): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Flattens an array.
|
|
19
|
+
*/
|
|
20
|
+
export declare function flatten(list: any[]): any[];
|
|
21
|
+
export declare function deepForEach<T>(input: (T | any[])[], fn: (value: T) => void): void;
|
|
22
|
+
export declare function addToArray(arr: any[], index: number, value: any): void;
|
|
23
|
+
export declare function removeFromArray(arr: any[], index: number): any;
|
|
24
|
+
export declare function newArray<T = any>(size: number): T[];
|
|
25
|
+
export declare function newArray<T>(size: number, value: T): T[];
|
|
26
|
+
/**
|
|
27
|
+
* Remove item from array (Same as `Array.splice()` but faster.)
|
|
28
|
+
*
|
|
29
|
+
* `Array.splice()` is not as fast because it has to allocate an array for the elements which were
|
|
30
|
+
* removed. This causes memory pressure and slows down code when most of the time we don't
|
|
31
|
+
* care about the deleted items array.
|
|
32
|
+
*
|
|
33
|
+
* https://jsperf.com/fast-array-splice (About 20x faster)
|
|
34
|
+
*
|
|
35
|
+
* @param array Array to splice
|
|
36
|
+
* @param index Index of element in array to remove.
|
|
37
|
+
* @param count Number of items to remove.
|
|
38
|
+
*/
|
|
39
|
+
export declare function arraySplice(array: any[], index: number, count: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Same as `Array.splice(index, 0, value)` but faster.
|
|
42
|
+
*
|
|
43
|
+
* `Array.splice()` is not fast because it has to allocate an array for the elements which were
|
|
44
|
+
* removed. This causes memory pressure and slows down code when most of the time we don't
|
|
45
|
+
* care about the deleted items array.
|
|
46
|
+
*
|
|
47
|
+
* @param array Array to splice.
|
|
48
|
+
* @param index Index in array where the `value` should be added.
|
|
49
|
+
* @param value Value to add to array.
|
|
50
|
+
*/
|
|
51
|
+
export declare function arrayInsert(array: any[], index: number, value: any): void;
|
|
52
|
+
/**
|
|
53
|
+
* Same as `Array.splice2(index, 0, value1, value2)` but faster.
|
|
54
|
+
*
|
|
55
|
+
* `Array.splice()` is not fast because it has to allocate an array for the elements which were
|
|
56
|
+
* removed. This causes memory pressure and slows down code when most of the time we don't
|
|
57
|
+
* care about the deleted items array.
|
|
58
|
+
*
|
|
59
|
+
* @param array Array to splice.
|
|
60
|
+
* @param index Index in array where the `value` should be added.
|
|
61
|
+
* @param value1 Value to add to array.
|
|
62
|
+
* @param value2 Value to add to array.
|
|
63
|
+
*/
|
|
64
|
+
export declare function arrayInsert2(array: any[], index: number, value1: any, value2: any): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get an index of an `value` in a sorted `array`.
|
|
67
|
+
*
|
|
68
|
+
* NOTE:
|
|
69
|
+
* - This uses binary search algorithm for fast removals.
|
|
70
|
+
*
|
|
71
|
+
* @param array A sorted array to binary search.
|
|
72
|
+
* @param value The value to look for.
|
|
73
|
+
* @returns index of the value.
|
|
74
|
+
* - positive index if value found.
|
|
75
|
+
* - negative index if value not found. (`~index` to get the value where it should have been
|
|
76
|
+
* located)
|
|
77
|
+
*/
|
|
78
|
+
export declare function arrayIndexOfSorted(array: string[], value: string): number;
|
|
79
|
+
/**
|
|
80
|
+
* `KeyValueArray` is an array where even positions contain keys and odd positions contain values.
|
|
81
|
+
*
|
|
82
|
+
* `KeyValueArray` provides a very efficient way of iterating over its contents. For small
|
|
83
|
+
* sets (~10) the cost of binary searching an `KeyValueArray` has about the same performance
|
|
84
|
+
* characteristics that of a `Map` with significantly better memory footprint.
|
|
85
|
+
*
|
|
86
|
+
* If used as a `Map` the keys are stored in alphabetical order so that they can be binary searched
|
|
87
|
+
* for retrieval.
|
|
88
|
+
*
|
|
89
|
+
* See: `keyValueArraySet`, `keyValueArrayGet`, `keyValueArrayIndexOf`, `keyValueArrayDelete`.
|
|
90
|
+
*/
|
|
91
|
+
export interface KeyValueArray<VALUE> extends Array<VALUE | string> {
|
|
92
|
+
__brand__: 'array-map';
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Set a `value` for a `key`.
|
|
96
|
+
*
|
|
97
|
+
* @param keyValueArray to modify.
|
|
98
|
+
* @param key The key to locate or create.
|
|
99
|
+
* @param value The value to set for a `key`.
|
|
100
|
+
* @returns index (always even) of where the value vas set.
|
|
101
|
+
*/
|
|
102
|
+
export declare function keyValueArraySet<V>(keyValueArray: KeyValueArray<V>, key: string, value: V): number;
|
|
103
|
+
/**
|
|
104
|
+
* Retrieve a `value` for a `key` (on `undefined` if not found.)
|
|
105
|
+
*
|
|
106
|
+
* @param keyValueArray to search.
|
|
107
|
+
* @param key The key to locate.
|
|
108
|
+
* @return The `value` stored at the `key` location or `undefined if not found.
|
|
109
|
+
*/
|
|
110
|
+
export declare function keyValueArrayGet<V>(keyValueArray: KeyValueArray<V>, key: string): V | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Retrieve a `key` index value in the array or `-1` if not found.
|
|
113
|
+
*
|
|
114
|
+
* @param keyValueArray to search.
|
|
115
|
+
* @param key The key to locate.
|
|
116
|
+
* @returns index of where the key is (or should have been.)
|
|
117
|
+
* - positive (even) index if key found.
|
|
118
|
+
* - negative index if key not found. (`~index` (even) to get the index where it should have
|
|
119
|
+
* been inserted.)
|
|
120
|
+
*/
|
|
121
|
+
export declare function keyValueArrayIndexOf<V>(keyValueArray: KeyValueArray<V>, key: string): number;
|
|
122
|
+
/**
|
|
123
|
+
* Delete a `key` (and `value`) from the `KeyValueArray`.
|
|
124
|
+
*
|
|
125
|
+
* @param keyValueArray to modify.
|
|
126
|
+
* @param key The key to locate or delete (if exist).
|
|
127
|
+
* @returns index of where the key was (or should have been.)
|
|
128
|
+
* - positive (even) index if key found and deleted.
|
|
129
|
+
* - negative index if key not found. (`~index` (even) to get the index where it should have
|
|
130
|
+
* been.)
|
|
131
|
+
*/
|
|
132
|
+
export declare function keyValueArrayDelete<V>(keyValueArray: KeyValueArray<V>, key: string): number;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
export declare function assertNumber(actual: any, msg: string): asserts actual is number;
|
|
9
|
+
export declare function assertNumberInRange(actual: any, minInclusive: number, maxInclusive: number): asserts actual is number;
|
|
10
|
+
export declare function assertString(actual: any, msg: string): asserts actual is string;
|
|
11
|
+
export declare function assertFunction(actual: any, msg: string): asserts actual is Function;
|
|
12
|
+
export declare function assertEqual<T>(actual: T, expected: T, msg: string): void;
|
|
13
|
+
export declare function assertNotEqual<T>(actual: T, expected: T, msg: string): asserts actual is T;
|
|
14
|
+
export declare function assertSame<T>(actual: T, expected: T, msg: string): asserts actual is T;
|
|
15
|
+
export declare function assertNotSame<T>(actual: T, expected: T, msg: string): void;
|
|
16
|
+
export declare function assertLessThan<T>(actual: T, expected: T, msg: string): asserts actual is T;
|
|
17
|
+
export declare function assertLessThanOrEqual<T>(actual: T, expected: T, msg: string): asserts actual is T;
|
|
18
|
+
export declare function assertGreaterThan<T>(actual: T, expected: T, msg: string): asserts actual is T;
|
|
19
|
+
export declare function assertGreaterThanOrEqual<T>(actual: T, expected: T, msg: string): asserts actual is T;
|
|
20
|
+
export declare function assertNotDefined<T>(actual: T, msg: string): void;
|
|
21
|
+
export declare function assertDefined<T>(actual: T | null | undefined, msg: string): asserts actual is T;
|
|
22
|
+
export declare function throwError(msg: string): never;
|
|
23
|
+
export declare function throwError(msg: string, actual: any, expected: any, comparison: string): never;
|
|
24
|
+
export declare function assertDomNode(node: any): asserts node is Node;
|
|
25
|
+
export declare function assertElement(node: any): asserts node is Element;
|
|
26
|
+
export declare function assertIndexInRange(arr: any[], index: number): void;
|
|
27
|
+
export declare function assertOneOf(value: any, ...validValues: any[]): boolean;
|
|
28
|
+
export declare function assertNotReactive(fn: string): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
* An ES Module object with a default export of the given type.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link injectAsync}
|
|
12
|
+
* @see [Route#loadComponent](/api/router/Route#loadComponent)
|
|
13
|
+
* @see [LoadChildrenCallback](/api/router/LoadChildrenCallback)
|
|
14
|
+
*
|
|
15
|
+
* @publicApi
|
|
16
|
+
*/
|
|
17
|
+
export interface DefaultExport<T> {
|
|
18
|
+
/**
|
|
19
|
+
* Default exports are bound under the name `"default"`, per the ES Module spec:
|
|
20
|
+
* https://tc39.es/ecma262/#table-export-forms-mapping-to-exportentry-records
|
|
21
|
+
*/
|
|
22
|
+
default: T;
|
|
23
|
+
}
|
|
24
|
+
export declare function maybeUnwrapDefaultExport<T>(input: T | DefaultExport<T>): T;
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
* TODO(incremental-hydration): Remove this file entirely once PromiseWithResolvers lands in stable
|
|
10
|
+
* node / TS.
|
|
11
|
+
*/
|
|
12
|
+
export interface PromiseWithResolvers<T> {
|
|
13
|
+
promise: Promise<T>;
|
|
14
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
15
|
+
reject: (reason?: any) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface PromiseConstructor {
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new Promise and returns it in an object, along with its resolve and reject functions.
|
|
20
|
+
* @returns An object with the properties `promise`, `resolve`, and `reject`.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* const { promise, resolve, reject } = Promise.withResolvers<T>();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
withResolvers<T>(): PromiseWithResolvers<T>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Replace with `Promise.withResolvers()` once it's available.
|
|
30
|
+
* NET September 2026
|
|
31
|
+
*
|
|
32
|
+
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers.
|
|
33
|
+
*/
|
|
34
|
+
export declare function promiseWithResolvers<T>(): {
|
|
35
|
+
promise: Promise<T>;
|
|
36
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
37
|
+
reject: (reason?: any) => void;
|
|
38
|
+
};
|
|
@@ -0,0 +1,261 @@
|
|
|
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 { EventEmitter } from '../event_emitter';
|
|
9
|
+
export declare const angularZoneInstanceIdProperty: string;
|
|
10
|
+
/**
|
|
11
|
+
* An injectable service for executing work inside or outside of the Angular zone.
|
|
12
|
+
*
|
|
13
|
+
* The most common use of this service is to optimize performance when starting a work consisting of
|
|
14
|
+
* one or more asynchronous tasks that don't require UI updates or error handling to be handled by
|
|
15
|
+
* Angular. Such tasks can be kicked off via {@link #runOutsideAngular} and if needed, these tasks
|
|
16
|
+
* can reenter the Angular zone via {@link #run}.
|
|
17
|
+
*
|
|
18
|
+
* <!-- TODO: add/fix links to:
|
|
19
|
+
* - docs explaining zones and the use of zones in Angular and change-detection
|
|
20
|
+
* - link to runOutsideAngular/run (throughout this file!)
|
|
21
|
+
* -->
|
|
22
|
+
*
|
|
23
|
+
* @usageNotes
|
|
24
|
+
* ### Example
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import {Component, NgZone} from '@angular/core';
|
|
28
|
+
*
|
|
29
|
+
* @Component({
|
|
30
|
+
* selector: 'ng-zone-demo',
|
|
31
|
+
* template: `
|
|
32
|
+
* <h2>Demo: NgZone</h2>
|
|
33
|
+
*
|
|
34
|
+
* <p>Progress: {{progress}}%</p>
|
|
35
|
+
* @if(progress >= 100) {
|
|
36
|
+
* <p>Done processing {{label}} of Angular zone!</p>
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* <button (click)="processWithinAngularZone()">Process within Angular zone</button>
|
|
40
|
+
* <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
|
|
41
|
+
* `,
|
|
42
|
+
* })
|
|
43
|
+
* export class NgZoneDemo {
|
|
44
|
+
* progress: number = 0;
|
|
45
|
+
* label: string;
|
|
46
|
+
*
|
|
47
|
+
* constructor(private _ngZone: NgZone) {}
|
|
48
|
+
*
|
|
49
|
+
* // Loop inside the Angular zone
|
|
50
|
+
* // so the UI DOES refresh after each setTimeout cycle
|
|
51
|
+
* processWithinAngularZone() {
|
|
52
|
+
* this.label = 'inside';
|
|
53
|
+
* this.progress = 0;
|
|
54
|
+
* this._increaseProgress(() => console.log('Inside Done!'));
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // Loop outside of the Angular zone
|
|
58
|
+
* // so the UI DOES NOT refresh after each setTimeout cycle
|
|
59
|
+
* processOutsideOfAngularZone() {
|
|
60
|
+
* this.label = 'outside';
|
|
61
|
+
* this.progress = 0;
|
|
62
|
+
* this._ngZone.runOutsideAngular(() => {
|
|
63
|
+
* this._increaseProgress(() => {
|
|
64
|
+
* // reenter the Angular zone and display done
|
|
65
|
+
* this._ngZone.run(() => { console.log('Outside Done!'); });
|
|
66
|
+
* });
|
|
67
|
+
* });
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* _increaseProgress(doneCallback: () => void) {
|
|
71
|
+
* this.progress += 1;
|
|
72
|
+
* console.log(`Current progress: ${this.progress}%`);
|
|
73
|
+
*
|
|
74
|
+
* if (this.progress < 100) {
|
|
75
|
+
* window.setTimeout(() => this._increaseProgress(doneCallback), 10);
|
|
76
|
+
* } else {
|
|
77
|
+
* doneCallback();
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @see [Resolving zone pollution](best-practices/zone-pollution#run-tasks-outside-ngzone)
|
|
84
|
+
*
|
|
85
|
+
* @publicApi
|
|
86
|
+
*/
|
|
87
|
+
export declare class NgZone {
|
|
88
|
+
readonly hasPendingMacrotasks: boolean;
|
|
89
|
+
readonly hasPendingMicrotasks: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Whether there are no outstanding microtasks or macrotasks.
|
|
92
|
+
*/
|
|
93
|
+
readonly isStable: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Notifies when code enters Angular Zone. This gets fired first on VM Turn.
|
|
96
|
+
*/
|
|
97
|
+
readonly onUnstable: EventEmitter<any>;
|
|
98
|
+
/**
|
|
99
|
+
* Notifies when there is no more microtasks enqueued in the current VM Turn.
|
|
100
|
+
* This is a hint for Angular to do change detection, which may enqueue more microtasks.
|
|
101
|
+
* For this reason this event can fire multiple times per VM Turn.
|
|
102
|
+
*/
|
|
103
|
+
readonly onMicrotaskEmpty: EventEmitter<any>;
|
|
104
|
+
/**
|
|
105
|
+
* Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
|
|
106
|
+
* implies we are about to relinquish VM turn.
|
|
107
|
+
* This event gets called just once.
|
|
108
|
+
*/
|
|
109
|
+
readonly onStable: EventEmitter<any>;
|
|
110
|
+
/**
|
|
111
|
+
* Notifies that an error has been delivered.
|
|
112
|
+
*/
|
|
113
|
+
readonly onError: EventEmitter<any>;
|
|
114
|
+
constructor(options: {
|
|
115
|
+
enableLongStackTrace?: boolean;
|
|
116
|
+
shouldCoalesceEventChangeDetection?: boolean;
|
|
117
|
+
shouldCoalesceRunChangeDetection?: boolean;
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
This method checks whether the method call happens within an Angular Zone instance.
|
|
121
|
+
*/
|
|
122
|
+
/**
|
|
123
|
+
Assures that the method is called within the Angular Zone, otherwise throws an error.
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
Assures that the method is called outside of the Angular Zone, otherwise throws an error.
|
|
127
|
+
*/
|
|
128
|
+
/**
|
|
129
|
+
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
|
|
130
|
+
* the function.
|
|
131
|
+
*
|
|
132
|
+
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
|
|
133
|
+
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
|
|
134
|
+
*
|
|
135
|
+
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
|
136
|
+
* within the Angular zone.
|
|
137
|
+
*
|
|
138
|
+
* If a synchronous error happens it will be rethrown and not reported via `onError`.
|
|
139
|
+
*/
|
|
140
|
+
run<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[]): T;
|
|
141
|
+
/**
|
|
142
|
+
* Executes the `fn` function synchronously within the Angular zone as a task and returns value
|
|
143
|
+
* returned by the function.
|
|
144
|
+
*
|
|
145
|
+
* Running functions via `runTask` allows you to reenter Angular zone from a task that was executed
|
|
146
|
+
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
|
|
147
|
+
*
|
|
148
|
+
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
|
149
|
+
* within the Angular zone.
|
|
150
|
+
*
|
|
151
|
+
* If a synchronous error happens it will be rethrown and not reported via `onError`.
|
|
152
|
+
*/
|
|
153
|
+
runTask<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[], name?: string): T;
|
|
154
|
+
/**
|
|
155
|
+
* Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
|
|
156
|
+
* rethrown.
|
|
157
|
+
*/
|
|
158
|
+
runGuarded<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[]): T;
|
|
159
|
+
/**
|
|
160
|
+
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
|
|
161
|
+
* the function.
|
|
162
|
+
*
|
|
163
|
+
* Running functions via {@link #runOutsideAngular} allows you to escape Angular's zone and do
|
|
164
|
+
* work that
|
|
165
|
+
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
|
|
166
|
+
*
|
|
167
|
+
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
|
168
|
+
* outside of the Angular zone.
|
|
169
|
+
*
|
|
170
|
+
* Use {@link #run} to reenter the Angular zone and do work that updates the application model.
|
|
171
|
+
*/
|
|
172
|
+
runOutsideAngular<T>(fn: (...args: any[]) => T): T; /** @nocollapse */
|
|
173
|
+
static ɵprov /**
|
|
174
|
+
@pureOrBreakMyCode */: import("../di/interface/defs").ɵɵInjectableDeclaration<NoopNgZone>;
|
|
175
|
+
}
|
|
176
|
+
export interface NgZonePrivate extends NgZone {
|
|
177
|
+
_outer: Zone;
|
|
178
|
+
_inner: Zone;
|
|
179
|
+
_nesting: number;
|
|
180
|
+
_hasPendingMicrotasks: boolean;
|
|
181
|
+
hasPendingMacrotasks: boolean;
|
|
182
|
+
hasPendingMicrotasks: boolean;
|
|
183
|
+
callbackScheduled: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* A flag to indicate if NgZone is currently inside
|
|
186
|
+
* checkStable and to prevent re-entry. The flag is
|
|
187
|
+
* needed because it is possible to invoke the change
|
|
188
|
+
* detection from within change detection leading to
|
|
189
|
+
* incorrect behavior.
|
|
190
|
+
*
|
|
191
|
+
* For detail, please refer here,
|
|
192
|
+
* https://github.com/angular/angular/pull/40540
|
|
193
|
+
*/
|
|
194
|
+
isCheckStableRunning: boolean;
|
|
195
|
+
isStable: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Optionally specify coalescing event change detections or not.
|
|
198
|
+
* Consider the following case.
|
|
199
|
+
*
|
|
200
|
+
* <div (click)="doSomething()">
|
|
201
|
+
* <button (click)="doSomethingElse()"></button>
|
|
202
|
+
* </div>
|
|
203
|
+
*
|
|
204
|
+
* When button is clicked, because of the event bubbling, both
|
|
205
|
+
* event handlers will be called and 2 change detections will be
|
|
206
|
+
* triggered. We can coalesce such kind of events to trigger
|
|
207
|
+
* change detection only once.
|
|
208
|
+
*
|
|
209
|
+
* By default, this option will be false. So the events will not be
|
|
210
|
+
* coalesced and the change detection will be triggered multiple times.
|
|
211
|
+
* And if this option be set to true, the change detection will be
|
|
212
|
+
* triggered async by scheduling it in an animation frame. So in the case above,
|
|
213
|
+
* the change detection will only be trigged once.
|
|
214
|
+
*/
|
|
215
|
+
shouldCoalesceEventChangeDetection: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Optionally specify if `NgZone#run()` method invocations should be coalesced
|
|
218
|
+
* into a single change detection.
|
|
219
|
+
*
|
|
220
|
+
* Consider the following case.
|
|
221
|
+
*
|
|
222
|
+
* for (let i = 0; i < 10; i ++) {
|
|
223
|
+
* ngZone.run(() => {
|
|
224
|
+
* // do something
|
|
225
|
+
* });
|
|
226
|
+
* }
|
|
227
|
+
*
|
|
228
|
+
* This case triggers the change detection multiple times.
|
|
229
|
+
* With ngZoneRunCoalescing options, all change detections in an event loops trigger only once.
|
|
230
|
+
* In addition, the change detection executes in requestAnimation.
|
|
231
|
+
*
|
|
232
|
+
*/
|
|
233
|
+
shouldCoalesceRunChangeDetection: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Whether to schedule the coalesced change detection in the root zone
|
|
236
|
+
*/
|
|
237
|
+
scheduleInRootZone: boolean;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Provides a noop implementation of `NgZone` which does nothing. This zone requires explicit calls
|
|
241
|
+
* to framework to perform rendering.
|
|
242
|
+
*/
|
|
243
|
+
export declare class NoopNgZone implements NgZone {
|
|
244
|
+
readonly hasPendingMicrotasks = false;
|
|
245
|
+
readonly hasPendingMacrotasks = false;
|
|
246
|
+
readonly isStable = true;
|
|
247
|
+
readonly onUnstable: EventEmitter<any>;
|
|
248
|
+
readonly onMicrotaskEmpty: EventEmitter<any>;
|
|
249
|
+
readonly onStable: EventEmitter<any>;
|
|
250
|
+
readonly onError: EventEmitter<any>;
|
|
251
|
+
run<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any): T;
|
|
252
|
+
runGuarded<T>(fn: (...args: any[]) => any, applyThis?: any, applyArgs?: any): T;
|
|
253
|
+
runOutsideAngular<T>(fn: (...args: any[]) => T): T;
|
|
254
|
+
runTask<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any, name?: string): T;
|
|
255
|
+
}
|
|
256
|
+
export interface InternalNgZoneOptions {
|
|
257
|
+
enableLongStackTrace?: boolean;
|
|
258
|
+
shouldCoalesceEventChangeDetection?: boolean;
|
|
259
|
+
shouldCoalesceRunChangeDetection?: boolean;
|
|
260
|
+
scheduleInRootZone?: boolean;
|
|
261
|
+
}
|