@angular/compiler-cli 15.2.0-next.4 → 15.2.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-HYFCMILZ.js → chunk-2OF2AI57.js} +11 -9
- package/bundles/chunk-2OF2AI57.js.map +6 -0
- package/bundles/{chunk-64X67E3N.js → chunk-2PLRZDNU.js} +4 -4
- package/bundles/{chunk-Q6W3UCXI.js → chunk-J3L7WZP3.js} +91 -124
- package/bundles/chunk-J3L7WZP3.js.map +6 -0
- package/bundles/{chunk-BEXFRTBC.js → chunk-MLCT4AWL.js} +3 -3
- package/bundles/{chunk-OAZD7RII.js → chunk-NXCQCU6C.js} +9 -7
- package/bundles/chunk-NXCQCU6C.js.map +6 -0
- package/bundles/{chunk-ZB4CDKOH.js → chunk-P6SWFK2U.js} +2 -2
- package/bundles/{chunk-JYL7IHZC.js → chunk-PKSKJEUS.js} +10 -8
- package/bundles/chunk-PKSKJEUS.js.map +6 -0
- package/bundles/chunk-QRHWLC7U.js +714 -0
- package/bundles/chunk-QRHWLC7U.js.map +6 -0
- package/bundles/chunk-ZCBRXUPO.js +877 -0
- package/bundles/chunk-ZCBRXUPO.js.map +6 -0
- package/bundles/index.js +6 -5
- package/bundles/index.js.map +1 -1
- package/bundles/linker/babel/index.js +3 -2
- package/bundles/linker/babel/index.js.map +1 -1
- package/bundles/linker/index.js +3 -2
- package/bundles/ngcc/index.js +6 -5
- package/bundles/ngcc/index.js.map +1 -1
- package/bundles/ngcc/main-ngcc.js +6 -5
- package/bundles/ngcc/main-ngcc.js.map +1 -1
- package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js +5 -4
- package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js.map +1 -1
- package/bundles/private/migrations.js +3 -2
- package/bundles/private/tooling.js +3 -1
- package/bundles/src/bin/ng_xi18n.js +5 -4
- package/bundles/src/bin/ng_xi18n.js.map +1 -1
- package/bundles/src/bin/ngc.js +5 -4
- package/bundles/src/bin/ngc.js.map +1 -1
- package/bundles_metadata.json +1 -1
- package/ngcc/src/packages/build_marker.d.ts +1 -1
- package/package.json +2 -2
- package/src/ngtsc/imports/index.d.ts +1 -0
- package/src/ngtsc/imports/src/default.d.ts +6 -10
- package/src/ngtsc/imports/src/patch_alias_reference_resolution.d.ts +61 -0
- package/bundles/chunk-HYFCMILZ.js.map +0 -6
- package/bundles/chunk-JYL7IHZC.js.map +0 -6
- package/bundles/chunk-OAZD7RII.js.map +0 -6
- package/bundles/chunk-Q6W3UCXI.js.map +0 -6
- package/bundles/chunk-Z534TW2O.js +0 -1540
- package/bundles/chunk-Z534TW2O.js.map +0 -6
- package/src/transformers/downlevel_decorators_transform/patch_alias_reference_resolution.d.ts +0 -14
- /package/bundles/{chunk-64X67E3N.js.map → chunk-2PLRZDNU.js.map} +0 -0
- /package/bundles/{chunk-BEXFRTBC.js.map → chunk-MLCT4AWL.js.map} +0 -0
- /package/bundles/{chunk-ZB4CDKOH.js.map → chunk-P6SWFK2U.js.map} +0 -0
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
|
|
2
|
+
import {createRequire as __cjsCompatRequire} from 'module';
|
|
3
|
+
const require = __cjsCompatRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
NoopImportRewriter
|
|
7
|
+
} from "./chunk-ZCBRXUPO.js";
|
|
8
|
+
|
|
9
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/context.mjs
|
|
10
|
+
var Context = class {
|
|
11
|
+
constructor(isStatement) {
|
|
12
|
+
this.isStatement = isStatement;
|
|
13
|
+
}
|
|
14
|
+
get withExpressionMode() {
|
|
15
|
+
return this.isStatement ? new Context(false) : this;
|
|
16
|
+
}
|
|
17
|
+
get withStatementMode() {
|
|
18
|
+
return !this.isStatement ? new Context(true) : this;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/translator.mjs
|
|
23
|
+
import * as o from "@angular/compiler";
|
|
24
|
+
var UNARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
25
|
+
[o.UnaryOperator.Minus, "-"],
|
|
26
|
+
[o.UnaryOperator.Plus, "+"]
|
|
27
|
+
]);
|
|
28
|
+
var BINARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
29
|
+
[o.BinaryOperator.And, "&&"],
|
|
30
|
+
[o.BinaryOperator.Bigger, ">"],
|
|
31
|
+
[o.BinaryOperator.BiggerEquals, ">="],
|
|
32
|
+
[o.BinaryOperator.BitwiseAnd, "&"],
|
|
33
|
+
[o.BinaryOperator.Divide, "/"],
|
|
34
|
+
[o.BinaryOperator.Equals, "=="],
|
|
35
|
+
[o.BinaryOperator.Identical, "==="],
|
|
36
|
+
[o.BinaryOperator.Lower, "<"],
|
|
37
|
+
[o.BinaryOperator.LowerEquals, "<="],
|
|
38
|
+
[o.BinaryOperator.Minus, "-"],
|
|
39
|
+
[o.BinaryOperator.Modulo, "%"],
|
|
40
|
+
[o.BinaryOperator.Multiply, "*"],
|
|
41
|
+
[o.BinaryOperator.NotEquals, "!="],
|
|
42
|
+
[o.BinaryOperator.NotIdentical, "!=="],
|
|
43
|
+
[o.BinaryOperator.Or, "||"],
|
|
44
|
+
[o.BinaryOperator.Plus, "+"],
|
|
45
|
+
[o.BinaryOperator.NullishCoalesce, "??"]
|
|
46
|
+
]);
|
|
47
|
+
var ExpressionTranslatorVisitor = class {
|
|
48
|
+
constructor(factory, imports, options) {
|
|
49
|
+
this.factory = factory;
|
|
50
|
+
this.imports = imports;
|
|
51
|
+
this.downlevelTaggedTemplates = options.downlevelTaggedTemplates === true;
|
|
52
|
+
this.downlevelVariableDeclarations = options.downlevelVariableDeclarations === true;
|
|
53
|
+
this.recordWrappedNode = options.recordWrappedNode || (() => {
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
visitDeclareVarStmt(stmt, context) {
|
|
57
|
+
var _a;
|
|
58
|
+
const varType = this.downlevelVariableDeclarations ? "var" : stmt.hasModifier(o.StmtModifier.Final) ? "const" : "let";
|
|
59
|
+
return this.attachComments(this.factory.createVariableDeclaration(stmt.name, (_a = stmt.value) == null ? void 0 : _a.visitExpression(this, context.withExpressionMode), varType), stmt.leadingComments);
|
|
60
|
+
}
|
|
61
|
+
visitDeclareFunctionStmt(stmt, context) {
|
|
62
|
+
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);
|
|
63
|
+
}
|
|
64
|
+
visitExpressionStmt(stmt, context) {
|
|
65
|
+
return this.attachComments(this.factory.createExpressionStatement(stmt.expr.visitExpression(this, context.withStatementMode)), stmt.leadingComments);
|
|
66
|
+
}
|
|
67
|
+
visitReturnStmt(stmt, context) {
|
|
68
|
+
return this.attachComments(this.factory.createReturnStatement(stmt.value.visitExpression(this, context.withExpressionMode)), stmt.leadingComments);
|
|
69
|
+
}
|
|
70
|
+
visitIfStmt(stmt, context) {
|
|
71
|
+
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);
|
|
72
|
+
}
|
|
73
|
+
visitReadVarExpr(ast, _context) {
|
|
74
|
+
const identifier = this.factory.createIdentifier(ast.name);
|
|
75
|
+
this.setSourceMapRange(identifier, ast.sourceSpan);
|
|
76
|
+
return identifier;
|
|
77
|
+
}
|
|
78
|
+
visitWriteVarExpr(expr, context) {
|
|
79
|
+
const assignment = this.factory.createAssignment(this.setSourceMapRange(this.factory.createIdentifier(expr.name), expr.sourceSpan), expr.value.visitExpression(this, context));
|
|
80
|
+
return context.isStatement ? assignment : this.factory.createParenthesizedExpression(assignment);
|
|
81
|
+
}
|
|
82
|
+
visitWriteKeyExpr(expr, context) {
|
|
83
|
+
const exprContext = context.withExpressionMode;
|
|
84
|
+
const target = this.factory.createElementAccess(expr.receiver.visitExpression(this, exprContext), expr.index.visitExpression(this, exprContext));
|
|
85
|
+
const assignment = this.factory.createAssignment(target, expr.value.visitExpression(this, exprContext));
|
|
86
|
+
return context.isStatement ? assignment : this.factory.createParenthesizedExpression(assignment);
|
|
87
|
+
}
|
|
88
|
+
visitWritePropExpr(expr, context) {
|
|
89
|
+
const target = this.factory.createPropertyAccess(expr.receiver.visitExpression(this, context), expr.name);
|
|
90
|
+
return this.factory.createAssignment(target, expr.value.visitExpression(this, context));
|
|
91
|
+
}
|
|
92
|
+
visitInvokeFunctionExpr(ast, context) {
|
|
93
|
+
return this.setSourceMapRange(this.factory.createCallExpression(ast.fn.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)), ast.pure), ast.sourceSpan);
|
|
94
|
+
}
|
|
95
|
+
visitTaggedTemplateExpr(ast, context) {
|
|
96
|
+
return this.setSourceMapRange(this.createTaggedTemplateExpression(ast.tag.visitExpression(this, context), {
|
|
97
|
+
elements: ast.template.elements.map((e) => {
|
|
98
|
+
var _a;
|
|
99
|
+
return createTemplateElement({
|
|
100
|
+
cooked: e.text,
|
|
101
|
+
raw: e.rawText,
|
|
102
|
+
range: (_a = e.sourceSpan) != null ? _a : ast.sourceSpan
|
|
103
|
+
});
|
|
104
|
+
}),
|
|
105
|
+
expressions: ast.template.expressions.map((e) => e.visitExpression(this, context))
|
|
106
|
+
}), ast.sourceSpan);
|
|
107
|
+
}
|
|
108
|
+
visitInstantiateExpr(ast, context) {
|
|
109
|
+
return this.factory.createNewExpression(ast.classExpr.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)));
|
|
110
|
+
}
|
|
111
|
+
visitLiteralExpr(ast, _context) {
|
|
112
|
+
return this.setSourceMapRange(this.factory.createLiteral(ast.value), ast.sourceSpan);
|
|
113
|
+
}
|
|
114
|
+
visitLocalizedString(ast, context) {
|
|
115
|
+
const elements = [createTemplateElement(ast.serializeI18nHead())];
|
|
116
|
+
const expressions = [];
|
|
117
|
+
for (let i = 0; i < ast.expressions.length; i++) {
|
|
118
|
+
const placeholder = this.setSourceMapRange(ast.expressions[i].visitExpression(this, context), ast.getPlaceholderSourceSpan(i));
|
|
119
|
+
expressions.push(placeholder);
|
|
120
|
+
elements.push(createTemplateElement(ast.serializeI18nTemplatePart(i + 1)));
|
|
121
|
+
}
|
|
122
|
+
const localizeTag = this.factory.createIdentifier("$localize");
|
|
123
|
+
return this.setSourceMapRange(this.createTaggedTemplateExpression(localizeTag, { elements, expressions }), ast.sourceSpan);
|
|
124
|
+
}
|
|
125
|
+
createTaggedTemplateExpression(tag, template) {
|
|
126
|
+
return this.downlevelTaggedTemplates ? this.createES5TaggedTemplateFunctionCall(tag, template) : this.factory.createTaggedTemplate(tag, template);
|
|
127
|
+
}
|
|
128
|
+
createES5TaggedTemplateFunctionCall(tagHandler, { elements, expressions }) {
|
|
129
|
+
const { moduleImport, symbol } = this.imports.generateNamedImport("tslib", "__makeTemplateObject");
|
|
130
|
+
const __makeTemplateObjectHelper = moduleImport === null ? this.factory.createIdentifier(symbol) : this.factory.createPropertyAccess(moduleImport, symbol);
|
|
131
|
+
const cooked = [];
|
|
132
|
+
const raw = [];
|
|
133
|
+
for (const element of elements) {
|
|
134
|
+
cooked.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.cooked), element.range));
|
|
135
|
+
raw.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.raw), element.range));
|
|
136
|
+
}
|
|
137
|
+
const templateHelperCall = this.factory.createCallExpression(
|
|
138
|
+
__makeTemplateObjectHelper,
|
|
139
|
+
[this.factory.createArrayLiteral(cooked), this.factory.createArrayLiteral(raw)],
|
|
140
|
+
false
|
|
141
|
+
);
|
|
142
|
+
return this.factory.createCallExpression(
|
|
143
|
+
tagHandler,
|
|
144
|
+
[templateHelperCall, ...expressions],
|
|
145
|
+
false
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
visitExternalExpr(ast, _context) {
|
|
149
|
+
if (ast.value.name === null) {
|
|
150
|
+
if (ast.value.moduleName === null) {
|
|
151
|
+
throw new Error("Invalid import without name nor moduleName");
|
|
152
|
+
}
|
|
153
|
+
return this.imports.generateNamespaceImport(ast.value.moduleName);
|
|
154
|
+
}
|
|
155
|
+
if (ast.value.moduleName !== null) {
|
|
156
|
+
const { moduleImport, symbol } = this.imports.generateNamedImport(ast.value.moduleName, ast.value.name);
|
|
157
|
+
if (moduleImport === null) {
|
|
158
|
+
return this.factory.createIdentifier(symbol);
|
|
159
|
+
} else {
|
|
160
|
+
return this.factory.createPropertyAccess(moduleImport, symbol);
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
return this.factory.createIdentifier(ast.value.name);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
visitConditionalExpr(ast, context) {
|
|
167
|
+
let cond = ast.condition.visitExpression(this, context);
|
|
168
|
+
if (ast.condition instanceof o.ConditionalExpr) {
|
|
169
|
+
cond = this.factory.createParenthesizedExpression(cond);
|
|
170
|
+
}
|
|
171
|
+
return this.factory.createConditional(cond, ast.trueCase.visitExpression(this, context), ast.falseCase.visitExpression(this, context));
|
|
172
|
+
}
|
|
173
|
+
visitNotExpr(ast, context) {
|
|
174
|
+
return this.factory.createUnaryExpression("!", ast.condition.visitExpression(this, context));
|
|
175
|
+
}
|
|
176
|
+
visitFunctionExpr(ast, context) {
|
|
177
|
+
var _a;
|
|
178
|
+
return this.factory.createFunctionExpression((_a = ast.name) != null ? _a : null, ast.params.map((param) => param.name), this.factory.createBlock(this.visitStatements(ast.statements, context)));
|
|
179
|
+
}
|
|
180
|
+
visitBinaryOperatorExpr(ast, context) {
|
|
181
|
+
if (!BINARY_OPERATORS.has(ast.operator)) {
|
|
182
|
+
throw new Error(`Unknown binary operator: ${o.BinaryOperator[ast.operator]}`);
|
|
183
|
+
}
|
|
184
|
+
return this.factory.createBinaryExpression(ast.lhs.visitExpression(this, context), BINARY_OPERATORS.get(ast.operator), ast.rhs.visitExpression(this, context));
|
|
185
|
+
}
|
|
186
|
+
visitReadPropExpr(ast, context) {
|
|
187
|
+
return this.factory.createPropertyAccess(ast.receiver.visitExpression(this, context), ast.name);
|
|
188
|
+
}
|
|
189
|
+
visitReadKeyExpr(ast, context) {
|
|
190
|
+
return this.factory.createElementAccess(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context));
|
|
191
|
+
}
|
|
192
|
+
visitLiteralArrayExpr(ast, context) {
|
|
193
|
+
return this.factory.createArrayLiteral(ast.entries.map((expr) => this.setSourceMapRange(expr.visitExpression(this, context), ast.sourceSpan)));
|
|
194
|
+
}
|
|
195
|
+
visitLiteralMapExpr(ast, context) {
|
|
196
|
+
const properties = ast.entries.map((entry) => {
|
|
197
|
+
return {
|
|
198
|
+
propertyName: entry.key,
|
|
199
|
+
quoted: entry.quoted,
|
|
200
|
+
value: entry.value.visitExpression(this, context)
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
return this.setSourceMapRange(this.factory.createObjectLiteral(properties), ast.sourceSpan);
|
|
204
|
+
}
|
|
205
|
+
visitCommaExpr(ast, context) {
|
|
206
|
+
throw new Error("Method not implemented.");
|
|
207
|
+
}
|
|
208
|
+
visitWrappedNodeExpr(ast, _context) {
|
|
209
|
+
this.recordWrappedNode(ast);
|
|
210
|
+
return ast.node;
|
|
211
|
+
}
|
|
212
|
+
visitTypeofExpr(ast, context) {
|
|
213
|
+
return this.factory.createTypeOfExpression(ast.expr.visitExpression(this, context));
|
|
214
|
+
}
|
|
215
|
+
visitUnaryOperatorExpr(ast, context) {
|
|
216
|
+
if (!UNARY_OPERATORS.has(ast.operator)) {
|
|
217
|
+
throw new Error(`Unknown unary operator: ${o.UnaryOperator[ast.operator]}`);
|
|
218
|
+
}
|
|
219
|
+
return this.factory.createUnaryExpression(UNARY_OPERATORS.get(ast.operator), ast.expr.visitExpression(this, context));
|
|
220
|
+
}
|
|
221
|
+
visitStatements(statements, context) {
|
|
222
|
+
return statements.map((stmt) => stmt.visitStatement(this, context)).filter((stmt) => stmt !== void 0);
|
|
223
|
+
}
|
|
224
|
+
setSourceMapRange(ast, span) {
|
|
225
|
+
return this.factory.setSourceMapRange(ast, createRange(span));
|
|
226
|
+
}
|
|
227
|
+
attachComments(statement, leadingComments) {
|
|
228
|
+
if (leadingComments !== void 0) {
|
|
229
|
+
this.factory.attachComments(statement, leadingComments);
|
|
230
|
+
}
|
|
231
|
+
return statement;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
function createTemplateElement({ cooked, raw, range }) {
|
|
235
|
+
return { cooked, raw, range: createRange(range) };
|
|
236
|
+
}
|
|
237
|
+
function createRange(span) {
|
|
238
|
+
if (span === null) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
const { start, end } = span;
|
|
242
|
+
const { url, content } = start.file;
|
|
243
|
+
if (!url) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
url,
|
|
248
|
+
content,
|
|
249
|
+
start: { offset: start.offset, line: start.line, column: start.col },
|
|
250
|
+
end: { offset: end.offset, line: end.line, column: end.col }
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager.mjs
|
|
255
|
+
import ts from "typescript";
|
|
256
|
+
var ImportManager = class {
|
|
257
|
+
constructor(rewriter = new NoopImportRewriter(), prefix = "i") {
|
|
258
|
+
this.rewriter = rewriter;
|
|
259
|
+
this.prefix = prefix;
|
|
260
|
+
this.specifierToIdentifier = /* @__PURE__ */ new Map();
|
|
261
|
+
this.nextIndex = 0;
|
|
262
|
+
}
|
|
263
|
+
generateNamespaceImport(moduleName) {
|
|
264
|
+
if (!this.specifierToIdentifier.has(moduleName)) {
|
|
265
|
+
this.specifierToIdentifier.set(moduleName, ts.factory.createIdentifier(`${this.prefix}${this.nextIndex++}`));
|
|
266
|
+
}
|
|
267
|
+
return this.specifierToIdentifier.get(moduleName);
|
|
268
|
+
}
|
|
269
|
+
generateNamedImport(moduleName, originalSymbol) {
|
|
270
|
+
const symbol = this.rewriter.rewriteSymbol(originalSymbol, moduleName);
|
|
271
|
+
if (!this.rewriter.shouldImportSymbol(symbol, moduleName)) {
|
|
272
|
+
return { moduleImport: null, symbol };
|
|
273
|
+
}
|
|
274
|
+
const moduleImport = this.generateNamespaceImport(moduleName);
|
|
275
|
+
return { moduleImport, symbol };
|
|
276
|
+
}
|
|
277
|
+
getAllImports(contextPath) {
|
|
278
|
+
const imports = [];
|
|
279
|
+
for (const [originalSpecifier, qualifier] of this.specifierToIdentifier) {
|
|
280
|
+
const specifier = this.rewriter.rewriteSpecifier(originalSpecifier, contextPath);
|
|
281
|
+
imports.push({
|
|
282
|
+
specifier,
|
|
283
|
+
qualifier
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
return imports;
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
|
|
291
|
+
import * as o2 from "@angular/compiler";
|
|
292
|
+
import ts3 from "typescript";
|
|
293
|
+
|
|
294
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.mjs
|
|
295
|
+
import ts2 from "typescript";
|
|
296
|
+
var IS_AFTER_TS_49 = isAfterVersion(4, 9);
|
|
297
|
+
var createParameterDeclaration = IS_AFTER_TS_49 ? ts2.factory.createParameterDeclaration : (modifiers, dotDotDotToken, name, questionToken, type, initializer) => ts2.factory.createParameterDeclaration(...splitModifiers(modifiers), dotDotDotToken, name, questionToken, type, initializer);
|
|
298
|
+
var createImportDeclaration = IS_AFTER_TS_49 ? ts2.factory.createImportDeclaration : (modifiers, importClause, moduleSpecifier, assertClause) => ts2.factory.createImportDeclaration(void 0, modifiers, importClause, moduleSpecifier, assertClause);
|
|
299
|
+
var createFunctionDeclaration = IS_AFTER_TS_49 ? ts2.factory.createFunctionDeclaration : (modifiers, asteriskToken, name, typeParameters, parameters, type, body) => ts2.factory.createFunctionDeclaration(...splitModifiers(modifiers), asteriskToken, name, typeParameters, parameters, type, body);
|
|
300
|
+
var createIndexSignature = IS_AFTER_TS_49 ? ts2.factory.createIndexSignature : (modifiers, parameters, type) => ts2.factory.createIndexSignature(modifiers, parameters, type);
|
|
301
|
+
function splitModifiers(allModifiers) {
|
|
302
|
+
if (!allModifiers) {
|
|
303
|
+
return [void 0, void 0];
|
|
304
|
+
}
|
|
305
|
+
const decorators = [];
|
|
306
|
+
const modifiers = [];
|
|
307
|
+
for (const current of allModifiers) {
|
|
308
|
+
if (ts2.isDecorator(current)) {
|
|
309
|
+
decorators.push(current);
|
|
310
|
+
} else {
|
|
311
|
+
modifiers.push(current);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return [decorators.length ? decorators : void 0, modifiers.length ? modifiers : void 0];
|
|
315
|
+
}
|
|
316
|
+
function isAfterVersion(targetMajor, targetMinor) {
|
|
317
|
+
const [major, minor] = ts2.versionMajorMinor.split(".").map((part) => parseInt(part));
|
|
318
|
+
if (major < targetMajor) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
return major === targetMajor ? minor >= targetMinor : true;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
|
|
325
|
+
function translateType(type, imports) {
|
|
326
|
+
return type.visitType(new TypeTranslatorVisitor(imports), new Context(false));
|
|
327
|
+
}
|
|
328
|
+
var TypeTranslatorVisitor = class {
|
|
329
|
+
constructor(imports) {
|
|
330
|
+
this.imports = imports;
|
|
331
|
+
}
|
|
332
|
+
visitBuiltinType(type, context) {
|
|
333
|
+
switch (type.name) {
|
|
334
|
+
case o2.BuiltinTypeName.Bool:
|
|
335
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.BooleanKeyword);
|
|
336
|
+
case o2.BuiltinTypeName.Dynamic:
|
|
337
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.AnyKeyword);
|
|
338
|
+
case o2.BuiltinTypeName.Int:
|
|
339
|
+
case o2.BuiltinTypeName.Number:
|
|
340
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.NumberKeyword);
|
|
341
|
+
case o2.BuiltinTypeName.String:
|
|
342
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.StringKeyword);
|
|
343
|
+
case o2.BuiltinTypeName.None:
|
|
344
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.NeverKeyword);
|
|
345
|
+
default:
|
|
346
|
+
throw new Error(`Unsupported builtin type: ${o2.BuiltinTypeName[type.name]}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
visitExpressionType(type, context) {
|
|
350
|
+
const typeNode = this.translateExpression(type.value, context);
|
|
351
|
+
if (type.typeParams === null) {
|
|
352
|
+
return typeNode;
|
|
353
|
+
}
|
|
354
|
+
if (!ts3.isTypeReferenceNode(typeNode)) {
|
|
355
|
+
throw new Error("An ExpressionType with type arguments must translate into a TypeReferenceNode");
|
|
356
|
+
} else if (typeNode.typeArguments !== void 0) {
|
|
357
|
+
throw new Error(`An ExpressionType with type arguments cannot have multiple levels of type arguments`);
|
|
358
|
+
}
|
|
359
|
+
const typeArgs = type.typeParams.map((param) => this.translateType(param, context));
|
|
360
|
+
return ts3.factory.createTypeReferenceNode(typeNode.typeName, typeArgs);
|
|
361
|
+
}
|
|
362
|
+
visitArrayType(type, context) {
|
|
363
|
+
return ts3.factory.createArrayTypeNode(this.translateType(type.of, context));
|
|
364
|
+
}
|
|
365
|
+
visitMapType(type, context) {
|
|
366
|
+
const parameter = createParameterDeclaration(void 0, void 0, "key", void 0, ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.StringKeyword));
|
|
367
|
+
const typeArgs = type.valueType !== null ? this.translateType(type.valueType, context) : ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.UnknownKeyword);
|
|
368
|
+
const indexSignature = createIndexSignature(void 0, [parameter], typeArgs);
|
|
369
|
+
return ts3.factory.createTypeLiteralNode([indexSignature]);
|
|
370
|
+
}
|
|
371
|
+
visitReadVarExpr(ast, context) {
|
|
372
|
+
if (ast.name === null) {
|
|
373
|
+
throw new Error(`ReadVarExpr with no variable name in type`);
|
|
374
|
+
}
|
|
375
|
+
return ts3.factory.createTypeQueryNode(ts3.factory.createIdentifier(ast.name));
|
|
376
|
+
}
|
|
377
|
+
visitWriteVarExpr(expr, context) {
|
|
378
|
+
throw new Error("Method not implemented.");
|
|
379
|
+
}
|
|
380
|
+
visitWriteKeyExpr(expr, context) {
|
|
381
|
+
throw new Error("Method not implemented.");
|
|
382
|
+
}
|
|
383
|
+
visitWritePropExpr(expr, context) {
|
|
384
|
+
throw new Error("Method not implemented.");
|
|
385
|
+
}
|
|
386
|
+
visitInvokeFunctionExpr(ast, context) {
|
|
387
|
+
throw new Error("Method not implemented.");
|
|
388
|
+
}
|
|
389
|
+
visitTaggedTemplateExpr(ast, context) {
|
|
390
|
+
throw new Error("Method not implemented.");
|
|
391
|
+
}
|
|
392
|
+
visitInstantiateExpr(ast, context) {
|
|
393
|
+
throw new Error("Method not implemented.");
|
|
394
|
+
}
|
|
395
|
+
visitLiteralExpr(ast, context) {
|
|
396
|
+
if (ast.value === null) {
|
|
397
|
+
return ts3.factory.createLiteralTypeNode(ts3.factory.createNull());
|
|
398
|
+
} else if (ast.value === void 0) {
|
|
399
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.UndefinedKeyword);
|
|
400
|
+
} else if (typeof ast.value === "boolean") {
|
|
401
|
+
return ts3.factory.createLiteralTypeNode(ast.value ? ts3.factory.createTrue() : ts3.factory.createFalse());
|
|
402
|
+
} else if (typeof ast.value === "number") {
|
|
403
|
+
return ts3.factory.createLiteralTypeNode(ts3.factory.createNumericLiteral(ast.value));
|
|
404
|
+
} else {
|
|
405
|
+
return ts3.factory.createLiteralTypeNode(ts3.factory.createStringLiteral(ast.value));
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
visitLocalizedString(ast, context) {
|
|
409
|
+
throw new Error("Method not implemented.");
|
|
410
|
+
}
|
|
411
|
+
visitExternalExpr(ast, context) {
|
|
412
|
+
if (ast.value.moduleName === null || ast.value.name === null) {
|
|
413
|
+
throw new Error(`Import unknown module or symbol`);
|
|
414
|
+
}
|
|
415
|
+
const { moduleImport, symbol } = this.imports.generateNamedImport(ast.value.moduleName, ast.value.name);
|
|
416
|
+
const symbolIdentifier = ts3.factory.createIdentifier(symbol);
|
|
417
|
+
const typeName = moduleImport ? ts3.factory.createQualifiedName(moduleImport, symbolIdentifier) : symbolIdentifier;
|
|
418
|
+
const typeArguments = ast.typeParams !== null ? ast.typeParams.map((type) => this.translateType(type, context)) : void 0;
|
|
419
|
+
return ts3.factory.createTypeReferenceNode(typeName, typeArguments);
|
|
420
|
+
}
|
|
421
|
+
visitConditionalExpr(ast, context) {
|
|
422
|
+
throw new Error("Method not implemented.");
|
|
423
|
+
}
|
|
424
|
+
visitNotExpr(ast, context) {
|
|
425
|
+
throw new Error("Method not implemented.");
|
|
426
|
+
}
|
|
427
|
+
visitFunctionExpr(ast, context) {
|
|
428
|
+
throw new Error("Method not implemented.");
|
|
429
|
+
}
|
|
430
|
+
visitUnaryOperatorExpr(ast, context) {
|
|
431
|
+
throw new Error("Method not implemented.");
|
|
432
|
+
}
|
|
433
|
+
visitBinaryOperatorExpr(ast, context) {
|
|
434
|
+
throw new Error("Method not implemented.");
|
|
435
|
+
}
|
|
436
|
+
visitReadPropExpr(ast, context) {
|
|
437
|
+
throw new Error("Method not implemented.");
|
|
438
|
+
}
|
|
439
|
+
visitReadKeyExpr(ast, context) {
|
|
440
|
+
throw new Error("Method not implemented.");
|
|
441
|
+
}
|
|
442
|
+
visitLiteralArrayExpr(ast, context) {
|
|
443
|
+
const values = ast.entries.map((expr) => this.translateExpression(expr, context));
|
|
444
|
+
return ts3.factory.createTupleTypeNode(values);
|
|
445
|
+
}
|
|
446
|
+
visitLiteralMapExpr(ast, context) {
|
|
447
|
+
const entries = ast.entries.map((entry) => {
|
|
448
|
+
const { key, quoted } = entry;
|
|
449
|
+
const type = this.translateExpression(entry.value, context);
|
|
450
|
+
return ts3.factory.createPropertySignature(
|
|
451
|
+
void 0,
|
|
452
|
+
quoted ? ts3.factory.createStringLiteral(key) : key,
|
|
453
|
+
void 0,
|
|
454
|
+
type
|
|
455
|
+
);
|
|
456
|
+
});
|
|
457
|
+
return ts3.factory.createTypeLiteralNode(entries);
|
|
458
|
+
}
|
|
459
|
+
visitCommaExpr(ast, context) {
|
|
460
|
+
throw new Error("Method not implemented.");
|
|
461
|
+
}
|
|
462
|
+
visitWrappedNodeExpr(ast, context) {
|
|
463
|
+
const node = ast.node;
|
|
464
|
+
if (ts3.isEntityName(node)) {
|
|
465
|
+
return ts3.factory.createTypeReferenceNode(node, void 0);
|
|
466
|
+
} else if (ts3.isTypeNode(node)) {
|
|
467
|
+
return node;
|
|
468
|
+
} else if (ts3.isLiteralExpression(node)) {
|
|
469
|
+
return ts3.factory.createLiteralTypeNode(node);
|
|
470
|
+
} else {
|
|
471
|
+
throw new Error(`Unsupported WrappedNodeExpr in TypeTranslatorVisitor: ${ts3.SyntaxKind[node.kind]}`);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
visitTypeofExpr(ast, context) {
|
|
475
|
+
const typeNode = this.translateExpression(ast.expr, context);
|
|
476
|
+
if (!ts3.isTypeReferenceNode(typeNode)) {
|
|
477
|
+
throw new Error(`The target of a typeof expression must be a type reference, but it was
|
|
478
|
+
${ts3.SyntaxKind[typeNode.kind]}`);
|
|
479
|
+
}
|
|
480
|
+
return ts3.factory.createTypeQueryNode(typeNode.typeName);
|
|
481
|
+
}
|
|
482
|
+
translateType(type, context) {
|
|
483
|
+
const typeNode = type.visitType(this, context);
|
|
484
|
+
if (!ts3.isTypeNode(typeNode)) {
|
|
485
|
+
throw new Error(`A Type must translate to a TypeNode, but was ${ts3.SyntaxKind[typeNode.kind]}`);
|
|
486
|
+
}
|
|
487
|
+
return typeNode;
|
|
488
|
+
}
|
|
489
|
+
translateExpression(expr, context) {
|
|
490
|
+
const typeNode = expr.visitExpression(this, context);
|
|
491
|
+
if (!ts3.isTypeNode(typeNode)) {
|
|
492
|
+
throw new Error(`An Expression must translate to a TypeNode, but was ${ts3.SyntaxKind[typeNode.kind]}`);
|
|
493
|
+
}
|
|
494
|
+
return typeNode;
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.mjs
|
|
499
|
+
import ts4 from "typescript";
|
|
500
|
+
var PureAnnotation;
|
|
501
|
+
(function(PureAnnotation2) {
|
|
502
|
+
PureAnnotation2["CLOSURE"] = "* @pureOrBreakMyCode ";
|
|
503
|
+
PureAnnotation2["TERSER"] = "@__PURE__";
|
|
504
|
+
})(PureAnnotation || (PureAnnotation = {}));
|
|
505
|
+
var UNARY_OPERATORS2 = {
|
|
506
|
+
"+": ts4.SyntaxKind.PlusToken,
|
|
507
|
+
"-": ts4.SyntaxKind.MinusToken,
|
|
508
|
+
"!": ts4.SyntaxKind.ExclamationToken
|
|
509
|
+
};
|
|
510
|
+
var BINARY_OPERATORS2 = {
|
|
511
|
+
"&&": ts4.SyntaxKind.AmpersandAmpersandToken,
|
|
512
|
+
">": ts4.SyntaxKind.GreaterThanToken,
|
|
513
|
+
">=": ts4.SyntaxKind.GreaterThanEqualsToken,
|
|
514
|
+
"&": ts4.SyntaxKind.AmpersandToken,
|
|
515
|
+
"/": ts4.SyntaxKind.SlashToken,
|
|
516
|
+
"==": ts4.SyntaxKind.EqualsEqualsToken,
|
|
517
|
+
"===": ts4.SyntaxKind.EqualsEqualsEqualsToken,
|
|
518
|
+
"<": ts4.SyntaxKind.LessThanToken,
|
|
519
|
+
"<=": ts4.SyntaxKind.LessThanEqualsToken,
|
|
520
|
+
"-": ts4.SyntaxKind.MinusToken,
|
|
521
|
+
"%": ts4.SyntaxKind.PercentToken,
|
|
522
|
+
"*": ts4.SyntaxKind.AsteriskToken,
|
|
523
|
+
"!=": ts4.SyntaxKind.ExclamationEqualsToken,
|
|
524
|
+
"!==": ts4.SyntaxKind.ExclamationEqualsEqualsToken,
|
|
525
|
+
"||": ts4.SyntaxKind.BarBarToken,
|
|
526
|
+
"+": ts4.SyntaxKind.PlusToken,
|
|
527
|
+
"??": ts4.SyntaxKind.QuestionQuestionToken
|
|
528
|
+
};
|
|
529
|
+
var VAR_TYPES = {
|
|
530
|
+
"const": ts4.NodeFlags.Const,
|
|
531
|
+
"let": ts4.NodeFlags.Let,
|
|
532
|
+
"var": ts4.NodeFlags.None
|
|
533
|
+
};
|
|
534
|
+
var TypeScriptAstFactory = class {
|
|
535
|
+
constructor(annotateForClosureCompiler) {
|
|
536
|
+
this.annotateForClosureCompiler = annotateForClosureCompiler;
|
|
537
|
+
this.externalSourceFiles = /* @__PURE__ */ new Map();
|
|
538
|
+
this.attachComments = attachComments;
|
|
539
|
+
this.createArrayLiteral = ts4.factory.createArrayLiteralExpression;
|
|
540
|
+
this.createElementAccess = ts4.factory.createElementAccessExpression;
|
|
541
|
+
this.createExpressionStatement = ts4.factory.createExpressionStatement;
|
|
542
|
+
this.createIdentifier = ts4.factory.createIdentifier;
|
|
543
|
+
this.createParenthesizedExpression = ts4.factory.createParenthesizedExpression;
|
|
544
|
+
this.createPropertyAccess = ts4.factory.createPropertyAccessExpression;
|
|
545
|
+
this.createThrowStatement = ts4.factory.createThrowStatement;
|
|
546
|
+
this.createTypeOfExpression = ts4.factory.createTypeOfExpression;
|
|
547
|
+
}
|
|
548
|
+
createAssignment(target, value) {
|
|
549
|
+
return ts4.factory.createBinaryExpression(target, ts4.SyntaxKind.EqualsToken, value);
|
|
550
|
+
}
|
|
551
|
+
createBinaryExpression(leftOperand, operator, rightOperand) {
|
|
552
|
+
return ts4.factory.createBinaryExpression(leftOperand, BINARY_OPERATORS2[operator], rightOperand);
|
|
553
|
+
}
|
|
554
|
+
createBlock(body) {
|
|
555
|
+
return ts4.factory.createBlock(body);
|
|
556
|
+
}
|
|
557
|
+
createCallExpression(callee, args, pure) {
|
|
558
|
+
const call = ts4.factory.createCallExpression(callee, void 0, args);
|
|
559
|
+
if (pure) {
|
|
560
|
+
ts4.addSyntheticLeadingComment(
|
|
561
|
+
call,
|
|
562
|
+
ts4.SyntaxKind.MultiLineCommentTrivia,
|
|
563
|
+
this.annotateForClosureCompiler ? PureAnnotation.CLOSURE : PureAnnotation.TERSER,
|
|
564
|
+
false
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
return call;
|
|
568
|
+
}
|
|
569
|
+
createConditional(condition, whenTrue, whenFalse) {
|
|
570
|
+
return ts4.factory.createConditionalExpression(condition, void 0, whenTrue, void 0, whenFalse);
|
|
571
|
+
}
|
|
572
|
+
createFunctionDeclaration(functionName, parameters, body) {
|
|
573
|
+
if (!ts4.isBlock(body)) {
|
|
574
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts4.SyntaxKind[body.kind]}.`);
|
|
575
|
+
}
|
|
576
|
+
return createFunctionDeclaration(void 0, void 0, functionName, void 0, parameters.map((param) => createParameterDeclaration(void 0, void 0, param)), void 0, body);
|
|
577
|
+
}
|
|
578
|
+
createFunctionExpression(functionName, parameters, body) {
|
|
579
|
+
if (!ts4.isBlock(body)) {
|
|
580
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts4.SyntaxKind[body.kind]}.`);
|
|
581
|
+
}
|
|
582
|
+
return ts4.factory.createFunctionExpression(void 0, void 0, functionName != null ? functionName : void 0, void 0, parameters.map((param) => createParameterDeclaration(void 0, void 0, param)), void 0, body);
|
|
583
|
+
}
|
|
584
|
+
createIfStatement(condition, thenStatement, elseStatement) {
|
|
585
|
+
return ts4.factory.createIfStatement(condition, thenStatement, elseStatement != null ? elseStatement : void 0);
|
|
586
|
+
}
|
|
587
|
+
createLiteral(value) {
|
|
588
|
+
if (value === void 0) {
|
|
589
|
+
return ts4.factory.createIdentifier("undefined");
|
|
590
|
+
} else if (value === null) {
|
|
591
|
+
return ts4.factory.createNull();
|
|
592
|
+
} else if (typeof value === "boolean") {
|
|
593
|
+
return value ? ts4.factory.createTrue() : ts4.factory.createFalse();
|
|
594
|
+
} else if (typeof value === "number") {
|
|
595
|
+
return ts4.factory.createNumericLiteral(value);
|
|
596
|
+
} else {
|
|
597
|
+
return ts4.factory.createStringLiteral(value);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
createNewExpression(expression, args) {
|
|
601
|
+
return ts4.factory.createNewExpression(expression, void 0, args);
|
|
602
|
+
}
|
|
603
|
+
createObjectLiteral(properties) {
|
|
604
|
+
return ts4.factory.createObjectLiteralExpression(properties.map((prop) => ts4.factory.createPropertyAssignment(prop.quoted ? ts4.factory.createStringLiteral(prop.propertyName) : ts4.factory.createIdentifier(prop.propertyName), prop.value)));
|
|
605
|
+
}
|
|
606
|
+
createReturnStatement(expression) {
|
|
607
|
+
return ts4.factory.createReturnStatement(expression != null ? expression : void 0);
|
|
608
|
+
}
|
|
609
|
+
createTaggedTemplate(tag, template) {
|
|
610
|
+
let templateLiteral;
|
|
611
|
+
const length = template.elements.length;
|
|
612
|
+
const head = template.elements[0];
|
|
613
|
+
if (length === 1) {
|
|
614
|
+
templateLiteral = ts4.factory.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
|
|
615
|
+
} else {
|
|
616
|
+
const spans = [];
|
|
617
|
+
for (let i = 1; i < length - 1; i++) {
|
|
618
|
+
const { cooked, raw, range } = template.elements[i];
|
|
619
|
+
const middle = createTemplateMiddle(cooked, raw);
|
|
620
|
+
if (range !== null) {
|
|
621
|
+
this.setSourceMapRange(middle, range);
|
|
622
|
+
}
|
|
623
|
+
spans.push(ts4.factory.createTemplateSpan(template.expressions[i - 1], middle));
|
|
624
|
+
}
|
|
625
|
+
const resolvedExpression = template.expressions[length - 2];
|
|
626
|
+
const templatePart = template.elements[length - 1];
|
|
627
|
+
const templateTail = createTemplateTail(templatePart.cooked, templatePart.raw);
|
|
628
|
+
if (templatePart.range !== null) {
|
|
629
|
+
this.setSourceMapRange(templateTail, templatePart.range);
|
|
630
|
+
}
|
|
631
|
+
spans.push(ts4.factory.createTemplateSpan(resolvedExpression, templateTail));
|
|
632
|
+
templateLiteral = ts4.factory.createTemplateExpression(ts4.factory.createTemplateHead(head.cooked, head.raw), spans);
|
|
633
|
+
}
|
|
634
|
+
if (head.range !== null) {
|
|
635
|
+
this.setSourceMapRange(templateLiteral, head.range);
|
|
636
|
+
}
|
|
637
|
+
return ts4.factory.createTaggedTemplateExpression(tag, void 0, templateLiteral);
|
|
638
|
+
}
|
|
639
|
+
createUnaryExpression(operator, operand) {
|
|
640
|
+
return ts4.factory.createPrefixUnaryExpression(UNARY_OPERATORS2[operator], operand);
|
|
641
|
+
}
|
|
642
|
+
createVariableDeclaration(variableName, initializer, type) {
|
|
643
|
+
return ts4.factory.createVariableStatement(void 0, ts4.factory.createVariableDeclarationList([ts4.factory.createVariableDeclaration(variableName, void 0, void 0, initializer != null ? initializer : void 0)], VAR_TYPES[type]));
|
|
644
|
+
}
|
|
645
|
+
setSourceMapRange(node, sourceMapRange) {
|
|
646
|
+
if (sourceMapRange === null) {
|
|
647
|
+
return node;
|
|
648
|
+
}
|
|
649
|
+
const url = sourceMapRange.url;
|
|
650
|
+
if (!this.externalSourceFiles.has(url)) {
|
|
651
|
+
this.externalSourceFiles.set(url, ts4.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
|
|
652
|
+
}
|
|
653
|
+
const source = this.externalSourceFiles.get(url);
|
|
654
|
+
ts4.setSourceMapRange(node, { pos: sourceMapRange.start.offset, end: sourceMapRange.end.offset, source });
|
|
655
|
+
return node;
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
function createTemplateMiddle(cooked, raw) {
|
|
659
|
+
const node = ts4.factory.createTemplateHead(cooked, raw);
|
|
660
|
+
node.kind = ts4.SyntaxKind.TemplateMiddle;
|
|
661
|
+
return node;
|
|
662
|
+
}
|
|
663
|
+
function createTemplateTail(cooked, raw) {
|
|
664
|
+
const node = ts4.factory.createTemplateHead(cooked, raw);
|
|
665
|
+
node.kind = ts4.SyntaxKind.TemplateTail;
|
|
666
|
+
return node;
|
|
667
|
+
}
|
|
668
|
+
function attachComments(statement, leadingComments) {
|
|
669
|
+
for (const comment of leadingComments) {
|
|
670
|
+
const commentKind = comment.multiline ? ts4.SyntaxKind.MultiLineCommentTrivia : ts4.SyntaxKind.SingleLineCommentTrivia;
|
|
671
|
+
if (comment.multiline) {
|
|
672
|
+
ts4.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
|
|
673
|
+
} else {
|
|
674
|
+
for (const line of comment.toString().split("\n")) {
|
|
675
|
+
ts4.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_translator.mjs
|
|
682
|
+
function translateExpression(expression, imports, options = {}) {
|
|
683
|
+
return expression.visitExpression(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(false));
|
|
684
|
+
}
|
|
685
|
+
function translateStatement(statement, imports, options = {}) {
|
|
686
|
+
return statement.visitStatement(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(true));
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export {
|
|
690
|
+
Context,
|
|
691
|
+
ImportManager,
|
|
692
|
+
ExpressionTranslatorVisitor,
|
|
693
|
+
createParameterDeclaration,
|
|
694
|
+
createImportDeclaration,
|
|
695
|
+
createFunctionDeclaration,
|
|
696
|
+
translateType,
|
|
697
|
+
translateExpression,
|
|
698
|
+
translateStatement
|
|
699
|
+
};
|
|
700
|
+
/*!
|
|
701
|
+
* @license
|
|
702
|
+
* Copyright Google LLC All Rights Reserved.
|
|
703
|
+
*
|
|
704
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
705
|
+
* found in the LICENSE file at https://angular.io/license
|
|
706
|
+
*/
|
|
707
|
+
/**
|
|
708
|
+
* @license
|
|
709
|
+
* Copyright Google LLC All Rights Reserved.
|
|
710
|
+
*
|
|
711
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
712
|
+
* found in the LICENSE file at https://angular.io/license
|
|
713
|
+
*/
|
|
714
|
+
//# sourceMappingURL=chunk-QRHWLC7U.js.map
|