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
This commit is contained in:
Nathan Walker 2016-04-08 00:31:20 -07:00
parent 30c43521d3
commit b602bd8c83
55 changed files with 187 additions and 178 deletions

View File

@ -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';
export * from './src/common/common_directives';

View File

@ -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';

View File

@ -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({

View File

@ -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`})

View File

@ -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()

View File

@ -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

View File

@ -0,0 +1,5 @@
/**
* Platform agnostic services.
* Can be used both in the browser and on the server.
*/
export * from 'angular2/src/platform/location';

View File

@ -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';

View File

@ -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";

View File

@ -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';

View File

@ -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';

View File

@ -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.

View File

@ -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';
/**

View File

@ -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';
/**

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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';

View File

@ -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';

View File

@ -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';
/**

View File

@ -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';

View File

@ -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.

View File

@ -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';

View File

@ -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 {

View File

@ -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([

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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');

View File

@ -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,

View File

@ -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';

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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';

View File

@ -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,

View File

@ -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';

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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 {

View File

@ -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 {

View File

@ -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';

View File

@ -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 {

View File

@ -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.

View File

@ -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
};

View File

@ -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`})

View File

@ -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';

View File

@ -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,

View File

@ -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<String> args, SendPort replyTo) {

View File

@ -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])

View File

@ -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
]);
]);