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:
parent
30c43521d3
commit
b602bd8c83
|
@ -1,4 +1,4 @@
|
||||||
export * from './src/common/pipes';
|
export * from './src/common/pipes';
|
||||||
export * from './src/common/directives';
|
export * from './src/common/directives';
|
||||||
export * from './src/common/forms';
|
export * from './src/common/forms';
|
||||||
export * from './src/common/common_directives';
|
export * from './src/common/common_directives';
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import {provide, Component} from 'angular2/core';
|
import {provide, Component} from 'angular2/core';
|
||||||
import {bootstrap} from 'angular2/platform/browser';
|
import {bootstrap} from 'angular2/platform/browser';
|
||||||
import {
|
import {CanActivate, RouteConfig, ComponentInstruction, ROUTER_DIRECTIVES} from 'angular2/router';
|
||||||
CanActivate,
|
import {APP_BASE_HREF} from 'angular2/platform/common';
|
||||||
RouteConfig,
|
|
||||||
ComponentInstruction,
|
|
||||||
APP_BASE_HREF,
|
|
||||||
ROUTER_DIRECTIVES
|
|
||||||
} from 'angular2/router';
|
|
||||||
|
|
||||||
function checkIfWeHavePermission(instruction: ComponentInstruction) {
|
function checkIfWeHavePermission(instruction: ComponentInstruction) {
|
||||||
return instruction.params['id'] == '1';
|
return instruction.params['id'] == '1';
|
||||||
|
|
|
@ -5,9 +5,9 @@ import {
|
||||||
RouteConfig,
|
RouteConfig,
|
||||||
RouteParams,
|
RouteParams,
|
||||||
ComponentInstruction,
|
ComponentInstruction,
|
||||||
ROUTER_DIRECTIVES,
|
ROUTER_DIRECTIVES
|
||||||
APP_BASE_HREF
|
|
||||||
} from 'angular2/router';
|
} from 'angular2/router';
|
||||||
|
import {APP_BASE_HREF} from 'angular2/platform/common';
|
||||||
|
|
||||||
// #docregion routerCanDeactivate
|
// #docregion routerCanDeactivate
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import {Component, provide} from 'angular2/core';
|
import {Component, provide} from 'angular2/core';
|
||||||
import {bootstrap} from 'angular2/platform/browser';
|
import {bootstrap} from 'angular2/platform/browser';
|
||||||
import {
|
import {OnActivate, ComponentInstruction, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
|
||||||
OnActivate,
|
import {APP_BASE_HREF} from 'angular2/platform/common';
|
||||||
ComponentInstruction,
|
|
||||||
RouteConfig,
|
|
||||||
ROUTER_DIRECTIVES,
|
|
||||||
APP_BASE_HREF
|
|
||||||
} from 'angular2/router';
|
|
||||||
|
|
||||||
// #docregion routerOnActivate
|
// #docregion routerOnActivate
|
||||||
@Component({template: `Child`})
|
@Component({template: `Child`})
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import {Component, Injectable, provide} from 'angular2/core';
|
import {Component, Injectable, provide} from 'angular2/core';
|
||||||
import {bootstrap} from 'angular2/platform/browser';
|
import {bootstrap} from 'angular2/platform/browser';
|
||||||
import {
|
import {OnDeactivate, ComponentInstruction, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
|
||||||
OnDeactivate,
|
import {APP_BASE_HREF} from 'angular2/platform/common';
|
||||||
ComponentInstruction,
|
|
||||||
RouteConfig,
|
|
||||||
ROUTER_DIRECTIVES,
|
|
||||||
APP_BASE_HREF
|
|
||||||
} from 'angular2/router';
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
|
@ -5,11 +5,11 @@ import {
|
||||||
RouteConfig,
|
RouteConfig,
|
||||||
ComponentInstruction,
|
ComponentInstruction,
|
||||||
ROUTER_DIRECTIVES,
|
ROUTER_DIRECTIVES,
|
||||||
APP_BASE_HREF,
|
|
||||||
CanReuse,
|
CanReuse,
|
||||||
RouteParams,
|
RouteParams,
|
||||||
OnReuse
|
OnReuse
|
||||||
} from 'angular2/router';
|
} from 'angular2/router';
|
||||||
|
import {APP_BASE_HREF} from 'angular2/platform/common';
|
||||||
|
|
||||||
|
|
||||||
// #docregion reuseCmp
|
// #docregion reuseCmp
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
/**
|
||||||
|
* Platform agnostic services.
|
||||||
|
* Can be used both in the browser and on the server.
|
||||||
|
*/
|
||||||
|
export * from 'angular2/src/platform/location';
|
|
@ -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 {DOM, setRootDomAdapter, DomAdapter} from 'angular2/src/platform/dom/dom_adapter';
|
||||||
export {DomRenderer} from 'angular2/src/platform/dom/dom_renderer';
|
export {DomRenderer} from 'angular2/src/platform/dom/dom_renderer';
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {MockAnimationBuilder} from 'angular2/src/mock/animation_builder_mock';
|
||||||
import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock';
|
import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock';
|
||||||
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
|
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
|
||||||
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
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 {MockNgZone} from 'angular2/src/mock/ng_zone_mock';
|
||||||
|
|
||||||
import {XHRImpl} from "angular2/src/platform/browser/xhr_impl";
|
import {XHRImpl} from "angular2/src/platform/browser/xhr_impl";
|
||||||
|
|
|
@ -16,7 +16,6 @@ import {MockAnimationBuilder} from 'angular2/src/mock/animation_builder_mock';
|
||||||
import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock';
|
import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock';
|
||||||
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
|
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
|
||||||
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
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 {MockNgZone} from 'angular2/src/mock/ng_zone_mock';
|
||||||
|
|
||||||
import {TestComponentBuilder} from 'angular2/src/testing/test_component_builder';
|
import {TestComponentBuilder} from 'angular2/src/testing/test_component_builder';
|
||||||
|
@ -36,6 +35,7 @@ import {
|
||||||
ELEMENT_PROBE_PROVIDERS
|
ELEMENT_PROBE_PROVIDERS
|
||||||
} from 'angular2/platform/common_dom';
|
} from 'angular2/platform/common_dom';
|
||||||
import {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events';
|
import {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events';
|
||||||
|
import {LocationStrategy} from 'angular2/platform/common';
|
||||||
|
|
||||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,7 @@ export {Router} from './src/router/router';
|
||||||
export {RouterOutlet} from './src/router/directives/router_outlet';
|
export {RouterOutlet} from './src/router/directives/router_outlet';
|
||||||
export {RouterLink} from './src/router/directives/router_link';
|
export {RouterLink} from './src/router/directives/router_link';
|
||||||
export {RouteParams, RouteData} from './src/router/instruction';
|
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 {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_config/route_config_decorator';
|
||||||
export * from './src/router/route_definition';
|
export * from './src/router/route_definition';
|
||||||
export {OnActivate, OnDeactivate, OnReuse, CanDeactivate, CanReuse} from './src/router/interfaces';
|
export {OnActivate, OnDeactivate, OnReuse, CanDeactivate, CanReuse} from './src/router/interfaces';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {Injectable} from 'angular2/src/core/di';
|
import {Injectable} from 'angular2/src/core/di';
|
||||||
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
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.
|
* A spy for {@link Location} that allows tests to fire simulated location events.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {Injectable} from 'angular2/src/core/di';
|
import {Injectable} from 'angular2/src/core/di';
|
||||||
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
import {LocationStrategy} from 'angular2/src/router/location/location_strategy';
|
import {LocationStrategy} from 'angular2/platform/common';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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 {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';
|
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,13 +1,8 @@
|
||||||
import {Injectable, Inject, Optional} from 'angular2/core';
|
import {Injectable, Inject, Optional} from 'angular2/core';
|
||||||
import {
|
import {LocationStrategy, APP_BASE_HREF} from './location_strategy';
|
||||||
LocationStrategy,
|
import {Location} from './location';
|
||||||
joinWithSlash,
|
import {UrlChangeListener, PlatformLocation} from './platform_location';
|
||||||
APP_BASE_HREF,
|
|
||||||
normalizeQueryParams
|
|
||||||
} from './location_strategy';
|
|
||||||
import {UrlChangeListener} from './platform_location';
|
|
||||||
import {isPresent} from 'angular2/src/facade/lang';
|
import {isPresent} from 'angular2/src/facade/lang';
|
||||||
import {PlatformLocation} from './platform_location';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `HashLocationStrategy` is a {@link LocationStrategy} used to configure the
|
* `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 {Component, provide} from 'angular2/core';
|
||||||
* import {
|
* import {
|
||||||
* ROUTER_DIRECTIVES,
|
|
||||||
* ROUTER_PROVIDERS,
|
|
||||||
* RouteConfig,
|
|
||||||
* Location,
|
* Location,
|
||||||
* LocationStrategy,
|
* LocationStrategy,
|
||||||
* HashLocationStrategy
|
* HashLocationStrategy
|
||||||
|
* } from 'angular2/platform/common';
|
||||||
|
* import {
|
||||||
|
* ROUTER_DIRECTIVES,
|
||||||
|
* ROUTER_PROVIDERS,
|
||||||
|
* RouteConfig
|
||||||
* } from 'angular2/router';
|
* } from 'angular2/router';
|
||||||
*
|
*
|
||||||
* @Component({directives: [ROUTER_DIRECTIVES]})
|
* @Component({directives: [ROUTER_DIRECTIVES]})
|
||||||
|
@ -78,12 +75,12 @@ export class HashLocationStrategy extends LocationStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareExternalUrl(internal: string): string {
|
prepareExternalUrl(internal: string): string {
|
||||||
var url = joinWithSlash(this._baseHref, internal);
|
var url = Location.joinWithSlash(this._baseHref, internal);
|
||||||
return url.length > 0 ? ('#' + url) : url;
|
return url.length > 0 ? ('#' + url) : url;
|
||||||
}
|
}
|
||||||
|
|
||||||
pushState(state: any, title: string, path: string, queryParams: string) {
|
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) {
|
if (url.length == 0) {
|
||||||
url = this._platformLocation.pathname;
|
url = this._platformLocation.pathname;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +88,7 @@ export class HashLocationStrategy extends LocationStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceState(state: any, title: string, path: string, queryParams: string) {
|
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) {
|
if (url.length == 0) {
|
||||||
url = this._platformLocation.pathname;
|
url = this._platformLocation.pathname;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import {LocationStrategy} from './location_strategy';
|
|
||||||
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
import {Injectable, Inject} from 'angular2/core';
|
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.
|
* `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 {Component} from 'angular2/core';
|
||||||
|
* import {Location} from 'angular2/platform/common';
|
||||||
* import {
|
* import {
|
||||||
* ROUTER_DIRECTIVES,
|
* ROUTER_DIRECTIVES,
|
||||||
* ROUTER_PROVIDERS,
|
* ROUTER_PROVIDERS,
|
||||||
* RouteConfig,
|
* RouteConfig
|
||||||
* Location
|
|
||||||
* } from 'angular2/router';
|
* } from 'angular2/router';
|
||||||
*
|
*
|
||||||
* @Component({directives: [ROUTER_DIRECTIVES]})
|
* @Component({directives: [ROUTER_DIRECTIVES]})
|
||||||
|
@ -51,7 +51,7 @@ export class Location {
|
||||||
|
|
||||||
constructor(public platformStrategy: LocationStrategy) {
|
constructor(public platformStrategy: LocationStrategy) {
|
||||||
var browserBaseHref = this.platformStrategy.getBaseHref();
|
var browserBaseHref = this.platformStrategy.getBaseHref();
|
||||||
this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref));
|
this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
|
||||||
this.platformStrategy.onPopState((ev) => {
|
this.platformStrategy.onPopState((ev) => {
|
||||||
ObservableWrapper.callEmit(this._subject, {'url': this.path(), 'pop': true, 'type': ev.type});
|
ObservableWrapper.callEmit(this._subject, {'url': this.path(), 'pop': true, 'type': ev.type});
|
||||||
});
|
});
|
||||||
|
@ -67,7 +67,7 @@ export class Location {
|
||||||
* trailing slashes
|
* trailing slashes
|
||||||
*/
|
*/
|
||||||
normalize(url: string): string {
|
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 {
|
onReturn: () => void = null): Object {
|
||||||
return ObservableWrapper.subscribe(this._subject, onNext, onThrow, onReturn);
|
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 {
|
function _stripBaseHref(baseHref: string, url: string): string {
|
||||||
|
@ -126,17 +170,10 @@ function _stripBaseHref(baseHref: string, url: string): string {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stripIndexHtml(url: string): string {
|
function _stripIndexHtml(url: string): string {
|
||||||
if (/\/index.html$/g.test(url)) {
|
if (/\/index.html$/g.test(url)) {
|
||||||
// '/index.html'.length == 11
|
// '/index.html'.length == 11
|
||||||
return url.substring(0, url.length - 11);
|
return url.substring(0, url.length - 11);
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stripTrailingSlash(url: string): string {
|
|
||||||
if (/\/$/g.test(url)) {
|
|
||||||
url = url.substring(0, url.length - 1);
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
}
|
|
|
@ -43,6 +43,7 @@ export abstract class LocationStrategy {
|
||||||
* ```
|
* ```
|
||||||
* import {Component} from 'angular2/core';
|
* import {Component} from 'angular2/core';
|
||||||
* import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
|
* import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
|
||||||
|
* import {APP_BASE_HREF} from 'angular2/platform/common';
|
||||||
*
|
*
|
||||||
* @Component({directives: [ROUTER_DIRECTIVES]})
|
* @Component({directives: [ROUTER_DIRECTIVES]})
|
||||||
* @RouteConfig([
|
* @RouteConfig([
|
||||||
|
@ -59,30 +60,3 @@ export abstract class LocationStrategy {
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export const APP_BASE_HREF: OpaqueToken = CONST_EXPR(new OpaqueToken('appBaseHref'));
|
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;
|
|
||||||
}
|
|
|
@ -1,13 +1,9 @@
|
||||||
import {Injectable, Inject, Optional} from 'angular2/core';
|
import {Injectable, Inject, Optional} from 'angular2/core';
|
||||||
import {isBlank} from 'angular2/src/facade/lang';
|
import {isBlank} from 'angular2/src/facade/lang';
|
||||||
import {BaseException} from 'angular2/src/facade/exceptions';
|
import {BaseException} from 'angular2/src/facade/exceptions';
|
||||||
import {
|
|
||||||
LocationStrategy,
|
|
||||||
APP_BASE_HREF,
|
|
||||||
normalizeQueryParams,
|
|
||||||
joinWithSlash
|
|
||||||
} from './location_strategy';
|
|
||||||
import {PlatformLocation, UrlChangeListener} from './platform_location';
|
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
|
* `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 {Component, provide} from 'angular2/core';
|
||||||
|
* import {bootstrap} from 'angular2/platform/browser';
|
||||||
* import {
|
* import {
|
||||||
|
* Location,
|
||||||
* APP_BASE_HREF
|
* APP_BASE_HREF
|
||||||
|
* } from 'angular2/platform/common';
|
||||||
|
* import {
|
||||||
* ROUTER_DIRECTIVES,
|
* ROUTER_DIRECTIVES,
|
||||||
* ROUTER_PROVIDERS,
|
* ROUTER_PROVIDERS,
|
||||||
* RouteConfig,
|
* RouteConfig
|
||||||
* Location
|
|
||||||
* } from 'angular2/router';
|
* } from 'angular2/router';
|
||||||
*
|
*
|
||||||
* @Component({directives: [ROUTER_DIRECTIVES]})
|
* @Component({directives: [ROUTER_DIRECTIVES]})
|
||||||
|
@ -81,19 +80,22 @@ export class PathLocationStrategy extends LocationStrategy {
|
||||||
|
|
||||||
getBaseHref(): string { return this._baseHref; }
|
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 {
|
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) {
|
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);
|
this._platformLocation.pushState(state, title, externalUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceState(state: any, title: string, url: string, queryParams: string) {
|
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);
|
this._platformLocation.replaceState(state, title, externalUrl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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';
|
|
@ -36,7 +36,6 @@ import {BrowserDomAdapter} from './browser/browser_adapter';
|
||||||
import {wtfInit} from 'angular2/src/core/profile/wtf_init';
|
import {wtfInit} from 'angular2/src/core/profile/wtf_init';
|
||||||
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';
|
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';
|
||||||
import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl';
|
import {MessageBasedXHRImpl} from 'angular2/src/web_workers/ui/xhr_impl';
|
||||||
import {BrowserPlatformLocation} from 'angular2/src/router/location/browser_platform_location';
|
|
||||||
import {
|
import {
|
||||||
ServiceMessageBrokerFactory,
|
ServiceMessageBrokerFactory,
|
||||||
ServiceMessageBrokerFactory_
|
ServiceMessageBrokerFactory_
|
||||||
|
@ -45,6 +44,9 @@ import {
|
||||||
ClientMessageBrokerFactory,
|
ClientMessageBrokerFactory,
|
||||||
ClientMessageBrokerFactory_
|
ClientMessageBrokerFactory_
|
||||||
} from 'angular2/src/web_workers/shared/client_message_broker';
|
} 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 {Serializer} from 'angular2/src/web_workers/shared/serializer';
|
||||||
import {ON_WEB_WORKER} from 'angular2/src/web_workers/shared/api';
|
import {ON_WEB_WORKER} from 'angular2/src/web_workers/shared/api';
|
||||||
import {RenderStore} from 'angular2/src/web_workers/shared/render_store';
|
import {RenderStore} from 'angular2/src/web_workers/shared/render_store';
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import {Directive} from 'angular2/core';
|
import {Directive} from 'angular2/core';
|
||||||
|
import {Location} from 'angular2/platform/common';
|
||||||
import {isString} from 'angular2/src/facade/lang';
|
import {isString} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
import {Router} from '../router';
|
import {Router} from '../router';
|
||||||
import {Location} from '../location/location';
|
|
||||||
import {Instruction} from '../instruction';
|
import {Instruction} from '../instruction';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {PromiseWrapper, EventEmitter, ObservableWrapper} from 'angular2/src/faca
|
||||||
import {Map, StringMapWrapper, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
import {Map, StringMapWrapper, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {isBlank, isString, isPresent, Type, isArray} from 'angular2/src/facade/lang';
|
import {isBlank, isString, isPresent, Type, isArray} from 'angular2/src/facade/lang';
|
||||||
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
|
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
|
||||||
|
import {Location} from 'angular2/platform/common';
|
||||||
import {Inject, Injectable} from 'angular2/core';
|
import {Inject, Injectable} from 'angular2/core';
|
||||||
|
|
||||||
import {RouteRegistry, ROUTER_PRIMARY_COMPONENT} from './route_registry';
|
import {RouteRegistry, ROUTER_PRIMARY_COMPONENT} from './route_registry';
|
||||||
|
@ -10,7 +11,6 @@ import {
|
||||||
Instruction,
|
Instruction,
|
||||||
} from './instruction';
|
} from './instruction';
|
||||||
import {RouterOutlet} from './directives/router_outlet';
|
import {RouterOutlet} from './directives/router_outlet';
|
||||||
import {Location} from './location/location';
|
|
||||||
import {getCanActivateHook} from './lifecycle/route_lifecycle_reflector';
|
import {getCanActivateHook} from './lifecycle/route_lifecycle_reflector';
|
||||||
import {RouteDefinition} from './route_config/route_config_impl';
|
import {RouteDefinition} from './route_config/route_config_impl';
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import {ROUTER_PROVIDERS_COMMON} from './router_providers_common';
|
import {ROUTER_PROVIDERS_COMMON} from './router_providers_common';
|
||||||
import {Provider} from 'angular2/core';
|
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 {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.
|
* A list of {@link Provider}s. To use the router, you must add this to your application.
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import {LocationStrategy} from 'angular2/src/router/location/location_strategy';
|
import {LocationStrategy, PathLocationStrategy, Location} from 'angular2/platform/common';
|
||||||
import {PathLocationStrategy} from 'angular2/src/router/location/path_location_strategy';
|
|
||||||
import {Router, RootRouter} from 'angular2/src/router/router';
|
import {Router, RootRouter} from 'angular2/src/router/router';
|
||||||
import {RouteRegistry, ROUTER_PRIMARY_COMPONENT} from 'angular2/src/router/route_registry';
|
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 {CONST_EXPR, Type} from 'angular2/src/facade/lang';
|
||||||
import {ApplicationRef, OpaqueToken, Provider} from 'angular2/core';
|
import {ApplicationRef, OpaqueToken, Provider} from 'angular2/core';
|
||||||
import {BaseException} from 'angular2/src/facade/exceptions';
|
import {BaseException} from 'angular2/src/facade/exceptions';
|
||||||
|
|
|
@ -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 {Injectable} from 'angular2/src/core/di';
|
||||||
import {ROUTER_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
|
import {ROUTER_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
|
||||||
import {
|
import {
|
||||||
|
@ -10,7 +13,6 @@ import {bind} from './bind';
|
||||||
import {LocationType} from 'angular2/src/web_workers/shared/serialized_types';
|
import {LocationType} from 'angular2/src/web_workers/shared/serialized_types';
|
||||||
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
|
import {MessageBus} from 'angular2/src/web_workers/shared/message_bus';
|
||||||
import {EventEmitter, ObservableWrapper, PromiseWrapper} from 'angular2/src/facade/async';
|
import {EventEmitter, ObservableWrapper, PromiseWrapper} from 'angular2/src/facade/async';
|
||||||
import {UrlChangeListener} from 'angular2/src/router/location/platform_location';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MessageBasedPlatformLocation {
|
export class MessageBasedPlatformLocation {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import {MessageBasedPlatformLocation} from './platform_location';
|
import {MessageBasedPlatformLocation} from './platform_location';
|
||||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
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';
|
import {APP_INITIALIZER, Provider, Injector, NgZone} from 'angular2/core';
|
||||||
|
|
||||||
export const WORKER_RENDER_ROUTER = CONST_EXPR([
|
export const WORKER_RENDER_ROUTER = CONST_EXPR([
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
import {Injectable} from 'angular2/src/core/di';
|
import {Injectable} from 'angular2/src/core/di';
|
||||||
import {
|
|
||||||
PlatformLocation,
|
|
||||||
UrlChangeEvent,
|
|
||||||
UrlChangeListener
|
|
||||||
} from 'angular2/src/router/location/platform_location';
|
|
||||||
import {
|
import {
|
||||||
FnArg,
|
FnArg,
|
||||||
UiArguments,
|
UiArguments,
|
||||||
ClientMessageBroker,
|
ClientMessageBroker,
|
||||||
ClientMessageBrokerFactory
|
ClientMessageBrokerFactory
|
||||||
} from 'angular2/src/web_workers/shared/client_message_broker';
|
} 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 {ROUTER_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
|
||||||
import {LocationType} from 'angular2/src/web_workers/shared/serialized_types';
|
import {LocationType} from 'angular2/src/web_workers/shared/serialized_types';
|
||||||
import {PromiseWrapper, EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
import {PromiseWrapper, EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {ApplicationRef, Provider, NgZone, APP_INITIALIZER} from 'angular2/core';
|
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 {WebWorkerPlatformLocation} from './platform_location';
|
||||||
import {ROUTER_PROVIDERS_COMMON} from 'angular2/src/router/router_providers_common';
|
import {ROUTER_PROVIDERS_COMMON} from 'angular2/src/router/router_providers_common';
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,10 @@ import {
|
||||||
xit
|
xit
|
||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
import {IS_DART, isPresent, stringify} from 'angular2/src/facade/lang';
|
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 {ApplicationRef} from 'angular2/src/core/application_ref';
|
||||||
import {Console} from 'angular2/src/core/console';
|
import {Console} from 'angular2/src/core/console';
|
||||||
import {Component, Directive, OnDestroy, platform} from 'angular2/core';
|
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 {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||||
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
|
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
|
||||||
import {PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async';
|
import {PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async';
|
||||||
|
|
|
@ -311,6 +311,17 @@ var NG_PLATFORM_BROWSER = [
|
||||||
'inspectNativeElement'
|
'inspectNativeElement'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var NG_PLATFORM_COMMON = [
|
||||||
|
'APP_BASE_HREF',
|
||||||
|
'HashLocationStrategy',
|
||||||
|
'Location',
|
||||||
|
'LocationStrategy',
|
||||||
|
'PathLocationStrategy',
|
||||||
|
'PlatformLocation',
|
||||||
|
'UrlChangeEvent:dart',
|
||||||
|
'UrlChangeListener:dart'
|
||||||
|
];
|
||||||
|
|
||||||
var NG_UPGRADE = [
|
var NG_UPGRADE = [
|
||||||
'UpgradeAdapter',
|
'UpgradeAdapter',
|
||||||
'UpgradeAdapterRef',
|
'UpgradeAdapterRef',
|
||||||
|
@ -322,6 +333,7 @@ var NG_API = {
|
||||||
ngCore: NG_CORE,
|
ngCore: NG_CORE,
|
||||||
ngInstrumentation: NG_INSTRUMENTATION,
|
ngInstrumentation: NG_INSTRUMENTATION,
|
||||||
ngPlatformBrowser: NG_PLATFORM_BROWSER,
|
ngPlatformBrowser: NG_PLATFORM_BROWSER,
|
||||||
|
ngPlatformCommon: NG_PLATFORM_COMMON,
|
||||||
ngUpgrade: NG_UPGRADE
|
ngUpgrade: NG_UPGRADE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -336,8 +348,15 @@ export function main() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
describe('public API', () => {
|
describe('public API', () => {
|
||||||
var barrelList =
|
var barrelList = [
|
||||||
['ngCommon', 'ngCompiler', 'ngCore', 'ngInstrumentation', 'ngPlatformBrowser', 'ngUpgrade'];
|
'ngCommon',
|
||||||
|
'ngCompiler',
|
||||||
|
'ngCore',
|
||||||
|
'ngInstrumentation',
|
||||||
|
'ngPlatformBrowser',
|
||||||
|
'ngPlatformCommon',
|
||||||
|
'ngUpgrade'
|
||||||
|
];
|
||||||
|
|
||||||
if (IS_DART) {
|
if (IS_DART) {
|
||||||
barrelList = barrelList.filter(b => b !== 'ngUpgrade');
|
barrelList = barrelList.filter(b => b !== 'ngUpgrade');
|
||||||
|
|
|
@ -18,9 +18,9 @@ import {SpyRouter, SpyLocation} from '../spies';
|
||||||
|
|
||||||
import {provide, Component} from 'angular2/core';
|
import {provide, Component} from 'angular2/core';
|
||||||
import {By} from 'angular2/platform/common_dom';
|
import {By} from 'angular2/platform/common_dom';
|
||||||
|
import {Location} from 'angular2/platform/common';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Location,
|
|
||||||
Router,
|
Router,
|
||||||
RouteRegistry,
|
RouteRegistry,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
|
|
|
@ -15,6 +15,7 @@ import {
|
||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
|
|
||||||
import {bootstrap} from 'angular2/platform/browser';
|
import {bootstrap} from 'angular2/platform/browser';
|
||||||
|
import {APP_BASE_HREF, LocationStrategy} from 'angular2/platform/common';
|
||||||
import {Component, Directive} from 'angular2/src/core/metadata';
|
import {Component, Directive} from 'angular2/src/core/metadata';
|
||||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||||
import {Console} from 'angular2/src/core/console';
|
import {Console} from 'angular2/src/core/console';
|
||||||
|
@ -33,9 +34,7 @@ import {
|
||||||
ROUTER_PRIMARY_COMPONENT,
|
ROUTER_PRIMARY_COMPONENT,
|
||||||
RouteParams,
|
RouteParams,
|
||||||
Router,
|
Router,
|
||||||
APP_BASE_HREF,
|
ROUTER_DIRECTIVES
|
||||||
ROUTER_DIRECTIVES,
|
|
||||||
LocationStrategy
|
|
||||||
} from 'angular2/router';
|
} from 'angular2/router';
|
||||||
|
|
||||||
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
||||||
|
|
|
@ -12,12 +12,12 @@ import {
|
||||||
xit,
|
xit,
|
||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
|
|
||||||
|
|
||||||
import {By} from 'angular2/platform/common_dom';
|
import {By} from 'angular2/platform/common_dom';
|
||||||
|
import {Location} from 'angular2/platform/common';
|
||||||
|
|
||||||
import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util';
|
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 {
|
import {
|
||||||
HelloCmp,
|
HelloCmp,
|
||||||
|
|
|
@ -16,9 +16,10 @@ import {
|
||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
|
|
||||||
import {By} from 'angular2/platform/common_dom';
|
import {By} from 'angular2/platform/common_dom';
|
||||||
|
import {Location} from 'angular2/platform/common';
|
||||||
import {provide, Component, Injector, Inject} from 'angular2/core';
|
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 {
|
import {
|
||||||
RouteConfig,
|
RouteConfig,
|
||||||
Route,
|
Route,
|
||||||
|
|
|
@ -15,7 +15,8 @@ import {
|
||||||
import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util';
|
import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util';
|
||||||
|
|
||||||
import {By} from 'angular2/platform/common_dom';
|
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 {
|
import {
|
||||||
HelloCmp,
|
HelloCmp,
|
||||||
|
|
|
@ -16,9 +16,10 @@ import {
|
||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
|
|
||||||
import {provide, Component, Injector, Inject} from 'angular2/core';
|
import {provide, Component, Injector, Inject} from 'angular2/core';
|
||||||
|
import {Location} from 'angular2/platform/common';
|
||||||
import {PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async';
|
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 {
|
import {
|
||||||
RouteConfig,
|
RouteConfig,
|
||||||
Route,
|
Route,
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
xit
|
xit
|
||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
|
|
||||||
import {Router, RouterOutlet, RouterLink, RouteParams, RouteData, Location} from 'angular2/router';
|
import {Router, RouterOutlet, RouterLink, RouteParams, RouteData} from 'angular2/router';
|
||||||
import {
|
import {
|
||||||
RouteConfig,
|
RouteConfig,
|
||||||
Route,
|
Route,
|
||||||
|
@ -23,6 +23,7 @@ import {
|
||||||
AsyncRoute,
|
AsyncRoute,
|
||||||
Redirect
|
Redirect
|
||||||
} from 'angular2/src/router/route_config/route_config_decorator';
|
} from 'angular2/src/router/route_config/route_config_decorator';
|
||||||
|
import {Location} from 'angular2/platform/common';
|
||||||
|
|
||||||
import {TEST_ROUTER_PROVIDERS, RootCmp, compile} from './util';
|
import {TEST_ROUTER_PROVIDERS, RootCmp, compile} from './util';
|
||||||
import {HelloCmp, GoodbyeCmp, RedirectToParentCmp} from './impl/fixture_components';
|
import {HelloCmp, GoodbyeCmp, RedirectToParentCmp} from './impl/fixture_components';
|
||||||
|
|
|
@ -18,6 +18,7 @@ import {
|
||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
|
|
||||||
import {By} from 'angular2/platform/common_dom';
|
import {By} from 'angular2/platform/common_dom';
|
||||||
|
import {Location} from 'angular2/platform/common';
|
||||||
import {NumberWrapper} from 'angular2/src/facade/lang';
|
import {NumberWrapper} from 'angular2/src/facade/lang';
|
||||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
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 {SpyLocation} from 'angular2/src/mock/location_mock';
|
||||||
import {
|
import {
|
||||||
Location,
|
|
||||||
Router,
|
Router,
|
||||||
RouteRegistry,
|
RouteRegistry,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {RootRouter} from 'angular2/src/router/router';
|
||||||
import {Router, ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT} from 'angular2/router';
|
import {Router, ROUTER_DIRECTIVES, ROUTER_PRIMARY_COMPONENT} from 'angular2/router';
|
||||||
|
|
||||||
import {SpyLocation} from 'angular2/src/mock/location_mock';
|
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 {RouteRegistry} from 'angular2/src/router/route_registry';
|
||||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||||
export {ComponentFixture} from 'angular2/testing_internal';
|
export {ComponentFixture} from 'angular2/testing_internal';
|
||||||
|
|
|
@ -14,9 +14,7 @@ import {
|
||||||
|
|
||||||
import {Injector, provide} from 'angular2/core';
|
import {Injector, provide} from 'angular2/core';
|
||||||
|
|
||||||
import {PlatformLocation} from 'angular2/src/router/location/platform_location';
|
import {PlatformLocation, APP_BASE_HREF, HashLocationStrategy} from 'angular2/platform/common';
|
||||||
import {APP_BASE_HREF} from 'angular2/src/router/location/location_strategy';
|
|
||||||
import {HashLocationStrategy} from 'angular2/src/router/location/hash_location_strategy';
|
|
||||||
import {SpyPlatformLocation} from '../spies';
|
import {SpyPlatformLocation} from '../spies';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
|
|
|
@ -15,8 +15,7 @@ import {
|
||||||
import {Injector, provide} from 'angular2/core';
|
import {Injector, provide} from 'angular2/core';
|
||||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
import {Location} from 'angular2/src/router/location/location';
|
import {Location, LocationStrategy, APP_BASE_HREF} from 'angular2/platform/common';
|
||||||
import {LocationStrategy, APP_BASE_HREF} from 'angular2/src/router/location/location_strategy';
|
|
||||||
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
|
|
|
@ -15,9 +15,12 @@ import {
|
||||||
import {Injector, provide} from 'angular2/core';
|
import {Injector, provide} from 'angular2/core';
|
||||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
import {PlatformLocation} from 'angular2/src/router/location/platform_location';
|
import {
|
||||||
import {LocationStrategy, APP_BASE_HREF} from 'angular2/src/router/location/location_strategy';
|
PlatformLocation,
|
||||||
import {PathLocationStrategy} from 'angular2/src/router/location/path_location_strategy';
|
LocationStrategy,
|
||||||
|
PathLocationStrategy,
|
||||||
|
APP_BASE_HREF
|
||||||
|
} from 'angular2/platform/common';
|
||||||
import {SpyPlatformLocation} from '../spies';
|
import {SpyPlatformLocation} from '../spies';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
} from 'angular2/testing_internal';
|
} from 'angular2/testing_internal';
|
||||||
|
|
||||||
import {bootstrap} from 'angular2/platform/browser';
|
import {bootstrap} from 'angular2/platform/browser';
|
||||||
|
import {APP_BASE_HREF, LocationStrategy} from 'angular2/platform/common';
|
||||||
import {Component, Directive} from 'angular2/src/core/metadata';
|
import {Component, Directive} from 'angular2/src/core/metadata';
|
||||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||||
import {Console} from 'angular2/src/core/console';
|
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 {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
|
||||||
import {Type, IS_DART} from 'angular2/src/facade/lang';
|
import {Type, IS_DART} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
import {
|
import {ROUTER_PROVIDERS, Router, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
|
||||||
ROUTER_PROVIDERS,
|
|
||||||
Router,
|
|
||||||
RouteConfig,
|
|
||||||
APP_BASE_HREF,
|
|
||||||
ROUTER_DIRECTIVES
|
|
||||||
} from 'angular2/router';
|
|
||||||
|
|
||||||
import {ExceptionHandler} from 'angular2/src/facade/exceptions';
|
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';
|
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
||||||
|
|
||||||
class _ArrayLogger {
|
class _ArrayLogger {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import {ListWrapper} from 'angular2/src/facade/collection';
|
||||||
|
|
||||||
import {Router, RootRouter} from 'angular2/src/router/router';
|
import {Router, RootRouter} from 'angular2/src/router/router';
|
||||||
import {SpyLocation} from 'angular2/src/mock/location_mock';
|
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 {RouteRegistry, ROUTER_PRIMARY_COMPONENT} from 'angular2/src/router/route_registry';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
library router.spies;
|
library router.spies;
|
||||||
|
|
||||||
|
import 'package:angular2/platform/common.dart' show PlatformLocation, Location;
|
||||||
import 'package:angular2/router.dart';
|
import 'package:angular2/router.dart';
|
||||||
import 'package:angular2/testing_internal.dart';
|
import 'package:angular2/testing_internal.dart';
|
||||||
|
|
||||||
|
|
|
@ -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';
|
import {SpyObject, proxy} from 'angular2/testing_internal';
|
||||||
|
|
||||||
export class SpyRouter extends SpyObject {
|
export class SpyRouter extends SpyObject {
|
||||||
|
|
|
@ -23,7 +23,8 @@ const LIB_MAP = const {
|
||||||
'ngCompiler': 'angular2.compiler',
|
'ngCompiler': 'angular2.compiler',
|
||||||
'ngCore': 'angular2.core',
|
'ngCore': 'angular2.core',
|
||||||
'ngInstrumentation': 'angular2.instrumentation',
|
'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.
|
// Have this list here to trick dart to force import.
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as ngCompiler from 'angular2/compiler';
|
||||||
import * as ngCore from 'angular2/core';
|
import * as ngCore from 'angular2/core';
|
||||||
import * as ngInstrumentation from 'angular2/instrumentation';
|
import * as ngInstrumentation from 'angular2/instrumentation';
|
||||||
import * as ngPlatformBrowser from 'angular2/platform/browser';
|
import * as ngPlatformBrowser from 'angular2/platform/browser';
|
||||||
|
import * as ngPlatformCommon from 'angular2/platform/common';
|
||||||
import * as ngUpgrade from 'angular2/upgrade';
|
import * as ngUpgrade from 'angular2/upgrade';
|
||||||
|
|
||||||
const LIB_MAP = {
|
const LIB_MAP = {
|
||||||
|
@ -13,6 +14,7 @@ const LIB_MAP = {
|
||||||
ngCore,
|
ngCore,
|
||||||
ngInstrumentation,
|
ngInstrumentation,
|
||||||
ngPlatformBrowser,
|
ngPlatformBrowser,
|
||||||
|
ngPlatformCommon,
|
||||||
ngUpgrade
|
ngUpgrade
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
import {Component, provide} from 'angular2/core';
|
import {Component, provide} from 'angular2/core';
|
||||||
import {bootstrap} from 'angular2/platform/browser';
|
import {bootstrap} from 'angular2/platform/browser';
|
||||||
import {
|
import {RouteConfig, Route, ROUTER_PROVIDERS, ROUTER_DIRECTIVES} from 'angular2/router';
|
||||||
RouteConfig,
|
import {HashLocationStrategy, LocationStrategy} from 'angular2/platform/common';
|
||||||
Route,
|
|
||||||
ROUTER_PROVIDERS,
|
|
||||||
ROUTER_DIRECTIVES,
|
|
||||||
HashLocationStrategy,
|
|
||||||
LocationStrategy
|
|
||||||
} from 'angular2/router';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({selector: 'hello-cmp', template: `hello`})
|
@Component({selector: 'hello-cmp', template: `hello`})
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
import {Component, Injectable} from 'angular2/core';
|
import {Component, Injectable} from 'angular2/core';
|
||||||
import {
|
import {RouterLink, RouteConfig, Router, Route, RouterOutlet, RouteParams} from 'angular2/router';
|
||||||
RouterLink,
|
|
||||||
RouteConfig,
|
|
||||||
Router,
|
|
||||||
Route,
|
|
||||||
RouterOutlet,
|
|
||||||
Location,
|
|
||||||
RouteParams
|
|
||||||
} from 'angular2/router';
|
|
||||||
import * as db from './data';
|
import * as db from './data';
|
||||||
|
import {Location} from 'angular2/platform/common';
|
||||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||||
import {isPresent, DateWrapper} from 'angular2/src/facade/lang';
|
import {isPresent, DateWrapper} from 'angular2/src/facade/lang';
|
||||||
import {PromiseCompleter} from 'angular2/src/facade/promise';
|
import {PromiseCompleter} from 'angular2/src/facade/promise';
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import {InboxApp} from './inbox-app';
|
import {InboxApp} from './inbox-app';
|
||||||
import {provide} from 'angular2/core';
|
import {provide} from 'angular2/core';
|
||||||
import {bootstrap} from 'angular2/platform/browser';
|
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() {
|
export function main() {
|
||||||
bootstrap(InboxApp,
|
bootstrap(InboxApp,
|
||||||
|
|
|
@ -4,8 +4,8 @@ import "index_common.dart" show App;
|
||||||
import "dart:isolate";
|
import "dart:isolate";
|
||||||
import "package:angular2/platform/worker_app.dart";
|
import "package:angular2/platform/worker_app.dart";
|
||||||
import "package:angular2/core.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/src/web_workers/worker/router_providers.dart";
|
||||||
import "package:angular2/router.dart";
|
|
||||||
|
|
||||||
@AngularEntrypoint()
|
@AngularEntrypoint()
|
||||||
main(List<String> args, SendPort replyTo) {
|
main(List<String> args, SendPort replyTo) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import {platform, Provider, NgZone} from "angular2/core";
|
import {platform, Provider, NgZone} from "angular2/core";
|
||||||
|
import {HashLocationStrategy, LocationStrategy} from 'angular2/platform/common';
|
||||||
import {
|
import {
|
||||||
WORKER_APP_PLATFORM,
|
WORKER_APP_PLATFORM,
|
||||||
WORKER_APP_APPLICATION,
|
WORKER_APP_APPLICATION,
|
||||||
WORKER_APP_ROUTER
|
WORKER_APP_ROUTER
|
||||||
} from "angular2/platform/worker_app";
|
} from "angular2/platform/worker_app";
|
||||||
import {App} from "./index_common";
|
import {App} from "./index_common";
|
||||||
import {HashLocationStrategy, LocationStrategy} from "angular2/router";
|
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
let refPromise = platform([WORKER_APP_PLATFORM])
|
let refPromise = platform([WORKER_APP_PLATFORM])
|
||||||
|
|
|
@ -5,7 +5,6 @@ import {
|
||||||
WORKER_SCRIPT,
|
WORKER_SCRIPT,
|
||||||
WORKER_RENDER_ROUTER
|
WORKER_RENDER_ROUTER
|
||||||
} from 'angular2/platform/worker_render';
|
} 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";
|
import {MessageBasedPlatformLocation} from "angular2/src/web_workers/ui/platform_location";
|
||||||
|
|
||||||
let ref = platform([WORKER_RENDER_PLATFORM])
|
let ref = platform([WORKER_RENDER_PLATFORM])
|
||||||
|
@ -13,4 +12,4 @@ let ref = platform([WORKER_RENDER_PLATFORM])
|
||||||
WORKER_RENDER_APP,
|
WORKER_RENDER_APP,
|
||||||
new Provider(WORKER_SCRIPT, {useValue: "loader.js"}),
|
new Provider(WORKER_SCRIPT, {useValue: "loader.js"}),
|
||||||
WORKER_RENDER_ROUTER
|
WORKER_RENDER_ROUTER
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in New Issue