@angular/core 19.0.0-next.8 → 19.0.0-rc.0

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.
Files changed (42) hide show
  1. package/fesm2022/core.mjs +21591 -19590
  2. package/fesm2022/core.mjs.map +1 -1
  3. package/fesm2022/primitives/event-dispatch.mjs +71 -47
  4. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  5. package/fesm2022/primitives/signals.mjs +8 -6
  6. package/fesm2022/primitives/signals.mjs.map +1 -1
  7. package/fesm2022/rxjs-interop.mjs +90 -10
  8. package/fesm2022/rxjs-interop.mjs.map +1 -1
  9. package/fesm2022/testing.mjs +177 -114
  10. package/fesm2022/testing.mjs.map +1 -1
  11. package/index.d.ts +591 -101
  12. package/package.json +1 -1
  13. package/primitives/event-dispatch/index.d.ts +7 -4
  14. package/primitives/signals/index.d.ts +7 -1
  15. package/rxjs-interop/index.d.ts +35 -4
  16. package/schematics/bundles/{checker-e68dd7ce.js → checker-2451e7c5.js} +2464 -1132
  17. package/schematics/bundles/{group_replacements-472b2387.js → combine_units-c52492ab.js} +1964 -2207
  18. package/schematics/bundles/{compiler_host-9a4d0c2b.js → compiler_host-f54f8309.js} +2 -2
  19. package/schematics/bundles/control-flow-migration.js +3 -3
  20. package/schematics/bundles/explicit-standalone-flag.js +31 -11
  21. package/schematics/bundles/{imports-4ac08251.js → imports-44987700.js} +1 -1
  22. package/schematics/bundles/inject-migration.js +122 -48
  23. package/schematics/bundles/{leading_space-d190b83b.js → leading_space-6e7a8ec6.js} +1 -1
  24. package/schematics/bundles/migrate_ts_type_references-ab18a7c3.js +1463 -0
  25. package/schematics/bundles/{nodes-0e7d45ca.js → ng_decorators-3ad437d2.js} +2 -15
  26. package/schematics/bundles/nodes-ffdce442.js +27 -0
  27. package/schematics/bundles/output-migration.js +7450 -0
  28. package/schematics/bundles/pending-tasks.js +5 -5
  29. package/schematics/bundles/{program-105283c5.js → program-58424797.js} +1359 -455
  30. package/schematics/bundles/{project_tsconfig_paths-e9ccccbf.js → project_tsconfig_paths-6c9cde78.js} +1 -1
  31. package/schematics/bundles/provide-initializer.js +190 -0
  32. package/schematics/bundles/route-lazy-loading.js +4 -4
  33. package/schematics/bundles/signal-input-migration.js +197 -349
  34. package/schematics/bundles/signal-queries-migration.js +462 -185
  35. package/schematics/bundles/signals.js +54 -0
  36. package/schematics/bundles/standalone-migration.js +38 -20
  37. package/schematics/collection.json +11 -0
  38. package/schematics/migrations.json +7 -1
  39. package/schematics/ng-generate/output-migration/schema.json +19 -0
  40. package/schematics/ng-generate/signal-queries-migration/schema.json +11 -0
  41. package/schematics/ng-generate/signals/schema.json +65 -0
  42. package/testing/index.d.ts +3 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-next.8
