static-injector 4.0.1 → 5.0.0-alpha.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 +33 -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,55 +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.Identifiers = void 0;
11
- const CORE = 'static-injector';
12
- class Identifiers {
13
- /* Methods */
14
- /* Instructions */
15
- static inject = { name: 'ɵɵinject', moduleName: CORE };
16
- static directiveInject = {
17
- name: 'ɵɵdirectiveInject',
18
- moduleName: CORE,
19
- };
20
- static invalidFactory = {
21
- name: 'ɵɵinvalidFactory',
22
- moduleName: CORE,
23
- };
24
- static invalidFactoryDep = {
25
- name: 'ɵɵinvalidFactoryDep',
26
- moduleName: CORE,
27
- };
28
- static forwardRef = {
29
- name: 'forwardRef',
30
- moduleName: CORE,
31
- };
32
- static resolveForwardRef = {
33
- name: 'resolveForwardRef',
34
- moduleName: CORE,
35
- };
36
- static ɵɵdefineInjectable = {
37
- name: 'ɵɵdefineInjectable',
38
- moduleName: CORE,
39
- };
40
- static InjectableDeclaration = {
41
- name: 'ɵɵInjectableDeclaration',
42
- moduleName: CORE,
43
- };
44
- static FactoryDeclaration = {
45
- name: 'ɵɵFactoryDeclaration',
46
- moduleName: CORE,
47
- };
48
- // Signal queries
49
- // Two-way bindings
50
- static getInheritedFactory = {
51
- name: 'ɵɵgetInheritedFactory',
52
- moduleName: CORE,
53
- };
54
- }
55
- exports.Identifiers = Identifiers;
@@ -1,85 +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 function typeWithParameters(type: o.Expression, numParams: number): o.ExpressionType;
10
- export interface R3Reference {
11
- value: o.Expression;
12
- type: o.Expression;
13
- }
14
- /**
15
- * Result of compilation of a render3 code unit, e.g. component, directive, pipe, etc.
16
- */
17
- export interface R3CompiledExpression {
18
- expression: o.Expression;
19
- type: o.Type;
20
- statements: o.Statement[];
21
- }
22
- /**
23
- * Describes an expression that may have been wrapped in a `forwardRef()` guard.
24
- *
25
- * This is used when describing expressions that can refer to types that may eagerly reference types
26
- * that have not yet been defined.
27
- */
28
- export interface MaybeForwardRefExpression<T extends o.Expression = o.Expression> {
29
- /**
30
- * The unwrapped expression.
31
- */
32
- expression: T;
33
- /**
34
- * Specified whether the `expression` contains a reference to something that has not yet been
35
- * defined, and whether the expression is still wrapped in a `forwardRef()` call.
36
- *
37
- * If this value is `ForwardRefHandling.None` then the `expression` is safe to use as-is.
38
- *
39
- * Otherwise the `expression` was wrapped in a call to `forwardRef()` and must not be eagerly
40
- * evaluated. Instead it must be wrapped in a function closure that will be evaluated lazily to
41
- * allow the definition of the expression to be evaluated first.
42
- *
43
- * In full AOT compilation it can be safe to unwrap the `forwardRef()` call up front if the
44
- * expression will actually be evaluated lazily inside a function call after the value of
45
- * `expression` has been defined.
46
- *
47
- * But in other cases, such as partial AOT compilation or JIT compilation the expression will be
48
- * evaluated eagerly in top level code so will need to continue to be wrapped in a `forwardRef()`
49
- * call.
50
- *
51
- */
52
- forwardRef: ForwardRefHandling;
53
- }
54
- export declare function createMayBeForwardRefExpression<T extends o.Expression>(expression: T, forwardRef: ForwardRefHandling): MaybeForwardRefExpression<T>;
55
- /**
56
- * Convert a `MaybeForwardRefExpression` to an `Expression`, possibly wrapping its expression in a
57
- * `forwardRef()` call.
58
- *
59
- * If `MaybeForwardRefExpression.forwardRef` is `ForwardRefHandling.Unwrapped` then the expression
60
- * was originally wrapped in a `forwardRef()` call to prevent the value from being eagerly evaluated
61
- * in the code.
62
- *
63
- * See `packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts` and
64
- * `packages/compiler/src/jit_compiler_facade.ts` for more information.
65
- */
66
- export declare function convertFromMaybeForwardRefExpression({ expression, forwardRef, }: MaybeForwardRefExpression): o.Expression;
67
- /**
68
- * Generate an expression that has the given `expr` wrapped in the following form:
69
- *
70
- * ```
71
- * forwardRef(() => expr)
72
- * ```
73
- */
74
- export declare function generateForwardRef(expr: o.Expression): o.Expression;
75
- /**
76
- * Specifies how a forward ref has been handled in a MaybeForwardRefExpression
77
- */
78
- export declare const enum ForwardRefHandling {
79
- /** The expression was not wrapped in a `forwardRef()` call in the first place. */
80
- None = 0,
81
- /** The expression is still wrapped in a `forwardRef()` call. */
82
- Wrapped = 1,
83
- /** The expression was wrapped in a `forwardRef()` call but has since been unwrapped. */
84
- Unwrapped = 2
85
- }
@@ -1,82 +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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.generateForwardRef = exports.convertFromMaybeForwardRefExpression = exports.createMayBeForwardRefExpression = exports.typeWithParameters = void 0;
34
- const o = __importStar(require("../output/output_ast"));
35
- const r3_identifiers_1 = require("./r3_identifiers");
36
- function typeWithParameters(type, numParams) {
37
- if (numParams === 0) {
38
- return o.expressionType(type);
39
- }
40
- const params = [];
41
- for (let i = 0; i < numParams; i++) {
42
- params.push(o.DYNAMIC_TYPE);
43
- }
44
- return o.expressionType(type, undefined, params);
45
- }
46
- exports.typeWithParameters = typeWithParameters;
47
- function createMayBeForwardRefExpression(expression, forwardRef) {
48
- return { expression, forwardRef };
49
- }
50
- exports.createMayBeForwardRefExpression = createMayBeForwardRefExpression;
51
- /**
52
- * Convert a `MaybeForwardRefExpression` to an `Expression`, possibly wrapping its expression in a
53
- * `forwardRef()` call.
54
- *
55
- * If `MaybeForwardRefExpression.forwardRef` is `ForwardRefHandling.Unwrapped` then the expression
56
- * was originally wrapped in a `forwardRef()` call to prevent the value from being eagerly evaluated
57
- * in the code.
58
- *
59
- * See `packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts` and
60
- * `packages/compiler/src/jit_compiler_facade.ts` for more information.
61
- */
62
- function convertFromMaybeForwardRefExpression({ expression, forwardRef, }) {
63
- switch (forwardRef) {
64
- case 0 /* ForwardRefHandling.None */:
65
- case 1 /* ForwardRefHandling.Wrapped */:
66
- return expression;
67
- case 2 /* ForwardRefHandling.Unwrapped */:
68
- return generateForwardRef(expression);
69
- }
70
- }
71
- exports.convertFromMaybeForwardRefExpression = convertFromMaybeForwardRefExpression;
72
- /**
73
- * Generate an expression that has the given `expr` wrapped in the following form:
74
- *
75
- * ```
76
- * forwardRef(() => expr)
77
- * ```
78
- */
79
- function generateForwardRef(expr) {
80
- return o.importExpr(r3_identifiers_1.Identifiers.forwardRef).callFn([o.arrowFn([], expr)]);
81
- }
82
- exports.generateForwardRef = generateForwardRef;
@@ -1,24 +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
- /** Special value representing a direct access to a template's context. */
10
- export declare const DIRECT_CONTEXT_REFERENCE = "#context";
11
- /**
12
- * A representation for an object literal used during codegen of definition objects. The generic
13
- * type `T` allows to reference a documented type of the generated structure, such that the
14
- * property names that are set can be resolved to their documented declaration.
15
- */
16
- export declare class DefinitionMap<T = any> {
17
- values: {
18
- key: string;
19
- quoted: boolean;
20
- value: o.Expression;
21
- }[];
22
- set(key: keyof T, value: o.Expression | null): void;
23
- toLiteralMap(): o.LiteralMapExpr;
24
- }
@@ -1,59 +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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.DefinitionMap = exports.DIRECT_CONTEXT_REFERENCE = void 0;
34
- const o = __importStar(require("../../output/output_ast"));
35
- /** Special value representing a direct access to a template's context. */
36
- exports.DIRECT_CONTEXT_REFERENCE = '#context';
37
- /**
38
- * A representation for an object literal used during codegen of definition objects. The generic
39
- * type `T` allows to reference a documented type of the generated structure, such that the
40
- * property names that are set can be resolved to their documented declaration.
41
- */
42
- class DefinitionMap {
43
- values = [];
44
- set(key, value) {
45
- if (value) {
46
- const existing = this.values.find((value) => value.key === key);
47
- if (existing) {
48
- existing.value = value;
49
- }
50
- else {
51
- this.values.push({ key: key, value, quoted: false });
52
- }
53
- }
54
- }
55
- toLiteralMap() {
56
- return o.literalMap(this.values);
57
- }
58
- }
59
- exports.DefinitionMap = DefinitionMap;
@@ -1,3 +0,0 @@
1
- export * from './src/di';
2
- export * from './src/factory';
3
- export * from './src/util';
@@ -1,19 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./src/di"), exports);
18
- __exportStar(require("./src/factory"), exports);
19
- __exportStar(require("./src/util"), exports);
@@ -1,37 +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 { R3DependencyMetadata } from 'static-injector/transform/compiler';
9
- import { ClassDeclaration, CtorParameter, ReflectionHost, UnavailableValue } from '../../../reflection';
10
- export type ConstructorDeps = {
11
- deps: R3DependencyMetadata[];
12
- } | {
13
- deps: null;
14
- errors: ConstructorDepError[];
15
- };
16
- export interface ConstructorDepError {
17
- index: number;
18
- param: CtorParameter;
19
- reason: UnavailableValue;
20
- }
21
- export declare function getConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): ConstructorDeps | null;
22
- /**
23
- * Convert `ConstructorDeps` into the `R3DependencyMetadata` array for those deps if they're valid,
24
- * or into an `'invalid'` signal if they're not.
25
- *
26
- * This is a companion function to `validateConstructorDependencies` which accepts invalid deps.
27
- */
28
- export declare function unwrapConstructorDependencies(deps: ConstructorDeps | null): R3DependencyMetadata[] | 'invalid' | null;
29
- export declare function getValidConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): R3DependencyMetadata[] | null;
30
- /**
31
- * Validate that `ConstructorDeps` does not have any invalid dependencies and convert them into the
32
- * `R3DependencyMetadata` array if so, or raise a diagnostic if some deps are invalid.
33
- *
34
- * This is a companion function to `unwrapConstructorDependencies` which does not accept invalid
35
- * deps.
36
- */
37
- export declare function validateConstructorDependencies(clazz: ClassDeclaration, deps: ConstructorDeps | null): R3DependencyMetadata[] | null;
@@ -1,195 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.validateConstructorDependencies = exports.getValidConstructorDependencies = exports.unwrapConstructorDependencies = exports.getConstructorDependencies = void 0;
14
- const compiler_1 = require("static-injector/transform/compiler");
15
- const typescript_1 = __importDefault(require("typescript"));
16
- const diagnostics_1 = require("../../../diagnostics");
17
- const util_1 = require("./util");
18
- function getConstructorDependencies(clazz, reflector, isCore) {
19
- const deps = [];
20
- const errors = [];
21
- let ctorParams = reflector.getConstructorParameters(clazz);
22
- if (ctorParams === null) {
23
- if (reflector.hasBaseClass(clazz)) {
24
- return null;
25
- }
26
- else {
27
- ctorParams = [];
28
- }
29
- }
30
- ctorParams.forEach((param, idx) => {
31
- let token = (0, util_1.valueReferenceToExpression)(param.typeValueReference);
32
- let attributeNameType = null;
33
- let optional = false, self = false, skipSelf = false, host = false;
34
- (param.decorators || [])
35
- .filter((dec) => isCore || (0, util_1.isAngularCore)(dec))
36
- .forEach((dec) => {
37
- const name = isCore || dec.import === null ? dec.name : dec.import.name;
38
- if (name === 'Inject') {
39
- if (dec.args === null || dec.args.length !== 1) {
40
- throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_ARITY_WRONG, dec.node, `Unexpected number of arguments to @Inject().`);
41
- }
42
- token = new compiler_1.WrappedNodeExpr(dec.args[0]);
43
- }
44
- else if (name === 'Optional') {
45
- optional = true;
46
- }
47
- else if (name === 'SkipSelf') {
48
- skipSelf = true;
49
- }
50
- else if (name === 'Self') {
51
- self = true;
52
- }
53
- else if (name === 'Host') {
54
- }
55
- else if (name === 'Attribute') {
56
- }
57
- else {
58
- throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_UNEXPECTED, dec.node, `Unexpected decorator ${name} on parameter.`);
59
- }
60
- });
61
- if (token === null) {
62
- if (param.typeValueReference.kind !== 2 /* TypeValueReferenceKind.UNAVAILABLE */) {
63
- throw new Error('Illegal state: expected value reference to be unavailable if no token is present');
64
- }
65
- errors.push({
66
- index: idx,
67
- param,
68
- reason: param.typeValueReference.reason,
69
- });
70
- }
71
- else {
72
- deps.push({ token, attributeNameType, optional, self, skipSelf });
73
- }
74
- });
75
- if (errors.length === 0) {
76
- return { deps };
77
- }
78
- else {
79
- return { deps: null, errors };
80
- }
81
- }
82
- exports.getConstructorDependencies = getConstructorDependencies;
83
- /**
84
- * Convert `ConstructorDeps` into the `R3DependencyMetadata` array for those deps if they're valid,
85
- * or into an `'invalid'` signal if they're not.
86
- *
87
- * This is a companion function to `validateConstructorDependencies` which accepts invalid deps.
88
- */
89
- function unwrapConstructorDependencies(deps) {
90
- if (deps === null) {
91
- return null;
92
- }
93
- else if (deps.deps !== null) {
94
- // These constructor dependencies are valid.
95
- return deps.deps;
96
- }
97
- else {
98
- // These deps are invalid.
99
- return 'invalid';
100
- }
101
- }
102
- exports.unwrapConstructorDependencies = unwrapConstructorDependencies;
103
- function getValidConstructorDependencies(clazz, reflector, isCore) {
104
- return validateConstructorDependencies(clazz, getConstructorDependencies(clazz, reflector, isCore));
105
- }
106
- exports.getValidConstructorDependencies = getValidConstructorDependencies;
107
- /**
108
- * Validate that `ConstructorDeps` does not have any invalid dependencies and convert them into the
109
- * `R3DependencyMetadata` array if so, or raise a diagnostic if some deps are invalid.
110
- *
111
- * This is a companion function to `unwrapConstructorDependencies` which does not accept invalid
112
- * deps.
113
- */
114
- function validateConstructorDependencies(clazz, deps) {
115
- if (deps === null) {
116
- return null;
117
- }
118
- else if (deps.deps !== null) {
119
- return deps.deps;
120
- }
121
- else {
122
- // There is at least one error.
123
- const error = deps.errors[0];
124
- throw createUnsuitableInjectionTokenError(clazz, error);
125
- }
126
- }
127
- exports.validateConstructorDependencies = validateConstructorDependencies;
128
- /**
129
- * Creates a fatal error with diagnostic for an invalid injection token.
130
- * @param clazz The class for which the injection token was unavailable.
131
- * @param error The reason why no valid injection token is available.
132
- */
133
- function createUnsuitableInjectionTokenError(clazz, error) {
134
- const { param, index, reason } = error;
135
- let chainMessage = undefined;
136
- let hints = undefined;
137
- switch (reason.kind) {
138
- case 5 /* ValueUnavailableKind.UNSUPPORTED */:
139
- chainMessage =
140
- 'Consider using the @Inject decorator to specify an injection token.';
141
- hints = [
142
- (0, diagnostics_1.makeRelatedInformation)(reason.typeNode, 'This type is not supported as injection token.'),
143
- ];
144
- break;
145
- case 1 /* ValueUnavailableKind.NO_VALUE_DECLARATION */:
146
- chainMessage =
147
- 'Consider using the @Inject decorator to specify an injection token.';
148
- hints = [
149
- (0, diagnostics_1.makeRelatedInformation)(reason.typeNode, 'This type does not have a value, so it cannot be used as injection token.'),
150
- ];
151
- if (reason.decl !== null) {
152
- hints.push((0, diagnostics_1.makeRelatedInformation)(reason.decl, 'The type is declared here.'));
153
- }
154
- break;
155
- case 2 /* ValueUnavailableKind.TYPE_ONLY_IMPORT */:
156
- chainMessage =
157
- 'Consider changing the type-only import to a regular import, or use the @Inject decorator to specify an injection token.';
158
- hints = [
159
- (0, diagnostics_1.makeRelatedInformation)(reason.typeNode, 'This type is imported using a type-only import, which prevents it from being usable as an injection token.'),
160
- (0, diagnostics_1.makeRelatedInformation)(reason.node, 'The type-only import occurs here.'),
161
- ];
162
- break;
163
- case 4 /* ValueUnavailableKind.NAMESPACE */:
164
- chainMessage =
165
- 'Consider using the @Inject decorator to specify an injection token.';
166
- hints = [
167
- (0, diagnostics_1.makeRelatedInformation)(reason.typeNode, 'This type corresponds with a namespace, which cannot be used as injection token.'),
168
- (0, diagnostics_1.makeRelatedInformation)(reason.importClause, 'The namespace import occurs here.'),
169
- ];
170
- break;
171
- case 3 /* ValueUnavailableKind.UNKNOWN_REFERENCE */:
172
- chainMessage = 'The type should reference a known declaration.';
173
- hints = [
174
- (0, diagnostics_1.makeRelatedInformation)(reason.typeNode, 'This type could not be resolved.'),
175
- ];
176
- break;
177
- case 0 /* ValueUnavailableKind.MISSING_TYPE */:
178
- chainMessage =
179
- 'Consider adding a type to the parameter or use the @Inject decorator to specify an injection token.';
180
- break;
181
- }
182
- const chain = {
183
- messageText: `No suitable injection token for parameter '${param.name || index}' of class '${clazz.name.text}'.`,
184
- category: typescript_1.default.DiagnosticCategory.Error,
185
- code: 0,
186
- next: [
187
- {
188
- messageText: chainMessage,
189
- category: typescript_1.default.DiagnosticCategory.Message,
190
- code: 0,
191
- },
192
- ],
193
- };
194
- return new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.PARAM_MISSING_TOKEN, param.nameNode, chain, hints);
195
- }
@@ -1,11 +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 { R3FactoryMetadata } from 'static-injector/transform/compiler';
9
- import { CompileResult } from '../../../transform';
10
- export type CompileFactoryFn = (metadata: R3FactoryMetadata) => CompileResult;
11
- export declare function compileNgFactoryDefField(metadata: R3FactoryMetadata): CompileResult;
@@ -1,22 +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.compileNgFactoryDefField = void 0;
11
- const compiler_1 = require("static-injector/transform/compiler");
12
- function compileNgFactoryDefField(metadata) {
13
- const res = (0, compiler_1.compileFactoryFunction)(metadata);
14
- return {
15
- name: 'ɵfac',
16
- initializer: res.expression,
17
- statements: res.statements,
18
- type: res.type,
19
- deferrableImports: null,
20
- };
21
- }
22
- exports.compileNgFactoryDefField = compileNgFactoryDefField;
@@ -1,64 +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 { Expression, FactoryTarget, R3FactoryMetadata, R3Reference } from 'static-injector/transform/compiler';
9
- import ts from 'typescript';
10
- import { ClassDeclaration, Decorator, Import, ImportedTypeValueReference, LocalTypeValueReference, ReflectionHost, TypeValueReference } from '../../../reflection';
11
- /** Module name of the framework core. */
12
- export declare const CORE_MODULE = "static-injector";
13
- /**
14
- * Convert a `TypeValueReference` to an `Expression` which refers to the type as a value.
15
- *
16
- * Local references are converted to a `WrappedNodeExpr` of the TypeScript expression, and non-local
17
- * references are converted to an `ExternalExpr`. Note that this is only valid in the context of the
18
- * file in which the `TypeValueReference` originated.
19
- */
20
- export declare function valueReferenceToExpression(valueRef: LocalTypeValueReference | ImportedTypeValueReference): Expression;
21
- export declare function valueReferenceToExpression(valueRef: TypeValueReference): Expression | null;
22
- export declare function isAngularCore(decorator: Decorator): decorator is Decorator & {
23
- import: Import;
24
- };
25
- export declare function findAngularDecorator(decorators: Decorator[], name: string, isCore: boolean): Decorator | undefined;
26
- export declare function isAngularDecorator(decorator: Decorator, name: string, isCore: boolean): boolean;
27
- export declare function getAngularDecorators(decorators: Decorator[], names: readonly string[], isCore: boolean): Decorator[];
28
- /**
29
- * Unwrap a `ts.Expression`, removing outer type-casts or parentheses until the expression is in its
30
- * lowest level form.
31
- *
32
- * For example, the expression "(foo as Type)" unwraps to "foo".
33
- */
34
- export declare function unwrapExpression(node: ts.Expression): ts.Expression;
35
- /**
36
- * If the given `node` is a forwardRef() expression then resolve its inner value, otherwise return
37
- * `null`.
38
- *
39
- * @param node the forwardRef() expression to resolve
40
- * @param reflector a ReflectionHost
41
- * @returns the resolved expression, if the original expression was a forwardRef(), or `null`
42
- * otherwise.
43
- */
44
- export declare function tryUnwrapForwardRef(node: ts.Expression, reflector: ReflectionHost): ts.Expression | null;
45
- /**
46
- * Wraps all functions in a given expression in parentheses. This is needed to avoid problems
47
- * where Tsickle annotations added between analyse and transform phases in Angular may trigger
48
- * automatic semicolon insertion, e.g. if a function is the expression in a `return` statement.
49
- * More
50
- * info can be found in Tsickle source code here:
51
- * https://github.com/angular/tsickle/blob/d7974262571c8a17d684e5ba07680e1b1993afdd/src/jsdoc_transformer.ts#L1021
52
- *
53
- * @param expression Expression where functions should be wrapped in parentheses
54
- */
55
- export declare function wrapFunctionExpressionsInParens(expression: ts.Expression): ts.Expression;
56
- /**
57
- * Create an R3Reference for a class.
58
- *
59
- * The `value` is the exported declaration of the class from its source file.
60
- * The `type` is an expression that would be used in the typings (.d.ts) files.
61
- */
62
- export declare function wrapTypeReference(reflector: ReflectionHost, clazz: ClassDeclaration): R3Reference;
63
- export declare function toFactoryMetadata(meta: Omit<R3FactoryMetadata, 'target'>, target: FactoryTarget): R3FactoryMetadata;
64
- export declare function isAbstractClassDeclaration(clazz: ClassDeclaration): boolean;