swup 3.0.0-rc.3 → 3.0.0
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 +14 -14
- package/dist/types/__test__/index.test.d.ts +1 -0
- package/dist/types/helpers/Location.d.ts +0 -10
- package/dist/types/helpers/fetch.d.ts +2 -2
- package/dist/types/helpers.d.ts +10 -11
- package/dist/types/index.d.ts +5 -4
- package/dist/types/modules/Cache.d.ts +2 -2
- package/dist/types/modules/enterPage.d.ts +1 -1
- package/dist/types/modules/fetchPage.d.ts +3 -3
- package/dist/types/modules/getAnimationPromises.d.ts +1 -1
- package/dist/types/modules/getPageData.d.ts +2 -2
- package/dist/types/modules/leavePage.d.ts +2 -2
- package/dist/types/modules/loadPage.d.ts +1 -1
- package/dist/types/modules/off.d.ts +2 -2
- package/dist/types/modules/on.d.ts +1 -1
- package/dist/types/modules/plugins.d.ts +5 -3
- package/dist/types/modules/renderPage.d.ts +2 -2
- package/dist/types/modules/triggerEvent.d.ts +2 -2
- package/dist/types/modules/updateTransition.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/package.json +16 -8
- package/readme.md +2 -2
- package/src/Swup.ts +21 -21
- package/src/__test__/index.test.ts +36 -0
- package/src/helpers/Location.ts +0 -10
- package/src/helpers/classify.ts +1 -1
- package/src/helpers/createHistoryRecord.ts +1 -1
- package/src/helpers/fetch.ts +2 -2
- package/src/helpers/getDataFromHtml.ts +1 -1
- package/src/helpers/markSwupElements.ts +1 -1
- package/src/helpers/updateHistoryRecord.ts +1 -1
- package/src/helpers.ts +10 -11
- package/src/index.ts +5 -4
- package/src/modules/Cache.ts +3 -3
- package/src/modules/enterPage.ts +2 -2
- package/src/modules/fetchPage.ts +4 -4
- package/src/modules/getAnchorElement.ts +1 -1
- package/src/modules/getAnimationPromises.ts +2 -2
- package/src/modules/getPageData.ts +3 -3
- package/src/modules/leavePage.ts +2 -2
- package/src/modules/loadPage.ts +3 -3
- package/src/modules/off.ts +2 -2
- package/src/modules/on.ts +1 -1
- package/src/modules/plugins.ts +13 -5
- package/src/modules/renderPage.ts +3 -3
- package/src/modules/triggerEvent.ts +2 -2
- package/src/modules/updateTransition.ts +1 -1
- package/src/utils.ts +1 -1
- package/dist/helpers.cjs +0 -2
- package/dist/helpers.cjs.map +0 -1
- package/dist/helpers.modern.js +0 -2
- package/dist/helpers.modern.js.map +0 -1
- package/dist/helpers.module.js +0 -2
- package/dist/helpers.module.js.map +0 -1
- package/dist/types/helpers/index.d.ts +0 -11
- package/dist/types/helpers/versionSatisfies.d.ts +0 -11
- package/dist/utils.cjs +0 -2
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.modern.js +0 -2
- package/dist/utils.modern.js.map +0 -1
- package/dist/utils.module.js +0 -2
- package/dist/utils.module.js.map +0 -1
- package/src/helpers/versionSatisfies.ts +0 -44
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a version satisfies all given version requirements
|
|
3
|
-
*
|
|
4
|
-
* versionSatisfies('2.1.0', ['>=2', '<4']) // true
|
|
5
|
-
* versionSatisfies('2.1.0', ['5']) // false
|
|
6
|
-
*
|
|
7
|
-
* @param {string} installed Installed version
|
|
8
|
-
* @param {Array.<string>} requirements Array of requirements that must be satisfied
|
|
9
|
-
* @returns boolean
|
|
10
|
-
*/
|
|
11
|
-
export declare const versionSatisfies: (installed: string, requirements: string[]) => boolean;
|
package/dist/utils.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
exports.escapeCssIdentifier=e=>window.CSS&&window.CSS.escape?CSS.escape(e):e,exports.nextTick=e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})},exports.query=function(e,r){return void 0===r&&(r=document),r.querySelector(e)},exports.queryAll=function(e,r){return void 0===r&&(r=document),Array.from(r.querySelectorAll(e))},exports.toMs=e=>1e3*Number(e.slice(0,-1).replace(",","."));
|
|
2
|
-
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../src/utils/index.ts"],"sourcesContent":["export const query = (selector: string, context: Document | Element = document) => {\n\treturn context.querySelector<HTMLElement>(selector);\n};\n\nexport const queryAll = (\n\tselector: string,\n\tcontext: Document | Element = document\n): HTMLElement[] => {\n\treturn Array.from(context.querySelectorAll(selector));\n};\n\nexport const nextTick = (callback: () => void) => {\n\trequestAnimationFrame(() => {\n\t\trequestAnimationFrame(() => {\n\t\t\tcallback();\n\t\t});\n\t});\n};\n\nexport const escapeCssIdentifier = (ident: string) => {\n\t// @ts-ignore this is for support check, so it's correct that TS complains\n\tif (window.CSS && window.CSS.escape) {\n\t\treturn CSS.escape(ident);\n\t} else {\n\t\treturn ident;\n\t}\n};\n\n// Fix for Chrome below v61 formatting CSS floats with comma in some locales\nexport const toMs = (s: string) => {\n\treturn Number(s.slice(0, -1).replace(',', '.')) * 1000;\n};\n"],"names":["ident","window","CSS","escape","callback","requestAnimationFrame","selector","context","document","querySelector","Array","from","querySelectorAll","s","Number","slice","replace"],"mappings":"4BAmBoCA,GAE/BC,OAAOC,KAAOD,OAAOC,IAAIC,OAClBD,IAACC,OAAOH,GAEXA,mBAbgBI,IACxBC,sBAAsB,KACrBA,sBAAsB,KACrBD,GAAQ,EAEV,EACD,gBAjBqB,SAACE,EAAkBC,GACvC,YADuC,IAAAA,IAAAA,EAA8BC,UACvDD,EAACE,cAA2BH,EAC3C,mBAEwB,SACvBA,EACAC,GAEA,YAFA,IAAAA,IAAAA,EAA8BC,UAElBE,MAACC,KAAKJ,EAAQK,iBAAiBN,GAC5C,eAoBqBO,GAC8B,IAArCC,OAACD,EAAEE,MAAM,GAAI,GAAGC,QAAQ,IAAK"}
|
package/dist/utils.modern.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=(e,r=document)=>r.querySelector(e),r=(e,r=document)=>Array.from(r.querySelectorAll(e)),o=e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})},t=e=>window.CSS&&window.CSS.escape?CSS.escape(e):e,c=e=>1e3*Number(e.slice(0,-1).replace(",","."));export{t as escapeCssIdentifier,o as nextTick,e as query,r as queryAll,c as toMs};
|
|
2
|
-
//# sourceMappingURL=utils.modern.js.map
|
package/dist/utils.modern.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.modern.js","sources":["../src/utils/index.ts"],"sourcesContent":["export const query = (selector: string, context: Document | Element = document) => {\n\treturn context.querySelector<HTMLElement>(selector);\n};\n\nexport const queryAll = (\n\tselector: string,\n\tcontext: Document | Element = document\n): HTMLElement[] => {\n\treturn Array.from(context.querySelectorAll(selector));\n};\n\nexport const nextTick = (callback: () => void) => {\n\trequestAnimationFrame(() => {\n\t\trequestAnimationFrame(() => {\n\t\t\tcallback();\n\t\t});\n\t});\n};\n\nexport const escapeCssIdentifier = (ident: string) => {\n\t// @ts-ignore this is for support check, so it's correct that TS complains\n\tif (window.CSS && window.CSS.escape) {\n\t\treturn CSS.escape(ident);\n\t} else {\n\t\treturn ident;\n\t}\n};\n\n// Fix for Chrome below v61 formatting CSS floats with comma in some locales\nexport const toMs = (s: string) => {\n\treturn Number(s.slice(0, -1).replace(',', '.')) * 1000;\n};\n"],"names":["query","selector","context","document","querySelector","queryAll","Array","from","querySelectorAll","nextTick","callback","requestAnimationFrame","escapeCssIdentifier","ident","window","CSS","escape","toMs","s","Number","slice","replace"],"mappings":"AAAaA,MAAAA,EAAQ,CAACC,EAAkBC,EAA8BC,aACtDC,cAA2BH,GAG9BI,EAAW,CACvBJ,EACAC,EAA8BC,WAEvBG,MAAMC,KAAKL,EAAQM,iBAAiBP,IAG/BQ,EAAYC,IACxBC,sBAAsB,KACrBA,sBAAsB,KACrBD,GACD,EACD,IAGYE,EAAuBC,GAE/BC,OAAOC,KAAOD,OAAOC,IAAIC,OAClBD,IAACC,OAAOH,GAEXA,EAKII,EAAQC,GAC8B,IAA3CC,OAAOD,EAAEE,MAAM,GAAI,GAAGC,QAAQ,IAAK"}
|
package/dist/utils.module.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=function(e,r){return void 0===r&&(r=document),r.querySelector(e)},r=function(e,r){return void 0===r&&(r=document),Array.from(r.querySelectorAll(e))},n=e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})},o=e=>window.CSS&&window.CSS.escape?CSS.escape(e):e,t=e=>1e3*Number(e.slice(0,-1).replace(",","."));export{o as escapeCssIdentifier,n as nextTick,e as query,r as queryAll,t as toMs};
|
|
2
|
-
//# sourceMappingURL=utils.module.js.map
|
package/dist/utils.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.module.js","sources":["../src/utils/index.ts"],"sourcesContent":["export const query = (selector: string, context: Document | Element = document) => {\n\treturn context.querySelector<HTMLElement>(selector);\n};\n\nexport const queryAll = (\n\tselector: string,\n\tcontext: Document | Element = document\n): HTMLElement[] => {\n\treturn Array.from(context.querySelectorAll(selector));\n};\n\nexport const nextTick = (callback: () => void) => {\n\trequestAnimationFrame(() => {\n\t\trequestAnimationFrame(() => {\n\t\t\tcallback();\n\t\t});\n\t});\n};\n\nexport const escapeCssIdentifier = (ident: string) => {\n\t// @ts-ignore this is for support check, so it's correct that TS complains\n\tif (window.CSS && window.CSS.escape) {\n\t\treturn CSS.escape(ident);\n\t} else {\n\t\treturn ident;\n\t}\n};\n\n// Fix for Chrome below v61 formatting CSS floats with comma in some locales\nexport const toMs = (s: string) => {\n\treturn Number(s.slice(0, -1).replace(',', '.')) * 1000;\n};\n"],"names":["query","selector","context","document","querySelector","queryAll","Array","from","querySelectorAll","nextTick","callback","requestAnimationFrame","escapeCssIdentifier","ident","window","CSS","escape","toMs","s","Number","slice","replace"],"mappings":"AAAaA,MAAAA,EAAQ,SAACC,EAAkBC,GACvC,YADuC,IAAAA,IAAAA,EAA8BC,UACvDD,EAACE,cAA2BH,EAC3C,EAEaI,EAAW,SACvBJ,EACAC,GAEA,YAFA,IAAAA,IAAAA,EAA8BC,UAElBG,MAACC,KAAKL,EAAQM,iBAAiBP,GAC5C,EAEqBQ,EAAIC,IACxBC,sBAAsB,KACrBA,sBAAsB,KACrBD,GAAQ,EAEV,EACD,EAEgCE,EAAIC,GAE/BC,OAAOC,KAAOD,OAAOC,IAAIC,OAClBD,IAACC,OAAOH,GAEXA,EAKQI,EAAIC,GAC8B,IAArCC,OAACD,EAAEE,MAAM,GAAI,GAAGC,QAAQ,IAAK"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
type Comparator = '>' | '>=' | '<' | '<=';
|
|
2
|
-
|
|
3
|
-
// Fill versions to exactly 3 decimals
|
|
4
|
-
const normalizeVersion = (version: string): string => {
|
|
5
|
-
return String(version).split('.').concat(['0', '0']).slice(0, 3).join('.');
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// Numerically compare version strings after normalizing them
|
|
9
|
-
const compareVersion = (a: string, b: string): number => {
|
|
10
|
-
a = normalizeVersion(a);
|
|
11
|
-
b = normalizeVersion(b);
|
|
12
|
-
return a.localeCompare(b, undefined, { numeric: true });
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// Apply a comparator (equals, greater-than, etc) by its symbol to a sort comparison
|
|
16
|
-
const applyComparator = (comparisonResult: number, comparator: Comparator) => {
|
|
17
|
-
const comparators = {
|
|
18
|
-
'': (r: number) => r === 0,
|
|
19
|
-
'>': (r: number) => r > 0,
|
|
20
|
-
'>=': (r: number) => r >= 0,
|
|
21
|
-
'<': (r: number) => r < 0,
|
|
22
|
-
'<=': (r: number) => r <= 0
|
|
23
|
-
};
|
|
24
|
-
const comparatorFn = comparators[comparator] || comparators[''];
|
|
25
|
-
return comparatorFn(comparisonResult);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Check if a version satisfies all given version requirements
|
|
30
|
-
*
|
|
31
|
-
* versionSatisfies('2.1.0', ['>=2', '<4']) // true
|
|
32
|
-
* versionSatisfies('2.1.0', ['5']) // false
|
|
33
|
-
*
|
|
34
|
-
* @param {string} installed Installed version
|
|
35
|
-
* @param {Array.<string>} requirements Array of requirements that must be satisfied
|
|
36
|
-
* @returns boolean
|
|
37
|
-
*/
|
|
38
|
-
export const versionSatisfies = (installed: string, requirements: string[]) => {
|
|
39
|
-
return requirements.every((required) => {
|
|
40
|
-
const [, comparator, version] = required.match(/^([\D]+)?(.*)$/) || [];
|
|
41
|
-
const comparisonResult = compareVersion(installed, version);
|
|
42
|
-
return applyComparator(comparisonResult, (comparator as Comparator) || '>=');
|
|
43
|
-
});
|
|
44
|
-
};
|