static-injector 1.0.10 → 2.1.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 (111) hide show
  1. package/import/commonjs/index.js +337 -124
  2. package/import/es2015/di/create_injector.js +30 -0
  3. package/import/es2015/di/initializer_token.js +15 -0
  4. package/import/es2015/di/inject_switch.js +27 -6
  5. package/import/es2015/di/injection_token.js +6 -0
  6. package/import/es2015/di/injector.js +6 -8
  7. package/import/es2015/di/injector_compatibility.js +90 -34
  8. package/import/es2015/di/injector_token.js +1 -1
  9. package/import/es2015/di/interface/defs.js +39 -0
  10. package/import/es2015/di/interface/injector.js +1 -0
  11. package/import/es2015/di/internal_tokens.js +9 -0
  12. package/import/es2015/di/metadata.js +4 -4
  13. package/import/es2015/di/provider_collection.js +49 -0
  14. package/import/es2015/di/r3_injector.js +102 -72
  15. package/import/es2015/di/scope.js +2 -2
  16. package/import/es2015/index.js +1 -1
  17. package/import/es2015/render3/errors_di.js +1 -1
  18. package/import/fesm2015/index.js +328 -114
  19. package/import/typings/di/create_injector.d.ts +23 -0
  20. package/import/typings/di/initializer_token.d.ts +15 -0
  21. package/import/typings/di/inject_switch.d.ts +7 -2
  22. package/import/typings/{decorator → di}/injectable.d.ts +2 -2
  23. package/import/typings/di/injection_token.d.ts +4 -0
  24. package/import/typings/di/injector.d.ts +20 -7
  25. package/import/typings/di/injector_compatibility.d.ts +42 -21
  26. package/import/typings/di/interface/defs.d.ts +10 -0
  27. package/import/typings/di/interface/injector.d.ts +26 -0
  28. package/import/typings/di/interface/provider.d.ts +3 -8
  29. package/import/typings/di/internal_tokens.d.ts +10 -0
  30. package/import/typings/di/provider_collection.d.ts +30 -0
  31. package/import/typings/di/provider_token.d.ts +1 -1
  32. package/import/typings/di/r3_injector.d.ts +68 -37
  33. package/import/typings/di/scope.d.ts +3 -2
  34. package/import/typings/index.d.ts +1 -1
  35. package/import/typings/render3/definition_factory.d.ts +1 -1
  36. package/package.json +5 -3
  37. package/{import/es2015/decorator/interface/provider.js → transform/compiler/compiler.d.ts} +1 -1
  38. package/transform/compiler/compiler.js +28 -0
  39. package/transform/compiler/index.d.ts +8 -5
  40. package/transform/compiler/index.js +17 -6
  41. package/transform/compiler/public_api.d.ts +13 -0
  42. package/transform/compiler/public_api.js +30 -0
  43. package/transform/compiler/src/compiler.d.ts +27 -0
  44. package/transform/compiler/src/compiler.js +47 -0
  45. package/transform/compiler/src/injectable_compiler_2.d.ts +7 -36
  46. package/transform/compiler/src/injectable_compiler_2.js +20 -23
  47. package/transform/compiler/src/output/output_ast.d.ts +30 -109
  48. package/transform/compiler/src/output/output_ast.js +66 -188
  49. package/transform/compiler/src/render3/partial/api.d.ts +1 -1
  50. package/transform/compiler/src/render3/partial/api.js +7 -0
  51. package/transform/compiler/src/render3/r3_factory.d.ts +8 -15
  52. package/transform/compiler/src/render3/r3_factory.js +46 -61
  53. package/transform/compiler/src/render3/util.d.ts +64 -0
  54. package/transform/compiler/src/render3/util.js +52 -9
  55. package/transform/compiler/src/render3/view/util.d.ts +0 -8
  56. package/transform/compiler/src/render3/view/util.js +5 -9
  57. package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +10 -0
  58. package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +26 -0
  59. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +37 -0
  60. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +197 -0
  61. package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.d.ts +3 -3
  62. package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.js +3 -3
  63. package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/util.d.ts +4 -34
  64. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +181 -0
  65. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +3 -4
  66. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +46 -53
  67. package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +6 -2
  68. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +9 -2
  69. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +12 -1
  70. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +7 -0
  71. package/transform/compiler-cli/src/ngtsc/imports/index.js +12 -1
  72. package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +19 -0
  73. package/transform/compiler-cli/src/ngtsc/imports/src/default.js +28 -0
  74. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +10 -3
  75. package/transform/compiler-cli/src/ngtsc/reflection/index.js +12 -1
  76. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +13 -14
  77. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +8 -25
  78. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +2 -2
  79. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +44 -55
  80. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +1 -1
  81. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +55 -69
  82. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +2 -2
  83. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +7 -23
  84. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +9 -2
  85. package/transform/compiler-cli/src/ngtsc/transform/index.js +12 -1
  86. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +4 -4
  87. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +2 -2
  88. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +16 -31
  89. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +12 -5
  90. package/transform/compiler-cli/src/ngtsc/translator/index.js +12 -1
  91. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +5 -5
  92. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +4 -4
  93. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +5 -21
  94. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +2 -6
  95. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +6 -18
  96. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +3 -6
  97. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +83 -90
  98. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +4 -4
  99. package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.d.ts +8 -0
  100. package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.js +24 -0
  101. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +45 -0
  102. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +86 -0
  103. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +1 -8
  104. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +4 -27
  105. package/transform/index.js +5 -1
  106. package/transform/injectable-transform.js +59 -38
  107. package/import/typings/decorator/interface/provider.d.ts +0 -312
  108. package/transform/compiler/src/render3/partial/util.d.ts +0 -16
  109. package/transform/compiler/src/render3/partial/util.js +0 -44
  110. package/transform/compiler-cli/src/ngtsc/annotations/src/util.js +0 -370
  111. /package/import/es2015/{decorator → di}/injectable.js +0 -0
