@angular/core 18.0.0-rc.0 → 18.0.0-rc.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/esm2022/primitives/event-dispatch/contract_binary.mjs +3 -3
- package/esm2022/primitives/event-dispatch/index.mjs +2 -2
- package/esm2022/primitives/event-dispatch/src/action_resolver.mjs +221 -0
- package/esm2022/primitives/event-dispatch/src/attribute.mjs +63 -65
- package/esm2022/primitives/event-dispatch/src/cache.mjs +10 -10
- package/esm2022/primitives/event-dispatch/src/dispatcher.mjs +52 -176
- package/esm2022/primitives/event-dispatch/src/earlyeventcontract.mjs +15 -9
- package/esm2022/primitives/event-dispatch/src/event_contract_defines.mjs +1 -19
- package/esm2022/primitives/event-dispatch/src/eventcontract.mjs +24 -362
- package/esm2022/primitives/event-dispatch/src/key_code.mjs +11 -13
- package/esm2022/primitives/event-dispatch/src/legacy_dispatcher.mjs +252 -2
- package/esm2022/primitives/event-dispatch/src/property.mjs +30 -27
- package/esm2022/primitives/event-dispatch/src/register_events.mjs +16 -17
- package/esm2022/primitives/event-dispatch/src/restriction.mjs +2 -2
- package/esm2022/src/application/application_ref.mjs +6 -3
- package/esm2022/src/application/create_application.mjs +12 -5
- package/esm2022/src/change_detection/scheduling/exhaustive_check_no_changes.mjs +150 -0
- package/esm2022/src/change_detection/scheduling/ng_zone_scheduling.mjs +6 -4
- package/esm2022/src/change_detection/scheduling/zoneless_scheduling.mjs +3 -1
- package/esm2022/src/change_detection/scheduling/zoneless_scheduling_impl.mjs +9 -6
- package/esm2022/src/core.mjs +2 -1
- package/esm2022/src/core_private_export.mjs +2 -1
- package/esm2022/src/core_reactivity_export_internal.mjs +1 -3
- package/esm2022/src/core_render3_private_export.mjs +1 -3
- package/esm2022/src/defer/instructions.mjs +20 -12
- package/esm2022/src/defer/interfaces.mjs +1 -3
- package/esm2022/src/errors.mjs +1 -1
- package/esm2022/src/hydration/event_replay.mjs +67 -79
- package/esm2022/src/hydration/utils.mjs +1 -2
- package/esm2022/src/metadata/directives.mjs +1 -1
- package/esm2022/src/platform/platform_ref.mjs +10 -4
- package/esm2022/src/render3/after_render_hooks.mjs +4 -2
- package/esm2022/src/render3/component_ref.mjs +1 -1
- package/esm2022/src/render3/index.mjs +1 -3
- package/esm2022/src/render3/instructions/change_detection.mjs +13 -10
- package/esm2022/src/render3/instructions/listener.mjs +12 -1
- package/esm2022/src/render3/interfaces/public_definitions.mjs +1 -1
- package/esm2022/src/render3/state.mjs +14 -4
- package/esm2022/src/render3/view_ref.mjs +3 -2
- package/esm2022/src/util/callback_scheduler.mjs +12 -26
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/src/zone/ng_zone.mjs +9 -23
- package/esm2022/testing/src/component_fixture.mjs +2 -4
- package/esm2022/testing/src/defer.mjs +1 -2
- package/esm2022/testing/src/logger.mjs +3 -3
- package/esm2022/testing/src/test_bed.mjs +1 -3
- package/esm2022/testing/src/test_bed_compiler.mjs +3 -6
- package/event-dispatch-contract.min.js +1 -1
- package/fesm2022/core.mjs +800 -660
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +484 -807
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +4 -10
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +36 -4
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +111 -162
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/http-providers/bundle.js +110 -71
- package/schematics/migrations/http-providers/bundle.js.map +3 -3
- package/schematics/migrations/invalid-two-way-bindings/bundle.js +197 -167
- package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +2 -2
- package/schematics/ng-generate/control-flow-migration/bundle.js +205 -175
- package/schematics/ng-generate/control-flow-migration/bundle.js.map +2 -2
- package/schematics/ng-generate/standalone-migration/bundle.js +481 -451
- package/schematics/ng-generate/standalone-migration/bundle.js.map +2 -2
- package/testing/index.d.ts +1 -4
- package/esm2022/primitives/event-dispatch/src/base_dispatcher.mjs +0 -96
- package/esm2022/primitives/event-dispatch/src/custom_events.mjs +0 -63
- package/esm2022/primitives/event-dispatch/src/replay.mjs +0 -389
|
@@ -60,7 +60,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
// bazel-out/
|
|
63
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/migrations/http-providers/index.mjs
|
|
64
64
|
var http_providers_exports = {};
|
|
65
65
|
__export(http_providers_exports, {
|
|
66
66
|
default: () => http_providers_default
|
|
@@ -69,7 +69,7 @@ module.exports = __toCommonJS(http_providers_exports);
|
|
|
69
69
|
var import_schematics = require("@angular-devkit/schematics");
|
|
70
70
|
var import_path3 = require("path");
|
|
71
71
|
|
|
72
|
-
// bazel-out/
|
|
72
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/project_tsconfig_paths.mjs
|
|
73
73
|
var import_core = require("@angular-devkit/core");
|
|
74
74
|
function getProjectTsConfigPaths(tree) {
|
|
75
75
|
return __async(this, null, function* () {
|
|
@@ -149,11 +149,11 @@ function getWorkspace(tree) {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
// bazel-out/
|
|
152
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/compiler_host.mjs
|
|
153
153
|
var import_path = require("path");
|
|
154
154
|
var import_typescript2 = __toESM(require("typescript"), 1);
|
|
155
155
|
|
|
156
|
-
// bazel-out/
|
|
156
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/parse_tsconfig.mjs
|
|
157
157
|
var path = __toESM(require("path"), 1);
|
|
158
158
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
159
159
|
function parseTsconfigFile(tsconfigPath, basePath) {
|
|
@@ -170,7 +170,7 @@ function parseTsconfigFile(tsconfigPath, basePath) {
|
|
|
170
170
|
return import_typescript.default.parseJsonConfigFileContent(config, parseConfigHost, basePath, {});
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
// bazel-out/
|
|
173
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/compiler_host.mjs
|
|
174
174
|
function createMigrationProgram(tree, tsconfigPath, basePath, fakeFileRead, additionalFiles) {
|
|
175
175
|
const { rootNames, options, host } = createProgramOptions(tree, tsconfigPath, basePath, fakeFileRead, additionalFiles);
|
|
176
176
|
return import_typescript2.default.createProgram(rootNames, options, host);
|
|
@@ -203,13 +203,13 @@ function canMigrateFile(basePath, sourceFile, program) {
|
|
|
203
203
|
return !(0, import_path.relative)(basePath, sourceFile.fileName).startsWith("..");
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
// bazel-out/
|
|
206
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/migrations/http-providers/utils.mjs
|
|
207
207
|
var import_typescript7 = __toESM(require("typescript"), 1);
|
|
208
208
|
|
|
209
|
-
// bazel-out/
|
|
209
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/change_tracker.mjs
|
|
210
210
|
var import_typescript4 = __toESM(require("typescript"), 1);
|
|
211
211
|
|
|
212
|
-
// bazel-out/
|
|
212
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/import_manager.mjs
|
|
213
213
|
var import_path2 = require("path");
|
|
214
214
|
var import_typescript3 = __toESM(require("typescript"), 1);
|
|
215
215
|
var ImportManager = class {
|
|
@@ -393,7 +393,7 @@ ${text}`;
|
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
395
|
|
|
396
|
-
// bazel-out/
|
|
396
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/change_tracker.mjs
|
|
397
397
|
var ChangeTracker = class {
|
|
398
398
|
constructor(_printer, _importRemapper) {
|
|
399
399
|
__publicField(this, "_printer");
|
|
@@ -456,10 +456,10 @@ function normalizePath(path2) {
|
|
|
456
456
|
return path2.replace(/\\/g, "/");
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
// bazel-out/
|
|
459
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/decorators.mjs
|
|
460
460
|
var import_typescript6 = __toESM(require("typescript"), 1);
|
|
461
461
|
|
|
462
|
-
// bazel-out/
|
|
462
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/imports.mjs
|
|
463
463
|
var import_typescript5 = __toESM(require("typescript"), 1);
|
|
464
464
|
function getImportOfIdentifier(typeChecker, node) {
|
|
465
465
|
const symbol = typeChecker.getSymbolAtLocation(node);
|
|
@@ -519,7 +519,7 @@ function findImportSpecifier(nodes, specifierName) {
|
|
|
519
519
|
});
|
|
520
520
|
}
|
|
521
521
|
|
|
522
|
-
// bazel-out/
|
|
522
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/typescript/decorators.mjs
|
|
523
523
|
function getCallDecoratorImport(typeChecker, decorator) {
|
|
524
524
|
if (!import_typescript6.default.isCallExpression(decorator.expression) || !import_typescript6.default.isIdentifier(decorator.expression.expression)) {
|
|
525
525
|
return null;
|
|
@@ -528,7 +528,7 @@ function getCallDecoratorImport(typeChecker, decorator) {
|
|
|
528
528
|
return getImportOfIdentifier(typeChecker, identifier);
|
|
529
529
|
}
|
|
530
530
|
|
|
531
|
-
// bazel-out/
|
|
531
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/utils/ng_decorators.mjs
|
|
532
532
|
function getAngularDecorators(typeChecker, decorators) {
|
|
533
533
|
return decorators.map((node) => ({ node, importData: getCallDecoratorImport(typeChecker, node) })).filter(({ importData }) => importData && importData.importModule.startsWith("@angular/")).map(({ node, importData }) => ({
|
|
534
534
|
node,
|
|
@@ -538,7 +538,7 @@ function getAngularDecorators(typeChecker, decorators) {
|
|
|
538
538
|
}));
|
|
539
539
|
}
|
|
540
540
|
|
|
541
|
-
// bazel-out/
|
|
541
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/migrations/http-providers/utils.mjs
|
|
542
542
|
var HTTP_CLIENT_MODULE = "HttpClientModule";
|
|
543
543
|
var HTTP_CLIENT_XSRF_MODULE = "HttpClientXsrfModule";
|
|
544
544
|
var HTTP_CLIENT_JSONP_MODULE = "HttpClientJsonpModule";
|
|
@@ -558,7 +558,7 @@ var HTTP_MODULES = /* @__PURE__ */ new Set([
|
|
|
558
558
|
]);
|
|
559
559
|
var HTTP_TESTING_MODULES = /* @__PURE__ */ new Set([HTTP_CLIENT_TESTING_MODULE]);
|
|
560
560
|
function migrateFile(sourceFile, typeChecker, rewriteFn) {
|
|
561
|
-
var _a, _b, _c;
|
|
561
|
+
var _a, _b, _c, _d, _e;
|
|
562
562
|
const changeTracker = new ChangeTracker(import_typescript7.default.createPrinter());
|
|
563
563
|
const addedImports = /* @__PURE__ */ new Map([
|
|
564
564
|
[COMMON_HTTP, /* @__PURE__ */ new Set()],
|
|
@@ -571,10 +571,10 @@ function migrateFile(sourceFile, typeChecker, rewriteFn) {
|
|
|
571
571
|
if (import_typescript7.default.isClassDeclaration(node)) {
|
|
572
572
|
const decorators = getAngularDecorators(typeChecker, import_typescript7.default.getDecorators(node) || []);
|
|
573
573
|
decorators.forEach((decorator) => {
|
|
574
|
-
migrateDecorator(decorator, commonHttpIdentifiers, addedImports, changeTracker);
|
|
574
|
+
migrateDecorator(decorator, commonHttpIdentifiers, commonHttpTestingIdentifiers, addedImports, changeTracker);
|
|
575
575
|
});
|
|
576
576
|
}
|
|
577
|
-
migrateTestingModuleImports(node, commonHttpTestingIdentifiers, addedImports, changeTracker);
|
|
577
|
+
migrateTestingModuleImports(node, commonHttpIdentifiers, commonHttpTestingIdentifiers, addedImports, changeTracker);
|
|
578
578
|
});
|
|
579
579
|
const commonHttpImports = getNamedImports(sourceFile, COMMON_HTTP);
|
|
580
580
|
if (commonHttpImports) {
|
|
@@ -586,6 +586,10 @@ function migrateFile(sourceFile, typeChecker, rewriteFn) {
|
|
|
586
586
|
})
|
|
587
587
|
]);
|
|
588
588
|
changeTracker.replaceNode(commonHttpImports, newImports);
|
|
589
|
+
} else if ((_b = addedImports.get(COMMON_HTTP)) == null ? void 0 : _b.size) {
|
|
590
|
+
(_c = addedImports.get(COMMON_HTTP)) == null ? void 0 : _c.forEach((entry) => {
|
|
591
|
+
changeTracker.addImport(sourceFile, entry, COMMON_HTTP);
|
|
592
|
+
});
|
|
589
593
|
}
|
|
590
594
|
const commonHttpTestingImports = getNamedImports(sourceFile, COMMON_HTTP_TESTING);
|
|
591
595
|
if (commonHttpTestingImports) {
|
|
@@ -594,7 +598,7 @@ function migrateFile(sourceFile, typeChecker, rewriteFn) {
|
|
|
594
598
|
]);
|
|
595
599
|
const newHttpTestingImports = import_typescript7.default.factory.updateNamedImports(commonHttpTestingImports, [
|
|
596
600
|
...commonHttpTestingImports.elements.filter((current) => !symbolImportsToRemove.includes(current)),
|
|
597
|
-
...[...(
|
|
601
|
+
...[...(_d = addedImports.get(COMMON_HTTP_TESTING)) != null ? _d : []].map((entry) => {
|
|
598
602
|
return import_typescript7.default.factory.createImportSpecifier(false, void 0, import_typescript7.default.factory.createIdentifier(entry));
|
|
599
603
|
})
|
|
600
604
|
]);
|
|
@@ -602,12 +606,12 @@ function migrateFile(sourceFile, typeChecker, rewriteFn) {
|
|
|
602
606
|
}
|
|
603
607
|
for (const changesInFile of changeTracker.recordChanges().values()) {
|
|
604
608
|
for (const change of changesInFile) {
|
|
605
|
-
rewriteFn(change.start, (
|
|
609
|
+
rewriteFn(change.start, (_e = change.removeLength) != null ? _e : 0, change.text);
|
|
606
610
|
}
|
|
607
611
|
}
|
|
608
612
|
}
|
|
609
|
-
function migrateDecorator(decorator, commonHttpIdentifiers, addedImports, changeTracker) {
|
|
610
|
-
var _a
|
|
613
|
+
function migrateDecorator(decorator, commonHttpIdentifiers, commonHttpTestingIdentifiers, addedImports, changeTracker) {
|
|
614
|
+
var _a;
|
|
611
615
|
if (decorator.name !== "NgModule" && decorator.name !== "Component" || decorator.node.expression.arguments.length < 1) {
|
|
612
616
|
return;
|
|
613
617
|
}
|
|
@@ -619,51 +623,59 @@ function migrateDecorator(decorator, commonHttpIdentifiers, addedImports, change
|
|
|
619
623
|
if (!moduleImports) {
|
|
620
624
|
return;
|
|
621
625
|
}
|
|
622
|
-
const importedModules = getImportedHttpModules(moduleImports, commonHttpIdentifiers);
|
|
626
|
+
const importedModules = getImportedHttpModules(moduleImports, commonHttpIdentifiers, commonHttpTestingIdentifiers);
|
|
623
627
|
if (!importedModules) {
|
|
624
628
|
return;
|
|
625
629
|
}
|
|
626
630
|
const addedProviders = /* @__PURE__ */ new Set();
|
|
627
|
-
|
|
628
|
-
|
|
631
|
+
const commonHttpAddedImports = addedImports.get(COMMON_HTTP);
|
|
632
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(PROVIDE_HTTP_CLIENT);
|
|
633
|
+
if (importedModules.client || importedModules.clientTesting) {
|
|
634
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_INTERCEPTORS_FROM_DI);
|
|
629
635
|
addedProviders.add(createCallExpression(WITH_INTERCEPTORS_FROM_DI));
|
|
630
636
|
}
|
|
631
637
|
if (importedModules.clientJsonp) {
|
|
632
|
-
|
|
638
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_JSONP_SUPPORT);
|
|
633
639
|
addedProviders.add(createCallExpression(WITH_JSONP_SUPPORT));
|
|
634
640
|
}
|
|
635
641
|
if (importedModules.xsrf) {
|
|
636
642
|
if (importedModules.xsrfOptions === "disable") {
|
|
637
|
-
|
|
643
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_NOXSRF_PROTECTION);
|
|
638
644
|
addedProviders.add(createCallExpression(WITH_NOXSRF_PROTECTION));
|
|
639
645
|
} else {
|
|
640
|
-
|
|
641
|
-
addedProviders.add(createCallExpression(WITH_XSRF_CONFIGURATION, ((
|
|
646
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_XSRF_CONFIGURATION);
|
|
647
|
+
addedProviders.add(createCallExpression(WITH_XSRF_CONFIGURATION, ((_a = importedModules.xsrfOptions) == null ? void 0 : _a.options) ? [importedModules.xsrfOptions.options] : []));
|
|
642
648
|
}
|
|
643
649
|
}
|
|
644
650
|
const newImports = import_typescript7.default.factory.createArrayLiteralExpression([
|
|
645
|
-
...moduleImports.elements.filter((item) => item !== importedModules.client && item !== importedModules.clientJsonp && item !== importedModules.xsrf)
|
|
651
|
+
...moduleImports.elements.filter((item) => item !== importedModules.client && item !== importedModules.clientJsonp && item !== importedModules.xsrf && item !== importedModules.clientTesting)
|
|
646
652
|
]);
|
|
647
|
-
(_f = addedImports.get(COMMON_HTTP)) == null ? void 0 : _f.add(PROVIDE_HTTP_CLIENT);
|
|
648
653
|
const providers = getProvidersFromLiteralExpr(metadata);
|
|
654
|
+
let provideHttpClientTestingExpr;
|
|
655
|
+
if (importedModules.clientTesting) {
|
|
656
|
+
const commonHttpTestingAddedImports = addedImports.get(COMMON_HTTP_TESTING);
|
|
657
|
+
commonHttpTestingAddedImports == null ? void 0 : commonHttpTestingAddedImports.add(PROVIDE_HTTP_CLIENT_TESTING);
|
|
658
|
+
provideHttpClientTestingExpr = createCallExpression(PROVIDE_HTTP_CLIENT_TESTING);
|
|
659
|
+
}
|
|
649
660
|
const provideHttpExpr = createCallExpression(PROVIDE_HTTP_CLIENT, [...addedProviders]);
|
|
661
|
+
const providersToAppend = provideHttpClientTestingExpr ? [provideHttpExpr, provideHttpClientTestingExpr] : [provideHttpExpr];
|
|
650
662
|
let newProviders;
|
|
651
663
|
if (!providers) {
|
|
652
|
-
newProviders = import_typescript7.default.factory.createArrayLiteralExpression(
|
|
664
|
+
newProviders = import_typescript7.default.factory.createArrayLiteralExpression(providersToAppend);
|
|
653
665
|
} else {
|
|
654
|
-
newProviders = import_typescript7.default.factory.
|
|
655
|
-
...providers.elements,
|
|
656
|
-
provideHttpExpr
|
|
657
|
-
]);
|
|
666
|
+
newProviders = import_typescript7.default.factory.updateArrayLiteralExpression(providers, import_typescript7.default.factory.createNodeArray([...providers.elements, ...providersToAppend], providers.elements.hasTrailingComma));
|
|
658
667
|
}
|
|
659
668
|
const newDecoratorArgs = import_typescript7.default.factory.createObjectLiteralExpression([
|
|
660
|
-
...metadata.properties.filter((
|
|
669
|
+
...metadata.properties.filter((property) => {
|
|
670
|
+
var _a2, _b;
|
|
671
|
+
return ((_a2 = property.name) == null ? void 0 : _a2.getText()) !== "imports" && ((_b = property.name) == null ? void 0 : _b.getText()) !== "providers";
|
|
672
|
+
}),
|
|
661
673
|
import_typescript7.default.factory.createPropertyAssignment("imports", newImports),
|
|
662
674
|
import_typescript7.default.factory.createPropertyAssignment("providers", newProviders)
|
|
663
675
|
]);
|
|
664
676
|
changeTracker.replaceNode(metadata, newDecoratorArgs);
|
|
665
677
|
}
|
|
666
|
-
function migrateTestingModuleImports(node, commonHttpTestingIdentifiers, addedImports, changeTracker) {
|
|
678
|
+
function migrateTestingModuleImports(node, commonHttpIdentifiers, commonHttpTestingIdentifiers, addedImports, changeTracker) {
|
|
667
679
|
var _a;
|
|
668
680
|
if (!import_typescript7.default.isCallExpression(node) || node.arguments.length < 1 || !import_typescript7.default.isPropertyAccessExpression(node.expression) || !import_typescript7.default.isIdentifier(node.expression.expression) || node.expression.expression.text !== "TestBed" || node.expression.name.text !== "configureTestingModule") {
|
|
669
681
|
return;
|
|
@@ -676,38 +688,52 @@ function migrateTestingModuleImports(node, commonHttpTestingIdentifiers, addedIm
|
|
|
676
688
|
if (!importsArray) {
|
|
677
689
|
return;
|
|
678
690
|
}
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
|
|
691
|
+
const commonHttpAddedImports = addedImports.get(COMMON_HTTP);
|
|
692
|
+
const httpClient = importsArray.elements.find((elt) => elt.getText() === HTTP_CLIENT_MODULE);
|
|
693
|
+
if (httpClient && commonHttpIdentifiers.has(HTTP_CLIENT_MODULE)) {
|
|
694
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(PROVIDE_HTTP_CLIENT);
|
|
695
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_INTERCEPTORS_FROM_DI);
|
|
696
|
+
const newImports = import_typescript7.default.factory.createArrayLiteralExpression([
|
|
697
|
+
...importsArray.elements.filter((item) => item !== httpClient)
|
|
698
|
+
]);
|
|
699
|
+
const provideHttpClient = createCallExpression(PROVIDE_HTTP_CLIENT, [
|
|
700
|
+
createCallExpression(WITH_INTERCEPTORS_FROM_DI)
|
|
701
|
+
]);
|
|
702
|
+
const providers = getProvidersFromLiteralExpr(configureTestingModuleArgs);
|
|
703
|
+
let newProviders;
|
|
704
|
+
if (!providers) {
|
|
705
|
+
newProviders = import_typescript7.default.factory.createArrayLiteralExpression([provideHttpClient]);
|
|
706
|
+
} else {
|
|
707
|
+
newProviders = import_typescript7.default.factory.updateArrayLiteralExpression(providers, import_typescript7.default.factory.createNodeArray([...providers.elements, provideHttpClient], providers.elements.hasTrailingComma));
|
|
708
|
+
}
|
|
709
|
+
const newTestingModuleArgs = updateTestBedConfiguration(configureTestingModuleArgs, newImports, newProviders);
|
|
710
|
+
changeTracker.replaceNode(configureTestingModuleArgs, newTestingModuleArgs);
|
|
682
711
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
const provideHttpClientTesting = createCallExpression(PROVIDE_HTTP_CLIENT_TESTING);
|
|
691
|
-
const providers = getProvidersFromLiteralExpr(configureTestingModuleArgs);
|
|
692
|
-
let newProviders;
|
|
693
|
-
if (!providers) {
|
|
694
|
-
newProviders = import_typescript7.default.factory.createArrayLiteralExpression([
|
|
695
|
-
provideHttpClient,
|
|
696
|
-
provideHttpClientTesting
|
|
712
|
+
const httpClientTesting = importsArray.elements.find((elt) => elt.getText() === HTTP_CLIENT_TESTING_MODULE);
|
|
713
|
+
if (httpClientTesting && commonHttpTestingIdentifiers.has(HTTP_CLIENT_TESTING_MODULE)) {
|
|
714
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(PROVIDE_HTTP_CLIENT);
|
|
715
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_INTERCEPTORS_FROM_DI);
|
|
716
|
+
(_a = addedImports.get(COMMON_HTTP_TESTING)) == null ? void 0 : _a.add(PROVIDE_HTTP_CLIENT_TESTING);
|
|
717
|
+
const newImports = import_typescript7.default.factory.createArrayLiteralExpression([
|
|
718
|
+
...importsArray.elements.filter((item) => item !== httpClientTesting)
|
|
697
719
|
]);
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
...providers.elements,
|
|
701
|
-
provideHttpClient,
|
|
702
|
-
provideHttpClientTesting
|
|
720
|
+
const provideHttpClient = createCallExpression(PROVIDE_HTTP_CLIENT, [
|
|
721
|
+
createCallExpression(WITH_INTERCEPTORS_FROM_DI)
|
|
703
722
|
]);
|
|
723
|
+
const provideHttpClientTesting = createCallExpression(PROVIDE_HTTP_CLIENT_TESTING);
|
|
724
|
+
const providers = getProvidersFromLiteralExpr(configureTestingModuleArgs);
|
|
725
|
+
let newProviders;
|
|
726
|
+
if (!providers) {
|
|
727
|
+
newProviders = import_typescript7.default.factory.createArrayLiteralExpression([
|
|
728
|
+
provideHttpClient,
|
|
729
|
+
provideHttpClientTesting
|
|
730
|
+
]);
|
|
731
|
+
} else {
|
|
732
|
+
newProviders = import_typescript7.default.factory.updateArrayLiteralExpression(providers, import_typescript7.default.factory.createNodeArray([...providers.elements, provideHttpClient, provideHttpClientTesting], providers.elements.hasTrailingComma));
|
|
733
|
+
}
|
|
734
|
+
const newTestingModuleArgs = updateTestBedConfiguration(configureTestingModuleArgs, newImports, newProviders);
|
|
735
|
+
changeTracker.replaceNode(configureTestingModuleArgs, newTestingModuleArgs);
|
|
704
736
|
}
|
|
705
|
-
const newTestingModuleArgs = import_typescript7.default.factory.createObjectLiteralExpression([
|
|
706
|
-
...configureTestingModuleArgs.properties.filter((p) => p.getText() === "imports"),
|
|
707
|
-
import_typescript7.default.factory.createPropertyAssignment("imports", newImports),
|
|
708
|
-
import_typescript7.default.factory.createPropertyAssignment("providers", newProviders)
|
|
709
|
-
]);
|
|
710
|
-
changeTracker.replaceNode(configureTestingModuleArgs, newTestingModuleArgs);
|
|
711
737
|
}
|
|
712
738
|
function getImportsProp(literal) {
|
|
713
739
|
const properties = literal.properties;
|
|
@@ -737,15 +763,16 @@ function getProvidersFromLiteralExpr(literal) {
|
|
|
737
763
|
}
|
|
738
764
|
return null;
|
|
739
765
|
}
|
|
740
|
-
function getImportedHttpModules(imports, commonHttpIdentifiers) {
|
|
766
|
+
function getImportedHttpModules(imports, commonHttpIdentifiers, commonHttpTestingIdentifiers) {
|
|
741
767
|
let client = null;
|
|
742
768
|
let clientJsonp = null;
|
|
743
769
|
let xsrf = null;
|
|
770
|
+
let clientTesting = null;
|
|
744
771
|
let xsrfOptions = null;
|
|
745
772
|
for (const item of imports.elements) {
|
|
746
773
|
if (import_typescript7.default.isIdentifier(item)) {
|
|
747
774
|
const moduleName = item.getText();
|
|
748
|
-
if (!commonHttpIdentifiers.has(moduleName)) {
|
|
775
|
+
if (!commonHttpIdentifiers.has(moduleName) && !commonHttpTestingIdentifiers.has(moduleName)) {
|
|
749
776
|
continue;
|
|
750
777
|
}
|
|
751
778
|
if (moduleName === HTTP_CLIENT_MODULE) {
|
|
@@ -754,6 +781,8 @@ function getImportedHttpModules(imports, commonHttpIdentifiers) {
|
|
|
754
781
|
clientJsonp = item;
|
|
755
782
|
} else if (moduleName === HTTP_CLIENT_XSRF_MODULE) {
|
|
756
783
|
xsrf = item;
|
|
784
|
+
} else if (moduleName === HTTP_CLIENT_TESTING_MODULE) {
|
|
785
|
+
clientTesting = item;
|
|
757
786
|
}
|
|
758
787
|
} else if (import_typescript7.default.isCallExpression(item) && import_typescript7.default.isPropertyAccessExpression(item.expression)) {
|
|
759
788
|
const moduleName = item.expression.expression.getText();
|
|
@@ -770,23 +799,33 @@ function getImportedHttpModules(imports, commonHttpIdentifiers) {
|
|
|
770
799
|
}
|
|
771
800
|
}
|
|
772
801
|
}
|
|
773
|
-
if (client !== null || clientJsonp !== null || xsrf !== null) {
|
|
774
|
-
return { client, clientJsonp, xsrf, xsrfOptions };
|
|
802
|
+
if (client !== null || clientJsonp !== null || xsrf !== null || clientTesting !== null) {
|
|
803
|
+
return { client, clientJsonp, xsrf, xsrfOptions, clientTesting };
|
|
775
804
|
}
|
|
776
805
|
return null;
|
|
777
806
|
}
|
|
778
807
|
function createCallExpression(functionName, args = []) {
|
|
779
808
|
return import_typescript7.default.factory.createCallExpression(import_typescript7.default.factory.createIdentifier(functionName), void 0, args);
|
|
780
809
|
}
|
|
810
|
+
function updateTestBedConfiguration(configureTestingModuleArgs, newImports, newProviders) {
|
|
811
|
+
return import_typescript7.default.factory.updateObjectLiteralExpression(configureTestingModuleArgs, [
|
|
812
|
+
...configureTestingModuleArgs.properties.filter((property) => {
|
|
813
|
+
var _a, _b;
|
|
814
|
+
return ((_a = property.name) == null ? void 0 : _a.getText()) !== "imports" && ((_b = property.name) == null ? void 0 : _b.getText()) !== "providers";
|
|
815
|
+
}),
|
|
816
|
+
import_typescript7.default.factory.createPropertyAssignment("imports", newImports),
|
|
817
|
+
import_typescript7.default.factory.createPropertyAssignment("providers", newProviders)
|
|
818
|
+
]);
|
|
819
|
+
}
|
|
781
820
|
|
|
782
|
-
// bazel-out/
|
|
821
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/core/schematics/migrations/http-providers/index.mjs
|
|
783
822
|
function http_providers_default() {
|
|
784
823
|
return (tree) => __async(this, null, function* () {
|
|
785
824
|
const { buildPaths, testPaths } = yield getProjectTsConfigPaths(tree);
|
|
786
825
|
const basePath = process.cwd();
|
|
787
826
|
const allPaths = [...buildPaths, ...testPaths];
|
|
788
827
|
if (!allPaths.length) {
|
|
789
|
-
throw new import_schematics.SchematicsException("Could not find any tsconfig file. Cannot run the
|
|
828
|
+
throw new import_schematics.SchematicsException("Could not find any tsconfig file. Cannot run the http providers migration.");
|
|
790
829
|
}
|
|
791
830
|
for (const tsconfigPath of allPaths) {
|
|
792
831
|
runMigration(tree, tsconfigPath, basePath);
|