static-injector 4.0.2 → 5.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.
Files changed (179) hide show
  1. package/{import/commonjs → commonjs}/index.js +29 -197
  2. package/{import/es2022 → es2022}/di/interface/defs.js +5 -1
  3. package/{import/es2022 → es2022}/index.js +0 -1
  4. package/{transform/compiler/index.d.ts → es2022/interface/lifecycle_hooks.js} +1 -1
  5. package/{transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.js → es2022/render3/definition_factory.js} +3 -2
  6. package/es2022/util/decorators.js +31 -0
  7. package/{import/fesm2022 → fesm2022}/index.js +30 -196
  8. package/package.json +17 -14
  9. package/readme.md +35 -13
  10. package/{import/typings → typings}/di/injectable.d.ts +0 -7
  11. package/{import/typings → typings}/index.d.ts +0 -1
  12. package/import/es2022/di/injectable.js +0 -14
  13. package/import/es2022/error_details_base_url.js +0 -19
  14. package/import/es2022/render3/definition_factory.js +0 -14
  15. package/import/es2022/render3/di.js +0 -49
  16. package/import/es2022/render3/error_code.js +0 -30
  17. package/import/es2022/util/array_utils.js +0 -17
  18. package/import/es2022/util/decorators.js +0 -53
  19. package/import/typings/error_details_base_url.d.ts +0 -19
  20. package/import/typings/render3/di.d.ts +0 -12
  21. package/import/typings/render3/error_code.d.ts +0 -24
  22. package/import/typings/util/array_utils.d.ts +0 -25
  23. package/transform/compiler/compiler.d.ts +0 -8
  24. package/transform/compiler/compiler.js +0 -28
  25. package/transform/compiler/index.js +0 -28
  26. package/transform/compiler/public_api.d.ts +0 -13
  27. package/transform/compiler/public_api.js +0 -30
  28. package/transform/compiler/src/compiler.d.ts +0 -5
  29. package/transform/compiler/src/compiler.js +0 -21
  30. package/transform/compiler/src/core.d.ts +0 -25
  31. package/transform/compiler/src/core.js +0 -22
  32. package/transform/compiler/src/injectable_compiler_2.d.ts +0 -23
  33. package/transform/compiler/src/injectable_compiler_2.js +0 -171
  34. package/transform/compiler/src/output/output_ast.d.ts +0 -512
  35. package/transform/compiler/src/output/output_ast.js +0 -1109
  36. package/transform/compiler/src/parse_util.d.ts +0 -50
  37. package/transform/compiler/src/parse_util.js +0 -71
  38. package/transform/compiler/src/render3/partial/api.d.ts +0 -171
  39. package/transform/compiler/src/render3/partial/api.js +0 -18
  40. package/transform/compiler/src/render3/r3_factory.d.ts +0 -82
  41. package/transform/compiler/src/render3/r3_factory.js +0 -225
  42. package/transform/compiler/src/render3/r3_identifiers.d.ts +0 -20
  43. package/transform/compiler/src/render3/r3_identifiers.js +0 -55
  44. package/transform/compiler/src/render3/util.d.ts +0 -85
  45. package/transform/compiler/src/render3/util.js +0 -82
  46. package/transform/compiler/src/render3/view/util.d.ts +0 -24
  47. package/transform/compiler/src/render3/view/util.js +0 -59
  48. package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +0 -3
  49. package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +0 -19
  50. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +0 -37
  51. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +0 -195
  52. package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.d.ts +0 -11
  53. package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.js +0 -22
  54. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +0 -64
  55. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +0 -189
  56. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +0 -43
  57. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +0 -277
  58. package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +0 -24
  59. package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +0 -84
  60. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.d.ts +0 -188
  61. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +0 -206
  62. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +0 -2
  63. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +0 -18
  64. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +0 -1
  65. package/transform/compiler-cli/src/ngtsc/imports/index.js +0 -17
  66. package/transform/compiler-cli/src/ngtsc/imports/src/core.d.ts +0 -36
  67. package/transform/compiler-cli/src/ngtsc/imports/src/core.js +0 -25
  68. package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +0 -19
  69. package/transform/compiler-cli/src/ngtsc/imports/src/default.js +0 -27
  70. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +0 -3
  71. package/transform/compiler-cli/src/ngtsc/reflection/index.js +0 -19
  72. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +0 -522
  73. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +0 -34
  74. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +0 -25
  75. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +0 -271
  76. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +0 -53
  77. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +0 -393
  78. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +0 -12
  79. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +0 -29
  80. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +0 -2
  81. package/transform/compiler-cli/src/ngtsc/transform/index.js +0 -18
  82. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +0 -115
  83. package/transform/compiler-cli/src/ngtsc/transform/src/api.js +0 -29
  84. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +0 -15
  85. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +0 -79
  86. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +0 -5
  87. package/transform/compiler-cli/src/ngtsc/translator/index.js +0 -21
  88. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +0 -289
  89. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.d.ts +0 -27
  90. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.js +0 -9
  91. package/transform/compiler-cli/src/ngtsc/translator/src/context.d.ts +0 -18
  92. package/transform/compiler-cli/src/ngtsc/translator/src/context.js +0 -28
  93. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +0 -47
  94. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +0 -66
  95. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +0 -56
  96. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +0 -270
  97. package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.d.ts +0 -12
  98. package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.js +0 -27
  99. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +0 -53
  100. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +0 -250
  101. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +0 -13
  102. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.js +0 -21
  103. package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.d.ts +0 -8
  104. package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.js +0 -24
  105. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +0 -45
  106. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +0 -86
  107. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +0 -4
  108. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +0 -16
  109. package/transform/index.d.ts +0 -1
  110. package/transform/index.js +0 -17
  111. package/transform/injectable-transform.d.ts +0 -41
  112. package/transform/injectable-transform.js +0 -245
  113. package/transform/node-Iteration.d.ts +0 -2
  114. package/transform/node-Iteration.js +0 -12
  115. /package/{import/es2022 → es2022}/di/create_injector.js +0 -0
  116. /package/{import/es2022 → es2022}/di/forward_ref.js +0 -0
  117. /package/{import/es2022 → es2022}/di/index.js +0 -0
  118. /package/{import/es2022 → es2022}/di/initializer_token.js +0 -0
  119. /package/{import/es2022 → es2022}/di/inject_switch.js +0 -0
  120. /package/{import/es2022/di/injector_marker.js → es2022/di/injectable.js} +0 -0
  121. /package/{import/es2022 → es2022}/di/injection_token.js +0 -0
  122. /package/{import/es2022 → es2022}/di/injector.js +0 -0
  123. /package/{import/es2022 → es2022}/di/injector_compatibility.js +0 -0
  124. /package/{import/es2022/di/provider_token.js → es2022/di/injector_marker.js} +0 -0
  125. /package/{import/es2022 → es2022}/di/injector_token.js +0 -0
  126. /package/{import/es2022 → es2022}/di/interface/injector.js +0 -0
  127. /package/{import/es2022 → es2022}/di/interface/provider.js +0 -0
  128. /package/{import/es2022 → es2022}/di/internal_tokens.js +0 -0
  129. /package/{import/es2022 → es2022}/di/metadata.js +0 -0
  130. /package/{import/es2022 → es2022}/di/null_injector.js +0 -0
  131. /package/{import/es2022 → es2022}/di/provider_collection.js +0 -0
  132. /package/{import/es2022/interface/lifecycle_hooks.js → es2022/di/provider_token.js} +0 -0
  133. /package/{import/es2022 → es2022}/di/r3_injector.js +0 -0
  134. /package/{import/es2022 → es2022}/di/scope.js +0 -0
  135. /package/{import/es2022 → es2022}/di.js +0 -0
  136. /package/{import/es2022 → es2022}/errors.js +0 -0
  137. /package/{import/es2022 → es2022}/interface/type.js +0 -0
  138. /package/{import/es2022 → es2022}/render3/errors_di.js +0 -0
  139. /package/{import/es2022 → es2022}/render3/fields.js +0 -0
  140. /package/{import/es2022 → es2022}/render3/instructions/di.js +0 -0
  141. /package/{import/es2022 → es2022}/render3/util/stringify_utils.js +0 -0
  142. /package/{import/es2022 → es2022}/util/closure.js +0 -0
  143. /package/{import/es2022 → es2022}/util/empty.js +0 -0
  144. /package/{import/es2022 → es2022}/util/property.js +0 -0
  145. /package/{import/es2022 → es2022}/util/stringify.js +0 -0
  146. /package/{import/typings → typings}/di/create_injector.d.ts +0 -0
  147. /package/{import/typings → typings}/di/forward_ref.d.ts +0 -0
  148. /package/{import/typings → typings}/di/index.d.ts +0 -0
  149. /package/{import/typings → typings}/di/initializer_token.d.ts +0 -0
  150. /package/{import/typings → typings}/di/inject_switch.d.ts +0 -0
  151. /package/{import/typings → typings}/di/injection_token.d.ts +0 -0
  152. /package/{import/typings → typings}/di/injector.d.ts +0 -0
  153. /package/{import/typings → typings}/di/injector_compatibility.d.ts +0 -0
  154. /package/{import/typings → typings}/di/injector_marker.d.ts +0 -0
  155. /package/{import/typings → typings}/di/injector_token.d.ts +0 -0
  156. /package/{import/typings → typings}/di/interface/defs.d.ts +0 -0
  157. /package/{import/typings → typings}/di/interface/injector.d.ts +0 -0
  158. /package/{import/typings → typings}/di/interface/provider.d.ts +0 -0
  159. /package/{import/typings → typings}/di/internal_tokens.d.ts +0 -0
  160. /package/{import/typings → typings}/di/metadata.d.ts +0 -0
  161. /package/{import/typings → typings}/di/null_injector.d.ts +0 -0
  162. /package/{import/typings → typings}/di/provider_collection.d.ts +0 -0
  163. /package/{import/typings → typings}/di/provider_token.d.ts +0 -0
  164. /package/{import/typings → typings}/di/r3_injector.d.ts +0 -0
  165. /package/{import/typings → typings}/di/scope.d.ts +0 -0
  166. /package/{import/typings → typings}/di.d.ts +0 -0
  167. /package/{import/typings → typings}/errors.d.ts +0 -0
  168. /package/{import/typings → typings}/interface/lifecycle_hooks.d.ts +0 -0
  169. /package/{import/typings → typings}/interface/type.d.ts +0 -0
  170. /package/{import/typings → typings}/render3/definition_factory.d.ts +0 -0
  171. /package/{import/typings → typings}/render3/errors_di.d.ts +0 -0
  172. /package/{import/typings → typings}/render3/fields.d.ts +0 -0
  173. /package/{import/typings → typings}/render3/instructions/di.d.ts +0 -0
  174. /package/{import/typings → typings}/render3/util/stringify_utils.d.ts +0 -0
  175. /package/{import/typings → typings}/util/closure.d.ts +0 -0
  176. /package/{import/typings → typings}/util/decorators.d.ts +0 -0
  177. /package/{import/typings → typings}/util/empty.d.ts +0 -0
  178. /package/{import/typings → typings}/util/property.d.ts +0 -0
  179. /package/{import/typings → typings}/util/stringify.d.ts +0 -0
