@angular/core 21.0.0-next.1 → 21.0.0-next.3
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/api.d.d.ts +1 -1
- package/chrome_dev_tools_performance.d.d.ts +1 -1
- package/discovery.d.d.ts +11 -36
- package/effect.d.d.ts +1 -1
- package/event_dispatcher.d.d.ts +1 -1
- package/fesm2022/attribute.mjs +1 -1
- package/fesm2022/attribute.mjs.map +1 -1
- package/fesm2022/core.mjs +46 -41
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/debug_node.mjs +29 -669
- package/fesm2022/debug_node.mjs.map +1 -1
- package/fesm2022/effect.mjs +1 -1
- package/fesm2022/effect.mjs.map +1 -1
- package/fesm2022/not_found.mjs +1 -1
- package/fesm2022/not_found.mjs.map +1 -1
- package/fesm2022/primitives/di.mjs +1 -1
- package/fesm2022/primitives/di.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -1
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/resource.mjs +1 -1
- package/fesm2022/resource.mjs.map +1 -1
- package/fesm2022/root_effect_scheduler.mjs +689 -81
- package/fesm2022/root_effect_scheduler.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +3 -3
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/signal.mjs +1 -1
- package/fesm2022/signal.mjs.map +1 -1
- package/fesm2022/testing.mjs +6 -8
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/weak_ref.mjs +1 -1
- package/fesm2022/weak_ref.mjs.map +1 -1
- package/graph.d.d.ts +1 -1
- package/index.d.ts +37 -54
- package/package.json +2 -2
- package/primitives/di/index.d.ts +1 -1
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/bundles/add-bootstrap-context-to-server-main.cjs +135 -0
- package/schematics/bundles/application-config-core.cjs +95 -0
- package/schematics/bundles/{apply_import_manager-yycO3l8f.cjs → apply_import_manager-tNexl58m.cjs} +3 -3
- package/schematics/bundles/cleanup-unused-imports.cjs +5 -5
- package/schematics/bundles/{compiler_host-DrXTGf_7.cjs → compiler_host-Df7s6Riz.cjs} +2 -2
- package/schematics/bundles/control-flow-migration.cjs +4 -4
- package/schematics/bundles/imports-26VeX8i-.cjs +1 -1
- package/schematics/bundles/{index-jjHOgYYs.cjs → index-CBaykQBv.cjs} +35 -14
- package/schematics/bundles/{index-BdH2rlWJ.cjs → index-Clvp4COX.cjs} +4 -4
- package/schematics/bundles/inject-migration.cjs +142 -47
- package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
- package/schematics/bundles/{migrate_ts_type_references-BVSg43hf.cjs → migrate_ts_type_references-C_gTvDtH.cjs} +5 -5
- package/schematics/bundles/{ng_component_template-DjLc4mdL.cjs → ng_component_template-HYGPuVhy.cjs} +2 -2
- package/schematics/bundles/ng_decorators-CtYwz9Lw.cjs +1 -1
- package/schematics/bundles/ngclass-to-class-migration.cjs +8 -8
- package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
- package/schematics/bundles/output-migration.cjs +6 -6
- package/schematics/bundles/{parse_html-CXR8hziE.cjs → parse_html-CLFKoiOK.cjs} +2 -2
- package/schematics/bundles/{project_paths-T_M15e2g.cjs → project_paths-BJTqcWvC.cjs} +3 -3
- package/schematics/bundles/{project_tsconfig_paths-D7xzGqRi.cjs → project_tsconfig_paths-bRwOJEk9.cjs} +13 -5
- package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
- package/schematics/bundles/route-lazy-loading.cjs +3 -3
- package/schematics/bundles/router-current-navigation.cjs +4 -4
- package/schematics/bundles/router-last-successful-navigation.cjs +4 -4
- package/schematics/bundles/self-closing-tags-migration.cjs +6 -6
- package/schematics/bundles/signal-input-migration.cjs +7 -7
- package/schematics/bundles/signal-queries-migration.cjs +7 -7
- package/schematics/bundles/signals.cjs +7 -7
- package/schematics/bundles/standalone-migration.cjs +4 -4
- package/schematics/bundles/symbol-VPWguRxr.cjs +1 -1
- package/schematics/migrations/ngclass-to-class-migration/schema.json +2 -2
- package/schematics/migrations.json +10 -0
- package/testing/index.d.ts +1 -1
- package/weak_ref.d.d.ts +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.0.0-next.
|
|
2
|
+
* @license Angular v21.0.0-next.3
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { getActiveConsumer, setActiveConsumer as setActiveConsumer$1, SIGNAL, createSignal } from './signal.mjs';
|
|
7
8
|
import { isNotFound, getCurrentInjector, setCurrentInjector } from './not_found.mjs';
|
|
8
|
-
import { getActiveConsumer, SIGNAL, createSignal } from './signal.mjs';
|
|
9
|
-
import { BehaviorSubject, Observable } from 'rxjs';
|
|
10
9
|
import { setActiveConsumer } from '@angular/core/primitives/signals';
|
|
11
10
|
import { isNotFound as isNotFound$1 } from '@angular/core/primitives/di';
|
|
11
|
+
import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Base URL for the error details page.
|
|
@@ -3551,6 +3551,679 @@ function injectDestroyRef() {
|
|
|
3551
3551
|
return new NodeInjectorDestroyRef(getLView());
|
|
3552
3552
|
}
|
|
3553
3553
|
|
|
3554
|
+
const SCHEDULE_IN_ROOT_ZONE_DEFAULT = false;
|
|
3555
|
+
|
|
3556
|
+
/**
|
|
3557
|
+
* Internal implementation of the pending tasks service.
|
|
3558
|
+
*/
|
|
3559
|
+
class PendingTasksInternal {
|
|
3560
|
+
taskId = 0;
|
|
3561
|
+
pendingTasks = new Set();
|
|
3562
|
+
destroyed = false;
|
|
3563
|
+
pendingTask = new BehaviorSubject(false);
|
|
3564
|
+
get hasPendingTasks() {
|
|
3565
|
+
// Accessing the value of a closed `BehaviorSubject` throws an error.
|
|
3566
|
+
return this.destroyed ? false : this.pendingTask.value;
|
|
3567
|
+
}
|
|
3568
|
+
/**
|
|
3569
|
+
* In case the service is about to be destroyed, return a self-completing observable.
|
|
3570
|
+
* Otherwise, return the observable that emits the current state of pending tasks.
|
|
3571
|
+
*/
|
|
3572
|
+
get hasPendingTasksObservable() {
|
|
3573
|
+
if (this.destroyed) {
|
|
3574
|
+
// Manually creating the observable pulls less symbols from RxJS than `of(false)`.
|
|
3575
|
+
return new Observable((subscriber) => {
|
|
3576
|
+
subscriber.next(false);
|
|
3577
|
+
subscriber.complete();
|
|
3578
|
+
});
|
|
3579
|
+
}
|
|
3580
|
+
return this.pendingTask;
|
|
3581
|
+
}
|
|
3582
|
+
add() {
|
|
3583
|
+
// Emitting a value to a closed subject throws an error.
|
|
3584
|
+
if (!this.hasPendingTasks && !this.destroyed) {
|
|
3585
|
+
this.pendingTask.next(true);
|
|
3586
|
+
}
|
|
3587
|
+
const taskId = this.taskId++;
|
|
3588
|
+
this.pendingTasks.add(taskId);
|
|
3589
|
+
return taskId;
|
|
3590
|
+
}
|
|
3591
|
+
has(taskId) {
|
|
3592
|
+
return this.pendingTasks.has(taskId);
|
|
3593
|
+
}
|
|
3594
|
+
remove(taskId) {
|
|
3595
|
+
this.pendingTasks.delete(taskId);
|
|
3596
|
+
if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
|
|
3597
|
+
this.pendingTask.next(false);
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
ngOnDestroy() {
|
|
3601
|
+
this.pendingTasks.clear();
|
|
3602
|
+
if (this.hasPendingTasks) {
|
|
3603
|
+
this.pendingTask.next(false);
|
|
3604
|
+
}
|
|
3605
|
+
// We call `unsubscribe()` to release observers, as users may forget to
|
|
3606
|
+
// unsubscribe manually when subscribing to `isStable`. We do not call
|
|
3607
|
+
// `complete()` because it is unsafe; if someone subscribes using the `first`
|
|
3608
|
+
// operator and the observable completes before emitting a value,
|
|
3609
|
+
// RxJS will throw an error.
|
|
3610
|
+
this.destroyed = true;
|
|
3611
|
+
this.pendingTask.unsubscribe();
|
|
3612
|
+
}
|
|
3613
|
+
/** @nocollapse */
|
|
3614
|
+
static ɵprov = /** @pureOrBreakMyCode */ /* @__PURE__ */ ɵɵdefineInjectable({
|
|
3615
|
+
token: PendingTasksInternal,
|
|
3616
|
+
providedIn: 'root',
|
|
3617
|
+
factory: () => new PendingTasksInternal(),
|
|
3618
|
+
});
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3621
|
+
class EventEmitter_ extends Subject {
|
|
3622
|
+
// tslint:disable-next-line:require-internal-with-underscore
|
|
3623
|
+
__isAsync;
|
|
3624
|
+
destroyRef = undefined;
|
|
3625
|
+
pendingTasks = undefined;
|
|
3626
|
+
constructor(isAsync = false) {
|
|
3627
|
+
super();
|
|
3628
|
+
this.__isAsync = isAsync;
|
|
3629
|
+
// Attempt to retrieve a `DestroyRef` and `PendingTasks` optionally.
|
|
3630
|
+
// For backwards compatibility reasons, this cannot be required.
|
|
3631
|
+
if (isInInjectionContext()) {
|
|
3632
|
+
// `DestroyRef` is optional because it is not available in all contexts.
|
|
3633
|
+
// But it is useful to properly complete the `EventEmitter` if used with `outputToObservable`
|
|
3634
|
+
// when the component/directive is destroyed. (See `outputToObservable` for more details.)
|
|
3635
|
+
this.destroyRef = inject(DestroyRef, { optional: true }) ?? undefined;
|
|
3636
|
+
this.pendingTasks = inject(PendingTasksInternal, { optional: true }) ?? undefined;
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
emit(value) {
|
|
3640
|
+
const prevConsumer = setActiveConsumer$1(null);
|
|
3641
|
+
try {
|
|
3642
|
+
super.next(value);
|
|
3643
|
+
}
|
|
3644
|
+
finally {
|
|
3645
|
+
setActiveConsumer$1(prevConsumer);
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
subscribe(observerOrNext, error, complete) {
|
|
3649
|
+
let nextFn = observerOrNext;
|
|
3650
|
+
let errorFn = error || (() => null);
|
|
3651
|
+
let completeFn = complete;
|
|
3652
|
+
if (observerOrNext && typeof observerOrNext === 'object') {
|
|
3653
|
+
const observer = observerOrNext;
|
|
3654
|
+
nextFn = observer.next?.bind(observer);
|
|
3655
|
+
errorFn = observer.error?.bind(observer);
|
|
3656
|
+
completeFn = observer.complete?.bind(observer);
|
|
3657
|
+
}
|
|
3658
|
+
if (this.__isAsync) {
|
|
3659
|
+
errorFn = this.wrapInTimeout(errorFn);
|
|
3660
|
+
if (nextFn) {
|
|
3661
|
+
nextFn = this.wrapInTimeout(nextFn);
|
|
3662
|
+
}
|
|
3663
|
+
if (completeFn) {
|
|
3664
|
+
completeFn = this.wrapInTimeout(completeFn);
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
const sink = super.subscribe({ next: nextFn, error: errorFn, complete: completeFn });
|
|
3668
|
+
if (observerOrNext instanceof Subscription) {
|
|
3669
|
+
observerOrNext.add(sink);
|
|
3670
|
+
}
|
|
3671
|
+
return sink;
|
|
3672
|
+
}
|
|
3673
|
+
wrapInTimeout(fn) {
|
|
3674
|
+
return (value) => {
|
|
3675
|
+
const taskId = this.pendingTasks?.add();
|
|
3676
|
+
setTimeout(() => {
|
|
3677
|
+
try {
|
|
3678
|
+
fn(value);
|
|
3679
|
+
}
|
|
3680
|
+
finally {
|
|
3681
|
+
if (taskId !== undefined) {
|
|
3682
|
+
this.pendingTasks?.remove(taskId);
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3686
|
+
};
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
/**
|
|
3690
|
+
* @publicApi
|
|
3691
|
+
*/
|
|
3692
|
+
const EventEmitter = EventEmitter_;
|
|
3693
|
+
|
|
3694
|
+
function noop(...args) {
|
|
3695
|
+
// Do nothing.
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
/**
|
|
3699
|
+
* Gets a scheduling function that runs the callback after the first of setTimeout and
|
|
3700
|
+
* requestAnimationFrame resolves.
|
|
3701
|
+
*
|
|
3702
|
+
* - `requestAnimationFrame` ensures that change detection runs ahead of a browser repaint.
|
|
3703
|
+
* This ensures that the create and update passes of a change detection always happen
|
|
3704
|
+
* in the same frame.
|
|
3705
|
+
* - When the browser is resource-starved, `rAF` can execute _before_ a `setTimeout` because
|
|
3706
|
+
* rendering is a very high priority process. This means that `setTimeout` cannot guarantee
|
|
3707
|
+
* same-frame create and update pass, when `setTimeout` is used to schedule the update phase.
|
|
3708
|
+
* - While `rAF` gives us the desirable same-frame updates, it has two limitations that
|
|
3709
|
+
* prevent it from being used alone. First, it does not run in background tabs, which would
|
|
3710
|
+
* prevent Angular from initializing an application when opened in a new tab (for example).
|
|
3711
|
+
* Second, repeated calls to requestAnimationFrame will execute at the refresh rate of the
|
|
3712
|
+
* hardware (~16ms for a 60Hz display). This would cause significant slowdown of tests that
|
|
3713
|
+
* are written with several updates and asserts in the form of "update; await stable; assert;".
|
|
3714
|
+
* - Both `setTimeout` and `rAF` are able to "coalesce" several events from a single user
|
|
3715
|
+
* interaction into a single change detection. Importantly, this reduces view tree traversals when
|
|
3716
|
+
* compared to an alternative timing mechanism like `queueMicrotask`, where change detection would
|
|
3717
|
+
* then be interleaves between each event.
|
|
3718
|
+
*
|
|
3719
|
+
* By running change detection after the first of `setTimeout` and `rAF` to execute, we get the
|
|
3720
|
+
* best of both worlds.
|
|
3721
|
+
*
|
|
3722
|
+
* @returns a function to cancel the scheduled callback
|
|
3723
|
+
*/
|
|
3724
|
+
function scheduleCallbackWithRafRace(callback) {
|
|
3725
|
+
let timeoutId;
|
|
3726
|
+
let animationFrameId;
|
|
3727
|
+
function cleanup() {
|
|
3728
|
+
callback = noop;
|
|
3729
|
+
try {
|
|
3730
|
+
if (animationFrameId !== undefined && typeof cancelAnimationFrame === 'function') {
|
|
3731
|
+
cancelAnimationFrame(animationFrameId);
|
|
3732
|
+
}
|
|
3733
|
+
if (timeoutId !== undefined) {
|
|
3734
|
+
clearTimeout(timeoutId);
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
catch {
|
|
3738
|
+
// Clearing/canceling can fail in tests due to the timing of functions being patched and unpatched
|
|
3739
|
+
// Just ignore the errors - we protect ourselves from this issue by also making the callback a no-op.
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3742
|
+
timeoutId = setTimeout(() => {
|
|
3743
|
+
callback();
|
|
3744
|
+
cleanup();
|
|
3745
|
+
});
|
|
3746
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
3747
|
+
animationFrameId = requestAnimationFrame(() => {
|
|
3748
|
+
callback();
|
|
3749
|
+
cleanup();
|
|
3750
|
+
});
|
|
3751
|
+
}
|
|
3752
|
+
return () => cleanup();
|
|
3753
|
+
}
|
|
3754
|
+
function scheduleCallbackWithMicrotask(callback) {
|
|
3755
|
+
queueMicrotask(() => callback());
|
|
3756
|
+
return () => {
|
|
3757
|
+
callback = noop;
|
|
3758
|
+
};
|
|
3759
|
+
}
|
|
3760
|
+
|
|
3761
|
+
class AsyncStackTaggingZoneSpec {
|
|
3762
|
+
createTask;
|
|
3763
|
+
constructor(namePrefix, consoleAsyncStackTaggingImpl = console) {
|
|
3764
|
+
this.name = 'asyncStackTagging for ' + namePrefix;
|
|
3765
|
+
this.createTask = consoleAsyncStackTaggingImpl?.createTask ?? (() => null);
|
|
3766
|
+
}
|
|
3767
|
+
// ZoneSpec implementation below.
|
|
3768
|
+
name;
|
|
3769
|
+
onScheduleTask(delegate, _current, target, task) {
|
|
3770
|
+
task.consoleTask = this.createTask(`Zone - ${task.source || task.type}`);
|
|
3771
|
+
return delegate.scheduleTask(target, task);
|
|
3772
|
+
}
|
|
3773
|
+
onInvokeTask(delegate, _currentZone, targetZone, task, applyThis, applyArgs) {
|
|
3774
|
+
let ret;
|
|
3775
|
+
if (task.consoleTask) {
|
|
3776
|
+
ret = task.consoleTask.run(() => delegate.invokeTask(targetZone, task, applyThis, applyArgs));
|
|
3777
|
+
}
|
|
3778
|
+
else {
|
|
3779
|
+
ret = delegate.invokeTask(targetZone, task, applyThis, applyArgs);
|
|
3780
|
+
}
|
|
3781
|
+
return ret;
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
|
|
3785
|
+
const isAngularZoneProperty = 'isAngularZone';
|
|
3786
|
+
const angularZoneInstanceIdProperty = isAngularZoneProperty + '_ID';
|
|
3787
|
+
let ngZoneInstanceId = 0;
|
|
3788
|
+
/**
|
|
3789
|
+
* An injectable service for executing work inside or outside of the Angular zone.
|
|
3790
|
+
*
|
|
3791
|
+
* The most common use of this service is to optimize performance when starting a work consisting of
|
|
3792
|
+
* one or more asynchronous tasks that don't require UI updates or error handling to be handled by
|
|
3793
|
+
* Angular. Such tasks can be kicked off via {@link #runOutsideAngular} and if needed, these tasks
|
|
3794
|
+
* can reenter the Angular zone via {@link #run}.
|
|
3795
|
+
*
|
|
3796
|
+
* <!-- TODO: add/fix links to:
|
|
3797
|
+
* - docs explaining zones and the use of zones in Angular and change-detection
|
|
3798
|
+
* - link to runOutsideAngular/run (throughout this file!)
|
|
3799
|
+
* -->
|
|
3800
|
+
*
|
|
3801
|
+
* @usageNotes
|
|
3802
|
+
* ### Example
|
|
3803
|
+
*
|
|
3804
|
+
* ```ts
|
|
3805
|
+
* import {Component, NgZone} from '@angular/core';
|
|
3806
|
+
*
|
|
3807
|
+
* @Component({
|
|
3808
|
+
* selector: 'ng-zone-demo',
|
|
3809
|
+
* template: `
|
|
3810
|
+
* <h2>Demo: NgZone</h2>
|
|
3811
|
+
*
|
|
3812
|
+
* <p>Progress: {{progress}}%</p>
|
|
3813
|
+
* @if(progress >= 100) {
|
|
3814
|
+
* <p>Done processing {{label}} of Angular zone!</p>
|
|
3815
|
+
* }
|
|
3816
|
+
*
|
|
3817
|
+
* <button (click)="processWithinAngularZone()">Process within Angular zone</button>
|
|
3818
|
+
* <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
|
|
3819
|
+
* `,
|
|
3820
|
+
* })
|
|
3821
|
+
* export class NgZoneDemo {
|
|
3822
|
+
* progress: number = 0;
|
|
3823
|
+
* label: string;
|
|
3824
|
+
*
|
|
3825
|
+
* constructor(private _ngZone: NgZone) {}
|
|
3826
|
+
*
|
|
3827
|
+
* // Loop inside the Angular zone
|
|
3828
|
+
* // so the UI DOES refresh after each setTimeout cycle
|
|
3829
|
+
* processWithinAngularZone() {
|
|
3830
|
+
* this.label = 'inside';
|
|
3831
|
+
* this.progress = 0;
|
|
3832
|
+
* this._increaseProgress(() => console.log('Inside Done!'));
|
|
3833
|
+
* }
|
|
3834
|
+
*
|
|
3835
|
+
* // Loop outside of the Angular zone
|
|
3836
|
+
* // so the UI DOES NOT refresh after each setTimeout cycle
|
|
3837
|
+
* processOutsideOfAngularZone() {
|
|
3838
|
+
* this.label = 'outside';
|
|
3839
|
+
* this.progress = 0;
|
|
3840
|
+
* this._ngZone.runOutsideAngular(() => {
|
|
3841
|
+
* this._increaseProgress(() => {
|
|
3842
|
+
* // reenter the Angular zone and display done
|
|
3843
|
+
* this._ngZone.run(() => { console.log('Outside Done!'); });
|
|
3844
|
+
* });
|
|
3845
|
+
* });
|
|
3846
|
+
* }
|
|
3847
|
+
*
|
|
3848
|
+
* _increaseProgress(doneCallback: () => void) {
|
|
3849
|
+
* this.progress += 1;
|
|
3850
|
+
* console.log(`Current progress: ${this.progress}%`);
|
|
3851
|
+
*
|
|
3852
|
+
* if (this.progress < 100) {
|
|
3853
|
+
* window.setTimeout(() => this._increaseProgress(doneCallback), 10);
|
|
3854
|
+
* } else {
|
|
3855
|
+
* doneCallback();
|
|
3856
|
+
* }
|
|
3857
|
+
* }
|
|
3858
|
+
* }
|
|
3859
|
+
* ```
|
|
3860
|
+
*
|
|
3861
|
+
* @publicApi
|
|
3862
|
+
*/
|
|
3863
|
+
class NgZone {
|
|
3864
|
+
hasPendingMacrotasks = false;
|
|
3865
|
+
hasPendingMicrotasks = false;
|
|
3866
|
+
/**
|
|
3867
|
+
* Whether there are no outstanding microtasks or macrotasks.
|
|
3868
|
+
*/
|
|
3869
|
+
isStable = true;
|
|
3870
|
+
/**
|
|
3871
|
+
* Notifies when code enters Angular Zone. This gets fired first on VM Turn.
|
|
3872
|
+
*/
|
|
3873
|
+
onUnstable = new EventEmitter(false);
|
|
3874
|
+
/**
|
|
3875
|
+
* Notifies when there is no more microtasks enqueued in the current VM Turn.
|
|
3876
|
+
* This is a hint for Angular to do change detection, which may enqueue more microtasks.
|
|
3877
|
+
* For this reason this event can fire multiple times per VM Turn.
|
|
3878
|
+
*/
|
|
3879
|
+
onMicrotaskEmpty = new EventEmitter(false);
|
|
3880
|
+
/**
|
|
3881
|
+
* Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
|
|
3882
|
+
* implies we are about to relinquish VM turn.
|
|
3883
|
+
* This event gets called just once.
|
|
3884
|
+
*/
|
|
3885
|
+
onStable = new EventEmitter(false);
|
|
3886
|
+
/**
|
|
3887
|
+
* Notifies that an error has been delivered.
|
|
3888
|
+
*/
|
|
3889
|
+
onError = new EventEmitter(false);
|
|
3890
|
+
constructor(options) {
|
|
3891
|
+
const { enableLongStackTrace = false, shouldCoalesceEventChangeDetection = false, shouldCoalesceRunChangeDetection = false, scheduleInRootZone = SCHEDULE_IN_ROOT_ZONE_DEFAULT, } = options;
|
|
3892
|
+
if (typeof Zone == 'undefined') {
|
|
3893
|
+
throw new RuntimeError(908 /* RuntimeErrorCode.MISSING_ZONEJS */, ngDevMode && `In this configuration Angular requires Zone.js`);
|
|
3894
|
+
}
|
|
3895
|
+
Zone.assertZonePatched();
|
|
3896
|
+
const self = this;
|
|
3897
|
+
self._nesting = 0;
|
|
3898
|
+
self._outer = self._inner = Zone.current;
|
|
3899
|
+
// AsyncStackTaggingZoneSpec provides `linked stack traces` to show
|
|
3900
|
+
// where the async operation is scheduled. For more details, refer
|
|
3901
|
+
// to this article, https://developer.chrome.com/blog/devtools-better-angular-debugging/
|
|
3902
|
+
// And we only import this AsyncStackTaggingZoneSpec in development mode,
|
|
3903
|
+
// in the production mode, the AsyncStackTaggingZoneSpec will be tree shaken away.
|
|
3904
|
+
if (ngDevMode) {
|
|
3905
|
+
self._inner = self._inner.fork(new AsyncStackTaggingZoneSpec('Angular'));
|
|
3906
|
+
}
|
|
3907
|
+
if (Zone['TaskTrackingZoneSpec']) {
|
|
3908
|
+
self._inner = self._inner.fork(new Zone['TaskTrackingZoneSpec']());
|
|
3909
|
+
}
|
|
3910
|
+
if (enableLongStackTrace && Zone['longStackTraceZoneSpec']) {
|
|
3911
|
+
self._inner = self._inner.fork(Zone['longStackTraceZoneSpec']);
|
|
3912
|
+
}
|
|
3913
|
+
// if shouldCoalesceRunChangeDetection is true, all tasks including event tasks will be
|
|
3914
|
+
// coalesced, so shouldCoalesceEventChangeDetection option is not necessary and can be skipped.
|
|
3915
|
+
self.shouldCoalesceEventChangeDetection =
|
|
3916
|
+
!shouldCoalesceRunChangeDetection && shouldCoalesceEventChangeDetection;
|
|
3917
|
+
self.shouldCoalesceRunChangeDetection = shouldCoalesceRunChangeDetection;
|
|
3918
|
+
self.callbackScheduled = false;
|
|
3919
|
+
self.scheduleInRootZone = scheduleInRootZone;
|
|
3920
|
+
forkInnerZoneWithAngularBehavior(self);
|
|
3921
|
+
}
|
|
3922
|
+
/**
|
|
3923
|
+
This method checks whether the method call happens within an Angular Zone instance.
|
|
3924
|
+
*/
|
|
3925
|
+
static isInAngularZone() {
|
|
3926
|
+
// Zone needs to be checked, because this method might be called even when NoopNgZone is used.
|
|
3927
|
+
return typeof Zone !== 'undefined' && Zone.current.get(isAngularZoneProperty) === true;
|
|
3928
|
+
}
|
|
3929
|
+
/**
|
|
3930
|
+
Assures that the method is called within the Angular Zone, otherwise throws an error.
|
|
3931
|
+
*/
|
|
3932
|
+
static assertInAngularZone() {
|
|
3933
|
+
if (!NgZone.isInAngularZone()) {
|
|
3934
|
+
throw new RuntimeError(909 /* RuntimeErrorCode.UNEXPECTED_ZONE_STATE */, ngDevMode && 'Expected to be in Angular Zone, but it is not!');
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
/**
|
|
3938
|
+
Assures that the method is called outside of the Angular Zone, otherwise throws an error.
|
|
3939
|
+
*/
|
|
3940
|
+
static assertNotInAngularZone() {
|
|
3941
|
+
if (NgZone.isInAngularZone()) {
|
|
3942
|
+
throw new RuntimeError(909 /* RuntimeErrorCode.UNEXPECTED_ZONE_STATE */, ngDevMode && 'Expected to not be in Angular Zone, but it is!');
|
|
3943
|
+
}
|
|
3944
|
+
}
|
|
3945
|
+
/**
|
|
3946
|
+
* Executes the `fn` function synchronously within the Angular zone and returns value returned by
|
|
3947
|
+
* the function.
|
|
3948
|
+
*
|
|
3949
|
+
* Running functions via `run` allows you to reenter Angular zone from a task that was executed
|
|
3950
|
+
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
|
|
3951
|
+
*
|
|
3952
|
+
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
|
3953
|
+
* within the Angular zone.
|
|
3954
|
+
*
|
|
3955
|
+
* If a synchronous error happens it will be rethrown and not reported via `onError`.
|
|
3956
|
+
*/
|
|
3957
|
+
run(fn, applyThis, applyArgs) {
|
|
3958
|
+
return this._inner.run(fn, applyThis, applyArgs);
|
|
3959
|
+
}
|
|
3960
|
+
/**
|
|
3961
|
+
* Executes the `fn` function synchronously within the Angular zone as a task and returns value
|
|
3962
|
+
* returned by the function.
|
|
3963
|
+
*
|
|
3964
|
+
* Running functions via `runTask` allows you to reenter Angular zone from a task that was executed
|
|
3965
|
+
* outside of the Angular zone (typically started via {@link #runOutsideAngular}).
|
|
3966
|
+
*
|
|
3967
|
+
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
|
3968
|
+
* within the Angular zone.
|
|
3969
|
+
*
|
|
3970
|
+
* If a synchronous error happens it will be rethrown and not reported via `onError`.
|
|
3971
|
+
*/
|
|
3972
|
+
runTask(fn, applyThis, applyArgs, name) {
|
|
3973
|
+
const zone = this._inner;
|
|
3974
|
+
const task = zone.scheduleEventTask('NgZoneEvent: ' + name, fn, EMPTY_PAYLOAD, noop, noop);
|
|
3975
|
+
try {
|
|
3976
|
+
return zone.runTask(task, applyThis, applyArgs);
|
|
3977
|
+
}
|
|
3978
|
+
finally {
|
|
3979
|
+
zone.cancelTask(task);
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
/**
|
|
3983
|
+
* Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
|
|
3984
|
+
* rethrown.
|
|
3985
|
+
*/
|
|
3986
|
+
runGuarded(fn, applyThis, applyArgs) {
|
|
3987
|
+
return this._inner.runGuarded(fn, applyThis, applyArgs);
|
|
3988
|
+
}
|
|
3989
|
+
/**
|
|
3990
|
+
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
|
|
3991
|
+
* the function.
|
|
3992
|
+
*
|
|
3993
|
+
* Running functions via {@link #runOutsideAngular} allows you to escape Angular's zone and do
|
|
3994
|
+
* work that
|
|
3995
|
+
* doesn't trigger Angular change-detection or is subject to Angular's error handling.
|
|
3996
|
+
*
|
|
3997
|
+
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
|
3998
|
+
* outside of the Angular zone.
|
|
3999
|
+
*
|
|
4000
|
+
* Use {@link #run} to reenter the Angular zone and do work that updates the application model.
|
|
4001
|
+
*/
|
|
4002
|
+
runOutsideAngular(fn) {
|
|
4003
|
+
return this._outer.run(fn);
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
const EMPTY_PAYLOAD = {};
|
|
4007
|
+
function checkStable(zone) {
|
|
4008
|
+
// TODO: @JiaLiPassion, should check zone.isCheckStableRunning to prevent
|
|
4009
|
+
// re-entry. The case is:
|
|
4010
|
+
//
|
|
4011
|
+
// @Component({...})
|
|
4012
|
+
// export class AppComponent {
|
|
4013
|
+
// constructor(private ngZone: NgZone) {
|
|
4014
|
+
// this.ngZone.onStable.subscribe(() => {
|
|
4015
|
+
// this.ngZone.run(() => console.log('stable'););
|
|
4016
|
+
// });
|
|
4017
|
+
// }
|
|
4018
|
+
//
|
|
4019
|
+
// The onStable subscriber run another function inside ngZone
|
|
4020
|
+
// which causes `checkStable()` re-entry.
|
|
4021
|
+
// But this fix causes some issues in g3, so this fix will be
|
|
4022
|
+
// launched in another PR.
|
|
4023
|
+
if (zone._nesting == 0 && !zone.hasPendingMicrotasks && !zone.isStable) {
|
|
4024
|
+
try {
|
|
4025
|
+
zone._nesting++;
|
|
4026
|
+
zone.onMicrotaskEmpty.emit(null);
|
|
4027
|
+
}
|
|
4028
|
+
finally {
|
|
4029
|
+
zone._nesting--;
|
|
4030
|
+
if (!zone.hasPendingMicrotasks) {
|
|
4031
|
+
try {
|
|
4032
|
+
zone.runOutsideAngular(() => zone.onStable.emit(null));
|
|
4033
|
+
}
|
|
4034
|
+
finally {
|
|
4035
|
+
zone.isStable = true;
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
function delayChangeDetectionForEvents(zone) {
|
|
4042
|
+
/**
|
|
4043
|
+
* We also need to check _nesting here
|
|
4044
|
+
* Consider the following case with shouldCoalesceRunChangeDetection = true
|
|
4045
|
+
*
|
|
4046
|
+
* ngZone.run(() => {});
|
|
4047
|
+
* ngZone.run(() => {});
|
|
4048
|
+
*
|
|
4049
|
+
* We want the two `ngZone.run()` only trigger one change detection
|
|
4050
|
+
* when shouldCoalesceRunChangeDetection is true.
|
|
4051
|
+
* And because in this case, change detection run in async way(requestAnimationFrame),
|
|
4052
|
+
* so we also need to check the _nesting here to prevent multiple
|
|
4053
|
+
* change detections.
|
|
4054
|
+
*/
|
|
4055
|
+
if (zone.isCheckStableRunning || zone.callbackScheduled) {
|
|
4056
|
+
return;
|
|
4057
|
+
}
|
|
4058
|
+
zone.callbackScheduled = true;
|
|
4059
|
+
function scheduleCheckStable() {
|
|
4060
|
+
scheduleCallbackWithRafRace(() => {
|
|
4061
|
+
zone.callbackScheduled = false;
|
|
4062
|
+
updateMicroTaskStatus(zone);
|
|
4063
|
+
zone.isCheckStableRunning = true;
|
|
4064
|
+
checkStable(zone);
|
|
4065
|
+
zone.isCheckStableRunning = false;
|
|
4066
|
+
});
|
|
4067
|
+
}
|
|
4068
|
+
if (zone.scheduleInRootZone) {
|
|
4069
|
+
Zone.root.run(() => {
|
|
4070
|
+
scheduleCheckStable();
|
|
4071
|
+
});
|
|
4072
|
+
}
|
|
4073
|
+
else {
|
|
4074
|
+
zone._outer.run(() => {
|
|
4075
|
+
scheduleCheckStable();
|
|
4076
|
+
});
|
|
4077
|
+
}
|
|
4078
|
+
updateMicroTaskStatus(zone);
|
|
4079
|
+
}
|
|
4080
|
+
function forkInnerZoneWithAngularBehavior(zone) {
|
|
4081
|
+
const delayChangeDetectionForEventsDelegate = () => {
|
|
4082
|
+
delayChangeDetectionForEvents(zone);
|
|
4083
|
+
};
|
|
4084
|
+
const instanceId = ngZoneInstanceId++;
|
|
4085
|
+
zone._inner = zone._inner.fork({
|
|
4086
|
+
name: 'angular',
|
|
4087
|
+
properties: {
|
|
4088
|
+
[isAngularZoneProperty]: true,
|
|
4089
|
+
[angularZoneInstanceIdProperty]: instanceId,
|
|
4090
|
+
[angularZoneInstanceIdProperty + instanceId]: true,
|
|
4091
|
+
},
|
|
4092
|
+
onInvokeTask: (delegate, current, target, task, applyThis, applyArgs) => {
|
|
4093
|
+
// Prevent triggering change detection when the flag is detected.
|
|
4094
|
+
if (shouldBeIgnoredByZone(applyArgs)) {
|
|
4095
|
+
return delegate.invokeTask(target, task, applyThis, applyArgs);
|
|
4096
|
+
}
|
|
4097
|
+
try {
|
|
4098
|
+
onEnter(zone);
|
|
4099
|
+
return delegate.invokeTask(target, task, applyThis, applyArgs);
|
|
4100
|
+
}
|
|
4101
|
+
finally {
|
|
4102
|
+
if ((zone.shouldCoalesceEventChangeDetection && task.type === 'eventTask') ||
|
|
4103
|
+
zone.shouldCoalesceRunChangeDetection) {
|
|
4104
|
+
delayChangeDetectionForEventsDelegate();
|
|
4105
|
+
}
|
|
4106
|
+
onLeave(zone);
|
|
4107
|
+
}
|
|
4108
|
+
},
|
|
4109
|
+
onInvoke: (delegate, current, target, callback, applyThis, applyArgs, source) => {
|
|
4110
|
+
try {
|
|
4111
|
+
onEnter(zone);
|
|
4112
|
+
return delegate.invoke(target, callback, applyThis, applyArgs, source);
|
|
4113
|
+
}
|
|
4114
|
+
finally {
|
|
4115
|
+
if (zone.shouldCoalesceRunChangeDetection &&
|
|
4116
|
+
// Do not delay change detection when the task is the scheduler's tick.
|
|
4117
|
+
// We need to synchronously trigger the stability logic so that the
|
|
4118
|
+
// zone-based scheduler can prevent a duplicate ApplicationRef.tick
|
|
4119
|
+
// by first checking if the scheduler tick is running. This does seem a bit roundabout,
|
|
4120
|
+
// but we _do_ still want to trigger all the correct events when we exit the zone.run
|
|
4121
|
+
// (`onMicrotaskEmpty` and `onStable` _should_ emit; developers can have code which
|
|
4122
|
+
// relies on these events happening after change detection runs).
|
|
4123
|
+
// Note: `zone.callbackScheduled` is already in delayChangeDetectionForEventsDelegate
|
|
4124
|
+
// but is added here as well to prevent reads of applyArgs when not necessary
|
|
4125
|
+
!zone.callbackScheduled &&
|
|
4126
|
+
!isSchedulerTick(applyArgs)) {
|
|
4127
|
+
delayChangeDetectionForEventsDelegate();
|
|
4128
|
+
}
|
|
4129
|
+
onLeave(zone);
|
|
4130
|
+
}
|
|
4131
|
+
},
|
|
4132
|
+
onHasTask: (delegate, current, target, hasTaskState) => {
|
|
4133
|
+
delegate.hasTask(target, hasTaskState);
|
|
4134
|
+
if (current === target) {
|
|
4135
|
+
// We are only interested in hasTask events which originate from our zone
|
|
4136
|
+
// (A child hasTask event is not interesting to us)
|
|
4137
|
+
if (hasTaskState.change == 'microTask') {
|
|
4138
|
+
zone._hasPendingMicrotasks = hasTaskState.microTask;
|
|
4139
|
+
updateMicroTaskStatus(zone);
|
|
4140
|
+
checkStable(zone);
|
|
4141
|
+
}
|
|
4142
|
+
else if (hasTaskState.change == 'macroTask') {
|
|
4143
|
+
zone.hasPendingMacrotasks = hasTaskState.macroTask;
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
},
|
|
4147
|
+
onHandleError: (delegate, current, target, error) => {
|
|
4148
|
+
delegate.handleError(target, error);
|
|
4149
|
+
zone.runOutsideAngular(() => zone.onError.emit(error));
|
|
4150
|
+
return false;
|
|
4151
|
+
},
|
|
4152
|
+
});
|
|
4153
|
+
}
|
|
4154
|
+
function updateMicroTaskStatus(zone) {
|
|
4155
|
+
if (zone._hasPendingMicrotasks ||
|
|
4156
|
+
((zone.shouldCoalesceEventChangeDetection || zone.shouldCoalesceRunChangeDetection) &&
|
|
4157
|
+
zone.callbackScheduled === true)) {
|
|
4158
|
+
zone.hasPendingMicrotasks = true;
|
|
4159
|
+
}
|
|
4160
|
+
else {
|
|
4161
|
+
zone.hasPendingMicrotasks = false;
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
function onEnter(zone) {
|
|
4165
|
+
zone._nesting++;
|
|
4166
|
+
if (zone.isStable) {
|
|
4167
|
+
zone.isStable = false;
|
|
4168
|
+
zone.onUnstable.emit(null);
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
function onLeave(zone) {
|
|
4172
|
+
zone._nesting--;
|
|
4173
|
+
checkStable(zone);
|
|
4174
|
+
}
|
|
4175
|
+
/**
|
|
4176
|
+
* Provides a noop implementation of `NgZone` which does nothing. This zone requires explicit calls
|
|
4177
|
+
* to framework to perform rendering.
|
|
4178
|
+
*/
|
|
4179
|
+
class NoopNgZone {
|
|
4180
|
+
hasPendingMicrotasks = false;
|
|
4181
|
+
hasPendingMacrotasks = false;
|
|
4182
|
+
isStable = true;
|
|
4183
|
+
onUnstable = new EventEmitter();
|
|
4184
|
+
onMicrotaskEmpty = new EventEmitter();
|
|
4185
|
+
onStable = new EventEmitter();
|
|
4186
|
+
onError = new EventEmitter();
|
|
4187
|
+
run(fn, applyThis, applyArgs) {
|
|
4188
|
+
return fn.apply(applyThis, applyArgs);
|
|
4189
|
+
}
|
|
4190
|
+
runGuarded(fn, applyThis, applyArgs) {
|
|
4191
|
+
return fn.apply(applyThis, applyArgs);
|
|
4192
|
+
}
|
|
4193
|
+
runOutsideAngular(fn) {
|
|
4194
|
+
return fn();
|
|
4195
|
+
}
|
|
4196
|
+
runTask(fn, applyThis, applyArgs, name) {
|
|
4197
|
+
return fn.apply(applyThis, applyArgs);
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
function shouldBeIgnoredByZone(applyArgs) {
|
|
4201
|
+
return hasApplyArgsData(applyArgs, '__ignore_ng_zone__');
|
|
4202
|
+
}
|
|
4203
|
+
function isSchedulerTick(applyArgs) {
|
|
4204
|
+
return hasApplyArgsData(applyArgs, '__scheduler_tick__');
|
|
4205
|
+
}
|
|
4206
|
+
function hasApplyArgsData(applyArgs, key) {
|
|
4207
|
+
if (!Array.isArray(applyArgs)) {
|
|
4208
|
+
return false;
|
|
4209
|
+
}
|
|
4210
|
+
// We should only ever get 1 arg passed through to invokeTask.
|
|
4211
|
+
// Short circuit here incase that behavior changes.
|
|
4212
|
+
if (applyArgs.length !== 1) {
|
|
4213
|
+
return false;
|
|
4214
|
+
}
|
|
4215
|
+
return applyArgs[0]?.data?.[key] === true;
|
|
4216
|
+
}
|
|
4217
|
+
function getNgZone(ngZoneToUse = 'zone.js', options) {
|
|
4218
|
+
if (ngZoneToUse === 'noop') {
|
|
4219
|
+
return new NoopNgZone();
|
|
4220
|
+
}
|
|
4221
|
+
if (ngZoneToUse === 'zone.js') {
|
|
4222
|
+
return new NgZone(options);
|
|
4223
|
+
}
|
|
4224
|
+
return ngZoneToUse;
|
|
4225
|
+
}
|
|
4226
|
+
|
|
3554
4227
|
/**
|
|
3555
4228
|
* Provides a hook for centralized exception handling.
|
|
3556
4229
|
*
|
|
@@ -3599,18 +4272,21 @@ const INTERNAL_APPLICATION_ERROR_HANDLER = new InjectionToken(typeof ngDevMode =
|
|
|
3599
4272
|
factory: () => {
|
|
3600
4273
|
// The user's error handler may depend on things that create a circular dependency
|
|
3601
4274
|
// so we inject it lazily.
|
|
4275
|
+
const zone = inject(NgZone);
|
|
3602
4276
|
const injector = inject(EnvironmentInjector);
|
|
3603
4277
|
let userErrorHandler;
|
|
3604
4278
|
return (e) => {
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
4279
|
+
zone.runOutsideAngular(() => {
|
|
4280
|
+
if (injector.destroyed && !userErrorHandler) {
|
|
4281
|
+
setTimeout(() => {
|
|
4282
|
+
throw e;
|
|
4283
|
+
});
|
|
4284
|
+
}
|
|
4285
|
+
else {
|
|
4286
|
+
userErrorHandler ??= injector.get(ErrorHandler);
|
|
4287
|
+
userErrorHandler.handleError(e);
|
|
4288
|
+
}
|
|
4289
|
+
});
|
|
3614
4290
|
};
|
|
3615
4291
|
},
|
|
3616
4292
|
});
|
|
@@ -3773,70 +4449,6 @@ function injectViewContext() {
|
|
|
3773
4449
|
return new ViewContext(getLView(), getCurrentTNode());
|
|
3774
4450
|
}
|
|
3775
4451
|
|
|
3776
|
-
/**
|
|
3777
|
-
* Internal implementation of the pending tasks service.
|
|
3778
|
-
*/
|
|
3779
|
-
class PendingTasksInternal {
|
|
3780
|
-
taskId = 0;
|
|
3781
|
-
pendingTasks = new Set();
|
|
3782
|
-
destroyed = false;
|
|
3783
|
-
pendingTask = new BehaviorSubject(false);
|
|
3784
|
-
get hasPendingTasks() {
|
|
3785
|
-
// Accessing the value of a closed `BehaviorSubject` throws an error.
|
|
3786
|
-
return this.destroyed ? false : this.pendingTask.value;
|
|
3787
|
-
}
|
|
3788
|
-
/**
|
|
3789
|
-
* In case the service is about to be destroyed, return a self-completing observable.
|
|
3790
|
-
* Otherwise, return the observable that emits the current state of pending tasks.
|
|
3791
|
-
*/
|
|
3792
|
-
get hasPendingTasksObservable() {
|
|
3793
|
-
if (this.destroyed) {
|
|
3794
|
-
// Manually creating the observable pulls less symbols from RxJS than `of(false)`.
|
|
3795
|
-
return new Observable((subscriber) => {
|
|
3796
|
-
subscriber.next(false);
|
|
3797
|
-
subscriber.complete();
|
|
3798
|
-
});
|
|
3799
|
-
}
|
|
3800
|
-
return this.pendingTask;
|
|
3801
|
-
}
|
|
3802
|
-
add() {
|
|
3803
|
-
// Emitting a value to a closed subject throws an error.
|
|
3804
|
-
if (!this.hasPendingTasks && !this.destroyed) {
|
|
3805
|
-
this.pendingTask.next(true);
|
|
3806
|
-
}
|
|
3807
|
-
const taskId = this.taskId++;
|
|
3808
|
-
this.pendingTasks.add(taskId);
|
|
3809
|
-
return taskId;
|
|
3810
|
-
}
|
|
3811
|
-
has(taskId) {
|
|
3812
|
-
return this.pendingTasks.has(taskId);
|
|
3813
|
-
}
|
|
3814
|
-
remove(taskId) {
|
|
3815
|
-
this.pendingTasks.delete(taskId);
|
|
3816
|
-
if (this.pendingTasks.size === 0 && this.hasPendingTasks) {
|
|
3817
|
-
this.pendingTask.next(false);
|
|
3818
|
-
}
|
|
3819
|
-
}
|
|
3820
|
-
ngOnDestroy() {
|
|
3821
|
-
this.pendingTasks.clear();
|
|
3822
|
-
if (this.hasPendingTasks) {
|
|
3823
|
-
this.pendingTask.next(false);
|
|
3824
|
-
}
|
|
3825
|
-
// We call `unsubscribe()` to release observers, as users may forget to
|
|
3826
|
-
// unsubscribe manually when subscribing to `isStable`. We do not call
|
|
3827
|
-
// `complete()` because it is unsafe; if someone subscribes using the `first`
|
|
3828
|
-
// operator and the observable completes before emitting a value,
|
|
3829
|
-
// RxJS will throw an error.
|
|
3830
|
-
this.destroyed = true;
|
|
3831
|
-
this.pendingTask.unsubscribe();
|
|
3832
|
-
}
|
|
3833
|
-
/** @nocollapse */
|
|
3834
|
-
static ɵprov = /** @pureOrBreakMyCode */ /* @__PURE__ */ ɵɵdefineInjectable({
|
|
3835
|
-
token: PendingTasksInternal,
|
|
3836
|
-
providedIn: 'root',
|
|
3837
|
-
factory: () => new PendingTasksInternal(),
|
|
3838
|
-
});
|
|
3839
|
-
}
|
|
3840
4452
|
/**
|
|
3841
4453
|
* Service that keeps track of pending tasks contributing to the stableness of Angular
|
|
3842
4454
|
* application. While several existing Angular services (ex.: `HttpClient`) will internally manage
|
|
@@ -3903,10 +4515,6 @@ class PendingTasks {
|
|
|
3903
4515
|
});
|
|
3904
4516
|
}
|
|
3905
4517
|
|
|
3906
|
-
function noop(...args) {
|
|
3907
|
-
// Do nothing.
|
|
3908
|
-
}
|
|
3909
|
-
|
|
3910
4518
|
/**
|
|
3911
4519
|
* A scheduler which manages the execution of effects.
|
|
3912
4520
|
*/
|
|
@@ -3997,5 +4605,5 @@ class ZoneAwareEffectScheduler {
|
|
|
3997
4605
|
}
|
|
3998
4606
|
}
|
|
3999
4607
|
|
|
4000
|
-
export { AFTER_RENDER_SEQUENCES_TO_ADD, CHILD_HEAD, CHILD_TAIL, CLEANUP, CONTAINER_HEADER_OFFSET, CONTEXT, ChangeDetectionScheduler, CheckNoChangesMode, DECLARATION_COMPONENT_VIEW, DECLARATION_LCONTAINER, DECLARATION_VIEW, DEHYDRATED_VIEWS, DOCUMENT, DestroyRef, EFFECTS, EFFECTS_TO_SCHEDULE, EMBEDDED_VIEW_INJECTOR, EMPTY_ARRAY, EMPTY_OBJ, ENVIRONMENT, ENVIRONMENT_INITIALIZER, EffectScheduler, EnvironmentInjector, ErrorHandler, FLAGS, HEADER_OFFSET, HOST, HYDRATION, ID, INJECTOR$1 as INJECTOR, INJECTOR as INJECTOR$1, INJECTOR_DEF_TYPES, INJECTOR_SCOPE, INTERNAL_APPLICATION_ERROR_HANDLER, InjectionToken, Injector, MATH_ML_NAMESPACE, MOVED_VIEWS, NATIVE, NEXT, NG_COMP_DEF, NG_DIR_DEF, NG_ELEMENT_ID, NG_FACTORY_DEF, NG_INJ_DEF, NG_MOD_DEF, NG_PIPE_DEF, NG_PROV_DEF, NodeInjectorDestroyRef, NullInjector, ON_DESTROY_HOOKS, PARENT, PREORDER_HOOK_FLAGS, PROVIDED_ZONELESS, PendingTasks, PendingTasksInternal, QUERIES, R3Injector, REACTIVE_TEMPLATE_CONSUMER, RENDERER, RuntimeError, SCHEDULE_IN_ROOT_ZONE, SVG_NAMESPACE, TVIEW, T_HOST, VIEW_REFS, ViewContext, XSS_SECURITY_URL, ZONELESS_ENABLED, ZONELESS_SCHEDULER_DISABLED, _global, addToArray, arrayEquals, arrayInsert2, arraySplice, assertComponentType, assertDefined, assertDirectiveDef, assertDomNode, assertElement, assertEqual, assertFirstCreatePass, assertFirstUpdatePass, assertFunction, assertGreaterThan, assertGreaterThanOrEqual, assertHasParent, assertInInjectionContext, assertIndexInDeclRange, assertIndexInExpandoRange, assertIndexInRange, assertInjectImplementationNotEqual, assertLContainer, assertLView, assertLessThan, assertNgModuleType, assertNodeInjector, assertNotDefined, assertNotEqual, assertNotInReactiveContext, assertNotReactive, assertNotSame, assertNumber, assertNumberInRange, assertOneOf, assertParentView, assertProjectionSlots, assertSame, assertString, assertTIcu, assertTNode, assertTNodeCreationIndex, assertTNodeForLView, assertTNodeForTView, attachInjectFlag, concatStringsWithSpace, convertToBitFlags, createInjector, createInjectorWithoutInjectorInstances, cyclicDependencyError, cyclicDependencyErrorWithDetails, debugStringifyTypeForError, decreaseElementDepthCount, deepForEach, emitEffectCreatedEvent, emitInjectEvent, emitInjectorToCreateInstanceEvent, emitInstanceCreatedByInjectorEvent, emitProviderConfiguredEvent, enterDI, enterSkipHydrationBlock, enterView, errorHandlerEnvironmentInitializer, fillProperties, flatten, formatRuntimeError, forwardRef, getAnimationElementRemovalRegistry, getBindingIndex, getBindingRoot, getBindingsEnabled, getClosureSafeProperty, getComponentDef, getComponentLViewByIndex, getConstant, getContextLView, getCurrentDirectiveDef, getCurrentDirectiveIndex, getCurrentParentTNode, getCurrentQueryIndex, getCurrentTNode, getCurrentTNodePlaceholderOk, getDirectiveDef, getDirectiveDefOrThrow, getElementDepthCount, getFactoryDef, getInjectableDef, getInjectorDef, getLView, getLViewParent, getNamespace, getNativeByIndex, getNativeByTNode, getNativeByTNodeOrNull, getNgModuleDef, getNgModuleDefOrThrow, getNullInjector, getOrCreateLViewCleanup, getOrCreateTViewCleanup, getPipeDef, getSelectedIndex, getSelectedTNode, getTNode, getTView, hasI18n, importProvidersFrom, increaseElementDepthCount, incrementBindingIndex, initNgDevMode, inject, injectRootLimpMode, internalImportProvidersFrom, isClassProvider, isComponentDef, isComponentHost, isContentQueryHost, isCreationMode, isCurrentTNodeParent, isDestroyed, isDirectiveHost, isEnvironmentProviders, isExhaustiveCheckNoChanges, isForwardRef, isInCheckNoChangesMode, isInI18nBlock, isInInjectionContext, isInSkipHydrationBlock, isInjectable, isLContainer, isLView, isProjectionTNode, isRefreshingViews, isRootView, isSignal, isSkipHydrationRootTNode, isStandalone, isTypeProvider, isWritableSignal, keyValueArrayGet, keyValueArrayIndexOf, keyValueArraySet, lastNodeWasCreated, leaveDI, leaveSkipHydrationBlock, leaveView, load, makeEnvironmentProviders, markAncestorsForTraversal, markViewForRefresh, newArray, nextBindingIndex, nextContextImpl, noop, provideBrowserGlobalErrorListeners, provideEnvironmentInitializer, providerToFactory, removeFromArray, removeLViewOnDestroy, renderStringify, requiresRefreshOrTraversal, resetPreOrderHookFlags, resolveForwardRef, runInInjectionContext, runInInjectorProfilerContext, setAnimationElementRemovalRegistry, setBindingIndex, setBindingRootForHostBindings, setCurrentDirectiveIndex, setCurrentQueryIndex, setCurrentTNode, setCurrentTNodeAsNotParent, setInI18nBlock, setInjectImplementation, setInjectorProfiler, setInjectorProfilerContext, setIsInCheckNoChangesMode, setIsRefreshingViews, setSelectedIndex, signal, signalAsReadonlyFn, store, storeCleanupWithContext, storeLViewOnDestroy, stringify, stringifyForError, throwError, throwProviderNotFoundError, truncateMiddle, unwrapLView, unwrapRNode, updateAncestorTraversalFlagsOnAttach, viewAttachedToChangeDetector, viewAttachedToContainer, walkProviderTree, walkUpViews, wasLastNodeCreated, ɵunwrapWritableSignal, ɵɵdefineInjectable, ɵɵdefineInjector, ɵɵdisableBindings, ɵɵenableBindings, ɵɵinject, ɵɵinvalidFactoryDep, ɵɵnamespaceHTML, ɵɵnamespaceMathML, ɵɵnamespaceSVG, ɵɵresetView, ɵɵrestoreView };
|
|
4608
|
+
export { AFTER_RENDER_SEQUENCES_TO_ADD, CHILD_HEAD, CHILD_TAIL, CLEANUP, CONTAINER_HEADER_OFFSET, CONTEXT, ChangeDetectionScheduler, CheckNoChangesMode, DECLARATION_COMPONENT_VIEW, DECLARATION_LCONTAINER, DECLARATION_VIEW, DEHYDRATED_VIEWS, DOCUMENT, DestroyRef, EFFECTS, EFFECTS_TO_SCHEDULE, EMBEDDED_VIEW_INJECTOR, EMPTY_ARRAY, EMPTY_OBJ, ENVIRONMENT, ENVIRONMENT_INITIALIZER, EffectScheduler, EnvironmentInjector, ErrorHandler, EventEmitter, FLAGS, HEADER_OFFSET, HOST, HYDRATION, ID, INJECTOR$1 as INJECTOR, INJECTOR as INJECTOR$1, INJECTOR_DEF_TYPES, INJECTOR_SCOPE, INTERNAL_APPLICATION_ERROR_HANDLER, InjectionToken, Injector, MATH_ML_NAMESPACE, MOVED_VIEWS, NATIVE, NEXT, NG_COMP_DEF, NG_DIR_DEF, NG_ELEMENT_ID, NG_FACTORY_DEF, NG_INJ_DEF, NG_MOD_DEF, NG_PIPE_DEF, NG_PROV_DEF, NgZone, NodeInjectorDestroyRef, NoopNgZone, NullInjector, ON_DESTROY_HOOKS, PARENT, PREORDER_HOOK_FLAGS, PROVIDED_ZONELESS, PendingTasks, PendingTasksInternal, QUERIES, R3Injector, REACTIVE_TEMPLATE_CONSUMER, RENDERER, RuntimeError, SCHEDULE_IN_ROOT_ZONE, SCHEDULE_IN_ROOT_ZONE_DEFAULT, SVG_NAMESPACE, TVIEW, T_HOST, VIEW_REFS, ViewContext, XSS_SECURITY_URL, ZONELESS_ENABLED, ZONELESS_SCHEDULER_DISABLED, _global, addToArray, angularZoneInstanceIdProperty, arrayEquals, arrayInsert2, arraySplice, assertComponentType, assertDefined, assertDirectiveDef, assertDomNode, assertElement, assertEqual, assertFirstCreatePass, assertFirstUpdatePass, assertFunction, assertGreaterThan, assertGreaterThanOrEqual, assertHasParent, assertInInjectionContext, assertIndexInDeclRange, assertIndexInExpandoRange, assertIndexInRange, assertInjectImplementationNotEqual, assertLContainer, assertLView, assertLessThan, assertNgModuleType, assertNodeInjector, assertNotDefined, assertNotEqual, assertNotInReactiveContext, assertNotReactive, assertNotSame, assertNumber, assertNumberInRange, assertOneOf, assertParentView, assertProjectionSlots, assertSame, assertString, assertTIcu, assertTNode, assertTNodeCreationIndex, assertTNodeForLView, assertTNodeForTView, attachInjectFlag, concatStringsWithSpace, convertToBitFlags, createInjector, createInjectorWithoutInjectorInstances, cyclicDependencyError, cyclicDependencyErrorWithDetails, debugStringifyTypeForError, decreaseElementDepthCount, deepForEach, emitEffectCreatedEvent, emitInjectEvent, emitInjectorToCreateInstanceEvent, emitInstanceCreatedByInjectorEvent, emitProviderConfiguredEvent, enterDI, enterSkipHydrationBlock, enterView, errorHandlerEnvironmentInitializer, fillProperties, flatten, formatRuntimeError, forwardRef, getAnimationElementRemovalRegistry, getBindingIndex, getBindingRoot, getBindingsEnabled, getClosureSafeProperty, getComponentDef, getComponentLViewByIndex, getConstant, getContextLView, getCurrentDirectiveDef, getCurrentDirectiveIndex, getCurrentParentTNode, getCurrentQueryIndex, getCurrentTNode, getCurrentTNodePlaceholderOk, getDirectiveDef, getDirectiveDefOrThrow, getElementDepthCount, getFactoryDef, getInjectableDef, getInjectorDef, getLView, getLViewParent, getNamespace, getNativeByIndex, getNativeByTNode, getNativeByTNodeOrNull, getNgModuleDef, getNgModuleDefOrThrow, getNgZone, getNullInjector, getOrCreateLViewCleanup, getOrCreateTViewCleanup, getPipeDef, getSelectedIndex, getSelectedTNode, getTNode, getTView, hasI18n, importProvidersFrom, increaseElementDepthCount, incrementBindingIndex, initNgDevMode, inject, injectRootLimpMode, internalImportProvidersFrom, isClassProvider, isComponentDef, isComponentHost, isContentQueryHost, isCreationMode, isCurrentTNodeParent, isDestroyed, isDirectiveHost, isEnvironmentProviders, isExhaustiveCheckNoChanges, isForwardRef, isInCheckNoChangesMode, isInI18nBlock, isInInjectionContext, isInSkipHydrationBlock, isInjectable, isLContainer, isLView, isProjectionTNode, isRefreshingViews, isRootView, isSignal, isSkipHydrationRootTNode, isStandalone, isTypeProvider, isWritableSignal, keyValueArrayGet, keyValueArrayIndexOf, keyValueArraySet, lastNodeWasCreated, leaveDI, leaveSkipHydrationBlock, leaveView, load, makeEnvironmentProviders, markAncestorsForTraversal, markViewForRefresh, newArray, nextBindingIndex, nextContextImpl, noop, provideBrowserGlobalErrorListeners, provideEnvironmentInitializer, providerToFactory, removeFromArray, removeLViewOnDestroy, renderStringify, requiresRefreshOrTraversal, resetPreOrderHookFlags, resolveForwardRef, runInInjectionContext, runInInjectorProfilerContext, scheduleCallbackWithMicrotask, scheduleCallbackWithRafRace, setAnimationElementRemovalRegistry, setBindingIndex, setBindingRootForHostBindings, setCurrentDirectiveIndex, setCurrentQueryIndex, setCurrentTNode, setCurrentTNodeAsNotParent, setInI18nBlock, setInjectImplementation, setInjectorProfiler, setInjectorProfilerContext, setIsInCheckNoChangesMode, setIsRefreshingViews, setSelectedIndex, signal, signalAsReadonlyFn, store, storeCleanupWithContext, storeLViewOnDestroy, stringify, stringifyForError, throwError, throwProviderNotFoundError, truncateMiddle, unwrapLView, unwrapRNode, updateAncestorTraversalFlagsOnAttach, viewAttachedToChangeDetector, viewAttachedToContainer, walkProviderTree, walkUpViews, wasLastNodeCreated, ɵunwrapWritableSignal, ɵɵdefineInjectable, ɵɵdefineInjector, ɵɵdisableBindings, ɵɵenableBindings, ɵɵinject, ɵɵinvalidFactoryDep, ɵɵnamespaceHTML, ɵɵnamespaceMathML, ɵɵnamespaceSVG, ɵɵresetView, ɵɵrestoreView };
|
|
4001
4609
|
//# sourceMappingURL=root_effect_scheduler.mjs.map
|