Skip to content

Commit

Permalink
fix(imports): Adjust imports for the new world
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRyanDev committed May 1, 2016
1 parent b7aa01a commit 2d51638
Show file tree
Hide file tree
Showing 28 changed files with 111 additions and 130 deletions.
2 changes: 1 addition & 1 deletion lib/component-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
OpaqueToken,
ComponentRef,
Optional
} from 'angular2/core';
} from '@angular/core';
import { Observable } from 'rxjs/Observable';

import { Async, ResourceLoader } from './resource-loader';
Expand Down
2 changes: 1 addition & 1 deletion lib/guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'rxjs/add/observable/of';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/every';
import { Observable } from 'rxjs/Observable';
import { Inject, Injectable, Provider, OpaqueToken, Injector, ReflectiveInjector } from 'angular2/core';
import { Inject, Injectable, Provider, OpaqueToken, Injector, ReflectiveInjector } from '@angular/core';

import { createProviderFactory } from './util';
import { Route } from './route';
Expand Down
58 changes: 38 additions & 20 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
import { Provider, provide } from 'angular2/core';
import { LocationStrategy, PathLocationStrategy } from 'angular2/platform/common';
import { Provider, provide, Type, PLATFORM_DIRECTIVES } from '@angular/core';
import { LocationStrategy, PathLocationStrategy, HashLocationStrategy } from '@angular/common';

import { ROUTER_PROVIDERS } from './router';
// Providers
import { ROUTER_PROVIDERS as ROUTER_SERVICE_PROVIDERS } from './router';
import { ROUTER_INSTRUCTION_PROVIDERS } from './router-instruction';
import { ROUTE_VIEW_PROVIDERS } from './route-view';
import { REDIRECT_PROVIDERS } from './redirect';
import { ROUTES, Routes } from './route';
import { GUARD_PROVIDERS } from './guard';
import { MATCH_ROUTE_PROVIDERS } from './route-traverser';
import { COMPONENT_RENDERER_PROVIDERS } from './component-renderer';
import { LINK_TO_PROVIDERS } from './link-to';
import { LINK_ACTIVE_PROVIDERS } from './link-active';
import { PARAMS_PROVIDERS } from './params';
import { RESOURCE_LOADER_PROVIDERS } from './resource-loader';
import { ZONE_OPERATOR_PROVIDERS } from './zone';

export function provideRouter(routes: Routes) {
// Directives
import { LinkTo } from './link-to';
import { LinkActive } from './link-active';
import { RouteView } from './route-view';


// Export all router providers
export const ROUTER_PROVIDERS = [
COMPONENT_RENDERER_PROVIDERS,
GUARD_PROVIDERS,
MATCH_ROUTE_PROVIDERS,
PARAMS_PROVIDERS,
REDIRECT_PROVIDERS,
RESOURCE_LOADER_PROVIDERS,
ROUTER_INSTRUCTION_PROVIDERS,
ROUTER_SERVICE_PROVIDERS,
ZONE_OPERATOR_PROVIDERS
];

// Export all router directives
export const ROUTER_DIRECTIVES = [
LinkTo,
LinkActive,
RouteView
];

// Export ROUTES opaque token and location strategy services
export { ROUTES, LocationStrategy, HashLocationStrategy, PathLocationStrategy };

// Export utility function for setting up providers
export function provideRouter(routes: Routes, locationStrategy: Type = PathLocationStrategy) {
return [
provide(LocationStrategy, { useClass: PathLocationStrategy }),
provide(LocationStrategy, { useClass: locationStrategy }),
provide(ROUTES, { useValue: routes }),
COMPONENT_RENDERER_PROVIDERS,
GUARD_PROVIDERS,
LINK_ACTIVE_PROVIDERS,
LINK_TO_PROVIDERS,
MATCH_ROUTE_PROVIDERS,
PARAMS_PROVIDERS,
REDIRECT_PROVIDERS,
RESOURCE_LOADER_PROVIDERS,
ROUTER_INSTRUCTION_PROVIDERS,
ROUTE_VIEW_PROVIDERS,
ROUTER_PROVIDERS,
ZONE_OPERATOR_PROVIDERS
provide(PLATFORM_DIRECTIVES, { useValue: ROUTER_DIRECTIVES, multi: true }),
ROUTER_PROVIDERS
];
}

Expand Down
12 changes: 1 addition & 11 deletions lib/link-active.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import {
OnDestroy,
Query,
QueryList,
PLATFORM_DIRECTIVES,
provide,
Provider,
Renderer
} from 'angular2/core';
} from '@angular/core';
import { LinkTo } from './link-to';
import { Router } from './router';

