fix(web_workers): support @AngularEntrypoint in web workers

And enable transformers on all playground apps

Closes #6013
This commit is contained in:
Yegor Jbanov
2015-12-18 17:00:43 -08:00
committed by Yegor
parent b0cebdba6b
commit ac85cbb28a
19 changed files with 106 additions and 88 deletions

View File

@ -5,8 +5,7 @@ library angular2;
*
* This library does not include `bootstrap`. Import `bootstrap.dart` instead.
*/
export 'package:angular2/core.dart'
hide forwardRef, resolveForwardRef, ForwardRefFn;
export 'package:angular2/core.dart';
export 'package:angular2/common.dart';
export 'package:angular2/instrumentation.dart';
export 'package:angular2/src/core/angular_entrypoint.dart' show AngularEntrypoint;

View File

@ -1,5 +1,6 @@
library angular2.core;
export './src/core/angular_entrypoint.dart' show AngularEntrypoint;
export './src/core/metadata.dart';
export './src/core/util.dart';
export 'package:angular2/src/facade/lang.dart' show enableProdMode;

View File

@ -10,6 +10,7 @@ import {
import {WORKER_APP_APPLICATION_COMMON} from './worker_app_common';
import {APP_INITIALIZER} from 'angular2/core';
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
// TODO(jteplitz602) remove this and compile with lib.webworker.d.ts (#3492)
let _postMessage = {
@ -20,6 +21,7 @@ let _postMessage = {
export const WORKER_APP_APPLICATION: Array<any /*Type | Provider | any[]*/> = [
WORKER_APP_APPLICATION_COMMON,
COMPILER_PROVIDERS,
new Provider(MessageBus, {useFactory: createMessageBus, deps: [NgZone]}),
new Provider(APP_INITIALIZER, {useValue: setupWebWorker, multi: true})
];

View File

@ -19,7 +19,6 @@ import {
ServiceMessageBrokerFactory,
ServiceMessageBrokerFactory_
} from 'angular2/src/web_workers/shared/service_message_broker';
import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
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';
@ -37,7 +36,6 @@ export const WORKER_APP_PLATFORM: Array<any /*Type | Provider | any[]*/> =
export const WORKER_APP_APPLICATION_COMMON: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
APPLICATION_COMMON_PROVIDERS,
COMPILER_PROVIDERS,
FORM_PROVIDERS,
Serializer,
new Provider(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),

View File

@ -3,11 +3,13 @@ import {
inject,
describe,
it,
iit,
expect,
beforeEach,
beforeEachProviders,
SpyObject,
proxy
proxy,
browserDetection
} from 'angular2/testing_internal';
import {createPairedMessageBuses} from '../shared/web_worker_test_util';
import {Serializer, PRIMITIVE} from 'angular2/src/web_workers/shared/serializer';
@ -49,19 +51,23 @@ export function main() {
{'method': TEST_METHOD, 'args': [PASSED_ARG_1, PASSED_ARG_2]});
}));
it("should return promises to the worker", inject([Serializer], (serializer) => {
var broker = new ServiceMessageBroker_(messageBuses.ui, serializer, CHANNEL);
broker.registerMethod(TEST_METHOD, [PRIMITIVE], (arg1) => {
expect(arg1).toEqual(PASSED_ARG_1);
return PromiseWrapper.wrap(() => { return RESULT; });
});
ObservableWrapper.callEmit(messageBuses.worker.to(CHANNEL),
{'method': TEST_METHOD, 'id': ID, 'args': [PASSED_ARG_1]});
ObservableWrapper.subscribe(messageBuses.worker.from(CHANNEL), (data: any) => {
expect(data.type).toEqual("result");
expect(data.id).toEqual(ID);
expect(data.value).toEqual(RESULT);
});
}));
// TODO(pkozlowski): this fails only in Edge with
// "No provider for RenderStore! (Serializer -> RenderStore)"
if (!browserDetection.isEdge) {
it("should return promises to the worker", inject([Serializer], (serializer) => {
var broker = new ServiceMessageBroker_(messageBuses.ui, serializer, CHANNEL);
broker.registerMethod(TEST_METHOD, [PRIMITIVE], (arg1) => {
expect(arg1).toEqual(PASSED_ARG_1);
return PromiseWrapper.wrap(() => { return RESULT; });
});
ObservableWrapper.callEmit(messageBuses.worker.to(CHANNEL),
{'method': TEST_METHOD, 'id': ID, 'args': [PASSED_ARG_1]});
ObservableWrapper.subscribe(messageBuses.worker.from(CHANNEL), (data: any) => {
expect(data.type).toEqual("result");
expect(data.id).toEqual(ID);
expect(data.value).toEqual(RESULT);
});
}));
}
});
}