@angular/core 19.0.0-next.9 → 19.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/core.mjs +21183 -19410
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +71 -47
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +8 -6
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +90 -10
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +174 -113
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +524 -92
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +7 -4
- package/primitives/signals/index.d.ts +3 -1
- package/rxjs-interop/index.d.ts +35 -4
- package/schematics/bundles/{checker-3b2ea20f.js → checker-9ca42e51.js} +2303 -1006
- package/schematics/bundles/combine_units-a16385aa.js +1634 -0
- package/schematics/bundles/{compiler_host-b4ba5a28.js → compiler_host-31afa4ed.js} +8 -5
- package/schematics/bundles/control-flow-migration.js +3 -3
- package/schematics/bundles/explicit-standalone-flag.js +29 -9
- package/schematics/bundles/imports-4ac08251.js +1 -1
- package/schematics/bundles/inject-migration.js +222 -54
- package/schematics/bundles/leading_space-d190b83b.js +1 -1
- package/schematics/bundles/migrate_ts_type_references-b2a28742.js +1463 -0
- package/schematics/bundles/nodes-0e7d45ca.js +1 -1
- package/schematics/bundles/output-migration.js +575 -0
- package/schematics/bundles/pending-tasks.js +3 -3
- package/schematics/bundles/{program-6534a30a.js → program-71beec0b.js} +1385 -460
- package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
- package/schematics/bundles/provide-initializer.js +179 -0
- package/schematics/bundles/route-lazy-loading.js +9 -4
- package/schematics/bundles/signal-input-migration.js +183 -311
- package/schematics/bundles/signal-queries-migration.js +404 -146
- package/schematics/bundles/signals.js +54 -0
- package/schematics/bundles/standalone-migration.js +29 -12
- package/schematics/collection.json +11 -0
- package/schematics/migrations.json +7 -1
- package/schematics/ng-generate/output-migration/schema.json +19 -0
- package/schematics/ng-generate/signal-queries-migration/schema.json +11 -0
- package/schematics/ng-generate/signals/schema.json +65 -0
- package/testing/index.d.ts +1 -1
- package/schematics/bundles/group_replacements-e1b5cbf8.js +0 -31571
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @license Angular v19.0.0-rc.1
|
|
4
|
+
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
|
+
|
|
11
|
+
var schematics = require('@angular-devkit/schematics');
|
|
12
|
+
var p = require('path');
|
|
13
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
|
|
14
|
+
var compiler_host = require('./compiler_host-31afa4ed.js');
|
|
15
|
+
var ts = require('typescript');
|
|
16
|
+
var imports = require('./imports-4ac08251.js');
|
|
17
|
+
require('@angular-devkit/core');
|
|
18
|
+
require('./checker-9ca42e51.js');
|
|
19
|
+
require('os');
|
|
20
|
+
require('fs');
|
|
21
|
+
require('module');
|
|
22
|
+
require('url');
|
|
23
|
+
|
|
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
|
+
function migrateFile(sourceFile, rewriteFn) {
|
|
29
|
+
const changeTracker = new compiler_host.ChangeTracker(ts__default["default"].createPrinter());
|
|
30
|
+
const visitNode = (node) => {
|
|
31
|
+
const provider = tryParseProviderExpression(node);
|
|
32
|
+
if (provider) {
|
|
33
|
+
replaceProviderWithNewApi({
|
|
34
|
+
sourceFile,
|
|
35
|
+
node,
|
|
36
|
+
provider,
|
|
37
|
+
changeTracker,
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
ts__default["default"].forEachChild(node, visitNode);
|
|
42
|
+
};
|
|
43
|
+
ts__default["default"].forEachChild(sourceFile, visitNode);
|
|
44
|
+
for (const change of changeTracker.recordChanges().get(sourceFile)?.values() ?? []) {
|
|
45
|
+
rewriteFn(change.start, change.removeLength ?? 0, change.text);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function replaceProviderWithNewApi({ sourceFile, node, provider, changeTracker, }) {
|
|
49
|
+
const { initializerCode, importInject, provideInitializerFunctionName, initializerToken } = provider;
|
|
50
|
+
const initializerTokenSpecifier = imports.getImportSpecifier(sourceFile, angularCoreModule, initializerToken);
|
|
51
|
+
// The token doesn't come from `@angular/core`.
|
|
52
|
+
if (!initializerTokenSpecifier) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Replace the provider with the new provide function.
|
|
56
|
+
changeTracker.replaceText(sourceFile, node.getStart(), node.getWidth(), `${provideInitializerFunctionName}(${initializerCode})`);
|
|
57
|
+
// Remove the `*_INITIALIZER` token from imports.
|
|
58
|
+
changeTracker.removeImport(sourceFile, initializerToken, angularCoreModule);
|
|
59
|
+
// Add the `inject` function to imports if needed.
|
|
60
|
+
if (importInject) {
|
|
61
|
+
changeTracker.addImport(sourceFile, 'inject', angularCoreModule);
|
|
62
|
+
}
|
|
63
|
+
// Add the `provide*Initializer` function to imports.
|
|
64
|
+
changeTracker.addImport(sourceFile, provideInitializerFunctionName, angularCoreModule);
|
|
65
|
+
}
|
|
66
|
+
function tryParseProviderExpression(node) {
|
|
67
|
+
if (!ts__default["default"].isObjectLiteralExpression(node)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let deps = [];
|
|
71
|
+
let initializerToken;
|
|
72
|
+
let useExisting;
|
|
73
|
+
let useFactory;
|
|
74
|
+
let useValue;
|
|
75
|
+
let multi = false;
|
|
76
|
+
for (const property of node.properties) {
|
|
77
|
+
if (!ts__default["default"].isPropertyAssignment(property) || !ts__default["default"].isIdentifier(property.name)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
switch (property.name.text) {
|
|
81
|
+
case 'deps':
|
|
82
|
+
if (ts__default["default"].isArrayLiteralExpression(property.initializer)) {
|
|
83
|
+
deps = property.initializer.elements.map((el) => el.getText());
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case 'provide':
|
|
87
|
+
initializerToken = property.initializer.getText();
|
|
88
|
+
break;
|
|
89
|
+
case 'useExisting':
|
|
90
|
+
useExisting = property.initializer;
|
|
91
|
+
break;
|
|
92
|
+
case 'useFactory':
|
|
93
|
+
useFactory = property.initializer;
|
|
94
|
+
break;
|
|
95
|
+
case 'useValue':
|
|
96
|
+
useValue = property.initializer;
|
|
97
|
+
break;
|
|
98
|
+
case 'multi':
|
|
99
|
+
multi = property.initializer.kind === ts__default["default"].SyntaxKind.TrueKeyword;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!initializerToken || !multi) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const provideInitializerFunctionName = initializerTokenToFunctionMap.get(initializerToken);
|
|
107
|
+
if (!provideInitializerFunctionName) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const info = {
|
|
111
|
+
initializerToken,
|
|
112
|
+
provideInitializerFunctionName,
|
|
113
|
+
importInject: false,
|
|
114
|
+
};
|
|
115
|
+
if (useExisting) {
|
|
116
|
+
return {
|
|
117
|
+
...info,
|
|
118
|
+
importInject: true,
|
|
119
|
+
initializerCode: `() => inject(${useExisting.getText()})()`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (useFactory) {
|
|
123
|
+
const args = deps.map((dep) => `inject(${dep})`);
|
|
124
|
+
return {
|
|
125
|
+
...info,
|
|
126
|
+
importInject: deps.length > 0,
|
|
127
|
+
initializerCode: `(${useFactory.getText()})(${args.join(', ')})`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (useValue) {
|
|
131
|
+
return { ...info, initializerCode: useValue.getText() };
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const angularCoreModule = '@angular/core';
|
|
136
|
+
const initializerTokenToFunctionMap = new Map([
|
|
137
|
+
['APP_INITIALIZER', 'provideAppInitializer'],
|
|
138
|
+
['ENVIRONMENT_INITIALIZER', 'provideEnvironmentInitializer'],
|
|
139
|
+
['PLATFORM_INITIALIZER', 'providePlatformInitializer'],
|
|
140
|
+
]);
|
|
141
|
+
|
|
142
|
+
function migrate() {
|
|
143
|
+
return async (tree) => {
|
|
144
|
+
const { buildPaths, testPaths } = await project_tsconfig_paths.getProjectTsConfigPaths(tree);
|
|
145
|
+
const basePath = process.cwd();
|
|
146
|
+
const allPaths = [...buildPaths, ...testPaths];
|
|
147
|
+
if (!allPaths.length) {
|
|
148
|
+
throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run the provide initializer migration.');
|
|
149
|
+
}
|
|
150
|
+
for (const tsconfigPath of allPaths) {
|
|
151
|
+
runMigration(tree, tsconfigPath, basePath);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function runMigration(tree, tsconfigPath, basePath) {
|
|
156
|
+
const program = compiler_host.createMigrationProgram(tree, tsconfigPath, basePath);
|
|
157
|
+
const sourceFiles = program
|
|
158
|
+
.getSourceFiles()
|
|
159
|
+
.filter((sourceFile) => compiler_host.canMigrateFile(basePath, sourceFile, program));
|
|
160
|
+
for (const sourceFile of sourceFiles) {
|
|
161
|
+
let update = null;
|
|
162
|
+
const rewriter = (startPos, width, text) => {
|
|
163
|
+
if (update === null) {
|
|
164
|
+
// Lazily initialize update, because most files will not require migration.
|
|
165
|
+
update = tree.beginUpdate(p.relative(basePath, sourceFile.fileName));
|
|
166
|
+
}
|
|
167
|
+
update.remove(startPos, width);
|
|
168
|
+
if (text !== null) {
|
|
169
|
+
update.insertLeft(startPos, text);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
migrateFile(sourceFile, rewriter);
|
|
173
|
+
if (update !== null) {
|
|
174
|
+
tree.commitUpdate(update);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
exports.migrate = migrate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-
|
|
3
|
+
* @license Angular v19.0.0-rc.1
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -11,10 +11,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
var schematics = require('@angular-devkit/schematics');
|
|
12
12
|
var fs = require('fs');
|
|
13
13
|
var p = require('path');
|
|
14
|
-
var compiler_host = require('./compiler_host-
|
|
14
|
+
var compiler_host = require('./compiler_host-31afa4ed.js');
|
|
15
15
|
var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
|
|
16
16
|
var ts = require('typescript');
|
|
17
|
-
require('./checker-
|
|
17
|
+
require('./checker-9ca42e51.js');
|
|
18
18
|
require('os');
|
|
19
19
|
require('module');
|
|
20
20
|
require('url');
|
|
@@ -61,7 +61,12 @@ function isStandaloneComponent(node) {
|
|
|
61
61
|
const arg = decorator.expression.arguments[0];
|
|
62
62
|
if (ts__default["default"].isObjectLiteralExpression(arg)) {
|
|
63
63
|
const property = findLiteralProperty(arg, 'standalone');
|
|
64
|
-
|
|
64
|
+
if (property) {
|
|
65
|
+
return property.initializer.getText() === 'true';
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return true; // standalone is true by default in v19
|
|
69
|
+
}
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
return false;
|