@@ -6,33 +6,17 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
11
  };
28
12
  Object.defineProperty(exports, "__esModule", { value: true });
29
13
  exports.InjectableDecoratorHandler = void 0;
30
- const compiler_1 = require("../../../../../compiler");
31
- const ts = __importStar(require("typescript"));
14
+ const compiler_1 = require("static-injector/transform/compiler");
15
+ const typescript_1 = __importDefault(require("typescript"));
16
+ const common_1 = require("../../annotations/common");
32
17
  const diagnostics_1 = require("../../diagnostics");
33
18
  const reflection_1 = require("../../reflection");
34
- const factory_1 = require("./factory");
35
- const util_1 = require("./util");
19
+ const common_2 = require("../common");
36
20
  /**
37
21
  * Adapts the `compileInjectable` compiler for `@Injectable` decorators to the Ivy compiler.
38
22
  */
@@ -54,7 +38,7 @@ class InjectableDecoratorHandler {
54
38
  if (!decorators) {
55
39
  return undefined;
56
40
  }
57
- const decorator = util_1.findAngularDecorator(decorators, 'Injectable', this.isCore);
41
+ const decorator = (0, common_2.findAngularDecorator)(decorators, 'Injectable', this.isCore);
58
42
  if (decorator !== undefined) {
59
43
  return {
60
44
  trigger: decorator.node,
@@ -78,13 +62,15 @@ class InjectableDecoratorHandler {
78
62
  };
79
63
  }
80
64
  compileFull(node, analysis) {
81
- return this.compile(factory_1.compileNgFactoryDefField, (meta) => compiler_1.compileInjectable(meta, false), node, analysis);
65
+ return this.compile(common_2.compileNgFactoryDefField, (meta) => (0, compiler_1.compileInjectable)(meta, false), node, analysis);
82
66
  }
83
67
  compile(compileFactoryFn, compileInjectableFn, node, analysis) {
84
68
  const results = [];
85
- const meta = analysis.meta;
86
- const factoryRes = compileFactoryFn(util_1.toFactoryMetadata(Object.assign(Object.assign({}, meta), { deps: analysis.ctorDeps }), compiler_1.FactoryTarget.Injectable));
87
- results.push(factoryRes);
69
+ if (true) {
70
+ const meta = analysis.meta;
71
+ const factoryRes = compileFactoryFn((0, common_2.toFactoryMetadata)(Object.assign(Object.assign({}, meta), { deps: analysis.ctorDeps }), compiler_1.FactoryTarget.Injectable));
72
+ results.push(factoryRes);
73
+ }
88
74
  const ɵprov = this.reflector
89
75
  .getMembersOfClass(node)
90
76
  .find((member) => member.name === 'ɵprov');
@@ -113,7 +99,7 @@ exports.InjectableDecoratorHandler = InjectableDecoratorHandler;
113
99
  */
114
100
  function extractInjectableMetadata(clazz, decorator, reflector) {
115
101
  const name = clazz.name.text;
116
- const type = util_1.wrapTypeReference(reflector, clazz);
102
+ const type = (0, common_2.wrapTypeReference)(reflector, clazz);
117
103
  const internalType = new compiler_1.WrappedNodeExpr(reflector.getInternalNameOfClass(clazz));
118
104
  const typeArgumentCount = reflector.getGenericArityOfClass(clazz) || 0;
119
105
  if (decorator.args === null) {
@@ -125,7 +111,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
125
111
  type,
126
112
  typeArgumentCount,
127
113
  internalType,
128
- providedIn: compiler_1.createR3ProviderExpression(new compiler_1.LiteralExpr(null), false),
114
+ providedIn: (0, compiler_1.createMayBeForwardRefExpression)(new compiler_1.LiteralExpr(null), 0 /* ForwardRefHandling.None */),
129
115
  };
130
116
  }
131
117
  else if (decorator.args.length === 1) {
@@ -133,18 +119,18 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
133
119
  // Firstly make sure the decorator argument is an inline literal - if not, it's illegal to
134
120
  // transport references from one location to another. This is the problem that lowering
135
121
  // used to solve - if this restriction proves too undesirable we can re-implement lowering.
136
- if (!ts.isObjectLiteralExpression(metaNode)) {
122
+ if (!typescript_1.default.isObjectLiteralExpression(metaNode)) {
137
123
  throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_ARG_NOT_LITERAL, metaNode, `@Injectable argument must be an object literal`);
138
124
  }
139
125
  // Resolve the fields of the literal into a map of field name to expression.
140
- const meta = reflection_1.reflectObjectLiteral(metaNode);
126
+ const meta = (0, reflection_1.reflectObjectLiteral)(metaNode);
141
127
  const providedIn = meta.has('providedIn')
142
128
  ? getProviderExpression(meta.get('providedIn'), reflector)
143
- : compiler_1.createR3ProviderExpression(new compiler_1.LiteralExpr(null), false);
129
+ : (0, compiler_1.createMayBeForwardRefExpression)(new compiler_1.LiteralExpr(null), 0 /* ForwardRefHandling.None */);
144
130
  let deps = undefined;
145
131
  if ((meta.has('useClass') || meta.has('useFactory')) && meta.has('deps')) {
146
132
  const depsExpr = meta.get('deps');
147
- if (!ts.isArrayLiteralExpression(depsExpr)) {
133
+ if (!typescript_1.default.isArrayLiteralExpression(depsExpr)) {
148
134
  throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.VALUE_NOT_LITERAL, depsExpr, `@Injectable deps metadata must be an inline array`);
149
135
  }
150
136
  deps = depsExpr.elements.map((dep) => getDep(dep, reflector));
@@ -184,8 +170,10 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
184
170
  * object to indicate whether the value needed unwrapping.
185
171
  */
186
172
  function getProviderExpression(expression, reflector) {
187
- const forwardRefValue = util_1.tryUnwrapForwardRef(expression, reflector);
188
- return compiler_1.createR3ProviderExpression(new compiler_1.WrappedNodeExpr(forwardRefValue !== null && forwardRefValue !== void 0 ? forwardRefValue : expression), forwardRefValue !== null);
173
+ const forwardRefValue = (0, common_2.tryUnwrapForwardRef)(expression, reflector);
174
+ return (0, compiler_1.createMayBeForwardRefExpression)(new compiler_1.WrappedNodeExpr(forwardRefValue !== null && forwardRefValue !== void 0 ? forwardRefValue : expression), forwardRefValue !== null
175
+ ? 2 /* ForwardRefHandling.Unwrapped */
176
+ : 0 /* ForwardRefHandling.None */);
189
177
  }
190
178
  function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps) {
191
179
  if (decorator.args === null) {
@@ -201,30 +189,35 @@ function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, st
201
189
  // To deal with this, @Injectable() without an argument is more lenient, and if the
202
190
  // constructor signature does not work for DI then a factory definition (ɵfac) that throws is
203
191
  // generated.
204
- if (strictCtorDeps) {
205
- ctorDeps = util_1.getValidConstructorDependencies(clazz, reflector, isCore);
192
+ if (strictCtorDeps && !(0, common_1.isAbstractClassDeclaration)(clazz)) {
193
+ ctorDeps = (0, common_2.getValidConstructorDependencies)(clazz, reflector, isCore);
206
194
  }
207
195
  else {
208
- ctorDeps = util_1.unwrapConstructorDependencies(util_1.getConstructorDependencies(clazz, reflector, isCore));
196
+ ctorDeps = (0, common_2.unwrapConstructorDependencies)((0, common_2.getConstructorDependencies)(clazz, reflector, isCore));
209
197
  }
210
198
  return ctorDeps;
211
199
  }
212
200
  else if (decorator.args.length === 1) {
213
- const rawCtorDeps = util_1.getConstructorDependencies(clazz, reflector, isCore);
201
+ const rawCtorDeps = (0, common_2.getConstructorDependencies)(clazz, reflector, isCore);
214
202
  if (strictCtorDeps &&
215
- meta.useValue === undefined &&
216
- meta.useExisting === undefined &&
217
- meta.useClass === undefined &&
218
- meta.useFactory === undefined) {
219
- // Since use* was not provided, validate the deps according to strictCtorDeps.
220
- ctorDeps = util_1.validateConstructorDependencies(clazz, rawCtorDeps);
203
+ !(0, common_1.isAbstractClassDeclaration)(clazz) &&
204
+ requiresValidCtor(meta)) {
205
+ // Since use* was not provided for a concrete class, validate the deps according to
206
+ // strictCtorDeps.
207
+ ctorDeps = (0, common_2.validateConstructorDependencies)(clazz, rawCtorDeps);
221
208
  }
222
209
  else {
223
- ctorDeps = util_1.unwrapConstructorDependencies(rawCtorDeps);
210
+ ctorDeps = (0, common_2.unwrapConstructorDependencies)(rawCtorDeps);
224
211
  }
225
212
  }
226
213
  return ctorDeps;
227
214
  }
215
+ function requiresValidCtor(meta) {
216
+ return (meta.useValue === undefined &&
217
+ meta.useExisting === undefined &&
218
+ meta.useClass === undefined &&
219
+ meta.useFactory === undefined);
220
+ }
228
221
  function getDep(dep, reflector) {
229
222
  const meta = {
230
223
  token: new compiler_1.WrappedNodeExpr(dep),
@@ -258,18 +251,18 @@ function getDep(dep, reflector) {
258
251
  }
259
252
  return true;
260
253
  }
261
- if (ts.isArrayLiteralExpression(dep)) {
254
+ if (typescript_1.default.isArrayLiteralExpression(dep)) {
262
255
  dep.elements.forEach((el) => {
263
- let isParametersDecorator = false;
264
- if (ts.isIdentifier(el)) {
265
- isParametersDecorator = maybeUpdateDecorator(el, reflector);
256
+ let isDecorator = false;
257
+ if (typescript_1.default.isIdentifier(el)) {
258
+ isDecorator = maybeUpdateDecorator(el, reflector);
266
259
  }
267
- else if (ts.isNewExpression(el) && ts.isIdentifier(el.expression)) {
260
+ else if (typescript_1.default.isNewExpression(el) && typescript_1.default.isIdentifier(el.expression)) {
268
261
  const token = (el.arguments && el.arguments.length > 0 && el.arguments[0]) ||
269
262
  undefined;
270
- isParametersDecorator = maybeUpdateDecorator(el.expression, reflector, token);
263
+ isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
271
264
  }
272
- if (!isParametersDecorator) {
265
+ if (!isDecorator) {
273
266
  meta.token = new compiler_1.WrappedNodeExpr(el);
274
267
  }
275
268
  });
@@ -8,7 +8,11 @@
8
8
  */
9
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
10
  if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
12
16
  }) : (function(o, m, k, k2) {
13
17
  if (k2 === undefined) k2 = k;
14
18
  o[k2] = m[k];
@@ -49,7 +53,7 @@ function makeDiagnostic(code, node, messageText, relatedInformation) {
49
53
  node = ts.getOriginalNode(node);
50
54
  return {
51
55
  category: ts.DiagnosticCategory.Error,
52
- code: error_code_1.ngErrorCode(code),
56
+ code: (0, error_code_1.ngErrorCode)(code),
53
57
  file: ts.getOriginalNode(node).getSourceFile(),
54
58
  start: node.getStart(undefined, false),
55
59
  length: node.getWidth(),
@@ -1,2 +1,9 @@
1
- export * from "./error";
2
- export * from "./error_code";
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 * from './error';
9
+ export * from './error_code';
@@ -1,7 +1,18 @@
1
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
+ */
2
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
10
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
16
  }) : (function(o, m, k, k2) {
6
17
  if (k2 === undefined) k2 = k;
7
18
  o[k2] = m[k];
@@ -1 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
1
8
  export * from './src/core';
@@ -1,7 +1,18 @@
1
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
+ */
2
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
10
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
16
  }) : (function(o, m, k, k2) {
6
17
  if (k2 === undefined) k2 = k;
7
18
  o[k2] = m[k];
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { WrappedNodeExpr } from 'static-injector/transform/compiler';
9
+ import ts from 'typescript';
10
+ /**
11
+ * Attaches a default import declaration to `expr` to indicate the dependency of `expr` on the
12
+ * default import.
13
+ */
14
+ export declare function attachDefaultImportDeclaration(expr: WrappedNodeExpr<unknown>, importDecl: ts.ImportDeclaration): void;
15
+ /**
16
+ * Obtains the default import declaration that `expr` depends on, or `null` if there is no such
17
+ * dependency.
18
+ */
19
+ export declare function getDefaultImportDeclaration(expr: WrappedNodeExpr<unknown>): ts.ImportDeclaration | null;
@@ -0,0 +1,28 @@
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.getDefaultImportDeclaration = exports.attachDefaultImportDeclaration = void 0;
11
+ const DefaultImportDeclaration = Symbol('DefaultImportDeclaration');
12
+ /**
13
+ * Attaches a default import declaration to `expr` to indicate the dependency of `expr` on the
14
+ * default import.
15
+ */
16
+ function attachDefaultImportDeclaration(expr, importDecl) {
17
+ expr[DefaultImportDeclaration] = importDecl;
18
+ }
19
+ exports.attachDefaultImportDeclaration = attachDefaultImportDeclaration;
20
+ /**
21
+ * Obtains the default import declaration that `expr` depends on, or `null` if there is no such
22
+ * dependency.
23
+ */
24
+ function getDefaultImportDeclaration(expr) {
25
+ var _a;
26
+ return ((_a = expr[DefaultImportDeclaration]) !== null && _a !== void 0 ? _a : null);
27
+ }
28
+ exports.getDefaultImportDeclaration = getDefaultImportDeclaration;
@@ -1,3 +1,10 @@
1
- export * from "./src/host";
2
- export * from "./src/typescript";
3
- export * from "./src/util";
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 * from './src/host';
9
+ export * from './src/typescript';
10
+ export * from './src/util';
@@ -1,7 +1,18 @@
1
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
+ */
2
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
10
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
16
  }) : (function(o, m, k, k2) {
6
17
  if (k2 === undefined) k2 = k;
7
18
  o[k2] = m[k];
@@ -5,12 +5,12 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import * as ts from 'typescript';
8
+ import ts from 'typescript';
9
9
  /**
10
10
  * Metadata extracted from an instance of a decorator on another declaration, or synthesized from
11
11
  * other information about a class.
12
12
  */
13
- export declare type Decorator = ConcreteDecorator | SyntheticDecorator;
13
+ export type Decorator = ConcreteDecorator | SyntheticDecorator;
14
14
  export interface BaseDecorator {
15
15
  /**
16
16
  * Name by which the decorator was invoked in the user's code.
@@ -68,12 +68,11 @@ export declare const Decorator: {
68
68
  * A decorator is identified by either a simple identifier (e.g. `Decorator`) or, in some cases,
69
69
  * a namespaced property access (e.g. `core.Decorator`).
70
70
  */
71
- export declare type DecoratorIdentifier = ts.Identifier | NamespacedIdentifier;
72
- export declare type NamespacedIdentifier = ts.PropertyAccessExpression & {
71
+ export type DecoratorIdentifier = ts.Identifier | NamespacedIdentifier;
72
+ export type NamespacedIdentifier = ts.PropertyAccessExpression & {
73
73
  expression: ts.Identifier;
74
74
  name: ts.Identifier;
75
75
  };
76
- /** 装饰器可能是 Injectable或者xx.Injectable */
77
76
  export declare function isDecoratorIdentifier(exp: ts.Expression): exp is DecoratorIdentifier;
78
77
  /**
79
78
  * The `ts.Declaration` of a "class".
@@ -90,7 +89,7 @@ export declare function isDecoratorIdentifier(exp: ts.Expression): exp is Decora
90
89
  * For `ReflectionHost` purposes, a class declaration should always have a `name` identifier,
91
90
  * because we need to be able to reference it in other parts of the program.
92
91
  */
93
- export declare type ClassDeclaration<T extends DeclarationNode = DeclarationNode> = T & {
92
+ export type ClassDeclaration<T extends DeclarationNode = DeclarationNode> = T & {
94
93
  name: ts.Identifier;
95
94
  };
96
95
  /**
@@ -290,7 +289,7 @@ export interface NoValueDeclaration {
290
289
  export interface TypeOnlyImport {
291
290
  kind: ValueUnavailableKind.TYPE_ONLY_IMPORT;
292
291
  typeNode: ts.TypeNode;
293
- importClause: ts.ImportClause;
292
+ node: ts.ImportClause | ts.ImportSpecifier;
294
293
  }
295
294
  export interface NamespaceImport {
296
295
  kind: ValueUnavailableKind.NAMESPACE;
@@ -307,7 +306,7 @@ export interface MissingType {
307
306
  /**
308
307
  * The various reasons why a type node may not be referred to as a value.
309
308
  */
310
- export declare type UnavailableValue = UnsupportedType | NoValueDeclaration | TypeOnlyImport | NamespaceImport | UnknownReference | MissingType;
309
+ export type UnavailableValue = UnsupportedType | NoValueDeclaration | TypeOnlyImport | NamespaceImport | UnknownReference | MissingType;
311
310
  /**
312
311
  * A reference to a value that originated from a type position.
313
312
  *
@@ -317,7 +316,7 @@ export declare type UnavailableValue = UnsupportedType | NoValueDeclaration | Ty
317
316
  *
318
317
  * See the individual types for additional information.
319
318
  */
320
- export declare type TypeValueReference = LocalTypeValueReference | ImportedTypeValueReference | UnavailableTypeValueReference;
319
+ export type TypeValueReference = LocalTypeValueReference | ImportedTypeValueReference | UnavailableTypeValueReference;
321
320
  /**
322
321
  * A parameter to a constructor.
323
322
  */
@@ -441,7 +440,7 @@ export interface Import {
441
440
  /**
442
441
  * The module from which the symbol was imported.
443
442
  *
444
- * This could either be an absolute module name (static-injector for example) or a relative path.
443
+ * This could either be an absolute module name (@angular/core for example) or a relative path.
445
444
  */
446
445
  from: string;
447
446
  }
@@ -470,7 +469,7 @@ export interface EnumMember {
470
469
  * An example of this is `exports.someVar = 42` where the declaration expression would be
471
470
  * `exports.someVar`.
472
471
  */
473
- export declare type DeclarationNode = ts.Declaration | ts.Expression;
472
+ export type DeclarationNode = ts.Declaration | ts.Expression;
474
473
  /**
475
474
  * The type of a Declaration - whether its node is concrete (ts.Declaration) or inline
476
475
  * (ts.Expression). See `ConcreteDeclaration`, `InlineDeclaration` and `DeclarationNode` for more
@@ -516,7 +515,7 @@ export interface ConcreteDeclaration<T extends ts.Declaration = ts.Declaration>
516
515
  */
517
516
  identity: SpecialDeclarationIdentity | null;
518
517
  }
519
- export declare type SpecialDeclarationIdentity = DownleveledEnum;
518
+ export type SpecialDeclarationIdentity = DownleveledEnum;
520
519
  export declare const enum SpecialDeclarationKind {
521
520
  DownleveledEnum = 0
522
521
  }
@@ -544,7 +543,7 @@ export interface InlineDeclaration extends BaseDeclaration<Exclude<DeclarationNo
544
543
  * The declaration of a symbol, along with information about how it was imported into the
545
544
  * application.
546
545
  */
547
- export declare type Declaration<T extends ts.Declaration = ts.Declaration> = ConcreteDeclaration<T> | InlineDeclaration;
546
+ export type Declaration<T extends ts.Declaration = ts.Declaration> = ConcreteDeclaration<T> | InlineDeclaration;
548
547
  /**
549
548
  * Abstracts reflection operations on a TypeScript AST.
550
549
  *
@@ -599,7 +598,7 @@ export interface ReflectionHost {
599
598
  * Determine if an identifier was imported from another module and return `Import` metadata
600
599
  * describing its origin.
601
600
  *
602
- * @param id a TypeScript `ts.Identifer` to reflect.
601
+ * @param id a TypeScript `ts.Identifier` to reflect.
603
602
  *
604
603
  * @returns metadata about the `Import` if the identifier was imported from another module, or
605
604
  * `null` if the identifier doesn't resolve to an import but instead is locally defined.
@@ -6,28 +6,12 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
11
  };
28
12
  Object.defineProperty(exports, "__esModule", { value: true });
29
13
  exports.isConcreteDeclaration = exports.KnownDeclaration = exports.ClassMemberKind = exports.isDecoratorIdentifier = exports.Decorator = void 0;
30
- const ts = __importStar(require("typescript"));
14
+ const typescript_1 = __importDefault(require("typescript"));
31
15
  exports.Decorator = {
32
16
  nodeForError: (decorator) => {
33
17
  if (decorator.node !== null) {
@@ -39,12 +23,11 @@ exports.Decorator = {
39
23
  }
40
24
  },
41
25
  };
42
- /** 装饰器可能是 Injectable或者xx.Injectable */
43
26
  function isDecoratorIdentifier(exp) {
44
- return (ts.isIdentifier(exp) ||
45
- (ts.isPropertyAccessExpression(exp) &&
46
- ts.isIdentifier(exp.expression) &&
47
- ts.isIdentifier(exp.name)));
27
+ return (typescript_1.default.isIdentifier(exp) ||
28
+ (typescript_1.default.isPropertyAccessExpression(exp) &&
29
+ typescript_1.default.isIdentifier(exp.expression) &&
30
+ typescript_1.default.isIdentifier(exp.name)));
48
31
  }
49
32
  exports.isDecoratorIdentifier = isDecoratorIdentifier;
50
33
  /**
@@ -93,6 +76,6 @@ var KnownDeclaration;
93
76
  * `ts.Declaration`).
94
77
  */
95
78
  function isConcreteDeclaration(decl) {
96
- return decl.kind === 0 /* Concrete */;
79
+ return decl.kind === 0 /* DeclarationKind.Concrete */;
97
80
  }
98
81
  exports.isConcreteDeclaration = isConcreteDeclaration;
@@ -5,8 +5,8 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import * as ts from "typescript";
9
- import { TypeValueReference } from "./host";
8
+ import ts from 'typescript';
9
+ import { TypeValueReference } from './host';
10
10
  /**
11
11
  * Potentially convert a `ts.TypeNode` to a `TypeValueReference`, which indicates how to use the
12
12
  * type given in the `ts.TypeNode` in a value position.