Skip to content

Commit 75cc29b

Browse files
Merge branch 'master' into aot
2 parents 271ded8 + 0a997a9 commit 75cc29b

File tree

12 files changed

+55
-61
lines changed

12 files changed

+55
-61
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"clean": "shx rm -rf lib lib-esm _bundles _doc",
77
"build": "npm run clean && node_modules/.bin/ngc && node_modules/.bin/ngc -p tsconfig.esm.json && webpack",
88
"test": "karma start config/karma.ng2.js",
9-
"docs": "typedoc --tsconfig tsconfig.typedoc.json --readme README.md --name 'ui-router-ng2' --theme node_modules/ui-router-typedoc-themes/bin/default --out _doc --external-aliases internalapi,external --navigation-label-globals ui-router-ng2"
9+
"docs": "typedoc --tsconfig tsconfig.typedoc.json --readme README.md --name 'ui-router-ng2' --theme node_modules/ui-router-typedoc-themes/bin/default --out _doc --internal-aliases internal,coreapi,ng2api --external-aliases internalapi,external --navigation-label-globals ui-router-ng2"
1010
},
1111
"homepage": "https://ui-router.github.io/ng2",
1212
"contributors": [
@@ -52,8 +52,8 @@
5252
"ui-router-core": "=1.0.1"
5353
},
5454
"peerDependencies": {
55-
"@angular/core": "~2.0.0",
56-
"@angular/common": "~2.0.0"
55+
"@angular/core": "^2.0.0",
56+
"@angular/common": "^2.0.0"
5757
},
5858
"devDependencies": {
5959
"@angular/common": "^2.3.1",

src/ng2.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
/** @module ng2 */ /** for typedoc */
1+
/** @ng2api @module ng2 */ /** for typedoc */
22
export * from "ui-router-core";
33
import "ui-router-core/lib/justjs";
44

5+
import 'rxjs/add/observable/of';
6+
import 'rxjs/add/observable/combineLatest';
7+
import 'rxjs/add/observable/fromPromise';
8+
import 'rxjs/add/operator/switchMap';
9+
import 'rxjs/add/operator/mergeMap';
10+
import 'rxjs/add/operator/concat';
11+
import 'rxjs/add/operator/map';
12+
513
export * from "./ng2/interface";
614
export * from "./ng2/lazyLoadNgModule";
715
export * from "./ng2/rx";
@@ -11,4 +19,3 @@ export * from "./ng2/directives/directives";
1119
export * from "./ng2/statebuilders/views";
1220
export * from "./ng2/uiRouterNgModule";
1321
export * from "./ng2/uiRouterConfig";
14-

src/ng2/directives/directives.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
* - [[UISref]]: A state ref to a target state; navigates when clicked
66
* - [[UISrefActive]]: (and `UISrefActiveEq`) Adds a css class when a UISref's target state (or a child state) is active
77
*
8-
* @preferred @module directives
8+
* @ng2api
9+
* @preferred
10+
* @module directives
911
*/ /** */
1012
import {UISref, AnchorUISref} from "./uiSref";
1113
import {UISrefActive} from "./uiSrefActive";

src/ng2/directives/uiSref.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module directives */ /** */
1+
/** @ng2api @module directives */ /** */
22
import {UIRouter, UIRouterGlobals} from "ui-router-core";
33
import {Directive, Inject, Input} from "@angular/core";
44
import {Optional} from "@angular/core";
@@ -8,7 +8,8 @@ import {UIView, ParentUIViewInject} from "./uiView";
88
import {extend, Obj} from "ui-router-core";
99
import {TransitionOptions} from "ui-router-core";
1010
import {Globals} from "ui-router-core";
11-
import {Subscription, ReplaySubject} from "rxjs/Rx";
11+
import {ReplaySubject} from 'rxjs/ReplaySubject';
12+
import {Subscription} from 'rxjs/Subscription';
1213
import {TargetState} from "ui-router-core";
1314
import "../rx";
1415

@@ -30,17 +31,17 @@ export class AnchorUISref {
3031
* ### Purpose
3132
*
3233
* This directive is applied to anchor tags (`<a>`) or any other clickable element. It is a state reference (or sref --
33-
* similar to an href). When clicked, the directive will transition to that state by calling [[StateService.go]],
34+
* similar to an href). When clicked, the directive will transition to that state by calling [[StateService.go]],
3435
* and optionally supply state parameter values and transition options.
3536
*
3637
* When this directive is on an anchor tag, it will also add an `href` attribute to the anchor.
3738
*
3839
* ### Selector
3940
*
4041
* - `[uiSref]`: The directive is created as an attribute on an element, e.g., `<a uiSref></a>`
41-
*
42+
*
4243
* ### Inputs
43-
*
44+
*
4445
* - `uiSref`: the target state's name, e.g., `uiSref="foostate"`. If a component template uses a relative `uiSref`,
4546
* e.g., `uiSref=".child"`, the reference is relative to that component's state.
4647
*

src/ng2/directives/uiSrefActive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/** @module directives */ /** */
1+
/** @ng2api @module directives */ /** */
22
import {Directive, Input, ElementRef, Host, Renderer} from "@angular/core";
33
import {UISrefStatus, SrefStatus} from "./uiSrefStatus";
4-
import {Subscription} from "rxjs/Rx";
4+
import {Subscription} from "rxjs/Subscription";
55

66
/**
77
* A directive that adds a CSS class when its associated `uiSref` link is active.

src/ng2/directives/uiSrefStatus.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module directives */ /** */
1+
/** @ng2api @module directives */ /** */
22
import {Directive, Output, EventEmitter, ContentChildren, QueryList, Inject} from "@angular/core";
33
import {UISref} from "./uiSref";
44
import {PathNode} from "ui-router-core";
@@ -9,7 +9,9 @@ import {anyTrueR, tail, unnestR, Predicate} from "ui-router-core";
99
import {Globals, UIRouterGlobals} from "ui-router-core";
1010
import {Param} from "ui-router-core";
1111
import {PathFactory} from "ui-router-core";
12-
import {Subscription, Observable, BehaviorSubject} from "rxjs/Rx";
12+
import {Subscription} from "rxjs/Subscription";
13+
import {Observable} from "rxjs/Observable";
14+
import {BehaviorSubject} from "rxjs/BehaviorSubject";
1315

1416
/** @internalapi */
1517
interface TransEvt { evt: string, trans: Transition }

src/ng2/directives/uiView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module directives */ /** */
1+
/** @ng2api @module directives */ /** */
22
import {
33
Component, ComponentFactoryResolver, ViewContainerRef, Input, ComponentRef, Type,
44
ReflectiveInjector, ViewChild, Injector, Inject

src/ng2/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module state */ /** */
1+
/** @ng2api @module state */ /** */
22
import {StateDeclaration, _ViewDeclaration} from "ui-router-core";
33
import {Transition} from "ui-router-core";
44
import {Type, OpaqueToken} from "@angular/core";

src/ng2/lazyLoadNgModule.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module core */ /** */
1+
/** @ng2api @module core */ /** */
22
import {NgModuleFactoryLoader, NgModuleRef, Injector, NgModuleFactory, Type, Compiler} from "@angular/core";
33
import {Transition, LazyLoadResult, UIRouter, Resolvable, NATIVE_INJECTOR_TOKEN, isString} from "ui-router-core";
44
import {RootModule, StatesModule, UIROUTER_ROOT_MODULE, UIROUTER_MODULE_TOKEN} from "./uiRouterNgModule";
@@ -105,25 +105,39 @@ export function applyNgModule(transition: Transition, ng2Module: NgModuleRef<any
105105
let originalName = transition.to().name;
106106
let originalState = uiRouter.stateRegistry.get(originalName);
107107

108-
let rootModules: RootModule[] = injector.get(UIROUTER_ROOT_MODULE);
109-
let parentRootModules: RootModule[] = parentInjector.get(UIROUTER_ROOT_MODULE);
110-
let newRootModules = rootModules.filter(module => parentRootModules.indexOf(module) === -1);
108+
let newRootModules: RootModule[] = multiProviderParentChildDelta(parentInjector, injector, UIROUTER_ROOT_MODULE);
111109

112110
if (newRootModules.length) {
113-
console.log(rootModules);
111+
console.log(newRootModules);
114112
throw new Error('Lazy loaded modules should not contain a UIRouterModule.forRoot() module');
115113
}
116114

117-
let modules: StatesModule[] = injector.get(UIROUTER_MODULE_TOKEN);
118-
modules.forEach(module => applyModuleConfig(uiRouter, injector, module));
115+
let newModules: RootModule[] = multiProviderParentChildDelta(parentInjector, injector, UIROUTER_MODULE_TOKEN);
116+
newModules.forEach(module => applyModuleConfig(uiRouter, injector, module));
119117

120118
let replacementState = uiRouter.stateRegistry.get(originalName);
121119
if (replacementState === originalState) {
122-
throw new Error(`The module that was lazy loaded by activating ${originalName} should also have a ui-router state named '${originalName}'`);
120+
throw new Error(`The Future State named '${originalName}' lazy loaded an NgModule. That NgModule should also have a UIRouterModule.forChild() state named '${originalName}' to replace the Future State, but it did not.`);
123121
}
124122

125123
// Supply the newly loaded states with the Injector from the lazy loaded NgModule
126124
replacementState.$$state().resolvables.push(Resolvable.fromData(NATIVE_INJECTOR_TOKEN, injector));
127125

128126
return {};
129127
}
128+
129+
/**
130+
* Returns the new dependency injection values from the Child Injector
131+
*
132+
* When a DI token is defined as multi: true, the child injector
133+
* can add new values for the token.
134+
*
135+
* This function returns the values added by the child injector, and excludes all values from the parent injector.
136+
*
137+
* @internalapi
138+
*/
139+
export function multiProviderParentChildDelta(parent: Injector, child: Injector, token: any) {
140+
let childVals: RootModule[] = child.get(token);
141+
let parentVals: RootModule[] = parent.get(token);
142+
return childVals.filter(val => parentVals.indexOf(val) === -1);
143+
}

src/ng2/rx.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @module ng2 */ /** */
2-
import {Observable, ReplaySubject} from "rxjs/Rx";
2+
import {Observable} from "rxjs/Observable";
3+
import {ReplaySubject} from "rxjs/ReplaySubject";
34
import {Transition} from "ui-router-core";
45
import {UIRouter} from "ui-router-core";
56
import {StateDeclaration} from "ui-router-core";

src/ng2/uiRouterNgModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @module core */ /** */
1+
/** @ng2api @module core */ /** */
22
import {Ng2StateDeclaration} from "./interface";
33
import {NgModule, OpaqueToken, ModuleWithProviders, ANALYZE_FOR_ENTRY_COMPONENTS, Provider, Type} from "@angular/core";
44
import {CommonModule} from "@angular/common";

tsconfig.typedoc.json

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,8 @@
1010
"sourceMap": false
1111
},
1212
"files": [
13+
"src/ng2.ts",
1314
"../ui-router-core/src/index.ts",
14-
"../ui-router-core/src/interface.ts",
15-
"../ui-router-core/src/globals.ts",
16-
"../ui-router-core/src/router.ts",
17-
"../ui-router-core/src/common/glob.ts",
18-
"../ui-router-core/src/common/trace.ts",
19-
"../ui-router-core/src/params/module.ts",
20-
"../ui-router-core/src/params/interface.ts",
21-
"../ui-router-core/src/resolve/interface.ts",
22-
"../ui-router-core/src/resolve/resolvable.ts",
23-
"../ui-router-core/src/state/interface.ts",
24-
"../ui-router-core/src/state/module.ts",
25-
"../ui-router-core/src/state/stateObject.ts",
26-
"../ui-router-core/src/state/stateRegistry.ts",
27-
"../ui-router-core/src/state/stateService.ts",
28-
"../ui-router-core/src/state/targetState.ts",
29-
"../ui-router-core/src/transition/module.ts",
30-
"../ui-router-core/src/transition/interface.ts",
31-
"../ui-router-core/src/transition/transition.ts",
32-
"../ui-router-core/src/transition/transitionService.ts",
33-
"../ui-router-core/src/url/module.ts",
34-
"../ui-router-core/src/url/urlMatcher.ts",
35-
"../ui-router-core/src/url/urlMatcherFactory.ts",
36-
"../ui-router-core/src/url/urlRouter.ts",
37-
"../ui-router-core/src/view/module.ts",
38-
"../ui-router-core/src/view/view.ts",
39-
"src/ng2/directives/directives.ts",
40-
"src/ng2/directives/uiSref.ts",
41-
"src/ng2/directives/uiSrefActive.ts",
42-
"src/ng2/directives/uiSrefStatus.ts",
43-
"src/ng2/directives/uiView.ts",
44-
"src/ng2/lazyLoadNgModule.ts",
45-
"src/ng2/uiRouterNgModule.ts",
46-
"src/ng2/interface.ts",
47-
"src/index.ts",
4815
"node_modules/typescript/lib/lib.es6.d.ts"
4916
]
5017
}

0 commit comments

Comments
 (0)