UNPKG

2.03 kBTypeScriptView Raw
1export declare type Path = string | RegExp | Array<string | RegExp>;
2export interface ActiveRouter {
3 subscribe: (location: LocationSegments, nextListeners: RouteSubscription[], routeSubscription: RouteSubscription) => Listener;
4 dispatch: (location: LocationSegments, nextListeners: RouteSubscription[]) => void;
5}
6export declare type Prompt = (location: LocationSegments, action: string) => string;
7export interface RouteRenderProps {
8 history: RouterHistory;
9 match: MatchResults;
10 [key: string]: any;
11}
12export interface RouteViewOptions {
13 scrollTopOffset?: number;
14 scrollToId?: string;
15}
16export interface RouteSubscription {
17 isMatch: boolean;
18 groupId?: string;
19 groupIndex?: number;
20}
21export declare type HistoryType = 'browser' | 'hash';
22export declare type Listener = () => void;
23export interface LocationSegments {
24 pathname: string;
25 query: {
26 [key: string]: any;
27 };
28 key: string;
29 scrollPosition?: [number, number];
30 search?: string;
31 hash?: string;
32 state?: any;
33}
34export declare type LocationSegmentPart = 'pathname' | 'search' | 'hash' | 'state' | 'key';
35export interface RouterHistory {
36 length: number;
37 action: string;
38 location: LocationSegments;
39 createHref: (location: LocationSegments) => string;
40 push: (path: string | LocationSegments, state?: any) => void;
41 replace: (path: string | LocationSegments, state?: any) => void;
42 go: (n: number) => void;
43 goBack: () => void;
44 goForward: () => void;
45 block: (prompt?: string | Prompt) => () => void;
46 listen: (listener: Function) => () => void;
47 win: Window;
48}
49export interface RouterGroup {
50 listenerList: ((switchMatched: boolean) => null | MatchResults)[];
51 groupedListener: () => void;
52 startLength: number;
53}
54export interface MatchOptions {
55 path?: Path;
56 exact?: boolean;
57 strict?: boolean;
58}
59export interface MatchResults {
60 path: string;
61 url: string;
62 isExact: boolean;
63 params: {
64 [key: string]: string;
65 };
66}