@angular/core 20.0.0-next.0 → 20.0.0-next.2
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/core.mjs +3307 -4479
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/di.mjs +45 -0
- package/fesm2022/primitives/di.mjs.map +1 -0
- package/fesm2022/primitives/event-dispatch.mjs +3 -590
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +19 -9
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +8 -33
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +392 -250
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/weak_ref-DrMdAIDh.mjs +12 -0
- package/fesm2022/weak_ref-DrMdAIDh.mjs.map +1 -0
- package/index.d.ts +14339 -15134
- package/navigation_types.d-u4EOrrdZ.d.ts +121 -0
- package/package.json +11 -1
- package/primitives/di/index.d.ts +91 -0
- package/primitives/event-dispatch/index.d.ts +206 -310
- package/primitives/signals/index.d.ts +159 -196
- package/rxjs-interop/index.d.ts +72 -92
- package/schematics/bundles/{apply_import_manager-0959b78c.js → apply_import_manager-CyRT0UvU.js} +13 -17
- package/schematics/bundles/{checker-cf6f7980.js → checker-DF8ZaFW5.js} +3363 -1289
- package/schematics/bundles/cleanup-unused-imports.js +22 -28
- package/schematics/bundles/{compiler_host-cc1379e9.js → compiler_host-Da636uJ8.js} +20 -24
- package/schematics/bundles/control-flow-migration.js +82 -39
- package/schematics/bundles/{imports-31a38653.js → imports-CIX-JgAN.js} +10 -15
- package/schematics/bundles/{index-42d84d69.js → index-DnkWgagp.js} +56 -60
- package/schematics/bundles/{index-6675d6bc.js → index-vGJcp5M7.js} +5 -5
- package/schematics/bundles/inject-flags.js +181 -0
- package/schematics/bundles/inject-migration.js +122 -128
- package/schematics/bundles/{leading_space-6e7a8ec6.js → leading_space-D9nQ8UQC.js} +2 -2
- package/schematics/bundles/{migrate_ts_type_references-5089e4ef.js → migrate_ts_type_references-DtkOnnv0.js} +113 -120
- package/schematics/bundles/{ng_decorators-6878e227.js → ng_decorators-DznZ5jMl.js} +5 -9
- package/schematics/bundles/{nodes-ffdce442.js → nodes-B16H9JUd.js} +3 -7
- package/schematics/bundles/output-migration.js +40 -46
- package/schematics/bundles/{program-362689f0.js → program-BZk27Ndu.js} +846 -2653
- package/schematics/bundles/{project_paths-7d2daa1e.js → project_paths-Jtbi76Bs.js} +26 -24
- package/schematics/bundles/{project_tsconfig_paths-6c9cde78.js → project_tsconfig_paths-CDVxT6Ov.js} +2 -2
- package/schematics/bundles/{property_name-42030525.js → property_name-BBwFuqMe.js} +4 -8
- package/schematics/bundles/route-lazy-loading.js +36 -42
- package/schematics/bundles/self-closing-tags-migration.js +55 -45
- package/schematics/bundles/signal-input-migration.js +61 -68
- package/schematics/bundles/signal-queries-migration.js +48 -55
- package/schematics/bundles/signals.js +10 -12
- package/schematics/bundles/standalone-migration.js +179 -185
- package/schematics/migrations.json +4 -15
- package/testing/index.d.ts +309 -478
- package/weak_ref.d-ttyj86RV.d.ts +9 -0
- package/schematics/bundles/explicit-standalone-flag.js +0 -184
- package/schematics/bundles/pending-tasks.js +0 -103
- package/schematics/bundles/provide-initializer.js +0 -186
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
4
|
-
* (c) 2010-
|
|
3
|
+
* @license Angular v20.0.0-next.2
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
@@ -10,14 +10,11 @@ var core = require('@angular-devkit/core');
|
|
|
10
10
|
var posixPath = require('node:path/posix');
|
|
11
11
|
var os = require('os');
|
|
12
12
|
var ts = require('typescript');
|
|
13
|
-
var checker = require('./checker-
|
|
14
|
-
var program = require('./program-
|
|
13
|
+
var checker = require('./checker-DF8ZaFW5.js');
|
|
14
|
+
var program = require('./program-BZk27Ndu.js');
|
|
15
15
|
require('path');
|
|
16
16
|
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
function _interopNamespace(e) {
|
|
20
|
-
if (e && e.__esModule) return e;
|
|
17
|
+
function _interopNamespaceDefault(e) {
|
|
21
18
|
var n = Object.create(null);
|
|
22
19
|
if (e) {
|
|
23
20
|
Object.keys(e).forEach(function (k) {
|
|
@@ -30,13 +27,12 @@ function _interopNamespace(e) {
|
|
|
30
27
|
}
|
|
31
28
|
});
|
|
32
29
|
}
|
|
33
|
-
n
|
|
30
|
+
n.default = e;
|
|
34
31
|
return Object.freeze(n);
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
var posixPath__namespace = /*#__PURE__*/
|
|
38
|
-
var os__namespace = /*#__PURE__*/
|
|
39
|
-
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
34
|
+
var posixPath__namespace = /*#__PURE__*/_interopNamespaceDefault(posixPath);
|
|
35
|
+
var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
|
|
40
36
|
|
|
41
37
|
/// <reference types="node" />
|
|
42
38
|
class NgtscCompilerHost {
|
|
@@ -49,11 +45,11 @@ class NgtscCompilerHost {
|
|
|
49
45
|
getSourceFile(fileName, languageVersion) {
|
|
50
46
|
const text = this.readFile(fileName);
|
|
51
47
|
return text !== undefined
|
|
52
|
-
?
|
|
48
|
+
? ts.createSourceFile(fileName, text, languageVersion, true)
|
|
53
49
|
: undefined;
|
|
54
50
|
}
|
|
55
51
|
getDefaultLibFileName(options) {
|
|
56
|
-
return this.fs.join(this.getDefaultLibLocation(),
|
|
52
|
+
return this.fs.join(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options));
|
|
57
53
|
}
|
|
58
54
|
getDefaultLibLocation() {
|
|
59
55
|
return this.fs.getDefaultLibLocation();
|
|
@@ -74,9 +70,9 @@ class NgtscCompilerHost {
|
|
|
74
70
|
}
|
|
75
71
|
getNewLine() {
|
|
76
72
|
switch (this.options.newLine) {
|
|
77
|
-
case
|
|
73
|
+
case ts.NewLineKind.CarriageReturnLineFeed:
|
|
78
74
|
return '\r\n';
|
|
79
|
-
case
|
|
75
|
+
case ts.NewLineKind.LineFeed:
|
|
80
76
|
return '\n';
|
|
81
77
|
default:
|
|
82
78
|
return os__namespace.EOL;
|
|
@@ -99,17 +95,23 @@ class NgtscCompilerHost {
|
|
|
99
95
|
}
|
|
100
96
|
|
|
101
97
|
// We use TypeScript's native `ts.matchFiles` utility for the virtual file systems
|
|
98
|
+
// and their TypeScript compiler host `readDirectory` implementation. TypeScript's
|
|
99
|
+
// function implements complex logic for matching files with respect to root
|
|
100
|
+
// directory, extensions, excludes, includes etc. The function is currently
|
|
101
|
+
// internal but we can use it as the API most likely will not change any time soon,
|
|
102
|
+
// nor does it seem like this is being made public any time soon.
|
|
103
|
+
// Related issue for tracking: https://github.com/microsoft/TypeScript/issues/13793.
|
|
102
104
|
/**
|
|
103
105
|
* Creates a {@link ts.CompilerHost#readDirectory} implementation function,
|
|
104
106
|
* that leverages the specified file system (that may be e.g. virtual).
|
|
105
107
|
*/
|
|
106
108
|
function createFileSystemTsReadDirectoryFn(fs) {
|
|
107
|
-
if (
|
|
109
|
+
if (ts.matchFiles === undefined) {
|
|
108
110
|
throw Error('Unable to read directory in configured file system. This means that ' +
|
|
109
111
|
'TypeScript changed its file matching internals.\n\nPlease consider downgrading your ' +
|
|
110
112
|
'TypeScript version, and report an issue in the Angular framework repository.');
|
|
111
113
|
}
|
|
112
|
-
const matchFilesFn =
|
|
114
|
+
const matchFilesFn = ts.matchFiles.bind(ts);
|
|
113
115
|
return (rootDir, extensions, excludes, includes, depth) => {
|
|
114
116
|
const directoryExists = (p) => {
|
|
115
117
|
const resolvedPath = fs.resolve(p);
|
|
@@ -148,7 +150,7 @@ function calcProjectFileAndBasePath(project, host = checker.getFileSystem()) {
|
|
|
148
150
|
function readConfiguration(project, existingOptions, host = checker.getFileSystem()) {
|
|
149
151
|
try {
|
|
150
152
|
const fs = checker.getFileSystem();
|
|
151
|
-
const readConfigFile = (configFile) =>
|
|
153
|
+
const readConfigFile = (configFile) => ts.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
|
|
152
154
|
const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
|
|
153
155
|
const { config, error } = readConfigFile(configFile);
|
|
154
156
|
if (error) {
|
|
@@ -195,7 +197,7 @@ function readConfiguration(project, existingOptions, host = checker.getFileSyste
|
|
|
195
197
|
...existingOptions,
|
|
196
198
|
};
|
|
197
199
|
const parseConfigHost = createParseConfigHost(host, fs);
|
|
198
|
-
const { options, errors, fileNames: rootNames, projectReferences, } =
|
|
200
|
+
const { options, errors, fileNames: rootNames, projectReferences, } = ts.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
|
|
199
201
|
let emitFlags = program.EmitFlags.Default;
|
|
200
202
|
if (!(options['skipMetadataEmit'] || options['flatModuleOutFile'])) {
|
|
201
203
|
emitFlags |= program.EmitFlags.Metadata;
|
|
@@ -208,7 +210,7 @@ function readConfiguration(project, existingOptions, host = checker.getFileSyste
|
|
|
208
210
|
catch (e) {
|
|
209
211
|
const errors = [
|
|
210
212
|
{
|
|
211
|
-
category:
|
|
213
|
+
category: ts.DiagnosticCategory.Error,
|
|
212
214
|
messageText: e.stack ?? e.message,
|
|
213
215
|
file: undefined,
|
|
214
216
|
start: undefined,
|
|
@@ -248,7 +250,7 @@ function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
|
|
|
248
250
|
else {
|
|
249
251
|
const parseConfigHost = createParseConfigHost(host, fs);
|
|
250
252
|
// Path isn't a rooted or relative path, resolve like a module.
|
|
251
|
-
const { resolvedModule } =
|
|
253
|
+
const { resolvedModule } = ts.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts.ModuleResolutionKind.Node10, resolveJsonModule: true }, parseConfigHost);
|
|
252
254
|
if (resolvedModule) {
|
|
253
255
|
return checker.absoluteFrom(resolvedModule.resolvedFileName);
|
|
254
256
|
}
|
|
@@ -464,7 +466,7 @@ const defaultMigrationTsOptions = {
|
|
|
464
466
|
* Creates an instance of a TypeScript program for the given project.
|
|
465
467
|
*/
|
|
466
468
|
function createPlainTsProgram(tsHost, tsconfig, optionOverrides) {
|
|
467
|
-
const program =
|
|
469
|
+
const program = ts.createProgram({
|
|
468
470
|
rootNames: tsconfig.rootNames,
|
|
469
471
|
options: {
|
|
470
472
|
...tsconfig.options,
|
|
@@ -493,7 +495,7 @@ function createNgtscProgram(tsHost, tsconfig, optionOverrides) {
|
|
|
493
495
|
}, tsHost);
|
|
494
496
|
// Expose an easy way to debug-print ng semantic diagnostics.
|
|
495
497
|
if (process.env['DEBUG_NG_SEMANTIC_DIAGNOSTICS'] === '1') {
|
|
496
|
-
console.error(
|
|
498
|
+
console.error(ts.formatDiagnosticsWithColorAndContext(ngtscProgram.getNgSemanticDiagnostics(), tsHost));
|
|
497
499
|
}
|
|
498
500
|
return {
|
|
499
501
|
ngCompiler: ngtscProgram.compiler,
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
4
|
-
* (c) 2010-
|
|
3
|
+
* @license Angular v20.0.0-next.2
|
|
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
10
|
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* Gets the text of the given property name. Returns null if the property
|
|
17
13
|
* name couldn't be determined statically.
|
|
18
14
|
*/
|
|
19
15
|
function getPropertyNameText(node) {
|
|
20
|
-
if (
|
|
16
|
+
if (ts.isIdentifier(node) || ts.isStringLiteralLike(node)) {
|
|
21
17
|
return node.text;
|
|
22
18
|
}
|
|
23
19
|
return null;
|
|
24
20
|
}
|
|
25
21
|
/** Finds a property with a specific name in an object literal expression. */
|
|
26
22
|
function findLiteralProperty(literal, name) {
|
|
27
|
-
return literal.properties.find((prop) => prop.name &&
|
|
23
|
+
return literal.properties.find((prop) => prop.name && ts.isIdentifier(prop.name) && prop.name.text === name);
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
exports.findLiteralProperty = findLiteralProperty;
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
4
|
-
* (c) 2010-
|
|
3
|
+
* @license Angular v20.0.0-next.2
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
|
-
|
|
11
9
|
var schematics = require('@angular-devkit/schematics');
|
|
12
10
|
var fs = require('fs');
|
|
13
11
|
var p = require('path');
|
|
14
|
-
var compiler_host = require('./compiler_host-
|
|
15
|
-
var project_tsconfig_paths = require('./project_tsconfig_paths-
|
|
12
|
+
var compiler_host = require('./compiler_host-Da636uJ8.js');
|
|
13
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
|
|
16
14
|
var ts = require('typescript');
|
|
17
|
-
var checker = require('./checker-
|
|
18
|
-
var property_name = require('./property_name-
|
|
15
|
+
var checker = require('./checker-DF8ZaFW5.js');
|
|
16
|
+
var property_name = require('./property_name-BBwFuqMe.js');
|
|
19
17
|
require('os');
|
|
20
18
|
require('@angular-devkit/core');
|
|
21
19
|
require('module');
|
|
22
20
|
require('url');
|
|
23
21
|
|
|
24
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
25
|
-
|
|
26
|
-
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
27
|
-
|
|
28
22
|
/**
|
|
29
23
|
* Finds the class declaration that is being referred to by a node.
|
|
30
24
|
* @param reference Node referring to a class declaration.
|
|
@@ -34,7 +28,7 @@ function findClassDeclaration(reference, typeChecker) {
|
|
|
34
28
|
return (typeChecker
|
|
35
29
|
.getTypeAtLocation(reference)
|
|
36
30
|
.getSymbol()
|
|
37
|
-
?.declarations?.find(
|
|
31
|
+
?.declarations?.find(ts.isClassDeclaration) || null);
|
|
38
32
|
}
|
|
39
33
|
|
|
40
34
|
/*!
|
|
@@ -59,7 +53,7 @@ function isStandaloneComponent(node, reflector) {
|
|
|
59
53
|
return false;
|
|
60
54
|
}
|
|
61
55
|
const arg = decorator.args[0];
|
|
62
|
-
if (
|
|
56
|
+
if (ts.isObjectLiteralExpression(arg)) {
|
|
63
57
|
const property = property_name.findLiteralProperty(arg, 'standalone');
|
|
64
58
|
if (property) {
|
|
65
59
|
return property.initializer.getText() === 'true';
|
|
@@ -76,7 +70,7 @@ function isStandaloneComponent(node, reflector) {
|
|
|
76
70
|
* @param typeChecker
|
|
77
71
|
*/
|
|
78
72
|
function isAngularRoutesArray(node, typeChecker) {
|
|
79
|
-
if (
|
|
73
|
+
if (ts.isVariableDeclaration(node)) {
|
|
80
74
|
const type = typeChecker.getTypeAtLocation(node);
|
|
81
75
|
if (type && typeChecker.isArrayType(type)) {
|
|
82
76
|
// Route[] is an array type
|
|
@@ -97,7 +91,7 @@ function isAngularRoutesArray(node, typeChecker) {
|
|
|
97
91
|
* - RouterModule.forChild(routes)
|
|
98
92
|
*/
|
|
99
93
|
function isRouterModuleCallExpression(node, typeChecker) {
|
|
100
|
-
if (
|
|
94
|
+
if (ts.isPropertyAccessExpression(node.expression)) {
|
|
101
95
|
const propAccess = node.expression;
|
|
102
96
|
const moduleSymbol = typeChecker.getSymbolAtLocation(propAccess.expression);
|
|
103
97
|
return (moduleSymbol?.name === 'RouterModule' &&
|
|
@@ -110,8 +104,8 @@ function isRouterModuleCallExpression(node, typeChecker) {
|
|
|
110
104
|
* Example: this.router.resetConfig(routes)
|
|
111
105
|
*/
|
|
112
106
|
function isRouterCallExpression(node, typeChecker) {
|
|
113
|
-
if (
|
|
114
|
-
|
|
107
|
+
if (ts.isCallExpression(node) &&
|
|
108
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
115
109
|
node.expression.name.text === 'resetConfig') {
|
|
116
110
|
const calleeExpression = node.expression.expression;
|
|
117
111
|
const symbol = typeChecker.getSymbolAtLocation(calleeExpression);
|
|
@@ -128,7 +122,7 @@ function isRouterCallExpression(node, typeChecker) {
|
|
|
128
122
|
* Example: provideRoutes(routes)
|
|
129
123
|
*/
|
|
130
124
|
function isRouterProviderCallExpression(node, typeChecker) {
|
|
131
|
-
if (
|
|
125
|
+
if (ts.isIdentifier(node.expression)) {
|
|
132
126
|
const moduleSymbol = typeChecker.getSymbolAtLocation(node.expression);
|
|
133
127
|
return moduleSymbol && moduleSymbol.name === 'provideRoutes';
|
|
134
128
|
}
|
|
@@ -139,7 +133,7 @@ function isRouterProviderCallExpression(node, typeChecker) {
|
|
|
139
133
|
* Example: provideRouter(routes)
|
|
140
134
|
*/
|
|
141
135
|
function isProvideRoutesCallExpression(node, typeChecker) {
|
|
142
|
-
if (
|
|
136
|
+
if (ts.isIdentifier(node.expression)) {
|
|
143
137
|
const moduleSymbol = typeChecker.getSymbolAtLocation(node.expression);
|
|
144
138
|
return moduleSymbol && moduleSymbol.name === 'provideRouter';
|
|
145
139
|
}
|
|
@@ -161,7 +155,7 @@ function isProvideRoutesCallExpression(node, typeChecker) {
|
|
|
161
155
|
function migrateFileToLazyRoutes(sourceFile, program) {
|
|
162
156
|
const typeChecker = program.getTypeChecker();
|
|
163
157
|
const reflector = new checker.TypeScriptReflectionHost(typeChecker);
|
|
164
|
-
const printer =
|
|
158
|
+
const printer = ts.createPrinter();
|
|
165
159
|
const tracker = new compiler_host.ChangeTracker(printer);
|
|
166
160
|
const routeArraysToMigrate = findRoutesArrayToMigrate(sourceFile, typeChecker);
|
|
167
161
|
if (routeArraysToMigrate.length === 0) {
|
|
@@ -178,14 +172,14 @@ function migrateFileToLazyRoutes(sourceFile, program) {
|
|
|
178
172
|
function findRoutesArrayToMigrate(sourceFile, typeChecker) {
|
|
179
173
|
const routesArrays = [];
|
|
180
174
|
sourceFile.forEachChild(function walk(node) {
|
|
181
|
-
if (
|
|
175
|
+
if (ts.isCallExpression(node)) {
|
|
182
176
|
if (isRouterModuleCallExpression(node, typeChecker) ||
|
|
183
177
|
isRouterProviderCallExpression(node, typeChecker) ||
|
|
184
178
|
isRouterCallExpression(node, typeChecker) ||
|
|
185
179
|
isProvideRoutesCallExpression(node, typeChecker)) {
|
|
186
180
|
const arg = node.arguments[0]; // ex: RouterModule.forRoot(routes) or provideRouter(routes)
|
|
187
|
-
const routeFileImports = sourceFile.statements.filter(
|
|
188
|
-
if (
|
|
181
|
+
const routeFileImports = sourceFile.statements.filter(ts.isImportDeclaration);
|
|
182
|
+
if (ts.isArrayLiteralExpression(arg) && arg.elements.length > 0) {
|
|
189
183
|
// ex: inline routes array: RouterModule.forRoot([{ path: 'test', component: TestComponent }])
|
|
190
184
|
routesArrays.push({
|
|
191
185
|
routeFilePath: sourceFile.fileName,
|
|
@@ -193,16 +187,16 @@ function findRoutesArrayToMigrate(sourceFile, typeChecker) {
|
|
|
193
187
|
routeFileImports,
|
|
194
188
|
});
|
|
195
189
|
}
|
|
196
|
-
else if (
|
|
190
|
+
else if (ts.isIdentifier(arg)) {
|
|
197
191
|
// ex: reference to routes array: RouterModule.forRoot(routes)
|
|
198
192
|
// RouterModule.forRoot(routes), provideRouter(routes), provideRoutes(routes)
|
|
199
193
|
const symbol = typeChecker.getSymbolAtLocation(arg);
|
|
200
194
|
if (!symbol?.declarations)
|
|
201
195
|
return;
|
|
202
196
|
for (const declaration of symbol.declarations) {
|
|
203
|
-
if (
|
|
197
|
+
if (ts.isVariableDeclaration(declaration)) {
|
|
204
198
|
const initializer = declaration.initializer;
|
|
205
|
-
if (initializer &&
|
|
199
|
+
if (initializer && ts.isArrayLiteralExpression(initializer)) {
|
|
206
200
|
// ex: const routes = [{ path: 'test', component: TestComponent }];
|
|
207
201
|
routesArrays.push({
|
|
208
202
|
routeFilePath: sourceFile.fileName,
|
|
@@ -215,11 +209,11 @@ function findRoutesArrayToMigrate(sourceFile, typeChecker) {
|
|
|
215
209
|
}
|
|
216
210
|
}
|
|
217
211
|
}
|
|
218
|
-
if (
|
|
212
|
+
if (ts.isVariableDeclaration(node)) {
|
|
219
213
|
if (isAngularRoutesArray(node, typeChecker)) {
|
|
220
214
|
const initializer = node.initializer;
|
|
221
215
|
if (initializer &&
|
|
222
|
-
|
|
216
|
+
ts.isArrayLiteralExpression(initializer) &&
|
|
223
217
|
initializer.elements.length > 0) {
|
|
224
218
|
// ex: const routes: Routes = [{ path: 'test', component: TestComponent }];
|
|
225
219
|
if (routesArrays.find((x) => x.array === initializer)) {
|
|
@@ -229,7 +223,7 @@ function findRoutesArrayToMigrate(sourceFile, typeChecker) {
|
|
|
229
223
|
routesArrays.push({
|
|
230
224
|
routeFilePath: sourceFile.fileName,
|
|
231
225
|
array: initializer,
|
|
232
|
-
routeFileImports: sourceFile.statements.filter(
|
|
226
|
+
routeFileImports: sourceFile.statements.filter(ts.isImportDeclaration),
|
|
233
227
|
});
|
|
234
228
|
}
|
|
235
229
|
}
|
|
@@ -245,7 +239,7 @@ function migrateRoutesArray(routesArray, typeChecker, reflector, tracker) {
|
|
|
245
239
|
const importsToRemove = [];
|
|
246
240
|
for (const route of routesArray) {
|
|
247
241
|
route.array.elements.forEach((element) => {
|
|
248
|
-
if (
|
|
242
|
+
if (ts.isObjectLiteralExpression(element)) {
|
|
249
243
|
const { migratedRoutes: migrated, skippedRoutes: toBeSkipped, importsToRemove: toBeRemoved, } = migrateRoute(element, route, typeChecker, reflector, tracker);
|
|
250
244
|
migratedRoutes.push(...migrated);
|
|
251
245
|
skippedRoutes.push(...toBeSkipped);
|
|
@@ -271,9 +265,9 @@ function migrateRoute(element, route, typeChecker, reflector, tracker) {
|
|
|
271
265
|
const routePath = property_name.findLiteralProperty(element, 'path')?.getText() ?? '';
|
|
272
266
|
const children = property_name.findLiteralProperty(element, 'children');
|
|
273
267
|
// recursively migrate children routes first if they exist
|
|
274
|
-
if (children &&
|
|
268
|
+
if (children && ts.isArrayLiteralExpression(children.initializer)) {
|
|
275
269
|
for (const childRoute of children.initializer.elements) {
|
|
276
|
-
if (
|
|
270
|
+
if (ts.isObjectLiteralExpression(childRoute)) {
|
|
277
271
|
const { migratedRoutes: migrated, skippedRoutes: toBeSkipped, importsToRemove: toBeRemoved, } = migrateRoute(childRoute, route, typeChecker, reflector, tracker);
|
|
278
272
|
migratedRoutes.push(...migrated);
|
|
279
273
|
skippedRoutes.push(...toBeSkipped);
|
|
@@ -294,7 +288,7 @@ function migrateRoute(element, route, typeChecker, reflector, tracker) {
|
|
|
294
288
|
skippedRoutes.push({ path: routePath, file: route.routeFilePath });
|
|
295
289
|
return routeMigrationResults;
|
|
296
290
|
}
|
|
297
|
-
const componentClassName = componentDeclaration.name &&
|
|
291
|
+
const componentClassName = componentDeclaration.name && ts.isIdentifier(componentDeclaration.name)
|
|
298
292
|
? componentDeclaration.name.text
|
|
299
293
|
: null;
|
|
300
294
|
if (!componentClassName) {
|
|
@@ -306,7 +300,7 @@ function migrateRoute(element, route, typeChecker, reflector, tracker) {
|
|
|
306
300
|
}
|
|
307
301
|
const componentImport = route.routeFileImports.find((importDecl) => importDecl.importClause?.getText().includes(componentClassName));
|
|
308
302
|
// remove single and double quotes from the import path
|
|
309
|
-
let componentImportPath =
|
|
303
|
+
let componentImportPath = ts.isStringLiteral(componentImport?.moduleSpecifier)
|
|
310
304
|
? componentImport.moduleSpecifier.text
|
|
311
305
|
: null;
|
|
312
306
|
// if the import path is not a string literal, skip it
|
|
@@ -314,7 +308,7 @@ function migrateRoute(element, route, typeChecker, reflector, tracker) {
|
|
|
314
308
|
skippedRoutes.push({ path: routePath, file: route.routeFilePath });
|
|
315
309
|
return routeMigrationResults;
|
|
316
310
|
}
|
|
317
|
-
const isDefaultExport = componentDeclaration.modifiers?.some((x) => x.kind ===
|
|
311
|
+
const isDefaultExport = componentDeclaration.modifiers?.some((x) => x.kind === ts.SyntaxKind.DefaultKeyword) ?? false;
|
|
318
312
|
const loadComponent = createLoadComponentPropertyAssignment(componentImportPath, componentClassName, isDefaultExport);
|
|
319
313
|
tracker.replaceNode(component, loadComponent);
|
|
320
314
|
// Add the import statement for the standalone component
|
|
@@ -334,18 +328,18 @@ function migrateRoute(element, route, typeChecker, reflector, tracker) {
|
|
|
334
328
|
* loadComponent: () => import('./path') // when isDefaultExport is true
|
|
335
329
|
*/
|
|
336
330
|
function createLoadComponentPropertyAssignment(componentImportPath, componentDeclarationName, isDefaultExport) {
|
|
337
|
-
return
|
|
331
|
+
return ts.factory.createPropertyAssignment('loadComponent', ts.factory.createArrowFunction(undefined, undefined, [], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), isDefaultExport
|
|
338
332
|
? createImportCallExpression(componentImportPath) // will generate import('./path) and will skip the then() call
|
|
339
|
-
:
|
|
333
|
+
: ts.factory.createCallExpression(
|
|
340
334
|
// will generate import('./path).then(m => m.componentName)
|
|
341
|
-
|
|
335
|
+
ts.factory.createPropertyAccessExpression(createImportCallExpression(componentImportPath), 'then'), undefined, [createImportThenCallExpression(componentDeclarationName)])));
|
|
342
336
|
}
|
|
343
337
|
// import('./path)
|
|
344
|
-
const createImportCallExpression = (componentImportPath) =>
|
|
345
|
-
|
|
338
|
+
const createImportCallExpression = (componentImportPath) => ts.factory.createCallExpression(ts.factory.createIdentifier('import'), undefined, [
|
|
339
|
+
ts.factory.createStringLiteral(componentImportPath, true),
|
|
346
340
|
]);
|
|
347
341
|
// m => m.componentName
|
|
348
|
-
const createImportThenCallExpression = (componentDeclarationName) =>
|
|
342
|
+
const createImportThenCallExpression = (componentDeclarationName) => ts.factory.createArrowFunction(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, 'm', undefined, undefined)], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('m'), componentDeclarationName));
|
|
349
343
|
|
|
350
344
|
function migrate(options) {
|
|
351
345
|
return async (tree, context) => {
|
|
@@ -1,33 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
4
|
-
* (c) 2010-
|
|
3
|
+
* @license Angular v20.0.0-next.2
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
|
-
|
|
11
9
|
var schematics = require('@angular-devkit/schematics');
|
|
12
|
-
var project_tsconfig_paths = require('./project_tsconfig_paths-
|
|
13
|
-
var project_paths = require('./project_paths-
|
|
10
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
|
|
11
|
+
var project_paths = require('./project_paths-Jtbi76Bs.js');
|
|
14
12
|
require('os');
|
|
15
13
|
var ts = require('typescript');
|
|
16
|
-
var checker = require('./checker-
|
|
17
|
-
require('./program-
|
|
14
|
+
var checker = require('./checker-DF8ZaFW5.js');
|
|
15
|
+
require('./program-BZk27Ndu.js');
|
|
18
16
|
require('path');
|
|
19
|
-
var ng_decorators = require('./ng_decorators-
|
|
20
|
-
var property_name = require('./property_name-
|
|
17
|
+
var ng_decorators = require('./ng_decorators-DznZ5jMl.js');
|
|
18
|
+
var property_name = require('./property_name-BBwFuqMe.js');
|
|
21
19
|
require('@angular-devkit/core');
|
|
22
20
|
require('node:path/posix');
|
|
23
21
|
require('fs');
|
|
24
22
|
require('module');
|
|
25
23
|
require('url');
|
|
26
|
-
require('./imports-
|
|
27
|
-
|
|
28
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
29
|
-
|
|
30
|
-
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
24
|
+
require('./imports-CIX-JgAN.js');
|
|
31
25
|
|
|
32
26
|
/**
|
|
33
27
|
* Unwraps a given expression TypeScript node. Expressions can be wrapped within multiple
|
|
@@ -35,7 +29,7 @@ var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
|
35
29
|
* TypeScript node referring to the inner expression. e.g "exp".
|
|
36
30
|
*/
|
|
37
31
|
function unwrapExpression(node) {
|
|
38
|
-
if (
|
|
32
|
+
if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node)) {
|
|
39
33
|
return unwrapExpression(node.expression);
|
|
40
34
|
}
|
|
41
35
|
else {
|
|
@@ -45,7 +39,7 @@ function unwrapExpression(node) {
|
|
|
45
39
|
|
|
46
40
|
/** Extracts `@Directive` or `@Component` metadata from the given class. */
|
|
47
41
|
function extractAngularClassMetadata(typeChecker, node) {
|
|
48
|
-
const decorators =
|
|
42
|
+
const decorators = ts.getDecorators(node);
|
|
49
43
|
if (!decorators || !decorators.length) {
|
|
50
44
|
return null;
|
|
51
45
|
}
|
|
@@ -64,7 +58,7 @@ function extractAngularClassMetadata(typeChecker, node) {
|
|
|
64
58
|
}
|
|
65
59
|
const metadata = unwrapExpression(decoratorCall.arguments[0]);
|
|
66
60
|
// Ensure that the metadata is an object literal expression.
|
|
67
|
-
if (!
|
|
61
|
+
if (!ts.isObjectLiteralExpression(metadata)) {
|
|
68
62
|
return null;
|
|
69
63
|
}
|
|
70
64
|
return {
|
|
@@ -138,10 +132,10 @@ class NgComponentTemplateVisitor {
|
|
|
138
132
|
this.typeChecker = typeChecker;
|
|
139
133
|
}
|
|
140
134
|
visitNode(node) {
|
|
141
|
-
if (node.kind ===
|
|
135
|
+
if (node.kind === ts.SyntaxKind.ClassDeclaration) {
|
|
142
136
|
this.visitClassDeclaration(node);
|
|
143
137
|
}
|
|
144
|
-
|
|
138
|
+
ts.forEachChild(node, (n) => this.visitNode(n));
|
|
145
139
|
}
|
|
146
140
|
visitClassDeclaration(node) {
|
|
147
141
|
const metadata = extractAngularClassMetadata(this.typeChecker, node);
|
|
@@ -153,13 +147,13 @@ class NgComponentTemplateVisitor {
|
|
|
153
147
|
// Walk through all component metadata properties and determine the referenced
|
|
154
148
|
// HTML templates (either external or inline)
|
|
155
149
|
metadata.node.properties.forEach((property) => {
|
|
156
|
-
if (!
|
|
150
|
+
if (!ts.isPropertyAssignment(property)) {
|
|
157
151
|
return;
|
|
158
152
|
}
|
|
159
153
|
const propertyName = property_name.getPropertyNameText(property.name);
|
|
160
154
|
// In case there is an inline template specified, ensure that the value is statically
|
|
161
155
|
// analyzable by checking if the initializer is a string literal-like node.
|
|
162
|
-
if (propertyName === 'template' &&
|
|
156
|
+
if (propertyName === 'template' && ts.isStringLiteralLike(property.initializer)) {
|
|
163
157
|
// Need to add an offset of one to the start because the template quotes are
|
|
164
158
|
// not part of the template content.
|
|
165
159
|
// The `getText()` method gives us the original raw text.
|
|
@@ -177,10 +171,10 @@ class NgComponentTemplateVisitor {
|
|
|
177
171
|
content,
|
|
178
172
|
inline: true,
|
|
179
173
|
start: start,
|
|
180
|
-
getCharacterAndLineOfPosition: (pos) =>
|
|
174
|
+
getCharacterAndLineOfPosition: (pos) => ts.getLineAndCharacterOfPosition(sourceFile, pos + start),
|
|
181
175
|
});
|
|
182
176
|
}
|
|
183
|
-
if (propertyName === 'templateUrl' &&
|
|
177
|
+
if (propertyName === 'templateUrl' && ts.isStringLiteralLike(property.initializer)) {
|
|
184
178
|
const absolutePath = this.fs.resolve(this.fs.dirname(sourceFileName), property.initializer.text);
|
|
185
179
|
if (!this.fs.exists(absolutePath)) {
|
|
186
180
|
return;
|
|
@@ -314,8 +308,9 @@ class SelfClosingTagsMigration extends project_paths.TsurgeFunnelMigration {
|
|
|
314
308
|
const typeChecker = program.getTypeChecker();
|
|
315
309
|
const tagReplacements = [];
|
|
316
310
|
for (const sf of sourceFiles) {
|
|
317
|
-
|
|
318
|
-
|
|
311
|
+
ts.forEachChild(sf, (node) => {
|
|
312
|
+
// Skipping any non component declarations
|
|
313
|
+
if (!ts.isClassDeclaration(node)) {
|
|
319
314
|
return;
|
|
320
315
|
}
|
|
321
316
|
const file = project_paths.projectFile(node.getSourceFile(), info);
|
|
@@ -326,22 +321,23 @@ class SelfClosingTagsMigration extends project_paths.TsurgeFunnelMigration {
|
|
|
326
321
|
templateVisitor.visitNode(node);
|
|
327
322
|
templateVisitor.resolvedTemplates.forEach((template) => {
|
|
328
323
|
const { migrated, changed, replacementCount } = migrateTemplateToSelfClosingTags(template.content);
|
|
329
|
-
if (changed) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
324
|
+
if (!changed) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const fileToMigrate = template.inline
|
|
328
|
+
? file
|
|
329
|
+
: project_paths.projectFile(template.filePath, info);
|
|
330
|
+
const end = template.start + template.content.length;
|
|
331
|
+
const replacements = [
|
|
332
|
+
prepareTextReplacement(fileToMigrate, migrated, template.start, end),
|
|
333
|
+
];
|
|
334
|
+
const fileReplacements = tagReplacements.find((tagReplacement) => tagReplacement.file === file);
|
|
335
|
+
if (fileReplacements) {
|
|
336
|
+
fileReplacements.replacements.push(...replacements);
|
|
337
|
+
fileReplacements.replacementCount += replacementCount;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
tagReplacements.push({ file, replacements, replacementCount });
|
|
345
341
|
}
|
|
346
342
|
});
|
|
347
343
|
});
|
|
@@ -349,9 +345,11 @@ class SelfClosingTagsMigration extends project_paths.TsurgeFunnelMigration {
|
|
|
349
345
|
return project_paths.confirmAsSerializable({ tagReplacements });
|
|
350
346
|
}
|
|
351
347
|
async combine(unitA, unitB) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
348
|
+
const uniqueReplacements = removeDuplicateReplacements([
|
|
349
|
+
...unitA.tagReplacements,
|
|
350
|
+
...unitB.tagReplacements,
|
|
351
|
+
]);
|
|
352
|
+
return project_paths.confirmAsSerializable({ tagReplacements: uniqueReplacements });
|
|
355
353
|
}
|
|
356
354
|
async globalMeta(combinedData) {
|
|
357
355
|
const globalMeta = {
|
|
@@ -380,6 +378,18 @@ function prepareTextReplacement(file, replacement, start, end) {
|
|
|
380
378
|
toInsert: replacement,
|
|
381
379
|
}));
|
|
382
380
|
}
|
|
381
|
+
function removeDuplicateReplacements(replacements) {
|
|
382
|
+
const uniqueFiles = new Set();
|
|
383
|
+
const result = [];
|
|
384
|
+
for (const replacement of replacements) {
|
|
385
|
+
const fileId = replacement.file.id;
|
|
386
|
+
if (!uniqueFiles.has(fileId)) {
|
|
387
|
+
uniqueFiles.add(fileId);
|
|
388
|
+
result.push(replacement);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
383
393
|
|
|
384
394
|
function migrate(options) {
|
|
385
395
|
return async (tree, context) => {
|