@angular/compiler-cli 20.2.0-next.0 → 20.2.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-SEKYV57I.js → chunk-6HOSNZU5.js} +2 -3
- package/bundles/{chunk-FPHHL4UV.js → chunk-BPDNYZBC.js} +253 -49
- package/bundles/chunk-DWRM7PIK.js +14 -0
- package/bundles/{chunk-JXYBFWGA.js → chunk-F7QVREVY.js} +19 -7
- package/bundles/{chunk-TPEB2IXF.js → chunk-GWZQLAGK.js} +35 -7
- package/bundles/{chunk-PML5JK7B.js → chunk-HYJ2H3FU.js} +120 -7
- package/bundles/{chunk-6ECVYRSU.js → chunk-I2BHWRAU.js} +11 -6
- package/bundles/{chunk-5TMRGUHP.js → chunk-PLUBZWSY.js} +27 -11
- package/bundles/{chunk-5JF7HF3W.js → chunk-SZY7NM6F.js} +2 -3
- package/bundles/{chunk-UZOSFHTN.js → chunk-TMIC4MKN.js} +2312 -736
- package/bundles/{chunk-YNE6T2TY.js → chunk-U3R42CLJ.js} +569 -103
- package/bundles/index.js +34 -19
- package/bundles/linker/babel/index.js +70 -18
- package/bundles/linker/index.js +11 -5
- package/bundles/private/localize.js +5 -6
- package/bundles/private/migrations.js +5 -6
- package/bundles/private/tooling.js +27 -11
- package/bundles/src/bin/ng_xi18n.js +11 -12
- package/bundles/src/bin/ngc.js +9 -10
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +3 -3
- package/src/ngtsc/perf/src/api.d.ts +24 -16
- package/src/ngtsc/typecheck/api/api.d.ts +1 -1
- package/src/ngtsc/typecheck/api/checker.d.ts +15 -0
- package/src/ngtsc/typecheck/diagnostics/src/diagnostic.d.ts +7 -1
- package/src/ngtsc/typecheck/src/checker.d.ts +2 -0
- package/src/ngtsc/typecheck/src/ts_util.d.ts +7 -0
- package/bundles/chunk-2FHBFXPC.js +0 -34
- package/bundles/chunk-2FHBFXPC.js.map +0 -6
- package/bundles/chunk-5JF7HF3W.js.map +0 -6
- package/bundles/chunk-5TMRGUHP.js.map +0 -6
- package/bundles/chunk-6ECVYRSU.js.map +0 -6
- package/bundles/chunk-FPHHL4UV.js.map +0 -6
- package/bundles/chunk-JXYBFWGA.js.map +0 -6
- package/bundles/chunk-KPQ72R34.js +0 -23
- package/bundles/chunk-KPQ72R34.js.map +0 -6
- package/bundles/chunk-PML5JK7B.js.map +0 -6
- package/bundles/chunk-SEKYV57I.js.map +0 -6
- package/bundles/chunk-TPEB2IXF.js.map +0 -6
- package/bundles/chunk-UZOSFHTN.js.map +0 -6
- package/bundles/chunk-YNE6T2TY.js.map +0 -6
- package/bundles/index.js.map +0 -6
- package/bundles/linker/babel/index.js.map +0 -6
- package/bundles/linker/index.js.map +0 -6
- package/bundles/private/localize.js.map +0 -6
- package/bundles/private/migrations.js.map +0 -6
- package/bundles/private/tooling.js.map +0 -6
- package/bundles/src/bin/ng_xi18n.js.map +0 -6
- package/bundles/src/bin/ngc.js.map +0 -6
|
@@ -4,16 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
SourceFileLoader
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HYJ2H3FU.js";
|
|
8
8
|
import {
|
|
9
9
|
Context,
|
|
10
10
|
ExpressionTranslatorVisitor
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-I2BHWRAU.js";
|
|
12
12
|
|
|
13
|
-
//
|
|
13
|
+
// packages/compiler-cli/linker/src/fatal_linker_error.js
|
|
14
14
|
var FatalLinkerError = class extends Error {
|
|
15
15
|
node;
|
|
16
16
|
type = "FatalLinkerError";
|
|
17
|
+
/**
|
|
18
|
+
* Create a new FatalLinkerError.
|
|
19
|
+
*
|
|
20
|
+
* @param node The AST node where the error occurred.
|
|
21
|
+
* @param message A description of the error.
|
|
22
|
+
*/
|
|
17
23
|
constructor(node, message) {
|
|
18
24
|
super(message);
|
|
19
25
|
this.node = node;
|
|
@@ -23,58 +29,109 @@ function isFatalLinkerError(e) {
|
|
|
23
29
|
return e && e.type === "FatalLinkerError";
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
//
|
|
32
|
+
// packages/compiler-cli/linker/src/ast/utils.js
|
|
27
33
|
function assert(node, predicate, expected) {
|
|
28
34
|
if (!predicate(node)) {
|
|
29
35
|
throw new FatalLinkerError(node, `Unsupported syntax, expected ${expected}.`);
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
//
|
|
39
|
+
// packages/compiler-cli/linker/src/ast/ast_value.js
|
|
34
40
|
import * as o from "@angular/compiler";
|
|
35
|
-
var AstObject = class {
|
|
41
|
+
var AstObject = class _AstObject {
|
|
36
42
|
expression;
|
|
37
43
|
obj;
|
|
38
44
|
host;
|
|
45
|
+
/**
|
|
46
|
+
* Create a new `AstObject` from the given `expression` and `host`.
|
|
47
|
+
*/
|
|
39
48
|
static parse(expression, host) {
|
|
40
49
|
const obj = host.parseObjectLiteral(expression);
|
|
41
|
-
return new
|
|
50
|
+
return new _AstObject(expression, obj, host);
|
|
42
51
|
}
|
|
43
52
|
constructor(expression, obj, host) {
|
|
44
53
|
this.expression = expression;
|
|
45
54
|
this.obj = obj;
|
|
46
55
|
this.host = host;
|
|
47
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns true if the object has a property called `propertyName`.
|
|
59
|
+
*/
|
|
48
60
|
has(propertyName) {
|
|
49
61
|
return this.obj.has(propertyName);
|
|
50
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns the number value of the property called `propertyName`.
|
|
65
|
+
*
|
|
66
|
+
* Throws an error if there is no such property or the property is not a number.
|
|
67
|
+
*/
|
|
51
68
|
getNumber(propertyName) {
|
|
52
69
|
return this.host.parseNumericLiteral(this.getRequiredProperty(propertyName));
|
|
53
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the string value of the property called `propertyName`.
|
|
73
|
+
*
|
|
74
|
+
* Throws an error if there is no such property or the property is not a string.
|
|
75
|
+
*/
|
|
54
76
|
getString(propertyName) {
|
|
55
77
|
return this.host.parseStringLiteral(this.getRequiredProperty(propertyName));
|
|
56
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Returns the boolean value of the property called `propertyName`.
|
|
81
|
+
*
|
|
82
|
+
* Throws an error if there is no such property or the property is not a boolean.
|
|
83
|
+
*/
|
|
57
84
|
getBoolean(propertyName) {
|
|
58
85
|
return this.host.parseBooleanLiteral(this.getRequiredProperty(propertyName));
|
|
59
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns the nested `AstObject` parsed from the property called `propertyName`.
|
|
89
|
+
*
|
|
90
|
+
* Throws an error if there is no such property or the property is not an object.
|
|
91
|
+
*/
|
|
60
92
|
getObject(propertyName) {
|
|
61
93
|
const expr = this.getRequiredProperty(propertyName);
|
|
62
94
|
const obj = this.host.parseObjectLiteral(expr);
|
|
63
|
-
return new
|
|
95
|
+
return new _AstObject(expr, obj, this.host);
|
|
64
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns an array of `AstValue` objects parsed from the property called `propertyName`.
|
|
99
|
+
*
|
|
100
|
+
* Throws an error if there is no such property or the property is not an array.
|
|
101
|
+
*/
|
|
65
102
|
getArray(propertyName) {
|
|
66
103
|
const arr = this.host.parseArrayLiteral(this.getRequiredProperty(propertyName));
|
|
67
104
|
return arr.map((entry) => new AstValue(entry, this.host));
|
|
68
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns a `WrappedNodeExpr` object that wraps the expression at the property called
|
|
108
|
+
* `propertyName`.
|
|
109
|
+
*
|
|
110
|
+
* Throws an error if there is no such property.
|
|
111
|
+
*/
|
|
69
112
|
getOpaque(propertyName) {
|
|
70
113
|
return new o.WrappedNodeExpr(this.getRequiredProperty(propertyName));
|
|
71
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Returns the raw `TExpression` value of the property called `propertyName`.
|
|
117
|
+
*
|
|
118
|
+
* Throws an error if there is no such property.
|
|
119
|
+
*/
|
|
72
120
|
getNode(propertyName) {
|
|
73
121
|
return this.getRequiredProperty(propertyName);
|
|
74
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Returns an `AstValue` that wraps the value of the property called `propertyName`.
|
|
125
|
+
*
|
|
126
|
+
* Throws an error if there is no such property.
|
|
127
|
+
*/
|
|
75
128
|
getValue(propertyName) {
|
|
76
129
|
return new AstValue(this.getRequiredProperty(propertyName), this.host);
|
|
77
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Converts the AstObject to a raw JavaScript object, mapping each property value (as an
|
|
133
|
+
* `AstValue`) to the generic type (`T`) via the `mapper` function.
|
|
134
|
+
*/
|
|
78
135
|
toLiteral(mapper) {
|
|
79
136
|
const result = {};
|
|
80
137
|
for (const [key, expression] of this.obj) {
|
|
@@ -82,6 +139,10 @@ var AstObject = class {
|
|
|
82
139
|
}
|
|
83
140
|
return result;
|
|
84
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Converts the AstObject to a JavaScript Map, mapping each property value (as an
|
|
144
|
+
* `AstValue`) to the generic type (`T`) via the `mapper` function.
|
|
145
|
+
*/
|
|
85
146
|
toMap(mapper) {
|
|
86
147
|
const result = /* @__PURE__ */ new Map();
|
|
87
148
|
for (const [key, expression] of this.obj) {
|
|
@@ -96,82 +157,135 @@ var AstObject = class {
|
|
|
96
157
|
return this.obj.get(propertyName);
|
|
97
158
|
}
|
|
98
159
|
};
|
|
99
|
-
var AstValue = class {
|
|
160
|
+
var AstValue = class _AstValue {
|
|
100
161
|
expression;
|
|
101
162
|
host;
|
|
163
|
+
/** Type brand that ensures that the `T` type is respected for assignability. */
|
|
102
164
|
\u0275typeBrand = null;
|
|
103
165
|
constructor(expression, host) {
|
|
104
166
|
this.expression = expression;
|
|
105
167
|
this.host = host;
|
|
106
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Get the name of the symbol represented by the given expression node, or `null` if it is not a
|
|
171
|
+
* symbol.
|
|
172
|
+
*/
|
|
107
173
|
getSymbolName() {
|
|
108
174
|
return this.host.getSymbolName(this.expression);
|
|
109
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Is this value a number?
|
|
178
|
+
*/
|
|
110
179
|
isNumber() {
|
|
111
180
|
return this.host.isNumericLiteral(this.expression);
|
|
112
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Parse the number from this value, or error if it is not a number.
|
|
184
|
+
*/
|
|
113
185
|
getNumber() {
|
|
114
186
|
return this.host.parseNumericLiteral(this.expression);
|
|
115
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Is this value a string?
|
|
190
|
+
*/
|
|
116
191
|
isString() {
|
|
117
192
|
return this.host.isStringLiteral(this.expression);
|
|
118
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Parse the string from this value, or error if it is not a string.
|
|
196
|
+
*/
|
|
119
197
|
getString() {
|
|
120
198
|
return this.host.parseStringLiteral(this.expression);
|
|
121
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Is this value a boolean?
|
|
202
|
+
*/
|
|
122
203
|
isBoolean() {
|
|
123
204
|
return this.host.isBooleanLiteral(this.expression);
|
|
124
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Parse the boolean from this value, or error if it is not a boolean.
|
|
208
|
+
*/
|
|
125
209
|
getBoolean() {
|
|
126
210
|
return this.host.parseBooleanLiteral(this.expression);
|
|
127
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Is this value an object literal?
|
|
214
|
+
*/
|
|
128
215
|
isObject() {
|
|
129
216
|
return this.host.isObjectLiteral(this.expression);
|
|
130
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Parse this value into an `AstObject`, or error if it is not an object literal.
|
|
220
|
+
*/
|
|
131
221
|
getObject() {
|
|
132
222
|
return AstObject.parse(this.expression, this.host);
|
|
133
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Is this value an array literal?
|
|
226
|
+
*/
|
|
134
227
|
isArray() {
|
|
135
228
|
return this.host.isArrayLiteral(this.expression);
|
|
136
229
|
}
|
|
230
|
+
/** Whether the value is explicitly set to `null`. */
|
|
137
231
|
isNull() {
|
|
138
232
|
return this.host.isNull(this.expression);
|
|
139
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Parse this value into an array of `AstValue` objects, or error if it is not an array literal.
|
|
236
|
+
*/
|
|
140
237
|
getArray() {
|
|
141
238
|
const arr = this.host.parseArrayLiteral(this.expression);
|
|
142
|
-
return arr.map((entry) => new
|
|
239
|
+
return arr.map((entry) => new _AstValue(entry, this.host));
|
|
143
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Is this value a function expression?
|
|
243
|
+
*/
|
|
144
244
|
isFunction() {
|
|
145
245
|
return this.host.isFunctionExpression(this.expression);
|
|
146
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Extract the return value as an `AstValue` from this value as a function expression, or error if
|
|
249
|
+
* it is not a function expression.
|
|
250
|
+
*/
|
|
147
251
|
getFunctionReturnValue() {
|
|
148
|
-
return new
|
|
252
|
+
return new _AstValue(this.host.parseReturnValue(this.expression), this.host);
|
|
149
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Extract the parameters from this value as a function expression, or error if it is not a
|
|
256
|
+
* function expression.
|
|
257
|
+
*/
|
|
150
258
|
getFunctionParameters() {
|
|
151
|
-
return this.host.parseParameters(this.expression).map((param) => new
|
|
259
|
+
return this.host.parseParameters(this.expression).map((param) => new _AstValue(param, this.host));
|
|
152
260
|
}
|
|
153
261
|
isCallExpression() {
|
|
154
262
|
return this.host.isCallExpression(this.expression);
|
|
155
263
|
}
|
|
156
264
|
getCallee() {
|
|
157
|
-
return new
|
|
265
|
+
return new _AstValue(this.host.parseCallee(this.expression), this.host);
|
|
158
266
|
}
|
|
159
267
|
getArguments() {
|
|
160
268
|
const args = this.host.parseArguments(this.expression);
|
|
161
|
-
return args.map((arg) => new
|
|
269
|
+
return args.map((arg) => new _AstValue(arg, this.host));
|
|
162
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Return the `TExpression` of this value wrapped in a `WrappedNodeExpr`.
|
|
273
|
+
*/
|
|
163
274
|
getOpaque() {
|
|
164
275
|
return new o.WrappedNodeExpr(this.expression);
|
|
165
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Get the range of the location of this value in the original source.
|
|
279
|
+
*/
|
|
166
280
|
getRange() {
|
|
167
281
|
return this.host.getRange(this.expression);
|
|
168
282
|
}
|
|
169
283
|
};
|
|
170
284
|
|
|
171
|
-
//
|
|
285
|
+
// packages/compiler-cli/linker/src/file_linker/emit_scopes/emit_scope.js
|
|
172
286
|
import { ConstantPool } from "@angular/compiler";
|
|
173
287
|
|
|
174
|
-
//
|
|
288
|
+
// packages/compiler-cli/linker/src/linker_import_generator.js
|
|
175
289
|
var LinkerImportGenerator = class {
|
|
176
290
|
factory;
|
|
177
291
|
ngImport;
|
|
@@ -193,7 +307,7 @@ var LinkerImportGenerator = class {
|
|
|
193
307
|
}
|
|
194
308
|
};
|
|
195
309
|
|
|
196
|
-
//
|
|
310
|
+
// packages/compiler-cli/linker/src/file_linker/emit_scopes/emit_scope.js
|
|
197
311
|
var EmitScope = class {
|
|
198
312
|
ngImport;
|
|
199
313
|
translator;
|
|
@@ -204,6 +318,11 @@ var EmitScope = class {
|
|
|
204
318
|
this.translator = translator;
|
|
205
319
|
this.factory = factory;
|
|
206
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Translate the given Output AST definition expression into a generic `TExpression`.
|
|
323
|
+
*
|
|
324
|
+
* Use a `LinkerImportGenerator` to handle any imports in the definition.
|
|
325
|
+
*/
|
|
207
326
|
translateDefinition(definition) {
|
|
208
327
|
const expression = this.translator.translateExpression(definition.expression, new LinkerImportGenerator(this.factory, this.ngImport));
|
|
209
328
|
if (definition.statements.length > 0) {
|
|
@@ -213,6 +332,9 @@ var EmitScope = class {
|
|
|
213
332
|
return expression;
|
|
214
333
|
}
|
|
215
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Return any constant statements that are shared between all uses of this `EmitScope`.
|
|
337
|
+
*/
|
|
216
338
|
getConstantStatements() {
|
|
217
339
|
const importGenerator = new LinkerImportGenerator(this.factory, this.ngImport);
|
|
218
340
|
return this.constantPool.statements.map((statement) => this.translator.translateStatement(statement, importGenerator));
|
|
@@ -220,28 +342,50 @@ var EmitScope = class {
|
|
|
220
342
|
wrapInIifeWithStatements(expression, statements) {
|
|
221
343
|
const returnStatement = this.factory.createReturnStatement(expression);
|
|
222
344
|
const body = this.factory.createBlock([...statements, returnStatement]);
|
|
223
|
-
const fn = this.factory.createFunctionExpression(
|
|
224
|
-
|
|
345
|
+
const fn = this.factory.createFunctionExpression(
|
|
346
|
+
/* name */
|
|
347
|
+
null,
|
|
348
|
+
/* args */
|
|
349
|
+
[],
|
|
350
|
+
body
|
|
351
|
+
);
|
|
352
|
+
return this.factory.createCallExpression(
|
|
353
|
+
fn,
|
|
354
|
+
/* args */
|
|
355
|
+
[],
|
|
356
|
+
/* pure */
|
|
357
|
+
false
|
|
358
|
+
);
|
|
225
359
|
}
|
|
226
360
|
};
|
|
227
361
|
|
|
228
|
-
//
|
|
362
|
+
// packages/compiler-cli/linker/src/file_linker/emit_scopes/local_emit_scope.js
|
|
229
363
|
var LocalEmitScope = class extends EmitScope {
|
|
364
|
+
/**
|
|
365
|
+
* Translate the given Output AST definition expression into a generic `TExpression`.
|
|
366
|
+
*
|
|
367
|
+
* Merges the `ConstantPool` statements with the definition statements when generating the
|
|
368
|
+
* definition expression. This means that `ConstantPool` statements will be emitted into an IIFE.
|
|
369
|
+
*/
|
|
230
370
|
translateDefinition(definition) {
|
|
231
371
|
return super.translateDefinition({
|
|
232
372
|
expression: definition.expression,
|
|
233
373
|
statements: [...this.constantPool.statements, ...definition.statements]
|
|
234
374
|
});
|
|
235
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* It is not valid to call this method, since there will be no shared constant statements - they
|
|
378
|
+
* are already emitted in the IIFE alongside the translated definition.
|
|
379
|
+
*/
|
|
236
380
|
getConstantStatements() {
|
|
237
381
|
throw new Error("BUG - LocalEmitScope should not expose any constant statements");
|
|
238
382
|
}
|
|
239
383
|
};
|
|
240
384
|
|
|
241
|
-
//
|
|
385
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_linker_selector.js
|
|
242
386
|
import semver3 from "semver";
|
|
243
387
|
|
|
244
|
-
//
|
|
388
|
+
// packages/compiler-cli/linker/src/file_linker/get_source_file.js
|
|
245
389
|
function createGetSourceFile(sourceUrl, code, loader) {
|
|
246
390
|
if (loader === null) {
|
|
247
391
|
return () => null;
|
|
@@ -256,7 +400,7 @@ function createGetSourceFile(sourceUrl, code, loader) {
|
|
|
256
400
|
}
|
|
257
401
|
}
|
|
258
402
|
|
|
259
|
-
//
|
|
403
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_class_metadata_async_linker_1.js
|
|
260
404
|
import { compileOpaqueAsyncClassMetadata } from "@angular/compiler";
|
|
261
405
|
var PartialClassMetadataAsyncLinkerVersion1 = class {
|
|
262
406
|
linkPartialDeclaration(constantPool, metaObj) {
|
|
@@ -281,7 +425,7 @@ var PartialClassMetadataAsyncLinkerVersion1 = class {
|
|
|
281
425
|
}
|
|
282
426
|
};
|
|
283
427
|
|
|
284
|
-
//
|
|
428
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_class_metadata_linker_1.js
|
|
285
429
|
import { compileClassMetadata } from "@angular/compiler";
|
|
286
430
|
var PartialClassMetadataLinkerVersion1 = class {
|
|
287
431
|
linkPartialDeclaration(constantPool, metaObj) {
|
|
@@ -301,17 +445,17 @@ function toR3ClassMetadata(metaObj) {
|
|
|
301
445
|
};
|
|
302
446
|
}
|
|
303
447
|
|
|
304
|
-
//
|
|
448
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_component_linker_1.js
|
|
305
449
|
import { ChangeDetectionStrategy, compileComponentFromMetadata, DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig, makeBindingParser as makeBindingParser2, parseTemplate, R3TargetBinder, R3TemplateDependencyKind, ViewEncapsulation } from "@angular/compiler";
|
|
306
450
|
import semver2 from "semver";
|
|
307
451
|
|
|
308
|
-
//
|
|
452
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_directive_linker_1.js
|
|
309
453
|
import { compileDirectiveFromMetadata, makeBindingParser, ParseLocation, ParseSourceFile, ParseSourceSpan } from "@angular/compiler";
|
|
310
454
|
|
|
311
|
-
//
|
|
455
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/util.js
|
|
312
456
|
import { createMayBeForwardRefExpression, outputAst as o2 } from "@angular/compiler";
|
|
313
457
|
import semver from "semver";
|
|
314
|
-
var PLACEHOLDER_VERSION = "20.2.0-next.
|
|
458
|
+
var PLACEHOLDER_VERSION = "20.2.0-next.1";
|
|
315
459
|
function wrapReference(wrapped) {
|
|
316
460
|
return { value: wrapped, type: wrapped };
|
|
317
461
|
}
|
|
@@ -341,7 +485,11 @@ function getDependency(depObj) {
|
|
|
341
485
|
}
|
|
342
486
|
function extractForwardRef(expr) {
|
|
343
487
|
if (!expr.isCallExpression()) {
|
|
344
|
-
return createMayBeForwardRefExpression(
|
|
488
|
+
return createMayBeForwardRefExpression(
|
|
489
|
+
expr.getOpaque(),
|
|
490
|
+
0
|
|
491
|
+
/* ForwardRefHandling.None */
|
|
492
|
+
);
|
|
345
493
|
}
|
|
346
494
|
const callee = expr.getCallee();
|
|
347
495
|
if (callee.getSymbolName() !== "forwardRef") {
|
|
@@ -355,7 +503,11 @@ function extractForwardRef(expr) {
|
|
|
355
503
|
if (!wrapperFn.isFunction()) {
|
|
356
504
|
throw new FatalLinkerError(wrapperFn, "Unsupported `forwardRef(fn)` call, expected its argument to be a function");
|
|
357
505
|
}
|
|
358
|
-
return createMayBeForwardRefExpression(
|
|
506
|
+
return createMayBeForwardRefExpression(
|
|
507
|
+
wrapperFn.getFunctionReturnValue().getOpaque(),
|
|
508
|
+
2
|
|
509
|
+
/* ForwardRefHandling.Unwrapped */
|
|
510
|
+
);
|
|
359
511
|
}
|
|
360
512
|
var STANDALONE_IS_DEFAULT_RANGE = new semver.Range(`>= 19.0.0 || ${PLACEHOLDER_VERSION}`, {
|
|
361
513
|
includePrerelease: true
|
|
@@ -364,7 +516,7 @@ function getDefaultStandaloneValue(version) {
|
|
|
364
516
|
return STANDALONE_IS_DEFAULT_RANGE.test(version);
|
|
365
517
|
}
|
|
366
518
|
|
|
367
|
-
//
|
|
519
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_directive_linker_1.js
|
|
368
520
|
var PartialDirectiveLinkerVersion1 = class {
|
|
369
521
|
sourceUrl;
|
|
370
522
|
code;
|
|
@@ -513,7 +665,7 @@ function createSourceSpan(range, code, sourceUrl) {
|
|
|
513
665
|
return new ParseSourceSpan(startLocation, startLocation.moveBy(range.endPos - range.startPos));
|
|
514
666
|
}
|
|
515
667
|
|
|
516
|
-
//
|
|
668
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_component_linker_1.js
|
|
517
669
|
function makeDirectiveMetadata(directiveExpr, typeExpr, isComponentByDefault = null) {
|
|
518
670
|
return {
|
|
519
671
|
kind: R3TemplateDependencyKind.Directive,
|
|
@@ -538,6 +690,9 @@ var PartialComponentLinkerVersion1 = class {
|
|
|
538
690
|
const meta = this.toR3ComponentMeta(metaObj, version);
|
|
539
691
|
return compileComponentFromMetadata(meta, constantPool, makeBindingParser2());
|
|
540
692
|
}
|
|
693
|
+
/**
|
|
694
|
+
* This function derives the `R3ComponentMetadata` from the provided AST object.
|
|
695
|
+
*/
|
|
541
696
|
toR3ComponentMeta(metaObj, version) {
|
|
542
697
|
const interpolation = parseInterpolationConfig(metaObj);
|
|
543
698
|
const templateSource = metaObj.getValue("template");
|
|
@@ -552,9 +707,11 @@ var PartialComponentLinkerVersion1 = class {
|
|
|
552
707
|
range: templateInfo.range,
|
|
553
708
|
enableI18nLegacyMessageIdFormat: false,
|
|
554
709
|
preserveWhitespaces: metaObj.has("preserveWhitespaces") ? metaObj.getBoolean("preserveWhitespaces") : false,
|
|
710
|
+
// We normalize line endings if the template is was inline.
|
|
555
711
|
i18nNormalizeLineEndingsInICUs: isInline,
|
|
556
712
|
enableBlockSyntax,
|
|
557
713
|
enableLetSyntax,
|
|
714
|
+
// TODO(crisbeto): figure out how this is enabled.
|
|
558
715
|
enableSelectorless: false
|
|
559
716
|
});
|
|
560
717
|
if (template.errors !== null) {
|
|
@@ -575,7 +732,12 @@ ${errors}`);
|
|
|
575
732
|
declarations.push(...metaObj.getArray("components").map((dir) => {
|
|
576
733
|
const dirExpr = dir.getObject();
|
|
577
734
|
const typeExpr = extractDeclarationTypeExpr(dirExpr.getValue("type"));
|
|
578
|
-
return makeDirectiveMetadata(
|
|
735
|
+
return makeDirectiveMetadata(
|
|
736
|
+
dirExpr,
|
|
737
|
+
typeExpr,
|
|
738
|
+
/* isComponentByDefault */
|
|
739
|
+
true
|
|
740
|
+
);
|
|
579
741
|
}));
|
|
580
742
|
}
|
|
581
743
|
if (metaObj.has("directives")) {
|
|
@@ -655,6 +817,9 @@ ${errors}`);
|
|
|
655
817
|
hasDirectiveDependencies: !baseMeta.isStandalone || hasDirectiveDependencies
|
|
656
818
|
};
|
|
657
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* Update the range to remove the start and end chars, which should be quotes around the template.
|
|
822
|
+
*/
|
|
658
823
|
getTemplateInfo(templateNode, isInline) {
|
|
659
824
|
const range = templateNode.getRange();
|
|
660
825
|
if (!isInline) {
|
|
@@ -749,7 +914,7 @@ function parseChangeDetectionStrategy(changeDetectionStrategy) {
|
|
|
749
914
|
return enumValue;
|
|
750
915
|
}
|
|
751
916
|
|
|
752
|
-
//
|
|
917
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_factory_linker_1.js
|
|
753
918
|
import { compileFactoryFunction, FactoryTarget } from "@angular/compiler";
|
|
754
919
|
var PartialFactoryLinkerVersion1 = class {
|
|
755
920
|
linkPartialDeclaration(constantPool, metaObj) {
|
|
@@ -785,12 +950,16 @@ function getDependencies(metaObj, propName) {
|
|
|
785
950
|
return null;
|
|
786
951
|
}
|
|
787
952
|
|
|
788
|
-
//
|
|
953
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_injectable_linker_1.js
|
|
789
954
|
import { compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression2, outputAst as o3 } from "@angular/compiler";
|
|
790
955
|
var PartialInjectableLinkerVersion1 = class {
|
|
791
956
|
linkPartialDeclaration(constantPool, metaObj) {
|
|
792
957
|
const meta = toR3InjectableMeta(metaObj);
|
|
793
|
-
return compileInjectable(
|
|
958
|
+
return compileInjectable(
|
|
959
|
+
meta,
|
|
960
|
+
/* resolveForwardRefs */
|
|
961
|
+
false
|
|
962
|
+
);
|
|
794
963
|
}
|
|
795
964
|
};
|
|
796
965
|
function toR3InjectableMeta(metaObj) {
|
|
@@ -803,7 +972,11 @@ function toR3InjectableMeta(metaObj) {
|
|
|
803
972
|
name: typeName,
|
|
804
973
|
type: wrapReference(typeExpr.getOpaque()),
|
|
805
974
|
typeArgumentCount: 0,
|
|
806
|
-
providedIn: metaObj.has("providedIn") ? extractForwardRef(metaObj.getValue("providedIn")) : createMayBeForwardRefExpression2(
|
|
975
|
+
providedIn: metaObj.has("providedIn") ? extractForwardRef(metaObj.getValue("providedIn")) : createMayBeForwardRefExpression2(
|
|
976
|
+
o3.literal(null),
|
|
977
|
+
0
|
|
978
|
+
/* ForwardRefHandling.None */
|
|
979
|
+
)
|
|
807
980
|
};
|
|
808
981
|
if (metaObj.has("useClass")) {
|
|
809
982
|
meta.useClass = extractForwardRef(metaObj.getValue("useClass"));
|
|
@@ -823,7 +996,7 @@ function toR3InjectableMeta(metaObj) {
|
|
|
823
996
|
return meta;
|
|
824
997
|
}
|
|
825
998
|
|
|
826
|
-
//
|
|
999
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_injector_linker_1.js
|
|
827
1000
|
import { compileInjector } from "@angular/compiler";
|
|
828
1001
|
var PartialInjectorLinkerVersion1 = class {
|
|
829
1002
|
linkPartialDeclaration(constantPool, metaObj) {
|
|
@@ -845,7 +1018,7 @@ function toR3InjectorMeta(metaObj) {
|
|
|
845
1018
|
};
|
|
846
1019
|
}
|
|
847
1020
|
|
|
848
|
-
//
|
|
1021
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_ng_module_linker_1.js
|
|
849
1022
|
import { compileNgModule, R3NgModuleMetadataKind, R3SelectorScopeMode } from "@angular/compiler";
|
|
850
1023
|
var PartialNgModuleLinkerVersion1 = class {
|
|
851
1024
|
emitInline;
|
|
@@ -918,7 +1091,7 @@ function wrapReferences(values) {
|
|
|
918
1091
|
return values.getArray().map((i) => wrapReference(i.getOpaque()));
|
|
919
1092
|
}
|
|
920
1093
|
|
|
921
|
-
//
|
|
1094
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_pipe_linker_1.js
|
|
922
1095
|
import { compilePipeFromMetadata } from "@angular/compiler";
|
|
923
1096
|
var PartialPipeLinkerVersion1 = class {
|
|
924
1097
|
constructor() {
|
|
@@ -947,7 +1120,7 @@ function toR3PipeMeta(metaObj, version) {
|
|
|
947
1120
|
};
|
|
948
1121
|
}
|
|
949
1122
|
|
|
950
|
-
//
|
|
1123
|
+
// packages/compiler-cli/linker/src/file_linker/partial_linkers/partial_linker_selector.js
|
|
951
1124
|
var \u0275\u0275ngDeclareDirective = "\u0275\u0275ngDeclareDirective";
|
|
952
1125
|
var \u0275\u0275ngDeclareClassMetadata = "\u0275\u0275ngDeclareClassMetadata";
|
|
953
1126
|
var \u0275\u0275ngDeclareComponent = "\u0275\u0275ngDeclareComponent";
|
|
@@ -1015,9 +1188,16 @@ var PartialLinkerSelector = class {
|
|
|
1015
1188
|
this.logger = logger;
|
|
1016
1189
|
this.unknownDeclarationVersionHandling = unknownDeclarationVersionHandling;
|
|
1017
1190
|
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Returns true if there are `PartialLinker` classes that can handle functions with this name.
|
|
1193
|
+
*/
|
|
1018
1194
|
supportsDeclaration(functionName) {
|
|
1019
1195
|
return this.linkers.has(functionName);
|
|
1020
1196
|
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Returns the `PartialLinker` that can handle functions with the given name and version.
|
|
1199
|
+
* Throws an error if there is none.
|
|
1200
|
+
*/
|
|
1021
1201
|
getLinker(functionName, minVersion, version) {
|
|
1022
1202
|
if (!this.linkers.has(functionName)) {
|
|
1023
1203
|
throw new Error(`Unknown partial declaration function ${functionName}.`);
|
|
@@ -1052,7 +1232,7 @@ function getRange(comparator, versionStr) {
|
|
|
1052
1232
|
return new semver3.Range(`${comparator}${version.format()}`);
|
|
1053
1233
|
}
|
|
1054
1234
|
|
|
1055
|
-
//
|
|
1235
|
+
// packages/compiler-cli/linker/src/file_linker/file_linker.js
|
|
1056
1236
|
var FileLinker = class {
|
|
1057
1237
|
linkerEnvironment;
|
|
1058
1238
|
linkerSelector;
|
|
@@ -1061,9 +1241,24 @@ var FileLinker = class {
|
|
|
1061
1241
|
this.linkerEnvironment = linkerEnvironment;
|
|
1062
1242
|
this.linkerSelector = new PartialLinkerSelector(createLinkerMap(this.linkerEnvironment, sourceUrl, code), this.linkerEnvironment.logger, this.linkerEnvironment.options.unknownDeclarationVersionHandling);
|
|
1063
1243
|
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Return true if the given callee name matches a partial declaration that can be linked.
|
|
1246
|
+
*/
|
|
1064
1247
|
isPartialDeclaration(calleeName) {
|
|
1065
1248
|
return this.linkerSelector.supportsDeclaration(calleeName);
|
|
1066
1249
|
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Link the metadata extracted from the args of a call to a partial declaration function.
|
|
1252
|
+
*
|
|
1253
|
+
* The `declarationScope` is used to determine the scope and strategy of emission of the linked
|
|
1254
|
+
* definition and any shared constant statements.
|
|
1255
|
+
*
|
|
1256
|
+
* @param declarationFn the name of the function used to declare the partial declaration - e.g.
|
|
1257
|
+
* `ɵɵngDeclareDirective`.
|
|
1258
|
+
* @param args the arguments passed to the declaration function, should be a single object that
|
|
1259
|
+
* corresponds to the `R3DeclareDirectiveMetadata` or `R3DeclareComponentMetadata` interfaces.
|
|
1260
|
+
* @param declarationScope the scope that contains this call to the declaration function.
|
|
1261
|
+
*/
|
|
1067
1262
|
linkPartialDeclaration(declarationFn, args, declarationScope) {
|
|
1068
1263
|
if (args.length !== 1) {
|
|
1069
1264
|
throw new Error(`Invalid function call: It should have only a single object literal argument, but contained ${args.length}.`);
|
|
@@ -1077,6 +1272,10 @@ var FileLinker = class {
|
|
|
1077
1272
|
const definition = linker.linkPartialDeclaration(emitScope.constantPool, metaObj, version);
|
|
1078
1273
|
return emitScope.translateDefinition(definition);
|
|
1079
1274
|
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Return all the shared constant statements and their associated constant scope references, so
|
|
1277
|
+
* that they can be inserted into the source code.
|
|
1278
|
+
*/
|
|
1080
1279
|
getConstantStatements() {
|
|
1081
1280
|
const results = [];
|
|
1082
1281
|
for (const [constantScope, emitScope] of this.emitScopes.entries()) {
|
|
@@ -1097,29 +1296,35 @@ var FileLinker = class {
|
|
|
1097
1296
|
}
|
|
1098
1297
|
};
|
|
1099
1298
|
|
|
1100
|
-
//
|
|
1299
|
+
// packages/compiler-cli/linker/src/file_linker/linker_options.js
|
|
1101
1300
|
var DEFAULT_LINKER_OPTIONS = {
|
|
1102
1301
|
sourceMapping: true,
|
|
1103
1302
|
linkerJitMode: false,
|
|
1104
1303
|
unknownDeclarationVersionHandling: "error"
|
|
1105
1304
|
};
|
|
1106
1305
|
|
|
1107
|
-
//
|
|
1306
|
+
// packages/compiler-cli/linker/src/file_linker/translator.js
|
|
1108
1307
|
var Translator = class {
|
|
1109
1308
|
factory;
|
|
1110
1309
|
constructor(factory) {
|
|
1111
1310
|
this.factory = factory;
|
|
1112
1311
|
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Translate the given output AST in the context of an expression.
|
|
1314
|
+
*/
|
|
1113
1315
|
translateExpression(expression, imports, options = {}) {
|
|
1114
1316
|
return expression.visitExpression(new ExpressionTranslatorVisitor(this.factory, imports, null, options), new Context(false));
|
|
1115
1317
|
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Translate the given output AST in the context of a statement.
|
|
1320
|
+
*/
|
|
1116
1321
|
translateStatement(statement, imports, options = {}) {
|
|
1117
1322
|
return statement.visitStatement(new ExpressionTranslatorVisitor(this.factory, imports, null, options), new Context(true));
|
|
1118
1323
|
}
|
|
1119
1324
|
};
|
|
1120
1325
|
|
|
1121
|
-
//
|
|
1122
|
-
var LinkerEnvironment = class {
|
|
1326
|
+
// packages/compiler-cli/linker/src/file_linker/linker_environment.js
|
|
1327
|
+
var LinkerEnvironment = class _LinkerEnvironment {
|
|
1123
1328
|
fileSystem;
|
|
1124
1329
|
logger;
|
|
1125
1330
|
host;
|
|
@@ -1137,7 +1342,7 @@ var LinkerEnvironment = class {
|
|
|
1137
1342
|
this.sourceFileLoader = this.options.sourceMapping ? new SourceFileLoader(this.fileSystem, this.logger, {}) : null;
|
|
1138
1343
|
}
|
|
1139
1344
|
static create(fileSystem, logger, host, factory, options) {
|
|
1140
|
-
return new
|
|
1345
|
+
return new _LinkerEnvironment(fileSystem, logger, host, factory, {
|
|
1141
1346
|
sourceMapping: options.sourceMapping ?? DEFAULT_LINKER_OPTIONS.sourceMapping,
|
|
1142
1347
|
linkerJitMode: options.linkerJitMode ?? DEFAULT_LINKER_OPTIONS.linkerJitMode,
|
|
1143
1348
|
unknownDeclarationVersionHandling: options.unknownDeclarationVersionHandling ?? DEFAULT_LINKER_OPTIONS.unknownDeclarationVersionHandling
|
|
@@ -1145,7 +1350,7 @@ var LinkerEnvironment = class {
|
|
|
1145
1350
|
}
|
|
1146
1351
|
};
|
|
1147
1352
|
|
|
1148
|
-
//
|
|
1353
|
+
// packages/compiler-cli/linker/src/file_linker/needs_linking.js
|
|
1149
1354
|
function needsLinking(path, source) {
|
|
1150
1355
|
return declarationFunctions.some((fn) => source.includes(fn));
|
|
1151
1356
|
}
|
|
@@ -1166,4 +1371,3 @@ export {
|
|
|
1166
1371
|
* Use of this source code is governed by an MIT-style license that can be
|
|
1167
1372
|
* found in the LICENSE file at https://angular.dev/license
|
|
1168
1373
|
*/
|
|
1169
|
-
//# sourceMappingURL=chunk-FPHHL4UV.js.map
|