diff --git a/most-typings.d.ts b/most-typings.d.ts new file mode 100644 index 0000000..0a8c88d --- /dev/null +++ b/most-typings.d.ts @@ -0,0 +1,9 @@ +import {Stream} from 'most'; +import {Pathname, Location} from '@cycle/history/lib/interfaces'; +import {RouteDefinitions, SwitchPathReturn} from './lib/interfaces'; +export interface RouterSource { + history$: Stream; + path(pathname: Pathname): RouterSource; + define(routes: RouteDefinitions): Stream; + createHref(path: Pathname): Pathname; +} \ No newline at end of file diff --git a/rx-typings.d.ts b/rx-typings.d.ts new file mode 100644 index 0000000..ef2866a --- /dev/null +++ b/rx-typings.d.ts @@ -0,0 +1,9 @@ +import {Observable} from 'rx'; +import {Pathname, Location} from '@cycle/history/lib/interfaces'; +import {RouteDefinitions, SwitchPathReturn} from './lib/interfaces'; +export interface RouterSource { + history$: Observable; + path(pathname: Pathname): RouterSource; + define(routes: RouteDefinitions): Observable; + createHref(path: Pathname): Pathname; +} \ No newline at end of file diff --git a/rxjs-typings.d.ts b/rxjs-typings.d.ts new file mode 100644 index 0000000..8aac249 --- /dev/null +++ b/rxjs-typings.d.ts @@ -0,0 +1,9 @@ +import {Observable} from 'rxjs'; +import {Pathname, Location} from '@cycle/history/lib/interfaces'; +import {RouteDefinitions, SwitchPathReturn} from './lib/interfaces'; +export interface RouterSource { + history$: Observable; + path(pathname: Pathname): RouterSource; + define(routes: RouteDefinitions): Observable; + createHref(path: Pathname): Pathname; +} \ No newline at end of file diff --git a/src/RouterSource.ts b/src/RouterSource.ts index 2546eb9..cb936d0 100644 --- a/src/RouterSource.ts +++ b/src/RouterSource.ts @@ -1,7 +1,7 @@ import {StreamAdapter} from '@cycle/base'; import {Location, Pathname} from '@cycle/history/lib/interfaces'; -import switchPath, {RouteDefinitions} from 'switch-path'; - +import switchPath from 'switch-path'; +import {RouteDefinitions, SwitchPathReturn} from './interfaces'; import * as util from './util'; function isStrictlyInScope(namespace: Pathname[], path: Pathname): boolean { @@ -39,7 +39,7 @@ export class RouterSource { let match$ = this._runSA.remember(this.history$ .map((location: Location) => { const filteredPath = getFilteredPath(namespace, location.pathname); - const {path, value} = switchPath(filteredPath, routes); + const {path, value} = switchPath(filteredPath, routes); return {path, value, location, createHref}; })); diff --git a/src/custom-typings/main.d.ts b/src/custom-typings/main.d.ts deleted file mode 100644 index ea84f59..0000000 --- a/src/custom-typings/main.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/src/custom-typings/switch-path.d.ts b/src/custom-typings/switch-path.d.ts deleted file mode 100644 index 323d478..0000000 --- a/src/custom-typings/switch-path.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare module 'switch-path' { - export interface RouteDefinitions { - [sourcePath: string]: any; - } - - export interface SwitchPathReturn { - path: string; - value: any; - } - - export default function switchPath(sourcePath: string, routes: RouteDefinitions): SwitchPathReturn; -} diff --git a/src/interfaces.ts b/src/interfaces.ts new file mode 100644 index 0000000..f56bc51 --- /dev/null +++ b/src/interfaces.ts @@ -0,0 +1,8 @@ +export interface RouteDefinitions { + [sourcePath: string]: any; +} + +export interface SwitchPathReturn { + path: string; + value: any; +} \ No newline at end of file diff --git a/src/switch-path.d.ts b/src/switch-path.d.ts new file mode 100644 index 0000000..44a8148 --- /dev/null +++ b/src/switch-path.d.ts @@ -0,0 +1,3 @@ +declare module 'switch-path' { + export default function switchPath(sourcePath: string, routes: {}): {}; +} diff --git a/tsconfig.json b/tsconfig.json index 4b72259..afd7815 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,9 +15,8 @@ "tabSize": 2 }, "files": [ - "typings/main.d.ts", - "src/custom-typings/main.d.ts", - "src/index.ts" + "src/index.ts", + "src/switch-path.d.ts" ], "exclude": [ "node_modules" diff --git a/typings.json b/typings.json index 8cc16b2..b7e9453 100644 --- a/typings.json +++ b/typings.json @@ -1,8 +1,5 @@ { "name": "cyclic-router", - "dependencies": { - "@cycle/history": "npm:@cycle/history" - }, "ambientDevDependencies": { "mocha": "github:DefinitelyTyped/DefinitelyTyped/mocha/mocha.d.ts#d6dd320291705694ba8e1a79497a908e9f5e6617", "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#20e1eb9616922d382d918cc5a21870a9dbe255f5" diff --git a/xstream-typings.d.ts b/xstream-typings.d.ts new file mode 100644 index 0000000..4d45ba0 --- /dev/null +++ b/xstream-typings.d.ts @@ -0,0 +1,9 @@ +import {Stream} from 'xstream'; +import {Pathname} from '@cycle/history/lib/interfaces'; +import {RouteDefinitions, SwitchPathReturn} from './lib/interfaces'; +export interface RouterSource { + history$: Stream; + path(pathname: Pathname): RouterSource; + define(routes: RouteDefinitions): Stream; + createHref(path: Pathname): Pathname; +} \ No newline at end of file