UNPKG

9.67 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. 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 */
8import { Observable } from 'rxjs/Observable';
9import { ErrorHandler } from '../src/error_handler';
10import { ApplicationInitStatus } from './application_init';
11import { Console } from './console';
12import { InjectionToken, Injector, Provider } from './di';
13import { CompilerOptions } from './linker/compiler';
14import { ComponentFactory, ComponentRef } from './linker/component_factory';
15import { ComponentFactoryResolver } from './linker/component_factory_resolver';
16import { NgModuleFactory, NgModuleRef } from './linker/ng_module_factory';
17import { ViewRef } from './linker/view_ref';
18import { Type } from './type';
19import { NgZone } from './zone/ng_zone';
20export declare const ALLOW_MULTIPLE_PLATFORMS: InjectionToken<boolean>;
21/**
22 * Disable Angular's development mode, which turns off assertions and other
23 * checks within the framework.
24 *
25 * One important assertion this disables verifies that a change detection pass
26 * does not result in additional changes to any bindings (also known as
27 * unidirectional data flow).
28 *
29 * @stable
30 */
31export declare function enableProdMode(): void;
32/**
33 * Returns whether Angular is in development mode. After called once,
34 * the value is locked and won't change any more.
35 *
36 * By default, this is true, unless a user calls `enableProdMode` before calling this.
37 *
38 * @experimental APIs related to application bootstrap are currently under review.
39 */
40export declare function isDevMode(): boolean;
41/**
42 * A token for third-party components that can register themselves with NgProbe.
43 *
44 * @experimental
45 */
46export declare class NgProbeToken {
47 name: string;
48 token: any;
49 constructor(name: string, token: any);
50}
51/**
52 * Creates a platform.
53 * Platforms have to be eagerly created via this function.
54 *
55 * @experimental APIs related to application bootstrap are currently under review.
56 */
57export declare function createPlatform(injector: Injector): PlatformRef;
58/**
59 * Creates a factory for a platform
60 *
61 * @experimental APIs related to application bootstrap are currently under review.
62 */
63export declare function createPlatformFactory(parentPlatformFactory: ((extraProviders?: Provider[]) => PlatformRef) | null, name: string, providers?: Provider[]): (extraProviders?: Provider[]) => PlatformRef;
64/**
65 * Checks that there currently is a platform which contains the given token as a provider.
66 *
67 * @experimental APIs related to application bootstrap are currently under review.
68 */
69export declare function assertPlatform(requiredToken: any): PlatformRef;
70/**
71 * Destroy the existing platform.
72 *
73 * @experimental APIs related to application bootstrap are currently under review.
74 */
75export declare function destroyPlatform(): void;
76/**
77 * Returns the current platform.
78 *
79 * @experimental APIs related to application bootstrap are currently under review.
80 */
81export declare function getPlatform(): PlatformRef | null;
82/**
83 * The Angular platform is the entry point for Angular on a web page. Each page
84 * has exactly one platform, and services (such as reflection) which are common
85 * to every Angular application running on the page are bound in its scope.
86 *
87 * A page's platform is initialized implicitly when a platform is created via a platform factory
88 * (e.g. {@link platformBrowser}), or explicitly by calling the {@link createPlatform} function.
89 *
90 * @stable
91 */
92export declare abstract class PlatformRef {
93 /**
94 * Creates an instance of an `@NgModule` for the given platform
95 * for offline compilation.
96 *
97 * ## Simple Example
98 *
99 * ```typescript
100 * my_module.ts:
101 *
102 * @NgModule({
103 * imports: [BrowserModule]
104 * })
105 * class MyModule {}
106 *
107 * main.ts:
108 * import {MyModuleNgFactory} from './my_module.ngfactory';
109 * import {platformBrowser} from '@angular/platform-browser';
110 *
111 * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
112 * ```
113 *
114 * @experimental APIs related to application bootstrap are currently under review.
115 */
116 abstract bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>): Promise<NgModuleRef<M>>;
117 /**
118 * Creates an instance of an `@NgModule` for a given platform using the given runtime compiler.
119 *
120 * ## Simple Example
121 *
122 * ```typescript
123 * @NgModule({
124 * imports: [BrowserModule]
125 * })
126 * class MyModule {}
127 *
128 * let moduleRef = platformBrowser().bootstrapModule(MyModule);
129 * ```
130 * @stable
131 */
132 abstract bootstrapModule<M>(moduleType: Type<M>, compilerOptions?: CompilerOptions | CompilerOptions[]): Promise<NgModuleRef<M>>;
133 /**
134 * Register a listener to be called when the platform is disposed.
135 */
136 abstract onDestroy(callback: () => void): void;
137 /**
138 * Retrieve the platform {@link Injector}, which is the parent injector for
139 * every Angular application on the page and provides singleton providers.
140 */
141 readonly abstract injector: Injector;
142 /**
143 * Destroy the Angular platform and all Angular applications on the page.
144 */
145 abstract destroy(): void;
146 readonly abstract destroyed: boolean;
147}
148/**
149 * workaround https://github.com/angular/tsickle/issues/350
150 * @suppress {checkTypes}
151 */
152export declare class PlatformRef_ extends PlatformRef {
153 private _injector;
154 private _modules;
155 private _destroyListeners;
156 private _destroyed;
157 constructor(_injector: Injector);
158 onDestroy(callback: () => void): void;
159 readonly injector: Injector;
160 readonly destroyed: boolean;
161 destroy(): void;
162 bootstrapModuleFactory<M>(moduleFactory: NgModuleFactory<M>): Promise<NgModuleRef<M>>;
163 private _bootstrapModuleFactoryWithZone<M>(moduleFactory, ngZone?);
164 bootstrapModule<M>(moduleType: Type<M>, compilerOptions?: CompilerOptions | CompilerOptions[]): Promise<NgModuleRef<M>>;
165 private _bootstrapModuleWithZone<M>(moduleType, compilerOptions?, ngZone?);
166 private _moduleDoBootstrap(moduleRef);
167}
168/**
169 * A reference to an Angular application running on a page.
170 *
171 * @stable
172 */
173export declare abstract class ApplicationRef {
174 /**
175 * Bootstrap a new component at the root level of the application.
176 *
177 * ### Bootstrap process
178 *
179 * When bootstrapping a new root component into an application, Angular mounts the
180 * specified application component onto DOM elements identified by the [componentType]'s
181 * selector and kicks off automatic change detection to finish initializing the component.
182 *
183 * ### Example
184 * {@example core/ts/platform/platform.ts region='longform'}
185 */
186 abstract bootstrap<C>(componentFactory: ComponentFactory<C> | Type<C>): ComponentRef<C>;
187 /**
188 * Invoke this method to explicitly process change detection and its side-effects.
189 *
190 * In development mode, `tick()` also performs a second change detection cycle to ensure that no
191 * further changes are detected. If additional changes are picked up during this second cycle,
192 * bindings in the app have side-effects that cannot be resolved in a single change detection
193 * pass.
194 * In this case, Angular throws an error, since an Angular application can only have one change
195 * detection pass during which all change detection must complete.
196 */
197 abstract tick(): void;
198 /**
199 * Get a list of component types registered to this application.
200 * This list is populated even before the component is created.
201 */
202 readonly abstract componentTypes: Type<any>[];
203 /**
204 * Get a list of components registered to this application.
205 */
206 readonly abstract components: ComponentRef<any>[];
207 /**
208 * Attaches a view so that it will be dirty checked.
209 * The view will be automatically detached when it is destroyed.
210 * This will throw if the view is already attached to a ViewContainer.
211 */
212 abstract attachView(view: ViewRef): void;
213 /**
214 * Detaches a view from dirty checking again.
215 */
216 abstract detachView(view: ViewRef): void;
217 /**
218 * Returns the number of attached views.
219 */
220 readonly abstract viewCount: number;
221 /**
222 * Returns an Observable that indicates when the application is stable or unstable.
223 */
224 readonly abstract isStable: Observable<boolean>;
225}
226/**
227 * workaround https://github.com/angular/tsickle/issues/350
228 * @suppress {checkTypes}
229 */
230export declare class ApplicationRef_ extends ApplicationRef {
231 private _zone;
232 private _console;
233 private _injector;
234 private _exceptionHandler;
235 private _componentFactoryResolver;
236 private _initStatus;
237 private _bootstrapListeners;
238 private _rootComponents;
239 private _rootComponentTypes;
240 private _views;
241 private _runningTick;
242 private _enforceNoNewChanges;
243 private _isStable;
244 private _stable;
245 constructor(_zone: NgZone, _console: Console, _injector: Injector, _exceptionHandler: ErrorHandler, _componentFactoryResolver: ComponentFactoryResolver, _initStatus: ApplicationInitStatus);
246 attachView(viewRef: ViewRef): void;
247 detachView(viewRef: ViewRef): void;
248 bootstrap<C>(componentOrFactory: ComponentFactory<C> | Type<C>): ComponentRef<C>;
249 private _loadComponent(componentRef);
250 private _unloadComponent(componentRef);
251 tick(): void;
252 ngOnDestroy(): void;
253 readonly viewCount: number;
254 readonly componentTypes: Type<any>[];
255 readonly components: ComponentRef<any>[];
256 readonly isStable: Observable<boolean>;
257}