@angular/compiler-cli 13.0.3 → 13.1.0-next.3

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 (88) hide show
  1. package/bundles/chunk-4EDYFHXN.js +681 -0
  2. package/bundles/chunk-4EDYFHXN.js.map +6 -0
  3. package/bundles/chunk-7HBAJSZA.js +5106 -0
  4. package/bundles/chunk-7HBAJSZA.js.map +6 -0
  5. package/bundles/chunk-7HVF6UHR.js +380 -0
  6. package/bundles/chunk-7HVF6UHR.js.map +6 -0
  7. package/bundles/chunk-COAETSNP.js +7531 -0
  8. package/bundles/chunk-COAETSNP.js.map +6 -0
  9. package/bundles/chunk-EP5JHXG2.js +448 -0
  10. package/bundles/chunk-EP5JHXG2.js.map +6 -0
  11. package/bundles/chunk-GLCRIILX.js +206 -0
  12. package/bundles/chunk-GLCRIILX.js.map +6 -0
  13. package/bundles/chunk-HDZS2JG2.js +1265 -0
  14. package/bundles/chunk-HDZS2JG2.js.map +6 -0
  15. package/bundles/chunk-IESRH26X.js +5684 -0
  16. package/bundles/chunk-IESRH26X.js.map +6 -0
  17. package/bundles/chunk-JJMLEEKA.js +382 -0
  18. package/bundles/chunk-JJMLEEKA.js.map +6 -0
  19. package/bundles/chunk-MFCLQBFK.js +968 -0
  20. package/bundles/chunk-MFCLQBFK.js.map +6 -0
  21. package/bundles/chunk-QDWL7SZJ.js +29 -0
  22. package/bundles/chunk-QDWL7SZJ.js.map +6 -0
  23. package/bundles/chunk-QL6ZC3U3.js +424 -0
  24. package/bundles/chunk-QL6ZC3U3.js.map +6 -0
  25. package/bundles/chunk-SKBLJA43.js +56 -0
  26. package/bundles/chunk-SKBLJA43.js.map +6 -0
  27. package/bundles/chunk-UIKTHF6Z.js +2177 -0
  28. package/bundles/chunk-UIKTHF6Z.js.map +6 -0
  29. package/bundles/chunk-UMUIU7TE.js +116 -0
  30. package/bundles/chunk-UMUIU7TE.js.map +6 -0
  31. package/bundles/chunk-XA5IZLLC.js +68 -0
  32. package/bundles/chunk-XA5IZLLC.js.map +6 -0
  33. package/bundles/index.js +67 -20229
  34. package/bundles/index.js.map +2 -2
  35. package/bundles/linker/babel/index.js +17 -1980
  36. package/bundles/linker/babel/index.js.map +2 -2
  37. package/bundles/linker/index.js +12 -1833
  38. package/bundles/linker/index.js.map +2 -2
  39. package/bundles/ngcc/index.js +24 -16040
  40. package/bundles/ngcc/index.js.map +2 -2
  41. package/bundles/ngcc/main-ngcc.js +16 -16124
  42. package/bundles/ngcc/main-ngcc.js.map +2 -2
  43. package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js +27 -13782
  44. package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js.map +2 -2
  45. package/bundles/ngcc/src/locking/lock_file_with_child_process/ngcc_lock_unlocker.js +10 -309
  46. package/bundles/ngcc/src/locking/lock_file_with_child_process/ngcc_lock_unlocker.js.map +2 -2
  47. package/bundles/private/bazel.js +4 -81
  48. package/bundles/private/bazel.js.map +2 -2
  49. package/bundles/private/localize.js +27 -870
  50. package/bundles/private/localize.js.map +2 -2
  51. package/bundles/private/migrations.js +13 -2178
  52. package/bundles/private/migrations.js.map +2 -2
  53. package/bundles/private/tooling.js +7 -931
  54. package/bundles/private/tooling.js.map +2 -2
  55. package/bundles/src/bin/ng_xi18n.js +20 -20378
  56. package/bundles/src/bin/ng_xi18n.js.map +2 -2
  57. package/bundles/src/bin/ngc.js +15 -20392
  58. package/bundles/src/bin/ngc.js.map +2 -2
  59. package/bundles_metadata.json +1 -1
  60. package/index.d.ts +0 -1
  61. package/ngcc/src/packages/build_marker.d.ts +1 -1
  62. package/package.json +3 -3
  63. package/src/ngtsc/core/src/host.d.ts +2 -1
  64. package/src/ngtsc/program_driver/src/ts_create_program_driver.d.ts +2 -1
  65. package/src/ngtsc/reflection/src/host.d.ts +1 -1
  66. package/src/ngtsc/util/src/typescript.d.ts +10 -0
  67. package/src/transformers/compiler_host.d.ts +1 -97
  68. package/src/transformers/program.d.ts +0 -19
  69. package/src/transformers/util.d.ts +1 -18
  70. package/src/{diagnostics/typescript_version.d.ts → version_helpers.d.ts} +1 -1
  71. package/src/diagnostics/translate_diagnostics.d.ts +0 -18
  72. package/src/language_services.d.ts +0 -11
  73. package/src/metadata/bundle_index_host.d.ts +0 -16
  74. package/src/metadata/bundler.d.ts +0 -66
  75. package/src/metadata/collector.d.ts +0 -44
  76. package/src/metadata/evaluator.d.ts +0 -58
  77. package/src/metadata/index.d.ts +0 -11
  78. package/src/metadata/index_writer.d.ts +0 -10
  79. package/src/metadata/schema.d.ts +0 -182
  80. package/src/metadata/symbols.d.ts +0 -22
  81. package/src/transformers/inline_resources.d.ts +0 -26
  82. package/src/transformers/lower_expressions.d.ts +0 -30
  83. package/src/transformers/metadata_cache.d.ts +0 -27
  84. package/src/transformers/metadata_reader.d.ts +0 -19
  85. package/src/transformers/node_emitter.d.ts +0 -105
  86. package/src/transformers/node_emitter_transform.d.ts +0 -19
  87. package/src/transformers/r3_metadata_transform.d.ts +0 -16
  88. package/src/transformers/r3_transform.d.ts +0 -16
