@angular/core 20.0.0-next.4 → 20.0.0-next.5
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-mxcXqDpA.d.ts +297 -0
- package/discovery.d-CyYpOJ7j.d.ts +7393 -0
- package/{event_dispatcher.d-pVP0-wST.d.ts → event_dispatcher.d-PWnbqZDx.d.ts} +3 -2
- package/fesm2022/attribute-B17mgaqe.mjs +24 -0
- package/fesm2022/attribute-B17mgaqe.mjs.map +1 -0
- package/fesm2022/core.mjs +580 -36869
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/debug_node-xKpCIZm-.mjs +32070 -0
- package/fesm2022/debug_node-xKpCIZm-.mjs.map +1 -0
- package/fesm2022/primitives/di.mjs +18 -4
- package/fesm2022/primitives/di.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +2 -16
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +5 -3
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/resource-BPpYEDic.mjs +621 -0
- package/fesm2022/resource-BPpYEDic.mjs.map +1 -0
- package/fesm2022/root_effect_scheduler-D0_b1cf_.mjs +3816 -0
- package/fesm2022/root_effect_scheduler-D0_b1cf_.mjs.map +1 -0
- package/fesm2022/rxjs-interop.mjs +91 -7
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/{untracked-DkcXpNb_.mjs → signal-DhRAAi7R.mjs} +16 -114
- package/fesm2022/signal-DhRAAi7R.mjs.map +1 -0
- package/fesm2022/testing.mjs +105 -103
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/untracked-DaaW3JJm.mjs +117 -0
- package/fesm2022/untracked-DaaW3JJm.mjs.map +1 -0
- package/fesm2022/weak_ref-DrMdAIDh.mjs +12 -0
- package/fesm2022/weak_ref-DrMdAIDh.mjs.map +1 -0
- package/{weak_ref.d-BZ7gyRag.d.ts → graph.d-StYigYp1.d.ts} +3 -24
- package/index.d.ts +2520 -10803
- package/ng_i18n_closure_mode.d-DLxSUiDr.d.ts +832 -0
- package/package.json +3 -3
- package/primitives/di/index.d.ts +3 -2
- package/primitives/event-dispatch/index.d.ts +3 -3
- package/primitives/signals/index.d.ts +8 -4
- package/rxjs-interop/index.d.ts +16 -4
- package/schematics/bundles/{apply_import_manager-CeNv8GIG.js → apply_import_manager-C-ysxahq.js} +3 -3
- package/schematics/bundles/{compiler_host-DwM3ugW3.js → change_tracker-0Ktek5Xl.js} +3 -121
- package/schematics/bundles/checker-DqUKCGda.js +17702 -0
- package/schematics/bundles/cleanup-unused-imports.js +6 -5
- package/schematics/bundles/{checker-k591b6WQ.js → compiler-CuoiHqkc.js} +366 -17992
- package/schematics/bundles/compiler_host-CAfDJO3W.js +129 -0
- package/schematics/bundles/control-flow-migration.js +28 -40
- package/schematics/bundles/document-core.js +96 -0
- package/schematics/bundles/imports-CIX-JgAN.js +1 -1
- package/schematics/bundles/{index-BhELUmYx.js → index-CwFQSYXZ.js} +30 -29
- package/schematics/bundles/{index-B4OAlHh8.js → index-WFXCe5Q0.js} +527 -524
- package/schematics/bundles/inject-flags.js +6 -5
- package/schematics/bundles/inject-migration.js +29 -10
- package/schematics/bundles/leading_space-D9nQ8UQC.js +1 -1
- package/schematics/bundles/{migrate_ts_type_references-Be0TNYen.js → migrate_ts_type_references-BNuHufqZ.js} +6 -5
- package/schematics/bundles/ng_decorators-DznZ5jMl.js +1 -1
- package/schematics/bundles/nodes-B16H9JUd.js +1 -1
- package/schematics/bundles/output-migration.js +15 -10
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.js +1 -1
- package/schematics/bundles/property_name-BBwFuqMe.js +1 -1
- package/schematics/bundles/route-lazy-loading.js +7 -5
- package/schematics/bundles/{run_in_devkit-CkvEksWP.js → run_in_devkit-CmHxABFr.js} +4 -3
- package/schematics/bundles/self-closing-tags-migration.js +10 -9
- package/schematics/bundles/signal-input-migration.js +8 -7
- package/schematics/bundles/signal-queries-migration.js +27 -14
- package/schematics/bundles/signals.js +8 -7
- package/schematics/bundles/standalone-migration.js +11 -9
- package/schematics/bundles/symbol-VPWguRxr.js +1 -1
- package/schematics/bundles/test-bed-get.js +5 -4
- package/schematics/collection.json +0 -6
- package/schematics/migrations.json +11 -0
- package/signal.d-BeaTIeOE.d.ts +31 -0
- package/testing/index.d.ts +13 -9
- package/weak_ref.d-ttyj86RV.d.ts +9 -0
- package/fesm2022/injector-BlLwZ2sr.mjs +0 -24
- package/fesm2022/injector-BlLwZ2sr.mjs.map +0 -1
- package/fesm2022/untracked-DkcXpNb_.mjs.map +0 -1
- package/navigation_types.d-DgDrF5rp.d.ts +0 -121
- package/schematics/ng-generate/control-flow-migration/schema.json +0 -20
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
3
|
+
* @license Angular v20.0.0-next.5
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var compiler = require('./compiler-CuoiHqkc.js');
|
|
10
10
|
var ts = require('typescript');
|
|
11
11
|
var p = require('path');
|
|
12
|
+
var checker = require('./checker-DqUKCGda.js');
|
|
12
13
|
require('os');
|
|
13
14
|
|
|
14
15
|
function _interopNamespaceDefault(e) {
|
|
@@ -44,7 +45,7 @@ class XmlTagDefinition {
|
|
|
44
45
|
return false;
|
|
45
46
|
}
|
|
46
47
|
getContentType() {
|
|
47
|
-
return
|
|
48
|
+
return compiler.TagContentType.PARSABLE_DATA;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
const _TAG_DEFINITION = new XmlTagDefinition();
|
|
@@ -52,7 +53,7 @@ function getXmlTagDefinition(tagName) {
|
|
|
52
53
|
return _TAG_DEFINITION;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
class XmlParser extends
|
|
56
|
+
class XmlParser extends compiler.Parser {
|
|
56
57
|
constructor() {
|
|
57
58
|
super(getXmlTagDefinition);
|
|
58
59
|
}
|
|
@@ -78,50 +79,50 @@ const _CONTEXT_GROUP_TAG = 'context-group';
|
|
|
78
79
|
const _CONTEXT_TAG = 'context';
|
|
79
80
|
// https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html
|
|
80
81
|
// https://docs.oasis-open.org/xliff/v1.2/xliff-profile-html/xliff-profile-html-1.2.html
|
|
81
|
-
class Xliff extends
|
|
82
|
+
class Xliff extends compiler.Serializer {
|
|
82
83
|
write(messages, locale) {
|
|
83
84
|
const visitor = new _WriteVisitor$1();
|
|
84
85
|
const transUnits = [];
|
|
85
86
|
messages.forEach((message) => {
|
|
86
87
|
let contextTags = [];
|
|
87
88
|
message.sources.forEach((source) => {
|
|
88
|
-
let contextGroupTag = new
|
|
89
|
-
contextGroupTag.children.push(new
|
|
90
|
-
new
|
|
91
|
-
]), new
|
|
92
|
-
new
|
|
93
|
-
]), new
|
|
94
|
-
contextTags.push(new
|
|
89
|
+
let contextGroupTag = new compiler.Tag(_CONTEXT_GROUP_TAG, { purpose: 'location' });
|
|
90
|
+
contextGroupTag.children.push(new compiler.CR(10), new compiler.Tag(_CONTEXT_TAG, { 'context-type': 'sourcefile' }, [
|
|
91
|
+
new compiler.Text$1(source.filePath),
|
|
92
|
+
]), new compiler.CR(10), new compiler.Tag(_CONTEXT_TAG, { 'context-type': 'linenumber' }, [
|
|
93
|
+
new compiler.Text$1(`${source.startLine}`),
|
|
94
|
+
]), new compiler.CR(8));
|
|
95
|
+
contextTags.push(new compiler.CR(8), contextGroupTag);
|
|
95
96
|
});
|
|
96
|
-
const transUnit = new
|
|
97
|
-
transUnit.children.push(new
|
|
97
|
+
const transUnit = new compiler.Tag(_UNIT_TAG$1, { id: message.id, datatype: 'html' });
|
|
98
|
+
transUnit.children.push(new compiler.CR(8), new compiler.Tag(_SOURCE_TAG$1, {}, visitor.serialize(message.nodes)), ...contextTags);
|
|
98
99
|
if (message.description) {
|
|
99
|
-
transUnit.children.push(new
|
|
100
|
-
new
|
|
100
|
+
transUnit.children.push(new compiler.CR(8), new compiler.Tag('note', { priority: '1', from: 'description' }, [
|
|
101
|
+
new compiler.Text$1(message.description),
|
|
101
102
|
]));
|
|
102
103
|
}
|
|
103
104
|
if (message.meaning) {
|
|
104
|
-
transUnit.children.push(new
|
|
105
|
+
transUnit.children.push(new compiler.CR(8), new compiler.Tag('note', { priority: '1', from: 'meaning' }, [new compiler.Text$1(message.meaning)]));
|
|
105
106
|
}
|
|
106
|
-
transUnit.children.push(new
|
|
107
|
-
transUnits.push(new
|
|
107
|
+
transUnit.children.push(new compiler.CR(6));
|
|
108
|
+
transUnits.push(new compiler.CR(6), transUnit);
|
|
108
109
|
});
|
|
109
|
-
const body = new
|
|
110
|
-
const file = new
|
|
110
|
+
const body = new compiler.Tag('body', {}, [...transUnits, new compiler.CR(4)]);
|
|
111
|
+
const file = new compiler.Tag('file', {
|
|
111
112
|
'source-language': locale || _DEFAULT_SOURCE_LANG$1,
|
|
112
113
|
datatype: 'plaintext',
|
|
113
114
|
original: 'ng2.template',
|
|
114
|
-
}, [new
|
|
115
|
-
const xliff = new
|
|
116
|
-
new
|
|
115
|
+
}, [new compiler.CR(4), body, new compiler.CR(2)]);
|
|
116
|
+
const xliff = new compiler.Tag('xliff', { version: _VERSION$1, xmlns: _XMLNS$1 }, [
|
|
117
|
+
new compiler.CR(2),
|
|
117
118
|
file,
|
|
118
|
-
new
|
|
119
|
+
new compiler.CR(),
|
|
119
120
|
]);
|
|
120
|
-
return
|
|
121
|
-
new
|
|
122
|
-
new
|
|
121
|
+
return compiler.serialize([
|
|
122
|
+
new compiler.Declaration({ version: '1.0', encoding: 'UTF-8' }),
|
|
123
|
+
new compiler.CR(),
|
|
123
124
|
xliff,
|
|
124
|
-
new
|
|
125
|
+
new compiler.CR(),
|
|
125
126
|
]);
|
|
126
127
|
}
|
|
127
128
|
load(content, url) {
|
|
@@ -142,12 +143,12 @@ class Xliff extends checker.Serializer {
|
|
|
142
143
|
return { locale: locale, i18nNodesByMsgId };
|
|
143
144
|
}
|
|
144
145
|
digest(message) {
|
|
145
|
-
return
|
|
146
|
+
return compiler.digest(message);
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
let _WriteVisitor$1 = class _WriteVisitor {
|
|
149
150
|
visitText(text, context) {
|
|
150
|
-
return [new
|
|
151
|
+
return [new compiler.Text$1(text.value)];
|
|
151
152
|
}
|
|
152
153
|
visitContainer(container, context) {
|
|
153
154
|
const nodes = [];
|
|
@@ -155,11 +156,11 @@ let _WriteVisitor$1 = class _WriteVisitor {
|
|
|
155
156
|
return nodes;
|
|
156
157
|
}
|
|
157
158
|
visitIcu(icu, context) {
|
|
158
|
-
const nodes = [new
|
|
159
|
+
const nodes = [new compiler.Text$1(`{${icu.expressionPlaceholder}, ${icu.type}, `)];
|
|
159
160
|
Object.keys(icu.cases).forEach((c) => {
|
|
160
|
-
nodes.push(new
|
|
161
|
+
nodes.push(new compiler.Text$1(`${c} {`), ...icu.cases[c].visit(this), new compiler.Text$1(`} `));
|
|
161
162
|
});
|
|
162
|
-
nodes.push(new
|
|
163
|
+
nodes.push(new compiler.Text$1(`}`));
|
|
163
164
|
return nodes;
|
|
164
165
|
}
|
|
165
166
|
visitTagPlaceholder(ph, context) {
|
|
@@ -167,15 +168,15 @@ let _WriteVisitor$1 = class _WriteVisitor {
|
|
|
167
168
|
if (ph.isVoid) {
|
|
168
169
|
// void tags have no children nor closing tags
|
|
169
170
|
return [
|
|
170
|
-
new
|
|
171
|
+
new compiler.Tag(_PLACEHOLDER_TAG$1, { id: ph.startName, ctype, 'equiv-text': `<${ph.tag}/>` }),
|
|
171
172
|
];
|
|
172
173
|
}
|
|
173
|
-
const startTagPh = new
|
|
174
|
+
const startTagPh = new compiler.Tag(_PLACEHOLDER_TAG$1, {
|
|
174
175
|
id: ph.startName,
|
|
175
176
|
ctype,
|
|
176
177
|
'equiv-text': `<${ph.tag}>`,
|
|
177
178
|
});
|
|
178
|
-
const closeTagPh = new
|
|
179
|
+
const closeTagPh = new compiler.Tag(_PLACEHOLDER_TAG$1, {
|
|
179
180
|
id: ph.closeName,
|
|
180
181
|
ctype,
|
|
181
182
|
'equiv-text': `</${ph.tag}>`,
|
|
@@ -183,23 +184,23 @@ let _WriteVisitor$1 = class _WriteVisitor {
|
|
|
183
184
|
return [startTagPh, ...this.serialize(ph.children), closeTagPh];
|
|
184
185
|
}
|
|
185
186
|
visitPlaceholder(ph, context) {
|
|
186
|
-
return [new
|
|
187
|
+
return [new compiler.Tag(_PLACEHOLDER_TAG$1, { id: ph.name, 'equiv-text': `{{${ph.value}}}` })];
|
|
187
188
|
}
|
|
188
189
|
visitBlockPlaceholder(ph, context) {
|
|
189
190
|
const ctype = `x-${ph.name.toLowerCase().replace(/[^a-z0-9]/g, '-')}`;
|
|
190
|
-
const startTagPh = new
|
|
191
|
+
const startTagPh = new compiler.Tag(_PLACEHOLDER_TAG$1, {
|
|
191
192
|
id: ph.startName,
|
|
192
193
|
ctype,
|
|
193
194
|
'equiv-text': `@${ph.name}`,
|
|
194
195
|
});
|
|
195
|
-
const closeTagPh = new
|
|
196
|
+
const closeTagPh = new compiler.Tag(_PLACEHOLDER_TAG$1, { id: ph.closeName, ctype, 'equiv-text': `}` });
|
|
196
197
|
return [startTagPh, ...this.serialize(ph.children), closeTagPh];
|
|
197
198
|
}
|
|
198
199
|
visitIcuPlaceholder(ph, context) {
|
|
199
200
|
const equivText = `{${ph.value.expression}, ${ph.value.type}, ${Object.keys(ph.value.cases)
|
|
200
201
|
.map((value) => value + ' {...}')
|
|
201
202
|
.join(' ')}}`;
|
|
202
|
-
return [new
|
|
203
|
+
return [new compiler.Tag(_PLACEHOLDER_TAG$1, { id: ph.name, 'equiv-text': equivText })];
|
|
203
204
|
}
|
|
204
205
|
serialize(nodes) {
|
|
205
206
|
return [].concat(...nodes.map((node) => node.visit(this)));
|
|
@@ -218,7 +219,7 @@ class XliffParser {
|
|
|
218
219
|
this._msgIdToHtml = {};
|
|
219
220
|
const xml = new XmlParser().parse(xliff, url);
|
|
220
221
|
this._errors = xml.errors;
|
|
221
|
-
|
|
222
|
+
compiler.visitAll$1(this, xml.rootNodes, null);
|
|
222
223
|
return {
|
|
223
224
|
msgIdToHtml: this._msgIdToHtml,
|
|
224
225
|
errors: this._errors,
|
|
@@ -239,7 +240,7 @@ class XliffParser {
|
|
|
239
240
|
this._addError(element, `Duplicated translations for msg ${id}`);
|
|
240
241
|
}
|
|
241
242
|
else {
|
|
242
|
-
|
|
243
|
+
compiler.visitAll$1(this, element.children, null);
|
|
243
244
|
if (typeof this._unitMlString === 'string') {
|
|
244
245
|
this._msgIdToHtml[id] = this._unitMlString;
|
|
245
246
|
}
|
|
@@ -266,12 +267,12 @@ class XliffParser {
|
|
|
266
267
|
if (localeAttr) {
|
|
267
268
|
this._locale = localeAttr.value;
|
|
268
269
|
}
|
|
269
|
-
|
|
270
|
+
compiler.visitAll$1(this, element.children, null);
|
|
270
271
|
break;
|
|
271
272
|
default:
|
|
272
273
|
// TODO(vicb): assert file structure, xliff version
|
|
273
274
|
// For now only recurse on unhandled nodes
|
|
274
|
-
|
|
275
|
+
compiler.visitAll$1(this, element.children, null);
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
visitAttribute(attribute, context) { }
|
|
@@ -283,7 +284,7 @@ class XliffParser {
|
|
|
283
284
|
visitBlockParameter(parameter, context) { }
|
|
284
285
|
visitLetDeclaration(decl, context) { }
|
|
285
286
|
_addError(node, message) {
|
|
286
|
-
this._errors.push(new
|
|
287
|
+
this._errors.push(new compiler.I18nError(node.sourceSpan, message));
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
// Convert ml nodes (xliff syntax) to i18n nodes
|
|
@@ -295,41 +296,41 @@ let XmlToI18n$1 = class XmlToI18n {
|
|
|
295
296
|
this._errors = xmlIcu.errors;
|
|
296
297
|
const i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0
|
|
297
298
|
? []
|
|
298
|
-
: [].concat(...
|
|
299
|
+
: [].concat(...compiler.visitAll$1(this, xmlIcu.rootNodes));
|
|
299
300
|
return {
|
|
300
301
|
i18nNodes: i18nNodes,
|
|
301
302
|
errors: this._errors,
|
|
302
303
|
};
|
|
303
304
|
}
|
|
304
305
|
visitText(text, context) {
|
|
305
|
-
return new
|
|
306
|
+
return new compiler.Text$2(text.value, text.sourceSpan);
|
|
306
307
|
}
|
|
307
308
|
visitElement(el, context) {
|
|
308
309
|
if (el.name === _PLACEHOLDER_TAG$1) {
|
|
309
310
|
const nameAttr = el.attrs.find((attr) => attr.name === 'id');
|
|
310
311
|
if (nameAttr) {
|
|
311
|
-
return new
|
|
312
|
+
return new compiler.Placeholder('', nameAttr.value, el.sourceSpan);
|
|
312
313
|
}
|
|
313
314
|
this._addError(el, `<${_PLACEHOLDER_TAG$1}> misses the "id" attribute`);
|
|
314
315
|
return null;
|
|
315
316
|
}
|
|
316
317
|
if (el.name === _MARKER_TAG$1) {
|
|
317
|
-
return [].concat(...
|
|
318
|
+
return [].concat(...compiler.visitAll$1(this, el.children));
|
|
318
319
|
}
|
|
319
320
|
this._addError(el, `Unexpected tag`);
|
|
320
321
|
return null;
|
|
321
322
|
}
|
|
322
323
|
visitExpansion(icu, context) {
|
|
323
324
|
const caseMap = {};
|
|
324
|
-
|
|
325
|
-
caseMap[c.value] = new
|
|
325
|
+
compiler.visitAll$1(this, icu.cases).forEach((c) => {
|
|
326
|
+
caseMap[c.value] = new compiler.Container(c.nodes, icu.sourceSpan);
|
|
326
327
|
});
|
|
327
|
-
return new
|
|
328
|
+
return new compiler.Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
|
|
328
329
|
}
|
|
329
330
|
visitExpansionCase(icuCase, context) {
|
|
330
331
|
return {
|
|
331
332
|
value: icuCase.value,
|
|
332
|
-
nodes:
|
|
333
|
+
nodes: compiler.visitAll$1(this, icuCase.expression),
|
|
333
334
|
};
|
|
334
335
|
}
|
|
335
336
|
visitComment(comment, context) { }
|
|
@@ -338,7 +339,7 @@ let XmlToI18n$1 = class XmlToI18n {
|
|
|
338
339
|
visitBlockParameter(parameter, context) { }
|
|
339
340
|
visitLetDeclaration(decl, context) { }
|
|
340
341
|
_addError(node, message) {
|
|
341
|
-
this._errors.push(new
|
|
342
|
+
this._errors.push(new compiler.I18nError(node.sourceSpan, message));
|
|
342
343
|
}
|
|
343
344
|
};
|
|
344
345
|
function getCtypeForTag(tag) {
|
|
@@ -364,43 +365,43 @@ const _SOURCE_TAG = 'source';
|
|
|
364
365
|
const _TARGET_TAG = 'target';
|
|
365
366
|
const _UNIT_TAG = 'unit';
|
|
366
367
|
// https://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html
|
|
367
|
-
class Xliff2 extends
|
|
368
|
+
class Xliff2 extends compiler.Serializer {
|
|
368
369
|
write(messages, locale) {
|
|
369
370
|
const visitor = new _WriteVisitor();
|
|
370
371
|
const units = [];
|
|
371
372
|
messages.forEach((message) => {
|
|
372
|
-
const unit = new
|
|
373
|
-
const notes = new
|
|
373
|
+
const unit = new compiler.Tag(_UNIT_TAG, { id: message.id });
|
|
374
|
+
const notes = new compiler.Tag('notes');
|
|
374
375
|
if (message.description || message.meaning) {
|
|
375
376
|
if (message.description) {
|
|
376
|
-
notes.children.push(new
|
|
377
|
+
notes.children.push(new compiler.CR(8), new compiler.Tag('note', { category: 'description' }, [new compiler.Text$1(message.description)]));
|
|
377
378
|
}
|
|
378
379
|
if (message.meaning) {
|
|
379
|
-
notes.children.push(new
|
|
380
|
+
notes.children.push(new compiler.CR(8), new compiler.Tag('note', { category: 'meaning' }, [new compiler.Text$1(message.meaning)]));
|
|
380
381
|
}
|
|
381
382
|
}
|
|
382
383
|
message.sources.forEach((source) => {
|
|
383
|
-
notes.children.push(new
|
|
384
|
-
new
|
|
384
|
+
notes.children.push(new compiler.CR(8), new compiler.Tag('note', { category: 'location' }, [
|
|
385
|
+
new compiler.Text$1(`${source.filePath}:${source.startLine}${source.endLine !== source.startLine ? ',' + source.endLine : ''}`),
|
|
385
386
|
]));
|
|
386
387
|
});
|
|
387
|
-
notes.children.push(new
|
|
388
|
-
unit.children.push(new
|
|
389
|
-
const segment = new
|
|
390
|
-
segment.children.push(new
|
|
391
|
-
unit.children.push(new
|
|
392
|
-
units.push(new
|
|
388
|
+
notes.children.push(new compiler.CR(6));
|
|
389
|
+
unit.children.push(new compiler.CR(6), notes);
|
|
390
|
+
const segment = new compiler.Tag('segment');
|
|
391
|
+
segment.children.push(new compiler.CR(8), new compiler.Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes)), new compiler.CR(6));
|
|
392
|
+
unit.children.push(new compiler.CR(6), segment, new compiler.CR(4));
|
|
393
|
+
units.push(new compiler.CR(4), unit);
|
|
393
394
|
});
|
|
394
|
-
const file = new
|
|
395
|
+
const file = new compiler.Tag('file', { 'original': 'ng.template', id: 'ngi18n' }, [
|
|
395
396
|
...units,
|
|
396
|
-
new
|
|
397
|
+
new compiler.CR(2),
|
|
397
398
|
]);
|
|
398
|
-
const xliff = new
|
|
399
|
-
return
|
|
400
|
-
new
|
|
401
|
-
new
|
|
399
|
+
const xliff = new compiler.Tag(_XLIFF_TAG, { version: _VERSION, xmlns: _XMLNS, srcLang: locale || _DEFAULT_SOURCE_LANG }, [new compiler.CR(2), file, new compiler.CR()]);
|
|
400
|
+
return compiler.serialize([
|
|
401
|
+
new compiler.Declaration({ version: '1.0', encoding: 'UTF-8' }),
|
|
402
|
+
new compiler.CR(),
|
|
402
403
|
xliff,
|
|
403
|
-
new
|
|
404
|
+
new compiler.CR(),
|
|
404
405
|
]);
|
|
405
406
|
}
|
|
406
407
|
load(content, url) {
|
|
@@ -421,13 +422,13 @@ class Xliff2 extends checker.Serializer {
|
|
|
421
422
|
return { locale: locale, i18nNodesByMsgId };
|
|
422
423
|
}
|
|
423
424
|
digest(message) {
|
|
424
|
-
return
|
|
425
|
+
return compiler.decimalDigest(message);
|
|
425
426
|
}
|
|
426
427
|
}
|
|
427
428
|
class _WriteVisitor {
|
|
428
429
|
_nextPlaceholderId = 0;
|
|
429
430
|
visitText(text, context) {
|
|
430
|
-
return [new
|
|
431
|
+
return [new compiler.Text$1(text.value)];
|
|
431
432
|
}
|
|
432
433
|
visitContainer(container, context) {
|
|
433
434
|
const nodes = [];
|
|
@@ -435,17 +436,17 @@ class _WriteVisitor {
|
|
|
435
436
|
return nodes;
|
|
436
437
|
}
|
|
437
438
|
visitIcu(icu, context) {
|
|
438
|
-
const nodes = [new
|
|
439
|
+
const nodes = [new compiler.Text$1(`{${icu.expressionPlaceholder}, ${icu.type}, `)];
|
|
439
440
|
Object.keys(icu.cases).forEach((c) => {
|
|
440
|
-
nodes.push(new
|
|
441
|
+
nodes.push(new compiler.Text$1(`${c} {`), ...icu.cases[c].visit(this), new compiler.Text$1(`} `));
|
|
441
442
|
});
|
|
442
|
-
nodes.push(new
|
|
443
|
+
nodes.push(new compiler.Text$1(`}`));
|
|
443
444
|
return nodes;
|
|
444
445
|
}
|
|
445
446
|
visitTagPlaceholder(ph, context) {
|
|
446
447
|
const type = getTypeForTag(ph.tag);
|
|
447
448
|
if (ph.isVoid) {
|
|
448
|
-
const tagPh = new
|
|
449
|
+
const tagPh = new compiler.Tag(_PLACEHOLDER_TAG, {
|
|
449
450
|
id: (this._nextPlaceholderId++).toString(),
|
|
450
451
|
equiv: ph.startName,
|
|
451
452
|
type: type,
|
|
@@ -453,7 +454,7 @@ class _WriteVisitor {
|
|
|
453
454
|
});
|
|
454
455
|
return [tagPh];
|
|
455
456
|
}
|
|
456
|
-
const tagPc = new
|
|
457
|
+
const tagPc = new compiler.Tag(_PLACEHOLDER_SPANNING_TAG, {
|
|
457
458
|
id: (this._nextPlaceholderId++).toString(),
|
|
458
459
|
equivStart: ph.startName,
|
|
459
460
|
equivEnd: ph.closeName,
|
|
@@ -466,14 +467,14 @@ class _WriteVisitor {
|
|
|
466
467
|
nodes.forEach((node) => tagPc.children.push(node));
|
|
467
468
|
}
|
|
468
469
|
else {
|
|
469
|
-
tagPc.children.push(new
|
|
470
|
+
tagPc.children.push(new compiler.Text$1(''));
|
|
470
471
|
}
|
|
471
472
|
return [tagPc];
|
|
472
473
|
}
|
|
473
474
|
visitPlaceholder(ph, context) {
|
|
474
475
|
const idStr = (this._nextPlaceholderId++).toString();
|
|
475
476
|
return [
|
|
476
|
-
new
|
|
477
|
+
new compiler.Tag(_PLACEHOLDER_TAG, {
|
|
477
478
|
id: idStr,
|
|
478
479
|
equiv: ph.name,
|
|
479
480
|
disp: `{{${ph.value}}}`,
|
|
@@ -481,7 +482,7 @@ class _WriteVisitor {
|
|
|
481
482
|
];
|
|
482
483
|
}
|
|
483
484
|
visitBlockPlaceholder(ph, context) {
|
|
484
|
-
const tagPc = new
|
|
485
|
+
const tagPc = new compiler.Tag(_PLACEHOLDER_SPANNING_TAG, {
|
|
485
486
|
id: (this._nextPlaceholderId++).toString(),
|
|
486
487
|
equivStart: ph.startName,
|
|
487
488
|
equivEnd: ph.closeName,
|
|
@@ -494,7 +495,7 @@ class _WriteVisitor {
|
|
|
494
495
|
nodes.forEach((node) => tagPc.children.push(node));
|
|
495
496
|
}
|
|
496
497
|
else {
|
|
497
|
-
tagPc.children.push(new
|
|
498
|
+
tagPc.children.push(new compiler.Text$1(''));
|
|
498
499
|
}
|
|
499
500
|
return [tagPc];
|
|
500
501
|
}
|
|
@@ -504,7 +505,7 @@ class _WriteVisitor {
|
|
|
504
505
|
.join(' ');
|
|
505
506
|
const idStr = (this._nextPlaceholderId++).toString();
|
|
506
507
|
return [
|
|
507
|
-
new
|
|
508
|
+
new compiler.Tag(_PLACEHOLDER_TAG, {
|
|
508
509
|
id: idStr,
|
|
509
510
|
equiv: ph.name,
|
|
510
511
|
disp: `{${ph.value.expression}, ${ph.value.type}, ${cases}}`,
|
|
@@ -528,7 +529,7 @@ class Xliff2Parser {
|
|
|
528
529
|
this._msgIdToHtml = {};
|
|
529
530
|
const xml = new XmlParser().parse(xliff, url);
|
|
530
531
|
this._errors = xml.errors;
|
|
531
|
-
|
|
532
|
+
compiler.visitAll$1(this, xml.rootNodes, null);
|
|
532
533
|
return {
|
|
533
534
|
msgIdToHtml: this._msgIdToHtml,
|
|
534
535
|
errors: this._errors,
|
|
@@ -549,7 +550,7 @@ class Xliff2Parser {
|
|
|
549
550
|
this._addError(element, `Duplicated translations for msg ${id}`);
|
|
550
551
|
}
|
|
551
552
|
else {
|
|
552
|
-
|
|
553
|
+
compiler.visitAll$1(this, element.children, null);
|
|
553
554
|
if (typeof this._unitMlString === 'string') {
|
|
554
555
|
this._msgIdToHtml[id] = this._unitMlString;
|
|
555
556
|
}
|
|
@@ -581,12 +582,12 @@ class Xliff2Parser {
|
|
|
581
582
|
this._addError(element, `The XLIFF file version ${version} is not compatible with XLIFF 2.0 serializer`);
|
|
582
583
|
}
|
|
583
584
|
else {
|
|
584
|
-
|
|
585
|
+
compiler.visitAll$1(this, element.children, null);
|
|
585
586
|
}
|
|
586
587
|
}
|
|
587
588
|
break;
|
|
588
589
|
default:
|
|
589
|
-
|
|
590
|
+
compiler.visitAll$1(this, element.children, null);
|
|
590
591
|
}
|
|
591
592
|
}
|
|
592
593
|
visitAttribute(attribute, context) { }
|
|
@@ -598,7 +599,7 @@ class Xliff2Parser {
|
|
|
598
599
|
visitBlockParameter(parameter, context) { }
|
|
599
600
|
visitLetDeclaration(decl, context) { }
|
|
600
601
|
_addError(node, message) {
|
|
601
|
-
this._errors.push(new
|
|
602
|
+
this._errors.push(new compiler.I18nError(node.sourceSpan, message));
|
|
602
603
|
}
|
|
603
604
|
}
|
|
604
605
|
// Convert ml nodes (xliff syntax) to i18n nodes
|
|
@@ -610,21 +611,21 @@ class XmlToI18n {
|
|
|
610
611
|
this._errors = xmlIcu.errors;
|
|
611
612
|
const i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0
|
|
612
613
|
? []
|
|
613
|
-
: [].concat(...
|
|
614
|
+
: [].concat(...compiler.visitAll$1(this, xmlIcu.rootNodes));
|
|
614
615
|
return {
|
|
615
616
|
i18nNodes,
|
|
616
617
|
errors: this._errors,
|
|
617
618
|
};
|
|
618
619
|
}
|
|
619
620
|
visitText(text, context) {
|
|
620
|
-
return new
|
|
621
|
+
return new compiler.Text$2(text.value, text.sourceSpan);
|
|
621
622
|
}
|
|
622
623
|
visitElement(el, context) {
|
|
623
624
|
switch (el.name) {
|
|
624
625
|
case _PLACEHOLDER_TAG:
|
|
625
626
|
const nameAttr = el.attrs.find((attr) => attr.name === 'equiv');
|
|
626
627
|
if (nameAttr) {
|
|
627
|
-
return [new
|
|
628
|
+
return [new compiler.Placeholder('', nameAttr.value, el.sourceSpan)];
|
|
628
629
|
}
|
|
629
630
|
this._addError(el, `<${_PLACEHOLDER_TAG}> misses the "equiv" attribute`);
|
|
630
631
|
break;
|
|
@@ -641,11 +642,11 @@ class XmlToI18n {
|
|
|
641
642
|
const startId = startAttr.value;
|
|
642
643
|
const endId = endAttr.value;
|
|
643
644
|
const nodes = [];
|
|
644
|
-
return nodes.concat(new
|
|
645
|
+
return nodes.concat(new compiler.Placeholder('', startId, el.sourceSpan), ...el.children.map((node) => node.visit(this, null)), new compiler.Placeholder('', endId, el.sourceSpan));
|
|
645
646
|
}
|
|
646
647
|
break;
|
|
647
648
|
case _MARKER_TAG:
|
|
648
|
-
return [].concat(...
|
|
649
|
+
return [].concat(...compiler.visitAll$1(this, el.children));
|
|
649
650
|
default:
|
|
650
651
|
this._addError(el, `Unexpected tag`);
|
|
651
652
|
}
|
|
@@ -653,15 +654,15 @@ class XmlToI18n {
|
|
|
653
654
|
}
|
|
654
655
|
visitExpansion(icu, context) {
|
|
655
656
|
const caseMap = {};
|
|
656
|
-
|
|
657
|
-
caseMap[c.value] = new
|
|
657
|
+
compiler.visitAll$1(this, icu.cases).forEach((c) => {
|
|
658
|
+
caseMap[c.value] = new compiler.Container(c.nodes, icu.sourceSpan);
|
|
658
659
|
});
|
|
659
|
-
return new
|
|
660
|
+
return new compiler.Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
|
|
660
661
|
}
|
|
661
662
|
visitExpansionCase(icuCase, context) {
|
|
662
663
|
return {
|
|
663
664
|
value: icuCase.value,
|
|
664
|
-
nodes: [].concat(...
|
|
665
|
+
nodes: [].concat(...compiler.visitAll$1(this, icuCase.expression)),
|
|
665
666
|
};
|
|
666
667
|
}
|
|
667
668
|
visitComment(comment, context) { }
|
|
@@ -670,7 +671,7 @@ class XmlToI18n {
|
|
|
670
671
|
visitBlockParameter(parameter, context) { }
|
|
671
672
|
visitLetDeclaration(decl, context) { }
|
|
672
673
|
_addError(node, message) {
|
|
673
|
-
this._errors.push(new
|
|
674
|
+
this._errors.push(new compiler.I18nError(node.sourceSpan, message));
|
|
674
675
|
}
|
|
675
676
|
}
|
|
676
677
|
function getTypeForTag(tag) {
|
|
@@ -719,8 +720,8 @@ class MessageBundle {
|
|
|
719
720
|
// affected message IDs.
|
|
720
721
|
const rootNodes = this._preserveWhitespace
|
|
721
722
|
? htmlParserResult.rootNodes
|
|
722
|
-
:
|
|
723
|
-
const i18nParserResult =
|
|
723
|
+
: compiler.visitAllWithSiblings(new compiler.WhitespaceVisitor(/* preserveSignificantWhitespace */ false), htmlParserResult.rootNodes);
|
|
724
|
+
const i18nParserResult = compiler.extractMessages(rootNodes, interpolationConfig, this._implicitTags, this._implicitAttrs,
|
|
724
725
|
/* preserveSignificantWhitespace */ this._preserveWhitespace);
|
|
725
726
|
if (i18nParserResult.errors.length) {
|
|
726
727
|
return i18nParserResult.errors;
|
|
@@ -751,7 +752,7 @@ class MessageBundle {
|
|
|
751
752
|
const mapper = serializer.createNameMapper(messages[id]);
|
|
752
753
|
const src = messages[id];
|
|
753
754
|
const nodes = mapper ? mapperVisitor.convert(src.nodes, mapper) : src.nodes;
|
|
754
|
-
let transformedMessage = new
|
|
755
|
+
let transformedMessage = new compiler.Message(nodes, {}, {}, src.meaning, src.description, id);
|
|
755
756
|
transformedMessage.sources = src.sources;
|
|
756
757
|
if (filterSources) {
|
|
757
758
|
transformedMessage.sources.forEach((source) => (source.filePath = filterSources(source.filePath)));
|
|
@@ -762,7 +763,7 @@ class MessageBundle {
|
|
|
762
763
|
}
|
|
763
764
|
}
|
|
764
765
|
// Transform an i18n AST by renaming the placeholder nodes with the given mapper
|
|
765
|
-
class MapPlaceholderNames extends
|
|
766
|
+
class MapPlaceholderNames extends compiler.CloneVisitor {
|
|
766
767
|
convert(nodes, mapper) {
|
|
767
768
|
return mapper ? nodes.map((n) => n.visit(this, mapper)) : nodes;
|
|
768
769
|
}
|
|
@@ -770,34 +771,34 @@ class MapPlaceholderNames extends checker.CloneVisitor {
|
|
|
770
771
|
const startName = mapper.toPublicName(ph.startName);
|
|
771
772
|
const closeName = ph.closeName ? mapper.toPublicName(ph.closeName) : ph.closeName;
|
|
772
773
|
const children = ph.children.map((n) => n.visit(this, mapper));
|
|
773
|
-
return new
|
|
774
|
+
return new compiler.TagPlaceholder(ph.tag, ph.attrs, startName, closeName, children, ph.isVoid, ph.sourceSpan, ph.startSourceSpan, ph.endSourceSpan);
|
|
774
775
|
}
|
|
775
776
|
visitBlockPlaceholder(ph, mapper) {
|
|
776
777
|
const startName = mapper.toPublicName(ph.startName);
|
|
777
778
|
const closeName = ph.closeName ? mapper.toPublicName(ph.closeName) : ph.closeName;
|
|
778
779
|
const children = ph.children.map((n) => n.visit(this, mapper));
|
|
779
|
-
return new
|
|
780
|
+
return new compiler.BlockPlaceholder(ph.name, ph.parameters, startName, closeName, children, ph.sourceSpan, ph.startSourceSpan, ph.endSourceSpan);
|
|
780
781
|
}
|
|
781
782
|
visitPlaceholder(ph, mapper) {
|
|
782
|
-
return new
|
|
783
|
+
return new compiler.Placeholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan);
|
|
783
784
|
}
|
|
784
785
|
visitIcuPlaceholder(ph, mapper) {
|
|
785
|
-
return new
|
|
786
|
+
return new compiler.IcuPlaceholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan);
|
|
786
787
|
}
|
|
787
788
|
}
|
|
788
789
|
|
|
789
790
|
function compileClassMetadata(metadata) {
|
|
790
791
|
const fnCall = internalCompileClassMetadata(metadata);
|
|
791
|
-
return
|
|
792
|
+
return compiler.arrowFn([], [compiler.devOnlyGuardedExpression(fnCall).toStmt()]).callFn([]);
|
|
792
793
|
}
|
|
793
794
|
/** Compiles only the `setClassMetadata` call without any additional wrappers. */
|
|
794
795
|
function internalCompileClassMetadata(metadata) {
|
|
795
|
-
return
|
|
796
|
+
return compiler.importExpr(compiler.Identifiers.setClassMetadata)
|
|
796
797
|
.callFn([
|
|
797
798
|
metadata.type,
|
|
798
799
|
metadata.decorators,
|
|
799
|
-
metadata.ctorParameters ??
|
|
800
|
-
metadata.propDecorators ??
|
|
800
|
+
metadata.ctorParameters ?? compiler.literal(null),
|
|
801
|
+
metadata.propDecorators ?? compiler.literal(null),
|
|
801
802
|
]);
|
|
802
803
|
}
|
|
803
804
|
/**
|
|
@@ -822,7 +823,7 @@ function compileComponentClassMetadata(metadata, dependencies) {
|
|
|
822
823
|
// If there are no deferrable symbols - just generate a regular `setClassMetadata` call.
|
|
823
824
|
return compileClassMetadata(metadata);
|
|
824
825
|
}
|
|
825
|
-
return internalCompileSetClassMetadataAsync(metadata, dependencies.map((dep) => new
|
|
826
|
+
return internalCompileSetClassMetadataAsync(metadata, dependencies.map((dep) => new compiler.FnParam(dep.symbolName, compiler.DYNAMIC_TYPE)), compileComponentMetadataAsyncResolver(dependencies));
|
|
826
827
|
}
|
|
827
828
|
/**
|
|
828
829
|
* Internal logic used to compile a `setClassMetadataAsync` call.
|
|
@@ -833,10 +834,10 @@ function compileComponentClassMetadata(metadata, dependencies) {
|
|
|
833
834
|
function internalCompileSetClassMetadataAsync(metadata, wrapperParams, dependencyResolverFn) {
|
|
834
835
|
// Omit the wrapper since it'll be added around `setClassMetadataAsync` instead.
|
|
835
836
|
const setClassMetadataCall = internalCompileClassMetadata(metadata);
|
|
836
|
-
const setClassMetaWrapper =
|
|
837
|
-
const setClassMetaAsync =
|
|
837
|
+
const setClassMetaWrapper = compiler.arrowFn(wrapperParams, [setClassMetadataCall.toStmt()]);
|
|
838
|
+
const setClassMetaAsync = compiler.importExpr(compiler.Identifiers.setClassMetadataAsync)
|
|
838
839
|
.callFn([metadata.type, dependencyResolverFn, setClassMetaWrapper]);
|
|
839
|
-
return
|
|
840
|
+
return compiler.arrowFn([], [compiler.devOnlyGuardedExpression(setClassMetaAsync).toStmt()]).callFn([]);
|
|
840
841
|
}
|
|
841
842
|
/**
|
|
842
843
|
* Compiles the function that loads the dependencies for the
|
|
@@ -847,12 +848,12 @@ function compileComponentMetadataAsyncResolver(dependencies) {
|
|
|
847
848
|
// e.g. `(m) => m.CmpA`
|
|
848
849
|
const innerFn =
|
|
849
850
|
// Default imports are always accessed through the `default` property.
|
|
850
|
-
|
|
851
|
+
compiler.arrowFn([new compiler.FnParam('m', compiler.DYNAMIC_TYPE)], compiler.variable('m').prop(isDefaultImport ? 'default' : symbolName));
|
|
851
852
|
// e.g. `import('./cmp-a').then(...)`
|
|
852
|
-
return new
|
|
853
|
+
return new compiler.DynamicImportExpr(importPath).prop('then').callFn([innerFn]);
|
|
853
854
|
});
|
|
854
855
|
// e.g. `() => [ ... ];`
|
|
855
|
-
return
|
|
856
|
+
return compiler.arrowFn([], compiler.literalArr(dynamicImports));
|
|
856
857
|
}
|
|
857
858
|
|
|
858
859
|
/**
|
|
@@ -868,32 +869,32 @@ const MINIMUM_PARTIAL_LINKER_VERSION$5 = '12.0.0';
|
|
|
868
869
|
*/
|
|
869
870
|
const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
|
|
870
871
|
function compileDeclareClassMetadata(metadata) {
|
|
871
|
-
const definitionMap = new
|
|
872
|
-
definitionMap.set('minVersion',
|
|
873
|
-
definitionMap.set('version',
|
|
874
|
-
definitionMap.set('ngImport',
|
|
872
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
873
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
874
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.5'));
|
|
875
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
875
876
|
definitionMap.set('type', metadata.type);
|
|
876
877
|
definitionMap.set('decorators', metadata.decorators);
|
|
877
878
|
definitionMap.set('ctorParameters', metadata.ctorParameters);
|
|
878
879
|
definitionMap.set('propDecorators', metadata.propDecorators);
|
|
879
|
-
return
|
|
880
|
+
return compiler.importExpr(compiler.Identifiers.declareClassMetadata).callFn([definitionMap.toLiteralMap()]);
|
|
880
881
|
}
|
|
881
882
|
function compileComponentDeclareClassMetadata(metadata, dependencies) {
|
|
882
883
|
if (dependencies === null || dependencies.length === 0) {
|
|
883
884
|
return compileDeclareClassMetadata(metadata);
|
|
884
885
|
}
|
|
885
|
-
const definitionMap = new
|
|
886
|
-
const callbackReturnDefinitionMap = new
|
|
886
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
887
|
+
const callbackReturnDefinitionMap = new compiler.DefinitionMap();
|
|
887
888
|
callbackReturnDefinitionMap.set('decorators', metadata.decorators);
|
|
888
|
-
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ??
|
|
889
|
-
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ??
|
|
890
|
-
definitionMap.set('minVersion',
|
|
891
|
-
definitionMap.set('version',
|
|
892
|
-
definitionMap.set('ngImport',
|
|
889
|
+
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? compiler.literal(null));
|
|
890
|
+
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? compiler.literal(null));
|
|
891
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
|
|
892
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.5'));
|
|
893
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
893
894
|
definitionMap.set('type', metadata.type);
|
|
894
895
|
definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
|
|
895
|
-
definitionMap.set('resolveMetadata',
|
|
896
|
-
return
|
|
896
|
+
definitionMap.set('resolveMetadata', compiler.arrowFn(dependencies.map((dep) => new compiler.FnParam(dep.symbolName, compiler.DYNAMIC_TYPE)), callbackReturnDefinitionMap.toLiteralMap()));
|
|
897
|
+
return compiler.importExpr(compiler.Identifiers.declareClassMetadataAsync).callFn([definitionMap.toLiteralMap()]);
|
|
897
898
|
}
|
|
898
899
|
|
|
899
900
|
/**
|
|
@@ -909,7 +910,7 @@ function toOptionalLiteralArray(values, mapper) {
|
|
|
909
910
|
if (values === null || values.length === 0) {
|
|
910
911
|
return null;
|
|
911
912
|
}
|
|
912
|
-
return
|
|
913
|
+
return compiler.literalArr(values.map((value) => mapper(value)));
|
|
913
914
|
}
|
|
914
915
|
/**
|
|
915
916
|
* Creates an object literal expression from the given object, mapping all values to an expression
|
|
@@ -926,7 +927,7 @@ function toOptionalLiteralMap(object, mapper) {
|
|
|
926
927
|
return { key, value: mapper(value), quoted: true };
|
|
927
928
|
});
|
|
928
929
|
if (entries.length > 0) {
|
|
929
|
-
return
|
|
930
|
+
return compiler.literalMap(entries);
|
|
930
931
|
}
|
|
931
932
|
else {
|
|
932
933
|
return null;
|
|
@@ -936,32 +937,32 @@ function compileDependencies(deps) {
|
|
|
936
937
|
if (deps === 'invalid') {
|
|
937
938
|
// The `deps` can be set to the string "invalid" by the `unwrapConstructorDependencies()`
|
|
938
939
|
// function, which tries to convert `ConstructorDeps` into `R3DependencyMetadata[]`.
|
|
939
|
-
return
|
|
940
|
+
return compiler.literal('invalid');
|
|
940
941
|
}
|
|
941
942
|
else if (deps === null) {
|
|
942
|
-
return
|
|
943
|
+
return compiler.literal(null);
|
|
943
944
|
}
|
|
944
945
|
else {
|
|
945
|
-
return
|
|
946
|
+
return compiler.literalArr(deps.map(compileDependency));
|
|
946
947
|
}
|
|
947
948
|
}
|
|
948
949
|
function compileDependency(dep) {
|
|
949
|
-
const depMeta = new
|
|
950
|
+
const depMeta = new compiler.DefinitionMap();
|
|
950
951
|
depMeta.set('token', dep.token);
|
|
951
952
|
if (dep.attributeNameType !== null) {
|
|
952
|
-
depMeta.set('attribute',
|
|
953
|
+
depMeta.set('attribute', compiler.literal(true));
|
|
953
954
|
}
|
|
954
955
|
if (dep.host) {
|
|
955
|
-
depMeta.set('host',
|
|
956
|
+
depMeta.set('host', compiler.literal(true));
|
|
956
957
|
}
|
|
957
958
|
if (dep.optional) {
|
|
958
|
-
depMeta.set('optional',
|
|
959
|
+
depMeta.set('optional', compiler.literal(true));
|
|
959
960
|
}
|
|
960
961
|
if (dep.self) {
|
|
961
|
-
depMeta.set('self',
|
|
962
|
+
depMeta.set('self', compiler.literal(true));
|
|
962
963
|
}
|
|
963
964
|
if (dep.skipSelf) {
|
|
964
|
-
depMeta.set('skipSelf',
|
|
965
|
+
depMeta.set('skipSelf', compiler.literal(true));
|
|
965
966
|
}
|
|
966
967
|
return depMeta.toLiteralMap();
|
|
967
968
|
}
|
|
@@ -971,8 +972,8 @@ function compileDependency(dep) {
|
|
|
971
972
|
*/
|
|
972
973
|
function compileDeclareDirectiveFromMetadata(meta) {
|
|
973
974
|
const definitionMap = createDirectiveDefinitionMap(meta);
|
|
974
|
-
const expression =
|
|
975
|
-
const type =
|
|
975
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareDirective).callFn([definitionMap.toLiteralMap()]);
|
|
976
|
+
const type = compiler.createDirectiveType(meta);
|
|
976
977
|
return { expression, type, statements: [] };
|
|
977
978
|
}
|
|
978
979
|
/**
|
|
@@ -980,47 +981,47 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
980
981
|
* this logic for components, as they extend the directive metadata.
|
|
981
982
|
*/
|
|
982
983
|
function createDirectiveDefinitionMap(meta) {
|
|
983
|
-
const definitionMap = new
|
|
984
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
984
985
|
const minVersion = getMinimumVersionForPartialOutput(meta);
|
|
985
|
-
definitionMap.set('minVersion',
|
|
986
|
-
definitionMap.set('version',
|
|
986
|
+
definitionMap.set('minVersion', compiler.literal(minVersion));
|
|
987
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.5'));
|
|
987
988
|
// e.g. `type: MyDirective`
|
|
988
989
|
definitionMap.set('type', meta.type.value);
|
|
989
990
|
if (meta.isStandalone !== undefined) {
|
|
990
|
-
definitionMap.set('isStandalone',
|
|
991
|
+
definitionMap.set('isStandalone', compiler.literal(meta.isStandalone));
|
|
991
992
|
}
|
|
992
993
|
if (meta.isSignal) {
|
|
993
|
-
definitionMap.set('isSignal',
|
|
994
|
+
definitionMap.set('isSignal', compiler.literal(meta.isSignal));
|
|
994
995
|
}
|
|
995
996
|
// e.g. `selector: 'some-dir'`
|
|
996
997
|
if (meta.selector !== null) {
|
|
997
|
-
definitionMap.set('selector',
|
|
998
|
+
definitionMap.set('selector', compiler.literal(meta.selector));
|
|
998
999
|
}
|
|
999
1000
|
definitionMap.set('inputs', needsNewInputPartialOutput(meta)
|
|
1000
1001
|
? createInputsPartialMetadata(meta.inputs)
|
|
1001
1002
|
: legacyInputsPartialMetadata(meta.inputs));
|
|
1002
|
-
definitionMap.set('outputs',
|
|
1003
|
+
definitionMap.set('outputs', compiler.conditionallyCreateDirectiveBindingLiteral(meta.outputs));
|
|
1003
1004
|
definitionMap.set('host', compileHostMetadata(meta.host));
|
|
1004
1005
|
definitionMap.set('providers', meta.providers);
|
|
1005
1006
|
if (meta.queries.length > 0) {
|
|
1006
|
-
definitionMap.set('queries',
|
|
1007
|
+
definitionMap.set('queries', compiler.literalArr(meta.queries.map(compileQuery)));
|
|
1007
1008
|
}
|
|
1008
1009
|
if (meta.viewQueries.length > 0) {
|
|
1009
|
-
definitionMap.set('viewQueries',
|
|
1010
|
+
definitionMap.set('viewQueries', compiler.literalArr(meta.viewQueries.map(compileQuery)));
|
|
1010
1011
|
}
|
|
1011
1012
|
if (meta.exportAs !== null) {
|
|
1012
|
-
definitionMap.set('exportAs',
|
|
1013
|
+
definitionMap.set('exportAs', compiler.asLiteral(meta.exportAs));
|
|
1013
1014
|
}
|
|
1014
1015
|
if (meta.usesInheritance) {
|
|
1015
|
-
definitionMap.set('usesInheritance',
|
|
1016
|
+
definitionMap.set('usesInheritance', compiler.literal(true));
|
|
1016
1017
|
}
|
|
1017
1018
|
if (meta.lifecycle.usesOnChanges) {
|
|
1018
|
-
definitionMap.set('usesOnChanges',
|
|
1019
|
+
definitionMap.set('usesOnChanges', compiler.literal(true));
|
|
1019
1020
|
}
|
|
1020
1021
|
if (meta.hostDirectives?.length) {
|
|
1021
1022
|
definitionMap.set('hostDirectives', createHostDirectives(meta.hostDirectives));
|
|
1022
1023
|
}
|
|
1023
|
-
definitionMap.set('ngImport',
|
|
1024
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1024
1025
|
return definitionMap;
|
|
1025
1026
|
}
|
|
1026
1027
|
/**
|
|
@@ -1071,28 +1072,28 @@ function needsNewInputPartialOutput(meta) {
|
|
|
1071
1072
|
* by `R3DeclareQueryMetadata`.
|
|
1072
1073
|
*/
|
|
1073
1074
|
function compileQuery(query) {
|
|
1074
|
-
const meta = new
|
|
1075
|
-
meta.set('propertyName',
|
|
1075
|
+
const meta = new compiler.DefinitionMap();
|
|
1076
|
+
meta.set('propertyName', compiler.literal(query.propertyName));
|
|
1076
1077
|
if (query.first) {
|
|
1077
|
-
meta.set('first',
|
|
1078
|
+
meta.set('first', compiler.literal(true));
|
|
1078
1079
|
}
|
|
1079
1080
|
meta.set('predicate', Array.isArray(query.predicate)
|
|
1080
|
-
?
|
|
1081
|
-
:
|
|
1081
|
+
? compiler.asLiteral(query.predicate)
|
|
1082
|
+
: compiler.convertFromMaybeForwardRefExpression(query.predicate));
|
|
1082
1083
|
if (!query.emitDistinctChangesOnly) {
|
|
1083
1084
|
// `emitDistinctChangesOnly` is special because we expect it to be `true`.
|
|
1084
1085
|
// Therefore we explicitly emit the field, and explicitly place it only when it's `false`.
|
|
1085
|
-
meta.set('emitDistinctChangesOnly',
|
|
1086
|
+
meta.set('emitDistinctChangesOnly', compiler.literal(false));
|
|
1086
1087
|
}
|
|
1087
1088
|
if (query.descendants) {
|
|
1088
|
-
meta.set('descendants',
|
|
1089
|
+
meta.set('descendants', compiler.literal(true));
|
|
1089
1090
|
}
|
|
1090
1091
|
meta.set('read', query.read);
|
|
1091
1092
|
if (query.static) {
|
|
1092
|
-
meta.set('static',
|
|
1093
|
+
meta.set('static', compiler.literal(true));
|
|
1093
1094
|
}
|
|
1094
1095
|
if (query.isSignal) {
|
|
1095
|
-
meta.set('isSignal',
|
|
1096
|
+
meta.set('isSignal', compiler.literal(true));
|
|
1096
1097
|
}
|
|
1097
1098
|
return meta.toLiteralMap();
|
|
1098
1099
|
}
|
|
@@ -1101,15 +1102,15 @@ function compileQuery(query) {
|
|
|
1101
1102
|
* in `R3DeclareDirectiveMetadata['host']`
|
|
1102
1103
|
*/
|
|
1103
1104
|
function compileHostMetadata(meta) {
|
|
1104
|
-
const hostMetadata = new
|
|
1105
|
+
const hostMetadata = new compiler.DefinitionMap();
|
|
1105
1106
|
hostMetadata.set('attributes', toOptionalLiteralMap(meta.attributes, (expression) => expression));
|
|
1106
|
-
hostMetadata.set('listeners', toOptionalLiteralMap(meta.listeners,
|
|
1107
|
-
hostMetadata.set('properties', toOptionalLiteralMap(meta.properties,
|
|
1107
|
+
hostMetadata.set('listeners', toOptionalLiteralMap(meta.listeners, compiler.literal));
|
|
1108
|
+
hostMetadata.set('properties', toOptionalLiteralMap(meta.properties, compiler.literal));
|
|
1108
1109
|
if (meta.specialAttributes.styleAttr) {
|
|
1109
|
-
hostMetadata.set('styleAttribute',
|
|
1110
|
+
hostMetadata.set('styleAttribute', compiler.literal(meta.specialAttributes.styleAttr));
|
|
1110
1111
|
}
|
|
1111
1112
|
if (meta.specialAttributes.classAttr) {
|
|
1112
|
-
hostMetadata.set('classAttribute',
|
|
1113
|
+
hostMetadata.set('classAttribute', compiler.literal(meta.specialAttributes.classAttr));
|
|
1113
1114
|
}
|
|
1114
1115
|
if (hostMetadata.values.length > 0) {
|
|
1115
1116
|
return hostMetadata.toLiteralMap();
|
|
@@ -1124,14 +1125,14 @@ function createHostDirectives(hostDirectives) {
|
|
|
1124
1125
|
{
|
|
1125
1126
|
key: 'directive',
|
|
1126
1127
|
value: current.isForwardReference
|
|
1127
|
-
?
|
|
1128
|
+
? compiler.generateForwardRef(current.directive.type)
|
|
1128
1129
|
: current.directive.type,
|
|
1129
1130
|
quoted: false,
|
|
1130
1131
|
},
|
|
1131
1132
|
];
|
|
1132
|
-
const inputsLiteral = current.inputs ?
|
|
1133
|
+
const inputsLiteral = current.inputs ? compiler.createHostDirectivesMappingArray(current.inputs) : null;
|
|
1133
1134
|
const outputsLiteral = current.outputs
|
|
1134
|
-
?
|
|
1135
|
+
? compiler.createHostDirectivesMappingArray(current.outputs)
|
|
1135
1136
|
: null;
|
|
1136
1137
|
if (inputsLiteral) {
|
|
1137
1138
|
keys.push({ key: 'inputs', value: inputsLiteral, quoted: false });
|
|
@@ -1139,11 +1140,11 @@ function createHostDirectives(hostDirectives) {
|
|
|
1139
1140
|
if (outputsLiteral) {
|
|
1140
1141
|
keys.push({ key: 'outputs', value: outputsLiteral, quoted: false });
|
|
1141
1142
|
}
|
|
1142
|
-
return
|
|
1143
|
+
return compiler.literalMap(keys);
|
|
1143
1144
|
});
|
|
1144
1145
|
// If there's a forward reference, we generate a `function() { return [{directive: HostDir}] }`,
|
|
1145
1146
|
// otherwise we can save some bytes by using a plain array, e.g. `[{directive: HostDir}]`.
|
|
1146
|
-
return
|
|
1147
|
+
return compiler.literalArr(expressions);
|
|
1147
1148
|
}
|
|
1148
1149
|
/**
|
|
1149
1150
|
* Generates partial output metadata for inputs of a directive.
|
|
@@ -1155,18 +1156,18 @@ function createInputsPartialMetadata(inputs) {
|
|
|
1155
1156
|
if (keys.length === 0) {
|
|
1156
1157
|
return null;
|
|
1157
1158
|
}
|
|
1158
|
-
return
|
|
1159
|
+
return compiler.literalMap(keys.map((declaredName) => {
|
|
1159
1160
|
const value = inputs[declaredName];
|
|
1160
1161
|
return {
|
|
1161
1162
|
key: declaredName,
|
|
1162
1163
|
// put quotes around keys that contain potentially unsafe characters
|
|
1163
|
-
quoted:
|
|
1164
|
-
value:
|
|
1165
|
-
{ key: 'classPropertyName', quoted: false, value:
|
|
1166
|
-
{ key: 'publicName', quoted: false, value:
|
|
1167
|
-
{ key: 'isSignal', quoted: false, value:
|
|
1168
|
-
{ key: 'isRequired', quoted: false, value:
|
|
1169
|
-
{ key: 'transformFunction', quoted: false, value: value.transformFunction ??
|
|
1164
|
+
quoted: compiler.UNSAFE_OBJECT_KEY_NAME_REGEXP.test(declaredName),
|
|
1165
|
+
value: compiler.literalMap([
|
|
1166
|
+
{ key: 'classPropertyName', quoted: false, value: compiler.asLiteral(value.classPropertyName) },
|
|
1167
|
+
{ key: 'publicName', quoted: false, value: compiler.asLiteral(value.bindingPropertyName) },
|
|
1168
|
+
{ key: 'isSignal', quoted: false, value: compiler.asLiteral(value.isSignal) },
|
|
1169
|
+
{ key: 'isRequired', quoted: false, value: compiler.asLiteral(value.required) },
|
|
1170
|
+
{ key: 'transformFunction', quoted: false, value: value.transformFunction ?? compiler.NULL_EXPR },
|
|
1170
1171
|
]),
|
|
1171
1172
|
};
|
|
1172
1173
|
}));
|
|
@@ -1190,25 +1191,25 @@ function legacyInputsPartialMetadata(inputs) {
|
|
|
1190
1191
|
if (keys.length === 0) {
|
|
1191
1192
|
return null;
|
|
1192
1193
|
}
|
|
1193
|
-
return
|
|
1194
|
+
return compiler.literalMap(keys.map((declaredName) => {
|
|
1194
1195
|
const value = inputs[declaredName];
|
|
1195
1196
|
const publicName = value.bindingPropertyName;
|
|
1196
1197
|
const differentDeclaringName = publicName !== declaredName;
|
|
1197
1198
|
let result;
|
|
1198
1199
|
if (differentDeclaringName || value.transformFunction !== null) {
|
|
1199
|
-
const values = [
|
|
1200
|
+
const values = [compiler.asLiteral(publicName), compiler.asLiteral(declaredName)];
|
|
1200
1201
|
if (value.transformFunction !== null) {
|
|
1201
1202
|
values.push(value.transformFunction);
|
|
1202
1203
|
}
|
|
1203
|
-
result =
|
|
1204
|
+
result = compiler.literalArr(values);
|
|
1204
1205
|
}
|
|
1205
1206
|
else {
|
|
1206
|
-
result =
|
|
1207
|
+
result = compiler.asLiteral(publicName);
|
|
1207
1208
|
}
|
|
1208
1209
|
return {
|
|
1209
1210
|
key: declaredName,
|
|
1210
1211
|
// put quotes around keys that contain potentially unsafe characters
|
|
1211
|
-
quoted:
|
|
1212
|
+
quoted: compiler.UNSAFE_OBJECT_KEY_NAME_REGEXP.test(declaredName),
|
|
1212
1213
|
value: result,
|
|
1213
1214
|
};
|
|
1214
1215
|
}));
|
|
@@ -1219,8 +1220,8 @@ function legacyInputsPartialMetadata(inputs) {
|
|
|
1219
1220
|
*/
|
|
1220
1221
|
function compileDeclareComponentFromMetadata(meta, template, additionalTemplateInfo) {
|
|
1221
1222
|
const definitionMap = createComponentDefinitionMap(meta, template, additionalTemplateInfo);
|
|
1222
|
-
const expression =
|
|
1223
|
-
const type =
|
|
1223
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareComponent).callFn([definitionMap.toLiteralMap()]);
|
|
1224
|
+
const type = compiler.createComponentType(meta);
|
|
1224
1225
|
return { expression, type, statements: [] };
|
|
1225
1226
|
}
|
|
1226
1227
|
/**
|
|
@@ -1229,17 +1230,17 @@ function compileDeclareComponentFromMetadata(meta, template, additionalTemplateI
|
|
|
1229
1230
|
function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
1230
1231
|
const definitionMap = createDirectiveDefinitionMap(meta);
|
|
1231
1232
|
const blockVisitor = new BlockPresenceVisitor();
|
|
1232
|
-
|
|
1233
|
+
compiler.visitAll(blockVisitor, template.nodes);
|
|
1233
1234
|
definitionMap.set('template', getTemplateExpression(template, templateInfo));
|
|
1234
1235
|
if (templateInfo.isInline) {
|
|
1235
|
-
definitionMap.set('isInline',
|
|
1236
|
+
definitionMap.set('isInline', compiler.literal(true));
|
|
1236
1237
|
}
|
|
1237
1238
|
// Set the minVersion to 17.0.0 if the component is using at least one block in its template.
|
|
1238
1239
|
// We don't do this for templates without blocks, in order to preserve backwards compatibility.
|
|
1239
1240
|
if (blockVisitor.hasBlocks) {
|
|
1240
|
-
definitionMap.set('minVersion',
|
|
1241
|
+
definitionMap.set('minVersion', compiler.literal('17.0.0'));
|
|
1241
1242
|
}
|
|
1242
|
-
definitionMap.set('styles', toOptionalLiteralArray(meta.styles,
|
|
1243
|
+
definitionMap.set('styles', toOptionalLiteralArray(meta.styles, compiler.literal));
|
|
1243
1244
|
definitionMap.set('dependencies', compileUsedDependenciesMetadata(meta));
|
|
1244
1245
|
definitionMap.set('viewProviders', meta.viewProviders);
|
|
1245
1246
|
definitionMap.set('animations', meta.animations);
|
|
@@ -1247,17 +1248,17 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
1247
1248
|
if (typeof meta.changeDetection === 'object') {
|
|
1248
1249
|
throw new Error('Impossible state! Change detection flag is not resolved!');
|
|
1249
1250
|
}
|
|
1250
|
-
definitionMap.set('changeDetection',
|
|
1251
|
-
.prop(
|
|
1251
|
+
definitionMap.set('changeDetection', compiler.importExpr(compiler.Identifiers.ChangeDetectionStrategy)
|
|
1252
|
+
.prop(compiler.ChangeDetectionStrategy[meta.changeDetection]));
|
|
1252
1253
|
}
|
|
1253
|
-
if (meta.encapsulation !==
|
|
1254
|
-
definitionMap.set('encapsulation',
|
|
1254
|
+
if (meta.encapsulation !== compiler.ViewEncapsulation.Emulated) {
|
|
1255
|
+
definitionMap.set('encapsulation', compiler.importExpr(compiler.Identifiers.ViewEncapsulation).prop(compiler.ViewEncapsulation[meta.encapsulation]));
|
|
1255
1256
|
}
|
|
1256
|
-
if (meta.interpolation !==
|
|
1257
|
-
definitionMap.set('interpolation',
|
|
1257
|
+
if (meta.interpolation !== compiler.DEFAULT_INTERPOLATION_CONFIG) {
|
|
1258
|
+
definitionMap.set('interpolation', compiler.literalArr([compiler.literal(meta.interpolation.start), compiler.literal(meta.interpolation.end)]));
|
|
1258
1259
|
}
|
|
1259
1260
|
if (template.preserveWhitespaces === true) {
|
|
1260
|
-
definitionMap.set('preserveWhitespaces',
|
|
1261
|
+
definitionMap.set('preserveWhitespaces', compiler.literal(true));
|
|
1261
1262
|
}
|
|
1262
1263
|
if (meta.defer.mode === 0 /* DeferBlockDepsEmitMode.PerBlock */) {
|
|
1263
1264
|
const resolvers = [];
|
|
@@ -1267,7 +1268,7 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
1267
1268
|
// defer resolver functions to defer blocks happens by index and not adding an array
|
|
1268
1269
|
// entry for a block can throw off the blocks coming after it.
|
|
1269
1270
|
if (deps === null) {
|
|
1270
|
-
resolvers.push(
|
|
1271
|
+
resolvers.push(compiler.literal(null));
|
|
1271
1272
|
}
|
|
1272
1273
|
else {
|
|
1273
1274
|
resolvers.push(deps);
|
|
@@ -1276,7 +1277,7 @@ function createComponentDefinitionMap(meta, template, templateInfo) {
|
|
|
1276
1277
|
}
|
|
1277
1278
|
// If *all* the resolvers are null, we can skip the field.
|
|
1278
1279
|
if (hasResolvers) {
|
|
1279
|
-
definitionMap.set('deferBlockDependencies',
|
|
1280
|
+
definitionMap.set('deferBlockDependencies', compiler.literalArr(resolvers));
|
|
1280
1281
|
}
|
|
1281
1282
|
}
|
|
1282
1283
|
else {
|
|
@@ -1297,16 +1298,16 @@ function getTemplateExpression(template, templateInfo) {
|
|
|
1297
1298
|
// that we cannot use the expression defining the template because the linker expects the template
|
|
1298
1299
|
// to be defined as a literal in the declaration.
|
|
1299
1300
|
if (templateInfo.isInline) {
|
|
1300
|
-
return
|
|
1301
|
+
return compiler.literal(templateInfo.content, null, null);
|
|
1301
1302
|
}
|
|
1302
1303
|
// The template is external so we must synthesize an expression node with
|
|
1303
1304
|
// the appropriate source-span.
|
|
1304
1305
|
const contents = templateInfo.content;
|
|
1305
|
-
const file = new
|
|
1306
|
-
const start = new
|
|
1306
|
+
const file = new compiler.ParseSourceFile(contents, templateInfo.sourceUrl);
|
|
1307
|
+
const start = new compiler.ParseLocation(file, 0, 0, 0);
|
|
1307
1308
|
const end = computeEndLocation(file, contents);
|
|
1308
|
-
const span = new
|
|
1309
|
-
return
|
|
1309
|
+
const span = new compiler.ParseSourceSpan(start, end);
|
|
1310
|
+
return compiler.literal(contents, null, span);
|
|
1310
1311
|
}
|
|
1311
1312
|
function computeEndLocation(file, contents) {
|
|
1312
1313
|
const length = contents.length;
|
|
@@ -1320,41 +1321,41 @@ function computeEndLocation(file, contents) {
|
|
|
1320
1321
|
line++;
|
|
1321
1322
|
}
|
|
1322
1323
|
} while (lineStart !== -1);
|
|
1323
|
-
return new
|
|
1324
|
+
return new compiler.ParseLocation(file, length, line, length - lastLineStart);
|
|
1324
1325
|
}
|
|
1325
1326
|
function compileUsedDependenciesMetadata(meta) {
|
|
1326
1327
|
const wrapType = meta.declarationListEmitMode !== 0 /* DeclarationListEmitMode.Direct */
|
|
1327
|
-
?
|
|
1328
|
+
? compiler.generateForwardRef
|
|
1328
1329
|
: (expr) => expr;
|
|
1329
1330
|
if (meta.declarationListEmitMode === 3 /* DeclarationListEmitMode.RuntimeResolved */) {
|
|
1330
1331
|
throw new Error(`Unsupported emit mode`);
|
|
1331
1332
|
}
|
|
1332
1333
|
return toOptionalLiteralArray(meta.declarations, (decl) => {
|
|
1333
1334
|
switch (decl.kind) {
|
|
1334
|
-
case
|
|
1335
|
-
const dirMeta = new
|
|
1336
|
-
dirMeta.set('kind',
|
|
1335
|
+
case compiler.R3TemplateDependencyKind.Directive:
|
|
1336
|
+
const dirMeta = new compiler.DefinitionMap();
|
|
1337
|
+
dirMeta.set('kind', compiler.literal(decl.isComponent ? 'component' : 'directive'));
|
|
1337
1338
|
dirMeta.set('type', wrapType(decl.type));
|
|
1338
|
-
dirMeta.set('selector',
|
|
1339
|
-
dirMeta.set('inputs', toOptionalLiteralArray(decl.inputs,
|
|
1340
|
-
dirMeta.set('outputs', toOptionalLiteralArray(decl.outputs,
|
|
1341
|
-
dirMeta.set('exportAs', toOptionalLiteralArray(decl.exportAs,
|
|
1339
|
+
dirMeta.set('selector', compiler.literal(decl.selector));
|
|
1340
|
+
dirMeta.set('inputs', toOptionalLiteralArray(decl.inputs, compiler.literal));
|
|
1341
|
+
dirMeta.set('outputs', toOptionalLiteralArray(decl.outputs, compiler.literal));
|
|
1342
|
+
dirMeta.set('exportAs', toOptionalLiteralArray(decl.exportAs, compiler.literal));
|
|
1342
1343
|
return dirMeta.toLiteralMap();
|
|
1343
|
-
case
|
|
1344
|
-
const pipeMeta = new
|
|
1345
|
-
pipeMeta.set('kind',
|
|
1344
|
+
case compiler.R3TemplateDependencyKind.Pipe:
|
|
1345
|
+
const pipeMeta = new compiler.DefinitionMap();
|
|
1346
|
+
pipeMeta.set('kind', compiler.literal('pipe'));
|
|
1346
1347
|
pipeMeta.set('type', wrapType(decl.type));
|
|
1347
|
-
pipeMeta.set('name',
|
|
1348
|
+
pipeMeta.set('name', compiler.literal(decl.name));
|
|
1348
1349
|
return pipeMeta.toLiteralMap();
|
|
1349
|
-
case
|
|
1350
|
-
const ngModuleMeta = new
|
|
1351
|
-
ngModuleMeta.set('kind',
|
|
1350
|
+
case compiler.R3TemplateDependencyKind.NgModule:
|
|
1351
|
+
const ngModuleMeta = new compiler.DefinitionMap();
|
|
1352
|
+
ngModuleMeta.set('kind', compiler.literal('ngmodule'));
|
|
1352
1353
|
ngModuleMeta.set('type', wrapType(decl.type));
|
|
1353
1354
|
return ngModuleMeta.toLiteralMap();
|
|
1354
1355
|
}
|
|
1355
1356
|
});
|
|
1356
1357
|
}
|
|
1357
|
-
class BlockPresenceVisitor extends
|
|
1358
|
+
class BlockPresenceVisitor extends compiler.RecursiveVisitor {
|
|
1358
1359
|
hasBlocks = false;
|
|
1359
1360
|
visitDeferredBlock() {
|
|
1360
1361
|
this.hasBlocks = true;
|
|
@@ -1397,17 +1398,17 @@ class BlockPresenceVisitor extends checker.RecursiveVisitor$1 {
|
|
|
1397
1398
|
*/
|
|
1398
1399
|
const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
1399
1400
|
function compileDeclareFactoryFunction(meta) {
|
|
1400
|
-
const definitionMap = new
|
|
1401
|
-
definitionMap.set('minVersion',
|
|
1402
|
-
definitionMap.set('version',
|
|
1403
|
-
definitionMap.set('ngImport',
|
|
1401
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1402
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
1403
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.5'));
|
|
1404
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1404
1405
|
definitionMap.set('type', meta.type.value);
|
|
1405
1406
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
1406
|
-
definitionMap.set('target',
|
|
1407
|
+
definitionMap.set('target', compiler.importExpr(compiler.Identifiers.FactoryTarget).prop(compiler.FactoryTarget[meta.target]));
|
|
1407
1408
|
return {
|
|
1408
|
-
expression:
|
|
1409
|
+
expression: compiler.importExpr(compiler.Identifiers.declareFactory).callFn([definitionMap.toLiteralMap()]),
|
|
1409
1410
|
statements: [],
|
|
1410
|
-
type:
|
|
1411
|
+
type: compiler.createFactoryType(meta),
|
|
1411
1412
|
};
|
|
1412
1413
|
}
|
|
1413
1414
|
|
|
@@ -1424,34 +1425,34 @@ const MINIMUM_PARTIAL_LINKER_VERSION$3 = '12.0.0';
|
|
|
1424
1425
|
*/
|
|
1425
1426
|
function compileDeclareInjectableFromMetadata(meta) {
|
|
1426
1427
|
const definitionMap = createInjectableDefinitionMap(meta);
|
|
1427
|
-
const expression =
|
|
1428
|
-
const type =
|
|
1428
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareInjectable).callFn([definitionMap.toLiteralMap()]);
|
|
1429
|
+
const type = compiler.createInjectableType(meta);
|
|
1429
1430
|
return { expression, type, statements: [] };
|
|
1430
1431
|
}
|
|
1431
1432
|
/**
|
|
1432
1433
|
* Gathers the declaration fields for a Injectable into a `DefinitionMap`.
|
|
1433
1434
|
*/
|
|
1434
1435
|
function createInjectableDefinitionMap(meta) {
|
|
1435
|
-
const definitionMap = new
|
|
1436
|
-
definitionMap.set('minVersion',
|
|
1437
|
-
definitionMap.set('version',
|
|
1438
|
-
definitionMap.set('ngImport',
|
|
1436
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1437
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
1438
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.5'));
|
|
1439
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1439
1440
|
definitionMap.set('type', meta.type.value);
|
|
1440
1441
|
// Only generate providedIn property if it has a non-null value
|
|
1441
1442
|
if (meta.providedIn !== undefined) {
|
|
1442
|
-
const providedIn =
|
|
1443
|
+
const providedIn = compiler.convertFromMaybeForwardRefExpression(meta.providedIn);
|
|
1443
1444
|
if (providedIn.value !== null) {
|
|
1444
1445
|
definitionMap.set('providedIn', providedIn);
|
|
1445
1446
|
}
|
|
1446
1447
|
}
|
|
1447
1448
|
if (meta.useClass !== undefined) {
|
|
1448
|
-
definitionMap.set('useClass',
|
|
1449
|
+
definitionMap.set('useClass', compiler.convertFromMaybeForwardRefExpression(meta.useClass));
|
|
1449
1450
|
}
|
|
1450
1451
|
if (meta.useExisting !== undefined) {
|
|
1451
|
-
definitionMap.set('useExisting',
|
|
1452
|
+
definitionMap.set('useExisting', compiler.convertFromMaybeForwardRefExpression(meta.useExisting));
|
|
1452
1453
|
}
|
|
1453
1454
|
if (meta.useValue !== undefined) {
|
|
1454
|
-
definitionMap.set('useValue',
|
|
1455
|
+
definitionMap.set('useValue', compiler.convertFromMaybeForwardRefExpression(meta.useValue));
|
|
1455
1456
|
}
|
|
1456
1457
|
// Factories do not contain `ForwardRef`s since any types are already wrapped in a function call
|
|
1457
1458
|
// so the types will not be eagerly evaluated. Therefore we do not need to process this expression
|
|
@@ -1460,7 +1461,7 @@ function createInjectableDefinitionMap(meta) {
|
|
|
1460
1461
|
definitionMap.set('useFactory', meta.useFactory);
|
|
1461
1462
|
}
|
|
1462
1463
|
if (meta.deps !== undefined) {
|
|
1463
|
-
definitionMap.set('deps',
|
|
1464
|
+
definitionMap.set('deps', compiler.literalArr(meta.deps.map(compileDependency)));
|
|
1464
1465
|
}
|
|
1465
1466
|
return definitionMap;
|
|
1466
1467
|
}
|
|
@@ -1475,22 +1476,22 @@ function createInjectableDefinitionMap(meta) {
|
|
|
1475
1476
|
const MINIMUM_PARTIAL_LINKER_VERSION$2 = '12.0.0';
|
|
1476
1477
|
function compileDeclareInjectorFromMetadata(meta) {
|
|
1477
1478
|
const definitionMap = createInjectorDefinitionMap(meta);
|
|
1478
|
-
const expression =
|
|
1479
|
-
const type =
|
|
1479
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareInjector).callFn([definitionMap.toLiteralMap()]);
|
|
1480
|
+
const type = compiler.createInjectorType(meta);
|
|
1480
1481
|
return { expression, type, statements: [] };
|
|
1481
1482
|
}
|
|
1482
1483
|
/**
|
|
1483
1484
|
* Gathers the declaration fields for an Injector into a `DefinitionMap`.
|
|
1484
1485
|
*/
|
|
1485
1486
|
function createInjectorDefinitionMap(meta) {
|
|
1486
|
-
const definitionMap = new
|
|
1487
|
-
definitionMap.set('minVersion',
|
|
1488
|
-
definitionMap.set('version',
|
|
1489
|
-
definitionMap.set('ngImport',
|
|
1487
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1488
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
1489
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.5'));
|
|
1490
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1490
1491
|
definitionMap.set('type', meta.type.value);
|
|
1491
1492
|
definitionMap.set('providers', meta.providers);
|
|
1492
1493
|
if (meta.imports.length > 0) {
|
|
1493
|
-
definitionMap.set('imports',
|
|
1494
|
+
definitionMap.set('imports', compiler.literalArr(meta.imports));
|
|
1494
1495
|
}
|
|
1495
1496
|
return definitionMap;
|
|
1496
1497
|
}
|
|
@@ -1505,40 +1506,40 @@ function createInjectorDefinitionMap(meta) {
|
|
|
1505
1506
|
const MINIMUM_PARTIAL_LINKER_VERSION$1 = '14.0.0';
|
|
1506
1507
|
function compileDeclareNgModuleFromMetadata(meta) {
|
|
1507
1508
|
const definitionMap = createNgModuleDefinitionMap(meta);
|
|
1508
|
-
const expression =
|
|
1509
|
-
const type =
|
|
1509
|
+
const expression = compiler.importExpr(compiler.Identifiers.declareNgModule).callFn([definitionMap.toLiteralMap()]);
|
|
1510
|
+
const type = compiler.createNgModuleType(meta);
|
|
1510
1511
|
return { expression, type, statements: [] };
|
|
1511
1512
|
}
|
|
1512
1513
|
/**
|
|
1513
1514
|
* Gathers the declaration fields for an NgModule into a `DefinitionMap`.
|
|
1514
1515
|
*/
|
|
1515
1516
|
function createNgModuleDefinitionMap(meta) {
|
|
1516
|
-
const definitionMap = new
|
|
1517
|
-
if (meta.kind ===
|
|
1517
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1518
|
+
if (meta.kind === compiler.R3NgModuleMetadataKind.Local) {
|
|
1518
1519
|
throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
|
|
1519
1520
|
}
|
|
1520
|
-
definitionMap.set('minVersion',
|
|
1521
|
-
definitionMap.set('version',
|
|
1522
|
-
definitionMap.set('ngImport',
|
|
1521
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
1522
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.5'));
|
|
1523
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1523
1524
|
definitionMap.set('type', meta.type.value);
|
|
1524
1525
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
1525
1526
|
// We must wrap the arrays inside a function if any of the values are a forward reference to a
|
|
1526
1527
|
// not-yet-declared class. This is to support JIT execution of the `ɵɵngDeclareNgModule()` call.
|
|
1527
1528
|
// In the linker these wrappers are stripped and then reapplied for the `ɵɵdefineNgModule()` call.
|
|
1528
1529
|
if (meta.bootstrap.length > 0) {
|
|
1529
|
-
definitionMap.set('bootstrap',
|
|
1530
|
+
definitionMap.set('bootstrap', compiler.refsToArray(meta.bootstrap, meta.containsForwardDecls));
|
|
1530
1531
|
}
|
|
1531
1532
|
if (meta.declarations.length > 0) {
|
|
1532
|
-
definitionMap.set('declarations',
|
|
1533
|
+
definitionMap.set('declarations', compiler.refsToArray(meta.declarations, meta.containsForwardDecls));
|
|
1533
1534
|
}
|
|
1534
1535
|
if (meta.imports.length > 0) {
|
|
1535
|
-
definitionMap.set('imports',
|
|
1536
|
+
definitionMap.set('imports', compiler.refsToArray(meta.imports, meta.containsForwardDecls));
|
|
1536
1537
|
}
|
|
1537
1538
|
if (meta.exports.length > 0) {
|
|
1538
|
-
definitionMap.set('exports',
|
|
1539
|
+
definitionMap.set('exports', compiler.refsToArray(meta.exports, meta.containsForwardDecls));
|
|
1539
1540
|
}
|
|
1540
1541
|
if (meta.schemas !== null && meta.schemas.length > 0) {
|
|
1541
|
-
definitionMap.set('schemas',
|
|
1542
|
+
definitionMap.set('schemas', compiler.literalArr(meta.schemas.map((ref) => ref.value)));
|
|
1542
1543
|
}
|
|
1543
1544
|
if (meta.id !== null) {
|
|
1544
1545
|
definitionMap.set('id', meta.id);
|
|
@@ -1559,28 +1560,28 @@ const MINIMUM_PARTIAL_LINKER_VERSION = '14.0.0';
|
|
|
1559
1560
|
*/
|
|
1560
1561
|
function compileDeclarePipeFromMetadata(meta) {
|
|
1561
1562
|
const definitionMap = createPipeDefinitionMap(meta);
|
|
1562
|
-
const expression =
|
|
1563
|
-
const type =
|
|
1563
|
+
const expression = compiler.importExpr(compiler.Identifiers.declarePipe).callFn([definitionMap.toLiteralMap()]);
|
|
1564
|
+
const type = compiler.createPipeType(meta);
|
|
1564
1565
|
return { expression, type, statements: [] };
|
|
1565
1566
|
}
|
|
1566
1567
|
/**
|
|
1567
1568
|
* Gathers the declaration fields for a Pipe into a `DefinitionMap`.
|
|
1568
1569
|
*/
|
|
1569
1570
|
function createPipeDefinitionMap(meta) {
|
|
1570
|
-
const definitionMap = new
|
|
1571
|
-
definitionMap.set('minVersion',
|
|
1572
|
-
definitionMap.set('version',
|
|
1573
|
-
definitionMap.set('ngImport',
|
|
1571
|
+
const definitionMap = new compiler.DefinitionMap();
|
|
1572
|
+
definitionMap.set('minVersion', compiler.literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
1573
|
+
definitionMap.set('version', compiler.literal('20.0.0-next.5'));
|
|
1574
|
+
definitionMap.set('ngImport', compiler.importExpr(compiler.Identifiers.core));
|
|
1574
1575
|
// e.g. `type: MyPipe`
|
|
1575
1576
|
definitionMap.set('type', meta.type.value);
|
|
1576
1577
|
if (meta.isStandalone !== undefined) {
|
|
1577
|
-
definitionMap.set('isStandalone',
|
|
1578
|
+
definitionMap.set('isStandalone', compiler.literal(meta.isStandalone));
|
|
1578
1579
|
}
|
|
1579
1580
|
// e.g. `name: "myPipe"`
|
|
1580
|
-
definitionMap.set('name',
|
|
1581
|
+
definitionMap.set('name', compiler.literal(meta.pipeName));
|
|
1581
1582
|
if (meta.pure === false) {
|
|
1582
1583
|
// e.g. `pure: false`
|
|
1583
|
-
definitionMap.set('pure',
|
|
1584
|
+
definitionMap.set('pure', compiler.literal(meta.pure));
|
|
1584
1585
|
}
|
|
1585
1586
|
return definitionMap;
|
|
1586
1587
|
}
|
|
@@ -1600,11 +1601,11 @@ function compileClassDebugInfo(debugInfo) {
|
|
|
1600
1601
|
}
|
|
1601
1602
|
// Include forbidOrphanRendering only if it's set to true (to reduce generated code)
|
|
1602
1603
|
if (debugInfo.forbidOrphanRendering) {
|
|
1603
|
-
debugInfoObject.forbidOrphanRendering =
|
|
1604
|
+
debugInfoObject.forbidOrphanRendering = compiler.literal(true);
|
|
1604
1605
|
}
|
|
1605
|
-
const fnCall =
|
|
1606
|
-
.callFn([debugInfo.type,
|
|
1607
|
-
const iife =
|
|
1606
|
+
const fnCall = compiler.importExpr(compiler.Identifiers.setClassDebugInfo)
|
|
1607
|
+
.callFn([debugInfo.type, compiler.mapLiteral(debugInfoObject)]);
|
|
1608
|
+
const iife = compiler.arrowFn([], [compiler.devOnlyGuardedExpression(fnCall).toStmt()]);
|
|
1608
1609
|
return iife.callFn([]);
|
|
1609
1610
|
}
|
|
1610
1611
|
|
|
@@ -1626,69 +1627,69 @@ function compileHmrInitializer(meta) {
|
|
|
1626
1627
|
const idName = 'id';
|
|
1627
1628
|
const importCallbackName = `${meta.className}_HmrLoad`;
|
|
1628
1629
|
const namespaces = meta.namespaceDependencies.map((dep) => {
|
|
1629
|
-
return new
|
|
1630
|
+
return new compiler.ExternalExpr({ moduleName: dep.moduleName, name: null });
|
|
1630
1631
|
});
|
|
1631
1632
|
// m.default
|
|
1632
|
-
const defaultRead =
|
|
1633
|
+
const defaultRead = compiler.variable(moduleName).prop('default');
|
|
1633
1634
|
// ɵɵreplaceMetadata(Comp, m.default, [...namespaces], [...locals], import.meta, id);
|
|
1634
|
-
const replaceCall =
|
|
1635
|
+
const replaceCall = compiler.importExpr(compiler.Identifiers.replaceMetadata)
|
|
1635
1636
|
.callFn([
|
|
1636
1637
|
meta.type,
|
|
1637
1638
|
defaultRead,
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1639
|
+
compiler.literalArr(namespaces),
|
|
1640
|
+
compiler.literalArr(meta.localDependencies.map((l) => l.runtimeRepresentation)),
|
|
1641
|
+
compiler.variable('import').prop('meta'),
|
|
1642
|
+
compiler.variable(idName),
|
|
1642
1643
|
]);
|
|
1643
1644
|
// (m) => m.default && ɵɵreplaceMetadata(...)
|
|
1644
|
-
const replaceCallback =
|
|
1645
|
+
const replaceCallback = compiler.arrowFn([new compiler.FnParam(moduleName)], defaultRead.and(replaceCall));
|
|
1645
1646
|
// '<url>?c=' + id + '&t=' + encodeURIComponent(t)
|
|
1646
|
-
const urlValue =
|
|
1647
|
-
.plus(
|
|
1648
|
-
.plus(
|
|
1649
|
-
.plus(
|
|
1647
|
+
const urlValue = compiler.literal(`./@ng/component?c=`)
|
|
1648
|
+
.plus(compiler.variable(idName))
|
|
1649
|
+
.plus(compiler.literal('&t='))
|
|
1650
|
+
.plus(compiler.variable('encodeURIComponent').callFn([compiler.variable(timestampName)]));
|
|
1650
1651
|
// import.meta.url
|
|
1651
|
-
const urlBase =
|
|
1652
|
+
const urlBase = compiler.variable('import').prop('meta').prop('url');
|
|
1652
1653
|
// new URL(urlValue, urlBase).href
|
|
1653
|
-
const urlHref = new
|
|
1654
|
+
const urlHref = new compiler.InstantiateExpr(compiler.variable('URL'), [urlValue, urlBase]).prop('href');
|
|
1654
1655
|
// function Cmp_HmrLoad(t) {
|
|
1655
1656
|
// import(/* @vite-ignore */ urlHref).then((m) => m.default && replaceMetadata(...));
|
|
1656
1657
|
// }
|
|
1657
|
-
const importCallback = new
|
|
1658
|
+
const importCallback = new compiler.DeclareFunctionStmt(importCallbackName, [new compiler.FnParam(timestampName)], [
|
|
1658
1659
|
// The vite-ignore special comment is required to prevent Vite from generating a superfluous
|
|
1659
1660
|
// warning for each usage within the development code. If Vite provides a method to
|
|
1660
1661
|
// programmatically avoid this warning in the future, this added comment can be removed here.
|
|
1661
|
-
new
|
|
1662
|
+
new compiler.DynamicImportExpr(urlHref, null, '@vite-ignore')
|
|
1662
1663
|
.prop('then')
|
|
1663
1664
|
.callFn([replaceCallback])
|
|
1664
1665
|
.toStmt(),
|
|
1665
|
-
], null,
|
|
1666
|
+
], null, compiler.StmtModifier.Final);
|
|
1666
1667
|
// (d) => d.id === id && Cmp_HmrLoad(d.timestamp)
|
|
1667
|
-
const updateCallback =
|
|
1668
|
+
const updateCallback = compiler.arrowFn([new compiler.FnParam(dataName)], compiler.variable(dataName)
|
|
1668
1669
|
.prop('id')
|
|
1669
|
-
.identical(
|
|
1670
|
-
.and(
|
|
1670
|
+
.identical(compiler.variable(idName))
|
|
1671
|
+
.and(compiler.variable(importCallbackName).callFn([compiler.variable(dataName).prop('timestamp')])));
|
|
1671
1672
|
// Cmp_HmrLoad(Date.now());
|
|
1672
1673
|
// Initial call to kick off the loading in order to avoid edge cases with components
|
|
1673
1674
|
// coming from lazy chunks that change before the chunk has loaded.
|
|
1674
|
-
const initialCall =
|
|
1675
|
-
.callFn([
|
|
1675
|
+
const initialCall = compiler.variable(importCallbackName)
|
|
1676
|
+
.callFn([compiler.variable('Date').prop('now').callFn([])]);
|
|
1676
1677
|
// import.meta.hot
|
|
1677
|
-
const hotRead =
|
|
1678
|
+
const hotRead = compiler.variable('import').prop('meta').prop('hot');
|
|
1678
1679
|
// import.meta.hot.on('angular:component-update', () => ...);
|
|
1679
1680
|
const hotListener = hotRead
|
|
1680
1681
|
.clone()
|
|
1681
1682
|
.prop('on')
|
|
1682
|
-
.callFn([
|
|
1683
|
-
return
|
|
1683
|
+
.callFn([compiler.literal('angular:component-update'), updateCallback]);
|
|
1684
|
+
return compiler.arrowFn([], [
|
|
1684
1685
|
// const id = <id>;
|
|
1685
|
-
new
|
|
1686
|
+
new compiler.DeclareVarStmt(idName, compiler.literal(encodeURIComponent(`${meta.filePath}@${meta.className}`)), null, compiler.StmtModifier.Final),
|
|
1686
1687
|
// function Cmp_HmrLoad() {...}.
|
|
1687
1688
|
importCallback,
|
|
1688
1689
|
// ngDevMode && Cmp_HmrLoad(Date.now());
|
|
1689
|
-
|
|
1690
|
+
compiler.devOnlyGuardedExpression(initialCall).toStmt(),
|
|
1690
1691
|
// ngDevMode && import.meta.hot && import.meta.hot.on(...)
|
|
1691
|
-
|
|
1692
|
+
compiler.devOnlyGuardedExpression(hotRead.and(hotListener)).toStmt(),
|
|
1692
1693
|
])
|
|
1693
1694
|
.callFn([]);
|
|
1694
1695
|
}
|
|
@@ -1701,25 +1702,25 @@ function compileHmrInitializer(meta) {
|
|
|
1701
1702
|
*/
|
|
1702
1703
|
function compileHmrUpdateCallback(definitions, constantStatements, meta) {
|
|
1703
1704
|
const namespaces = 'ɵɵnamespaces';
|
|
1704
|
-
const params = [meta.className, namespaces].map((name) => new
|
|
1705
|
+
const params = [meta.className, namespaces].map((name) => new compiler.FnParam(name, compiler.DYNAMIC_TYPE));
|
|
1705
1706
|
const body = [];
|
|
1706
1707
|
for (const local of meta.localDependencies) {
|
|
1707
|
-
params.push(new
|
|
1708
|
+
params.push(new compiler.FnParam(local.name));
|
|
1708
1709
|
}
|
|
1709
1710
|
// Declare variables that read out the individual namespaces.
|
|
1710
1711
|
for (let i = 0; i < meta.namespaceDependencies.length; i++) {
|
|
1711
|
-
body.push(new
|
|
1712
|
+
body.push(new compiler.DeclareVarStmt(meta.namespaceDependencies[i].assignedName, compiler.variable(namespaces).key(compiler.literal(i)), compiler.DYNAMIC_TYPE, compiler.StmtModifier.Final));
|
|
1712
1713
|
}
|
|
1713
1714
|
body.push(...constantStatements);
|
|
1714
1715
|
for (const field of definitions) {
|
|
1715
1716
|
if (field.initializer !== null) {
|
|
1716
|
-
body.push(
|
|
1717
|
+
body.push(compiler.variable(meta.className).prop(field.name).set(field.initializer).toStmt());
|
|
1717
1718
|
for (const stmt of field.statements) {
|
|
1718
1719
|
body.push(stmt);
|
|
1719
1720
|
}
|
|
1720
1721
|
}
|
|
1721
1722
|
}
|
|
1722
|
-
return new
|
|
1723
|
+
return new compiler.DeclareFunctionStmt(`${meta.className}_UpdateMetadata`, params, body, null, compiler.StmtModifier.Final);
|
|
1723
1724
|
}
|
|
1724
1725
|
|
|
1725
1726
|
/**
|
|
@@ -1772,7 +1773,7 @@ class UnifiedModulesAliasingHost {
|
|
|
1772
1773
|
}
|
|
1773
1774
|
// viaModule is the module it'll actually be imported from.
|
|
1774
1775
|
const moduleName = this.unifiedModulesHost.fileNameToModuleName(via.fileName, via.fileName);
|
|
1775
|
-
return new
|
|
1776
|
+
return new compiler.ExternalExpr({ moduleName, name: this.aliasName(decl, via) });
|
|
1776
1777
|
}
|
|
1777
1778
|
/**
|
|
1778
1779
|
* Generates an alias name based on the full module name of the file which declares the aliased
|
|
@@ -4231,7 +4232,7 @@ class IvyTransformationVisitor extends Visitor {
|
|
|
4231
4232
|
* A transformer which operates on ts.SourceFiles and applies changes from an `IvyCompilation`.
|
|
4232
4233
|
*/
|
|
4233
4234
|
function transformIvySourceFile(compilation, context, reflector, importRewriter, localCompilationExtraImportsTracker, file, isCore, isClosureCompilerEnabled, recordWrappedNode) {
|
|
4234
|
-
const constantPool = new
|
|
4235
|
+
const constantPool = new compiler.ConstantPool(isClosureCompilerEnabled);
|
|
4235
4236
|
const importManager = new checker.ImportManager({
|
|
4236
4237
|
...checker.presetImportManagerForceNamespaceImports,
|
|
4237
4238
|
rewriter: importRewriter,
|
|
@@ -4387,7 +4388,7 @@ function resolveEncapsulationEnumValueLocally(expr) {
|
|
|
4387
4388
|
return null;
|
|
4388
4389
|
}
|
|
4389
4390
|
const exprText = expr.getText().trim();
|
|
4390
|
-
for (const key in
|
|
4391
|
+
for (const key in compiler.ViewEncapsulation) {
|
|
4391
4392
|
if (!Number.isNaN(Number(key))) {
|
|
4392
4393
|
continue;
|
|
4393
4394
|
}
|
|
@@ -4395,7 +4396,7 @@ function resolveEncapsulationEnumValueLocally(expr) {
|
|
|
4395
4396
|
// Check whether the enum is imported by name or used by import namespace (e.g.,
|
|
4396
4397
|
// core.ViewEncapsulation.None)
|
|
4397
4398
|
if (exprText === suffix || exprText.endsWith(`.${suffix}`)) {
|
|
4398
|
-
const ans = Number(
|
|
4399
|
+
const ans = Number(compiler.ViewEncapsulation[key]);
|
|
4399
4400
|
return ans;
|
|
4400
4401
|
}
|
|
4401
4402
|
}
|
|
@@ -4421,7 +4422,7 @@ function resolveLiteral(decorator, literalCache) {
|
|
|
4421
4422
|
}
|
|
4422
4423
|
|
|
4423
4424
|
function compileNgFactoryDefField(metadata) {
|
|
4424
|
-
const res =
|
|
4425
|
+
const res = compiler.compileFactoryFunction(metadata);
|
|
4425
4426
|
return {
|
|
4426
4427
|
name: 'ɵfac',
|
|
4427
4428
|
initializer: res.expression,
|
|
@@ -4506,35 +4507,33 @@ function extractClassMetadata(clazz, reflection, isCore, annotateForClosureCompi
|
|
|
4506
4507
|
if (ngClassDecorators.length === 0) {
|
|
4507
4508
|
return null;
|
|
4508
4509
|
}
|
|
4509
|
-
const metaDecorators = new
|
|
4510
|
+
const metaDecorators = new compiler.WrappedNodeExpr(ts.factory.createArrayLiteralExpression(ngClassDecorators));
|
|
4510
4511
|
// Convert the constructor parameters to metadata, passing null if none are present.
|
|
4511
4512
|
let metaCtorParameters = null;
|
|
4512
4513
|
const classCtorParameters = reflection.getConstructorParameters(clazz);
|
|
4513
4514
|
if (classCtorParameters !== null) {
|
|
4514
4515
|
const ctorParameters = classCtorParameters.map((param) => ctorParameterToMetadata(param, isCore));
|
|
4515
|
-
metaCtorParameters = new
|
|
4516
|
+
metaCtorParameters = new compiler.ArrowFunctionExpr([], new compiler.LiteralArrayExpr(ctorParameters));
|
|
4516
4517
|
}
|
|
4517
4518
|
// Do the same for property decorators.
|
|
4518
4519
|
let metaPropDecorators = null;
|
|
4519
4520
|
const classMembers = reflection
|
|
4520
4521
|
.getMembersOfClass(clazz)
|
|
4521
4522
|
.filter((member) => !member.isStatic && member.decorators !== null && member.decorators.length > 0);
|
|
4522
|
-
const
|
|
4523
|
-
|
|
4524
|
-
.filter((name, i, arr) => arr.indexOf(name) < i);
|
|
4525
|
-
if (duplicateDecoratedMemberNames.length > 0) {
|
|
4523
|
+
const duplicateDecoratedMembers = classMembers.filter((member, i, arr) => arr.findIndex((arrayMember) => arrayMember.name === member.name) < i);
|
|
4524
|
+
if (duplicateDecoratedMembers.length > 0) {
|
|
4526
4525
|
// This should theoretically never happen, because the only way to have duplicate instance
|
|
4527
4526
|
// member names is getter/setter pairs and decorators cannot appear in both a getter and the
|
|
4528
4527
|
// corresponding setter.
|
|
4529
|
-
throw new
|
|
4530
|
-
|
|
4528
|
+
throw new checker.FatalDiagnosticError(checker.ErrorCode.DUPLICATE_DECORATED_PROPERTIES, duplicateDecoratedMembers[0].nameNode ?? clazz, `Duplicate decorated properties found on class '${clazz.name.text}': ` +
|
|
4529
|
+
duplicateDecoratedMembers.map((member) => member.name).join(', '));
|
|
4531
4530
|
}
|
|
4532
4531
|
const decoratedMembers = classMembers.map((member) => classMemberToMetadata(member.nameNode ?? member.name, member.decorators, isCore));
|
|
4533
4532
|
if (decoratedMembers.length > 0) {
|
|
4534
|
-
metaPropDecorators = new
|
|
4533
|
+
metaPropDecorators = new compiler.WrappedNodeExpr(ts.factory.createObjectLiteralExpression(decoratedMembers));
|
|
4535
4534
|
}
|
|
4536
4535
|
return {
|
|
4537
|
-
type: new
|
|
4536
|
+
type: new compiler.WrappedNodeExpr(id),
|
|
4538
4537
|
decorators: metaDecorators,
|
|
4539
4538
|
ctorParameters: metaCtorParameters,
|
|
4540
4539
|
propDecorators: metaPropDecorators,
|
|
@@ -4548,7 +4547,7 @@ function ctorParameterToMetadata(param, isCore) {
|
|
|
4548
4547
|
// its type is undefined.
|
|
4549
4548
|
const type = param.typeValueReference.kind !== 2 /* TypeValueReferenceKind.UNAVAILABLE */
|
|
4550
4549
|
? checker.valueReferenceToExpression(param.typeValueReference)
|
|
4551
|
-
: new
|
|
4550
|
+
: new compiler.LiteralExpr(undefined);
|
|
4552
4551
|
const mapEntries = [
|
|
4553
4552
|
{ key: 'type', value: type, quoted: false },
|
|
4554
4553
|
];
|
|
@@ -4557,10 +4556,10 @@ function ctorParameterToMetadata(param, isCore) {
|
|
|
4557
4556
|
const ngDecorators = param.decorators
|
|
4558
4557
|
.filter((dec) => isAngularDecorator$1(dec, isCore))
|
|
4559
4558
|
.map((decorator) => decoratorToMetadata(decorator));
|
|
4560
|
-
const value = new
|
|
4559
|
+
const value = new compiler.WrappedNodeExpr(ts.factory.createArrayLiteralExpression(ngDecorators));
|
|
4561
4560
|
mapEntries.push({ key: 'decorators', value, quoted: false });
|
|
4562
4561
|
}
|
|
4563
|
-
return
|
|
4562
|
+
return compiler.literalMap(mapEntries);
|
|
4564
4563
|
}
|
|
4565
4564
|
/**
|
|
4566
4565
|
* Convert a reflected class member to metadata.
|
|
@@ -4624,10 +4623,10 @@ function extractClassDebugInfo(clazz, reflection, compilerHost, rootDirs, forbid
|
|
|
4624
4623
|
const srcFile = clazz.getSourceFile();
|
|
4625
4624
|
const srcFileMaybeRelativePath = getProjectRelativePath(srcFile.fileName, rootDirs, compilerHost);
|
|
4626
4625
|
return {
|
|
4627
|
-
type: new
|
|
4628
|
-
className:
|
|
4629
|
-
filePath: srcFileMaybeRelativePath ?
|
|
4630
|
-
lineNumber:
|
|
4626
|
+
type: new compiler.WrappedNodeExpr(clazz.name),
|
|
4627
|
+
className: compiler.literal(clazz.name.getText()),
|
|
4628
|
+
filePath: srcFileMaybeRelativePath ? compiler.literal(srcFileMaybeRelativePath) : null,
|
|
4629
|
+
lineNumber: compiler.literal(srcFile.getLineAndCharacterOfPosition(clazz.name.pos).line + 1),
|
|
4631
4630
|
forbidOrphanRendering,
|
|
4632
4631
|
};
|
|
4633
4632
|
}
|
|
@@ -4658,10 +4657,10 @@ function extractSchemas(rawExpr, evaluator, context) {
|
|
|
4658
4657
|
// renamed when the user imported it, these names will match.
|
|
4659
4658
|
switch (id.text) {
|
|
4660
4659
|
case 'CUSTOM_ELEMENTS_SCHEMA':
|
|
4661
|
-
schemas.push(
|
|
4660
|
+
schemas.push(compiler.CUSTOM_ELEMENTS_SCHEMA);
|
|
4662
4661
|
break;
|
|
4663
4662
|
case 'NO_ERRORS_SCHEMA':
|
|
4664
|
-
schemas.push(
|
|
4663
|
+
schemas.push(compiler.NO_ERRORS_SCHEMA);
|
|
4665
4664
|
break;
|
|
4666
4665
|
default:
|
|
4667
4666
|
throw checker.createValueHasWrongTypeError(rawExpr, schemaRef, `'${schemaRef.debugName}' is not a valid ${context} schema`);
|
|
@@ -4686,7 +4685,7 @@ function compileInputTransformFields(inputs) {
|
|
|
4686
4685
|
if (input.transform) {
|
|
4687
4686
|
extraFields.push({
|
|
4688
4687
|
name: `ngAcceptInputType_${input.classPropertyName}`,
|
|
4689
|
-
type:
|
|
4688
|
+
type: compiler.transplantedType(input.transform.type),
|
|
4690
4689
|
statements: [],
|
|
4691
4690
|
initializer: null,
|
|
4692
4691
|
deferrableImports: null,
|
|
@@ -4969,7 +4968,7 @@ class SemanticDepGraphUpdater {
|
|
|
4969
4968
|
}
|
|
4970
4969
|
}
|
|
4971
4970
|
function getImportPath(expr) {
|
|
4972
|
-
if (expr instanceof
|
|
4971
|
+
if (expr instanceof compiler.ExternalExpr) {
|
|
4973
4972
|
return `${expr.value.moduleName}\$${expr.value.name}`;
|
|
4974
4973
|
}
|
|
4975
4974
|
else {
|
|
@@ -5737,7 +5736,7 @@ class LocalModuleScopeRegistry {
|
|
|
5737
5736
|
return;
|
|
5738
5737
|
}
|
|
5739
5738
|
if (!reexportMap.has(exportName)) {
|
|
5740
|
-
if (exportRef.alias && exportRef.alias instanceof
|
|
5739
|
+
if (exportRef.alias && exportRef.alias instanceof compiler.ExternalExpr) {
|
|
5741
5740
|
reexports.push({
|
|
5742
5741
|
fromModule: exportRef.alias.value.moduleName,
|
|
5743
5742
|
symbolName: exportRef.alias.value.name,
|
|
@@ -5748,7 +5747,7 @@ class LocalModuleScopeRegistry {
|
|
|
5748
5747
|
const emittedRef = this.refEmitter.emit(exportRef.cloneWithNoIdentifiers(), sourceFile);
|
|
5749
5748
|
checker.assertSuccessfulReferenceEmit(emittedRef, ngModuleRef.node.name, 'class');
|
|
5750
5749
|
const expr = emittedRef.expression;
|
|
5751
|
-
if (!(expr instanceof
|
|
5750
|
+
if (!(expr instanceof compiler.ExternalExpr) ||
|
|
5752
5751
|
expr.value.moduleName === null ||
|
|
5753
5752
|
expr.value.name === null) {
|
|
5754
5753
|
throw new Error('Expected ExternalExpr');
|
|
@@ -5887,7 +5886,7 @@ class TypeCheckScopeRegistry {
|
|
|
5887
5886
|
* an empty type-check scope is returned.
|
|
5888
5887
|
*/
|
|
5889
5888
|
getTypeCheckScope(node) {
|
|
5890
|
-
const matcher = new
|
|
5889
|
+
const matcher = new compiler.SelectorMatcher();
|
|
5891
5890
|
const directives = [];
|
|
5892
5891
|
const pipes = new Map();
|
|
5893
5892
|
const scope = this.scopeReader.getScopeForComponent(node);
|
|
@@ -5920,7 +5919,7 @@ class TypeCheckScopeRegistry {
|
|
|
5920
5919
|
}
|
|
5921
5920
|
// Carry over the `isExplicitlyDeferred` flag from the dependency info.
|
|
5922
5921
|
const directiveMeta = this.applyExplicitlyDeferredFlag(extMeta, meta.isExplicitlyDeferred);
|
|
5923
|
-
matcher.addSelectables(
|
|
5922
|
+
matcher.addSelectables(compiler.CssSelector.parse(meta.selector), [
|
|
5924
5923
|
...this.hostDirectivesResolver.resolve(directiveMeta),
|
|
5925
5924
|
directiveMeta,
|
|
5926
5925
|
]);
|
|
@@ -6736,7 +6735,7 @@ class DirectiveDecoratorHandler {
|
|
|
6736
6735
|
}
|
|
6737
6736
|
const hostElement = checker.createHostElement('directive', meta.meta.selector, node, meta.hostBindingNodes.literal, meta.hostBindingNodes.bindingDecorators, meta.hostBindingNodes.listenerDecorators);
|
|
6738
6737
|
if (hostElement !== null) {
|
|
6739
|
-
const binder = new
|
|
6738
|
+
const binder = new compiler.R3TargetBinder(scope.matcher);
|
|
6740
6739
|
const hostBindingsContext = {
|
|
6741
6740
|
node: hostElement,
|
|
6742
6741
|
sourceMapping: { type: 'direct', node },
|
|
@@ -6753,7 +6752,7 @@ class DirectiveDecoratorHandler {
|
|
|
6753
6752
|
}
|
|
6754
6753
|
const diagnostics = [];
|
|
6755
6754
|
if (analysis.providersRequiringFactory !== null &&
|
|
6756
|
-
analysis.meta.providers instanceof
|
|
6755
|
+
analysis.meta.providers instanceof compiler.WrappedNodeExpr) {
|
|
6757
6756
|
const providerDiagnostics = checker.getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
|
|
6758
6757
|
diagnostics.push(...providerDiagnostics);
|
|
6759
6758
|
}
|
|
@@ -6775,8 +6774,8 @@ class DirectiveDecoratorHandler {
|
|
|
6775
6774
|
return { data: {} };
|
|
6776
6775
|
}
|
|
6777
6776
|
compileFull(node, analysis, resolution, pool) {
|
|
6778
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
6779
|
-
const def =
|
|
6777
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Directive));
|
|
6778
|
+
const def = compiler.compileDirectiveFromMetadata(analysis.meta, pool, compiler.makeBindingParser());
|
|
6780
6779
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
6781
6780
|
const classMetadata = analysis.classMetadata !== null
|
|
6782
6781
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
@@ -6784,7 +6783,7 @@ class DirectiveDecoratorHandler {
|
|
|
6784
6783
|
return checker.compileResults(fac, def, classMetadata, 'ɵdir', inputTransformFields, null /* deferrableImports */);
|
|
6785
6784
|
}
|
|
6786
6785
|
compilePartial(node, analysis, resolution) {
|
|
6787
|
-
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta,
|
|
6786
|
+
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Directive));
|
|
6788
6787
|
const def = compileDeclareDirectiveFromMetadata(analysis.meta);
|
|
6789
6788
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
6790
6789
|
const classMetadata = analysis.classMetadata !== null
|
|
@@ -6793,8 +6792,8 @@ class DirectiveDecoratorHandler {
|
|
|
6793
6792
|
return checker.compileResults(fac, def, classMetadata, 'ɵdir', inputTransformFields, null /* deferrableImports */);
|
|
6794
6793
|
}
|
|
6795
6794
|
compileLocal(node, analysis, resolution, pool) {
|
|
6796
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
6797
|
-
const def =
|
|
6795
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Directive));
|
|
6796
|
+
const def = compiler.compileDirectiveFromMetadata(analysis.meta, pool, compiler.makeBindingParser());
|
|
6798
6797
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
6799
6798
|
const classMetadata = analysis.classMetadata !== null
|
|
6800
6799
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
@@ -7178,7 +7177,7 @@ class NgModuleDecoratorHandler {
|
|
|
7178
7177
|
if (ngModule.has('id')) {
|
|
7179
7178
|
const idExpr = ngModule.get('id');
|
|
7180
7179
|
if (!isModuleIdExpression(idExpr)) {
|
|
7181
|
-
id = new
|
|
7180
|
+
id = new compiler.WrappedNodeExpr(idExpr);
|
|
7182
7181
|
}
|
|
7183
7182
|
else {
|
|
7184
7183
|
const diag = checker.makeDiagnostic(checker.ErrorCode.WARN_NGMODULE_ID_UNNECESSARY, idExpr, `Using 'module.id' for NgModule.id is a common anti-pattern that is ignored by the Angular compiler.`);
|
|
@@ -7209,23 +7208,23 @@ class NgModuleDecoratorHandler {
|
|
|
7209
7208
|
let ngModuleMetadata;
|
|
7210
7209
|
if (this.compilationMode === checker.CompilationMode.LOCAL) {
|
|
7211
7210
|
ngModuleMetadata = {
|
|
7212
|
-
kind:
|
|
7211
|
+
kind: compiler.R3NgModuleMetadataKind.Local,
|
|
7213
7212
|
type,
|
|
7214
|
-
bootstrapExpression: rawBootstrap ? new
|
|
7215
|
-
declarationsExpression: rawDeclarations ? new
|
|
7216
|
-
exportsExpression: rawExports ? new
|
|
7217
|
-
importsExpression: rawImports ? new
|
|
7213
|
+
bootstrapExpression: rawBootstrap ? new compiler.WrappedNodeExpr(rawBootstrap) : null,
|
|
7214
|
+
declarationsExpression: rawDeclarations ? new compiler.WrappedNodeExpr(rawDeclarations) : null,
|
|
7215
|
+
exportsExpression: rawExports ? new compiler.WrappedNodeExpr(rawExports) : null,
|
|
7216
|
+
importsExpression: rawImports ? new compiler.WrappedNodeExpr(rawImports) : null,
|
|
7218
7217
|
id,
|
|
7219
7218
|
// Use `ɵɵsetNgModuleScope` to patch selector scopes onto the generated definition in a
|
|
7220
7219
|
// tree-shakeable way.
|
|
7221
|
-
selectorScopeMode:
|
|
7220
|
+
selectorScopeMode: compiler.R3SelectorScopeMode.SideEffect,
|
|
7222
7221
|
// TODO: to be implemented as a part of FW-1004.
|
|
7223
7222
|
schemas: [],
|
|
7224
7223
|
};
|
|
7225
7224
|
}
|
|
7226
7225
|
else {
|
|
7227
7226
|
ngModuleMetadata = {
|
|
7228
|
-
kind:
|
|
7227
|
+
kind: compiler.R3NgModuleMetadataKind.Global,
|
|
7229
7228
|
type,
|
|
7230
7229
|
bootstrap,
|
|
7231
7230
|
declarations,
|
|
@@ -7240,8 +7239,8 @@ class NgModuleDecoratorHandler {
|
|
|
7240
7239
|
// Use `ɵɵsetNgModuleScope` to patch selector scopes onto the generated definition in a
|
|
7241
7240
|
// tree-shakeable way.
|
|
7242
7241
|
selectorScopeMode: this.includeSelectorScope
|
|
7243
|
-
?
|
|
7244
|
-
:
|
|
7242
|
+
? compiler.R3SelectorScopeMode.SideEffect
|
|
7243
|
+
: compiler.R3SelectorScopeMode.Omit,
|
|
7245
7244
|
// TODO: to be implemented as a part of FW-1004.
|
|
7246
7245
|
schemas: [],
|
|
7247
7246
|
};
|
|
@@ -7252,7 +7251,7 @@ class NgModuleDecoratorHandler {
|
|
|
7252
7251
|
// and don't include the providers if it doesn't which saves us a few bytes.
|
|
7253
7252
|
if (rawProviders !== null &&
|
|
7254
7253
|
(!ts.isArrayLiteralExpression(rawProviders) || rawProviders.elements.length > 0)) {
|
|
7255
|
-
wrappedProviders = new
|
|
7254
|
+
wrappedProviders = new compiler.WrappedNodeExpr(this.annotateForClosureCompiler
|
|
7256
7255
|
? checker.wrapFunctionExpressionsInParens(rawProviders)
|
|
7257
7256
|
: rawProviders);
|
|
7258
7257
|
}
|
|
@@ -7304,12 +7303,12 @@ class NgModuleDecoratorHandler {
|
|
|
7304
7303
|
if (ts.isArrayLiteralExpression(exp)) {
|
|
7305
7304
|
// If array expression then add it entry-by-entry to the injector imports
|
|
7306
7305
|
if (exp.elements) {
|
|
7307
|
-
injectorMetadata.imports.push(...exp.elements.map((n) => new
|
|
7306
|
+
injectorMetadata.imports.push(...exp.elements.map((n) => new compiler.WrappedNodeExpr(n)));
|
|
7308
7307
|
}
|
|
7309
7308
|
}
|
|
7310
7309
|
else {
|
|
7311
7310
|
// if not array expression then add it as is to the injector's imports field.
|
|
7312
|
-
injectorMetadata.imports.push(new
|
|
7311
|
+
injectorMetadata.imports.push(new compiler.WrappedNodeExpr(exp));
|
|
7313
7312
|
}
|
|
7314
7313
|
}
|
|
7315
7314
|
}
|
|
@@ -7318,7 +7317,7 @@ class NgModuleDecoratorHandler {
|
|
|
7318
7317
|
type,
|
|
7319
7318
|
typeArgumentCount: 0,
|
|
7320
7319
|
deps: checker.getValidConstructorDependencies(node, this.reflector, this.isCore),
|
|
7321
|
-
target:
|
|
7320
|
+
target: compiler.FactoryTarget.NgModule,
|
|
7322
7321
|
};
|
|
7323
7322
|
// Remote scoping is used when adding imports to a component file would create a cycle. In such
|
|
7324
7323
|
// circumstances the component scope is monkey-patched from the NgModule file instead.
|
|
@@ -7417,7 +7416,7 @@ class NgModuleDecoratorHandler {
|
|
|
7417
7416
|
if (topLevelImport.hasModuleWithProviders) {
|
|
7418
7417
|
// We have no choice but to emit expressions which contain MWPs, as we cannot filter on
|
|
7419
7418
|
// individual references.
|
|
7420
|
-
data.injectorImports.push(new
|
|
7419
|
+
data.injectorImports.push(new compiler.WrappedNodeExpr(topLevelImport.expression));
|
|
7421
7420
|
continue;
|
|
7422
7421
|
}
|
|
7423
7422
|
const refsToEmit = [];
|
|
@@ -7460,7 +7459,7 @@ class NgModuleDecoratorHandler {
|
|
|
7460
7459
|
if (refsToEmit.length === topLevelImport.resolvedReferences.length) {
|
|
7461
7460
|
// All references within this top-level import should be emitted, so just use the user's
|
|
7462
7461
|
// expression.
|
|
7463
|
-
data.injectorImports.push(new
|
|
7462
|
+
data.injectorImports.push(new compiler.WrappedNodeExpr(topLevelImport.expression));
|
|
7464
7463
|
}
|
|
7465
7464
|
else {
|
|
7466
7465
|
// Some references have been filtered out. Emit references to individual classes.
|
|
@@ -7512,11 +7511,11 @@ class NgModuleDecoratorHandler {
|
|
|
7512
7511
|
}
|
|
7513
7512
|
compileFull(node, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection, }, { injectorImports }) {
|
|
7514
7513
|
const factoryFn = compileNgFactoryDefField(fac);
|
|
7515
|
-
const ngInjectorDef =
|
|
7514
|
+
const ngInjectorDef = compiler.compileInjector({
|
|
7516
7515
|
...inj,
|
|
7517
7516
|
imports: injectorImports,
|
|
7518
7517
|
});
|
|
7519
|
-
const ngModuleDef =
|
|
7518
|
+
const ngModuleDef = compiler.compileNgModule(mod);
|
|
7520
7519
|
const statements = ngModuleDef.statements;
|
|
7521
7520
|
const metadata = classMetadata !== null ? compileClassMetadata(classMetadata) : null;
|
|
7522
7521
|
this.insertMetadataStatement(statements, metadata);
|
|
@@ -7537,10 +7536,10 @@ class NgModuleDecoratorHandler {
|
|
|
7537
7536
|
}
|
|
7538
7537
|
compileLocal(node, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection, }) {
|
|
7539
7538
|
const factoryFn = compileNgFactoryDefField(fac);
|
|
7540
|
-
const ngInjectorDef =
|
|
7539
|
+
const ngInjectorDef = compiler.compileInjector({
|
|
7541
7540
|
...inj,
|
|
7542
7541
|
});
|
|
7543
|
-
const ngModuleDef =
|
|
7542
|
+
const ngModuleDef = compiler.compileNgModule(mod);
|
|
7544
7543
|
const statements = ngModuleDef.statements;
|
|
7545
7544
|
const metadata = classMetadata !== null ? compileClassMetadata(classMetadata) : null;
|
|
7546
7545
|
this.insertMetadataStatement(statements, metadata);
|
|
@@ -7578,19 +7577,19 @@ class NgModuleDecoratorHandler {
|
|
|
7578
7577
|
checker.assertSuccessfulReferenceEmit(type, node, 'pipe');
|
|
7579
7578
|
return type.expression;
|
|
7580
7579
|
});
|
|
7581
|
-
const directiveArray = new
|
|
7582
|
-
const pipesArray = new
|
|
7580
|
+
const directiveArray = new compiler.LiteralArrayExpr(directives);
|
|
7581
|
+
const pipesArray = new compiler.LiteralArrayExpr(pipes);
|
|
7583
7582
|
const directiveExpr = remoteScopesMayRequireCycleProtection && directives.length > 0
|
|
7584
|
-
? new
|
|
7583
|
+
? new compiler.FunctionExpr([], [new compiler.ReturnStatement(directiveArray)])
|
|
7585
7584
|
: directiveArray;
|
|
7586
7585
|
const pipesExpr = remoteScopesMayRequireCycleProtection && pipes.length > 0
|
|
7587
|
-
? new
|
|
7586
|
+
? new compiler.FunctionExpr([], [new compiler.ReturnStatement(pipesArray)])
|
|
7588
7587
|
: pipesArray;
|
|
7589
7588
|
const componentType = this.refEmitter.emit(decl, context);
|
|
7590
7589
|
checker.assertSuccessfulReferenceEmit(componentType, node, 'component');
|
|
7591
7590
|
const declExpr = componentType.expression;
|
|
7592
|
-
const setComponentScope = new
|
|
7593
|
-
const callExpr = new
|
|
7591
|
+
const setComponentScope = new compiler.ExternalExpr(compiler.Identifiers.setComponentScope);
|
|
7592
|
+
const callExpr = new compiler.InvokeFunctionExpr(setComponentScope, [
|
|
7594
7593
|
declExpr,
|
|
7595
7594
|
directiveExpr,
|
|
7596
7595
|
pipesExpr,
|
|
@@ -7855,7 +7854,7 @@ function createEmptyTemplate(componentClass, component, containingFile) {
|
|
|
7855
7854
|
styles: [],
|
|
7856
7855
|
styleUrls: [],
|
|
7857
7856
|
ngContentSelectors: [],
|
|
7858
|
-
file: new
|
|
7857
|
+
file: new compiler.ParseSourceFile('', ''),
|
|
7859
7858
|
sourceMapping: templateUrl
|
|
7860
7859
|
? { type: 'direct', node: template }
|
|
7861
7860
|
: {
|
|
@@ -7868,7 +7867,7 @@ function createEmptyTemplate(componentClass, component, containingFile) {
|
|
|
7868
7867
|
declaration: templateUrl
|
|
7869
7868
|
? {
|
|
7870
7869
|
isInline: false,
|
|
7871
|
-
interpolationConfig:
|
|
7870
|
+
interpolationConfig: compiler.InterpolationConfig.fromArray(null),
|
|
7872
7871
|
preserveWhitespaces: false,
|
|
7873
7872
|
templateUrlExpression: templateUrl,
|
|
7874
7873
|
templateUrl: 'missing.ng.html',
|
|
@@ -7876,7 +7875,7 @@ function createEmptyTemplate(componentClass, component, containingFile) {
|
|
|
7876
7875
|
}
|
|
7877
7876
|
: {
|
|
7878
7877
|
isInline: true,
|
|
7879
|
-
interpolationConfig:
|
|
7878
|
+
interpolationConfig: compiler.InterpolationConfig.fromArray(null),
|
|
7880
7879
|
preserveWhitespaces: false,
|
|
7881
7880
|
expression: template,
|
|
7882
7881
|
templateUrl: containingFile,
|
|
@@ -7897,7 +7896,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
7897
7896
|
enableBlockSyntax: options.enableBlockSyntax,
|
|
7898
7897
|
enableLetSyntax: options.enableLetSyntax,
|
|
7899
7898
|
};
|
|
7900
|
-
const parsedTemplate =
|
|
7899
|
+
const parsedTemplate = compiler.parseTemplate(sourceStr, sourceMapUrl ?? '', {
|
|
7901
7900
|
...commonParseOptions,
|
|
7902
7901
|
preserveWhitespaces: template.preserveWhitespaces,
|
|
7903
7902
|
preserveSignificantWhitespace: options.preserveSignificantWhitespace,
|
|
@@ -7916,7 +7915,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
7916
7915
|
//
|
|
7917
7916
|
// In order to guarantee the correctness of diagnostics, templates are parsed a second time
|
|
7918
7917
|
// with the above options set to preserve source mappings.
|
|
7919
|
-
const { nodes: diagNodes } =
|
|
7918
|
+
const { nodes: diagNodes } = compiler.parseTemplate(sourceStr, sourceMapUrl ?? '', {
|
|
7920
7919
|
...commonParseOptions,
|
|
7921
7920
|
preserveWhitespaces: true,
|
|
7922
7921
|
preserveLineEndings: true,
|
|
@@ -7926,7 +7925,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
7926
7925
|
return {
|
|
7927
7926
|
...parsedTemplate,
|
|
7928
7927
|
diagNodes,
|
|
7929
|
-
file: new
|
|
7928
|
+
file: new compiler.ParseSourceFile(sourceStr, sourceMapUrl ?? ''),
|
|
7930
7929
|
};
|
|
7931
7930
|
}
|
|
7932
7931
|
function parseTemplateDeclaration(node, decorator, component, containingFile, evaluator, depTracker, resourceLoader, defaultPreserveWhitespaces) {
|
|
@@ -7939,7 +7938,7 @@ function parseTemplateDeclaration(node, decorator, component, containingFile, ev
|
|
|
7939
7938
|
}
|
|
7940
7939
|
preserveWhitespaces = value;
|
|
7941
7940
|
}
|
|
7942
|
-
let interpolationConfig =
|
|
7941
|
+
let interpolationConfig = compiler.DEFAULT_INTERPOLATION_CONFIG;
|
|
7943
7942
|
if (component.has('interpolation')) {
|
|
7944
7943
|
const expr = component.get('interpolation');
|
|
7945
7944
|
const value = evaluator.evaluate(expr);
|
|
@@ -7948,7 +7947,7 @@ function parseTemplateDeclaration(node, decorator, component, containingFile, ev
|
|
|
7948
7947
|
!value.every((element) => typeof element === 'string')) {
|
|
7949
7948
|
throw checker.createValueHasWrongTypeError(expr, value, 'interpolation must be an array with 2 elements of string type');
|
|
7950
7949
|
}
|
|
7951
|
-
interpolationConfig =
|
|
7950
|
+
interpolationConfig = compiler.InterpolationConfig.fromArray(value);
|
|
7952
7951
|
}
|
|
7953
7952
|
if (component.has('templateUrl')) {
|
|
7954
7953
|
const templateUrlExpr = component.get('templateUrl');
|
|
@@ -8431,7 +8430,7 @@ function extractHmrDependencies(node, definition, factory, deferBlockMetadata, c
|
|
|
8431
8430
|
const local = [];
|
|
8432
8431
|
const seenLocals = new Set();
|
|
8433
8432
|
for (const readNode of visitor.allReads) {
|
|
8434
|
-
const readName = readNode instanceof
|
|
8433
|
+
const readName = readNode instanceof compiler.ReadVarExpr ? readNode.name : readNode.text;
|
|
8435
8434
|
if (readName !== name && !seenLocals.has(readName) && availableTopLevel.has(readName)) {
|
|
8436
8435
|
const runtimeRepresentation = getRuntimeRepresentation(readNode, reflection, evaluator);
|
|
8437
8436
|
if (runtimeRepresentation === null) {
|
|
@@ -8453,8 +8452,8 @@ function extractHmrDependencies(node, definition, factory, deferBlockMetadata, c
|
|
|
8453
8452
|
* Gets a node that can be used to represent an identifier in the HMR replacement code at runtime.
|
|
8454
8453
|
*/
|
|
8455
8454
|
function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
8456
|
-
if (node instanceof
|
|
8457
|
-
return
|
|
8455
|
+
if (node instanceof compiler.ReadVarExpr) {
|
|
8456
|
+
return compiler.variable(node.name);
|
|
8458
8457
|
}
|
|
8459
8458
|
// Const enums can't be passed by reference, because their values are inlined.
|
|
8460
8459
|
// Pass in an object literal with all of the values instead.
|
|
@@ -8471,7 +8470,7 @@ function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
|
8471
8470
|
members.push({
|
|
8472
8471
|
key: name,
|
|
8473
8472
|
quoted: false,
|
|
8474
|
-
value:
|
|
8473
|
+
value: compiler.literal(value.resolved),
|
|
8475
8474
|
});
|
|
8476
8475
|
}
|
|
8477
8476
|
else {
|
|
@@ -8481,10 +8480,10 @@ function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
|
8481
8480
|
return null;
|
|
8482
8481
|
}
|
|
8483
8482
|
}
|
|
8484
|
-
return
|
|
8483
|
+
return compiler.literalMap(members);
|
|
8485
8484
|
}
|
|
8486
8485
|
}
|
|
8487
|
-
return
|
|
8486
|
+
return compiler.variable(node.text);
|
|
8488
8487
|
}
|
|
8489
8488
|
/**
|
|
8490
8489
|
* Gets the names of all top-level declarations within the file (imports, declared classes etc).
|
|
@@ -8564,7 +8563,7 @@ function trackBindingName(node, results) {
|
|
|
8564
8563
|
* The reads are "potential", because the visitor doesn't account for local variables
|
|
8565
8564
|
* inside functions.
|
|
8566
8565
|
*/
|
|
8567
|
-
class PotentialTopLevelReadsVisitor extends
|
|
8566
|
+
class PotentialTopLevelReadsVisitor extends compiler.RecursiveAstVisitor$1 {
|
|
8568
8567
|
allReads = new Set();
|
|
8569
8568
|
namespaceReads = new Set();
|
|
8570
8569
|
visitExternalExpr(ast, context) {
|
|
@@ -8750,7 +8749,7 @@ function extractHmrMetatadata(clazz, reflection, evaluator, compilerHost, rootDi
|
|
|
8750
8749
|
return null;
|
|
8751
8750
|
}
|
|
8752
8751
|
const meta = {
|
|
8753
|
-
type: new
|
|
8752
|
+
type: new compiler.WrappedNodeExpr(clazz.name),
|
|
8754
8753
|
className: clazz.name.text,
|
|
8755
8754
|
filePath,
|
|
8756
8755
|
localDependencies: dependencies.local,
|
|
@@ -8809,8 +8808,8 @@ class HmrModuleImportRewriter {
|
|
|
8809
8808
|
}
|
|
8810
8809
|
|
|
8811
8810
|
const EMPTY_ARRAY = [];
|
|
8812
|
-
const isUsedDirective = (decl) => decl.kind ===
|
|
8813
|
-
const isUsedPipe = (decl) => decl.kind ===
|
|
8811
|
+
const isUsedDirective = (decl) => decl.kind === compiler.R3TemplateDependencyKind.Directive;
|
|
8812
|
+
const isUsedPipe = (decl) => decl.kind === compiler.R3TemplateDependencyKind.Pipe;
|
|
8814
8813
|
/**
|
|
8815
8814
|
* `DecoratorHandler` which handles the `@Component` annotation.
|
|
8816
8815
|
*/
|
|
@@ -8918,7 +8917,7 @@ class ComponentDecoratorHandler {
|
|
|
8918
8917
|
this.canDeferDeps = !enableHmr;
|
|
8919
8918
|
}
|
|
8920
8919
|
literalCache = new Map();
|
|
8921
|
-
elementSchemaRegistry = new
|
|
8920
|
+
elementSchemaRegistry = new compiler.DomElementSchemaRegistry();
|
|
8922
8921
|
/**
|
|
8923
8922
|
* During the asynchronous preanalyze phase, it's necessary to parse the template to extract
|
|
8924
8923
|
* any potential <link> tags which might need to be loaded. This cache ensures that work is not
|
|
@@ -9053,19 +9052,19 @@ class ComponentDecoratorHandler {
|
|
|
9053
9052
|
const encapsulation = (this.compilationMode !== checker.CompilationMode.LOCAL
|
|
9054
9053
|
? resolveEnumValue(this.evaluator, component, 'encapsulation', 'ViewEncapsulation', this.isCore)
|
|
9055
9054
|
: resolveEncapsulationEnumValueLocally(component.get('encapsulation'))) ??
|
|
9056
|
-
|
|
9055
|
+
compiler.ViewEncapsulation.Emulated;
|
|
9057
9056
|
let changeDetection = null;
|
|
9058
9057
|
if (this.compilationMode !== checker.CompilationMode.LOCAL) {
|
|
9059
9058
|
changeDetection = resolveEnumValue(this.evaluator, component, 'changeDetection', 'ChangeDetectionStrategy', this.isCore);
|
|
9060
9059
|
}
|
|
9061
9060
|
else if (component.has('changeDetection')) {
|
|
9062
|
-
changeDetection = new
|
|
9061
|
+
changeDetection = new compiler.WrappedNodeExpr(component.get('changeDetection'));
|
|
9063
9062
|
}
|
|
9064
9063
|
let animations = null;
|
|
9065
9064
|
let animationTriggerNames = null;
|
|
9066
9065
|
if (component.has('animations')) {
|
|
9067
9066
|
const animationExpression = component.get('animations');
|
|
9068
|
-
animations = new
|
|
9067
|
+
animations = new compiler.WrappedNodeExpr(animationExpression);
|
|
9069
9068
|
const animationsValue = this.evaluator.evaluate(animationExpression, animationTriggerResolver);
|
|
9070
9069
|
animationTriggerNames = { includesDynamicAnimations: false, staticTriggerNames: [] };
|
|
9071
9070
|
collectAnimationNames(animationsValue, animationTriggerNames);
|
|
@@ -9090,7 +9089,7 @@ class ComponentDecoratorHandler {
|
|
|
9090
9089
|
if (component.has('viewProviders')) {
|
|
9091
9090
|
const viewProviders = component.get('viewProviders');
|
|
9092
9091
|
viewProvidersRequiringFactory = checker.resolveProvidersRequiringFactory(viewProviders, this.reflector, this.evaluator);
|
|
9093
|
-
wrappedViewProviders = new
|
|
9092
|
+
wrappedViewProviders = new compiler.WrappedNodeExpr(this.annotateForClosureCompiler
|
|
9094
9093
|
? checker.wrapFunctionExpressionsInParens(viewProviders)
|
|
9095
9094
|
: viewProviders);
|
|
9096
9095
|
}
|
|
@@ -9268,7 +9267,7 @@ class ComponentDecoratorHandler {
|
|
|
9268
9267
|
diagnostics.push(makeResourceNotFoundError(styleUrl.url, styleUrl.expression, resourceType).toDiagnostic());
|
|
9269
9268
|
}
|
|
9270
9269
|
}
|
|
9271
|
-
if (encapsulation ===
|
|
9270
|
+
if (encapsulation === compiler.ViewEncapsulation.ShadowDom && metadata.selector !== null) {
|
|
9272
9271
|
const selectorError = checkCustomElementSelectorForErrors(metadata.selector);
|
|
9273
9272
|
if (selectorError !== null) {
|
|
9274
9273
|
if (diagnostics === undefined) {
|
|
@@ -9341,7 +9340,7 @@ class ComponentDecoratorHandler {
|
|
|
9341
9340
|
template,
|
|
9342
9341
|
encapsulation,
|
|
9343
9342
|
changeDetection,
|
|
9344
|
-
interpolation: template.interpolationConfig ??
|
|
9343
|
+
interpolation: template.interpolationConfig ?? compiler.DEFAULT_INTERPOLATION_CONFIG,
|
|
9345
9344
|
styles,
|
|
9346
9345
|
externalStyles,
|
|
9347
9346
|
// These will be replaced during the compilation step, after all `NgModule`s have been
|
|
@@ -9350,7 +9349,7 @@ class ComponentDecoratorHandler {
|
|
|
9350
9349
|
viewProviders: wrappedViewProviders,
|
|
9351
9350
|
i18nUseExternalIds: this.i18nUseExternalIds,
|
|
9352
9351
|
relativeContextFilePath,
|
|
9353
|
-
rawImports: rawImports !== null ? new
|
|
9352
|
+
rawImports: rawImports !== null ? new compiler.WrappedNodeExpr(rawImports) : undefined,
|
|
9354
9353
|
relativeTemplatePath,
|
|
9355
9354
|
},
|
|
9356
9355
|
typeCheckMeta: checker.extractDirectiveTypeCheckMeta(node, inputs, this.reflector),
|
|
@@ -9433,7 +9432,7 @@ class ComponentDecoratorHandler {
|
|
|
9433
9432
|
}
|
|
9434
9433
|
const scope = this.scopeReader.getScopeForComponent(node);
|
|
9435
9434
|
const selector = analysis.meta.selector;
|
|
9436
|
-
const matcher = new
|
|
9435
|
+
const matcher = new compiler.SelectorMatcher();
|
|
9437
9436
|
if (scope !== null) {
|
|
9438
9437
|
let { dependencies, isPoisoned } = scope.kind === checker.ComponentScopeKind.NgModule ? scope.compilation : scope;
|
|
9439
9438
|
if ((isPoisoned || (scope.kind === checker.ComponentScopeKind.NgModule && scope.exported.isPoisoned)) &&
|
|
@@ -9444,14 +9443,14 @@ class ComponentDecoratorHandler {
|
|
|
9444
9443
|
}
|
|
9445
9444
|
for (const dep of dependencies) {
|
|
9446
9445
|
if (dep.kind === checker.MetaKind.Directive && dep.selector !== null) {
|
|
9447
|
-
matcher.addSelectables(
|
|
9446
|
+
matcher.addSelectables(compiler.CssSelector.parse(dep.selector), [
|
|
9448
9447
|
...this.hostDirectivesResolver.resolve(dep),
|
|
9449
9448
|
dep,
|
|
9450
9449
|
]);
|
|
9451
9450
|
}
|
|
9452
9451
|
}
|
|
9453
9452
|
}
|
|
9454
|
-
const binder = new
|
|
9453
|
+
const binder = new compiler.R3TargetBinder(matcher);
|
|
9455
9454
|
const boundTemplate = binder.bind({ template: analysis.template.diagNodes });
|
|
9456
9455
|
context.addComponent({
|
|
9457
9456
|
declaration: node,
|
|
@@ -9473,7 +9472,7 @@ class ComponentDecoratorHandler {
|
|
|
9473
9472
|
// Don't type-check components that had errors in their scopes, unless requested.
|
|
9474
9473
|
return;
|
|
9475
9474
|
}
|
|
9476
|
-
const binder = new
|
|
9475
|
+
const binder = new compiler.R3TargetBinder(scope.matcher);
|
|
9477
9476
|
const templateContext = {
|
|
9478
9477
|
nodes: meta.template.diagNodes,
|
|
9479
9478
|
pipes: scope.pipes,
|
|
@@ -9597,18 +9596,23 @@ class ComponentDecoratorHandler {
|
|
|
9597
9596
|
diagnostics.push(diagnostic);
|
|
9598
9597
|
}
|
|
9599
9598
|
}
|
|
9600
|
-
// Set up the R3TargetBinder
|
|
9601
|
-
// later fed to the TemplateDefinitionBuilder.
|
|
9599
|
+
// Set up the R3TargetBinder.
|
|
9602
9600
|
const binder = createTargetBinder(dependencies);
|
|
9603
|
-
const pipes = extractPipes(dependencies);
|
|
9604
9601
|
let allDependencies = dependencies;
|
|
9605
9602
|
let deferBlockBinder = binder;
|
|
9606
9603
|
// If there are any explicitly deferred dependencies (via `@Component.deferredImports`),
|
|
9607
|
-
// re-compute the list of dependencies and create a new binder for defer blocks.
|
|
9604
|
+
// re-compute the list of dependencies and create a new binder for defer blocks. This
|
|
9605
|
+
// is because we have deferred dependencies that are not in the standard imports list
|
|
9606
|
+
// and need to be referenced later when determining what dependencies need to be in a
|
|
9607
|
+
// defer function / instruction call. Otherwise they end up treated as a standard
|
|
9608
|
+
// import, which is wrong.
|
|
9608
9609
|
if (explicitlyDeferredDependencies.length > 0) {
|
|
9609
9610
|
allDependencies = [...explicitlyDeferredDependencies, ...dependencies];
|
|
9610
9611
|
deferBlockBinder = createTargetBinder(allDependencies);
|
|
9611
9612
|
}
|
|
9613
|
+
// Set up the pipes map that is later used to determine which dependencies are used in
|
|
9614
|
+
// the template.
|
|
9615
|
+
const pipes = extractPipes(allDependencies);
|
|
9612
9616
|
// Next, the component template AST is bound using the R3TargetBinder. This produces a
|
|
9613
9617
|
// BoundTarget, which is similar to a ts.TypeChecker.
|
|
9614
9618
|
const bound = binder.bind({ template: metadata.template.nodes });
|
|
@@ -9651,10 +9655,10 @@ class ComponentDecoratorHandler {
|
|
|
9651
9655
|
// including all defer blocks.
|
|
9652
9656
|
const wholeTemplateUsed = new Set(eagerlyUsed);
|
|
9653
9657
|
for (const bound of deferBlocks.values()) {
|
|
9654
|
-
for (const dir of bound.
|
|
9658
|
+
for (const dir of bound.getUsedDirectives()) {
|
|
9655
9659
|
wholeTemplateUsed.add(dir.ref.node);
|
|
9656
9660
|
}
|
|
9657
|
-
for (const name of bound.
|
|
9661
|
+
for (const name of bound.getUsedPipes()) {
|
|
9658
9662
|
if (!pipes.has(name)) {
|
|
9659
9663
|
continue;
|
|
9660
9664
|
}
|
|
@@ -9676,7 +9680,7 @@ class ComponentDecoratorHandler {
|
|
|
9676
9680
|
const dirType = this.refEmitter.emit(dep.ref, context);
|
|
9677
9681
|
checker.assertSuccessfulReferenceEmit(dirType, node.name, dep.isComponent ? 'component' : 'directive');
|
|
9678
9682
|
declarations.set(dep.ref.node, {
|
|
9679
|
-
kind:
|
|
9683
|
+
kind: compiler.R3TemplateDependencyKind.Directive,
|
|
9680
9684
|
ref: dep.ref,
|
|
9681
9685
|
type: dirType.expression,
|
|
9682
9686
|
importedFile: dirType.importedFile,
|
|
@@ -9694,7 +9698,7 @@ class ComponentDecoratorHandler {
|
|
|
9694
9698
|
const pipeType = this.refEmitter.emit(dep.ref, context);
|
|
9695
9699
|
checker.assertSuccessfulReferenceEmit(pipeType, node.name, 'pipe');
|
|
9696
9700
|
declarations.set(dep.ref.node, {
|
|
9697
|
-
kind:
|
|
9701
|
+
kind: compiler.R3TemplateDependencyKind.Pipe,
|
|
9698
9702
|
type: pipeType.expression,
|
|
9699
9703
|
name: dep.name,
|
|
9700
9704
|
ref: dep.ref,
|
|
@@ -9705,7 +9709,7 @@ class ComponentDecoratorHandler {
|
|
|
9705
9709
|
const ngModuleType = this.refEmitter.emit(dep.ref, context);
|
|
9706
9710
|
checker.assertSuccessfulReferenceEmit(ngModuleType, node.name, 'NgModule');
|
|
9707
9711
|
declarations.set(dep.ref.node, {
|
|
9708
|
-
kind:
|
|
9712
|
+
kind: compiler.R3TemplateDependencyKind.NgModule,
|
|
9709
9713
|
type: ngModuleType.expression,
|
|
9710
9714
|
importedFile: ngModuleType.importedFile,
|
|
9711
9715
|
});
|
|
@@ -9721,7 +9725,7 @@ class ComponentDecoratorHandler {
|
|
|
9721
9725
|
.filter(isUsedPipe)
|
|
9722
9726
|
.map(getSemanticReference);
|
|
9723
9727
|
}
|
|
9724
|
-
const eagerDeclarations = Array.from(declarations.values()).filter((decl) => decl.kind ===
|
|
9728
|
+
const eagerDeclarations = Array.from(declarations.values()).filter((decl) => decl.kind === compiler.R3TemplateDependencyKind.NgModule || eagerlyUsed.has(decl.ref.node));
|
|
9725
9729
|
// Process information related to defer blocks
|
|
9726
9730
|
if (this.compilationMode !== checker.CompilationMode.LOCAL) {
|
|
9727
9731
|
this.resolveDeferBlocks(node, deferBlocks, declarations, data, analysis, eagerlyUsed);
|
|
@@ -9738,10 +9742,10 @@ class ComponentDecoratorHandler {
|
|
|
9738
9742
|
const cycle = this._checkForCyclicImport(usedDep.importedFile, usedDep.type, context);
|
|
9739
9743
|
if (cycle !== null) {
|
|
9740
9744
|
switch (usedDep.kind) {
|
|
9741
|
-
case
|
|
9745
|
+
case compiler.R3TemplateDependencyKind.Directive:
|
|
9742
9746
|
cyclesFromDirectives.set(usedDep, cycle);
|
|
9743
9747
|
break;
|
|
9744
|
-
case
|
|
9748
|
+
case compiler.R3TemplateDependencyKind.Pipe:
|
|
9745
9749
|
cyclesFromPipes.set(usedDep, cycle);
|
|
9746
9750
|
break;
|
|
9747
9751
|
}
|
|
@@ -9782,7 +9786,7 @@ class ComponentDecoratorHandler {
|
|
|
9782
9786
|
// best-guess extra imports globally to all files using
|
|
9783
9787
|
// `localCompilationExtraImportsTracker.addGlobalImportFromIdentifier`.
|
|
9784
9788
|
for (const { type } of eagerDeclarations) {
|
|
9785
|
-
if (type instanceof
|
|
9789
|
+
if (type instanceof compiler.ExternalExpr && type.value.moduleName) {
|
|
9786
9790
|
this.localCompilationExtraImportsTracker.addImportForFile(context, type.value.moduleName);
|
|
9787
9791
|
}
|
|
9788
9792
|
}
|
|
@@ -9839,12 +9843,12 @@ class ComponentDecoratorHandler {
|
|
|
9839
9843
|
diagnostics.push(...importDiagnostics);
|
|
9840
9844
|
}
|
|
9841
9845
|
if (analysis.providersRequiringFactory !== null &&
|
|
9842
|
-
analysis.meta.providers instanceof
|
|
9846
|
+
analysis.meta.providers instanceof compiler.WrappedNodeExpr) {
|
|
9843
9847
|
const providerDiagnostics = checker.getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
|
|
9844
9848
|
diagnostics.push(...providerDiagnostics);
|
|
9845
9849
|
}
|
|
9846
9850
|
if (analysis.viewProvidersRequiringFactory !== null &&
|
|
9847
|
-
analysis.meta.viewProviders instanceof
|
|
9851
|
+
analysis.meta.viewProviders instanceof compiler.WrappedNodeExpr) {
|
|
9848
9852
|
const viewProviderDiagnostics = checker.getProviderDiagnostics(analysis.viewProvidersRequiringFactory, analysis.meta.viewProviders.node, this.injectableRegistry);
|
|
9849
9853
|
diagnostics.push(...viewProviderDiagnostics);
|
|
9850
9854
|
}
|
|
@@ -9865,7 +9869,7 @@ class ComponentDecoratorHandler {
|
|
|
9865
9869
|
return { data };
|
|
9866
9870
|
}
|
|
9867
9871
|
xi18n(ctx, node, analysis) {
|
|
9868
|
-
ctx.updateFromTemplate(analysis.template.content, analysis.template.declaration.resolvedTemplateUrl, analysis.template.interpolationConfig ??
|
|
9872
|
+
ctx.updateFromTemplate(analysis.template.content, analysis.template.declaration.resolvedTemplateUrl, analysis.template.interpolationConfig ?? compiler.DEFAULT_INTERPOLATION_CONFIG);
|
|
9869
9873
|
}
|
|
9870
9874
|
updateResources(node, analysis) {
|
|
9871
9875
|
const containingFile = node.getSourceFile().fileName;
|
|
@@ -9914,11 +9918,11 @@ class ComponentDecoratorHandler {
|
|
|
9914
9918
|
...resolution,
|
|
9915
9919
|
defer,
|
|
9916
9920
|
};
|
|
9917
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta,
|
|
9921
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, compiler.FactoryTarget.Component));
|
|
9918
9922
|
if (perComponentDeferredDeps !== null) {
|
|
9919
9923
|
removeDeferrableTypesFromComponentDecorator(analysis, perComponentDeferredDeps);
|
|
9920
9924
|
}
|
|
9921
|
-
const def =
|
|
9925
|
+
const def = compiler.compileComponentFromMetadata(meta, pool, compiler.makeBindingParser());
|
|
9922
9926
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
9923
9927
|
const classMetadata = analysis.classMetadata !== null
|
|
9924
9928
|
? compileComponentClassMetadata(analysis.classMetadata, perComponentDeferredDeps).toStmt()
|
|
@@ -9944,7 +9948,7 @@ class ComponentDecoratorHandler {
|
|
|
9944
9948
|
sourceUrl: analysis.template.declaration.resolvedTemplateUrl,
|
|
9945
9949
|
isInline: analysis.template.declaration.isInline,
|
|
9946
9950
|
inlineTemplateLiteralExpression: analysis.template.sourceMapping.type === 'direct'
|
|
9947
|
-
? new
|
|
9951
|
+
? new compiler.WrappedNodeExpr(analysis.template.sourceMapping.node)
|
|
9948
9952
|
: null,
|
|
9949
9953
|
};
|
|
9950
9954
|
const perComponentDeferredDeps = this.canDeferDeps
|
|
@@ -9956,7 +9960,7 @@ class ComponentDecoratorHandler {
|
|
|
9956
9960
|
...resolution,
|
|
9957
9961
|
defer,
|
|
9958
9962
|
};
|
|
9959
|
-
const fac = compileDeclareFactory(checker.toFactoryMetadata(meta,
|
|
9963
|
+
const fac = compileDeclareFactory(checker.toFactoryMetadata(meta, compiler.FactoryTarget.Component));
|
|
9960
9964
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
9961
9965
|
const def = compileDeclareComponentFromMetadata(meta, analysis.template, templateInfo);
|
|
9962
9966
|
const classMetadata = analysis.classMetadata !== null
|
|
@@ -9985,8 +9989,8 @@ class ComponentDecoratorHandler {
|
|
|
9985
9989
|
if (deferrableTypes !== null) {
|
|
9986
9990
|
removeDeferrableTypesFromComponentDecorator(analysis, deferrableTypes);
|
|
9987
9991
|
}
|
|
9988
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta,
|
|
9989
|
-
const def =
|
|
9992
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, compiler.FactoryTarget.Component));
|
|
9993
|
+
const def = compiler.compileComponentFromMetadata(meta, pool, compiler.makeBindingParser());
|
|
9990
9994
|
const inputTransformFields = compileInputTransformFields(analysis.inputs);
|
|
9991
9995
|
const classMetadata = analysis.classMetadata !== null
|
|
9992
9996
|
? compileComponentClassMetadata(analysis.classMetadata, deferrableTypes).toStmt()
|
|
@@ -10008,15 +10012,15 @@ class ComponentDecoratorHandler {
|
|
|
10008
10012
|
return null;
|
|
10009
10013
|
}
|
|
10010
10014
|
// Create a brand-new constant pool since there shouldn't be any constant sharing.
|
|
10011
|
-
const pool = new
|
|
10015
|
+
const pool = new compiler.ConstantPool();
|
|
10012
10016
|
const defer = this.compileDeferBlocks(resolution);
|
|
10013
10017
|
const meta = {
|
|
10014
10018
|
...analysis.meta,
|
|
10015
10019
|
...resolution,
|
|
10016
10020
|
defer,
|
|
10017
10021
|
};
|
|
10018
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta,
|
|
10019
|
-
const def =
|
|
10022
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(meta, compiler.FactoryTarget.Component));
|
|
10023
|
+
const def = compiler.compileComponentFromMetadata(meta, pool, compiler.makeBindingParser());
|
|
10020
10024
|
const classMetadata = analysis.classMetadata !== null
|
|
10021
10025
|
? compileComponentClassMetadata(analysis.classMetadata, null).toStmt()
|
|
10022
10026
|
: null;
|
|
@@ -10037,7 +10041,7 @@ class ComponentDecoratorHandler {
|
|
|
10037
10041
|
*/
|
|
10038
10042
|
locateDeferBlocksWithoutScope(template) {
|
|
10039
10043
|
const deferBlocks = new Map();
|
|
10040
|
-
const directivelessBinder = new
|
|
10044
|
+
const directivelessBinder = new compiler.R3TargetBinder(new compiler.SelectorMatcher());
|
|
10041
10045
|
const bound = directivelessBinder.bind({ template: template.nodes });
|
|
10042
10046
|
const deferredBlocks = bound.getDeferBlocks();
|
|
10043
10047
|
for (const block of deferredBlocks) {
|
|
@@ -10140,14 +10144,14 @@ class ComponentDecoratorHandler {
|
|
|
10140
10144
|
resolutionData.deferPerBlockDependencies.set(deferBlock, deps);
|
|
10141
10145
|
}
|
|
10142
10146
|
for (const decl of Array.from(deferrableDecls.values())) {
|
|
10143
|
-
if (decl.kind ===
|
|
10147
|
+
if (decl.kind === compiler.R3TemplateDependencyKind.NgModule) {
|
|
10144
10148
|
continue;
|
|
10145
10149
|
}
|
|
10146
|
-
if (decl.kind ===
|
|
10150
|
+
if (decl.kind === compiler.R3TemplateDependencyKind.Directive &&
|
|
10147
10151
|
!usedDirectives.has(decl.ref.node)) {
|
|
10148
10152
|
continue;
|
|
10149
10153
|
}
|
|
10150
|
-
if (decl.kind ===
|
|
10154
|
+
if (decl.kind === compiler.R3TemplateDependencyKind.Pipe && !usedPipes.has(decl.name)) {
|
|
10151
10155
|
continue;
|
|
10152
10156
|
}
|
|
10153
10157
|
// Collect initial information about this dependency.
|
|
@@ -10242,7 +10246,7 @@ class ComponentDecoratorHandler {
|
|
|
10242
10246
|
}
|
|
10243
10247
|
const blocks = new Map();
|
|
10244
10248
|
for (const [block, dependencies] of perBlockDeps) {
|
|
10245
|
-
blocks.set(block, dependencies.length === 0 ? null :
|
|
10249
|
+
blocks.set(block, dependencies.length === 0 ? null : compiler.compileDeferResolverFunction({ mode, dependencies }));
|
|
10246
10250
|
}
|
|
10247
10251
|
return { mode, blocks };
|
|
10248
10252
|
}
|
|
@@ -10254,7 +10258,7 @@ class ComponentDecoratorHandler {
|
|
|
10254
10258
|
mode,
|
|
10255
10259
|
dependenciesFn: perComponentDeps.length === 0
|
|
10256
10260
|
? null
|
|
10257
|
-
:
|
|
10261
|
+
: compiler.compileDeferResolverFunction({ mode, dependencies: perComponentDeps }),
|
|
10258
10262
|
};
|
|
10259
10263
|
}
|
|
10260
10264
|
throw new Error(`Invalid deferBlockDepsEmitMode. Cannot compile deferred block metadata.`);
|
|
@@ -10264,13 +10268,13 @@ class ComponentDecoratorHandler {
|
|
|
10264
10268
|
* Creates an instance of a target binder based on provided dependencies.
|
|
10265
10269
|
*/
|
|
10266
10270
|
function createTargetBinder(dependencies) {
|
|
10267
|
-
const matcher = new
|
|
10271
|
+
const matcher = new compiler.SelectorMatcher();
|
|
10268
10272
|
for (const dep of dependencies) {
|
|
10269
10273
|
if (dep.kind === checker.MetaKind.Directive && dep.selector !== null) {
|
|
10270
|
-
matcher.addSelectables(
|
|
10274
|
+
matcher.addSelectables(compiler.CssSelector.parse(dep.selector), [dep]);
|
|
10271
10275
|
}
|
|
10272
10276
|
}
|
|
10273
|
-
return new
|
|
10277
|
+
return new compiler.R3TargetBinder(matcher);
|
|
10274
10278
|
}
|
|
10275
10279
|
/**
|
|
10276
10280
|
* Returns the list of dependencies from `@Component.deferredImports` if provided.
|
|
@@ -10297,7 +10301,7 @@ function removeDeferrableTypesFromComponentDecorator(analysis, deferrableTypes)
|
|
|
10297
10301
|
if (analysis.classMetadata) {
|
|
10298
10302
|
const deferrableSymbols = new Set(deferrableTypes.map((t) => t.symbolName));
|
|
10299
10303
|
const rewrittenDecoratorsNode = removeIdentifierReferences(analysis.classMetadata.decorators.node, deferrableSymbols);
|
|
10300
|
-
analysis.classMetadata.decorators = new
|
|
10304
|
+
analysis.classMetadata.decorators = new compiler.WrappedNodeExpr(rewrittenDecoratorsNode);
|
|
10301
10305
|
}
|
|
10302
10306
|
}
|
|
10303
10307
|
/**
|
|
@@ -10453,19 +10457,19 @@ class InjectableDecoratorHandler {
|
|
|
10453
10457
|
return {};
|
|
10454
10458
|
}
|
|
10455
10459
|
compileFull(node, analysis) {
|
|
10456
|
-
return this.compile(compileNgFactoryDefField, (meta) =>
|
|
10460
|
+
return this.compile(compileNgFactoryDefField, (meta) => compiler.compileInjectable(meta, false), compileClassMetadata, node, analysis);
|
|
10457
10461
|
}
|
|
10458
10462
|
compilePartial(node, analysis) {
|
|
10459
10463
|
return this.compile(compileDeclareFactory, compileDeclareInjectableFromMetadata, compileDeclareClassMetadata, node, analysis);
|
|
10460
10464
|
}
|
|
10461
10465
|
compileLocal(node, analysis) {
|
|
10462
|
-
return this.compile(compileNgFactoryDefField, (meta) =>
|
|
10466
|
+
return this.compile(compileNgFactoryDefField, (meta) => compiler.compileInjectable(meta, false), compileClassMetadata, node, analysis);
|
|
10463
10467
|
}
|
|
10464
10468
|
compile(compileFactoryFn, compileInjectableFn, compileClassMetadataFn, node, analysis) {
|
|
10465
10469
|
const results = [];
|
|
10466
10470
|
if (analysis.needsFactory) {
|
|
10467
10471
|
const meta = analysis.meta;
|
|
10468
|
-
const factoryRes = compileFactoryFn(checker.toFactoryMetadata({ ...meta, deps: analysis.ctorDeps },
|
|
10472
|
+
const factoryRes = compileFactoryFn(checker.toFactoryMetadata({ ...meta, deps: analysis.ctorDeps }, compiler.FactoryTarget.Injectable));
|
|
10469
10473
|
if (analysis.classMetadata !== null) {
|
|
10470
10474
|
factoryRes.statements.push(compileClassMetadataFn(analysis.classMetadata).toStmt());
|
|
10471
10475
|
}
|
|
@@ -10507,7 +10511,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10507
10511
|
name,
|
|
10508
10512
|
type,
|
|
10509
10513
|
typeArgumentCount,
|
|
10510
|
-
providedIn:
|
|
10514
|
+
providedIn: compiler.createMayBeForwardRefExpression(new compiler.LiteralExpr(null), 0 /* ForwardRefHandling.None */),
|
|
10511
10515
|
};
|
|
10512
10516
|
}
|
|
10513
10517
|
else if (decorator.args.length === 1) {
|
|
@@ -10522,7 +10526,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10522
10526
|
const meta = checker.reflectObjectLiteral(metaNode);
|
|
10523
10527
|
const providedIn = meta.has('providedIn')
|
|
10524
10528
|
? getProviderExpression(meta.get('providedIn'), reflector)
|
|
10525
|
-
:
|
|
10529
|
+
: compiler.createMayBeForwardRefExpression(new compiler.LiteralExpr(null), 0 /* ForwardRefHandling.None */);
|
|
10526
10530
|
let deps = undefined;
|
|
10527
10531
|
if ((meta.has('useClass') || meta.has('useFactory')) && meta.has('deps')) {
|
|
10528
10532
|
const depsExpr = meta.get('deps');
|
|
@@ -10543,7 +10547,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10543
10547
|
result.deps = deps;
|
|
10544
10548
|
}
|
|
10545
10549
|
else if (meta.has('useFactory')) {
|
|
10546
|
-
result.useFactory = new
|
|
10550
|
+
result.useFactory = new compiler.WrappedNodeExpr(meta.get('useFactory'));
|
|
10547
10551
|
result.deps = deps;
|
|
10548
10552
|
}
|
|
10549
10553
|
return result;
|
|
@@ -10561,7 +10565,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
10561
10565
|
*/
|
|
10562
10566
|
function getProviderExpression(expression, reflector) {
|
|
10563
10567
|
const forwardRefValue = checker.tryUnwrapForwardRef(expression, reflector);
|
|
10564
|
-
return
|
|
10568
|
+
return compiler.createMayBeForwardRefExpression(new compiler.WrappedNodeExpr(forwardRefValue ?? expression), forwardRefValue !== null ? 2 /* ForwardRefHandling.Unwrapped */ : 0 /* ForwardRefHandling.None */);
|
|
10565
10569
|
}
|
|
10566
10570
|
function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps) {
|
|
10567
10571
|
if (decorator.args === null) {
|
|
@@ -10606,7 +10610,7 @@ function requiresValidCtor(meta) {
|
|
|
10606
10610
|
}
|
|
10607
10611
|
function getDep(dep, reflector) {
|
|
10608
10612
|
const meta = {
|
|
10609
|
-
token: new
|
|
10613
|
+
token: new compiler.WrappedNodeExpr(dep),
|
|
10610
10614
|
attributeNameType: null,
|
|
10611
10615
|
host: false,
|
|
10612
10616
|
optional: false,
|
|
@@ -10621,7 +10625,7 @@ function getDep(dep, reflector) {
|
|
|
10621
10625
|
switch (source.name) {
|
|
10622
10626
|
case 'Inject':
|
|
10623
10627
|
if (token !== undefined) {
|
|
10624
|
-
meta.token = new
|
|
10628
|
+
meta.token = new compiler.WrappedNodeExpr(token);
|
|
10625
10629
|
}
|
|
10626
10630
|
break;
|
|
10627
10631
|
case 'Optional':
|
|
@@ -10649,7 +10653,7 @@ function getDep(dep, reflector) {
|
|
|
10649
10653
|
isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
|
|
10650
10654
|
}
|
|
10651
10655
|
if (!isDecorator) {
|
|
10652
|
-
meta.token = new
|
|
10656
|
+
meta.token = new compiler.WrappedNodeExpr(el);
|
|
10653
10657
|
}
|
|
10654
10658
|
});
|
|
10655
10659
|
}
|
|
@@ -10815,15 +10819,15 @@ class PipeDecoratorHandler {
|
|
|
10815
10819
|
return {};
|
|
10816
10820
|
}
|
|
10817
10821
|
compileFull(node, analysis) {
|
|
10818
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
10819
|
-
const def =
|
|
10822
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Pipe));
|
|
10823
|
+
const def = compiler.compilePipeFromMetadata(analysis.meta);
|
|
10820
10824
|
const classMetadata = analysis.classMetadata !== null
|
|
10821
10825
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
10822
10826
|
: null;
|
|
10823
10827
|
return checker.compileResults(fac, def, classMetadata, 'ɵpipe', null, null /* deferrableImports */);
|
|
10824
10828
|
}
|
|
10825
10829
|
compilePartial(node, analysis) {
|
|
10826
|
-
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta,
|
|
10830
|
+
const fac = compileDeclareFactory(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Pipe));
|
|
10827
10831
|
const def = compileDeclarePipeFromMetadata(analysis.meta);
|
|
10828
10832
|
const classMetadata = analysis.classMetadata !== null
|
|
10829
10833
|
? compileDeclareClassMetadata(analysis.classMetadata).toStmt()
|
|
@@ -10831,8 +10835,8 @@ class PipeDecoratorHandler {
|
|
|
10831
10835
|
return checker.compileResults(fac, def, classMetadata, 'ɵpipe', null, null /* deferrableImports */);
|
|
10832
10836
|
}
|
|
10833
10837
|
compileLocal(node, analysis) {
|
|
10834
|
-
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta,
|
|
10835
|
-
const def =
|
|
10838
|
+
const fac = compileNgFactoryDefField(checker.toFactoryMetadata(analysis.meta, compiler.FactoryTarget.Pipe));
|
|
10839
|
+
const def = compiler.compilePipeFromMetadata(analysis.meta);
|
|
10836
10840
|
const classMetadata = analysis.classMetadata !== null
|
|
10837
10841
|
? compileClassMetadata(analysis.classMetadata).toStmt()
|
|
10838
10842
|
: null;
|
|
@@ -10845,7 +10849,7 @@ class PipeDecoratorHandler {
|
|
|
10845
10849
|
* @description
|
|
10846
10850
|
* Entry point for all public APIs of the compiler-cli package.
|
|
10847
10851
|
*/
|
|
10848
|
-
new
|
|
10852
|
+
new compiler.Version('20.0.0-next.5');
|
|
10849
10853
|
|
|
10850
10854
|
/**
|
|
10851
10855
|
* Whether a given decorator should be treated as an Angular decorator.
|
|
@@ -11584,7 +11588,7 @@ function i18nSerialize(bundle, formatName, options) {
|
|
|
11584
11588
|
let serializer;
|
|
11585
11589
|
switch (format) {
|
|
11586
11590
|
case 'xmb':
|
|
11587
|
-
serializer = new
|
|
11591
|
+
serializer = new compiler.Xmb();
|
|
11588
11592
|
break;
|
|
11589
11593
|
case 'xliff2':
|
|
11590
11594
|
case 'xlf2':
|
|
@@ -13927,7 +13931,7 @@ class IndexingContext {
|
|
|
13927
13931
|
* Visiting `text {{prop}}` will return
|
|
13928
13932
|
* `[TopLevelIdentifier {name: 'prop', span: {start: 7, end: 11}}]`.
|
|
13929
13933
|
*/
|
|
13930
|
-
class ExpressionVisitor extends
|
|
13934
|
+
class ExpressionVisitor extends compiler.RecursiveAstVisitor {
|
|
13931
13935
|
expressionStr;
|
|
13932
13936
|
absoluteOffset;
|
|
13933
13937
|
boundTemplate;
|
|
@@ -13979,12 +13983,12 @@ class ExpressionVisitor extends checker.RecursiveAstVisitor {
|
|
|
13979
13983
|
// impossible to determine by an indexer and unsupported by the indexing module.
|
|
13980
13984
|
// The indexing module also does not currently support references to identifiers declared in the
|
|
13981
13985
|
// template itself, which have a non-null expression target.
|
|
13982
|
-
if (!(ast.receiver instanceof
|
|
13986
|
+
if (!(ast.receiver instanceof compiler.ImplicitReceiver)) {
|
|
13983
13987
|
return;
|
|
13984
13988
|
}
|
|
13985
13989
|
// The source span of the requested AST starts at a location that is offset from the expression.
|
|
13986
13990
|
let identifierStart = ast.sourceSpan.start - this.absoluteOffset;
|
|
13987
|
-
if (ast instanceof
|
|
13991
|
+
if (ast instanceof compiler.PropertyRead || ast instanceof compiler.PropertyWrite) {
|
|
13988
13992
|
// For `PropertyRead` and `PropertyWrite`, the identifier starts at the `nameSpan`, not
|
|
13989
13993
|
// necessarily the `sourceSpan`.
|
|
13990
13994
|
identifierStart = ast.nameSpan.start - this.absoluteOffset;
|
|
@@ -14012,7 +14016,7 @@ class ExpressionVisitor extends checker.RecursiveAstVisitor {
|
|
|
14012
14016
|
* Visits the AST of a parsed Angular template. Discovers and stores
|
|
14013
14017
|
* identifiers of interest, deferring to an `ExpressionVisitor` as needed.
|
|
14014
14018
|
*/
|
|
14015
|
-
let TemplateVisitor$1 = class TemplateVisitor extends
|
|
14019
|
+
let TemplateVisitor$1 = class TemplateVisitor extends compiler.RecursiveVisitor {
|
|
14016
14020
|
boundTemplate;
|
|
14017
14021
|
// Identifiers of interest found in the template.
|
|
14018
14022
|
identifiers = new Set();
|
|
@@ -14111,7 +14115,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14111
14115
|
this.visitAll(block.children);
|
|
14112
14116
|
}
|
|
14113
14117
|
visitDeferredTrigger(trigger) {
|
|
14114
|
-
if (trigger instanceof
|
|
14118
|
+
if (trigger instanceof compiler.BoundDeferredTrigger) {
|
|
14115
14119
|
this.visitExpression(trigger.value);
|
|
14116
14120
|
}
|
|
14117
14121
|
}
|
|
@@ -14156,7 +14160,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14156
14160
|
}
|
|
14157
14161
|
let name;
|
|
14158
14162
|
let kind;
|
|
14159
|
-
if (node instanceof
|
|
14163
|
+
if (node instanceof compiler.Template) {
|
|
14160
14164
|
name = node.tagName ?? 'ng-template';
|
|
14161
14165
|
kind = IdentifierKind.Template;
|
|
14162
14166
|
}
|
|
@@ -14218,7 +14222,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14218
14222
|
}
|
|
14219
14223
|
const span = new AbsoluteSourceSpan(start, start + name.length);
|
|
14220
14224
|
let identifier;
|
|
14221
|
-
if (node instanceof
|
|
14225
|
+
if (node instanceof compiler.Reference) {
|
|
14222
14226
|
// If the node is a reference, we care about its target. The target can be an element, a
|
|
14223
14227
|
// template, a directive applied on a template or element (in which case the directive field
|
|
14224
14228
|
// is non-null), or nothing at all.
|
|
@@ -14227,7 +14231,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14227
14231
|
if (refTarget) {
|
|
14228
14232
|
let node = null;
|
|
14229
14233
|
let directive = null;
|
|
14230
|
-
if (refTarget instanceof
|
|
14234
|
+
if (refTarget instanceof compiler.Element || refTarget instanceof compiler.Template) {
|
|
14231
14235
|
node = this.elementOrTemplateToIdentifier(refTarget);
|
|
14232
14236
|
}
|
|
14233
14237
|
else {
|
|
@@ -14249,7 +14253,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14249
14253
|
target,
|
|
14250
14254
|
};
|
|
14251
14255
|
}
|
|
14252
|
-
else if (node instanceof
|
|
14256
|
+
else if (node instanceof compiler.Variable) {
|
|
14253
14257
|
identifier = {
|
|
14254
14258
|
name,
|
|
14255
14259
|
span,
|
|
@@ -14283,7 +14287,7 @@ let TemplateVisitor$1 = class TemplateVisitor extends checker.RecursiveVisitor$1
|
|
|
14283
14287
|
*/
|
|
14284
14288
|
visitExpression(ast) {
|
|
14285
14289
|
// Only include ASTs that have information about their source and absolute source spans.
|
|
14286
|
-
if (ast instanceof
|
|
14290
|
+
if (ast instanceof compiler.ASTWithSource && ast.source !== null) {
|
|
14287
14291
|
// Make target to identifier mapping closure stateful to this visitor instance.
|
|
14288
14292
|
const targetToIdentifier = this.targetToIdentifier.bind(this);
|
|
14289
14293
|
const absoluteOffset = ast.sourceSpan.start;
|
|
@@ -14326,7 +14330,7 @@ function generateAnalysis(context) {
|
|
|
14326
14330
|
});
|
|
14327
14331
|
// Get source files for the component and the template. If the template is inline, its source
|
|
14328
14332
|
// file is the component's.
|
|
14329
|
-
const componentFile = new
|
|
14333
|
+
const componentFile = new compiler.ParseSourceFile(declaration.getSourceFile().getFullText(), declaration.getSourceFile().fileName);
|
|
14330
14334
|
let templateFile;
|
|
14331
14335
|
if (templateMeta.isInline) {
|
|
14332
14336
|
templateFile = componentFile;
|
|
@@ -14866,7 +14870,7 @@ class TemplateCheckWithVisitor {
|
|
|
14866
14870
|
/**
|
|
14867
14871
|
* Visits all nodes in a template (TmplAstNode and AST) and calls `visitNode` for each one.
|
|
14868
14872
|
*/
|
|
14869
|
-
class TemplateVisitor extends
|
|
14873
|
+
class TemplateVisitor extends compiler.RecursiveAstVisitor {
|
|
14870
14874
|
ctx;
|
|
14871
14875
|
component;
|
|
14872
14876
|
check;
|
|
@@ -14887,7 +14891,7 @@ class TemplateVisitor extends checker.RecursiveAstVisitor {
|
|
|
14887
14891
|
}
|
|
14888
14892
|
}
|
|
14889
14893
|
visitAst(ast) {
|
|
14890
|
-
if (ast instanceof
|
|
14894
|
+
if (ast instanceof compiler.ASTWithSource) {
|
|
14891
14895
|
ast = ast.ast;
|
|
14892
14896
|
}
|
|
14893
14897
|
this.visit(ast);
|
|
@@ -14943,7 +14947,7 @@ class TemplateVisitor extends checker.RecursiveAstVisitor {
|
|
|
14943
14947
|
deferred.visitAll(this);
|
|
14944
14948
|
}
|
|
14945
14949
|
visitDeferredTrigger(trigger) {
|
|
14946
|
-
if (trigger instanceof
|
|
14950
|
+
if (trigger instanceof compiler.BoundDeferredTrigger) {
|
|
14947
14951
|
this.visitAst(trigger.value);
|
|
14948
14952
|
}
|
|
14949
14953
|
}
|
|
@@ -15006,13 +15010,13 @@ class InterpolatedSignalCheck extends TemplateCheckWithVisitor {
|
|
|
15006
15010
|
code = checker.ErrorCode.INTERPOLATED_SIGNAL_NOT_INVOKED;
|
|
15007
15011
|
visitNode(ctx, component, node) {
|
|
15008
15012
|
// interpolations like `{{ mySignal }}`
|
|
15009
|
-
if (node instanceof
|
|
15013
|
+
if (node instanceof compiler.Interpolation) {
|
|
15010
15014
|
return node.expressions
|
|
15011
|
-
.filter((item) => item instanceof
|
|
15015
|
+
.filter((item) => item instanceof compiler.PropertyRead)
|
|
15012
15016
|
.flatMap((item) => buildDiagnosticForSignal(ctx, item, component));
|
|
15013
15017
|
}
|
|
15014
15018
|
// bound properties like `[prop]="mySignal"`
|
|
15015
|
-
else if (node instanceof
|
|
15019
|
+
else if (node instanceof compiler.BoundAttribute) {
|
|
15016
15020
|
// we skip the check if the node is an input binding
|
|
15017
15021
|
const usedDirectives = ctx.templateTypeChecker.getUsedDirectives(component);
|
|
15018
15022
|
if (usedDirectives !== null &&
|
|
@@ -15022,17 +15026,17 @@ class InterpolatedSignalCheck extends TemplateCheckWithVisitor {
|
|
|
15022
15026
|
// otherwise, we check if the node is
|
|
15023
15027
|
if (
|
|
15024
15028
|
// a bound property like `[prop]="mySignal"`
|
|
15025
|
-
(node.type ===
|
|
15029
|
+
(node.type === compiler.BindingType.Property ||
|
|
15026
15030
|
// or a class binding like `[class.myClass]="mySignal"`
|
|
15027
|
-
node.type ===
|
|
15031
|
+
node.type === compiler.BindingType.Class ||
|
|
15028
15032
|
// or a style binding like `[style.width]="mySignal"`
|
|
15029
|
-
node.type ===
|
|
15033
|
+
node.type === compiler.BindingType.Style ||
|
|
15030
15034
|
// or an attribute binding like `[attr.role]="mySignal"`
|
|
15031
|
-
node.type ===
|
|
15035
|
+
node.type === compiler.BindingType.Attribute ||
|
|
15032
15036
|
// or an animation binding like `[@myAnimation]="mySignal"`
|
|
15033
|
-
node.type ===
|
|
15034
|
-
node.value instanceof
|
|
15035
|
-
node.value.ast instanceof
|
|
15037
|
+
node.type === compiler.BindingType.Animation) &&
|
|
15038
|
+
node.value instanceof compiler.ASTWithSource &&
|
|
15039
|
+
node.value.ast instanceof compiler.PropertyRead) {
|
|
15036
15040
|
return buildDiagnosticForSignal(ctx, node.value.ast, component);
|
|
15037
15041
|
}
|
|
15038
15042
|
}
|
|
@@ -15085,7 +15089,7 @@ const factory$b = {
|
|
|
15085
15089
|
class InvalidBananaInBoxCheck extends TemplateCheckWithVisitor {
|
|
15086
15090
|
code = checker.ErrorCode.INVALID_BANANA_IN_BOX;
|
|
15087
15091
|
visitNode(ctx, component, node) {
|
|
15088
|
-
if (!(node instanceof
|
|
15092
|
+
if (!(node instanceof compiler.BoundEvent))
|
|
15089
15093
|
return [];
|
|
15090
15094
|
const name = node.name;
|
|
15091
15095
|
if (!name.startsWith('[') || !name.endsWith(']'))
|
|
@@ -15138,7 +15142,7 @@ class MissingControlFlowDirectiveCheck extends TemplateCheckWithVisitor {
|
|
|
15138
15142
|
return super.run(ctx, component, template);
|
|
15139
15143
|
}
|
|
15140
15144
|
visitNode(ctx, component, node) {
|
|
15141
|
-
if (!(node instanceof
|
|
15145
|
+
if (!(node instanceof compiler.Template))
|
|
15142
15146
|
return [];
|
|
15143
15147
|
const controlFlowAttr = node.templateAttrs.find((attr) => KNOWN_CONTROL_FLOW_DIRECTIVES.has(attr.name));
|
|
15144
15148
|
if (!controlFlowAttr)
|
|
@@ -15173,7 +15177,7 @@ const factory$9 = {
|
|
|
15173
15177
|
class MissingNgForOfLetCheck extends TemplateCheckWithVisitor {
|
|
15174
15178
|
code = checker.ErrorCode.MISSING_NGFOROF_LET;
|
|
15175
15179
|
visitNode(ctx, component, node) {
|
|
15176
|
-
if (!(node instanceof
|
|
15180
|
+
if (!(node instanceof compiler.Template)) {
|
|
15177
15181
|
return [];
|
|
15178
15182
|
}
|
|
15179
15183
|
if (node.templateAttrs.length === 0) {
|
|
@@ -15207,7 +15211,7 @@ class NullishCoalescingNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15207
15211
|
canVisitStructuralAttributes = false;
|
|
15208
15212
|
code = checker.ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
|
|
15209
15213
|
visitNode(ctx, component, node) {
|
|
15210
|
-
if (!(node instanceof
|
|
15214
|
+
if (!(node instanceof compiler.Binary) || node.operation !== '??')
|
|
15211
15215
|
return [];
|
|
15212
15216
|
const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.left, component);
|
|
15213
15217
|
if (symbolLeft === null || symbolLeft.kind !== checker.SymbolKind.Expression) {
|
|
@@ -15259,9 +15263,9 @@ class OptionalChainNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15259
15263
|
canVisitStructuralAttributes = false;
|
|
15260
15264
|
code = checker.ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
|
|
15261
15265
|
visitNode(ctx, component, node) {
|
|
15262
|
-
if (!(node instanceof
|
|
15263
|
-
!(node instanceof
|
|
15264
|
-
!(node instanceof
|
|
15266
|
+
if (!(node instanceof compiler.SafeCall) &&
|
|
15267
|
+
!(node instanceof compiler.SafePropertyRead) &&
|
|
15268
|
+
!(node instanceof compiler.SafeKeyedRead))
|
|
15265
15269
|
return [];
|
|
15266
15270
|
const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.receiver, component);
|
|
15267
15271
|
if (symbolLeft === null || symbolLeft.kind !== checker.SymbolKind.Expression) {
|
|
@@ -15286,7 +15290,7 @@ class OptionalChainNotNullableCheck extends TemplateCheckWithVisitor {
|
|
|
15286
15290
|
if (templateMapping === null) {
|
|
15287
15291
|
return [];
|
|
15288
15292
|
}
|
|
15289
|
-
const advice = node instanceof
|
|
15293
|
+
const advice = node instanceof compiler.SafePropertyRead
|
|
15290
15294
|
? `the '?.' operator can be replaced with the '.' operator`
|
|
15291
15295
|
: `the '?.' operator can be safely removed`;
|
|
15292
15296
|
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}.`);
|
|
@@ -15315,14 +15319,14 @@ class NgSkipHydrationSpec extends TemplateCheckWithVisitor {
|
|
|
15315
15319
|
code = checker.ErrorCode.SKIP_HYDRATION_NOT_STATIC;
|
|
15316
15320
|
visitNode(ctx, component, node) {
|
|
15317
15321
|
/** Binding should always error */
|
|
15318
|
-
if (node instanceof
|
|
15322
|
+
if (node instanceof compiler.BoundAttribute && node.name === NG_SKIP_HYDRATION_ATTR_NAME) {
|
|
15319
15323
|
const errorString = `ngSkipHydration should not be used as a binding.`;
|
|
15320
15324
|
const diagnostic = ctx.makeTemplateDiagnostic(node.sourceSpan, errorString);
|
|
15321
15325
|
return [diagnostic];
|
|
15322
15326
|
}
|
|
15323
15327
|
/** No value, empty string or `"true"` are the only valid values */
|
|
15324
15328
|
const acceptedValues = ['true', '' /* empty string */];
|
|
15325
|
-
if (node instanceof
|
|
15329
|
+
if (node instanceof compiler.TextAttribute &&
|
|
15326
15330
|
node.name === NG_SKIP_HYDRATION_ATTR_NAME &&
|
|
15327
15331
|
!acceptedValues.includes(node.value) &&
|
|
15328
15332
|
node.value !== undefined) {
|
|
@@ -15347,7 +15351,7 @@ const STYLE_SUFFIXES = ['px', '%', 'em'];
|
|
|
15347
15351
|
class SuffixNotSupportedCheck extends TemplateCheckWithVisitor {
|
|
15348
15352
|
code = checker.ErrorCode.SUFFIX_NOT_SUPPORTED;
|
|
15349
15353
|
visitNode(ctx, component, node) {
|
|
15350
|
-
if (!(node instanceof
|
|
15354
|
+
if (!(node instanceof compiler.BoundAttribute))
|
|
15351
15355
|
return [];
|
|
15352
15356
|
if (!node.keySpan.toString().startsWith('attr.') ||
|
|
15353
15357
|
!STYLE_SUFFIXES.some((suffix) => node.name.endsWith(`.${suffix}`))) {
|
|
@@ -15373,7 +15377,7 @@ const factory$4 = {
|
|
|
15373
15377
|
class TextAttributeNotBindingSpec extends TemplateCheckWithVisitor {
|
|
15374
15378
|
code = checker.ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING;
|
|
15375
15379
|
visitNode(ctx, component, node) {
|
|
15376
|
-
if (!(node instanceof
|
|
15380
|
+
if (!(node instanceof compiler.TextAttribute))
|
|
15377
15381
|
return [];
|
|
15378
15382
|
const name = node.name;
|
|
15379
15383
|
if (!name.startsWith('attr.') && !name.startsWith('style.') && !name.startsWith('class.')) {
|
|
@@ -15417,19 +15421,19 @@ class UninvokedFunctionInEventBindingSpec extends TemplateCheckWithVisitor {
|
|
|
15417
15421
|
code = checker.ErrorCode.UNINVOKED_FUNCTION_IN_EVENT_BINDING;
|
|
15418
15422
|
visitNode(ctx, component, node) {
|
|
15419
15423
|
// If the node is not a bound event, skip it.
|
|
15420
|
-
if (!(node instanceof
|
|
15424
|
+
if (!(node instanceof compiler.BoundEvent))
|
|
15421
15425
|
return [];
|
|
15422
15426
|
// If the node is not a regular or animation event, skip it.
|
|
15423
|
-
if (node.type !==
|
|
15427
|
+
if (node.type !== compiler.ParsedEventType.Regular && node.type !== compiler.ParsedEventType.Animation)
|
|
15424
15428
|
return [];
|
|
15425
|
-
if (!(node.handler instanceof
|
|
15429
|
+
if (!(node.handler instanceof compiler.ASTWithSource))
|
|
15426
15430
|
return [];
|
|
15427
15431
|
const sourceExpressionText = node.handler.source || '';
|
|
15428
|
-
if (node.handler.ast instanceof
|
|
15432
|
+
if (node.handler.ast instanceof compiler.Chain) {
|
|
15429
15433
|
// (click)="increment; decrement"
|
|
15430
15434
|
return node.handler.ast.expressions.flatMap((expression) => assertExpressionInvoked(expression, component, node, sourceExpressionText, ctx));
|
|
15431
15435
|
}
|
|
15432
|
-
if (node.handler.ast instanceof
|
|
15436
|
+
if (node.handler.ast instanceof compiler.Conditional) {
|
|
15433
15437
|
// (click)="true ? increment : decrement"
|
|
15434
15438
|
const { trueExp, falseExp } = node.handler.ast;
|
|
15435
15439
|
return [trueExp, falseExp].flatMap((expression) => assertExpressionInvoked(expression, component, node, sourceExpressionText, ctx));
|
|
@@ -15443,10 +15447,10 @@ class UninvokedFunctionInEventBindingSpec extends TemplateCheckWithVisitor {
|
|
|
15443
15447
|
* If the expression is a property read, and it has a call signature, a diagnostic is generated.
|
|
15444
15448
|
*/
|
|
15445
15449
|
function assertExpressionInvoked(expression, component, node, expressionText, ctx) {
|
|
15446
|
-
if (expression instanceof
|
|
15450
|
+
if (expression instanceof compiler.Call || expression instanceof compiler.SafeCall) {
|
|
15447
15451
|
return []; // If the method is called, skip it.
|
|
15448
15452
|
}
|
|
15449
|
-
if (!(expression instanceof
|
|
15453
|
+
if (!(expression instanceof compiler.PropertyRead) && !(expression instanceof compiler.SafePropertyRead)) {
|
|
15450
15454
|
return []; // If the expression is not a property read, skip it.
|
|
15451
15455
|
}
|
|
15452
15456
|
const symbol = ctx.templateTypeChecker.getSymbolOfNode(expression, component);
|
|
@@ -15475,10 +15479,10 @@ const factory$2 = {
|
|
|
15475
15479
|
class UnparenthesizedNullishCoalescing extends TemplateCheckWithVisitor {
|
|
15476
15480
|
code = checker.ErrorCode.UNPARENTHESIZED_NULLISH_COALESCING;
|
|
15477
15481
|
visitNode(ctx, component, node) {
|
|
15478
|
-
if (node instanceof
|
|
15482
|
+
if (node instanceof compiler.Binary) {
|
|
15479
15483
|
if (node.operation === '&&' || node.operation === '||') {
|
|
15480
|
-
if ((node.left instanceof
|
|
15481
|
-
(node.right instanceof
|
|
15484
|
+
if ((node.left instanceof compiler.Binary && node.left.operation === '??') ||
|
|
15485
|
+
(node.right instanceof compiler.Binary && node.right.operation === '??')) {
|
|
15482
15486
|
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
|
|
15483
15487
|
if (symbol?.kind !== checker.SymbolKind.Expression) {
|
|
15484
15488
|
return [];
|
|
@@ -15520,13 +15524,13 @@ class UnusedLetDeclarationCheck extends TemplateCheckWithVisitor {
|
|
|
15520
15524
|
return diagnostics;
|
|
15521
15525
|
}
|
|
15522
15526
|
visitNode(ctx, component, node) {
|
|
15523
|
-
if (node instanceof
|
|
15527
|
+
if (node instanceof compiler.LetDeclaration) {
|
|
15524
15528
|
this.getAnalysis(component).allLetDeclarations.add(node);
|
|
15525
15529
|
}
|
|
15526
|
-
else if (node instanceof
|
|
15527
|
-
const unwrappedNode = node instanceof
|
|
15530
|
+
else if (node instanceof compiler.AST) {
|
|
15531
|
+
const unwrappedNode = node instanceof compiler.ASTWithSource ? node.ast : node;
|
|
15528
15532
|
const target = ctx.templateTypeChecker.getExpressionTarget(unwrappedNode, component);
|
|
15529
|
-
if (target !== null && target instanceof
|
|
15533
|
+
if (target !== null && target instanceof compiler.LetDeclaration) {
|
|
15530
15534
|
this.getAnalysis(component).usedLetDeclarations.add(target);
|
|
15531
15535
|
}
|
|
15532
15536
|
}
|
|
@@ -15664,7 +15668,7 @@ class TemplateSemanticsCheckerImpl {
|
|
|
15664
15668
|
}
|
|
15665
15669
|
}
|
|
15666
15670
|
/** Visitor that verifies the semantics of a template. */
|
|
15667
|
-
class TemplateSemanticsVisitor extends
|
|
15671
|
+
class TemplateSemanticsVisitor extends compiler.RecursiveVisitor {
|
|
15668
15672
|
expressionVisitor;
|
|
15669
15673
|
constructor(expressionVisitor) {
|
|
15670
15674
|
super();
|
|
@@ -15683,7 +15687,7 @@ class TemplateSemanticsVisitor extends checker.RecursiveVisitor$1 {
|
|
|
15683
15687
|
}
|
|
15684
15688
|
}
|
|
15685
15689
|
/** Visitor that verifies the semantics of the expressions within a template. */
|
|
15686
|
-
class ExpressionsSemanticsVisitor extends
|
|
15690
|
+
class ExpressionsSemanticsVisitor extends compiler.RecursiveAstVisitor {
|
|
15687
15691
|
templateTypeChecker;
|
|
15688
15692
|
component;
|
|
15689
15693
|
diagnostics;
|
|
@@ -15702,26 +15706,26 @@ class ExpressionsSemanticsVisitor extends checker.RecursiveAstVisitor {
|
|
|
15702
15706
|
this.checkForIllegalWriteInTwoWayBinding(ast, context);
|
|
15703
15707
|
}
|
|
15704
15708
|
checkForIllegalWriteInEventBinding(ast, context) {
|
|
15705
|
-
if (!(context instanceof
|
|
15709
|
+
if (!(context instanceof compiler.BoundEvent) || !(ast.receiver instanceof compiler.ImplicitReceiver)) {
|
|
15706
15710
|
return;
|
|
15707
15711
|
}
|
|
15708
15712
|
const target = this.templateTypeChecker.getExpressionTarget(ast, this.component);
|
|
15709
|
-
if (target instanceof
|
|
15713
|
+
if (target instanceof compiler.Variable) {
|
|
15710
15714
|
const errorMessage = `Cannot use variable '${target.name}' as the left-hand side of an assignment expression. Template variables are read-only.`;
|
|
15711
15715
|
this.diagnostics.push(this.makeIllegalTemplateVarDiagnostic(target, context, errorMessage));
|
|
15712
15716
|
}
|
|
15713
15717
|
}
|
|
15714
15718
|
checkForIllegalWriteInTwoWayBinding(ast, context) {
|
|
15715
15719
|
// Only check top-level property reads inside two-way bindings for illegal assignments.
|
|
15716
|
-
if (!(context instanceof
|
|
15717
|
-
context.type !==
|
|
15718
|
-
!(ast.receiver instanceof
|
|
15720
|
+
if (!(context instanceof compiler.BoundEvent) ||
|
|
15721
|
+
context.type !== compiler.ParsedEventType.TwoWay ||
|
|
15722
|
+
!(ast.receiver instanceof compiler.ImplicitReceiver) ||
|
|
15719
15723
|
ast !== unwrapAstWithSource(context.handler)) {
|
|
15720
15724
|
return;
|
|
15721
15725
|
}
|
|
15722
15726
|
const target = this.templateTypeChecker.getExpressionTarget(ast, this.component);
|
|
15723
|
-
const isVariable = target instanceof
|
|
15724
|
-
const isLet = target instanceof
|
|
15727
|
+
const isVariable = target instanceof compiler.Variable;
|
|
15728
|
+
const isLet = target instanceof compiler.LetDeclaration;
|
|
15725
15729
|
if (!isVariable && !isLet) {
|
|
15726
15730
|
return;
|
|
15727
15731
|
}
|
|
@@ -15739,7 +15743,7 @@ class ExpressionsSemanticsVisitor extends checker.RecursiveAstVisitor {
|
|
|
15739
15743
|
}
|
|
15740
15744
|
}
|
|
15741
15745
|
makeIllegalTemplateVarDiagnostic(target, expressionNode, errorMessage) {
|
|
15742
|
-
const span = target instanceof
|
|
15746
|
+
const span = target instanceof compiler.Variable ? target.valueSpan || target.sourceSpan : target.sourceSpan;
|
|
15743
15747
|
return this.templateTypeChecker.makeTemplateDiagnostic(this.component, expressionNode.handlerSpan, ts.DiagnosticCategory.Error, checker.ngErrorCode(checker.ErrorCode.WRITE_TO_READ_ONLY_VARIABLE), errorMessage, [
|
|
15744
15748
|
{
|
|
15745
15749
|
text: `'${target.name}' is declared here.`,
|
|
@@ -15751,7 +15755,7 @@ class ExpressionsSemanticsVisitor extends checker.RecursiveAstVisitor {
|
|
|
15751
15755
|
}
|
|
15752
15756
|
}
|
|
15753
15757
|
function unwrapAstWithSource(ast) {
|
|
15754
|
-
return ast instanceof
|
|
15758
|
+
return ast instanceof compiler.ASTWithSource ? ast.ast : ast;
|
|
15755
15759
|
}
|
|
15756
15760
|
|
|
15757
15761
|
/*!
|
|
@@ -18713,7 +18717,7 @@ var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
|
|
|
18713
18717
|
* @param minVersion Minimum required version for the feature.
|
|
18714
18718
|
*/
|
|
18715
18719
|
function coreVersionSupportsFeature(coreVersion, minVersion) {
|
|
18716
|
-
// A version of `20.0.0-next.
|
|
18720
|
+
// A version of `20.0.0-next.5` usually means that core is at head so it supports
|
|
18717
18721
|
// all features. Use string interpolation prevent the placeholder from being replaced
|
|
18718
18722
|
// with the current version during build time.
|
|
18719
18723
|
if (coreVersion === `0.0.0-${'PLACEHOLDER'}`) {
|
|
@@ -19315,7 +19319,7 @@ class NgCompiler {
|
|
|
19315
19319
|
// back to version detection. Only Angular versions greater than 17.2 have the necessary symbols
|
|
19316
19320
|
// to type check signals in two-way bindings. We also allow version 0.0.0 in case somebody is
|
|
19317
19321
|
// using Angular at head.
|
|
19318
|
-
let allowSignalsInTwoWayBindings = coreHasSymbol(this.inputProgram,
|
|
19322
|
+
let allowSignalsInTwoWayBindings = coreHasSymbol(this.inputProgram, compiler.Identifiers.unwrapWritableSignal) ??
|
|
19319
19323
|
(this.angularCoreVersion === null ||
|
|
19320
19324
|
coreVersionSupportsFeature(this.angularCoreVersion, '>= 17.2.0'));
|
|
19321
19325
|
// First select a type-checking configuration, based on whether full template type-checking is
|
|
@@ -19535,8 +19539,7 @@ class NgCompiler {
|
|
|
19535
19539
|
// namespace" and the logic of `LogicalProjectStrategy` is required to generate correct
|
|
19536
19540
|
// imports which may cross these multiple directories. Otherwise, plain relative imports are
|
|
19537
19541
|
// sufficient.
|
|
19538
|
-
if (this.options.
|
|
19539
|
-
(this.options.rootDirs !== undefined && this.options.rootDirs.length > 0)) {
|
|
19542
|
+
if (this.options.rootDirs !== undefined && this.options.rootDirs.length > 0) {
|
|
19540
19543
|
// rootDirs logic is in effect - use the `LogicalProjectStrategy` for in-project relative
|
|
19541
19544
|
// imports.
|
|
19542
19545
|
localImportStrategy = new checker.LogicalProjectStrategy(reflector, new checker.LogicalFileSystem([...this.adapter.rootDirs], this.adapter));
|
|
@@ -20296,7 +20299,7 @@ class NgtscProgram {
|
|
|
20296
20299
|
return [];
|
|
20297
20300
|
}
|
|
20298
20301
|
emitXi18n() {
|
|
20299
|
-
const ctx = new MessageBundle(new
|
|
20302
|
+
const ctx = new MessageBundle(new compiler.HtmlParser(), [], {}, this.options.i18nOutLocale ?? null, this.options.i18nPreserveWhitespaceForLegacyExtraction);
|
|
20300
20303
|
this.compiler.xi18n(ctx);
|
|
20301
20304
|
i18nExtract(this.options.i18nOutFormat ?? null, this.options.i18nOutFile ?? null, this.host, this.options, ctx, checker.resolve);
|
|
20302
20305
|
}
|