1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import './util/ng_jit_mode';
|
---|
9 | import { merge, Observable } from 'rxjs';
|
---|
10 | import { share } from 'rxjs/operators';
|
---|
11 | import { ApplicationInitStatus } from './application_init';
|
---|
12 | import { APP_BOOTSTRAP_LISTENER, PLATFORM_INITIALIZER } from './application_tokens';
|
---|
13 | import { getCompilerFacade } from './compiler/compiler_facade';
|
---|
14 | import { Console } from './console';
|
---|
15 | import { Injectable } from './di/injectable';
|
---|
16 | import { InjectionToken } from './di/injection_token';
|
---|
17 | import { Injector } from './di/injector';
|
---|
18 | import { INJECTOR_SCOPE } from './di/scope';
|
---|
19 | import { ErrorHandler } from './error_handler';
|
---|
20 | import { DEFAULT_LOCALE_ID } from './i18n/localization';
|
---|
21 | import { LOCALE_ID } from './i18n/tokens';
|
---|
22 | import { ivyEnabled } from './ivy_switch';
|
---|
23 | import { COMPILER_OPTIONS, CompilerFactory } from './linker/compiler';
|
---|
24 | import { ComponentFactory } from './linker/component_factory';
|
---|
25 | import { ComponentFactoryBoundToModule, ComponentFactoryResolver } from './linker/component_factory_resolver';
|
---|
26 | import { NgModuleRef } from './linker/ng_module_factory';
|
---|
27 | import { isComponentResourceResolutionQueueEmpty, resolveComponentResources } from './metadata/resource_loading';
|
---|
28 | import { assertNgModuleType } from './render3/assert';
|
---|
29 | import { setLocaleId } from './render3/i18n/i18n_locale_id';
|
---|
30 | import { setJitOptions } from './render3/jit/jit_options';
|
---|
31 | import { NgModuleFactory as R3NgModuleFactory } from './render3/ng_module_ref';
|
---|
32 | import { publishDefaultGlobalUtils as _publishDefaultGlobalUtils } from './render3/util/global_utils';
|
---|
33 | import { Testability, TestabilityRegistry } from './testability/testability';
|
---|
34 | import { isDevMode } from './util/is_dev_mode';
|
---|
35 | import { isPromise } from './util/lang';
|
---|
36 | import { scheduleMicroTask } from './util/microtask';
|
---|
37 | import { stringify } from './util/stringify';
|
---|
38 | import { NgZone, NoopNgZone } from './zone/ng_zone';
|
---|
39 | let _platform;
|
---|
40 | let compileNgModuleFactory = compileNgModuleFactory__PRE_R3__;
|
---|
41 | function compileNgModuleFactory__PRE_R3__(injector, options, moduleType) {
|
---|
42 | const compilerFactory = injector.get(CompilerFactory);
|
---|
43 | const compiler = compilerFactory.createCompiler([options]);
|
---|
44 | return compiler.compileModuleAsync(moduleType);
|
---|
45 | }
|
---|
46 | export function compileNgModuleFactory__POST_R3__(injector, options, moduleType) {
|
---|
47 | ngDevMode && assertNgModuleType(moduleType);
|
---|
48 | const moduleFactory = new R3NgModuleFactory(moduleType);
|
---|
49 | // All of the logic below is irrelevant for AOT-compiled code.
|
---|
50 | if (typeof ngJitMode !== 'undefined' && !ngJitMode) {
|
---|
51 | return Promise.resolve(moduleFactory);
|
---|
52 | }
|
---|
53 | const compilerOptions = injector.get(COMPILER_OPTIONS, []).concat(options);
|
---|
54 | // Configure the compiler to use the provided options. This call may fail when multiple modules
|
---|
55 | // are bootstrapped with incompatible options, as a component can only be compiled according to
|
---|
56 | // a single set of options.
|
---|
57 | setJitOptions({
|
---|
58 | defaultEncapsulation: _lastDefined(compilerOptions.map(opts => opts.defaultEncapsulation)),
|
---|
59 | preserveWhitespaces: _lastDefined(compilerOptions.map(opts => opts.preserveWhitespaces)),
|
---|
60 | });
|
---|
61 | if (isComponentResourceResolutionQueueEmpty()) {
|
---|
62 | return Promise.resolve(moduleFactory);
|
---|
63 | }
|
---|
64 | const compilerProviders = _mergeArrays(compilerOptions.map(o => o.providers));
|
---|
65 | // In case there are no compiler providers, we just return the module factory as
|
---|
66 | // there won't be any resource loader. This can happen with Ivy, because AOT compiled
|
---|
67 | // modules can be still passed through "bootstrapModule". In that case we shouldn't
|
---|
68 | // unnecessarily require the JIT compiler.
|
---|
69 | if (compilerProviders.length === 0) {
|
---|
70 | return Promise.resolve(moduleFactory);
|
---|
71 | }
|
---|
72 | const compiler = getCompilerFacade({
|
---|
73 | usage: 0 /* Decorator */,
|
---|
74 | kind: 'NgModule',
|
---|
75 | type: moduleType,
|
---|
76 | });
|
---|
77 | const compilerInjector = Injector.create({ providers: compilerProviders });
|
---|
78 | const resourceLoader = compilerInjector.get(compiler.ResourceLoader);
|
---|
79 | // The resource loader can also return a string while the "resolveComponentResources"
|
---|
80 | // always expects a promise. Therefore we need to wrap the returned value in a promise.
|
---|
81 | return resolveComponentResources(url => Promise.resolve(resourceLoader.get(url)))
|
---|
82 | .then(() => moduleFactory);
|
---|
83 | }
|
---|
84 | // the `window.ng` global utilities are only available in non-VE versions of
|
---|
85 | // Angular. The function switch below will make sure that the code is not
|
---|
86 | // included into Angular when PRE mode is active.
|
---|
87 | export function publishDefaultGlobalUtils__PRE_R3__() { }
|
---|
88 | export function publishDefaultGlobalUtils__POST_R3__() {
|
---|
89 | ngDevMode && _publishDefaultGlobalUtils();
|
---|
90 | }
|
---|
91 | let publishDefaultGlobalUtils = publishDefaultGlobalUtils__PRE_R3__;
|
---|
92 | let isBoundToModule = isBoundToModule__PRE_R3__;
|
---|
93 | export function isBoundToModule__PRE_R3__(cf) {
|
---|
94 | return cf instanceof ComponentFactoryBoundToModule;
|
---|
95 | }
|
---|
96 | export function isBoundToModule__POST_R3__(cf) {
|
---|
97 | return cf.isBoundToModule;
|
---|
98 | }
|
---|
99 | export const ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
|
---|
100 | /**
|
---|
101 | * A token for third-party components that can register themselves with NgProbe.
|
---|
102 | *
|
---|
103 | * @publicApi
|
---|
104 | */
|
---|
105 | export class NgProbeToken {
|
---|
106 | constructor(name, token) {
|
---|
107 | this.name = name;
|
---|
108 | this.token = token;
|
---|
109 | }
|
---|
110 | }
|
---|
111 | /**
|
---|
112 | * Creates a platform.
|
---|
113 | * Platforms must be created on launch using this function.
|
---|
114 | *
|
---|
115 | * @publicApi
|
---|
116 | */
|
---|
117 | export function createPlatform(injector) {
|
---|
118 | if (_platform && !_platform.destroyed &&
|
---|
119 | !_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
|
---|
120 | throw new Error('There can be only one platform. Destroy the previous one to create a new one.');
|
---|
121 | }
|
---|
122 | publishDefaultGlobalUtils();
|
---|
123 | _platform = injector.get(PlatformRef);
|
---|
124 | const inits = injector.get(PLATFORM_INITIALIZER, null);
|
---|
125 | if (inits)
|
---|
126 | inits.forEach((init) => init());
|
---|
127 | return _platform;
|
---|
128 | }
|
---|
129 | /**
|
---|
130 | * Creates a factory for a platform. Can be used to provide or override `Providers` specific to
|
---|
131 | * your application's runtime needs, such as `PLATFORM_INITIALIZER` and `PLATFORM_ID`.
|
---|
132 | * @param parentPlatformFactory Another platform factory to modify. Allows you to compose factories
|
---|
133 | * to build up configurations that might be required by different libraries or parts of the
|
---|
134 | * application.
|
---|
135 | * @param name Identifies the new platform factory.
|
---|
136 | * @param providers A set of dependency providers for platforms created with the new factory.
|
---|
137 | *
|
---|
138 | * @publicApi
|
---|
139 | */
|
---|
140 | export function createPlatformFactory(parentPlatformFactory, name, providers = []) {
|
---|
141 | const desc = `Platform: ${name}`;
|
---|
142 | const marker = new InjectionToken(desc);
|
---|
143 | return (extraProviders = []) => {
|
---|
144 | let platform = getPlatform();
|
---|
145 | if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
|
---|
146 | if (parentPlatformFactory) {
|
---|
147 | parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
|
---|
148 | }
|
---|
149 | else {
|
---|
150 | const injectedProviders = providers.concat(extraProviders).concat({ provide: marker, useValue: true }, {
|
---|
151 | provide: INJECTOR_SCOPE,
|
---|
152 | useValue: 'platform'
|
---|
153 | });
|
---|
154 | createPlatform(Injector.create({ providers: injectedProviders, name: desc }));
|
---|
155 | }
|
---|
156 | }
|
---|
157 | return assertPlatform(marker);
|
---|
158 | };
|
---|
159 | }
|
---|
160 | /**
|
---|
161 | * Checks that there is currently a platform that contains the given token as a provider.
|
---|
162 | *
|
---|
163 | * @publicApi
|
---|
164 | */
|
---|
165 | export function assertPlatform(requiredToken) {
|
---|
166 | const platform = getPlatform();
|
---|
167 | if (!platform) {
|
---|
168 | throw new Error('No platform exists!');
|
---|
169 | }
|
---|
170 | if (!platform.injector.get(requiredToken, null)) {
|
---|
171 | throw new Error('A platform with a different configuration has been created. Please destroy it first.');
|
---|
172 | }
|
---|
173 | return platform;
|
---|
174 | }
|
---|
175 | /**
|
---|
176 | * Destroys the current Angular platform and all Angular applications on the page.
|
---|
177 | * Destroys all modules and listeners registered with the platform.
|
---|
178 | *
|
---|
179 | * @publicApi
|
---|
180 | */
|
---|
181 | export function destroyPlatform() {
|
---|
182 | if (_platform && !_platform.destroyed) {
|
---|
183 | _platform.destroy();
|
---|
184 | }
|
---|
185 | }
|
---|
186 | /**
|
---|
187 | * Returns the current platform.
|
---|
188 | *
|
---|
189 | * @publicApi
|
---|
190 | */
|
---|
191 | export function getPlatform() {
|
---|
192 | return _platform && !_platform.destroyed ? _platform : null;
|
---|
193 | }
|
---|
194 | /**
|
---|
195 | * The Angular platform is the entry point for Angular on a web page.
|
---|
196 | * Each page has exactly one platform. Services (such as reflection) which are common
|
---|
197 | * to every Angular application running on the page are bound in its scope.
|
---|
198 | * A page's platform is initialized implicitly when a platform is created using a platform
|
---|
199 | * factory such as `PlatformBrowser`, or explicitly by calling the `createPlatform()` function.
|
---|
200 | *
|
---|
201 | * @publicApi
|
---|
202 | */
|
---|
203 | export class PlatformRef {
|
---|
204 | /** @internal */
|
---|
205 | constructor(_injector) {
|
---|
206 | this._injector = _injector;
|
---|
207 | this._modules = [];
|
---|
208 | this._destroyListeners = [];
|
---|
209 | this._destroyed = false;
|
---|
210 | }
|
---|
211 | /**
|
---|
212 | * Creates an instance of an `@NgModule` for the given platform for offline compilation.
|
---|
213 | *
|
---|
214 | * @usageNotes
|
---|
215 | *
|
---|
216 | * The following example creates the NgModule for a browser platform.
|
---|
217 | *
|
---|
218 | * ```typescript
|
---|
219 | * my_module.ts:
|
---|
220 | *
|
---|
221 | * @NgModule({
|
---|
222 | * imports: [BrowserModule]
|
---|
223 | * })
|
---|
224 | * class MyModule {}
|
---|
225 | *
|
---|
226 | * main.ts:
|
---|
227 | * import {MyModuleNgFactory} from './my_module.ngfactory';
|
---|
228 | * import {platformBrowser} from '@angular/platform-browser';
|
---|
229 | *
|
---|
230 | * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
|
---|
231 | * ```
|
---|
232 | */
|
---|
233 | bootstrapModuleFactory(moduleFactory, options) {
|
---|
234 | // Note: We need to create the NgZone _before_ we instantiate the module,
|
---|
235 | // as instantiating the module creates some providers eagerly.
|
---|
236 | // So we create a mini parent injector that just contains the new NgZone and
|
---|
237 | // pass that as parent to the NgModuleFactory.
|
---|
238 | const ngZoneOption = options ? options.ngZone : undefined;
|
---|
239 | const ngZoneEventCoalescing = (options && options.ngZoneEventCoalescing) || false;
|
---|
240 | const ngZoneRunCoalescing = (options && options.ngZoneRunCoalescing) || false;
|
---|
241 | const ngZone = getNgZone(ngZoneOption, { ngZoneEventCoalescing, ngZoneRunCoalescing });
|
---|
242 | const providers = [{ provide: NgZone, useValue: ngZone }];
|
---|
243 | // Note: Create ngZoneInjector within ngZone.run so that all of the instantiated services are
|
---|
244 | // created within the Angular zone
|
---|
245 | // Do not try to replace ngZone.run with ApplicationRef#run because ApplicationRef would then be
|
---|
246 | // created outside of the Angular zone.
|
---|
247 | return ngZone.run(() => {
|
---|
248 | const ngZoneInjector = Injector.create({ providers: providers, parent: this.injector, name: moduleFactory.moduleType.name });
|
---|
249 | const moduleRef = moduleFactory.create(ngZoneInjector);
|
---|
250 | const exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
|
---|
251 | if (!exceptionHandler) {
|
---|
252 | throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
|
---|
253 | }
|
---|
254 | ngZone.runOutsideAngular(() => {
|
---|
255 | const subscription = ngZone.onError.subscribe({
|
---|
256 | next: (error) => {
|
---|
257 | exceptionHandler.handleError(error);
|
---|
258 | }
|
---|
259 | });
|
---|
260 | moduleRef.onDestroy(() => {
|
---|
261 | remove(this._modules, moduleRef);
|
---|
262 | subscription.unsubscribe();
|
---|
263 | });
|
---|
264 | });
|
---|
265 | return _callAndReportToErrorHandler(exceptionHandler, ngZone, () => {
|
---|
266 | const initStatus = moduleRef.injector.get(ApplicationInitStatus);
|
---|
267 | initStatus.runInitializers();
|
---|
268 | return initStatus.donePromise.then(() => {
|
---|
269 | if (ivyEnabled) {
|
---|
270 | // If the `LOCALE_ID` provider is defined at bootstrap then we set the value for ivy
|
---|
271 | const localeId = moduleRef.injector.get(LOCALE_ID, DEFAULT_LOCALE_ID);
|
---|
272 | setLocaleId(localeId || DEFAULT_LOCALE_ID);
|
---|
273 | }
|
---|
274 | this._moduleDoBootstrap(moduleRef);
|
---|
275 | return moduleRef;
|
---|
276 | });
|
---|
277 | });
|
---|
278 | });
|
---|
279 | }
|
---|
280 | /**
|
---|
281 | * Creates an instance of an `@NgModule` for a given platform using the given runtime compiler.
|
---|
282 | *
|
---|
283 | * @usageNotes
|
---|
284 | * ### Simple Example
|
---|
285 | *
|
---|
286 | * ```typescript
|
---|
287 | * @NgModule({
|
---|
288 | * imports: [BrowserModule]
|
---|
289 | * })
|
---|
290 | * class MyModule {}
|
---|
291 | *
|
---|
292 | * let moduleRef = platformBrowser().bootstrapModule(MyModule);
|
---|
293 | * ```
|
---|
294 | *
|
---|
295 | */
|
---|
296 | bootstrapModule(moduleType, compilerOptions = []) {
|
---|
297 | const options = optionsReducer({}, compilerOptions);
|
---|
298 | return compileNgModuleFactory(this.injector, options, moduleType)
|
---|
299 | .then(moduleFactory => this.bootstrapModuleFactory(moduleFactory, options));
|
---|
300 | }
|
---|
301 | _moduleDoBootstrap(moduleRef) {
|
---|
302 | const appRef = moduleRef.injector.get(ApplicationRef);
|
---|
303 | if (moduleRef._bootstrapComponents.length > 0) {
|
---|
304 | moduleRef._bootstrapComponents.forEach(f => appRef.bootstrap(f));
|
---|
305 | }
|
---|
306 | else if (moduleRef.instance.ngDoBootstrap) {
|
---|
307 | moduleRef.instance.ngDoBootstrap(appRef);
|
---|
308 | }
|
---|
309 | else {
|
---|
310 | throw new Error(`The module ${stringify(moduleRef.instance
|
---|
311 | .constructor)} was bootstrapped, but it does not declare "@NgModule.bootstrap" components nor a "ngDoBootstrap" method. ` +
|
---|
312 | `Please define one of these.`);
|
---|
313 | }
|
---|
314 | this._modules.push(moduleRef);
|
---|
315 | }
|
---|
316 | /**
|
---|
317 | * Registers a listener to be called when the platform is destroyed.
|
---|
318 | */
|
---|
319 | onDestroy(callback) {
|
---|
320 | this._destroyListeners.push(callback);
|
---|
321 | }
|
---|
322 | /**
|
---|
323 | * Retrieves the platform {@link Injector}, which is the parent injector for
|
---|
324 | * every Angular application on the page and provides singleton providers.
|
---|
325 | */
|
---|
326 | get injector() {
|
---|
327 | return this._injector;
|
---|
328 | }
|
---|
329 | /**
|
---|
330 | * Destroys the current Angular platform and all Angular applications on the page.
|
---|
331 | * Destroys all modules and listeners registered with the platform.
|
---|
332 | */
|
---|
333 | destroy() {
|
---|
334 | if (this._destroyed) {
|
---|
335 | throw new Error('The platform has already been destroyed!');
|
---|
336 | }
|
---|
337 | this._modules.slice().forEach(module => module.destroy());
|
---|
338 | this._destroyListeners.forEach(listener => listener());
|
---|
339 | this._destroyed = true;
|
---|
340 | }
|
---|
341 | get destroyed() {
|
---|
342 | return this._destroyed;
|
---|
343 | }
|
---|
344 | }
|
---|
345 | PlatformRef.decorators = [
|
---|
346 | { type: Injectable }
|
---|
347 | ];
|
---|
348 | PlatformRef.ctorParameters = () => [
|
---|
349 | { type: Injector }
|
---|
350 | ];
|
---|
351 | function getNgZone(ngZoneOption, extra) {
|
---|
352 | let ngZone;
|
---|
353 | if (ngZoneOption === 'noop') {
|
---|
354 | ngZone = new NoopNgZone();
|
---|
355 | }
|
---|
356 | else {
|
---|
357 | ngZone = (ngZoneOption === 'zone.js' ? undefined : ngZoneOption) || new NgZone({
|
---|
358 | enableLongStackTrace: isDevMode(),
|
---|
359 | shouldCoalesceEventChangeDetection: !!(extra === null || extra === void 0 ? void 0 : extra.ngZoneEventCoalescing),
|
---|
360 | shouldCoalesceRunChangeDetection: !!(extra === null || extra === void 0 ? void 0 : extra.ngZoneRunCoalescing)
|
---|
361 | });
|
---|
362 | }
|
---|
363 | return ngZone;
|
---|
364 | }
|
---|
365 | function _callAndReportToErrorHandler(errorHandler, ngZone, callback) {
|
---|
366 | try {
|
---|
367 | const result = callback();
|
---|
368 | if (isPromise(result)) {
|
---|
369 | return result.catch((e) => {
|
---|
370 | ngZone.runOutsideAngular(() => errorHandler.handleError(e));
|
---|
371 | // rethrow as the exception handler might not do it
|
---|
372 | throw e;
|
---|
373 | });
|
---|
374 | }
|
---|
375 | return result;
|
---|
376 | }
|
---|
377 | catch (e) {
|
---|
378 | ngZone.runOutsideAngular(() => errorHandler.handleError(e));
|
---|
379 | // rethrow as the exception handler might not do it
|
---|
380 | throw e;
|
---|
381 | }
|
---|
382 | }
|
---|
383 | function optionsReducer(dst, objs) {
|
---|
384 | if (Array.isArray(objs)) {
|
---|
385 | dst = objs.reduce(optionsReducer, dst);
|
---|
386 | }
|
---|
387 | else {
|
---|
388 | dst = Object.assign(Object.assign({}, dst), objs);
|
---|
389 | }
|
---|
390 | return dst;
|
---|
391 | }
|
---|
392 | /**
|
---|
393 | * A reference to an Angular application running on a page.
|
---|
394 | *
|
---|
395 | * @usageNotes
|
---|
396 | *
|
---|
397 | * {@a is-stable-examples}
|
---|
398 | * ### isStable examples and caveats
|
---|
399 | *
|
---|
400 | * Note two important points about `isStable`, demonstrated in the examples below:
|
---|
401 | * - the application will never be stable if you start any kind
|
---|
402 | * of recurrent asynchronous task when the application starts
|
---|
403 | * (for example for a polling process, started with a `setInterval`, a `setTimeout`
|
---|
404 | * or using RxJS operators like `interval`);
|
---|
405 | * - the `isStable` Observable runs outside of the Angular zone.
|
---|
406 | *
|
---|
407 | * Let's imagine that you start a recurrent task
|
---|
408 | * (here incrementing a counter, using RxJS `interval`),
|
---|
409 | * and at the same time subscribe to `isStable`.
|
---|
410 | *
|
---|
411 | * ```
|
---|
412 | * constructor(appRef: ApplicationRef) {
|
---|
413 | * appRef.isStable.pipe(
|
---|
414 | * filter(stable => stable)
|
---|
415 | * ).subscribe(() => console.log('App is stable now');
|
---|
416 | * interval(1000).subscribe(counter => console.log(counter));
|
---|
417 | * }
|
---|
418 | * ```
|
---|
419 | * In this example, `isStable` will never emit `true`,
|
---|
420 | * and the trace "App is stable now" will never get logged.
|
---|
421 | *
|
---|
422 | * If you want to execute something when the app is stable,
|
---|
423 | * you have to wait for the application to be stable
|
---|
424 | * before starting your polling process.
|
---|
425 | *
|
---|
426 | * ```
|
---|
427 | * constructor(appRef: ApplicationRef) {
|
---|
428 | * appRef.isStable.pipe(
|
---|
429 | * first(stable => stable),
|
---|
430 | * tap(stable => console.log('App is stable now')),
|
---|
431 | * switchMap(() => interval(1000))
|
---|
432 | * ).subscribe(counter => console.log(counter));
|
---|
433 | * }
|
---|
434 | * ```
|
---|
435 | * In this example, the trace "App is stable now" will be logged
|
---|
436 | * and then the counter starts incrementing every second.
|
---|
437 | *
|
---|
438 | * Note also that this Observable runs outside of the Angular zone,
|
---|
439 | * which means that the code in the subscription
|
---|
440 | * to this Observable will not trigger the change detection.
|
---|
441 | *
|
---|
442 | * Let's imagine that instead of logging the counter value,
|
---|
443 | * you update a field of your component
|
---|
444 | * and display it in its template.
|
---|
445 | *
|
---|
446 | * ```
|
---|
447 | * constructor(appRef: ApplicationRef) {
|
---|
448 | * appRef.isStable.pipe(
|
---|
449 | * first(stable => stable),
|
---|
450 | * switchMap(() => interval(1000))
|
---|
451 | * ).subscribe(counter => this.value = counter);
|
---|
452 | * }
|
---|
453 | * ```
|
---|
454 | * As the `isStable` Observable runs outside the zone,
|
---|
455 | * the `value` field will be updated properly,
|
---|
456 | * but the template will not be refreshed!
|
---|
457 | *
|
---|
458 | * You'll have to manually trigger the change detection to update the template.
|
---|
459 | *
|
---|
460 | * ```
|
---|
461 | * constructor(appRef: ApplicationRef, cd: ChangeDetectorRef) {
|
---|
462 | * appRef.isStable.pipe(
|
---|
463 | * first(stable => stable),
|
---|
464 | * switchMap(() => interval(1000))
|
---|
465 | * ).subscribe(counter => {
|
---|
466 | * this.value = counter;
|
---|
467 | * cd.detectChanges();
|
---|
468 | * });
|
---|
469 | * }
|
---|
470 | * ```
|
---|
471 | *
|
---|
472 | * Or make the subscription callback run inside the zone.
|
---|
473 | *
|
---|
474 | * ```
|
---|
475 | * constructor(appRef: ApplicationRef, zone: NgZone) {
|
---|
476 | * appRef.isStable.pipe(
|
---|
477 | * first(stable => stable),
|
---|
478 | * switchMap(() => interval(1000))
|
---|
479 | * ).subscribe(counter => zone.run(() => this.value = counter));
|
---|
480 | * }
|
---|
481 | * ```
|
---|
482 | *
|
---|
483 | * @publicApi
|
---|
484 | */
|
---|
485 | export class ApplicationRef {
|
---|
486 | /** @internal */
|
---|
487 | constructor(_zone, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
|
---|
488 | this._zone = _zone;
|
---|
489 | this._injector = _injector;
|
---|
490 | this._exceptionHandler = _exceptionHandler;
|
---|
491 | this._componentFactoryResolver = _componentFactoryResolver;
|
---|
492 | this._initStatus = _initStatus;
|
---|
493 | /** @internal */
|
---|
494 | this._bootstrapListeners = [];
|
---|
495 | this._views = [];
|
---|
496 | this._runningTick = false;
|
---|
497 | this._stable = true;
|
---|
498 | /**
|
---|
499 | * Get a list of component types registered to this application.
|
---|
500 | * This list is populated even before the component is created.
|
---|
501 | */
|
---|
502 | this.componentTypes = [];
|
---|
503 | /**
|
---|
504 | * Get a list of components registered to this application.
|
---|
505 | */
|
---|
506 | this.components = [];
|
---|
507 | this._onMicrotaskEmptySubscription = this._zone.onMicrotaskEmpty.subscribe({
|
---|
508 | next: () => {
|
---|
509 | this._zone.run(() => {
|
---|
510 | this.tick();
|
---|
511 | });
|
---|
512 | }
|
---|
513 | });
|
---|
514 | const isCurrentlyStable = new Observable((observer) => {
|
---|
515 | this._stable = this._zone.isStable && !this._zone.hasPendingMacrotasks &&
|
---|
516 | !this._zone.hasPendingMicrotasks;
|
---|
517 | this._zone.runOutsideAngular(() => {
|
---|
518 | observer.next(this._stable);
|
---|
519 | observer.complete();
|
---|
520 | });
|
---|
521 | });
|
---|
522 | const isStable = new Observable((observer) => {
|
---|
523 | // Create the subscription to onStable outside the Angular Zone so that
|
---|
524 | // the callback is run outside the Angular Zone.
|
---|
525 | let stableSub;
|
---|
526 | this._zone.runOutsideAngular(() => {
|
---|
527 | stableSub = this._zone.onStable.subscribe(() => {
|
---|
528 | NgZone.assertNotInAngularZone();
|
---|
529 | // Check whether there are no pending macro/micro tasks in the next tick
|
---|
530 | // to allow for NgZone to update the state.
|
---|
531 | scheduleMicroTask(() => {
|
---|
532 | if (!this._stable && !this._zone.hasPendingMacrotasks &&
|
---|
533 | !this._zone.hasPendingMicrotasks) {
|
---|
534 | this._stable = true;
|
---|
535 | observer.next(true);
|
---|
536 | }
|
---|
537 | });
|
---|
538 | });
|
---|
539 | });
|
---|
540 | const unstableSub = this._zone.onUnstable.subscribe(() => {
|
---|
541 | NgZone.assertInAngularZone();
|
---|
542 | if (this._stable) {
|
---|
543 | this._stable = false;
|
---|
544 | this._zone.runOutsideAngular(() => {
|
---|
545 | observer.next(false);
|
---|
546 | });
|
---|
547 | }
|
---|
548 | });
|
---|
549 | return () => {
|
---|
550 | stableSub.unsubscribe();
|
---|
551 | unstableSub.unsubscribe();
|
---|
552 | };
|
---|
553 | });
|
---|
554 | this.isStable =
|
---|
555 | merge(isCurrentlyStable, isStable.pipe(share()));
|
---|
556 | }
|
---|
557 | /**
|
---|
558 | * Bootstrap a component onto the element identified by its selector or, optionally, to a
|
---|
559 | * specified element.
|
---|
560 | *
|
---|
561 | * @usageNotes
|
---|
562 | * ### Bootstrap process
|
---|
563 | *
|
---|
564 | * When bootstrapping a component, Angular mounts it onto a target DOM element
|
---|
565 | * and kicks off automatic change detection. The target DOM element can be
|
---|
566 | * provided using the `rootSelectorOrNode` argument.
|
---|
567 | *
|
---|
568 | * If the target DOM element is not provided, Angular tries to find one on a page
|
---|
569 | * using the `selector` of the component that is being bootstrapped
|
---|
570 | * (first matched element is used).
|
---|
571 | *
|
---|
572 | * ### Example
|
---|
573 | *
|
---|
574 | * Generally, we define the component to bootstrap in the `bootstrap` array of `NgModule`,
|
---|
575 | * but it requires us to know the component while writing the application code.
|
---|
576 | *
|
---|
577 | * Imagine a situation where we have to wait for an API call to decide about the component to
|
---|
578 | * bootstrap. We can use the `ngDoBootstrap` hook of the `NgModule` and call this method to
|
---|
579 | * dynamically bootstrap a component.
|
---|
580 | *
|
---|
581 | * {@example core/ts/platform/platform.ts region='componentSelector'}
|
---|
582 | *
|
---|
583 | * Optionally, a component can be mounted onto a DOM element that does not match the
|
---|
584 | * selector of the bootstrapped component.
|
---|
585 | *
|
---|
586 | * In the following example, we are providing a CSS selector to match the target element.
|
---|
587 | *
|
---|
588 | * {@example core/ts/platform/platform.ts region='cssSelector'}
|
---|
589 | *
|
---|
590 | * While in this example, we are providing reference to a DOM node.
|
---|
591 | *
|
---|
592 | * {@example core/ts/platform/platform.ts region='domNode'}
|
---|
593 | */
|
---|
594 | bootstrap(componentOrFactory, rootSelectorOrNode) {
|
---|
595 | if (!this._initStatus.done) {
|
---|
596 | throw new Error('Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
|
---|
597 | }
|
---|
598 | let componentFactory;
|
---|
599 | if (componentOrFactory instanceof ComponentFactory) {
|
---|
600 | componentFactory = componentOrFactory;
|
---|
601 | }
|
---|
602 | else {
|
---|
603 | componentFactory =
|
---|
604 | this._componentFactoryResolver.resolveComponentFactory(componentOrFactory);
|
---|
605 | }
|
---|
606 | this.componentTypes.push(componentFactory.componentType);
|
---|
607 | // Create a factory associated with the current module if it's not bound to some other
|
---|
608 | const ngModule = isBoundToModule(componentFactory) ? undefined : this._injector.get(NgModuleRef);
|
---|
609 | const selectorOrNode = rootSelectorOrNode || componentFactory.selector;
|
---|
610 | const compRef = componentFactory.create(Injector.NULL, [], selectorOrNode, ngModule);
|
---|
611 | const nativeElement = compRef.location.nativeElement;
|
---|
612 | const testability = compRef.injector.get(Testability, null);
|
---|
613 | const testabilityRegistry = testability && compRef.injector.get(TestabilityRegistry);
|
---|
614 | if (testability && testabilityRegistry) {
|
---|
615 | testabilityRegistry.registerApplication(nativeElement, testability);
|
---|
616 | }
|
---|
617 | compRef.onDestroy(() => {
|
---|
618 | this.detachView(compRef.hostView);
|
---|
619 | remove(this.components, compRef);
|
---|
620 | if (testabilityRegistry) {
|
---|
621 | testabilityRegistry.unregisterApplication(nativeElement);
|
---|
622 | }
|
---|
623 | });
|
---|
624 | this._loadComponent(compRef);
|
---|
625 | // Note that we have still left the `isDevMode()` condition in order to avoid
|
---|
626 | // creating a breaking change for projects that still use the View Engine.
|
---|
627 | if ((typeof ngDevMode === 'undefined' || ngDevMode) && isDevMode()) {
|
---|
628 | const _console = this._injector.get(Console);
|
---|
629 | _console.log(`Angular is running in development mode. Call enableProdMode() to enable production mode.`);
|
---|
630 | }
|
---|
631 | return compRef;
|
---|
632 | }
|
---|
633 | /**
|
---|
634 | * Invoke this method to explicitly process change detection and its side-effects.
|
---|
635 | *
|
---|
636 | * In development mode, `tick()` also performs a second change detection cycle to ensure that no
|
---|
637 | * further changes are detected. If additional changes are picked up during this second cycle,
|
---|
638 | * bindings in the app have side-effects that cannot be resolved in a single change detection
|
---|
639 | * pass.
|
---|
640 | * In this case, Angular throws an error, since an Angular application can only have one change
|
---|
641 | * detection pass during which all change detection must complete.
|
---|
642 | */
|
---|
643 | tick() {
|
---|
644 | if (this._runningTick) {
|
---|
645 | throw new Error('ApplicationRef.tick is called recursively');
|
---|
646 | }
|
---|
647 | try {
|
---|
648 | this._runningTick = true;
|
---|
649 | for (let view of this._views) {
|
---|
650 | view.detectChanges();
|
---|
651 | }
|
---|
652 | // Note that we have still left the `isDevMode()` condition in order to avoid
|
---|
653 | // creating a breaking change for projects that still use the View Engine.
|
---|
654 | if ((typeof ngDevMode === 'undefined' || ngDevMode) && isDevMode()) {
|
---|
655 | for (let view of this._views) {
|
---|
656 | view.checkNoChanges();
|
---|
657 | }
|
---|
658 | }
|
---|
659 | }
|
---|
660 | catch (e) {
|
---|
661 | // Attention: Don't rethrow as it could cancel subscriptions to Observables!
|
---|
662 | this._zone.runOutsideAngular(() => this._exceptionHandler.handleError(e));
|
---|
663 | }
|
---|
664 | finally {
|
---|
665 | this._runningTick = false;
|
---|
666 | }
|
---|
667 | }
|
---|
668 | /**
|
---|
669 | * Attaches a view so that it will be dirty checked.
|
---|
670 | * The view will be automatically detached when it is destroyed.
|
---|
671 | * This will throw if the view is already attached to a ViewContainer.
|
---|
672 | */
|
---|
673 | attachView(viewRef) {
|
---|
674 | const view = viewRef;
|
---|
675 | this._views.push(view);
|
---|
676 | view.attachToAppRef(this);
|
---|
677 | }
|
---|
678 | /**
|
---|
679 | * Detaches a view from dirty checking again.
|
---|
680 | */
|
---|
681 | detachView(viewRef) {
|
---|
682 | const view = viewRef;
|
---|
683 | remove(this._views, view);
|
---|
684 | view.detachFromAppRef();
|
---|
685 | }
|
---|
686 | _loadComponent(componentRef) {
|
---|
687 | this.attachView(componentRef.hostView);
|
---|
688 | this.tick();
|
---|
689 | this.components.push(componentRef);
|
---|
690 | // Get the listeners lazily to prevent DI cycles.
|
---|
691 | const listeners = this._injector.get(APP_BOOTSTRAP_LISTENER, []).concat(this._bootstrapListeners);
|
---|
692 | listeners.forEach((listener) => listener(componentRef));
|
---|
693 | }
|
---|
694 | /** @internal */
|
---|
695 | ngOnDestroy() {
|
---|
696 | this._views.slice().forEach((view) => view.destroy());
|
---|
697 | this._onMicrotaskEmptySubscription.unsubscribe();
|
---|
698 | }
|
---|
699 | /**
|
---|
700 | * Returns the number of attached views.
|
---|
701 | */
|
---|
702 | get viewCount() {
|
---|
703 | return this._views.length;
|
---|
704 | }
|
---|
705 | }
|
---|
706 | ApplicationRef.decorators = [
|
---|
707 | { type: Injectable }
|
---|
708 | ];
|
---|
709 | ApplicationRef.ctorParameters = () => [
|
---|
710 | { type: NgZone },
|
---|
711 | { type: Injector },
|
---|
712 | { type: ErrorHandler },
|
---|
713 | { type: ComponentFactoryResolver },
|
---|
714 | { type: ApplicationInitStatus }
|
---|
715 | ];
|
---|
716 | function remove(list, el) {
|
---|
717 | const index = list.indexOf(el);
|
---|
718 | if (index > -1) {
|
---|
719 | list.splice(index, 1);
|
---|
720 | }
|
---|
721 | }
|
---|
722 | function _lastDefined(args) {
|
---|
723 | for (let i = args.length - 1; i >= 0; i--) {
|
---|
724 | if (args[i] !== undefined) {
|
---|
725 | return args[i];
|
---|
726 | }
|
---|
727 | }
|
---|
728 | return undefined;
|
---|
729 | }
|
---|
730 | function _mergeArrays(parts) {
|
---|
731 | const result = [];
|
---|
732 | parts.forEach((part) => part && result.push(...part));
|
---|
733 | return result;
|
---|
734 | }
|
---|
735 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGljYXRpb25fcmVmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29yZS9zcmMvYXBwbGljYXRpb25fcmVmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sb0JBQW9CLENBQUM7QUFFNUIsT0FBTyxFQUFDLEtBQUssRUFBRSxVQUFVLEVBQXlCLE1BQU0sTUFBTSxDQUFDO0FBQy9ELE9BQU8sRUFBQyxLQUFLLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUVyQyxPQUFPLEVBQUMscUJBQXFCLEVBQUMsTUFBTSxvQ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