@angular/core 16.2.4 → 16.2.5
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/src/render3/after_render_hooks.mjs +83 -49
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/testing/src/logger.mjs +3 -3
- package/fesm2022/core.mjs +142 -110
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +142 -110
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +6 -20
- package/package.json +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/ng-generate/standalone-migration/bundle.js +9 -9
- package/schematics/ng-generate/standalone-migration/bundle.js.map +1 -1
- package/testing/index.d.ts +1 -1
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v16.2.
|
|
2
|
+
* @license Angular v16.2.5
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -10905,7 +10905,7 @@ class Version {
|
|
|
10905
10905
|
/**
|
|
10906
10906
|
* @publicApi
|
|
10907
10907
|
*/
|
|
10908
|
-
const VERSION = new Version('16.2.
|
|
10908
|
+
const VERSION = new Version('16.2.5');
|
|
10909
10909
|
|
|
10910
10910
|
// This default value is when checking the hierarchy for a token.
|
|
10911
10911
|
//
|
|
@@ -10926,6 +10926,66 @@ const VERSION = new Version('16.2.4');
|
|
|
10926
10926
|
// - mod2.injector.get(token, default)
|
|
10927
10927
|
const NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
|
|
10928
10928
|
|
|
10929
|
+
const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
|
|
10930
|
+
function wrappedError(message, originalError) {
|
|
10931
|
+
const msg = `${message} caused by: ${originalError instanceof Error ? originalError.message : originalError}`;
|
|
10932
|
+
const error = Error(msg);
|
|
10933
|
+
error[ERROR_ORIGINAL_ERROR] = originalError;
|
|
10934
|
+
return error;
|
|
10935
|
+
}
|
|
10936
|
+
function getOriginalError(error) {
|
|
10937
|
+
return error[ERROR_ORIGINAL_ERROR];
|
|
10938
|
+
}
|
|
10939
|
+
|
|
10940
|
+
/**
|
|
10941
|
+
* Provides a hook for centralized exception handling.
|
|
10942
|
+
*
|
|
10943
|
+
* The default implementation of `ErrorHandler` prints error messages to the `console`. To
|
|
10944
|
+
* intercept error handling, write a custom exception handler that replaces this default as
|
|
10945
|
+
* appropriate for your app.
|
|
10946
|
+
*
|
|
10947
|
+
* @usageNotes
|
|
10948
|
+
* ### Example
|
|
10949
|
+
*
|
|
10950
|
+
* ```
|
|
10951
|
+
* class MyErrorHandler implements ErrorHandler {
|
|
10952
|
+
* handleError(error) {
|
|
10953
|
+
* // do something with the exception
|
|
10954
|
+
* }
|
|
10955
|
+
* }
|
|
10956
|
+
*
|
|
10957
|
+
* @NgModule({
|
|
10958
|
+
* providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
|
|
10959
|
+
* })
|
|
10960
|
+
* class MyModule {}
|
|
10961
|
+
* ```
|
|
10962
|
+
*
|
|
10963
|
+
* @publicApi
|
|
10964
|
+
*/
|
|
10965
|
+
class ErrorHandler {
|
|
10966
|
+
constructor() {
|
|
10967
|
+
/**
|
|
10968
|
+
* @internal
|
|
10969
|
+
*/
|
|
10970
|
+
this._console = console;
|
|
10971
|
+
}
|
|
10972
|
+
handleError(error) {
|
|
10973
|
+
const originalError = this._findOriginalError(error);
|
|
10974
|
+
this._console.error('ERROR', error);
|
|
10975
|
+
if (originalError) {
|
|
10976
|
+
this._console.error('ORIGINAL ERROR', originalError);
|
|
10977
|
+
}
|
|
10978
|
+
}
|
|
10979
|
+
/** @internal */
|
|
10980
|
+
_findOriginalError(error) {
|
|
10981
|
+
let e = error && getOriginalError(error);
|
|
10982
|
+
while (e && getOriginalError(e)) {
|
|
10983
|
+
e = getOriginalError(e);
|
|
10984
|
+
}
|
|
10985
|
+
return e || null;
|
|
10986
|
+
}
|
|
10987
|
+
}
|
|
10988
|
+
|
|
10929
10989
|
/**
|
|
10930
10990
|
* `DestroyRef` lets you set callbacks to run for any cleanup or destruction behavior.
|
|
10931
10991
|
* The scope of this destruction depends on where `DestroyRef` is injected. If `DestroyRef`
|
|
@@ -11580,14 +11640,18 @@ function afterRender(callback, options) {
|
|
|
11580
11640
|
}
|
|
11581
11641
|
let destroy;
|
|
11582
11642
|
const unregisterFn = injector.get(DestroyRef).onDestroy(() => destroy?.());
|
|
11583
|
-
const
|
|
11643
|
+
const afterRenderEventManager = injector.get(AfterRenderEventManager);
|
|
11644
|
+
// Lazily initialize the handler implementation, if necessary. This is so that it can be
|
|
11645
|
+
// tree-shaken if `afterRender` and `afterNextRender` aren't used.
|
|
11646
|
+
const callbackHandler = afterRenderEventManager.handler ??= new AfterRenderCallbackHandlerImpl();
|
|
11584
11647
|
const ngZone = injector.get(NgZone);
|
|
11585
|
-
const
|
|
11648
|
+
const errorHandler = injector.get(ErrorHandler, null, { optional: true });
|
|
11649
|
+
const instance = new AfterRenderCallback(ngZone, errorHandler, callback);
|
|
11586
11650
|
destroy = () => {
|
|
11587
|
-
|
|
11651
|
+
callbackHandler.unregister(instance);
|
|
11588
11652
|
unregisterFn();
|
|
11589
11653
|
};
|
|
11590
|
-
|
|
11654
|
+
callbackHandler.register(instance);
|
|
11591
11655
|
return { destroy };
|
|
11592
11656
|
}
|
|
11593
11657
|
/**
|
|
@@ -11640,89 +11704,117 @@ function afterNextRender(callback, options) {
|
|
|
11640
11704
|
}
|
|
11641
11705
|
let destroy;
|
|
11642
11706
|
const unregisterFn = injector.get(DestroyRef).onDestroy(() => destroy?.());
|
|
11643
|
-
const
|
|
11707
|
+
const afterRenderEventManager = injector.get(AfterRenderEventManager);
|
|
11708
|
+
// Lazily initialize the handler implementation, if necessary. This is so that it can be
|
|
11709
|
+
// tree-shaken if `afterRender` and `afterNextRender` aren't used.
|
|
11710
|
+
const callbackHandler = afterRenderEventManager.handler ??= new AfterRenderCallbackHandlerImpl();
|
|
11644
11711
|
const ngZone = injector.get(NgZone);
|
|
11645
|
-
const
|
|
11712
|
+
const errorHandler = injector.get(ErrorHandler, null, { optional: true });
|
|
11713
|
+
const instance = new AfterRenderCallback(ngZone, errorHandler, () => {
|
|
11646
11714
|
destroy?.();
|
|
11647
|
-
|
|
11715
|
+
callback();
|
|
11648
11716
|
});
|
|
11649
11717
|
destroy = () => {
|
|
11650
|
-
|
|
11718
|
+
callbackHandler.unregister(instance);
|
|
11651
11719
|
unregisterFn();
|
|
11652
11720
|
};
|
|
11653
|
-
|
|
11721
|
+
callbackHandler.register(instance);
|
|
11654
11722
|
return { destroy };
|
|
11655
11723
|
}
|
|
11656
11724
|
/**
|
|
11657
11725
|
* A wrapper around a function to be used as an after render callback.
|
|
11658
|
-
* @private
|
|
11659
11726
|
*/
|
|
11660
11727
|
class AfterRenderCallback {
|
|
11661
|
-
constructor(
|
|
11662
|
-
this.
|
|
11728
|
+
constructor(zone, errorHandler, callbackFn) {
|
|
11729
|
+
this.zone = zone;
|
|
11730
|
+
this.errorHandler = errorHandler;
|
|
11731
|
+
this.callbackFn = callbackFn;
|
|
11663
11732
|
}
|
|
11664
11733
|
invoke() {
|
|
11665
|
-
|
|
11734
|
+
try {
|
|
11735
|
+
this.zone.runOutsideAngular(this.callbackFn);
|
|
11736
|
+
}
|
|
11737
|
+
catch (err) {
|
|
11738
|
+
this.errorHandler?.handleError(err);
|
|
11739
|
+
}
|
|
11666
11740
|
}
|
|
11667
11741
|
}
|
|
11668
11742
|
/**
|
|
11669
|
-
*
|
|
11743
|
+
* Core functionality for `afterRender` and `afterNextRender`. Kept separate from
|
|
11744
|
+
* `AfterRenderEventManager` for tree-shaking.
|
|
11670
11745
|
*/
|
|
11671
|
-
class
|
|
11746
|
+
class AfterRenderCallbackHandlerImpl {
|
|
11672
11747
|
constructor() {
|
|
11748
|
+
this.executingCallbacks = false;
|
|
11673
11749
|
this.callbacks = new Set();
|
|
11674
11750
|
this.deferredCallbacks = new Set();
|
|
11675
|
-
this.renderDepth = 0;
|
|
11676
|
-
this.runningCallbacks = false;
|
|
11677
11751
|
}
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
* Throws if called from an `afterRender` callback.
|
|
11681
|
-
*/
|
|
11682
|
-
begin() {
|
|
11683
|
-
if (this.runningCallbacks) {
|
|
11752
|
+
validateBegin() {
|
|
11753
|
+
if (this.executingCallbacks) {
|
|
11684
11754
|
throw new RuntimeError(102 /* RuntimeErrorCode.RECURSIVE_APPLICATION_RENDER */, ngDevMode &&
|
|
11685
11755
|
'A new render operation began before the previous operation ended. ' +
|
|
11686
11756
|
'Did you trigger change detection from afterRender or afterNextRender?');
|
|
11687
11757
|
}
|
|
11688
|
-
this.renderDepth++;
|
|
11689
|
-
}
|
|
11690
|
-
/**
|
|
11691
|
-
* Mark the end of a render operation. Registered callbacks
|
|
11692
|
-
* are invoked if there are no more pending operations.
|
|
11693
|
-
*/
|
|
11694
|
-
end() {
|
|
11695
|
-
this.renderDepth--;
|
|
11696
|
-
if (this.renderDepth === 0) {
|
|
11697
|
-
try {
|
|
11698
|
-
this.runningCallbacks = true;
|
|
11699
|
-
for (const callback of this.callbacks) {
|
|
11700
|
-
callback.invoke();
|
|
11701
|
-
}
|
|
11702
|
-
}
|
|
11703
|
-
finally {
|
|
11704
|
-
this.runningCallbacks = false;
|
|
11705
|
-
for (const callback of this.deferredCallbacks) {
|
|
11706
|
-
this.callbacks.add(callback);
|
|
11707
|
-
}
|
|
11708
|
-
this.deferredCallbacks.clear();
|
|
11709
|
-
}
|
|
11710
|
-
}
|
|
11711
11758
|
}
|
|
11712
11759
|
register(callback) {
|
|
11713
11760
|
// If we're currently running callbacks, new callbacks should be deferred
|
|
11714
11761
|
// until the next render operation.
|
|
11715
|
-
const target = this.
|
|
11762
|
+
const target = this.executingCallbacks ? this.deferredCallbacks : this.callbacks;
|
|
11716
11763
|
target.add(callback);
|
|
11717
11764
|
}
|
|
11718
11765
|
unregister(callback) {
|
|
11719
11766
|
this.callbacks.delete(callback);
|
|
11720
11767
|
this.deferredCallbacks.delete(callback);
|
|
11721
11768
|
}
|
|
11722
|
-
|
|
11769
|
+
execute() {
|
|
11770
|
+
this.executingCallbacks = true;
|
|
11771
|
+
for (const callback of this.callbacks) {
|
|
11772
|
+
callback.invoke();
|
|
11773
|
+
}
|
|
11774
|
+
this.executingCallbacks = false;
|
|
11775
|
+
for (const callback of this.deferredCallbacks) {
|
|
11776
|
+
this.callbacks.add(callback);
|
|
11777
|
+
}
|
|
11778
|
+
this.deferredCallbacks.clear();
|
|
11779
|
+
}
|
|
11780
|
+
destroy() {
|
|
11723
11781
|
this.callbacks.clear();
|
|
11724
11782
|
this.deferredCallbacks.clear();
|
|
11725
11783
|
}
|
|
11784
|
+
}
|
|
11785
|
+
/**
|
|
11786
|
+
* Implements core timing for `afterRender` and `afterNextRender` events.
|
|
11787
|
+
* Delegates to an optional `AfterRenderCallbackHandler` for implementation.
|
|
11788
|
+
*/
|
|
11789
|
+
class AfterRenderEventManager {
|
|
11790
|
+
constructor() {
|
|
11791
|
+
this.renderDepth = 0;
|
|
11792
|
+
/* @internal */
|
|
11793
|
+
this.handler = null;
|
|
11794
|
+
}
|
|
11795
|
+
/**
|
|
11796
|
+
* Mark the beginning of a render operation (i.e. CD cycle).
|
|
11797
|
+
* Throws if called while executing callbacks.
|
|
11798
|
+
*/
|
|
11799
|
+
begin() {
|
|
11800
|
+
this.handler?.validateBegin();
|
|
11801
|
+
this.renderDepth++;
|
|
11802
|
+
}
|
|
11803
|
+
/**
|
|
11804
|
+
* Mark the end of a render operation. Callbacks will be
|
|
11805
|
+
* executed if there are no more pending operations.
|
|
11806
|
+
*/
|
|
11807
|
+
end() {
|
|
11808
|
+
ngDevMode && assertGreaterThan(this.renderDepth, 0, 'renderDepth must be greater than 0');
|
|
11809
|
+
this.renderDepth--;
|
|
11810
|
+
if (this.renderDepth === 0) {
|
|
11811
|
+
this.handler?.execute();
|
|
11812
|
+
}
|
|
11813
|
+
}
|
|
11814
|
+
ngOnDestroy() {
|
|
11815
|
+
this.handler?.destroy();
|
|
11816
|
+
this.handler = null;
|
|
11817
|
+
}
|
|
11726
11818
|
/** @nocollapse */
|
|
11727
11819
|
static { this.ɵprov = ɵɵdefineInjectable({
|
|
11728
11820
|
token: AfterRenderEventManager,
|
|
@@ -11756,66 +11848,6 @@ function markViewDirty(lView) {
|
|
|
11756
11848
|
return null;
|
|
11757
11849
|
}
|
|
11758
11850
|
|
|
11759
|
-
const ERROR_ORIGINAL_ERROR = 'ngOriginalError';
|
|
11760
|
-
function wrappedError(message, originalError) {
|
|
11761
|
-
const msg = `${message} caused by: ${originalError instanceof Error ? originalError.message : originalError}`;
|
|
11762
|
-
const error = Error(msg);
|
|
11763
|
-
error[ERROR_ORIGINAL_ERROR] = originalError;
|
|
11764
|
-
return error;
|
|
11765
|
-
}
|
|
11766
|
-
function getOriginalError(error) {
|
|
11767
|
-
return error[ERROR_ORIGINAL_ERROR];
|
|
11768
|
-
}
|
|
11769
|
-
|
|
11770
|
-
/**
|
|
11771
|
-
* Provides a hook for centralized exception handling.
|
|
11772
|
-
*
|
|
11773
|
-
* The default implementation of `ErrorHandler` prints error messages to the `console`. To
|
|
11774
|
-
* intercept error handling, write a custom exception handler that replaces this default as
|
|
11775
|
-
* appropriate for your app.
|
|
11776
|
-
*
|
|
11777
|
-
* @usageNotes
|
|
11778
|
-
* ### Example
|
|
11779
|
-
*
|
|
11780
|
-
* ```
|
|
11781
|
-
* class MyErrorHandler implements ErrorHandler {
|
|
11782
|
-
* handleError(error) {
|
|
11783
|
-
* // do something with the exception
|
|
11784
|
-
* }
|
|
11785
|
-
* }
|
|
11786
|
-
*
|
|
11787
|
-
* @NgModule({
|
|
11788
|
-
* providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
|
|
11789
|
-
* })
|
|
11790
|
-
* class MyModule {}
|
|
11791
|
-
* ```
|
|
11792
|
-
*
|
|
11793
|
-
* @publicApi
|
|
11794
|
-
*/
|
|
11795
|
-
class ErrorHandler {
|
|
11796
|
-
constructor() {
|
|
11797
|
-
/**
|
|
11798
|
-
* @internal
|
|
11799
|
-
*/
|
|
11800
|
-
this._console = console;
|
|
11801
|
-
}
|
|
11802
|
-
handleError(error) {
|
|
11803
|
-
const originalError = this._findOriginalError(error);
|
|
11804
|
-
this._console.error('ERROR', error);
|
|
11805
|
-
if (originalError) {
|
|
11806
|
-
this._console.error('ORIGINAL ERROR', originalError);
|
|
11807
|
-
}
|
|
11808
|
-
}
|
|
11809
|
-
/** @internal */
|
|
11810
|
-
_findOriginalError(error) {
|
|
11811
|
-
let e = error && getOriginalError(error);
|
|
11812
|
-
while (e && getOriginalError(e)) {
|
|
11813
|
-
e = getOriginalError(e);
|
|
11814
|
-
}
|
|
11815
|
-
return e || null;
|
|
11816
|
-
}
|
|
11817
|
-
}
|
|
11818
|
-
|
|
11819
11851
|
/**
|
|
11820
11852
|
* Internal token that specifies whether DOM reuse logic
|
|
11821
11853
|
* during hydration is enabled.
|