aptechka 0.50.9 → 0.50.12
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/billboard/index.cjs +1 -1
- package/lib/billboard/index.js +40 -38
- package/lib/loading/index.cjs +1 -1
- package/lib/loading/index.d.ts +5 -1
- package/lib/loading/index.js +44 -31
- package/lib/morph/Morph.d.ts +5 -0
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +187 -174
- package/lib/utils/events.d.ts +1 -1
- package/package.json +1 -1
package/lib/billboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=s=>{throw TypeError(s)};var M=(s,n,t)=>n.has(s)||_("Cannot "+t);var e=(s,n,t)=>(M(s,n,"read from private field"),t?t.call(s):n.get(s)),i=(s,n,t)=>n.has(s)?_("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(s):n.set(s,t),h=(s,n,t,
|
|
1
|
+
"use strict";var _=s=>{throw TypeError(s)};var M=(s,n,t)=>n.has(s)||_("Cannot "+t);var e=(s,n,t)=>(M(s,n,"read from private field"),t?t.call(s):n.get(s)),i=(s,n,t)=>n.has(s)?_("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(s):n.set(s,t),h=(s,n,t,r)=>(M(s,n,"write to private field"),r?r.call(s,t):n.set(s,t),t),d=(s,n,t)=>(M(s,n,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../index-Cqw2NKev.cjs"),H=require("../dom-JBOkFLTh.cjs"),D=require("../css-property/index.cjs"),N=require("../events-KVanG9sR.cjs"),O=require("../number-0243DApo.cjs");var f,v,p,c,b,l,A,y,C,T,P,q;class I extends HTMLElement{constructor(){super(...arguments);i(this,l);i(this,f,new D.CSSProperty(this,"--autoplay",!1));i(this,v);i(this,p,!1);i(this,c,[]);i(this,b,0);i(this,C,t=>{h(this,p,t.isIntersecting),e(this,p)?d(this,l,y).call(this):clearInterval(e(this,v))});i(this,T,()=>{clearInterval(e(this,v)),e(this,p)&&h(this,v,setInterval(e(this,q),parseFloat(e(this,f).current||"0")*1e3))});i(this,q,()=>{d(this,l,P).call(this,e(this,b)+1)})}get counter(){return e(this,b)}get itemElements(){return e(this,c)}addItem(t){e(this,c).push(t),d(this,l,A).call(this)}set(t){d(this,l,P).call(this,t),d(this,l,y).call(this)}shift(t){this.set(e(this,b)+t)}connectedCallback(){var t;h(this,c,[...this.querySelectorAll("[data-billboard-item]")]),(t=e(this,c)[0])==null||t.classList.add("current"),d(this,l,A).call(this),e(this,f).subscribe(r=>{r.current?(g.intersector.subscribe(this,e(this,C)),d(this,l,y).call(this)):(h(this,p,!0),g.intersector.unsubscribe(e(this,C)),clearInterval(e(this,v)),d(this,l,P).call(this,0))}),e(this,f).observe()}disconnectedCallback(){e(this,f).unobserve(),g.intersector.unsubscribe(e(this,C)),clearInterval(e(this,v))}}f=new WeakMap,v=new WeakMap,p=new WeakMap,c=new WeakMap,b=new WeakMap,l=new WeakSet,A=function(){e(this,c).length>1?this.classList.add("has-length"):this.classList.remove("has-length")},y=function(){e(this,f).current!==!1&&e(this,T).call(this)},C=new WeakMap,T=new WeakMap,P=function(t){h(this,b,O.loopNumber(t,e(this,c).length)),e(this,c).forEach((r,a)=>{a===e(this,b)?r.classList.add("current"):r.classList.remove("current")}),N.dispatchEvent(this,"billboardChange",{detail:{counter:e(this,b)}}),setTimeout(()=>{window.dispatchEvent(new Event("resize"))},0)},q=new WeakMap;customElements.get("e-billboard")||customElements.define("e-billboard",I);var o,u,S,B;class j extends HTMLElement{constructor(){super(...arguments);i(this,o,null);i(this,u,[]);i(this,S,t=>{const r=t.currentTarget,a=e(this,u).findIndex(w=>w===r);a>=0&&e(this,o).set(a)});i(this,B,()=>{e(this,u).forEach((t,r)=>{r===e(this,o).counter?t.classList.add("current"):t.classList.remove("current")})})}connectedCallback(){h(this,o,H.findParentElement(this,I)),e(this,o)&&customElements.whenDefined("e-billboard").then(()=>{var t;if(this.isConnected){const r=e(this,o).itemElements.length;for(let a=0;a<r;a++){const w=document.createElement("button");e(this,u).push(w),this.appendChild(w)}e(this,u).forEach(a=>{a.addEventListener("click",e(this,S))}),(t=e(this,o))==null||t.addEventListener("billboardChange",e(this,B)),e(this,B).call(this)}})}disconnectedCallback(){var t;e(this,u).forEach(r=>{r.removeEventListener("click",e(this,S))}),(t=e(this,o))==null||t.removeEventListener("billboardChange",e(this,B)),this.innerHTML="",h(this,u,[])}}o=new WeakMap,u=new WeakMap,S=new WeakMap,B=new WeakMap;g.isBrowser&&!customElements.get("e-billboard-bullets")&&customElements.define("e-billboard-bullets",j);var m,E,L;class z extends HTMLElement{constructor(){super();i(this,m,new D.CSSProperty(this,"--index",0));i(this,E,null);i(this,L,()=>{var t;e(this,m).current===((t=e(this,E))==null?void 0:t.counter)?this.classList.add("current"):this.classList.remove("current")});this.addEventListener("click",()=>{e(this,E)&&e(this,E).set(e(this,m).current)})}connectedCallback(){var t;this.tabIndex=0,h(this,E,H.findParentElement(this,I)),(t=e(this,E))==null||t.addEventListener("billboardChange",e(this,L)),customElements.whenDefined("e-billboard").then(()=>{this.isConnected&&e(this,L).call(this)}),e(this,m).subscribe(e(this,L)),e(this,m).observe()}disconnectedCallback(){var t;this.removeAttribute("tabindex"),e(this,m).unsubscribe(e(this,L)),e(this,m).unobserve(),(t=e(this,E))==null||t.removeEventListener("billboardChange",e(this,L))}}m=new WeakMap,E=new WeakMap,L=new WeakMap;g.isBrowser&&!customElements.get("e-billboard-set-button")&&customElements.define("e-billboard-set-button",z);var k,x;class F extends HTMLElement{constructor(){super();i(this,k,new D.CSSProperty(this,"--step",1));i(this,x,null);this.addEventListener("click",()=>{e(this,x)&&e(this,x).shift(e(this,k).current)})}connectedCallback(){this.tabIndex=0,h(this,x,H.findParentElement(this,I)),e(this,k).observe()}disconnectedCallback(){this.removeAttribute("tabindex"),e(this,k).unobserve()}}k=new WeakMap,x=new WeakMap;g.isBrowser&&!customElements.get("e-billboard-step-button")&&customElements.define("e-billboard-step-button",F);exports.BillboardBulletsElement=j;exports.BillboardElement=I;exports.BillboardSetButtonElement=z;exports.BillboardStepButtonElement=F;
|
package/lib/billboard/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
1
|
+
var F = (s) => {
|
|
2
2
|
throw TypeError(s);
|
|
3
3
|
};
|
|
4
|
-
var H = (s, n, e) => n.has(s) ||
|
|
5
|
-
var t = (s, n, e) => (H(s, n, "read from private field"), e ? e.call(s) : n.get(s)), i = (s, n, e) => n.has(s) ?
|
|
4
|
+
var H = (s, n, e) => n.has(s) || F("Cannot " + e);
|
|
5
|
+
var t = (s, n, e) => (H(s, n, "read from private field"), e ? e.call(s) : n.get(s)), i = (s, n, e) => n.has(s) ? F("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(s) : n.set(s, e), h = (s, n, e, l) => (H(s, n, "write to private field"), l ? l.call(s, e) : n.set(s, e), e), d = (s, n, e) => (H(s, n, "access private method"), e);
|
|
6
6
|
import { a as M, i as P } from "../index-euf5anj6.js";
|
|
7
7
|
import { b as q } from "../dom-CVWzyXPH.js";
|
|
8
|
-
import { CSSProperty as
|
|
9
|
-
import { d as
|
|
10
|
-
import { l as
|
|
11
|
-
var E, v,
|
|
8
|
+
import { CSSProperty as z } from "../css-property/index.js";
|
|
9
|
+
import { d as N } from "../events-CsVF98U6.js";
|
|
10
|
+
import { l as j } from "../number-DwCxt_Ck.js";
|
|
11
|
+
var E, v, L, a, b, r, D, B, g, y, T, S;
|
|
12
12
|
class A extends HTMLElement {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
15
|
i(this, r);
|
|
16
|
-
i(this, E, new
|
|
16
|
+
i(this, E, new z(this, "--autoplay", !1));
|
|
17
17
|
i(this, v);
|
|
18
|
-
i(this,
|
|
18
|
+
i(this, L, !1);
|
|
19
19
|
i(this, a, []);
|
|
20
20
|
i(this, b, 0);
|
|
21
21
|
i(this, g, (e) => {
|
|
22
|
-
h(this,
|
|
22
|
+
h(this, L, e.isIntersecting), t(this, L) ? d(this, r, B).call(this) : clearInterval(t(this, v));
|
|
23
23
|
});
|
|
24
|
-
i(this,
|
|
25
|
-
clearInterval(t(this, v)), t(this,
|
|
26
|
-
t(this,
|
|
24
|
+
i(this, y, () => {
|
|
25
|
+
clearInterval(t(this, v)), t(this, L) && h(this, v, setInterval(
|
|
26
|
+
t(this, S),
|
|
27
27
|
parseFloat(t(this, E).current || "0") * 1e3
|
|
28
28
|
));
|
|
29
29
|
});
|
|
30
|
-
i(this,
|
|
31
|
-
d(this, r,
|
|
30
|
+
i(this, S, () => {
|
|
31
|
+
d(this, r, T).call(this, t(this, b) + 1);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
get counter() {
|
|
@@ -41,7 +41,7 @@ class A extends HTMLElement {
|
|
|
41
41
|
t(this, a).push(e), d(this, r, D).call(this);
|
|
42
42
|
}
|
|
43
43
|
set(e) {
|
|
44
|
-
d(this, r,
|
|
44
|
+
d(this, r, T).call(this, e), d(this, r, B).call(this);
|
|
45
45
|
}
|
|
46
46
|
shift(e) {
|
|
47
47
|
this.set(t(this, b) + e);
|
|
@@ -51,26 +51,28 @@ class A extends HTMLElement {
|
|
|
51
51
|
h(this, a, [
|
|
52
52
|
...this.querySelectorAll("[data-billboard-item]")
|
|
53
53
|
]), (e = t(this, a)[0]) == null || e.classList.add("current"), d(this, r, D).call(this), t(this, E).subscribe((l) => {
|
|
54
|
-
l.current ? (M.subscribe(this, t(this, g)), d(this, r,
|
|
54
|
+
l.current ? (M.subscribe(this, t(this, g)), d(this, r, B).call(this)) : (h(this, L, !0), M.unsubscribe(t(this, g)), clearInterval(t(this, v)), d(this, r, T).call(this, 0));
|
|
55
55
|
}), t(this, E).observe();
|
|
56
56
|
}
|
|
57
57
|
disconnectedCallback() {
|
|
58
58
|
t(this, E).unobserve(), M.unsubscribe(t(this, g)), clearInterval(t(this, v));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
E = new WeakMap(), v = new WeakMap(),
|
|
61
|
+
E = new WeakMap(), v = new WeakMap(), L = new WeakMap(), a = new WeakMap(), b = new WeakMap(), r = new WeakSet(), D = function() {
|
|
62
62
|
t(this, a).length > 1 ? this.classList.add("has-length") : this.classList.remove("has-length");
|
|
63
|
-
},
|
|
64
|
-
t(this, E).current !== !1 && t(this,
|
|
65
|
-
}, g = new WeakMap(),
|
|
66
|
-
h(this, b,
|
|
63
|
+
}, B = function() {
|
|
64
|
+
t(this, E).current !== !1 && t(this, y).call(this);
|
|
65
|
+
}, g = new WeakMap(), y = new WeakMap(), T = function(e) {
|
|
66
|
+
h(this, b, j(e, t(this, a).length)), t(this, a).forEach((l, o) => {
|
|
67
67
|
o === t(this, b) ? l.classList.add("current") : l.classList.remove("current");
|
|
68
|
-
}),
|
|
68
|
+
}), N(this, "billboardChange", {
|
|
69
69
|
detail: {
|
|
70
70
|
counter: t(this, b)
|
|
71
71
|
}
|
|
72
|
-
})
|
|
73
|
-
|
|
72
|
+
}), setTimeout(() => {
|
|
73
|
+
window.dispatchEvent(new Event("resize"));
|
|
74
|
+
}, 0);
|
|
75
|
+
}, S = new WeakMap();
|
|
74
76
|
customElements.get("e-billboard") || customElements.define("e-billboard", A);
|
|
75
77
|
var c, u, I, C;
|
|
76
78
|
class G extends HTMLElement {
|
|
@@ -79,7 +81,7 @@ class G extends HTMLElement {
|
|
|
79
81
|
i(this, c, null);
|
|
80
82
|
i(this, u, []);
|
|
81
83
|
i(this, I, (e) => {
|
|
82
|
-
const l = e.currentTarget, o = t(this, u).findIndex((
|
|
84
|
+
const l = e.currentTarget, o = t(this, u).findIndex((w) => w === l);
|
|
83
85
|
o >= 0 && t(this, c).set(o);
|
|
84
86
|
});
|
|
85
87
|
i(this, C, () => {
|
|
@@ -94,8 +96,8 @@ class G extends HTMLElement {
|
|
|
94
96
|
if (this.isConnected) {
|
|
95
97
|
const l = t(this, c).itemElements.length;
|
|
96
98
|
for (let o = 0; o < l; o++) {
|
|
97
|
-
const
|
|
98
|
-
t(this, u).push(
|
|
99
|
+
const w = document.createElement("button");
|
|
100
|
+
t(this, u).push(w), this.appendChild(w);
|
|
99
101
|
}
|
|
100
102
|
t(this, u).forEach((o) => {
|
|
101
103
|
o.addEventListener("click", t(this, I));
|
|
@@ -118,13 +120,13 @@ class G extends HTMLElement {
|
|
|
118
120
|
}
|
|
119
121
|
c = new WeakMap(), u = new WeakMap(), I = new WeakMap(), C = new WeakMap();
|
|
120
122
|
P && !customElements.get("e-billboard-bullets") && customElements.define("e-billboard-bullets", G);
|
|
121
|
-
var m, f,
|
|
123
|
+
var m, f, p;
|
|
122
124
|
class J extends HTMLElement {
|
|
123
125
|
constructor() {
|
|
124
126
|
super();
|
|
125
|
-
i(this, m, new
|
|
127
|
+
i(this, m, new z(this, "--index", 0));
|
|
126
128
|
i(this, f, null);
|
|
127
|
-
i(this,
|
|
129
|
+
i(this, p, () => {
|
|
128
130
|
var e;
|
|
129
131
|
t(this, m).current === ((e = t(this, f)) == null ? void 0 : e.counter) ? this.classList.add("current") : this.classList.remove("current");
|
|
130
132
|
});
|
|
@@ -136,26 +138,26 @@ class J extends HTMLElement {
|
|
|
136
138
|
var e;
|
|
137
139
|
this.tabIndex = 0, h(this, f, q(this, A)), (e = t(this, f)) == null || e.addEventListener(
|
|
138
140
|
"billboardChange",
|
|
139
|
-
t(this,
|
|
141
|
+
t(this, p)
|
|
140
142
|
), customElements.whenDefined("e-billboard").then(() => {
|
|
141
|
-
this.isConnected && t(this,
|
|
142
|
-
}), t(this, m).subscribe(t(this,
|
|
143
|
+
this.isConnected && t(this, p).call(this);
|
|
144
|
+
}), t(this, m).subscribe(t(this, p)), t(this, m).observe();
|
|
143
145
|
}
|
|
144
146
|
disconnectedCallback() {
|
|
145
147
|
var e;
|
|
146
|
-
this.removeAttribute("tabindex"), t(this, m).unsubscribe(t(this,
|
|
148
|
+
this.removeAttribute("tabindex"), t(this, m).unsubscribe(t(this, p)), t(this, m).unobserve(), (e = t(this, f)) == null || e.removeEventListener(
|
|
147
149
|
"billboardChange",
|
|
148
|
-
t(this,
|
|
150
|
+
t(this, p)
|
|
149
151
|
);
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
|
-
m = new WeakMap(), f = new WeakMap(),
|
|
154
|
+
m = new WeakMap(), f = new WeakMap(), p = new WeakMap();
|
|
153
155
|
P && !customElements.get("e-billboard-set-button") && customElements.define("e-billboard-set-button", J);
|
|
154
156
|
var k, x;
|
|
155
157
|
class K extends HTMLElement {
|
|
156
158
|
constructor() {
|
|
157
159
|
super();
|
|
158
|
-
i(this, k, new
|
|
160
|
+
i(this, k, new z(this, "--step", 1));
|
|
159
161
|
i(this, x, null);
|
|
160
162
|
this.addEventListener("click", () => {
|
|
161
163
|
t(this, x) && t(this, x).shift(t(this, k).current);
|
package/lib/loading/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var v=i=>{throw TypeError(i)};var E=(i,t,s)=>t.has(i)||v("Cannot "+s);var e=(i,t,s)=>(E(i,t,"read from private field"),s?s.call(i):t.get(i)),r=(i,t,s)=>t.has(i)?v("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),n=(i,t,s,d)=>(E(i,t,"write to private field"),d?d.call(i,s):t.set(i,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../events-KVanG9sR.cjs"),b=require("../function-MthRj-GJ.cjs");require("../index-Cqw2NKev.cjs");var o,a,h,l,c,p,g,f;class q{constructor(){r(this,o,new Map);r(this,a,!1);r(this,h,0);r(this,l,0);r(this,c,0);r(this,p,b.debounce(()=>{e(this,a)||(n(this,a,!0),u.dispatchEvent(document,"loadingStart"),e(this,g).call(this))},0));r(this,g,t=>{if(!e(this,a))return;const s=e(this,o).size,d=Array.from(e(this,o)).filter(S=>S[1]).length,m=d/s;n(this,h,s),n(this,l,d),n(this,c,m),u.dispatchEvent(document,"loadingProgress",{detail:{total:s,loaded:d,progress:m,resourceName:t}}),m===1&&e(this,f).call(this)});r(this,f,b.debounce(()=>{n(this,a,!1),u.dispatchEvent(document,"loadingComplete",{detail:{total:e(this,o).size}}),n(this,h,0),n(this,l,0),n(this,c,0),e(this,o).clear()},0))}get total(){return e(this,h)}get loaded(){return e(this,l)}get progress(){return e(this,c)}get map(){return e(this,o)}add(t){e(this,o).set(t,!1),e(this,p).call(this)}complete(t){e(this,o).set(t,!0),e(this,g).call(this,t)}error(t){e(this,o).has(t)&&(console.error(`Failed to load ${t}`),e(this,o).delete(t),u.dispatchEvent(document,"loadingError",{detail:{name:t}})),e(this,g).call(this)}}o=new WeakMap,a=new WeakMap,h=new WeakMap,l=new WeakMap,c=new WeakMap,p=new WeakMap,g=new WeakMap,f=new WeakMap;const y=new q;exports.loading=y;
|
package/lib/loading/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface LoadingEvents {
|
|
|
3
3
|
total: number;
|
|
4
4
|
loaded: number;
|
|
5
5
|
progress: number;
|
|
6
|
+
resourceName: string | undefined;
|
|
6
7
|
}>;
|
|
7
8
|
loadingStart: CustomEvent<{}>;
|
|
8
9
|
loadingComplete: CustomEvent<{
|
|
@@ -14,6 +15,9 @@ export interface LoadingEvents {
|
|
|
14
15
|
}
|
|
15
16
|
declare class Loading {
|
|
16
17
|
#private;
|
|
18
|
+
get total(): number;
|
|
19
|
+
get loaded(): number;
|
|
20
|
+
get progress(): number;
|
|
17
21
|
get map(): Map<string, boolean>;
|
|
18
22
|
add(resourceName: string): void;
|
|
19
23
|
complete(resourceName: string): void;
|
|
@@ -21,7 +25,7 @@ declare class Loading {
|
|
|
21
25
|
}
|
|
22
26
|
export declare const loading: Loading;
|
|
23
27
|
declare global {
|
|
24
|
-
interface
|
|
28
|
+
interface DocumentEventMap extends LoadingEvents {
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
export {};
|
package/lib/loading/index.js
CHANGED
|
@@ -1,58 +1,71 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var w = (i) => {
|
|
2
|
+
throw TypeError(i);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import { d as
|
|
7
|
-
import { d as
|
|
4
|
+
var z = (i, t, e) => t.has(i) || w("Cannot " + e);
|
|
5
|
+
var s = (i, t, e) => (z(i, t, "read from private field"), e ? e.call(i) : t.get(i)), r = (i, t, e) => t.has(i) ? w("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), a = (i, t, e, d) => (z(i, t, "write to private field"), d ? d.call(i, e) : t.set(i, e), e);
|
|
6
|
+
import { d as c } from "../events-CsVF98U6.js";
|
|
7
|
+
import { d as E } from "../function-C10DGppn.js";
|
|
8
8
|
import "../index-euf5anj6.js";
|
|
9
|
-
var o,
|
|
10
|
-
class
|
|
9
|
+
var o, h, l, n, g, m, p, f;
|
|
10
|
+
class b {
|
|
11
11
|
constructor() {
|
|
12
12
|
r(this, o, /* @__PURE__ */ new Map());
|
|
13
|
-
r(this,
|
|
14
|
-
r(this,
|
|
15
|
-
|
|
13
|
+
r(this, h, !1);
|
|
14
|
+
r(this, l, 0);
|
|
15
|
+
r(this, n, 0);
|
|
16
|
+
r(this, g, 0);
|
|
17
|
+
r(this, m, E(() => {
|
|
18
|
+
s(this, h) || (a(this, h, !0), c(document, "loadingStart"), s(this, p).call(this));
|
|
16
19
|
}, 0));
|
|
17
|
-
r(this,
|
|
18
|
-
if (!
|
|
20
|
+
r(this, p, (t) => {
|
|
21
|
+
if (!s(this, h))
|
|
19
22
|
return;
|
|
20
|
-
const
|
|
21
|
-
n(
|
|
23
|
+
const e = s(this, o).size, d = Array.from(s(this, o)).filter((S) => S[1]).length, u = d / e;
|
|
24
|
+
a(this, l, e), a(this, n, d), a(this, g, u), c(document, "loadingProgress", {
|
|
22
25
|
detail: {
|
|
23
|
-
total:
|
|
24
|
-
loaded:
|
|
25
|
-
progress:
|
|
26
|
+
total: e,
|
|
27
|
+
loaded: d,
|
|
28
|
+
progress: u,
|
|
29
|
+
resourceName: t
|
|
26
30
|
}
|
|
27
|
-
}),
|
|
31
|
+
}), u === 1 && s(this, f).call(this);
|
|
28
32
|
});
|
|
29
|
-
r(this,
|
|
30
|
-
|
|
33
|
+
r(this, f, E(() => {
|
|
34
|
+
a(this, h, !1), c(document, "loadingComplete", {
|
|
31
35
|
detail: {
|
|
32
|
-
total:
|
|
36
|
+
total: s(this, o).size
|
|
33
37
|
}
|
|
34
|
-
}),
|
|
38
|
+
}), a(this, l, 0), a(this, n, 0), a(this, g, 0), s(this, o).clear();
|
|
35
39
|
}, 0));
|
|
36
40
|
}
|
|
41
|
+
get total() {
|
|
42
|
+
return s(this, l);
|
|
43
|
+
}
|
|
44
|
+
get loaded() {
|
|
45
|
+
return s(this, n);
|
|
46
|
+
}
|
|
47
|
+
get progress() {
|
|
48
|
+
return s(this, g);
|
|
49
|
+
}
|
|
37
50
|
get map() {
|
|
38
|
-
return
|
|
51
|
+
return s(this, o);
|
|
39
52
|
}
|
|
40
53
|
add(t) {
|
|
41
|
-
|
|
54
|
+
s(this, o).set(t, !1), s(this, m).call(this);
|
|
42
55
|
}
|
|
43
56
|
complete(t) {
|
|
44
|
-
|
|
57
|
+
s(this, o).set(t, !0), s(this, p).call(this, t);
|
|
45
58
|
}
|
|
46
59
|
error(t) {
|
|
47
|
-
|
|
60
|
+
s(this, o).has(t) && (console.error(`Failed to load ${t}`), s(this, o).delete(t), c(document, "loadingError", {
|
|
48
61
|
detail: {
|
|
49
62
|
name: t
|
|
50
63
|
}
|
|
51
|
-
})),
|
|
64
|
+
})), s(this, p).call(this);
|
|
52
65
|
}
|
|
53
66
|
}
|
|
54
|
-
o = new WeakMap(),
|
|
55
|
-
const
|
|
67
|
+
o = new WeakMap(), h = new WeakMap(), l = new WeakMap(), n = new WeakMap(), g = new WeakMap(), m = new WeakMap(), p = new WeakMap(), f = new WeakMap();
|
|
68
|
+
const A = new b();
|
|
56
69
|
export {
|
|
57
|
-
|
|
70
|
+
A as loading
|
|
58
71
|
};
|
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -28,11 +28,16 @@ export interface MorphNavigateOptions {
|
|
|
28
28
|
offsetScroll?: number | ElementOrSelector<HTMLElement>;
|
|
29
29
|
revalidate?: boolean;
|
|
30
30
|
}
|
|
31
|
+
export interface MorphScrollDetail {
|
|
32
|
+
left: number;
|
|
33
|
+
top: number;
|
|
34
|
+
}
|
|
31
35
|
export interface MorphEvents {
|
|
32
36
|
morphStart: CustomEvent<MorphTransitionEntry>;
|
|
33
37
|
morphComplete: CustomEvent<MorphTransitionEntry>;
|
|
34
38
|
morphNewChildrenAdded: CustomEvent<MorphChildrenActionEntry>;
|
|
35
39
|
morphOldChildrenRemoved: CustomEvent<MorphChildrenActionEntry>;
|
|
40
|
+
morphScroll: CustomEvent<MorphScrollDetail>;
|
|
36
41
|
}
|
|
37
42
|
export declare class Morph {
|
|
38
43
|
#private;
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),Et=n=>{throw TypeError(n)};var $=(n,t,s)=>t.has(n)||Et("Cannot "+s);var e=(n,t,s)=>($(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?Et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>($(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>($(n,t,"access private method"),s);var M=(n,t,s)=>new Promise((i,u)=>{var f=l=>{try{k(s.next(l))}catch(g){u(g)}},B=l=>{try{k(s.throw(l))}catch(g){u(g)}},k=l=>l.done?i(l.value):Promise.resolve(l.value).then(f,B);k((s=s.apply(n,t)).next())});var gt=(n,t,s)=>(t=n[pt("asyncIterator")])?t.call(n):(n=n[pt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=f=>new Promise((B,k,l)=>(f=u.call(n,f),l=f.done,Promise.resolve(f.value).then(g=>B({value:g,done:l}),k)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),G=require("../events-KVanG9sR.cjs"),Mt=require("../polyfills-Df4r-ETT.cjs"),Tt=require("../scroll-H9zqFeML.cjs"),J=require("../url-CLvdjbII.cjs"),Ht=require("../css-value-parser/index.cjs");class Lt 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,i]of Object.entries(t))this.setAttribute(s,i)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Lt);var w,c,T,W,z;class vt{constructor(t,s){o(this,w);o(this,c);o(this,T);o(this,W,t=>{t.preventDefault();const s=e(this,c).getAttribute("data-history-action")||"push",i=e(this,c).hasAttribute("data-center-scroll"),u=getComputedStyle(e(this,c)).getPropertyValue("--offset-scroll").trim(),f=u?Ht.cssValueParser.parse(u):void 0,B=e(this,c).hasAttribute("data-revalidate");e(this,w).navigate(e(this,T),{historyAction:s,centerScroll:i,offsetScroll:f,revalidate:B})});o(this,z,()=>{e(this,w).prefetch(e(this,T)),e(this,c).removeEventListener("pointerenter",e(this,z))});a(this,w,s),a(this,c,t),a(this,T,e(this,c).getAttribute("href")||"/"),e(this,c).addEventListener("click",e(this,W)),this.checkCurrent(location.pathname),e(this,c).hasAttribute("data-prefetch")&&e(this,c).addEventListener("pointerenter",e(this,z))}get element(){return e(this,c)}checkCurrent(t){const s=e(this,w).normalizePath(t),i=e(this,w).normalizePath(e(this,T));e(this,c).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,c).classList.add("current"):i.pathname===s.pathname?e(this,c).classList.add("current"):e(this,c).classList.remove("current")}destroy(){e(this,c).removeEventListener("click",e(this,W)),e(this,c).removeEventListener("pointerenter",e(this,z)),e(this,c).classList.remove("current")}}w=new WeakMap,c=new WeakMap,T=new WeakMap,W=new WeakMap,z=new WeakMap;var H,F,p,x,N,b;class yt{constructor(t,s,i){o(this,H);o(this,F);o(this,p,{x:0,y:0});o(this,x);o(this,N,null);o(this,b,null);a(this,H,t),a(this,F,s),a(this,x,i.cloneNode(!0))}get pathname(){return e(this,F)}get scrollState(){return e(this,p)}get document(){return e(this,b)}cloneDocument(){a(this,b,(e(this,N)||e(this,x)).cloneNode(!0))}get title(){let t="";if(e(this,b).title)t=e(this,b).title;else{const s=e(this,b).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,F)}return t}clearScrollState(){e(this,p).x=0,e(this,p).y=0}clearDocumentState(){a(this,N,null)}saveScrollState(){e(this,x).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,H).scrollElement.scrollLeft,e(this,p).y=e(this,H).scrollElement.scrollTop)}saveDocumentState(){e(this,x).documentElement.hasAttribute("data-no-page-restoration")?a(this,N,null):a(this,N,document.cloneNode(!0))}restoreScrollPosition(){e(this,H).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}H=new WeakMap,F=new WeakMap,p=new WeakMap,x=new WeakMap,N=new WeakMap,b=new WeakMap;var P,j,E,Q,A,m,U,D,C,I,V,R,h,tt,et,st,wt,it,nt,rt,ot,X;class xt{constructor(t){o(this,h);o(this,P,null);o(this,j,null);o(this,E,[]);o(this,Q,new DOMParser);o(this,A);o(this,m,null);o(this,U);o(this,D,[]);o(this,C,!1);o(this,I,null);o(this,V,new Map);o(this,R,null);o(this,X,t=>M(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(a(this,C,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,C,!1))}));if(St.isBrowser){a(this,P,{base:J.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,j,d(this,h,st).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,m,s.pathname),e(this,V).set(e(this,m),new yt(this,e(this,m),document)),document.documentElement.setAttribute("data-current-pathname",e(this,m)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,X)),J.changeHistory({action:"replace",pathname:e(this,m),searchParameters:s.parameters,hash:s.hash}),a(this,R,new Lt),d(this,h,rt).call(this,document)}}get currentPathname(){return e(this,m)}get previousPathname(){return e(this,U)}get links(){return e(this,E)}get scrollElement(){return e(this,I)}normalizePath(t){return J.splitPath(t,{base:e(this,P).base,trailingSlash:e(this,P).trailingSlash})}prefetch(t){return M(this,null,function*(){const s=this.normalizePath(t);d(this,h,et).call(this,s.pathname)})}navigate(B){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:f}={}){if(e(this,D).length)return;const k=this.normalizePath(t);let{pathname:l,hash:g,parameters:bt,leaf:Pt}=k;if(e(this,A)===l||e(this,m)===l){e(this,C)||d(this,h,ot).call(this,g||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,A,l),e(this,E).forEach(q=>{q.checkCurrent(l)});try{let q=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var L;(L=this.preprocessor)==null||L.call(this,{pathname:l,resolve:r,reject:S})})}catch(r){r?console.error(r):console.log("Route change canceled"),q=!1}if(!q||e(this,A)!==l){e(this,E).forEach(r=>{r.checkCurrent(e(this,m))});return}const at=yield d(this,h,tt).call(this,e(this,m)),y=yield d(this,h,tt).call(this,l,f);if(e(this,A)!==l){e(this,E).forEach(r=>{r.checkCurrent(e(this,m))});return}at.saveScrollState(),at.saveDocumentState(),e(this,C)||(y.clearScrollState(),y.clearDocumentState()),y.cloneDocument(),e(this,R).textContent=y.title,document.body.appendChild(e(this,R));const ht={pathname:l};G.dispatchEvent(document,"morphStart",{detail:ht});const lt=Array.from(document.head.children),ct=Array.from(y.document.head.children),ut=d(this,h,wt).call(this,lt,ct),At=d(this,h,it).call(this,lt,ut),_=d(this,h,it).call(this,ct,ut);_.forEach((r,S)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const L=document.createElement("script");L.type="module",L.src=r.getAttribute("src"),_[S]=L}}),_.forEach(r=>{document.head.appendChild(r)});const Z=_.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,h,nt).call(this,r))return!0});e(this,P).waitForHeadToLoad&&Z.length&&(yield new Promise(r=>M(this,null,function*(){let S=0;try{for(var L=gt(Z),mt,O,ft;mt=!(O=yield L.next()).done;mt=!1){const K=O.value;K.onload=()=>{S++,S===Z.length&&r()}}}catch(O){ft=[O]}finally{try{mt&&(O=L.return)&&(yield O.call(L))}finally{if(ft)throw ft[0]}}})));const dt=[];At.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,h,nt).call(this,r)?dt.push(r):r.remove())});const Ct=d(this,h,st).call(this,y.document.body);d(this,h,rt).call(this,y.document),document.documentElement.setAttribute("data-current-pathname",l),document.documentElement.setAttribute("data-current-leaf",Pt),J.changeHistory({action:s,pathname:l,searchParameters:bt,hash:g}),e(this,R).remove(),a(this,U,e(this,m)),a(this,m,l),e(this,j).forEach((r,S)=>{const L=Ct[S],mt=getComputedStyle(r).getPropertyValue("--morph-duration"),O=[...L.childNodes];if(mt){const ft=[...r.childNodes];ft.forEach(v=>{v instanceof HTMLElement&&v.classList.add("old")}),O.forEach(v=>{v instanceof HTMLElement&&v.classList.add("new")}),r.prepend(...O),Mt.requestIdleCallback(()=>{O.forEach(v=>{v instanceof HTMLElement&&v.classList.add("in")})});const K={morphElement:r,pathname:l};G.dispatchEvent(document,"morphNewChildrenAdded",{detail:K});const kt=new Promise(v=>{setTimeout(()=>{ft.forEach(Y=>Y.remove()),O.forEach(Y=>{Y instanceof HTMLElement&&Y.classList.remove("in","new")}),G.dispatchEvent(document,"morphOldChildrenRemoved",{detail:K}),v()},(parseFloat(mt)||0)*1e3+10)});e(this,D).push(kt)}else r.innerHTML="",r.append(...O)}),g?(y.clearScrollState(),d(this,h,ot).call(this,g,{centerScroll:i,offsetScroll:u})):e(this,C)&&y.restoreScrollPosition(),yield Promise.all(e(this,D)),dt.forEach(r=>r.remove()),a(this,D,[]),this.findLinks(),G.dispatchEvent(document,"morphComplete",{detail:ht}),window.dispatchEvent(new Event("resize"))}catch(q){console.error(q)}a(this,A,void 0)})}addLink(t){e(this,E).push(new vt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var i;return((i=s.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,E).forEach(s=>s.destroy()),a(this,E,t.map(s=>new vt(s,this)))}}P=new WeakMap,j=new WeakMap,E=new WeakMap,Q=new WeakMap,A=new WeakMap,m=new WeakMap,U=new WeakMap,D=new WeakMap,C=new WeakMap,I=new WeakMap,V=new WeakMap,R=new WeakMap,h=new WeakSet,tt=function(t,s=!1){return M(this,null,function*(){let i=e(this,V).get(t);return(!i||s)&&(i=yield d(this,h,et).call(this,t)),i})},et=function(t){return M(this,null,function*(){const i=yield(yield fetch(t)).text(),u=e(this,Q).parseFromString(i,"text/html"),f=new yt(this,t,u);return e(this,V).set(t,f),f})},st=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},wt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},it=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},nt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},rt=function(t){a(this,I,t.querySelector(e(this,P).scrollSelector)||t.documentElement)},ot=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Tt.scrollToElement(i,{scrollElement:e(this,I),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},X=new WeakMap;exports.Morph=xt;
|
|
1
|
+
"use strict";var Et=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),gt=n=>{throw TypeError(n)};var tt=(n,t,s)=>t.has(n)||gt("Cannot "+s);var e=(n,t,s)=>(tt(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?gt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>(tt(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(tt(n,t,"access private method"),s);var M=(n,t,s)=>new Promise((i,u)=>{var f=c=>{try{T(s.next(c))}catch(g){u(g)}},O=c=>{try{T(s.throw(c))}catch(g){u(g)}},T=c=>c.done?i(c.value):Promise.resolve(c.value).then(f,O);T((s=s.apply(n,t)).next())});var vt=(n,t,s)=>(t=n[Et("asyncIterator")])?t.call(n):(n=n[Et("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=f=>new Promise((O,T,c)=>(f=u.call(n,f),c=f.done,Promise.resolve(f.value).then(g=>O({value:g,done:c}),T)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const yt=require("../index-Cqw2NKev.cjs"),j=require("../events-KVanG9sR.cjs"),Mt=require("../polyfills-Df4r-ETT.cjs"),Ht=require("../scroll-H9zqFeML.cjs"),Q=require("../url-CLvdjbII.cjs"),xt=require("../css-value-parser/index.cjs");class wt 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,i]of Object.entries(t))this.setAttribute(s,i)}}yt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",wt);var b,h,H,U,F;class Lt{constructor(t,s){o(this,b);o(this,h);o(this,H);o(this,U,t=>{t.preventDefault();const s=e(this,h).getAttribute("data-history-action")||"push",i=e(this,h).hasAttribute("data-center-scroll"),u=getComputedStyle(e(this,h)).getPropertyValue("--offset-scroll").trim(),f=u?xt.cssValueParser.parse(u):void 0,O=e(this,h).hasAttribute("data-revalidate");e(this,b).navigate(e(this,H),{historyAction:s,centerScroll:i,offsetScroll:f,revalidate:O})});o(this,F,()=>{e(this,b).prefetch(e(this,H)),e(this,h).removeEventListener("pointerenter",e(this,F))});a(this,b,s),a(this,h,t),a(this,H,e(this,h).getAttribute("href")||"/"),e(this,h).addEventListener("click",e(this,U)),this.checkCurrent(location.pathname),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,F))}get element(){return e(this,h)}checkCurrent(t){const s=e(this,b).normalizePath(t),i=e(this,b).normalizePath(e(this,H));e(this,h).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,h).classList.add("current"):i.pathname===s.pathname?e(this,h).classList.add("current"):e(this,h).classList.remove("current")}destroy(){e(this,h).removeEventListener("click",e(this,U)),e(this,h).removeEventListener("pointerenter",e(this,F)),e(this,h).classList.remove("current")}}b=new WeakMap,h=new WeakMap,H=new WeakMap,U=new WeakMap,F=new WeakMap;var x,I,p,N,D,P;class St{constructor(t,s,i){o(this,x);o(this,I);o(this,p,{x:0,y:0});o(this,N);o(this,D,null);o(this,P,null);a(this,x,t),a(this,I,s),a(this,N,i.cloneNode(!0))}get pathname(){return e(this,I)}get scrollState(){return e(this,p)}get document(){return e(this,P)}cloneDocument(){a(this,P,(e(this,D)||e(this,N)).cloneNode(!0))}get title(){let t="";if(e(this,P).title)t=e(this,P).title;else{const s=e(this,P).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,I)}return t}clearScrollState(){e(this,p).x=0,e(this,p).y=0}clearDocumentState(){a(this,D,null)}saveScrollState(){e(this,N).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,x).scrollElement.scrollLeft,e(this,p).y=e(this,x).scrollElement.scrollTop)}saveDocumentState(){e(this,N).documentElement.hasAttribute("data-no-page-restoration")?a(this,D,null):a(this,D,document.cloneNode(!0))}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}x=new WeakMap,I=new WeakMap,p=new WeakMap,N=new WeakMap,D=new WeakMap,P=new WeakMap;var A,_,E,X,C,m,K,R,k,L,V,q,l,et,st,it,bt,nt,rt,ot,at,Z,B;class Nt{constructor(t){o(this,l);o(this,A,null);o(this,_,null);o(this,E,[]);o(this,X,new DOMParser);o(this,C);o(this,m,null);o(this,K);o(this,R,[]);o(this,k,!1);o(this,L,null);o(this,V,new Map);o(this,q,null);o(this,Z,t=>M(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,k,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,k,!1))}));o(this,B,()=>{const t=e(this,L).scrollTop,s=e(this,L).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),j.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(yt.isBrowser){a(this,A,{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,_,d(this,l,it).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,m,s.pathname),e(this,V).set(e(this,m),new St(this,e(this,m),document)),document.documentElement.setAttribute("data-current-pathname",e(this,m)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,Z)),Q.changeHistory({action:"replace",pathname:e(this,m),searchParameters:s.parameters,hash:s.hash}),a(this,q,new wt),d(this,l,ot).call(this,document)}}get currentPathname(){return e(this,m)}get previousPathname(){return e(this,K)}get links(){return e(this,E)}get scrollElement(){return e(this,L)}normalizePath(t){return Q.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t){return M(this,null,function*(){const s=this.normalizePath(t);d(this,l,st).call(this,s.pathname)})}navigate(O){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:f}={}){if(e(this,R).length)return;const T=this.normalizePath(t);let{pathname:c,hash:g,parameters:Pt,leaf:At}=T;if(e(this,C)===c||e(this,m)===c){e(this,k)||d(this,l,at).call(this,g||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,C,c),e(this,E).forEach(z=>{z.checkCurrent(c)});try{let z=!0;if(this.preprocessor)try{yield new Promise((r,y)=>{var w;(w=this.preprocessor)==null||w.call(this,{pathname:c,resolve:r,reject:y})})}catch(r){r?console.error(r):console.log("Route change canceled"),z=!1}if(!z||e(this,C)!==c){e(this,E).forEach(r=>{r.checkCurrent(e(this,m))});return}const lt=yield d(this,l,et).call(this,e(this,m)),S=yield d(this,l,et).call(this,c,f);if(e(this,C)!==c){e(this,E).forEach(r=>{r.checkCurrent(e(this,m))});return}lt.saveScrollState(),lt.saveDocumentState(),e(this,k)||(S.clearScrollState(),S.clearDocumentState()),S.cloneDocument(),e(this,q).textContent=S.title,document.body.appendChild(e(this,q));const ct={pathname:c};j.dispatchEvent(document,"morphStart",{detail:ct});const ht=Array.from(document.head.children),ut=Array.from(S.document.head.children),dt=d(this,l,bt).call(this,ht,ut),Ct=d(this,l,nt).call(this,ht,dt),Y=d(this,l,nt).call(this,ut,dt);Y.forEach((r,y)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const w=document.createElement("script");w.type="module",w.src=r.getAttribute("src"),Y[y]=w}}),Y.forEach(r=>{document.head.appendChild(r)});const $=Y.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,l,rt).call(this,r))return!0});e(this,A).waitForHeadToLoad&&$.length&&(yield new Promise(r=>M(this,null,function*(){let y=0;try{for(var w=vt($),ft,W,pt;ft=!(W=yield w.next()).done;ft=!1){const G=W.value;G.onload=()=>{y++,y===$.length&&r()}}}catch(W){pt=[W]}finally{try{ft&&(W=w.return)&&(yield W.call(w))}finally{if(pt)throw pt[0]}}})));const mt=[];Ct.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,l,rt).call(this,r)?mt.push(r):r.remove())});const kt=d(this,l,it).call(this,S.document.body);d(this,l,ot).call(this,S.document),document.documentElement.setAttribute("data-current-pathname",c),document.documentElement.setAttribute("data-current-leaf",At),Q.changeHistory({action:s,pathname:c,searchParameters:Pt,hash:g}),e(this,q).remove(),a(this,K,e(this,m)),a(this,m,c),e(this,_).forEach((r,y)=>{const w=kt[y],ft=getComputedStyle(r).getPropertyValue("--morph-duration"),W=[...w.childNodes];if(ft){const pt=[...r.childNodes];pt.forEach(v=>{v instanceof HTMLElement&&v.classList.add("old")}),W.forEach(v=>{v instanceof HTMLElement&&v.classList.add("new")}),r.prepend(...W),Mt.requestIdleCallback(()=>{W.forEach(v=>{v instanceof HTMLElement&&v.classList.add("in")})});const G={morphElement:r,pathname:c};j.dispatchEvent(document,"morphNewChildrenAdded",{detail:G});const Tt=new Promise(v=>{setTimeout(()=>{pt.forEach(J=>J.remove()),W.forEach(J=>{J instanceof HTMLElement&&J.classList.remove("in","new")}),j.dispatchEvent(document,"morphOldChildrenRemoved",{detail:G}),v()},(parseFloat(ft)||0)*1e3+10)});e(this,R).push(Tt)}else r.innerHTML="",r.append(...W)}),g?(S.clearScrollState(),d(this,l,at).call(this,g,{centerScroll:i,offsetScroll:u})):e(this,k)&&S.restoreScrollPosition(),yield Promise.all(e(this,R)),mt.forEach(r=>r.remove()),a(this,R,[]),this.findLinks(),j.dispatchEvent(document,"morphComplete",{detail:ct}),window.dispatchEvent(new Event("resize"))}catch(z){console.error(z)}a(this,C,void 0)})}addLink(t){e(this,E).push(new Lt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var i;return((i=s.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,E).forEach(s=>s.destroy()),a(this,E,t.map(s=>new Lt(s,this)))}}A=new WeakMap,_=new WeakMap,E=new WeakMap,X=new WeakMap,C=new WeakMap,m=new WeakMap,K=new WeakMap,R=new WeakMap,k=new WeakMap,L=new WeakMap,V=new WeakMap,q=new WeakMap,l=new WeakSet,et=function(t,s=!1){return M(this,null,function*(){let i=e(this,V).get(t);return(!i||s)&&(i=yield d(this,l,st).call(this,t)),i})},st=function(t){return M(this,null,function*(){const i=yield(yield fetch(t)).text(),u=e(this,X).parseFromString(i,"text/html"),f=new St(this,t,u);return e(this,V).set(t,f),f})},it=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},bt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},nt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},rt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},ot=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,B)),a(this,L,t.querySelector(e(this,A).scrollSelector)||t.documentElement),(i=e(this,L))==null||i.addEventListener("scroll",e(this,B)),e(this,B).call(this)},at=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ht.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},Z=new WeakMap,B=new WeakMap;exports.Morph=Nt;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var
|
|
1
|
+
var pt = (r, t) => (t = Symbol[r]) ? t : Symbol.for("Symbol." + r), Et = (r) => {
|
|
2
2
|
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var e = (r, t, s) => (
|
|
6
|
-
var
|
|
7
|
-
var f = (
|
|
4
|
+
var $ = (r, t, s) => t.has(r) || Et("Cannot " + s);
|
|
5
|
+
var e = (r, t, s) => ($(r, t, "read from private field"), s ? s.call(r) : t.get(r)), o = (r, t, s) => t.has(r) ? Et("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, s), a = (r, t, s, i) => ($(r, t, "write to private field"), i ? i.call(r, s) : t.set(r, s), s), d = (r, t, s) => ($(r, t, "access private method"), s);
|
|
6
|
+
var M = (r, t, s) => new Promise((i, u) => {
|
|
7
|
+
var f = (h) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
T(s.next(h));
|
|
10
10
|
} catch (g) {
|
|
11
11
|
u(g);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, O = (h) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
T(s.throw(h));
|
|
16
16
|
} catch (g) {
|
|
17
17
|
u(g);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, T = (h) => h.done ? i(h.value) : Promise.resolve(h.value).then(f, O);
|
|
20
|
+
T((s = s.apply(r, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var
|
|
23
|
-
import { i as
|
|
24
|
-
import { d as
|
|
25
|
-
import { r as
|
|
26
|
-
import { s as
|
|
27
|
-
import { n as
|
|
28
|
-
import { cssValueParser as
|
|
29
|
-
class
|
|
22
|
+
var gt = (r, t, s) => (t = r[pt("asyncIterator")]) ? t.call(r) : (r = r[pt("iterator")](), t = {}, s = (i, u) => (u = r[i]) && (t[i] = (f) => new Promise((O, T, h) => (f = u.call(r, f), h = f.done, Promise.resolve(f.value).then((g) => O({ value: g, done: h }), T)))), s("next"), s("return"), t);
|
|
23
|
+
import { i as yt } from "../index-euf5anj6.js";
|
|
24
|
+
import { d as U } from "../events-CsVF98U6.js";
|
|
25
|
+
import { r as Mt } from "../polyfills-DJrTJQky.js";
|
|
26
|
+
import { s as Ht } from "../scroll-myLAt-Tq.js";
|
|
27
|
+
import { n as xt, c as vt, s as Nt } from "../url-CfcHdBT6.js";
|
|
28
|
+
import { cssValueParser as Dt } from "../css-value-parser/index.js";
|
|
29
|
+
class wt extends HTMLElement {
|
|
30
30
|
connectedCallback() {
|
|
31
31
|
const t = {
|
|
32
32
|
"aria-live": "assertive",
|
|
@@ -37,72 +37,72 @@ class yt extends HTMLElement {
|
|
|
37
37
|
this.setAttribute(s, i);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
class
|
|
40
|
+
yt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", wt);
|
|
41
|
+
var b, c, H, j, F;
|
|
42
|
+
class Lt {
|
|
43
43
|
constructor(t, s) {
|
|
44
|
-
o(this,
|
|
44
|
+
o(this, b);
|
|
45
45
|
o(this, c);
|
|
46
|
-
o(this,
|
|
47
|
-
o(this,
|
|
46
|
+
o(this, H);
|
|
47
|
+
o(this, j, (t) => {
|
|
48
48
|
t.preventDefault();
|
|
49
49
|
const s = e(this, c).getAttribute(
|
|
50
50
|
"data-history-action"
|
|
51
|
-
) || "push", i = e(this, c).hasAttribute("data-center-scroll"), u = getComputedStyle(e(this, c)).getPropertyValue("--offset-scroll").trim(), f = u ?
|
|
52
|
-
e(this,
|
|
51
|
+
) || "push", i = e(this, c).hasAttribute("data-center-scroll"), u = getComputedStyle(e(this, c)).getPropertyValue("--offset-scroll").trim(), f = u ? Dt.parse(u) : void 0, O = e(this, c).hasAttribute("data-revalidate");
|
|
52
|
+
e(this, b).navigate(e(this, H), {
|
|
53
53
|
historyAction: s,
|
|
54
54
|
centerScroll: i,
|
|
55
55
|
offsetScroll: f,
|
|
56
|
-
revalidate:
|
|
56
|
+
revalidate: O
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
-
o(this,
|
|
60
|
-
e(this,
|
|
59
|
+
o(this, F, () => {
|
|
60
|
+
e(this, b).prefetch(e(this, H)), e(this, c).removeEventListener("pointerenter", e(this, F));
|
|
61
61
|
});
|
|
62
|
-
a(this,
|
|
62
|
+
a(this, b, s), a(this, c, t), a(this, H, e(this, c).getAttribute("href") || "/"), e(this, c).addEventListener("click", e(this, j)), this.checkCurrent(location.pathname), e(this, c).hasAttribute("data-prefetch") && e(this, c).addEventListener("pointerenter", e(this, F));
|
|
63
63
|
}
|
|
64
64
|
get element() {
|
|
65
65
|
return e(this, c);
|
|
66
66
|
}
|
|
67
67
|
checkCurrent(t) {
|
|
68
|
-
const s = e(this,
|
|
68
|
+
const s = e(this, b).normalizePath(t), i = e(this, b).normalizePath(e(this, H));
|
|
69
69
|
e(this, c).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, c).classList.add("current") : i.pathname === s.pathname ? e(this, c).classList.add("current") : e(this, c).classList.remove("current");
|
|
70
70
|
}
|
|
71
71
|
destroy() {
|
|
72
|
-
e(this, c).removeEventListener("click", e(this,
|
|
72
|
+
e(this, c).removeEventListener("click", e(this, j)), e(this, c).removeEventListener("pointerenter", e(this, F)), e(this, c).classList.remove("current");
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
var
|
|
75
|
+
b = new WeakMap(), c = new WeakMap(), H = new WeakMap(), j = new WeakMap(), F = new WeakMap();
|
|
76
|
+
var x, I, p, N, D, P;
|
|
77
77
|
class St {
|
|
78
78
|
constructor(t, s, i) {
|
|
79
|
-
o(this, H);
|
|
80
|
-
o(this, F);
|
|
81
|
-
o(this, p, { x: 0, y: 0 });
|
|
82
79
|
o(this, x);
|
|
83
|
-
o(this,
|
|
84
|
-
o(this,
|
|
85
|
-
|
|
80
|
+
o(this, I);
|
|
81
|
+
o(this, p, { x: 0, y: 0 });
|
|
82
|
+
o(this, N);
|
|
83
|
+
o(this, D, null);
|
|
84
|
+
o(this, P, null);
|
|
85
|
+
a(this, x, t), a(this, I, s), a(this, N, i.cloneNode(!0));
|
|
86
86
|
}
|
|
87
87
|
get pathname() {
|
|
88
|
-
return e(this,
|
|
88
|
+
return e(this, I);
|
|
89
89
|
}
|
|
90
90
|
get scrollState() {
|
|
91
91
|
return e(this, p);
|
|
92
92
|
}
|
|
93
93
|
get document() {
|
|
94
|
-
return e(this,
|
|
94
|
+
return e(this, P);
|
|
95
95
|
}
|
|
96
96
|
cloneDocument() {
|
|
97
|
-
a(this,
|
|
97
|
+
a(this, P, (e(this, D) || e(this, N)).cloneNode(!0));
|
|
98
98
|
}
|
|
99
99
|
get title() {
|
|
100
100
|
let t = "";
|
|
101
|
-
if (e(this,
|
|
102
|
-
t = e(this,
|
|
101
|
+
if (e(this, P).title)
|
|
102
|
+
t = e(this, P).title;
|
|
103
103
|
else {
|
|
104
|
-
const s = e(this,
|
|
105
|
-
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this,
|
|
104
|
+
const s = e(this, P).querySelector("h1");
|
|
105
|
+
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, I);
|
|
106
106
|
}
|
|
107
107
|
return t;
|
|
108
108
|
}
|
|
@@ -110,54 +110,63 @@ class St {
|
|
|
110
110
|
e(this, p).x = 0, e(this, p).y = 0;
|
|
111
111
|
}
|
|
112
112
|
clearDocumentState() {
|
|
113
|
-
a(this,
|
|
113
|
+
a(this, D, null);
|
|
114
114
|
}
|
|
115
115
|
saveScrollState() {
|
|
116
|
-
e(this,
|
|
116
|
+
e(this, N).documentElement.hasAttribute(
|
|
117
117
|
"data-no-scroll-restoration"
|
|
118
|
-
) ? (e(this, p).x = 0, e(this, p).y = 0) : (e(this, p).x = e(this,
|
|
118
|
+
) ? (e(this, p).x = 0, e(this, p).y = 0) : (e(this, p).x = e(this, x).scrollElement.scrollLeft, e(this, p).y = e(this, x).scrollElement.scrollTop);
|
|
119
119
|
}
|
|
120
120
|
saveDocumentState() {
|
|
121
|
-
e(this,
|
|
121
|
+
e(this, N).documentElement.hasAttribute(
|
|
122
122
|
"data-no-page-restoration"
|
|
123
|
-
) ? a(this,
|
|
123
|
+
) ? a(this, D, null) : a(this, D, document.cloneNode(!0));
|
|
124
124
|
}
|
|
125
125
|
restoreScrollPosition() {
|
|
126
|
-
e(this,
|
|
126
|
+
e(this, x).scrollElement.scroll({
|
|
127
127
|
top: e(this, p).y,
|
|
128
128
|
left: e(this, p).x
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
|
|
133
|
-
var
|
|
134
|
-
class
|
|
132
|
+
x = new WeakMap(), I = new WeakMap(), p = new WeakMap(), N = new WeakMap(), D = new WeakMap(), P = new WeakMap();
|
|
133
|
+
var A, K, E, X, C, m, Y, R, k, L, V, z, l, tt, et, st, bt, it, rt, nt, ot, Z, B;
|
|
134
|
+
class Ot {
|
|
135
135
|
constructor(t) {
|
|
136
|
-
o(this,
|
|
137
|
-
o(this,
|
|
138
|
-
o(this,
|
|
136
|
+
o(this, l);
|
|
137
|
+
o(this, A, null);
|
|
138
|
+
o(this, K, null);
|
|
139
139
|
o(this, E, []);
|
|
140
|
-
o(this,
|
|
141
|
-
o(this,
|
|
140
|
+
o(this, X, new DOMParser());
|
|
141
|
+
o(this, C);
|
|
142
142
|
o(this, m, null);
|
|
143
|
-
o(this,
|
|
144
|
-
o(this,
|
|
145
|
-
o(this,
|
|
146
|
-
o(this,
|
|
143
|
+
o(this, Y);
|
|
144
|
+
o(this, R, []);
|
|
145
|
+
o(this, k, !1);
|
|
146
|
+
o(this, L, null);
|
|
147
147
|
o(this, V, /* @__PURE__ */ new Map());
|
|
148
|
-
o(this,
|
|
149
|
-
o(this,
|
|
148
|
+
o(this, z, null);
|
|
149
|
+
o(this, Z, (t) => M(this, null, function* () {
|
|
150
150
|
var s;
|
|
151
|
-
(s = t.state) != null && s.path && (a(this,
|
|
151
|
+
(s = t.state) != null && s.path && (t.preventDefault(), a(this, k, !0), yield this.navigate(t.state.path, { historyAction: "none" }), a(this, k, !1));
|
|
152
152
|
}));
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
o(this, B, () => {
|
|
154
|
+
const t = e(this, L).scrollTop, s = e(this, L).scrollLeft;
|
|
155
|
+
document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0), U(document, "morphScroll", {
|
|
156
|
+
detail: {
|
|
157
|
+
left: s,
|
|
158
|
+
top: t
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
if (yt) {
|
|
163
|
+
a(this, A, {
|
|
164
|
+
base: xt(t == null ? void 0 : t.base),
|
|
156
165
|
waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
|
|
157
166
|
cachePages: (t == null ? void 0 : t.cachePages) !== !1,
|
|
158
167
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
159
168
|
scrollSelector: (t == null ? void 0 : t.scrollSelector) || "body"
|
|
160
|
-
}), a(this,
|
|
169
|
+
}), a(this, K, d(this, l, st).call(this, document.body));
|
|
161
170
|
const s = this.normalizePath(
|
|
162
171
|
location.pathname + location.hash
|
|
163
172
|
);
|
|
@@ -170,183 +179,183 @@ class Bt {
|
|
|
170
179
|
), document.documentElement.setAttribute(
|
|
171
180
|
"data-current-leaf",
|
|
172
181
|
s.leaf
|
|
173
|
-
), this.findLinks(), addEventListener("popstate", e(this,
|
|
182
|
+
), this.findLinks(), addEventListener("popstate", e(this, Z)), vt({
|
|
174
183
|
action: "replace",
|
|
175
184
|
pathname: e(this, m),
|
|
176
185
|
searchParameters: s.parameters,
|
|
177
186
|
hash: s.hash
|
|
178
|
-
}), a(this,
|
|
187
|
+
}), a(this, z, new wt()), d(this, l, nt).call(this, document);
|
|
179
188
|
}
|
|
180
189
|
}
|
|
181
190
|
get currentPathname() {
|
|
182
191
|
return e(this, m);
|
|
183
192
|
}
|
|
184
193
|
get previousPathname() {
|
|
185
|
-
return e(this,
|
|
194
|
+
return e(this, Y);
|
|
186
195
|
}
|
|
187
196
|
get links() {
|
|
188
197
|
return e(this, E);
|
|
189
198
|
}
|
|
190
199
|
get scrollElement() {
|
|
191
|
-
return e(this,
|
|
200
|
+
return e(this, L);
|
|
192
201
|
}
|
|
193
202
|
normalizePath(t) {
|
|
194
|
-
return
|
|
195
|
-
base: e(this,
|
|
196
|
-
trailingSlash: e(this,
|
|
203
|
+
return Nt(t, {
|
|
204
|
+
base: e(this, A).base,
|
|
205
|
+
trailingSlash: e(this, A).trailingSlash
|
|
197
206
|
});
|
|
198
207
|
}
|
|
199
208
|
prefetch(t) {
|
|
200
|
-
return
|
|
209
|
+
return M(this, null, function* () {
|
|
201
210
|
const s = this.normalizePath(t);
|
|
202
|
-
d(this,
|
|
211
|
+
d(this, l, et).call(this, s.pathname);
|
|
203
212
|
});
|
|
204
213
|
}
|
|
205
|
-
navigate(
|
|
206
|
-
return
|
|
214
|
+
navigate(O) {
|
|
215
|
+
return M(this, arguments, function* (t, {
|
|
207
216
|
historyAction: s = "push",
|
|
208
217
|
centerScroll: i,
|
|
209
218
|
offsetScroll: u,
|
|
210
219
|
revalidate: f
|
|
211
220
|
} = {}) {
|
|
212
|
-
if (e(this,
|
|
221
|
+
if (e(this, R).length)
|
|
213
222
|
return;
|
|
214
|
-
const
|
|
215
|
-
let { pathname:
|
|
216
|
-
if (e(this,
|
|
217
|
-
e(this,
|
|
223
|
+
const T = this.normalizePath(t);
|
|
224
|
+
let { pathname: h, hash: g, parameters: Pt, leaf: At } = T;
|
|
225
|
+
if (e(this, C) === h || e(this, m) === h) {
|
|
226
|
+
e(this, k) || d(this, l, ot).call(this, g || 0, {
|
|
218
227
|
centerScroll: i,
|
|
219
228
|
offsetScroll: u,
|
|
220
229
|
behavior: "smooth"
|
|
221
230
|
});
|
|
222
231
|
return;
|
|
223
232
|
}
|
|
224
|
-
a(this,
|
|
225
|
-
|
|
233
|
+
a(this, C, h), e(this, E).forEach((q) => {
|
|
234
|
+
q.checkCurrent(h);
|
|
226
235
|
});
|
|
227
236
|
try {
|
|
228
|
-
let
|
|
237
|
+
let q = !0;
|
|
229
238
|
if (this.preprocessor)
|
|
230
239
|
try {
|
|
231
|
-
yield new Promise((n,
|
|
232
|
-
var
|
|
233
|
-
(
|
|
234
|
-
pathname:
|
|
240
|
+
yield new Promise((n, y) => {
|
|
241
|
+
var w;
|
|
242
|
+
(w = this.preprocessor) == null || w.call(this, {
|
|
243
|
+
pathname: h,
|
|
235
244
|
resolve: n,
|
|
236
|
-
reject:
|
|
245
|
+
reject: y
|
|
237
246
|
});
|
|
238
247
|
});
|
|
239
248
|
} catch (n) {
|
|
240
|
-
n ? console.error(n) : console.log("Route change canceled"),
|
|
249
|
+
n ? console.error(n) : console.log("Route change canceled"), q = !1;
|
|
241
250
|
}
|
|
242
|
-
if (!
|
|
251
|
+
if (!q || e(this, C) !== h) {
|
|
243
252
|
e(this, E).forEach((n) => {
|
|
244
253
|
n.checkCurrent(e(this, m));
|
|
245
254
|
});
|
|
246
255
|
return;
|
|
247
256
|
}
|
|
248
|
-
const
|
|
249
|
-
if (e(this,
|
|
257
|
+
const at = yield d(this, l, tt).call(this, e(this, m)), S = yield d(this, l, tt).call(this, h, f);
|
|
258
|
+
if (e(this, C) !== h) {
|
|
250
259
|
e(this, E).forEach((n) => {
|
|
251
260
|
n.checkCurrent(e(this, m));
|
|
252
261
|
});
|
|
253
262
|
return;
|
|
254
263
|
}
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
pathname:
|
|
264
|
+
at.saveScrollState(), at.saveDocumentState(), e(this, k) || (S.clearScrollState(), S.clearDocumentState()), S.cloneDocument(), e(this, z).textContent = S.title, document.body.appendChild(e(this, z));
|
|
265
|
+
const lt = {
|
|
266
|
+
pathname: h
|
|
258
267
|
};
|
|
259
|
-
|
|
260
|
-
detail:
|
|
268
|
+
U(document, "morphStart", {
|
|
269
|
+
detail: lt
|
|
261
270
|
});
|
|
262
|
-
const ht = Array.from(document.head.children),
|
|
263
|
-
|
|
271
|
+
const ht = Array.from(document.head.children), ct = Array.from(S.document.head.children), ut = d(this, l, bt).call(this, ht, ct), Ct = d(this, l, it).call(this, ht, ut), G = d(this, l, it).call(this, ct, ut);
|
|
272
|
+
G.forEach((n, y) => {
|
|
264
273
|
if (n.tagName === "SCRIPT" && n.getAttribute("src")) {
|
|
265
|
-
const
|
|
266
|
-
|
|
274
|
+
const w = document.createElement("script");
|
|
275
|
+
w.type = "module", w.src = n.getAttribute("src"), G[y] = w;
|
|
267
276
|
}
|
|
268
|
-
}),
|
|
277
|
+
}), G.forEach((n) => {
|
|
269
278
|
document.head.appendChild(n);
|
|
270
279
|
});
|
|
271
|
-
const
|
|
280
|
+
const _ = G.filter((n) => {
|
|
272
281
|
if (n.hasAttribute("data-no-waiting"))
|
|
273
282
|
return !1;
|
|
274
|
-
if (d(this,
|
|
283
|
+
if (d(this, l, rt).call(this, n))
|
|
275
284
|
return !0;
|
|
276
285
|
});
|
|
277
|
-
e(this,
|
|
278
|
-
let
|
|
286
|
+
e(this, A).waitForHeadToLoad && _.length && (yield new Promise((n) => M(this, null, function* () {
|
|
287
|
+
let y = 0;
|
|
279
288
|
try {
|
|
280
|
-
for (var
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
289
|
+
for (var w = gt(_), mt, W, ft; mt = !(W = yield w.next()).done; mt = !1) {
|
|
290
|
+
const J = W.value;
|
|
291
|
+
J.onload = () => {
|
|
292
|
+
y++, y === _.length && n();
|
|
284
293
|
};
|
|
285
294
|
}
|
|
286
|
-
} catch (
|
|
287
|
-
|
|
295
|
+
} catch (W) {
|
|
296
|
+
ft = [W];
|
|
288
297
|
} finally {
|
|
289
298
|
try {
|
|
290
|
-
|
|
299
|
+
mt && (W = w.return) && (yield W.call(w));
|
|
291
300
|
} finally {
|
|
292
|
-
if (
|
|
293
|
-
throw
|
|
301
|
+
if (ft)
|
|
302
|
+
throw ft[0];
|
|
294
303
|
}
|
|
295
304
|
}
|
|
296
305
|
})));
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
n.hasAttribute("data-permanent") || (d(this,
|
|
306
|
+
const dt = [];
|
|
307
|
+
Ct.forEach((n) => {
|
|
308
|
+
n.hasAttribute("data-permanent") || (d(this, l, rt).call(this, n) ? dt.push(n) : n.remove());
|
|
300
309
|
});
|
|
301
|
-
const
|
|
302
|
-
d(this,
|
|
310
|
+
const kt = d(this, l, st).call(this, S.document.body);
|
|
311
|
+
d(this, l, nt).call(this, S.document), document.documentElement.setAttribute("data-current-pathname", h), document.documentElement.setAttribute("data-current-leaf", At), vt({
|
|
303
312
|
action: s,
|
|
304
|
-
pathname:
|
|
305
|
-
searchParameters:
|
|
313
|
+
pathname: h,
|
|
314
|
+
searchParameters: Pt,
|
|
306
315
|
hash: g
|
|
307
|
-
}), e(this,
|
|
308
|
-
const
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
|
|
316
|
+
}), e(this, z).remove(), a(this, Y, e(this, m)), a(this, m, h), e(this, K).forEach((n, y) => {
|
|
317
|
+
const w = kt[y], mt = getComputedStyle(n).getPropertyValue("--morph-duration"), W = [...w.childNodes];
|
|
318
|
+
if (mt) {
|
|
319
|
+
const ft = [...n.childNodes];
|
|
320
|
+
ft.forEach((v) => {
|
|
312
321
|
v instanceof HTMLElement && v.classList.add("old");
|
|
313
|
-
}),
|
|
322
|
+
}), W.forEach((v) => {
|
|
314
323
|
v instanceof HTMLElement && v.classList.add("new");
|
|
315
|
-
}), n.prepend(...
|
|
316
|
-
|
|
324
|
+
}), n.prepend(...W), Mt(() => {
|
|
325
|
+
W.forEach((v) => {
|
|
317
326
|
v instanceof HTMLElement && v.classList.add("in");
|
|
318
327
|
});
|
|
319
328
|
});
|
|
320
|
-
const
|
|
329
|
+
const J = {
|
|
321
330
|
morphElement: n,
|
|
322
|
-
pathname:
|
|
331
|
+
pathname: h
|
|
323
332
|
};
|
|
324
|
-
|
|
325
|
-
detail:
|
|
333
|
+
U(document, "morphNewChildrenAdded", {
|
|
334
|
+
detail: J
|
|
326
335
|
});
|
|
327
|
-
const
|
|
336
|
+
const Tt = new Promise((v) => {
|
|
328
337
|
setTimeout(() => {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}),
|
|
332
|
-
detail:
|
|
338
|
+
ft.forEach((Q) => Q.remove()), W.forEach((Q) => {
|
|
339
|
+
Q instanceof HTMLElement && Q.classList.remove("in", "new");
|
|
340
|
+
}), U(document, "morphOldChildrenRemoved", {
|
|
341
|
+
detail: J
|
|
333
342
|
}), v();
|
|
334
|
-
}, (parseFloat(
|
|
343
|
+
}, (parseFloat(mt) || 0) * 1e3 + 10);
|
|
335
344
|
});
|
|
336
|
-
e(this,
|
|
345
|
+
e(this, R).push(Tt);
|
|
337
346
|
} else
|
|
338
|
-
n.innerHTML = "", n.append(...
|
|
339
|
-
}), g ? (S.clearScrollState(), d(this,
|
|
340
|
-
detail:
|
|
347
|
+
n.innerHTML = "", n.append(...W);
|
|
348
|
+
}), g ? (S.clearScrollState(), d(this, l, ot).call(this, g, { centerScroll: i, offsetScroll: u })) : e(this, k) && S.restoreScrollPosition(), yield Promise.all(e(this, R)), dt.forEach((n) => n.remove()), a(this, R, []), this.findLinks(), U(document, "morphComplete", {
|
|
349
|
+
detail: lt
|
|
341
350
|
}), window.dispatchEvent(new Event("resize"));
|
|
342
|
-
} catch (
|
|
343
|
-
console.error(
|
|
351
|
+
} catch (q) {
|
|
352
|
+
console.error(q);
|
|
344
353
|
}
|
|
345
|
-
a(this,
|
|
354
|
+
a(this, C, void 0);
|
|
346
355
|
});
|
|
347
356
|
}
|
|
348
357
|
addLink(t) {
|
|
349
|
-
e(this, E).push(new
|
|
358
|
+
e(this, E).push(new Lt(t, this));
|
|
350
359
|
}
|
|
351
360
|
addLinks(t) {
|
|
352
361
|
t.forEach((s) => {
|
|
@@ -365,47 +374,51 @@ class Bt {
|
|
|
365
374
|
return ((i = s.getAttribute("href")) == null ? void 0 : i.startsWith("/")) && !s.hasAttribute("download") && !s.hasAttribute("data-morph-skip") && !s.closest("[data-morph-skip]");
|
|
366
375
|
}
|
|
367
376
|
);
|
|
368
|
-
e(this, E).forEach((s) => s.destroy()), a(this, E, t.map((s) => new
|
|
377
|
+
e(this, E).forEach((s) => s.destroy()), a(this, E, t.map((s) => new Lt(s, this)));
|
|
369
378
|
}
|
|
370
379
|
}
|
|
371
|
-
|
|
372
|
-
return
|
|
380
|
+
A = new WeakMap(), K = new WeakMap(), E = new WeakMap(), X = new WeakMap(), C = new WeakMap(), m = new WeakMap(), Y = new WeakMap(), R = new WeakMap(), k = new WeakMap(), L = new WeakMap(), V = new WeakMap(), z = new WeakMap(), l = new WeakSet(), tt = function(t, s = !1) {
|
|
381
|
+
return M(this, null, function* () {
|
|
373
382
|
let i = e(this, V).get(t);
|
|
374
|
-
return (!i || s) && (i = yield d(this,
|
|
383
|
+
return (!i || s) && (i = yield d(this, l, et).call(this, t)), i;
|
|
375
384
|
});
|
|
376
|
-
},
|
|
377
|
-
return
|
|
378
|
-
const i = yield (yield fetch(t)).text(), u = e(this,
|
|
385
|
+
}, et = function(t) {
|
|
386
|
+
return M(this, null, function* () {
|
|
387
|
+
const i = yield (yield fetch(t)).text(), u = e(this, X).parseFromString(i, "text/html"), f = new St(this, t, u);
|
|
379
388
|
return e(this, V).set(t, f), f;
|
|
380
389
|
});
|
|
381
|
-
},
|
|
390
|
+
}, st = function(t) {
|
|
382
391
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
383
392
|
return s.length ? s : [t];
|
|
384
|
-
},
|
|
393
|
+
}, bt = function(t, s) {
|
|
385
394
|
return t.filter(
|
|
386
395
|
(i) => s.find(
|
|
387
396
|
(u) => u.outerHTML === i.outerHTML
|
|
388
397
|
)
|
|
389
398
|
);
|
|
390
|
-
},
|
|
399
|
+
}, it = function(t, s) {
|
|
391
400
|
return t.filter(
|
|
392
401
|
(i) => !s.find(
|
|
393
402
|
(u) => u.outerHTML === i.outerHTML
|
|
394
403
|
)
|
|
395
404
|
);
|
|
396
|
-
}, it = function(t) {
|
|
397
|
-
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
398
405
|
}, rt = function(t) {
|
|
399
|
-
|
|
400
|
-
}, nt = function(t
|
|
406
|
+
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
407
|
+
}, nt = function(t) {
|
|
408
|
+
var s, i;
|
|
409
|
+
(s = e(this, L)) == null || s.removeEventListener(
|
|
410
|
+
"scroll",
|
|
411
|
+
e(this, B)
|
|
412
|
+
), a(this, L, t.querySelector(e(this, A).scrollSelector) || t.documentElement), (i = e(this, L)) == null || i.addEventListener("scroll", e(this, B)), e(this, B).call(this);
|
|
413
|
+
}, ot = function(t, s) {
|
|
401
414
|
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
402
|
-
(typeof i == "number" || i) &&
|
|
403
|
-
scrollElement: e(this,
|
|
415
|
+
(typeof i == "number" || i) && Ht(i, {
|
|
416
|
+
scrollElement: e(this, L),
|
|
404
417
|
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
405
418
|
center: s == null ? void 0 : s.centerScroll,
|
|
406
419
|
offset: s == null ? void 0 : s.offsetScroll
|
|
407
420
|
});
|
|
408
|
-
},
|
|
421
|
+
}, Z = new WeakMap(), B = new WeakMap();
|
|
409
422
|
export {
|
|
410
|
-
|
|
423
|
+
Ot as Morph
|
|
411
424
|
};
|
package/lib/utils/events.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function dispatchEvent<K extends keyof HTMLElementEventMap | keyof WindowEventMap | keyof DocumentEventMap>(from: HTMLElement | Window | Document, name: K, init?: CustomEventInit<K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] extends CustomEvent<any> ? HTMLElementEventMap[K]['detail'] : unknown : K extends keyof WindowEventMap ? WindowEventMap[K] extends CustomEvent<any> ? WindowEventMap[K]['detail'] : unknown : unknown> & {
|
|
1
|
+
export declare function dispatchEvent<K extends keyof HTMLElementEventMap | keyof WindowEventMap | keyof DocumentEventMap>(from: HTMLElement | Window | Document, name: K, init?: CustomEventInit<K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] extends CustomEvent<any> ? HTMLElementEventMap[K]['detail'] : unknown : K extends keyof WindowEventMap ? WindowEventMap[K] extends CustomEvent<any> ? WindowEventMap[K]['detail'] : unknown : K extends keyof DocumentEventMap ? DocumentEventMap[K] extends CustomEvent<any> ? DocumentEventMap[K]['detail'] : unknown : unknown> & {
|
|
2
2
|
custom?: boolean;
|
|
3
3
|
}): void;
|