|
1 | | -interface Window { |
2 | | - readonly navigation: Navigation; |
3 | | -} |
| 1 | +// As of TS 6.0, the dom-navigation types are included in lib.dom.d.ts. |
4 | 2 |
|
5 | | -interface NavigationEventMap { |
6 | | - navigate: NavigateEvent; |
7 | | - navigatesuccess: Event; |
8 | | - navigateerror: ErrorEvent; |
9 | | - currententrychange: NavigationCurrentEntryChangeEvent; |
10 | | -} |
11 | | - |
12 | | -interface NavigationResult { |
13 | | - committed: Promise<NavigationHistoryEntry>; |
14 | | - finished: Promise<NavigationHistoryEntry>; |
15 | | -} |
16 | | - |
17 | | -declare class Navigation extends EventTarget { |
18 | | - entries(): NavigationHistoryEntry[]; |
19 | | - readonly currentEntry: NavigationHistoryEntry | null; |
20 | | - updateCurrentEntry(options: NavigationUpdateCurrentEntryOptions): void; |
21 | | - readonly transition: NavigationTransition | null; |
22 | | - |
23 | | - readonly canGoBack: boolean; |
24 | | - readonly canGoForward: boolean; |
25 | | - |
26 | | - navigate(url: string, options?: NavigationNavigateOptions): NavigationResult; |
27 | | - reload(options?: NavigationReloadOptions): NavigationResult; |
28 | | - |
29 | | - traverseTo(key: string, options?: NavigationOptions): NavigationResult; |
30 | | - back(options?: NavigationOptions): NavigationResult; |
31 | | - forward(options?: NavigationOptions): NavigationResult; |
32 | | - |
33 | | - onnavigate: ((this: Navigation, ev: NavigateEvent) => any) | null; |
34 | | - onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null; |
35 | | - onnavigateerror: ((this: Navigation, ev: ErrorEvent) => any) | null; |
36 | | - oncurrententrychange: ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any) | null; |
37 | | - |
38 | | - addEventListener<K extends keyof NavigationEventMap>( |
39 | | - type: K, |
40 | | - listener: (this: Navigation, ev: NavigationEventMap[K]) => any, |
41 | | - options?: boolean | AddEventListenerOptions, |
42 | | - ): void; |
43 | | - addEventListener( |
44 | | - type: string, |
45 | | - listener: EventListenerOrEventListenerObject, |
46 | | - options?: boolean | AddEventListenerOptions, |
47 | | - ): void; |
48 | | - removeEventListener<K extends keyof NavigationEventMap>( |
49 | | - type: K, |
50 | | - listener: (this: Navigation, ev: NavigationEventMap[K]) => any, |
51 | | - options?: boolean | EventListenerOptions, |
52 | | - ): void; |
53 | | - removeEventListener( |
54 | | - type: string, |
55 | | - listener: EventListenerOrEventListenerObject, |
56 | | - options?: boolean | EventListenerOptions, |
57 | | - ): void; |
58 | | -} |
59 | | - |
60 | | -declare class NavigationTransition { |
61 | | - readonly navigationType: NavigationTypeString; |
62 | | - readonly from: NavigationHistoryEntry; |
63 | | - readonly finished: Promise<void>; |
64 | | -} |
65 | | - |
66 | | -interface NavigationHistoryEntryEventMap { |
67 | | - dispose: Event; |
68 | | -} |
69 | | - |
70 | | -interface NavigationHistoryEntry extends EventTarget { |
71 | | - readonly key: string; |
72 | | - readonly id: string; |
73 | | - readonly url: string | null; |
74 | | - readonly index: number; |
75 | | - readonly sameDocument: boolean; |
76 | | - |
77 | | - getState(): unknown; |
78 | | - |
79 | | - ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null; |
80 | | - |
81 | | - addEventListener<K extends keyof NavigationHistoryEntryEventMap>( |
82 | | - type: K, |
83 | | - listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, |
84 | | - options?: boolean | AddEventListenerOptions, |
85 | | - ): void; |
86 | | - addEventListener( |
87 | | - type: string, |
88 | | - listener: EventListenerOrEventListenerObject, |
89 | | - options?: boolean | AddEventListenerOptions, |
90 | | - ): void; |
91 | | - removeEventListener<K extends keyof NavigationHistoryEntryEventMap>( |
92 | | - type: K, |
93 | | - listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, |
94 | | - options?: boolean | EventListenerOptions, |
95 | | - ): void; |
96 | | - removeEventListener( |
97 | | - type: string, |
98 | | - listener: EventListenerOrEventListenerObject, |
99 | | - options?: boolean | EventListenerOptions, |
100 | | - ): void; |
101 | | -} |
102 | | - |
103 | | -declare var NavigationHistoryEntry: { |
104 | | - prototype: NavigationHistoryEntry; |
105 | | - new(): NavigationHistoryEntry; |
106 | | -}; |
107 | | - |
108 | | -type NavigationTypeString = "reload" | "push" | "replace" | "traverse"; |
109 | | - |
110 | | -interface NavigationUpdateCurrentEntryOptions { |
111 | | - state: unknown; |
112 | | -} |
113 | | - |
114 | | -interface NavigationOptions { |
115 | | - info?: unknown; |
116 | | -} |
117 | | - |
118 | | -interface NavigationNavigateOptions extends NavigationOptions { |
119 | | - state?: unknown; |
120 | | - history?: "auto" | "push" | "replace"; |
121 | | -} |
122 | | - |
123 | | -interface NavigationReloadOptions extends NavigationOptions { |
124 | | - state?: unknown; |
125 | | -} |
126 | | - |
127 | | -declare class NavigationCurrentEntryChangeEvent extends Event { |
128 | | - constructor(type: string, eventInit?: NavigationCurrentEntryChangeEventInit); |
129 | | - |
130 | | - readonly navigationType: NavigationTypeString | null; |
131 | | - readonly from: NavigationHistoryEntry; |
132 | | -} |
133 | | - |
134 | | -interface NavigationCurrentEntryChangeEventInit extends EventInit { |
135 | | - navigationType?: NavigationTypeString | null; |
136 | | - from: NavigationHistoryEntry; |
137 | | -} |
138 | | - |
139 | | -declare class NavigateEvent extends Event { |
140 | | - constructor(type: string, eventInit?: NavigateEventInit); |
141 | | - |
142 | | - readonly navigationType: NavigationTypeString; |
143 | | - readonly canIntercept: boolean; |
144 | | - readonly userInitiated: boolean; |
145 | | - readonly hashChange: boolean; |
146 | | - readonly hasUAVisualTransition: boolean; |
147 | | - readonly destination: NavigationDestination; |
148 | | - readonly signal: AbortSignal; |
149 | | - readonly formData: FormData | null; |
150 | | - readonly downloadRequest: string | null; |
151 | | - readonly info?: unknown; |
152 | | - |
153 | | - intercept(options?: NavigationInterceptOptions): void; |
154 | | - scroll(): void; |
155 | | -} |
156 | | - |
157 | | -interface NavigateEventInit extends EventInit { |
158 | | - navigationType?: NavigationTypeString; |
159 | | - canIntercept?: boolean; |
160 | | - userInitiated?: boolean; |
161 | | - hashChange?: boolean; |
162 | | - destination: NavigationDestination; |
163 | | - signal: AbortSignal; |
164 | | - formData?: FormData | null; |
165 | | - downloadRequest?: string | null; |
166 | | - info?: unknown; |
167 | | -} |
168 | | - |
169 | | -interface NavigationInterceptOptions { |
170 | | - handler?: () => Promise<void>; |
171 | | - focusReset?: "after-transition" | "manual"; |
172 | | - scroll?: "after-transition" | "manual"; |
173 | | -} |
174 | | - |
175 | | -declare class NavigationDestination { |
176 | | - readonly url: string; |
177 | | - readonly key: string | null; |
178 | | - readonly id: string | null; |
179 | | - readonly index: number; |
180 | | - readonly sameDocument: boolean; |
181 | | - |
182 | | - getState(): unknown; |
183 | | -} |
| 3 | +type NavigationTypeString = NavigationType; |
0 commit comments