From 736871edaafaada50df921a290fb2c0704ce1e71 Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Thu, 10 Dec 2015 16:11:53 -0800 Subject: [PATCH 1/2] fix(compiler): remove AppRootUrl Related to #5815 This should not break anything because AppRootUrl wasn't actually being used by the compiler anymore. --- modules/angular2/angular2.dart | 1 - modules/angular2/compiler.ts | 3 +-- .../src/compiler/anchor_based_app_root_url.ts | 10 ++++------ modules/angular2/src/compiler/app_root_url.ts | 16 ---------------- modules/angular2/src/compiler/compiler.ts | 2 -- .../angular2/src/platform/worker_app_common.ts | 2 -- .../src/platform/worker_render_common.ts | 2 -- modules/angular2/web_worker/worker.ts | 2 +- 8 files changed, 6 insertions(+), 32 deletions(-) delete mode 100644 modules/angular2/src/compiler/app_root_url.ts diff --git a/modules/angular2/angular2.dart b/modules/angular2/angular2.dart index 07129721736e..6dd8a9c701fa 100644 --- a/modules/angular2/angular2.dart +++ b/modules/angular2/angular2.dart @@ -16,4 +16,3 @@ export 'package:angular2/src/platform/dom/dom_tokens.dart'; export 'package:angular2/src/platform/dom/dom_adapter.dart'; export 'package:angular2/src/platform/dom/events/event_manager.dart'; export 'package:angular2/src/compiler/url_resolver.dart'; -export 'package:angular2/src/compiler/app_root_url.dart'; diff --git a/modules/angular2/compiler.ts b/modules/angular2/compiler.ts index b7a776c8cc94..57856c054b5f 100644 --- a/modules/angular2/compiler.ts +++ b/modules/angular2/compiler.ts @@ -5,5 +5,4 @@ */ export * from './src/compiler/url_resolver'; export * from './src/compiler/xhr'; -export * from './src/compiler/compiler'; -export * from './src/compiler/app_root_url'; \ No newline at end of file +export * from './src/compiler/compiler'; \ No newline at end of file diff --git a/modules/angular2/src/compiler/anchor_based_app_root_url.ts b/modules/angular2/src/compiler/anchor_based_app_root_url.ts index 7e59c0b553a3..c0a347de99da 100644 --- a/modules/angular2/src/compiler/anchor_based_app_root_url.ts +++ b/modules/angular2/src/compiler/anchor_based_app_root_url.ts @@ -1,16 +1,14 @@ -import {AppRootUrl} from "angular2/src/compiler/app_root_url"; import {DOM} from "angular2/src/platform/dom/dom_adapter"; import {Injectable} from "angular2/src/core/di"; /** - * Extension of {@link AppRootUrl} that uses a DOM anchor tag to set the root url to - * the current page's url. + * Set the root url to the current page's url. */ @Injectable() -export class AnchorBasedAppRootUrl extends AppRootUrl { +export class AnchorBasedAppRootUrl { + value: string; constructor() { - super(""); - // compute the root url to pass to AppRootUrl + // compute the root url var a = DOM.createElement('a'); DOM.resolveAndSetHref(a, './', null); this.value = DOM.getHref(a); diff --git a/modules/angular2/src/compiler/app_root_url.ts b/modules/angular2/src/compiler/app_root_url.ts deleted file mode 100644 index 6c88be7045ed..000000000000 --- a/modules/angular2/src/compiler/app_root_url.ts +++ /dev/null @@ -1,16 +0,0 @@ -import {Injectable} from 'angular2/src/core/di'; -import {isBlank} from 'angular2/src/facade/lang'; - -/** - * Specifies app root url for the application. - * - * Used by the {@link Compiler} when resolving HTML and CSS template URLs. - * - * This interface can be overridden by the application developer to create custom behavior. - * - * See {@link Compiler} - */ -@Injectable() -export class AppRootUrl { - constructor(public value: string) {} -} diff --git a/modules/angular2/src/compiler/compiler.ts b/modules/angular2/src/compiler/compiler.ts index 93e4c3e32c20..4ca4311835ff 100644 --- a/modules/angular2/src/compiler/compiler.ts +++ b/modules/angular2/src/compiler/compiler.ts @@ -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 {AppRootUrl} from 'angular2/src/compiler/app_root_url'; import {AnchorBasedAppRootUrl} from 'angular2/src/compiler/anchor_based_app_root_url'; import {Parser, Lexer} from 'angular2/src/core/change_detection/change_detection'; @@ -51,6 +50,5 @@ export const COMPILER_PROVIDERS: Array = CONST_EXPR([ DomElementSchemaRegistry, new Provider(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}), AnchorBasedAppRootUrl, - new Provider(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}), UrlResolver ]); diff --git a/modules/angular2/src/platform/worker_app_common.ts b/modules/angular2/src/platform/worker_app_common.ts index af7eadc416a4..fef90aaf1dd9 100644 --- a/modules/angular2/src/platform/worker_app_common.ts +++ b/modules/angular2/src/platform/worker_app_common.ts @@ -1,7 +1,6 @@ import {XHR} from 'angular2/src/compiler/xhr'; import {WebWorkerXHRImpl} from 'angular2/src/web_workers/worker/xhr_impl'; import {ListWrapper} from 'angular2/src/facade/collection'; -import {AppRootUrl} from 'angular2/src/compiler/app_root_url'; import {WebWorkerRenderer} from 'angular2/src/web_workers/worker/renderer'; import {print, Type, CONST_EXPR, isPresent} from 'angular2/src/facade/lang'; import {MessageBus} from 'angular2/src/web_workers/shared/message_bus'; @@ -86,7 +85,6 @@ export function genericWorkerAppProviders(bus: MessageBus, subscription = ObservableWrapper.subscribe(emitter, (initData: {[key: string]: any}) => { var bindings = ListWrapper.concat(WORKER_APP_COMMON_PROVIDERS, [ new Provider(MessageBus, {useValue: bus}), - new Provider(AppRootUrl, {useValue: new AppRootUrl(initData['rootUrl'])}), ]); bootstrapProcess.resolve(bindings); ObservableWrapper.dispose(subscription); diff --git a/modules/angular2/src/platform/worker_render_common.ts b/modules/angular2/src/platform/worker_render_common.ts index 7f950c01fed8..288c071363a4 100644 --- a/modules/angular2/src/platform/worker_render_common.ts +++ b/modules/angular2/src/platform/worker_render_common.ts @@ -2,7 +2,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 {AppRootUrl} from 'angular2/src/compiler/app_root_url'; import { PLATFORM_DIRECTIVES, PLATFORM_PIPES, @@ -83,7 +82,6 @@ export const WORKER_RENDER_APP_COMMON: Array = new Provider(ServiceMessageBrokerFactory, {useClass: ServiceMessageBrokerFactory_}), new Provider(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}), AnchorBasedAppRootUrl, - new Provider(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}), Serializer, new Provider(ON_WEB_WORKER, {useValue: false}), RenderViewWithFragmentsStore, diff --git a/modules/angular2/web_worker/worker.ts b/modules/angular2/web_worker/worker.ts index a540cff63f3c..a444f923ce76 100644 --- a/modules/angular2/web_worker/worker.ts +++ b/modules/angular2/web_worker/worker.ts @@ -1,6 +1,6 @@ export * from '../common'; export * from '../core'; export * from '../platform/worker_app'; -export {UrlResolver, AppRootUrl} from '../compiler'; +export {UrlResolver} from '../compiler'; export * from '../instrumentation'; export * from 'angular2/src/platform/worker_app'; From d367a8a7163847fd69a0b61b78ea813312b224c1 Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Thu, 10 Dec 2015 16:24:46 -0800 Subject: [PATCH 2/2] 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 --- .../src/compiler/anchor_based_app_root_url.ts | 16 ----------- modules/angular2/src/compiler/compiler.ts | 2 -- .../src/platform/worker_app_common.ts | 23 ++++------------ .../angular2/src/platform/worker_render.ts | 1 - .../src/platform/worker_render_common.ts | 5 +--- .../src/web_workers/shared/messaging_api.ts | 1 - modules/angular2/src/web_workers/ui/setup.ts | 27 ------------------- modules/angular2/test/public_api_spec.ts | 3 --- 8 files changed, 6 insertions(+), 72 deletions(-) delete mode 100644 modules/angular2/src/compiler/anchor_based_app_root_url.ts delete mode 100644 modules/angular2/src/web_workers/ui/setup.ts diff --git a/modules/angular2/src/compiler/anchor_based_app_root_url.ts b/modules/angular2/src/compiler/anchor_based_app_root_url.ts deleted file mode 100644 index c0a347de99da..000000000000 --- a/modules/angular2/src/compiler/anchor_based_app_root_url.ts +++ /dev/null @@ -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); - } -} diff --git a/modules/angular2/src/compiler/compiler.ts b/modules/angular2/src/compiler/compiler.ts index 4ca4311835ff..76a112f8798e 100644 --- a/modules/angular2/src/compiler/compiler.ts +++ b/modules/angular2/src/compiler/compiler.ts @@ -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 = CONST_EXPR([ new Provider(Compiler, {useExisting: RuntimeCompiler}), DomElementSchemaRegistry, new Provider(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}), - AnchorBasedAppRootUrl, UrlResolver ]); diff --git a/modules/angular2/src/platform/worker_app_common.ts b/modules/angular2/src/platform/worker_app_common.ts index fef90aaf1dd9..c924180fac2f 100644 --- a/modules/angular2/src/platform/worker_app_common.ts +++ b/modules/angular2/src/platform/worker_app_common.ts @@ -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> { - var bootstrapProcess: PromiseCompleter = 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); } diff --git a/modules/angular2/src/platform/worker_render.ts b/modules/angular2/src/platform/worker_render.ts index c80bd35fb1af..858ee860fabe 100644 --- a/modules/angular2/src/platform/worker_render.ts +++ b/modules/angular2/src/platform/worker_render.ts @@ -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 { diff --git a/modules/angular2/src/platform/worker_render_common.ts b/modules/angular2/src/platform/worker_render_common.ts index 288c071363a4..cf5c965d9205 100644 --- a/modules/angular2/src/platform/worker_render_common.ts +++ b/modules/angular2/src/platform/worker_render_common.ts @@ -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 = - CONST_EXPR([MessageBasedRenderer, MessageBasedXHRImpl, WebWorkerSetup]); + CONST_EXPR([MessageBasedRenderer, MessageBasedXHRImpl]); export const WORKER_RENDER_PLATFORM: Array = CONST_EXPR([ PLATFORM_COMMON_PROVIDERS, @@ -81,7 +79,6 @@ export const WORKER_RENDER_APP_COMMON: Array = MessageBasedXHRImpl, new Provider(ServiceMessageBrokerFactory, {useClass: ServiceMessageBrokerFactory_}), new Provider(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}), - AnchorBasedAppRootUrl, Serializer, new Provider(ON_WEB_WORKER, {useValue: false}), RenderViewWithFragmentsStore, diff --git a/modules/angular2/src/web_workers/shared/messaging_api.ts b/modules/angular2/src/web_workers/shared/messaging_api.ts index 8f12ea3b0731..e84a6b03e1af 100644 --- a/modules/angular2/src/web_workers/shared/messaging_api.ts +++ b/modules/angular2/src/web_workers/shared/messaging_api.ts @@ -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"; diff --git a/modules/angular2/src/web_workers/ui/setup.ts b/modules/angular2/src/web_workers/ui/setup.ts deleted file mode 100644 index 3381e897f89a..000000000000 --- a/modules/angular2/src/web_workers/ui/setup.ts +++ /dev/null @@ -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}); - } - }); - } -} diff --git a/modules/angular2/test/public_api_spec.ts b/modules/angular2/test/public_api_spec.ts index 4177ee25bb1e..74023fa563f0 100644 --- a/modules/angular2/test/public_api_spec.ts +++ b/modules/angular2/test/public_api_spec.ts @@ -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()",