aptechka 0.4.14 → 0.4.15
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/Morph.d.ts +1 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +140 -121
- 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/Morph.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ export declare class Morph {
|
|
|
23
23
|
beforeNavigationEvent(callback: MorphNavigationCallback): () => void;
|
|
24
24
|
afterNavigationEvent(callback: MorphNavigationCallback): () => void;
|
|
25
25
|
prefetch(pathname: string): Promise<Document>;
|
|
26
|
-
navigate(
|
|
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 et=(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 P=(n,t,e)=>new Promise((o,i)=>{var a=l=>{try{f(e.next(l))}catch(g){i(g)}},w=l=>{try{f(e.throw(l))}catch(g){i(g)}},f=l=>l.done?o(l.value):Promise.resolve(l.value).then(a,w);f((e=e.apply(n,t)).next())});var st=(n,t,e)=>(t=n[et("asyncIterator")])?t.call(n):(n=n[et("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(g=>w({value:g,done:l}),f)))),e("next"),e("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const it=require("../notifier/index.cjs"),ut=require("../browser-CpzFX2xg.cjs");require("../path-data-polyfill-CXsOR7Oc.cjs");var y,u,L,T,H,S;class dt{constructor(t,e){r(this,y,void 0);r(this,u,void 0);r(this,L,void 0);r(this,T,void 0);r(this,H,t=>{t.preventDefault(),s(this,y).navigate(s(this,L),s(this,T))});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,T,s(this,u).getAttribute("data-history-action")||"push"),s(this,u).addEventListener("click",s(this,H)),s(this,L)===location.pathname&&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,H)),s(this,u).removeEventListener("pointerenter",s(this,S)),s(this,u).classList.remove("current")}}y=new WeakMap,u=new WeakMap,L=new WeakMap,T=new WeakMap,H=new WeakMap,S=new WeakMap;var p,N,A,C,k,$,b,v,M,x,W,q,z,j,nt,D,G,R,J,B,rt,F,Q,K;class ft{constructor(t){r(this,q);r(this,j);r(this,D);r(this,R);r(this,B);r(this,F);r(this,p,null);r(this,N,null);r(this,A,null);r(this,C,null);r(this,k,[]);r(this,$,new DOMParser);r(this,b,new Map);r(this,v,void 0);r(this,M,null);r(this,x,new it.Notifier);r(this,W,new it.Notifier);r(this,K,t=>{t.state&&this.navigate(t.state,"none")});ut.isBrowser&&(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,N,(t==null?void 0:t.waitForHeadToLoad)!==!1),c(this,A,(t==null?void 0:t.cachePages)!==!1),c(this,C,d(this,R,J).call(this,document)),c(this,M,location.pathname),d(this,D,G).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 P(this,null,function*(){return d(this,q,z).call(this,t)})}navigate(t,e="push"){return P(this,null,function*(){var l;const o=d(this,j,nt).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 g=!0;if(s(this,x).notify({pathname:i,isCached:f}),this.preprocessor)try{yield new Promise((h,m)=>{var E;(E=this.preprocessor)==null||E.call(this,{pathname:i,resolve:h,reject:m,isCached:f})})}catch(h){h?console.error(h):console.log("Route change canceled"),g=!1}if(!g||s(this,v)!==i)return;const U=s(this,b).get(i)||(yield d(this,q,z).call(this,i));if(s(this,v)!==i)return;const V=Array.from(document.head.children),X=Array.from(U.head.cloneNode(!0).children),Z=d(this,B,rt).call(this,V,X),ot=d(this,F,Q).call(this,V,Z),I=d(this,F,Q).call(this,X,Z);ot.forEach(h=>{h.remove()}),I.forEach((h,m)=>{if(h.tagName==="SCRIPT"&&h.getAttribute("src")){const E=document.createElement("script");E.type="module",E.src=h.getAttribute("src"),I[m]=E}}),I.forEach((h,m)=>{document.head.appendChild(h)});const Y=I.filter(h=>h.tagName==="STYLE"||h.tagName==="SCRIPT"||h.tagName==="LINK");s(this,N)&&Y.length&&(yield new Promise(h=>P(this,null,function*(){let m=0;try{for(var E=st(Y),pt,Et,vt;pt=!(Et=yield E.next()).done;pt=!1){const lt=Et.value;lt.onload=()=>{m++,m===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 O=w||location.search,ht=a?a.startsWith("#")?a:"#"+a:"",ct=O?O.startsWith("?")?O:"?"+O:"",tt=`${i}${ht}${ct}`;e==="push"?history.pushState(i,"",tt):e==="replace"&&history.replaceState(i,"",tt);const at=d(this,R,J).call(this,U);s(this,C).forEach((h,m)=>{const E=at[m];h.innerHTML=E.innerHTML}),d(this,D,G).call(this),(l=this.postprocessor)==null||l.call(this,{pathname:i,isCached:f}),s(this,W).notify({pathname:i,isCached:f})}catch(g){console.error(g)}c(this,v,void 0)})}}p=new WeakMap,N=new WeakMap,A=new WeakMap,C=new WeakMap,k=new WeakMap,$=new WeakMap,b=new WeakMap,v=new WeakMap,M=new WeakMap,x=new WeakMap,W=new WeakMap,q=new WeakSet,z=function(t){return P(this,null,function*(){const e=s(this,b).get(t);if(e)return e;const i=yield(yield fetch(t)).text(),a=s(this,$).parseFromString(i,"text/html");return s(this,A)&&s(this,b).set(t,a),a})},j=new WeakSet,nt=function(t){t=t.replace(s(this,p),""),t.startsWith("/")&&(t=t.slice(1));const e=t.split("#"),o=e[0].split("?"),i=s(this,p)+o[0],a=o==null?void 0:o[1],w=e==null?void 0:e[1];return{pathname:i,parameters:a,hash:w}},D=new WeakSet,G=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)))},R=new WeakSet,J=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))},F=new WeakSet,Q=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,210 @@
|
|
|
1
|
-
var
|
|
2
|
-
var z = (
|
|
3
|
-
if (!t.has(
|
|
1
|
+
var et = (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
|
|
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 P = (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 st = (n, t, e) => (t = n[et("asyncIterator")]) ? t.call(n) : (n = n[et("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 it } 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
|
|
32
|
+
var b, u, w, T, M, N;
|
|
33
|
+
class ft {
|
|
34
34
|
constructor(t, e) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
t.preventDefault(),
|
|
35
|
+
o(this, b, void 0);
|
|
36
|
+
o(this, u, void 0);
|
|
37
|
+
o(this, w, void 0);
|
|
38
|
+
o(this, T, void 0);
|
|
39
|
+
o(this, M, (t) => {
|
|
40
|
+
t.preventDefault(), s(this, b).navigate(s(this, w), s(this, T));
|
|
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, T, s(this, u).getAttribute(
|
|
46
46
|
"data-history-action"
|
|
47
|
-
) || "push"),
|
|
47
|
+
) || "push"), s(this, u).addEventListener("click", s(this, M)), s(this, w) === location.pathname && 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, M)), 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(), T = new WeakMap(), M = new WeakMap(), N = new WeakMap();
|
|
54
|
+
var p, S, A, C, k, O, y, L, H, x, W, D, G, B, nt, R, J, F, Q, K, ot, I, U, 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, B);
|
|
59
|
+
o(this, R);
|
|
60
|
+
o(this, F);
|
|
61
|
+
o(this, K);
|
|
62
|
+
o(this, I);
|
|
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, O, 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 it());
|
|
73
|
+
o(this, W, new it());
|
|
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, F, Q).call(this, document)), c(this, H, location.pathname), f(this, R, J).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
|
-
return
|
|
87
|
-
return
|
|
86
|
+
return P(this, null, function* () {
|
|
87
|
+
return f(this, D, G).call(this, t);
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
navigate(t, e = "push") {
|
|
91
|
-
return
|
|
92
|
-
var
|
|
93
|
-
|
|
91
|
+
return P(this, null, function* () {
|
|
92
|
+
var l;
|
|
93
|
+
const r = f(this, B, nt).call(this, t);
|
|
94
|
+
let { pathname: i, hash: a, parameters: v } = r;
|
|
95
|
+
if (s(this, L) === i || s(this, H) === i)
|
|
94
96
|
return;
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
+
c(this, L, i);
|
|
98
|
+
const d = s(this, y).has(i);
|
|
97
99
|
try {
|
|
98
|
-
let
|
|
99
|
-
if (this.
|
|
100
|
+
let m = !0;
|
|
101
|
+
if (s(this, x).notify({
|
|
102
|
+
pathname: i,
|
|
103
|
+
isCached: d
|
|
104
|
+
}), this.preprocessor)
|
|
100
105
|
try {
|
|
101
|
-
yield new Promise((h,
|
|
102
|
-
var
|
|
103
|
-
(
|
|
106
|
+
yield new Promise((h, g) => {
|
|
107
|
+
var E;
|
|
108
|
+
(E = this.preprocessor) == null || E.call(this, { pathname: i, resolve: h, reject: g, isCached: d });
|
|
104
109
|
});
|
|
105
110
|
} catch (h) {
|
|
106
|
-
h ? console.error(h) : console.log("Route change canceled"),
|
|
111
|
+
h ? console.error(h) : console.log("Route change canceled"), m = !1;
|
|
107
112
|
}
|
|
108
|
-
if (
|
|
109
|
-
pathname: t,
|
|
110
|
-
isCached: o
|
|
111
|
-
}), !l || i(this, v) !== t)
|
|
113
|
+
if (!m || s(this, L) !== i)
|
|
112
114
|
return;
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
+
const V = s(this, y).get(i) || (yield f(this, D, G).call(this, i));
|
|
116
|
+
if (s(this, L) !== i)
|
|
115
117
|
return;
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
),
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
const X = Array.from(document.head.children), Z = Array.from(
|
|
119
|
+
V.head.cloneNode(!0).children
|
|
120
|
+
), _ = f(this, K, ot).call(this, X, Z), rt = f(this, I, U).call(this, X, _), $ = f(this, I, U).call(this, Z, _);
|
|
121
|
+
rt.forEach((h) => {
|
|
122
|
+
h.remove();
|
|
123
|
+
}), $.forEach((h, g) => {
|
|
124
|
+
if (h.tagName === "SCRIPT" && h.getAttribute("src")) {
|
|
125
|
+
const E = document.createElement("script");
|
|
126
|
+
E.type = "module", E.src = h.getAttribute("src"), $[g] = E;
|
|
127
|
+
}
|
|
128
|
+
}), $.forEach((h, g) => {
|
|
129
|
+
document.head.appendChild(h);
|
|
130
|
+
});
|
|
131
|
+
const j = $.filter(
|
|
121
132
|
(h) => h.tagName === "STYLE" || h.tagName === "SCRIPT" || h.tagName === "LINK"
|
|
122
133
|
);
|
|
123
|
-
|
|
124
|
-
let
|
|
134
|
+
s(this, S) && j.length && (yield new Promise((h) => P(this, null, function* () {
|
|
135
|
+
let g = 0;
|
|
125
136
|
try {
|
|
126
|
-
for (var
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
137
|
+
for (var E = st(j), wt, yt, bt; wt = !(yt = yield E.next()).done; wt = !1) {
|
|
138
|
+
const lt = yt.value;
|
|
139
|
+
lt.onload = () => {
|
|
140
|
+
g++, g === j.length && h();
|
|
130
141
|
};
|
|
131
142
|
}
|
|
132
|
-
} catch (
|
|
133
|
-
|
|
143
|
+
} catch (yt) {
|
|
144
|
+
bt = [yt];
|
|
134
145
|
} finally {
|
|
135
146
|
try {
|
|
136
|
-
|
|
147
|
+
wt && (yt = E.return) && (yield yt.call(E));
|
|
137
148
|
} finally {
|
|
138
|
-
if (
|
|
139
|
-
throw
|
|
149
|
+
if (bt)
|
|
150
|
+
throw bt[0];
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
|
-
})));
|
|
143
|
-
const
|
|
144
|
-
i
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
}))), c(this, H, i);
|
|
154
|
+
const q = v || location.search, ht = a ? a.startsWith("#") ? a : "#" + a : "", ct = q ? q.startsWith("?") ? q : "?" + q : "", tt = `${i}${ht}${ct}`;
|
|
155
|
+
e === "push" ? history.pushState(i, "", tt) : e === "replace" && history.replaceState(i, "", tt);
|
|
156
|
+
const at = f(this, F, Q).call(this, V);
|
|
157
|
+
s(this, C).forEach((h, g) => {
|
|
158
|
+
const E = at[g];
|
|
159
|
+
h.innerHTML = E.innerHTML;
|
|
160
|
+
}), f(this, R, J).call(this), (l = this.postprocessor) == null || l.call(this, { pathname: i, isCached: d }), s(this, W).notify({ pathname: i, isCached: d });
|
|
161
|
+
} catch (m) {
|
|
162
|
+
console.error(m);
|
|
150
163
|
}
|
|
151
|
-
|
|
164
|
+
c(this, L, void 0);
|
|
152
165
|
});
|
|
153
166
|
}
|
|
154
167
|
}
|
|
155
|
-
|
|
156
|
-
return
|
|
157
|
-
const e =
|
|
168
|
+
p = new WeakMap(), S = new WeakMap(), A = new WeakMap(), C = new WeakMap(), k = new WeakMap(), O = new WeakMap(), y = new WeakMap(), L = new WeakMap(), H = new WeakMap(), x = new WeakMap(), W = new WeakMap(), D = new WeakSet(), G = function(t) {
|
|
169
|
+
return P(this, null, function* () {
|
|
170
|
+
const e = s(this, y).get(t);
|
|
158
171
|
if (e)
|
|
159
172
|
return e;
|
|
160
|
-
const
|
|
161
|
-
return
|
|
173
|
+
const i = yield (yield fetch(t)).text(), a = s(this, O).parseFromString(i, "text/html");
|
|
174
|
+
return s(this, A) && s(this, y).set(t, a), a;
|
|
162
175
|
});
|
|
163
|
-
}, B = new WeakSet(),
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
}, B = new WeakSet(), nt = function(t) {
|
|
177
|
+
t = t.replace(s(this, p), ""), t.startsWith("/") && (t = t.slice(1));
|
|
178
|
+
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];
|
|
179
|
+
return {
|
|
180
|
+
pathname: i,
|
|
181
|
+
parameters: a,
|
|
182
|
+
hash: v
|
|
183
|
+
};
|
|
184
|
+
}, R = new WeakSet(), J = function() {
|
|
166
185
|
const t = [
|
|
167
186
|
...document.documentElement.querySelectorAll("a")
|
|
168
187
|
].filter((e) => {
|
|
169
|
-
var
|
|
170
|
-
return (
|
|
188
|
+
var r;
|
|
189
|
+
return (r = e.getAttribute("href")) == null ? void 0 : r.startsWith("/");
|
|
171
190
|
});
|
|
172
|
-
|
|
191
|
+
s(this, k).forEach((e) => e.destroy()), c(this, k, t.map((e) => new ft(e, this)));
|
|
173
192
|
}, F = new WeakSet(), Q = function(t) {
|
|
174
193
|
const e = t.querySelectorAll("[data-morph]");
|
|
175
194
|
return e.length ? [...e] : [t.body];
|
|
176
|
-
}, K = new WeakSet(),
|
|
195
|
+
}, K = new WeakSet(), ot = function(t, e) {
|
|
177
196
|
return t.filter(
|
|
178
|
-
(
|
|
179
|
-
(
|
|
197
|
+
(r) => e.find(
|
|
198
|
+
(i) => i.outerHTML === r.outerHTML
|
|
180
199
|
)
|
|
181
200
|
);
|
|
182
|
-
},
|
|
201
|
+
}, I = new WeakSet(), U = function(t, e) {
|
|
183
202
|
return t.filter(
|
|
184
|
-
(
|
|
185
|
-
(
|
|
203
|
+
(r) => !e.find(
|
|
204
|
+
(i) => i.outerHTML === r.outerHTML
|
|
186
205
|
)
|
|
187
206
|
);
|
|
188
207
|
}, Y = new WeakMap();
|
|
189
208
|
export {
|
|
190
|
-
|
|
209
|
+
Et as Morph
|
|
191
210
|
};
|