@angular/core 19.0.0-next.10 → 19.0.0-next.11
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 +13205 -11798
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -1
- package/fesm2022/primitives/signals.mjs +8 -6
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +72 -4
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +4 -4
- package/index.d.ts +527 -51
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +3 -1
- package/rxjs-interop/index.d.ts +32 -1
- package/schematics/bundles/{checker-77660732.js → checker-51c08a1b.js} +112 -97
- package/schematics/bundles/{compiler_host-81f430d9.js → compiler_host-d7f120f0.js} +2 -2
- package/schematics/bundles/control-flow-migration.js +3 -3
- package/schematics/bundles/explicit-standalone-flag.js +6 -4
- package/schematics/bundles/imports-4ac08251.js +1 -1
- package/schematics/bundles/{group_replacements-1f48eff7.js → index-f7b283e6.js} +247 -1649
- package/schematics/bundles/inject-migration.js +7 -6
- package/schematics/bundles/leading_space-d190b83b.js +1 -1
- package/schematics/bundles/migrate_ts_type_references-b2b55f62.js +1448 -0
- package/schematics/bundles/{nodes-0e7d45ca.js → ng_decorators-4579dec6.js} +1 -14
- package/schematics/bundles/nodes-a535b2be.js +27 -0
- package/schematics/bundles/output-migration.js +7295 -0
- package/schematics/bundles/pending-tasks.js +3 -3
- package/schematics/bundles/{program-1413936a.js → program-6e6520d8.js} +40 -18
- package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
- package/schematics/bundles/provide-initializer.js +190 -0
- package/schematics/bundles/route-lazy-loading.js +3 -3
- package/schematics/bundles/signal-input-migration.js +73 -60
- package/schematics/bundles/signal-queries-migration.js +119 -90
- package/schematics/bundles/signals.js +54 -0
- package/schematics/bundles/standalone-migration.js +12 -11
- 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/signals/schema.json +65 -0
- package/testing/index.d.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-next.
|
|
3
|
+
* @license Angular v19.0.0-next.11
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -11,11 +11,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
var schematics = require('@angular-devkit/schematics');
|
|
12
12
|
var p = require('path');
|
|
13
13
|
var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
|
|
14
|
-
var compiler_host = require('./compiler_host-
|
|
14
|
+
var compiler_host = require('./compiler_host-d7f120f0.js');
|
|
15
15
|
var ts = require('typescript');
|
|
16
16
|
var imports = require('./imports-4ac08251.js');
|
|
17
17
|
require('@angular-devkit/core');
|
|
18
|
-
require('./checker-
|
|
18
|
+
require('./checker-51c08a1b.js');
|
|
19
19
|
require('os');
|
|
20
20
|
require('fs');
|
|
21
21
|
require('module');
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-next.
|
|
3
|
+
* @license Angular v19.0.0-next.11
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
var checker = require('./checker-
|
|
9
|
+
var checker = require('./checker-51c08a1b.js');
|
|
10
10
|
var ts = require('typescript');
|
|
11
11
|
var p = require('path');
|
|
12
12
|
require('os');
|
|
@@ -930,7 +930,7 @@ const MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION = '18.0.0';
|
|
|
930
930
|
function compileDeclareClassMetadata(metadata) {
|
|
931
931
|
const definitionMap = new checker.DefinitionMap();
|
|
932
932
|
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
933
|
-
definitionMap.set('version', checker.literal('19.0.0-next.
|
|
933
|
+
definitionMap.set('version', checker.literal('19.0.0-next.11'));
|
|
934
934
|
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
935
935
|
definitionMap.set('type', metadata.type);
|
|
936
936
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -948,7 +948,7 @@ function compileComponentDeclareClassMetadata(metadata, dependencies) {
|
|
|
948
948
|
callbackReturnDefinitionMap.set('ctorParameters', metadata.ctorParameters ?? checker.literal(null));
|
|
949
949
|
callbackReturnDefinitionMap.set('propDecorators', metadata.propDecorators ?? checker.literal(null));
|
|
950
950
|
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_DEFER_SUPPORT_VERSION));
|
|
951
|
-
definitionMap.set('version', checker.literal('19.0.0-next.
|
|
951
|
+
definitionMap.set('version', checker.literal('19.0.0-next.11'));
|
|
952
952
|
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
953
953
|
definitionMap.set('type', metadata.type);
|
|
954
954
|
definitionMap.set('resolveDeferredDeps', compileComponentMetadataAsyncResolver(dependencies));
|
|
@@ -1043,7 +1043,7 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
1043
1043
|
const definitionMap = new checker.DefinitionMap();
|
|
1044
1044
|
const minVersion = getMinimumVersionForPartialOutput(meta);
|
|
1045
1045
|
definitionMap.set('minVersion', checker.literal(minVersion));
|
|
1046
|
-
definitionMap.set('version', checker.literal('19.0.0-next.
|
|
1046
|
+
definitionMap.set('version', checker.literal('19.0.0-next.11'));
|
|
1047
1047
|
// e.g. `type: MyDirective`
|
|
1048
1048
|
definitionMap.set('type', meta.type.value);
|
|
1049
1049
|
if (meta.isStandalone !== undefined) {
|
|
@@ -1462,7 +1462,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
1462
1462
|
function compileDeclareFactoryFunction(meta) {
|
|
1463
1463
|
const definitionMap = new checker.DefinitionMap();
|
|
1464
1464
|
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
1465
|
-
definitionMap.set('version', checker.literal('19.0.0-next.
|
|
1465
|
+
definitionMap.set('version', checker.literal('19.0.0-next.11'));
|
|
1466
1466
|
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1467
1467
|
definitionMap.set('type', meta.type.value);
|
|
1468
1468
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -1497,7 +1497,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
1497
1497
|
function createInjectableDefinitionMap(meta) {
|
|
1498
1498
|
const definitionMap = new checker.DefinitionMap();
|
|
1499
1499
|
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
1500
|
-
definitionMap.set('version', checker.literal('19.0.0-next.
|
|
1500
|
+
definitionMap.set('version', checker.literal('19.0.0-next.11'));
|
|
1501
1501
|
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1502
1502
|
definitionMap.set('type', meta.type.value);
|
|
1503
1503
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -1548,7 +1548,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
1548
1548
|
function createInjectorDefinitionMap(meta) {
|
|
1549
1549
|
const definitionMap = new checker.DefinitionMap();
|
|
1550
1550
|
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
1551
|
-
definitionMap.set('version', checker.literal('19.0.0-next.
|
|
1551
|
+
definitionMap.set('version', checker.literal('19.0.0-next.11'));
|
|
1552
1552
|
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1553
1553
|
definitionMap.set('type', meta.type.value);
|
|
1554
1554
|
definitionMap.set('providers', meta.providers);
|
|
@@ -1581,7 +1581,7 @@ function createNgModuleDefinitionMap(meta) {
|
|
|
1581
1581
|
throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
|
|
1582
1582
|
}
|
|
1583
1583
|
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
1584
|
-
definitionMap.set('version', checker.literal('19.0.0-next.
|
|
1584
|
+
definitionMap.set('version', checker.literal('19.0.0-next.11'));
|
|
1585
1585
|
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1586
1586
|
definitionMap.set('type', meta.type.value);
|
|
1587
1587
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -1632,7 +1632,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
1632
1632
|
function createPipeDefinitionMap(meta) {
|
|
1633
1633
|
const definitionMap = new checker.DefinitionMap();
|
|
1634
1634
|
definitionMap.set('minVersion', checker.literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
1635
|
-
definitionMap.set('version', checker.literal('19.0.0-next.
|
|
1635
|
+
definitionMap.set('version', checker.literal('19.0.0-next.11'));
|
|
1636
1636
|
definitionMap.set('ngImport', checker.importExpr(checker.Identifiers.core));
|
|
1637
1637
|
// e.g. `type: MyPipe`
|
|
1638
1638
|
definitionMap.set('type', meta.type.value);
|
|
@@ -5951,6 +5951,8 @@ function makeUnknownComponentDeferredImportDiagnostic(ref, rawExpr) {
|
|
|
5951
5951
|
return checker.makeDiagnostic(checker.ErrorCode.COMPONENT_UNKNOWN_DEFERRED_IMPORT, getDiagnosticNode(ref, rawExpr), `Component deferred imports must be standalone components, directives or pipes.`);
|
|
5952
5952
|
}
|
|
5953
5953
|
|
|
5954
|
+
/** Value used to mark a module whose scope is in the process of being resolved. */
|
|
5955
|
+
const IN_PROGRESS_RESOLUTION = {};
|
|
5954
5956
|
/**
|
|
5955
5957
|
* A registry which collects information about NgModules, Directives, Components, and Pipes which
|
|
5956
5958
|
* are local (declared in the ts.Program being compiled), and can produce `LocalModuleScope`s
|
|
@@ -6122,8 +6124,12 @@ class LocalModuleScopeRegistry {
|
|
|
6122
6124
|
*/
|
|
6123
6125
|
getScopeOfModuleReference(ref) {
|
|
6124
6126
|
if (this.cache.has(ref.node)) {
|
|
6125
|
-
|
|
6127
|
+
const cachedValue = this.cache.get(ref.node);
|
|
6128
|
+
if (cachedValue !== IN_PROGRESS_RESOLUTION) {
|
|
6129
|
+
return cachedValue;
|
|
6130
|
+
}
|
|
6126
6131
|
}
|
|
6132
|
+
this.cache.set(ref.node, IN_PROGRESS_RESOLUTION);
|
|
6127
6133
|
// Seal the registry to protect the integrity of the `LocalModuleScope` cache.
|
|
6128
6134
|
this.sealed = true;
|
|
6129
6135
|
// `ref` should be an NgModule previously added to the registry. If not, a scope for it
|
|
@@ -6168,13 +6174,18 @@ class LocalModuleScopeRegistry {
|
|
|
6168
6174
|
for (const decl of ngModule.imports) {
|
|
6169
6175
|
const importScope = this.getExportedScope(decl, diagnostics, ref.node, 'import');
|
|
6170
6176
|
if (importScope !== null) {
|
|
6171
|
-
if (importScope === 'invalid' ||
|
|
6177
|
+
if (importScope === 'invalid' ||
|
|
6178
|
+
importScope === 'cycle' ||
|
|
6179
|
+
importScope.exported.isPoisoned) {
|
|
6172
6180
|
// An import was an NgModule but contained errors of its own. Record this as an error too,
|
|
6173
6181
|
// because this scope is always going to be incorrect if one of its imports could not be
|
|
6174
6182
|
// read.
|
|
6175
|
-
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawImports, 'import'));
|
|
6176
6183
|
isPoisoned = true;
|
|
6177
|
-
|
|
6184
|
+
// Prevent the module from reporting a diagnostic about itself when there's a cycle.
|
|
6185
|
+
if (importScope !== 'cycle') {
|
|
6186
|
+
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawImports, 'import'));
|
|
6187
|
+
}
|
|
6188
|
+
if (importScope === 'invalid' || importScope === 'cycle') {
|
|
6178
6189
|
continue;
|
|
6179
6190
|
}
|
|
6180
6191
|
}
|
|
@@ -6260,13 +6271,18 @@ class LocalModuleScopeRegistry {
|
|
|
6260
6271
|
for (const decl of ngModule.exports) {
|
|
6261
6272
|
// Attempt to resolve decl as an NgModule.
|
|
6262
6273
|
const exportScope = this.getExportedScope(decl, diagnostics, ref.node, 'export');
|
|
6263
|
-
if (exportScope === 'invalid' ||
|
|
6274
|
+
if (exportScope === 'invalid' ||
|
|
6275
|
+
exportScope === 'cycle' ||
|
|
6276
|
+
(exportScope !== null && exportScope.exported.isPoisoned)) {
|
|
6264
6277
|
// An export was an NgModule but contained errors of its own. Record this as an error too,
|
|
6265
6278
|
// because this scope is always going to be incorrect if one of its exports could not be
|
|
6266
6279
|
// read.
|
|
6267
|
-
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawExports, 'export'));
|
|
6268
6280
|
isPoisoned = true;
|
|
6269
|
-
|
|
6281
|
+
// Prevent the module from reporting a diagnostic about itself when there's a cycle.
|
|
6282
|
+
if (exportScope !== 'cycle') {
|
|
6283
|
+
diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawExports, 'export'));
|
|
6284
|
+
}
|
|
6285
|
+
if (exportScope === 'invalid' || exportScope === 'cycle') {
|
|
6270
6286
|
continue;
|
|
6271
6287
|
}
|
|
6272
6288
|
}
|
|
@@ -6371,6 +6387,12 @@ class LocalModuleScopeRegistry {
|
|
|
6371
6387
|
return this.dependencyScopeReader.resolve(ref);
|
|
6372
6388
|
}
|
|
6373
6389
|
else {
|
|
6390
|
+
if (this.cache.get(ref.node) === IN_PROGRESS_RESOLUTION) {
|
|
6391
|
+
diagnostics.push(checker.makeDiagnostic(type === 'import'
|
|
6392
|
+
? checker.ErrorCode.NGMODULE_INVALID_IMPORT
|
|
6393
|
+
: checker.ErrorCode.NGMODULE_INVALID_EXPORT, checker.identifierOfNode(ref.node) || ref.node, `NgModule "${type}" field contains a cycle`));
|
|
6394
|
+
return 'cycle';
|
|
6395
|
+
}
|
|
6374
6396
|
// The NgModule is declared locally in the current program. Resolve it from the registry.
|
|
6375
6397
|
return this.getScopeOfModuleReference(ref);
|
|
6376
6398
|
}
|
|
@@ -19749,7 +19771,7 @@ var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
|
|
|
19749
19771
|
* @param minVersion Minimum required version for the feature.
|
|
19750
19772
|
*/
|
|
19751
19773
|
function coreVersionSupportsFeature(coreVersion, minVersion) {
|
|
19752
|
-
// A version of `19.0.0-next.
|
|
19774
|
+
// A version of `19.0.0-next.11` usually means that core is at head so it supports
|
|
19753
19775
|
// all features. Use string interpolation prevent the placeholder from being replaced
|
|
19754
19776
|
// with the current version during build time.
|
|
19755
19777
|
if (coreVersion === `0.0.0-${'PLACEHOLDER'}`) {
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @license Angular v19.0.0-next.11
|
|
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-d7f120f0.js');
|
|
15
|
+
var ts = require('typescript');
|
|
16
|
+
var imports = require('./imports-4ac08251.js');
|
|
17
|
+
var nodes = require('./nodes-a535b2be.js');
|
|
18
|
+
require('@angular-devkit/core');
|
|
19
|
+
require('./checker-51c08a1b.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.
|
|
3
|
+
* @license Angular v19.0.0-next.11
|
|
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-d7f120f0.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-51c08a1b.js');
|
|
18
18
|
require('os');
|
|
19
19
|
require('module');
|
|
20
20
|
require('url');
|