3
+ * @license Angular v19.0.0-rc.0
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -0,0 +1,190 @@
1
+ 'use strict';
2
+ /**
3
+ * @license Angular v19.0.0-rc.0
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-6c9cde78.js');
14
+ var compiler_host = require('./compiler_host-f54f8309.js');
15
+ var ts = require('typescript');
16
+ var imports = require('./imports-44987700.js');
17
+ var nodes = require('./nodes-ffdce442.js');
18
+ require('@angular-devkit/core');
19
+ require('./checker-2451e7c5.js');
20
+ require('os');
21
+ require('fs');
22
+ require('module');
23
+ require('url');
24
+
25
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
26
+
27
+ var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
28
+
29
+ function migrateFile(sourceFile, rewriteFn) {
30
+ const changeTracker = new compiler_host.ChangeTracker(ts__default["default"].createPrinter());
31
+ const visitNode = (node) => {
32
+ const provider = tryParseProviderExpression(node);
33
+ if (provider) {
34
+ replaceProviderWithNewApi({
35
+ sourceFile: sourceFile,
36
+ node: node,
37
+ provider: provider,
38
+ changeTracker,
39
+ });
40
+ return;
41
+ }
42
+ ts__default["default"].forEachChild(node, visitNode);
43
+ };
44
+ ts__default["default"].forEachChild(sourceFile, visitNode);
45
+ for (const change of changeTracker.recordChanges().get(sourceFile)?.values() ?? []) {
46
+ rewriteFn(change.start, change.removeLength ?? 0, change.text);
47
+ }
48
+ }
49
+ function replaceProviderWithNewApi({ sourceFile, node, provider, changeTracker, }) {
50
+ const { initializerCode, importInject, provideInitializerFunctionName, initializerToken } = provider;
51
+ const initializerTokenSpecifier = imports.getImportSpecifier(sourceFile, angularCoreModule, initializerToken);
52
+ // The token doesn't come from `@angular/core`.
53
+ if (!initializerTokenSpecifier) {
54
+ return;
55
+ }
56
+ // Replace the provider with the new provide function.
57
+ changeTracker.replaceText(sourceFile, node.getStart(), node.getWidth(), `${provideInitializerFunctionName}(${initializerCode})`);
58
+ // Import declaration and named imports are necessarily there.
59
+ const namedImports = nodes.closestNode(initializerTokenSpecifier, ts__default["default"].isNamedImports);
60
+ // `provide*Initializer` function is already imported.
61
+ const hasProvideInitializeFunction = namedImports.elements.some((element) => element.name.getText() === provideInitializerFunctionName);
62
+ const newNamedImports = ts__default["default"].factory.updateNamedImports(namedImports, [
63
+ // Remove the `*_INITIALIZER` token from imports.
64
+ ...namedImports.elements.filter((element) => element !== initializerTokenSpecifier),
65
+ // Add the `inject` function to imports if needed.
66
+ ...(importInject ? [createImportSpecifier('inject')] : []),
67
+ // Add the `provide*Initializer` function to imports.
68
+ ...(!hasProvideInitializeFunction
69
+ ? [createImportSpecifier(provideInitializerFunctionName)]
70
+ : []),
71
+ ]);
72
+ changeTracker.replaceNode(namedImports, newNamedImports);
73
+ }
74
+ function createImportSpecifier(name) {
75
+ return ts__default["default"].factory.createImportSpecifier(false, undefined, ts__default["default"].factory.createIdentifier(name));
76
+ }
77
+ function tryParseProviderExpression(node) {
78
+ if (!ts__default["default"].isObjectLiteralExpression(node)) {
79
+ return;
80
+ }
81
+ let deps = [];
82
+ let initializerToken;
83
+ let useExisting;
84
+ let useFactory;
85
+ let useValue;
86
+ let multi = false;
87
+ for (const property of node.properties) {
88
+ if (!ts__default["default"].isPropertyAssignment(property) || !ts__default["default"].isIdentifier(property.name)) {
89
+ continue;
90
+ }
91
+ switch (property.name.text) {
92
+ case 'deps':
93
+ if (ts__default["default"].isArrayLiteralExpression(property.initializer)) {
94
+ deps = property.initializer.elements.map((el) => el.getText());
95
+ }
96
+ break;
97
+ case 'provide':
98
+ initializerToken = property.initializer.getText();
99
+ break;
100
+ case 'useExisting':
101
+ useExisting = property.initializer;
102
+ break;
103
+ case 'useFactory':
104
+ useFactory = property.initializer;
105
+ break;
106
+ case 'useValue':
107
+ useValue = property.initializer;
108
+ break;
109
+ case 'multi':
110
+ multi = property.initializer.kind === ts__default["default"].SyntaxKind.TrueKeyword;
111
+ break;
112
+ }
113
+ }
114
+ if (!initializerToken || !multi) {
115
+ return;
116
+ }
117
+ const provideInitializerFunctionName = initializerTokenToFunctionMap.get(initializerToken);
118
+ if (!provideInitializerFunctionName) {
119
+ return;
120
+ }
121
+ const info = {
122
+ initializerToken,
123
+ provideInitializerFunctionName,
124
+ importInject: false,
125
+ };
126
+ if (useExisting) {
127
+ return {
128
+ ...info,
129
+ importInject: true,
130
+ initializerCode: `() => inject(${useExisting.getText()})()`,
131
+ };
132
+ }
133
+ if (useFactory) {
134
+ const args = deps.map((dep) => `inject(${dep})`);
135
+ return {
136
+ ...info,
137
+ importInject: deps.length > 0,
138
+ initializerCode: `() => { return (${useFactory.getText()})(${args.join(', ')}); }`,
139
+ };
140
+ }
141
+ if (useValue) {
142
+ return { ...info, initializerCode: useValue.getText() };
143
+ }
144
+ return;
145
+ }
146
+ const angularCoreModule = '@angular/core';
147
+ const initializerTokenToFunctionMap = new Map([
148
+ ['APP_INITIALIZER', 'provideAppInitializer'],
149
+ ['ENVIRONMENT_INITIALIZER', 'provideEnvironmentInitializer'],
150
+ ['PLATFORM_INITIALIZER', 'providePlatformInitializer'],
151
+ ]);
152
+
153
+ function migrate() {
154
+ return async (tree) => {
155
+ const { buildPaths, testPaths } = await project_tsconfig_paths.getProjectTsConfigPaths(tree);
156
+ const basePath = process.cwd();
157
+ const allPaths = [...buildPaths, ...testPaths];
158
+ if (!allPaths.length) {
159
+ throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run the provide initializer migration.');
160
+ }
161
+ for (const tsconfigPath of allPaths) {
162
+ runMigration(tree, tsconfigPath, basePath);
163
+ }
164
+ };
165
+ }
166
+ function runMigration(tree, tsconfigPath, basePath) {
167
+ const program = compiler_host.createMigrationProgram(tree, tsconfigPath, basePath);
168
+ const sourceFiles = program
169
+ .getSourceFiles()
170
+ .filter((sourceFile) => compiler_host.canMigrateFile(basePath, sourceFile, program));
171
+ for (const sourceFile of sourceFiles) {
172
+ let update = null;
173
+ const rewriter = (startPos, width, text) => {
174
+ if (update === null) {
175
+ // Lazily initialize update, because most files will not require migration.
176
+ update = tree.beginUpdate(p.relative(basePath, sourceFile.fileName));
177
+ }
178
+ update.remove(startPos, width);
179
+ if (text !== null) {
180
+ update.insertLeft(startPos, text);
181
+ }
182
+ };
183
+ migrateFile(sourceFile, rewriter);
184
+ if (update !== null) {
185
+ tree.commitUpdate(update);
186
+ }
187
+ }
188
+ }
189
+
190
+ exports.migrate = migrate;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-next.8
3
+ * @license Angular v19.0.0-rc.0
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-9a4d0c2b.js');
15
- var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
14
+ var compiler_host = require('./compiler_host-f54f8309.js');
15
+ var project_tsconfig_paths = require('./project_tsconfig_paths-6c9cde78.js');
16
16
  var ts = require('typescript');
17
- require('./checker-e68dd7ce.js');
17
+ require('./checker-2451e7c5.js');
18
18
  require('os');
19
19
  require('module');
20
20
  require('url');