aptechka 0.4.14 → 0.4.16
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/{Damped-BZujMwuv.js → Damped-B91XlC1a.js} +6 -7
- package/lib/Damped-D2k3SbmP.cjs +1 -0
- package/lib/animation/Animation.d.ts +2 -2
- package/lib/animation/index.cjs +1 -1
- package/lib/animation/index.js +21 -20
- package/lib/morph/Link.d.ts +1 -1
- package/lib/morph/Morph.d.ts +2 -2
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +142 -120
- package/lib/scroll/ScrollElement.d.ts +13 -9
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +527 -491
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.js +38 -36
- package/package.json +1 -1
- package/lib/Damped-DK3CSBXb.cjs +0 -1
|
@@ -27,7 +27,7 @@ import { S as M } from "./Store-Cd-E5W1z.js";
|
|
|
27
27
|
import { ticker as R } from "./ticker/index.js";
|
|
28
28
|
var d, f, F, g, y;
|
|
29
29
|
class E extends M {
|
|
30
|
-
constructor(t
|
|
30
|
+
constructor(t) {
|
|
31
31
|
super(t || 0);
|
|
32
32
|
a(this, d, void 0);
|
|
33
33
|
a(this, f, void 0);
|
|
@@ -36,7 +36,6 @@ class E extends M {
|
|
|
36
36
|
a(this, y, (t) => {
|
|
37
37
|
this.handleAnimationFrame(t);
|
|
38
38
|
});
|
|
39
|
-
this.updateOptions(h);
|
|
40
39
|
}
|
|
41
40
|
get isRunning() {
|
|
42
41
|
return s(this, g);
|
|
@@ -47,9 +46,6 @@ class E extends M {
|
|
|
47
46
|
close() {
|
|
48
47
|
super.close(), this.unlistenAnimationFrame();
|
|
49
48
|
}
|
|
50
|
-
updateOptions(t) {
|
|
51
|
-
r(this, d, c(t == null ? void 0 : t.maxFPS, s(this, d))), r(this, f, c(t == null ? void 0 : t.order, s(this, f))), r(this, F, c(t == null ? void 0 : t.culling, s(this, F)));
|
|
52
|
-
}
|
|
53
49
|
listenAnimationFrame() {
|
|
54
50
|
s(this, g).current || (s(this, g).current = !0, R.subscribe(s(this, y), {
|
|
55
51
|
maxFPS: s(this, d),
|
|
@@ -60,12 +56,15 @@ class E extends M {
|
|
|
60
56
|
unlistenAnimationFrame() {
|
|
61
57
|
s(this, g).current && (s(this, g).current = !1, R.unsubscribe(s(this, y)));
|
|
62
58
|
}
|
|
59
|
+
updateOptions(t) {
|
|
60
|
+
r(this, d, c(t == null ? void 0 : t.maxFPS, s(this, d))), r(this, f, c(t == null ? void 0 : t.order, s(this, f))), r(this, F, c(t == null ? void 0 : t.culling, s(this, F)));
|
|
61
|
+
}
|
|
63
62
|
}
|
|
64
63
|
d = new WeakMap(), f = new WeakMap(), F = new WeakMap(), g = new WeakMap(), y = new WeakMap();
|
|
65
64
|
var n, A, m, u, l, x, b;
|
|
66
65
|
class V extends E {
|
|
67
66
|
constructor(t, h) {
|
|
68
|
-
super(t || 0
|
|
67
|
+
super(t || 0);
|
|
69
68
|
a(this, n, void 0);
|
|
70
69
|
a(this, A, void 0);
|
|
71
70
|
a(this, m, void 0);
|
|
@@ -75,7 +74,7 @@ class V extends E {
|
|
|
75
74
|
a(this, b, void 0);
|
|
76
75
|
this.damping = 0.01, this.stiffness = 0, this.mass = 0, r(this, n, 0), r(this, A, 0), r(this, m, 0), r(this, u, 0), r(this, l, 0), r(this, x, 0), r(this, b, () => {
|
|
77
76
|
this.set(s(this, n), !0);
|
|
78
|
-
}), r(this, m, c(h == null ? void 0 : h.min, -1 / 0)), r(this, u, c(h == null ? void 0 : h.max, 1 / 0)), r(this, n, this.current);
|
|
77
|
+
}), r(this, m, c(h == null ? void 0 : h.min, -1 / 0)), r(this, u, c(h == null ? void 0 : h.max, 1 / 0)), r(this, n, this.current), this.updateOptions(h);
|
|
79
78
|
}
|
|
80
79
|
get target() {
|
|
81
80
|
return s(this, n);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var w=Object.defineProperty,L=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var k=(s,e,t)=>e in s?w(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,N=(s,e)=>{for(var t in e||(e={}))j.call(e,t)&&k(s,t,e[t]);if(O)for(var t of O(e))z.call(e,t)&&k(s,t,e[t]);return s},P=(s,e)=>L(s,_(e));var v=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var i=(s,e,t)=>(v(s,e,"read from private field"),t?t.call(s):e.get(s)),a=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},r=(s,e,t,h)=>(v(s,e,"write to private field"),h?h.call(s,t):e.set(s,t),t);const D=require("./math-GDWEqu7y.cjs"),S=require("./number-yVpzMdbQ.cjs"),c=require("./polyfills-CrcS4RcO.cjs");require("./path-data-polyfill-CXsOR7Oc.cjs");const I=require("./Store-BQGNOHlY.cjs"),M=require("./ticker/index.cjs");var d,f,F,m,C;class R extends I.Store{constructor(t){super(t||0);a(this,d,void 0);a(this,f,void 0);a(this,F,void 0);a(this,m,new I.Store(!1));a(this,C,t=>{this.handleAnimationFrame(t)})}get isRunning(){return i(this,m)}reset(){this.unlistenAnimationFrame(),super.reset()}close(){super.close(),this.unlistenAnimationFrame()}listenAnimationFrame(){i(this,m).current||(i(this,m).current=!0,M.ticker.subscribe(i(this,C),{maxFPS:i(this,d),order:i(this,f),culling:i(this,F)}))}unlistenAnimationFrame(){i(this,m).current&&(i(this,m).current=!1,M.ticker.unsubscribe(i(this,C)))}updateOptions(t){r(this,d,c.nullishCoalescing(t==null?void 0:t.maxFPS,i(this,d))),r(this,f,c.nullishCoalescing(t==null?void 0:t.order,i(this,f))),r(this,F,c.nullishCoalescing(t==null?void 0:t.culling,i(this,F)))}}d=new WeakMap,f=new WeakMap,F=new WeakMap,m=new WeakMap,C=new WeakMap;var n,A,u,l,g,x,b;class B extends R{constructor(t,h){super(t||0);a(this,n,void 0);a(this,A,void 0);a(this,u,void 0);a(this,l,void 0);a(this,g,void 0);a(this,x,void 0);a(this,b,void 0);this.damping=.01,this.stiffness=0,this.mass=0,r(this,n,0),r(this,A,0),r(this,u,0),r(this,l,0),r(this,g,0),r(this,x,0),r(this,b,()=>{this.set(i(this,n),!0)}),r(this,u,c.nullishCoalescing(h==null?void 0:h.min,-1/0)),r(this,l,c.nullishCoalescing(h==null?void 0:h.max,1/0)),r(this,n,this.current),this.updateOptions(h)}get target(){return i(this,n)}get direction(){return i(this,A)}get min(){return i(this,u)}set min(t){r(this,u,t),i(this,b).call(this)}get max(){return i(this,l)}set max(t){r(this,l,t),i(this,b).call(this)}get velocity(){return i(this,g)}get speed(){return i(this,x)}get length(){return i(this,l)-i(this,u)}get progress(){return this.length?S.preciseNumber((this.current-i(this,u))/this.length,6):0}get entry(){return P(N({},super.entry),{min:i(this,u),max:i(this,l),length:this.length,direction:this.direction,progress:this.progress})}set(t,h=!1){const y=i(this,n);r(this,n,D.clamp(t,i(this,u),i(this,l))),h&&(this.current=i(this,n)),i(this,n)!==y&&(r(this,A,Math.sign(t-i(this,n))||1),this.listenAnimationFrame())}shift(t,h=!1){this.set(i(this,n)+t,h)}reset(){this.set(this.initial,!0),super.reset()}listenAnimationFrame(){this.current!==this.target&&super.listenAnimationFrame()}updateOptions(t){super.updateOptions(t),this.damping=c.nullishCoalescing(t==null?void 0:t.damping,this.damping),this.mass=c.nullishCoalescing(t==null?void 0:t.damping,this.mass),this.stiffness=c.nullishCoalescing(t==null?void 0:t.damping,this.stiffness)}handleAnimationFrame(t){S.preciseNumber(this.current,4)===S.preciseNumber(this.target,4)&&(this.unlistenAnimationFrame(),this.current=this.target);const h=this.current,y=Math.abs(h-this.target);r(this,x,y/t.elapsed);const q=t.elapsed/1e3;if(this.mass||this.stiffness){const p=(i(this,n)-this.current)*this.stiffness-i(this,g)*this.damping;r(this,g,i(this,g)+p/this.mass*q),this.current+=i(this,g)*q}else this.current=D.damp(this.current,this.target,this.damping,q)}}n=new WeakMap,A=new WeakMap,u=new WeakMap,l=new WeakMap,g=new WeakMap,x=new WeakMap,b=new WeakMap;exports.Animation=R;exports.Damped=B;
|
|
@@ -10,14 +10,14 @@ export interface AnimationOptions extends TickerAddOptions, StoreOptions<number>
|
|
|
10
10
|
}
|
|
11
11
|
export declare abstract class Animation<Options extends AnimationOptions, Entry extends StoreEntry<number> = StoreEntry<number>> extends Store<number, 'number', Entry> {
|
|
12
12
|
#private;
|
|
13
|
-
constructor(initial?: number
|
|
13
|
+
constructor(initial?: number);
|
|
14
14
|
get isRunning(): Store<boolean, keyof import('../store').StoreManagers, StoreEntry<boolean>>;
|
|
15
15
|
abstract set(value: number): void;
|
|
16
16
|
abstract shift(value: number): void;
|
|
17
17
|
reset(): void;
|
|
18
18
|
close(): void;
|
|
19
|
-
updateOptions(options?: Omit<Options, keyof StoreOptions<number>>): void;
|
|
20
19
|
listenAnimationFrame(): void;
|
|
21
20
|
unlistenAnimationFrame(): void;
|
|
21
|
+
updateOptions(options?: Omit<Options, keyof StoreOptions<number>>): void;
|
|
22
22
|
protected abstract handleAnimationFrame(e: TickerCallbackEntry): void;
|
|
23
23
|
}
|
package/lib/animation/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var F=Object.defineProperty,O=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var d=(i,t
|
|
1
|
+
"use strict";var F=Object.defineProperty,O=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var d=(i,e,t)=>e in i?F(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,p=(i,e)=>{for(var t in e||(e={}))D.call(e,t)&&d(i,t,e[t]);if(g)for(var t of g(e))w.call(e,t)&&d(i,t,e[t]);return i},f=(i,e)=>O(i,T(e));var o=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var r=(i,e,t)=>(o(i,e,"read from private field"),t?t.call(i):e.get(i)),u=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},l=(i,e,t,s)=>(o(i,e,"write to private field"),s?s.call(i,t):e.set(i,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../Damped-D2k3SbmP.cjs"),C=require("../easings-DsS5-Kqc.cjs"),M=require("../math-GDWEqu7y.cjs"),q=require("../number-yVpzMdbQ.cjs"),A=require("../polyfills-CrcS4RcO.cjs");require("../path-data-polyfill-CXsOR7Oc.cjs");var c,h,n,a,m;class N extends b.Animation{constructor(t,s){super(t||0);u(this,c,C.linear);u(this,h,1e3);u(this,n,0);u(this,a,0);u(this,m,0);this.updateOptions(s)}get direction(){return r(this,m)}get length(){return r(this,a)-r(this,n)}get progress(){return this.length?q.preciseNumber((this.current-r(this,n))/this.length,6):0}get entry(){return f(p({},super.entry),{length:this.length,direction:this.direction,progress:this.progress})}set(t,s){s!=null&&s.restart&&(this.current=this.initial),l(this,n,this.current),l(this,a,t),l(this,m,Math.sign(this.length)),this.updateOptions(s),r(this,h)?(this.unlistenAnimationFrame(),this.listenAnimationFrame()):(this.current=r(this,a),this.unlistenAnimationFrame())}shift(t,s){this.set(this.current+t,s)}updateOptions(t){super.updateOptions(t),l(this,c,A.nullishCoalescing(t==null?void 0:t.easing,r(this,c))),l(this,h,A.nullishCoalescing(t==null?void 0:t.duration,r(this,h)))}handleAnimationFrame(t){const s=(t.timestamp-t.startTimestamp)/1e3/(r(this,h)/1e3),y=r(this,c).call(this,M.clamp(s,0,1));this.current=q.preciseNumber(r(this,n)+(r(this,a)-r(this,n))*y,6),s>1&&this.unlistenAnimationFrame()}}c=new WeakMap,h=new WeakMap,n=new WeakMap,a=new WeakMap,m=new WeakMap;exports.Damped=b.Damped;exports.Tweened=N;
|
package/lib/animation/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
1
|
+
var x = Object.defineProperty, y = Object.defineProperties;
|
|
2
2
|
var D = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var g = Object.getOwnPropertySymbols;
|
|
4
4
|
var T = Object.prototype.hasOwnProperty, b = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var d = (e, i, t) => i in e ?
|
|
5
|
+
var d = (e, i, t) => i in e ? x(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t, p = (e, i) => {
|
|
6
6
|
for (var t in i || (i = {}))
|
|
7
7
|
T.call(i, t) && d(e, t, i[t]);
|
|
8
8
|
if (g)
|
|
9
9
|
for (var t of g(i))
|
|
10
10
|
b.call(i, t) && d(e, t, i[t]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
12
|
+
}, f = (e, i) => y(e, D(i));
|
|
13
13
|
var o = (e, i, t) => {
|
|
14
14
|
if (!i.has(e))
|
|
15
15
|
throw TypeError("Cannot " + t);
|
|
16
16
|
};
|
|
17
|
-
var
|
|
17
|
+
var r = (e, i, t) => (o(e, i, "read from private field"), t ? t.call(e) : i.get(e)), m = (e, i, t) => {
|
|
18
18
|
if (i.has(e))
|
|
19
19
|
throw TypeError("Cannot add the same private member more than once");
|
|
20
20
|
i instanceof WeakSet ? i.add(e) : i.set(e, t);
|
|
21
|
-
}, u = (e, i, t,
|
|
22
|
-
import { A as w } from "../Damped-
|
|
23
|
-
import { D as I } from "../Damped-
|
|
21
|
+
}, u = (e, i, t, s) => (o(e, i, "write to private field"), s ? s.call(e, t) : i.set(e, t), t);
|
|
22
|
+
import { A as w } from "../Damped-B91XlC1a.js";
|
|
23
|
+
import { D as I } from "../Damped-B91XlC1a.js";
|
|
24
24
|
import { l as C } from "../easings-BKi40vHz.js";
|
|
25
25
|
import { c as M } from "../math-BOBiC4TN.js";
|
|
26
26
|
import { p as A } from "../number-Bo5RdrA1.js";
|
|
@@ -28,42 +28,43 @@ import { n as F } from "../polyfills-DJUYczFm.js";
|
|
|
28
28
|
import "../path-data-polyfill-DgeDWYeI.js";
|
|
29
29
|
var l, n, h, a, c;
|
|
30
30
|
class E extends w {
|
|
31
|
-
constructor(t,
|
|
32
|
-
super(t || 0
|
|
31
|
+
constructor(t, s) {
|
|
32
|
+
super(t || 0);
|
|
33
33
|
m(this, l, C);
|
|
34
34
|
m(this, n, 1e3);
|
|
35
35
|
m(this, h, 0);
|
|
36
36
|
m(this, a, 0);
|
|
37
37
|
m(this, c, 0);
|
|
38
|
+
this.updateOptions(s);
|
|
38
39
|
}
|
|
39
40
|
get direction() {
|
|
40
|
-
return
|
|
41
|
+
return r(this, c);
|
|
41
42
|
}
|
|
42
43
|
get length() {
|
|
43
|
-
return
|
|
44
|
+
return r(this, a) - r(this, h);
|
|
44
45
|
}
|
|
45
46
|
get progress() {
|
|
46
|
-
return this.length ? A((this.current -
|
|
47
|
+
return this.length ? A((this.current - r(this, h)) / this.length, 6) : 0;
|
|
47
48
|
}
|
|
48
49
|
get entry() {
|
|
49
|
-
return p(
|
|
50
|
+
return f(p({}, super.entry), {
|
|
50
51
|
length: this.length,
|
|
51
52
|
direction: this.direction,
|
|
52
53
|
progress: this.progress
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
set(t,
|
|
56
|
-
|
|
56
|
+
set(t, s) {
|
|
57
|
+
s != null && s.restart && (this.current = this.initial), u(this, h, this.current), u(this, a, t), u(this, c, Math.sign(this.length)), this.updateOptions(s), r(this, n) ? (this.unlistenAnimationFrame(), this.listenAnimationFrame()) : (this.current = r(this, a), this.unlistenAnimationFrame());
|
|
57
58
|
}
|
|
58
|
-
shift(t,
|
|
59
|
-
this.set(this.current + t,
|
|
59
|
+
shift(t, s) {
|
|
60
|
+
this.set(this.current + t, s);
|
|
60
61
|
}
|
|
61
62
|
updateOptions(t) {
|
|
62
|
-
super.updateOptions(t), u(this, l, F(t == null ? void 0 : t.easing,
|
|
63
|
+
super.updateOptions(t), u(this, l, F(t == null ? void 0 : t.easing, r(this, l))), u(this, n, F(t == null ? void 0 : t.duration, r(this, n)));
|
|
63
64
|
}
|
|
64
65
|
handleAnimationFrame(t) {
|
|
65
|
-
const
|
|
66
|
-
this.current = A(
|
|
66
|
+
const s = (t.timestamp - t.startTimestamp) / 1e3 / (r(this, n) / 1e3), O = r(this, l).call(this, M(s, 0, 1));
|
|
67
|
+
this.current = A(r(this, h) + (r(this, a) - r(this, h)) * O, 6), s > 1 && this.unlistenAnimationFrame();
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
l = new WeakMap(), n = new WeakMap(), h = new WeakMap(), a = new WeakMap(), c = new WeakMap();
|
package/lib/morph/Link.d.ts
CHANGED
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -22,6 +22,6 @@ export declare class Morph {
|
|
|
22
22
|
constructor(parameters?: MorphParameters);
|
|
23
23
|
beforeNavigationEvent(callback: MorphNavigationCallback): () => void;
|
|
24
24
|
afterNavigationEvent(callback: MorphNavigationCallback): () => void;
|
|
25
|
-
prefetch(
|
|
26
|
-
navigate(
|
|
25
|
+
prefetch(path: string): Promise<Document>;
|
|
26
|
+
navigate(path: string, historyAction?: MorphHistoryAction): Promise<void>;
|
|
27
27
|
}
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var st=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n);var _=(n,t,e)=>{if(!t.has(n))throw TypeError("Cannot "+e)};var s=(n,t,e)=>(_(n,t,"read from private field"),e?e.call(n):t.get(n)),r=(n,t,e)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,e)},c=(n,t,e,o)=>(_(n,t,"write to private field"),o?o.call(n,e):t.set(n,e),e);var d=(n,t,e)=>(_(n,t,"access private method"),e);var T=(n,t,e)=>new Promise((o,i)=>{var a=l=>{try{f(e.next(l))}catch(m){i(m)}},w=l=>{try{f(e.throw(l))}catch(m){i(m)}},f=l=>l.done?o(l.value):Promise.resolve(l.value).then(a,w);f((e=e.apply(n,t)).next())});var it=(n,t,e)=>(t=n[st("asyncIterator")])?t.call(n):(n=n[st("iterator")](),t={},e=(o,i)=>(i=n[o])&&(t[o]=a=>new Promise((w,f,l)=>(a=i.call(n,a),l=a.done,Promise.resolve(a.value).then(m=>w({value:m,done:l}),f)))),e("next"),e("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const nt=require("../notifier/index.cjs"),ut=require("../browser-CpzFX2xg.cjs");require("../path-data-polyfill-CXsOR7Oc.cjs");var y,u,L,H,P,S;class dt{constructor(t,e,o){r(this,y,void 0);r(this,u,void 0);r(this,L,void 0);r(this,H,void 0);r(this,P,t=>{t.preventDefault(),s(this,y).navigate(s(this,L),s(this,H))});r(this,S,()=>{s(this,y).prefetch(s(this,L))});c(this,y,e),c(this,u,t),c(this,L,s(this,u).getAttribute("href")||"/"),c(this,H,s(this,u).getAttribute("data-history-action")||"push"),s(this,u).addEventListener("click",s(this,P)),s(this,L)===location.pathname.replace(o.slice(0,-1),"")&&s(this,u).classList.add("current"),s(this,u).hasAttribute("data-prefetch")&&s(this,u).addEventListener("pointerenter",s(this,S))}destroy(){s(this,u).removeEventListener("click",s(this,P)),s(this,u).removeEventListener("pointerenter",s(this,S)),s(this,u).classList.remove("current")}}y=new WeakMap,u=new WeakMap,L=new WeakMap,H=new WeakMap,P=new WeakMap,S=new WeakMap;var g,N,A,C,k,j,b,v,M,x,W,q,z,D,G,R,J,F,Q,B,rt,I,U,K;class ft{constructor(t){r(this,q);r(this,D);r(this,R);r(this,F);r(this,B);r(this,I);r(this,g,null);r(this,N,null);r(this,A,null);r(this,C,null);r(this,k,[]);r(this,j,new DOMParser);r(this,b,new Map);r(this,v,void 0);r(this,M,null);r(this,x,new nt.Notifier);r(this,W,new nt.Notifier);r(this,K,t=>{t.state&&this.navigate(t.state,"none")});ut.isBrowser&&(c(this,g,(t==null?void 0:t.base)||"/"),t!=null&&t.base?(c(this,g,t.base),t.base.endsWith("/")||c(this,g,s(this,g)+"/")):c(this,g,"/"),c(this,N,(t==null?void 0:t.waitForHeadToLoad)!==!1),c(this,A,(t==null?void 0:t.cachePages)!==!1),c(this,C,d(this,F,Q).call(this,document)),c(this,M,location.pathname),d(this,R,J).call(this),addEventListener("popstate",s(this,K)))}beforeNavigationEvent(t){return s(this,x).subscribe(t)}afterNavigationEvent(t){return s(this,W).subscribe(t)}prefetch(t){return T(this,null,function*(){const e=d(this,D,G).call(this,t);return d(this,q,z).call(this,e.pathname)})}navigate(t,e="push"){return T(this,null,function*(){var l;const o=d(this,D,G).call(this,t);let{pathname:i,hash:a,parameters:w}=o;if(s(this,v)===i||s(this,M)===i)return;c(this,v,i);const f=s(this,b).has(i);try{let m=!0;if(s(this,x).notify({pathname:i,isCached:f}),this.preprocessor)try{yield new Promise((h,p)=>{var E;(E=this.preprocessor)==null||E.call(this,{pathname:i,resolve:h,reject:p,isCached:f})})}catch(h){h?console.error(h):console.log("Route change canceled"),m=!1}if(!m||s(this,v)!==i)return;const V=s(this,b).get(i)||(yield d(this,q,z).call(this,i));if(s(this,v)!==i)return;const X=Array.from(document.head.children),Z=Array.from(V.head.cloneNode(!0).children),tt=d(this,B,rt).call(this,X,Z),ot=d(this,I,U).call(this,X,tt),O=d(this,I,U).call(this,Z,tt);ot.forEach(h=>{h.remove()}),O.forEach((h,p)=>{if(h.tagName==="SCRIPT"&&h.getAttribute("src")){const E=document.createElement("script");E.type="module",E.src=h.getAttribute("src"),O[p]=E}}),O.forEach((h,p)=>{document.head.appendChild(h)});const Y=O.filter(h=>h.tagName==="STYLE"||h.tagName==="SCRIPT"||h.tagName==="LINK");s(this,N)&&Y.length&&(yield new Promise(h=>T(this,null,function*(){let p=0;try{for(var E=it(Y),pt,Et,vt;pt=!(Et=yield E.next()).done;pt=!1){const lt=Et.value;lt.onload=()=>{p++,p===Y.length&&h()}}}catch(Et){vt=[Et]}finally{try{pt&&(Et=E.return)&&(yield Et.call(E))}finally{if(vt)throw vt[0]}}}))),c(this,M,i);const $=w||location.search,ht=a?a.startsWith("#")?a:"#"+a:"",ct=$?$.startsWith("?")?$:"?"+$:"",et=`${i}${ht}${ct}`;e==="push"?history.pushState(i,"",et):e==="replace"&&history.replaceState(i,"",et);const at=d(this,F,Q).call(this,V);s(this,C).forEach((h,p)=>{const E=at[p];h.innerHTML=E.innerHTML}),d(this,R,J).call(this),(l=this.postprocessor)==null||l.call(this,{pathname:i,isCached:f}),s(this,W).notify({pathname:i,isCached:f})}catch(m){console.error(m)}c(this,v,void 0)})}}g=new WeakMap,N=new WeakMap,A=new WeakMap,C=new WeakMap,k=new WeakMap,j=new WeakMap,b=new WeakMap,v=new WeakMap,M=new WeakMap,x=new WeakMap,W=new WeakMap,q=new WeakSet,z=function(t){return T(this,null,function*(){const e=s(this,b).get(t);if(e)return e;const i=yield(yield fetch(t)).text(),a=s(this,j).parseFromString(i,"text/html");return s(this,A)&&s(this,b).set(t,a),a})},D=new WeakSet,G=function(t){t=t.replace(s(this,g),""),t.startsWith("/")&&(t=t.slice(1));const e=t.split("#"),o=e[0].split("?"),i=s(this,g)+o[0],a=o==null?void 0:o[1],w=e==null?void 0:e[1];return{pathname:i,parameters:a,hash:w}},R=new WeakSet,J=function(){const t=[...document.documentElement.querySelectorAll("a")].filter(e=>{var o;return(o=e.getAttribute("href"))==null?void 0:o.startsWith("/")});s(this,k).forEach(e=>e.destroy()),c(this,k,t.map(e=>new dt(e,this,s(this,g))))},F=new WeakSet,Q=function(t){const e=t.querySelectorAll("[data-morph]");return e.length?[...e]:[t.body]},B=new WeakSet,rt=function(t,e){return t.filter(o=>e.find(i=>i.outerHTML===o.outerHTML))},I=new WeakSet,U=function(t,e){return t.filter(o=>!e.find(i=>i.outerHTML===o.outerHTML))},K=new WeakMap;exports.Morph=ft;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,191 +1,213 @@
|
|
|
1
|
-
var
|
|
2
|
-
var z = (
|
|
3
|
-
if (!t.has(
|
|
1
|
+
var st = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n);
|
|
2
|
+
var z = (n, t, e) => {
|
|
3
|
+
if (!t.has(n))
|
|
4
4
|
throw TypeError("Cannot " + e);
|
|
5
5
|
};
|
|
6
|
-
var
|
|
7
|
-
if (t.has(
|
|
6
|
+
var s = (n, t, e) => (z(n, t, "read from private field"), e ? e.call(n) : t.get(n)), o = (n, t, e) => {
|
|
7
|
+
if (t.has(n))
|
|
8
8
|
throw TypeError("Cannot add the same private member more than once");
|
|
9
|
-
t instanceof WeakSet ? t.add(
|
|
10
|
-
},
|
|
11
|
-
var
|
|
12
|
-
var T = (
|
|
13
|
-
var
|
|
9
|
+
t instanceof WeakSet ? t.add(n) : t.set(n, e);
|
|
10
|
+
}, c = (n, t, e, r) => (z(n, t, "write to private field"), r ? r.call(n, e) : t.set(n, e), e);
|
|
11
|
+
var f = (n, t, e) => (z(n, t, "access private method"), e);
|
|
12
|
+
var T = (n, t, e) => new Promise((r, i) => {
|
|
13
|
+
var a = (l) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
|
|
15
|
+
d(e.next(l));
|
|
16
|
+
} catch (m) {
|
|
17
|
+
i(m);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
19
|
+
}, v = (l) => {
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
} catch (
|
|
23
|
-
|
|
21
|
+
d(e.throw(l));
|
|
22
|
+
} catch (m) {
|
|
23
|
+
i(m);
|
|
24
24
|
}
|
|
25
|
-
},
|
|
26
|
-
|
|
25
|
+
}, d = (l) => l.done ? r(l.value) : Promise.resolve(l.value).then(a, v);
|
|
26
|
+
d((e = e.apply(n, t)).next());
|
|
27
27
|
});
|
|
28
|
-
var
|
|
29
|
-
import { Notifier as
|
|
30
|
-
import { i as
|
|
28
|
+
var it = (n, t, e) => (t = n[st("asyncIterator")]) ? t.call(n) : (n = n[st("iterator")](), t = {}, e = (r, i) => (i = n[r]) && (t[r] = (a) => new Promise((v, d, l) => (a = i.call(n, a), l = a.done, Promise.resolve(a.value).then((m) => v({ value: m, done: l }), d)))), e("next"), e("return"), t);
|
|
29
|
+
import { Notifier as nt } from "../notifier/index.js";
|
|
30
|
+
import { i as ut } from "../browser-0zX67oeU.js";
|
|
31
31
|
import "../path-data-polyfill-DgeDWYeI.js";
|
|
32
|
-
var
|
|
33
|
-
class
|
|
34
|
-
constructor(t, e) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
t.preventDefault(),
|
|
32
|
+
var b, u, w, M, P, N;
|
|
33
|
+
class ft {
|
|
34
|
+
constructor(t, e, r) {
|
|
35
|
+
o(this, b, void 0);
|
|
36
|
+
o(this, u, void 0);
|
|
37
|
+
o(this, w, void 0);
|
|
38
|
+
o(this, M, void 0);
|
|
39
|
+
o(this, P, (t) => {
|
|
40
|
+
t.preventDefault(), s(this, b).navigate(s(this, w), s(this, M));
|
|
41
41
|
});
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
o(this, N, () => {
|
|
43
|
+
s(this, b).prefetch(s(this, w));
|
|
44
44
|
});
|
|
45
|
-
|
|
45
|
+
c(this, b, e), c(this, u, t), c(this, w, s(this, u).getAttribute("href") || "/"), c(this, M, s(this, u).getAttribute(
|
|
46
46
|
"data-history-action"
|
|
47
|
-
) || "push"),
|
|
47
|
+
) || "push"), s(this, u).addEventListener("click", s(this, P)), s(this, w) === location.pathname.replace(r.slice(0, -1), "") && s(this, u).classList.add("current"), s(this, u).hasAttribute("data-prefetch") && s(this, u).addEventListener("pointerenter", s(this, N));
|
|
48
48
|
}
|
|
49
49
|
destroy() {
|
|
50
|
-
|
|
50
|
+
s(this, u).removeEventListener("click", s(this, P)), s(this, u).removeEventListener("pointerenter", s(this, N)), s(this, u).classList.remove("current");
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
class
|
|
53
|
+
b = new WeakMap(), u = new WeakMap(), w = new WeakMap(), M = new WeakMap(), P = new WeakMap(), N = new WeakMap();
|
|
54
|
+
var p, S, A, C, k, B, y, L, H, x, W, D, G, R, J, F, Q, I, U, K, ot, $, V, Y;
|
|
55
|
+
class Et {
|
|
56
56
|
constructor(t) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
o(this, D);
|
|
58
|
+
o(this, R);
|
|
59
|
+
o(this, F);
|
|
60
|
+
o(this, I);
|
|
61
|
+
o(this, K);
|
|
62
|
+
o(this, $);
|
|
63
|
+
o(this, p, null);
|
|
64
|
+
o(this, S, null);
|
|
65
|
+
o(this, A, null);
|
|
66
|
+
o(this, C, null);
|
|
67
|
+
o(this, k, []);
|
|
68
|
+
o(this, B, new DOMParser());
|
|
69
|
+
o(this, y, /* @__PURE__ */ new Map());
|
|
70
|
+
o(this, L, void 0);
|
|
71
|
+
o(this, H, null);
|
|
72
|
+
o(this, x, new nt());
|
|
73
|
+
o(this, W, new nt());
|
|
74
|
+
o(this, Y, (t) => {
|
|
75
75
|
t.state && this.navigate(t.state, "none");
|
|
76
76
|
});
|
|
77
|
-
|
|
77
|
+
ut && (c(this, p, (t == null ? void 0 : t.base) || "/"), t != null && t.base ? (c(this, p, t.base), t.base.endsWith("/") || c(this, p, s(this, p) + "/")) : c(this, p, "/"), c(this, S, (t == null ? void 0 : t.waitForHeadToLoad) !== !1), c(this, A, (t == null ? void 0 : t.cachePages) !== !1), c(this, C, f(this, I, U).call(this, document)), c(this, H, location.pathname), f(this, F, Q).call(this), addEventListener("popstate", s(this, Y)));
|
|
78
78
|
}
|
|
79
79
|
beforeNavigationEvent(t) {
|
|
80
|
-
return
|
|
80
|
+
return s(this, x).subscribe(t);
|
|
81
81
|
}
|
|
82
82
|
afterNavigationEvent(t) {
|
|
83
|
-
return
|
|
83
|
+
return s(this, W).subscribe(t);
|
|
84
84
|
}
|
|
85
85
|
prefetch(t) {
|
|
86
86
|
return T(this, null, function* () {
|
|
87
|
-
|
|
87
|
+
const e = f(this, R, J).call(this, t);
|
|
88
|
+
return f(this, D, G).call(this, e.pathname);
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
91
|
navigate(t, e = "push") {
|
|
91
92
|
return T(this, null, function* () {
|
|
92
|
-
var
|
|
93
|
-
|
|
93
|
+
var l;
|
|
94
|
+
const r = f(this, R, J).call(this, t);
|
|
95
|
+
let { pathname: i, hash: a, parameters: v } = r;
|
|
96
|
+
if (s(this, L) === i || s(this, H) === i)
|
|
94
97
|
return;
|
|
95
|
-
|
|
96
|
-
const
|
|
98
|
+
c(this, L, i);
|
|
99
|
+
const d = s(this, y).has(i);
|
|
97
100
|
try {
|
|
98
|
-
let
|
|
99
|
-
if (this.
|
|
101
|
+
let m = !0;
|
|
102
|
+
if (s(this, x).notify({
|
|
103
|
+
pathname: i,
|
|
104
|
+
isCached: d
|
|
105
|
+
}), this.preprocessor)
|
|
100
106
|
try {
|
|
101
|
-
yield new Promise((h,
|
|
102
|
-
var
|
|
103
|
-
(
|
|
107
|
+
yield new Promise((h, g) => {
|
|
108
|
+
var E;
|
|
109
|
+
(E = this.preprocessor) == null || E.call(this, { pathname: i, resolve: h, reject: g, isCached: d });
|
|
104
110
|
});
|
|
105
111
|
} catch (h) {
|
|
106
|
-
h ? console.error(h) : console.log("Route change canceled"),
|
|
112
|
+
h ? console.error(h) : console.log("Route change canceled"), m = !1;
|
|
107
113
|
}
|
|
108
|
-
if (
|
|
109
|
-
pathname: t,
|
|
110
|
-
isCached: o
|
|
111
|
-
}), !l || i(this, v) !== t)
|
|
114
|
+
if (!m || s(this, L) !== i)
|
|
112
115
|
return;
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
116
|
+
const X = s(this, y).get(i) || (yield f(this, D, G).call(this, i));
|
|
117
|
+
if (s(this, L) !== i)
|
|
115
118
|
return;
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
),
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
const Z = Array.from(document.head.children), _ = Array.from(
|
|
120
|
+
X.head.cloneNode(!0).children
|
|
121
|
+
), tt = f(this, K, ot).call(this, Z, _), rt = f(this, $, V).call(this, Z, tt), q = f(this, $, V).call(this, _, tt);
|
|
122
|
+
rt.forEach((h) => {
|
|
123
|
+
h.remove();
|
|
124
|
+
}), q.forEach((h, g) => {
|
|
125
|
+
if (h.tagName === "SCRIPT" && h.getAttribute("src")) {
|
|
126
|
+
const E = document.createElement("script");
|
|
127
|
+
E.type = "module", E.src = h.getAttribute("src"), q[g] = E;
|
|
128
|
+
}
|
|
129
|
+
}), q.forEach((h, g) => {
|
|
130
|
+
document.head.appendChild(h);
|
|
131
|
+
});
|
|
132
|
+
const j = q.filter(
|
|
121
133
|
(h) => h.tagName === "STYLE" || h.tagName === "SCRIPT" || h.tagName === "LINK"
|
|
122
134
|
);
|
|
123
|
-
|
|
124
|
-
let
|
|
135
|
+
s(this, S) && j.length && (yield new Promise((h) => T(this, null, function* () {
|
|
136
|
+
let g = 0;
|
|
125
137
|
try {
|
|
126
|
-
for (var
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
138
|
+
for (var E = it(j), wt, yt, bt; wt = !(yt = yield E.next()).done; wt = !1) {
|
|
139
|
+
const lt = yt.value;
|
|
140
|
+
lt.onload = () => {
|
|
141
|
+
g++, g === j.length && h();
|
|
130
142
|
};
|
|
131
143
|
}
|
|
132
|
-
} catch (
|
|
133
|
-
|
|
144
|
+
} catch (yt) {
|
|
145
|
+
bt = [yt];
|
|
134
146
|
} finally {
|
|
135
147
|
try {
|
|
136
|
-
|
|
148
|
+
wt && (yt = E.return) && (yield yt.call(E));
|
|
137
149
|
} finally {
|
|
138
|
-
if (
|
|
139
|
-
throw
|
|
150
|
+
if (bt)
|
|
151
|
+
throw bt[0];
|
|
140
152
|
}
|
|
141
153
|
}
|
|
142
|
-
})));
|
|
143
|
-
const
|
|
144
|
-
i
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
154
|
+
}))), c(this, H, i);
|
|
155
|
+
const O = v || location.search, ht = a ? a.startsWith("#") ? a : "#" + a : "", ct = O ? O.startsWith("?") ? O : "?" + O : "", et = `${i}${ht}${ct}`;
|
|
156
|
+
e === "push" ? history.pushState(i, "", et) : e === "replace" && history.replaceState(i, "", et);
|
|
157
|
+
const at = f(this, I, U).call(this, X);
|
|
158
|
+
s(this, C).forEach((h, g) => {
|
|
159
|
+
const E = at[g];
|
|
160
|
+
h.innerHTML = E.innerHTML;
|
|
161
|
+
}), f(this, F, Q).call(this), (l = this.postprocessor) == null || l.call(this, { pathname: i, isCached: d }), s(this, W).notify({ pathname: i, isCached: d });
|
|
162
|
+
} catch (m) {
|
|
163
|
+
console.error(m);
|
|
150
164
|
}
|
|
151
|
-
|
|
165
|
+
c(this, L, void 0);
|
|
152
166
|
});
|
|
153
167
|
}
|
|
154
168
|
}
|
|
155
|
-
|
|
169
|
+
p = new WeakMap(), S = new WeakMap(), A = new WeakMap(), C = new WeakMap(), k = new WeakMap(), B = new WeakMap(), y = new WeakMap(), L = new WeakMap(), H = new WeakMap(), x = new WeakMap(), W = new WeakMap(), D = new WeakSet(), G = function(t) {
|
|
156
170
|
return T(this, null, function* () {
|
|
157
|
-
const e =
|
|
171
|
+
const e = s(this, y).get(t);
|
|
158
172
|
if (e)
|
|
159
173
|
return e;
|
|
160
|
-
const
|
|
161
|
-
return
|
|
174
|
+
const i = yield (yield fetch(t)).text(), a = s(this, B).parseFromString(i, "text/html");
|
|
175
|
+
return s(this, A) && s(this, y).set(t, a), a;
|
|
162
176
|
});
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
|
|
177
|
+
}, R = new WeakSet(), J = function(t) {
|
|
178
|
+
t = t.replace(s(this, p), ""), t.startsWith("/") && (t = t.slice(1));
|
|
179
|
+
const e = t.split("#"), r = e[0].split("?"), i = s(this, p) + r[0], a = r == null ? void 0 : r[1], v = e == null ? void 0 : e[1];
|
|
180
|
+
return {
|
|
181
|
+
pathname: i,
|
|
182
|
+
parameters: a,
|
|
183
|
+
hash: v
|
|
184
|
+
};
|
|
185
|
+
}, F = new WeakSet(), Q = function() {
|
|
166
186
|
const t = [
|
|
167
187
|
...document.documentElement.querySelectorAll("a")
|
|
168
188
|
].filter((e) => {
|
|
169
|
-
var
|
|
170
|
-
return (
|
|
189
|
+
var r;
|
|
190
|
+
return (r = e.getAttribute("href")) == null ? void 0 : r.startsWith("/");
|
|
171
191
|
});
|
|
172
|
-
|
|
173
|
-
|
|
192
|
+
s(this, k).forEach((e) => e.destroy()), c(this, k, t.map(
|
|
193
|
+
(e) => new ft(e, this, s(this, p))
|
|
194
|
+
));
|
|
195
|
+
}, I = new WeakSet(), U = function(t) {
|
|
174
196
|
const e = t.querySelectorAll("[data-morph]");
|
|
175
197
|
return e.length ? [...e] : [t.body];
|
|
176
|
-
}, K = new WeakSet(),
|
|
198
|
+
}, K = new WeakSet(), ot = function(t, e) {
|
|
177
199
|
return t.filter(
|
|
178
|
-
(
|
|
179
|
-
(
|
|
200
|
+
(r) => e.find(
|
|
201
|
+
(i) => i.outerHTML === r.outerHTML
|
|
180
202
|
)
|
|
181
203
|
);
|
|
182
|
-
},
|
|
204
|
+
}, $ = new WeakSet(), V = function(t, e) {
|
|
183
205
|
return t.filter(
|
|
184
|
-
(
|
|
185
|
-
(
|
|
206
|
+
(r) => !e.find(
|
|
207
|
+
(i) => i.outerHTML === r.outerHTML
|
|
186
208
|
)
|
|
187
209
|
);
|
|
188
210
|
}, Y = new WeakMap();
|
|
189
211
|
export {
|
|
190
|
-
|
|
212
|
+
Et as Morph
|
|
191
213
|
};
|