@angular/compiler-cli 18.0.0-next.0 → 18.0.0-next.2
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.
- package/bundles/{chunk-NB6ZWAGP.js → chunk-32GYU5L6.js} +60 -21
- package/bundles/chunk-32GYU5L6.js.map +6 -0
- package/bundles/{chunk-4A7ZWBEL.js → chunk-4CJL5R2P.js} +59 -57
- package/bundles/{chunk-4A7ZWBEL.js.map → chunk-4CJL5R2P.js.map} +1 -1
- package/bundles/{chunk-A46CQFUG.js → chunk-MTZKBEZU.js} +276 -245
- package/bundles/chunk-MTZKBEZU.js.map +6 -0
- package/bundles/{chunk-6X7GQ6BQ.js → chunk-NPXXJQN4.js} +603 -245
- package/bundles/chunk-NPXXJQN4.js.map +6 -0
- package/bundles/{chunk-64VF23SF.js → chunk-VFVLP7AO.js} +2 -2
- package/bundles/{chunk-SQY7XLGB.js → chunk-YMLYBTFV.js} +2225 -904
- package/bundles/chunk-YMLYBTFV.js.map +6 -0
- package/bundles/index.js +7 -5
- package/bundles/index.js.map +1 -1
- package/bundles/linker/babel/index.js +10 -3
- package/bundles/linker/babel/index.js.map +1 -1
- package/bundles/linker/index.js +2 -2
- package/bundles/private/migrations.js +2 -2
- package/bundles/private/tooling.js +3 -3
- package/bundles/src/bin/ng_xi18n.js +4 -4
- package/bundles/src/bin/ngc.js +4 -4
- package/bundles_metadata.json +1 -1
- package/index.d.ts +1 -0
- package/linker/babel/src/ast/babel_ast_host.d.ts +2 -1
- package/linker/src/ast/ast_host.d.ts +4 -0
- package/linker/src/ast/ast_value.d.ts +5 -0
- package/linker/src/ast/typescript/typescript_ast_host.d.ts +1 -0
- package/linker/src/file_linker/partial_linkers/partial_class_metadata_async_linker_1.d.ts +16 -0
- package/linker/src/file_linker/partial_linkers/partial_linker_selector.d.ts +1 -0
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/linker/src/file_linker/translator.d.ts +2 -2
- package/linker/src/linker_import_generator.d.ts +5 -5
- package/package.json +4 -4
- package/src/ngtsc/annotations/component/src/handler.d.ts +1 -1
- package/src/ngtsc/annotations/directive/index.d.ts +1 -0
- package/src/ngtsc/annotations/directive/src/initializer_function_access.d.ts +17 -0
- package/src/ngtsc/annotations/directive/src/initializer_functions.d.ts +10 -6
- package/src/ngtsc/annotations/directive/src/input_function.d.ts +4 -1
- package/src/ngtsc/annotations/directive/src/model_function.d.ts +4 -1
- package/src/ngtsc/annotations/directive/src/output_function.d.ts +4 -1
- package/src/ngtsc/annotations/directive/src/query_functions.d.ts +8 -2
- package/src/ngtsc/annotations/index.d.ts +1 -1
- package/src/ngtsc/core/src/core_version.d.ts +11 -0
- package/src/ngtsc/diagnostics/src/error_code.d.ts +19 -0
- package/src/ngtsc/docs/src/entities.d.ts +36 -1
- package/src/ngtsc/docs/src/function_extractor.d.ts +3 -2
- package/src/ngtsc/docs/src/initializer_api_function_extractor.d.ts +24 -0
- package/src/ngtsc/docs/src/internal.d.ts +8 -0
- package/src/ngtsc/imports/index.d.ts +1 -1
- package/src/ngtsc/imports/src/core.d.ts +0 -9
- package/src/ngtsc/imports/src/imported_symbols_tracker.d.ts +13 -0
- package/src/ngtsc/imports/src/patch_alias_reference_resolution.d.ts +3 -1
- package/src/ngtsc/reflection/src/host.d.ts +13 -3
- package/src/ngtsc/reflection/src/typescript.d.ts +8 -1
- package/src/ngtsc/reflection/src/util.d.ts +6 -1
- package/src/ngtsc/transform/index.d.ts +0 -1
- package/src/ngtsc/transform/src/declaration.d.ts +1 -1
- package/src/ngtsc/translator/index.d.ts +2 -2
- package/src/ngtsc/translator/src/api/import_generator.d.ts +22 -10
- package/src/ngtsc/translator/src/import_manager/check_unique_identifier_name.d.ts +13 -0
- package/src/ngtsc/translator/src/import_manager/import_manager.d.ts +94 -0
- package/src/ngtsc/translator/src/import_manager/import_typescript_transform.d.ts +17 -0
- package/src/ngtsc/translator/src/import_manager/reuse_generated_imports.d.ts +32 -0
- package/src/ngtsc/translator/src/import_manager/reuse_source_file_imports.d.ts +38 -0
- package/src/ngtsc/translator/src/translator.d.ts +3 -2
- package/src/ngtsc/translator/src/type_translator.d.ts +1 -1
- package/src/ngtsc/translator/src/typescript_translator.d.ts +2 -2
- package/src/ngtsc/typecheck/src/oob.d.ts +3 -3
- package/src/ngtsc/typecheck/src/reference_emit_environment.d.ts +1 -1
- package/src/ngtsc/typecheck/src/ts_util.d.ts +0 -2
- package/src/ngtsc/validation/index.d.ts +8 -0
- package/src/ngtsc/validation/src/rules/api.d.ts +24 -0
- package/src/ngtsc/validation/src/rules/initializer_api_usage_rule.d.ts +21 -0
- package/src/ngtsc/validation/src/source_file_validator.d.ts +22 -0
- package/src/transformers/jit_transforms/initializer_api_transforms/transform_api.d.ts +4 -4
- package/bundles/chunk-6X7GQ6BQ.js.map +0 -6
- package/bundles/chunk-A46CQFUG.js.map +0 -6
- package/bundles/chunk-NB6ZWAGP.js.map +0 -6
- package/bundles/chunk-SQY7XLGB.js.map +0 -6
- package/src/ngtsc/transform/src/utils.d.ts +0 -15
- package/src/ngtsc/translator/src/import_manager.d.ts +0 -47
- /package/bundles/{chunk-64VF23SF.js.map → chunk-VFVLP7AO.js.map} +0 -0
|
@@ -30,6 +30,7 @@ var ErrorCode;
|
|
|
30
30
|
ErrorCode2[ErrorCode2["INITIALIZER_API_WITH_DISALLOWED_DECORATOR"] = 1050] = "INITIALIZER_API_WITH_DISALLOWED_DECORATOR";
|
|
31
31
|
ErrorCode2[ErrorCode2["INITIALIZER_API_DECORATOR_METADATA_COLLISION"] = 1051] = "INITIALIZER_API_DECORATOR_METADATA_COLLISION";
|
|
32
32
|
ErrorCode2[ErrorCode2["INITIALIZER_API_NO_REQUIRED_FUNCTION"] = 1052] = "INITIALIZER_API_NO_REQUIRED_FUNCTION";
|
|
33
|
+
ErrorCode2[ErrorCode2["INITIALIZER_API_DISALLOWED_MEMBER_VISIBILITY"] = 1053] = "INITIALIZER_API_DISALLOWED_MEMBER_VISIBILITY";
|
|
33
34
|
ErrorCode2[ErrorCode2["INCORRECTLY_DECLARED_ON_STATIC_MEMBER"] = 1100] = "INCORRECTLY_DECLARED_ON_STATIC_MEMBER";
|
|
34
35
|
ErrorCode2[ErrorCode2["COMPONENT_MISSING_TEMPLATE"] = 2001] = "COMPONENT_MISSING_TEMPLATE";
|
|
35
36
|
ErrorCode2[ErrorCode2["PIPE_MISSING_NAME"] = 2002] = "PIPE_MISSING_NAME";
|
|
@@ -96,6 +97,7 @@ var ErrorCode;
|
|
|
96
97
|
ErrorCode2[ErrorCode2["OPTIONAL_CHAIN_NOT_NULLABLE"] = 8107] = "OPTIONAL_CHAIN_NOT_NULLABLE";
|
|
97
98
|
ErrorCode2[ErrorCode2["SKIP_HYDRATION_NOT_STATIC"] = 8108] = "SKIP_HYDRATION_NOT_STATIC";
|
|
98
99
|
ErrorCode2[ErrorCode2["INTERPOLATED_SIGNAL_NOT_INVOKED"] = 8109] = "INTERPOLATED_SIGNAL_NOT_INVOKED";
|
|
100
|
+
ErrorCode2[ErrorCode2["UNSUPPORTED_INITIALIZER_API_USAGE"] = 8110] = "UNSUPPORTED_INITIALIZER_API_USAGE";
|
|
99
101
|
ErrorCode2[ErrorCode2["INLINE_TCB_REQUIRED"] = 8900] = "INLINE_TCB_REQUIRED";
|
|
100
102
|
ErrorCode2[ErrorCode2["INLINE_TYPE_CTOR_REQUIRED"] = 8901] = "INLINE_TYPE_CTOR_REQUIRED";
|
|
101
103
|
ErrorCode2[ErrorCode2["INJECTABLE_DUPLICATE_PROV"] = 9001] = "INJECTABLE_DUPLICATE_PROV";
|
|
@@ -117,12 +119,12 @@ function ngErrorCode(code) {
|
|
|
117
119
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/diagnostics/src/error.mjs
|
|
118
120
|
var FatalDiagnosticError = class extends Error {
|
|
119
121
|
constructor(code, node, diagnosticMessage, relatedInformation) {
|
|
120
|
-
super(`FatalDiagnosticError
|
|
122
|
+
super(`FatalDiagnosticError: Code: ${code}, Message: ${ts.flattenDiagnosticMessageText(diagnosticMessage, "\n")}`);
|
|
121
123
|
this.code = code;
|
|
122
124
|
this.node = node;
|
|
123
125
|
this.diagnosticMessage = diagnosticMessage;
|
|
124
126
|
this.relatedInformation = relatedInformation;
|
|
125
|
-
this.message =
|
|
127
|
+
this.message = this.message;
|
|
126
128
|
this._isFatalDiagnosticError = true;
|
|
127
129
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
128
130
|
}
|
|
@@ -225,6 +227,14 @@ var ClassMemberKind;
|
|
|
225
227
|
ClassMemberKind2[ClassMemberKind2["Property"] = 3] = "Property";
|
|
226
228
|
ClassMemberKind2[ClassMemberKind2["Method"] = 4] = "Method";
|
|
227
229
|
})(ClassMemberKind || (ClassMemberKind = {}));
|
|
230
|
+
var ClassMemberAccessLevel;
|
|
231
|
+
(function(ClassMemberAccessLevel2) {
|
|
232
|
+
ClassMemberAccessLevel2[ClassMemberAccessLevel2["PublicWritable"] = 0] = "PublicWritable";
|
|
233
|
+
ClassMemberAccessLevel2[ClassMemberAccessLevel2["PublicReadonly"] = 1] = "PublicReadonly";
|
|
234
|
+
ClassMemberAccessLevel2[ClassMemberAccessLevel2["Protected"] = 2] = "Protected";
|
|
235
|
+
ClassMemberAccessLevel2[ClassMemberAccessLevel2["Private"] = 3] = "Private";
|
|
236
|
+
ClassMemberAccessLevel2[ClassMemberAccessLevel2["EcmaScriptPrivate"] = 4] = "EcmaScriptPrivate";
|
|
237
|
+
})(ClassMemberAccessLevel || (ClassMemberAccessLevel = {}));
|
|
228
238
|
var AmbientImport = {};
|
|
229
239
|
|
|
230
240
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/type_to_value.mjs
|
|
@@ -408,6 +418,21 @@ function isNamedClassDeclaration(node) {
|
|
|
408
418
|
function isIdentifier(node) {
|
|
409
419
|
return node !== void 0 && ts4.isIdentifier(node);
|
|
410
420
|
}
|
|
421
|
+
function classMemberAccessLevelToString(level) {
|
|
422
|
+
switch (level) {
|
|
423
|
+
case ClassMemberAccessLevel.EcmaScriptPrivate:
|
|
424
|
+
return "ES private";
|
|
425
|
+
case ClassMemberAccessLevel.Private:
|
|
426
|
+
return "private";
|
|
427
|
+
case ClassMemberAccessLevel.Protected:
|
|
428
|
+
return "protected";
|
|
429
|
+
case ClassMemberAccessLevel.PublicReadonly:
|
|
430
|
+
return "public readonly";
|
|
431
|
+
case ClassMemberAccessLevel.PublicWritable:
|
|
432
|
+
default:
|
|
433
|
+
return "public";
|
|
434
|
+
}
|
|
435
|
+
}
|
|
411
436
|
|
|
412
437
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/reflection/src/typescript.mjs
|
|
413
438
|
var TypeScriptReflectionHost = class {
|
|
@@ -421,7 +446,16 @@ var TypeScriptReflectionHost = class {
|
|
|
421
446
|
}
|
|
422
447
|
getMembersOfClass(clazz) {
|
|
423
448
|
const tsClazz = castDeclarationToClassOrDie(clazz);
|
|
424
|
-
return tsClazz.members.map((member) =>
|
|
449
|
+
return tsClazz.members.map((member) => {
|
|
450
|
+
const result = reflectClassMember(member);
|
|
451
|
+
if (result === null) {
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
return {
|
|
455
|
+
...result,
|
|
456
|
+
decorators: this.getDecoratorsOfDeclaration(member)
|
|
457
|
+
};
|
|
458
|
+
}).filter((member) => member !== null);
|
|
425
459
|
}
|
|
426
460
|
getConstructorParameters(clazz) {
|
|
427
461
|
const tsClazz = castDeclarationToClassOrDie(clazz);
|
|
@@ -656,51 +690,6 @@ var TypeScriptReflectionHost = class {
|
|
|
656
690
|
args
|
|
657
691
|
};
|
|
658
692
|
}
|
|
659
|
-
_reflectMember(node) {
|
|
660
|
-
let kind = null;
|
|
661
|
-
let value = null;
|
|
662
|
-
let name = null;
|
|
663
|
-
let nameNode = null;
|
|
664
|
-
if (ts5.isPropertyDeclaration(node)) {
|
|
665
|
-
kind = ClassMemberKind.Property;
|
|
666
|
-
value = node.initializer || null;
|
|
667
|
-
} else if (ts5.isGetAccessorDeclaration(node)) {
|
|
668
|
-
kind = ClassMemberKind.Getter;
|
|
669
|
-
} else if (ts5.isSetAccessorDeclaration(node)) {
|
|
670
|
-
kind = ClassMemberKind.Setter;
|
|
671
|
-
} else if (ts5.isMethodDeclaration(node)) {
|
|
672
|
-
kind = ClassMemberKind.Method;
|
|
673
|
-
} else if (ts5.isConstructorDeclaration(node)) {
|
|
674
|
-
kind = ClassMemberKind.Constructor;
|
|
675
|
-
} else {
|
|
676
|
-
return null;
|
|
677
|
-
}
|
|
678
|
-
if (ts5.isConstructorDeclaration(node)) {
|
|
679
|
-
name = "constructor";
|
|
680
|
-
} else if (ts5.isIdentifier(node.name)) {
|
|
681
|
-
name = node.name.text;
|
|
682
|
-
nameNode = node.name;
|
|
683
|
-
} else if (ts5.isStringLiteral(node.name)) {
|
|
684
|
-
name = node.name.text;
|
|
685
|
-
nameNode = node.name;
|
|
686
|
-
} else {
|
|
687
|
-
return null;
|
|
688
|
-
}
|
|
689
|
-
const decorators = this.getDecoratorsOfDeclaration(node);
|
|
690
|
-
const modifiers = ts5.getModifiers(node);
|
|
691
|
-
const isStatic = modifiers !== void 0 && modifiers.some((mod) => mod.kind === ts5.SyntaxKind.StaticKeyword);
|
|
692
|
-
return {
|
|
693
|
-
node,
|
|
694
|
-
implementation: node,
|
|
695
|
-
kind,
|
|
696
|
-
type: node.type || null,
|
|
697
|
-
name,
|
|
698
|
-
nameNode,
|
|
699
|
-
decorators,
|
|
700
|
-
value,
|
|
701
|
-
isStatic
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
693
|
getLocalExportedDeclarationsOfSourceFile(file) {
|
|
705
694
|
const cacheSf = file;
|
|
706
695
|
if (cacheSf[LocalExportedDeclarations] !== void 0) {
|
|
@@ -792,6 +781,83 @@ function filterToMembersWithDecorator(members, name, module) {
|
|
|
792
781
|
return { member, decorators };
|
|
793
782
|
}).filter((value) => value !== null);
|
|
794
783
|
}
|
|
784
|
+
function extractModifiersOfMember(node) {
|
|
785
|
+
const modifiers = ts5.getModifiers(node);
|
|
786
|
+
let isStatic = false;
|
|
787
|
+
let isReadonly = false;
|
|
788
|
+
let accessLevel = ClassMemberAccessLevel.PublicWritable;
|
|
789
|
+
if (modifiers !== void 0) {
|
|
790
|
+
for (const modifier of modifiers) {
|
|
791
|
+
switch (modifier.kind) {
|
|
792
|
+
case ts5.SyntaxKind.StaticKeyword:
|
|
793
|
+
isStatic = true;
|
|
794
|
+
break;
|
|
795
|
+
case ts5.SyntaxKind.PrivateKeyword:
|
|
796
|
+
accessLevel = ClassMemberAccessLevel.Private;
|
|
797
|
+
break;
|
|
798
|
+
case ts5.SyntaxKind.ProtectedKeyword:
|
|
799
|
+
accessLevel = ClassMemberAccessLevel.Protected;
|
|
800
|
+
break;
|
|
801
|
+
case ts5.SyntaxKind.ReadonlyKeyword:
|
|
802
|
+
isReadonly = true;
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (isReadonly && accessLevel === ClassMemberAccessLevel.PublicWritable) {
|
|
808
|
+
accessLevel = ClassMemberAccessLevel.PublicReadonly;
|
|
809
|
+
}
|
|
810
|
+
if (node.name !== void 0 && ts5.isPrivateIdentifier(node.name)) {
|
|
811
|
+
accessLevel = ClassMemberAccessLevel.EcmaScriptPrivate;
|
|
812
|
+
}
|
|
813
|
+
return { accessLevel, isStatic };
|
|
814
|
+
}
|
|
815
|
+
function reflectClassMember(node) {
|
|
816
|
+
let kind = null;
|
|
817
|
+
let value = null;
|
|
818
|
+
let name = null;
|
|
819
|
+
let nameNode = null;
|
|
820
|
+
if (ts5.isPropertyDeclaration(node)) {
|
|
821
|
+
kind = ClassMemberKind.Property;
|
|
822
|
+
value = node.initializer || null;
|
|
823
|
+
} else if (ts5.isGetAccessorDeclaration(node)) {
|
|
824
|
+
kind = ClassMemberKind.Getter;
|
|
825
|
+
} else if (ts5.isSetAccessorDeclaration(node)) {
|
|
826
|
+
kind = ClassMemberKind.Setter;
|
|
827
|
+
} else if (ts5.isMethodDeclaration(node)) {
|
|
828
|
+
kind = ClassMemberKind.Method;
|
|
829
|
+
} else if (ts5.isConstructorDeclaration(node)) {
|
|
830
|
+
kind = ClassMemberKind.Constructor;
|
|
831
|
+
} else {
|
|
832
|
+
return null;
|
|
833
|
+
}
|
|
834
|
+
if (ts5.isConstructorDeclaration(node)) {
|
|
835
|
+
name = "constructor";
|
|
836
|
+
} else if (ts5.isIdentifier(node.name)) {
|
|
837
|
+
name = node.name.text;
|
|
838
|
+
nameNode = node.name;
|
|
839
|
+
} else if (ts5.isStringLiteral(node.name)) {
|
|
840
|
+
name = node.name.text;
|
|
841
|
+
nameNode = node.name;
|
|
842
|
+
} else if (ts5.isPrivateIdentifier(node.name)) {
|
|
843
|
+
name = node.name.text;
|
|
844
|
+
nameNode = node.name;
|
|
845
|
+
} else {
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
const { accessLevel, isStatic } = extractModifiersOfMember(node);
|
|
849
|
+
return {
|
|
850
|
+
node,
|
|
851
|
+
implementation: node,
|
|
852
|
+
kind,
|
|
853
|
+
type: node.type || null,
|
|
854
|
+
accessLevel,
|
|
855
|
+
name,
|
|
856
|
+
nameNode,
|
|
857
|
+
value,
|
|
858
|
+
isStatic
|
|
859
|
+
};
|
|
860
|
+
}
|
|
795
861
|
function reflectObjectLiteral(node) {
|
|
796
862
|
const map = /* @__PURE__ */ new Map();
|
|
797
863
|
node.properties.forEach((prop) => {
|
|
@@ -1360,9 +1426,6 @@ function normalizeSeparators(path) {
|
|
|
1360
1426
|
|
|
1361
1427
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/core.mjs
|
|
1362
1428
|
var NoopImportRewriter = class {
|
|
1363
|
-
shouldImportSymbol(symbol, specifier) {
|
|
1364
|
-
return true;
|
|
1365
|
-
}
|
|
1366
1429
|
rewriteSymbol(symbol, specifier) {
|
|
1367
1430
|
return symbol;
|
|
1368
1431
|
}
|
|
@@ -1390,9 +1453,6 @@ var R3SymbolsImportRewriter = class {
|
|
|
1390
1453
|
constructor(r3SymbolsPath) {
|
|
1391
1454
|
this.r3SymbolsPath = r3SymbolsPath;
|
|
1392
1455
|
}
|
|
1393
|
-
shouldImportSymbol(symbol, specifier) {
|
|
1394
|
-
return true;
|
|
1395
|
-
}
|
|
1396
1456
|
rewriteSymbol(symbol, specifier) {
|
|
1397
1457
|
if (specifier !== CORE_MODULE) {
|
|
1398
1458
|
return symbol;
|
|
@@ -1636,6 +1696,17 @@ var ImportedSymbolsTracker = class {
|
|
|
1636
1696
|
const namespaces = this.fileToNamespaceImports.get(sourceFile);
|
|
1637
1697
|
return (_b = (_a = namespaces.get(moduleName)) == null ? void 0 : _a.has(node.text)) != null ? _b : false;
|
|
1638
1698
|
}
|
|
1699
|
+
hasNamedImport(sourceFile, exportedName, moduleName) {
|
|
1700
|
+
this.scanImports(sourceFile);
|
|
1701
|
+
const fileImports = this.fileToNamedImports.get(sourceFile);
|
|
1702
|
+
const moduleImports = fileImports.get(moduleName);
|
|
1703
|
+
return moduleImports !== void 0 && moduleImports.has(exportedName);
|
|
1704
|
+
}
|
|
1705
|
+
hasNamespaceImport(sourceFile, moduleName) {
|
|
1706
|
+
this.scanImports(sourceFile);
|
|
1707
|
+
const namespaces = this.fileToNamespaceImports.get(sourceFile);
|
|
1708
|
+
return namespaces.has(moduleName);
|
|
1709
|
+
}
|
|
1639
1710
|
scanImports(sourceFile) {
|
|
1640
1711
|
var _a, _b;
|
|
1641
1712
|
if (this.fileToNamedImports.has(sourceFile) && this.fileToNamespaceImports.has(sourceFile)) {
|
|
@@ -1737,47 +1808,320 @@ var ModuleResolver = class {
|
|
|
1737
1808
|
}
|
|
1738
1809
|
};
|
|
1739
1810
|
|
|
1740
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager.mjs
|
|
1811
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/import_manager.mjs
|
|
1812
|
+
import ts16 from "typescript";
|
|
1813
|
+
|
|
1814
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/check_unique_identifier_name.mjs
|
|
1741
1815
|
import ts12 from "typescript";
|
|
1816
|
+
function createGenerateUniqueIdentifierHelper() {
|
|
1817
|
+
const generatedIdentifiers = /* @__PURE__ */ new Set();
|
|
1818
|
+
return (sourceFile, symbolName) => {
|
|
1819
|
+
const sf = sourceFile;
|
|
1820
|
+
if (sf.identifiers === void 0) {
|
|
1821
|
+
throw new Error("Source file unexpectedly lacks map of parsed `identifiers`.");
|
|
1822
|
+
}
|
|
1823
|
+
const isUniqueIdentifier = (name2) => !sf.identifiers.has(name2) && !generatedIdentifiers.has(name2);
|
|
1824
|
+
if (isUniqueIdentifier(symbolName)) {
|
|
1825
|
+
generatedIdentifiers.add(symbolName);
|
|
1826
|
+
return null;
|
|
1827
|
+
}
|
|
1828
|
+
let name = null;
|
|
1829
|
+
let counter = 1;
|
|
1830
|
+
do {
|
|
1831
|
+
name = `${symbolName}_${counter++}`;
|
|
1832
|
+
} while (!isUniqueIdentifier(name));
|
|
1833
|
+
generatedIdentifiers.add(name);
|
|
1834
|
+
return ts12.factory.createUniqueName(name, ts12.GeneratedIdentifierFlags.Optimistic);
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/import_typescript_transform.mjs
|
|
1839
|
+
import ts13 from "typescript";
|
|
1840
|
+
function createTsTransformForImportManager(manager, extraStatementsForFiles) {
|
|
1841
|
+
return (ctx) => {
|
|
1842
|
+
const { affectedFiles, newImports, updatedImports, reusedOriginalAliasDeclarations } = manager.finalize();
|
|
1843
|
+
if (reusedOriginalAliasDeclarations.size > 0) {
|
|
1844
|
+
const referencedAliasDeclarations = loadIsReferencedAliasDeclarationPatch(ctx);
|
|
1845
|
+
reusedOriginalAliasDeclarations.forEach((aliasDecl) => referencedAliasDeclarations.add(aliasDecl));
|
|
1846
|
+
}
|
|
1847
|
+
if (extraStatementsForFiles !== void 0) {
|
|
1848
|
+
for (const [fileName, statements] of extraStatementsForFiles.entries()) {
|
|
1849
|
+
if (statements.length > 0) {
|
|
1850
|
+
affectedFiles.add(fileName);
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
const visitStatement = (node) => {
|
|
1855
|
+
if (!ts13.isImportDeclaration(node) || node.importClause === void 0 || !ts13.isImportClause(node.importClause)) {
|
|
1856
|
+
return node;
|
|
1857
|
+
}
|
|
1858
|
+
const clause = node.importClause;
|
|
1859
|
+
if (clause.namedBindings === void 0 || !ts13.isNamedImports(clause.namedBindings) || !updatedImports.has(clause.namedBindings)) {
|
|
1860
|
+
return node;
|
|
1861
|
+
}
|
|
1862
|
+
const newClause = ctx.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, updatedImports.get(clause.namedBindings));
|
|
1863
|
+
const newImport = ctx.factory.updateImportDeclaration(node, node.modifiers, newClause, node.moduleSpecifier, node.attributes);
|
|
1864
|
+
ts13.setOriginalNode(newImport, { importClause: newClause, kind: newImport.kind });
|
|
1865
|
+
return newImport;
|
|
1866
|
+
};
|
|
1867
|
+
return (sourceFile) => {
|
|
1868
|
+
var _a, _b;
|
|
1869
|
+
if (!affectedFiles.has(sourceFile.fileName)) {
|
|
1870
|
+
return sourceFile;
|
|
1871
|
+
}
|
|
1872
|
+
sourceFile = ts13.visitEachChild(sourceFile, visitStatement, ctx);
|
|
1873
|
+
const extraStatements = (_a = extraStatementsForFiles == null ? void 0 : extraStatementsForFiles.get(sourceFile.fileName)) != null ? _a : [];
|
|
1874
|
+
const existingImports = [];
|
|
1875
|
+
const body = [];
|
|
1876
|
+
for (const statement of sourceFile.statements) {
|
|
1877
|
+
if (isImportStatement(statement)) {
|
|
1878
|
+
existingImports.push(statement);
|
|
1879
|
+
} else {
|
|
1880
|
+
body.push(statement);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
return ctx.factory.updateSourceFile(sourceFile, [
|
|
1884
|
+
...existingImports,
|
|
1885
|
+
...(_b = newImports.get(sourceFile.fileName)) != null ? _b : [],
|
|
1886
|
+
...extraStatements,
|
|
1887
|
+
...body
|
|
1888
|
+
], sourceFile.isDeclarationFile, sourceFile.referencedFiles, sourceFile.typeReferenceDirectives, sourceFile.hasNoDefaultLib, sourceFile.libReferenceDirectives);
|
|
1889
|
+
};
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
function isImportStatement(stmt) {
|
|
1893
|
+
return ts13.isImportDeclaration(stmt) || ts13.isImportEqualsDeclaration(stmt) || ts13.isNamespaceImport(stmt);
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/reuse_generated_imports.mjs
|
|
1897
|
+
import ts14 from "typescript";
|
|
1898
|
+
function attemptToReuseGeneratedImports(tracker, request) {
|
|
1899
|
+
const requestHash = hashImportRequest(request);
|
|
1900
|
+
const existingExactImport = tracker.directReuseCache.get(requestHash);
|
|
1901
|
+
if (existingExactImport !== void 0) {
|
|
1902
|
+
return existingExactImport;
|
|
1903
|
+
}
|
|
1904
|
+
const potentialNamespaceImport = tracker.namespaceImportReuseCache.get(request.exportModuleSpecifier);
|
|
1905
|
+
if (potentialNamespaceImport === void 0) {
|
|
1906
|
+
return null;
|
|
1907
|
+
}
|
|
1908
|
+
if (request.exportSymbolName === null) {
|
|
1909
|
+
return potentialNamespaceImport;
|
|
1910
|
+
}
|
|
1911
|
+
return [potentialNamespaceImport, ts14.factory.createIdentifier(request.exportSymbolName)];
|
|
1912
|
+
}
|
|
1913
|
+
function captureGeneratedImport(request, tracker, referenceNode) {
|
|
1914
|
+
tracker.directReuseCache.set(hashImportRequest(request), referenceNode);
|
|
1915
|
+
if (request.exportSymbolName === null && !Array.isArray(referenceNode)) {
|
|
1916
|
+
tracker.namespaceImportReuseCache.set(request.exportModuleSpecifier, referenceNode);
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
function hashImportRequest(req) {
|
|
1920
|
+
return `${req.requestedFile.fileName}:${req.exportModuleSpecifier}:${req.exportSymbolName}`;
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/reuse_source_file_imports.mjs
|
|
1924
|
+
import ts15 from "typescript";
|
|
1925
|
+
function attemptToReuseExistingSourceFileImports(tracker, sourceFile, request) {
|
|
1926
|
+
let candidateImportToBeUpdated = null;
|
|
1927
|
+
for (let i = sourceFile.statements.length - 1; i >= 0; i--) {
|
|
1928
|
+
const statement = sourceFile.statements[i];
|
|
1929
|
+
if (!ts15.isImportDeclaration(statement) || !ts15.isStringLiteral(statement.moduleSpecifier)) {
|
|
1930
|
+
continue;
|
|
1931
|
+
}
|
|
1932
|
+
if (!statement.importClause || statement.importClause.isTypeOnly) {
|
|
1933
|
+
continue;
|
|
1934
|
+
}
|
|
1935
|
+
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
1936
|
+
if (moduleSpecifier !== request.exportModuleSpecifier) {
|
|
1937
|
+
continue;
|
|
1938
|
+
}
|
|
1939
|
+
if (statement.importClause.namedBindings) {
|
|
1940
|
+
const namedBindings = statement.importClause.namedBindings;
|
|
1941
|
+
if (ts15.isNamespaceImport(namedBindings)) {
|
|
1942
|
+
tracker.reusedAliasDeclarations.add(namedBindings);
|
|
1943
|
+
if (request.exportSymbolName === null) {
|
|
1944
|
+
return namedBindings.name;
|
|
1945
|
+
}
|
|
1946
|
+
return [namedBindings.name, ts15.factory.createIdentifier(request.exportSymbolName)];
|
|
1947
|
+
}
|
|
1948
|
+
if (ts15.isNamedImports(namedBindings) && request.exportSymbolName !== null) {
|
|
1949
|
+
const existingElement = namedBindings.elements.find((e) => {
|
|
1950
|
+
return !e.isTypeOnly && (e.propertyName ? e.propertyName.text === request.exportSymbolName : e.name.text === request.exportSymbolName);
|
|
1951
|
+
});
|
|
1952
|
+
if (existingElement !== void 0) {
|
|
1953
|
+
tracker.reusedAliasDeclarations.add(existingElement);
|
|
1954
|
+
return existingElement.name;
|
|
1955
|
+
}
|
|
1956
|
+
candidateImportToBeUpdated = statement;
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
if (candidateImportToBeUpdated === null || request.exportSymbolName === null) {
|
|
1961
|
+
return null;
|
|
1962
|
+
}
|
|
1963
|
+
if (!tracker.updatedImports.has(candidateImportToBeUpdated)) {
|
|
1964
|
+
tracker.updatedImports.set(candidateImportToBeUpdated, []);
|
|
1965
|
+
}
|
|
1966
|
+
const symbolsToBeImported = tracker.updatedImports.get(candidateImportToBeUpdated);
|
|
1967
|
+
const propertyName = ts15.factory.createIdentifier(request.exportSymbolName);
|
|
1968
|
+
const fileUniqueAlias = tracker.generateUniqueIdentifier(sourceFile, request.exportSymbolName);
|
|
1969
|
+
symbolsToBeImported.push({
|
|
1970
|
+
propertyName,
|
|
1971
|
+
fileUniqueAlias
|
|
1972
|
+
});
|
|
1973
|
+
return fileUniqueAlias != null ? fileUniqueAlias : propertyName;
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/import_manager.mjs
|
|
1977
|
+
var presetImportManagerForceNamespaceImports = {
|
|
1978
|
+
disableOriginalSourceFileReuse: true,
|
|
1979
|
+
forceGenerateNamespacesForNewImports: true
|
|
1980
|
+
};
|
|
1742
1981
|
var ImportManager = class {
|
|
1743
|
-
constructor(
|
|
1744
|
-
|
|
1745
|
-
this.
|
|
1746
|
-
this.
|
|
1747
|
-
this.
|
|
1748
|
-
this.
|
|
1982
|
+
constructor(_config = {}) {
|
|
1983
|
+
var _a;
|
|
1984
|
+
this._config = _config;
|
|
1985
|
+
this.newImports = /* @__PURE__ */ new Map();
|
|
1986
|
+
this.nextUniqueIndex = 0;
|
|
1987
|
+
this.config = {
|
|
1988
|
+
shouldUseSingleQuotes: () => false,
|
|
1989
|
+
rewriter: null,
|
|
1990
|
+
disableOriginalSourceFileReuse: false,
|
|
1991
|
+
forceGenerateNamespacesForNewImports: false,
|
|
1992
|
+
namespaceImportPrefix: "i",
|
|
1993
|
+
generateUniqueIdentifier: (_a = this._config.generateUniqueIdentifier) != null ? _a : createGenerateUniqueIdentifierHelper(),
|
|
1994
|
+
...this._config
|
|
1995
|
+
};
|
|
1996
|
+
this.reuseSourceFileImportsTracker = {
|
|
1997
|
+
generateUniqueIdentifier: this.config.generateUniqueIdentifier,
|
|
1998
|
+
reusedAliasDeclarations: /* @__PURE__ */ new Set(),
|
|
1999
|
+
updatedImports: /* @__PURE__ */ new Map()
|
|
2000
|
+
};
|
|
2001
|
+
this.reuseGeneratedImportsTracker = {
|
|
2002
|
+
directReuseCache: /* @__PURE__ */ new Map(),
|
|
2003
|
+
namespaceImportReuseCache: /* @__PURE__ */ new Map()
|
|
2004
|
+
};
|
|
1749
2005
|
}
|
|
1750
|
-
|
|
1751
|
-
if (
|
|
1752
|
-
this.
|
|
2006
|
+
addSideEffectImport(requestedFile, moduleSpecifier) {
|
|
2007
|
+
if (this.config.rewriter !== null) {
|
|
2008
|
+
moduleSpecifier = this.config.rewriter.rewriteSpecifier(moduleSpecifier, requestedFile.fileName);
|
|
1753
2009
|
}
|
|
1754
|
-
|
|
2010
|
+
this._getNewImportsTrackerForFile(requestedFile).sideEffectImports.add(moduleSpecifier);
|
|
1755
2011
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
2012
|
+
addImport(request) {
|
|
2013
|
+
if (this.config.rewriter !== null) {
|
|
2014
|
+
if (request.exportSymbolName !== null) {
|
|
2015
|
+
request.exportSymbolName = this.config.rewriter.rewriteSymbol(request.exportSymbolName, request.exportModuleSpecifier);
|
|
2016
|
+
}
|
|
2017
|
+
request.exportModuleSpecifier = this.config.rewriter.rewriteSpecifier(request.exportModuleSpecifier, request.requestedFile.fileName);
|
|
1760
2018
|
}
|
|
1761
|
-
const
|
|
1762
|
-
|
|
2019
|
+
const previousGeneratedImportRef = attemptToReuseGeneratedImports(this.reuseGeneratedImportsTracker, request);
|
|
2020
|
+
if (previousGeneratedImportRef !== null) {
|
|
2021
|
+
return createImportReference(!!request.asTypeReference, previousGeneratedImportRef);
|
|
2022
|
+
}
|
|
2023
|
+
const resultImportRef = this._generateNewImport(request);
|
|
2024
|
+
captureGeneratedImport(request, this.reuseGeneratedImportsTracker, resultImportRef);
|
|
2025
|
+
return createImportReference(!!request.asTypeReference, resultImportRef);
|
|
1763
2026
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
2027
|
+
_generateNewImport(request) {
|
|
2028
|
+
var _a;
|
|
2029
|
+
const { requestedFile: sourceFile } = request;
|
|
2030
|
+
const disableOriginalSourceFileReuse = this.config.disableOriginalSourceFileReuse;
|
|
2031
|
+
const forceGenerateNamespacesForNewImports = this.config.forceGenerateNamespacesForNewImports;
|
|
2032
|
+
if (!disableOriginalSourceFileReuse) {
|
|
2033
|
+
const reuseResult = attemptToReuseExistingSourceFileImports(this.reuseSourceFileImportsTracker, sourceFile, request);
|
|
2034
|
+
if (reuseResult !== null) {
|
|
2035
|
+
return reuseResult;
|
|
2036
|
+
}
|
|
1767
2037
|
}
|
|
2038
|
+
const { namedImports, namespaceImports } = this._getNewImportsTrackerForFile(sourceFile);
|
|
2039
|
+
if (request.exportSymbolName === null || forceGenerateNamespacesForNewImports) {
|
|
2040
|
+
const namespaceImportName = `${this.config.namespaceImportPrefix}${this.nextUniqueIndex++}`;
|
|
2041
|
+
const namespaceImport2 = ts16.factory.createNamespaceImport((_a = this.config.generateUniqueIdentifier(sourceFile, namespaceImportName)) != null ? _a : ts16.factory.createIdentifier(namespaceImportName));
|
|
2042
|
+
namespaceImports.set(request.exportModuleSpecifier, namespaceImport2);
|
|
2043
|
+
captureGeneratedImport({ ...request, exportSymbolName: null }, this.reuseGeneratedImportsTracker, namespaceImport2.name);
|
|
2044
|
+
if (request.exportSymbolName !== null) {
|
|
2045
|
+
return [namespaceImport2.name, ts16.factory.createIdentifier(request.exportSymbolName)];
|
|
2046
|
+
}
|
|
2047
|
+
return namespaceImport2.name;
|
|
2048
|
+
}
|
|
2049
|
+
if (!namedImports.has(request.exportModuleSpecifier)) {
|
|
2050
|
+
namedImports.set(request.exportModuleSpecifier, []);
|
|
2051
|
+
}
|
|
2052
|
+
const exportSymbolName = ts16.factory.createIdentifier(request.exportSymbolName);
|
|
2053
|
+
const fileUniqueName = this.config.generateUniqueIdentifier(sourceFile, request.exportSymbolName);
|
|
2054
|
+
const needsAlias = fileUniqueName !== null;
|
|
2055
|
+
const specifierName = needsAlias ? fileUniqueName : exportSymbolName;
|
|
2056
|
+
namedImports.get(request.exportModuleSpecifier).push(ts16.factory.createImportSpecifier(false, needsAlias ? exportSymbolName : void 0, specifierName));
|
|
2057
|
+
return specifierName;
|
|
2058
|
+
}
|
|
2059
|
+
finalize() {
|
|
2060
|
+
const affectedFiles = /* @__PURE__ */ new Set();
|
|
2061
|
+
const updatedImportsResult = /* @__PURE__ */ new Map();
|
|
2062
|
+
const newImportsResult = /* @__PURE__ */ new Map();
|
|
2063
|
+
const addNewImport = (fileName, importDecl) => {
|
|
2064
|
+
affectedFiles.add(fileName);
|
|
2065
|
+
if (newImportsResult.has(fileName)) {
|
|
2066
|
+
newImportsResult.get(fileName).push(importDecl);
|
|
2067
|
+
} else {
|
|
2068
|
+
newImportsResult.set(fileName, [importDecl]);
|
|
2069
|
+
}
|
|
2070
|
+
};
|
|
2071
|
+
this.reuseSourceFileImportsTracker.updatedImports.forEach((expressions, importDecl) => {
|
|
2072
|
+
const namedBindings = importDecl.importClause.namedBindings;
|
|
2073
|
+
const newNamedBindings = ts16.factory.updateNamedImports(namedBindings, namedBindings.elements.concat(expressions.map(({ propertyName, fileUniqueAlias }) => ts16.factory.createImportSpecifier(false, fileUniqueAlias !== null ? propertyName : void 0, fileUniqueAlias != null ? fileUniqueAlias : propertyName))));
|
|
2074
|
+
affectedFiles.add(importDecl.getSourceFile().fileName);
|
|
2075
|
+
updatedImportsResult.set(namedBindings, newNamedBindings);
|
|
2076
|
+
});
|
|
2077
|
+
this.newImports.forEach(({ namedImports, namespaceImports, sideEffectImports }, sourceFile) => {
|
|
2078
|
+
const useSingleQuotes = this.config.shouldUseSingleQuotes(sourceFile);
|
|
2079
|
+
const fileName = sourceFile.fileName;
|
|
2080
|
+
sideEffectImports.forEach((moduleName) => {
|
|
2081
|
+
addNewImport(fileName, ts16.factory.createImportDeclaration(void 0, void 0, ts16.factory.createStringLiteral(moduleName)));
|
|
2082
|
+
});
|
|
2083
|
+
namespaceImports.forEach((namespaceImport2, moduleName) => {
|
|
2084
|
+
const newImport = ts16.factory.createImportDeclaration(void 0, ts16.factory.createImportClause(false, void 0, namespaceImport2), ts16.factory.createStringLiteral(moduleName, useSingleQuotes));
|
|
2085
|
+
ts16.setOriginalNode(namespaceImport2.name, newImport);
|
|
2086
|
+
addNewImport(fileName, newImport);
|
|
2087
|
+
});
|
|
2088
|
+
namedImports.forEach((specifiers, moduleName) => {
|
|
2089
|
+
const newImport = ts16.factory.createImportDeclaration(void 0, ts16.factory.createImportClause(false, void 0, ts16.factory.createNamedImports(specifiers)), ts16.factory.createStringLiteral(moduleName, useSingleQuotes));
|
|
2090
|
+
addNewImport(fileName, newImport);
|
|
2091
|
+
});
|
|
2092
|
+
});
|
|
2093
|
+
return {
|
|
2094
|
+
affectedFiles,
|
|
2095
|
+
newImports: newImportsResult,
|
|
2096
|
+
updatedImports: updatedImportsResult,
|
|
2097
|
+
reusedOriginalAliasDeclarations: this.reuseSourceFileImportsTracker.reusedAliasDeclarations
|
|
2098
|
+
};
|
|
1768
2099
|
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
2100
|
+
toTsTransform(extraStatementsMap) {
|
|
2101
|
+
return createTsTransformForImportManager(this, extraStatementsMap);
|
|
2102
|
+
}
|
|
2103
|
+
transformTsFile(ctx, file, extraStatementsAfterImports) {
|
|
2104
|
+
const extraStatementsMap = extraStatementsAfterImports ? /* @__PURE__ */ new Map([[file.fileName, extraStatementsAfterImports]]) : void 0;
|
|
2105
|
+
return this.toTsTransform(extraStatementsMap)(ctx)(file);
|
|
2106
|
+
}
|
|
2107
|
+
_getNewImportsTrackerForFile(file) {
|
|
2108
|
+
if (!this.newImports.has(file)) {
|
|
2109
|
+
this.newImports.set(file, {
|
|
2110
|
+
namespaceImports: /* @__PURE__ */ new Map(),
|
|
2111
|
+
namedImports: /* @__PURE__ */ new Map(),
|
|
2112
|
+
sideEffectImports: /* @__PURE__ */ new Set()
|
|
1776
2113
|
});
|
|
1777
2114
|
}
|
|
1778
|
-
return
|
|
2115
|
+
return this.newImports.get(file);
|
|
1779
2116
|
}
|
|
1780
2117
|
};
|
|
2118
|
+
function createImportReference(asTypeReference, ref) {
|
|
2119
|
+
if (asTypeReference) {
|
|
2120
|
+
return Array.isArray(ref) ? ts16.factory.createQualifiedName(ref[0], ref[1]) : ref;
|
|
2121
|
+
} else {
|
|
2122
|
+
return Array.isArray(ref) ? ts16.factory.createPropertyAccessExpression(ref[0], ref[1]) : ref;
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
1781
2125
|
|
|
1782
2126
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/context.mjs
|
|
1783
2127
|
var Context = class {
|
|
@@ -1819,9 +2163,10 @@ var BINARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
|
1819
2163
|
[o.BinaryOperator.NullishCoalesce, "??"]
|
|
1820
2164
|
]);
|
|
1821
2165
|
var ExpressionTranslatorVisitor = class {
|
|
1822
|
-
constructor(factory, imports, options) {
|
|
2166
|
+
constructor(factory, imports, contextFile, options) {
|
|
1823
2167
|
this.factory = factory;
|
|
1824
2168
|
this.imports = imports;
|
|
2169
|
+
this.contextFile = contextFile;
|
|
1825
2170
|
this.downlevelTaggedTemplates = options.downlevelTaggedTemplates === true;
|
|
1826
2171
|
this.downlevelVariableDeclarations = options.downlevelVariableDeclarations === true;
|
|
1827
2172
|
this.recordWrappedNode = options.recordWrappedNode || (() => {
|
|
@@ -1900,8 +2245,11 @@ var ExpressionTranslatorVisitor = class {
|
|
|
1900
2245
|
return this.downlevelTaggedTemplates ? this.createES5TaggedTemplateFunctionCall(tag, template) : this.factory.createTaggedTemplate(tag, template);
|
|
1901
2246
|
}
|
|
1902
2247
|
createES5TaggedTemplateFunctionCall(tagHandler, { elements, expressions }) {
|
|
1903
|
-
const
|
|
1904
|
-
|
|
2248
|
+
const __makeTemplateObjectHelper = this.imports.addImport({
|
|
2249
|
+
exportModuleSpecifier: "tslib",
|
|
2250
|
+
exportSymbolName: "__makeTemplateObject",
|
|
2251
|
+
requestedFile: this.contextFile
|
|
2252
|
+
});
|
|
1905
2253
|
const cooked = [];
|
|
1906
2254
|
const raw = [];
|
|
1907
2255
|
for (const element of elements) {
|
|
@@ -1924,15 +2272,18 @@ var ExpressionTranslatorVisitor = class {
|
|
|
1924
2272
|
if (ast.value.moduleName === null) {
|
|
1925
2273
|
throw new Error("Invalid import without name nor moduleName");
|
|
1926
2274
|
}
|
|
1927
|
-
return this.imports.
|
|
2275
|
+
return this.imports.addImport({
|
|
2276
|
+
exportModuleSpecifier: ast.value.moduleName,
|
|
2277
|
+
exportSymbolName: null,
|
|
2278
|
+
requestedFile: this.contextFile
|
|
2279
|
+
});
|
|
1928
2280
|
}
|
|
1929
2281
|
if (ast.value.moduleName !== null) {
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
}
|
|
2282
|
+
return this.imports.addImport({
|
|
2283
|
+
exportModuleSpecifier: ast.value.moduleName,
|
|
2284
|
+
exportSymbolName: ast.value.name,
|
|
2285
|
+
requestedFile: this.contextFile
|
|
2286
|
+
});
|
|
1936
2287
|
} else {
|
|
1937
2288
|
return this.factory.createIdentifier(ast.value.name);
|
|
1938
2289
|
}
|
|
@@ -2032,7 +2383,7 @@ function createRange(span) {
|
|
|
2032
2383
|
}
|
|
2033
2384
|
|
|
2034
2385
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_emitter.mjs
|
|
2035
|
-
import
|
|
2386
|
+
import ts17 from "typescript";
|
|
2036
2387
|
var INELIGIBLE = {};
|
|
2037
2388
|
function canEmitType(type, canEmit) {
|
|
2038
2389
|
return canEmitTypeWorker(type);
|
|
@@ -2040,13 +2391,13 @@ function canEmitType(type, canEmit) {
|
|
|
2040
2391
|
return visitNode(type2) !== INELIGIBLE;
|
|
2041
2392
|
}
|
|
2042
2393
|
function visitNode(node) {
|
|
2043
|
-
if (
|
|
2394
|
+
if (ts17.isImportTypeNode(node)) {
|
|
2044
2395
|
return INELIGIBLE;
|
|
2045
2396
|
}
|
|
2046
|
-
if (
|
|
2397
|
+
if (ts17.isTypeReferenceNode(node) && !canEmitTypeReference(node)) {
|
|
2047
2398
|
return INELIGIBLE;
|
|
2048
2399
|
} else {
|
|
2049
|
-
return
|
|
2400
|
+
return ts17.forEachChild(node, visitNode);
|
|
2050
2401
|
}
|
|
2051
2402
|
}
|
|
2052
2403
|
function canEmitTypeReference(type2) {
|
|
@@ -2063,35 +2414,35 @@ var TypeEmitter = class {
|
|
|
2063
2414
|
emitType(type) {
|
|
2064
2415
|
const typeReferenceTransformer = (context) => {
|
|
2065
2416
|
const visitNode = (node) => {
|
|
2066
|
-
if (
|
|
2417
|
+
if (ts17.isImportTypeNode(node)) {
|
|
2067
2418
|
throw new Error("Unable to emit import type");
|
|
2068
2419
|
}
|
|
2069
|
-
if (
|
|
2420
|
+
if (ts17.isTypeReferenceNode(node)) {
|
|
2070
2421
|
return this.emitTypeReference(node);
|
|
2071
|
-
} else if (
|
|
2422
|
+
} else if (ts17.isLiteralExpression(node)) {
|
|
2072
2423
|
let clone;
|
|
2073
|
-
if (
|
|
2074
|
-
clone =
|
|
2075
|
-
} else if (
|
|
2076
|
-
clone =
|
|
2077
|
-
} else if (
|
|
2078
|
-
clone =
|
|
2079
|
-
} else if (
|
|
2080
|
-
clone =
|
|
2081
|
-
} else if (
|
|
2082
|
-
clone =
|
|
2424
|
+
if (ts17.isStringLiteral(node)) {
|
|
2425
|
+
clone = ts17.factory.createStringLiteral(node.text);
|
|
2426
|
+
} else if (ts17.isNumericLiteral(node)) {
|
|
2427
|
+
clone = ts17.factory.createNumericLiteral(node.text);
|
|
2428
|
+
} else if (ts17.isBigIntLiteral(node)) {
|
|
2429
|
+
clone = ts17.factory.createBigIntLiteral(node.text);
|
|
2430
|
+
} else if (ts17.isNoSubstitutionTemplateLiteral(node)) {
|
|
2431
|
+
clone = ts17.factory.createNoSubstitutionTemplateLiteral(node.text, node.rawText);
|
|
2432
|
+
} else if (ts17.isRegularExpressionLiteral(node)) {
|
|
2433
|
+
clone = ts17.factory.createRegularExpressionLiteral(node.text);
|
|
2083
2434
|
} else {
|
|
2084
|
-
throw new Error(`Unsupported literal kind ${
|
|
2435
|
+
throw new Error(`Unsupported literal kind ${ts17.SyntaxKind[node.kind]}`);
|
|
2085
2436
|
}
|
|
2086
|
-
|
|
2437
|
+
ts17.setTextRange(clone, { pos: -1, end: -1 });
|
|
2087
2438
|
return clone;
|
|
2088
2439
|
} else {
|
|
2089
|
-
return
|
|
2440
|
+
return ts17.visitEachChild(node, visitNode, context);
|
|
2090
2441
|
}
|
|
2091
2442
|
};
|
|
2092
|
-
return (node) =>
|
|
2443
|
+
return (node) => ts17.visitNode(node, visitNode, ts17.isTypeNode);
|
|
2093
2444
|
};
|
|
2094
|
-
return
|
|
2445
|
+
return ts17.transform(type, [typeReferenceTransformer]).transformed[0];
|
|
2095
2446
|
}
|
|
2096
2447
|
emitTypeReference(type) {
|
|
2097
2448
|
const translatedType = this.translator(type);
|
|
@@ -2100,24 +2451,24 @@ var TypeEmitter = class {
|
|
|
2100
2451
|
}
|
|
2101
2452
|
let typeArguments = void 0;
|
|
2102
2453
|
if (type.typeArguments !== void 0) {
|
|
2103
|
-
typeArguments =
|
|
2454
|
+
typeArguments = ts17.factory.createNodeArray(type.typeArguments.map((typeArg) => this.emitType(typeArg)));
|
|
2104
2455
|
}
|
|
2105
|
-
return
|
|
2456
|
+
return ts17.factory.updateTypeReferenceNode(type, translatedType.typeName, typeArguments);
|
|
2106
2457
|
}
|
|
2107
2458
|
};
|
|
2108
2459
|
|
|
2109
2460
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
|
|
2110
2461
|
import * as o2 from "@angular/compiler";
|
|
2111
|
-
import
|
|
2462
|
+
import ts19 from "typescript";
|
|
2112
2463
|
|
|
2113
2464
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/ts_util.mjs
|
|
2114
|
-
import
|
|
2465
|
+
import ts18 from "typescript";
|
|
2115
2466
|
function tsNumericExpression(value) {
|
|
2116
2467
|
if (value < 0) {
|
|
2117
|
-
const operand =
|
|
2118
|
-
return
|
|
2468
|
+
const operand = ts18.factory.createNumericLiteral(Math.abs(value));
|
|
2469
|
+
return ts18.factory.createPrefixUnaryExpression(ts18.SyntaxKind.MinusToken, operand);
|
|
2119
2470
|
}
|
|
2120
|
-
return
|
|
2471
|
+
return ts18.factory.createNumericLiteral(value);
|
|
2121
2472
|
}
|
|
2122
2473
|
|
|
2123
2474
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
|
|
@@ -2134,16 +2485,16 @@ var TypeTranslatorVisitor = class {
|
|
|
2134
2485
|
visitBuiltinType(type, context) {
|
|
2135
2486
|
switch (type.name) {
|
|
2136
2487
|
case o2.BuiltinTypeName.Bool:
|
|
2137
|
-
return
|
|
2488
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.BooleanKeyword);
|
|
2138
2489
|
case o2.BuiltinTypeName.Dynamic:
|
|
2139
|
-
return
|
|
2490
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.AnyKeyword);
|
|
2140
2491
|
case o2.BuiltinTypeName.Int:
|
|
2141
2492
|
case o2.BuiltinTypeName.Number:
|
|
2142
|
-
return
|
|
2493
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.NumberKeyword);
|
|
2143
2494
|
case o2.BuiltinTypeName.String:
|
|
2144
|
-
return
|
|
2495
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.StringKeyword);
|
|
2145
2496
|
case o2.BuiltinTypeName.None:
|
|
2146
|
-
return
|
|
2497
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.NeverKeyword);
|
|
2147
2498
|
default:
|
|
2148
2499
|
throw new Error(`Unsupported builtin type: ${o2.BuiltinTypeName[type.name]}`);
|
|
2149
2500
|
}
|
|
@@ -2153,26 +2504,26 @@ var TypeTranslatorVisitor = class {
|
|
|
2153
2504
|
if (type.typeParams === null) {
|
|
2154
2505
|
return typeNode;
|
|
2155
2506
|
}
|
|
2156
|
-
if (!
|
|
2507
|
+
if (!ts19.isTypeReferenceNode(typeNode)) {
|
|
2157
2508
|
throw new Error("An ExpressionType with type arguments must translate into a TypeReferenceNode");
|
|
2158
2509
|
} else if (typeNode.typeArguments !== void 0) {
|
|
2159
2510
|
throw new Error(`An ExpressionType with type arguments cannot have multiple levels of type arguments`);
|
|
2160
2511
|
}
|
|
2161
2512
|
const typeArgs = type.typeParams.map((param) => this.translateType(param, context));
|
|
2162
|
-
return
|
|
2513
|
+
return ts19.factory.createTypeReferenceNode(typeNode.typeName, typeArgs);
|
|
2163
2514
|
}
|
|
2164
2515
|
visitArrayType(type, context) {
|
|
2165
|
-
return
|
|
2516
|
+
return ts19.factory.createArrayTypeNode(this.translateType(type.of, context));
|
|
2166
2517
|
}
|
|
2167
2518
|
visitMapType(type, context) {
|
|
2168
|
-
const parameter =
|
|
2169
|
-
const typeArgs = type.valueType !== null ? this.translateType(type.valueType, context) :
|
|
2170
|
-
const indexSignature =
|
|
2171
|
-
return
|
|
2519
|
+
const parameter = ts19.factory.createParameterDeclaration(void 0, void 0, "key", void 0, ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.StringKeyword));
|
|
2520
|
+
const typeArgs = type.valueType !== null ? this.translateType(type.valueType, context) : ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.UnknownKeyword);
|
|
2521
|
+
const indexSignature = ts19.factory.createIndexSignature(void 0, [parameter], typeArgs);
|
|
2522
|
+
return ts19.factory.createTypeLiteralNode([indexSignature]);
|
|
2172
2523
|
}
|
|
2173
2524
|
visitTransplantedType(ast, context) {
|
|
2174
2525
|
const node = ast.type instanceof Reference ? ast.type.node : ast.type;
|
|
2175
|
-
if (!
|
|
2526
|
+
if (!ts19.isTypeNode(node)) {
|
|
2176
2527
|
throw new Error(`A TransplantedType must wrap a TypeNode`);
|
|
2177
2528
|
}
|
|
2178
2529
|
const viaModule = ast.type instanceof Reference ? ast.type.bestGuessOwningModule : null;
|
|
@@ -2183,7 +2534,7 @@ var TypeTranslatorVisitor = class {
|
|
|
2183
2534
|
if (ast.name === null) {
|
|
2184
2535
|
throw new Error(`ReadVarExpr with no variable name in type`);
|
|
2185
2536
|
}
|
|
2186
|
-
return
|
|
2537
|
+
return ts19.factory.createTypeQueryNode(ts19.factory.createIdentifier(ast.name));
|
|
2187
2538
|
}
|
|
2188
2539
|
visitWriteVarExpr(expr, context) {
|
|
2189
2540
|
throw new Error("Method not implemented.");
|
|
@@ -2205,15 +2556,15 @@ var TypeTranslatorVisitor = class {
|
|
|
2205
2556
|
}
|
|
2206
2557
|
visitLiteralExpr(ast, context) {
|
|
2207
2558
|
if (ast.value === null) {
|
|
2208
|
-
return
|
|
2559
|
+
return ts19.factory.createLiteralTypeNode(ts19.factory.createNull());
|
|
2209
2560
|
} else if (ast.value === void 0) {
|
|
2210
|
-
return
|
|
2561
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.UndefinedKeyword);
|
|
2211
2562
|
} else if (typeof ast.value === "boolean") {
|
|
2212
|
-
return
|
|
2563
|
+
return ts19.factory.createLiteralTypeNode(ast.value ? ts19.factory.createTrue() : ts19.factory.createFalse());
|
|
2213
2564
|
} else if (typeof ast.value === "number") {
|
|
2214
|
-
return
|
|
2565
|
+
return ts19.factory.createLiteralTypeNode(tsNumericExpression(ast.value));
|
|
2215
2566
|
} else {
|
|
2216
|
-
return
|
|
2567
|
+
return ts19.factory.createLiteralTypeNode(ts19.factory.createStringLiteral(ast.value));
|
|
2217
2568
|
}
|
|
2218
2569
|
}
|
|
2219
2570
|
visitLocalizedString(ast, context) {
|
|
@@ -2223,11 +2574,14 @@ var TypeTranslatorVisitor = class {
|
|
|
2223
2574
|
if (ast.value.moduleName === null || ast.value.name === null) {
|
|
2224
2575
|
throw new Error(`Import unknown module or symbol`);
|
|
2225
2576
|
}
|
|
2226
|
-
const
|
|
2227
|
-
|
|
2228
|
-
|
|
2577
|
+
const typeName = this.imports.addImport({
|
|
2578
|
+
exportModuleSpecifier: ast.value.moduleName,
|
|
2579
|
+
exportSymbolName: ast.value.name,
|
|
2580
|
+
requestedFile: this.contextFile,
|
|
2581
|
+
asTypeReference: true
|
|
2582
|
+
});
|
|
2229
2583
|
const typeArguments = ast.typeParams !== null ? ast.typeParams.map((type) => this.translateType(type, context)) : void 0;
|
|
2230
|
-
return
|
|
2584
|
+
return ts19.factory.createTypeReferenceNode(typeName, typeArguments);
|
|
2231
2585
|
}
|
|
2232
2586
|
visitConditionalExpr(ast, context) {
|
|
2233
2587
|
throw new Error("Method not implemented.");
|
|
@@ -2258,60 +2612,60 @@ var TypeTranslatorVisitor = class {
|
|
|
2258
2612
|
}
|
|
2259
2613
|
visitLiteralArrayExpr(ast, context) {
|
|
2260
2614
|
const values = ast.entries.map((expr) => this.translateExpression(expr, context));
|
|
2261
|
-
return
|
|
2615
|
+
return ts19.factory.createTupleTypeNode(values);
|
|
2262
2616
|
}
|
|
2263
2617
|
visitLiteralMapExpr(ast, context) {
|
|
2264
2618
|
const entries = ast.entries.map((entry) => {
|
|
2265
2619
|
const { key, quoted } = entry;
|
|
2266
2620
|
const type = this.translateExpression(entry.value, context);
|
|
2267
|
-
return
|
|
2621
|
+
return ts19.factory.createPropertySignature(
|
|
2268
2622
|
void 0,
|
|
2269
|
-
quoted ?
|
|
2623
|
+
quoted ? ts19.factory.createStringLiteral(key) : key,
|
|
2270
2624
|
void 0,
|
|
2271
2625
|
type
|
|
2272
2626
|
);
|
|
2273
2627
|
});
|
|
2274
|
-
return
|
|
2628
|
+
return ts19.factory.createTypeLiteralNode(entries);
|
|
2275
2629
|
}
|
|
2276
2630
|
visitCommaExpr(ast, context) {
|
|
2277
2631
|
throw new Error("Method not implemented.");
|
|
2278
2632
|
}
|
|
2279
2633
|
visitWrappedNodeExpr(ast, context) {
|
|
2280
2634
|
const node = ast.node;
|
|
2281
|
-
if (
|
|
2282
|
-
return
|
|
2283
|
-
} else if (
|
|
2635
|
+
if (ts19.isEntityName(node)) {
|
|
2636
|
+
return ts19.factory.createTypeReferenceNode(node, void 0);
|
|
2637
|
+
} else if (ts19.isTypeNode(node)) {
|
|
2284
2638
|
return node;
|
|
2285
|
-
} else if (
|
|
2286
|
-
return
|
|
2639
|
+
} else if (ts19.isLiteralExpression(node)) {
|
|
2640
|
+
return ts19.factory.createLiteralTypeNode(node);
|
|
2287
2641
|
} else {
|
|
2288
|
-
throw new Error(`Unsupported WrappedNodeExpr in TypeTranslatorVisitor: ${
|
|
2642
|
+
throw new Error(`Unsupported WrappedNodeExpr in TypeTranslatorVisitor: ${ts19.SyntaxKind[node.kind]}`);
|
|
2289
2643
|
}
|
|
2290
2644
|
}
|
|
2291
2645
|
visitTypeofExpr(ast, context) {
|
|
2292
2646
|
const typeNode = this.translateExpression(ast.expr, context);
|
|
2293
|
-
if (!
|
|
2647
|
+
if (!ts19.isTypeReferenceNode(typeNode)) {
|
|
2294
2648
|
throw new Error(`The target of a typeof expression must be a type reference, but it was
|
|
2295
|
-
${
|
|
2649
|
+
${ts19.SyntaxKind[typeNode.kind]}`);
|
|
2296
2650
|
}
|
|
2297
|
-
return
|
|
2651
|
+
return ts19.factory.createTypeQueryNode(typeNode.typeName);
|
|
2298
2652
|
}
|
|
2299
2653
|
translateType(type, context) {
|
|
2300
2654
|
const typeNode = type.visitType(this, context);
|
|
2301
|
-
if (!
|
|
2302
|
-
throw new Error(`A Type must translate to a TypeNode, but was ${
|
|
2655
|
+
if (!ts19.isTypeNode(typeNode)) {
|
|
2656
|
+
throw new Error(`A Type must translate to a TypeNode, but was ${ts19.SyntaxKind[typeNode.kind]}`);
|
|
2303
2657
|
}
|
|
2304
2658
|
return typeNode;
|
|
2305
2659
|
}
|
|
2306
2660
|
translateExpression(expr, context) {
|
|
2307
2661
|
const typeNode = expr.visitExpression(this, context);
|
|
2308
|
-
if (!
|
|
2309
|
-
throw new Error(`An Expression must translate to a TypeNode, but was ${
|
|
2662
|
+
if (!ts19.isTypeNode(typeNode)) {
|
|
2663
|
+
throw new Error(`An Expression must translate to a TypeNode, but was ${ts19.SyntaxKind[typeNode.kind]}`);
|
|
2310
2664
|
}
|
|
2311
2665
|
return typeNode;
|
|
2312
2666
|
}
|
|
2313
2667
|
translateTypeReference(type, context, viaModule) {
|
|
2314
|
-
const target =
|
|
2668
|
+
const target = ts19.isIdentifier(type.typeName) ? type.typeName : type.typeName.right;
|
|
2315
2669
|
const declaration = this.reflector.getDeclarationOfIdentifier(target);
|
|
2316
2670
|
if (declaration === null) {
|
|
2317
2671
|
throw new Error(`Unable to statically determine the declaration file of type node ${target.text}`);
|
|
@@ -2327,79 +2681,79 @@ var TypeTranslatorVisitor = class {
|
|
|
2327
2681
|
const emittedType = this.refEmitter.emit(reference, this.contextFile, ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowAmbientReferences);
|
|
2328
2682
|
assertSuccessfulReferenceEmit(emittedType, target, "type");
|
|
2329
2683
|
const typeNode = this.translateExpression(emittedType.expression, context);
|
|
2330
|
-
if (!
|
|
2331
|
-
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${
|
|
2684
|
+
if (!ts19.isTypeReferenceNode(typeNode)) {
|
|
2685
|
+
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${ts19.SyntaxKind[typeNode.kind]}.`);
|
|
2332
2686
|
}
|
|
2333
2687
|
return typeNode;
|
|
2334
2688
|
}
|
|
2335
2689
|
};
|
|
2336
2690
|
|
|
2337
2691
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.mjs
|
|
2338
|
-
import
|
|
2692
|
+
import ts20 from "typescript";
|
|
2339
2693
|
var PureAnnotation;
|
|
2340
2694
|
(function(PureAnnotation2) {
|
|
2341
2695
|
PureAnnotation2["CLOSURE"] = "* @pureOrBreakMyCode ";
|
|
2342
2696
|
PureAnnotation2["TERSER"] = "@__PURE__";
|
|
2343
2697
|
})(PureAnnotation || (PureAnnotation = {}));
|
|
2344
2698
|
var UNARY_OPERATORS2 = {
|
|
2345
|
-
"+":
|
|
2346
|
-
"-":
|
|
2347
|
-
"!":
|
|
2699
|
+
"+": ts20.SyntaxKind.PlusToken,
|
|
2700
|
+
"-": ts20.SyntaxKind.MinusToken,
|
|
2701
|
+
"!": ts20.SyntaxKind.ExclamationToken
|
|
2348
2702
|
};
|
|
2349
2703
|
var BINARY_OPERATORS2 = {
|
|
2350
|
-
"&&":
|
|
2351
|
-
">":
|
|
2352
|
-
">=":
|
|
2353
|
-
"&":
|
|
2354
|
-
"|":
|
|
2355
|
-
"/":
|
|
2356
|
-
"==":
|
|
2357
|
-
"===":
|
|
2358
|
-
"<":
|
|
2359
|
-
"<=":
|
|
2360
|
-
"-":
|
|
2361
|
-
"%":
|
|
2362
|
-
"*":
|
|
2363
|
-
"!=":
|
|
2364
|
-
"!==":
|
|
2365
|
-
"||":
|
|
2366
|
-
"+":
|
|
2367
|
-
"??":
|
|
2704
|
+
"&&": ts20.SyntaxKind.AmpersandAmpersandToken,
|
|
2705
|
+
">": ts20.SyntaxKind.GreaterThanToken,
|
|
2706
|
+
">=": ts20.SyntaxKind.GreaterThanEqualsToken,
|
|
2707
|
+
"&": ts20.SyntaxKind.AmpersandToken,
|
|
2708
|
+
"|": ts20.SyntaxKind.BarToken,
|
|
2709
|
+
"/": ts20.SyntaxKind.SlashToken,
|
|
2710
|
+
"==": ts20.SyntaxKind.EqualsEqualsToken,
|
|
2711
|
+
"===": ts20.SyntaxKind.EqualsEqualsEqualsToken,
|
|
2712
|
+
"<": ts20.SyntaxKind.LessThanToken,
|
|
2713
|
+
"<=": ts20.SyntaxKind.LessThanEqualsToken,
|
|
2714
|
+
"-": ts20.SyntaxKind.MinusToken,
|
|
2715
|
+
"%": ts20.SyntaxKind.PercentToken,
|
|
2716
|
+
"*": ts20.SyntaxKind.AsteriskToken,
|
|
2717
|
+
"!=": ts20.SyntaxKind.ExclamationEqualsToken,
|
|
2718
|
+
"!==": ts20.SyntaxKind.ExclamationEqualsEqualsToken,
|
|
2719
|
+
"||": ts20.SyntaxKind.BarBarToken,
|
|
2720
|
+
"+": ts20.SyntaxKind.PlusToken,
|
|
2721
|
+
"??": ts20.SyntaxKind.QuestionQuestionToken
|
|
2368
2722
|
};
|
|
2369
2723
|
var VAR_TYPES = {
|
|
2370
|
-
"const":
|
|
2371
|
-
"let":
|
|
2372
|
-
"var":
|
|
2724
|
+
"const": ts20.NodeFlags.Const,
|
|
2725
|
+
"let": ts20.NodeFlags.Let,
|
|
2726
|
+
"var": ts20.NodeFlags.None
|
|
2373
2727
|
};
|
|
2374
2728
|
var TypeScriptAstFactory = class {
|
|
2375
2729
|
constructor(annotateForClosureCompiler) {
|
|
2376
2730
|
this.annotateForClosureCompiler = annotateForClosureCompiler;
|
|
2377
2731
|
this.externalSourceFiles = /* @__PURE__ */ new Map();
|
|
2378
2732
|
this.attachComments = attachComments;
|
|
2379
|
-
this.createArrayLiteral =
|
|
2380
|
-
this.createElementAccess =
|
|
2381
|
-
this.createExpressionStatement =
|
|
2382
|
-
this.createIdentifier =
|
|
2383
|
-
this.createParenthesizedExpression =
|
|
2384
|
-
this.createPropertyAccess =
|
|
2385
|
-
this.createThrowStatement =
|
|
2386
|
-
this.createTypeOfExpression =
|
|
2733
|
+
this.createArrayLiteral = ts20.factory.createArrayLiteralExpression;
|
|
2734
|
+
this.createElementAccess = ts20.factory.createElementAccessExpression;
|
|
2735
|
+
this.createExpressionStatement = ts20.factory.createExpressionStatement;
|
|
2736
|
+
this.createIdentifier = ts20.factory.createIdentifier;
|
|
2737
|
+
this.createParenthesizedExpression = ts20.factory.createParenthesizedExpression;
|
|
2738
|
+
this.createPropertyAccess = ts20.factory.createPropertyAccessExpression;
|
|
2739
|
+
this.createThrowStatement = ts20.factory.createThrowStatement;
|
|
2740
|
+
this.createTypeOfExpression = ts20.factory.createTypeOfExpression;
|
|
2387
2741
|
}
|
|
2388
2742
|
createAssignment(target, value) {
|
|
2389
|
-
return
|
|
2743
|
+
return ts20.factory.createBinaryExpression(target, ts20.SyntaxKind.EqualsToken, value);
|
|
2390
2744
|
}
|
|
2391
2745
|
createBinaryExpression(leftOperand, operator, rightOperand) {
|
|
2392
|
-
return
|
|
2746
|
+
return ts20.factory.createBinaryExpression(leftOperand, BINARY_OPERATORS2[operator], rightOperand);
|
|
2393
2747
|
}
|
|
2394
2748
|
createBlock(body) {
|
|
2395
|
-
return
|
|
2749
|
+
return ts20.factory.createBlock(body);
|
|
2396
2750
|
}
|
|
2397
2751
|
createCallExpression(callee, args, pure) {
|
|
2398
|
-
const call =
|
|
2752
|
+
const call = ts20.factory.createCallExpression(callee, void 0, args);
|
|
2399
2753
|
if (pure) {
|
|
2400
|
-
|
|
2754
|
+
ts20.addSyntheticLeadingComment(
|
|
2401
2755
|
call,
|
|
2402
|
-
|
|
2756
|
+
ts20.SyntaxKind.MultiLineCommentTrivia,
|
|
2403
2757
|
this.annotateForClosureCompiler ? PureAnnotation.CLOSURE : PureAnnotation.TERSER,
|
|
2404
2758
|
false
|
|
2405
2759
|
);
|
|
@@ -2407,64 +2761,64 @@ var TypeScriptAstFactory = class {
|
|
|
2407
2761
|
return call;
|
|
2408
2762
|
}
|
|
2409
2763
|
createConditional(condition, whenTrue, whenFalse) {
|
|
2410
|
-
return
|
|
2764
|
+
return ts20.factory.createConditionalExpression(condition, void 0, whenTrue, void 0, whenFalse);
|
|
2411
2765
|
}
|
|
2412
2766
|
createDynamicImport(url) {
|
|
2413
|
-
return
|
|
2414
|
-
|
|
2767
|
+
return ts20.factory.createCallExpression(
|
|
2768
|
+
ts20.factory.createToken(ts20.SyntaxKind.ImportKeyword),
|
|
2415
2769
|
void 0,
|
|
2416
|
-
[
|
|
2770
|
+
[ts20.factory.createStringLiteral(url)]
|
|
2417
2771
|
);
|
|
2418
2772
|
}
|
|
2419
2773
|
createFunctionDeclaration(functionName, parameters, body) {
|
|
2420
|
-
if (!
|
|
2421
|
-
throw new Error(`Invalid syntax, expected a block, but got ${
|
|
2774
|
+
if (!ts20.isBlock(body)) {
|
|
2775
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts20.SyntaxKind[body.kind]}.`);
|
|
2422
2776
|
}
|
|
2423
|
-
return
|
|
2777
|
+
return ts20.factory.createFunctionDeclaration(void 0, void 0, functionName, void 0, parameters.map((param) => ts20.factory.createParameterDeclaration(void 0, void 0, param)), void 0, body);
|
|
2424
2778
|
}
|
|
2425
2779
|
createFunctionExpression(functionName, parameters, body) {
|
|
2426
|
-
if (!
|
|
2427
|
-
throw new Error(`Invalid syntax, expected a block, but got ${
|
|
2780
|
+
if (!ts20.isBlock(body)) {
|
|
2781
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts20.SyntaxKind[body.kind]}.`);
|
|
2428
2782
|
}
|
|
2429
|
-
return
|
|
2783
|
+
return ts20.factory.createFunctionExpression(void 0, void 0, functionName != null ? functionName : void 0, void 0, parameters.map((param) => ts20.factory.createParameterDeclaration(void 0, void 0, param)), void 0, body);
|
|
2430
2784
|
}
|
|
2431
2785
|
createArrowFunctionExpression(parameters, body) {
|
|
2432
|
-
if (
|
|
2433
|
-
throw new Error(`Invalid syntax, expected a block, but got ${
|
|
2786
|
+
if (ts20.isStatement(body) && !ts20.isBlock(body)) {
|
|
2787
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts20.SyntaxKind[body.kind]}.`);
|
|
2434
2788
|
}
|
|
2435
|
-
return
|
|
2789
|
+
return ts20.factory.createArrowFunction(void 0, void 0, parameters.map((param) => ts20.factory.createParameterDeclaration(void 0, void 0, param)), void 0, void 0, body);
|
|
2436
2790
|
}
|
|
2437
2791
|
createIfStatement(condition, thenStatement, elseStatement) {
|
|
2438
|
-
return
|
|
2792
|
+
return ts20.factory.createIfStatement(condition, thenStatement, elseStatement != null ? elseStatement : void 0);
|
|
2439
2793
|
}
|
|
2440
2794
|
createLiteral(value) {
|
|
2441
2795
|
if (value === void 0) {
|
|
2442
|
-
return
|
|
2796
|
+
return ts20.factory.createIdentifier("undefined");
|
|
2443
2797
|
} else if (value === null) {
|
|
2444
|
-
return
|
|
2798
|
+
return ts20.factory.createNull();
|
|
2445
2799
|
} else if (typeof value === "boolean") {
|
|
2446
|
-
return value ?
|
|
2800
|
+
return value ? ts20.factory.createTrue() : ts20.factory.createFalse();
|
|
2447
2801
|
} else if (typeof value === "number") {
|
|
2448
2802
|
return tsNumericExpression(value);
|
|
2449
2803
|
} else {
|
|
2450
|
-
return
|
|
2804
|
+
return ts20.factory.createStringLiteral(value);
|
|
2451
2805
|
}
|
|
2452
2806
|
}
|
|
2453
2807
|
createNewExpression(expression, args) {
|
|
2454
|
-
return
|
|
2808
|
+
return ts20.factory.createNewExpression(expression, void 0, args);
|
|
2455
2809
|
}
|
|
2456
2810
|
createObjectLiteral(properties) {
|
|
2457
|
-
return
|
|
2811
|
+
return ts20.factory.createObjectLiteralExpression(properties.map((prop) => ts20.factory.createPropertyAssignment(prop.quoted ? ts20.factory.createStringLiteral(prop.propertyName) : ts20.factory.createIdentifier(prop.propertyName), prop.value)));
|
|
2458
2812
|
}
|
|
2459
2813
|
createReturnStatement(expression) {
|
|
2460
|
-
return
|
|
2814
|
+
return ts20.factory.createReturnStatement(expression != null ? expression : void 0);
|
|
2461
2815
|
}
|
|
2462
2816
|
createTaggedTemplate(tag, template) {
|
|
2463
2817
|
let templateLiteral;
|
|
2464
2818
|
const length = template.elements.length;
|
|
2465
2819
|
const head = template.elements[0];
|
|
2466
2820
|
if (length === 1) {
|
|
2467
|
-
templateLiteral =
|
|
2821
|
+
templateLiteral = ts20.factory.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
|
|
2468
2822
|
} else {
|
|
2469
2823
|
const spans = [];
|
|
2470
2824
|
for (let i = 1; i < length - 1; i++) {
|
|
@@ -2473,7 +2827,7 @@ var TypeScriptAstFactory = class {
|
|
|
2473
2827
|
if (range !== null) {
|
|
2474
2828
|
this.setSourceMapRange(middle, range);
|
|
2475
2829
|
}
|
|
2476
|
-
spans.push(
|
|
2830
|
+
spans.push(ts20.factory.createTemplateSpan(template.expressions[i - 1], middle));
|
|
2477
2831
|
}
|
|
2478
2832
|
const resolvedExpression = template.expressions[length - 2];
|
|
2479
2833
|
const templatePart = template.elements[length - 1];
|
|
@@ -2481,19 +2835,19 @@ var TypeScriptAstFactory = class {
|
|
|
2481
2835
|
if (templatePart.range !== null) {
|
|
2482
2836
|
this.setSourceMapRange(templateTail, templatePart.range);
|
|
2483
2837
|
}
|
|
2484
|
-
spans.push(
|
|
2485
|
-
templateLiteral =
|
|
2838
|
+
spans.push(ts20.factory.createTemplateSpan(resolvedExpression, templateTail));
|
|
2839
|
+
templateLiteral = ts20.factory.createTemplateExpression(ts20.factory.createTemplateHead(head.cooked, head.raw), spans);
|
|
2486
2840
|
}
|
|
2487
2841
|
if (head.range !== null) {
|
|
2488
2842
|
this.setSourceMapRange(templateLiteral, head.range);
|
|
2489
2843
|
}
|
|
2490
|
-
return
|
|
2844
|
+
return ts20.factory.createTaggedTemplateExpression(tag, void 0, templateLiteral);
|
|
2491
2845
|
}
|
|
2492
2846
|
createUnaryExpression(operator, operand) {
|
|
2493
|
-
return
|
|
2847
|
+
return ts20.factory.createPrefixUnaryExpression(UNARY_OPERATORS2[operator], operand);
|
|
2494
2848
|
}
|
|
2495
2849
|
createVariableDeclaration(variableName, initializer, type) {
|
|
2496
|
-
return
|
|
2850
|
+
return ts20.factory.createVariableStatement(void 0, ts20.factory.createVariableDeclarationList([ts20.factory.createVariableDeclaration(variableName, void 0, void 0, initializer != null ? initializer : void 0)], VAR_TYPES[type]));
|
|
2497
2851
|
}
|
|
2498
2852
|
setSourceMapRange(node, sourceMapRange) {
|
|
2499
2853
|
if (sourceMapRange === null) {
|
|
@@ -2501,42 +2855,42 @@ var TypeScriptAstFactory = class {
|
|
|
2501
2855
|
}
|
|
2502
2856
|
const url = sourceMapRange.url;
|
|
2503
2857
|
if (!this.externalSourceFiles.has(url)) {
|
|
2504
|
-
this.externalSourceFiles.set(url,
|
|
2858
|
+
this.externalSourceFiles.set(url, ts20.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
|
|
2505
2859
|
}
|
|
2506
2860
|
const source = this.externalSourceFiles.get(url);
|
|
2507
|
-
|
|
2861
|
+
ts20.setSourceMapRange(node, { pos: sourceMapRange.start.offset, end: sourceMapRange.end.offset, source });
|
|
2508
2862
|
return node;
|
|
2509
2863
|
}
|
|
2510
2864
|
};
|
|
2511
2865
|
function createTemplateMiddle(cooked, raw) {
|
|
2512
|
-
const node =
|
|
2513
|
-
node.kind =
|
|
2866
|
+
const node = ts20.factory.createTemplateHead(cooked, raw);
|
|
2867
|
+
node.kind = ts20.SyntaxKind.TemplateMiddle;
|
|
2514
2868
|
return node;
|
|
2515
2869
|
}
|
|
2516
2870
|
function createTemplateTail(cooked, raw) {
|
|
2517
|
-
const node =
|
|
2518
|
-
node.kind =
|
|
2871
|
+
const node = ts20.factory.createTemplateHead(cooked, raw);
|
|
2872
|
+
node.kind = ts20.SyntaxKind.TemplateTail;
|
|
2519
2873
|
return node;
|
|
2520
2874
|
}
|
|
2521
2875
|
function attachComments(statement, leadingComments) {
|
|
2522
2876
|
for (const comment of leadingComments) {
|
|
2523
|
-
const commentKind = comment.multiline ?
|
|
2877
|
+
const commentKind = comment.multiline ? ts20.SyntaxKind.MultiLineCommentTrivia : ts20.SyntaxKind.SingleLineCommentTrivia;
|
|
2524
2878
|
if (comment.multiline) {
|
|
2525
|
-
|
|
2879
|
+
ts20.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
|
|
2526
2880
|
} else {
|
|
2527
2881
|
for (const line of comment.toString().split("\n")) {
|
|
2528
|
-
|
|
2882
|
+
ts20.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
|
|
2529
2883
|
}
|
|
2530
2884
|
}
|
|
2531
2885
|
}
|
|
2532
2886
|
}
|
|
2533
2887
|
|
|
2534
2888
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_translator.mjs
|
|
2535
|
-
function translateExpression(expression, imports, options = {}) {
|
|
2536
|
-
return expression.visitExpression(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(false));
|
|
2889
|
+
function translateExpression(contextFile, expression, imports, options = {}) {
|
|
2890
|
+
return expression.visitExpression(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, contextFile, options), new Context(false));
|
|
2537
2891
|
}
|
|
2538
|
-
function translateStatement(statement, imports, options = {}) {
|
|
2539
|
-
return statement.visitStatement(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(true));
|
|
2892
|
+
function translateStatement(contextFile, statement, imports, options = {}) {
|
|
2893
|
+
return statement.visitStatement(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, contextFile, options), new Context(true));
|
|
2540
2894
|
}
|
|
2541
2895
|
|
|
2542
2896
|
export {
|
|
@@ -2588,13 +2942,16 @@ export {
|
|
|
2588
2942
|
getDefaultImportDeclaration,
|
|
2589
2943
|
DefaultImportTracker,
|
|
2590
2944
|
ClassMemberKind,
|
|
2945
|
+
ClassMemberAccessLevel,
|
|
2591
2946
|
AmbientImport,
|
|
2592
2947
|
typeNodeToValueExpr,
|
|
2593
2948
|
entityNameToValue,
|
|
2594
2949
|
isNamedClassDeclaration,
|
|
2950
|
+
classMemberAccessLevelToString,
|
|
2595
2951
|
TypeScriptReflectionHost,
|
|
2596
2952
|
reflectTypeEntityToDeclaration,
|
|
2597
2953
|
filterToMembersWithDecorator,
|
|
2954
|
+
reflectClassMember,
|
|
2598
2955
|
reflectObjectLiteral,
|
|
2599
2956
|
DeferredSymbolTracker,
|
|
2600
2957
|
ImportedSymbolsTracker,
|
|
@@ -2602,6 +2959,7 @@ export {
|
|
|
2602
2959
|
Reference,
|
|
2603
2960
|
ModuleResolver,
|
|
2604
2961
|
Context,
|
|
2962
|
+
presetImportManagerForceNamespaceImports,
|
|
2605
2963
|
ImportManager,
|
|
2606
2964
|
ExpressionTranslatorVisitor,
|
|
2607
2965
|
canEmitType,
|
|
@@ -2624,4 +2982,4 @@ export {
|
|
|
2624
2982
|
* Use of this source code is governed by an MIT-style license that can be
|
|
2625
2983
|
* found in the LICENSE file at https://angular.io/license
|
|
2626
2984
|
*/
|
|
2627
|
-
//# sourceMappingURL=chunk-
|
|
2985
|
+
//# sourceMappingURL=chunk-NPXXJQN4.js.map
|