parent
84463cf0bd
commit
a1c53eec6b
|
@ -2,8 +2,8 @@ import {CONST_EXPR} from "angular2/src/facade/lang";
|
|||
import {OpaqueToken} from "angular2/di";
|
||||
import {RenderElementRef, RenderViewRef} from "angular2/src/render/api";
|
||||
|
||||
export const ON_WEBWORKER = CONST_EXPR(new OpaqueToken('WebWorker.onWebWorker'));
|
||||
export const ON_WEB_WORKER = CONST_EXPR(new OpaqueToken('WebWorker.onWebWorker'));
|
||||
|
||||
export class WorkerElementRef implements RenderElementRef {
|
||||
export class WebWorkerElementRef implements RenderElementRef {
|
||||
constructor(public renderView: RenderViewRef, public renderBoundElementIndex: number) {}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ export interface MessageBusSource {
|
|||
/**
|
||||
* Attaches the SourceListener to this source.
|
||||
* The SourceListener will get called whenever the bus receives a message
|
||||
* Returns a listener id that can be passed to {@link removeListener}
|
||||
* Returns a listener id that can be passed to {removeListener}
|
||||
*/
|
||||
addListener(fn: SourceListener): number;
|
||||
removeListener(index: number);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Injectable, Inject} from "angular2/di";
|
||||
import {RenderProtoViewRef} from "angular2/src/render/api";
|
||||
import {ON_WEBWORKER} from "angular2/src/web-workers/shared/api";
|
||||
import {ON_WEB_WORKER} from "angular2/src/web-workers/shared/api";
|
||||
|
||||
@Injectable()
|
||||
export class RenderProtoViewRefStore {
|
||||
|
@ -10,7 +10,7 @@ export class RenderProtoViewRefStore {
|
|||
private _nextIndex: number = 0;
|
||||
private _onWebworker: boolean;
|
||||
|
||||
constructor(@Inject(ON_WEBWORKER) onWebworker) { this._onWebworker = onWebworker; }
|
||||
constructor(@Inject(ON_WEB_WORKER) onWebworker) { this._onWebworker = onWebworker; }
|
||||
|
||||
storeRenderProtoViewRef(ref: RenderProtoViewRef): number {
|
||||
if (this._lookupByProtoView.has(ref)) {
|
||||
|
@ -32,7 +32,7 @@ export class RenderProtoViewRefStore {
|
|||
}
|
||||
|
||||
if (this._onWebworker) {
|
||||
return new WebworkerRenderProtoViewRef(index);
|
||||
return new WebWorkerRenderProtoViewRef(index);
|
||||
} else {
|
||||
return this.retreiveRenderProtoViewRef(index);
|
||||
}
|
||||
|
@ -44,13 +44,13 @@ export class RenderProtoViewRefStore {
|
|||
}
|
||||
|
||||
if (this._onWebworker) {
|
||||
return (<WebworkerRenderProtoViewRef>ref).refNumber;
|
||||
return (<WebWorkerRenderProtoViewRef>ref).refNumber;
|
||||
} else {
|
||||
return this.storeRenderProtoViewRef(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class WebworkerRenderProtoViewRef extends RenderProtoViewRef {
|
||||
export class WebWorkerRenderProtoViewRef extends RenderProtoViewRef {
|
||||
constructor(public refNumber: number) { super(); }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Injectable, Inject} from "angular2/di";
|
||||
import {RenderViewRef, RenderFragmentRef, RenderViewWithFragments} from "angular2/src/render/api";
|
||||
import {ON_WEBWORKER} from "angular2/src/web-workers/shared/api";
|
||||
import {ON_WEB_WORKER} from "angular2/src/web-workers/shared/api";
|
||||
import {List, ListWrapper} from "angular2/src/facade/collection";
|
||||
|
||||
@Injectable()
|
||||
|
@ -10,7 +10,7 @@ export class RenderViewWithFragmentsStore {
|
|||
private _lookupByIndex: Map<number, RenderViewRef | RenderFragmentRef>;
|
||||
private _lookupByView: Map<RenderViewRef | RenderFragmentRef, number>;
|
||||
|
||||
constructor(@Inject(ON_WEBWORKER) onWebWorker) {
|
||||
constructor(@Inject(ON_WEB_WORKER) onWebWorker) {
|
||||
this._onWebWorker = onWebWorker;
|
||||
this._lookupByIndex = new Map<number, RenderViewRef | RenderFragmentRef>();
|
||||
this._lookupByView = new Map<RenderViewRef | RenderFragmentRef, number>();
|
||||
|
@ -19,11 +19,11 @@ export class RenderViewWithFragmentsStore {
|
|||
allocate(fragmentCount: number): RenderViewWithFragments {
|
||||
var initialIndex = this._nextIndex;
|
||||
|
||||
var viewRef = new WorkerRenderViewRef(this._nextIndex++);
|
||||
var viewRef = new WebWorkerRenderViewRef(this._nextIndex++);
|
||||
var fragmentRefs = ListWrapper.createGrowableSize(fragmentCount);
|
||||
|
||||
for (var i = 0; i < fragmentCount; i++) {
|
||||
fragmentRefs[i] = new WorkerRenderFragmentRef(this._nextIndex++);
|
||||
fragmentRefs[i] = new WebWorkerRenderFragmentRef(this._nextIndex++);
|
||||
}
|
||||
var renderViewWithFragments = new RenderViewWithFragments(viewRef, fragmentRefs);
|
||||
this.store(renderViewWithFragments, initialIndex);
|
||||
|
@ -79,7 +79,7 @@ export class RenderViewWithFragmentsStore {
|
|||
}
|
||||
|
||||
if (this._onWebWorker) {
|
||||
return (<WorkerRenderFragmentRef | WorkerRenderViewRef>ref).serialize();
|
||||
return (<WebWorkerRenderFragmentRef | WebWorkerRenderViewRef>ref).serialize();
|
||||
} else {
|
||||
return this._lookupByView.get(ref);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ export class RenderViewWithFragmentsStore {
|
|||
|
||||
if (this._onWebWorker) {
|
||||
return {
|
||||
'viewRef': (<WorkerRenderViewRef>view.viewRef).serialize(),
|
||||
'viewRef': (<WebWorkerRenderViewRef>view.viewRef).serialize(),
|
||||
'fragmentRefs': ListWrapper.map(view.fragmentRefs, (val) => val.serialize())
|
||||
};
|
||||
} else {
|
||||
|
@ -116,19 +116,21 @@ export class RenderViewWithFragmentsStore {
|
|||
}
|
||||
}
|
||||
|
||||
export class WorkerRenderViewRef extends RenderViewRef {
|
||||
export class WebWorkerRenderViewRef extends RenderViewRef {
|
||||
constructor(public refNumber: number) { super(); }
|
||||
serialize(): number { return this.refNumber; }
|
||||
|
||||
static deserialize(ref: number): WorkerRenderViewRef { return new WorkerRenderViewRef(ref); }
|
||||
}
|
||||
|
||||
export class WorkerRenderFragmentRef extends RenderFragmentRef {
|
||||
constructor(public refNumber: number) { super(); }
|
||||
|
||||
serialize(): number { return this.refNumber; }
|
||||
|
||||
static deserialize(ref: number): WorkerRenderFragmentRef {
|
||||
return new WorkerRenderFragmentRef(ref);
|
||||
static deserialize(ref: number): WebWorkerRenderViewRef {
|
||||
return new WebWorkerRenderViewRef(ref);
|
||||
}
|
||||
}
|
||||
|
||||
export class WebWorkerRenderFragmentRef extends RenderFragmentRef {
|
||||
constructor(public refNumber: number) { super(); }
|
||||
|
||||
serialize(): number { return this.refNumber; }
|
||||
|
||||
static deserialize(ref: number): WebWorkerRenderFragmentRef {
|
||||
return new WebWorkerRenderFragmentRef(ref);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import {
|
|||
ViewEncapsulation,
|
||||
PropertyBindingType
|
||||
} from "angular2/src/render/api";
|
||||
import {WorkerElementRef} from 'angular2/src/web-workers/shared/api';
|
||||
import {WebWorkerElementRef} from 'angular2/src/web-workers/shared/api';
|
||||
import {AST, ASTWithSource} from 'angular2/src/change_detection/change_detection';
|
||||
import {Parser} from "angular2/src/change_detection/parser/parser";
|
||||
import {Injectable} from "angular2/di";
|
||||
|
@ -99,7 +99,7 @@ export class Serializer {
|
|||
return this._renderViewStore.serializeRenderViewRef(obj);
|
||||
} else if (type == RenderFragmentRef) {
|
||||
return this._renderViewStore.serializeRenderFragmentRef(obj);
|
||||
} else if (type == WorkerElementRef) {
|
||||
} else if (type == WebWorkerElementRef) {
|
||||
return this._serializeWorkerElementRef(obj);
|
||||
} else if (type == ElementPropertyBinding) {
|
||||
return this._serializeElementPropertyBinding(obj);
|
||||
|
@ -143,7 +143,7 @@ export class Serializer {
|
|||
return this._renderViewStore.deserializeRenderViewRef(map);
|
||||
} else if (type == RenderFragmentRef) {
|
||||
return this._renderViewStore.deserializeRenderFragmentRef(map);
|
||||
} else if (type == WorkerElementRef) {
|
||||
} else if (type == WebWorkerElementRef) {
|
||||
return this._deserializeWorkerElementRef(map);
|
||||
} else if (type == EventBinding) {
|
||||
return this._deserializeEventBinding(map);
|
||||
|
@ -219,8 +219,8 @@ export class Serializer {
|
|||
}
|
||||
|
||||
private _deserializeWorkerElementRef(map: StringMap<string, any>): RenderElementRef {
|
||||
return new WorkerElementRef(this.deserialize(map['renderView'], RenderViewRef),
|
||||
map['renderBoundElementIndex']);
|
||||
return new WebWorkerElementRef(this.deserialize(map['renderView'], RenderViewRef),
|
||||
map['renderBoundElementIndex']);
|
||||
}
|
||||
|
||||
private _serializeRenderProtoViewMergeMapping(mapping: RenderProtoViewMergeMapping): Object {
|
||||
|
|
|
@ -14,7 +14,7 @@ import 'package:angular2/src/web-workers/ui/impl.dart' show bootstrapUICommon;
|
|||
* Note: The WebWorker script must call bootstrapWebworker once it is set up to complete the bootstrapping process
|
||||
*/
|
||||
Future<MessageBus> bootstrap(String uri) {
|
||||
return spawnWorker(Uri.parse(uri)).then((bus) {
|
||||
return spawnWebWorker(Uri.parse(uri)).then((bus) {
|
||||
bootstrapUICommon(bus);
|
||||
return bus;
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ Future<MessageBus> bootstrap(String uri) {
|
|||
/**
|
||||
* To be called from the main thread to spawn and communicate with the worker thread
|
||||
*/
|
||||
Future<UIMessageBus> spawnWorker(Uri uri) {
|
||||
Future<UIMessageBus> spawnWebWorker(Uri uri) {
|
||||
var receivePort = new ReceivePort();
|
||||
var isolateEndSendPort = receivePort.sendPort;
|
||||
return Isolate.spawnUri(uri, const [], isolateEndSendPort).then((_) {
|
||||
|
|
|
@ -16,14 +16,14 @@ import {bootstrapUICommon} from "angular2/src/web-workers/ui/impl";
|
|||
* bootstrapping process
|
||||
*/
|
||||
export function bootstrap(uri: string): MessageBus {
|
||||
var messageBus = spawnWorker(uri);
|
||||
var messageBus = spawnWebWorker(uri);
|
||||
bootstrapUICommon(messageBus);
|
||||
return messageBus;
|
||||
}
|
||||
|
||||
export function spawnWorker(uri: string): MessageBus {
|
||||
var worker: Worker = new Worker(uri);
|
||||
return new UIMessageBus(new UIMessageBusSink(worker), new UIMessageBusSource(worker));
|
||||
export function spawnWebWorker(uri: string): MessageBus {
|
||||
var webWorker: Worker = new Worker(uri);
|
||||
return new UIMessageBus(new UIMessageBusSink(webWorker), new UIMessageBusSource(webWorker));
|
||||
}
|
||||
|
||||
export class UIMessageBus implements MessageBus {
|
||||
|
@ -31,19 +31,19 @@ export class UIMessageBus implements MessageBus {
|
|||
}
|
||||
|
||||
export class UIMessageBusSink implements MessageBusSink {
|
||||
constructor(private _worker: Worker) {}
|
||||
constructor(private _webWorker: Worker) {}
|
||||
|
||||
send(message: Object): void { this._worker.postMessage(message); }
|
||||
send(message: Object): void { this._webWorker.postMessage(message); }
|
||||
}
|
||||
|
||||
export class UIMessageBusSource implements MessageBusSource {
|
||||
private _listenerStore: Map<int, SourceListener> = new Map<int, SourceListener>();
|
||||
private _numListeners: int = 0;
|
||||
|
||||
constructor(private _worker: Worker) {}
|
||||
constructor(private _webWorker: Worker) {}
|
||||
|
||||
public addListener(fn: SourceListener): int {
|
||||
this._worker.addEventListener("message", fn);
|
||||
this._webWorker.addEventListener("message", fn);
|
||||
this._listenerStore[++this._numListeners] = fn;
|
||||
return this._numListeners;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ import {Testability} from 'angular2/src/core/testability/testability';
|
|||
import {XHR} from 'angular2/src/render/xhr';
|
||||
import {XHRImpl} from 'angular2/src/render/xhr_impl';
|
||||
import {Serializer} from 'angular2/src/web-workers/shared/serializer';
|
||||
import {ON_WEBWORKER} from 'angular2/src/web-workers/shared/api';
|
||||
import {ON_WEB_WORKER} from 'angular2/src/web-workers/shared/api';
|
||||
import {RenderProtoViewRefStore} from 'angular2/src/web-workers/shared/render_proto_view_ref_store';
|
||||
import {
|
||||
RenderViewWithFragmentsStore
|
||||
|
@ -101,7 +101,7 @@ function _injectorBindings(): List<Type | Binding | List<any>> {
|
|||
DomSharedStylesHost,
|
||||
bind(SharedStylesHost).toAlias(DomSharedStylesHost),
|
||||
Serializer,
|
||||
bind(ON_WEBWORKER).toValue(false),
|
||||
bind(ON_WEB_WORKER).toValue(false),
|
||||
bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),
|
||||
RenderViewWithFragmentsStore,
|
||||
RenderProtoViewRefStore,
|
||||
|
|
|
@ -27,7 +27,7 @@ import {
|
|||
RenderViewWithFragmentsStore
|
||||
} from 'angular2/src/web-workers/shared/render_view_with_fragments_store';
|
||||
import {createNgZone} from 'angular2/src/core/application_common';
|
||||
import {WorkerElementRef} from 'angular2/src/web-workers/shared/api';
|
||||
import {WebWorkerElementRef} from 'angular2/src/web-workers/shared/api';
|
||||
import {AnchorBasedAppRootUrl} from 'angular2/src/services/anchor_based_app_root_url';
|
||||
import {Injectable} from 'angular2/di';
|
||||
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
|
||||
|
@ -50,7 +50,7 @@ export function bootstrapUICommon(bus: MessageBus) {
|
|||
zone.run(() => {
|
||||
var injector = createInjector(zone);
|
||||
var webWorkerMain = injector.get(WebWorkerMain);
|
||||
webWorkerMain.attachToWorker(bus);
|
||||
webWorkerMain.attachToWebWorker(bus);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -70,21 +70,21 @@ export class WebWorkerMain {
|
|||
* This instance will now listen for all messages from the worker and handle them appropriately
|
||||
* Note: Don't attach more than one WebWorkerMain instance to the same MessageBus.
|
||||
*/
|
||||
attachToWorker(bus: MessageBus) {
|
||||
attachToWebWorker(bus: MessageBus) {
|
||||
this._bus = bus;
|
||||
this._bus.source.addListener((message) => { this._handleWorkerMessage(message); });
|
||||
this._bus.source.addListener((message) => { this._handleWebWorkerMessage(message); });
|
||||
}
|
||||
|
||||
private _sendInitMessage() { this._sendWorkerMessage("init", {"rootUrl": this._rootUrl}); }
|
||||
private _sendInitMessage() { this._sendWebWorkerMessage("init", {"rootUrl": this._rootUrl}); }
|
||||
|
||||
/*
|
||||
* Sends an error back to the worker thread in response to an opeartion on the UI thread
|
||||
*/
|
||||
private _sendWorkerError(id: string, error: any) {
|
||||
this._sendWorkerMessage("error", {"error": error}, id);
|
||||
private _sendWebWorkerError(id: string, error: any) {
|
||||
this._sendWebWorkerMessage("error", {"error": error}, id);
|
||||
}
|
||||
|
||||
private _sendWorkerMessage(type: string, value: StringMap<string, any>, id?: string) {
|
||||
private _sendWebWorkerMessage(type: string, value: StringMap<string, any>, id?: string) {
|
||||
this._bus.sink.send({'type': type, 'id': id, 'value': value});
|
||||
}
|
||||
|
||||
|
@ -95,17 +95,17 @@ export class WebWorkerMain {
|
|||
case "compileHost":
|
||||
var directiveMetadata = this._serializer.deserialize(data.args[0], DirectiveMetadata);
|
||||
promise = this._renderCompiler.compileHost(directiveMetadata);
|
||||
this._wrapWorkerPromise(data.id, promise, ProtoViewDto);
|
||||
this._wrapWebWorkerPromise(data.id, promise, ProtoViewDto);
|
||||
break;
|
||||
case "compile":
|
||||
var view = this._serializer.deserialize(data.args[0], ViewDefinition);
|
||||
promise = this._renderCompiler.compile(view);
|
||||
this._wrapWorkerPromise(data.id, promise, ProtoViewDto);
|
||||
this._wrapWebWorkerPromise(data.id, promise, ProtoViewDto);
|
||||
break;
|
||||
case "mergeProtoViewsRecursively":
|
||||
var views = this._serializer.deserialize(data.args[0], RenderProtoViewRef);
|
||||
promise = this._renderCompiler.mergeProtoViewsRecursively(views);
|
||||
this._wrapWorkerPromise(data.id, promise, RenderProtoViewMergeMapping);
|
||||
this._wrapWebWorkerPromise(data.id, promise, RenderProtoViewMergeMapping);
|
||||
break;
|
||||
default:
|
||||
throw new BaseException("not implemented");
|
||||
|
@ -145,7 +145,7 @@ export class WebWorkerMain {
|
|||
this._renderer.attachFragmentAfterFragment(previousFragment, fragment);
|
||||
break;
|
||||
case "attachFragmentAfterElement":
|
||||
var element = this._serializer.deserialize(args[0], WorkerElementRef);
|
||||
var element = this._serializer.deserialize(args[0], WebWorkerElementRef);
|
||||
var fragment = this._serializer.deserialize(args[1], RenderFragmentRef);
|
||||
this._renderer.attachFragmentAfterElement(element, fragment);
|
||||
break;
|
||||
|
@ -168,31 +168,31 @@ export class WebWorkerMain {
|
|||
this._renderer.setText(viewRef, textNodeIndex, text);
|
||||
break;
|
||||
case "setElementProperty":
|
||||
var elementRef = this._serializer.deserialize(args[0], WorkerElementRef);
|
||||
var elementRef = this._serializer.deserialize(args[0], WebWorkerElementRef);
|
||||
var propName = args[1];
|
||||
var propValue = args[2];
|
||||
this._renderer.setElementProperty(elementRef, propName, propValue);
|
||||
break;
|
||||
case "setElementAttribute":
|
||||
var elementRef = this._serializer.deserialize(args[0], WorkerElementRef);
|
||||
var elementRef = this._serializer.deserialize(args[0], WebWorkerElementRef);
|
||||
var attributeName = args[1];
|
||||
var attributeValue = args[2];
|
||||
this._renderer.setElementAttribute(elementRef, attributeName, attributeValue);
|
||||
break;
|
||||
case "setElementClass":
|
||||
var elementRef = this._serializer.deserialize(args[0], WorkerElementRef);
|
||||
var elementRef = this._serializer.deserialize(args[0], WebWorkerElementRef);
|
||||
var className = args[1];
|
||||
var isAdd = args[2];
|
||||
this._renderer.setElementClass(elementRef, className, isAdd);
|
||||
break;
|
||||
case "setElementStyle":
|
||||
var elementRef = this._serializer.deserialize(args[0], WorkerElementRef);
|
||||
var elementRef = this._serializer.deserialize(args[0], WebWorkerElementRef);
|
||||
var styleName = args[1];
|
||||
var styleValue = args[2];
|
||||
this._renderer.setElementStyle(elementRef, styleName, styleValue);
|
||||
break;
|
||||
case "invokeElementMethod":
|
||||
var elementRef = this._serializer.deserialize(args[0], WorkerElementRef);
|
||||
var elementRef = this._serializer.deserialize(args[0], WebWorkerElementRef);
|
||||
var methodName = args[1];
|
||||
var methodArgs = args[2];
|
||||
this._renderer.invokeElementMethod(elementRef, methodName, methodArgs);
|
||||
|
@ -208,7 +208,7 @@ export class WebWorkerMain {
|
|||
}
|
||||
|
||||
// TODO(jteplitz602): Create message type enum #3044
|
||||
private _handleWorkerMessage(message: StringMap<string, any>) {
|
||||
private _handleWebWorkerMessage(message: StringMap<string, any>) {
|
||||
var data: ReceivedMessage = new ReceivedMessage(message['data']);
|
||||
switch (data.type) {
|
||||
case "ready":
|
||||
|
@ -220,14 +220,14 @@ export class WebWorkerMain {
|
|||
}
|
||||
}
|
||||
|
||||
private _wrapWorkerPromise(id: string, promise: Promise<any>, type: Type): void {
|
||||
private _wrapWebWorkerPromise(id: string, promise: Promise<any>, type: Type): void {
|
||||
PromiseWrapper.then(promise, (result: any) => {
|
||||
try {
|
||||
this._sendWorkerMessage("result", this._serializer.serialize(result, type), id);
|
||||
this._sendWebWorkerMessage("result", this._serializer.serialize(result, type), id);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}, (error: any) => { this._sendWorkerError(id, error); });
|
||||
}, (error: any) => { this._sendWebWorkerError(id, error); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ library angular2.src.web_workers.worker;
|
|||
import "package:angular2/src/web-workers/shared/message_bus.dart"
|
||||
show MessageBus, MessageBusSource, MessageBusSink;
|
||||
import "package:angular2/src/web-workers/worker/application_common.dart"
|
||||
show bootstrapWebworkerCommon;
|
||||
show bootstrapWebWorkerCommon;
|
||||
import "package:angular2/src/facade/async.dart" show Future;
|
||||
import "package:angular2/src/core/application.dart" show ApplicationRef;
|
||||
import "package:angular2/src/facade/lang.dart" show Type, BaseException;
|
||||
|
@ -22,30 +22,30 @@ import 'dart:core';
|
|||
* bootstrap() in a regular Angular application
|
||||
* See the bootstrap() docs for more details.
|
||||
*/
|
||||
Future<ApplicationRef> bootstrapWebworker(
|
||||
Future<ApplicationRef> bootstrapWebWorker(
|
||||
SendPort replyTo, Type appComponentType,
|
||||
[List<dynamic> componentInjectableBindings = null]) {
|
||||
ReceivePort rPort = new ReceivePort();
|
||||
WorkerMessageBus bus = new WorkerMessageBus.fromPorts(replyTo, rPort);
|
||||
return bootstrapWebworkerCommon(
|
||||
WebWorkerMessageBus bus = new WebWorkerMessageBus.fromPorts(replyTo, rPort);
|
||||
return bootstrapWebWorkerCommon(
|
||||
appComponentType, bus, componentInjectableBindings);
|
||||
}
|
||||
|
||||
class WorkerMessageBus extends MessageBus {
|
||||
final WorkerMessageBusSink sink;
|
||||
final WorkerMessageBusSource source;
|
||||
class WebWorkerMessageBus extends MessageBus {
|
||||
final WebWorkerMessageBusSink sink;
|
||||
final WebWorkerMessageBusSource source;
|
||||
|
||||
WorkerMessageBus(this.sink, this.source);
|
||||
WebWorkerMessageBus(this.sink, this.source);
|
||||
|
||||
WorkerMessageBus.fromPorts(SendPort sPort, ReceivePort rPort)
|
||||
: sink = new WorkerMessageBusSink(sPort, rPort),
|
||||
source = new WorkerMessageBusSource(rPort);
|
||||
WebWorkerMessageBus.fromPorts(SendPort sPort, ReceivePort rPort)
|
||||
: sink = new WebWorkerMessageBusSink(sPort, rPort),
|
||||
source = new WebWorkerMessageBusSource(rPort);
|
||||
}
|
||||
|
||||
class WorkerMessageBusSink extends MessageBusSink {
|
||||
class WebWorkerMessageBusSink extends MessageBusSink {
|
||||
final SendPort _port;
|
||||
|
||||
WorkerMessageBusSink(SendPort sPort, ReceivePort rPort) : _port = sPort {
|
||||
WebWorkerMessageBusSink(SendPort sPort, ReceivePort rPort) : _port = sPort {
|
||||
this.send(rPort.sendPort);
|
||||
}
|
||||
|
||||
|
@ -54,14 +54,14 @@ class WorkerMessageBusSink extends MessageBusSink {
|
|||
}
|
||||
}
|
||||
|
||||
class WorkerMessageBusSource extends MessageBusSource {
|
||||
class WebWorkerMessageBusSource extends MessageBusSource {
|
||||
final ReceivePort _port;
|
||||
final Stream rawDataStream;
|
||||
Map<int, StreamSubscription> _listenerStore =
|
||||
new Map<int, StreamSubscription>();
|
||||
int _numListeners = 0;
|
||||
|
||||
WorkerMessageBusSource(ReceivePort rPort)
|
||||
WebWorkerMessageBusSource(ReceivePort rPort)
|
||||
: _port = rPort,
|
||||
rawDataStream = rPort.asBroadcastStream();
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
import {Type, BaseException} from "angular2/src/facade/lang";
|
||||
import {Binding} from "angular2/di";
|
||||
|
||||
import {bootstrapWebworkerCommon} from "angular2/src/web-workers/worker/application_common";
|
||||
import {bootstrapWebWorkerCommon} from "angular2/src/web-workers/worker/application_common";
|
||||
import {ApplicationRef} from "angular2/src/core/application";
|
||||
import {Injectable} from "angular2/di";
|
||||
|
||||
|
@ -23,31 +23,31 @@ var _postMessage: (message: any, transferrables?:[ArrayBuffer]) => void = <any>p
|
|||
* application
|
||||
* See the bootstrap() docs for more details.
|
||||
*/
|
||||
export function bootstrapWebworker(
|
||||
export function bootstrapWebWorker(
|
||||
appComponentType: Type, componentInjectableBindings: List<Type | Binding | List<any>> = null):
|
||||
Promise<ApplicationRef> {
|
||||
var bus: WorkerMessageBus =
|
||||
new WorkerMessageBus(new WorkerMessageBusSink(), new WorkerMessageBusSource());
|
||||
var bus: WebWorkerMessageBus =
|
||||
new WebWorkerMessageBus(new WebWorkerMessageBusSink(), new WebWorkerMessageBusSource());
|
||||
|
||||
return bootstrapWebworkerCommon(appComponentType, bus, componentInjectableBindings);
|
||||
return bootstrapWebWorkerCommon(appComponentType, bus, componentInjectableBindings);
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class WorkerMessageBus implements MessageBus {
|
||||
sink: WorkerMessageBusSink;
|
||||
source: WorkerMessageBusSource;
|
||||
export class WebWorkerMessageBus implements MessageBus {
|
||||
sink: WebWorkerMessageBusSink;
|
||||
source: WebWorkerMessageBusSource;
|
||||
|
||||
constructor(sink: WorkerMessageBusSink, source: WorkerMessageBusSource) {
|
||||
constructor(sink: WebWorkerMessageBusSink, source: WebWorkerMessageBusSource) {
|
||||
this.sink = sink;
|
||||
this.source = source;
|
||||
}
|
||||
}
|
||||
|
||||
export class WorkerMessageBusSink implements MessageBusSink {
|
||||
export class WebWorkerMessageBusSink implements MessageBusSink {
|
||||
public send(message: Object) { _postMessage(message); }
|
||||
}
|
||||
|
||||
export class WorkerMessageBusSource implements MessageBusSource {
|
||||
export class WebWorkerMessageBusSource implements MessageBusSource {
|
||||
private listenerStore: Map<int, SourceListener>;
|
||||
private numListeners: int;
|
||||
|
||||
|
|
|
@ -48,12 +48,12 @@ import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
|
|||
import {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils';
|
||||
import {AppViewListener} from 'angular2/src/core/compiler/view_listener';
|
||||
import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
|
||||
import {WorkerRenderer, WorkerCompiler} from './renderer';
|
||||
import {WebWorkerRenderer, WebWorkerCompiler} from './renderer';
|
||||
import {Renderer, RenderCompiler} from 'angular2/src/render/api';
|
||||
import {internalView} from 'angular2/src/core/compiler/view_ref';
|
||||
|
||||
import {MessageBroker} from 'angular2/src/web-workers/worker/broker';
|
||||
import {WorkerMessageBus} from 'angular2/src/web-workers/worker/application';
|
||||
import {WebWorkerMessageBus} from 'angular2/src/web-workers/worker/application';
|
||||
import {
|
||||
appComponentRefPromiseToken,
|
||||
appComponentTypeToken
|
||||
|
@ -61,7 +61,7 @@ import {
|
|||
import {ApplicationRef} from 'angular2/src/core/application';
|
||||
import {createNgZone} from 'angular2/src/core/application_common';
|
||||
import {Serializer} from "angular2/src/web-workers/shared/serializer";
|
||||
import {ON_WEBWORKER} from "angular2/src/web-workers/shared/api";
|
||||
import {ON_WEB_WORKER} from "angular2/src/web-workers/shared/api";
|
||||
import {RenderProtoViewRefStore} from 'angular2/src/web-workers/shared/render_proto_view_ref_store';
|
||||
import {
|
||||
RenderViewWithFragmentsStore
|
||||
|
@ -78,7 +78,7 @@ class PrintLogger {
|
|||
logGroupEnd() {}
|
||||
}
|
||||
|
||||
function _injectorBindings(appComponentType, bus: WorkerMessageBus,
|
||||
function _injectorBindings(appComponentType, bus: WebWorkerMessageBus,
|
||||
initData: StringMap<string, any>): List<Type | Binding | List<any>> {
|
||||
var bestChangeDetection: Type = DynamicChangeDetection;
|
||||
if (PreGeneratedChangeDetection.isSupported()) {
|
||||
|
@ -103,14 +103,15 @@ function _injectorBindings(appComponentType, bus: WorkerMessageBus,
|
|||
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()),
|
||||
[ExceptionHandler]),
|
||||
Serializer,
|
||||
bind(WorkerMessageBus).toValue(bus),
|
||||
bind(WebWorkerMessageBus).toValue(bus),
|
||||
bind(MessageBroker)
|
||||
.toFactory((a, b, c) => new MessageBroker(a, b, c), [WorkerMessageBus, Serializer, NgZone]),
|
||||
WorkerRenderer,
|
||||
bind(Renderer).toAlias(WorkerRenderer),
|
||||
WorkerCompiler,
|
||||
bind(RenderCompiler).toAlias(WorkerCompiler),
|
||||
bind(ON_WEBWORKER).toValue(true),
|
||||
.toFactory((a, b, c) => new MessageBroker(a, b, c),
|
||||
[WebWorkerMessageBus, Serializer, NgZone]),
|
||||
WebWorkerRenderer,
|
||||
bind(Renderer).toAlias(WebWorkerRenderer),
|
||||
WebWorkerCompiler,
|
||||
bind(RenderCompiler).toAlias(WebWorkerCompiler),
|
||||
bind(ON_WEB_WORKER).toValue(true),
|
||||
RenderViewWithFragmentsStore,
|
||||
RenderProtoViewRefStore,
|
||||
ProtoViewFactory,
|
||||
|
@ -140,8 +141,8 @@ function _injectorBindings(appComponentType, bus: WorkerMessageBus,
|
|||
];
|
||||
}
|
||||
|
||||
export function bootstrapWebworkerCommon(
|
||||
appComponentType: Type, bus: WorkerMessageBus,
|
||||
export function bootstrapWebWorkerCommon(
|
||||
appComponentType: Type, bus: WebWorkerMessageBus,
|
||||
componentInjectableBindings: List<Type | Binding | List<any>> = null): Promise<ApplicationRef> {
|
||||
var bootstrapProcess: PromiseCompleter<any> = PromiseWrapper.completer();
|
||||
|
||||
|
@ -188,8 +189,8 @@ export function bootstrapWebworkerCommon(
|
|||
}
|
||||
|
||||
function _createAppInjector(appComponentType: Type, bindings: List<Type | Binding | List<any>>,
|
||||
zone: NgZone, bus: WorkerMessageBus, initData: StringMap<string, any>):
|
||||
Injector {
|
||||
zone: NgZone, bus: WebWorkerMessageBus,
|
||||
initData: StringMap<string, any>): Injector {
|
||||
if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings);
|
||||
var mergedBindings: any[] =
|
||||
isPresent(bindings) ?
|
||||
|
@ -197,4 +198,4 @@ function _createAppInjector(appComponentType: Type, bindings: List<Type | Bindin
|
|||
_injectorBindings(appComponentType, bus, initData);
|
||||
mergedBindings.push(bind(NgZone).toValue(zone));
|
||||
return _rootInjector.resolveAndCreateChild(mergedBindings);
|
||||
}
|
||||
}
|
|
@ -18,12 +18,12 @@ import {isPresent, print, BaseException} from "angular2/src/facade/lang";
|
|||
import {Injectable} from "angular2/di";
|
||||
import {
|
||||
RenderViewWithFragmentsStore,
|
||||
WorkerRenderViewRef
|
||||
WebWorkerRenderViewRef
|
||||
} from 'angular2/src/web-workers/shared/render_view_with_fragments_store';
|
||||
import {WorkerElementRef} from 'angular2/src/web-workers/shared/api';
|
||||
import {WebWorkerElementRef} from 'angular2/src/web-workers/shared/api';
|
||||
|
||||
@Injectable()
|
||||
export class WorkerCompiler implements RenderCompiler {
|
||||
export class WebWorkerCompiler implements RenderCompiler {
|
||||
constructor(private _messageBroker: MessageBroker) {}
|
||||
/**
|
||||
* Creats a ProtoViewDto that contains a single nested component with the given componentId.
|
||||
|
@ -64,7 +64,7 @@ export class WorkerCompiler implements RenderCompiler {
|
|||
|
||||
|
||||
@Injectable()
|
||||
export class WorkerRenderer implements Renderer {
|
||||
export class WebWorkerRenderer implements Renderer {
|
||||
constructor(private _messageBroker: MessageBroker,
|
||||
private _renderViewStore: RenderViewWithFragmentsStore) {}
|
||||
/**
|
||||
|
@ -96,7 +96,7 @@ export class WorkerRenderer implements Renderer {
|
|||
hostElementSelector?: string): RenderViewWithFragments {
|
||||
var renderViewWithFragments = this._renderViewStore.allocate(fragmentCount);
|
||||
|
||||
var startIndex = (<WorkerRenderViewRef>(renderViewWithFragments.viewRef)).refNumber;
|
||||
var startIndex = (<WebWorkerRenderViewRef>(renderViewWithFragments.viewRef)).refNumber;
|
||||
var fnArgs: List<FnArg> = [
|
||||
new FnArg(protoViewRef, RenderProtoViewRef),
|
||||
new FnArg(fragmentCount, null),
|
||||
|
@ -141,7 +141,7 @@ export class WorkerRenderer implements Renderer {
|
|||
*/
|
||||
attachFragmentAfterElement(elementRef: RenderElementRef, fragmentRef: RenderFragmentRef) {
|
||||
var fnArgs =
|
||||
[new FnArg(elementRef, WorkerElementRef), new FnArg(fragmentRef, RenderFragmentRef)];
|
||||
[new FnArg(elementRef, WebWorkerElementRef), new FnArg(fragmentRef, RenderFragmentRef)];
|
||||
var args = new UiArguments("renderer", "attachFragmentAfterElement", fnArgs);
|
||||
this._messageBroker.runOnUiThread(args, null);
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ export class WorkerRenderer implements Renderer {
|
|||
*/
|
||||
setElementProperty(location: RenderElementRef, propertyName: string, propertyValue: any) {
|
||||
var fnArgs = [
|
||||
new FnArg(location, WorkerElementRef),
|
||||
new FnArg(location, WebWorkerElementRef),
|
||||
new FnArg(propertyName, null),
|
||||
new FnArg(propertyValue, null)
|
||||
];
|
||||
|
@ -199,7 +199,7 @@ export class WorkerRenderer implements Renderer {
|
|||
*/
|
||||
setElementAttribute(location: RenderElementRef, attributeName: string, attributeValue: string) {
|
||||
var fnArgs = [
|
||||
new FnArg(location, WorkerElementRef),
|
||||
new FnArg(location, WebWorkerElementRef),
|
||||
new FnArg(attributeName, null),
|
||||
new FnArg(attributeValue, null)
|
||||
];
|
||||
|
@ -211,8 +211,11 @@ export class WorkerRenderer implements Renderer {
|
|||
* Sets a class on an element.
|
||||
*/
|
||||
setElementClass(location: RenderElementRef, className: string, isAdd: boolean) {
|
||||
var fnArgs =
|
||||
[new FnArg(location, WorkerElementRef), new FnArg(className, null), new FnArg(isAdd, null)];
|
||||
var fnArgs = [
|
||||
new FnArg(location, WebWorkerElementRef),
|
||||
new FnArg(className, null),
|
||||
new FnArg(isAdd, null)
|
||||
];
|
||||
var args = new UiArguments("renderer", "setElementClass", fnArgs);
|
||||
this._messageBroker.runOnUiThread(args, null);
|
||||
}
|
||||
|
@ -222,7 +225,7 @@ export class WorkerRenderer implements Renderer {
|
|||
*/
|
||||
setElementStyle(location: RenderElementRef, styleName: string, styleValue: string) {
|
||||
var fnArgs = [
|
||||
new FnArg(location, WorkerElementRef),
|
||||
new FnArg(location, WebWorkerElementRef),
|
||||
new FnArg(styleName, null),
|
||||
new FnArg(styleValue, null)
|
||||
];
|
||||
|
@ -235,8 +238,11 @@ export class WorkerRenderer implements Renderer {
|
|||
* Note: For now we're assuming that everything in the args list are primitive
|
||||
*/
|
||||
invokeElementMethod(location: RenderElementRef, methodName: string, args: List<any>) {
|
||||
var fnArgs =
|
||||
[new FnArg(location, WorkerElementRef), new FnArg(methodName, null), new FnArg(args, null)];
|
||||
var fnArgs = [
|
||||
new FnArg(location, WebWorkerElementRef),
|
||||
new FnArg(methodName, null),
|
||||
new FnArg(args, null)
|
||||
];
|
||||
var uiArgs = new UiArguments("renderer", "invokeElementMethod", fnArgs);
|
||||
this._messageBroker.runOnUiThread(uiArgs, null);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ import {AsyncTestCompleter, beforeEach, inject, describe, it, expect} from "angu
|
|||
import {RenderViewWithFragments, RenderViewRef, RenderFragmentRef} from "angular2/src/render/api";
|
||||
import {
|
||||
RenderViewWithFragmentsStore,
|
||||
WorkerRenderViewRef,
|
||||
WorkerRenderFragmentRef
|
||||
WebWorkerRenderViewRef,
|
||||
WebWorkerRenderFragmentRef
|
||||
} from "angular2/src/web-workers/shared/render_view_with_fragments_store";
|
||||
import {List, ListWrapper} from "angular2/src/facade/collection";
|
||||
|
||||
|
@ -16,11 +16,11 @@ export function main() {
|
|||
it("should allocate fragmentCount + 1 refs", () => {
|
||||
var view: RenderViewWithFragments = store.allocate(10);
|
||||
|
||||
var viewRef: WorkerRenderViewRef = <WorkerRenderViewRef>view.viewRef;
|
||||
var viewRef: WebWorkerRenderViewRef = <WebWorkerRenderViewRef>view.viewRef;
|
||||
expect(viewRef.refNumber).toEqual(0);
|
||||
|
||||
var fragmentRefs: List<WorkerRenderFragmentRef> =
|
||||
<List<WorkerRenderFragmentRef>>view.fragmentRefs;
|
||||
var fragmentRefs: List<WebWorkerRenderFragmentRef> =
|
||||
<List<WebWorkerRenderFragmentRef>>view.fragmentRefs;
|
||||
expect(fragmentRefs.length).toEqual(10);
|
||||
|
||||
for (var i = 0; i < fragmentRefs.length; i++) {
|
||||
|
@ -31,7 +31,7 @@ export function main() {
|
|||
it("should not reuse a reference", () => {
|
||||
store.allocate(10);
|
||||
var view = store.allocate(0);
|
||||
var viewRef = <WorkerRenderViewRef>view.viewRef;
|
||||
var viewRef = <WebWorkerRenderViewRef>view.viewRef;
|
||||
expect(viewRef.refNumber).toEqual(11);
|
||||
});
|
||||
|
||||
|
|
|
@ -15,19 +15,19 @@ import {Serializer} from 'angular2/src/web-workers/shared/serializer';
|
|||
import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
||||
import {MessageBroker} from 'angular2/src/web-workers/worker/broker';
|
||||
import {MockMessageBus, MockMessageBusSink, MockMessageBusSource} from './worker_test_util';
|
||||
import {ON_WEBWORKER} from 'angular2/src/web-workers/shared/api';
|
||||
import {ON_WEB_WORKER} from 'angular2/src/web-workers/shared/api';
|
||||
import {bind} from 'angular2/di';
|
||||
import {RenderProtoViewRefStore} from 'angular2/src/web-workers/shared/render_proto_view_ref_store';
|
||||
import {
|
||||
RenderViewWithFragmentsStore,
|
||||
WorkerRenderViewRef
|
||||
WebWorkerRenderViewRef
|
||||
} from 'angular2/src/web-workers/shared/render_view_with_fragments_store';
|
||||
import {RenderEventDispatcher, RenderViewRef} from 'angular2/src/render/api';
|
||||
|
||||
export function main() {
|
||||
describe("MessageBroker", () => {
|
||||
beforeEachBindings(() => [
|
||||
bind(ON_WEBWORKER)
|
||||
bind(ON_WEB_WORKER)
|
||||
.toValue(true),
|
||||
RenderProtoViewRefStore,
|
||||
RenderViewWithFragmentsStore
|
||||
|
@ -38,7 +38,7 @@ export function main() {
|
|||
var broker = new MessageBroker(bus, serializer, zone);
|
||||
|
||||
var eventDispatcher = new SpyEventDispatcher();
|
||||
var viewRef = new WorkerRenderViewRef(0);
|
||||
var viewRef = new WebWorkerRenderViewRef(0);
|
||||
serializer.allocateRenderViews(0); // serialize the ref so it's in the store
|
||||
viewRef =
|
||||
serializer.deserialize(serializer.serialize(viewRef, RenderViewRef), RenderViewRef);
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {DomTestbed, TestRootView, elRef} from '../../render/dom/dom_testbed';
|
||||
import {bind} from 'angular2/di';
|
||||
import {WorkerCompiler, WorkerRenderer} from "angular2/src/web-workers/worker/renderer";
|
||||
import {WebWorkerCompiler, WebWorkerRenderer} from "angular2/src/web-workers/worker/renderer";
|
||||
import {MessageBroker, UiArguments, FnArg} from "angular2/src/web-workers/worker/broker";
|
||||
import {Serializer} from "angular2/src/web-workers/shared/serializer";
|
||||
import {isPresent, isBlank, BaseException, Type} from "angular2/src/facade/lang";
|
||||
|
@ -28,11 +28,11 @@ import {
|
|||
} from "angular2/src/render/api";
|
||||
import {
|
||||
RenderProtoViewRefStore,
|
||||
WebworkerRenderProtoViewRef
|
||||
WebWorkerRenderProtoViewRef
|
||||
} from "angular2/src/web-workers/shared/render_proto_view_ref_store";
|
||||
import {
|
||||
RenderViewWithFragmentsStore,
|
||||
WorkerRenderViewRef
|
||||
WebWorkerRenderViewRef
|
||||
} from 'angular2/src/web-workers/shared/render_view_with_fragments_store';
|
||||
import {resolveInternalDomProtoView, DomProtoView} from 'angular2/src/render/dom/view/proto_view';
|
||||
import {someComponent} from '../../render/dom/dom_renderer_integration_spec';
|
||||
|
@ -56,23 +56,23 @@ export function main() {
|
|||
// set up the ui side
|
||||
var webWorkerMain = new WebWorkerMain(tb.compiler, tb.renderer, uiRenderViewStore, uiSerializer,
|
||||
new AnchorBasedAppRootUrl());
|
||||
webWorkerMain.attachToWorker(uiMessageBus);
|
||||
webWorkerMain.attachToWebWorker(uiMessageBus);
|
||||
return broker;
|
||||
}
|
||||
|
||||
function createWorkerRenderer(workerSerializer: Serializer, uiSerializer: Serializer,
|
||||
tb: DomTestbed, uiRenderViewStore: RenderViewWithFragmentsStore,
|
||||
workerRenderViewStore: RenderViewWithFragmentsStore):
|
||||
WorkerRenderer {
|
||||
WebWorkerRenderer {
|
||||
var broker =
|
||||
createBroker(workerSerializer, uiSerializer, tb, uiRenderViewStore, workerRenderViewStore);
|
||||
return new WorkerRenderer(broker, workerRenderViewStore);
|
||||
return new WebWorkerRenderer(broker, workerRenderViewStore);
|
||||
}
|
||||
|
||||
function createWorkerCompiler(workerSerializer: Serializer, uiSerializer: Serializer,
|
||||
tb: DomTestbed): WorkerCompiler {
|
||||
tb: DomTestbed): WebWorkerCompiler {
|
||||
var broker = createBroker(workerSerializer, uiSerializer, tb, null, null);
|
||||
return new WorkerCompiler(broker);
|
||||
return new WebWorkerCompiler(broker);
|
||||
}
|
||||
|
||||
describe("Web Worker Compiler", function() {
|
||||
|
@ -91,12 +91,12 @@ export function main() {
|
|||
});
|
||||
|
||||
function resolveWebWorkerRef(ref: RenderProtoViewRef) {
|
||||
var refNumber = (<WebworkerRenderProtoViewRef>ref).refNumber;
|
||||
var refNumber = (<WebWorkerRenderProtoViewRef>ref).refNumber;
|
||||
return resolveInternalDomProtoView(uiRenderProtoViewRefStore.deserialize(refNumber));
|
||||
}
|
||||
|
||||
it('should build the proto view', inject([AsyncTestCompleter], (async) => {
|
||||
var compiler: WorkerCompiler = createWorkerCompiler(workerSerializer, uiSerializer, tb);
|
||||
var compiler: WebWorkerCompiler = createWorkerCompiler(workerSerializer, uiSerializer, tb);
|
||||
|
||||
var dirMetadata = DirectiveMetadata.create(
|
||||
{id: 'id', selector: 'custom', type: DirectiveMetadata.COMPONENT_TYPE});
|
||||
|
@ -113,7 +113,7 @@ export function main() {
|
|||
});
|
||||
|
||||
describe("Web Worker Renderer", () => {
|
||||
var renderer: WorkerRenderer;
|
||||
var renderer: WebWorkerRenderer;
|
||||
var workerSerializer: Serializer;
|
||||
var workerRenderViewStore: RenderViewWithFragmentsStore;
|
||||
var uiRenderViewStore: RenderViewWithFragmentsStore;
|
||||
|
@ -291,7 +291,7 @@ class WorkerTestRootView extends TestRootView {
|
|||
constructor(workerViewWithFragments: RenderViewWithFragments, uiRenderViewStore) {
|
||||
super(new RenderViewWithFragments(
|
||||
uiRenderViewStore.retreive(
|
||||
(<WorkerRenderViewRef>workerViewWithFragments.viewRef).refNumber),
|
||||
(<WebWorkerRenderViewRef>workerViewWithFragments.viewRef).refNumber),
|
||||
ListWrapper.map(workerViewWithFragments.fragmentRefs,
|
||||
(val) => { return uiRenderViewStore.retreive(val.refNumber); })));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
library angular2.examples.message_broker.background_index;
|
||||
|
||||
import "package:angular2/src/web-workers/worker/application.dart"
|
||||
show WorkerMessageBus, WorkerMessageBusSource, WorkerMessageBusSink;
|
||||
show WebWorkerMessageBus;
|
||||
import "package:angular2/src/web-workers/worker/broker.dart"
|
||||
show MessageBroker, UiArguments;
|
||||
import "package:angular2/src/web-workers/shared/serializer.dart"
|
||||
|
@ -11,7 +11,7 @@ import "dart:isolate";
|
|||
|
||||
main(List<String> args, SendPort replyTo) {
|
||||
ReceivePort rPort = new ReceivePort();
|
||||
WorkerMessageBus bus = new WorkerMessageBus.fromPorts(replyTo, rPort);
|
||||
WebWorkerMessageBus bus = new WebWorkerMessageBus.fromPorts(replyTo, rPort);
|
||||
bus.source.addListener((message) {
|
||||
if (identical(message['data']['type'], "echo")) {
|
||||
bus.sink
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import {
|
||||
WorkerMessageBus,
|
||||
WorkerMessageBusSource,
|
||||
WorkerMessageBusSink
|
||||
WebWorkerMessageBus,
|
||||
WebWorkerMessageBusSource,
|
||||
WebWorkerMessageBusSink
|
||||
} from "angular2/src/web-workers/worker/application";
|
||||
import {MessageBroker, UiArguments} from "angular2/src/web-workers/worker/broker";
|
||||
import {Serializer} from "angular2/src/web-workers/shared/serializer";
|
||||
|
||||
export function main() {
|
||||
var bus = new WorkerMessageBus(new WorkerMessageBusSink(), new WorkerMessageBusSource());
|
||||
var bus = new WebWorkerMessageBus(new WebWorkerMessageBusSink(), new WebWorkerMessageBusSource());
|
||||
bus.source.addListener((message) => {
|
||||
if (message.data.type === "echo") {
|
||||
bus.sink.send({type: "echo_response", 'value': message.data.value});
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
library angular2.examples.message_broker.index;
|
||||
|
||||
import "package:angular2/src/web-workers/ui/application.dart"
|
||||
show spawnWorker, UIMessageBus, UIMessageBusSink, UIMessageBusSource;
|
||||
show spawnWebWorker, UIMessageBus, UIMessageBusSink, UIMessageBusSource;
|
||||
|
||||
import "dart:html";
|
||||
|
||||
main() {
|
||||
var VALUE = 5;
|
||||
spawnWorker(Uri.parse("background_index.dart")).then((bus) {
|
||||
spawnWebWorker(Uri.parse("background_index.dart")).then((bus) {
|
||||
querySelector("#send_echo").addEventListener("click", (e) {
|
||||
var val = (querySelector("#echo_input") as InputElement).value;
|
||||
bus.sink.send({'type': 'echo', 'value': val});
|
||||
|
|
|
@ -3,11 +3,11 @@ library examples.src.web_workers.images.background_index;
|
|||
import "index_common.dart" show ImageDemo;
|
||||
import "dart:isolate";
|
||||
import "package:angular2/src/web-workers/worker/application.dart"
|
||||
show bootstrapWebworker;
|
||||
show bootstrapWebWorker;
|
||||
import "package:angular2/src/reflection/reflection_capabilities.dart";
|
||||
import "package:angular2/src/reflection/reflection.dart";
|
||||
|
||||
main(List<String> args, SendPort replyTo) {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
bootstrapWebworker(replyTo, ImageDemo).catchError((error) => throw error);
|
||||
bootstrapWebWorker(replyTo, ImageDemo).catchError((error) => throw error);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {bootstrapWebworker} from "angular2/src/web-workers/worker/application";
|
||||
import {bootstrapWebWorker} from "angular2/src/web-workers/worker/application";
|
||||
import {ImageDemo} from "./index_common";
|
||||
|
||||
export function main() {
|
||||
bootstrapWebworker(ImageDemo);
|
||||
bootstrapWebWorker(ImageDemo);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ library examples.src.web_workers.kitchen_sink.background_index;
|
|||
import "index_common.dart" show HelloCmp;
|
||||
import "dart:isolate";
|
||||
import "package:angular2/src/web-workers/worker/application.dart"
|
||||
show bootstrapWebworker;
|
||||
show bootstrapWebWorker;
|
||||
import "package:angular2/src/reflection/reflection_capabilities.dart";
|
||||
import "package:angular2/src/reflection/reflection.dart";
|
||||
|
||||
main(List<String> args, SendPort replyTo) {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
bootstrapWebworker(replyTo, HelloCmp).catchError((error) => throw error);
|
||||
bootstrapWebWorker(replyTo, HelloCmp).catchError((error) => throw error);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {HelloCmp} from "./index_common";
|
||||
import {bootstrapWebworker} from "angular2/src/web-workers/worker/application";
|
||||
import {bootstrapWebWorker} from "angular2/src/web-workers/worker/application";
|
||||
|
||||
export function main() {
|
||||
bootstrapWebworker(HelloCmp);
|
||||
bootstrapWebWorker(HelloCmp);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ library examples.src.web_workers.todo.background_index;
|
|||
import "index_common.dart" show TodoApp;
|
||||
import "dart:isolate";
|
||||
import "package:angular2/src/web-workers/worker/application.dart"
|
||||
show bootstrapWebworker;
|
||||
show bootstrapWebWorker;
|
||||
import "package:angular2/src/reflection/reflection_capabilities.dart";
|
||||
import "package:angular2/src/reflection/reflection.dart";
|
||||
|
||||
main(List<String> args, SendPort replyTo) {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
bootstrapWebworker(replyTo, TodoApp).catchError((error) => throw error);
|
||||
bootstrapWebWorker(replyTo, TodoApp).catchError((error) => throw error);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {bootstrapWebworker} from "angular2/src/web-workers/worker/application";
|
||||
import {bootstrapWebWorker} from "angular2/src/web-workers/worker/application";
|
||||
import {TodoApp} from "./index_common";
|
||||
|
||||
export function main() {
|
||||
bootstrapWebworker(TodoApp);
|
||||
bootstrapWebWorker(TodoApp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue