diff --git a/modules/angular2/src/web-workers/shared/api.ts b/modules/angular2/src/web-workers/shared/api.ts index 0658e2d9ab..54b619e8ca 100644 --- a/modules/angular2/src/web-workers/shared/api.ts +++ b/modules/angular2/src/web-workers/shared/api.ts @@ -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) {} } diff --git a/modules/angular2/src/web-workers/shared/message_bus.ts b/modules/angular2/src/web-workers/shared/message_bus.ts index e14278622e..8f40e76732 100644 --- a/modules/angular2/src/web-workers/shared/message_bus.ts +++ b/modules/angular2/src/web-workers/shared/message_bus.ts @@ -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); diff --git a/modules/angular2/src/web-workers/shared/render_proto_view_ref_store.ts b/modules/angular2/src/web-workers/shared/render_proto_view_ref_store.ts index 5accac9c7a..ef46bc0dcf 100644 --- a/modules/angular2/src/web-workers/shared/render_proto_view_ref_store.ts +++ b/modules/angular2/src/web-workers/shared/render_proto_view_ref_store.ts @@ -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 (ref).refNumber; + return (ref).refNumber; } else { return this.storeRenderProtoViewRef(ref); } } } -export class WebworkerRenderProtoViewRef extends RenderProtoViewRef { +export class WebWorkerRenderProtoViewRef extends RenderProtoViewRef { constructor(public refNumber: number) { super(); } } diff --git a/modules/angular2/src/web-workers/shared/render_view_with_fragments_store.ts b/modules/angular2/src/web-workers/shared/render_view_with_fragments_store.ts index 62f829e131..a7d7ef48d6 100644 --- a/modules/angular2/src/web-workers/shared/render_view_with_fragments_store.ts +++ b/modules/angular2/src/web-workers/shared/render_view_with_fragments_store.ts @@ -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; private _lookupByView: Map; - constructor(@Inject(ON_WEBWORKER) onWebWorker) { + constructor(@Inject(ON_WEB_WORKER) onWebWorker) { this._onWebWorker = onWebWorker; this._lookupByIndex = new Map(); this._lookupByView = new Map(); @@ -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 (ref).serialize(); + return (ref).serialize(); } else { return this._lookupByView.get(ref); } @@ -92,7 +92,7 @@ export class RenderViewWithFragmentsStore { if (this._onWebWorker) { return { - 'viewRef': (view.viewRef).serialize(), + 'viewRef': (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); } } diff --git a/modules/angular2/src/web-workers/shared/serializer.ts b/modules/angular2/src/web-workers/shared/serializer.ts index 5767649f4f..0c472d4195 100644 --- a/modules/angular2/src/web-workers/shared/serializer.ts +++ b/modules/angular2/src/web-workers/shared/serializer.ts @@ -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): 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 { diff --git a/modules/angular2/src/web-workers/ui/application.dart b/modules/angular2/src/web-workers/ui/application.dart index dacb314f5a..595540e22d 100644 --- a/modules/angular2/src/web-workers/ui/application.dart +++ b/modules/angular2/src/web-workers/ui/application.dart @@ -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 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 bootstrap(String uri) { /** * To be called from the main thread to spawn and communicate with the worker thread */ -Future spawnWorker(Uri uri) { +Future spawnWebWorker(Uri uri) { var receivePort = new ReceivePort(); var isolateEndSendPort = receivePort.sendPort; return Isolate.spawnUri(uri, const [], isolateEndSendPort).then((_) { diff --git a/modules/angular2/src/web-workers/ui/application.ts b/modules/angular2/src/web-workers/ui/application.ts index 8f230d038c..8dcfa1b30b 100644 --- a/modules/angular2/src/web-workers/ui/application.ts +++ b/modules/angular2/src/web-workers/ui/application.ts @@ -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 = new Map(); 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; } diff --git a/modules/angular2/src/web-workers/ui/di_bindings.ts b/modules/angular2/src/web-workers/ui/di_bindings.ts index f00514c71a..17f559d25f 100644 --- a/modules/angular2/src/web-workers/ui/di_bindings.ts +++ b/modules/angular2/src/web-workers/ui/di_bindings.ts @@ -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> { DomSharedStylesHost, bind(SharedStylesHost).toAlias(DomSharedStylesHost), Serializer, - bind(ON_WEBWORKER).toValue(false), + bind(ON_WEB_WORKER).toValue(false), bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()), RenderViewWithFragmentsStore, RenderProtoViewRefStore, diff --git a/modules/angular2/src/web-workers/ui/impl.ts b/modules/angular2/src/web-workers/ui/impl.ts index 3e0b10f006..490eecda17 100644 --- a/modules/angular2/src/web-workers/ui/impl.ts +++ b/modules/angular2/src/web-workers/ui/impl.ts @@ -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, id?: string) { + private _sendWebWorkerMessage(type: string, value: StringMap, 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) { + private _handleWebWorkerMessage(message: StringMap) { 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, type: Type): void { + private _wrapWebWorkerPromise(id: string, promise: Promise, 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); }); } } diff --git a/modules/angular2/src/web-workers/worker/application.dart b/modules/angular2/src/web-workers/worker/application.dart index 6130e941c5..e34bbc7150 100644 --- a/modules/angular2/src/web-workers/worker/application.dart +++ b/modules/angular2/src/web-workers/worker/application.dart @@ -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 bootstrapWebworker( +Future bootstrapWebWorker( SendPort replyTo, Type appComponentType, [List 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 _listenerStore = new Map(); int _numListeners = 0; - WorkerMessageBusSource(ReceivePort rPort) + WebWorkerMessageBusSource(ReceivePort rPort) : _port = rPort, rawDataStream = rPort.asBroadcastStream(); diff --git a/modules/angular2/src/web-workers/worker/application.ts b/modules/angular2/src/web-workers/worker/application.ts index c017191192..e0e5c302b2 100644 --- a/modules/angular2/src/web-workers/worker/application.ts +++ b/modules/angular2/src/web-workers/worker/application.ts @@ -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 = p * application * See the bootstrap() docs for more details. */ -export function bootstrapWebworker( +export function bootstrapWebWorker( appComponentType: Type, componentInjectableBindings: List> = null): Promise { - 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; private numListeners: int; diff --git a/modules/angular2/src/web-workers/worker/application_common.ts b/modules/angular2/src/web-workers/worker/application_common.ts index 6233f8e4fb..4b7f661578 100644 --- a/modules/angular2/src/web-workers/worker/application_common.ts +++ b/modules/angular2/src/web-workers/worker/application_common.ts @@ -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): List> { 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> = null): Promise { var bootstrapProcess: PromiseCompleter = PromiseWrapper.completer(); @@ -188,8 +189,8 @@ export function bootstrapWebworkerCommon( } function _createAppInjector(appComponentType: Type, bindings: List>, - zone: NgZone, bus: WorkerMessageBus, initData: StringMap): - Injector { + zone: NgZone, bus: WebWorkerMessageBus, + initData: StringMap): Injector { if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings); var mergedBindings: any[] = isPresent(bindings) ? @@ -197,4 +198,4 @@ function _createAppInjector(appComponentType: Type, bindings: List(renderViewWithFragments.viewRef)).refNumber; + var startIndex = ((renderViewWithFragments.viewRef)).refNumber; var fnArgs: List = [ 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) { - 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); } diff --git a/modules/angular2/test/web-workers/shared/render_view_with_fragments_store_spec.ts b/modules/angular2/test/web-workers/shared/render_view_with_fragments_store_spec.ts index d6c680b719..c445c02d35 100644 --- a/modules/angular2/test/web-workers/shared/render_view_with_fragments_store_spec.ts +++ b/modules/angular2/test/web-workers/shared/render_view_with_fragments_store_spec.ts @@ -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 = view.viewRef; + var viewRef: WebWorkerRenderViewRef = view.viewRef; expect(viewRef.refNumber).toEqual(0); - var fragmentRefs: List = - >view.fragmentRefs; + var fragmentRefs: List = + >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 = view.viewRef; + var viewRef = view.viewRef; expect(viewRef.refNumber).toEqual(11); }); diff --git a/modules/angular2/test/web-workers/worker/broker_spec.ts b/modules/angular2/test/web-workers/worker/broker_spec.ts index 9b68ebd5c3..55ae8149d0 100644 --- a/modules/angular2/test/web-workers/worker/broker_spec.ts +++ b/modules/angular2/test/web-workers/worker/broker_spec.ts @@ -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); diff --git a/modules/angular2/test/web-workers/worker/renderer_spec.ts b/modules/angular2/test/web-workers/worker/renderer_spec.ts index 6c8623c10e..3f5dc38ca6 100644 --- a/modules/angular2/test/web-workers/worker/renderer_spec.ts +++ b/modules/angular2/test/web-workers/worker/renderer_spec.ts @@ -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 = (ref).refNumber; + var refNumber = (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( - (workerViewWithFragments.viewRef).refNumber), + (workerViewWithFragments.viewRef).refNumber), ListWrapper.map(workerViewWithFragments.fragmentRefs, (val) => { return uiRenderViewStore.retreive(val.refNumber); }))); } diff --git a/modules/examples/src/message_broker/background_index.dart b/modules/examples/src/message_broker/background_index.dart index 40b6081c31..0bd3ea1876 100644 --- a/modules/examples/src/message_broker/background_index.dart +++ b/modules/examples/src/message_broker/background_index.dart @@ -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 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 diff --git a/modules/examples/src/message_broker/background_index.ts b/modules/examples/src/message_broker/background_index.ts index 35f23ca4bc..5913492ca3 100644 --- a/modules/examples/src/message_broker/background_index.ts +++ b/modules/examples/src/message_broker/background_index.ts @@ -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}); diff --git a/modules/examples/src/message_broker/index.dart b/modules/examples/src/message_broker/index.dart index 8bdd7ac2ee..2aff6a6523 100644 --- a/modules/examples/src/message_broker/index.dart +++ b/modules/examples/src/message_broker/index.dart @@ -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}); diff --git a/modules/examples/src/web_workers/images/background_index.dart b/modules/examples/src/web_workers/images/background_index.dart index 0060bd5e96..95c4bb71bf 100644 --- a/modules/examples/src/web_workers/images/background_index.dart +++ b/modules/examples/src/web_workers/images/background_index.dart @@ -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 args, SendPort replyTo) { reflector.reflectionCapabilities = new ReflectionCapabilities(); - bootstrapWebworker(replyTo, ImageDemo).catchError((error) => throw error); + bootstrapWebWorker(replyTo, ImageDemo).catchError((error) => throw error); } diff --git a/modules/examples/src/web_workers/images/background_index.ts b/modules/examples/src/web_workers/images/background_index.ts index e7dff8031c..52322e246f 100644 --- a/modules/examples/src/web_workers/images/background_index.ts +++ b/modules/examples/src/web_workers/images/background_index.ts @@ -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); } diff --git a/modules/examples/src/web_workers/kitchen_sink/background_index.dart b/modules/examples/src/web_workers/kitchen_sink/background_index.dart index 0efb21fe26..ceb734025c 100644 --- a/modules/examples/src/web_workers/kitchen_sink/background_index.dart +++ b/modules/examples/src/web_workers/kitchen_sink/background_index.dart @@ -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 args, SendPort replyTo) { reflector.reflectionCapabilities = new ReflectionCapabilities(); - bootstrapWebworker(replyTo, HelloCmp).catchError((error) => throw error); + bootstrapWebWorker(replyTo, HelloCmp).catchError((error) => throw error); } diff --git a/modules/examples/src/web_workers/kitchen_sink/background_index.ts b/modules/examples/src/web_workers/kitchen_sink/background_index.ts index 40b09d9348..4900897832 100644 --- a/modules/examples/src/web_workers/kitchen_sink/background_index.ts +++ b/modules/examples/src/web_workers/kitchen_sink/background_index.ts @@ -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); } diff --git a/modules/examples/src/web_workers/todo/background_index.dart b/modules/examples/src/web_workers/todo/background_index.dart index 6a4814d1db..e323476375 100644 --- a/modules/examples/src/web_workers/todo/background_index.dart +++ b/modules/examples/src/web_workers/todo/background_index.dart @@ -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 args, SendPort replyTo) { reflector.reflectionCapabilities = new ReflectionCapabilities(); - bootstrapWebworker(replyTo, TodoApp).catchError((error) => throw error); + bootstrapWebWorker(replyTo, TodoApp).catchError((error) => throw error); } diff --git a/modules/examples/src/web_workers/todo/background_index.ts b/modules/examples/src/web_workers/todo/background_index.ts index 7237799977..fe981babe6 100644 --- a/modules/examples/src/web_workers/todo/background_index.ts +++ b/modules/examples/src/web_workers/todo/background_index.ts @@ -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); }