Project

General

Profile

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
 */
8
import { Observable } from 'rxjs/Observable';
9
import { ErrorHandler } from '../src/error_handler';
10
import { ApplicationInitStatus } from './application_init';
11
import { Console } from './console';
12
import { InjectionToken, Injector, Provider } from './di';
13
import { CompilerOptions } from './linker/compiler';
14
import { ComponentFactory, ComponentRef } from './linker/component_factory';
15
import { ComponentFactoryResolver } from './linker/component_factory_resolver';
16
import { NgModuleFactory, NgModuleRef } from './linker/ng_module_factory';
17
import { ViewRef } from './linker/view_ref';
18
import { Type } from './type';
19
import { NgZone } from './zone/ng_zone';
20
export 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
 */
31
export 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
 */
40
export declare function isDevMode(): boolean;
41
/**
42
 * A token for third-party components that can register themselves with NgProbe.
43
 *
44
 * @experimental
45
 */
46
export 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
 */
57
export 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
 */
63
export 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
 */
69
export 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
 */
75
export declare function destroyPlatform(): void;
76
/**
77
 * Returns the current platform.
78
 *
79
 * @experimental APIs related to application bootstrap are currently under review.
80
 */
81
export 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
 */
92
export 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
 */
152
export 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
 */
173
export 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
     * Optionally, a component can be mounted onto a DOM element that does not match the
184
     * [componentType]'s selector.
185
     *
186
     * ### Example
187
     * {@example core/ts/platform/platform.ts region='longform'}
188
     */
189
    abstract bootstrap<C>(componentFactory: ComponentFactory<C> | Type<C>, rootSelectorOrNode?: string | any): ComponentRef<C>;
190
    /**
191
     * Invoke this method to explicitly process change detection and its side-effects.
192
     *
193
     * In development mode, `tick()` also performs a second change detection cycle to ensure that no
194
     * further changes are detected. If additional changes are picked up during this second cycle,
195
     * bindings in the app have side-effects that cannot be resolved in a single change detection
196
     * pass.
197
     * In this case, Angular throws an error, since an Angular application can only have one change
198
     * detection pass during which all change detection must complete.
199
     */
200
    abstract tick(): void;
201
    /**
202
     * Get a list of component types registered to this application.
203
     * This list is populated even before the component is created.
204
     */
205
    readonly abstract componentTypes: Type<any>[];
206
    /**
207
     * Get a list of components registered to this application.
208
     */
209
    readonly abstract components: ComponentRef<any>[];
210
    /**
211
     * Attaches a view so that it will be dirty checked.
212
     * The view will be automatically detached when it is destroyed.
213
     * This will throw if the view is already attached to a ViewContainer.
214
     */
215
    abstract attachView(view: ViewRef): void;
216
    /**
217
     * Detaches a view from dirty checking again.
218
     */
219
    abstract detachView(view: ViewRef): void;
220
    /**
221
     * Returns the number of attached views.
222
     */
223
    readonly abstract viewCount: number;
224
    /**
225
     * Returns an Observable that indicates when the application is stable or unstable.
226
     */
227
    readonly abstract isStable: Observable<boolean>;
228
}
229
/**
230
 * workaround https://github.com/angular/tsickle/issues/350
231
 * @suppress {checkTypes}
232
 */
233
export declare class ApplicationRef_ extends ApplicationRef {
234
    private _zone;
235
    private _console;
236
    private _injector;
237
    private _exceptionHandler;
238
    private _componentFactoryResolver;
239
    private _initStatus;
240
    private _bootstrapListeners;
241
    private _rootComponents;
242
    private _rootComponentTypes;
243
    private _views;
244
    private _runningTick;
245
    private _enforceNoNewChanges;
246
    private _isStable;
247
    private _stable;
248
    constructor(_zone: NgZone, _console: Console, _injector: Injector, _exceptionHandler: ErrorHandler, _componentFactoryResolver: ComponentFactoryResolver, _initStatus: ApplicationInitStatus);
249
    attachView(viewRef: ViewRef): void;
250
    detachView(viewRef: ViewRef): void;
251
    bootstrap<C>(componentOrFactory: ComponentFactory<C> | Type<C>, rootSelectorOrNode?: string | any): ComponentRef<C>;
252
    private _loadComponent(componentRef);
253
    private _unloadComponent(componentRef);
254
    tick(): void;
255
    ngOnDestroy(): void;
256
    readonly viewCount: number;
257
    readonly componentTypes: Type<any>[];
258
    readonly components: ComponentRef<any>[];
259
    readonly isStable: Observable<boolean>;
260
}
(3-3/22)