@angular/core 20.0.0-next.4 → 20.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.d-DQLNOR5l.d.ts +297 -0
- package/discovery.d-CFs2MaLO.d.ts +7383 -0
- package/{event_dispatcher.d-pVP0-wST.d.ts → event_dispatcher.d-DlbccpYq.d.ts} +3 -2
- package/fesm2022/attribute-BWp59EjE.mjs +24 -0
- package/fesm2022/attribute-BWp59EjE.mjs.map +1 -0
- package/fesm2022/core.mjs +586 -36873
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/debug_node-z_3NG8qT.mjs +32079 -0
- package/fesm2022/debug_node-z_3NG8qT.mjs.map +1 -0
- package/fesm2022/primitives/di.mjs +18 -4
- package/fesm2022/primitives/di.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +2 -16
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +5 -3
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/resource-CPPwEcg7.mjs +619 -0
- package/fesm2022/resource-CPPwEcg7.mjs.map +1 -0
- package/fesm2022/root_effect_scheduler-VSXfCzDX.mjs +3847 -0
- package/fesm2022/root_effect_scheduler-VSXfCzDX.mjs.map +1 -0
- package/fesm2022/rxjs-interop.mjs +16 -9
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/{untracked-DkcXpNb_.mjs → signal-B6pMq7KS.mjs} +16 -114
- package/fesm2022/signal-B6pMq7KS.mjs.map +1 -0
- package/fesm2022/testing.mjs +265 -201
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/untracked-Bz5WMeU1.mjs +117 -0
- package/fesm2022/untracked-Bz5WMeU1.mjs.map +1 -0
- package/fesm2022/weak_ref-BaIq-pgY.mjs +12 -0
- package/fesm2022/weak_ref-BaIq-pgY.mjs.map +1 -0
- package/{weak_ref.d-BZ7gyRag.d.ts → graph.d-BcIOep_B.d.ts} +3 -24
- package/index.d.ts +2624 -10909
- package/ng_i18n_closure_mode.d-C9d2CaSt.d.ts +832 -0
- package/package.json +3 -3
- package/primitives/di/index.d.ts +3 -2
- package/primitives/event-dispatch/index.d.ts +3 -3
- package/primitives/signals/index.d.ts +8 -4
- package/rxjs-interop/index.d.ts +10 -7
- package/schematics/bundles/{apply_import_manager-CeNv8GIG.js → apply_import_manager-DnMqg1pY.js} +6 -6
- package/schematics/bundles/{compiler_host-DwM3ugW3.js → change_tracker-UMPkv-eH.js} +3 -121
- package/schematics/bundles/checker-BFBQyesT.js +17719 -0
- package/schematics/bundles/cleanup-unused-imports.js +25 -19
- package/schematics/bundles/{checker-k591b6WQ.js → compiler-BQ7R7w2v.js} +1325 -18286
- package/schematics/bundles/compiler_host-CAfDJO3W.js +129 -0
- package/schematics/bundles/control-flow-migration.js +28 -40
- package/schematics/bundles/document-core.js +96 -0
- package/schematics/bundles/imports-CIX-JgAN.js +1 -1
- package/schematics/bundles/{index-B4OAlHh8.js → index-Cv4Q415G.js} +641 -547
- package/schematics/bundles/{index-BhELUmYx.js → index-D8tMJPKa.js} +35 -34
- package/schematics/bundles/inject-flags.js +14 -13
- package/schematics/bundles/inject-migration.js +29 -10
- package/schematics/bundles/leading_space-D9nQ8UQC.js +1 -1
- package/schematics/bundles/{migrate_ts_type_references-Be0TNYen.js → migrate_ts_type_references-Cq_ZBuT4.js} +21 -20
- package/schematics/bundles/ng_decorators-DznZ5jMl.js +1 -1
- package/schematics/bundles/nodes-B16H9JUd.js +1 -1
- package/schematics/bundles/output-migration.js +88 -25
- package/schematics/bundles/{run_in_devkit-CkvEksWP.js → project_paths-ql6qcf_c.js} +254 -243
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.js +1 -1
- package/schematics/bundles/property_name-BBwFuqMe.js +1 -1
- package/schematics/bundles/route-lazy-loading.js +7 -5
- package/schematics/bundles/self-closing-tags-migration.js +25 -19
- package/schematics/bundles/signal-input-migration.js +26 -20
- package/schematics/bundles/signal-queries-migration.js +51 -33
- package/schematics/bundles/signals.js +8 -7
- package/schematics/bundles/standalone-migration.js +11 -9
- package/schematics/bundles/symbol-VPWguRxr.js +1 -1
- package/schematics/bundles/test-bed-get.js +13 -12
- package/schematics/collection.json +0 -6
- package/schematics/migrations.json +11 -0
- package/signal.d-E0e5nW1p.d.ts +31 -0
- package/testing/index.d.ts +16 -28
- package/weak_ref.d-eGOEP9S1.d.ts +9 -0
- package/fesm2022/injector-BlLwZ2sr.mjs +0 -24
- package/fesm2022/injector-BlLwZ2sr.mjs.map +0 -1
- package/fesm2022/untracked-DkcXpNb_.mjs.map +0 -1
- package/navigation_types.d-DgDrF5rp.d.ts +0 -121
- package/schematics/ng-generate/control-flow-migration/schema.json +0 -20
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @license Angular v20.0.0-next.6
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var p = require('path');
|
|
10
|
+
var ts = require('typescript');
|
|
11
|
+
|
|
12
|
+
function _interopNamespaceDefault(e) {
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var p__namespace = /*#__PURE__*/_interopNamespaceDefault(p);
|
|
30
|
+
|
|
31
|
+
function parseTsconfigFile(tsconfigPath, basePath) {
|
|
32
|
+
const { config } = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
33
|
+
const parseConfigHost = {
|
|
34
|
+
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
35
|
+
fileExists: ts.sys.fileExists,
|
|
36
|
+
readDirectory: ts.sys.readDirectory,
|
|
37
|
+
readFile: ts.sys.readFile,
|
|
38
|
+
};
|
|
39
|
+
// Throw if incorrect arguments are passed to this function. Passing relative base paths
|
|
40
|
+
// results in root directories not being resolved and in later type checking runtime errors.
|
|
41
|
+
// More details can be found here: https://github.com/microsoft/TypeScript/issues/37731.
|
|
42
|
+
if (!p__namespace.isAbsolute(basePath)) {
|
|
43
|
+
throw Error('Unexpected relative base path has been specified.');
|
|
44
|
+
}
|
|
45
|
+
return ts.parseJsonConfigFileContent(config, parseConfigHost, basePath, {});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Creates a TypeScript program instance for a TypeScript project within
|
|
50
|
+
* the virtual file system tree.
|
|
51
|
+
* @param tree Virtual file system tree that contains the source files.
|
|
52
|
+
* @param tsconfigPath Virtual file system path that resolves to the TypeScript project.
|
|
53
|
+
* @param basePath Base path for the virtual file system tree.
|
|
54
|
+
* @param fakeFileRead Optional file reader function. Can be used to overwrite files in
|
|
55
|
+
* the TypeScript program, or to add in-memory files (e.g. to add global types).
|
|
56
|
+
* @param additionalFiles Additional file paths that should be added to the program.
|
|
57
|
+
*/
|
|
58
|
+
function createMigrationProgram(tree, tsconfigPath, basePath, fakeFileRead, additionalFiles) {
|
|
59
|
+
const { rootNames, options, host } = createProgramOptions(tree, tsconfigPath, basePath, fakeFileRead);
|
|
60
|
+
return ts.createProgram(rootNames, options, host);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates the options necessary to instantiate a TypeScript program.
|
|
64
|
+
* @param tree Virtual file system tree that contains the source files.
|
|
65
|
+
* @param tsconfigPath Virtual file system path that resolves to the TypeScript project.
|
|
66
|
+
* @param basePath Base path for the virtual file system tree.
|
|
67
|
+
* @param fakeFileRead Optional file reader function. Can be used to overwrite files in
|
|
68
|
+
* the TypeScript program, or to add in-memory files (e.g. to add global types).
|
|
69
|
+
* @param additionalFiles Additional file paths that should be added to the program.
|
|
70
|
+
* @param optionOverrides Overrides of the parsed compiler options.
|
|
71
|
+
*/
|
|
72
|
+
function createProgramOptions(tree, tsconfigPath, basePath, fakeFileRead, additionalFiles, optionOverrides) {
|
|
73
|
+
// Resolve the tsconfig path to an absolute path. This is needed as TypeScript otherwise
|
|
74
|
+
// is not able to resolve root directories in the given tsconfig. More details can be found
|
|
75
|
+
// in the following issue: https://github.com/microsoft/TypeScript/issues/37731.
|
|
76
|
+
tsconfigPath = p.resolve(basePath, tsconfigPath);
|
|
77
|
+
const parsed = parseTsconfigFile(tsconfigPath, p.dirname(tsconfigPath));
|
|
78
|
+
const options = optionOverrides ? { ...parsed.options, ...optionOverrides } : parsed.options;
|
|
79
|
+
const host = createMigrationCompilerHost(tree, options, basePath, fakeFileRead);
|
|
80
|
+
return { rootNames: parsed.fileNames.concat([]), options, host };
|
|
81
|
+
}
|
|
82
|
+
function createMigrationCompilerHost(tree, options, basePath, fakeRead) {
|
|
83
|
+
const host = ts.createCompilerHost(options, true);
|
|
84
|
+
const defaultReadFile = host.readFile;
|
|
85
|
+
// We need to overwrite the host "readFile" method, as we want the TypeScript
|
|
86
|
+
// program to be based on the file contents in the virtual file tree. Otherwise
|
|
87
|
+
// if we run multiple migrations we might have intersecting changes and
|
|
88
|
+
// source files.
|
|
89
|
+
host.readFile = (fileName) => {
|
|
90
|
+
const treeRelativePath = p.relative(basePath, fileName);
|
|
91
|
+
let result = fakeRead?.(treeRelativePath);
|
|
92
|
+
if (typeof result !== 'string') {
|
|
93
|
+
// If the relative path resolved to somewhere outside of the tree, fall back to
|
|
94
|
+
// TypeScript's default file reading function since the `tree` will throw an error.
|
|
95
|
+
result = treeRelativePath.startsWith('..')
|
|
96
|
+
? defaultReadFile.call(host, fileName)
|
|
97
|
+
: tree.read(treeRelativePath)?.toString();
|
|
98
|
+
}
|
|
99
|
+
// Strip BOM as otherwise TSC methods (Ex: getWidth) will return an offset,
|
|
100
|
+
// which breaks the CLI UpdateRecorder.
|
|
101
|
+
// See: https://github.com/angular/angular/pull/30719
|
|
102
|
+
return typeof result === 'string' ? result.replace(/^\uFEFF/, '') : undefined;
|
|
103
|
+
};
|
|
104
|
+
return host;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Checks whether a file can be migrate by our automated migrations.
|
|
108
|
+
* @param basePath Absolute path to the project.
|
|
109
|
+
* @param sourceFile File being checked.
|
|
110
|
+
* @param program Program that includes the source file.
|
|
111
|
+
*/
|
|
112
|
+
function canMigrateFile(basePath, sourceFile, program) {
|
|
113
|
+
// We shouldn't migrate .d.ts files, files from an external library or type checking files.
|
|
114
|
+
if (sourceFile.fileName.endsWith('.ngtypecheck.ts') ||
|
|
115
|
+
sourceFile.isDeclarationFile ||
|
|
116
|
+
program.isSourceFileFromExternalLibrary(sourceFile)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
// Our migrations are set up to create a `Program` from the project's tsconfig and to migrate all
|
|
120
|
+
// the files within the program. This can include files that are outside of the Angular CLI
|
|
121
|
+
// project. We can't migrate files outside of the project, because our file system interactions
|
|
122
|
+
// go through the CLI's `Tree` which assumes that all files are within the project. See:
|
|
123
|
+
// https://github.com/angular/angular-cli/blob/0b0961c9c233a825b6e4bb59ab7f0790f9b14676/packages/angular_devkit/schematics/src/tree/host-tree.ts#L131
|
|
124
|
+
return !p.relative(basePath, sourceFile.fileName).startsWith('..');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
exports.canMigrateFile = canMigrateFile;
|
|
128
|
+
exports.createMigrationProgram = createMigrationProgram;
|
|
129
|
+
exports.createProgramOptions = createProgramOptions;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
3
|
+
* @license Angular v20.0.0-next.6
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -8,13 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
var schematics = require('@angular-devkit/schematics');
|
|
10
10
|
var p = require('path');
|
|
11
|
-
var compiler_host = require('./compiler_host-
|
|
12
|
-
var
|
|
11
|
+
var compiler_host = require('./compiler_host-CAfDJO3W.js');
|
|
12
|
+
var compiler = require('./compiler-BQ7R7w2v.js');
|
|
13
13
|
var ts = require('typescript');
|
|
14
|
-
require('
|
|
15
|
-
require('
|
|
16
|
-
require('module');
|
|
17
|
-
require('url');
|
|
14
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
|
|
15
|
+
require('@angular-devkit/core');
|
|
18
16
|
|
|
19
17
|
function lookupIdentifiersInSourceFile(sourceFile, names) {
|
|
20
18
|
const results = new Set();
|
|
@@ -273,7 +271,7 @@ class AnalyzedFile {
|
|
|
273
271
|
}
|
|
274
272
|
}
|
|
275
273
|
/** Finds all non-control flow elements from common module. */
|
|
276
|
-
class CommonCollector extends
|
|
274
|
+
class CommonCollector extends compiler.RecursiveVisitor$1 {
|
|
277
275
|
count = 0;
|
|
278
276
|
visitElement(el) {
|
|
279
277
|
if (el.attrs.length > 0) {
|
|
@@ -312,7 +310,7 @@ class CommonCollector extends checker.RecursiveVisitor {
|
|
|
312
310
|
}
|
|
313
311
|
}
|
|
314
312
|
/** Finds all elements that represent i18n blocks. */
|
|
315
|
-
class i18nCollector extends
|
|
313
|
+
class i18nCollector extends compiler.RecursiveVisitor$1 {
|
|
316
314
|
elements = [];
|
|
317
315
|
visitElement(el) {
|
|
318
316
|
if (el.attrs.find((a) => a.name === 'i18n') !== undefined) {
|
|
@@ -322,7 +320,7 @@ class i18nCollector extends checker.RecursiveVisitor {
|
|
|
322
320
|
}
|
|
323
321
|
}
|
|
324
322
|
/** Finds all elements with ngif structural directives. */
|
|
325
|
-
class ElementCollector extends
|
|
323
|
+
class ElementCollector extends compiler.RecursiveVisitor$1 {
|
|
326
324
|
_attributes;
|
|
327
325
|
elements = [];
|
|
328
326
|
constructor(_attributes = []) {
|
|
@@ -375,7 +373,7 @@ class ElementCollector extends checker.RecursiveVisitor {
|
|
|
375
373
|
}
|
|
376
374
|
}
|
|
377
375
|
/** Finds all elements with ngif structural directives. */
|
|
378
|
-
class TemplateCollector extends
|
|
376
|
+
class TemplateCollector extends compiler.RecursiveVisitor$1 {
|
|
379
377
|
elements = [];
|
|
380
378
|
templates = new Map();
|
|
381
379
|
visitElement(el) {
|
|
@@ -589,7 +587,7 @@ function parseTemplate(template) {
|
|
|
589
587
|
// interpolated text as text nodes containing a mixture of interpolation tokens and text tokens,
|
|
590
588
|
// rather than turning them into `BoundText` nodes like the Ivy AST does. This allows us to
|
|
591
589
|
// easily get the text-only ranges without having to reconstruct the original text.
|
|
592
|
-
parsed = new
|
|
590
|
+
parsed = new compiler.HtmlParser().parse(template, '', {
|
|
593
591
|
// Allows for ICUs to be parsed.
|
|
594
592
|
tokenizeExpansionForms: true,
|
|
595
593
|
// Explicitly disable blocks so that their characters are treated as plain text.
|
|
@@ -627,7 +625,7 @@ function validateMigratedTemplate(migrated, fileName) {
|
|
|
627
625
|
}
|
|
628
626
|
function validateI18nStructure(parsed, fileName) {
|
|
629
627
|
const visitor = new i18nCollector();
|
|
630
|
-
|
|
628
|
+
compiler.visitAll$1(visitor, parsed.rootNodes);
|
|
631
629
|
const parents = visitor.elements.filter((el) => el.children.length > 0);
|
|
632
630
|
for (const p of parents) {
|
|
633
631
|
for (const el of visitor.elements) {
|
|
@@ -707,7 +705,7 @@ function getTemplates(template) {
|
|
|
707
705
|
const parsed = parseTemplate(template);
|
|
708
706
|
if (parsed.tree !== undefined) {
|
|
709
707
|
const visitor = new TemplateCollector();
|
|
710
|
-
|
|
708
|
+
compiler.visitAll$1(visitor, parsed.tree.rootNodes);
|
|
711
709
|
for (let [key, tmpl] of visitor.templates) {
|
|
712
710
|
tmpl.count = countTemplateUsage(parsed.tree.rootNodes, key);
|
|
713
711
|
tmpl.generateContents(template);
|
|
@@ -883,7 +881,7 @@ function canRemoveCommonModule(template) {
|
|
|
883
881
|
let removeCommonModule = false;
|
|
884
882
|
if (parsed.tree !== undefined) {
|
|
885
883
|
const visitor = new CommonCollector();
|
|
886
|
-
|
|
884
|
+
compiler.visitAll$1(visitor, parsed.tree.rootNodes);
|
|
887
885
|
removeCommonModule = visitor.count === 0;
|
|
888
886
|
}
|
|
889
887
|
return removeCommonModule;
|
|
@@ -1006,7 +1004,7 @@ function generateI18nMarkers(tmpl) {
|
|
|
1006
1004
|
let parsed = parseTemplate(tmpl);
|
|
1007
1005
|
if (parsed.tree !== undefined) {
|
|
1008
1006
|
const visitor = new i18nCollector();
|
|
1009
|
-
|
|
1007
|
+
compiler.visitAll$1(visitor, parsed.tree.rootNodes);
|
|
1010
1008
|
for (const [ix, el] of visitor.elements.entries()) {
|
|
1011
1009
|
// we only care about elements with children and i18n tags
|
|
1012
1010
|
// elements without children have nothing to translate
|
|
@@ -1208,7 +1206,7 @@ function migrateCase(template) {
|
|
|
1208
1206
|
}
|
|
1209
1207
|
let result = template;
|
|
1210
1208
|
const visitor = new ElementCollector(cases);
|
|
1211
|
-
|
|
1209
|
+
compiler.visitAll$1(visitor, parsed.tree.rootNodes);
|
|
1212
1210
|
calculateNesting(visitor, hasLineBreaks(template));
|
|
1213
1211
|
// this tracks the character shift from different lengths of blocks from
|
|
1214
1212
|
// the prior directives so as to adjust for nested block replacement during
|
|
@@ -1305,7 +1303,7 @@ function migrateFor(template) {
|
|
|
1305
1303
|
}
|
|
1306
1304
|
let result = template;
|
|
1307
1305
|
const visitor = new ElementCollector(fors);
|
|
1308
|
-
|
|
1306
|
+
compiler.visitAll$1(visitor, parsed.tree.rootNodes);
|
|
1309
1307
|
calculateNesting(visitor, hasLineBreaks(template));
|
|
1310
1308
|
// this tracks the character shift from different lengths of blocks from
|
|
1311
1309
|
// the prior directives so as to adjust for nested block replacement during
|
|
@@ -1510,7 +1508,7 @@ function migrateIf(template) {
|
|
|
1510
1508
|
}
|
|
1511
1509
|
let result = template;
|
|
1512
1510
|
const visitor = new ElementCollector(ifs);
|
|
1513
|
-
|
|
1511
|
+
compiler.visitAll$1(visitor, parsed.tree.rootNodes);
|
|
1514
1512
|
calculateNesting(visitor, hasLineBreaks(template));
|
|
1515
1513
|
// this tracks the character shift from different lengths of blocks from
|
|
1516
1514
|
// the prior directives so as to adjust for nested block replacement during
|
|
@@ -1703,7 +1701,7 @@ function migrateSwitch(template) {
|
|
|
1703
1701
|
}
|
|
1704
1702
|
let result = template;
|
|
1705
1703
|
const visitor = new ElementCollector(switches);
|
|
1706
|
-
|
|
1704
|
+
compiler.visitAll$1(visitor, parsed.tree.rootNodes);
|
|
1707
1705
|
calculateNesting(visitor, hasLineBreaks(template));
|
|
1708
1706
|
// this tracks the character shift from different lengths of blocks from
|
|
1709
1707
|
// the prior directives so as to adjust for nested block replacement during
|
|
@@ -1734,11 +1732,11 @@ function migrateSwitch(template) {
|
|
|
1734
1732
|
}
|
|
1735
1733
|
function assertValidSwitchStructure(children) {
|
|
1736
1734
|
for (const child of children) {
|
|
1737
|
-
if (child instanceof
|
|
1735
|
+
if (child instanceof compiler.Text && child.value.trim() !== '') {
|
|
1738
1736
|
throw new Error(`Text node: "${child.value}" would result in invalid migrated @switch block structure. ` +
|
|
1739
1737
|
`@switch can only have @case or @default as children.`);
|
|
1740
1738
|
}
|
|
1741
|
-
else if (child instanceof
|
|
1739
|
+
else if (child instanceof compiler.Element$1) {
|
|
1742
1740
|
let hasCase = false;
|
|
1743
1741
|
for (const attr of child.attrs) {
|
|
1744
1742
|
if (cases.includes(attr.name)) {
|
|
@@ -1836,20 +1834,17 @@ function migrateTemplate(template, templateType, node, file, format = true, anal
|
|
|
1836
1834
|
return { migrated, errors };
|
|
1837
1835
|
}
|
|
1838
1836
|
|
|
1839
|
-
function migrate(
|
|
1837
|
+
function migrate() {
|
|
1840
1838
|
return async (tree, context) => {
|
|
1839
|
+
const { buildPaths, testPaths } = await project_tsconfig_paths.getProjectTsConfigPaths(tree);
|
|
1841
1840
|
const basePath = process.cwd();
|
|
1842
|
-
const
|
|
1843
|
-
let allPaths = [];
|
|
1844
|
-
if (pathToMigrate.trim() !== '') {
|
|
1845
|
-
allPaths.push(pathToMigrate);
|
|
1846
|
-
}
|
|
1841
|
+
const allPaths = [...buildPaths, ...testPaths];
|
|
1847
1842
|
if (!allPaths.length) {
|
|
1848
|
-
throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run the
|
|
1843
|
+
throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run the http providers migration.');
|
|
1849
1844
|
}
|
|
1850
1845
|
let errors = [];
|
|
1851
1846
|
for (const tsconfigPath of allPaths) {
|
|
1852
|
-
const migrateErrors = runControlFlowMigration(tree, tsconfigPath, basePath
|
|
1847
|
+
const migrateErrors = runControlFlowMigration(tree, tsconfigPath, basePath);
|
|
1853
1848
|
errors = [...errors, ...migrateErrors];
|
|
1854
1849
|
}
|
|
1855
1850
|
if (errors.length > 0) {
|
|
@@ -1860,18 +1855,11 @@ function migrate(options) {
|
|
|
1860
1855
|
}
|
|
1861
1856
|
};
|
|
1862
1857
|
}
|
|
1863
|
-
function runControlFlowMigration(tree, tsconfigPath, basePath
|
|
1864
|
-
if (schematicOptions.path.startsWith('..')) {
|
|
1865
|
-
throw new schematics.SchematicsException('Cannot run control flow migration outside of the current project.');
|
|
1866
|
-
}
|
|
1858
|
+
function runControlFlowMigration(tree, tsconfigPath, basePath) {
|
|
1867
1859
|
const program = compiler_host.createMigrationProgram(tree, tsconfigPath, basePath);
|
|
1868
1860
|
const sourceFiles = program
|
|
1869
1861
|
.getSourceFiles()
|
|
1870
|
-
.filter((sourceFile) =>
|
|
1871
|
-
compiler_host.canMigrateFile(basePath, sourceFile, program));
|
|
1872
|
-
if (sourceFiles.length === 0) {
|
|
1873
|
-
throw new schematics.SchematicsException(`Could not find any files to migrate under the path ${pathToMigrate}. Cannot run the control flow migration.`);
|
|
1874
|
-
}
|
|
1862
|
+
.filter((sourceFile) => compiler_host.canMigrateFile(basePath, sourceFile, program));
|
|
1875
1863
|
const analysis = new Map();
|
|
1876
1864
|
const migrateErrors = new Map();
|
|
1877
1865
|
for (const sourceFile of sourceFiles) {
|
|
@@ -1889,7 +1877,7 @@ function runControlFlowMigration(tree, tsconfigPath, basePath, pathToMigrate, sc
|
|
|
1889
1877
|
for (const { start, end, node, type } of ranges) {
|
|
1890
1878
|
const template = content.slice(start, end);
|
|
1891
1879
|
const length = (end ?? content.length) - start;
|
|
1892
|
-
const { migrated, errors } = migrateTemplate(template, type, node, file,
|
|
1880
|
+
const { migrated, errors } = migrateTemplate(template, type, node, file, true, analysis);
|
|
1893
1881
|
if (migrated !== null) {
|
|
1894
1882
|
update.remove(start, length);
|
|
1895
1883
|
update.insertLeft(start, migrated);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @license Angular v20.0.0-next.6
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
require('./compiler-BQ7R7w2v.js');
|
|
10
|
+
require('typescript');
|
|
11
|
+
var checker = require('./checker-BFBQyesT.js');
|
|
12
|
+
require('os');
|
|
13
|
+
var apply_import_manager = require('./apply_import_manager-DnMqg1pY.js');
|
|
14
|
+
require('./index-Cv4Q415G.js');
|
|
15
|
+
require('path');
|
|
16
|
+
var project_paths = require('./project_paths-ql6qcf_c.js');
|
|
17
|
+
var imports = require('./imports-CIX-JgAN.js');
|
|
18
|
+
require('@angular-devkit/core');
|
|
19
|
+
require('node:path/posix');
|
|
20
|
+
require('fs');
|
|
21
|
+
require('module');
|
|
22
|
+
require('url');
|
|
23
|
+
require('@angular-devkit/schematics');
|
|
24
|
+
require('./project_tsconfig_paths-CDVxT6Ov.js');
|
|
25
|
+
|
|
26
|
+
/** Migration that moves the import of `DOCUMENT` from `core` to `common`. */
|
|
27
|
+
class DocumentCoreMigration extends project_paths.TsurgeFunnelMigration {
|
|
28
|
+
async analyze(info) {
|
|
29
|
+
const replacements = [];
|
|
30
|
+
let importManager = null;
|
|
31
|
+
for (const sourceFile of info.sourceFiles) {
|
|
32
|
+
const specifier = imports.getImportSpecifier(sourceFile, '@angular/common', 'DOCUMENT');
|
|
33
|
+
if (specifier === null) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
importManager ??= new checker.ImportManager({
|
|
37
|
+
// Prevent the manager from trying to generate a non-conflicting import.
|
|
38
|
+
generateUniqueIdentifier: () => null,
|
|
39
|
+
shouldUseSingleQuotes: () => true,
|
|
40
|
+
});
|
|
41
|
+
importManager.removeImport(sourceFile, 'DOCUMENT', '@angular/common');
|
|
42
|
+
importManager.addImport({
|
|
43
|
+
exportSymbolName: 'DOCUMENT',
|
|
44
|
+
exportModuleSpecifier: '@angular/core',
|
|
45
|
+
requestedFile: sourceFile,
|
|
46
|
+
unsafeAliasOverride: specifier.propertyName ? specifier.name.text : undefined,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (importManager !== null) {
|
|
50
|
+
apply_import_manager.applyImportManagerChanges(importManager, replacements, info.sourceFiles, info);
|
|
51
|
+
}
|
|
52
|
+
return project_paths.confirmAsSerializable({ replacements });
|
|
53
|
+
}
|
|
54
|
+
async migrate(globalData) {
|
|
55
|
+
return project_paths.confirmAsSerializable(globalData);
|
|
56
|
+
}
|
|
57
|
+
async combine(unitA, unitB) {
|
|
58
|
+
const seen = new Set();
|
|
59
|
+
const combined = [];
|
|
60
|
+
[unitA.replacements, unitB.replacements].forEach((replacements) => {
|
|
61
|
+
replacements.forEach((current) => {
|
|
62
|
+
const { position, end, toInsert } = current.update.data;
|
|
63
|
+
const key = current.projectFile.id + '/' + position + '/' + end + '/' + toInsert;
|
|
64
|
+
if (!seen.has(key)) {
|
|
65
|
+
seen.add(key);
|
|
66
|
+
combined.push(current);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
return project_paths.confirmAsSerializable({ replacements: combined });
|
|
71
|
+
}
|
|
72
|
+
async globalMeta(combinedData) {
|
|
73
|
+
return project_paths.confirmAsSerializable(combinedData);
|
|
74
|
+
}
|
|
75
|
+
async stats() {
|
|
76
|
+
return { counters: {} };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/*!
|
|
81
|
+
* @license
|
|
82
|
+
* Copyright Google LLC All Rights Reserved.
|
|
83
|
+
*
|
|
84
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
85
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
86
|
+
*/
|
|
87
|
+
function migrate() {
|
|
88
|
+
return async (tree) => {
|
|
89
|
+
await project_paths.runMigrationInDevkit({
|
|
90
|
+
tree,
|
|
91
|
+
getMigration: () => new DocumentCoreMigration(),
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
exports.migrate = migrate;
|