2019-07-29 15:44:43 +03:00
|
|
|
type Kicker = {
|
|
|
|
text: () => Promise<SimpleResponse>,
|
|
|
|
json: () => Promise<SimpleResponse>,
|
|
|
|
html: () => Promise<SimpleResponse>
|
|
|
|
}
|
|
|
|
|
|
|
|
type SimpleRequest = {
|
|
|
|
method: string,
|
|
|
|
url: string,
|
2019-08-19 11:06:25 +03:00
|
|
|
body: FormData | null,
|
2019-07-29 15:44:43 +03:00
|
|
|
headers: Headers
|
|
|
|
}
|
|
|
|
|
|
|
|
export type SimpleResponse = {
|
|
|
|
url: string,
|
|
|
|
status: number,
|
2019-08-19 11:10:53 +03:00
|
|
|
statusText: string,
|
2019-07-29 15:44:43 +03:00
|
|
|
headers: Headers,
|
|
|
|
text: string,
|
|
|
|
json: {[key: string]: any},
|
|
|
|
html: DocumentFragment
|
|
|
|
}
|
|
|
|
|
2019-09-24 00:12:46 +03:00
|
|
|
export type ErrorWithResponse = {
|
|
|
|
response: SimpleResponse
|
|
|
|
}
|
|
|
|
|
2019-07-29 15:44:43 +03:00
|
|
|
export type RemoteFormHandler = (form: HTMLFormElement, kicker: Kicker, req: SimpleRequest) => void | Promise<void>;
|
2019-09-06 12:27:57 +03:00
|
|
|
export function afterRemote(fn: (form: HTMLFormElement) => void | Promise<void>): void;
|
|
|
|
export function beforeRemote(fn: (form: HTMLFormElement) => void | Promise<void>): void;
|
2019-07-29 15:44:43 +03:00
|
|
|
export function remoteForm(selector: string, fn: RemoteFormHandler): void;
|
|
|
|
export function remoteUninstall(selector: string, fn: RemoteFormHandler): void;
|