Created
April 10, 2019 09:43
-
-
Save langpavel/62ebb1de81e31a01888ce4bce471b956 to your computer and use it in GitHub Desktop.
universal-router generated type definitions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Params } from './types'; | |
import UniversalRouter from './universal-router'; | |
export default function generateUrls(router: UniversalRouter<any, any>, options?: any): (routeName: string, params: Params) => string; | |
//# sourceMappingURL=generate-urls.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export * from './types'; | |
export * from './match-path'; | |
export * from './match-route'; | |
export * from './resolve-route'; | |
export * from './is-child-route'; | |
export { default as generateUrls } from './generate-urls'; | |
export { default as UniversalRouter } from './universal-router'; | |
export { default as UniversalRouterSync } from './universal-router-sync'; | |
//# sourceMappingURL=index.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Universal Router (https://www.kriasoft.com/universal-router/) | |
* | |
* Copyright (c) 2015-present Kriasoft. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE.txt file in the root directory of this source tree. | |
*/ | |
declare type WithParent = { | |
parent?: WithParent | null | undefined; | |
}; | |
export declare function isChildRoute(parentRoute: WithParent | null, childRoute: WithParent | null | undefined): boolean; | |
export {}; | |
//# sourceMappingURL=is-child-route.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Universal Router (https://www.kriasoft.com/universal-router/) | |
* | |
* Copyright (c) 2015-present Kriasoft. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE.txt file in the root directory of this source tree. | |
*/ | |
import { MatchedKeys, MatchedPath, Params, Route } from './types'; | |
export declare function matchPath<Context extends object, Result>(route: Route<Context, Result>, pathname: string, parentKeys: MatchedKeys, parentParams?: Params | null): MatchedPath | null; | |
//# sourceMappingURL=match-path.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Universal Router (https://www.kriasoft.com/universal-router/) | |
* | |
* Copyright (c) 2015-present Kriasoft. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE.txt file in the root directory of this source tree. | |
*/ | |
import { MatchedKeys, MatchedRoute, Params, Route } from './types'; | |
export declare function matchRoute<Context extends object, Result>(route: Route<Context, Result>, baseUrl: string, pathname: string, parentKeys: MatchedKeys, parentParams?: Params | null): { | |
next(routeToSkip?: Route<Context, Result> | null | undefined): MatchedRoute<Context, Result>; | |
}; | |
//# sourceMappingURL=match-route.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Universal Router (https://www.kriasoft.com/universal-router/) | |
* | |
* Copyright (c) 2015-present Kriasoft. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE.txt file in the root directory of this source tree. | |
*/ | |
import { Params, ResultReturn, RouteContext } from './types'; | |
export declare function resolveRoute<Context extends object, Result>(context: RouteContext<Context, Result>, params: Params): ResultReturn<Result>; | |
//# sourceMappingURL=resolve-route.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UniversalRouter from './universal-router'; | |
export interface Params { | |
[paramName: string]: string | string[]; | |
[paramIndex: number]: string | string[]; | |
} | |
export declare type MatchedKeys = Array<import('path-to-regexp').Key>; | |
export declare type MatchedPath = { | |
path: string; | |
keys: MatchedKeys; | |
params: Params; | |
}; | |
export interface MatchedRouteValue<Context extends object, Result> { | |
route: Route<Context, Result>; | |
baseUrl: string; | |
path: string; | |
keys: MatchedKeys; | |
params: Params; | |
} | |
export declare type MatchedRoute<Context extends object, Result> = { | |
done: true; | |
value: undefined; | |
} | { | |
done: false; | |
value: MatchedRouteValue<Context, Result>; | |
}; | |
export interface ResolveContext { | |
pathname: string; | |
} | |
export declare type MayBePromiseLike<T> = T | PromiseLike<T>; | |
export declare type ResultReturn<Result> = MayBePromiseLike<Result | null | undefined>; | |
export interface RouteContext<Context extends object, Result> extends ResolveContext, MatchedRouteValue<Context, Result> { | |
router: UniversalRouter<Context, Result>; | |
next(resume?: boolean, parent?: Route<Context, Result> | null | undefined, prevResult?: Result): ResultReturn<Result>; | |
} | |
export interface Route<Context extends object, Result> { | |
path?: string | RegExp | Array<string | RegExp>; | |
name?: string; | |
parent?: Route<Context, Result> | null; | |
children?: Routes<Context, Result> | null; | |
action?: (context: RouteContext<Context, Result>, params: Params) => ResultReturn<Result>; | |
[name: string]: unknown; | |
} | |
export declare type Routes<Context extends object, Result> = Array<Route<Context, Result>>; | |
export declare type RouteOrRoutes<Context extends object, Result> = Routes<Context, Result> | Route<Context, Result>; | |
export declare type ResolveRoute<Context extends object, Result> = (context: RouteContext<Context, Result>, params: Params) => ResultReturn<Result>; | |
export declare type ErrorHandler<Context extends object, Result> = (error: Error & { | |
status?: number; | |
}, context: RouteContext<Context, Result>) => ResultReturn<Result>; | |
export interface Options<Context extends object, Result> { | |
context?: Context; | |
baseUrl?: string; | |
resolveRoute?: ResolveRoute<Context, Result>; | |
errorHandler?: ErrorHandler<Context, Result>; | |
} | |
export declare type RouteNameMap = Map<string, any>; | |
//# sourceMappingURL=types.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Universal Router (https://www.kriasoft.com/universal-router/) | |
* | |
* Copyright (c) 2015-present Kriasoft. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE.txt file in the root directory of this source tree. | |
*/ | |
export * from './types'; | |
export { default as generateUrls } from './generate-urls'; | |
export { default as UniversalRouter } from './universal-router'; | |
//# sourceMappingURL=universal-router-generate-urls.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Universal Router (https://www.kriasoft.com/universal-router/) | |
* | |
* Copyright (c) 2015-present Kriasoft. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE.txt file in the root directory of this source tree. | |
*/ | |
import pathToRegexp from 'path-to-regexp'; | |
import { ErrorHandler, Options, ResolveContext, ResolveRoute, ResultReturn, Route, RouteOrRoutes } from './types'; | |
declare type RouterContext<Context extends object, Result> = Context & { | |
router: UniversalRouterSync<Context, Result>; | |
}; | |
export default class UniversalRouterSync<Context extends object, Result> { | |
static pathToRegexp: typeof pathToRegexp; | |
baseUrl: string; | |
errorHandler?: ErrorHandler<Context, Result>; | |
resolveRoute: ResolveRoute<Context, Result>; | |
context: RouterContext<Context, Result>; | |
root: Route<Context, Result>; | |
constructor(routes: RouteOrRoutes<Context, Result>, options?: Options<Context, Result>); | |
resolve(pathnameOrContext: string | (ResolveContext & Context)): ResultReturn<Result>; | |
} | |
export {}; | |
//# sourceMappingURL=universal-router-sync.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Universal Router (https://www.kriasoft.com/universal-router/) | |
* | |
* Copyright (c) 2015-present Kriasoft. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE.txt file in the root directory of this source tree. | |
*/ | |
import pathToRegexp from 'path-to-regexp'; | |
import { ErrorHandler, Options, ResolveContext, ResolveRoute, ResultReturn, Route, RouteNameMap, RouteOrRoutes } from './types'; | |
declare type RouterContext<Context extends object, Result> = Context & { | |
router: UniversalRouter<Context, Result>; | |
}; | |
export default class UniversalRouter<Context extends object, Result> { | |
static pathToRegexp: typeof pathToRegexp; | |
routesByName?: RouteNameMap; | |
baseUrl: string; | |
errorHandler?: ErrorHandler<Context, Result>; | |
resolveRoute: ResolveRoute<Context, Result>; | |
context: RouterContext<Context, Result>; | |
root: Route<Context, Result>; | |
constructor(routes: RouteOrRoutes<Context, Result>, options?: Options<Context, Result>); | |
resolve(pathnameOrContext: string | (ResolveContext & Context)): ResultReturn<Result>; | |
} | |
export {}; | |
//# sourceMappingURL=universal-router.d.ts.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment