@hotwired/turbo 7.0.0-beta.3 → 7.0.0-beta.4

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.
Files changed (48) hide show
  1. package/dist/turbo.es2017-esm.js +647 -574
  2. package/dist/turbo.es2017-esm.js.map +1 -1
  3. package/dist/turbo.es2017-umd.js +647 -574
  4. package/dist/turbo.es2017-umd.js.map +1 -1
  5. package/dist/turbo.es5-umd.js +1153 -843
  6. package/dist/turbo.es5-umd.js.map +1 -1
  7. package/dist/types/core/drive/error_renderer.d.ts +7 -11
  8. package/dist/types/core/drive/form_submission.d.ts +11 -3
  9. package/dist/types/core/drive/head_snapshot.d.ts +21 -0
  10. package/dist/types/core/drive/history.d.ts +5 -6
  11. package/dist/types/core/drive/navigator.d.ts +7 -7
  12. package/dist/types/core/drive/page_renderer.d.ts +26 -0
  13. package/dist/types/core/drive/page_snapshot.d.ts +17 -0
  14. package/dist/types/core/drive/page_view.d.ts +21 -0
  15. package/dist/types/core/drive/snapshot_cache.d.ts +8 -9
  16. package/dist/types/core/drive/visit.d.ts +13 -15
  17. package/dist/types/core/frames/frame_controller.d.ts +11 -10
  18. package/dist/types/core/frames/frame_renderer.d.ts +8 -0
  19. package/dist/types/core/frames/frame_view.d.ts +7 -0
  20. package/dist/types/core/index.d.ts +1 -1
  21. package/dist/types/core/native/adapter.d.ts +1 -2
  22. package/dist/types/core/native/browser_adapter.d.ts +1 -2
  23. package/dist/types/core/renderer.d.ts +26 -0
  24. package/dist/types/core/session.d.ts +23 -21
  25. package/dist/types/core/snapshot.d.ts +11 -0
  26. package/dist/types/core/streams/stream_message.d.ts +1 -0
  27. package/dist/types/core/url.d.ts +7 -0
  28. package/dist/types/core/view.d.ts +27 -0
  29. package/dist/types/http/fetch_request.d.ts +8 -11
  30. package/dist/types/http/fetch_response.d.ts +1 -2
  31. package/dist/types/observers/link_click_observer.d.ts +3 -4
  32. package/dist/types/observers/stream_observer.d.ts +0 -1
  33. package/dist/types/tests/functional/form_submission_tests.d.ts +11 -3
  34. package/dist/types/tests/functional/frame_tests.d.ts +4 -0
  35. package/dist/types/tests/functional/navigation_tests.d.ts +1 -0
  36. package/dist/types/tests/functional/rendering_tests.d.ts +2 -0
  37. package/dist/types/tests/functional/stream_tests.d.ts +0 -2
  38. package/dist/types/tests/helpers/functional_test_case.d.ts +3 -0
  39. package/dist/types/tests/unit/deprecated_adapter_support_test.d.ts +21 -0
  40. package/dist/types/tests/unit/index.d.ts +1 -0
  41. package/dist/types/util.d.ts +2 -0
  42. package/package.json +1 -1
  43. package/dist/types/core/drive/head_details.d.ts +0 -22
  44. package/dist/types/core/drive/renderer.d.ts +0 -13
  45. package/dist/types/core/drive/snapshot.d.ts +0 -24
  46. package/dist/types/core/drive/snapshot_renderer.d.ts +0 -43
  47. package/dist/types/core/drive/view.d.ts +0 -34
  48. package/dist/types/core/location.d.ts +0 -22
@@ -1,9 +1,6 @@
1
1
  import { FetchResponse } from "./fetch_response";
