Repository URL to install this package:
|
Version:
1.2.17 ▾
|
import { MemoryRouter, StaticRouter, BrowserRouter } from 'react-router'
// import * as HistoryType from 'history'
/**
* @see https://github.com/mjackson/history
*/
export type Action = 'PUSH' | 'POP' | 'REPLACE';
export type UnregisterCallback = () => void;
export type LocationDescriptor = Path | LocationDescriptorObject;
export type LocationKey = string;
export type LocationListener = (location: Location, action: Action) => void;
export type LocationState = any;
export type Path = string;
export type Pathname = string;
export type Search = string;
export type TransitionHook = (location: Location, callback: (result: any) => void) => any;
export type Hash = string;
export type Href = string;
export interface OneRouterOptions {
shouldUseNative?: boolean
shouldStringify?: boolean
shouldMerge?: boolean
}
export interface HistoryType {
length: number;
action: Action;
location: Location;
push(path: Path, state?: LocationState): void;
push(location: LocationDescriptorObject): void;
replace(path: Path, state?: LocationState): void;
replace(location: LocationDescriptorObject): void;
go(n: number): void;
goBack(): void;
goForward(): void;
block(prompt?: boolean): UnregisterCallback;
listen(listener: LocationListener): UnregisterCallback;
createHref(location: LocationDescriptorObject): Href;
}
export interface Location {
pathname: Pathname;
search: Search;
state: LocationState;
hash: Hash;
key: LocationKey;
}
export interface LocationDescriptorObject {
pathname?: Pathname;
search?: Search;
state?: LocationState;
hash?: Hash;
key?: LocationKey;
}
// https://gist.github.com/icfantv/775a6000748384e9f77569017d67c240
// https://github.com/Microsoft/TypeScript/issues/6579
export type FullyQualifiedWebAddress = typeof (/^(?:[a-z]+:)?/)
export type RelativeWebAddress = '/route' | string
export type StringifiedParam = '=' | '?' | '#' | String
export type OneRouterParamVariations = Object | StringifiedParam
export declare class RouterEntries implements MemoryRouter, History, StaticRouter {
matched: any
location: any
history: HistoryType | History
// ((any: any) => any))
// ...browserLocation,
// ...this.history,
// ...this.history.location,
// ...this.getSearchParams({}),
// ...this.router,
// ...this.matched,
}
export declare class OneRouter {
// ReactRouter
router: MemoryRouter | StaticRouter | BrowserRouter
// ReactRouter.history || html5 history
history: History
urlFromExpress: string
entries(): RouterEntries
has(data: OneRouterParamVariations): Boolean
update(to: OneRouterParamVariations, options?: OneRouterOptions): OneRouter
delete(arg: String | Object): OneRouter
toString(pretty?: Boolean): String
private getSearchParams(fallback?: string): Object | ''
private get searchParams(): String
// localhost/eh/10/, /eh/:categoryId, match.params.categoryId
private get matched(): Object
private get pathname(): History.Pathname
private log(msg: String, data?: Object): void
}
export declare var oneRouter: OneRouter
declare global {
export const oneRouter: OneRouter
}