@@ -0,0 +1,681 @@
1
+
2
+ import {createRequire as __cjsCompatRequire} from 'module';
3
+ const require = __cjsCompatRequire(import.meta.url);
4
+ const __ESM_IMPORT_META_URL__ = import.meta.url;
5
+
6
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/typescript.mjs
7
+ import ts4 from "typescript";
8
+
9
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/host.mjs
10
+ import ts from "typescript";
11
+ var Decorator = {
12
+ nodeForError: (decorator) => {
13
+ if (decorator.node !== null) {
14
+ return decorator.node;
15
+ } else {
16
+ return decorator.synthesizedFor;
17
+ }
18
+ }
19
+ };
20
+ function isDecoratorIdentifier(exp) {
21
+ return ts.isIdentifier(exp) || ts.isPropertyAccessExpression(exp) && ts.isIdentifier(exp.expression) && ts.isIdentifier(exp.name);
22
+ }
23
+ var ClassMemberKind;
24
+ (function(ClassMemberKind2) {
25
+ ClassMemberKind2[ClassMemberKind2["Constructor"] = 0] = "Constructor";
26
+ ClassMemberKind2[ClassMemberKind2["Getter"] = 1] = "Getter";
27
+ ClassMemberKind2[ClassMemberKind2["Setter"] = 2] = "Setter";
28
+ ClassMemberKind2[ClassMemberKind2["Property"] = 3] = "Property";
29
+ ClassMemberKind2[ClassMemberKind2["Method"] = 4] = "Method";
30
+ })(ClassMemberKind || (ClassMemberKind = {}));
31
+ var KnownDeclaration;
32
+ (function(KnownDeclaration2) {
33
+ KnownDeclaration2[KnownDeclaration2["JsGlobalObject"] = 0] = "JsGlobalObject";
34
+ KnownDeclaration2[KnownDeclaration2["TsHelperAssign"] = 1] = "TsHelperAssign";
35
+ KnownDeclaration2[KnownDeclaration2["TsHelperSpread"] = 2] = "TsHelperSpread";
36
+ KnownDeclaration2[KnownDeclaration2["TsHelperSpreadArrays"] = 3] = "TsHelperSpreadArrays";
37
+ KnownDeclaration2[KnownDeclaration2["TsHelperSpreadArray"] = 4] = "TsHelperSpreadArray";
38
+ KnownDeclaration2[KnownDeclaration2["TsHelperRead"] = 5] = "TsHelperRead";
39
+ })(KnownDeclaration || (KnownDeclaration = {}));
40
+ function isConcreteDeclaration(decl) {
41
+ return decl.kind === 0;
42
+ }
43
+
44
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/type_to_value.mjs
45
+ import ts2 from "typescript";
46
+ function typeToValue(typeNode, checker) {
47
+ if (typeNode === null) {
48
+ return missingType();
49
+ }
50
+ if (!ts2.isTypeReferenceNode(typeNode)) {
51
+ return unsupportedType(typeNode);
52
+ }
53
+ const symbols = resolveTypeSymbols(typeNode, checker);
54
+ if (symbols === null) {
55
+ return unknownReference(typeNode);
56
+ }
57
+ const { local, decl } = symbols;
58
+ if (decl.valueDeclaration === void 0 || decl.flags & ts2.SymbolFlags.ConstEnum) {
59
+ let typeOnlyDecl = null;
60
+ if (decl.declarations !== void 0 && decl.declarations.length > 0) {
61
+ typeOnlyDecl = decl.declarations[0];
62
+ }
63
+ return noValueDeclaration(typeNode, typeOnlyDecl);
64
+ }
65
+ const firstDecl = local.declarations && local.declarations[0];
66
+ if (firstDecl !== void 0) {
67
+ if (ts2.isImportClause(firstDecl) && firstDecl.name !== void 0) {
68
+ if (firstDecl.isTypeOnly) {
69
+ return typeOnlyImport(typeNode, firstDecl);
70
+ }
71
+ return {
72
+ kind: 0,
73
+ expression: firstDecl.name,
74
+ defaultImportStatement: firstDecl.parent
75
+ };
76
+ } else if (ts2.isImportSpecifier(firstDecl)) {
77
+ if (firstDecl.isTypeOnly) {
78
+ return typeOnlyImport(typeNode, firstDecl);
79
+ }
80
+ if (firstDecl.parent.parent.isTypeOnly) {
81
+ return typeOnlyImport(typeNode, firstDecl.parent.parent);
82
+ }
83
+ const importedName = (firstDecl.propertyName || firstDecl.name).text;
84
+ const [_localName, ...nestedPath] = symbols.symbolNames;
85
+ const moduleName = extractModuleName(firstDecl.parent.parent.parent);
86
+ return {
87
+ kind: 1,
88
+ valueDeclaration: decl.valueDeclaration,
89
+ moduleName,
90
+ importedName,
91
+ nestedPath
92
+ };
93
+ } else if (ts2.isNamespaceImport(firstDecl)) {
94
+ if (firstDecl.parent.isTypeOnly) {
95
+ return typeOnlyImport(typeNode, firstDecl.parent);
96
+ }
97
+ if (symbols.symbolNames.length === 1) {
98
+ return namespaceImport(typeNode, firstDecl.parent);
99
+ }
100
+ const [_ns, importedName, ...nestedPath] = symbols.symbolNames;
101
+ const moduleName = extractModuleName(firstDecl.parent.parent);
102
+ return {
103
+ kind: 1,
104
+ valueDeclaration: decl.valueDeclaration,
105
+ moduleName,
106
+ importedName,
107
+ nestedPath
108
+ };
109
+ }
110
+ }
111
+ const expression = typeNodeToValueExpr(typeNode);
112
+ if (expression !== null) {
113
+ return {
114
+ kind: 0,
115
+ expression,
116
+ defaultImportStatement: null
117
+ };
118
+ } else {
119
+ return unsupportedType(typeNode);
120
+ }
121
+ }
122
+ function unsupportedType(typeNode) {
123
+ return {
124
+ kind: 2,
125
+ reason: { kind: 5, typeNode }
126
+ };
127
+ }
128
+ function noValueDeclaration(typeNode, decl) {
129
+ return {
130
+ kind: 2,
131
+ reason: { kind: 1, typeNode, decl }
132
+ };
133
+ }
134
+ function typeOnlyImport(typeNode, node) {
135
+ return {
136
+ kind: 2,
137
+ reason: { kind: 2, typeNode, node }
138
+ };
139
+ }
140
+ function unknownReference(typeNode) {
141
+ return {
142
+ kind: 2,
143
+ reason: { kind: 3, typeNode }
144
+ };
145
+ }
146
+ function namespaceImport(typeNode, importClause) {
147
+ return {
148
+ kind: 2,
149
+ reason: { kind: 4, typeNode, importClause }
150
+ };
151
+ }
152
+ function missingType() {
153
+ return {
154
+ kind: 2,
155
+ reason: { kind: 0 }
156
+ };
157
+ }
158
+ function typeNodeToValueExpr(node) {
159
+ if (ts2.isTypeReferenceNode(node)) {
160
+ return entityNameToValue(node.typeName);
161
+ } else {
162
+ return null;
163
+ }
164
+ }
165
+ function resolveTypeSymbols(typeRef, checker) {
166
+ const typeName = typeRef.typeName;
167
+ const typeRefSymbol = checker.getSymbolAtLocation(typeName);
168
+ if (typeRefSymbol === void 0) {
169
+ return null;
170
+ }
171
+ let local = typeRefSymbol;
172
+ let leftMost = typeName;
173
+ const symbolNames = [];
174
+ while (ts2.isQualifiedName(leftMost)) {
175
+ symbolNames.unshift(leftMost.right.text);
176
+ leftMost = leftMost.left;
177
+ }
178
+ symbolNames.unshift(leftMost.text);
179
+ if (leftMost !== typeName) {
180
+ const localTmp = checker.getSymbolAtLocation(leftMost);
181
+ if (localTmp !== void 0) {
182
+ local = localTmp;
183
+ }
184
+ }
185
+ let decl = typeRefSymbol;
186
+ if (typeRefSymbol.flags & ts2.SymbolFlags.Alias) {
187
+ decl = checker.getAliasedSymbol(typeRefSymbol);
188
+ }
189
+ return { local, decl, symbolNames };
190
+ }
191
+ function entityNameToValue(node) {
192
+ if (ts2.isQualifiedName(node)) {
193
+ const left = entityNameToValue(node.left);
194
+ return left !== null ? ts2.createPropertyAccess(left, node.right) : null;
195
+ } else if (ts2.isIdentifier(node)) {
196
+ return ts2.getMutableClone(node);
197
+ } else {
198
+ return null;
199
+ }
200
+ }
201
+ function extractModuleName(node) {
202
+ if (!ts2.isStringLiteral(node.moduleSpecifier)) {
203
+ throw new Error("not a module specifier");
204
+ }
205
+ return node.moduleSpecifier.text;
206
+ }
207
+
208
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/util.mjs
209
+ import ts3 from "typescript";
210
+ function isNamedClassDeclaration(node) {
211
+ return ts3.isClassDeclaration(node) && isIdentifier(node.name);
212
+ }
213
+ function isNamedFunctionDeclaration(node) {
214
+ return ts3.isFunctionDeclaration(node) && isIdentifier(node.name);
215
+ }
216
+ function isNamedVariableDeclaration(node) {
217
+ return ts3.isVariableDeclaration(node) && isIdentifier(node.name);
218
+ }
219
+ function isIdentifier(node) {
220
+ return node !== void 0 && ts3.isIdentifier(node);
221
+ }
222
+
223
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/typescript.mjs
224
+ var TypeScriptReflectionHost = class {
225
+ constructor(checker) {
226
+ this.checker = checker;
227
+ }
228
+ getDecoratorsOfDeclaration(declaration) {
229
+ if (declaration.decorators === void 0 || declaration.decorators.length === 0) {
230
+ return null;
231
+ }
232
+ return declaration.decorators.map((decorator) => this._reflectDecorator(decorator)).filter((dec) => dec !== null);
233
+ }
234
+ getMembersOfClass(clazz) {
235
+ const tsClazz = castDeclarationToClassOrDie(clazz);
236
+ return tsClazz.members.map((member) => this._reflectMember(member)).filter((member) => member !== null);
237
+ }
238
+ getConstructorParameters(clazz) {
239
+ const tsClazz = castDeclarationToClassOrDie(clazz);
240
+ const isDeclaration = tsClazz.getSourceFile().isDeclarationFile;
241
+ const ctor = tsClazz.members.find((member) => ts4.isConstructorDeclaration(member) && (isDeclaration || member.body !== void 0));
242
+ if (ctor === void 0) {
243
+ return null;
244
+ }
245
+ return ctor.parameters.map((node) => {
246
+ const name = parameterName(node.name);
247
+ const decorators = this.getDecoratorsOfDeclaration(node);
248
+ let originalTypeNode = node.type || null;
249
+ let typeNode = originalTypeNode;
250
+ if (typeNode && ts4.isUnionTypeNode(typeNode)) {
251
+ let childTypeNodes = typeNode.types.filter((childTypeNode) => !(ts4.isLiteralTypeNode(childTypeNode) && childTypeNode.literal.kind === ts4.SyntaxKind.NullKeyword));
252
+ if (childTypeNodes.length === 1) {
253
+ typeNode = childTypeNodes[0];
254
+ }
255
+ }
256
+ const typeValueReference = typeToValue(typeNode, this.checker);
257
+ return {
258
+ name,
259
+ nameNode: node.name,
260
+ typeValueReference,
261
+ typeNode: originalTypeNode,
262
+ decorators
263
+ };
264
+ });
265
+ }
266
+ getImportOfIdentifier(id) {
267
+ const directImport = this.getDirectImportOfIdentifier(id);
268
+ if (directImport !== null) {
269
+ return directImport;
270
+ } else if (ts4.isQualifiedName(id.parent) && id.parent.right === id) {
271
+ return this.getImportOfNamespacedIdentifier(id, getQualifiedNameRoot(id.parent));
272
+ } else if (ts4.isPropertyAccessExpression(id.parent) && id.parent.name === id) {
273
+ return this.getImportOfNamespacedIdentifier(id, getFarLeftIdentifier(id.parent));
274
+ } else {
275
+ return null;
276
+ }
277
+ }
278
+ getExportsOfModule(node) {
279
+ if (!ts4.isSourceFile(node)) {
280
+ throw new Error(`getExportsOfModule() called on non-SourceFile in TS code`);
281
+ }
282
+ const symbol = this.checker.getSymbolAtLocation(node);
283
+ if (symbol === void 0) {
284
+ return null;
285
+ }
286
+ const map = new Map();
287
+ this.checker.getExportsOfModule(symbol).forEach((exportSymbol) => {
288
+ const decl = this.getDeclarationOfSymbol(exportSymbol, null);
289
+ if (decl !== null) {
290
+ map.set(exportSymbol.name, decl);
291
+ }
292
+ });
293
+ return map;
294
+ }
295
+ isClass(node) {
296
+ return isNamedClassDeclaration(node);
297
+ }
298
+ hasBaseClass(clazz) {
299
+ return this.getBaseClassExpression(clazz) !== null;
300
+ }
301
+ getBaseClassExpression(clazz) {
302
+ if (!(ts4.isClassDeclaration(clazz) || ts4.isClassExpression(clazz)) || clazz.heritageClauses === void 0) {
303
+ return null;
304
+ }
305
+ const extendsClause = clazz.heritageClauses.find((clause) => clause.token === ts4.SyntaxKind.ExtendsKeyword);
306
+ if (extendsClause === void 0) {
307
+ return null;
308
+ }
309
+ const extendsType = extendsClause.types[0];
310
+ if (extendsType === void 0) {
311
+ return null;
312
+ }
313
+ return extendsType.expression;
314
+ }
315
+ getDeclarationOfIdentifier(id) {
316
+ let symbol = this.checker.getSymbolAtLocation(id);
317
+ if (symbol === void 0) {
318
+ return null;
319
+ }
320
+ return this.getDeclarationOfSymbol(symbol, id);
321
+ }
322
+ getDefinitionOfFunction(node) {
323
+ if (!ts4.isFunctionDeclaration(node) && !ts4.isMethodDeclaration(node) && !ts4.isFunctionExpression(node)) {
324
+ return null;
325
+ }
326
+ return {
327
+ node,
328
+ body: node.body !== void 0 ? Array.from(node.body.statements) : null,
329
+ parameters: node.parameters.map((param) => {
330
+ const name = parameterName(param.name);
331
+ const initializer = param.initializer || null;
332
+ return { name, node: param, initializer };
333
+ })
334
+ };
335
+ }
336
+ getGenericArityOfClass(clazz) {
337
+ if (!ts4.isClassDeclaration(clazz)) {
338
+ return null;
339
+ }
340
+ return clazz.typeParameters !== void 0 ? clazz.typeParameters.length : 0;
341
+ }
342
+ getVariableValue(declaration) {
343
+ return declaration.initializer || null;
344
+ }
345
+ getDtsDeclaration(_) {
346
+ return null;
347
+ }
348
+ getInternalNameOfClass(clazz) {
349
+ return clazz.name;
350
+ }
351
+ getAdjacentNameOfClass(clazz) {
352
+ return clazz.name;
353
+ }
354
+ isStaticallyExported(decl) {
355
+ let topLevel = decl;
356
+ if (ts4.isVariableDeclaration(decl) && ts4.isVariableDeclarationList(decl.parent)) {
357
+ topLevel = decl.parent.parent;
358
+ }
359
+ if (topLevel.modifiers !== void 0 && topLevel.modifiers.some((modifier) => modifier.kind === ts4.SyntaxKind.ExportKeyword)) {
360
+ return true;
361
+ }
362
+ if (topLevel.parent === void 0 || !ts4.isSourceFile(topLevel.parent)) {
363
+ return false;
364
+ }
365
+ const localExports = this.getLocalExportedDeclarationsOfSourceFile(decl.getSourceFile());
366
+ return localExports.has(decl);
367
+ }
368
+ getDirectImportOfIdentifier(id) {
369
+ const symbol = this.checker.getSymbolAtLocation(id);
370
+ if (symbol === void 0 || symbol.declarations === void 0 || symbol.declarations.length !== 1) {
371
+ return null;
372
+ }
373
+ const decl = symbol.declarations[0];
374
+ const importDecl = getContainingImportDeclaration(decl);
375
+ if (importDecl === null) {
376
+ return null;
377
+ }
378
+ if (!ts4.isStringLiteral(importDecl.moduleSpecifier)) {
379
+ return null;
380
+ }
381
+ return { from: importDecl.moduleSpecifier.text, name: getExportedName(decl, id) };
382
+ }
383
+ getImportOfNamespacedIdentifier(id, namespaceIdentifier) {
384
+ if (namespaceIdentifier === null) {
385
+ return null;
386
+ }
387
+ const namespaceSymbol = this.checker.getSymbolAtLocation(namespaceIdentifier);
388
+ if (!namespaceSymbol || namespaceSymbol.declarations === void 0) {
389
+ return null;
390
+ }
391
+ const declaration = namespaceSymbol.declarations.length === 1 ? namespaceSymbol.declarations[0] : null;
392
+ if (!declaration) {
393
+ return null;
394
+ }
395
+ const namespaceDeclaration = ts4.isNamespaceImport(declaration) ? declaration : null;
396
+ if (!namespaceDeclaration) {
397
+ return null;
398
+ }
399
+ const importDeclaration = namespaceDeclaration.parent.parent;
400
+ if (!ts4.isStringLiteral(importDeclaration.moduleSpecifier)) {
401
+ return null;
402
+ }
403
+ return {
404
+ from: importDeclaration.moduleSpecifier.text,
405
+ name: id.text
406
+ };
407
+ }
408
+ getDeclarationOfSymbol(symbol, originalId) {
409
+ let valueDeclaration = void 0;
410
+ if (symbol.valueDeclaration !== void 0) {
411
+ valueDeclaration = symbol.valueDeclaration;
412
+ } else if (symbol.declarations !== void 0 && symbol.declarations.length > 0) {
413
+ valueDeclaration = symbol.declarations[0];
414
+ }
415
+ if (valueDeclaration !== void 0 && ts4.isShorthandPropertyAssignment(valueDeclaration)) {
416
+ const shorthandSymbol = this.checker.getShorthandAssignmentValueSymbol(valueDeclaration);
417
+ if (shorthandSymbol === void 0) {
418
+ return null;
419
+ }
420
+ return this.getDeclarationOfSymbol(shorthandSymbol, originalId);
421
+ } else if (valueDeclaration !== void 0 && ts4.isExportSpecifier(valueDeclaration)) {
422
+ const targetSymbol = this.checker.getExportSpecifierLocalTargetSymbol(valueDeclaration);
423
+ if (targetSymbol === void 0) {
424
+ return null;
425
+ }
426
+ return this.getDeclarationOfSymbol(targetSymbol, originalId);
427
+ }
428
+ const importInfo = originalId && this.getImportOfIdentifier(originalId);
429
+ const viaModule = importInfo !== null && importInfo.from !== null && !importInfo.from.startsWith(".") ? importInfo.from : null;
430
+ while (symbol.flags & ts4.SymbolFlags.Alias) {
431
+ symbol = this.checker.getAliasedSymbol(symbol);
432
+ }
433
+ if (symbol.valueDeclaration !== void 0) {
434
+ return {
435
+ node: symbol.valueDeclaration,
436
+ known: null,
437
+ viaModule,
438
+ identity: null,
439
+ kind: 0
440
+ };
441
+ } else if (symbol.declarations !== void 0 && symbol.declarations.length > 0) {
442
+ return {
443
+ node: symbol.declarations[0],
444
+ known: null,
445
+ viaModule,
446
+ identity: null,
447
+ kind: 0
448
+ };
449
+ } else {
450
+ return null;
451
+ }
452
+ }
453
+ _reflectDecorator(node) {
454
+ let decoratorExpr = node.expression;
455
+ let args = null;
456
+ if (ts4.isCallExpression(decoratorExpr)) {
457
+ args = Array.from(decoratorExpr.arguments);
458
+ decoratorExpr = decoratorExpr.expression;
459
+ }
460
+ if (!isDecoratorIdentifier(decoratorExpr)) {
461
+ return null;
462
+ }
463
+ const decoratorIdentifier = ts4.isIdentifier(decoratorExpr) ? decoratorExpr : decoratorExpr.name;
464
+ const importDecl = this.getImportOfIdentifier(decoratorIdentifier);
465
+ return {
466
+ name: decoratorIdentifier.text,
467
+ identifier: decoratorExpr,
468
+ import: importDecl,
469
+ node,
470
+ args
471
+ };
472
+ }
473
+ _reflectMember(node) {
474
+ let kind = null;
475
+ let value = null;
476
+ let name = null;
477
+ let nameNode = null;
478
+ if (ts4.isPropertyDeclaration(node)) {
479
+ kind = ClassMemberKind.Property;
480
+ value = node.initializer || null;
481
+ } else if (ts4.isGetAccessorDeclaration(node)) {
482
+ kind = ClassMemberKind.Getter;
483
+ } else if (ts4.isSetAccessorDeclaration(node)) {
484
+ kind = ClassMemberKind.Setter;
485
+ } else if (ts4.isMethodDeclaration(node)) {
486
+ kind = ClassMemberKind.Method;
487
+ } else if (ts4.isConstructorDeclaration(node)) {
488
+ kind = ClassMemberKind.Constructor;
489
+ } else {
490
+ return null;
491
+ }
492
+ if (ts4.isConstructorDeclaration(node)) {
493
+ name = "constructor";
494
+ } else if (ts4.isIdentifier(node.name)) {
495
+ name = node.name.text;
496
+ nameNode = node.name;
497
+ } else if (ts4.isStringLiteral(node.name)) {
498
+ name = node.name.text;
499
+ nameNode = node.name;
500
+ } else {
501
+ return null;
502
+ }
503
+ const decorators = this.getDecoratorsOfDeclaration(node);
504
+ const isStatic = node.modifiers !== void 0 && node.modifiers.some((mod) => mod.kind === ts4.SyntaxKind.StaticKeyword);
505
+ return {
506
+ node,
507
+ implementation: node,
508
+ kind,
509
+ type: node.type || null,
510
+ name,
511
+ nameNode,
512
+ decorators,
513
+ value,
514
+ isStatic
515
+ };
516
+ }
517
+ getLocalExportedDeclarationsOfSourceFile(file) {
518
+ const cacheSf = file;
519
+ if (cacheSf[LocalExportedDeclarations] !== void 0) {
520
+ return cacheSf[LocalExportedDeclarations];
521
+ }
522
+ const exportSet = new Set();
523
+ cacheSf[LocalExportedDeclarations] = exportSet;
524
+ const sfSymbol = this.checker.getSymbolAtLocation(cacheSf);
525
+ if (sfSymbol === void 0 || sfSymbol.exports === void 0) {
526
+ return exportSet;
527
+ }
528
+ const iter = sfSymbol.exports.values();
529
+ let item = iter.next();
530
+ while (item.done !== true) {
531
+ let exportedSymbol = item.value;
532
+ if (exportedSymbol.flags & ts4.SymbolFlags.Alias) {
533
+ exportedSymbol = this.checker.getAliasedSymbol(exportedSymbol);
534
+ }
535
+ if (exportedSymbol.valueDeclaration !== void 0 && exportedSymbol.valueDeclaration.getSourceFile() === file) {
536
+ exportSet.add(exportedSymbol.valueDeclaration);
537
+ }
538
+ item = iter.next();
539
+ }
540
+ return exportSet;
541
+ }
542
+ };
543
+ function reflectTypeEntityToDeclaration(type, checker) {
544
+ let realSymbol = checker.getSymbolAtLocation(type);
545
+ if (realSymbol === void 0) {
546
+ throw new Error(`Cannot resolve type entity ${type.getText()} to symbol`);
547
+ }
548
+ while (realSymbol.flags & ts4.SymbolFlags.Alias) {
549
+ realSymbol = checker.getAliasedSymbol(realSymbol);
550
+ }
551
+ let node = null;
552
+ if (realSymbol.valueDeclaration !== void 0) {
553
+ node = realSymbol.valueDeclaration;
554
+ } else if (realSymbol.declarations !== void 0 && realSymbol.declarations.length === 1) {
555
+ node = realSymbol.declarations[0];
556
+ } else {
557
+ throw new Error(`Cannot resolve type entity symbol to declaration`);
558
+ }
559
+ if (ts4.isQualifiedName(type)) {
560
+ if (!ts4.isIdentifier(type.left)) {
561
+ throw new Error(`Cannot handle qualified name with non-identifier lhs`);
562
+ }
563
+ const symbol = checker.getSymbolAtLocation(type.left);
564
+ if (symbol === void 0 || symbol.declarations === void 0 || symbol.declarations.length !== 1) {
565
+ throw new Error(`Cannot resolve qualified type entity lhs to symbol`);
566
+ }
567
+ const decl = symbol.declarations[0];
568
+ if (ts4.isNamespaceImport(decl)) {
569
+ const clause = decl.parent;
570
+ const importDecl = clause.parent;
571
+ if (!ts4.isStringLiteral(importDecl.moduleSpecifier)) {
572
+ throw new Error(`Module specifier is not a string`);
573
+ }
574
+ return { node, from: importDecl.moduleSpecifier.text };
575
+ } else if (ts4.isModuleDeclaration(decl)) {
576
+ return { node, from: null };
577
+ } else {
578
+ throw new Error(`Unknown import type?`);
579
+ }
580
+ } else {
581
+ return { node, from: null };
582
+ }
583
+ }
584
+ function filterToMembersWithDecorator(members, name, module) {
585
+ return members.filter((member) => !member.isStatic).map((member) => {
586
+ if (member.decorators === null) {
587
+ return null;
588
+ }
589
+ const decorators = member.decorators.filter((dec) => {
590
+ if (dec.import !== null) {
591
+ return dec.import.name === name && (module === void 0 || dec.import.from === module);
592
+ } else {
593
+ return dec.name === name && module === void 0;
594
+ }
595
+ });
596
+ if (decorators.length === 0) {
597
+ return null;
598
+ }
599
+ return { member, decorators };
600
+ }).filter((value) => value !== null);
601
+ }
602
+ function reflectObjectLiteral(node) {
603
+ const map = new Map();
604
+ node.properties.forEach((prop) => {
605
+ if (ts4.isPropertyAssignment(prop)) {
606
+ const name = propertyNameToString(prop.name);
607
+ if (name === null) {
608
+ return;
609
+ }
610
+ map.set(name, prop.initializer);
611
+ } else if (ts4.isShorthandPropertyAssignment(prop)) {
612
+ map.set(prop.name.text, prop.name);
613
+ } else {
614
+ return;
615
+ }
616
+ });
617
+ return map;
618
+ }
619
+ function castDeclarationToClassOrDie(declaration) {
620
+ if (!ts4.isClassDeclaration(declaration)) {
621
+ throw new Error(`Reflecting on a ${ts4.SyntaxKind[declaration.kind]} instead of a ClassDeclaration.`);
622
+ }
623
+ return declaration;
624
+ }
625
+ function parameterName(name) {
626
+ if (ts4.isIdentifier(name)) {
627
+ return name.text;
628
+ } else {
629
+ return null;
630
+ }
631
+ }
632
+ function propertyNameToString(node) {
633
+ if (ts4.isIdentifier(node) || ts4.isStringLiteral(node) || ts4.isNumericLiteral(node)) {
634
+ return node.text;
635
+ } else {
636
+ return null;
637
+ }
638
+ }
639
+ function getQualifiedNameRoot(qualifiedName) {
640
+ while (ts4.isQualifiedName(qualifiedName.left)) {
641
+ qualifiedName = qualifiedName.left;
642
+ }
643
+ return ts4.isIdentifier(qualifiedName.left) ? qualifiedName.left : null;
644
+ }
645
+ function getFarLeftIdentifier(propertyAccess) {
646
+ while (ts4.isPropertyAccessExpression(propertyAccess.expression)) {
647
+ propertyAccess = propertyAccess.expression;
648
+ }
649
+ return ts4.isIdentifier(propertyAccess.expression) ? propertyAccess.expression : null;
650
+ }
651
+ function getContainingImportDeclaration(node) {
652
+ return ts4.isImportSpecifier(node) ? node.parent.parent.parent : ts4.isNamespaceImport(node) ? node.parent.parent : null;
653
+ }
654
+ function getExportedName(decl, originalId) {
655
+ return ts4.isImportSpecifier(decl) ? (decl.propertyName !== void 0 ? decl.propertyName : decl.name).text : originalId.text;
656
+ }
657
+ var LocalExportedDeclarations = Symbol("LocalExportedDeclarations");
658
+
659
+ export {
660
+ Decorator,
661
+ isDecoratorIdentifier,
662
+ ClassMemberKind,
663
+ KnownDeclaration,
664
+ isConcreteDeclaration,
665
+ typeNodeToValueExpr,
666
+ isNamedClassDeclaration,
667
+ isNamedFunctionDeclaration,
668
+ isNamedVariableDeclaration,
669
+ TypeScriptReflectionHost,
670
+ reflectTypeEntityToDeclaration,
671
+ filterToMembersWithDecorator,
672
+ reflectObjectLiteral
673
+ };
674
+ /**
675
+ * @license
676
+ * Copyright Google LLC All Rights Reserved.
677
+ *
678
+ * Use of this source code is governed by an MIT-style license that can be
679
+ * found in the LICENSE file at https://angular.io/license
680
+ */
681
+ //# sourceMappingURL=chunk-4EDYFHXN.js.map