2
- import { Location } from "../core/location";
3
2
  export interface FetchRequestDelegate {
4
- additionalHeadersForRequest?(request: FetchRequest): {
5
- [header: string]: string;
6
- };
3
+ prepareHeadersForRequest?(headers: FetchRequestHeaders, request: FetchRequest): void;
7
4
  requestStarted(request: FetchRequest): void;
8
5
  requestPreventedHandlingResponse(request: FetchRequest, response: FetchResponse): void;
9
6
  requestSucceededWithResponse(request: FetchRequest, response: FetchResponse): void;
@@ -19,7 +16,7 @@ export declare enum FetchMethod {
19
16
  delete = 4
20
17
  }
21
18
  export declare function fetchMethodFromString(method: string): FetchMethod | undefined;
22
- export declare type FetchRequestBody = FormData;
19
+ export declare type FetchRequestBody = FormData | URLSearchParams;
23
20
  export declare type FetchRequestHeaders = {
24
21
  [header: string]: string;
25
22
  };
@@ -31,11 +28,11 @@ export interface FetchRequestOptions {
31
28
  export declare class FetchRequest {
32
29
  readonly delegate: FetchRequestDelegate;
33
30
  readonly method: FetchMethod;
34
- readonly location: Location;
31
+ readonly url: URL;
35
32
  readonly body?: FetchRequestBody;
36
33
  readonly abortController: AbortController;
37
- constructor(delegate: FetchRequestDelegate, method: FetchMethod, location: Location, body?: FetchRequestBody);
38
- get url(): string;
34
+ constructor(delegate: FetchRequestDelegate, method: FetchMethod, location: URL, body?: FetchRequestBody);
35
+ get location(): URL;
39
36
  get params(): URLSearchParams;
40
37
  get entries(): [string, FormDataEntryValue][];
41
38
  cancel(): void;
@@ -46,8 +43,8 @@ export declare class FetchRequest {
46
43
  get headers(): {
47
44
  Accept: string;
48
45
  };
49
- get additionalHeaders(): {
50
- [header: string]: string;
51
- };
52
46
  get abortSignal(): AbortSignal;
47
+ get defaultHeaders(): {
48
+ Accept: string;
49
+ };
53
50
  }
@@ -1,4 +1,3 @@
1
- import { Location } from "../core/location";
2
1
  export declare class FetchResponse {
3
2
  readonly response: Response;
4
3
  constructor(response: Response);
@@ -7,7 +6,7 @@ export declare class FetchResponse {
7
6
  get clientError(): boolean;
8
7
  get serverError(): boolean;
9
8
  get redirected(): boolean;
10
- get location(): Location;
9
+ get location(): URL;
11
10
  get isHTML(): "" | RegExpMatchArray | null;
12
11
  get statusCode(): number;
13
12
  get contentType(): string | null;
@@ -1,7 +1,6 @@
1
- import { Location } from "../core/location";
2
1
  export interface LinkClickObserverDelegate {
3
- willFollowLinkToLocation(link: Element, location: Location): boolean;
4
- followedLinkToLocation(link: Element, location: Location): void;
2
+ willFollowLinkToLocation(link: Element, location: URL): boolean;
3
+ followedLinkToLocation(link: Element, location: URL): void;
5
4
  }
6
5
  export declare class LinkClickObserver {
7
6
  readonly delegate: LinkClickObserverDelegate;
@@ -13,5 +12,5 @@ export declare class LinkClickObserver {
13
12
  clickBubbled: (event: MouseEvent) => void;
14
13
  clickEventIsSignificant(event: MouseEvent): boolean;
15
14
  findLinkFromClickTarget(target: EventTarget | null): Element | null | undefined;
16
- getLocationForLink(link: Element): Location;
15
+ getLocationForLink(link: Element): URL;
17
16
  }
@@ -14,7 +14,6 @@ export declare class StreamObserver {
14
14
  connectStreamSource(source: StreamSource): void;
15
15
  disconnectStreamSource(source: StreamSource): void;
16
16
  streamSourceIsConnected(source: StreamSource): boolean;
17
- prepareFetchRequest: EventListener;
18
17
  inspectFetchResponse: EventListener;
19
18
  receiveMessageEvent: (event: MessageEvent) => void;
20
19
  receiveMessageResponse(response: FetchResponse): Promise<void>;
@@ -2,11 +2,19 @@ import { TurboDriveTestCase } from "../helpers/turbo_drive_test_case";
2
2
  export declare class FormSubmissionTests extends TurboDriveTestCase {
3
3
  setup(): Promise<void>;
4
4
  "test standard form submission with redirect response"(): Promise<void>;
5
+ "test standard GET form submission"(): Promise<void>;
6
+ "test standard GET form submission appending keys"(): Promise<void>;
5
7
  "test standard form submission with empty created response"(): Promise<void>;
6
8
  "test standard form submission with empty no-content response"(): Promise<void>;
9
+ "test standard POST form submission with multipart/form-data enctype"(): Promise<void>;
10
+ "test standard GET form submission ignores enctype"(): Promise<void>;
11
+ "test standard POST form submission without an enctype"(): Promise<void>;
12
+ "test no-action form submission with single parameter"(): Promise<void>;
13
+ "test no-action form submission with multiple parameters"(): Promise<void>;
7
14
  "test invalid form submission with unprocessable entity status"(): Promise<void>;
8
15
  "test invalid form submission with server error status"(): Promise<void>;
9
16
  "test submitter form submission reads button attributes"(): Promise<void>;
17
+ "test submitter POST form submission with multipart/form-data formenctype"(): Promise<void>;
10
18
  "test frame form submission with redirect response"(): Promise<void>;
11
19
  "test frame form submission with empty created response"(): Promise<void>;
12
20
  "test frame form submission with empty no-content response"(): Promise<void>;
@@ -15,9 +23,9 @@ export declare class FormSubmissionTests extends TurboDriveTestCase {
15
23
  "test frame form submission with stream response"(): Promise<void>;
16
24
  "test frame form submission with HTTP verb other than GET or POST"(): Promise<void>;
17
25
  "test form submission with Turbo disabled on the form"(): Promise<void>;
18
- "test form submission with Turbo disabled on the submitter"(): Promise<void>;
26
+ "test form submission with [data-turbo=false] on the submitter"(): Promise<void>;
19
27
  "test form submission skipped within method=dialog"(): Promise<void>;
20
28
  "test form submission skipped with submitter formmethod=dialog"(): Promise<void>;
21
- listenForFormSubmissions(): void;
22
- get turboFormSubmitted(): Promise<boolean>;
29
+ "test form submission targets disabled frame"(): Promise<void>;
30
+ get formSubmitted(): Promise<boolean>;
23
31
  }
@@ -2,4 +2,8 @@ import { FunctionalTestCase } from "../helpers/functional_test_case";
2
2
  export declare class FrameTests extends FunctionalTestCase {
3
3
  setup(): Promise<void>;
4
4
  "test following a link to a page without a matching frame results in an empty frame"(): Promise<void>;
5
+ "test following a link within a frame with a target set navigates the target frame"(): Promise<void>;
6
+ "test following a link within a descendant frame whose ancestor declares a target set navigates the descendant frame"(): Promise<void>;
7
+ "test following a link that declares data-turbo-frame within a frame whose ancestor respects the override"(): Promise<void>;
8
+ "test following a link within a frame with target=_top navigates the page"(): Promise<void>;
5
9
  }
@@ -16,4 +16,5 @@ export declare class NavigationTests extends TurboDriveTestCase {
16
16
  "test following a cross-origin link inside an SVG element"(): Promise<void>;
17
17
  "test clicking the back button"(): Promise<void>;
18
18
  "test clicking the forward button"(): Promise<void>;
19
+ "test link targeting a disabled turbo-frame navigates the page"(): Promise<void>;
19
20
  }
@@ -12,6 +12,8 @@ export declare class RenderingTests extends TurboDriveTestCase {
12
12
  "test evaluates body script elements on each render"(): Promise<void>;
13
13
  "test does not evaluate data-turbo-eval=false scripts"(): Promise<void>;
14
14
  "test preserves permanent elements"(): Promise<void>;
15
+ "test preserves permanent elements within turbo-frames"(): Promise<void>;
16
+ "test preserves permanent elements within turbo-frames rendered without layouts"(): Promise<void>;
15
17
  "test before-cache event"(): Promise<void>;
16
18
  "test mutation record as before-cache notification"(): Promise<void>;
17
19
  "test error pages"(): Promise<void>;
@@ -2,6 +2,4 @@ import { FunctionalTestCase } from "../helpers/functional_test_case";
2
2
  export declare class StreamTests extends FunctionalTestCase {
3
3
  setup(): Promise<void>;
4
4
  "test receiving a stream message"(): Promise<void>;
5
- createMessage(content: string): Promise<void>;
6
- post(path: string, params?: any): Promise<void>;
7
5
  }
@@ -24,5 +24,8 @@ export declare class FunctionalTestCase extends InternTestCase {
24
24
  get location(): Promise<string>;
25
25
  get origin(): Promise<string>;
26
26
  get pathname(): Promise<string>;
27
+ get searchParams(): Promise<URLSearchParams>;
28
+ getSearchParam(key: string): Promise<string>;
29
+ getAllSearchParams(key: string): Promise<string[]>;
27
30
  get hash(): Promise<string>;
28
31
  }
@@ -0,0 +1,21 @@
1
+ import { VisitOptions, Visit } from "../../core/drive/visit";
2
+ import { Adapter } from "../../core/native/adapter";
3
+ import { DOMTestCase } from "../helpers/dom_test_case";
4
+ export declare class DeprecatedAdapterSupportTest extends DOMTestCase implements Adapter {
5
+ locations: any[];
6
+ originalAdapter: Adapter;
7
+ setup(): Promise<void>;
8
+ teardown(): Promise<void>;
9
+ "test visit proposal location includes deprecated absoluteURL property"(): Promise<void>;
10
+ "test visit start location includes deprecated absoluteURL property"(): Promise<void>;
11
+ visitProposedToLocation(location: URL, options?: Partial<VisitOptions>): void;
12
+ visitStarted(visit: Visit): void;
13
+ visitCompleted(visit: Visit): void;
14
+ visitFailed(visit: Visit): void;
15
+ visitRequestStarted(visit: Visit): void;
16
+ visitRequestCompleted(visit: Visit): void;
17
+ visitRequestFailedWithStatusCode(visit: Visit, statusCode: number): void;
18
+ visitRequestFinished(visit: Visit): void;
19
+ visitRendered(visit: Visit): void;
20
+ pageInvalidated(): void;
21
+ }
@@ -1 +1,2 @@
1
+ export * from "./deprecated_adapter_support_test";
1
2
  export * from "./stream_element_tests";
@@ -5,6 +5,8 @@ export declare type DispatchOptions = {
5
5
  };
6
6
  export declare function dispatch(eventName: string, { target, cancelable, detail }?: Partial<DispatchOptions>): CustomEvent<any>;
7
7
  export declare function nextAnimationFrame(): Promise<void>;
8
+ export declare function nextEventLoopTick(): Promise<void>;
8
9
  export declare function nextMicrotask(): Promise<void>;
10
+ export declare function parseHTMLDocument(html?: string): Document;
9
11
  export declare function unindent(strings: TemplateStringsArray, ...values: any[]): string;
10
12
  export declare function uuid(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotwired/turbo",
3
- "version": "7.0.0-beta.3",
3
+ "version": "7.0.0-beta.4",
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.es5-umd.js",
@@ -1,22 +0,0 @@
1
- declare type ElementDetailMap = {
2
- [outerHTML: string]: ElementDetails;
3
- };
4
- declare type ElementDetails = {
5
- type?: ElementType;
6
- tracked: boolean;
7
- elements: Element[];
8
- };
9
- declare type ElementType = "script" | "stylesheet";
10
- export declare class HeadDetails {
11
- readonly detailsByOuterHTML: ElementDetailMap;
12
- static fromHeadElement(headElement: HTMLHeadElement | null): HeadDetails;
13
- constructor(children: Element[]);
14
- getTrackedElementSignature(): string;
15
- getScriptElementsNotInDetails(headDetails: HeadDetails): Element[];
16
- getStylesheetElementsNotInDetails(headDetails: HeadDetails): Element[];
17
- getElementsMatchingTypeNotInDetails(matchedType: ElementType, headDetails: HeadDetails): Element[];
18
- getProvisionalElements(): Element[];
19
- getMetaValue(name: string): string | null;
20
- findMetaElementByName(name: string): Element | undefined;
21
- }
22
- export {};
@@ -1,13 +0,0 @@
1
- export declare type RenderCallback = () => void;
2
- export interface RenderDelegate {
3
- viewWillRender(newBody: HTMLBodyElement): void;
4
- viewRendered(newBody: HTMLBodyElement): void;
5
- viewInvalidated(): void;
6
- }
7
- export declare abstract class Renderer {
8
- abstract delegate: RenderDelegate;
9
- abstract newBody: HTMLBodyElement;
10
- renderView(callback: RenderCallback): void;
11
- invalidateView(): void;
12
- createScriptElement(element: Element): Element;
13
- }
@@ -1,24 +0,0 @@
1
- import { HeadDetails } from "./head_details";
2
- import { Location } from "../location";
3
- export declare class Snapshot {
4
- static wrap(value: Snapshot | string | HTMLHtmlElement): Snapshot;
5
- static fromHTMLString(html: string): Snapshot;
6
- static fromHTMLElement(htmlElement: HTMLHtmlElement): Snapshot;
7
- readonly headDetails: HeadDetails;
8
- readonly bodyElement: HTMLBodyElement;
9
- constructor(headDetails: HeadDetails, bodyElement: HTMLBodyElement);
10
- clone(): Snapshot;
11
- getRootLocation(): Location;
12
- getCacheControlValue(): string | undefined;
13
- getElementForAnchor(anchor: string): Element | null;
14
- getPermanentElements(): Element[];
15
- getPermanentElementById(id: string): Element | null;
16
- getPermanentElementsPresentInSnapshot(snapshot: Snapshot): Element[];
17
- findFirstAutofocusableElement(): Element | null;
18
- hasAnchor(anchor: string): boolean;
19
- isPreviewable(): boolean;
20
- isCacheable(): boolean;
21
- isVisitable(): boolean;
22
- getSetting(name: string): string | undefined;
23
- getSetting(name: string, defaultValue: string): string;
24
- }
@@ -1,43 +0,0 @@
1
- import { HeadDetails } from "./head_details";
2
- import { RenderCallback, RenderDelegate, Renderer } from "./renderer";
3
- import { Snapshot } from "./snapshot";
4
- export { RenderCallback, RenderDelegate } from "./renderer";
5
- export declare type PermanentElement = Element & {
6
- id: string;
7
- };
8
- export declare type Placeholder = {
9
- element: Element;
10
- permanentElement: PermanentElement;
11
- };
12
- export declare class SnapshotRenderer extends Renderer {
13
- readonly delegate: RenderDelegate;
14
- readonly currentSnapshot: Snapshot;
15
- readonly currentHeadDetails: HeadDetails;
16
- readonly newSnapshot: Snapshot;
17
- readonly newHeadDetails: HeadDetails;
18
- readonly newBody: HTMLBodyElement;
19
- readonly isPreview: boolean;
20
- static render(delegate: RenderDelegate, callback: RenderCallback, currentSnapshot: Snapshot, newSnapshot: Snapshot, isPreview: boolean): void;
21
- constructor(delegate: RenderDelegate, currentSnapshot: Snapshot, newSnapshot: Snapshot, isPreview: boolean);
22
- render(callback: RenderCallback): void;
23
- mergeHead(): void;
24
- replaceBody(): void;
25
- shouldRender(): boolean;
26
- trackedElementsAreIdentical(): boolean;
27
- copyNewHeadStylesheetElements(): void;
28
- copyNewHeadScriptElements(): void;
29
- removeCurrentHeadProvisionalElements(): void;
30
- copyNewHeadProvisionalElements(): void;
31
- relocateCurrentBodyPermanentElements(): Placeholder[];
32
- replacePlaceholderElementsWithClonedPermanentElements(placeholders: Placeholder[]): void;
33
- activateNewBody(): void;
34
- activateNewBodyScriptElements(): void;
35
- assignNewBody(): void;
36
- focusFirstAutofocusableElement(): void;
37
- getNewHeadStylesheetElements(): Element[];
38
- getNewHeadScriptElements(): Element[];
39
- getCurrentHeadProvisionalElements(): Element[];
40
- getNewHeadProvisionalElements(): Element[];
41
- getCurrentBodyPermanentElements(): PermanentElement[];
42
- getNewBodyScriptElements(): HTMLScriptElement[];
43
- }
@@ -1,34 +0,0 @@
1
- import { Location } from "../location";
2
- import { Snapshot } from "./snapshot";
3
- import { SnapshotCache } from "./snapshot_cache";
4
- import { RenderCallback, RenderDelegate } from "./snapshot_renderer";
5
- import { Position } from "../types";
6
- export declare type RenderOptions = {
7
- snapshot: Snapshot;
8
- error: string;
9
- isPreview: boolean;
10
- };
11
- export declare type ViewDelegate = RenderDelegate & {
12
- viewWillCacheSnapshot(): void;
13
- };
14
- export declare class View {
15
- readonly delegate: ViewDelegate;
16
- readonly htmlElement: HTMLHtmlElement;
17
- readonly snapshotCache: SnapshotCache;
18
- lastRenderedLocation?: Location;
19
- constructor(delegate: ViewDelegate);
20
- getRootLocation(): Location;
21
- getElementForAnchor(anchor: string): Element | null;
22
- getSnapshot(): Snapshot;
23
- clearSnapshotCache(): void;
24
- shouldCacheSnapshot(): boolean;
25
- cacheSnapshot(): Promise<void>;
26
- getCachedSnapshotForLocation(location: Location): Snapshot | undefined;
27
- render({ snapshot, error, isPreview }: Partial<RenderOptions>, callback: RenderCallback): void;
28
- scrollToAnchor(anchor: string): void;
29
- scrollToElement(element: Element): void;
30
- scrollToPosition({ x, y }: Position): void;
31
- markAsPreview(isPreview: boolean | undefined): void;
32
- renderSnapshot(snapshot: Snapshot, isPreview: boolean | undefined, callback: RenderCallback): void;
33
- renderError(error: string | undefined, callback: RenderCallback): void;
34
- }
@@ -1,22 +0,0 @@
1
- export declare type Locatable = Location | string;
2
- export declare class Location {
3
- static get currentLocation(): Location;
4
- static wrap(locatable: Locatable): Location;
5
- static wrap(locatable?: Locatable | null): Location | undefined;
6
- readonly absoluteURL: string;
7
- readonly requestURL: string;
8
- readonly anchor?: string;
9
- constructor(url: string);
10
- getOrigin(): string;
11
- getPath(): string;
12
- getPathComponents(): string[];
13
- getLastPathComponent(): string;
14
- getExtension(): string;
15
- isHTML(): boolean;
16
- isPrefixedBy(location: Location): boolean;
17
- isEqualTo(location?: Location): boolean | undefined;
18
- toCacheKey(): string;
19
- toJSON(): string;
20
- toString(): string;
21
- valueOf(): string;
22
- }