Expand Down Expand Up @@ -72,10 +69,3 @@ export interface LinkActiveOptions {
}
}
}

export const LINK_ACTIVE_PROVIDERS = [
provide(PLATFORM_DIRECTIVES, {
multi: true,
useValue: [ LinkActive ]
})
];
17 changes: 1 addition & 16 deletions lib/link-to.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
Directive,
HostBinding,
HostListener,
Input,
PLATFORM_DIRECTIVES,
provide,
Provider
} from 'angular2/core';
import { Directive, HostBinding, HostListener, Input } from '@angular/core';
import { Router } from './router';

/**
Expand Down Expand Up @@ -76,10 +68,3 @@ export class LinkTo {
return href;
}
}

export const LINK_TO_PROVIDERS = [
provide(PLATFORM_DIRECTIVES, {
multi: true,
useValue: [ LinkTo ]
})
];
2 changes: 1 addition & 1 deletion lib/params.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'rxjs/add/operator/map';
import { Observable } from 'rxjs/Observable';
import { Provider } from 'angular2/core';
import { Provider } from '@angular/core';

import { RouterInstruction } from './router-instruction';

Expand Down
2 changes: 1 addition & 1 deletion lib/redirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
import 'rxjs/add/operator/filter';
import { Observable } from 'rxjs/Observable';
import { Provider, Injectable } from 'angular2/core';
import { Provider, Injectable } from '@angular/core';

import { Router } from './router';
import { Routes, Route } from './route';
Expand Down
2 changes: 1 addition & 1 deletion lib/resource-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Provider } from 'angular2/core';
import { Injectable, Provider } from '@angular/core';

export type Async<T> = () => Promise<T>;

Expand Down
2 changes: 1 addition & 1 deletion lib/route-traverser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'rxjs/add/operator/map';
import 'rxjs/add/operator/concatMap';
import 'rxjs/add/operator/take';
import { Observable } from 'rxjs/Observable';
import { OpaqueToken, Provider, Inject, Injectable, Optional } from 'angular2/core';
import { OpaqueToken, Provider, Inject, Injectable, Optional } from '@angular/core';

import { ResourceLoader, Async } from './resource-loader';
import { matchPattern, makeParams } from './match-pattern';
Expand Down
17 changes: 4 additions & 13 deletions lib/route-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ import {
ComponentRef,
ReflectiveInjector,
Injector,
provide,
OnDestroy,
OnInit,
Provider,
PLATFORM_DIRECTIVES,
ViewContainerRef,
DynamicComponentLoader,
Attribute
} from 'angular2/core';
Attribute,
Provider
} from '@angular/core';

import { Route, getNamedComponents } from './route';
import { RouterInstruction, NextInstruction } from './router-instruction';
Expand All @@ -37,7 +35,7 @@ import { ComponentRenderer } from './component-renderer';
export class RouteView implements OnDestroy, OnInit {
private _prev: ComponentRef;
private _sub: any;
private _routerInstructionProvider = provide(RouterInstruction, {
private _routerInstructionProvider = new Provider(RouterInstruction, {
useValue: this._routerInstruction$.map<NextInstruction>(set => {
return {
locationChange: set.locationChange,
Expand Down Expand Up @@ -89,10 +87,3 @@ export class RouteView implements OnDestroy, OnInit {
}
}
}

export const ROUTE_VIEW_PROVIDERS = [
provide(PLATFORM_DIRECTIVES, {
multi: true,
useValue: [ RouteView ]
})
];
2 changes: 1 addition & 1 deletion lib/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Route and IndexRoute interfaces are similar to react-router's interfaces.
*/
import { Observable } from 'rxjs/Observable';
import { Provider, Type, OpaqueToken } from 'angular2/core';
import { Provider, Type, OpaqueToken } from '@angular/core';

