static-injector 2.1.0 → 2.1.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/commonjs/index.js +419 -157
- package/import/es2015/di/create_injector.js +5 -1
- package/import/es2015/di/forward_ref.js +3 -3
- package/import/es2015/di/injection_token.js +18 -11
- package/import/es2015/di/injector_compatibility.js +19 -10
- package/import/es2015/di/injector_token.js +3 -3
- package/import/es2015/di/interface/defs.js +21 -12
- package/import/es2015/di/interface/provider.js +3 -1
- package/import/es2015/di/null_injector.js +3 -3
- package/import/es2015/di/provider_collection.js +196 -1
- package/import/es2015/di/r3_injector.js +25 -22
- package/import/es2015/error_details_base_url.js +19 -0
- package/import/es2015/errors.js +42 -0
- package/import/es2015/interface/type.js +14 -1
- package/import/es2015/render3/definition_factory.js +2 -3
- package/import/es2015/render3/errors_di.js +2 -3
- package/import/es2015/render3/instructions/di.js +0 -7
- package/import/es2015/render3/util/stringify_utils.js +5 -5
- package/import/es2015/util/array_utils.js +0 -7
- package/import/es2015/util/decorators.js +24 -1
- package/import/es2015/util/empty.js +4 -0
- package/import/es2015/util/stringify.js +5 -5
- package/import/fesm2015/index.js +416 -155
- package/import/typings/di/forward_ref.d.ts +1 -1
- package/import/typings/di/injectable.d.ts +4 -3
- package/import/typings/di/injection_token.d.ts +21 -6
- package/import/typings/di/injector.d.ts +16 -0
- package/import/typings/di/injector_compatibility.d.ts +11 -5
- package/import/typings/di/injector_token.d.ts +2 -2
- package/import/typings/di/interface/defs.d.ts +15 -8
- package/import/typings/di/interface/provider.d.ts +60 -0
- package/import/typings/di/null_injector.d.ts +1 -1
- package/import/typings/di/provider_collection.d.ts +54 -1
- package/import/typings/di/provider_token.d.ts +2 -2
- package/import/typings/di/r3_injector.d.ts +3 -8
- package/import/typings/error_details_base_url.d.ts +19 -0
- package/import/typings/errors.d.ts +89 -0
- package/import/typings/interface/type.d.ts +45 -0
- package/import/typings/render3/errors_di.d.ts +7 -0
- package/import/typings/render3/instructions/di.d.ts +0 -7
- package/import/typings/util/array_utils.d.ts +15 -7
- package/import/typings/util/decorators.d.ts +2 -1
- package/import/typings/util/empty.d.ts +1 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
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.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { Type } from
|
|
8
|
+
import { Type } from '../interface/type';
|
|
9
9
|
/**
|
|
10
10
|
* An interface that a function passed into {@link forwardRef} has to implement.
|
|
11
11
|
*
|
|
@@ -5,9 +5,9 @@
|
|
|
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.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { ValueSansProvider, ExistingSansProvider, StaticClassSansProvider, ConstructorSansProvider, FactorySansProvider, ClassSansProvider } from './interface/provider';
|
|
9
8
|
import { Type } from '../interface/type';
|
|
10
9
|
import { TypeDecorator } from '../util/decorators';
|
|
10
|
+
import { ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueSansProvider } from './interface/provider';
|
|
11
11
|
/**
|
|
12
12
|
* Injectable providers used in `@Injectable` decorator.
|
|
13
13
|
*
|
|
@@ -57,7 +57,8 @@ export interface Injectable {
|
|
|
57
57
|
/**
|
|
58
58
|
* Determines which injectors will provide the injectable.
|
|
59
59
|
*
|
|
60
|
-
* - `Type<any>` - associates the injectable with an `@NgModule` or other `InjectorType
|
|
60
|
+
* - `Type<any>` - associates the injectable with an `@NgModule` or other `InjectorType`. This
|
|
61
|
+
* option is DEPRECATED.
|
|
61
62
|
* - 'null' : Equivalent to `undefined`. The injectable is not provided in any scope automatically
|
|
62
63
|
* and must be added to a `providers` array of an [@NgModule](api/core/NgModule#providers),
|
|
63
64
|
* [@Component](api/core/Directive#providers) or [@Directive](api/core/Directive#providers).
|
|
@@ -68,7 +69,7 @@ export interface Injectable {
|
|
|
68
69
|
* - 'platform' : A special singleton platform injector shared by all
|
|
69
70
|
* applications on the page.
|
|
70
71
|
* - 'any' : Provides a unique instance in each lazy loaded module while all eagerly loaded
|
|
71
|
-
* modules share one instance.
|
|
72
|
+
* modules share one instance. This option is DEPRECATED.
|
|
72
73
|
*
|
|
73
74
|
*/
|
|
74
75
|
providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
|
|
@@ -14,11 +14,11 @@ import { Type } from '../interface/type';
|
|
|
14
14
|
* parameterized type.
|
|
15
15
|
*
|
|
16
16
|
* `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
|
|
17
|
-
* the `Injector`. This provides additional level of type safety.
|
|
17
|
+
* the `Injector`. This provides an additional level of type safety.
|
|
18
18
|
*
|
|
19
19
|
* ```
|
|
20
20
|
* interface MyInterface {...}
|
|
21
|
-
*
|
|
21
|
+
* const myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
|
|
22
22
|
* // myInterface is inferred to be MyInterface.
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
@@ -26,14 +26,18 @@ import { Type } from '../interface/type';
|
|
|
26
26
|
* (possibly by creating) a default value of the parameterized type `T`. This sets up the
|
|
27
27
|
* `InjectionToken` using this factory as a provider as if it was defined explicitly in the
|
|
28
28
|
* application's root injector. If the factory function, which takes zero arguments, needs to inject
|
|
29
|
-
* dependencies, it can do so using the `inject` function.
|
|
29
|
+
* dependencies, it can do so using the `inject` function.
|
|
30
|
+
* As you can see in the Tree-shakable InjectionToken example below.
|
|
30
31
|
*
|
|
31
32
|
* Additionally, if a `factory` is specified you can also specify the `providedIn` option, which
|
|
32
|
-
* overrides the above behavior and marks the token as belonging to a particular `@NgModule
|
|
33
|
-
* mentioned above, `'root'` is the default value for
|
|
33
|
+
* overrides the above behavior and marks the token as belonging to a particular `@NgModule` (note:
|
|
34
|
+
* this option is now deprecated). As mentioned above, `'root'` is the default value for
|
|
35
|
+
* `providedIn`.
|
|
36
|
+
*
|
|
37
|
+
* The `providedIn: NgModule` and `providedIn: 'any'` options are deprecated.
|
|
34
38
|
*
|
|
35
39
|
* @usageNotes
|
|
36
|
-
* ### Basic
|
|
40
|
+
* ### Basic Examples
|
|
37
41
|
*
|
|
38
42
|
* ### Plain InjectionToken
|
|
39
43
|
*
|
|
@@ -48,7 +52,15 @@ import { Type } from '../interface/type';
|
|
|
48
52
|
*/
|
|
49
53
|
export declare class InjectionToken<T> {
|
|
50
54
|
protected _desc: string;
|
|
55
|
+
/** @internal */
|
|
56
|
+
readonly ngMetadataName = "InjectionToken";
|
|
51
57
|
readonly ɵprov: unknown;
|
|
58
|
+
/**
|
|
59
|
+
* @param _desc Description for the token,
|
|
60
|
+
* used only for debugging purposes,
|
|
61
|
+
* it should but does not need to be unique
|
|
62
|
+
* @param options Options for the token's usage, as described above
|
|
63
|
+
*/
|
|
52
64
|
constructor(_desc: string, options?: {
|
|
53
65
|
providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
|
|
54
66
|
factory: () => T;
|
|
@@ -59,3 +71,6 @@ export declare class InjectionToken<T> {
|
|
|
59
71
|
get multi(): InjectionToken<Array<T>>;
|
|
60
72
|
toString(): string;
|
|
61
73
|
}
|
|
74
|
+
export interface InjectableDefToken<T> extends InjectionToken<T> {
|
|
75
|
+
ɵprov: unknown;
|
|
76
|
+
}
|
|
@@ -62,6 +62,22 @@ export declare abstract class Injector {
|
|
|
62
62
|
* @throws When the `notFoundValue` is `undefined` or `Injector.THROW_IF_NOT_FOUND`.
|
|
63
63
|
*/
|
|
64
64
|
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions | InjectFlags): T;
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves an instance from the injector based on the provided token.
|
|
67
|
+
* @returns The instance from the injector if defined, otherwise the `notFoundValue`.
|
|
68
|
+
* @throws When the `notFoundValue` is `undefined` or `Injector.THROW_IF_NOT_FOUND`.
|
|
69
|
+
* @deprecated use object-based flags (`InjectOptions`) instead.
|
|
70
|
+
*/
|
|
71
|
+
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated from v4.0.0 use ProviderToken<T>
|
|
74
|
+
* @suppress {duplicate}
|
|
75
|
+
*/
|
|
76
|
+
abstract get(token: any, notFoundValue?: any): any;
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated from v5 use the new signature Injector.create(options)
|
|
79
|
+
*/
|
|
80
|
+
static create(providers: StaticProvider[], parent?: Injector): Injector;
|
|
65
81
|
/**
|
|
66
82
|
* Creates a new injector instance that provides one or more dependencies,
|
|
67
83
|
* according to a given type or types of `StaticProvider`.
|
|
@@ -11,15 +11,11 @@ import { ProviderToken } from './provider_token';
|
|
|
11
11
|
export declare const THROW_IF_NOT_FOUND: {};
|
|
12
12
|
export declare const NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
|
|
13
13
|
export declare const SOURCE = "__source";
|
|
14
|
-
export declare const USE_VALUE: string;
|
|
15
14
|
export declare function setCurrentInjector(injector: Injector | null | undefined): Injector | undefined | null;
|
|
16
15
|
export declare function injectInjectorOnly<T>(token: ProviderToken<T>): T;
|
|
17
16
|
export declare function injectInjectorOnly<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
|
|
18
17
|
/**
|
|
19
|
-
* Generated instruction:
|
|
20
|
-
*
|
|
21
|
-
* Must be used in the context of a factory function such as one defined for an
|
|
22
|
-
* `InjectionToken`. Throws an error if not called from such a context.
|
|
18
|
+
* Generated instruction: injects a token from the currently active injector.
|
|
23
19
|
*
|
|
24
20
|
* (Additional documentation moved to `inject`, as it is the public API, and an alias for this
|
|
25
21
|
* instruction)
|
|
@@ -30,6 +26,16 @@ export declare function injectInjectorOnly<T>(token: ProviderToken<T>, flags?: I
|
|
|
30
26
|
*/
|
|
31
27
|
export declare function ɵɵinject<T>(token: ProviderToken<T>): T;
|
|
32
28
|
export declare function ɵɵinject<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
|
|
29
|
+
/**
|
|
30
|
+
* Throws an error indicating that a factory function could not be generated by the compiler for a
|
|
31
|
+
* particular class.
|
|
32
|
+
*
|
|
33
|
+
* The name of the class is not mentioned here, but will be in the generated factory function name
|
|
34
|
+
* and thus in the stack trace.
|
|
35
|
+
*
|
|
36
|
+
* @codeGenApi
|
|
37
|
+
*/
|
|
38
|
+
export declare function ɵɵinvalidFactoryDep(index: number): void;
|
|
33
39
|
/**
|
|
34
40
|
* @param token A token that represents a dependency that should be injected.
|
|
35
41
|
* @returns the injected value if operation is successful, `null` otherwise.
|
|
@@ -5,8 +5,8 @@
|
|
|
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.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { InjectionToken } from
|
|
9
|
-
import { Injector } from
|
|
8
|
+
import { InjectionToken } from './injection_token';
|
|
9
|
+
import { Injector } from './injector';
|
|
10
10
|
/**
|
|
11
11
|
* An InjectionToken that gets the current `Injector` for `createInjector()`-style injectors.
|
|
12
12
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import { Type } from '../../interface/type';
|
|
9
|
-
import { ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, ValueProvider } from './provider';
|
|
9
|
+
import { ClassProvider, ConstructorProvider, EnvironmentProviders, ExistingProvider, FactoryProvider, StaticClassProvider, ValueProvider } from './provider';
|
|
10
10
|
/**
|
|
11
11
|
* Information about how a type or `InjectionToken` interfaces with the DI system.
|
|
12
12
|
*
|
|
@@ -31,7 +31,7 @@ export interface ɵɵInjectableDeclaration<T> {
|
|
|
31
31
|
* - `null`, does not belong to any injector. Must be explicitly listed in the injector
|
|
32
32
|
* `providers`.
|
|
33
33
|
*/
|
|
34
|
-
providedIn: InjectorType<any> | 'root' | 'platform' | 'any' | null;
|
|
34
|
+
providedIn: InjectorType<any> | 'root' | 'platform' | 'any' | 'environment' | null;
|
|
35
35
|
/**
|
|
36
36
|
* The token to which this definition belongs.
|
|
37
37
|
*
|
|
@@ -60,14 +60,14 @@ export interface ɵɵInjectableDeclaration<T> {
|
|
|
60
60
|
* @codeGenApi
|
|
61
61
|
*/
|
|
62
62
|
export interface ɵɵInjectorDef<T> {
|
|
63
|
-
providers: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
|
|
63
|
+
providers: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | EnvironmentProviders | any[])[];
|
|
64
64
|
imports: (InjectorType<any> | InjectorTypeWithProviders<any>)[];
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* A `Type` which has a `ɵprov: ɵɵInjectableDeclaration` static field.
|
|
68
68
|
*
|
|
69
69
|
* `InjectableType`s contain their own Dependency Injection metadata and are usable in an
|
|
70
|
-
* `InjectorDef`-based `StaticInjector
|
|
70
|
+
* `InjectorDef`-based `StaticInjector`.
|
|
71
71
|
*
|
|
72
72
|
* @publicApi
|
|
73
73
|
*/
|
|
@@ -100,7 +100,7 @@ export interface InjectorType<T> extends Type<T> {
|
|
|
100
100
|
*/
|
|
101
101
|
export interface InjectorTypeWithProviders<T> {
|
|
102
102
|
ngModule: InjectorType<T>;
|
|
103
|
-
providers?: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
|
|
103
|
+
providers?: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | EnvironmentProviders | any[])[];
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* Construct an injectable definition which defines how a token will be constructed by the DI
|
|
@@ -121,7 +121,7 @@ export interface InjectorTypeWithProviders<T> {
|
|
|
121
121
|
*/
|
|
122
122
|
export declare function ɵɵdefineInjectable<T>(opts: {
|
|
123
123
|
token: unknown;
|
|
124
|
-
providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
|
|
124
|
+
providedIn?: Type<any> | 'root' | 'platform' | 'any' | 'environment' | null;
|
|
125
125
|
factory: () => T;
|
|
126
126
|
}): unknown;
|
|
127
127
|
/**
|
|
@@ -152,7 +152,7 @@ export declare function ɵɵdefineInjector(options: {
|
|
|
152
152
|
* @param type A type which may have its own (non-inherited) `ɵprov`.
|
|
153
153
|
*/
|
|
154
154
|
export declare function getInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T> | null;
|
|
155
|
-
export declare
|
|
155
|
+
export declare function isInjectable(type: any): boolean;
|
|
156
156
|
/**
|
|
157
157
|
* Read the injectable def (`ɵprov`) for `type` or read the `ɵprov` from one of its ancestors.
|
|
158
158
|
*
|
|
@@ -162,4 +162,11 @@ export declare const NG_PROV_DEF: string;
|
|
|
162
162
|
* scenario if we find the `ɵprov` on an ancestor only.
|
|
163
163
|
*/
|
|
164
164
|
export declare function getInheritedInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T> | null;
|
|
165
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Read the injector def type in a way which is immune to accidentally reading inherited value.
|
|
167
|
+
*
|
|
168
|
+
* @param type type which may have an injector def (`ɵinj`)
|
|
169
|
+
*/
|
|
170
|
+
export declare function getInjectorDef<T>(type: any): ɵɵInjectorDef<T> | null;
|
|
171
|
+
export declare const NG_PROV_DEF: string;
|
|
172
|
+
export declare const NG_INJ_DEF: string;
|
|
@@ -305,3 +305,63 @@ export interface ClassProvider extends ClassSansProvider {
|
|
|
305
305
|
* @publicApi
|
|
306
306
|
*/
|
|
307
307
|
export type Provider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | any[];
|
|
308
|
+
/**
|
|
309
|
+
* Encapsulated `Provider`s that are only accepted during creation of an `EnvironmentInjector` (e.g.
|
|
310
|
+
* in an `NgModule`).
|
|
311
|
+
*
|
|
312
|
+
* Using this wrapper type prevents providers which are only designed to work in
|
|
313
|
+
* application/environment injectors from being accidentally included in
|
|
314
|
+
* `@Component.providers` and ending up in a component injector.
|
|
315
|
+
*
|
|
316
|
+
* This wrapper type prevents access to the `Provider`s inside.
|
|
317
|
+
*
|
|
318
|
+
* @see `makeEnvironmentProviders`
|
|
319
|
+
* @see `importProvidersFrom`
|
|
320
|
+
*
|
|
321
|
+
* @publicApi
|
|
322
|
+
*/
|
|
323
|
+
export type EnvironmentProviders = {
|
|
324
|
+
ɵbrand: 'EnvironmentProviders';
|
|
325
|
+
};
|
|
326
|
+
export interface InternalEnvironmentProviders extends EnvironmentProviders {
|
|
327
|
+
ɵproviders: (Provider | EnvironmentProviders)[];
|
|
328
|
+
/**
|
|
329
|
+
* If present, indicates that the `EnvironmentProviders` were derived from NgModule providers.
|
|
330
|
+
*
|
|
331
|
+
* This is used to produce clearer error messages.
|
|
332
|
+
*/
|
|
333
|
+
ɵfromNgModule?: true;
|
|
334
|
+
}
|
|
335
|
+
export declare function isEnvironmentProviders(value: Provider | EnvironmentProviders | InternalEnvironmentProviders): value is InternalEnvironmentProviders;
|
|
336
|
+
/**
|
|
337
|
+
* Describes a function that is used to process provider lists (such as provider
|
|
338
|
+
* overrides).
|
|
339
|
+
*/
|
|
340
|
+
export type ProcessProvidersFunction = (providers: Provider[]) => Provider[];
|
|
341
|
+
/**
|
|
342
|
+
* A wrapper around an NgModule that associates it with [providers](guide/glossary#provider
|
|
343
|
+
* "Definition"). Usage without a generic type is deprecated.
|
|
344
|
+
*
|
|
345
|
+
* @see [Deprecations](guide/deprecations#modulewithproviders-type-without-a-generic)
|
|
346
|
+
*
|
|
347
|
+
* @publicApi
|
|
348
|
+
*/
|
|
349
|
+
export interface ModuleWithProviders<T> {
|
|
350
|
+
ngModule: Type<T>;
|
|
351
|
+
providers?: Array<Provider | EnvironmentProviders>;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Providers that were imported from NgModules via the `importProvidersFrom` function.
|
|
355
|
+
*
|
|
356
|
+
* These providers are meant for use in an application injector (or other environment injectors) and
|
|
357
|
+
* should not be used in component injectors.
|
|
358
|
+
*
|
|
359
|
+
* This type cannot be directly implemented. It's returned from the `importProvidersFrom` function
|
|
360
|
+
* and serves to prevent the extracted NgModule providers from being used in the wrong contexts.
|
|
361
|
+
*
|
|
362
|
+
* @see `importProvidersFrom`
|
|
363
|
+
*
|
|
364
|
+
* @publicApi
|
|
365
|
+
* @deprecated replaced by `EnvironmentProviders`
|
|
366
|
+
*/
|
|
367
|
+
export type ImportedNgModuleProviders = EnvironmentProviders;
|
|
@@ -5,7 +5,7 @@
|
|
|
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.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { Injector } from
|
|
8
|
+
import { Injector } from './injector';
|
|
9
9
|
export declare class NullInjector implements Injector {
|
|
10
10
|
get(token: any, notFoundValue?: any): any;
|
|
11
11
|
}
|
|
@@ -7,7 +7,60 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Type } from '../interface/type';
|
|
9
9
|
import { InjectorTypeWithProviders } from './interface/defs';
|
|
10
|
-
import { ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, TypeProvider, ValueProvider } from './interface/provider';
|
|
10
|
+
import { ClassProvider, ConstructorProvider, EnvironmentProviders, ExistingProvider, FactoryProvider, ModuleWithProviders, Provider, StaticClassProvider, TypeProvider, ValueProvider } from './interface/provider';
|
|
11
|
+
/**
|
|
12
|
+
* Wrap an array of `Provider`s into `EnvironmentProviders`, preventing them from being accidentally
|
|
13
|
+
* referenced in `@Component in a component injector.
|
|
14
|
+
*/
|
|
15
|
+
export declare function makeEnvironmentProviders(providers: (Provider | EnvironmentProviders)[]): EnvironmentProviders;
|
|
16
|
+
/**
|
|
17
|
+
* A source of providers for the `importProvidersFrom` function.
|
|
18
|
+
*
|
|
19
|
+
* @publicApi
|
|
20
|
+
*/
|
|
21
|
+
export type ImportProvidersSource = Type<unknown> | ModuleWithProviders<unknown> | Array<ImportProvidersSource>;
|
|
22
|
+
/**
|
|
23
|
+
* Collects providers from all NgModules and standalone components, including transitively imported
|
|
24
|
+
* ones.
|
|
25
|
+
*
|
|
26
|
+
* Providers extracted via `importProvidersFrom` are only usable in an application injector or
|
|
27
|
+
* another environment injector (such as a route injector). They should not be used in component
|
|
28
|
+
* providers.
|
|
29
|
+
*
|
|
30
|
+
* More information about standalone components can be found in [this
|
|
31
|
+
* guide](guide/standalone-components).
|
|
32
|
+
*
|
|
33
|
+
* @usageNotes
|
|
34
|
+
* The results of the `importProvidersFrom` call can be used in the `bootstrapApplication` call:
|
|
35
|
+
*
|
|
36
|
+
* ```typescript
|
|
37
|
+
* await bootstrapApplication(RootComponent, {
|
|
38
|
+
* providers: [
|
|
39
|
+
* importProvidersFrom(NgModuleOne, NgModuleTwo)
|
|
40
|
+
* ]
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* You can also use the `importProvidersFrom` results in the `providers` field of a route, when a
|
|
45
|
+
* standalone component is used:
|
|
46
|
+
*
|
|
47
|
+
* ```typescript
|
|
48
|
+
* export const ROUTES: Route[] = [
|
|
49
|
+
* {
|
|
50
|
+
* path: 'foo',
|
|
51
|
+
* providers: [
|
|
52
|
+
* importProvidersFrom(NgModuleOne, NgModuleTwo)
|
|
53
|
+
* ],
|
|
54
|
+
* component: YourStandaloneComponent
|
|
55
|
+
* }
|
|
56
|
+
* ];
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @returns Collected providers from the specified list of types.
|
|
60
|
+
* @publicApi
|
|
61
|
+
*/
|
|
62
|
+
export declare function importProvidersFrom(...sources: ImportProvidersSource[]): EnvironmentProviders;
|
|
63
|
+
export declare function internalImportProvidersFrom(checkForStandaloneCmp: boolean, ...sources: ImportProvidersSource[]): Provider[];
|
|
11
64
|
/**
|
|
12
65
|
* Internal type for a single provider in a deep provider array.
|
|
13
66
|
*/
|
|
@@ -5,8 +5,8 @@
|
|
|
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.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { AbstractType, Type } from
|
|
9
|
-
import { InjectionToken } from
|
|
8
|
+
import { AbstractType, Type } from '../interface/type';
|
|
9
|
+
import { InjectionToken } from './injection_token';
|
|
10
10
|
/**
|
|
11
11
|
* @description
|
|
12
12
|
*
|
|
@@ -8,13 +8,10 @@
|
|
|
8
8
|
import { Injector } from './injector';
|
|
9
9
|
import { InjectorType } from './interface/defs';
|
|
10
10
|
import { InjectFlags, InjectOptions } from './interface/injector';
|
|
11
|
-
import {
|
|
11
|
+
import { EnvironmentProviders, Provider } from './interface/provider';
|
|
12
|
+
import { SingleProvider } from './provider_collection';
|
|
12
13
|
import { ProviderToken } from './provider_token';
|
|
13
14
|
import { InjectorScope } from './scope';
|
|
14
|
-
/**
|
|
15
|
-
* Internal type for a single provider in a deep provider array.
|
|
16
|
-
*/
|
|
17
|
-
type SingleProvider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | StaticClassProvider;
|
|
18
15
|
export declare function getNullInjector(): Injector;
|
|
19
16
|
/**
|
|
20
17
|
* An `Injector` that's part of the environment injector hierarchy, which exists outside of the
|
|
@@ -91,7 +88,7 @@ export declare class R3Injector extends EnvironmentInjector {
|
|
|
91
88
|
get destroyed(): boolean;
|
|
92
89
|
private _destroyed;
|
|
93
90
|
private injectorDefTypes;
|
|
94
|
-
constructor(providers: Array<Provider>, parent: Injector, source: string | null, scopes: Set<InjectorScope>);
|
|
91
|
+
constructor(providers: Array<Provider | EnvironmentProviders>, parent: Injector, source: string | null, scopes: Set<InjectorScope>);
|
|
95
92
|
/**
|
|
96
93
|
* Destroy the injector and release references to every instance or provider associated with it.
|
|
97
94
|
*
|
|
@@ -119,5 +116,3 @@ export declare class R3Injector extends EnvironmentInjector {
|
|
|
119
116
|
* @param provider provider to convert to factory
|
|
120
117
|
*/
|
|
121
118
|
export declare function providerToFactory(provider: SingleProvider, ngModuleType?: InjectorType<any>, providers?: any[]): () => any;
|
|
122
|
-
export declare function isTypeProvider(value: SingleProvider): value is TypeProvider;
|
|
123
|
-
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
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.io/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Base URL for the error details page.
|
|
10
|
+
*
|
|
11
|
+
* Keep this constant in sync across:
|
|
12
|
+
* - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
|
|
13
|
+
* - packages/core/src/error_details_base_url.ts
|
|
14
|
+
*/
|
|
15
|
+
export declare const ERROR_DETAILS_PAGE_BASE_URL = "https://angular.io/errors";
|
|
16
|
+
/**
|
|
17
|
+
* URL for the XSS security documentation.
|
|
18
|
+
*/
|
|
19
|
+
export declare const XSS_SECURITY_URL = "https://g.co/ng/security#xss";
|
|
@@ -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.io/license
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The list of error codes used in runtime code of the `core` package.
|
|
10
|
+
* Reserved error code range: 100-999.
|
|
11
|
+
*
|
|
12
|
+
* Note: the minus sign denotes the fact that a particular code has a detailed guide on
|
|
13
|
+
* angular.io. This extra annotation is needed to avoid introducing a separate set to store
|
|
14
|
+
* error codes which have guides, which might leak into runtime code.
|
|
15
|
+
*
|
|
16
|
+
* Full list of available error guides can be found at https://angular.io/errors.
|
|
17
|
+
*/
|
|
18
|
+
export declare const enum RuntimeErrorCode {
|
|
19
|
+
EXPRESSION_CHANGED_AFTER_CHECKED = -100,
|
|
20
|
+
RECURSIVE_APPLICATION_REF_TICK = 101,
|
|
21
|
+
CYCLIC_DI_DEPENDENCY = -200,
|
|
22
|
+
PROVIDER_NOT_FOUND = -201,
|
|
23
|
+
INVALID_FACTORY_DEPENDENCY = 202,
|
|
24
|
+
MISSING_INJECTION_CONTEXT = -203,
|
|
25
|
+
INVALID_INJECTION_TOKEN = 204,
|
|
26
|
+
INJECTOR_ALREADY_DESTROYED = 205,
|
|
27
|
+
PROVIDER_IN_WRONG_CONTEXT = 207,
|
|
28
|
+
MISSING_INJECTION_TOKEN = 208,
|
|
29
|
+
INVALID_MULTI_PROVIDER = -209,
|
|
30
|
+
MULTIPLE_COMPONENTS_MATCH = -300,
|
|
31
|
+
EXPORT_NOT_FOUND = -301,
|
|
32
|
+
PIPE_NOT_FOUND = -302,
|
|
33
|
+
UNKNOWN_BINDING = 303,
|
|
34
|
+
UNKNOWN_ELEMENT = 304,
|
|
35
|
+
TEMPLATE_STRUCTURE_ERROR = 305,
|
|
36
|
+
INVALID_EVENT_BINDING = 306,
|
|
37
|
+
HOST_DIRECTIVE_UNRESOLVABLE = 307,
|
|
38
|
+
HOST_DIRECTIVE_NOT_STANDALONE = 308,
|
|
39
|
+
DUPLICATE_DIRECTITVE = 309,
|
|
40
|
+
HOST_DIRECTIVE_COMPONENT = 310,
|
|
41
|
+
HOST_DIRECTIVE_UNDEFINED_BINDING = 311,
|
|
42
|
+
HOST_DIRECTIVE_CONFLICTING_ALIAS = 312,
|
|
43
|
+
MULTIPLE_PLATFORMS = 400,
|
|
44
|
+
PLATFORM_NOT_FOUND = 401,
|
|
45
|
+
ERROR_HANDLER_NOT_FOUND = 402,
|
|
46
|
+
BOOTSTRAP_COMPONENTS_NOT_FOUND = -403,
|
|
47
|
+
PLATFORM_ALREADY_DESTROYED = 404,
|
|
48
|
+
ASYNC_INITIALIZERS_STILL_RUNNING = 405,
|
|
49
|
+
APPLICATION_REF_ALREADY_DESTROYED = 406,
|
|
50
|
+
RENDERER_NOT_FOUND = 407,
|
|
51
|
+
INVALID_I18N_STRUCTURE = 700,
|
|
52
|
+
MISSING_LOCALE_DATA = 701,
|
|
53
|
+
IMPORT_PROVIDERS_FROM_STANDALONE = 800,
|
|
54
|
+
INVALID_DIFFER_INPUT = 900,
|
|
55
|
+
NO_SUPPORTING_DIFFER_FACTORY = 901,
|
|
56
|
+
VIEW_ALREADY_ATTACHED = 902,
|
|
57
|
+
INVALID_INHERITANCE = 903,
|
|
58
|
+
UNSAFE_VALUE_IN_RESOURCE_URL = 904,
|
|
59
|
+
UNSAFE_VALUE_IN_SCRIPT = 905,
|
|
60
|
+
MISSING_GENERATED_DEF = 906,
|
|
61
|
+
TYPE_IS_NOT_STANDALONE = 907,
|
|
62
|
+
MISSING_ZONEJS = 908,
|
|
63
|
+
UNEXPECTED_ZONE_STATE = 909,
|
|
64
|
+
UNSAFE_IFRAME_ATTRS = -910
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Class that represents a runtime error.
|
|
68
|
+
* Formats and outputs the error message in a consistent way.
|
|
69
|
+
*
|
|
70
|
+
* Example:
|
|
71
|
+
* ```
|
|
72
|
+
* throw new RuntimeError(
|
|
73
|
+
* RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
|
|
74
|
+
* ngDevMode && 'Injector has already been destroyed.');
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* Note: the `message` argument contains a descriptive error message as a string in development
|
|
78
|
+
* mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
|
|
79
|
+
* `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
|
|
80
|
+
*/
|
|
81
|
+
export declare class RuntimeError<T extends number = RuntimeErrorCode> extends Error {
|
|
82
|
+
code: T;
|
|
83
|
+
constructor(code: T, message: null | false | string);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Called to format a runtime error.
|
|
87
|
+
* See additional info on the `message` argument type in the `RuntimeError` class description.
|
|
88
|
+
*/
|
|
89
|
+
export declare function formatRuntimeError<T extends number = RuntimeErrorCode>(code: T, message: null | false | string): string;
|
|
@@ -5,6 +5,18 @@
|
|
|
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.io/license
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
*
|
|
11
|
+
* Represents a type that a Component or other object is instances of.
|
|
12
|
+
*
|
|
13
|
+
* An example of a `Type` is `MyCustomComponent` class, which in JavaScript is represented by
|
|
14
|
+
* the `MyCustomComponent` constructor function.
|
|
15
|
+
*
|
|
16
|
+
* @publicApi
|
|
17
|
+
*/
|
|
18
|
+
export declare const Type: FunctionConstructor;
|
|
19
|
+
export declare function isType(v: any): v is Type<any>;
|
|
8
20
|
/**
|
|
9
21
|
* @description
|
|
10
22
|
*
|
|
@@ -19,3 +31,36 @@ export interface AbstractType<T> extends Function {
|
|
|
19
31
|
export interface Type<T> extends Function {
|
|
20
32
|
new (...args: any[]): T;
|
|
21
33
|
}
|
|
34
|
+
export type Mutable<T extends {
|
|
35
|
+
[x: string]: any;
|
|
36
|
+
}, K extends string> = {
|
|
37
|
+
[P in K]: T[P];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Returns a writable type version of type.
|
|
41
|
+
*
|
|
42
|
+
* USAGE:
|
|
43
|
+
* Given:
|
|
44
|
+
* ```
|
|
45
|
+
* interface Person {readonly name: string}
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* We would like to get a read/write version of `Person`.
|
|
49
|
+
* ```
|
|
50
|
+
* const WritablePerson = Writable<Person>;
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* The result is that you can do:
|
|
54
|
+
*
|
|
55
|
+
* ```
|
|
56
|
+
* const readonlyPerson: Person = {name: 'Marry'};
|
|
57
|
+
* readonlyPerson.name = 'John'; // TypeError
|
|
58
|
+
* (readonlyPerson as WritablePerson).name = 'John'; // OK
|
|
59
|
+
*
|
|
60
|
+
* // Error: Correctly detects that `Person` did not have `age` property.
|
|
61
|
+
* (readonlyPerson as WritablePerson).age = 30;
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export type Writable<T> = {
|
|
65
|
+
-readonly [K in keyof T]: T[K];
|
|
66
|
+
};
|
|
@@ -1,2 +1,9 @@
|
|
|
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.io/license
|
|
7
|
+
*/
|
|
1
8
|
/** Throws an error when a token is not found in DI. */
|
|
2
9
|
export declare function throwProviderNotFoundError(token: any, injectorName?: string): never;
|
|
@@ -1,10 +1,3 @@
|
|
|
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.io/license
|
|
7
|
-
*/
|
|
8
1
|
/**
|
|
9
2
|
* Throws an error indicating that a factory function could not be generated by the compiler for a
|
|
10
3
|
* particular class.
|
|
@@ -1,10 +1,18 @@
|
|
|
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.io/license
|
|
7
|
-
*/
|
|
8
1
|
export declare function deepForEach<T>(input: (T | any[])[], fn: (value: T) => void): void;
|
|
9
2
|
export declare function newArray<T = any>(size: number): T[];
|
|
10
3
|
export declare function newArray<T>(size: number, value: T): T[];
|
|
4
|
+
/**
|
|
5
|
+
* `KeyValueArray` is an array where even positions contain keys and odd positions contain values.
|
|
6
|
+
*
|
|
7
|
+
* `KeyValueArray` provides a very efficient way of iterating over its contents. For small
|
|
8
|
+
* sets (~10) the cost of binary searching an `KeyValueArray` has about the same performance
|
|
9
|
+
* characteristics that of a `Map` with significantly better memory footprint.
|
|
10
|
+
*
|
|
11
|
+
* If used as a `Map` the keys are stored in alphabetical order so that they can be binary searched
|
|
12
|
+
* for retrieval.
|
|
13
|
+
*
|
|
14
|
+
* See: `keyValueArraySet`, `keyValueArrayGet`, `keyValueArrayIndexOf`, `keyValueArrayDelete`.
|
|
15
|
+
*/
|
|
16
|
+
export interface KeyValueArray<VALUE> extends Array<VALUE | string> {
|
|
17
|
+
__brand__: 'array-map';
|
|
18
|
+
}
|
|
@@ -24,4 +24,5 @@ export interface TypeDecorator {
|
|
|
24
24
|
<T extends Type<any>>(type: T): T;
|
|
25
25
|
(target: Object, propertyKey?: string | symbol, parameterIndex?: number): void;
|
|
26
26
|
}
|
|
27
|
-
export declare
|
|
27
|
+
export declare const PARAMETERS = "__parameters__";
|
|
28
|
+
export declare function makeParamDecorator(name: string, props?: (...args: any[]) => any, parentClass?: any): any;
|