@hotwired/turbo 7.2.0-beta.2 → 7.2.0-rc.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.
- package/README.md +4 -0
- package/dist/turbo.es2017-esm.js +137 -62
- package/dist/turbo.es2017-umd.js +147 -69
- package/dist/types/core/drive/form_submission.d.ts +1 -3
- package/dist/types/core/drive/navigator.d.ts +1 -1
- package/dist/types/core/drive/visit.d.ts +2 -1
- package/dist/types/core/frames/frame_controller.d.ts +9 -3
- package/dist/types/core/index.d.ts +3 -5
- package/dist/types/core/session.d.ts +6 -10
- package/dist/types/core/snapshot.d.ts +3 -1
- package/dist/types/core/streams/stream_actions.d.ts +4 -2
- package/dist/types/core/streams/stream_message_renderer.d.ts +7 -0
- package/dist/types/elements/index.d.ts +1 -0
- package/dist/types/elements/stream_element.d.ts +5 -1
- package/dist/types/http/fetch_request.d.ts +7 -3
- package/dist/types/http/index.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/tests/functional/drive_custom_body_tests.d.ts +1 -0
- package/dist/types/tests/helpers/page.d.ts +8 -2
- package/dist/types/util.d.ts +1 -0
- package/package.json +4 -4
|
@@ -12,12 +12,10 @@ declare const session: Session;
|
|
|
12
12
|
declare const cache: Cache;
|
|
13
13
|
declare const navigator: import("./drive/navigator").Navigator;
|
|
14
14
|
export { navigator, session, cache, PageRenderer, PageSnapshot, FrameRenderer };
|
|
15
|
-
export { TurboBeforeCacheEvent, TurboBeforeRenderEvent, TurboBeforeVisitEvent, TurboClickEvent,
|
|
15
|
+
export { TurboBeforeCacheEvent, TurboBeforeRenderEvent, TurboBeforeVisitEvent, TurboClickEvent, TurboFrameLoadEvent, TurboFrameRenderEvent, TurboLoadEvent, TurboRenderEvent, TurboVisitEvent, } from "./session";
|
|
16
16
|
export { TurboSubmitStartEvent, TurboSubmitEndEvent } from "./drive/form_submission";
|
|
17
17
|
export { TurboFrameMissingEvent } from "./frames/frame_controller";
|
|
18
|
-
export {
|
|
19
|
-
export { TurboBeforeStreamRenderEvent } from "../elements/stream_element";
|
|
20
|
-
export { StreamActions } from "./streams/stream_actions";
|
|
18
|
+
export { StreamActions, TurboStreamAction, TurboStreamActions } from "./streams/stream_actions";
|
|
21
19
|
export declare function start(): void;
|
|
22
20
|
export declare function registerAdapter(adapter: Adapter): void;
|
|
23
21
|
export declare function visit(location: Locatable, options?: Partial<VisitOptions>): Promise<void>;
|
|
@@ -26,5 +24,5 @@ export declare function disconnectStreamSource(source: StreamSource): void;
|
|
|
26
24
|
export declare function renderStreamMessage(message: StreamMessage | string): void;
|
|
27
25
|
export declare function clearCache(): void;
|
|
28
26
|
export declare function setProgressBarDelay(delay: number): void;
|
|
29
|
-
export declare function setConfirmMethod(confirmMethod: (message: string, element: HTMLFormElement) => Promise<boolean>): void;
|
|
27
|
+
export declare function setConfirmMethod(confirmMethod: (message: string, element: HTMLFormElement, submitter: HTMLElement | undefined) => Promise<boolean>): void;
|
|
30
28
|
export declare function setFormMode(mode: FormMode): void;
|
|
@@ -11,6 +11,7 @@ import { Navigator, NavigatorDelegate } from "./drive/navigator";
|
|
|
11
11
|
import { PageObserver, PageObserverDelegate } from "../observers/page_observer";
|
|
12
12
|
import { ScrollObserver } from "../observers/scroll_observer";
|
|
13
13
|
import { StreamMessage } from "./streams/stream_message";
|
|
14
|
+
import { StreamMessageRenderer } from "./streams/stream_message_renderer";
|
|
14
15
|
import { StreamObserver } from "../observers/stream_observer";
|
|
15
16
|
import { Action, Position, StreamSource } from "./types";
|
|
16
17
|
import { PageView, PageViewDelegate, PageViewRenderOptions } from "./drive/page_view";
|
|
@@ -20,7 +21,6 @@ import { FrameElement } from "../elements/frame_element";
|
|
|
20
21
|
import { FrameViewRenderOptions } from "./frames/frame_view";
|
|
21
22
|
import { FetchResponse } from "../http/fetch_response";
|
|
22
23
|
import { Preloader, PreloaderDelegate } from "./drive/preloader";
|
|
23
|
-
import { FetchRequest } from "../http/fetch_request";
|
|
24
24
|
export declare type FormMode = "on" | "off" | "optin";
|
|
25
25
|
export declare type TimingData = unknown;
|
|
26
26
|
export declare type TurboBeforeCacheEvent = CustomEvent;
|
|
@@ -38,10 +38,6 @@ export declare type TurboFrameLoadEvent = CustomEvent;
|
|
|
38
38
|
export declare type TurboBeforeFrameRenderEvent = CustomEvent<{
|
|
39
39
|
newFrame: FrameElement;
|
|
40
40
|
} & FrameViewRenderOptions>;
|
|
41
|
-
export declare type TurboFetchRequestErrorEvent = CustomEvent<{
|
|
42
|
-
request: FetchRequest;
|
|
43
|
-
error: Error;
|
|
44
|
-
}>;
|
|
45
41
|
export declare type TurboFrameRenderEvent = CustomEvent<{
|
|
46
42
|
fetchResponse: FetchResponse;
|
|
47
43
|
}>;
|
|
@@ -68,6 +64,7 @@ export declare class Session implements FormSubmitObserverDelegate, HistoryDeleg
|
|
|
68
64
|
readonly streamObserver: StreamObserver;
|
|
69
65
|
readonly formLinkClickObserver: FormLinkClickObserver;
|
|
70
66
|
readonly frameRedirector: FrameRedirector;
|
|
67
|
+
readonly streamMessageRenderer: StreamMessageRenderer;
|
|
71
68
|
drive: boolean;
|
|
72
69
|
enabled: boolean;
|
|
73
70
|
progressBarDelay: number;
|
|
@@ -92,7 +89,7 @@ export declare class Session implements FormSubmitObserverDelegate, HistoryDeleg
|
|
|
92
89
|
submittedFormLinkToLocation(): void;
|
|
93
90
|
willFollowLinkToLocation(link: Element, location: URL, event: MouseEvent): boolean;
|
|
94
91
|
followedLinkToLocation(link: Element, location: URL): void;
|
|
95
|
-
|
|
92
|
+
allowsVisitingLocation(location: URL, options?: Partial<VisitOptions>): boolean;
|
|
96
93
|
visitProposedToLocation(location: URL, options: Partial<VisitOptions>): Promise<void>;
|
|
97
94
|
visitStarted(visit: Visit): void;
|
|
98
95
|
visitCompleted(visit: Visit): void;
|
|
@@ -111,17 +108,16 @@ export declare class Session implements FormSubmitObserverDelegate, HistoryDeleg
|
|
|
111
108
|
viewInvalidated(reason: ReloadReason): void;
|
|
112
109
|
frameLoaded(frame: FrameElement): void;
|
|
113
110
|
frameRendered(fetchResponse: FetchResponse, frame: FrameElement): void;
|
|
114
|
-
frameMissing(frame: FrameElement, fetchResponse: FetchResponse): Promise<void>;
|
|
115
111
|
applicationAllowsFollowingLinkToLocation(link: Element, location: URL, ev: MouseEvent): boolean;
|
|
116
|
-
applicationAllowsVisitingLocation(location: URL): boolean;
|
|
112
|
+
applicationAllowsVisitingLocation(location: URL, options?: Partial<VisitOptions>): boolean;
|
|
117
113
|
notifyApplicationAfterClickingLinkToLocation(link: Element, location: URL, event: MouseEvent): CustomEvent<{
|
|
118
114
|
url: string;
|
|
119
115
|
originalEvent: MouseEvent;
|
|
120
116
|
}>;
|
|
121
|
-
notifyApplicationBeforeVisitingLocation(location: URL): CustomEvent<{
|
|
117
|
+
notifyApplicationBeforeVisitingLocation(location: URL, element?: Element): CustomEvent<{
|
|
122
118
|
url: string;
|
|
123
119
|
}>;
|
|
124
|
-
notifyApplicationAfterVisitingLocation(location: URL, action: Action): CustomEvent<{
|
|
120
|
+
notifyApplicationAfterVisitingLocation(location: URL, action: Action, element?: Element): CustomEvent<{
|
|
125
121
|
url: string;
|
|
126
122
|
action: Action;
|
|
127
123
|
}>;
|
|
@@ -7,8 +7,10 @@ export declare class Snapshot<E extends Element = Element> {
|
|
|
7
7
|
getElementForAnchor(anchor: string | undefined): Element | null;
|
|
8
8
|
get isConnected(): boolean;
|
|
9
9
|
get firstAutofocusableElement(): Element | null;
|
|
10
|
-
get permanentElements(): Element
|
|
10
|
+
get permanentElements(): NodeListOf<Element>;
|
|
11
11
|
getPermanentElementById(id: string): Element | null;
|
|
12
12
|
getPermanentElementMapForSnapshot(snapshot: Snapshot): PermanentElementMap;
|
|
13
13
|
}
|
|
14
|
+
export declare function getPermanentElementById(node: ParentNode, id: string): Element | null;
|
|
15
|
+
export declare function queryPermanentElementsAll(node: ParentNode): NodeListOf<Element>;
|
|
14
16
|
export declare type PermanentElementMap = Record<string, [Element, Element]>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { StreamElement } from "../../elements/stream_element";
|
|
2
|
-
export declare
|
|
3
|
-
|
|
2
|
+
export declare type TurboStreamAction = (this: StreamElement) => void;
|
|
3
|
+
export declare type TurboStreamActions = {
|
|
4
|
+
[action: string]: TurboStreamAction;
|
|
4
5
|
};
|
|
6
|
+
export declare const StreamActions: TurboStreamActions;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StreamMessage } from "./stream_message";
|
|
2
|
+
import { BardoDelegate } from "../bardo";
|
|
3
|
+
export declare class StreamMessageRenderer implements BardoDelegate {
|
|
4
|
+
render({ fragment }: StreamMessage): void;
|
|
5
|
+
enteringBardo(currentPermanentElement: Element, newPermanentElement: Element): void;
|
|
6
|
+
leavingBardo(): void;
|
|
7
|
+
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
declare type Render = (currentElement: StreamElement) => Promise<void>;
|
|
1
2
|
export declare type TurboBeforeStreamRenderEvent = CustomEvent<{
|
|
2
3
|
newStream: StreamElement;
|
|
4
|
+
render: Render;
|
|
3
5
|
}>;
|
|
4
6
|
export declare class StreamElement extends HTMLElement {
|
|
7
|
+
static renderElement(newElement: StreamElement): Promise<void>;
|
|
5
8
|
connectedCallback(): Promise<void>;
|
|
6
9
|
private renderPromise?;
|
|
7
10
|
render(): Promise<void>;
|
|
8
11
|
disconnect(): void;
|
|
9
12
|
removeDuplicateTargetChildren(): void;
|
|
10
13
|
get duplicateChildren(): any[];
|
|
11
|
-
get performAction(): (
|
|
14
|
+
get performAction(): import("../core/streams/stream_actions").TurboStreamAction;
|
|
12
15
|
get targetElements(): any[];
|
|
13
16
|
get templateContent(): DocumentFragment;
|
|
14
17
|
get templateElement(): HTMLTemplateElement;
|
|
@@ -21,3 +24,4 @@ export declare class StreamElement extends HTMLElement {
|
|
|
21
24
|
private get targetElementsById();
|
|
22
25
|
private get targetElementsByQuery();
|
|
23
26
|
}
|
|
27
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FetchResponse } from "./fetch_response";
|
|
2
|
-
import { FrameElement } from "../elements/frame_element";
|
|
3
2
|
export declare type TurboBeforeFetchRequestEvent = CustomEvent<{
|
|
4
3
|
fetchOptions: RequestInit;
|
|
5
4
|
url: URL;
|
|
@@ -8,6 +7,10 @@ export declare type TurboBeforeFetchRequestEvent = CustomEvent<{
|
|
|
8
7
|
export declare type TurboBeforeFetchResponseEvent = CustomEvent<{
|
|
9
8
|
fetchResponse: FetchResponse;
|
|
10
9
|
}>;
|
|
10
|
+
export declare type TurboFetchRequestErrorEvent = CustomEvent<{
|
|
11
|
+
request: FetchRequest;
|
|
12
|
+
error: Error;
|
|
13
|
+
}>;
|
|
11
14
|
export interface FetchRequestDelegate {
|
|
12
15
|
referrer?: URL;
|
|
13
16
|
prepareHeadersForRequest?(headers: FetchRequestHeaders, request: FetchRequest): void;
|
|
@@ -41,10 +44,10 @@ export declare class FetchRequest {
|
|
|
41
44
|
readonly headers: FetchRequestHeaders;
|
|
42
45
|
readonly url: URL;
|
|
43
46
|
readonly body?: FetchRequestBody;
|
|
44
|
-
readonly target?:
|
|
47
|
+
readonly target?: Element | null;
|
|
45
48
|
readonly abortController: AbortController;
|
|
46
49
|
private resolveRequestPromise;
|
|
47
|
-
constructor(delegate: FetchRequestDelegate, method: FetchMethod, location: URL, body?: FetchRequestBody, target?:
|
|
50
|
+
constructor(delegate: FetchRequestDelegate, method: FetchMethod, location: URL, body?: FetchRequestBody, target?: Element | null);
|
|
48
51
|
get location(): URL;
|
|
49
52
|
get params(): URLSearchParams;
|
|
50
53
|
get entries(): [string, FormDataEntryValue][];
|
|
@@ -59,4 +62,5 @@ export declare class FetchRequest {
|
|
|
59
62
|
get abortSignal(): AbortSignal;
|
|
60
63
|
acceptResponseType(mimeType: string): void;
|
|
61
64
|
private allowRequestToBeIntercepted;
|
|
65
|
+
private willDelegateErrorHandling;
|
|
62
66
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TurboBeforeFetchRequestEvent, TurboBeforeFetchResponseEvent, TurboFetchRequestErrorEvent, } from "./fetch_request";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { JSHandle, Locator, Page } from "@playwright/test";
|
|
2
|
-
declare type
|
|
3
|
-
declare type
|
|
2
|
+
declare type Target = string | null;
|
|
3
|
+
declare type EventType = string;
|
|
4
|
+
declare type EventDetail = any;
|
|
5
|
+
declare type EventLog = [EventType, EventDetail, Target];
|
|
6
|
+
declare type MutationAttributeName = string;
|
|
7
|
+
declare type MutationAttributeValue = string | null;
|
|
8
|
+
declare type MutationLog = [MutationAttributeName, Target, MutationAttributeValue];
|
|
4
9
|
export declare function attributeForSelector(page: Page, selector: string, attributeName: string): Promise<string | null>;
|
|
5
10
|
export declare function clickWithoutScrolling(page: Page, selector: string, options?: {}): Promise<false | void>;
|
|
6
11
|
export declare function clearLocalStorage(page: Page): Promise<void>;
|
|
@@ -16,6 +21,7 @@ export declare function nextBody(_page: Page, timeout?: number): Promise<void>;
|
|
|
16
21
|
export declare function nextEventNamed(page: Page, eventName: string): Promise<any>;
|
|
17
22
|
export declare function nextEventOnTarget(page: Page, elementId: string, eventName: string): Promise<any>;
|
|
18
23
|
export declare function nextAttributeMutationNamed(page: Page, elementId: string, attributeName: string): Promise<string | null>;
|
|
24
|
+
export declare function noNextAttributeMutationNamed(page: Page, elementId: string, attributeName: string): Promise<boolean>;
|
|
19
25
|
export declare function noNextEventNamed(page: Page, eventName: string): Promise<boolean>;
|
|
20
26
|
export declare function noNextEventOnTarget(page: Page, elementId: string, eventName: string): Promise<boolean>;
|
|
21
27
|
export declare function outerHTMLForSelector(page: Page, selector: string): Promise<string>;
|
package/dist/types/util.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare function parseHTMLDocument(html?: string): Document;
|
|
|
14
14
|
export declare function unindent(strings: TemplateStringsArray, ...values: any[]): string;
|
|
15
15
|
export declare function uuid(): string;
|
|
16
16
|
export declare function getAttribute(attributeName: string, ...elements: (Element | undefined)[]): string | null;
|
|
17
|
+
export declare function hasAttribute(attributeName: string, ...elements: (Element | undefined)[]): boolean;
|
|
17
18
|
export declare function markAsBusy(...elements: Element[]): void;
|
|
18
19
|
export declare function clearBusyState(...elements: Element[]): void;
|
|
19
20
|
export declare function waitForLoad(element: HTMLLinkElement, timeoutInMilliseconds?: number): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hotwired/turbo",
|
|
3
|
-
"version": "7.2.0-
|
|
3
|
+
"version": "7.2.0-rc.2",
|
|
4
4
|
"description": "The speed of a single-page web application without having to write any JavaScript",
|
|
5
5
|
"module": "dist/turbo.es2017-esm.js",
|
|
6
6
|
"main": "dist/turbo.es2017-umd.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@playwright/test": "^1.22.2",
|
|
39
39
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
40
|
-
"@rollup/plugin-typescript": "8.
|
|
40
|
+
"@rollup/plugin-typescript": "^8.5.0",
|
|
41
41
|
"@types/multer": "^1.4.5",
|
|
42
42
|
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
43
43
|
"@typescript-eslint/parser": "^5.20.0",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"multer": "^1.4.2",
|
|
51
51
|
"prettier": "2.6.2",
|
|
52
52
|
"rollup": "^2.35.1",
|
|
53
|
-
"tslib": "^2.0
|
|
54
|
-
"typescript": "^4.
|
|
53
|
+
"tslib": "^2.4.0",
|
|
54
|
+
"typescript": "^4.8.2"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"clean": "rm -fr dist",
|