refactor(core): support non reflective bootstrap.
This changes Angular so that it can be used without reflection (assuming a codegen for injectors). BREAKIKNG CHANGE: - Drops `APP_COMPONENT` provider. Instead, inject `ApplicationRef` and read its `componentTypes` property. - long form bootstrap has changed into the following: ``` var platform = createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS)); var appInjector = ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, appProviders], platform.injector); coreLoadAndBootstrap(appInjector, MyApp); ```
This commit is contained in:
parent
0a7d10ba55
commit
9092ac79d4
@ -10,7 +10,7 @@ export 'package:angular2/common.dart';
|
|||||||
export 'package:angular2/instrumentation.dart';
|
export 'package:angular2/instrumentation.dart';
|
||||||
export 'package:angular2/src/core/angular_entrypoint.dart' show AngularEntrypoint;
|
export 'package:angular2/src/core/angular_entrypoint.dart' show AngularEntrypoint;
|
||||||
export 'package:angular2/src/core/application_tokens.dart'
|
export 'package:angular2/src/core/application_tokens.dart'
|
||||||
hide APP_COMPONENT_REF_PROMISE, APP_ID_RANDOM_PROVIDER;
|
hide APP_ID_RANDOM_PROVIDER;
|
||||||
export 'package:angular2/src/platform/dom/dom_tokens.dart';
|
export 'package:angular2/src/platform/dom/dom_tokens.dart';
|
||||||
export 'package:angular2/src/platform/dom/dom_adapter.dart';
|
export 'package:angular2/src/platform/dom/dom_adapter.dart';
|
||||||
export 'package:angular2/src/platform/dom/events/event_manager.dart';
|
export 'package:angular2/src/platform/dom/events/event_manager.dart';
|
||||||
|
@ -6,9 +6,10 @@ export './src/core/util.dart';
|
|||||||
export 'package:angular2/src/facade/lang.dart' show enableProdMode;
|
export 'package:angular2/src/facade/lang.dart' show enableProdMode;
|
||||||
export './src/core/di.dart' hide ForwardRefFn, resolveForwardRef, forwardRef;
|
export './src/core/di.dart' hide ForwardRefFn, resolveForwardRef, forwardRef;
|
||||||
export './src/facade/facade.dart';
|
export './src/facade/facade.dart';
|
||||||
export './src/core/application_ref.dart' show platform, createNgZone, PlatformRef, ApplicationRef;
|
export './src/core/application_ref.dart' show createPlatform, assertPlatform,
|
||||||
|
disposePlatform, getPlatform,
|
||||||
|
coreLoadAndBootstrap, coreBootstrap, createNgZone, PlatformRef, ApplicationRef;
|
||||||
export './src/core/application_tokens.dart' show APP_ID,
|
export './src/core/application_tokens.dart' show APP_ID,
|
||||||
APP_COMPONENT,
|
|
||||||
APP_INITIALIZER,
|
APP_INITIALIZER,
|
||||||
PACKAGE_ROOT_URL,
|
PACKAGE_ROOT_URL,
|
||||||
PLATFORM_INITIALIZER;
|
PLATFORM_INITIALIZER;
|
||||||
|
@ -9,10 +9,19 @@ export * from './src/core/prod_mode';
|
|||||||
export * from './src/core/di';
|
export * from './src/core/di';
|
||||||
export * from './src/facade/facade';
|
export * from './src/facade/facade';
|
||||||
export {enableProdMode} from 'angular2/src/facade/lang';
|
export {enableProdMode} from 'angular2/src/facade/lang';
|
||||||
export {platform, createNgZone, PlatformRef, ApplicationRef} from './src/core/application_ref';
|
export {
|
||||||
|
createPlatform,
|
||||||
|
assertPlatform,
|
||||||
|
disposePlatform,
|
||||||
|
getPlatform,
|
||||||
|
coreBootstrap,
|
||||||
|
coreLoadAndBootstrap,
|
||||||
|
createNgZone,
|
||||||
|
PlatformRef,
|
||||||
|
ApplicationRef
|
||||||
|
} from './src/core/application_ref';
|
||||||
export {
|
export {
|
||||||
APP_ID,
|
APP_ID,
|
||||||
APP_COMPONENT,
|
|
||||||
APP_INITIALIZER,
|
APP_INITIALIZER,
|
||||||
PACKAGE_ROOT_URL,
|
PACKAGE_ROOT_URL,
|
||||||
PLATFORM_INITIALIZER
|
PLATFORM_INITIALIZER
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Component, platform} from 'angular2/core';
|
import {Component, createPlatform, coreLoadAndBootstrap, ReflectiveInjector} from 'angular2/core';
|
||||||
import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
|
import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
|
||||||
|
|
||||||
var appProviders: any[] = [];
|
var appProviders: any[] = [];
|
||||||
@ -8,6 +8,8 @@ var appProviders: any[] = [];
|
|||||||
class MyApp {
|
class MyApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
var app = platform(BROWSER_PROVIDERS).application([BROWSER_APP_PROVIDERS, appProviders]);
|
var platform = createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS));
|
||||||
app.bootstrap(MyApp);
|
var appInjector =
|
||||||
|
ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, appProviders], platform.injector);
|
||||||
|
coreLoadAndBootstrap(appInjector, MyApp);
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
|
@ -13,13 +13,24 @@ export {
|
|||||||
disableDebugTools
|
disableDebugTools
|
||||||
} from 'angular2/src/platform/browser_common';
|
} from 'angular2/src/platform/browser_common';
|
||||||
|
|
||||||
import {Type, isPresent, CONST_EXPR} from 'angular2/src/facade/lang';
|
import {Type, isPresent, isBlank, CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
import {
|
import {
|
||||||
BROWSER_PROVIDERS,
|
BROWSER_PROVIDERS,
|
||||||
BROWSER_APP_COMMON_PROVIDERS
|
BROWSER_APP_COMMON_PROVIDERS,
|
||||||
|
BROWSER_PLATFORM_MARKER
|
||||||
} from 'angular2/src/platform/browser_common';
|
} from 'angular2/src/platform/browser_common';
|
||||||
import {COMPILER_PROVIDERS} from 'angular2/compiler';
|
import {COMPILER_PROVIDERS} from 'angular2/compiler';
|
||||||
import {ComponentRef, platform, reflector} from 'angular2/core';
|
import {
|
||||||
|
ComponentRef,
|
||||||
|
coreLoadAndBootstrap,
|
||||||
|
reflector,
|
||||||
|
ReflectiveInjector,
|
||||||
|
PlatformRef,
|
||||||
|
OpaqueToken,
|
||||||
|
getPlatform,
|
||||||
|
createPlatform,
|
||||||
|
assertPlatform
|
||||||
|
} from 'angular2/core';
|
||||||
import {ReflectionCapabilities} from 'angular2/src/core/reflection/reflection_capabilities';
|
import {ReflectionCapabilities} from 'angular2/src/core/reflection/reflection_capabilities';
|
||||||
import {XHRImpl} from "angular2/src/platform/browser/xhr_impl";
|
import {XHRImpl} from "angular2/src/platform/browser/xhr_impl";
|
||||||
import {XHR} from 'angular2/compiler';
|
import {XHR} from 'angular2/compiler';
|
||||||
@ -34,6 +45,13 @@ export const BROWSER_APP_PROVIDERS: Array<any /*Type | Provider | any[]*/> = CON
|
|||||||
new Provider(XHR, {useClass: XHRImpl}),
|
new Provider(XHR, {useClass: XHRImpl}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
export function browserPlatform(): PlatformRef {
|
||||||
|
if (isBlank(getPlatform())) {
|
||||||
|
createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS));
|
||||||
|
}
|
||||||
|
return assertPlatform(BROWSER_PLATFORM_MARKER);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrapping for Angular applications.
|
* Bootstrapping for Angular applications.
|
||||||
*
|
*
|
||||||
@ -106,7 +124,8 @@ export function bootstrap(
|
|||||||
appComponentType: Type,
|
appComponentType: Type,
|
||||||
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef> {
|
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef> {
|
||||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||||
let appProviders =
|
var appInjector = ReflectiveInjector.resolveAndCreate(
|
||||||
isPresent(customProviders) ? [BROWSER_APP_PROVIDERS, customProviders] : BROWSER_APP_PROVIDERS;
|
[BROWSER_APP_PROVIDERS, isPresent(customProviders) ? customProviders : []],
|
||||||
return platform(BROWSER_PROVIDERS).application(appProviders).bootstrap(appComponentType);
|
browserPlatform().injector);
|
||||||
|
return coreLoadAndBootstrap(appInjector, appComponentType);
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,21 @@ export {
|
|||||||
disableDebugTools
|
disableDebugTools
|
||||||
} from 'angular2/src/platform/browser_common';
|
} from 'angular2/src/platform/browser_common';
|
||||||
|
|
||||||
import {Type, isPresent} from 'angular2/src/facade/lang';
|
import {Type, isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||||
import {
|
import {
|
||||||
BROWSER_PROVIDERS,
|
BROWSER_PROVIDERS,
|
||||||
BROWSER_APP_COMMON_PROVIDERS
|
BROWSER_APP_COMMON_PROVIDERS,
|
||||||
|
BROWSER_PLATFORM_MARKER
|
||||||
} from 'angular2/src/platform/browser_common';
|
} from 'angular2/src/platform/browser_common';
|
||||||
import {ComponentRef, platform} from 'angular2/core';
|
import {
|
||||||
|
ComponentRef,
|
||||||
|
coreLoadAndBootstrap,
|
||||||
|
ReflectiveInjector,
|
||||||
|
PlatformRef,
|
||||||
|
getPlatform,
|
||||||
|
createPlatform,
|
||||||
|
assertPlatform
|
||||||
|
} from 'angular2/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of providers that should be passed into `application()` when bootstrapping a component
|
* An array of providers that should be passed into `application()` when bootstrapping a component
|
||||||
@ -26,6 +35,13 @@ import {ComponentRef, platform} from 'angular2/core';
|
|||||||
export const BROWSER_APP_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
export const BROWSER_APP_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||||
BROWSER_APP_COMMON_PROVIDERS;
|
BROWSER_APP_COMMON_PROVIDERS;
|
||||||
|
|
||||||
|
export function browserStaticPlatform(): PlatformRef {
|
||||||
|
if (isBlank(getPlatform())) {
|
||||||
|
createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS));
|
||||||
|
}
|
||||||
|
return assertPlatform(BROWSER_PLATFORM_MARKER);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See {@link bootstrap} for more information.
|
* See {@link bootstrap} for more information.
|
||||||
*/
|
*/
|
||||||
@ -38,5 +54,7 @@ export function bootstrapStatic(appComponentType: Type,
|
|||||||
|
|
||||||
let appProviders =
|
let appProviders =
|
||||||
isPresent(customProviders) ? [BROWSER_APP_PROVIDERS, customProviders] : BROWSER_APP_PROVIDERS;
|
isPresent(customProviders) ? [BROWSER_APP_PROVIDERS, customProviders] : BROWSER_APP_PROVIDERS;
|
||||||
return platform(BROWSER_PROVIDERS).application(appProviders).bootstrap(appComponentType);
|
var appInjector =
|
||||||
|
ReflectiveInjector.resolveAndCreate(appProviders, browserStaticPlatform().injector);
|
||||||
|
return coreLoadAndBootstrap(appInjector, appComponentType);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
library angular2.platform.worker_app;
|
library angular2.platform.worker_app;
|
||||||
|
|
||||||
|
import "package:angular2/src/platform/worker_app_common.dart";
|
||||||
|
import "package:angular2/src/platform/worker_app.dart";
|
||||||
|
import 'package:angular2/core.dart';
|
||||||
|
import 'package:angular2/src/facade/lang.dart';
|
||||||
|
import 'dart:isolate';
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
export "package:angular2/src/platform/worker_app_common.dart"
|
export "package:angular2/src/platform/worker_app_common.dart"
|
||||||
show WORKER_APP_PLATFORM, WORKER_APP_APPLICATION_COMMON;
|
show WORKER_APP_PLATFORM, WORKER_APP_APPLICATION_COMMON;
|
||||||
export "package:angular2/src/core/angular_entrypoint.dart"
|
export "package:angular2/src/core/angular_entrypoint.dart"
|
||||||
@ -14,3 +21,31 @@ export 'package:angular2/src/web_workers/shared/serializer.dart' show PRIMITIVE;
|
|||||||
export 'package:angular2/src/web_workers/shared/message_bus.dart';
|
export 'package:angular2/src/web_workers/shared/message_bus.dart';
|
||||||
export 'package:angular2/src/web_workers/worker/router_providers.dart'
|
export 'package:angular2/src/web_workers/worker/router_providers.dart'
|
||||||
show WORKER_APP_ROUTER;
|
show WORKER_APP_ROUTER;
|
||||||
|
|
||||||
|
PlatformRef _platform = null;
|
||||||
|
SendPort _renderSendPort = null;
|
||||||
|
|
||||||
|
PlatformRef workerAppPlatform(SendPort renderSendPort) {
|
||||||
|
if (isBlank(getPlatform())) {
|
||||||
|
createPlatform(ReflectiveInjector.resolveAndCreate([
|
||||||
|
WORKER_APP_PLATFORM,
|
||||||
|
new Provider(RENDER_SEND_PORT, useValue: renderSendPort)
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
var platform = assertPlatform(WORKER_APP_PLATFORM_MARKER);
|
||||||
|
if (platform.injector.get(RENDER_SEND_PORT, null) != renderSendPort) {
|
||||||
|
throw 'Platform has already been created with a different SendPort. Please distroy it first.';
|
||||||
|
}
|
||||||
|
return platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ComponentRef> bootstrapApp(
|
||||||
|
SendPort renderSendPort,
|
||||||
|
Type appComponentType,
|
||||||
|
[List<dynamic /*Type | Provider | any[]*/> customProviders]) {
|
||||||
|
var appInjector = ReflectiveInjector.resolveAndCreate([
|
||||||
|
WORKER_APP_APPLICATION,
|
||||||
|
isPresent(customProviders) ? customProviders : []
|
||||||
|
], workerAppPlatform(renderSendPort).injector);
|
||||||
|
return coreLoadAndBootstrap(appInjector, appComponentType);
|
||||||
|
}
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||||
|
import {
|
||||||
|
WORKER_APP_PLATFORM,
|
||||||
|
WORKER_APP_PLATFORM_MARKER
|
||||||
|
} from 'angular2/src/platform/worker_app_common';
|
||||||
|
import {WORKER_APP_APPLICATION} from 'angular2/src/platform/worker_app';
|
||||||
|
import {
|
||||||
|
PlatformRef,
|
||||||
|
Type,
|
||||||
|
ComponentRef,
|
||||||
|
ReflectiveInjector,
|
||||||
|
coreLoadAndBootstrap,
|
||||||
|
getPlatform,
|
||||||
|
createPlatform,
|
||||||
|
assertPlatform
|
||||||
|
} from 'angular2/core';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
WORKER_APP_PLATFORM,
|
WORKER_APP_PLATFORM,
|
||||||
WORKER_APP_APPLICATION_COMMON
|
WORKER_APP_APPLICATION_COMMON
|
||||||
@ -18,3 +35,19 @@ export {PRIMITIVE} from 'angular2/src/web_workers/shared/serializer';
|
|||||||
export * from 'angular2/src/web_workers/shared/message_bus';
|
export * from 'angular2/src/web_workers/shared/message_bus';
|
||||||
export {AngularEntrypoint} from 'angular2/src/core/angular_entrypoint';
|
export {AngularEntrypoint} from 'angular2/src/core/angular_entrypoint';
|
||||||
export {WORKER_APP_ROUTER} from 'angular2/src/web_workers/worker/router_providers';
|
export {WORKER_APP_ROUTER} from 'angular2/src/web_workers/worker/router_providers';
|
||||||
|
|
||||||
|
export function workerAppPlatform(): PlatformRef {
|
||||||
|
if (isBlank(getPlatform())) {
|
||||||
|
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_APP_PLATFORM));
|
||||||
|
}
|
||||||
|
return assertPlatform(WORKER_APP_PLATFORM_MARKER);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function bootstrapApp(
|
||||||
|
appComponentType: Type,
|
||||||
|
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef> {
|
||||||
|
var appInjector = ReflectiveInjector.resolveAndCreate(
|
||||||
|
[WORKER_APP_APPLICATION, isPresent(customProviders) ? customProviders : []],
|
||||||
|
workerAppPlatform().injector);
|
||||||
|
return coreLoadAndBootstrap(appInjector, appComponentType);
|
||||||
|
}
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
library angular2.platform.worker_render;
|
library angular2.platform.worker_render;
|
||||||
|
|
||||||
|
import 'package:angular2/src/platform/worker_render.dart';
|
||||||
|
import 'package:angular2/src/platform/worker_render_common.dart';
|
||||||
|
import 'package:angular2/core.dart';
|
||||||
|
import 'package:angular2/src/facade/lang.dart';
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
export 'package:angular2/src/platform/worker_render_common.dart'
|
export 'package:angular2/src/platform/worker_render_common.dart'
|
||||||
show
|
show
|
||||||
WORKER_SCRIPT,
|
WORKER_SCRIPT,
|
||||||
@ -8,7 +14,7 @@ export 'package:angular2/src/platform/worker_render_common.dart'
|
|||||||
initializeGenericWorkerRenderer;
|
initializeGenericWorkerRenderer;
|
||||||
|
|
||||||
export 'package:angular2/src/platform/worker_render.dart'
|
export 'package:angular2/src/platform/worker_render.dart'
|
||||||
show WORKER_RENDER_APPLICATION, initIsolate, WebWorkerInstance;
|
show WORKER_RENDER_APPLICATION, WebWorkerInstance;
|
||||||
|
|
||||||
export '../src/web_workers/shared/client_message_broker.dart'
|
export '../src/web_workers/shared/client_message_broker.dart'
|
||||||
show ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments;
|
show ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments;
|
||||||
@ -20,7 +26,24 @@ export '../src/web_workers/shared/serializer.dart' show PRIMITIVE;
|
|||||||
export '../src/web_workers/shared/message_bus.dart';
|
export '../src/web_workers/shared/message_bus.dart';
|
||||||
export '../src/web_workers/ui/router_providers.dart' show WORKER_RENDER_ROUTER;
|
export '../src/web_workers/ui/router_providers.dart' show WORKER_RENDER_ROUTER;
|
||||||
|
|
||||||
import 'package:angular2/src/platform/worker_render_common.dart';
|
|
||||||
|
|
||||||
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;
|
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;
|
||||||
|
|
||||||
|
PlatformRef workerRenderPlatform() {
|
||||||
|
if (isBlank(getPlatform())) {
|
||||||
|
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM));
|
||||||
|
}
|
||||||
|
return assertPlatform(WORKER_RENDER_PLATFORM_MARKER);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ApplicationRef> bootstrapRender(
|
||||||
|
String workerScriptUri,
|
||||||
|
[List<dynamic /*Type | Provider | any[]*/> customProviders]) {
|
||||||
|
return initIsolate(workerScriptUri).then( (appProviders) {
|
||||||
|
var appInjector = ReflectiveInjector.resolveAndCreate([
|
||||||
|
appProviders,
|
||||||
|
isPresent(customProviders) ? customProviders : []
|
||||||
|
], workerRenderPlatform().injector);
|
||||||
|
return appInjector.get(ApplicationRef);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||||
|
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||||
|
import {
|
||||||
|
ApplicationRef,
|
||||||
|
PlatformRef,
|
||||||
|
ReflectiveInjector,
|
||||||
|
Provider,
|
||||||
|
getPlatform,
|
||||||
|
createPlatform,
|
||||||
|
assertPlatform
|
||||||
|
} from 'angular2/core';
|
||||||
|
import {WORKER_RENDER_APPLICATION} from 'angular2/src/platform/worker_render';
|
||||||
|
import {
|
||||||
|
WORKER_SCRIPT,
|
||||||
|
WORKER_RENDER_PLATFORM,
|
||||||
|
WORKER_RENDER_PLATFORM_MARKER
|
||||||
|
} from 'angular2/src/platform/worker_render_common';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
WORKER_SCRIPT,
|
WORKER_SCRIPT,
|
||||||
WORKER_RENDER_PLATFORM,
|
WORKER_RENDER_PLATFORM,
|
||||||
@ -18,10 +36,33 @@ export {
|
|||||||
} from '../src/web_workers/shared/service_message_broker';
|
} from '../src/web_workers/shared/service_message_broker';
|
||||||
export {PRIMITIVE} from '../src/web_workers/shared/serializer';
|
export {PRIMITIVE} from '../src/web_workers/shared/serializer';
|
||||||
export * from '../src/web_workers/shared/message_bus';
|
export * from '../src/web_workers/shared/message_bus';
|
||||||
import {WORKER_RENDER_APPLICATION} from 'angular2/src/platform/worker_render';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use WORKER_RENDER_APPLICATION
|
* @deprecated Use WORKER_RENDER_APPLICATION
|
||||||
*/
|
*/
|
||||||
export const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION;
|
export const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION;
|
||||||
export {WORKER_RENDER_ROUTER} from 'angular2/src/web_workers/ui/router_providers';
|
export {WORKER_RENDER_ROUTER} from 'angular2/src/web_workers/ui/router_providers';
|
||||||
|
|
||||||
|
export function workerRenderPlatform(): PlatformRef {
|
||||||
|
if (isBlank(getPlatform())) {
|
||||||
|
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM));
|
||||||
|
}
|
||||||
|
return assertPlatform(WORKER_RENDER_PLATFORM_MARKER);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function bootstrapRender(
|
||||||
|
workerScriptUri: string,
|
||||||
|
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ApplicationRef> {
|
||||||
|
var pf = ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM);
|
||||||
|
var app = ReflectiveInjector.resolveAndCreate(
|
||||||
|
[
|
||||||
|
WORKER_RENDER_APPLICATION,
|
||||||
|
new Provider(WORKER_SCRIPT, {useValue: workerScriptUri}),
|
||||||
|
isPresent(customProviders) ? customProviders : []
|
||||||
|
],
|
||||||
|
workerRenderPlatform().injector);
|
||||||
|
// Return a promise so that we keep the same semantics as Dart,
|
||||||
|
// and we might want to wait for the app side to come up
|
||||||
|
// in the future...
|
||||||
|
return PromiseWrapper.resolve(app.get(ApplicationRef));
|
||||||
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import {Type, CONST_EXPR} from 'angular2/src/facade/lang';
|
import {Type, CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
|
import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
|
||||||
import {
|
import {APP_ID_RANDOM_PROVIDER} from './application_tokens';
|
||||||
APP_COMPONENT_REF_PROMISE,
|
import {APPLICATION_CORE_PROVIDERS} from './application_ref';
|
||||||
APP_COMPONENT,
|
|
||||||
APP_ID_RANDOM_PROVIDER
|
|
||||||
} from './application_tokens';
|
|
||||||
import {
|
import {
|
||||||
IterableDiffers,
|
IterableDiffers,
|
||||||
defaultIterableDiffers,
|
defaultIterableDiffers,
|
||||||
@ -24,6 +21,7 @@ var __unused: Type; // avoid unused import when Type union types are erased
|
|||||||
* application, regardless of the platform it runs onto.
|
* application, regardless of the platform it runs onto.
|
||||||
*/
|
*/
|
||||||
export const APPLICATION_COMMON_PROVIDERS: Array<Type | Provider | any[]> = CONST_EXPR([
|
export const APPLICATION_COMMON_PROVIDERS: Array<Type | Provider | any[]> = CONST_EXPR([
|
||||||
|
APPLICATION_CORE_PROVIDERS,
|
||||||
new Provider(ComponentResolver, {useClass: ReflectorComponentResolver}),
|
new Provider(ComponentResolver, {useClass: ReflectorComponentResolver}),
|
||||||
APP_ID_RANDOM_PROVIDER,
|
APP_ID_RANDOM_PROVIDER,
|
||||||
ViewUtils,
|
ViewUtils,
|
||||||
|
@ -5,20 +5,17 @@ import {
|
|||||||
isPresent,
|
isPresent,
|
||||||
assertionsEnabled,
|
assertionsEnabled,
|
||||||
print,
|
print,
|
||||||
IS_DART
|
IS_DART,
|
||||||
|
CONST_EXPR,
|
||||||
|
lockMode,
|
||||||
|
isPromise
|
||||||
} from 'angular2/src/facade/lang';
|
} from 'angular2/src/facade/lang';
|
||||||
import {provide, Provider, Injector, ReflectiveInjector, OpaqueToken} from 'angular2/src/core/di';
|
import {provide, Provider, Injector, Injectable} from 'angular2/src/core/di';
|
||||||
import {
|
import {APP_ID_RANDOM_PROVIDER, PLATFORM_INITIALIZER, APP_INITIALIZER} from './application_tokens';
|
||||||
APP_COMPONENT_REF_PROMISE,
|
|
||||||
APP_COMPONENT,
|
|
||||||
APP_ID_RANDOM_PROVIDER,
|
|
||||||
PLATFORM_INITIALIZER,
|
|
||||||
APP_INITIALIZER
|
|
||||||
} from './application_tokens';
|
|
||||||
import {PromiseWrapper, PromiseCompleter, ObservableWrapper} from 'angular2/src/facade/async';
|
import {PromiseWrapper, PromiseCompleter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability';
|
import {TestabilityRegistry, Testability} from 'angular2/src/core/testability/testability';
|
||||||
import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader';
|
import {ComponentResolver} from 'angular2/src/core/linker/component_resolver';
|
||||||
import {ComponentRef} from 'angular2/src/core/linker/component_factory';
|
import {ComponentRef} from 'angular2/src/core/linker/component_factory';
|
||||||
import {
|
import {
|
||||||
BaseException,
|
BaseException,
|
||||||
@ -29,42 +26,7 @@ import {
|
|||||||
import {Console} from 'angular2/src/core/console';
|
import {Console} from 'angular2/src/core/console';
|
||||||
import {wtfLeave, wtfCreateScope, WtfScopeFn} from './profile/profile';
|
import {wtfLeave, wtfCreateScope, WtfScopeFn} from './profile/profile';
|
||||||
import {ChangeDetectorRef} from 'angular2/src/core/change_detection/change_detector_ref';
|
import {ChangeDetectorRef} from 'angular2/src/core/change_detection/change_detector_ref';
|
||||||
import {lockMode} from 'angular2/src/facade/lang';
|
import {ComponentFactory} from 'angular2/src/core/linker/component_factory';
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct providers specific to an individual root component.
|
|
||||||
*/
|
|
||||||
function _componentProviders(appComponentType: Type): Array<Type | Provider | any[]> {
|
|
||||||
return [
|
|
||||||
provide(APP_COMPONENT, {useValue: appComponentType}),
|
|
||||||
provide(APP_COMPONENT_REF_PROMISE,
|
|
||||||
{
|
|
||||||
useFactory: (dynamicComponentLoader: DynamicComponentLoader, appRef: ApplicationRef_,
|
|
||||||
injector: Injector) => {
|
|
||||||
// Save the ComponentRef for disposal later.
|
|
||||||
var ref: ComponentRef;
|
|
||||||
// TODO(rado): investigate whether to support providers on root component.
|
|
||||||
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector,
|
|
||||||
() => { appRef._unloadComponent(ref); })
|
|
||||||
.then((componentRef) => {
|
|
||||||
ref = componentRef;
|
|
||||||
var testability = injector.get(Testability, null);
|
|
||||||
if (isPresent(testability)) {
|
|
||||||
injector.get(TestabilityRegistry)
|
|
||||||
.registerApplication(componentRef.location.nativeElement, testability);
|
|
||||||
}
|
|
||||||
return componentRef;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
deps: [DynamicComponentLoader, ApplicationRef, Injector]
|
|
||||||
}),
|
|
||||||
provide(appComponentType,
|
|
||||||
{
|
|
||||||
useFactory: (p: Promise<any>) => p.then(ref => ref.instance),
|
|
||||||
deps: [APP_COMPONENT_REF_PROMISE]
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an Angular zone.
|
* Create an Angular zone.
|
||||||
@ -74,59 +36,86 @@ export function createNgZone(): NgZone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _platform: PlatformRef;
|
var _platform: PlatformRef;
|
||||||
var _platformProviders: any[];
|
var _inPlatformCreate: boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the Angular 'platform' on the page.
|
* Creates a platform.
|
||||||
*
|
* Platforms have to be eagerly created via this function.
|
||||||
* See {@link PlatformRef} for details on the Angular platform.
|
|
||||||
*
|
|
||||||
* It is also possible to specify providers to be made in the new platform. These providers
|
|
||||||
* will be shared between all applications on the page. For example, an abstraction for
|
|
||||||
* the browser cookie jar should be bound at the platform level, because there is only one
|
|
||||||
* cookie jar regardless of how many applications on the page will be accessing it.
|
|
||||||
*
|
|
||||||
* The platform function can be called multiple times as long as the same list of providers
|
|
||||||
* is passed into each call. If the platform function is called with a different set of
|
|
||||||
* provides, Angular will throw an exception.
|
|
||||||
*/
|
*/
|
||||||
export function platform(providers?: Array<Type | Provider | any[]>): PlatformRef {
|
export function createPlatform(injector: Injector): PlatformRef {
|
||||||
|
if (_inPlatformCreate) {
|
||||||
|
throw new BaseException('Already creating a platform...');
|
||||||
|
}
|
||||||
|
if (isPresent(_platform) && !_platform.disposed) {
|
||||||
|
throw new BaseException(
|
||||||
|
"There can be only one platform. Destroy the previous one to create a new one.");
|
||||||
|
}
|
||||||
lockMode();
|
lockMode();
|
||||||
if (isPresent(_platform)) {
|
_inPlatformCreate = true;
|
||||||
if (ListWrapper.equals(_platformProviders, providers)) {
|
try {
|
||||||
|
_platform = injector.get(PlatformRef);
|
||||||
|
} finally {
|
||||||
|
_inPlatformCreate = false;
|
||||||
|
}
|
||||||
return _platform;
|
return _platform;
|
||||||
} else {
|
|
||||||
throw new BaseException("platform cannot be initialized with different sets of providers.");
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return _createPlatform(providers);
|
/**
|
||||||
|
* Checks that there currently is a platform
|
||||||
|
* which contains the given token as a provider.
|
||||||
|
*/
|
||||||
|
export function assertPlatform(requiredToken: any): PlatformRef {
|
||||||
|
var platform = getPlatform();
|
||||||
|
if (isBlank(platform)) {
|
||||||
|
throw new BaseException('Not platform exists!');
|
||||||
}
|
}
|
||||||
|
if (isPresent(platform) && isBlank(platform.injector.get(requiredToken, null))) {
|
||||||
|
throw new BaseException(
|
||||||
|
'A platform with a different configuration has been created. Please destroy it first.');
|
||||||
|
}
|
||||||
|
return platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose the existing platform.
|
* Dispose the existing platform.
|
||||||
*/
|
*/
|
||||||
export function disposePlatform(): void {
|
export function disposePlatform(): void {
|
||||||
if (isPresent(_platform)) {
|
if (isPresent(_platform) && !_platform.disposed) {
|
||||||
_platform.dispose();
|
_platform.dispose();
|
||||||
_platform = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _createPlatform(providers?: Array<Type | Provider | any[]>): PlatformRef {
|
/**
|
||||||
_platformProviders = providers;
|
* Returns the current platform.
|
||||||
let injector = ReflectiveInjector.resolveAndCreate(providers);
|
*/
|
||||||
_platform = new PlatformRef_(injector, () => {
|
export function getPlatform(): PlatformRef {
|
||||||
_platform = null;
|
return isPresent(_platform) && !_platform.disposed ? _platform : null;
|
||||||
_platformProviders = null;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for ApplicationRef.bootstrap.
|
||||||
|
* Requires a platform the be created first.
|
||||||
|
*/
|
||||||
|
export function coreBootstrap(injector: Injector,
|
||||||
|
componentFactory: ComponentFactory): ComponentRef {
|
||||||
|
var appRef: ApplicationRef = injector.get(ApplicationRef);
|
||||||
|
return appRef.bootstrap(componentFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves the componentFactory for the given component,
|
||||||
|
* waits for asynchronous initializers and bootstraps the component.
|
||||||
|
* Requires a platform the be created first.
|
||||||
|
*/
|
||||||
|
export function coreLoadAndBootstrap(injector: Injector,
|
||||||
|
componentType: Type): Promise<ComponentRef> {
|
||||||
|
var appRef: ApplicationRef = injector.get(ApplicationRef);
|
||||||
|
return appRef.run(() => {
|
||||||
|
var componentResolver: ComponentResolver = injector.get(ComponentResolver);
|
||||||
|
return PromiseWrapper
|
||||||
|
.all([componentResolver.resolveComponent(componentType), appRef.waitForAsyncInitializers()])
|
||||||
|
.then((arr) => appRef.bootstrap(arr[0]));
|
||||||
});
|
});
|
||||||
_runPlatformInitializers(injector);
|
|
||||||
return _platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _runPlatformInitializers(injector: Injector): void {
|
|
||||||
let inits: Function[] = <Function[]>injector.get(PLATFORM_INITIALIZER, null);
|
|
||||||
if (isPresent(inits)) inits.forEach(init => init());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,7 +124,7 @@ function _runPlatformInitializers(injector: Injector): void {
|
|||||||
* to every Angular application running on the page are bound in its scope.
|
* to every Angular application running on the page are bound in its scope.
|
||||||
*
|
*
|
||||||
* A page's platform is initialized implicitly when {@link bootstrap}() is called, or
|
* A page's platform is initialized implicitly when {@link bootstrap}() is called, or
|
||||||
* explicitly by calling {@link platform}().
|
* explicitly by calling {@link createPlatform}().
|
||||||
*/
|
*/
|
||||||
export abstract class PlatformRef {
|
export abstract class PlatformRef {
|
||||||
/**
|
/**
|
||||||
@ -149,157 +138,50 @@ export abstract class PlatformRef {
|
|||||||
*/
|
*/
|
||||||
get injector(): Injector { throw unimplemented(); };
|
get injector(): Injector { throw unimplemented(); };
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiate a new Angular application on the page.
|
|
||||||
*
|
|
||||||
* ### What is an application?
|
|
||||||
*
|
|
||||||
* Each Angular application has its own zone, change detection, compiler,
|
|
||||||
* renderer, and other framework components. An application hosts one or more
|
|
||||||
* root components, which can be initialized via `ApplicationRef.bootstrap()`.
|
|
||||||
*
|
|
||||||
* ### Application Providers
|
|
||||||
*
|
|
||||||
* Angular applications require numerous providers to be properly instantiated.
|
|
||||||
* When using `application()` to create a new app on the page, these providers
|
|
||||||
* must be provided. Fortunately, there are helper functions to configure
|
|
||||||
* typical providers, as shown in the example below.
|
|
||||||
*
|
|
||||||
* ### Example
|
|
||||||
*
|
|
||||||
* {@example core/ts/platform/platform.ts region='longform'}
|
|
||||||
* ### See Also
|
|
||||||
*
|
|
||||||
* See the {@link bootstrap} documentation for more details.
|
|
||||||
*/
|
|
||||||
abstract application(providers: Array<Type | Provider | any[]>): ApplicationRef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiate a new Angular application on the page, using providers which
|
|
||||||
* are only available asynchronously. One such use case is to initialize an
|
|
||||||
* application running in a web worker.
|
|
||||||
*
|
|
||||||
* ### Usage
|
|
||||||
*
|
|
||||||
* `bindingFn` is a function that will be called in the new application's zone.
|
|
||||||
* It should return a `Promise` to a list of providers to be used for the
|
|
||||||
* new application. Once this promise resolves, the application will be
|
|
||||||
* constructed in the same manner as a normal `application()`.
|
|
||||||
*/
|
|
||||||
abstract asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>,
|
|
||||||
providers?: Array<Type | Provider | any[]>): Promise<ApplicationRef>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the Angular platform and all Angular applications on the page.
|
* Destroy the Angular platform and all Angular applications on the page.
|
||||||
*/
|
*/
|
||||||
abstract dispose(): void;
|
abstract dispose(): void;
|
||||||
|
|
||||||
|
get disposed(): boolean { throw unimplemented(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
export class PlatformRef_ extends PlatformRef {
|
export class PlatformRef_ extends PlatformRef {
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_applications: ApplicationRef[] = [];
|
_applications: ApplicationRef[] = [];
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_disposeListeners: Function[] = [];
|
_disposeListeners: Function[] = [];
|
||||||
|
|
||||||
constructor(private _injector: ReflectiveInjector, private _dispose: () => void) { super(); }
|
private _disposed: boolean = false;
|
||||||
|
|
||||||
|
constructor(private _injector: Injector) {
|
||||||
|
super();
|
||||||
|
if (!_inPlatformCreate) {
|
||||||
|
throw new BaseException('Platforms have to be created via `createPlatform`!');
|
||||||
|
}
|
||||||
|
let inits: Function[] = <Function[]>_injector.get(PLATFORM_INITIALIZER, null);
|
||||||
|
if (isPresent(inits)) inits.forEach(init => init());
|
||||||
|
}
|
||||||
|
|
||||||
registerDisposeListener(dispose: () => void): void { this._disposeListeners.push(dispose); }
|
registerDisposeListener(dispose: () => void): void { this._disposeListeners.push(dispose); }
|
||||||
|
|
||||||
get injector(): ReflectiveInjector { return this._injector; }
|
get injector(): Injector { return this._injector; }
|
||||||
|
|
||||||
application(providers: Array<Type | Provider | any[]>): ApplicationRef {
|
get disposed() { return this._disposed; }
|
||||||
var app = this._initApp(createNgZone(), providers);
|
|
||||||
if (PromiseWrapper.isPromise(app)) {
|
|
||||||
throw new BaseException(
|
|
||||||
"Cannot use asyncronous app initializers with application. Use asyncApplication instead.");
|
|
||||||
}
|
|
||||||
return <ApplicationRef>app;
|
|
||||||
}
|
|
||||||
|
|
||||||
asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>,
|
addApplication(appRef: ApplicationRef) { this._applications.push(appRef); }
|
||||||
additionalProviders?: Array<Type | Provider | any[]>): Promise<ApplicationRef> {
|
|
||||||
var zone = createNgZone();
|
|
||||||
var completer = PromiseWrapper.completer<ApplicationRef>();
|
|
||||||
if (bindingFn === null) {
|
|
||||||
completer.resolve(this._initApp(zone, additionalProviders));
|
|
||||||
} else {
|
|
||||||
zone.run(() => {
|
|
||||||
PromiseWrapper.then(bindingFn(zone), (providers: Array<Type | Provider | any[]>) => {
|
|
||||||
if (isPresent(additionalProviders)) {
|
|
||||||
providers = ListWrapper.concat(providers, additionalProviders);
|
|
||||||
}
|
|
||||||
let promise = this._initApp(zone, providers);
|
|
||||||
completer.resolve(promise);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return completer.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _initApp(zone: NgZone,
|
|
||||||
providers: Array<Type | Provider | any[]>): Promise<ApplicationRef>|
|
|
||||||
ApplicationRef {
|
|
||||||
var injector: ReflectiveInjector;
|
|
||||||
var app: ApplicationRef;
|
|
||||||
zone.run(() => {
|
|
||||||
providers = ListWrapper.concat(providers, [
|
|
||||||
provide(NgZone, {useValue: zone}),
|
|
||||||
provide(ApplicationRef, {useFactory: (): ApplicationRef => app, deps: []})
|
|
||||||
]);
|
|
||||||
|
|
||||||
var exceptionHandler: ExceptionHandler;
|
|
||||||
try {
|
|
||||||
injector = this.injector.resolveAndCreateChild(providers);
|
|
||||||
exceptionHandler = injector.get(ExceptionHandler);
|
|
||||||
ObservableWrapper.subscribe(zone.onError, (error: NgZoneError) => {
|
|
||||||
exceptionHandler.call(error.error, error.stackTrace);
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
if (isPresent(exceptionHandler)) {
|
|
||||||
exceptionHandler.call(e, e.stack);
|
|
||||||
} else {
|
|
||||||
print(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
app = new ApplicationRef_(this, zone, injector);
|
|
||||||
this._applications.push(app);
|
|
||||||
var promise = _runAppInitializers(injector);
|
|
||||||
if (promise !== null) {
|
|
||||||
return PromiseWrapper.then(promise, (_) => app);
|
|
||||||
} else {
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose(): void {
|
dispose(): void {
|
||||||
ListWrapper.clone(this._applications).forEach((app) => app.dispose());
|
ListWrapper.clone(this._applications).forEach((app) => app.dispose());
|
||||||
this._disposeListeners.forEach((dispose) => dispose());
|
this._disposeListeners.forEach((dispose) => dispose());
|
||||||
this._dispose();
|
this._disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_applicationDisposed(app: ApplicationRef): void { ListWrapper.remove(this._applications, app); }
|
_applicationDisposed(app: ApplicationRef): void { ListWrapper.remove(this._applications, app); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function _runAppInitializers(injector: Injector): Promise<any> {
|
|
||||||
let inits: Function[] = injector.get(APP_INITIALIZER, null);
|
|
||||||
let promises: Promise<any>[] = [];
|
|
||||||
if (isPresent(inits)) {
|
|
||||||
inits.forEach(init => {
|
|
||||||
var retVal = init();
|
|
||||||
if (PromiseWrapper.isPromise(retVal)) {
|
|
||||||
promises.push(retVal);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (promises.length > 0) {
|
|
||||||
return PromiseWrapper.all(promises);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reference to an Angular application running on a page.
|
* A reference to an Angular application running on a page.
|
||||||
*
|
*
|
||||||
@ -317,6 +199,18 @@ export abstract class ApplicationRef {
|
|||||||
*/
|
*/
|
||||||
abstract registerDisposeListener(dispose: () => void): void;
|
abstract registerDisposeListener(dispose: () => void): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when all asynchronous application initializers
|
||||||
|
* are done.
|
||||||
|
*/
|
||||||
|
abstract waitForAsyncInitializers(): Promise<any>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the given callback in the zone and returns the result of the callback.
|
||||||
|
* Exceptions will be forwarded to the ExceptionHandler and rethrown.
|
||||||
|
*/
|
||||||
|
abstract run(callback: Function): any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap a new component at the root level of the application.
|
* Bootstrap a new component at the root level of the application.
|
||||||
*
|
*
|
||||||
@ -326,17 +220,10 @@ export abstract class ApplicationRef {
|
|||||||
* specified application component onto DOM elements identified by the [componentType]'s
|
* specified application component onto DOM elements identified by the [componentType]'s
|
||||||
* selector and kicks off automatic change detection to finish initializing the component.
|
* selector and kicks off automatic change detection to finish initializing the component.
|
||||||
*
|
*
|
||||||
* ### Optional Providers
|
|
||||||
*
|
|
||||||
* Providers for the given component can optionally be overridden via the `providers`
|
|
||||||
* parameter. These providers will only apply for the root component being added and any
|
|
||||||
* child components under it.
|
|
||||||
*
|
|
||||||
* ### Example
|
* ### Example
|
||||||
* {@example core/ts/platform/platform.ts region='longform'}
|
* {@example core/ts/platform/platform.ts region='longform'}
|
||||||
*/
|
*/
|
||||||
abstract bootstrap(componentType: Type,
|
abstract bootstrap(componentFactory: ComponentFactory): ComponentRef;
|
||||||
providers?: Array<Type | Provider | any[]>): Promise<ComponentRef>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the application {@link Injector}.
|
* Retrieve the application {@link Injector}.
|
||||||
@ -371,6 +258,7 @@ export abstract class ApplicationRef {
|
|||||||
get componentTypes(): Type[] { return <Type[]>unimplemented(); };
|
get componentTypes(): Type[] { return <Type[]>unimplemented(); };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
export class ApplicationRef_ extends ApplicationRef {
|
export class ApplicationRef_ extends ApplicationRef {
|
||||||
/** @internal */
|
/** @internal */
|
||||||
static _tickScope: WtfScopeFn = wtfCreateScope('ApplicationRef#tick()');
|
static _tickScope: WtfScopeFn = wtfCreateScope('ApplicationRef#tick()');
|
||||||
@ -390,15 +278,44 @@ export class ApplicationRef_ extends ApplicationRef {
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
private _enforceNoNewChanges: boolean = false;
|
private _enforceNoNewChanges: boolean = false;
|
||||||
|
|
||||||
constructor(private _platform: PlatformRef_, private _zone: NgZone,
|
private _exceptionHandler: ExceptionHandler;
|
||||||
private _injector: ReflectiveInjector) {
|
|
||||||
|
private _asyncInitDonePromise: Promise<any>;
|
||||||
|
private _asyncInitDone: boolean;
|
||||||
|
|
||||||
|
constructor(private _platform: PlatformRef_, private _zone: NgZone, private _injector: Injector) {
|
||||||
super();
|
super();
|
||||||
if (isPresent(this._zone)) {
|
var zone: NgZone = _injector.get(NgZone);
|
||||||
|
this._enforceNoNewChanges = assertionsEnabled();
|
||||||
|
zone.run(() => { this._exceptionHandler = _injector.get(ExceptionHandler); });
|
||||||
|
this._asyncInitDonePromise = this.run(() => {
|
||||||
|
let inits: Function[] = _injector.get(APP_INITIALIZER, null);
|
||||||
|
var asyncInitResults = [];
|
||||||
|
var asyncInitDonePromise;
|
||||||
|
if (isPresent(inits)) {
|
||||||
|
for (var i = 0; i < inits.length; i++) {
|
||||||
|
var initResult = inits[i]();
|
||||||
|
if (isPromise(initResult)) {
|
||||||
|
asyncInitResults.push(initResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (asyncInitResults.length > 0) {
|
||||||
|
asyncInitDonePromise =
|
||||||
|
PromiseWrapper.all(asyncInitResults).then((_) => this._asyncInitDone = true);
|
||||||
|
this._asyncInitDone = false;
|
||||||
|
} else {
|
||||||
|
this._asyncInitDone = true;
|
||||||
|
asyncInitDonePromise = PromiseWrapper.resolve(true);
|
||||||
|
}
|
||||||
|
return asyncInitDonePromise;
|
||||||
|
});
|
||||||
|
ObservableWrapper.subscribe(zone.onError, (error: NgZoneError) => {
|
||||||
|
this._exceptionHandler.call(error.error, error.stackTrace);
|
||||||
|
});
|
||||||
ObservableWrapper.subscribe(this._zone.onMicrotaskEmpty,
|
ObservableWrapper.subscribe(this._zone.onMicrotaskEmpty,
|
||||||
(_) => { this._zone.run(() => { this.tick(); }); });
|
(_) => { this._zone.run(() => { this.tick(); }); });
|
||||||
}
|
}
|
||||||
this._enforceNoNewChanges = assertionsEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
registerBootstrapListener(listener: (ref: ComponentRef) => void): void {
|
registerBootstrapListener(listener: (ref: ComponentRef) => void): void {
|
||||||
this._bootstrapListeners.push(listener);
|
this._bootstrapListeners.push(listener);
|
||||||
@ -414,42 +331,56 @@ export class ApplicationRef_ extends ApplicationRef {
|
|||||||
ListWrapper.remove(this._changeDetectorRefs, changeDetector);
|
ListWrapper.remove(this._changeDetectorRefs, changeDetector);
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap(componentType: Type,
|
waitForAsyncInitializers(): Promise<any> { return this._asyncInitDonePromise; }
|
||||||
providers?: Array<Type | Provider | any[]>): Promise<ComponentRef> {
|
|
||||||
|
run(callback: Function): any {
|
||||||
|
var zone = this.injector.get(NgZone);
|
||||||
|
var result;
|
||||||
|
// Note: Don't use zone.runGuarded as we want to know about
|
||||||
|
// the thrown exception!
|
||||||
|
// Note: the completer needs to be created outside
|
||||||
|
// of `zone.run` as Dart swallows rejected promises
|
||||||
|
// via the onError callback of the promise.
|
||||||
var completer = PromiseWrapper.completer();
|
var completer = PromiseWrapper.completer();
|
||||||
this._zone.run(() => {
|
zone.run(() => {
|
||||||
var componentProviders = _componentProviders(componentType);
|
|
||||||
if (isPresent(providers)) {
|
|
||||||
componentProviders.push(providers);
|
|
||||||
}
|
|
||||||
var exceptionHandler = this._injector.get(ExceptionHandler);
|
|
||||||
this._rootComponentTypes.push(componentType);
|
|
||||||
try {
|
try {
|
||||||
var injector: Injector = this._injector.resolveAndCreateChild(componentProviders);
|
result = callback();
|
||||||
var compRefToken: Promise<ComponentRef> = injector.get(APP_COMPONENT_REF_PROMISE);
|
if (isPromise(result)) {
|
||||||
var tick = (componentRef: ComponentRef) => {
|
PromiseWrapper.then(result, (ref) => { completer.resolve(ref); }, (err, stackTrace) => {
|
||||||
this._loadComponent(componentRef);
|
|
||||||
completer.resolve(componentRef);
|
|
||||||
};
|
|
||||||
|
|
||||||
var tickResult = PromiseWrapper.then(compRefToken, tick);
|
|
||||||
|
|
||||||
PromiseWrapper.then(tickResult, null, (err, stackTrace) => {
|
|
||||||
completer.reject(err, stackTrace);
|
completer.reject(err, stackTrace);
|
||||||
exceptionHandler.call(err, stackTrace);
|
this._exceptionHandler.call(err, stackTrace);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
exceptionHandler.call(e, e.stack);
|
this._exceptionHandler.call(e, e.stack);
|
||||||
completer.reject(e, e.stack);
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return completer.promise.then<ComponentRef>((ref: ComponentRef) => {
|
return isPromise(result) ? completer.promise : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrap(componentFactory: ComponentFactory): ComponentRef {
|
||||||
|
if (!this._asyncInitDone) {
|
||||||
|
throw new BaseException(
|
||||||
|
'Cannot bootstrap as there are still asynchronous initializers running. Wait for them using waitForAsyncInitializers().');
|
||||||
|
}
|
||||||
|
return this.run(() => {
|
||||||
|
this._rootComponentTypes.push(componentFactory.componentType);
|
||||||
|
var compRef = componentFactory.create(this._injector, [], componentFactory.selector);
|
||||||
|
compRef.onDestroy(() => { this._unloadComponent(compRef); });
|
||||||
|
var testability = compRef.injector.get(Testability, null);
|
||||||
|
if (isPresent(testability)) {
|
||||||
|
compRef.injector.get(TestabilityRegistry)
|
||||||
|
.registerApplication(compRef.location.nativeElement, testability);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._loadComponent(compRef);
|
||||||
let c = this._injector.get(Console);
|
let c = this._injector.get(Console);
|
||||||
if (assertionsEnabled()) {
|
if (assertionsEnabled()) {
|
||||||
c.log(
|
c.log(
|
||||||
"Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.");
|
"Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.");
|
||||||
}
|
}
|
||||||
return ref;
|
return compRef;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,3 +432,18 @@ export class ApplicationRef_ extends ApplicationRef {
|
|||||||
|
|
||||||
get componentTypes(): Type[] { return this._rootComponentTypes; }
|
get componentTypes(): Type[] { return this._rootComponentTypes; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const PLATFORM_CORE_PROVIDERS =
|
||||||
|
CONST_EXPR([PlatformRef_, CONST_EXPR(new Provider(PlatformRef, {useExisting: PlatformRef_}))]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export const APPLICATION_CORE_PROVIDERS = CONST_EXPR([
|
||||||
|
CONST_EXPR(new Provider(NgZone, {useFactory: createNgZone, deps: CONST_EXPR([])})),
|
||||||
|
ApplicationRef_,
|
||||||
|
CONST_EXPR(new Provider(ApplicationRef, {useExisting: ApplicationRef_}))
|
||||||
|
]);
|
||||||
|
@ -1,29 +1,6 @@
|
|||||||
import {OpaqueToken, Provider} from 'angular2/src/core/di';
|
import {OpaqueToken, Provider} from 'angular2/src/core/di';
|
||||||
import {CONST_EXPR, Math, StringWrapper} from 'angular2/src/facade/lang';
|
import {CONST_EXPR, Math, StringWrapper} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export const APP_COMPONENT_REF_PROMISE = CONST_EXPR(new OpaqueToken('Promise<ComponentRef>'));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An {@link OpaqueToken-class.html} representing the application root type in the {@link
|
|
||||||
* Injector}.
|
|
||||||
*
|
|
||||||
* ```
|
|
||||||
* @Component(...)
|
|
||||||
* class MyApp {
|
|
||||||
* ...
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* bootstrap(MyApp).then((appRef:ApplicationRef) {
|
|
||||||
* expect(appRef.injector.get(appComponentTypeToken)).toEqual(MyApp);
|
|
||||||
* });
|
|
||||||
*
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export const APP_COMPONENT: OpaqueToken = CONST_EXPR(new OpaqueToken('AppComponent'));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DI Token representing a unique string id assigned to the application by Angular and used
|
* A DI Token representing a unique string id assigned to the application by Angular and used
|
||||||
* primarily for prefixing application attributes and CSS styles when
|
* primarily for prefixing application attributes and CSS styles when
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import {unimplemented} from 'angular2/src/facade/exceptions';
|
|
||||||
import {AppElement} from './element';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper around a native element inside of a View.
|
* A wrapper around a native element inside of a View.
|
||||||
*
|
*
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {unimplemented} from 'angular2/src/facade/exceptions';
|
import {unimplemented} from 'angular2/src/facade/exceptions';
|
||||||
import {Injector} from 'angular2/src/core/di/injector';
|
import {Injector} from 'angular2/src/core/di/injector';
|
||||||
import {ReflectiveInjector} from 'angular2/src/core/di/reflective_injector';
|
|
||||||
import {ResolvedReflectiveProvider} from 'angular2/src/core/di/reflective_provider';
|
|
||||||
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||||
import {wtfCreateScope, wtfLeave, WtfScopeFn} from '../profile/profile';
|
import {wtfCreateScope, wtfLeave, WtfScopeFn} from '../profile/profile';
|
||||||
|
|
||||||
@ -75,8 +73,7 @@ export abstract class ViewContainerRef {
|
|||||||
*
|
*
|
||||||
* If `index` is not specified, the new View will be inserted as the last View in the container.
|
* If `index` is not specified, the new View will be inserted as the last View in the container.
|
||||||
*
|
*
|
||||||
* You can optionally specify the {@link Injector}
|
* You can optionally specify the {@link Injector} that will be used as parent for the Component.
|
||||||
* that will be used for the component.
|
|
||||||
*
|
*
|
||||||
* Returns the {@link ComponentRef} of the Host View created for the newly instantiated Component.
|
* Returns the {@link ComponentRef} of the Host View created for the newly instantiated Component.
|
||||||
*/
|
*/
|
||||||
|
@ -4,6 +4,7 @@ import {Console} from 'angular2/src/core/console';
|
|||||||
import {Reflector, reflector} from './reflection/reflection';
|
import {Reflector, reflector} from './reflection/reflection';
|
||||||
import {ReflectorReader} from './reflection/reflector_reader';
|
import {ReflectorReader} from './reflection/reflector_reader';
|
||||||
import {TestabilityRegistry} from 'angular2/src/core/testability/testability';
|
import {TestabilityRegistry} from 'angular2/src/core/testability/testability';
|
||||||
|
import {PLATFORM_CORE_PROVIDERS} from './application_ref';
|
||||||
|
|
||||||
function _reflector(): Reflector {
|
function _reflector(): Reflector {
|
||||||
return reflector;
|
return reflector;
|
||||||
@ -13,6 +14,7 @@ function _reflector(): Reflector {
|
|||||||
* A default set of providers which should be included in any Angular platform.
|
* A default set of providers which should be included in any Angular platform.
|
||||||
*/
|
*/
|
||||||
export const PLATFORM_COMMON_PROVIDERS: Array<Type | Provider | any[]> = CONST_EXPR([
|
export const PLATFORM_COMMON_PROVIDERS: Array<Type | Provider | any[]> = CONST_EXPR([
|
||||||
|
PLATFORM_CORE_PROVIDERS,
|
||||||
new Provider(Reflector, {useFactory: _reflector, deps: []}),
|
new Provider(Reflector, {useFactory: _reflector, deps: []}),
|
||||||
new Provider(ReflectorReader, {useExisting: Reflector}),
|
new Provider(ReflectorReader, {useExisting: Reflector}),
|
||||||
TestabilityRegistry,
|
TestabilityRegistry,
|
||||||
|
@ -200,9 +200,17 @@ export class NgZone {
|
|||||||
*
|
*
|
||||||
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
* Any future tasks or microtasks scheduled from within this function will continue executing from
|
||||||
* within the Angular zone.
|
* within the Angular zone.
|
||||||
|
*
|
||||||
|
* If a synchronous error happens it will be rethrown and not reported via `onError`.
|
||||||
*/
|
*/
|
||||||
run(fn: () => any): any { return this._zoneImpl.runInner(fn); }
|
run(fn: () => any): any { return this._zoneImpl.runInner(fn); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as #run, except that synchronous errors are caught and forwarded
|
||||||
|
* via `onError` and not rethrown.
|
||||||
|
*/
|
||||||
|
runGuarded(fn: () => any): any { return this._zoneImpl.runInnerGuarded(fn); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
|
* Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
|
||||||
* the function.
|
* the function.
|
||||||
|
@ -122,10 +122,14 @@ class NgZoneImpl {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic runInner(fn()) {
|
dynamic runInnerGuarded(fn()) {
|
||||||
return _innerZone.runGuarded(fn);
|
return _innerZone.runGuarded(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dynamic runInner(fn()) {
|
||||||
|
return _innerZone.run(fn);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs `fn` in the mount zone and returns whatever it returns.
|
* Runs `fn` in the mount zone and returns whatever it returns.
|
||||||
*
|
*
|
||||||
|
@ -94,6 +94,7 @@ export class NgZoneImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runInner(fn: () => any): any { return this.inner.runGuarded(fn); };
|
runInner(fn: () => any): any { return this.inner.run(fn); };
|
||||||
|
runInnerGuarded(fn: () => any): any { return this.inner.runGuarded(fn); };
|
||||||
runOuter(fn: () => any): any { return this.outer.run(fn); };
|
runOuter(fn: () => any): any { return this.outer.run(fn); };
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {ApplicationRef} from 'angular2/src/core/application_ref';
|
import {ApplicationRef} from 'angular2/src/core/application_ref';
|
||||||
import {Injectable} from 'angular2/src/core/di';
|
import {Injectable} from 'angular2/src/core/di';
|
||||||
import {Type} from 'angular2/src/facade/lang';
|
import {Type} from 'angular2/src/facade/lang';
|
||||||
import {ComponentRef} from 'angular2/src/core/linker/component_factory';
|
import {ComponentRef, ComponentFactory} from 'angular2/src/core/linker/component_factory';
|
||||||
import {Provider, Injector} from 'angular2/src/core/di';
|
import {Injector} from 'angular2/src/core/di';
|
||||||
import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,14 +14,16 @@ export class MockApplicationRef extends ApplicationRef {
|
|||||||
|
|
||||||
registerDisposeListener(dispose: () => void): void {}
|
registerDisposeListener(dispose: () => void): void {}
|
||||||
|
|
||||||
bootstrap(componentType: Type, bindings?: Array<Type | Provider | any[]>): Promise<ComponentRef> {
|
bootstrap(componentFactory: ComponentFactory): ComponentRef { return null; }
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
get injector(): Injector { return null; };
|
get injector(): Injector { return null; };
|
||||||
|
|
||||||
get zone(): NgZone { return null; };
|
get zone(): NgZone { return null; };
|
||||||
|
|
||||||
|
run(callback: Function): any { return null; }
|
||||||
|
|
||||||
|
waitForAsyncInitializers(): Promise<any> { return null; }
|
||||||
|
|
||||||
dispose(): void {}
|
dispose(): void {}
|
||||||
|
|
||||||
tick(): void {}
|
tick(): void {}
|
||||||
|
@ -6,7 +6,6 @@ import {
|
|||||||
PLATFORM_DIRECTIVES,
|
PLATFORM_DIRECTIVES,
|
||||||
PLATFORM_PIPES,
|
PLATFORM_PIPES,
|
||||||
ComponentRef,
|
ComponentRef,
|
||||||
platform,
|
|
||||||
ExceptionHandler,
|
ExceptionHandler,
|
||||||
Reflector,
|
Reflector,
|
||||||
RootRenderer,
|
RootRenderer,
|
||||||
@ -48,12 +47,15 @@ export {BrowserDomAdapter} from './browser/browser_adapter';
|
|||||||
export {enableDebugTools, disableDebugTools} from 'angular2/src/platform/browser/tools/tools';
|
export {enableDebugTools, disableDebugTools} from 'angular2/src/platform/browser/tools/tools';
|
||||||
export {HAMMER_GESTURE_CONFIG, HammerGestureConfig} from './dom/events/hammer_gestures';
|
export {HAMMER_GESTURE_CONFIG, HammerGestureConfig} from './dom/events/hammer_gestures';
|
||||||
|
|
||||||
|
export const BROWSER_PLATFORM_MARKER = CONST_EXPR(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.
|
||||||
*
|
*
|
||||||
* Used automatically by `bootstrap`, or can be passed to {@link platform}.
|
* Used automatically by `bootstrap`, or can be passed to {@link platform}.
|
||||||
*/
|
*/
|
||||||
export const BROWSER_PROVIDERS: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
|
export const BROWSER_PROVIDERS: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
|
||||||
|
new Provider(BROWSER_PLATFORM_MARKER, {useValue: true}),
|
||||||
PLATFORM_COMMON_PROVIDERS,
|
PLATFORM_COMMON_PROVIDERS,
|
||||||
new Provider(PLATFORM_INITIALIZER, {useValue: initDomAdapter, multi: true}),
|
new Provider(PLATFORM_INITIALIZER, {useValue: initDomAdapter, multi: true}),
|
||||||
]);
|
]);
|
||||||
|
@ -10,7 +10,7 @@ export class DomEventsPlugin extends EventManagerPlugin {
|
|||||||
|
|
||||||
addEventListener(element: HTMLElement, eventName: string, handler: Function): Function {
|
addEventListener(element: HTMLElement, eventName: string, handler: Function): Function {
|
||||||
var zone = this.manager.getZone();
|
var zone = this.manager.getZone();
|
||||||
var outsideHandler = (event) => zone.run(() => handler(event));
|
var outsideHandler = (event) => zone.runGuarded(() => handler(event));
|
||||||
return this.manager.getZone().runOutsideAngular(
|
return this.manager.getZone().runOutsideAngular(
|
||||||
() => DOM.onAndCancel(element, eventName, outsideHandler));
|
() => DOM.onAndCancel(element, eventName, outsideHandler));
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ export class DomEventsPlugin extends EventManagerPlugin {
|
|||||||
addGlobalEventListener(target: string, eventName: string, handler: Function): Function {
|
addGlobalEventListener(target: string, eventName: string, handler: Function): Function {
|
||||||
var element = DOM.getGlobalEventTarget(target);
|
var element = DOM.getGlobalEventTarget(target);
|
||||||
var zone = this.manager.getZone();
|
var zone = this.manager.getZone();
|
||||||
var outsideHandler = (event) => zone.run(() => handler(event));
|
var outsideHandler = (event) => zone.runGuarded(() => handler(event));
|
||||||
return this.manager.getZone().runOutsideAngular(
|
return this.manager.getZone().runOutsideAngular(
|
||||||
() => DOM.onAndCancel(element, eventName, outsideHandler));
|
() => DOM.onAndCancel(element, eventName, outsideHandler));
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class HammerGesturesPlugin extends HammerGesturesPluginCommon {
|
|||||||
mc.callMethod('on', [
|
mc.callMethod('on', [
|
||||||
eventName,
|
eventName,
|
||||||
(eventObj) {
|
(eventObj) {
|
||||||
zone.run(() {
|
zone.runGuarded(() {
|
||||||
var dartEvent = new HammerEvent._fromJsEvent(eventObj);
|
var dartEvent = new HammerEvent._fromJsEvent(eventObj);
|
||||||
handler(dartEvent);
|
handler(dartEvent);
|
||||||
});
|
});
|
||||||
|
@ -52,7 +52,7 @@ export class HammerGesturesPlugin extends HammerGesturesPluginCommon {
|
|||||||
return zone.runOutsideAngular(() => {
|
return zone.runOutsideAngular(() => {
|
||||||
// Creating the manager bind events, must be done outside of angular
|
// Creating the manager bind events, must be done outside of angular
|
||||||
var mc = this._config.buildHammer(element);
|
var mc = this._config.buildHammer(element);
|
||||||
var callback = function(eventObj) { zone.run(function() { handler(eventObj); }); };
|
var callback = function(eventObj) { zone.runGuarded(function() { handler(eventObj); }); };
|
||||||
mc.on(eventName, callback);
|
mc.on(eventName, callback);
|
||||||
return () => { mc.off(eventName, callback); };
|
return () => { mc.off(eventName, callback); };
|
||||||
});
|
});
|
||||||
|
@ -95,7 +95,7 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
|||||||
zone: NgZone): Function {
|
zone: NgZone): Function {
|
||||||
return (event) => {
|
return (event) => {
|
||||||
if (StringWrapper.equals(KeyEventsPlugin.getEventFullKey(event), fullKey)) {
|
if (StringWrapper.equals(KeyEventsPlugin.getEventFullKey(event), fullKey)) {
|
||||||
zone.run(() => handler(event));
|
zone.runGuarded(() => handler(event));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
ExceptionHandler,
|
ExceptionHandler,
|
||||||
APPLICATION_COMMON_PROVIDERS,
|
APPLICATION_COMMON_PROVIDERS,
|
||||||
PLATFORM_COMMON_PROVIDERS,
|
PLATFORM_COMMON_PROVIDERS,
|
||||||
|
OpaqueToken
|
||||||
} from 'angular2/core';
|
} from 'angular2/core';
|
||||||
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from "angular2/common";
|
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from "angular2/common";
|
||||||
import {
|
import {
|
||||||
@ -31,8 +32,12 @@ class PrintLogger {
|
|||||||
logGroupEnd() {}
|
logGroupEnd() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WORKER_APP_PLATFORM: Array<any /*Type | Provider | any[]*/> =
|
export const WORKER_APP_PLATFORM_MARKER = CONST_EXPR(new OpaqueToken('WorkerAppPlatformMarker'));
|
||||||
CONST_EXPR([PLATFORM_COMMON_PROVIDERS]);
|
|
||||||
|
export const WORKER_APP_PLATFORM: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
|
||||||
|
PLATFORM_COMMON_PROVIDERS,
|
||||||
|
CONST_EXPR(new Provider(WORKER_APP_PLATFORM_MARKER, {useValue: true}))
|
||||||
|
]);
|
||||||
|
|
||||||
export const WORKER_APP_APPLICATION_COMMON: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
|
export const WORKER_APP_APPLICATION_COMMON: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
|
||||||
APPLICATION_COMMON_PROVIDERS,
|
APPLICATION_COMMON_PROVIDERS,
|
||||||
|
@ -10,14 +10,12 @@ import 'package:angular2/src/web_workers/shared/isolate_message_bus.dart';
|
|||||||
import 'package:angular2/src/web_workers/shared/message_bus.dart';
|
import 'package:angular2/src/web_workers/shared/message_bus.dart';
|
||||||
import 'package:angular2/core.dart';
|
import 'package:angular2/core.dart';
|
||||||
import 'package:angular2/src/core/di.dart';
|
import 'package:angular2/src/core/di.dart';
|
||||||
import 'package:angular2/src/core/zone/ng_zone.dart';
|
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;
|
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;
|
||||||
|
|
||||||
initIsolate(String scriptUri) {
|
Future<List> initIsolate(String scriptUri) async {
|
||||||
return (NgZone zone) async {
|
|
||||||
var instance = await spawnIsolate(Uri.parse(scriptUri));
|
var instance = await spawnIsolate(Uri.parse(scriptUri));
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -29,7 +27,6 @@ initIsolate(String scriptUri) {
|
|||||||
deps: [Injector]),
|
deps: [Injector]),
|
||||||
new Provider(MessageBus, useValue: instance.bus)
|
new Provider(MessageBus, useValue: instance.bus)
|
||||||
];
|
];
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
PLATFORM_DIRECTIVES,
|
PLATFORM_DIRECTIVES,
|
||||||
PLATFORM_PIPES,
|
PLATFORM_PIPES,
|
||||||
ComponentRef,
|
ComponentRef,
|
||||||
platform,
|
|
||||||
ExceptionHandler,
|
ExceptionHandler,
|
||||||
Reflector,
|
Reflector,
|
||||||
reflector,
|
reflector,
|
||||||
@ -58,8 +57,12 @@ export const WORKER_SCRIPT: OpaqueToken = CONST_EXPR(new OpaqueToken("WebWorkerS
|
|||||||
export const WORKER_RENDER_MESSAGING_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
export const WORKER_RENDER_MESSAGING_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||||
CONST_EXPR([MessageBasedRenderer, MessageBasedXHRImpl]);
|
CONST_EXPR([MessageBasedRenderer, MessageBasedXHRImpl]);
|
||||||
|
|
||||||
|
export const WORKER_RENDER_PLATFORM_MARKER =
|
||||||
|
CONST_EXPR(new OpaqueToken('WorkerRenderPlatformMarker'));
|
||||||
|
|
||||||
export const WORKER_RENDER_PLATFORM: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
|
export const WORKER_RENDER_PLATFORM: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
|
||||||
PLATFORM_COMMON_PROVIDERS,
|
PLATFORM_COMMON_PROVIDERS,
|
||||||
|
CONST_EXPR(new Provider(WORKER_RENDER_PLATFORM_MARKER, {useValue: true})),
|
||||||
new Provider(PLATFORM_INITIALIZER, {useValue: initWebWorkerRenderPlatform, multi: true})
|
new Provider(PLATFORM_INITIALIZER, {useValue: initWebWorkerRenderPlatform, multi: true})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -103,7 +106,7 @@ export function initializeGenericWorkerRenderer(injector: Injector) {
|
|||||||
let zone = injector.get(NgZone);
|
let zone = injector.get(NgZone);
|
||||||
bus.attachToZone(zone);
|
bus.attachToZone(zone);
|
||||||
|
|
||||||
zone.run(() => {
|
zone.runGuarded(() => {
|
||||||
WORKER_RENDER_MESSAGING_PROVIDERS.forEach((token) => { injector.get(token).start(); });
|
WORKER_RENDER_MESSAGING_PROVIDERS.forEach((token) => { injector.get(token).start(); });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
provide,
|
provide,
|
||||||
platform,
|
|
||||||
ApplicationRef,
|
ApplicationRef,
|
||||||
ComponentResolver,
|
ComponentResolver,
|
||||||
Injector,
|
Injector,
|
||||||
NgZone,
|
NgZone,
|
||||||
PlatformRef,
|
PlatformRef,
|
||||||
|
ReflectiveInjector,
|
||||||
ComponentFactory,
|
ComponentFactory,
|
||||||
Provider,
|
Provider,
|
||||||
Type,
|
Type,
|
||||||
@ -14,7 +14,7 @@ import {
|
|||||||
} from 'angular2/core';
|
} from 'angular2/core';
|
||||||
import {global} from 'angular2/src/facade/lang';
|
import {global} from 'angular2/src/facade/lang';
|
||||||
import {ObservableWrapper} from 'angular2/src/facade/async';
|
import {ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
|
import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS, browserPlatform} from 'angular2/platform/browser';
|
||||||
|
|
||||||
import {getComponentInfo, ComponentInfo} from './metadata';
|
import {getComponentInfo, ComponentInfo} from './metadata';
|
||||||
import {onError, controllerKey} from './util';
|
import {onError, controllerKey} from './util';
|
||||||
@ -294,13 +294,18 @@ export class UpgradeAdapter {
|
|||||||
config?: angular.IAngularBootstrapConfig): UpgradeAdapterRef {
|
config?: angular.IAngularBootstrapConfig): UpgradeAdapterRef {
|
||||||
var upgrade = new UpgradeAdapterRef();
|
var upgrade = new UpgradeAdapterRef();
|
||||||
var ng1Injector: angular.IInjectorService = null;
|
var ng1Injector: angular.IInjectorService = null;
|
||||||
var platformRef: PlatformRef = platform(BROWSER_PROVIDERS);
|
var platformRef: PlatformRef = browserPlatform();
|
||||||
var applicationRef: ApplicationRef = platformRef.application([
|
var applicationRef: ApplicationRef =
|
||||||
|
ReflectiveInjector.resolveAndCreate(
|
||||||
|
[
|
||||||
BROWSER_APP_PROVIDERS,
|
BROWSER_APP_PROVIDERS,
|
||||||
provide(NG1_INJECTOR, {useFactory: () => ng1Injector}),
|
provide(NG1_INJECTOR, {useFactory: () => ng1Injector}),
|
||||||
provide(NG1_COMPILE, {useFactory: () => ng1Injector.get(NG1_COMPILE)}),
|
provide(NG1_COMPILE,
|
||||||
|
{useFactory: () => ng1Injector.get(NG1_COMPILE)}),
|
||||||
this.providers
|
this.providers
|
||||||
]);
|
],
|
||||||
|
platformRef.injector)
|
||||||
|
.get(ApplicationRef);
|
||||||
var injector: Injector = applicationRef.injector;
|
var injector: Injector = applicationRef.injector;
|
||||||
var ngZone: NgZone = injector.get(NgZone);
|
var ngZone: NgZone = injector.get(NgZone);
|
||||||
var compiler: ComponentResolver = injector.get(ComponentResolver);
|
var compiler: ComponentResolver = injector.get(ComponentResolver);
|
||||||
|
@ -17,6 +17,6 @@ function initRouterListeners(injector: Injector): () => void {
|
|||||||
return () => {
|
return () => {
|
||||||
let zone = injector.get(NgZone);
|
let zone = injector.get(NgZone);
|
||||||
|
|
||||||
zone.run(() => injector.get(MessageBasedPlatformLocation).start());
|
zone.runGuarded(() => injector.get(MessageBasedPlatformLocation).start());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -16,5 +16,5 @@ export var WORKER_APP_ROUTER = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
function initRouter(platformLocation: WebWorkerPlatformLocation, zone: NgZone): Promise<boolean> {
|
function initRouter(platformLocation: WebWorkerPlatformLocation, zone: NgZone): Promise<boolean> {
|
||||||
return zone.run(() => { return platformLocation.init(); });
|
return zone.runGuarded(() => { return platformLocation.init(); });
|
||||||
}
|
}
|
||||||
|
@ -14,131 +14,169 @@ import {
|
|||||||
inject,
|
inject,
|
||||||
SpyObject
|
SpyObject
|
||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
|
import {Type} from 'angular2/src/facade/lang';
|
||||||
import {SpyChangeDetectorRef} from './spies';
|
import {SpyChangeDetectorRef} from './spies';
|
||||||
import {ApplicationRef_, ApplicationRef, PlatformRef_} from "angular2/src/core/application_ref";
|
import {
|
||||||
import {Injector, Provider, APP_INITIALIZER} from "angular2/core";
|
ApplicationRef_,
|
||||||
|
ApplicationRef,
|
||||||
|
PLATFORM_CORE_PROVIDERS,
|
||||||
|
APPLICATION_CORE_PROVIDERS
|
||||||
|
} from "angular2/src/core/application_ref";
|
||||||
|
import {
|
||||||
|
Injector,
|
||||||
|
Provider,
|
||||||
|
APP_INITIALIZER,
|
||||||
|
Component,
|
||||||
|
ReflectiveInjector,
|
||||||
|
coreLoadAndBootstrap,
|
||||||
|
coreBootstrap,
|
||||||
|
PlatformRef,
|
||||||
|
createPlatform,
|
||||||
|
disposePlatform,
|
||||||
|
ComponentResolver,
|
||||||
|
ChangeDetectorRef
|
||||||
|
} from "angular2/core";
|
||||||
|
import {Console} from 'angular2/src/core/console';
|
||||||
|
import {BaseException} from 'angular2/src/facade/exceptions';
|
||||||
import {PromiseWrapper, PromiseCompleter, TimerWrapper} from "angular2/src/facade/async";
|
import {PromiseWrapper, PromiseCompleter, TimerWrapper} from "angular2/src/facade/async";
|
||||||
import {ListWrapper} from "angular2/src/facade/collection";
|
import {
|
||||||
|
ComponentFactory,
|
||||||
|
ComponentRef_,
|
||||||
|
ComponentRef
|
||||||
|
} from 'angular2/src/core/linker/component_factory';
|
||||||
import {ExceptionHandler} from 'angular2/src/facade/exception_handler';
|
import {ExceptionHandler} from 'angular2/src/facade/exception_handler';
|
||||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
|
describe("bootstrap", () => {
|
||||||
|
var platform: PlatformRef;
|
||||||
|
var errorLogger: _ArrayLogger;
|
||||||
|
var someCompFactory: ComponentFactory;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
errorLogger = new _ArrayLogger();
|
||||||
|
disposePlatform();
|
||||||
|
platform = createPlatform(ReflectiveInjector.resolveAndCreate(PLATFORM_CORE_PROVIDERS));
|
||||||
|
someCompFactory =
|
||||||
|
new _MockComponentFactory(new _MockComponentRef(ReflectiveInjector.resolveAndCreate([])));
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => { disposePlatform(); });
|
||||||
|
|
||||||
|
function createApplication(providers: any[]): ApplicationRef_ {
|
||||||
|
var appInjector = ReflectiveInjector.resolveAndCreate(
|
||||||
|
[
|
||||||
|
APPLICATION_CORE_PROVIDERS,
|
||||||
|
new Provider(Console, {useValue: new _MockConsole()}),
|
||||||
|
new Provider(ExceptionHandler, {useValue: new ExceptionHandler(errorLogger, false)}),
|
||||||
|
new Provider(ComponentResolver,
|
||||||
|
{useValue: new _MockComponentResolver(someCompFactory)}),
|
||||||
|
providers
|
||||||
|
],
|
||||||
|
platform.injector);
|
||||||
|
return appInjector.get(ApplicationRef);
|
||||||
|
}
|
||||||
|
|
||||||
describe("ApplicationRef", () => {
|
describe("ApplicationRef", () => {
|
||||||
it("should throw when reentering tick", () => {
|
it("should throw when reentering tick", () => {
|
||||||
var cdRef = <any>new SpyChangeDetectorRef();
|
var cdRef = <any>new SpyChangeDetectorRef();
|
||||||
var ref = new ApplicationRef_(null, null, null);
|
var ref = createApplication([]);
|
||||||
|
try {
|
||||||
ref.registerChangeDetector(cdRef);
|
ref.registerChangeDetector(cdRef);
|
||||||
cdRef.spy("detectChanges").andCallFake(() => ref.tick());
|
cdRef.spy("detectChanges").andCallFake(() => ref.tick());
|
||||||
expect(() => ref.tick()).toThrowError("ApplicationRef.tick is called recursively");
|
expect(() => ref.tick()).toThrowError("ApplicationRef.tick is called recursively");
|
||||||
});
|
} finally {
|
||||||
|
ref.unregisterChangeDetector(cdRef);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("PlatformRef", () => {
|
describe('run', () => {
|
||||||
var exceptionHandler =
|
it('should rethrow errors even if the exceptionHandler is not rethrowing', () => {
|
||||||
new Provider(ExceptionHandler, {useValue: new ExceptionHandler(DOM, true)});
|
var ref = createApplication([]);
|
||||||
describe("asyncApplication", () => {
|
expect(() => ref.run(() => { throw new BaseException('Test'); })).toThrowError('Test');
|
||||||
function expectProviders(injector: Injector, providers: Array<any>): void {
|
});
|
||||||
for (let i = 0; i < providers.length; i++) {
|
|
||||||
let provider = providers[i];
|
|
||||||
expect(injector.get(provider.token)).toBe(provider.useValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
it("should merge syncronous and asyncronous providers",
|
it('should return a promise with rejected errors even if the exceptionHandler is not rethrowing',
|
||||||
inject([AsyncTestCompleter, Injector], (async, injector) => {
|
inject([AsyncTestCompleter, Injector], (async, injector) => {
|
||||||
let ref = new PlatformRef_(injector, null);
|
var ref = createApplication([]);
|
||||||
let ASYNC_PROVIDERS = [new Provider(Foo, {useValue: new Foo()}), exceptionHandler];
|
var promise = ref.run(() => PromiseWrapper.reject('Test', null));
|
||||||
let SYNC_PROVIDERS = [new Provider(Bar, {useValue: new Bar()})];
|
PromiseWrapper.catchError(promise, (e) => {
|
||||||
ref.asyncApplication((zone) => PromiseWrapper.resolve(ASYNC_PROVIDERS), SYNC_PROVIDERS)
|
expect(e).toEqual('Test');
|
||||||
.then((appRef) => {
|
|
||||||
var providers = ListWrapper.concat(ASYNC_PROVIDERS, SYNC_PROVIDERS);
|
|
||||||
expectProviders(appRef.injector, providers);
|
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should allow function to be null",
|
describe("coreLoadAndBootstrap", () => {
|
||||||
|
it("should wait for asynchronous app initializers",
|
||||||
inject([AsyncTestCompleter, Injector], (async, injector) => {
|
inject([AsyncTestCompleter, Injector], (async, injector) => {
|
||||||
let ref = new PlatformRef_(injector, null);
|
let completer: PromiseCompleter<any> = PromiseWrapper.completer();
|
||||||
let SYNC_PROVIDERS = [new Provider(Bar, {useValue: new Bar()}), exceptionHandler];
|
var initializerDone = false;
|
||||||
ref.asyncApplication(null, SYNC_PROVIDERS)
|
TimerWrapper.setTimeout(() => {
|
||||||
.then((appRef) => {
|
completer.resolve(true);
|
||||||
expectProviders(appRef.injector, SYNC_PROVIDERS);
|
initializerDone = true;
|
||||||
|
}, 1);
|
||||||
|
var app = createApplication(
|
||||||
|
[new Provider(APP_INITIALIZER, {useValue: () => completer.promise, multi: true})]);
|
||||||
|
coreLoadAndBootstrap(app.injector, MyComp)
|
||||||
|
.then((compRef) => {
|
||||||
|
expect(initializerDone).toBe(true);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
function mockAsyncAppInitializer(completer: PromiseCompleter<any>,
|
describe("coreBootstrap", () => {
|
||||||
providers: Array<any> = null, injector?: Injector) {
|
it("should throw if an APP_INITIIALIZER is not yet resolved",
|
||||||
return () => {
|
inject([Injector], (injector) => {
|
||||||
if (providers != null) {
|
var app = createApplication([
|
||||||
expectProviders(injector, providers);
|
|
||||||
}
|
|
||||||
TimerWrapper.setTimeout(() => completer.resolve(true), 1);
|
|
||||||
return completer.promise;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
it("should wait for asyncronous app initializers",
|
|
||||||
inject([AsyncTestCompleter, Injector], (async, injector) => {
|
|
||||||
let ref = new PlatformRef_(injector, null);
|
|
||||||
|
|
||||||
let completer: PromiseCompleter<any> = PromiseWrapper.completer();
|
|
||||||
let SYNC_PROVIDERS = [
|
|
||||||
new Provider(Bar, {useValue: new Bar()}),
|
|
||||||
new Provider(APP_INITIALIZER,
|
new Provider(APP_INITIALIZER,
|
||||||
{useValue: mockAsyncAppInitializer(completer), multi: true})
|
{useValue: () => PromiseWrapper.completer().promise, multi: true})
|
||||||
];
|
]);
|
||||||
ref.asyncApplication(null, [SYNC_PROVIDERS, exceptionHandler])
|
expect(() => app.bootstrap(someCompFactory))
|
||||||
.then((appRef) => {
|
|
||||||
expectProviders(appRef.injector,
|
|
||||||
SYNC_PROVIDERS.slice(0, SYNC_PROVIDERS.length - 1));
|
|
||||||
completer.promise.then((_) => async.done());
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
|
|
||||||
it("should wait for async providers and then async app initializers",
|
|
||||||
inject([AsyncTestCompleter, Injector], (async, injector) => {
|
|
||||||
let ref = new PlatformRef_(injector, null);
|
|
||||||
let ASYNC_PROVIDERS = [new Provider(Foo, {useValue: new Foo()})];
|
|
||||||
let completer: PromiseCompleter<any> = PromiseWrapper.completer();
|
|
||||||
let SYNC_PROVIDERS = [
|
|
||||||
new Provider(Bar, {useValue: new Bar()}),
|
|
||||||
new Provider(APP_INITIALIZER,
|
|
||||||
{
|
|
||||||
useFactory: (injector) => mockAsyncAppInitializer(
|
|
||||||
<any>completer, ASYNC_PROVIDERS, injector),
|
|
||||||
multi: true,
|
|
||||||
deps: [Injector]
|
|
||||||
})
|
|
||||||
];
|
|
||||||
ref.asyncApplication((zone) => PromiseWrapper.resolve(ASYNC_PROVIDERS),
|
|
||||||
[SYNC_PROVIDERS, exceptionHandler])
|
|
||||||
.then((appRef) => {
|
|
||||||
expectProviders(appRef.injector,
|
|
||||||
SYNC_PROVIDERS.slice(0, SYNC_PROVIDERS.length - 1));
|
|
||||||
completer.promise.then((_) => async.done());
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("application", () => {
|
|
||||||
it("should throw if an APP_INITIIALIZER returns a promise", inject([Injector], (injector) => {
|
|
||||||
let ref = new PlatformRef_(injector, null);
|
|
||||||
let appInitializer = new Provider(
|
|
||||||
APP_INITIALIZER, {useValue: () => PromiseWrapper.resolve([]), multi: true});
|
|
||||||
expect(() => ref.application([appInitializer, exceptionHandler]))
|
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
"Cannot use asyncronous app initializers with application. Use asyncApplication instead.");
|
"Cannot bootstrap as there are still asynchronous initializers running. Wait for them using waitForAsyncInitializers().");
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class Foo {
|
@Component({selector: 'my-comp', template: ''})
|
||||||
constructor() {}
|
class MyComp {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bar {
|
class _ArrayLogger {
|
||||||
constructor() {}
|
res: any[] = [];
|
||||||
|
log(s: any): void { this.res.push(s); }
|
||||||
|
logError(s: any): void { this.res.push(s); }
|
||||||
|
logGroup(s: any): void { this.res.push(s); }
|
||||||
|
logGroupEnd(){};
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MockComponentFactory extends ComponentFactory {
|
||||||
|
constructor(private _compRef: ComponentRef) { super(null, null, null); }
|
||||||
|
create(injector: Injector, projectableNodes: any[][] = null,
|
||||||
|
rootSelectorOrNode: string | any = null): ComponentRef {
|
||||||
|
return this._compRef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MockComponentResolver implements ComponentResolver {
|
||||||
|
constructor(private _compFactory: ComponentFactory) {}
|
||||||
|
|
||||||
|
resolveComponent(type: Type): Promise<ComponentFactory> {
|
||||||
|
return PromiseWrapper.resolve(this._compFactory);
|
||||||
|
}
|
||||||
|
clearCache() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MockComponentRef extends ComponentRef_ {
|
||||||
|
constructor(private _injector: Injector) { super(null, null); }
|
||||||
|
get injector(): Injector { return this._injector; }
|
||||||
|
get changeDetectorRef(): ChangeDetectorRef { return <any>new SpyChangeDetectorRef(); }
|
||||||
|
onDestroy(cb: Function) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MockConsole implements Console {
|
||||||
|
log(message) {}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import {
|
|||||||
|
|
||||||
import {Predicate} from 'angular2/src/facade/collection';
|
import {Predicate} from 'angular2/src/facade/collection';
|
||||||
import {Injector, OnDestroy, DebugElement, Type, ViewContainerRef, ViewChild} from 'angular2/core';
|
import {Injector, OnDestroy, DebugElement, Type, ViewContainerRef, ViewChild} from 'angular2/core';
|
||||||
import {NgIf} from 'angular2/common';
|
|
||||||
import {Component, ViewMetadata} from 'angular2/src/core/metadata';
|
import {Component, ViewMetadata} from 'angular2/src/core/metadata';
|
||||||
import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader';
|
import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader';
|
||||||
import {ElementRef} from 'angular2/src/core/linker/element_ref';
|
import {ElementRef} from 'angular2/src/core/linker/element_ref';
|
||||||
|
@ -8,7 +8,11 @@ import {DomAdapter} from 'angular2/src/platform/dom/dom_adapter';
|
|||||||
import {SpyObject, proxy} from 'angular2/testing_internal';
|
import {SpyObject, proxy} from 'angular2/testing_internal';
|
||||||
|
|
||||||
export class SpyChangeDetectorRef extends SpyObject {
|
export class SpyChangeDetectorRef extends SpyObject {
|
||||||
constructor() { super(ChangeDetectorRef); }
|
constructor() {
|
||||||
|
super(ChangeDetectorRef);
|
||||||
|
this.spy('detectChanges');
|
||||||
|
this.spy('checkNoChanges');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SpyIterableDifferFactory extends SpyObject {}
|
export class SpyIterableDifferFactory extends SpyObject {}
|
||||||
|
@ -685,12 +685,12 @@ function commonTests() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('exceptions', () => {
|
describe('exceptions', () => {
|
||||||
it('should call the on error callback when it is defined',
|
it('should call the on error callback when it is invoked via zone.runGuarded',
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
macroTask(() => {
|
macroTask(() => {
|
||||||
var exception = new BaseException('sync');
|
var exception = new BaseException('sync');
|
||||||
|
|
||||||
_zone.run(() => { throw exception; });
|
_zone.runGuarded(() => { throw exception; });
|
||||||
|
|
||||||
expect(_errors.length).toBe(1);
|
expect(_errors.length).toBe(1);
|
||||||
expect(_errors[0]).toBe(exception);
|
expect(_errors[0]).toBe(exception);
|
||||||
@ -698,6 +698,17 @@ function commonTests() {
|
|||||||
});
|
});
|
||||||
}), testTimeout);
|
}), testTimeout);
|
||||||
|
|
||||||
|
it('should not call the on error callback but rethrow when it is invoked via zone.run',
|
||||||
|
inject([AsyncTestCompleter], (async) => {
|
||||||
|
macroTask(() => {
|
||||||
|
var exception = new BaseException('sync');
|
||||||
|
expect(() => _zone.run(() => { throw exception; })).toThrowError('sync');
|
||||||
|
|
||||||
|
expect(_errors.length).toBe(0);
|
||||||
|
async.done();
|
||||||
|
});
|
||||||
|
}), testTimeout);
|
||||||
|
|
||||||
it('should call onError for errors from microtasks', inject([AsyncTestCompleter], (async) => {
|
it('should call onError for errors from microtasks', inject([AsyncTestCompleter], (async) => {
|
||||||
var exception = new BaseException('async');
|
var exception = new BaseException('async');
|
||||||
|
|
||||||
|
@ -14,13 +14,22 @@ import {
|
|||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
import {IS_DART, isPresent, stringify} from 'angular2/src/facade/lang';
|
import {IS_DART, isPresent, stringify} from 'angular2/src/facade/lang';
|
||||||
import {bootstrap, BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
|
import {bootstrap, BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
|
||||||
import {ApplicationRef} from 'angular2/src/core/application_ref';
|
import {ApplicationRef, PlatformRef} from 'angular2/src/core/application_ref';
|
||||||
import {Console} from 'angular2/src/core/console';
|
import {Console} from 'angular2/src/core/console';
|
||||||
import {Component, Directive, OnDestroy, platform} from 'angular2/core';
|
import {Component, Directive, OnDestroy} from 'angular2/core';
|
||||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||||
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
|
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
|
||||||
import {PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async';
|
import {PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async';
|
||||||
import {provide, Inject, Injector, PLATFORM_INITIALIZER, APP_INITIALIZER} from 'angular2/core';
|
import {
|
||||||
|
provide,
|
||||||
|
Inject,
|
||||||
|
Injector,
|
||||||
|
PLATFORM_INITIALIZER,
|
||||||
|
APP_INITIALIZER,
|
||||||
|
coreLoadAndBootstrap,
|
||||||
|
createPlatform,
|
||||||
|
ReflectiveInjector
|
||||||
|
} from 'angular2/core';
|
||||||
import {disposePlatform} from 'angular2/src/core/application_ref';
|
import {disposePlatform} from 'angular2/src/core/application_ref';
|
||||||
import {ExceptionHandler, BaseException} from 'angular2/src/facade/exceptions';
|
import {ExceptionHandler, BaseException} from 'angular2/src/facade/exceptions';
|
||||||
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
|
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
|
||||||
@ -91,6 +100,8 @@ export function main() {
|
|||||||
|
|
||||||
describe('bootstrap factory method', () => {
|
describe('bootstrap factory method', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
disposePlatform();
|
||||||
|
|
||||||
fakeDoc = DOM.createHtmlDocument();
|
fakeDoc = DOM.createHtmlDocument();
|
||||||
el = DOM.createElement('hello-app', fakeDoc);
|
el = DOM.createElement('hello-app', fakeDoc);
|
||||||
el2 = DOM.createElement('hello-app-2', fakeDoc);
|
el2 = DOM.createElement('hello-app-2', fakeDoc);
|
||||||
@ -105,21 +116,16 @@ export function main() {
|
|||||||
|
|
||||||
afterEach(disposePlatform);
|
afterEach(disposePlatform);
|
||||||
|
|
||||||
it('should throw if bootstrapped Directive is not a Component',
|
it('should throw if bootstrapped Directive is not a Component', () => {
|
||||||
inject([AsyncTestCompleter], (async) => {
|
|
||||||
var logger = new _ArrayLogger();
|
var logger = new _ArrayLogger();
|
||||||
var exceptionHandler = new ExceptionHandler(logger, false);
|
var exceptionHandler = new ExceptionHandler(logger, false);
|
||||||
var refPromise =
|
expect(
|
||||||
bootstrap(HelloRootDirectiveIsNotCmp,
|
() => bootstrap(HelloRootDirectiveIsNotCmp,
|
||||||
[testProviders, provide(ExceptionHandler, {useValue: exceptionHandler})]);
|
[testProviders, provide(ExceptionHandler, {useValue: exceptionHandler})]))
|
||||||
|
.toThrowError(
|
||||||
PromiseWrapper.then(refPromise, null, (exception) => {
|
|
||||||
expect(exception).toContainError(
|
|
||||||
`Could not compile '${stringify(HelloRootDirectiveIsNotCmp)}' because it is not a component.`);
|
`Could not compile '${stringify(HelloRootDirectiveIsNotCmp)}' because it is not a component.`);
|
||||||
expect(logger.res.join("")).toContain("Could not compile");
|
expect(logger.res.join("")).toContain("Could not compile");
|
||||||
async.done();
|
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
|
|
||||||
it('should throw if no element is found', inject([AsyncTestCompleter], (async) => {
|
it('should throw if no element is found', inject([AsyncTestCompleter], (async) => {
|
||||||
var logger = new _ArrayLogger();
|
var logger = new _ArrayLogger();
|
||||||
@ -201,8 +207,11 @@ export function main() {
|
|||||||
|
|
||||||
it('should unregister change detectors when components are disposed',
|
it('should unregister change detectors when components are disposed',
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
var app = platform(BROWSER_PROVIDERS).application([BROWSER_APP_PROVIDERS, testProviders]);
|
var platform = createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS));
|
||||||
app.bootstrap(HelloRootCmp)
|
var app = ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, testProviders],
|
||||||
|
platform.injector)
|
||||||
|
.get(ApplicationRef);
|
||||||
|
coreLoadAndBootstrap(app.injector, HelloRootCmp)
|
||||||
.then((ref) => {
|
.then((ref) => {
|
||||||
ref.destroy();
|
ref.destroy();
|
||||||
expect(() => app.tick()).not.toThrow();
|
expect(() => app.tick()).not.toThrow();
|
||||||
@ -232,18 +241,21 @@ export function main() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it("should run platform initializers", inject([Log], (log: Log) => {
|
it("should run platform initializers", inject([Log], (log: Log) => {
|
||||||
let p = platform([
|
let p = createPlatform(ReflectiveInjector.resolveAndCreate([
|
||||||
BROWSER_PROVIDERS,
|
BROWSER_PROVIDERS,
|
||||||
provide(PLATFORM_INITIALIZER, {useValue: log.fn("platform_init1"), multi: true}),
|
provide(PLATFORM_INITIALIZER, {useValue: log.fn("platform_init1"), multi: true}),
|
||||||
provide(PLATFORM_INITIALIZER, {useValue: log.fn("platform_init2"), multi: true})
|
provide(PLATFORM_INITIALIZER, {useValue: log.fn("platform_init2"), multi: true})
|
||||||
]);
|
]));
|
||||||
expect(log.result()).toEqual("platform_init1; platform_init2");
|
expect(log.result()).toEqual("platform_init1; platform_init2");
|
||||||
log.clear();
|
log.clear();
|
||||||
p.application([
|
var a = ReflectiveInjector.resolveAndCreate(
|
||||||
|
[
|
||||||
BROWSER_APP_PROVIDERS,
|
BROWSER_APP_PROVIDERS,
|
||||||
provide(APP_INITIALIZER, {useValue: log.fn("app_init1"), multi: true}),
|
provide(APP_INITIALIZER, {useValue: log.fn("app_init1"), multi: true}),
|
||||||
provide(APP_INITIALIZER, {useValue: log.fn("app_init2"), multi: true})
|
provide(APP_INITIALIZER, {useValue: log.fn("app_init2"), multi: true})
|
||||||
]);
|
],
|
||||||
|
p.injector);
|
||||||
|
a.get(ApplicationRef);
|
||||||
|
|
||||||
expect(log.result()).toEqual("app_init1; app_init2");
|
expect(log.result()).toEqual("app_init1; app_init2");
|
||||||
}));
|
}));
|
||||||
|
@ -140,7 +140,6 @@ var NG_COMPILER = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
var NG_CORE = [
|
var NG_CORE = [
|
||||||
'APP_COMPONENT',
|
|
||||||
'APP_INITIALIZER',
|
'APP_INITIALIZER',
|
||||||
'APP_ID',
|
'APP_ID',
|
||||||
'AngularEntrypoint:dart',
|
'AngularEntrypoint:dart',
|
||||||
@ -261,7 +260,12 @@ var NG_CORE = [
|
|||||||
'provide',
|
'provide',
|
||||||
'createNgZone',
|
'createNgZone',
|
||||||
'forwardRef:js',
|
'forwardRef:js',
|
||||||
'platform',
|
'coreBootstrap',
|
||||||
|
'coreLoadAndBootstrap',
|
||||||
|
'createPlatform',
|
||||||
|
'disposePlatform',
|
||||||
|
'getPlatform',
|
||||||
|
'assertPlatform',
|
||||||
'resolveForwardRef:js',
|
'resolveForwardRef:js',
|
||||||
'PLATFORM_COMMON_PROVIDERS',
|
'PLATFORM_COMMON_PROVIDERS',
|
||||||
'PLATFORM_INITIALIZER',
|
'PLATFORM_INITIALIZER',
|
||||||
@ -306,6 +310,7 @@ var NG_PLATFORM_BROWSER = [
|
|||||||
'ELEMENT_PROBE_PROVIDERS_PROD_MODE',
|
'ELEMENT_PROBE_PROVIDERS_PROD_MODE',
|
||||||
'Title',
|
'Title',
|
||||||
'bootstrap',
|
'bootstrap',
|
||||||
|
'browserPlatform',
|
||||||
'disableDebugTools',
|
'disableDebugTools',
|
||||||
'enableDebugTools',
|
'enableDebugTools',
|
||||||
'inspectNativeElement'
|
'inspectNativeElement'
|
||||||
|
@ -54,7 +54,7 @@ export function main() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// do not refactor out the `bootstrap` functionality. We still want to
|
// do not refactor out the `bootstrap` functionality. We still want to
|
||||||
// keep this test around so we can ensure that bootstrapping a router works
|
// keep this test around so we can ensure that bootstrap a router works
|
||||||
it('should bootstrap a simple app', inject([AsyncTestCompleter], (async) => {
|
it('should bootstrap a simple app', inject([AsyncTestCompleter], (async) => {
|
||||||
var fakeDoc = DOM.createHtmlDocument();
|
var fakeDoc = DOM.createHtmlDocument();
|
||||||
var el = DOM.createElement('app-cmp', fakeDoc);
|
var el = DOM.createElement('app-cmp', fakeDoc);
|
||||||
|
@ -153,7 +153,8 @@ export class DynamicLoaderCmp {
|
|||||||
this._componentRef.destroy();
|
this._componentRef.destroy();
|
||||||
this._componentRef = null;
|
this._componentRef = null;
|
||||||
}
|
}
|
||||||
return this._dynamicComponentLoader.loadNextToLocation(DynamicallyLoadedComponent, viewport)
|
return this._dynamicComponentLoader.loadNextToLocation(DynamicallyLoadedComponent,
|
||||||
|
this.viewport)
|
||||||
.then((cmp) => { this._componentRef = cmp; });
|
.then((cmp) => { this._componentRef = cmp; });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,11 @@ main() {
|
|||||||
it("should be able to load in a Dart VM", () {
|
it("should be able to load in a Dart VM", () {
|
||||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||||
var buses = createPairedMessageBuses();
|
var buses = createPairedMessageBuses();
|
||||||
platform([WORKER_APP_PLATFORM])
|
disposePlatform();
|
||||||
.application([WORKER_APP_APPLICATION_COMMON]);
|
var platform = createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_APP_PLATFORM));
|
||||||
|
var appInjector = ReflectiveInjector.resolveAndCreate(WORKER_APP_APPLICATION_COMMON,
|
||||||
|
platform.injector);
|
||||||
|
appInjector.get(ApplicationRef);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
export * from 'angular2/src/facade/facade';
|
export * from 'angular2/src/facade/facade';
|
||||||
export * from '../src/core/di';
|
export * from '../src/core/di';
|
||||||
export {platform, PlatformRef, ApplicationRef} from '../src/core/application_ref';
|
export {PlatformRef, ApplicationRef} from '../src/core/application_ref';
|
||||||
export {
|
export {APP_ID, APP_INITIALIZER, PLATFORM_INITIALIZER} from '../src/core/application_tokens';
|
||||||
APP_ID,
|
|
||||||
APP_COMPONENT,
|
|
||||||
APP_INITIALIZER,
|
|
||||||
PLATFORM_INITIALIZER
|
|
||||||
} from '../src/core/application_tokens';
|
|
||||||
export * from '../src/core/zone';
|
export * from '../src/core/zone';
|
||||||
export * from 'angular2/platform/worker_render';
|
export * from 'angular2/platform/worker_render';
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<title>Animation Example</title>
|
<title>Animation Example</title>
|
||||||
<link rel="stylesheet" type="text/css" href="./css/app.css" />
|
<link rel="stylesheet" type="text/css" href="./css/app.css" />
|
||||||
<base href="/playground/src/animate/">
|
|
||||||
<body>
|
<body>
|
||||||
<animate-app>Loading...</animate-app>
|
<animate-app>Loading...</animate-app>
|
||||||
$SCRIPTS$
|
$SCRIPTS$
|
||||||
|
@ -9,8 +9,5 @@ import "package:angular2/src/core/reflection/reflection.dart";
|
|||||||
|
|
||||||
main(List<String> args, SendPort replyTo) {
|
main(List<String> args, SendPort replyTo) {
|
||||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||||
platform([
|
bootstrapApp(replyTo, ImageDemo);
|
||||||
WORKER_APP_PLATFORM,
|
|
||||||
new Provider(RENDER_SEND_PORT, useValue: replyTo)
|
|
||||||
]).application([WORKER_APP_APPLICATION]).bootstrap(ImageDemo);
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {ImageDemo} from "./index_common";
|
import {ImageDemo} from "./index_common";
|
||||||
import {platform} from "angular2/core";
|
import {bootstrapApp} from "angular2/platform/worker_app";
|
||||||
import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from "angular2/platform/worker_app";
|
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
platform([WORKER_APP_PLATFORM]).application([WORKER_APP_APPLICATION]).bootstrap(ImageDemo)
|
bootstrapApp(ImageDemo);
|
||||||
}
|
}
|
@ -7,6 +7,5 @@ import "package:angular2/src/core/reflection/reflection.dart";
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
bootstrapRender("background_index.dart");
|
||||||
.asyncApplication(initIsolate("background_index.dart"));
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import {platform, Provider} from 'angular2/core';
|
import {Provider} from 'angular2/core';
|
||||||
import {
|
import {
|
||||||
WORKER_RENDER_APPLICATION,
|
bootstrapRender,
|
||||||
WORKER_RENDER_PLATFORM,
|
|
||||||
WORKER_SCRIPT
|
|
||||||
} from 'angular2/platform/worker_render';
|
} from 'angular2/platform/worker_render';
|
||||||
|
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
bootstrapRender("loader.js");
|
||||||
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
|
|
||||||
|
@ -7,7 +7,5 @@ import "package:angular2/core.dart";
|
|||||||
|
|
||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main(List<String> args, SendPort replyTo) {
|
main(List<String> args, SendPort replyTo) {
|
||||||
platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)])
|
bootstrapApp(replyTo, InputCmp);
|
||||||
.application([WORKER_APP_APPLICATION])
|
|
||||||
.bootstrap(InputCmp);
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {InputCmp} from "./index_common";
|
import {InputCmp} from "./index_common";
|
||||||
import {platform} from "angular2/core";
|
import {bootstrapApp} from "angular2/platform/worker_app";
|
||||||
import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from "angular2/platform/worker_app";
|
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
platform([WORKER_APP_PLATFORM]).application([WORKER_APP_APPLICATION]).bootstrap(InputCmp);
|
bootstrapApp(InputCmp);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,5 @@ import "package:angular2/core.dart";
|
|||||||
|
|
||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main() {
|
main() {
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
bootstrapRender("background_index.dart");
|
||||||
.asyncApplication(initIsolate("background_index.dart"));
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
import {platform, Provider} from 'angular2/core';
|
import {Provider} from 'angular2/core';
|
||||||
import {
|
import {bootstrapRender} from 'angular2/platform/worker_render';
|
||||||
WORKER_RENDER_APPLICATION,
|
|
||||||
WORKER_RENDER_PLATFORM,
|
|
||||||
WORKER_SCRIPT
|
|
||||||
} from 'angular2/platform/worker_render';
|
|
||||||
|
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
bootstrapRender("loader.js");
|
||||||
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
|
|
||||||
|
@ -7,7 +7,5 @@ import "package:angular2/core.dart";
|
|||||||
|
|
||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main(List<String> args, SendPort replyTo) {
|
main(List<String> args, SendPort replyTo) {
|
||||||
platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)])
|
bootstrapApp(replyTo, HelloCmp);
|
||||||
.application([WORKER_APP_APPLICATION])
|
|
||||||
.bootstrap(HelloCmp);
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {HelloCmp} from "./index_common";
|
import {HelloCmp} from "./index_common";
|
||||||
import {platform} from "angular2/core";
|
import {bootstrapApp} from "angular2/platform/worker_app";
|
||||||
import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from "angular2/platform/worker_app";
|
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
platform([WORKER_APP_PLATFORM]).application([WORKER_APP_APPLICATION]).bootstrap(HelloCmp);
|
bootstrapApp(HelloCmp);
|
||||||
}
|
}
|
@ -5,6 +5,5 @@ import "package:angular2/core.dart";
|
|||||||
|
|
||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main() {
|
main() {
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
bootstrapRender("background_index.dart");
|
||||||
.asyncApplication(initIsolate("background_index.dart"));
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
import {platform, Provider} from 'angular2/core';
|
import {Provider} from 'angular2/core';
|
||||||
import {
|
import {bootstrapRender} from 'angular2/platform/worker_render';
|
||||||
WORKER_RENDER_APPLICATION,
|
|
||||||
WORKER_RENDER_PLATFORM,
|
|
||||||
WORKER_SCRIPT
|
|
||||||
} from 'angular2/platform/worker_render';
|
|
||||||
|
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
bootstrapRender("loader.js");
|
||||||
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
|
|
||||||
|
@ -7,7 +7,5 @@ import "dart:isolate";
|
|||||||
|
|
||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main(List<String> args, SendPort replyTo) {
|
main(List<String> args, SendPort replyTo) {
|
||||||
platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)])
|
bootstrapApp(replyTo, App);
|
||||||
.application([WORKER_APP_APPLICATION])
|
|
||||||
.bootstrap(App);
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {platform} from "angular2/core";
|
import {bootstrapApp} from "angular2/platform/worker_app";
|
||||||
import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from "angular2/platform/worker_app";
|
|
||||||
import {App} from "./index_common";
|
import {App} from "./index_common";
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
platform([WORKER_APP_PLATFORM]).application([WORKER_APP_APPLICATION]).bootstrap(App)
|
bootstrapApp(App);
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@ import "dart:html";
|
|||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main() {
|
main() {
|
||||||
const ECHO_CHANNEL = "ECHO";
|
const ECHO_CHANNEL = "ECHO";
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
bootstrapRender("background_index.dart")
|
||||||
.asyncApplication(initIsolate("background_index.dart"))
|
|
||||||
.then((ref) {
|
.then((ref) {
|
||||||
var brokerFactory = ref.injector.get(ClientMessageBrokerFactory);
|
var brokerFactory = ref.injector.get(ClientMessageBrokerFactory);
|
||||||
var broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false);
|
var broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false);
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import {platform, Provider} from 'angular2/core';
|
import {Provider, ApplicationRef} from 'angular2/core';
|
||||||
import {
|
import {
|
||||||
WORKER_RENDER_APPLICATION,
|
bootstrapRender,
|
||||||
WORKER_RENDER_PLATFORM,
|
|
||||||
WORKER_SCRIPT,
|
|
||||||
UiArguments,
|
UiArguments,
|
||||||
FnArg,
|
FnArg,
|
||||||
PRIMITIVE,
|
PRIMITIVE,
|
||||||
@ -11,10 +9,9 @@ import {
|
|||||||
|
|
||||||
const ECHO_CHANNEL = "ECHO";
|
const ECHO_CHANNEL = "ECHO";
|
||||||
|
|
||||||
let ref =
|
bootstrapRender("loader.js").then((ref) => afterBootstrap(ref));
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
|
||||||
.application(
|
function afterBootstrap(ref: ApplicationRef) {
|
||||||
[WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
|
|
||||||
let brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory);
|
let brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory);
|
||||||
var broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false);
|
var broker = brokerFactory.createMessageBroker(ECHO_CHANNEL, false);
|
||||||
|
|
||||||
@ -36,3 +33,4 @@ document.getElementById("send_echo")
|
|||||||
`<span class='response'>${echo_result}</span>`;
|
`<span class='response'>${echo_result}</span>`;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
@ -9,12 +9,5 @@ import "package:angular2/src/web_workers/worker/router_providers.dart";
|
|||||||
|
|
||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main(List<String> args, SendPort replyTo) {
|
main(List<String> args, SendPort replyTo) {
|
||||||
platform([
|
bootstrapApp(replyTo, App, [WORKER_APP_ROUTER, new Provider(LocationStrategy, useClass: HashLocationStrategy)]);
|
||||||
WORKER_APP_PLATFORM,
|
|
||||||
new Provider(RENDER_SEND_PORT, useValue: replyTo)
|
|
||||||
]).asyncApplication(null, [
|
|
||||||
WORKER_APP_APPLICATION,
|
|
||||||
WORKER_APP_ROUTER,
|
|
||||||
new Provider(LocationStrategy, useClass: HashLocationStrategy)
|
|
||||||
]).then((ref) => ref.bootstrap(App));
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,9 @@
|
|||||||
import {platform, Provider, NgZone} from "angular2/core";
|
import {Provider} from "angular2/core";
|
||||||
|
import {bootstrapApp, WORKER_APP_ROUTER} from "angular2/platform/worker_app";
|
||||||
import {HashLocationStrategy, LocationStrategy} from 'angular2/platform/common';
|
import {HashLocationStrategy, LocationStrategy} from 'angular2/platform/common';
|
||||||
import {
|
|
||||||
WORKER_APP_PLATFORM,
|
|
||||||
WORKER_APP_APPLICATION,
|
|
||||||
WORKER_APP_ROUTER
|
|
||||||
} from "angular2/platform/worker_app";
|
|
||||||
import {App} from "./index_common";
|
import {App} from "./index_common";
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
let refPromise = platform([WORKER_APP_PLATFORM])
|
bootstrapApp(
|
||||||
.asyncApplication(null, [
|
App, [WORKER_APP_ROUTER, new Provider(LocationStrategy, {useClass: HashLocationStrategy})]);
|
||||||
WORKER_APP_APPLICATION,
|
|
||||||
WORKER_APP_ROUTER,
|
|
||||||
new Provider(LocationStrategy, {useClass: HashLocationStrategy})
|
|
||||||
]);
|
|
||||||
refPromise.then((ref) => ref.bootstrap(App));
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,5 @@ import "package:angular2/src/core/reflection/reflection.dart";
|
|||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main() {
|
main() {
|
||||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||||
platform([WORKER_RENDER_PLATFORM]).asyncApplication(
|
bootstrapRender("background_index.dart", WORKER_RENDER_ROUTER);
|
||||||
initIsolate("background_index.dart"), [WORKER_RENDER_ROUTER]);
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
import {platform, Provider} from 'angular2/core';
|
import {Provider} from 'angular2/core';
|
||||||
import {
|
import {bootstrapRender, WORKER_RENDER_ROUTER} from 'angular2/platform/worker_render';
|
||||||
WORKER_RENDER_APP,
|
|
||||||
WORKER_RENDER_PLATFORM,
|
|
||||||
WORKER_SCRIPT,
|
|
||||||
WORKER_RENDER_ROUTER
|
|
||||||
} from 'angular2/platform/worker_render';
|
|
||||||
import {MessageBasedPlatformLocation} from "angular2/src/web_workers/ui/platform_location";
|
import {MessageBasedPlatformLocation} from "angular2/src/web_workers/ui/platform_location";
|
||||||
|
|
||||||
let ref = platform([WORKER_RENDER_PLATFORM])
|
let ref = bootstrapRender("loader.js", WORKER_RENDER_ROUTER);
|
||||||
.application([
|
|
||||||
WORKER_RENDER_APP,
|
|
||||||
new Provider(WORKER_SCRIPT, {useValue: "loader.js"}),
|
|
||||||
WORKER_RENDER_ROUTER
|
|
||||||
]);
|
|
||||||
|
@ -7,7 +7,5 @@ import "package:angular2/core.dart";
|
|||||||
|
|
||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main(List<String> args, SendPort replyTo) {
|
main(List<String> args, SendPort replyTo) {
|
||||||
platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)])
|
bootstrapApp(replyTo, TodoApp);
|
||||||
.application([WORKER_APP_APPLICATION])
|
|
||||||
.bootstrap(TodoApp);
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {TodoApp} from "./index_common";
|
import {TodoApp} from "./index_common";
|
||||||
import {platform} from "angular2/core";
|
import {bootstrapApp} from "angular2/platform/worker_app";
|
||||||
import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from "angular2/platform/worker_app";
|
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
platform([WORKER_APP_PLATFORM]).application([WORKER_APP_APPLICATION]).bootstrap(TodoApp)
|
bootstrapApp(TodoApp);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,5 @@ import "package:angular2/core.dart";
|
|||||||
|
|
||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main() {
|
main() {
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
bootstrapRender("background_index.dart");
|
||||||
.asyncApplication(initIsolate("background_index.dart"));
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
import {platform, Provider} from 'angular2/core';
|
import {Provider} from 'angular2/core';
|
||||||
import {
|
import {bootstrapRender} from 'angular2/platform/worker_render';
|
||||||
WORKER_RENDER_APPLICATION,
|
|
||||||
WORKER_RENDER_PLATFORM,
|
|
||||||
WORKER_SCRIPT
|
|
||||||
} from 'angular2/platform/worker_render';
|
|
||||||
|
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
bootstrapRender("loader.js");
|
||||||
.application([WORKER_RENDER_APPLICATION, new Provider(WORKER_SCRIPT, {useValue: "loader.js"})]);
|
|
@ -10,13 +10,15 @@ main() {
|
|||||||
var webSocket = new WebSocket("ws://127.0.0.1:1337/ws");
|
var webSocket = new WebSocket("ws://127.0.0.1:1337/ws");
|
||||||
webSocket.onOpen.listen((e) {
|
webSocket.onOpen.listen((e) {
|
||||||
var bus = new WebSocketMessageBus.fromWebSocket(webSocket);
|
var bus = new WebSocketMessageBus.fromWebSocket(webSocket);
|
||||||
platform([WORKER_RENDER_PLATFORM])
|
var platform = createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM));
|
||||||
.application([WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, useValue: bus),
|
var appInjector = ReflectiveInjector.resolveAndCreate([
|
||||||
|
WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, useValue: bus),
|
||||||
new Provider(APP_INITIALIZER,
|
new Provider(APP_INITIALIZER,
|
||||||
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
|
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
|
||||||
deps: [Injector],
|
deps: [Injector],
|
||||||
multi: true
|
multi: true
|
||||||
)
|
)
|
||||||
]);
|
], platform.injector);
|
||||||
|
appInjector.get(ApplicationRef);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,14 @@ void main() {
|
|||||||
print("Server Listening for requests on 127.0.0.1:1337");
|
print("Server Listening for requests on 127.0.0.1:1337");
|
||||||
var bus = new MultiClientServerMessageBus.fromHttpServer(server);
|
var bus = new MultiClientServerMessageBus.fromHttpServer(server);
|
||||||
|
|
||||||
platform([WORKER_APP_PLATFORM]).application([
|
var platform = createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_APP_PLATFORM));
|
||||||
|
var appInjector = ReflectiveInjector.resolveAndCreate([
|
||||||
WORKER_APP_APPLICATION_COMMON,
|
WORKER_APP_APPLICATION_COMMON,
|
||||||
new Provider(MessageBus, useValue: bus),
|
new Provider(MessageBus, useValue: bus),
|
||||||
new Provider(APP_INITIALIZER,
|
new Provider(APP_INITIALIZER,
|
||||||
useFactory: initAppThread, multi: true, deps: [NgZone, MessageBus])
|
useFactory: initAppThread, multi: true, deps: [NgZone, MessageBus])
|
||||||
]).bootstrap(TodoApp);
|
], platform.injector);
|
||||||
|
coreLoadAndBootstrap(appInjector, TodoApp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import 'package:test/test.dart';
|
|||||||
|
|
||||||
import 'package:angular2/angular2.dart';
|
import 'package:angular2/angular2.dart';
|
||||||
import 'package:angular2/src/core/di/metadata.dart' show InjectMetadata;
|
import 'package:angular2/src/core/di/metadata.dart' show InjectMetadata;
|
||||||
import 'package:angular2/src/core/di/exceptions.dart' show NoAnnotationError;
|
import 'package:angular2/src/core/di/reflective_exceptions.dart' show NoAnnotationError;
|
||||||
import 'package:angular2/src/core/reflection/reflection.dart';
|
import 'package:angular2/src/core/reflection/reflection.dart';
|
||||||
import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
|
import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
|
||||||
import 'package:angular2/src/testing/test_injector.dart';
|
import 'package:angular2/src/testing/test_injector.dart';
|
||||||
|
@ -3,7 +3,7 @@ library bar;
|
|||||||
import 'package:angular2/src/core/metadata.dart';
|
import 'package:angular2/src/core/metadata.dart';
|
||||||
import 'foo.dart';
|
import 'foo.dart';
|
||||||
|
|
||||||
@Component(componentServices: const [MyContext])
|
@Component(selector: 'my', providers: const [MyContext])
|
||||||
@View(template: '')
|
@View(template: '')
|
||||||
class MyComponent {
|
class MyComponent {
|
||||||
final MyContext c;
|
final MyContext c;
|
||||||
|
@ -29,13 +29,15 @@ const CORE = [
|
|||||||
'AfterViewInit',
|
'AfterViewInit',
|
||||||
'AfterViewInit.ngAfterViewInit():any',
|
'AfterViewInit.ngAfterViewInit():any',
|
||||||
'ApplicationRef',
|
'ApplicationRef',
|
||||||
'ApplicationRef.bootstrap(componentType:Type, providers:Array<Type|Provider|any[]>):Promise<ComponentRef>',
|
'ApplicationRef.bootstrap(componentFactory:ComponentFactory):ComponentRef',
|
||||||
'ApplicationRef.componentTypes:Type[]',
|
'ApplicationRef.componentTypes:Type[]',
|
||||||
'ApplicationRef.dispose():void',
|
'ApplicationRef.dispose():void',
|
||||||
'ApplicationRef.injector:Injector',
|
'ApplicationRef.injector:Injector',
|
||||||
'ApplicationRef.registerBootstrapListener(listener:(ref: ComponentRef) => void):void',
|
'ApplicationRef.registerBootstrapListener(listener:(ref: ComponentRef) => void):void',
|
||||||
'ApplicationRef.registerDisposeListener(dispose:() => void):void',
|
'ApplicationRef.registerDisposeListener(dispose:() => void):void',
|
||||||
'ApplicationRef.tick():void',
|
'ApplicationRef.tick():void',
|
||||||
|
'ApplicationRef.run(callback:Function):any',
|
||||||
|
'ApplicationRef.waitForAsyncInitializers():Promise<any>',
|
||||||
'ApplicationRef.zone:NgZone',
|
'ApplicationRef.zone:NgZone',
|
||||||
'AttributeMetadataFactory',
|
'AttributeMetadataFactory',
|
||||||
'AttributeMetadata',
|
'AttributeMetadata',
|
||||||
@ -157,7 +159,7 @@ const CORE = [
|
|||||||
'DoCheck',
|
'DoCheck',
|
||||||
'DoCheck.ngDoCheck():any',
|
'DoCheck.ngDoCheck():any',
|
||||||
'DynamicComponentLoader',
|
'DynamicComponentLoader',
|
||||||
'DynamicComponentLoader.loadAsRoot(type:Type, overrideSelectorOrNode:string, injector:Injector, onDispose:() => void, projectableNodes:any[][]):Promise<ComponentRef>',
|
'DynamicComponentLoader.loadAsRoot(type:Type, overrideSelectorOrNode:string|any, injector:Injector, onDispose:() => void, projectableNodes:any[][]):Promise<ComponentRef>',
|
||||||
'DynamicComponentLoader.loadNextToLocation(type:Type, location:ViewContainerRef, providers:ResolvedReflectiveProvider[], projectableNodes:any[][]):Promise<ComponentRef>',
|
'DynamicComponentLoader.loadNextToLocation(type:Type, location:ViewContainerRef, providers:ResolvedReflectiveProvider[], projectableNodes:any[][]):Promise<ComponentRef>',
|
||||||
'ElementRef',
|
'ElementRef',
|
||||||
'ElementRef.nativeElement:any',
|
'ElementRef.nativeElement:any',
|
||||||
@ -274,6 +276,7 @@ const CORE = [
|
|||||||
'NgZone.onMicrotaskEmpty:EventEmitter<any>',
|
'NgZone.onMicrotaskEmpty:EventEmitter<any>',
|
||||||
'NgZone.onUnstable:EventEmitter<any>',
|
'NgZone.onUnstable:EventEmitter<any>',
|
||||||
'NgZone.run(fn:() => any):any',
|
'NgZone.run(fn:() => any):any',
|
||||||
|
'NgZone.runGuarded(fn:() => any):any',
|
||||||
'NgZone.runOutsideAngular(fn:() => any):any',
|
'NgZone.runOutsideAngular(fn:() => any):any',
|
||||||
'NgZoneError',
|
'NgZoneError',
|
||||||
'NgZoneError.constructor(error:any, stackTrace:any)',
|
'NgZoneError.constructor(error:any, stackTrace:any)',
|
||||||
@ -306,11 +309,10 @@ const CORE = [
|
|||||||
'PipeTransform',
|
'PipeTransform',
|
||||||
'PipeTransform.transform(value:any, args:any[]):any',
|
'PipeTransform.transform(value:any, args:any[]):any',
|
||||||
'PlatformRef',
|
'PlatformRef',
|
||||||
'PlatformRef.application(providers:Array<Type|Provider|any[]>):ApplicationRef',
|
|
||||||
'PlatformRef.asyncApplication(bindingFn:(zone: NgZone) => Promise<Array<Type | Provider | any[]>>, providers:Array<Type|Provider|any[]>):Promise<ApplicationRef>',
|
|
||||||
'PlatformRef.dispose():void',
|
'PlatformRef.dispose():void',
|
||||||
'PlatformRef.injector:Injector',
|
'PlatformRef.injector:Injector',
|
||||||
'PlatformRef.registerDisposeListener(dispose:() => void):void',
|
'PlatformRef.registerDisposeListener(dispose:() => void):void',
|
||||||
|
'PlatformRef.disposed:boolean',
|
||||||
'Provider',
|
'Provider',
|
||||||
'Provider.constructor(token:any, {useClass,useValue,useExisting,useFactory,deps,multi}:{useClass?:Type, useValue?:any, useExisting?:any, useFactory?:Function, deps?:Object[], multi?:boolean})',
|
'Provider.constructor(token:any, {useClass,useValue,useExisting,useFactory,deps,multi}:{useClass?:Type, useValue?:any, useExisting?:any, useFactory?:Function, deps?:Object[], multi?:boolean})',
|
||||||
'Provider.dependencies:Object[]',
|
'Provider.dependencies:Object[]',
|
||||||
@ -493,7 +495,6 @@ const CORE = [
|
|||||||
'WrappedValue.wrap(value:any):WrappedValue',
|
'WrappedValue.wrap(value:any):WrappedValue',
|
||||||
'bind(token:any):ProviderBuilder',
|
'bind(token:any):ProviderBuilder',
|
||||||
'const APPLICATION_COMMON_PROVIDERS:Array<Type|Provider|any[]>',
|
'const APPLICATION_COMMON_PROVIDERS:Array<Type|Provider|any[]>',
|
||||||
'const APP_COMPONENT:OpaqueToken',
|
|
||||||
'const APP_ID:OpaqueToken',
|
'const APP_ID:OpaqueToken',
|
||||||
'const APP_INITIALIZER:OpaqueToken',
|
'const APP_INITIALIZER:OpaqueToken',
|
||||||
'const PACKAGE_ROOT_URL:OpaqueToken',
|
'const PACKAGE_ROOT_URL:OpaqueToken',
|
||||||
@ -504,7 +505,12 @@ const CORE = [
|
|||||||
'createNgZone():NgZone',
|
'createNgZone():NgZone',
|
||||||
'enableProdMode():any',
|
'enableProdMode():any',
|
||||||
'forwardRef(forwardRefFn:ForwardRefFn):Type',
|
'forwardRef(forwardRefFn:ForwardRefFn):Type',
|
||||||
'platform(providers:Array<Type|Provider|any[]>):PlatformRef',
|
'coreBootstrap(injector:Injector, componentFactory:ComponentFactory):ComponentRef',
|
||||||
|
'coreLoadAndBootstrap(injector:Injector, componentType:Type):Promise<ComponentRef>',
|
||||||
|
'assertPlatform(requiredToken:any):PlatformRef',
|
||||||
|
'createPlatform(injector:Injector):PlatformRef',
|
||||||
|
'disposePlatform():void',
|
||||||
|
'getPlatform():PlatformRef',
|
||||||
'provide(token:any, {useClass,useValue,useExisting,useFactory,deps,multi}:{useClass?:Type, useValue?:any, useExisting?:any, useFactory?:Function, deps?:Object[], multi?:boolean}):Provider',
|
'provide(token:any, {useClass,useValue,useExisting,useFactory,deps,multi}:{useClass?:Type, useValue?:any, useExisting?:any, useFactory?:Function, deps?:Object[], multi?:boolean}):Provider',
|
||||||
'resolveForwardRef(type:any):any',
|
'resolveForwardRef(type:any):any',
|
||||||
'setTestabilityGetter(getter:GetTestability):void',
|
'setTestabilityGetter(getter:GetTestability):void',
|
||||||
@ -1210,7 +1216,8 @@ const BROWSER = [
|
|||||||
'const ELEMENT_PROBE_PROVIDERS_PROD_MODE:any[]',
|
'const ELEMENT_PROBE_PROVIDERS_PROD_MODE:any[]',
|
||||||
'disableDebugTools():void',
|
'disableDebugTools():void',
|
||||||
'enableDebugTools(ref:ComponentRef):void',
|
'enableDebugTools(ref:ComponentRef):void',
|
||||||
'inspectNativeElement(element:any):DebugNode'
|
'inspectNativeElement(element:any):DebugNode',
|
||||||
|
'browserStaticPlatform():PlatformRef'
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('public API', () => {
|
describe('public API', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user