@@ -1,50 +0,0 @@
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
- export declare class ParseLocation {
9
- file: ParseSourceFile;
10
- offset: number;
11
- line: number;
12
- col: number;
13
- constructor(file: ParseSourceFile, offset: number, line: number, col: number);
14
- }
15
- export declare class ParseSourceFile {
16
- content: string;
17
- url: string;
18
- constructor(content: string, url: string);
19
- }
20
- export declare class ParseSourceSpan {
21
- start: ParseLocation;
22
- end: ParseLocation;
23
- fullStart: ParseLocation;
24
- details: string | null;
25
- /**
26
- * Create an object that holds information about spans of tokens/nodes captured during
27
- * lexing/parsing of text.
28
- *
29
- * @param start
30
- * The location of the start of the span (having skipped leading trivia).
31
- * Skipping leading trivia makes source-spans more "user friendly", since things like HTML
32
- * elements will appear to begin at the start of the opening tag, rather than at the start of any
33
- * leading trivia, which could include newlines.
34
- *
35
- * @param end
36
- * The location of the end of the span.
37
- *
38
- * @param fullStart
39
- * The start of the token without skipping the leading trivia.
40
- * This is used by tooling that splits tokens further, such as extracting Angular interpolations
41
- * from text tokens. Such tooling creates new source-spans relative to the original token's
42
- * source-span. If leading trivia characters have been skipped then the new source-spans may be
43
- * incorrectly offset.
44
- *
45
- * @param details
46
- * Additional information (such as identifier names) that should be associated with the span.
47
- */
48
- constructor(start: ParseLocation, end: ParseLocation, fullStart?: ParseLocation, details?: string | null);
49
- toString(): string;
50
- }
@@ -1,71 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ParseSourceSpan = exports.ParseSourceFile = exports.ParseLocation = void 0;
11
- class ParseLocation {
12
- file;
13
- offset;
14
- line;
15
- col;
16
- constructor(file, offset, line, col) {
17
- this.file = file;
18
- this.offset = offset;
19
- this.line = line;
20
- this.col = col;
21
- }
22
- }
23
- exports.ParseLocation = ParseLocation;
24
- class ParseSourceFile {
25
- content;
26
- url;
27
- constructor(content, url) {
28
- this.content = content;
29
- this.url = url;
30
- }
31
- }
32
- exports.ParseSourceFile = ParseSourceFile;
33
- class ParseSourceSpan {
34
- start;
35
- end;
36
- fullStart;
37
- details;
38
- /**
39
- * Create an object that holds information about spans of tokens/nodes captured during
40
- * lexing/parsing of text.
41
- *
42
- * @param start
43
- * The location of the start of the span (having skipped leading trivia).
44
- * Skipping leading trivia makes source-spans more "user friendly", since things like HTML
45
- * elements will appear to begin at the start of the opening tag, rather than at the start of any
46
- * leading trivia, which could include newlines.
47
- *
48
- * @param end
49
- * The location of the end of the span.
50
- *
51
- * @param fullStart
52
- * The start of the token without skipping the leading trivia.
53
- * This is used by tooling that splits tokens further, such as extracting Angular interpolations
54
- * from text tokens. Such tooling creates new source-spans relative to the original token's
55
- * source-span. If leading trivia characters have been skipped then the new source-spans may be
56
- * incorrectly offset.
57
- *
58
- * @param details
59
- * Additional information (such as identifier names) that should be associated with the span.
60
- */
61
- constructor(start, end, fullStart = start, details = null) {
62
- this.start = start;
63
- this.end = end;
64
- this.fullStart = fullStart;
65
- this.details = details;
66
- }
67
- toString() {
68
- return this.start.file.content.substring(this.start.offset, this.end.offset);
69
- }
70
- }
71
- exports.ParseSourceSpan = ParseSourceSpan;
@@ -1,171 +0,0 @@
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 * as o from '../../output/output_ast';
9
- export interface R3PartialDeclaration {
10
- /**
11
- * The minimum version of the compiler that can process this partial declaration.
12
- */
13
- minVersion: string;
14
- /**
15
- * Version number of the Angular compiler that was used to compile this declaration. The linker
16
- * will be able to detect which version a library is using and interpret its metadata accordingly.
17
- */
18
- version: string;
19
- /**
20
- * A reference to the `@angular/core` ES module, which allows access
21
- * to all Angular exports, including Ivy instructions.
22
- */
23
- ngImport: o.Expression;
24
- /**
25
- * Reference to the decorated class, which is subject to this partial declaration.
26
- */
27
- type: o.Expression;
28
- }
29
- export type LegacyInputPartialMapping = string | [
30
- bindingPropertyName: string,
31
- classPropertyName: string,
32
- transformFunction?: o.Expression
33
- ];
34
- /**
35
- * Describes the shape of the objects that the `ɵɵngDeclareInjector()` accepts.
36
- */
37
- export interface R3DeclareInjectorMetadata extends R3PartialDeclaration {
38
- /**
39
- * The list of providers provided by the injector.
40
- */
41
- providers?: o.Expression;
42
- /**
43
- * The list of imports into the injector.
44
- */
45
- imports?: o.Expression[];
46
- }
47
- /**
48
- * Describes the shape of the object that the `ɵɵngDeclareFactory()` function accepts.
49
- *
50
- * This interface serves primarily as documentation, as conformance to this interface is not
51
- * enforced during linking.
52
- */
53
- export interface R3DeclareFactoryMetadata extends R3PartialDeclaration {
54
- /**
55
- * A collection of dependencies that this factory relies upon.
56
- *
57
- * If this is `null`, then the type's constructor is nonexistent and will be inherited from an
58
- * ancestor of the type.
59
- *
60
- * If this is `'invalid'`, then one or more of the parameters wasn't resolvable and any attempt to
61
- * use these deps will result in a runtime error.
62
- */
63
- deps: R3DeclareDependencyMetadata[] | 'invalid' | null;
64
- /**
65
- * Type of the target being created by the factory.
66
- */
67
- target: FactoryTarget;
68
- }
69
- export declare enum FactoryTarget {
70
- Directive = 0,
71
- Component = 1,
72
- Injectable = 2,
73
- Pipe = 3,
74
- NgModule = 4
75
- }
76
- /**
77
- * Describes the shape of the object that the `ɵɵngDeclareInjectable()` function accepts.
78
- *
79
- * This interface serves primarily as documentation, as conformance to this interface is not
80
- * enforced during linking.
81
- */
82
- export interface R3DeclareInjectableMetadata extends R3PartialDeclaration {
83
- /**
84
- * If provided, specifies that the declared injectable belongs to a particular injector:
85
- * - `InjectorType` such as `NgModule`,
86
- * - `'root'` the root injector
87
- * - `'any'` all injectors.
88
- * If not provided, then it does not belong to any injector. Must be explicitly listed in the
89
- * providers of an injector.
90
- */
91
- providedIn?: o.Expression;
92
- /**
93
- * If provided, an expression that evaluates to a class to use when creating an instance of this
94
- * injectable.
95
- */
96
- useClass?: o.Expression;
97
- /**
98
- * If provided, an expression that evaluates to a function to use when creating an instance of
99
- * this injectable.
100
- */
101
- useFactory?: o.Expression;
102
- /**
103
- * If provided, an expression that evaluates to a token of another injectable that this injectable
104
- * aliases.
105
- */
106
- useExisting?: o.Expression;
107
- /**
108
- * If provided, an expression that evaluates to the value of the instance of this injectable.
109
- */
110
- useValue?: o.Expression;
111
- /**
112
- * An array of dependencies to support instantiating this injectable via `useClass` or
113
- * `useFactory`.
114
- */
115
- deps?: R3DeclareDependencyMetadata[];
116
- }
117
- /**
118
- * Metadata indicating how a dependency should be injected into a factory.
119
- */
120
- export interface R3DeclareDependencyMetadata {
121
- /**
122
- * An expression representing the token or value to be injected, or `null` if the dependency is
123
- * not valid.
124
- *
125
- * If this dependency is due to the `@Attribute()` decorator, then this is an expression
126
- * evaluating to the name of the attribute.
127
- */
128
- token: o.Expression | null;
129
- /**
130
- * Whether the dependency is injecting an attribute value.
131
- * Default: false.
132
- */
133
- attribute?: boolean;
134
- /**
135
- * Whether the dependency has an @Optional qualifier.
136
- * Default: false,
137
- */
138
- optional?: boolean;
139
- /**
140
- * Whether the dependency has an @Self qualifier.
141
- * Default: false,
142
- */
143
- self?: boolean;
144
- /**
145
- * Whether the dependency has an @SkipSelf qualifier.
146
- * Default: false,
147
- */
148
- skipSelf?: boolean;
149
- }
150
- /**
151
- * Describes the shape of the object that the `ɵɵngDeclareClassMetadata()` function accepts.
152
- *
153
- * This interface serves primarily as documentation, as conformance to this interface is not
154
- * enforced during linking.
155
- */
156
- export interface R3DeclareClassMetadata extends R3PartialDeclaration {
157
- /**
158
- * The Angular decorators of the class.
159
- */
160
- decorators: o.Expression;
161
- /**
162
- * Optionally specifies the constructor parameters, their types and the Angular decorators of each
163
- * parameter. This property is omitted if the class does not have a constructor.
164
- */
165
- ctorParameters?: o.Expression;
166
- /**
167
- * Optionally specifies the Angular decorators applied to the class properties. This property is
168
- * omitted if no properties have any decorators.
169
- */
170
- propDecorators?: o.Expression;
171
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.FactoryTarget = void 0;
11
- var FactoryTarget;
12
- (function (FactoryTarget) {
13
- FactoryTarget[FactoryTarget["Directive"] = 0] = "Directive";
14
- FactoryTarget[FactoryTarget["Component"] = 1] = "Component";
15
- FactoryTarget[FactoryTarget["Injectable"] = 2] = "Injectable";
16
- FactoryTarget[FactoryTarget["Pipe"] = 3] = "Pipe";
17
- FactoryTarget[FactoryTarget["NgModule"] = 4] = "NgModule";
18
- })(FactoryTarget || (exports.FactoryTarget = FactoryTarget = {}));
@@ -1,82 +0,0 @@
1
- import * as o from '../output/output_ast';
2
- import { R3CompiledExpression, R3Reference } from './util';
3
- /**
4
- * Metadata required by the factory generator to generate a `factory` function for a type.
5
- */
6
- export interface R3ConstructorFactoryMetadata {
7
- /**
8
- * String name of the type being generated (used to name the factory function).
9
- */
10
- name: string;
11
- /**
12
- * An expression representing the interface type being constructed.
13
- */
14
- type: R3Reference;
15
- /** Number of arguments for the `type`. */
16
- typeArgumentCount: number;
17
- /**
18
- * Regardless of whether `fnOrClass` is a constructor function or a user-defined factory, it
19
- * may have 0 or more parameters, which will be injected according to the `R3DependencyMetadata`
20
- * for those parameters. If this is `null`, then the type's constructor is nonexistent and will
21
- * be inherited from `fnOrClass` which is interpreted as the current type. If this is `'invalid'`,
22
- * then one or more of the parameters wasn't resolvable and any attempt to use these deps will
23
- * result in a runtime error.
24
- */
25
- deps: R3DependencyMetadata[] | 'invalid' | null;
26
- /**
27
- * Type of the target being created by the factory.
28
- */
29
- target: FactoryTarget;
30
- }
31
- export declare enum R3FactoryDelegateType {
32
- Class = 0,
33
- Function = 1
34
- }
35
- export interface R3DelegatedFnOrClassMetadata extends R3ConstructorFactoryMetadata {
36
- delegate: o.Expression;
37
- delegateType: R3FactoryDelegateType;
38
- delegateDeps: R3DependencyMetadata[];
39
- }
40
- export interface R3ExpressionFactoryMetadata extends R3ConstructorFactoryMetadata {
41
- expression: o.Expression;
42
- }
43
- export type R3FactoryMetadata = R3ConstructorFactoryMetadata | R3DelegatedFnOrClassMetadata | R3ExpressionFactoryMetadata;
44
- export declare enum FactoryTarget {
45
- Directive = 0,
46
- Component = 1,
47
- Injectable = 2,
48
- Pipe = 3,
49
- NgModule = 4
50
- }
51
- export interface R3DependencyMetadata {
52
- /**
53
- * An expression representing the token or value to be injected.
54
- * Or `null` if the dependency could not be resolved - making it invalid.
55
- */
56
- token: o.Expression | null;
57
- /**
58
- * If an @Attribute decorator is present, this is the literal type of the attribute name, or
59
- * the unknown type if no literal type is available (e.g. the attribute name is an expression).
60
- * Otherwise it is null;
61
- */
62
- attributeNameType: o.Expression | null;
63
- /**
64
- * Whether the dependency has an @Optional qualifier.
65
- */
66
- optional: boolean;
67
- /**
68
- * Whether the dependency has an @Self qualifier.
69
- */
70
- self: boolean;
71
- /**
72
- * Whether the dependency has an @SkipSelf qualifier.
73
- */
74
- skipSelf: boolean;
75
- }
76
- /**
77
- * Construct a factory function expression for the given `R3FactoryMetadata`.
78
- */
79
- export declare function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpression;
80
- export declare function createFactoryType(meta: R3FactoryMetadata): o.ExpressionType;
81
- export declare function isDelegatedFactoryMetadata(meta: R3FactoryMetadata): meta is R3DelegatedFnOrClassMetadata;
82
- export declare function isExpressionFactoryMetadata(meta: R3FactoryMetadata): meta is R3ExpressionFactoryMetadata;
@@ -1,225 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.isExpressionFactoryMetadata = exports.isDelegatedFactoryMetadata = exports.createFactoryType = exports.compileFactoryFunction = exports.FactoryTarget = exports.R3FactoryDelegateType = void 0;
27
- const o = __importStar(require("../output/output_ast"));
28
- const r3_identifiers_1 = require("../render3/r3_identifiers");
29
- const util_1 = require("./util");
30
- var R3FactoryDelegateType;
31
- (function (R3FactoryDelegateType) {
32
- R3FactoryDelegateType[R3FactoryDelegateType["Class"] = 0] = "Class";
33
- R3FactoryDelegateType[R3FactoryDelegateType["Function"] = 1] = "Function";
34
- })(R3FactoryDelegateType || (exports.R3FactoryDelegateType = R3FactoryDelegateType = {}));
35
- var FactoryTarget;
36
- (function (FactoryTarget) {
37
- FactoryTarget[FactoryTarget["Directive"] = 0] = "Directive";
38
- FactoryTarget[FactoryTarget["Component"] = 1] = "Component";
39
- FactoryTarget[FactoryTarget["Injectable"] = 2] = "Injectable";
40
- FactoryTarget[FactoryTarget["Pipe"] = 3] = "Pipe";
41
- FactoryTarget[FactoryTarget["NgModule"] = 4] = "NgModule";
42
- })(FactoryTarget || (exports.FactoryTarget = FactoryTarget = {}));
43
- /**
44
- * Construct a factory function expression for the given `R3FactoryMetadata`.
45
- */
46
- function compileFactoryFunction(meta) {
47
- const t = o.variable('t');
48
- let baseFactoryVar = null;
49
- // The type to instantiate via constructor invocation. If there is no delegated factory, meaning
50
- // this type is always created by constructor invocation, then this is the type-to-create
51
- // parameter provided by the user (t) if specified, or the current type if not. If there is a
52
- // delegated factory (which is used to create the current type) then this is only the type-to-
53
- // create parameter (t).
54
- const typeForCtor = !isDelegatedFactoryMetadata(meta)
55
- ? new o.BinaryOperatorExpr(o.BinaryOperator.Or, t, meta.type.value)
56
- : t;
57
- let ctorExpr = null;
58
- if (meta.deps !== null) {
59
- // There is a constructor (either explicitly or implicitly defined).
60
- if (meta.deps !== 'invalid') {
61
- ctorExpr = new o.InstantiateExpr(typeForCtor, injectDependencies(meta.deps, meta.target));
62
- }
63
- }
64
- else {
65
- // There is no constructor, use the base class' factory to construct typeForCtor.
66
- baseFactoryVar = o.variable(`ɵ${meta.name}_BaseFactory`);
67
- ctorExpr = baseFactoryVar.callFn([typeForCtor]);
68
- }
69
- const body = [];
70
- let retExpr = null;
71
- function makeConditionalFactory(nonCtorExpr) {
72
- const r = o.variable('r');
73
- body.push(r.set(o.NULL_EXPR).toDeclStmt());
74
- const ctorStmt = ctorExpr !== null
75
- ? r.set(ctorExpr).toStmt()
76
- : o.importExpr(r3_identifiers_1.Identifiers.invalidFactory).callFn([]).toStmt();
77
- body.push(o.ifStmt(t, [ctorStmt], [r.set(nonCtorExpr).toStmt()]));
78
- return r;
79
- }
80
- if (isDelegatedFactoryMetadata(meta)) {
81
- // This type is created with a delegated factory. If a type parameter is not specified, call
82
- // the factory instead.
83
- const delegateArgs = injectDependencies(meta.delegateDeps, meta.target);
84
- // Either call `new delegate(...)` or `delegate(...)` depending on meta.delegateType.
85
- const factoryExpr = new (meta.delegateType === R3FactoryDelegateType.Class
86
- ? o.InstantiateExpr
87
- : o.InvokeFunctionExpr)(meta.delegate, delegateArgs);
88
- retExpr = makeConditionalFactory(factoryExpr);
89
- }
90
- else if (isExpressionFactoryMetadata(meta)) {
91
- // TODO(alxhub): decide whether to lower the value here or in the caller
92
- retExpr = makeConditionalFactory(meta.expression);
93
- }
94
- else {
95
- retExpr = ctorExpr;
96
- }
97
- if (retExpr === null) {
98
- // The expression cannot be formed so render an `ɵɵinvalidFactory()` call.
99
- body.push(o.importExpr(r3_identifiers_1.Identifiers.invalidFactory).callFn([]).toStmt());
100
- }
101
- else if (baseFactoryVar !== null) {
102
- // This factory uses a base factory, so call `ɵɵgetInheritedFactory()` to compute it.
103
- const getInheritedFactoryCall = o
104
- .importExpr(r3_identifiers_1.Identifiers.getInheritedFactory)
105
- .callFn([meta.type.value]);
106
- // Memoize the base factoryFn: `baseFactory || (baseFactory = ɵɵgetInheritedFactory(...))`
107
- const baseFactory = new o.BinaryOperatorExpr(o.BinaryOperator.Or, baseFactoryVar, baseFactoryVar.set(getInheritedFactoryCall));
108
- body.push(new o.ReturnStatement(baseFactory.callFn([typeForCtor])));
109
- }
110
- else {
111
- // This is straightforward factory, just return it.
112
- body.push(new o.ReturnStatement(retExpr));
113
- }
114
- let factoryFn = o.fn([new o.FnParam('t', o.DYNAMIC_TYPE)], body, o.INFERRED_TYPE, undefined, `${meta.name}_Factory`);
115
- if (baseFactoryVar !== null) {
116
- // There is a base factory variable so wrap its declaration along with the factory function into
117
- // an IIFE.
118
- factoryFn = o
119
- .arrowFn([], [
120
- new o.DeclareVarStmt(baseFactoryVar.name),
121
- new o.ReturnStatement(factoryFn),
122
- ])
123
- .callFn([], /* sourceSpan */ undefined, /* pure */ true);
124
- }
125
- return {
126
- expression: factoryFn,
127
- statements: [],
128
- type: createFactoryType(meta),
129
- };
130
- }
131
- exports.compileFactoryFunction = compileFactoryFunction;
132
- function createFactoryType(meta) {
133
- const ctorDepsType = meta.deps !== null && meta.deps !== 'invalid'
134
- ? createCtorDepsType(meta.deps)
135
- : o.NONE_TYPE;
136
- return o.expressionType(o.importExpr(r3_identifiers_1.Identifiers.FactoryDeclaration, [
137
- (0, util_1.typeWithParameters)(meta.type.type, meta.typeArgumentCount),
138
- ctorDepsType,
139
- ]));
140
- }
141
- exports.createFactoryType = createFactoryType;
142
- function injectDependencies(deps, target) {
143
- return deps.map((dep, index) => compileInjectDependency(dep, target, index));
144
- }
145
- function compileInjectDependency(dep, target, index) {
146
- // Interpret the dependency according to its resolved type.
147
- if (dep.token === null) {
148
- return o.importExpr(r3_identifiers_1.Identifiers.invalidFactoryDep).callFn([o.literal(index)]);
149
- }
150
- else if (dep.attributeNameType === null) {
151
- // Build up the injection flags according to the metadata.
152
- const flags = 0 /* InjectFlags.Default */ |
153
- (dep.self ? 2 /* InjectFlags.Self */ : 0) |
154
- (dep.skipSelf ? 4 /* InjectFlags.SkipSelf */ : 0) |
155
- 0 |
156
- (dep.optional ? 8 /* InjectFlags.Optional */ : 0) |
157
- 0;
158
- // If this dependency is optional or otherwise has non-default flags, then additional
159
- // parameters describing how to inject the dependency must be passed to the inject function
160
- // that's being used.
161
- let flagsParam = flags !== 0 /* InjectFlags.Default */ || dep.optional ? o.literal(flags) : null;
162
- // Build up the arguments to the injectFn call.
163
- const injectArgs = [dep.token];
164
- if (flagsParam) {
165
- injectArgs.push(flagsParam);
166
- }
167
- const injectFn = getInjectFn(target);
168
- return o.importExpr(injectFn).callFn(injectArgs);
169
- }
170
- else {
171
- throw new Error('compileInjectDependency');
172
- }
173
- }
174
- function createCtorDepsType(deps) {
175
- let hasTypes = false;
176
- const attributeTypes = deps.map((dep) => {
177
- const type = createCtorDepType(dep);
178
- if (type !== null) {
179
- hasTypes = true;
180
- return type;
181
- }
182
- else {
183
- return o.literal(null);
184
- }
185
- });
186
- if (hasTypes) {
187
- return o.expressionType(o.literalArr(attributeTypes));
188
- }
189
- else {
190
- return o.NONE_TYPE;
191
- }
192
- }
193
- function createCtorDepType(dep) {
194
- const entries = [];
195
- if (dep.optional) {
196
- entries.push({ key: 'optional', value: o.literal(true), quoted: false });
197
- }
198
- if (dep.self) {
199
- entries.push({ key: 'self', value: o.literal(true), quoted: false });
200
- }
201
- if (dep.skipSelf) {
202
- entries.push({ key: 'skipSelf', value: o.literal(true), quoted: false });
203
- }
204
- return entries.length > 0 ? o.literalMap(entries) : null;
205
- }
206
- function isDelegatedFactoryMetadata(meta) {
207
- return meta.delegateType !== undefined;
208
- }
209
- exports.isDelegatedFactoryMetadata = isDelegatedFactoryMetadata;
210
- function isExpressionFactoryMetadata(meta) {
211
- return meta.expression !== undefined;
212
- }
213
- exports.isExpressionFactoryMetadata = isExpressionFactoryMetadata;
214
- function getInjectFn(target) {
215
- switch (target) {
216
- case FactoryTarget.Component:
217
- case FactoryTarget.Directive:
218
- case FactoryTarget.Pipe:
219
- return r3_identifiers_1.Identifiers.directiveInject;
220
- case FactoryTarget.NgModule:
221
- case FactoryTarget.Injectable:
222
- default:
223
- return r3_identifiers_1.Identifiers.inject;
224
- }
225
- }
@@ -1,20 +0,0 @@
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 * as o from '../output/output_ast';
9
- export declare class Identifiers {
10
- static inject: o.ExternalReference;
11
- static directiveInject: o.ExternalReference;
12
- static invalidFactory: o.ExternalReference;
13
- static invalidFactoryDep: o.ExternalReference;
14
- static forwardRef: o.ExternalReference;
15
- static resolveForwardRef: o.ExternalReference;
16
- static ɵɵdefineInjectable: o.ExternalReference;
17
- static InjectableDeclaration: o.ExternalReference;
18
- static FactoryDeclaration: o.ExternalReference;
19
- static getInheritedFactory: o.ExternalReference;
20
- }