@angular/core 15.2.0 → 15.2.2
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/esm2020/src/application_ref.mjs +14 -3
- package/esm2020/src/application_tokens.mjs +1 -12
- package/esm2020/src/change_detection/change_detection.mjs +2 -2
- package/esm2020/src/change_detection/constants.mjs +1 -49
- package/esm2020/src/core.mjs +3 -3
- package/esm2020/src/core_private_export.mjs +1 -5
- package/esm2020/src/core_render3_private_export.mjs +2 -1
- package/esm2020/src/linker/query_list.mjs +6 -7
- package/esm2020/src/linker/template_ref.mjs +3 -3
- package/esm2020/src/render3/i18n/i18n_util.mjs +3 -3
- package/esm2020/src/render3/instructions/element.mjs +10 -9
- package/esm2020/src/render3/instructions/shared.mjs +4 -5
- package/esm2020/src/render3/instructions/template.mjs +2 -2
- package/esm2020/src/render3/interfaces/node.mjs +1 -1
- package/esm2020/src/render3/jit/directive.mjs +1 -2
- package/esm2020/src/util/iterable.mjs +6 -7
- package/esm2020/src/version.mjs +1 -1
- package/esm2020/testing/src/logger.mjs +3 -3
- package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
- package/fesm2015/core.mjs +43 -116
- package/fesm2015/core.mjs.map +1 -1
- package/fesm2015/testing.mjs +29 -99
- package/fesm2015/testing.mjs.map +1 -1
- package/fesm2020/core.mjs +42 -116
- package/fesm2020/core.mjs.map +1 -1
- package/fesm2020/testing.mjs +29 -99
- package/fesm2020/testing.mjs.map +1 -1
- package/index.d.ts +17 -70
- package/package.json +2 -2
- package/schematics/ng-generate/standalone-migration/bundle.js +475 -416
- package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
- package/testing/index.d.ts +1 -1
- package/esm2020/src/util/symbol.mjs +0 -30
|
@@ -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.
|
|
16117
|
+
var VERSION2 = new Version("15.2.2");
|
|
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.
|
|
17432
|
+
definitionMap.set("version", literal("15.2.2"));
|
|
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.
|
|
17501
|
+
definitionMap.set("version", literal("15.2.2"));
|
|
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.
|
|
17683
|
+
definitionMap.set("version", literal("15.2.2"));
|
|
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.
|
|
17706
|
+
definitionMap.set("version", literal("15.2.2"));
|
|
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.
|
|
17744
|
+
definitionMap.set("version", literal("15.2.2"));
|
|
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.
|
|
17765
|
+
definitionMap.set("version", literal("15.2.2"));
|
|
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.
|
|
17800
|
+
definitionMap.set("version", literal("15.2.2"));
|
|
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.
|
|
17817
|
+
var VERSION3 = new Version("15.2.2");
|
|
17818
17818
|
|
|
17819
17819
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/transformers/api.mjs
|
|
17820
17820
|
var EmitFlags;
|
|
@@ -25786,7 +25786,7 @@ function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedSt
|
|
|
25786
25786
|
file: new ParseSourceFile(sourceStr, sourceMapUrl != null ? sourceMapUrl : "")
|
|
25787
25787
|
});
|
|
25788
25788
|
}
|
|
25789
|
-
function parseTemplateDeclaration(decorator, component, containingFile, evaluator, resourceLoader, defaultPreserveWhitespaces) {
|
|
25789
|
+
function parseTemplateDeclaration(node, decorator, component, containingFile, evaluator, depTracker, resourceLoader, defaultPreserveWhitespaces) {
|
|
25790
25790
|
let preserveWhitespaces = defaultPreserveWhitespaces;
|
|
25791
25791
|
if (component.has("preserveWhitespaces")) {
|
|
25792
25792
|
const expr = component.get("preserveWhitespaces");
|
|
@@ -25822,6 +25822,9 @@ function parseTemplateDeclaration(decorator, component, containingFile, evaluato
|
|
|
25822
25822
|
resolvedTemplateUrl: resourceUrl
|
|
25823
25823
|
};
|
|
25824
25824
|
} catch (e) {
|
|
25825
|
+
if (depTracker !== null) {
|
|
25826
|
+
depTracker.recordDependencyAnalysisFailure(node.getSourceFile());
|
|
25827
|
+
}
|
|
25825
25828
|
throw makeResourceNotFoundError(templateUrl, templateUrlExpr, 0);
|
|
25826
25829
|
}
|
|
25827
25830
|
} else if (component.has("template")) {
|
|
@@ -25849,7 +25852,7 @@ function preloadAndParseTemplate(evaluator, resourceLoader, depTracker, preanaly
|
|
|
25849
25852
|
const templatePromise = resourceLoader.preload(resourceUrl, { type: "template", containingFile });
|
|
25850
25853
|
if (templatePromise !== void 0) {
|
|
25851
25854
|
return templatePromise.then(() => {
|
|
25852
|
-
const templateDecl = parseTemplateDeclaration(decorator, component, containingFile, evaluator, resourceLoader, defaultPreserveWhitespaces);
|
|
25855
|
+
const templateDecl = parseTemplateDeclaration(node, decorator, component, containingFile, evaluator, depTracker, resourceLoader, defaultPreserveWhitespaces);
|
|
25853
25856
|
const template = extractTemplate(node, templateDecl, evaluator, depTracker, resourceLoader, options);
|
|
25854
25857
|
preanalyzeTemplateCache.set(node, template);
|
|
25855
25858
|
return template;
|
|
@@ -25858,10 +25861,13 @@ function preloadAndParseTemplate(evaluator, resourceLoader, depTracker, preanaly
|
|
|
25858
25861
|
return Promise.resolve(null);
|
|
25859
25862
|
}
|
|
25860
25863
|
} catch (e) {
|
|
25864
|
+
if (depTracker !== null) {
|
|
25865
|
+
depTracker.recordDependencyAnalysisFailure(node.getSourceFile());
|
|
25866
|
+
}
|
|
25861
25867
|
throw makeResourceNotFoundError(templateUrl, templateUrlExpr, 0);
|
|
25862
25868
|
}
|
|
25863
25869
|
} else {
|
|
25864
|
-
const templateDecl = parseTemplateDeclaration(decorator, component, containingFile, evaluator, resourceLoader, defaultPreserveWhitespaces);
|
|
25870
|
+
const templateDecl = parseTemplateDeclaration(node, decorator, component, containingFile, evaluator, depTracker, resourceLoader, defaultPreserveWhitespaces);
|
|
25865
25871
|
const template = extractTemplate(node, templateDecl, evaluator, depTracker, resourceLoader, options);
|
|
25866
25872
|
preanalyzeTemplateCache.set(node, template);
|
|
25867
25873
|
return Promise.resolve(template);
|
|
@@ -26291,7 +26297,7 @@ var ComponentDecoratorHandler = class {
|
|
|
26291
26297
|
this.preanalyzeTemplateCache.delete(node);
|
|
26292
26298
|
template = preanalyzed;
|
|
26293
26299
|
} else {
|
|
26294
|
-
const templateDecl = parseTemplateDeclaration(decorator, component, containingFile, this.evaluator, this.resourceLoader, this.defaultPreserveWhitespaces);
|
|
26300
|
+
const templateDecl = parseTemplateDeclaration(node, decorator, component, containingFile, this.evaluator, this.depTracker, this.resourceLoader, this.defaultPreserveWhitespaces);
|
|
26295
26301
|
template = extractTemplate(node, templateDecl, this.evaluator, this.depTracker, this.resourceLoader, {
|
|
26296
26302
|
enableI18nLegacyMessageIdFormat: this.enableI18nLegacyMessageIdFormat,
|
|
26297
26303
|
i18nNormalizeLineEndingsInICUs: this.i18nNormalizeLineEndingsInICUs,
|
|
@@ -26317,6 +26323,9 @@ var ComponentDecoratorHandler = class {
|
|
|
26317
26323
|
this.depTracker.addResourceDependency(node.getSourceFile(), absoluteFrom(resourceUrl));
|
|
26318
26324
|
}
|
|
26319
26325
|
} catch (e) {
|
|
26326
|
+
if (this.depTracker !== null) {
|
|
26327
|
+
this.depTracker.recordDependencyAnalysisFailure(node.getSourceFile());
|
|
26328
|
+
}
|
|
26320
26329
|
if (diagnostics === void 0) {
|
|
26321
26330
|
diagnostics = [];
|
|
26322
26331
|
}
|
|
@@ -34611,227 +34620,14 @@ setFileSystem(new NodeJSFileSystem());
|
|
|
34611
34620
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/index.mjs
|
|
34612
34621
|
var import_fs2 = require("fs");
|
|
34613
34622
|
var import_path8 = require("path");
|
|
34614
|
-
var
|
|
34623
|
+
var import_typescript113 = __toESM(require("typescript"), 1);
|
|
34615
34624
|
|
|
34616
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/
|
|
34617
|
-
var import_core13 = require("@angular-devkit/core");
|
|
34618
|
-
function getProjectTsConfigPaths(tree) {
|
|
34619
|
-
return __async(this, null, function* () {
|
|
34620
|
-
const buildPaths = /* @__PURE__ */ new Set();
|
|
34621
|
-
const testPaths = /* @__PURE__ */ new Set();
|
|
34622
|
-
const workspace = yield getWorkspace(tree);
|
|
34623
|
-
for (const [, project] of workspace.projects) {
|
|
34624
|
-
for (const [name, target] of project.targets) {
|
|
34625
|
-
if (name !== "build" && name !== "test") {
|
|
34626
|
-
continue;
|
|
34627
|
-
}
|
|
34628
|
-
for (const [, options] of allTargetOptions(target)) {
|
|
34629
|
-
const tsConfig = options.tsConfig;
|
|
34630
|
-
if (typeof tsConfig !== "string" || !tree.exists(tsConfig)) {
|
|
34631
|
-
continue;
|
|
34632
|
-
}
|
|
34633
|
-
if (name === "build") {
|
|
34634
|
-
buildPaths.add((0, import_core13.normalize)(tsConfig));
|
|
34635
|
-
} else {
|
|
34636
|
-
testPaths.add((0, import_core13.normalize)(tsConfig));
|
|
34637
|
-
}
|
|
34638
|
-
}
|
|
34639
|
-
}
|
|
34640
|
-
}
|
|
34641
|
-
return {
|
|
34642
|
-
buildPaths: [...buildPaths],
|
|
34643
|
-
testPaths: [...testPaths]
|
|
34644
|
-
};
|
|
34645
|
-
});
|
|
34646
|
-
}
|
|
34647
|
-
function* allTargetOptions(target) {
|
|
34648
|
-
if (target.options) {
|
|
34649
|
-
yield [void 0, target.options];
|
|
34650
|
-
}
|
|
34651
|
-
if (!target.configurations) {
|
|
34652
|
-
return;
|
|
34653
|
-
}
|
|
34654
|
-
for (const [name, options] of Object.entries(target.configurations)) {
|
|
34655
|
-
if (options) {
|
|
34656
|
-
yield [name, options];
|
|
34657
|
-
}
|
|
34658
|
-
}
|
|
34659
|
-
}
|
|
34660
|
-
function createHost(tree) {
|
|
34661
|
-
return {
|
|
34662
|
-
readFile(path3) {
|
|
34663
|
-
return __async(this, null, function* () {
|
|
34664
|
-
const data = tree.read(path3);
|
|
34665
|
-
if (!data) {
|
|
34666
|
-
throw new Error("File not found.");
|
|
34667
|
-
}
|
|
34668
|
-
return import_core13.virtualFs.fileBufferToString(data);
|
|
34669
|
-
});
|
|
34670
|
-
},
|
|
34671
|
-
writeFile(path3, data) {
|
|
34672
|
-
return __async(this, null, function* () {
|
|
34673
|
-
return tree.overwrite(path3, data);
|
|
34674
|
-
});
|
|
34675
|
-
},
|
|
34676
|
-
isDirectory(path3) {
|
|
34677
|
-
return __async(this, null, function* () {
|
|
34678
|
-
return !tree.exists(path3) && tree.getDir(path3).subfiles.length > 0;
|
|
34679
|
-
});
|
|
34680
|
-
},
|
|
34681
|
-
isFile(path3) {
|
|
34682
|
-
return __async(this, null, function* () {
|
|
34683
|
-
return tree.exists(path3);
|
|
34684
|
-
});
|
|
34685
|
-
}
|
|
34686
|
-
};
|
|
34687
|
-
}
|
|
34688
|
-
function getWorkspace(tree) {
|
|
34689
|
-
return __async(this, null, function* () {
|
|
34690
|
-
const host = createHost(tree);
|
|
34691
|
-
const { workspace } = yield import_core13.workspaces.readWorkspace("/", host);
|
|
34692
|
-
return workspace;
|
|
34693
|
-
});
|
|
34694
|
-
}
|
|
34695
|
-
|
|
34696
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/compiler_host.mjs
|
|
34697
|
-
var import_path4 = require("path");
|
|
34625
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/change_tracker.mjs
|
|
34698
34626
|
var import_typescript102 = __toESM(require("typescript"), 1);
|
|
34699
34627
|
|
|
34700
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/parse_tsconfig.mjs
|
|
34701
|
-
var path2 = __toESM(require("path"), 1);
|
|
34702
|
-
var import_typescript101 = __toESM(require("typescript"), 1);
|
|
34703
|
-
function parseTsconfigFile(tsconfigPath, basePath) {
|
|
34704
|
-
const { config } = import_typescript101.default.readConfigFile(tsconfigPath, import_typescript101.default.sys.readFile);
|
|
34705
|
-
const parseConfigHost = {
|
|
34706
|
-
useCaseSensitiveFileNames: import_typescript101.default.sys.useCaseSensitiveFileNames,
|
|
34707
|
-
fileExists: import_typescript101.default.sys.fileExists,
|
|
34708
|
-
readDirectory: import_typescript101.default.sys.readDirectory,
|
|
34709
|
-
readFile: import_typescript101.default.sys.readFile
|
|
34710
|
-
};
|
|
34711
|
-
if (!path2.isAbsolute(basePath)) {
|
|
34712
|
-
throw Error("Unexpected relative base path has been specified.");
|
|
34713
|
-
}
|
|
34714
|
-
return import_typescript101.default.parseJsonConfigFileContent(config, parseConfigHost, basePath, {});
|
|
34715
|
-
}
|
|
34716
|
-
|
|
34717
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/compiler_host.mjs
|
|
34718
|
-
function createProgramOptions(tree, tsconfigPath, basePath, fakeFileRead, additionalFiles, optionOverrides) {
|
|
34719
|
-
tsconfigPath = (0, import_path4.resolve)(basePath, tsconfigPath);
|
|
34720
|
-
const parsed = parseTsconfigFile(tsconfigPath, (0, import_path4.dirname)(tsconfigPath));
|
|
34721
|
-
const options = optionOverrides ? __spreadValues(__spreadValues({}, parsed.options), optionOverrides) : parsed.options;
|
|
34722
|
-
const host = createMigrationCompilerHost(tree, options, basePath, fakeFileRead);
|
|
34723
|
-
return { rootNames: parsed.fileNames.concat(additionalFiles || []), options, host };
|
|
34724
|
-
}
|
|
34725
|
-
function createMigrationCompilerHost(tree, options, basePath, fakeRead) {
|
|
34726
|
-
const host = import_typescript102.default.createCompilerHost(options, true);
|
|
34727
|
-
const defaultReadFile = host.readFile;
|
|
34728
|
-
host.readFile = (fileName) => {
|
|
34729
|
-
var _a;
|
|
34730
|
-
const treeRelativePath = (0, import_path4.relative)(basePath, fileName);
|
|
34731
|
-
let result = fakeRead == null ? void 0 : fakeRead(treeRelativePath);
|
|
34732
|
-
if (typeof result !== "string") {
|
|
34733
|
-
result = treeRelativePath.startsWith("..") ? defaultReadFile.call(host, fileName) : (_a = tree.read(treeRelativePath)) == null ? void 0 : _a.toString();
|
|
34734
|
-
}
|
|
34735
|
-
return typeof result === "string" ? result.replace(/^\uFEFF/, "") : void 0;
|
|
34736
|
-
};
|
|
34737
|
-
return host;
|
|
34738
|
-
}
|
|
34739
|
-
function canMigrateFile(basePath, sourceFile, program) {
|
|
34740
|
-
if (sourceFile.fileName.endsWith(".ngtypecheck.ts") || sourceFile.isDeclarationFile || program.isSourceFileFromExternalLibrary(sourceFile)) {
|
|
34741
|
-
return false;
|
|
34742
|
-
}
|
|
34743
|
-
return !(0, import_path4.relative)(basePath, sourceFile.fileName).startsWith("..");
|
|
34744
|
-
}
|
|
34745
|
-
|
|
34746
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/prune-modules.mjs
|
|
34747
|
-
var import_typescript108 = __toESM(require("typescript"), 1);
|
|
34748
|
-
|
|
34749
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/decorators.mjs
|
|
34750
|
-
var import_typescript104 = __toESM(require("typescript"), 1);
|
|
34751
|
-
|
|
34752
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/imports.mjs
|
|
34753
|
-
var import_typescript103 = __toESM(require("typescript"), 1);
|
|
34754
|
-
function getImportOfIdentifier(typeChecker, node) {
|
|
34755
|
-
const symbol = typeChecker.getSymbolAtLocation(node);
|
|
34756
|
-
if (!symbol || symbol.declarations === void 0 || !symbol.declarations.length) {
|
|
34757
|
-
return null;
|
|
34758
|
-
}
|
|
34759
|
-
const decl = symbol.declarations[0];
|
|
34760
|
-
if (!import_typescript103.default.isImportSpecifier(decl)) {
|
|
34761
|
-
return null;
|
|
34762
|
-
}
|
|
34763
|
-
const importDecl = decl.parent.parent.parent;
|
|
34764
|
-
if (!import_typescript103.default.isStringLiteral(importDecl.moduleSpecifier)) {
|
|
34765
|
-
return null;
|
|
34766
|
-
}
|
|
34767
|
-
return {
|
|
34768
|
-
name: decl.propertyName ? decl.propertyName.text : decl.name.text,
|
|
34769
|
-
importModule: importDecl.moduleSpecifier.text,
|
|
34770
|
-
node: importDecl
|
|
34771
|
-
};
|
|
34772
|
-
}
|
|
34773
|
-
function getImportSpecifier(sourceFile, moduleName, specifierName) {
|
|
34774
|
-
var _a;
|
|
34775
|
-
for (const node of sourceFile.statements) {
|
|
34776
|
-
if (import_typescript103.default.isImportDeclaration(node) && import_typescript103.default.isStringLiteral(node.moduleSpecifier)) {
|
|
34777
|
-
const isMatch = typeof moduleName === "string" ? node.moduleSpecifier.text === moduleName : moduleName.test(node.moduleSpecifier.text);
|
|
34778
|
-
const namedBindings = (_a = node.importClause) == null ? void 0 : _a.namedBindings;
|
|
34779
|
-
if (isMatch && namedBindings && import_typescript103.default.isNamedImports(namedBindings)) {
|
|
34780
|
-
const match = findImportSpecifier(namedBindings.elements, specifierName);
|
|
34781
|
-
if (match) {
|
|
34782
|
-
return match;
|
|
34783
|
-
}
|
|
34784
|
-
}
|
|
34785
|
-
}
|
|
34786
|
-
}
|
|
34787
|
-
return null;
|
|
34788
|
-
}
|
|
34789
|
-
function findImportSpecifier(nodes, specifierName) {
|
|
34790
|
-
return nodes.find((element) => {
|
|
34791
|
-
const { name, propertyName } = element;
|
|
34792
|
-
return propertyName ? propertyName.text === specifierName : name.text === specifierName;
|
|
34793
|
-
});
|
|
34794
|
-
}
|
|
34795
|
-
|
|
34796
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/decorators.mjs
|
|
34797
|
-
function getCallDecoratorImport(typeChecker, decorator) {
|
|
34798
|
-
if (!import_typescript104.default.isCallExpression(decorator.expression) || !import_typescript104.default.isIdentifier(decorator.expression.expression)) {
|
|
34799
|
-
return null;
|
|
34800
|
-
}
|
|
34801
|
-
const identifier = decorator.expression.expression;
|
|
34802
|
-
return getImportOfIdentifier(typeChecker, identifier);
|
|
34803
|
-
}
|
|
34804
|
-
|
|
34805
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/ng_decorators.mjs
|
|
34806
|
-
function getAngularDecorators(typeChecker, decorators) {
|
|
34807
|
-
return decorators.map((node) => ({ node, importData: getCallDecoratorImport(typeChecker, node) })).filter(({ importData }) => importData && importData.importModule.startsWith("@angular/")).map(({ node, importData }) => ({
|
|
34808
|
-
node,
|
|
34809
|
-
name: importData.name,
|
|
34810
|
-
moduleName: importData.importModule,
|
|
34811
|
-
importNode: importData.node
|
|
34812
|
-
}));
|
|
34813
|
-
}
|
|
34814
|
-
|
|
34815
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/nodes.mjs
|
|
34816
|
-
var import_typescript105 = __toESM(require("typescript"), 1);
|
|
34817
|
-
function closestNode(node, predicate) {
|
|
34818
|
-
let current = node.parent;
|
|
34819
|
-
while (current && !import_typescript105.default.isSourceFile(current)) {
|
|
34820
|
-
if (predicate(current)) {
|
|
34821
|
-
return current;
|
|
34822
|
-
}
|
|
34823
|
-
current = current.parent;
|
|
34824
|
-
}
|
|
34825
|
-
return null;
|
|
34826
|
-
}
|
|
34827
|
-
|
|
34828
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/util.mjs
|
|
34829
|
-
var import_path6 = require("path");
|
|
34830
|
-
var import_typescript107 = __toESM(require("typescript"), 1);
|
|
34831
|
-
|
|
34832
34628
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/import_manager.mjs
|
|
34833
|
-
var
|
|
34834
|
-
var
|
|
34629
|
+
var import_path4 = require("path");
|
|
34630
|
+
var import_typescript101 = __toESM(require("typescript"), 1);
|
|
34835
34631
|
var IS_AFTER_TS_492 = isAfterVersion2(4, 9);
|
|
34836
34632
|
var ImportManager2 = class {
|
|
34837
34633
|
constructor(getUpdateRecorder, printer) {
|
|
@@ -34844,7 +34640,7 @@ var ImportManager2 = class {
|
|
|
34844
34640
|
this.importCache = [];
|
|
34845
34641
|
}
|
|
34846
34642
|
addImportToSourceFile(sourceFile, symbolName, moduleName, alias = null, typeImport = false) {
|
|
34847
|
-
const sourceDir = (0,
|
|
34643
|
+
const sourceDir = (0, import_path4.dirname)(sourceFile.fileName);
|
|
34848
34644
|
let importStartIndex = 0;
|
|
34849
34645
|
let existingImport = null;
|
|
34850
34646
|
const cachedImport = this.importCache.find((c) => c.sourceFile === sourceFile && c.symbolName === symbolName && c.moduleName === moduleName && c.alias === alias);
|
|
@@ -34853,21 +34649,21 @@ var ImportManager2 = class {
|
|
|
34853
34649
|
}
|
|
34854
34650
|
for (let i = sourceFile.statements.length - 1; i >= 0; i--) {
|
|
34855
34651
|
const statement = sourceFile.statements[i];
|
|
34856
|
-
if (!
|
|
34652
|
+
if (!import_typescript101.default.isImportDeclaration(statement) || !import_typescript101.default.isStringLiteral(statement.moduleSpecifier) || !statement.importClause) {
|
|
34857
34653
|
continue;
|
|
34858
34654
|
}
|
|
34859
34655
|
if (importStartIndex === 0) {
|
|
34860
34656
|
importStartIndex = this._getEndPositionOfNode(statement);
|
|
34861
34657
|
}
|
|
34862
34658
|
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
34863
|
-
if (moduleSpecifier.startsWith(".") && (0,
|
|
34659
|
+
if (moduleSpecifier.startsWith(".") && (0, import_path4.resolve)(sourceDir, moduleSpecifier) !== (0, import_path4.resolve)(sourceDir, moduleName) || moduleSpecifier !== moduleName) {
|
|
34864
34660
|
continue;
|
|
34865
34661
|
}
|
|
34866
34662
|
if (statement.importClause.namedBindings) {
|
|
34867
34663
|
const namedBindings = statement.importClause.namedBindings;
|
|
34868
|
-
if (
|
|
34869
|
-
return
|
|
34870
|
-
} else if (
|
|
34664
|
+
if (import_typescript101.default.isNamespaceImport(namedBindings) && !typeImport) {
|
|
34665
|
+
return import_typescript101.default.factory.createPropertyAccessExpression(import_typescript101.default.factory.createIdentifier(namedBindings.name.text), import_typescript101.default.factory.createIdentifier(alias || symbolName || "default"));
|
|
34666
|
+
} else if (import_typescript101.default.isNamedImports(namedBindings) && symbolName) {
|
|
34871
34667
|
const existingElement = namedBindings.elements.find((e) => {
|
|
34872
34668
|
if (alias) {
|
|
34873
34669
|
return e.propertyName && e.name.text === alias && e.propertyName.text === symbolName;
|
|
@@ -34875,12 +34671,12 @@ var ImportManager2 = class {
|
|
|
34875
34671
|
return e.propertyName ? e.propertyName.text === symbolName : e.name.text === symbolName;
|
|
34876
34672
|
});
|
|
34877
34673
|
if (existingElement) {
|
|
34878
|
-
return
|
|
34674
|
+
return import_typescript101.default.factory.createIdentifier(existingElement.name.text);
|
|
34879
34675
|
}
|
|
34880
34676
|
existingImport = statement;
|
|
34881
34677
|
}
|
|
34882
34678
|
} else if (statement.importClause.name && !symbolName) {
|
|
34883
|
-
return
|
|
34679
|
+
return import_typescript101.default.factory.createIdentifier(statement.importClause.name.text);
|
|
34884
34680
|
}
|
|
34885
34681
|
}
|
|
34886
34682
|
if (existingImport) {
|
|
@@ -34904,7 +34700,7 @@ var ImportManager2 = class {
|
|
|
34904
34700
|
if (!importMap.has(moduleName)) {
|
|
34905
34701
|
importMap.set(moduleName, []);
|
|
34906
34702
|
}
|
|
34907
|
-
importMap.get(moduleName).push(
|
|
34703
|
+
importMap.get(moduleName).push(import_typescript101.default.factory.createImportSpecifier(false, propertyName, name));
|
|
34908
34704
|
} else {
|
|
34909
34705
|
const importMap = this.newImports.get(sourceFile).defaultImports;
|
|
34910
34706
|
identifier = this._getUniqueIdentifier(sourceFile, "defaultExport");
|
|
@@ -34918,19 +34714,19 @@ var ImportManager2 = class {
|
|
|
34918
34714
|
const sourceFile = importDecl.getSourceFile();
|
|
34919
34715
|
const recorder = this.getUpdateRecorder(sourceFile);
|
|
34920
34716
|
const namedBindings = importDecl.importClause.namedBindings;
|
|
34921
|
-
const newNamedBindings =
|
|
34922
|
-
const newNamedBindingsText = this.printer.printNode(
|
|
34717
|
+
const newNamedBindings = import_typescript101.default.factory.updateNamedImports(namedBindings, namedBindings.elements.concat(expressions.map(({ propertyName, importName }) => import_typescript101.default.factory.createImportSpecifier(false, propertyName, importName))));
|
|
34718
|
+
const newNamedBindingsText = this.printer.printNode(import_typescript101.default.EmitHint.Unspecified, newNamedBindings, sourceFile);
|
|
34923
34719
|
recorder.updateExistingImport(namedBindings, newNamedBindingsText);
|
|
34924
34720
|
});
|
|
34925
34721
|
this.newImports.forEach(({ importStartIndex, defaultImports, namedImports }, sourceFile) => {
|
|
34926
34722
|
const recorder = this.getUpdateRecorder(sourceFile);
|
|
34927
34723
|
const useSingleQuotes = this._getQuoteStyle(sourceFile) === 0;
|
|
34928
34724
|
defaultImports.forEach((identifier, moduleName) => {
|
|
34929
|
-
const newImport = createImportDeclaration2(void 0,
|
|
34725
|
+
const newImport = createImportDeclaration2(void 0, import_typescript101.default.factory.createImportClause(false, identifier, void 0), import_typescript101.default.factory.createStringLiteral(moduleName, useSingleQuotes));
|
|
34930
34726
|
recorder.addNewImport(importStartIndex, this._getNewImportText(importStartIndex, newImport, sourceFile));
|
|
34931
34727
|
});
|
|
34932
34728
|
namedImports.forEach((specifiers, moduleName) => {
|
|
34933
|
-
const newImport = createImportDeclaration2(void 0,
|
|
34729
|
+
const newImport = createImportDeclaration2(void 0, import_typescript101.default.factory.createImportClause(false, void 0, import_typescript101.default.factory.createNamedImports(specifiers)), import_typescript101.default.factory.createStringLiteral(moduleName, useSingleQuotes));
|
|
34934
34730
|
recorder.addNewImport(importStartIndex, this._getNewImportText(importStartIndex, newImport, sourceFile));
|
|
34935
34731
|
});
|
|
34936
34732
|
});
|
|
@@ -34938,7 +34734,7 @@ var ImportManager2 = class {
|
|
|
34938
34734
|
_getUniqueIdentifier(sourceFile, baseName) {
|
|
34939
34735
|
if (this.isUniqueIdentifierName(sourceFile, baseName)) {
|
|
34940
34736
|
this._recordUsedIdentifier(sourceFile, baseName);
|
|
34941
|
-
return
|
|
34737
|
+
return import_typescript101.default.factory.createIdentifier(baseName);
|
|
34942
34738
|
}
|
|
34943
34739
|
let name = null;
|
|
34944
34740
|
let counter = 1;
|
|
@@ -34946,7 +34742,7 @@ var ImportManager2 = class {
|
|
|
34946
34742
|
name = `${baseName}_${counter++}`;
|
|
34947
34743
|
} while (!this.isUniqueIdentifierName(sourceFile, name));
|
|
34948
34744
|
this._recordUsedIdentifier(sourceFile, name);
|
|
34949
|
-
return
|
|
34745
|
+
return import_typescript101.default.factory.createIdentifier(name);
|
|
34950
34746
|
}
|
|
34951
34747
|
isUniqueIdentifierName(sourceFile, name) {
|
|
34952
34748
|
if (this.usedIdentifierNames.has(sourceFile) && this.usedIdentifierNames.get(sourceFile).indexOf(name) !== -1) {
|
|
@@ -34955,7 +34751,7 @@ var ImportManager2 = class {
|
|
|
34955
34751
|
const nodeQueue = [sourceFile];
|
|
34956
34752
|
while (nodeQueue.length) {
|
|
34957
34753
|
const node = nodeQueue.shift();
|
|
34958
|
-
if (
|
|
34754
|
+
if (import_typescript101.default.isIdentifier(node) && node.text === name && (!import_typescript101.default.isImportSpecifier(node.parent) || node.parent.propertyName !== node)) {
|
|
34959
34755
|
return false;
|
|
34960
34756
|
}
|
|
34961
34757
|
nodeQueue.push(...node.getChildren());
|
|
@@ -34967,21 +34763,21 @@ var ImportManager2 = class {
|
|
|
34967
34763
|
}
|
|
34968
34764
|
_getEndPositionOfNode(node) {
|
|
34969
34765
|
const nodeEndPos = node.getEnd();
|
|
34970
|
-
const commentRanges =
|
|
34766
|
+
const commentRanges = import_typescript101.default.getTrailingCommentRanges(node.getSourceFile().text, nodeEndPos);
|
|
34971
34767
|
if (!commentRanges || !commentRanges.length) {
|
|
34972
34768
|
return nodeEndPos;
|
|
34973
34769
|
}
|
|
34974
34770
|
return commentRanges[commentRanges.length - 1].end;
|
|
34975
34771
|
}
|
|
34976
34772
|
_getNewImportText(importStartIndex, newImport, sourceFile) {
|
|
34977
|
-
const text = this.printer.printNode(
|
|
34773
|
+
const text = this.printer.printNode(import_typescript101.default.EmitHint.Unspecified, newImport, sourceFile);
|
|
34978
34774
|
return importStartIndex === 0 ? `${text}
|
|
34979
34775
|
` : `
|
|
34980
34776
|
${text}`;
|
|
34981
34777
|
}
|
|
34982
34778
|
_getImportParts(sourceFile, symbolName, alias) {
|
|
34983
|
-
const symbolIdentifier =
|
|
34984
|
-
const aliasIdentifier = alias ?
|
|
34779
|
+
const symbolIdentifier = import_typescript101.default.factory.createIdentifier(symbolName);
|
|
34780
|
+
const aliasIdentifier = alias ? import_typescript101.default.factory.createIdentifier(alias) : null;
|
|
34985
34781
|
const generatedUniqueIdentifier = this._getUniqueIdentifier(sourceFile, alias || symbolName);
|
|
34986
34782
|
const needsGeneratedUniqueName = generatedUniqueIdentifier.text !== (alias || symbolName);
|
|
34987
34783
|
let propertyName;
|
|
@@ -35001,7 +34797,7 @@ ${text}`;
|
|
|
35001
34797
|
if (!this.quoteStyles.hasOwnProperty(sourceFile.fileName)) {
|
|
35002
34798
|
let quoteStyle;
|
|
35003
34799
|
for (const statement of sourceFile.statements) {
|
|
35004
|
-
if (
|
|
34800
|
+
if (import_typescript101.default.isImportDeclaration(statement) && import_typescript101.default.isStringLiteralLike(statement.moduleSpecifier)) {
|
|
35005
34801
|
quoteStyle = statement.moduleSpecifier.getText().trim().startsWith('"') ? 1 : 0;
|
|
35006
34802
|
break;
|
|
35007
34803
|
}
|
|
@@ -35012,17 +34808,17 @@ ${text}`;
|
|
|
35012
34808
|
}
|
|
35013
34809
|
};
|
|
35014
34810
|
function createImportDeclaration2(modifiers, importClause, moduleSpecifier, assertClause) {
|
|
35015
|
-
return IS_AFTER_TS_492 ?
|
|
34811
|
+
return IS_AFTER_TS_492 ? import_typescript101.default.factory.createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause) : import_typescript101.default.factory.createImportDeclaration(void 0, modifiers, importClause, moduleSpecifier, assertClause);
|
|
35016
34812
|
}
|
|
35017
34813
|
function isAfterVersion2(targetMajor, targetMinor) {
|
|
35018
|
-
const [major, minor] =
|
|
34814
|
+
const [major, minor] = import_typescript101.default.versionMajorMinor.split(".").map((part) => parseInt(part));
|
|
35019
34815
|
if (major < targetMajor) {
|
|
35020
34816
|
return false;
|
|
35021
34817
|
}
|
|
35022
34818
|
return major === targetMajor ? minor >= targetMinor : true;
|
|
35023
34819
|
}
|
|
35024
34820
|
|
|
35025
|
-
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/
|
|
34821
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/change_tracker.mjs
|
|
35026
34822
|
var ChangeTracker = class {
|
|
35027
34823
|
constructor(_printer, _importRemapper) {
|
|
35028
34824
|
this._printer = _printer;
|
|
@@ -35039,7 +34835,7 @@ var ChangeTracker = class {
|
|
|
35039
34835
|
replaceText(sourceFile, start, removeLength, text) {
|
|
35040
34836
|
this._trackChange(sourceFile, { start, removeLength, text });
|
|
35041
34837
|
}
|
|
35042
|
-
replaceNode(oldNode, newNode, emitHint =
|
|
34838
|
+
replaceNode(oldNode, newNode, emitHint = import_typescript102.default.EmitHint.Unspecified, sourceFileWhenPrinting) {
|
|
35043
34839
|
const sourceFile = oldNode.getSourceFile();
|
|
35044
34840
|
this.replaceText(sourceFile, oldNode.getStart(), oldNode.getWidth(), this._printer.printNode(emitHint, newNode, sourceFileWhenPrinting || sourceFile));
|
|
35045
34841
|
}
|
|
@@ -35048,7 +34844,7 @@ var ChangeTracker = class {
|
|
|
35048
34844
|
}
|
|
35049
34845
|
addImport(sourceFile, symbolName, moduleName, alias = null) {
|
|
35050
34846
|
if (this._importRemapper) {
|
|
35051
|
-
moduleName = this._importRemapper(moduleName);
|
|
34847
|
+
moduleName = this._importRemapper(moduleName, sourceFile.fileName);
|
|
35052
34848
|
}
|
|
35053
34849
|
moduleName = normalizePath(moduleName);
|
|
35054
34850
|
return this._importManager.addImportToSourceFile(sourceFile, symbolName, moduleName, alias);
|
|
@@ -35071,6 +34867,225 @@ var ChangeTracker = class {
|
|
|
35071
34867
|
}
|
|
35072
34868
|
}
|
|
35073
34869
|
};
|
|
34870
|
+
function normalizePath(path3) {
|
|
34871
|
+
return path3.replace(/\\/g, "/");
|
|
34872
|
+
}
|
|
34873
|
+
|
|
34874
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/project_tsconfig_paths.mjs
|
|
34875
|
+
var import_core13 = require("@angular-devkit/core");
|
|
34876
|
+
function getProjectTsConfigPaths(tree) {
|
|
34877
|
+
return __async(this, null, function* () {
|
|
34878
|
+
const buildPaths = /* @__PURE__ */ new Set();
|
|
34879
|
+
const testPaths = /* @__PURE__ */ new Set();
|
|
34880
|
+
const workspace = yield getWorkspace(tree);
|
|
34881
|
+
for (const [, project] of workspace.projects) {
|
|
34882
|
+
for (const [name, target] of project.targets) {
|
|
34883
|
+
if (name !== "build" && name !== "test") {
|
|
34884
|
+
continue;
|
|
34885
|
+
}
|
|
34886
|
+
for (const [, options] of allTargetOptions(target)) {
|
|
34887
|
+
const tsConfig = options.tsConfig;
|
|
34888
|
+
if (typeof tsConfig !== "string" || !tree.exists(tsConfig)) {
|
|
34889
|
+
continue;
|
|
34890
|
+
}
|
|
34891
|
+
if (name === "build") {
|
|
34892
|
+
buildPaths.add((0, import_core13.normalize)(tsConfig));
|
|
34893
|
+
} else {
|
|
34894
|
+
testPaths.add((0, import_core13.normalize)(tsConfig));
|
|
34895
|
+
}
|
|
34896
|
+
}
|
|
34897
|
+
}
|
|
34898
|
+
}
|
|
34899
|
+
return {
|
|
34900
|
+
buildPaths: [...buildPaths],
|
|
34901
|
+
testPaths: [...testPaths]
|
|
34902
|
+
};
|
|
34903
|
+
});
|
|
34904
|
+
}
|
|
34905
|
+
function* allTargetOptions(target) {
|
|
34906
|
+
if (target.options) {
|
|
34907
|
+
yield [void 0, target.options];
|
|
34908
|
+
}
|
|
34909
|
+
if (!target.configurations) {
|
|
34910
|
+
return;
|
|
34911
|
+
}
|
|
34912
|
+
for (const [name, options] of Object.entries(target.configurations)) {
|
|
34913
|
+
if (options) {
|
|
34914
|
+
yield [name, options];
|
|
34915
|
+
}
|
|
34916
|
+
}
|
|
34917
|
+
}
|
|
34918
|
+
function createHost(tree) {
|
|
34919
|
+
return {
|
|
34920
|
+
readFile(path3) {
|
|
34921
|
+
return __async(this, null, function* () {
|
|
34922
|
+
const data = tree.read(path3);
|
|
34923
|
+
if (!data) {
|
|
34924
|
+
throw new Error("File not found.");
|
|
34925
|
+
}
|
|
34926
|
+
return import_core13.virtualFs.fileBufferToString(data);
|
|
34927
|
+
});
|
|
34928
|
+
},
|
|
34929
|
+
writeFile(path3, data) {
|
|
34930
|
+
return __async(this, null, function* () {
|
|
34931
|
+
return tree.overwrite(path3, data);
|
|
34932
|
+
});
|
|
34933
|
+
},
|
|
34934
|
+
isDirectory(path3) {
|
|
34935
|
+
return __async(this, null, function* () {
|
|
34936
|
+
return !tree.exists(path3) && tree.getDir(path3).subfiles.length > 0;
|
|
34937
|
+
});
|
|
34938
|
+
},
|
|
34939
|
+
isFile(path3) {
|
|
34940
|
+
return __async(this, null, function* () {
|
|
34941
|
+
return tree.exists(path3);
|
|
34942
|
+
});
|
|
34943
|
+
}
|
|
34944
|
+
};
|
|
34945
|
+
}
|
|
34946
|
+
function getWorkspace(tree) {
|
|
34947
|
+
return __async(this, null, function* () {
|
|
34948
|
+
const host = createHost(tree);
|
|
34949
|
+
const { workspace } = yield import_core13.workspaces.readWorkspace("/", host);
|
|
34950
|
+
return workspace;
|
|
34951
|
+
});
|
|
34952
|
+
}
|
|
34953
|
+
|
|
34954
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/compiler_host.mjs
|
|
34955
|
+
var import_path5 = require("path");
|
|
34956
|
+
var import_typescript104 = __toESM(require("typescript"), 1);
|
|
34957
|
+
|
|
34958
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/parse_tsconfig.mjs
|
|
34959
|
+
var path2 = __toESM(require("path"), 1);
|
|
34960
|
+
var import_typescript103 = __toESM(require("typescript"), 1);
|
|
34961
|
+
function parseTsconfigFile(tsconfigPath, basePath) {
|
|
34962
|
+
const { config } = import_typescript103.default.readConfigFile(tsconfigPath, import_typescript103.default.sys.readFile);
|
|
34963
|
+
const parseConfigHost = {
|
|
34964
|
+
useCaseSensitiveFileNames: import_typescript103.default.sys.useCaseSensitiveFileNames,
|
|
34965
|
+
fileExists: import_typescript103.default.sys.fileExists,
|
|
34966
|
+
readDirectory: import_typescript103.default.sys.readDirectory,
|
|
34967
|
+
readFile: import_typescript103.default.sys.readFile
|
|
34968
|
+
};
|
|
34969
|
+
if (!path2.isAbsolute(basePath)) {
|
|
34970
|
+
throw Error("Unexpected relative base path has been specified.");
|
|
34971
|
+
}
|
|
34972
|
+
return import_typescript103.default.parseJsonConfigFileContent(config, parseConfigHost, basePath, {});
|
|
34973
|
+
}
|
|
34974
|
+
|
|
34975
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/compiler_host.mjs
|
|
34976
|
+
function createProgramOptions(tree, tsconfigPath, basePath, fakeFileRead, additionalFiles, optionOverrides) {
|
|
34977
|
+
tsconfigPath = (0, import_path5.resolve)(basePath, tsconfigPath);
|
|
34978
|
+
const parsed = parseTsconfigFile(tsconfigPath, (0, import_path5.dirname)(tsconfigPath));
|
|
34979
|
+
const options = optionOverrides ? __spreadValues(__spreadValues({}, parsed.options), optionOverrides) : parsed.options;
|
|
34980
|
+
const host = createMigrationCompilerHost(tree, options, basePath, fakeFileRead);
|
|
34981
|
+
return { rootNames: parsed.fileNames.concat(additionalFiles || []), options, host };
|
|
34982
|
+
}
|
|
34983
|
+
function createMigrationCompilerHost(tree, options, basePath, fakeRead) {
|
|
34984
|
+
const host = import_typescript104.default.createCompilerHost(options, true);
|
|
34985
|
+
const defaultReadFile = host.readFile;
|
|
34986
|
+
host.readFile = (fileName) => {
|
|
34987
|
+
var _a;
|
|
34988
|
+
const treeRelativePath = (0, import_path5.relative)(basePath, fileName);
|
|
34989
|
+
let result = fakeRead == null ? void 0 : fakeRead(treeRelativePath);
|
|
34990
|
+
if (typeof result !== "string") {
|
|
34991
|
+
result = treeRelativePath.startsWith("..") ? defaultReadFile.call(host, fileName) : (_a = tree.read(treeRelativePath)) == null ? void 0 : _a.toString();
|
|
34992
|
+
}
|
|
34993
|
+
return typeof result === "string" ? result.replace(/^\uFEFF/, "") : void 0;
|
|
34994
|
+
};
|
|
34995
|
+
return host;
|
|
34996
|
+
}
|
|
34997
|
+
function canMigrateFile(basePath, sourceFile, program) {
|
|
34998
|
+
if (sourceFile.fileName.endsWith(".ngtypecheck.ts") || sourceFile.isDeclarationFile || program.isSourceFileFromExternalLibrary(sourceFile)) {
|
|
34999
|
+
return false;
|
|
35000
|
+
}
|
|
35001
|
+
return !(0, import_path5.relative)(basePath, sourceFile.fileName).startsWith("..");
|
|
35002
|
+
}
|
|
35003
|
+
|
|
35004
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/prune-modules.mjs
|
|
35005
|
+
var import_typescript109 = __toESM(require("typescript"), 1);
|
|
35006
|
+
|
|
35007
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/decorators.mjs
|
|
35008
|
+
var import_typescript106 = __toESM(require("typescript"), 1);
|
|
35009
|
+
|
|
35010
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/imports.mjs
|
|
35011
|
+
var import_typescript105 = __toESM(require("typescript"), 1);
|
|
35012
|
+
function getImportOfIdentifier(typeChecker, node) {
|
|
35013
|
+
const symbol = typeChecker.getSymbolAtLocation(node);
|
|
35014
|
+
if (!symbol || symbol.declarations === void 0 || !symbol.declarations.length) {
|
|
35015
|
+
return null;
|
|
35016
|
+
}
|
|
35017
|
+
const decl = symbol.declarations[0];
|
|
35018
|
+
if (!import_typescript105.default.isImportSpecifier(decl)) {
|
|
35019
|
+
return null;
|
|
35020
|
+
}
|
|
35021
|
+
const importDecl = decl.parent.parent.parent;
|
|
35022
|
+
if (!import_typescript105.default.isStringLiteral(importDecl.moduleSpecifier)) {
|
|
35023
|
+
return null;
|
|
35024
|
+
}
|
|
35025
|
+
return {
|
|
35026
|
+
name: decl.propertyName ? decl.propertyName.text : decl.name.text,
|
|
35027
|
+
importModule: importDecl.moduleSpecifier.text,
|
|
35028
|
+
node: importDecl
|
|
35029
|
+
};
|
|
35030
|
+
}
|
|
35031
|
+
function getImportSpecifier(sourceFile, moduleName, specifierName) {
|
|
35032
|
+
var _a;
|
|
35033
|
+
for (const node of sourceFile.statements) {
|
|
35034
|
+
if (import_typescript105.default.isImportDeclaration(node) && import_typescript105.default.isStringLiteral(node.moduleSpecifier)) {
|
|
35035
|
+
const isMatch = typeof moduleName === "string" ? node.moduleSpecifier.text === moduleName : moduleName.test(node.moduleSpecifier.text);
|
|
35036
|
+
const namedBindings = (_a = node.importClause) == null ? void 0 : _a.namedBindings;
|
|
35037
|
+
if (isMatch && namedBindings && import_typescript105.default.isNamedImports(namedBindings)) {
|
|
35038
|
+
const match = findImportSpecifier(namedBindings.elements, specifierName);
|
|
35039
|
+
if (match) {
|
|
35040
|
+
return match;
|
|
35041
|
+
}
|
|
35042
|
+
}
|
|
35043
|
+
}
|
|
35044
|
+
}
|
|
35045
|
+
return null;
|
|
35046
|
+
}
|
|
35047
|
+
function findImportSpecifier(nodes, specifierName) {
|
|
35048
|
+
return nodes.find((element) => {
|
|
35049
|
+
const { name, propertyName } = element;
|
|
35050
|
+
return propertyName ? propertyName.text === specifierName : name.text === specifierName;
|
|
35051
|
+
});
|
|
35052
|
+
}
|
|
35053
|
+
|
|
35054
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/decorators.mjs
|
|
35055
|
+
function getCallDecoratorImport(typeChecker, decorator) {
|
|
35056
|
+
if (!import_typescript106.default.isCallExpression(decorator.expression) || !import_typescript106.default.isIdentifier(decorator.expression.expression)) {
|
|
35057
|
+
return null;
|
|
35058
|
+
}
|
|
35059
|
+
const identifier = decorator.expression.expression;
|
|
35060
|
+
return getImportOfIdentifier(typeChecker, identifier);
|
|
35061
|
+
}
|
|
35062
|
+
|
|
35063
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/ng_decorators.mjs
|
|
35064
|
+
function getAngularDecorators(typeChecker, decorators) {
|
|
35065
|
+
return decorators.map((node) => ({ node, importData: getCallDecoratorImport(typeChecker, node) })).filter(({ importData }) => importData && importData.importModule.startsWith("@angular/")).map(({ node, importData }) => ({
|
|
35066
|
+
node,
|
|
35067
|
+
name: importData.name,
|
|
35068
|
+
moduleName: importData.importModule,
|
|
35069
|
+
importNode: importData.node
|
|
35070
|
+
}));
|
|
35071
|
+
}
|
|
35072
|
+
|
|
35073
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/nodes.mjs
|
|
35074
|
+
var import_typescript107 = __toESM(require("typescript"), 1);
|
|
35075
|
+
function closestNode(node, predicate) {
|
|
35076
|
+
let current = node.parent;
|
|
35077
|
+
while (current && !import_typescript107.default.isSourceFile(current)) {
|
|
35078
|
+
if (predicate(current)) {
|
|
35079
|
+
return current;
|
|
35080
|
+
}
|
|
35081
|
+
current = current.parent;
|
|
35082
|
+
}
|
|
35083
|
+
return null;
|
|
35084
|
+
}
|
|
35085
|
+
|
|
35086
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/util.mjs
|
|
35087
|
+
var import_path6 = require("path");
|
|
35088
|
+
var import_typescript108 = __toESM(require("typescript"), 1);
|
|
35074
35089
|
var UniqueItemTracker = class {
|
|
35075
35090
|
constructor() {
|
|
35076
35091
|
this._nodes = /* @__PURE__ */ new Map();
|
|
@@ -35083,6 +35098,9 @@ var UniqueItemTracker = class {
|
|
|
35083
35098
|
this._nodes.set(key, /* @__PURE__ */ new Set([item]));
|
|
35084
35099
|
}
|
|
35085
35100
|
}
|
|
35101
|
+
get(key) {
|
|
35102
|
+
return this._nodes.get(key);
|
|
35103
|
+
}
|
|
35086
35104
|
getEntries() {
|
|
35087
35105
|
return this._nodes.entries();
|
|
35088
35106
|
}
|
|
@@ -35110,7 +35128,7 @@ var ReferenceResolver = class {
|
|
|
35110
35128
|
const results = /* @__PURE__ */ new Map();
|
|
35111
35129
|
for (const symbol of referencedSymbols) {
|
|
35112
35130
|
for (const ref of symbol.references) {
|
|
35113
|
-
if (!ref.isDefinition || symbol.definition.kind ===
|
|
35131
|
+
if (!ref.isDefinition || symbol.definition.kind === import_typescript108.default.ScriptElementKind.alias) {
|
|
35114
35132
|
if (!results.has(ref.fileName)) {
|
|
35115
35133
|
results.set(ref.fileName, []);
|
|
35116
35134
|
}
|
|
@@ -35134,7 +35152,7 @@ var ReferenceResolver = class {
|
|
|
35134
35152
|
for (const file of highlights) {
|
|
35135
35153
|
if (file.fileName === fileName) {
|
|
35136
35154
|
for (const { textSpan: { start, length }, kind } of file.highlightSpans) {
|
|
35137
|
-
if (kind !==
|
|
35155
|
+
if (kind !== import_typescript108.default.HighlightSpanKind.none) {
|
|
35138
35156
|
results.push([start, start + length]);
|
|
35139
35157
|
}
|
|
35140
35158
|
}
|
|
@@ -35160,19 +35178,19 @@ var ReferenceResolver = class {
|
|
|
35160
35178
|
rootFileNames.push(fileName);
|
|
35161
35179
|
}
|
|
35162
35180
|
});
|
|
35163
|
-
this._languageService =
|
|
35181
|
+
this._languageService = import_typescript108.default.createLanguageService({
|
|
35164
35182
|
getCompilationSettings: () => this._program.getTsProgram().getCompilerOptions(),
|
|
35165
35183
|
getScriptFileNames: () => rootFileNames,
|
|
35166
35184
|
getScriptVersion: () => "0",
|
|
35167
35185
|
getScriptSnapshot: (path3) => {
|
|
35168
35186
|
const content = this._readFile(path3);
|
|
35169
|
-
return content ?
|
|
35187
|
+
return content ? import_typescript108.default.ScriptSnapshot.fromString(content) : void 0;
|
|
35170
35188
|
},
|
|
35171
35189
|
getCurrentDirectory: () => this._basePath,
|
|
35172
|
-
getDefaultLibFileName: (options) =>
|
|
35190
|
+
getDefaultLibFileName: (options) => import_typescript108.default.getDefaultLibFilePath(options),
|
|
35173
35191
|
readFile: (path3) => this._readFile(path3),
|
|
35174
35192
|
fileExists: (path3) => this._host.fileExists(path3)
|
|
35175
|
-
},
|
|
35193
|
+
}, import_typescript108.default.createDocumentRegistry(), import_typescript108.default.LanguageServiceMode.PartialSemantic);
|
|
35176
35194
|
}
|
|
35177
35195
|
return this._languageService;
|
|
35178
35196
|
}
|
|
@@ -35202,10 +35220,10 @@ function offsetsToNodes(lookup, offsets, results) {
|
|
|
35202
35220
|
}
|
|
35203
35221
|
function findClassDeclaration(reference, typeChecker) {
|
|
35204
35222
|
var _a, _b;
|
|
35205
|
-
return ((_b = (_a = typeChecker.getTypeAtLocation(reference).getSymbol()) == null ? void 0 : _a.declarations) == null ? void 0 : _b.find(
|
|
35223
|
+
return ((_b = (_a = typeChecker.getTypeAtLocation(reference).getSymbol()) == null ? void 0 : _a.declarations) == null ? void 0 : _b.find(import_typescript108.default.isClassDeclaration)) || null;
|
|
35206
35224
|
}
|
|
35207
35225
|
function findLiteralProperty(literal3, name) {
|
|
35208
|
-
return literal3.properties.find((prop) => prop.name &&
|
|
35226
|
+
return literal3.properties.find((prop) => prop.name && import_typescript108.default.isIdentifier(prop.name) && prop.name.text === name);
|
|
35209
35227
|
}
|
|
35210
35228
|
function getRelativeImportPath(fromFile, toFile) {
|
|
35211
35229
|
let path3 = (0, import_path6.relative)((0, import_path6.dirname)(fromFile), toFile).replace(/\.ts$/, "");
|
|
@@ -35214,9 +35232,6 @@ function getRelativeImportPath(fromFile, toFile) {
|
|
|
35214
35232
|
}
|
|
35215
35233
|
return normalizePath(path3);
|
|
35216
35234
|
}
|
|
35217
|
-
function normalizePath(path3) {
|
|
35218
|
-
return path3.replace(/\\/g, "/");
|
|
35219
|
-
}
|
|
35220
35235
|
function knownInternalAliasRemapper(imports) {
|
|
35221
35236
|
return imports.map((current) => current.moduleSpecifier === "@angular/common" && current.symbolName === "NgForOf" ? __spreadProps(__spreadValues({}, current), { symbolName: "NgFor" }) : current);
|
|
35222
35237
|
}
|
|
@@ -35229,9 +35244,9 @@ function isClassReferenceInAngularModule(node, className, moduleName, typeChecke
|
|
|
35229
35244
|
const externalName = `@angular/${moduleName}`;
|
|
35230
35245
|
const internalName = `angular2/rc/packages/${moduleName}`;
|
|
35231
35246
|
return !!((_a = symbol == null ? void 0 : symbol.declarations) == null ? void 0 : _a.some((decl) => {
|
|
35232
|
-
const closestClass = closestOrSelf(decl,
|
|
35247
|
+
const closestClass = closestOrSelf(decl, import_typescript108.default.isClassDeclaration);
|
|
35233
35248
|
const closestClassFileName = closestClass == null ? void 0 : closestClass.getSourceFile().fileName;
|
|
35234
|
-
if (!closestClass || !closestClassFileName || !closestClass.name || !
|
|
35249
|
+
if (!closestClass || !closestClassFileName || !closestClass.name || !import_typescript108.default.isIdentifier(closestClass.name) || !closestClassFileName.includes(externalName) && !closestClassFileName.includes(internalName)) {
|
|
35235
35250
|
return false;
|
|
35236
35251
|
}
|
|
35237
35252
|
return typeof className === "string" ? closestClass.name.text === className : className.test(closestClass.name.text);
|
|
@@ -35242,19 +35257,28 @@ function isClassReferenceInAngularModule(node, className, moduleName, typeChecke
|
|
|
35242
35257
|
function pruneNgModules(program, host, basePath, rootFileNames, sourceFiles, printer, importRemapper, referenceLookupExcludedFiles) {
|
|
35243
35258
|
const filesToRemove = /* @__PURE__ */ new Set();
|
|
35244
35259
|
const tracker = new ChangeTracker(printer, importRemapper);
|
|
35245
|
-
const
|
|
35260
|
+
const tsProgram = program.getTsProgram();
|
|
35261
|
+
const typeChecker = tsProgram.getTypeChecker();
|
|
35246
35262
|
const referenceResolver = new ReferenceResolver(program, host, rootFileNames, basePath, referenceLookupExcludedFiles);
|
|
35247
35263
|
const removalLocations = {
|
|
35248
35264
|
arrays: new UniqueItemTracker(),
|
|
35249
35265
|
imports: new UniqueItemTracker(),
|
|
35250
35266
|
exports: new UniqueItemTracker(),
|
|
35251
|
-
classes: /* @__PURE__ */ new Set(),
|
|
35252
35267
|
unknown: /* @__PURE__ */ new Set()
|
|
35253
35268
|
};
|
|
35269
|
+
const classesToRemove = /* @__PURE__ */ new Set();
|
|
35270
|
+
const barrelExports = new UniqueItemTracker();
|
|
35271
|
+
const nodesToRemove = /* @__PURE__ */ new Set();
|
|
35254
35272
|
sourceFiles.forEach(function walk(node) {
|
|
35255
|
-
|
|
35273
|
+
var _a, _b;
|
|
35274
|
+
if (import_typescript109.default.isClassDeclaration(node) && canRemoveClass(node, typeChecker)) {
|
|
35256
35275
|
collectRemovalLocations(node, removalLocations, referenceResolver, program);
|
|
35257
|
-
|
|
35276
|
+
classesToRemove.add(node);
|
|
35277
|
+
} else if (import_typescript109.default.isExportDeclaration(node) && !node.exportClause && node.moduleSpecifier && import_typescript109.default.isStringLiteralLike(node.moduleSpecifier) && node.moduleSpecifier.text.startsWith(".")) {
|
|
35278
|
+
const exportedSourceFile = (_b = (_a = typeChecker.getSymbolAtLocation(node.moduleSpecifier)) == null ? void 0 : _a.valueDeclaration) == null ? void 0 : _b.getSourceFile();
|
|
35279
|
+
if (exportedSourceFile) {
|
|
35280
|
+
barrelExports.track(exportedSourceFile, node);
|
|
35281
|
+
}
|
|
35258
35282
|
}
|
|
35259
35283
|
node.forEachChild(walk);
|
|
35260
35284
|
});
|
|
@@ -35262,9 +35286,22 @@ function pruneNgModules(program, host, basePath, rootFileNames, sourceFiles, pri
|
|
|
35262
35286
|
removeImportReferences(removalLocations.imports, tracker);
|
|
35263
35287
|
removeExportReferences(removalLocations.exports, tracker);
|
|
35264
35288
|
addRemovalTodos(removalLocations.unknown, tracker);
|
|
35265
|
-
|
|
35289
|
+
(function trackNodesToRemove(nodes) {
|
|
35290
|
+
for (const node of nodes) {
|
|
35291
|
+
const sourceFile = node.getSourceFile();
|
|
35292
|
+
if (!filesToRemove.has(sourceFile) && canRemoveFile(sourceFile, nodes)) {
|
|
35293
|
+
const barrelExportsForFile = barrelExports.get(sourceFile);
|
|
35294
|
+
nodesToRemove.add(node);
|
|
35295
|
+
filesToRemove.add(sourceFile);
|
|
35296
|
+
barrelExportsForFile && trackNodesToRemove(barrelExportsForFile);
|
|
35297
|
+
} else {
|
|
35298
|
+
nodesToRemove.add(node);
|
|
35299
|
+
}
|
|
35300
|
+
}
|
|
35301
|
+
})(classesToRemove);
|
|
35302
|
+
for (const node of nodesToRemove) {
|
|
35266
35303
|
const sourceFile = node.getSourceFile();
|
|
35267
|
-
if (!filesToRemove.has(sourceFile) && canRemoveFile(sourceFile,
|
|
35304
|
+
if (!filesToRemove.has(sourceFile) && canRemoveFile(sourceFile, nodesToRemove)) {
|
|
35268
35305
|
filesToRemove.add(sourceFile);
|
|
35269
35306
|
} else {
|
|
35270
35307
|
tracker.removeNode(node);
|
|
@@ -35283,17 +35320,17 @@ function collectRemovalLocations(ngModule, removalLocations, referenceResolver,
|
|
|
35283
35320
|
}
|
|
35284
35321
|
}
|
|
35285
35322
|
for (const node of nodes) {
|
|
35286
|
-
const closestArray = closestNode(node,
|
|
35323
|
+
const closestArray = closestNode(node, import_typescript109.default.isArrayLiteralExpression);
|
|
35287
35324
|
if (closestArray) {
|
|
35288
35325
|
removalLocations.arrays.track(closestArray, node);
|
|
35289
35326
|
continue;
|
|
35290
35327
|
}
|
|
35291
|
-
const closestImport = closestNode(node,
|
|
35328
|
+
const closestImport = closestNode(node, import_typescript109.default.isNamedImports);
|
|
35292
35329
|
if (closestImport) {
|
|
35293
35330
|
removalLocations.imports.track(closestImport, node);
|
|
35294
35331
|
continue;
|
|
35295
35332
|
}
|
|
35296
|
-
const closestExport = closestNode(node,
|
|
35333
|
+
const closestExport = closestNode(node, import_typescript109.default.isNamedExports);
|
|
35297
35334
|
if (closestExport) {
|
|
35298
35335
|
removalLocations.exports.track(closestExport, node);
|
|
35299
35336
|
continue;
|
|
@@ -35304,24 +35341,24 @@ function collectRemovalLocations(ngModule, removalLocations, referenceResolver,
|
|
|
35304
35341
|
function removeArrayReferences(locations, tracker) {
|
|
35305
35342
|
for (const [array, toRemove] of locations.getEntries()) {
|
|
35306
35343
|
const newElements = filterRemovedElements(array.elements, toRemove);
|
|
35307
|
-
tracker.replaceNode(array,
|
|
35344
|
+
tracker.replaceNode(array, import_typescript109.default.factory.updateArrayLiteralExpression(array, newElements));
|
|
35308
35345
|
}
|
|
35309
35346
|
}
|
|
35310
35347
|
function removeImportReferences(locations, tracker) {
|
|
35311
35348
|
for (const [namedImports, toRemove] of locations.getEntries()) {
|
|
35312
35349
|
const newElements = filterRemovedElements(namedImports.elements, toRemove);
|
|
35313
35350
|
if (newElements.length === 0) {
|
|
35314
|
-
const importClause = closestNode(namedImports,
|
|
35351
|
+
const importClause = closestNode(namedImports, import_typescript109.default.isImportClause);
|
|
35315
35352
|
if (importClause && importClause.name) {
|
|
35316
|
-
tracker.replaceNode(importClause,
|
|
35353
|
+
tracker.replaceNode(importClause, import_typescript109.default.factory.updateImportClause(importClause, importClause.isTypeOnly, importClause.name, void 0));
|
|
35317
35354
|
} else {
|
|
35318
|
-
const declaration = closestNode(namedImports,
|
|
35355
|
+
const declaration = closestNode(namedImports, import_typescript109.default.isImportDeclaration);
|
|
35319
35356
|
if (declaration) {
|
|
35320
35357
|
tracker.removeNode(declaration);
|
|
35321
35358
|
}
|
|
35322
35359
|
}
|
|
35323
35360
|
} else {
|
|
35324
|
-
tracker.replaceNode(namedImports,
|
|
35361
|
+
tracker.replaceNode(namedImports, import_typescript109.default.factory.updateNamedImports(namedImports, newElements));
|
|
35325
35362
|
}
|
|
35326
35363
|
}
|
|
35327
35364
|
}
|
|
@@ -35329,22 +35366,22 @@ function removeExportReferences(locations, tracker) {
|
|
|
35329
35366
|
for (const [namedExports, toRemove] of locations.getEntries()) {
|
|
35330
35367
|
const newElements = filterRemovedElements(namedExports.elements, toRemove);
|
|
35331
35368
|
if (newElements.length === 0) {
|
|
35332
|
-
const declaration = closestNode(namedExports,
|
|
35369
|
+
const declaration = closestNode(namedExports, import_typescript109.default.isExportDeclaration);
|
|
35333
35370
|
if (declaration) {
|
|
35334
35371
|
tracker.removeNode(declaration);
|
|
35335
35372
|
}
|
|
35336
35373
|
} else {
|
|
35337
|
-
tracker.replaceNode(namedExports,
|
|
35374
|
+
tracker.replaceNode(namedExports, import_typescript109.default.factory.updateNamedExports(namedExports, newElements));
|
|
35338
35375
|
}
|
|
35339
35376
|
}
|
|
35340
35377
|
}
|
|
35341
35378
|
function canRemoveClass(node, typeChecker) {
|
|
35342
35379
|
var _a;
|
|
35343
35380
|
const decorator = (_a = findNgModuleDecorator(node, typeChecker)) == null ? void 0 : _a.node;
|
|
35344
|
-
if (!decorator || !
|
|
35381
|
+
if (!decorator || !import_typescript109.default.isCallExpression(decorator.expression)) {
|
|
35345
35382
|
return false;
|
|
35346
35383
|
}
|
|
35347
|
-
if (decorator.expression.arguments.length > 0 && !
|
|
35384
|
+
if (decorator.expression.arguments.length > 0 && !import_typescript109.default.isObjectLiteralExpression(decorator.expression.arguments[0])) {
|
|
35348
35385
|
return false;
|
|
35349
35386
|
}
|
|
35350
35387
|
if (node.members.length > 0 && node.members.some((member) => !isEmptyConstructor(member))) {
|
|
@@ -35357,7 +35394,7 @@ function canRemoveClass(node, typeChecker) {
|
|
|
35357
35394
|
const imports = findLiteralProperty(literal3, "imports");
|
|
35358
35395
|
if (imports && isNonEmptyNgModuleProperty(imports)) {
|
|
35359
35396
|
for (const dep of imports.initializer.elements) {
|
|
35360
|
-
if (!
|
|
35397
|
+
if (!import_typescript109.default.isIdentifier(dep)) {
|
|
35361
35398
|
return false;
|
|
35362
35399
|
}
|
|
35363
35400
|
const depDeclaration = findClassDeclaration(dep, typeChecker);
|
|
@@ -35375,15 +35412,15 @@ function canRemoveClass(node, typeChecker) {
|
|
|
35375
35412
|
return true;
|
|
35376
35413
|
}
|
|
35377
35414
|
function isNonEmptyNgModuleProperty(node) {
|
|
35378
|
-
return
|
|
35415
|
+
return import_typescript109.default.isPropertyAssignment(node) && import_typescript109.default.isIdentifier(node.name) && import_typescript109.default.isArrayLiteralExpression(node.initializer) && node.initializer.elements.length > 0;
|
|
35379
35416
|
}
|
|
35380
|
-
function canRemoveFile(sourceFile,
|
|
35417
|
+
function canRemoveFile(sourceFile, nodesToBeRemoved) {
|
|
35381
35418
|
var _a;
|
|
35382
35419
|
for (const node of sourceFile.statements) {
|
|
35383
|
-
if (
|
|
35420
|
+
if (import_typescript109.default.isImportDeclaration(node) || nodesToBeRemoved.has(node)) {
|
|
35384
35421
|
continue;
|
|
35385
35422
|
}
|
|
35386
|
-
if (
|
|
35423
|
+
if (import_typescript109.default.isExportDeclaration(node) || import_typescript109.default.canHaveModifiers(node) && ((_a = import_typescript109.default.getModifiers(node)) == null ? void 0 : _a.some((m) => m.kind === import_typescript109.default.SyntaxKind.ExportKeyword))) {
|
|
35387
35424
|
return false;
|
|
35388
35425
|
}
|
|
35389
35426
|
}
|
|
@@ -35403,7 +35440,7 @@ function filterRemovedElements(elements, toRemove) {
|
|
|
35403
35440
|
});
|
|
35404
35441
|
}
|
|
35405
35442
|
function isEmptyConstructor(node) {
|
|
35406
|
-
return
|
|
35443
|
+
return import_typescript109.default.isConstructorDeclaration(node) && node.parameters.length === 0 && (node.body == null || node.body.statements.length === 0);
|
|
35407
35444
|
}
|
|
35408
35445
|
function addRemovalTodos(nodes, tracker) {
|
|
35409
35446
|
for (const node of nodes) {
|
|
@@ -35411,19 +35448,19 @@ function addRemovalTodos(nodes, tracker) {
|
|
|
35411
35448
|
}
|
|
35412
35449
|
}
|
|
35413
35450
|
function findNgModuleDecorator(node, typeChecker) {
|
|
35414
|
-
const decorators = getAngularDecorators(typeChecker,
|
|
35451
|
+
const decorators = getAngularDecorators(typeChecker, import_typescript109.default.getDecorators(node) || []);
|
|
35415
35452
|
return decorators.find((decorator) => decorator.name === "NgModule") || null;
|
|
35416
35453
|
}
|
|
35417
35454
|
|
|
35418
35455
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/standalone-bootstrap.mjs
|
|
35419
35456
|
var import_path7 = require("path");
|
|
35420
|
-
var
|
|
35457
|
+
var import_typescript112 = __toESM(require("typescript"), 1);
|
|
35421
35458
|
|
|
35422
35459
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/to-standalone.mjs
|
|
35423
|
-
var
|
|
35460
|
+
var import_typescript111 = __toESM(require("typescript"), 1);
|
|
35424
35461
|
|
|
35425
35462
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/symbol.mjs
|
|
35426
|
-
var
|
|
35463
|
+
var import_typescript110 = __toESM(require("typescript"), 1);
|
|
35427
35464
|
function isReferenceToImport(typeChecker, node, importSpecifier) {
|
|
35428
35465
|
var _a, _b;
|
|
35429
35466
|
const nodeSymbol = typeChecker.getTypeAtLocation(node).getSymbol();
|
|
@@ -35435,9 +35472,9 @@ function isReferenceToImport(typeChecker, node, importSpecifier) {
|
|
|
35435
35472
|
function toStandalone(sourceFiles, program, printer, fileImportRemapper, componentImportRemapper) {
|
|
35436
35473
|
const templateTypeChecker = program.compiler.getTemplateTypeChecker();
|
|
35437
35474
|
const typeChecker = program.getTsProgram().getTypeChecker();
|
|
35438
|
-
const modulesToMigrate =
|
|
35439
|
-
const testObjectsToMigrate =
|
|
35440
|
-
const declarations =
|
|
35475
|
+
const modulesToMigrate = /* @__PURE__ */ new Set();
|
|
35476
|
+
const testObjectsToMigrate = /* @__PURE__ */ new Set();
|
|
35477
|
+
const declarations = /* @__PURE__ */ new Set();
|
|
35441
35478
|
const tracker = new ChangeTracker(printer, fileImportRemapper);
|
|
35442
35479
|
for (const sourceFile of sourceFiles) {
|
|
35443
35480
|
const modules = findNgModuleClassesToMigrate(sourceFile, typeChecker);
|
|
@@ -35446,11 +35483,11 @@ function toStandalone(sourceFiles, program, printer, fileImportRemapper, compone
|
|
|
35446
35483
|
const allModuleDeclarations = extractDeclarationsFromModule(module3, templateTypeChecker);
|
|
35447
35484
|
const unbootstrappedDeclarations = filterNonBootstrappedDeclarations(allModuleDeclarations, module3, templateTypeChecker, typeChecker);
|
|
35448
35485
|
if (unbootstrappedDeclarations.length > 0) {
|
|
35449
|
-
modulesToMigrate.
|
|
35450
|
-
declarations.
|
|
35486
|
+
modulesToMigrate.add(module3);
|
|
35487
|
+
unbootstrappedDeclarations.forEach((decl) => declarations.add(decl));
|
|
35451
35488
|
}
|
|
35452
35489
|
}
|
|
35453
|
-
testObjectsToMigrate.
|
|
35490
|
+
testObjects.forEach((obj) => testObjectsToMigrate.add(obj));
|
|
35454
35491
|
}
|
|
35455
35492
|
for (const declaration of declarations) {
|
|
35456
35493
|
convertNgModuleDeclarationToStandalone(declaration, declarations, tracker, templateTypeChecker, componentImportRemapper);
|
|
@@ -35461,48 +35498,48 @@ function toStandalone(sourceFiles, program, printer, fileImportRemapper, compone
|
|
|
35461
35498
|
migrateTestDeclarations(testObjectsToMigrate, declarations, tracker, templateTypeChecker, typeChecker);
|
|
35462
35499
|
return tracker.recordChanges();
|
|
35463
35500
|
}
|
|
35464
|
-
function convertNgModuleDeclarationToStandalone(
|
|
35465
|
-
const directiveMeta = typeChecker.getDirectiveMetadata(
|
|
35501
|
+
function convertNgModuleDeclarationToStandalone(decl, allDeclarations, tracker, typeChecker, importRemapper) {
|
|
35502
|
+
const directiveMeta = typeChecker.getDirectiveMetadata(decl);
|
|
35466
35503
|
if (directiveMeta && directiveMeta.decorator && !directiveMeta.isStandalone) {
|
|
35467
35504
|
let decorator = addStandaloneToDecorator(directiveMeta.decorator);
|
|
35468
35505
|
if (directiveMeta.isComponent) {
|
|
35469
|
-
const importsToAdd = getComponentImportExpressions(
|
|
35506
|
+
const importsToAdd = getComponentImportExpressions(decl, allDeclarations, tracker, typeChecker, importRemapper);
|
|
35470
35507
|
if (importsToAdd.length > 0) {
|
|
35471
|
-
decorator = addPropertyToAngularDecorator(decorator,
|
|
35508
|
+
decorator = addPropertyToAngularDecorator(decorator, import_typescript111.default.factory.createPropertyAssignment("imports", import_typescript111.default.factory.createArrayLiteralExpression(importsToAdd)));
|
|
35472
35509
|
}
|
|
35473
35510
|
}
|
|
35474
35511
|
tracker.replaceNode(directiveMeta.decorator, decorator);
|
|
35475
35512
|
} else {
|
|
35476
|
-
const pipeMeta = typeChecker.getPipeMetadata(
|
|
35513
|
+
const pipeMeta = typeChecker.getPipeMetadata(decl);
|
|
35477
35514
|
if (pipeMeta && pipeMeta.decorator && !pipeMeta.isStandalone) {
|
|
35478
35515
|
tracker.replaceNode(pipeMeta.decorator, addStandaloneToDecorator(pipeMeta.decorator));
|
|
35479
35516
|
}
|
|
35480
35517
|
}
|
|
35481
35518
|
}
|
|
35482
|
-
function getComponentImportExpressions(
|
|
35483
|
-
const templateDependencies = findTemplateDependencies(
|
|
35484
|
-
const usedDependenciesInMigration = new Set(templateDependencies.filter((dep) => allDeclarations.
|
|
35519
|
+
function getComponentImportExpressions(decl, allDeclarations, tracker, typeChecker, importRemapper) {
|
|
35520
|
+
const templateDependencies = findTemplateDependencies(decl, typeChecker);
|
|
35521
|
+
const usedDependenciesInMigration = new Set(templateDependencies.filter((dep) => allDeclarations.has(dep.node)));
|
|
35485
35522
|
const imports = [];
|
|
35486
35523
|
const seenImports = /* @__PURE__ */ new Set();
|
|
35487
35524
|
const resolvedDependencies = [];
|
|
35488
35525
|
for (const dep of templateDependencies) {
|
|
35489
|
-
const importLocation = findImportLocation(dep,
|
|
35526
|
+
const importLocation = findImportLocation(dep, decl, usedDependenciesInMigration.has(dep) ? PotentialImportMode.ForceDirect : PotentialImportMode.Normal, typeChecker);
|
|
35490
35527
|
if (importLocation && !seenImports.has(importLocation.symbolName)) {
|
|
35491
35528
|
seenImports.add(importLocation.symbolName);
|
|
35492
35529
|
resolvedDependencies.push(importLocation);
|
|
35493
35530
|
}
|
|
35494
35531
|
}
|
|
35495
|
-
const processedDependencies = importRemapper ? importRemapper(resolvedDependencies,
|
|
35532
|
+
const processedDependencies = importRemapper ? importRemapper(resolvedDependencies, decl) : resolvedDependencies;
|
|
35496
35533
|
for (const importLocation of processedDependencies) {
|
|
35497
35534
|
if (importLocation.moduleSpecifier) {
|
|
35498
|
-
const identifier = tracker.addImport(
|
|
35535
|
+
const identifier = tracker.addImport(decl.getSourceFile(), importLocation.symbolName, importLocation.moduleSpecifier);
|
|
35499
35536
|
imports.push(identifier);
|
|
35500
35537
|
} else {
|
|
35501
|
-
const identifier =
|
|
35538
|
+
const identifier = import_typescript111.default.factory.createIdentifier(importLocation.symbolName);
|
|
35502
35539
|
if (importLocation.isForwardReference) {
|
|
35503
|
-
const forwardRefExpression = tracker.addImport(
|
|
35504
|
-
const arrowFunction =
|
|
35505
|
-
imports.push(
|
|
35540
|
+
const forwardRefExpression = tracker.addImport(decl.getSourceFile(), "forwardRef", "@angular/core");
|
|
35541
|
+
const arrowFunction = import_typescript111.default.factory.createArrowFunction(void 0, void 0, [], void 0, void 0, identifier);
|
|
35542
|
+
imports.push(import_typescript111.default.factory.createCallExpression(forwardRefExpression, void 0, [arrowFunction]));
|
|
35506
35543
|
} else {
|
|
35507
35544
|
imports.push(identifier);
|
|
35508
35545
|
}
|
|
@@ -35515,7 +35552,7 @@ function migrateNgModuleClass(node, allDeclarations, tracker, typeChecker, templ
|
|
|
35515
35552
|
const decorator = (_a = templateTypeChecker.getNgModuleMetadata(node)) == null ? void 0 : _a.decorator;
|
|
35516
35553
|
const metadata = decorator ? extractMetadataLiteral(decorator) : null;
|
|
35517
35554
|
if (metadata) {
|
|
35518
|
-
moveDeclarationsToImports(metadata, allDeclarations
|
|
35555
|
+
moveDeclarationsToImports(metadata, allDeclarations, typeChecker, templateTypeChecker, tracker);
|
|
35519
35556
|
}
|
|
35520
35557
|
}
|
|
35521
35558
|
function moveDeclarationsToImports(literal3, allDeclarations, typeChecker, templateTypeChecker, tracker) {
|
|
@@ -35527,10 +35564,10 @@ function moveDeclarationsToImports(literal3, allDeclarations, typeChecker, templ
|
|
|
35527
35564
|
const declarationsToCopy = [];
|
|
35528
35565
|
const properties = [];
|
|
35529
35566
|
const importsProp = findLiteralProperty(literal3, "imports");
|
|
35530
|
-
if (
|
|
35531
|
-
if (
|
|
35567
|
+
if (import_typescript111.default.isPropertyAssignment(declarationsProp)) {
|
|
35568
|
+
if (import_typescript111.default.isArrayLiteralExpression(declarationsProp.initializer)) {
|
|
35532
35569
|
for (const el of declarationsProp.initializer.elements) {
|
|
35533
|
-
if (
|
|
35570
|
+
if (import_typescript111.default.isIdentifier(el)) {
|
|
35534
35571
|
const correspondingClass = findClassDeclaration(el, typeChecker);
|
|
35535
35572
|
if (!correspondingClass || isStandaloneDeclaration(correspondingClass, allDeclarations, templateTypeChecker)) {
|
|
35536
35573
|
declarationsToCopy.push(el);
|
|
@@ -35542,11 +35579,11 @@ function moveDeclarationsToImports(literal3, allDeclarations, typeChecker, templ
|
|
|
35542
35579
|
}
|
|
35543
35580
|
}
|
|
35544
35581
|
} else {
|
|
35545
|
-
declarationsToCopy.push(
|
|
35582
|
+
declarationsToCopy.push(import_typescript111.default.factory.createSpreadElement(declarationsProp.initializer));
|
|
35546
35583
|
}
|
|
35547
35584
|
}
|
|
35548
35585
|
if (!importsProp && declarationsToCopy.length > 0) {
|
|
35549
|
-
properties.push(
|
|
35586
|
+
properties.push(import_typescript111.default.factory.createPropertyAssignment("imports", import_typescript111.default.factory.createArrayLiteralExpression(declarationsToCopy)));
|
|
35550
35587
|
}
|
|
35551
35588
|
for (const prop of literal3.properties) {
|
|
35552
35589
|
if (!isNamedPropertyAssignment(prop)) {
|
|
@@ -35555,46 +35592,46 @@ function moveDeclarationsToImports(literal3, allDeclarations, typeChecker, templ
|
|
|
35555
35592
|
}
|
|
35556
35593
|
if (prop === declarationsProp) {
|
|
35557
35594
|
if (declarationsToPreserve.length > 0) {
|
|
35558
|
-
properties.push(
|
|
35595
|
+
properties.push(import_typescript111.default.factory.updatePropertyAssignment(prop, prop.name, import_typescript111.default.factory.createArrayLiteralExpression(declarationsToPreserve)));
|
|
35559
35596
|
}
|
|
35560
35597
|
continue;
|
|
35561
35598
|
}
|
|
35562
35599
|
if (prop === importsProp && declarationsToCopy.length > 0) {
|
|
35563
35600
|
let initializer;
|
|
35564
|
-
if (
|
|
35565
|
-
initializer =
|
|
35601
|
+
if (import_typescript111.default.isArrayLiteralExpression(prop.initializer)) {
|
|
35602
|
+
initializer = import_typescript111.default.factory.updateArrayLiteralExpression(prop.initializer, [...prop.initializer.elements, ...declarationsToCopy]);
|
|
35566
35603
|
} else {
|
|
35567
|
-
initializer =
|
|
35604
|
+
initializer = import_typescript111.default.factory.createArrayLiteralExpression([import_typescript111.default.factory.createSpreadElement(prop.initializer), ...declarationsToCopy]);
|
|
35568
35605
|
}
|
|
35569
|
-
properties.push(
|
|
35606
|
+
properties.push(import_typescript111.default.factory.updatePropertyAssignment(prop, prop.name, initializer));
|
|
35570
35607
|
continue;
|
|
35571
35608
|
}
|
|
35572
35609
|
properties.push(prop);
|
|
35573
35610
|
}
|
|
35574
|
-
tracker.replaceNode(literal3,
|
|
35611
|
+
tracker.replaceNode(literal3, import_typescript111.default.factory.updateObjectLiteralExpression(literal3, properties), import_typescript111.default.EmitHint.Expression);
|
|
35575
35612
|
}
|
|
35576
35613
|
function addStandaloneToDecorator(node) {
|
|
35577
|
-
return addPropertyToAngularDecorator(node,
|
|
35614
|
+
return addPropertyToAngularDecorator(node, import_typescript111.default.factory.createPropertyAssignment("standalone", import_typescript111.default.factory.createToken(import_typescript111.default.SyntaxKind.TrueKeyword)));
|
|
35578
35615
|
}
|
|
35579
35616
|
function addPropertyToAngularDecorator(node, property) {
|
|
35580
|
-
if (!
|
|
35617
|
+
if (!import_typescript111.default.isCallExpression(node.expression) || node.expression.arguments.length > 1) {
|
|
35581
35618
|
return node;
|
|
35582
35619
|
}
|
|
35583
35620
|
let literalProperties;
|
|
35584
35621
|
if (node.expression.arguments.length === 0) {
|
|
35585
35622
|
literalProperties = [property];
|
|
35586
|
-
} else if (
|
|
35623
|
+
} else if (import_typescript111.default.isObjectLiteralExpression(node.expression.arguments[0])) {
|
|
35587
35624
|
literalProperties = [...node.expression.arguments[0].properties, property];
|
|
35588
35625
|
} else {
|
|
35589
35626
|
return node;
|
|
35590
35627
|
}
|
|
35591
|
-
return
|
|
35628
|
+
return import_typescript111.default.factory.createDecorator(import_typescript111.default.factory.createCallExpression(node.expression.expression, node.expression.typeArguments, [import_typescript111.default.factory.createObjectLiteralExpression(literalProperties, literalProperties.length > 1)]));
|
|
35592
35629
|
}
|
|
35593
35630
|
function isNamedPropertyAssignment(node) {
|
|
35594
|
-
return
|
|
35631
|
+
return import_typescript111.default.isPropertyAssignment(node) && node.name && import_typescript111.default.isIdentifier(node.name);
|
|
35595
35632
|
}
|
|
35596
35633
|
function findImportLocation(target, inComponent, importMode, typeChecker) {
|
|
35597
|
-
const importLocations = typeChecker.getPotentialImportsFor(target, inComponent
|
|
35634
|
+
const importLocations = typeChecker.getPotentialImportsFor(target, inComponent, importMode);
|
|
35598
35635
|
let firstSameFileImport = null;
|
|
35599
35636
|
let firstModuleImport = null;
|
|
35600
35637
|
for (const location of importLocations) {
|
|
@@ -35611,14 +35648,14 @@ function findImportLocation(target, inComponent, importMode, typeChecker) {
|
|
|
35611
35648
|
return firstSameFileImport || firstModuleImport || importLocations[0] || null;
|
|
35612
35649
|
}
|
|
35613
35650
|
function hasNgModuleMetadataElements(node) {
|
|
35614
|
-
return
|
|
35651
|
+
return import_typescript111.default.isPropertyAssignment(node) && (!import_typescript111.default.isArrayLiteralExpression(node.initializer) || node.initializer.elements.length > 0);
|
|
35615
35652
|
}
|
|
35616
35653
|
function findNgModuleClassesToMigrate(sourceFile, typeChecker) {
|
|
35617
35654
|
const modules = [];
|
|
35618
35655
|
if (getImportSpecifier(sourceFile, "@angular/core", "NgModule")) {
|
|
35619
35656
|
sourceFile.forEachChild(function walk(node) {
|
|
35620
|
-
if (
|
|
35621
|
-
const decorator = getAngularDecorators(typeChecker,
|
|
35657
|
+
if (import_typescript111.default.isClassDeclaration(node)) {
|
|
35658
|
+
const decorator = getAngularDecorators(typeChecker, import_typescript111.default.getDecorators(node) || []).find((current) => current.name === "NgModule");
|
|
35622
35659
|
const metadata = decorator ? extractMetadataLiteral(decorator.node) : null;
|
|
35623
35660
|
if (metadata) {
|
|
35624
35661
|
const declarations = findLiteralProperty(metadata, "declarations");
|
|
@@ -35638,8 +35675,8 @@ function findTestObjectsToMigrate(sourceFile, typeChecker) {
|
|
|
35638
35675
|
const catalystImport = getImportSpecifier(sourceFile, /testing\/catalyst$/, "setupModule");
|
|
35639
35676
|
if (testBedImport || catalystImport) {
|
|
35640
35677
|
sourceFile.forEachChild(function walk(node) {
|
|
35641
|
-
if (
|
|
35642
|
-
if (testBedImport &&
|
|
35678
|
+
if (import_typescript111.default.isCallExpression(node) && node.arguments.length > 0 && import_typescript111.default.isObjectLiteralExpression(node.arguments[0])) {
|
|
35679
|
+
if (testBedImport && import_typescript111.default.isPropertyAccessExpression(node.expression) && node.expression.name.text === "configureTestingModule" && isReferenceToImport(typeChecker, node.expression.expression, testBedImport) || catalystImport && import_typescript111.default.isIdentifier(node.expression) && isReferenceToImport(typeChecker, node.expression, catalystImport)) {
|
|
35643
35680
|
testObjects.push(node.arguments[0]);
|
|
35644
35681
|
}
|
|
35645
35682
|
}
|
|
@@ -35648,21 +35685,21 @@ function findTestObjectsToMigrate(sourceFile, typeChecker) {
|
|
|
35648
35685
|
}
|
|
35649
35686
|
return testObjects;
|
|
35650
35687
|
}
|
|
35651
|
-
function findTemplateDependencies(
|
|
35688
|
+
function findTemplateDependencies(decl, typeChecker) {
|
|
35652
35689
|
const results = [];
|
|
35653
|
-
const usedDirectives = typeChecker.getUsedDirectives(
|
|
35654
|
-
const usedPipes = typeChecker.getUsedPipes(
|
|
35690
|
+
const usedDirectives = typeChecker.getUsedDirectives(decl);
|
|
35691
|
+
const usedPipes = typeChecker.getUsedPipes(decl);
|
|
35655
35692
|
if (usedDirectives !== null) {
|
|
35656
35693
|
for (const dir of usedDirectives) {
|
|
35657
|
-
if (
|
|
35694
|
+
if (import_typescript111.default.isClassDeclaration(dir.ref.node)) {
|
|
35658
35695
|
results.push(dir.ref);
|
|
35659
35696
|
}
|
|
35660
35697
|
}
|
|
35661
35698
|
}
|
|
35662
35699
|
if (usedPipes !== null) {
|
|
35663
|
-
const potentialPipes = typeChecker.getPotentialPipes(
|
|
35700
|
+
const potentialPipes = typeChecker.getPotentialPipes(decl);
|
|
35664
35701
|
for (const pipe of potentialPipes) {
|
|
35665
|
-
if (
|
|
35702
|
+
if (import_typescript111.default.isClassDeclaration(pipe.ref.node) && usedPipes.some((current) => pipe.name === current)) {
|
|
35666
35703
|
results.push(pipe.ref);
|
|
35667
35704
|
}
|
|
35668
35705
|
}
|
|
@@ -35676,42 +35713,42 @@ function filterNonBootstrappedDeclarations(declarations, ngModule, templateTypeC
|
|
|
35676
35713
|
if (!bootstrapProp) {
|
|
35677
35714
|
return declarations;
|
|
35678
35715
|
}
|
|
35679
|
-
if (!
|
|
35716
|
+
if (!import_typescript111.default.isPropertyAssignment(bootstrapProp) || !import_typescript111.default.isArrayLiteralExpression(bootstrapProp.initializer)) {
|
|
35680
35717
|
return [];
|
|
35681
35718
|
}
|
|
35682
35719
|
const bootstrappedClasses = /* @__PURE__ */ new Set();
|
|
35683
35720
|
for (const el of bootstrapProp.initializer.elements) {
|
|
35684
|
-
const referencedClass =
|
|
35721
|
+
const referencedClass = import_typescript111.default.isIdentifier(el) ? findClassDeclaration(el, typeChecker) : null;
|
|
35685
35722
|
if (referencedClass) {
|
|
35686
35723
|
bootstrappedClasses.add(referencedClass);
|
|
35687
35724
|
} else {
|
|
35688
35725
|
return [];
|
|
35689
35726
|
}
|
|
35690
35727
|
}
|
|
35691
|
-
return declarations.filter((ref) => !bootstrappedClasses.has(ref
|
|
35728
|
+
return declarations.filter((ref) => !bootstrappedClasses.has(ref));
|
|
35692
35729
|
}
|
|
35693
35730
|
function extractDeclarationsFromModule(ngModule, templateTypeChecker) {
|
|
35694
35731
|
const metadata = templateTypeChecker.getNgModuleMetadata(ngModule);
|
|
35695
|
-
return metadata ? metadata.declarations.filter((decl) =>
|
|
35732
|
+
return metadata ? metadata.declarations.filter((decl) => import_typescript111.default.isClassDeclaration(decl.node)).map((decl) => decl.node) : [];
|
|
35696
35733
|
}
|
|
35697
35734
|
function migrateTestDeclarations(testObjects, declarationsOutsideOfTestFiles, tracker, templateTypeChecker, typeChecker) {
|
|
35698
35735
|
const { decorators, componentImports } = analyzeTestingModules(testObjects, typeChecker);
|
|
35699
|
-
const allDeclarations = declarationsOutsideOfTestFiles
|
|
35736
|
+
const allDeclarations = new Set(declarationsOutsideOfTestFiles);
|
|
35700
35737
|
for (const decorator of decorators) {
|
|
35701
|
-
const closestClass = closestNode(decorator.node,
|
|
35738
|
+
const closestClass = closestNode(decorator.node, import_typescript111.default.isClassDeclaration);
|
|
35702
35739
|
if (decorator.name === "Pipe" || decorator.name === "Directive") {
|
|
35703
35740
|
tracker.replaceNode(decorator.node, addStandaloneToDecorator(decorator.node));
|
|
35704
35741
|
if (closestClass) {
|
|
35705
|
-
allDeclarations.
|
|
35742
|
+
allDeclarations.add(closestClass);
|
|
35706
35743
|
}
|
|
35707
35744
|
} else if (decorator.name === "Component") {
|
|
35708
35745
|
const newDecorator = addStandaloneToDecorator(decorator.node);
|
|
35709
35746
|
const importsToAdd = componentImports.get(decorator.node);
|
|
35710
35747
|
if (closestClass) {
|
|
35711
|
-
allDeclarations.
|
|
35748
|
+
allDeclarations.add(closestClass);
|
|
35712
35749
|
}
|
|
35713
35750
|
if (importsToAdd && importsToAdd.size > 0) {
|
|
35714
|
-
tracker.replaceNode(decorator.node, addPropertyToAngularDecorator(newDecorator,
|
|
35751
|
+
tracker.replaceNode(decorator.node, addPropertyToAngularDecorator(newDecorator, import_typescript111.default.factory.createPropertyAssignment("imports", import_typescript111.default.factory.createArrayLiteralExpression(Array.from(importsToAdd)))));
|
|
35715
35752
|
} else {
|
|
35716
35753
|
tracker.replaceNode(decorator.node, newDecorator);
|
|
35717
35754
|
}
|
|
@@ -35732,13 +35769,13 @@ function analyzeTestingModules(testObjects, typeChecker) {
|
|
|
35732
35769
|
}
|
|
35733
35770
|
const importsProp = findLiteralProperty(obj, "imports");
|
|
35734
35771
|
const importElements = importsProp && hasNgModuleMetadataElements(importsProp) ? importsProp.initializer.elements.filter((el) => {
|
|
35735
|
-
return !
|
|
35772
|
+
return !import_typescript111.default.isCallExpression(el) && !isClassReferenceInAngularModule(el, /^BrowserAnimationsModule|NoopAnimationsModule$/, "platform-browser/animations", typeChecker);
|
|
35736
35773
|
}) : null;
|
|
35737
35774
|
for (const decl of declarations) {
|
|
35738
35775
|
if (seenDeclarations.has(decl)) {
|
|
35739
35776
|
continue;
|
|
35740
35777
|
}
|
|
35741
|
-
const [decorator] = getAngularDecorators(typeChecker,
|
|
35778
|
+
const [decorator] = getAngularDecorators(typeChecker, import_typescript111.default.getDecorators(decl) || []);
|
|
35742
35779
|
if (decorator) {
|
|
35743
35780
|
seenDeclarations.add(decl);
|
|
35744
35781
|
decorators.push(decorator);
|
|
@@ -35769,10 +35806,10 @@ function extractDeclarationsFromTestObject(obj, typeChecker) {
|
|
|
35769
35806
|
return results;
|
|
35770
35807
|
}
|
|
35771
35808
|
function extractMetadataLiteral(decorator) {
|
|
35772
|
-
return
|
|
35809
|
+
return import_typescript111.default.isCallExpression(decorator.expression) && decorator.expression.arguments.length === 1 && import_typescript111.default.isObjectLiteralExpression(decorator.expression.arguments[0]) ? decorator.expression.arguments[0] : null;
|
|
35773
35810
|
}
|
|
35774
35811
|
function isStandaloneDeclaration(node, declarationsInMigration, templateTypeChecker) {
|
|
35775
|
-
if (declarationsInMigration.
|
|
35812
|
+
if (declarationsInMigration.has(node)) {
|
|
35776
35813
|
return true;
|
|
35777
35814
|
}
|
|
35778
35815
|
const metadata = templateTypeChecker.getDirectiveMetadata(node) || templateTypeChecker.getPipeMetadata(node);
|
|
@@ -35786,11 +35823,12 @@ function toStandaloneBootstrap(program, host, basePath, rootFileNames, sourceFil
|
|
|
35786
35823
|
const templateTypeChecker = program.compiler.getTemplateTypeChecker();
|
|
35787
35824
|
const referenceResolver = new ReferenceResolver(program, host, rootFileNames, basePath, referenceLookupExcludedFiles);
|
|
35788
35825
|
const bootstrapCalls = [];
|
|
35789
|
-
const testObjects =
|
|
35790
|
-
const allDeclarations =
|
|
35826
|
+
const testObjects = /* @__PURE__ */ new Set();
|
|
35827
|
+
const allDeclarations = /* @__PURE__ */ new Set();
|
|
35828
|
+
const additionalProviders = hasImport(program, rootFileNames, "protractor") ? /* @__PURE__ */ new Map([["provideProtractorTestingSupport", "@angular/platform-browser"]]) : null;
|
|
35791
35829
|
for (const sourceFile of sourceFiles) {
|
|
35792
35830
|
sourceFile.forEachChild(function walk(node) {
|
|
35793
|
-
if (
|
|
35831
|
+
if (import_typescript112.default.isCallExpression(node) && import_typescript112.default.isPropertyAccessExpression(node.expression) && node.expression.name.text === "bootstrapModule" && isClassReferenceInAngularModule(node.expression, "PlatformRef", "core", typeChecker)) {
|
|
35794
35832
|
const call = analyzeBootstrapCall(node, typeChecker, templateTypeChecker);
|
|
35795
35833
|
if (call) {
|
|
35796
35834
|
bootstrapCalls.push(call);
|
|
@@ -35798,11 +35836,11 @@ function toStandaloneBootstrap(program, host, basePath, rootFileNames, sourceFil
|
|
|
35798
35836
|
}
|
|
35799
35837
|
node.forEachChild(walk);
|
|
35800
35838
|
});
|
|
35801
|
-
|
|
35839
|
+
findTestObjectsToMigrate(sourceFile, typeChecker).forEach((obj) => testObjects.add(obj));
|
|
35802
35840
|
}
|
|
35803
35841
|
for (const call of bootstrapCalls) {
|
|
35804
|
-
|
|
35805
|
-
migrateBootstrapCall(call, tracker, referenceResolver, typeChecker, printer);
|
|
35842
|
+
call.declarations.forEach((decl) => allDeclarations.add(decl));
|
|
35843
|
+
migrateBootstrapCall(call, tracker, additionalProviders, referenceResolver, typeChecker, printer);
|
|
35806
35844
|
}
|
|
35807
35845
|
for (const declaration of allDeclarations) {
|
|
35808
35846
|
convertNgModuleDeclarationToStandalone(declaration, allDeclarations, tracker, templateTypeChecker, componentImportRemapper);
|
|
@@ -35811,24 +35849,24 @@ function toStandaloneBootstrap(program, host, basePath, rootFileNames, sourceFil
|
|
|
35811
35849
|
return tracker.recordChanges();
|
|
35812
35850
|
}
|
|
35813
35851
|
function analyzeBootstrapCall(call, typeChecker, templateTypeChecker) {
|
|
35814
|
-
if (call.arguments.length === 0 || !
|
|
35852
|
+
if (call.arguments.length === 0 || !import_typescript112.default.isIdentifier(call.arguments[0])) {
|
|
35815
35853
|
return null;
|
|
35816
35854
|
}
|
|
35817
35855
|
const declaration = findClassDeclaration(call.arguments[0], typeChecker);
|
|
35818
35856
|
if (!declaration) {
|
|
35819
35857
|
return null;
|
|
35820
35858
|
}
|
|
35821
|
-
const decorator = getAngularDecorators(typeChecker,
|
|
35822
|
-
if (!decorator || decorator.node.expression.arguments.length === 0 || !
|
|
35859
|
+
const decorator = getAngularDecorators(typeChecker, import_typescript112.default.getDecorators(declaration) || []).find((decorator2) => decorator2.name === "NgModule");
|
|
35860
|
+
if (!decorator || decorator.node.expression.arguments.length === 0 || !import_typescript112.default.isObjectLiteralExpression(decorator.node.expression.arguments[0])) {
|
|
35823
35861
|
return null;
|
|
35824
35862
|
}
|
|
35825
35863
|
const metadata = decorator.node.expression.arguments[0];
|
|
35826
35864
|
const bootstrapProp = findLiteralProperty(metadata, "bootstrap");
|
|
35827
|
-
if (!bootstrapProp || !
|
|
35865
|
+
if (!bootstrapProp || !import_typescript112.default.isPropertyAssignment(bootstrapProp) || !import_typescript112.default.isArrayLiteralExpression(bootstrapProp.initializer) || bootstrapProp.initializer.elements.length === 0 || !import_typescript112.default.isIdentifier(bootstrapProp.initializer.elements[0])) {
|
|
35828
35866
|
return null;
|
|
35829
35867
|
}
|
|
35830
35868
|
const component = findClassDeclaration(bootstrapProp.initializer.elements[0], typeChecker);
|
|
35831
|
-
if (component && component.name &&
|
|
35869
|
+
if (component && component.name && import_typescript112.default.isIdentifier(component.name)) {
|
|
35832
35870
|
return {
|
|
35833
35871
|
module: declaration,
|
|
35834
35872
|
metadata,
|
|
@@ -35839,7 +35877,7 @@ function analyzeBootstrapCall(call, typeChecker, templateTypeChecker) {
|
|
|
35839
35877
|
}
|
|
35840
35878
|
return null;
|
|
35841
35879
|
}
|
|
35842
|
-
function migrateBootstrapCall(analysis, tracker, referenceResolver, typeChecker, printer) {
|
|
35880
|
+
function migrateBootstrapCall(analysis, tracker, additionalProviders, referenceResolver, typeChecker, printer) {
|
|
35843
35881
|
const sourceFile = analysis.call.getSourceFile();
|
|
35844
35882
|
const moduleSourceFile = analysis.metadata.getSourceFile();
|
|
35845
35883
|
const providers = findLiteralProperty(analysis.metadata, "providers");
|
|
@@ -35850,19 +35888,24 @@ function migrateBootstrapCall(analysis, tracker, referenceResolver, typeChecker,
|
|
|
35850
35888
|
let nodeLookup = null;
|
|
35851
35889
|
tracker.insertText(moduleSourceFile, analysis.metadata.getStart(), "/* TODO(standalone-migration): clean up removed NgModule class manually. \n");
|
|
35852
35890
|
tracker.insertText(moduleSourceFile, analysis.metadata.getEnd(), " */");
|
|
35853
|
-
if (providers &&
|
|
35891
|
+
if (providers && import_typescript112.default.isPropertyAssignment(providers)) {
|
|
35854
35892
|
nodeLookup = nodeLookup || getNodeLookup(moduleSourceFile);
|
|
35855
|
-
if (
|
|
35893
|
+
if (import_typescript112.default.isArrayLiteralExpression(providers.initializer)) {
|
|
35856
35894
|
providersInNewCall.push(...providers.initializer.elements);
|
|
35857
35895
|
} else {
|
|
35858
|
-
providersInNewCall.push(
|
|
35896
|
+
providersInNewCall.push(import_typescript112.default.factory.createSpreadElement(providers.initializer));
|
|
35859
35897
|
}
|
|
35860
35898
|
addNodesToCopy(sourceFile, providers, nodeLookup, tracker, nodesToCopy, referenceResolver);
|
|
35861
35899
|
}
|
|
35862
|
-
if (imports &&
|
|
35900
|
+
if (imports && import_typescript112.default.isPropertyAssignment(imports)) {
|
|
35863
35901
|
nodeLookup = nodeLookup || getNodeLookup(moduleSourceFile);
|
|
35864
35902
|
migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, moduleImportsInNewCall, providersInNewCall, tracker, nodesToCopy, referenceResolver, typeChecker);
|
|
35865
35903
|
}
|
|
35904
|
+
if (additionalProviders) {
|
|
35905
|
+
additionalProviders.forEach((moduleSpecifier, name) => {
|
|
35906
|
+
providersInNewCall.push(import_typescript112.default.factory.createCallExpression(tracker.addImport(sourceFile, name, moduleSpecifier), void 0, void 0));
|
|
35907
|
+
});
|
|
35908
|
+
}
|
|
35866
35909
|
if (nodesToCopy.size > 0) {
|
|
35867
35910
|
let text = "\n\n";
|
|
35868
35911
|
nodesToCopy.forEach((node) => {
|
|
@@ -35870,7 +35913,7 @@ function migrateBootstrapCall(analysis, tracker, referenceResolver, typeChecker,
|
|
|
35870
35913
|
if (transformedNode === node) {
|
|
35871
35914
|
text += transformedNode.getText() + "\n";
|
|
35872
35915
|
} else {
|
|
35873
|
-
text += printer.printNode(
|
|
35916
|
+
text += printer.printNode(import_typescript112.default.EmitHint.Unspecified, transformedNode, node.getSourceFile());
|
|
35874
35917
|
}
|
|
35875
35918
|
});
|
|
35876
35919
|
text += "\n";
|
|
@@ -35887,30 +35930,30 @@ function replaceBootstrapCallExpression(analysis, providers, modules, tracker) {
|
|
|
35887
35930
|
const combinedProviders = [];
|
|
35888
35931
|
if (modules.length > 0) {
|
|
35889
35932
|
const importProvidersExpression = tracker.addImport(sourceFile, "importProvidersFrom", "@angular/core");
|
|
35890
|
-
combinedProviders.push(
|
|
35933
|
+
combinedProviders.push(import_typescript112.default.factory.createCallExpression(importProvidersExpression, [], modules));
|
|
35891
35934
|
}
|
|
35892
35935
|
combinedProviders.push(...providers);
|
|
35893
|
-
const initializer = remapDynamicImports(sourceFile.fileName,
|
|
35894
|
-
args.push(
|
|
35936
|
+
const initializer = remapDynamicImports(sourceFile.fileName, import_typescript112.default.factory.createArrayLiteralExpression(combinedProviders, combinedProviders.length > 1));
|
|
35937
|
+
args.push(import_typescript112.default.factory.createObjectLiteralExpression([import_typescript112.default.factory.createPropertyAssignment("providers", initializer)], true));
|
|
35895
35938
|
}
|
|
35896
35939
|
tracker.replaceNode(
|
|
35897
35940
|
analysis.call,
|
|
35898
|
-
|
|
35941
|
+
import_typescript112.default.factory.createCallExpression(bootstrapExpression, [], args),
|
|
35899
35942
|
void 0,
|
|
35900
35943
|
analysis.metadata.getSourceFile()
|
|
35901
35944
|
);
|
|
35902
35945
|
}
|
|
35903
35946
|
function migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, importsForNewCall, providersInNewCall, tracker, nodesToCopy, referenceResolver, typeChecker) {
|
|
35904
|
-
if (!
|
|
35947
|
+
if (!import_typescript112.default.isArrayLiteralExpression(imports.initializer)) {
|
|
35905
35948
|
importsForNewCall.push(imports.initializer);
|
|
35906
35949
|
return;
|
|
35907
35950
|
}
|
|
35908
35951
|
for (const element of imports.initializer.elements) {
|
|
35909
|
-
if (
|
|
35952
|
+
if (import_typescript112.default.isCallExpression(element) && import_typescript112.default.isPropertyAccessExpression(element.expression) && element.arguments.length > 0 && element.expression.name.text === "forRoot" && isClassReferenceInAngularModule(element.expression.expression, "RouterModule", "router", typeChecker)) {
|
|
35910
35953
|
const options = element.arguments[1];
|
|
35911
35954
|
const features = options ? getRouterModuleForRootFeatures(sourceFile, options, tracker) : [];
|
|
35912
35955
|
if (features !== null) {
|
|
35913
|
-
providersInNewCall.push(
|
|
35956
|
+
providersInNewCall.push(import_typescript112.default.factory.createCallExpression(tracker.addImport(sourceFile, "provideRouter", "@angular/router"), [], [element.arguments[0], ...features]));
|
|
35914
35957
|
addNodesToCopy(sourceFile, element.arguments[0], nodeLookup, tracker, nodesToCopy, referenceResolver);
|
|
35915
35958
|
if (options) {
|
|
35916
35959
|
addNodesToCopy(sourceFile, options, nodeLookup, tracker, nodesToCopy, referenceResolver);
|
|
@@ -35918,30 +35961,30 @@ function migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, imports
|
|
|
35918
35961
|
continue;
|
|
35919
35962
|
}
|
|
35920
35963
|
}
|
|
35921
|
-
if (
|
|
35964
|
+
if (import_typescript112.default.isIdentifier(element)) {
|
|
35922
35965
|
const animationsModule = "platform-browser/animations";
|
|
35923
35966
|
const animationsImport = `@angular/${animationsModule}`;
|
|
35924
35967
|
if (isClassReferenceInAngularModule(element, "BrowserAnimationsModule", animationsModule, typeChecker)) {
|
|
35925
|
-
providersInNewCall.push(
|
|
35968
|
+
providersInNewCall.push(import_typescript112.default.factory.createCallExpression(tracker.addImport(sourceFile, "provideAnimations", animationsImport), [], []));
|
|
35926
35969
|
continue;
|
|
35927
35970
|
}
|
|
35928
35971
|
if (isClassReferenceInAngularModule(element, "NoopAnimationsModule", animationsModule, typeChecker)) {
|
|
35929
|
-
providersInNewCall.push(
|
|
35972
|
+
providersInNewCall.push(import_typescript112.default.factory.createCallExpression(tracker.addImport(sourceFile, "provideNoopAnimations", animationsImport), [], []));
|
|
35930
35973
|
continue;
|
|
35931
35974
|
}
|
|
35932
35975
|
const httpClientModule = "common/http";
|
|
35933
35976
|
const httpClientImport = `@angular/${httpClientModule}`;
|
|
35934
35977
|
if (isClassReferenceInAngularModule(element, "HttpClientModule", httpClientModule, typeChecker)) {
|
|
35935
35978
|
const callArgs = [
|
|
35936
|
-
|
|
35979
|
+
import_typescript112.default.factory.createCallExpression(tracker.addImport(sourceFile, "withInterceptorsFromDi", httpClientImport), [], [])
|
|
35937
35980
|
];
|
|
35938
|
-
providersInNewCall.push(
|
|
35981
|
+
providersInNewCall.push(import_typescript112.default.factory.createCallExpression(tracker.addImport(sourceFile, "provideHttpClient", httpClientImport), [], callArgs));
|
|
35939
35982
|
continue;
|
|
35940
35983
|
}
|
|
35941
35984
|
}
|
|
35942
|
-
const target =
|
|
35985
|
+
const target = import_typescript112.default.isCallExpression(element) && import_typescript112.default.isPropertyAccessExpression(element.expression) ? element.expression.expression : element;
|
|
35943
35986
|
const classDeclaration = findClassDeclaration(target, typeChecker);
|
|
35944
|
-
const decorators = classDeclaration ? getAngularDecorators(typeChecker,
|
|
35987
|
+
const decorators = classDeclaration ? getAngularDecorators(typeChecker, import_typescript112.default.getDecorators(classDeclaration) || []) : void 0;
|
|
35945
35988
|
if (!decorators || decorators.length === 0 || decorators.every(({ name }) => name !== "Directive" && name !== "Component" && name !== "Pipe")) {
|
|
35946
35989
|
importsForNewCall.push(element);
|
|
35947
35990
|
addNodesToCopy(sourceFile, element, nodeLookup, tracker, nodesToCopy, referenceResolver);
|
|
@@ -35949,7 +35992,7 @@ function migrateImportsForBootstrapCall(sourceFile, imports, nodeLookup, imports
|
|
|
35949
35992
|
}
|
|
35950
35993
|
}
|
|
35951
35994
|
function getRouterModuleForRootFeatures(sourceFile, options, tracker) {
|
|
35952
|
-
if (!
|
|
35995
|
+
if (!import_typescript112.default.isObjectLiteralExpression(options)) {
|
|
35953
35996
|
return null;
|
|
35954
35997
|
}
|
|
35955
35998
|
const featureExpressions = [];
|
|
@@ -35957,7 +36000,7 @@ function getRouterModuleForRootFeatures(sourceFile, options, tracker) {
|
|
|
35957
36000
|
const inMemoryScrollingOptions = [];
|
|
35958
36001
|
const features = new UniqueItemTracker();
|
|
35959
36002
|
for (const prop of options.properties) {
|
|
35960
|
-
if (!
|
|
36003
|
+
if (!import_typescript112.default.isPropertyAssignment(prop) || !import_typescript112.default.isIdentifier(prop.name) && !import_typescript112.default.isStringLiteralLike(prop.name)) {
|
|
35961
36004
|
return null;
|
|
35962
36005
|
}
|
|
35963
36006
|
switch (prop.name.text) {
|
|
@@ -35965,12 +36008,12 @@ function getRouterModuleForRootFeatures(sourceFile, options, tracker) {
|
|
|
35965
36008
|
features.track("withPreloading", prop.initializer);
|
|
35966
36009
|
break;
|
|
35967
36010
|
case "enableTracing":
|
|
35968
|
-
if (prop.initializer.kind ===
|
|
36011
|
+
if (prop.initializer.kind === import_typescript112.default.SyntaxKind.TrueKeyword) {
|
|
35969
36012
|
features.track("withDebugTracing", null);
|
|
35970
36013
|
}
|
|
35971
36014
|
break;
|
|
35972
36015
|
case "initialNavigation":
|
|
35973
|
-
if (!
|
|
36016
|
+
if (!import_typescript112.default.isStringLiteralLike(prop.initializer)) {
|
|
35974
36017
|
return null;
|
|
35975
36018
|
}
|
|
35976
36019
|
if (prop.initializer.text === "enabledBlocking" || prop.initializer.text === "enabled") {
|
|
@@ -35980,7 +36023,7 @@ function getRouterModuleForRootFeatures(sourceFile, options, tracker) {
|
|
|
35980
36023
|
}
|
|
35981
36024
|
break;
|
|
35982
36025
|
case "useHash":
|
|
35983
|
-
if (prop.initializer.kind ===
|
|
36026
|
+
if (prop.initializer.kind === import_typescript112.default.SyntaxKind.TrueKeyword) {
|
|
35984
36027
|
features.track("withHashLocation", null);
|
|
35985
36028
|
}
|
|
35986
36029
|
break;
|
|
@@ -35997,10 +36040,10 @@ function getRouterModuleForRootFeatures(sourceFile, options, tracker) {
|
|
|
35997
36040
|
}
|
|
35998
36041
|
}
|
|
35999
36042
|
if (inMemoryScrollingOptions.length > 0) {
|
|
36000
|
-
features.track("withInMemoryScrolling",
|
|
36043
|
+
features.track("withInMemoryScrolling", import_typescript112.default.factory.createObjectLiteralExpression(inMemoryScrollingOptions));
|
|
36001
36044
|
}
|
|
36002
36045
|
if (configOptions.length > 0) {
|
|
36003
|
-
features.track("withRouterConfig",
|
|
36046
|
+
features.track("withRouterConfig", import_typescript112.default.factory.createObjectLiteralExpression(configOptions));
|
|
36004
36047
|
}
|
|
36005
36048
|
for (const [feature, featureArgs] of features.getEntries()) {
|
|
36006
36049
|
const callArgs = [];
|
|
@@ -36009,25 +36052,25 @@ function getRouterModuleForRootFeatures(sourceFile, options, tracker) {
|
|
|
36009
36052
|
callArgs.push(arg);
|
|
36010
36053
|
}
|
|
36011
36054
|
});
|
|
36012
|
-
featureExpressions.push(
|
|
36055
|
+
featureExpressions.push(import_typescript112.default.factory.createCallExpression(tracker.addImport(sourceFile, feature, "@angular/router"), [], callArgs));
|
|
36013
36056
|
}
|
|
36014
36057
|
return featureExpressions;
|
|
36015
36058
|
}
|
|
36016
36059
|
function addNodesToCopy(targetFile, rootNode, nodeLookup, tracker, nodesToCopy, referenceResolver) {
|
|
36017
36060
|
const refs = findAllSameFileReferences(rootNode, nodeLookup, referenceResolver);
|
|
36018
36061
|
for (const ref of refs) {
|
|
36019
|
-
const importSpecifier = closestOrSelf(ref,
|
|
36020
|
-
const importDeclaration = importSpecifier ? closestNode(importSpecifier,
|
|
36021
|
-
if (importDeclaration && importSpecifier &&
|
|
36062
|
+
const importSpecifier = closestOrSelf(ref, import_typescript112.default.isImportSpecifier);
|
|
36063
|
+
const importDeclaration = importSpecifier ? closestNode(importSpecifier, import_typescript112.default.isImportDeclaration) : null;
|
|
36064
|
+
if (importDeclaration && importSpecifier && import_typescript112.default.isStringLiteralLike(importDeclaration.moduleSpecifier)) {
|
|
36022
36065
|
const moduleName = importDeclaration.moduleSpecifier.text.startsWith(".") ? remapRelativeImport(targetFile.fileName, importDeclaration.moduleSpecifier) : importDeclaration.moduleSpecifier.text;
|
|
36023
36066
|
const symbolName = importSpecifier.propertyName ? importSpecifier.propertyName.text : importSpecifier.name.text;
|
|
36024
36067
|
const alias = importSpecifier.propertyName ? importSpecifier.name.text : null;
|
|
36025
36068
|
tracker.addImport(targetFile, symbolName, moduleName, alias);
|
|
36026
36069
|
continue;
|
|
36027
36070
|
}
|
|
36028
|
-
const variableDeclaration = closestOrSelf(ref,
|
|
36029
|
-
const variableStatement = variableDeclaration ? closestNode(variableDeclaration,
|
|
36030
|
-
if (variableDeclaration && variableStatement &&
|
|
36071
|
+
const variableDeclaration = closestOrSelf(ref, import_typescript112.default.isVariableDeclaration);
|
|
36072
|
+
const variableStatement = variableDeclaration ? closestNode(variableDeclaration, import_typescript112.default.isVariableStatement) : null;
|
|
36073
|
+
if (variableDeclaration && variableStatement && import_typescript112.default.isIdentifier(variableDeclaration.name)) {
|
|
36031
36074
|
if (isExported3(variableStatement)) {
|
|
36032
36075
|
tracker.addImport(targetFile, variableDeclaration.name.text, getRelativeImportPath(targetFile.fileName, ref.getSourceFile().fileName));
|
|
36033
36076
|
} else {
|
|
@@ -36068,7 +36111,7 @@ function findAllSameFileReferences(rootNode, nodeLookup, referenceResolver) {
|
|
|
36068
36111
|
if (!closestTopLevel || traversedTopLevelNodes.has(closestTopLevel)) {
|
|
36069
36112
|
continue;
|
|
36070
36113
|
}
|
|
36071
|
-
if (!
|
|
36114
|
+
if (!import_typescript112.default.isImportDeclaration(closestTopLevel) && isOutsideRange(excludeStart, excludeEnd, closestTopLevel.getStart(), closestTopLevel.getEnd())) {
|
|
36072
36115
|
traversedTopLevelNodes.add(closestTopLevel);
|
|
36073
36116
|
walk(closestTopLevel);
|
|
36074
36117
|
}
|
|
@@ -36089,25 +36132,25 @@ function referencesToNodeWithinSameFile(node, nodeLookup, excludeStart, excludeE
|
|
|
36089
36132
|
function remapDynamicImports(targetFileName, rootNode) {
|
|
36090
36133
|
let hasChanged = false;
|
|
36091
36134
|
const transformer = (context) => {
|
|
36092
|
-
return (sourceFile) =>
|
|
36093
|
-
if (
|
|
36135
|
+
return (sourceFile) => import_typescript112.default.visitNode(sourceFile, function walk(node) {
|
|
36136
|
+
if (import_typescript112.default.isCallExpression(node) && node.expression.kind === import_typescript112.default.SyntaxKind.ImportKeyword && node.arguments.length > 0 && import_typescript112.default.isStringLiteralLike(node.arguments[0]) && node.arguments[0].text.startsWith(".")) {
|
|
36094
36137
|
hasChanged = true;
|
|
36095
36138
|
return context.factory.updateCallExpression(node, node.expression, node.typeArguments, [
|
|
36096
36139
|
context.factory.createStringLiteral(remapRelativeImport(targetFileName, node.arguments[0])),
|
|
36097
36140
|
...node.arguments.slice(1)
|
|
36098
36141
|
]);
|
|
36099
36142
|
}
|
|
36100
|
-
return
|
|
36143
|
+
return import_typescript112.default.visitEachChild(node, walk, context);
|
|
36101
36144
|
});
|
|
36102
36145
|
};
|
|
36103
|
-
const result =
|
|
36146
|
+
const result = import_typescript112.default.transform(rootNode, [transformer]).transformed[0];
|
|
36104
36147
|
return hasChanged ? result : rootNode;
|
|
36105
36148
|
}
|
|
36106
36149
|
function isTopLevelStatement(node) {
|
|
36107
|
-
return node.parent != null &&
|
|
36150
|
+
return node.parent != null && import_typescript112.default.isSourceFile(node.parent);
|
|
36108
36151
|
}
|
|
36109
36152
|
function isReferenceIdentifier(node) {
|
|
36110
|
-
return
|
|
36153
|
+
return import_typescript112.default.isIdentifier(node) && (!import_typescript112.default.isPropertyAssignment(node.parent) && !import_typescript112.default.isParameter(node.parent) || node.parent.name !== node);
|
|
36111
36154
|
}
|
|
36112
36155
|
function isOutsideRange(excludeStart, excludeEnd, start, end) {
|
|
36113
36156
|
return start < excludeStart && end < excludeStart || start > excludeEnd;
|
|
@@ -36116,15 +36159,15 @@ function remapRelativeImport(targetFileName, specifier) {
|
|
|
36116
36159
|
return getRelativeImportPath(targetFileName, (0, import_path7.join)((0, import_path7.dirname)(specifier.getSourceFile().fileName), specifier.text));
|
|
36117
36160
|
}
|
|
36118
36161
|
function isExported3(node) {
|
|
36119
|
-
return
|
|
36162
|
+
return import_typescript112.default.canHaveModifiers(node) && node.modifiers ? node.modifiers.some((modifier) => modifier.kind === import_typescript112.default.SyntaxKind.ExportKeyword) : false;
|
|
36120
36163
|
}
|
|
36121
36164
|
function isExportableDeclaration(node) {
|
|
36122
|
-
return
|
|
36165
|
+
return import_typescript112.default.isEnumDeclaration(node) || import_typescript112.default.isClassDeclaration(node) || import_typescript112.default.isFunctionDeclaration(node) || import_typescript112.default.isInterfaceDeclaration(node) || import_typescript112.default.isTypeAliasDeclaration(node);
|
|
36123
36166
|
}
|
|
36124
36167
|
function getLastImportEnd(sourceFile) {
|
|
36125
36168
|
let index = 0;
|
|
36126
36169
|
for (const statement of sourceFile.statements) {
|
|
36127
|
-
if (
|
|
36170
|
+
if (import_typescript112.default.isImportDeclaration(statement)) {
|
|
36128
36171
|
index = Math.max(index, statement.getEnd());
|
|
36129
36172
|
} else {
|
|
36130
36173
|
break;
|
|
@@ -36132,6 +36175,22 @@ function getLastImportEnd(sourceFile) {
|
|
|
36132
36175
|
}
|
|
36133
36176
|
return index;
|
|
36134
36177
|
}
|
|
36178
|
+
function hasImport(program, rootFileNames, moduleName) {
|
|
36179
|
+
const tsProgram = program.getTsProgram();
|
|
36180
|
+
const deepImportStart = moduleName + "/";
|
|
36181
|
+
for (const fileName of rootFileNames) {
|
|
36182
|
+
const sourceFile = tsProgram.getSourceFile(fileName);
|
|
36183
|
+
if (!sourceFile) {
|
|
36184
|
+
continue;
|
|
36185
|
+
}
|
|
36186
|
+
for (const statement of sourceFile.statements) {
|
|
36187
|
+
if (import_typescript112.default.isImportDeclaration(statement) && import_typescript112.default.isStringLiteralLike(statement.moduleSpecifier) && (statement.moduleSpecifier.text === moduleName || statement.moduleSpecifier.text.startsWith(deepImportStart))) {
|
|
36188
|
+
return true;
|
|
36189
|
+
}
|
|
36190
|
+
}
|
|
36191
|
+
}
|
|
36192
|
+
return false;
|
|
36193
|
+
}
|
|
36135
36194
|
|
|
36136
36195
|
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/ng-generate/standalone-migration/index.mjs
|
|
36137
36196
|
var MigrationMode;
|
|
@@ -36172,7 +36231,7 @@ function standaloneMigration(tree, tsconfigPath, basePath, pathToMigrate, schema
|
|
|
36172
36231
|
});
|
|
36173
36232
|
const referenceLookupExcludedFiles = /node_modules|\.ngtypecheck\.ts/;
|
|
36174
36233
|
const program = createProgram({ rootNames, host, options, oldProgram });
|
|
36175
|
-
const printer =
|
|
36234
|
+
const printer = import_typescript113.default.createPrinter();
|
|
36176
36235
|
if ((0, import_fs2.existsSync)(pathToMigrate) && !(0, import_fs2.statSync)(pathToMigrate).isDirectory()) {
|
|
36177
36236
|
throw new import_schematics.SchematicsException(`Migration path ${pathToMigrate} has to be a directory. Cannot run the standalone migration.`);
|
|
36178
36237
|
}
|