/
history_v4.9.x.js
138 lines (120 loc) · 3.69 KB
/
history_v4.9.x.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
declare module 'history' {
declare function Unblock(): void;
declare export type Action = 'PUSH' | 'REPLACE' | 'POP';
declare export type BrowserLocation = {
pathname: string,
search: string,
hash: string,
// Browser and Memory specific
state: {...},
key: string,
...
};
declare interface IBrowserHistory {
length: number;
location: BrowserLocation;
action: Action;
push(path: string, state?: {...}): void;
push(location: Partial<BrowserLocation>): void;
replace(path: string, state?: {...}): void;
replace(location: Partial<BrowserLocation>): void;
go(n: number): void;
goBack(): void;
goForward(): void;
listen((location: BrowserLocation, action: Action) => void): void;
block(message: string): typeof Unblock;
block(
(location: BrowserLocation, action: Action) => string
): typeof Unblock;
}
declare export type BrowserHistory = IBrowserHistory;
declare type BrowserHistoryOpts = {
basename?: string,
forceRefresh?: boolean,
getUserConfirmation?: (
message: string,
callback: (willContinue: boolean) => void
) => void,
...
};
declare function createBrowserHistory(
opts?: BrowserHistoryOpts
): BrowserHistory;
declare export type MemoryLocation = {
pathname: string,
search: string,
hash: string,
// Browser and Memory specific
state: {...},
key: string,
...
};
declare interface IMemoryHistory {
length: number;
location: MemoryLocation;
action: Action;
index: number;
entries: Array<string>;
push(path: string, state?: {...}): void;
push(location: Partial<MemoryLocation>): void;
replace(path: string, state?: {...}): void;
replace(location: Partial<MemoryLocation>): void;
go(n: number): void;
goBack(): void;
goForward(): void;
// Memory only
canGo(n: number): boolean;
listen((location: MemoryLocation, action: Action) => void): void;
block(message: string): typeof Unblock;
block((location: MemoryLocation, action: Action) => string): typeof Unblock;
}
declare export type MemoryHistory = IMemoryHistory;
declare type MemoryHistoryOpts = {
initialEntries?: Array<string>,
initialIndex?: number,
keyLength?: number,
getUserConfirmation?: (
message: string,
callback: (willContinue: boolean) => void
) => void,
...
};
declare function createMemoryHistory(opts?: MemoryHistoryOpts): MemoryHistory;
declare export type HashLocation = {
pathname: string,
search: string,
hash: string,
...
};
declare interface IHashHistory {
length: number;
location: HashLocation;
action: Action;
push(path: string, state?: {...}): void;
push(location: Partial<HashLocation>): void;
replace(path: string, state?: {...}): void;
replace(location: Partial<HashLocation>): void;
go(n: number): void;
goBack(): void;
goForward(): void;
listen((location: HashLocation, action: Action) => void): void;
block(message: string): typeof Unblock;
block((location: HashLocation, action: Action) => string): typeof Unblock;
push(path: string): void;
}
declare export type HashHistory = IHashHistory;
declare type HashHistoryOpts = {
basename?: string,
hashType: 'slash' | 'noslash' | 'hashbang',
getUserConfirmation?: (
message: string,
callback: (willContinue: boolean) => void
) => void,
...
};
declare function createHashHistory(opts?: HashHistoryOpts): HashHistory;
declare function parsePath(path: string): BrowserLocation | MemoryLocation | HashLocation;
declare function createPath(
path: BrowserLocation | MemoryLocation | HashLocation
): string;
}