refactor(core): clean up platform bootstrap and initTestEnvironment
- Introduces `CompilerFactory` which can be part of a `PlatformRef`. - Introduces `WorkerAppModule`, `WorkerUiModule`, `ServerModule` - Introduces `serverDynamicPlatform` for applications using runtime compilation on the server. - Changes browser bootstrap for runtime and offline compilation (see below for an example). * introduces `bootstrapModule` and `bootstrapModuleFactory` in `@angular/core` * introduces new `browserDynamicPlatform` in `@angular/platform-browser-dynamic - Changes `initTestEnvironment` (which used to be `setBaseTestProviders`) to not take a compiler factory any more (see below for an example). BREAKING CHANGE: ## Migration from `setBaseTestProviders` to `initTestEnvironment`: - For the browser platform: BEFORE: ``` import {setBaseTestProviders} from ‘@angular/core/testing’; import {TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS} from ‘@angular/platform-browser-dynamic/testing’; setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); ``` AFTER: ``` import {initTestEnvironment} from ‘@angular/core/testing’; import {browserDynamicTestPlatform, BrowserDynamicTestModule} from ‘@angular/platform-browser-dynamic/testing’; initTestEnvironment( BrowserDynamicTestModule, browserDynamicTestPlatform()); ``` - For the server platform: BEFORE: ``` import {setBaseTestProviders} from ‘@angular/core/testing’; import {TEST_SERVER_PLATFORM_PROVIDERS, TEST_SERVER_APPLICATION_PROVIDERS} from ‘@angular/platform-server/testing/server’; setBaseTestProviders(TEST_SERVER_PLATFORM_PROVIDERS, TEST_SERVER_APPLICATION_PROVIDERS); ``` AFTER: ``` import {initTestEnvironment} from ‘@angular/core/testing’; import {serverTestPlatform, ServerTestModule} from ‘@angular/platform-browser-dynamic/testing’; initTestEnvironment( ServerTestModule, serverTestPlatform()); ``` ## Bootstrap changes ``` @AppModule({ modules: [BrowserModule], precompile: [MainComponent], providers: […], // additional providers directives: […], // additional platform directives pipes: […] // additional platform pipes }) class MyModule { constructor(appRef: ApplicationRef) { appRef.bootstrap(MainComponent); } } // offline compile import {browserPlatform} from ‘@angular/platform-browser’; import {bootstrapModuleFactory} from ‘@angular/core’; bootstrapModuleFactory(MyModuleNgFactory, browserPlatform()); // runtime compile long form import {browserDynamicPlatform} from ‘@angular/platform-browser-dynamic’; import {bootstrapModule} from ‘@angular/core’; bootstrapModule(MyModule, browserDynamicPlatform()); ``` Closes #9922 Part of #9726
This commit is contained in:
parent
d84a43c828
commit
fa47890032
@ -49,8 +49,10 @@ bootstrap.ts
|
|||||||
-------------
|
-------------
|
||||||
|
|
||||||
import {MainModuleNgFactory} from './main_module.ngfactory';
|
import {MainModuleNgFactory} from './main_module.ngfactory';
|
||||||
|
import {bootstrapModuleFactory} from '@angular/core';
|
||||||
|
import {browserPlatform} from '@angular/platform-browser';
|
||||||
|
|
||||||
MainModuleNgFactory.create(browserPlatform().injector);
|
bootstrapModuleFactory(MainModuleNgFactory, browserPlatform());
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {AppModuleFactory, AppModuleRef} from '@angular/core';
|
import {AppModuleFactory, AppModuleRef, bootstrapModuleFactory} from '@angular/core';
|
||||||
import {ComponentFixture} from '@angular/core/testing';
|
import {ComponentFixture} from '@angular/core/testing';
|
||||||
import {serverPlatform} from '@angular/platform-server';
|
import {serverPlatform} from '@angular/platform-server';
|
||||||
|
|
||||||
import {MainModuleNgFactory} from '../src/module.ngfactory';
|
import {MainModuleNgFactory} from '../src/module.ngfactory';
|
||||||
|
|
||||||
export function createModule<M>(factory: AppModuleFactory<M>): AppModuleRef<M> {
|
export function createModule<M>(factory: AppModuleFactory<M>): AppModuleRef<M> {
|
||||||
return factory.create(serverPlatform().injector);
|
return bootstrapModuleFactory(factory, serverPlatform());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createComponent<C>(
|
export function createComponent<C>(
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* @description
|
* @description
|
||||||
* Starting point to import all compiler APIs.
|
* Starting point to import all compiler APIs.
|
||||||
*/
|
*/
|
||||||
export {COMPILER_PROVIDERS, CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileFactoryMetadata, CompileIdentifierMetadata, CompileMetadataWithIdentifier, CompileMetadataWithType, CompilePipeMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTemplateMetadata, CompileTokenMetadata, CompileTypeMetadata, CompilerConfig, DEFAULT_PACKAGE_URL_PROVIDER, DirectiveResolver, OfflineCompiler, PipeResolver, RenderTypes, RuntimeCompiler, SourceModule, TEMPLATE_TRANSFORMS, UrlResolver, ViewResolver, XHR, createOfflineCompileUrlResolver} from './src/compiler';
|
export {COMPILER_PROVIDERS, CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileFactoryMetadata, CompileIdentifierMetadata, CompileMetadataWithIdentifier, CompileMetadataWithType, CompilePipeMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTemplateMetadata, CompileTokenMetadata, CompileTypeMetadata, CompilerConfig, DEFAULT_PACKAGE_URL_PROVIDER, DirectiveResolver, OfflineCompiler, PipeResolver, RUNTIME_COMPILER_FACTORY, RenderTypes, RuntimeCompiler, SourceModule, TEMPLATE_TRANSFORMS, UrlResolver, ViewResolver, XHR, createOfflineCompileUrlResolver} from './src/compiler';
|
||||||
export {ElementSchemaRegistry} from './src/schema/element_schema_registry';
|
export {ElementSchemaRegistry} from './src/schema/element_schema_registry';
|
||||||
|
|
||||||
export * from './src/template_ast';
|
export * from './src/template_ast';
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Compiler, ComponentResolver, Type} from '@angular/core';
|
import {Compiler, CompilerFactory, CompilerOptions, ComponentResolver, Injectable, PLATFORM_DIRECTIVES, PLATFORM_PIPES, ReflectiveInjector, Type, ViewEncapsulation, isDevMode} from '@angular/core';
|
||||||
|
|
||||||
export * from './template_ast';
|
export * from './template_ast';
|
||||||
export {TEMPLATE_TRANSFORMS} from './template_parser';
|
export {TEMPLATE_TRANSFORMS} from './template_parser';
|
||||||
@ -39,6 +39,7 @@ import {ViewResolver} from './view_resolver';
|
|||||||
import {DirectiveResolver} from './directive_resolver';
|
import {DirectiveResolver} from './directive_resolver';
|
||||||
import {PipeResolver} from './pipe_resolver';
|
import {PipeResolver} from './pipe_resolver';
|
||||||
import {Console, Reflector, reflector, ReflectorReader} from '../core_private';
|
import {Console, Reflector, reflector, ReflectorReader} from '../core_private';
|
||||||
|
import {XHR} from './xhr';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of providers that provide `RuntimeCompiler` and its dependencies to use for
|
* A set of providers that provide `RuntimeCompiler` and its dependencies to use for
|
||||||
@ -46,6 +47,8 @@ import {Console, Reflector, reflector, ReflectorReader} from '../core_private';
|
|||||||
*/
|
*/
|
||||||
export const COMPILER_PROVIDERS: Array<any|Type|{[k: string]: any}|any[]> =
|
export const COMPILER_PROVIDERS: Array<any|Type|{[k: string]: any}|any[]> =
|
||||||
/*@ts2dart_const*/[
|
/*@ts2dart_const*/[
|
||||||
|
{provide: PLATFORM_DIRECTIVES, useValue: [], multi: true},
|
||||||
|
{provide: PLATFORM_PIPES, useValue: [], multi: true},
|
||||||
{provide: Reflector, useValue: reflector},
|
{provide: Reflector, useValue: reflector},
|
||||||
{provide: ReflectorReader, useExisting: Reflector},
|
{provide: ReflectorReader, useExisting: Reflector},
|
||||||
Console,
|
Console,
|
||||||
@ -70,3 +73,109 @@ export const COMPILER_PROVIDERS: Array<any|Type|{[k: string]: any}|any[]> =
|
|||||||
DirectiveResolver,
|
DirectiveResolver,
|
||||||
PipeResolver
|
PipeResolver
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class _RuntimeCompilerFactory extends CompilerFactory {
|
||||||
|
createCompiler(options: CompilerOptions): Compiler {
|
||||||
|
const deprecationMessages: string[] = [];
|
||||||
|
let platformDirectivesFromAppProviders: any[] = [];
|
||||||
|
let platformPipesFromAppProviders: any[] = [];
|
||||||
|
let compilerProvidersFromAppProviders: any[] = [];
|
||||||
|
let useDebugFromAppProviders: boolean;
|
||||||
|
let useJitFromAppProviders: boolean;
|
||||||
|
let defaultEncapsulationFromAppProviders: ViewEncapsulation;
|
||||||
|
|
||||||
|
if (options.deprecatedAppProviders && options.deprecatedAppProviders.length > 0) {
|
||||||
|
// Note: This is a hack to still support the old way
|
||||||
|
// of configuring platform directives / pipes and the compiler xhr.
|
||||||
|
// This will soon be deprecated!
|
||||||
|
const inj = ReflectiveInjector.resolveAndCreate(options.deprecatedAppProviders);
|
||||||
|
const compilerConfig: CompilerConfig = inj.get(CompilerConfig, null);
|
||||||
|
if (compilerConfig) {
|
||||||
|
platformDirectivesFromAppProviders = compilerConfig.platformDirectives;
|
||||||
|
platformPipesFromAppProviders = compilerConfig.platformPipes;
|
||||||
|
useJitFromAppProviders = compilerConfig.useJit;
|
||||||
|
useDebugFromAppProviders = compilerConfig.genDebugInfo;
|
||||||
|
defaultEncapsulationFromAppProviders = compilerConfig.defaultEncapsulation;
|
||||||
|
deprecationMessages.push(
|
||||||
|
`Passing a CompilerConfig to "bootstrap()" as provider is deprecated. Pass the provider via the new parameter "compilerOptions" of "bootstrap()" instead.`);
|
||||||
|
} else {
|
||||||
|
// If nobody provided a CompilerConfig, use the
|
||||||
|
// PLATFORM_DIRECTIVES / PLATFORM_PIPES values directly if existing
|
||||||
|
platformDirectivesFromAppProviders = inj.get(PLATFORM_DIRECTIVES, []);
|
||||||
|
if (platformDirectivesFromAppProviders.length > 0) {
|
||||||
|
deprecationMessages.push(
|
||||||
|
`Passing PLATFORM_DIRECTIVES to "bootstrap()" as provider is deprecated. Use the new parameter "directives" of "bootstrap()" instead.`);
|
||||||
|
}
|
||||||
|
platformPipesFromAppProviders = inj.get(PLATFORM_PIPES, []);
|
||||||
|
if (platformPipesFromAppProviders.length > 0) {
|
||||||
|
deprecationMessages.push(
|
||||||
|
`Passing PLATFORM_PIPES to "bootstrap()" as provider is deprecated. Use the new parameter "pipes" of "bootstrap()" instead.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const xhr = inj.get(XHR, null);
|
||||||
|
if (xhr) {
|
||||||
|
compilerProvidersFromAppProviders.push([{provide: XHR, useValue: xhr}]);
|
||||||
|
deprecationMessages.push(
|
||||||
|
`Passing an instance of XHR to "bootstrap()" as provider is deprecated. Pass the provider via the new parameter "compilerOptions" of "bootstrap()" instead.`);
|
||||||
|
}
|
||||||
|
// Need to copy console from deprecatedAppProviders to compiler providers
|
||||||
|
// as well so that we can test the above deprecation messages in old style bootstrap
|
||||||
|
// where we only have app providers!
|
||||||
|
const console = inj.get(Console, null);
|
||||||
|
if (console) {
|
||||||
|
compilerProvidersFromAppProviders.push([{provide: Console, useValue: console}]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const injector = ReflectiveInjector.resolveAndCreate([
|
||||||
|
COMPILER_PROVIDERS, {
|
||||||
|
provide: CompilerConfig,
|
||||||
|
useFactory: (platformDirectives: any[], platformPipes: any[]) => {
|
||||||
|
return new CompilerConfig({
|
||||||
|
platformDirectives:
|
||||||
|
_mergeArrays(platformDirectivesFromAppProviders, platformDirectives),
|
||||||
|
platformPipes: _mergeArrays(platformPipesFromAppProviders, platformPipes),
|
||||||
|
// let explicit values from the compiler options overwrite options
|
||||||
|
// from the app providers. E.g. important for the testing platform.
|
||||||
|
genDebugInfo: _firstDefined(options.useDebug, useDebugFromAppProviders, isDevMode()),
|
||||||
|
// let explicit values from the compiler options overwrite options
|
||||||
|
// from the app providers
|
||||||
|
useJit: _firstDefined(options.useJit, useJitFromAppProviders, true),
|
||||||
|
// let explicit values from the compiler options overwrite options
|
||||||
|
// from the app providers
|
||||||
|
defaultEncapsulation: _firstDefined(
|
||||||
|
options.defaultEncapsulation, defaultEncapsulationFromAppProviders,
|
||||||
|
ViewEncapsulation.Emulated)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
deps: [PLATFORM_DIRECTIVES, PLATFORM_PIPES]
|
||||||
|
},
|
||||||
|
// options.providers will always contain a provider for XHR as well
|
||||||
|
// (added by platforms). So allow compilerProvidersFromAppProviders to overwrite this
|
||||||
|
_mergeArrays(options.providers, compilerProvidersFromAppProviders)
|
||||||
|
]);
|
||||||
|
const console: Console = injector.get(Console);
|
||||||
|
deprecationMessages.forEach((msg) => { console.warn(msg); });
|
||||||
|
|
||||||
|
return injector.get(Compiler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const RUNTIME_COMPILER_FACTORY = new _RuntimeCompilerFactory();
|
||||||
|
|
||||||
|
function _firstDefined<T>(...args: T[]): T {
|
||||||
|
for (var i = 0; i < args.length; i++) {
|
||||||
|
if (args[i] !== undefined) {
|
||||||
|
return args[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _mergeArrays(...parts: any[][]): any[] {
|
||||||
|
let result: any[] = [];
|
||||||
|
parts.forEach((part) => result.push(...part));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
export * from './src/metadata';
|
export * from './src/metadata';
|
||||||
export * from './src/util';
|
export * from './src/util';
|
||||||
export * from './src/di';
|
export * from './src/di';
|
||||||
export {createPlatform, assertPlatform, disposePlatform, getPlatform, coreBootstrap, coreLoadAndBootstrap, PlatformRef, ApplicationRef, enableProdMode, lockRunMode, isDevMode} from './src/application_ref';
|
export {createPlatform, assertPlatform, disposePlatform, getPlatform, bootstrapModuleFactory, bootstrapModule, coreBootstrap, coreLoadAndBootstrap, PlatformRef, ApplicationRef, enableProdMode, lockRunMode, isDevMode, createPlatformFactory} from './src/application_ref';
|
||||||
export {APP_ID, APP_INITIALIZER, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER} from './src/application_tokens';
|
export {APP_ID, APP_INITIALIZER, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER} from './src/application_tokens';
|
||||||
export * from './src/zone';
|
export * from './src/zone';
|
||||||
export * from './src/render';
|
export * from './src/render';
|
||||||
|
@ -14,7 +14,9 @@ import {ConcreteType, IS_DART, Type, isBlank, isPresent, isPromise} from '../src
|
|||||||
import {APP_INITIALIZER, PLATFORM_INITIALIZER} from './application_tokens';
|
import {APP_INITIALIZER, PLATFORM_INITIALIZER} from './application_tokens';
|
||||||
import {ChangeDetectorRef} from './change_detection/change_detector_ref';
|
import {ChangeDetectorRef} from './change_detection/change_detector_ref';
|
||||||
import {Console} from './console';
|
import {Console} from './console';
|
||||||
import {Inject, Injectable, Injector, Optional, OptionalMetadata, SkipSelf, SkipSelfMetadata, forwardRef} from './di';
|
import {Inject, Injectable, Injector, OpaqueToken, Optional, OptionalMetadata, ReflectiveInjector, SkipSelf, SkipSelfMetadata, forwardRef} from './di';
|
||||||
|
import {AppModuleFactory, AppModuleRef} from './linker/app_module_factory';
|
||||||
|
import {Compiler, CompilerFactory, CompilerOptions} from './linker/compiler';
|
||||||
import {ComponentFactory, ComponentRef} from './linker/component_factory';
|
import {ComponentFactory, ComponentRef} from './linker/component_factory';
|
||||||
import {ComponentFactoryResolver} from './linker/component_factory_resolver';
|
import {ComponentFactoryResolver} from './linker/component_factory_resolver';
|
||||||
import {ComponentResolver} from './linker/component_resolver';
|
import {ComponentResolver} from './linker/component_resolver';
|
||||||
@ -111,6 +113,22 @@ export function createPlatform(injector: Injector): PlatformRef {
|
|||||||
return _platform;
|
return _platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a fatory for a platform
|
||||||
|
*
|
||||||
|
* @experimental APIs related to application bootstrap are currently under review.
|
||||||
|
*/
|
||||||
|
export function createPlatformFactory(name: string, providers: any[]): () => PlatformRef {
|
||||||
|
const marker = new OpaqueToken(`Platform: ${name}`);
|
||||||
|
return () => {
|
||||||
|
if (!getPlatform()) {
|
||||||
|
createPlatform(
|
||||||
|
ReflectiveInjector.resolveAndCreate(providers.concat({provide: marker, useValue: true})));
|
||||||
|
}
|
||||||
|
return assertPlatform(marker);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that there currently is a platform
|
* Checks that there currently is a platform
|
||||||
* which contains the given token as a provider.
|
* which contains the given token as a provider.
|
||||||
@ -149,6 +167,70 @@ export function getPlatform(): PlatformRef {
|
|||||||
return isPresent(_platform) && !_platform.disposed ? _platform : null;
|
return isPresent(_platform) && !_platform.disposed ? _platform : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of an `@AppModule` for the given platform
|
||||||
|
* for offline compilation.
|
||||||
|
*
|
||||||
|
* ## Simple Example
|
||||||
|
*
|
||||||
|
* ```typescript
|
||||||
|
* my_module.ts:
|
||||||
|
*
|
||||||
|
* @AppModule({
|
||||||
|
* modules: [BrowserModule]
|
||||||
|
* })
|
||||||
|
* class MyModule {}
|
||||||
|
*
|
||||||
|
* main.ts:
|
||||||
|
* import {MyModuleNgFactory} from './my_module.ngfactory';
|
||||||
|
* import {bootstrapModuleFactory} from '@angular/core';
|
||||||
|
* import {browserPlatform} from '@angular/platform-browser';
|
||||||
|
*
|
||||||
|
* let moduleRef = bootstrapModuleFactory(MyModuleNgFactory, browserPlatform());
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @experimental APIs related to application bootstrap are currently under review.
|
||||||
|
*/
|
||||||
|
export function bootstrapModuleFactory<M>(
|
||||||
|
moduleFactory: AppModuleFactory<M>, platform: PlatformRef): AppModuleRef<M> {
|
||||||
|
// Note: We need to create the NgZone _before_ we instantiate the module,
|
||||||
|
// as instantiating the module creates some providers eagerly.
|
||||||
|
// So we create a mini parent injector that just contains the new NgZone and
|
||||||
|
// pass that as parent to the AppModuleFactory.
|
||||||
|
const ngZone = new NgZone({enableLongStackTrace: isDevMode()});
|
||||||
|
const ngZoneInjector =
|
||||||
|
ReflectiveInjector.resolveAndCreate([{provide: NgZone, useValue: ngZone}], platform.injector);
|
||||||
|
return ngZone.run(() => moduleFactory.create(ngZoneInjector));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of an `@AppModule` for a given platform using the given runtime compiler.
|
||||||
|
*
|
||||||
|
* ## Simple Example
|
||||||
|
*
|
||||||
|
* ```typescript
|
||||||
|
* @AppModule({
|
||||||
|
* modules: [BrowserModule]
|
||||||
|
* })
|
||||||
|
* class MyModule {}
|
||||||
|
*
|
||||||
|
* let moduleRef = bootstrapModule(MyModule, browserPlatform());
|
||||||
|
* ```
|
||||||
|
* @stable
|
||||||
|
*/
|
||||||
|
export function bootstrapModule<M>(
|
||||||
|
moduleType: ConcreteType<M>, platform: PlatformRef,
|
||||||
|
compilerOptions: CompilerOptions = {}): Promise<AppModuleRef<M>> {
|
||||||
|
const compilerFactory: CompilerFactory = platform.injector.get(CompilerFactory);
|
||||||
|
const compiler = compilerFactory.createCompiler(compilerOptions);
|
||||||
|
return compiler.compileAppModuleAsync(moduleType)
|
||||||
|
.then((moduleFactory) => bootstrapModuleFactory(moduleFactory, platform))
|
||||||
|
.then((moduleRef) => {
|
||||||
|
const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
|
||||||
|
return appRef.waitForAsyncInitializers().then(() => moduleRef);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortcut for ApplicationRef.bootstrap.
|
* Shortcut for ApplicationRef.bootstrap.
|
||||||
* Requires a platform to be created first.
|
* Requires a platform to be created first.
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// Public API for compiler
|
// Public API for compiler
|
||||||
export {AppModuleFactory, AppModuleRef} from './linker/app_module_factory';
|
export {AppModuleFactory, AppModuleRef} from './linker/app_module_factory';
|
||||||
export {AppModuleFactoryLoader} from './linker/app_module_factory_loader';
|
export {AppModuleFactoryLoader} from './linker/app_module_factory_loader';
|
||||||
export {Compiler, ComponentStillLoadingError} from './linker/compiler';
|
export {Compiler, CompilerFactory, CompilerOptions, ComponentStillLoadingError} from './linker/compiler';
|
||||||
export {ComponentFactory, ComponentRef} from './linker/component_factory';
|
export {ComponentFactory, ComponentRef} from './linker/component_factory';
|
||||||
export {ComponentFactoryResolver, NoComponentFactoryError} from './linker/component_factory_resolver';
|
export {ComponentFactoryResolver, NoComponentFactoryError} from './linker/component_factory_resolver';
|
||||||
export {ComponentResolver} from './linker/component_resolver';
|
export {ComponentResolver} from './linker/component_resolver';
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
import {Injector} from '../di';
|
import {Injector} from '../di';
|
||||||
import {BaseException} from '../facade/exceptions';
|
import {BaseException} from '../facade/exceptions';
|
||||||
import {ConcreteType, Type, stringify} from '../facade/lang';
|
import {ConcreteType, Type, stringify} from '../facade/lang';
|
||||||
|
import {ViewEncapsulation} from '../metadata';
|
||||||
import {AppModuleMetadata} from '../metadata/app_module';
|
import {AppModuleMetadata} from '../metadata/app_module';
|
||||||
|
|
||||||
import {AppModuleFactory} from './app_module_factory';
|
import {AppModuleFactory} from './app_module_factory';
|
||||||
@ -86,3 +87,64 @@ export class Compiler {
|
|||||||
*/
|
*/
|
||||||
clearCacheFor(type: Type) {}
|
clearCacheFor(type: Type) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for creating a compiler
|
||||||
|
*
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
export type CompilerOptions = {
|
||||||
|
useDebug?: boolean,
|
||||||
|
useJit?: boolean,
|
||||||
|
defaultEncapsulation?: ViewEncapsulation,
|
||||||
|
providers?: any[],
|
||||||
|
deprecatedAppProviders?: any[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A factory for creating a Compiler
|
||||||
|
*
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
export abstract class CompilerFactory {
|
||||||
|
static mergeOptions(defaultOptions: CompilerOptions = {}, newOptions: CompilerOptions = {}):
|
||||||
|
CompilerOptions {
|
||||||
|
return {
|
||||||
|
useDebug: _firstDefined(newOptions.useDebug, defaultOptions.useDebug),
|
||||||
|
useJit: _firstDefined(newOptions.useJit, defaultOptions.useJit),
|
||||||
|
defaultEncapsulation:
|
||||||
|
_firstDefined(newOptions.defaultEncapsulation, defaultOptions.defaultEncapsulation),
|
||||||
|
providers: _mergeArrays(defaultOptions.providers, newOptions.providers),
|
||||||
|
deprecatedAppProviders:
|
||||||
|
_mergeArrays(defaultOptions.deprecatedAppProviders, newOptions.deprecatedAppProviders)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
withDefaults(options: CompilerOptions = {}): CompilerFactory {
|
||||||
|
return new _DefaultApplyingCompilerFactory(this, options);
|
||||||
|
}
|
||||||
|
abstract createCompiler(options?: CompilerOptions): Compiler;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DefaultApplyingCompilerFactory extends CompilerFactory {
|
||||||
|
constructor(private _delegate: CompilerFactory, private _options: CompilerOptions) { super(); }
|
||||||
|
|
||||||
|
createCompiler(options: CompilerOptions = {}): Compiler {
|
||||||
|
return this._delegate.createCompiler(CompilerFactory.mergeOptions(this._options, options));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _firstDefined<T>(...args: T[]): T {
|
||||||
|
for (var i = 0; i < args.length; i++) {
|
||||||
|
if (args[i] !== undefined) {
|
||||||
|
return args[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _mergeArrays(...parts: any[][]): any[] {
|
||||||
|
let result: any[] = [];
|
||||||
|
parts.forEach((part) => result.push(...part));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {AppModule, AppModuleFactory, AppModuleMetadata, AppModuleRef, Compiler, ComponentStillLoadingError, Injector, PlatformRef, Provider, Type} from '../index';
|
import {AppModule, AppModuleFactory, AppModuleMetadata, AppModuleRef, Compiler, CompilerFactory, ComponentStillLoadingError, Injector, PlatformRef, Provider, Type} from '../index';
|
||||||
import {ListWrapper} from '../src/facade/collection';
|
import {ListWrapper} from '../src/facade/collection';
|
||||||
import {BaseException} from '../src/facade/exceptions';
|
import {BaseException} from '../src/facade/exceptions';
|
||||||
import {FunctionWrapper, isPresent, stringify} from '../src/facade/lang';
|
import {FunctionWrapper, isPresent, stringify} from '../src/facade/lang';
|
||||||
@ -15,14 +15,6 @@ import {AsyncTestCompleter} from './async_test_completer';
|
|||||||
|
|
||||||
const UNDEFINED = new Object();
|
const UNDEFINED = new Object();
|
||||||
|
|
||||||
/**
|
|
||||||
* Signature of the compiler factory passed to `initTestEnvironment`.
|
|
||||||
*
|
|
||||||
* @experimental
|
|
||||||
*/
|
|
||||||
export type TestCompilerFactory =
|
|
||||||
(config: {providers?: Array<Type|Provider|any[]>, useJit?: boolean}) => Compiler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
@ -54,8 +46,6 @@ export class TestInjector implements Injector {
|
|||||||
this._instantiated = false;
|
this._instantiated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
compilerFactory: TestCompilerFactory = null;
|
|
||||||
|
|
||||||
platform: PlatformRef = null;
|
platform: PlatformRef = null;
|
||||||
|
|
||||||
appModule: Type = null;
|
appModule: Type = null;
|
||||||
@ -118,8 +108,12 @@ export class TestInjector implements Injector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createCompilerAndModuleMeta(): AppModuleMetadata {
|
private _createCompilerAndModuleMeta(): AppModuleMetadata {
|
||||||
this._compiler =
|
const compilerFactory: CompilerFactory = this.platform.injector.get(CompilerFactory);
|
||||||
this.compilerFactory({providers: this._compilerProviders, useJit: this._compilerUseJit});
|
this._compiler = compilerFactory.createCompiler({
|
||||||
|
providers: this._compilerProviders,
|
||||||
|
useJit: this._compilerUseJit,
|
||||||
|
deprecatedAppProviders: this._providers
|
||||||
|
});
|
||||||
const moduleMeta = new AppModuleMetadata({
|
const moduleMeta = new AppModuleMetadata({
|
||||||
providers: this._providers.concat([{provide: TestInjector, useValue: this}]),
|
providers: this._providers.concat([{provide: TestInjector, useValue: this}]),
|
||||||
modules: this._modules.concat([this.appModule]),
|
modules: this._modules.concat([this.appModule]),
|
||||||
@ -181,18 +175,16 @@ export function getTestInjector() {
|
|||||||
* suite on the current platform. If you absolutely need to change the providers,
|
* suite on the current platform. If you absolutely need to change the providers,
|
||||||
* first use `resetTestEnvironment`.
|
* first use `resetTestEnvironment`.
|
||||||
*
|
*
|
||||||
* Test Providers for individual platforms are available from
|
* Test modules and platforms for individual platforms are available from
|
||||||
* 'angular2/platform/testing/<platform_name>'.
|
* 'angular2/platform/testing/<platform_name>'.
|
||||||
*
|
*
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export function initTestEnvironment(
|
export function initTestEnvironment(appModule: Type, platform: PlatformRef) {
|
||||||
compilerFactory: TestCompilerFactory, platform: PlatformRef, appModule: Type) {
|
|
||||||
var testInjector = getTestInjector();
|
var testInjector = getTestInjector();
|
||||||
if (testInjector.compilerFactory || testInjector.platform || testInjector.appModule) {
|
if (testInjector.platform || testInjector.appModule) {
|
||||||
throw new BaseException('Cannot set base providers because it has already been called');
|
throw new BaseException('Cannot set base providers because it has already been called');
|
||||||
}
|
}
|
||||||
testInjector.compilerFactory = compilerFactory;
|
|
||||||
testInjector.platform = platform;
|
testInjector.platform = platform;
|
||||||
testInjector.appModule = appModule;
|
testInjector.appModule = appModule;
|
||||||
}
|
}
|
||||||
@ -204,7 +196,6 @@ export function initTestEnvironment(
|
|||||||
*/
|
*/
|
||||||
export function resetTestEnvironment() {
|
export function resetTestEnvironment() {
|
||||||
var testInjector = getTestInjector();
|
var testInjector = getTestInjector();
|
||||||
testInjector.compilerFactory = null;
|
|
||||||
testInjector.platform = null;
|
testInjector.platform = null;
|
||||||
testInjector.appModule = null;
|
testInjector.appModule = null;
|
||||||
testInjector.reset();
|
testInjector.reset();
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {COMMON_DIRECTIVES, COMMON_PIPES} from '@angular/common';
|
import {COMMON_DIRECTIVES, COMMON_PIPES} from '@angular/common';
|
||||||
import {COMPILER_PROVIDERS, CompilerConfig, XHR} from '@angular/compiler';
|
import {COMPILER_PROVIDERS, CompilerConfig, XHR, RUNTIME_COMPILER_FACTORY,} from '@angular/compiler';
|
||||||
import {AppModule, AppModuleRef, ApplicationRef, Compiler, ComponentRef, ComponentResolver, ExceptionHandler, PLATFORM_DIRECTIVES, PLATFORM_PIPES, ReflectiveInjector, Type, coreLoadAndBootstrap, isDevMode} from '@angular/core';
|
import {AppModule, AppModuleRef, ApplicationRef, Compiler, ComponentRef, ComponentResolver, ExceptionHandler, PLATFORM_DIRECTIVES, PLATFORM_PIPES, ReflectiveInjector, Type, coreLoadAndBootstrap, bootstrapModule, bootstrapModuleFactory, isDevMode, OpaqueToken, PlatformRef, getPlatform, assertPlatform, createPlatform, PLATFORM_INITIALIZER, CompilerOptions, CompilerFactory, createPlatformFactory} from '@angular/core';
|
||||||
import {BROWSER_APP_PROVIDERS, BrowserModule, WORKER_APP_APPLICATION_PROVIDERS, WORKER_SCRIPT, WORKER_UI_APPLICATION_PROVIDERS, bootstrapModuleFactory, browserPlatform, workerAppPlatform, workerUiPlatform} from '@angular/platform-browser';
|
import {BROWSER_APP_PROVIDERS, BrowserModule, WORKER_APP_APPLICATION_PROVIDERS, WORKER_SCRIPT, WORKER_UI_APPLICATION_PROVIDERS, browserPlatform, workerAppPlatform, workerUiPlatform, BROWSER_PLATFORM_PROVIDERS} from '@angular/platform-browser';
|
||||||
|
|
||||||
import {Console, ReflectionCapabilities, reflector} from './core_private';
|
import {Console, ReflectionCapabilities, reflector} from './core_private';
|
||||||
import {getDOM, initDomAdapter} from './platform_browser_private';
|
import {getDOM, initDomAdapter} from './platform_browser_private';
|
||||||
@ -18,8 +18,6 @@ import {ConcreteType, isPresent, stringify} from './src/facade/lang';
|
|||||||
import {CachedXHR} from './src/xhr/xhr_cache';
|
import {CachedXHR} from './src/xhr/xhr_cache';
|
||||||
import {XHRImpl} from './src/xhr/xhr_impl';
|
import {XHRImpl} from './src/xhr/xhr_impl';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
@ -36,61 +34,40 @@ export const BROWSER_APP_COMPILER_PROVIDERS: Array<any /*Type | Provider | any[]
|
|||||||
{provide: PLATFORM_PIPES, useValue: COMMON_PIPES, multi: true}
|
{provide: PLATFORM_PIPES, useValue: COMMON_PIPES, multi: true}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export const CACHED_TEMPLATE_PROVIDER: Array<any /*Type | Provider | any[]*/> =
|
export const CACHED_TEMPLATE_PROVIDER: Array<any /*Type | Provider | any[]*/> =
|
||||||
[{provide: XHR, useClass: CachedXHR}];
|
[{provide: XHR, useClass: CachedXHR}];
|
||||||
|
|
||||||
function _initGlobals() {
|
function initReflector() {
|
||||||
initDomAdapter();
|
|
||||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the runtime compiler for the browser.
|
* CompilerFactory for the browser dynamic platform
|
||||||
*
|
*
|
||||||
* @stable
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export function browserCompiler({useDebug, useJit = true, providers = []}: {
|
export const BROWSER_DYNAMIC_COMPILER_FACTORY =
|
||||||
useDebug?: boolean,
|
RUNTIME_COMPILER_FACTORY.withDefaults({providers: [{provide: XHR, useClass: XHRImpl}]});
|
||||||
useJit?: boolean,
|
|
||||||
providers?: Array<any /*Type | Provider | any[]*/>
|
|
||||||
} = {}): Compiler {
|
|
||||||
_initGlobals();
|
|
||||||
if (useDebug === undefined) {
|
|
||||||
useDebug = isDevMode();
|
|
||||||
}
|
|
||||||
const injector = ReflectiveInjector.resolveAndCreate([
|
|
||||||
COMPILER_PROVIDERS, {
|
|
||||||
provide: CompilerConfig,
|
|
||||||
useValue: new CompilerConfig({genDebugInfo: useDebug, useJit: useJit})
|
|
||||||
},
|
|
||||||
{provide: XHR, useClass: XHRImpl}, providers ? providers : []
|
|
||||||
]);
|
|
||||||
return injector.get(Compiler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of an `@AppModule` for the browser platform.
|
* Providers for the browser dynamic platform
|
||||||
*
|
*
|
||||||
* ## Simple Example
|
* @experimental
|
||||||
*
|
|
||||||
* ```typescript
|
|
||||||
* @AppModule({
|
|
||||||
* modules: [BrowserModule]
|
|
||||||
* })
|
|
||||||
* class MyModule {}
|
|
||||||
*
|
|
||||||
* let moduleRef = bootstrapModule(MyModule);
|
|
||||||
* ```
|
|
||||||
* @stable
|
|
||||||
*/
|
*/
|
||||||
export function bootstrapModule<M>(
|
export const BROWSER_DYNAMIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||||
moduleType: ConcreteType<M>, compiler: Compiler = browserCompiler()): Promise<AppModuleRef<M>> {
|
BROWSER_PLATFORM_PROVIDERS,
|
||||||
return compiler.compileAppModuleAsync(moduleType).then(bootstrapModuleFactory);
|
{provide: CompilerFactory, useValue: BROWSER_DYNAMIC_COMPILER_FACTORY},
|
||||||
}
|
{provide: PLATFORM_INITIALIZER, useValue: initReflector, multi: true},
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @experimental API related to bootstrapping are still under review.
|
||||||
|
*/
|
||||||
|
export const browserDynamicPlatform =
|
||||||
|
createPlatformFactory('browserDynamic', BROWSER_DYNAMIC_PLATFORM_PROVIDERS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrapping for Angular applications.
|
* Bootstrapping for Angular applications.
|
||||||
@ -175,13 +152,13 @@ export function bootstrap<C>(
|
|||||||
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<C>>;
|
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<C>>;
|
||||||
export function bootstrap<C>(
|
export function bootstrap<C>(
|
||||||
appComponentType: ConcreteType<C>,
|
appComponentType: ConcreteType<C>,
|
||||||
{providers, directives, pipes, modules, precompile, compiler}?: {
|
{providers, directives, pipes, modules, precompile, compilerOptions}?: {
|
||||||
providers?: Array<any /*Type | Provider | any[]*/>,
|
providers?: Array<any /*Type | Provider | any[]*/>,
|
||||||
directives?: any[],
|
directives?: any[],
|
||||||
pipes?: any[],
|
pipes?: any[],
|
||||||
modules?: any[],
|
modules?: any[],
|
||||||
precompile?: any[],
|
precompile?: any[],
|
||||||
compiler?: Compiler
|
compilerOptions?: CompilerOptions
|
||||||
}): Promise<ComponentRef<C>>;
|
}): Promise<ComponentRef<C>>;
|
||||||
export function bootstrap<C>(
|
export function bootstrap<C>(
|
||||||
appComponentType: ConcreteType<C>,
|
appComponentType: ConcreteType<C>,
|
||||||
@ -191,10 +168,9 @@ export function bootstrap<C>(
|
|||||||
pipes: any[],
|
pipes: any[],
|
||||||
modules: any[],
|
modules: any[],
|
||||||
precompile: any[],
|
precompile: any[],
|
||||||
compiler: Compiler
|
compilerOptions: CompilerOptions
|
||||||
}): Promise<ComponentRef<C>> {
|
}): Promise<ComponentRef<C>> {
|
||||||
_initGlobals();
|
let compilerOptions: CompilerOptions;
|
||||||
let compiler: Compiler;
|
|
||||||
let compilerProviders: any = [];
|
let compilerProviders: any = [];
|
||||||
let providers: any[] = [];
|
let providers: any[] = [];
|
||||||
let directives: any[] = [];
|
let directives: any[] = [];
|
||||||
@ -209,56 +185,8 @@ export function bootstrap<C>(
|
|||||||
pipes = normalizeArray(customProvidersOrDynamicModule.pipes);
|
pipes = normalizeArray(customProvidersOrDynamicModule.pipes);
|
||||||
modules = normalizeArray(customProvidersOrDynamicModule.modules);
|
modules = normalizeArray(customProvidersOrDynamicModule.modules);
|
||||||
precompile = normalizeArray(customProvidersOrDynamicModule.precompile);
|
precompile = normalizeArray(customProvidersOrDynamicModule.precompile);
|
||||||
compiler = customProvidersOrDynamicModule.compiler;
|
compilerOptions = customProvidersOrDynamicModule.compilerOptions;
|
||||||
}
|
}
|
||||||
const deprecationMessages: string[] = [];
|
|
||||||
if (providers && providers.length > 0) {
|
|
||||||
// Note: This is a hack to still support the old way
|
|
||||||
// of configuring platform directives / pipes and the compiler xhr.
|
|
||||||
// This will soon be deprecated!
|
|
||||||
const inj = ReflectiveInjector.resolveAndCreate(providers);
|
|
||||||
const compilerConfig: CompilerConfig = inj.get(CompilerConfig, null);
|
|
||||||
if (compilerConfig) {
|
|
||||||
// Note: forms read the platform directives / pipes, modify them
|
|
||||||
// and provide a CompilerConfig out of it
|
|
||||||
directives = directives.concat(compilerConfig.platformDirectives);
|
|
||||||
pipes = pipes.concat(compilerConfig.platformPipes);
|
|
||||||
deprecationMessages.push(
|
|
||||||
`Passing a CompilerConfig to "bootstrap()" as provider is deprecated. Pass the provider to "createCompiler()" and call "bootstrap()" with the created compiler instead.`);
|
|
||||||
} else {
|
|
||||||
// If nobody provided a CompilerConfig, use the
|
|
||||||
// PLATFORM_DIRECTIVES / PLATFORM_PIPES values directly.
|
|
||||||
const platformDirectives = inj.get(PLATFORM_DIRECTIVES, []);
|
|
||||||
if (platformDirectives.length > 0) {
|
|
||||||
deprecationMessages.push(
|
|
||||||
`Passing PLATFORM_DIRECTIVES to "bootstrap()" as provider is deprecated. Use the new parameter "directives" of "bootstrap()" instead.`);
|
|
||||||
}
|
|
||||||
directives = directives.concat(platformDirectives);
|
|
||||||
const platformPipes = inj.get(PLATFORM_PIPES, []);
|
|
||||||
if (platformPipes.length > 0) {
|
|
||||||
deprecationMessages.push(
|
|
||||||
`Passing PLATFORM_PIPES to "bootstrap()" as provider is deprecated. Use the new parameter "pipes" of "bootstrap()" instead.`);
|
|
||||||
}
|
|
||||||
pipes = pipes.concat(platformPipes);
|
|
||||||
}
|
|
||||||
const xhr = inj.get(XHR, null);
|
|
||||||
if (xhr) {
|
|
||||||
compilerProviders.push([{provide: XHR, useValue: xhr}]);
|
|
||||||
deprecationMessages.push(
|
|
||||||
`Passing an instance of XHR to "bootstrap()" as provider is deprecated. Pass the provider to "createCompiler()" and call "bootstrap()" with the created compiler instead.`);
|
|
||||||
}
|
|
||||||
// Need to copy console from providers to compiler
|
|
||||||
// as well so that we can test the above deprecation messages!
|
|
||||||
const console = inj.get(Console, null);
|
|
||||||
if (console) {
|
|
||||||
compilerProviders.push([{provide: Console, useValue: console}]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!compiler) {
|
|
||||||
compiler = browserCompiler({providers: compilerProviders});
|
|
||||||
}
|
|
||||||
const console: Console = compiler.injector.get(Console);
|
|
||||||
deprecationMessages.forEach((msg) => { console.warn(msg); });
|
|
||||||
|
|
||||||
@AppModule({
|
@AppModule({
|
||||||
providers: providers,
|
providers: providers,
|
||||||
@ -268,13 +196,15 @@ export function bootstrap<C>(
|
|||||||
precompile: precompile.concat([appComponentType])
|
precompile: precompile.concat([appComponentType])
|
||||||
})
|
})
|
||||||
class DynamicModule {
|
class DynamicModule {
|
||||||
constructor(public appRef: ApplicationRef) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bootstrapModule(DynamicModule, compiler)
|
return bootstrapModule(
|
||||||
.then(
|
DynamicModule, browserDynamicPlatform(),
|
||||||
(moduleRef) => moduleRef.instance.appRef.waitForAsyncInitializers().then(
|
CompilerFactory.mergeOptions(compilerOptions, {deprecatedAppProviders: providers}))
|
||||||
() => moduleRef.instance.appRef.bootstrap(appComponentType)));
|
.then((moduleRef) => {
|
||||||
|
const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
|
||||||
|
return appRef.bootstrap(appComponentType);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -296,7 +226,6 @@ export function bootstrapWorkerUi(
|
|||||||
return PromiseWrapper.resolve(app.get(ApplicationRef));
|
return PromiseWrapper.resolve(app.get(ApplicationRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
|
@ -8,47 +8,44 @@
|
|||||||
|
|
||||||
import {CompilerConfig, DirectiveResolver, ViewResolver} from '@angular/compiler';
|
import {CompilerConfig, DirectiveResolver, ViewResolver} from '@angular/compiler';
|
||||||
import {MockDirectiveResolver, MockViewResolver, OverridingTestComponentBuilder} from '@angular/compiler/testing';
|
import {MockDirectiveResolver, MockViewResolver, OverridingTestComponentBuilder} from '@angular/compiler/testing';
|
||||||
import {AppModule, Compiler, Provider, ReflectiveInjector, Type} from '@angular/core';
|
import {AppModule, Compiler, CompilerFactory, PlatformRef, Provider, ReflectiveInjector, Type, createPlatformFactory} from '@angular/core';
|
||||||
import {TestComponentBuilder, TestComponentRenderer} from '@angular/core/testing';
|
import {TestComponentBuilder, TestComponentRenderer} from '@angular/core/testing';
|
||||||
import {BrowserTestModule, browserTestPlatform} from '@angular/platform-browser/testing';
|
import {BrowserTestModule, TEST_BROWSER_PLATFORM_PROVIDERS} from '@angular/platform-browser/testing';
|
||||||
|
|
||||||
import {BROWSER_APP_COMPILER_PROVIDERS} from './index';
|
import {BROWSER_APP_COMPILER_PROVIDERS, BROWSER_DYNAMIC_COMPILER_FACTORY, BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './index';
|
||||||
import {DOMTestComponentRenderer} from './testing/dom_test_component_renderer';
|
import {DOMTestComponentRenderer} from './testing/dom_test_component_renderer';
|
||||||
|
|
||||||
export * from './private_export_testing'
|
export * from './private_export_testing'
|
||||||
|
|
||||||
const TEST_BROWSER_DYNAMIC_COMPILER_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
/**
|
||||||
BROWSER_APP_COMPILER_PROVIDERS,
|
* CompilerFactory for browser dynamic test platform
|
||||||
[
|
*
|
||||||
{ provide: DirectiveResolver,
|
* @experimental
|
||||||
useClass: MockDirectiveResolver },
|
*/
|
||||||
{ provide: ViewResolver,
|
export const BROWSER_DYNAMIC_TEST_COMPILER_FACTORY = BROWSER_DYNAMIC_COMPILER_FACTORY.withDefaults({
|
||||||
useClass: MockViewResolver }
|
providers: [
|
||||||
|
{provide: DirectiveResolver, useClass: MockDirectiveResolver},
|
||||||
|
{provide: ViewResolver, useClass: MockViewResolver}
|
||||||
]
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Providers for the browser dynamic platform
|
||||||
|
*
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
const BROWSER_DYNAMIC_TEST_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||||
|
TEST_BROWSER_PLATFORM_PROVIDERS,
|
||||||
|
BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
||||||
|
{provide: CompilerFactory, useValue: BROWSER_DYNAMIC_TEST_COMPILER_FACTORY},
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a compiler for testing
|
|
||||||
*
|
|
||||||
* @stable
|
|
||||||
*/
|
|
||||||
export function browserTestCompiler(
|
|
||||||
{providers = [], useJit = true}: {providers?: Array<Type|Provider|any[]>,
|
|
||||||
useJit?: boolean} = {}): Compiler {
|
|
||||||
const injector = ReflectiveInjector.resolveAndCreate([
|
|
||||||
TEST_BROWSER_DYNAMIC_COMPILER_PROVIDERS,
|
|
||||||
{provide: CompilerConfig, useValue: new CompilerConfig({genDebugInfo: true, useJit: useJit})},
|
|
||||||
providers ? providers : []
|
|
||||||
]);
|
|
||||||
return injector.get(Compiler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Platform for testing.
|
|
||||||
*
|
|
||||||
* @experimental API related to bootstrapping are still under review.
|
* @experimental API related to bootstrapping are still under review.
|
||||||
*/
|
*/
|
||||||
export const browserDynamicTestPlatform = browserTestPlatform;
|
export const browserDynamicTestPlatform =
|
||||||
|
createPlatformFactory('browserDynamicTest', BROWSER_DYNAMIC_TEST_PLATFORM_PROVIDERS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AppModule for testing.
|
* AppModule for testing.
|
||||||
|
@ -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 {BROWSER_APP_PROVIDERS, BROWSER_PLATFORM_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS, BrowserModule, bootstrapModuleFactory, browserPlatform} from './src/browser';
|
export {BROWSER_APP_PROVIDERS, BROWSER_PLATFORM_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS, BrowserModule, browserPlatform} from './src/browser';
|
||||||
export {BrowserPlatformLocation} from './src/browser/location/browser_platform_location';
|
export {BrowserPlatformLocation} from './src/browser/location/browser_platform_location';
|
||||||
export {Title} from './src/browser/title';
|
export {Title} from './src/browser/title';
|
||||||
export {disableDebugTools, enableDebugTools} from './src/browser/tools/tools';
|
export {disableDebugTools, enableDebugTools} from './src/browser/tools/tools';
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {COMMON_DIRECTIVES, COMMON_PIPES, PlatformLocation} from '@angular/common';
|
import {COMMON_DIRECTIVES, COMMON_PIPES, PlatformLocation} from '@angular/common';
|
||||||
import {APPLICATION_COMMON_PROVIDERS, AppModule, AppModuleFactory, AppModuleRef, ExceptionHandler, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, SanitizationService, Testability, assertPlatform, createPlatform, getPlatform, isDevMode} from '@angular/core';
|
import {APPLICATION_COMMON_PROVIDERS, AppModule, AppModuleFactory, AppModuleRef, ExceptionHandler, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, SanitizationService, Testability, assertPlatform, createPlatform, createPlatformFactory, getPlatform, isDevMode} from '@angular/core';
|
||||||
|
|
||||||
import {wtfInit} from '../core_private';
|
import {wtfInit} from '../core_private';
|
||||||
import {AnimationDriver} from '../src/dom/animation_driver';
|
import {AnimationDriver} from '../src/dom/animation_driver';
|
||||||
@ -28,7 +28,6 @@ import {DomSharedStylesHost, SharedStylesHost} from './dom/shared_styles_host';
|
|||||||
import {isBlank} from './facade/lang';
|
import {isBlank} from './facade/lang';
|
||||||
import {DomSanitizationService, DomSanitizationServiceImpl} from './security/dom_sanitization_service';
|
import {DomSanitizationService, DomSanitizationServiceImpl} from './security/dom_sanitization_service';
|
||||||
|
|
||||||
const BROWSER_PLATFORM_MARKER = new OpaqueToken('BrowserPlatformMarker');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of providers to initialize the Angular platform in a web browser.
|
* A set of providers to initialize the Angular platform in a web browser.
|
||||||
@ -38,8 +37,7 @@ const BROWSER_PLATFORM_MARKER = new OpaqueToken('BrowserPlatformMarker');
|
|||||||
* @experimental API related to bootstrapping are still under review.
|
* @experimental API related to bootstrapping are still under review.
|
||||||
*/
|
*/
|
||||||
export const BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
export const BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||||
{provide: BROWSER_PLATFORM_MARKER, useValue: true}, PLATFORM_COMMON_PROVIDERS,
|
PLATFORM_COMMON_PROVIDERS, {provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true},
|
||||||
{provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true},
|
|
||||||
{provide: PlatformLocation, useClass: BrowserPlatformLocation}
|
{provide: PlatformLocation, useClass: BrowserPlatformLocation}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -80,12 +78,7 @@ export const BROWSER_APP_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
|||||||
/**
|
/**
|
||||||
* @experimental API related to bootstrapping are still under review.
|
* @experimental API related to bootstrapping are still under review.
|
||||||
*/
|
*/
|
||||||
export function browserPlatform(): PlatformRef {
|
export const browserPlatform = createPlatformFactory('browser', BROWSER_PLATFORM_PROVIDERS);
|
||||||
if (isBlank(getPlatform())) {
|
|
||||||
createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PLATFORM_PROVIDERS));
|
|
||||||
}
|
|
||||||
return assertPlatform(BROWSER_PLATFORM_MARKER);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initDomAdapter() {
|
export function initDomAdapter() {
|
||||||
BrowserDomAdapter.makeCurrent();
|
BrowserDomAdapter.makeCurrent();
|
||||||
@ -110,7 +103,8 @@ export function _resolveDefaultAnimationDriver(): AnimationDriver {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The app module for the browser.
|
* The app module for the browser.
|
||||||
* @stable
|
*
|
||||||
|
* @experimental
|
||||||
*/
|
*/
|
||||||
@AppModule({
|
@AppModule({
|
||||||
providers: [
|
providers: [
|
||||||
@ -121,37 +115,3 @@ export function _resolveDefaultAnimationDriver(): AnimationDriver {
|
|||||||
})
|
})
|
||||||
export class BrowserModule {
|
export class BrowserModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an instance of an `@AppModule` for the browser platform
|
|
||||||
* for offline compilation.
|
|
||||||
*
|
|
||||||
* ## Simple Example
|
|
||||||
*
|
|
||||||
* ```typescript
|
|
||||||
* my_module.ts:
|
|
||||||
*
|
|
||||||
* @AppModule({
|
|
||||||
* modules: [BrowserModule]
|
|
||||||
* })
|
|
||||||
* class MyModule {}
|
|
||||||
*
|
|
||||||
* main.ts:
|
|
||||||
* import {MyModuleNgFactory} from './my_module.ngfactory';
|
|
||||||
* import {bootstrapModuleFactory} from '@angular/platform-browser';
|
|
||||||
*
|
|
||||||
* let moduleRef = bootstrapModuleFactory(MyModuleNgFactory);
|
|
||||||
* ```
|
|
||||||
* @stable
|
|
||||||
*/
|
|
||||||
export function bootstrapModuleFactory<M>(moduleFactory: AppModuleFactory<M>): AppModuleRef<M> {
|
|
||||||
let platformInjector = browserPlatform().injector;
|
|
||||||
// Note: We need to create the NgZone _before_ we instantiate the module,
|
|
||||||
// as instantiating the module creates some providers eagerly.
|
|
||||||
// So we create a mini parent injector that just contains the new NgZone and
|
|
||||||
// pass that as parent to the AppModuleFactory.
|
|
||||||
let ngZone = new NgZone({enableLongStackTrace: isDevMode()});
|
|
||||||
let ngZoneInjector =
|
|
||||||
ReflectiveInjector.resolveAndCreate([{provide: NgZone, useValue: ngZone}], platformInjector);
|
|
||||||
return ngZone.run(() => { return moduleFactory.create(ngZoneInjector); });
|
|
||||||
}
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {FORM_PROVIDERS} from '@angular/common';
|
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from '@angular/common';
|
||||||
import {APPLICATION_COMMON_PROVIDERS, APP_INITIALIZER, ExceptionHandler, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PlatformRef, ReflectiveInjector, RootRenderer, assertPlatform, createPlatform, getPlatform} from '@angular/core';
|
import {APPLICATION_COMMON_PROVIDERS, APP_INITIALIZER, AppModule, ExceptionHandler, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PlatformRef, ReflectiveInjector, RootRenderer, assertPlatform, createPlatform, createPlatformFactory, getPlatform} from '@angular/core';
|
||||||
|
|
||||||
import {BROWSER_SANITIZATION_PROVIDERS} from './browser';
|
import {BROWSER_SANITIZATION_PROVIDERS} from './browser';
|
||||||
import {isBlank, print} from './facade/lang';
|
import {isBlank, print} from './facade/lang';
|
||||||
@ -28,13 +28,11 @@ class PrintLogger {
|
|||||||
logGroupEnd() {}
|
logGroupEnd() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const WORKER_APP_PLATFORM_MARKER = new OpaqueToken('WorkerAppPlatformMarker');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export const WORKER_APP_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
export const WORKER_APP_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||||
[PLATFORM_COMMON_PROVIDERS, {provide: WORKER_APP_PLATFORM_MARKER, useValue: true}];
|
PLATFORM_COMMON_PROVIDERS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
@ -53,12 +51,7 @@ export const WORKER_APP_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any
|
|||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export function workerAppPlatform(): PlatformRef {
|
export const workerAppPlatform = createPlatformFactory('workerApp', WORKER_APP_PLATFORM_PROVIDERS);
|
||||||
if (isBlank(getPlatform())) {
|
|
||||||
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_APP_PLATFORM_PROVIDERS));
|
|
||||||
}
|
|
||||||
return assertPlatform(WORKER_APP_PLATFORM_MARKER);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _exceptionHandler(): ExceptionHandler {
|
function _exceptionHandler(): ExceptionHandler {
|
||||||
return new ExceptionHandler(new PrintLogger());
|
return new ExceptionHandler(new PrintLogger());
|
||||||
@ -82,3 +75,16 @@ function createMessageBus(zone: NgZone): MessageBus {
|
|||||||
function setupWebWorker(): void {
|
function setupWebWorker(): void {
|
||||||
WorkerDomAdapter.makeCurrent();
|
WorkerDomAdapter.makeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The app module for the worker app side.
|
||||||
|
*
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
@AppModule({
|
||||||
|
providers: WORKER_APP_APPLICATION_PROVIDERS,
|
||||||
|
directives: COMMON_DIRECTIVES,
|
||||||
|
pipes: COMMON_PIPES
|
||||||
|
})
|
||||||
|
export class WorkerAppModule {
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {APPLICATION_COMMON_PROVIDERS, APP_INITIALIZER, ExceptionHandler, Injectable, Injector, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, Testability, assertPlatform, createPlatform, getPlatform} from '@angular/core';
|
import {APPLICATION_COMMON_PROVIDERS, APP_INITIALIZER, AppModule, ExceptionHandler, Injectable, Injector, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, Testability, assertPlatform, createPlatform, createPlatformFactory, getPlatform} from '@angular/core';
|
||||||
|
|
||||||
import {wtfInit} from '../core_private';
|
import {wtfInit} from '../core_private';
|
||||||
|
|
||||||
@ -33,7 +33,6 @@ import {Serializer} from './web_workers/shared/serializer';
|
|||||||
import {ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_} from './web_workers/shared/service_message_broker';
|
import {ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_} from './web_workers/shared/service_message_broker';
|
||||||
import {MessageBasedRenderer} from './web_workers/ui/renderer';
|
import {MessageBasedRenderer} from './web_workers/ui/renderer';
|
||||||
|
|
||||||
const WORKER_RENDER_PLATFORM_MARKER = new OpaqueToken('WorkerRenderPlatformMarker');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class that exposes the Worker
|
* Wrapper class that exposes the Worker
|
||||||
@ -72,7 +71,7 @@ export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
|
|||||||
* @experimental WebWorker support is currently experimental.
|
* @experimental WebWorker support is currently experimental.
|
||||||
*/
|
*/
|
||||||
export const WORKER_UI_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
export const WORKER_UI_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||||
PLATFORM_COMMON_PROVIDERS, {provide: WORKER_RENDER_PLATFORM_MARKER, useValue: true},
|
PLATFORM_COMMON_PROVIDERS,
|
||||||
{provide: PLATFORM_INITIALIZER, useValue: initWebWorkerRenderPlatform, multi: true}
|
{provide: PLATFORM_INITIALIZER, useValue: initWebWorkerRenderPlatform, multi: true}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -132,12 +131,7 @@ function initWebWorkerRenderPlatform(): void {
|
|||||||
/**
|
/**
|
||||||
* @experimental WebWorker support is currently experimental.
|
* @experimental WebWorker support is currently experimental.
|
||||||
*/
|
*/
|
||||||
export function workerUiPlatform(): PlatformRef {
|
export const workerUiPlatform = createPlatformFactory('workerUi', WORKER_UI_PLATFORM_PROVIDERS);
|
||||||
if (isBlank(getPlatform())) {
|
|
||||||
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_UI_PLATFORM_PROVIDERS));
|
|
||||||
}
|
|
||||||
return assertPlatform(WORKER_RENDER_PLATFORM_MARKER);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _exceptionHandler(): ExceptionHandler {
|
function _exceptionHandler(): ExceptionHandler {
|
||||||
return new ExceptionHandler(getDOM());
|
return new ExceptionHandler(getDOM());
|
||||||
@ -181,3 +175,14 @@ function _resolveDefaultAnimationDriver(): AnimationDriver {
|
|||||||
// work with animations just yet...
|
// work with animations just yet...
|
||||||
return AnimationDriver.NOOP;
|
return AnimationDriver.NOOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The app module for the worker ui side.
|
||||||
|
* To use this, you need to create an own module that includes this module
|
||||||
|
* and provides the `WORKER_SCRIPT` token.
|
||||||
|
*
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
@AppModule({providers: WORKER_UI_APPLICATION_PROVIDERS})
|
||||||
|
export class WorkerUiModule {
|
||||||
|
}
|
||||||
|
@ -304,7 +304,7 @@ export function main() {
|
|||||||
])).then((compRef) => {
|
])).then((compRef) => {
|
||||||
expect(el).toHaveText('hello world!');
|
expect(el).toHaveText('hello world!');
|
||||||
expect(compilerConsole.warnings).toEqual([
|
expect(compilerConsole.warnings).toEqual([
|
||||||
'Passing an instance of XHR to "bootstrap()" as provider is deprecated. Pass the provider to "createCompiler()" and call "bootstrap()" with the created compiler instead.'
|
'Passing an instance of XHR to "bootstrap()" as provider is deprecated. Pass the provider via the new parameter "compilerOptions" of "bootstrap()" instead.'
|
||||||
]);
|
]);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -26,7 +26,7 @@ import {ServiceMessageBrokerFactory_} from '@angular/platform-browser/src/web_wo
|
|||||||
import {CompilerConfig} from '@angular/compiler';
|
import {CompilerConfig} from '@angular/compiler';
|
||||||
import {dispatchEvent} from '../../../../platform-browser/testing/browser_util';
|
import {dispatchEvent} from '../../../../platform-browser/testing/browser_util';
|
||||||
import {BrowserTestModule} from '@angular/platform-browser/testing';
|
import {BrowserTestModule} from '@angular/platform-browser/testing';
|
||||||
import {browserTestCompiler, browserDynamicTestPlatform} from '@angular/platform-browser-dynamic/testing'
|
import {browserDynamicTestPlatform} from '@angular/platform-browser-dynamic/testing'
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
function createWebWorkerBrokerFactory(
|
function createWebWorkerBrokerFactory(
|
||||||
@ -70,7 +70,6 @@ export function main() {
|
|||||||
uiRenderStore = new RenderStore();
|
uiRenderStore = new RenderStore();
|
||||||
var testUiInjector = new TestInjector();
|
var testUiInjector = new TestInjector();
|
||||||
testUiInjector.platform = browserDynamicTestPlatform();
|
testUiInjector.platform = browserDynamicTestPlatform();
|
||||||
testUiInjector.compilerFactory = browserTestCompiler;
|
|
||||||
testUiInjector.appModule = BrowserTestModule;
|
testUiInjector.appModule = BrowserTestModule;
|
||||||
testUiInjector.configureModule({
|
testUiInjector.configureModule({
|
||||||
providers: [
|
providers: [
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {LocationStrategy} from '@angular/common';
|
import {LocationStrategy} from '@angular/common';
|
||||||
import {APP_ID, AppModule, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, assertPlatform, createPlatform, getPlatform} from '@angular/core';
|
import {APP_ID, AppModule, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, assertPlatform, createPlatform, createPlatformFactory, getPlatform} from '@angular/core';
|
||||||
|
|
||||||
import {BROWSER_APP_PROVIDERS, BrowserModule} from '../src/browser';
|
import {BROWSER_APP_PROVIDERS, BrowserModule} from '../src/browser';
|
||||||
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
||||||
@ -16,8 +16,6 @@ import {ELEMENT_PROBE_PROVIDERS} from '../src/dom/debug/ng_probe';
|
|||||||
|
|
||||||
import {BrowserDetection} from './browser_util';
|
import {BrowserDetection} from './browser_util';
|
||||||
|
|
||||||
const BROWSER_TEST_PLATFORM_MARKER = new OpaqueToken('BrowserTestPlatformMarker');
|
|
||||||
|
|
||||||
function initBrowserTests() {
|
function initBrowserTests() {
|
||||||
BrowserDomAdapter.makeCurrent();
|
BrowserDomAdapter.makeCurrent();
|
||||||
BrowserDetection.setup();
|
BrowserDetection.setup();
|
||||||
@ -27,8 +25,13 @@ function createNgZone(): NgZone {
|
|||||||
return new NgZone({enableLongStackTrace: true});
|
return new NgZone({enableLongStackTrace: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
/**
|
||||||
PLATFORM_COMMON_PROVIDERS, {provide: BROWSER_TEST_PLATFORM_MARKER, useValue: true},
|
* Providers for the browser test platform
|
||||||
|
*
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
export const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||||
|
PLATFORM_COMMON_PROVIDERS,
|
||||||
{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -37,12 +40,8 @@ const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
|||||||
*
|
*
|
||||||
* @experimental API related to bootstrapping are still under review.
|
* @experimental API related to bootstrapping are still under review.
|
||||||
*/
|
*/
|
||||||
export function browserTestPlatform(): PlatformRef {
|
export const browserTestPlatform =
|
||||||
if (!getPlatform()) {
|
createPlatformFactory('browserTest', TEST_BROWSER_PLATFORM_PROVIDERS);
|
||||||
createPlatform(ReflectiveInjector.resolveAndCreate(TEST_BROWSER_PLATFORM_PROVIDERS));
|
|
||||||
}
|
|
||||||
return assertPlatform(BROWSER_TEST_PLATFORM_MARKER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AppModule for testing.
|
* AppModule for testing.
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {SERVER_PLATFORM_PROVIDERS, serverBootstrap, serverPlatform} from './src/server';
|
export {SERVER_PLATFORM_PROVIDERS, serverBootstrap, serverDynamicPlatform, serverPlatform} from './src/server';
|
||||||
|
@ -7,14 +7,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {PlatformLocation} from '@angular/common';
|
import {PlatformLocation} from '@angular/common';
|
||||||
import {ComponentRef, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, Type, assertPlatform, coreLoadAndBootstrap, createPlatform, getPlatform} from '@angular/core';
|
import {CompilerFactory, ComponentRef, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, Type, assertPlatform, coreLoadAndBootstrap, createPlatform, createPlatformFactory, getPlatform} from '@angular/core';
|
||||||
|
import {BROWSER_DYNAMIC_TEST_COMPILER_FACTORY} from '@angular/platform-browser-dynamic/testing';
|
||||||
|
|
||||||
import {ReflectionCapabilities, reflector, wtfInit} from '../core_private';
|
import {ReflectionCapabilities, reflector, wtfInit} from '../core_private';
|
||||||
|
|
||||||
import {Parse5DomAdapter} from './parse5_adapter';
|
import {Parse5DomAdapter} from './parse5_adapter';
|
||||||
|
|
||||||
const SERVER_PLATFORM_MARKER = new OpaqueToken('ServerPlatformMarker');
|
|
||||||
|
|
||||||
function notSupported(feature: string): Error {
|
function notSupported(feature: string): Error {
|
||||||
throw new Error(`platform-server does not support '${feature}'.`);
|
throw new Error(`platform-server does not support '${feature}'.`);
|
||||||
}
|
}
|
||||||
@ -39,9 +38,14 @@ class ServerPlatformLocation extends PlatformLocation {
|
|||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export const SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
export const SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||||
{provide: SERVER_PLATFORM_MARKER, useValue: true}, PLATFORM_COMMON_PROVIDERS,
|
PLATFORM_COMMON_PROVIDERS,
|
||||||
{provide: PLATFORM_INITIALIZER, useValue: initParse5Adapter, multi: true},
|
{provide: PLATFORM_INITIALIZER, useValue: initParse5Adapter, multi: true},
|
||||||
{provide: PlatformLocation, useClass: ServerPlatformLocation}
|
{provide: PlatformLocation, useClass: ServerPlatformLocation},
|
||||||
|
];
|
||||||
|
|
||||||
|
const SERVER_DYNAMIC_PROVIDERS: any[] = [
|
||||||
|
SERVER_PLATFORM_PROVIDERS,
|
||||||
|
{provide: CompilerFactory, useValue: BROWSER_DYNAMIC_TEST_COMPILER_FACTORY},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -53,12 +57,15 @@ function initParse5Adapter() {
|
|||||||
/**
|
/**
|
||||||
* @experimental
|
* @experimental
|
||||||
*/
|
*/
|
||||||
export function serverPlatform(): PlatformRef {
|
export const serverPlatform = createPlatformFactory('server', SERVER_PLATFORM_PROVIDERS);
|
||||||
if (!getPlatform()) {
|
|
||||||
createPlatform(ReflectiveInjector.resolveAndCreate(SERVER_PLATFORM_PROVIDERS));
|
/**
|
||||||
}
|
* The server platform that supports the runtime compiler.
|
||||||
return assertPlatform(SERVER_PLATFORM_MARKER);
|
*
|
||||||
}
|
* @experimental
|
||||||
|
*/
|
||||||
|
export const serverDynamicPlatform =
|
||||||
|
createPlatformFactory('serverDynamic', SERVER_DYNAMIC_PROVIDERS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to bootstrap Angular in server environment (such as node).
|
* Used to bootstrap Angular in server environment (such as node).
|
||||||
|
@ -6,29 +6,20 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {AppModule, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, assertPlatform, createPlatform, getPlatform} from '@angular/core';
|
import {AppModule, CompilerFactory, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, assertPlatform, createPlatform, createPlatformFactory, getPlatform} from '@angular/core';
|
||||||
import {BrowserDynamicTestModule, browserTestCompiler} from '@angular/platform-browser-dynamic/testing';
|
import {BROWSER_DYNAMIC_TEST_COMPILER_FACTORY, BrowserDynamicTestModule} from '@angular/platform-browser-dynamic/testing';
|
||||||
|
|
||||||
import {Parse5DomAdapter} from '../src/parse5_adapter';
|
import {Parse5DomAdapter} from '../src/parse5_adapter';
|
||||||
|
|
||||||
const SERVER_TEST_PLATFORM_MARKER = new OpaqueToken('ServerTestPlatformMarker');
|
|
||||||
|
|
||||||
function initServerTests() {
|
function initServerTests() {
|
||||||
Parse5DomAdapter.makeCurrent();
|
Parse5DomAdapter.makeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a compiler for testing
|
|
||||||
*
|
|
||||||
* @stable
|
|
||||||
*/
|
|
||||||
export const serverTestCompiler = browserTestCompiler;
|
|
||||||
|
|
||||||
const TEST_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
const TEST_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||||
/*@ts2dart_const*/[
|
/*@ts2dart_const*/[
|
||||||
PLATFORM_COMMON_PROVIDERS,
|
PLATFORM_COMMON_PROVIDERS,
|
||||||
/*@ts2dart_Provider*/ {provide: PLATFORM_INITIALIZER, useValue: initServerTests, multi: true},
|
/*@ts2dart_Provider*/ {provide: PLATFORM_INITIALIZER, useValue: initServerTests, multi: true},
|
||||||
{provide: SERVER_TEST_PLATFORM_MARKER, useValue: true}
|
{provide: CompilerFactory, useValue: BROWSER_DYNAMIC_TEST_COMPILER_FACTORY},
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,12 +27,8 @@ const TEST_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
|||||||
*
|
*
|
||||||
* @experimental API related to bootstrapping are still under review.
|
* @experimental API related to bootstrapping are still under review.
|
||||||
*/
|
*/
|
||||||
export function serverTestPlatform(): PlatformRef {
|
export const serverTestPlatform =
|
||||||
if (!getPlatform()) {
|
createPlatformFactory('serverTest', TEST_SERVER_PLATFORM_PROVIDERS);
|
||||||
createPlatform(ReflectiveInjector.resolveAndCreate(TEST_SERVER_PLATFORM_PROVIDERS));
|
|
||||||
}
|
|
||||||
return assertPlatform(SERVER_TEST_PLATFORM_MARKER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AppModule for testing.
|
* AppModule for testing.
|
||||||
|
@ -73,9 +73,8 @@ Promise.all([
|
|||||||
var testingBrowser = providers[1];
|
var testingBrowser = providers[1];
|
||||||
|
|
||||||
testing.initTestEnvironment(
|
testing.initTestEnvironment(
|
||||||
testingBrowser.browserTestCompiler,
|
testingBrowser.BrowserDynamicTestModule,
|
||||||
testingBrowser.browserDynamicTestPlatform(),
|
testingBrowser.browserDynamicTestPlatform());
|
||||||
testingBrowser.BrowserDynamicTestModule);
|
|
||||||
|
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
// Finally, load all spec files.
|
// Finally, load all spec files.
|
||||||
|
@ -3,7 +3,7 @@ set -ex -o pipefail
|
|||||||
|
|
||||||
# These ones can be `npm link`ed for fast development
|
# These ones can be `npm link`ed for fast development
|
||||||
LINKABLE_PKGS=(
|
LINKABLE_PKGS=(
|
||||||
$(pwd)/dist/packages-dist/{common,core,compiler,compiler-cli,platform-{browser,server}}
|
$(pwd)/dist/packages-dist/{common,core,compiler,compiler-cli,platform-{browser,server},platform-browser-dynamic}
|
||||||
$(pwd)/dist/tools/@angular/tsc-wrapped
|
$(pwd)/dist/tools/@angular/tsc-wrapped
|
||||||
)
|
)
|
||||||
PKGS=(
|
PKGS=(
|
||||||
|
@ -76,9 +76,8 @@ System.import('@angular/core/testing')
|
|||||||
return System.import('@angular/platform-browser-dynamic/testing')
|
return System.import('@angular/platform-browser-dynamic/testing')
|
||||||
.then(function(browserTesting) {
|
.then(function(browserTesting) {
|
||||||
coreTesting.initTestEnvironment(
|
coreTesting.initTestEnvironment(
|
||||||
browserTesting.browserTestCompiler,
|
browserTesting.BrowserDynamicTestModule,
|
||||||
browserTesting.browserDynamicTestPlatform(),
|
browserTesting.browserDynamicTestPlatform());
|
||||||
browserTesting.BrowserDynamicTestModule);
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
@ -2,5 +2,4 @@ var testingPlatformServer = require('../../all/@angular/platform-server/testing/
|
|||||||
var testing = require('../../all/@angular/core/testing');
|
var testing = require('../../all/@angular/core/testing');
|
||||||
|
|
||||||
testing.initTestEnvironment(
|
testing.initTestEnvironment(
|
||||||
testingPlatformServer.serverTestCompiler, testingPlatformServer.serverTestPlatform(),
|
testingPlatformServer.ServerTestModule, testingPlatformServer.serverTestPlatform());
|
||||||
testingPlatformServer.ServerTestModule);
|
|
||||||
|
25
tools/public_api_guard/core/index.d.ts
vendored
25
tools/public_api_guard/core/index.d.ts
vendored
@ -256,6 +256,12 @@ export declare class Binding extends Provider {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @stable */
|
||||||
|
export declare function bootstrapModule<M>(moduleType: ConcreteType<M>, platform: PlatformRef, compilerOptions?: CompilerOptions): Promise<AppModuleRef<M>>;
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare function bootstrapModuleFactory<M>(moduleFactory: AppModuleFactory<M>, platform: PlatformRef): AppModuleRef<M>;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare enum ChangeDetectionStrategy {
|
export declare enum ChangeDetectionStrategy {
|
||||||
OnPush = 0,
|
OnPush = 0,
|
||||||
@ -302,6 +308,22 @@ export declare class Compiler {
|
|||||||
compileComponentSync<T>(component: ConcreteType<T>): ComponentFactory<T>;
|
compileComponentSync<T>(component: ConcreteType<T>): ComponentFactory<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare abstract class CompilerFactory {
|
||||||
|
abstract createCompiler(options?: CompilerOptions): Compiler;
|
||||||
|
withDefaults(options?: CompilerOptions): CompilerFactory;
|
||||||
|
static mergeOptions(defaultOptions?: CompilerOptions, newOptions?: CompilerOptions): CompilerOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare type CompilerOptions = {
|
||||||
|
useDebug?: boolean;
|
||||||
|
useJit?: boolean;
|
||||||
|
defaultEncapsulation?: ViewEncapsulation;
|
||||||
|
providers?: any[];
|
||||||
|
deprecatedAppProviders?: any[];
|
||||||
|
};
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare var Component: ComponentMetadataFactory;
|
export declare var Component: ComponentMetadataFactory;
|
||||||
|
|
||||||
@ -513,6 +535,9 @@ export declare function coreLoadAndBootstrap(componentType: Type, injector: Inje
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function createPlatform(injector: Injector): PlatformRef;
|
export declare function createPlatform(injector: Injector): PlatformRef;
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare function createPlatformFactory(name: string, providers: any[]): () => PlatformRef;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare class CyclicDependencyError extends AbstractProviderError {
|
export declare class CyclicDependencyError extends AbstractProviderError {
|
||||||
constructor(injector: ReflectiveInjector, key: ReflectiveKey);
|
constructor(injector: ReflectiveInjector, key: ReflectiveKey);
|
||||||
|
9
tools/public_api_guard/core/testing.d.ts
vendored
9
tools/public_api_guard/core/testing.d.ts
vendored
@ -83,7 +83,7 @@ export declare function getTestInjector(): TestInjector;
|
|||||||
export declare var iit: any;
|
export declare var iit: any;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function initTestEnvironment(compilerFactory: TestCompilerFactory, platform: PlatformRef, appModule: Type): void;
|
export declare function initTestEnvironment(appModule: Type, platform: PlatformRef): void;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare function inject(tokens: any[], fn: Function): () => any;
|
export declare function inject(tokens: any[], fn: Function): () => any;
|
||||||
@ -106,12 +106,6 @@ export declare var it: any;
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function resetTestEnvironment(): void;
|
export declare function resetTestEnvironment(): void;
|
||||||
|
|
||||||
/** @experimental */
|
|
||||||
export declare type TestCompilerFactory = (config: {
|
|
||||||
providers?: Array<Type | Provider | any[]>;
|
|
||||||
useJit?: boolean;
|
|
||||||
}) => Compiler;
|
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare class TestComponentBuilder {
|
export declare class TestComponentBuilder {
|
||||||
protected _injector: Injector;
|
protected _injector: Injector;
|
||||||
@ -136,7 +130,6 @@ export declare class TestComponentRenderer {
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare class TestInjector implements Injector {
|
export declare class TestInjector implements Injector {
|
||||||
appModule: Type;
|
appModule: Type;
|
||||||
compilerFactory: TestCompilerFactory;
|
|
||||||
platform: PlatformRef;
|
platform: PlatformRef;
|
||||||
configureCompiler(config: {
|
configureCompiler(config: {
|
||||||
providers?: any[];
|
providers?: any[];
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function bootstrap<C>(appComponentType: ConcreteType<C>, customProviders?: Array<any>): Promise<ComponentRef<C>>;
|
export declare function bootstrap<C>(appComponentType: ConcreteType<C>, customProviders?: Array<any>): Promise<ComponentRef<C>>;
|
||||||
|
|
||||||
/** @stable */
|
|
||||||
export declare function bootstrapModule<M>(moduleType: ConcreteType<M>, compiler?: Compiler): Promise<AppModuleRef<M>>;
|
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function bootstrapWorkerApp(appComponentType: Type, customProviders?: Array<any>): Promise<ComponentRef<any>>;
|
export declare function bootstrapWorkerApp(appComponentType: Type, customProviders?: Array<any>): Promise<ComponentRef<any>>;
|
||||||
|
|
||||||
@ -13,12 +10,14 @@ export declare function bootstrapWorkerUi(workerScriptUri: string, customProvide
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const BROWSER_APP_COMPILER_PROVIDERS: Array<any>;
|
export declare const BROWSER_APP_COMPILER_PROVIDERS: Array<any>;
|
||||||
|
|
||||||
/** @stable */
|
/** @experimental */
|
||||||
export declare function browserCompiler({useDebug, useJit, providers}?: {
|
export declare const BROWSER_DYNAMIC_COMPILER_FACTORY: CompilerFactory;
|
||||||
useDebug?: boolean;
|
|
||||||
useJit?: boolean;
|
/** @experimental */
|
||||||
providers?: Array<any>;
|
export declare const BROWSER_DYNAMIC_PLATFORM_PROVIDERS: Array<any>;
|
||||||
}): Compiler;
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare const browserDynamicPlatform: () => PlatformRef;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const CACHED_TEMPLATE_PROVIDER: Array<any>;
|
export declare const CACHED_TEMPLATE_PROVIDER: Array<any>;
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
|
/** @experimental */
|
||||||
|
export declare const BROWSER_DYNAMIC_TEST_COMPILER_FACTORY: CompilerFactory;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare class BrowserDynamicTestModule {
|
export declare class BrowserDynamicTestModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const browserDynamicTestPlatform: typeof browserTestPlatform;
|
export declare const browserDynamicTestPlatform: () => PlatformRef;
|
||||||
|
|
||||||
/** @stable */
|
|
||||||
export declare function browserTestCompiler({providers, useJit}?: {
|
|
||||||
providers?: Array<Type | Provider | any[]>;
|
|
||||||
useJit?: boolean;
|
|
||||||
}): Compiler;
|
|
||||||
|
@ -4,9 +4,6 @@ export declare abstract class AnimationDriver {
|
|||||||
static NOOP: AnimationDriver;
|
static NOOP: AnimationDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @stable */
|
|
||||||
export declare function bootstrapModuleFactory<M>(moduleFactory: AppModuleFactory<M>): AppModuleRef<M>;
|
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const BROWSER_APP_PROVIDERS: Array<any>;
|
export declare const BROWSER_APP_PROVIDERS: Array<any>;
|
||||||
|
|
||||||
@ -16,12 +13,12 @@ export declare const BROWSER_PLATFORM_PROVIDERS: Array<any>;
|
|||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare const BROWSER_SANITIZATION_PROVIDERS: Array<any>;
|
export declare const BROWSER_SANITIZATION_PROVIDERS: Array<any>;
|
||||||
|
|
||||||
/** @stable */
|
/** @experimental */
|
||||||
export declare class BrowserModule {
|
export declare class BrowserModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function browserPlatform(): PlatformRef;
|
export declare const browserPlatform: () => PlatformRef;
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare class BrowserPlatformLocation extends PlatformLocation {
|
export declare class BrowserPlatformLocation extends PlatformLocation {
|
||||||
@ -227,7 +224,15 @@ export declare const WORKER_UI_PLATFORM_PROVIDERS: Array<any>;
|
|||||||
export declare const WORKER_UI_STARTABLE_MESSAGING_SERVICE: OpaqueToken;
|
export declare const WORKER_UI_STARTABLE_MESSAGING_SERVICE: OpaqueToken;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function workerAppPlatform(): PlatformRef;
|
export declare class WorkerAppModule {
|
||||||
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function workerUiPlatform(): PlatformRef;
|
export declare const workerAppPlatform: () => PlatformRef;
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare class WorkerUiModule {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare const workerUiPlatform: () => PlatformRef;
|
||||||
|
@ -3,4 +3,7 @@ export declare class BrowserTestModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function browserTestPlatform(): PlatformRef;
|
export declare const browserTestPlatform: () => PlatformRef;
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any>;
|
||||||
|
@ -5,4 +5,7 @@ export declare const SERVER_PLATFORM_PROVIDERS: Array<any>;
|
|||||||
export declare function serverBootstrap(appComponentType: Type, providers: Array<any>): Promise<ComponentRef<any>>;
|
export declare function serverBootstrap(appComponentType: Type, providers: Array<any>): Promise<ComponentRef<any>>;
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function serverPlatform(): PlatformRef;
|
export declare const serverDynamicPlatform: () => PlatformRef;
|
||||||
|
|
||||||
|
/** @experimental */
|
||||||
|
export declare const serverPlatform: () => PlatformRef;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
/** @stable */
|
|
||||||
export declare const serverTestCompiler: typeof browserTestCompiler;
|
|
||||||
|
|
||||||
/** @stable */
|
/** @stable */
|
||||||
export declare class ServerTestModule {
|
export declare class ServerTestModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @experimental */
|
/** @experimental */
|
||||||
export declare function serverTestPlatform(): PlatformRef;
|
export declare const serverTestPlatform: () => PlatformRef;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user