@angular/core 18.0.0-rc.0 → 18.0.0-rc.1
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/index.mjs +2 -2
- package/esm2022/primitives/event-dispatch/src/action_resolver.mjs +234 -0
- package/esm2022/primitives/event-dispatch/src/base_dispatcher.mjs +6 -8
- package/esm2022/primitives/event-dispatch/src/custom_events.mjs +40 -1
- package/esm2022/primitives/event-dispatch/src/dispatcher.mjs +22 -15
- package/esm2022/primitives/event-dispatch/src/earlyeventcontract.mjs +14 -8
- package/esm2022/primitives/event-dispatch/src/event_contract_defines.mjs +1 -14
- package/esm2022/primitives/event-dispatch/src/eventcontract.mjs +23 -344
- package/esm2022/primitives/event-dispatch/src/register_events.mjs +29 -10
- package/esm2022/src/application/application_ref.mjs +6 -3
- package/esm2022/src/application/create_application.mjs +3 -3
- package/esm2022/src/change_detection/scheduling/exhaustive_check_no_changes.mjs +150 -0
- package/esm2022/src/change_detection/scheduling/ng_zone_scheduling.mjs +17 -3
- package/esm2022/src/change_detection/scheduling/zoneless_scheduling_impl.mjs +5 -5
- package/esm2022/src/core.mjs +2 -1
- package/esm2022/src/core_private_export.mjs +2 -1
- 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 +23 -3
- package/esm2022/src/platform/platform_ref.mjs +8 -1
- package/esm2022/src/render3/after_render_hooks.mjs +4 -2
- package/esm2022/src/render3/component_ref.mjs +1 -1
- package/esm2022/src/render3/instructions/change_detection.mjs +13 -10
- package/esm2022/src/render3/instructions/listener.mjs +12 -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 +1 -3
- package/esm2022/testing/src/defer.mjs +1 -2
- package/esm2022/testing/src/logger.mjs +3 -3
- package/esm2022/testing/src/test_bed_compiler.mjs +3 -4
- package/event-dispatch-contract.min.js +1 -1
- package/fesm2022/core.mjs +752 -574
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +315 -369
- 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 +3 -7
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +34 -4
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +41 -44
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/http-providers/bundle.js +66 -44
- package/schematics/migrations/http-providers/bundle.js.map +2 -2
- package/schematics/migrations/invalid-two-way-bindings/bundle.js +39 -9
- package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +2 -2
- package/schematics/ng-generate/control-flow-migration/bundle.js +39 -9
- package/schematics/ng-generate/control-flow-migration/bundle.js.map +2 -2
- package/schematics/ng-generate/standalone-migration/bundle.js +48 -18
- package/schematics/ng-generate/standalone-migration/bundle.js.map +2 -2
- package/testing/index.d.ts +1 -4
package/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v18.0.0-rc.
|
|
2
|
+
* @license Angular v18.0.0-rc.1
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
import { BehaviorSubject } from 'rxjs';
|
|
9
|
+
import { EnvironmentProviders as EnvironmentProviders_2 } from '@angular/core';
|
|
9
10
|
import { Observable } from 'rxjs';
|
|
10
11
|
import { ReactiveNode } from '@angular/core/primitives/signals';
|
|
11
12
|
import { SIGNAL } from '@angular/core/primitives/signals';
|
|
@@ -646,7 +647,6 @@ export declare class ApplicationRef {
|
|
|
646
647
|
private readonly zonelessEnabled;
|
|
647
648
|
private externalTestViews;
|
|
648
649
|
private beforeRender;
|
|
649
|
-
private get allViews();
|
|
650
650
|
/**
|
|
651
651
|
* Indicates whether this instance was destroyed.
|
|
652
652
|
*/
|
|
@@ -8169,6 +8169,32 @@ declare type ProcessProvidersFunction = (providers: Provider[]) => Provider[];
|
|
|
8169
8169
|
*/
|
|
8170
8170
|
declare type ProjectionSlots = (ɵCssSelectorList | '*')[];
|
|
8171
8171
|
|
|
8172
|
+
/**
|
|
8173
|
+
* Used to periodically verify no expressions have changed after they were checked.
|
|
8174
|
+
*
|
|
8175
|
+
* @param options Used to configure when the check will execute.
|
|
8176
|
+
* - `interval` will periodically run exhaustive `checkNoChanges` on application views
|
|
8177
|
+
* - `useNgZoneOnStable` will us ZoneJS to determine when change detection might have run
|
|
8178
|
+
* in an application using ZoneJS to drive change detection. When the `NgZone.onStable` would
|
|
8179
|
+
* have emit, all views attached to the `ApplicationRef` are checked for changes.
|
|
8180
|
+
* - 'exhaustive' means that all views attached to `ApplicationRef` and all the descendants of those views will be
|
|
8181
|
+
* checked for changes (excluding those subtrees which are detached via `ChangeDetectorRef.detach()`).
|
|
8182
|
+
* This is useful because the check that runs after regular change detection does not work for components using `ChangeDetectionStrategy.OnPush`.
|
|
8183
|
+
* This check is will surface any existing errors hidden by `OnPush` components. By default, this check is exhaustive
|
|
8184
|
+
* and will always check all views, regardless of their "dirty" state and `ChangeDetectionStrategy`.
|
|
8185
|
+
*
|
|
8186
|
+
* When the `useNgZoneOnStable` option is `true`, this function will provide its own `NgZone` implementation and needs
|
|
8187
|
+
* to come after any other `NgZone` provider, including `provideZoneChangeDetection()` and `provideExperimentalZonelessChangeDetection()`.
|
|
8188
|
+
*
|
|
8189
|
+
* @experimental
|
|
8190
|
+
* @publicApi
|
|
8191
|
+
*/
|
|
8192
|
+
export declare function provideExperimentalCheckNoChangesForDebug(options: {
|
|
8193
|
+
interval?: number;
|
|
8194
|
+
useNgZoneOnStable?: boolean;
|
|
8195
|
+
exhaustive?: boolean;
|
|
8196
|
+
}): EnvironmentProviders_2;
|
|
8197
|
+
|
|
8172
8198
|
/**
|
|
8173
8199
|
* Provides change detection without ZoneJS for the application bootstrapped using
|
|
8174
8200
|
* `bootstrapApplication`.
|
|
@@ -12288,7 +12314,6 @@ export declare const ɵDEFER_BLOCK_DEPENDENCY_INTERCEPTOR: InjectionToken<ɵDefe
|
|
|
12288
12314
|
/**
|
|
12289
12315
|
* Options for configuring defer blocks behavior.
|
|
12290
12316
|
* @publicApi
|
|
12291
|
-
* @developerPreview
|
|
12292
12317
|
*/
|
|
12293
12318
|
export declare enum ɵDeferBlockBehavior {
|
|
12294
12319
|
/**
|
|
@@ -12343,7 +12368,6 @@ export declare interface ɵDeferBlockDetails {
|
|
|
12343
12368
|
* Describes the current state of this defer block instance.
|
|
12344
12369
|
*
|
|
12345
12370
|
* @publicApi
|
|
12346
|
-
* @developerPreview
|
|
12347
12371
|
*/
|
|
12348
12372
|
export declare enum ɵDeferBlockState {
|
|
12349
12373
|
/** The placeholder block content is rendered */
|
|
@@ -12828,6 +12852,11 @@ export declare interface ɵInternalEnvironmentProviders extends EnvironmentProvi
|
|
|
12828
12852
|
ɵfromNgModule?: true;
|
|
12829
12853
|
}
|
|
12830
12854
|
|
|
12855
|
+
export declare function ɵinternalProvideZoneChangeDetection({ ngZoneFactory, ignoreChangesOutsideZone, }: {
|
|
12856
|
+
ngZoneFactory?: () => NgZone;
|
|
12857
|
+
ignoreChangesOutsideZone?: boolean;
|
|
12858
|
+
}): StaticProvider[];
|
|
12859
|
+
|
|
12831
12860
|
/**
|
|
12832
12861
|
* Internal token that specifies whether DOM reuse logic
|
|
12833
12862
|
* during hydration is enabled.
|
|
@@ -13504,6 +13533,7 @@ export declare const enum ɵRuntimeErrorCode {
|
|
|
13504
13533
|
ASYNC_INITIALIZERS_STILL_RUNNING = 405,
|
|
13505
13534
|
APPLICATION_REF_ALREADY_DESTROYED = 406,
|
|
13506
13535
|
RENDERER_NOT_FOUND = 407,
|
|
13536
|
+
PROVIDED_BOTH_ZONE_AND_ZONELESS = 408,
|
|
13507
13537
|
HYDRATION_NODE_MISMATCH = -500,
|
|
13508
13538
|
HYDRATION_MISSING_SIBLINGS = -501,
|
|
13509
13539
|
HYDRATION_MISSING_NODE = -502,
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v18.0.0-rc.
|
|
2
|
+
* @license Angular v18.0.0-rc.1
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -26,16 +26,28 @@ declare type ActionInfoInternal = [name: string, element: Element];
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Provides a factory function for bootstrapping an event contract on a
|
|
29
|
-
*
|
|
30
|
-
* @param field The property on the
|
|
29
|
+
* specified object (by default, exposed on the `window`).
|
|
30
|
+
* @param field The property on the object that the event contract will be placed on.
|
|
31
|
+
* @param container The container that listens to events
|
|
32
|
+
* @param appId A given identifier for an application. If there are multiple apps on the page
|
|
33
|
+
* then this is how contracts can be initialized for each one.
|
|
34
|
+
* @param eventTypes An array of event names that should be listened to.
|
|
35
|
+
* @param captureEventTypes An array of event names that should be listened to with capture.
|
|
36
|
+
* @param earlyJsactionTracker The object that should receive the event contract.
|
|
37
|
+
*/
|
|
38
|
+
export declare function bootstrapEarlyEventContract(field: string, container: HTMLElement, appId: string, eventTypes: string[], captureEventTypes: string[], earlyJsactionTracker?: EventContractTracker<EarlyJsactionDataContainer>): void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Provides a factory function for bootstrapping an event contract on a
|
|
42
|
+
* specified object (by default, exposed on the `window`).
|
|
43
|
+
* @param field The property on the object that the event contract will be placed on.
|
|
31
44
|
* @param container The container that listens to events
|
|
32
45
|
* @param appId A given identifier for an application. If there are multiple apps on the page
|
|
33
46
|
* then this is how contracts can be initialized for each one.
|
|
34
47
|
* @param events An array of event names that should be listened to.
|
|
35
|
-
* @param
|
|
36
|
-
* @returns The `event` contract. This is both assigned to `anyWindow` and returned for testing.
|
|
48
|
+
* @param earlyJsactionTracker The object that should receive the event contract.
|
|
37
49
|
*/
|
|
38
|
-
export declare function bootstrapEventContract(field: string, container: Element, appId: string, events: string[],
|
|
50
|
+
export declare function bootstrapEventContract(field: string, container: Element, appId: string, events: string[], earlyJsactionTracker?: EventContractTracker<EventContract>): void;
|
|
39
51
|
|
|
40
52
|
/** Clones an `EventInfo` */
|
|
41
53
|
declare function cloneEventInfo(eventInfo: EventInfo): EventInfo;
|
|
@@ -116,8 +128,6 @@ export declare class Dispatcher {
|
|
|
116
128
|
*
|
|
117
129
|
* @param eventInfo The info for the event that triggered this call or the
|
|
118
130
|
* queue of events from EventContract.
|
|
119
|
-
* @param isGlobalDispatch If true, dispatches a global event instead of a
|
|
120
|
-
* regular jsaction handler.
|
|
121
131
|
*/
|
|
122
132
|
dispatch(eventInfo: EventInfo, isGlobalDispatch?: boolean): void;
|
|
123
133
|
/**
|
|
@@ -202,6 +212,21 @@ export declare class Dispatcher {
|
|
|
202
212
|
/** A function that is called to handle events captured by the EventContract. */
|
|
203
213
|
declare type Dispatcher_2 = (eventInfo: eventInfoLib.EventInfo, globalDispatch?: boolean) => void;
|
|
204
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Defines the early jsaction data types.
|
|
217
|
+
*/
|
|
218
|
+
declare interface EarlyJsactionData {
|
|
219
|
+
et: string[];
|
|
220
|
+
etc: string[];
|
|
221
|
+
q: EventInfo[];
|
|
222
|
+
h: (event: Event) => void;
|
|
223
|
+
c: HTMLElement;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare interface EarlyJsactionDataContainer {
|
|
227
|
+
_ejsa?: EarlyJsactionData;
|
|
228
|
+
}
|
|
229
|
+
|
|
205
230
|
/**
|
|
206
231
|
* EventContract intercepts events in the bubbling phase at the
|
|
207
232
|
* boundary of a container element, and maps them to generic actions
|
|
@@ -218,11 +243,10 @@ declare type Dispatcher_2 = (eventInfo: eventInfoLib.EventInfo, globalDispatch?:
|
|
|
218
243
|
*/
|
|
219
244
|
export declare class EventContract implements UnrenamedEventContract {
|
|
220
245
|
static CUSTOM_EVENT_SUPPORT: boolean;
|
|
221
|
-
static STOP_PROPAGATION: boolean;
|
|
222
246
|
static A11Y_CLICK_SUPPORT: boolean;
|
|
223
247
|
static MOUSE_SPECIAL_SUPPORT: boolean;
|
|
224
|
-
static JSNAMESPACE_SUPPORT: boolean;
|
|
225
248
|
private containerManager;
|
|
249
|
+
private readonly actionResolver;
|
|
226
250
|
/**
|
|
227
251
|
* The DOM events which this contract covers. Used to prevent double
|
|
228
252
|
* registration of event types. The value of the map is the
|
|
@@ -245,13 +269,8 @@ export declare class EventContract implements UnrenamedEventContract {
|
|
|
245
269
|
* as soon as the `Dispatcher` is registered.
|
|
246
270
|
*/
|
|
247
271
|
private queuedEventInfos;
|
|
248
|
-
/** Whether a11y click support has been loaded or not. */
|
|
249
|
-
private hasA11yClickSupport;
|
|
250
272
|
/** Whether to add an a11y click listener. */
|
|
251
273
|
private addA11yClickListener;
|
|
252
|
-
private updateEventInfoForA11yClick?;
|
|
253
|
-
private preventDefaultForA11yClick?;
|
|
254
|
-
private populateClickOnlyAction?;
|
|
255
274
|
ecaacs?: (updateEventInfoForA11yClick: typeof a11yClickLib.updateEventInfoForA11yClick, preventDefaultForA11yClick: typeof a11yClickLib.preventDefaultForA11yClick, populateClickOnlyAction: typeof a11yClickLib.populateClickOnlyAction) => void;
|
|
256
275
|
constructor(containerManager: EventContractContainerManager);
|
|
257
276
|
private handleEvent;
|
|
@@ -259,34 +278,6 @@ export declare class EventContract implements UnrenamedEventContract {
|
|
|
259
278
|
* Handle an `EventInfo`.
|
|
260
279
|
*/
|
|
261
280
|
private handleEventInfo;
|
|
262
|
-
/**
|
|
263
|
-
* Searches for a jsaction that the DOM event maps to and creates an
|
|
264
|
-
* object containing event information used for dispatching by
|
|
265
|
-
* jsaction.Dispatcher. This method populates the `action` and `actionElement`
|
|
266
|
-
* fields of the EventInfo object passed in by finding the first
|
|
267
|
-
* jsaction attribute above the target Node of the event, and below
|
|
268
|
-
* the container Node, that specifies a jsaction for the event
|
|
269
|
-
* type. If no such jsaction is found, then action is undefined.
|
|
270
|
-
*
|
|
271
|
-
* @param eventInfo `EventInfo` to set `action` and `actionElement` if an
|
|
272
|
-
* action is found on any `Element` in the path of the `Event`.
|
|
273
|
-
*/
|
|
274
|
-
private populateAction;
|
|
275
|
-
/**
|
|
276
|
-
* Accesses the jsaction map on a node and retrieves the name of the
|
|
277
|
-
* action the given event is mapped to, if any. It parses the
|
|
278
|
-
* attribute value and stores it in a property on the node for
|
|
279
|
-
* subsequent retrieval without re-parsing and re-accessing the
|
|
280
|
-
* attribute. In order to fully qualify jsaction names using a
|
|
281
|
-
* namespace, the DOM is searched starting at the current node and
|
|
282
|
-
* going through ancestor nodes until a jsnamespace attribute is
|
|
283
|
-
* found.
|
|
284
|
-
*
|
|
285
|
-
* @param actionElement The DOM node to retrieve the jsaction map from.
|
|
286
|
-
* @param eventInfo `EventInfo` to set `action` and `actionElement` if an
|
|
287
|
-
* action is found on the `actionElement`.
|
|
288
|
-
*/
|
|
289
|
-
private populateActionOnElement;
|
|
290
281
|
/**
|
|
291
282
|
* Enables jsaction handlers to be called for the event type given by
|
|
292
283
|
* name.
|
|
@@ -306,7 +297,7 @@ export declare class EventContract implements UnrenamedEventContract {
|
|
|
306
297
|
* in the provided event contract. Once all the events are replayed, it cleans
|
|
307
298
|
* up the early contract.
|
|
308
299
|
*/
|
|
309
|
-
replayEarlyEvents(): void;
|
|
300
|
+
replayEarlyEvents(earlyJsactionContainer?: EarlyJsactionDataContainer): void;
|
|
310
301
|
/**
|
|
311
302
|
* Returns all JSAction event types that have been registered for a given
|
|
312
303
|
* browser event type.
|
|
@@ -393,6 +384,12 @@ declare interface EventContractContainerManager {
|
|
|
393
384
|
cleanUp(): void;
|
|
394
385
|
}
|
|
395
386
|
|
|
387
|
+
export declare type EventContractTracker<T> = {
|
|
388
|
+
[key: string]: {
|
|
389
|
+
[appId: string]: T;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
|
|
396
393
|
/**
|
|
397
394
|
* A function that handles an event dispatched from the browser.
|
|
398
395
|
*
|
package/rxjs-interop/index.d.ts
CHANGED
|
@@ -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()],
|
|
@@ -574,7 +574,7 @@ function migrateFile(sourceFile, typeChecker, rewriteFn) {
|
|
|
574
574
|
migrateDecorator(decorator, commonHttpIdentifiers, 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
613
|
function migrateDecorator(decorator, commonHttpIdentifiers, addedImports, changeTracker) {
|
|
610
|
-
var _a
|
|
614
|
+
var _a;
|
|
611
615
|
if (decorator.name !== "NgModule" && decorator.name !== "Component" || decorator.node.expression.arguments.length < 1) {
|
|
612
616
|
return;
|
|
613
617
|
}
|
|
@@ -624,37 +628,35 @@ function migrateDecorator(decorator, commonHttpIdentifiers, addedImports, change
|
|
|
624
628
|
return;
|
|
625
629
|
}
|
|
626
630
|
const addedProviders = /* @__PURE__ */ new Set();
|
|
631
|
+
const commonHttpAddedImports = addedImports.get(COMMON_HTTP);
|
|
627
632
|
if (importedModules.client) {
|
|
628
|
-
|
|
633
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_INTERCEPTORS_FROM_DI);
|
|
629
634
|
addedProviders.add(createCallExpression(WITH_INTERCEPTORS_FROM_DI));
|
|
630
635
|
}
|
|
631
636
|
if (importedModules.clientJsonp) {
|
|
632
|
-
|
|
637
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_JSONP_SUPPORT);
|
|
633
638
|
addedProviders.add(createCallExpression(WITH_JSONP_SUPPORT));
|
|
634
639
|
}
|
|
635
640
|
if (importedModules.xsrf) {
|
|
636
641
|
if (importedModules.xsrfOptions === "disable") {
|
|
637
|
-
|
|
642
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_NOXSRF_PROTECTION);
|
|
638
643
|
addedProviders.add(createCallExpression(WITH_NOXSRF_PROTECTION));
|
|
639
644
|
} else {
|
|
640
|
-
|
|
641
|
-
addedProviders.add(createCallExpression(WITH_XSRF_CONFIGURATION, ((
|
|
645
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_XSRF_CONFIGURATION);
|
|
646
|
+
addedProviders.add(createCallExpression(WITH_XSRF_CONFIGURATION, ((_a = importedModules.xsrfOptions) == null ? void 0 : _a.options) ? [importedModules.xsrfOptions.options] : []));
|
|
642
647
|
}
|
|
643
648
|
}
|
|
644
649
|
const newImports = import_typescript7.default.factory.createArrayLiteralExpression([
|
|
645
650
|
...moduleImports.elements.filter((item) => item !== importedModules.client && item !== importedModules.clientJsonp && item !== importedModules.xsrf)
|
|
646
651
|
]);
|
|
647
|
-
|
|
652
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(PROVIDE_HTTP_CLIENT);
|
|
648
653
|
const providers = getProvidersFromLiteralExpr(metadata);
|
|
649
654
|
const provideHttpExpr = createCallExpression(PROVIDE_HTTP_CLIENT, [...addedProviders]);
|
|
650
655
|
let newProviders;
|
|
651
656
|
if (!providers) {
|
|
652
657
|
newProviders = import_typescript7.default.factory.createArrayLiteralExpression([provideHttpExpr]);
|
|
653
658
|
} else {
|
|
654
|
-
newProviders = import_typescript7.default.factory.
|
|
655
|
-
...providers.elements,
|
|
656
|
-
provideHttpExpr
|
|
657
|
-
]);
|
|
659
|
+
newProviders = import_typescript7.default.factory.updateArrayLiteralExpression(providers, import_typescript7.default.factory.createNodeArray([...providers.elements, provideHttpExpr], providers.elements.hasTrailingComma));
|
|
658
660
|
}
|
|
659
661
|
const newDecoratorArgs = import_typescript7.default.factory.createObjectLiteralExpression([
|
|
660
662
|
...metadata.properties.filter((p) => p.getText() === "imports"),
|
|
@@ -663,7 +665,7 @@ function migrateDecorator(decorator, commonHttpIdentifiers, addedImports, change
|
|
|
663
665
|
]);
|
|
664
666
|
changeTracker.replaceNode(metadata, newDecoratorArgs);
|
|
665
667
|
}
|
|
666
|
-
function migrateTestingModuleImports(node, commonHttpTestingIdentifiers, addedImports, changeTracker) {
|
|
668
|
+
function migrateTestingModuleImports(node, commonHttpIdentifiers, commonHttpTestingIdentifiers, addedImports, changeTracker) {
|
|
667
669
|
var _a;
|
|
668
670
|
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
671
|
return;
|
|
@@ -676,38 +678,52 @@ function migrateTestingModuleImports(node, commonHttpTestingIdentifiers, addedIm
|
|
|
676
678
|
if (!importsArray) {
|
|
677
679
|
return;
|
|
678
680
|
}
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
|
|
681
|
+
const commonHttpAddedImports = addedImports.get(COMMON_HTTP);
|
|
682
|
+
const httpClient = importsArray.elements.find((elt) => elt.getText() === HTTP_CLIENT_MODULE);
|
|
683
|
+
if (httpClient && commonHttpIdentifiers.has(HTTP_CLIENT_MODULE)) {
|
|
684
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(PROVIDE_HTTP_CLIENT);
|
|
685
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_INTERCEPTORS_FROM_DI);
|
|
686
|
+
const newImports = import_typescript7.default.factory.createArrayLiteralExpression([
|
|
687
|
+
...importsArray.elements.filter((item) => item !== httpClient)
|
|
688
|
+
]);
|
|
689
|
+
const provideHttpClient = createCallExpression(PROVIDE_HTTP_CLIENT, [
|
|
690
|
+
createCallExpression(WITH_INTERCEPTORS_FROM_DI)
|
|
691
|
+
]);
|
|
692
|
+
const providers = getProvidersFromLiteralExpr(configureTestingModuleArgs);
|
|
693
|
+
let newProviders;
|
|
694
|
+
if (!providers) {
|
|
695
|
+
newProviders = import_typescript7.default.factory.createArrayLiteralExpression([provideHttpClient]);
|
|
696
|
+
} else {
|
|
697
|
+
newProviders = import_typescript7.default.factory.updateArrayLiteralExpression(providers, import_typescript7.default.factory.createNodeArray([...providers.elements, provideHttpClient], providers.elements.hasTrailingComma));
|
|
698
|
+
}
|
|
699
|
+
const newTestingModuleArgs = updateTestBedConfiguration(configureTestingModuleArgs, newImports, newProviders);
|
|
700
|
+
changeTracker.replaceNode(configureTestingModuleArgs, newTestingModuleArgs);
|
|
682
701
|
}
|
|
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
|
|
702
|
+
const httpClientTesting = importsArray.elements.find((elt) => elt.getText() === HTTP_CLIENT_TESTING_MODULE);
|
|
703
|
+
if (httpClientTesting && commonHttpTestingIdentifiers.has(HTTP_CLIENT_TESTING_MODULE)) {
|
|
704
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(PROVIDE_HTTP_CLIENT);
|
|
705
|
+
commonHttpAddedImports == null ? void 0 : commonHttpAddedImports.add(WITH_INTERCEPTORS_FROM_DI);
|
|
706
|
+
(_a = addedImports.get(COMMON_HTTP_TESTING)) == null ? void 0 : _a.add(PROVIDE_HTTP_CLIENT_TESTING);
|
|
707
|
+
const newImports = import_typescript7.default.factory.createArrayLiteralExpression([
|
|
708
|
+
...importsArray.elements.filter((item) => item !== httpClientTesting)
|
|
697
709
|
]);
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
...providers.elements,
|
|
701
|
-
provideHttpClient,
|
|
702
|
-
provideHttpClientTesting
|
|
710
|
+
const provideHttpClient = createCallExpression(PROVIDE_HTTP_CLIENT, [
|
|
711
|
+
createCallExpression(WITH_INTERCEPTORS_FROM_DI)
|
|
703
712
|
]);
|
|
713
|
+
const provideHttpClientTesting = createCallExpression(PROVIDE_HTTP_CLIENT_TESTING);
|
|
714
|
+
const providers = getProvidersFromLiteralExpr(configureTestingModuleArgs);
|
|
715
|
+
let newProviders;
|
|
716
|
+
if (!providers) {
|
|
717
|
+
newProviders = import_typescript7.default.factory.createArrayLiteralExpression([
|
|
718
|
+
provideHttpClient,
|
|
719
|
+
provideHttpClientTesting
|
|
720
|
+
]);
|
|
721
|
+
} else {
|
|
722
|
+
newProviders = import_typescript7.default.factory.updateArrayLiteralExpression(providers, import_typescript7.default.factory.createNodeArray([...providers.elements, provideHttpClient, provideHttpClientTesting], providers.elements.hasTrailingComma));
|
|
723
|
+
}
|
|
724
|
+
const newTestingModuleArgs = updateTestBedConfiguration(configureTestingModuleArgs, newImports, newProviders);
|
|
725
|
+
changeTracker.replaceNode(configureTestingModuleArgs, newTestingModuleArgs);
|
|
704
726
|
}
|
|
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
727
|
}
|
|
712
728
|
function getImportsProp(literal) {
|
|
713
729
|
const properties = literal.properties;
|
|
@@ -778,6 +794,12 @@ function getImportedHttpModules(imports, commonHttpIdentifiers) {
|
|
|
778
794
|
function createCallExpression(functionName, args = []) {
|
|
779
795
|
return import_typescript7.default.factory.createCallExpression(import_typescript7.default.factory.createIdentifier(functionName), void 0, args);
|
|
780
796
|
}
|
|
797
|
+
function updateTestBedConfiguration(configureTestingModuleArgs, newImports, newProviders) {
|
|
798
|
+
return import_typescript7.default.factory.updateObjectLiteralExpression(configureTestingModuleArgs, [
|
|
799
|
+
import_typescript7.default.factory.createPropertyAssignment("imports", newImports),
|
|
800
|
+
import_typescript7.default.factory.createPropertyAssignment("providers", newProviders)
|
|
801
|
+
]);
|
|
802
|
+
}
|
|
781
803
|
|
|
782
804
|
// bazel-out/k8-fastbuild/bin/packages/core/schematics/migrations/http-providers/index.mjs
|
|
783
805
|
function http_providers_default() {
|