import { Async } from './resource-loader';

Expand Down
2 changes: 1 addition & 1 deletion lib/router-instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/observeOn';
import { Observable } from 'rxjs/Observable';
import { asap } from 'rxjs/scheduler/asap';
import { Provider, Injector, OpaqueToken, Inject, Optional, Injectable } from 'angular2/core';
import { Provider, Injector, OpaqueToken, Inject, Optional, Injectable } from '@angular/core';
import { parse as parseQueryString } from 'query-string';

import { ZoneOperator } from './zone';
Expand Down
9 changes: 4 additions & 5 deletions lib/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* It exposes location updates as a BehaviorSubject, letting the router
* observe location changes.
*/
import { ReplaySubject } from 'rxjs/subject/ReplaySubject';
import { ReplaySubject } from 'rxjs/ReplaySubject';
import { Subscriber } from 'rxjs/Subscriber';
import { LocationStrategy } from 'angular2/platform/common';
import { UrlChangeEvent, PlatformLocation } from 'angular2/platform/common';
import { BrowserPlatformLocation } from 'angular2/src/platform/browser/location/browser_platform_location';
import { Injectable, Inject, Provider, provide } from 'angular2/core';
import { LocationStrategy, UrlChangeEvent, PlatformLocation } from '@angular/common';
import { BrowserPlatformLocation } from '@angular/platform-browser';
import { Injectable, Inject, Provider, provide } from '@angular/core';
import { stringify as stringifyQueryParams } from 'query-string';

export interface LocationChange {
Expand Down
2 changes: 1 addition & 1 deletion lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Observable } from 'rxjs/Observable';
import { Subscriber } from 'rxjs/Subscriber';
import { provide, Provider, OpaqueToken } from 'angular2/core';
import { provide, Provider, OpaqueToken } from '@angular/core';

export function createProviderFactory<T>(
name: string,
Expand Down
6 changes: 3 additions & 3 deletions lib/zone.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, NgZone, Provider } from 'angular2/core';
import { Injectable, NgZone, Provider } from '@angular/core';
import { Operator } from 'rxjs/Operator';
import { Subscriber } from 'rxjs/Subscriber';

