@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,1265 @@
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
+ import {
7
+ LogicalProjectPath,
8
+ absoluteFrom,
9
+ absoluteFromSourceFile,
10
+ dirname,
11
+ getFileSystem,
12
+ relative,
13
+ resolve,
14
+ stripExtension,
15
+ toRelativeImport
16
+ } from "./chunk-EP5JHXG2.js";
17
+
18
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/util/src/typescript.mjs
19
+ import ts from "typescript";
20
+ var TS = /\.tsx?$/i;
21
+ var D_TS = /\.d\.ts$/i;
22
+ var PARSED_TS_VERSION = parseFloat(ts.versionMajorMinor);
23
+ function isSymbolWithValueDeclaration(symbol) {
24
+ return symbol != null && symbol.valueDeclaration !== void 0 && symbol.declarations !== void 0;
25
+ }
26
+ function isDtsPath(filePath) {
27
+ return D_TS.test(filePath);
28
+ }
29
+ function isNonDeclarationTsPath(filePath) {
30
+ return TS.test(filePath) && !D_TS.test(filePath);
31
+ }
32
+ function isFromDtsFile(node) {
33
+ let sf = node.getSourceFile();
34
+ if (sf === void 0) {
35
+ sf = ts.getOriginalNode(node).getSourceFile();
36
+ }
37
+ return sf !== void 0 && sf.isDeclarationFile;
38
+ }
39
+ function nodeNameForError(node) {
40
+ if (node.name !== void 0 && ts.isIdentifier(node.name)) {
41
+ return node.name.text;
42
+ } else {
43
+ const kind = ts.SyntaxKind[node.kind];
44
+ const { line, character } = ts.getLineAndCharacterOfPosition(node.getSourceFile(), node.getStart());
45
+ return `${kind}@${line}:${character}`;
46
+ }
47
+ }
48
+ function getSourceFile(node) {
49
+ const directSf = node.getSourceFile();
50
+ return directSf !== void 0 ? directSf : ts.getOriginalNode(node).getSourceFile();
51
+ }
52
+ function getSourceFileOrNull(program, fileName) {
53
+ return program.getSourceFile(fileName) || null;
54
+ }
55
+ function getTokenAtPosition(sf, pos) {
56
+ return ts.getTokenAtPosition(sf, pos);
57
+ }
58
+ function identifierOfNode(decl) {
59
+ if (decl.name !== void 0 && ts.isIdentifier(decl.name)) {
60
+ return decl.name;
61
+ } else {
62
+ return null;
63
+ }
64
+ }
65
+ function isDeclaration(node) {
66
+ return isValueDeclaration(node) || isTypeDeclaration(node);
67
+ }
68
+ function isValueDeclaration(node) {
69
+ return ts.isClassDeclaration(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node);
70
+ }
71
+ function isTypeDeclaration(node) {
72
+ return ts.isEnumDeclaration(node) || ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node);
73
+ }
74
+ function isNamedDeclaration(node) {
75
+ const namedNode = node;
76
+ return namedNode.name !== void 0 && ts.isIdentifier(namedNode.name);
77
+ }
78
+ function getRootDirs(host, options) {
79
+ const rootDirs = [];
80
+ const cwd = host.getCurrentDirectory();
81
+ const fs = getFileSystem();
82
+ if (options.rootDirs !== void 0) {
83
+ rootDirs.push(...options.rootDirs);
84
+ } else if (options.rootDir !== void 0) {
85
+ rootDirs.push(options.rootDir);
86
+ } else {
87
+ rootDirs.push(cwd);
88
+ }
89
+ return rootDirs.map((rootDir) => fs.resolve(cwd, host.getCanonicalFileName(rootDir)));
90
+ }
91
+ function nodeDebugInfo(node) {
92
+ const sf = getSourceFile(node);
93
+ const { line, character } = ts.getLineAndCharacterOfPosition(sf, node.pos);
94
+ return `[${sf.fileName}: ${ts.SyntaxKind[node.kind]} @ ${line}:${character}]`;
95
+ }
96
+ function resolveModuleName(moduleName, containingFile, compilerOptions, compilerHost, moduleResolutionCache) {
97
+ if (compilerHost.resolveModuleNames) {
98
+ return compilerHost.resolveModuleNames([moduleName], containingFile, void 0, void 0, compilerOptions)[0];
99
+ } else {
100
+ return ts.resolveModuleName(moduleName, containingFile, compilerOptions, compilerHost, moduleResolutionCache !== null ? moduleResolutionCache : void 0).resolvedModule;
101
+ }
102
+ }
103
+ function isAssignment(node) {
104
+ return ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken;
105
+ }
106
+ function toUnredirectedSourceFile(sf) {
107
+ const redirectInfo = sf.redirectInfo;
108
+ if (redirectInfo === void 0) {
109
+ return sf;
110
+ }
111
+ return redirectInfo.unredirected;
112
+ }
113
+ function createExportSpecifier(propertyName, name, isTypeOnly = false) {
114
+ return PARSED_TS_VERSION > 4.4 ? ts.createExportSpecifier(isTypeOnly, propertyName, name) : ts.createExportSpecifier(propertyName, name);
115
+ }
116
+
117
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/references.mjs
118
+ var Reference = class {
119
+ constructor(node, bestGuessOwningModule = null) {
120
+ this.node = node;
121
+ this.identifiers = [];
122
+ this.synthetic = false;
123
+ this._alias = null;
124
+ this.bestGuessOwningModule = bestGuessOwningModule;
125
+ const id = identifierOfNode(node);
126
+ if (id !== null) {
127
+ this.identifiers.push(id);
128
+ }
129
+ }
130
+ get ownedByModuleGuess() {
131
+ if (this.bestGuessOwningModule !== null) {
132
+ return this.bestGuessOwningModule.specifier;
133
+ } else {
134
+ return null;
135
+ }
136
+ }
137
+ get hasOwningModuleGuess() {
138
+ return this.bestGuessOwningModule !== null;
139
+ }
140
+ get debugName() {
141
+ const id = identifierOfNode(this.node);
142
+ return id !== null ? id.text : null;
143
+ }
144
+ get alias() {
145
+ return this._alias;
146
+ }
147
+ addIdentifier(identifier) {
148
+ this.identifiers.push(identifier);
149
+ }
150
+ getIdentityIn(context) {
151
+ return this.identifiers.find((id) => id.getSourceFile() === context) || null;
152
+ }
153
+ getIdentityInExpression(expr) {
154
+ const sf = expr.getSourceFile();
155
+ return this.identifiers.find((id) => {
156
+ if (id.getSourceFile() !== sf) {
157
+ return false;
158
+ }
159
+ return id.pos >= expr.pos && id.end <= expr.end;
160
+ }) || null;
161
+ }
162
+ getOriginForDiagnostics(container, fallback = container) {
163
+ const id = this.getIdentityInExpression(container);
164
+ return id !== null ? id : fallback;
165
+ }
166
+ cloneWithAlias(alias) {
167
+ const ref = new Reference(this.node, this.bestGuessOwningModule);
168
+ ref.identifiers = [...this.identifiers];
169
+ ref._alias = alias;
170
+ return ref;
171
+ }
172
+ cloneWithNoIdentifiers() {
173
+ const ref = new Reference(this.node, this.bestGuessOwningModule);
174
+ ref._alias = this._alias;
175
+ ref.identifiers = [];
176
+ return ref;
177
+ }
178
+ };
179
+
180
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/alias.mjs
181
+ import { ExternalExpr as ExternalExpr2 } from "@angular/compiler";
182
+
183
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/emitter.mjs
184
+ import { ExternalExpr, ExternalReference, WrappedNodeExpr } from "@angular/compiler";
185
+ import ts3 from "typescript";
186
+
187
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/find_export.mjs
188
+ import ts2 from "typescript";
189
+ function findExportedNameOfNode(target, file, reflector) {
190
+ const exports = reflector.getExportsOfModule(file);
191
+ if (exports === null) {
192
+ return null;
193
+ }
194
+ const declaredName = isNamedDeclaration(target) ? target.name.text : null;
195
+ let foundExportName = null;
196
+ for (const [exportName, declaration] of exports) {
197
+ if (declaration.node !== target) {
198
+ continue;
199
+ }
200
+ if (exportName === declaredName) {
201
+ return exportName;
202
+ }
203
+ foundExportName = exportName;
204
+ }
205
+ if (foundExportName === null) {
206
+ throw new Error(`Failed to find exported name of node (${target.getText()}) in '${file.fileName}'.`);
207
+ }
208
+ return foundExportName;
209
+ }
210
+
211
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/emitter.mjs
212
+ var ImportFlags;
213
+ (function(ImportFlags2) {
214
+ ImportFlags2[ImportFlags2["None"] = 0] = "None";
215
+ ImportFlags2[ImportFlags2["ForceNewImport"] = 1] = "ForceNewImport";
216
+ ImportFlags2[ImportFlags2["NoAliasing"] = 2] = "NoAliasing";
217
+ ImportFlags2[ImportFlags2["AllowTypeImports"] = 4] = "AllowTypeImports";
218
+ })(ImportFlags || (ImportFlags = {}));
219
+ var ReferenceEmitter = class {
220
+ constructor(strategies) {
221
+ this.strategies = strategies;
222
+ }
223
+ emit(ref, context, importFlags = ImportFlags.None) {
224
+ for (const strategy of this.strategies) {
225
+ const emitted = strategy.emit(ref, context, importFlags);
226
+ if (emitted !== null) {
227
+ return emitted;
228
+ }
229
+ }
230
+ throw new Error(`Unable to write a reference to ${nodeNameForError(ref.node)} in ${ref.node.getSourceFile().fileName} from ${context.fileName}`);
231
+ }
232
+ };
233
+ var LocalIdentifierStrategy = class {
234
+ emit(ref, context, importFlags) {
235
+ const refSf = getSourceFile(ref.node);
236
+ if (importFlags & ImportFlags.ForceNewImport && refSf !== context) {
237
+ return null;
238
+ }
239
+ if (!isDeclaration(ref.node) && refSf === context) {
240
+ return {
241
+ expression: new WrappedNodeExpr(ref.node),
242
+ importedFile: null
243
+ };
244
+ }
245
+ const identifier = ref.getIdentityIn(context);
246
+ if (identifier !== null) {
247
+ return {
248
+ expression: new WrappedNodeExpr(identifier),
249
+ importedFile: null
250
+ };
251
+ } else {
252
+ return null;
253
+ }
254
+ }
255
+ };
256
+ var AbsoluteModuleStrategy = class {
257
+ constructor(program, checker, moduleResolver, reflectionHost) {
258
+ this.program = program;
259
+ this.checker = checker;
260
+ this.moduleResolver = moduleResolver;
261
+ this.reflectionHost = reflectionHost;
262
+ this.moduleExportsCache = new Map();
263
+ }
264
+ emit(ref, context, importFlags) {
265
+ if (ref.bestGuessOwningModule === null) {
266
+ return null;
267
+ } else if (!isDeclaration(ref.node)) {
268
+ throw new Error(`Debug assert: unable to import a Reference to non-declaration of type ${ts3.SyntaxKind[ref.node.kind]}.`);
269
+ } else if ((importFlags & ImportFlags.AllowTypeImports) === 0 && isTypeDeclaration(ref.node)) {
270
+ throw new Error(`Importing a type-only declaration of type ${ts3.SyntaxKind[ref.node.kind]} in a value position is not allowed.`);
271
+ }
272
+ const { specifier, resolutionContext } = ref.bestGuessOwningModule;
273
+ const exports = this.getExportsOfModule(specifier, resolutionContext);
274
+ if (exports === null || !exports.exportMap.has(ref.node)) {
275
+ throw new Error(`Symbol ${ref.debugName} declared in ${getSourceFile(ref.node).fileName} is not exported from ${specifier} (import into ${context.fileName})`);
276
+ }
277
+ const symbolName = exports.exportMap.get(ref.node);
278
+ return {
279
+ expression: new ExternalExpr(new ExternalReference(specifier, symbolName)),
280
+ importedFile: exports.module
281
+ };
282
+ }
283
+ getExportsOfModule(moduleName, fromFile) {
284
+ if (!this.moduleExportsCache.has(moduleName)) {
285
+ this.moduleExportsCache.set(moduleName, this.enumerateExportsOfModule(moduleName, fromFile));
286
+ }
287
+ return this.moduleExportsCache.get(moduleName);
288
+ }
289
+ enumerateExportsOfModule(specifier, fromFile) {
290
+ const entryPointFile = this.moduleResolver.resolveModule(specifier, fromFile);
291
+ if (entryPointFile === null) {
292
+ return null;
293
+ }
294
+ const exports = this.reflectionHost.getExportsOfModule(entryPointFile);
295
+ if (exports === null) {
296
+ return null;
297
+ }
298
+ const exportMap = new Map();
299
+ for (const [name, declaration] of exports) {
300
+ if (exportMap.has(declaration.node)) {
301
+ const existingExport = exportMap.get(declaration.node);
302
+ if (isNamedDeclaration(declaration.node) && declaration.node.name.text === existingExport) {
303
+ continue;
304
+ }
305
+ }
306
+ exportMap.set(declaration.node, name);
307
+ }
308
+ return { module: entryPointFile, exportMap };
309
+ }
310
+ };
311
+ var LogicalProjectStrategy = class {
312
+ constructor(reflector, logicalFs) {
313
+ this.reflector = reflector;
314
+ this.logicalFs = logicalFs;
315
+ }
316
+ emit(ref, context) {
317
+ const destSf = getSourceFile(ref.node);
318
+ const destPath = this.logicalFs.logicalPathOfSf(destSf);
319
+ if (destPath === null) {
320
+ return null;
321
+ }
322
+ const originPath = this.logicalFs.logicalPathOfSf(context);
323
+ if (originPath === null) {
324
+ throw new Error(`Debug assert: attempt to import from ${context.fileName} but it's outside the program?`);
325
+ }
326
+ if (destPath === originPath) {
327
+ return null;
328
+ }
329
+ const name = findExportedNameOfNode(ref.node, destSf, this.reflector);
330
+ if (name === null) {
331
+ return null;
332
+ }
333
+ const moduleName = LogicalProjectPath.relativePathBetween(originPath, destPath);
334
+ return {
335
+ expression: new ExternalExpr({ moduleName, name }),
336
+ importedFile: destSf
337
+ };
338
+ }
339
+ };
340
+ var RelativePathStrategy = class {
341
+ constructor(reflector) {
342
+ this.reflector = reflector;
343
+ }
344
+ emit(ref, context) {
345
+ const destSf = getSourceFile(ref.node);
346
+ const relativePath = relative(dirname(absoluteFromSourceFile(context)), absoluteFromSourceFile(destSf));
347
+ const moduleName = toRelativeImport(stripExtension(relativePath));
348
+ const name = findExportedNameOfNode(ref.node, destSf, this.reflector);
349
+ return { expression: new ExternalExpr({ moduleName, name }), importedFile: destSf };
350
+ }
351
+ };
352
+ var UnifiedModulesStrategy = class {
353
+ constructor(reflector, unifiedModulesHost) {
354
+ this.reflector = reflector;
355
+ this.unifiedModulesHost = unifiedModulesHost;
356
+ }
357
+ emit(ref, context) {
358
+ const destSf = getSourceFile(ref.node);
359
+ const name = findExportedNameOfNode(ref.node, destSf, this.reflector);
360
+ if (name === null) {
361
+ return null;
362
+ }
363
+ const moduleName = this.unifiedModulesHost.fileNameToModuleName(destSf.fileName, context.fileName);
364
+ return {
365
+ expression: new ExternalExpr({ moduleName, name }),
366
+ importedFile: destSf
367
+ };
368
+ }
369
+ };
370
+
371
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/alias.mjs
372
+ var CHARS_TO_ESCAPE = /[^a-zA-Z0-9/_]/g;
373
+ var UnifiedModulesAliasingHost = class {
374
+ constructor(unifiedModulesHost) {
375
+ this.unifiedModulesHost = unifiedModulesHost;
376
+ this.aliasExportsInDts = false;
377
+ }
378
+ maybeAliasSymbolAs(ref, context, ngModuleName, isReExport) {
379
+ if (!isReExport) {
380
+ return null;
381
+ }
382
+ return this.aliasName(ref.node, context);
383
+ }
384
+ getAliasIn(decl, via, isReExport) {
385
+ if (!isReExport) {
386
+ return null;
387
+ }
388
+ const moduleName = this.unifiedModulesHost.fileNameToModuleName(via.fileName, via.fileName);
389
+ return new ExternalExpr2({ moduleName, name: this.aliasName(decl, via) });
390
+ }
391
+ aliasName(decl, context) {
392
+ const declModule = this.unifiedModulesHost.fileNameToModuleName(decl.getSourceFile().fileName, context.fileName);
393
+ const replaced = declModule.replace(CHARS_TO_ESCAPE, "_").replace(/\//g, "$");
394
+ return "\u0275ng$" + replaced + "$$" + decl.name.text;
395
+ }
396
+ };
397
+ var PrivateExportAliasingHost = class {
398
+ constructor(host) {
399
+ this.host = host;
400
+ this.aliasExportsInDts = true;
401
+ }
402
+ maybeAliasSymbolAs(ref, context, ngModuleName) {
403
+ if (ref.hasOwningModuleGuess) {
404
+ return null;
405
+ }
406
+ const exports = this.host.getExportsOfModule(context);
407
+ if (exports === null) {
408
+ throw new Error(`Could not determine the exports of: ${context.fileName}`);
409
+ }
410
+ let found = false;
411
+ exports.forEach((value) => {
412
+ if (value.node === ref.node) {
413
+ found = true;
414
+ }
415
+ });
416
+ if (found) {
417
+ return null;
418
+ }
419
+ return `\u0275ngExport\u0275${ngModuleName}\u0275${ref.node.name.text}`;
420
+ }
421
+ getAliasIn() {
422
+ return null;
423
+ }
424
+ };
425
+ var AliasStrategy = class {
426
+ emit(ref, context, importMode) {
427
+ if (importMode & ImportFlags.NoAliasing || ref.alias === null) {
428
+ return null;
429
+ }
430
+ return { expression: ref.alias, importedFile: "unknown" };
431
+ }
432
+ };
433
+
434
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/util/src/path.mjs
435
+ function relativePathBetween(from, to) {
436
+ const relativePath = stripExtension(relative(dirname(resolve(from)), resolve(to)));
437
+ return relativePath !== "" ? toRelativeImport(relativePath) : null;
438
+ }
439
+ function normalizeSeparators(path) {
440
+ return path.replace(/\\/g, "/");
441
+ }
442
+
443
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/core.mjs
444
+ var NoopImportRewriter = class {
445
+ shouldImportSymbol(symbol, specifier) {
446
+ return true;
447
+ }
448
+ rewriteSymbol(symbol, specifier) {
449
+ return symbol;
450
+ }
451
+ rewriteSpecifier(specifier, inContextOfFile) {
452
+ return specifier;
453
+ }
454
+ };
455
+ var CORE_SUPPORTED_SYMBOLS = new Map([
456
+ ["\u0275\u0275defineInjectable", "\u0275\u0275defineInjectable"],
457
+ ["\u0275\u0275defineInjector", "\u0275\u0275defineInjector"],
458
+ ["\u0275\u0275defineNgModule", "\u0275\u0275defineNgModule"],
459
+ ["\u0275\u0275setNgModuleScope", "\u0275\u0275setNgModuleScope"],
460
+ ["\u0275\u0275inject", "\u0275\u0275inject"],
461
+ ["\u0275\u0275FactoryDeclaration", "\u0275\u0275FactoryDeclaration"],
462
+ ["\u0275setClassMetadata", "setClassMetadata"],
463
+ ["\u0275\u0275InjectableDeclaration", "\u0275\u0275InjectableDeclaration"],
464
+ ["\u0275\u0275InjectorDeclaration", "\u0275\u0275InjectorDeclaration"],
465
+ ["\u0275\u0275NgModuleDeclaration", "\u0275\u0275NgModuleDeclaration"],
466
+ ["\u0275NgModuleFactory", "NgModuleFactory"],
467
+ ["\u0275noSideEffects", "\u0275noSideEffects"]
468
+ ]);
469
+ var CORE_MODULE = "@angular/core";
470
+ var R3SymbolsImportRewriter = class {
471
+ constructor(r3SymbolsPath) {
472
+ this.r3SymbolsPath = r3SymbolsPath;
473
+ }
474
+ shouldImportSymbol(symbol, specifier) {
475
+ return true;
476
+ }
477
+ rewriteSymbol(symbol, specifier) {
478
+ if (specifier !== CORE_MODULE) {
479
+ return symbol;
480
+ }
481
+ return validateAndRewriteCoreSymbol(symbol);
482
+ }
483
+ rewriteSpecifier(specifier, inContextOfFile) {
484
+ if (specifier !== CORE_MODULE) {
485
+ return specifier;
486
+ }
487
+ const relativePathToR3Symbols = relativePathBetween(inContextOfFile, this.r3SymbolsPath);
488
+ if (relativePathToR3Symbols === null) {
489
+ throw new Error(`Failed to rewrite import inside ${CORE_MODULE}: ${inContextOfFile} -> ${this.r3SymbolsPath}`);
490
+ }
491
+ return relativePathToR3Symbols;
492
+ }
493
+ };
494
+ function validateAndRewriteCoreSymbol(name) {
495
+ if (!CORE_SUPPORTED_SYMBOLS.has(name)) {
496
+ throw new Error(`Importing unexpected symbol ${name} while compiling ${CORE_MODULE}`);
497
+ }
498
+ return CORE_SUPPORTED_SYMBOLS.get(name);
499
+ }
500
+
501
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/default.mjs
502
+ import ts4 from "typescript";
503
+ var DefaultImportDeclaration = Symbol("DefaultImportDeclaration");
504
+ function attachDefaultImportDeclaration(expr, importDecl) {
505
+ expr[DefaultImportDeclaration] = importDecl;
506
+ }
507
+ function getDefaultImportDeclaration(expr) {
508
+ var _a;
509
+ return (_a = expr[DefaultImportDeclaration]) != null ? _a : null;
510
+ }
511
+ var DefaultImportTracker = class {
512
+ constructor() {
513
+ this.sourceFileToUsedImports = new Map();
514
+ }
515
+ recordUsedImport(importDecl) {
516
+ const sf = getSourceFile(importDecl);
517
+ if (!this.sourceFileToUsedImports.has(sf)) {
518
+ this.sourceFileToUsedImports.set(sf, new Set());
519
+ }
520
+ this.sourceFileToUsedImports.get(sf).add(importDecl);
521
+ }
522
+ importPreservingTransformer() {
523
+ return (context) => {
524
+ return (sf) => {
525
+ return this.transformSourceFile(sf);
526
+ };
527
+ };
528
+ }
529
+ transformSourceFile(sf) {
530
+ const originalSf = ts4.getOriginalNode(sf);
531
+ if (!this.sourceFileToUsedImports.has(originalSf)) {
532
+ return sf;
533
+ }
534
+ const importsToPreserve = this.sourceFileToUsedImports.get(originalSf);
535
+ const statements = sf.statements.map((stmt) => {
536
+ if (ts4.isImportDeclaration(stmt) && importsToPreserve.has(stmt)) {
537
+ stmt = ts4.getMutableClone(stmt);
538
+ }
539
+ return stmt;
540
+ });
541
+ this.sourceFileToUsedImports.delete(originalSf);
542
+ return ts4.updateSourceFileNode(sf, statements);
543
+ }
544
+ };
545
+
546
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/resolver.mjs
547
+ var ModuleResolver = class {
548
+ constructor(program, compilerOptions, host, moduleResolutionCache) {
549
+ this.program = program;
550
+ this.compilerOptions = compilerOptions;
551
+ this.host = host;
552
+ this.moduleResolutionCache = moduleResolutionCache;
553
+ }
554
+ resolveModule(moduleName, containingFile) {
555
+ const resolved = resolveModuleName(moduleName, containingFile, this.compilerOptions, this.host, this.moduleResolutionCache);
556
+ if (resolved === void 0) {
557
+ return null;
558
+ }
559
+ return getSourceFileOrNull(this.program, absoluteFrom(resolved.resolvedFileName));
560
+ }
561
+ };
562
+
563
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/context.mjs
564
+ var Context = class {
565
+ constructor(isStatement) {
566
+ this.isStatement = isStatement;
567
+ }
568
+ get withExpressionMode() {
569
+ return this.isStatement ? new Context(false) : this;
570
+ }
571
+ get withStatementMode() {
572
+ return !this.isStatement ? new Context(true) : this;
573
+ }
574
+ };
575
+
576
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/translator.mjs
577
+ import {
578
+ BinaryOperator,
579
+ ConditionalExpr,
580
+ StmtModifier,
581
+ UnaryOperator
582
+ } from "@angular/compiler";
583
+ var UNARY_OPERATORS = new Map([
584
+ [UnaryOperator.Minus, "-"],
585
+ [UnaryOperator.Plus, "+"]
586
+ ]);
587
+ var BINARY_OPERATORS = new Map([
588
+ [BinaryOperator.And, "&&"],
589
+ [BinaryOperator.Bigger, ">"],
590
+ [BinaryOperator.BiggerEquals, ">="],
591
+ [BinaryOperator.BitwiseAnd, "&"],
592
+ [BinaryOperator.Divide, "/"],
593
+ [BinaryOperator.Equals, "=="],
594
+ [BinaryOperator.Identical, "==="],
595
+ [BinaryOperator.Lower, "<"],
596
+ [BinaryOperator.LowerEquals, "<="],
597
+ [BinaryOperator.Minus, "-"],
598
+ [BinaryOperator.Modulo, "%"],
599
+ [BinaryOperator.Multiply, "*"],
600
+ [BinaryOperator.NotEquals, "!="],
601
+ [BinaryOperator.NotIdentical, "!=="],
602
+ [BinaryOperator.Or, "||"],
603
+ [BinaryOperator.Plus, "+"],
604
+ [BinaryOperator.NullishCoalesce, "??"]
605
+ ]);
606
+ var ExpressionTranslatorVisitor = class {
607
+ constructor(factory, imports, options) {
608
+ this.factory = factory;
609
+ this.imports = imports;
610
+ this.downlevelTaggedTemplates = options.downlevelTaggedTemplates === true;
611
+ this.downlevelVariableDeclarations = options.downlevelVariableDeclarations === true;
612
+ this.recordWrappedNode = options.recordWrappedNode || (() => {
613
+ });
614
+ }
615
+ visitDeclareVarStmt(stmt, context) {
616
+ var _a;
617
+ const varType = this.downlevelVariableDeclarations ? "var" : stmt.hasModifier(StmtModifier.Final) ? "const" : "let";
618
+ return this.attachComments(this.factory.createVariableDeclaration(stmt.name, (_a = stmt.value) == null ? void 0 : _a.visitExpression(this, context.withExpressionMode), varType), stmt.leadingComments);
619
+ }
620
+ visitDeclareFunctionStmt(stmt, context) {
621
+ return this.attachComments(this.factory.createFunctionDeclaration(stmt.name, stmt.params.map((param) => param.name), this.factory.createBlock(this.visitStatements(stmt.statements, context.withStatementMode))), stmt.leadingComments);
622
+ }
623
+ visitExpressionStmt(stmt, context) {
624
+ return this.attachComments(this.factory.createExpressionStatement(stmt.expr.visitExpression(this, context.withStatementMode)), stmt.leadingComments);
625
+ }
626
+ visitReturnStmt(stmt, context) {
627
+ return this.attachComments(this.factory.createReturnStatement(stmt.value.visitExpression(this, context.withExpressionMode)), stmt.leadingComments);
628
+ }
629
+ visitDeclareClassStmt(_stmt, _context) {
630
+ throw new Error("Method not implemented.");
631
+ }
632
+ visitIfStmt(stmt, context) {
633
+ return this.attachComments(this.factory.createIfStatement(stmt.condition.visitExpression(this, context), this.factory.createBlock(this.visitStatements(stmt.trueCase, context.withStatementMode)), stmt.falseCase.length > 0 ? this.factory.createBlock(this.visitStatements(stmt.falseCase, context.withStatementMode)) : null), stmt.leadingComments);
634
+ }
635
+ visitTryCatchStmt(_stmt, _context) {
636
+ throw new Error("Method not implemented.");
637
+ }
638
+ visitThrowStmt(stmt, context) {
639
+ return this.attachComments(this.factory.createThrowStatement(stmt.error.visitExpression(this, context.withExpressionMode)), stmt.leadingComments);
640
+ }
641
+ visitReadVarExpr(ast, _context) {
642
+ const identifier = this.factory.createIdentifier(ast.name);
643
+ this.setSourceMapRange(identifier, ast.sourceSpan);
644
+ return identifier;
645
+ }
646
+ visitWriteVarExpr(expr, context) {
647
+ const assignment = this.factory.createAssignment(this.setSourceMapRange(this.factory.createIdentifier(expr.name), expr.sourceSpan), expr.value.visitExpression(this, context));
648
+ return context.isStatement ? assignment : this.factory.createParenthesizedExpression(assignment);
649
+ }
650
+ visitWriteKeyExpr(expr, context) {
651
+ const exprContext = context.withExpressionMode;
652
+ const target = this.factory.createElementAccess(expr.receiver.visitExpression(this, exprContext), expr.index.visitExpression(this, exprContext));
653
+ const assignment = this.factory.createAssignment(target, expr.value.visitExpression(this, exprContext));
654
+ return context.isStatement ? assignment : this.factory.createParenthesizedExpression(assignment);
655
+ }
656
+ visitWritePropExpr(expr, context) {
657
+ const target = this.factory.createPropertyAccess(expr.receiver.visitExpression(this, context), expr.name);
658
+ return this.factory.createAssignment(target, expr.value.visitExpression(this, context));
659
+ }
660
+ visitInvokeFunctionExpr(ast, context) {
661
+ return this.setSourceMapRange(this.factory.createCallExpression(ast.fn.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)), ast.pure), ast.sourceSpan);
662
+ }
663
+ visitTaggedTemplateExpr(ast, context) {
664
+ return this.setSourceMapRange(this.createTaggedTemplateExpression(ast.tag.visitExpression(this, context), {
665
+ elements: ast.template.elements.map((e) => {
666
+ var _a;
667
+ return createTemplateElement({
668
+ cooked: e.text,
669
+ raw: e.rawText,
670
+ range: (_a = e.sourceSpan) != null ? _a : ast.sourceSpan
671
+ });
672
+ }),
673
+ expressions: ast.template.expressions.map((e) => e.visitExpression(this, context))
674
+ }), ast.sourceSpan);
675
+ }
676
+ visitInstantiateExpr(ast, context) {
677
+ return this.factory.createNewExpression(ast.classExpr.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)));
678
+ }
679
+ visitLiteralExpr(ast, _context) {
680
+ return this.setSourceMapRange(this.factory.createLiteral(ast.value), ast.sourceSpan);
681
+ }
682
+ visitLocalizedString(ast, context) {
683
+ const elements = [createTemplateElement(ast.serializeI18nHead())];
684
+ const expressions = [];
685
+ for (let i = 0; i < ast.expressions.length; i++) {
686
+ const placeholder = this.setSourceMapRange(ast.expressions[i].visitExpression(this, context), ast.getPlaceholderSourceSpan(i));
687
+ expressions.push(placeholder);
688
+ elements.push(createTemplateElement(ast.serializeI18nTemplatePart(i + 1)));
689
+ }
690
+ const localizeTag = this.factory.createIdentifier("$localize");
691
+ return this.setSourceMapRange(this.createTaggedTemplateExpression(localizeTag, { elements, expressions }), ast.sourceSpan);
692
+ }
693
+ createTaggedTemplateExpression(tag, template) {
694
+ return this.downlevelTaggedTemplates ? this.createES5TaggedTemplateFunctionCall(tag, template) : this.factory.createTaggedTemplate(tag, template);
695
+ }
696
+ createES5TaggedTemplateFunctionCall(tagHandler, { elements, expressions }) {
697
+ const { moduleImport, symbol } = this.imports.generateNamedImport("tslib", "__makeTemplateObject");
698
+ const __makeTemplateObjectHelper = moduleImport === null ? this.factory.createIdentifier(symbol) : this.factory.createPropertyAccess(moduleImport, symbol);
699
+ const cooked = [];
700
+ const raw = [];
701
+ for (const element of elements) {
702
+ cooked.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.cooked), element.range));
703
+ raw.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.raw), element.range));
704
+ }
705
+ const templateHelperCall = this.factory.createCallExpression(__makeTemplateObjectHelper, [this.factory.createArrayLiteral(cooked), this.factory.createArrayLiteral(raw)], false);
706
+ return this.factory.createCallExpression(tagHandler, [templateHelperCall, ...expressions], false);
707
+ }
708
+ visitExternalExpr(ast, _context) {
709
+ if (ast.value.name === null) {
710
+ if (ast.value.moduleName === null) {
711
+ throw new Error("Invalid import without name nor moduleName");
712
+ }
713
+ return this.imports.generateNamespaceImport(ast.value.moduleName);
714
+ }
715
+ if (ast.value.moduleName !== null) {
716
+ const { moduleImport, symbol } = this.imports.generateNamedImport(ast.value.moduleName, ast.value.name);
717
+ if (moduleImport === null) {
718
+ return this.factory.createIdentifier(symbol);
719
+ } else {
720
+ return this.factory.createPropertyAccess(moduleImport, symbol);
721
+ }
722
+ } else {
723
+ return this.factory.createIdentifier(ast.value.name);
724
+ }
725
+ }
726
+ visitConditionalExpr(ast, context) {
727
+ let cond = ast.condition.visitExpression(this, context);
728
+ if (ast.condition instanceof ConditionalExpr) {
729
+ cond = this.factory.createParenthesizedExpression(cond);
730
+ }
731
+ return this.factory.createConditional(cond, ast.trueCase.visitExpression(this, context), ast.falseCase.visitExpression(this, context));
732
+ }
733
+ visitNotExpr(ast, context) {
734
+ return this.factory.createUnaryExpression("!", ast.condition.visitExpression(this, context));
735
+ }
736
+ visitAssertNotNullExpr(ast, context) {
737
+ return ast.condition.visitExpression(this, context);
738
+ }
739
+ visitCastExpr(ast, context) {
740
+ return ast.value.visitExpression(this, context);
741
+ }
742
+ visitFunctionExpr(ast, context) {
743
+ var _a;
744
+ return this.factory.createFunctionExpression((_a = ast.name) != null ? _a : null, ast.params.map((param) => param.name), this.factory.createBlock(this.visitStatements(ast.statements, context)));
745
+ }
746
+ visitBinaryOperatorExpr(ast, context) {
747
+ if (!BINARY_OPERATORS.has(ast.operator)) {
748
+ throw new Error(`Unknown binary operator: ${BinaryOperator[ast.operator]}`);
749
+ }
750
+ return this.factory.createBinaryExpression(ast.lhs.visitExpression(this, context), BINARY_OPERATORS.get(ast.operator), ast.rhs.visitExpression(this, context));
751
+ }
752
+ visitReadPropExpr(ast, context) {
753
+ return this.factory.createPropertyAccess(ast.receiver.visitExpression(this, context), ast.name);
754
+ }
755
+ visitReadKeyExpr(ast, context) {
756
+ return this.factory.createElementAccess(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context));
757
+ }
758
+ visitLiteralArrayExpr(ast, context) {
759
+ return this.factory.createArrayLiteral(ast.entries.map((expr) => this.setSourceMapRange(expr.visitExpression(this, context), ast.sourceSpan)));
760
+ }
761
+ visitLiteralMapExpr(ast, context) {
762
+ const properties = ast.entries.map((entry) => {
763
+ return {
764
+ propertyName: entry.key,
765
+ quoted: entry.quoted,
766
+ value: entry.value.visitExpression(this, context)
767
+ };
768
+ });
769
+ return this.setSourceMapRange(this.factory.createObjectLiteral(properties), ast.sourceSpan);
770
+ }
771
+ visitCommaExpr(ast, context) {
772
+ throw new Error("Method not implemented.");
773
+ }
774
+ visitWrappedNodeExpr(ast, _context) {
775
+ this.recordWrappedNode(ast);
776
+ return ast.node;
777
+ }
778
+ visitTypeofExpr(ast, context) {
779
+ return this.factory.createTypeOfExpression(ast.expr.visitExpression(this, context));
780
+ }
781
+ visitUnaryOperatorExpr(ast, context) {
782
+ if (!UNARY_OPERATORS.has(ast.operator)) {
783
+ throw new Error(`Unknown unary operator: ${UnaryOperator[ast.operator]}`);
784
+ }
785
+ return this.factory.createUnaryExpression(UNARY_OPERATORS.get(ast.operator), ast.expr.visitExpression(this, context));
786
+ }
787
+ visitStatements(statements, context) {
788
+ return statements.map((stmt) => stmt.visitStatement(this, context)).filter((stmt) => stmt !== void 0);
789
+ }
790
+ setSourceMapRange(ast, span) {
791
+ return this.factory.setSourceMapRange(ast, createRange(span));
792
+ }
793
+ attachComments(statement, leadingComments) {
794
+ if (leadingComments !== void 0) {
795
+ this.factory.attachComments(statement, leadingComments);
796
+ }
797
+ return statement;
798
+ }
799
+ };
800
+ function createTemplateElement({ cooked, raw, range }) {
801
+ return { cooked, raw, range: createRange(range) };
802
+ }
803
+ function createRange(span) {
804
+ if (span === null) {
805
+ return null;
806
+ }
807
+ const { start, end } = span;
808
+ const { url, content } = start.file;
809
+ if (!url) {
810
+ return null;
811
+ }
812
+ return {
813
+ url,
814
+ content,
815
+ start: { offset: start.offset, line: start.line, column: start.col },
816
+ end: { offset: end.offset, line: end.line, column: end.col }
817
+ };
818
+ }
819
+
820
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager.mjs
821
+ import ts5 from "typescript";
822
+ var ImportManager = class {
823
+ constructor(rewriter = new NoopImportRewriter(), prefix = "i") {
824
+ this.rewriter = rewriter;
825
+ this.prefix = prefix;
826
+ this.specifierToIdentifier = new Map();
827
+ this.nextIndex = 0;
828
+ }
829
+ generateNamespaceImport(moduleName) {
830
+ if (!this.specifierToIdentifier.has(moduleName)) {
831
+ this.specifierToIdentifier.set(moduleName, ts5.createIdentifier(`${this.prefix}${this.nextIndex++}`));
832
+ }
833
+ return this.specifierToIdentifier.get(moduleName);
834
+ }
835
+ generateNamedImport(moduleName, originalSymbol) {
836
+ const symbol = this.rewriter.rewriteSymbol(originalSymbol, moduleName);
837
+ if (!this.rewriter.shouldImportSymbol(symbol, moduleName)) {
838
+ return { moduleImport: null, symbol };
839
+ }
840
+ const moduleImport = this.generateNamespaceImport(moduleName);
841
+ return { moduleImport, symbol };
842
+ }
843
+ getAllImports(contextPath) {
844
+ const imports = [];
845
+ for (const [originalSpecifier, qualifier] of this.specifierToIdentifier) {
846
+ const specifier = this.rewriter.rewriteSpecifier(originalSpecifier, contextPath);
847
+ imports.push({
848
+ specifier,
849
+ qualifier
850
+ });
851
+ }
852
+ return imports;
853
+ }
854
+ };
855
+
856
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
857
+ import {
858
+ BuiltinTypeName
859
+ } from "@angular/compiler";
860
+ import ts6 from "typescript";
861
+ function translateType(type, imports) {
862
+ return type.visitType(new TypeTranslatorVisitor(imports), new Context(false));
863
+ }
864
+ var TypeTranslatorVisitor = class {
865
+ constructor(imports) {
866
+ this.imports = imports;
867
+ }
868
+ visitBuiltinType(type, context) {
869
+ switch (type.name) {
870
+ case BuiltinTypeName.Bool:
871
+ return ts6.createKeywordTypeNode(ts6.SyntaxKind.BooleanKeyword);
872
+ case BuiltinTypeName.Dynamic:
873
+ return ts6.createKeywordTypeNode(ts6.SyntaxKind.AnyKeyword);
874
+ case BuiltinTypeName.Int:
875
+ case BuiltinTypeName.Number:
876
+ return ts6.createKeywordTypeNode(ts6.SyntaxKind.NumberKeyword);
877
+ case BuiltinTypeName.String:
878
+ return ts6.createKeywordTypeNode(ts6.SyntaxKind.StringKeyword);
879
+ case BuiltinTypeName.None:
880
+ return ts6.createKeywordTypeNode(ts6.SyntaxKind.NeverKeyword);
881
+ default:
882
+ throw new Error(`Unsupported builtin type: ${BuiltinTypeName[type.name]}`);
883
+ }
884
+ }
885
+ visitExpressionType(type, context) {
886
+ const typeNode = this.translateExpression(type.value, context);
887
+ if (type.typeParams === null) {
888
+ return typeNode;
889
+ }
890
+ if (!ts6.isTypeReferenceNode(typeNode)) {
891
+ throw new Error("An ExpressionType with type arguments must translate into a TypeReferenceNode");
892
+ } else if (typeNode.typeArguments !== void 0) {
893
+ throw new Error(`An ExpressionType with type arguments cannot have multiple levels of type arguments`);
894
+ }
895
+ const typeArgs = type.typeParams.map((param) => this.translateType(param, context));
896
+ return ts6.createTypeReferenceNode(typeNode.typeName, typeArgs);
897
+ }
898
+ visitArrayType(type, context) {
899
+ return ts6.createArrayTypeNode(this.translateType(type.of, context));
900
+ }
901
+ visitMapType(type, context) {
902
+ const parameter = ts6.createParameter(void 0, void 0, void 0, "key", void 0, ts6.createKeywordTypeNode(ts6.SyntaxKind.StringKeyword));
903
+ const typeArgs = type.valueType !== null ? this.translateType(type.valueType, context) : ts6.createKeywordTypeNode(ts6.SyntaxKind.UnknownKeyword);
904
+ const indexSignature = ts6.createIndexSignature(void 0, void 0, [parameter], typeArgs);
905
+ return ts6.createTypeLiteralNode([indexSignature]);
906
+ }
907
+ visitReadVarExpr(ast, context) {
908
+ if (ast.name === null) {
909
+ throw new Error(`ReadVarExpr with no variable name in type`);
910
+ }
911
+ return ts6.createTypeQueryNode(ts6.createIdentifier(ast.name));
912
+ }
913
+ visitWriteVarExpr(expr, context) {
914
+ throw new Error("Method not implemented.");
915
+ }
916
+ visitWriteKeyExpr(expr, context) {
917
+ throw new Error("Method not implemented.");
918
+ }
919
+ visitWritePropExpr(expr, context) {
920
+ throw new Error("Method not implemented.");
921
+ }
922
+ visitInvokeFunctionExpr(ast, context) {
923
+ throw new Error("Method not implemented.");
924
+ }
925
+ visitTaggedTemplateExpr(ast, context) {
926
+ throw new Error("Method not implemented.");
927
+ }
928
+ visitInstantiateExpr(ast, context) {
929
+ throw new Error("Method not implemented.");
930
+ }
931
+ visitLiteralExpr(ast, context) {
932
+ if (ast.value === null) {
933
+ return ts6.createLiteralTypeNode(ts6.createNull());
934
+ } else if (ast.value === void 0) {
935
+ return ts6.createKeywordTypeNode(ts6.SyntaxKind.UndefinedKeyword);
936
+ } else if (typeof ast.value === "boolean") {
937
+ return ts6.createLiteralTypeNode(ts6.createLiteral(ast.value));
938
+ } else if (typeof ast.value === "number") {
939
+ return ts6.createLiteralTypeNode(ts6.createLiteral(ast.value));
940
+ } else {
941
+ return ts6.createLiteralTypeNode(ts6.createLiteral(ast.value));
942
+ }
943
+ }
944
+ visitLocalizedString(ast, context) {
945
+ throw new Error("Method not implemented.");
946
+ }
947
+ visitExternalExpr(ast, context) {
948
+ if (ast.value.moduleName === null || ast.value.name === null) {
949
+ throw new Error(`Import unknown module or symbol`);
950
+ }
951
+ const { moduleImport, symbol } = this.imports.generateNamedImport(ast.value.moduleName, ast.value.name);
952
+ const symbolIdentifier = ts6.createIdentifier(symbol);
953
+ const typeName = moduleImport ? ts6.createQualifiedName(moduleImport, symbolIdentifier) : symbolIdentifier;
954
+ const typeArguments = ast.typeParams !== null ? ast.typeParams.map((type) => this.translateType(type, context)) : void 0;
955
+ return ts6.createTypeReferenceNode(typeName, typeArguments);
956
+ }
957
+ visitConditionalExpr(ast, context) {
958
+ throw new Error("Method not implemented.");
959
+ }
960
+ visitNotExpr(ast, context) {
961
+ throw new Error("Method not implemented.");
962
+ }
963
+ visitAssertNotNullExpr(ast, context) {
964
+ throw new Error("Method not implemented.");
965
+ }
966
+ visitCastExpr(ast, context) {
967
+ throw new Error("Method not implemented.");
968
+ }
969
+ visitFunctionExpr(ast, context) {
970
+ throw new Error("Method not implemented.");
971
+ }
972
+ visitUnaryOperatorExpr(ast, context) {
973
+ throw new Error("Method not implemented.");
974
+ }
975
+ visitBinaryOperatorExpr(ast, context) {
976
+ throw new Error("Method not implemented.");
977
+ }
978
+ visitReadPropExpr(ast, context) {
979
+ throw new Error("Method not implemented.");
980
+ }
981
+ visitReadKeyExpr(ast, context) {
982
+ throw new Error("Method not implemented.");
983
+ }
984
+ visitLiteralArrayExpr(ast, context) {
985
+ const values = ast.entries.map((expr) => this.translateExpression(expr, context));
986
+ return ts6.createTupleTypeNode(values);
987
+ }
988
+ visitLiteralMapExpr(ast, context) {
989
+ const entries = ast.entries.map((entry) => {
990
+ const { key, quoted } = entry;
991
+ const type = this.translateExpression(entry.value, context);
992
+ return ts6.createPropertySignature(void 0, quoted ? ts6.createStringLiteral(key) : key, void 0, type, void 0);
993
+ });
994
+ return ts6.createTypeLiteralNode(entries);
995
+ }
996
+ visitCommaExpr(ast, context) {
997
+ throw new Error("Method not implemented.");
998
+ }
999
+ visitWrappedNodeExpr(ast, context) {
1000
+ const node = ast.node;
1001
+ if (ts6.isEntityName(node)) {
1002
+ return ts6.createTypeReferenceNode(node, void 0);
1003
+ } else if (ts6.isTypeNode(node)) {
1004
+ return node;
1005
+ } else if (ts6.isLiteralExpression(node)) {
1006
+ return ts6.createLiteralTypeNode(node);
1007
+ } else {
1008
+ throw new Error(`Unsupported WrappedNodeExpr in TypeTranslatorVisitor: ${ts6.SyntaxKind[node.kind]}`);
1009
+ }
1010
+ }
1011
+ visitTypeofExpr(ast, context) {
1012
+ const typeNode = this.translateExpression(ast.expr, context);
1013
+ if (!ts6.isTypeReferenceNode(typeNode)) {
1014
+ throw new Error(`The target of a typeof expression must be a type reference, but it was
1015
+ ${ts6.SyntaxKind[typeNode.kind]}`);
1016
+ }
1017
+ return ts6.createTypeQueryNode(typeNode.typeName);
1018
+ }
1019
+ translateType(type, context) {
1020
+ const typeNode = type.visitType(this, context);
1021
+ if (!ts6.isTypeNode(typeNode)) {
1022
+ throw new Error(`A Type must translate to a TypeNode, but was ${ts6.SyntaxKind[typeNode.kind]}`);
1023
+ }
1024
+ return typeNode;
1025
+ }
1026
+ translateExpression(expr, context) {
1027
+ const typeNode = expr.visitExpression(this, context);
1028
+ if (!ts6.isTypeNode(typeNode)) {
1029
+ throw new Error(`An Expression must translate to a TypeNode, but was ${ts6.SyntaxKind[typeNode.kind]}`);
1030
+ }
1031
+ return typeNode;
1032
+ }
1033
+ };
1034
+
1035
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.mjs
1036
+ import ts7 from "typescript";
1037
+ var PureAnnotation;
1038
+ (function(PureAnnotation2) {
1039
+ PureAnnotation2["CLOSURE"] = "* @pureOrBreakMyCode ";
1040
+ PureAnnotation2["TERSER"] = "@__PURE__";
1041
+ })(PureAnnotation || (PureAnnotation = {}));
1042
+ var UNARY_OPERATORS2 = {
1043
+ "+": ts7.SyntaxKind.PlusToken,
1044
+ "-": ts7.SyntaxKind.MinusToken,
1045
+ "!": ts7.SyntaxKind.ExclamationToken
1046
+ };
1047
+ var BINARY_OPERATORS2 = {
1048
+ "&&": ts7.SyntaxKind.AmpersandAmpersandToken,
1049
+ ">": ts7.SyntaxKind.GreaterThanToken,
1050
+ ">=": ts7.SyntaxKind.GreaterThanEqualsToken,
1051
+ "&": ts7.SyntaxKind.AmpersandToken,
1052
+ "/": ts7.SyntaxKind.SlashToken,
1053
+ "==": ts7.SyntaxKind.EqualsEqualsToken,
1054
+ "===": ts7.SyntaxKind.EqualsEqualsEqualsToken,
1055
+ "<": ts7.SyntaxKind.LessThanToken,
1056
+ "<=": ts7.SyntaxKind.LessThanEqualsToken,
1057
+ "-": ts7.SyntaxKind.MinusToken,
1058
+ "%": ts7.SyntaxKind.PercentToken,
1059
+ "*": ts7.SyntaxKind.AsteriskToken,
1060
+ "!=": ts7.SyntaxKind.ExclamationEqualsToken,
1061
+ "!==": ts7.SyntaxKind.ExclamationEqualsEqualsToken,
1062
+ "||": ts7.SyntaxKind.BarBarToken,
1063
+ "+": ts7.SyntaxKind.PlusToken,
1064
+ "??": ts7.SyntaxKind.QuestionQuestionToken
1065
+ };
1066
+ var VAR_TYPES = {
1067
+ "const": ts7.NodeFlags.Const,
1068
+ "let": ts7.NodeFlags.Let,
1069
+ "var": ts7.NodeFlags.None
1070
+ };
1071
+ var TypeScriptAstFactory = class {
1072
+ constructor(annotateForClosureCompiler) {
1073
+ this.annotateForClosureCompiler = annotateForClosureCompiler;
1074
+ this.externalSourceFiles = new Map();
1075
+ this.attachComments = attachComments;
1076
+ this.createArrayLiteral = ts7.createArrayLiteral;
1077
+ this.createConditional = ts7.createConditional;
1078
+ this.createElementAccess = ts7.createElementAccess;
1079
+ this.createExpressionStatement = ts7.createExpressionStatement;
1080
+ this.createIdentifier = ts7.createIdentifier;
1081
+ this.createParenthesizedExpression = ts7.createParen;
1082
+ this.createPropertyAccess = ts7.createPropertyAccess;
1083
+ this.createThrowStatement = ts7.createThrow;
1084
+ this.createTypeOfExpression = ts7.createTypeOf;
1085
+ }
1086
+ createAssignment(target, value) {
1087
+ return ts7.createBinary(target, ts7.SyntaxKind.EqualsToken, value);
1088
+ }
1089
+ createBinaryExpression(leftOperand, operator, rightOperand) {
1090
+ return ts7.createBinary(leftOperand, BINARY_OPERATORS2[operator], rightOperand);
1091
+ }
1092
+ createBlock(body) {
1093
+ return ts7.createBlock(body);
1094
+ }
1095
+ createCallExpression(callee, args, pure) {
1096
+ const call = ts7.createCall(callee, void 0, args);
1097
+ if (pure) {
1098
+ ts7.addSyntheticLeadingComment(call, ts7.SyntaxKind.MultiLineCommentTrivia, this.annotateForClosureCompiler ? PureAnnotation.CLOSURE : PureAnnotation.TERSER, false);
1099
+ }
1100
+ return call;
1101
+ }
1102
+ createFunctionDeclaration(functionName, parameters, body) {
1103
+ if (!ts7.isBlock(body)) {
1104
+ throw new Error(`Invalid syntax, expected a block, but got ${ts7.SyntaxKind[body.kind]}.`);
1105
+ }
1106
+ return ts7.createFunctionDeclaration(void 0, void 0, void 0, functionName, void 0, parameters.map((param) => ts7.createParameter(void 0, void 0, void 0, param)), void 0, body);
1107
+ }
1108
+ createFunctionExpression(functionName, parameters, body) {
1109
+ if (!ts7.isBlock(body)) {
1110
+ throw new Error(`Invalid syntax, expected a block, but got ${ts7.SyntaxKind[body.kind]}.`);
1111
+ }
1112
+ return ts7.createFunctionExpression(void 0, void 0, functionName != null ? functionName : void 0, void 0, parameters.map((param) => ts7.createParameter(void 0, void 0, void 0, param)), void 0, body);
1113
+ }
1114
+ createIfStatement(condition, thenStatement, elseStatement) {
1115
+ return ts7.createIf(condition, thenStatement, elseStatement != null ? elseStatement : void 0);
1116
+ }
1117
+ createLiteral(value) {
1118
+ if (value === void 0) {
1119
+ return ts7.createIdentifier("undefined");
1120
+ } else if (value === null) {
1121
+ return ts7.createNull();
1122
+ } else {
1123
+ return ts7.createLiteral(value);
1124
+ }
1125
+ }
1126
+ createNewExpression(expression, args) {
1127
+ return ts7.createNew(expression, void 0, args);
1128
+ }
1129
+ createObjectLiteral(properties) {
1130
+ return ts7.createObjectLiteral(properties.map((prop) => ts7.createPropertyAssignment(prop.quoted ? ts7.createLiteral(prop.propertyName) : ts7.createIdentifier(prop.propertyName), prop.value)));
1131
+ }
1132
+ createReturnStatement(expression) {
1133
+ return ts7.createReturn(expression != null ? expression : void 0);
1134
+ }
1135
+ createTaggedTemplate(tag, template) {
1136
+ let templateLiteral;
1137
+ const length = template.elements.length;
1138
+ const head = template.elements[0];
1139
+ if (length === 1) {
1140
+ templateLiteral = ts7.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
1141
+ } else {
1142
+ const spans = [];
1143
+ for (let i = 1; i < length - 1; i++) {
1144
+ const { cooked, raw, range } = template.elements[i];
1145
+ const middle = createTemplateMiddle(cooked, raw);
1146
+ if (range !== null) {
1147
+ this.setSourceMapRange(middle, range);
1148
+ }
1149
+ spans.push(ts7.createTemplateSpan(template.expressions[i - 1], middle));
1150
+ }
1151
+ const resolvedExpression = template.expressions[length - 2];
1152
+ const templatePart = template.elements[length - 1];
1153
+ const templateTail = createTemplateTail(templatePart.cooked, templatePart.raw);
1154
+ if (templatePart.range !== null) {
1155
+ this.setSourceMapRange(templateTail, templatePart.range);
1156
+ }
1157
+ spans.push(ts7.createTemplateSpan(resolvedExpression, templateTail));
1158
+ templateLiteral = ts7.createTemplateExpression(ts7.createTemplateHead(head.cooked, head.raw), spans);
1159
+ }
1160
+ if (head.range !== null) {
1161
+ this.setSourceMapRange(templateLiteral, head.range);
1162
+ }
1163
+ return ts7.createTaggedTemplate(tag, templateLiteral);
1164
+ }
1165
+ createUnaryExpression(operator, operand) {
1166
+ return ts7.createPrefix(UNARY_OPERATORS2[operator], operand);
1167
+ }
1168
+ createVariableDeclaration(variableName, initializer, type) {
1169
+ return ts7.createVariableStatement(void 0, ts7.createVariableDeclarationList([ts7.createVariableDeclaration(variableName, void 0, initializer != null ? initializer : void 0)], VAR_TYPES[type]));
1170
+ }
1171
+ setSourceMapRange(node, sourceMapRange) {
1172
+ if (sourceMapRange === null) {
1173
+ return node;
1174
+ }
1175
+ const url = sourceMapRange.url;
1176
+ if (!this.externalSourceFiles.has(url)) {
1177
+ this.externalSourceFiles.set(url, ts7.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
1178
+ }
1179
+ const source = this.externalSourceFiles.get(url);
1180
+ ts7.setSourceMapRange(node, { pos: sourceMapRange.start.offset, end: sourceMapRange.end.offset, source });
1181
+ return node;
1182
+ }
1183
+ };
1184
+ function createTemplateMiddle(cooked, raw) {
1185
+ const node = ts7.createTemplateHead(cooked, raw);
1186
+ node.kind = ts7.SyntaxKind.TemplateMiddle;
1187
+ return node;
1188
+ }
1189
+ function createTemplateTail(cooked, raw) {
1190
+ const node = ts7.createTemplateHead(cooked, raw);
1191
+ node.kind = ts7.SyntaxKind.TemplateTail;
1192
+ return node;
1193
+ }
1194
+ function attachComments(statement, leadingComments) {
1195
+ for (const comment of leadingComments) {
1196
+ const commentKind = comment.multiline ? ts7.SyntaxKind.MultiLineCommentTrivia : ts7.SyntaxKind.SingleLineCommentTrivia;
1197
+ if (comment.multiline) {
1198
+ ts7.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
1199
+ } else {
1200
+ for (const line of comment.toString().split("\n")) {
1201
+ ts7.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
1202
+ }
1203
+ }
1204
+ }
1205
+ }
1206
+
1207
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_translator.mjs
1208
+ function translateExpression(expression, imports, options = {}) {
1209
+ return expression.visitExpression(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(false));
1210
+ }
1211
+ function translateStatement(statement, imports, options = {}) {
1212
+ return statement.visitStatement(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(true));
1213
+ }
1214
+
1215
+ export {
1216
+ isSymbolWithValueDeclaration,
1217
+ isDtsPath,
1218
+ isNonDeclarationTsPath,
1219
+ isFromDtsFile,
1220
+ nodeNameForError,
1221
+ getSourceFile,
1222
+ getSourceFileOrNull,
1223
+ getTokenAtPosition,
1224
+ identifierOfNode,
1225
+ isDeclaration,
1226
+ getRootDirs,
1227
+ nodeDebugInfo,
1228
+ isAssignment,
1229
+ toUnredirectedSourceFile,
1230
+ createExportSpecifier,
1231
+ ImportFlags,
1232
+ ReferenceEmitter,
1233
+ LocalIdentifierStrategy,
1234
+ AbsoluteModuleStrategy,
1235
+ LogicalProjectStrategy,
1236
+ RelativePathStrategy,
1237
+ UnifiedModulesStrategy,
1238
+ UnifiedModulesAliasingHost,
1239
+ PrivateExportAliasingHost,
1240
+ AliasStrategy,
1241
+ relativePathBetween,
1242
+ normalizeSeparators,
1243
+ NoopImportRewriter,
1244
+ R3SymbolsImportRewriter,
1245
+ validateAndRewriteCoreSymbol,
1246
+ attachDefaultImportDeclaration,
1247
+ getDefaultImportDeclaration,
1248
+ DefaultImportTracker,
1249
+ Reference,
1250
+ ModuleResolver,
1251
+ Context,
1252
+ ImportManager,
1253
+ ExpressionTranslatorVisitor,
1254
+ translateType,
1255
+ translateExpression,
1256
+ translateStatement
1257
+ };
1258
+ /**
1259
+ * @license
1260
+ * Copyright Google LLC All Rights Reserved.
1261
+ *
1262
+ * Use of this source code is governed by an MIT-style license that can be
1263
+ * found in the LICENSE file at https://angular.io/license
1264
+ */
1265
+ //# sourceMappingURL=chunk-HDZS2JG2.js.map