@types/hotwired__turbo 8.0.0 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hotwired__turbo/README.md +1 -1
- hotwired__turbo/index.d.ts +152 -10
- hotwired__turbo/package.json +4 -3
hotwired__turbo/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for @hotwired/turbo (https://turbo.hotwir
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hotwired__turbo.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated: Mon,
|
|
11
|
+
* Last updated: Mon, 11 Nov 2024 19:32:12 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
hotwired__turbo/index.d.ts
CHANGED
|
@@ -40,8 +40,32 @@ export class StreamElement extends HTMLElement {
|
|
|
40
40
|
readonly requestId: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export class FetchRequest {
|
|
44
|
-
|
|
43
|
+
export class FetchRequest {
|
|
44
|
+
body: FormData | URLSearchParams;
|
|
45
|
+
enctype: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
|
46
|
+
fetchOptions: RequestInit;
|
|
47
|
+
headers: Headers | { [k: string]: any };
|
|
48
|
+
method: "get" | "post" | "put" | "patch" | "delete";
|
|
49
|
+
params: URLSearchParams;
|
|
50
|
+
target: HTMLFormElement | HTMLAnchorElement | FrameElement | null;
|
|
51
|
+
url: URL;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class FetchResponse {
|
|
55
|
+
clientError: boolean;
|
|
56
|
+
contentType: string;
|
|
57
|
+
failed: boolean;
|
|
58
|
+
header(key: string): string | undefined;
|
|
59
|
+
isHTML: boolean;
|
|
60
|
+
location: URL;
|
|
61
|
+
redirected: boolean;
|
|
62
|
+
responseHTML: Promise<string>;
|
|
63
|
+
responseText: Promise<string>;
|
|
64
|
+
response: Response;
|
|
65
|
+
serverError: boolean;
|
|
66
|
+
statusCode: number;
|
|
67
|
+
succeeded: boolean;
|
|
68
|
+
}
|
|
45
69
|
|
|
46
70
|
/**
|
|
47
71
|
* Connects a stream source to the main session.
|
|
@@ -71,10 +95,16 @@ export interface TurboSession {
|
|
|
71
95
|
renderStreamMessage(message: unknown): void;
|
|
72
96
|
}
|
|
73
97
|
|
|
74
|
-
export
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
export const StreamActions: {
|
|
99
|
+
[action: string]: (this: StreamElement) => void;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type Action = "advance" | "replace" | "restore";
|
|
103
|
+
export interface VisitOptions {
|
|
104
|
+
action?: Action;
|
|
105
|
+
frame?: string;
|
|
106
|
+
}
|
|
107
|
+
export function visit(location: string, options?: VisitOptions): void;
|
|
78
108
|
|
|
79
109
|
export interface TurboGlobal {
|
|
80
110
|
/**
|
|
@@ -98,10 +128,7 @@ export interface TurboGlobal {
|
|
|
98
128
|
*/
|
|
99
129
|
setConfirmMethod(confirmMethod: () => boolean): void;
|
|
100
130
|
|
|
101
|
-
visit(
|
|
102
|
-
location: string,
|
|
103
|
-
options?: { action?: "advance" | "replace"; frame?: string },
|
|
104
|
-
): void;
|
|
131
|
+
visit(location: string, options?: { action?: Action; frame?: string }): void;
|
|
105
132
|
|
|
106
133
|
session: TurboSession;
|
|
107
134
|
}
|
|
@@ -109,3 +136,118 @@ export interface TurboGlobal {
|
|
|
109
136
|
declare global {
|
|
110
137
|
const Turbo: TurboGlobal;
|
|
111
138
|
}
|
|
139
|
+
|
|
140
|
+
export type Render = (currentElement: StreamElement) => Promise<void>;
|
|
141
|
+
export type TimingData = unknown;
|
|
142
|
+
export type VisitFallback = (location: string | Response, options: VisitOptions) => Promise<void>;
|
|
143
|
+
|
|
144
|
+
export type TurboBeforeCacheEvent = CustomEvent;
|
|
145
|
+
export type TurboBeforePrefetchEvent = CustomEvent;
|
|
146
|
+
export type TurboBeforeRenderEvent = CustomEvent<{
|
|
147
|
+
newBody: HTMLBodyElement;
|
|
148
|
+
renderMethod: "replace" | "morph";
|
|
149
|
+
isPreview: boolean;
|
|
150
|
+
resume: (value?: any) => void;
|
|
151
|
+
render: (currentBody: HTMLBodyElement, newBody: HTMLBodyElement) => void;
|
|
152
|
+
}>;
|
|
153
|
+
export type TurboBeforeVisitEvent = CustomEvent<{ url: string }>;
|
|
154
|
+
export type TurboClickEvent = CustomEvent<{
|
|
155
|
+
url: string;
|
|
156
|
+
originalEvent: MouseEvent;
|
|
157
|
+
}>;
|
|
158
|
+
export type TurboFrameLoadEvent = CustomEvent;
|
|
159
|
+
export type TurboBeforeFrameRenderEvent = CustomEvent<{
|
|
160
|
+
newFrame: FrameElement;
|
|
161
|
+
resume: (value?: any) => void;
|
|
162
|
+
render: (currentFrame: FrameElement, newFrame: FrameElement) => void;
|
|
163
|
+
}>;
|
|
164
|
+
export type TurboFrameRenderEvent = CustomEvent<{
|
|
165
|
+
fetchResponse: FetchResponse;
|
|
166
|
+
}>;
|
|
167
|
+
export type TurboLoadEvent = CustomEvent<{ url: string; timing: TimingData }>;
|
|
168
|
+
export type TurboRenderEvent = CustomEvent;
|
|
169
|
+
export type TurboReloadEvent = CustomEvent;
|
|
170
|
+
export type TurboVisitEvent = CustomEvent<{ url: string; action: Action }>;
|
|
171
|
+
|
|
172
|
+
export type TurboBeforeStreamRenderEvent = CustomEvent<{
|
|
173
|
+
newStream: StreamElement;
|
|
174
|
+
render: Render;
|
|
175
|
+
}>;
|
|
176
|
+
|
|
177
|
+
export interface FormSubmission {
|
|
178
|
+
action: string;
|
|
179
|
+
body: FormData | URLSearchParams;
|
|
180
|
+
enctype: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
|
181
|
+
fetchRequest: FetchRequest;
|
|
182
|
+
formElement: HTMLFormElement;
|
|
183
|
+
isSafe: boolean;
|
|
184
|
+
location: URL;
|
|
185
|
+
method: "get" | "post" | "put" | "patch" | "delete";
|
|
186
|
+
stop(): void;
|
|
187
|
+
submitter?: HTMLButtonElement | HTMLInputElement;
|
|
188
|
+
}
|
|
189
|
+
export type FormSubmissionResult =
|
|
190
|
+
| { success: boolean; fetchResponse: FetchResponse }
|
|
191
|
+
| { success: false; error: Error };
|
|
192
|
+
|
|
193
|
+
export type TurboSubmitStartEvent = CustomEvent<{
|
|
194
|
+
formSubmission: FormSubmission;
|
|
195
|
+
}>;
|
|
196
|
+
export type TurboSubmitEndEvent = CustomEvent<
|
|
197
|
+
& { formSubmission: FormSubmission }
|
|
198
|
+
& {
|
|
199
|
+
[K in keyof FormSubmissionResult]?: FormSubmissionResult[K];
|
|
200
|
+
}
|
|
201
|
+
>;
|
|
202
|
+
|
|
203
|
+
export type TurboFrameMissingEvent = CustomEvent<{
|
|
204
|
+
response: Response;
|
|
205
|
+
visit: VisitFallback;
|
|
206
|
+
}>;
|
|
207
|
+
|
|
208
|
+
export type TurboBeforeFetchRequestEvent = CustomEvent<{
|
|
209
|
+
fetchOptions: RequestInit;
|
|
210
|
+
url: URL;
|
|
211
|
+
resume: (value: any) => void;
|
|
212
|
+
}>;
|
|
213
|
+
|
|
214
|
+
export type TurboBeforeFetchResponseEvent = CustomEvent<{
|
|
215
|
+
fetchResponse: FetchResponse;
|
|
216
|
+
}>;
|
|
217
|
+
|
|
218
|
+
export type TurboFetchRequestErrorEvent = CustomEvent<{
|
|
219
|
+
request: FetchRequest;
|
|
220
|
+
error: Error;
|
|
221
|
+
}>;
|
|
222
|
+
|
|
223
|
+
export interface TurboElementEventMap {
|
|
224
|
+
"turbo:before-frame-render": TurboBeforeFrameRenderEvent;
|
|
225
|
+
"turbo:before-fetch-request": TurboBeforeFetchRequestEvent;
|
|
226
|
+
"turbo:before-fetch-response": TurboBeforeFetchResponseEvent;
|
|
227
|
+
"turbo:fetch-request-error": TurboFetchRequestErrorEvent;
|
|
228
|
+
"turbo:frame-load": TurboFrameLoadEvent;
|
|
229
|
+
"turbo:frame-render": TurboFrameRenderEvent;
|
|
230
|
+
"turbo:frame-missing": TurboFrameMissingEvent;
|
|
231
|
+
"turbo:submit-start": TurboSubmitStartEvent;
|
|
232
|
+
"turbo:submit-end": TurboSubmitEndEvent;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface TurboGlobalEventHandlersEventMap extends TurboElementEventMap {
|
|
236
|
+
"turbo:before-cache": TurboBeforeCacheEvent;
|
|
237
|
+
"turbo:before-prefetch": TurboBeforePrefetchEvent;
|
|
238
|
+
"turbo:before-stream-render": TurboBeforeStreamRenderEvent;
|
|
239
|
+
"turbo:before-render": TurboBeforeRenderEvent;
|
|
240
|
+
"turbo:before-visit": TurboBeforeVisitEvent;
|
|
241
|
+
"turbo:click": TurboClickEvent;
|
|
242
|
+
"turbo:load": TurboLoadEvent;
|
|
243
|
+
"turbo:render": TurboRenderEvent;
|
|
244
|
+
"turbo:reload": TurboReloadEvent;
|
|
245
|
+
"turbo:visit": TurboVisitEvent;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
declare global {
|
|
249
|
+
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
250
|
+
interface ElementEventMap extends TurboElementEventMap {}
|
|
251
|
+
interface GlobalEventHandlersEventMap extends TurboGlobalEventHandlersEventMap {}
|
|
252
|
+
/* eslint-enable @typescript-eslint/no-empty-interface */
|
|
253
|
+
}
|
hotwired__turbo/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/hotwired__turbo",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"description": "TypeScript definitions for @hotwired/turbo",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hotwired__turbo",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {},
|
|
27
27
|
"dependencies": {},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"peerDependencies": {},
|
|
29
|
+
"typesPublisherContentHash": "f650a9ca94456cc346fc48c3c2ba2c8bcd3d5c4f5113befe5ca20bc6ecc77c9a",
|
|
30
|
+
"typeScriptVersion": "4.9"
|
|
30
31
|
}
|