swup 3.0.0-rc.2 → 3.0.0-rc.3
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 +3 -3
- package/dist/types/helpers/Location.d.ts +1 -1
- package/dist/types/helpers/classify.d.ts +1 -2
- package/dist/types/helpers/cleanupAnimationClasses.d.ts +2 -2
- package/dist/types/helpers/createHistoryRecord.d.ts +1 -2
- package/dist/types/helpers/delegateEvent.d.ts +1 -2
- package/dist/types/helpers/fetch.d.ts +1 -2
- package/dist/types/helpers/getCurrentUrl.d.ts +1 -2
- package/dist/types/helpers/getDataFromHtml.d.ts +1 -2
- package/dist/types/helpers/markSwupElements.d.ts +1 -2
- package/dist/types/helpers/updateHistoryRecord.d.ts +1 -2
- package/dist/types/helpers/versionSatisfies.d.ts +0 -1
- package/dist/types/helpers.d.ts +11 -1
- package/dist/types/index.d.ts +4 -7
- package/dist/types/modules/Cache.d.ts +0 -1
- package/dist/types/modules/enterPage.d.ts +1 -2
- package/dist/types/modules/fetchPage.d.ts +1 -1
- package/dist/types/modules/getAnchorElement.d.ts +1 -2
- package/dist/types/modules/getAnimationPromises.d.ts +1 -1
- package/dist/types/modules/getPageData.d.ts +1 -2
- package/dist/types/modules/leavePage.d.ts +1 -2
- package/dist/types/modules/loadPage.d.ts +1 -2
- package/dist/types/modules/off.d.ts +1 -2
- package/dist/types/modules/on.d.ts +1 -2
- package/dist/types/modules/renderPage.d.ts +1 -2
- package/dist/types/modules/replaceContent.d.ts +1 -2
- package/dist/types/modules/triggerEvent.d.ts +1 -2
- package/dist/types/modules/updateTransition.d.ts +1 -2
- package/package.json +10 -5
- package/src/Swup.ts +14 -14
- package/src/helpers/Location.ts +1 -1
- package/src/helpers/classify.ts +1 -3
- package/src/helpers/cleanupAnimationClasses.ts +2 -4
- package/src/helpers/createHistoryRecord.ts +5 -4
- package/src/helpers/delegateEvent.ts +1 -3
- package/src/helpers/fetch.ts +1 -3
- package/src/helpers/getCurrentUrl.ts +1 -3
- package/src/helpers/getDataFromHtml.ts +1 -3
- package/src/helpers/markSwupElements.ts +1 -3
- package/src/helpers/updateHistoryRecord.ts +2 -4
- package/src/helpers/versionSatisfies.ts +0 -2
- package/src/helpers.ts +11 -1
- package/src/modules/Cache.ts +0 -2
- package/src/modules/enterPage.ts +1 -3
- package/src/modules/fetchPage.ts +1 -1
- package/src/modules/getAnchorElement.ts +1 -3
- package/src/modules/getAnimationPromises.ts +1 -1
- package/src/modules/getPageData.ts +1 -3
- package/src/modules/leavePage.ts +1 -3
- package/src/modules/loadPage.ts +5 -3
- package/src/modules/off.ts +1 -3
- package/src/modules/on.ts +1 -3
- package/src/modules/renderPage.ts +1 -3
- package/src/modules/replaceContent.ts +1 -3
- package/src/modules/triggerEvent.ts +1 -3
- package/src/modules/updateTransition.ts +6 -3
- package/src/helpers/index.ts +0 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swup",
|
|
3
3
|
"amdName": "Swup",
|
|
4
|
-
"version": "3.0.0-rc.
|
|
4
|
+
"version": "3.0.0-rc.3",
|
|
5
5
|
"description": "Complete, flexible, extensible, and easy-to-use page transition library for your server-side rendered website.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"source": "src/Swup.ts",
|
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
"build:module": "microbundle src/index.ts -f modern,esm,cjs",
|
|
20
20
|
"build:bundle": "microbundle src/Swup.ts -f umd --external none",
|
|
21
21
|
"dev": "microbundle src/*.ts -w",
|
|
22
|
-
"lint": "
|
|
22
|
+
"lint": "npm run lint:ts && npm run lint:prettier -- --check",
|
|
23
|
+
"format": "npm run lint:ts && npm run lint:prettier -- --write",
|
|
24
|
+
"lint:ts": "tsc --noEmit --skipLibCheck",
|
|
25
|
+
"lint:prettier": "prettier 'src/**/*.ts'",
|
|
23
26
|
"prepublish": "npm run build",
|
|
24
27
|
"postinstall": "opencollective-postinstall || true",
|
|
25
28
|
"ci": "start-server-and-test test:start 8274 cy:run:record",
|
|
@@ -30,7 +33,8 @@
|
|
|
30
33
|
"test:start": "npm run test:instrument && npm run test:server",
|
|
31
34
|
"cy:run": "cypress run",
|
|
32
35
|
"cy:run:record": "cypress run --record",
|
|
33
|
-
"cy:open": "cypress open"
|
|
36
|
+
"cy:open": "cypress open",
|
|
37
|
+
"prepare": "husky install"
|
|
34
38
|
},
|
|
35
39
|
"author": "Georgy Marchuk",
|
|
36
40
|
"license": "MIT",
|
|
@@ -51,13 +55,14 @@
|
|
|
51
55
|
"devDependencies": {
|
|
52
56
|
"@cypress/code-coverage": "^3.10.0",
|
|
53
57
|
"@swup/prettier-config": "^1.0.0",
|
|
54
|
-
"cypress": "^
|
|
58
|
+
"cypress": "^12.3.0",
|
|
55
59
|
"http-server": "^14.1.1",
|
|
56
60
|
"istanbul-lib-coverage": "^3.2.0",
|
|
57
61
|
"microbundle": "^0.15.0",
|
|
58
62
|
"nyc": "^15.1.0",
|
|
59
63
|
"prettier": "^2.8.2",
|
|
60
|
-
"start-server-and-test": "^1.14.0"
|
|
64
|
+
"start-server-and-test": "^1.14.0",
|
|
65
|
+
"husky": "^8.0.0"
|
|
61
66
|
},
|
|
62
67
|
"collective": {
|
|
63
68
|
"type": "opencollective",
|
package/src/Swup.ts
CHANGED
|
@@ -12,21 +12,21 @@ import {
|
|
|
12
12
|
} from './helpers.js';
|
|
13
13
|
import { Unsubscribe } from './helpers/delegateEvent.js';
|
|
14
14
|
|
|
15
|
-
import Cache from './modules/Cache.js';
|
|
16
|
-
import enterPage from './modules/enterPage.js';
|
|
17
|
-
import getAnchorElement from './modules/getAnchorElement.js';
|
|
18
|
-
import getAnimationPromises from './modules/getAnimationPromises.js';
|
|
19
|
-
import getPageData from './modules/getPageData.js';
|
|
20
|
-
import fetchPage from './modules/fetchPage.js';
|
|
21
|
-
import leavePage from './modules/leavePage.js';
|
|
22
|
-
import loadPage from './modules/loadPage.js';
|
|
23
|
-
import replaceContent from './modules/replaceContent.js';
|
|
24
|
-
import off from './modules/off.js';
|
|
25
|
-
import on,
|
|
15
|
+
import { Cache } from './modules/Cache.js';
|
|
16
|
+
import { enterPage } from './modules/enterPage.js';
|
|
17
|
+
import { getAnchorElement } from './modules/getAnchorElement.js';
|
|
18
|
+
import { getAnimationPromises } from './modules/getAnimationPromises.js';
|
|
19
|
+
import { getPageData } from './modules/getPageData.js';
|
|
20
|
+
import { fetchPage } from './modules/fetchPage.js';
|
|
21
|
+
import { leavePage } from './modules/leavePage.js';
|
|
22
|
+
import { loadPage } from './modules/loadPage.js';
|
|
23
|
+
import { replaceContent } from './modules/replaceContent.js';
|
|
24
|
+
import { off } from './modules/off.js';
|
|
25
|
+
import { on, Handlers } from './modules/on.js';
|
|
26
26
|
import { use, unuse, findPlugin, Plugin } from './modules/plugins.js';
|
|
27
|
-
import renderPage from './modules/renderPage.js';
|
|
28
|
-
import triggerEvent from './modules/triggerEvent.js';
|
|
29
|
-
import updateTransition from './modules/updateTransition.js';
|
|
27
|
+
import { renderPage } from './modules/renderPage.js';
|
|
28
|
+
import { triggerEvent } from './modules/triggerEvent.js';
|
|
29
|
+
import { updateTransition } from './modules/updateTransition.js';
|
|
30
30
|
|
|
31
31
|
import { queryAll } from './utils.js';
|
|
32
32
|
|
package/src/helpers/Location.ts
CHANGED
package/src/helpers/classify.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const classify = (text: string, fallback?: string): string => {
|
|
1
|
+
export const classify = (text: string, fallback?: string): string => {
|
|
2
2
|
const output = String(text)
|
|
3
3
|
.toLowerCase()
|
|
4
4
|
// .normalize('NFD') // split an accented letter in the base letter and the acent
|
|
@@ -9,5 +9,3 @@ const classify = (text: string, fallback?: string): string => {
|
|
|
9
9
|
.replace(/^-+|-+$/, ''); // trim '-' from edges
|
|
10
10
|
return output || fallback || '';
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
export default classify;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
const isSwupClass = (className: string): boolean =>
|
|
1
|
+
export const isSwupClass = (className: string): boolean =>
|
|
2
2
|
/^to-/.test(className) || ['is-changing', 'is-rendering', 'is-popstate'].includes(className);
|
|
3
3
|
|
|
4
|
-
const cleanupAnimationClasses = (): void => {
|
|
4
|
+
export const cleanupAnimationClasses = (): void => {
|
|
5
5
|
const htmlClasses = document.documentElement.className.split(' ');
|
|
6
6
|
const removeClasses = htmlClasses.filter(isSwupClass);
|
|
7
7
|
document.documentElement.classList.remove(...removeClasses);
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
export default cleanupAnimationClasses;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCurrentUrl } from './getCurrentUrl.js';
|
|
2
2
|
|
|
3
|
-
const createHistoryRecord = (
|
|
3
|
+
export const createHistoryRecord = (
|
|
4
|
+
url: string,
|
|
5
|
+
customData: Record<string, unknown> = {}
|
|
6
|
+
): void => {
|
|
4
7
|
url = url || getCurrentUrl({ hash: true });
|
|
5
8
|
const data = {
|
|
6
9
|
url,
|
|
@@ -10,5 +13,3 @@ const createHistoryRecord = (url: string, customData: Record<string, unknown> =
|
|
|
10
13
|
};
|
|
11
14
|
history.pushState(data, '', url);
|
|
12
15
|
};
|
|
13
|
-
|
|
14
|
-
export default createHistoryRecord;
|
|
@@ -4,7 +4,7 @@ import { ParseSelector } from 'typed-query-selector/parser';
|
|
|
4
4
|
export type Unsubscribe = {
|
|
5
5
|
destroy: () => void;
|
|
6
6
|
};
|
|
7
|
-
const delegateEvent = <Selector extends string, TEvent extends EventType>(
|
|
7
|
+
export const delegateEvent = <Selector extends string, TEvent extends EventType>(
|
|
8
8
|
selector: Selector,
|
|
9
9
|
type: TEvent,
|
|
10
10
|
callback: delegate.EventHandler<GlobalEventHandlersEventMap[TEvent]>,
|
|
@@ -19,5 +19,3 @@ const delegateEvent = <Selector extends string, TEvent extends EventType>(
|
|
|
19
19
|
);
|
|
20
20
|
return { destroy: () => delegation.destroy() };
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
export default delegateEvent;
|
package/src/helpers/fetch.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransitionOptions } from '../modules/loadPage.js';
|
|
2
2
|
import { Options } from '../Swup.js';
|
|
3
3
|
|
|
4
|
-
const fetch = (
|
|
4
|
+
export const fetch = (
|
|
5
5
|
options: TransitionOptions & { headers: Options['requestHeaders'] },
|
|
6
6
|
callback: (request: XMLHttpRequest) => void
|
|
7
7
|
): XMLHttpRequest => {
|
|
@@ -31,5 +31,3 @@ const fetch = (
|
|
|
31
31
|
|
|
32
32
|
return request;
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
export default fetch;
|
|
@@ -7,7 +7,7 @@ export type PageHtmlData = {
|
|
|
7
7
|
pageClass?: string;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const getDataFromHtml = (html: string, containers: string[]): PageHtmlData => {
|
|
10
|
+
export const getDataFromHtml = (html: string, containers: string[]): PageHtmlData => {
|
|
11
11
|
let fakeDom = document.createElement('html');
|
|
12
12
|
fakeDom.innerHTML = html;
|
|
13
13
|
let blocks: string[] = [];
|
|
@@ -37,5 +37,3 @@ const getDataFromHtml = (html: string, containers: string[]): PageHtmlData => {
|
|
|
37
37
|
|
|
38
38
|
return { title, pageClass, blocks, originalContent: html };
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
export default getDataFromHtml;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { query, queryAll } from '../utils.js';
|
|
2
2
|
|
|
3
|
-
const markSwupElements = (element: Element, containers: string[]): void => {
|
|
3
|
+
export const markSwupElements = (element: Element, containers: string[]): void => {
|
|
4
4
|
let blocks = 0;
|
|
5
5
|
|
|
6
6
|
containers.forEach((selector) => {
|
|
@@ -14,5 +14,3 @@ const markSwupElements = (element: Element, containers: string[]): void => {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
export default markSwupElements;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCurrentUrl } from './getCurrentUrl.js';
|
|
2
2
|
|
|
3
|
-
const updateHistoryRecord = (
|
|
3
|
+
export const updateHistoryRecord = (
|
|
4
4
|
url: string | null = null,
|
|
5
5
|
customData: Record<string, unknown> = {}
|
|
6
6
|
): void => {
|
|
@@ -14,5 +14,3 @@ const updateHistoryRecord = (
|
|
|
14
14
|
};
|
|
15
15
|
history.replaceState(data, '', url);
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
export default updateHistoryRecord;
|
package/src/helpers.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
// Re-export all helpers to allow custom package export path
|
|
2
2
|
// e.g. import { getPageData } from 'swup/helpers'
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export { classify } from './helpers/classify.js';
|
|
5
|
+
export { createHistoryRecord } from './helpers/createHistoryRecord.js';
|
|
6
|
+
export { updateHistoryRecord } from './helpers/updateHistoryRecord.js';
|
|
7
|
+
export { delegateEvent } from './helpers/delegateEvent.js';
|
|
8
|
+
export { getDataFromHtml } from './helpers/getDataFromHtml.js';
|
|
9
|
+
export { fetch } from './helpers/fetch.js';
|
|
10
|
+
export { getCurrentUrl } from './helpers/getCurrentUrl.js';
|
|
11
|
+
export { Location } from './helpers/Location.js';
|
|
12
|
+
export { markSwupElements } from './helpers/markSwupElements.js';
|
|
13
|
+
export { cleanupAnimationClasses } from './helpers/cleanupAnimationClasses.js';
|
|
14
|
+
export { versionSatisfies } from './helpers/versionSatisfies.js';
|
package/src/modules/Cache.ts
CHANGED
package/src/modules/enterPage.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { nextTick } from '../utils.js';
|
|
2
2
|
import Swup from '../Swup.js';
|
|
3
3
|
|
|
4
|
-
const enterPage = function (
|
|
4
|
+
export const enterPage = function (
|
|
5
5
|
this: Swup,
|
|
6
6
|
{ popstate, skipTransition }: { popstate?: PopStateEvent; skipTransition?: boolean }
|
|
7
7
|
) {
|
|
@@ -24,5 +24,3 @@ const enterPage = function (
|
|
|
24
24
|
});
|
|
25
25
|
return animationPromises;
|
|
26
26
|
};
|
|
27
|
-
|
|
28
|
-
export default enterPage;
|
package/src/modules/fetchPage.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { fetch } from '../helpers.js';
|
|
|
3
3
|
import { TransitionOptions } from './loadPage.js';
|
|
4
4
|
import { PageRecord } from './Cache.js';
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export function fetchPage(this: Swup, data: TransitionOptions): Promise<PageRecord> {
|
|
7
7
|
const headers = this.options.requestHeaders;
|
|
8
8
|
const { url } = data;
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { escapeCssIdentifier, query } from '../utils.js';
|
|
2
2
|
|
|
3
|
-
const getAnchorElement = (hash: string): Element | null => {
|
|
3
|
+
export const getAnchorElement = (hash: string): Element | null => {
|
|
4
4
|
if (!hash) {
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
@@ -15,5 +15,3 @@ const getAnchorElement = (hash: string): Element | null => {
|
|
|
15
15
|
// https://html.spec.whatwg.org/#find-a-potential-indicated-element
|
|
16
16
|
return query(`#${hash}`) || query(`a[name='${hash}']`);
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
export default getAnchorElement;
|
|
@@ -17,7 +17,7 @@ if (window.onanimationend === undefined && window.onwebkitanimationend !== undef
|
|
|
17
17
|
animationEndEvent = 'webkitAnimationEnd';
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export
|
|
20
|
+
export function getAnimationPromises(
|
|
21
21
|
this: Swup,
|
|
22
22
|
// we don't use this argument, but JS plugin depends on it with
|
|
23
23
|
// its own version of getAnimationPromises, so it must be specified when
|
|
@@ -5,7 +5,7 @@ import { PageHtmlData } from '../helpers/getDataFromHtml.js';
|
|
|
5
5
|
export type PageData = PageHtmlData & {
|
|
6
6
|
responseURL: string;
|
|
7
7
|
};
|
|
8
|
-
const getPageData = function (this: Swup, request: XMLHttpRequest): PageData | null {
|
|
8
|
+
export const getPageData = function (this: Swup, request: XMLHttpRequest): PageData | null {
|
|
9
9
|
// this method can be replaced in case other content than html is expected to be received from server
|
|
10
10
|
// this function should always return { title, pageClass, originalContent, blocks, responseURL }
|
|
11
11
|
// in case page has invalid structure - return null
|
|
@@ -22,5 +22,3 @@ const getPageData = function (this: Swup, request: XMLHttpRequest): PageData | n
|
|
|
22
22
|
responseURL: request.responseURL || window.location.href
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
export default getPageData;
|
package/src/modules/leavePage.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Swup from '../Swup.js';
|
|
2
2
|
import { TransitionOptions } from './loadPage.js';
|
|
3
3
|
|
|
4
|
-
const leavePage = function (
|
|
4
|
+
export const leavePage = function (
|
|
5
5
|
this: Swup,
|
|
6
6
|
data: TransitionOptions,
|
|
7
7
|
{ popstate, skipTransition }: { popstate: PopStateEvent | null; skipTransition?: boolean } = {
|
|
@@ -29,5 +29,3 @@ const leavePage = function (
|
|
|
29
29
|
|
|
30
30
|
return animationPromises;
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
export default leavePage;
|
package/src/modules/loadPage.ts
CHANGED
|
@@ -7,7 +7,11 @@ export type TransitionOptions = {
|
|
|
7
7
|
customTransition?: string;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const loadPage = function (
|
|
10
|
+
export const loadPage = function (
|
|
11
|
+
this: Swup,
|
|
12
|
+
data: TransitionOptions,
|
|
13
|
+
popstate: PopStateEvent | null
|
|
14
|
+
) {
|
|
11
15
|
const { url, customTransition } = data;
|
|
12
16
|
const skipTransition = !!(popstate && !this.options.animateHistoryBrowsing);
|
|
13
17
|
|
|
@@ -51,5 +55,3 @@ const loadPage = function (this: Swup, data: TransitionOptions, popstate: PopSta
|
|
|
51
55
|
history.go(-1);
|
|
52
56
|
});
|
|
53
57
|
};
|
|
54
|
-
|
|
55
|
-
export default loadPage;
|
package/src/modules/off.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Swup from '../Swup.js';
|
|
2
2
|
import { EventType, Handler } from './on.js';
|
|
3
3
|
|
|
4
|
-
const off = function off(this: Swup, event?: EventType, handler?: Handler) {
|
|
4
|
+
export const off = function off(this: Swup, event?: EventType, handler?: Handler) {
|
|
5
5
|
if (event && handler) {
|
|
6
6
|
// Remove specific handler
|
|
7
7
|
if (this._handlers[event].includes(handler)) {
|
|
@@ -19,5 +19,3 @@ const off = function off(this: Swup, event?: EventType, handler?: Handler) {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
export default off;
|
package/src/modules/on.ts
CHANGED
|
@@ -24,12 +24,10 @@ export type EventType =
|
|
|
24
24
|
export type Handler = (event?: Event) => void;
|
|
25
25
|
export type Handlers = Record<EventType, Handler[]>;
|
|
26
26
|
|
|
27
|
-
const on = function on(this: Swup, event: EventType, handler: Handler) {
|
|
27
|
+
export const on = function on(this: Swup, event: EventType, handler: Handler) {
|
|
28
28
|
if (this._handlers[event]) {
|
|
29
29
|
this._handlers[event].push(handler);
|
|
30
30
|
} else {
|
|
31
31
|
console.warn(`Unsupported event ${event}.`);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
export default on;
|
|
@@ -2,7 +2,7 @@ import { Location, updateHistoryRecord, getCurrentUrl } from '../helpers.js';
|
|
|
2
2
|
import Swup from '../Swup.js';
|
|
3
3
|
import { PageRecord } from './Cache.js';
|
|
4
4
|
|
|
5
|
-
const renderPage = function (
|
|
5
|
+
export const renderPage = function (
|
|
6
6
|
this: Swup,
|
|
7
7
|
page: PageRecord,
|
|
8
8
|
{ popstate, skipTransition }: { popstate: PopStateEvent | null; skipTransition?: boolean } = {
|
|
@@ -48,5 +48,3 @@ const renderPage = function (
|
|
|
48
48
|
this.scrollToElement = null;
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
|
-
|
|
52
|
-
export default renderPage;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @param {object} page The page object
|
|
11
11
|
* @returns Promise
|
|
12
12
|
*/
|
|
13
|
-
const replaceContent = function ({ blocks, title }: { blocks: string[]; title: string }) {
|
|
13
|
+
export const replaceContent = function ({ blocks, title }: { blocks: string[]; title: string }) {
|
|
14
14
|
// Replace content blocks
|
|
15
15
|
blocks.forEach((html, i) => {
|
|
16
16
|
// we know the block exists at this point
|
|
@@ -24,5 +24,3 @@ const replaceContent = function ({ blocks, title }: { blocks: string[]; title: s
|
|
|
24
24
|
// Return a Promise to allow plugins to defer
|
|
25
25
|
return Promise.resolve();
|
|
26
26
|
};
|
|
27
|
-
|
|
28
|
-
export default replaceContent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventType } from './on.js';
|
|
2
2
|
import Swup from '../Swup.js';
|
|
3
3
|
|
|
4
|
-
const triggerEvent = function (
|
|
4
|
+
export const triggerEvent = function (
|
|
5
5
|
this: Swup,
|
|
6
6
|
eventName: EventType,
|
|
7
7
|
originalEvent?: PopStateEvent | MouseEvent
|
|
@@ -19,5 +19,3 @@ const triggerEvent = function (
|
|
|
19
19
|
const event = new CustomEvent(`swup:${eventName}`, { detail: eventName });
|
|
20
20
|
document.dispatchEvent(event);
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
export default triggerEvent;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import Swup from '../Swup.js';
|
|
2
2
|
|
|
3
|
-
const updateTransition = function (
|
|
3
|
+
export const updateTransition = function (
|
|
4
|
+
this: Swup,
|
|
5
|
+
from: string,
|
|
6
|
+
to: string,
|
|
7
|
+
custom?: string
|
|
8
|
+
): void {
|
|
4
9
|
this.transition = { from, to, custom };
|
|
5
10
|
};
|
|
6
|
-
|
|
7
|
-
export default updateTransition;
|
package/src/helpers/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { default as classify } from './classify.js';
|
|
2
|
-
export { default as createHistoryRecord } from './createHistoryRecord.js';
|
|
3
|
-
export { default as updateHistoryRecord } from './updateHistoryRecord.js';
|
|
4
|
-
export { default as delegateEvent } from './delegateEvent.js';
|
|
5
|
-
export { default as getDataFromHtml } from './getDataFromHtml.js';
|
|
6
|
-
export { default as fetch } from './fetch.js';
|
|
7
|
-
export { default as getCurrentUrl } from './getCurrentUrl.js';
|
|
8
|
-
export { default as Location } from './Location.js';
|
|
9
|
-
export { default as markSwupElements } from './markSwupElements.js';
|
|
10
|
-
export { default as cleanupAnimationClasses } from './cleanupAnimationClasses.js';
|
|
11
|
-
export { default as versionSatisfies } from './versionSatisfies.js';
|