Expand All @@ -7,8 +7,8 @@ import { Subscriber } from 'rxjs/Subscriber';
export class ZoneOperator<T> implements Operator<T, T> {
constructor(private _zone: NgZone) { }

call(subscriber: Subscriber<T>): Subscriber<T> {
return new ZoneSubscriber(subscriber, this._zone);
call(subscriber: Subscriber<T>, source: any): any {
return source._subscribe(new ZoneSubscriber(subscriber, this._zone));
}
}

Expand Down
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@
],
"license": "MIT",
"peerDependencies": {
"angular2": "^2.0.0-beta.16",
"rxjs": "5.0.0-beta.4"
"rxjs": "5.0.0-beta.6",
"@angular/core": "0.0.0-3",
"@angular/platform-browser": "0.0.0-3",
"@angular/common": "0.0.0-3"
},
"devDependencies": {
"angular2": "^2.0.0-beta.16",
"@angular/core": "0.0.0-3",
"@angular/platform-browser": "0.0.0-3",
"@angular/platform-browser-dynamic": "0.0.0-3",
"@angular/common": "0.0.0-3",
"@angular/compiler": "0.0.0-3",
"conventional-changelog-cli": "^1.1.1",
"core-js": "^2.2.2",
"esdoc": "^0.4.6",
Expand All @@ -57,7 +63,7 @@
"karma-webpack": "^1.7.0",
"npm-run-all": "^1.7.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.4",
"rxjs": "5.0.0-beta.6",
"source-map-loader": "^0.1.5",
"ts-loader": "^0.8.1",
"tslint": "^3.6.0",
Expand Down
9 changes: 2 additions & 7 deletions spec/component-renderer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import 'rxjs/add/operator/toPromise';
import { Subject } from 'rxjs/Subject';
import { Observable } from 'rxjs/Observable';
import { ReflectiveInjector, provide, DynamicComponentLoader, ViewContainerRef } from 'angular2/core';
import { ReflectiveInjector, provide, DynamicComponentLoader, ViewContainerRef } from '@angular/core';

import { RESOURCE_LOADER_PROVIDERS } from '../lib/resource-loader';

import {
ComponentRenderer,
PRE_RENDER_HOOKS,
POST_RENDER_HOOKS
} from '../lib/component-renderer';
import { ComponentRenderer, PRE_RENDER_HOOKS, POST_RENDER_HOOKS } from '../lib/component-renderer';
import { Route, BaseRoute } from '../lib/route';
import { Hook } from '../lib/hooks';

Expand Down
2 changes: 1 addition & 1 deletion spec/guard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'rxjs/add/observable/of';
import { Observable } from 'rxjs/Observable';
import { ReflectiveInjector } from 'angular2/core';
import { ReflectiveInjector } from '@angular/core';

import { Route } from '../lib/route';
import { TraversalCandidate } from '../lib/route-traverser';
Expand Down
19 changes: 8 additions & 11 deletions spec/link-active.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ import {
beforeEachProviders,
it,
iit,
TestComponentBuilder,
async,
inject,
expect
} from 'angular2/testing';
import {
Component,
provide
} from 'angular2/core';
} from '@angular/core/testing';
import { MockLocationStrategy, SpyLocation } from '@angular/common/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import { Component, provide } from '@angular/core';
import { LocationStrategy } from '@angular/common';
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/subject/BehaviorSubject';

import { LinkTo } from '../lib/link-to';
import { LinkActive } from '../lib/link-active';
import { ROUTER_PROVIDERS, Router } from '../lib/router';
import { SpyLocation } from 'angular2/router/testing';
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/subject/BehaviorSubject';
import { LocationStrategy } from 'angular2/platform/common';
import { MockLocationStrategy } from 'angular2/src/mock/mock_location_strategy';

@Component({
selector: 'link-active-test',
Expand Down
13 changes: 7 additions & 6 deletions spec/link-to.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import {
beforeEachProviders,
it,
iit,
TestComponentBuilder,
async,
inject,
expect
} from 'angular2/testing';
import { Component, provide, ViewChild } from 'angular2/core';
} from '@angular/core/testing';
import { MockLocationStrategy } from '@angular/common/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import { Component, provide, ViewChild } from '@angular/core';
import { LocationStrategy } from '@angular/common';
import { Observable } from 'rxjs/Observable';

import { LinkTo } from '../lib/link-to';
import { ROUTER_PROVIDERS, Router } from '../lib/router';
import { Observable } from 'rxjs/Observable';
import { LocationStrategy } from 'angular2/platform/common';
import { MockLocationStrategy } from 'angular2/src/mock/mock_location_strategy';

@Component({
selector: 'link-test',
Expand Down
3 changes: 2 additions & 1 deletion spec/params.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Subject } from 'rxjs/Subject';
import { ReflectiveInjector, provide } from 'angular2/core';
import { ReflectiveInjector, provide } from '@angular/core';

import { NextInstruction, RouterInstruction } from '../lib/router-instruction';
import { RouteParams, QueryParams, PARAMS_PROVIDERS } from '../lib/params';

Expand Down
Loading

0 comments on commit 2d51638

Please sign in to comment.