From b602bd8c835ef33f9d0c44e2595558471462fec5 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 8 Apr 2016 00:31:20 -0700 Subject: [PATCH] refactor(Location): out of router and into platform/common closes https://github.com/angular/angular/issues/4943 BREAKING CHANGE: `Location` and other related providers have been moved out of `router` and into `platform/common`. `BrowserPlatformLocation` is not meant to be used directly however advanced configurations may use it via the following import change. Before: ``` import { PlatformLocation, Location, LocationStrategy, HashLocationStrategy, PathLocationStrategy, APP_BASE_HREF} from 'angular2/router'; import {BrowserPlatformLocation} from 'angular2/src/router/location/browser_platform_location'; ``` After: ``` import { PlatformLocation, Location, LocationStrategy, HashLocationStrategy, PathLocationStrategy, APP_BASE_HREF} from 'angular2/platform/common'; import {BrowserPlatformLocation} from 'angular2/src/platform/browser/location/browser_platform_location'; ``` Closes #7962 --- modules/angular2/common.ts | 2 +- .../ts/can_activate/can_activate_example.ts | 9 +-- .../can_deactivate/can_deactivate_example.ts | 4 +- .../ts/on_activate/on_activate_example.ts | 9 +-- .../ts/on_deactivate/on_deactivate_example.ts | 9 +-- .../examples/router/ts/reuse/reuse_example.ts | 2 +- modules/angular2/platform/common.ts | 5 ++ modules/angular2/platform/common_dom.ts | 3 +- .../platform/testing/browser_static.ts | 2 +- modules/angular2/platform/testing/server.ts | 2 +- modules/angular2/router.ts | 5 -- modules/angular2/src/mock/location_mock.ts | 2 +- .../src/mock/mock_location_strategy.ts | 2 +- .../location/browser_platform_location.ts | 5 +- .../location/hash_location_strategy.ts | 25 ++++---- .../browser}/location/location.ts | 63 +++++++++++++++---- .../browser}/location/location_strategy.ts | 28 +-------- .../location/path_location_strategy.ts | 26 ++++---- .../browser}/location/platform_location.ts | 0 modules/angular2/src/platform/location.ts | 5 ++ .../src/platform/worker_render_common.ts | 4 +- .../src/router/directives/router_link.ts | 2 +- modules/angular2/src/router/router.ts | 2 +- .../angular2/src/router/router_providers.ts | 6 +- .../src/router/router_providers_common.ts | 4 +- .../src/web_workers/ui/platform_location.ts | 6 +- .../src/web_workers/ui/router_providers.ts | 4 +- .../web_workers/worker/platform_location.ts | 6 +- .../web_workers/worker/router_providers.ts | 2 +- .../test/platform/browser/bootstrap_spec.ts | 3 +- modules/angular2/test/public_api_spec.ts | 23 ++++++- .../router/directives/router_link_spec.ts | 2 +- .../test/router/integration/bootstrap_spec.ts | 5 +- .../integration/impl/async_route_spec_impl.ts | 4 +- .../integration/impl/aux_route_spec_impl.ts | 3 +- .../integration/impl/sync_route_spec_impl.ts | 3 +- .../router/integration/navigation_spec.ts | 3 +- .../router/integration/redirect_route_spec.ts | 3 +- .../router/integration/router_link_spec.ts | 2 +- .../angular2/test/router/integration/util.ts | 2 +- .../location/hash_location_strategy_spec.ts | 4 +- .../test/router/location/location_spec.ts | 3 +- .../location/path_location_strategy_spec.ts | 9 ++- .../router/route_config/route_config_spec.ts | 10 +-- modules/angular2/test/router/router_spec.ts | 2 +- modules/angular2/test/router/spies.dart | 1 + modules/angular2/test/router/spies.ts | 3 +- .../symbol_inspector/symbol_inspector.dart | 3 +- .../test/symbol_inspector/symbol_inspector.ts | 2 + modules/playground/src/hash_routing/index.ts | 10 +-- modules/playground/src/routing/inbox-app.ts | 11 +--- modules/playground/src/routing/index.ts | 3 +- .../web_workers/router/background_index.dart | 2 +- .../web_workers/router/background_index.ts | 2 +- .../src/web_workers/router/index.ts | 3 +- 55 files changed, 187 insertions(+), 178 deletions(-) create mode 100644 modules/angular2/platform/common.ts rename modules/angular2/src/{router => platform/browser}/location/browser_platform_location.ts (91%) rename modules/angular2/src/{router => platform/browser}/location/hash_location_strategy.ts (84%) rename modules/angular2/src/{router => platform/browser}/location/location.ts (74%) rename modules/angular2/src/{router => platform/browser}/location/location_strategy.ts (77%) rename modules/angular2/src/{router => platform/browser}/location/path_location_strategy.ts (80%) rename modules/angular2/src/{router => platform/browser}/location/platform_location.ts (100%) create mode 100644 modules/angular2/src/platform/location.ts diff --git a/modules/angular2/common.ts b/modules/angular2/common.ts index 4611aaaace..23e730cf32 100644 --- a/modules/angular2/common.ts +++ b/modules/angular2/common.ts @@ -1,4 +1,4 @@ export * from './src/common/pipes'; export * from './src/common/directives'; export * from './src/common/forms'; -export * from './src/common/common_directives'; \ No newline at end of file +export * from './src/common/common_directives'; diff --git a/modules/angular2/examples/router/ts/can_activate/can_activate_example.ts b/modules/angular2/examples/router/ts/can_activate/can_activate_example.ts index bfa02bf67a..d9c9819bc5 100644 --- a/modules/angular2/examples/router/ts/can_activate/can_activate_example.ts +++ b/modules/angular2/examples/router/ts/can_activate/can_activate_example.ts @@ -1,12 +1,7 @@ import {provide, Component} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; -import { - CanActivate, - RouteConfig, - ComponentInstruction, - APP_BASE_HREF, - ROUTER_DIRECTIVES -} from 'angular2/router'; +import {CanActivate, RouteConfig, ComponentInstruction, ROUTER_DIRECTIVES} from 'angular2/router'; +import {APP_BASE_HREF} from 'angular2/platform/common'; function checkIfWeHavePermission(instruction: ComponentInstruction) { return instruction.params['id'] == '1'; diff --git a/modules/angular2/examples/router/ts/can_deactivate/can_deactivate_example.ts b/modules/angular2/examples/router/ts/can_deactivate/can_deactivate_example.ts index e330aff1fe..e7fc23539d 100644 --- a/modules/angular2/examples/router/ts/can_deactivate/can_deactivate_example.ts +++ b/modules/angular2/examples/router/ts/can_deactivate/can_deactivate_example.ts @@ -5,9 +5,9 @@ import { RouteConfig, RouteParams, ComponentInstruction, - ROUTER_DIRECTIVES, - APP_BASE_HREF + ROUTER_DIRECTIVES } from 'angular2/router'; +import {APP_BASE_HREF} from 'angular2/platform/common'; // #docregion routerCanDeactivate @Component({ diff --git a/modules/angular2/examples/router/ts/on_activate/on_activate_example.ts b/modules/angular2/examples/router/ts/on_activate/on_activate_example.ts index 47c24bcd09..155714dde4 100644 --- a/modules/angular2/examples/router/ts/on_activate/on_activate_example.ts +++ b/modules/angular2/examples/router/ts/on_activate/on_activate_example.ts @@ -1,12 +1,7 @@ import {Component, provide} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; -import { - OnActivate, - ComponentInstruction, - RouteConfig, - ROUTER_DIRECTIVES, - APP_BASE_HREF -} from 'angular2/router'; +import {OnActivate, ComponentInstruction, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router'; +import {APP_BASE_HREF} from 'angular2/platform/common'; // #docregion routerOnActivate @Component({template: `Child`}) diff --git a/modules/angular2/examples/router/ts/on_deactivate/on_deactivate_example.ts b/modules/angular2/examples/router/ts/on_deactivate/on_deactivate_example.ts index a4b4c15072..a3875b7879 100644 --- a/modules/angular2/examples/router/ts/on_deactivate/on_deactivate_example.ts +++ b/modules/angular2/examples/router/ts/on_deactivate/on_deactivate_example.ts @@ -1,12 +1,7 @@ import {Component, Injectable, provide} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; -import { - OnDeactivate, - ComponentInstruction, - RouteConfig, - ROUTER_DIRECTIVES, - APP_BASE_HREF -} from 'angular2/router'; +import {OnDeactivate, ComponentInstruction, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router'; +import {APP_BASE_HREF} from 'angular2/platform/common'; @Injectable() diff --git a/modules/angular2/examples/router/ts/reuse/reuse_example.ts b/modules/angular2/examples/router/ts/reuse/reuse_example.ts index 7a2b182611..e2482653b4 100644 --- a/modules/angular2/examples/router/ts/reuse/reuse_example.ts +++ b/modules/angular2/examples/router/ts/reuse/reuse_example.ts @@ -5,11 +5,11 @@ import { RouteConfig, ComponentInstruction, ROUTER_DIRECTIVES, - APP_BASE_HREF, CanReuse, RouteParams, OnReuse } from 'angular2/router'; +import {APP_BASE_HREF} from 'angular2/platform/common'; // #docregion reuseCmp diff --git a/modules/angular2/platform/common.ts b/modules/angular2/platform/common.ts new file mode 100644 index 0000000000..c0e4a141a8 --- /dev/null +++ b/modules/angular2/platform/common.ts @@ -0,0 +1,5 @@ +/** + * Platform agnostic services. + * Can be used both in the browser and on the server. + */ +export * from 'angular2/src/platform/location'; diff --git a/modules/angular2/platform/common_dom.ts b/modules/angular2/platform/common_dom.ts index 50d3b5ba04..a6a4601b90 100644 --- a/modules/angular2/platform/common_dom.ts +++ b/modules/angular2/platform/common_dom.ts @@ -1,5 +1,6 @@ /** - * This is a set of classes and objects that can be used both in the browser and on the server. + * This is a set of DOM related classes and objects that can be used both in the browser and on the + * server. */ export {DOM, setRootDomAdapter, DomAdapter} from 'angular2/src/platform/dom/dom_adapter'; export {DomRenderer} from 'angular2/src/platform/dom/dom_renderer'; diff --git a/modules/angular2/platform/testing/browser_static.ts b/modules/angular2/platform/testing/browser_static.ts index c176bd98c3..86f5984372 100644 --- a/modules/angular2/platform/testing/browser_static.ts +++ b/modules/angular2/platform/testing/browser_static.ts @@ -14,7 +14,7 @@ import {MockAnimationBuilder} from 'angular2/src/mock/animation_builder_mock'; import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock'; import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock'; import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy'; -import {LocationStrategy} from 'angular2/src/router/location/location_strategy'; +import {LocationStrategy} from 'angular2/platform/common'; import {MockNgZone} from 'angular2/src/mock/ng_zone_mock'; import {XHRImpl} from "angular2/src/platform/browser/xhr_impl"; diff --git a/modules/angular2/platform/testing/server.ts b/modules/angular2/platform/testing/server.ts index 7e78718a0b..fdd710c2a4 100644 --- a/modules/angular2/platform/testing/server.ts +++ b/modules/angular2/platform/testing/server.ts @@ -16,7 +16,6 @@ import {MockAnimationBuilder} from 'angular2/src/mock/animation_builder_mock'; import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock'; import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock'; import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy'; -import {LocationStrategy} from 'angular2/src/router/location/location_strategy'; import {MockNgZone} from 'angular2/src/mock/ng_zone_mock'; import {TestComponentBuilder} from 'angular2/src/testing/test_component_builder'; @@ -36,6 +35,7 @@ import { ELEMENT_PROBE_PROVIDERS } from 'angular2/platform/common_dom'; import {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events'; +import {LocationStrategy} from 'angular2/platform/common'; import {CONST_EXPR} from 'angular2/src/facade/lang'; diff --git a/modules/angular2/router.ts b/modules/angular2/router.ts index 245c2cb072..a84d3897bc 100644 --- a/modules/angular2/router.ts +++ b/modules/angular2/router.ts @@ -8,12 +8,7 @@ export {Router} from './src/router/router'; export {RouterOutlet} from './src/router/directives/router_outlet'; export {RouterLink} from './src/router/directives/router_link'; export {RouteParams, RouteData} from './src/router/instruction'; -export {PlatformLocation} from './src/router/location/platform_location'; export {RouteRegistry, ROUTER_PRIMARY_COMPONENT} from './src/router/route_registry'; -export {LocationStrategy, APP_BASE_HREF} from './src/router/location/location_strategy'; -export {HashLocationStrategy} from './src/router/location/hash_location_strategy'; -export {PathLocationStrategy} from './src/router/location/path_location_strategy'; -export {Location} from './src/router/location/location'; export * from './src/router/route_config/route_config_decorator'; export * from './src/router/route_definition'; export {OnActivate, OnDeactivate, OnReuse, CanDeactivate, CanReuse} from './src/router/interfaces'; diff --git a/modules/angular2/src/mock/location_mock.ts b/modules/angular2/src/mock/location_mock.ts index 759ab04c2b..5effadff63 100644 --- a/modules/angular2/src/mock/location_mock.ts +++ b/modules/angular2/src/mock/location_mock.ts @@ -1,7 +1,7 @@ import {Injectable} from 'angular2/src/core/di'; import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; import {ListWrapper} from 'angular2/src/facade/collection'; -import {Location} from 'angular2/src/router/location/location'; +import {Location} from 'angular2/platform/common'; /** * A spy for {@link Location} that allows tests to fire simulated location events. diff --git a/modules/angular2/src/mock/mock_location_strategy.ts b/modules/angular2/src/mock/mock_location_strategy.ts index 9fa30767d0..161f45d571 100644 --- a/modules/angular2/src/mock/mock_location_strategy.ts +++ b/modules/angular2/src/mock/mock_location_strategy.ts @@ -1,6 +1,6 @@ import {Injectable} from 'angular2/src/core/di'; import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; -import {LocationStrategy} from 'angular2/src/router/location/location_strategy'; +import {LocationStrategy} from 'angular2/platform/common'; /** diff --git a/modules/angular2/src/router/location/browser_platform_location.ts b/modules/angular2/src/platform/browser/location/browser_platform_location.ts similarity index 91% rename from modules/angular2/src/router/location/browser_platform_location.ts rename to modules/angular2/src/platform/browser/location/browser_platform_location.ts index 88917717fc..3572080582 100644 --- a/modules/angular2/src/router/location/browser_platform_location.ts +++ b/modules/angular2/src/platform/browser/location/browser_platform_location.ts @@ -1,7 +1,6 @@ -import {Injectable} from 'angular2/core'; +import {Injectable} from 'angular2/src/core/di/decorators'; +import {UrlChangeListener, PlatformLocation} from './platform_location'; import {History, Location} from 'angular2/src/facade/browser'; -import {UrlChangeListener} from './platform_location'; -import {PlatformLocation} from './platform_location'; import {DOM} from 'angular2/src/platform/dom/dom_adapter'; /** diff --git a/modules/angular2/src/router/location/hash_location_strategy.ts b/modules/angular2/src/platform/browser/location/hash_location_strategy.ts similarity index 84% rename from modules/angular2/src/router/location/hash_location_strategy.ts rename to modules/angular2/src/platform/browser/location/hash_location_strategy.ts index 26dd67016d..0f1fccd994 100644 --- a/modules/angular2/src/router/location/hash_location_strategy.ts +++ b/modules/angular2/src/platform/browser/location/hash_location_strategy.ts @@ -1,13 +1,8 @@ import {Injectable, Inject, Optional} from 'angular2/core'; -import { - LocationStrategy, - joinWithSlash, - APP_BASE_HREF, - normalizeQueryParams -} from './location_strategy'; -import {UrlChangeListener} from './platform_location'; +import {LocationStrategy, APP_BASE_HREF} from './location_strategy'; +import {Location} from './location'; +import {UrlChangeListener, PlatformLocation} from './platform_location'; import {isPresent} from 'angular2/src/facade/lang'; -import {PlatformLocation} from './platform_location'; /** * `HashLocationStrategy` is a {@link LocationStrategy} used to configure the @@ -23,12 +18,14 @@ import {PlatformLocation} from './platform_location'; * ``` * import {Component, provide} from 'angular2/core'; * import { - * ROUTER_DIRECTIVES, - * ROUTER_PROVIDERS, - * RouteConfig, * Location, * LocationStrategy, * HashLocationStrategy + * } from 'angular2/platform/common'; + * import { + * ROUTER_DIRECTIVES, + * ROUTER_PROVIDERS, + * RouteConfig * } from 'angular2/router'; * * @Component({directives: [ROUTER_DIRECTIVES]}) @@ -78,12 +75,12 @@ export class HashLocationStrategy extends LocationStrategy { } prepareExternalUrl(internal: string): string { - var url = joinWithSlash(this._baseHref, internal); + var url = Location.joinWithSlash(this._baseHref, internal); return url.length > 0 ? ('#' + url) : url; } pushState(state: any, title: string, path: string, queryParams: string) { - var url = this.prepareExternalUrl(path + normalizeQueryParams(queryParams)); + var url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams)); if (url.length == 0) { url = this._platformLocation.pathname; } @@ -91,7 +88,7 @@ export class HashLocationStrategy extends LocationStrategy { } replaceState(state: any, title: string, path: string, queryParams: string) { - var url = this.prepareExternalUrl(path + normalizeQueryParams(queryParams)); + var url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams)); if (url.length == 0) { url = this._platformLocation.pathname; } diff --git a/modules/angular2/src/router/location/location.ts b/modules/angular2/src/platform/browser/location/location.ts similarity index 74% rename from modules/angular2/src/router/location/location.ts rename to modules/angular2/src/platform/browser/location/location.ts index 8684a34681..ef4254be27 100644 --- a/modules/angular2/src/router/location/location.ts +++ b/modules/angular2/src/platform/browser/location/location.ts @@ -1,6 +1,6 @@ -import {LocationStrategy} from './location_strategy'; import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; import {Injectable, Inject} from 'angular2/core'; +import {LocationStrategy} from './location_strategy'; /** * `Location` is a service that applications can use to interact with a browser's URL. @@ -22,11 +22,11 @@ import {Injectable, Inject} from 'angular2/core'; * * ``` * import {Component} from 'angular2/core'; + * import {Location} from 'angular2/platform/common'; * import { * ROUTER_DIRECTIVES, * ROUTER_PROVIDERS, - * RouteConfig, - * Location + * RouteConfig * } from 'angular2/router'; * * @Component({directives: [ROUTER_DIRECTIVES]}) @@ -51,7 +51,7 @@ export class Location { constructor(public platformStrategy: LocationStrategy) { var browserBaseHref = this.platformStrategy.getBaseHref(); - this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref)); + this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref)); this.platformStrategy.onPopState((ev) => { ObservableWrapper.callEmit(this._subject, {'url': this.path(), 'pop': true, 'type': ev.type}); }); @@ -67,7 +67,7 @@ export class Location { * trailing slashes */ normalize(url: string): string { - return stripTrailingSlash(_stripBaseHref(this._baseHref, stripIndexHtml(url))); + return Location.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url))); } /** @@ -117,6 +117,50 @@ export class Location { onReturn: () => void = null): Object { return ObservableWrapper.subscribe(this._subject, onNext, onThrow, onReturn); } + + /** + * Given a string of url parameters, prepend with '?' if needed, otherwise return parameters as + * is. + */ + public static normalizeQueryParams(params: string): string { + return (params.length > 0 && params.substring(0, 1) != '?') ? ('?' + params) : params; + } + + /** + * Given 2 parts of a url, join them with a slash if needed. + */ + public static joinWithSlash(start: string, end: string): string { + if (start.length == 0) { + return end; + } + if (end.length == 0) { + return start; + } + var slashes = 0; + if (start.endsWith('/')) { + slashes++; + } + if (end.startsWith('/')) { + slashes++; + } + if (slashes == 2) { + return start + end.substring(1); + } + if (slashes == 1) { + return start + end; + } + return start + '/' + end; + } + + /** + * If url has a trailing slash, remove it, otherwise return url as is. + */ + public static stripTrailingSlash(url: string): string { + if (/\/$/g.test(url)) { + url = url.substring(0, url.length - 1); + } + return url; + } } function _stripBaseHref(baseHref: string, url: string): string { @@ -126,17 +170,10 @@ function _stripBaseHref(baseHref: string, url: string): string { return url; } -function stripIndexHtml(url: string): string { +function _stripIndexHtml(url: string): string { if (/\/index.html$/g.test(url)) { // '/index.html'.length == 11 return url.substring(0, url.length - 11); } return url; } - -function stripTrailingSlash(url: string): string { - if (/\/$/g.test(url)) { - url = url.substring(0, url.length - 1); - } - return url; -} diff --git a/modules/angular2/src/router/location/location_strategy.ts b/modules/angular2/src/platform/browser/location/location_strategy.ts similarity index 77% rename from modules/angular2/src/router/location/location_strategy.ts rename to modules/angular2/src/platform/browser/location/location_strategy.ts index 7c258e2734..c7e93db163 100644 --- a/modules/angular2/src/router/location/location_strategy.ts +++ b/modules/angular2/src/platform/browser/location/location_strategy.ts @@ -43,6 +43,7 @@ export abstract class LocationStrategy { * ``` * import {Component} from 'angular2/core'; * import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router'; + * import {APP_BASE_HREF} from 'angular2/platform/common'; * * @Component({directives: [ROUTER_DIRECTIVES]}) * @RouteConfig([ @@ -59,30 +60,3 @@ export abstract class LocationStrategy { * ``` */ export const APP_BASE_HREF: OpaqueToken = CONST_EXPR(new OpaqueToken('appBaseHref')); - -export function normalizeQueryParams(params: string): string { - return (params.length > 0 && params.substring(0, 1) != '?') ? ('?' + params) : params; -} - -export function joinWithSlash(start: string, end: string): string { - if (start.length == 0) { - return end; - } - if (end.length == 0) { - return start; - } - var slashes = 0; - if (start.endsWith('/')) { - slashes++; - } - if (end.startsWith('/')) { - slashes++; - } - if (slashes == 2) { - return start + end.substring(1); - } - if (slashes == 1) { - return start + end; - } - return start + '/' + end; -} diff --git a/modules/angular2/src/router/location/path_location_strategy.ts b/modules/angular2/src/platform/browser/location/path_location_strategy.ts similarity index 80% rename from modules/angular2/src/router/location/path_location_strategy.ts rename to modules/angular2/src/platform/browser/location/path_location_strategy.ts index 7d114d1403..e5d953a045 100644 --- a/modules/angular2/src/router/location/path_location_strategy.ts +++ b/modules/angular2/src/platform/browser/location/path_location_strategy.ts @@ -1,13 +1,9 @@ import {Injectable, Inject, Optional} from 'angular2/core'; import {isBlank} from 'angular2/src/facade/lang'; import {BaseException} from 'angular2/src/facade/exceptions'; -import { - LocationStrategy, - APP_BASE_HREF, - normalizeQueryParams, - joinWithSlash -} from './location_strategy'; import {PlatformLocation, UrlChangeListener} from './platform_location'; +import {LocationStrategy, APP_BASE_HREF} from './location_strategy'; +import {Location} from './location'; /** * `PathLocationStrategy` is a {@link LocationStrategy} used to configure the @@ -30,12 +26,15 @@ import {PlatformLocation, UrlChangeListener} from './platform_location'; * * ``` * import {Component, provide} from 'angular2/core'; + * import {bootstrap} from 'angular2/platform/browser'; * import { + * Location, * APP_BASE_HREF + * } from 'angular2/platform/common'; + * import { * ROUTER_DIRECTIVES, * ROUTER_PROVIDERS, - * RouteConfig, - * Location + * RouteConfig * } from 'angular2/router'; * * @Component({directives: [ROUTER_DIRECTIVES]}) @@ -81,19 +80,22 @@ export class PathLocationStrategy extends LocationStrategy { getBaseHref(): string { return this._baseHref; } - prepareExternalUrl(internal: string): string { return joinWithSlash(this._baseHref, internal); } + prepareExternalUrl(internal: string): string { + return Location.joinWithSlash(this._baseHref, internal); + } path(): string { - return this._platformLocation.pathname + normalizeQueryParams(this._platformLocation.search); + return this._platformLocation.pathname + + Location.normalizeQueryParams(this._platformLocation.search); } pushState(state: any, title: string, url: string, queryParams: string) { - var externalUrl = this.prepareExternalUrl(url + normalizeQueryParams(queryParams)); + var externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams)); this._platformLocation.pushState(state, title, externalUrl); } replaceState(state: any, title: string, url: string, queryParams: string) { - var externalUrl = this.prepareExternalUrl(url + normalizeQueryParams(queryParams)); + var externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams)); this._platformLocation.replaceState(state, title, externalUrl); } diff --git a/modules/angular2/src/router/location/platform_location.ts b/modules/angular2/src/platform/browser/location/platform_location.ts similarity index 100% rename from modules/angular2/src/router/location/platform_location.ts rename to modules/angular2/src/platform/browser/location/platform_location.ts diff --git a/modules/angular2/src/platform/location.ts b/modules/angular2/src/platform/location.ts new file mode 100644 index 0000000000..947856be74 --- /dev/null +++ b/modules/angular2/src/platform/location.ts @@ -0,0 +1,5 @@ +export * from './browser/location/platform_location'; +export * from './browser/location/location_strategy'; +export * from './browser/location/hash_location_strategy'; +export * from './browser/location/path_location_strategy'; +export * from './browser/location/location'; diff --git a/modules/angular2/src/platform/worker_render_common.ts b/modules/angular2/src/platform/worker_render_common.ts index 59360b5335..4bcf974b18 100644 --- a/modules/angular2/src/platform/worker_render_common.ts +++ b/modules/angular2/src/platform/worker_render_common.ts @@ -36,7 +36,6 @@ import {BrowserDomAdapter} from './browser/browser_adapter'; import {wtfInit} from 'angular2/src/core/profile/wtf_init'; import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer'; import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl'; -import {BrowserPlatformLocation} from 'angular2/src/router/location/browser_platform_location'; import { ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_ @@ -45,6 +44,9 @@ import { ClientMessageBrokerFactory, ClientMessageBrokerFactory_ } from 'angular2/src/web_workers/shared/client_message_broker'; +import { + BrowserPlatformLocation +} from 'angular2/src/platform/browser/location/browser_platform_location'; import {Serializer} from 'angular2/src/web_workers/shared/serializer'; import {ON_WEB_WORKER} from 'angular2/src/web_workers/shared/api'; import {RenderStore} from 'angular2/src/web_workers/shared/render_store'; diff --git a/modules/angular2/src/router/directives/router_link.ts b/modules/angular2/src/router/directives/router_link.ts index 45e288fa18..627aa24c30 100644 --- a/modules/angular2/src/router/directives/router_link.ts +++ b/modules/angular2/src/router/directives/router_link.ts @@ -1,8 +1,8 @@ import {Directive} from 'angular2/core'; +import {Location} from 'angular2/platform/common'; import {isString} from 'angular2/src/facade/lang'; import {Router} from '../router'; -import {Location} from '../location/location'; import {Instruction} from '../instruction'; /** diff --git a/modules/angular2/src/router/router.ts b/modules/angular2/src/router/router.ts index 2547279871..aca28dd772 100644 --- a/modules/angular2/src/router/router.ts +++ b/modules/angular2/src/router/router.ts @@ -2,6 +2,7 @@ import {PromiseWrapper, EventEmitter, ObservableWrapper} from 'angular2/src/faca import {Map, StringMapWrapper, MapWrapper, ListWrapper} from 'angular2/src/facade/collection'; import {isBlank, isString, isPresent, Type, isArray} from 'angular2/src/facade/lang'; import {BaseException, WrappedException} from 'angular2/src/facade/exceptions'; +import {Location} from 'angular2/platform/common'; import {Inject, Injectable} from 'angular2/core'; import {RouteRegistry, ROUTER_PRIMARY_COMPONENT} from './route_registry'; @@ -10,7 +11,6 @@ import { Instruction, } from './instruction'; import {RouterOutlet} from './directives/router_outlet'; -import {Location} from './location/location'; import {getCanActivateHook} from './lifecycle/route_lifecycle_reflector'; import {RouteDefinition} from './route_config/route_config_impl'; diff --git a/modules/angular2/src/router/router_providers.ts b/modules/angular2/src/router/router_providers.ts index 081765312a..a1327cb649 100644 --- a/modules/angular2/src/router/router_providers.ts +++ b/modules/angular2/src/router/router_providers.ts @@ -1,8 +1,10 @@ import {ROUTER_PROVIDERS_COMMON} from './router_providers_common'; import {Provider} from 'angular2/core'; +import { + BrowserPlatformLocation +} from 'angular2/src/platform/browser/location/browser_platform_location'; +import {PlatformLocation} from 'angular2/platform/common'; import {CONST_EXPR} from 'angular2/src/facade/lang'; -import {BrowserPlatformLocation} from './location/browser_platform_location'; -import {PlatformLocation} from './location/platform_location'; /** * A list of {@link Provider}s. To use the router, you must add this to your application. diff --git a/modules/angular2/src/router/router_providers_common.ts b/modules/angular2/src/router/router_providers_common.ts index f2c3a65827..529055c436 100644 --- a/modules/angular2/src/router/router_providers_common.ts +++ b/modules/angular2/src/router/router_providers_common.ts @@ -1,8 +1,6 @@ -import {LocationStrategy} from 'angular2/src/router/location/location_strategy'; -import {PathLocationStrategy} from 'angular2/src/router/location/path_location_strategy'; +import {LocationStrategy, PathLocationStrategy, Location} from 'angular2/platform/common'; import {Router, RootRouter} from 'angular2/src/router/router'; import {RouteRegistry, ROUTER_PRIMARY_COMPONENT} from 'angular2/src/router/route_registry'; -import {Location} from 'angular2/src/router/location/location'; import {CONST_EXPR, Type} from 'angular2/src/facade/lang'; import {ApplicationRef, OpaqueToken, Provider} from 'angular2/core'; import {BaseException} from 'angular2/src/facade/exceptions'; diff --git a/modules/angular2/src/web_workers/ui/platform_location.ts b/modules/angular2/src/web_workers/ui/platform_location.ts index fa9bd1c315..60d59d3231 100644 --- a/modules/angular2/src/web_workers/ui/platform_location.ts +++ b/modules/angular2/src/web_workers/ui/platform_location.ts @@ -1,4 +1,7 @@ -import {BrowserPlatformLocation} from 'angular2/src/router/location/browser_platform_location'; +import { + BrowserPlatformLocation +} from 'angular2/src/platform/browser/location/browser_platform_location'; +import {UrlChangeListener} from 'angular2/platform/common'; import {Injectable} from 'angular2/src/core/di'; import {ROUTER_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api'; import { @@ -10,7 +13,6 @@ import {bind} from './bind'; import {LocationType} from 'angular2/src/web_workers/shared/serialized_types'; import {MessageBus} from 'angular2/src/web_workers/shared/message_bus'; import {EventEmitter, ObservableWrapper, PromiseWrapper} from 'angular2/src/facade/async'; -import {UrlChangeListener} from 'angular2/src/router/location/platform_location'; @Injectable() export class MessageBasedPlatformLocation { diff --git a/modules/angular2/src/web_workers/ui/router_providers.ts b/modules/angular2/src/web_workers/ui/router_providers.ts index 21edef9beb..4d1df791d8 100644 --- a/modules/angular2/src/web_workers/ui/router_providers.ts +++ b/modules/angular2/src/web_workers/ui/router_providers.ts @@ -1,6 +1,8 @@ import {MessageBasedPlatformLocation} from './platform_location'; import {CONST_EXPR} from 'angular2/src/facade/lang'; -import {BrowserPlatformLocation} from 'angular2/src/router/location/browser_platform_location'; +import { + BrowserPlatformLocation +} from 'angular2/src/platform/browser/location/browser_platform_location'; import {APP_INITIALIZER, Provider, Injector, NgZone} from 'angular2/core'; export const WORKER_RENDER_ROUTER = CONST_EXPR([ diff --git a/modules/angular2/src/web_workers/worker/platform_location.ts b/modules/angular2/src/web_workers/worker/platform_location.ts index 59ce6bee84..73881ce389 100644 --- a/modules/angular2/src/web_workers/worker/platform_location.ts +++ b/modules/angular2/src/web_workers/worker/platform_location.ts @@ -1,15 +1,11 @@ import {Injectable} from 'angular2/src/core/di'; -import { - PlatformLocation, - UrlChangeEvent, - UrlChangeListener -} from 'angular2/src/router/location/platform_location'; import { FnArg, UiArguments, ClientMessageBroker, ClientMessageBrokerFactory } from 'angular2/src/web_workers/shared/client_message_broker'; +import {PlatformLocation, UrlChangeEvent, UrlChangeListener} from 'angular2/platform/common'; import {ROUTER_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api'; import {LocationType} from 'angular2/src/web_workers/shared/serialized_types'; import {PromiseWrapper, EventEmitter, ObservableWrapper} from 'angular2/src/facade/async'; diff --git a/modules/angular2/src/web_workers/worker/router_providers.ts b/modules/angular2/src/web_workers/worker/router_providers.ts index 3a07f1cdd5..c6742ea581 100644 --- a/modules/angular2/src/web_workers/worker/router_providers.ts +++ b/modules/angular2/src/web_workers/worker/router_providers.ts @@ -1,5 +1,5 @@ import {ApplicationRef, Provider, NgZone, APP_INITIALIZER} from 'angular2/core'; -import {PlatformLocation} from 'angular2/src/router/location/platform_location'; +import {PlatformLocation} from 'angular2/platform/common'; import {WebWorkerPlatformLocation} from './platform_location'; import {ROUTER_PROVIDERS_COMMON} from 'angular2/src/router/router_providers_common'; diff --git a/modules/angular2/test/platform/browser/bootstrap_spec.ts b/modules/angular2/test/platform/browser/bootstrap_spec.ts index 4c99af2f15..b8d6c177b4 100644 --- a/modules/angular2/test/platform/browser/bootstrap_spec.ts +++ b/modules/angular2/test/platform/browser/bootstrap_spec.ts @@ -13,11 +13,10 @@ import { xit } from 'angular2/testing_internal'; import {IS_DART, isPresent, stringify} from 'angular2/src/facade/lang'; -import {bootstrap} from 'angular2/platform/browser'; +import {bootstrap, BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser'; import {ApplicationRef} from 'angular2/src/core/application_ref'; import {Console} from 'angular2/src/core/console'; import {Component, Directive, OnDestroy, platform} from 'angular2/core'; -import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser'; import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens'; import {PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async'; diff --git a/modules/angular2/test/public_api_spec.ts b/modules/angular2/test/public_api_spec.ts index 68b3f91c4a..e365717eaa 100644 --- a/modules/angular2/test/public_api_spec.ts +++ b/modules/angular2/test/public_api_spec.ts @@ -311,6 +311,17 @@ var NG_PLATFORM_BROWSER = [ 'inspectNativeElement' ]; +var NG_PLATFORM_COMMON = [ + 'APP_BASE_HREF', + 'HashLocationStrategy', + 'Location', + 'LocationStrategy', + 'PathLocationStrategy', + 'PlatformLocation', + 'UrlChangeEvent:dart', + 'UrlChangeListener:dart' +]; + var NG_UPGRADE = [ 'UpgradeAdapter', 'UpgradeAdapterRef', @@ -322,6 +333,7 @@ var NG_API = { ngCore: NG_CORE, ngInstrumentation: NG_INSTRUMENTATION, ngPlatformBrowser: NG_PLATFORM_BROWSER, + ngPlatformCommon: NG_PLATFORM_COMMON, ngUpgrade: NG_UPGRADE }; @@ -336,8 +348,15 @@ export function main() { */ describe('public API', () => { - var barrelList = - ['ngCommon', 'ngCompiler', 'ngCore', 'ngInstrumentation', 'ngPlatformBrowser', 'ngUpgrade']; + var barrelList = [ + 'ngCommon', + 'ngCompiler', + 'ngCore', + 'ngInstrumentation', + 'ngPlatformBrowser', + 'ngPlatformCommon', + 'ngUpgrade' + ]; if (IS_DART) { barrelList = barrelList.filter(b => b !== 'ngUpgrade'); diff --git a/modules/angular2/test/router/directives/router_link_spec.ts b/modules/angular2/test/router/directives/router_link_spec.ts index 0105616bd5..2b5ec177f3 100644 --- a/modules/angular2/test/router/directives/router_link_spec.ts +++ b/modules/angular2/test/router/directives/router_link_spec.ts @@ -18,9 +18,9 @@ import {SpyRouter, SpyLocation} from '../spies'; import {provide, Component} from 'angular2/core'; import {By} from 'angular2/platform/common_dom'; +import {Location} from 'angular2/platform/common'; import { - Location, Router, RouteRegistry, RouterLink, diff --git a/modules/angular2/test/router/integration/bootstrap_spec.ts b/modules/angular2/test/router/integration/bootstrap_spec.ts index f064852dc6..07ec1ec07e 100644 --- a/modules/angular2/test/router/integration/bootstrap_spec.ts +++ b/modules/angular2/test/router/integration/bootstrap_spec.ts @@ -15,6 +15,7 @@ import { } from 'angular2/testing_internal'; import {bootstrap} from 'angular2/platform/browser'; +import {APP_BASE_HREF, LocationStrategy} from 'angular2/platform/common'; import {Component, Directive} from 'angular2/src/core/metadata'; import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {Console} from 'angular2/src/core/console'; @@ -33,9 +34,7 @@ import { ROUTER_PRIMARY_COMPONENT, RouteParams, Router, - APP_BASE_HREF, - ROUTER_DIRECTIVES, - LocationStrategy + ROUTER_DIRECTIVES } from 'angular2/router'; import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy'; diff --git a/modules/angular2/test/router/integration/impl/async_route_spec_impl.ts b/modules/angular2/test/router/integration/impl/async_route_spec_impl.ts index 3303ff2926..d3fdb8c5c8 100644 --- a/modules/angular2/test/router/integration/impl/async_route_spec_impl.ts +++ b/modules/angular2/test/router/integration/impl/async_route_spec_impl.ts @@ -12,12 +12,12 @@ import { xit, } from 'angular2/testing_internal'; - import {By} from 'angular2/platform/common_dom'; +import {Location} from 'angular2/platform/common'; import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util'; -import {Router, AsyncRoute, Route, Location} from 'angular2/router'; +import {Router, AsyncRoute, Route} from 'angular2/router'; import { HelloCmp, diff --git a/modules/angular2/test/router/integration/impl/aux_route_spec_impl.ts b/modules/angular2/test/router/integration/impl/aux_route_spec_impl.ts index f7b26c515a..af0edeba2b 100644 --- a/modules/angular2/test/router/integration/impl/aux_route_spec_impl.ts +++ b/modules/angular2/test/router/integration/impl/aux_route_spec_impl.ts @@ -16,9 +16,10 @@ import { } from 'angular2/testing_internal'; import {By} from 'angular2/platform/common_dom'; +import {Location} from 'angular2/platform/common'; import {provide, Component, Injector, Inject} from 'angular2/core'; -import {Router, ROUTER_DIRECTIVES, RouteParams, RouteData, Location} from 'angular2/router'; +import {Router, ROUTER_DIRECTIVES, RouteParams, RouteData} from 'angular2/router'; import { RouteConfig, Route, diff --git a/modules/angular2/test/router/integration/impl/sync_route_spec_impl.ts b/modules/angular2/test/router/integration/impl/sync_route_spec_impl.ts index 0a1f7af132..4818dc2118 100644 --- a/modules/angular2/test/router/integration/impl/sync_route_spec_impl.ts +++ b/modules/angular2/test/router/integration/impl/sync_route_spec_impl.ts @@ -15,7 +15,8 @@ import { import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util'; import {By} from 'angular2/platform/common_dom'; -import {Router, Route, Location} from 'angular2/router'; +import {Location} from 'angular2/platform/common'; +import {Router, Route} from 'angular2/router'; import { HelloCmp, diff --git a/modules/angular2/test/router/integration/navigation_spec.ts b/modules/angular2/test/router/integration/navigation_spec.ts index f1e40e3a02..8e97d59269 100644 --- a/modules/angular2/test/router/integration/navigation_spec.ts +++ b/modules/angular2/test/router/integration/navigation_spec.ts @@ -16,9 +16,10 @@ import { } from 'angular2/testing_internal'; import {provide, Component, Injector, Inject} from 'angular2/core'; +import {Location} from 'angular2/platform/common'; import {PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async'; -import {Router, RouterOutlet, RouterLink, RouteParams, RouteData, Location} from 'angular2/router'; +import {Router, RouterOutlet, RouterLink, RouteParams, RouteData} from 'angular2/router'; import { RouteConfig, Route, diff --git a/modules/angular2/test/router/integration/redirect_route_spec.ts b/modules/angular2/test/router/integration/redirect_route_spec.ts index 84fd398eee..1049ff0d12 100644 --- a/modules/angular2/test/router/integration/redirect_route_spec.ts +++ b/modules/angular2/test/router/integration/redirect_route_spec.ts @@ -15,7 +15,7 @@ import { xit } from 'angular2/testing_internal'; -import {Router, RouterOutlet, RouterLink, RouteParams, RouteData, Location} from 'angular2/router'; +import {Router, RouterOutlet, RouterLink, RouteParams, RouteData} from 'angular2/router'; import { RouteConfig, Route, @@ -23,6 +23,7 @@ import { AsyncRoute, Redirect } from 'angular2/src/router/route_config/route_config_decorator'; +import {Location} from 'angular2/platform/common'; import {TEST_ROUTER_PROVIDERS, RootCmp, compile} from './util'; import {HelloCmp, GoodbyeCmp, RedirectToParentCmp} from './impl/fixture_components'; diff --git a/modules/angular2/test/router/integration/router_link_spec.ts b/modules/angular2/test/router/integration/router_link_spec.ts index 376dcab662..297969bc66 100644 --- a/modules/angular2/test/router/integration/router_link_spec.ts +++ b/modules/angular2/test/router/integration/router_link_spec.ts @@ -18,6 +18,7 @@ import { } from 'angular2/testing_internal'; import {By} from 'angular2/platform/common_dom'; +import {Location} from 'angular2/platform/common'; import {NumberWrapper} from 'angular2/src/facade/lang'; import {PromiseWrapper} from 'angular2/src/facade/async'; import {ListWrapper} from 'angular2/src/facade/collection'; @@ -26,7 +27,6 @@ import {provide, Component} from 'angular2/core'; import {SpyLocation} from 'angular2/src/mock/location_mock'; import { - Location, Router, RouteRegistry, RouterLink, diff --git a/modules/angular2/test/router/integration/util.ts b/modules/angular2/test/router/integration/util.ts index 848a469b92..56ce6d8719 100644 --- a/modules/angular2/test/router/integration/util.ts +++ b/modules/angular2/test/router/integration/util.ts @@ -21,7 +21,7 @@ import {RootRouter} from 'angular2/src/router/router'; import {Router, ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT} from 'angular2/router'; import {SpyLocation} from 'angular2/src/mock/location_mock'; -import {Location} from 'angular2/src/router/location/location'; +import {Location} from 'angular2/platform/common'; import {RouteRegistry} from 'angular2/src/router/route_registry'; import {DOM} from 'angular2/src/platform/dom/dom_adapter'; export {ComponentFixture} from 'angular2/testing_internal'; diff --git a/modules/angular2/test/router/location/hash_location_strategy_spec.ts b/modules/angular2/test/router/location/hash_location_strategy_spec.ts index ad79255819..d52b4b5027 100644 --- a/modules/angular2/test/router/location/hash_location_strategy_spec.ts +++ b/modules/angular2/test/router/location/hash_location_strategy_spec.ts @@ -14,9 +14,7 @@ import { import {Injector, provide} from 'angular2/core'; -import {PlatformLocation} from 'angular2/src/router/location/platform_location'; -import {APP_BASE_HREF} from 'angular2/src/router/location/location_strategy'; -import {HashLocationStrategy} from 'angular2/src/router/location/hash_location_strategy'; +import {PlatformLocation, APP_BASE_HREF, HashLocationStrategy} from 'angular2/platform/common'; import {SpyPlatformLocation} from '../spies'; export function main() { diff --git a/modules/angular2/test/router/location/location_spec.ts b/modules/angular2/test/router/location/location_spec.ts index 09e1296b97..045778c3d9 100644 --- a/modules/angular2/test/router/location/location_spec.ts +++ b/modules/angular2/test/router/location/location_spec.ts @@ -15,8 +15,7 @@ import { import {Injector, provide} from 'angular2/core'; import {CONST_EXPR} from 'angular2/src/facade/lang'; -import {Location} from 'angular2/src/router/location/location'; -import {LocationStrategy, APP_BASE_HREF} from 'angular2/src/router/location/location_strategy'; +import {Location, LocationStrategy, APP_BASE_HREF} from 'angular2/platform/common'; import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy'; export function main() { diff --git a/modules/angular2/test/router/location/path_location_strategy_spec.ts b/modules/angular2/test/router/location/path_location_strategy_spec.ts index c884b1e6bb..dc6f98f121 100644 --- a/modules/angular2/test/router/location/path_location_strategy_spec.ts +++ b/modules/angular2/test/router/location/path_location_strategy_spec.ts @@ -15,9 +15,12 @@ import { import {Injector, provide} from 'angular2/core'; import {CONST_EXPR} from 'angular2/src/facade/lang'; -import {PlatformLocation} from 'angular2/src/router/location/platform_location'; -import {LocationStrategy, APP_BASE_HREF} from 'angular2/src/router/location/location_strategy'; -import {PathLocationStrategy} from 'angular2/src/router/location/path_location_strategy'; +import { + PlatformLocation, + LocationStrategy, + PathLocationStrategy, + APP_BASE_HREF +} from 'angular2/platform/common'; import {SpyPlatformLocation} from '../spies'; export function main() { diff --git a/modules/angular2/test/router/route_config/route_config_spec.ts b/modules/angular2/test/router/route_config/route_config_spec.ts index 7da0123fff..93d18b2f2e 100644 --- a/modules/angular2/test/router/route_config/route_config_spec.ts +++ b/modules/angular2/test/router/route_config/route_config_spec.ts @@ -12,6 +12,7 @@ import { } from 'angular2/testing_internal'; import {bootstrap} from 'angular2/platform/browser'; +import {APP_BASE_HREF, LocationStrategy} from 'angular2/platform/common'; import {Component, Directive} from 'angular2/src/core/metadata'; import {DOM} from 'angular2/src/platform/dom/dom_adapter'; import {Console} from 'angular2/src/core/console'; @@ -19,16 +20,9 @@ import {provide} from 'angular2/core'; import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens'; import {Type, IS_DART} from 'angular2/src/facade/lang'; -import { - ROUTER_PROVIDERS, - Router, - RouteConfig, - APP_BASE_HREF, - ROUTER_DIRECTIVES -} from 'angular2/router'; +import {ROUTER_PROVIDERS, Router, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router'; import {ExceptionHandler} from 'angular2/src/facade/exceptions'; -import {LocationStrategy} from 'angular2/src/router/location/location_strategy'; import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy'; class _ArrayLogger { diff --git a/modules/angular2/test/router/router_spec.ts b/modules/angular2/test/router/router_spec.ts index d349e7f5ce..d9768c5238 100644 --- a/modules/angular2/test/router/router_spec.ts +++ b/modules/angular2/test/router/router_spec.ts @@ -18,7 +18,7 @@ import {ListWrapper} from 'angular2/src/facade/collection'; import {Router, RootRouter} from 'angular2/src/router/router'; import {SpyLocation} from 'angular2/src/mock/location_mock'; -import {Location} from 'angular2/src/router/location/location'; +import {Location} from 'angular2/platform/common'; import {RouteRegistry, ROUTER_PRIMARY_COMPONENT} from 'angular2/src/router/route_registry'; import { diff --git a/modules/angular2/test/router/spies.dart b/modules/angular2/test/router/spies.dart index 47a45f91bd..da5df6692d 100644 --- a/modules/angular2/test/router/spies.dart +++ b/modules/angular2/test/router/spies.dart @@ -1,5 +1,6 @@ library router.spies; +import 'package:angular2/platform/common.dart' show PlatformLocation, Location; import 'package:angular2/router.dart'; import 'package:angular2/testing_internal.dart'; diff --git a/modules/angular2/test/router/spies.ts b/modules/angular2/test/router/spies.ts index a6b2a910fa..42e4d45fbb 100644 --- a/modules/angular2/test/router/spies.ts +++ b/modules/angular2/test/router/spies.ts @@ -1,4 +1,5 @@ -import {Router, RouterOutlet, Location, PlatformLocation} from 'angular2/router'; +import {Location} from 'angular2/platform/common'; +import {Router, RouterOutlet} from 'angular2/router'; import {SpyObject, proxy} from 'angular2/testing_internal'; export class SpyRouter extends SpyObject { diff --git a/modules/angular2/test/symbol_inspector/symbol_inspector.dart b/modules/angular2/test/symbol_inspector/symbol_inspector.dart index 855657f075..4634471b64 100644 --- a/modules/angular2/test/symbol_inspector/symbol_inspector.dart +++ b/modules/angular2/test/symbol_inspector/symbol_inspector.dart @@ -23,7 +23,8 @@ const LIB_MAP = const { 'ngCompiler': 'angular2.compiler', 'ngCore': 'angular2.core', 'ngInstrumentation': 'angular2.instrumentation', - 'ngPlatformBrowser': 'angular2.platform.browser' + 'ngPlatformBrowser': 'angular2.platform.browser', + 'ngPlatformCommon': 'angular2.platform.common' }; // Have this list here to trick dart to force import. diff --git a/modules/angular2/test/symbol_inspector/symbol_inspector.ts b/modules/angular2/test/symbol_inspector/symbol_inspector.ts index 6c45540482..42ff8d1eaf 100644 --- a/modules/angular2/test/symbol_inspector/symbol_inspector.ts +++ b/modules/angular2/test/symbol_inspector/symbol_inspector.ts @@ -4,6 +4,7 @@ import * as ngCompiler from 'angular2/compiler'; import * as ngCore from 'angular2/core'; import * as ngInstrumentation from 'angular2/instrumentation'; import * as ngPlatformBrowser from 'angular2/platform/browser'; +import * as ngPlatformCommon from 'angular2/platform/common'; import * as ngUpgrade from 'angular2/upgrade'; const LIB_MAP = { @@ -13,6 +14,7 @@ const LIB_MAP = { ngCore, ngInstrumentation, ngPlatformBrowser, + ngPlatformCommon, ngUpgrade }; diff --git a/modules/playground/src/hash_routing/index.ts b/modules/playground/src/hash_routing/index.ts index 94f24135bf..0d31ae7f01 100644 --- a/modules/playground/src/hash_routing/index.ts +++ b/modules/playground/src/hash_routing/index.ts @@ -1,13 +1,7 @@ import {Component, provide} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; -import { - RouteConfig, - Route, - ROUTER_PROVIDERS, - ROUTER_DIRECTIVES, - HashLocationStrategy, - LocationStrategy -} from 'angular2/router'; +import {RouteConfig, Route, ROUTER_PROVIDERS, ROUTER_DIRECTIVES} from 'angular2/router'; +import {HashLocationStrategy, LocationStrategy} from 'angular2/platform/common'; @Component({selector: 'hello-cmp', template: `hello`}) diff --git a/modules/playground/src/routing/inbox-app.ts b/modules/playground/src/routing/inbox-app.ts index d8a0d63751..519e2dd1e5 100644 --- a/modules/playground/src/routing/inbox-app.ts +++ b/modules/playground/src/routing/inbox-app.ts @@ -1,14 +1,7 @@ import {Component, Injectable} from 'angular2/core'; -import { - RouterLink, - RouteConfig, - Router, - Route, - RouterOutlet, - Location, - RouteParams -} from 'angular2/router'; +import {RouterLink, RouteConfig, Router, Route, RouterOutlet, RouteParams} from 'angular2/router'; import * as db from './data'; +import {Location} from 'angular2/platform/common'; import {PromiseWrapper} from 'angular2/src/facade/async'; import {isPresent, DateWrapper} from 'angular2/src/facade/lang'; import {PromiseCompleter} from 'angular2/src/facade/promise'; diff --git a/modules/playground/src/routing/index.ts b/modules/playground/src/routing/index.ts index c745adeb23..577ab49134 100644 --- a/modules/playground/src/routing/index.ts +++ b/modules/playground/src/routing/index.ts @@ -1,7 +1,8 @@ import {InboxApp} from './inbox-app'; import {provide} from 'angular2/core'; import {bootstrap} from 'angular2/platform/browser'; -import {ROUTER_PROVIDERS, HashLocationStrategy, LocationStrategy} from 'angular2/router'; +import {HashLocationStrategy, LocationStrategy} from 'angular2/platform/common'; +import {ROUTER_PROVIDERS} from 'angular2/router'; export function main() { bootstrap(InboxApp, diff --git a/modules/playground/src/web_workers/router/background_index.dart b/modules/playground/src/web_workers/router/background_index.dart index ce4530dfa9..8089e62558 100644 --- a/modules/playground/src/web_workers/router/background_index.dart +++ b/modules/playground/src/web_workers/router/background_index.dart @@ -4,8 +4,8 @@ import "index_common.dart" show App; import "dart:isolate"; import "package:angular2/platform/worker_app.dart"; import "package:angular2/core.dart"; +import "package:angular2/platform/common.dart" show LocationStrategy, HashLocationStrategy; import "package:angular2/src/web_workers/worker/router_providers.dart"; -import "package:angular2/router.dart"; @AngularEntrypoint() main(List args, SendPort replyTo) { diff --git a/modules/playground/src/web_workers/router/background_index.ts b/modules/playground/src/web_workers/router/background_index.ts index e9fe6157be..5e67f44e32 100644 --- a/modules/playground/src/web_workers/router/background_index.ts +++ b/modules/playground/src/web_workers/router/background_index.ts @@ -1,11 +1,11 @@ import {platform, Provider, NgZone} from "angular2/core"; +import {HashLocationStrategy, LocationStrategy} from 'angular2/platform/common'; import { WORKER_APP_PLATFORM, WORKER_APP_APPLICATION, WORKER_APP_ROUTER } from "angular2/platform/worker_app"; import {App} from "./index_common"; -import {HashLocationStrategy, LocationStrategy} from "angular2/router"; export function main() { let refPromise = platform([WORKER_APP_PLATFORM]) diff --git a/modules/playground/src/web_workers/router/index.ts b/modules/playground/src/web_workers/router/index.ts index 29f66f3ee4..35d5f75bcd 100644 --- a/modules/playground/src/web_workers/router/index.ts +++ b/modules/playground/src/web_workers/router/index.ts @@ -5,7 +5,6 @@ import { WORKER_SCRIPT, WORKER_RENDER_ROUTER } from 'angular2/platform/worker_render'; -import {BrowserPlatformLocation} from "angular2/src/router/location/browser_platform_location"; import {MessageBasedPlatformLocation} from "angular2/src/web_workers/ui/platform_location"; let ref = platform([WORKER_RENDER_PLATFORM]) @@ -13,4 +12,4 @@ let ref = platform([WORKER_RENDER_PLATFORM]) WORKER_RENDER_APP, new Provider(WORKER_SCRIPT, {useValue: "loader.js"}), WORKER_RENDER_ROUTER - ]); \ No newline at end of file + ]);