@angular/core 20.0.0-rc.3 → 20.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.d-B0vztftH.d.ts +1 -1
- package/chrome_dev_tools_performance.d-DvzAxqBc.d.ts +1 -1
- package/{discovery.d-DZNIp-Fw.d.ts → discovery.d-CB2iJta5.d.ts} +8 -9
- package/event_dispatcher.d-BReQpZfC.d.ts +1 -1
- package/fesm2022/attribute-BWp59EjE.mjs +1 -1
- package/fesm2022/core.mjs +12 -12
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/{debug_node-Dn-GvQJo.mjs → debug_node-B9JawCEy.mjs} +33 -23
- package/fesm2022/debug_node-B9JawCEy.mjs.map +1 -0
- package/fesm2022/primitives/di.mjs +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -1
- package/fesm2022/primitives/signals.mjs +4 -4
- package/fesm2022/{resource-BPCh38bN.mjs → resource-W6LObBPP.mjs} +8 -6
- package/fesm2022/{resource-BPCh38bN.mjs.map → resource-W6LObBPP.mjs.map} +1 -1
- package/fesm2022/{root_effect_scheduler-0BxwqIgm.mjs → root_effect_scheduler-C4AUixQF.mjs} +19 -13
- package/fesm2022/root_effect_scheduler-C4AUixQF.mjs.map +1 -0
- package/fesm2022/rxjs-interop.mjs +12 -7
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/{signal-ePSl6jXn.mjs → signal-BZ1SD--i.mjs} +8 -9
- package/fesm2022/{signal-ePSl6jXn.mjs.map → signal-BZ1SD--i.mjs.map} +1 -1
- package/fesm2022/testing.mjs +4 -4
- package/fesm2022/{untracked-2ouAFbCz.mjs → untracked-RA6XPQ1Z.mjs} +3 -3
- package/fesm2022/{untracked-2ouAFbCz.mjs.map → untracked-RA6XPQ1Z.mjs.map} +1 -1
- package/fesm2022/weak_ref-BaIq-pgY.mjs +1 -1
- package/graph.d-BcIOep_B.d.ts +1 -1
- package/index.d.ts +19 -14
- package/package.json +2 -2
- package/primitives/di/index.d.ts +1 -1
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +3 -3
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/bundles/{apply_import_manager-Bqnvtho4.cjs → apply_import_manager-DT15wSJs.cjs} +3 -3
- package/schematics/bundles/{compiler-Dl11rH6-.cjs → checker-Bu1Wu4f7.cjs} +18350 -336
- package/schematics/bundles/cleanup-unused-imports.cjs +12 -9
- package/schematics/bundles/{change_tracker-DaCWdziV.cjs → compiler_host-C_4Iw5UD.cjs} +121 -3
- package/schematics/bundles/control-flow-migration.cjs +46 -25
- package/schematics/bundles/document-core.cjs +5 -6
- package/schematics/bundles/imports-CIX-JgAN.cjs +1 -1
- package/schematics/bundles/{index-CYxAVSJC.cjs → index-CAM7Xiu7.cjs} +29 -30
- package/schematics/bundles/{index-DPvX-lSh.cjs → index-CCX_cTPD.cjs} +516 -517
- package/schematics/bundles/inject-flags.cjs +5 -6
- package/schematics/bundles/inject-migration.cjs +5 -7
- package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
- package/schematics/bundles/{migrate_ts_type_references-DWUePVh6.cjs → migrate_ts_type_references-DSqmdRpG.cjs} +5 -6
- package/schematics/bundles/ng_decorators-B5HCqr20.cjs +1 -1
- package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
- package/schematics/bundles/output-migration.cjs +7 -8
- package/schematics/bundles/{project_paths-BPBAn_A2.cjs → project_paths-BjQra9mv.cjs} +3 -4
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +1 -1
- package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
- package/schematics/bundles/route-lazy-loading.cjs +5 -7
- package/schematics/bundles/self-closing-tags-migration.cjs +9 -10
- package/schematics/bundles/signal-input-migration.cjs +7 -8
- package/schematics/bundles/signal-queries-migration.cjs +13 -14
- package/schematics/bundles/signals.cjs +7 -8
- package/schematics/bundles/standalone-migration.cjs +9 -11
- package/schematics/bundles/symbol-VPWguRxr.cjs +1 -1
- package/schematics/bundles/test-bed-get.cjs +4 -5
- package/schematics/collection.json +6 -0
- package/schematics/migrations/control-flow-migration/schema.json +20 -0
- package/{signal.d-D6VJ67xi.d.ts → signal.d-fOdF0h0o.d.ts} +4 -3
- package/testing/index.d.ts +3 -3
- package/weak_ref.d-eGOEP9S1.d.ts +1 -1
- package/fesm2022/debug_node-Dn-GvQJo.mjs.map +0 -1
- package/fesm2022/root_effect_scheduler-0BxwqIgm.mjs.map +0 -1
- package/schematics/bundles/checker-BHgMyU8j.cjs +0 -17996
- package/schematics/bundles/compiler_host-CAfDJO3W.cjs +0 -129
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.
|
|
3
|
+
* @license Angular v20.0.1
|
|
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 checker = require('./checker-Bu1Wu4f7.cjs');
|
|
10
10
|
var ts = require('typescript');
|
|
11
11
|
var p = require('path');
|
|
12
|
-
var checker = require('./checker-BHgMyU8j.cjs');
|
|
13
12
|
require('os');
|
|
14
13
|
|
|
15
14
|
function _interopNamespaceDefault(e) {
|
|
@@ -45,7 +44,7 @@ class XmlTagDefinition {
|
|
|
45
44
|
return false;
|
|
46
45
|
}
|
|
47
46
|
getContentType() {
|
|
48
|
-
return
|
|
47
|
+
return checker.TagContentType.PARSABLE_DATA;
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
const _TAG_DEFINITION = new XmlTagDefinition();
|
|
@@ -53,7 +52,7 @@ function getXmlTagDefinition(tagName) {
|
|
|
53
52
|
return _TAG_DEFINITION;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
class XmlParser extends
|
|
55
|
+
class XmlParser extends checker.Parser {
|
|
57
56
|
constructor() {
|
|
58
57
|
super(getXmlTagDefinition);
|
|
59
58
|
}
|
|
@@ -84,50 +83,50 @@ const _CONTEXT_GROUP_TAG = 'context-group';
|
|
|
84
83
|
const _CONTEXT_TAG = 'context';
|
|
85
84
|
// https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html
|
|
86
85
|
// https://docs.oasis-open.org/xliff/v1.2/xliff-profile-html/xliff-profile-html-1.2.html
|
|
87
|
-
class Xliff extends
|
|
86
|
+
class Xliff extends checker.Serializer {
|
|
88
87
|
write(messages, locale) {
|
|
89
88
|
const visitor = new _WriteVisitor$1();
|
|
90
89
|
const transUnits = [];
|
|
91
90
|
messages.forEach((message) => {
|
|
92
91
|
let contextTags = [];
|
|
93
92
|
message.sources.forEach((source) => {
|
|
94
|
-
let contextGroupTag = new
|
|
95
|
-
contextGroupTag.children.push(new
|
|
96
|
-
new
|
|
97
|
-
]), new
|
|
98
|
-
new
|
|
99
|
-
]), new
|
|
100
|
-
contextTags.push(new
|
|
93
|
+
let contextGroupTag = new checker.Tag(_CONTEXT_GROUP_TAG, { purpose: 'location' });
|
|
94
|
+
contextGroupTag.children.push(new checker.CR(10), new checker.Tag(_CONTEXT_TAG, { 'context-type': 'sourcefile' }, [
|
|
95
|
+
new checker.Text$1(source.filePath),
|
|
96
|
+
]), new checker.CR(10), new checker.Tag(_CONTEXT_TAG, { 'context-type': 'linenumber' }, [
|
|
97
|
+
new checker.Text$1(`${source.startLine}`),
|
|
98
|
+
]), new checker.CR(8));
|
|
99
|
+
contextTags.push(new checker.CR(8), contextGroupTag);
|
|
101
100
|
});
|
|
102
|
-
const transUnit = new
|
|
103
|
-
transUnit.children.push(new
|
|
101
|
+
const transUnit = new checker.Tag(_UNIT_TAG$1, { id: message.id, datatype: 'html' });
|
|
102
|
+
transUnit.children.push(new checker.CR(8), new checker.Tag(_SOURCE_TAG$1, {}, visitor.serialize(message.nodes)), ...contextTags);
|
|
104
103
|
if (message.description) {
|
|
105
|
-
transUnit.children.push(new
|
|
106
|
-
new
|
|
104
|
+
transUnit.children.push(new checker.CR(8), new checker.Tag('note', { priority: '1', from: 'description' }, [
|
|
105
|
+
new checker.Text$1(message.description),
|
|
107
106
|
]));
|
|
108
107
|
}
|
|
109
108
|
if (message.meaning) {
|
|
110
|
-
transUnit.children.push(new
|
|
109
|
+
transUnit.children.push(new checker.CR(8), new checker.Tag('note', { priority: '1', from: 'meaning' }, [new checker.Text$1(message.meaning)]));
|
|
111
110
|
}
|
|
112
|
-
transUnit.children.push(new
|
|
113
|
-
transUnits.push(new
|
|
111
|
+
transUnit.children.push(new checker.CR(6));
|
|
112
|
+
transUnits.push(new checker.CR(6), transUnit);
|
|
114
113
|
});
|
|
115
|
-
const body = new
|
|
116
|
-
const file = new
|
|
114
|
+
const body = new checker.Tag('body', {}, [...transUnits, new checker.CR(4)]);
|
|
115
|
+
const file = new checker.Tag('file', {
|
|
117
116
|
'source-language': locale || _DEFAULT_SOURCE_LANG$1,
|
|
118
117
|
datatype: 'plaintext',
|
|
119
118
|
original: 'ng2.template',
|
|
120
|
-
}, [new
|
|
121
|
-
const xliff = new
|
|
122
|
-
new
|
|
119
|
+
}, [new checker.CR(4), body, new checker.CR(2)]);
|
|
120
|
+
const xliff = new checker.Tag('xliff', { version: _VERSION$1, xmlns: _XMLNS$1 }, [
|
|
121
|
+
new checker.CR(2),
|
|
123
122
|
file,
|
|
124
|
-
new
|
|
123
|
+
new checker.CR(),
|
|
125
124
|
]);
|
|
126
|
-
return
|
|
127
|
-
new
|
|
128
|
-
new
|
|
125
|
+
return checker.serialize([
|
|
126
|
+
new checker.Declaration({ version: '1.0', encoding: 'UTF-8' }),
|
|
127
|
+
new checker.CR(),
|
|
129
128
|
xliff,
|
|
130
|
-
new
|
|
129
|
+
new checker.CR(),
|
|
131
130
|
]);
|
|
132
131
|
}
|
|
133
132
|
load(content, url) {
|
|
@@ -148,12 +147,12 @@ class Xliff extends compiler.Serializer {
|
|
|
148
147
|
return { locale: locale, i18nNodesByMsgId };
|
|
149
148
|
}
|
|
150
149
|
digest(message) {
|
|
151
|
-
return
|
|
150
|
+
return checker.digest(message);
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
let _WriteVisitor$1 = class _WriteVisitor {
|
|
155
154
|
visitText(text, context) {
|
|
156
|
-
return [new
|
|
155
|
+
return [new checker.Text$1(text.value)];
|
|
157
156
|
}
|
|
158
157
|
visitContainer(container, context) {
|
|
159
158
|
const nodes = [];
|
|
@@ -161,11 +160,11 @@ let _WriteVisitor$1 = class _WriteVisitor {
|
|
|
161
160
|
return nodes;
|
|
162
161
|
}
|
|
163
162
|
visitIcu(icu, context) {
|
|
164
|
-
const nodes = [new
|
|
163
|
+
const nodes = [new checker.Text$1(`{${icu.expressionPlaceholder}, ${icu.type}, `)];
|
|
165
164
|
Object.keys(icu.cases).forEach((c) => {
|
|
166
|
-
nodes.push(new
|
|
165
|
+
nodes.push(new checker.Text$1(`${c} {`), ...icu.cases[c].visit(this), new checker.Text$1(`} `));
|
|
167
166
|
});
|
|
168
|
-
nodes.push(new
|
|
167
|
+
nodes.push(new checker.Text$1(`}`));
|
|
169
168
|
return nodes;
|
|
170
169
|
}
|
|
171
170
|
visitTagPlaceholder(ph, context) {
|
|
@@ -173,15 +172,15 @@ let _WriteVisitor$1 = class _WriteVisitor {
|
|
|
173
172
|
if (ph.isVoid) {
|
|
174
173
|
// void tags have no children nor closing tags
|
|
175
174
|
return [
|
|
176
|
-
new
|
|
175
|
+
new checker.Tag(_PLACEHOLDER_TAG$1, { id: ph.startName, ctype, 'equiv-text': `<${ph.tag}/>` }),
|
|
177
176
|
];
|
|
178
177
|
}
|
|
179
|
-
const startTagPh = new
|
|
178
|
+
const startTagPh = new checker.Tag(_PLACEHOLDER_TAG$1, {
|
|
180
179
|
id: ph.startName,
|
|
181
180
|
ctype,
|
|
182
181
|
'equiv-text': `<${ph.tag}>`,
|
|
183
182
|
});
|
|
184
|
-
const closeTagPh = new
|
|
183
|
+
const closeTagPh = new checker.Tag(_PLACEHOLDER_TAG$1, {
|
|
185
184
|
id: ph.closeName,
|
|
186
185
|
ctype,
|
|
187
186
|
'equiv-text': `</${ph.tag}>`,
|
|
@@ -189,23 +188,23 @@ let _WriteVisitor$1 = class _WriteVisitor {
|
|
|
189
188
|
return [startTagPh, ...this.serialize(ph.children), closeTagPh];
|
|
190
189
|
}
|
|
191
190
|
visitPlaceholder(ph, context) {
|
|
192
|
-
return [new
|
|
191
|
+
return [new checker.Tag(_PLACEHOLDER_TAG$1, { id: ph.name, 'equiv-text': `{{${ph.value}}}` })];
|
|
193
192
|
}
|
|
194
193
|
visitBlockPlaceholder(ph, context) {
|
|
195
194
|
const ctype = `x-${ph.name.toLowerCase().replace(/[^a-z0-9]/g, '-')}`;
|
|
196
|
-
const startTagPh = new
|
|
195
|
+
const startTagPh = new checker.Tag(_PLACEHOLDER_TAG$1, {
|
|
197
196
|
id: ph.startName,
|
|
198
197
|
ctype,
|
|
199
198
|
'equiv-text': `@${ph.name}`,
|
|
200
199
|
});
|
|
201
|
-
const closeTagPh = new
|
|
200
|
+
const closeTagPh = new checker.Tag(_PLACEHOLDER_TAG$1, { id: ph.closeName, ctype, 'equiv-text': `}` });
|
|
202
201
|
return [startTagPh, ...this.serialize(ph.children), closeTagPh];
|
|
203
202
|
}
|
|
204
203
|
visitIcuPlaceholder(ph, context) {
|
|
205
204
|
const equivText = `{${ph.value.expression}, ${ph.value.type}, ${Object.keys(ph.value.cases)
|
|
206
205
|
.map((value) => value + ' {...}')
|
|
207
206
|
.join(' ')}}`;
|
|
208
|
-
return [new
|
|
207
|
+
return [new checker.Tag(_PLACEHOLDER_TAG$1, { id: ph.name, 'equiv-text': equivText })];
|
|
209
208
|
}
|
|
210
209
|
serialize(nodes) {
|
|
211
210
|
return [].concat(...nodes.map((node) => node.visit(this)));
|
|
@@ -224,7 +223,7 @@ class XliffParser {
|
|
|
224
223
|
this._msgIdToHtml = {};
|
|
225
224
|
const xml = new XmlParser().parse(xliff, url);
|
|
226
225
|
this._errors = xml.errors;
|
|
227
|
-
|
|
226
|
+
checker.visitAll$1(this, xml.rootNodes, null);
|
|
228
227
|
return {
|
|
229
228
|
msgIdToHtml: this._msgIdToHtml,
|
|
230
229
|
errors: this._errors,
|
|
@@ -245,7 +244,7 @@ class XliffParser {
|
|
|
245
244
|
this._addError(element, `Duplicated translations for msg ${id}`);
|
|
246
245
|
}
|
|
247
246
|
else {
|
|
248
|
-
|
|
247
|
+
checker.visitAll$1(this, element.children, null);
|
|
249
248
|
if (typeof this._unitMlString === 'string') {
|
|
250
249
|
this._msgIdToHtml[id] = this._unitMlString;
|
|
251
250
|
}
|
|
@@ -272,12 +271,12 @@ class XliffParser {
|
|
|
272
271
|
if (localeAttr) {
|
|
273
272
|
this._locale = localeAttr.value;
|
|
274
273
|
}
|
|
275
|
-
|
|
274
|
+
checker.visitAll$1(this, element.children, null);
|
|
276
275
|
break;
|
|
277
276
|
default:
|
|
278
277
|
// TODO(vicb): assert file structure, xliff version
|
|
279
278
|
// For now only recurse on unhandled nodes
|
|
280
|
-
|
|
279
|
+
checker.visitAll$1(this, element.children, null);
|
|
281
280
|
}
|
|
282
281
|
}
|
|
283
282
|
visitAttribute(attribute, context) { }
|
|
@@ -291,7 +290,7 @@ class XliffParser {
|
|
|
291
290
|
visitComponent(component, context) { }
|
|
292
291
|
visitDirective(directive, context) { }
|
|
293
292
|
_addError(node, message) {
|
|
294
|
-
this._errors.push(new
|
|
293
|
+
this._errors.push(new checker.I18nError(node.sourceSpan, message));
|
|
295
294
|
}
|
|
296
295
|
}
|
|
297
296
|
// Convert ml nodes (xliff syntax) to i18n nodes
|
|
@@ -303,41 +302,41 @@ let XmlToI18n$1 = class XmlToI18n {
|
|
|
303
302
|
this._errors = xmlIcu.errors;
|
|
304
303
|
const i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0
|
|
305
304
|
? []
|
|
306
|
-
: [].concat(...
|
|
305
|
+
: [].concat(...checker.visitAll$1(this, xmlIcu.rootNodes));
|
|
307
306
|
return {
|
|
308
307
|
i18nNodes: i18nNodes,
|
|
309
308
|
errors: this._errors,
|
|
310
309
|
};
|
|
311
310
|
}
|
|
312
311
|
visitText(text, context) {
|
|
313
|
-
return new
|
|
312
|
+
return new checker.Text$2(text.value, text.sourceSpan);
|
|
314
313
|
}
|
|
315
314
|
visitElement(el, context) {
|
|
316
315
|
if (el.name === _PLACEHOLDER_TAG$1) {
|
|
317
316
|
const nameAttr = el.attrs.find((attr) => attr.name === 'id');
|
|
318
317
|
if (nameAttr) {
|
|
319
|
-
return new
|
|
318
|
+
return new checker.Placeholder('', nameAttr.value, el.sourceSpan);
|
|
320
319
|
}
|
|
321
320
|
this._addError(el, `<${_PLACEHOLDER_TAG$1}> misses the "id" attribute`);
|
|
322
321
|
return null;
|
|
323
322
|
}
|
|
324
323
|
if (el.name === _MARKER_TAG$1) {
|
|
325
|
-
return [].concat(...
|
|
324
|
+
return [].concat(...checker.visitAll$1(this, el.children));
|
|
326
325
|
}
|
|
327
326
|
this._addError(el, `Unexpected tag`);
|
|
328
327
|
return null;
|
|
329
328
|
}
|
|
330
329
|
visitExpansion(icu, context) {
|
|
331
330
|
const caseMap = {};
|
|
332
|
-
|
|
333
|
-
caseMap[c.value] = new
|
|
331
|
+
checker.visitAll$1(this, icu.cases).forEach((c) => {
|
|
332
|
+
caseMap[c.value] = new checker.Container(c.nodes, icu.sourceSpan);
|
|
334
333
|
});
|
|
335
|
-
return new
|
|
334
|
+
return new checker.Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
|
|
336
335
|
}
|
|
337
336
|
visitExpansionCase(icuCase, context) {
|
|
338
337
|
return {
|
|
339
338
|
value: icuCase.value,
|
|
340
|
-
nodes:
|
|
339
|
+
nodes: checker.visitAll$1(this, icuCase.expression),
|
|
341
340
|
};
|
|
342
341
|
}
|
|
343
342
|
visitComment(comment, context) { }
|
|
@@ -352,7 +351,7 @@ let XmlToI18n$1 = class XmlToI18n {
|
|
|
352
351
|
this._addError(directive, 'Unexpected node');
|
|
353
352
|
}
|
|
354
353
|
_addError(node, message) {
|
|
355
|
-
this._errors.push(new
|
|
354
|
+
this._errors.push(new checker.I18nError(node.sourceSpan, message));
|
|
356
355
|
}
|
|
357
356
|
};
|
|
358
357
|
function getCtypeForTag(tag) {
|
|
@@ -378,43 +377,43 @@ const _SOURCE_TAG = 'source';
|
|
|
378
377
|
const _TARGET_TAG = 'target';
|
|
379
378
|
const _UNIT_TAG = 'unit';
|
|
380
379
|
// https://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html
|
|
381
|
-
class Xliff2 extends
|
|
380
|
+
class Xliff2 extends checker.Serializer {
|
|
382
381
|
write(messages, locale) {
|
|
383
382
|
const visitor = new _WriteVisitor();
|
|
384
383
|
const units = [];
|
|
385
384
|
messages.forEach((message) => {
|
|
386
|
-
const unit = new
|
|
387
|
-
const notes = new
|
|
385
|
+
const unit = new checker.Tag(_UNIT_TAG, { id: message.id });
|
|
386
|
+
const notes = new checker.Tag('notes');
|
|
388
387
|
if (message.description || message.meaning) {
|
|
389
388
|
if (message.description) {
|
|
390
|
-
notes.children.push(new
|
|
389
|
+
notes.children.push(new checker.CR(8), new checker.Tag('note', { category: 'description' }, [new checker.Text$1(message.description)]));
|
|
391
390
|
}
|
|
392
391
|
if (message.meaning) {
|
|
393
|
-
notes.children.push(new
|
|
392
|
+
notes.children.push(new checker.CR(8), new checker.Tag('note', { category: 'meaning' }, [new checker.Text$1(message.meaning)]));
|
|
394
393
|
}
|
|
395
394
|
}
|
|
396
395
|
message.sources.forEach((source) => {
|
|
397
|
-
notes.children.push(new
|
|
398
|
-
new
|
|
396
|
+
notes.children.push(new checker.CR(8), new checker.Tag('note', { category: 'location' }, [
|
|
397
|
+
new checker.Text$1(`${source.filePath}:${source.startLine}${source.endLine !== source.startLine ? ',' + source.endLine : ''}`),
|
|
399
398
|
]));
|
|
400
399
|
});
|
|
401
|
-
notes.children.push(new
|
|
402
|
-
unit.children.push(new
|
|
403
|
-
const segment = new
|
|
404
|
-
segment.children.push(new
|
|
405
|
-
unit.children.push(new
|
|
406
|
-
units.push(new
|
|
400
|
+
notes.children.push(new checker.CR(6));
|
|
401
|
+
unit.children.push(new checker.CR(6), notes);
|
|
402
|
+
const segment = new checker.Tag('segment');
|
|
403
|
+
segment.children.push(new checker.CR(8), new checker.Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes)), new checker.CR(6));
|
|
404
|
+
unit.children.push(new checker.CR(6), segment, new checker.CR(4));
|
|
405
|
+
units.push(new checker.CR(4), unit);
|
|
407
406
|
});
|
|
408
|
-
const file = new
|
|
407
|
+
const file = new checker.Tag('file', { 'original': 'ng.template', id: 'ngi18n' }, [
|
|
409
408
|
...units,
|
|
410
|
-
new
|
|
409
|
+
new checker.CR(2),
|
|
411
410
|
]);
|
|
412
|
-
const xliff = new
|
|
413
|
-
return
|
|
414
|
-
new
|
|
415
|
-
new
|
|
411
|
+
const xliff = new checker.Tag(_XLIFF_TAG, { version: _VERSION, xmlns: _XMLNS, srcLang: locale || _DEFAULT_SOURCE_LANG }, [new checker.CR(2), file, new checker.CR()]);
|
|
412
|
+
return checker.serialize([
|
|
413
|
+
new checker.Declaration({ version: '1.0', encoding: 'UTF-8' }),
|
|
414
|
+
new checker.CR(),
|
|
416
415
|
xliff,
|
|
417
|
-
new
|
|
416
|
+
new checker.CR(),
|
|
418
417
|
]);
|
|
419
418
|
}
|
|
420
419
|
load(content, url) {
|
|
@@ -435,13 +434,13 @@ class Xliff2 extends compiler.Serializer {
|
|
|
435
434
|
return { locale: locale, i18nNodesByMsgId };
|
|
436
435
|
}
|
|
437
436
|
digest(message) {
|
|
438
|
-
return
|
|
437
|
+
return checker.decimalDigest(message);
|
|
439
438
|
}
|
|
440
439
|
}
|
|
441
440
|
class _WriteVisitor {
|
|
442
441
|
_nextPlaceholderId = 0;
|
|
443
442
|
visitText(text, context) {
|
|
444
|
-
return [new
|
|
443
|
+
return [new checker.Text$1(text.value)];
|
|
445
444
|
}
|
|
446
445
|
visitContainer(container, context) {
|
|
447
446
|
const nodes = [];
|
|
@@ -449,17 +448,17 @@ class _WriteVisitor {
|
|
|
449
448
|
return nodes;
|
|
450
449
|
}
|
|
451
450
|
visitIcu(icu, context) {
|
|
452
|
-
const nodes = [new
|
|
451
|
+
const nodes = [new checker.Text$1(`{${icu.expressionPlaceholder}, ${icu.type}, `)];
|
|
453
452
|
Object.keys(icu.cases).forEach((c) => {
|
|
454
|
-
nodes.push(new
|
|
453
|
+
nodes.push(new checker.Text$1(`${c} {`), ...icu.cases[c].visit(this), new checker.Text$1(`} `));
|
|
455
454
|
});
|
|
456
|
-
nodes.push(new
|
|
455
|
+
nodes.push(new checker.Text$1(`}`));
|
|
457
456
|
return nodes;
|
|
458
457
|
}
|
|
459
458
|
visitTagPlaceholder(ph, context) {
|
|
460
459
|
const type = getTypeForTag(ph.tag);
|
|
461
460
|
if (ph.isVoid) {
|
|
462
|
-
const tagPh = new
|
|
461
|
+
const tagPh = new checker.Tag(_PLACEHOLDER_TAG, {
|
|
463
462
|
id: (this._nextPlaceholderId++).toString(),
|
|
464
463
|
equiv: ph.startName,
|
|
465
464
|
type: type,
|
|
@@ -467,7 +466,7 @@ class _WriteVisitor {
|
|
|
467
466
|
});
|
|
468
467
|
return [tagPh];
|
|
469
468
|
}
|
|
470
|
-
const tagPc = new
|
|
469
|
+
const tagPc = new checker.Tag(_PLACEHOLDER_SPANNING_TAG, {
|
|
471
470
|
id: (this._nextPlaceholderId++).toString(),
|
|
472
471
|
equivStart: ph.startName,
|
|
473
472
|
equivEnd: ph.closeName,
|
|
@@ -480,14 +479,14 @@ class _WriteVisitor {
|
|
|
480
479
|
nodes.forEach((node) => tagPc.children.push(node));
|
|
481
480
|
}
|
|
482
481
|
else {
|
|
483
|
-
tagPc.children.push(new
|
|
482
|
+
tagPc.children.push(new checker.Text$1(''));
|
|
484
483
|
}
|
|
485
484
|
return [tagPc];
|
|
486
485
|
}
|
|
487
486
|
visitPlaceholder(ph, context) {
|
|
488
487
|
const idStr = (this._nextPlaceholderId++).toString();
|
|
489
488
|
return [
|
|
490
|
-
new
|
|
489
|
+
new checker.Tag(_PLACEHOLDER_TAG, {
|
|
491
490
|
id: idStr,
|
|
492
491
|
equiv: ph.name,
|
|
493
492
|
disp: `{{${ph.value}}}`,
|
|
@@ -495,7 +494,7 @@ class _WriteVisitor {
|
|
|
495
494
|
];
|
|
496
495
|
}
|
|
497
496
|
visitBlockPlaceholder(ph, context) {
|
|
498
|
-
const tagPc = new
|
|
497
|
+
const tagPc = new checker.Tag(_PLACEHOLDER_SPANNING_TAG, {
|
|
499
498
|
id: (this._nextPlaceholderId++).toString(),
|
|
500
499
|
equivStart: ph.startName,
|
|
501
500
|
equivEnd: ph.closeName,
|
|
@@ -508,7 +507,7 @@ class _WriteVisitor {
|
|
|
508
507
|
nodes.forEach((node) => tagPc.children.push(node));
|
|
509
508
|
}
|
|
510
509
|
else {
|
|
511
|
-
tagPc.children.push(new
|
|
510
|
+
tagPc.children.push(new checker.Text$1(''));
|
|
512
511
|
}
|
|
513
512
|
return [tagPc];
|
|
514
513
|
}
|
|
@@ -518,7 +517,7 @@ class _WriteVisitor {
|
|
|
518
517
|
.join(' ');
|
|
519
518
|
const idStr = (this._nextPlaceholderId++).toString();
|
|
520
519
|
return [
|
|
521
|
-
new
|
|
520
|
+
new checker.Tag(_PLACEHOLDER_TAG, {
|
|
522
521
|
id: idStr,
|
|
523
522
|
equiv: ph.name,
|
|
524
523
|
disp: `{${ph.value.expression}, ${ph.value.type}, ${cases}}`,
|
|
@@ -542,7 +541,7 @@ class Xliff2Parser {
|
|
|
542
541
|
this._msgIdToHtml = {};
|
|
543
542
|
const xml = new XmlParser().parse(xliff, url);
|
|
544
543
|
this._errors = xml.errors;
|
|
545
|
-
|
|
544
|
+
checker.visitAll$1(this, xml.rootNodes, null);
|
|
546
545
|
return {
|
|
547
546
|
msgIdToHtml: this._msgIdToHtml,
|
|
548
547
|
errors: this._errors,
|
|
@@ -563,7 +562,7 @@ class Xliff2Parser {
|
|
|
563
562
|
this._addError(element, `Duplicated translations for msg ${id}`);
|
|
564
563
|
}
|
|
565
564
|
else {
|
|
566
|
-
|
|
565
|
+
checker.visitAll$1(this, element.children, null);
|
|
567
566
|
if (typeof this._unitMlString === 'string') {
|
|
568
567
|
this._msgIdToHtml[id] = this._unitMlString;
|
|
569
568
|
}
|
|
@@ -595,12 +594,12 @@ class Xliff2Parser {
|
|
|
595
594
|
this._addError(element, `The XLIFF file version ${version} is not compatible with XLIFF 2.0 serializer`);
|
|
596
595
|
}
|
|
597
596
|
else {
|
|
598
|
-
|
|
597
|
+
checker.visitAll$1(this, element.children, null);
|
|
599
598
|
}
|
|
600
599
|
}
|
|
601
600
|
break;
|
|
602
601
|
default:
|
|
603
|
-
|
|
602
|
+
checker.visitAll$1(this, element.children, null);
|
|
604
603
|
}
|
|
605
604
|
}
|
|
606
605
|
visitAttribute(attribute, context) { }
|
|
@@ -614,7 +613,7 @@ class Xliff2Parser {
|
|
|
614
613
|
visitComponent(component, context) { }
|
|
615
614
|
visitDirective(directive, context) { }
|
|
616
615
|
_addError(node, message) {
|
|
617
|
-
this._errors.push(new
|
|
616
|
+
this._errors.push(new checker.I18nError(node.sourceSpan, message));
|
|
618
617
|
}
|
|
619
618
|
}
|
|
620
619
|
// Convert ml nodes (xliff syntax) to i18n nodes
|
|
@@ -626,21 +625,21 @@ class XmlToI18n {
|
|
|
626
625
|
this._errors = xmlIcu.errors;
|
|
627
626
|
const i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0
|
|
628
627
|
? []
|
|
629
|
-
: [].concat(...
|
|
628
|
+
: [].concat(...checker.visitAll$1(this, xmlIcu.rootNodes));
|
|
630
629
|
return {
|
|
631
630
|
i18nNodes,
|
|
632
631
|
errors: this._errors,
|
|
633
632
|
};
|
|
634
633
|
}
|
|
635
634
|
visitText(text, context) {
|
|
636
|
-
return new
|
|
635
|
+
return new checker.Text$2(text.value, text.sourceSpan);
|
|
637
636
|
}
|
|
638
637
|
visitElement(el, context) {
|
|
639
638
|
switch (el.name) {
|
|
640
639
|
case _PLACEHOLDER_TAG:
|
|
641
640
|
const nameAttr = el.attrs.find((attr) => attr.name === 'equiv');
|
|
642
641
|
if (nameAttr) {
|
|
643
|
-
return [new
|
|
642
|
+
return [new checker.Placeholder('', nameAttr.value, el.sourceSpan)];
|
|
644
643
|
}
|
|
645
644
|
this._addError(el, `<${_PLACEHOLDER_TAG}> misses the "equiv" attribute`);
|
|
646
645
|
break;
|
|
@@ -657,11 +656,11 @@ class XmlToI18n {
|
|
|
657
656
|
const startId = startAttr.value;
|
|
658
657
|
const endId = endAttr.value;
|
|
659
658
|
const nodes = [];
|
|
660
|
-
return nodes.concat(new
|
|
659
|
+
return nodes.concat(new checker.Placeholder('', startId, el.sourceSpan), ...el.children.map((node) => node.visit(this, null)), new checker.Placeholder('', endId, el.sourceSpan));
|
|
661
660
|
}
|
|
662
661
|
break;
|
|
663
662
|
case _MARKER_TAG:
|
|
664
|
-
return [].concat(...
|
|
663
|
+
return [].concat(...checker.visitAll$1(this, el.children));
|
|
665
664
|
default:
|
|
666
665
|
this._addError(el, `Unexpected tag`);
|
|
667
666
|
}
|
|
@@ -669,15 +668,15 @@ class XmlToI18n {
|
|
|
669
668
|
}
|
|
670
669
|
visitExpansion(icu, context) {
|
|
671
670
|
const caseMap = {};
|
|
672
|
-
|
|
673
|
-
caseMap[c.value] = new
|
|
671
|
+
checker.visitAll$1(this, icu.cases).forEach((c) => {
|
|
672
|
+
caseMap[c.value] = new checker.Container(c.nodes, icu.sourceSpan);
|
|
674
673
|
});
|
|
675
|
-
return new
|
|
674
|
+
return new checker.Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
|
|
676
675
|
}
|
|
677
676
|
visitExpansionCase(icuCase, context) {
|
|
678
677
|
return {
|
|
679
678
|
value: icuCase.value,
|
|
680
|
-
nodes: [].concat(...
|
|
679
|
+
nodes: [].concat(...checker.visitAll$1(this, icuCase.expression)),
|
|
681
680
|
};
|
|
682
681
|
}
|
|
683
682
|
visitComment(comment, context) { }
|
|
@@ -692,7 +691,7 @@ class XmlToI18n {
|
|
|
692
691
|
this._addError(directive, 'Unexpected node');
|
|
693
692
|
}
|
|
694
693
|
_addError(node, message) {
|
|
695
|
-
this._errors.push(new
|
|
694
|
+
this._errors.push(new checker.I18nError(node.sourceSpan, message));
|
|
696
695
|
}
|
|
697
696
|
}
|
|
698
697
|
function getTypeForTag(tag) {
|
|
@@ -741,8 +740,8 @@ class MessageBundle {
|
|
|
741
740
|
// affected message IDs.
|
|
742
741
|
const rootNodes = this._preserveWhitespace
|
|
743
742
|
? htmlParserResult.rootNodes
|
|
744
|
-
:
|
|
745
|
-
const i18nParserResult =
|
|
743
|
+
: checker.visitAllWithSiblings(new checker.WhitespaceVisitor(/* preserveSignificantWhitespace */ false), htmlParserResult.rootNodes);
|
|
744
|
+
const i18nParserResult = checker.extractMessages(rootNodes, interpolationConfig, this._implicitTags, this._implicitAttrs,
|
|
746
745
|
/* preserveSignificantWhitespace */ this._preserveWhitespace);
|
|
747
746
|
if (i18nParserResult.errors.length) {
|
|
748
747
|
return i18nParserResult.errors;
|
|
@@ -773,7 +772,7 @@ class MessageBundle {
|
|
|
773
772
|
const mapper = serializer.createNameMapper(messages[id]);
|
|
774
773
|
const src = messages[id];
|
|
775
774
|
const nodes = mapper ? mapperVisitor.convert(src.nodes, mapper) : src.nodes;
|
|
776
|
-
let transformedMessage = new
|
|
775
|
+
let transformedMessage = new checker.Message(nodes, {}, {}, src.meaning, src.description, id);
|
|
777
776
|
transformedMessage.sources = src.sources;
|
|
778
777
|
if (filterSources) {
|
|
779
778
|
transformedMessage.sources.forEach((source) => (source.filePath = filterSources(source.filePath)));
|
|
@@ -784,7 +783,7 @@ class MessageBundle {
|
|
|
784
783
|
}
|
|
785
784
|
}
|
|
786
785
|
// Transform an i18n AST by renaming the placeholder nodes with the given mapper
|
|
787
|
-
class MapPlaceholderNames extends
|
|
786
|
+
class MapPlaceholderNames extends checker.CloneVisitor {
|
|
788
787
|
convert(nodes, mapper) {
|
|
789
788
|
return mapper ? nodes.map((n) => n.visit(this, mapper)) : nodes;
|
|
790
789
|
}
|
|
@@ -792,34 +791,34 @@ class MapPlaceholderNames extends compiler.CloneVisitor {
|
|
|
792
791
|
const startName = mapper.toPublicName(ph.startName);
|
|
793
792
|
const closeName = ph.closeName ? mapper.toPublicName(ph.closeName) : ph.closeName;
|
|
794
793
|
const children = ph.children.map((n) => n.visit(this, mapper));
|
|
795
|
-
return new
|
|
794
|
+
return new checker.TagPlaceholder(ph.tag, ph.attrs, startName, closeName, children, ph.isVoid, ph.sourceSpan, ph.startSourceSpan, ph.endSourceSpan);
|
|
796
795
|
}
|
|
797
796
|
visitBlockPlaceholder(ph, mapper) {
|
|
798
797
|
const startName = mapper.toPublicName(ph.startName);
|
|
799
798
|
const closeName = ph.closeName ? mapper.toPublicName(ph.closeName) : ph.closeName;
|
|
800
799
|
const children = ph.children.map((n) => n.visit(this, mapper));
|
|
801
|
-
return new
|
|
800
|
+
return new checker.BlockPlaceholder(ph.name, ph.parameters, startName, closeName, children, ph.sourceSpan, ph.startSourceSpan, ph.endSourceSpan);
|
|
802
801
|
}
|
|
803
802
|
visitPlaceholder(ph, mapper) {
|
|
804
|
-
return new
|
|
803
|
+
return new checker.Placeholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan);
|
|
805
804
|
}
|
|
806
805
|
visitIcuPlaceholder(ph, mapper) {
|
|
807
|
-
return new
|
|
806
|
+
return new checker.IcuPlaceholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan);
|
|
808
807
|
}
|
|
809
808
|
}
|
|
810
809
|
|
|
811
810
|
function compileClassMetadata(metadata) {
|
|
812
811
|
const fnCall = internalCompileClassMetadata(metadata);
|
|
813
|
-
return
|
|
812
|
+
return checker.arrowFn([], [checker.devOnlyGuardedExpression(fnCall).toStmt()]).callFn([]);
|
|
814
813
|
}
|
|
815
814
|
/** Compiles only the `setClassMetadata` call without any additional wrappers. */
|
|
816
815
|
function internalCompileClassMetadata(metadata) {
|
|
817
|
-
return
|
|
816
|
+
return checker.importExpr(checker.Identifiers.setClassMetadata)
|
|
818
817
|
.callFn([
|
|
819
818
|
metadata.type,
|
|
820
819
|
metadata.decorators,
|
|
821
|
-
metadata.ctorParameters ??
|
|
822
|
-
metadata.propDecorators ??
|
|
820
|
+
metadata.ctorParameters ?? checker.literal(null),
|
|
821
|
+
metadata.propDecorators ?? checker.literal(null),
|
|
823
822
|
]);
|
|
824
823
|
}
|
|
825
824
|
/**
|
|
@@ -844,7 +843,7 @@ function compileComponentClassMetadata(metadata, dependencies) {
|
|
|
844
843
|
// If there are no deferrable symbols - just generate a regular `setClassMetadata` call.
|
|
845
844
|
return compileClassMetadata(metadata);
|
|
846
845
|
}
|
|
847
|
-
return internalCompileSetClassMetadataAsync(metadata, dependencies.map((dep) => new
|
|
846
|
+
return internalCompileSetClassMetadataAsync(metadata, dependencies.map((dep) => new checker.FnParam(dep.symbolName, checker.DYNAMIC_TYPE)), compileComponentMetadataAsyncResolver(dependencies));
|
|
848
847
|
}
|
|
849
848
|
/**
|
|
850
849
|
* Internal logic used to compile a `setClassMetadataAsync` call.
|
|
@@ -855,10 +854,10 @@ function compileComponentClassMetadata(metadata, dependencies) {
|
|
|
855
854
|
function internalCompileSetClassMetadataAsync(metadata, wrapperParams, dependencyResolverFn) {
|
|
856
855
|
// Omit the wrapper since it'll be added around `setClassMetadataAsync` instead.
|
|
857
856
|
const setClassMetadataCall = internalCompileClassMetadata(metadata);
|
|
858
|
-
const setClassMetaWrapper =
|
|
859
|
-
const setClassMetaAsync =
|
|
857
|
+
const setClassMetaWrapper = checker.arrowFn(wrapperParams, [setClassMetadataCall.toStmt()]);
|
|
858
|
+
const setClassMetaAsync = checker.importExpr(checker.Identifiers.setClassMetadataAsync)
|
|
860
859
|
.callFn([metadata.type, dependencyResolverFn, setClassMetaWrapper]);
|
|
861
|
-
return
|
|
860
|
+
return checker.arrowFn([], [checker.devOnlyGuardedExpression(setClassMetaAsync).toStmt()]).callFn([]);
|
|
862
861
|
}
|
|
863
862
|
/**
|
|
864
863
|
* Compiles the function that loads the dependencies for the
|
|
@@ -869,12 +868,12 @@ function compileComponentMetadataAsyncResolver(dependencies) {
|
|
|
869
868
|
// e.g. `(m) => m.CmpA`
|
|
870
869
|
const innerFn =
|
|
871
870
|
// Default imports are always accessed through the `default` property.
|
|
872
|
-
|
|
871
|
+
checker.arrowFn([new checker.FnParam('m', checker.DYNAMIC_TYPE)], checker.variable('m').prop(isDefaultImport ? 'default' : symbolName));
|
|
873
872
|
// e.g. `import('./cmp-a').then(...)`
|
|
874
|
-
return new
|
|
873
|
+
return new checker.DynamicImportExpr(importPath).prop('then').callFn([innerFn]);
|
|
875
874
|
});
|
|
876
875
|
// e.g. `() => [ ... ];`
|
|
877
|
-
return
|
|
876
|
+
return checker.arrowFn([], checker.literalArr(dynamicImports));
|
|
878
877
|
}
|
|
879
878
|
|
|
880
879
|
/**
|
|
@@ -890,32 +889,32 @@ const MINIMUM_PARTIAL_LINKER_VERSION$5 = '12.0.0';
|
|
|
890
889
|
*/
|
|
891
890
|
const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
|
|
892
891
|
function compileDeclareClassMetadata(metadata) {
|
|
893
|
-
const definitionMap = new
|
|
894
|
-
definitionMap.set('minVersion',
|
|
895
|
-
definitionMap.set('version',
|
|
896
|
-
definitionMap.set('ngImport',
|
|
892
|
+
const definitionMap = new checker.DefinitionMap();
|
|
893
|
+
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
894
|
+
definitionMap.set('version', checker.literal('20.0.1'));
|
|
895
|
+
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
897
896
|
definitionMap.set('type', metadata.type);
|
|
898
897
|
definitionMap.set('decorators', metadata.decorators);
|
|
899
898
|
definitionMap.set('ctorParameters', metadata.ctorParameters);
|
|
900
899
|
definitionMap.set('propDecorators', metadata.propDecorators);
|
|
901
|
-
return
|
|
900
|
+
return checker.importExpr(checker.Identifiers.declareClassMetadata).callFn([definitionMap.toLiteralMap()]);
|
|
902
901
|
}
|
|
903
902
|
function compileComponentDeclareClassMetadata(metadata, dependencies) {
|
|
904
903
|
if (dependencies === null || dependencies.length === 0) {
|
|
905
904
|
return compileDeclareClassMetadata(metadata);
|
|
906
905
|
}
|
|
907
|
-
const definitionMap = new
|
|
908
|
-
const callbackReturnDefinitionMap = new
|
|
906
|
+
const definitionMap = new checker.DefinitionMap();
|
|
907
|
+
const callbackReturnDefinitionMap = new checker.DefinitionMap();
|
|
909
908
|
callbackReturnDefinitionMap.set('decorators', metadata.decorators);
|
|
910
|
-
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ??
|
|
911
|
-
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ??
|
|
912
|
-
definitionMap.set('minVersion',
|
|
913
|
-
definitionMap.set('version',
|
|
914
|
-
definitionMap.set('ngImport',
|
|
909
|
+
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? checker.literal(null));
|
|
910
|
+
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? checker.literal(null));
|
|
911
|
+
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
|
|
912
|
+
definitionMap.set('version', checker.literal('20.0.1'));
|
|
913
|
+
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
915
914
|
definitionMap.set('type', metadata.type);
|
|
916
915
|
definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
|
|
917
|
-
definitionMap.set('resolveMetadata',
|
|
918
|
-
return
|
|
916
|
+
definitionMap.set('resolveMetadata', checker.arrowFn(dependencies.map((dep) => new checker.FnParam(dep.symbolName, checker.DYNAMIC_TYPE)), callbackReturnDefinitionMap.toLiteralMap()));
|
|
917
|
+
return checker.importExpr(checker.Identifiers.declareClassMetadataAsync).callFn([definitionMap.toLiteralMap()]);
|
|
919
918
|
}
|
|
920
919
|
|
|
921
920
|
/**
|
|
@@ -931,7 +930,7 @@ function toOptionalLiteralArray(values, mapper) {
|
|
|
931
930
|
if (values === null || values.length === 0) {
|
|
932
931
|
return null;
|
|
933
932
|
}
|
|
934
|
-
return
|
|
933
|
+
return checker.literalArr(values.map((value) => mapper(value)));
|
|
935
934
|
}
|
|
936
935
|
/**
|
|
937
936
|
* Creates an object literal expression from the given object, mapping all values to an expression
|
|
@@ -948,7 +947,7 @@ function toOptionalLiteralMap(object, mapper) {
|
|
|
948
947
|
return { key, value: mapper(value), quoted: true };
|
|
949
948
|
});
|
|
950
949
|
if (entries.length > 0) {
|
|
951
|
-
return
|
|
950
|
+
return checker.literalMap(entries);
|
|
952
951
|
}
|
|
953
952
|
else {
|
|
954
953
|
return null;
|
|
@@ -958,32 +957,32 @@ function compileDependencies(deps) {
|
|
|
958
957
|
if (deps === 'invalid') {
|
|
959
958
|
// The `deps` can be set to the string "invalid" by the `unwrapConstructorDependencies()`
|
|
960
959
|
// function, which tries to convert `ConstructorDeps` into `R3DependencyMetadata[]`.
|
|
961
|
-
return
|
|
960
|
+
return checker.literal('invalid');
|
|
962
961
|
}
|
|
963
962
|
else if (deps === null) {
|
|
964
|
-
return
|
|
963
|
+
return checker.literal(null);
|
|
965
964
|
}
|
|
966
965
|
else {
|
|
967
|
-
return
|
|
966
|
+
return checker.literalArr(deps.map(compileDependency));
|
|
968
967
|
}
|
|
969
968
|
}
|
|
970
969
|
function compileDependency(dep) {
|
|
971
|
-
const depMeta = new
|
|
970
|
+
const depMeta = new checker.DefinitionMap();
|
|
972
971
|
depMeta.set('token', dep.token);
|
|
973
972
|
if (dep.attributeNameType !== null) {
|
|
974
|
-
depMeta.set('attribute',
|
|
973
|
+
depMeta.set('attribute', checker.literal(true));
|
|
975
974
|
}
|
|
976
975
|
if (dep.host) {
|
|
977
|
-
depMeta.set('host',
|
|
976
|
+
depMeta.set('host', checker.literal(true));
|
|
978
977
|
}
|
|
979
978
|
if (dep.optional) {
|
|
980
|
-
depMeta.set('optional',
|
|
979
|
+
depMeta.set('optional', checker.literal(true));
|
|
981
980
|
}
|
|
982
981
|
if (dep.self) {
|
|
983
|
-
depMeta.set('self',
|
|
982
|
+
depMeta.set('self', checker.literal(true));
|
|
984
983
|
}
|
|
985
984
|
if (dep.skipSelf) {
|
|
986
|
-
depMeta.set('skipSelf',
|
|
985
|
+
depMeta.set('skipSelf', checker.literal(true));
|
|
987
986
|
}
|
|
988
987
|
return depMeta.toLiteralMap();
|
|
989
988
|
}
|
|
@@ -993,8 +992,8 @@ function compileDependency(dep) {
|
|
|
993
992
|
*/
|
|
994
993
|
function compileDeclareDirectiveFromMetadata(meta) {
|
|
995
994
|
const definitionMap = createDirectiveDefinitionMap(meta);
|
|
996
|
-
const expression =
|
|
997
|
-
const type =
|
|
995
|
+
const expression = checker.importExpr(checker.Identifiers.declareDirective).callFn([definitionMap.toLiteralMap()]);
|
|
996
|
+
const type = checker.createDirectiveType(meta);
|
|
998
997
|
return { expression, type, statements: [] };
|
|
999
998
|
}
|
|
1000
999
|
/**
|
|
@@ -1002,47 +1001,47 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
1002
1001
|
* this logic for components, as they extend the directive metadata.
|
|
1003
1002
|
*/
|
|
1004
1003
|
function createDirectiveDefinitionMap(meta) {
|
|
1005
|
-
const definitionMap = new
|
|
1004
|
+
const definitionMap = new checker.DefinitionMap();
|
|
1006
1005
|
const minVersion = getMinimumVersionForPartialOutput(meta);
|
|
1007
|
-
definitionMap.set('minVersion',
|
|
1008
|
-
definitionMap.set('version',
|
|
1006
|
+
definitionMap.set('minVersion', checker.literal(minVersion));
|
|
1007
|
+
definitionMap.set('version', checker.literal('20.0.1'));
|
|
1009
1008
|
// e.g. `type: MyDirective`
|
|
1010
1009
|
definitionMap.set('type', meta.type.value);
|
|
1011
1010
|
if (meta.isStandalone !== undefined) {
|
|
1012
|
-
definitionMap.set('isStandalone',
|
|
1011
|
+
definitionMap.set('isStandalone', checker.literal(meta.isStandalone));
|
|
1013
1012
|
}
|
|
1014
1013
|
if (meta.isSignal) {
|
|
1015
|
-
definitionMap.set('isSignal',
|
|
1014
|
+
definitionMap.set('isSignal', checker.literal(meta.isSignal));
|
|
1016
1015
|
}
|
|
1017
1016
|
// e.g. `selector: 'some-dir'`
|
|
1018
1017
|
if (meta.selector !== null) {
|
|
1019
|
-
definitionMap.set('selector',
|
|
1018
|
+
definitionMap.set('selector', checker.literal(meta.selector));
|
|
1020
1019
|
}
|
|
1021
1020
|
definitionMap.set('inputs', needsNewInputPartialOutput(meta)
|
|
1022
1021
|
? createInputsPartialMetadata(meta.inputs)
|
|
1023
1022
|
: legacyInputsPartialMetadata(meta.inputs));
|
|
1024
|
-
definitionMap.set('outputs',
|
|
1023
|
+
definitionMap.set('outputs', checker.conditionallyCreateDirectiveBindingLiteral(meta.outputs));
|
|
1025
1024
|
definitionMap.set('host', compileHostMetadata(meta.host));
|
|
1026
1025
|
definitionMap.set('providers', meta.providers);
|
|
1027
1026
|
if (meta.queries.length > 0) {
|
|
1028
|
-
definitionMap.set('queries',
|
|
1027
|
+
definitionMap.set('queries', checker.literalArr(meta.queries.map(compileQuery)));
|
|
1029
1028
|
}
|
|
1030
1029
|
if (meta.viewQueries.length > 0) {
|
|
1031
|
-
definitionMap.set('viewQueries',
|
|
1030
|
+
definitionMap.set('viewQueries', checker.literalArr(meta.viewQueries.map(compileQuery)));
|
|
1032
1031
|
}
|
|
1033
1032
|
if (meta.exportAs !== null) {
|
|
1034
|
-
definitionMap.set('exportAs',
|
|
1033
|
+
definitionMap.set('exportAs', checker.asLiteral(meta.exportAs));
|
|
1035
1034
|
}
|
|
1036
1035
|
if (meta.usesInheritance) {
|
|
1037
|
-
definitionMap.set('usesInheritance',
|
|
1036
|
+
definitionMap.set('usesInheritance', checker.literal(true));
|
|
1038
1037
|
}
|
|
1039
1038
|
if (meta.lifecycle.usesOnChanges) {
|
|
1040
|
-
definitionMap.set('usesOnChanges',
|
|
1039
|
+
definitionMap.set('usesOnChanges', checker.literal(true));
|
|
1041
1040
|
}
|
|
1042
1041
|
if (meta.hostDirectives?.length) {
|
|
1043
1042
|
definitionMap.set('hostDirectives', createHostDirectives(meta.hostDirectives));
|
|
1044
1043
|
}
|
|
1045
|
-
definitionMap.set('ngImport',
|
|
1044
|
+
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1046
1045
|
return definitionMap;
|
|
1047
1046
|
}
|
|
1048
1047
|
/**
|
|
@@ -1093,28 +1092,28 @@ function needsNewInputPartialOutput(meta) {
|
|
|
1093
1092
|
* by `R3DeclareQueryMetadata`.
|
|
1094
1093
|
*/
|
|
1095
1094
|
function compileQuery(query) {
|
|
1096
|
-
const meta = new
|
|
1097
|
-
meta.set('propertyName',
|
|
1095
|
+
const meta = new checker.DefinitionMap();
|
|
1096
|
+
meta.set('propertyName', checker.literal(query.propertyName));
|
|
1098
1097
|
if (query.first) {
|
|
1099
|
-
meta.set('first',
|
|
1098
|
+
meta.set('first', checker.literal(true));
|
|
1100
1099
|
}
|
|
1101
1100
|
meta.set('predicate', Array.isArray(query.predicate)
|
|
1102
|
-
?
|
|
1103
|
-
:
|
|
1101
|
+
? checker.asLiteral(query.predicate)
|
|
1102
|
+
: checker.convertFromMaybeForwardRefExpression(query.predicate));
|
|
1104
1103
|
if (!query.emitDistinctChangesOnly) {
|
|
1105
1104
|
// `emitDistinctChangesOnly` is special because we expect it to be `true`.
|
|
1106
1105
|
// Therefore we explicitly emit the field, and explicitly place it only when it's `false`.
|
|
1107
|
-
meta.set('emitDistinctChangesOnly',
|
|
1106
|
+
meta.set('emitDistinctChangesOnly', checker.literal(false));
|
|
1108
1107
|
}
|
|
1109
1108
|
if (query.descendants) {
|
|
1110
|
-
meta.set('descendants',
|
|
1109
|
+
meta.set('descendants', checker.literal(true));
|
|
1111
1110
|
}
|
|
1112
1111
|
meta.set('read', query.read);
|
|
1113
1112
|
if (query.static) {
|
|
1114
|
-
meta.set('static',
|
|
1113
|
+
meta.set('static', checker.literal(true));
|
|
1115
1114
|
}
|
|
1116
1115
|
if (query.isSignal) {
|
|
1117
|
-
meta.set('isSignal',
|
|
1116
|
+
meta.set('isSignal', checker.literal(true));
|
|
1118
1117
|
}
|
|
1119
1118
|
return meta.toLiteralMap();
|
|
1120
1119
|
}
|
|
@@ -1123,15 +1122,15 @@ function compileQuery(query) {
|
|
|
1123
1122
|
* in `R3DeclareDirectiveMetadata['host']`
|
|
1124
1123
|
*/
|
|
1125
1124
|
function compileHostMetadata(meta) {
|
|
1126
|
-
const hostMetadata = new
|
|
1125
|
+
const hostMetadata = new checker.DefinitionMap();
|
|
1127
1126
|
hostMetadata.set('attributes', toOptionalLiteralMap(meta.attributes, (expression) => expression));
|
|
1128
|
-
hostMetadata.set('listeners', toOptionalLiteralMap(meta.listeners,
|
|
1129
|
-
hostMetadata.set('properties', toOptionalLiteralMap(meta.properties,
|
|
1127
|
+
hostMetadata.set('listeners', toOptionalLiteralMap(meta.listeners, checker.literal));
|
|
1128
|
+
hostMetadata.set('properties', toOptionalLiteralMap(meta.properties, checker.literal));
|
|
1130
1129
|
if (meta.specialAttributes.styleAttr) {
|
|
1131
|
-
hostMetadata.set('styleAttribute',
|
|
1130
|
+
hostMetadata.set('styleAttribute', checker.literal(meta.specialAttributes.styleAttr));
|
|
1132
1131
|
}
|
|
1133
1132
|
if (meta.specialAttributes.classAttr) {
|
|
1134
|
-
hostMetadata.set('classAttribute',
|
|
1133
|
+
hostMetadata.set('classAttribute', checker.literal(meta.specialAttributes.classAttr));
|
|
1135
1134
|
}
|
|
1136
1135
|
if (hostMetadata.values.length > 0) {
|
|
1137
1136
|
return hostMetadata.toLiteralMap();
|
|
@@ -1146,14 +1145,14 @@ function createHostDirectives(hostDirectives) {
|
|
|
1146
1145
|
{
|
|
1147
1146
|
key: 'directive',
|
|
1148
1147
|
value: current.isForwardReference
|
|
1149
|
-
?
|
|
1148
|
+
? checker.generateForwardRef(current.directive.type)
|
|
1150
1149
|
: current.directive.type,
|
|
1151
1150
|
quoted: false,
|
|
1152
1151
|
},
|
|
1153
1152
|
];
|
|
1154
|
-
const inputsLiteral = current.inputs ?
|
|
1153
|
+
const inputsLiteral = current.inputs ? checker.createHostDirectivesMappingArray(current.inputs) : null;
|
|
1155
1154
|
const outputsLiteral = current.outputs
|
|
1156
|
-
?
|
|
1155
|
+
? checker.createHostDirectivesMappingArray(current.outputs)
|
|
1157
1156
|
: null;
|
|
1158
1157
|
if (inputsLiteral) {
|
|
1159
1158
|
keys.push({ key: 'inputs', value: inputsLiteral, quoted: false });
|
|
@@ -1161,11 +1160,11 @@ function createHostDirectives(hostDirectives) {
|
|
|
1161
1160
|
if (outputsLiteral) {
|
|
1162
1161
|
keys.push({ key: 'outputs', value: outputsLiteral, quoted: false });
|
|
1163
1162
|
}
|
|
1164
|
-
return
|
|
1163
|
+
return checker.literalMap(keys);
|
|
1165
1164
|
});
|
|
1166
1165
|
// If there's a forward reference, we generate a `function() { return [{directive: HostDir}] }`,
|
|
1167
1166
|
// otherwise we can save some bytes by using a plain array, e.g. `[{directive: HostDir}]`.
|
|
1168
|
-
return
|
|
1167
|
+
return checker.literalArr(expressions);
|
|
1169
1168
|
}
|
|
1170
1169
|
/**
|
|
1171
1170
|
* Generates partial output metadata for inputs of a directive.
|
|
@@ -1177,18 +1176,18 @@ function createInputsPartialMetadata(inputs) {
|
|
|
1177
1176
|
if (keys.length === 0) {
|
|
1178
1177
|
return null;
|
|
1179
1178
|
}
|
|
1180
|
-
return
|
|
1179
|
+
return checker.literalMap(keys.map((declaredName) => {
|
|
1181
1180
|
const value = inputs[declaredName];
|
|
1182
1181
|
return {
|
|
1183
1182
|
key: declaredName,
|
|
1184
1183
|
// put quotes around keys that contain potentially unsafe characters
|
|
1185
|
-
quoted:
|
|
1186
|
-
value:
|
|
1187
|
-
{ key: 'classPropertyName', quoted: false, value:
|
|
1188
|
-
{ key: 'publicName', quoted: false, value:
|
|
1189
|
-
{ key: 'isSignal', quoted: false, value:
|
|
1190
|
-
{ key: 'isRequired', quoted: false, value:
|
|
1191
|
-
{ key: 'transformFunction', quoted: false, value: value.transformFunction ??
|
|
1184
|
+
quoted: checker.UNSAFE_OBJECT_KEY_NAME_REGEXP.test(declaredName),
|
|
1185
|
+
value: checker.literalMap([
|
|
1186
|
+
{ key: 'classPropertyName', quoted: false, value: checker.asLiteral(value.classPropertyName) },
|
|
1187
|
+
{ key: 'publicName', quoted: false, value: checker.asLiteral(value.bindingPropertyName) },
|
|
1188
|
+
{ key: 'isSignal', quoted: false, value: checker.asLiteral(value.isSignal) },
|
|
1189
|
+
{ key: 'isRequired', quoted: false, value: checker.asLiteral(value.required) },
|
|
1190
|
+
{ key: 'transformFunction', quoted: false, value: value.transformFunction ?? checker.NULL_EXPR },
|
|
1192
1191
|
]),
|
|
1193
1192
|
};
|
|
1194
1193
|
}));
|
|
@@ -1212,25 +1211,25 @@ function legacyInputsPartialMetadata(inputs) {
|
|
|
1212
1211
|
if (keys.length === 0) {
|
|
1213
1212
|
return null;
|
|
1214
1213
|
}
|
|
1215
|
-
return
|
|
1214
|
+
return checker.literalMap(keys.map((declaredName) => {
|
|
1216
1215
|
const value = inputs[declaredName];
|
|
1217
1216
|
const publicName = value.bindingPropertyName;
|
|
1218
1217
|
const differentDeclaringName = publicName !== declaredName;
|
|
1219
1218
|
let result;
|
|
1220
1219
|
if (differentDeclaringName || value.transformFunction !== null) {
|
|
1221
|
-
const values = [
|
|
1220
|
+
const values = [checker.asLiteral(publicName), checker.asLiteral(declaredName)];
|
|
1222
1221
|
if (value.transformFunction !== null) {
|
|
1223
1222
|
values.push(value.transformFunction);
|
|
1224
1223
|
}
|
|
1225
|
-
result =
|
|
1224
|
+
result = checker.literalArr(values);
|
|
1226
1225
|
}
|
|
1227
1226
|
else {
|
|
1228
|
-
result =
|
|
1227
|
+
result = checker.asLiteral(publicName);
|
|
1229
1228
|
}
|
|
1230
1229
|
return {
|
|
1231
1230
|
key: declaredName,
|
|
1232
1231
|
// put quotes around keys that contain potentially unsafe characters
|
|
1233
|
-
quoted:
|
|
1232
|
+
quoted: checker.UNSAFE_OBJECT_KEY_NAME_REGEXP.test(declaredName),
|
|
1234
1233
|
value: result,
|
|
1235
1234
|
};
|
|
1236
1235
|
}));
|
|
@@ -1241,8 +1240,8 @@ function legacyInputsPartialMetadata(inputs) {
|
|
|
1241
1240
|
*/
|
|
1242
1241
|
function compileDeclareComponentFromMetadata(meta, template, additionalTemplateInfo) {
|
|
1243
1242
|
const definitionMap = createComponentDefinitionMap(meta, template, additionalTemplateInfo);
|
|
1244
|
-
const expression =
|
|
1245
|
-
const type =
|
|
1243
|
+
const expression = checker.importExpr(checker.Identifiers.declareComponent).callFn([definitionMap.toLiteralMap()]);
|
|
1244
|
+
const type = checker.createComponentType(meta);
|
|
1246
1245
|
return { expression, type, statements: [] };
|
|
1247
1246
|
}
|
|
1248
1247
|
/**
|
|
@@ -1251,17 +1250,17 @@ function compileDeclareComponentFromMetadata(meta, template, additionalTemplateI
|
|
|
1251
1250
|
function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
1252
1251
|
const definitionMap = createDirectiveDefinitionMap(meta);
|
|
1253
1252
|
const blockVisitor = new BlockPresenceVisitor();
|
|
1254
|
-
|
|
1253
|
+
checker.visitAll(blockVisitor, template.nodes);
|
|
1255
1254
|
definitionMap.set('template', getTemplateExpression(template, templateInfo));
|
|
1256
1255
|
if (templateInfo.isInline) {
|
|
1257
|
-
definitionMap.set('isInline',
|
|
1256
|
+
definitionMap.set('isInline', checker.literal(true));
|
|
1258
1257
|
}
|
|
1259
1258
|
// Set the minVersion to 17.0.0 if the component is using at least one block in its template.
|
|
1260
1259
|
// We don't do this for templates without blocks, in order to preserve backwards compatibility.
|
|
1261
1260
|
if (blockVisitor.hasBlocks) {
|
|
1262
|
-
definitionMap.set('minVersion',
|
|
1261
|
+
definitionMap.set('minVersion', checker.literal('17.0.0'));
|
|
1263
1262
|
}
|
|
1264
|
-
definitionMap.set('styles', toOptionalLiteralArray(meta.styles,
|
|
1263
|
+
definitionMap.set('styles', toOptionalLiteralArray(meta.styles, checker.literal));
|
|
1265
1264
|
definitionMap.set('dependencies', compileUsedDependenciesMetadata(meta));
|
|
1266
1265
|
definitionMap.set('viewProviders', meta.viewProviders);
|
|
1267
1266
|
definitionMap.set('animations', meta.animations);
|
|
@@ -1269,17 +1268,17 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
1269
1268
|
if (typeof meta.changeDetection === 'object') {
|
|
1270
1269
|
throw new Error('Impossible state! Change detection flag is not resolved!');
|
|
1271
1270
|
}
|
|
1272
|
-
definitionMap.set('changeDetection',
|
|
1273
|
-
.prop(
|
|
1271
|
+
definitionMap.set('changeDetection', checker.importExpr(checker.Identifiers.ChangeDetectionStrategy)
|
|
1272
|
+
.prop(checker.ChangeDetectionStrategy[meta.changeDetection]));
|
|
1274
1273
|
}
|
|
1275
|
-
if (meta.encapsulation !==
|
|
1276
|
-
definitionMap.set('encapsulation',
|
|
1274
|
+
if (meta.encapsulation !== checker.ViewEncapsulation.Emulated) {
|
|
1275
|
+
definitionMap.set('encapsulation', checker.importExpr(checker.Identifiers.ViewEncapsulation).prop(checker.ViewEncapsulation[meta.encapsulation]));
|
|
1277
1276
|
}
|
|
1278
|
-
if (meta.interpolation !==
|
|
1279
|
-
definitionMap.set('interpolation',
|
|
1277
|
+
if (meta.interpolation !== checker.DEFAULT_INTERPOLATION_CONFIG) {
|
|
1278
|
+
definitionMap.set('interpolation', checker.literalArr([checker.literal(meta.interpolation.start), checker.literal(meta.interpolation.end)]));
|
|
1280
1279
|
}
|
|
1281
1280
|
if (template.preserveWhitespaces === true) {
|
|
1282
|
-
definitionMap.set('preserveWhitespaces',
|
|
1281
|
+
definitionMap.set('preserveWhitespaces', checker.literal(true));
|
|
1283
1282
|
}
|
|
1284
1283
|
if (meta.defer.mode === 0 /* DeferBlockDepsEmitMode.PerBlock */) {
|
|
1285
1284
|
const resolvers = [];
|
|
@@ -1289,7 +1288,7 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
1289
1288
|
// defer resolver functions to defer blocks happens by index and not adding an array
|
|
1290
1289
|
// entry for a block can throw off the blocks coming after it.
|
|
1291
1290
|
if (deps === null) {
|
|
1292
|
-
resolvers.push(
|
|
1291
|
+
resolvers.push(checker.literal(null));
|
|
1293
1292
|
}
|
|
1294
1293
|
else {
|
|
1295
1294
|
resolvers.push(deps);
|
|
@@ -1298,7 +1297,7 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
1298
1297
|
}
|
|
1299
1298
|
// If *all* the resolvers are null, we can skip the field.
|
|
1300
1299
|
if (hasResolvers) {
|
|
1301
|
-
definitionMap.set('deferBlockDependencies',
|
|
1300
|
+
definitionMap.set('deferBlockDependencies', checker.literalArr(resolvers));
|
|
1302
1301
|
}
|
|
1303
1302
|
}
|
|
1304
1303
|
else {
|
|
@@ -1319,16 +1318,16 @@ function getTemplateExpression(template, templateInfo) {
|
|
|
1319
1318
|
// that we cannot use the expression defining the template because the linker expects the template
|
|
1320
1319
|
// to be defined as a literal in the declaration.
|
|
1321
1320
|
if (templateInfo.isInline) {
|
|
1322
|
-
return
|
|
1321
|
+
return checker.literal(templateInfo.content, null, null);
|
|
1323
1322
|
}
|
|
1324
1323
|
// The template is external so we must synthesize an expression node with
|
|
1325
1324
|
// the appropriate source-span.
|
|
1326
1325
|
const contents = templateInfo.content;
|
|
1327
|
-
const file = new
|
|
1328
|
-
const start = new
|
|
1326
|
+
const file = new checker.ParseSourceFile(contents, templateInfo.sourceUrl);
|
|
1327
|
+
const start = new checker.ParseLocation(file, 0, 0, 0);
|
|
1329
1328
|
const end = computeEndLocation(file, contents);
|
|
1330
|
-
const span = new
|
|
1331
|
-
return
|
|
1329
|
+
const span = new checker.ParseSourceSpan(start, end);
|
|
1330
|
+
return checker.literal(contents, null, span);
|
|
1332
1331
|
}
|
|
1333
1332
|
function computeEndLocation(file, contents) {
|
|
1334
1333
|
const length = contents.length;
|
|
@@ -1342,41 +1341,41 @@ function computeEndLocation(file, contents) {
|
|
|
1342
1341
|
line++;
|
|
1343
1342
|
}
|
|
1344
1343
|
} while (lineStart !== -1);
|
|
1345
|
-
return new
|
|
1344
|
+
return new checker.ParseLocation(file, length, line, length - lastLineStart);
|
|
1346
1345
|
}
|
|
1347
1346
|
function compileUsedDependenciesMetadata(meta) {
|
|
1348
1347
|
const wrapType = meta.declarationListEmitMode !== 0 /* DeclarationListEmitMode.Direct */
|
|
1349
|
-
?
|
|
1348
|
+
? checker.generateForwardRef
|
|
1350
1349
|
: (expr) => expr;
|
|
1351
1350
|
if (meta.declarationListEmitMode === 3 /* DeclarationListEmitMode.RuntimeResolved */) {
|
|
1352
1351
|
throw new Error(`Unsupported emit mode`);
|
|
1353
1352
|
}
|
|
1354
1353
|
return toOptionalLiteralArray(meta.declarations, (decl) => {
|
|
1355
1354
|
switch (decl.kind) {
|
|
1356
|
-
case
|
|
1357
|
-
const dirMeta = new
|
|
1358
|
-
dirMeta.set('kind',
|
|
1355
|
+
case checker.R3TemplateDependencyKind.Directive:
|
|
1356
|
+
const dirMeta = new checker.DefinitionMap();
|
|
1357
|
+
dirMeta.set('kind', checker.literal(decl.isComponent ? 'component' : 'directive'));
|
|
1359
1358
|
dirMeta.set('type', wrapType(decl.type));
|
|
1360
|
-
dirMeta.set('selector',
|
|
1361
|
-
dirMeta.set('inputs', toOptionalLiteralArray(decl.inputs,
|
|
1362
|
-
dirMeta.set('outputs', toOptionalLiteralArray(decl.outputs,
|
|
1363
|
-
dirMeta.set('exportAs', toOptionalLiteralArray(decl.exportAs,
|
|
1359
|
+
dirMeta.set('selector', checker.literal(decl.selector));
|
|
1360
|
+
dirMeta.set('inputs', toOptionalLiteralArray(decl.inputs, checker.literal));
|
|
1361
|
+
dirMeta.set('outputs', toOptionalLiteralArray(decl.outputs, checker.literal));
|
|
1362
|
+
dirMeta.set('exportAs', toOptionalLiteralArray(decl.exportAs, checker.literal));
|
|
1364
1363
|
return dirMeta.toLiteralMap();
|
|
1365
|
-
case
|
|
1366
|
-
const pipeMeta = new
|
|
1367
|
-
pipeMeta.set('kind',
|
|
1364
|
+
case checker.R3TemplateDependencyKind.Pipe:
|
|
1365
|
+
const pipeMeta = new checker.DefinitionMap();
|
|
1366
|
+
pipeMeta.set('kind', checker.literal('pipe'));
|
|
1368
1367
|
pipeMeta.set('type', wrapType(decl.type));
|
|
1369
|
-
pipeMeta.set('name',
|
|
1368
|
+
pipeMeta.set('name', checker.literal(decl.name));
|
|
1370
1369
|
return pipeMeta.toLiteralMap();
|
|
1371
|
-
case
|
|
1372
|
-
const ngModuleMeta = new
|
|
1373
|
-
ngModuleMeta.set('kind',
|
|
1370
|
+
case checker.R3TemplateDependencyKind.NgModule:
|
|
1371
|
+
const ngModuleMeta = new checker.DefinitionMap();
|
|
1372
|
+
ngModuleMeta.set('kind', checker.literal('ngmodule'));
|
|
1374
1373
|
ngModuleMeta.set('type', wrapType(decl.type));
|
|
1375
1374
|
return ngModuleMeta.toLiteralMap();
|
|
1376
1375
|
}
|
|
1377
1376
|
});
|
|
1378
1377
|
}
|
|
1379
|
-
class BlockPresenceVisitor extends
|
|
1378
|
+
class BlockPresenceVisitor extends checker.RecursiveVisitor {
|
|
1380
1379
|
hasBlocks = false;
|
|
1381
1380
|
visitDeferredBlock() {
|
|
1382
1381
|
this.hasBlocks = true;
|
|
@@ -1419,17 +1418,17 @@ class BlockPresenceVisitor extends compiler.RecursiveVisitor {
|
|
|
1419
1418
|
*/
|
|
1420
1419
|
const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
1421
1420
|
function compileDeclareFactoryFunction(meta) {
|
|
1422
|
-
const definitionMap = new
|
|
1423
|
-
definitionMap.set('minVersion',
|
|
1424
|
-
definitionMap.set('version',
|
|
1425
|
-
definitionMap.set('ngImport',
|
|
1421
|
+
const definitionMap = new checker.DefinitionMap();
|
|
1422
|
+
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
1423
|
+
definitionMap.set('version', checker.literal('20.0.1'));
|
|
1424
|
+
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1426
1425
|
definitionMap.set('type', meta.type.value);
|
|
1427
1426
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
1428
|
-
definitionMap.set('target',
|
|
1427
|
+
definitionMap.set('target', checker.importExpr(checker.Identifiers.FactoryTarget).prop(checker.FactoryTarget[meta.target]));
|
|
1429
1428
|
return {
|
|
1430
|
-
expression:
|
|
1429
|
+
expression: checker.importExpr(checker.Identifiers.declareFactory).callFn([definitionMap.toLiteralMap()]),
|
|
1431
1430
|
statements: [],
|
|
1432
|
-
type:
|
|
1431
|
+
type: checker.createFactoryType(meta),
|
|
1433
1432
|
};
|
|
1434
1433
|
}
|
|
1435
1434
|
|
|
@@ -1446,34 +1445,34 @@ const MINIMUM_PARTIAL_LINKER_VERSION$3 = '12.0.0';
|
|
|
1446
1445
|
*/
|
|
1447
1446
|
function compileDeclareInjectableFromMetadata(meta) {
|
|
1448
1447
|
const definitionMap = createInjectableDefinitionMap(meta);
|
|
1449
|
-
const expression =
|
|
1450
|
-
const type =
|
|
1448
|
+
const expression = checker.importExpr(checker.Identifiers.declareInjectable).callFn([definitionMap.toLiteralMap()]);
|
|
1449
|
+
const type = checker.createInjectableType(meta);
|
|
1451
1450
|
return { expression, type, statements: [] };
|
|
1452
1451
|
}
|
|
1453
1452
|
/**
|
|
1454
1453
|
* Gathers the declaration fields for a Injectable into a `DefinitionMap`.
|
|
1455
1454
|
*/
|
|
1456
1455
|
function createInjectableDefinitionMap(meta) {
|
|
1457
|
-
const definitionMap = new
|
|
1458
|
-
definitionMap.set('minVersion',
|
|
1459
|
-
definitionMap.set('version',
|
|
1460
|
-
definitionMap.set('ngImport',
|
|
1456
|
+
const definitionMap = new checker.DefinitionMap();
|
|
1457
|
+
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
1458
|
+
definitionMap.set('version', checker.literal('20.0.1'));
|
|
1459
|
+
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1461
1460
|
definitionMap.set('type', meta.type.value);
|
|
1462
1461
|
// Only generate providedIn property if it has a non-null value
|
|
1463
1462
|
if (meta.providedIn !== undefined) {
|
|
1464
|
-
const providedIn =
|
|
1463
|
+
const providedIn = checker.convertFromMaybeForwardRefExpression(meta.providedIn);
|
|
1465
1464
|
if (providedIn.value !== null) {
|
|
1466
1465
|
definitionMap.set('providedIn', providedIn);
|
|
1467
1466
|
}
|
|
1468
1467
|
}
|
|
1469
1468
|
if (meta.useClass !== undefined) {
|
|
1470
|
-
definitionMap.set('useClass',
|
|
1469
|
+
definitionMap.set('useClass', checker.convertFromMaybeForwardRefExpression(meta.useClass));
|
|
1471
1470
|
}
|
|
1472
1471
|
if (meta.useExisting !== undefined) {
|
|
1473
|
-
definitionMap.set('useExisting',
|
|
1472
|
+
definitionMap.set('useExisting', checker.convertFromMaybeForwardRefExpression(meta.useExisting));
|
|
1474
1473
|
}
|
|
1475
1474
|
if (meta.useValue !== undefined) {
|
|
1476
|
-
definitionMap.set('useValue',
|
|
1475
|
+
definitionMap.set('useValue', checker.convertFromMaybeForwardRefExpression(meta.useValue));
|
|
1477
1476
|
}
|
|
1478
1477
|
// Factories do not contain `ForwardRef`s since any types are already wrapped in a function call
|
|
1479
1478
|
// so the types will not be eagerly evaluated. Therefore we do not need to process this expression
|
|
@@ -1482,7 +1481,7 @@ function createInjectableDefinitionMap(meta) {
|
|
|
1482
1481
|
definitionMap.set('useFactory', meta.useFactory);
|
|
1483
1482
|
}
|
|
1484
1483
|
if (meta.deps !== undefined) {
|
|
1485
|
-
definitionMap.set('deps',
|
|
1484
|
+
definitionMap.set('deps', checker.literalArr(meta.deps.map(compileDependency)));
|
|
1486
1485
|
}
|
|
1487
1486
|
return definitionMap;
|
|
1488
1487
|
}
|
|
@@ -1497,22 +1496,22 @@ function createInjectableDefinitionMap(meta) {
|
|
|
1497
1496
|
const MINIMUM_PARTIAL_LINKER_VERSION$2 = '12.0.0';
|
|
1498
1497
|
function compileDeclareInjectorFromMetadata(meta) {
|
|
1499
1498
|
const definitionMap = createInjectorDefinitionMap(meta);
|
|
1500
|
-
const expression =
|
|
1501
|
-
const type =
|
|
1499
|
+
const expression = checker.importExpr(checker.Identifiers.declareInjector).callFn([definitionMap.toLiteralMap()]);
|
|
1500
|
+
const type = checker.createInjectorType(meta);
|
|
1502
1501
|
return { expression, type, statements: [] };
|
|
1503
1502
|
}
|
|
1504
1503
|
/**
|
|
1505
1504
|
* Gathers the declaration fields for an Injector into a `DefinitionMap`.
|
|
1506
1505
|
*/
|
|
1507
1506
|
function createInjectorDefinitionMap(meta) {
|
|
1508
|
-
const definitionMap = new
|
|
1509
|
-
definitionMap.set('minVersion',
|
|
1510
|
-
definitionMap.set('version',
|
|
1511
|
-
definitionMap.set('ngImport',
|
|
1507
|
+
const definitionMap = new checker.DefinitionMap();
|
|
1508
|
+
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
1509
|
+
definitionMap.set('version', checker.literal('20.0.1'));
|
|
1510
|
+
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1512
1511
|
definitionMap.set('type', meta.type.value);
|
|
1513
1512
|
definitionMap.set('providers', meta.providers);
|
|
1514
1513
|
if (meta.imports.length > 0) {
|
|
1515
|
-
definitionMap.set('imports',
|
|
1514
|
+
definitionMap.set('imports', checker.literalArr(meta.imports));
|
|
1516
1515
|
}
|
|
1517
1516
|
return definitionMap;
|
|
1518
1517
|
}
|
|
@@ -1527,40 +1526,40 @@ function createInjectorDefinitionMap(meta) {
|
|
|
1527
1526
|
const MINIMUM_PARTIAL_LINKER_VERSION$1 = '14.0.0';
|
|
1528
1527
|
function compileDeclareNgModuleFromMetadata(meta) {
|
|
1529
1528
|
const definitionMap = createNgModuleDefinitionMap(meta);
|
|
1530
|
-
const expression =
|
|
1531
|
-
const type =
|
|
1529
|
+
const expression = checker.importExpr(checker.Identifiers.declareNgModule).callFn([definitionMap.toLiteralMap()]);
|
|
1530
|
+
const type = checker.createNgModuleType(meta);
|
|
1532
1531
|
return { expression, type, statements: [] };
|
|
1533
1532
|
}
|
|
1534
1533
|
/**
|
|
1535
1534
|
* Gathers the declaration fields for an NgModule into a `DefinitionMap`.
|
|
1536
1535
|
*/
|
|
1537
1536
|
function createNgModuleDefinitionMap(meta) {
|
|
1538
|
-
const definitionMap = new
|
|
1539
|
-
if (meta.kind ===
|
|
1537
|
+
const definitionMap = new checker.DefinitionMap();
|
|
1538
|
+
if (meta.kind === checker.R3NgModuleMetadataKind.Local) {
|
|
1540
1539
|
throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
|
|
1541
1540
|
}
|
|
1542
|
-
definitionMap.set('minVersion',
|
|
1543
|
-
definitionMap.set('version',
|
|
1544
|
-
definitionMap.set('ngImport',
|
|
1541
|
+
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
1542
|
+
definitionMap.set('version', checker.literal('20.0.1'));
|
|
1543
|
+
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1545
1544
|
definitionMap.set('type', meta.type.value);
|
|
1546
1545
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
1547
1546
|
// We must wrap the arrays inside a function if any of the values are a forward reference to a
|
|
1548
1547
|
// not-yet-declared class. This is to support JIT execution of the `ɵɵngDeclareNgModule()` call.
|
|
1549
1548
|
// In the linker these wrappers are stripped and then reapplied for the `ɵɵdefineNgModule()` call.
|
|
1550
1549
|
if (meta.bootstrap.length > 0) {
|
|
1551
|
-
definitionMap.set('bootstrap',
|
|
1550
|
+
definitionMap.set('bootstrap', checker.refsToArray(meta.bootstrap, meta.containsForwardDecls));
|
|
1552
1551
|
}
|
|
1553
1552
|
if (meta.declarations.length > 0) {
|
|
1554
|
-
definitionMap.set('declarations',
|
|
1553
|
+
definitionMap.set('declarations', checker.refsToArray(meta.declarations, meta.containsForwardDecls));
|
|
1555
1554
|
}
|
|
1556
1555
|
if (meta.imports.length > 0) {
|
|
1557
|
-
definitionMap.set('imports',
|
|
1556
|
+
definitionMap.set('imports', checker.refsToArray(meta.imports, meta.containsForwardDecls));
|
|
1558
1557
|
}
|
|
1559
1558
|
if (meta.exports.length > 0) {
|
|
1560
|
-
definitionMap.set('exports',
|
|
1559
|
+
definitionMap.set('exports', checker.refsToArray(meta.exports, meta.containsForwardDecls));
|
|
1561
1560
|
}
|
|
1562
1561
|
if (meta.schemas !== null && meta.schemas.length > 0) {
|
|
1563
|
-
definitionMap.set('schemas',
|
|
1562
|
+
definitionMap.set('schemas', checker.literalArr(meta.schemas.map((ref) => ref.value)));
|
|
1564
1563
|
}
|
|
1565
1564
|
if (meta.id !== null) {
|
|
1566
1565
|
definitionMap.set('id', meta.id);
|
|
@@ -1581,28 +1580,28 @@ const MINIMUM_PARTIAL_LINKER_VERSION = '14.0.0';
|
|
|
1581
1580
|
*/
|
|
1582
1581
|
function compileDeclarePipeFromMetadata(meta) {
|
|
1583
1582
|
const definitionMap = createPipeDefinitionMap(meta);
|
|
1584
|
-
const expression =
|
|
1585
|
-
const type =
|
|
1583
|
+
const expression = checker.importExpr(checker.Identifiers.declarePipe).callFn([definitionMap.toLiteralMap()]);
|
|
1584
|
+
const type = checker.createPipeType(meta);
|
|
1586
1585
|
return { expression, type, statements: [] };
|
|
1587
1586
|
}
|
|
1588
1587
|
/**
|
|
1589
1588
|
* Gathers the declaration fields for a Pipe into a `DefinitionMap`.
|
|
1590
1589
|
*/
|
|
1591
1590
|
function createPipeDefinitionMap(meta) {
|
|
1592
|
-
const definitionMap = new
|
|
1593
|
-
definitionMap.set('minVersion',
|
|
1594
|
-
definitionMap.set('version',
|
|
1595
|
-
definitionMap.set('ngImport',
|
|
1591
|
+
const definitionMap = new checker.DefinitionMap();
|
|
1592
|
+
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
1593
|
+
definitionMap.set('version', checker.literal('20.0.1'));
|
|
1594
|
+
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1596
1595
|
// e.g. `type: MyPipe`
|
|
1597
1596
|
definitionMap.set('type', meta.type.value);
|
|
1598
1597
|
if (meta.isStandalone !== undefined) {
|
|
1599
|
-
definitionMap.set('isStandalone',
|
|
1598
|
+
definitionMap.set('isStandalone', checker.literal(meta.isStandalone));
|
|
1600
1599
|
}
|
|
1601
1600
|
// e.g. `name: "myPipe"`
|
|
1602
|
-
definitionMap.set('name',
|
|
1601
|
+
definitionMap.set('name', checker.literal(meta.pipeName));
|
|
1603
1602
|
if (meta.pure === false) {
|
|
1604
1603
|
// e.g. `pure: false`
|
|
1605
|
-
definitionMap.set('pure',
|
|
1604
|
+
definitionMap.set('pure', checker.literal(meta.pure));
|
|
1606
1605
|
}
|
|
1607
1606
|
return definitionMap;
|
|
1608
1607
|
}
|
|
@@ -1622,11 +1621,11 @@ function compileClassDebugInfo(debugInfo) {
|
|
|
1622
1621
|
}
|
|
1623
1622
|
// Include forbidOrphanRendering only if it's set to true (to reduce generated code)
|
|
1624
1623
|
if (debugInfo.forbidOrphanRendering) {
|
|
1625
|
-
debugInfoObject.forbidOrphanRendering =
|
|
1624
|
+
debugInfoObject.forbidOrphanRendering = checker.literal(true);
|
|
1626
1625
|
}
|
|
1627
|
-
const fnCall =
|
|
1628
|
-
.callFn([debugInfo.type,
|
|
1629
|
-
const iife =
|
|
1626
|
+
const fnCall = checker.importExpr(checker.Identifiers.setClassDebugInfo)
|
|
1627
|
+
.callFn([debugInfo.type, checker.mapLiteral(debugInfoObject)]);
|
|
1628
|
+
const iife = checker.arrowFn([], [checker.devOnlyGuardedExpression(fnCall).toStmt()]);
|
|
1630
1629
|
return iife.callFn([]);
|
|
1631
1630
|
}
|
|
1632
1631
|
|
|
@@ -1648,67 +1647,67 @@ function compileHmrInitializer(meta) {
|
|
|
1648
1647
|
const idName = 'id';
|
|
1649
1648
|
const importCallbackName = `${meta.className}_HmrLoad`;
|
|
1650
1649
|
const namespaces = meta.namespaceDependencies.map((dep) => {
|
|
1651
|
-
return new
|
|
1650
|
+
return new checker.ExternalExpr({ moduleName: dep.moduleName, name: null });
|
|
1652
1651
|
});
|
|
1653
1652
|
// m.default
|
|
1654
|
-
const defaultRead =
|
|
1653
|
+
const defaultRead = checker.variable(moduleName).prop('default');
|
|
1655
1654
|
// ɵɵreplaceMetadata(Comp, m.default, [...namespaces], [...locals], import.meta, id);
|
|
1656
|
-
const replaceCall =
|
|
1655
|
+
const replaceCall = checker.importExpr(checker.Identifiers.replaceMetadata)
|
|
1657
1656
|
.callFn([
|
|
1658
1657
|
meta.type,
|
|
1659
1658
|
defaultRead,
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1659
|
+
checker.literalArr(namespaces),
|
|
1660
|
+
checker.literalArr(meta.localDependencies.map((l) => l.runtimeRepresentation)),
|
|
1661
|
+
checker.variable('import').prop('meta'),
|
|
1662
|
+
checker.variable(idName),
|
|
1664
1663
|
]);
|
|
1665
1664
|
// (m) => m.default && ɵɵreplaceMetadata(...)
|
|
1666
|
-
const replaceCallback =
|
|
1665
|
+
const replaceCallback = checker.arrowFn([new checker.FnParam(moduleName)], defaultRead.and(replaceCall));
|
|
1667
1666
|
// getReplaceMetadataURL(id, timestamp, import.meta.url)
|
|
1668
|
-
const url =
|
|
1667
|
+
const url = checker.importExpr(checker.Identifiers.getReplaceMetadataURL)
|
|
1669
1668
|
.callFn([
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1669
|
+
checker.variable(idName),
|
|
1670
|
+
checker.variable(timestampName),
|
|
1671
|
+
checker.variable('import').prop('meta').prop('url'),
|
|
1673
1672
|
]);
|
|
1674
1673
|
// function Cmp_HmrLoad(t) {
|
|
1675
1674
|
// import(/* @vite-ignore */ url).then((m) => m.default && replaceMetadata(...));
|
|
1676
1675
|
// }
|
|
1677
|
-
const importCallback = new
|
|
1676
|
+
const importCallback = new checker.DeclareFunctionStmt(importCallbackName, [new checker.FnParam(timestampName)], [
|
|
1678
1677
|
// The vite-ignore special comment is required to prevent Vite from generating a superfluous
|
|
1679
1678
|
// warning for each usage within the development code. If Vite provides a method to
|
|
1680
1679
|
// programmatically avoid this warning in the future, this added comment can be removed here.
|
|
1681
|
-
new
|
|
1680
|
+
new checker.DynamicImportExpr(url, null, '@vite-ignore')
|
|
1682
1681
|
.prop('then')
|
|
1683
1682
|
.callFn([replaceCallback])
|
|
1684
1683
|
.toStmt(),
|
|
1685
|
-
], null,
|
|
1684
|
+
], null, checker.StmtModifier.Final);
|
|
1686
1685
|
// (d) => d.id === id && Cmp_HmrLoad(d.timestamp)
|
|
1687
|
-
const updateCallback =
|
|
1686
|
+
const updateCallback = checker.arrowFn([new checker.FnParam(dataName)], checker.variable(dataName)
|
|
1688
1687
|
.prop('id')
|
|
1689
|
-
.identical(
|
|
1690
|
-
.and(
|
|
1688
|
+
.identical(checker.variable(idName))
|
|
1689
|
+
.and(checker.variable(importCallbackName).callFn([checker.variable(dataName).prop('timestamp')])));
|
|
1691
1690
|
// Cmp_HmrLoad(Date.now());
|
|
1692
1691
|
// Initial call to kick off the loading in order to avoid edge cases with components
|
|
1693
1692
|
// coming from lazy chunks that change before the chunk has loaded.
|
|
1694
|
-
const initialCall =
|
|
1695
|
-
.callFn([
|
|
1693
|
+
const initialCall = checker.variable(importCallbackName)
|
|
1694
|
+
.callFn([checker.variable('Date').prop('now').callFn([])]);
|
|
1696
1695
|
// import.meta.hot
|
|
1697
|
-
const hotRead =
|
|
1696
|
+
const hotRead = checker.variable('import').prop('meta').prop('hot');
|
|
1698
1697
|
// import.meta.hot.on('angular:component-update', () => ...);
|
|
1699
1698
|
const hotListener = hotRead
|
|
1700
1699
|
.clone()
|
|
1701
1700
|
.prop('on')
|
|
1702
|
-
.callFn([
|
|
1703
|
-
return
|
|
1701
|
+
.callFn([checker.literal('angular:component-update'), updateCallback]);
|
|
1702
|
+
return checker.arrowFn([], [
|
|
1704
1703
|
// const id = <id>;
|
|
1705
|
-
new
|
|
1704
|
+
new checker.DeclareVarStmt(idName, checker.literal(encodeURIComponent(`${meta.filePath}@${meta.className}`)), null, checker.StmtModifier.Final),
|
|
1706
1705
|
// function Cmp_HmrLoad() {...}.
|
|
1707
1706
|
importCallback,
|
|
1708
1707
|
// ngDevMode && Cmp_HmrLoad(Date.now());
|
|
1709
|
-
|
|
1708
|
+
checker.devOnlyGuardedExpression(initialCall).toStmt(),
|
|
1710
1709
|
// ngDevMode && import.meta.hot && import.meta.hot.on(...)
|
|
1711
|
-
|
|
1710
|
+
checker.devOnlyGuardedExpression(hotRead.and(hotListener)).toStmt(),
|
|
1712
1711
|
])
|
|
1713
1712
|
.callFn([]);
|
|
1714
1713
|
}
|
|
@@ -1721,25 +1720,25 @@ function compileHmrInitializer(meta) {
|
|
|
1721
1720
|
*/
|
|
1722
1721
|
function compileHmrUpdateCallback(definitions, constantStatements, meta) {
|
|
1723
1722
|
const namespaces = 'ɵɵnamespaces';
|
|
1724
|
-
const params = [meta.className, namespaces].map((name) => new
|
|
1723
|
+
const params = [meta.className, namespaces].map((name) => new checker.FnParam(name, checker.DYNAMIC_TYPE));
|
|
1725
1724
|
const body = [];
|
|
1726
1725
|
for (const local of meta.localDependencies) {
|
|
1727
|
-
params.push(new
|
|
1726
|
+
params.push(new checker.FnParam(local.name));
|
|
1728
1727
|
}
|
|
1729
1728
|
// Declare variables that read out the individual namespaces.
|
|
1730
1729
|
for (let i = 0; i < meta.namespaceDependencies.length; i++) {
|
|
1731
|
-
body.push(new
|
|
1730
|
+
body.push(new checker.DeclareVarStmt(meta.namespaceDependencies[i].assignedName, checker.variable(namespaces).key(checker.literal(i)), checker.DYNAMIC_TYPE, checker.StmtModifier.Final));
|
|
1732
1731
|
}
|
|
1733
1732
|
body.push(...constantStatements);
|
|
1734
1733
|
for (const field of definitions) {
|
|
1735
1734
|
if (field.initializer !== null) {
|
|
1736
|
-
body.push(
|
|
1735
|
+
body.push(checker.variable(meta.className).prop(field.name).set(field.initializer).toStmt());
|
|
1737
1736
|
for (const stmt of field.statements) {
|
|
1738
1737
|
body.push(stmt);
|
|
1739
1738
|
}
|
|
1740
1739
|
}
|
|
1741
1740
|
}
|
|
1742
|
-
return new
|
|
1741
|
+
return new checker.DeclareFunctionStmt(`${meta.className}_UpdateMetadata`, params, body, null, checker.StmtModifier.Final);
|
|
1743
1742
|
}
|
|
1744
1743
|
|
|
1745
1744
|
/**
|
|
@@ -1792,7 +1791,7 @@ class UnifiedModulesAliasingHost {
|
|
|
1792
1791
|
}
|
|
1793
1792
|
// viaModule is the module it'll actually be imported from.
|
|
1794
1793
|
const moduleName = this.unifiedModulesHost.fileNameToModuleName(via.fileName, via.fileName);
|
|
1795
|
-
return new
|
|
1794
|
+
return new checker.ExternalExpr({ moduleName, name: this.aliasName(decl, via) });
|
|
1796
1795
|
}
|
|
1797
1796
|
/**
|
|
1798
1797
|
* Generates an alias name based on the full module name of the file which declares the aliased
|
|
@@ -4252,7 +4251,7 @@ class IvyTransformationVisitor extends Visitor {
|
|
|
4252
4251
|
* A transformer which operates on ts.SourceFiles and applies changes from an `IvyCompilation`.
|
|
4253
4252
|
*/
|
|
4254
4253
|
function transformIvySourceFile(compilation, context, reflector, importRewriter, localCompilationExtraImportsTracker, file, isCore, isClosureCompilerEnabled, recordWrappedNode) {
|
|
4255
|
-
const constantPool = new
|
|
4254
|
+
const constantPool = new checker.ConstantPool(isClosureCompilerEnabled);
|
|
4256
4255
|
const importManager = new checker.ImportManager({
|
|
4257
4256
|
...checker.presetImportManagerForceNamespaceImports,
|
|
4258
4257
|
rewriter: importRewriter,
|
|
@@ -4408,7 +4407,7 @@ function resolveEncapsulationEnumValueLocally(expr) {
|
|
|
4408
4407
|
return null;
|
|
4409
4408
|
}
|
|
4410
4409
|
const exprText = expr.getText().trim();
|
|
4411
|
-
for (const key in
|
|
4410
|
+
for (const key in checker.ViewEncapsulation) {
|
|
4412
4411
|
if (!Number.isNaN(Number(key))) {
|
|
4413
4412
|
continue;
|
|
4414
4413
|
}
|
|
@@ -4416,7 +4415,7 @@ function resolveEncapsulationEnumValueLocally(expr) {
|
|
|
4416
4415
|
// Check whether the enum is imported by name or used by import namespace (e.g.,
|
|
4417
4416
|
// core.ViewEncapsulation.None)
|
|
4418
4417
|
if (exprText === suffix || exprText.endsWith(`.${suffix}`)) {
|
|
4419
|
-
const ans = Number(
|
|
4418
|
+
const ans = Number(checker.ViewEncapsulation[key]);
|
|
4420
4419
|
return ans;
|
|
4421
4420
|
}
|
|
4422
4421
|
}
|
|
@@ -4442,7 +4441,7 @@ function resolveLiteral(decorator, literalCache) {
|
|
|
4442
4441
|
}
|
|
4443
4442
|
|
|
4444
4443
|
function compileNgFactoryDefField(metadata) {
|
|
4445
|
-
const res =
|
|
4444
|
+
const res = checker.compileFactoryFunction(metadata);
|
|
4446
4445
|
return {
|
|
4447
4446
|
name: 'ɵfac',
|
|
4448
4447
|
initializer: res.expression,
|
|
@@ -4527,13 +4526,13 @@ function extractClassMetadata(clazz, reflection, isCore, annotateForClosureCompi
|
|
|
4527
4526
|
if (ngClassDecorators.length === 0) {
|
|
4528
4527
|
return null;
|
|
4529
4528
|
}
|
|
4530
|
-
const metaDecorators = new
|
|
4529
|
+
const metaDecorators = new checker.WrappedNodeExpr(ts.factory.createArrayLiteralExpression(ngClassDecorators));
|
|
4531
4530
|
// Convert the constructor parameters to metadata, passing null if none are present.
|
|
4532
4531
|
let metaCtorParameters = null;
|
|
4533
4532
|
const classCtorParameters = reflection.getConstructorParameters(clazz);
|
|
4534
4533
|
if (classCtorParameters !== null) {
|
|
4535
4534
|
const ctorParameters = classCtorParameters.map((param) => ctorParameterToMetadata(param, isCore));
|
|
4536
|
-
metaCtorParameters = new
|
|
4535
|
+
metaCtorParameters = new checker.ArrowFunctionExpr([], new checker.LiteralArrayExpr(ctorParameters));
|
|
4537
4536
|
}
|
|
4538
4537
|
// Do the same for property decorators.
|
|
4539
4538
|
let metaPropDecorators = null;
|
|
@@ -4552,10 +4551,10 @@ function extractClassMetadata(clazz, reflection, isCore, annotateForClosureCompi
|
|
|
4552
4551
|
}
|
|
4553
4552
|
const decoratedMembers = classMembers.map((member) => classMemberToMetadata(member.nameNode ?? member.name, member.decorators, isCore));
|
|
4554
4553
|
if (decoratedMembers.length > 0) {
|
|
4555
|
-
metaPropDecorators = new
|
|
4554
|
+
metaPropDecorators = new checker.WrappedNodeExpr(ts.factory.createObjectLiteralExpression(decoratedMembers));
|
|
4556
4555
|
}
|
|
4557
4556
|
return {
|
|
4558
|
-
type: new
|
|
4557
|
+
type: new checker.WrappedNodeExpr(id),
|
|
4559
4558
|
decorators: metaDecorators,
|
|
4560
4559
|
ctorParameters: metaCtorParameters,
|
|
4561
4560
|
propDecorators: metaPropDecorators,
|
|
@@ -4569,7 +4568,7 @@ function ctorParameterToMetadata(param, isCore) {
|
|
|
4569
4568
|
// its type is undefined.
|
|
4570
4569
|
const type = param.typeValueReference.kind !== 2 /* TypeValueReferenceKind.UNAVAILABLE */
|
|
4571
4570
|
? checker.valueReferenceToExpression(param.typeValueReference)
|
|
4572
|
-
: new
|
|
4571
|
+
: new checker.LiteralExpr(undefined);
|
|
4573
4572
|
const mapEntries = [
|
|
4574
4573
|
{ key: 'type', value: type, quoted: false },
|
|
4575
4574
|
];
|
|
@@ -4578,10 +4577,10 @@ function ctorParameterToMetadata(param, isCore) {
|
|
|
4578
4577
|
const ngDecorators = param.decorators
|
|
4579
4578
|
.filter((dec) => isAngularDecorator$1(dec, isCore))
|
|
4580
4579
|
.map((decorator) => decoratorToMetadata(decorator));
|
|
4581
|
-
const value = new
|
|
4580
|
+
const value = new checker.WrappedNodeExpr(ts.factory.createArrayLiteralExpression(ngDecorators));
|
|
4582
4581
|
mapEntries.push({ key: 'decorators', value, quoted: false });
|
|
4583
4582
|
}
|
|
4584
|
-
return
|
|
4583
|
+
return checker.literalMap(mapEntries);
|
|
4585
4584
|
}
|
|
4586
4585
|
/**
|
|
4587
4586
|
* Convert a reflected class member to metadata.
|
|
@@ -4645,10 +4644,10 @@ function extractClassDebugInfo(clazz, reflection, compilerHost, rootDirs, forbid
|
|
|
4645
4644
|
const srcFile = clazz.getSourceFile();
|
|
4646
4645
|
const srcFileMaybeRelativePath = getProjectRelativePath(srcFile.fileName, rootDirs, compilerHost);
|
|
4647
4646
|
return {
|
|
4648
|
-
type: new
|
|
4649
|
-
className:
|
|
4650
|
-
filePath: srcFileMaybeRelativePath ?
|
|
4651
|
-
lineNumber:
|
|
4647
|
+
type: new checker.WrappedNodeExpr(clazz.name),
|
|
4648
|
+
className: checker.literal(clazz.name.getText()),
|
|
4649
|
+
filePath: srcFileMaybeRelativePath ? checker.literal(srcFileMaybeRelativePath) : null,
|
|
4650
|
+
lineNumber: checker.literal(srcFile.getLineAndCharacterOfPosition(clazz.name.pos).line + 1),
|
|
4652
4651
|
forbidOrphanRendering,
|
|
4653
4652
|
};
|
|
4654
4653
|
}
|
|
@@ -4679,10 +4678,10 @@ function extractSchemas(rawExpr, evaluator, context) {
|
|
|
4679
4678
|
// renamed when the user imported it, these names will match.
|
|
4680
4679
|
switch (id.text) {
|
|
4681
4680
|
case 'CUSTOM_ELEMENTS_SCHEMA':
|
|
4682
|
-
schemas.push(
|
|
4681
|
+
schemas.push(checker.CUSTOM_ELEMENTS_SCHEMA);
|
|
4683
4682
|
break;
|
|
4684
4683
|
case 'NO_ERRORS_SCHEMA':
|
|
4685
|
-
schemas.push(
|
|
4684
|
+
schemas.push(checker.NO_ERRORS_SCHEMA);
|
|
4686
4685
|
break;
|
|
4687
4686
|
default:
|
|
4688
4687
|
throw checker.createValueHasWrongTypeError(rawExpr, schemaRef, `'${schemaRef.debugName}' is not a valid ${context} schema`);
|
|
@@ -4707,7 +4706,7 @@ function compileInputTransformFields(inputs) {
|
|
|
4707
4706
|
if (input.transform) {
|
|
4708
4707
|
extraFields.push({
|
|
4709
4708
|
name: `ngAcceptInputType_${input.classPropertyName}`,
|
|
4710
|
-
type:
|
|
4709
|
+
type: checker.transplantedType(input.transform.type),
|
|
4711
4710
|
statements: [],
|
|
4712
4711
|
initializer: null,
|
|
4713
4712
|
deferrableImports: null,
|
|
@@ -4990,7 +4989,7 @@ class SemanticDepGraphUpdater {
|
|
|
4990
4989
|
}
|
|
4991
4990
|
}
|
|
4992
4991
|
function getImportPath(expr) {
|
|
4993
|
-
if (expr instanceof
|
|
4992
|
+
if (expr instanceof checker.ExternalExpr) {
|
|
4994
4993
|
return `${expr.value.moduleName}\$${expr.value.name}`;
|
|
4995
4994
|
}
|
|
4996
4995
|
else {
|
|
@@ -5758,7 +5757,7 @@ class LocalModuleScopeRegistry {
|
|
|
5758
5757
|
return;
|
|
5759
5758
|
}
|
|
5760
5759
|
if (!reexportMap.has(exportName)) {
|
|
5761
|
-
if (exportRef.alias && exportRef.alias instanceof
|
|
5760
|
+
if (exportRef.alias && exportRef.alias instanceof checker.ExternalExpr) {
|
|
5762
5761
|
reexports.push({
|
|
5763
5762
|
fromModule: exportRef.alias.value.moduleName,
|
|
5764
5763
|
symbolName: exportRef.alias.value.name,
|
|
@@ -5769,7 +5768,7 @@ class LocalModuleScopeRegistry {
|
|
|
5769
5768
|
const emittedRef = this.refEmitter.emit(exportRef.cloneWithNoIdentifiers(), sourceFile);
|
|
5770
5769
|
checker.assertSuccessfulReferenceEmit(emittedRef, ngModuleRef.node.name, 'class');
|
|
5771
5770
|
const expr = emittedRef.expression;
|
|
5772
|
-
if (!(expr instanceof
|
|
5771
|
+
if (!(expr instanceof checker.ExternalExpr) ||
|
|
5773
5772
|
expr.value.moduleName === null ||
|
|
5774
5773
|
expr.value.name === null) {
|
|
5775
5774
|
throw new Error('Expected ExternalExpr');
|
|
@@ -5908,7 +5907,7 @@ class TypeCheckScopeRegistry {
|
|
|
5908
5907
|
* an empty type-check scope is returned.
|
|
5909
5908
|
*/
|
|
5910
5909
|
getTypeCheckScope(node) {
|
|
5911
|
-
const matcher = new
|
|
5910
|
+
const matcher = new checker.SelectorMatcher();
|
|
5912
5911
|
const directives = [];
|
|
5913
5912
|
const pipes = new Map();
|
|
5914
5913
|
const scope = this.scopeReader.getScopeForComponent(node);
|
|
@@ -5941,7 +5940,7 @@ class TypeCheckScopeRegistry {
|
|
|
5941
5940
|
}
|
|
5942
5941
|
// Carry over the `isExplicitlyDeferred` flag from the dependency info.
|
|
5943
5942
|
const directiveMeta = this.applyExplicitlyDeferredFlag(extMeta, meta.isExplicitlyDeferred);
|
|
5944
|
-
matcher.addSelectables(
|
|
5943
|
+
matcher.addSelectables(checker.CssSelector.parse(meta.selector), [
|
|
5945
5944
|
...this.hostDirectivesResolver.resolve(directiveMeta),
|
|
5946
5945
|
directiveMeta,
|
|
5947
5946
|
]);
|
|
@@ -6757,7 +6756,7 @@ class DirectiveDecoratorHandler {
|
|
|
6757
6756
|
}
|
|
6758
6757
|
const hostElement = checker.createHostElement('directive', meta.meta.selector, node, meta.hostBindingNodes.literal, meta.hostBindingNodes.bindingDecorators, meta.hostBindingNodes.listenerDecorators);
|
|
6759
6758
|
if (hostElement !== null) {
|
|
6760
|
-
const binder = new
|
|
6759
|
+
const binder = new checker.R3TargetBinder(scope.matcher);
|
|
6761
6760
|
const hostBindingsContext = {
|
|
6762
6761
|
node: hostElement,
|
|
6763
6762
|
sourceMapping: { type: 'direct', node },
|
|
@@ -6774,7 +6773,7 @@ class DirectiveDecoratorHandler {
|
|
|
6774
6773
|
}
|
|
6775
6774
|
const diagnostics = [];
|
|
6776
6775
|
if (analysis.providersRequiringFactory !== null &&
|
|
6777
|
-
analysis.meta.providers instanceof
|
|
6776
|
+
analysis.meta.providers instanceof checker.WrappedNodeExpr) {
|
|
6778
6777
|
const providerDiagnostics = checker.getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
|
|
6779
6778
|
diagnostics.push(...providerDiagnostics);
|
|
6780
6779
|
}
|
|
@@ -6796,8 +6795,8 @@ class DirectiveDecoratorHandler {
|
|
|
6796
6795
|
return { data: {} };
|
|
6797
6796
|
}
|
|
6798
6797
|
compileFull(node, analysis, resolution, pool) {
|
|
6799
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
6800
|
-
const def =
|
|
6798
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, checker.FactoryTarget.Directive));
|
|
6799
|
+
const def = checker.compileDirectiveFromMetadata(analysis.meta, pool, checker.makeBindingParser());
|
|
6801
6800
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
6802
6801
|
const classMetadata = analysis.classMetadata !== null
|
|
6803
6802
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
@@ -6805,7 +6804,7 @@ class DirectiveDecoratorHandler {
|
|
|
6805
6804
|
return checker.compileResults(fac, def, classMetadata, 'ɵdir', inputTransformFields, null /* deferrableImports */);
|
|
6806
6805
|
}
|
|
6807
6806
|
compilePartial(node, analysis, resolution) {
|
|
6808
|
-
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta,
|
|
6807
|
+
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta, checker.FactoryTarget.Directive));
|
|
6809
6808
|
const def = compileDeclareDirectiveFromMetadata(analysis.meta);
|
|
6810
6809
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
6811
6810
|
const classMetadata = analysis.classMetadata !== null
|
|
@@ -6814,8 +6813,8 @@ class DirectiveDecoratorHandler {
|
|
|
6814
6813
|
return checker.compileResults(fac, def, classMetadata, 'ɵdir', inputTransformFields, null /* deferrableImports */);
|
|
6815
6814
|
}
|
|
6816
6815
|
compileLocal(node, analysis, resolution, pool) {
|
|
6817
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
6818
|
-
const def =
|
|
6816
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, checker.FactoryTarget.Directive));
|
|
6817
|
+
const def = checker.compileDirectiveFromMetadata(analysis.meta, pool, checker.makeBindingParser());
|
|
6819
6818
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
6820
6819
|
const classMetadata = analysis.classMetadata !== null
|
|
6821
6820
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
@@ -7217,7 +7216,7 @@ class NgModuleDecoratorHandler {
|
|
|
7217
7216
|
if (ngModule.has('id')) {
|
|
7218
7217
|
const idExpr = ngModule.get('id');
|
|
7219
7218
|
if (!isModuleIdExpression(idExpr)) {
|
|
7220
|
-
id = new
|
|
7219
|
+
id = new checker.WrappedNodeExpr(idExpr);
|
|
7221
7220
|
}
|
|
7222
7221
|
else {
|
|
7223
7222
|
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.`);
|
|
@@ -7248,23 +7247,23 @@ class NgModuleDecoratorHandler {
|
|
|
7248
7247
|
let ngModuleMetadata;
|
|
7249
7248
|
if (this.compilationMode === checker.CompilationMode.LOCAL) {
|
|
7250
7249
|
ngModuleMetadata = {
|
|
7251
|
-
kind:
|
|
7250
|
+
kind: checker.R3NgModuleMetadataKind.Local,
|
|
7252
7251
|
type,
|
|
7253
|
-
bootstrapExpression: rawBootstrap ? new
|
|
7254
|
-
declarationsExpression: rawDeclarations ? new
|
|
7255
|
-
exportsExpression: rawExports ? new
|
|
7256
|
-
importsExpression: rawImports ? new
|
|
7252
|
+
bootstrapExpression: rawBootstrap ? new checker.WrappedNodeExpr(rawBootstrap) : null,
|
|
7253
|
+
declarationsExpression: rawDeclarations ? new checker.WrappedNodeExpr(rawDeclarations) : null,
|
|
7254
|
+
exportsExpression: rawExports ? new checker.WrappedNodeExpr(rawExports) : null,
|
|
7255
|
+
importsExpression: rawImports ? new checker.WrappedNodeExpr(rawImports) : null,
|
|
7257
7256
|
id,
|
|
7258
7257
|
// Use `ɵɵsetNgModuleScope` to patch selector scopes onto the generated definition in a
|
|
7259
7258
|
// tree-shakeable way.
|
|
7260
|
-
selectorScopeMode:
|
|
7259
|
+
selectorScopeMode: checker.R3SelectorScopeMode.SideEffect,
|
|
7261
7260
|
// TODO: to be implemented as a part of FW-1004.
|
|
7262
7261
|
schemas: [],
|
|
7263
7262
|
};
|
|
7264
7263
|
}
|
|
7265
7264
|
else {
|
|
7266
7265
|
ngModuleMetadata = {
|
|
7267
|
-
kind:
|
|
7266
|
+
kind: checker.R3NgModuleMetadataKind.Global,
|
|
7268
7267
|
type,
|
|
7269
7268
|
bootstrap,
|
|
7270
7269
|
declarations,
|
|
@@ -7279,8 +7278,8 @@ class NgModuleDecoratorHandler {
|
|
|
7279
7278
|
// Use `ɵɵsetNgModuleScope` to patch selector scopes onto the generated definition in a
|
|
7280
7279
|
// tree-shakeable way.
|
|
7281
7280
|
selectorScopeMode: this.includeSelectorScope
|
|
7282
|
-
?
|
|
7283
|
-
:
|
|
7281
|
+
? checker.R3SelectorScopeMode.SideEffect
|
|
7282
|
+
: checker.R3SelectorScopeMode.Omit,
|
|
7284
7283
|
// TODO: to be implemented as a part of FW-1004.
|
|
7285
7284
|
schemas: [],
|
|
7286
7285
|
};
|
|
@@ -7291,7 +7290,7 @@ class NgModuleDecoratorHandler {
|
|
|
7291
7290
|
// and don't include the providers if it doesn't which saves us a few bytes.
|
|
7292
7291
|
if (rawProviders !== null &&
|
|
7293
7292
|
(!ts.isArrayLiteralExpression(rawProviders) || rawProviders.elements.length > 0)) {
|
|
7294
|
-
wrappedProviders = new
|
|
7293
|
+
wrappedProviders = new checker.WrappedNodeExpr(this.annotateForClosureCompiler
|
|
7295
7294
|
? checker.wrapFunctionExpressionsInParens(rawProviders)
|
|
7296
7295
|
: rawProviders);
|
|
7297
7296
|
}
|
|
@@ -7343,12 +7342,12 @@ class NgModuleDecoratorHandler {
|
|
|
7343
7342
|
if (ts.isArrayLiteralExpression(exp)) {
|
|
7344
7343
|
// If array expression then add it entry-by-entry to the injector imports
|
|
7345
7344
|
if (exp.elements) {
|
|
7346
|
-
injectorMetadata.imports.push(...exp.elements.map((n) => new
|
|
7345
|
+
injectorMetadata.imports.push(...exp.elements.map((n) => new checker.WrappedNodeExpr(n)));
|
|
7347
7346
|
}
|
|
7348
7347
|
}
|
|
7349
7348
|
else {
|
|
7350
7349
|
// if not array expression then add it as is to the injector's imports field.
|
|
7351
|
-
injectorMetadata.imports.push(new
|
|
7350
|
+
injectorMetadata.imports.push(new checker.WrappedNodeExpr(exp));
|
|
7352
7351
|
}
|
|
7353
7352
|
}
|
|
7354
7353
|
}
|
|
@@ -7357,7 +7356,7 @@ class NgModuleDecoratorHandler {
|
|
|
7357
7356
|
type,
|
|
7358
7357
|
typeArgumentCount: 0,
|
|
7359
7358
|
deps: checker.getValidConstructorDependencies(node, this.reflector, this.isCore),
|
|
7360
|
-
target:
|
|
7359
|
+
target: checker.FactoryTarget.NgModule,
|
|
7361
7360
|
};
|
|
7362
7361
|
// Remote scoping is used when adding imports to a component file would create a cycle. In such
|
|
7363
7362
|
// circumstances the component scope is monkey-patched from the NgModule file instead.
|
|
@@ -7456,7 +7455,7 @@ class NgModuleDecoratorHandler {
|
|
|
7456
7455
|
if (topLevelImport.hasModuleWithProviders) {
|
|
7457
7456
|
// We have no choice but to emit expressions which contain MWPs, as we cannot filter on
|
|
7458
7457
|
// individual references.
|
|
7459
|
-
data.injectorImports.push(new
|
|
7458
|
+
data.injectorImports.push(new checker.WrappedNodeExpr(topLevelImport.expression));
|
|
7460
7459
|
continue;
|
|
7461
7460
|
}
|
|
7462
7461
|
const refsToEmit = [];
|
|
@@ -7499,7 +7498,7 @@ class NgModuleDecoratorHandler {
|
|
|
7499
7498
|
if (refsToEmit.length === topLevelImport.resolvedReferences.length) {
|
|
7500
7499
|
// All references within this top-level import should be emitted, so just use the user's
|
|
7501
7500
|
// expression.
|
|
7502
|
-
data.injectorImports.push(new
|
|
7501
|
+
data.injectorImports.push(new checker.WrappedNodeExpr(topLevelImport.expression));
|
|
7503
7502
|
}
|
|
7504
7503
|
else {
|
|
7505
7504
|
// Some references have been filtered out. Emit references to individual classes.
|
|
@@ -7551,11 +7550,11 @@ class NgModuleDecoratorHandler {
|
|
|
7551
7550
|
}
|
|
7552
7551
|
compileFull(node, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection, }, { injectorImports }) {
|
|
7553
7552
|
const factoryFn = compileNgFactoryDefField(fac);
|
|
7554
|
-
const ngInjectorDef =
|
|
7553
|
+
const ngInjectorDef = checker.compileInjector({
|
|
7555
7554
|
...inj,
|
|
7556
7555
|
imports: injectorImports,
|
|
7557
7556
|
});
|
|
7558
|
-
const ngModuleDef =
|
|
7557
|
+
const ngModuleDef = checker.compileNgModule(mod);
|
|
7559
7558
|
const statements = ngModuleDef.statements;
|
|
7560
7559
|
const metadata = classMetadata !== null ? compileClassMetadata(classMetadata) : null;
|
|
7561
7560
|
this.insertMetadataStatement(statements, metadata);
|
|
@@ -7576,10 +7575,10 @@ class NgModuleDecoratorHandler {
|
|
|
7576
7575
|
}
|
|
7577
7576
|
compileLocal(node, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection, }) {
|
|
7578
7577
|
const factoryFn = compileNgFactoryDefField(fac);
|
|
7579
|
-
const ngInjectorDef =
|
|
7578
|
+
const ngInjectorDef = checker.compileInjector({
|
|
7580
7579
|
...inj,
|
|
7581
7580
|
});
|
|
7582
|
-
const ngModuleDef =
|
|
7581
|
+
const ngModuleDef = checker.compileNgModule(mod);
|
|
7583
7582
|
const statements = ngModuleDef.statements;
|
|
7584
7583
|
const metadata = classMetadata !== null ? compileClassMetadata(classMetadata) : null;
|
|
7585
7584
|
this.insertMetadataStatement(statements, metadata);
|
|
@@ -7617,19 +7616,19 @@ class NgModuleDecoratorHandler {
|
|
|
7617
7616
|
checker.assertSuccessfulReferenceEmit(type, node, 'pipe');
|
|
7618
7617
|
return type.expression;
|
|
7619
7618
|
});
|
|
7620
|
-
const directiveArray = new
|
|
7621
|
-
const pipesArray = new
|
|
7619
|
+
const directiveArray = new checker.LiteralArrayExpr(directives);
|
|
7620
|
+
const pipesArray = new checker.LiteralArrayExpr(pipes);
|
|
7622
7621
|
const directiveExpr = remoteScopesMayRequireCycleProtection && directives.length > 0
|
|
7623
|
-
? new
|
|
7622
|
+
? new checker.FunctionExpr([], [new checker.ReturnStatement(directiveArray)])
|
|
7624
7623
|
: directiveArray;
|
|
7625
7624
|
const pipesExpr = remoteScopesMayRequireCycleProtection && pipes.length > 0
|
|
7626
|
-
? new
|
|
7625
|
+
? new checker.FunctionExpr([], [new checker.ReturnStatement(pipesArray)])
|
|
7627
7626
|
: pipesArray;
|
|
7628
7627
|
const componentType = this.refEmitter.emit(decl, context);
|
|
7629
7628
|
checker.assertSuccessfulReferenceEmit(componentType, node, 'component');
|
|
7630
7629
|
const declExpr = componentType.expression;
|
|
7631
|
-
const setComponentScope = new
|
|
7632
|
-
const callExpr = new
|
|
7630
|
+
const setComponentScope = new checker.ExternalExpr(checker.Identifiers.setComponentScope);
|
|
7631
|
+
const callExpr = new checker.InvokeFunctionExpr(setComponentScope, [
|
|
7633
7632
|
declExpr,
|
|
7634
7633
|
directiveExpr,
|
|
7635
7634
|
pipesExpr,
|
|
@@ -7894,7 +7893,7 @@ function createEmptyTemplate(componentClass, component, containingFile) {
|
|
|
7894
7893
|
styles: [],
|
|
7895
7894
|
styleUrls: [],
|
|
7896
7895
|
ngContentSelectors: [],
|
|
7897
|
-
file: new
|
|
7896
|
+
file: new checker.ParseSourceFile('', ''),
|
|
7898
7897
|
sourceMapping: templateUrl
|
|
7899
7898
|
? { type: 'direct', node: template }
|
|
7900
7899
|
: {
|
|
@@ -7907,7 +7906,7 @@ function createEmptyTemplate(componentClass, component, containingFile) {
|
|
|
7907
7906
|
declaration: templateUrl
|
|
7908
7907
|
? {
|
|
7909
7908
|
isInline: false,
|
|
7910
|
-
interpolationConfig:
|
|
7909
|
+
interpolationConfig: checker.InterpolationConfig.fromArray(null),
|
|
7911
7910
|
preserveWhitespaces: false,
|
|
7912
7911
|
templateUrlExpression: templateUrl,
|
|
7913
7912
|
templateUrl: 'missing.ng.html',
|
|
@@ -7915,7 +7914,7 @@ function createEmptyTemplate(componentClass, component, containingFile) {
|
|
|
7915
7914
|
}
|
|
7916
7915
|
: {
|
|
7917
7916
|
isInline: true,
|
|
7918
|
-
interpolationConfig:
|
|
7917
|
+
interpolationConfig: checker.InterpolationConfig.fromArray(null),
|
|
7919
7918
|
preserveWhitespaces: false,
|
|
7920
7919
|
expression: template,
|
|
7921
7920
|
templateUrl: containingFile,
|
|
@@ -7937,7 +7936,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
7937
7936
|
enableLetSyntax: options.enableLetSyntax,
|
|
7938
7937
|
enableSelectorless: options.enableSelectorless,
|
|
7939
7938
|
};
|
|
7940
|
-
const parsedTemplate =
|
|
7939
|
+
const parsedTemplate = checker.parseTemplate(sourceStr, sourceMapUrl ?? '', {
|
|
7941
7940
|
...commonParseOptions,
|
|
7942
7941
|
preserveWhitespaces: template.preserveWhitespaces,
|
|
7943
7942
|
preserveSignificantWhitespace: options.preserveSignificantWhitespace,
|
|
@@ -7956,7 +7955,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
7956
7955
|
//
|
|
7957
7956
|
// In order to guarantee the correctness of diagnostics, templates are parsed a second time
|
|
7958
7957
|
// with the above options set to preserve source mappings.
|
|
7959
|
-
const { nodes: diagNodes } =
|
|
7958
|
+
const { nodes: diagNodes } = checker.parseTemplate(sourceStr, sourceMapUrl ?? '', {
|
|
7960
7959
|
...commonParseOptions,
|
|
7961
7960
|
preserveWhitespaces: true,
|
|
7962
7961
|
preserveLineEndings: true,
|
|
@@ -7966,7 +7965,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
7966
7965
|
return {
|
|
7967
7966
|
...parsedTemplate,
|
|
7968
7967
|
diagNodes,
|
|
7969
|
-
file: new
|
|
7968
|
+
file: new checker.ParseSourceFile(sourceStr, sourceMapUrl ?? ''),
|
|
7970
7969
|
};
|
|
7971
7970
|
}
|
|
7972
7971
|
function parseTemplateDeclaration(node, decorator, component, containingFile, evaluator, depTracker, resourceLoader, defaultPreserveWhitespaces) {
|
|
@@ -7979,7 +7978,7 @@ function parseTemplateDeclaration(node, decorator, component, containingFile, ev
|
|
|
7979
7978
|
}
|
|
7980
7979
|
preserveWhitespaces = value;
|
|
7981
7980
|
}
|
|
7982
|
-
let interpolationConfig =
|
|
7981
|
+
let interpolationConfig = checker.DEFAULT_INTERPOLATION_CONFIG;
|
|
7983
7982
|
if (component.has('interpolation')) {
|
|
7984
7983
|
const expr = component.get('interpolation');
|
|
7985
7984
|
const value = evaluator.evaluate(expr);
|
|
@@ -7988,7 +7987,7 @@ function parseTemplateDeclaration(node, decorator, component, containingFile, ev
|
|
|
7988
7987
|
!value.every((element) => typeof element === 'string')) {
|
|
7989
7988
|
throw checker.createValueHasWrongTypeError(expr, value, 'interpolation must be an array with 2 elements of string type');
|
|
7990
7989
|
}
|
|
7991
|
-
interpolationConfig =
|
|
7990
|
+
interpolationConfig = checker.InterpolationConfig.fromArray(value);
|
|
7992
7991
|
}
|
|
7993
7992
|
if (component.has('templateUrl')) {
|
|
7994
7993
|
const templateUrlExpr = component.get('templateUrl');
|
|
@@ -8471,7 +8470,7 @@ function extractHmrDependencies(node, definition, factory, deferBlockMetadata, c
|
|
|
8471
8470
|
const local = [];
|
|
8472
8471
|
const seenLocals = new Set();
|
|
8473
8472
|
for (const readNode of visitor.allReads) {
|
|
8474
|
-
const readName = readNode instanceof
|
|
8473
|
+
const readName = readNode instanceof checker.ReadVarExpr ? readNode.name : readNode.text;
|
|
8475
8474
|
if (readName !== name && !seenLocals.has(readName) && availableTopLevel.has(readName)) {
|
|
8476
8475
|
const runtimeRepresentation = getRuntimeRepresentation(readNode, reflection, evaluator);
|
|
8477
8476
|
if (runtimeRepresentation === null) {
|
|
@@ -8493,8 +8492,8 @@ function extractHmrDependencies(node, definition, factory, deferBlockMetadata, c
|
|
|
8493
8492
|
* Gets a node that can be used to represent an identifier in the HMR replacement code at runtime.
|
|
8494
8493
|
*/
|
|
8495
8494
|
function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
8496
|
-
if (node instanceof
|
|
8497
|
-
return
|
|
8495
|
+
if (node instanceof checker.ReadVarExpr) {
|
|
8496
|
+
return checker.variable(node.name);
|
|
8498
8497
|
}
|
|
8499
8498
|
// Const enums can't be passed by reference, because their values are inlined.
|
|
8500
8499
|
// Pass in an object literal with all of the values instead.
|
|
@@ -8511,7 +8510,7 @@ function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
|
8511
8510
|
members.push({
|
|
8512
8511
|
key: name,
|
|
8513
8512
|
quoted: false,
|
|
8514
|
-
value:
|
|
8513
|
+
value: checker.literal(value.resolved),
|
|
8515
8514
|
});
|
|
8516
8515
|
}
|
|
8517
8516
|
else {
|
|
@@ -8521,10 +8520,10 @@ function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
|
8521
8520
|
return null;
|
|
8522
8521
|
}
|
|
8523
8522
|
}
|
|
8524
|
-
return
|
|
8523
|
+
return checker.literalMap(members);
|
|
8525
8524
|
}
|
|
8526
8525
|
}
|
|
8527
|
-
return
|
|
8526
|
+
return checker.variable(node.text);
|
|
8528
8527
|
}
|
|
8529
8528
|
/**
|
|
8530
8529
|
* Gets the names of all top-level declarations within the file (imports, declared classes etc).
|
|
@@ -8604,7 +8603,7 @@ function trackBindingName(node, results) {
|
|
|
8604
8603
|
* The reads are "potential", because the visitor doesn't account for local variables
|
|
8605
8604
|
* inside functions.
|
|
8606
8605
|
*/
|
|
8607
|
-
class PotentialTopLevelReadsVisitor extends
|
|
8606
|
+
class PotentialTopLevelReadsVisitor extends checker.RecursiveAstVisitor$1 {
|
|
8608
8607
|
allReads = new Set();
|
|
8609
8608
|
namespaceReads = new Set();
|
|
8610
8609
|
visitExternalExpr(ast, context) {
|
|
@@ -8790,7 +8789,7 @@ function extractHmrMetatadata(clazz, reflection, evaluator, compilerHost, rootDi
|
|
|
8790
8789
|
return null;
|
|
8791
8790
|
}
|
|
8792
8791
|
const meta = {
|
|
8793
|
-
type: new
|
|
8792
|
+
type: new checker.WrappedNodeExpr(clazz.name),
|
|
8794
8793
|
className: clazz.name.text,
|
|
8795
8794
|
filePath,
|
|
8796
8795
|
localDependencies: dependencies.local,
|
|
@@ -8849,8 +8848,8 @@ class HmrModuleImportRewriter {
|
|
|
8849
8848
|
}
|
|
8850
8849
|
|
|
8851
8850
|
const EMPTY_ARRAY = [];
|
|
8852
|
-
const isUsedDirective = (decl) => decl.kind ===
|
|
8853
|
-
const isUsedPipe = (decl) => decl.kind ===
|
|
8851
|
+
const isUsedDirective = (decl) => decl.kind === checker.R3TemplateDependencyKind.Directive;
|
|
8852
|
+
const isUsedPipe = (decl) => decl.kind === checker.R3TemplateDependencyKind.Pipe;
|
|
8854
8853
|
/**
|
|
8855
8854
|
* `DecoratorHandler` which handles the `@Component` annotation.
|
|
8856
8855
|
*/
|
|
@@ -8961,7 +8960,7 @@ class ComponentDecoratorHandler {
|
|
|
8961
8960
|
this.canDeferDeps = !enableHmr;
|
|
8962
8961
|
}
|
|
8963
8962
|
literalCache = new Map();
|
|
8964
|
-
elementSchemaRegistry = new
|
|
8963
|
+
elementSchemaRegistry = new checker.DomElementSchemaRegistry();
|
|
8965
8964
|
/**
|
|
8966
8965
|
* During the asynchronous preanalyze phase, it's necessary to parse the template to extract
|
|
8967
8966
|
* any potential <link> tags which might need to be loaded. This cache ensures that work is not
|
|
@@ -9096,19 +9095,19 @@ class ComponentDecoratorHandler {
|
|
|
9096
9095
|
const encapsulation = (this.compilationMode !== checker.CompilationMode.LOCAL
|
|
9097
9096
|
? resolveEnumValue(this.evaluator, component, 'encapsulation', 'ViewEncapsulation', this.isCore)
|
|
9098
9097
|
: resolveEncapsulationEnumValueLocally(component.get('encapsulation'))) ??
|
|
9099
|
-
|
|
9098
|
+
checker.ViewEncapsulation.Emulated;
|
|
9100
9099
|
let changeDetection = null;
|
|
9101
9100
|
if (this.compilationMode !== checker.CompilationMode.LOCAL) {
|
|
9102
9101
|
changeDetection = resolveEnumValue(this.evaluator, component, 'changeDetection', 'ChangeDetectionStrategy', this.isCore);
|
|
9103
9102
|
}
|
|
9104
9103
|
else if (component.has('changeDetection')) {
|
|
9105
|
-
changeDetection = new
|
|
9104
|
+
changeDetection = new checker.WrappedNodeExpr(component.get('changeDetection'));
|
|
9106
9105
|
}
|
|
9107
9106
|
let animations = null;
|
|
9108
9107
|
let animationTriggerNames = null;
|
|
9109
9108
|
if (component.has('animations')) {
|
|
9110
9109
|
const animationExpression = component.get('animations');
|
|
9111
|
-
animations = new
|
|
9110
|
+
animations = new checker.WrappedNodeExpr(animationExpression);
|
|
9112
9111
|
const animationsValue = this.evaluator.evaluate(animationExpression, animationTriggerResolver);
|
|
9113
9112
|
animationTriggerNames = { includesDynamicAnimations: false, staticTriggerNames: [] };
|
|
9114
9113
|
collectAnimationNames(animationsValue, animationTriggerNames);
|
|
@@ -9133,7 +9132,7 @@ class ComponentDecoratorHandler {
|
|
|
9133
9132
|
if (component.has('viewProviders')) {
|
|
9134
9133
|
const viewProviders = component.get('viewProviders');
|
|
9135
9134
|
viewProvidersRequiringFactory = checker.resolveProvidersRequiringFactory(viewProviders, this.reflector, this.evaluator);
|
|
9136
|
-
wrappedViewProviders = new
|
|
9135
|
+
wrappedViewProviders = new checker.WrappedNodeExpr(this.annotateForClosureCompiler
|
|
9137
9136
|
? checker.wrapFunctionExpressionsInParens(viewProviders)
|
|
9138
9137
|
: viewProviders);
|
|
9139
9138
|
}
|
|
@@ -9312,7 +9311,7 @@ class ComponentDecoratorHandler {
|
|
|
9312
9311
|
diagnostics.push(makeResourceNotFoundError(styleUrl.url, styleUrl.expression, resourceType).toDiagnostic());
|
|
9313
9312
|
}
|
|
9314
9313
|
}
|
|
9315
|
-
if (encapsulation ===
|
|
9314
|
+
if (encapsulation === checker.ViewEncapsulation.ShadowDom && metadata.selector !== null) {
|
|
9316
9315
|
const selectorError = checkCustomElementSelectorForErrors(metadata.selector);
|
|
9317
9316
|
if (selectorError !== null) {
|
|
9318
9317
|
if (diagnostics === undefined) {
|
|
@@ -9385,7 +9384,7 @@ class ComponentDecoratorHandler {
|
|
|
9385
9384
|
template,
|
|
9386
9385
|
encapsulation,
|
|
9387
9386
|
changeDetection,
|
|
9388
|
-
interpolation: template.interpolationConfig ??
|
|
9387
|
+
interpolation: template.interpolationConfig ?? checker.DEFAULT_INTERPOLATION_CONFIG,
|
|
9389
9388
|
styles,
|
|
9390
9389
|
externalStyles,
|
|
9391
9390
|
// These will be replaced during the compilation step, after all `NgModule`s have been
|
|
@@ -9394,7 +9393,7 @@ class ComponentDecoratorHandler {
|
|
|
9394
9393
|
viewProviders: wrappedViewProviders,
|
|
9395
9394
|
i18nUseExternalIds: this.i18nUseExternalIds,
|
|
9396
9395
|
relativeContextFilePath,
|
|
9397
|
-
rawImports: rawImports !== null ? new
|
|
9396
|
+
rawImports: rawImports !== null ? new checker.WrappedNodeExpr(rawImports) : undefined,
|
|
9398
9397
|
relativeTemplatePath,
|
|
9399
9398
|
},
|
|
9400
9399
|
typeCheckMeta: checker.extractDirectiveTypeCheckMeta(node, inputs, this.reflector),
|
|
@@ -9477,7 +9476,7 @@ class ComponentDecoratorHandler {
|
|
|
9477
9476
|
}
|
|
9478
9477
|
const scope = this.scopeReader.getScopeForComponent(node);
|
|
9479
9478
|
const selector = analysis.meta.selector;
|
|
9480
|
-
const matcher = new
|
|
9479
|
+
const matcher = new checker.SelectorMatcher();
|
|
9481
9480
|
if (scope !== null) {
|
|
9482
9481
|
let { dependencies, isPoisoned } = scope.kind === checker.ComponentScopeKind.NgModule ? scope.compilation : scope;
|
|
9483
9482
|
if ((isPoisoned || (scope.kind === checker.ComponentScopeKind.NgModule && scope.exported.isPoisoned)) &&
|
|
@@ -9488,7 +9487,7 @@ class ComponentDecoratorHandler {
|
|
|
9488
9487
|
}
|
|
9489
9488
|
for (const dep of dependencies) {
|
|
9490
9489
|
if (dep.kind === checker.MetaKind.Directive && dep.selector !== null) {
|
|
9491
|
-
matcher.addSelectables(
|
|
9490
|
+
matcher.addSelectables(checker.CssSelector.parse(dep.selector), [
|
|
9492
9491
|
...this.hostDirectivesResolver.resolve(dep),
|
|
9493
9492
|
dep,
|
|
9494
9493
|
]);
|
|
@@ -9496,7 +9495,7 @@ class ComponentDecoratorHandler {
|
|
|
9496
9495
|
}
|
|
9497
9496
|
}
|
|
9498
9497
|
// TODO(crisbeto): implement for selectorless.
|
|
9499
|
-
const binder = new
|
|
9498
|
+
const binder = new checker.R3TargetBinder(matcher);
|
|
9500
9499
|
const boundTemplate = binder.bind({ template: analysis.template.diagNodes });
|
|
9501
9500
|
context.addComponent({
|
|
9502
9501
|
declaration: node,
|
|
@@ -9519,7 +9518,7 @@ class ComponentDecoratorHandler {
|
|
|
9519
9518
|
return;
|
|
9520
9519
|
}
|
|
9521
9520
|
// TODO(crisbeto): implement for selectorless.
|
|
9522
|
-
const binder = new
|
|
9521
|
+
const binder = new checker.R3TargetBinder(scope.matcher);
|
|
9523
9522
|
const templateContext = {
|
|
9524
9523
|
nodes: meta.template.diagNodes,
|
|
9525
9524
|
pipes: scope.pipes,
|
|
@@ -9639,7 +9638,7 @@ class ComponentDecoratorHandler {
|
|
|
9639
9638
|
return { data };
|
|
9640
9639
|
}
|
|
9641
9640
|
xi18n(ctx, node, analysis) {
|
|
9642
|
-
ctx.updateFromTemplate(analysis.template.content, analysis.template.declaration.resolvedTemplateUrl, analysis.template.interpolationConfig ??
|
|
9641
|
+
ctx.updateFromTemplate(analysis.template.content, analysis.template.declaration.resolvedTemplateUrl, analysis.template.interpolationConfig ?? checker.DEFAULT_INTERPOLATION_CONFIG);
|
|
9643
9642
|
}
|
|
9644
9643
|
updateResources(node, analysis) {
|
|
9645
9644
|
const containingFile = node.getSourceFile().fileName;
|
|
@@ -9688,11 +9687,11 @@ class ComponentDecoratorHandler {
|
|
|
9688
9687
|
...resolution,
|
|
9689
9688
|
defer,
|
|
9690
9689
|
};
|
|
9691
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta,
|
|
9690
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, checker.FactoryTarget.Component));
|
|
9692
9691
|
if (perComponentDeferredDeps !== null) {
|
|
9693
9692
|
removeDeferrableTypesFromComponentDecorator(analysis, perComponentDeferredDeps);
|
|
9694
9693
|
}
|
|
9695
|
-
const def =
|
|
9694
|
+
const def = checker.compileComponentFromMetadata(meta, pool, checker.makeBindingParser());
|
|
9696
9695
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
9697
9696
|
const classMetadata = analysis.classMetadata !== null
|
|
9698
9697
|
? compileComponentClassMetadata(analysis.classMetadata, perComponentDeferredDeps).toStmt()
|
|
@@ -9718,7 +9717,7 @@ class ComponentDecoratorHandler {
|
|
|
9718
9717
|
sourceUrl: analysis.template.declaration.resolvedTemplateUrl,
|
|
9719
9718
|
isInline: analysis.template.declaration.isInline,
|
|
9720
9719
|
inlineTemplateLiteralExpression: analysis.template.sourceMapping.type === 'direct'
|
|
9721
|
-
? new
|
|
9720
|
+
? new checker.WrappedNodeExpr(analysis.template.sourceMapping.node)
|
|
9722
9721
|
: null,
|
|
9723
9722
|
};
|
|
9724
9723
|
const perComponentDeferredDeps = this.canDeferDeps
|
|
@@ -9730,7 +9729,7 @@ class ComponentDecoratorHandler {
|
|
|
9730
9729
|
...resolution,
|
|
9731
9730
|
defer,
|
|
9732
9731
|
};
|
|
9733
|
-
const fac = compileDeclareFactory(checker.toFactoryMetadata(meta,
|
|
9732
|
+
const fac = compileDeclareFactory(checker.toFactoryMetadata(meta, checker.FactoryTarget.Component));
|
|
9734
9733
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
9735
9734
|
const def = compileDeclareComponentFromMetadata(meta, analysis.template, templateInfo);
|
|
9736
9735
|
const classMetadata = analysis.classMetadata !== null
|
|
@@ -9759,8 +9758,8 @@ class ComponentDecoratorHandler {
|
|
|
9759
9758
|
if (deferrableTypes !== null) {
|
|
9760
9759
|
removeDeferrableTypesFromComponentDecorator(analysis, deferrableTypes);
|
|
9761
9760
|
}
|
|
9762
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta,
|
|
9763
|
-
const def =
|
|
9761
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, checker.FactoryTarget.Component));
|
|
9762
|
+
const def = checker.compileComponentFromMetadata(meta, pool, checker.makeBindingParser());
|
|
9764
9763
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
9765
9764
|
const classMetadata = analysis.classMetadata !== null
|
|
9766
9765
|
? compileComponentClassMetadata(analysis.classMetadata, deferrableTypes).toStmt()
|
|
@@ -9782,15 +9781,15 @@ class ComponentDecoratorHandler {
|
|
|
9782
9781
|
return null;
|
|
9783
9782
|
}
|
|
9784
9783
|
// Create a brand-new constant pool since there shouldn't be any constant sharing.
|
|
9785
|
-
const pool = new
|
|
9784
|
+
const pool = new checker.ConstantPool();
|
|
9786
9785
|
const defer = this.compileDeferBlocks(resolution);
|
|
9787
9786
|
const meta = {
|
|
9788
9787
|
...analysis.meta,
|
|
9789
9788
|
...resolution,
|
|
9790
9789
|
defer,
|
|
9791
9790
|
};
|
|
9792
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta,
|
|
9793
|
-
const def =
|
|
9791
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, checker.FactoryTarget.Component));
|
|
9792
|
+
const def = checker.compileComponentFromMetadata(meta, pool, checker.makeBindingParser());
|
|
9794
9793
|
const classMetadata = analysis.classMetadata !== null
|
|
9795
9794
|
? compileComponentClassMetadata(analysis.classMetadata, null).toStmt()
|
|
9796
9795
|
: null;
|
|
@@ -9939,7 +9938,7 @@ class ComponentDecoratorHandler {
|
|
|
9939
9938
|
const dirType = this.refEmitter.emit(dep.ref, context);
|
|
9940
9939
|
checker.assertSuccessfulReferenceEmit(dirType, node.name, dep.isComponent ? 'component' : 'directive');
|
|
9941
9940
|
declarations.set(dep.ref.node, {
|
|
9942
|
-
kind:
|
|
9941
|
+
kind: checker.R3TemplateDependencyKind.Directive,
|
|
9943
9942
|
ref: dep.ref,
|
|
9944
9943
|
type: dirType.expression,
|
|
9945
9944
|
importedFile: dirType.importedFile,
|
|
@@ -9957,7 +9956,7 @@ class ComponentDecoratorHandler {
|
|
|
9957
9956
|
const pipeType = this.refEmitter.emit(dep.ref, context);
|
|
9958
9957
|
checker.assertSuccessfulReferenceEmit(pipeType, node.name, 'pipe');
|
|
9959
9958
|
declarations.set(dep.ref.node, {
|
|
9960
|
-
kind:
|
|
9959
|
+
kind: checker.R3TemplateDependencyKind.Pipe,
|
|
9961
9960
|
type: pipeType.expression,
|
|
9962
9961
|
name: dep.name,
|
|
9963
9962
|
ref: dep.ref,
|
|
@@ -9968,7 +9967,7 @@ class ComponentDecoratorHandler {
|
|
|
9968
9967
|
const ngModuleType = this.refEmitter.emit(dep.ref, context);
|
|
9969
9968
|
checker.assertSuccessfulReferenceEmit(ngModuleType, node.name, 'NgModule');
|
|
9970
9969
|
declarations.set(dep.ref.node, {
|
|
9971
|
-
kind:
|
|
9970
|
+
kind: checker.R3TemplateDependencyKind.NgModule,
|
|
9972
9971
|
type: ngModuleType.expression,
|
|
9973
9972
|
importedFile: ngModuleType.importedFile,
|
|
9974
9973
|
});
|
|
@@ -9980,7 +9979,7 @@ class ComponentDecoratorHandler {
|
|
|
9980
9979
|
/** Handles any cycles in the dependencies of a component. */
|
|
9981
9980
|
handleDependencyCycles(node, context, scope, data, analysis, metadata, declarations, eagerlyUsed, symbol) {
|
|
9982
9981
|
const eagerDeclarations = Array.from(declarations.values()).filter((decl) => {
|
|
9983
|
-
return decl.kind ===
|
|
9982
|
+
return decl.kind === checker.R3TemplateDependencyKind.NgModule || eagerlyUsed.has(decl.ref.node);
|
|
9984
9983
|
});
|
|
9985
9984
|
const cyclesFromDirectives = new Map();
|
|
9986
9985
|
const cyclesFromPipes = new Map();
|
|
@@ -9994,10 +9993,10 @@ class ComponentDecoratorHandler {
|
|
|
9994
9993
|
const cycle = this._checkForCyclicImport(usedDep.importedFile, usedDep.type, context);
|
|
9995
9994
|
if (cycle !== null) {
|
|
9996
9995
|
switch (usedDep.kind) {
|
|
9997
|
-
case
|
|
9996
|
+
case checker.R3TemplateDependencyKind.Directive:
|
|
9998
9997
|
cyclesFromDirectives.set(usedDep, cycle);
|
|
9999
9998
|
break;
|
|
10000
|
-
case
|
|
9999
|
+
case checker.R3TemplateDependencyKind.Pipe:
|
|
10001
10000
|
cyclesFromPipes.set(usedDep, cycle);
|
|
10002
10001
|
break;
|
|
10003
10002
|
}
|
|
@@ -10038,7 +10037,7 @@ class ComponentDecoratorHandler {
|
|
|
10038
10037
|
// best-guess extra imports globally to all files using
|
|
10039
10038
|
// `localCompilationExtraImportsTracker.addGlobalImportFromIdentifier`.
|
|
10040
10039
|
for (const { type } of eagerDeclarations) {
|
|
10041
|
-
if (type instanceof
|
|
10040
|
+
if (type instanceof checker.ExternalExpr && type.value.moduleName) {
|
|
10042
10041
|
this.localCompilationExtraImportsTracker.addImportForFile(context, type.value.moduleName);
|
|
10043
10042
|
}
|
|
10044
10043
|
}
|
|
@@ -10095,13 +10094,13 @@ class ComponentDecoratorHandler {
|
|
|
10095
10094
|
diagnostics.push(...importDiagnostics);
|
|
10096
10095
|
}
|
|
10097
10096
|
if (analysis.providersRequiringFactory !== null &&
|
|
10098
|
-
analysis.meta.providers instanceof
|
|
10097
|
+
analysis.meta.providers instanceof checker.WrappedNodeExpr) {
|
|
10099
10098
|
const providerDiagnostics = checker.getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
|
|
10100
10099
|
diagnostics ??= [];
|
|
10101
10100
|
diagnostics.push(...providerDiagnostics);
|
|
10102
10101
|
}
|
|
10103
10102
|
if (analysis.viewProvidersRequiringFactory !== null &&
|
|
10104
|
-
analysis.meta.viewProviders instanceof
|
|
10103
|
+
analysis.meta.viewProviders instanceof checker.WrappedNodeExpr) {
|
|
10105
10104
|
const viewProviderDiagnostics = checker.getProviderDiagnostics(analysis.viewProvidersRequiringFactory, analysis.meta.viewProviders.node, this.injectableRegistry);
|
|
10106
10105
|
diagnostics ??= [];
|
|
10107
10106
|
diagnostics.push(...viewProviderDiagnostics);
|
|
@@ -10126,7 +10125,7 @@ class ComponentDecoratorHandler {
|
|
|
10126
10125
|
*/
|
|
10127
10126
|
locateDeferBlocksWithoutScope(template) {
|
|
10128
10127
|
const deferBlocks = new Map();
|
|
10129
|
-
const directivelessBinder = new
|
|
10128
|
+
const directivelessBinder = new checker.R3TargetBinder(null);
|
|
10130
10129
|
const bound = directivelessBinder.bind({ template: template.nodes });
|
|
10131
10130
|
const deferredBlocks = bound.getDeferBlocks();
|
|
10132
10131
|
for (const block of deferredBlocks) {
|
|
@@ -10229,14 +10228,14 @@ class ComponentDecoratorHandler {
|
|
|
10229
10228
|
resolutionData.deferPerBlockDependencies.set(deferBlock, deps);
|
|
10230
10229
|
}
|
|
10231
10230
|
for (const decl of Array.from(deferrableDecls.values())) {
|
|
10232
|
-
if (decl.kind ===
|
|
10231
|
+
if (decl.kind === checker.R3TemplateDependencyKind.NgModule) {
|
|
10233
10232
|
continue;
|
|
10234
10233
|
}
|
|
10235
|
-
if (decl.kind ===
|
|
10234
|
+
if (decl.kind === checker.R3TemplateDependencyKind.Directive &&
|
|
10236
10235
|
!usedDirectives.has(decl.ref.node)) {
|
|
10237
10236
|
continue;
|
|
10238
10237
|
}
|
|
10239
|
-
if (decl.kind ===
|
|
10238
|
+
if (decl.kind === checker.R3TemplateDependencyKind.Pipe && !usedPipes.has(decl.name)) {
|
|
10240
10239
|
continue;
|
|
10241
10240
|
}
|
|
10242
10241
|
// Collect initial information about this dependency.
|
|
@@ -10331,7 +10330,7 @@ class ComponentDecoratorHandler {
|
|
|
10331
10330
|
}
|
|
10332
10331
|
const blocks = new Map();
|
|
10333
10332
|
for (const [block, dependencies] of perBlockDeps) {
|
|
10334
|
-
blocks.set(block, dependencies.length === 0 ? null :
|
|
10333
|
+
blocks.set(block, dependencies.length === 0 ? null : checker.compileDeferResolverFunction({ mode, dependencies }));
|
|
10335
10334
|
}
|
|
10336
10335
|
return { mode, blocks };
|
|
10337
10336
|
}
|
|
@@ -10343,7 +10342,7 @@ class ComponentDecoratorHandler {
|
|
|
10343
10342
|
mode,
|
|
10344
10343
|
dependenciesFn: perComponentDeps.length === 0
|
|
10345
10344
|
? null
|
|
10346
|
-
:
|
|
10345
|
+
: checker.compileDeferResolverFunction({ mode, dependencies: perComponentDeps }),
|
|
10347
10346
|
};
|
|
10348
10347
|
}
|
|
10349
10348
|
throw new Error(`Invalid deferBlockDepsEmitMode. Cannot compile deferred block metadata.`);
|
|
@@ -10353,14 +10352,14 @@ class ComponentDecoratorHandler {
|
|
|
10353
10352
|
* Creates an instance of a target binder based on provided dependencies.
|
|
10354
10353
|
*/
|
|
10355
10354
|
function createTargetBinder(dependencies) {
|
|
10356
|
-
const matcher = new
|
|
10355
|
+
const matcher = new checker.SelectorMatcher();
|
|
10357
10356
|
for (const dep of dependencies) {
|
|
10358
10357
|
if (dep.kind === checker.MetaKind.Directive && dep.selector !== null) {
|
|
10359
|
-
matcher.addSelectables(
|
|
10358
|
+
matcher.addSelectables(checker.CssSelector.parse(dep.selector), [dep]);
|
|
10360
10359
|
}
|
|
10361
10360
|
}
|
|
10362
10361
|
// TODO(crisbeto): implement for selectorless.
|
|
10363
|
-
return new
|
|
10362
|
+
return new checker.R3TargetBinder(matcher);
|
|
10364
10363
|
}
|
|
10365
10364
|
/**
|
|
10366
10365
|
* Returns the list of dependencies from `@Component.deferredImports` if provided.
|
|
@@ -10387,7 +10386,7 @@ function removeDeferrableTypesFromComponentDecorator(analysis, deferrableTypes)
|
|
|
10387
10386
|
if (analysis.classMetadata) {
|
|
10388
10387
|
const deferrableSymbols = new Set(deferrableTypes.map((t) => t.symbolName));
|
|
10389
10388
|
const rewrittenDecoratorsNode = removeIdentifierReferences(analysis.classMetadata.decorators.node, deferrableSymbols);
|
|
10390
|
-
analysis.classMetadata.decorators = new
|
|
10389
|
+
analysis.classMetadata.decorators = new checker.WrappedNodeExpr(rewrittenDecoratorsNode);
|
|
10391
10390
|
}
|
|
10392
10391
|
}
|
|
10393
10392
|
/**
|
|
@@ -10543,19 +10542,19 @@ class InjectableDecoratorHandler {
|
|
|
10543
10542
|
return {};
|
|
10544
10543
|
}
|
|
10545
10544
|
compileFull(node, analysis) {
|
|
10546
|
-
return this.compile(compileNgFactoryDefField, (meta) =>
|
|
10545
|
+
return this.compile(compileNgFactoryDefField, (meta) => checker.compileInjectable(meta, false), compileClassMetadata, node, analysis);
|
|
10547
10546
|
}
|
|
10548
10547
|
compilePartial(node, analysis) {
|
|
10549
10548
|
return this.compile(compileDeclareFactory, compileDeclareInjectableFromMetadata, compileDeclareClassMetadata, node, analysis);
|
|
10550
10549
|
}
|
|
10551
10550
|
compileLocal(node, analysis) {
|
|
10552
|
-
return this.compile(compileNgFactoryDefField, (meta) =>
|
|
10551
|
+
return this.compile(compileNgFactoryDefField, (meta) => checker.compileInjectable(meta, false), compileClassMetadata, node, analysis);
|
|
10553
10552
|
}
|
|
10554
10553
|
compile(compileFactoryFn, compileInjectableFn, compileClassMetadataFn, node, analysis) {
|
|
10555
10554
|
const results = [];
|
|
10556
10555
|
if (analysis.needsFactory) {
|
|
10557
10556
|
const meta = analysis.meta;
|
|
10558
|
-
const factoryRes = compileFactoryFn(checker.toFactoryMetadata({ ...meta, deps: analysis.ctorDeps },
|
|
10557
|
+
const factoryRes = compileFactoryFn(checker.toFactoryMetadata({ ...meta, deps: analysis.ctorDeps }, checker.FactoryTarget.Injectable));
|
|
10559
10558
|
if (analysis.classMetadata !== null) {
|
|
10560
10559
|
factoryRes.statements.push(compileClassMetadataFn(analysis.classMetadata).toStmt());
|
|
10561
10560
|
}
|
|
@@ -10597,7 +10596,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10597
10596
|
name,
|
|
10598
10597
|
type,
|
|
10599
10598
|
typeArgumentCount,
|
|
10600
|
-
providedIn:
|
|
10599
|
+
providedIn: checker.createMayBeForwardRefExpression(new checker.LiteralExpr(null), 0 /* ForwardRefHandling.None */),
|
|
10601
10600
|
};
|
|
10602
10601
|
}
|
|
10603
10602
|
else if (decorator.args.length === 1) {
|
|
@@ -10612,7 +10611,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10612
10611
|
const meta = checker.reflectObjectLiteral(metaNode);
|
|
10613
10612
|
const providedIn = meta.has('providedIn')
|
|
10614
10613
|
? getProviderExpression(meta.get('providedIn'), reflector)
|
|
10615
|
-
:
|
|
10614
|
+
: checker.createMayBeForwardRefExpression(new checker.LiteralExpr(null), 0 /* ForwardRefHandling.None */);
|
|
10616
10615
|
let deps = undefined;
|
|
10617
10616
|
if ((meta.has('useClass') || meta.has('useFactory')) && meta.has('deps')) {
|
|
10618
10617
|
const depsExpr = meta.get('deps');
|
|
@@ -10633,7 +10632,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10633
10632
|
result.deps = deps;
|
|
10634
10633
|
}
|
|
10635
10634
|
else if (meta.has('useFactory')) {
|
|
10636
|
-
result.useFactory = new
|
|
10635
|
+
result.useFactory = new checker.WrappedNodeExpr(meta.get('useFactory'));
|
|
10637
10636
|
result.deps = deps;
|
|
10638
10637
|
}
|
|
10639
10638
|
return result;
|
|
@@ -10651,7 +10650,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10651
10650
|
*/
|
|
10652
10651
|
function getProviderExpression(expression, reflector) {
|
|
10653
10652
|
const forwardRefValue = checker.tryUnwrapForwardRef(expression, reflector);
|
|
10654
|
-
return
|
|
10653
|
+
return checker.createMayBeForwardRefExpression(new checker.WrappedNodeExpr(forwardRefValue ?? expression), forwardRefValue !== null ? 2 /* ForwardRefHandling.Unwrapped */ : 0 /* ForwardRefHandling.None */);
|
|
10655
10654
|
}
|
|
10656
10655
|
function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps) {
|
|
10657
10656
|
if (decorator.args === null) {
|
|
@@ -10696,7 +10695,7 @@ function requiresValidCtor(meta) {
|
|
|
10696
10695
|
}
|
|
10697
10696
|
function getDep(dep, reflector) {
|
|
10698
10697
|
const meta = {
|
|
10699
|
-
token: new
|
|
10698
|
+
token: new checker.WrappedNodeExpr(dep),
|
|
10700
10699
|
attributeNameType: null,
|
|
10701
10700
|
host: false,
|
|
10702
10701
|
optional: false,
|
|
@@ -10711,7 +10710,7 @@ function getDep(dep, reflector) {
|
|
|
10711
10710
|
switch (source.name) {
|
|
10712
10711
|
case 'Inject':
|
|
10713
10712
|
if (token !== undefined) {
|
|
10714
|
-
meta.token = new
|
|
10713
|
+
meta.token = new checker.WrappedNodeExpr(token);
|
|
10715
10714
|
}
|
|
10716
10715
|
break;
|
|
10717
10716
|
case 'Optional':
|
|
@@ -10739,7 +10738,7 @@ function getDep(dep, reflector) {
|
|
|
10739
10738
|
isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
|
|
10740
10739
|
}
|
|
10741
10740
|
if (!isDecorator) {
|
|
10742
|
-
meta.token = new
|
|
10741
|
+
meta.token = new checker.WrappedNodeExpr(el);
|
|
10743
10742
|
}
|
|
10744
10743
|
});
|
|
10745
10744
|
}
|
|
@@ -10906,15 +10905,15 @@ class PipeDecoratorHandler {
|
|
|
10906
10905
|
return {};
|
|
10907
10906
|
}
|
|
10908
10907
|
compileFull(node, analysis) {
|
|
10909
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
10910
|
-
const def =
|
|
10908
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, checker.FactoryTarget.Pipe));
|
|
10909
|
+
const def = checker.compilePipeFromMetadata(analysis.meta);
|
|
10911
10910
|
const classMetadata = analysis.classMetadata !== null
|
|
10912
10911
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
10913
10912
|
: null;
|
|
10914
10913
|
return checker.compileResults(fac, def, classMetadata, 'ɵpipe', null, null /* deferrableImports */);
|
|
10915
10914
|
}
|
|
10916
10915
|
compilePartial(node, analysis) {
|
|
10917
|
-
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta,
|
|
10916
|
+
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta, checker.FactoryTarget.Pipe));
|
|
10918
10917
|
const def = compileDeclarePipeFromMetadata(analysis.meta);
|
|
10919
10918
|
const classMetadata = analysis.classMetadata !== null
|
|
10920
10919
|
? compileDeclareClassMetadata(analysis.classMetadata).toStmt()
|
|
@@ -10922,8 +10921,8 @@ class PipeDecoratorHandler {
|
|
|
10922
10921
|
return checker.compileResults(fac, def, classMetadata, 'ɵpipe', null, null /* deferrableImports */);
|
|
10923
10922
|
}
|
|
10924
10923
|
compileLocal(node, analysis) {
|
|
10925
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
10926
|
-
const def =
|
|
10924
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, checker.FactoryTarget.Pipe));
|
|
10925
|
+
const def = checker.compilePipeFromMetadata(analysis.meta);
|
|
10927
10926
|
const classMetadata = analysis.classMetadata !== null
|
|
10928
10927
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
10929
10928
|
: null;
|
|
@@ -10936,7 +10935,7 @@ class PipeDecoratorHandler {
|
|
|
10936
10935
|
* @description
|
|
10937
10936
|
* Entry point for all public APIs of the compiler-cli package.
|
|
10938
10937
|
*/
|
|
10939
|
-
new
|
|
10938
|
+
new checker.Version('20.0.1');
|
|
10940
10939
|
|
|
10941
10940
|
/**
|
|
10942
10941
|
* Whether a given decorator should be treated as an Angular decorator.
|
|
@@ -11675,7 +11674,7 @@ function i18nSerialize(bundle, formatName, options) {
|
|
|
11675
11674
|
let serializer;
|
|
11676
11675
|
switch (format) {
|
|
11677
11676
|
case 'xmb':
|
|
11678
|
-
serializer = new
|
|
11677
|
+
serializer = new checker.Xmb();
|
|
11679
11678
|
break;
|
|
11680
11679
|
case 'xliff2':
|
|
11681
11680
|
case 'xlf2':
|
|
@@ -14039,7 +14038,7 @@ class IndexingContext {
|
|
|
14039
14038
|
* Visiting `text {{prop}}` will return
|
|
14040
14039
|
* `[TopLevelIdentifier {name: 'prop', span: {start: 7, end: 11}}]`.
|
|
14041
14040
|
*/
|
|
14042
|
-
class ExpressionVisitor extends
|
|
14041
|
+
class ExpressionVisitor extends checker.RecursiveAstVisitor {
|
|
14043
14042
|
expressionStr;
|
|
14044
14043
|
absoluteOffset;
|
|
14045
14044
|
boundTemplate;
|
|
@@ -14091,12 +14090,12 @@ class ExpressionVisitor extends compiler.RecursiveAstVisitor {
|
|
|
14091
14090
|
// impossible to determine by an indexer and unsupported by the indexing module.
|
|
14092
14091
|
// The indexing module also does not currently support references to identifiers declared in the
|
|
14093
14092
|
// template itself, which have a non-null expression target.
|
|
14094
|
-
if (!(ast.receiver instanceof
|
|
14093
|
+
if (!(ast.receiver instanceof checker.ImplicitReceiver)) {
|
|
14095
14094
|
return;
|
|
14096
14095
|
}
|
|
14097
14096
|
// The source span of the requested AST starts at a location that is offset from the expression.
|
|
14098
14097
|
let identifierStart = ast.sourceSpan.start - this.absoluteOffset;
|
|
14099
|
-
if (ast instanceof
|
|
14098
|
+
if (ast instanceof checker.PropertyRead || ast instanceof checker.PropertyWrite) {
|
|
14100
14099
|
// For `PropertyRead` and `PropertyWrite`, the identifier starts at the `nameSpan`, not
|
|
14101
14100
|
// necessarily the `sourceSpan`.
|
|
14102
14101
|
identifierStart = ast.nameSpan.start - this.absoluteOffset;
|
|
@@ -14124,7 +14123,7 @@ class ExpressionVisitor extends compiler.RecursiveAstVisitor {
|
|
|
14124
14123
|
* Visits the AST of a parsed Angular template. Discovers and stores
|
|
14125
14124
|
* identifiers of interest, deferring to an `ExpressionVisitor` as needed.
|
|
14126
14125
|
*/
|
|
14127
|
-
let TemplateVisitor$1 = class TemplateVisitor extends
|
|
14126
|
+
let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor {
|
|
14128
14127
|
boundTemplate;
|
|
14129
14128
|
// Identifiers of interest found in the template.
|
|
14130
14129
|
identifiers = new Set();
|
|
@@ -14225,7 +14224,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends compiler.RecursiveVisitor
|
|
|
14225
14224
|
this.visitAll(block.children);
|
|
14226
14225
|
}
|
|
14227
14226
|
visitDeferredTrigger(trigger) {
|
|
14228
|
-
if (trigger instanceof
|
|
14227
|
+
if (trigger instanceof checker.BoundDeferredTrigger) {
|
|
14229
14228
|
this.visitExpression(trigger.value);
|
|
14230
14229
|
}
|
|
14231
14230
|
}
|
|
@@ -14270,7 +14269,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends compiler.RecursiveVisitor
|
|
|
14270
14269
|
}
|
|
14271
14270
|
/** Creates an identifier for a template element or template node. */
|
|
14272
14271
|
elementOrTemplateToIdentifier(node) {
|
|
14273
|
-
if (node instanceof
|
|
14272
|
+
if (node instanceof checker.Component || node instanceof checker.Directive) {
|
|
14274
14273
|
throw new Error('TODO');
|
|
14275
14274
|
}
|
|
14276
14275
|
// If this node has already been seen, return the cached result.
|
|
@@ -14279,7 +14278,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends compiler.RecursiveVisitor
|
|
|
14279
14278
|
}
|
|
14280
14279
|
let name;
|
|
14281
14280
|
let kind;
|
|
14282
|
-
if (node instanceof
|
|
14281
|
+
if (node instanceof checker.Template) {
|
|
14283
14282
|
name = node.tagName ?? 'ng-template';
|
|
14284
14283
|
kind = IdentifierKind.Template;
|
|
14285
14284
|
}
|
|
@@ -14341,7 +14340,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends compiler.RecursiveVisitor
|
|
|
14341
14340
|
}
|
|
14342
14341
|
const span = new AbsoluteSourceSpan(start, start + name.length);
|
|
14343
14342
|
let identifier;
|
|
14344
|
-
if (node instanceof
|
|
14343
|
+
if (node instanceof checker.Reference$1) {
|
|
14345
14344
|
// If the node is a reference, we care about its target. The target can be an element, a
|
|
14346
14345
|
// template, a directive applied on a template or element (in which case the directive field
|
|
14347
14346
|
// is non-null), or nothing at all.
|
|
@@ -14350,10 +14349,10 @@ let TemplateVisitor$1 = class TemplateVisitor extends compiler.RecursiveVisitor
|
|
|
14350
14349
|
if (refTarget) {
|
|
14351
14350
|
let node = null;
|
|
14352
14351
|
let directive = null;
|
|
14353
|
-
if (refTarget instanceof
|
|
14354
|
-
refTarget instanceof
|
|
14355
|
-
refTarget instanceof
|
|
14356
|
-
refTarget instanceof
|
|
14352
|
+
if (refTarget instanceof checker.Element ||
|
|
14353
|
+
refTarget instanceof checker.Template ||
|
|
14354
|
+
refTarget instanceof checker.Component ||
|
|
14355
|
+
refTarget instanceof checker.Directive) {
|
|
14357
14356
|
node = this.elementOrTemplateToIdentifier(refTarget);
|
|
14358
14357
|
}
|
|
14359
14358
|
else {
|
|
@@ -14375,7 +14374,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends compiler.RecursiveVisitor
|
|
|
14375
14374
|
target,
|
|
14376
14375
|
};
|
|
14377
14376
|
}
|
|
14378
|
-
else if (node instanceof
|
|
14377
|
+
else if (node instanceof checker.Variable) {
|
|
14379
14378
|
identifier = {
|
|
14380
14379
|
name,
|
|
14381
14380
|
span,
|
|
@@ -14409,7 +14408,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends compiler.RecursiveVisitor
|
|
|
14409
14408
|
*/
|
|
14410
14409
|
visitExpression(ast) {
|
|
14411
14410
|
// Only include ASTs that have information about their source and absolute source spans.
|
|
14412
|
-
if (ast instanceof
|
|
14411
|
+
if (ast instanceof checker.ASTWithSource && ast.source !== null) {
|
|
14413
14412
|
// Make target to identifier mapping closure stateful to this visitor instance.
|
|
14414
14413
|
const targetToIdentifier = this.targetToIdentifier.bind(this);
|
|
14415
14414
|
const absoluteOffset = ast.sourceSpan.start;
|
|
@@ -14452,7 +14451,7 @@ function generateAnalysis(context) {
|
|
|
14452
14451
|
});
|
|
14453
14452
|
// Get source files for the component and the template. If the template is inline, its source
|
|
14454
14453
|
// file is the component's.
|
|
14455
|
-
const componentFile = new
|
|
14454
|
+
const componentFile = new checker.ParseSourceFile(declaration.getSourceFile().getFullText(), declaration.getSourceFile().fileName);
|
|
14456
14455
|
let templateFile;
|
|
14457
14456
|
if (templateMeta.isInline) {
|
|
14458
14457
|
templateFile = componentFile;
|
|
@@ -14995,7 +14994,7 @@ class TemplateCheckWithVisitor {
|
|
|
14995
14994
|
/**
|
|
14996
14995
|
* Visits all nodes in a template (TmplAstNode and AST) and calls `visitNode` for each one.
|
|
14997
14996
|
*/
|
|
14998
|
-
class TemplateVisitor extends
|
|
14997
|
+
class TemplateVisitor extends checker.RecursiveAstVisitor {
|
|
14999
14998
|
ctx;
|
|
15000
14999
|
component;
|
|
15001
15000
|
check;
|
|
@@ -15016,7 +15015,7 @@ class TemplateVisitor extends compiler.RecursiveAstVisitor {
|
|
|
15016
15015
|
}
|
|
15017
15016
|
}
|
|
15018
15017
|
visitAst(ast) {
|
|
15019
|
-
if (ast instanceof
|
|
15018
|
+
if (ast instanceof checker.ASTWithSource) {
|
|
15020
15019
|
ast = ast.ast;
|
|
15021
15020
|
}
|
|
15022
15021
|
this.visit(ast);
|
|
@@ -15074,7 +15073,7 @@ class TemplateVisitor extends compiler.RecursiveAstVisitor {
|
|
|
15074
15073
|
deferred.visitAll(this);
|
|
15075
15074
|
}
|
|
15076
15075
|
visitDeferredTrigger(trigger) {
|
|
15077
|
-
if (trigger instanceof
|
|
15076
|
+
if (trigger instanceof checker.BoundDeferredTrigger) {
|
|
15078
15077
|
this.visitAst(trigger.value);
|
|
15079
15078
|
}
|
|
15080
15079
|
}
|
|
@@ -15151,13 +15150,13 @@ class InterpolatedSignalCheck extends TemplateCheckWithVisitor {
|
|
|
15151
15150
|
code = checker.ErrorCode.INTERPOLATED_SIGNAL_NOT_INVOKED;
|
|
15152
15151
|
visitNode(ctx, component, node) {
|
|
15153
15152
|
// interpolations like `{{ mySignal }}`
|
|
15154
|
-
if (node instanceof
|
|
15153
|
+
if (node instanceof checker.Interpolation) {
|
|
15155
15154
|
return node.expressions
|
|
15156
|
-
.filter((item) => item instanceof
|
|
15155
|
+
.filter((item) => item instanceof checker.PropertyRead)
|
|
15157
15156
|
.flatMap((item) => buildDiagnosticForSignal(ctx, item, component));
|
|
15158
15157
|
}
|
|
15159
15158
|
// bound properties like `[prop]="mySignal"`
|
|
15160
|
-
else if (node instanceof
|
|
15159
|
+
else if (node instanceof checker.BoundAttribute) {
|
|
15161
15160
|
// we skip the check if the node is an input binding
|
|
15162
15161
|
const usedDirectives = ctx.templateTypeChecker.getUsedDirectives(component);
|
|
15163
15162
|
if (usedDirectives !== null &&
|
|
@@ -15167,17 +15166,17 @@ class InterpolatedSignalCheck extends TemplateCheckWithVisitor {
|
|
|
15167
15166
|
// otherwise, we check if the node is
|
|
15168
15167
|
if (
|
|
15169
15168
|
// a bound property like `[prop]="mySignal"`
|
|
15170
|
-
(node.type ===
|
|
15169
|
+
(node.type === checker.BindingType.Property ||
|
|
15171
15170
|
// or a class binding like `[class.myClass]="mySignal"`
|
|
15172
|
-
node.type ===
|
|
15171
|
+
node.type === checker.BindingType.Class ||
|
|
15173
15172
|
// or a style binding like `[style.width]="mySignal"`
|
|
15174
|
-
node.type ===
|
|
15173
|
+
node.type === checker.BindingType.Style ||
|
|
15175
15174
|
// or an attribute binding like `[attr.role]="mySignal"`
|
|
15176
|
-
node.type ===
|
|
15175
|
+
node.type === checker.BindingType.Attribute ||
|
|
15177
15176
|
// or an animation binding like `[@myAnimation]="mySignal"`
|
|
15178
|
-
node.type ===
|
|
15179
|
-
node.value instanceof
|
|
15180
|
-
node.value.ast instanceof
|
|
15177
|
+
node.type === checker.BindingType.Animation) &&
|
|
15178
|
+
node.value instanceof checker.ASTWithSource &&
|
|
15179
|
+
node.value.ast instanceof checker.PropertyRead) {
|
|
15181
15180
|
return buildDiagnosticForSignal(ctx, node.value.ast, component);
|
|
15182
15181
|
}
|
|
15183
15182
|
}
|
|
@@ -15230,7 +15229,7 @@ const factory$d = {
|
|
|
15230
15229
|
class InvalidBananaInBoxCheck extends TemplateCheckWithVisitor {
|
|
15231
15230
|
code = checker.ErrorCode.INVALID_BANANA_IN_BOX;
|
|
15232
15231
|
visitNode(ctx, component, node) {
|
|
15233
|
-
if (!(node instanceof
|
|
15232
|
+
if (!(node instanceof checker.BoundEvent))
|
|
15234
15233
|
return [];
|
|
15235
15234
|
const name = node.name;
|
|
15236
15235
|
if (!name.startsWith('[') || !name.endsWith(']'))
|
|
@@ -15283,7 +15282,7 @@ class MissingControlFlowDirectiveCheck extends TemplateCheckWithVisitor {
|
|
|
15283
15282
|
return super.run(ctx, component, template);
|
|
15284
15283
|
}
|
|
15285
15284
|
visitNode(ctx, component, node) {
|
|
15286
|
-
if (!(node instanceof
|
|
15285
|
+
if (!(node instanceof checker.Template))
|
|
15287
15286
|
return [];
|
|
15288
15287
|
const controlFlowAttr = node.templateAttrs.find((attr) => KNOWN_CONTROL_FLOW_DIRECTIVES$1.has(attr.name));
|
|
15289
15288
|
if (!controlFlowAttr)
|
|
@@ -15318,7 +15317,7 @@ const factory$b = {
|
|
|
15318
15317
|
class MissingNgForOfLetCheck extends TemplateCheckWithVisitor {
|
|
15319
15318
|
code = checker.ErrorCode.MISSING_NGFOROF_LET;
|
|
15320
15319
|
visitNode(ctx, component, node) {
|
|
15321
|
-
if (!(node instanceof
|
|
15320
|
+
if (!(node instanceof checker.Template)) {
|
|
15322
15321
|
return [];
|
|
15323
15322
|
}
|
|
15324
15323
|
if (node.templateAttrs.length === 0) {
|
|
@@ -15375,7 +15374,7 @@ class MissingStructuralDirectiveCheck extends TemplateCheckWithVisitor {
|
|
|
15375
15374
|
return super.run(ctx, component, template);
|
|
15376
15375
|
}
|
|
15377
15376
|
visitNode(ctx, component, node) {
|
|
15378
|
-
if (!(node instanceof
|
|
15377
|
+
if (!(node instanceof checker.Template))
|
|
15379
15378
|
return [];
|
|
15380
15379
|
const customStructuralDirective = node.templateAttrs.find((attr) => !KNOWN_CONTROL_FLOW_DIRECTIVES.has(attr.name));
|
|
15381
15380
|
if (!customStructuralDirective)
|
|
@@ -15407,7 +15406,7 @@ class NullishCoalescingNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15407
15406
|
canVisitStructuralAttributes = false;
|
|
15408
15407
|
code = checker.ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
|
|
15409
15408
|
visitNode(ctx, component, node) {
|
|
15410
|
-
if (!(node instanceof
|
|
15409
|
+
if (!(node instanceof checker.Binary) || node.operation !== '??')
|
|
15411
15410
|
return [];
|
|
15412
15411
|
const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.left, component);
|
|
15413
15412
|
if (symbolLeft === null || symbolLeft.kind !== checker.SymbolKind.Expression) {
|
|
@@ -15459,9 +15458,9 @@ class OptionalChainNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15459
15458
|
canVisitStructuralAttributes = false;
|
|
15460
15459
|
code = checker.ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
|
|
15461
15460
|
visitNode(ctx, component, node) {
|
|
15462
|
-
if (!(node instanceof
|
|
15463
|
-
!(node instanceof
|
|
15464
|
-
!(node instanceof
|
|
15461
|
+
if (!(node instanceof checker.SafeCall) &&
|
|
15462
|
+
!(node instanceof checker.SafePropertyRead) &&
|
|
15463
|
+
!(node instanceof checker.SafeKeyedRead))
|
|
15465
15464
|
return [];
|
|
15466
15465
|
const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.receiver, component);
|
|
15467
15466
|
if (symbolLeft === null || symbolLeft.kind !== checker.SymbolKind.Expression) {
|
|
@@ -15486,7 +15485,7 @@ class OptionalChainNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15486
15485
|
if (templateMapping === null) {
|
|
15487
15486
|
return [];
|
|
15488
15487
|
}
|
|
15489
|
-
const advice = node instanceof
|
|
15488
|
+
const advice = node instanceof checker.SafePropertyRead
|
|
15490
15489
|
? `the '?.' operator can be replaced with the '.' operator`
|
|
15491
15490
|
: `the '?.' operator can be safely removed`;
|
|
15492
15491
|
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}.`);
|
|
@@ -15515,14 +15514,14 @@ class NgSkipHydrationSpec extends TemplateCheckWithVisitor {
|
|
|
15515
15514
|
code = checker.ErrorCode.SKIP_HYDRATION_NOT_STATIC;
|
|
15516
15515
|
visitNode(ctx, component, node) {
|
|
15517
15516
|
/** Binding should always error */
|
|
15518
|
-
if (node instanceof
|
|
15517
|
+
if (node instanceof checker.BoundAttribute && node.name === NG_SKIP_HYDRATION_ATTR_NAME) {
|
|
15519
15518
|
const errorString = `ngSkipHydration should not be used as a binding.`;
|
|
15520
15519
|
const diagnostic = ctx.makeTemplateDiagnostic(node.sourceSpan, errorString);
|
|
15521
15520
|
return [diagnostic];
|
|
15522
15521
|
}
|
|
15523
15522
|
/** No value, empty string or `"true"` are the only valid values */
|
|
15524
15523
|
const acceptedValues = ['true', '' /* empty string */];
|
|
15525
|
-
if (node instanceof
|
|
15524
|
+
if (node instanceof checker.TextAttribute &&
|
|
15526
15525
|
node.name === NG_SKIP_HYDRATION_ATTR_NAME &&
|
|
15527
15526
|
!acceptedValues.includes(node.value) &&
|
|
15528
15527
|
node.value !== undefined) {
|
|
@@ -15547,7 +15546,7 @@ const STYLE_SUFFIXES = ['px', '%', 'em'];
|
|
|
15547
15546
|
class SuffixNotSupportedCheck extends TemplateCheckWithVisitor {
|
|
15548
15547
|
code = checker.ErrorCode.SUFFIX_NOT_SUPPORTED;
|
|
15549
15548
|
visitNode(ctx, component, node) {
|
|
15550
|
-
if (!(node instanceof
|
|
15549
|
+
if (!(node instanceof checker.BoundAttribute))
|
|
15551
15550
|
return [];
|
|
15552
15551
|
if (!node.keySpan.toString().startsWith('attr.') ||
|
|
15553
15552
|
!STYLE_SUFFIXES.some((suffix) => node.name.endsWith(`.${suffix}`))) {
|
|
@@ -15573,7 +15572,7 @@ const factory$5 = {
|
|
|
15573
15572
|
class TextAttributeNotBindingSpec extends TemplateCheckWithVisitor {
|
|
15574
15573
|
code = checker.ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING;
|
|
15575
15574
|
visitNode(ctx, component, node) {
|
|
15576
|
-
if (!(node instanceof
|
|
15575
|
+
if (!(node instanceof checker.TextAttribute))
|
|
15577
15576
|
return [];
|
|
15578
15577
|
const name = node.name;
|
|
15579
15578
|
if (!name.startsWith('attr.') && !name.startsWith('style.') && !name.startsWith('class.')) {
|
|
@@ -15617,19 +15616,19 @@ class UninvokedFunctionInEventBindingSpec extends TemplateCheckWithVisitor {
|
|
|
15617
15616
|
code = checker.ErrorCode.UNINVOKED_FUNCTION_IN_EVENT_BINDING;
|
|
15618
15617
|
visitNode(ctx, component, node) {
|
|
15619
15618
|
// If the node is not a bound event, skip it.
|
|
15620
|
-
if (!(node instanceof
|
|
15619
|
+
if (!(node instanceof checker.BoundEvent))
|
|
15621
15620
|
return [];
|
|
15622
15621
|
// If the node is not a regular or animation event, skip it.
|
|
15623
|
-
if (node.type !==
|
|
15622
|
+
if (node.type !== checker.ParsedEventType.Regular && node.type !== checker.ParsedEventType.Animation)
|
|
15624
15623
|
return [];
|
|
15625
|
-
if (!(node.handler instanceof
|
|
15624
|
+
if (!(node.handler instanceof checker.ASTWithSource))
|
|
15626
15625
|
return [];
|
|
15627
15626
|
const sourceExpressionText = node.handler.source || '';
|
|
15628
|
-
if (node.handler.ast instanceof
|
|
15627
|
+
if (node.handler.ast instanceof checker.Chain) {
|
|
15629
15628
|
// (click)="increment; decrement"
|
|
15630
15629
|
return node.handler.ast.expressions.flatMap((expression) => assertExpressionInvoked(expression, component, node, sourceExpressionText, ctx));
|
|
15631
15630
|
}
|
|
15632
|
-
if (node.handler.ast instanceof
|
|
15631
|
+
if (node.handler.ast instanceof checker.Conditional) {
|
|
15633
15632
|
// (click)="true ? increment : decrement"
|
|
15634
15633
|
const { trueExp, falseExp } = node.handler.ast;
|
|
15635
15634
|
return [trueExp, falseExp].flatMap((expression) => assertExpressionInvoked(expression, component, node, sourceExpressionText, ctx));
|
|
@@ -15643,10 +15642,10 @@ class UninvokedFunctionInEventBindingSpec extends TemplateCheckWithVisitor {
|
|
|
15643
15642
|
* If the expression is a property read, and it has a call signature, a diagnostic is generated.
|
|
15644
15643
|
*/
|
|
15645
15644
|
function assertExpressionInvoked(expression, component, node, expressionText, ctx) {
|
|
15646
|
-
if (expression instanceof
|
|
15645
|
+
if (expression instanceof checker.Call || expression instanceof checker.SafeCall) {
|
|
15647
15646
|
return []; // If the method is called, skip it.
|
|
15648
15647
|
}
|
|
15649
|
-
if (!(expression instanceof
|
|
15648
|
+
if (!(expression instanceof checker.PropertyRead) && !(expression instanceof checker.SafePropertyRead)) {
|
|
15650
15649
|
return []; // If the expression is not a property read, skip it.
|
|
15651
15650
|
}
|
|
15652
15651
|
const symbol = ctx.templateTypeChecker.getSymbolOfNode(expression, component);
|
|
@@ -15675,10 +15674,10 @@ const factory$3 = {
|
|
|
15675
15674
|
class UnparenthesizedNullishCoalescing extends TemplateCheckWithVisitor {
|
|
15676
15675
|
code = checker.ErrorCode.UNPARENTHESIZED_NULLISH_COALESCING;
|
|
15677
15676
|
visitNode(ctx, component, node) {
|
|
15678
|
-
if (node instanceof
|
|
15677
|
+
if (node instanceof checker.Binary) {
|
|
15679
15678
|
if (node.operation === '&&' || node.operation === '||') {
|
|
15680
|
-
if ((node.left instanceof
|
|
15681
|
-
(node.right instanceof
|
|
15679
|
+
if ((node.left instanceof checker.Binary && node.left.operation === '??') ||
|
|
15680
|
+
(node.right instanceof checker.Binary && node.right.operation === '??')) {
|
|
15682
15681
|
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
|
|
15683
15682
|
if (symbol?.kind !== checker.SymbolKind.Expression) {
|
|
15684
15683
|
return [];
|
|
@@ -15720,13 +15719,13 @@ class UnusedLetDeclarationCheck extends TemplateCheckWithVisitor {
|
|
|
15720
15719
|
return diagnostics;
|
|
15721
15720
|
}
|
|
15722
15721
|
visitNode(ctx, component, node) {
|
|
15723
|
-
if (node instanceof
|
|
15722
|
+
if (node instanceof checker.LetDeclaration) {
|
|
15724
15723
|
this.getAnalysis(component).allLetDeclarations.add(node);
|
|
15725
15724
|
}
|
|
15726
|
-
else if (node instanceof
|
|
15727
|
-
const unwrappedNode = node instanceof
|
|
15725
|
+
else if (node instanceof checker.AST) {
|
|
15726
|
+
const unwrappedNode = node instanceof checker.ASTWithSource ? node.ast : node;
|
|
15728
15727
|
const target = ctx.templateTypeChecker.getExpressionTarget(unwrappedNode, component);
|
|
15729
|
-
if (target !== null && target instanceof
|
|
15728
|
+
if (target !== null && target instanceof checker.LetDeclaration) {
|
|
15730
15729
|
this.getAnalysis(component).usedLetDeclarations.add(target);
|
|
15731
15730
|
}
|
|
15732
15731
|
}
|
|
@@ -15751,15 +15750,15 @@ const factory$1 = {
|
|
|
15751
15750
|
class UninvokedTrackFunctionCheck extends TemplateCheckWithVisitor {
|
|
15752
15751
|
code = checker.ErrorCode.UNINVOKED_TRACK_FUNCTION;
|
|
15753
15752
|
visitNode(ctx, component, node) {
|
|
15754
|
-
if (!(node instanceof
|
|
15753
|
+
if (!(node instanceof checker.ForLoopBlock) || !node.trackBy) {
|
|
15755
15754
|
return [];
|
|
15756
15755
|
}
|
|
15757
|
-
if (node.trackBy.ast instanceof
|
|
15756
|
+
if (node.trackBy.ast instanceof checker.Call || node.trackBy.ast instanceof checker.SafeCall) {
|
|
15758
15757
|
// If the method is called, skip it.
|
|
15759
15758
|
return [];
|
|
15760
15759
|
}
|
|
15761
|
-
if (!(node.trackBy.ast instanceof
|
|
15762
|
-
!(node.trackBy.ast instanceof
|
|
15760
|
+
if (!(node.trackBy.ast instanceof checker.PropertyRead) &&
|
|
15761
|
+
!(node.trackBy.ast instanceof checker.SafePropertyRead)) {
|
|
15763
15762
|
// If the expression is not a property read, skip it.
|
|
15764
15763
|
return [];
|
|
15765
15764
|
}
|
|
@@ -15904,7 +15903,7 @@ class TemplateSemanticsCheckerImpl {
|
|
|
15904
15903
|
}
|
|
15905
15904
|
}
|
|
15906
15905
|
/** Visitor that verifies the semantics of a template. */
|
|
15907
|
-
class TemplateSemanticsVisitor extends
|
|
15906
|
+
class TemplateSemanticsVisitor extends checker.RecursiveVisitor {
|
|
15908
15907
|
expressionVisitor;
|
|
15909
15908
|
constructor(expressionVisitor) {
|
|
15910
15909
|
super();
|
|
@@ -15923,7 +15922,7 @@ class TemplateSemanticsVisitor extends compiler.RecursiveVisitor {
|
|
|
15923
15922
|
}
|
|
15924
15923
|
}
|
|
15925
15924
|
/** Visitor that verifies the semantics of the expressions within a template. */
|
|
15926
|
-
class ExpressionsSemanticsVisitor extends
|
|
15925
|
+
class ExpressionsSemanticsVisitor extends checker.RecursiveAstVisitor {
|
|
15927
15926
|
templateTypeChecker;
|
|
15928
15927
|
component;
|
|
15929
15928
|
diagnostics;
|
|
@@ -15942,26 +15941,26 @@ class ExpressionsSemanticsVisitor extends compiler.RecursiveAstVisitor {
|
|
|
15942
15941
|
this.checkForIllegalWriteInTwoWayBinding(ast, context);
|
|
15943
15942
|
}
|
|
15944
15943
|
checkForIllegalWriteInEventBinding(ast, context) {
|
|
15945
|
-
if (!(context instanceof
|
|
15944
|
+
if (!(context instanceof checker.BoundEvent) || !(ast.receiver instanceof checker.ImplicitReceiver)) {
|
|
15946
15945
|
return;
|
|
15947
15946
|
}
|
|
15948
15947
|
const target = this.templateTypeChecker.getExpressionTarget(ast, this.component);
|
|
15949
|
-
if (target instanceof
|
|
15948
|
+
if (target instanceof checker.Variable) {
|
|
15950
15949
|
const errorMessage = `Cannot use variable '${target.name}' as the left-hand side of an assignment expression. Template variables are read-only.`;
|
|
15951
15950
|
this.diagnostics.push(this.makeIllegalTemplateVarDiagnostic(target, context, errorMessage));
|
|
15952
15951
|
}
|
|
15953
15952
|
}
|
|
15954
15953
|
checkForIllegalWriteInTwoWayBinding(ast, context) {
|
|
15955
15954
|
// Only check top-level property reads inside two-way bindings for illegal assignments.
|
|
15956
|
-
if (!(context instanceof
|
|
15957
|
-
context.type !==
|
|
15958
|
-
!(ast.receiver instanceof
|
|
15955
|
+
if (!(context instanceof checker.BoundEvent) ||
|
|
15956
|
+
context.type !== checker.ParsedEventType.TwoWay ||
|
|
15957
|
+
!(ast.receiver instanceof checker.ImplicitReceiver) ||
|
|
15959
15958
|
ast !== unwrapAstWithSource(context.handler)) {
|
|
15960
15959
|
return;
|
|
15961
15960
|
}
|
|
15962
15961
|
const target = this.templateTypeChecker.getExpressionTarget(ast, this.component);
|
|
15963
|
-
const isVariable = target instanceof
|
|
15964
|
-
const isLet = target instanceof
|
|
15962
|
+
const isVariable = target instanceof checker.Variable;
|
|
15963
|
+
const isLet = target instanceof checker.LetDeclaration;
|
|
15965
15964
|
if (!isVariable && !isLet) {
|
|
15966
15965
|
return;
|
|
15967
15966
|
}
|
|
@@ -15979,7 +15978,7 @@ class ExpressionsSemanticsVisitor extends compiler.RecursiveAstVisitor {
|
|
|
15979
15978
|
}
|
|
15980
15979
|
}
|
|
15981
15980
|
makeIllegalTemplateVarDiagnostic(target, expressionNode, errorMessage) {
|
|
15982
|
-
const span = target instanceof
|
|
15981
|
+
const span = target instanceof checker.Variable ? target.valueSpan || target.sourceSpan : target.sourceSpan;
|
|
15983
15982
|
return this.templateTypeChecker.makeTemplateDiagnostic(this.component, expressionNode.handlerSpan, ts.DiagnosticCategory.Error, checker.ngErrorCode(checker.ErrorCode.WRITE_TO_READ_ONLY_VARIABLE), errorMessage, [
|
|
15984
15983
|
{
|
|
15985
15984
|
text: `'${target.name}' is declared here.`,
|
|
@@ -15991,7 +15990,7 @@ class ExpressionsSemanticsVisitor extends compiler.RecursiveAstVisitor {
|
|
|
15991
15990
|
}
|
|
15992
15991
|
}
|
|
15993
15992
|
function unwrapAstWithSource(ast) {
|
|
15994
|
-
return ast instanceof
|
|
15993
|
+
return ast instanceof checker.ASTWithSource ? ast.ast : ast;
|
|
15995
15994
|
}
|
|
15996
15995
|
|
|
15997
15996
|
/*!
|
|
@@ -18975,7 +18974,7 @@ var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
|
|
|
18975
18974
|
* @param minVersion Minimum required version for the feature.
|
|
18976
18975
|
*/
|
|
18977
18976
|
function coreVersionSupportsFeature(coreVersion, minVersion) {
|
|
18978
|
-
// A version of `20.0.
|
|
18977
|
+
// A version of `20.0.1` usually means that core is at head so it supports
|
|
18979
18978
|
// all features. Use string interpolation prevent the placeholder from being replaced
|
|
18980
18979
|
// with the current version during build time.
|
|
18981
18980
|
if (coreVersion === `0.0.0-${'PLACEHOLDER'}`) {
|
|
@@ -20564,7 +20563,7 @@ class NgtscProgram {
|
|
|
20564
20563
|
return [];
|
|
20565
20564
|
}
|
|
20566
20565
|
emitXi18n() {
|
|
20567
|
-
const ctx = new MessageBundle(new
|
|
20566
|
+
const ctx = new MessageBundle(new checker.HtmlParser(), [], {}, this.options.i18nOutLocale ?? null, this.options.i18nPreserveWhitespaceForLegacyExtraction);
|
|
20568
20567
|
this.compiler.xi18n(ctx);
|
|
20569
20568
|
i18nExtract(this.options.i18nOutFormat ?? null, this.options.i18nOutFile ?? null, this.host, this.options, ctx, checker.resolve);
|
|
20570
20569
|
}
|