From e7ae47bc647622b654779da4f382fb6520c456c6 Mon Sep 17 00:00:00 2001 From: Leonardo Gentile Date: Wed, 2 May 2018 12:17:49 +0200 Subject: [PATCH 1/4] docs(README): Coorect peer deps --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6392dac..87c3d93 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This plugin can also be used standalone together with mobx. ## Requirements -- __router5 >= 5.0.0__ +- __router5 >= 6.1.2__ - __mobx >= 4.0.0__ These are considered `peerDependencies` that means they should exist in your installation, you should install them yourself to make this plugin work. The package won't install them as dependencies. From b0e7e732bf0c697cd8d98df0ca0df9cf4cfe9a93 Mon Sep 17 00:00:00 2001 From: Nenad Rakic Date: Tue, 22 May 2018 15:20:07 +0200 Subject: [PATCH 2/4] typescript typings wip --- src/index.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/index.d.ts diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..5f20627 --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,17 @@ +declare module "mobx-router5" { + import {PluginFactory} from "router5/core/plugins"; + + class RouterStore { + public navigate: (toRoute: string, params?: any) => void; + } + + function mobxPlugin(router: any): PluginFactory; + + namespace RouterStore {} + namespace mobxPlugin {} + + export { + RouterStore, + mobxPlugin, + }; +} \ No newline at end of file From d7afde22de4552476d305e6bc52e87ec4cb9e208 Mon Sep 17 00:00:00 2001 From: Nenad Rakic Date: Fri, 25 May 2018 10:28:45 +0200 Subject: [PATCH 3/4] added typescript typings --- .gitignore | 1 + src/index.d.ts | 46 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index cb91249..ff1bd01 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ coverage dist docs/dist node_modules +.idea npm-debug.log diff --git a/src/index.d.ts b/src/index.d.ts index 5f20627..98ab78a 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,17 +1,39 @@ +import {State} from "router5"; +import {IComputedValue} from "mobx/lib/core/computedvalue"; +import {Route, Router} from "router5/create-router"; + declare module "mobx-router5" { - import {PluginFactory} from "router5/core/plugins"; + import {PluginFactory} from "router5/core/plugins"; + import {Params} from "router5"; + + class RouterStore { + public router: Router; + public previousRoute: Route; + public transitionRoute: Route; + public transitionError: any; + public intersectionNode: string; + // public toActivate: IObservableArray; + // public toDeactivate: IObservableArray; - class RouterStore { - public navigate: (toRoute: string, params?: any) => void; - } + public setRouter: (router: Router) => void; + public updateRoute: (routeType: string, route: Route) => void; + public resetRoute: (routeType: string) => void; + public onTransitionStart: (route: Route, previousRoute: Route) => void; + public onTransitionSuccess: (route: Route, previousRoute: Route, opts) => void; + public onTransitionCancel: (route: Route, previousRoute: Route) => void; + public onTransitionError: (route: Route, previousRoute: Route, transitionError: any) => void; + public clearErrors: () => void; + public navigate: (toRoute: string, params?: Params) => void; + public shouldUpdateNodeFactory: (nodeName) => IComputedValue<(toState: State, fromState?: State) => Boolean>; + } - function mobxPlugin(router: any): PluginFactory; + function mobxPlugin(routerStore: RouterStore): PluginFactory; - namespace RouterStore {} - namespace mobxPlugin {} + namespace RouterStore {} + namespace mobxPlugin {} - export { - RouterStore, - mobxPlugin, - }; -} \ No newline at end of file + export { + RouterStore, + mobxPlugin, + }; +} From 4303d2fa6b9fb93775f2ea1397bfca5b143c6848 Mon Sep 17 00:00:00 2001 From: Nenad Rakic Date: Fri, 25 May 2018 10:40:15 +0200 Subject: [PATCH 4/4] added types for transition options and nodeName --- src/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 98ab78a..8a5e2b8 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,6 +1,7 @@ import {State} from "router5"; import {IComputedValue} from "mobx/lib/core/computedvalue"; import {Route, Router} from "router5/create-router"; +import {Options} from "router5/core/navigation"; declare module "mobx-router5" { import {PluginFactory} from "router5/core/plugins"; @@ -19,12 +20,12 @@ declare module "mobx-router5" { public updateRoute: (routeType: string, route: Route) => void; public resetRoute: (routeType: string) => void; public onTransitionStart: (route: Route, previousRoute: Route) => void; - public onTransitionSuccess: (route: Route, previousRoute: Route, opts) => void; + public onTransitionSuccess: (route: Route, previousRoute: Route, opts: Options) => void; public onTransitionCancel: (route: Route, previousRoute: Route) => void; public onTransitionError: (route: Route, previousRoute: Route, transitionError: any) => void; public clearErrors: () => void; public navigate: (toRoute: string, params?: Params) => void; - public shouldUpdateNodeFactory: (nodeName) => IComputedValue<(toState: State, fromState?: State) => Boolean>; + public shouldUpdateNodeFactory: (nodeName: string) => IComputedValue<(toState: State, fromState?: State) => Boolean>; } function mobxPlugin(routerStore: RouterStore): PluginFactory;