@angular/core 15.2.0-next.4 → 15.2.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v15.2.0-next.4
2
+ * @license Angular v15.2.0-rc.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/core",
3
- "version": "15.2.0-next.4",
3
+ "version": "15.2.0-rc.0",
4
4
  "description": "Angular - the core framework",
5
5
  "author": "angular",
6
6
  "license": "MIT",
@@ -16114,7 +16114,7 @@ function publishFacade(global2) {
16114
16114
  }
16115
16115
 
16116
16116
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
16117
- var VERSION2 = new Version("15.2.0-next.4");
16117
+ var VERSION2 = new Version("15.2.0-rc.0");
16118
16118
 
16119
16119
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
16120
16120
  var _I18N_ATTR = "i18n";
@@ -17429,7 +17429,7 @@ var MINIMUM_PARTIAL_LINKER_VERSION = "12.0.0";
17429
17429
  function compileDeclareClassMetadata(metadata) {
17430
17430
  const definitionMap = new DefinitionMap();
17431
17431
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION));
17432
- definitionMap.set("version", literal("15.2.0-next.4"));
17432
+ definitionMap.set("version", literal("15.2.0-rc.0"));
17433
17433
  definitionMap.set("ngImport", importExpr(Identifiers.core));
17434
17434
  definitionMap.set("type", metadata.type);
17435
17435
  definitionMap.set("decorators", metadata.decorators);
@@ -17498,7 +17498,7 @@ function createDirectiveDefinitionMap(meta) {
17498
17498
  var _a;
17499
17499
  const definitionMap = new DefinitionMap();
17500
17500
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION2));
17501
- definitionMap.set("version", literal("15.2.0-next.4"));
17501
+ definitionMap.set("version", literal("15.2.0-rc.0"));
17502
17502
  definitionMap.set("type", meta.internalType);
17503
17503
  if (meta.isStandalone) {
17504
17504
  definitionMap.set("isStandalone", literal(meta.isStandalone));
@@ -17680,7 +17680,7 @@ var MINIMUM_PARTIAL_LINKER_VERSION3 = "12.0.0";
17680
17680
  function compileDeclareFactoryFunction(meta) {
17681
17681
  const definitionMap = new DefinitionMap();
17682
17682
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION3));
17683
- definitionMap.set("version", literal("15.2.0-next.4"));
17683
+ definitionMap.set("version", literal("15.2.0-rc.0"));
17684
17684
  definitionMap.set("ngImport", importExpr(Identifiers.core));
17685
17685
  definitionMap.set("type", meta.internalType);
17686
17686
  definitionMap.set("deps", compileDependencies(meta.deps));
@@ -17703,7 +17703,7 @@ function compileDeclareInjectableFromMetadata(meta) {
17703
17703
  function createInjectableDefinitionMap(meta) {
17704
17704
  const definitionMap = new DefinitionMap();
17705
17705
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION4));
17706
- definitionMap.set("version", literal("15.2.0-next.4"));
17706
+ definitionMap.set("version", literal("15.2.0-rc.0"));
17707
17707
  definitionMap.set("ngImport", importExpr(Identifiers.core));
17708
17708
  definitionMap.set("type", meta.internalType);
17709
17709
  if (meta.providedIn !== void 0) {
@@ -17741,7 +17741,7 @@ function compileDeclareInjectorFromMetadata(meta) {
17741
17741
  function createInjectorDefinitionMap(meta) {
17742
17742
  const definitionMap = new DefinitionMap();
17743
17743
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION5));
17744
- definitionMap.set("version", literal("15.2.0-next.4"));
17744
+ definitionMap.set("version", literal("15.2.0-rc.0"));
17745
17745
  definitionMap.set("ngImport", importExpr(Identifiers.core));
17746
17746
  definitionMap.set("type", meta.internalType);
17747
17747
  definitionMap.set("providers", meta.providers);
@@ -17762,7 +17762,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
17762
17762
  function createNgModuleDefinitionMap(meta) {
17763
17763
  const definitionMap = new DefinitionMap();
17764
17764
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION6));
17765
- definitionMap.set("version", literal("15.2.0-next.4"));
17765
+ definitionMap.set("version", literal("15.2.0-rc.0"));
17766
17766
  definitionMap.set("ngImport", importExpr(Identifiers.core));
17767
17767
  definitionMap.set("type", meta.internalType);
