static-injector 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/import/commonjs/index.js +1248 -0
  2. package/import/es2015/decorator/injectable.js +14 -0
  3. package/import/es2015/decorator/interface/provider.js +8 -0
  4. package/import/es2015/di/forward_ref.js +53 -0
  5. package/import/es2015/di/inject_switch.js +31 -0
  6. package/import/es2015/di/injection_token.js +71 -0
  7. package/import/es2015/di/injector.js +63 -0
  8. package/import/es2015/di/injector_compatibility.js +172 -0
  9. package/import/es2015/di/injector_marker.js +8 -0
  10. package/import/es2015/di/injector_token.js +21 -0
  11. package/import/es2015/di/interface/defs.js +72 -0
  12. package/import/es2015/di/interface/injector.js +25 -0
  13. package/import/es2015/di/interface/provider.js +8 -0
  14. package/import/es2015/di/metadata.js +49 -0
  15. package/import/es2015/di/null_injector.js +19 -0
  16. package/import/es2015/di/provider_token.js +8 -0
  17. package/import/es2015/di/r3_injector.js +382 -0
  18. package/import/es2015/di/scope.js +14 -0
  19. package/import/es2015/index.js +11 -0
  20. package/import/es2015/interface/lifecycle_hooks.js +8 -0
  21. package/import/es2015/interface/type.js +8 -0
  22. package/import/es2015/render3/definition_factory.js +15 -0
  23. package/import/es2015/render3/error_code.js +29 -0
  24. package/import/es2015/render3/errors_di.js +14 -0
  25. package/import/es2015/render3/fields.js +11 -0
  26. package/import/es2015/render3/instructions/di.js +23 -0
  27. package/import/es2015/render3/util/stringify_utils.js +37 -0
  28. package/import/es2015/util/array_utils.js +17 -0
  29. package/import/es2015/util/closure.js +19 -0
  30. package/import/es2015/util/decorators.js +30 -0
  31. package/import/es2015/util/empty.js +14 -0
  32. package/import/es2015/util/property.js +15 -0
  33. package/import/es2015/util/stringify.js +30 -0
  34. package/import/fesm2015/index.js +1211 -0
  35. package/import/typings/decorator/injectable.d.ts +82 -0
  36. package/import/typings/decorator/interface/provider.d.ts +312 -0
  37. package/import/typings/di/forward_ref.d.ts +49 -0
  38. package/import/typings/di/inject_switch.d.ts +17 -0
  39. package/import/typings/di/injection_token.d.ts +57 -0
  40. package/import/typings/di/injector.d.ts +76 -0
  41. package/import/typings/di/injector_compatibility.d.ts +77 -0
  42. package/import/typings/di/injector_marker.d.ts +23 -0
  43. package/import/typings/di/injector_token.d.ts +18 -0
  44. package/import/typings/di/interface/defs.d.ts +155 -0
  45. package/import/typings/di/interface/injector.d.ts +48 -0
  46. package/import/typings/di/interface/provider.d.ts +312 -0
  47. package/import/typings/di/metadata.d.ts +176 -0
  48. package/import/typings/di/null_injector.d.ts +11 -0
  49. package/import/typings/di/provider_token.d.ts +17 -0
  50. package/import/typings/di/r3_injector.d.ts +92 -0
  51. package/import/typings/di/scope.d.ts +14 -0
  52. package/import/typings/index.d.ts +11 -0
  53. package/import/typings/interface/lifecycle_hooks.d.ts +28 -0
  54. package/import/typings/interface/type.d.ts +21 -0
  55. package/import/typings/render3/definition_factory.d.ts +24 -0
  56. package/import/typings/render3/error_code.d.ts +24 -0
  57. package/import/typings/render3/errors_di.d.ts +2 -0
  58. package/import/typings/render3/fields.d.ts +8 -0
  59. package/import/typings/render3/instructions/di.d.ts +20 -0
  60. package/import/typings/render3/util/stringify_utils.d.ts +20 -0
  61. package/import/typings/util/array_utils.d.ts +10 -0
  62. package/import/typings/util/closure.d.ts +17 -0
  63. package/import/typings/util/decorators.d.ts +27 -0
  64. package/import/typings/util/empty.d.ts +14 -0
  65. package/import/typings/util/property.d.ts +8 -0
  66. package/import/typings/util/stringify.d.ts +8 -0
  67. package/package.json +34 -0
  68. package/readme.md +27 -0
  69. package/transform/compiler/index.d.ts +5 -0
  70. package/transform/compiler/index.js +17 -0
  71. package/transform/compiler/src/core.d.ts +19 -0
  72. package/transform/compiler/src/core.js +9 -0
  73. package/transform/compiler/src/injectable_compiler_2.d.ts +53 -0
  74. package/transform/compiler/src/injectable_compiler_2.js +159 -0
  75. package/transform/compiler/src/output/output_ast.d.ts +534 -0
  76. package/transform/compiler/src/output/output_ast.js +986 -0
  77. package/transform/compiler/src/parse_util.d.ts +50 -0
  78. package/transform/compiler/src/parse_util.js +61 -0
  79. package/transform/compiler/src/render3/partial/api.d.ts +166 -0
  80. package/transform/compiler/src/render3/partial/api.js +11 -0
  81. package/transform/compiler/src/render3/partial/util.d.ts +16 -0
  82. package/transform/compiler/src/render3/partial/util.js +44 -0
  83. package/transform/compiler/src/render3/r3_factory.d.ts +97 -0
  84. package/transform/compiler/src/render3/r3_factory.js +239 -0
  85. package/transform/compiler/src/render3/r3_identifiers.d.ts +20 -0
  86. package/transform/compiler/src/render3/r3_identifiers.js +51 -0
  87. package/transform/compiler/src/render3/util.d.ts +21 -0
  88. package/transform/compiler/src/render3/util.js +41 -0
  89. package/transform/compiler/src/render3/view/util.d.ts +30 -0
  90. package/transform/compiler/src/render3/view/util.js +57 -0
  91. package/transform/compiler-cli/src/ngtsc/annotations/src/factory.d.ts +11 -0
  92. package/transform/compiler-cli/src/ngtsc/annotations/src/factory.js +21 -0
  93. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +42 -0
  94. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +278 -0
  95. package/transform/compiler-cli/src/ngtsc/annotations/src/util.d.ts +91 -0
  96. package/transform/compiler-cli/src/ngtsc/annotations/src/util.js +370 -0
  97. package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +24 -0
  98. package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +76 -0
  99. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.d.ts +188 -0
  100. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +206 -0
  101. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +2 -0
  102. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +14 -0
  103. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +1 -0
  104. package/transform/compiler-cli/src/ngtsc/imports/index.js +13 -0
  105. package/transform/compiler-cli/src/ngtsc/imports/src/core.d.ts +36 -0
  106. package/transform/compiler-cli/src/ngtsc/imports/src/core.js +25 -0
  107. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +3 -0
  108. package/transform/compiler-cli/src/ngtsc/reflection/index.js +15 -0
  109. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +667 -0
  110. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +98 -0
  111. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +24 -0
  112. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +271 -0
  113. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +50 -0
  114. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +396 -0
  115. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +12 -0
  116. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +45 -0
  117. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +2 -0
  118. package/transform/compiler-cli/src/ngtsc/transform/index.js +14 -0
  119. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +115 -0
  120. package/transform/compiler-cli/src/ngtsc/transform/src/api.js +30 -0
  121. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +15 -0
  122. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +84 -0
  123. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +5 -0
  124. package/transform/compiler-cli/src/ngtsc/translator/index.js +17 -0
  125. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +274 -0
  126. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.js +9 -0
  127. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.d.ts +27 -0
  128. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.js +9 -0
  129. package/transform/compiler-cli/src/ngtsc/translator/src/context.d.ts +18 -0
  130. package/transform/compiler-cli/src/ngtsc/translator/src/context.js +27 -0
  131. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +29 -0
  132. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +70 -0
  133. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +58 -0
  134. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +270 -0
  135. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +54 -0
  136. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +245 -0
  137. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +13 -0
  138. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.js +21 -0
  139. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +11 -0
  140. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +39 -0
  141. package/transform/index.d.ts +1 -0
  142. package/transform/index.js +13 -0
  143. package/transform/injectable-transform.d.ts +41 -0
  144. package/transform/injectable-transform.js +195 -0
  145. package/transform/node-Iteration.d.ts +2 -0
  146. package/transform/node-Iteration.js +12 -0
