@angular/core 20.0.0-next.4 → 20.0.0-next.6
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/api.d-DQLNOR5l.d.ts +297 -0
- package/discovery.d-CFs2MaLO.d.ts +7383 -0
- package/{event_dispatcher.d-pVP0-wST.d.ts → event_dispatcher.d-DlbccpYq.d.ts} +3 -2
- package/fesm2022/attribute-BWp59EjE.mjs +24 -0
- package/fesm2022/attribute-BWp59EjE.mjs.map +1 -0
- package/fesm2022/core.mjs +586 -36873
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/debug_node-z_3NG8qT.mjs +32079 -0
- package/fesm2022/debug_node-z_3NG8qT.mjs.map +1 -0
- package/fesm2022/primitives/di.mjs +18 -4
- package/fesm2022/primitives/di.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +2 -16
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +5 -3
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/resource-CPPwEcg7.mjs +619 -0
- package/fesm2022/resource-CPPwEcg7.mjs.map +1 -0
- package/fesm2022/root_effect_scheduler-VSXfCzDX.mjs +3847 -0
- package/fesm2022/root_effect_scheduler-VSXfCzDX.mjs.map +1 -0
- package/fesm2022/rxjs-interop.mjs +16 -9
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/{untracked-DkcXpNb_.mjs → signal-B6pMq7KS.mjs} +16 -114
- package/fesm2022/signal-B6pMq7KS.mjs.map +1 -0
- package/fesm2022/testing.mjs +265 -201
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/untracked-Bz5WMeU1.mjs +117 -0
- package/fesm2022/untracked-Bz5WMeU1.mjs.map +1 -0
- package/fesm2022/weak_ref-BaIq-pgY.mjs +12 -0
- package/fesm2022/weak_ref-BaIq-pgY.mjs.map +1 -0
- package/{weak_ref.d-BZ7gyRag.d.ts → graph.d-BcIOep_B.d.ts} +3 -24
- package/index.d.ts +2624 -10909
- package/ng_i18n_closure_mode.d-C9d2CaSt.d.ts +832 -0
- package/package.json +3 -3
- package/primitives/di/index.d.ts +3 -2
- package/primitives/event-dispatch/index.d.ts +3 -3
- package/primitives/signals/index.d.ts +8 -4
- package/rxjs-interop/index.d.ts +10 -7
- package/schematics/bundles/{apply_import_manager-CeNv8GIG.js → apply_import_manager-DnMqg1pY.js} +6 -6
- package/schematics/bundles/{compiler_host-DwM3ugW3.js → change_tracker-UMPkv-eH.js} +3 -121
- package/schematics/bundles/checker-BFBQyesT.js +17719 -0
- package/schematics/bundles/cleanup-unused-imports.js +25 -19
- package/schematics/bundles/{checker-k591b6WQ.js → compiler-BQ7R7w2v.js} +1325 -18286
- package/schematics/bundles/compiler_host-CAfDJO3W.js +129 -0
- package/schematics/bundles/control-flow-migration.js +28 -40
- package/schematics/bundles/document-core.js +96 -0
- package/schematics/bundles/imports-CIX-JgAN.js +1 -1
- package/schematics/bundles/{index-B4OAlHh8.js → index-Cv4Q415G.js} +641 -547
- package/schematics/bundles/{index-BhELUmYx.js → index-D8tMJPKa.js} +35 -34
- package/schematics/bundles/inject-flags.js +14 -13
- package/schematics/bundles/inject-migration.js +29 -10
- package/schematics/bundles/leading_space-D9nQ8UQC.js +1 -1
- package/schematics/bundles/{migrate_ts_type_references-Be0TNYen.js → migrate_ts_type_references-Cq_ZBuT4.js} +21 -20
- package/schematics/bundles/ng_decorators-DznZ5jMl.js +1 -1
- package/schematics/bundles/nodes-B16H9JUd.js +1 -1
- package/schematics/bundles/output-migration.js +88 -25
- package/schematics/bundles/{run_in_devkit-CkvEksWP.js → project_paths-ql6qcf_c.js} +254 -243
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.js +1 -1
- package/schematics/bundles/property_name-BBwFuqMe.js +1 -1
- package/schematics/bundles/route-lazy-loading.js +7 -5
- package/schematics/bundles/self-closing-tags-migration.js +25 -19
- package/schematics/bundles/signal-input-migration.js +26 -20
- package/schematics/bundles/signal-queries-migration.js +51 -33
- package/schematics/bundles/signals.js +8 -7
- package/schematics/bundles/standalone-migration.js +11 -9
- package/schematics/bundles/symbol-VPWguRxr.js +1 -1
- package/schematics/bundles/test-bed-get.js +13 -12
- package/schematics/collection.json +0 -6
- package/schematics/migrations.json +11 -0
- package/signal.d-E0e5nW1p.d.ts +31 -0
- package/testing/index.d.ts +16 -28
- package/weak_ref.d-eGOEP9S1.d.ts +9 -0
- package/fesm2022/injector-BlLwZ2sr.mjs +0 -24
- package/fesm2022/injector-BlLwZ2sr.mjs.map +0 -1
- package/fesm2022/untracked-DkcXpNb_.mjs.map +0 -1
- package/navigation_types.d-DgDrF5rp.d.ts +0 -121
- package/schematics/ng-generate/control-flow-migration/schema.json +0 -20
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
3
|
+
* @license Angular v20.0.0-next.6
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var compiler = require('./compiler-BQ7R7w2v.js');
|
|
10
10
|
var ts = require('typescript');
|
|
11
11
|
var p = require('path');
|
|
12
|
+
var checker = require('./checker-BFBQyesT.js');
|
|
12
13
|
require('os');
|
|
13
14
|
|
|
14
15
|
function _interopNamespaceDefault(e) {
|
|
@@ -44,7 +45,7 @@ class XmlTagDefinition {
|
|
|
44
45
|
return false;
|
|
45
46
|
}
|
|
46
47
|
getContentType() {
|
|
47
|
-
return
|
|
48
|
+
return compiler.TagContentType.PARSABLE_DATA;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
const _TAG_DEFINITION = new XmlTagDefinition();
|
|
@@ -52,13 +53,18 @@ function getXmlTagDefinition(tagName) {
|
|
|
52
53
|
return _TAG_DEFINITION;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
class XmlParser extends
|
|
56
|
+
class XmlParser extends compiler.Parser {
|
|
56
57
|
constructor() {
|
|
57
58
|
super(getXmlTagDefinition);
|
|
58
59
|
}
|
|
59
60
|
parse(source, url, options = {}) {
|
|
60
61
|
// Blocks and let declarations aren't supported in an XML context.
|
|
61
|
-
return super.parse(source, url, {
|
|
62
|
+
return super.parse(source, url, {
|
|
63
|
+
...options,
|
|
64
|
+
tokenizeBlocks: false,
|
|
65
|
+
tokenizeLet: false,
|
|
66
|
+
selectorlessEnabled: false,
|
|
67
|
+
});
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
|
|
@@ -78,50 +84,50 @@ const _CONTEXT_GROUP_TAG = 'context-group';
|
|
|
78
84
|
const _CONTEXT_TAG = 'context';
|
|
79
85
|
// https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html
|
|
80
86
|
// https://docs.oasis-open.org/xliff/v1.2/xliff-profile-html/xliff-profile-html-1.2.html
|
|
81
|
-
class Xliff extends
|
|
87
|
+
class Xliff extends compiler.Serializer {
|
|
82
88
|
write(messages, locale) {
|
|
83
89
|
const visitor = new _WriteVisitor$1();
|
|
84
90
|
const transUnits = [];
|
|
85
91
|
messages.forEach((message) => {
|
|
86
92
|
let contextTags = [];
|
|
87
93
|
message.sources.forEach((source) => {
|
|
88
|
-
let contextGroupTag = new
|
|
89
|
-
contextGroupTag.children.push(new
|
|
90
|
-
new
|
|
91
|
-
]), new
|
|
92
|
-
new
|
|
93
|
-
]), new
|
|
94
|
-
contextTags.push(new
|
|
94
|
+
let contextGroupTag = new compiler.Tag(_CONTEXT_GROUP_TAG, { purpose: 'location' });
|
|
95
|
+
contextGroupTag.children.push(new compiler.CR(10), new compiler.Tag(_CONTEXT_TAG, { 'context-type': 'sourcefile' }, [
|
|
96
|
+
new compiler.Text$1(source.filePath),
|
|
97
|
+
]), new compiler.CR(10), new compiler.Tag(_CONTEXT_TAG, { 'context-type': 'linenumber' }, [
|
|
98
|
+
new compiler.Text$1(`${source.startLine}`),
|
|
99
|
+
]), new compiler.CR(8));
|
|
100
|
+
contextTags.push(new compiler.CR(8), contextGroupTag);
|
|
95
101
|
});
|
|
96
|
-
const transUnit = new
|
|
97
|
-
transUnit.children.push(new
|
|
102
|
+
const transUnit = new compiler.Tag(_UNIT_TAG$1, { id: message.id, datatype: 'html' });
|
|
103
|
+
transUnit.children.push(new compiler.CR(8), new compiler.Tag(_SOURCE_TAG$1, {}, visitor.serialize(message.nodes)), ...contextTags);
|
|
98
104
|
if (message.description) {
|
|
99
|
-
transUnit.children.push(new
|
|
100
|
-
new
|
|
105
|
+
transUnit.children.push(new compiler.CR(8), new compiler.Tag('note', { priority: '1', from: 'description' }, [
|
|
106
|
+
new compiler.Text$1(message.description),
|
|
101
107
|
]));
|
|
102
108
|
}
|
|
103
109
|
if (message.meaning) {
|
|
104
|
-
transUnit.children.push(new
|
|
110
|
+
transUnit.children.push(new compiler.CR(8), new compiler.Tag('note', { priority: '1', from: 'meaning' }, [new compiler.Text$1(message.meaning)]));
|
|
105
111
|
}
|
|
106
|
-
transUnit.children.push(new
|
|
107
|
-
transUnits.push(new
|
|
112
|
+
transUnit.children.push(new compiler.CR(6));
|
|
113
|
+
transUnits.push(new compiler.CR(6), transUnit);
|
|
108
114
|
});
|
|
109
|
-
const body = new
|
|
110
|
-
const file = new
|
|
115
|
+
const body = new compiler.Tag('body', {}, [...transUnits, new compiler.CR(4)]);
|
|
116
|
+
const file = new compiler.Tag('file', {
|
|
111
117
|
'source-language': locale || _DEFAULT_SOURCE_LANG$1,
|
|
112
118
|
datatype: 'plaintext',
|
|
113
119
|
original: 'ng2.template',
|
|
114
|
-
}, [new
|
|
115
|
-
const xliff = new
|
|
116
|
-
new
|
|
120
|
+
}, [new compiler.CR(4), body, new compiler.CR(2)]);
|
|
121
|
+
const xliff = new compiler.Tag('xliff', { version: _VERSION$1, xmlns: _XMLNS$1 }, [
|
|
122
|
+
new compiler.CR(2),
|
|
117
123
|
file,
|
|
118
|
-
new
|
|
124
|
+
new compiler.CR(),
|
|
119
125
|
]);
|
|
120
|
-
return
|
|
121
|
-
new
|
|
122
|
-
new
|
|
126
|
+
return compiler.serialize([
|
|
127
|
+
new compiler.Declaration({ version: '1.0', encoding: 'UTF-8' }),
|
|
128
|
+
new compiler.CR(),
|
|
123
129
|
xliff,
|
|
124
|
-
new
|
|
130
|
+
new compiler.CR(),
|
|
125
131
|
]);
|
|
126
132
|
}
|
|
127
133
|
load(content, url) {
|
|
@@ -142,12 +148,12 @@ class Xliff extends checker.Serializer {
|
|
|
142
148
|
return { locale: locale, i18nNodesByMsgId };
|
|
143
149
|
}
|
|
144
150
|
digest(message) {
|
|
145
|
-
return
|
|
151
|
+
return compiler.digest(message);
|
|
146
152
|
}
|
|
147
153
|
}
|
|
148
154
|
let _WriteVisitor$1 = class _WriteVisitor {
|
|
149
155
|
visitText(text, context) {
|
|
150
|
-
return [new
|
|
156
|
+
return [new compiler.Text$1(text.value)];
|
|
151
157
|
}
|
|
152
158
|
visitContainer(container, context) {
|
|
153
159
|
const nodes = [];
|
|
@@ -155,11 +161,11 @@ let _WriteVisitor$1 = class _WriteVisitor {
|
|
|
155
161
|
return nodes;
|
|
156
162
|
}
|
|
157
163
|
visitIcu(icu, context) {
|
|
158
|
-
const nodes = [new
|
|
164
|
+
const nodes = [new compiler.Text$1(`{${icu.expressionPlaceholder}, ${icu.type}, `)];
|
|
159
165
|
Object.keys(icu.cases).forEach((c) => {
|
|
160
|
-
nodes.push(new
|
|
166
|
+
nodes.push(new compiler.Text$1(`${c} {`), ...icu.cases[c].visit(this), new compiler.Text$1(`} `));
|
|
161
167
|
});
|
|
162
|
-
nodes.push(new
|
|
168
|
+
nodes.push(new compiler.Text$1(`}`));
|
|
163
169
|
return nodes;
|
|
164
170
|
}
|
|
165
171
|
visitTagPlaceholder(ph, context) {
|
|
@@ -167,15 +173,15 @@ let _WriteVisitor$1 = class _WriteVisitor {
|
|
|
167
173
|
if (ph.isVoid) {
|
|
168
174
|
// void tags have no children nor closing tags
|
|
169
175
|
return [
|
|
170
|
-
new
|
|
176
|
+
new compiler.Tag(_PLACEHOLDER_TAG$1, { id: ph.startName, ctype, 'equiv-text': `<${ph.tag}/>` }),
|
|
171
177
|
];
|
|
172
178
|
}
|
|
173
|
-
const startTagPh = new
|
|
179
|
+
const startTagPh = new compiler.Tag(_PLACEHOLDER_TAG$1, {
|
|
174
180
|
id: ph.startName,
|
|
175
181
|
ctype,
|
|
176
182
|
'equiv-text': `<${ph.tag}>`,
|
|
177
183
|
});
|
|
178
|
-
const closeTagPh = new
|
|
184
|
+
const closeTagPh = new compiler.Tag(_PLACEHOLDER_TAG$1, {
|
|
179
185
|
id: ph.closeName,
|
|
180
186
|
ctype,
|
|
181
187
|
'equiv-text': `</${ph.tag}>`,
|
|
@@ -183,23 +189,23 @@ let _WriteVisitor$1 = class _WriteVisitor {
|
|
|
183
189
|
return [startTagPh, ...this.serialize(ph.children), closeTagPh];
|
|
184
190
|
}
|
|
185
191
|
visitPlaceholder(ph, context) {
|
|
186
|
-
return [new
|
|
192
|
+
return [new compiler.Tag(_PLACEHOLDER_TAG$1, { id: ph.name, 'equiv-text': `{{${ph.value}}}` })];
|
|
187
193
|
}
|
|
188
194
|
visitBlockPlaceholder(ph, context) {
|
|
189
195
|
const ctype = `x-${ph.name.toLowerCase().replace(/[^a-z0-9]/g, '-')}`;
|
|
190
|
-
const startTagPh = new
|
|
196
|
+
const startTagPh = new compiler.Tag(_PLACEHOLDER_TAG$1, {
|
|
191
197
|
id: ph.startName,
|
|
192
198
|
ctype,
|
|
193
199
|
'equiv-text': `@${ph.name}`,
|
|
194
200
|
});
|
|
195
|
-
const closeTagPh = new
|
|
201
|
+
const closeTagPh = new compiler.Tag(_PLACEHOLDER_TAG$1, { id: ph.closeName, ctype, 'equiv-text': `}` });
|
|
196
202
|
return [startTagPh, ...this.serialize(ph.children), closeTagPh];
|
|
197
203
|
}
|
|
198
204
|
visitIcuPlaceholder(ph, context) {
|
|
199
205
|
const equivText = `{${ph.value.expression}, ${ph.value.type}, ${Object.keys(ph.value.cases)
|
|
200
206
|
.map((value) => value + ' {...}')
|
|
201
207
|
.join(' ')}}`;
|
|
202
|
-
return [new
|
|
208
|
+
return [new compiler.Tag(_PLACEHOLDER_TAG$1, { id: ph.name, 'equiv-text': equivText })];
|
|
203
209
|
}
|
|
204
210
|
serialize(nodes) {
|
|
205
211
|
return [].concat(...nodes.map((node) => node.visit(this)));
|
|
@@ -218,7 +224,7 @@ class XliffParser {
|
|
|
218
224
|
this._msgIdToHtml = {};
|
|
219
225
|
const xml = new XmlParser().parse(xliff, url);
|
|
220
226
|
this._errors = xml.errors;
|
|
221
|
-
|
|
227
|
+
compiler.visitAll$1(this, xml.rootNodes, null);
|
|
222
228
|
return {
|
|
223
229
|
msgIdToHtml: this._msgIdToHtml,
|
|
224
230
|
errors: this._errors,
|
|
@@ -239,7 +245,7 @@ class XliffParser {
|
|
|
239
245
|
this._addError(element, `Duplicated translations for msg ${id}`);
|
|
240
246
|
}
|
|
241
247
|
else {
|
|
242
|
-
|
|
248
|
+
compiler.visitAll$1(this, element.children, null);
|
|
243
249
|
if (typeof this._unitMlString === 'string') {
|
|
244
250
|
this._msgIdToHtml[id] = this._unitMlString;
|
|
245
251
|
}
|
|
@@ -266,12 +272,12 @@ class XliffParser {
|
|
|
266
272
|
if (localeAttr) {
|
|
267
273
|
this._locale = localeAttr.value;
|
|
268
274
|
}
|
|
269
|
-
|
|
275
|
+
compiler.visitAll$1(this, element.children, null);
|
|
270
276
|
break;
|
|
271
277
|
default:
|
|
272
278
|
// TODO(vicb): assert file structure, xliff version
|
|
273
279
|
// For now only recurse on unhandled nodes
|
|
274
|
-
|
|
280
|
+
compiler.visitAll$1(this, element.children, null);
|
|
275
281
|
}
|
|
276
282
|
}
|
|
277
283
|
visitAttribute(attribute, context) { }
|
|
@@ -282,8 +288,10 @@ class XliffParser {
|
|
|
282
288
|
visitBlock(block, context) { }
|
|
283
289
|
visitBlockParameter(parameter, context) { }
|
|
284
290
|
visitLetDeclaration(decl, context) { }
|
|
291
|
+
visitComponent(component, context) { }
|
|
292
|
+
visitDirective(directive, context) { }
|
|
285
293
|
_addError(node, message) {
|
|
286
|
-
this._errors.push(new
|
|
294
|
+
this._errors.push(new compiler.I18nError(node.sourceSpan, message));
|
|
287
295
|
}
|
|
288
296
|
}
|
|
289
297
|
// Convert ml nodes (xliff syntax) to i18n nodes
|
|
@@ -295,41 +303,41 @@ let XmlToI18n$1 = class XmlToI18n {
|
|
|
295
303
|
this._errors = xmlIcu.errors;
|
|
296
304
|
const i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0
|
|
297
305
|
? []
|
|
298
|
-
: [].concat(...
|
|
306
|
+
: [].concat(...compiler.visitAll$1(this, xmlIcu.rootNodes));
|
|
299
307
|
return {
|
|
300
308
|
i18nNodes: i18nNodes,
|
|
301
309
|
errors: this._errors,
|
|
302
310
|
};
|
|
303
311
|
}
|
|
304
312
|
visitText(text, context) {
|
|
305
|
-
return new
|
|
313
|
+
return new compiler.Text$2(text.value, text.sourceSpan);
|
|
306
314
|
}
|
|
307
315
|
visitElement(el, context) {
|
|
308
316
|
if (el.name === _PLACEHOLDER_TAG$1) {
|
|
309
317
|
const nameAttr = el.attrs.find((attr) => attr.name === 'id');
|
|
310
318
|
if (nameAttr) {
|
|
311
|
-
return new
|
|
319
|
+
return new compiler.Placeholder('', nameAttr.value, el.sourceSpan);
|
|
312
320
|
}
|
|
313
321
|
this._addError(el, `<${_PLACEHOLDER_TAG$1}> misses the "id" attribute`);
|
|
314
322
|
return null;
|
|
315
323
|
}
|
|
316
324
|
if (el.name === _MARKER_TAG$1) {
|
|
317
|
-
return [].concat(...
|
|
325
|
+
return [].concat(...compiler.visitAll$1(this, el.children));
|
|
318
326
|
}
|
|
319
327
|
this._addError(el, `Unexpected tag`);
|
|
320
328
|
return null;
|
|
321
329
|
}
|
|
322
330
|
visitExpansion(icu, context) {
|
|
323
331
|
const caseMap = {};
|
|
324
|
-
|
|
325
|
-
caseMap[c.value] = new
|
|
332
|
+
compiler.visitAll$1(this, icu.cases).forEach((c) => {
|
|
333
|
+
caseMap[c.value] = new compiler.Container(c.nodes, icu.sourceSpan);
|
|
326
334
|
});
|
|
327
|
-
return new
|
|
335
|
+
return new compiler.Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
|
|
328
336
|
}
|
|
329
337
|
visitExpansionCase(icuCase, context) {
|
|
330
338
|
return {
|
|
331
339
|
value: icuCase.value,
|
|
332
|
-
nodes:
|
|
340
|
+
nodes: compiler.visitAll$1(this, icuCase.expression),
|
|
333
341
|
};
|
|
334
342
|
}
|
|
335
343
|
visitComment(comment, context) { }
|
|
@@ -337,8 +345,14 @@ let XmlToI18n$1 = class XmlToI18n {
|
|
|
337
345
|
visitBlock(block, context) { }
|
|
338
346
|
visitBlockParameter(parameter, context) { }
|
|
339
347
|
visitLetDeclaration(decl, context) { }
|
|
348
|
+
visitComponent(component, context) {
|
|
349
|
+
this._addError(component, 'Unexpected node');
|
|
350
|
+
}
|
|
351
|
+
visitDirective(directive, context) {
|
|
352
|
+
this._addError(directive, 'Unexpected node');
|
|
353
|
+
}
|
|
340
354
|
_addError(node, message) {
|
|
341
|
-
this._errors.push(new
|
|
355
|
+
this._errors.push(new compiler.I18nError(node.sourceSpan, message));
|
|
342
356
|
}
|
|
343
357
|
};
|
|
344
358
|
function getCtypeForTag(tag) {
|
|
@@ -364,43 +378,43 @@ const _SOURCE_TAG = 'source';
|
|
|
364
378
|
const _TARGET_TAG = 'target';
|
|
365
379
|
const _UNIT_TAG = 'unit';
|
|
366
380
|
// https://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html
|
|
367
|
-
class Xliff2 extends
|
|
381
|
+
class Xliff2 extends compiler.Serializer {
|
|
368
382
|
write(messages, locale) {
|
|
369
383
|
const visitor = new _WriteVisitor();
|
|
370
384
|
const units = [];
|
|
371
385
|
messages.forEach((message) => {
|
|
372
|
-
const unit = new
|
|
373
|
-
const notes = new
|
|
386
|
+
const unit = new compiler.Tag(_UNIT_TAG, { id: message.id });
|
|
387
|
+
const notes = new compiler.Tag('notes');
|
|
374
388
|
if (message.description || message.meaning) {
|
|
375
389
|
if (message.description) {
|
|
376
|
-
notes.children.push(new
|
|
390
|
+
notes.children.push(new compiler.CR(8), new compiler.Tag('note', { category: 'description' }, [new compiler.Text$1(message.description)]));
|
|
377
391
|
}
|
|
378
392
|
if (message.meaning) {
|
|
379
|
-
notes.children.push(new
|
|
393
|
+
notes.children.push(new compiler.CR(8), new compiler.Tag('note', { category: 'meaning' }, [new compiler.Text$1(message.meaning)]));
|
|
380
394
|
}
|
|
381
395
|
}
|
|
382
396
|
message.sources.forEach((source) => {
|
|
383
|
-
notes.children.push(new
|
|
384
|
-
new
|
|
397
|
+
notes.children.push(new compiler.CR(8), new compiler.Tag('note', { category: 'location' }, [
|
|
398
|
+
new compiler.Text$1(`${source.filePath}:${source.startLine}${source.endLine !== source.startLine ? ',' + source.endLine : ''}`),
|
|
385
399
|
]));
|
|
386
400
|
});
|
|
387
|
-
notes.children.push(new
|
|
388
|
-
unit.children.push(new
|
|
389
|
-
const segment = new
|
|
390
|
-
segment.children.push(new
|
|
391
|
-
unit.children.push(new
|
|
392
|
-
units.push(new
|
|
401
|
+
notes.children.push(new compiler.CR(6));
|
|
402
|
+
unit.children.push(new compiler.CR(6), notes);
|
|
403
|
+
const segment = new compiler.Tag('segment');
|
|
404
|
+
segment.children.push(new compiler.CR(8), new compiler.Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes)), new compiler.CR(6));
|
|
405
|
+
unit.children.push(new compiler.CR(6), segment, new compiler.CR(4));
|
|
406
|
+
units.push(new compiler.CR(4), unit);
|
|
393
407
|
});
|
|
394
|
-
const file = new
|
|
408
|
+
const file = new compiler.Tag('file', { 'original': 'ng.template', id: 'ngi18n' }, [
|
|
395
409
|
...units,
|
|
396
|
-
new
|
|
410
|
+
new compiler.CR(2),
|
|
397
411
|
]);
|
|
398
|
-
const xliff = new
|
|
399
|
-
return
|
|
400
|
-
new
|
|
401
|
-
new
|
|
412
|
+
const xliff = new compiler.Tag(_XLIFF_TAG, { version: _VERSION, xmlns: _XMLNS, srcLang: locale || _DEFAULT_SOURCE_LANG }, [new compiler.CR(2), file, new compiler.CR()]);
|
|
413
|
+
return compiler.serialize([
|
|
414
|
+
new compiler.Declaration({ version: '1.0', encoding: 'UTF-8' }),
|
|
415
|
+
new compiler.CR(),
|
|
402
416
|
xliff,
|
|
403
|
-
new
|
|
417
|
+
new compiler.CR(),
|
|
404
418
|
]);
|
|
405
419
|
}
|
|
406
420
|
load(content, url) {
|
|
@@ -421,13 +435,13 @@ class Xliff2 extends checker.Serializer {
|
|
|
421
435
|
return { locale: locale, i18nNodesByMsgId };
|
|
422
436
|
}
|
|
423
437
|
digest(message) {
|
|
424
|
-
return
|
|
438
|
+
return compiler.decimalDigest(message);
|
|
425
439
|
}
|
|
426
440
|
}
|
|
427
441
|
class _WriteVisitor {
|
|
428
442
|
_nextPlaceholderId = 0;
|
|
429
443
|
visitText(text, context) {
|
|
430
|
-
return [new
|
|
444
|
+
return [new compiler.Text$1(text.value)];
|
|
431
445
|
}
|
|
432
446
|
visitContainer(container, context) {
|
|
433
447
|
const nodes = [];
|
|
@@ -435,17 +449,17 @@ class _WriteVisitor {
|
|
|
435
449
|
return nodes;
|
|
436
450
|
}
|
|
437
451
|
visitIcu(icu, context) {
|
|
438
|
-
const nodes = [new
|
|
452
|
+
const nodes = [new compiler.Text$1(`{${icu.expressionPlaceholder}, ${icu.type}, `)];
|
|
439
453
|
Object.keys(icu.cases).forEach((c) => {
|
|
440
|
-
nodes.push(new
|
|
454
|
+
nodes.push(new compiler.Text$1(`${c} {`), ...icu.cases[c].visit(this), new compiler.Text$1(`} `));
|
|
441
455
|
});
|
|
442
|
-
nodes.push(new
|
|
456
|
+
nodes.push(new compiler.Text$1(`}`));
|
|
443
457
|
return nodes;
|
|
444
458
|
}
|
|
445
459
|
visitTagPlaceholder(ph, context) {
|
|
446
460
|
const type = getTypeForTag(ph.tag);
|
|
447
461
|
if (ph.isVoid) {
|
|
448
|
-
const tagPh = new
|
|
462
|
+
const tagPh = new compiler.Tag(_PLACEHOLDER_TAG, {
|
|
449
463
|
id: (this._nextPlaceholderId++).toString(),
|
|
450
464
|
equiv: ph.startName,
|
|
451
465
|
type: type,
|
|
@@ -453,7 +467,7 @@ class _WriteVisitor {
|
|
|
453
467
|
});
|
|
454
468
|
return [tagPh];
|
|
455
469
|
}
|
|
456
|
-
const tagPc = new
|
|
470
|
+
const tagPc = new compiler.Tag(_PLACEHOLDER_SPANNING_TAG, {
|
|
457
471
|
id: (this._nextPlaceholderId++).toString(),
|
|
458
472
|
equivStart: ph.startName,
|
|
459
473
|
equivEnd: ph.closeName,
|
|
@@ -466,14 +480,14 @@ class _WriteVisitor {
|
|
|
466
480
|
nodes.forEach((node) => tagPc.children.push(node));
|
|
467
481
|
}
|
|
468
482
|
else {
|
|
469
|
-
tagPc.children.push(new
|
|
483
|
+
tagPc.children.push(new compiler.Text$1(''));
|
|
470
484
|
}
|
|
471
485
|
return [tagPc];
|
|
472
486
|
}
|
|
473
487
|
visitPlaceholder(ph, context) {
|
|
474
488
|
const idStr = (this._nextPlaceholderId++).toString();
|
|
475
489
|
return [
|
|
476
|
-
new
|
|
490
|
+
new compiler.Tag(_PLACEHOLDER_TAG, {
|
|
477
491
|
id: idStr,
|
|
478
492
|
equiv: ph.name,
|
|
479
493
|
disp: `{{${ph.value}}}`,
|
|
@@ -481,7 +495,7 @@ class _WriteVisitor {
|
|
|
481
495
|
];
|
|
482
496
|
}
|
|
483
497
|
visitBlockPlaceholder(ph, context) {
|
|
484
|
-
const tagPc = new
|
|
498
|
+
const tagPc = new compiler.Tag(_PLACEHOLDER_SPANNING_TAG, {
|
|
485
499
|
id: (this._nextPlaceholderId++).toString(),
|
|
486
500
|
equivStart: ph.startName,
|
|
487
501
|
equivEnd: ph.closeName,
|
|
@@ -494,7 +508,7 @@ class _WriteVisitor {
|
|
|
494
508
|
nodes.forEach((node) => tagPc.children.push(node));
|
|
495
509
|
}
|
|
496
510
|
else {
|
|
497
|
-
tagPc.children.push(new
|
|
511
|
+
tagPc.children.push(new compiler.Text$1(''));
|
|
498
512
|
}
|
|
499
513
|
return [tagPc];
|
|
500
514
|
}
|
|
@@ -504,7 +518,7 @@ class _WriteVisitor {
|
|
|
504
518
|
.join(' ');
|
|
505
519
|
const idStr = (this._nextPlaceholderId++).toString();
|
|
506
520
|
return [
|
|
507
|
-
new
|
|
521
|
+
new compiler.Tag(_PLACEHOLDER_TAG, {
|
|
508
522
|
id: idStr,
|
|
509
523
|
equiv: ph.name,
|
|
510
524
|
disp: `{${ph.value.expression}, ${ph.value.type}, ${cases}}`,
|
|
@@ -528,7 +542,7 @@ class Xliff2Parser {
|
|
|
528
542
|
this._msgIdToHtml = {};
|
|
529
543
|
const xml = new XmlParser().parse(xliff, url);
|
|
530
544
|
this._errors = xml.errors;
|
|
531
|
-
|
|
545
|
+
compiler.visitAll$1(this, xml.rootNodes, null);
|
|
532
546
|
return {
|
|
533
547
|
msgIdToHtml: this._msgIdToHtml,
|
|
534
548
|
errors: this._errors,
|
|
@@ -549,7 +563,7 @@ class Xliff2Parser {
|
|
|
549
563
|
this._addError(element, `Duplicated translations for msg ${id}`);
|
|
550
564
|
}
|
|
551
565
|
else {
|
|
552
|
-
|
|
566
|
+
compiler.visitAll$1(this, element.children, null);
|
|
553
567
|
if (typeof this._unitMlString === 'string') {
|
|
554
568
|
this._msgIdToHtml[id] = this._unitMlString;
|
|
555
569
|
}
|
|
@@ -581,12 +595,12 @@ class Xliff2Parser {
|
|
|
581
595
|
this._addError(element, `The XLIFF file version ${version} is not compatible with XLIFF 2.0 serializer`);
|
|
582
596
|
}
|
|
583
597
|
else {
|
|
584
|
-
|
|
598
|
+
compiler.visitAll$1(this, element.children, null);
|
|
585
599
|
}
|
|
586
600
|
}
|
|
587
601
|
break;
|
|
588
602
|
default:
|
|
589
|
-
|
|
603
|
+
compiler.visitAll$1(this, element.children, null);
|
|
590
604
|
}
|
|
591
605
|
}
|
|
592
606
|
visitAttribute(attribute, context) { }
|
|
@@ -597,8 +611,10 @@ class Xliff2Parser {
|
|
|
597
611
|
visitBlock(block, context) { }
|
|
598
612
|
visitBlockParameter(parameter, context) { }
|
|
599
613
|
visitLetDeclaration(decl, context) { }
|
|
614
|
+
visitComponent(component, context) { }
|
|
615
|
+
visitDirective(directive, context) { }
|
|
600
616
|
_addError(node, message) {
|
|
601
|
-
this._errors.push(new
|
|
617
|
+
this._errors.push(new compiler.I18nError(node.sourceSpan, message));
|
|
602
618
|
}
|
|
603
619
|
}
|
|
604
620
|
// Convert ml nodes (xliff syntax) to i18n nodes
|
|
@@ -610,21 +626,21 @@ class XmlToI18n {
|
|
|
610
626
|
this._errors = xmlIcu.errors;
|
|
611
627
|
const i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0
|
|
612
628
|
? []
|
|
613
|
-
: [].concat(...
|
|
629
|
+
: [].concat(...compiler.visitAll$1(this, xmlIcu.rootNodes));
|
|
614
630
|
return {
|
|
615
631
|
i18nNodes,
|
|
616
632
|
errors: this._errors,
|
|
617
633
|
};
|
|
618
634
|
}
|
|
619
635
|
visitText(text, context) {
|
|
620
|
-
return new
|
|
636
|
+
return new compiler.Text$2(text.value, text.sourceSpan);
|
|
621
637
|
}
|
|
622
638
|
visitElement(el, context) {
|
|
623
639
|
switch (el.name) {
|
|
624
640
|
case _PLACEHOLDER_TAG:
|
|
625
641
|
const nameAttr = el.attrs.find((attr) => attr.name === 'equiv');
|
|
626
642
|
if (nameAttr) {
|
|
627
|
-
return [new
|
|
643
|
+
return [new compiler.Placeholder('', nameAttr.value, el.sourceSpan)];
|
|
628
644
|
}
|
|
629
645
|
this._addError(el, `<${_PLACEHOLDER_TAG}> misses the "equiv" attribute`);
|
|
630
646
|
break;
|
|
@@ -641,11 +657,11 @@ class XmlToI18n {
|
|
|
641
657
|
const startId = startAttr.value;
|
|
642
658
|
const endId = endAttr.value;
|
|
643
659
|
const nodes = [];
|
|
644
|
-
return nodes.concat(new
|
|
660
|
+
return nodes.concat(new compiler.Placeholder('', startId, el.sourceSpan), ...el.children.map((node) => node.visit(this, null)), new compiler.Placeholder('', endId, el.sourceSpan));
|
|
645
661
|
}
|
|
646
662
|
break;
|
|
647
663
|
case _MARKER_TAG:
|
|
648
|
-
return [].concat(...
|
|
664
|
+
return [].concat(...compiler.visitAll$1(this, el.children));
|
|
649
665
|
default:
|
|
650
666
|
this._addError(el, `Unexpected tag`);
|
|
651
667
|
}
|
|
@@ -653,15 +669,15 @@ class XmlToI18n {
|
|
|
653
669
|
}
|
|
654
670
|
visitExpansion(icu, context) {
|
|
655
671
|
const caseMap = {};
|
|
656
|
-
|
|
657
|
-
caseMap[c.value] = new
|
|
672
|
+
compiler.visitAll$1(this, icu.cases).forEach((c) => {
|
|
673
|
+
caseMap[c.value] = new compiler.Container(c.nodes, icu.sourceSpan);
|
|
658
674
|
});
|
|
659
|
-
return new
|
|
675
|
+
return new compiler.Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
|
|
660
676
|
}
|
|
661
677
|
visitExpansionCase(icuCase, context) {
|
|
662
678
|
return {
|
|
663
679
|
value: icuCase.value,
|
|
664
|
-
nodes: [].concat(...
|
|
680
|
+
nodes: [].concat(...compiler.visitAll$1(this, icuCase.expression)),
|
|
665
681
|
};
|
|
666
682
|
}
|
|
667
683
|
visitComment(comment, context) { }
|
|
@@ -669,8 +685,14 @@ class XmlToI18n {
|
|
|
669
685
|
visitBlock(block, context) { }
|
|
670
686
|
visitBlockParameter(parameter, context) { }
|
|
671
687
|
visitLetDeclaration(decl, context) { }
|
|
688
|
+
visitComponent(component, context) {
|
|
689
|
+
this._addError(component, 'Unexpected node');
|
|
690
|
+
}
|
|
691
|
+
visitDirective(directive, context) {
|
|
692
|
+
this._addError(directive, 'Unexpected node');
|
|
693
|
+
}
|
|
672
694
|
_addError(node, message) {
|
|
673
|
-
this._errors.push(new
|
|
695
|
+
this._errors.push(new compiler.I18nError(node.sourceSpan, message));
|
|
674
696
|
}
|
|
675
697
|
}
|
|
676
698
|
function getTypeForTag(tag) {
|
|
@@ -719,8 +741,8 @@ class MessageBundle {
|
|
|
719
741
|
// affected message IDs.
|
|
720
742
|
const rootNodes = this._preserveWhitespace
|
|
721
743
|
? htmlParserResult.rootNodes
|
|
722
|
-
:
|
|
723
|
-
const i18nParserResult =
|
|
744
|
+
: compiler.visitAllWithSiblings(new compiler.WhitespaceVisitor(/* preserveSignificantWhitespace */ false), htmlParserResult.rootNodes);
|
|
745
|
+
const i18nParserResult = compiler.extractMessages(rootNodes, interpolationConfig, this._implicitTags, this._implicitAttrs,
|
|
724
746
|
/* preserveSignificantWhitespace */ this._preserveWhitespace);
|
|
725
747
|
if (i18nParserResult.errors.length) {
|
|
726
748
|
return i18nParserResult.errors;
|
|
@@ -751,7 +773,7 @@ class MessageBundle {
|
|
|
751
773
|
const mapper = serializer.createNameMapper(messages[id]);
|
|
752
774
|
const src = messages[id];
|
|
753
775
|
const nodes = mapper ? mapperVisitor.convert(src.nodes, mapper) : src.nodes;
|
|
754
|
-
let transformedMessage = new
|
|
776
|
+
let transformedMessage = new compiler.Message(nodes, {}, {}, src.meaning, src.description, id);
|
|
755
777
|
transformedMessage.sources = src.sources;
|
|
756
778
|
if (filterSources) {
|
|
757
779
|
transformedMessage.sources.forEach((source) => (source.filePath = filterSources(source.filePath)));
|
|
@@ -762,7 +784,7 @@ class MessageBundle {
|
|
|
762
784
|
}
|
|
763
785
|
}
|
|
764
786
|
// Transform an i18n AST by renaming the placeholder nodes with the given mapper
|
|
765
|
-
class MapPlaceholderNames extends
|
|
787
|
+
class MapPlaceholderNames extends compiler.CloneVisitor {
|
|
766
788
|
convert(nodes, mapper) {
|
|
767
789
|
return mapper ? nodes.map((n) => n.visit(this, mapper)) : nodes;
|
|
768
790
|
}
|
|
@@ -770,34 +792,34 @@ class MapPlaceholderNames extends checker.CloneVisitor {
|
|
|
770
792
|
const startName = mapper.toPublicName(ph.startName);
|
|
771
793
|
const closeName = ph.closeName ? mapper.toPublicName(ph.closeName) : ph.closeName;
|
|
772
794
|
const children = ph.children.map((n) => n.visit(this, mapper));
|
|
773
|
-
return new
|
|
795
|
+
return new compiler.TagPlaceholder(ph.tag, ph.attrs, startName, closeName, children, ph.isVoid, ph.sourceSpan, ph.startSourceSpan, ph.endSourceSpan);
|
|
774
796
|
}
|
|
775
797
|
visitBlockPlaceholder(ph, mapper) {
|
|
776
798
|
const startName = mapper.toPublicName(ph.startName);
|
|
777
799
|
const closeName = ph.closeName ? mapper.toPublicName(ph.closeName) : ph.closeName;
|
|
778
800
|
const children = ph.children.map((n) => n.visit(this, mapper));
|
|
779
|
-
return new
|
|
801
|
+
return new compiler.BlockPlaceholder(ph.name, ph.parameters, startName, closeName, children, ph.sourceSpan, ph.startSourceSpan, ph.endSourceSpan);
|
|
780
802
|
}
|
|
781
803
|
visitPlaceholder(ph, mapper) {
|
|
782
|
-
return new
|
|
804
|
+
return new compiler.Placeholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan);
|
|
783
805
|
}
|
|
784
806
|
visitIcuPlaceholder(ph, mapper) {
|
|
785
|
-
return new
|
|
807
|
+
return new compiler.IcuPlaceholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan);
|
|
786
808
|
}
|
|
787
809
|
}
|
|
788
810
|
|
|
789
811
|
function compileClassMetadata(metadata) {
|
|
790
812
|
const fnCall = internalCompileClassMetadata(metadata);
|
|
791
|
-
return
|
|
813
|
+
return compiler.arrowFn([], [compiler.devOnlyGuardedExpression(fnCall).toStmt()]).callFn([]);
|
|
792
814
|
}
|
|
793
815
|
/** Compiles only the `setClassMetadata` call without any additional wrappers. */
|
|
794
816
|
function internalCompileClassMetadata(metadata) {
|
|
795
|
-
return
|
|
817
|
+
return compiler.importExpr(compiler.Identifiers.setClassMetadata)
|
|
796
818
|
.callFn([
|
|
797
819
|
metadata.type,
|
|
798
820
|
metadata.decorators,
|
|
799
|
-
metadata.ctorParameters ??
|
|
800
|
-
metadata.propDecorators ??
|
|
821
|
+
metadata.ctorParameters ?? compiler.literal(null),
|
|
822
|
+
metadata.propDecorators ?? compiler.literal(null),
|
|
801
823
|
]);
|
|
802
824
|
}
|
|
803
825
|
/**
|
|
@@ -822,7 +844,7 @@ function compileComponentClassMetadata(metadata, dependencies) {
|
|
|
822
844
|
// If there are no deferrable symbols - just generate a regular `setClassMetadata` call.
|
|
823
845
|
return compileClassMetadata(metadata);
|
|
824
846
|
}
|
|
825
|
-
return internalCompileSetClassMetadataAsync(metadata, dependencies.map((dep) => new
|
|
847
|
+
return internalCompileSetClassMetadataAsync(metadata, dependencies.map((dep) => new compiler.FnParam(dep.symbolName, compiler.DYNAMIC_TYPE)), compileComponentMetadataAsyncResolver(dependencies));
|
|
826
848
|
}
|
|
827
849
|
/**
|
|
828
850
|
* Internal logic used to compile a `setClassMetadataAsync` call.
|
|
@@ -833,10 +855,10 @@ function compileComponentClassMetadata(metadata, dependencies) {
|
|
|
833
855
|
function internalCompileSetClassMetadataAsync(metadata, wrapperParams, dependencyResolverFn) {
|
|
834
856
|
// Omit the wrapper since it'll be added around `setClassMetadataAsync` instead.
|
|
835
857
|
const setClassMetadataCall = internalCompileClassMetadata(metadata);
|
|
836
|
-
const setClassMetaWrapper =
|
|
837
|
-
const setClassMetaAsync =
|
|
858
|
+
const setClassMetaWrapper = compiler.arrowFn(wrapperParams, [setClassMetadataCall.toStmt()]);
|
|
859
|
+
const setClassMetaAsync = compiler.importExpr(compiler.Identifiers.setClassMetadataAsync)
|
|
838
860
|
.callFn([metadata.type, dependencyResolverFn, setClassMetaWrapper]);
|
|
839
|
-
return
|
|
861
|
+
return compiler.arrowFn([], [compiler.devOnlyGuardedExpression(setClassMetaAsync).toStmt()]).callFn([]);
|
|
840
862
|
}
|
|
841
863
|
/**
|
|
842
864
|
* Compiles the function that loads the dependencies for the
|
|
@@ -847,12 +869,12 @@ function compileComponentMetadataAsyncResolver(dependencies) {
|
|
|
847
869
|
// e.g. `(m) => m.CmpA`
|
|
848
870
|
const innerFn =
|
|
849
871
|
// Default imports are always accessed through the `default` property.
|
|
850
|
-
|
|
872
|
+
compiler.arrowFn([new compiler.FnParam('m', compiler.DYNAMIC_TYPE)], compiler.variable('m').prop(isDefaultImport ? 'default' : symbolName));
|
|
851
873
|
// e.g. `import('./cmp-a').then(...)`
|
|
852
|
-
return new
|
|
874
|
+
return new compiler.DynamicImportExpr(importPath).prop('then').callFn([innerFn]);
|
|
853
875
|
});
|
|
854
876
|
// e.g. `() => [ ... ];`
|
|
855
|
-
return
|
|
877
|
+
return compiler.arrowFn([], compiler.literalArr(dynamicImports));
|
|
856
878
|
}
|
|
857
879
|
|
|
858
880
|
/**
|
|
@@ -868,32 +890,32 @@ const MINIMUM_PARTIAL_LINKER_VERSION$5 = '12.0.0';
|
|
|
868
890
|
*/
|
|
869
891
|
const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
|
|
870
892
|
function compileDeclareClassMetadata(metadata) {
|
|
871
|
-
const definitionMap = new
|
|
872
|
-
definitionMap.set('minVersion',
|
|
873
|
-
definitionMap.set('version',
|
|
874
|
-
definitionMap.set('ngImport',
|
|
893
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
894
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
895
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.6'));
|
|
896
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
875
897
|
definitionMap.set('type', metadata.type);
|
|
876
898
|
definitionMap.set('decorators', metadata.decorators);
|
|
877
899
|
definitionMap.set('ctorParameters', metadata.ctorParameters);
|
|
878
900
|
definitionMap.set('propDecorators', metadata.propDecorators);
|
|
879
|
-
return
|
|
901
|
+
return compiler.importExpr(compiler.Identifiers.declareClassMetadata).callFn([definitionMap.toLiteralMap()]);
|
|
880
902
|
}
|
|
881
903
|
function compileComponentDeclareClassMetadata(metadata, dependencies) {
|
|
882
904
|
if (dependencies === null || dependencies.length === 0) {
|
|
883
905
|
return compileDeclareClassMetadata(metadata);
|
|
884
906
|
}
|
|
885
|
-
const definitionMap = new
|
|
886
|
-
const callbackReturnDefinitionMap = new
|
|
907
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
908
|
+
const callbackReturnDefinitionMap = new compiler.DefinitionMap();
|
|
887
909
|
callbackReturnDefinitionMap.set('decorators', metadata.decorators);
|
|
888
|
-
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ??
|
|
889
|
-
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ??
|
|
890
|
-
definitionMap.set('minVersion',
|
|
891
|
-
definitionMap.set('version',
|
|
892
|
-
definitionMap.set('ngImport',
|
|
910
|
+
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? compiler.literal(null));
|
|
911
|
+
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? compiler.literal(null));
|
|
912
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
|
|
913
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.6'));
|
|
914
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
893
915
|
definitionMap.set('type', metadata.type);
|
|
894
916
|
definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
|
|
895
|
-
definitionMap.set('resolveMetadata',
|
|
896
|
-
return
|
|
917
|
+
definitionMap.set('resolveMetadata', compiler.arrowFn(dependencies.map((dep) => new compiler.FnParam(dep.symbolName, compiler.DYNAMIC_TYPE)), callbackReturnDefinitionMap.toLiteralMap()));
|
|
918
|
+
return compiler.importExpr(compiler.Identifiers.declareClassMetadataAsync).callFn([definitionMap.toLiteralMap()]);
|
|
897
919
|
}
|
|
898
920
|
|
|
899
921
|
/**
|
|
@@ -909,7 +931,7 @@ function toOptionalLiteralArray(values, mapper) {
|
|
|
909
931
|
if (values === null || values.length === 0) {
|
|
910
932
|
return null;
|
|
911
933
|
}
|
|
912
|
-
return
|
|
934
|
+
return compiler.literalArr(values.map((value) => mapper(value)));
|
|
913
935
|
}
|
|
914
936
|
/**
|
|
915
937
|
* Creates an object literal expression from the given object, mapping all values to an expression
|
|
@@ -926,7 +948,7 @@ function toOptionalLiteralMap(object, mapper) {
|
|
|
926
948
|
return { key, value: mapper(value), quoted: true };
|
|
927
949
|
});
|
|
928
950
|
if (entries.length > 0) {
|
|
929
|
-
return
|
|
951
|
+
return compiler.literalMap(entries);
|
|
930
952
|
}
|
|
931
953
|
else {
|
|
932
954
|
return null;
|
|
@@ -936,32 +958,32 @@ function compileDependencies(deps) {
|
|
|
936
958
|
if (deps === 'invalid') {
|
|
937
959
|
// The `deps` can be set to the string "invalid" by the `unwrapConstructorDependencies()`
|
|
938
960
|
// function, which tries to convert `ConstructorDeps` into `R3DependencyMetadata[]`.
|
|
939
|
-
return
|
|
961
|
+
return compiler.literal('invalid');
|
|
940
962
|
}
|
|
941
963
|
else if (deps === null) {
|
|
942
|
-
return
|
|
964
|
+
return compiler.literal(null);
|
|
943
965
|
}
|
|
944
966
|
else {
|
|
945
|
-
return
|
|
967
|
+
return compiler.literalArr(deps.map(compileDependency));
|
|
946
968
|
}
|
|
947
969
|
}
|
|
948
970
|
function compileDependency(dep) {
|
|
949
|
-
const depMeta = new
|
|
971
|
+
const depMeta = new compiler.DefinitionMap();
|
|
950
972
|
depMeta.set('token', dep.token);
|
|
951
973
|
if (dep.attributeNameType !== null) {
|
|
952
|
-
depMeta.set('attribute',
|
|
974
|
+
depMeta.set('attribute', compiler.literal(true));
|
|
953
975
|
}
|
|
954
976
|
if (dep.host) {
|
|
955
|
-
depMeta.set('host',
|
|
977
|
+
depMeta.set('host', compiler.literal(true));
|
|
956
978
|
}
|
|
957
979
|
if (dep.optional) {
|
|
958
|
-
depMeta.set('optional',
|
|
980
|
+
depMeta.set('optional', compiler.literal(true));
|
|
959
981
|
}
|
|
960
982
|
if (dep.self) {
|
|
961
|
-
depMeta.set('self',
|
|
983
|
+
depMeta.set('self', compiler.literal(true));
|
|
962
984
|
}
|
|
963
985
|
if (dep.skipSelf) {
|
|
964
|
-
depMeta.set('skipSelf',
|
|
986
|
+
depMeta.set('skipSelf', compiler.literal(true));
|
|
965
987
|
}
|
|
966
988
|
return depMeta.toLiteralMap();
|
|
967
989
|
}
|
|
@@ -971,8 +993,8 @@ function compileDependency(dep) {
|
|
|
971
993
|
*/
|
|
972
994
|
function compileDeclareDirectiveFromMetadata(meta) {
|
|
973
995
|
const definitionMap = createDirectiveDefinitionMap(meta);
|
|
974
|
-
const expression =
|
|
975
|
-
const type =
|
|
996
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareDirective).callFn([definitionMap.toLiteralMap()]);
|
|
997
|
+
const type = compiler.createDirectiveType(meta);
|
|
976
998
|
return { expression, type, statements: [] };
|
|
977
999
|
}
|
|
978
1000
|
/**
|
|
@@ -980,47 +1002,47 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
980
1002
|
* this logic for components, as they extend the directive metadata.
|
|
981
1003
|
*/
|
|
982
1004
|
function createDirectiveDefinitionMap(meta) {
|
|
983
|
-
const definitionMap = new
|
|
1005
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
984
1006
|
const minVersion = getMinimumVersionForPartialOutput(meta);
|
|
985
|
-
definitionMap.set('minVersion',
|
|
986
|
-
definitionMap.set('version',
|
|
1007
|
+
definitionMap.set('minVersion', compiler.literal(minVersion));
|
|
1008
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.6'));
|
|
987
1009
|
// e.g. `type: MyDirective`
|
|
988
1010
|
definitionMap.set('type', meta.type.value);
|
|
989
1011
|
if (meta.isStandalone !== undefined) {
|
|
990
|
-
definitionMap.set('isStandalone',
|
|
1012
|
+
definitionMap.set('isStandalone', compiler.literal(meta.isStandalone));
|
|
991
1013
|
}
|
|
992
1014
|
if (meta.isSignal) {
|
|
993
|
-
definitionMap.set('isSignal',
|
|
1015
|
+
definitionMap.set('isSignal', compiler.literal(meta.isSignal));
|
|
994
1016
|
}
|
|
995
1017
|
// e.g. `selector: 'some-dir'`
|
|
996
1018
|
if (meta.selector !== null) {
|
|
997
|
-
definitionMap.set('selector',
|
|
1019
|
+
definitionMap.set('selector', compiler.literal(meta.selector));
|
|
998
1020
|
}
|
|
999
1021
|
definitionMap.set('inputs', needsNewInputPartialOutput(meta)
|
|
1000
1022
|
? createInputsPartialMetadata(meta.inputs)
|
|
1001
1023
|
: legacyInputsPartialMetadata(meta.inputs));
|
|
1002
|
-
definitionMap.set('outputs',
|
|
1024
|
+
definitionMap.set('outputs', compiler.conditionallyCreateDirectiveBindingLiteral(meta.outputs));
|
|
1003
1025
|
definitionMap.set('host', compileHostMetadata(meta.host));
|
|
1004
1026
|
definitionMap.set('providers', meta.providers);
|
|
1005
1027
|
if (meta.queries.length > 0) {
|
|
1006
|
-
definitionMap.set('queries',
|
|
1028
|
+
definitionMap.set('queries', compiler.literalArr(meta.queries.map(compileQuery)));
|
|
1007
1029
|
}
|
|
1008
1030
|
if (meta.viewQueries.length > 0) {
|
|
1009
|
-
definitionMap.set('viewQueries',
|
|
1031
|
+
definitionMap.set('viewQueries', compiler.literalArr(meta.viewQueries.map(compileQuery)));
|
|
1010
1032
|
}
|
|
1011
1033
|
if (meta.exportAs !== null) {
|
|
1012
|
-
definitionMap.set('exportAs',
|
|
1034
|
+
definitionMap.set('exportAs', compiler.asLiteral(meta.exportAs));
|
|
1013
1035
|
}
|
|
1014
1036
|
if (meta.usesInheritance) {
|
|
1015
|
-
definitionMap.set('usesInheritance',
|
|
1037
|
+
definitionMap.set('usesInheritance', compiler.literal(true));
|
|
1016
1038
|
}
|
|
1017
1039
|
if (meta.lifecycle.usesOnChanges) {
|
|
1018
|
-
definitionMap.set('usesOnChanges',
|
|
1040
|
+
definitionMap.set('usesOnChanges', compiler.literal(true));
|
|
1019
1041
|
}
|
|
1020
1042
|
if (meta.hostDirectives?.length) {
|
|
1021
1043
|
definitionMap.set('hostDirectives', createHostDirectives(meta.hostDirectives));
|
|
1022
1044
|
}
|
|
1023
|
-
definitionMap.set('ngImport',
|
|
1045
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1024
1046
|
return definitionMap;
|
|
1025
1047
|
}
|
|
1026
1048
|
/**
|
|
@@ -1071,28 +1093,28 @@ function needsNewInputPartialOutput(meta) {
|
|
|
1071
1093
|
* by `R3DeclareQueryMetadata`.
|
|
1072
1094
|
*/
|
|
1073
1095
|
function compileQuery(query) {
|
|
1074
|
-
const meta = new
|
|
1075
|
-
meta.set('propertyName',
|
|
1096
|
+
const meta = new compiler.DefinitionMap();
|
|
1097
|
+
meta.set('propertyName', compiler.literal(query.propertyName));
|
|
1076
1098
|
if (query.first) {
|
|
1077
|
-
meta.set('first',
|
|
1099
|
+
meta.set('first', compiler.literal(true));
|
|
1078
1100
|
}
|
|
1079
1101
|
meta.set('predicate', Array.isArray(query.predicate)
|
|
1080
|
-
?
|
|
1081
|
-
:
|
|
1102
|
+
? compiler.asLiteral(query.predicate)
|
|
1103
|
+
: compiler.convertFromMaybeForwardRefExpression(query.predicate));
|
|
1082
1104
|
if (!query.emitDistinctChangesOnly) {
|
|
1083
1105
|
// `emitDistinctChangesOnly` is special because we expect it to be `true`.
|
|
1084
1106
|
// Therefore we explicitly emit the field, and explicitly place it only when it's `false`.
|
|
1085
|
-
meta.set('emitDistinctChangesOnly',
|
|
1107
|
+
meta.set('emitDistinctChangesOnly', compiler.literal(false));
|
|
1086
1108
|
}
|
|
1087
1109
|
if (query.descendants) {
|
|
1088
|
-
meta.set('descendants',
|
|
1110
|
+
meta.set('descendants', compiler.literal(true));
|
|
1089
1111
|
}
|
|
1090
1112
|
meta.set('read', query.read);
|
|
1091
1113
|
if (query.static) {
|
|
1092
|
-
meta.set('static',
|
|
1114
|
+
meta.set('static', compiler.literal(true));
|
|
1093
1115
|
}
|
|
1094
1116
|
if (query.isSignal) {
|
|
1095
|
-
meta.set('isSignal',
|
|
1117
|
+
meta.set('isSignal', compiler.literal(true));
|
|
1096
1118
|
}
|
|
1097
1119
|
return meta.toLiteralMap();
|
|
1098
1120
|
}
|
|
@@ -1101,15 +1123,15 @@ function compileQuery(query) {
|
|
|
1101
1123
|
* in `R3DeclareDirectiveMetadata['host']`
|
|
1102
1124
|
*/
|
|
1103
1125
|
function compileHostMetadata(meta) {
|
|
1104
|
-
const hostMetadata = new
|
|
1126
|
+
const hostMetadata = new compiler.DefinitionMap();
|
|
1105
1127
|
hostMetadata.set('attributes', toOptionalLiteralMap(meta.attributes, (expression) => expression));
|
|
1106
|
-
hostMetadata.set('listeners', toOptionalLiteralMap(meta.listeners,
|
|
1107
|
-
hostMetadata.set('properties', toOptionalLiteralMap(meta.properties,
|
|
1128
|
+
hostMetadata.set('listeners', toOptionalLiteralMap(meta.listeners, compiler.literal));
|
|
1129
|
+
hostMetadata.set('properties', toOptionalLiteralMap(meta.properties, compiler.literal));
|
|
1108
1130
|
if (meta.specialAttributes.styleAttr) {
|
|
1109
|
-
hostMetadata.set('styleAttribute',
|
|
1131
|
+
hostMetadata.set('styleAttribute', compiler.literal(meta.specialAttributes.styleAttr));
|
|
1110
1132
|
}
|
|
1111
1133
|
if (meta.specialAttributes.classAttr) {
|
|
1112
|
-
hostMetadata.set('classAttribute',
|
|
1134
|
+
hostMetadata.set('classAttribute', compiler.literal(meta.specialAttributes.classAttr));
|
|
1113
1135
|
}
|
|
1114
1136
|
if (hostMetadata.values.length > 0) {
|
|
1115
1137
|
return hostMetadata.toLiteralMap();
|
|
@@ -1124,14 +1146,14 @@ function createHostDirectives(hostDirectives) {
|
|
|
1124
1146
|
{
|
|
1125
1147
|
key: 'directive',
|
|
1126
1148
|
value: current.isForwardReference
|
|
1127
|
-
?
|
|
1149
|
+
? compiler.generateForwardRef(current.directive.type)
|
|
1128
1150
|
: current.directive.type,
|
|
1129
1151
|
quoted: false,
|
|
1130
1152
|
},
|
|
1131
1153
|
];
|
|
1132
|
-
const inputsLiteral = current.inputs ?
|
|
1154
|
+
const inputsLiteral = current.inputs ? compiler.createHostDirectivesMappingArray(current.inputs) : null;
|
|
1133
1155
|
const outputsLiteral = current.outputs
|
|
1134
|
-
?
|
|
1156
|
+
? compiler.createHostDirectivesMappingArray(current.outputs)
|
|
1135
1157
|
: null;
|
|
1136
1158
|
if (inputsLiteral) {
|
|
1137
1159
|
keys.push({ key: 'inputs', value: inputsLiteral, quoted: false });
|
|
@@ -1139,11 +1161,11 @@ function createHostDirectives(hostDirectives) {
|
|
|
1139
1161
|
if (outputsLiteral) {
|
|
1140
1162
|
keys.push({ key: 'outputs', value: outputsLiteral, quoted: false });
|
|
1141
1163
|
}
|
|
1142
|
-
return
|
|
1164
|
+
return compiler.literalMap(keys);
|
|
1143
1165
|
});
|
|
1144
1166
|
// If there's a forward reference, we generate a `function() { return [{directive: HostDir}] }`,
|
|
1145
1167
|
// otherwise we can save some bytes by using a plain array, e.g. `[{directive: HostDir}]`.
|
|
1146
|
-
return
|
|
1168
|
+
return compiler.literalArr(expressions);
|
|
1147
1169
|
}
|
|
1148
1170
|
/**
|
|
1149
1171
|
* Generates partial output metadata for inputs of a directive.
|
|
@@ -1155,18 +1177,18 @@ function createInputsPartialMetadata(inputs) {
|
|
|
1155
1177
|
if (keys.length === 0) {
|
|
1156
1178
|
return null;
|
|
1157
1179
|
}
|
|
1158
|
-
return
|
|
1180
|
+
return compiler.literalMap(keys.map((declaredName) => {
|
|
1159
1181
|
const value = inputs[declaredName];
|
|
1160
1182
|
return {
|
|
1161
1183
|
key: declaredName,
|
|
1162
1184
|
// put quotes around keys that contain potentially unsafe characters
|
|
1163
|
-
quoted:
|
|
1164
|
-
value:
|
|
1165
|
-
{ key: 'classPropertyName', quoted: false, value:
|
|
1166
|
-
{ key: 'publicName', quoted: false, value:
|
|
1167
|
-
{ key: 'isSignal', quoted: false, value:
|
|
1168
|
-
{ key: 'isRequired', quoted: false, value:
|
|
1169
|
-
{ key: 'transformFunction', quoted: false, value: value.transformFunction ??
|
|
1185
|
+
quoted: compiler.UNSAFE_OBJECT_KEY_NAME_REGEXP.test(declaredName),
|
|
1186
|
+
value: compiler.literalMap([
|
|
1187
|
+
{ key: 'classPropertyName', quoted: false, value: compiler.asLiteral(value.classPropertyName) },
|
|
1188
|
+
{ key: 'publicName', quoted: false, value: compiler.asLiteral(value.bindingPropertyName) },
|
|
1189
|
+
{ key: 'isSignal', quoted: false, value: compiler.asLiteral(value.isSignal) },
|
|
1190
|
+
{ key: 'isRequired', quoted: false, value: compiler.asLiteral(value.required) },
|
|
1191
|
+
{ key: 'transformFunction', quoted: false, value: value.transformFunction ?? compiler.NULL_EXPR },
|
|
1170
1192
|
]),
|
|
1171
1193
|
};
|
|
1172
1194
|
}));
|
|
@@ -1190,25 +1212,25 @@ function legacyInputsPartialMetadata(inputs) {
|
|
|
1190
1212
|
if (keys.length === 0) {
|
|
1191
1213
|
return null;
|
|
1192
1214
|
}
|
|
1193
|
-
return
|
|
1215
|
+
return compiler.literalMap(keys.map((declaredName) => {
|
|
1194
1216
|
const value = inputs[declaredName];
|
|
1195
1217
|
const publicName = value.bindingPropertyName;
|
|
1196
1218
|
const differentDeclaringName = publicName !== declaredName;
|
|
1197
1219
|
let result;
|
|
1198
1220
|
if (differentDeclaringName || value.transformFunction !== null) {
|
|
1199
|
-
const values = [
|
|
1221
|
+
const values = [compiler.asLiteral(publicName), compiler.asLiteral(declaredName)];
|
|
1200
1222
|
if (value.transformFunction !== null) {
|
|
1201
1223
|
values.push(value.transformFunction);
|
|
1202
1224
|
}
|
|
1203
|
-
result =
|
|
1225
|
+
result = compiler.literalArr(values);
|
|
1204
1226
|
}
|
|
1205
1227
|
else {
|
|
1206
|
-
result =
|
|
1228
|
+
result = compiler.asLiteral(publicName);
|
|
1207
1229
|
}
|
|
1208
1230
|
return {
|
|
1209
1231
|
key: declaredName,
|
|
1210
1232
|
// put quotes around keys that contain potentially unsafe characters
|
|
1211
|
-
quoted:
|
|
1233
|
+
quoted: compiler.UNSAFE_OBJECT_KEY_NAME_REGEXP.test(declaredName),
|
|
1212
1234
|
value: result,
|
|
1213
1235
|
};
|
|
1214
1236
|
}));
|
|
@@ -1219,8 +1241,8 @@ function legacyInputsPartialMetadata(inputs) {
|
|
|
1219
1241
|
*/
|
|
1220
1242
|
function compileDeclareComponentFromMetadata(meta, template, additionalTemplateInfo) {
|
|
1221
1243
|
const definitionMap = createComponentDefinitionMap(meta, template, additionalTemplateInfo);
|
|
1222
|
-
const expression =
|
|
1223
|
-
const type =
|
|
1244
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareComponent).callFn([definitionMap.toLiteralMap()]);
|
|
1245
|
+
const type = compiler.createComponentType(meta);
|
|
1224
1246
|
return { expression, type, statements: [] };
|
|
1225
1247
|
}
|
|
1226
1248
|
/**
|
|
@@ -1229,17 +1251,17 @@ function compileDeclareComponentFromMetadata(meta, template, additionalTemplateI
|
|
|
1229
1251
|
function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
1230
1252
|
const definitionMap = createDirectiveDefinitionMap(meta);
|
|
1231
1253
|
const blockVisitor = new BlockPresenceVisitor();
|
|
1232
|
-
|
|
1254
|
+
compiler.visitAll(blockVisitor, template.nodes);
|
|
1233
1255
|
definitionMap.set('template', getTemplateExpression(template, templateInfo));
|
|
1234
1256
|
if (templateInfo.isInline) {
|
|
1235
|
-
definitionMap.set('isInline',
|
|
1257
|
+
definitionMap.set('isInline', compiler.literal(true));
|
|
1236
1258
|
}
|
|
1237
1259
|
// Set the minVersion to 17.0.0 if the component is using at least one block in its template.
|
|
1238
1260
|
// We don't do this for templates without blocks, in order to preserve backwards compatibility.
|
|
1239
1261
|
if (blockVisitor.hasBlocks) {
|
|
1240
|
-
definitionMap.set('minVersion',
|
|
1262
|
+
definitionMap.set('minVersion', compiler.literal('17.0.0'));
|
|
1241
1263
|
}
|
|
1242
|
-
definitionMap.set('styles', toOptionalLiteralArray(meta.styles,
|
|
1264
|
+
definitionMap.set('styles', toOptionalLiteralArray(meta.styles, compiler.literal));
|
|
1243
1265
|
definitionMap.set('dependencies', compileUsedDependenciesMetadata(meta));
|
|
1244
1266
|
definitionMap.set('viewProviders', meta.viewProviders);
|
|
1245
1267
|
definitionMap.set('animations', meta.animations);
|
|
@@ -1247,17 +1269,17 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
1247
1269
|
if (typeof meta.changeDetection === 'object') {
|
|
1248
1270
|
throw new Error('Impossible state! Change detection flag is not resolved!');
|
|
1249
1271
|
}
|
|
1250
|
-
definitionMap.set('changeDetection',
|
|
1251
|
-
.prop(
|
|
1272
|
+
definitionMap.set('changeDetection', compiler.importExpr(compiler.Identifiers.ChangeDetectionStrategy)
|
|
1273
|
+
.prop(compiler.ChangeDetectionStrategy[meta.changeDetection]));
|
|
1252
1274
|
}
|
|
1253
|
-
if (meta.encapsulation !==
|
|
1254
|
-
definitionMap.set('encapsulation',
|
|
1275
|
+
if (meta.encapsulation !== compiler.ViewEncapsulation.Emulated) {
|
|
1276
|
+
definitionMap.set('encapsulation', compiler.importExpr(compiler.Identifiers.ViewEncapsulation).prop(compiler.ViewEncapsulation[meta.encapsulation]));
|
|
1255
1277
|
}
|
|
1256
|
-
if (meta.interpolation !==
|
|
1257
|
-
definitionMap.set('interpolation',
|
|
1278
|
+
if (meta.interpolation !== compiler.DEFAULT_INTERPOLATION_CONFIG) {
|
|
1279
|
+
definitionMap.set('interpolation', compiler.literalArr([compiler.literal(meta.interpolation.start), compiler.literal(meta.interpolation.end)]));
|
|
1258
1280
|
}
|
|
1259
1281
|
if (template.preserveWhitespaces === true) {
|
|
1260
|
-
definitionMap.set('preserveWhitespaces',
|
|
1282
|
+
definitionMap.set('preserveWhitespaces', compiler.literal(true));
|
|
1261
1283
|
}
|
|
1262
1284
|
if (meta.defer.mode === 0 /* DeferBlockDepsEmitMode.PerBlock */) {
|
|
1263
1285
|
const resolvers = [];
|
|
@@ -1267,7 +1289,7 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
1267
1289
|
// defer resolver functions to defer blocks happens by index and not adding an array
|
|
1268
1290
|
// entry for a block can throw off the blocks coming after it.
|
|
1269
1291
|
if (deps === null) {
|
|
1270
|
-
resolvers.push(
|
|
1292
|
+
resolvers.push(compiler.literal(null));
|
|
1271
1293
|
}
|
|
1272
1294
|
else {
|
|
1273
1295
|
resolvers.push(deps);
|
|
@@ -1276,7 +1298,7 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
1276
1298
|
}
|
|
1277
1299
|
// If *all* the resolvers are null, we can skip the field.
|
|
1278
1300
|
if (hasResolvers) {
|
|
1279
|
-
definitionMap.set('deferBlockDependencies',
|
|
1301
|
+
definitionMap.set('deferBlockDependencies', compiler.literalArr(resolvers));
|
|
1280
1302
|
}
|
|
1281
1303
|
}
|
|
1282
1304
|
else {
|
|
@@ -1297,16 +1319,16 @@ function getTemplateExpression(template, templateInfo) {
|
|
|
1297
1319
|
// that we cannot use the expression defining the template because the linker expects the template
|
|
1298
1320
|
// to be defined as a literal in the declaration.
|
|
1299
1321
|
if (templateInfo.isInline) {
|
|
1300
|
-
return
|
|
1322
|
+
return compiler.literal(templateInfo.content, null, null);
|
|
1301
1323
|
}
|
|
1302
1324
|
// The template is external so we must synthesize an expression node with
|
|
1303
1325
|
// the appropriate source-span.
|
|
1304
1326
|
const contents = templateInfo.content;
|
|
1305
|
-
const file = new
|
|
1306
|
-
const start = new
|
|
1327
|
+
const file = new compiler.ParseSourceFile(contents, templateInfo.sourceUrl);
|
|
1328
|
+
const start = new compiler.ParseLocation(file, 0, 0, 0);
|
|
1307
1329
|
const end = computeEndLocation(file, contents);
|
|
1308
|
-
const span = new
|
|
1309
|
-
return
|
|
1330
|
+
const span = new compiler.ParseSourceSpan(start, end);
|
|
1331
|
+
return compiler.literal(contents, null, span);
|
|
1310
1332
|
}
|
|
1311
1333
|
function computeEndLocation(file, contents) {
|
|
1312
1334
|
const length = contents.length;
|
|
@@ -1320,41 +1342,41 @@ function computeEndLocation(file, contents) {
|
|
|
1320
1342
|
line++;
|
|
1321
1343
|
}
|
|
1322
1344
|
} while (lineStart !== -1);
|
|
1323
|
-
return new
|
|
1345
|
+
return new compiler.ParseLocation(file, length, line, length - lastLineStart);
|
|
1324
1346
|
}
|
|
1325
1347
|
function compileUsedDependenciesMetadata(meta) {
|
|
1326
1348
|
const wrapType = meta.declarationListEmitMode !== 0 /* DeclarationListEmitMode.Direct */
|
|
1327
|
-
?
|
|
1349
|
+
? compiler.generateForwardRef
|
|
1328
1350
|
: (expr) => expr;
|
|
1329
1351
|
if (meta.declarationListEmitMode === 3 /* DeclarationListEmitMode.RuntimeResolved */) {
|
|
1330
1352
|
throw new Error(`Unsupported emit mode`);
|
|
1331
1353
|
}
|
|
1332
1354
|
return toOptionalLiteralArray(meta.declarations, (decl) => {
|
|
1333
1355
|
switch (decl.kind) {
|
|
1334
|
-
case
|
|
1335
|
-
const dirMeta = new
|
|
1336
|
-
dirMeta.set('kind',
|
|
1356
|
+
case compiler.R3TemplateDependencyKind.Directive:
|
|
1357
|
+
const dirMeta = new compiler.DefinitionMap();
|
|
1358
|
+
dirMeta.set('kind', compiler.literal(decl.isComponent ? 'component' : 'directive'));
|
|
1337
1359
|
dirMeta.set('type', wrapType(decl.type));
|
|
1338
|
-
dirMeta.set('selector',
|
|
1339
|
-
dirMeta.set('inputs', toOptionalLiteralArray(decl.inputs,
|
|
1340
|
-
dirMeta.set('outputs', toOptionalLiteralArray(decl.outputs,
|
|
1341
|
-
dirMeta.set('exportAs', toOptionalLiteralArray(decl.exportAs,
|
|
1360
|
+
dirMeta.set('selector', compiler.literal(decl.selector));
|
|
1361
|
+
dirMeta.set('inputs', toOptionalLiteralArray(decl.inputs, compiler.literal));
|
|
1362
|
+
dirMeta.set('outputs', toOptionalLiteralArray(decl.outputs, compiler.literal));
|
|
1363
|
+
dirMeta.set('exportAs', toOptionalLiteralArray(decl.exportAs, compiler.literal));
|
|
1342
1364
|
return dirMeta.toLiteralMap();
|
|
1343
|
-
case
|
|
1344
|
-
const pipeMeta = new
|
|
1345
|
-
pipeMeta.set('kind',
|
|
1365
|
+
case compiler.R3TemplateDependencyKind.Pipe:
|
|
1366
|
+
const pipeMeta = new compiler.DefinitionMap();
|
|
1367
|
+
pipeMeta.set('kind', compiler.literal('pipe'));
|
|
1346
1368
|
pipeMeta.set('type', wrapType(decl.type));
|
|
1347
|
-
pipeMeta.set('name',
|
|
1369
|
+
pipeMeta.set('name', compiler.literal(decl.name));
|
|
1348
1370
|
return pipeMeta.toLiteralMap();
|
|
1349
|
-
case
|
|
1350
|
-
const ngModuleMeta = new
|
|
1351
|
-
ngModuleMeta.set('kind',
|
|
1371
|
+
case compiler.R3TemplateDependencyKind.NgModule:
|
|
1372
|
+
const ngModuleMeta = new compiler.DefinitionMap();
|
|
1373
|
+
ngModuleMeta.set('kind', compiler.literal('ngmodule'));
|
|
1352
1374
|
ngModuleMeta.set('type', wrapType(decl.type));
|
|
1353
1375
|
return ngModuleMeta.toLiteralMap();
|
|
1354
1376
|
}
|
|
1355
1377
|
});
|
|
1356
1378
|
}
|
|
1357
|
-
class BlockPresenceVisitor extends
|
|
1379
|
+
class BlockPresenceVisitor extends compiler.RecursiveVisitor {
|
|
1358
1380
|
hasBlocks = false;
|
|
1359
1381
|
visitDeferredBlock() {
|
|
1360
1382
|
this.hasBlocks = true;
|
|
@@ -1397,17 +1419,17 @@ class BlockPresenceVisitor extends checker.RecursiveVisitor$1 {
|
|
|
1397
1419
|
*/
|
|
1398
1420
|
const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
1399
1421
|
function compileDeclareFactoryFunction(meta) {
|
|
1400
|
-
const definitionMap = new
|
|
1401
|
-
definitionMap.set('minVersion',
|
|
1402
|
-
definitionMap.set('version',
|
|
1403
|
-
definitionMap.set('ngImport',
|
|
1422
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1423
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
1424
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.6'));
|
|
1425
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1404
1426
|
definitionMap.set('type', meta.type.value);
|
|
1405
1427
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
1406
|
-
definitionMap.set('target',
|
|
1428
|
+
definitionMap.set('target', compiler.importExpr(compiler.Identifiers.FactoryTarget).prop(compiler.FactoryTarget[meta.target]));
|
|
1407
1429
|
return {
|
|
1408
|
-
expression:
|
|
1430
|
+
expression: compiler.importExpr(compiler.Identifiers.declareFactory).callFn([definitionMap.toLiteralMap()]),
|
|
1409
1431
|
statements: [],
|
|
1410
|
-
type:
|
|
1432
|
+
type: compiler.createFactoryType(meta),
|
|
1411
1433
|
};
|
|
1412
1434
|
}
|
|
1413
1435
|
|
|
@@ -1424,34 +1446,34 @@ const MINIMUM_PARTIAL_LINKER_VERSION$3 = '12.0.0';
|
|
|
1424
1446
|
*/
|
|
1425
1447
|
function compileDeclareInjectableFromMetadata(meta) {
|
|
1426
1448
|
const definitionMap = createInjectableDefinitionMap(meta);
|
|
1427
|
-
const expression =
|
|
1428
|
-
const type =
|
|
1449
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareInjectable).callFn([definitionMap.toLiteralMap()]);
|
|
1450
|
+
const type = compiler.createInjectableType(meta);
|
|
1429
1451
|
return { expression, type, statements: [] };
|
|
1430
1452
|
}
|
|
1431
1453
|
/**
|
|
1432
1454
|
* Gathers the declaration fields for a Injectable into a `DefinitionMap`.
|
|
1433
1455
|
*/
|
|
1434
1456
|
function createInjectableDefinitionMap(meta) {
|
|
1435
|
-
const definitionMap = new
|
|
1436
|
-
definitionMap.set('minVersion',
|
|
1437
|
-
definitionMap.set('version',
|
|
1438
|
-
definitionMap.set('ngImport',
|
|
1457
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1458
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
1459
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.6'));
|
|
1460
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1439
1461
|
definitionMap.set('type', meta.type.value);
|
|
1440
1462
|
// Only generate providedIn property if it has a non-null value
|
|
1441
1463
|
if (meta.providedIn !== undefined) {
|
|
1442
|
-
const providedIn =
|
|
1464
|
+
const providedIn = compiler.convertFromMaybeForwardRefExpression(meta.providedIn);
|
|
1443
1465
|
if (providedIn.value !== null) {
|
|
1444
1466
|
definitionMap.set('providedIn', providedIn);
|
|
1445
1467
|
}
|
|
1446
1468
|
}
|
|
1447
1469
|
if (meta.useClass !== undefined) {
|
|
1448
|
-
definitionMap.set('useClass',
|
|
1470
|
+
definitionMap.set('useClass', compiler.convertFromMaybeForwardRefExpression(meta.useClass));
|
|
1449
1471
|
}
|
|
1450
1472
|
if (meta.useExisting !== undefined) {
|
|
1451
|
-
definitionMap.set('useExisting',
|
|
1473
|
+
definitionMap.set('useExisting', compiler.convertFromMaybeForwardRefExpression(meta.useExisting));
|
|
1452
1474
|
}
|
|
1453
1475
|
if (meta.useValue !== undefined) {
|
|
1454
|
-
definitionMap.set('useValue',
|
|
1476
|
+
definitionMap.set('useValue', compiler.convertFromMaybeForwardRefExpression(meta.useValue));
|
|
1455
1477
|
}
|
|
1456
1478
|
// Factories do not contain `ForwardRef`s since any types are already wrapped in a function call
|
|
1457
1479
|
// so the types will not be eagerly evaluated. Therefore we do not need to process this expression
|
|
@@ -1460,7 +1482,7 @@ function createInjectableDefinitionMap(meta) {
|
|
|
1460
1482
|
definitionMap.set('useFactory', meta.useFactory);
|
|
1461
1483
|
}
|
|
1462
1484
|
if (meta.deps !== undefined) {
|
|
1463
|
-
definitionMap.set('deps',
|
|
1485
|
+
definitionMap.set('deps', compiler.literalArr(meta.deps.map(compileDependency)));
|
|
1464
1486
|
}
|
|
1465
1487
|
return definitionMap;
|
|
1466
1488
|
}
|
|
@@ -1475,22 +1497,22 @@ function createInjectableDefinitionMap(meta) {
|
|
|
1475
1497
|
const MINIMUM_PARTIAL_LINKER_VERSION$2 = '12.0.0';
|
|
1476
1498
|
function compileDeclareInjectorFromMetadata(meta) {
|
|
1477
1499
|
const definitionMap = createInjectorDefinitionMap(meta);
|
|
1478
|
-
const expression =
|
|
1479
|
-
const type =
|
|
1500
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareInjector).callFn([definitionMap.toLiteralMap()]);
|
|
1501
|
+
const type = compiler.createInjectorType(meta);
|
|
1480
1502
|
return { expression, type, statements: [] };
|
|
1481
1503
|
}
|
|
1482
1504
|
/**
|
|
1483
1505
|
* Gathers the declaration fields for an Injector into a `DefinitionMap`.
|
|
1484
1506
|
*/
|
|
1485
1507
|
function createInjectorDefinitionMap(meta) {
|
|
1486
|
-
const definitionMap = new
|
|
1487
|
-
definitionMap.set('minVersion',
|
|
1488
|
-
definitionMap.set('version',
|
|
1489
|
-
definitionMap.set('ngImport',
|
|
1508
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1509
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
1510
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.6'));
|
|
1511
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1490
1512
|
definitionMap.set('type', meta.type.value);
|
|
1491
1513
|
definitionMap.set('providers', meta.providers);
|
|
1492
1514
|
if (meta.imports.length > 0) {
|
|
1493
|
-
definitionMap.set('imports',
|
|
1515
|
+
definitionMap.set('imports', compiler.literalArr(meta.imports));
|
|
1494
1516
|
}
|
|
1495
1517
|
return definitionMap;
|
|
1496
1518
|
}
|
|
@@ -1505,40 +1527,40 @@ function createInjectorDefinitionMap(meta) {
|
|
|
1505
1527
|
const MINIMUM_PARTIAL_LINKER_VERSION$1 = '14.0.0';
|
|
1506
1528
|
function compileDeclareNgModuleFromMetadata(meta) {
|
|
1507
1529
|
const definitionMap = createNgModuleDefinitionMap(meta);
|
|
1508
|
-
const expression =
|
|
1509
|
-
const type =
|
|
1530
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareNgModule).callFn([definitionMap.toLiteralMap()]);
|
|
1531
|
+
const type = compiler.createNgModuleType(meta);
|
|
1510
1532
|
return { expression, type, statements: [] };
|
|
1511
1533
|
}
|
|
1512
1534
|
/**
|
|
1513
1535
|
* Gathers the declaration fields for an NgModule into a `DefinitionMap`.
|
|
1514
1536
|
*/
|
|
1515
1537
|
function createNgModuleDefinitionMap(meta) {
|
|
1516
|
-
const definitionMap = new
|
|
1517
|
-
if (meta.kind ===
|
|
1538
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1539
|
+
if (meta.kind === compiler.R3NgModuleMetadataKind.Local) {
|
|
1518
1540
|
throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
|
|
1519
1541
|
}
|
|
1520
|
-
definitionMap.set('minVersion',
|
|
1521
|
-
definitionMap.set('version',
|
|
1522
|
-
definitionMap.set('ngImport',
|
|
1542
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
1543
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.6'));
|
|
1544
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1523
1545
|
definitionMap.set('type', meta.type.value);
|
|
1524
1546
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
1525
1547
|
// We must wrap the arrays inside a function if any of the values are a forward reference to a
|
|
1526
1548
|
// not-yet-declared class. This is to support JIT execution of the `ɵɵngDeclareNgModule()` call.
|
|
1527
1549
|
// In the linker these wrappers are stripped and then reapplied for the `ɵɵdefineNgModule()` call.
|
|
1528
1550
|
if (meta.bootstrap.length > 0) {
|
|
1529
|
-
definitionMap.set('bootstrap',
|
|
1551
|
+
definitionMap.set('bootstrap', compiler.refsToArray(meta.bootstrap, meta.containsForwardDecls));
|
|
1530
1552
|
}
|
|
1531
1553
|
if (meta.declarations.length > 0) {
|
|
1532
|
-
definitionMap.set('declarations',
|
|
1554
|
+
definitionMap.set('declarations', compiler.refsToArray(meta.declarations, meta.containsForwardDecls));
|
|
1533
1555
|
}
|
|
1534
1556
|
if (meta.imports.length > 0) {
|
|
1535
|
-
definitionMap.set('imports',
|
|
1557
|
+
definitionMap.set('imports', compiler.refsToArray(meta.imports, meta.containsForwardDecls));
|
|
1536
1558
|
}
|
|
1537
1559
|
if (meta.exports.length > 0) {
|
|
1538
|
-
definitionMap.set('exports',
|
|
1560
|
+
definitionMap.set('exports', compiler.refsToArray(meta.exports, meta.containsForwardDecls));
|
|
1539
1561
|
}
|
|
1540
1562
|
if (meta.schemas !== null && meta.schemas.length > 0) {
|
|
1541
|
-
definitionMap.set('schemas',
|
|
1563
|
+
definitionMap.set('schemas', compiler.literalArr(meta.schemas.map((ref) => ref.value)));
|
|
1542
1564
|
}
|
|
1543
1565
|
if (meta.id !== null) {
|
|
1544
1566
|
definitionMap.set('id', meta.id);
|
|
@@ -1559,28 +1581,28 @@ const MINIMUM_PARTIAL_LINKER_VERSION = '14.0.0';
|
|
|
1559
1581
|
*/
|
|
1560
1582
|
function compileDeclarePipeFromMetadata(meta) {
|
|
1561
1583
|
const definitionMap = createPipeDefinitionMap(meta);
|
|
1562
|
-
const expression =
|
|
1563
|
-
const type =
|
|
1584
|
+
const expression = compiler.importExpr(compiler.Identifiers.declarePipe).callFn([definitionMap.toLiteralMap()]);
|
|
1585
|
+
const type = compiler.createPipeType(meta);
|
|
1564
1586
|
return { expression, type, statements: [] };
|
|
1565
1587
|
}
|
|
1566
1588
|
/**
|
|
1567
1589
|
* Gathers the declaration fields for a Pipe into a `DefinitionMap`.
|
|
1568
1590
|
*/
|
|
1569
1591
|
function createPipeDefinitionMap(meta) {
|
|
1570
|
-
const definitionMap = new
|
|
1571
|
-
definitionMap.set('minVersion',
|
|
1572
|
-
definitionMap.set('version',
|
|
1573
|
-
definitionMap.set('ngImport',
|
|
1592
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1593
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
1594
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.6'));
|
|
1595
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1574
1596
|
// e.g. `type: MyPipe`
|
|
1575
1597
|
definitionMap.set('type', meta.type.value);
|
|
1576
1598
|
if (meta.isStandalone !== undefined) {
|
|
1577
|
-
definitionMap.set('isStandalone',
|
|
1599
|
+
definitionMap.set('isStandalone', compiler.literal(meta.isStandalone));
|
|
1578
1600
|
}
|
|
1579
1601
|
// e.g. `name: "myPipe"`
|
|
1580
|
-
definitionMap.set('name',
|
|
1602
|
+
definitionMap.set('name', compiler.literal(meta.pipeName));
|
|
1581
1603
|
if (meta.pure === false) {
|
|
1582
1604
|
// e.g. `pure: false`
|
|
1583
|
-
definitionMap.set('pure',
|
|
1605
|
+
definitionMap.set('pure', compiler.literal(meta.pure));
|
|
1584
1606
|
}
|
|
1585
1607
|
return definitionMap;
|
|
1586
1608
|
}
|
|
@@ -1600,11 +1622,11 @@ function compileClassDebugInfo(debugInfo) {
|
|
|
1600
1622
|
}
|
|
1601
1623
|
// Include forbidOrphanRendering only if it's set to true (to reduce generated code)
|
|
1602
1624
|
if (debugInfo.forbidOrphanRendering) {
|
|
1603
|
-
debugInfoObject.forbidOrphanRendering =
|
|
1625
|
+
debugInfoObject.forbidOrphanRendering = compiler.literal(true);
|
|
1604
1626
|
}
|
|
1605
|
-
const fnCall =
|
|
1606
|
-
.callFn([debugInfo.type,
|
|
1607
|
-
const iife =
|
|
1627
|
+
const fnCall = compiler.importExpr(compiler.Identifiers.setClassDebugInfo)
|
|
1628
|
+
.callFn([debugInfo.type, compiler.mapLiteral(debugInfoObject)]);
|
|
1629
|
+
const iife = compiler.arrowFn([], [compiler.devOnlyGuardedExpression(fnCall).toStmt()]);
|
|
1608
1630
|
return iife.callFn([]);
|
|
1609
1631
|
}
|
|
1610
1632
|
|
|
@@ -1626,69 +1648,69 @@ function compileHmrInitializer(meta) {
|
|
|
1626
1648
|
const idName = 'id';
|
|
1627
1649
|
const importCallbackName = `${meta.className}_HmrLoad`;
|
|
1628
1650
|
const namespaces = meta.namespaceDependencies.map((dep) => {
|
|
1629
|
-
return new
|
|
1651
|
+
return new compiler.ExternalExpr({ moduleName: dep.moduleName, name: null });
|
|
1630
1652
|
});
|
|
1631
1653
|
// m.default
|
|
1632
|
-
const defaultRead =
|
|
1654
|
+
const defaultRead = compiler.variable(moduleName).prop('default');
|
|
1633
1655
|
// ɵɵreplaceMetadata(Comp, m.default, [...namespaces], [...locals], import.meta, id);
|
|
1634
|
-
const replaceCall =
|
|
1656
|
+
const replaceCall = compiler.importExpr(compiler.Identifiers.replaceMetadata)
|
|
1635
1657
|
.callFn([
|
|
1636
1658
|
meta.type,
|
|
1637
1659
|
defaultRead,
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1660
|
+
compiler.literalArr(namespaces),
|
|
1661
|
+
compiler.literalArr(meta.localDependencies.map((l) => l.runtimeRepresentation)),
|
|
1662
|
+
compiler.variable('import').prop('meta'),
|
|
1663
|
+
compiler.variable(idName),
|
|
1642
1664
|
]);
|
|
1643
1665
|
// (m) => m.default && ɵɵreplaceMetadata(...)
|
|
1644
|
-
const replaceCallback =
|
|
1666
|
+
const replaceCallback = compiler.arrowFn([new compiler.FnParam(moduleName)], defaultRead.and(replaceCall));
|
|
1645
1667
|
// '<url>?c=' + id + '&t=' + encodeURIComponent(t)
|
|
1646
|
-
const urlValue =
|
|
1647
|
-
.plus(
|
|
1648
|
-
.plus(
|
|
1649
|
-
.plus(
|
|
1668
|
+
const urlValue = compiler.literal(`./@ng/component?c=`)
|
|
1669
|
+
.plus(compiler.variable(idName))
|
|
1670
|
+
.plus(compiler.literal('&t='))
|
|
1671
|
+
.plus(compiler.variable('encodeURIComponent').callFn([compiler.variable(timestampName)]));
|
|
1650
1672
|
// import.meta.url
|
|
1651
|
-
const urlBase =
|
|
1673
|
+
const urlBase = compiler.variable('import').prop('meta').prop('url');
|
|
1652
1674
|
// new URL(urlValue, urlBase).href
|
|
1653
|
-
const urlHref = new
|
|
1675
|
+
const urlHref = new compiler.InstantiateExpr(compiler.variable('URL'), [urlValue, urlBase]).prop('href');
|
|
1654
1676
|
// function Cmp_HmrLoad(t) {
|
|
1655
1677
|
// import(/* @vite-ignore */ urlHref).then((m) => m.default && replaceMetadata(...));
|
|
1656
1678
|
// }
|
|
1657
|
-
const importCallback = new
|
|
1679
|
+
const importCallback = new compiler.DeclareFunctionStmt(importCallbackName, [new compiler.FnParam(timestampName)], [
|
|
1658
1680
|
// The vite-ignore special comment is required to prevent Vite from generating a superfluous
|
|
1659
1681
|
// warning for each usage within the development code. If Vite provides a method to
|
|
1660
1682
|
// programmatically avoid this warning in the future, this added comment can be removed here.
|
|
1661
|
-
new
|
|
1683
|
+
new compiler.DynamicImportExpr(urlHref, null, '@vite-ignore')
|
|
1662
1684
|
.prop('then')
|
|
1663
1685
|
.callFn([replaceCallback])
|
|
1664
1686
|
.toStmt(),
|
|
1665
|
-
], null,
|
|
1687
|
+
], null, compiler.StmtModifier.Final);
|
|
1666
1688
|
// (d) => d.id === id && Cmp_HmrLoad(d.timestamp)
|
|
1667
|
-
const updateCallback =
|
|
1689
|
+
const updateCallback = compiler.arrowFn([new compiler.FnParam(dataName)], compiler.variable(dataName)
|
|
1668
1690
|
.prop('id')
|
|
1669
|
-
.identical(
|
|
1670
|
-
.and(
|
|
1691
|
+
.identical(compiler.variable(idName))
|
|
1692
|
+
.and(compiler.variable(importCallbackName).callFn([compiler.variable(dataName).prop('timestamp')])));
|
|
1671
1693
|
// Cmp_HmrLoad(Date.now());
|
|
1672
1694
|
// Initial call to kick off the loading in order to avoid edge cases with components
|
|
1673
1695
|
// coming from lazy chunks that change before the chunk has loaded.
|
|
1674
|
-
const initialCall =
|
|
1675
|
-
.callFn([
|
|
1696
|
+
const initialCall = compiler.variable(importCallbackName)
|
|
1697
|
+
.callFn([compiler.variable('Date').prop('now').callFn([])]);
|
|
1676
1698
|
// import.meta.hot
|
|
1677
|
-
const hotRead =
|
|
1699
|
+
const hotRead = compiler.variable('import').prop('meta').prop('hot');
|
|
1678
1700
|
// import.meta.hot.on('angular:component-update', () => ...);
|
|
1679
1701
|
const hotListener = hotRead
|
|
1680
1702
|
.clone()
|
|
1681
1703
|
.prop('on')
|
|
1682
|
-
.callFn([
|
|
1683
|
-
return
|
|
1704
|
+
.callFn([compiler.literal('angular:component-update'), updateCallback]);
|
|
1705
|
+
return compiler.arrowFn([], [
|
|
1684
1706
|
// const id = <id>;
|
|
1685
|
-
new
|
|
1707
|
+
new compiler.DeclareVarStmt(idName, compiler.literal(encodeURIComponent(`${meta.filePath}@${meta.className}`)), null, compiler.StmtModifier.Final),
|
|
1686
1708
|
// function Cmp_HmrLoad() {...}.
|
|
1687
1709
|
importCallback,
|
|
1688
1710
|
// ngDevMode && Cmp_HmrLoad(Date.now());
|
|
1689
|
-
|
|
1711
|
+
compiler.devOnlyGuardedExpression(initialCall).toStmt(),
|
|
1690
1712
|
// ngDevMode && import.meta.hot && import.meta.hot.on(...)
|
|
1691
|
-
|
|
1713
|
+
compiler.devOnlyGuardedExpression(hotRead.and(hotListener)).toStmt(),
|
|
1692
1714
|
])
|
|
1693
1715
|
.callFn([]);
|
|
1694
1716
|
}
|
|
@@ -1701,25 +1723,25 @@ function compileHmrInitializer(meta) {
|
|
|
1701
1723
|
*/
|
|
1702
1724
|
function compileHmrUpdateCallback(definitions, constantStatements, meta) {
|
|
1703
1725
|
const namespaces = 'ɵɵnamespaces';
|
|
1704
|
-
const params = [meta.className, namespaces].map((name) => new
|
|
1726
|
+
const params = [meta.className, namespaces].map((name) => new compiler.FnParam(name, compiler.DYNAMIC_TYPE));
|
|
1705
1727
|
const body = [];
|
|
1706
1728
|
for (const local of meta.localDependencies) {
|
|
1707
|
-
params.push(new
|
|
1729
|
+
params.push(new compiler.FnParam(local.name));
|
|
1708
1730
|
}
|
|
1709
1731
|
// Declare variables that read out the individual namespaces.
|
|
1710
1732
|
for (let i = 0; i < meta.namespaceDependencies.length; i++) {
|
|
1711
|
-
body.push(new
|
|
1733
|
+
body.push(new compiler.DeclareVarStmt(meta.namespaceDependencies[i].assignedName, compiler.variable(namespaces).key(compiler.literal(i)), compiler.DYNAMIC_TYPE, compiler.StmtModifier.Final));
|
|
1712
1734
|
}
|
|
1713
1735
|
body.push(...constantStatements);
|
|
1714
1736
|
for (const field of definitions) {
|
|
1715
1737
|
if (field.initializer !== null) {
|
|
1716
|
-
body.push(
|
|
1738
|
+
body.push(compiler.variable(meta.className).prop(field.name).set(field.initializer).toStmt());
|
|
1717
1739
|
for (const stmt of field.statements) {
|
|
1718
1740
|
body.push(stmt);
|
|
1719
1741
|
}
|
|
1720
1742
|
}
|
|
1721
1743
|
}
|
|
1722
|
-
return new
|
|
1744
|
+
return new compiler.DeclareFunctionStmt(`${meta.className}_UpdateMetadata`, params, body, null, compiler.StmtModifier.Final);
|
|
1723
1745
|
}
|
|
1724
1746
|
|
|
1725
1747
|
/**
|
|
@@ -1772,7 +1794,7 @@ class UnifiedModulesAliasingHost {
|
|
|
1772
1794
|
}
|
|
1773
1795
|
// viaModule is the module it'll actually be imported from.
|
|
1774
1796
|
const moduleName = this.unifiedModulesHost.fileNameToModuleName(via.fileName, via.fileName);
|
|
1775
|
-
return new
|
|
1797
|
+
return new compiler.ExternalExpr({ moduleName, name: this.aliasName(decl, via) });
|
|
1776
1798
|
}
|
|
1777
1799
|
/**
|
|
1778
1800
|
* Generates an alias name based on the full module name of the file which declares the aliased
|
|
@@ -4231,7 +4253,7 @@ class IvyTransformationVisitor extends Visitor {
|
|
|
4231
4253
|
* A transformer which operates on ts.SourceFiles and applies changes from an `IvyCompilation`.
|
|
4232
4254
|
*/
|
|
4233
4255
|
function transformIvySourceFile(compilation, context, reflector, importRewriter, localCompilationExtraImportsTracker, file, isCore, isClosureCompilerEnabled, recordWrappedNode) {
|
|
4234
|
-
const constantPool = new
|
|
4256
|
+
const constantPool = new compiler.ConstantPool(isClosureCompilerEnabled);
|
|
4235
4257
|
const importManager = new checker.ImportManager({
|
|
4236
4258
|
...checker.presetImportManagerForceNamespaceImports,
|
|
4237
4259
|
rewriter: importRewriter,
|
|
@@ -4387,7 +4409,7 @@ function resolveEncapsulationEnumValueLocally(expr) {
|
|
|
4387
4409
|
return null;
|
|
4388
4410
|
}
|
|
4389
4411
|
const exprText = expr.getText().trim();
|
|
4390
|
-
for (const key in
|
|
4412
|
+
for (const key in compiler.ViewEncapsulation) {
|
|
4391
4413
|
if (!Number.isNaN(Number(key))) {
|
|
4392
4414
|
continue;
|
|
4393
4415
|
}
|
|
@@ -4395,7 +4417,7 @@ function resolveEncapsulationEnumValueLocally(expr) {
|
|
|
4395
4417
|
// Check whether the enum is imported by name or used by import namespace (e.g.,
|
|
4396
4418
|
// core.ViewEncapsulation.None)
|
|
4397
4419
|
if (exprText === suffix || exprText.endsWith(`.${suffix}`)) {
|
|
4398
|
-
const ans = Number(
|
|
4420
|
+
const ans = Number(compiler.ViewEncapsulation[key]);
|
|
4399
4421
|
return ans;
|
|
4400
4422
|
}
|
|
4401
4423
|
}
|
|
@@ -4421,7 +4443,7 @@ function resolveLiteral(decorator, literalCache) {
|
|
|
4421
4443
|
}
|
|
4422
4444
|
|
|
4423
4445
|
function compileNgFactoryDefField(metadata) {
|
|
4424
|
-
const res =
|
|
4446
|
+
const res = compiler.compileFactoryFunction(metadata);
|
|
4425
4447
|
return {
|
|
4426
4448
|
name: 'ɵfac',
|
|
4427
4449
|
initializer: res.expression,
|
|
@@ -4506,35 +4528,33 @@ function extractClassMetadata(clazz, reflection, isCore, annotateForClosureCompi
|
|
|
4506
4528
|
if (ngClassDecorators.length === 0) {
|
|
4507
4529
|
return null;
|
|
4508
4530
|
}
|
|
4509
|
-
const metaDecorators = new
|
|
4531
|
+
const metaDecorators = new compiler.WrappedNodeExpr(ts.factory.createArrayLiteralExpression(ngClassDecorators));
|
|
4510
4532
|
// Convert the constructor parameters to metadata, passing null if none are present.
|
|
4511
4533
|
let metaCtorParameters = null;
|
|
4512
4534
|
const classCtorParameters = reflection.getConstructorParameters(clazz);
|
|
4513
4535
|
if (classCtorParameters !== null) {
|
|
4514
4536
|
const ctorParameters = classCtorParameters.map((param) => ctorParameterToMetadata(param, isCore));
|
|
4515
|
-
metaCtorParameters = new
|
|
4537
|
+
metaCtorParameters = new compiler.ArrowFunctionExpr([], new compiler.LiteralArrayExpr(ctorParameters));
|
|
4516
4538
|
}
|
|
4517
4539
|
// Do the same for property decorators.
|
|
4518
4540
|
let metaPropDecorators = null;
|
|
4519
4541
|
const classMembers = reflection
|
|
4520
4542
|
.getMembersOfClass(clazz)
|
|
4521
4543
|
.filter((member) => !member.isStatic && member.decorators !== null && member.decorators.length > 0);
|
|
4522
|
-
const
|
|
4523
|
-
|
|
4524
|
-
.filter((name, i, arr) => arr.indexOf(name) < i);
|
|
4525
|
-
if (duplicateDecoratedMemberNames.length > 0) {
|
|
4544
|
+
const duplicateDecoratedMembers = classMembers.filter((member, i, arr) => arr.findIndex((arrayMember) => arrayMember.name === member.name) < i);
|
|
4545
|
+
if (duplicateDecoratedMembers.length > 0) {
|
|
4526
4546
|
// This should theoretically never happen, because the only way to have duplicate instance
|
|
4527
4547
|
// member names is getter/setter pairs and decorators cannot appear in both a getter and the
|
|
4528
4548
|
// corresponding setter.
|
|
4529
|
-
throw new
|
|
4530
|
-
|
|
4549
|
+
throw new checker.FatalDiagnosticError(checker.ErrorCode.DUPLICATE_DECORATED_PROPERTIES, duplicateDecoratedMembers[0].nameNode ?? clazz, `Duplicate decorated properties found on class '${clazz.name.text}': ` +
|
|
4550
|
+
duplicateDecoratedMembers.map((member) => member.name).join(', '));
|
|
4531
4551
|
}
|
|
4532
4552
|
const decoratedMembers = classMembers.map((member) => classMemberToMetadata(member.nameNode ?? member.name, member.decorators, isCore));
|
|
4533
4553
|
if (decoratedMembers.length > 0) {
|
|
4534
|
-
metaPropDecorators = new
|
|
4554
|
+
metaPropDecorators = new compiler.WrappedNodeExpr(ts.factory.createObjectLiteralExpression(decoratedMembers));
|
|
4535
4555
|
}
|
|
4536
4556
|
return {
|
|
4537
|
-
type: new
|
|
4557
|
+
type: new compiler.WrappedNodeExpr(id),
|
|
4538
4558
|
decorators: metaDecorators,
|
|
4539
4559
|
ctorParameters: metaCtorParameters,
|
|
4540
4560
|
propDecorators: metaPropDecorators,
|
|
@@ -4548,7 +4568,7 @@ function ctorParameterToMetadata(param, isCore) {
|
|
|
4548
4568
|
// its type is undefined.
|
|
4549
4569
|
const type = param.typeValueReference.kind !== 2 /* TypeValueReferenceKind.UNAVAILABLE */
|
|
4550
4570
|
? checker.valueReferenceToExpression(param.typeValueReference)
|
|
4551
|
-
: new
|
|
4571
|
+
: new compiler.LiteralExpr(undefined);
|
|
4552
4572
|
const mapEntries = [
|
|
4553
4573
|
{ key: 'type', value: type, quoted: false },
|
|
4554
4574
|
];
|
|
@@ -4557,10 +4577,10 @@ function ctorParameterToMetadata(param, isCore) {
|
|
|
4557
4577
|
const ngDecorators = param.decorators
|
|
4558
4578
|
.filter((dec) => isAngularDecorator$1(dec, isCore))
|
|
4559
4579
|
.map((decorator) => decoratorToMetadata(decorator));
|
|
4560
|
-
const value = new
|
|
4580
|
+
const value = new compiler.WrappedNodeExpr(ts.factory.createArrayLiteralExpression(ngDecorators));
|
|
4561
4581
|
mapEntries.push({ key: 'decorators', value, quoted: false });
|
|
4562
4582
|
}
|
|
4563
|
-
return
|
|
4583
|
+
return compiler.literalMap(mapEntries);
|
|
4564
4584
|
}
|
|
4565
4585
|
/**
|
|
4566
4586
|
* Convert a reflected class member to metadata.
|
|
@@ -4624,10 +4644,10 @@ function extractClassDebugInfo(clazz, reflection, compilerHost, rootDirs, forbid
|
|
|
4624
4644
|
const srcFile = clazz.getSourceFile();
|
|
4625
4645
|
const srcFileMaybeRelativePath = getProjectRelativePath(srcFile.fileName, rootDirs, compilerHost);
|
|
4626
4646
|
return {
|
|
4627
|
-
type: new
|
|
4628
|
-
className:
|
|
4629
|
-
filePath: srcFileMaybeRelativePath ?
|
|
4630
|
-
lineNumber:
|
|
4647
|
+
type: new compiler.WrappedNodeExpr(clazz.name),
|
|
4648
|
+
className: compiler.literal(clazz.name.getText()),
|
|
4649
|
+
filePath: srcFileMaybeRelativePath ? compiler.literal(srcFileMaybeRelativePath) : null,
|
|
4650
|
+
lineNumber: compiler.literal(srcFile.getLineAndCharacterOfPosition(clazz.name.pos).line + 1),
|
|
4631
4651
|
forbidOrphanRendering,
|
|
4632
4652
|
};
|
|
4633
4653
|
}
|
|
@@ -4658,10 +4678,10 @@ function extractSchemas(rawExpr, evaluator, context) {
|
|
|
4658
4678
|
// renamed when the user imported it, these names will match.
|
|
4659
4679
|
switch (id.text) {
|
|
4660
4680
|
case 'CUSTOM_ELEMENTS_SCHEMA':
|
|
4661
|
-
schemas.push(
|
|
4681
|
+
schemas.push(compiler.CUSTOM_ELEMENTS_SCHEMA);
|
|
4662
4682
|
break;
|
|
4663
4683
|
case 'NO_ERRORS_SCHEMA':
|
|
4664
|
-
schemas.push(
|
|
4684
|
+
schemas.push(compiler.NO_ERRORS_SCHEMA);
|
|
4665
4685
|
break;
|
|
4666
4686
|
default:
|
|
4667
4687
|
throw checker.createValueHasWrongTypeError(rawExpr, schemaRef, `'${schemaRef.debugName}' is not a valid ${context} schema`);
|
|
@@ -4686,7 +4706,7 @@ function compileInputTransformFields(inputs) {
|
|
|
4686
4706
|
if (input.transform) {
|
|
4687
4707
|
extraFields.push({
|
|
4688
4708
|
name: `ngAcceptInputType_${input.classPropertyName}`,
|
|
4689
|
-
type:
|
|
4709
|
+
type: compiler.transplantedType(input.transform.type),
|
|
4690
4710
|
statements: [],
|
|
4691
4711
|
initializer: null,
|
|
4692
4712
|
deferrableImports: null,
|
|
@@ -4969,7 +4989,7 @@ class SemanticDepGraphUpdater {
|
|
|
4969
4989
|
}
|
|
4970
4990
|
}
|
|
4971
4991
|
function getImportPath(expr) {
|
|
4972
|
-
if (expr instanceof
|
|
4992
|
+
if (expr instanceof compiler.ExternalExpr) {
|
|
4973
4993
|
return `${expr.value.moduleName}\$${expr.value.name}`;
|
|
4974
4994
|
}
|
|
4975
4995
|
else {
|
|
@@ -5737,7 +5757,7 @@ class LocalModuleScopeRegistry {
|
|
|
5737
5757
|
return;
|
|
5738
5758
|
}
|
|
5739
5759
|
if (!reexportMap.has(exportName)) {
|
|
5740
|
-
if (exportRef.alias && exportRef.alias instanceof
|
|
5760
|
+
if (exportRef.alias && exportRef.alias instanceof compiler.ExternalExpr) {
|
|
5741
5761
|
reexports.push({
|
|
5742
5762
|
fromModule: exportRef.alias.value.moduleName,
|
|
5743
5763
|
symbolName: exportRef.alias.value.name,
|
|
@@ -5748,7 +5768,7 @@ class LocalModuleScopeRegistry {
|
|
|
5748
5768
|
const emittedRef = this.refEmitter.emit(exportRef.cloneWithNoIdentifiers(), sourceFile);
|
|
5749
5769
|
checker.assertSuccessfulReferenceEmit(emittedRef, ngModuleRef.node.name, 'class');
|
|
5750
5770
|
const expr = emittedRef.expression;
|
|
5751
|
-
if (!(expr instanceof
|
|
5771
|
+
if (!(expr instanceof compiler.ExternalExpr) ||
|
|
5752
5772
|
expr.value.moduleName === null ||
|
|
5753
5773
|
expr.value.name === null) {
|
|
5754
5774
|
throw new Error('Expected ExternalExpr');
|
|
@@ -5887,7 +5907,7 @@ class TypeCheckScopeRegistry {
|
|
|
5887
5907
|
* an empty type-check scope is returned.
|
|
5888
5908
|
*/
|
|
5889
5909
|
getTypeCheckScope(node) {
|
|
5890
|
-
const matcher = new
|
|
5910
|
+
const matcher = new compiler.SelectorMatcher();
|
|
5891
5911
|
const directives = [];
|
|
5892
5912
|
const pipes = new Map();
|
|
5893
5913
|
const scope = this.scopeReader.getScopeForComponent(node);
|
|
@@ -5920,7 +5940,7 @@ class TypeCheckScopeRegistry {
|
|
|
5920
5940
|
}
|
|
5921
5941
|
// Carry over the `isExplicitlyDeferred` flag from the dependency info.
|
|
5922
5942
|
const directiveMeta = this.applyExplicitlyDeferredFlag(extMeta, meta.isExplicitlyDeferred);
|
|
5923
|
-
matcher.addSelectables(
|
|
5943
|
+
matcher.addSelectables(compiler.CssSelector.parse(meta.selector), [
|
|
5924
5944
|
...this.hostDirectivesResolver.resolve(directiveMeta),
|
|
5925
5945
|
directiveMeta,
|
|
5926
5946
|
]);
|
|
@@ -6736,7 +6756,7 @@ class DirectiveDecoratorHandler {
|
|
|
6736
6756
|
}
|
|
6737
6757
|
const hostElement = checker.createHostElement('directive', meta.meta.selector, node, meta.hostBindingNodes.literal, meta.hostBindingNodes.bindingDecorators, meta.hostBindingNodes.listenerDecorators);
|
|
6738
6758
|
if (hostElement !== null) {
|
|
6739
|
-
const binder = new
|
|
6759
|
+
const binder = new compiler.R3TargetBinder(scope.matcher);
|
|
6740
6760
|
const hostBindingsContext = {
|
|
6741
6761
|
node: hostElement,
|
|
6742
6762
|
sourceMapping: { type: 'direct', node },
|
|
@@ -6753,7 +6773,7 @@ class DirectiveDecoratorHandler {
|
|
|
6753
6773
|
}
|
|
6754
6774
|
const diagnostics = [];
|
|
6755
6775
|
if (analysis.providersRequiringFactory !== null &&
|
|
6756
|
-
analysis.meta.providers instanceof
|
|
6776
|
+
analysis.meta.providers instanceof compiler.WrappedNodeExpr) {
|
|
6757
6777
|
const providerDiagnostics = checker.getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
|
|
6758
6778
|
diagnostics.push(...providerDiagnostics);
|
|
6759
6779
|
}
|
|
@@ -6775,8 +6795,8 @@ class DirectiveDecoratorHandler {
|
|
|
6775
6795
|
return { data: {} };
|
|
6776
6796
|
}
|
|
6777
6797
|
compileFull(node, analysis, resolution, pool) {
|
|
6778
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
6779
|
-
const def =
|
|
6798
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Directive));
|
|
6799
|
+
const def = compiler.compileDirectiveFromMetadata(analysis.meta, pool, compiler.makeBindingParser());
|
|
6780
6800
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
6781
6801
|
const classMetadata = analysis.classMetadata !== null
|
|
6782
6802
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
@@ -6784,7 +6804,7 @@ class DirectiveDecoratorHandler {
|
|
|
6784
6804
|
return checker.compileResults(fac, def, classMetadata, 'ɵdir', inputTransformFields, null /* deferrableImports */);
|
|
6785
6805
|
}
|
|
6786
6806
|
compilePartial(node, analysis, resolution) {
|
|
6787
|
-
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta,
|
|
6807
|
+
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Directive));
|
|
6788
6808
|
const def = compileDeclareDirectiveFromMetadata(analysis.meta);
|
|
6789
6809
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
6790
6810
|
const classMetadata = analysis.classMetadata !== null
|
|
@@ -6793,8 +6813,8 @@ class DirectiveDecoratorHandler {
|
|
|
6793
6813
|
return checker.compileResults(fac, def, classMetadata, 'ɵdir', inputTransformFields, null /* deferrableImports */);
|
|
6794
6814
|
}
|
|
6795
6815
|
compileLocal(node, analysis, resolution, pool) {
|
|
6796
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
6797
|
-
const def =
|
|
6816
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Directive));
|
|
6817
|
+
const def = compiler.compileDirectiveFromMetadata(analysis.meta, pool, compiler.makeBindingParser());
|
|
6798
6818
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
6799
6819
|
const classMetadata = analysis.classMetadata !== null
|
|
6800
6820
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
@@ -7178,7 +7198,7 @@ class NgModuleDecoratorHandler {
|
|
|
7178
7198
|
if (ngModule.has('id')) {
|
|
7179
7199
|
const idExpr = ngModule.get('id');
|
|
7180
7200
|
if (!isModuleIdExpression(idExpr)) {
|
|
7181
|
-
id = new
|
|
7201
|
+
id = new compiler.WrappedNodeExpr(idExpr);
|
|
7182
7202
|
}
|
|
7183
7203
|
else {
|
|
7184
7204
|
const diag = checker.makeDiagnostic(checker.ErrorCode.WARN_NGMODULE_ID_UNNECESSARY, idExpr, `Using 'module.id' for NgModule.id is a common anti-pattern that is ignored by the Angular compiler.`);
|
|
@@ -7209,23 +7229,23 @@ class NgModuleDecoratorHandler {
|
|
|
7209
7229
|
let ngModuleMetadata;
|
|
7210
7230
|
if (this.compilationMode === checker.CompilationMode.LOCAL) {
|
|
7211
7231
|
ngModuleMetadata = {
|
|
7212
|
-
kind:
|
|
7232
|
+
kind: compiler.R3NgModuleMetadataKind.Local,
|
|
7213
7233
|
type,
|
|
7214
|
-
bootstrapExpression: rawBootstrap ? new
|
|
7215
|
-
declarationsExpression: rawDeclarations ? new
|
|
7216
|
-
exportsExpression: rawExports ? new
|
|
7217
|
-
importsExpression: rawImports ? new
|
|
7234
|
+
bootstrapExpression: rawBootstrap ? new compiler.WrappedNodeExpr(rawBootstrap) : null,
|
|
7235
|
+
declarationsExpression: rawDeclarations ? new compiler.WrappedNodeExpr(rawDeclarations) : null,
|
|
7236
|
+
exportsExpression: rawExports ? new compiler.WrappedNodeExpr(rawExports) : null,
|
|
7237
|
+
importsExpression: rawImports ? new compiler.WrappedNodeExpr(rawImports) : null,
|
|
7218
7238
|
id,
|
|
7219
7239
|
// Use `ɵɵsetNgModuleScope` to patch selector scopes onto the generated definition in a
|
|
7220
7240
|
// tree-shakeable way.
|
|
7221
|
-
selectorScopeMode:
|
|
7241
|
+
selectorScopeMode: compiler.R3SelectorScopeMode.SideEffect,
|
|
7222
7242
|
// TODO: to be implemented as a part of FW-1004.
|
|
7223
7243
|
schemas: [],
|
|
7224
7244
|
};
|
|
7225
7245
|
}
|
|
7226
7246
|
else {
|
|
7227
7247
|
ngModuleMetadata = {
|
|
7228
|
-
kind:
|
|
7248
|
+
kind: compiler.R3NgModuleMetadataKind.Global,
|
|
7229
7249
|
type,
|
|
7230
7250
|
bootstrap,
|
|
7231
7251
|
declarations,
|
|
@@ -7240,8 +7260,8 @@ class NgModuleDecoratorHandler {
|
|
|
7240
7260
|
// Use `ɵɵsetNgModuleScope` to patch selector scopes onto the generated definition in a
|
|
7241
7261
|
// tree-shakeable way.
|
|
7242
7262
|
selectorScopeMode: this.includeSelectorScope
|
|
7243
|
-
?
|
|
7244
|
-
:
|
|
7263
|
+
? compiler.R3SelectorScopeMode.SideEffect
|
|
7264
|
+
: compiler.R3SelectorScopeMode.Omit,
|
|
7245
7265
|
// TODO: to be implemented as a part of FW-1004.
|
|
7246
7266
|
schemas: [],
|
|
7247
7267
|
};
|
|
@@ -7252,7 +7272,7 @@ class NgModuleDecoratorHandler {
|
|
|
7252
7272
|
// and don't include the providers if it doesn't which saves us a few bytes.
|
|
7253
7273
|
if (rawProviders !== null &&
|
|
7254
7274
|
(!ts.isArrayLiteralExpression(rawProviders) || rawProviders.elements.length > 0)) {
|
|
7255
|
-
wrappedProviders = new
|
|
7275
|
+
wrappedProviders = new compiler.WrappedNodeExpr(this.annotateForClosureCompiler
|
|
7256
7276
|
? checker.wrapFunctionExpressionsInParens(rawProviders)
|
|
7257
7277
|
: rawProviders);
|
|
7258
7278
|
}
|
|
@@ -7304,12 +7324,12 @@ class NgModuleDecoratorHandler {
|
|
|
7304
7324
|
if (ts.isArrayLiteralExpression(exp)) {
|
|
7305
7325
|
// If array expression then add it entry-by-entry to the injector imports
|
|
7306
7326
|
if (exp.elements) {
|
|
7307
|
-
injectorMetadata.imports.push(...exp.elements.map((n) => new
|
|
7327
|
+
injectorMetadata.imports.push(...exp.elements.map((n) => new compiler.WrappedNodeExpr(n)));
|
|
7308
7328
|
}
|
|
7309
7329
|
}
|
|
7310
7330
|
else {
|
|
7311
7331
|
// if not array expression then add it as is to the injector's imports field.
|
|
7312
|
-
injectorMetadata.imports.push(new
|
|
7332
|
+
injectorMetadata.imports.push(new compiler.WrappedNodeExpr(exp));
|
|
7313
7333
|
}
|
|
7314
7334
|
}
|
|
7315
7335
|
}
|
|
@@ -7318,7 +7338,7 @@ class NgModuleDecoratorHandler {
|
|
|
7318
7338
|
type,
|
|
7319
7339
|
typeArgumentCount: 0,
|
|
7320
7340
|
deps: checker.getValidConstructorDependencies(node, this.reflector, this.isCore),
|
|
7321
|
-
target:
|
|
7341
|
+
target: compiler.FactoryTarget.NgModule,
|
|
7322
7342
|
};
|
|
7323
7343
|
// Remote scoping is used when adding imports to a component file would create a cycle. In such
|
|
7324
7344
|
// circumstances the component scope is monkey-patched from the NgModule file instead.
|
|
@@ -7417,7 +7437,7 @@ class NgModuleDecoratorHandler {
|
|
|
7417
7437
|
if (topLevelImport.hasModuleWithProviders) {
|
|
7418
7438
|
// We have no choice but to emit expressions which contain MWPs, as we cannot filter on
|
|
7419
7439
|
// individual references.
|
|
7420
|
-
data.injectorImports.push(new
|
|
7440
|
+
data.injectorImports.push(new compiler.WrappedNodeExpr(topLevelImport.expression));
|
|
7421
7441
|
continue;
|
|
7422
7442
|
}
|
|
7423
7443
|
const refsToEmit = [];
|
|
@@ -7460,7 +7480,7 @@ class NgModuleDecoratorHandler {
|
|
|
7460
7480
|
if (refsToEmit.length === topLevelImport.resolvedReferences.length) {
|
|
7461
7481
|
// All references within this top-level import should be emitted, so just use the user's
|
|
7462
7482
|
// expression.
|
|
7463
|
-
data.injectorImports.push(new
|
|
7483
|
+
data.injectorImports.push(new compiler.WrappedNodeExpr(topLevelImport.expression));
|
|
7464
7484
|
}
|
|
7465
7485
|
else {
|
|
7466
7486
|
// Some references have been filtered out. Emit references to individual classes.
|
|
@@ -7512,11 +7532,11 @@ class NgModuleDecoratorHandler {
|
|
|
7512
7532
|
}
|
|
7513
7533
|
compileFull(node, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection, }, { injectorImports }) {
|
|
7514
7534
|
const factoryFn = compileNgFactoryDefField(fac);
|
|
7515
|
-
const ngInjectorDef =
|
|
7535
|
+
const ngInjectorDef = compiler.compileInjector({
|
|
7516
7536
|
...inj,
|
|
7517
7537
|
imports: injectorImports,
|
|
7518
7538
|
});
|
|
7519
|
-
const ngModuleDef =
|
|
7539
|
+
const ngModuleDef = compiler.compileNgModule(mod);
|
|
7520
7540
|
const statements = ngModuleDef.statements;
|
|
7521
7541
|
const metadata = classMetadata !== null ? compileClassMetadata(classMetadata) : null;
|
|
7522
7542
|
this.insertMetadataStatement(statements, metadata);
|
|
@@ -7537,10 +7557,10 @@ class NgModuleDecoratorHandler {
|
|
|
7537
7557
|
}
|
|
7538
7558
|
compileLocal(node, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection, }) {
|
|
7539
7559
|
const factoryFn = compileNgFactoryDefField(fac);
|
|
7540
|
-
const ngInjectorDef =
|
|
7560
|
+
const ngInjectorDef = compiler.compileInjector({
|
|
7541
7561
|
...inj,
|
|
7542
7562
|
});
|
|
7543
|
-
const ngModuleDef =
|
|
7563
|
+
const ngModuleDef = compiler.compileNgModule(mod);
|
|
7544
7564
|
const statements = ngModuleDef.statements;
|
|
7545
7565
|
const metadata = classMetadata !== null ? compileClassMetadata(classMetadata) : null;
|
|
7546
7566
|
this.insertMetadataStatement(statements, metadata);
|
|
@@ -7578,19 +7598,19 @@ class NgModuleDecoratorHandler {
|
|
|
7578
7598
|
checker.assertSuccessfulReferenceEmit(type, node, 'pipe');
|
|
7579
7599
|
return type.expression;
|
|
7580
7600
|
});
|
|
7581
|
-
const directiveArray = new
|
|
7582
|
-
const pipesArray = new
|
|
7601
|
+
const directiveArray = new compiler.LiteralArrayExpr(directives);
|
|
7602
|
+
const pipesArray = new compiler.LiteralArrayExpr(pipes);
|
|
7583
7603
|
const directiveExpr = remoteScopesMayRequireCycleProtection && directives.length > 0
|
|
7584
|
-
? new
|
|
7604
|
+
? new compiler.FunctionExpr([], [new compiler.ReturnStatement(directiveArray)])
|
|
7585
7605
|
: directiveArray;
|
|
7586
7606
|
const pipesExpr = remoteScopesMayRequireCycleProtection && pipes.length > 0
|
|
7587
|
-
? new
|
|
7607
|
+
? new compiler.FunctionExpr([], [new compiler.ReturnStatement(pipesArray)])
|
|
7588
7608
|
: pipesArray;
|
|
7589
7609
|
const componentType = this.refEmitter.emit(decl, context);
|
|
7590
7610
|
checker.assertSuccessfulReferenceEmit(componentType, node, 'component');
|
|
7591
7611
|
const declExpr = componentType.expression;
|
|
7592
|
-
const setComponentScope = new
|
|
7593
|
-
const callExpr = new
|
|
7612
|
+
const setComponentScope = new compiler.ExternalExpr(compiler.Identifiers.setComponentScope);
|
|
7613
|
+
const callExpr = new compiler.InvokeFunctionExpr(setComponentScope, [
|
|
7594
7614
|
declExpr,
|
|
7595
7615
|
directiveExpr,
|
|
7596
7616
|
pipesExpr,
|
|
@@ -7855,7 +7875,7 @@ function createEmptyTemplate(componentClass, component, containingFile) {
|
|
|
7855
7875
|
styles: [],
|
|
7856
7876
|
styleUrls: [],
|
|
7857
7877
|
ngContentSelectors: [],
|
|
7858
|
-
file: new
|
|
7878
|
+
file: new compiler.ParseSourceFile('', ''),
|
|
7859
7879
|
sourceMapping: templateUrl
|
|
7860
7880
|
? { type: 'direct', node: template }
|
|
7861
7881
|
: {
|
|
@@ -7868,7 +7888,7 @@ function createEmptyTemplate(componentClass, component, containingFile) {
|
|
|
7868
7888
|
declaration: templateUrl
|
|
7869
7889
|
? {
|
|
7870
7890
|
isInline: false,
|
|
7871
|
-
interpolationConfig:
|
|
7891
|
+
interpolationConfig: compiler.InterpolationConfig.fromArray(null),
|
|
7872
7892
|
preserveWhitespaces: false,
|
|
7873
7893
|
templateUrlExpression: templateUrl,
|
|
7874
7894
|
templateUrl: 'missing.ng.html',
|
|
@@ -7876,7 +7896,7 @@ function createEmptyTemplate(componentClass, component, containingFile) {
|
|
|
7876
7896
|
}
|
|
7877
7897
|
: {
|
|
7878
7898
|
isInline: true,
|
|
7879
|
-
interpolationConfig:
|
|
7899
|
+
interpolationConfig: compiler.InterpolationConfig.fromArray(null),
|
|
7880
7900
|
preserveWhitespaces: false,
|
|
7881
7901
|
expression: template,
|
|
7882
7902
|
templateUrl: containingFile,
|
|
@@ -7897,7 +7917,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
7897
7917
|
enableBlockSyntax: options.enableBlockSyntax,
|
|
7898
7918
|
enableLetSyntax: options.enableLetSyntax,
|
|
7899
7919
|
};
|
|
7900
|
-
const parsedTemplate =
|
|
7920
|
+
const parsedTemplate = compiler.parseTemplate(sourceStr, sourceMapUrl ?? '', {
|
|
7901
7921
|
...commonParseOptions,
|
|
7902
7922
|
preserveWhitespaces: template.preserveWhitespaces,
|
|
7903
7923
|
preserveSignificantWhitespace: options.preserveSignificantWhitespace,
|
|
@@ -7916,7 +7936,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
7916
7936
|
//
|
|
7917
7937
|
// In order to guarantee the correctness of diagnostics, templates are parsed a second time
|
|
7918
7938
|
// with the above options set to preserve source mappings.
|
|
7919
|
-
const { nodes: diagNodes } =
|
|
7939
|
+
const { nodes: diagNodes } = compiler.parseTemplate(sourceStr, sourceMapUrl ?? '', {
|
|
7920
7940
|
...commonParseOptions,
|
|
7921
7941
|
preserveWhitespaces: true,
|
|
7922
7942
|
preserveLineEndings: true,
|
|
@@ -7926,7 +7946,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
7926
7946
|
return {
|
|
7927
7947
|
...parsedTemplate,
|
|
7928
7948
|
diagNodes,
|
|
7929
|
-
file: new
|
|
7949
|
+
file: new compiler.ParseSourceFile(sourceStr, sourceMapUrl ?? ''),
|
|
7930
7950
|
};
|
|
7931
7951
|
}
|
|
7932
7952
|
function parseTemplateDeclaration(node, decorator, component, containingFile, evaluator, depTracker, resourceLoader, defaultPreserveWhitespaces) {
|
|
@@ -7939,7 +7959,7 @@ function parseTemplateDeclaration(node, decorator, component, containingFile, ev
|
|
|
7939
7959
|
}
|
|
7940
7960
|
preserveWhitespaces = value;
|
|
7941
7961
|
}
|
|
7942
|
-
let interpolationConfig =
|
|
7962
|
+
let interpolationConfig = compiler.DEFAULT_INTERPOLATION_CONFIG;
|
|
7943
7963
|
if (component.has('interpolation')) {
|
|
7944
7964
|
const expr = component.get('interpolation');
|
|
7945
7965
|
const value = evaluator.evaluate(expr);
|
|
@@ -7948,7 +7968,7 @@ function parseTemplateDeclaration(node, decorator, component, containingFile, ev
|
|
|
7948
7968
|
!value.every((element) => typeof element === 'string')) {
|
|
7949
7969
|
throw checker.createValueHasWrongTypeError(expr, value, 'interpolation must be an array with 2 elements of string type');
|
|
7950
7970
|
}
|
|
7951
|
-
interpolationConfig =
|
|
7971
|
+
interpolationConfig = compiler.InterpolationConfig.fromArray(value);
|
|
7952
7972
|
}
|
|
7953
7973
|
if (component.has('templateUrl')) {
|
|
7954
7974
|
const templateUrlExpr = component.get('templateUrl');
|
|
@@ -8431,7 +8451,7 @@ function extractHmrDependencies(node, definition, factory, deferBlockMetadata, c
|
|
|
8431
8451
|
const local = [];
|
|
8432
8452
|
const seenLocals = new Set();
|
|
8433
8453
|
for (const readNode of visitor.allReads) {
|
|
8434
|
-
const readName = readNode instanceof
|
|
8454
|
+
const readName = readNode instanceof compiler.ReadVarExpr ? readNode.name : readNode.text;
|
|
8435
8455
|
if (readName !== name && !seenLocals.has(readName) && availableTopLevel.has(readName)) {
|
|
8436
8456
|
const runtimeRepresentation = getRuntimeRepresentation(readNode, reflection, evaluator);
|
|
8437
8457
|
if (runtimeRepresentation === null) {
|
|
@@ -8453,8 +8473,8 @@ function extractHmrDependencies(node, definition, factory, deferBlockMetadata, c
|
|
|
8453
8473
|
* Gets a node that can be used to represent an identifier in the HMR replacement code at runtime.
|
|
8454
8474
|
*/
|
|
8455
8475
|
function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
8456
|
-
if (node instanceof
|
|
8457
|
-
return
|
|
8476
|
+
if (node instanceof compiler.ReadVarExpr) {
|
|
8477
|
+
return compiler.variable(node.name);
|
|
8458
8478
|
}
|
|
8459
8479
|
// Const enums can't be passed by reference, because their values are inlined.
|
|
8460
8480
|
// Pass in an object literal with all of the values instead.
|
|
@@ -8471,7 +8491,7 @@ function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
|
8471
8491
|
members.push({
|
|
8472
8492
|
key: name,
|
|
8473
8493
|
quoted: false,
|
|
8474
|
-
value:
|
|
8494
|
+
value: compiler.literal(value.resolved),
|
|
8475
8495
|
});
|
|
8476
8496
|
}
|
|
8477
8497
|
else {
|
|
@@ -8481,10 +8501,10 @@ function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
|
8481
8501
|
return null;
|
|
8482
8502
|
}
|
|
8483
8503
|
}
|
|
8484
|
-
return
|
|
8504
|
+
return compiler.literalMap(members);
|
|
8485
8505
|
}
|
|
8486
8506
|
}
|
|
8487
|
-
return
|
|
8507
|
+
return compiler.variable(node.text);
|
|
8488
8508
|
}
|
|
8489
8509
|
/**
|
|
8490
8510
|
* Gets the names of all top-level declarations within the file (imports, declared classes etc).
|
|
@@ -8564,7 +8584,7 @@ function trackBindingName(node, results) {
|
|
|
8564
8584
|
* The reads are "potential", because the visitor doesn't account for local variables
|
|
8565
8585
|
* inside functions.
|
|
8566
8586
|
*/
|
|
8567
|
-
class PotentialTopLevelReadsVisitor extends
|
|
8587
|
+
class PotentialTopLevelReadsVisitor extends compiler.RecursiveAstVisitor$1 {
|
|
8568
8588
|
allReads = new Set();
|
|
8569
8589
|
namespaceReads = new Set();
|
|
8570
8590
|
visitExternalExpr(ast, context) {
|
|
@@ -8750,7 +8770,7 @@ function extractHmrMetatadata(clazz, reflection, evaluator, compilerHost, rootDi
|
|
|
8750
8770
|
return null;
|
|
8751
8771
|
}
|
|
8752
8772
|
const meta = {
|
|
8753
|
-
type: new
|
|
8773
|
+
type: new compiler.WrappedNodeExpr(clazz.name),
|
|
8754
8774
|
className: clazz.name.text,
|
|
8755
8775
|
filePath,
|
|
8756
8776
|
localDependencies: dependencies.local,
|
|
@@ -8809,8 +8829,8 @@ class HmrModuleImportRewriter {
|
|
|
8809
8829
|
}
|
|
8810
8830
|
|
|
8811
8831
|
const EMPTY_ARRAY = [];
|
|
8812
|
-
const isUsedDirective = (decl) => decl.kind ===
|
|
8813
|
-
const isUsedPipe = (decl) => decl.kind ===
|
|
8832
|
+
const isUsedDirective = (decl) => decl.kind === compiler.R3TemplateDependencyKind.Directive;
|
|
8833
|
+
const isUsedPipe = (decl) => decl.kind === compiler.R3TemplateDependencyKind.Pipe;
|
|
8814
8834
|
/**
|
|
8815
8835
|
* `DecoratorHandler` which handles the `@Component` annotation.
|
|
8816
8836
|
*/
|
|
@@ -8918,7 +8938,7 @@ class ComponentDecoratorHandler {
|
|
|
8918
8938
|
this.canDeferDeps = !enableHmr;
|
|
8919
8939
|
}
|
|
8920
8940
|
literalCache = new Map();
|
|
8921
|
-
elementSchemaRegistry = new
|
|
8941
|
+
elementSchemaRegistry = new compiler.DomElementSchemaRegistry();
|
|
8922
8942
|
/**
|
|
8923
8943
|
* During the asynchronous preanalyze phase, it's necessary to parse the template to extract
|
|
8924
8944
|
* any potential <link> tags which might need to be loaded. This cache ensures that work is not
|
|
@@ -9053,19 +9073,19 @@ class ComponentDecoratorHandler {
|
|
|
9053
9073
|
const encapsulation = (this.compilationMode !== checker.CompilationMode.LOCAL
|
|
9054
9074
|
? resolveEnumValue(this.evaluator, component, 'encapsulation', 'ViewEncapsulation', this.isCore)
|
|
9055
9075
|
: resolveEncapsulationEnumValueLocally(component.get('encapsulation'))) ??
|
|
9056
|
-
|
|
9076
|
+
compiler.ViewEncapsulation.Emulated;
|
|
9057
9077
|
let changeDetection = null;
|
|
9058
9078
|
if (this.compilationMode !== checker.CompilationMode.LOCAL) {
|
|
9059
9079
|
changeDetection = resolveEnumValue(this.evaluator, component, 'changeDetection', 'ChangeDetectionStrategy', this.isCore);
|
|
9060
9080
|
}
|
|
9061
9081
|
else if (component.has('changeDetection')) {
|
|
9062
|
-
changeDetection = new
|
|
9082
|
+
changeDetection = new compiler.WrappedNodeExpr(component.get('changeDetection'));
|
|
9063
9083
|
}
|
|
9064
9084
|
let animations = null;
|
|
9065
9085
|
let animationTriggerNames = null;
|
|
9066
9086
|
if (component.has('animations')) {
|
|
9067
9087
|
const animationExpression = component.get('animations');
|
|
9068
|
-
animations = new
|
|
9088
|
+
animations = new compiler.WrappedNodeExpr(animationExpression);
|
|
9069
9089
|
const animationsValue = this.evaluator.evaluate(animationExpression, animationTriggerResolver);
|
|
9070
9090
|
animationTriggerNames = { includesDynamicAnimations: false, staticTriggerNames: [] };
|
|
9071
9091
|
collectAnimationNames(animationsValue, animationTriggerNames);
|
|
@@ -9090,7 +9110,7 @@ class ComponentDecoratorHandler {
|
|
|
9090
9110
|
if (component.has('viewProviders')) {
|
|
9091
9111
|
const viewProviders = component.get('viewProviders');
|
|
9092
9112
|
viewProvidersRequiringFactory = checker.resolveProvidersRequiringFactory(viewProviders, this.reflector, this.evaluator);
|
|
9093
|
-
wrappedViewProviders = new
|
|
9113
|
+
wrappedViewProviders = new compiler.WrappedNodeExpr(this.annotateForClosureCompiler
|
|
9094
9114
|
? checker.wrapFunctionExpressionsInParens(viewProviders)
|
|
9095
9115
|
: viewProviders);
|
|
9096
9116
|
}
|
|
@@ -9268,7 +9288,7 @@ class ComponentDecoratorHandler {
|
|
|
9268
9288
|
diagnostics.push(makeResourceNotFoundError(styleUrl.url, styleUrl.expression, resourceType).toDiagnostic());
|
|
9269
9289
|
}
|
|
9270
9290
|
}
|
|
9271
|
-
if (encapsulation ===
|
|
9291
|
+
if (encapsulation === compiler.ViewEncapsulation.ShadowDom && metadata.selector !== null) {
|
|
9272
9292
|
const selectorError = checkCustomElementSelectorForErrors(metadata.selector);
|
|
9273
9293
|
if (selectorError !== null) {
|
|
9274
9294
|
if (diagnostics === undefined) {
|
|
@@ -9341,7 +9361,7 @@ class ComponentDecoratorHandler {
|
|
|
9341
9361
|
template,
|
|
9342
9362
|
encapsulation,
|
|
9343
9363
|
changeDetection,
|
|
9344
|
-
interpolation: template.interpolationConfig ??
|
|
9364
|
+
interpolation: template.interpolationConfig ?? compiler.DEFAULT_INTERPOLATION_CONFIG,
|
|
9345
9365
|
styles,
|
|
9346
9366
|
externalStyles,
|
|
9347
9367
|
// These will be replaced during the compilation step, after all `NgModule`s have been
|
|
@@ -9350,7 +9370,7 @@ class ComponentDecoratorHandler {
|
|
|
9350
9370
|
viewProviders: wrappedViewProviders,
|
|
9351
9371
|
i18nUseExternalIds: this.i18nUseExternalIds,
|
|
9352
9372
|
relativeContextFilePath,
|
|
9353
|
-
rawImports: rawImports !== null ? new
|
|
9373
|
+
rawImports: rawImports !== null ? new compiler.WrappedNodeExpr(rawImports) : undefined,
|
|
9354
9374
|
relativeTemplatePath,
|
|
9355
9375
|
},
|
|
9356
9376
|
typeCheckMeta: checker.extractDirectiveTypeCheckMeta(node, inputs, this.reflector),
|
|
@@ -9433,7 +9453,7 @@ class ComponentDecoratorHandler {
|
|
|
9433
9453
|
}
|
|
9434
9454
|
const scope = this.scopeReader.getScopeForComponent(node);
|
|
9435
9455
|
const selector = analysis.meta.selector;
|
|
9436
|
-
const matcher = new
|
|
9456
|
+
const matcher = new compiler.SelectorMatcher();
|
|
9437
9457
|
if (scope !== null) {
|
|
9438
9458
|
let { dependencies, isPoisoned } = scope.kind === checker.ComponentScopeKind.NgModule ? scope.compilation : scope;
|
|
9439
9459
|
if ((isPoisoned || (scope.kind === checker.ComponentScopeKind.NgModule && scope.exported.isPoisoned)) &&
|
|
@@ -9444,14 +9464,14 @@ class ComponentDecoratorHandler {
|
|
|
9444
9464
|
}
|
|
9445
9465
|
for (const dep of dependencies) {
|
|
9446
9466
|
if (dep.kind === checker.MetaKind.Directive && dep.selector !== null) {
|
|
9447
|
-
matcher.addSelectables(
|
|
9467
|
+
matcher.addSelectables(compiler.CssSelector.parse(dep.selector), [
|
|
9448
9468
|
...this.hostDirectivesResolver.resolve(dep),
|
|
9449
9469
|
dep,
|
|
9450
9470
|
]);
|
|
9451
9471
|
}
|
|
9452
9472
|
}
|
|
9453
9473
|
}
|
|
9454
|
-
const binder = new
|
|
9474
|
+
const binder = new compiler.R3TargetBinder(matcher);
|
|
9455
9475
|
const boundTemplate = binder.bind({ template: analysis.template.diagNodes });
|
|
9456
9476
|
context.addComponent({
|
|
9457
9477
|
declaration: node,
|
|
@@ -9473,7 +9493,7 @@ class ComponentDecoratorHandler {
|
|
|
9473
9493
|
// Don't type-check components that had errors in their scopes, unless requested.
|
|
9474
9494
|
return;
|
|
9475
9495
|
}
|
|
9476
|
-
const binder = new
|
|
9496
|
+
const binder = new compiler.R3TargetBinder(scope.matcher);
|
|
9477
9497
|
const templateContext = {
|
|
9478
9498
|
nodes: meta.template.diagNodes,
|
|
9479
9499
|
pipes: scope.pipes,
|
|
@@ -9597,18 +9617,23 @@ class ComponentDecoratorHandler {
|
|
|
9597
9617
|
diagnostics.push(diagnostic);
|
|
9598
9618
|
}
|
|
9599
9619
|
}
|
|
9600
|
-
// Set up the R3TargetBinder
|
|
9601
|
-
// later fed to the TemplateDefinitionBuilder.
|
|
9620
|
+
// Set up the R3TargetBinder.
|
|
9602
9621
|
const binder = createTargetBinder(dependencies);
|
|
9603
|
-
const pipes = extractPipes(dependencies);
|
|
9604
9622
|
let allDependencies = dependencies;
|
|
9605
9623
|
let deferBlockBinder = binder;
|
|
9606
9624
|
// If there are any explicitly deferred dependencies (via `@Component.deferredImports`),
|
|
9607
|
-
// re-compute the list of dependencies and create a new binder for defer blocks.
|
|
9625
|
+
// re-compute the list of dependencies and create a new binder for defer blocks. This
|
|
9626
|
+
// is because we have deferred dependencies that are not in the standard imports list
|
|
9627
|
+
// and need to be referenced later when determining what dependencies need to be in a
|
|
9628
|
+
// defer function / instruction call. Otherwise they end up treated as a standard
|
|
9629
|
+
// import, which is wrong.
|
|
9608
9630
|
if (explicitlyDeferredDependencies.length > 0) {
|
|
9609
9631
|
allDependencies = [...explicitlyDeferredDependencies, ...dependencies];
|
|
9610
9632
|
deferBlockBinder = createTargetBinder(allDependencies);
|
|
9611
9633
|
}
|
|
9634
|
+
// Set up the pipes map that is later used to determine which dependencies are used in
|
|
9635
|
+
// the template.
|
|
9636
|
+
const pipes = extractPipes(allDependencies);
|
|
9612
9637
|
// Next, the component template AST is bound using the R3TargetBinder. This produces a
|
|
9613
9638
|
// BoundTarget, which is similar to a ts.TypeChecker.
|
|
9614
9639
|
const bound = binder.bind({ template: metadata.template.nodes });
|
|
@@ -9651,10 +9676,10 @@ class ComponentDecoratorHandler {
|
|
|
9651
9676
|
// including all defer blocks.
|
|
9652
9677
|
const wholeTemplateUsed = new Set(eagerlyUsed);
|
|
9653
9678
|
for (const bound of deferBlocks.values()) {
|
|
9654
|
-
for (const dir of bound.
|
|
9679
|
+
for (const dir of bound.getUsedDirectives()) {
|
|
9655
9680
|
wholeTemplateUsed.add(dir.ref.node);
|
|
9656
9681
|
}
|
|
9657
|
-
for (const name of bound.
|
|
9682
|
+
for (const name of bound.getUsedPipes()) {
|
|
9658
9683
|
if (!pipes.has(name)) {
|
|
9659
9684
|
continue;
|
|
9660
9685
|
}
|
|
@@ -9676,7 +9701,7 @@ class ComponentDecoratorHandler {
|
|
|
9676
9701
|
const dirType = this.refEmitter.emit(dep.ref, context);
|
|
9677
9702
|
checker.assertSuccessfulReferenceEmit(dirType, node.name, dep.isComponent ? 'component' : 'directive');
|
|
9678
9703
|
declarations.set(dep.ref.node, {
|
|
9679
|
-
kind:
|
|
9704
|
+
kind: compiler.R3TemplateDependencyKind.Directive,
|
|
9680
9705
|
ref: dep.ref,
|
|
9681
9706
|
type: dirType.expression,
|
|
9682
9707
|
importedFile: dirType.importedFile,
|
|
@@ -9694,7 +9719,7 @@ class ComponentDecoratorHandler {
|
|
|
9694
9719
|
const pipeType = this.refEmitter.emit(dep.ref, context);
|
|
9695
9720
|
checker.assertSuccessfulReferenceEmit(pipeType, node.name, 'pipe');
|
|
9696
9721
|
declarations.set(dep.ref.node, {
|
|
9697
|
-
kind:
|
|
9722
|
+
kind: compiler.R3TemplateDependencyKind.Pipe,
|
|
9698
9723
|
type: pipeType.expression,
|
|
9699
9724
|
name: dep.name,
|
|
9700
9725
|
ref: dep.ref,
|
|
@@ -9705,7 +9730,7 @@ class ComponentDecoratorHandler {
|
|
|
9705
9730
|
const ngModuleType = this.refEmitter.emit(dep.ref, context);
|
|
9706
9731
|
checker.assertSuccessfulReferenceEmit(ngModuleType, node.name, 'NgModule');
|
|
9707
9732
|
declarations.set(dep.ref.node, {
|
|
9708
|
-
kind:
|
|
9733
|
+
kind: compiler.R3TemplateDependencyKind.NgModule,
|
|
9709
9734
|
type: ngModuleType.expression,
|
|
9710
9735
|
importedFile: ngModuleType.importedFile,
|
|
9711
9736
|
});
|
|
@@ -9721,7 +9746,7 @@ class ComponentDecoratorHandler {
|
|
|
9721
9746
|
.filter(isUsedPipe)
|
|
9722
9747
|
.map(getSemanticReference);
|
|
9723
9748
|
}
|
|
9724
|
-
const eagerDeclarations = Array.from(declarations.values()).filter((decl) => decl.kind ===
|
|
9749
|
+
const eagerDeclarations = Array.from(declarations.values()).filter((decl) => decl.kind === compiler.R3TemplateDependencyKind.NgModule || eagerlyUsed.has(decl.ref.node));
|
|
9725
9750
|
// Process information related to defer blocks
|
|
9726
9751
|
if (this.compilationMode !== checker.CompilationMode.LOCAL) {
|
|
9727
9752
|
this.resolveDeferBlocks(node, deferBlocks, declarations, data, analysis, eagerlyUsed);
|
|
@@ -9738,10 +9763,10 @@ class ComponentDecoratorHandler {
|
|
|
9738
9763
|
const cycle = this._checkForCyclicImport(usedDep.importedFile, usedDep.type, context);
|
|
9739
9764
|
if (cycle !== null) {
|
|
9740
9765
|
switch (usedDep.kind) {
|
|
9741
|
-
case
|
|
9766
|
+
case compiler.R3TemplateDependencyKind.Directive:
|
|
9742
9767
|
cyclesFromDirectives.set(usedDep, cycle);
|
|
9743
9768
|
break;
|
|
9744
|
-
case
|
|
9769
|
+
case compiler.R3TemplateDependencyKind.Pipe:
|
|
9745
9770
|
cyclesFromPipes.set(usedDep, cycle);
|
|
9746
9771
|
break;
|
|
9747
9772
|
}
|
|
@@ -9782,7 +9807,7 @@ class ComponentDecoratorHandler {
|
|
|
9782
9807
|
// best-guess extra imports globally to all files using
|
|
9783
9808
|
// `localCompilationExtraImportsTracker.addGlobalImportFromIdentifier`.
|
|
9784
9809
|
for (const { type } of eagerDeclarations) {
|
|
9785
|
-
if (type instanceof
|
|
9810
|
+
if (type instanceof compiler.ExternalExpr && type.value.moduleName) {
|
|
9786
9811
|
this.localCompilationExtraImportsTracker.addImportForFile(context, type.value.moduleName);
|
|
9787
9812
|
}
|
|
9788
9813
|
}
|
|
@@ -9839,12 +9864,12 @@ class ComponentDecoratorHandler {
|
|
|
9839
9864
|
diagnostics.push(...importDiagnostics);
|
|
9840
9865
|
}
|
|
9841
9866
|
if (analysis.providersRequiringFactory !== null &&
|
|
9842
|
-
analysis.meta.providers instanceof
|
|
9867
|
+
analysis.meta.providers instanceof compiler.WrappedNodeExpr) {
|
|
9843
9868
|
const providerDiagnostics = checker.getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
|
|
9844
9869
|
diagnostics.push(...providerDiagnostics);
|
|
9845
9870
|
}
|
|
9846
9871
|
if (analysis.viewProvidersRequiringFactory !== null &&
|
|
9847
|
-
analysis.meta.viewProviders instanceof
|
|
9872
|
+
analysis.meta.viewProviders instanceof compiler.WrappedNodeExpr) {
|
|
9848
9873
|
const viewProviderDiagnostics = checker.getProviderDiagnostics(analysis.viewProvidersRequiringFactory, analysis.meta.viewProviders.node, this.injectableRegistry);
|
|
9849
9874
|
diagnostics.push(...viewProviderDiagnostics);
|
|
9850
9875
|
}
|
|
@@ -9865,7 +9890,7 @@ class ComponentDecoratorHandler {
|
|
|
9865
9890
|
return { data };
|
|
9866
9891
|
}
|
|
9867
9892
|
xi18n(ctx, node, analysis) {
|
|
9868
|
-
ctx.updateFromTemplate(analysis.template.content, analysis.template.declaration.resolvedTemplateUrl, analysis.template.interpolationConfig ??
|
|
9893
|
+
ctx.updateFromTemplate(analysis.template.content, analysis.template.declaration.resolvedTemplateUrl, analysis.template.interpolationConfig ?? compiler.DEFAULT_INTERPOLATION_CONFIG);
|
|
9869
9894
|
}
|
|
9870
9895
|
updateResources(node, analysis) {
|
|
9871
9896
|
const containingFile = node.getSourceFile().fileName;
|
|
@@ -9914,11 +9939,11 @@ class ComponentDecoratorHandler {
|
|
|
9914
9939
|
...resolution,
|
|
9915
9940
|
defer,
|
|
9916
9941
|
};
|
|
9917
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta,
|
|
9942
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, compiler.FactoryTarget.Component));
|
|
9918
9943
|
if (perComponentDeferredDeps !== null) {
|
|
9919
9944
|
removeDeferrableTypesFromComponentDecorator(analysis, perComponentDeferredDeps);
|
|
9920
9945
|
}
|
|
9921
|
-
const def =
|
|
9946
|
+
const def = compiler.compileComponentFromMetadata(meta, pool, compiler.makeBindingParser());
|
|
9922
9947
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
9923
9948
|
const classMetadata = analysis.classMetadata !== null
|
|
9924
9949
|
? compileComponentClassMetadata(analysis.classMetadata, perComponentDeferredDeps).toStmt()
|
|
@@ -9944,7 +9969,7 @@ class ComponentDecoratorHandler {
|
|
|
9944
9969
|
sourceUrl: analysis.template.declaration.resolvedTemplateUrl,
|
|
9945
9970
|
isInline: analysis.template.declaration.isInline,
|
|
9946
9971
|
inlineTemplateLiteralExpression: analysis.template.sourceMapping.type === 'direct'
|
|
9947
|
-
? new
|
|
9972
|
+
? new compiler.WrappedNodeExpr(analysis.template.sourceMapping.node)
|
|
9948
9973
|
: null,
|
|
9949
9974
|
};
|
|
9950
9975
|
const perComponentDeferredDeps = this.canDeferDeps
|
|
@@ -9956,7 +9981,7 @@ class ComponentDecoratorHandler {
|
|
|
9956
9981
|
...resolution,
|
|
9957
9982
|
defer,
|
|
9958
9983
|
};
|
|
9959
|
-
const fac = compileDeclareFactory(checker.toFactoryMetadata(meta,
|
|
9984
|
+
const fac = compileDeclareFactory(checker.toFactoryMetadata(meta, compiler.FactoryTarget.Component));
|
|
9960
9985
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
9961
9986
|
const def = compileDeclareComponentFromMetadata(meta, analysis.template, templateInfo);
|
|
9962
9987
|
const classMetadata = analysis.classMetadata !== null
|
|
@@ -9985,8 +10010,8 @@ class ComponentDecoratorHandler {
|
|
|
9985
10010
|
if (deferrableTypes !== null) {
|
|
9986
10011
|
removeDeferrableTypesFromComponentDecorator(analysis, deferrableTypes);
|
|
9987
10012
|
}
|
|
9988
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta,
|
|
9989
|
-
const def =
|
|
10013
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, compiler.FactoryTarget.Component));
|
|
10014
|
+
const def = compiler.compileComponentFromMetadata(meta, pool, compiler.makeBindingParser());
|
|
9990
10015
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
9991
10016
|
const classMetadata = analysis.classMetadata !== null
|
|
9992
10017
|
? compileComponentClassMetadata(analysis.classMetadata, deferrableTypes).toStmt()
|
|
@@ -10008,15 +10033,15 @@ class ComponentDecoratorHandler {
|
|
|
10008
10033
|
return null;
|
|
10009
10034
|
}
|
|
10010
10035
|
// Create a brand-new constant pool since there shouldn't be any constant sharing.
|
|
10011
|
-
const pool = new
|
|
10036
|
+
const pool = new compiler.ConstantPool();
|
|
10012
10037
|
const defer = this.compileDeferBlocks(resolution);
|
|
10013
10038
|
const meta = {
|
|
10014
10039
|
...analysis.meta,
|
|
10015
10040
|
...resolution,
|
|
10016
10041
|
defer,
|
|
10017
10042
|
};
|
|
10018
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta,
|
|
10019
|
-
const def =
|
|
10043
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, compiler.FactoryTarget.Component));
|
|
10044
|
+
const def = compiler.compileComponentFromMetadata(meta, pool, compiler.makeBindingParser());
|
|
10020
10045
|
const classMetadata = analysis.classMetadata !== null
|
|
10021
10046
|
? compileComponentClassMetadata(analysis.classMetadata, null).toStmt()
|
|
10022
10047
|
: null;
|
|
@@ -10037,7 +10062,7 @@ class ComponentDecoratorHandler {
|
|
|
10037
10062
|
*/
|
|
10038
10063
|
locateDeferBlocksWithoutScope(template) {
|
|
10039
10064
|
const deferBlocks = new Map();
|
|
10040
|
-
const directivelessBinder = new
|
|
10065
|
+
const directivelessBinder = new compiler.R3TargetBinder(new compiler.SelectorMatcher());
|
|
10041
10066
|
const bound = directivelessBinder.bind({ template: template.nodes });
|
|
10042
10067
|
const deferredBlocks = bound.getDeferBlocks();
|
|
10043
10068
|
for (const block of deferredBlocks) {
|
|
@@ -10140,14 +10165,14 @@ class ComponentDecoratorHandler {
|
|
|
10140
10165
|
resolutionData.deferPerBlockDependencies.set(deferBlock, deps);
|
|
10141
10166
|
}
|
|
10142
10167
|
for (const decl of Array.from(deferrableDecls.values())) {
|
|
10143
|
-
if (decl.kind ===
|
|
10168
|
+
if (decl.kind === compiler.R3TemplateDependencyKind.NgModule) {
|
|
10144
10169
|
continue;
|
|
10145
10170
|
}
|
|
10146
|
-
if (decl.kind ===
|
|
10171
|
+
if (decl.kind === compiler.R3TemplateDependencyKind.Directive &&
|
|
10147
10172
|
!usedDirectives.has(decl.ref.node)) {
|
|
10148
10173
|
continue;
|
|
10149
10174
|
}
|
|
10150
|
-
if (decl.kind ===
|
|
10175
|
+
if (decl.kind === compiler.R3TemplateDependencyKind.Pipe && !usedPipes.has(decl.name)) {
|
|
10151
10176
|
continue;
|
|
10152
10177
|
}
|
|
10153
10178
|
// Collect initial information about this dependency.
|
|
@@ -10242,7 +10267,7 @@ class ComponentDecoratorHandler {
|
|
|
10242
10267
|
}
|
|
10243
10268
|
const blocks = new Map();
|
|
10244
10269
|
for (const [block, dependencies] of perBlockDeps) {
|
|
10245
|
-
blocks.set(block, dependencies.length === 0 ? null :
|
|
10270
|
+
blocks.set(block, dependencies.length === 0 ? null : compiler.compileDeferResolverFunction({ mode, dependencies }));
|
|
10246
10271
|
}
|
|
10247
10272
|
return { mode, blocks };
|
|
10248
10273
|
}
|
|
@@ -10254,7 +10279,7 @@ class ComponentDecoratorHandler {
|
|
|
10254
10279
|
mode,
|
|
10255
10280
|
dependenciesFn: perComponentDeps.length === 0
|
|
10256
10281
|
? null
|
|
10257
|
-
:
|
|
10282
|
+
: compiler.compileDeferResolverFunction({ mode, dependencies: perComponentDeps }),
|
|
10258
10283
|
};
|
|
10259
10284
|
}
|
|
10260
10285
|
throw new Error(`Invalid deferBlockDepsEmitMode. Cannot compile deferred block metadata.`);
|
|
@@ -10264,13 +10289,13 @@ class ComponentDecoratorHandler {
|
|
|
10264
10289
|
* Creates an instance of a target binder based on provided dependencies.
|
|
10265
10290
|
*/
|
|
10266
10291
|
function createTargetBinder(dependencies) {
|
|
10267
|
-
const matcher = new
|
|
10292
|
+
const matcher = new compiler.SelectorMatcher();
|
|
10268
10293
|
for (const dep of dependencies) {
|
|
10269
10294
|
if (dep.kind === checker.MetaKind.Directive && dep.selector !== null) {
|
|
10270
|
-
matcher.addSelectables(
|
|
10295
|
+
matcher.addSelectables(compiler.CssSelector.parse(dep.selector), [dep]);
|
|
10271
10296
|
}
|
|
10272
10297
|
}
|
|
10273
|
-
return new
|
|
10298
|
+
return new compiler.R3TargetBinder(matcher);
|
|
10274
10299
|
}
|
|
10275
10300
|
/**
|
|
10276
10301
|
* Returns the list of dependencies from `@Component.deferredImports` if provided.
|
|
@@ -10297,7 +10322,7 @@ function removeDeferrableTypesFromComponentDecorator(analysis, deferrableTypes)
|
|
|
10297
10322
|
if (analysis.classMetadata) {
|
|
10298
10323
|
const deferrableSymbols = new Set(deferrableTypes.map((t) => t.symbolName));
|
|
10299
10324
|
const rewrittenDecoratorsNode = removeIdentifierReferences(analysis.classMetadata.decorators.node, deferrableSymbols);
|
|
10300
|
-
analysis.classMetadata.decorators = new
|
|
10325
|
+
analysis.classMetadata.decorators = new compiler.WrappedNodeExpr(rewrittenDecoratorsNode);
|
|
10301
10326
|
}
|
|
10302
10327
|
}
|
|
10303
10328
|
/**
|
|
@@ -10453,19 +10478,19 @@ class InjectableDecoratorHandler {
|
|
|
10453
10478
|
return {};
|
|
10454
10479
|
}
|
|
10455
10480
|
compileFull(node, analysis) {
|
|
10456
|
-
return this.compile(compileNgFactoryDefField, (meta) =>
|
|
10481
|
+
return this.compile(compileNgFactoryDefField, (meta) => compiler.compileInjectable(meta, false), compileClassMetadata, node, analysis);
|
|
10457
10482
|
}
|
|
10458
10483
|
compilePartial(node, analysis) {
|
|
10459
10484
|
return this.compile(compileDeclareFactory, compileDeclareInjectableFromMetadata, compileDeclareClassMetadata, node, analysis);
|
|
10460
10485
|
}
|
|
10461
10486
|
compileLocal(node, analysis) {
|
|
10462
|
-
return this.compile(compileNgFactoryDefField, (meta) =>
|
|
10487
|
+
return this.compile(compileNgFactoryDefField, (meta) => compiler.compileInjectable(meta, false), compileClassMetadata, node, analysis);
|
|
10463
10488
|
}
|
|
10464
10489
|
compile(compileFactoryFn, compileInjectableFn, compileClassMetadataFn, node, analysis) {
|
|
10465
10490
|
const results = [];
|
|
10466
10491
|
if (analysis.needsFactory) {
|
|
10467
10492
|
const meta = analysis.meta;
|
|
10468
|
-
const factoryRes = compileFactoryFn(checker.toFactoryMetadata({ ...meta, deps: analysis.ctorDeps },
|
|
10493
|
+
const factoryRes = compileFactoryFn(checker.toFactoryMetadata({ ...meta, deps: analysis.ctorDeps }, compiler.FactoryTarget.Injectable));
|
|
10469
10494
|
if (analysis.classMetadata !== null) {
|
|
10470
10495
|
factoryRes.statements.push(compileClassMetadataFn(analysis.classMetadata).toStmt());
|
|
10471
10496
|
}
|
|
@@ -10507,7 +10532,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10507
10532
|
name,
|
|
10508
10533
|
type,
|
|
10509
10534
|
typeArgumentCount,
|
|
10510
|
-
providedIn:
|
|
10535
|
+
providedIn: compiler.createMayBeForwardRefExpression(new compiler.LiteralExpr(null), 0 /* ForwardRefHandling.None */),
|
|
10511
10536
|
};
|
|
10512
10537
|
}
|
|
10513
10538
|
else if (decorator.args.length === 1) {
|
|
@@ -10522,7 +10547,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10522
10547
|
const meta = checker.reflectObjectLiteral(metaNode);
|
|
10523
10548
|
const providedIn = meta.has('providedIn')
|
|
10524
10549
|
? getProviderExpression(meta.get('providedIn'), reflector)
|
|
10525
|
-
:
|
|
10550
|
+
: compiler.createMayBeForwardRefExpression(new compiler.LiteralExpr(null), 0 /* ForwardRefHandling.None */);
|
|
10526
10551
|
let deps = undefined;
|
|
10527
10552
|
if ((meta.has('useClass') || meta.has('useFactory')) && meta.has('deps')) {
|
|
10528
10553
|
const depsExpr = meta.get('deps');
|
|
@@ -10543,7 +10568,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10543
10568
|
result.deps = deps;
|
|
10544
10569
|
}
|
|
10545
10570
|
else if (meta.has('useFactory')) {
|
|
10546
|
-
result.useFactory = new
|
|
10571
|
+
result.useFactory = new compiler.WrappedNodeExpr(meta.get('useFactory'));
|
|
10547
10572
|
result.deps = deps;
|
|
10548
10573
|
}
|
|
10549
10574
|
return result;
|
|
@@ -10561,7 +10586,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10561
10586
|
*/
|
|
10562
10587
|
function getProviderExpression(expression, reflector) {
|
|
10563
10588
|
const forwardRefValue = checker.tryUnwrapForwardRef(expression, reflector);
|
|
10564
|
-
return
|
|
10589
|
+
return compiler.createMayBeForwardRefExpression(new compiler.WrappedNodeExpr(forwardRefValue ?? expression), forwardRefValue !== null ? 2 /* ForwardRefHandling.Unwrapped */ : 0 /* ForwardRefHandling.None */);
|
|
10565
10590
|
}
|
|
10566
10591
|
function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps) {
|
|
10567
10592
|
if (decorator.args === null) {
|
|
@@ -10606,7 +10631,7 @@ function requiresValidCtor(meta) {
|
|
|
10606
10631
|
}
|
|
10607
10632
|
function getDep(dep, reflector) {
|
|
10608
10633
|
const meta = {
|
|
10609
|
-
token: new
|
|
10634
|
+
token: new compiler.WrappedNodeExpr(dep),
|
|
10610
10635
|
attributeNameType: null,
|
|
10611
10636
|
host: false,
|
|
10612
10637
|
optional: false,
|
|
@@ -10621,7 +10646,7 @@ function getDep(dep, reflector) {
|
|
|
10621
10646
|
switch (source.name) {
|
|
10622
10647
|
case 'Inject':
|
|
10623
10648
|
if (token !== undefined) {
|
|
10624
|
-
meta.token = new
|
|
10649
|
+
meta.token = new compiler.WrappedNodeExpr(token);
|
|
10625
10650
|
}
|
|
10626
10651
|
break;
|
|
10627
10652
|
case 'Optional':
|
|
@@ -10649,7 +10674,7 @@ function getDep(dep, reflector) {
|
|
|
10649
10674
|
isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
|
|
10650
10675
|
}
|
|
10651
10676
|
if (!isDecorator) {
|
|
10652
|
-
meta.token = new
|
|
10677
|
+
meta.token = new compiler.WrappedNodeExpr(el);
|
|
10653
10678
|
}
|
|
10654
10679
|
});
|
|
10655
10680
|
}
|
|
@@ -10815,15 +10840,15 @@ class PipeDecoratorHandler {
|
|
|
10815
10840
|
return {};
|
|
10816
10841
|
}
|
|
10817
10842
|
compileFull(node, analysis) {
|
|
10818
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
10819
|
-
const def =
|
|
10843
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Pipe));
|
|
10844
|
+
const def = compiler.compilePipeFromMetadata(analysis.meta);
|
|
10820
10845
|
const classMetadata = analysis.classMetadata !== null
|
|
10821
10846
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
10822
10847
|
: null;
|
|
10823
10848
|
return checker.compileResults(fac, def, classMetadata, 'ɵpipe', null, null /* deferrableImports */);
|
|
10824
10849
|
}
|
|
10825
10850
|
compilePartial(node, analysis) {
|
|
10826
|
-
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta,
|
|
10851
|
+
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Pipe));
|
|
10827
10852
|
const def = compileDeclarePipeFromMetadata(analysis.meta);
|
|
10828
10853
|
const classMetadata = analysis.classMetadata !== null
|
|
10829
10854
|
? compileDeclareClassMetadata(analysis.classMetadata).toStmt()
|
|
@@ -10831,8 +10856,8 @@ class PipeDecoratorHandler {
|
|
|
10831
10856
|
return checker.compileResults(fac, def, classMetadata, 'ɵpipe', null, null /* deferrableImports */);
|
|
10832
10857
|
}
|
|
10833
10858
|
compileLocal(node, analysis) {
|
|
10834
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
10835
|
-
const def =
|
|
10859
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Pipe));
|
|
10860
|
+
const def = compiler.compilePipeFromMetadata(analysis.meta);
|
|
10836
10861
|
const classMetadata = analysis.classMetadata !== null
|
|
10837
10862
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
10838
10863
|
: null;
|
|
@@ -10845,7 +10870,7 @@ class PipeDecoratorHandler {
|
|
|
10845
10870
|
* @description
|
|
10846
10871
|
* Entry point for all public APIs of the compiler-cli package.
|
|
10847
10872
|
*/
|
|
10848
|
-
new
|
|
10873
|
+
new compiler.Version('20.0.0-next.6');
|
|
10849
10874
|
|
|
10850
10875
|
/**
|
|
10851
10876
|
* Whether a given decorator should be treated as an Angular decorator.
|
|
@@ -11584,7 +11609,7 @@ function i18nSerialize(bundle, formatName, options) {
|
|
|
11584
11609
|
let serializer;
|
|
11585
11610
|
switch (format) {
|
|
11586
11611
|
case 'xmb':
|
|
11587
|
-
serializer = new
|
|
11612
|
+
serializer = new compiler.Xmb();
|
|
11588
11613
|
break;
|
|
11589
11614
|
case 'xliff2':
|
|
11590
11615
|
case 'xlf2':
|
|
@@ -13927,7 +13952,7 @@ class IndexingContext {
|
|
|
13927
13952
|
* Visiting `text {{prop}}` will return
|
|
13928
13953
|
* `[TopLevelIdentifier {name: 'prop', span: {start: 7, end: 11}}]`.
|
|
13929
13954
|
*/
|
|
13930
|
-
class ExpressionVisitor extends
|
|
13955
|
+
class ExpressionVisitor extends compiler.RecursiveAstVisitor {
|
|
13931
13956
|
expressionStr;
|
|
13932
13957
|
absoluteOffset;
|
|
13933
13958
|
boundTemplate;
|
|
@@ -13979,12 +14004,12 @@ class ExpressionVisitor extends checker.RecursiveAstVisitor {
|
|
|
13979
14004
|
// impossible to determine by an indexer and unsupported by the indexing module.
|
|
13980
14005
|
// The indexing module also does not currently support references to identifiers declared in the
|
|
13981
14006
|
// template itself, which have a non-null expression target.
|
|
13982
|
-
if (!(ast.receiver instanceof
|
|
14007
|
+
if (!(ast.receiver instanceof compiler.ImplicitReceiver)) {
|
|
13983
14008
|
return;
|
|
13984
14009
|
}
|
|
13985
14010
|
// The source span of the requested AST starts at a location that is offset from the expression.
|
|
13986
14011
|
let identifierStart = ast.sourceSpan.start - this.absoluteOffset;
|
|
13987
|
-
if (ast instanceof
|
|
14012
|
+
if (ast instanceof compiler.PropertyRead || ast instanceof compiler.PropertyWrite) {
|
|
13988
14013
|
// For `PropertyRead` and `PropertyWrite`, the identifier starts at the `nameSpan`, not
|
|
13989
14014
|
// necessarily the `sourceSpan`.
|
|
13990
14015
|
identifierStart = ast.nameSpan.start - this.absoluteOffset;
|
|
@@ -14012,7 +14037,7 @@ class ExpressionVisitor extends checker.RecursiveAstVisitor {
|
|
|
14012
14037
|
* Visits the AST of a parsed Angular template. Discovers and stores
|
|
14013
14038
|
* identifiers of interest, deferring to an `ExpressionVisitor` as needed.
|
|
14014
14039
|
*/
|
|
14015
|
-
let TemplateVisitor$1 = class TemplateVisitor extends
|
|
14040
|
+
let TemplateVisitor$1 = class TemplateVisitor extends compiler.RecursiveVisitor {
|
|
14016
14041
|
boundTemplate;
|
|
14017
14042
|
// Identifiers of interest found in the template.
|
|
14018
14043
|
identifiers = new Set();
|
|
@@ -14055,6 +14080,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14055
14080
|
this.visitAll(element.references);
|
|
14056
14081
|
this.visitAll(element.inputs);
|
|
14057
14082
|
this.visitAll(element.attributes);
|
|
14083
|
+
this.visitAll(element.directives);
|
|
14058
14084
|
this.visitAll(element.children);
|
|
14059
14085
|
this.visitAll(element.outputs);
|
|
14060
14086
|
}
|
|
@@ -14063,6 +14089,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14063
14089
|
if (templateIdentifier !== null) {
|
|
14064
14090
|
this.identifiers.add(templateIdentifier);
|
|
14065
14091
|
}
|
|
14092
|
+
this.visitAll(template.directives);
|
|
14066
14093
|
this.visitAll(template.variables);
|
|
14067
14094
|
this.visitAll(template.attributes);
|
|
14068
14095
|
this.visitAll(template.templateAttrs);
|
|
@@ -14111,7 +14138,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14111
14138
|
this.visitAll(block.children);
|
|
14112
14139
|
}
|
|
14113
14140
|
visitDeferredTrigger(trigger) {
|
|
14114
|
-
if (trigger instanceof
|
|
14141
|
+
if (trigger instanceof compiler.BoundDeferredTrigger) {
|
|
14115
14142
|
this.visitExpression(trigger.value);
|
|
14116
14143
|
}
|
|
14117
14144
|
}
|
|
@@ -14148,6 +14175,12 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14148
14175
|
}
|
|
14149
14176
|
this.visitExpression(decl.value);
|
|
14150
14177
|
}
|
|
14178
|
+
visitComponent(component) {
|
|
14179
|
+
throw new Error('TODO');
|
|
14180
|
+
}
|
|
14181
|
+
visitDirective(directive) {
|
|
14182
|
+
throw new Error('TODO');
|
|
14183
|
+
}
|
|
14151
14184
|
/** Creates an identifier for a template element or template node. */
|
|
14152
14185
|
elementOrTemplateToIdentifier(node) {
|
|
14153
14186
|
// If this node has already been seen, return the cached result.
|
|
@@ -14156,7 +14189,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14156
14189
|
}
|
|
14157
14190
|
let name;
|
|
14158
14191
|
let kind;
|
|
14159
|
-
if (node instanceof
|
|
14192
|
+
if (node instanceof compiler.Template) {
|
|
14160
14193
|
name = node.tagName ?? 'ng-template';
|
|
14161
14194
|
kind = IdentifierKind.Template;
|
|
14162
14195
|
}
|
|
@@ -14218,7 +14251,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14218
14251
|
}
|
|
14219
14252
|
const span = new AbsoluteSourceSpan(start, start + name.length);
|
|
14220
14253
|
let identifier;
|
|
14221
|
-
if (node instanceof
|
|
14254
|
+
if (node instanceof compiler.Reference) {
|
|
14222
14255
|
// If the node is a reference, we care about its target. The target can be an element, a
|
|
14223
14256
|
// template, a directive applied on a template or element (in which case the directive field
|
|
14224
14257
|
// is non-null), or nothing at all.
|
|
@@ -14227,7 +14260,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14227
14260
|
if (refTarget) {
|
|
14228
14261
|
let node = null;
|
|
14229
14262
|
let directive = null;
|
|
14230
|
-
if (refTarget instanceof
|
|
14263
|
+
if (refTarget instanceof compiler.Element || refTarget instanceof compiler.Template) {
|
|
14231
14264
|
node = this.elementOrTemplateToIdentifier(refTarget);
|
|
14232
14265
|
}
|
|
14233
14266
|
else {
|
|
@@ -14249,7 +14282,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14249
14282
|
target,
|
|
14250
14283
|
};
|
|
14251
14284
|
}
|
|
14252
|
-
else if (node instanceof
|
|
14285
|
+
else if (node instanceof compiler.Variable) {
|
|
14253
14286
|
identifier = {
|
|
14254
14287
|
name,
|
|
14255
14288
|
span,
|
|
@@ -14283,7 +14316,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14283
14316
|
*/
|
|
14284
14317
|
visitExpression(ast) {
|
|
14285
14318
|
// Only include ASTs that have information about their source and absolute source spans.
|
|
14286
|
-
if (ast instanceof
|
|
14319
|
+
if (ast instanceof compiler.ASTWithSource && ast.source !== null) {
|
|
14287
14320
|
// Make target to identifier mapping closure stateful to this visitor instance.
|
|
14288
14321
|
const targetToIdentifier = this.targetToIdentifier.bind(this);
|
|
14289
14322
|
const absoluteOffset = ast.sourceSpan.start;
|
|
@@ -14326,7 +14359,7 @@ function generateAnalysis(context) {
|
|
|
14326
14359
|
});
|
|
14327
14360
|
// Get source files for the component and the template. If the template is inline, its source
|
|
14328
14361
|
// file is the component's.
|
|
14329
|
-
const componentFile = new
|
|
14362
|
+
const componentFile = new compiler.ParseSourceFile(declaration.getSourceFile().getFullText(), declaration.getSourceFile().fileName);
|
|
14330
14363
|
let templateFile;
|
|
14331
14364
|
if (templateMeta.isInline) {
|
|
14332
14365
|
templateFile = componentFile;
|
|
@@ -14866,7 +14899,7 @@ class TemplateCheckWithVisitor {
|
|
|
14866
14899
|
/**
|
|
14867
14900
|
* Visits all nodes in a template (TmplAstNode and AST) and calls `visitNode` for each one.
|
|
14868
14901
|
*/
|
|
14869
|
-
class TemplateVisitor extends
|
|
14902
|
+
class TemplateVisitor extends compiler.RecursiveAstVisitor {
|
|
14870
14903
|
ctx;
|
|
14871
14904
|
component;
|
|
14872
14905
|
check;
|
|
@@ -14887,7 +14920,7 @@ class TemplateVisitor extends checker.RecursiveAstVisitor {
|
|
|
14887
14920
|
}
|
|
14888
14921
|
}
|
|
14889
14922
|
visitAst(ast) {
|
|
14890
|
-
if (ast instanceof
|
|
14923
|
+
if (ast instanceof compiler.ASTWithSource) {
|
|
14891
14924
|
ast = ast.ast;
|
|
14892
14925
|
}
|
|
14893
14926
|
this.visit(ast);
|
|
@@ -14896,6 +14929,7 @@ class TemplateVisitor extends checker.RecursiveAstVisitor {
|
|
|
14896
14929
|
this.visitAllNodes(element.attributes);
|
|
14897
14930
|
this.visitAllNodes(element.inputs);
|
|
14898
14931
|
this.visitAllNodes(element.outputs);
|
|
14932
|
+
this.visitAllNodes(element.directives);
|
|
14899
14933
|
this.visitAllNodes(element.references);
|
|
14900
14934
|
this.visitAllNodes(element.children);
|
|
14901
14935
|
}
|
|
@@ -14909,6 +14943,7 @@ class TemplateVisitor extends checker.RecursiveAstVisitor {
|
|
|
14909
14943
|
this.visitAllNodes(template.inputs);
|
|
14910
14944
|
this.visitAllNodes(template.outputs);
|
|
14911
14945
|
}
|
|
14946
|
+
this.visitAllNodes(template.directives);
|
|
14912
14947
|
// TODO(crisbeto): remove this condition when deleting `canVisitStructuralAttributes`.
|
|
14913
14948
|
if (this.check.canVisitStructuralAttributes || isInlineTemplate) {
|
|
14914
14949
|
// `templateAttrs` aren't transferred over to the inner element so we always have to visit them.
|
|
@@ -14943,7 +14978,7 @@ class TemplateVisitor extends checker.RecursiveAstVisitor {
|
|
|
14943
14978
|
deferred.visitAll(this);
|
|
14944
14979
|
}
|
|
14945
14980
|
visitDeferredTrigger(trigger) {
|
|
14946
|
-
if (trigger instanceof
|
|
14981
|
+
if (trigger instanceof compiler.BoundDeferredTrigger) {
|
|
14947
14982
|
this.visitAst(trigger.value);
|
|
14948
14983
|
}
|
|
14949
14984
|
}
|
|
@@ -14985,6 +15020,20 @@ class TemplateVisitor extends checker.RecursiveAstVisitor {
|
|
|
14985
15020
|
visitLetDeclaration(decl) {
|
|
14986
15021
|
this.visitAst(decl.value);
|
|
14987
15022
|
}
|
|
15023
|
+
visitComponent(component) {
|
|
15024
|
+
this.visitAllNodes(component.attributes);
|
|
15025
|
+
this.visitAllNodes(component.inputs);
|
|
15026
|
+
this.visitAllNodes(component.outputs);
|
|
15027
|
+
this.visitAllNodes(component.directives);
|
|
15028
|
+
this.visitAllNodes(component.references);
|
|
15029
|
+
this.visitAllNodes(component.children);
|
|
15030
|
+
}
|
|
15031
|
+
visitDirective(directive) {
|
|
15032
|
+
this.visitAllNodes(directive.attributes);
|
|
15033
|
+
this.visitAllNodes(directive.inputs);
|
|
15034
|
+
this.visitAllNodes(directive.outputs);
|
|
15035
|
+
this.visitAllNodes(directive.references);
|
|
15036
|
+
}
|
|
14988
15037
|
getDiagnostics(template) {
|
|
14989
15038
|
this.diagnostics = [];
|
|
14990
15039
|
this.visitAllNodes(template);
|
|
@@ -15006,13 +15055,13 @@ class InterpolatedSignalCheck extends TemplateCheckWithVisitor {
|
|
|
15006
15055
|
code = checker.ErrorCode.INTERPOLATED_SIGNAL_NOT_INVOKED;
|
|
15007
15056
|
visitNode(ctx, component, node) {
|
|
15008
15057
|
// interpolations like `{{ mySignal }}`
|
|
15009
|
-
if (node instanceof
|
|
15058
|
+
if (node instanceof compiler.Interpolation) {
|
|
15010
15059
|
return node.expressions
|
|
15011
|
-
.filter((item) => item instanceof
|
|
15060
|
+
.filter((item) => item instanceof compiler.PropertyRead)
|
|
15012
15061
|
.flatMap((item) => buildDiagnosticForSignal(ctx, item, component));
|
|
15013
15062
|
}
|
|
15014
15063
|
// bound properties like `[prop]="mySignal"`
|
|
15015
|
-
else if (node instanceof
|
|
15064
|
+
else if (node instanceof compiler.BoundAttribute) {
|
|
15016
15065
|
// we skip the check if the node is an input binding
|
|
15017
15066
|
const usedDirectives = ctx.templateTypeChecker.getUsedDirectives(component);
|
|
15018
15067
|
if (usedDirectives !== null &&
|
|
@@ -15022,17 +15071,17 @@ class InterpolatedSignalCheck extends TemplateCheckWithVisitor {
|
|
|
15022
15071
|
// otherwise, we check if the node is
|
|
15023
15072
|
if (
|
|
15024
15073
|
// a bound property like `[prop]="mySignal"`
|
|
15025
|
-
(node.type ===
|
|
15074
|
+
(node.type === compiler.BindingType.Property ||
|
|
15026
15075
|
// or a class binding like `[class.myClass]="mySignal"`
|
|
15027
|
-
node.type ===
|
|
15076
|
+
node.type === compiler.BindingType.Class ||
|
|
15028
15077
|
// or a style binding like `[style.width]="mySignal"`
|
|
15029
|
-
node.type ===
|
|
15078
|
+
node.type === compiler.BindingType.Style ||
|
|
15030
15079
|
// or an attribute binding like `[attr.role]="mySignal"`
|
|
15031
|
-
node.type ===
|
|
15080
|
+
node.type === compiler.BindingType.Attribute ||
|
|
15032
15081
|
// or an animation binding like `[@myAnimation]="mySignal"`
|
|
15033
|
-
node.type ===
|
|
15034
|
-
node.value instanceof
|
|
15035
|
-
node.value.ast instanceof
|
|
15082
|
+
node.type === compiler.BindingType.Animation) &&
|
|
15083
|
+
node.value instanceof compiler.ASTWithSource &&
|
|
15084
|
+
node.value.ast instanceof compiler.PropertyRead) {
|
|
15036
15085
|
return buildDiagnosticForSignal(ctx, node.value.ast, component);
|
|
15037
15086
|
}
|
|
15038
15087
|
}
|
|
@@ -15071,7 +15120,7 @@ function buildDiagnosticForSignal(ctx, node, component) {
|
|
|
15071
15120
|
}
|
|
15072
15121
|
return [];
|
|
15073
15122
|
}
|
|
15074
|
-
const factory$
|
|
15123
|
+
const factory$c = {
|
|
15075
15124
|
code: checker.ErrorCode.INTERPOLATED_SIGNAL_NOT_INVOKED,
|
|
15076
15125
|
name: checker.ExtendedTemplateDiagnosticName.INTERPOLATED_SIGNAL_NOT_INVOKED,
|
|
15077
15126
|
create: () => new InterpolatedSignalCheck(),
|
|
@@ -15085,7 +15134,7 @@ const factory$b = {
|
|
|
15085
15134
|
class InvalidBananaInBoxCheck extends TemplateCheckWithVisitor {
|
|
15086
15135
|
code = checker.ErrorCode.INVALID_BANANA_IN_BOX;
|
|
15087
15136
|
visitNode(ctx, component, node) {
|
|
15088
|
-
if (!(node instanceof
|
|
15137
|
+
if (!(node instanceof compiler.BoundEvent))
|
|
15089
15138
|
return [];
|
|
15090
15139
|
const name = node.name;
|
|
15091
15140
|
if (!name.startsWith('[') || !name.endsWith(']'))
|
|
@@ -15097,7 +15146,7 @@ class InvalidBananaInBoxCheck extends TemplateCheckWithVisitor {
|
|
|
15097
15146
|
return [diagnostic];
|
|
15098
15147
|
}
|
|
15099
15148
|
}
|
|
15100
|
-
const factory$
|
|
15149
|
+
const factory$b = {
|
|
15101
15150
|
code: checker.ErrorCode.INVALID_BANANA_IN_BOX,
|
|
15102
15151
|
name: checker.ExtendedTemplateDiagnosticName.INVALID_BANANA_IN_BOX,
|
|
15103
15152
|
create: () => new InvalidBananaInBoxCheck(),
|
|
@@ -15138,7 +15187,7 @@ class MissingControlFlowDirectiveCheck extends TemplateCheckWithVisitor {
|
|
|
15138
15187
|
return super.run(ctx, component, template);
|
|
15139
15188
|
}
|
|
15140
15189
|
visitNode(ctx, component, node) {
|
|
15141
|
-
if (!(node instanceof
|
|
15190
|
+
if (!(node instanceof compiler.Template))
|
|
15142
15191
|
return [];
|
|
15143
15192
|
const controlFlowAttr = node.templateAttrs.find((attr) => KNOWN_CONTROL_FLOW_DIRECTIVES.has(attr.name));
|
|
15144
15193
|
if (!controlFlowAttr)
|
|
@@ -15158,7 +15207,7 @@ class MissingControlFlowDirectiveCheck extends TemplateCheckWithVisitor {
|
|
|
15158
15207
|
return [diagnostic];
|
|
15159
15208
|
}
|
|
15160
15209
|
}
|
|
15161
|
-
const factory$
|
|
15210
|
+
const factory$a = {
|
|
15162
15211
|
code: checker.ErrorCode.MISSING_CONTROL_FLOW_DIRECTIVE,
|
|
15163
15212
|
name: checker.ExtendedTemplateDiagnosticName.MISSING_CONTROL_FLOW_DIRECTIVE,
|
|
15164
15213
|
create: (options) => {
|
|
@@ -15173,7 +15222,7 @@ const factory$9 = {
|
|
|
15173
15222
|
class MissingNgForOfLetCheck extends TemplateCheckWithVisitor {
|
|
15174
15223
|
code = checker.ErrorCode.MISSING_NGFOROF_LET;
|
|
15175
15224
|
visitNode(ctx, component, node) {
|
|
15176
|
-
if (!(node instanceof
|
|
15225
|
+
if (!(node instanceof compiler.Template)) {
|
|
15177
15226
|
return [];
|
|
15178
15227
|
}
|
|
15179
15228
|
if (node.templateAttrs.length === 0) {
|
|
@@ -15191,7 +15240,7 @@ class MissingNgForOfLetCheck extends TemplateCheckWithVisitor {
|
|
|
15191
15240
|
return [diagnostic];
|
|
15192
15241
|
}
|
|
15193
15242
|
}
|
|
15194
|
-
const factory$
|
|
15243
|
+
const factory$9 = {
|
|
15195
15244
|
code: checker.ErrorCode.MISSING_NGFOROF_LET,
|
|
15196
15245
|
name: checker.ExtendedTemplateDiagnosticName.MISSING_NGFOROF_LET,
|
|
15197
15246
|
create: () => new MissingNgForOfLetCheck(),
|
|
@@ -15207,7 +15256,7 @@ class NullishCoalescingNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15207
15256
|
canVisitStructuralAttributes = false;
|
|
15208
15257
|
code = checker.ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
|
|
15209
15258
|
visitNode(ctx, component, node) {
|
|
15210
|
-
if (!(node instanceof
|
|
15259
|
+
if (!(node instanceof compiler.Binary) || node.operation !== '??')
|
|
15211
15260
|
return [];
|
|
15212
15261
|
const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.left, component);
|
|
15213
15262
|
if (symbolLeft === null || symbolLeft.kind !== checker.SymbolKind.Expression) {
|
|
@@ -15236,7 +15285,7 @@ class NullishCoalescingNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15236
15285
|
return [diagnostic];
|
|
15237
15286
|
}
|
|
15238
15287
|
}
|
|
15239
|
-
const factory$
|
|
15288
|
+
const factory$8 = {
|
|
15240
15289
|
code: checker.ErrorCode.NULLISH_COALESCING_NOT_NULLABLE,
|
|
15241
15290
|
name: checker.ExtendedTemplateDiagnosticName.NULLISH_COALESCING_NOT_NULLABLE,
|
|
15242
15291
|
create: (options) => {
|
|
@@ -15259,9 +15308,9 @@ class OptionalChainNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15259
15308
|
canVisitStructuralAttributes = false;
|
|
15260
15309
|
code = checker.ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
|
|
15261
15310
|
visitNode(ctx, component, node) {
|
|
15262
|
-
if (!(node instanceof
|
|
15263
|
-
!(node instanceof
|
|
15264
|
-
!(node instanceof
|
|
15311
|
+
if (!(node instanceof compiler.SafeCall) &&
|
|
15312
|
+
!(node instanceof compiler.SafePropertyRead) &&
|
|
15313
|
+
!(node instanceof compiler.SafeKeyedRead))
|
|
15265
15314
|
return [];
|
|
15266
15315
|
const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.receiver, component);
|
|
15267
15316
|
if (symbolLeft === null || symbolLeft.kind !== checker.SymbolKind.Expression) {
|
|
@@ -15286,14 +15335,14 @@ class OptionalChainNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15286
15335
|
if (templateMapping === null) {
|
|
15287
15336
|
return [];
|
|
15288
15337
|
}
|
|
15289
|
-
const advice = node instanceof
|
|
15338
|
+
const advice = node instanceof compiler.SafePropertyRead
|
|
15290
15339
|
? `the '?.' operator can be replaced with the '.' operator`
|
|
15291
15340
|
: `the '?.' operator can be safely removed`;
|
|
15292
15341
|
const diagnostic = ctx.makeTemplateDiagnostic(templateMapping.span, `The left side of this optional chain operation does not include 'null' or 'undefined' in its type, therefore ${advice}.`);
|
|
15293
15342
|
return [diagnostic];
|
|
15294
15343
|
}
|
|
15295
15344
|
}
|
|
15296
|
-
const factory$
|
|
15345
|
+
const factory$7 = {
|
|
15297
15346
|
code: checker.ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE,
|
|
15298
15347
|
name: checker.ExtendedTemplateDiagnosticName.OPTIONAL_CHAIN_NOT_NULLABLE,
|
|
15299
15348
|
create: (options) => {
|
|
@@ -15315,14 +15364,14 @@ class NgSkipHydrationSpec extends TemplateCheckWithVisitor {
|
|
|
15315
15364
|
code = checker.ErrorCode.SKIP_HYDRATION_NOT_STATIC;
|
|
15316
15365
|
visitNode(ctx, component, node) {
|
|
15317
15366
|
/** Binding should always error */
|
|
15318
|
-
if (node instanceof
|
|
15367
|
+
if (node instanceof compiler.BoundAttribute && node.name === NG_SKIP_HYDRATION_ATTR_NAME) {
|
|
15319
15368
|
const errorString = `ngSkipHydration should not be used as a binding.`;
|
|
15320
15369
|
const diagnostic = ctx.makeTemplateDiagnostic(node.sourceSpan, errorString);
|
|
15321
15370
|
return [diagnostic];
|
|
15322
15371
|
}
|
|
15323
15372
|
/** No value, empty string or `"true"` are the only valid values */
|
|
15324
15373
|
const acceptedValues = ['true', '' /* empty string */];
|
|
15325
|
-
if (node instanceof
|
|
15374
|
+
if (node instanceof compiler.TextAttribute &&
|
|
15326
15375
|
node.name === NG_SKIP_HYDRATION_ATTR_NAME &&
|
|
15327
15376
|
!acceptedValues.includes(node.value) &&
|
|
15328
15377
|
node.value !== undefined) {
|
|
@@ -15333,7 +15382,7 @@ class NgSkipHydrationSpec extends TemplateCheckWithVisitor {
|
|
|
15333
15382
|
return [];
|
|
15334
15383
|
}
|
|
15335
15384
|
}
|
|
15336
|
-
const factory$
|
|
15385
|
+
const factory$6 = {
|
|
15337
15386
|
code: checker.ErrorCode.SKIP_HYDRATION_NOT_STATIC,
|
|
15338
15387
|
name: checker.ExtendedTemplateDiagnosticName.SKIP_HYDRATION_NOT_STATIC,
|
|
15339
15388
|
create: () => new NgSkipHydrationSpec(),
|
|
@@ -15347,7 +15396,7 @@ const STYLE_SUFFIXES = ['px', '%', 'em'];
|
|
|
15347
15396
|
class SuffixNotSupportedCheck extends TemplateCheckWithVisitor {
|
|
15348
15397
|
code = checker.ErrorCode.SUFFIX_NOT_SUPPORTED;
|
|
15349
15398
|
visitNode(ctx, component, node) {
|
|
15350
|
-
if (!(node instanceof
|
|
15399
|
+
if (!(node instanceof compiler.BoundAttribute))
|
|
15351
15400
|
return [];
|
|
15352
15401
|
if (!node.keySpan.toString().startsWith('attr.') ||
|
|
15353
15402
|
!STYLE_SUFFIXES.some((suffix) => node.name.endsWith(`.${suffix}`))) {
|
|
@@ -15357,7 +15406,7 @@ class SuffixNotSupportedCheck extends TemplateCheckWithVisitor {
|
|
|
15357
15406
|
return [diagnostic];
|
|
15358
15407
|
}
|
|
15359
15408
|
}
|
|
15360
|
-
const factory$
|
|
15409
|
+
const factory$5 = {
|
|
15361
15410
|
code: checker.ErrorCode.SUFFIX_NOT_SUPPORTED,
|
|
15362
15411
|
name: checker.ExtendedTemplateDiagnosticName.SUFFIX_NOT_SUPPORTED,
|
|
15363
15412
|
create: () => new SuffixNotSupportedCheck(),
|
|
@@ -15373,7 +15422,7 @@ const factory$4 = {
|
|
|
15373
15422
|
class TextAttributeNotBindingSpec extends TemplateCheckWithVisitor {
|
|
15374
15423
|
code = checker.ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING;
|
|
15375
15424
|
visitNode(ctx, component, node) {
|
|
15376
|
-
if (!(node instanceof
|
|
15425
|
+
if (!(node instanceof compiler.TextAttribute))
|
|
15377
15426
|
return [];
|
|
15378
15427
|
const name = node.name;
|
|
15379
15428
|
if (!name.startsWith('attr.') && !name.startsWith('style.') && !name.startsWith('class.')) {
|
|
@@ -15402,7 +15451,7 @@ class TextAttributeNotBindingSpec extends TemplateCheckWithVisitor {
|
|
|
15402
15451
|
return [diagnostic];
|
|
15403
15452
|
}
|
|
15404
15453
|
}
|
|
15405
|
-
const factory$
|
|
15454
|
+
const factory$4 = {
|
|
15406
15455
|
code: checker.ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING,
|
|
15407
15456
|
name: checker.ExtendedTemplateDiagnosticName.TEXT_ATTRIBUTE_NOT_BINDING,
|
|
15408
15457
|
create: () => new TextAttributeNotBindingSpec(),
|
|
@@ -15417,19 +15466,19 @@ class UninvokedFunctionInEventBindingSpec extends TemplateCheckWithVisitor {
|
|
|
15417
15466
|
code = checker.ErrorCode.UNINVOKED_FUNCTION_IN_EVENT_BINDING;
|
|
15418
15467
|
visitNode(ctx, component, node) {
|
|
15419
15468
|
// If the node is not a bound event, skip it.
|
|
15420
|
-
if (!(node instanceof
|
|
15469
|
+
if (!(node instanceof compiler.BoundEvent))
|
|
15421
15470
|
return [];
|
|
15422
15471
|
// If the node is not a regular or animation event, skip it.
|
|
15423
|
-
if (node.type !==
|
|
15472
|
+
if (node.type !== compiler.ParsedEventType.Regular && node.type !== compiler.ParsedEventType.Animation)
|
|
15424
15473
|
return [];
|
|
15425
|
-
if (!(node.handler instanceof
|
|
15474
|
+
if (!(node.handler instanceof compiler.ASTWithSource))
|
|
15426
15475
|
return [];
|
|
15427
15476
|
const sourceExpressionText = node.handler.source || '';
|
|
15428
|
-
if (node.handler.ast instanceof
|
|
15477
|
+
if (node.handler.ast instanceof compiler.Chain) {
|
|
15429
15478
|
// (click)="increment; decrement"
|
|
15430
15479
|
return node.handler.ast.expressions.flatMap((expression) => assertExpressionInvoked(expression, component, node, sourceExpressionText, ctx));
|
|
15431
15480
|
}
|
|
15432
|
-
if (node.handler.ast instanceof
|
|
15481
|
+
if (node.handler.ast instanceof compiler.Conditional) {
|
|
15433
15482
|
// (click)="true ? increment : decrement"
|
|
15434
15483
|
const { trueExp, falseExp } = node.handler.ast;
|
|
15435
15484
|
return [trueExp, falseExp].flatMap((expression) => assertExpressionInvoked(expression, component, node, sourceExpressionText, ctx));
|
|
@@ -15443,26 +15492,26 @@ class UninvokedFunctionInEventBindingSpec extends TemplateCheckWithVisitor {
|
|
|
15443
15492
|
* If the expression is a property read, and it has a call signature, a diagnostic is generated.
|
|
15444
15493
|
*/
|
|
15445
15494
|
function assertExpressionInvoked(expression, component, node, expressionText, ctx) {
|
|
15446
|
-
if (expression instanceof
|
|
15495
|
+
if (expression instanceof compiler.Call || expression instanceof compiler.SafeCall) {
|
|
15447
15496
|
return []; // If the method is called, skip it.
|
|
15448
15497
|
}
|
|
15449
|
-
if (!(expression instanceof
|
|
15498
|
+
if (!(expression instanceof compiler.PropertyRead) && !(expression instanceof compiler.SafePropertyRead)) {
|
|
15450
15499
|
return []; // If the expression is not a property read, skip it.
|
|
15451
15500
|
}
|
|
15452
15501
|
const symbol = ctx.templateTypeChecker.getSymbolOfNode(expression, component);
|
|
15453
15502
|
if (symbol !== null && symbol.kind === checker.SymbolKind.Expression) {
|
|
15454
15503
|
if (symbol.tsType.getCallSignatures()?.length > 0) {
|
|
15455
|
-
const fullExpressionText = generateStringFromExpression(expression, expressionText);
|
|
15504
|
+
const fullExpressionText = generateStringFromExpression$1(expression, expressionText);
|
|
15456
15505
|
const errorString = `Function in event binding should be invoked: ${fullExpressionText}()`;
|
|
15457
15506
|
return [ctx.makeTemplateDiagnostic(node.sourceSpan, errorString)];
|
|
15458
15507
|
}
|
|
15459
15508
|
}
|
|
15460
15509
|
return [];
|
|
15461
15510
|
}
|
|
15462
|
-
function generateStringFromExpression(expression, source) {
|
|
15511
|
+
function generateStringFromExpression$1(expression, source) {
|
|
15463
15512
|
return source.substring(expression.span.start, expression.span.end);
|
|
15464
15513
|
}
|
|
15465
|
-
const factory$
|
|
15514
|
+
const factory$3 = {
|
|
15466
15515
|
code: checker.ErrorCode.UNINVOKED_FUNCTION_IN_EVENT_BINDING,
|
|
15467
15516
|
name: checker.ExtendedTemplateDiagnosticName.UNINVOKED_FUNCTION_IN_EVENT_BINDING,
|
|
15468
15517
|
create: () => new UninvokedFunctionInEventBindingSpec(),
|
|
@@ -15475,10 +15524,10 @@ const factory$2 = {
|
|
|
15475
15524
|
class UnparenthesizedNullishCoalescing extends TemplateCheckWithVisitor {
|
|
15476
15525
|
code = checker.ErrorCode.UNPARENTHESIZED_NULLISH_COALESCING;
|
|
15477
15526
|
visitNode(ctx, component, node) {
|
|
15478
|
-
if (node instanceof
|
|
15527
|
+
if (node instanceof compiler.Binary) {
|
|
15479
15528
|
if (node.operation === '&&' || node.operation === '||') {
|
|
15480
|
-
if ((node.left instanceof
|
|
15481
|
-
(node.right instanceof
|
|
15529
|
+
if ((node.left instanceof compiler.Binary && node.left.operation === '??') ||
|
|
15530
|
+
(node.right instanceof compiler.Binary && node.right.operation === '??')) {
|
|
15482
15531
|
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
|
|
15483
15532
|
if (symbol?.kind !== checker.SymbolKind.Expression) {
|
|
15484
15533
|
return [];
|
|
@@ -15495,7 +15544,7 @@ class UnparenthesizedNullishCoalescing extends TemplateCheckWithVisitor {
|
|
|
15495
15544
|
return [];
|
|
15496
15545
|
}
|
|
15497
15546
|
}
|
|
15498
|
-
const factory$
|
|
15547
|
+
const factory$2 = {
|
|
15499
15548
|
code: checker.ErrorCode.UNPARENTHESIZED_NULLISH_COALESCING,
|
|
15500
15549
|
name: checker.ExtendedTemplateDiagnosticName.UNPARENTHESIZED_NULLISH_COALESCING,
|
|
15501
15550
|
create: () => new UnparenthesizedNullishCoalescing(),
|
|
@@ -15520,13 +15569,13 @@ class UnusedLetDeclarationCheck extends TemplateCheckWithVisitor {
|
|
|
15520
15569
|
return diagnostics;
|
|
15521
15570
|
}
|
|
15522
15571
|
visitNode(ctx, component, node) {
|
|
15523
|
-
if (node instanceof
|
|
15572
|
+
if (node instanceof compiler.LetDeclaration) {
|
|
15524
15573
|
this.getAnalysis(component).allLetDeclarations.add(node);
|
|
15525
15574
|
}
|
|
15526
|
-
else if (node instanceof
|
|
15527
|
-
const unwrappedNode = node instanceof
|
|
15575
|
+
else if (node instanceof compiler.AST) {
|
|
15576
|
+
const unwrappedNode = node instanceof compiler.ASTWithSource ? node.ast : node;
|
|
15528
15577
|
const target = ctx.templateTypeChecker.getExpressionTarget(unwrappedNode, component);
|
|
15529
|
-
if (target !== null && target instanceof
|
|
15578
|
+
if (target !== null && target instanceof compiler.LetDeclaration) {
|
|
15530
15579
|
this.getAnalysis(component).usedLetDeclarations.add(target);
|
|
15531
15580
|
}
|
|
15532
15581
|
}
|
|
@@ -15539,12 +15588,50 @@ class UnusedLetDeclarationCheck extends TemplateCheckWithVisitor {
|
|
|
15539
15588
|
return this.analysis.get(node);
|
|
15540
15589
|
}
|
|
15541
15590
|
}
|
|
15542
|
-
const factory = {
|
|
15591
|
+
const factory$1 = {
|
|
15543
15592
|
code: checker.ErrorCode.UNUSED_LET_DECLARATION,
|
|
15544
15593
|
name: checker.ExtendedTemplateDiagnosticName.UNUSED_LET_DECLARATION,
|
|
15545
15594
|
create: () => new UnusedLetDeclarationCheck(),
|
|
15546
15595
|
};
|
|
15547
15596
|
|
|
15597
|
+
/**
|
|
15598
|
+
* Ensures that track functions in @for loops are invoked.
|
|
15599
|
+
*/
|
|
15600
|
+
class UninvokedTrackFunctionCheck extends TemplateCheckWithVisitor {
|
|
15601
|
+
code = checker.ErrorCode.UNINVOKED_TRACK_FUNCTION;
|
|
15602
|
+
visitNode(ctx, component, node) {
|
|
15603
|
+
if (!(node instanceof compiler.ForLoopBlock) || !node.trackBy) {
|
|
15604
|
+
return [];
|
|
15605
|
+
}
|
|
15606
|
+
if (node.trackBy.ast instanceof compiler.Call || node.trackBy.ast instanceof compiler.SafeCall) {
|
|
15607
|
+
// If the method is called, skip it.
|
|
15608
|
+
return [];
|
|
15609
|
+
}
|
|
15610
|
+
if (!(node.trackBy.ast instanceof compiler.PropertyRead) &&
|
|
15611
|
+
!(node.trackBy.ast instanceof compiler.SafePropertyRead)) {
|
|
15612
|
+
// If the expression is not a property read, skip it.
|
|
15613
|
+
return [];
|
|
15614
|
+
}
|
|
15615
|
+
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node.trackBy.ast, component);
|
|
15616
|
+
if (symbol !== null &&
|
|
15617
|
+
symbol.kind === checker.SymbolKind.Expression &&
|
|
15618
|
+
symbol.tsType.getCallSignatures()?.length > 0) {
|
|
15619
|
+
const fullExpressionText = generateStringFromExpression(node.trackBy.ast, node.trackBy.source || '');
|
|
15620
|
+
const errorString = `The track function in the @for block should be invoked: ${fullExpressionText}(/* arguments */)`;
|
|
15621
|
+
return [ctx.makeTemplateDiagnostic(node.sourceSpan, errorString)];
|
|
15622
|
+
}
|
|
15623
|
+
return [];
|
|
15624
|
+
}
|
|
15625
|
+
}
|
|
15626
|
+
function generateStringFromExpression(expression, source) {
|
|
15627
|
+
return source.substring(expression.span.start, expression.span.end);
|
|
15628
|
+
}
|
|
15629
|
+
const factory = {
|
|
15630
|
+
code: checker.ErrorCode.UNINVOKED_TRACK_FUNCTION,
|
|
15631
|
+
name: checker.ExtendedTemplateDiagnosticName.UNINVOKED_TRACK_FUNCTION,
|
|
15632
|
+
create: () => new UninvokedTrackFunctionCheck(),
|
|
15633
|
+
};
|
|
15634
|
+
|
|
15548
15635
|
/**
|
|
15549
15636
|
* A label referring to a `ts.DiagnosticCategory` or `'suppress'`, meaning the associated diagnostic
|
|
15550
15637
|
* should not be displayed at all.
|
|
@@ -15632,18 +15719,19 @@ function assertNever(value) {
|
|
|
15632
15719
|
}
|
|
15633
15720
|
|
|
15634
15721
|
const ALL_DIAGNOSTIC_FACTORIES = [
|
|
15635
|
-
factory$
|
|
15722
|
+
factory$b,
|
|
15723
|
+
factory$8,
|
|
15636
15724
|
factory$7,
|
|
15637
|
-
factory$
|
|
15725
|
+
factory$a,
|
|
15726
|
+
factory$4,
|
|
15638
15727
|
factory$9,
|
|
15728
|
+
factory$5,
|
|
15729
|
+
factory$c,
|
|
15639
15730
|
factory$3,
|
|
15640
|
-
factory$
|
|
15641
|
-
factory$
|
|
15642
|
-
factory$b,
|
|
15731
|
+
factory$1,
|
|
15732
|
+
factory$6,
|
|
15643
15733
|
factory$2,
|
|
15644
15734
|
factory,
|
|
15645
|
-
factory$5,
|
|
15646
|
-
factory$1,
|
|
15647
15735
|
];
|
|
15648
15736
|
const SUPPORTED_DIAGNOSTIC_NAMES = new Set([
|
|
15649
15737
|
checker.ExtendedTemplateDiagnosticName.CONTROL_FLOW_PREVENTING_CONTENT_PROJECTION,
|
|
@@ -15664,7 +15752,7 @@ class TemplateSemanticsCheckerImpl {
|
|
|
15664
15752
|
}
|
|
15665
15753
|
}
|
|
15666
15754
|
/** Visitor that verifies the semantics of a template. */
|
|
15667
|
-
class TemplateSemanticsVisitor extends
|
|
15755
|
+
class TemplateSemanticsVisitor extends compiler.RecursiveVisitor {
|
|
15668
15756
|
expressionVisitor;
|
|
15669
15757
|
constructor(expressionVisitor) {
|
|
15670
15758
|
super();
|
|
@@ -15683,7 +15771,7 @@ class TemplateSemanticsVisitor extends checker.RecursiveVisitor$1 {
|
|
|
15683
15771
|
}
|
|
15684
15772
|
}
|
|
15685
15773
|
/** Visitor that verifies the semantics of the expressions within a template. */
|
|
15686
|
-
class ExpressionsSemanticsVisitor extends
|
|
15774
|
+
class ExpressionsSemanticsVisitor extends compiler.RecursiveAstVisitor {
|
|
15687
15775
|
templateTypeChecker;
|
|
15688
15776
|
component;
|
|
15689
15777
|
diagnostics;
|
|
@@ -15702,26 +15790,26 @@ class ExpressionsSemanticsVisitor extends checker.RecursiveAstVisitor {
|
|
|
15702
15790
|
this.checkForIllegalWriteInTwoWayBinding(ast, context);
|
|
15703
15791
|
}
|
|
15704
15792
|
checkForIllegalWriteInEventBinding(ast, context) {
|
|
15705
|
-
if (!(context instanceof
|
|
15793
|
+
if (!(context instanceof compiler.BoundEvent) || !(ast.receiver instanceof compiler.ImplicitReceiver)) {
|
|
15706
15794
|
return;
|
|
15707
15795
|
}
|
|
15708
15796
|
const target = this.templateTypeChecker.getExpressionTarget(ast, this.component);
|
|
15709
|
-
if (target instanceof
|
|
15797
|
+
if (target instanceof compiler.Variable) {
|
|
15710
15798
|
const errorMessage = `Cannot use variable '${target.name}' as the left-hand side of an assignment expression. Template variables are read-only.`;
|
|
15711
15799
|
this.diagnostics.push(this.makeIllegalTemplateVarDiagnostic(target, context, errorMessage));
|
|
15712
15800
|
}
|
|
15713
15801
|
}
|
|
15714
15802
|
checkForIllegalWriteInTwoWayBinding(ast, context) {
|
|
15715
15803
|
// Only check top-level property reads inside two-way bindings for illegal assignments.
|
|
15716
|
-
if (!(context instanceof
|
|
15717
|
-
context.type !==
|
|
15718
|
-
!(ast.receiver instanceof
|
|
15804
|
+
if (!(context instanceof compiler.BoundEvent) ||
|
|
15805
|
+
context.type !== compiler.ParsedEventType.TwoWay ||
|
|
15806
|
+
!(ast.receiver instanceof compiler.ImplicitReceiver) ||
|
|
15719
15807
|
ast !== unwrapAstWithSource(context.handler)) {
|
|
15720
15808
|
return;
|
|
15721
15809
|
}
|
|
15722
15810
|
const target = this.templateTypeChecker.getExpressionTarget(ast, this.component);
|
|
15723
|
-
const isVariable = target instanceof
|
|
15724
|
-
const isLet = target instanceof
|
|
15811
|
+
const isVariable = target instanceof compiler.Variable;
|
|
15812
|
+
const isLet = target instanceof compiler.LetDeclaration;
|
|
15725
15813
|
if (!isVariable && !isLet) {
|
|
15726
15814
|
return;
|
|
15727
15815
|
}
|
|
@@ -15739,7 +15827,7 @@ class ExpressionsSemanticsVisitor extends checker.RecursiveAstVisitor {
|
|
|
15739
15827
|
}
|
|
15740
15828
|
}
|
|
15741
15829
|
makeIllegalTemplateVarDiagnostic(target, expressionNode, errorMessage) {
|
|
15742
|
-
const span = target instanceof
|
|
15830
|
+
const span = target instanceof compiler.Variable ? target.valueSpan || target.sourceSpan : target.sourceSpan;
|
|
15743
15831
|
return this.templateTypeChecker.makeTemplateDiagnostic(this.component, expressionNode.handlerSpan, ts.DiagnosticCategory.Error, checker.ngErrorCode(checker.ErrorCode.WRITE_TO_READ_ONLY_VARIABLE), errorMessage, [
|
|
15744
15832
|
{
|
|
15745
15833
|
text: `'${target.name}' is declared here.`,
|
|
@@ -15751,7 +15839,7 @@ class ExpressionsSemanticsVisitor extends checker.RecursiveAstVisitor {
|
|
|
15751
15839
|
}
|
|
15752
15840
|
}
|
|
15753
15841
|
function unwrapAstWithSource(ast) {
|
|
15754
|
-
return ast instanceof
|
|
15842
|
+
return ast instanceof compiler.ASTWithSource ? ast.ast : ast;
|
|
15755
15843
|
}
|
|
15756
15844
|
|
|
15757
15845
|
/*!
|
|
@@ -18713,7 +18801,7 @@ var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
|
|
|
18713
18801
|
* @param minVersion Minimum required version for the feature.
|
|
18714
18802
|
*/
|
|
18715
18803
|
function coreVersionSupportsFeature(coreVersion, minVersion) {
|
|
18716
|
-
// A version of `20.0.0-next.
|
|
18804
|
+
// A version of `20.0.0-next.6` usually means that core is at head so it supports
|
|
18717
18805
|
// all features. Use string interpolation prevent the placeholder from being replaced
|
|
18718
18806
|
// with the current version during build time.
|
|
18719
18807
|
if (coreVersion === `0.0.0-${'PLACEHOLDER'}`) {
|
|
@@ -19261,7 +19349,14 @@ class NgCompiler {
|
|
|
19261
19349
|
const printer = ts.createPrinter();
|
|
19262
19350
|
const nodeText = printer.printNode(ts.EmitHint.Unspecified, callback, sourceFile);
|
|
19263
19351
|
return ts.transpileModule(nodeText, {
|
|
19264
|
-
compilerOptions:
|
|
19352
|
+
compilerOptions: {
|
|
19353
|
+
...this.options,
|
|
19354
|
+
// Some module types can produce additional code (see #60795) whereas we need the
|
|
19355
|
+
// HMR update module to use a native `export`. Override the `target` and `module`
|
|
19356
|
+
// to ensure that it looks as expected.
|
|
19357
|
+
module: ts.ModuleKind.ES2022,
|
|
19358
|
+
target: ts.ScriptTarget.ES2022,
|
|
19359
|
+
},
|
|
19265
19360
|
fileName: sourceFile.fileName,
|
|
19266
19361
|
reportDiagnostics: false,
|
|
19267
19362
|
}).outputText;
|
|
@@ -19315,7 +19410,7 @@ class NgCompiler {
|
|
|
19315
19410
|
// back to version detection. Only Angular versions greater than 17.2 have the necessary symbols
|
|
19316
19411
|
// to type check signals in two-way bindings. We also allow version 0.0.0 in case somebody is
|
|
19317
19412
|
// using Angular at head.
|
|
19318
|
-
let allowSignalsInTwoWayBindings = coreHasSymbol(this.inputProgram,
|
|
19413
|
+
let allowSignalsInTwoWayBindings = coreHasSymbol(this.inputProgram, compiler.Identifiers.unwrapWritableSignal) ??
|
|
19319
19414
|
(this.angularCoreVersion === null ||
|
|
19320
19415
|
coreVersionSupportsFeature(this.angularCoreVersion, '>= 17.2.0'));
|
|
19321
19416
|
// First select a type-checking configuration, based on whether full template type-checking is
|
|
@@ -19535,8 +19630,7 @@ class NgCompiler {
|
|
|
19535
19630
|
// namespace" and the logic of `LogicalProjectStrategy` is required to generate correct
|
|
19536
19631
|
// imports which may cross these multiple directories. Otherwise, plain relative imports are
|
|
19537
19632
|
// sufficient.
|
|
19538
|
-
if (this.options.
|
|
19539
|
-
(this.options.rootDirs !== undefined && this.options.rootDirs.length > 0)) {
|
|
19633
|
+
if (this.options.rootDirs !== undefined && this.options.rootDirs.length > 0) {
|
|
19540
19634
|
// rootDirs logic is in effect - use the `LogicalProjectStrategy` for in-project relative
|
|
19541
19635
|
// imports.
|
|
19542
19636
|
localImportStrategy = new checker.LogicalProjectStrategy(reflector, new checker.LogicalFileSystem([...this.adapter.rootDirs], this.adapter));
|
|
@@ -20296,7 +20390,7 @@ class NgtscProgram {
|
|
|
20296
20390
|
return [];
|
|
20297
20391
|
}
|
|
20298
20392
|
emitXi18n() {
|
|
20299
|
-
const ctx = new MessageBundle(new
|
|
20393
|
+
const ctx = new MessageBundle(new compiler.HtmlParser(), [], {}, this.options.i18nOutLocale ?? null, this.options.i18nPreserveWhitespaceForLegacyExtraction);
|
|
20300
20394
|
this.compiler.xi18n(ctx);
|
|
20301
20395
|
i18nExtract(this.options.i18nOutFormat ?? null, this.options.i18nOutFile ?? null, this.host, this.options, ctx, checker.resolve);
|
|
20302
20396
|
}
|