static-injector 6.3.0 → 6.4.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/di/index.d.ts +1 -0
- package/import/render3/debug/injector_profiler.d.ts +133 -0
- package/import/render3/errors_di.d.ts +25 -0
- package/import/render3/util/stringify_utils.d.ts +21 -0
- package/import/util/array_utils.d.ts +132 -0
- package/import/util/assert.d.ts +28 -0
- package/index.js +1502 -1142
- package/index.js.map +4 -4
- package/index.mjs +1502 -1142
- package/index.mjs.map +4 -4
- package/package.json +2 -2
package/import/di/index.d.ts
CHANGED
|
@@ -0,0 +1,133 @@
|
|
|
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 { EffectRef } 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 Angular DI system is about to create an instance corresponding to a given token.
|
|
36
|
+
*/
|
|
37
|
+
InjectorToCreateInstanceEvent = 4
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An object that defines an injection context for the injector profiler.
|
|
41
|
+
*/
|
|
42
|
+
export interface InjectorProfilerContext {
|
|
43
|
+
}
|
|
44
|
+
export interface InjectedServiceEvent {
|
|
45
|
+
}
|
|
46
|
+
export interface InjectorToCreateInstanceEvent {
|
|
47
|
+
}
|
|
48
|
+
export interface InjectorCreatedInstanceEvent {
|
|
49
|
+
}
|
|
50
|
+
export interface ProviderConfiguredEvent {
|
|
51
|
+
}
|
|
52
|
+
export interface EffectCreatedEvent {
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* An object representing an event that is emitted through the injector profiler
|
|
56
|
+
*/
|
|
57
|
+
export type InjectorProfilerEvent = InjectedServiceEvent | InjectorToCreateInstanceEvent | InjectorCreatedInstanceEvent | ProviderConfiguredEvent | EffectCreatedEvent;
|
|
58
|
+
/**
|
|
59
|
+
* An object that contains information about a provider that has been configured
|
|
60
|
+
*
|
|
61
|
+
* TODO: rename to indicate that it is a debug structure eg. ProviderDebugInfo.
|
|
62
|
+
*/
|
|
63
|
+
export interface ProviderRecord {
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* An object that contains information about a value that has been constructed within an injector
|
|
67
|
+
*/
|
|
68
|
+
export interface InjectorCreatedInstance {
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* An object that contains information a service that has been injected within an
|
|
72
|
+
* InjectorProfilerContext
|
|
73
|
+
*/
|
|
74
|
+
export interface InjectedService {
|
|
75
|
+
/**
|
|
76
|
+
* In NodeInjectors, the LView and TNode that serviced this injection.
|
|
77
|
+
*/
|
|
78
|
+
injectedIn?: {};
|
|
79
|
+
}
|
|
80
|
+
export interface InjectorProfiler {
|
|
81
|
+
(event: InjectorProfilerEvent): void;
|
|
82
|
+
}
|
|
83
|
+
export declare function getInjectorProfilerContext(): InjectorProfilerContext;
|
|
84
|
+
export declare function setInjectorProfilerContext(context: InjectorProfilerContext): InjectorProfilerContext;
|
|
85
|
+
/**
|
|
86
|
+
* Adds a callback function which will be invoked during certain DI events within the
|
|
87
|
+
* runtime (for example: injecting services, creating injectable instances, configuring providers).
|
|
88
|
+
* Multiple profiler callbacks can be set: in this case profiling events are
|
|
89
|
+
* reported to every registered callback.
|
|
90
|
+
*
|
|
91
|
+
* Warning: this function is *INTERNAL* and should not be relied upon in application's code.
|
|
92
|
+
* The contract of the function might be changed in any release and/or the function can be removed
|
|
93
|
+
* completely.
|
|
94
|
+
*
|
|
95
|
+
* @param profiler function provided by the caller or null value to disable profiling.
|
|
96
|
+
* @returns a cleanup function that, when invoked, removes a given profiler callback.
|
|
97
|
+
*/
|
|
98
|
+
export declare function setInjectorProfiler(injectorProfiler: InjectorProfiler | null): () => void;
|
|
99
|
+
/**
|
|
100
|
+
* Injector profiler function which emits on DI events executed by the runtime.
|
|
101
|
+
*
|
|
102
|
+
* @param event InjectorProfilerEvent corresponding to the DI event being emitted
|
|
103
|
+
*/
|
|
104
|
+
export declare function injectorProfiler(event: InjectorProfilerEvent): void;
|
|
105
|
+
/**
|
|
106
|
+
* Emits an InjectorProfilerEventType.ProviderConfigured to the injector profiler. The data in the
|
|
107
|
+
* emitted event includes the raw provider, as well as the token that provider is providing.
|
|
108
|
+
*
|
|
109
|
+
* @param eventProvider A provider object
|
|
110
|
+
*/
|
|
111
|
+
export declare function emitProviderConfiguredEvent(eventProvider: SingleProvider, isViewProvider?: boolean): void;
|
|
112
|
+
/**
|
|
113
|
+
* 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
|
|
114
|
+
* the injector associated with this emission can be accessed by using getDebugInjectContext()
|
|
115
|
+
*
|
|
116
|
+
* @param instance an object created by an injector
|
|
117
|
+
*/
|
|
118
|
+
export declare function emitInjectorToCreateInstanceEvent(token: ProviderToken<unknown>): void;
|
|
119
|
+
/**
|
|
120
|
+
* Emits an event to the injector profiler with the instance that was created. Note that
|
|
121
|
+
* the injector associated with this emission can be accessed by using getDebugInjectContext()
|
|
122
|
+
*
|
|
123
|
+
* @param instance an object created by an injector
|
|
124
|
+
*/
|
|
125
|
+
export declare function emitInstanceCreatedByInjectorEvent(instance: unknown): void;
|
|
126
|
+
/**
|
|
127
|
+
* @param token DI token associated with injected service
|
|
128
|
+
* @param value the instance of the injected service (i.e the result of `inject(token)`)
|
|
129
|
+
* @param flags the flags that the token was injected with
|
|
130
|
+
*/
|
|
131
|
+
export declare function emitInjectEvent(token: Type<unknown>, value: unknown, flags: InternalInjectFlags): void;
|
|
132
|
+
export declare function emitEffectCreatedEvent(effect: EffectRef): void;
|
|
133
|
+
export declare function runInInjectorProfilerContext(injector: Injector, token: Type<unknown>, callback: () => void): void;
|
|
@@ -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
|
|
@@ -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: any): 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;
|
|
@@ -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;
|