@angular/compiler-cli 17.1.0-next.4 → 17.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/{chunk-HQUXRCDO.js → chunk-75SXFAVW.js} +56 -30
- package/bundles/chunk-75SXFAVW.js.map +6 -0
- package/bundles/{chunk-YGXKICXB.js → chunk-AJU3W7PS.js} +93 -10
- package/bundles/chunk-AJU3W7PS.js.map +6 -0
- package/bundles/{chunk-5QWOGIJL.js → chunk-FIHKBAQF.js} +2 -2
- package/bundles/{chunk-EFMKZSXJ.js → chunk-OQ7ITPZT.js} +817 -2
- package/bundles/chunk-OQ7ITPZT.js.map +6 -0
- package/bundles/chunk-Q5Y7HH3O.js +62 -0
- package/bundles/chunk-Q5Y7HH3O.js.map +6 -0
- package/bundles/{chunk-OZXTEOXW.js → chunk-R5FBSX7J.js} +21 -3
- package/bundles/chunk-R5FBSX7J.js.map +6 -0
- package/bundles/{chunk-U4EFDEE4.js → chunk-YS2EFQ7B.js} +94 -102
- package/bundles/chunk-YS2EFQ7B.js.map +6 -0
- package/bundles/index.js +8 -6
- package/bundles/index.js.map +1 -1
- package/bundles/linker/babel/index.js +5 -3
- package/bundles/linker/babel/index.js.map +1 -1
- package/bundles/linker/index.js +2 -3
- package/bundles/private/migrations.js +6 -5
- package/bundles/private/tooling.js +6 -2
- package/bundles/src/bin/ng_xi18n.js +5 -5
- package/bundles/src/bin/ngc.js +5 -5
- package/bundles_metadata.json +1 -1
- package/linker/babel/src/ast/babel_ast_host.d.ts +1 -0
- package/linker/src/ast/ast_host.d.ts +4 -0
- package/linker/src/ast/ast_value.d.ts +8 -1
- package/linker/src/ast/typescript/typescript_ast_host.d.ts +1 -0
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +2 -2
- package/private/tooling.d.ts +22 -6
- package/src/ngtsc/annotations/directive/index.d.ts +1 -0
- package/src/ngtsc/annotations/directive/src/input_function.d.ts +4 -13
- package/src/ngtsc/annotations/directive/src/shared.d.ts +2 -2
- package/src/ngtsc/annotations/index.d.ts +2 -2
- package/src/ngtsc/diagnostics/src/error_code.d.ts +6 -0
- package/src/ngtsc/transform/index.d.ts +1 -0
- package/src/ngtsc/transform/src/utils.d.ts +1 -1
- package/src/ngtsc/translator/src/api/ast_factory.d.ts +1 -1
- package/src/ngtsc/translator/src/import_manager.d.ts +2 -1
- package/src/ngtsc/typecheck/src/oob.d.ts +3 -3
- package/src/ngtsc/typecheck/src/tcb_util.d.ts +1 -1
- package/src/transformers/{downlevel_decorators_transform → jit_transforms}/index.d.ts +1 -0
- package/src/transformers/jit_transforms/signal_inputs_metadata_transform.d.ts +21 -0
- package/bundles/chunk-EFMKZSXJ.js.map +0 -6
- package/bundles/chunk-HQUXRCDO.js.map +0 -6
- package/bundles/chunk-MFE4YVWE.js +0 -831
- package/bundles/chunk-MFE4YVWE.js.map +0 -6
- package/bundles/chunk-OZXTEOXW.js.map +0 -6
- package/bundles/chunk-U4EFDEE4.js.map +0 -6
- package/bundles/chunk-YGXKICXB.js.map +0 -6
- /package/bundles/{chunk-5QWOGIJL.js.map → chunk-FIHKBAQF.js.map} +0 -0
- /package/src/transformers/{downlevel_decorators_transform → jit_transforms}/downlevel_decorators_transform.d.ts +0 -0
|
@@ -841,6 +841,9 @@ var ErrorCode;
|
|
|
841
841
|
ErrorCode2[ErrorCode2["DECORATOR_COLLISION"] = 1006] = "DECORATOR_COLLISION";
|
|
842
842
|
ErrorCode2[ErrorCode2["VALUE_HAS_WRONG_TYPE"] = 1010] = "VALUE_HAS_WRONG_TYPE";
|
|
843
843
|
ErrorCode2[ErrorCode2["VALUE_NOT_LITERAL"] = 1011] = "VALUE_NOT_LITERAL";
|
|
844
|
+
ErrorCode2[ErrorCode2["SIGNAL_INPUT_AND_DISALLOWED_DECORATOR"] = 1050] = "SIGNAL_INPUT_AND_DISALLOWED_DECORATOR";
|
|
845
|
+
ErrorCode2[ErrorCode2["SIGNAL_INPUT_AND_INPUTS_ARRAY_COLLISION"] = 1051] = "SIGNAL_INPUT_AND_INPUTS_ARRAY_COLLISION";
|
|
846
|
+
ErrorCode2[ErrorCode2["INPUT_DECLARED_ON_STATIC_MEMBER"] = 1100] = "INPUT_DECLARED_ON_STATIC_MEMBER";
|
|
844
847
|
ErrorCode2[ErrorCode2["COMPONENT_MISSING_TEMPLATE"] = 2001] = "COMPONENT_MISSING_TEMPLATE";
|
|
845
848
|
ErrorCode2[ErrorCode2["PIPE_MISSING_NAME"] = 2002] = "PIPE_MISSING_NAME";
|
|
846
849
|
ErrorCode2[ErrorCode2["PARAM_MISSING_TOKEN"] = 2003] = "PARAM_MISSING_TOKEN";
|
|
@@ -1584,6 +1587,803 @@ var ModuleResolver = class {
|
|
|
1584
1587
|
}
|
|
1585
1588
|
};
|
|
1586
1589
|
|
|
1590
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager.mjs
|
|
1591
|
+
import ts10 from "typescript";
|
|
1592
|
+
var ImportManager = class {
|
|
1593
|
+
constructor(rewriter = new NoopImportRewriter(), prefix = "i", factory = ts10.factory) {
|
|
1594
|
+
this.rewriter = rewriter;
|
|
1595
|
+
this.prefix = prefix;
|
|
1596
|
+
this.factory = factory;
|
|
1597
|
+
this.specifierToIdentifier = /* @__PURE__ */ new Map();
|
|
1598
|
+
this.nextIndex = 0;
|
|
1599
|
+
}
|
|
1600
|
+
generateNamespaceImport(moduleName) {
|
|
1601
|
+
if (!this.specifierToIdentifier.has(moduleName)) {
|
|
1602
|
+
this.specifierToIdentifier.set(moduleName, this.factory.createIdentifier(`${this.prefix}${this.nextIndex++}`));
|
|
1603
|
+
}
|
|
1604
|
+
return this.specifierToIdentifier.get(moduleName);
|
|
1605
|
+
}
|
|
1606
|
+
generateNamedImport(moduleName, originalSymbol) {
|
|
1607
|
+
const symbol = this.rewriter.rewriteSymbol(originalSymbol, moduleName);
|
|
1608
|
+
if (!this.rewriter.shouldImportSymbol(symbol, moduleName)) {
|
|
1609
|
+
return { moduleImport: null, symbol };
|
|
1610
|
+
}
|
|
1611
|
+
const moduleImport = this.generateNamespaceImport(moduleName);
|
|
1612
|
+
return { moduleImport, symbol };
|
|
1613
|
+
}
|
|
1614
|
+
getAllImports(contextPath) {
|
|
1615
|
+
const imports = [];
|
|
1616
|
+
for (const [originalSpecifier, qualifier] of this.specifierToIdentifier) {
|
|
1617
|
+
const specifier = this.rewriter.rewriteSpecifier(originalSpecifier, contextPath);
|
|
1618
|
+
imports.push({
|
|
1619
|
+
specifier,
|
|
1620
|
+
qualifier
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1623
|
+
return imports;
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1627
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/context.mjs
|
|
1628
|
+
var Context = class {
|
|
1629
|
+
constructor(isStatement) {
|
|
1630
|
+
this.isStatement = isStatement;
|
|
1631
|
+
}
|
|
1632
|
+
get withExpressionMode() {
|
|
1633
|
+
return this.isStatement ? new Context(false) : this;
|
|
1634
|
+
}
|
|
1635
|
+
get withStatementMode() {
|
|
1636
|
+
return !this.isStatement ? new Context(true) : this;
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1639
|
+
|
|
1640
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/translator.mjs
|
|
1641
|
+
import * as o from "@angular/compiler";
|
|
1642
|
+
var UNARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
1643
|
+
[o.UnaryOperator.Minus, "-"],
|
|
1644
|
+
[o.UnaryOperator.Plus, "+"]
|
|
1645
|
+
]);
|
|
1646
|
+
var BINARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
1647
|
+
[o.BinaryOperator.And, "&&"],
|
|
1648
|
+
[o.BinaryOperator.Bigger, ">"],
|
|
1649
|
+
[o.BinaryOperator.BiggerEquals, ">="],
|
|
1650
|
+
[o.BinaryOperator.BitwiseAnd, "&"],
|
|
1651
|
+
[o.BinaryOperator.BitwiseOr, "|"],
|
|
1652
|
+
[o.BinaryOperator.Divide, "/"],
|
|
1653
|
+
[o.BinaryOperator.Equals, "=="],
|
|
1654
|
+
[o.BinaryOperator.Identical, "==="],
|
|
1655
|
+
[o.BinaryOperator.Lower, "<"],
|
|
1656
|
+
[o.BinaryOperator.LowerEquals, "<="],
|
|
1657
|
+
[o.BinaryOperator.Minus, "-"],
|
|
1658
|
+
[o.BinaryOperator.Modulo, "%"],
|
|
1659
|
+
[o.BinaryOperator.Multiply, "*"],
|
|
1660
|
+
[o.BinaryOperator.NotEquals, "!="],
|
|
1661
|
+
[o.BinaryOperator.NotIdentical, "!=="],
|
|
1662
|
+
[o.BinaryOperator.Or, "||"],
|
|
1663
|
+
[o.BinaryOperator.Plus, "+"],
|
|
1664
|
+
[o.BinaryOperator.NullishCoalesce, "??"]
|
|
1665
|
+
]);
|
|
1666
|
+
var ExpressionTranslatorVisitor = class {
|
|
1667
|
+
constructor(factory, imports, options) {
|
|
1668
|
+
this.factory = factory;
|
|
1669
|
+
this.imports = imports;
|
|
1670
|
+
this.downlevelTaggedTemplates = options.downlevelTaggedTemplates === true;
|
|
1671
|
+
this.downlevelVariableDeclarations = options.downlevelVariableDeclarations === true;
|
|
1672
|
+
this.recordWrappedNode = options.recordWrappedNode || (() => {
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
visitDeclareVarStmt(stmt, context) {
|
|
1676
|
+
var _a;
|
|
1677
|
+
const varType = this.downlevelVariableDeclarations ? "var" : stmt.hasModifier(o.StmtModifier.Final) ? "const" : "let";
|
|
1678
|
+
return this.attachComments(this.factory.createVariableDeclaration(stmt.name, (_a = stmt.value) == null ? void 0 : _a.visitExpression(this, context.withExpressionMode), varType), stmt.leadingComments);
|
|
1679
|
+
}
|
|
1680
|
+
visitDeclareFunctionStmt(stmt, context) {
|
|
1681
|
+
return this.attachComments(this.factory.createFunctionDeclaration(stmt.name, stmt.params.map((param) => param.name), this.factory.createBlock(this.visitStatements(stmt.statements, context.withStatementMode))), stmt.leadingComments);
|
|
1682
|
+
}
|
|
1683
|
+
visitExpressionStmt(stmt, context) {
|
|
1684
|
+
return this.attachComments(this.factory.createExpressionStatement(stmt.expr.visitExpression(this, context.withStatementMode)), stmt.leadingComments);
|
|
1685
|
+
}
|
|
1686
|
+
visitReturnStmt(stmt, context) {
|
|
1687
|
+
return this.attachComments(this.factory.createReturnStatement(stmt.value.visitExpression(this, context.withExpressionMode)), stmt.leadingComments);
|
|
1688
|
+
}
|
|
1689
|
+
visitIfStmt(stmt, context) {
|
|
1690
|
+
return this.attachComments(this.factory.createIfStatement(stmt.condition.visitExpression(this, context), this.factory.createBlock(this.visitStatements(stmt.trueCase, context.withStatementMode)), stmt.falseCase.length > 0 ? this.factory.createBlock(this.visitStatements(stmt.falseCase, context.withStatementMode)) : null), stmt.leadingComments);
|
|
1691
|
+
}
|
|
1692
|
+
visitReadVarExpr(ast, _context) {
|
|
1693
|
+
const identifier = this.factory.createIdentifier(ast.name);
|
|
1694
|
+
this.setSourceMapRange(identifier, ast.sourceSpan);
|
|
1695
|
+
return identifier;
|
|
1696
|
+
}
|
|
1697
|
+
visitWriteVarExpr(expr, context) {
|
|
1698
|
+
const assignment = this.factory.createAssignment(this.setSourceMapRange(this.factory.createIdentifier(expr.name), expr.sourceSpan), expr.value.visitExpression(this, context));
|
|
1699
|
+
return context.isStatement ? assignment : this.factory.createParenthesizedExpression(assignment);
|
|
1700
|
+
}
|
|
1701
|
+
visitWriteKeyExpr(expr, context) {
|
|
1702
|
+
const exprContext = context.withExpressionMode;
|
|
1703
|
+
const target = this.factory.createElementAccess(expr.receiver.visitExpression(this, exprContext), expr.index.visitExpression(this, exprContext));
|
|
1704
|
+
const assignment = this.factory.createAssignment(target, expr.value.visitExpression(this, exprContext));
|
|
1705
|
+
return context.isStatement ? assignment : this.factory.createParenthesizedExpression(assignment);
|
|
1706
|
+
}
|
|
1707
|
+
visitWritePropExpr(expr, context) {
|
|
1708
|
+
const target = this.factory.createPropertyAccess(expr.receiver.visitExpression(this, context), expr.name);
|
|
1709
|
+
return this.factory.createAssignment(target, expr.value.visitExpression(this, context));
|
|
1710
|
+
}
|
|
1711
|
+
visitInvokeFunctionExpr(ast, context) {
|
|
1712
|
+
return this.setSourceMapRange(this.factory.createCallExpression(ast.fn.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)), ast.pure), ast.sourceSpan);
|
|
1713
|
+
}
|
|
1714
|
+
visitTaggedTemplateExpr(ast, context) {
|
|
1715
|
+
return this.setSourceMapRange(this.createTaggedTemplateExpression(ast.tag.visitExpression(this, context), {
|
|
1716
|
+
elements: ast.template.elements.map((e) => {
|
|
1717
|
+
var _a;
|
|
1718
|
+
return createTemplateElement({
|
|
1719
|
+
cooked: e.text,
|
|
1720
|
+
raw: e.rawText,
|
|
1721
|
+
range: (_a = e.sourceSpan) != null ? _a : ast.sourceSpan
|
|
1722
|
+
});
|
|
1723
|
+
}),
|
|
1724
|
+
expressions: ast.template.expressions.map((e) => e.visitExpression(this, context))
|
|
1725
|
+
}), ast.sourceSpan);
|
|
1726
|
+
}
|
|
1727
|
+
visitInstantiateExpr(ast, context) {
|
|
1728
|
+
return this.factory.createNewExpression(ast.classExpr.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)));
|
|
1729
|
+
}
|
|
1730
|
+
visitLiteralExpr(ast, _context) {
|
|
1731
|
+
return this.setSourceMapRange(this.factory.createLiteral(ast.value), ast.sourceSpan);
|
|
1732
|
+
}
|
|
1733
|
+
visitLocalizedString(ast, context) {
|
|
1734
|
+
const elements = [createTemplateElement(ast.serializeI18nHead())];
|
|
1735
|
+
const expressions = [];
|
|
1736
|
+
for (let i = 0; i < ast.expressions.length; i++) {
|
|
1737
|
+
const placeholder = this.setSourceMapRange(ast.expressions[i].visitExpression(this, context), ast.getPlaceholderSourceSpan(i));
|
|
1738
|
+
expressions.push(placeholder);
|
|
1739
|
+
elements.push(createTemplateElement(ast.serializeI18nTemplatePart(i + 1)));
|
|
1740
|
+
}
|
|
1741
|
+
const localizeTag = this.factory.createIdentifier("$localize");
|
|
1742
|
+
return this.setSourceMapRange(this.createTaggedTemplateExpression(localizeTag, { elements, expressions }), ast.sourceSpan);
|
|
1743
|
+
}
|
|
1744
|
+
createTaggedTemplateExpression(tag, template) {
|
|
1745
|
+
return this.downlevelTaggedTemplates ? this.createES5TaggedTemplateFunctionCall(tag, template) : this.factory.createTaggedTemplate(tag, template);
|
|
1746
|
+
}
|
|
1747
|
+
createES5TaggedTemplateFunctionCall(tagHandler, { elements, expressions }) {
|
|
1748
|
+
const { moduleImport, symbol } = this.imports.generateNamedImport("tslib", "__makeTemplateObject");
|
|
1749
|
+
const __makeTemplateObjectHelper = moduleImport === null ? this.factory.createIdentifier(symbol) : this.factory.createPropertyAccess(moduleImport, symbol);
|
|
1750
|
+
const cooked = [];
|
|
1751
|
+
const raw = [];
|
|
1752
|
+
for (const element of elements) {
|
|
1753
|
+
cooked.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.cooked), element.range));
|
|
1754
|
+
raw.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.raw), element.range));
|
|
1755
|
+
}
|
|
1756
|
+
const templateHelperCall = this.factory.createCallExpression(
|
|
1757
|
+
__makeTemplateObjectHelper,
|
|
1758
|
+
[this.factory.createArrayLiteral(cooked), this.factory.createArrayLiteral(raw)],
|
|
1759
|
+
false
|
|
1760
|
+
);
|
|
1761
|
+
return this.factory.createCallExpression(
|
|
1762
|
+
tagHandler,
|
|
1763
|
+
[templateHelperCall, ...expressions],
|
|
1764
|
+
false
|
|
1765
|
+
);
|
|
1766
|
+
}
|
|
1767
|
+
visitExternalExpr(ast, _context) {
|
|
1768
|
+
if (ast.value.name === null) {
|
|
1769
|
+
if (ast.value.moduleName === null) {
|
|
1770
|
+
throw new Error("Invalid import without name nor moduleName");
|
|
1771
|
+
}
|
|
1772
|
+
return this.imports.generateNamespaceImport(ast.value.moduleName);
|
|
1773
|
+
}
|
|
1774
|
+
if (ast.value.moduleName !== null) {
|
|
1775
|
+
const { moduleImport, symbol } = this.imports.generateNamedImport(ast.value.moduleName, ast.value.name);
|
|
1776
|
+
if (moduleImport === null) {
|
|
1777
|
+
return this.factory.createIdentifier(symbol);
|
|
1778
|
+
} else {
|
|
1779
|
+
return this.factory.createPropertyAccess(moduleImport, symbol);
|
|
1780
|
+
}
|
|
1781
|
+
} else {
|
|
1782
|
+
return this.factory.createIdentifier(ast.value.name);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
visitConditionalExpr(ast, context) {
|
|
1786
|
+
let cond = ast.condition.visitExpression(this, context);
|
|
1787
|
+
if (ast.condition instanceof o.ConditionalExpr) {
|
|
1788
|
+
cond = this.factory.createParenthesizedExpression(cond);
|
|
1789
|
+
}
|
|
1790
|
+
return this.factory.createConditional(cond, ast.trueCase.visitExpression(this, context), ast.falseCase.visitExpression(this, context));
|
|
1791
|
+
}
|
|
1792
|
+
visitDynamicImportExpr(ast, context) {
|
|
1793
|
+
return this.factory.createDynamicImport(ast.url);
|
|
1794
|
+
}
|
|
1795
|
+
visitNotExpr(ast, context) {
|
|
1796
|
+
return this.factory.createUnaryExpression("!", ast.condition.visitExpression(this, context));
|
|
1797
|
+
}
|
|
1798
|
+
visitFunctionExpr(ast, context) {
|
|
1799
|
+
var _a;
|
|
1800
|
+
return this.factory.createFunctionExpression((_a = ast.name) != null ? _a : null, ast.params.map((param) => param.name), this.factory.createBlock(this.visitStatements(ast.statements, context)));
|
|
1801
|
+
}
|
|
1802
|
+
visitArrowFunctionExpr(ast, context) {
|
|
1803
|
+
return this.factory.createArrowFunctionExpression(ast.params.map((param) => param.name), Array.isArray(ast.body) ? this.factory.createBlock(this.visitStatements(ast.body, context)) : ast.body.visitExpression(this, context));
|
|
1804
|
+
}
|
|
1805
|
+
visitBinaryOperatorExpr(ast, context) {
|
|
1806
|
+
if (!BINARY_OPERATORS.has(ast.operator)) {
|
|
1807
|
+
throw new Error(`Unknown binary operator: ${o.BinaryOperator[ast.operator]}`);
|
|
1808
|
+
}
|
|
1809
|
+
return this.factory.createBinaryExpression(ast.lhs.visitExpression(this, context), BINARY_OPERATORS.get(ast.operator), ast.rhs.visitExpression(this, context));
|
|
1810
|
+
}
|
|
1811
|
+
visitReadPropExpr(ast, context) {
|
|
1812
|
+
return this.factory.createPropertyAccess(ast.receiver.visitExpression(this, context), ast.name);
|
|
1813
|
+
}
|
|
1814
|
+
visitReadKeyExpr(ast, context) {
|
|
1815
|
+
return this.factory.createElementAccess(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context));
|
|
1816
|
+
}
|
|
1817
|
+
visitLiteralArrayExpr(ast, context) {
|
|
1818
|
+
return this.factory.createArrayLiteral(ast.entries.map((expr) => this.setSourceMapRange(expr.visitExpression(this, context), ast.sourceSpan)));
|
|
1819
|
+
}
|
|
1820
|
+
visitLiteralMapExpr(ast, context) {
|
|
1821
|
+
const properties = ast.entries.map((entry) => {
|
|
1822
|
+
return {
|
|
1823
|
+
propertyName: entry.key,
|
|
1824
|
+
quoted: entry.quoted,
|
|
1825
|
+
value: entry.value.visitExpression(this, context)
|
|
1826
|
+
};
|
|
1827
|
+
});
|
|
1828
|
+
return this.setSourceMapRange(this.factory.createObjectLiteral(properties), ast.sourceSpan);
|
|
1829
|
+
}
|
|
1830
|
+
visitCommaExpr(ast, context) {
|
|
1831
|
+
throw new Error("Method not implemented.");
|
|
1832
|
+
}
|
|
1833
|
+
visitWrappedNodeExpr(ast, _context) {
|
|
1834
|
+
this.recordWrappedNode(ast);
|
|
1835
|
+
return ast.node;
|
|
1836
|
+
}
|
|
1837
|
+
visitTypeofExpr(ast, context) {
|
|
1838
|
+
return this.factory.createTypeOfExpression(ast.expr.visitExpression(this, context));
|
|
1839
|
+
}
|
|
1840
|
+
visitUnaryOperatorExpr(ast, context) {
|
|
1841
|
+
if (!UNARY_OPERATORS.has(ast.operator)) {
|
|
1842
|
+
throw new Error(`Unknown unary operator: ${o.UnaryOperator[ast.operator]}`);
|
|
1843
|
+
}
|
|
1844
|
+
return this.factory.createUnaryExpression(UNARY_OPERATORS.get(ast.operator), ast.expr.visitExpression(this, context));
|
|
1845
|
+
}
|
|
1846
|
+
visitStatements(statements, context) {
|
|
1847
|
+
return statements.map((stmt) => stmt.visitStatement(this, context)).filter((stmt) => stmt !== void 0);
|
|
1848
|
+
}
|
|
1849
|
+
setSourceMapRange(ast, span) {
|
|
1850
|
+
return this.factory.setSourceMapRange(ast, createRange(span));
|
|
1851
|
+
}
|
|
1852
|
+
attachComments(statement, leadingComments) {
|
|
1853
|
+
if (leadingComments !== void 0) {
|
|
1854
|
+
this.factory.attachComments(statement, leadingComments);
|
|
1855
|
+
}
|
|
1856
|
+
return statement;
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
function createTemplateElement({ cooked, raw, range }) {
|
|
1860
|
+
return { cooked, raw, range: createRange(range) };
|
|
1861
|
+
}
|
|
1862
|
+
function createRange(span) {
|
|
1863
|
+
if (span === null) {
|
|
1864
|
+
return null;
|
|
1865
|
+
}
|
|
1866
|
+
const { start, end } = span;
|
|
1867
|
+
const { url, content } = start.file;
|
|
1868
|
+
if (!url) {
|
|
1869
|
+
return null;
|
|
1870
|
+
}
|
|
1871
|
+
return {
|
|
1872
|
+
url,
|
|
1873
|
+
content,
|
|
1874
|
+
start: { offset: start.offset, line: start.line, column: start.col },
|
|
1875
|
+
end: { offset: end.offset, line: end.line, column: end.col }
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_emitter.mjs
|
|
1880
|
+
import ts11 from "typescript";
|
|
1881
|
+
var INELIGIBLE = {};
|
|
1882
|
+
function canEmitType(type, canEmit) {
|
|
1883
|
+
return canEmitTypeWorker(type);
|
|
1884
|
+
function canEmitTypeWorker(type2) {
|
|
1885
|
+
return visitNode(type2) !== INELIGIBLE;
|
|
1886
|
+
}
|
|
1887
|
+
function visitNode(node) {
|
|
1888
|
+
if (ts11.isImportTypeNode(node)) {
|
|
1889
|
+
return INELIGIBLE;
|
|
1890
|
+
}
|
|
1891
|
+
if (ts11.isTypeReferenceNode(node) && !canEmitTypeReference(node)) {
|
|
1892
|
+
return INELIGIBLE;
|
|
1893
|
+
} else {
|
|
1894
|
+
return ts11.forEachChild(node, visitNode);
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
function canEmitTypeReference(type2) {
|
|
1898
|
+
if (!canEmit(type2)) {
|
|
1899
|
+
return false;
|
|
1900
|
+
}
|
|
1901
|
+
return type2.typeArguments === void 0 || type2.typeArguments.every(canEmitTypeWorker);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
var TypeEmitter = class {
|
|
1905
|
+
constructor(translator) {
|
|
1906
|
+
this.translator = translator;
|
|
1907
|
+
}
|
|
1908
|
+
emitType(type) {
|
|
1909
|
+
const typeReferenceTransformer = (context) => {
|
|
1910
|
+
const visitNode = (node) => {
|
|
1911
|
+
if (ts11.isImportTypeNode(node)) {
|
|
1912
|
+
throw new Error("Unable to emit import type");
|
|
1913
|
+
}
|
|
1914
|
+
if (ts11.isTypeReferenceNode(node)) {
|
|
1915
|
+
return this.emitTypeReference(node);
|
|
1916
|
+
} else if (ts11.isLiteralExpression(node)) {
|
|
1917
|
+
let clone;
|
|
1918
|
+
if (ts11.isStringLiteral(node)) {
|
|
1919
|
+
clone = ts11.factory.createStringLiteral(node.text);
|
|
1920
|
+
} else if (ts11.isNumericLiteral(node)) {
|
|
1921
|
+
clone = ts11.factory.createNumericLiteral(node.text);
|
|
1922
|
+
} else if (ts11.isBigIntLiteral(node)) {
|
|
1923
|
+
clone = ts11.factory.createBigIntLiteral(node.text);
|
|
1924
|
+
} else if (ts11.isNoSubstitutionTemplateLiteral(node)) {
|
|
1925
|
+
clone = ts11.factory.createNoSubstitutionTemplateLiteral(node.text, node.rawText);
|
|
1926
|
+
} else if (ts11.isRegularExpressionLiteral(node)) {
|
|
1927
|
+
clone = ts11.factory.createRegularExpressionLiteral(node.text);
|
|
1928
|
+
} else {
|
|
1929
|
+
throw new Error(`Unsupported literal kind ${ts11.SyntaxKind[node.kind]}`);
|
|
1930
|
+
}
|
|
1931
|
+
ts11.setTextRange(clone, { pos: -1, end: -1 });
|
|
1932
|
+
return clone;
|
|
1933
|
+
} else {
|
|
1934
|
+
return ts11.visitEachChild(node, visitNode, context);
|
|
1935
|
+
}
|
|
1936
|
+
};
|
|
1937
|
+
return (node) => ts11.visitNode(node, visitNode, ts11.isTypeNode);
|
|
1938
|
+
};
|
|
1939
|
+
return ts11.transform(type, [typeReferenceTransformer]).transformed[0];
|
|
1940
|
+
}
|
|
1941
|
+
emitTypeReference(type) {
|
|
1942
|
+
const translatedType = this.translator(type);
|
|
1943
|
+
if (translatedType === null) {
|
|
1944
|
+
throw new Error("Unable to emit an unresolved reference");
|
|
1945
|
+
}
|
|
1946
|
+
let typeArguments = void 0;
|
|
1947
|
+
if (type.typeArguments !== void 0) {
|
|
1948
|
+
typeArguments = ts11.factory.createNodeArray(type.typeArguments.map((typeArg) => this.emitType(typeArg)));
|
|
1949
|
+
}
|
|
1950
|
+
return ts11.factory.updateTypeReferenceNode(type, translatedType.typeName, typeArguments);
|
|
1951
|
+
}
|
|
1952
|
+
};
|
|
1953
|
+
|
|
1954
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
|
|
1955
|
+
import * as o2 from "@angular/compiler";
|
|
1956
|
+
import ts13 from "typescript";
|
|
1957
|
+
|
|
1958
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/ts_util.mjs
|
|
1959
|
+
import ts12 from "typescript";
|
|
1960
|
+
function tsNumericExpression(value) {
|
|
1961
|
+
if (value < 0) {
|
|
1962
|
+
const operand = ts12.factory.createNumericLiteral(Math.abs(value));
|
|
1963
|
+
return ts12.factory.createPrefixUnaryExpression(ts12.SyntaxKind.MinusToken, operand);
|
|
1964
|
+
}
|
|
1965
|
+
return ts12.factory.createNumericLiteral(value);
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
|
|
1969
|
+
function translateType(type, contextFile, reflector, refEmitter, imports) {
|
|
1970
|
+
return type.visitType(new TypeTranslatorVisitor(imports, contextFile, reflector, refEmitter), new Context(false));
|
|
1971
|
+
}
|
|
1972
|
+
var TypeTranslatorVisitor = class {
|
|
1973
|
+
constructor(imports, contextFile, reflector, refEmitter) {
|
|
1974
|
+
this.imports = imports;
|
|
1975
|
+
this.contextFile = contextFile;
|
|
1976
|
+
this.reflector = reflector;
|
|
1977
|
+
this.refEmitter = refEmitter;
|
|
1978
|
+
}
|
|
1979
|
+
visitBuiltinType(type, context) {
|
|
1980
|
+
switch (type.name) {
|
|
1981
|
+
case o2.BuiltinTypeName.Bool:
|
|
1982
|
+
return ts13.factory.createKeywordTypeNode(ts13.SyntaxKind.BooleanKeyword);
|
|
1983
|
+
case o2.BuiltinTypeName.Dynamic:
|
|
1984
|
+
return ts13.factory.createKeywordTypeNode(ts13.SyntaxKind.AnyKeyword);
|
|
1985
|
+
case o2.BuiltinTypeName.Int:
|
|
1986
|
+
case o2.BuiltinTypeName.Number:
|
|
1987
|
+
return ts13.factory.createKeywordTypeNode(ts13.SyntaxKind.NumberKeyword);
|
|
1988
|
+
case o2.BuiltinTypeName.String:
|
|
1989
|
+
return ts13.factory.createKeywordTypeNode(ts13.SyntaxKind.StringKeyword);
|
|
1990
|
+
case o2.BuiltinTypeName.None:
|
|
1991
|
+
return ts13.factory.createKeywordTypeNode(ts13.SyntaxKind.NeverKeyword);
|
|
1992
|
+
default:
|
|
1993
|
+
throw new Error(`Unsupported builtin type: ${o2.BuiltinTypeName[type.name]}`);
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
visitExpressionType(type, context) {
|
|
1997
|
+
const typeNode = this.translateExpression(type.value, context);
|
|
1998
|
+
if (type.typeParams === null) {
|
|
1999
|
+
return typeNode;
|
|
2000
|
+
}
|
|
2001
|
+
if (!ts13.isTypeReferenceNode(typeNode)) {
|
|
2002
|
+
throw new Error("An ExpressionType with type arguments must translate into a TypeReferenceNode");
|
|
2003
|
+
} else if (typeNode.typeArguments !== void 0) {
|
|
2004
|
+
throw new Error(`An ExpressionType with type arguments cannot have multiple levels of type arguments`);
|
|
2005
|
+
}
|
|
2006
|
+
const typeArgs = type.typeParams.map((param) => this.translateType(param, context));
|
|
2007
|
+
return ts13.factory.createTypeReferenceNode(typeNode.typeName, typeArgs);
|
|
2008
|
+
}
|
|
2009
|
+
visitArrayType(type, context) {
|
|
2010
|
+
return ts13.factory.createArrayTypeNode(this.translateType(type.of, context));
|
|
2011
|
+
}
|
|
2012
|
+
visitMapType(type, context) {
|
|
2013
|
+
const parameter = ts13.factory.createParameterDeclaration(void 0, void 0, "key", void 0, ts13.factory.createKeywordTypeNode(ts13.SyntaxKind.StringKeyword));
|
|
2014
|
+
const typeArgs = type.valueType !== null ? this.translateType(type.valueType, context) : ts13.factory.createKeywordTypeNode(ts13.SyntaxKind.UnknownKeyword);
|
|
2015
|
+
const indexSignature = ts13.factory.createIndexSignature(void 0, [parameter], typeArgs);
|
|
2016
|
+
return ts13.factory.createTypeLiteralNode([indexSignature]);
|
|
2017
|
+
}
|
|
2018
|
+
visitTransplantedType(ast, context) {
|
|
2019
|
+
const node = ast.type instanceof Reference ? ast.type.node : ast.type;
|
|
2020
|
+
if (!ts13.isTypeNode(node)) {
|
|
2021
|
+
throw new Error(`A TransplantedType must wrap a TypeNode`);
|
|
2022
|
+
}
|
|
2023
|
+
const viaModule = ast.type instanceof Reference ? ast.type.bestGuessOwningModule : null;
|
|
2024
|
+
const emitter = new TypeEmitter((typeRef) => this.translateTypeReference(typeRef, context, viaModule));
|
|
2025
|
+
return emitter.emitType(node);
|
|
2026
|
+
}
|
|
2027
|
+
visitReadVarExpr(ast, context) {
|
|
2028
|
+
if (ast.name === null) {
|
|
2029
|
+
throw new Error(`ReadVarExpr with no variable name in type`);
|
|
2030
|
+
}
|
|
2031
|
+
return ts13.factory.createTypeQueryNode(ts13.factory.createIdentifier(ast.name));
|
|
2032
|
+
}
|
|
2033
|
+
visitWriteVarExpr(expr, context) {
|
|
2034
|
+
throw new Error("Method not implemented.");
|
|
2035
|
+
}
|
|
2036
|
+
visitWriteKeyExpr(expr, context) {
|
|
2037
|
+
throw new Error("Method not implemented.");
|
|
2038
|
+
}
|
|
2039
|
+
visitWritePropExpr(expr, context) {
|
|
2040
|
+
throw new Error("Method not implemented.");
|
|
2041
|
+
}
|
|
2042
|
+
visitInvokeFunctionExpr(ast, context) {
|
|
2043
|
+
throw new Error("Method not implemented.");
|
|
2044
|
+
}
|
|
2045
|
+
visitTaggedTemplateExpr(ast, context) {
|
|
2046
|
+
throw new Error("Method not implemented.");
|
|
2047
|
+
}
|
|
2048
|
+
visitInstantiateExpr(ast, context) {
|
|
2049
|
+
throw new Error("Method not implemented.");
|
|
2050
|
+
}
|
|
2051
|
+
visitLiteralExpr(ast, context) {
|
|
2052
|
+
if (ast.value === null) {
|
|
2053
|
+
return ts13.factory.createLiteralTypeNode(ts13.factory.createNull());
|
|
2054
|
+
} else if (ast.value === void 0) {
|
|
2055
|
+
return ts13.factory.createKeywordTypeNode(ts13.SyntaxKind.UndefinedKeyword);
|
|
2056
|
+
} else if (typeof ast.value === "boolean") {
|
|
2057
|
+
return ts13.factory.createLiteralTypeNode(ast.value ? ts13.factory.createTrue() : ts13.factory.createFalse());
|
|
2058
|
+
} else if (typeof ast.value === "number") {
|
|
2059
|
+
return ts13.factory.createLiteralTypeNode(tsNumericExpression(ast.value));
|
|
2060
|
+
} else {
|
|
2061
|
+
return ts13.factory.createLiteralTypeNode(ts13.factory.createStringLiteral(ast.value));
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
visitLocalizedString(ast, context) {
|
|
2065
|
+
throw new Error("Method not implemented.");
|
|
2066
|
+
}
|
|
2067
|
+
visitExternalExpr(ast, context) {
|
|
2068
|
+
if (ast.value.moduleName === null || ast.value.name === null) {
|
|
2069
|
+
throw new Error(`Import unknown module or symbol`);
|
|
2070
|
+
}
|
|
2071
|
+
const { moduleImport, symbol } = this.imports.generateNamedImport(ast.value.moduleName, ast.value.name);
|
|
2072
|
+
const symbolIdentifier = ts13.factory.createIdentifier(symbol);
|
|
2073
|
+
const typeName = moduleImport ? ts13.factory.createQualifiedName(moduleImport, symbolIdentifier) : symbolIdentifier;
|
|
2074
|
+
const typeArguments = ast.typeParams !== null ? ast.typeParams.map((type) => this.translateType(type, context)) : void 0;
|
|
2075
|
+
return ts13.factory.createTypeReferenceNode(typeName, typeArguments);
|
|
2076
|
+
}
|
|
2077
|
+
visitConditionalExpr(ast, context) {
|
|
2078
|
+
throw new Error("Method not implemented.");
|
|
2079
|
+
}
|
|
2080
|
+
visitDynamicImportExpr(ast, context) {
|
|
2081
|
+
throw new Error("Method not implemented.");
|
|
2082
|
+
}
|
|
2083
|
+
visitNotExpr(ast, context) {
|
|
2084
|
+
throw new Error("Method not implemented.");
|
|
2085
|
+
}
|
|
2086
|
+
visitFunctionExpr(ast, context) {
|
|
2087
|
+
throw new Error("Method not implemented.");
|
|
2088
|
+
}
|
|
2089
|
+
visitArrowFunctionExpr(ast, context) {
|
|
2090
|
+
throw new Error("Method not implemented.");
|
|
2091
|
+
}
|
|
2092
|
+
visitUnaryOperatorExpr(ast, context) {
|
|
2093
|
+
throw new Error("Method not implemented.");
|
|
2094
|
+
}
|
|
2095
|
+
visitBinaryOperatorExpr(ast, context) {
|
|
2096
|
+
throw new Error("Method not implemented.");
|
|
2097
|
+
}
|
|
2098
|
+
visitReadPropExpr(ast, context) {
|
|
2099
|
+
throw new Error("Method not implemented.");
|
|
2100
|
+
}
|
|
2101
|
+
visitReadKeyExpr(ast, context) {
|
|
2102
|
+
throw new Error("Method not implemented.");
|
|
2103
|
+
}
|
|
2104
|
+
visitLiteralArrayExpr(ast, context) {
|
|
2105
|
+
const values = ast.entries.map((expr) => this.translateExpression(expr, context));
|
|
2106
|
+
return ts13.factory.createTupleTypeNode(values);
|
|
2107
|
+
}
|
|
2108
|
+
visitLiteralMapExpr(ast, context) {
|
|
2109
|
+
const entries = ast.entries.map((entry) => {
|
|
2110
|
+
const { key, quoted } = entry;
|
|
2111
|
+
const type = this.translateExpression(entry.value, context);
|
|
2112
|
+
return ts13.factory.createPropertySignature(
|
|
2113
|
+
void 0,
|
|
2114
|
+
quoted ? ts13.factory.createStringLiteral(key) : key,
|
|
2115
|
+
void 0,
|
|
2116
|
+
type
|
|
2117
|
+
);
|
|
2118
|
+
});
|
|
2119
|
+
return ts13.factory.createTypeLiteralNode(entries);
|
|
2120
|
+
}
|
|
2121
|
+
visitCommaExpr(ast, context) {
|
|
2122
|
+
throw new Error("Method not implemented.");
|
|
2123
|
+
}
|
|
2124
|
+
visitWrappedNodeExpr(ast, context) {
|
|
2125
|
+
const node = ast.node;
|
|
2126
|
+
if (ts13.isEntityName(node)) {
|
|
2127
|
+
return ts13.factory.createTypeReferenceNode(node, void 0);
|
|
2128
|
+
} else if (ts13.isTypeNode(node)) {
|
|
2129
|
+
return node;
|
|
2130
|
+
} else if (ts13.isLiteralExpression(node)) {
|
|
2131
|
+
return ts13.factory.createLiteralTypeNode(node);
|
|
2132
|
+
} else {
|
|
2133
|
+
throw new Error(`Unsupported WrappedNodeExpr in TypeTranslatorVisitor: ${ts13.SyntaxKind[node.kind]}`);
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
visitTypeofExpr(ast, context) {
|
|
2137
|
+
const typeNode = this.translateExpression(ast.expr, context);
|
|
2138
|
+
if (!ts13.isTypeReferenceNode(typeNode)) {
|
|
2139
|
+
throw new Error(`The target of a typeof expression must be a type reference, but it was
|
|
2140
|
+
${ts13.SyntaxKind[typeNode.kind]}`);
|
|
2141
|
+
}
|
|
2142
|
+
return ts13.factory.createTypeQueryNode(typeNode.typeName);
|
|
2143
|
+
}
|
|
2144
|
+
translateType(type, context) {
|
|
2145
|
+
const typeNode = type.visitType(this, context);
|
|
2146
|
+
if (!ts13.isTypeNode(typeNode)) {
|
|
2147
|
+
throw new Error(`A Type must translate to a TypeNode, but was ${ts13.SyntaxKind[typeNode.kind]}`);
|
|
2148
|
+
}
|
|
2149
|
+
return typeNode;
|
|
2150
|
+
}
|
|
2151
|
+
translateExpression(expr, context) {
|
|
2152
|
+
const typeNode = expr.visitExpression(this, context);
|
|
2153
|
+
if (!ts13.isTypeNode(typeNode)) {
|
|
2154
|
+
throw new Error(`An Expression must translate to a TypeNode, but was ${ts13.SyntaxKind[typeNode.kind]}`);
|
|
2155
|
+
}
|
|
2156
|
+
return typeNode;
|
|
2157
|
+
}
|
|
2158
|
+
translateTypeReference(type, context, viaModule) {
|
|
2159
|
+
const target = ts13.isIdentifier(type.typeName) ? type.typeName : type.typeName.right;
|
|
2160
|
+
const declaration = this.reflector.getDeclarationOfIdentifier(target);
|
|
2161
|
+
if (declaration === null) {
|
|
2162
|
+
throw new Error(`Unable to statically determine the declaration file of type node ${target.text}`);
|
|
2163
|
+
}
|
|
2164
|
+
let owningModule = viaModule;
|
|
2165
|
+
if (typeof declaration.viaModule === "string") {
|
|
2166
|
+
owningModule = {
|
|
2167
|
+
specifier: declaration.viaModule,
|
|
2168
|
+
resolutionContext: type.getSourceFile().fileName
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
const reference = new Reference(declaration.node, declaration.viaModule === AmbientImport ? AmbientImport : owningModule);
|
|
2172
|
+
const emittedType = this.refEmitter.emit(reference, this.contextFile, ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowAmbientReferences);
|
|
2173
|
+
assertSuccessfulReferenceEmit(emittedType, target, "type");
|
|
2174
|
+
const typeNode = this.translateExpression(emittedType.expression, context);
|
|
2175
|
+
if (!ts13.isTypeReferenceNode(typeNode)) {
|
|
2176
|
+
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${ts13.SyntaxKind[typeNode.kind]}.`);
|
|
2177
|
+
}
|
|
2178
|
+
return typeNode;
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2181
|
+
|
|
2182
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.mjs
|
|
2183
|
+
import ts14 from "typescript";
|
|
2184
|
+
var PureAnnotation;
|
|
2185
|
+
(function(PureAnnotation2) {
|
|
2186
|
+
PureAnnotation2["CLOSURE"] = "* @pureOrBreakMyCode ";
|
|
2187
|
+
PureAnnotation2["TERSER"] = "@__PURE__";
|
|
2188
|
+
})(PureAnnotation || (PureAnnotation = {}));
|
|
2189
|
+
var UNARY_OPERATORS2 = {
|
|
2190
|
+
"+": ts14.SyntaxKind.PlusToken,
|
|
2191
|
+
"-": ts14.SyntaxKind.MinusToken,
|
|
2192
|
+
"!": ts14.SyntaxKind.ExclamationToken
|
|
2193
|
+
};
|
|
2194
|
+
var BINARY_OPERATORS2 = {
|
|
2195
|
+
"&&": ts14.SyntaxKind.AmpersandAmpersandToken,
|
|
2196
|
+
">": ts14.SyntaxKind.GreaterThanToken,
|
|
2197
|
+
">=": ts14.SyntaxKind.GreaterThanEqualsToken,
|
|
2198
|
+
"&": ts14.SyntaxKind.AmpersandToken,
|
|
2199
|
+
"|": ts14.SyntaxKind.BarToken,
|
|
2200
|
+
"/": ts14.SyntaxKind.SlashToken,
|
|
2201
|
+
"==": ts14.SyntaxKind.EqualsEqualsToken,
|
|
2202
|
+
"===": ts14.SyntaxKind.EqualsEqualsEqualsToken,
|
|
2203
|
+
"<": ts14.SyntaxKind.LessThanToken,
|
|
2204
|
+
"<=": ts14.SyntaxKind.LessThanEqualsToken,
|
|
2205
|
+
"-": ts14.SyntaxKind.MinusToken,
|
|
2206
|
+
"%": ts14.SyntaxKind.PercentToken,
|
|
2207
|
+
"*": ts14.SyntaxKind.AsteriskToken,
|
|
2208
|
+
"!=": ts14.SyntaxKind.ExclamationEqualsToken,
|
|
2209
|
+
"!==": ts14.SyntaxKind.ExclamationEqualsEqualsToken,
|
|
2210
|
+
"||": ts14.SyntaxKind.BarBarToken,
|
|
2211
|
+
"+": ts14.SyntaxKind.PlusToken,
|
|
2212
|
+
"??": ts14.SyntaxKind.QuestionQuestionToken
|
|
2213
|
+
};
|
|
2214
|
+
var VAR_TYPES = {
|
|
2215
|
+
"const": ts14.NodeFlags.Const,
|
|
2216
|
+
"let": ts14.NodeFlags.Let,
|
|
2217
|
+
"var": ts14.NodeFlags.None
|
|
2218
|
+
};
|
|
2219
|
+
var TypeScriptAstFactory = class {
|
|
2220
|
+
constructor(annotateForClosureCompiler) {
|
|
2221
|
+
this.annotateForClosureCompiler = annotateForClosureCompiler;
|
|
2222
|
+
this.externalSourceFiles = /* @__PURE__ */ new Map();
|
|
2223
|
+
this.attachComments = attachComments;
|
|
2224
|
+
this.createArrayLiteral = ts14.factory.createArrayLiteralExpression;
|
|
2225
|
+
this.createElementAccess = ts14.factory.createElementAccessExpression;
|
|
2226
|
+
this.createExpressionStatement = ts14.factory.createExpressionStatement;
|
|
2227
|
+
this.createIdentifier = ts14.factory.createIdentifier;
|
|
2228
|
+
this.createParenthesizedExpression = ts14.factory.createParenthesizedExpression;
|
|
2229
|
+
this.createPropertyAccess = ts14.factory.createPropertyAccessExpression;
|
|
2230
|
+
this.createThrowStatement = ts14.factory.createThrowStatement;
|
|
2231
|
+
this.createTypeOfExpression = ts14.factory.createTypeOfExpression;
|
|
2232
|
+
}
|
|
2233
|
+
createAssignment(target, value) {
|
|
2234
|
+
return ts14.factory.createBinaryExpression(target, ts14.SyntaxKind.EqualsToken, value);
|
|
2235
|
+
}
|
|
2236
|
+
createBinaryExpression(leftOperand, operator, rightOperand) {
|
|
2237
|
+
return ts14.factory.createBinaryExpression(leftOperand, BINARY_OPERATORS2[operator], rightOperand);
|
|
2238
|
+
}
|
|
2239
|
+
createBlock(body) {
|
|
2240
|
+
return ts14.factory.createBlock(body);
|
|
2241
|
+
}
|
|
2242
|
+
createCallExpression(callee, args, pure) {
|
|
2243
|
+
const call = ts14.factory.createCallExpression(callee, void 0, args);
|
|
2244
|
+
if (pure) {
|
|
2245
|
+
ts14.addSyntheticLeadingComment(
|
|
2246
|
+
call,
|
|
2247
|
+
ts14.SyntaxKind.MultiLineCommentTrivia,
|
|
2248
|
+
this.annotateForClosureCompiler ? PureAnnotation.CLOSURE : PureAnnotation.TERSER,
|
|
2249
|
+
false
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2252
|
+
return call;
|
|
2253
|
+
}
|
|
2254
|
+
createConditional(condition, whenTrue, whenFalse) {
|
|
2255
|
+
return ts14.factory.createConditionalExpression(condition, void 0, whenTrue, void 0, whenFalse);
|
|
2256
|
+
}
|
|
2257
|
+
createDynamicImport(url) {
|
|
2258
|
+
return ts14.factory.createCallExpression(
|
|
2259
|
+
ts14.factory.createToken(ts14.SyntaxKind.ImportKeyword),
|
|
2260
|
+
void 0,
|
|
2261
|
+
[ts14.factory.createStringLiteral(url)]
|
|
2262
|
+
);
|
|
2263
|
+
}
|
|
2264
|
+
createFunctionDeclaration(functionName, parameters, body) {
|
|
2265
|
+
if (!ts14.isBlock(body)) {
|
|
2266
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts14.SyntaxKind[body.kind]}.`);
|
|
2267
|
+
}
|
|
2268
|
+
return ts14.factory.createFunctionDeclaration(void 0, void 0, functionName, void 0, parameters.map((param) => ts14.factory.createParameterDeclaration(void 0, void 0, param)), void 0, body);
|
|
2269
|
+
}
|
|
2270
|
+
createFunctionExpression(functionName, parameters, body) {
|
|
2271
|
+
if (!ts14.isBlock(body)) {
|
|
2272
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts14.SyntaxKind[body.kind]}.`);
|
|
2273
|
+
}
|
|
2274
|
+
return ts14.factory.createFunctionExpression(void 0, void 0, functionName != null ? functionName : void 0, void 0, parameters.map((param) => ts14.factory.createParameterDeclaration(void 0, void 0, param)), void 0, body);
|
|
2275
|
+
}
|
|
2276
|
+
createArrowFunctionExpression(parameters, body) {
|
|
2277
|
+
if (ts14.isStatement(body) && !ts14.isBlock(body)) {
|
|
2278
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts14.SyntaxKind[body.kind]}.`);
|
|
2279
|
+
}
|
|
2280
|
+
return ts14.factory.createArrowFunction(void 0, void 0, parameters.map((param) => ts14.factory.createParameterDeclaration(void 0, void 0, param)), void 0, void 0, body);
|
|
2281
|
+
}
|
|
2282
|
+
createIfStatement(condition, thenStatement, elseStatement) {
|
|
2283
|
+
return ts14.factory.createIfStatement(condition, thenStatement, elseStatement != null ? elseStatement : void 0);
|
|
2284
|
+
}
|
|
2285
|
+
createLiteral(value) {
|
|
2286
|
+
if (value === void 0) {
|
|
2287
|
+
return ts14.factory.createIdentifier("undefined");
|
|
2288
|
+
} else if (value === null) {
|
|
2289
|
+
return ts14.factory.createNull();
|
|
2290
|
+
} else if (typeof value === "boolean") {
|
|
2291
|
+
return value ? ts14.factory.createTrue() : ts14.factory.createFalse();
|
|
2292
|
+
} else if (typeof value === "number") {
|
|
2293
|
+
return tsNumericExpression(value);
|
|
2294
|
+
} else {
|
|
2295
|
+
return ts14.factory.createStringLiteral(value);
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
createNewExpression(expression, args) {
|
|
2299
|
+
return ts14.factory.createNewExpression(expression, void 0, args);
|
|
2300
|
+
}
|
|
2301
|
+
createObjectLiteral(properties) {
|
|
2302
|
+
return ts14.factory.createObjectLiteralExpression(properties.map((prop) => ts14.factory.createPropertyAssignment(prop.quoted ? ts14.factory.createStringLiteral(prop.propertyName) : ts14.factory.createIdentifier(prop.propertyName), prop.value)));
|
|
2303
|
+
}
|
|
2304
|
+
createReturnStatement(expression) {
|
|
2305
|
+
return ts14.factory.createReturnStatement(expression != null ? expression : void 0);
|
|
2306
|
+
}
|
|
2307
|
+
createTaggedTemplate(tag, template) {
|
|
2308
|
+
let templateLiteral;
|
|
2309
|
+
const length = template.elements.length;
|
|
2310
|
+
const head = template.elements[0];
|
|
2311
|
+
if (length === 1) {
|
|
2312
|
+
templateLiteral = ts14.factory.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
|
|
2313
|
+
} else {
|
|
2314
|
+
const spans = [];
|
|
2315
|
+
for (let i = 1; i < length - 1; i++) {
|
|
2316
|
+
const { cooked, raw, range } = template.elements[i];
|
|
2317
|
+
const middle = createTemplateMiddle(cooked, raw);
|
|
2318
|
+
if (range !== null) {
|
|
2319
|
+
this.setSourceMapRange(middle, range);
|
|
2320
|
+
}
|
|
2321
|
+
spans.push(ts14.factory.createTemplateSpan(template.expressions[i - 1], middle));
|
|
2322
|
+
}
|
|
2323
|
+
const resolvedExpression = template.expressions[length - 2];
|
|
2324
|
+
const templatePart = template.elements[length - 1];
|
|
2325
|
+
const templateTail = createTemplateTail(templatePart.cooked, templatePart.raw);
|
|
2326
|
+
if (templatePart.range !== null) {
|
|
2327
|
+
this.setSourceMapRange(templateTail, templatePart.range);
|
|
2328
|
+
}
|
|
2329
|
+
spans.push(ts14.factory.createTemplateSpan(resolvedExpression, templateTail));
|
|
2330
|
+
templateLiteral = ts14.factory.createTemplateExpression(ts14.factory.createTemplateHead(head.cooked, head.raw), spans);
|
|
2331
|
+
}
|
|
2332
|
+
if (head.range !== null) {
|
|
2333
|
+
this.setSourceMapRange(templateLiteral, head.range);
|
|
2334
|
+
}
|
|
2335
|
+
return ts14.factory.createTaggedTemplateExpression(tag, void 0, templateLiteral);
|
|
2336
|
+
}
|
|
2337
|
+
createUnaryExpression(operator, operand) {
|
|
2338
|
+
return ts14.factory.createPrefixUnaryExpression(UNARY_OPERATORS2[operator], operand);
|
|
2339
|
+
}
|
|
2340
|
+
createVariableDeclaration(variableName, initializer, type) {
|
|
2341
|
+
return ts14.factory.createVariableStatement(void 0, ts14.factory.createVariableDeclarationList([ts14.factory.createVariableDeclaration(variableName, void 0, void 0, initializer != null ? initializer : void 0)], VAR_TYPES[type]));
|
|
2342
|
+
}
|
|
2343
|
+
setSourceMapRange(node, sourceMapRange) {
|
|
2344
|
+
if (sourceMapRange === null) {
|
|
2345
|
+
return node;
|
|
2346
|
+
}
|
|
2347
|
+
const url = sourceMapRange.url;
|
|
2348
|
+
if (!this.externalSourceFiles.has(url)) {
|
|
2349
|
+
this.externalSourceFiles.set(url, ts14.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
|
|
2350
|
+
}
|
|
2351
|
+
const source = this.externalSourceFiles.get(url);
|
|
2352
|
+
ts14.setSourceMapRange(node, { pos: sourceMapRange.start.offset, end: sourceMapRange.end.offset, source });
|
|
2353
|
+
return node;
|
|
2354
|
+
}
|
|
2355
|
+
};
|
|
2356
|
+
function createTemplateMiddle(cooked, raw) {
|
|
2357
|
+
const node = ts14.factory.createTemplateHead(cooked, raw);
|
|
2358
|
+
node.kind = ts14.SyntaxKind.TemplateMiddle;
|
|
2359
|
+
return node;
|
|
2360
|
+
}
|
|
2361
|
+
function createTemplateTail(cooked, raw) {
|
|
2362
|
+
const node = ts14.factory.createTemplateHead(cooked, raw);
|
|
2363
|
+
node.kind = ts14.SyntaxKind.TemplateTail;
|
|
2364
|
+
return node;
|
|
2365
|
+
}
|
|
2366
|
+
function attachComments(statement, leadingComments) {
|
|
2367
|
+
for (const comment of leadingComments) {
|
|
2368
|
+
const commentKind = comment.multiline ? ts14.SyntaxKind.MultiLineCommentTrivia : ts14.SyntaxKind.SingleLineCommentTrivia;
|
|
2369
|
+
if (comment.multiline) {
|
|
2370
|
+
ts14.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
|
|
2371
|
+
} else {
|
|
2372
|
+
for (const line of comment.toString().split("\n")) {
|
|
2373
|
+
ts14.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_translator.mjs
|
|
2380
|
+
function translateExpression(expression, imports, options = {}) {
|
|
2381
|
+
return expression.visitExpression(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(false));
|
|
2382
|
+
}
|
|
2383
|
+
function translateStatement(statement, imports, options = {}) {
|
|
2384
|
+
return statement.visitStatement(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(true));
|
|
2385
|
+
}
|
|
2386
|
+
|
|
1587
2387
|
export {
|
|
1588
2388
|
ErrorCode,
|
|
1589
2389
|
COMPILER_ERRORS_WITH_GUIDES,
|
|
@@ -1640,8 +2440,23 @@ export {
|
|
|
1640
2440
|
reflectObjectLiteral,
|
|
1641
2441
|
DeferredSymbolTracker,
|
|
1642
2442
|
Reference,
|
|
1643
|
-
ModuleResolver
|
|
2443
|
+
ModuleResolver,
|
|
2444
|
+
Context,
|
|
2445
|
+
ImportManager,
|
|
2446
|
+
ExpressionTranslatorVisitor,
|
|
2447
|
+
canEmitType,
|
|
2448
|
+
TypeEmitter,
|
|
2449
|
+
translateType,
|
|
2450
|
+
translateExpression,
|
|
2451
|
+
translateStatement
|
|
1644
2452
|
};
|
|
2453
|
+
/*!
|
|
2454
|
+
* @license
|
|
2455
|
+
* Copyright Google LLC All Rights Reserved.
|
|
2456
|
+
*
|
|
2457
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
2458
|
+
* found in the LICENSE file at https://angular.io/license
|
|
2459
|
+
*/
|
|
1645
2460
|
/**
|
|
1646
2461
|
* @license
|
|
1647
2462
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -1649,4 +2464,4 @@ export {
|
|
|
1649
2464
|
* Use of this source code is governed by an MIT-style license that can be
|
|
1650
2465
|
* found in the LICENSE file at https://angular.io/license
|
|
1651
2466
|
*/
|
|
1652
|
-
//# sourceMappingURL=chunk-
|
|
2467
|
+
//# sourceMappingURL=chunk-OQ7ITPZT.js.map
|