fix(web_workers): remove unnecessary setup module and AppRootUrl
Since AppRootUrl is removed, the logic for extending and emitting the root url as part of the setup seems unnecessary. BREAKING CHANGES: The setupWebWorker function exported from angular2/platform/worker_app no longer returns a promise of providers, but instead synchronously returns providers. Related to #5815 Closes #5820
This commit is contained in:
parent
ed2c25eb2f
commit
a885f37dfa
|
@ -1,16 +0,0 @@
|
|||
import {DOM} from "angular2/src/platform/dom/dom_adapter";
|
||||
import {Injectable} from "angular2/src/core/di";
|
||||
|
||||
/**
|
||||
* Set the root url to the current page's url.
|
||||
*/
|
||||
@Injectable()
|
||||
export class AnchorBasedAppRootUrl {
|
||||
value: string;
|
||||
constructor() {
|
||||
// compute the root url
|
||||
var a = DOM.createElement('a');
|
||||
DOM.resolveAndSetHref(a, './', null);
|
||||
this.value = DOM.getHref(a);
|
||||
}
|
||||
}
|
|
@ -25,7 +25,6 @@ import {RuntimeCompiler} from 'angular2/src/compiler/runtime_compiler';
|
|||
import {ElementSchemaRegistry} from 'angular2/src/compiler/schema/element_schema_registry';
|
||||
import {DomElementSchemaRegistry} from 'angular2/src/compiler/schema/dom_element_schema_registry';
|
||||
import {UrlResolver, DEFAULT_PACKAGE_URL_PROVIDER} from 'angular2/src/compiler/url_resolver';
|
||||
import {AnchorBasedAppRootUrl} from 'angular2/src/compiler/anchor_based_app_root_url';
|
||||
import {Parser, Lexer} from 'angular2/src/core/change_detection/change_detection';
|
||||
|
||||
function _createChangeDetectorGenConfig() {
|
||||
|
@ -49,6 +48,5 @@ export const COMPILER_PROVIDERS: Array<Type | Provider | any[]> = CONST_EXPR([
|
|||
new Provider(Compiler, {useExisting: RuntimeCompiler}),
|
||||
DomElementSchemaRegistry,
|
||||
new Provider(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}),
|
||||
AnchorBasedAppRootUrl,
|
||||
UrlResolver
|
||||
]);
|
||||
|
|
|
@ -31,9 +31,7 @@ import {
|
|||
} from 'angular2/src/web_workers/shared/render_view_with_fragments_store';
|
||||
import {WebWorkerEventDispatcher} from 'angular2/src/web_workers/worker/event_dispatcher';
|
||||
import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
||||
import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/facade/async';
|
||||
import {SETUP_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
|
||||
import {ObservableWrapper} from 'angular2/src/facade/async';
|
||||
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
class PrintLogger {
|
||||
log = print;
|
||||
|
@ -76,20 +74,9 @@ function _exceptionHandler(): ExceptionHandler {
|
|||
*/
|
||||
export function genericWorkerAppProviders(bus: MessageBus,
|
||||
zone: NgZone): Promise<Array<Type | Provider | any[]>> {
|
||||
var bootstrapProcess: PromiseCompleter<any> = PromiseWrapper.completer();
|
||||
bus.attachToZone(zone);
|
||||
bus.initChannel(SETUP_CHANNEL, false);
|
||||
|
||||
var subscription: any;
|
||||
var emitter = bus.from(SETUP_CHANNEL);
|
||||
subscription = ObservableWrapper.subscribe(emitter, (initData: {[key: string]: any}) => {
|
||||
var bindings = ListWrapper.concat(WORKER_APP_COMMON_PROVIDERS, [
|
||||
new Provider(MessageBus, {useValue: bus}),
|
||||
]);
|
||||
bootstrapProcess.resolve(bindings);
|
||||
ObservableWrapper.dispose(subscription);
|
||||
});
|
||||
|
||||
ObservableWrapper.callNext(bus.to(SETUP_CHANNEL), "ready");
|
||||
return bootstrapProcess.promise;
|
||||
var bindings = ListWrapper.concat(WORKER_APP_COMMON_PROVIDERS, [
|
||||
new Provider(MessageBus, {useValue: bus}),
|
||||
]);
|
||||
return PromiseWrapper.resolve(bindings);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import {
|
|||
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
|
||||
import {APP_INITIALIZER} from 'angular2/core';
|
||||
import {Injector, Injectable, Provider} from 'angular2/src/core/di';
|
||||
import {WebWorkerSetup} from 'angular2/src/web_workers/ui/setup';
|
||||
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';
|
||||
import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl';
|
||||
import {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {CONST_EXPR, IS_DART} from 'angular2/src/facade/lang';
|
||||
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
|
||||
import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
||||
import {AnchorBasedAppRootUrl} from 'angular2/src/compiler/anchor_based_app_root_url';
|
||||
import {
|
||||
PLATFORM_DIRECTIVES,
|
||||
PLATFORM_PIPES,
|
||||
|
@ -35,7 +34,6 @@ import {Testability} from 'angular2/src/core/testability/testability';
|
|||
import {BrowserGetTestability} from 'angular2/src/platform/browser/testability';
|
||||
import {BrowserDomAdapter} from './browser/browser_adapter';
|
||||
import {wtfInit} from 'angular2/src/core/profile/wtf_init';
|
||||
import {WebWorkerSetup} from 'angular2/src/web_workers/ui/setup';
|
||||
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';
|
||||
import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl';
|
||||
import {
|
||||
|
@ -57,7 +55,7 @@ export const WORKER_SCRIPT: OpaqueToken = CONST_EXPR(new OpaqueToken("WebWorkerS
|
|||
|
||||
// Message based Worker classes that listen on the MessageBus
|
||||
export const WORKER_RENDER_MESSAGING_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
CONST_EXPR([MessageBasedRenderer, MessageBasedXHRImpl, WebWorkerSetup]);
|
||||
CONST_EXPR([MessageBasedRenderer, MessageBasedXHRImpl]);
|
||||
|
||||
export const WORKER_RENDER_PLATFORM: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
|
@ -81,7 +79,6 @@ export const WORKER_RENDER_APP_COMMON: Array<any /*Type | Provider | any[]*/> =
|
|||
MessageBasedXHRImpl,
|
||||
new Provider(ServiceMessageBrokerFactory, {useClass: ServiceMessageBrokerFactory_}),
|
||||
new Provider(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}),
|
||||
AnchorBasedAppRootUrl,
|
||||
Serializer,
|
||||
new Provider(ON_WEB_WORKER, {useValue: false}),
|
||||
RenderViewWithFragmentsStore,
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* All channels used by angular's WebWorker components are listed here.
|
||||
* You should not use these channels in your application code.
|
||||
*/
|
||||
export const SETUP_CHANNEL = "ng-WebWorkerSetup";
|
||||
export const RENDERER_CHANNEL = "ng-Renderer";
|
||||
export const XHR_CHANNEL = "ng-XHR";
|
||||
export const EVENT_CHANNEL = "ng-events";
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
import {SETUP_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
|
||||
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
|
||||
import {AnchorBasedAppRootUrl} from 'angular2/src/compiler/anchor_based_app_root_url';
|
||||
import {StringWrapper} from 'angular2/src/facade/lang';
|
||||
import {Injectable} from 'angular2/src/core/di';
|
||||
|
||||
@Injectable()
|
||||
export class WebWorkerSetup {
|
||||
rootUrl: string;
|
||||
|
||||
constructor(private _bus: MessageBus, anchorBasedAppRootUrl: AnchorBasedAppRootUrl) {
|
||||
this.rootUrl = anchorBasedAppRootUrl.value;
|
||||
}
|
||||
|
||||
start(): void {
|
||||
this._bus.initChannel(SETUP_CHANNEL, false);
|
||||
var sink = this._bus.to(SETUP_CHANNEL);
|
||||
var source = this._bus.from(SETUP_CHANNEL);
|
||||
|
||||
ObservableWrapper.subscribe(source, (message: string) => {
|
||||
if (StringWrapper.equals(message, "ready")) {
|
||||
ObservableWrapper.callEmit(sink, {"rootUrl": this.rootUrl});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -614,9 +614,6 @@ var NG_COMPILER = [
|
|||
"VariableAst.sourceSpan=",
|
||||
"VariableAst.value",
|
||||
"VariableAst.value=",
|
||||
"AppRootUrl",
|
||||
"AppRootUrl.value",
|
||||
"AppRootUrl.value=",
|
||||
"DEFAULT_PACKAGE_URL_PROVIDER",
|
||||
"UrlResolver",
|
||||
"UrlResolver.resolve()",
|
||||
|
|
Loading…
Reference in New Issue