aptechka 0.44.3 → 0.45.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/lib/{Animation-Je56LXXj.js → Animation-CKBO5DMV.js} +4 -3
- package/lib/Animation-CwizHYX9.cjs +1 -0
- package/lib/{Damped-BMmEn7PH.js → Damped-CucKOQsI.js} +5 -4
- package/lib/Damped-DbaLw6w1.cjs +1 -0
- package/lib/{Tweened-BNCj14Jz.js → Tweened-CcPeZ0UE.js} +7 -6
- package/lib/Tweened-Dm6Avip9.cjs +1 -0
- package/lib/animation/index.cjs +1 -1
- package/lib/animation/index.js +3 -3
- package/lib/controls/index.cjs +1 -1
- package/lib/controls/index.js +2 -2
- package/lib/morph/Morph.d.ts +14 -27
- package/lib/morph/MorphRoute.d.ts +23 -0
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.d.ts +1 -1
- package/lib/morph/index.js +322 -295
- package/lib/need_redo_tweaker/index.cjs +3 -3
- package/lib/need_redo_tweaker/index.js +61 -60
- package/lib/number-0243DApo.cjs +1 -0
- package/lib/number-DwCxt_Ck.js +33 -0
- package/lib/pointer/index.cjs +1 -1
- package/lib/pointer/index.js +1 -1
- package/lib/polyfills-DJrTJQky.js +24 -0
- package/lib/polyfills-Df4r-ETT.cjs +1 -0
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +3 -3
- package/lib/scroll-DNUlcfbO.js +22 -0
- package/lib/scroll-DPDSZypW.cjs +1 -0
- package/lib/scroll-segment/index.cjs +1 -1
- package/lib/scroll-segment/index.js +1 -1
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.js +158 -172
- package/lib/utils/polyfills.d.ts +1 -0
- package/lib/utils/scroll.d.ts +2 -1
- package/package.json +1 -1
- package/lib/Animation-D1lL_XhF.cjs +0 -1
- package/lib/Damped-BbJjFOLH.cjs +0 -1
- package/lib/Tweened-Dk1UNPSH.cjs +0 -1
- package/lib/polyfills-BANSrI_m.cjs +0 -1
- package/lib/polyfills-CxfUK5OU.js +0 -37
|
@@ -5,12 +5,13 @@ var S = (e, r, t) => r.has(e) || I("Cannot " + t);
|
|
|
5
5
|
var i = (e, r, t) => (S(e, r, "read from private field"), t ? t.call(e) : r.get(e)), a = (e, r, t) => r.has(e) ? I("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(e) : r.set(e, t), h = (e, r, t, u) => (S(e, r, "write to private field"), u ? u.call(e, t) : r.set(e, t), t), P = (e, r, t) => (S(e, r, "access private method"), t);
|
|
6
6
|
import { S as q } from "./Store-D2xCXENW.js";
|
|
7
7
|
import { c as y } from "./math-BOBiC4TN.js";
|
|
8
|
-
import { p as z
|
|
8
|
+
import { p as z } from "./number-DwCxt_Ck.js";
|
|
9
|
+
import { n as F } from "./polyfills-DJrTJQky.js";
|
|
9
10
|
import "./index-euf5anj6.js";
|
|
10
11
|
import { ticker as O } from "./ticker/index.js";
|
|
11
12
|
import { TICK_ORDER as N } from "./order/index.js";
|
|
12
13
|
var f, d, A, l, b, s, n, m, c, g, M, R, x;
|
|
13
|
-
class
|
|
14
|
+
class V extends q {
|
|
14
15
|
constructor(t, u) {
|
|
15
16
|
super(t || 0, u);
|
|
16
17
|
a(this, M);
|
|
@@ -102,5 +103,5 @@ f = new WeakMap(), d = new WeakMap(), A = new WeakMap(), l = new WeakMap(), b =
|
|
|
102
103
|
h(this, b, Math.sign(t - i(this, s))), h(this, s, y(t, i(this, n), i(this, m))), h(this, c, this.current);
|
|
103
104
|
}, x = new WeakMap();
|
|
104
105
|
export {
|
|
105
|
-
|
|
106
|
+
V as A
|
|
106
107
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var C=i=>{throw TypeError(i)};var S=(i,r,t)=>r.has(i)||C("Cannot "+t);var e=(i,r,t)=>(S(i,r,"read from private field"),t?t.call(i):r.get(i)),a=(i,r,t)=>r.has(i)?C("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(i):r.set(i,t),h=(i,r,t,n)=>(S(i,r,"write to private field"),n?n.call(i,t):r.set(i,t),t),M=(i,r,t)=>(S(i,r,"access private method"),t);const I=require("./Store-DRp_K37w.cjs"),N=require("./math-GDWEqu7y.cjs"),P=require("./number-0243DApo.cjs"),q=require("./polyfills-Df4r-ETT.cjs");require("./index-Cqw2NKev.cjs");const y=require("./ticker/index.cjs"),O=require("./order/index.cjs");var d,f,b,c,A,s,u,l,m,g,x,z,F;class R extends I.Store{constructor(t,n){super(t||0,n);a(this,x);a(this,d);a(this,f,O.TICK_ORDER.ANIMATION);a(this,b);a(this,c,new I.Store(!1));a(this,A,0);a(this,s,0);a(this,u,-1/0);a(this,l,1/0);a(this,m,0);a(this,g,null);a(this,F,t=>{this.handleAnimationFrame(t)});h(this,s,this.current)}get direction(){return e(this,A)}get target(){return e(this,s)}get min(){return e(this,u)}set min(t){h(this,u,t),this.set(e(this,s),{equalize:!0})}get max(){return e(this,l)}set max(t){h(this,l,t),this.set(e(this,s),{equalize:!0})}get from(){return e(this,m)}get isRunning(){return e(this,c)}get delta(){return Math.abs(e(this,s)-e(this,m))}get deltaProgress(){return this.delta?P.preciseNumber(Math.abs(this.current-e(this,m))/this.delta,6):0}get distance(){return Math.abs(e(this,l)-e(this,u))}get distanceProgress(){return this.distance?P.preciseNumber(Math.abs(this.current-e(this,u))/this.distance,6):0}set(t,n){(e(this,s)!==t||n!=null&&n.restart)&&(h(this,g,t),this.updateOptions(n),h(this,g,null),e(this,s)!==this.current&&this.start())}shift(t,n){this.set(e(this,s)+t,n)}reset(){super.reset(),this.set(this.initial,{equalize:!0})}close(){super.close(),this.reset(),this.unlistenAnimationFrame()}listenAnimationFrame(){e(this,c).current||(e(this,c).current=!0,y.ticker.subscribe(e(this,F),{maxFPS:e(this,d),order:e(this,f),culling:e(this,b)}))}unlistenAnimationFrame(){e(this,c).current&&(e(this,c).current=!1,y.ticker.unsubscribe(e(this,F)))}updateOptions(t){h(this,d,q.nullishCoalescing(t==null?void 0:t.maxFPS,e(this,d))),h(this,f,q.nullishCoalescing(t==null?void 0:t.order,e(this,f))),h(this,b,q.nullishCoalescing(t==null?void 0:t.culling,e(this,b))),h(this,u,q.nullishCoalescing(t==null?void 0:t.min,e(this,u))),h(this,l,q.nullishCoalescing(t==null?void 0:t.max,e(this,l))),M(this,x,z).call(this,typeof e(this,g)=="number"?e(this,g):e(this,s)),t!=null&&t.equalize&&(this.unlistenAnimationFrame(),this.current=e(this,s)),t!=null&&t.restart&&(this.unlistenAnimationFrame(),this.current=this.initial)}start(){this.listenAnimationFrame()}}d=new WeakMap,f=new WeakMap,b=new WeakMap,c=new WeakMap,A=new WeakMap,s=new WeakMap,u=new WeakMap,l=new WeakMap,m=new WeakMap,g=new WeakMap,x=new WeakSet,z=function(t){h(this,A,Math.sign(t-e(this,s))),h(this,s,N.clamp(t,e(this,u),e(this,l))),h(this,m,this.current)},F=new WeakMap;exports.Animation=R;
|
|
@@ -16,11 +16,12 @@ var f = (s, e, t) => e in s ? v(s, e, { enumerable: !0, configurable: !0, writab
|
|
|
16
16
|
var A = (s, e, t) => e.has(s) || g("Cannot " + t);
|
|
17
17
|
var a = (s, e, t) => (A(s, e, "read from private field"), t ? t.call(s) : e.get(s)), c = (s, e, t) => e.has(s) ? g("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), m = (s, e, t, r) => (A(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
|
|
18
18
|
import { d as D } from "./math-BOBiC4TN.js";
|
|
19
|
-
import {
|
|
19
|
+
import { p as F } from "./number-DwCxt_Ck.js";
|
|
20
|
+
import { n as u } from "./polyfills-DJrTJQky.js";
|
|
20
21
|
import "./index-euf5anj6.js";
|
|
21
|
-
import { A as q } from "./Animation-
|
|
22
|
+
import { A as q } from "./Animation-CKBO5DMV.js";
|
|
22
23
|
var i, h;
|
|
23
|
-
class
|
|
24
|
+
class E extends q {
|
|
24
25
|
constructor(t, r) {
|
|
25
26
|
super(t, r);
|
|
26
27
|
c(this, i);
|
|
@@ -50,5 +51,5 @@ class k extends q {
|
|
|
50
51
|
}
|
|
51
52
|
i = new WeakMap(), h = new WeakMap();
|
|
52
53
|
export {
|
|
53
|
-
|
|
54
|
+
E as D
|
|
54
55
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty,C=Object.defineProperties;var O=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var g=t=>{throw TypeError(t)};var d=(t,e,s)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,f=(t,e)=>{for(var s in e||(e={}))v.call(e,s)&&d(t,s,e[s]);if(l)for(var s of l(e))w.call(e,s)&&d(t,s,e[s]);return t},p=(t,e)=>C(t,O(e));var q=(t,e,s)=>e.has(t)||g("Cannot "+s);var a=(t,e,s)=>(q(t,e,"read from private field"),s?s.call(t):e.get(t)),c=(t,e,s)=>e.has(t)?g("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),n=(t,e,s,r)=>(q(t,e,"write to private field"),r?r.call(t,s):e.set(t,s),s);const B=require("./math-GDWEqu7y.cjs"),b=require("./number-0243DApo.cjs"),m=require("./polyfills-Df4r-ETT.cjs");require("./index-Cqw2NKev.cjs");const D=require("./Animation-CwizHYX9.cjs");var i,h;class N extends D.Animation{constructor(s,r){super(s,r);c(this,i);c(this,h);this.damping=20,this.stiffness=0,this.mass=0,n(this,i,0),n(this,h,0),this.updateOptions(p(f({},r),{equalize:!0}))}get velocity(){return a(this,i)}get speed(){return a(this,h)}updateOptions(s){this.damping=m.nullishCoalescing(s==null?void 0:s.damping,this.damping),this.mass=m.nullishCoalescing(s==null?void 0:s.mass,this.mass),this.stiffness=m.nullishCoalescing(s==null?void 0:s.stiffness,this.stiffness),super.updateOptions(s)}handleAnimationFrame(s){b.preciseNumber(this.current,6)===b.preciseNumber(this.target,6)&&(this.unlistenAnimationFrame(),this.current=this.target);const r=this.current,A=Math.abs(r-this.target);n(this,h,A/s.timeBetweenFrames);const u=s.timeBetweenFrames/1e3;if(this.mass||this.stiffness){const F=(this.target-this.current)*this.stiffness-a(this,i)*this.damping;n(this,i,a(this,i)+F/this.mass*u),this.current+=a(this,i)*u}else this.current=B.damp(this.current,this.target,this.damping,u)}}i=new WeakMap,h=new WeakMap;exports.Damped=N;
|
|
@@ -17,11 +17,12 @@ var A = (a, r, e) => r.has(a) || f("Cannot " + e);
|
|
|
17
17
|
var m = (a, r, e) => (A(a, r, "read from private field"), e ? e.call(a) : r.get(a)), n = (a, r, e) => r.has(a) ? f("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(a) : r.set(a, e), u = (a, r, e, i) => (A(a, r, "write to private field"), i ? i.call(a, e) : r.set(a, e), e);
|
|
18
18
|
import { l as h, e as T } from "./easings-Bni3YAAW.js";
|
|
19
19
|
import { c as q } from "./math-BOBiC4TN.js";
|
|
20
|
-
import {
|
|
20
|
+
import { p as w } from "./number-DwCxt_Ck.js";
|
|
21
|
+
import { n as z } from "./polyfills-DJrTJQky.js";
|
|
21
22
|
import "./index-euf5anj6.js";
|
|
22
|
-
import { A as C } from "./Animation-
|
|
23
|
+
import { A as C } from "./Animation-CKBO5DMV.js";
|
|
23
24
|
var s, t;
|
|
24
|
-
class
|
|
25
|
+
class G extends C {
|
|
25
26
|
constructor(e, i) {
|
|
26
27
|
super(e || 0, i);
|
|
27
28
|
n(this, s, h);
|
|
@@ -29,11 +30,11 @@ class D extends C {
|
|
|
29
30
|
this.updateOptions(g(d({}, i), { equalize: !0 }));
|
|
30
31
|
}
|
|
31
32
|
updateOptions(e) {
|
|
32
|
-
super.updateOptions(e), u(this, s, typeof (e == null ? void 0 : e.easing) == "function" ? e.easing : typeof (e == null ? void 0 : e.easing) == "string" ? T[e.easing] || h : h), u(this, t, (e == null ? void 0 : e.duration) === !1 ? 0 :
|
|
33
|
+
super.updateOptions(e), u(this, s, typeof (e == null ? void 0 : e.easing) == "function" ? e.easing : typeof (e == null ? void 0 : e.easing) == "string" ? T[e.easing] || h : h), u(this, t, (e == null ? void 0 : e.duration) === !1 ? 0 : z(e == null ? void 0 : e.duration, m(this, t)));
|
|
33
34
|
}
|
|
34
35
|
handleAnimationFrame(e) {
|
|
35
36
|
const i = e.timeElapsedSinceSubscription / 1e3 / (m(this, t) / 1e3) || 0, F = m(this, s).call(this, q(i, 0, 1));
|
|
36
|
-
this.current =
|
|
37
|
+
this.current = w(this.from + (this.target - this.from) * F, 6), i > 1 && this.unlistenAnimationFrame();
|
|
37
38
|
}
|
|
38
39
|
start() {
|
|
39
40
|
this.unlistenAnimationFrame(), this.listenAnimationFrame();
|
|
@@ -41,5 +42,5 @@ class D extends C {
|
|
|
41
42
|
}
|
|
42
43
|
s = new WeakMap(), t = new WeakMap();
|
|
43
44
|
export {
|
|
44
|
-
|
|
45
|
+
G as T
|
|
45
46
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var F=Object.defineProperty,b=Object.defineProperties;var y=Object.getOwnPropertyDescriptors;var m=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var d=i=>{throw TypeError(i)};var h=(i,r,e)=>r in i?F(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e,g=(i,r)=>{for(var e in r||(r={}))O.call(r,e)&&h(i,e,r[e]);if(m)for(var e of m(r))w.call(r,e)&&h(i,e,r[e]);return i},f=(i,r)=>b(i,y(r));var q=(i,r,e)=>r.has(i)||d("Cannot "+e);var s=(i,r,e)=>(q(i,r,"read from private field"),e?e.call(i):r.get(i)),c=(i,r,e)=>r.has(i)?d("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(i):r.set(i,e),l=(i,r,e,a)=>(q(i,r,"write to private field"),a?a.call(i,e):r.set(i,e),e);const u=require("./easings-GegIwET5.cjs"),S=require("./math-GDWEqu7y.cjs"),T=require("./number-0243DApo.cjs"),x=require("./polyfills-Df4r-ETT.cjs");require("./index-Cqw2NKev.cjs");const z=require("./Animation-CwizHYX9.cjs");var n,t;class C extends z.Animation{constructor(e,a){super(e||0,a);c(this,n,u.linear);c(this,t,1e3);this.updateOptions(f(g({},a),{equalize:!0}))}updateOptions(e){super.updateOptions(e),l(this,n,typeof(e==null?void 0:e.easing)=="function"?e.easing:typeof(e==null?void 0:e.easing)=="string"&&u.easings[e.easing]||u.linear),l(this,t,(e==null?void 0:e.duration)===!1?0:x.nullishCoalescing(e==null?void 0:e.duration,s(this,t)))}handleAnimationFrame(e){const a=e.timeElapsedSinceSubscription/1e3/(s(this,t)/1e3)||0,A=s(this,n).call(this,S.clamp(a,0,1));this.current=T.preciseNumber(this.from+(this.target-this.from)*A,6),a>1&&this.unlistenAnimationFrame()}start(){this.unlistenAnimationFrame(),this.listenAnimationFrame()}}n=new WeakMap,t=new WeakMap;exports.Tweened=C;
|
package/lib/animation/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../Animation-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../Animation-CwizHYX9.cjs"),n=require("../Damped-DbaLw6w1.cjs"),i=require("../Tweened-Dm6Avip9.cjs");exports.Animation=e.Animation;exports.Damped=n.Damped;exports.Tweened=i.Tweened;
|
package/lib/animation/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as r } from "../Animation-
|
|
2
|
-
import { D as m } from "../Damped-
|
|
3
|
-
import { T as t } from "../Tweened-
|
|
1
|
+
import { A as r } from "../Animation-CKBO5DMV.js";
|
|
2
|
+
import { D as m } from "../Damped-CucKOQsI.js";
|
|
3
|
+
import { T as t } from "../Tweened-CcPeZ0UE.js";
|
|
4
4
|
export {
|
|
5
5
|
r as Animation,
|
|
6
6
|
m as Damped,
|
package/lib/controls/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var V=h=>{throw TypeError(h)};var F=(h,n,e)=>n.has(h)||V("Cannot "+e);var t=(h,n,e)=>(F(h,n,"read from private field"),e?e.call(h):n.get(h)),s=(h,n,e)=>n.has(h)?V("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(h):n.set(h,e),i=(h,n,e,r)=>(F(h,n,"write to private field"),r?r.call(h,e):n.set(h,e),e),k=(h,n,e)=>(F(h,n,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("../notifier/index.cjs"),o=require("../index-Cqw2NKev.cjs"),Q=require("../dom-JBOkFLTh.cjs"),q=require("../ticker/index.cjs");require("../Store-DRp_K37w.cjs");const J=require("../easings-GegIwET5.cjs"),Z=require("../Tweened-
|
|
1
|
+
"use strict";var V=h=>{throw TypeError(h)};var F=(h,n,e)=>n.has(h)||V("Cannot "+e);var t=(h,n,e)=>(F(h,n,"read from private field"),e?e.call(h):n.get(h)),s=(h,n,e)=>n.has(h)?V("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(h):n.set(h,e),i=(h,n,e,r)=>(F(h,n,"write to private field"),r?r.call(h,e):n.set(h,e),e),k=(h,n,e)=>(F(h,n,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("../notifier/index.cjs"),o=require("../index-Cqw2NKev.cjs"),Q=require("../dom-JBOkFLTh.cjs"),q=require("../ticker/index.cjs");require("../Store-DRp_K37w.cjs");const J=require("../easings-GegIwET5.cjs"),Z=require("../Tweened-Dm6Avip9.cjs"),_=require("../gestures-DHLrn6Q8.cjs"),$=require("../number-0243DApo.cjs"),p=require("../order/index.cjs");var R;class Y{constructor(){s(this,R,new G.Notifier)}get changeEvent(){return t(this,R)}}R=new WeakMap;var g,c,u,H;class ee extends Y{constructor(e){super();s(this,g,null);s(this,c,null);s(this,u,"offsetHeight");s(this,H,e=>{const r=e.shiftKey?-1:1;let a;e.code==="Space"?a=r*t(this,c)[t(this,u)]*.4:e.code==="ArrowLeft"?a=-1*t(this,c)[t(this,u)]*.2:e.code==="ArrowRight"?a=1*t(this,c)[t(this,u)]*.2:e.code==="ArrowUp"?a=-1*t(this,c)[t(this,u)]*.2:e.code==="ArrowDown"?a=1*t(this,c)[t(this,u)]*.2:e.code==="PageUp"?a=-1*t(this,c)[t(this,u)]:e.code==="PageDown"?a=1*t(this,c)[t(this,u)]:e.code==="Home"?a=0:e.code==="End"&&(a=t(this,u)==="offsetWidth"?t(this,c).scrollWidth:t(this,c).scrollHeight),a&&(e.stopPropagation(),this.changeEvent.notify("keyboard",a))});o.isBrowser&&(i(this,g,e!=null&&e.element&&Q.getElement(e.element)||window),i(this,c,t(this,g)instanceof HTMLElement?t(this,g):document.documentElement),this.dimension=e==null?void 0:e.dimension)}set dimension(e){i(this,u,e==="width"?"offsetWidth":"offsetHeight")}connect(){o.isBrowser&&t(this,g).addEventListener("keydown",t(this,H))}disconnect(){o.isBrowser&&t(this,g).removeEventListener("keydown",t(this,H))}}g=new WeakMap,c=new WeakMap,u=new WeakMap,H=new WeakMap;var b,x,P,z,d,T,f,w,O,U,C,W,B;class te extends Y{constructor(e){super();s(this,w);s(this,b);s(this,x);s(this,P);s(this,z);s(this,d);s(this,T);s(this,f);s(this,C);s(this,W);s(this,B);this.direction=1,i(this,d,new Z.Tweened(0,{easing:J.easeInQuad})),i(this,f,!1),i(this,C,r=>{t(this,d).current!==1&&this.changeEvent.notify("autoplay",r.timeBetweenFrames*t(this,b)*this.direction*(1-t(this,d).current))}),i(this,W,()=>{t(this,d).current!==1&&this.changeEvent.notify("autoplay",Math.sign(t(this,b))*this.direction*(1-t(this,d).current))}),i(this,B,()=>{t(this,x)&&(document.hidden?t(this,d).set(1,{equalize:!0}):t(this,d).set(0,{equalize:!0}))}),i(this,b,(e==null?void 0:e.speed)||1),i(this,x,(e==null?void 0:e.interval)||!1),i(this,P,e)}set interval(e){i(this,x,e),t(this,f)&&k(this,w,O).call(this)}set speed(e){i(this,b,e),t(this,f)&&k(this,w,O).call(this)}connect(){t(this,f)||(i(this,f,!0),k(this,w,O).call(this))}disconnect(){t(this,f)&&(i(this,f,!1),k(this,w,U).call(this))}pauseAndContinue(e,r){t(this,f)&&e&&(clearTimeout(t(this,T)),t(this,d).set(1,{duration:Math.min(e,1e3),equalize:r}),i(this,T,setTimeout(()=>{t(this,d).set(0,{duration:Math.min(e,5e3),equalize:r})},e)))}}b=new WeakMap,x=new WeakMap,P=new WeakMap,z=new WeakMap,d=new WeakMap,T=new WeakMap,f=new WeakMap,w=new WeakSet,O=function(){k(this,w,U).call(this),t(this,x)?i(this,z,setInterval(t(this,W),Math.abs(t(this,b)))):q.ticker.subscribe(t(this,C),t(this,P)),document.addEventListener("visibilitychange",t(this,B))},U=function(){clearInterval(t(this,z)),q.ticker.unsubscribe(t(this,C)),clearTimeout(t(this,T)),t(this,d).close(),document.removeEventListener("visibilitychange",t(this,B))},C=new WeakMap,W=new WeakMap,B=new WeakMap;var A,v,D,X;class ie extends Y{constructor(e){super();s(this,A,null);s(this,v);s(this,D);s(this,X,e=>{let r=0;if(!(this.axis==="x"&&Math.abs(e.deltaY)>Math.abs(e.deltaX)*1||this.axis==="y"&&Math.abs(e.deltaX)>Math.abs(e.deltaY)*1))if(e.preventDefault(),r=(this.axis==="max"?Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.deltaY:this.axis==="x"?e.deltaX:e.deltaY)*this.speed,e.stopPropagation(),this.debounce){const a=Date.now();if(a-t(this,D)>40&&(r=100*Math.sign(r)),i(this,D,a),Math.abs(r)<100||t(this,v))return;this.changeEvent.notify("wheel",r),i(this,v,setTimeout(()=>{i(this,v,void 0)},80))}else this.changeEvent.notify("wheel",r)});this.axis=(e==null?void 0:e.axis)||"y",this.speed=(e==null?void 0:e.speed)||1,this.debounce=(e==null?void 0:e.debounce)||!1,i(this,D,Date.now()),o.isBrowser&&i(this,A,e!=null&&e.element&&Q.getElement(e.element)||window)}connect(){o.isBrowser&&t(this,A).addEventListener("wheel",t(this,X),{passive:!1})}disconnect(){o.isBrowser&&(t(this,A).removeEventListener("wheel",t(this,X)),clearTimeout(t(this,v)))}}A=new WeakMap,v=new WeakMap,D=new WeakMap,X=new WeakMap;var L,m,l,I,y;const E=class E extends Y{constructor(e){super();s(this,m);s(this,l);s(this,I);s(this,y);this.inertion=1,i(this,m,null),i(this,l,0),i(this,I,r=>{if(r.composedPath().find(M=>M instanceof HTMLElement&&M.hasAttribute("drag-dead-zone")))return;this.swipe||q.ticker.unsubscribe(t(this,y));let a=r,S=!1;i(this,l,0),document.documentElement.classList.add("grabbing");let K=0,N=0;_.setupDrag(M=>{t(E,L)&&t(E,L)!==t(this,m)||(K=a.x-M.x,N=a.y-M.y,this.axis==="x"?i(this,l,K):i(this,l,N),a=M,S=this.axis==="x"&&Math.abs(K)>Math.abs(N)||this.axis==="y"&&Math.abs(N)>Math.abs(K),S&&(document.documentElement.classList.add("dragging"),i(E,L,t(this,m)),this.changeEvent.notify("drag",t(this,l))))},()=>{i(E,L,null),S&&!this.swipe&&this.inertion?(i(this,l,t(this,l)*this.inertion),q.ticker.subscribe(t(this,y),{order:p.TICK_ORDER.CONTROLS-1})):this.swipe&&this.changeEvent.notify("drag-end",t(this,l)),document.documentElement.classList.remove("grabbing"),document.documentElement.classList.remove("dragging")})}),i(this,y,()=>{Math.floor(Math.abs(t(this,l)))||q.ticker.unsubscribe(t(this,y)),i(this,l,t(this,l)*.95),i(this,l,$.preciseNumber(t(this,l),3)),this.changeEvent.notify("drag",t(this,l))}),this.axis=(e==null?void 0:e.axis)||"y",this.swipe=(e==null?void 0:e.swipe)||!1,o.isBrowser&&i(this,m,e!=null&&e.element&&Q.getElement(e.element)||document.documentElement)}connect(){o.isBrowser&&t(this,m).addEventListener("pointerdown",t(this,I))}disconnect(){o.isBrowser&&(t(this,m).removeEventListener("pointerdown",t(this,I)),q.ticker.unsubscribe(t(this,y)))}};L=new WeakMap,m=new WeakMap,l=new WeakMap,I=new WeakMap,y=new WeakMap,s(E,L,null);let j=E;exports.AutoplayControls=te;exports.Controls=Y;exports.DragControls=j;exports.KeyboardControls=ee;exports.WheelControls=ie;
|
package/lib/controls/index.js
CHANGED
|
@@ -9,9 +9,9 @@ import { g as Q } from "../dom-CVWzyXPH.js";
|
|
|
9
9
|
import { ticker as k } from "../ticker/index.js";
|
|
10
10
|
import "../Store-D2xCXENW.js";
|
|
11
11
|
import { b as J } from "../easings-Bni3YAAW.js";
|
|
12
|
-
import { T as Z } from "../Tweened-
|
|
12
|
+
import { T as Z } from "../Tweened-CcPeZ0UE.js";
|
|
13
13
|
import { s as $ } from "../gestures-D2Fdra_G.js";
|
|
14
|
-
import { p } from "../
|
|
14
|
+
import { p } from "../number-DwCxt_Ck.js";
|
|
15
15
|
import { TICK_ORDER as _ } from "../order/index.js";
|
|
16
16
|
var O;
|
|
17
17
|
class B {
|
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { ChangeHistoryAction } from '../utils';
|
|
1
|
+
import { ChangeHistoryAction, ElementOrSelector } from '../utils';
|
|
2
2
|
import { MorphLink } from './MorphLink';
|
|
3
|
-
export interface
|
|
4
|
-
base
|
|
5
|
-
waitForHeadToLoad
|
|
6
|
-
cachePages
|
|
7
|
-
trailingSlash
|
|
3
|
+
export interface MorphOptions {
|
|
4
|
+
base: string;
|
|
5
|
+
waitForHeadToLoad: boolean;
|
|
6
|
+
cachePages: boolean;
|
|
7
|
+
trailingSlash: boolean;
|
|
8
|
+
scrollSelector: string;
|
|
8
9
|
}
|
|
9
10
|
export interface MorphNavigationEntry {
|
|
10
11
|
pathname: string;
|
|
11
|
-
isCached: boolean;
|
|
12
|
-
state?: any;
|
|
13
12
|
}
|
|
14
13
|
export interface MorphTransitionEntry extends MorphNavigationEntry {
|
|
15
|
-
newDocument: Document;
|
|
16
14
|
}
|
|
17
15
|
export interface MorphChildrenActionEntry {
|
|
18
16
|
morphElement: HTMLElement;
|
|
19
17
|
pathname: string;
|
|
20
|
-
isCached: boolean;
|
|
21
|
-
state?: any;
|
|
22
18
|
}
|
|
23
19
|
export interface MorphPreprocessorEntry extends MorphNavigationEntry {
|
|
24
20
|
resolve: () => void;
|
|
@@ -26,19 +22,11 @@ export interface MorphPreprocessorEntry extends MorphNavigationEntry {
|
|
|
26
22
|
}
|
|
27
23
|
export type MorphPreprocessor = (entry: MorphPreprocessorEntry) => void;
|
|
28
24
|
export type MorphNavigationCallback = (entry: MorphNavigationEntry) => void;
|
|
29
|
-
export type MorphPostprocessor = MorphNavigationCallback;
|
|
30
|
-
export interface MorphScrollState {
|
|
31
|
-
x: number;
|
|
32
|
-
y: number;
|
|
33
|
-
selector: string;
|
|
34
|
-
}
|
|
35
25
|
export interface MorphNavigateOptions {
|
|
36
26
|
historyAction?: ChangeHistoryAction;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
restoreScrollState?: boolean;
|
|
41
|
-
restoreDocumentState?: boolean;
|
|
27
|
+
centerScroll?: boolean;
|
|
28
|
+
offsetScroll?: number | ElementOrSelector<HTMLElement>;
|
|
29
|
+
revalidate?: boolean;
|
|
42
30
|
}
|
|
43
31
|
export interface MorphEvents {
|
|
44
32
|
morphStart: CustomEvent<MorphTransitionEntry>;
|
|
@@ -49,20 +37,19 @@ export interface MorphEvents {
|
|
|
49
37
|
export declare class Morph {
|
|
50
38
|
#private;
|
|
51
39
|
preprocessor?: MorphPreprocessor;
|
|
52
|
-
|
|
53
|
-
constructor(parameters?: MorphParameters);
|
|
40
|
+
constructor(parameters?: Partial<MorphOptions>);
|
|
54
41
|
get currentPathname(): string;
|
|
55
42
|
get previousPathname(): string | undefined;
|
|
56
|
-
get currentState(): any;
|
|
57
43
|
get links(): MorphLink[];
|
|
44
|
+
get scrollElement(): HTMLElement;
|
|
58
45
|
normalizePath(path: string): {
|
|
59
46
|
leaf: string;
|
|
60
47
|
pathname: string;
|
|
61
48
|
parameters: string;
|
|
62
49
|
hash: string;
|
|
63
50
|
};
|
|
64
|
-
prefetch(path: string): Promise<
|
|
65
|
-
navigate(path: string, { historyAction,
|
|
51
|
+
prefetch(path: string): Promise<void>;
|
|
52
|
+
navigate(path: string, { historyAction, centerScroll, offsetScroll, revalidate, }?: MorphNavigateOptions): Promise<void>;
|
|
66
53
|
addLink(element: HTMLAnchorElement): void;
|
|
67
54
|
addLinks(elements: Array<HTMLAnchorElement>): void;
|
|
68
55
|
removeLink(element: HTMLAnchorElement): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Morph } from './Morph';
|
|
2
|
+
export interface MorphRouteScrollState {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface MorphRouteSaveState {
|
|
7
|
+
scroll?: MorphRouteScrollState | undefined;
|
|
8
|
+
document?: Document | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare class MorphRoute {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(morph: Morph, pathname: string, initialDocument: Document);
|
|
13
|
+
get pathname(): string;
|
|
14
|
+
get scrollState(): MorphRouteScrollState;
|
|
15
|
+
get document(): Document;
|
|
16
|
+
cloneDocument(): void;
|
|
17
|
+
get title(): string;
|
|
18
|
+
clearScrollState(): void;
|
|
19
|
+
clearDocumentState(): void;
|
|
20
|
+
saveScrollState(): void;
|
|
21
|
+
saveDocumentState(): void;
|
|
22
|
+
restoreScrollPosition(): void;
|
|
23
|
+
}
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Et=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),St=r=>{throw TypeError(r)};var ot=(r,e,s)=>e.has(r)||St("Cannot "+s);var t=(r,e,s)=>(ot(r,e,"read from private field"),s?s.call(r):e.get(r)),o=(r,e,s)=>e.has(r)?St("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,s),a=(r,e,s,n)=>(ot(r,e,"write to private field"),n?n.call(r,s):e.set(r,s),s),A=(r,e,s)=>(ot(r,e,"access private method"),s);var O=(r,e,s)=>new Promise((n,c)=>{var d=f=>{try{p(s.next(f))}catch(M){c(M)}},y=f=>{try{p(s.throw(f))}catch(M){c(M)}},p=f=>f.done?n(f.value):Promise.resolve(f.value).then(d,y);p((s=s.apply(r,e)).next())});var wt=(r,e,s)=>(e=r[Et("asyncIterator")])?e.call(r):(r=r[Et("iterator")](),e={},s=(n,c)=>(c=r[n])&&(e[n]=d=>new Promise((y,p,f)=>(d=c.call(r,d),f=d.done,Promise.resolve(d.value).then(M=>y({value:M,done:f}),p)))),s("next"),s("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const yt=require("../loading/index.cjs"),At=require("../index-Cqw2NKev.cjs"),st=require("../events-KVanG9sR.cjs"),it=require("../url-CLvdjbII.cjs"),Dt=require("../dom-JBOkFLTh.cjs");var C,h,v,B,L,F,j,W,Y,x,K,D;class bt{constructor(e,s){o(this,C);o(this,h);o(this,v);o(this,B);o(this,L,null);o(this,F,!1);o(this,j,!1);o(this,W,!1);o(this,Y);o(this,x);o(this,K,e=>{e.preventDefault(),t(this,C).links.forEach(n=>{var c;t(this,v)===t(n,v)||(c=t(n,x))!=null&&c.includes(t(this,v))?t(n,h).classList.add("clicked"):t(n,h).classList.remove("clicked")});let s;t(this,L)&&(s={x:t(this,L).scrollLeft,y:t(this,L).scrollTop,selector:t(this,L).id?"#"+t(this,L).id:""}),t(this,C).navigate(t(this,v),{historyAction:t(this,B),state:t(this,Y),saveScrollState:s,saveDocumentState:t(this,F),restoreDocumentState:t(this,W),restoreScrollState:t(this,j)})});o(this,D,()=>{t(this,C).prefetch(t(this,v)),t(this,h).removeEventListener("pointerenter",t(this,D))});var y,p;a(this,C,s),a(this,h,e),a(this,v,t(this,h).getAttribute("href")||"/"),a(this,B,t(this,h).getAttribute("data-history-action")||"push");const n=t(this,h).getAttribute("data-save-scroll-state");typeof n=="string"&&(n===""?a(this,L,Dt.findScrollParentElement(t(this,h))):a(this,L,document.getElementById(n))),a(this,F,t(this,h).hasAttribute("data-save-document-state")),a(this,W,t(this,h).hasAttribute("data-restore-document-state")),a(this,j,t(this,h).hasAttribute("data-restore-scroll-state")),a(this,Y,t(this,h).getAttribute("data-state")||void 0),t(this,h).addEventListener("click",t(this,K));const c=s.normalizePath(t(this,v)),d=s.normalizePath(location.pathname);a(this,x,(y=t(this,h).getAttribute("data-match-paths"))==null?void 0:y.split(",").map(f=>s.normalizePath(f.trim()).pathname)),t(this,h).hasAttribute("data-include")?d.pathname.includes(c.pathname)&&t(this,h).classList.add("current"):c.pathname===d.pathname||(p=t(this,x))!=null&&p.includes(d.pathname)?(t(this,h).classList.add("current"),t(this,h).classList.add("clicked")):t(this,h).classList.remove("clicked"),t(this,h).hasAttribute("data-prefetch")&&t(this,h).addEventListener("pointerenter",t(this,D))}get element(){return t(this,h)}destroy(){t(this,h).removeEventListener("click",t(this,K)),t(this,h).removeEventListener("pointerenter",t(this,D)),t(this,h).classList.remove("current")}}C=new WeakMap,h=new WeakMap,v=new WeakMap,B=new WeakMap,L=new WeakMap,F=new WeakMap,j=new WeakMap,W=new WeakMap,Y=new WeakMap,x=new WeakMap,K=new WeakMap,D=new WeakMap;class Pt extends HTMLElement{connectedCallback(){const e={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,n]of Object.entries(e))this.setAttribute(s,n)}}At.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Pt);var V,G,J,Q,q,S,nt,k,P,E,U,X,H,w,z,R,T,m,ht,ct,Tt,lt,at;class qt{constructor(e){o(this,m);o(this,V,null);o(this,G,null);o(this,J,null);o(this,Q,!1);o(this,q,null);o(this,S,[]);o(this,nt,new DOMParser);o(this,k,new Map);o(this,P);o(this,E,null);o(this,U);o(this,X);o(this,H,[]);o(this,w);o(this,z);o(this,R,!1);o(this,T,null);o(this,at,e=>{var s;(s=e.state)!=null&&s.path&&(a(this,R,!0),this.navigate(e.state.path,{historyAction:"none"}),a(this,R,!1))});if(At.isBrowser){a(this,V,it.normalizeBase(e==null?void 0:e.base)),a(this,G,(e==null?void 0:e.waitForHeadToLoad)!==!1),a(this,J,(e==null?void 0:e.cachePages)!==!1),a(this,Q,(e==null?void 0:e.trailingSlash)||!1),a(this,q,A(this,m,ct).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,E,s.pathname),document.documentElement.setAttribute("data-current-pathname",t(this,E)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",t(this,at)),it.changeHistory({action:"replace",pathname:t(this,E),searchParameters:s.parameters,hash:s.hash}),t(this,q).map(n=>[...n.children]).flat().forEach(n=>{n instanceof HTMLElement&&n.classList.add("current")}),a(this,T,new Pt)}}get currentPathname(){return t(this,E)}get previousPathname(){return t(this,U)}get currentState(){return t(this,X)}get links(){return t(this,S)}normalizePath(e){return it.splitPath(e,{base:t(this,V),trailingSlash:t(this,Q)})}prefetch(e){return O(this,null,function*(){const s=this.normalizePath(e);return A(this,m,ht).call(this,s.pathname)})}navigate(f){return O(this,arguments,function*(e,{historyAction:s="push",state:n,saveScrollState:c,saveDocumentState:d,restoreDocumentState:y,restoreScrollState:p}={}){var dt;if(t(this,H).length)return;t(this,R)||(y||a(this,z,void 0),p||a(this,w,void 0));const M=this.normalizePath(e);let{pathname:l,hash:Mt,parameters:Ct,leaf:kt}=M;if(t(this,P)===l||t(this,E)===l)return;a(this,X,n),a(this,P,l);const Z=t(this,k).has(l);try{yt.loading.add("__morph");let $=!0;if(this.preprocessor)try{yield new Promise((i,g)=>{var b;(b=this.preprocessor)==null||b.call(this,{pathname:l,resolve:i,reject:g,isCached:Z,state:n})})}catch(i){i?console.error(i):console.log("Route change canceled"),$=!1}if(!$||t(this,P)!==l)return;const N=(t(this,z)||t(this,k).get(l)||(yield A(this,m,ht).call(this,l))).cloneNode(!0);if(t(this,P)!==l)return;if(a(this,z,d?document.cloneNode(!0):void 0),N.title)t(this,T).textContent=N.title;else{const i=N.querySelector("h1"),g=(i==null?void 0:i.innerText)||(i==null?void 0:i.textContent)||l;t(this,T).textContent=g}document.body.appendChild(t(this,T));const ut={pathname:l,isCached:Z,state:n,newDocument:N};st.dispatchEvent(document,"morphStart",{detail:ut});const mt=Array.from(document.head.children),ft=Array.from(N.head.children),pt=A(this,m,Tt).call(this,mt,ft),Ht=A(this,m,lt).call(this,mt,pt),tt=A(this,m,lt).call(this,ft,pt);tt.forEach((i,g)=>{if(i.tagName==="SCRIPT"&&i.getAttribute("src")){const b=document.createElement("script");b.type="module",b.src=i.getAttribute("src"),tt[g]=b}}),tt.forEach(i=>{document.head.appendChild(i)});const rt=tt.filter(i=>!i.hasAttribute("data-no-waiting")&&(i.tagName==="STYLE"||i.tagName==="SCRIPT"||i.tagName==="LINK")&&i.getAttribute("rel")!=="canonical");t(this,G)&&rt.length&&(yield new Promise(i=>O(this,null,function*(){let g=0;try{for(var b=wt(rt),vt,_,Lt;vt=!(_=yield b.next()).done;vt=!1){const et=_.value;et.onload=()=>{g++,g===rt.length&&i()}}}catch(_){Lt=[_]}finally{try{vt&&(_=b.return)&&(yield _.call(b))}finally{if(Lt)throw Lt[0]}}})));const gt=[];Ht.forEach(i=>{i.hasAttribute("data-permanent")||(i.tagName==="SCRIPT"||i.tagName==="STYLE"||i.getAttribute("rel")==="stylesheet"?gt.push(i):i.remove())}),a(this,U,t(this,E)),a(this,E,l),it.changeHistory({action:s,pathname:l,searchParameters:Ct,hash:Mt});const Nt=A(this,m,ct).call(this,N.body);t(this,q).forEach((i,g)=>{const b=Nt[g++],vt=getComputedStyle(i).getPropertyValue("--morph-duration"),_=[...b.childNodes];if(vt){const Lt=[...i.childNodes];if(Lt.forEach(u=>{u instanceof HTMLElement&&u.classList.add("old")}),_.forEach(u=>{u instanceof HTMLElement&&(u.classList.remove("current"),u.classList.add("new"))}),i.prepend(..._),t(this,w)){const u=document.querySelector(t(this,w).selector);u&&u.scroll({top:t(this,w).y,left:t(this,w).x,behavior:"auto"})}setTimeout(()=>{_.forEach(u=>{u instanceof HTMLElement&&u.classList.add("in")})},10);const et={morphElement:i,pathname:l,isCached:Z,state:n};st.dispatchEvent(document,"morphNewChildrenAdded",{detail:et});const xt=new Promise(u=>{setTimeout(()=>{Lt.forEach(I=>I.remove()),_.forEach(I=>{I instanceof HTMLElement&&(I.classList.remove("new","in"),I.classList.add("current"))}),st.dispatchEvent(document,"morphOldChildrenRemoved",{detail:et}),u()},(parseFloat(vt)||0)*1e3+10)});t(this,H).push(xt)}else i.innerHTML="",i.append(..._)}),yield Promise.all(t(this,H)),gt.forEach(i=>i.remove()),a(this,H,[]),a(this,w,c),this.findLinks(),document.documentElement.setAttribute("data-current-pathname",l),document.documentElement.setAttribute("data-current-leaf",kt),t(this,T).remove(),(dt=this.postprocessor)==null||dt.call(this,{pathname:l,isCached:Z,state:n}),st.dispatchEvent(document,"morphComplete",{detail:ut}),yt.loading.complete("__morph")}catch($){console.error($)}a(this,P,void 0)})}addLink(e){t(this,S).push(new bt(e,this))}addLinks(e){e.forEach(s=>{this.addLink(s)})}removeLink(e){a(this,S,t(this,S).filter(s=>s.element===e?(s.destroy(),!1):!0))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(s=>{var n;return((n=s.getAttribute("href"))==null?void 0:n.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});t(this,S).forEach(s=>s.destroy()),a(this,S,e.map(s=>new bt(s,this)))}}V=new WeakMap,G=new WeakMap,J=new WeakMap,Q=new WeakMap,q=new WeakMap,S=new WeakMap,nt=new WeakMap,k=new WeakMap,P=new WeakMap,E=new WeakMap,U=new WeakMap,X=new WeakMap,H=new WeakMap,w=new WeakMap,z=new WeakMap,R=new WeakMap,T=new WeakMap,m=new WeakSet,ht=function(e){return O(this,null,function*(){const s=t(this,k).get(e);if(s)return s;const c=yield(yield fetch(e)).text(),d=t(this,nt).parseFromString(c,"text/html");return t(this,J)&&t(this,k).set(e,d),d})},ct=function(e){const s=[...e.querySelectorAll("[data-morph]")];return s.length?s:[e]},Tt=function(e,s){return e.filter(n=>s.find(c=>c.outerHTML===n.outerHTML))},lt=function(e,s){return e.filter(n=>!s.find(c=>c.outerHTML===n.outerHTML))},at=new WeakMap;exports.Morph=qt;
|
|
1
|
+
"use strict";var ft=(i,t)=>(t=Symbol[i])?t:Symbol.for("Symbol."+i),pt=i=>{throw TypeError(i)};var $=(i,t,s)=>t.has(i)||pt("Cannot "+s);var e=(i,t,s)=>($(i,t,"read from private field"),s?s.call(i):t.get(i)),o=(i,t,s)=>t.has(i)?pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),a=(i,t,s,r)=>($(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s),d=(i,t,s)=>($(i,t,"access private method"),s);var M=(i,t,s)=>new Promise((r,u)=>{var m=l=>{try{A(s.next(l))}catch(g){u(g)}},V=l=>{try{A(s.throw(l))}catch(g){u(g)}},A=l=>l.done?r(l.value):Promise.resolve(l.value).then(m,V);A((s=s.apply(i,t)).next())});var Et=(i,t,s)=>(t=i[ft("asyncIterator")])?t.call(i):(i=i[ft("iterator")](),t={},s=(r,u)=>(u=i[r])&&(t[r]=m=>new Promise((V,A,l)=>(m=u.call(i,m),l=m.done,Promise.resolve(m.value).then(g=>V({value:g,done:l}),A)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),J=require("../events-KVanG9sR.cjs"),Tt=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DPDSZypW.cjs"),Q=require("../url-CLvdjbII.cjs"),Ht=require("../css-value-parser/index.cjs");class yt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,r]of Object.entries(t))this.setAttribute(s,r)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",yt);var R,h,T,O,q;class gt{constructor(t,s){o(this,R);o(this,h);o(this,T);o(this,O,t=>{t.preventDefault();const s=e(this,h).getAttribute("data-history-action")||"push",r=e(this,h).hasAttribute("data-center-scroll"),u=getComputedStyle(e(this,h)).getPropertyValue("--offset-scroll").trim(),m=u?Ht.cssValueParser.parse(u):void 0,V=e(this,h).hasAttribute("data-revalidate");e(this,R).navigate(e(this,T),{historyAction:s,centerScroll:r,offsetScroll:m,revalidate:V})});o(this,q,()=>{e(this,R).prefetch(e(this,T)),e(this,h).removeEventListener("pointerenter",e(this,q))});a(this,R,s),a(this,h,t),a(this,T,e(this,h).getAttribute("href")||"/"),e(this,h).addEventListener("click",e(this,O));const r=s.normalizePath(e(this,T)),u=s.normalizePath(location.pathname);e(this,h).hasAttribute("data-include")&&u.pathname.includes(r.pathname)?e(this,h).classList.add("current"):r.pathname===u.pathname&&e(this,h).classList.add("current"),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,q))}get element(){return e(this,h)}destroy(){e(this,h).removeEventListener("click",e(this,O)),e(this,h).removeEventListener("pointerenter",e(this,q)),e(this,h).classList.remove("current")}}R=new WeakMap,h=new WeakMap,T=new WeakMap,O=new WeakMap,q=new WeakMap;var C,z,p,H,k,w;class vt{constructor(t,s,r){o(this,C);o(this,z);o(this,p,{x:0,y:0});o(this,H);o(this,k,null);o(this,w,null);a(this,C,t),a(this,z,s),a(this,H,r.cloneNode(!0))}get pathname(){return e(this,z)}get scrollState(){return e(this,p)}get document(){return e(this,w)}cloneDocument(){a(this,w,(e(this,k)||e(this,H)).cloneNode(!0))}get title(){let t="";if(e(this,w).title)t=e(this,w).title;else{const s=e(this,w).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,z)}return t}clearScrollState(){e(this,p).x=0,e(this,p).y=0}clearDocumentState(){a(this,k,null)}saveScrollState(){e(this,H).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,C).scrollElement.scrollLeft,e(this,p).y=e(this,C).scrollElement.scrollTop)}saveDocumentState(){e(this,H).documentElement.hasAttribute("data-no-page-restoration")?a(this,k,null):a(this,k,document.cloneNode(!0))}restoreScrollPosition(){e(this,C).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}C=new WeakMap,z=new WeakMap,p=new WeakMap,H=new WeakMap,k=new WeakMap,w=new WeakMap;var b,W,v,U,P,f,j,x,N,F,I,D,c,tt,et,st,Lt,it,nt,rt,X;class kt{constructor(t){o(this,c);o(this,b,null);o(this,W,null);o(this,v,[]);o(this,U,new DOMParser);o(this,P);o(this,f,null);o(this,j);o(this,x,[]);o(this,N,!1);o(this,F,null);o(this,I,new Map);o(this,D,null);o(this,X,t=>M(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(a(this,N,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,N,!1))}));if(St.isBrowser){a(this,b,{base:Q.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body"}),a(this,W,d(this,c,st).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,f,s.pathname),e(this,I).set(e(this,f),new vt(this,e(this,f),document)),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,X)),Q.changeHistory({action:"replace",pathname:e(this,f),searchParameters:s.parameters,hash:s.hash}),a(this,D,new yt),d(this,c,rt).call(this)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,j)}get links(){return e(this,v)}get scrollElement(){return e(this,F)}normalizePath(t){return Q.splitPath(t,{base:e(this,b).base,trailingSlash:e(this,b).trailingSlash})}prefetch(t){return M(this,null,function*(){const s=this.normalizePath(t);d(this,c,et).call(this,s.pathname)})}navigate(V){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:r,offsetScroll:u,revalidate:m}={}){if(e(this,x).length)return;const A=this.normalizePath(t);let{pathname:l,hash:g,parameters:wt,leaf:bt}=A;if(!(e(this,P)===l||e(this,f)===l)){a(this,P,l);try{let _=!0;if(this.preprocessor)try{yield new Promise((n,y)=>{var L;(L=this.preprocessor)==null||L.call(this,{pathname:l,resolve:n,reject:y})})}catch(n){n?console.error(n):console.log("Route change canceled"),_=!1}if(!_||e(this,P)!==l)return;const ot=yield d(this,c,tt).call(this,e(this,f)),S=yield d(this,c,tt).call(this,l,m);if(e(this,P)!==l)return;ot.saveScrollState(),ot.saveDocumentState(),e(this,N)||(S.clearScrollState(),S.clearDocumentState()),S.cloneDocument(),e(this,D).textContent=S.title,document.body.appendChild(e(this,D));const at={pathname:l};J.dispatchEvent(document,"morphStart",{detail:at});const lt=Array.from(document.head.children),ct=Array.from(S.document.head.children),ht=d(this,c,Lt).call(this,lt,ct),Pt=d(this,c,it).call(this,lt,ht),K=d(this,c,it).call(this,ct,ht);K.forEach((n,y)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const L=document.createElement("script");L.type="module",L.src=n.getAttribute("src"),K[y]=L}}),K.forEach(n=>{document.head.appendChild(n)});const Z=K.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(d(this,c,nt).call(this,n))return!0});e(this,b).waitForHeadToLoad&&Z.length&&(yield new Promise(n=>M(this,null,function*(){let y=0;try{for(var L=Et(Z),dt,B,mt;dt=!(B=yield L.next()).done;dt=!1){const Y=B.value;Y.onload=()=>{y++,y===Z.length&&n()}}}catch(B){mt=[B]}finally{try{dt&&(B=L.return)&&(yield B.call(L))}finally{if(mt)throw mt[0]}}})));const ut=[];Pt.forEach(n=>{n.hasAttribute("data-permanent")||(d(this,c,nt).call(this,n)?ut.push(n):n.remove())});const At=d(this,c,st).call(this,S.document.body);if(e(this,W).forEach((n,y)=>{const L=At[y],dt=getComputedStyle(n).getPropertyValue("--morph-duration"),B=[...L.childNodes];if(dt){const mt=[...n.childNodes];mt.forEach(E=>{E instanceof HTMLElement&&E.classList.add("old")}),B.forEach(E=>{E instanceof HTMLElement&&E.classList.add("new")}),n.prepend(...B),Tt.requestIdleCallback(()=>{B.forEach(E=>{E instanceof HTMLElement&&E.classList.add("in")})});const Y={morphElement:n,pathname:l};J.dispatchEvent(document,"morphNewChildrenAdded",{detail:Y});const Mt=new Promise(E=>{setTimeout(()=>{mt.forEach(G=>G.remove()),B.forEach(G=>{G instanceof HTMLElement&&G.classList.remove("in","new")}),J.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Y}),E()},(parseFloat(dt)||0)*1e3+10)});e(this,x).push(Mt)}else n.innerHTML="",n.append(...B)}),d(this,c,rt).call(this),g){S.clearScrollState();const n=document.getElementById(g);n instanceof HTMLElement&&Ct.scrollToElement(n,{scrollElement:e(this,F),behaviour:"instant",center:r,offset:u})}else e(this,N)&&S.restoreScrollPosition();yield Promise.all(e(this,x)),ut.forEach(n=>n.remove()),a(this,j,e(this,f)),a(this,f,l),a(this,x,[]),this.findLinks(),document.documentElement.setAttribute("data-current-pathname",l),document.documentElement.setAttribute("data-current-leaf",bt),e(this,D).remove(),Q.changeHistory({action:s,pathname:l,searchParameters:wt,hash:g}),J.dispatchEvent(document,"morphComplete",{detail:at})}catch(_){console.error(_)}a(this,P,void 0)}})}addLink(t){e(this,v).push(new gt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,v,e(this,v).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var r;return((r=s.getAttribute("href"))==null?void 0:r.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,v).forEach(s=>s.destroy()),a(this,v,t.map(s=>new gt(s,this)))}}b=new WeakMap,W=new WeakMap,v=new WeakMap,U=new WeakMap,P=new WeakMap,f=new WeakMap,j=new WeakMap,x=new WeakMap,N=new WeakMap,F=new WeakMap,I=new WeakMap,D=new WeakMap,c=new WeakSet,tt=function(t,s=!1){return M(this,null,function*(){let r=e(this,I).get(t);return(!r||s)&&(r=yield d(this,c,et).call(this,t)),r})},et=function(t){return M(this,null,function*(){const r=yield(yield fetch(t)).text(),u=e(this,U).parseFromString(r,"text/html"),m=new vt(this,t,u);return e(this,I).set(t,m),m})},st=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Lt=function(t,s){return t.filter(r=>s.find(u=>u.outerHTML===r.outerHTML))},it=function(t,s){return t.filter(r=>!s.find(u=>u.outerHTML===r.outerHTML))},nt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},rt=function(){a(this,F,document.querySelector(e(this,b).scrollSelector)||document.documentElement)},X=new WeakMap;exports.Morph=kt;
|
package/lib/morph/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Morph, type
|
|
1
|
+
export { Morph, type MorphNavigationCallback, type MorphPreprocessor, type MorphPreprocessorEntry, type MorphNavigationEntry, type MorphOptions, type MorphTransitionEntry, type MorphChildrenActionEntry, type MorphNavigateOptions, type MorphEvents, } from './Morph';
|