@angular/core 21.0.0-next.9 → 21.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/_attribute-chunk.mjs +2 -14
- package/fesm2022/_attribute-chunk.mjs.map +1 -1
- package/fesm2022/_debug_node-chunk.mjs +15265 -28386
- package/fesm2022/_debug_node-chunk.mjs.map +1 -1
- package/fesm2022/_effect-chunk.mjs +322 -504
- package/fesm2022/_effect-chunk.mjs.map +1 -1
- package/fesm2022/_effect-chunk2.mjs +2200 -4068
- package/fesm2022/_effect-chunk2.mjs.map +1 -1
- package/fesm2022/_not_found-chunk.mjs +18 -35
- package/fesm2022/_not_found-chunk.mjs.map +1 -1
- package/fesm2022/_resource-chunk.mjs +312 -391
- package/fesm2022/_resource-chunk.mjs.map +1 -1
- package/fesm2022/_untracked-chunk.mjs +75 -96
- package/fesm2022/_untracked-chunk.mjs.map +1 -1
- package/fesm2022/_weak_ref-chunk.mjs +2 -4
- package/fesm2022/_weak_ref-chunk.mjs.map +1 -1
- package/fesm2022/core.mjs +2463 -4307
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives-di.mjs +9 -9
- package/fesm2022/primitives-di.mjs.map +1 -1
- package/fesm2022/primitives-event-dispatch.mjs +626 -1460
- package/fesm2022/primitives-event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives-signals.mjs +154 -188
- package/fesm2022/primitives-signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +204 -304
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +2303 -3162
- package/fesm2022/testing.mjs.map +1 -1
- package/package.json +8 -2
- package/resources/best-practices.md +56 -0
- package/schematics/bundles/add-bootstrap-context-to-server-main.cjs +7 -25
- package/schematics/bundles/application-config-core.cjs +8 -19
- package/schematics/bundles/{apply_import_manager-CoeTX_Ob.cjs → apply_import_manager-1Zs_gpB6.cjs} +4 -5
- package/schematics/bundles/bootstrap-options-migration.cjs +93 -132
- package/schematics/bundles/cleanup-unused-imports.cjs +9 -13
- package/schematics/bundles/common-to-standalone-migration.cjs +12 -16
- package/schematics/bundles/{compiler_host-emLDwK2U.cjs → compiler_host-DBwYMlTo.cjs} +10 -11
- package/schematics/bundles/control-flow-migration.cjs +29 -31
- package/schematics/bundles/{imports-DwPXlGFl.cjs → imports-DP72APSx.cjs} +1 -23
- package/schematics/bundles/{index-CLxYZ09c.cjs → index-B7I9sIUx.cjs} +36 -37
- package/schematics/bundles/inject-migration.cjs +9 -26
- package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
- package/schematics/bundles/{migrate_ts_type_references-CpM5FPGa.cjs → migrate_ts_type_references-UGIUl7En.cjs} +458 -24
- package/schematics/bundles/{ng_component_template-BRbBIAUX.cjs → ng_component_template-Dsuq1Lw7.cjs} +4 -5
- package/schematics/bundles/{ng_decorators-BI0uV7KI.cjs → ng_decorators-DSFlWYQY.cjs} +2 -2
- package/schematics/bundles/ngclass-to-class-migration.cjs +16 -19
- package/schematics/bundles/ngstyle-to-style-migration.cjs +15 -18
- package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
- package/schematics/bundles/output-migration.cjs +16 -19
- package/schematics/bundles/{parse_html-CPWfkfhR.cjs → parse_html-8VLCL37B.cjs} +5 -5
- package/schematics/bundles/{project_paths-C8H7KDJ3.cjs → project_paths-DvD50ouC.cjs} +14 -247
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +90 -0
- package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
- package/schematics/bundles/route-lazy-loading.cjs +9 -25
- package/schematics/bundles/router-current-navigation.cjs +6 -17
- package/schematics/bundles/router-last-successful-navigation.cjs +6 -17
- package/schematics/bundles/router-testing-module-migration.cjs +7 -18
- package/schematics/bundles/self-closing-tags-migration.cjs +14 -17
- package/schematics/bundles/signal-input-migration.cjs +23 -26
- package/schematics/bundles/signal-queries-migration.cjs +22 -25
- package/schematics/bundles/signals.cjs +10 -13
- package/schematics/bundles/standalone-migration.cjs +22 -56
- package/schematics/bundles/symbol-BObKoqes.cjs +1 -1
- package/types/_api-chunk.d.ts +1 -1
- package/types/_chrome_dev_tools_performance-chunk.d.ts +34 -28
- package/types/_discovery-chunk.d.ts +26 -15
- package/types/_effect-chunk.d.ts +1 -1
- package/types/_event_dispatcher-chunk.d.ts +1 -1
- package/types/_formatter-chunk.d.ts +1 -1
- package/types/_weak_ref-chunk.d.ts +1 -1
- package/types/core.d.ts +18 -88
- package/types/primitives-di.d.ts +1 -1
- package/types/primitives-event-dispatch.d.ts +1 -1
- package/types/primitives-signals.d.ts +1 -1
- package/types/rxjs-interop.d.ts +1 -1
- package/types/testing.d.ts +1 -1
- package/schematics/bundles/index-Dvqnp6JS.cjs +0 -22419
- package/schematics/bundles/project_tsconfig_paths-CiBzGSIa.cjs +0 -51591
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v21.0.0-
|
|
3
|
+
* @license Angular v21.0.0-rc.1
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
var ts = require('typescript');
|
|
10
|
-
require('
|
|
11
|
-
var
|
|
12
|
-
require('./index-Dvqnp6JS.cjs');
|
|
13
|
-
require('path');
|
|
10
|
+
require('@angular/compiler-cli');
|
|
11
|
+
var migrations = require('@angular/compiler-cli/private/migrations');
|
|
14
12
|
require('node:path');
|
|
15
|
-
var project_paths = require('./project_paths-
|
|
16
|
-
var ng_component_template = require('./ng_component_template-
|
|
17
|
-
var ng_decorators = require('./ng_decorators-
|
|
18
|
-
var apply_import_manager = require('./apply_import_manager-
|
|
19
|
-
var imports = require('./imports-
|
|
13
|
+
var project_paths = require('./project_paths-DvD50ouC.cjs');
|
|
14
|
+
var ng_component_template = require('./ng_component_template-Dsuq1Lw7.cjs');
|
|
15
|
+
var ng_decorators = require('./ng_decorators-DSFlWYQY.cjs');
|
|
16
|
+
var apply_import_manager = require('./apply_import_manager-1Zs_gpB6.cjs');
|
|
17
|
+
var imports = require('./imports-DP72APSx.cjs');
|
|
20
18
|
require('@angular-devkit/core');
|
|
21
19
|
require('node:path/posix');
|
|
22
|
-
require('fs');
|
|
23
|
-
require('module');
|
|
24
|
-
require('url');
|
|
25
20
|
require('@angular-devkit/schematics');
|
|
21
|
+
require('./project_tsconfig_paths-CDVxT6Ov.cjs');
|
|
26
22
|
require('./property_name-BBwFuqMe.cjs');
|
|
27
23
|
|
|
28
24
|
const commonModuleStr = 'CommonModule';
|
|
@@ -81,7 +77,7 @@ function migrateCommonModuleUsage(template, componentNode, typeChecker) {
|
|
|
81
77
|
};
|
|
82
78
|
}
|
|
83
79
|
function createCommonModuleImportsArrayRemoval(classNode, file, typeChecker, neededImports) {
|
|
84
|
-
const reflector = new
|
|
80
|
+
const reflector = new migrations.TypeScriptReflectionHost(typeChecker);
|
|
85
81
|
const decorators = reflector.getDecoratorsOfDeclaration(classNode);
|
|
86
82
|
if (!decorators) {
|
|
87
83
|
return null;
|
|
@@ -149,7 +145,7 @@ function analyzeTemplateContent(templateContent) {
|
|
|
149
145
|
}
|
|
150
146
|
function hasCommonModuleInImports(componentNode, typeChecker) {
|
|
151
147
|
// First check if there's a CommonModule in the imports array
|
|
152
|
-
const reflector = new
|
|
148
|
+
const reflector = new migrations.TypeScriptReflectionHost(typeChecker);
|
|
153
149
|
const decorators = reflector.getDecoratorsOfDeclaration(componentNode);
|
|
154
150
|
if (!decorators) {
|
|
155
151
|
return false;
|
|
@@ -193,7 +189,7 @@ function processResolvedTemplate(template, componentNode, info, typeChecker, rep
|
|
|
193
189
|
if (replacement) {
|
|
194
190
|
replacements.push(replacement);
|
|
195
191
|
}
|
|
196
|
-
const importManager = new
|
|
192
|
+
const importManager = new migrations.ImportManager({
|
|
197
193
|
shouldUseSingleQuotes: () => true,
|
|
198
194
|
});
|
|
199
195
|
// Always remove 'CommonModule' regardless of whether it's aliased or not
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v21.0.0-
|
|
3
|
+
* @license Angular v21.0.0-rc.1
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
var ts = require('typescript');
|
|
10
|
-
var
|
|
11
|
-
require('
|
|
12
|
-
var p = require('path');
|
|
10
|
+
var migrations = require('@angular/compiler-cli/private/migrations');
|
|
11
|
+
var path = require('path');
|
|
13
12
|
|
|
14
13
|
function _interopNamespaceDefault(e) {
|
|
15
14
|
var n = Object.create(null);
|
|
@@ -28,7 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
28
27
|
return Object.freeze(n);
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
var
|
|
30
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
32
31
|
|
|
33
32
|
/** Tracks changes that have to be made for specific files. */
|
|
34
33
|
class ChangeTracker {
|
|
@@ -40,7 +39,7 @@ class ChangeTracker {
|
|
|
40
39
|
constructor(_printer, _importRemapper) {
|
|
41
40
|
this._printer = _printer;
|
|
42
41
|
this._importRemapper = _importRemapper;
|
|
43
|
-
this._importManager = new
|
|
42
|
+
this._importManager = new migrations.ImportManager({
|
|
44
43
|
shouldUseSingleQuotes: (file) => this._getQuoteKind(file) === 0 /* QuoteKind.SINGLE */,
|
|
45
44
|
});
|
|
46
45
|
}
|
|
@@ -227,7 +226,7 @@ function parseTsconfigFile(tsconfigPath, basePath) {
|
|
|
227
226
|
// Throw if incorrect arguments are passed to this function. Passing relative base paths
|
|
228
227
|
// results in root directories not being resolved and in later type checking runtime errors.
|
|
229
228
|
// More details can be found here: https://github.com/microsoft/TypeScript/issues/37731.
|
|
230
|
-
if (!
|
|
229
|
+
if (!path__namespace.isAbsolute(basePath)) {
|
|
231
230
|
throw Error('Unexpected relative base path has been specified.');
|
|
232
231
|
}
|
|
233
232
|
return ts.parseJsonConfigFileContent(config, parseConfigHost, basePath, {});
|
|
@@ -261,8 +260,8 @@ function createProgramOptions(tree, tsconfigPath, basePath, fakeFileRead, additi
|
|
|
261
260
|
// Resolve the tsconfig path to an absolute path. This is needed as TypeScript otherwise
|
|
262
261
|
// is not able to resolve root directories in the given tsconfig. More details can be found
|
|
263
262
|
// in the following issue: https://github.com/microsoft/TypeScript/issues/37731.
|
|
264
|
-
tsconfigPath =
|
|
265
|
-
const parsed = parseTsconfigFile(tsconfigPath,
|
|
263
|
+
tsconfigPath = path.resolve(basePath, tsconfigPath);
|
|
264
|
+
const parsed = parseTsconfigFile(tsconfigPath, path.dirname(tsconfigPath));
|
|
266
265
|
const options = optionOverrides ? { ...parsed.options, ...optionOverrides } : parsed.options;
|
|
267
266
|
const host = createMigrationCompilerHost(tree, options, basePath, fakeFileRead);
|
|
268
267
|
return { rootNames: parsed.fileNames.concat([]), options, host };
|
|
@@ -275,7 +274,7 @@ function createMigrationCompilerHost(tree, options, basePath, fakeRead) {
|
|
|
275
274
|
// if we run multiple migrations we might have intersecting changes and
|
|
276
275
|
// source files.
|
|
277
276
|
host.readFile = (fileName) => {
|
|
278
|
-
const treeRelativePath =
|
|
277
|
+
const treeRelativePath = path.relative(basePath, fileName);
|
|
279
278
|
let result = fakeRead?.(treeRelativePath);
|
|
280
279
|
if (typeof result !== 'string') {
|
|
281
280
|
// If the relative path resolved to somewhere outside of the tree, fall back to
|
|
@@ -309,7 +308,7 @@ function canMigrateFile(basePath, sourceFile, program) {
|
|
|
309
308
|
// project. We can't migrate files outside of the project, because our file system interactions
|
|
310
309
|
// go through the CLI's `Tree` which assumes that all files are within the project. See:
|
|
311
310
|
// https://github.com/angular/angular-cli/blob/0b0961c9c233a825b6e4bb59ab7f0790f9b14676/packages/angular_devkit/schematics/src/tree/host-tree.ts#L131
|
|
312
|
-
return !
|
|
311
|
+
return !path.relative(basePath, sourceFile.fileName).startsWith('..');
|
|
313
312
|
}
|
|
314
313
|
|
|
315
314
|
exports.ChangeTracker = ChangeTracker;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v21.0.0-
|
|
3
|
+
* @license Angular v21.0.0-rc.1
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
var schematics = require('@angular-devkit/schematics');
|
|
10
|
-
var
|
|
11
|
-
var compiler_host = require('./compiler_host-
|
|
12
|
-
var
|
|
10
|
+
var path = require('path');
|
|
11
|
+
var compiler_host = require('./compiler_host-DBwYMlTo.cjs');
|
|
12
|
+
var compiler = require('@angular/compiler');
|
|
13
13
|
var ts = require('typescript');
|
|
14
|
-
var parse_html = require('./parse_html-
|
|
15
|
-
require('
|
|
16
|
-
require('
|
|
17
|
-
require('module');
|
|
18
|
-
require('url');
|
|
14
|
+
var parse_html = require('./parse_html-8VLCL37B.cjs');
|
|
15
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.cjs');
|
|
16
|
+
require('@angular/compiler-cli/private/migrations');
|
|
19
17
|
require('@angular-devkit/core');
|
|
20
18
|
|
|
21
19
|
function lookupIdentifiersInSourceFile(sourceFile, names) {
|
|
@@ -275,7 +273,7 @@ class AnalyzedFile {
|
|
|
275
273
|
}
|
|
276
274
|
}
|
|
277
275
|
/** Finds all non-control flow elements from common module. */
|
|
278
|
-
class CommonCollector extends
|
|
276
|
+
class CommonCollector extends compiler.RecursiveVisitor {
|
|
279
277
|
count = 0;
|
|
280
278
|
visitElement(el) {
|
|
281
279
|
if (el.attrs.length > 0) {
|
|
@@ -314,7 +312,7 @@ class CommonCollector extends project_tsconfig_paths.RecursiveVisitor$1 {
|
|
|
314
312
|
}
|
|
315
313
|
}
|
|
316
314
|
/** Finds all elements that represent i18n blocks. */
|
|
317
|
-
class i18nCollector extends
|
|
315
|
+
class i18nCollector extends compiler.RecursiveVisitor {
|
|
318
316
|
elements = [];
|
|
319
317
|
visitElement(el) {
|
|
320
318
|
if (el.attrs.find((a) => a.name === 'i18n') !== undefined) {
|
|
@@ -324,7 +322,7 @@ class i18nCollector extends project_tsconfig_paths.RecursiveVisitor$1 {
|
|
|
324
322
|
}
|
|
325
323
|
}
|
|
326
324
|
/** Finds all elements with ngif structural directives. */
|
|
327
|
-
class ElementCollector extends
|
|
325
|
+
class ElementCollector extends compiler.RecursiveVisitor {
|
|
328
326
|
_attributes;
|
|
329
327
|
elements = [];
|
|
330
328
|
constructor(_attributes = []) {
|
|
@@ -377,7 +375,7 @@ class ElementCollector extends project_tsconfig_paths.RecursiveVisitor$1 {
|
|
|
377
375
|
}
|
|
378
376
|
}
|
|
379
377
|
/** Finds all elements with ngif structural directives. */
|
|
380
|
-
class TemplateCollector extends
|
|
378
|
+
class TemplateCollector extends compiler.RecursiveVisitor {
|
|
381
379
|
elements = [];
|
|
382
380
|
templates = new Map();
|
|
383
381
|
visitElement(el) {
|
|
@@ -550,8 +548,8 @@ function analyzeDecorators(node, sourceFile, analyzedFiles) {
|
|
|
550
548
|
case 'templateUrl':
|
|
551
549
|
// Leave the end as undefined which means that the range is until the end of the file.
|
|
552
550
|
if (ts.isStringLiteralLike(prop.initializer)) {
|
|
553
|
-
const path =
|
|
554
|
-
AnalyzedFile.addRange(path, sourceFile, analyzedFiles, {
|
|
551
|
+
const path$1 = path.join(path.dirname(sourceFile.fileName), prop.initializer.text);
|
|
552
|
+
AnalyzedFile.addRange(path$1, sourceFile, analyzedFiles, {
|
|
555
553
|
start: 0,
|
|
556
554
|
node: prop,
|
|
557
555
|
type: 'templateUrl',
|
|
@@ -601,7 +599,7 @@ function validateMigratedTemplate(migrated, fileName) {
|
|
|
601
599
|
}
|
|
602
600
|
function validateI18nStructure(parsed, fileName) {
|
|
603
601
|
const visitor = new i18nCollector();
|
|
604
|
-
|
|
602
|
+
compiler.visitAll(visitor, parsed.rootNodes);
|
|
605
603
|
const parents = visitor.elements.filter((el) => el.children.length > 0);
|
|
606
604
|
for (const p of parents) {
|
|
607
605
|
for (const el of visitor.elements) {
|
|
@@ -681,7 +679,7 @@ function getTemplates(template) {
|
|
|
681
679
|
const parsed = parse_html.parseTemplate(template);
|
|
682
680
|
if (parsed.tree !== undefined) {
|
|
683
681
|
const visitor = new TemplateCollector();
|
|
684
|
-
|
|
682
|
+
compiler.visitAll(visitor, parsed.tree.rootNodes);
|
|
685
683
|
for (let [key, tmpl] of visitor.templates) {
|
|
686
684
|
tmpl.count = countTemplateUsage(parsed.tree.rootNodes, key);
|
|
687
685
|
tmpl.generateContents(template);
|
|
@@ -785,7 +783,7 @@ function analyzeTemplateUsage(nodes, templateName) {
|
|
|
785
783
|
if (node.attrs) {
|
|
786
784
|
for (const attr of node.attrs) {
|
|
787
785
|
if ((attr.name === '*ngTemplateOutlet' || attr.name === '[ngTemplateOutlet]') &&
|
|
788
|
-
attr.value === templateName) {
|
|
786
|
+
attr.value?.split(';')[0]?.trim() === templateName) {
|
|
789
787
|
isReferencedInTemplateOutlet = true;
|
|
790
788
|
}
|
|
791
789
|
if (attr.name.trim() === templateNameWithHash) {
|
|
@@ -888,7 +886,7 @@ function canRemoveCommonModule(template) {
|
|
|
888
886
|
let removeCommonModule = false;
|
|
889
887
|
if (parsed.tree !== undefined) {
|
|
890
888
|
const visitor = new CommonCollector();
|
|
891
|
-
|
|
889
|
+
compiler.visitAll(visitor, parsed.tree.rootNodes);
|
|
892
890
|
removeCommonModule = visitor.count === 0;
|
|
893
891
|
}
|
|
894
892
|
return removeCommonModule;
|
|
@@ -1011,7 +1009,7 @@ function generateI18nMarkers(tmpl) {
|
|
|
1011
1009
|
let parsed = parse_html.parseTemplate(tmpl);
|
|
1012
1010
|
if (parsed.tree !== undefined) {
|
|
1013
1011
|
const visitor = new i18nCollector();
|
|
1014
|
-
|
|
1012
|
+
compiler.visitAll(visitor, parsed.tree.rootNodes);
|
|
1015
1013
|
for (const [ix, el] of visitor.elements.entries()) {
|
|
1016
1014
|
// we only care about elements with children and i18n tags
|
|
1017
1015
|
// elements without children have nothing to translate
|
|
@@ -1213,7 +1211,7 @@ function migrateCase(template) {
|
|
|
1213
1211
|
}
|
|
1214
1212
|
let result = template;
|
|
1215
1213
|
const visitor = new ElementCollector(cases);
|
|
1216
|
-
|
|
1214
|
+
compiler.visitAll(visitor, parsed.tree.rootNodes);
|
|
1217
1215
|
calculateNesting(visitor, hasLineBreaks(template));
|
|
1218
1216
|
// this tracks the character shift from different lengths of blocks from
|
|
1219
1217
|
// the prior directives so as to adjust for nested block replacement during
|
|
@@ -1310,7 +1308,7 @@ function migrateFor(template) {
|
|
|
1310
1308
|
}
|
|
1311
1309
|
let result = template;
|
|
1312
1310
|
const visitor = new ElementCollector(fors);
|
|
1313
|
-
|
|
1311
|
+
compiler.visitAll(visitor, parsed.tree.rootNodes);
|
|
1314
1312
|
calculateNesting(visitor, hasLineBreaks(template));
|
|
1315
1313
|
// this tracks the character shift from different lengths of blocks from
|
|
1316
1314
|
// the prior directives so as to adjust for nested block replacement during
|
|
@@ -1515,7 +1513,7 @@ function migrateIf(template) {
|
|
|
1515
1513
|
}
|
|
1516
1514
|
let result = template;
|
|
1517
1515
|
const visitor = new ElementCollector(ifs);
|
|
1518
|
-
|
|
1516
|
+
compiler.visitAll(visitor, parsed.tree.rootNodes);
|
|
1519
1517
|
calculateNesting(visitor, hasLineBreaks(template));
|
|
1520
1518
|
// this tracks the character shift from different lengths of blocks from
|
|
1521
1519
|
// the prior directives so as to adjust for nested block replacement during
|
|
@@ -1708,7 +1706,7 @@ function migrateSwitch(template) {
|
|
|
1708
1706
|
}
|
|
1709
1707
|
let result = template;
|
|
1710
1708
|
const visitor = new ElementCollector(switches);
|
|
1711
|
-
|
|
1709
|
+
compiler.visitAll(visitor, parsed.tree.rootNodes);
|
|
1712
1710
|
calculateNesting(visitor, hasLineBreaks(template));
|
|
1713
1711
|
// this tracks the character shift from different lengths of blocks from
|
|
1714
1712
|
// the prior directives so as to adjust for nested block replacement during
|
|
@@ -1739,11 +1737,11 @@ function migrateSwitch(template) {
|
|
|
1739
1737
|
}
|
|
1740
1738
|
function assertValidSwitchStructure(children) {
|
|
1741
1739
|
for (const child of children) {
|
|
1742
|
-
if (child instanceof
|
|
1740
|
+
if (child instanceof compiler.Text && child.value.trim() !== '') {
|
|
1743
1741
|
throw new Error(`Text node: "${child.value}" would result in invalid migrated @switch block structure. ` +
|
|
1744
1742
|
`@switch can only have @case or @default as children.`);
|
|
1745
1743
|
}
|
|
1746
|
-
else if (child instanceof
|
|
1744
|
+
else if (child instanceof compiler.Element) {
|
|
1747
1745
|
let hasCase = false;
|
|
1748
1746
|
for (const attr of child.attrs) {
|
|
1749
1747
|
if (cases.includes(attr.name)) {
|
|
@@ -1850,7 +1848,7 @@ function migrate(options) {
|
|
|
1850
1848
|
if (options.path.startsWith('..')) {
|
|
1851
1849
|
throw new schematics.SchematicsException('Cannot run control flow migration outside of the current project.');
|
|
1852
1850
|
}
|
|
1853
|
-
pathToMigrate = compiler_host.normalizePath(
|
|
1851
|
+
pathToMigrate = compiler_host.normalizePath(path.join(basePath, options.path));
|
|
1854
1852
|
if (pathToMigrate.trim() !== '') {
|
|
1855
1853
|
allPaths.push(pathToMigrate);
|
|
1856
1854
|
}
|
|
@@ -1893,10 +1891,10 @@ function runControlFlowMigration(tree, sourceFiles, basePath, schematicOptions)
|
|
|
1893
1891
|
// sort files with .html files first
|
|
1894
1892
|
// this ensures class files know if it's safe to remove CommonModule
|
|
1895
1893
|
const paths = sortFilePaths([...analysis.keys()]);
|
|
1896
|
-
for (const path of paths) {
|
|
1897
|
-
const file = analysis.get(path);
|
|
1894
|
+
for (const path$1 of paths) {
|
|
1895
|
+
const file = analysis.get(path$1);
|
|
1898
1896
|
const ranges = file.getSortedRanges();
|
|
1899
|
-
const relativePath =
|
|
1897
|
+
const relativePath = path.relative(basePath, path$1);
|
|
1900
1898
|
const content = tree.readText(relativePath);
|
|
1901
1899
|
const update = tree.beginUpdate(relativePath);
|
|
1902
1900
|
for (const { start, end, node, type } of ranges) {
|
|
@@ -1908,7 +1906,7 @@ function runControlFlowMigration(tree, sourceFiles, basePath, schematicOptions)
|
|
|
1908
1906
|
update.insertLeft(start, migrated);
|
|
1909
1907
|
}
|
|
1910
1908
|
if (errors.length > 0) {
|
|
1911
|
-
migrateErrors.set(path, errors);
|
|
1909
|
+
migrateErrors.set(path$1, errors);
|
|
1912
1910
|
}
|
|
1913
1911
|
}
|
|
1914
1912
|
tree.commitUpdate(update);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v21.0.0-
|
|
3
|
+
* @license Angular v21.0.0-rc.1
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -103,30 +103,8 @@ function findImportSpecifier(nodes, specifierName) {
|
|
|
103
103
|
return propertyName ? propertyName.text === specifierName : name.text === specifierName;
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Gets the relative path between two files.
|
|
108
|
-
* @param from Path of the file that is importing from another file.
|
|
109
|
-
* @param to Path of the file that is being imported.
|
|
110
|
-
*/
|
|
111
|
-
function getRelativePath(from, to) {
|
|
112
|
-
const fromParts = from.split('/').slice(0, -1);
|
|
113
|
-
const toParts = to.split('/');
|
|
114
|
-
while (fromParts.length > 0 && toParts.length > 0 && fromParts[0] === toParts[0]) {
|
|
115
|
-
fromParts.shift();
|
|
116
|
-
toParts.shift();
|
|
117
|
-
}
|
|
118
|
-
let relativePath = fromParts.map(() => '..').join('/') + (fromParts.length > 0 ? '/' : '') + toParts.join('/');
|
|
119
|
-
if (relativePath.endsWith('.ts')) {
|
|
120
|
-
relativePath = relativePath.slice(0, -3);
|
|
121
|
-
}
|
|
122
|
-
if (!relativePath.startsWith('.')) {
|
|
123
|
-
relativePath = './' + relativePath;
|
|
124
|
-
}
|
|
125
|
-
return relativePath;
|
|
126
|
-
}
|
|
127
106
|
|
|
128
107
|
exports.getImportOfIdentifier = getImportOfIdentifier;
|
|
129
108
|
exports.getImportSpecifier = getImportSpecifier;
|
|
130
109
|
exports.getImportSpecifiers = getImportSpecifiers;
|
|
131
110
|
exports.getNamedImports = getNamedImports;
|
|
132
|
-
exports.getRelativePath = getRelativePath;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v21.0.0-
|
|
3
|
+
* @license Angular v21.0.0-rc.1
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
var ts = require('typescript');
|
|
10
|
-
require('
|
|
11
|
-
var
|
|
12
|
-
var index = require('./index-Dvqnp6JS.cjs');
|
|
13
|
-
require('path');
|
|
10
|
+
var compilerCli = require('@angular/compiler-cli');
|
|
11
|
+
var migrations = require('@angular/compiler-cli/private/migrations');
|
|
14
12
|
require('node:path');
|
|
15
|
-
var project_paths = require('./project_paths-
|
|
13
|
+
var project_paths = require('./project_paths-DvD50ouC.cjs');
|
|
14
|
+
var compiler = require('@angular/compiler');
|
|
16
15
|
|
|
17
16
|
function getMemberName(member) {
|
|
18
17
|
if (member.name === undefined) {
|
|
@@ -189,7 +188,7 @@ function lookupPropertyAccess(checker, type, path, options = {}) {
|
|
|
189
188
|
* This resolution is important to be able to migrate references to inputs
|
|
190
189
|
* that will be migrated to signal inputs.
|
|
191
190
|
*/
|
|
192
|
-
class TemplateReferenceVisitor extends
|
|
191
|
+
class TemplateReferenceVisitor extends compiler.TmplAstRecursiveVisitor {
|
|
193
192
|
result = [];
|
|
194
193
|
/**
|
|
195
194
|
* Whether we are currently descending into HTML AST nodes
|
|
@@ -236,21 +235,21 @@ class TemplateReferenceVisitor extends project_tsconfig_paths.RecursiveVisitor {
|
|
|
236
235
|
// of signal calls in templates.
|
|
237
236
|
// TODO: Remove with: https://github.com/angular/angular/pull/55456.
|
|
238
237
|
this.templateAttributeReferencedFields = [];
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
compiler.tmplAstVisitAll(this, template.attributes);
|
|
239
|
+
compiler.tmplAstVisitAll(this, template.templateAttrs);
|
|
241
240
|
// If we are dealing with a microsyntax template, do not check
|
|
242
241
|
// inputs and outputs as those are already passed to the children.
|
|
243
242
|
// Template attributes may contain relevant expressions though.
|
|
244
243
|
if (template.tagName === 'ng-template') {
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
compiler.tmplAstVisitAll(this, template.inputs);
|
|
245
|
+
compiler.tmplAstVisitAll(this, template.outputs);
|
|
247
246
|
}
|
|
248
247
|
const referencedInputs = this.templateAttributeReferencedFields;
|
|
249
248
|
this.templateAttributeReferencedFields = null;
|
|
250
249
|
this.descendAndCheckForNarrowedSimilarReferences(referencedInputs, () => {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
250
|
+
compiler.tmplAstVisitAll(this, template.children);
|
|
251
|
+
compiler.tmplAstVisitAll(this, template.references);
|
|
252
|
+
compiler.tmplAstVisitAll(this, template.variables);
|
|
254
253
|
});
|
|
255
254
|
}
|
|
256
255
|
visitIfBlockBranch(block) {
|
|
@@ -317,7 +316,7 @@ class TemplateReferenceVisitor extends project_tsconfig_paths.RecursiveVisitor {
|
|
|
317
316
|
* This resolution is important to be able to migrate references to inputs
|
|
318
317
|
* that will be migrated to signal inputs.
|
|
319
318
|
*/
|
|
320
|
-
class TemplateExpressionReferenceVisitor extends
|
|
319
|
+
class TemplateExpressionReferenceVisitor extends compiler.RecursiveAstVisitor {
|
|
321
320
|
typeChecker;
|
|
322
321
|
templateTypeChecker;
|
|
323
322
|
componentClass;
|
|
@@ -364,7 +363,7 @@ class TemplateExpressionReferenceVisitor extends project_tsconfig_paths.Recursiv
|
|
|
364
363
|
super.visitPropertyRead(ast, context);
|
|
365
364
|
}
|
|
366
365
|
visitBinary(ast, context) {
|
|
367
|
-
if (ast.operation === '=' && ast.left instanceof
|
|
366
|
+
if (ast.operation === '=' && ast.left instanceof compiler.PropertyRead) {
|
|
368
367
|
this._inspectPropertyAccess(ast.left, true, [...context, ast, ast.left]);
|
|
369
368
|
}
|
|
370
369
|
else {
|
|
@@ -402,7 +401,7 @@ class TemplateExpressionReferenceVisitor extends project_tsconfig_paths.Recursiv
|
|
|
402
401
|
return false;
|
|
403
402
|
}
|
|
404
403
|
const symbol = this.templateTypeChecker.getSymbolOfNode(ast, this.componentClass);
|
|
405
|
-
if (symbol?.kind !==
|
|
404
|
+
if (symbol?.kind !== migrations.SymbolKind.Expression || symbol.tsSymbol === null) {
|
|
406
405
|
return false;
|
|
407
406
|
}
|
|
408
407
|
// Dangerous: Type checking symbol retrieval is a totally different `ts.Program`,
|
|
@@ -464,7 +463,7 @@ class TemplateExpressionReferenceVisitor extends project_tsconfig_paths.Recursiv
|
|
|
464
463
|
_isPartOfNarrowingTernary(read) {
|
|
465
464
|
// Note: We do not safe check that the reads are fully matching 1:1. This is acceptable
|
|
466
465
|
// as worst case we just skip an input from being migrated. This is very unlikely too.
|
|
467
|
-
return this.insideConditionalExpressionsWithReads.some((r) => (r instanceof
|
|
466
|
+
return this.insideConditionalExpressionsWithReads.some((r) => (r instanceof compiler.PropertyRead || r instanceof compiler.SafePropertyRead) && r.name === read.name);
|
|
468
467
|
}
|
|
469
468
|
}
|
|
470
469
|
/**
|
|
@@ -474,11 +473,11 @@ class TemplateExpressionReferenceVisitor extends project_tsconfig_paths.Recursiv
|
|
|
474
473
|
function traverseReceiverAndLookupSymbol(readOrWrite, componentClass, checker) {
|
|
475
474
|
const path = [readOrWrite.name];
|
|
476
475
|
let node = readOrWrite;
|
|
477
|
-
while (node.receiver instanceof
|
|
476
|
+
while (node.receiver instanceof compiler.PropertyRead) {
|
|
478
477
|
node = node.receiver;
|
|
479
478
|
path.unshift(node.name);
|
|
480
479
|
}
|
|
481
|
-
if (!(node.receiver instanceof
|
|
480
|
+
if (!(node.receiver instanceof compiler.ImplicitReceiver || node.receiver instanceof compiler.ThisReceiver)) {
|
|
482
481
|
return null;
|
|
483
482
|
}
|
|
484
483
|
const classType = checker.getTypeAtLocation(componentClass.name);
|
|
@@ -490,8 +489,8 @@ function traverseReceiverAndLookupSymbol(readOrWrite, componentClass, checker) {
|
|
|
490
489
|
}
|
|
491
490
|
/** Whether the given node refers to a two-way binding AST node. */
|
|
492
491
|
function isTwoWayBindingNode(node) {
|
|
493
|
-
return ((node instanceof
|
|
494
|
-
(node instanceof
|
|
492
|
+
return ((node instanceof compiler.TmplAstBoundAttribute && node.type === compiler.BindingType.TwoWay) ||
|
|
493
|
+
(node instanceof compiler.TmplAstBoundEvent && node.type === compiler.ParsedEventType.TwoWay));
|
|
495
494
|
}
|
|
496
495
|
|
|
497
496
|
/** Possible types of references to known fields detected. */
|
|
@@ -534,7 +533,7 @@ function identifyHostBindingReferences(node, programInfo, checker, reflector, re
|
|
|
534
533
|
if (decorators === null) {
|
|
535
534
|
return;
|
|
536
535
|
}
|
|
537
|
-
const angularDecorators =
|
|
536
|
+
const angularDecorators = migrations.getAngularDecorators(decorators, ['Directive', 'Component'],
|
|
538
537
|
/* isAngularCore */ false);
|
|
539
538
|
if (angularDecorators.length === 0) {
|
|
540
539
|
return;
|
|
@@ -544,15 +543,15 @@ function identifyHostBindingReferences(node, programInfo, checker, reflector, re
|
|
|
544
543
|
if (ngDecorator.args?.length !== 1) {
|
|
545
544
|
return;
|
|
546
545
|
}
|
|
547
|
-
const metadataNode =
|
|
546
|
+
const metadataNode = migrations.unwrapExpression(ngDecorator.args[0]);
|
|
548
547
|
if (!ts.isObjectLiteralExpression(metadataNode)) {
|
|
549
548
|
return;
|
|
550
549
|
}
|
|
551
|
-
const metadata =
|
|
550
|
+
const metadata = migrations.reflectObjectLiteral(metadataNode);
|
|
552
551
|
if (!metadata.has('host')) {
|
|
553
552
|
return;
|
|
554
553
|
}
|
|
555
|
-
let hostField =
|
|
554
|
+
let hostField = migrations.unwrapExpression(metadata.get('host'));
|
|
556
555
|
// Special-case in case host bindings are shared via a variable.
|
|
557
556
|
// e.g. Material button shares host bindings as a constant in the same target.
|
|
558
557
|
if (ts.isIdentifier(hostField)) {
|
|
@@ -570,7 +569,7 @@ function identifyHostBindingReferences(node, programInfo, checker, reflector, re
|
|
|
570
569
|
if (hostField === undefined || !ts.isObjectLiteralExpression(hostField)) {
|
|
571
570
|
return;
|
|
572
571
|
}
|
|
573
|
-
const hostMap =
|
|
572
|
+
const hostMap = migrations.reflectObjectLiteral(hostField);
|
|
574
573
|
const expressionResult = [];
|
|
575
574
|
const expressionVisitor = new TemplateExpressionReferenceVisitor(checker, null, node, knownFields, fieldNamesToConsiderForReferenceLookup);
|
|
576
575
|
for (const [rawName, expression] of hostMap.entries()) {
|
|
@@ -583,11 +582,11 @@ function identifyHostBindingReferences(node, programInfo, checker, reflector, re
|
|
|
583
582
|
if (!isPropertyBinding && !isEventBinding) {
|
|
584
583
|
continue;
|
|
585
584
|
}
|
|
586
|
-
const parser =
|
|
587
|
-
const sourceSpan = new
|
|
585
|
+
const parser = compiler.makeBindingParser();
|
|
586
|
+
const sourceSpan = new compiler.ParseSourceSpan(
|
|
588
587
|
// Fake source span to keep parsing offsets zero-based.
|
|
589
588
|
// We then later combine these with the expression TS node offsets.
|
|
590
|
-
new
|
|
589
|
+
new compiler.ParseLocation({ content: '', url: '' }, 0, 0, 0), new compiler.ParseLocation({ content: '', url: '' }, 0, 0, 0));
|
|
591
590
|
const name = rawName.substring(1, rawName.length - 1);
|
|
592
591
|
let parsed = undefined;
|
|
593
592
|
if (isEventBinding) {
|
|
@@ -630,9 +629,9 @@ function identifyHostBindingReferences(node, programInfo, checker, reflector, re
|
|
|
630
629
|
*/
|
|
631
630
|
function attemptExtractTemplateDefinition(node, checker, reflector, resourceLoader) {
|
|
632
631
|
const classDecorators = reflector.getDecoratorsOfDeclaration(node);
|
|
633
|
-
const evaluator = new
|
|
632
|
+
const evaluator = new migrations.PartialEvaluator(reflector, checker, null);
|
|
634
633
|
const ngDecorators = classDecorators !== null
|
|
635
|
-
?
|
|
634
|
+
? migrations.getAngularDecorators(classDecorators, ['Component'], /* isAngularCore */ false)
|
|
636
635
|
: [];
|
|
637
636
|
if (ngDecorators.length === 0 ||
|
|
638
637
|
ngDecorators[0].args === null ||
|
|
@@ -640,7 +639,7 @@ function attemptExtractTemplateDefinition(node, checker, reflector, resourceLoad
|
|
|
640
639
|
!ts.isObjectLiteralExpression(ngDecorators[0].args[0])) {
|
|
641
640
|
return null;
|
|
642
641
|
}
|
|
643
|
-
const properties =
|
|
642
|
+
const properties = migrations.reflectObjectLiteral(ngDecorators[0].args[0]);
|
|
644
643
|
const templateProp = properties.get('template');
|
|
645
644
|
const templateUrlProp = properties.get('templateUrl');
|
|
646
645
|
const containingFile = node.getSourceFile().fileName;
|
|
@@ -683,7 +682,7 @@ function attemptExtractTemplateDefinition(node, checker, reflector, resourceLoad
|
|
|
683
682
|
* all of the references to inputs.
|
|
684
683
|
*/
|
|
685
684
|
function identifyTemplateReferences(programInfo, node, reflector, checker, evaluator, templateTypeChecker, resourceLoader, options, result, knownFields, fieldNamesToConsiderForReferenceLookup) {
|
|
686
|
-
const template = templateTypeChecker.getTemplate(node,
|
|
685
|
+
const template = templateTypeChecker.getTemplate(node, compilerCli.OptimizeFor.WholeProgram) ??
|
|
687
686
|
// If there is no template registered in the TCB or compiler, the template may
|
|
688
687
|
// be skipped due to an explicit `jit: true` setting. We try to detect this case
|
|
689
688
|
// and parse the template manually.
|
|
@@ -712,7 +711,7 @@ function identifyTemplateReferences(programInfo, node, reflector, checker, evalu
|
|
|
712
711
|
node: res.context,
|
|
713
712
|
isObjectShorthandExpression: res.isObjectShorthandExpression,
|
|
714
713
|
originatingTsFile: project_paths.projectFile(node.getSourceFile(), programInfo),
|
|
715
|
-
templateFile: project_paths.projectFile(
|
|
714
|
+
templateFile: project_paths.projectFile(compilerCli.absoluteFrom(templateFilePath), programInfo),
|
|
716
715
|
isLikelyPartOfNarrowing: res.isLikelyNarrowed,
|
|
717
716
|
isWrite: res.isWrite,
|
|
718
717
|
},
|
|
@@ -738,14 +737,14 @@ function extractTemplateWithoutCompilerAnalysis(node, checker, reflector, resour
|
|
|
738
737
|
if (tmplDef === null) {
|
|
739
738
|
return null;
|
|
740
739
|
}
|
|
741
|
-
return
|
|
740
|
+
return migrations.extractTemplate(node, tmplDef, evaluator, null, resourceLoader, {
|
|
742
741
|
enableBlockSyntax: true,
|
|
743
742
|
enableLetSyntax: true,
|
|
744
743
|
usePoisonedData: true,
|
|
745
744
|
enableI18nLegacyMessageIdFormat: options.enableI18nLegacyMessageIdFormat !== false,
|
|
746
745
|
i18nNormalizeLineEndingsInICUs: options.i18nNormalizeLineEndingsInICUs === true,
|
|
747
746
|
enableSelectorless: false,
|
|
748
|
-
},
|
|
747
|
+
}, migrations.CompilationMode.FULL).nodes;
|
|
749
748
|
}
|
|
750
749
|
|
|
751
750
|
/** Gets the pattern and property name for a given binding element. */
|