swup 4.2.0 → 4.3.1
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/dist/Swup.cjs +1 -1
- package/dist/Swup.cjs.map +1 -1
- package/dist/Swup.modern.js +1 -1
- package/dist/Swup.modern.js.map +1 -1
- package/dist/Swup.module.js +1 -1
- package/dist/Swup.module.js.map +1 -1
- package/dist/Swup.umd.js +1 -1
- package/dist/Swup.umd.js.map +1 -1
- package/dist/types/Swup.d.ts +119 -119
- package/dist/types/__test__/index.test.d.ts +1 -1
- package/dist/types/config/version.d.ts +5 -5
- package/dist/types/helpers/Location.d.ts +24 -24
- package/dist/types/helpers/__test__/matchPath.test.d.ts +1 -1
- package/dist/types/helpers/classify.d.ts +2 -2
- package/dist/types/helpers/createHistoryRecord.d.ts +9 -2
- package/dist/types/helpers/delegateEvent.d.ts +7 -7
- package/dist/types/helpers/getCurrentUrl.d.ts +4 -4
- package/dist/types/helpers/matchPath.d.ts +4 -4
- package/dist/types/helpers/updateHistoryRecord.d.ts +2 -2
- package/dist/types/helpers.d.ts +7 -7
- package/dist/types/index.d.ts +14 -14
- package/dist/types/modules/Cache.d.ts +34 -34
- package/dist/types/modules/Classes.d.ts +13 -13
- package/dist/types/modules/Hooks.d.ts +268 -250
- package/dist/types/modules/Visit.d.ts +80 -77
- package/dist/types/modules/__test__/cache.test.d.ts +1 -1
- package/dist/types/modules/__test__/{delegateEvent.d.ts → delegateEvent.test.d.ts} +1 -1
- package/dist/types/modules/__test__/hooks.test.d.ts +1 -1
- package/dist/types/modules/__test__/plugins.test.d.ts +1 -1
- package/dist/types/modules/__test__/replaceContent.test.d.ts +1 -1
- package/dist/types/modules/animatePageIn.d.ts +6 -6
- package/dist/types/modules/animatePageOut.d.ts +6 -6
- package/dist/types/modules/awaitAnimations.d.ts +19 -19
- package/dist/types/modules/fetchPage.d.ts +27 -29
- package/dist/types/modules/getAnchorElement.d.ts +9 -9
- package/dist/types/modules/navigate.d.ts +41 -35
- package/dist/types/modules/plugins.d.ts +26 -26
- package/dist/types/modules/renderPage.d.ts +7 -7
- package/dist/types/modules/replaceContent.d.ts +13 -13
- package/dist/types/modules/resolveUrl.d.ts +14 -14
- package/dist/types/modules/scrollToContent.d.ts +6 -6
- package/dist/types/utils/index.d.ts +20 -20
- package/dist/types/utils.d.ts +1 -1
- package/package.json +9 -3
- package/src/Swup.ts +26 -17
- package/src/config/version.ts +1 -2
- package/src/helpers/createHistoryRecord.ts +9 -1
- package/src/helpers/matchPath.ts +1 -1
- package/src/helpers/updateHistoryRecord.ts +4 -2
- package/src/modules/Cache.ts +2 -2
- package/src/modules/Classes.ts +1 -1
- package/src/modules/Hooks.ts +91 -39
- package/src/modules/Visit.ts +19 -21
- package/src/modules/__test__/cache.test.ts +3 -3
- package/src/modules/__test__/hooks.test.ts +12 -13
- package/src/modules/animatePageIn.ts +1 -1
- package/src/modules/animatePageOut.ts +2 -2
- package/src/modules/awaitAnimations.ts +1 -1
- package/src/modules/fetchPage.ts +7 -5
- package/src/modules/navigate.ts +23 -4
- package/src/modules/plugins.ts +3 -3
- package/src/modules/renderPage.ts +1 -5
- package/src/modules/replaceContent.ts +13 -0
- package/src/modules/scrollToContent.ts +1 -1
- package/src/utils/index.ts +5 -4
- /package/src/modules/__test__/{delegateEvent.ts → delegateEvent.test.ts} +0 -0
|
@@ -1,77 +1,80 @@
|
|
|
1
|
-
import Swup, { Options } from '../Swup.js';
|
|
2
|
-
import { HistoryAction, HistoryDirection } from './navigate.js';
|
|
3
|
-
/** An object holding details about the current visit. */
|
|
4
|
-
export interface Visit {
|
|
5
|
-
/** The previous page, about to leave */
|
|
6
|
-
from: VisitFrom;
|
|
7
|
-
/** The next page, about to enter */
|
|
8
|
-
to: VisitTo;
|
|
9
|
-
/** The content containers, about to be replaced */
|
|
10
|
-
containers: Options['containers'];
|
|
11
|
-
/** Information about animated page transitions */
|
|
12
|
-
animation: VisitAnimation;
|
|
13
|
-
/** What triggered this visit */
|
|
14
|
-
trigger: VisitTrigger;
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/** The
|
|
28
|
-
|
|
29
|
-
/** The
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/** Whether
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/** DOM
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/** Whether this visit
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
export interface
|
|
65
|
-
to:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
import Swup, { Options } from '../Swup.js';
|
|
2
|
+
import { HistoryAction, HistoryDirection } from './navigate.js';
|
|
3
|
+
/** An object holding details about the current visit. */
|
|
4
|
+
export interface Visit {
|
|
5
|
+
/** The previous page, about to leave */
|
|
6
|
+
from: VisitFrom;
|
|
7
|
+
/** The next page, about to enter */
|
|
8
|
+
to: VisitTo;
|
|
9
|
+
/** The content containers, about to be replaced */
|
|
10
|
+
containers: Options['containers'];
|
|
11
|
+
/** Information about animated page transitions */
|
|
12
|
+
animation: VisitAnimation;
|
|
13
|
+
/** What triggered this visit */
|
|
14
|
+
trigger: VisitTrigger;
|
|
15
|
+
/** Cache behavior for this visit */
|
|
16
|
+
cache: VisitCache;
|
|
17
|
+
/** Browser history behavior on this visit */
|
|
18
|
+
history: VisitHistory;
|
|
19
|
+
/** Scroll behavior on this visit */
|
|
20
|
+
scroll: VisitScroll;
|
|
21
|
+
}
|
|
22
|
+
export interface VisitFrom {
|
|
23
|
+
/** The URL of the previous page */
|
|
24
|
+
url: string;
|
|
25
|
+
}
|
|
26
|
+
export interface VisitTo {
|
|
27
|
+
/** The URL of the next page */
|
|
28
|
+
url: string;
|
|
29
|
+
/** The hash of the next page */
|
|
30
|
+
hash?: string;
|
|
31
|
+
/** The HTML content of the next page */
|
|
32
|
+
html?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface VisitAnimation {
|
|
35
|
+
/** Whether this visit is animated. Default: `true` */
|
|
36
|
+
animate: boolean;
|
|
37
|
+
/** Whether to wait for the next page to load before starting the animation. Default: `false` */
|
|
38
|
+
wait: boolean;
|
|
39
|
+
/** Name of a custom animation to run. */
|
|
40
|
+
name?: string;
|
|
41
|
+
/** Elements on which to add animation classes. Default: `html` element */
|
|
42
|
+
scope: 'html' | 'containers' | string[];
|
|
43
|
+
/** Selector for detecting animation timing. Default: `[class*="transition-"]` */
|
|
44
|
+
selector: Options['animationSelector'];
|
|
45
|
+
}
|
|
46
|
+
export interface VisitScroll {
|
|
47
|
+
/** Whether to reset the scroll position after the visit. Default: `true` */
|
|
48
|
+
reset: boolean;
|
|
49
|
+
/** Anchor element to scroll to on the next page. */
|
|
50
|
+
target?: string | false;
|
|
51
|
+
}
|
|
52
|
+
export interface VisitTrigger {
|
|
53
|
+
/** DOM element that triggered this visit. */
|
|
54
|
+
el?: Element;
|
|
55
|
+
/** DOM event that triggered this visit. */
|
|
56
|
+
event?: Event;
|
|
57
|
+
}
|
|
58
|
+
export interface VisitCache {
|
|
59
|
+
/** Whether this visit will try to load the requested page from cache. */
|
|
60
|
+
read: boolean;
|
|
61
|
+
/** Whether this visit will save the loaded page in cache. */
|
|
62
|
+
write: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface VisitHistory {
|
|
65
|
+
/** History action to perform: `push` for creating a new history entry, `replace` for replacing the current entry. Default: `push` */
|
|
66
|
+
action: HistoryAction;
|
|
67
|
+
/** Whether this visit was triggered by a browser history navigation. */
|
|
68
|
+
popstate: boolean;
|
|
69
|
+
/** The direction of travel in case of a browser history navigation: backward or forward. */
|
|
70
|
+
direction: HistoryDirection | undefined;
|
|
71
|
+
}
|
|
72
|
+
export interface VisitInitOptions {
|
|
73
|
+
to: string;
|
|
74
|
+
from?: string;
|
|
75
|
+
hash?: string;
|
|
76
|
+
el?: Element;
|
|
77
|
+
event?: Event;
|
|
78
|
+
}
|
|
79
|
+
/** Create a new visit object. */
|
|
80
|
+
export declare function createVisit(this: Swup, { to, from, hash, el, event }: VisitInitOptions): Visit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Swup from '../Swup.js';
|
|
2
|
-
/**
|
|
3
|
-
* Perform the in/enter animation of the next page.
|
|
4
|
-
* @returns Promise<void>
|
|
5
|
-
*/
|
|
6
|
-
export declare const animatePageIn: (this: Swup) => Promise<void>;
|
|
1
|
+
import Swup from '../Swup.js';
|
|
2
|
+
/**
|
|
3
|
+
* Perform the in/enter animation of the next page.
|
|
4
|
+
* @returns Promise<void>
|
|
5
|
+
*/
|
|
6
|
+
export declare const animatePageIn: (this: Swup) => Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Swup from '../Swup.js';
|
|
2
|
-
/**
|
|
3
|
-
* Perform the out/leave animation of the current page.
|
|
4
|
-
* @returns Promise<void>
|
|
5
|
-
*/
|
|
6
|
-
export declare const animatePageOut: (this: Swup) => Promise<void>;
|
|
1
|
+
import Swup from '../Swup.js';
|
|
2
|
+
/**
|
|
3
|
+
* Perform the out/leave animation of the current page.
|
|
4
|
+
* @returns Promise<void>
|
|
5
|
+
*/
|
|
6
|
+
export declare const animatePageOut: (this: Swup) => Promise<void>;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import Swup, { Options } from '../Swup.js';
|
|
2
|
-
declare const TRANSITION = "transition";
|
|
3
|
-
declare const ANIMATION = "animation";
|
|
4
|
-
type AnimationTypes = typeof TRANSITION | typeof ANIMATION;
|
|
5
|
-
export type AnimationDirection = 'in' | 'out';
|
|
6
|
-
/**
|
|
7
|
-
* Return a Promise that resolves when all CSS animations and transitions
|
|
8
|
-
* are done on the page. Filters by selector or takes elements directly.
|
|
9
|
-
*/
|
|
10
|
-
export declare function awaitAnimations(this: Swup, { elements, selector }: {
|
|
11
|
-
selector: Options['animationSelector'];
|
|
12
|
-
elements?: NodeListOf<HTMLElement> | HTMLElement[];
|
|
13
|
-
}): Promise<void>;
|
|
14
|
-
export declare function getTransitionInfo(element: Element, expectedType?: AnimationTypes): {
|
|
15
|
-
type: AnimationTypes | null;
|
|
16
|
-
timeout: number;
|
|
17
|
-
propCount: number;
|
|
18
|
-
};
|
|
19
|
-
export {};
|
|
1
|
+
import Swup, { Options } from '../Swup.js';
|
|
2
|
+
declare const TRANSITION = "transition";
|
|
3
|
+
declare const ANIMATION = "animation";
|
|
4
|
+
type AnimationTypes = typeof TRANSITION | typeof ANIMATION;
|
|
5
|
+
export type AnimationDirection = 'in' | 'out';
|
|
6
|
+
/**
|
|
7
|
+
* Return a Promise that resolves when all CSS animations and transitions
|
|
8
|
+
* are done on the page. Filters by selector or takes elements directly.
|
|
9
|
+
*/
|
|
10
|
+
export declare function awaitAnimations(this: Swup, { elements, selector }: {
|
|
11
|
+
selector: Options['animationSelector'];
|
|
12
|
+
elements?: NodeListOf<HTMLElement> | HTMLElement[];
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
export declare function getTransitionInfo(element: Element, expectedType?: AnimationTypes): {
|
|
15
|
+
type: AnimationTypes | null;
|
|
16
|
+
timeout: number;
|
|
17
|
+
propCount: number;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import Swup from '../Swup.js';
|
|
2
|
-
/** A page object as used by swup and its cache. */
|
|
3
|
-
export interface PageData {
|
|
4
|
-
/** The URL of the page */
|
|
5
|
-
url: string;
|
|
6
|
-
/** The complete HTML response received from the server */
|
|
7
|
-
html: string;
|
|
8
|
-
}
|
|
9
|
-
/** Define how a page is fetched. */
|
|
10
|
-
export interface FetchOptions extends RequestInit {
|
|
11
|
-
/** The request method. */
|
|
12
|
-
method?: 'GET' | 'POST';
|
|
13
|
-
/** The body of the request: raw string, form data object or URL params. */
|
|
14
|
-
body?: string | FormData | URLSearchParams;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
export declare function fetchPage(this: Swup, url: URL | string, options?: FetchOptions): Promise<PageData>;
|
|
1
|
+
import Swup from '../Swup.js';
|
|
2
|
+
/** A page object as used by swup and its cache. */
|
|
3
|
+
export interface PageData {
|
|
4
|
+
/** The URL of the page */
|
|
5
|
+
url: string;
|
|
6
|
+
/** The complete HTML response received from the server */
|
|
7
|
+
html: string;
|
|
8
|
+
}
|
|
9
|
+
/** Define how a page is fetched. */
|
|
10
|
+
export interface FetchOptions extends Omit<RequestInit, 'cache'> {
|
|
11
|
+
/** The request method. */
|
|
12
|
+
method?: 'GET' | 'POST';
|
|
13
|
+
/** The body of the request: raw string, form data object or URL params. */
|
|
14
|
+
body?: string | FormData | URLSearchParams;
|
|
15
|
+
}
|
|
16
|
+
export declare class FetchError extends Error {
|
|
17
|
+
url: string;
|
|
18
|
+
status: number;
|
|
19
|
+
constructor(message: string, details: {
|
|
20
|
+
url: string;
|
|
21
|
+
status: number;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Fetch a page from the server, return it and cache it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fetchPage(this: Swup, url: URL | string, options?: FetchOptions): Promise<PageData>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find the anchor element for a given hash.
|
|
3
|
-
*
|
|
4
|
-
* @param hash Hash with or without leading '#'
|
|
5
|
-
* @returns The element, if found, or null.
|
|
6
|
-
*
|
|
7
|
-
* @see https://html.spec.whatwg.org/#find-a-potential-indicated-element
|
|
8
|
-
*/
|
|
9
|
-
export declare const getAnchorElement: (hash?: string) => Element | null;
|
|
1
|
+
/**
|
|
2
|
+
* Find the anchor element for a given hash.
|
|
3
|
+
*
|
|
4
|
+
* @param hash Hash with or without leading '#'
|
|
5
|
+
* @returns The element, if found, or null.
|
|
6
|
+
*
|
|
7
|
+
* @see https://html.spec.whatwg.org/#find-a-potential-indicated-element
|
|
8
|
+
*/
|
|
9
|
+
export declare const getAnchorElement: (hash?: string) => Element | null;
|
|
@@ -1,35 +1,41 @@
|
|
|
1
|
-
import Swup from '../Swup.js';
|
|
2
|
-
import { FetchOptions } from './fetchPage.js';
|
|
3
|
-
import { VisitInitOptions } from './Visit.js';
|
|
4
|
-
export type HistoryAction = 'push' | 'replace';
|
|
5
|
-
export type HistoryDirection = 'forwards' | 'backwards';
|
|
6
|
-
export type NavigationToSelfAction = 'scroll' | 'navigate';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import Swup from '../Swup.js';
|
|
2
|
+
import { FetchOptions } from './fetchPage.js';
|
|
3
|
+
import { VisitInitOptions } from './Visit.js';
|
|
4
|
+
export type HistoryAction = 'push' | 'replace';
|
|
5
|
+
export type HistoryDirection = 'forwards' | 'backwards';
|
|
6
|
+
export type NavigationToSelfAction = 'scroll' | 'navigate';
|
|
7
|
+
export type CacheControl = Partial<{
|
|
8
|
+
read: boolean;
|
|
9
|
+
write: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
/** Define how to navigate to a page. */
|
|
12
|
+
type NavigationOptions = {
|
|
13
|
+
/** Whether this visit is animated. Default: `true` */
|
|
14
|
+
animate?: boolean;
|
|
15
|
+
/** Name of a custom animation to run. */
|
|
16
|
+
animation?: string;
|
|
17
|
+
/** History action to perform: `push` for creating a new history entry, `replace` for replacing the current entry. Default: `push` */
|
|
18
|
+
history?: HistoryAction;
|
|
19
|
+
/** Whether this visit should read from or write to the cache. */
|
|
20
|
+
cache?: CacheControl;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Navigate to a new URL.
|
|
24
|
+
* @param url The URL to navigate to.
|
|
25
|
+
* @param options Options for how to perform this visit.
|
|
26
|
+
* @returns Promise<void>
|
|
27
|
+
*/
|
|
28
|
+
export declare function navigate(this: Swup, url: string, options?: NavigationOptions & FetchOptions, init?: Omit<VisitInitOptions, 'to'>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Start a visit to a new URL.
|
|
31
|
+
*
|
|
32
|
+
* Internal method that assumes the visit context has already been created.
|
|
33
|
+
*
|
|
34
|
+
* As a user, you should call `swup.navigate(url)` instead.
|
|
35
|
+
*
|
|
36
|
+
* @param url The URL to navigate to.
|
|
37
|
+
* @param options Options for how to perform this visit.
|
|
38
|
+
* @returns Promise<void>
|
|
39
|
+
*/
|
|
40
|
+
export declare function performNavigation(this: Swup, options?: NavigationOptions & FetchOptions): Promise<void>;
|
|
41
|
+
export {};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import Swup from '../Swup.js';
|
|
2
|
-
export type Plugin = {
|
|
3
|
-
/** Identify as a swup plugin */
|
|
4
|
-
isSwupPlugin: true;
|
|
5
|
-
/** Name of this plugin */
|
|
6
|
-
name: string;
|
|
7
|
-
/** Version of this plugin. Currently not in use, defined here for backward compatiblity. */
|
|
8
|
-
version?: string;
|
|
9
|
-
/** The swup instance that mounted this plugin */
|
|
10
|
-
swup?: Swup;
|
|
11
|
-
/** Version requirements of this plugin. Example: `{ swup: '>=4' }` */
|
|
12
|
-
requires?: Record<string, string | string[]>;
|
|
13
|
-
/** Run on mount */
|
|
14
|
-
mount: () => void;
|
|
15
|
-
/** Run on unmount */
|
|
16
|
-
unmount: () => void;
|
|
17
|
-
_beforeMount?: () => void;
|
|
18
|
-
_afterUnmount?: () => void;
|
|
19
|
-
_checkRequirements?: () => boolean;
|
|
20
|
-
};
|
|
21
|
-
/** Install a plugin. */
|
|
22
|
-
export declare const use: (this: Swup, plugin: unknown) => Plugin[] | undefined;
|
|
23
|
-
/** Uninstall a plugin. */
|
|
24
|
-
export declare function unuse(this: Swup, pluginOrName: Plugin | string): Plugin[] | undefined;
|
|
25
|
-
/** Find a plugin by name or reference. */
|
|
26
|
-
export declare function findPlugin(this: Swup, pluginOrName: Plugin | string): Plugin | undefined;
|
|
1
|
+
import Swup from '../Swup.js';
|
|
2
|
+
export type Plugin = {
|
|
3
|
+
/** Identify as a swup plugin */
|
|
4
|
+
isSwupPlugin: true;
|
|
5
|
+
/** Name of this plugin */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Version of this plugin. Currently not in use, defined here for backward compatiblity. */
|
|
8
|
+
version?: string;
|
|
9
|
+
/** The swup instance that mounted this plugin */
|
|
10
|
+
swup?: Swup;
|
|
11
|
+
/** Version requirements of this plugin. Example: `{ swup: '>=4' }` */
|
|
12
|
+
requires?: Record<string, string | string[]>;
|
|
13
|
+
/** Run on mount */
|
|
14
|
+
mount: () => void;
|
|
15
|
+
/** Run on unmount */
|
|
16
|
+
unmount: () => void;
|
|
17
|
+
_beforeMount?: () => void;
|
|
18
|
+
_afterUnmount?: () => void;
|
|
19
|
+
_checkRequirements?: () => boolean;
|
|
20
|
+
};
|
|
21
|
+
/** Install a plugin. */
|
|
22
|
+
export declare const use: (this: Swup, plugin: unknown) => Plugin[] | undefined;
|
|
23
|
+
/** Uninstall a plugin. */
|
|
24
|
+
export declare function unuse(this: Swup, pluginOrName: Plugin | string): Plugin[] | undefined;
|
|
25
|
+
/** Find a plugin by name or reference. */
|
|
26
|
+
export declare function findPlugin(this: Swup, pluginOrName: Plugin | string): Plugin | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Swup from '../Swup.js';
|
|
2
|
-
import { PageData } from './fetchPage.js';
|
|
3
|
-
/**
|
|
4
|
-
* Render the next page: replace the content and update scroll position.
|
|
5
|
-
* @returns Promise<void>
|
|
6
|
-
*/
|
|
7
|
-
export declare const renderPage: (this: Swup, requestedUrl: string, page: PageData) => Promise<void>;
|
|
1
|
+
import Swup from '../Swup.js';
|
|
2
|
+
import { PageData } from './fetchPage.js';
|
|
3
|
+
/**
|
|
4
|
+
* Render the next page: replace the content and update scroll position.
|
|
5
|
+
* @returns Promise<void>
|
|
6
|
+
*/
|
|
7
|
+
export declare const renderPage: (this: Swup, requestedUrl: string, page: PageData) => Promise<void>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import Swup, { Options } from '../Swup.js';
|
|
2
|
-
import { PageData } from './fetchPage.js';
|
|
3
|
-
/**
|
|
4
|
-
* Perform the replacement of content after loading a page.
|
|
5
|
-
*
|
|
6
|
-
* It takes an object with the page data as returned from `fetchPage` and a list
|
|
7
|
-
* of container selectors to replace.
|
|
8
|
-
*
|
|
9
|
-
* @returns Whether all containers were replaced.
|
|
10
|
-
*/
|
|
11
|
-
export declare const replaceContent: (this: Swup, { html }: PageData, { containers }?: {
|
|
12
|
-
containers: Options['containers'];
|
|
13
|
-
}) => boolean;
|
|
1
|
+
import Swup, { Options } from '../Swup.js';
|
|
2
|
+
import { PageData } from './fetchPage.js';
|
|
3
|
+
/**
|
|
4
|
+
* Perform the replacement of content after loading a page.
|
|
5
|
+
*
|
|
6
|
+
* It takes an object with the page data as returned from `fetchPage` and a list
|
|
7
|
+
* of container selectors to replace.
|
|
8
|
+
*
|
|
9
|
+
* @returns Whether all containers were replaced.
|
|
10
|
+
*/
|
|
11
|
+
export declare const replaceContent: (this: Swup, { html }: PageData, { containers }?: {
|
|
12
|
+
containers: Options['containers'];
|
|
13
|
+
}) => boolean;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import Swup from '../Swup.js';
|
|
2
|
-
/**
|
|
3
|
-
* Utility function to validate and run the global option 'resolveUrl'
|
|
4
|
-
* @param {string} url
|
|
5
|
-
* @returns {string} the resolved url
|
|
6
|
-
*/
|
|
7
|
-
export declare function resolveUrl(this: Swup, url: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Compares the resolved version of two paths and returns true if they are the same
|
|
10
|
-
* @param {string} url1
|
|
11
|
-
* @param {string} url2
|
|
12
|
-
* @returns {boolean}
|
|
13
|
-
*/
|
|
14
|
-
export declare function isSameResolvedUrl(this: Swup, url1: string, url2: string): boolean;
|
|
1
|
+
import Swup from '../Swup.js';
|
|
2
|
+
/**
|
|
3
|
+
* Utility function to validate and run the global option 'resolveUrl'
|
|
4
|
+
* @param {string} url
|
|
5
|
+
* @returns {string} the resolved url
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveUrl(this: Swup, url: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Compares the resolved version of two paths and returns true if they are the same
|
|
10
|
+
* @param {string} url1
|
|
11
|
+
* @param {string} url2
|
|
12
|
+
* @returns {boolean}
|
|
13
|
+
*/
|
|
14
|
+
export declare function isSameResolvedUrl(this: Swup, url1: string, url2: string): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Swup from '../Swup.js';
|
|
2
|
-
/**
|
|
3
|
-
* Update the scroll position after page render.
|
|
4
|
-
* @returns Promise<boolean>
|
|
5
|
-
*/
|
|
6
|
-
export declare const scrollToContent: (this: Swup) => boolean;
|
|
1
|
+
import Swup from '../Swup.js';
|
|
2
|
+
/**
|
|
3
|
+
* Update the scroll position after page render.
|
|
4
|
+
* @returns Promise<boolean>
|
|
5
|
+
*/
|
|
6
|
+
export declare const scrollToContent: (this: Swup) => boolean;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/** Find an element by selector. */
|
|
2
|
-
export declare const query: (selector: string, context?: Document | Element) => HTMLElement | null;
|
|
3
|
-
/** Find a set of elements by selector. */
|
|
4
|
-
export declare const queryAll: (selector: string, context?: Document | Element) => HTMLElement[];
|
|
5
|
-
/** Return a Promise that resolves after the next event loop. */
|
|
6
|
-
export declare const nextTick: () => Promise<void>;
|
|
7
|
-
/** Check if an object is a Promise or a Thenable */
|
|
8
|
-
export declare function isPromise<T>(obj:
|
|
9
|
-
/** Call a function as a Promise. Resolves with the returned Promsise or immediately. */
|
|
10
|
-
export declare function runAsPromise(func: Function, args?:
|
|
11
|
-
/**
|
|
12
|
-
* Force a layout reflow, e.g. after adding classnames
|
|
13
|
-
* @returns The offset height, just here so it doesn't get optimized away by the JS engine
|
|
14
|
-
* @see https://stackoverflow.com/a/21665117/3759615
|
|
15
|
-
*/
|
|
16
|
-
export declare function forceReflow(element?: HTMLElement): number;
|
|
17
|
-
/** Escape a string with special chars to not break CSS selectors. */
|
|
18
|
-
export declare const escapeCssIdentifier: (ident: string) => string;
|
|
19
|
-
/** Fix for Chrome below v61 formatting CSS floats with comma in some locales. */
|
|
20
|
-
export declare const toMs: (s: string) => number;
|
|
1
|
+
/** Find an element by selector. */
|
|
2
|
+
export declare const query: (selector: string, context?: Document | Element) => HTMLElement | null;
|
|
3
|
+
/** Find a set of elements by selector. */
|
|
4
|
+
export declare const queryAll: (selector: string, context?: Document | Element) => HTMLElement[];
|
|
5
|
+
/** Return a Promise that resolves after the next event loop. */
|
|
6
|
+
export declare const nextTick: () => Promise<void>;
|
|
7
|
+
/** Check if an object is a Promise or a Thenable */
|
|
8
|
+
export declare function isPromise<T>(obj: unknown): obj is PromiseLike<T>;
|
|
9
|
+
/** Call a function as a Promise. Resolves with the returned Promsise or immediately. */
|
|
10
|
+
export declare function runAsPromise(func: Function, args?: unknown[]): Promise<unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Force a layout reflow, e.g. after adding classnames
|
|
13
|
+
* @returns The offset height, just here so it doesn't get optimized away by the JS engine
|
|
14
|
+
* @see https://stackoverflow.com/a/21665117/3759615
|
|
15
|
+
*/
|
|
16
|
+
export declare function forceReflow(element?: HTMLElement): number;
|
|
17
|
+
/** Escape a string with special chars to not break CSS selectors. */
|
|
18
|
+
export declare const escapeCssIdentifier: (ident: string) => string;
|
|
19
|
+
/** Fix for Chrome below v61 formatting CSS floats with comma in some locales. */
|
|
20
|
+
export declare const toMs: (s: string) => number;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './utils/index.js';
|
|
1
|
+
export * from './utils/index.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swup",
|
|
3
3
|
"amdName": "Swup",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.1",
|
|
5
5
|
"description": "Versatile and extensible page transition library for server-rendered websites",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"source": "./src/Swup.ts",
|
|
@@ -26,9 +26,10 @@
|
|
|
26
26
|
"build:module": "BROWSERSLIST_ENV=modern microbundle src/index.ts -f modern,esm,cjs",
|
|
27
27
|
"build:bundle": "BROWSERSLIST_ENV=production microbundle src/Swup.ts -f umd --external none",
|
|
28
28
|
"dev": "npm run clean && BROWSERSLIST_ENV=development microbundle src/index.ts -w -f modern",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
29
|
+
"format": "npx eslint . --fix",
|
|
30
|
+
"lint": "npm run lint:ts && npm run lint:es",
|
|
31
31
|
"lint:ts": "tsc --noEmit --skipLibCheck",
|
|
32
|
+
"lint:es": "npx eslint .",
|
|
32
33
|
"lint:prettier": "prettier 'src/**/*.ts'",
|
|
33
34
|
"prepublishOnly": "npm run build",
|
|
34
35
|
"postinstall": "opencollective-postinstall || true",
|
|
@@ -70,7 +71,12 @@
|
|
|
70
71
|
"@swup/browserslist-config": "^1.0.0",
|
|
71
72
|
"@swup/prettier-config": "^1.0.0",
|
|
72
73
|
"@types/jsdom": "^21.1.1",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
75
|
+
"@typescript-eslint/parser": "^6.3.0",
|
|
73
76
|
"cypress": "^12.3.0",
|
|
77
|
+
"eslint": "^8.46.0",
|
|
78
|
+
"eslint-config-prettier": "^9.0.0",
|
|
79
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
74
80
|
"http-server": "^14.1.1",
|
|
75
81
|
"husky": "^8.0.0",
|
|
76
82
|
"istanbul-lib-coverage": "^3.2.0",
|