fix(WebWorker): remove the platform-browser dependency on compiler
This commit is contained in:
@ -1 +1,6 @@
|
||||
export * from './src/platform_browser';
|
||||
|
||||
export * from './src/worker_render';
|
||||
export * from './src/worker_app';
|
||||
|
||||
export * from './private_export';
|
||||
|
@ -5,7 +5,7 @@ import * as css_animation_options from './src/animate/css_animation_options';
|
||||
import * as animation from './src/animate/animation';
|
||||
import * as dom_adapter from './src/dom/dom_adapter';
|
||||
import * as browser_adapter from './src/browser/browser_adapter';
|
||||
|
||||
import * as browser_common from './src/browser_common';
|
||||
|
||||
export namespace __platform_browser_private__ {
|
||||
export type DomAdapter = dom_adapter.DomAdapter;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Provider,
|
||||
PLATFORM_INITIALIZER,
|
||||
PLATFORM_DIRECTIVES,
|
||||
PLATFORM_PIPES,
|
||||
@ -36,7 +35,8 @@ import {
|
||||
import {DomSharedStylesHost} from './dom/shared_styles_host';
|
||||
import {AnimationBuilder} from './animate/animation_builder';
|
||||
import {BrowserDetails} from './animate/browser_details';
|
||||
|
||||
import {PlatformLocation} from '@angular/common';
|
||||
import {BrowserPlatformLocation} from './browser/location/browser_platform_location';
|
||||
export {Title} from './browser/title';
|
||||
export {BrowserDomAdapter} from './browser/browser_adapter';
|
||||
export {enableDebugTools, disableDebugTools} from './browser/tools/tools';
|
||||
@ -54,6 +54,7 @@ export const BROWSER_PROVIDERS: Array<any /*Type | Provider | any[]*/> = /*@ts2d
|
||||
/*@ts2dart_Provider*/ {provide: BROWSER_PLATFORM_MARKER, useValue: true},
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
/*@ts2dart_Provider*/ {provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true},
|
||||
/*@ts2dart_Provider*/ {provide: PlatformLocation, useClass: BrowserPlatformLocation}
|
||||
];
|
||||
|
||||
function _exceptionHandler(): ExceptionHandler {
|
||||
@ -101,14 +102,9 @@ export const BROWSER_APP_COMMON_PROVIDERS: Array<any /*Type | Provider | any[]*/
|
||||
];
|
||||
|
||||
|
||||
export {
|
||||
HAMMER_GESTURE_CONFIG,
|
||||
HammerGestureConfig
|
||||
} from '../src/dom/events/hammer_gestures'
|
||||
export {HAMMER_GESTURE_CONFIG, HammerGestureConfig} from '../src/dom/events/hammer_gestures';
|
||||
|
||||
|
||||
export function
|
||||
initDomAdapter() {
|
||||
export function initDomAdapter() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
wtfInit();
|
||||
BrowserGetTestability.init();
|
||||
|
@ -1,13 +1,5 @@
|
||||
import {
|
||||
ReflectiveInjector,
|
||||
PlatformRef,
|
||||
getPlatform,
|
||||
createPlatform,
|
||||
assertPlatform
|
||||
} from '@angular/core';
|
||||
import {isBlank} from './facade/lang';
|
||||
import {BROWSER_PROVIDERS, BROWSER_PLATFORM_MARKER} from './browser_common';
|
||||
export {DomEventsPlugin} from './dom/events/dom_events';
|
||||
export {KeyEventsPlugin} from './dom/events/key_events';
|
||||
|
||||
export {EventManager, EVENT_MANAGER_PLUGINS} from './dom/events/event_manager';
|
||||
export {ELEMENT_PROBE_PROVIDERS} from './dom/debug/ng_probe';
|
||||
@ -23,7 +15,6 @@ export {
|
||||
HammerGestureConfig
|
||||
} from './browser_common';
|
||||
|
||||
export * from '../private_export';
|
||||
export {DOCUMENT} from './dom/dom_tokens';
|
||||
|
||||
export {
|
||||
@ -38,16 +29,7 @@ export {
|
||||
|
||||
export {
|
||||
bootstrapStatic,
|
||||
browserStaticPlatform,
|
||||
browserPlatform,
|
||||
BROWSER_APP_STATIC_PROVIDERS,
|
||||
BrowserPlatformLocation
|
||||
} from './platform_browser_static';
|
||||
|
||||
|
||||
|
||||
export function browserPlatform(): PlatformRef {
|
||||
if (isBlank(getPlatform())) {
|
||||
createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS));
|
||||
}
|
||||
return assertPlatform(BROWSER_PLATFORM_MARKER);
|
||||
}
|
||||
} from './platform_browser_static';
|
@ -26,13 +26,12 @@ export {
|
||||
|
||||
/**
|
||||
* An array of providers that should be passed into `application()` when bootstrapping a component
|
||||
* when all templates
|
||||
* have been precompiled offline.
|
||||
* when all templates have been precompiled offline.
|
||||
*/
|
||||
export const BROWSER_APP_STATIC_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/ BROWSER_APP_COMMON_PROVIDERS;
|
||||
|
||||
export function browserStaticPlatform(): PlatformRef {
|
||||
export function browserPlatform(): PlatformRef {
|
||||
if (isBlank(getPlatform())) {
|
||||
createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PROVIDERS));
|
||||
}
|
||||
@ -52,6 +51,6 @@ export function bootstrapStatic(appComponentType: Type,
|
||||
let appProviders = isPresent(customProviders) ? [BROWSER_APP_STATIC_PROVIDERS, customProviders] :
|
||||
BROWSER_APP_STATIC_PROVIDERS;
|
||||
var appInjector =
|
||||
ReflectiveInjector.resolveAndCreate(appProviders, browserStaticPlatform().injector);
|
||||
ReflectiveInjector.resolveAndCreate(appProviders, browserPlatform().injector);
|
||||
return coreLoadAndBootstrap(appInjector, appComponentType);
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
import {OpaqueToken} from '@angular/core/src/di';
|
||||
import {OpaqueToken} from '@angular/core';
|
||||
|
||||
export const ON_WEB_WORKER = /*@ts2dart_const*/ new OpaqueToken('WebWorker.onWebWorker');
|
||||
|
@ -1,6 +1,5 @@
|
||||
import {EventEmitter} from '../../../src/facade/async';
|
||||
import {NgZone} from '@angular/core/src/zone/ng_zone';
|
||||
export {EventEmitter, Observable} from '../../../src/facade/async';
|
||||
import {NgZone} from '@angular/core';
|
||||
|
||||
/**
|
||||
* Message Bus is a low level API used to communicate between the UI and the background.
|
||||
|
@ -3,6 +3,5 @@
|
||||
* You should not use these channels in your application code.
|
||||
*/
|
||||
export const RENDERER_CHANNEL = "ng-Renderer";
|
||||
export const XHR_CHANNEL = "ng-XHR";
|
||||
export const EVENT_CHANNEL = "ng-Events";
|
||||
export const ROUTER_CHANNEL = "ng-Router";
|
||||
|
@ -2,8 +2,7 @@ import {MessageBus, MessageBusSource, MessageBusSink} from './message_bus';
|
||||
import {BaseException} from '../../../src/facade/exceptions';
|
||||
import {EventEmitter, ObservableWrapper} from '../../../src/facade/async';
|
||||
import {StringMapWrapper} from '../../../src/facade/collection';
|
||||
import {Injectable} from '@angular/core/src/di';
|
||||
import {NgZone} from '@angular/core/src/zone/ng_zone';
|
||||
import {Injectable, NgZone} from '@angular/core';
|
||||
|
||||
// TODO(jteplitz602) Replace this with the definition in lib.webworker.d.ts(#3492)
|
||||
export interface PostMessageTarget { postMessage: (message: any, transfer?:[ArrayBuffer]) => void; }
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core/src/di';
|
||||
import {Injectable} from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class RenderStore {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Injectable} from '@angular/core/src/di';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ListWrapper, Map} from '../../../src/facade/collection';
|
||||
import {Serializer} from '../shared/serializer';
|
||||
import {isPresent, Type, FunctionWrapper} from '../../../src/facade/lang';
|
||||
|
@ -1,11 +0,0 @@
|
||||
library angular2.src.web_workers.ui.bind;
|
||||
|
||||
/**
|
||||
* Binding is not necessary in dart.
|
||||
* This method just returns the passed function regardless of scope.
|
||||
* It's only here to match the TypeScript implementation.
|
||||
* TODO(jteplitz602) Have ts2dart remove calls to bind(#3820)
|
||||
*/
|
||||
Function bind(Function fn, dynamic scope) {
|
||||
return fn;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
export function bind(fn: Function, scope: any): Function {
|
||||
return fn.bind(scope);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
import {MessageBasedPlatformLocation} from './platform_location';
|
||||
import {BrowserPlatformLocation} from '../../browser/location/browser_platform_location';
|
||||
import {APP_INITIALIZER, Injector, NgZone} from '@angular/core';
|
||||
|
||||
/**
|
||||
* A list of {@link Provider}s. To use the router in a Worker enabled application you must
|
||||
* include these providers when setting up the render thread.
|
||||
*/
|
||||
export const WORKER_RENDER_LOCATION_PROVIDERS = /*@ts2dart_const*/[
|
||||
MessageBasedPlatformLocation,
|
||||
BrowserPlatformLocation,
|
||||
/* @ts2dart_Provider */ {provide: APP_INITIALIZER, useFactory: initUiLocation, multi: true, deps: [Injector]}
|
||||
];
|
||||
|
||||
function initUiLocation(injector: Injector): () => void {
|
||||
return () => {
|
||||
let zone = injector.get(NgZone);
|
||||
|
||||
zone.runGuarded(() => injector.get(MessageBasedPlatformLocation).start());
|
||||
};
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
import {
|
||||
BrowserPlatformLocation
|
||||
} from '@angular/platform-browser/src/browser/location/browser_platform_location';
|
||||
import {BrowserPlatformLocation} from '../../browser/location/browser_platform_location';
|
||||
import {UrlChangeListener} from '@angular/common';
|
||||
import {Injectable} from '@angular/core/src/di';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ROUTER_CHANNEL} from '../shared/messaging_api';
|
||||
import {ServiceMessageBrokerFactory, ServiceMessageBroker} from '../shared/service_message_broker';
|
||||
import {PRIMITIVE, Serializer} from '../shared/serializer';
|
||||
import {bind} from './bind';
|
||||
import {LocationType} from '../shared/serialized_types';
|
||||
import {MessageBus} from '../shared/message_bus';
|
||||
import {EventEmitter, ObservableWrapper, PromiseWrapper} from '../../../src/facade/async';
|
||||
import {FunctionWrapper} from '../../../src/facade/lang';
|
||||
|
||||
@Injectable()
|
||||
export class MessageBasedPlatformLocation {
|
||||
@ -19,23 +17,30 @@ export class MessageBasedPlatformLocation {
|
||||
constructor(private _brokerFactory: ServiceMessageBrokerFactory,
|
||||
private _platformLocation: BrowserPlatformLocation, bus: MessageBus,
|
||||
private _serializer: Serializer) {
|
||||
this._platformLocation.onPopState(<UrlChangeListener>bind(this._sendUrlChangeEvent, this));
|
||||
this._platformLocation.onHashChange(<UrlChangeListener>bind(this._sendUrlChangeEvent, this));
|
||||
this._platformLocation.onPopState(
|
||||
<UrlChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
|
||||
this._platformLocation.onHashChange(
|
||||
<UrlChangeListener>FunctionWrapper.bind(this._sendUrlChangeEvent, this));
|
||||
this._broker = this._brokerFactory.createMessageBroker(ROUTER_CHANNEL);
|
||||
this._channelSink = bus.to(ROUTER_CHANNEL);
|
||||
}
|
||||
|
||||
start(): void {
|
||||
this._broker.registerMethod("getLocation", null, bind(this._getLocation, this), LocationType);
|
||||
this._broker.registerMethod("setPathname", [PRIMITIVE], bind(this._setPathname, this));
|
||||
this._broker.registerMethod("pushState", [PRIMITIVE, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._platformLocation.pushState, this._platformLocation));
|
||||
this._broker.registerMethod("replaceState", [PRIMITIVE, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._platformLocation.replaceState, this._platformLocation));
|
||||
this._broker.registerMethod("forward", null,
|
||||
bind(this._platformLocation.forward, this._platformLocation));
|
||||
this._broker.registerMethod("back", null,
|
||||
bind(this._platformLocation.back, this._platformLocation));
|
||||
this._broker.registerMethod("getLocation", null, FunctionWrapper.bind(this._getLocation, this),
|
||||
LocationType);
|
||||
this._broker.registerMethod("setPathname", [PRIMITIVE],
|
||||
FunctionWrapper.bind(this._setPathname, this));
|
||||
this._broker.registerMethod(
|
||||
"pushState", [PRIMITIVE, PRIMITIVE, PRIMITIVE],
|
||||
FunctionWrapper.bind(this._platformLocation.pushState, this._platformLocation));
|
||||
this._broker.registerMethod(
|
||||
"replaceState", [PRIMITIVE, PRIMITIVE, PRIMITIVE],
|
||||
FunctionWrapper.bind(this._platformLocation.replaceState, this._platformLocation));
|
||||
this._broker.registerMethod(
|
||||
"forward", null,
|
||||
FunctionWrapper.bind(this._platformLocation.forward, this._platformLocation));
|
||||
this._broker.registerMethod(
|
||||
"back", null, FunctionWrapper.bind(this._platformLocation.back, this._platformLocation));
|
||||
}
|
||||
|
||||
private _getLocation(): Promise<Location> {
|
||||
|
@ -1,12 +1,11 @@
|
||||
import {Injectable} from '@angular/core/src/di';
|
||||
import {Injectable, RootRenderer, Renderer, RenderComponentType} from '@angular/core';
|
||||
import {MessageBus} from '../shared/message_bus';
|
||||
import {Serializer, PRIMITIVE, RenderStoreObject} from '../shared/serializer';
|
||||
import {RootRenderer, Renderer, RenderComponentType} from '@angular/core/src/render/api';
|
||||
import {EVENT_CHANNEL, RENDERER_CHANNEL} from '../shared/messaging_api';
|
||||
import {bind} from './bind';
|
||||
import {EventDispatcher} from '../ui/event_dispatcher';
|
||||
import {RenderStore} from '../shared/render_store';
|
||||
import {ServiceMessageBrokerFactory} from '../shared/service_message_broker';
|
||||
import {FunctionWrapper} from '../../facade/lang';
|
||||
|
||||
@Injectable()
|
||||
export class MessageBasedRenderer {
|
||||
@ -22,55 +21,55 @@ export class MessageBasedRenderer {
|
||||
this._eventDispatcher = new EventDispatcher(this._bus.to(EVENT_CHANNEL), this._serializer);
|
||||
|
||||
broker.registerMethod("renderComponent", [RenderComponentType, PRIMITIVE],
|
||||
bind(this._renderComponent, this));
|
||||
FunctionWrapper.bind(this._renderComponent, this));
|
||||
|
||||
broker.registerMethod("selectRootElement", [RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._selectRootElement, this));
|
||||
FunctionWrapper.bind(this._selectRootElement, this));
|
||||
broker.registerMethod("createElement",
|
||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._createElement, this));
|
||||
FunctionWrapper.bind(this._createElement, this));
|
||||
broker.registerMethod("createViewRoot", [RenderStoreObject, RenderStoreObject, PRIMITIVE],
|
||||
bind(this._createViewRoot, this));
|
||||
FunctionWrapper.bind(this._createViewRoot, this));
|
||||
broker.registerMethod("createTemplateAnchor", [RenderStoreObject, RenderStoreObject, PRIMITIVE],
|
||||
bind(this._createTemplateAnchor, this));
|
||||
FunctionWrapper.bind(this._createTemplateAnchor, this));
|
||||
broker.registerMethod("createText",
|
||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._createText, this));
|
||||
FunctionWrapper.bind(this._createText, this));
|
||||
broker.registerMethod("projectNodes", [RenderStoreObject, RenderStoreObject, RenderStoreObject],
|
||||
bind(this._projectNodes, this));
|
||||
FunctionWrapper.bind(this._projectNodes, this));
|
||||
broker.registerMethod("attachViewAfter",
|
||||
[RenderStoreObject, RenderStoreObject, RenderStoreObject],
|
||||
bind(this._attachViewAfter, this));
|
||||
FunctionWrapper.bind(this._attachViewAfter, this));
|
||||
broker.registerMethod("detachView", [RenderStoreObject, RenderStoreObject],
|
||||
bind(this._detachView, this));
|
||||
FunctionWrapper.bind(this._detachView, this));
|
||||
broker.registerMethod("destroyView", [RenderStoreObject, RenderStoreObject, RenderStoreObject],
|
||||
bind(this._destroyView, this));
|
||||
FunctionWrapper.bind(this._destroyView, this));
|
||||
broker.registerMethod("setElementProperty",
|
||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._setElementProperty, this));
|
||||
FunctionWrapper.bind(this._setElementProperty, this));
|
||||
broker.registerMethod("setElementAttribute",
|
||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._setElementAttribute, this));
|
||||
FunctionWrapper.bind(this._setElementAttribute, this));
|
||||
broker.registerMethod("setBindingDebugInfo",
|
||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._setBindingDebugInfo, this));
|
||||
FunctionWrapper.bind(this._setBindingDebugInfo, this));
|
||||
broker.registerMethod("setElementClass",
|
||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._setElementClass, this));
|
||||
FunctionWrapper.bind(this._setElementClass, this));
|
||||
broker.registerMethod("setElementStyle",
|
||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._setElementStyle, this));
|
||||
FunctionWrapper.bind(this._setElementStyle, this));
|
||||
broker.registerMethod("invokeElementMethod",
|
||||
[RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._invokeElementMethod, this));
|
||||
FunctionWrapper.bind(this._invokeElementMethod, this));
|
||||
broker.registerMethod("setText", [RenderStoreObject, RenderStoreObject, PRIMITIVE],
|
||||
bind(this._setText, this));
|
||||
FunctionWrapper.bind(this._setText, this));
|
||||
broker.registerMethod("listen", [RenderStoreObject, RenderStoreObject, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._listen, this));
|
||||
FunctionWrapper.bind(this._listen, this));
|
||||
broker.registerMethod("listenGlobal", [RenderStoreObject, PRIMITIVE, PRIMITIVE, PRIMITIVE],
|
||||
bind(this._listenGlobal, this));
|
||||
FunctionWrapper.bind(this._listenGlobal, this));
|
||||
broker.registerMethod("listenDone", [RenderStoreObject, RenderStoreObject],
|
||||
bind(this._listenDone, this));
|
||||
FunctionWrapper.bind(this._listenDone, this));
|
||||
}
|
||||
|
||||
private _renderComponent(renderComponentType: RenderComponentType, rendererId: number) {
|
||||
|
@ -1,19 +0,0 @@
|
||||
import {MessageBasedPlatformLocation} from './platform_location';
|
||||
import {
|
||||
BrowserPlatformLocation
|
||||
} from '@angular/platform-browser/src/browser/location/browser_platform_location';
|
||||
import {APP_INITIALIZER, Provider, Injector, NgZone} from '@angular/core';
|
||||
|
||||
export const WORKER_RENDER_ROUTER = /*@ts2dart_const*/[
|
||||
MessageBasedPlatformLocation,
|
||||
BrowserPlatformLocation,
|
||||
/* @ts2dart_Provider */ {provide: APP_INITIALIZER, useFactory: initRouterListeners, multi: true, deps: [Injector]}
|
||||
];
|
||||
|
||||
function initRouterListeners(injector: Injector): () => void {
|
||||
return () => {
|
||||
let zone = injector.get(NgZone);
|
||||
|
||||
zone.runGuarded(() => injector.get(MessageBasedPlatformLocation).start());
|
||||
};
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {PRIMITIVE} from '../shared/serializer';
|
||||
import {XHR_CHANNEL} from '../shared/messaging_api';
|
||||
import {XHR} from '@angular/compiler';
|
||||
import {ServiceMessageBrokerFactory} from '../shared/service_message_broker';
|
||||
import {bind} from './bind';
|
||||
|
||||
@Injectable()
|
||||
export class MessageBasedXHRImpl {
|
||||
constructor(private _brokerFactory: ServiceMessageBrokerFactory, private _xhr: XHR) {}
|
||||
|
||||
start(): void {
|
||||
var broker = this._brokerFactory.createMessageBroker(XHR_CHANNEL);
|
||||
broker.registerMethod("get", [PRIMITIVE], bind(this._xhr.get, this._xhr), PRIMITIVE);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
import {NgZone, APP_INITIALIZER} from '@angular/core';
|
||||
import {PlatformLocation} from '@angular/common';
|
||||
import {WebWorkerPlatformLocation} from './platform_location';
|
||||
|
||||
/**
|
||||
* Those providers should be added when the router is used in a worker context in addition to the
|
||||
* {@link ROUTER_PROVIDERS} and after them.
|
||||
*/
|
||||
export const WORKER_APP_LOCATION_PROVIDERS = /*@ts2dart_const*/[
|
||||
/* @ts2dart_Provider */ {provide: PlatformLocation, useClass: WebWorkerPlatformLocation},
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: (platformLocation: WebWorkerPlatformLocation, zone: NgZone) => () =>
|
||||
initWorkerLocation(platformLocation, zone),
|
||||
multi: true,
|
||||
deps: [PlatformLocation, NgZone]
|
||||
}
|
||||
];
|
||||
|
||||
function initWorkerLocation(platformLocation: WebWorkerPlatformLocation, zone: NgZone): Promise<boolean> {
|
||||
return zone.runGuarded(() => platformLocation.init());
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
import {Injectable} from '@angular/core/src/di';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {
|
||||
FnArg,
|
||||
UiArguments,
|
||||
ClientMessageBroker,
|
||||
ClientMessageBrokerFactory
|
||||
} from '../shared/client_message_broker';
|
||||
import {PlatformLocation, UrlChangeEvent, UrlChangeListener} from '@angular/common';
|
||||
import {PlatformLocation, UrlChangeListener} from '@angular/common';
|
||||
import {ROUTER_CHANNEL} from '../shared/messaging_api';
|
||||
import {LocationType} from '../shared/serialized_types';
|
||||
import {PromiseWrapper, EventEmitter, ObservableWrapper} from '../../../src/facade/async';
|
||||
|
@ -2,24 +2,19 @@ import {
|
||||
Renderer,
|
||||
RootRenderer,
|
||||
RenderComponentType,
|
||||
RenderDebugInfo
|
||||
} from '@angular/core/src/render/api';
|
||||
import {
|
||||
ClientMessageBroker,
|
||||
ClientMessageBrokerFactory,
|
||||
FnArg,
|
||||
UiArguments
|
||||
} from '../shared/client_message_broker';
|
||||
import {isPresent, isBlank, print} from '../../../src/facade/lang';
|
||||
Injectable,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import {RenderDebugInfo} from '../../../core_private';
|
||||
|
||||
import {ClientMessageBrokerFactory, FnArg, UiArguments} from '../shared/client_message_broker';
|
||||
import {isPresent, isBlank} from '../../../src/facade/lang';
|
||||
import {ListWrapper} from '../../../src/facade/collection';
|
||||
import {Injectable} from '@angular/core/src/di';
|
||||
import {RenderStore} from '../shared/render_store';
|
||||
import {RENDERER_CHANNEL} from '../shared/messaging_api';
|
||||
import {RENDERER_CHANNEL, EVENT_CHANNEL} from '../shared/messaging_api';
|
||||
import {Serializer, RenderStoreObject} from '../shared/serializer';
|
||||
import {EVENT_CHANNEL} from '../shared/messaging_api';
|
||||
import {MessageBus} from '../shared/message_bus';
|
||||
import {ObservableWrapper} from '../../../src/facade/async';
|
||||
import {ViewEncapsulation} from '@angular/core';
|
||||
import {deserializeGenericEvent} from './event_deserializer';
|
||||
|
||||
@Injectable()
|
||||
|
@ -1,20 +0,0 @@
|
||||
import {Provider, NgZone, APP_INITIALIZER} from '@angular/core';
|
||||
import {PlatformLocation} from '@angular/common';
|
||||
import {WebWorkerPlatformLocation} from './platform_location';
|
||||
import {ROUTER_PROVIDERS} from '@angular/router';
|
||||
|
||||
export var WORKER_APP_ROUTER = [
|
||||
ROUTER_PROVIDERS,
|
||||
/* @ts2dart_Provider */ {provide: PlatformLocation, useClass: WebWorkerPlatformLocation},
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: (platformLocation: WebWorkerPlatformLocation, zone: NgZone) => () =>
|
||||
initRouter(platformLocation, zone),
|
||||
multi: true,
|
||||
deps: [PlatformLocation, NgZone]
|
||||
}
|
||||
];
|
||||
|
||||
function initRouter(platformLocation: WebWorkerPlatformLocation, zone: NgZone): Promise<boolean> {
|
||||
return zone.runGuarded(() => { return platformLocation.init(); });
|
||||
}
|
@ -0,0 +1,390 @@
|
||||
library angular2.dom.webWorkerAdapter;
|
||||
|
||||
import 'abstract_html_adapter.dart';
|
||||
import 'package:angular2/platform/common_dom.dart';
|
||||
|
||||
/**
|
||||
* This adapter is required to log error messages.
|
||||
*
|
||||
* Note: other methods all throw as the DOM is not accessible directly
|
||||
* in web worker context.
|
||||
*/
|
||||
class WebWorkerDomAdapter implements DomAdapter {
|
||||
static void makeCurrent() {
|
||||
setRootDomAdapter(new WebWorkerDomAdapter());
|
||||
}
|
||||
|
||||
logError(error) {
|
||||
print('${error}');
|
||||
}
|
||||
|
||||
log(error) {
|
||||
print('${error}');
|
||||
}
|
||||
|
||||
logGroup(error) {
|
||||
print('${error}');
|
||||
}
|
||||
|
||||
logGroupEnd() {}
|
||||
|
||||
hasProperty(element, String name) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
void setProperty(Element element, String name, Object value) =>
|
||||
throw 'not implemented';
|
||||
|
||||
getProperty(Element element, String name) => throw 'not implemented';
|
||||
|
||||
invoke(Element element, String methodName, List args) =>
|
||||
throw 'not implemented';
|
||||
|
||||
get attrToPropMap => throw 'not implemented';
|
||||
|
||||
set attrToPropMap(value) {
|
||||
throw 'readonly';
|
||||
}
|
||||
|
||||
getGlobalEventTarget(String target) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getTitle() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setTitle(String newTitle) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getEventKey(event) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
void replaceChild(el, newNode, oldNode) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
dynamic getBoundingClientRect(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
Type getXHR() => throw 'not implemented';
|
||||
|
||||
Element parse(String templateHtml) => throw 'not implemented';
|
||||
query(selector) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
querySelector(el, String selector) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
List querySelectorAll(el, String selector) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
on(el, evt, listener) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
Function onAndCancel(el, evt, listener) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
dispatchEvent(el, evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createMouseEvent(eventType) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createEvent(eventType) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
preventDefault(evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
isPrevented(evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getInnerHTML(el) => throw 'not implemented';
|
||||
|
||||
getOuterHTML(el) => throw 'not implemented';
|
||||
|
||||
String nodeName(node) => throw 'not implemented';
|
||||
|
||||
String nodeValue(node) => throw 'not implemented';
|
||||
|
||||
String type(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
content(node) => throw 'not implemented';
|
||||
|
||||
firstChild(el) => throw 'not implemented';
|
||||
|
||||
nextSibling(el) => throw 'not implemented';
|
||||
|
||||
parentElement(el) => throw 'not implemented';
|
||||
|
||||
List childNodes(el) => throw 'not implemented';
|
||||
List childNodesAsList(el) => throw 'not implemented';
|
||||
clearNodes(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
appendChild(el, node) => throw 'not implemented';
|
||||
removeChild(el, node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
remove(el) => throw 'not implemented';
|
||||
insertBefore(el, node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
insertAllBefore(el, nodes) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
insertAfter(el, node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setInnerHTML(el, value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getText(el) => throw 'not implemented';
|
||||
|
||||
setText(el, String value) => throw 'not implemented';
|
||||
|
||||
getValue(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setValue(el, String value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getChecked(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setChecked(el, bool value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createComment(String text) => throw 'not implemented';
|
||||
createTemplate(String html) => throw 'not implemented';
|
||||
createElement(tagName, [doc]) => throw 'not implemented';
|
||||
|
||||
createElementNS(ns, tagName, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createTextNode(String text, [doc]) => throw 'not implemented';
|
||||
|
||||
createScriptTag(String attrName, String attrValue, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createStyleElement(String css, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createShadowRoot(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getShadowRoot(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getHost(el) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
clone(node) => throw 'not implemented';
|
||||
getElementsByClassName(element, String name) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getElementsByTagName(element, String name) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
List classList(element) => throw 'not implemented';
|
||||
|
||||
addClass(element, String className) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
removeClass(element, String className) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
hasClass(element, String className) => throw 'not implemented';
|
||||
|
||||
setStyle(element, String styleName, String styleValue) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool hasStyle(Element element, String styleName, [String styleValue]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
removeStyle(element, String styleName) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getStyle(element, String styleName) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String tagName(element) => throw 'not implemented';
|
||||
|
||||
attributeMap(element) => throw 'not implemented';
|
||||
|
||||
hasAttribute(element, String attribute) => throw 'not implemented';
|
||||
|
||||
hasAttributeNS(element, String ns, String attribute) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getAttribute(element, String attribute) => throw 'not implemented';
|
||||
|
||||
getAttributeNS(element, String ns, String attribute) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setAttribute(element, String name, String value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
setAttributeNS(element, String ns, String name, String value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
removeAttribute(element, String attribute) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
removeAttributeNS(element, String ns, String attribute) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
templateAwareRoot(el) => throw 'not implemented';
|
||||
|
||||
createHtmlDocument() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
defaultDoc() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool elementMatches(n, String selector) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool isTemplateElement(Element el) => throw 'not implemented';
|
||||
|
||||
bool isTextNode(node) => throw 'not implemented';
|
||||
bool isCommentNode(node) => throw 'not implemented';
|
||||
|
||||
bool isElementNode(node) => throw 'not implemented';
|
||||
|
||||
bool hasShadowRoot(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool isShadowRoot(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
importIntoDoc(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
adoptNode(node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getHref(element) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
void resolveAndSetHref(element, baseUrl, href) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
List getDistributedNodes(Node) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
bool supportsDOMEvents() => throw 'not implemented';
|
||||
|
||||
bool supportsNativeShadowDOM() => throw 'not implemented';
|
||||
|
||||
getHistory() => throw 'not implemented';
|
||||
|
||||
getLocation() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getBaseHref() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
resetBaseElement() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getUserAgent() => throw 'not implemented';
|
||||
|
||||
void setData(Element element, String name, String value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getComputedStyle(element) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getData(Element element, String name) => throw 'not implemented';
|
||||
|
||||
// TODO(tbosch): move this into a separate environment class once we have it
|
||||
setGlobalVar(String name, value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
requestAnimationFrame(callback) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
cancelAnimationFrame(id) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
performanceNow() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getAnimationPrefix() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
getTransitionEnd() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
supportsAnimation() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
import {Type} from '../../../src/facade/lang';
|
||||
import {DomAdapter, setRootDomAdapter} from '../../dom/dom_adapter';
|
||||
|
||||
/**
|
||||
* This adapter is required to log error messages.
|
||||
*
|
||||
* Note: other methods all throw as the DOM is not accessible directly in web worker context.
|
||||
*/
|
||||
export class WorkerDomAdapter extends DomAdapter {
|
||||
static makeCurrent() { setRootDomAdapter(new WorkerDomAdapter()); }
|
||||
|
||||
logError(error) {
|
||||
if (console.error) {
|
||||
console.error(error);
|
||||
} else {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
log(error) { console.log(error); }
|
||||
|
||||
logGroup(error) {
|
||||
if (console.group) {
|
||||
console.group(error);
|
||||
this.logError(error);
|
||||
} else {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
logGroupEnd() {
|
||||
if (console.groupEnd) {
|
||||
console.groupEnd();
|
||||
}
|
||||
}
|
||||
|
||||
hasProperty(element, name: string): boolean { throw "not implemented"; }
|
||||
setProperty(el: Element, name: string, value: any) { throw "not implemented"; }
|
||||
getProperty(el: Element, name: string): any { throw "not implemented"; }
|
||||
invoke(el: Element, methodName: string, args: any[]): any { throw "not implemented"; }
|
||||
|
||||
getXHR(): Type { throw "not implemented"; }
|
||||
|
||||
get attrToPropMap(): {[key: string]: string} { throw "not implemented"; }
|
||||
set attrToPropMap(value: {[key: string]: string}) { throw "not implemented"; }
|
||||
|
||||
parse(templateHtml: string) { throw "not implemented"; }
|
||||
query(selector: string): any { throw "not implemented"; }
|
||||
querySelector(el, selector: string): HTMLElement { throw "not implemented"; }
|
||||
querySelectorAll(el, selector: string): any[] { throw "not implemented"; }
|
||||
on(el, evt, listener) { throw "not implemented"; }
|
||||
onAndCancel(el, evt, listener): Function { throw "not implemented"; }
|
||||
dispatchEvent(el, evt) { throw "not implemented"; }
|
||||
createMouseEvent(eventType): any { throw "not implemented"; }
|
||||
createEvent(eventType: string): any { throw "not implemented"; }
|
||||
preventDefault(evt) { throw "not implemented"; }
|
||||
isPrevented(evt): boolean { throw "not implemented"; }
|
||||
getInnerHTML(el): string { throw "not implemented"; }
|
||||
getTemplateContent(el): any { throw "not implemented"; }
|
||||
getOuterHTML(el): string { throw "not implemented"; }
|
||||
nodeName(node): string { throw "not implemented"; }
|
||||
nodeValue(node): string { throw "not implemented"; }
|
||||
type(node): string { throw "not implemented"; }
|
||||
content(node): any { throw "not implemented"; }
|
||||
firstChild(el): Node { throw "not implemented"; }
|
||||
nextSibling(el): Node { throw "not implemented"; }
|
||||
parentElement(el): Node { throw "not implemented"; }
|
||||
childNodes(el): Node[] { throw "not implemented"; }
|
||||
childNodesAsList(el): Node[] { throw "not implemented"; }
|
||||
clearNodes(el) { throw "not implemented"; }
|
||||
appendChild(el, node) { throw "not implemented"; }
|
||||
removeChild(el, node) { throw "not implemented"; }
|
||||
replaceChild(el, newNode, oldNode) { throw "not implemented"; }
|
||||
remove(el): Node { throw "not implemented"; }
|
||||
insertBefore(el, node) { throw "not implemented"; }
|
||||
insertAllBefore(el, nodes) { throw "not implemented"; }
|
||||
insertAfter(el, node) { throw "not implemented"; }
|
||||
setInnerHTML(el, value) { throw "not implemented"; }
|
||||
getText(el): string { throw "not implemented"; }
|
||||
setText(el, value: string) { throw "not implemented"; }
|
||||
getValue(el): string { throw "not implemented"; }
|
||||
setValue(el, value: string) { throw "not implemented"; }
|
||||
getChecked(el): boolean { throw "not implemented"; }
|
||||
setChecked(el, value: boolean) { throw "not implemented"; }
|
||||
createComment(text: string): any { throw "not implemented"; }
|
||||
createTemplate(html): HTMLElement { throw "not implemented"; }
|
||||
createElement(tagName, doc?): HTMLElement { throw "not implemented"; }
|
||||
createElementNS(ns: string, tagName: string, doc?): Element { throw "not implemented"; }
|
||||
createTextNode(text: string, doc?): Text { throw "not implemented"; }
|
||||
createScriptTag(attrName: string, attrValue: string, doc?): HTMLElement {
|
||||
throw "not implemented";
|
||||
}
|
||||
createStyleElement(css: string, doc?): HTMLStyleElement { throw "not implemented"; }
|
||||
createShadowRoot(el): any { throw "not implemented"; }
|
||||
getShadowRoot(el): any { throw "not implemented"; }
|
||||
getHost(el): any { throw "not implemented"; }
|
||||
getDistributedNodes(el): Node[] { throw "not implemented"; }
|
||||
clone(node: Node): Node { throw "not implemented"; }
|
||||
getElementsByClassName(element, name: string): HTMLElement[] { throw "not implemented"; }
|
||||
getElementsByTagName(element, name: string): HTMLElement[] { throw "not implemented"; }
|
||||
classList(element): any[] { throw "not implemented"; }
|
||||
addClass(element, className: string) { throw "not implemented"; }
|
||||
removeClass(element, className: string) { throw "not implemented"; }
|
||||
hasClass(element, className: string): boolean { throw "not implemented"; }
|
||||
setStyle(element, styleName: string, styleValue: string) { throw "not implemented"; }
|
||||
removeStyle(element, styleName: string) { throw "not implemented"; }
|
||||
getStyle(element, styleName: string): string { throw "not implemented"; }
|
||||
hasStyle(element, styleName: string, styleValue?: string): boolean { throw "not implemented"; }
|
||||
tagName(element): string { throw "not implemented"; }
|
||||
attributeMap(element): Map<string, string> { throw "not implemented"; }
|
||||
hasAttribute(element, attribute: string): boolean { throw "not implemented"; }
|
||||
hasAttributeNS(element, ns: string, attribute: string): boolean { throw "not implemented"; }
|
||||
getAttribute(element, attribute: string): string { throw "not implemented"; }
|
||||
getAttributeNS(element, ns: string, attribute: string): string { throw "not implemented"; }
|
||||
setAttribute(element, name: string, value: string) { throw "not implemented"; }
|
||||
setAttributeNS(element, ns: string, name: string, value: string) { throw "not implemented"; }
|
||||
removeAttribute(element, attribute: string) { throw "not implemented"; }
|
||||
removeAttributeNS(element, ns: string, attribute: string) { throw "not implemented"; }
|
||||
templateAwareRoot(el) { throw "not implemented"; }
|
||||
createHtmlDocument(): HTMLDocument { throw "not implemented"; }
|
||||
defaultDoc(): HTMLDocument { throw "not implemented"; }
|
||||
getBoundingClientRect(el) { throw "not implemented"; }
|
||||
getTitle(): string { throw "not implemented"; }
|
||||
setTitle(newTitle: string) { throw "not implemented"; }
|
||||
elementMatches(n, selector: string): boolean { throw "not implemented"; }
|
||||
isTemplateElement(el: any): boolean { throw "not implemented"; }
|
||||
isTextNode(node): boolean { throw "not implemented"; }
|
||||
isCommentNode(node): boolean { throw "not implemented"; }
|
||||
isElementNode(node): boolean { throw "not implemented"; }
|
||||
hasShadowRoot(node): boolean { throw "not implemented"; }
|
||||
isShadowRoot(node): boolean { throw "not implemented"; }
|
||||
importIntoDoc(node: Node): Node { throw "not implemented"; }
|
||||
adoptNode(node: Node): Node { throw "not implemented"; }
|
||||
getHref(element): string { throw "not implemented"; }
|
||||
getEventKey(event): string { throw "not implemented"; }
|
||||
resolveAndSetHref(element, baseUrl: string, href: string) { throw "not implemented"; }
|
||||
supportsDOMEvents(): boolean { throw "not implemented"; }
|
||||
supportsNativeShadowDOM(): boolean { throw "not implemented"; }
|
||||
getGlobalEventTarget(target: string): any { throw "not implemented"; }
|
||||
getHistory(): History { throw "not implemented"; }
|
||||
getLocation(): Location { throw "not implemented"; }
|
||||
getBaseHref(): string { throw "not implemented"; }
|
||||
resetBaseElement(): void { throw "not implemented"; }
|
||||
getUserAgent(): string { throw "not implemented"; }
|
||||
setData(element, name: string, value: string) { throw "not implemented"; }
|
||||
getComputedStyle(element): any { throw "not implemented"; }
|
||||
getData(element, name: string): string { throw "not implemented"; }
|
||||
setGlobalVar(name: string, value: any) { throw "not implemented"; }
|
||||
requestAnimationFrame(callback): number { throw "not implemented"; }
|
||||
cancelAnimationFrame(id) { throw "not implemented"; }
|
||||
performanceNow(): number { throw "not implemented"; }
|
||||
getAnimationPrefix(): string { throw "not implemented"; }
|
||||
getTransitionEnd(): string { throw "not implemented"; }
|
||||
supportsAnimation(): boolean { throw "not implemented"; }
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
import {Injectable} from '@angular/core/src/di';
|
||||
import {XHR} from '@angular/compiler/src/xhr';
|
||||
import {
|
||||
FnArg,
|
||||
UiArguments,
|
||||
ClientMessageBroker,
|
||||
ClientMessageBrokerFactory
|
||||
} from '../shared/client_message_broker';
|
||||
import {XHR_CHANNEL} from '../shared/messaging_api';
|
||||
|
||||
/**
|
||||
* Implementation of compiler/xhr that relays XHR requests to the UI side where they are sent
|
||||
* and the result is proxied back to the worker
|
||||
*/
|
||||
@Injectable()
|
||||
export class WebWorkerXHRImpl extends XHR {
|
||||
private _messageBroker: ClientMessageBroker;
|
||||
|
||||
constructor(messageBrokerFactory: ClientMessageBrokerFactory) {
|
||||
super();
|
||||
this._messageBroker = messageBrokerFactory.createMessageBroker(XHR_CHANNEL);
|
||||
}
|
||||
|
||||
get(url: string): Promise<string> {
|
||||
var fnArgs: FnArg[] = [new FnArg(url, null)];
|
||||
var args: UiArguments = new UiArguments("get", fnArgs);
|
||||
return this._messageBroker.runOnService(args, String);
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ import 'dart:isolate';
|
||||
|
||||
const OpaqueToken RENDER_SEND_PORT = const OpaqueToken("RenderSendPort");
|
||||
|
||||
const List<dynamic> WORKER_APP_APPLICATION = const [
|
||||
const List<dynamic> WORKER_APP_APPLICATION_PROVIDERS = const [
|
||||
WORKER_APP_APPLICATION_COMMON,
|
||||
const Provider(MessageBus,
|
||||
useFactory: createMessageBus, deps: const [NgZone, RENDER_SEND_PORT]),
|
||||
|
@ -1,15 +1,12 @@
|
||||
import {NgZone} from '@angular/core/src/zone/ng_zone';
|
||||
import {Provider} from '@angular/core/src/di';
|
||||
import {Parse5DomAdapter} from '@angular/platform-server';
|
||||
import {APP_INITIALIZER, NgZone} from '@angular/core';
|
||||
import {WorkerDomAdapter} from '../web_workers/worker/worker_adapter';
|
||||
import {
|
||||
PostMessageBus,
|
||||
PostMessageBusSink,
|
||||
PostMessageBusSource
|
||||
} from '../web_workers/shared/post_message_bus';
|
||||
import {WORKER_APP_APPLICATION_COMMON} from './worker_app_common';
|
||||
import {APP_INITIALIZER} from '@angular/core';
|
||||
import {WORKER_APP_APPLICATION_COMMON_PROVIDERS} from './worker_app_common';
|
||||
import {MessageBus} from '../web_workers/shared/message_bus';
|
||||
import {COMPILER_PROVIDERS} from '@angular/compiler/src/compiler';
|
||||
|
||||
// TODO(jteplitz602) remove this and compile with lib.webworker.d.ts (#3492)
|
||||
let _postMessage = {
|
||||
@ -18,9 +15,8 @@ let _postMessage = {
|
||||
}
|
||||
};
|
||||
|
||||
export const WORKER_APP_APPLICATION: Array<any /*Type | Provider | any[]*/> = [
|
||||
WORKER_APP_APPLICATION_COMMON,
|
||||
COMPILER_PROVIDERS,
|
||||
export const WORKER_APP_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
WORKER_APP_APPLICATION_COMMON_PROVIDERS,
|
||||
/* @ts2dart_Provider */ {provide: MessageBus, useFactory: createMessageBus, deps: [NgZone]},
|
||||
/* @ts2dart_Provider */ {provide: APP_INITIALIZER, useValue: setupWebWorker, multi: true}
|
||||
];
|
||||
@ -34,5 +30,5 @@ function createMessageBus(zone: NgZone): MessageBus {
|
||||
}
|
||||
|
||||
function setupWebWorker(): void {
|
||||
Parse5DomAdapter.makeCurrent();
|
||||
WorkerDomAdapter.makeCurrent();
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
import {XHR} from '@angular/compiler';
|
||||
import {WebWorkerXHRImpl} from '../web_workers/worker/xhr_impl';
|
||||
import {WebWorkerRootRenderer} from '../web_workers/worker/renderer';
|
||||
import {print} from '../../src/facade/lang';
|
||||
import {RootRenderer} from '@angular/core/src/render/api';
|
||||
import {
|
||||
PLATFORM_DIRECTIVES,
|
||||
PLATFORM_PIPES,
|
||||
ExceptionHandler,
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
OpaqueToken
|
||||
OpaqueToken,
|
||||
RootRenderer
|
||||
} from '@angular/core';
|
||||
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from '@angular/common';
|
||||
import {
|
||||
@ -22,8 +20,8 @@ import {
|
||||
} from '../web_workers/shared/service_message_broker';
|
||||
import {Serializer} from '../web_workers/shared/serializer';
|
||||
import {ON_WEB_WORKER} from '../web_workers/shared/api';
|
||||
import {Provider} from '@angular/core/src/di';
|
||||
import {RenderStore} from '../web_workers/shared/render_store';
|
||||
import {BROWSER_SANITIZATION_PROVIDERS} from '../browser_common';
|
||||
|
||||
class PrintLogger {
|
||||
log = print;
|
||||
@ -35,17 +33,18 @@ class PrintLogger {
|
||||
export const WORKER_APP_PLATFORM_MARKER =
|
||||
/*@ts2dart_const*/ new OpaqueToken('WorkerAppPlatformMarker');
|
||||
|
||||
export const WORKER_APP_PLATFORM: Array<any /*Type | Provider | any[]*/> =
|
||||
export const WORKER_APP_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
/*@ts2dart_const*/ (
|
||||
/* @ts2dart_Provider */ {provide: WORKER_APP_PLATFORM_MARKER, useValue: true})
|
||||
];
|
||||
|
||||
export const WORKER_APP_APPLICATION_COMMON: Array<any /*Type | Provider | any[]*/> =
|
||||
export const WORKER_APP_APPLICATION_COMMON_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
FORM_PROVIDERS,
|
||||
BROWSER_SANITIZATION_PROVIDERS,
|
||||
Serializer,
|
||||
/* @ts2dart_Provider */ {provide: PLATFORM_PIPES, useValue: COMMON_PIPES, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: PLATFORM_DIRECTIVES, useValue: COMMON_DIRECTIVES, multi: true},
|
||||
@ -55,9 +54,7 @@ export const WORKER_APP_APPLICATION_COMMON: Array<any /*Type | Provider | any[]*
|
||||
/* @ts2dart_Provider */ {provide: RootRenderer, useExisting: WebWorkerRootRenderer},
|
||||
/* @ts2dart_Provider */ {provide: ON_WEB_WORKER, useValue: true},
|
||||
RenderStore,
|
||||
/* @ts2dart_Provider */ {provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []},
|
||||
WebWorkerXHRImpl,
|
||||
/* @ts2dart_Provider */ {provide: XHR, useExisting: WebWorkerXHRImpl}
|
||||
/* @ts2dart_Provider */ {provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []}
|
||||
];
|
||||
|
||||
function _exceptionHandler(): ExceptionHandler {
|
||||
|
@ -2,7 +2,7 @@ library angular2.src.platform.worker_render;
|
||||
|
||||
import 'package:angular2/src/platform/worker_render_common.dart'
|
||||
show
|
||||
WORKER_RENDER_APPLICATION_COMMON,
|
||||
WORKER_RENDER_APPLICATION_COMMON_PROVIDERS,
|
||||
WORKER_RENDER_MESSAGING_PROVIDERS,
|
||||
WORKER_SCRIPT,
|
||||
initializeGenericWorkerRenderer;
|
||||
@ -13,7 +13,7 @@ import 'package:angular2/src/core/di.dart';
|
||||
import 'dart:isolate';
|
||||
import 'dart:async';
|
||||
|
||||
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;
|
||||
const WORKER_RENDER_APP_PROVIDERS = WORKER_RENDER_APPLICATION_COMMON_PROVIDERS;
|
||||
|
||||
Future<List> initIsolate(String scriptUri) async {
|
||||
var instance = await spawnIsolate(Uri.parse(scriptUri));
|
||||
|
@ -4,15 +4,16 @@ import {
|
||||
PostMessageBusSource
|
||||
} from '../web_workers/shared/post_message_bus';
|
||||
import {MessageBus} from '../web_workers/shared/message_bus';
|
||||
import {APP_INITIALIZER} from '@angular/core';
|
||||
import {Injector, Injectable, Provider} from '@angular/core/src/di';
|
||||
import {Injector, Injectable, APP_INITIALIZER} from '@angular/core';
|
||||
import {
|
||||
WORKER_RENDER_APPLICATION_COMMON,
|
||||
WORKER_RENDER_APPLICATION_COMMON_PROVIDERS,
|
||||
WORKER_SCRIPT,
|
||||
initializeGenericWorkerRenderer
|
||||
} from './worker_render_common';
|
||||
import {BaseException} from '../../src/facade/exceptions';
|
||||
|
||||
export {WORKER_RENDER_STARTABLE_MESSAGING_SERVICE} from './worker_render_common';
|
||||
|
||||
/**
|
||||
* Wrapper class that exposes the Worker
|
||||
* and underlying {@link MessageBus} for lower level message passing.
|
||||
@ -32,8 +33,8 @@ export class WebWorkerInstance {
|
||||
/**
|
||||
* An array of providers that should be passed into `application()` when initializing a new Worker.
|
||||
*/
|
||||
export const WORKER_RENDER_APPLICATION: Array<any /*Type | Provider | any[]*/> = /*@ts2dart_const*/[
|
||||
WORKER_RENDER_APPLICATION_COMMON, WebWorkerInstance,
|
||||
export const WORKER_RENDER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> = /*@ts2dart_const*/[
|
||||
WORKER_RENDER_APPLICATION_COMMON_PROVIDERS, WebWorkerInstance,
|
||||
/*@ts2dart_Provider*/ {
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: (injector => () => initWebWorkerApplication(injector)),
|
||||
|
@ -1,6 +1,7 @@
|
||||
import {IS_DART} from '../../src/facade/lang';
|
||||
import {MessageBus} from '../web_workers/shared/message_bus';
|
||||
import {NgZone} from '@angular/core/src/zone/ng_zone';
|
||||
import {NgZone, Provider, Injector, OpaqueToken, Testability} from '@angular/core';
|
||||
import {wtfInit} from '../../core_private';
|
||||
import {
|
||||
ExceptionHandler,
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
@ -8,24 +9,17 @@ import {
|
||||
RootRenderer,
|
||||
PLATFORM_INITIALIZER
|
||||
} from '@angular/core';
|
||||
import {Provider, Injector, OpaqueToken} from '@angular/core/src/di';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {DomEventsPlugin} from '@angular/platform-browser/src/dom/events/dom_events';
|
||||
import {KeyEventsPlugin} from '@angular/platform-browser/src/dom/events/key_events';
|
||||
import {HammerGesturesPlugin} from '@angular/platform-browser/src/dom/events/hammer_gestures';
|
||||
import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens';
|
||||
import {DomRootRenderer, DomRootRenderer_} from '@angular/platform-browser/src/dom/dom_renderer';
|
||||
import {
|
||||
DomSharedStylesHost,
|
||||
SharedStylesHost
|
||||
} from '@angular/platform-browser/src/dom/shared_styles_host';
|
||||
import {getDOM} from '../dom/dom_adapter';
|
||||
import {DomEventsPlugin} from '../dom/events/dom_events';
|
||||
import {KeyEventsPlugin} from '../dom/events/key_events';
|
||||
import {HammerGesturesPlugin} from '../dom/events/hammer_gestures';
|
||||
import {DOCUMENT} from '../dom/dom_tokens';
|
||||
import {DomRootRenderer, DomRootRenderer_} from '../dom/dom_renderer';
|
||||
import {DomSharedStylesHost, SharedStylesHost} from '../dom/shared_styles_host';
|
||||
import {BrowserDetails} from '../animate/browser_details';
|
||||
import {AnimationBuilder} from '../animate/animation_builder';
|
||||
import {Testability} from '@angular/core/src/testability/testability';
|
||||
import {BrowserGetTestability} from '@angular/platform-browser/src/browser/testability';
|
||||
import {BrowserGetTestability} from '../browser/testability';
|
||||
import {BrowserDomAdapter} from '../browser/browser_adapter';
|
||||
import {BROWSER_SANITIZATION_PROVIDERS} from '../browser_common';
|
||||
import {wtfInit} from '@angular/core/src/profile/wtf_init';
|
||||
import {MessageBasedRenderer} from '../web_workers/ui/renderer';
|
||||
import {
|
||||
ServiceMessageBrokerFactory,
|
||||
@ -35,47 +29,38 @@ import {
|
||||
ClientMessageBrokerFactory,
|
||||
ClientMessageBrokerFactory_
|
||||
} from '../web_workers/shared/client_message_broker';
|
||||
import {
|
||||
BrowserPlatformLocation
|
||||
} from '@angular/platform-browser/src/browser/location/browser_platform_location';
|
||||
import {Serializer} from '../web_workers/shared/serializer';
|
||||
import {ON_WEB_WORKER} from '../web_workers/shared/api';
|
||||
import {RenderStore} from '../web_workers/shared/render_store';
|
||||
import {HAMMER_GESTURE_CONFIG, HammerGestureConfig} from '../dom/events/hammer_gestures';
|
||||
import {SanitizationService} from '../../core_private';
|
||||
import {DomSanitizationService} from '../security/dom_sanitization_service';
|
||||
import {EventManager, EVENT_MANAGER_PLUGINS} from '../dom/events/event_manager';
|
||||
import {XHR} from "../../../compiler/src/xhr";
|
||||
import {XHRImpl} from "../../../platform-browser-dynamic/src/xhr/xhr_impl";
|
||||
import {MessageBasedXHRImpl} from "../web_workers/ui/xhr_impl";
|
||||
// TODO change these imports once dom_adapter is moved out of core
|
||||
import {BROWSER_SANITIZATION_PROVIDERS} from '../browser_common';
|
||||
|
||||
export const WORKER_SCRIPT: OpaqueToken = /*@ts2dart_const*/ new OpaqueToken("WebWorkerScript");
|
||||
|
||||
// Message based Worker classes that listen on the MessageBus
|
||||
export const WORKER_RENDER_MESSAGING_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[MessageBasedRenderer, MessageBasedXHRImpl];
|
||||
/**
|
||||
* A multiple providers used to automatically call the `start()` method after the service is
|
||||
* created.
|
||||
*
|
||||
* TODO(vicb): create an interface for startable services to implement
|
||||
*/
|
||||
export const WORKER_RENDER_STARTABLE_MESSAGING_SERVICE =
|
||||
/*@ts2dart_const*/ new OpaqueToken('WorkerRenderStartableMsgService');
|
||||
|
||||
export const WORKER_RENDER_PLATFORM_MARKER =
|
||||
/*@ts2dart_const*/ new OpaqueToken('WorkerRenderPlatformMarker');
|
||||
|
||||
export const WORKER_RENDER_PLATFORM: Array<any /*Type | Provider | any[]*/> = /*@ts2dart_const*/[
|
||||
export const WORKER_RENDER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = /*@ts2dart_const*/[
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
/*@ts2dart_const*/ (/* @ts2dart_Provider */ {provide: WORKER_RENDER_PLATFORM_MARKER, useValue: true}),
|
||||
/* @ts2dart_Provider */ {provide: PLATFORM_INITIALIZER, useValue: initWebWorkerRenderPlatform, multi: true}
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of {@link Provider}s. To use the router in a Worker enabled application you must
|
||||
* include these providers when setting up the render thread.
|
||||
*/
|
||||
export const WORKER_RENDER_ROUTER: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[BrowserPlatformLocation];
|
||||
|
||||
export const WORKER_RENDER_APPLICATION_COMMON: Array<any /*Type | Provider | any[]*/> =
|
||||
export const WORKER_RENDER_APPLICATION_COMMON_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
WORKER_RENDER_MESSAGING_PROVIDERS,
|
||||
MessageBasedRenderer,
|
||||
/* @ts2dart_Provider */ {provide: WORKER_RENDER_STARTABLE_MESSAGING_SERVICE, useExisting: MessageBasedRenderer, multi: true},
|
||||
BROWSER_SANITIZATION_PROVIDERS,
|
||||
/* @ts2dart_Provider */ {provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []},
|
||||
/* @ts2dart_Provider */ {provide: DOCUMENT, useFactory: _document, deps: []},
|
||||
@ -88,8 +73,6 @@ export const WORKER_RENDER_APPLICATION_COMMON: Array<any /*Type | Provider | any
|
||||
/* @ts2dart_Provider */ {provide: DomRootRenderer, useClass: DomRootRenderer_},
|
||||
/* @ts2dart_Provider */ {provide: RootRenderer, useExisting: DomRootRenderer},
|
||||
/* @ts2dart_Provider */ {provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||
/* @ts2dart_Provider */ {provide: XHR, useClass: XHRImpl},
|
||||
MessageBasedXHRImpl,
|
||||
/* @ts2dart_Provider */ {provide: ServiceMessageBrokerFactory, useClass: ServiceMessageBrokerFactory_},
|
||||
/* @ts2dart_Provider */ {provide: ClientMessageBrokerFactory, useClass: ClientMessageBrokerFactory_},
|
||||
Serializer,
|
||||
@ -107,9 +90,9 @@ export function initializeGenericWorkerRenderer(injector: Injector) {
|
||||
let zone = injector.get(NgZone);
|
||||
bus.attachToZone(zone);
|
||||
|
||||
zone.runGuarded(() => {
|
||||
WORKER_RENDER_MESSAGING_PROVIDERS.forEach((token) => { injector.get(token).start(); });
|
||||
});
|
||||
// initialize message services after the bus has been created
|
||||
let services = injector.get(WORKER_RENDER_STARTABLE_MESSAGING_SERVICE);
|
||||
zone.runGuarded(() => { services.forEach((svc) => { svc.start(); }); });
|
||||
}
|
||||
|
||||
export function initWebWorkerRenderPlatform(): void {
|
||||
|
@ -8,18 +8,18 @@ import 'dart:isolate';
|
||||
import 'dart:async';
|
||||
|
||||
export "package:angular2/src/platform/worker_app_common.dart"
|
||||
show WORKER_APP_PLATFORM, WORKER_APP_APPLICATION_COMMON;
|
||||
show WORKER_APP_PLATFORM_PROVIDERS, WORKER_APP_APPLICATION_COMMON_PROVIDERS;
|
||||
export "package:angular2/src/core/angular_entrypoint.dart"
|
||||
show AngularEntrypoint;
|
||||
export "package:angular2/src/platform/worker_app.dart"
|
||||
show WORKER_APP_APPLICATION, RENDER_SEND_PORT;
|
||||
show WORKER_APP_APPLICATION_PROVIDERS, RENDER_SEND_PORT;
|
||||
export 'package:angular2/src/web_workers/shared/client_message_broker.dart'
|
||||
show ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments;
|
||||
export 'package:angular2/src/web_workers/shared/service_message_broker.dart'
|
||||
show ReceivedMessage, ServiceMessageBroker, ServiceMessageBrokerFactory;
|
||||
export 'package:angular2/src/web_workers/shared/serializer.dart' show PRIMITIVE;
|
||||
export 'package:angular2/src/web_workers/shared/message_bus.dart';
|
||||
export 'package:angular2/src/web_workers/worker/router_providers.dart'
|
||||
export 'package:angular2/src/web_workers/worker/location_providers.dart'
|
||||
show WORKER_APP_ROUTER;
|
||||
|
||||
PlatformRef _platform = null;
|
||||
@ -28,13 +28,13 @@ SendPort _renderSendPort = null;
|
||||
PlatformRef workerAppPlatform(SendPort renderSendPort) {
|
||||
if (isBlank(getPlatform())) {
|
||||
createPlatform(ReflectiveInjector.resolveAndCreate([
|
||||
WORKER_APP_PLATFORM,
|
||||
WORKER_APP_PLATFORM_PROVIDERS,
|
||||
new Provider(RENDER_SEND_PORT, useValue: renderSendPort)
|
||||
]));
|
||||
}
|
||||
var platform = assertPlatform(WORKER_APP_PLATFORM_MARKER);
|
||||
if (platform.injector.get(RENDER_SEND_PORT, null) != renderSendPort) {
|
||||
throw 'Platform has already been created with a different SendPort. Please distroy it first.';
|
||||
throw 'Platform has already been created with a different SendPort. Please destroy it first.';
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
@ -44,7 +44,7 @@ Future<ComponentRef<dynamic>> bootstrapApp(
|
||||
Type appComponentType,
|
||||
[List<dynamic /*Type | Provider | any[]*/> customProviders]) {
|
||||
var appInjector = ReflectiveInjector.resolveAndCreate([
|
||||
WORKER_APP_APPLICATION,
|
||||
WORKER_APP_APPLICATION_PROVIDERS,
|
||||
isPresent(customProviders) ? customProviders : []
|
||||
], workerAppPlatform(renderSendPort).injector);
|
||||
return coreLoadAndBootstrap(appInjector, appComponentType);
|
||||
|
@ -1,6 +1,9 @@
|
||||
import {isPresent, isBlank} from './facade/lang';
|
||||
import {WORKER_APP_PLATFORM, WORKER_APP_PLATFORM_MARKER} from './webworker/worker_app_common';
|
||||
import {WORKER_APP_APPLICATION} from './webworker/worker_app';
|
||||
import {
|
||||
WORKER_APP_PLATFORM_PROVIDERS,
|
||||
WORKER_APP_PLATFORM_MARKER
|
||||
} from './webworker/worker_app_common';
|
||||
import {WORKER_APP_APPLICATION_PROVIDERS} from './webworker/worker_app';
|
||||
import {
|
||||
PlatformRef,
|
||||
Type,
|
||||
@ -12,8 +15,11 @@ import {
|
||||
assertPlatform
|
||||
} from '@angular/core';
|
||||
|
||||
export {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION_COMMON} from './webworker/worker_app_common';
|
||||
export {WORKER_APP_APPLICATION} from './webworker/worker_app';
|
||||
export {
|
||||
WORKER_APP_PLATFORM_PROVIDERS,
|
||||
WORKER_APP_APPLICATION_COMMON_PROVIDERS
|
||||
} from './webworker/worker_app_common';
|
||||
export {WORKER_APP_APPLICATION_PROVIDERS} from './webworker/worker_app';
|
||||
export {
|
||||
ClientMessageBroker,
|
||||
ClientMessageBrokerFactory,
|
||||
@ -27,20 +33,20 @@ export {
|
||||
} from './web_workers/shared/service_message_broker';
|
||||
export {PRIMITIVE} from './web_workers/shared/serializer';
|
||||
export * from './web_workers/shared/message_bus';
|
||||
export {WORKER_APP_ROUTER} from './web_workers/worker/router_providers';
|
||||
export {WORKER_APP_LOCATION_PROVIDERS} from './web_workers/worker/location_providers';
|
||||
|
||||
export function workerAppPlatform(): PlatformRef {
|
||||
if (isBlank(getPlatform())) {
|
||||
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_APP_PLATFORM));
|
||||
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_APP_PLATFORM_PROVIDERS));
|
||||
}
|
||||
return assertPlatform(WORKER_APP_PLATFORM_MARKER);
|
||||
}
|
||||
|
||||
export function bootstrapApp(
|
||||
export function bootstrapStaticApp(
|
||||
appComponentType: Type,
|
||||
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> {
|
||||
var appInjector = ReflectiveInjector.resolveAndCreate(
|
||||
[WORKER_APP_APPLICATION, isPresent(customProviders) ? customProviders : []],
|
||||
[WORKER_APP_APPLICATION_PROVIDERS, isPresent(customProviders) ? customProviders : []],
|
||||
workerAppPlatform().injector);
|
||||
return coreLoadAndBootstrap(appInjector, appComponentType);
|
||||
}
|
||||
|
@ -24,19 +24,19 @@ export '../src/web_workers/shared/service_message_broker.dart'
|
||||
|
||||
export '../src/web_workers/shared/serializer.dart' show PRIMITIVE;
|
||||
export '../src/web_workers/shared/message_bus.dart';
|
||||
export '../src/web_workers/ui/router_providers.dart' show WORKER_RENDER_ROUTER;
|
||||
export '../src/web_workers/ui/location_providers.dart' show WORKER_RENDER_ROUTER;
|
||||
|
||||
|
||||
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;
|
||||
|
||||
PlatformRef workerRenderPlatform() {
|
||||
PlatformRef workerStaticRenderPlatform() {
|
||||
if (isBlank(getPlatform())) {
|
||||
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM));
|
||||
}
|
||||
return assertPlatform(WORKER_RENDER_PLATFORM_MARKER);
|
||||
}
|
||||
|
||||
Future<ApplicationRef> bootstrapRender(
|
||||
Future<ApplicationRef> bootstrapStaticRender(
|
||||
String workerScriptUri,
|
||||
[List<dynamic /*Type | Provider | any[]*/> customProviders]) {
|
||||
return initIsolate(workerScriptUri).then( (appProviders) {
|
||||
|
@ -4,25 +4,28 @@ import {
|
||||
ApplicationRef,
|
||||
PlatformRef,
|
||||
ReflectiveInjector,
|
||||
Provider,
|
||||
getPlatform,
|
||||
createPlatform,
|
||||
assertPlatform
|
||||
} from '@angular/core';
|
||||
import {WORKER_RENDER_APPLICATION} from './webworker/worker_render';
|
||||
import {WORKER_RENDER_APPLICATION_PROVIDERS} from './webworker/worker_render';
|
||||
import {
|
||||
WORKER_SCRIPT,
|
||||
WORKER_RENDER_PLATFORM,
|
||||
WORKER_RENDER_PLATFORM_PROVIDERS,
|
||||
WORKER_RENDER_PLATFORM_MARKER
|
||||
} from './webworker/worker_render_common';
|
||||
|
||||
export {
|
||||
WORKER_SCRIPT,
|
||||
WORKER_RENDER_PLATFORM,
|
||||
WORKER_RENDER_PLATFORM_PROVIDERS,
|
||||
initializeGenericWorkerRenderer,
|
||||
WORKER_RENDER_APPLICATION_COMMON
|
||||
WORKER_RENDER_APPLICATION_COMMON_PROVIDERS
|
||||
} from './webworker/worker_render_common';
|
||||
export {WORKER_RENDER_APPLICATION, WebWorkerInstance} from './webworker/worker_render';
|
||||
export {
|
||||
WORKER_RENDER_APPLICATION_PROVIDERS,
|
||||
WORKER_RENDER_STARTABLE_MESSAGING_SERVICE,
|
||||
WebWorkerInstance
|
||||
} from './webworker/worker_render';
|
||||
export {
|
||||
ClientMessageBroker,
|
||||
ClientMessageBrokerFactory,
|
||||
@ -37,26 +40,21 @@ export {
|
||||
export {PRIMITIVE} from './web_workers/shared/serializer';
|
||||
export * from './web_workers/shared/message_bus';
|
||||
|
||||
/**
|
||||
* @deprecated Use WORKER_RENDER_APPLICATION
|
||||
*/
|
||||
export const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION;
|
||||
export {WORKER_RENDER_ROUTER} from '../src/web_workers/ui/router_providers';
|
||||
export {WORKER_RENDER_LOCATION_PROVIDERS} from '../src/web_workers/ui/location_providers';
|
||||
|
||||
export function workerRenderPlatform(): PlatformRef {
|
||||
if (isBlank(getPlatform())) {
|
||||
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM));
|
||||
createPlatform(ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM_PROVIDERS));
|
||||
}
|
||||
return assertPlatform(WORKER_RENDER_PLATFORM_MARKER);
|
||||
}
|
||||
|
||||
export function bootstrapRender(
|
||||
export function bootstrapStaticRender(
|
||||
workerScriptUri: string,
|
||||
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ApplicationRef> {
|
||||
var pf = ReflectiveInjector.resolveAndCreate(WORKER_RENDER_PLATFORM);
|
||||
var app = ReflectiveInjector.resolveAndCreate(
|
||||
[
|
||||
WORKER_RENDER_APPLICATION,
|
||||
WORKER_RENDER_APPLICATION_PROVIDERS,
|
||||
/* @ts2dart_Provider */ {provide: WORKER_SCRIPT, useValue: workerScriptUri},
|
||||
isPresent(customProviders) ? customProviders : []
|
||||
],
|
||||
|
@ -1,7 +0,0 @@
|
||||
library angular2.test.testing.testing_browser_pec;
|
||||
|
||||
/**
|
||||
* This is intentionally left blank. The public test lib is only for TS/JS
|
||||
* apps.
|
||||
*/
|
||||
main() {}
|
@ -1,194 +0,0 @@
|
||||
import {
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
describe,
|
||||
ddescribe,
|
||||
xdescribe,
|
||||
expect,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
inject,
|
||||
} from '@angular/core/testing';
|
||||
import {
|
||||
async,
|
||||
fakeAsync,
|
||||
flushMicrotasks,
|
||||
Log,
|
||||
tick,
|
||||
} from '@angular/core/testing';
|
||||
|
||||
import {ROUTER_FAKE_PROVIDERS} from '@angular/router/testing';
|
||||
import {ROUTER_DIRECTIVES, Routes, Route} from '@angular/router';
|
||||
|
||||
|
||||
import {Component, bind} from '@angular/core';
|
||||
import {PromiseWrapper} from '../src/facade/promise';
|
||||
import {XHR} from '@angular/compiler';
|
||||
import {XHRImpl} from '../../platform-browser-dynamic/src/xhr/xhr_impl';
|
||||
import {TestComponentBuilder} from '@angular/compiler/testing';
|
||||
|
||||
// Components for the tests.
|
||||
class FancyService {
|
||||
value: string = 'real value';
|
||||
getAsyncValue() { return Promise.resolve('async value'); }
|
||||
getTimeoutValue() {
|
||||
return new Promise((resolve, reject) => { setTimeout(() => {resolve('timeout value')}, 10); })
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'external-template-comp',
|
||||
templateUrl: '/base/modules/@angular/platform-browser/test/static_assets/test.html'
|
||||
})
|
||||
class ExternalTemplateComp {
|
||||
}
|
||||
|
||||
@Component({selector: 'bad-template-comp', templateUrl: 'non-existant.html'})
|
||||
class BadTemplateUrl {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'test-router-cmp',
|
||||
template: `<a [routerLink]="['One']">one</a> <a [routerLink]="['Two']">two</a><router-outlet></router-outlet>`,
|
||||
directives: [ROUTER_DIRECTIVES]
|
||||
})
|
||||
@Routes([
|
||||
new Route({path: '/One', component: BadTemplateUrl}),
|
||||
new Route({path: '/Two', component: ExternalTemplateComp}),
|
||||
])
|
||||
class TestRouterComponent {
|
||||
}
|
||||
|
||||
// Tests for angular2/testing bundle specific to the browser environment.
|
||||
// For general tests, see test/testing/testing_public_spec.ts.
|
||||
export function main() {
|
||||
describe('test APIs for the browser', () => {
|
||||
describe('angular2 jasmine matchers', () => {
|
||||
describe('toHaveCssClass', () => {
|
||||
it('should assert that the CSS class is present', () => {
|
||||
var el = document.createElement('div');
|
||||
el.classList.add('matias');
|
||||
expect(el).toHaveCssClass('matias');
|
||||
});
|
||||
|
||||
it('should assert that the CSS class is not present', () => {
|
||||
var el = document.createElement('div');
|
||||
el.classList.add('matias');
|
||||
expect(el).not.toHaveCssClass('fatias');
|
||||
});
|
||||
});
|
||||
|
||||
describe('toHaveCssStyle', () => {
|
||||
it('should assert that the CSS style is present', () => {
|
||||
var el = document.createElement('div');
|
||||
expect(el).not.toHaveCssStyle('width');
|
||||
|
||||
el.style.setProperty('width', '100px');
|
||||
expect(el).toHaveCssStyle('width');
|
||||
});
|
||||
|
||||
it('should assert that the styles are matched against the element', () => {
|
||||
var el = document.createElement('div');
|
||||
expect(el).not.toHaveCssStyle({width: '100px', height: '555px'});
|
||||
|
||||
el.style.setProperty('width', '100px');
|
||||
expect(el).toHaveCssStyle({width: '100px'});
|
||||
expect(el).not.toHaveCssStyle({width: '100px', height: '555px'});
|
||||
|
||||
el.style.setProperty('height', '555px');
|
||||
expect(el).toHaveCssStyle({height: '555px'});
|
||||
expect(el).toHaveCssStyle({width: '100px', height: '555px'});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('using the async helper', () => {
|
||||
var actuallyDone: boolean;
|
||||
|
||||
beforeEach(() => { actuallyDone = false; });
|
||||
|
||||
afterEach(() => { expect(actuallyDone).toEqual(true); });
|
||||
|
||||
it('should run async tests with XHRs', async(() => {
|
||||
var xhr = new XHRImpl();
|
||||
xhr.get('/base/modules/@angular/platform-browser/test/static_assets/test.html')
|
||||
.then(() => { actuallyDone = true; });
|
||||
}),
|
||||
10000); // Long timeout here because this test makes an actual XHR.
|
||||
});
|
||||
|
||||
describe('using the test injector with the inject helper', () => {
|
||||
describe('setting up Providers', () => {
|
||||
beforeEachProviders(() => [bind(FancyService).toValue(new FancyService())]);
|
||||
|
||||
it('provides a real XHR instance',
|
||||
inject([XHR], (xhr) => { expect(xhr).toBeAnInstanceOf(XHRImpl); }));
|
||||
|
||||
it('should allow the use of fakeAsync', fakeAsync(inject([FancyService], (service) => {
|
||||
var value;
|
||||
service.getAsyncValue().then(function(val) { value = val; });
|
||||
tick();
|
||||
expect(value).toEqual('async value');
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
||||
describe('errors', () => {
|
||||
var originalJasmineIt: any;
|
||||
|
||||
var patchJasmineIt = () => {
|
||||
var deferred = PromiseWrapper.completer();
|
||||
originalJasmineIt = jasmine.getEnv().it;
|
||||
jasmine.getEnv().it = (description: string, fn) => {
|
||||
var done = () => { deferred.resolve() };
|
||||
(<any>done).fail = (err) => { deferred.reject(err) };
|
||||
fn(done);
|
||||
return null;
|
||||
};
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var restoreJasmineIt = () => { jasmine.getEnv().it = originalJasmineIt; };
|
||||
|
||||
it('should fail when an XHR fails', (done) => {
|
||||
var itPromise = patchJasmineIt();
|
||||
|
||||
it('should fail with an error from a promise',
|
||||
async(inject([TestComponentBuilder],
|
||||
(tcb) => { return tcb.createAsync(BadTemplateUrl); })));
|
||||
|
||||
itPromise.then(() => { done.fail('Expected test to fail, but it did not'); }, (err) => {
|
||||
expect(err).toEqual('Uncaught (in promise): Failed to load non-existant.html');
|
||||
done();
|
||||
});
|
||||
restoreJasmineIt();
|
||||
}, 10000);
|
||||
});
|
||||
|
||||
describe('test component builder', function() {
|
||||
it('should allow an external templateUrl',
|
||||
async(inject([TestComponentBuilder],
|
||||
(tcb: TestComponentBuilder) => {
|
||||
|
||||
tcb.createAsync(ExternalTemplateComp)
|
||||
.then((componentFixture) => {
|
||||
componentFixture.detectChanges();
|
||||
expect(componentFixture.debugElement.nativeElement)
|
||||
.toHaveText('from external template\n');
|
||||
});
|
||||
})),
|
||||
10000); // Long timeout here because this test makes an actual XHR, and is slow on Edge.
|
||||
});
|
||||
});
|
||||
|
||||
describe('apps with router components', () => {
|
||||
beforeEachProviders(() => [ROUTER_FAKE_PROVIDERS]);
|
||||
|
||||
it('should build without a problem',
|
||||
async(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
tcb.createAsync(TestRouterComponent)
|
||||
.then((fixture) => { expect(fixture.nativeElement).toHaveText('one two'); });
|
||||
})));
|
||||
});
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
import {
|
||||
inject,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
beforeEachProviders
|
||||
} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {SpyMessageBroker} from './spies';
|
||||
import {WebWorkerXHRImpl} from '@angular/platform-browser/src/web_workers/worker/xhr_impl';
|
||||
import {PromiseWrapper} from '../../../src/facade/async';
|
||||
import {MockMessageBrokerFactory, expectBrokerCall} from '../shared/web_worker_test_util';
|
||||
|
||||
export function main() {
|
||||
describe("WebWorkerXHRImpl", () => {
|
||||
it("should pass requests through the broker and return the response",
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
const URL = "http://www.example.com/test";
|
||||
const RESPONSE = "Example response text";
|
||||
|
||||
var messageBroker = new SpyMessageBroker();
|
||||
expectBrokerCall(messageBroker, "get", [URL],
|
||||
(_) => { return PromiseWrapper.wrap(() => { return RESPONSE; }); });
|
||||
var xhrImpl = new WebWorkerXHRImpl(new MockMessageBrokerFactory(<any>messageBroker));
|
||||
xhrImpl.get(URL).then((response) => {
|
||||
expect(response).toEqual(RESPONSE);
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
export * from './testing/browser_util';
|
||||
export * from './testing/browser_static';
|
||||
export * from './testing/matchers';
|
||||
export * from './testing/dom_test_component_renderer';
|
||||
|
@ -1,26 +1,14 @@
|
||||
import {
|
||||
APP_ID,
|
||||
NgZone,
|
||||
Provider,
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
PLATFORM_INITIALIZER
|
||||
} from '@angular/core';
|
||||
import {DirectiveResolver, ViewResolver, XHR} from '@angular/compiler';
|
||||
import {APP_ID, NgZone, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER} from '@angular/core';
|
||||
import {BROWSER_APP_COMMON_PROVIDERS} from '../src/browser_common';
|
||||
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
||||
import {AnimationBuilder} from '../src/animate/animation_builder';
|
||||
import {MockAnimationBuilder} from './animation_builder_mock';
|
||||
import {MockDirectiveResolver} from '@angular/compiler/testing';
|
||||
import {MockViewResolver} from '@angular/compiler/testing';
|
||||
import {MockLocationStrategy} from '@angular/common/testing';
|
||||
import {LocationStrategy} from '@angular/common';
|
||||
import {MockNgZone} from '@angular/core/testing';
|
||||
import {TestComponentBuilder} from '@angular/compiler/testing';
|
||||
import {BrowserDetection} from './browser_util';
|
||||
import {Log} from '@angular/core/testing';
|
||||
import {ELEMENT_PROBE_PROVIDERS} from '../src/dom/debug/ng_probe';
|
||||
import {TestComponentRenderer} from '@angular/compiler/testing';
|
||||
import {DOMTestComponentRenderer} from './dom_test_component_renderer';
|
||||
import {IS_DART} from '../src/facade/lang';
|
||||
|
||||
function initBrowserTests() {
|
||||
@ -32,8 +20,6 @@ function createNgZone(): NgZone {
|
||||
return IS_DART ? new MockNgZone() : new NgZone({enableLongStackTrace: true});
|
||||
}
|
||||
|
||||
export {TestComponentRenderer} from '@angular/compiler/testing';
|
||||
|
||||
/**
|
||||
* Default platform providers for testing without a compiler.
|
||||
*/
|
||||
@ -47,14 +33,10 @@ export const ADDITIONAL_TEST_BROWSER_PROVIDERS: Array<any /*Type | Provider | an
|
||||
/*@ts2dart_const*/[
|
||||
/*@ts2dart_Provider*/ {provide: APP_ID, useValue: 'a'},
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
/*@ts2dart_Provider*/ {provide: DirectiveResolver, useClass: MockDirectiveResolver},
|
||||
/*@ts2dart_Provider*/ {provide: ViewResolver, useClass: MockViewResolver},
|
||||
Log,
|
||||
TestComponentBuilder,
|
||||
/*@ts2dart_Provider*/ {provide: NgZone, useFactory: createNgZone},
|
||||
/*@ts2dart_Provider*/ {provide: LocationStrategy, useClass: MockLocationStrategy},
|
||||
/*@ts2dart_Provider*/ {provide: AnimationBuilder, useClass: MockAnimationBuilder},
|
||||
/*@ts2dart_Provider*/ {provide: TestComponentRenderer, useClass: DOMTestComponentRenderer}
|
||||
/*@ts2dart_Provider*/ {provide: AnimationBuilder, useClass: MockAnimationBuilder}
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,8 @@ export class BrowserDetection {
|
||||
}
|
||||
|
||||
get isChromeDesktop(): boolean {
|
||||
return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 && this._ua.indexOf('Edge') == -1;
|
||||
return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&
|
||||
this._ua.indexOf('Edge') == -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
import {Inject, Injectable} from '@angular/core';
|
||||
import {DOCUMENT} from '../src/dom/dom_tokens';
|
||||
import {getDOM} from '../src/dom/dom_adapter';
|
||||
import {TestComponentRenderer} from '@angular/compiler/testing';
|
||||
import {el} from './browser_util';
|
||||
|
||||
/**
|
||||
* A DOM based implementation of the TestComponentRenderer.
|
||||
*/
|
||||
@Injectable()
|
||||
export class DOMTestComponentRenderer extends TestComponentRenderer {
|
||||
constructor(@Inject(DOCUMENT) private _doc) { super(); }
|
||||
|
||||
insertRootElement(rootElId: string) {
|
||||
let rootEl = el(`<div id="${rootElId}"></div>`);
|
||||
|
||||
// TODO(juliemr): can/should this be optional?
|
||||
let oldRoots = getDOM().querySelectorAll(this._doc, '[id^=root]');
|
||||
for (let i = 0; i < oldRoots.length; i++) {
|
||||
getDOM().remove(oldRoots[i]);
|
||||
}
|
||||
getDOM().appendChild(this._doc.body, rootEl);
|
||||
}
|
||||
}
|
@ -15,9 +15,7 @@
|
||||
"@angular/core": ["../../../dist/packages-dist/core"],
|
||||
"@angular/core/testing": ["../../../dist/packages-dist/core/testing"],
|
||||
"@angular/common": ["../../../dist/packages-dist/common"],
|
||||
"@angular/common/testing": ["../../../dist/packages-dist/common/testing"],
|
||||
"@angular/compiler": ["../../../dist/packages-dist/compiler"],
|
||||
"@angular/compiler/testing": ["../../../dist/packages-dist/compiler/testing"]
|
||||
"@angular/common/testing": ["../../../dist/packages-dist/common/testing"]
|
||||
},
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
|
@ -15,9 +15,7 @@
|
||||
"@angular/core": ["../../../dist/packages-dist/core"],
|
||||
"@angular/core/testing": ["../../../dist/packages-dist/core/testing"],
|
||||
"@angular/common": ["../../../dist/packages-dist/common"],
|
||||
"@angular/common/testing": ["../../../dist/packages-dist/common/testing"],
|
||||
"@angular/compiler": ["../../../dist/packages-dist/compiler"],
|
||||
"@angular/compiler/testing": ["../../../dist/packages-dist/compiler/testing"]
|
||||
"@angular/common/testing": ["../../../dist/packages-dist/common/testing"]
|
||||
},
|
||||
"rootDir": ".",
|
||||
"sourceMap": true,
|
||||
|
Reference in New Issue
Block a user