@angular/compiler-cli 18.0.0-next.0 → 18.0.0-next.1
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-SQY7XLGB.js → chunk-ALDR4XSX.js} +1107 -57
- package/bundles/chunk-ALDR4XSX.js.map +6 -0
- package/bundles/{chunk-4A7ZWBEL.js → chunk-AWB4ZG2D.js} +24 -24
- package/bundles/chunk-AWB4ZG2D.js.map +6 -0
- package/bundles/{chunk-64VF23SF.js → chunk-B454JZVO.js} +2 -2
- package/bundles/{chunk-NB6ZWAGP.js → chunk-C4L7A7U3.js} +16 -16
- package/bundles/chunk-C4L7A7U3.js.map +6 -0
- package/bundles/{chunk-6X7GQ6BQ.js → chunk-GGJA4IFT.js} +475 -197
- package/bundles/chunk-GGJA4IFT.js.map +6 -0
- package/bundles/{chunk-A46CQFUG.js → chunk-OHOBDHII.js} +174 -217
- package/bundles/chunk-OHOBDHII.js.map +6 -0
- package/bundles/index.js +5 -5
- package/bundles/linker/babel/index.js +2 -2
- 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/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 +3 -3
- package/src/ngtsc/core/src/core_version.d.ts +11 -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/patch_alias_reference_resolution.d.ts +3 -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/reference_emit_environment.d.ts +1 -1
- package/src/ngtsc/typecheck/src/ts_util.d.ts +0 -2
- package/src/transformers/jit_transforms/initializer_api_transforms/transform_api.d.ts +1 -1
- package/bundles/chunk-4A7ZWBEL.js.map +0 -6
- 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-B454JZVO.js.map} +0 -0
|
@@ -1360,9 +1360,6 @@ function normalizeSeparators(path) {
|
|
|
1360
1360
|
|
|
1361
1361
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/imports/src/core.mjs
|
|
1362
1362
|
var NoopImportRewriter = class {
|
|
1363
|
-
shouldImportSymbol(symbol, specifier) {
|
|
1364
|
-
return true;
|
|
1365
|
-
}
|
|
1366
1363
|
rewriteSymbol(symbol, specifier) {
|
|
1367
1364
|
return symbol;
|
|
1368
1365
|
}
|
|
@@ -1390,9 +1387,6 @@ var R3SymbolsImportRewriter = class {
|
|
|
1390
1387
|
constructor(r3SymbolsPath) {
|
|
1391
1388
|
this.r3SymbolsPath = r3SymbolsPath;
|
|
1392
1389
|
}
|
|
1393
|
-
shouldImportSymbol(symbol, specifier) {
|
|
1394
|
-
return true;
|
|
1395
|
-
}
|
|
1396
1390
|
rewriteSymbol(symbol, specifier) {
|
|
1397
1391
|
if (specifier !== CORE_MODULE) {
|
|
1398
1392
|
return symbol;
|
|
@@ -1737,47 +1731,320 @@ var ModuleResolver = class {
|
|
|
1737
1731
|
}
|
|
1738
1732
|
};
|
|
1739
1733
|
|
|
1740
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager.mjs
|
|
1734
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/import_manager.mjs
|
|
1735
|
+
import ts16 from "typescript";
|
|
1736
|
+
|
|
1737
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/check_unique_identifier_name.mjs
|
|
1741
1738
|
import ts12 from "typescript";
|
|
1739
|
+
function createGenerateUniqueIdentifierHelper() {
|
|
1740
|
+
const generatedIdentifiers = /* @__PURE__ */ new Set();
|
|
1741
|
+
return (sourceFile, symbolName) => {
|
|
1742
|
+
const sf = sourceFile;
|
|
1743
|
+
if (sf.identifiers === void 0) {
|
|
1744
|
+
throw new Error("Source file unexpectedly lacks map of parsed `identifiers`.");
|
|
1745
|
+
}
|
|
1746
|
+
const isUniqueIdentifier = (name2) => !sf.identifiers.has(name2) && !generatedIdentifiers.has(name2);
|
|
1747
|
+
if (isUniqueIdentifier(symbolName)) {
|
|
1748
|
+
generatedIdentifiers.add(symbolName);
|
|
1749
|
+
return null;
|
|
1750
|
+
}
|
|
1751
|
+
let name = null;
|
|
1752
|
+
let counter = 1;
|
|
1753
|
+
do {
|
|
1754
|
+
name = `${symbolName}_${counter++}`;
|
|
1755
|
+
} while (!isUniqueIdentifier(name));
|
|
1756
|
+
generatedIdentifiers.add(name);
|
|
1757
|
+
return ts12.factory.createUniqueName(name, ts12.GeneratedIdentifierFlags.Optimistic);
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/import_typescript_transform.mjs
|
|
1762
|
+
import ts13 from "typescript";
|
|
1763
|
+
function createTsTransformForImportManager(manager, extraStatementsForFiles) {
|
|
1764
|
+
return (ctx) => {
|
|
1765
|
+
const { affectedFiles, newImports, updatedImports, reusedOriginalAliasDeclarations } = manager.finalize();
|
|
1766
|
+
if (reusedOriginalAliasDeclarations.size > 0) {
|
|
1767
|
+
const referencedAliasDeclarations = loadIsReferencedAliasDeclarationPatch(ctx);
|
|
1768
|
+
reusedOriginalAliasDeclarations.forEach((aliasDecl) => referencedAliasDeclarations.add(aliasDecl));
|
|
1769
|
+
}
|
|
1770
|
+
if (extraStatementsForFiles !== void 0) {
|
|
1771
|
+
for (const [fileName, statements] of extraStatementsForFiles.entries()) {
|
|
1772
|
+
if (statements.length > 0) {
|
|
1773
|
+
affectedFiles.add(fileName);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
const visitStatement = (node) => {
|
|
1778
|
+
if (!ts13.isImportDeclaration(node) || node.importClause === void 0 || !ts13.isImportClause(node.importClause)) {
|
|
1779
|
+
return node;
|
|
1780
|
+
}
|
|
1781
|
+
const clause = node.importClause;
|
|
1782
|
+
if (clause.namedBindings === void 0 || !ts13.isNamedImports(clause.namedBindings) || !updatedImports.has(clause.namedBindings)) {
|
|
1783
|
+
return node;
|
|
1784
|
+
}
|
|
1785
|
+
const newClause = ctx.factory.updateImportClause(clause, clause.isTypeOnly, clause.name, updatedImports.get(clause.namedBindings));
|
|
1786
|
+
const newImport = ctx.factory.updateImportDeclaration(node, node.modifiers, newClause, node.moduleSpecifier, node.attributes);
|
|
1787
|
+
ts13.setOriginalNode(newImport, { importClause: newClause, kind: newImport.kind });
|
|
1788
|
+
return newImport;
|
|
1789
|
+
};
|
|
1790
|
+
return (sourceFile) => {
|
|
1791
|
+
var _a, _b;
|
|
1792
|
+
if (!affectedFiles.has(sourceFile.fileName)) {
|
|
1793
|
+
return sourceFile;
|
|
1794
|
+
}
|
|
1795
|
+
sourceFile = ts13.visitEachChild(sourceFile, visitStatement, ctx);
|
|
1796
|
+
const extraStatements = (_a = extraStatementsForFiles == null ? void 0 : extraStatementsForFiles.get(sourceFile.fileName)) != null ? _a : [];
|
|
1797
|
+
const existingImports = [];
|
|
1798
|
+
const body = [];
|
|
1799
|
+
for (const statement of sourceFile.statements) {
|
|
1800
|
+
if (isImportStatement(statement)) {
|
|
1801
|
+
existingImports.push(statement);
|
|
1802
|
+
} else {
|
|
1803
|
+
body.push(statement);
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
return ctx.factory.updateSourceFile(sourceFile, [
|
|
1807
|
+
...existingImports,
|
|
1808
|
+
...(_b = newImports.get(sourceFile.fileName)) != null ? _b : [],
|
|
1809
|
+
...extraStatements,
|
|
1810
|
+
...body
|
|
1811
|
+
], sourceFile.isDeclarationFile, sourceFile.referencedFiles, sourceFile.typeReferenceDirectives, sourceFile.hasNoDefaultLib, sourceFile.libReferenceDirectives);
|
|
1812
|
+
};
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
function isImportStatement(stmt) {
|
|
1816
|
+
return ts13.isImportDeclaration(stmt) || ts13.isImportEqualsDeclaration(stmt) || ts13.isNamespaceImport(stmt);
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/reuse_generated_imports.mjs
|
|
1820
|
+
import ts14 from "typescript";
|
|
1821
|
+
function attemptToReuseGeneratedImports(tracker, request) {
|
|
1822
|
+
const requestHash = hashImportRequest(request);
|
|
1823
|
+
const existingExactImport = tracker.directReuseCache.get(requestHash);
|
|
1824
|
+
if (existingExactImport !== void 0) {
|
|
1825
|
+
return existingExactImport;
|
|
1826
|
+
}
|
|
1827
|
+
const potentialNamespaceImport = tracker.namespaceImportReuseCache.get(request.exportModuleSpecifier);
|
|
1828
|
+
if (potentialNamespaceImport === void 0) {
|
|
1829
|
+
return null;
|
|
1830
|
+
}
|
|
1831
|
+
if (request.exportSymbolName === null) {
|
|
1832
|
+
return potentialNamespaceImport;
|
|
1833
|
+
}
|
|
1834
|
+
return [potentialNamespaceImport, ts14.factory.createIdentifier(request.exportSymbolName)];
|
|
1835
|
+
}
|
|
1836
|
+
function captureGeneratedImport(request, tracker, referenceNode) {
|
|
1837
|
+
tracker.directReuseCache.set(hashImportRequest(request), referenceNode);
|
|
1838
|
+
if (request.exportSymbolName === null && !Array.isArray(referenceNode)) {
|
|
1839
|
+
tracker.namespaceImportReuseCache.set(request.exportModuleSpecifier, referenceNode);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
function hashImportRequest(req) {
|
|
1843
|
+
return `${req.requestedFile.fileName}:${req.exportModuleSpecifier}:${req.exportSymbolName}`;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/reuse_source_file_imports.mjs
|
|
1847
|
+
import ts15 from "typescript";
|
|
1848
|
+
function attemptToReuseExistingSourceFileImports(tracker, sourceFile, request) {
|
|
1849
|
+
let candidateImportToBeUpdated = null;
|
|
1850
|
+
for (let i = sourceFile.statements.length - 1; i >= 0; i--) {
|
|
1851
|
+
const statement = sourceFile.statements[i];
|
|
1852
|
+
if (!ts15.isImportDeclaration(statement) || !ts15.isStringLiteral(statement.moduleSpecifier)) {
|
|
1853
|
+
continue;
|
|
1854
|
+
}
|
|
1855
|
+
if (!statement.importClause || statement.importClause.isTypeOnly) {
|
|
1856
|
+
continue;
|
|
1857
|
+
}
|
|
1858
|
+
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
1859
|
+
if (moduleSpecifier !== request.exportModuleSpecifier) {
|
|
1860
|
+
continue;
|
|
1861
|
+
}
|
|
1862
|
+
if (statement.importClause.namedBindings) {
|
|
1863
|
+
const namedBindings = statement.importClause.namedBindings;
|
|
1864
|
+
if (ts15.isNamespaceImport(namedBindings)) {
|
|
1865
|
+
tracker.reusedAliasDeclarations.add(namedBindings);
|
|
1866
|
+
if (request.exportSymbolName === null) {
|
|
1867
|
+
return namedBindings.name;
|
|
1868
|
+
}
|
|
1869
|
+
return [namedBindings.name, ts15.factory.createIdentifier(request.exportSymbolName)];
|
|
1870
|
+
}
|
|
1871
|
+
if (ts15.isNamedImports(namedBindings) && request.exportSymbolName !== null) {
|
|
1872
|
+
const existingElement = namedBindings.elements.find((e) => {
|
|
1873
|
+
return !e.isTypeOnly && (e.propertyName ? e.propertyName.text === request.exportSymbolName : e.name.text === request.exportSymbolName);
|
|
1874
|
+
});
|
|
1875
|
+
if (existingElement !== void 0) {
|
|
1876
|
+
tracker.reusedAliasDeclarations.add(existingElement);
|
|
1877
|
+
return existingElement.name;
|
|
1878
|
+
}
|
|
1879
|
+
candidateImportToBeUpdated = statement;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
if (candidateImportToBeUpdated === null || request.exportSymbolName === null) {
|
|
1884
|
+
return null;
|
|
1885
|
+
}
|
|
1886
|
+
if (!tracker.updatedImports.has(candidateImportToBeUpdated)) {
|
|
1887
|
+
tracker.updatedImports.set(candidateImportToBeUpdated, []);
|
|
1888
|
+
}
|
|
1889
|
+
const symbolsToBeImported = tracker.updatedImports.get(candidateImportToBeUpdated);
|
|
1890
|
+
const propertyName = ts15.factory.createIdentifier(request.exportSymbolName);
|
|
1891
|
+
const fileUniqueAlias = tracker.generateUniqueIdentifier(sourceFile, request.exportSymbolName);
|
|
1892
|
+
symbolsToBeImported.push({
|
|
1893
|
+
propertyName,
|
|
1894
|
+
fileUniqueAlias
|
|
1895
|
+
});
|
|
1896
|
+
return fileUniqueAlias != null ? fileUniqueAlias : propertyName;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager/import_manager.mjs
|
|
1900
|
+
var presetImportManagerForceNamespaceImports = {
|
|
1901
|
+
disableOriginalSourceFileReuse: true,
|
|
1902
|
+
forceGenerateNamespacesForNewImports: true
|
|
1903
|
+
};
|
|
1742
1904
|
var ImportManager = class {
|
|
1743
|
-
constructor(
|
|
1744
|
-
|
|
1745
|
-
this.
|
|
1746
|
-
this.
|
|
1747
|
-
this.
|
|
1748
|
-
this.
|
|
1905
|
+
constructor(_config = {}) {
|
|
1906
|
+
var _a;
|
|
1907
|
+
this._config = _config;
|
|
1908
|
+
this.newImports = /* @__PURE__ */ new Map();
|
|
1909
|
+
this.nextUniqueIndex = 0;
|
|
1910
|
+
this.config = {
|
|
1911
|
+
shouldUseSingleQuotes: () => false,
|
|
1912
|
+
rewriter: null,
|
|
1913
|
+
disableOriginalSourceFileReuse: false,
|
|
1914
|
+
forceGenerateNamespacesForNewImports: false,
|
|
1915
|
+
namespaceImportPrefix: "i",
|
|
1916
|
+
generateUniqueIdentifier: (_a = this._config.generateUniqueIdentifier) != null ? _a : createGenerateUniqueIdentifierHelper(),
|
|
1917
|
+
...this._config
|
|
1918
|
+
};
|
|
1919
|
+
this.reuseSourceFileImportsTracker = {
|
|
1920
|
+
generateUniqueIdentifier: this.config.generateUniqueIdentifier,
|
|
1921
|
+
reusedAliasDeclarations: /* @__PURE__ */ new Set(),
|
|
1922
|
+
updatedImports: /* @__PURE__ */ new Map()
|
|
1923
|
+
};
|
|
1924
|
+
this.reuseGeneratedImportsTracker = {
|
|
1925
|
+
directReuseCache: /* @__PURE__ */ new Map(),
|
|
1926
|
+
namespaceImportReuseCache: /* @__PURE__ */ new Map()
|
|
1927
|
+
};
|
|
1749
1928
|
}
|
|
1750
|
-
|
|
1751
|
-
if (
|
|
1752
|
-
this.
|
|
1929
|
+
addSideEffectImport(requestedFile, moduleSpecifier) {
|
|
1930
|
+
if (this.config.rewriter !== null) {
|
|
1931
|
+
moduleSpecifier = this.config.rewriter.rewriteSpecifier(moduleSpecifier, requestedFile.fileName);
|
|
1753
1932
|
}
|
|
1754
|
-
|
|
1933
|
+
this._getNewImportsTrackerForFile(requestedFile).sideEffectImports.add(moduleSpecifier);
|
|
1755
1934
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1935
|
+
addImport(request) {
|
|
1936
|
+
if (this.config.rewriter !== null) {
|
|
1937
|
+
if (request.exportSymbolName !== null) {
|
|
1938
|
+
request.exportSymbolName = this.config.rewriter.rewriteSymbol(request.exportSymbolName, request.exportModuleSpecifier);
|
|
1939
|
+
}
|
|
1940
|
+
request.exportModuleSpecifier = this.config.rewriter.rewriteSpecifier(request.exportModuleSpecifier, request.requestedFile.fileName);
|
|
1941
|
+
}
|
|
1942
|
+
const previousGeneratedImportRef = attemptToReuseGeneratedImports(this.reuseGeneratedImportsTracker, request);
|
|
1943
|
+
if (previousGeneratedImportRef !== null) {
|
|
1944
|
+
return createImportReference(!!request.asTypeReference, previousGeneratedImportRef);
|
|
1760
1945
|
}
|
|
1761
|
-
const
|
|
1762
|
-
|
|
1946
|
+
const resultImportRef = this._generateNewImport(request);
|
|
1947
|
+
captureGeneratedImport(request, this.reuseGeneratedImportsTracker, resultImportRef);
|
|
1948
|
+
return createImportReference(!!request.asTypeReference, resultImportRef);
|
|
1763
1949
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1950
|
+
_generateNewImport(request) {
|
|
1951
|
+
var _a;
|
|
1952
|
+
const { requestedFile: sourceFile } = request;
|
|
1953
|
+
const disableOriginalSourceFileReuse = this.config.disableOriginalSourceFileReuse;
|
|
1954
|
+
const forceGenerateNamespacesForNewImports = this.config.forceGenerateNamespacesForNewImports;
|
|
1955
|
+
if (!disableOriginalSourceFileReuse) {
|
|
1956
|
+
const reuseResult = attemptToReuseExistingSourceFileImports(this.reuseSourceFileImportsTracker, sourceFile, request);
|
|
1957
|
+
if (reuseResult !== null) {
|
|
1958
|
+
return reuseResult;
|
|
1959
|
+
}
|
|
1767
1960
|
}
|
|
1961
|
+
const { namedImports, namespaceImports } = this._getNewImportsTrackerForFile(sourceFile);
|
|
1962
|
+
if (request.exportSymbolName === null || forceGenerateNamespacesForNewImports) {
|
|
1963
|
+
const namespaceImportName = `${this.config.namespaceImportPrefix}${this.nextUniqueIndex++}`;
|
|
1964
|
+
const namespaceImport2 = ts16.factory.createNamespaceImport((_a = this.config.generateUniqueIdentifier(sourceFile, namespaceImportName)) != null ? _a : ts16.factory.createIdentifier(namespaceImportName));
|
|
1965
|
+
namespaceImports.set(request.exportModuleSpecifier, namespaceImport2);
|
|
1966
|
+
captureGeneratedImport({ ...request, exportSymbolName: null }, this.reuseGeneratedImportsTracker, namespaceImport2.name);
|
|
1967
|
+
if (request.exportSymbolName !== null) {
|
|
1968
|
+
return [namespaceImport2.name, ts16.factory.createIdentifier(request.exportSymbolName)];
|
|
1969
|
+
}
|
|
1970
|
+
return namespaceImport2.name;
|
|
1971
|
+
}
|
|
1972
|
+
if (!namedImports.has(request.exportModuleSpecifier)) {
|
|
1973
|
+
namedImports.set(request.exportModuleSpecifier, []);
|
|
1974
|
+
}
|
|
1975
|
+
const exportSymbolName = ts16.factory.createIdentifier(request.exportSymbolName);
|
|
1976
|
+
const fileUniqueName = this.config.generateUniqueIdentifier(sourceFile, request.exportSymbolName);
|
|
1977
|
+
const needsAlias = fileUniqueName !== null;
|
|
1978
|
+
const specifierName = needsAlias ? fileUniqueName : exportSymbolName;
|
|
1979
|
+
namedImports.get(request.exportModuleSpecifier).push(ts16.factory.createImportSpecifier(false, needsAlias ? exportSymbolName : void 0, specifierName));
|
|
1980
|
+
return specifierName;
|
|
1981
|
+
}
|
|
1982
|
+
finalize() {
|
|
1983
|
+
const affectedFiles = /* @__PURE__ */ new Set();
|
|
1984
|
+
const updatedImportsResult = /* @__PURE__ */ new Map();
|
|
1985
|
+
const newImportsResult = /* @__PURE__ */ new Map();
|
|
1986
|
+
const addNewImport = (fileName, importDecl) => {
|
|
1987
|
+
affectedFiles.add(fileName);
|
|
1988
|
+
if (newImportsResult.has(fileName)) {
|
|
1989
|
+
newImportsResult.get(fileName).push(importDecl);
|
|
1990
|
+
} else {
|
|
1991
|
+
newImportsResult.set(fileName, [importDecl]);
|
|
1992
|
+
}
|
|
1993
|
+
};
|
|
1994
|
+
this.reuseSourceFileImportsTracker.updatedImports.forEach((expressions, importDecl) => {
|
|
1995
|
+
const namedBindings = importDecl.importClause.namedBindings;
|
|
1996
|
+
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))));
|
|
1997
|
+
affectedFiles.add(importDecl.getSourceFile().fileName);
|
|
1998
|
+
updatedImportsResult.set(namedBindings, newNamedBindings);
|
|
1999
|
+
});
|
|
2000
|
+
this.newImports.forEach(({ namedImports, namespaceImports, sideEffectImports }, sourceFile) => {
|
|
2001
|
+
const useSingleQuotes = this.config.shouldUseSingleQuotes(sourceFile);
|
|
2002
|
+
const fileName = sourceFile.fileName;
|
|
2003
|
+
sideEffectImports.forEach((moduleName) => {
|
|
2004
|
+
addNewImport(fileName, ts16.factory.createImportDeclaration(void 0, void 0, ts16.factory.createStringLiteral(moduleName)));
|
|
2005
|
+
});
|
|
2006
|
+
namespaceImports.forEach((namespaceImport2, moduleName) => {
|
|
2007
|
+
const newImport = ts16.factory.createImportDeclaration(void 0, ts16.factory.createImportClause(false, void 0, namespaceImport2), ts16.factory.createStringLiteral(moduleName, useSingleQuotes));
|
|
2008
|
+
ts16.setOriginalNode(namespaceImport2.name, newImport);
|
|
2009
|
+
addNewImport(fileName, newImport);
|
|
2010
|
+
});
|
|
2011
|
+
namedImports.forEach((specifiers, moduleName) => {
|
|
2012
|
+
const newImport = ts16.factory.createImportDeclaration(void 0, ts16.factory.createImportClause(false, void 0, ts16.factory.createNamedImports(specifiers)), ts16.factory.createStringLiteral(moduleName, useSingleQuotes));
|
|
2013
|
+
addNewImport(fileName, newImport);
|
|
2014
|
+
});
|
|
2015
|
+
});
|
|
2016
|
+
return {
|
|
2017
|
+
affectedFiles,
|
|
2018
|
+
newImports: newImportsResult,
|
|
2019
|
+
updatedImports: updatedImportsResult,
|
|
2020
|
+
reusedOriginalAliasDeclarations: this.reuseSourceFileImportsTracker.reusedAliasDeclarations
|
|
2021
|
+
};
|
|
2022
|
+
}
|
|
2023
|
+
toTsTransform(extraStatementsMap) {
|
|
2024
|
+
return createTsTransformForImportManager(this, extraStatementsMap);
|
|
2025
|
+
}
|
|
2026
|
+
transformTsFile(ctx, file, extraStatementsAfterImports) {
|
|
2027
|
+
const extraStatementsMap = extraStatementsAfterImports ? /* @__PURE__ */ new Map([[file.fileName, extraStatementsAfterImports]]) : void 0;
|
|
2028
|
+
return this.toTsTransform(extraStatementsMap)(ctx)(file);
|
|
1768
2029
|
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
qualifier
|
|
2030
|
+
_getNewImportsTrackerForFile(file) {
|
|
2031
|
+
if (!this.newImports.has(file)) {
|
|
2032
|
+
this.newImports.set(file, {
|
|
2033
|
+
namespaceImports: /* @__PURE__ */ new Map(),
|
|
2034
|
+
namedImports: /* @__PURE__ */ new Map(),
|
|
2035
|
+
sideEffectImports: /* @__PURE__ */ new Set()
|
|
1776
2036
|
});
|
|
1777
2037
|
}
|
|
1778
|
-
return
|
|
2038
|
+
return this.newImports.get(file);
|
|
1779
2039
|
}
|
|
1780
2040
|
};
|
|
2041
|
+
function createImportReference(asTypeReference, ref) {
|
|
2042
|
+
if (asTypeReference) {
|
|
2043
|
+
return Array.isArray(ref) ? ts16.factory.createQualifiedName(ref[0], ref[1]) : ref;
|
|
2044
|
+
} else {
|
|
2045
|
+
return Array.isArray(ref) ? ts16.factory.createPropertyAccessExpression(ref[0], ref[1]) : ref;
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
1781
2048
|
|
|
1782
2049
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/context.mjs
|
|
1783
2050
|
var Context = class {
|
|
@@ -1819,9 +2086,10 @@ var BINARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
|
1819
2086
|
[o.BinaryOperator.NullishCoalesce, "??"]
|
|
1820
2087
|
]);
|
|
1821
2088
|
var ExpressionTranslatorVisitor = class {
|
|
1822
|
-
constructor(factory, imports, options) {
|
|
2089
|
+
constructor(factory, imports, contextFile, options) {
|
|
1823
2090
|
this.factory = factory;
|
|
1824
2091
|
this.imports = imports;
|
|
2092
|
+
this.contextFile = contextFile;
|
|
1825
2093
|
this.downlevelTaggedTemplates = options.downlevelTaggedTemplates === true;
|
|
1826
2094
|
this.downlevelVariableDeclarations = options.downlevelVariableDeclarations === true;
|
|
1827
2095
|
this.recordWrappedNode = options.recordWrappedNode || (() => {
|
|
@@ -1900,8 +2168,11 @@ var ExpressionTranslatorVisitor = class {
|
|
|
1900
2168
|
return this.downlevelTaggedTemplates ? this.createES5TaggedTemplateFunctionCall(tag, template) : this.factory.createTaggedTemplate(tag, template);
|
|
1901
2169
|
}
|
|
1902
2170
|
createES5TaggedTemplateFunctionCall(tagHandler, { elements, expressions }) {
|
|
1903
|
-
const
|
|
1904
|
-
|
|
2171
|
+
const __makeTemplateObjectHelper = this.imports.addImport({
|
|
2172
|
+
exportModuleSpecifier: "tslib",
|
|
2173
|
+
exportSymbolName: "__makeTemplateObject",
|
|
2174
|
+
requestedFile: this.contextFile
|
|
2175
|
+
});
|
|
1905
2176
|
const cooked = [];
|
|
1906
2177
|
const raw = [];
|
|
1907
2178
|
for (const element of elements) {
|
|
@@ -1924,15 +2195,18 @@ var ExpressionTranslatorVisitor = class {
|
|
|
1924
2195
|
if (ast.value.moduleName === null) {
|
|
1925
2196
|
throw new Error("Invalid import without name nor moduleName");
|
|
1926
2197
|
}
|
|
1927
|
-
return this.imports.
|
|
2198
|
+
return this.imports.addImport({
|
|
2199
|
+
exportModuleSpecifier: ast.value.moduleName,
|
|
2200
|
+
exportSymbolName: null,
|
|
2201
|
+
requestedFile: this.contextFile
|
|
2202
|
+
});
|
|
1928
2203
|
}
|
|
1929
2204
|
if (ast.value.moduleName !== null) {
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
}
|
|
2205
|
+
return this.imports.addImport({
|
|
2206
|
+
exportModuleSpecifier: ast.value.moduleName,
|
|
2207
|
+
exportSymbolName: ast.value.name,
|
|
2208
|
+
requestedFile: this.contextFile
|
|
2209
|
+
});
|
|
1936
2210
|
} else {
|
|
1937
2211
|
return this.factory.createIdentifier(ast.value.name);
|
|
1938
2212
|
}
|
|
@@ -2032,7 +2306,7 @@ function createRange(span) {
|
|
|
2032
2306
|
}
|
|
2033
2307
|
|
|
2034
2308
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_emitter.mjs
|
|
2035
|
-
import
|
|
2309
|
+
import ts17 from "typescript";
|
|
2036
2310
|
var INELIGIBLE = {};
|
|
2037
2311
|
function canEmitType(type, canEmit) {
|
|
2038
2312
|
return canEmitTypeWorker(type);
|
|
@@ -2040,13 +2314,13 @@ function canEmitType(type, canEmit) {
|
|
|
2040
2314
|
return visitNode(type2) !== INELIGIBLE;
|
|
2041
2315
|
}
|
|
2042
2316
|
function visitNode(node) {
|
|
2043
|
-
if (
|
|
2317
|
+
if (ts17.isImportTypeNode(node)) {
|
|
2044
2318
|
return INELIGIBLE;
|
|
2045
2319
|
}
|
|
2046
|
-
if (
|
|
2320
|
+
if (ts17.isTypeReferenceNode(node) && !canEmitTypeReference(node)) {
|
|
2047
2321
|
return INELIGIBLE;
|
|
2048
2322
|
} else {
|
|
2049
|
-
return
|
|
2323
|
+
return ts17.forEachChild(node, visitNode);
|
|
2050
2324
|
}
|
|
2051
2325
|
}
|
|
2052
2326
|
function canEmitTypeReference(type2) {
|
|
@@ -2063,35 +2337,35 @@ var TypeEmitter = class {
|
|
|
2063
2337
|
emitType(type) {
|
|
2064
2338
|
const typeReferenceTransformer = (context) => {
|
|
2065
2339
|
const visitNode = (node) => {
|
|
2066
|
-
if (
|
|
2340
|
+
if (ts17.isImportTypeNode(node)) {
|
|
2067
2341
|
throw new Error("Unable to emit import type");
|
|
2068
2342
|
}
|
|
2069
|
-
if (
|
|
2343
|
+
if (ts17.isTypeReferenceNode(node)) {
|
|
2070
2344
|
return this.emitTypeReference(node);
|
|
2071
|
-
} else if (
|
|
2345
|
+
} else if (ts17.isLiteralExpression(node)) {
|
|
2072
2346
|
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 =
|
|
2347
|
+
if (ts17.isStringLiteral(node)) {
|
|
2348
|
+
clone = ts17.factory.createStringLiteral(node.text);
|
|
2349
|
+
} else if (ts17.isNumericLiteral(node)) {
|
|
2350
|
+
clone = ts17.factory.createNumericLiteral(node.text);
|
|
2351
|
+
} else if (ts17.isBigIntLiteral(node)) {
|
|
2352
|
+
clone = ts17.factory.createBigIntLiteral(node.text);
|
|
2353
|
+
} else if (ts17.isNoSubstitutionTemplateLiteral(node)) {
|
|
2354
|
+
clone = ts17.factory.createNoSubstitutionTemplateLiteral(node.text, node.rawText);
|
|
2355
|
+
} else if (ts17.isRegularExpressionLiteral(node)) {
|
|
2356
|
+
clone = ts17.factory.createRegularExpressionLiteral(node.text);
|
|
2083
2357
|
} else {
|
|
2084
|
-
throw new Error(`Unsupported literal kind ${
|
|
2358
|
+
throw new Error(`Unsupported literal kind ${ts17.SyntaxKind[node.kind]}`);
|
|
2085
2359
|
}
|
|
2086
|
-
|
|
2360
|
+
ts17.setTextRange(clone, { pos: -1, end: -1 });
|
|
2087
2361
|
return clone;
|
|
2088
2362
|
} else {
|
|
2089
|
-
return
|
|
2363
|
+
return ts17.visitEachChild(node, visitNode, context);
|
|
2090
2364
|
}
|
|
2091
2365
|
};
|
|
2092
|
-
return (node) =>
|
|
2366
|
+
return (node) => ts17.visitNode(node, visitNode, ts17.isTypeNode);
|
|
2093
2367
|
};
|
|
2094
|
-
return
|
|
2368
|
+
return ts17.transform(type, [typeReferenceTransformer]).transformed[0];
|
|
2095
2369
|
}
|
|
2096
2370
|
emitTypeReference(type) {
|
|
2097
2371
|
const translatedType = this.translator(type);
|
|
@@ -2100,24 +2374,24 @@ var TypeEmitter = class {
|
|
|
2100
2374
|
}
|
|
2101
2375
|
let typeArguments = void 0;
|
|
2102
2376
|
if (type.typeArguments !== void 0) {
|
|
2103
|
-
typeArguments =
|
|
2377
|
+
typeArguments = ts17.factory.createNodeArray(type.typeArguments.map((typeArg) => this.emitType(typeArg)));
|
|
2104
2378
|
}
|
|
2105
|
-
return
|
|
2379
|
+
return ts17.factory.updateTypeReferenceNode(type, translatedType.typeName, typeArguments);
|
|
2106
2380
|
}
|
|
2107
2381
|
};
|
|
2108
2382
|
|
|
2109
2383
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
|
|
2110
2384
|
import * as o2 from "@angular/compiler";
|
|
2111
|
-
import
|
|
2385
|
+
import ts19 from "typescript";
|
|
2112
2386
|
|
|
2113
2387
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/ts_util.mjs
|
|
2114
|
-
import
|
|
2388
|
+
import ts18 from "typescript";
|
|
2115
2389
|
function tsNumericExpression(value) {
|
|
2116
2390
|
if (value < 0) {
|
|
2117
|
-
const operand =
|
|
2118
|
-
return
|
|
2391
|
+
const operand = ts18.factory.createNumericLiteral(Math.abs(value));
|
|
2392
|
+
return ts18.factory.createPrefixUnaryExpression(ts18.SyntaxKind.MinusToken, operand);
|
|
2119
2393
|
}
|
|
2120
|
-
return
|
|
2394
|
+
return ts18.factory.createNumericLiteral(value);
|
|
2121
2395
|
}
|
|
2122
2396
|
|
|
2123
2397
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
|
|
@@ -2134,16 +2408,16 @@ var TypeTranslatorVisitor = class {
|
|
|
2134
2408
|
visitBuiltinType(type, context) {
|
|
2135
2409
|
switch (type.name) {
|
|
2136
2410
|
case o2.BuiltinTypeName.Bool:
|
|
2137
|
-
return
|
|
2411
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.BooleanKeyword);
|
|
2138
2412
|
case o2.BuiltinTypeName.Dynamic:
|
|
2139
|
-
return
|
|
2413
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.AnyKeyword);
|
|
2140
2414
|
case o2.BuiltinTypeName.Int:
|
|
2141
2415
|
case o2.BuiltinTypeName.Number:
|
|
2142
|
-
return
|
|
2416
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.NumberKeyword);
|
|
2143
2417
|
case o2.BuiltinTypeName.String:
|
|
2144
|
-
return
|
|
2418
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.StringKeyword);
|
|
2145
2419
|
case o2.BuiltinTypeName.None:
|
|
2146
|
-
return
|
|
2420
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.NeverKeyword);
|
|
2147
2421
|
default:
|
|
2148
2422
|
throw new Error(`Unsupported builtin type: ${o2.BuiltinTypeName[type.name]}`);
|
|
2149
2423
|
}
|
|
@@ -2153,26 +2427,26 @@ var TypeTranslatorVisitor = class {
|
|
|
2153
2427
|
if (type.typeParams === null) {
|
|
2154
2428
|
return typeNode;
|
|
2155
2429
|
}
|
|
2156
|
-
if (!
|
|
2430
|
+
if (!ts19.isTypeReferenceNode(typeNode)) {
|
|
2157
2431
|
throw new Error("An ExpressionType with type arguments must translate into a TypeReferenceNode");
|
|
2158
2432
|
} else if (typeNode.typeArguments !== void 0) {
|
|
2159
2433
|
throw new Error(`An ExpressionType with type arguments cannot have multiple levels of type arguments`);
|
|
2160
2434
|
}
|
|
2161
2435
|
const typeArgs = type.typeParams.map((param) => this.translateType(param, context));
|
|
2162
|
-
return
|
|
2436
|
+
return ts19.factory.createTypeReferenceNode(typeNode.typeName, typeArgs);
|
|
2163
2437
|
}
|
|
2164
2438
|
visitArrayType(type, context) {
|
|
2165
|
-
return
|
|
2439
|
+
return ts19.factory.createArrayTypeNode(this.translateType(type.of, context));
|
|
2166
2440
|
}
|
|
2167
2441
|
visitMapType(type, context) {
|
|
2168
|
-
const parameter =
|
|
2169
|
-
const typeArgs = type.valueType !== null ? this.translateType(type.valueType, context) :
|
|
2170
|
-
const indexSignature =
|
|
2171
|
-
return
|
|
2442
|
+
const parameter = ts19.factory.createParameterDeclaration(void 0, void 0, "key", void 0, ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.StringKeyword));
|
|
2443
|
+
const typeArgs = type.valueType !== null ? this.translateType(type.valueType, context) : ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.UnknownKeyword);
|
|
2444
|
+
const indexSignature = ts19.factory.createIndexSignature(void 0, [parameter], typeArgs);
|
|
2445
|
+
return ts19.factory.createTypeLiteralNode([indexSignature]);
|
|
2172
2446
|
}
|
|
2173
2447
|
visitTransplantedType(ast, context) {
|
|
2174
2448
|
const node = ast.type instanceof Reference ? ast.type.node : ast.type;
|
|
2175
|
-
if (!
|
|
2449
|
+
if (!ts19.isTypeNode(node)) {
|
|
2176
2450
|
throw new Error(`A TransplantedType must wrap a TypeNode`);
|
|
2177
2451
|
}
|
|
2178
2452
|
const viaModule = ast.type instanceof Reference ? ast.type.bestGuessOwningModule : null;
|
|
@@ -2183,7 +2457,7 @@ var TypeTranslatorVisitor = class {
|
|
|
2183
2457
|
if (ast.name === null) {
|
|
2184
2458
|
throw new Error(`ReadVarExpr with no variable name in type`);
|
|
2185
2459
|
}
|
|
2186
|
-
return
|
|
2460
|
+
return ts19.factory.createTypeQueryNode(ts19.factory.createIdentifier(ast.name));
|
|
2187
2461
|
}
|
|
2188
2462
|
visitWriteVarExpr(expr, context) {
|
|
2189
2463
|
throw new Error("Method not implemented.");
|
|
@@ -2205,15 +2479,15 @@ var TypeTranslatorVisitor = class {
|
|
|
2205
2479
|
}
|
|
2206
2480
|
visitLiteralExpr(ast, context) {
|
|
2207
2481
|
if (ast.value === null) {
|
|
2208
|
-
return
|
|
2482
|
+
return ts19.factory.createLiteralTypeNode(ts19.factory.createNull());
|
|
2209
2483
|
} else if (ast.value === void 0) {
|
|
2210
|
-
return
|
|
2484
|
+
return ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.UndefinedKeyword);
|
|
2211
2485
|
} else if (typeof ast.value === "boolean") {
|
|
2212
|
-
return
|
|
2486
|
+
return ts19.factory.createLiteralTypeNode(ast.value ? ts19.factory.createTrue() : ts19.factory.createFalse());
|
|
2213
2487
|
} else if (typeof ast.value === "number") {
|
|
2214
|
-
return
|
|
2488
|
+
return ts19.factory.createLiteralTypeNode(tsNumericExpression(ast.value));
|
|
2215
2489
|
} else {
|
|
2216
|
-
return
|
|
2490
|
+
return ts19.factory.createLiteralTypeNode(ts19.factory.createStringLiteral(ast.value));
|
|
2217
2491
|
}
|
|
2218
2492
|
}
|
|
2219
2493
|
visitLocalizedString(ast, context) {
|
|
@@ -2223,11 +2497,14 @@ var TypeTranslatorVisitor = class {
|
|
|
2223
2497
|
if (ast.value.moduleName === null || ast.value.name === null) {
|
|
2224
2498
|
throw new Error(`Import unknown module or symbol`);
|
|
2225
2499
|
}
|
|
2226
|
-
const
|
|
2227
|
-
|
|
2228
|
-
|
|
2500
|
+
const typeName = this.imports.addImport({
|
|
2501
|
+
exportModuleSpecifier: ast.value.moduleName,
|
|
2502
|
+
exportSymbolName: ast.value.name,
|
|
2503
|
+
requestedFile: this.contextFile,
|
|
2504
|
+
asTypeReference: true
|
|
2505
|
+
});
|
|
2229
2506
|
const typeArguments = ast.typeParams !== null ? ast.typeParams.map((type) => this.translateType(type, context)) : void 0;
|
|
2230
|
-
return
|
|
2507
|
+
return ts19.factory.createTypeReferenceNode(typeName, typeArguments);
|
|
2231
2508
|
}
|
|
2232
2509
|
visitConditionalExpr(ast, context) {
|
|
2233
2510
|
throw new Error("Method not implemented.");
|
|
@@ -2258,60 +2535,60 @@ var TypeTranslatorVisitor = class {
|
|
|
2258
2535
|
}
|
|
2259
2536
|
visitLiteralArrayExpr(ast, context) {
|
|
2260
2537
|
const values = ast.entries.map((expr) => this.translateExpression(expr, context));
|
|
2261
|
-
return
|
|
2538
|
+
return ts19.factory.createTupleTypeNode(values);
|
|
2262
2539
|
}
|
|
2263
2540
|
visitLiteralMapExpr(ast, context) {
|
|
2264
2541
|
const entries = ast.entries.map((entry) => {
|
|
2265
2542
|
const { key, quoted } = entry;
|
|
2266
2543
|
const type = this.translateExpression(entry.value, context);
|
|
2267
|
-
return
|
|
2544
|
+
return ts19.factory.createPropertySignature(
|
|
2268
2545
|
void 0,
|
|
2269
|
-
quoted ?
|
|
2546
|
+
quoted ? ts19.factory.createStringLiteral(key) : key,
|
|
2270
2547
|
void 0,
|
|
2271
2548
|
type
|
|
2272
2549
|
);
|
|
2273
2550
|
});
|
|
2274
|
-
return
|
|
2551
|
+
return ts19.factory.createTypeLiteralNode(entries);
|
|
2275
2552
|
}
|
|
2276
2553
|
visitCommaExpr(ast, context) {
|
|
2277
2554
|
throw new Error("Method not implemented.");
|
|
2278
2555
|
}
|
|
2279
2556
|
visitWrappedNodeExpr(ast, context) {
|
|
2280
2557
|
const node = ast.node;
|
|
2281
|
-
if (
|
|
2282
|
-
return
|
|
2283
|
-
} else if (
|
|
2558
|
+
if (ts19.isEntityName(node)) {
|
|
2559
|
+
return ts19.factory.createTypeReferenceNode(node, void 0);
|
|
2560
|
+
} else if (ts19.isTypeNode(node)) {
|
|
2284
2561
|
return node;
|
|
2285
|
-
} else if (
|
|
2286
|
-
return
|
|
2562
|
+
} else if (ts19.isLiteralExpression(node)) {
|
|
2563
|
+
return ts19.factory.createLiteralTypeNode(node);
|
|
2287
2564
|
} else {
|
|
2288
|
-
throw new Error(`Unsupported WrappedNodeExpr in TypeTranslatorVisitor: ${
|
|
2565
|
+
throw new Error(`Unsupported WrappedNodeExpr in TypeTranslatorVisitor: ${ts19.SyntaxKind[node.kind]}`);
|
|
2289
2566
|
}
|
|
2290
2567
|
}
|
|
2291
2568
|
visitTypeofExpr(ast, context) {
|
|
2292
2569
|
const typeNode = this.translateExpression(ast.expr, context);
|
|
2293
|
-
if (!
|
|
2570
|
+
if (!ts19.isTypeReferenceNode(typeNode)) {
|
|
2294
2571
|
throw new Error(`The target of a typeof expression must be a type reference, but it was
|
|
2295
|
-
${
|
|
2572
|
+
${ts19.SyntaxKind[typeNode.kind]}`);
|
|
2296
2573
|
}
|
|
2297
|
-
return
|
|
2574
|
+
return ts19.factory.createTypeQueryNode(typeNode.typeName);
|
|
2298
2575
|
}
|
|
2299
2576
|
translateType(type, context) {
|
|
2300
2577
|
const typeNode = type.visitType(this, context);
|
|
2301
|
-
if (!
|
|
2302
|
-
throw new Error(`A Type must translate to a TypeNode, but was ${
|
|
2578
|
+
if (!ts19.isTypeNode(typeNode)) {
|
|
2579
|
+
throw new Error(`A Type must translate to a TypeNode, but was ${ts19.SyntaxKind[typeNode.kind]}`);
|
|
2303
2580
|
}
|
|
2304
2581
|
return typeNode;
|
|
2305
2582
|
}
|
|
2306
2583
|
translateExpression(expr, context) {
|
|
2307
2584
|
const typeNode = expr.visitExpression(this, context);
|
|
2308
|
-
if (!
|
|
2309
|
-
throw new Error(`An Expression must translate to a TypeNode, but was ${
|
|
2585
|
+
if (!ts19.isTypeNode(typeNode)) {
|
|
2586
|
+
throw new Error(`An Expression must translate to a TypeNode, but was ${ts19.SyntaxKind[typeNode.kind]}`);
|
|
2310
2587
|
}
|
|
2311
2588
|
return typeNode;
|
|
2312
2589
|
}
|
|
2313
2590
|
translateTypeReference(type, context, viaModule) {
|
|
2314
|
-
const target =
|
|
2591
|
+
const target = ts19.isIdentifier(type.typeName) ? type.typeName : type.typeName.right;
|
|
2315
2592
|
const declaration = this.reflector.getDeclarationOfIdentifier(target);
|
|
2316
2593
|
if (declaration === null) {
|
|
2317
2594
|
throw new Error(`Unable to statically determine the declaration file of type node ${target.text}`);
|
|
@@ -2327,79 +2604,79 @@ var TypeTranslatorVisitor = class {
|
|
|
2327
2604
|
const emittedType = this.refEmitter.emit(reference, this.contextFile, ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowAmbientReferences);
|
|
2328
2605
|
assertSuccessfulReferenceEmit(emittedType, target, "type");
|
|
2329
2606
|
const typeNode = this.translateExpression(emittedType.expression, context);
|
|
2330
|
-
if (!
|
|
2331
|
-
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${
|
|
2607
|
+
if (!ts19.isTypeReferenceNode(typeNode)) {
|
|
2608
|
+
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${ts19.SyntaxKind[typeNode.kind]}.`);
|
|
2332
2609
|
}
|
|
2333
2610
|
return typeNode;
|
|
2334
2611
|
}
|
|
2335
2612
|
};
|
|
2336
2613
|
|
|
2337
2614
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.mjs
|
|
2338
|
-
import
|
|
2615
|
+
import ts20 from "typescript";
|
|
2339
2616
|
var PureAnnotation;
|
|
2340
2617
|
(function(PureAnnotation2) {
|
|
2341
2618
|
PureAnnotation2["CLOSURE"] = "* @pureOrBreakMyCode ";
|
|
2342
2619
|
PureAnnotation2["TERSER"] = "@__PURE__";
|
|
2343
2620
|
})(PureAnnotation || (PureAnnotation = {}));
|
|
2344
2621
|
var UNARY_OPERATORS2 = {
|
|
2345
|
-
"+":
|
|
2346
|
-
"-":
|
|
2347
|
-
"!":
|
|
2622
|
+
"+": ts20.SyntaxKind.PlusToken,
|
|
2623
|
+
"-": ts20.SyntaxKind.MinusToken,
|
|
2624
|
+
"!": ts20.SyntaxKind.ExclamationToken
|
|
2348
2625
|
};
|
|
2349
2626
|
var BINARY_OPERATORS2 = {
|
|
2350
|
-
"&&":
|
|
2351
|
-
">":
|
|
2352
|
-
">=":
|
|
2353
|
-
"&":
|
|
2354
|
-
"|":
|
|
2355
|
-
"/":
|
|
2356
|
-
"==":
|
|
2357
|
-
"===":
|
|
2358
|
-
"<":
|
|
2359
|
-
"<=":
|
|
2360
|
-
"-":
|
|
2361
|
-
"%":
|
|
2362
|
-
"*":
|
|
2363
|
-
"!=":
|
|
2364
|
-
"!==":
|
|
2365
|
-
"||":
|
|
2366
|
-
"+":
|
|
2367
|
-
"??":
|
|
2627
|
+
"&&": ts20.SyntaxKind.AmpersandAmpersandToken,
|
|
2628
|
+
">": ts20.SyntaxKind.GreaterThanToken,
|
|
2629
|
+
">=": ts20.SyntaxKind.GreaterThanEqualsToken,
|
|
2630
|
+
"&": ts20.SyntaxKind.AmpersandToken,
|
|
2631
|
+
"|": ts20.SyntaxKind.BarToken,
|
|
2632
|
+
"/": ts20.SyntaxKind.SlashToken,
|
|
2633
|
+
"==": ts20.SyntaxKind.EqualsEqualsToken,
|
|
2634
|
+
"===": ts20.SyntaxKind.EqualsEqualsEqualsToken,
|
|
2635
|
+
"<": ts20.SyntaxKind.LessThanToken,
|
|
2636
|
+
"<=": ts20.SyntaxKind.LessThanEqualsToken,
|
|
2637
|
+
"-": ts20.SyntaxKind.MinusToken,
|
|
2638
|
+
"%": ts20.SyntaxKind.PercentToken,
|
|
2639
|
+
"*": ts20.SyntaxKind.AsteriskToken,
|
|
2640
|
+
"!=": ts20.SyntaxKind.ExclamationEqualsToken,
|
|
2641
|
+
"!==": ts20.SyntaxKind.ExclamationEqualsEqualsToken,
|
|
2642
|
+
"||": ts20.SyntaxKind.BarBarToken,
|
|
2643
|
+
"+": ts20.SyntaxKind.PlusToken,
|
|
2644
|
+
"??": ts20.SyntaxKind.QuestionQuestionToken
|
|
2368
2645
|
};
|
|
2369
2646
|
var VAR_TYPES = {
|
|
2370
|
-
"const":
|
|
2371
|
-
"let":
|
|
2372
|
-
"var":
|
|
2647
|
+
"const": ts20.NodeFlags.Const,
|
|
2648
|
+
"let": ts20.NodeFlags.Let,
|
|
2649
|
+
"var": ts20.NodeFlags.None
|
|
2373
2650
|
};
|
|
2374
2651
|
var TypeScriptAstFactory = class {
|
|
2375
2652
|
constructor(annotateForClosureCompiler) {
|
|
2376
2653
|
this.annotateForClosureCompiler = annotateForClosureCompiler;
|
|
2377
2654
|
this.externalSourceFiles = /* @__PURE__ */ new Map();
|
|
2378
2655
|
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 =
|
|
2656
|
+
this.createArrayLiteral = ts20.factory.createArrayLiteralExpression;
|
|
2657
|
+
this.createElementAccess = ts20.factory.createElementAccessExpression;
|
|
2658
|
+
this.createExpressionStatement = ts20.factory.createExpressionStatement;
|
|
2659
|
+
this.createIdentifier = ts20.factory.createIdentifier;
|
|
2660
|
+
this.createParenthesizedExpression = ts20.factory.createParenthesizedExpression;
|
|
2661
|
+
this.createPropertyAccess = ts20.factory.createPropertyAccessExpression;
|
|
2662
|
+
this.createThrowStatement = ts20.factory.createThrowStatement;
|
|
2663
|
+
this.createTypeOfExpression = ts20.factory.createTypeOfExpression;
|
|
2387
2664
|
}
|
|
2388
2665
|
createAssignment(target, value) {
|
|
2389
|
-
return
|
|
2666
|
+
return ts20.factory.createBinaryExpression(target, ts20.SyntaxKind.EqualsToken, value);
|
|
2390
2667
|
}
|
|
2391
2668
|
createBinaryExpression(leftOperand, operator, rightOperand) {
|
|
2392
|
-
return
|
|
2669
|
+
return ts20.factory.createBinaryExpression(leftOperand, BINARY_OPERATORS2[operator], rightOperand);
|
|
2393
2670
|
}
|
|
2394
2671
|
createBlock(body) {
|
|
2395
|
-
return
|
|
2672
|
+
return ts20.factory.createBlock(body);
|
|
2396
2673
|
}
|
|
2397
2674
|
createCallExpression(callee, args, pure) {
|
|
2398
|
-
const call =
|
|
2675
|
+
const call = ts20.factory.createCallExpression(callee, void 0, args);
|
|
2399
2676
|
if (pure) {
|
|
2400
|
-
|
|
2677
|
+
ts20.addSyntheticLeadingComment(
|
|
2401
2678
|
call,
|
|
2402
|
-
|
|
2679
|
+
ts20.SyntaxKind.MultiLineCommentTrivia,
|
|
2403
2680
|
this.annotateForClosureCompiler ? PureAnnotation.CLOSURE : PureAnnotation.TERSER,
|
|
2404
2681
|
false
|
|
2405
2682
|
);
|
|
@@ -2407,64 +2684,64 @@ var TypeScriptAstFactory = class {
|
|
|
2407
2684
|
return call;
|
|
2408
2685
|
}
|
|
2409
2686
|
createConditional(condition, whenTrue, whenFalse) {
|
|
2410
|
-
return
|
|
2687
|
+
return ts20.factory.createConditionalExpression(condition, void 0, whenTrue, void 0, whenFalse);
|
|
2411
2688
|
}
|
|
2412
2689
|
createDynamicImport(url) {
|
|
2413
|
-
return
|
|
2414
|
-
|
|
2690
|
+
return ts20.factory.createCallExpression(
|
|
2691
|
+
ts20.factory.createToken(ts20.SyntaxKind.ImportKeyword),
|
|
2415
2692
|
void 0,
|
|
2416
|
-
[
|
|
2693
|
+
[ts20.factory.createStringLiteral(url)]
|
|
2417
2694
|
);
|
|
2418
2695
|
}
|
|
2419
2696
|
createFunctionDeclaration(functionName, parameters, body) {
|
|
2420
|
-
if (!
|
|
2421
|
-
throw new Error(`Invalid syntax, expected a block, but got ${
|
|
2697
|
+
if (!ts20.isBlock(body)) {
|
|
2698
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts20.SyntaxKind[body.kind]}.`);
|
|
2422
2699
|
}
|
|
2423
|
-
return
|
|
2700
|
+
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
2701
|
}
|
|
2425
2702
|
createFunctionExpression(functionName, parameters, body) {
|
|
2426
|
-
if (!
|
|
2427
|
-
throw new Error(`Invalid syntax, expected a block, but got ${
|
|
2703
|
+
if (!ts20.isBlock(body)) {
|
|
2704
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts20.SyntaxKind[body.kind]}.`);
|
|
2428
2705
|
}
|
|
2429
|
-
return
|
|
2706
|
+
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
2707
|
}
|
|
2431
2708
|
createArrowFunctionExpression(parameters, body) {
|
|
2432
|
-
if (
|
|
2433
|
-
throw new Error(`Invalid syntax, expected a block, but got ${
|
|
2709
|
+
if (ts20.isStatement(body) && !ts20.isBlock(body)) {
|
|
2710
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts20.SyntaxKind[body.kind]}.`);
|
|
2434
2711
|
}
|
|
2435
|
-
return
|
|
2712
|
+
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
2713
|
}
|
|
2437
2714
|
createIfStatement(condition, thenStatement, elseStatement) {
|
|
2438
|
-
return
|
|
2715
|
+
return ts20.factory.createIfStatement(condition, thenStatement, elseStatement != null ? elseStatement : void 0);
|
|
2439
2716
|
}
|
|
2440
2717
|
createLiteral(value) {
|
|
2441
2718
|
if (value === void 0) {
|
|
2442
|
-
return
|
|
2719
|
+
return ts20.factory.createIdentifier("undefined");
|
|
2443
2720
|
} else if (value === null) {
|
|
2444
|
-
return
|
|
2721
|
+
return ts20.factory.createNull();
|
|
2445
2722
|
} else if (typeof value === "boolean") {
|
|
2446
|
-
return value ?
|
|
2723
|
+
return value ? ts20.factory.createTrue() : ts20.factory.createFalse();
|
|
2447
2724
|
} else if (typeof value === "number") {
|
|
2448
2725
|
return tsNumericExpression(value);
|
|
2449
2726
|
} else {
|
|
2450
|
-
return
|
|
2727
|
+
return ts20.factory.createStringLiteral(value);
|
|
2451
2728
|
}
|
|
2452
2729
|
}
|
|
2453
2730
|
createNewExpression(expression, args) {
|
|
2454
|
-
return
|
|
2731
|
+
return ts20.factory.createNewExpression(expression, void 0, args);
|
|
2455
2732
|
}
|
|
2456
2733
|
createObjectLiteral(properties) {
|
|
2457
|
-
return
|
|
2734
|
+
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
2735
|
}
|
|
2459
2736
|
createReturnStatement(expression) {
|
|
2460
|
-
return
|
|
2737
|
+
return ts20.factory.createReturnStatement(expression != null ? expression : void 0);
|
|
2461
2738
|
}
|
|
2462
2739
|
createTaggedTemplate(tag, template) {
|
|
2463
2740
|
let templateLiteral;
|
|
2464
2741
|
const length = template.elements.length;
|
|
2465
2742
|
const head = template.elements[0];
|
|
2466
2743
|
if (length === 1) {
|
|
2467
|
-
templateLiteral =
|
|
2744
|
+
templateLiteral = ts20.factory.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
|
|
2468
2745
|
} else {
|
|
2469
2746
|
const spans = [];
|
|
2470
2747
|
for (let i = 1; i < length - 1; i++) {
|
|
@@ -2473,7 +2750,7 @@ var TypeScriptAstFactory = class {
|
|
|
2473
2750
|
if (range !== null) {
|
|
2474
2751
|
this.setSourceMapRange(middle, range);
|
|
2475
2752
|
}
|
|
2476
|
-
spans.push(
|
|
2753
|
+
spans.push(ts20.factory.createTemplateSpan(template.expressions[i - 1], middle));
|
|
2477
2754
|
}
|
|
2478
2755
|
const resolvedExpression = template.expressions[length - 2];
|
|
2479
2756
|
const templatePart = template.elements[length - 1];
|
|
@@ -2481,19 +2758,19 @@ var TypeScriptAstFactory = class {
|
|
|
2481
2758
|
if (templatePart.range !== null) {
|
|
2482
2759
|
this.setSourceMapRange(templateTail, templatePart.range);
|
|
2483
2760
|
}
|
|
2484
|
-
spans.push(
|
|
2485
|
-
templateLiteral =
|
|
2761
|
+
spans.push(ts20.factory.createTemplateSpan(resolvedExpression, templateTail));
|
|
2762
|
+
templateLiteral = ts20.factory.createTemplateExpression(ts20.factory.createTemplateHead(head.cooked, head.raw), spans);
|
|
2486
2763
|
}
|
|
2487
2764
|
if (head.range !== null) {
|
|
2488
2765
|
this.setSourceMapRange(templateLiteral, head.range);
|
|
2489
2766
|
}
|
|
2490
|
-
return
|
|
2767
|
+
return ts20.factory.createTaggedTemplateExpression(tag, void 0, templateLiteral);
|
|
2491
2768
|
}
|
|
2492
2769
|
createUnaryExpression(operator, operand) {
|
|
2493
|
-
return
|
|
2770
|
+
return ts20.factory.createPrefixUnaryExpression(UNARY_OPERATORS2[operator], operand);
|
|
2494
2771
|
}
|
|
2495
2772
|
createVariableDeclaration(variableName, initializer, type) {
|
|
2496
|
-
return
|
|
2773
|
+
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
2774
|
}
|
|
2498
2775
|
setSourceMapRange(node, sourceMapRange) {
|
|
2499
2776
|
if (sourceMapRange === null) {
|
|
@@ -2501,42 +2778,42 @@ var TypeScriptAstFactory = class {
|
|
|
2501
2778
|
}
|
|
2502
2779
|
const url = sourceMapRange.url;
|
|
2503
2780
|
if (!this.externalSourceFiles.has(url)) {
|
|
2504
|
-
this.externalSourceFiles.set(url,
|
|
2781
|
+
this.externalSourceFiles.set(url, ts20.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
|
|
2505
2782
|
}
|
|
2506
2783
|
const source = this.externalSourceFiles.get(url);
|
|
2507
|
-
|
|
2784
|
+
ts20.setSourceMapRange(node, { pos: sourceMapRange.start.offset, end: sourceMapRange.end.offset, source });
|
|
2508
2785
|
return node;
|
|
2509
2786
|
}
|
|
2510
2787
|
};
|
|
2511
2788
|
function createTemplateMiddle(cooked, raw) {
|
|
2512
|
-
const node =
|
|
2513
|
-
node.kind =
|
|
2789
|
+
const node = ts20.factory.createTemplateHead(cooked, raw);
|
|
2790
|
+
node.kind = ts20.SyntaxKind.TemplateMiddle;
|
|
2514
2791
|
return node;
|
|
2515
2792
|
}
|
|
2516
2793
|
function createTemplateTail(cooked, raw) {
|
|
2517
|
-
const node =
|
|
2518
|
-
node.kind =
|
|
2794
|
+
const node = ts20.factory.createTemplateHead(cooked, raw);
|
|
2795
|
+
node.kind = ts20.SyntaxKind.TemplateTail;
|
|
2519
2796
|
return node;
|
|
2520
2797
|
}
|
|
2521
2798
|
function attachComments(statement, leadingComments) {
|
|
2522
2799
|
for (const comment of leadingComments) {
|
|
2523
|
-
const commentKind = comment.multiline ?
|
|
2800
|
+
const commentKind = comment.multiline ? ts20.SyntaxKind.MultiLineCommentTrivia : ts20.SyntaxKind.SingleLineCommentTrivia;
|
|
2524
2801
|
if (comment.multiline) {
|
|
2525
|
-
|
|
2802
|
+
ts20.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
|
|
2526
2803
|
} else {
|
|
2527
2804
|
for (const line of comment.toString().split("\n")) {
|
|
2528
|
-
|
|
2805
|
+
ts20.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
|
|
2529
2806
|
}
|
|
2530
2807
|
}
|
|
2531
2808
|
}
|
|
2532
2809
|
}
|
|
2533
2810
|
|
|
2534
2811
|
// 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));
|
|
2812
|
+
function translateExpression(contextFile, expression, imports, options = {}) {
|
|
2813
|
+
return expression.visitExpression(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, contextFile, options), new Context(false));
|
|
2537
2814
|
}
|
|
2538
|
-
function translateStatement(statement, imports, options = {}) {
|
|
2539
|
-
return statement.visitStatement(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(true));
|
|
2815
|
+
function translateStatement(contextFile, statement, imports, options = {}) {
|
|
2816
|
+
return statement.visitStatement(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, contextFile, options), new Context(true));
|
|
2540
2817
|
}
|
|
2541
2818
|
|
|
2542
2819
|
export {
|
|
@@ -2602,6 +2879,7 @@ export {
|
|
|
2602
2879
|
Reference,
|
|
2603
2880
|
ModuleResolver,
|
|
2604
2881
|
Context,
|
|
2882
|
+
presetImportManagerForceNamespaceImports,
|
|
2605
2883
|
ImportManager,
|
|
2606
2884
|
ExpressionTranslatorVisitor,
|
|
2607
2885
|
canEmitType,
|
|
@@ -2624,4 +2902,4 @@ export {
|
|
|
2624
2902
|
* Use of this source code is governed by an MIT-style license that can be
|
|
2625
2903
|
* found in the LICENSE file at https://angular.io/license
|
|
2626
2904
|
*/
|
|
2627
|
-
//# sourceMappingURL=chunk-
|
|
2905
|
+
//# sourceMappingURL=chunk-GGJA4IFT.js.map
|