From 6e62217b784b670c114b6eaa8e319a8fe44b1855 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 13 May 2016 13:22:29 -0700 Subject: [PATCH] fix(WebWorker): remove the platform-browser dependency on compiler --- build.sh | 2 +- .../integrationtest/test/basic_spec.ts | 6 +- .../core/src/platform_common_providers.ts | 4 +- modules/@angular/facade/src/lang.dart | 4 + modules/@angular/facade/src/lang.ts | 2 + .../integration_test/public_api_spec.ts | 45 +- .../platform-browser-dynamic/index.ts | 5 +- .../platform_browser_private.ts | 5 +- .../{ => src}/platform_browser_dynamic.ts | 26 +- .../src/web_workers/shared/messaging_api.ts | 5 + .../src/web_workers/ui/xhr_impl.ts | 23 ++ .../src/web_workers/worker/xhr_impl.ts | 10 +- .../src/worker_app.ts | 28 ++ .../src/worker_render.ts | 38 ++ .../test/static_assets/test.html | 1 + .../test/testing_public_browser_spec.dart | 0 .../test/testing_public_browser_spec.ts | 0 .../test/web_workers/worker/xhr_impl_spec.ts | 19 +- .../platform-browser-dynamic/testing.ts | 1 + .../testing/browser.ts | 23 +- .../testing/dom_test_component_renderer.ts | 6 +- modules/@angular/platform-browser/index.ts | 5 + .../platform-browser/private_export.ts | 2 +- .../platform-browser/src/browser_common.ts | 14 +- .../platform-browser/src/platform_browser.ts | 24 +- .../src/platform_browser_static.ts | 7 +- .../src/web_workers/shared/api.ts | 2 +- .../src/web_workers/shared/message_bus.ts | 3 +- .../src/web_workers/shared/messaging_api.ts | 1 - .../web_workers/shared/post_message_bus.ts | 3 +- .../src/web_workers/shared/render_store.ts | 2 +- .../shared/service_message_broker.ts | 2 +- .../src/web_workers/ui/bind.dart | 11 - .../src/web_workers/ui/bind.ts | 3 - .../src/web_workers/ui/location_providers.ts | 21 + .../src/web_workers/ui/platform_location.ts | 39 +- .../src/web_workers/ui/renderer.ts | 45 +- .../src/web_workers/ui/router_providers.ts | 19 - .../src/web_workers/ui/xhr_impl.ts | 16 - .../web_workers/worker/location_providers.ts | 22 + .../web_workers/worker/platform_location.ts | 4 +- .../src/web_workers/worker/renderer.ts | 21 +- .../web_workers/worker/router_providers.ts | 20 - .../web_workers/worker/worker_adapter.dart | 390 ++++++++++++++++++ .../src/web_workers/worker/worker_adapter.ts | 155 +++++++ .../src/webworker/worker_app.dart | 2 +- .../src/webworker/worker_app.ts | 16 +- .../src/webworker/worker_app_common.ts | 17 +- .../src/webworker/worker_render.dart | 4 +- .../src/webworker/worker_render.ts | 11 +- .../src/webworker/worker_render_common.ts | 69 ++-- .../platform-browser/src/worker_app.dart | 12 +- .../platform-browser/src/worker_app.ts | 22 +- .../platform-browser/src/worker_render.dart | 6 +- .../platform-browser/src/worker_render.ts | 28 +- modules/@angular/platform-browser/testing.ts | 1 - .../testing/browser_static.ts | 22 +- .../platform-browser/testing/browser_util.ts | 3 +- .../platform-browser/tsconfig-es2015.json | 4 +- .../platform-browser/tsconfig-es5.json | 4 +- .../src/webworker_adapter.dart | 24 -- .../platform-server/testing/server.ts | 3 +- .../@angular/router/src/router_providers.ts | 8 +- .../router/src/router_providers_common.ts | 2 +- .../@angular/upgrade/src/upgrade_adapter.ts | 2 +- .../src/alt_routing/app/drafts.html | 2 +- .../playground/src/alt_routing/app/inbox.html | 2 +- modules/playground/src/alt_routing/index.ts | 2 +- modules/playground/src/bootstrap.ts | 8 +- modules/playground/src/key_events/index.ts | 2 +- .../playground/src/web_workers/images/b64.js | 124 ++++++ .../web_workers/images/background_index.ts | 2 +- .../src/web_workers/images/index.ts | 9 +- .../src/web_workers/images/loader.js | 43 +- .../src/web_workers/input/background_index.ts | 2 +- .../playground/src/web_workers/input/index.ts | 7 +- .../src/web_workers/input/loader.js | 42 +- .../kitchen_sink/background_index.ts | 2 +- .../src/web_workers/kitchen_sink/index.ts | 7 +- .../src/web_workers/kitchen_sink/loader.js | 42 +- .../message_broker/background_index.ts | 2 +- .../src/web_workers/message_broker/index.ts | 17 +- .../message_broker/index_common.ts | 1 - .../src/web_workers/message_broker/loader.js | 42 +- .../web_workers/router/background_index.ts | 17 +- .../src/web_workers/router/index.ts | 11 +- .../src/web_workers/router/loader.js | 43 +- .../src/web_workers/todo/background_index.ts | 2 +- .../playground/src/web_workers/todo/index.ts | 7 +- .../playground/src/web_workers/todo/loader.js | 42 +- protractor-js-new-world.conf.js | 1 - tools/public_api_guard/public_api_spec.ts | 2 +- 92 files changed, 1331 insertions(+), 496 deletions(-) rename modules/@angular/platform-browser-dynamic/{ => src}/platform_browser_dynamic.ts (89%) create mode 100644 modules/@angular/platform-browser-dynamic/src/web_workers/shared/messaging_api.ts create mode 100644 modules/@angular/platform-browser-dynamic/src/web_workers/ui/xhr_impl.ts rename modules/@angular/{platform-browser => platform-browser-dynamic}/src/web_workers/worker/xhr_impl.ts (73%) create mode 100644 modules/@angular/platform-browser-dynamic/src/worker_app.ts create mode 100644 modules/@angular/platform-browser-dynamic/src/worker_render.ts create mode 100644 modules/@angular/platform-browser-dynamic/test/static_assets/test.html rename modules/@angular/{platform-browser => platform-browser-dynamic}/test/testing_public_browser_spec.dart (100%) rename modules/@angular/{platform-browser => platform-browser-dynamic}/test/testing_public_browser_spec.ts (100%) rename modules/@angular/{platform-browser => platform-browser-dynamic}/test/web_workers/worker/xhr_impl_spec.ts (68%) rename modules/@angular/{platform-browser => platform-browser-dynamic}/testing/dom_test_component_renderer.ts (81%) delete mode 100644 modules/@angular/platform-browser/src/web_workers/ui/bind.dart delete mode 100644 modules/@angular/platform-browser/src/web_workers/ui/bind.ts create mode 100644 modules/@angular/platform-browser/src/web_workers/ui/location_providers.ts delete mode 100644 modules/@angular/platform-browser/src/web_workers/ui/router_providers.ts delete mode 100644 modules/@angular/platform-browser/src/web_workers/ui/xhr_impl.ts create mode 100644 modules/@angular/platform-browser/src/web_workers/worker/location_providers.ts delete mode 100644 modules/@angular/platform-browser/src/web_workers/worker/router_providers.ts create mode 100644 modules/@angular/platform-browser/src/web_workers/worker/worker_adapter.dart create mode 100644 modules/@angular/platform-browser/src/web_workers/worker/worker_adapter.ts delete mode 100644 modules/@angular/platform-server/src/webworker_adapter.dart create mode 100644 modules/playground/src/web_workers/images/b64.js diff --git a/build.sh b/build.sh index 8b93a2f124..72f2e9b487 100755 --- a/build.sh +++ b/build.sh @@ -22,7 +22,7 @@ ln -s ../../../../node_modules/zone.js/dist/long-stack-trace-zone.js . ln -s ../../../../node_modules/systemjs/dist/system.src.js . ln -s ../../../../node_modules/base64-js/lib/b64.js . ln -s ../../../../node_modules/reflect-metadata/Reflect.js . -ln -s ../../../../node_modules/rxjs/bundles/Rx.js . +ln -s ../../../../node_modules/rxjs . ln -s ../../../../node_modules/angular/angular.js . cd - diff --git a/modules/@angular/compiler_cli/integrationtest/test/basic_spec.ts b/modules/@angular/compiler_cli/integrationtest/test/basic_spec.ts index 748b28c839..97a310cd46 100644 --- a/modules/@angular/compiler_cli/integrationtest/test/basic_spec.ts +++ b/modules/@angular/compiler_cli/integrationtest/test/basic_spec.ts @@ -30,14 +30,14 @@ describe("template codegen output", () => { it("should be able to create the basic component", () => { const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_STATIC_PROVIDERS, - browserPlatform().injector); + browserPlatform().injector); var comp = BasicNgFactory.create(appInjector); expect(comp.instance).toBeTruthy(); }); it("should support ngIf", () => { const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_STATIC_PROVIDERS, - browserPlatform().injector); + browserPlatform().injector); var comp = BasicNgFactory.create(appInjector); var debugElement = getDebugNode(comp.location.nativeElement); expect(debugElement.children.length).toBe(2); @@ -50,7 +50,7 @@ describe("template codegen output", () => { it("should support ngFor", () => { const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_STATIC_PROVIDERS, - browserPlatform().injector); + browserPlatform().injector); var comp = BasicNgFactory.create(appInjector); var debugElement = getDebugNode(comp.location.nativeElement); expect(debugElement.children.length).toBe(2); diff --git a/modules/@angular/core/src/platform_common_providers.ts b/modules/@angular/core/src/platform_common_providers.ts index 3e5552d447..3e10eda8d8 100644 --- a/modules/@angular/core/src/platform_common_providers.ts +++ b/modules/@angular/core/src/platform_common_providers.ts @@ -1,5 +1,5 @@ -import {Type, isBlank, isPresent, assertionsEnabled} from '../src/facade/lang'; -import {provide, Provider, Injector, OpaqueToken} from './di'; +import {Type} from '../src/facade/lang'; +import {Provider} from './di'; import {Console} from './console'; import {Reflector, reflector} from './reflection/reflection'; import {ReflectorReader} from './reflection/reflector_reader'; diff --git a/modules/@angular/facade/src/lang.dart b/modules/@angular/facade/src/lang.dart index 0ac64ad387..eb788121af 100644 --- a/modules/@angular/facade/src/lang.dart +++ b/modules/@angular/facade/src/lang.dart @@ -252,6 +252,10 @@ class FunctionWrapper { static apply(Function fn, posArgs) { return Function.apply(fn, posArgs); } + + static Function bind(Function fn, dynamic scope) { + return fn; + } } const _NAN_KEY = const Object(); diff --git a/modules/@angular/facade/src/lang.ts b/modules/@angular/facade/src/lang.ts index b322884636..a938f43f20 100644 --- a/modules/@angular/facade/src/lang.ts +++ b/modules/@angular/facade/src/lang.ts @@ -379,6 +379,8 @@ export class RegExpMatcherWrapper { export class FunctionWrapper { static apply(fn: Function, posArgs: any): any { return fn.apply(null, posArgs); } + + static bind(fn: Function, scope: any): Function { return fn.bind(scope); } } // JS has NaN !== NaN diff --git a/modules/@angular/integration_test/public_api_spec.ts b/modules/@angular/integration_test/public_api_spec.ts index 3bb02b34a1..24bb201b14 100644 --- a/modules/@angular/integration_test/public_api_spec.ts +++ b/modules/@angular/integration_test/public_api_spec.ts @@ -373,12 +373,12 @@ var PLATFORM_BROWSER: string[] = [ 'DOCUMENT', 'ELEMENT_PROBE_PROVIDERS', 'DomEventsPlugin', + 'KeyEventsPlugin', 'EVENT_MANAGER_PLUGINS', 'EventManager', 'HAMMER_GESTURE_CONFIG', 'HammerGestureConfig', 'bootstrapStatic', - 'browserStaticPlatform', 'browserPlatform', 'BrowserPlatformLocation', 'AngularEntrypoint:dart', @@ -387,7 +387,32 @@ var PLATFORM_BROWSER: string[] = [ 'SecurityContext', 'Title', 'disableDebugTools', - 'enableDebugTools' + 'enableDebugTools', + 'ClientMessageBroker', + 'ClientMessageBrokerFactory', + 'FnArg', + 'MessageBus', + 'PRIMITIVE', + 'ReceivedMessage', + 'ServiceMessageBroker', + 'ServiceMessageBrokerFactory', + 'UiArguments', + 'WORKER_APP_APPLICATION_COMMON_PROVIDERS', + 'WORKER_APP_APPLICATION_PROVIDERS', + 'WORKER_APP_PLATFORM_PROVIDERS', + 'WORKER_RENDER_APPLICATION_COMMON_PROVIDERS', + 'WORKER_RENDER_APPLICATION_PROVIDERS', + 'WORKER_RENDER_PLATFORM_PROVIDERS', + 'WORKER_RENDER_STARTABLE_MESSAGING_SERVICE', + 'WORKER_SCRIPT', + 'WORKER_APP_LOCATION_PROVIDERS', + 'WORKER_RENDER_LOCATION_PROVIDERS', + 'workerAppPlatform', + 'workerRenderPlatform', + 'WebWorkerInstance', + 'bootstrapStaticApp', + 'bootstrapStaticRender', + 'initializeGenericWorkerRenderer' ]; var PLATFORM_BROWSER_TESTING: string[] = [ @@ -395,8 +420,6 @@ var PLATFORM_BROWSER_TESTING: string[] = [ 'TEST_BROWSER_STATIC_PLATFORM_PROVIDERS', 'ADDITIONAL_TEST_BROWSER_PROVIDERS', // This should be made private 'BrowserDetection', - 'DOMTestComponentRenderer', - 'TestComponentRenderer', 'browserDetection', 'dispatchEvent', 'el', @@ -410,11 +433,19 @@ var PLATFORM_BROWSER_DYNAMIC: string[] = [ 'CACHED_TEMPLATE_PROVIDER', 'bootstrap', 'UrlChangeEvent:dart', - 'UrlChangeListener:dart' + 'UrlChangeListener:dart', + 'WORKER_APP_DYNAMIC_APPLICATION_PROVIDERS', + 'WORKER_RENDER_DYNAMIC_APPLICATION_PROVIDERS', + 'bootstrapApp', + 'bootstrapRender' ]; -var PLATFORM_BROWSER_DYNAMIC_TESTING: string[] = - ['TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS', 'TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS']; +var PLATFORM_BROWSER_DYNAMIC_TESTING: string[] = [ + 'TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS', + 'TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS', + 'ADDITIONAL_DYNAMIC_TEST_BROWSER_PROVIDERS', + 'DOMTestComponentRenderer' +]; var PLATFORM_SERVER: string[] = ['Parse5DomAdapter']; diff --git a/modules/@angular/platform-browser-dynamic/index.ts b/modules/@angular/platform-browser-dynamic/index.ts index fde5be24a0..47e4ce9df7 100644 --- a/modules/@angular/platform-browser-dynamic/index.ts +++ b/modules/@angular/platform-browser-dynamic/index.ts @@ -1 +1,4 @@ -export * from './platform_browser_dynamic'; +export * from './src/platform_browser_dynamic'; + +export * from './src/worker_render'; +export * from './src/worker_app'; diff --git a/modules/@angular/platform-browser-dynamic/platform_browser_private.ts b/modules/@angular/platform-browser-dynamic/platform_browser_private.ts index f3c064cc71..9901bb7d43 100644 --- a/modules/@angular/platform-browser-dynamic/platform_browser_private.ts +++ b/modules/@angular/platform-browser-dynamic/platform_browser_private.ts @@ -1,4 +1,7 @@ import {__platform_browser_private__ as _} from '@angular/platform-browser'; export type DomAdapter = _.DomAdapter; -export function getDOM(): _.DomAdapter{return _.getDOM()}; +export function getDOM(): _.DomAdapter { + return _.getDOM() +} + diff --git a/modules/@angular/platform-browser-dynamic/platform_browser_dynamic.ts b/modules/@angular/platform-browser-dynamic/src/platform_browser_dynamic.ts similarity index 89% rename from modules/@angular/platform-browser-dynamic/platform_browser_dynamic.ts rename to modules/@angular/platform-browser-dynamic/src/platform_browser_dynamic.ts index 173df9613e..bb1befc762 100644 --- a/modules/@angular/platform-browser-dynamic/platform_browser_dynamic.ts +++ b/modules/@angular/platform-browser-dynamic/src/platform_browser_dynamic.ts @@ -1,12 +1,20 @@ +import { + reflector, + ReflectiveInjector, + coreLoadAndBootstrap, + Type, + ComponentRef +} from '@angular/core'; + import {COMPILER_PROVIDERS, XHR} from '@angular/compiler'; -import {CachedXHR} from './src/xhr/xhr_cache'; -import {Provider, Type, ComponentRef} from '@angular/core'; -import {isPresent} from './src/facade/lang'; -import {XHRImpl} from './src/xhr/xhr_impl'; -import {BROWSER_APP_COMMON_PROVIDERS, browserPlatform} from '@angular/platform-browser'; -import {reflector, ReflectiveInjector, coreLoadAndBootstrap} from '@angular/core'; -import {getDOM} from './platform_browser_private'; -import {ReflectionCapabilities} from './core_private'; +import {CachedXHR} from '../src/xhr/xhr_cache'; +import {isPresent} from '../src/facade/lang'; +import {XHRImpl} from '../src/xhr/xhr_impl'; +import { + browserPlatform, + BROWSER_APP_COMMON_PROVIDERS, +} from '@angular/platform-browser'; +import {ReflectionCapabilities} from '../core_private'; export const CACHED_TEMPLATE_PROVIDER: Array = /*@ts2dart_const*/[{provide: XHR, useClass: CachedXHR}]; @@ -21,8 +29,6 @@ export const BROWSER_APP_DYNAMIC_PROVIDERS: Array = [ + WORKER_APP_APPLICATION_PROVIDERS, + COMPILER_PROVIDERS, + WebWorkerXHRImpl, + /* @ts2dart_Provider */ {provide: XHR, useExisting: WebWorkerXHRImpl} +]; + +export function bootstrapApp( + appComponentType: Type, + customProviders?: Array): Promise> { + var appInjector = ReflectiveInjector.resolveAndCreate( + [WORKER_APP_DYNAMIC_APPLICATION_PROVIDERS, isPresent(customProviders) ? customProviders : []], + workerAppPlatform().injector); + return coreLoadAndBootstrap(appInjector, appComponentType); +} diff --git a/modules/@angular/platform-browser-dynamic/src/worker_render.ts b/modules/@angular/platform-browser-dynamic/src/worker_render.ts new file mode 100644 index 0000000000..8eee1988d5 --- /dev/null +++ b/modules/@angular/platform-browser-dynamic/src/worker_render.ts @@ -0,0 +1,38 @@ +import {XHR} from "@angular/compiler"; +import {XHRImpl} from "./xhr/xhr_impl"; +import {MessageBasedXHRImpl} from "./web_workers/ui/xhr_impl"; +import { + WORKER_RENDER_APPLICATION_PROVIDERS, + WORKER_RENDER_STARTABLE_MESSAGING_SERVICE +} from '@angular/platform-browser'; +import { + ApplicationRef, + PlatformRef, + ReflectiveInjector, +} from '@angular/core'; +import {workerRenderPlatform, WORKER_SCRIPT} from '@angular/platform-browser'; +import {isPresent} from './facade/lang'; +import {PromiseWrapper} from './facade/async'; + +export const WORKER_RENDER_DYNAMIC_APPLICATION_PROVIDERS: Array = [ + WORKER_RENDER_APPLICATION_PROVIDERS, + /* @ts2dart_Provider */ {provide: XHR, useClass: XHRImpl}, + MessageBasedXHRImpl, + /* @ts2dart_Provider */ {provide: WORKER_RENDER_STARTABLE_MESSAGING_SERVICE, useExisting: MessageBasedXHRImpl, multi: true}, +]; + +export function bootstrapRender( + workerScriptUri: string, + customProviders?: Array): Promise { + var app = ReflectiveInjector.resolveAndCreate( + [ + WORKER_RENDER_DYNAMIC_APPLICATION_PROVIDERS, + /* @ts2dart_Provider */ {provide: WORKER_SCRIPT, useValue: workerScriptUri}, + isPresent(customProviders) ? customProviders : [] + ], + workerRenderPlatform().injector); + // Return a promise so that we keep the same semantics as Dart, + // and we might want to wait for the app side to come up + // in the future... + return PromiseWrapper.resolve(app.get(ApplicationRef)); +} diff --git a/modules/@angular/platform-browser-dynamic/test/static_assets/test.html b/modules/@angular/platform-browser-dynamic/test/static_assets/test.html new file mode 100644 index 0000000000..4c2b23755f --- /dev/null +++ b/modules/@angular/platform-browser-dynamic/test/static_assets/test.html @@ -0,0 +1 @@ +from external template diff --git a/modules/@angular/platform-browser/test/testing_public_browser_spec.dart b/modules/@angular/platform-browser-dynamic/test/testing_public_browser_spec.dart similarity index 100% rename from modules/@angular/platform-browser/test/testing_public_browser_spec.dart rename to modules/@angular/platform-browser-dynamic/test/testing_public_browser_spec.dart diff --git a/modules/@angular/platform-browser/test/testing_public_browser_spec.ts b/modules/@angular/platform-browser-dynamic/test/testing_public_browser_spec.ts similarity index 100% rename from modules/@angular/platform-browser/test/testing_public_browser_spec.ts rename to modules/@angular/platform-browser-dynamic/test/testing_public_browser_spec.ts diff --git a/modules/@angular/platform-browser/test/web_workers/worker/xhr_impl_spec.ts b/modules/@angular/platform-browser-dynamic/test/web_workers/worker/xhr_impl_spec.ts similarity index 68% rename from modules/@angular/platform-browser/test/web_workers/worker/xhr_impl_spec.ts rename to modules/@angular/platform-browser-dynamic/test/web_workers/worker/xhr_impl_spec.ts index d141c14346..d83defc4dd 100644 --- a/modules/@angular/platform-browser/test/web_workers/worker/xhr_impl_spec.ts +++ b/modules/@angular/platform-browser-dynamic/test/web_workers/worker/xhr_impl_spec.ts @@ -1,16 +1,13 @@ -import { - inject, - describe, - it, - expect, - beforeEach, - beforeEachProviders -} from '@angular/core/testing/testing_internal'; +import {inject, describe, it, expect} 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 {SpyMessageBroker} from '@angular/platform-browser/test/web_workers/worker/spies'; +import {WebWorkerXHRImpl} from '@angular/platform-browser-dynamic/src/web_workers/worker/xhr_impl'; import {PromiseWrapper} from '../../../src/facade/async'; -import {MockMessageBrokerFactory, expectBrokerCall} from '../shared/web_worker_test_util'; +import { + MockMessageBrokerFactory, + expectBrokerCall +} from '@angular/platform-browser/test/web_workers/shared/web_worker_test_util'; export function main() { describe("WebWorkerXHRImpl", () => { diff --git a/modules/@angular/platform-browser-dynamic/testing.ts b/modules/@angular/platform-browser-dynamic/testing.ts index d306127a27..1376d99805 100644 --- a/modules/@angular/platform-browser-dynamic/testing.ts +++ b/modules/@angular/platform-browser-dynamic/testing.ts @@ -1 +1,2 @@ export * from './testing/browser'; +export * from './testing/dom_test_component_renderer'; \ No newline at end of file diff --git a/modules/@angular/platform-browser-dynamic/testing/browser.ts b/modules/@angular/platform-browser-dynamic/testing/browser.ts index f1c0a116bd..92001b391e 100644 --- a/modules/@angular/platform-browser-dynamic/testing/browser.ts +++ b/modules/@angular/platform-browser-dynamic/testing/browser.ts @@ -3,7 +3,14 @@ import { ADDITIONAL_TEST_BROWSER_PROVIDERS } from '@angular/platform-browser/testing'; import {BROWSER_APP_DYNAMIC_PROVIDERS} from '../index'; - +import {DirectiveResolver, ViewResolver} from '@angular/compiler'; +import { + MockDirectiveResolver, + MockViewResolver, + TestComponentRenderer, + TestComponentBuilder +} from '@angular/compiler/testing'; +import {DOMTestComponentRenderer} from './dom_test_component_renderer'; /** * Default platform providers for testing. @@ -11,8 +18,20 @@ import {BROWSER_APP_DYNAMIC_PROVIDERS} from '../index'; export const TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS: Array = /*@ts2dart_const*/[TEST_BROWSER_STATIC_PLATFORM_PROVIDERS]; + +export const ADDITIONAL_DYNAMIC_TEST_BROWSER_PROVIDERS = [ + /*@ts2dart_Provider*/ {provide: DirectiveResolver, useClass: MockDirectiveResolver}, + /*@ts2dart_Provider*/ {provide: ViewResolver, useClass: MockViewResolver}, + TestComponentBuilder, + /*@ts2dart_Provider*/ {provide: TestComponentRenderer, useClass: DOMTestComponentRenderer}, +]; + /** * Default application providers for testing. */ export const TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS: Array = - /*@ts2dart_const*/[BROWSER_APP_DYNAMIC_PROVIDERS, ADDITIONAL_TEST_BROWSER_PROVIDERS]; + /*@ts2dart_const*/[ + BROWSER_APP_DYNAMIC_PROVIDERS, + ADDITIONAL_TEST_BROWSER_PROVIDERS, + ADDITIONAL_DYNAMIC_TEST_BROWSER_PROVIDERS + ]; diff --git a/modules/@angular/platform-browser/testing/dom_test_component_renderer.ts b/modules/@angular/platform-browser-dynamic/testing/dom_test_component_renderer.ts similarity index 81% rename from modules/@angular/platform-browser/testing/dom_test_component_renderer.ts rename to modules/@angular/platform-browser-dynamic/testing/dom_test_component_renderer.ts index 977b04bb2a..952e666e70 100644 --- a/modules/@angular/platform-browser/testing/dom_test_component_renderer.ts +++ b/modules/@angular/platform-browser-dynamic/testing/dom_test_component_renderer.ts @@ -1,8 +1,8 @@ import {Inject, Injectable} from '@angular/core'; -import {DOCUMENT} from '../src/dom/dom_tokens'; -import {getDOM} from '../src/dom/dom_adapter'; +import {DOCUMENT} from '@angular/platform-browser'; +import {getDOM} from '../platform_browser_private'; import {TestComponentRenderer} from '@angular/compiler/testing'; -import {el} from './browser_util'; +import {el} from '@angular/platform-browser/testing'; /** * A DOM based implementation of the TestComponentRenderer. diff --git a/modules/@angular/platform-browser/index.ts b/modules/@angular/platform-browser/index.ts index 4fd770b024..ae819c274b 100644 --- a/modules/@angular/platform-browser/index.ts +++ b/modules/@angular/platform-browser/index.ts @@ -1 +1,6 @@ export * from './src/platform_browser'; + +export * from './src/worker_render'; +export * from './src/worker_app'; + +export * from './private_export'; diff --git a/modules/@angular/platform-browser/private_export.ts b/modules/@angular/platform-browser/private_export.ts index 1885bffb80..5c15de12c2 100644 --- a/modules/@angular/platform-browser/private_export.ts +++ b/modules/@angular/platform-browser/private_export.ts @@ -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; diff --git a/modules/@angular/platform-browser/src/browser_common.ts b/modules/@angular/platform-browser/src/browser_common.ts index 1ec7a8cbed..3a07e688d9 100644 --- a/modules/@angular/platform-browser/src/browser_common.ts +++ b/modules/@angular/platform-browser/src/browser_common.ts @@ -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 = /*@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 = /*@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); } diff --git a/modules/@angular/platform-browser/src/web_workers/shared/api.ts b/modules/@angular/platform-browser/src/web_workers/shared/api.ts index f59f6e5deb..e94d68237a 100644 --- a/modules/@angular/platform-browser/src/web_workers/shared/api.ts +++ b/modules/@angular/platform-browser/src/web_workers/shared/api.ts @@ -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'); diff --git a/modules/@angular/platform-browser/src/web_workers/shared/message_bus.ts b/modules/@angular/platform-browser/src/web_workers/shared/message_bus.ts index 410b55d0ac..29660c0398 100644 --- a/modules/@angular/platform-browser/src/web_workers/shared/message_bus.ts +++ b/modules/@angular/platform-browser/src/web_workers/shared/message_bus.ts @@ -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. diff --git a/modules/@angular/platform-browser/src/web_workers/shared/messaging_api.ts b/modules/@angular/platform-browser/src/web_workers/shared/messaging_api.ts index b0207dddf0..086288b405 100644 --- a/modules/@angular/platform-browser/src/web_workers/shared/messaging_api.ts +++ b/modules/@angular/platform-browser/src/web_workers/shared/messaging_api.ts @@ -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"; diff --git a/modules/@angular/platform-browser/src/web_workers/shared/post_message_bus.ts b/modules/@angular/platform-browser/src/web_workers/shared/post_message_bus.ts index df5b934089..d56e45790f 100644 --- a/modules/@angular/platform-browser/src/web_workers/shared/post_message_bus.ts +++ b/modules/@angular/platform-browser/src/web_workers/shared/post_message_bus.ts @@ -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; } diff --git a/modules/@angular/platform-browser/src/web_workers/shared/render_store.ts b/modules/@angular/platform-browser/src/web_workers/shared/render_store.ts index bdff418b01..f0b25ac5bc 100644 --- a/modules/@angular/platform-browser/src/web_workers/shared/render_store.ts +++ b/modules/@angular/platform-browser/src/web_workers/shared/render_store.ts @@ -1,4 +1,4 @@ -import {Injectable} from '@angular/core/src/di'; +import {Injectable} from '@angular/core'; @Injectable() export class RenderStore { diff --git a/modules/@angular/platform-browser/src/web_workers/shared/service_message_broker.ts b/modules/@angular/platform-browser/src/web_workers/shared/service_message_broker.ts index 87745e6aef..3643e4de24 100644 --- a/modules/@angular/platform-browser/src/web_workers/shared/service_message_broker.ts +++ b/modules/@angular/platform-browser/src/web_workers/shared/service_message_broker.ts @@ -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'; diff --git a/modules/@angular/platform-browser/src/web_workers/ui/bind.dart b/modules/@angular/platform-browser/src/web_workers/ui/bind.dart deleted file mode 100644 index 0f738006d8..0000000000 --- a/modules/@angular/platform-browser/src/web_workers/ui/bind.dart +++ /dev/null @@ -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; -} diff --git a/modules/@angular/platform-browser/src/web_workers/ui/bind.ts b/modules/@angular/platform-browser/src/web_workers/ui/bind.ts deleted file mode 100644 index f83db63ceb..0000000000 --- a/modules/@angular/platform-browser/src/web_workers/ui/bind.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function bind(fn: Function, scope: any): Function { - return fn.bind(scope); -} diff --git a/modules/@angular/platform-browser/src/web_workers/ui/location_providers.ts b/modules/@angular/platform-browser/src/web_workers/ui/location_providers.ts new file mode 100644 index 0000000000..b83b889857 --- /dev/null +++ b/modules/@angular/platform-browser/src/web_workers/ui/location_providers.ts @@ -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()); + }; +} diff --git a/modules/@angular/platform-browser/src/web_workers/ui/platform_location.ts b/modules/@angular/platform-browser/src/web_workers/ui/platform_location.ts index f0aab782c6..c868dbca4e 100644 --- a/modules/@angular/platform-browser/src/web_workers/ui/platform_location.ts +++ b/modules/@angular/platform-browser/src/web_workers/ui/platform_location.ts @@ -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(bind(this._sendUrlChangeEvent, this)); - this._platformLocation.onHashChange(bind(this._sendUrlChangeEvent, this)); + this._platformLocation.onPopState( + FunctionWrapper.bind(this._sendUrlChangeEvent, this)); + this._platformLocation.onHashChange( + 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 { diff --git a/modules/@angular/platform-browser/src/web_workers/ui/renderer.ts b/modules/@angular/platform-browser/src/web_workers/ui/renderer.ts index 4631fb07ba..f7269225dd 100644 --- a/modules/@angular/platform-browser/src/web_workers/ui/renderer.ts +++ b/modules/@angular/platform-browser/src/web_workers/ui/renderer.ts @@ -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) { diff --git a/modules/@angular/platform-browser/src/web_workers/ui/router_providers.ts b/modules/@angular/platform-browser/src/web_workers/ui/router_providers.ts deleted file mode 100644 index c81b12c361..0000000000 --- a/modules/@angular/platform-browser/src/web_workers/ui/router_providers.ts +++ /dev/null @@ -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()); - }; -} diff --git a/modules/@angular/platform-browser/src/web_workers/ui/xhr_impl.ts b/modules/@angular/platform-browser/src/web_workers/ui/xhr_impl.ts deleted file mode 100644 index e869d7c78b..0000000000 --- a/modules/@angular/platform-browser/src/web_workers/ui/xhr_impl.ts +++ /dev/null @@ -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); - } -} diff --git a/modules/@angular/platform-browser/src/web_workers/worker/location_providers.ts b/modules/@angular/platform-browser/src/web_workers/worker/location_providers.ts new file mode 100644 index 0000000000..1f15d8fb89 --- /dev/null +++ b/modules/@angular/platform-browser/src/web_workers/worker/location_providers.ts @@ -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 { + return zone.runGuarded(() => platformLocation.init()); +} diff --git a/modules/@angular/platform-browser/src/web_workers/worker/platform_location.ts b/modules/@angular/platform-browser/src/web_workers/worker/platform_location.ts index 1bb6ef24e7..a400b9a7d6 100644 --- a/modules/@angular/platform-browser/src/web_workers/worker/platform_location.ts +++ b/modules/@angular/platform-browser/src/web_workers/worker/platform_location.ts @@ -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'; diff --git a/modules/@angular/platform-browser/src/web_workers/worker/renderer.ts b/modules/@angular/platform-browser/src/web_workers/worker/renderer.ts index a523ea222c..dfb1f1091b 100644 --- a/modules/@angular/platform-browser/src/web_workers/worker/renderer.ts +++ b/modules/@angular/platform-browser/src/web_workers/worker/renderer.ts @@ -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() diff --git a/modules/@angular/platform-browser/src/web_workers/worker/router_providers.ts b/modules/@angular/platform-browser/src/web_workers/worker/router_providers.ts deleted file mode 100644 index 865907d126..0000000000 --- a/modules/@angular/platform-browser/src/web_workers/worker/router_providers.ts +++ /dev/null @@ -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 { - return zone.runGuarded(() => { return platformLocation.init(); }); -} diff --git a/modules/@angular/platform-browser/src/web_workers/worker/worker_adapter.dart b/modules/@angular/platform-browser/src/web_workers/worker/worker_adapter.dart new file mode 100644 index 0000000000..2221c1e0e1 --- /dev/null +++ b/modules/@angular/platform-browser/src/web_workers/worker/worker_adapter.dart @@ -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'; + } +} diff --git a/modules/@angular/platform-browser/src/web_workers/worker/worker_adapter.ts b/modules/@angular/platform-browser/src/web_workers/worker/worker_adapter.ts new file mode 100644 index 0000000000..582539e388 --- /dev/null +++ b/modules/@angular/platform-browser/src/web_workers/worker/worker_adapter.ts @@ -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 { 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"; } +} \ No newline at end of file diff --git a/modules/@angular/platform-browser/src/webworker/worker_app.dart b/modules/@angular/platform-browser/src/webworker/worker_app.dart index de2b707099..a558911cab 100644 --- a/modules/@angular/platform-browser/src/webworker/worker_app.dart +++ b/modules/@angular/platform-browser/src/webworker/worker_app.dart @@ -10,7 +10,7 @@ import 'dart:isolate'; const OpaqueToken RENDER_SEND_PORT = const OpaqueToken("RenderSendPort"); -const List WORKER_APP_APPLICATION = const [ +const List WORKER_APP_APPLICATION_PROVIDERS = const [ WORKER_APP_APPLICATION_COMMON, const Provider(MessageBus, useFactory: createMessageBus, deps: const [NgZone, RENDER_SEND_PORT]), diff --git a/modules/@angular/platform-browser/src/webworker/worker_app.ts b/modules/@angular/platform-browser/src/webworker/worker_app.ts index c03e82ca15..2e97016da2 100644 --- a/modules/@angular/platform-browser/src/webworker/worker_app.ts +++ b/modules/@angular/platform-browser/src/webworker/worker_app.ts @@ -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 = [ - WORKER_APP_APPLICATION_COMMON, - COMPILER_PROVIDERS, +export const WORKER_APP_APPLICATION_PROVIDERS: Array = [ + 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(); } diff --git a/modules/@angular/platform-browser/src/webworker/worker_app_common.ts b/modules/@angular/platform-browser/src/webworker/worker_app_common.ts index aae058de27..00935af30e 100644 --- a/modules/@angular/platform-browser/src/webworker/worker_app_common.ts +++ b/modules/@angular/platform-browser/src/webworker/worker_app_common.ts @@ -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 = +export const WORKER_APP_PLATFORM_PROVIDERS: Array = /*@ts2dart_const*/[ PLATFORM_COMMON_PROVIDERS, /*@ts2dart_const*/ ( /* @ts2dart_Provider */ {provide: WORKER_APP_PLATFORM_MARKER, useValue: true}) ]; -export const WORKER_APP_APPLICATION_COMMON: Array = +export const WORKER_APP_APPLICATION_COMMON_PROVIDERS: Array = /*@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 initIsolate(String scriptUri) async { var instance = await spawnIsolate(Uri.parse(scriptUri)); diff --git a/modules/@angular/platform-browser/src/webworker/worker_render.ts b/modules/@angular/platform-browser/src/webworker/worker_render.ts index 1d7309e4fa..c4467ddb57 100644 --- a/modules/@angular/platform-browser/src/webworker/worker_render.ts +++ b/modules/@angular/platform-browser/src/webworker/worker_render.ts @@ -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 = /*@ts2dart_const*/[ - WORKER_RENDER_APPLICATION_COMMON, WebWorkerInstance, +export const WORKER_RENDER_APPLICATION_PROVIDERS: Array = /*@ts2dart_const*/[ + WORKER_RENDER_APPLICATION_COMMON_PROVIDERS, WebWorkerInstance, /*@ts2dart_Provider*/ { provide: APP_INITIALIZER, useFactory: (injector => () => initWebWorkerApplication(injector)), diff --git a/modules/@angular/platform-browser/src/webworker/worker_render_common.ts b/modules/@angular/platform-browser/src/webworker/worker_render_common.ts index 1a356fd1bb..e2cfa43be5 100644 --- a/modules/@angular/platform-browser/src/webworker/worker_render_common.ts +++ b/modules/@angular/platform-browser/src/webworker/worker_render_common.ts @@ -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 = - /*@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 = /*@ts2dart_const*/[ +export const WORKER_RENDER_PLATFORM_PROVIDERS: Array = /*@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 = - /*@ts2dart_const*/[BrowserPlatformLocation]; - -export const WORKER_RENDER_APPLICATION_COMMON: Array = +export const WORKER_RENDER_APPLICATION_COMMON_PROVIDERS: Array = /*@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 { - 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 { diff --git a/modules/@angular/platform-browser/src/worker_app.dart b/modules/@angular/platform-browser/src/worker_app.dart index a951be4bfb..e00c3a3b18 100644 --- a/modules/@angular/platform-browser/src/worker_app.dart +++ b/modules/@angular/platform-browser/src/worker_app.dart @@ -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> bootstrapApp( Type appComponentType, [List customProviders]) { var appInjector = ReflectiveInjector.resolveAndCreate([ - WORKER_APP_APPLICATION, + WORKER_APP_APPLICATION_PROVIDERS, isPresent(customProviders) ? customProviders : [] ], workerAppPlatform(renderSendPort).injector); return coreLoadAndBootstrap(appInjector, appComponentType); diff --git a/modules/@angular/platform-browser/src/worker_app.ts b/modules/@angular/platform-browser/src/worker_app.ts index dbd217c9f4..df65eac0db 100644 --- a/modules/@angular/platform-browser/src/worker_app.ts +++ b/modules/@angular/platform-browser/src/worker_app.ts @@ -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): Promise> { var appInjector = ReflectiveInjector.resolveAndCreate( - [WORKER_APP_APPLICATION, isPresent(customProviders) ? customProviders : []], + [WORKER_APP_APPLICATION_PROVIDERS, isPresent(customProviders) ? customProviders : []], workerAppPlatform().injector); return coreLoadAndBootstrap(appInjector, appComponentType); } diff --git a/modules/@angular/platform-browser/src/worker_render.dart b/modules/@angular/platform-browser/src/worker_render.dart index c7eb15194e..472501c063 100644 --- a/modules/@angular/platform-browser/src/worker_render.dart +++ b/modules/@angular/platform-browser/src/worker_render.dart @@ -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 bootstrapRender( +Future bootstrapStaticRender( String workerScriptUri, [List customProviders]) { return initIsolate(workerScriptUri).then( (appProviders) { diff --git a/modules/@angular/platform-browser/src/worker_render.ts b/modules/@angular/platform-browser/src/worker_render.ts index 030cfe76cb..9a554c669a 100644 --- a/modules/@angular/platform-browser/src/worker_render.ts +++ b/modules/@angular/platform-browser/src/worker_render.ts @@ -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): Promise { - 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 : [] ], diff --git a/modules/@angular/platform-browser/testing.ts b/modules/@angular/platform-browser/testing.ts index 8dd3b5a288..9a3751c3dc 100644 --- a/modules/@angular/platform-browser/testing.ts +++ b/modules/@angular/platform-browser/testing.ts @@ -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'; diff --git a/modules/@angular/platform-browser/testing/browser_static.ts b/modules/@angular/platform-browser/testing/browser_static.ts index 7c38928f08..733a6bdfde 100644 --- a/modules/@angular/platform-browser/testing/browser_static.ts +++ b/modules/@angular/platform-browser/testing/browser_static.ts @@ -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 -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; } } diff --git a/modules/@angular/platform-browser/tsconfig-es2015.json b/modules/@angular/platform-browser/tsconfig-es2015.json index ad605dd149..7c17132d47 100644 --- a/modules/@angular/platform-browser/tsconfig-es2015.json +++ b/modules/@angular/platform-browser/tsconfig-es2015.json @@ -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, diff --git a/modules/@angular/platform-browser/tsconfig-es5.json b/modules/@angular/platform-browser/tsconfig-es5.json index d28055ba23..e034d605b1 100644 --- a/modules/@angular/platform-browser/tsconfig-es5.json +++ b/modules/@angular/platform-browser/tsconfig-es5.json @@ -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, diff --git a/modules/@angular/platform-server/src/webworker_adapter.dart b/modules/@angular/platform-server/src/webworker_adapter.dart deleted file mode 100644 index b8f0960e64..0000000000 --- a/modules/@angular/platform-server/src/webworker_adapter.dart +++ /dev/null @@ -1,24 +0,0 @@ -library angular2.dom.webWorkerAdapter; - -import 'abstract_html_adapter.dart'; -import 'package:angular2/platform/common_dom.dart'; - -class WebWorkerDomAdapter extends AbstractHtml5LibAdapter { - static void makeCurrent() { - setRootDomAdapter(new WebWorkerDomAdapter()); - } - - logError(error) { - print('${error}'); - } - - log(error) { - print('${error}'); - } - - logGroup(error) { - print('${error}'); - } - - logGroupEnd() {} -} diff --git a/modules/@angular/platform-server/testing/server.ts b/modules/@angular/platform-server/testing/server.ts index 660e4547c8..d381b4dcb0 100644 --- a/modules/@angular/platform-server/testing/server.ts +++ b/modules/@angular/platform-server/testing/server.ts @@ -4,7 +4,6 @@ import { PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, APPLICATION_COMMON_PROVIDERS, - Renderer, } from '@angular/core'; import {DirectiveResolver, ViewResolver} from '@angular/compiler'; import {TestComponentBuilder} from '@angular/compiler/testing'; @@ -36,7 +35,7 @@ import { import {DomEventsPlugin} from '@angular/platform-browser'; import {LocationStrategy} from '@angular/common'; import {Log} from '@angular/core/testing'; -import {DOMTestComponentRenderer} from '@angular/platform-browser/testing'; +import {DOMTestComponentRenderer} from '@angular/platform-browser-dynamic/testing'; import {TestComponentRenderer} from '@angular/compiler/testing'; function initServerTests() { diff --git a/modules/@angular/router/src/router_providers.ts b/modules/@angular/router/src/router_providers.ts index 3bc15761ab..985236461e 100644 --- a/modules/@angular/router/src/router_providers.ts +++ b/modules/@angular/router/src/router_providers.ts @@ -1,6 +1,4 @@ import {ROUTER_PROVIDERS_COMMON} from './router_providers_common'; -import {BrowserPlatformLocation} from '@angular/platform-browser'; -import {PlatformLocation} from '@angular/common'; /** * A list of {@link Provider}s. To use the router, you must add this to your application. @@ -24,7 +22,5 @@ import {PlatformLocation} from '@angular/common'; * bootstrap(AppCmp, [ROUTER_PROVIDERS]); * ``` */ -export const ROUTER_PROVIDERS: any[] = /*@ts2dart_const*/[ - ROUTER_PROVIDERS_COMMON, - /*@ts2dart_Provider*/ {provide: PlatformLocation, useClass: BrowserPlatformLocation}, -]; +// TODO: merge with router_providers_common.ts +export const ROUTER_PROVIDERS: any[] = /*@ts2dart_const*/[ROUTER_PROVIDERS_COMMON]; diff --git a/modules/@angular/router/src/router_providers_common.ts b/modules/@angular/router/src/router_providers_common.ts index df412a3f5d..410acde528 100644 --- a/modules/@angular/router/src/router_providers_common.ts +++ b/modules/@angular/router/src/router_providers_common.ts @@ -1,4 +1,4 @@ -import {OpaqueToken, ComponentResolver} from '@angular/core'; +import {ComponentResolver} from '@angular/core'; import {LocationStrategy, PathLocationStrategy, Location} from '@angular/common'; import {Router, RouterOutletMap} from './router'; import {RouteSegment} from './segments'; diff --git a/modules/@angular/upgrade/src/upgrade_adapter.ts b/modules/@angular/upgrade/src/upgrade_adapter.ts index d280ac34b5..88ea4f5d52 100644 --- a/modules/@angular/upgrade/src/upgrade_adapter.ts +++ b/modules/@angular/upgrade/src/upgrade_adapter.ts @@ -11,8 +11,8 @@ import { Type, Testability } from '@angular/core'; -import {BROWSER_APP_DYNAMIC_PROVIDERS} from '@angular/platform-browser-dynamic'; import {browserPlatform} from '@angular/platform-browser'; +import {BROWSER_APP_DYNAMIC_PROVIDERS} from '@angular/platform-browser-dynamic'; import {getComponentInfo, ComponentInfo} from './metadata'; import {onError, controllerKey} from './util'; import { diff --git a/modules/playground/src/alt_routing/app/drafts.html b/modules/playground/src/alt_routing/app/drafts.html index 0f647c86e9..62d968bc1c 100644 --- a/modules/playground/src/alt_routing/app/drafts.html +++ b/modules/playground/src/alt_routing/app/drafts.html @@ -2,7 +2,7 @@

Drafts

    -
  1. +
  2. {{ item.subject }} diff --git a/modules/playground/src/alt_routing/app/inbox.html b/modules/playground/src/alt_routing/app/inbox.html index 35a26b5a36..c33bdbdad6 100644 --- a/modules/playground/src/alt_routing/app/inbox.html +++ b/modules/playground/src/alt_routing/app/inbox.html @@ -2,7 +2,7 @@

    Inbox

      -
    1. +
    2. {{ item.subject }}
    3. diff --git a/modules/playground/src/alt_routing/index.ts b/modules/playground/src/alt_routing/index.ts index c66b6a5054..1f2414a427 100644 --- a/modules/playground/src/alt_routing/index.ts +++ b/modules/playground/src/alt_routing/index.ts @@ -2,7 +2,7 @@ import {InboxApp} from './app/inbox-app'; import {provide} from '@angular/core'; import {bootstrap} from '@angular/platform-browser-dynamic'; import {HashLocationStrategy, LocationStrategy} from '@angular/common'; -import {ROUTER_PROVIDERS} from '@angular/router'; +import {ROUTER_PROVIDERS} from '@angular/router-deprecated'; export function main() { bootstrap(InboxApp, diff --git a/modules/playground/src/bootstrap.ts b/modules/playground/src/bootstrap.ts index e029adf713..9bd1fa180c 100644 --- a/modules/playground/src/bootstrap.ts +++ b/modules/playground/src/bootstrap.ts @@ -8,12 +8,9 @@ declare var System: any; writeScriptTag('/all/playground/vendor/long-stack-trace-zone.js'); writeScriptTag('/all/playground/vendor/system.src.js'); writeScriptTag('/all/playground/vendor/Reflect.js'); - writeScriptTag('/all/playground/vendor/Rx.js', 'playgroundBootstrap()'); + writeScriptTag('/all/playground/vendor/rxjs/bundles/Rx.js', 'playgroundBootstrap()'); global.playgroundBootstrap = playgroundBootstrap; - - - //////// function playgroundBootstrap() { // check query param var useBundles = location.search.indexOf('bundles=false') == -1; @@ -54,7 +51,8 @@ declare var System: any; '@angular/compiler': {main: 'index.js', defaultExtension: 'js'}, '@angular/common': {main: 'index.js', defaultExtension: 'js'}, '@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'}, - '@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'} + '@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'}, + '@angular/router': {main: 'index.js', defaultExtension: 'js'}, // 'rxjs': { // defaultExtension: 'js' // } diff --git a/modules/playground/src/key_events/index.ts b/modules/playground/src/key_events/index.ts index 9bec7bfa96..54ae3540aa 100644 --- a/modules/playground/src/key_events/index.ts +++ b/modules/playground/src/key_events/index.ts @@ -1,6 +1,6 @@ import {bootstrap} from '@angular/platform-browser-dynamic'; import {Component} from '@angular/core'; -import {KeyEventsPlugin} from '@angular/platform-browser/src/dom/events/key_events'; +import {KeyEventsPlugin} from '@angular/platform-browser'; @Component({ selector: 'key-events-app', diff --git a/modules/playground/src/web_workers/images/b64.js b/modules/playground/src/web_workers/images/b64.js new file mode 100644 index 0000000000..46001d2f16 --- /dev/null +++ b/modules/playground/src/web_workers/images/b64.js @@ -0,0 +1,124 @@ +var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + +;(function (exports) { + 'use strict'; + + var Arr = (typeof Uint8Array !== 'undefined') + ? Uint8Array + : Array + + var PLUS = '+'.charCodeAt(0) + var SLASH = '/'.charCodeAt(0) + var NUMBER = '0'.charCodeAt(0) + var LOWER = 'a'.charCodeAt(0) + var UPPER = 'A'.charCodeAt(0) + var PLUS_URL_SAFE = '-'.charCodeAt(0) + var SLASH_URL_SAFE = '_'.charCodeAt(0) + + function decode (elt) { + var code = elt.charCodeAt(0) + if (code === PLUS || + code === PLUS_URL_SAFE) + return 62 // '+' + if (code === SLASH || + code === SLASH_URL_SAFE) + return 63 // '/' + if (code < NUMBER) + return -1 //no match + if (code < NUMBER + 10) + return code - NUMBER + 26 + 26 + if (code < UPPER + 26) + return code - UPPER + if (code < LOWER + 26) + return code - LOWER + 26 + } + + function b64ToByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + + if (b64.length % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + var len = b64.length + placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 + + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(b64.length * 3 / 4 - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? b64.length - 4 : b64.length + + var L = 0 + + function push (v) { + arr[L++] = v + } + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) + push((tmp & 0xFF0000) >> 16) + push((tmp & 0xFF00) >> 8) + push(tmp & 0xFF) + } + + if (placeHolders === 2) { + tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) + push(tmp & 0xFF) + } else if (placeHolders === 1) { + tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) + push((tmp >> 8) & 0xFF) + push(tmp & 0xFF) + } + + return arr + } + + function uint8ToBase64 (uint8) { + var i, + extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes + output = "", + temp, length + + function encode (num) { + return lookup.charAt(num) + } + + function tripletToBase64 (num) { + return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) + } + + // go through the array every three bytes, we'll deal with trailing stuff later + for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { + temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output += tripletToBase64(temp) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + switch (extraBytes) { + case 1: + temp = uint8[uint8.length - 1] + output += encode(temp >> 2) + output += encode((temp << 4) & 0x3F) + output += '==' + break + case 2: + temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) + output += encode(temp >> 10) + output += encode((temp >> 4) & 0x3F) + output += encode((temp << 2) & 0x3F) + output += '=' + break + } + + return output + } + + exports.toByteArray = b64ToByteArray + exports.fromByteArray = uint8ToBase64 +}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) diff --git a/modules/playground/src/web_workers/images/background_index.ts b/modules/playground/src/web_workers/images/background_index.ts index 019c559de2..c6d25f74c1 100644 --- a/modules/playground/src/web_workers/images/background_index.ts +++ b/modules/playground/src/web_workers/images/background_index.ts @@ -1,5 +1,5 @@ import {ImageDemo} from './index_common'; -import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app'; +import {bootstrapApp} from '@angular/platform-browser-dynamic'; export function main() { bootstrapApp(ImageDemo); diff --git a/modules/playground/src/web_workers/images/index.ts b/modules/playground/src/web_workers/images/index.ts index 902526a8b9..eec4c2a8ac 100644 --- a/modules/playground/src/web_workers/images/index.ts +++ b/modules/playground/src/web_workers/images/index.ts @@ -1,6 +1,5 @@ -import {Provider} from '@angular/core'; -import { - bootstrapRender, -} from '../../../../@angular/platform-browser/src/worker_render'; +import {bootstrapRender} from '@angular/platform-browser-dynamic'; -bootstrapRender("loader.js"); +export function main() { + bootstrapRender("loader.js"); +} diff --git a/modules/playground/src/web_workers/images/loader.js b/modules/playground/src/web_workers/images/loader.js index 2d760938e0..8598128f4b 100644 --- a/modules/playground/src/web_workers/images/loader.js +++ b/modules/playground/src/web_workers/images/loader.js @@ -1,19 +1,38 @@ -$SCRIPTS$ -importScripts("b64.js"); +importScripts("../../../vendor/es6-shim.js", + "../../../vendor/zone.js", + "../../../vendor/long-stack-trace-zone.js", + "../../../vendor/system.src.js", + "../../../vendor/Reflect.js", + "b64.js"); System.config({ - baseURL: '/', + baseURL: '/all', + + map: {'rxjs': '/all/playground/vendor/rxjs'}, + + packages: { + '@angular/core': {main: 'index.js', defaultExtension: 'js'}, + '@angular/compiler': {main: 'index.js', defaultExtension: 'js'}, + '@angular/common': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'}, + '@angular/router': {main: 'index.js', defaultExtension: 'js'}, + 'rxjs': { + defaultExtension: 'js' + } + }, + defaultJSExtensions: true }); System.import("playground/src/web_workers/images/background_index") - .then( - function(m) { - try { - m.main(); - } catch (e) { - console.error(e); - } - }, - function(error) { console.error("error loading background", error); }); + .then( + function(m) { + try { + m.main(); + } catch (e) { + console.error(e); + } + }, + function(error) { console.error("error loading background", error); }); diff --git a/modules/playground/src/web_workers/input/background_index.ts b/modules/playground/src/web_workers/input/background_index.ts index ef2e7e13d4..d2e16ec932 100644 --- a/modules/playground/src/web_workers/input/background_index.ts +++ b/modules/playground/src/web_workers/input/background_index.ts @@ -1,5 +1,5 @@ import {InputCmp} from './index_common'; -import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app'; +import {bootstrapApp} from '@angular/platform-browser-dynamic'; export function main() { bootstrapApp(InputCmp); diff --git a/modules/playground/src/web_workers/input/index.ts b/modules/playground/src/web_workers/input/index.ts index 26004c7370..eec4c2a8ac 100644 --- a/modules/playground/src/web_workers/input/index.ts +++ b/modules/playground/src/web_workers/input/index.ts @@ -1,4 +1,5 @@ -import {Provider} from '@angular/core'; -import {bootstrapRender} from '../../../../@angular/platform-browser/src/worker_render'; +import {bootstrapRender} from '@angular/platform-browser-dynamic'; -bootstrapRender("loader.js"); +export function main() { + bootstrapRender("loader.js"); +} diff --git a/modules/playground/src/web_workers/input/loader.js b/modules/playground/src/web_workers/input/loader.js index 647f1c577b..c1dbcadac2 100644 --- a/modules/playground/src/web_workers/input/loader.js +++ b/modules/playground/src/web_workers/input/loader.js @@ -1,17 +1,37 @@ -$SCRIPTS$ +importScripts("../../../vendor/es6-shim.js", + "../../../vendor/zone.js", + "../../../vendor/long-stack-trace-zone.js", + "../../../vendor/system.src.js", + "../../../vendor/Reflect.js"); + System.config({ - baseURL: '/', + baseURL: '/all', + + map: {'rxjs': '/all/playground/vendor/rxjs'}, + + packages: { + '@angular/core': {main: 'index.js', defaultExtension: 'js'}, + '@angular/compiler': {main: 'index.js', defaultExtension: 'js'}, + '@angular/common': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'}, + '@angular/router': {main: 'index.js', defaultExtension: 'js'}, + 'rxjs': { + defaultExtension: 'js' + } + }, + defaultJSExtensions: true }); System.import("playground/src/web_workers/input/background_index") - .then( - function(m) { - try { - m.main(); - } catch (e) { - console.error(e); - } - }, - function(error) { console.error("error loading background", error); }); + .then( + function(m) { + try { + m.main(); + } catch (e) { + console.error(e); + } + }, + function(error) { console.error("error loading background", error); }); diff --git a/modules/playground/src/web_workers/kitchen_sink/background_index.ts b/modules/playground/src/web_workers/kitchen_sink/background_index.ts index 89b31272af..e04f3476c8 100644 --- a/modules/playground/src/web_workers/kitchen_sink/background_index.ts +++ b/modules/playground/src/web_workers/kitchen_sink/background_index.ts @@ -1,5 +1,5 @@ import {HelloCmp} from './index_common'; -import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app'; +import {bootstrapApp} from '@angular/platform-browser-dynamic'; export function main() { bootstrapApp(HelloCmp); diff --git a/modules/playground/src/web_workers/kitchen_sink/index.ts b/modules/playground/src/web_workers/kitchen_sink/index.ts index 26004c7370..eec4c2a8ac 100644 --- a/modules/playground/src/web_workers/kitchen_sink/index.ts +++ b/modules/playground/src/web_workers/kitchen_sink/index.ts @@ -1,4 +1,5 @@ -import {Provider} from '@angular/core'; -import {bootstrapRender} from '../../../../@angular/platform-browser/src/worker_render'; +import {bootstrapRender} from '@angular/platform-browser-dynamic'; -bootstrapRender("loader.js"); +export function main() { + bootstrapRender("loader.js"); +} diff --git a/modules/playground/src/web_workers/kitchen_sink/loader.js b/modules/playground/src/web_workers/kitchen_sink/loader.js index b910440723..53436e7535 100644 --- a/modules/playground/src/web_workers/kitchen_sink/loader.js +++ b/modules/playground/src/web_workers/kitchen_sink/loader.js @@ -1,17 +1,37 @@ -$SCRIPTS$ +importScripts("../../../vendor/es6-shim.js", + "../../../vendor/zone.js", + "../../../vendor/long-stack-trace-zone.js", + "../../../vendor/system.src.js", + "../../../vendor/Reflect.js"); + System.config({ - baseURL: '/', + baseURL: '/all', + + map: {'rxjs': '/all/playground/vendor/rxjs'}, + + packages: { + '@angular/core': {main: 'index.js', defaultExtension: 'js'}, + '@angular/compiler': {main: 'index.js', defaultExtension: 'js'}, + '@angular/common': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'}, + '@angular/router': {main: 'index.js', defaultExtension: 'js'}, + 'rxjs': { + defaultExtension: 'js' + }, + }, + defaultJSExtensions: true }); System.import("playground/src/web_workers/kitchen_sink/background_index") - .then( - function(m) { - try { - m.main(); - } catch (e) { - console.error(e); - } - }, - function(error) { console.error("error loading background", error); }); + .then( + function(m) { + try { + m.main(); + } catch (e) { + console.error(e); + } + }, + function(error) { console.error("error loading background", error); }); diff --git a/modules/playground/src/web_workers/message_broker/background_index.ts b/modules/playground/src/web_workers/message_broker/background_index.ts index c4f9ef2956..d499f5a3f6 100644 --- a/modules/playground/src/web_workers/message_broker/background_index.ts +++ b/modules/playground/src/web_workers/message_broker/background_index.ts @@ -1,4 +1,4 @@ -import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app'; +import {bootstrapApp} from '@angular/platform-browser-dynamic'; import {App} from './index_common'; export function main() { diff --git a/modules/playground/src/web_workers/message_broker/index.ts b/modules/playground/src/web_workers/message_broker/index.ts index 24ca469dba..3b214e60ad 100644 --- a/modules/playground/src/web_workers/message_broker/index.ts +++ b/modules/playground/src/web_workers/message_broker/index.ts @@ -1,15 +1,14 @@ -import {Provider, ApplicationRef} from '@angular/core'; -import { - bootstrapRender, - UiArguments, - FnArg, - PRIMITIVE, - ClientMessageBrokerFactory -} from '../../../../@angular/platform-browser/src/worker_render'; +import {ApplicationRef} from '@angular/core'; +import {bootstrapRender} from '@angular/platform-browser-dynamic'; + +// TODO +import {UiArguments, FnArg, PRIMITIVE, ClientMessageBrokerFactory} from '@angular/platform-browser'; const ECHO_CHANNEL = "ECHO"; -bootstrapRender("loader.js").then((ref) => afterBootstrap(ref)); +export function main() { + bootstrapRender("loader.js").then((ref) => afterBootstrap(ref)); +} function afterBootstrap(ref: ApplicationRef) { let brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory); diff --git a/modules/playground/src/web_workers/message_broker/index_common.ts b/modules/playground/src/web_workers/message_broker/index_common.ts index 29ab08a032..c75b2da684 100644 --- a/modules/playground/src/web_workers/message_broker/index_common.ts +++ b/modules/playground/src/web_workers/message_broker/index_common.ts @@ -1,7 +1,6 @@ import {PromiseWrapper} from '@angular/core/src/facade/async'; import {Component} from '@angular/core'; import {ServiceMessageBrokerFactory, PRIMITIVE} from '@angular/platform-browser/src/worker_app'; -; const ECHO_CHANNEL = "ECHO"; diff --git a/modules/playground/src/web_workers/message_broker/loader.js b/modules/playground/src/web_workers/message_broker/loader.js index a828da4812..8701b0620e 100644 --- a/modules/playground/src/web_workers/message_broker/loader.js +++ b/modules/playground/src/web_workers/message_broker/loader.js @@ -1,17 +1,37 @@ -$SCRIPTS$ +importScripts("../../../vendor/es6-shim.js", + "../../../vendor/zone.js", + "../../../vendor/long-stack-trace-zone.js", + "../../../vendor/system.src.js", + "../../../vendor/Reflect.js"); + System.config({ - baseURL: '/', + baseURL: '/all', + + map: {'rxjs': '/all/playground/vendor/rxjs'}, + + packages: { + '@angular/core': {main: 'index.js', defaultExtension: 'js'}, + '@angular/compiler': {main: 'index.js', defaultExtension: 'js'}, + '@angular/common': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'}, + '@angular/router': {main: 'index.js', defaultExtension: 'js'}, + 'rxjs': { + defaultExtension: 'js' + }, + }, + defaultJSExtensions: true }); System.import("playground/src/web_workers/message_broker/background_index") - .then( - function(m) { - try { - m.main(); - } catch (e) { - console.error(e); - } - }, - function(error) { console.error("error loading background", error); }); + .then( + function(m) { + try { + m.main(); + } catch (e) { + console.error(e); + } + }, + function(error) { console.error("error loading background", error); }); diff --git a/modules/playground/src/web_workers/router/background_index.ts b/modules/playground/src/web_workers/router/background_index.ts index d113ed6b00..a3aff30650 100644 --- a/modules/playground/src/web_workers/router/background_index.ts +++ b/modules/playground/src/web_workers/router/background_index.ts @@ -1,12 +1,15 @@ -import {Provider} from '@angular/core'; -import { - bootstrapApp, - WORKER_APP_ROUTER -} from '../../../../@angular/platform-browser/src/worker_app'; +import {ROUTER_PROVIDERS} from '@angular/router-deprecated'; +import {bootstrapApp} from '@angular/platform-browser-dynamic'; + +import {WORKER_APP_LOCATION_PROVIDERS} from '@angular/platform-browser'; + import {HashLocationStrategy, LocationStrategy} from '@angular/common'; import {App} from './index_common'; export function main() { - bootstrapApp(App, - [WORKER_APP_ROUTER, {provide: LocationStrategy, useClass: HashLocationStrategy}]); + bootstrapApp(App, [ + ROUTER_PROVIDERS, + WORKER_APP_LOCATION_PROVIDERS, + {provide: LocationStrategy, useClass: HashLocationStrategy} + ]); } diff --git a/modules/playground/src/web_workers/router/index.ts b/modules/playground/src/web_workers/router/index.ts index 887d56a980..6669bda31b 100644 --- a/modules/playground/src/web_workers/router/index.ts +++ b/modules/playground/src/web_workers/router/index.ts @@ -1,6 +1,7 @@ -import { - bootstrapRender, - WORKER_RENDER_ROUTER -} from '../../../../@angular/platform-browser/src/worker_render'; +import {bootstrapRender} from '@angular/platform-browser-dynamic'; -bootstrapRender("loader.js", WORKER_RENDER_ROUTER); +import {WORKER_RENDER_LOCATION_PROVIDERS} from '@angular/platform-browser'; + +export function main() { + bootstrapRender("loader.js", WORKER_RENDER_LOCATION_PROVIDERS); +} diff --git a/modules/playground/src/web_workers/router/loader.js b/modules/playground/src/web_workers/router/loader.js index d4a24d0dd7..ac7ab9469f 100644 --- a/modules/playground/src/web_workers/router/loader.js +++ b/modules/playground/src/web_workers/router/loader.js @@ -1,17 +1,38 @@ -$SCRIPTS$ +importScripts("../../../vendor/es6-shim.js", + "../../../vendor/zone.js", + "../../../vendor/long-stack-trace-zone.js", + "../../../vendor/system.src.js", + "../../../vendor/Reflect.js"); + System.config({ - baseURL: '/', + baseURL: '/all', + + map: {'rxjs': '/all/playground/vendor/rxjs'}, + + packages: { + '@angular/core': {main: 'index.js', defaultExtension: 'js'}, + '@angular/compiler': {main: 'index.js', defaultExtension: 'js'}, + '@angular/common': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'}, + '@angular/router': {main: 'index.js', defaultExtension: 'js'}, + '@angular/router-deprecated': {main: 'index.js', defaultExtension: 'js'}, + 'rxjs': { + defaultExtension: 'js' + }, + }, + defaultJSExtensions: true }); System.import("playground/src/web_workers/router/background_index") - .then( - function(m) { - try { - m.main(); - } catch (e) { - console.error(e); - } - }, - function(error) { console.error("error loading background", error); }); + .then( + function(m) { + try { + m.main(); + } catch (e) { + console.error(e); + } + }, + function(error) { console.error("error loading background", error); }); diff --git a/modules/playground/src/web_workers/todo/background_index.ts b/modules/playground/src/web_workers/todo/background_index.ts index f61456b6d0..3540b38138 100644 --- a/modules/playground/src/web_workers/todo/background_index.ts +++ b/modules/playground/src/web_workers/todo/background_index.ts @@ -1,5 +1,5 @@ import {TodoApp} from './index_common'; -import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app'; +import {bootstrapApp} from '@angular/platform-browser-dynamic'; export function main() { bootstrapApp(TodoApp); diff --git a/modules/playground/src/web_workers/todo/index.ts b/modules/playground/src/web_workers/todo/index.ts index 26004c7370..eec4c2a8ac 100644 --- a/modules/playground/src/web_workers/todo/index.ts +++ b/modules/playground/src/web_workers/todo/index.ts @@ -1,4 +1,5 @@ -import {Provider} from '@angular/core'; -import {bootstrapRender} from '../../../../@angular/platform-browser/src/worker_render'; +import {bootstrapRender} from '@angular/platform-browser-dynamic'; -bootstrapRender("loader.js"); +export function main() { + bootstrapRender("loader.js"); +} diff --git a/modules/playground/src/web_workers/todo/loader.js b/modules/playground/src/web_workers/todo/loader.js index 26947faa50..e5ea058175 100644 --- a/modules/playground/src/web_workers/todo/loader.js +++ b/modules/playground/src/web_workers/todo/loader.js @@ -1,17 +1,37 @@ -$SCRIPTS$ +importScripts("../../../vendor/es6-shim.js", + "../../../vendor/zone.js", + "../../../vendor/long-stack-trace-zone.js", + "../../../vendor/system.src.js", + "../../../vendor/Reflect.js"); + System.config({ - baseURL: '/', + baseURL: '/all', + + map: {'rxjs': '/all/playground/vendor/rxjs'}, + + packages: { + '@angular/core': {main: 'index.js', defaultExtension: 'js'}, + '@angular/compiler': {main: 'index.js', defaultExtension: 'js'}, + '@angular/common': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'}, + '@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'}, + '@angular/router': {main: 'index.js', defaultExtension: 'js'}, + 'rxjs': { + defaultExtension: 'js' + } + }, + defaultJSExtensions: true }); System.import("playground/src/web_workers/todo/background_index") - .then( - function(m) { - try { - m.main(); - } catch (e) { - console.error(e); - } - }, - function(error) { console.error("error loading background", error); }); + .then( + function(m) { + try { + m.main(); + } catch (e) { + console.error(e); + } + }, + function(error) { console.error("error loading background", error); }); diff --git a/protractor-js-new-world.conf.js b/protractor-js-new-world.conf.js index d60f2d5300..62758d4111 100644 --- a/protractor-js-new-world.conf.js +++ b/protractor-js-new-world.conf.js @@ -19,7 +19,6 @@ exports.config = { 'dist/all/**/e2e_test/**/*_spec.js' ], exclude: [ - '**/web_workers/**', // needs to be setup '**/key_events/**', // can't tell why this is failing '**/sourcemap/**' // fails only on travis ], diff --git a/tools/public_api_guard/public_api_spec.ts b/tools/public_api_guard/public_api_spec.ts index d00860aa90..1dbd7349aa 100644 --- a/tools/public_api_guard/public_api_spec.ts +++ b/tools/public_api_guard/public_api_spec.ts @@ -1241,7 +1241,7 @@ const BROWSER = [ 'disableDebugTools():void', 'enableDebugTools(ref:ComponentRef):void', 'inspectNativeElement(element:any):DebugNode', - 'browserStaticPlatform():PlatformRef' + 'browserPlatform():PlatformRef' ]; describe('public API', () => {