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