17768
17768
  if (meta.bootstrap.length > 0) {
@@ -17797,7 +17797,7 @@ function compileDeclarePipeFromMetadata(meta) {
17797
17797
  function createPipeDefinitionMap(meta) {
17798
17798
  const definitionMap = new DefinitionMap();
17799
17799
  definitionMap.set("minVersion", literal(MINIMUM_PARTIAL_LINKER_VERSION7));
17800
- definitionMap.set("version", literal("15.2.0-next.4"));
17800
+ definitionMap.set("version", literal("15.2.0-rc.0"));
17801
17801
  definitionMap.set("ngImport", importExpr(Identifiers.core));
17802
17802
  definitionMap.set("type", meta.internalType);
17803
17803
  if (meta.isStandalone) {
@@ -17814,7 +17814,7 @@ function createPipeDefinitionMap(meta) {
17814
17814
  publishFacade(_global);
17815
17815
 
17816
17816
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/version.mjs
17817
- var VERSION3 = new Version("15.2.0-next.4");
17817
+ var VERSION3 = new Version("15.2.0-rc.0");
17818
17818
 
17819
17819
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/transformers/api.mjs
17820
17820
  var EmitFlags;
@@ -35060,21 +35060,96 @@ var UniqueItemTracker = class {
35060
35060
  return this._nodes.entries();
35061
35061
  }
35062
35062
  };
35063
- function createLanguageService(program, host, rootFileNames, basePath) {
35064
- return import_typescript108.default.createLanguageService({
35065
- getCompilationSettings: () => program.getTsProgram().getCompilerOptions(),
35066
- getScriptFileNames: () => rootFileNames,
35067
- getScriptVersion: () => "0",
35068
- getScriptSnapshot: (fileName) => {
35069
- const content = host.readFile(fileName);
35070
- return content ? import_typescript108.default.ScriptSnapshot.fromString(content) : void 0;
35071
- },
35072
- getCurrentDirectory: () => basePath,
35073
- getDefaultLibFileName: (options) => import_typescript108.default.getDefaultLibFilePath(options),
35074
- readFile: (path3) => host.readFile(path3),
35075
- fileExists: (path3) => host.fileExists(path3)
35076
- });
35077
- }
35063
+ var ReferenceResolver = class {
35064
+ constructor(_program, _host, _rootFileNames, _basePath, _excludedFiles) {
35065
+ this._program = _program;
35066
+ this._host = _host;
35067
+ this._rootFileNames = _rootFileNames;
35068
+ this._basePath = _basePath;
35069
+ this._excludedFiles = _excludedFiles;
35070
+ this._tempOnlyFile = null;
35071
+ }
35072
+ findReferencesInProject(node) {
35073
+ const languageService = this._getLanguageService();
35074
+ const fileName = node.getSourceFile().fileName;
35075
+ const start = node.getStart();
35076
+ let referencedSymbols;
35077
+ try {
35078
+ referencedSymbols = languageService.findReferences(fileName, start) || [];
35079
+ } catch (e) {
35080
+ console.error("Failed reference lookup for node " + node.getText(), e.message);
35081
+ referencedSymbols = [];
35082
+ }
35083
+ const results = /* @__PURE__ */ new Map();
35084
+ for (const symbol of referencedSymbols) {
35085
+ for (const ref of symbol.references) {
35086
+ if (!ref.isDefinition || symbol.definition.kind === import_typescript108.default.ScriptElementKind.alias) {
35087
+ if (!results.has(ref.fileName)) {
35088
+ results.set(ref.fileName, []);
35089
+ }
35090
+ results.get(ref.fileName).push([ref.textSpan.start, ref.textSpan.start + ref.textSpan.length]);
35091
+ }
35092
+ }
35093
+ }
35094
+ return results;
35095
+ }
35096
+ findSameFileReferences(node, fileName) {
35097
+ this._tempOnlyFile = fileName;
35098
+ const nodeStart = node.getStart();
35099
+ const results = [];
35100
+ let highlights;
35101
+ try {
35102
+ highlights = this._getLanguageService().getDocumentHighlights(fileName, nodeStart, [fileName]);
35103
+ } catch (e) {
35104
+ console.error("Failed reference lookup for node " + node.getText(), e.message);
35105
+ }
35106
+ if (highlights) {
35107
+ for (const file of highlights) {
35108
+ if (file.fileName === fileName) {
35109
+ for (const { textSpan: { start, length }, kind } of file.highlightSpans) {
35110
+ if (kind !== import_typescript108.default.HighlightSpanKind.none) {
35111
+ results.push([start, start + length]);
35112
+ }
35113
+ }
35114
+ }
35115
+ }
35116
+ }
35117
+ this._tempOnlyFile = null;
35118
+ return results;
35119
+ }
35120
+ _readFile(path3) {
35121
+ var _a;
35122
+ if (this._tempOnlyFile !== null && path3 !== this._tempOnlyFile || ((_a = this._excludedFiles) == null ? void 0 : _a.test(path3))) {
35123
+ return "";
35124
+ }
35125
+ return this._host.readFile(path3);
35126
+ }
35127
+ _getLanguageService() {
35128
+ if (!this._languageService) {
35129
+ const rootFileNames = this._rootFileNames.slice();
35130
+ this._program.getTsProgram().getSourceFiles().forEach(({ fileName }) => {
35131
+ var _a;
35132
+ if (!((_a = this._excludedFiles) == null ? void 0 : _a.test(fileName)) && !rootFileNames.includes(fileName)) {
35133
+ rootFileNames.push(fileName);
35134
+ }
35135
+ });
35136
+ this._languageService = import_typescript108.default.createLanguageService({
35137
+ getCompilationSettings: () => this._program.getTsProgram().getCompilerOptions(),
35138
+ getScriptFileNames: () => rootFileNames,
35139
+ getScriptVersion: () => "0",
35140
+ getScriptSnapshot: (path3) => {
35141
+ const content = this._readFile(path3);
35142
+ return content ? import_typescript108.default.ScriptSnapshot.fromString(content) : void 0;
35143
+ },
35144
+ getCurrentDirectory: () => this._basePath,
35145
+ getDefaultLibFileName: (options) => import_typescript108.default.getDefaultLibFilePath(options),
35146
+ readFile: (path3) => this._readFile(path3),
35147
+ fileExists: (path3) => this._host.fileExists(path3)
35148
+ }, import_typescript108.default.createDocumentRegistry(), import_typescript108.default.LanguageServiceMode.PartialSemantic);
35149
+ }
35150
+ return this._languageService;
35151
+ }
35152
+ };
35078
35153
  function getNodeLookup(sourceFile) {
35079
35154
  const lookup = /* @__PURE__ */ new Map();
35080
35155
  sourceFile.forEachChild(function walk(node) {
@@ -35115,13 +35190,16 @@ function getRelativeImportPath(fromFile, toFile) {
35115
35190
  function normalizePath(path3) {
35116
35191
  return path3.replace(/\\/g, "/");
35117
35192
  }
35193
+ function knownInternalAliasRemapper(imports) {
35194
+ return imports.map((current) => current.moduleSpecifier === "@angular/common" && current.symbolName === "NgForOf" ? __spreadProps(__spreadValues({}, current), { symbolName: "NgFor" }) : current);
35195
+ }
35118
35196
 
35119
35197
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/prune-modules.mjs
35120
- function pruneNgModules(program, host, basePath, rootFileNames, sourceFiles, printer, importRemapper) {
35198
+ function pruneNgModules(program, host, basePath, rootFileNames, sourceFiles, printer, importRemapper, referenceLookupExcludedFiles) {
35121
35199
  const filesToRemove = /* @__PURE__ */ new Set();
35122
35200
  const tracker = new ChangeTracker(printer, importRemapper);
35123
35201
  const typeChecker = program.getTsProgram().getTypeChecker();
35124
- const languageService = createLanguageService(program, host, rootFileNames, basePath);
35202
+ const referenceResolver = new ReferenceResolver(program, host, rootFileNames, basePath, referenceLookupExcludedFiles);
35125
35203
  const removalLocations = {
35126
35204
  arrays: new UniqueItemTracker(),
35127
35205
  imports: new UniqueItemTracker(),
@@ -35131,7 +35209,7 @@ function pruneNgModules(program, host, basePath, rootFileNames, sourceFiles, pri
35131
35209
  };
35132
35210
  sourceFiles.forEach(function walk(node) {
35133
35211
  if (import_typescript109.default.isClassDeclaration(node) && canRemoveClass(node, typeChecker)) {
35134
- collectRemovalLocations(node, removalLocations, languageService, program);
35212
+ collectRemovalLocations(node, removalLocations, referenceResolver, program);
35135
35213
  removalLocations.classes.add(node);
35136
35214
  }
35137
35215
  node.forEachChild(walk);
@@ -35150,8 +35228,8 @@ function pruneNgModules(program, host, basePath, rootFileNames, sourceFiles, pri
35150
35228
  }
35151
35229
  return { pendingChanges: tracker.recordChanges(), filesToRemove };
35152
35230
  }
35153
- function collectRemovalLocations(ngModule, removalLocations, languageService, program) {
35154
- const refsByFile = extractReferences(ngModule, languageService);
35231
+ function collectRemovalLocations(ngModule, removalLocations, referenceResolver, program) {
35232
+ const refsByFile = referenceResolver.findReferencesInProject(ngModule.name);
35155
35233
  const tsProgram = program.getTsProgram();
35156
35234
  const nodes = /* @__PURE__ */ new Set();
35157
35235
  for (const [fileName, refs] of refsByFile) {
@@ -35267,21 +35345,6 @@ function canRemoveFile(sourceFile, classesToBeRemoved) {
35267
35345
  }
35268
35346
  return true;
35269
35347
  }
35270
- function extractReferences(node, languageService) {
35271
- const result = /* @__PURE__ */ new Map();
35272
- const referencedSymbols = languageService.findReferences(node.getSourceFile().fileName, node.name.getStart()) || [];
35273
- for (const symbol of referencedSymbols) {
35274
- for (const ref of symbol.references) {
35275
- if (!ref.isDefinition || symbol.definition.kind === import_typescript109.default.ScriptElementKind.alias) {
35276
- if (!result.has(ref.fileName)) {
35277
- result.set(ref.fileName, []);
35278
- }
35279
- result.get(ref.fileName).push([ref.textSpan.start, ref.textSpan.start + ref.textSpan.length]);
35280
- }
35281
- }
35282
- }
35283
- return result;
35284
- }
35285
35348
  function contains(parent, child) {
35286
35349
  return parent === child || parent.getSourceFile().fileName === child.getSourceFile().fileName && child.getStart() >= parent.getStart() && child.getStart() <= parent.getEnd();
35287
35350
  }
@@ -35325,13 +35388,13 @@ function isReferenceToImport(typeChecker, node, importSpecifier) {
35325
35388
  }
35326
35389
 
35327
35390
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/to-standalone.mjs
35328
- function toStandalone(sourceFiles, program, printer, importRemapper) {
35391
+ function toStandalone(sourceFiles, program, printer, fileImportRemapper, componentImportRemapper) {
35329
35392
  const templateTypeChecker = program.compiler.getTemplateTypeChecker();
35330
35393
  const typeChecker = program.getTsProgram().getTypeChecker();
35331
35394
  const modulesToMigrate = [];
35332
35395
  const testObjectsToMigrate = [];
35333
35396
  const declarations = [];
35334
- const tracker = new ChangeTracker(printer, importRemapper);
35397
+ const tracker = new ChangeTracker(printer, fileImportRemapper);
35335
35398
  for (const sourceFile of sourceFiles) {
35336
35399
  const modules = findNgModuleClassesToMigrate(sourceFile, typeChecker);
35337
35400
  const testObjects = findTestObjectsToMigrate(sourceFile, typeChecker);
@@ -35346,7 +35409,7 @@ function toStandalone(sourceFiles, program, printer, importRemapper) {
35346
35409
  testObjectsToMigrate.push(...testObjects);
35347
35410
  }
35348
35411
  for (const declaration of declarations) {
35349
- convertNgModuleDeclarationToStandalone(declaration, declarations, tracker, templateTypeChecker);
35412
+ convertNgModuleDeclarationToStandalone(declaration, declarations, tracker, templateTypeChecker, componentImportRemapper);
35350
35413
  }
35351
35414
  for (const node of modulesToMigrate) {
35352
35415
  migrateNgModuleClass(node, declarations, tracker, typeChecker, templateTypeChecker);
@@ -35354,12 +35417,12 @@ function toStandalone(sourceFiles, program, printer, importRemapper) {
35354
35417
  migrateTestDeclarations(testObjectsToMigrate, declarations, tracker, templateTypeChecker, typeChecker);
35355
35418
  return tracker.recordChanges();
35356
35419
  }
35357
- function convertNgModuleDeclarationToStandalone(ref, allDeclarations, tracker, typeChecker) {
35420
+ function convertNgModuleDeclarationToStandalone(ref, allDeclarations, tracker, typeChecker, importRemapper) {
35358
35421
  const directiveMeta = typeChecker.getDirectiveMetadata(ref.node);
35359
35422
  if (directiveMeta && directiveMeta.decorator && !directiveMeta.isStandalone) {
35360
35423
  let decorator = addStandaloneToDecorator(directiveMeta.decorator);
35361
35424
  if (directiveMeta.isComponent) {
35362
- const importsToAdd = getComponentImportExpressions(ref, allDeclarations, tracker, typeChecker);
35425
+ const importsToAdd = getComponentImportExpressions(ref, allDeclarations, tracker, typeChecker, importRemapper);
35363
35426
  if (importsToAdd.length > 0) {
35364
35427
  decorator = addPropertyToAngularDecorator(decorator, import_typescript111.default.factory.createPropertyAssignment("imports", import_typescript111.default.factory.createArrayLiteralExpression(importsToAdd)));
35365
35428
  }
@@ -35372,28 +35435,33 @@ function convertNgModuleDeclarationToStandalone(ref, allDeclarations, tracker, t
35372
35435
  }
35373
35436
  }
35374
35437
  }
35375
- function getComponentImportExpressions(ref, allDeclarations, tracker, typeChecker) {
35438
+ function getComponentImportExpressions(ref, allDeclarations, tracker, typeChecker, importRemapper) {
35376
35439
  const templateDependencies = findTemplateDependencies(ref, typeChecker);
35377
35440
  const usedDependenciesInMigration = new Set(templateDependencies.filter((dep) => allDeclarations.find((current) => current.node === dep.node)));
35378
35441
  const imports = [];
35379
35442
  const seenImports = /* @__PURE__ */ new Set();
35443
+ const resolvedDependencies = [];
35380
35444
  for (const dep of templateDependencies) {
35381
35445
  const importLocation = findImportLocation(dep, ref, usedDependenciesInMigration.has(dep) ? PotentialImportMode.ForceDirect : PotentialImportMode.Normal, typeChecker);
35382
35446
  if (importLocation && !seenImports.has(importLocation.symbolName)) {
35383
- if (importLocation.moduleSpecifier) {
35384
- const identifier = tracker.addImport(ref.node.getSourceFile(), importLocation.symbolName, importLocation.moduleSpecifier);
35385
- imports.push(identifier);
35447
+ seenImports.add(importLocation.symbolName);
35448
+ resolvedDependencies.push(importLocation);
35449
+ }
35450
+ }
35451
+ const processedDependencies = importRemapper ? importRemapper(resolvedDependencies, ref) : resolvedDependencies;
35452
+ for (const importLocation of processedDependencies) {
35453
+ if (importLocation.moduleSpecifier) {
35454
+ const identifier = tracker.addImport(ref.node.getSourceFile(), importLocation.symbolName, importLocation.moduleSpecifier);
35455
+ imports.push(identifier);
35456
+ } else {
35457
+ const identifier = import_typescript111.default.factory.createIdentifier(importLocation.symbolName);
35458
+ if (importLocation.isForwardReference) {
35459
+ const forwardRefExpression = tracker.addImport(ref.node.getSourceFile(), "forwardRef", "@angular/core");
35460
+ const arrowFunction = import_typescript111.default.factory.createArrowFunction(void 0, void 0, [], void 0, void 0, identifier);
35461
+ imports.push(import_typescript111.default.factory.createCallExpression(forwardRefExpression, void 0, [arrowFunction]));
35386
35462
  } else {
35387
- const identifier = import_typescript111.default.factory.createIdentifier(importLocation.symbolName);
35388
- if (importLocation.isForwardReference) {
35389
- const forwardRefExpression = tracker.addImport(ref.node.getSourceFile(), "forwardRef", "@angular/core");
35390
- const arrowFunction = import_typescript111.default.factory.createArrowFunction(void 0, void 0, [], void 0, void 0, identifier);
35391
- imports.push(import_typescript111.default.factory.createCallExpression(forwardRefExpression, void 0, [arrowFunction]));
35392
- } else {
35393
- imports.push(identifier);
35394
- }
35463
+ imports.push(identifier);
35395
35464
  }
35396
- seenImports.add(importLocation.symbolName);
35397
35465
  }
35398
35466
  }
35399
35467
  return imports;
@@ -35666,11 +35734,11 @@ function isStandaloneDeclaration(node, declarationsInMigration, templateTypeChec
35666
35734
  }
35667
35735
 
35668
35736
  // bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/standalone-bootstrap.mjs
35669
- function toStandaloneBootstrap(program, host, basePath, rootFileNames, sourceFiles, printer, importRemapper) {
35737
+ function toStandaloneBootstrap(program, host, basePath, rootFileNames, sourceFiles, printer, importRemapper, referenceLookupExcludedFiles, componentImportRemapper) {
35670
35738
  const tracker = new ChangeTracker(printer, importRemapper);
35671
35739
  const typeChecker = program.getTsProgram().getTypeChecker();
35672
35740
  const templateTypeChecker = program.compiler.getTemplateTypeChecker();
35673
- const languageService = createLanguageService(program, host, rootFileNames, basePath);
35741
+ const referenceResolver = new ReferenceResolver(program, host, rootFileNames, basePath, referenceLookupExcludedFiles);
35674
35742
  const bootstrapCalls = [];
35675
35743
  const testObjects = [];
35676
35744
  const allDeclarations = [];
@@ -35688,10 +35756,10 @@ function toStandaloneBootstrap(program, host, basePath, rootFileNames, sourceFil
35688
35756
  }
35689
35757
  for (const call of bootstrapCalls) {
35690
35758
  allDeclarations.push(...call.declarations);
35691
- migrateBootstrapCall(call, tracker, languageService, typeChecker, printer);
35759
+ migrateBootstrapCall(call, tracker, referenceResolver, typeChecker, printer);
35692
35760
  }
35693
35761
  for (const declaration of allDeclarations) {
35694
- convertNgModuleDeclarationToStandalone(declaration, allDeclarations, tracker, templateTypeChecker);
35762
+ convertNgModuleDeclarationToStandalone(declaration, allDeclarations, tracker, templateTypeChecker, componentImportRemapper);
35695
35763
  }
35696
35764
  migrateTestDeclarations(testObjects, allDeclarations, tracker, templateTypeChecker, typeChecker);
35697
35765
  return tracker.recordChanges();
@@ -35725,7 +35793,7 @@ function analyzeBootstrapCall(call, typeChecker, templateTypeChecker) {
35725
35793
  }
35726
35794
  return null;
35727
35795
  }
35728
- function migrateBootstrapCall(analysis, tracker, languageService, typeChecker, printer) {
35796
+ function migrateBootstrapCall(analysis, tracker, referenceResolver, typeChecker, printer) {
35729
35797
  const sourceFile = analysis.call.getSourceFile();
35730
35798
  const moduleSourceFile = analysis.metadata.getSourceFile();
35731
35799
  const providers = findLiteralProperty(analysis.metadata, "providers");
@@ -35734,7 +35802,7 @@ function migrateBootstrapCall(analysis, tracker, languageService, typeChecker, p
35734
35802
  const providersInNewCall = [];
35735
35803
  const moduleImportsInNewCall = [];
35736
35804
  let nodeLookup = null;
35737
- tracker.insertText(moduleSourceFile, analysis.metadata.getStart(), '/* TODO(standalone-migration): clean up removed NgModule class manually or run the "Remove unnecessary NgModule classes" step of the migration again. \n');
35805
+ tracker.insertText(moduleSourceFile, analysis.metadata.getStart(), "/* TODO(standalone-migration): clean up removed NgModule class manually. \n");
35738
35806
  tracker.insertText(moduleSourceFile, analysis.metadata.getEnd(), " */");
35739
35807
  if (providers && import_typescript112.default.isPropertyAssignment(providers)) {
35740
35808
  nodeLookup = nodeLookup || getNodeLookup(moduleSourceFile);
@@ -35743,11 +35811,11 @@ function migrateBootstrapCall(analysis, tracker, languageService, typeChecker, p
35743
35811
  } else {
35744
35812
  providersInNewCall.push(import_typescript112.default.factory.createSpreadElement(providers.initializer));
35745
35813
  }
35746
- addNodesToCopy(sourceFile, providers, nodeLookup, tracker, nodesToCopy, languageService);
35814
+ addNodesToCopy(sourceFile, providers, nodeLookup, tracker, nodesToCopy, referenceResolver);
35747
35815
  }
35748
35816
  if (imports && import_typescript112.default.isPropertyAssignment(imports)) {
35749
35817
  nodeLookup = nodeLookup || getNodeLookup(moduleSourceFile);
35750
- migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, moduleImportsInNewCall, providersInNewCall, tracker, nodesToCopy, languageService, typeChecker);
35818
+ migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, moduleImportsInNewCall, providersInNewCall, tracker, nodesToCopy, referenceResolver, typeChecker);
35751
35819
  }
35752
35820
  if (nodesToCopy.size > 0) {
35753
35821
  let text = "\n\n";
@@ -35786,7 +35854,7 @@ function replaceBootstrapCallExpression(analysis, providers, modules, tracker) {
35786
35854
  analysis.metadata.getSourceFile()
35787
35855
  );
35788
35856
  }
35789
- function migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, importsForNewCall, providersInNewCall, tracker, nodesToCopy, languageService, typeChecker) {
35857
+ function migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, importsForNewCall, providersInNewCall, tracker, nodesToCopy, referenceResolver, typeChecker) {
35790
35858
  if (!import_typescript112.default.isArrayLiteralExpression(imports.initializer)) {
35791
35859
  importsForNewCall.push(imports.initializer);
35792
35860
  return;
@@ -35797,9 +35865,9 @@ function migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, imports
35797
35865
  const features = options ? getRouterModuleForRootFeatures(sourceFile, options, tracker) : [];
35798
35866
  if (features !== null) {
35799
35867
  providersInNewCall.push(import_typescript112.default.factory.createCallExpression(tracker.addImport(sourceFile, "provideRouter", "@angular/router"), [], [element.arguments[0], ...features]));
35800
- addNodesToCopy(sourceFile, element.arguments[0], nodeLookup, tracker, nodesToCopy, languageService);
35868
+ addNodesToCopy(sourceFile, element.arguments[0], nodeLookup, tracker, nodesToCopy, referenceResolver);
35801
35869
  if (options) {
35802
- addNodesToCopy(sourceFile, options, nodeLookup, tracker, nodesToCopy, languageService);
35870
+ addNodesToCopy(sourceFile, options, nodeLookup, tracker, nodesToCopy, referenceResolver);
35803
35871
  }
35804
35872
  continue;
35805
35873
  }
@@ -35821,7 +35889,7 @@ function migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, imports
35821
35889
  const decorators = classDeclaration ? getAngularDecorators(typeChecker, import_typescript112.default.getDecorators(classDeclaration) || []) : void 0;
35822
35890
  if (!decorators || decorators.length === 0 || decorators.every(({ name }) => name !== "Directive" && name !== "Component" && name !== "Pipe")) {
35823
35891
  importsForNewCall.push(element);
35824
- addNodesToCopy(sourceFile, element, nodeLookup, tracker, nodesToCopy, languageService);
35892
+ addNodesToCopy(sourceFile, element, nodeLookup, tracker, nodesToCopy, referenceResolver);
35825
35893
  }
35826
35894
  }
35827
35895
  }
@@ -35890,8 +35958,8 @@ function getRouterModuleForRootFeatures(sourceFile, options, tracker) {
35890
35958
  }
35891
35959
  return featureExpressions;
35892
35960
  }
35893
- function addNodesToCopy(targetFile, rootNode, nodeLookup, tracker, nodesToCopy, languageService) {
35894
- const refs = findAllSameFileReferences(rootNode, nodeLookup, languageService);
35961
+ function addNodesToCopy(targetFile, rootNode, nodeLookup, tracker, nodesToCopy, referenceResolver) {
35962
+ const refs = findAllSameFileReferences(rootNode, nodeLookup, referenceResolver);
35895
35963
  for (const ref of refs) {
35896
35964
  const importSpecifier = closestOrSelf(ref, import_typescript112.default.isImportSpecifier);
35897
35965
  const importDeclaration = importSpecifier ? closestNode(importSpecifier, import_typescript112.default.isImportDeclaration) : null;
@@ -35922,8 +35990,9 @@ function addNodesToCopy(targetFile, rootNode, nodeLookup, tracker, nodesToCopy,
35922
35990
  }
35923
35991
  }
35924
35992
  }
35925
- function findAllSameFileReferences(rootNode, nodeLookup, languageService) {
35993
+ function findAllSameFileReferences(rootNode, nodeLookup, referenceResolver) {
35926
35994
  const results = /* @__PURE__ */ new Set();
35995
+ const traversedTopLevelNodes = /* @__PURE__ */ new Set();
35927
35996
  const excludeStart = rootNode.getStart();
35928
35997
  const excludeEnd = rootNode.getEnd();
35929
35998
  (function walk(node) {
@@ -35931,7 +36000,7 @@ function findAllSameFileReferences(rootNode, nodeLookup, languageService) {
35931
36000
  node.forEachChild(walk);
35932
36001
  return;
35933
36002
  }
35934
- const refs = referencesToNodeWithinSameFile(node, nodeLookup, excludeStart, excludeEnd, languageService);
36003
+ const refs = referencesToNodeWithinSameFile(node, nodeLookup, excludeStart, excludeEnd, referenceResolver);
35935
36004
  if (refs === null) {
35936
36005
  return;
35937
36006
  }
@@ -35939,36 +36008,25 @@ function findAllSameFileReferences(rootNode, nodeLookup, languageService) {
35939
36008
  if (results.has(ref)) {
35940
36009
  continue;
35941
36010
  }
35942
- const closestTopLevel = closestNode(ref, isTopLevelStatement);
35943
36011
  results.add(ref);
35944
- if (closestTopLevel && !import_typescript112.default.isImportDeclaration(closestTopLevel) && isOutsideRange(excludeStart, excludeEnd, closestTopLevel.getStart(), closestTopLevel.getEnd())) {
36012
+ const closestTopLevel = closestNode(ref, isTopLevelStatement);
36013
+ if (!closestTopLevel || traversedTopLevelNodes.has(closestTopLevel)) {
36014
+ continue;
36015
+ }
36016
+ if (!import_typescript112.default.isImportDeclaration(closestTopLevel) && isOutsideRange(excludeStart, excludeEnd, closestTopLevel.getStart(), closestTopLevel.getEnd())) {
36017
+ traversedTopLevelNodes.add(closestTopLevel);
35945
36018
  walk(closestTopLevel);
35946
36019
  }
35947
36020
  }
35948
36021
  })(rootNode);
35949
36022
  return results;
35950
36023
  }
35951
- function referencesToNodeWithinSameFile(node, nodeLookup, excludeStart, excludeEnd, languageService) {
35952
- const sourceFile = node.getSourceFile();
35953
- const fileName = sourceFile.fileName;
35954
- const highlights = languageService.getDocumentHighlights(fileName, node.getStart(), [fileName]);
35955
- if (highlights) {
35956
- const offsets = [];
35957
- for (const file of highlights) {
35958
- if (file.fileName === fileName) {
35959
- for (const { textSpan: { start, length }, kind } of file.highlightSpans) {
35960
- const end = start + length;
35961
- if (kind !== import_typescript112.default.HighlightSpanKind.none && isOutsideRange(excludeStart, excludeEnd, start, end)) {
35962
- offsets.push([start, end]);
35963
- }
35964
- }
35965
- }
35966
- }
35967
- if (offsets.length > 0) {
35968
- const nodes = offsetsToNodes(nodeLookup, offsets, /* @__PURE__ */ new Set());
35969
- if (nodes.size > 0) {
35970
- return nodes;
35971
- }
36024
+ function referencesToNodeWithinSameFile(node, nodeLookup, excludeStart, excludeEnd, referenceResolver) {
36025
+ const offsets = referenceResolver.findSameFileReferences(node, node.getSourceFile().fileName).filter(([start, end]) => isOutsideRange(excludeStart, excludeEnd, start, end));
36026
+ if (offsets.length > 0) {
36027
+ const nodes = offsetsToNodes(nodeLookup, offsets, /* @__PURE__ */ new Set());
36028
+ if (nodes.size > 0) {
36029
+ return nodes;
35972
36030
  }
35973
36031
  }
35974
36032
  return null;
@@ -36042,7 +36100,7 @@ var MigrationMode;
36042
36100
  MigrationMode2["standaloneBootstrap"] = "standalone-bootstrap";
36043
36101
  })(MigrationMode || (MigrationMode = {}));
36044
36102
  function standalone_migration_default(options) {
36045
- return (tree) => __async(this, null, function* () {
36103
+ return (tree, context) => __async(this, null, function* () {
36046
36104
  const { buildPaths, testPaths } = yield getProjectTsConfigPaths(tree);
36047
36105
  const basePath = process.cwd();
36048
36106
  const allPaths = [...buildPaths, ...testPaths];
@@ -36057,9 +36115,11 @@ function standalone_migration_default(options) {
36057
36115
  if (migratedFiles === 0) {
36058
36116
  throw new import_schematics.SchematicsException(`Could not find any files to migrate under the path ${pathToMigrate}. Cannot run the standalone migration.`);
36059
36117
  }
36118
+ context.logger.info("\u{1F389} Automated migration step has finished! \u{1F389}");
36119
+ context.logger.info("IMPORTANT! Please verify manually that your application builds and behaves as expected.");
36060
36120
  });
36061
36121
  }
36062
- function standaloneMigration(tree, tsconfigPath, basePath, pathToMigrate, schematicOptions) {
36122
+ function standaloneMigration(tree, tsconfigPath, basePath, pathToMigrate, schematicOptions, oldProgram) {
36063
36123
  if (schematicOptions.path.startsWith("..")) {
36064
36124
  throw new import_schematics.SchematicsException("Cannot run standalone migration outside of the current project.");
36065
36125
  }
@@ -36069,27 +36129,26 @@ function standaloneMigration(tree, tsconfigPath, basePath, pathToMigrate, schema
36069
36129
  skipLibCheck: true,
36070
36130
  skipDefaultLibCheck: true
36071
36131
  });
36072
- const program = createProgram({ rootNames, host, options });
36132
+ const referenceLookupExcludedFiles = /node_modules|\.ngtypecheck\.ts/;
36133
+ const program = createProgram({ rootNames, host, options, oldProgram });
36073
36134
  const printer = import_typescript113.default.createPrinter();
36074
36135
  if ((0, import_fs2.existsSync)(pathToMigrate) && !(0, import_fs2.statSync)(pathToMigrate).isDirectory()) {
36075
36136
  throw new import_schematics.SchematicsException(`Migration path ${pathToMigrate} has to be a directory. Cannot run the standalone migration.`);
36076
36137
  }
36077
- const sourceFiles = program.getTsProgram().getSourceFiles().filter((sourceFile) => {
36078
- return sourceFile.fileName.startsWith(pathToMigrate) && canMigrateFile(basePath, sourceFile, program.getTsProgram());
36079
- });
36138
+ const sourceFiles = program.getTsProgram().getSourceFiles().filter((sourceFile) => sourceFile.fileName.startsWith(pathToMigrate) && canMigrateFile(basePath, sourceFile, program.getTsProgram()));
36080
36139
  if (sourceFiles.length === 0) {
36081
36140
  return 0;
36082
36141
  }
36083
36142
  let pendingChanges;
36084
36143
  let filesToRemove = null;
36085
36144
  if (schematicOptions.mode === MigrationMode.pruneModules) {
36086
- const result = pruneNgModules(program, host, basePath, rootNames, sourceFiles, printer);
36145
+ const result = pruneNgModules(program, host, basePath, rootNames, sourceFiles, printer, void 0, referenceLookupExcludedFiles);
36087
36146
  pendingChanges = result.pendingChanges;
36088
36147
  filesToRemove = result.filesToRemove;
36089
36148
  } else if (schematicOptions.mode === MigrationMode.standaloneBootstrap) {
36090
- pendingChanges = toStandaloneBootstrap(program, host, basePath, rootNames, sourceFiles, printer);
36149
+ pendingChanges = toStandaloneBootstrap(program, host, basePath, rootNames, sourceFiles, printer, void 0, referenceLookupExcludedFiles, knownInternalAliasRemapper);
36091
36150
  } else {
36092
- pendingChanges = toStandalone(sourceFiles, program, printer);
36151
+ pendingChanges = toStandalone(sourceFiles, program, printer, void 0, knownInternalAliasRemapper);
36093
36152
  }
36094
36153
  for (const [file, changes] of pendingChanges.entries()) {
36095
36154
  if (filesToRemove == null ? void 0 : filesToRemove.has(file)) {
@@ -36109,6 +36168,9 @@ function standaloneMigration(tree, tsconfigPath, basePath, pathToMigrate, schema
36109
36168
  tree.delete((0, import_path8.relative)(basePath, file.fileName));
36110
36169
  }
36111
36170
  }
36171
+ if (schematicOptions.mode === MigrationMode.standaloneBootstrap) {
36172
+ return standaloneMigration(tree, tsconfigPath, basePath, pathToMigrate, __spreadProps(__spreadValues({}, schematicOptions), { mode: MigrationMode.pruneModules }), program) + sourceFiles.length;
36173
+ }
36112
36174
  return sourceFiles.length;
36113
36175
  }
36114
36176
  // Annotate the CommonJS export names for ESM import in node: