@angular/core 19.1.0-next.3 → 19.1.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.
- package/LICENSE +1 -1
- package/fesm2022/core.mjs +516 -266
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -24
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +5 -5
- package/index.d.ts +169 -17
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/bundles/apply_import_manager-6508401d.js +732 -0
- package/schematics/bundles/{checker-228cb8a8.js → checker-24b68d23.js} +75 -27
- package/schematics/bundles/cleanup-unused-imports.js +295 -0
- package/schematics/bundles/{compiler_host-fc806dbe.js → compiler_host-5f693799.js} +2 -2
- package/schematics/bundles/control-flow-migration.js +3 -3
- package/schematics/bundles/explicit-standalone-flag.js +3 -3
- package/schematics/bundles/imports-abe29092.js +1 -1
- package/schematics/bundles/{combine_units-5d6a7099.js → index-767e341d.js} +10 -723
- package/schematics/bundles/index-b1033cf0.js +30 -0
- package/schematics/bundles/inject-migration.js +3 -3
- package/schematics/bundles/leading_space-d190b83b.js +1 -1
- package/schematics/bundles/{migrate_ts_type_references-d02c6750.js → migrate_ts_type_references-bc7d8784.js} +29 -28
- package/schematics/bundles/nodes-a9f0b985.js +1 -1
- package/schematics/bundles/output-migration.js +26 -25
- package/schematics/bundles/pending-tasks.js +3 -3
- package/schematics/bundles/{program-1591ec8f.js → program-c810a4c2.js} +81 -40
- package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
- package/schematics/bundles/provide-initializer.js +3 -3
- package/schematics/bundles/route-lazy-loading.js +3 -3
- package/schematics/bundles/signal-input-migration.js +31 -30
- package/schematics/bundles/signal-queries-migration.js +48 -47
- package/schematics/bundles/signals.js +6 -5
- package/schematics/bundles/standalone-migration.js +9 -25
- package/schematics/collection.json +5 -0
- package/schematics/ng-generate/cleanup-unused-imports/schema.json +7 -0
- package/testing/index.d.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.1.0-
|
|
3
|
+
* @license Angular v19.1.0-rc.0
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
10
|
|
|
11
11
|
var schematics = require('@angular-devkit/schematics');
|
|
12
|
-
var migrate_ts_type_references = require('./migrate_ts_type_references-
|
|
12
|
+
var migrate_ts_type_references = require('./migrate_ts_type_references-bc7d8784.js');
|
|
13
13
|
var ts = require('typescript');
|
|
14
14
|
require('os');
|
|
15
|
-
var checker = require('./checker-
|
|
16
|
-
var program = require('./program-
|
|
15
|
+
var checker = require('./checker-24b68d23.js');
|
|
16
|
+
var program = require('./program-c810a4c2.js');
|
|
17
17
|
require('path');
|
|
18
|
-
var
|
|
18
|
+
var apply_import_manager = require('./apply_import_manager-6508401d.js');
|
|
19
|
+
var index = require('./index-767e341d.js');
|
|
19
20
|
var assert = require('assert');
|
|
20
21
|
var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
|
|
21
22
|
require('./leading_space-d190b83b.js');
|
|
@@ -107,7 +108,7 @@ function getInputDescriptor(hostOrInfo, node) {
|
|
|
107
108
|
className = node.parent.name?.text ?? '<anonymous>';
|
|
108
109
|
}
|
|
109
110
|
const info = hostOrInfo instanceof MigrationHost ? hostOrInfo.programInfo : hostOrInfo;
|
|
110
|
-
const file =
|
|
111
|
+
const file = apply_import_manager.projectFile(node.getSourceFile(), info);
|
|
111
112
|
// Inputs may be detected in `.d.ts` files. Ensure that if the file IDs
|
|
112
113
|
// match regardless of extension. E.g. `/google3/blaze-out/bin/my_file.ts` should
|
|
113
114
|
// have the same ID as `/google3/my_file.ts`.
|
|
@@ -126,11 +127,11 @@ function attemptRetrieveInputFromSymbol(programInfo, memberSymbol, knownInputs)
|
|
|
126
127
|
// Even for declared classes from `.d.ts`, the value declaration
|
|
127
128
|
// should exist and point to the property declaration.
|
|
128
129
|
if (memberSymbol.valueDeclaration !== undefined &&
|
|
129
|
-
|
|
130
|
+
index.isInputContainerNode(memberSymbol.valueDeclaration)) {
|
|
130
131
|
const member = memberSymbol.valueDeclaration;
|
|
131
132
|
// If the member itself is an input that is being migrated, we
|
|
132
133
|
// do not need to check, as overriding would be fine then— like before.
|
|
133
|
-
const memberInputDescr =
|
|
134
|
+
const memberInputDescr = index.isInputContainerNode(member)
|
|
134
135
|
? getInputDescriptor(programInfo, member)
|
|
135
136
|
: null;
|
|
136
137
|
return memberInputDescr !== null ? (knownInputs.get(memberInputDescr) ?? null) : null;
|
|
@@ -186,7 +187,7 @@ class KnownInputs {
|
|
|
186
187
|
}
|
|
187
188
|
const directiveInfo = this._classToDirectiveInfo.get(data.node.parent);
|
|
188
189
|
const inputInfo = {
|
|
189
|
-
file:
|
|
190
|
+
file: apply_import_manager.projectFile(data.node.getSourceFile(), this.programInfo),
|
|
190
191
|
metadata: data.metadata,
|
|
191
192
|
descriptor: data.descriptor,
|
|
192
193
|
container: directiveInfo,
|
|
@@ -326,7 +327,7 @@ function extractDecoratorInput(node, host, reflector, metadataReader, evaluator)
|
|
|
326
327
|
* part of a `.d.ts` file.
|
|
327
328
|
*/
|
|
328
329
|
function extractDtsInput(node, metadataReader) {
|
|
329
|
-
if (!
|
|
330
|
+
if (!index.isInputContainerNode(node) ||
|
|
330
331
|
!ts__default["default"].isIdentifier(node.name) ||
|
|
331
332
|
!node.getSourceFile().isDeclarationFile) {
|
|
332
333
|
return null;
|
|
@@ -369,7 +370,7 @@ function extractDtsInput(node, metadataReader) {
|
|
|
369
370
|
* directly defined inside a source file (`.ts`).
|
|
370
371
|
*/
|
|
371
372
|
function extractSourceCodeInput(node, host, reflector, evaluator) {
|
|
372
|
-
if (!
|
|
373
|
+
if (!index.isInputContainerNode(node) ||
|
|
373
374
|
!ts__default["default"].isIdentifier(node.name) ||
|
|
374
375
|
node.getSourceFile().isDeclarationFile) {
|
|
375
376
|
return null;
|
|
@@ -602,7 +603,7 @@ function pass1__IdentifySourceFileAndDeclarationInputs(sf, host, checker, reflec
|
|
|
602
603
|
const visitor = (node) => {
|
|
603
604
|
const decoratorInput = extractDecoratorInput(node, host, reflector, dtsMetadataReader, evaluator);
|
|
604
605
|
if (decoratorInput !== null) {
|
|
605
|
-
assert__default["default"](
|
|
606
|
+
assert__default["default"](index.isInputContainerNode(node), 'Expected input to be declared on accessor or property.');
|
|
606
607
|
const inputDescr = getInputDescriptor(host, node);
|
|
607
608
|
// track all inputs, even from declarations for reference resolution.
|
|
608
609
|
knownDecoratorInputs.register({ descriptor: inputDescr, metadata: decoratorInput, node });
|
|
@@ -673,7 +674,7 @@ function pass3__checkIncompatiblePatterns(host, inheritanceGraph, checker$1, gro
|
|
|
673
674
|
* such.
|
|
674
675
|
*/
|
|
675
676
|
function pass2_IdentifySourceFileReferences(programInfo, checker, reflector, resourceLoader, evaluator, templateTypeChecker, groupedTsAstVisitor, knownInputs, result, fieldNamesToConsiderForReferenceLookup) {
|
|
676
|
-
groupedTsAstVisitor.register(
|
|
677
|
+
groupedTsAstVisitor.register(index.createFindAllSourceFileReferencesVisitor(programInfo, checker, reflector, resourceLoader, evaluator, templateTypeChecker, knownInputs, fieldNamesToConsiderForReferenceLookup, result).visitor);
|
|
677
678
|
}
|
|
678
679
|
|
|
679
680
|
/**
|
|
@@ -711,13 +712,13 @@ function executeAnalysisPhase(host, knownInputs, result, { sourceFiles, fullProg
|
|
|
711
712
|
pass2And3SourceFileVisitor.execute();
|
|
712
713
|
// Determine incompatible inputs based on resolved references.
|
|
713
714
|
for (const reference of result.references) {
|
|
714
|
-
if (
|
|
715
|
+
if (index.isTsReference(reference) && reference.from.isWrite) {
|
|
715
716
|
knownInputs.markFieldIncompatible(reference.target, {
|
|
716
717
|
reason: migrate_ts_type_references.FieldIncompatibilityReason.WriteAssignment,
|
|
717
718
|
context: reference.from.node,
|
|
718
719
|
});
|
|
719
720
|
}
|
|
720
|
-
if (
|
|
721
|
+
if (index.isTemplateReference(reference) || index.isHostBindingReference(reference)) {
|
|
721
722
|
if (reference.from.isWrite) {
|
|
722
723
|
knownInputs.markFieldIncompatible(reference.target, {
|
|
723
724
|
reason: migrate_ts_type_references.FieldIncompatibilityReason.WriteAssignment,
|
|
@@ -728,7 +729,7 @@ function executeAnalysisPhase(host, knownInputs, result, { sourceFiles, fullProg
|
|
|
728
729
|
}
|
|
729
730
|
// TODO: Remove this when we support signal narrowing in templates.
|
|
730
731
|
// https://github.com/angular/angular/pull/55456.
|
|
731
|
-
if (
|
|
732
|
+
if (index.isTemplateReference(reference)) {
|
|
732
733
|
if (reference.from.isLikelyPartOfNarrowing) {
|
|
733
734
|
knownInputs.markFieldIncompatible(reference.target, {
|
|
734
735
|
reason: migrate_ts_type_references.FieldIncompatibilityReason.PotentiallyNarrowedInTemplateButNoSupportYet,
|
|
@@ -1040,7 +1041,7 @@ function convertToSignalInput(node, { resolvedMetadata: metadata, resolvedType,
|
|
|
1040
1041
|
if (leadingTodoText !== null) {
|
|
1041
1042
|
replacements.push(migrate_ts_type_references.insertPrecedingLine(node, info, '// TODO: Notes from signal input migration:'), ...migrate_ts_type_references.cutStringToLineLimit(leadingTodoText, 70).map((line) => migrate_ts_type_references.insertPrecedingLine(node, info, `// ${line}`)));
|
|
1042
1043
|
}
|
|
1043
|
-
replacements.push(new
|
|
1044
|
+
replacements.push(new apply_import_manager.Replacement(apply_import_manager.projectFile(node.getSourceFile(), info), new apply_import_manager.TextUpdate({
|
|
1044
1045
|
position: node.getStart(),
|
|
1045
1046
|
end: node.getEnd(),
|
|
1046
1047
|
toInsert: newPropertyText,
|
|
@@ -1120,7 +1121,7 @@ function pass6__migrateInputDeclarations(host, checker, result, knownInputs, imp
|
|
|
1120
1121
|
* previous migrate phases.
|
|
1121
1122
|
*/
|
|
1122
1123
|
function pass10_applyImportManager(importManager, result, sourceFiles, info) {
|
|
1123
|
-
|
|
1124
|
+
apply_import_manager.applyImportManagerChanges(importManager, result.replacements, sourceFiles, info);
|
|
1124
1125
|
}
|
|
1125
1126
|
|
|
1126
1127
|
/**
|
|
@@ -1141,7 +1142,7 @@ function pass7__migrateTemplateReferences(host, references) {
|
|
|
1141
1142
|
const seenFileReferences = new Set();
|
|
1142
1143
|
for (const reference of references) {
|
|
1143
1144
|
// This pass only deals with HTML template references.
|
|
1144
|
-
if (!
|
|
1145
|
+
if (!index.isTemplateReference(reference)) {
|
|
1145
1146
|
continue;
|
|
1146
1147
|
}
|
|
1147
1148
|
// Skip references to incompatible inputs.
|
|
@@ -1158,7 +1159,7 @@ function pass7__migrateTemplateReferences(host, references) {
|
|
|
1158
1159
|
const appendText = reference.from.isObjectShorthandExpression
|
|
1159
1160
|
? `: ${reference.from.read.name}()`
|
|
1160
1161
|
: `()`;
|
|
1161
|
-
host.replacements.push(new
|
|
1162
|
+
host.replacements.push(new apply_import_manager.Replacement(reference.from.templateFile, new apply_import_manager.TextUpdate({
|
|
1162
1163
|
position: reference.from.read.sourceSpan.end,
|
|
1163
1164
|
end: reference.from.read.sourceSpan.end,
|
|
1164
1165
|
toInsert: appendText,
|
|
@@ -1174,7 +1175,7 @@ function pass8__migrateHostBindings(host, references, info) {
|
|
|
1174
1175
|
const seenReferences = new WeakMap();
|
|
1175
1176
|
for (const reference of references) {
|
|
1176
1177
|
// This pass only deals with host binding references.
|
|
1177
|
-
if (!
|
|
1178
|
+
if (!index.isHostBindingReference(reference)) {
|
|
1178
1179
|
continue;
|
|
1179
1180
|
}
|
|
1180
1181
|
// Skip references to incompatible inputs.
|
|
@@ -1198,7 +1199,7 @@ function pass8__migrateHostBindings(host, references, info) {
|
|
|
1198
1199
|
const appendText = reference.from.isObjectShorthandExpression
|
|
1199
1200
|
? `: ${reference.from.read.name}()`
|
|
1200
1201
|
: `()`;
|
|
1201
|
-
host.replacements.push(new
|
|
1202
|
+
host.replacements.push(new apply_import_manager.Replacement(apply_import_manager.projectFile(bindingField.getSourceFile(), info), new apply_import_manager.TextUpdate({ position: readEndPos, end: readEndPos, toInsert: appendText })));
|
|
1202
1203
|
}
|
|
1203
1204
|
}
|
|
1204
1205
|
|
|
@@ -1261,7 +1262,7 @@ function filterIncompatibilitiesForBestEffortMode(knownInputs) {
|
|
|
1261
1262
|
* Tsurge migration for migrating Angular `@Input()` declarations to
|
|
1262
1263
|
* signal inputs, with support for batch execution.
|
|
1263
1264
|
*/
|
|
1264
|
-
class SignalInputMigration extends
|
|
1265
|
+
class SignalInputMigration extends apply_import_manager.TsurgeComplexMigration {
|
|
1265
1266
|
config;
|
|
1266
1267
|
upgradedAnalysisPhaseResults = null;
|
|
1267
1268
|
constructor(config = {}) {
|
|
@@ -1270,7 +1271,7 @@ class SignalInputMigration extends combine_units.TsurgeComplexMigration {
|
|
|
1270
1271
|
}
|
|
1271
1272
|
// Override the default program creation, to add extra flags.
|
|
1272
1273
|
createProgram(tsconfigAbsPath, fs) {
|
|
1273
|
-
return
|
|
1274
|
+
return apply_import_manager.createBaseProgramInfo(tsconfigAbsPath, fs, {
|
|
1274
1275
|
_compilePoisonedComponents: true,
|
|
1275
1276
|
// We want to migrate non-exported classes too.
|
|
1276
1277
|
compileNonExportedClasses: true,
|
|
@@ -1342,13 +1343,13 @@ class SignalInputMigration extends combine_units.TsurgeComplexMigration {
|
|
|
1342
1343
|
knownInputs,
|
|
1343
1344
|
};
|
|
1344
1345
|
}
|
|
1345
|
-
return
|
|
1346
|
+
return apply_import_manager.confirmAsSerializable(unitData);
|
|
1346
1347
|
}
|
|
1347
1348
|
async combine(unitA, unitB) {
|
|
1348
|
-
return
|
|
1349
|
+
return apply_import_manager.confirmAsSerializable(combineCompilationUnitData(unitA, unitB));
|
|
1349
1350
|
}
|
|
1350
1351
|
async globalMeta(combinedData) {
|
|
1351
|
-
return
|
|
1352
|
+
return apply_import_manager.confirmAsSerializable(convertToGlobalMeta(combinedData));
|
|
1352
1353
|
}
|
|
1353
1354
|
async migrate(globalMetadata, info, nonBatchData) {
|
|
1354
1355
|
const knownInputs = nonBatchData?.knownInputs ?? new KnownInputs(info, this.config);
|
|
@@ -1442,7 +1443,7 @@ function migrate(options) {
|
|
|
1442
1443
|
if (!buildPaths.length && !testPaths.length) {
|
|
1443
1444
|
throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run signal input migration.');
|
|
1444
1445
|
}
|
|
1445
|
-
const fs = new
|
|
1446
|
+
const fs = new apply_import_manager.DevkitMigrationFilesystem(tree);
|
|
1446
1447
|
checker.setFileSystem(fs);
|
|
1447
1448
|
const migration = new SignalInputMigration({
|
|
1448
1449
|
bestEffortMode: options.bestEffortMode,
|
|
@@ -1474,7 +1475,7 @@ function migrate(options) {
|
|
|
1474
1475
|
context.logger.info(``);
|
|
1475
1476
|
context.logger.info(`Processing analysis data between targets..`);
|
|
1476
1477
|
context.logger.info(``);
|
|
1477
|
-
const combined = await
|
|
1478
|
+
const combined = await apply_import_manager.synchronouslyCombineUnitData(migration, unitResults);
|
|
1478
1479
|
if (combined === null) {
|
|
1479
1480
|
context.logger.error('Migration failed unexpectedly with no analysis data');
|
|
1480
1481
|
return;
|
|
@@ -1484,7 +1485,7 @@ function migrate(options) {
|
|
|
1484
1485
|
for (const { info, tsconfigPath } of programInfos) {
|
|
1485
1486
|
context.logger.info(`Migrating: ${tsconfigPath}..`);
|
|
1486
1487
|
const { replacements } = await migration.migrate(globalMeta, info);
|
|
1487
|
-
const changesPerFile =
|
|
1488
|
+
const changesPerFile = apply_import_manager.groupReplacementsByFile(replacements);
|
|
1488
1489
|
for (const [file, changes] of changesPerFile) {
|
|
1489
1490
|
if (!replacementsPerFile.has(file)) {
|
|
1490
1491
|
replacementsPerFile.set(file, changes);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.1.0-
|
|
3
|
+
* @license Angular v19.1.0-rc.0
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -10,14 +10,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
10
10
|
|
|
11
11
|
var schematics = require('@angular-devkit/schematics');
|
|
12
12
|
var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
|
|
13
|
-
var
|
|
13
|
+
var apply_import_manager = require('./apply_import_manager-6508401d.js');
|
|
14
14
|
require('os');
|
|
15
15
|
var ts = require('typescript');
|
|
16
|
-
var checker = require('./checker-
|
|
17
|
-
var program = require('./program-
|
|
16
|
+
var checker = require('./checker-24b68d23.js');
|
|
17
|
+
var program = require('./program-c810a4c2.js');
|
|
18
18
|
require('path');
|
|
19
|
-
var migrate_ts_type_references = require('./migrate_ts_type_references-
|
|
19
|
+
var migrate_ts_type_references = require('./migrate_ts_type_references-bc7d8784.js');
|
|
20
20
|
var assert = require('assert');
|
|
21
|
+
var index = require('./index-767e341d.js');
|
|
21
22
|
require('@angular-devkit/core');
|
|
22
23
|
require('node:path/posix');
|
|
23
24
|
require('fs');
|
|
@@ -38,7 +39,7 @@ function migrateHostBindings(host, references, info) {
|
|
|
38
39
|
const seenReferences = new WeakMap();
|
|
39
40
|
for (const reference of references) {
|
|
40
41
|
// This pass only deals with host binding references.
|
|
41
|
-
if (!
|
|
42
|
+
if (!index.isHostBindingReference(reference)) {
|
|
42
43
|
continue;
|
|
43
44
|
}
|
|
44
45
|
// Skip references to incompatible inputs.
|
|
@@ -62,7 +63,7 @@ function migrateHostBindings(host, references, info) {
|
|
|
62
63
|
const appendText = reference.from.isObjectShorthandExpression
|
|
63
64
|
? `: ${reference.from.read.name}()`
|
|
64
65
|
: `()`;
|
|
65
|
-
host.replacements.push(new
|
|
66
|
+
host.replacements.push(new apply_import_manager.Replacement(apply_import_manager.projectFile(bindingField.getSourceFile(), info), new apply_import_manager.TextUpdate({ position: readEndPos, end: readEndPos, toInsert: appendText })));
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -74,7 +75,7 @@ function migrateTemplateReferences(host, references) {
|
|
|
74
75
|
const seenFileReferences = new Set();
|
|
75
76
|
for (const reference of references) {
|
|
76
77
|
// This pass only deals with HTML template references.
|
|
77
|
-
if (!
|
|
78
|
+
if (!index.isTemplateReference(reference)) {
|
|
78
79
|
continue;
|
|
79
80
|
}
|
|
80
81
|
// Skip references to incompatible inputs.
|
|
@@ -91,7 +92,7 @@ function migrateTemplateReferences(host, references) {
|
|
|
91
92
|
const appendText = reference.from.isObjectShorthandExpression
|
|
92
93
|
? `: ${reference.from.read.name}()`
|
|
93
94
|
: `()`;
|
|
94
|
-
host.replacements.push(new
|
|
95
|
+
host.replacements.push(new apply_import_manager.Replacement(reference.from.templateFile, new apply_import_manager.TextUpdate({
|
|
95
96
|
position: reference.from.read.sourceSpan.end,
|
|
96
97
|
end: reference.from.read.sourceSpan.end,
|
|
97
98
|
toInsert: appendText,
|
|
@@ -222,7 +223,7 @@ function computeReplacementsToMigrateQuery(node, metadata, importManager, info,
|
|
|
222
223
|
resolvedReadType === null && type !== undefined ? [type] : undefined, args);
|
|
223
224
|
const updated = ts__default["default"].factory.createPropertyDeclaration([ts__default["default"].factory.createModifier(ts__default["default"].SyntaxKind.ReadonlyKeyword)], node.name, undefined, undefined, call);
|
|
224
225
|
return [
|
|
225
|
-
new
|
|
226
|
+
new apply_import_manager.Replacement(apply_import_manager.projectFile(node.getSourceFile(), info), new apply_import_manager.TextUpdate({
|
|
226
227
|
position: node.getStart(),
|
|
227
228
|
end: node.getEnd(),
|
|
228
229
|
toInsert: printer.printNode(ts__default["default"].EmitHint.Unspecified, updated, sf),
|
|
@@ -263,7 +264,7 @@ function getUniqueIDForClassProperty(property, info) {
|
|
|
263
264
|
if (property.name === undefined) {
|
|
264
265
|
return null;
|
|
265
266
|
}
|
|
266
|
-
const id =
|
|
267
|
+
const id = apply_import_manager.projectFile(property.getSourceFile(), info).id.replace(/\.d\.ts$/, '.ts');
|
|
267
268
|
// Note: If a class is nested, there could be an ID clash.
|
|
268
269
|
// This is highly unlikely though, and this is not a problem because
|
|
269
270
|
// in such cases, there is even less chance there are any references to
|
|
@@ -387,7 +388,7 @@ class KnownQueries {
|
|
|
387
388
|
});
|
|
388
389
|
this.knownQueryIDs.set(id, { key: id, node: queryField });
|
|
389
390
|
const descriptor = { key: id, node: queryField };
|
|
390
|
-
const file =
|
|
391
|
+
const file = apply_import_manager.projectFile(queryField.getSourceFile(), this.info);
|
|
391
392
|
if (this.config.shouldMigrateQuery !== undefined &&
|
|
392
393
|
!this.config.shouldMigrateQuery(descriptor, file)) {
|
|
393
394
|
this.markFieldIncompatible(descriptor, {
|
|
@@ -501,7 +502,7 @@ function queryFunctionNameToDecorator(name) {
|
|
|
501
502
|
* E.g. whether `<my-read>.toArray` is detected.
|
|
502
503
|
*/
|
|
503
504
|
function checkTsReferenceAccessesField(ref, fieldName) {
|
|
504
|
-
const accessNode =
|
|
505
|
+
const accessNode = index.traverseAccess(ref.from.node);
|
|
505
506
|
// Check if the reference is part of a property access.
|
|
506
507
|
if (!ts__default["default"].isPropertyAccessExpression(accessNode.parent) ||
|
|
507
508
|
!ts__default["default"].isIdentifier(accessNode.parent.name)) {
|
|
@@ -570,7 +571,7 @@ function checkNonTsReferenceCallsField(ref, fieldName) {
|
|
|
570
571
|
}
|
|
571
572
|
|
|
572
573
|
function removeQueryListToArrayCall(ref, info, globalMetadata, knownQueries, replacements) {
|
|
573
|
-
if (!
|
|
574
|
+
if (!index.isHostBindingReference(ref) && !index.isTemplateReference(ref) && !index.isTsReference(ref)) {
|
|
574
575
|
return;
|
|
575
576
|
}
|
|
576
577
|
if (knownQueries.isFieldIncompatible(ref.target)) {
|
|
@@ -580,13 +581,13 @@ function removeQueryListToArrayCall(ref, info, globalMetadata, knownQueries, rep
|
|
|
580
581
|
return;
|
|
581
582
|
}
|
|
582
583
|
// TS references.
|
|
583
|
-
if (
|
|
584
|
+
if (index.isTsReference(ref)) {
|
|
584
585
|
const toArrayCallExpr = checkTsReferenceCallsField(ref, 'toArray');
|
|
585
586
|
if (toArrayCallExpr === null) {
|
|
586
587
|
return;
|
|
587
588
|
}
|
|
588
589
|
const toArrayExpr = toArrayCallExpr.expression;
|
|
589
|
-
replacements.push(new
|
|
590
|
+
replacements.push(new apply_import_manager.Replacement(apply_import_manager.projectFile(toArrayExpr.getSourceFile(), info), new apply_import_manager.TextUpdate({
|
|
590
591
|
// Delete from expression end to call end. E.g. `.toArray(<..>)`.
|
|
591
592
|
position: toArrayExpr.expression.getEnd(),
|
|
592
593
|
end: toArrayCallExpr.getEnd(),
|
|
@@ -599,9 +600,9 @@ function removeQueryListToArrayCall(ref, info, globalMetadata, knownQueries, rep
|
|
|
599
600
|
if (callExpr === null) {
|
|
600
601
|
return;
|
|
601
602
|
}
|
|
602
|
-
const file =
|
|
603
|
-
const offset =
|
|
604
|
-
replacements.push(new
|
|
603
|
+
const file = index.isHostBindingReference(ref) ? ref.from.file : ref.from.templateFile;
|
|
604
|
+
const offset = index.isHostBindingReference(ref) ? ref.from.hostPropertyNode.getStart() + 1 : 0;
|
|
605
|
+
replacements.push(new apply_import_manager.Replacement(file, new apply_import_manager.TextUpdate({
|
|
605
606
|
// Delete from expression end to call end. E.g. `.toArray(<..>)`.
|
|
606
607
|
position: offset + callExpr.receiver.receiver.sourceSpan.end,
|
|
607
608
|
end: offset + callExpr.sourceSpan.end,
|
|
@@ -610,7 +611,7 @@ function removeQueryListToArrayCall(ref, info, globalMetadata, knownQueries, rep
|
|
|
610
611
|
}
|
|
611
612
|
|
|
612
613
|
function replaceQueryListGetCall(ref, info, globalMetadata, knownQueries, replacements) {
|
|
613
|
-
if (!
|
|
614
|
+
if (!index.isHostBindingReference(ref) && !index.isTemplateReference(ref) && !index.isTsReference(ref)) {
|
|
614
615
|
return;
|
|
615
616
|
}
|
|
616
617
|
if (knownQueries.isFieldIncompatible(ref.target)) {
|
|
@@ -619,13 +620,13 @@ function replaceQueryListGetCall(ref, info, globalMetadata, knownQueries, replac
|
|
|
619
620
|
if (!globalMetadata.knownQueryFields[ref.target.key]?.isMulti) {
|
|
620
621
|
return;
|
|
621
622
|
}
|
|
622
|
-
if (
|
|
623
|
+
if (index.isTsReference(ref)) {
|
|
623
624
|
const getCallExpr = checkTsReferenceCallsField(ref, 'get');
|
|
624
625
|
if (getCallExpr === null) {
|
|
625
626
|
return;
|
|
626
627
|
}
|
|
627
628
|
const getExpr = getCallExpr.expression;
|
|
628
|
-
replacements.push(new
|
|
629
|
+
replacements.push(new apply_import_manager.Replacement(apply_import_manager.projectFile(getExpr.getSourceFile(), info), new apply_import_manager.TextUpdate({
|
|
629
630
|
position: getExpr.name.getStart(),
|
|
630
631
|
end: getExpr.name.getEnd(),
|
|
631
632
|
toInsert: 'at',
|
|
@@ -637,9 +638,9 @@ function replaceQueryListGetCall(ref, info, globalMetadata, knownQueries, replac
|
|
|
637
638
|
if (callExpr === null) {
|
|
638
639
|
return;
|
|
639
640
|
}
|
|
640
|
-
const file =
|
|
641
|
-
const offset =
|
|
642
|
-
replacements.push(new
|
|
641
|
+
const file = index.isHostBindingReference(ref) ? ref.from.file : ref.from.templateFile;
|
|
642
|
+
const offset = index.isHostBindingReference(ref) ? ref.from.hostPropertyNode.getStart() + 1 : 0;
|
|
643
|
+
replacements.push(new apply_import_manager.Replacement(file, new apply_import_manager.TextUpdate({
|
|
643
644
|
position: offset + callExpr.receiver.nameSpan.start,
|
|
644
645
|
end: offset + callExpr.receiver.nameSpan.end,
|
|
645
646
|
toInsert: 'at',
|
|
@@ -655,7 +656,7 @@ const problematicQueryListMethods = [
|
|
|
655
656
|
'destroy',
|
|
656
657
|
];
|
|
657
658
|
function checkForIncompatibleQueryListAccesses(ref, result) {
|
|
658
|
-
if (
|
|
659
|
+
if (index.isTsReference(ref)) {
|
|
659
660
|
for (const problematicFn of problematicQueryListMethods) {
|
|
660
661
|
const access = checkTsReferenceAccessesField(ref, problematicFn);
|
|
661
662
|
if (access !== null) {
|
|
@@ -664,7 +665,7 @@ function checkForIncompatibleQueryListAccesses(ref, result) {
|
|
|
664
665
|
}
|
|
665
666
|
}
|
|
666
667
|
}
|
|
667
|
-
if (
|
|
668
|
+
if (index.isHostBindingReference(ref) || index.isTemplateReference(ref)) {
|
|
668
669
|
for (const problematicFn of problematicQueryListMethods) {
|
|
669
670
|
const access = checkNonTsReferenceAccessesField(ref, problematicFn);
|
|
670
671
|
if (access !== null) {
|
|
@@ -680,7 +681,7 @@ const mapping = new Map([
|
|
|
680
681
|
['last', 'at(-1)!'],
|
|
681
682
|
]);
|
|
682
683
|
function replaceQueryListFirstAndLastReferences(ref, info, globalMetadata, knownQueries, replacements) {
|
|
683
|
-
if (!
|
|
684
|
+
if (!index.isHostBindingReference(ref) && !index.isTemplateReference(ref) && !index.isTsReference(ref)) {
|
|
684
685
|
return;
|
|
685
686
|
}
|
|
686
687
|
if (knownQueries.isFieldIncompatible(ref.target)) {
|
|
@@ -689,12 +690,12 @@ function replaceQueryListFirstAndLastReferences(ref, info, globalMetadata, known
|
|
|
689
690
|
if (!globalMetadata.knownQueryFields[ref.target.key]?.isMulti) {
|
|
690
691
|
return;
|
|
691
692
|
}
|
|
692
|
-
if (
|
|
693
|
+
if (index.isTsReference(ref)) {
|
|
693
694
|
const expr = checkTsReferenceAccessesField(ref, 'first') ?? checkTsReferenceAccessesField(ref, 'last');
|
|
694
695
|
if (expr === null) {
|
|
695
696
|
return;
|
|
696
697
|
}
|
|
697
|
-
replacements.push(new
|
|
698
|
+
replacements.push(new apply_import_manager.Replacement(apply_import_manager.projectFile(expr.getSourceFile(), info), new apply_import_manager.TextUpdate({
|
|
698
699
|
position: expr.name.getStart(),
|
|
699
700
|
end: expr.name.getEnd(),
|
|
700
701
|
toInsert: mapping.get(expr.name.text),
|
|
@@ -706,16 +707,16 @@ function replaceQueryListFirstAndLastReferences(ref, info, globalMetadata, known
|
|
|
706
707
|
if (expr === null) {
|
|
707
708
|
return;
|
|
708
709
|
}
|
|
709
|
-
const file =
|
|
710
|
-
const offset =
|
|
711
|
-
replacements.push(new
|
|
710
|
+
const file = index.isHostBindingReference(ref) ? ref.from.file : ref.from.templateFile;
|
|
711
|
+
const offset = index.isHostBindingReference(ref) ? ref.from.hostPropertyNode.getStart() + 1 : 0;
|
|
712
|
+
replacements.push(new apply_import_manager.Replacement(file, new apply_import_manager.TextUpdate({
|
|
712
713
|
position: offset + expr.nameSpan.start,
|
|
713
714
|
end: offset + expr.nameSpan.end,
|
|
714
715
|
toInsert: mapping.get(expr.name),
|
|
715
716
|
})));
|
|
716
717
|
}
|
|
717
718
|
|
|
718
|
-
class SignalQueriesMigration extends
|
|
719
|
+
class SignalQueriesMigration extends apply_import_manager.TsurgeComplexMigration {
|
|
719
720
|
config;
|
|
720
721
|
constructor(config = {}) {
|
|
721
722
|
super();
|
|
@@ -753,7 +754,7 @@ class SignalQueriesMigration extends combine_units.TsurgeComplexMigration {
|
|
|
753
754
|
key: extractedQuery.id,
|
|
754
755
|
node: queryNode,
|
|
755
756
|
};
|
|
756
|
-
const containingFile =
|
|
757
|
+
const containingFile = apply_import_manager.projectFile(queryNode.getSourceFile(), info);
|
|
757
758
|
// If we have a config filter function, use it here for later
|
|
758
759
|
// perf-boosted reference lookups. Useful in non-batch mode.
|
|
759
760
|
if (this.config.shouldMigrateQuery === undefined ||
|
|
@@ -812,7 +813,7 @@ class SignalQueriesMigration extends combine_units.TsurgeComplexMigration {
|
|
|
812
813
|
return descriptor;
|
|
813
814
|
},
|
|
814
815
|
};
|
|
815
|
-
groupedAstVisitor.register(
|
|
816
|
+
groupedAstVisitor.register(index.createFindAllSourceFileReferencesVisitor(info, checker$1, reflector, resourceLoader, evaluator, templateTypeChecker, allFieldsOrKnownQueries,
|
|
816
817
|
// In non-batch mode, we know what inputs exist and can optimize the reference
|
|
817
818
|
// resolution significantly (for e.g. VSCode integration)— as we know what
|
|
818
819
|
// field names may be used to reference potential queries.
|
|
@@ -840,15 +841,15 @@ class SignalQueriesMigration extends combine_units.TsurgeComplexMigration {
|
|
|
840
841
|
// Determine incompatible queries based on problematic references
|
|
841
842
|
// we saw in TS code, templates or host bindings.
|
|
842
843
|
for (const ref of referenceResult.references) {
|
|
843
|
-
if (
|
|
844
|
+
if (index.isTsReference(ref) && ref.from.isWrite) {
|
|
844
845
|
markFieldIncompatibleInMetadata(res.potentialProblematicQueries, ref.target.key, migrate_ts_type_references.FieldIncompatibilityReason.WriteAssignment);
|
|
845
846
|
}
|
|
846
|
-
if ((
|
|
847
|
+
if ((index.isTemplateReference(ref) || index.isHostBindingReference(ref)) && ref.from.isWrite) {
|
|
847
848
|
markFieldIncompatibleInMetadata(res.potentialProblematicQueries, ref.target.key, migrate_ts_type_references.FieldIncompatibilityReason.WriteAssignment);
|
|
848
849
|
}
|
|
849
850
|
// TODO: Remove this when we support signal narrowing in templates.
|
|
850
851
|
// https://github.com/angular/angular/pull/55456.
|
|
851
|
-
if (
|
|
852
|
+
if (index.isTemplateReference(ref) && ref.from.isLikelyPartOfNarrowing) {
|
|
852
853
|
markFieldIncompatibleInMetadata(res.potentialProblematicQueries, ref.target.key, migrate_ts_type_references.FieldIncompatibilityReason.PotentiallyNarrowedInTemplateButNoSupportYet);
|
|
853
854
|
}
|
|
854
855
|
// Check for other incompatible query list accesses.
|
|
@@ -857,7 +858,7 @@ class SignalQueriesMigration extends combine_units.TsurgeComplexMigration {
|
|
|
857
858
|
if (this.config.assumeNonBatch) {
|
|
858
859
|
res.reusableAnalysisReferences = referenceResult.references;
|
|
859
860
|
}
|
|
860
|
-
return
|
|
861
|
+
return apply_import_manager.confirmAsSerializable(res);
|
|
861
862
|
}
|
|
862
863
|
async combine(unitA, unitB) {
|
|
863
864
|
const combined = {
|
|
@@ -897,7 +898,7 @@ class SignalQueriesMigration extends combine_units.TsurgeComplexMigration {
|
|
|
897
898
|
}
|
|
898
899
|
}
|
|
899
900
|
}
|
|
900
|
-
return
|
|
901
|
+
return apply_import_manager.confirmAsSerializable(combined);
|
|
901
902
|
}
|
|
902
903
|
async globalMeta(combinedData) {
|
|
903
904
|
const globalUnitData = {
|
|
@@ -910,7 +911,7 @@ class SignalQueriesMigration extends combine_units.TsurgeComplexMigration {
|
|
|
910
911
|
markFieldIncompatibleInMetadata(globalUnitData.problematicQueries, id, migrate_ts_type_references.FieldIncompatibilityReason.SignalQueries__QueryListProblematicFieldAccessed);
|
|
911
912
|
}
|
|
912
913
|
}
|
|
913
|
-
return
|
|
914
|
+
return apply_import_manager.confirmAsSerializable(globalUnitData);
|
|
914
915
|
}
|
|
915
916
|
async migrate(globalMetadata, info) {
|
|
916
917
|
// Pre-Analyze the program and get access to the template type checker.
|
|
@@ -973,7 +974,7 @@ class SignalQueriesMigration extends combine_units.TsurgeComplexMigration {
|
|
|
973
974
|
referenceResult.references = globalMetadata.reusableAnalysisReferences;
|
|
974
975
|
}
|
|
975
976
|
else {
|
|
976
|
-
groupedAstVisitor.register(
|
|
977
|
+
groupedAstVisitor.register(index.createFindAllSourceFileReferencesVisitor(info, checker$1, reflector, resourceLoader, evaluator, templateTypeChecker, knownQueries, fieldNamesToConsiderForReferenceLookup, referenceResult).visitor);
|
|
977
978
|
}
|
|
978
979
|
// Check inheritance.
|
|
979
980
|
// NOTE: Inheritance is only checked in the migrate stage as we cannot reliably
|
|
@@ -1046,7 +1047,7 @@ class SignalQueriesMigration extends combine_units.TsurgeComplexMigration {
|
|
|
1046
1047
|
importManager.removeImport(file, 'QueryList', '@angular/core');
|
|
1047
1048
|
}
|
|
1048
1049
|
}
|
|
1049
|
-
|
|
1050
|
+
apply_import_manager.applyImportManagerChanges(importManager, replacements, sourceFiles, info);
|
|
1050
1051
|
return { replacements, knownQueries };
|
|
1051
1052
|
}
|
|
1052
1053
|
async stats(globalMetadata) {
|
|
@@ -1109,7 +1110,7 @@ function migrate(options) {
|
|
|
1109
1110
|
if (!buildPaths.length && !testPaths.length) {
|
|
1110
1111
|
throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run signal queries migration.');
|
|
1111
1112
|
}
|
|
1112
|
-
const fs = new
|
|
1113
|
+
const fs = new apply_import_manager.DevkitMigrationFilesystem(tree);
|
|
1113
1114
|
checker.setFileSystem(fs);
|
|
1114
1115
|
const migration = new SignalQueriesMigration({
|
|
1115
1116
|
bestEffortMode: options.bestEffortMode,
|
|
@@ -1141,7 +1142,7 @@ function migrate(options) {
|
|
|
1141
1142
|
context.logger.info(``);
|
|
1142
1143
|
context.logger.info(`Processing analysis data between targets..`);
|
|
1143
1144
|
context.logger.info(``);
|
|
1144
|
-
const combined = await
|
|
1145
|
+
const combined = await apply_import_manager.synchronouslyCombineUnitData(migration, unitResults);
|
|
1145
1146
|
if (combined === null) {
|
|
1146
1147
|
context.logger.error('Migration failed unexpectedly with no analysis data');
|
|
1147
1148
|
return;
|
|
@@ -1151,7 +1152,7 @@ function migrate(options) {
|
|
|
1151
1152
|
for (const { info, tsconfigPath } of programInfos) {
|
|
1152
1153
|
context.logger.info(`Migrating: ${tsconfigPath}..`);
|
|
1153
1154
|
const { replacements } = await migration.migrate(globalMeta, info);
|
|
1154
|
-
const changesPerFile =
|
|
1155
|
+
const changesPerFile = apply_import_manager.groupReplacementsByFile(replacements);
|
|
1155
1156
|
for (const [file, changes] of changesPerFile) {
|
|
1156
1157
|
if (!replacementsPerFile.has(file)) {
|
|
1157
1158
|
replacementsPerFile.set(file, changes);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.1.0-
|
|
3
|
+
* @license Angular v19.1.0-rc.0
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -14,18 +14,19 @@ var signalInputMigration = require('./signal-input-migration.js');
|
|
|
14
14
|
var outputMigration = require('./output-migration.js');
|
|
15
15
|
require('./project_tsconfig_paths-e9ccccbf.js');
|
|
16
16
|
require('@angular-devkit/core');
|
|
17
|
-
require('./
|
|
17
|
+
require('./apply_import_manager-6508401d.js');
|
|
18
18
|
require('node:path/posix');
|
|
19
19
|
require('os');
|
|
20
20
|
require('typescript');
|
|
21
|
-
require('./checker-
|
|
21
|
+
require('./checker-24b68d23.js');
|
|
22
22
|
require('fs');
|
|
23
23
|
require('module');
|
|
24
24
|
require('path');
|
|
25
25
|
require('url');
|
|
26
|
-
require('./program-
|
|
27
|
-
require('./migrate_ts_type_references-
|
|
26
|
+
require('./program-c810a4c2.js');
|
|
27
|
+
require('./migrate_ts_type_references-bc7d8784.js');
|
|
28
28
|
require('assert');
|
|
29
|
+
require('./index-767e341d.js');
|
|
29
30
|
require('./leading_space-d190b83b.js');
|
|
30
31
|
|
|
31
32
|
function migrate(options) {
|