Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create app_history.d.ts #140

Merged
merged 5 commits into from
Jul 30, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions app_history.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
interface Window {
readonly appHistory: AppHistory;
}

declare class AppHistory extends EventTarget {
readonly current: AppHistoryEntry|null;
readonly transition: AppHistoryTransition|null;

entries(): AppHistoryEntry[];

readonly canGoBack: boolean;
readonly canGoForward: boolean;

navigate(url: string, options?: AppHistoryNavigateOptions): Promise<void>;
tbondwilkinson marked this conversation as resolved.
Show resolved Hide resolved
reload(options?: AppHistoryReloadOptions): Promise<void>;

goTo(key: string, options?: AppHistoryNavigationOptions): Promise<void>;
back(options?: AppHistoryNavigationOptions): Promise<void>;
forward(options?: AppHistoryNavigationOptions): Promise<void>;

onnavigate: ((this: AppHistory, ev: Event) => any)|null;
tbondwilkinson marked this conversation as resolved.
Show resolved Hide resolved
onnavigatesuccess: ((this: AppHistory, ev: Event) => any)|null;
onnavigateerror: ((this: AppHistory, ev: Event) => any)|null;
tbondwilkinson marked this conversation as resolved.
Show resolved Hide resolved
}

declare class AppHistoryTransition {
readonly navigationType: AppHistoryNavigationType;
readonly from: AppHistoryEntry;
readonly finished: Promise<void>;

rollback(options?: AppHistoryNavigationOptions): Promise<void>;
}

declare class AppHistoryEntry extends EventTarget {
readonly key: string;
readonly id: string;
readonly url: string;
readonly index: number;
readonly sameDocument: boolean;

getState(): unknown;

onnavigateto: ((this: AppHistoryEntry, ev: Event) => any)|null;
onnavigatefrom: ((this: AppHistoryEntry, ev: Event) => any)|null;
onfinish: ((this: AppHistoryEntry, ev: Event) => any)|null;
ondispose: ((this: AppHistoryEntry, ev: Event) => any)|null;
}

type AppHistoryNavigationType = 'reload'|'push'|'replace'|'traverse';

declare class AppHistoryNavigationOptions {
tbondwilkinson marked this conversation as resolved.
Show resolved Hide resolved
navigateInfo?: unknown;
}

declare class AppHistoryNavigateOptions extends AppHistoryNavigationOptions {
state?: unknown;
replace?: boolean;
}

declare class AppHistoryReloadOptions extends AppHistoryNavigationOptions {
state?: unknown;
}

declare class AppHistoryNavigateEvent extends Event {
tbondwilkinson marked this conversation as resolved.
Show resolved Hide resolved
constructor(type: string, eventInit: AppHistoryNavigateEventInit);

readonly navigationType: AppHistoryNavigationType;
readonly canRespond: boolean;
readonly userInitiated: boolean;
readonly hashChange: boolean;
readonly destination: AppHistoryDestination;
readonly signal: AbortSignal;
readonly formData: FormData|null;
readonly info: unknown;

respondWith(newNavigationAction: Promise<void>): void;
}

declare class AppHistoryNavigateEventInit extends EventInit {
tbondwilkinson marked this conversation as resolved.
Show resolved Hide resolved
navigationType?: AppHistoryNavigationType;
canRespond?: boolean;
userInitiated?: boolean;
hashChange?: boolean;
destination: AppHistoryDestination;
signal: AbortSignal;
formData?: FormData|null;
info?: unknown;
}

declare class AppHistoryDestination {
readonly url: string;
readonly key: string|null;
readonly id: string|null;
readonly index: number;
readonly sameDocument: boolean;

getState(): unknown;
}