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); ```
62 lines
2.4 KiB
TypeScript
62 lines
2.4 KiB
TypeScript
import {XHR} from 'angular2/src/compiler/xhr';
|
|
import {WebWorkerXHRImpl} from 'angular2/src/web_workers/worker/xhr_impl';
|
|
import {WebWorkerRootRenderer} from 'angular2/src/web_workers/worker/renderer';
|
|
import {print, Type, CONST_EXPR, isPresent} from 'angular2/src/facade/lang';
|
|
import {RootRenderer} from 'angular2/src/core/render/api';
|
|
import {
|
|
PLATFORM_DIRECTIVES,
|
|
PLATFORM_PIPES,
|
|
ExceptionHandler,
|
|
APPLICATION_COMMON_PROVIDERS,
|
|
PLATFORM_COMMON_PROVIDERS,
|
|
OpaqueToken
|
|
} from 'angular2/core';
|
|
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from "angular2/common";
|
|
import {
|
|
ClientMessageBrokerFactory,
|
|
ClientMessageBrokerFactory_
|
|
} from 'angular2/src/web_workers/shared/client_message_broker';
|
|
import {
|
|
ServiceMessageBrokerFactory,
|
|
ServiceMessageBrokerFactory_
|
|
} from 'angular2/src/web_workers/shared/service_message_broker';
|
|
import {Serializer} from "angular2/src/web_workers/shared/serializer";
|
|
import {ON_WEB_WORKER} from "angular2/src/web_workers/shared/api";
|
|
import {Provider} from 'angular2/src/core/di';
|
|
import {RenderStore} from 'angular2/src/web_workers/shared/render_store';
|
|
|
|
class PrintLogger {
|
|
log = print;
|
|
logError = print;
|
|
logGroup = print;
|
|
logGroupEnd() {}
|
|
}
|
|
|
|
export const WORKER_APP_PLATFORM_MARKER = CONST_EXPR(new OpaqueToken('WorkerAppPlatformMarker'));
|
|
|
|
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([
|
|
APPLICATION_COMMON_PROVIDERS,
|
|
FORM_PROVIDERS,
|
|
Serializer,
|
|
new Provider(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
|
|
new Provider(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
|
|
new Provider(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}),
|
|
new Provider(ServiceMessageBrokerFactory, {useClass: ServiceMessageBrokerFactory_}),
|
|
WebWorkerRootRenderer,
|
|
new Provider(RootRenderer, {useExisting: WebWorkerRootRenderer}),
|
|
new Provider(ON_WEB_WORKER, {useValue: true}),
|
|
RenderStore,
|
|
new Provider(ExceptionHandler, {useFactory: _exceptionHandler, deps: []}),
|
|
WebWorkerXHRImpl,
|
|
new Provider(XHR, {useExisting: WebWorkerXHRImpl})
|
|
]);
|
|
|
|
function _exceptionHandler(): ExceptionHandler {
|
|
return new ExceptionHandler(new PrintLogger());
|
|
}
|