From 964c99fbe388ff0392596609ff7737b99391e37d Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Fri, 18 Nov 2016 17:01:03 +0000 Subject: [PATCH 1/4] fix(#3087): deep rxjs imports --- src/ng2.ts | 9 ++++++++- src/ng2/directives/uiSref.ts | 9 +++++---- src/ng2/directives/uiSrefActive.ts | 2 +- src/ng2/directives/uiSrefStatus.ts | 6 ++++-- src/ng2/rx.ts | 3 ++- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/ng2.ts b/src/ng2.ts index ef6434367..8e27183e9 100644 --- a/src/ng2.ts +++ b/src/ng2.ts @@ -2,6 +2,14 @@ export * from "ui-router-core"; import "ui-router-core/lib/justjs"; +import 'rxjs/add/observable/of'; +import 'rxjs/add/observable/combineLatest'; +import 'rxjs/add/observable/fromPromise'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/mergeMap'; +import 'rxjs/add/operator/concat'; +import 'rxjs/add/operator/map'; + export * from "./ng2/interface"; export * from "./ng2/lazyLoadNgModule"; export * from "./ng2/rx"; @@ -11,4 +19,3 @@ export * from "./ng2/directives/directives"; export * from "./ng2/statebuilders/views"; export * from "./ng2/uiRouterNgModule"; export * from "./ng2/uiRouterConfig"; - diff --git a/src/ng2/directives/uiSref.ts b/src/ng2/directives/uiSref.ts index 900212c6d..c8c6a82aa 100644 --- a/src/ng2/directives/uiSref.ts +++ b/src/ng2/directives/uiSref.ts @@ -8,7 +8,8 @@ import {UIView, ParentUIViewInject} from "./uiView"; import {extend, Obj} from "ui-router-core"; import {TransitionOptions} from "ui-router-core"; import {Globals} from "ui-router-core"; -import {Subscription, ReplaySubject} from "rxjs/Rx"; +import {ReplaySubject} from 'rxjs/ReplaySubject'; +import {Subscription} from 'rxjs/Subscription'; import {TargetState} from "ui-router-core"; import "../rx"; @@ -30,7 +31,7 @@ export class AnchorUISref { * ### Purpose * * This directive is applied to anchor tags (``) or any other clickable element. It is a state reference (or sref -- - * similar to an href). When clicked, the directive will transition to that state by calling [[StateService.go]], + * similar to an href). When clicked, the directive will transition to that state by calling [[StateService.go]], * and optionally supply state parameter values and transition options. * * When this directive is on an anchor tag, it will also add an `href` attribute to the anchor. @@ -38,9 +39,9 @@ export class AnchorUISref { * ### Selector * * - `[uiSref]`: The directive is created as an attribute on an element, e.g., `` - * + * * ### Inputs - * + * * - `uiSref`: the target state's name, e.g., `uiSref="foostate"`. If a component template uses a relative `uiSref`, * e.g., `uiSref=".child"`, the reference is relative to that component's state. * diff --git a/src/ng2/directives/uiSrefActive.ts b/src/ng2/directives/uiSrefActive.ts index 7ce15dd43..6a33ade21 100644 --- a/src/ng2/directives/uiSrefActive.ts +++ b/src/ng2/directives/uiSrefActive.ts @@ -1,7 +1,7 @@ /** @module directives */ /** */ import {Directive, Input, ElementRef, Host, Renderer} from "@angular/core"; import {UISrefStatus, SrefStatus} from "./uiSrefStatus"; -import {Subscription} from "rxjs/Rx"; +import {Subscription} from "rxjs/Subscription"; /** * A directive that adds a CSS class when its associated `uiSref` link is active. diff --git a/src/ng2/directives/uiSrefStatus.ts b/src/ng2/directives/uiSrefStatus.ts index fc96b6342..f441c42f3 100644 --- a/src/ng2/directives/uiSrefStatus.ts +++ b/src/ng2/directives/uiSrefStatus.ts @@ -9,7 +9,9 @@ import {anyTrueR, tail, unnestR, Predicate} from "ui-router-core"; import {Globals, UIRouterGlobals} from "ui-router-core"; import {Param} from "ui-router-core"; import {PathFactory} from "ui-router-core"; -import {Subscription, Observable, BehaviorSubject} from "rxjs/Rx"; +import {Subscription} from "rxjs/Subscription"; +import {Observable} from "rxjs/Observable"; +import {BehaviorSubject} from "rxjs/BehaviorSubject"; /** @internalapi */ interface TransEvt { evt: string, trans: Transition } @@ -75,7 +77,7 @@ function spreadToSubPaths(basePath: PathNode[], appendPath: PathNode[]): PathNod /** * Given a TransEvt (Transition event: started, success, error) * and a UISref Target State, return a SrefStatus object - * which represents the current status of that Sref: + * which represents the current status of that Sref: * active, activeEq (exact match), entering, exiting * * @internalapi diff --git a/src/ng2/rx.ts b/src/ng2/rx.ts index 82e76547e..61e9a3747 100644 --- a/src/ng2/rx.ts +++ b/src/ng2/rx.ts @@ -1,5 +1,6 @@ /** @module ng2 */ /** */ -import {Observable, ReplaySubject} from "rxjs/Rx"; +import {Observable} from "rxjs/Observable"; +import {ReplaySubject} from "rxjs/ReplaySubject"; import {Transition} from "ui-router-core"; import {UIRouter} from "ui-router-core"; import {StateDeclaration} from "ui-router-core"; From dca0f61a2b9bcfee8e5c44b7a8ce2e86ab71d0cb Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Wed, 2 Nov 2016 17:51:38 -0500 Subject: [PATCH 2/4] chore(build): use ^2.0.0 ng2 deps --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 45619dd0d..a4eda1733 100644 --- a/package.json +++ b/package.json @@ -52,16 +52,16 @@ "ui-router-core": "=1.0.1" }, "peerDependencies": { - "@angular/core": "~2.0.0", - "@angular/common": "~2.0.0" + "@angular/core": "^2.0.0", + "@angular/common": "^2.0.0" }, "devDependencies": { - "@angular/common": "~2.0.0", - "@angular/compiler": "~2.0.0", - "@angular/core": "~2.0.0", - "@angular/platform-browser": "~2.0.0", - "@angular/platform-browser-dynamic": "~2.0.0", - "@angular/platform-server": "~2.0.0", + "@angular/common": "^2.0.0", + "@angular/compiler": "^2.0.0", + "@angular/core": "^2.0.0", + "@angular/platform-browser": "^2.0.0", + "@angular/platform-browser-dynamic": "^2.0.0", + "@angular/platform-server": "^2.0.0", "@types/jasmine": "^2.2.34", "@types/jquery": "^1.10.31", "awesome-typescript-loader": "^2.2.4", From 7d4ac6db28e4b38b345aa7467fd9b10de7238fbf Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Wed, 2 Nov 2016 18:28:32 -0500 Subject: [PATCH 3/4] fix(loadNgModule): Better error message when lazy loaded NgModule contains no state defs --- src/ng2/lazyLoadNgModule.ts | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/ng2/lazyLoadNgModule.ts b/src/ng2/lazyLoadNgModule.ts index 02b802131..047869e15 100644 --- a/src/ng2/lazyLoadNgModule.ts +++ b/src/ng2/lazyLoadNgModule.ts @@ -105,21 +105,19 @@ export function applyNgModule(transition: Transition, ng2Module: NgModuleRef parentRootModules.indexOf(module) === -1); + let newRootModules: RootModule[] = multiProviderParentChildDelta(parentInjector, injector, UIROUTER_ROOT_MODULE); if (newRootModules.length) { - console.log(rootModules); + console.log(newRootModules); throw new Error('Lazy loaded modules should not contain a UIRouterModule.forRoot() module'); } - let modules: StatesModule[] = injector.get(UIROUTER_MODULE_TOKEN); - modules.forEach(module => applyModuleConfig(uiRouter, injector, module)); + let newModules: RootModule[] = multiProviderParentChildDelta(parentInjector, injector, UIROUTER_MODULE_TOKEN); + newModules.forEach(module => applyModuleConfig(uiRouter, injector, module)); let replacementState = uiRouter.stateRegistry.get(originalName); if (replacementState === originalState) { - throw new Error(`The module that was lazy loaded by activating ${originalName} should also have a ui-router state named '${originalName}'`); + 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.`); } // Supply the newly loaded states with the Injector from the lazy loaded NgModule @@ -127,3 +125,19 @@ export function applyNgModule(transition: Transition, ng2Module: NgModuleRef parentVals.indexOf(val) === -1); +} \ No newline at end of file From 0a997a936e2e7f552cc98ff226dccdbc202bb257 Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Tue, 8 Nov 2016 20:55:45 -0600 Subject: [PATCH 4/4] docs(*): Mark files as @ng2docs. Symbols in these files will appear in the docs by default. --- package.json | 2 +- src/ng2.ts | 2 +- src/ng2/directives/directives.ts | 4 +++- src/ng2/directives/uiSref.ts | 2 +- src/ng2/directives/uiSrefActive.ts | 2 +- src/ng2/directives/uiSrefStatus.ts | 2 +- src/ng2/directives/uiView.ts | 2 +- src/ng2/interface.ts | 2 +- src/ng2/lazyLoadNgModule.ts | 2 +- src/ng2/uiRouterNgModule.ts | 2 +- tsconfig.typedoc.json | 35 +----------------------------- 11 files changed, 13 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index a4eda1733..c977642d1 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "clean": "shx rm -rf lib lib-esm _bundles _doc", "build": "npm run clean && tsc && tsc -p tsconfig.esm.json && webpack", "test": "karma start config/karma.ng2.js", - "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" + "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" }, "homepage": "https://ui-router.github.io/ng2", "contributors": [ diff --git a/src/ng2.ts b/src/ng2.ts index 8e27183e9..e44188599 100644 --- a/src/ng2.ts +++ b/src/ng2.ts @@ -1,4 +1,4 @@ -/** @module ng2 */ /** for typedoc */ +/** @ng2api @module ng2 */ /** for typedoc */ export * from "ui-router-core"; import "ui-router-core/lib/justjs"; diff --git a/src/ng2/directives/directives.ts b/src/ng2/directives/directives.ts index 954dd9b30..f03c4ac35 100644 --- a/src/ng2/directives/directives.ts +++ b/src/ng2/directives/directives.ts @@ -5,7 +5,9 @@ * - [[UISref]]: A state ref to a target state; navigates when clicked * - [[UISrefActive]]: (and `UISrefActiveEq`) Adds a css class when a UISref's target state (or a child state) is active * - * @preferred @module directives + * @ng2api + * @preferred + * @module directives */ /** */ import {UISref, AnchorUISref} from "./uiSref"; import {UISrefActive} from "./uiSrefActive"; diff --git a/src/ng2/directives/uiSref.ts b/src/ng2/directives/uiSref.ts index c8c6a82aa..2ff5434f4 100644 --- a/src/ng2/directives/uiSref.ts +++ b/src/ng2/directives/uiSref.ts @@ -1,4 +1,4 @@ -/** @module directives */ /** */ +/** @ng2api @module directives */ /** */ import {UIRouter, UIRouterGlobals} from "ui-router-core"; import {Directive, Inject, Input} from "@angular/core"; import {Optional} from "@angular/core"; diff --git a/src/ng2/directives/uiSrefActive.ts b/src/ng2/directives/uiSrefActive.ts index 6a33ade21..f50ed5ee1 100644 --- a/src/ng2/directives/uiSrefActive.ts +++ b/src/ng2/directives/uiSrefActive.ts @@ -1,4 +1,4 @@ -/** @module directives */ /** */ +/** @ng2api @module directives */ /** */ import {Directive, Input, ElementRef, Host, Renderer} from "@angular/core"; import {UISrefStatus, SrefStatus} from "./uiSrefStatus"; import {Subscription} from "rxjs/Subscription"; diff --git a/src/ng2/directives/uiSrefStatus.ts b/src/ng2/directives/uiSrefStatus.ts index f441c42f3..b0568b2a1 100644 --- a/src/ng2/directives/uiSrefStatus.ts +++ b/src/ng2/directives/uiSrefStatus.ts @@ -1,4 +1,4 @@ -/** @module directives */ /** */ +/** @ng2api @module directives */ /** */ import {Directive, Output, EventEmitter, ContentChildren, QueryList, Inject} from "@angular/core"; import {UISref} from "./uiSref"; import {PathNode} from "ui-router-core"; diff --git a/src/ng2/directives/uiView.ts b/src/ng2/directives/uiView.ts index f669bd8c9..77aa887b5 100755 --- a/src/ng2/directives/uiView.ts +++ b/src/ng2/directives/uiView.ts @@ -1,4 +1,4 @@ -/** @module directives */ /** */ +/** @ng2api @module directives */ /** */ import { Component, ComponentFactoryResolver, ViewContainerRef, Input, ComponentRef, Type, ReflectiveInjector, ViewChild, Injector, Inject diff --git a/src/ng2/interface.ts b/src/ng2/interface.ts index 60a0cc27c..7f84eda16 100644 --- a/src/ng2/interface.ts +++ b/src/ng2/interface.ts @@ -1,4 +1,4 @@ -/** @module state */ /** */ +/** @ng2api @module state */ /** */ import {StateDeclaration, _ViewDeclaration} from "ui-router-core"; import {Transition} from "ui-router-core"; import {Type, OpaqueToken} from "@angular/core"; diff --git a/src/ng2/lazyLoadNgModule.ts b/src/ng2/lazyLoadNgModule.ts index 047869e15..3fb53898e 100644 --- a/src/ng2/lazyLoadNgModule.ts +++ b/src/ng2/lazyLoadNgModule.ts @@ -1,4 +1,4 @@ -/** @module core */ /** */ +/** @ng2api @module core */ /** */ import {NgModuleFactoryLoader, NgModuleRef, Injector, NgModuleFactory, Type, Compiler} from "@angular/core"; import {Transition, LazyLoadResult, UIRouter, Resolvable, NATIVE_INJECTOR_TOKEN, isString} from "ui-router-core"; import {RootModule, StatesModule, UIROUTER_ROOT_MODULE, UIROUTER_MODULE_TOKEN} from "./uiRouterNgModule"; diff --git a/src/ng2/uiRouterNgModule.ts b/src/ng2/uiRouterNgModule.ts index 5ac08444c..76da7bffa 100644 --- a/src/ng2/uiRouterNgModule.ts +++ b/src/ng2/uiRouterNgModule.ts @@ -1,4 +1,4 @@ -/** @module core */ /** */ +/** @ng2api @module core */ /** */ import {Ng2StateDeclaration} from "./interface"; import {NgModule, OpaqueToken, ModuleWithProviders, ANALYZE_FOR_ENTRY_COMPONENTS, Provider, Type} from "@angular/core"; import {CommonModule} from "@angular/common"; diff --git a/tsconfig.typedoc.json b/tsconfig.typedoc.json index 00e35ad02..d05a082af 100644 --- a/tsconfig.typedoc.json +++ b/tsconfig.typedoc.json @@ -10,41 +10,8 @@ "sourceMap": false }, "files": [ + "src/ng2.ts", "../ui-router-core/src/index.ts", - "../ui-router-core/src/interface.ts", - "../ui-router-core/src/globals.ts", - "../ui-router-core/src/router.ts", - "../ui-router-core/src/common/glob.ts", - "../ui-router-core/src/common/trace.ts", - "../ui-router-core/src/params/module.ts", - "../ui-router-core/src/params/interface.ts", - "../ui-router-core/src/resolve/interface.ts", - "../ui-router-core/src/resolve/resolvable.ts", - "../ui-router-core/src/state/interface.ts", - "../ui-router-core/src/state/module.ts", - "../ui-router-core/src/state/stateObject.ts", - "../ui-router-core/src/state/stateRegistry.ts", - "../ui-router-core/src/state/stateService.ts", - "../ui-router-core/src/state/targetState.ts", - "../ui-router-core/src/transition/module.ts", - "../ui-router-core/src/transition/interface.ts", - "../ui-router-core/src/transition/transition.ts", - "../ui-router-core/src/transition/transitionService.ts", - "../ui-router-core/src/url/module.ts", - "../ui-router-core/src/url/urlMatcher.ts", - "../ui-router-core/src/url/urlMatcherFactory.ts", - "../ui-router-core/src/url/urlRouter.ts", - "../ui-router-core/src/view/module.ts", - "../ui-router-core/src/view/view.ts", - "src/ng2/directives/directives.ts", - "src/ng2/directives/uiSref.ts", - "src/ng2/directives/uiSrefActive.ts", - "src/ng2/directives/uiSrefStatus.ts", - "src/ng2/directives/uiView.ts", - "src/ng2/lazyLoadNgModule.ts", - "src/ng2/uiRouterNgModule.ts", - "src/ng2/interface.ts", - "src/index.ts", "node_modules/typescript/lib/lib.es6.d.ts" ] }