mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(core): move Zone providers to a single provider function (#49373)
This commit moves the providers for `NgZone`-based change detection to a single provider function. This function is currently called by default in all places where `NgZone` was provided (`bootstrapApplication`, `bootstrapModule`, and `TestBed`). When we want to make Angular applications zoneless by default, we can make a public provider method that has to be used in order to enable the zone change detection features. When this method is not called, Angular would use `NoopNgZone` by default and not initialize any subscriptions to the `NgZone` stability events. Side note: There are actually two places that `NgZone` is provided for `TestBed` (providers in `compileTestModule` and `BrowserTestingModule`). This likely doesn't need to be in both locations. PR Close #49373
This commit is contained in:
committed by
Alex Rickabaugh
parent
67c5272946
commit
4e098fa8a7
@@ -27,8 +27,6 @@ export const enum RuntimeErrorCode {
|
|||||||
// (undocumented)
|
// (undocumented)
|
||||||
DUPLICATE_DIRECTITVE = 309,
|
DUPLICATE_DIRECTITVE = 309,
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
ERROR_HANDLER_NOT_FOUND = 402,
|
|
||||||
// (undocumented)
|
|
||||||
EXPORT_NOT_FOUND = -301,
|
EXPORT_NOT_FOUND = -301,
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
EXPRESSION_CHANGED_AFTER_CHECKED = -100,
|
EXPRESSION_CHANGED_AFTER_CHECKED = -100,
|
||||||
@@ -69,6 +67,8 @@ export const enum RuntimeErrorCode {
|
|||||||
// (undocumented)
|
// (undocumented)
|
||||||
MISSING_LOCALE_DATA = 701,
|
MISSING_LOCALE_DATA = 701,
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
|
MISSING_REQUIRED_INJECTABLE_IN_BOOTSTRAP = 402,
|
||||||
|
// (undocumented)
|
||||||
MISSING_ZONEJS = 908,
|
MISSING_ZONEJS = 908,
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
MULTIPLE_COMPONENTS_MATCH = -300,
|
MULTIPLE_COMPONENTS_MATCH = -300,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"aio-local": {
|
"aio-local": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime": 4325,
|
"runtime": 4325,
|
||||||
"main": 468169,
|
"main": 469002,
|
||||||
"polyfills": 33836,
|
"polyfills": 33836,
|
||||||
"styles": 74561,
|
"styles": 74561,
|
||||||
"light-theme": 92890,
|
"light-theme": 92890,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"cli-hello-world": {
|
"cli-hello-world": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime": 908,
|
"runtime": 908,
|
||||||
"main": 126848,
|
"main": 128010,
|
||||||
"polyfills": 33792
|
"polyfills": 33792
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -19,14 +19,14 @@
|
|||||||
"cli-hello-world-ivy-i18n": {
|
"cli-hello-world-ivy-i18n": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime": 926,
|
"runtime": 926,
|
||||||
"main": 125546,
|
"main": 126699,
|
||||||
"polyfills": 34676
|
"polyfills": 34676
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cli-hello-world-lazy": {
|
"cli-hello-world-lazy": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime": 2734,
|
"runtime": 2734,
|
||||||
"main": 230728,
|
"main": 231317,
|
||||||
"polyfills": 33810,
|
"polyfills": 33810,
|
||||||
"src_app_lazy_lazy_routes_ts": 487
|
"src_app_lazy_lazy_routes_ts": 487
|
||||||
}
|
}
|
||||||
@@ -34,21 +34,21 @@
|
|||||||
"forms": {
|
"forms": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime": 888,
|
"runtime": 888,
|
||||||
"main": 159074,
|
"main": 160227,
|
||||||
"polyfills": 33772
|
"polyfills": 33772
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"animations": {
|
"animations": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime": 898,
|
"runtime": 898,
|
||||||
"main": 158262,
|
"main": 159415,
|
||||||
"polyfills": 33782
|
"polyfills": 33782
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"standalone-bootstrap": {
|
"standalone-bootstrap": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime": 918,
|
"runtime": 918,
|
||||||
"main": 86351,
|
"main": 86975,
|
||||||
"polyfills": 33802
|
"polyfills": 33802
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {ApplicationInitStatus} from './application_init';
|
|||||||
import {PLATFORM_INITIALIZER} from './application_tokens';
|
import {PLATFORM_INITIALIZER} from './application_tokens';
|
||||||
import {getCompilerFacade, JitCompilerUsage} from './compiler/compiler_facade';
|
import {getCompilerFacade, JitCompilerUsage} from './compiler/compiler_facade';
|
||||||
import {Console} from './console';
|
import {Console} from './console';
|
||||||
import {inject} from './di';
|
import {ENVIRONMENT_INITIALIZER, inject} from './di';
|
||||||
import {Injectable} from './di/injectable';
|
import {Injectable} from './di/injectable';
|
||||||
import {InjectionToken} from './di/injection_token';
|
import {InjectionToken} from './di/injection_token';
|
||||||
import {Injector} from './di/injector';
|
import {Injector} from './di/injector';
|
||||||
@@ -38,12 +38,12 @@ import {isStandalone} from './render3/definition';
|
|||||||
import {assertStandaloneComponentType} from './render3/errors';
|
import {assertStandaloneComponentType} from './render3/errors';
|
||||||
import {setLocaleId} from './render3/i18n/i18n_locale_id';
|
import {setLocaleId} from './render3/i18n/i18n_locale_id';
|
||||||
import {setJitOptions} from './render3/jit/jit_options';
|
import {setJitOptions} from './render3/jit/jit_options';
|
||||||
import {createEnvironmentInjector, NgModuleFactory as R3NgModuleFactory} from './render3/ng_module_ref';
|
import {createEnvironmentInjector, createNgModuleRefWithProviders, NgModuleFactory as R3NgModuleFactory} from './render3/ng_module_ref';
|
||||||
import {publishDefaultGlobalUtils as _publishDefaultGlobalUtils} from './render3/util/global_utils';
|
import {publishDefaultGlobalUtils as _publishDefaultGlobalUtils} from './render3/util/global_utils';
|
||||||
import {TESTABILITY} from './testability/testability';
|
import {TESTABILITY} from './testability/testability';
|
||||||
import {isPromise} from './util/lang';
|
import {isPromise} from './util/lang';
|
||||||
import {stringify} from './util/stringify';
|
import {stringify} from './util/stringify';
|
||||||
import {IS_STABLE, NgZone, NoopNgZone} from './zone/ng_zone';
|
import {isStableFactory, NgZone, NoopNgZone, ZONE_IS_STABLE_OBSERVABLE} from './zone/ng_zone';
|
||||||
|
|
||||||
const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
|
const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ export function internalCreateApplication(config: {
|
|||||||
// Create root application injector based on a set of providers configured at the platform
|
// Create root application injector based on a set of providers configured at the platform
|
||||||
// bootstrap level as well as providers passed to the bootstrap call by a user.
|
// bootstrap level as well as providers passed to the bootstrap call by a user.
|
||||||
const allAppProviders = [
|
const allAppProviders = [
|
||||||
{provide: NgZone, useValue: ngZone},
|
provideNgZoneChangeDetection(ngZone),
|
||||||
...(appProviders || []),
|
...(appProviders || []),
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ export function internalCreateApplication(config: {
|
|||||||
const exceptionHandler: ErrorHandler|null = envInjector.get(ErrorHandler, null);
|
const exceptionHandler: ErrorHandler|null = envInjector.get(ErrorHandler, null);
|
||||||
if (NG_DEV_MODE && !exceptionHandler) {
|
if (NG_DEV_MODE && !exceptionHandler) {
|
||||||
throw new RuntimeError(
|
throw new RuntimeError(
|
||||||
RuntimeErrorCode.ERROR_HANDLER_NOT_FOUND,
|
RuntimeErrorCode.MISSING_REQUIRED_INJECTABLE_IN_BOOTSTRAP,
|
||||||
'No `ErrorHandler` found in the Dependency Injection tree.');
|
'No `ErrorHandler` found in the Dependency Injection tree.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,25 +448,23 @@ export class PlatformRef {
|
|||||||
// So we create a mini parent injector that just contains the new NgZone and
|
// So we create a mini parent injector that just contains the new NgZone and
|
||||||
// pass that as parent to the NgModuleFactory.
|
// pass that as parent to the NgModuleFactory.
|
||||||
const ngZone = getNgZone(options?.ngZone, getNgZoneOptions(options));
|
const ngZone = getNgZone(options?.ngZone, getNgZoneOptions(options));
|
||||||
const providers: StaticProvider[] = [{provide: NgZone, useValue: ngZone}];
|
|
||||||
// Note: Create ngZoneInjector within ngZone.run so that all of the instantiated services are
|
// Note: Create ngZoneInjector within ngZone.run so that all of the instantiated services are
|
||||||
// created within the Angular zone
|
// created within the Angular zone
|
||||||
// Do not try to replace ngZone.run with ApplicationRef#run because ApplicationRef would then be
|
// Do not try to replace ngZone.run with ApplicationRef#run because ApplicationRef would then be
|
||||||
// created outside of the Angular zone.
|
// created outside of the Angular zone.
|
||||||
return ngZone.run(() => {
|
return ngZone.run(() => {
|
||||||
const ngZoneInjector = Injector.create(
|
const moduleRef = createNgModuleRefWithProviders(
|
||||||
{providers: providers, parent: this.injector, name: moduleFactory.moduleType.name});
|
moduleFactory.moduleType, this.injector, provideNgZoneChangeDetection(ngZone));
|
||||||
const moduleRef = <InternalNgModuleRef<M>>moduleFactory.create(ngZoneInjector);
|
const exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
|
||||||
const exceptionHandler: ErrorHandler|null = moduleRef.injector.get(ErrorHandler, null);
|
if (NG_DEV_MODE && exceptionHandler === null) {
|
||||||
if (!exceptionHandler) {
|
|
||||||
throw new RuntimeError(
|
throw new RuntimeError(
|
||||||
RuntimeErrorCode.ERROR_HANDLER_NOT_FOUND,
|
RuntimeErrorCode.MISSING_REQUIRED_INJECTABLE_IN_BOOTSTRAP,
|
||||||
ngDevMode && 'No ErrorHandler. Is platform module (BrowserModule) included?');
|
'No ErrorHandler. Is platform module (BrowserModule) included?');
|
||||||
}
|
}
|
||||||
ngZone.runOutsideAngular(() => {
|
ngZone.runOutsideAngular(() => {
|
||||||
const subscription = ngZone.onError.subscribe({
|
const subscription = ngZone.onError.subscribe({
|
||||||
next: (error: any) => {
|
next: (error: any) => {
|
||||||
exceptionHandler.handleError(error);
|
exceptionHandler!.handleError(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
moduleRef.onDestroy(() => {
|
moduleRef.onDestroy(() => {
|
||||||
@@ -474,7 +472,7 @@ export class PlatformRef {
|
|||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return _callAndReportToErrorHandler(exceptionHandler, ngZone, () => {
|
return _callAndReportToErrorHandler(exceptionHandler!, ngZone, () => {
|
||||||
const initStatus: ApplicationInitStatus = moduleRef.injector.get(ApplicationInitStatus);
|
const initStatus: ApplicationInitStatus = moduleRef.injector.get(ApplicationInitStatus);
|
||||||
initStatus.runInitializers();
|
initStatus.runInitializers();
|
||||||
return initStatus.donePromise.then(() => {
|
return initStatus.donePromise.then(() => {
|
||||||
@@ -755,8 +753,9 @@ export class ApplicationRef {
|
|||||||
/**
|
/**
|
||||||
* Returns an Observable that indicates when the application is stable or unstable.
|
* Returns an Observable that indicates when the application is stable or unstable.
|
||||||
*/
|
*/
|
||||||
public readonly isStable = inject(IS_STABLE);
|
public readonly isStable = inject(ZONE_IS_STABLE_OBSERVABLE);
|
||||||
|
|
||||||
|
private readonly _injector = inject(EnvironmentInjector);
|
||||||
/**
|
/**
|
||||||
* The `EnvironmentInjector` used to create this application.
|
* The `EnvironmentInjector` used to create this application.
|
||||||
*/
|
*/
|
||||||
@@ -764,11 +763,6 @@ export class ApplicationRef {
|
|||||||
return this._injector;
|
return this._injector;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
|
||||||
constructor(private _injector: EnvironmentInjector) {
|
|
||||||
inject(NgZoneChangeDetectionScheduler).initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap a component onto the element identified by its selector or, optionally, to a
|
* Bootstrap a component onto the element identified by its selector or, optionally, to a
|
||||||
* specified element.
|
* specified element.
|
||||||
@@ -1111,36 +1105,37 @@ function _lastDefined<T>(args: T[]): T|undefined {
|
|||||||
*
|
*
|
||||||
* `NgZone` is provided by default today so the default (and only) implementation for this
|
* `NgZone` is provided by default today so the default (and only) implementation for this
|
||||||
* is calling `ErrorHandler.handleError` outside of the Angular zone.
|
* is calling `ErrorHandler.handleError` outside of the Angular zone.
|
||||||
*
|
|
||||||
* TODO: When NgZone is off by default, the default behavior should be to just call
|
|
||||||
* the `ErrorHandler.handleError` directly.
|
|
||||||
*/
|
*/
|
||||||
const INTERNAL_APPLICATION_ERROR_HANDLER =
|
const INTERNAL_APPLICATION_ERROR_HANDLER =
|
||||||
new InjectionToken<(e: any) => void>(NG_DEV_MODE ? 'internal error handler' : '', {
|
new InjectionToken<(e: any) => void>(NG_DEV_MODE ? 'internal error handler' : '', {
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
factory: () => {
|
factory: () => {
|
||||||
const zone = inject(NgZone);
|
|
||||||
const userErrorHandler = inject(ErrorHandler);
|
const userErrorHandler = inject(ErrorHandler);
|
||||||
return (e) => zone.runOutsideAngular(() => userErrorHandler.handleError(e));
|
return userErrorHandler.handleError.bind(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function ngZoneApplicationErrorHandlerFactory() {
|
||||||
|
const zone = inject(NgZone);
|
||||||
|
const userErrorHandler = inject(ErrorHandler);
|
||||||
|
return (e: unknown) => zone.runOutsideAngular(() => userErrorHandler.handleError(e));
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({providedIn: 'root'})
|
@Injectable({providedIn: 'root'})
|
||||||
export class NgZoneChangeDetectionScheduler {
|
export class NgZoneChangeDetectionScheduler {
|
||||||
private readonly zone = inject(NgZone);
|
private readonly zone = inject(NgZone);
|
||||||
private readonly injector = inject(EnvironmentInjector);
|
private readonly applicationRef = inject(ApplicationRef);
|
||||||
|
|
||||||
// Lazy initialization to avoid circular DI since ApplicationRef initializes the scheduler.
|
|
||||||
// When Zoneless is the default, we can make the opt-in provider function have an
|
|
||||||
// ENVIRONMENT_INITIALIZER which initializes class instead of `ApplicationRef`.
|
|
||||||
private applicationRef?: ApplicationRef;
|
|
||||||
private _onMicrotaskEmptySubscription?: Subscription;
|
private _onMicrotaskEmptySubscription?: Subscription;
|
||||||
|
|
||||||
initialize(): void {
|
initialize(): void {
|
||||||
|
if (this._onMicrotaskEmptySubscription) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._onMicrotaskEmptySubscription = this.zone.onMicrotaskEmpty.subscribe({
|
this._onMicrotaskEmptySubscription = this.zone.onMicrotaskEmpty.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
this.applicationRef ??= this.injector.get(ApplicationRef);
|
|
||||||
this.applicationRef.tick();
|
this.applicationRef.tick();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1151,3 +1146,25 @@ export class NgZoneChangeDetectionScheduler {
|
|||||||
this._onMicrotaskEmptySubscription?.unsubscribe();
|
this._onMicrotaskEmptySubscription?.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function provideNgZoneChangeDetection(ngZone: NgZone): StaticProvider[] {
|
||||||
|
return [
|
||||||
|
{provide: NgZone, useValue: ngZone},
|
||||||
|
{
|
||||||
|
provide: ENVIRONMENT_INITIALIZER,
|
||||||
|
multi: true,
|
||||||
|
useFactory: () => {
|
||||||
|
const ngZoneChangeDetectionScheduler =
|
||||||
|
inject(NgZoneChangeDetectionScheduler, {optional: true});
|
||||||
|
if (NG_DEV_MODE && ngZoneChangeDetectionScheduler === null) {
|
||||||
|
throw new RuntimeError(
|
||||||
|
RuntimeErrorCode.MISSING_REQUIRED_INJECTABLE_IN_BOOTSTRAP,
|
||||||
|
'No NgZoneChangeDetectionScheduler found in the Dependency Injection tree.');
|
||||||
|
}
|
||||||
|
return () => ngZoneChangeDetectionScheduler!.initialize();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{provide: INTERNAL_APPLICATION_ERROR_HANDLER, useFactory: ngZoneApplicationErrorHandlerFactory},
|
||||||
|
{provide: ZONE_IS_STABLE_OBSERVABLE, useFactory: isStableFactory},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {ALLOW_MULTIPLE_PLATFORMS as ɵALLOW_MULTIPLE_PLATFORMS, internalCreateApplication as ɵinternalCreateApplication} from './application_ref';
|
export {ALLOW_MULTIPLE_PLATFORMS as ɵALLOW_MULTIPLE_PLATFORMS, internalCreateApplication as ɵinternalCreateApplication, provideNgZoneChangeDetection as ɵprovideNgZoneChangeDetection} from './application_ref';
|
||||||
export {APP_ID_RANDOM_PROVIDER as ɵAPP_ID_RANDOM_PROVIDER} from './application_tokens';
|
export {APP_ID_RANDOM_PROVIDER as ɵAPP_ID_RANDOM_PROVIDER} from './application_tokens';
|
||||||
export {defaultIterableDiffers as ɵdefaultIterableDiffers, defaultKeyValueDiffers as ɵdefaultKeyValueDiffers} from './change_detection/change_detection';
|
export {defaultIterableDiffers as ɵdefaultIterableDiffers, defaultKeyValueDiffers as ɵdefaultKeyValueDiffers} from './change_detection/change_detection';
|
||||||
export {Console as ɵConsole} from './console';
|
export {Console as ɵConsole} from './console';
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export const enum RuntimeErrorCode {
|
|||||||
// Bootstrap Errors
|
// Bootstrap Errors
|
||||||
MULTIPLE_PLATFORMS = 400,
|
MULTIPLE_PLATFORMS = 400,
|
||||||
PLATFORM_NOT_FOUND = 401,
|
PLATFORM_NOT_FOUND = 401,
|
||||||
ERROR_HANDLER_NOT_FOUND = 402,
|
MISSING_REQUIRED_INJECTABLE_IN_BOOTSTRAP = 402,
|
||||||
BOOTSTRAP_COMPONENTS_NOT_FOUND = -403,
|
BOOTSTRAP_COMPONENTS_NOT_FOUND = -403,
|
||||||
PLATFORM_ALREADY_DESTROYED = 404,
|
PLATFORM_ALREADY_DESTROYED = 404,
|
||||||
ASYNC_INITIALIZERS_STILL_RUNNING = 405,
|
ASYNC_INITIALIZERS_STILL_RUNNING = 405,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import {createInjectorWithoutInjectorInstances} from '../di/create_injector';
|
import {createInjectorWithoutInjectorInstances} from '../di/create_injector';
|
||||||
import {Injector} from '../di/injector';
|
import {Injector} from '../di/injector';
|
||||||
import {EnvironmentProviders, Provider} from '../di/interface/provider';
|
import {EnvironmentProviders, Provider, StaticProvider} from '../di/interface/provider';
|
||||||
import {EnvironmentInjector, getNullInjector, R3Injector} from '../di/r3_injector';
|
import {EnvironmentInjector, getNullInjector, R3Injector} from '../di/r3_injector';
|
||||||
import {Type} from '../interface/type';
|
import {Type} from '../interface/type';
|
||||||
import {ComponentFactoryResolver as viewEngine_ComponentFactoryResolver} from '../linker/component_factory_resolver';
|
import {ComponentFactoryResolver as viewEngine_ComponentFactoryResolver} from '../linker/component_factory_resolver';
|
||||||
@@ -32,7 +32,7 @@ import {maybeUnwrapFn} from './util/misc_utils';
|
|||||||
*/
|
*/
|
||||||
export function createNgModule<T>(
|
export function createNgModule<T>(
|
||||||
ngModule: Type<T>, parentInjector?: Injector): viewEngine_NgModuleRef<T> {
|
ngModule: Type<T>, parentInjector?: Injector): viewEngine_NgModuleRef<T> {
|
||||||
return new NgModuleRef<T>(ngModule, parentInjector ?? null);
|
return new NgModuleRef<T>(ngModule, parentInjector ?? null, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +59,8 @@ export class NgModuleRef<T> extends viewEngine_NgModuleRef<T> implements Interna
|
|||||||
override readonly componentFactoryResolver: ComponentFactoryResolver =
|
override readonly componentFactoryResolver: ComponentFactoryResolver =
|
||||||
new ComponentFactoryResolver(this);
|
new ComponentFactoryResolver(this);
|
||||||
|
|
||||||
constructor(ngModuleType: Type<T>, public _parent: Injector|null) {
|
constructor(
|
||||||
|
ngModuleType: Type<T>, public _parent: Injector|null, additionalProviders: StaticProvider[]) {
|
||||||
super();
|
super();
|
||||||
const ngModuleDef = getNgModuleDef(ngModuleType);
|
const ngModuleDef = getNgModuleDef(ngModuleType);
|
||||||
ngDevMode &&
|
ngDevMode &&
|
||||||
@@ -74,7 +75,8 @@ export class NgModuleRef<T> extends viewEngine_NgModuleRef<T> implements Interna
|
|||||||
{provide: viewEngine_NgModuleRef, useValue: this}, {
|
{provide: viewEngine_NgModuleRef, useValue: this}, {
|
||||||
provide: viewEngine_ComponentFactoryResolver,
|
provide: viewEngine_ComponentFactoryResolver,
|
||||||
useValue: this.componentFactoryResolver
|
useValue: this.componentFactoryResolver
|
||||||
}
|
},
|
||||||
|
...additionalProviders
|
||||||
],
|
],
|
||||||
stringify(ngModuleType), new Set(['environment'])) as R3Injector;
|
stringify(ngModuleType), new Set(['environment'])) as R3Injector;
|
||||||
|
|
||||||
@@ -108,10 +110,16 @@ export class NgModuleFactory<T> extends viewEngine_NgModuleFactory<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override create(parentInjector: Injector|null): viewEngine_NgModuleRef<T> {
|
override create(parentInjector: Injector|null): viewEngine_NgModuleRef<T> {
|
||||||
return new NgModuleRef(this.moduleType, parentInjector);
|
return new NgModuleRef(this.moduleType, parentInjector, []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createNgModuleRefWithProviders<T>(
|
||||||
|
moduleType: Type<T>, parentInjector: Injector|null,
|
||||||
|
additionalProviders: StaticProvider[]): InternalNgModuleRef<T> {
|
||||||
|
return new NgModuleRef(moduleType, parentInjector, additionalProviders);
|
||||||
|
}
|
||||||
|
|
||||||
class EnvironmentNgModuleRefAdapter extends viewEngine_NgModuleRef<null> {
|
class EnvironmentNgModuleRefAdapter extends viewEngine_NgModuleRef<null> {
|
||||||
override readonly injector: EnvironmentInjector;
|
override readonly injector: EnvironmentInjector;
|
||||||
override readonly componentFactoryResolver: ComponentFactoryResolver =
|
override readonly componentFactoryResolver: ComponentFactoryResolver =
|
||||||
|
|||||||
@@ -517,54 +517,59 @@ export class NoopNgZone implements NgZone {
|
|||||||
* for `NoopNgZone` which is always just an `Observable` of `true`. Additionally, we should consider
|
* for `NoopNgZone` which is always just an `Observable` of `true`. Additionally, we should consider
|
||||||
* whether the property on `NgZone` should be `Observable` or `Signal`.
|
* whether the property on `NgZone` should be `Observable` or `Signal`.
|
||||||
*/
|
*/
|
||||||
export const IS_STABLE =
|
export const ZONE_IS_STABLE_OBSERVABLE =
|
||||||
new InjectionToken<Observable<boolean>>(ngDevMode ? 'isStable Observable' : '', {
|
new InjectionToken<Observable<boolean>>(ngDevMode ? 'isStable Observable' : '', {
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
factory: () => {
|
// TODO(atscott): Replace this with a suitable default like `new
|
||||||
const zone = inject(NgZone);
|
// BehaviorSubject(true).asObservable`. Again, long term this won't exist on ApplicationRef at
|
||||||
let _stable = true;
|
// all but until we can remove it, we need a default value zoneless.
|
||||||
const isCurrentlyStable = new Observable<boolean>((observer: Observer<boolean>) => {
|
factory: isStableFactory,
|
||||||
_stable = zone.isStable && !zone.hasPendingMacrotasks && !zone.hasPendingMicrotasks;
|
});
|
||||||
zone.runOutsideAngular(() => {
|
|
||||||
observer.next(_stable);
|
export function isStableFactory() {
|
||||||
observer.complete();
|
const zone = inject(NgZone);
|
||||||
});
|
let _stable = true;
|
||||||
|
const isCurrentlyStable = new Observable<boolean>((observer: Observer<boolean>) => {
|
||||||
|
_stable = zone.isStable && !zone.hasPendingMacrotasks && !zone.hasPendingMicrotasks;
|
||||||
|
zone.runOutsideAngular(() => {
|
||||||
|
observer.next(_stable);
|
||||||
|
observer.complete();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const isStable = new Observable<boolean>((observer: Observer<boolean>) => {
|
||||||
|
// Create the subscription to onStable outside the Angular Zone so that
|
||||||
|
// the callback is run outside the Angular Zone.
|
||||||
|
let stableSub: Subscription;
|
||||||
|
zone.runOutsideAngular(() => {
|
||||||
|
stableSub = zone.onStable.subscribe(() => {
|
||||||
|
NgZone.assertNotInAngularZone();
|
||||||
|
|
||||||
|
// Check whether there are no pending macro/micro tasks in the next tick
|
||||||
|
// to allow for NgZone to update the state.
|
||||||
|
scheduleMicroTask(() => {
|
||||||
|
if (!_stable && !zone.hasPendingMacrotasks && !zone.hasPendingMicrotasks) {
|
||||||
|
_stable = true;
|
||||||
|
observer.next(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const isStable = new Observable<boolean>((observer: Observer<boolean>) => {
|
const unstableSub: Subscription = zone.onUnstable.subscribe(() => {
|
||||||
// Create the subscription to onStable outside the Angular Zone so that
|
NgZone.assertInAngularZone();
|
||||||
// the callback is run outside the Angular Zone.
|
if (_stable) {
|
||||||
let stableSub: Subscription;
|
_stable = false;
|
||||||
zone.runOutsideAngular(() => {
|
zone.runOutsideAngular(() => {
|
||||||
stableSub = zone.onStable.subscribe(() => {
|
observer.next(false);
|
||||||
NgZone.assertNotInAngularZone();
|
|
||||||
|
|
||||||
// Check whether there are no pending macro/micro tasks in the next tick
|
|
||||||
// to allow for NgZone to update the state.
|
|
||||||
scheduleMicroTask(() => {
|
|
||||||
if (!_stable && !zone.hasPendingMacrotasks && !zone.hasPendingMicrotasks) {
|
|
||||||
_stable = true;
|
|
||||||
observer.next(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const unstableSub: Subscription = zone.onUnstable.subscribe(() => {
|
|
||||||
NgZone.assertInAngularZone();
|
|
||||||
if (_stable) {
|
|
||||||
_stable = false;
|
|
||||||
zone.runOutsideAngular(() => {
|
|
||||||
observer.next(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
stableSub.unsubscribe();
|
|
||||||
unstableSub.unsubscribe();
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
return merge(isCurrentlyStable, isStable.pipe(share()));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
stableSub.unsubscribe();
|
||||||
|
unstableSub.unsubscribe();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return merge(isCurrentlyStable, isStable.pipe(share()));
|
||||||
|
}
|
||||||
|
|||||||
@@ -427,9 +427,7 @@ class SomeComponent {
|
|||||||
|
|
||||||
return defaultPlatform.bootstrapModule(EmptyModule)
|
return defaultPlatform.bootstrapModule(EmptyModule)
|
||||||
.then(() => fail('expecting error'), (error) => {
|
.then(() => fail('expecting error'), (error) => {
|
||||||
expect(error.message)
|
expect(error.message).toMatch(/NG0402/);
|
||||||
.toEqual(
|
|
||||||
'NG0402: No ErrorHandler. Is platform module (BrowserModule) included?');
|
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -260,6 +260,9 @@
|
|||||||
{
|
{
|
||||||
"name": "INJECTOR_SCOPE"
|
"name": "INJECTOR_SCOPE"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "INTERNAL_APPLICATION_ERROR_HANDLER"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "InjectFlags"
|
"name": "InjectFlags"
|
||||||
},
|
},
|
||||||
@@ -398,6 +401,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NgZone"
|
"name": "NgZone"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NgZoneChangeDetectionScheduler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NodeInjector"
|
"name": "NodeInjector"
|
||||||
},
|
},
|
||||||
@@ -587,6 +593,9 @@
|
|||||||
{
|
{
|
||||||
"name": "WebAnimationsStyleNormalizer"
|
"name": "WebAnimationsStyleNormalizer"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "_CACHED_BODY"
|
"name": "_CACHED_BODY"
|
||||||
},
|
},
|
||||||
@@ -884,6 +893,9 @@
|
|||||||
{
|
{
|
||||||
"name": "forEachSingleProvider"
|
"name": "forEachSingleProvider"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "formatRuntimeError"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "forwardRef"
|
"name": "forwardRef"
|
||||||
},
|
},
|
||||||
@@ -1157,6 +1169,9 @@
|
|||||||
{
|
{
|
||||||
"name": "isPromise2"
|
"name": "isPromise2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "isStableFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isTemplateNode"
|
"name": "isTemplateNode"
|
||||||
},
|
},
|
||||||
@@ -1238,6 +1253,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ngOnChangesSetInput"
|
"name": "ngOnChangesSetInput"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ngZoneApplicationErrorHandlerFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "noSideEffects"
|
"name": "noSideEffects"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -161,6 +161,9 @@
|
|||||||
{
|
{
|
||||||
"name": "INJECTOR_SCOPE"
|
"name": "INJECTOR_SCOPE"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "INTERNAL_APPLICATION_ERROR_HANDLER"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "InjectFlags"
|
"name": "InjectFlags"
|
||||||
},
|
},
|
||||||
@@ -293,6 +296,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NgZone"
|
"name": "NgZone"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NgZoneChangeDetectionScheduler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NodeInjector"
|
"name": "NodeInjector"
|
||||||
},
|
},
|
||||||
@@ -434,6 +440,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ViewRef"
|
"name": "ViewRef"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "_DOM"
|
"name": "_DOM"
|
||||||
},
|
},
|
||||||
@@ -647,6 +656,9 @@
|
|||||||
{
|
{
|
||||||
"name": "forEachSingleProvider"
|
"name": "forEachSingleProvider"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "formatRuntimeError"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "forwardRef"
|
"name": "forwardRef"
|
||||||
},
|
},
|
||||||
@@ -890,6 +902,9 @@
|
|||||||
{
|
{
|
||||||
"name": "isPromise2"
|
"name": "isPromise2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "isStableFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isTemplateNode"
|
"name": "isTemplateNode"
|
||||||
},
|
},
|
||||||
@@ -953,6 +968,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ngOnChangesSetInput"
|
"name": "ngOnChangesSetInput"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ngZoneApplicationErrorHandlerFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "noSideEffects"
|
"name": "noSideEffects"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -236,6 +236,9 @@
|
|||||||
{
|
{
|
||||||
"name": "INJECTOR_SCOPE"
|
"name": "INJECTOR_SCOPE"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "INTERNAL_APPLICATION_ERROR_HANDLER"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "InjectFlags"
|
"name": "InjectFlags"
|
||||||
},
|
},
|
||||||
@@ -404,6 +407,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NgZone"
|
"name": "NgZone"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NgZoneChangeDetectionScheduler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NodeInjector"
|
"name": "NodeInjector"
|
||||||
},
|
},
|
||||||
@@ -596,6 +602,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ViewRef"
|
"name": "ViewRef"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "_DOM"
|
"name": "_DOM"
|
||||||
},
|
},
|
||||||
@@ -911,6 +920,9 @@
|
|||||||
{
|
{
|
||||||
"name": "formGroupNameProvider"
|
"name": "formGroupNameProvider"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "formatRuntimeError"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "forwardRef"
|
"name": "forwardRef"
|
||||||
},
|
},
|
||||||
@@ -1253,6 +1265,9 @@
|
|||||||
{
|
{
|
||||||
"name": "isPromise2"
|
"name": "isPromise2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "isStableFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isStylingMatch"
|
"name": "isStylingMatch"
|
||||||
},
|
},
|
||||||
@@ -1379,6 +1394,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ngOnChangesSetInput"
|
"name": "ngOnChangesSetInput"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ngZoneApplicationErrorHandlerFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "noSideEffects"
|
"name": "noSideEffects"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -221,6 +221,9 @@
|
|||||||
{
|
{
|
||||||
"name": "INJECTOR_SCOPE"
|
"name": "INJECTOR_SCOPE"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "INTERNAL_APPLICATION_ERROR_HANDLER"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "InjectFlags"
|
"name": "InjectFlags"
|
||||||
},
|
},
|
||||||
@@ -395,6 +398,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NgZone"
|
"name": "NgZone"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NgZoneChangeDetectionScheduler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NodeInjector"
|
"name": "NodeInjector"
|
||||||
},
|
},
|
||||||
@@ -587,6 +593,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ViewRef"
|
"name": "ViewRef"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "_DOM"
|
"name": "_DOM"
|
||||||
},
|
},
|
||||||
@@ -878,6 +887,9 @@
|
|||||||
{
|
{
|
||||||
"name": "formDirectiveProvider"
|
"name": "formDirectiveProvider"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "formatRuntimeError"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "forwardRef"
|
"name": "forwardRef"
|
||||||
},
|
},
|
||||||
@@ -1211,6 +1223,9 @@
|
|||||||
{
|
{
|
||||||
"name": "isPromise2"
|
"name": "isPromise2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "isStableFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isStylingMatch"
|
"name": "isStylingMatch"
|
||||||
},
|
},
|
||||||
@@ -1343,6 +1358,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ngOnChangesSetInput"
|
"name": "ngOnChangesSetInput"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ngZoneApplicationErrorHandlerFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "noSideEffects"
|
"name": "noSideEffects"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -110,6 +110,9 @@
|
|||||||
{
|
{
|
||||||
"name": "INJECTOR_SCOPE"
|
"name": "INJECTOR_SCOPE"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "INTERNAL_APPLICATION_ERROR_HANDLER"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "InjectFlags"
|
"name": "InjectFlags"
|
||||||
},
|
},
|
||||||
@@ -152,6 +155,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NG_COMP_DEF"
|
"name": "NG_COMP_DEF"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NG_DIR_DEF"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NG_ELEMENT_ID"
|
"name": "NG_ELEMENT_ID"
|
||||||
},
|
},
|
||||||
@@ -173,6 +179,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NG_MOD_DEF"
|
"name": "NG_MOD_DEF"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NG_PIPE_DEF"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NG_PROV_DEF"
|
"name": "NG_PROV_DEF"
|
||||||
},
|
},
|
||||||
@@ -221,6 +230,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NgZone"
|
"name": "NgZone"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NgZoneChangeDetectionScheduler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NodeInjector"
|
"name": "NodeInjector"
|
||||||
},
|
},
|
||||||
@@ -332,6 +344,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ViewRef"
|
"name": "ViewRef"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "_DOM"
|
"name": "_DOM"
|
||||||
},
|
},
|
||||||
@@ -494,6 +509,9 @@
|
|||||||
{
|
{
|
||||||
"name": "forEachSingleProvider"
|
"name": "forEachSingleProvider"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "formatRuntimeError"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "forwardRef"
|
"name": "forwardRef"
|
||||||
},
|
},
|
||||||
@@ -683,6 +701,9 @@
|
|||||||
{
|
{
|
||||||
"name": "isPromise2"
|
"name": "isPromise2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "isStableFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isTypeProvider"
|
"name": "isTypeProvider"
|
||||||
},
|
},
|
||||||
@@ -731,6 +752,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ngOnChangesSetInput"
|
"name": "ngOnChangesSetInput"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ngZoneApplicationErrorHandlerFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "noop"
|
"name": "noop"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -275,6 +275,9 @@
|
|||||||
{
|
{
|
||||||
"name": "INJECTOR_SCOPE"
|
"name": "INJECTOR_SCOPE"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "INTERNAL_APPLICATION_ERROR_HANDLER"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "INTERNAL_BROWSER_PLATFORM_PROVIDERS"
|
"name": "INTERNAL_BROWSER_PLATFORM_PROVIDERS"
|
||||||
},
|
},
|
||||||
@@ -467,6 +470,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NgZone"
|
"name": "NgZone"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NgZoneChangeDetectionScheduler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NoMatch"
|
"name": "NoMatch"
|
||||||
},
|
},
|
||||||
@@ -800,6 +806,9 @@
|
|||||||
{
|
{
|
||||||
"name": "XSS_SECURITY_URL"
|
"name": "XSS_SECURITY_URL"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "_DOM"
|
"name": "_DOM"
|
||||||
},
|
},
|
||||||
@@ -1562,6 +1571,9 @@
|
|||||||
{
|
{
|
||||||
"name": "isScheduler"
|
"name": "isScheduler"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "isStableFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isTemplateNode"
|
"name": "isTemplateNode"
|
||||||
},
|
},
|
||||||
@@ -1682,6 +1694,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ngOnChangesSetInput"
|
"name": "ngOnChangesSetInput"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ngZoneApplicationErrorHandlerFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "noLeftoversInUrl"
|
"name": "noLeftoversInUrl"
|
||||||
},
|
},
|
||||||
@@ -1748,6 +1763,9 @@
|
|||||||
{
|
{
|
||||||
"name": "promise"
|
"name": "promise"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "provideNgZoneChangeDetection"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "redirectIfUrlTree"
|
"name": "redirectIfUrlTree"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -146,6 +146,9 @@
|
|||||||
{
|
{
|
||||||
"name": "INJECTOR_SCOPE"
|
"name": "INJECTOR_SCOPE"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "INTERNAL_APPLICATION_ERROR_HANDLER"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "INTERNAL_BROWSER_PLATFORM_PROVIDERS"
|
"name": "INTERNAL_BROWSER_PLATFORM_PROVIDERS"
|
||||||
},
|
},
|
||||||
@@ -266,6 +269,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NgZone"
|
"name": "NgZone"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NgZoneChangeDetectionScheduler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NodeInjector"
|
"name": "NodeInjector"
|
||||||
},
|
},
|
||||||
@@ -395,6 +401,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ViewRef"
|
"name": "ViewRef"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "_DOM"
|
"name": "_DOM"
|
||||||
},
|
},
|
||||||
@@ -788,6 +797,9 @@
|
|||||||
{
|
{
|
||||||
"name": "isPromise2"
|
"name": "isPromise2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "isStableFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isTemplateNode"
|
"name": "isTemplateNode"
|
||||||
},
|
},
|
||||||
@@ -845,6 +857,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ngOnChangesSetInput"
|
"name": "ngOnChangesSetInput"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ngZoneApplicationErrorHandlerFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "nonNull"
|
"name": "nonNull"
|
||||||
},
|
},
|
||||||
@@ -872,6 +887,9 @@
|
|||||||
{
|
{
|
||||||
"name": "promise"
|
"name": "promise"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "provideNgZoneChangeDetection"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "refCount"
|
"name": "refCount"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -164,6 +164,9 @@
|
|||||||
{
|
{
|
||||||
"name": "INJECTOR_SCOPE"
|
"name": "INJECTOR_SCOPE"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "INTERNAL_APPLICATION_ERROR_HANDLER"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "InjectFlags"
|
"name": "InjectFlags"
|
||||||
},
|
},
|
||||||
@@ -308,6 +311,9 @@
|
|||||||
{
|
{
|
||||||
"name": "NgZone"
|
"name": "NgZone"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "NgZoneChangeDetectionScheduler"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "NodeInjector"
|
"name": "NodeInjector"
|
||||||
},
|
},
|
||||||
@@ -509,6 +515,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ViewRef"
|
"name": "ViewRef"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ZONE_IS_STABLE_OBSERVABLE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "_DOM"
|
"name": "_DOM"
|
||||||
},
|
},
|
||||||
@@ -770,6 +779,9 @@
|
|||||||
{
|
{
|
||||||
"name": "forEachSingleProvider"
|
"name": "forEachSingleProvider"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "formatRuntimeError"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "forwardRef"
|
"name": "forwardRef"
|
||||||
},
|
},
|
||||||
@@ -1067,6 +1079,9 @@
|
|||||||
{
|
{
|
||||||
"name": "isPromise2"
|
"name": "isPromise2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "isStableFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "isStylingMatch"
|
"name": "isStylingMatch"
|
||||||
},
|
},
|
||||||
@@ -1163,6 +1178,9 @@
|
|||||||
{
|
{
|
||||||
"name": "ngOnChangesSetInput"
|
"name": "ngOnChangesSetInput"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "ngZoneApplicationErrorHandlerFactory"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "noSideEffects"
|
"name": "noSideEffects"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {ResourceLoader} from '@angular/compiler';
|
import {ResourceLoader} from '@angular/compiler';
|
||||||
import {ApplicationInitStatus, Compiler, COMPILER_OPTIONS, Component, Directive, Injector, InjectorType, LOCALE_ID, ModuleWithComponentFactories, ModuleWithProviders, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, resolveForwardRef, Type, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵDirectiveDef as DirectiveDef, ɵgetInjectableDef as getInjectableDef, ɵInternalEnvironmentProviders as InternalEnvironmentProviders, ɵisEnvironmentProviders as isEnvironmentProviders, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIR_DEF as NG_DIR_DEF, ɵNG_INJ_DEF as NG_INJ_DEF, ɵNG_MOD_DEF as NG_MOD_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵNgModuleType as NgModuleType, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor, ɵɵInjectableDeclaration as InjectableDeclaration} from '@angular/core';
|
import {ApplicationInitStatus, Compiler, COMPILER_OPTIONS, Component, Directive, Injector, InjectorType, LOCALE_ID, ModuleWithComponentFactories, ModuleWithProviders, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, resolveForwardRef, Type, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵDirectiveDef as DirectiveDef, ɵgetInjectableDef as getInjectableDef, ɵInternalEnvironmentProviders as InternalEnvironmentProviders, ɵisEnvironmentProviders as isEnvironmentProviders, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIR_DEF as NG_DIR_DEF, ɵNG_INJ_DEF as NG_INJ_DEF, ɵNG_MOD_DEF as NG_MOD_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵNgModuleType as NgModuleType, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵprovideNgZoneChangeDetection as provideNgZoneChangeDetection, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor, ɵɵInjectableDeclaration as InjectableDeclaration} from '@angular/core';
|
||||||
|
|
||||||
import {clearResolutionOfComponentResourcesQueue, isComponentDefPendingResolution, resolveComponentResources, restoreComponentResolutionQueue} from '../../src/metadata/resource_loading';
|
import {clearResolutionOfComponentResourcesQueue, isComponentDefPendingResolution, resolveComponentResources, restoreComponentResolutionQueue} from '../../src/metadata/resource_loading';
|
||||||
import {ComponentDef, ComponentType} from '../../src/render3';
|
import {ComponentDef, ComponentType} from '../../src/render3';
|
||||||
@@ -287,7 +287,7 @@ export class TestBedCompiler {
|
|||||||
this.componentToModuleScope.clear();
|
this.componentToModuleScope.clear();
|
||||||
|
|
||||||
const parentInjector = this.platform.injector;
|
const parentInjector = this.platform.injector;
|
||||||
this.testModuleRef = new NgModuleRef(this.testModuleType, parentInjector);
|
this.testModuleRef = new NgModuleRef(this.testModuleType, parentInjector, []);
|
||||||
|
|
||||||
// ApplicationInitStatus.runInitializers() is marked @internal to core.
|
// ApplicationInitStatus.runInitializers() is marked @internal to core.
|
||||||
// Cast it to any before accessing it.
|
// Cast it to any before accessing it.
|
||||||
@@ -748,7 +748,7 @@ export class TestBedCompiler {
|
|||||||
|
|
||||||
const ngZone = new NgZone({enableLongStackTrace: true});
|
const ngZone = new NgZone({enableLongStackTrace: true});
|
||||||
const providers: Provider[] = [
|
const providers: Provider[] = [
|
||||||
{provide: NgZone, useValue: ngZone},
|
provideNgZoneChangeDetection(ngZone),
|
||||||
{provide: Compiler, useFactory: () => new R3TestCompiler(this)},
|
{provide: Compiler, useFactory: () => new R3TestCompiler(this)},
|
||||||
...this.providers,
|
...this.providers,
|
||||||
...this.providerOverrides,
|
...this.providerOverrides,
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ function bootstrap(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if no provider', done => {
|
it('should throw if no provider', async () => {
|
||||||
const logger = new MockConsole();
|
const logger = new MockConsole();
|
||||||
const errorHandler = new ErrorHandler();
|
const errorHandler = new ErrorHandler();
|
||||||
(errorHandler as any)._console = logger as any;
|
(errorHandler as any)._console = logger as any;
|
||||||
@@ -460,14 +460,9 @@ function bootstrap(
|
|||||||
class CustomModule {
|
class CustomModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap(RootCmp, [{provide: ErrorHandler, useValue: errorHandler}], [], [
|
await expectAsync(bootstrap(RootCmp, [{provide: ErrorHandler, useValue: errorHandler}], [], [
|
||||||
CustomModule
|
CustomModule
|
||||||
]).then(null, (e: Error) => {
|
])).toBeRejected();
|
||||||
const errorMsg = `R3InjectorError(TestModule)[IDontExist -> IDontExist -> IDontExist]: \n`;
|
|
||||||
expect(e.message).toContain(errorMsg);
|
|
||||||
done();
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (getDOM().supportsDOMEvents) {
|
if (getDOM().supportsDOMEvents) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
import {PlatformLocation} from '@angular/common';
|
import {PlatformLocation} from '@angular/common';
|
||||||
import {MockPlatformLocation} from '@angular/common/testing';
|
import {MockPlatformLocation} from '@angular/common/testing';
|
||||||
import {APP_ID, createPlatformFactory, NgModule, NgZone, PLATFORM_INITIALIZER, platformCore, StaticProvider} from '@angular/core';
|
import {APP_ID, createPlatformFactory, NgModule, PLATFORM_INITIALIZER, platformCore, StaticProvider, ɵprovideNgZoneChangeDetection as provideNgZoneChangeDetection} from '@angular/core';
|
||||||
import {BrowserModule, ɵBrowserDomAdapter as BrowserDomAdapter} from '@angular/platform-browser';
|
import {BrowserModule, ɵBrowserDomAdapter as BrowserDomAdapter} from '@angular/platform-browser';
|
||||||
|
|
||||||
import {BrowserDetection, createNgZone} from './browser_util';
|
import {BrowserDetection, createNgZone} from './browser_util';
|
||||||
@@ -37,7 +37,7 @@ export const platformBrowserTesting =
|
|||||||
exports: [BrowserModule],
|
exports: [BrowserModule],
|
||||||
providers: [
|
providers: [
|
||||||
{provide: APP_ID, useValue: 'a'},
|
{provide: APP_ID, useValue: 'a'},
|
||||||
{provide: NgZone, useFactory: createNgZone},
|
provideNgZoneChangeDetection(createNgZone()),
|
||||||
{provide: PlatformLocation, useClass: MockPlatformLocation},
|
{provide: PlatformLocation, useClass: MockPlatformLocation},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user