aptechka 0.4.13 → 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/custom-element/index.cjs +1 -1
- package/lib/custom-element/index.d.ts +1 -0
- package/lib/custom-element/index.js +16 -12
- 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/array.d.ts +1 -0
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +152 -138
- package/lib/utils/svg.d.ts +1 -1
- 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();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../browser-CpzFX2xg.cjs");require("../path-data-polyfill-CXsOR7Oc.cjs");function n(t,e){return function(s){o.isBrowser&&!customElements.get(t)&&customElements.define(t,s,{extends:e})}}function i(t,e,s){o.isBrowser&&!customElements.get(t)&&customElements.define(t,e,{extends:s})}const d=o.isBrowser?window.HTMLElement:class{attachShadow(){}};class r extends d{openShadow(...e){if(!this.shadowRoot&&o.isBrowser){const s=this.attachShadow({mode:"open"});return this.addStylesheet(...e),s}return this.shadowRoot}addStylesheet(...e){this.shadowRoot&&o.isBrowser&&this.shadowRoot.adoptedStyleSheets.push(...e)}}exports.CustomElement=r;exports.define=n;exports.defineElement=i;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function define(name: string, extend?: keyof HTMLElementTagNameMap): (Constructor: CustomElementConstructor) => void;
|
|
2
|
+
export declare function defineElement(name: string, Constructor: CustomElementConstructor, extend?: keyof HTMLElementTagNameMap): void;
|
|
2
3
|
declare const HTMLElement: {
|
|
3
4
|
new (): HTMLElement;
|
|
4
5
|
prototype: HTMLElement;
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import { i as
|
|
1
|
+
import { i as s } from "../browser-0zX67oeU.js";
|
|
2
2
|
import "../path-data-polyfill-DgeDWYeI.js";
|
|
3
|
-
function
|
|
4
|
-
return function(
|
|
5
|
-
|
|
3
|
+
function h(e, t) {
|
|
4
|
+
return function(o) {
|
|
5
|
+
s && !customElements.get(e) && customElements.define(e, o, { extends: t });
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
function a(e, t, o) {
|
|
9
|
+
s && !customElements.get(e) && customElements.define(e, t, { extends: o });
|
|
10
|
+
}
|
|
11
|
+
const n = s ? window.HTMLElement : class {
|
|
9
12
|
attachShadow() {
|
|
10
13
|
}
|
|
11
14
|
};
|
|
12
|
-
class
|
|
15
|
+
class m extends n {
|
|
13
16
|
openShadow(...t) {
|
|
14
|
-
if (!this.shadowRoot &&
|
|
15
|
-
const
|
|
16
|
-
return this.addStylesheet(...t),
|
|
17
|
+
if (!this.shadowRoot && s) {
|
|
18
|
+
const o = this.attachShadow({ mode: "open" });
|
|
19
|
+
return this.addStylesheet(...t), o;
|
|
17
20
|
}
|
|
18
21
|
return this.shadowRoot;
|
|
19
22
|
}
|
|
20
23
|
addStylesheet(...t) {
|
|
21
|
-
this.shadowRoot &&
|
|
24
|
+
this.shadowRoot && s && this.shadowRoot.adoptedStyleSheets.push(...t);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
m as CustomElement,
|
|
29
|
+
h as define,
|
|
30
|
+
a as defineElement
|
|
27
31
|
};
|
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;
|