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