@@ -0,0 +1,57 @@
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
+ import { Type } from '../interface/type';
9
+ /**
10
+ * Creates a token that can be used in a DI Provider.
11
+ *
12
+ * Use an `InjectionToken` whenever the type you are injecting is not reified (does not have a
13
+ * runtime representation) such as when injecting an interface, callable type, array or
14
+ * parameterized type.
15
+ *
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.
18
+ *
19
+ * ```
20
+ * interface MyInterface {...}
21
+ * var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
22
+ * // myInterface is inferred to be MyInterface.
23
+ * ```
24
+ *
25
+ * When creating an `InjectionToken`, you can optionally specify a factory function which returns
26
+ * (possibly by creating) a default value of the parameterized type `T`. This sets up the
27
+ * `InjectionToken` using this factory as a provider as if it was defined explicitly in the
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. See below for an example.
30
+ *
31
+ * 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`. As
33
+ * mentioned above, `'root'` is the default value for `providedIn`.
34
+ *
35
+ * @usageNotes
36
+ * ### Basic Example
37
+ *
38
+ * ### Plain InjectionToken
39
+ *
40
+ * {@example core/di/ts/injector_spec.ts region='InjectionToken'}
41
+ *
42
+ * ### Tree-shakable InjectionToken
43
+ *
44
+ * {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'}
45
+ *
46
+ *
47
+ * @publicApi
48
+ */
49
+ export declare class InjectionToken<T> {
50
+ protected _desc: string;
51
+ readonly ɵprov: unknown;
52
+ constructor(_desc: string, options?: {
53
+ providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
54
+ factory: () => T;
55
+ });
56
+ toString(): string;
57
+ }
@@ -0,0 +1,76 @@
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
+ import { InjectorMarkers } from './injector_marker';
9
+ import { InjectFlags } from './interface/injector';
10
+ import { StaticProvider } from './interface/provider';
11
+ import { ProviderToken } from './provider_token';
12
+ export declare function INJECTOR_IMPL__POST_R3__(providers: StaticProvider[], parent: Injector | undefined, name: string): Injector;
13
+ export declare const INJECTOR_IMPL: typeof INJECTOR_IMPL__POST_R3__;
14
+ /**
15
+ * Concrete injectors implement this interface. Injectors are configured
16
+ * with [providers](guide/glossary#provider) that associate
17
+ * dependencies of various types with [injection tokens](guide/glossary#di-token).
18
+ *
19
+ * @see ["DI Providers"](guide/dependency-injection-providers).
20
+ * @see `StaticProvider`
21
+ *
22
+ * @usageNotes
23
+ *
24
+ * The following example creates a service injector instance.
25
+ *
26
+ * {@example core/di/ts/provider_spec.ts region='ConstructorProvider'}
27
+ *
28
+ * ### Usage example
29
+ *
30
+ * {@example core/di/ts/injector_spec.ts region='Injector'}
31
+ *
32
+ * `Injector` returns itself when given `Injector` as a token:
33
+ *
34
+ * {@example core/di/ts/injector_spec.ts region='injectInjector'}
35
+ *
36
+ * @publicApi
37
+ */
38
+ export declare abstract class Injector {
39
+ static THROW_IF_NOT_FOUND: {};
40
+ static NULL: Injector;
41
+ /**
42
+ * Retrieves an instance from the injector based on the provided token.
43
+ * @returns The instance from the injector if defined, otherwise the `notFoundValue`.
44
+ * @throws When the `notFoundValue` is `undefined` or `Injector.THROW_IF_NOT_FOUND`.
45
+ */
46
+ abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
47
+ /**
48
+ * @deprecated from v4.0.0 use ProviderToken<T>
49
+ * @suppress {duplicate}
50
+ */
51
+ abstract get(token: any, notFoundValue?: any): any;
52
+ /**
53
+ * Creates a new injector instance that provides one or more dependencies,
54
+ * according to a given type or types of `StaticProvider`.
55
+ *
56
+ * @param options An object with the following properties:
57
+ * * `providers`: An array of providers of the [StaticProvider type](api/core/StaticProvider).
58
+ * * `parent`: (optional) A parent injector.
59
+ * * `name`: (optional) A developer-defined identifying name for the new injector.
60
+ *
61
+ * @returns The new injector instance.
62
+ *
63
+ */
64
+ static create(options: {
65
+ providers: StaticProvider[];
66
+ parent?: Injector;
67
+ name?: string;
68
+ }): Injector;
69
+ /** @nocollapse */
70
+ static ɵprov: unknown;
71
+ /**
72
+ * @internal
73
+ * @nocollapse
74
+ */
75
+ static __NG_ELEMENT_ID__: InjectorMarkers;
76
+ }
@@ -0,0 +1,77 @@
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
+ import { Injector } from "./injector";
9
+ import { DecoratorFlags, InjectFlags, InternalInjectFlags } from "./interface/injector";
10
+ import { ProviderToken } from "./provider_token";
11
+ export declare const THROW_IF_NOT_FOUND: {};
12
+ export declare const NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
13
+ export declare const SOURCE = "__source";
14
+ export declare const USE_VALUE: string;
15
+ export declare function setCurrentInjector(injector: Injector | null | undefined): Injector | undefined | null;
16
+ export declare function injectInjectorOnly<T>(token: ProviderToken<T>): T;
17
+ export declare function injectInjectorOnly<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
18
+ /**
19
+ * Generated instruction: Injects a token from the currently active injector.
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.
23
+ *
24
+ * (Additional documentation moved to `inject`, as it is the public API, and an alias for this
25
+ * instruction)
26
+ *
27
+ * @see inject
28
+ * @codeGenApi
29
+ * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
30
+ */
31
+ export declare function ɵɵinject<T>(token: ProviderToken<T>): T;
32
+ export declare function ɵɵinject<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
33
+ /**
34
+ * Injects a token from the currently active injector.
35
+ *
36
+ * Must be used in the context of a factory function such as one defined for an
37
+ * `InjectionToken`. Throws an error if not called from such a context.
38
+ *
39
+ * Within such a factory function, using this function to request injection of a dependency
40
+ * is faster and more type-safe than providing an additional array of dependencies
41
+ * (as has been common with `useFactory` providers).
42
+ *
43
+ * @param token The injection token for the dependency to be injected.
44
+ * @param flags Optional flags that control how injection is executed.
45
+ * The flags correspond to injection strategies that can be specified with
46
+ * parameter decorators `@Host`, `@Self`, `@SkipSef`, and `@Optional`.
47
+ * @returns the injected value if injection is successful, `null` otherwise.
48
+ *
49
+ * @usageNotes
50
+ *
51
+ * ### Example
52
+ *
53
+ * {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'}
54
+ *
55
+ * @publicApi
56
+ */
57
+ export declare const inject: typeof ɵɵinject;
58
+ export declare function injectArgs(types: (ProviderToken<any> | any[])[]): any[];
59
+ /**
60
+ * Attaches a given InjectFlag to a given decorator using monkey-patching.
61
+ * Since DI decorators can be used in providers `deps` array (when provider is configured using
62
+ * `useFactory`) without initialization (e.g. `Host`) and as an instance (e.g. `new Host()`), we
63
+ * attach the flag to make it available both as a static property and as a field on decorator
64
+ * instance.
65
+ *
66
+ * @param decorator Provided DI decorator.
67
+ * @param flag InjectFlag that should be applied.
68
+ */
69
+ export declare function attachInjectFlag(decorator: any, flag: InternalInjectFlags | DecoratorFlags): any;
70
+ /**
71
+ * Reads monkey-patched property that contains InjectFlag attached to a decorator.
72
+ *
73
+ * @param token Token that may contain monkey-patched DI flags property.
74
+ */
75
+ export declare function getInjectFlag(token: any): number | undefined;
76
+ export declare function catchInjectorError(e: any, token: any, injectorErrorName: string, source: string | null): never;
77
+ export declare function formatError(text: string, obj: any, injectorErrorName: string, source?: string | null): string;
@@ -0,0 +1,23 @@
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
+ * Special markers which can be left on `Type.__NG_ELEMENT_ID__` which are used by the Ivy's
10
+ * `NodeInjector`. Usually these markers contain factory functions. But in case of this special
11
+ * marker we can't leave behind a function because it would create tree shaking problem.
12
+ *
13
+ * Currently only `Injector` is special.
14
+ *
15
+ * NOTE: the numbers here must be negative, because positive numbers are used as IDs for bloom
16
+ * filter.
17
+ */
18
+ export declare const enum InjectorMarkers {
19
+ /**
20
+ * Marks that the current type is `Injector`
21
+ */
22
+ Injector = -1
23
+ }
@@ -0,0 +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
+ import { InjectionToken } from "./injection_token";
9
+ import { Injector } from "./injector";
10
+ /**
11
+ * An InjectionToken that gets the current `Injector` for `createInjector()`-style injectors.
12
+ *
13
+ * Requesting this token instead of `Injector` allows `StaticInjector` to be tree-shaken from a
14
+ * project.
15
+ *
16
+ * @publicApi
17
+ */
18
+ export declare const INJECTOR: InjectionToken<Injector>;
@@ -0,0 +1,155 @@
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
+ import { Type } from '../../interface/type';
9
+ import { ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, ValueProvider } from './provider';
10
+ /**
11
+ * Information about how a type or `InjectionToken` interfaces with the DI system.
12
+ *
13
+ * At a minimum, this includes a `factory` which defines how to create the given type `T`, possibly
14
+ * requesting injection of other types if necessary.
15
+ *
16
+ * Optionally, a `providedIn` parameter specifies that the given type belongs to a particular
17
+ * `Injector`, `NgModule`, or a special scope (e.g. `'root'`). A value of `null` indicates
18
+ * that the injectable does not belong to any scope.
19
+ *
20
+ * @codeGenApi
21
+ * @publicApi The ViewEngine compiler emits code with this type for injectables. This code is
22
+ * deployed to npm, and should be treated as public api.
23
+
24
+ */
25
+ export interface ɵɵInjectableDeclaration<T> {
26
+ /**
27
+ * Specifies that the given type belongs to a particular injector:
28
+ * - `InjectorType` such as `NgModule`,
29
+ * - `'root'` the root injector
30
+ * - `'any'` all injectors.
31
+ * - `null`, does not belong to any injector. Must be explicitly listed in the injector
32
+ * `providers`.
33
+ */
34
+ providedIn: InjectorType<any> | 'root' | 'platform' | 'any' | null;
35
+ /**
36
+ * The token to which this definition belongs.
37
+ *
38
+ * Note that this may not be the same as the type that the `factory` will create.
39
+ */
40
+ token: unknown;
41
+ /**
42
+ * Factory method to execute to create an instance of the injectable.
43
+ */
44
+ factory: (t?: Type<any>) => T;
45
+ /**
46
+ * In a case of no explicit injector, a location where the instance of the injectable is stored.
47
+ */
48
+ value: T | undefined;
49
+ }
50
+ /**
51
+ * Information about the providers to be included in an `Injector` as well as how the given type
52
+ * which carries the information should be created by the DI system.
53
+ *
54
+ * An `InjectorDef` can import other types which have `InjectorDefs`, forming a deep nested
55
+ * structure of providers with a defined priority (identically to how `NgModule`s also have
56
+ * an import/dependency structure).
57
+ *
58
+ * NOTE: This is a private type and should not be exported
59
+ *
60
+ * @codeGenApi
61
+ */
62
+ export interface ɵɵInjectorDef<T> {
63
+ providers: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
64
+ imports: (InjectorType<any> | InjectorTypeWithProviders<any>)[];
65
+ }
66
+ /**
67
+ * A `Type` which has a `ɵprov: ɵɵInjectableDeclaration` static field.
68
+ *
69
+ * `InjectableType`s contain their own Dependency Injection metadata and are usable in an
70
+ * `InjectorDef`-based `StaticInjector.
71
+ *
72
+ * @publicApi
73
+ */
74
+ export interface InjectableType<T> extends Type<T> {
75
+ /**
76
+ * Opaque type whose structure is highly version dependent. Do not rely on any properties.
77
+ */
78
+ ɵprov: unknown;
79
+ }
80
+ /**
81
+ * A type which has an `InjectorDef` static field.
82
+ *
83
+ * `InjectorTypes` can be used to configure a `StaticInjector`.
84
+ *
85
+ * This is an opaque type whose structure is highly version dependent. Do not rely on any
86
+ * properties.
87
+ *
88
+ * @publicApi
89
+ */
90
+ export interface InjectorType<T> extends Type<T> {
91
+ ɵfac?: unknown;
92
+ }
93
+ /**
94
+ * Describes the `InjectorDef` equivalent of a `ModuleWithProviders`, an `InjectorType` with an
95
+ * associated array of providers.
96
+ *
97
+ * Objects of this type can be listed in the imports section of an `InjectorDef`.
98
+ *
99
+ * NOTE: This is a private type and should not be exported
100
+ */
101
+ export interface InjectorTypeWithProviders<T> {
102
+ ngModule: InjectorType<T>;
103
+ providers?: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
104
+ }
105
+ /**
106
+ * Construct an injectable definition which defines how a token will be constructed by the DI
107
+ * system, and in which injectors (if any) it will be available.
108
+ *
109
+ * This should be assigned to a static `ɵprov` field on a type, which will then be an
110
+ * `InjectableType`.
111
+ *
112
+ * Options:
113
+ * * `providedIn` determines which injectors will include the injectable, by either associating it
114
+ * with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be
115
+ * provided in the `'root'` injector, which will be the application-level injector in most apps.
116
+ * * `factory` gives the zero argument function which will create an instance of the injectable.
117
+ * The factory can call `inject` to access the `Injector` and request injection of dependencies.
118
+ *
119
+ * @codeGenApi
120
+ * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
121
+ */
122
+ export declare function ɵɵdefineInjectable<T>(opts: {
123
+ token: unknown;
124
+ providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
125
+ factory: () => T;
126
+ }): unknown;
127
+ /**
128
+ * Construct an `InjectorDef` which configures an injector.
129
+ *
130
+ * This should be assigned to a static injector def (`ɵinj`) field on a type, which will then be an
131
+ * `InjectorType`.
132
+ *
133
+ * Options:
134
+ *
135
+ * * `providers`: an optional array of providers to add to the injector. Each provider must
136
+ * either have a factory or point to a type which has a `ɵprov` static property (the
137
+ * type must be an `InjectableType`).
138
+ * * `imports`: an optional array of imports of other `InjectorType`s or `InjectorTypeWithModule`s
139
+ * whose providers will also be added to the injector. Locally provided types will override
140
+ * providers from imports.
141
+ *
142
+ * @codeGenApi
143
+ */
144
+ export declare function ɵɵdefineInjector(options: {
145
+ providers?: any[];
146
+ imports?: any[];
147
+ }): unknown;
148
+ /**
149
+ * Read the injectable def (`ɵprov`) for `type` in a way which is immune to accidentally reading
150
+ * inherited value.
151
+ *
152
+ * @param type A type which may have its own (non-inherited) `ɵprov`.
153
+ */
154
+ export declare function getInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T> | null;
155
+ export declare const NG_PROV_DEF: string;
@@ -0,0 +1,48 @@
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
+ * Special flag indicating that a decorator is of type `Inject`. It's used to make `Inject`
10
+ * decorator tree-shakable (so we don't have to rely on the `instanceof` checks).
11
+ * Note: this flag is not included into the `InjectFlags` since it's an internal-only API.
12
+ */
13
+ export declare const enum DecoratorFlags {
14
+ Inject = -1
15
+ }
16
+ /**
17
+ * Injection flags for DI.
18
+ *
19
+ * @publicApi
20
+ */
21
+ export declare enum InjectFlags {
22
+ /** Check self and check parent injector if needed */
23
+ Default = 0,
24
+ /** Don't ascend to ancestors of the node requesting injection. */
25
+ Self = 2,
26
+ /** Skip the node that is requesting injection. */
27
+ SkipSelf = 4,
28
+ /** Inject `defaultValue` instead if token not found. */
29
+ Optional = 8
30
+ }
31
+ /**
32
+ * This enum is an exact copy of the `InjectFlags` enum above, but the difference is that this is a
33
+ * const enum, so actual enum values would be inlined in generated code. The `InjectFlags` enum can
34
+ * be turned into a const enum when ViewEngine is removed (see TODO at the `InjectFlags` enum
35
+ * above). The benefit of inlining is that we can use these flags at the top level without affecting
36
+ * tree-shaking (see "no-toplevel-property-access" tslint rule for more info).
37
+ * Keep this enum in sync with `InjectFlags` enum above.
38
+ */
39
+ export declare const enum InternalInjectFlags {
40
+ /** Check self and check parent injector if needed */
41
+ Default = 0,
42
+ /** Don't ascend to ancestors of the node requesting injection. */
43
+ Self = 2,
44
+ /** Skip the node that is requesting injection. */
45
+ SkipSelf = 4,
46
+ /** Inject `defaultValue` instead if token not found. */
47
+ Optional = 8
48
+ }