aptechka 0.25.2 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Animation-B9m8bw96.cjs +1 -0
- package/lib/Animation-DN95L7Xo.js +105 -0
- package/lib/Damped-CTsV8tl_.cjs +1 -0
- package/lib/Damped-Chu29wn-.js +53 -0
- package/lib/Tweened-BUuSLSF7.js +44 -0
- package/lib/Tweened-BttGiyB0.cjs +1 -0
- package/lib/animation/index.cjs +1 -1
- package/lib/animation/index.js +6 -53
- package/lib/canvas-CU5Xjahf.cjs +1 -0
- package/lib/canvas-DeZ0SLUJ.js +34 -0
- package/lib/connector/index.cjs +1 -1
- package/lib/connector/index.js +1 -1
- package/lib/controls/index.cjs +1 -1
- package/lib/controls/index.js +3 -3
- package/lib/coordinates-CgdGoSYs.js +24 -0
- package/lib/coordinates-D8Np3cPD.cjs +1 -0
- package/lib/css-property/index.cjs +1 -1
- package/lib/css-property/index.js +1 -1
- package/lib/dev/index.cjs +1 -1
- package/lib/dev/index.js +1 -1
- package/lib/device/index.cjs +1 -1
- package/lib/device/index.js +1 -1
- package/lib/element-resizer/react/index.cjs +1 -0
- package/lib/element-resizer/react/index.js +8 -0
- package/lib/element-resizer/vanilla/index.cjs +1 -0
- package/lib/element-resizer/{index.js → vanilla/index.js} +2 -2
- package/lib/en3/index.cjs +8 -0
- package/lib/en3/index.js +374 -0
- package/lib/events-CsVF98U6.js +6 -0
- package/lib/events-KVanG9sR.cjs +1 -0
- package/lib/intersector/react/index.cjs +1 -0
- package/lib/intersector/react/index.js +12 -0
- package/lib/intersector/vanilla/index.cjs +1 -0
- package/lib/intersector/{index.js → vanilla/index.js} +2 -2
- package/lib/jss-CjccJC-K.js +21 -0
- package/lib/jss-GJLvaNfT.cjs +1 -0
- package/lib/layout-box/index.cjs +1 -1
- package/lib/layout-box/index.js +3 -3
- package/lib/loading/index.cjs +1 -1
- package/lib/loading/index.js +42 -85
- package/lib/math-BOBiC4TN.js +45 -0
- package/lib/math-GDWEqu7y.cjs +1 -0
- package/lib/media/index.cjs +1 -1
- package/lib/media/index.js +1 -1
- package/lib/media-elements/index.cjs +5 -0
- package/lib/media-elements/index.js +389 -0
- package/lib/morph/index.cjs +1 -0
- package/lib/morph/index.js +227 -0
- package/lib/need_redo_tweaker/index.cjs +4 -4
- package/lib/need_redo_tweaker/index.js +6 -4
- package/lib/object-CCiXnER2.cjs +1 -0
- package/lib/object-D6MVWB4l.js +85 -0
- package/lib/pointer/index.cjs +1 -0
- package/lib/pointer/index.js +151 -0
- package/lib/polyfills-CM4SCDTt.cjs +1 -0
- package/lib/polyfills-X6KXuHg-.js +33 -0
- package/lib/router/index.cjs +1 -0
- package/lib/router/index.js +266 -0
- package/lib/scroll/react/index.cjs +30 -0
- package/lib/scroll/react/index.js +761 -0
- package/lib/scroll/vanilla/index.cjs +1 -0
- package/lib/scroll/vanilla/index.js +1120 -0
- package/lib/slicer/index.cjs +11 -0
- package/lib/slicer/index.js +108 -0
- package/lib/source/index.cjs +1 -1
- package/lib/source/index.js +1 -1
- package/lib/store/react/index.cjs +1 -0
- package/lib/store/react/index.js +14 -0
- package/lib/store/vanilla/index.cjs +1 -0
- package/lib/store/{index.js → vanilla/index.js} +3 -3
- package/lib/style-BqzUd8Fy.cjs +1 -0
- package/lib/style-M-RBTQxT.js +21 -0
- package/lib/ticker/react/index.cjs +1 -0
- package/lib/ticker/react/index.js +19 -0
- package/lib/ticker/vanilla/index.cjs +1 -0
- package/lib/ticker/{index.js → vanilla/index.js} +2 -2
- package/lib/url-BuZrUXAO.js +25 -0
- package/lib/url-qZNgg7IM.cjs +1 -0
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.js +147 -223
- package/lib/window-resizer/react/index.cjs +1 -0
- package/lib/window-resizer/react/index.js +8 -0
- package/lib/window-resizer/vanilla/index.cjs +1 -0
- package/lib/window-resizer/vanilla/index.js +32 -0
- package/package.json +146 -26
- package/lib/Tweened-CDYmG9hk.js +0 -138
- package/lib/Tweened-DlyMbHu_.cjs +0 -1
- package/lib/element-resizer/index.cjs +0 -1
- package/lib/intersector/index.cjs +0 -1
- package/lib/polyfills-AItxku8u.js +0 -76
- package/lib/polyfills-Caa6z-Ay.cjs +0 -1
- package/lib/store/index.cjs +0 -1
- package/lib/style-B2GS6rev.js +0 -104
- package/lib/style-qftK_UJp.cjs +0 -1
- package/lib/ticker/index.cjs +0 -1
- package/lib/window-resizer/index.cjs +0 -1
- package/lib/window-resizer/index.js +0 -42
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function o(t, n, a) {
|
|
2
|
+
return (1 - a) * t + a * n;
|
|
3
|
+
}
|
|
4
|
+
function p(t, n, a, s) {
|
|
5
|
+
return o(t, n, 1 - Math.exp(-a * s));
|
|
6
|
+
}
|
|
7
|
+
function d(t, n, a = 0, s = 1) {
|
|
8
|
+
return n < t ? a : s;
|
|
9
|
+
}
|
|
10
|
+
function l(t, n = 5) {
|
|
11
|
+
return +t.toFixed(n);
|
|
12
|
+
}
|
|
13
|
+
function i(t, n = 0, a = 0) {
|
|
14
|
+
return Math.max(n, Math.min(t, a));
|
|
15
|
+
}
|
|
16
|
+
function h(t, n, a) {
|
|
17
|
+
const c = (t - n[0]) / (n[1] - n[0]) * (a[1] - a[0]) + a[0];
|
|
18
|
+
return i(c, a[0], a[1]);
|
|
19
|
+
}
|
|
20
|
+
function M(t, n, a) {
|
|
21
|
+
return t <= n ? 0 : t >= a ? 1 : (t = (t - n) / (a - n), t * t * (3 - 2 * t));
|
|
22
|
+
}
|
|
23
|
+
function m(t, n, a) {
|
|
24
|
+
return t <= n ? 0 : t >= a ? 1 : (t = (t - n) / (a - n), t * t * t * (t * (t * 6 - 15) + 10));
|
|
25
|
+
}
|
|
26
|
+
function y(t, n) {
|
|
27
|
+
const a = n.x - t.x, s = n.y - t.y;
|
|
28
|
+
return Math.sqrt(Math.pow(a, 2) + Math.pow(s, 2));
|
|
29
|
+
}
|
|
30
|
+
function D(t, n, a, s, c, e) {
|
|
31
|
+
const r = s - t, u = c - n;
|
|
32
|
+
return Math.sqrt(r * r + u * u) - (a + e);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
M as a,
|
|
36
|
+
m as b,
|
|
37
|
+
i as c,
|
|
38
|
+
p as d,
|
|
39
|
+
y as e,
|
|
40
|
+
D as f,
|
|
41
|
+
o as l,
|
|
42
|
+
h as m,
|
|
43
|
+
l as r,
|
|
44
|
+
d as s
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function r(t,n,e){return(1-e)*t+e*n}function p(t,n,e,c){return r(t,n,1-Math.exp(-e*c))}function l(t,n,e=0,c=1){return n<t?e:c}function d(t,n=5){return+t.toFixed(n)}function i(t,n=0,e=0){return Math.max(n,Math.min(t,e))}function f(t,n,e){const a=(t-n[0])/(n[1]-n[0])*(e[1]-e[0])+e[0];return i(a,e[0],e[1])}function h(t,n,e){return t<=n?0:t>=e?1:(t=(t-n)/(e-n),t*t*(3-2*t))}function m(t,n,e){return t<=n?0:t>=e?1:(t=(t-n)/(e-n),t*t*t*(t*(t*6-15)+10))}function M(t,n){const e=n.x-t.x,c=n.y-t.y;return Math.sqrt(Math.pow(e,2)+Math.pow(c,2))}function D(t,n,e,c,a,u){const s=c-t,o=a-n;return Math.sqrt(s*s+o*o)-(e+u)}exports.calculateDistance=M;exports.calculateDistanceWithRadius=D;exports.clamp=i;exports.damp=p;exports.lerp=r;exports.mapRange=f;exports.round=d;exports.smootherstep=m;exports.smoothstep=h;exports.step=l;
|
package/lib/media/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=e=>{throw TypeError(e)};var d=(e,r,s)=>r.has(e)||a("Cannot "+s);var o=(e,r,s)=>(d(e,r,"read from private field"),s?s.call(e):r.get(e)),c=(e,r,s)=>r.has(e)?a("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(e):r.set(e,s),n=(e,r,s,u)=>(d(e,r,"write to private field"),u?u.call(e,s):r.set(e,s),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../order/index.cjs"),h=require("../window-resizer/vanilla/index.cjs"),b=require("../Store-CDb6RMce.cjs");var i,t;class w extends b.Store{constructor(s){super(!1);c(this,i);c(this,t);n(this,i,s),n(this,t,h.windowResizer.subscribe(()=>{matchMedia(o(this,i)).matches?this.current=!0:this.current=!1},l.RESIZE_ORDER.MEDIA))}close(){super.close(),o(this,t).call(this)}}i=new WeakMap,t=new WeakMap;exports.Media=w;
|
package/lib/media/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var a = (e) => {
|
|
|
4
4
|
var h = (e, s, r) => s.has(e) || a("Cannot " + r);
|
|
5
5
|
var o = (e, s, r) => (h(e, s, "read from private field"), r ? r.call(e) : s.get(e)), c = (e, s, r) => s.has(e) ? a("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(e) : s.set(e, r), u = (e, s, r, m) => (h(e, s, "write to private field"), m ? m.call(e, r) : s.set(e, r), r);
|
|
6
6
|
import { RESIZE_ORDER as n } from "../order/index.js";
|
|
7
|
-
import { windowResizer as f } from "../window-resizer/index.js";
|
|
7
|
+
import { windowResizer as f } from "../window-resizer/vanilla/index.js";
|
|
8
8
|
import { S as l } from "../Store-OTdcl6SX.js";
|
|
9
9
|
var t, i;
|
|
10
10
|
class w extends l {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var oe=n=>{throw TypeError(n)};var te=(n,r,t)=>r.has(n)||oe("Cannot "+t);var e=(n,r,t)=>(te(n,r,"read from private field"),t?t.call(n):r.get(n)),s=(n,r,t)=>r.has(n)?oe("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(n):r.set(n,t),h=(n,r,t,i)=>(te(n,r,"write to private field"),i?i.call(n,t):r.set(n,t),t),b=(n,r,t)=>(te(n,r,"access private method"),t);var ce=(n,r,t)=>new Promise((i,l)=>{var R=m=>{try{E(t.next(m))}catch(o){l(o)}},Y=m=>{try{E(t.throw(m))}catch(o){l(o)}},E=m=>m.done?i(m.value):Promise.resolve(m.value).then(R,Y);E((t=t.apply(n,r)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ve=require("../source/index.cjs"),Ee=require("../class-linked-status/index.cjs"),he=require("../browser-CpzFX2xg.cjs"),ie=require("../events-KVanG9sR.cjs"),Se=require("../string-DhgS_iFl.cjs"),se=require("../loading/index.cjs"),j=require("../css-property/index.cjs"),Q=require("../element-resizer/vanilla/index.cjs"),le=require("../canvas-CU5Xjahf.cjs"),B=require("../ticker/vanilla/index.cjs"),ye=require("../jss-GJLvaNfT.cjs"),we=require("../math-GDWEqu7y.cjs");let Ce=0;var u,a,S,_,p,k,c,M,F,J,U,W,Z;class ee extends HTMLElement{constructor(){super();s(this,F);s(this,u,null);s(this,a,null);s(this,S,!1);s(this,_,!1);s(this,p,!1);s(this,k,"");s(this,c,new Ee.ClassLinkedStatus(this,{loading:!1,loaded:!1,error:!1}));s(this,M,null);s(this,U,t=>{const i=t[0];e(this,p)&&(!e(this,_)||this.hasAttribute("reload-source"))&&i.isIntersecting&&(e(this,u).current&&e(this,u).current!==e(this,u).previous&&b(this,F,J).call(this,e(this,u).current),h(this,_,!0)),i.isIntersecting?ie.dispatchEvent(this,"sourceCapture",{custom:!0}):(this.hasAttribute("reload-source")&&b(this,F,J).call(this,void 0),ie.dispatchEvent(this,"sourceRelease",{custom:!0}))});s(this,W,()=>{e(this,c).set("loaded",!0),e(this,c).set("error",!1),e(this,c).set("loading",!1),!e(this,p)&&!e(this,S)&&se.loading.complete(e(this,k)),h(this,S,!0)});s(this,Z,t=>{e(this,c).set("loaded",!1),e(this,c).set("error",!0),e(this,c).set("loading",!1),!e(this,p)&&!e(this,S)&&se.loading.error(e(this,k)),h(this,S,!0)});he.isBrowser&&window.IntersectionObserver&&(h(this,k,`source-consumer-${++Ce}`),h(this,M,new IntersectionObserver(e(this,U))))}get consumerElement(){return e(this,a)}get sourceManager(){return e(this,u)}get status(){return e(this,c)}get isLazy(){return e(this,p)}connectedCallback(){const t=this.getAttribute("srcset");t&&(h(this,a,this.createConsumer()),e(this,a).style.cssText=`
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
`,e(this,a).classList.add("source-consumer"),Array.from(this.attributes).forEach(i=>{if(i.name!=="srcset"){const l=i.nodeValue||"",R=Se.kebabToCamel(i.name);R in e(this,a)&&(e(this,a)[R]=l||!0)}}),this.appendChild(e(this,a)),h(this,u,new ve.SourceManager({srcset:t})),h(this,p,this.hasAttribute("lazy")),e(this,u).subscribe(i=>{(!e(this,p)||e(this,p)&&e(this,_))&&b(this,F,J).call(this,i.current)}),e(this,M).observe(this),e(this,u).connect())}disconnectedCallback(){e(this,M).disconnect(),e(this,u).close(),e(this,a).onloadeddata=null,e(this,a).onload=null,e(this,a).onerror=null,e(this,a).remove(),e(this,c).reset()}}u=new WeakMap,a=new WeakMap,S=new WeakMap,_=new WeakMap,p=new WeakMap,k=new WeakMap,c=new WeakMap,M=new WeakMap,F=new WeakSet,J=function(t){if(e(this,a).onloadeddata=null,e(this,a).onload=null,e(this,a).onerror=null,e(this,c).set("loaded",!1),e(this,c).set("error",!1),e(this,c).set("loading",!1),t){const i=this.hasAttribute("keep-source-parameters");e(this,c).set("loading",!0);const l=i?t.url:t.name+t.extension;this.consumeSource(l),!e(this,p)&&!e(this,S)&&se.loading.add(e(this,k)),e(this,a).onloadeddata=()=>{e(this,W).call(this)},e(this,a).onload=()=>{e(this,W).call(this)},e(this,a).onerror=()=>{e(this,Z).call(this,l)}}else this.consumeSource(null)},U=new WeakMap,W=new WeakMap,Z=new WeakMap;class ue extends ee{createConsumer(){return document.createElement("img")}consumeSource(r){this.consumerElement.src=r||""}}customElements.get("e-image")||customElements.define("e-image",ue);var y,g,H,L,P,T,D,K,d,ne,me,N,O,re,pe;class de extends HTMLElement{constructor(){super();s(this,d);s(this,y,new j.CSSProperty(this,"--fps",0));s(this,g,null);s(this,H,null);s(this,L,0);s(this,P,0);s(this,T,1);s(this,D,0);s(this,K,1);s(this,N,t=>{h(this,T,we.clamp(devicePixelRatio,1,2)),h(this,L,t.contentRect.width),h(this,P,t.contentRect.height),e(this,g).width=e(this,L)*this.pixelRatio,e(this,g).height=e(this,P)*this.pixelRatio,this.context.scale(this.pixelRatio,this.pixelRatio),b(this,d,pe).call(this),b(this,d,re).call(this)});s(this,O,t=>{h(this,D,t.timestamp),h(this,K,t.timeBetweenFrames),b(this,d,re).call(this)});if(he.isBrowser){const t=this.attachShadow({mode:"open"});t.adoptedStyleSheets.push(ye.createStylesheet({" :host, canvas":{display:"block",width:"100%",height:"100%"}})),h(this,g,document.createElement("canvas")),h(this,H,e(this,g).getContext("2d")),t.appendChild(e(this,g)),e(this,y).subscribe(i=>{typeof i.previous!="undefined"&&i.current!==i.previous&&b(this,d,ne).call(this)})}}get fpsCSSProperty(){return e(this,y)}get canvasElement(){return e(this,g)}get context(){return e(this,H)}get pixelRatio(){return e(this,T)}get width(){return e(this,L)}get height(){return e(this,P)}get detail(){return{width:e(this,L),height:e(this,P),element:this,canvasElement:e(this,g),pixelRatio:e(this,T),context:e(this,H),timestamp:e(this,D),timeBetweenFrames:e(this,K)}}connectedCallback(){e(this,y).observe(),Q.elementResizer.subscribe(this,e(this,N)),b(this,d,ne).call(this)}disconnectedCallback(){e(this,y).unobserve(),Q.elementResizer.unsubscribe(e(this,N)),b(this,d,me).call(this)}}y=new WeakMap,g=new WeakMap,H=new WeakMap,L=new WeakMap,P=new WeakMap,T=new WeakMap,D=new WeakMap,K=new WeakMap,d=new WeakSet,ne=function(){B.ticker.unsubscribe(e(this,O)),this.hasAttribute("static")||B.ticker.subscribe(e(this,O),{culling:this,maxFPS:e(this,y).current})},me=function(){B.ticker.unsubscribe(e(this,O))},N=new WeakMap,O=new WeakMap,re=function(){this.dispatchEvent(new CustomEvent("canvasRender",{composed:!0,detail:this.detail}))},pe=function(){this.dispatchEvent(new CustomEvent("canvasResize",{composed:!0,detail:this.detail}))};customElements.get("e-canvas")||customElements.define("e-canvas",de);function xe(n){const r=n.match(/\{([\d-]+)\}/);if(r){const t=r[1].split("-");if(t.length===2){const i=parseInt(t[0],10),l=parseInt(t[1],10);return{start:i,end:l}}}return null}var f,q,V,w,C,I,z,X,v,x;class fe extends ee{constructor(t){super();s(this,f,[]);s(this,q,new j.CSSProperty(this,"--fit","contain"));s(this,V,new j.CSSProperty(this,"--autoplay",!1));s(this,w,new j.CSSProperty(this,"--offset-x",.5));s(this,C,new j.CSSProperty(this,"--offset-y",.5));s(this,I,null);s(this,z,0);s(this,X,1);s(this,v,()=>{if(e(this,f).length){const t=e(this,f)[0];e(this,q).current==="cover"?h(this,I,le.cover(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,w).current,e(this,C).current)):h(this,I,le.contain(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,w).current,e(this,C).current))}});s(this,x,t=>{if(this.status.isFalse("loaded")||!e(this,I))return;t.detail.context.clearRect(0,0,t.detail.width,t.detail.height);const i=e(this,f)[e(this,z)];i&&t.detail.context.drawImage(i,...e(this,I)),e(this,V).current&&h(this,z,(e(this,z)+1)%e(this,f).length)});he.isBrowser&&(h(this,X,parseInt(((t==null?void 0:t.pad)||this.getAttribute("pad")||"1").toString())),e(this,q).subscribe(e(this,v)),e(this,w).subscribe(e(this,v)),e(this,C).subscribe(e(this,v)),this.addEventListener("sourceCapture",i=>{this.consumerElement.addEventListener("canvasRender",e(this,x))}),this.addEventListener("sourceRelease",i=>{this.consumerElement.removeEventListener("canvasRender",e(this,x))}))}setProgress(t){e(this,f).length&&h(this,z,Math.floor((e(this,f).length-1)*t))}connectedCallback(){super.connectedCallback(),e(this,V).observe(),e(this,q).observe(),e(this,w).observe(),e(this,C).observe(),Q.elementResizer.subscribe(this,e(this,v))}disconnectedCallback(){super.disconnectedCallback(),e(this,V).unobserve(),e(this,q).unobserve(),e(this,w).unobserve(),e(this,C).unobserve(),h(this,f,[]),Q.elementResizer.unsubscribe(e(this,v)),this.consumerElement.removeEventListener("canvasRender",e(this,x))}createConsumer(){return new de}consumeSource(t){return ce(this,null,function*(){var i,l,R,Y;if(t){this.consumerElement.removeEventListener("canvasRender",e(this,x));const E=[],m=xe(t);if(m)for(let o=m.start;o<=m.end;o++){const ae=t.replace(/\{([^}]+)\}/,o.toString().padStart(e(this,X),"0")),G=new Image;G.src=ae,E.push(G)}else{const o=new Image;o.src=t,E.push(o)}try{yield Promise.all(E.map((o,ae)=>new Promise((G,ge)=>{o.onload=()=>{G()},o.onerror=Re=>{ge(`${o.src} Image not found`)}}))),h(this,f,E),e(this,v).call(this),(l=(i=this.consumerElement).onload)==null||l.call(i,new Event("load")),this.isLazy||this.consumerElement.addEventListener("canvasRender",e(this,x))}catch(o){console.error(o),(Y=(R=this.consumerElement).onerror)==null||Y.call(R,new Event("error"))}}})}}f=new WeakMap,q=new WeakMap,V=new WeakMap,w=new WeakMap,C=new WeakMap,I=new WeakMap,z=new WeakMap,X=new WeakMap,v=new WeakMap,x=new WeakMap;customElements.get("e-sequence")||customElements.define("e-sequence",fe);var A,$;class be extends ee{constructor(){super(...arguments);s(this,A,0);s(this,$,()=>{this.classList.add(`state-${this.consumerElement.readyState}`);const t=this.consumerElement.readyState/4;t>e(this,A)&&h(this,A,t),ie.dispatchEvent(this,"videoReadyStateChange",{detail:{readyState:this.consumerElement.readyState,progress:e(this,A)}}),this.consumerElement.readyState===4&&B.ticker.unsubscribe(e(this,$))})}connectedCallback(){super.connectedCallback(),this.addEventListener("sourceCapture",()=>{B.ticker.subscribe(e(this,$)),this.hasAttribute("capture-autoplay")&&this.consumerElement.play()}),this.addEventListener("sourceRelease",()=>{this.hasAttribute("capture-autoplay")&&(this.consumerElement.pause(),this.hasAttribute("replay")&&(this.consumerElement.currentTime=0)),this.hasAttribute("reload-source")&&this.classList.remove("state-0","state-1","state-2","state-3","state-4")})}disconnectedCallback(){super.disconnectedCallback(),B.ticker.unsubscribe(e(this,$)),h(this,A,0)}createConsumer(){return document.createElement("video")}consumeSource(t){this.consumerElement.src=t||""}}A=new WeakMap,$=new WeakMap;customElements.get("e-video")||customElements.define("e-video",be);exports.ImageElement=ue;exports.SequenceElement=fe;exports.SourceElement=ee;exports.VideoElement=be;
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
var oe = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
|
+
};
|
|
4
|
+
var ee = (r, n, t) => n.has(r) || oe("Cannot " + t);
|
|
5
|
+
var e = (r, n, t) => (ee(r, n, "read from private field"), t ? t.call(r) : n.get(r)), s = (r, n, t) => n.has(r) ? oe("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(r) : n.set(r, t), h = (r, n, t, i) => (ee(r, n, "write to private field"), i ? i.call(r, t) : n.set(r, t), t), b = (r, n, t) => (ee(r, n, "access private method"), t);
|
|
6
|
+
var ce = (r, n, t) => new Promise((i, l) => {
|
|
7
|
+
var L = (m) => {
|
|
8
|
+
try {
|
|
9
|
+
E(t.next(m));
|
|
10
|
+
} catch (o) {
|
|
11
|
+
l(o);
|
|
12
|
+
}
|
|
13
|
+
}, G = (m) => {
|
|
14
|
+
try {
|
|
15
|
+
E(t.throw(m));
|
|
16
|
+
} catch (o) {
|
|
17
|
+
l(o);
|
|
18
|
+
}
|
|
19
|
+
}, E = (m) => m.done ? i(m.value) : Promise.resolve(m.value).then(L, G);
|
|
20
|
+
E((t = t.apply(r, n)).next());
|
|
21
|
+
});
|
|
22
|
+
import { SourceManager as pe } from "../source/index.js";
|
|
23
|
+
import { ClassLinkedStatus as fe } from "../class-linked-status/index.js";
|
|
24
|
+
import { i as ne } from "../browser-0zX67oeU.js";
|
|
25
|
+
import { d as se } from "../events-CsVF98U6.js";
|
|
26
|
+
import { k as be } from "../string-f0Dnk0L1.js";
|
|
27
|
+
import { loading as te } from "../loading/index.js";
|
|
28
|
+
import { CSSProperty as D } from "../css-property/index.js";
|
|
29
|
+
import { elementResizer as U } from "../element-resizer/vanilla/index.js";
|
|
30
|
+
import { c as ge, a as ve } from "../canvas-DeZ0SLUJ.js";
|
|
31
|
+
import { ticker as F } from "../ticker/vanilla/index.js";
|
|
32
|
+
import { c as Ee } from "../jss-CjccJC-K.js";
|
|
33
|
+
import { c as we } from "../math-BOBiC4TN.js";
|
|
34
|
+
let Se = 0;
|
|
35
|
+
var u, a, w, H, p, R, c, M, T, Q, Z, K, _;
|
|
36
|
+
class he extends HTMLElement {
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
s(this, T);
|
|
40
|
+
s(this, u, null);
|
|
41
|
+
s(this, a, null);
|
|
42
|
+
s(this, w, !1);
|
|
43
|
+
s(this, H, !1);
|
|
44
|
+
s(this, p, !1);
|
|
45
|
+
s(this, R, "");
|
|
46
|
+
s(this, c, new fe(this, {
|
|
47
|
+
loading: !1,
|
|
48
|
+
loaded: !1,
|
|
49
|
+
error: !1
|
|
50
|
+
}));
|
|
51
|
+
s(this, M, null);
|
|
52
|
+
s(this, Z, (t) => {
|
|
53
|
+
const i = t[0];
|
|
54
|
+
e(this, p) && (!e(this, H) || this.hasAttribute("reload-source")) && i.isIntersecting && (e(this, u).current && e(this, u).current !== e(this, u).previous && b(this, T, Q).call(this, e(this, u).current), h(this, H, !0)), i.isIntersecting ? se(this, "sourceCapture", { custom: !0 }) : (this.hasAttribute("reload-source") && b(this, T, Q).call(this, void 0), se(this, "sourceRelease", { custom: !0 }));
|
|
55
|
+
});
|
|
56
|
+
s(this, K, () => {
|
|
57
|
+
e(this, c).set("loaded", !0), e(this, c).set("error", !1), e(this, c).set("loading", !1), !e(this, p) && !e(this, w) && te.complete(e(this, R)), h(this, w, !0);
|
|
58
|
+
});
|
|
59
|
+
s(this, _, (t) => {
|
|
60
|
+
e(this, c).set("loaded", !1), e(this, c).set("error", !0), e(this, c).set("loading", !1), !e(this, p) && !e(this, w) && te.error(e(this, R)), h(this, w, !0);
|
|
61
|
+
});
|
|
62
|
+
ne && window.IntersectionObserver && (h(this, R, `source-consumer-${++Se}`), h(this, M, new IntersectionObserver(
|
|
63
|
+
e(this, Z)
|
|
64
|
+
)));
|
|
65
|
+
}
|
|
66
|
+
get consumerElement() {
|
|
67
|
+
return e(this, a);
|
|
68
|
+
}
|
|
69
|
+
get sourceManager() {
|
|
70
|
+
return e(this, u);
|
|
71
|
+
}
|
|
72
|
+
get status() {
|
|
73
|
+
return e(this, c);
|
|
74
|
+
}
|
|
75
|
+
get isLazy() {
|
|
76
|
+
return e(this, p);
|
|
77
|
+
}
|
|
78
|
+
connectedCallback() {
|
|
79
|
+
const t = this.getAttribute("srcset");
|
|
80
|
+
t && (h(this, a, this.createConsumer()), e(this, a).style.cssText = `
|
|
81
|
+
display: block;
|
|
82
|
+
width: 100%;
|
|
83
|
+
height: 100%;
|
|
84
|
+
`, e(this, a).classList.add("source-consumer"), Array.from(this.attributes).forEach((i) => {
|
|
85
|
+
if (i.name !== "srcset") {
|
|
86
|
+
const l = i.nodeValue || "", L = be(i.name);
|
|
87
|
+
L in e(this, a) && (e(this, a)[L] = l || !0);
|
|
88
|
+
}
|
|
89
|
+
}), this.appendChild(e(this, a)), h(this, u, new pe({
|
|
90
|
+
srcset: t
|
|
91
|
+
})), h(this, p, this.hasAttribute("lazy")), e(this, u).subscribe((i) => {
|
|
92
|
+
(!e(this, p) || e(this, p) && e(this, H)) && b(this, T, Q).call(this, i.current);
|
|
93
|
+
}), e(this, M).observe(this), e(this, u).connect());
|
|
94
|
+
}
|
|
95
|
+
disconnectedCallback() {
|
|
96
|
+
e(this, M).disconnect(), e(this, u).close(), e(this, a).onloadeddata = null, e(this, a).onload = null, e(this, a).onerror = null, e(this, a).remove(), e(this, c).reset();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
u = new WeakMap(), a = new WeakMap(), w = new WeakMap(), H = new WeakMap(), p = new WeakMap(), R = new WeakMap(), c = new WeakMap(), M = new WeakMap(), T = new WeakSet(), Q = function(t) {
|
|
100
|
+
if (e(this, a).onloadeddata = null, e(this, a).onload = null, e(this, a).onerror = null, e(this, c).set("loaded", !1), e(this, c).set("error", !1), e(this, c).set("loading", !1), t) {
|
|
101
|
+
const i = this.hasAttribute("keep-source-parameters");
|
|
102
|
+
e(this, c).set("loading", !0);
|
|
103
|
+
const l = i ? t.url : t.name + t.extension;
|
|
104
|
+
this.consumeSource(l), !e(this, p) && !e(this, w) && te.add(e(this, R)), e(this, a).onloadeddata = () => {
|
|
105
|
+
e(this, K).call(this);
|
|
106
|
+
}, e(this, a).onload = () => {
|
|
107
|
+
e(this, K).call(this);
|
|
108
|
+
}, e(this, a).onerror = () => {
|
|
109
|
+
e(this, _).call(this, l);
|
|
110
|
+
};
|
|
111
|
+
} else
|
|
112
|
+
this.consumeSource(null);
|
|
113
|
+
}, Z = new WeakMap(), K = new WeakMap(), _ = new WeakMap();
|
|
114
|
+
class Ce extends he {
|
|
115
|
+
createConsumer() {
|
|
116
|
+
return document.createElement("img");
|
|
117
|
+
}
|
|
118
|
+
consumeSource(n) {
|
|
119
|
+
this.consumerElement.src = n || "";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
customElements.get("e-image") || customElements.define("e-image", Ce);
|
|
123
|
+
var S, g, q, k, I, O, N, X, d, ie, ue, Y, $, re, de;
|
|
124
|
+
class le extends HTMLElement {
|
|
125
|
+
constructor() {
|
|
126
|
+
super();
|
|
127
|
+
s(this, d);
|
|
128
|
+
s(this, S, new D(this, "--fps", 0));
|
|
129
|
+
s(this, g, null);
|
|
130
|
+
s(this, q, null);
|
|
131
|
+
s(this, k, 0);
|
|
132
|
+
s(this, I, 0);
|
|
133
|
+
s(this, O, 1);
|
|
134
|
+
s(this, N, 0);
|
|
135
|
+
s(this, X, 1);
|
|
136
|
+
s(this, Y, (t) => {
|
|
137
|
+
h(this, O, we(devicePixelRatio, 1, 2)), h(this, k, t.contentRect.width), h(this, I, t.contentRect.height), e(this, g).width = e(this, k) * this.pixelRatio, e(this, g).height = e(this, I) * this.pixelRatio, this.context.scale(this.pixelRatio, this.pixelRatio), b(this, d, de).call(this), b(this, d, re).call(this);
|
|
138
|
+
});
|
|
139
|
+
s(this, $, (t) => {
|
|
140
|
+
h(this, N, t.timestamp), h(this, X, t.timeBetweenFrames), b(this, d, re).call(this);
|
|
141
|
+
});
|
|
142
|
+
if (ne) {
|
|
143
|
+
const t = this.attachShadow({ mode: "open" });
|
|
144
|
+
t.adoptedStyleSheets.push(
|
|
145
|
+
Ee({
|
|
146
|
+
" :host, canvas": {
|
|
147
|
+
display: "block",
|
|
148
|
+
width: "100%",
|
|
149
|
+
height: "100%"
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
), h(this, g, document.createElement("canvas")), h(this, q, e(this, g).getContext("2d")), t.appendChild(e(this, g)), e(this, S).subscribe((i) => {
|
|
153
|
+
typeof i.previous != "undefined" && i.current !== i.previous && b(this, d, ie).call(this);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
get fpsCSSProperty() {
|
|
158
|
+
return e(this, S);
|
|
159
|
+
}
|
|
160
|
+
get canvasElement() {
|
|
161
|
+
return e(this, g);
|
|
162
|
+
}
|
|
163
|
+
get context() {
|
|
164
|
+
return e(this, q);
|
|
165
|
+
}
|
|
166
|
+
get pixelRatio() {
|
|
167
|
+
return e(this, O);
|
|
168
|
+
}
|
|
169
|
+
get width() {
|
|
170
|
+
return e(this, k);
|
|
171
|
+
}
|
|
172
|
+
get height() {
|
|
173
|
+
return e(this, I);
|
|
174
|
+
}
|
|
175
|
+
get detail() {
|
|
176
|
+
return {
|
|
177
|
+
width: e(this, k),
|
|
178
|
+
height: e(this, I),
|
|
179
|
+
element: this,
|
|
180
|
+
canvasElement: e(this, g),
|
|
181
|
+
pixelRatio: e(this, O),
|
|
182
|
+
context: e(this, q),
|
|
183
|
+
timestamp: e(this, N),
|
|
184
|
+
timeBetweenFrames: e(this, X)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
connectedCallback() {
|
|
188
|
+
e(this, S).observe(), U.subscribe(this, e(this, Y)), b(this, d, ie).call(this);
|
|
189
|
+
}
|
|
190
|
+
disconnectedCallback() {
|
|
191
|
+
e(this, S).unobserve(), U.unsubscribe(e(this, Y)), b(this, d, ue).call(this);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
S = new WeakMap(), g = new WeakMap(), q = new WeakMap(), k = new WeakMap(), I = new WeakMap(), O = new WeakMap(), N = new WeakMap(), X = new WeakMap(), d = new WeakSet(), ie = function() {
|
|
195
|
+
F.unsubscribe(e(this, $)), this.hasAttribute("static") || F.subscribe(e(this, $), {
|
|
196
|
+
culling: this,
|
|
197
|
+
maxFPS: e(this, S).current
|
|
198
|
+
});
|
|
199
|
+
}, ue = function() {
|
|
200
|
+
F.unsubscribe(e(this, $));
|
|
201
|
+
}, Y = new WeakMap(), $ = new WeakMap(), re = function() {
|
|
202
|
+
this.dispatchEvent(
|
|
203
|
+
new CustomEvent("canvasRender", {
|
|
204
|
+
composed: !0,
|
|
205
|
+
detail: this.detail
|
|
206
|
+
})
|
|
207
|
+
);
|
|
208
|
+
}, de = function() {
|
|
209
|
+
this.dispatchEvent(
|
|
210
|
+
new CustomEvent("canvasResize", {
|
|
211
|
+
composed: !0,
|
|
212
|
+
detail: this.detail
|
|
213
|
+
})
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
customElements.get("e-canvas") || customElements.define("e-canvas", le);
|
|
217
|
+
function ye(r) {
|
|
218
|
+
const n = r.match(/\{([\d-]+)\}/);
|
|
219
|
+
if (n) {
|
|
220
|
+
const t = n[1].split("-");
|
|
221
|
+
if (t.length === 2) {
|
|
222
|
+
const i = parseInt(t[0], 10), l = parseInt(t[1], 10);
|
|
223
|
+
return { start: i, end: l };
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
var f, P, V, C, y, A, z, j, v, x;
|
|
229
|
+
class xe extends he {
|
|
230
|
+
constructor(t) {
|
|
231
|
+
super();
|
|
232
|
+
s(this, f, []);
|
|
233
|
+
s(this, P, new D(
|
|
234
|
+
this,
|
|
235
|
+
"--fit",
|
|
236
|
+
"contain"
|
|
237
|
+
));
|
|
238
|
+
s(this, V, new D(this, "--autoplay", !1));
|
|
239
|
+
s(this, C, new D(this, "--offset-x", 0.5));
|
|
240
|
+
s(this, y, new D(this, "--offset-y", 0.5));
|
|
241
|
+
s(this, A, null);
|
|
242
|
+
s(this, z, 0);
|
|
243
|
+
s(this, j, 1);
|
|
244
|
+
s(this, v, () => {
|
|
245
|
+
if (e(this, f).length) {
|
|
246
|
+
const t = e(this, f)[0];
|
|
247
|
+
e(this, P).current === "cover" ? h(this, A, ge(
|
|
248
|
+
t.naturalWidth,
|
|
249
|
+
t.naturalHeight,
|
|
250
|
+
this.consumerElement.width,
|
|
251
|
+
this.consumerElement.height,
|
|
252
|
+
e(this, C).current,
|
|
253
|
+
e(this, y).current
|
|
254
|
+
)) : h(this, A, ve(
|
|
255
|
+
t.naturalWidth,
|
|
256
|
+
t.naturalHeight,
|
|
257
|
+
this.consumerElement.width,
|
|
258
|
+
this.consumerElement.height,
|
|
259
|
+
e(this, C).current,
|
|
260
|
+
e(this, y).current
|
|
261
|
+
));
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
s(this, x, (t) => {
|
|
265
|
+
if (this.status.isFalse("loaded") || !e(this, A))
|
|
266
|
+
return;
|
|
267
|
+
t.detail.context.clearRect(0, 0, t.detail.width, t.detail.height);
|
|
268
|
+
const i = e(this, f)[e(this, z)];
|
|
269
|
+
i && t.detail.context.drawImage(i, ...e(this, A)), e(this, V).current && h(this, z, (e(this, z) + 1) % e(this, f).length);
|
|
270
|
+
});
|
|
271
|
+
ne && (h(this, j, parseInt(
|
|
272
|
+
((t == null ? void 0 : t.pad) || this.getAttribute("pad") || "1").toString()
|
|
273
|
+
)), e(this, P).subscribe(e(this, v)), e(this, C).subscribe(e(this, v)), e(this, y).subscribe(e(this, v)), this.addEventListener("sourceCapture", (i) => {
|
|
274
|
+
this.consumerElement.addEventListener(
|
|
275
|
+
"canvasRender",
|
|
276
|
+
e(this, x)
|
|
277
|
+
);
|
|
278
|
+
}), this.addEventListener("sourceRelease", (i) => {
|
|
279
|
+
this.consumerElement.removeEventListener(
|
|
280
|
+
"canvasRender",
|
|
281
|
+
e(this, x)
|
|
282
|
+
);
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
setProgress(t) {
|
|
286
|
+
e(this, f).length && h(this, z, Math.floor((e(this, f).length - 1) * t));
|
|
287
|
+
}
|
|
288
|
+
connectedCallback() {
|
|
289
|
+
super.connectedCallback(), e(this, V).observe(), e(this, P).observe(), e(this, C).observe(), e(this, y).observe(), U.subscribe(this, e(this, v));
|
|
290
|
+
}
|
|
291
|
+
disconnectedCallback() {
|
|
292
|
+
super.disconnectedCallback(), e(this, V).unobserve(), e(this, P).unobserve(), e(this, C).unobserve(), e(this, y).unobserve(), h(this, f, []), U.unsubscribe(e(this, v)), this.consumerElement.removeEventListener(
|
|
293
|
+
"canvasRender",
|
|
294
|
+
e(this, x)
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
createConsumer() {
|
|
298
|
+
return new le();
|
|
299
|
+
}
|
|
300
|
+
consumeSource(t) {
|
|
301
|
+
return ce(this, null, function* () {
|
|
302
|
+
var i, l, L, G;
|
|
303
|
+
if (t) {
|
|
304
|
+
this.consumerElement.removeEventListener(
|
|
305
|
+
"canvasRender",
|
|
306
|
+
e(this, x)
|
|
307
|
+
);
|
|
308
|
+
const E = [], m = ye(t);
|
|
309
|
+
if (m)
|
|
310
|
+
for (let o = m.start; o <= m.end; o++) {
|
|
311
|
+
const ae = t.replace(
|
|
312
|
+
/\{([^}]+)\}/,
|
|
313
|
+
o.toString().padStart(e(this, j), "0")
|
|
314
|
+
), J = new Image();
|
|
315
|
+
J.src = ae, E.push(J);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
const o = new Image();
|
|
319
|
+
o.src = t, E.push(o);
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
yield Promise.all(
|
|
323
|
+
E.map((o, ae) => new Promise((J, me) => {
|
|
324
|
+
o.onload = () => {
|
|
325
|
+
J();
|
|
326
|
+
}, o.onerror = (Re) => {
|
|
327
|
+
me(`${o.src} Image not found`);
|
|
328
|
+
};
|
|
329
|
+
}))
|
|
330
|
+
), h(this, f, E), e(this, v).call(this), (l = (i = this.consumerElement).onload) == null || l.call(i, new Event("load")), this.isLazy || this.consumerElement.addEventListener(
|
|
331
|
+
"canvasRender",
|
|
332
|
+
e(this, x)
|
|
333
|
+
);
|
|
334
|
+
} catch (o) {
|
|
335
|
+
console.error(o), (G = (L = this.consumerElement).onerror) == null || G.call(L, new Event("error"));
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
f = new WeakMap(), P = new WeakMap(), V = new WeakMap(), C = new WeakMap(), y = new WeakMap(), A = new WeakMap(), z = new WeakMap(), j = new WeakMap(), v = new WeakMap(), x = new WeakMap();
|
|
342
|
+
customElements.get("e-sequence") || customElements.define("e-sequence", xe);
|
|
343
|
+
var B, W;
|
|
344
|
+
class Le extends he {
|
|
345
|
+
constructor() {
|
|
346
|
+
super(...arguments);
|
|
347
|
+
s(this, B, 0);
|
|
348
|
+
s(this, W, () => {
|
|
349
|
+
this.classList.add(`state-${this.consumerElement.readyState}`);
|
|
350
|
+
const t = this.consumerElement.readyState / 4;
|
|
351
|
+
t > e(this, B) && h(this, B, t), se(this, "videoReadyStateChange", {
|
|
352
|
+
detail: {
|
|
353
|
+
readyState: this.consumerElement.readyState,
|
|
354
|
+
progress: e(this, B)
|
|
355
|
+
}
|
|
356
|
+
}), this.consumerElement.readyState === 4 && F.unsubscribe(e(this, W));
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
connectedCallback() {
|
|
360
|
+
super.connectedCallback(), this.addEventListener("sourceCapture", () => {
|
|
361
|
+
F.subscribe(e(this, W)), this.hasAttribute("capture-autoplay") && this.consumerElement.play();
|
|
362
|
+
}), this.addEventListener("sourceRelease", () => {
|
|
363
|
+
this.hasAttribute("capture-autoplay") && (this.consumerElement.pause(), this.hasAttribute("replay") && (this.consumerElement.currentTime = 0)), this.hasAttribute("reload-source") && this.classList.remove(
|
|
364
|
+
"state-0",
|
|
365
|
+
"state-1",
|
|
366
|
+
"state-2",
|
|
367
|
+
"state-3",
|
|
368
|
+
"state-4"
|
|
369
|
+
);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
disconnectedCallback() {
|
|
373
|
+
super.disconnectedCallback(), F.unsubscribe(e(this, W)), h(this, B, 0);
|
|
374
|
+
}
|
|
375
|
+
createConsumer() {
|
|
376
|
+
return document.createElement("video");
|
|
377
|
+
}
|
|
378
|
+
consumeSource(t) {
|
|
379
|
+
this.consumerElement.src = t || "";
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
B = new WeakMap(), W = new WeakMap();
|
|
383
|
+
customElements.get("e-video") || customElements.define("e-video", Le);
|
|
384
|
+
export {
|
|
385
|
+
Ce as ImageElement,
|
|
386
|
+
xe as SequenceElement,
|
|
387
|
+
he as SourceElement,
|
|
388
|
+
Le as VideoElement
|
|
389
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var it=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),nt=n=>{throw TypeError(n)};var Y=(n,t,i)=>t.has(n)||nt("Cannot "+i);var e=(n,t,i)=>(Y(n,t,"read from private field"),i?i.call(n):t.get(n)),o=(n,t,i)=>t.has(n)?nt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,i),u=(n,t,i,r)=>(Y(n,t,"write to private field"),r?r.call(n,i):t.set(n,i),i),m=(n,t,i)=>(Y(n,t,"access private method"),i);var T=(n,t,i)=>new Promise((r,s)=>{var d=l=>{try{p(i.next(l))}catch(E){s(E)}},g=l=>{try{p(i.throw(l))}catch(E){s(E)}},p=l=>l.done?r(l.value):Promise.resolve(l.value).then(d,g);p((i=i.apply(n,t)).next())});var st=(n,t,i)=>(t=n[it("asyncIterator")])?t.call(n):(n=n[it("iterator")](),t={},i=(r,s)=>(s=n[r])&&(t[r]=d=>new Promise((g,p,l)=>(d=s.call(n,d),l=d.done,Promise.resolve(d.value).then(E=>g({value:E,done:l}),p)))),i("next"),i("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rt=require("../notifier/index.cjs"),ut=require("../browser-CpzFX2xg.cjs"),G=require("../url-qZNgg7IM.cjs"),at=require("../loading/index.cjs");var y,h,f,k,A,C,M;class dt{constructor(t,i){o(this,y);o(this,h);o(this,f);o(this,k);o(this,A);o(this,C,t=>{t.preventDefault(),e(this,y).links.forEach(i=>{var r;e(this,f)===e(i,f)||(r=e(i,A))!=null&&r.includes(e(this,f))?e(i,h).classList.add("clicked"):e(i,h).classList.remove("clicked")}),e(this,y).navigate(e(this,f),e(this,k))});o(this,M,()=>{e(this,y).prefetch(e(this,f)),e(this,h).removeEventListener("pointerenter",e(this,M))});var d,g;u(this,y,i),u(this,h,t),u(this,f,e(this,h).getAttribute("href")||"/"),u(this,k,e(this,h).getAttribute("data-history-action")||"push"),e(this,h).addEventListener("click",e(this,C));const r=i.normalizePath(e(this,f)),s=i.normalizePath(location.pathname);u(this,A,(d=e(this,h).getAttribute("data-match-paths"))==null?void 0:d.split(",").map(p=>i.normalizePath(p.trim()).pathname)),e(this,h).hasAttribute("data-include")?s.pathname.includes(r.pathname)&&e(this,h).classList.add("current"):r.pathname===s.pathname||(g=e(this,A))!=null&&g.includes(s.pathname)?(e(this,h).classList.add("current"),e(this,h).classList.add("clicked")):e(this,h).classList.remove("clicked"),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,M))}destroy(){e(this,h).removeEventListener("click",e(this,C)),e(this,h).removeEventListener("pointerenter",e(this,M)),e(this,h).classList.remove("current")}}y=new WeakMap,h=new WeakMap,f=new WeakMap,k=new WeakMap,A=new WeakMap,C=new WeakMap,M=new WeakMap;var S,z,q,x,H,O,P,L,w,_,D,c,J,Q,U,ot,V,B;class mt{constructor(t){o(this,c);o(this,S,null);o(this,z,null);o(this,q,null);o(this,x,null);o(this,H,[]);o(this,O,new DOMParser);o(this,P,new Map);o(this,L);o(this,w,null);o(this,_,new rt.Notifier);o(this,D,new rt.Notifier);o(this,B,t=>{t.state&&this.navigate(t.state,"none")});if(ut.isBrowser){u(this,S,G.normalizeBase(t==null?void 0:t.base)),u(this,z,(t==null?void 0:t.waitForHeadToLoad)!==!1),u(this,q,(t==null?void 0:t.cachePages)!==!1),u(this,x,m(this,c,U).call(this,document.body));const i=this.normalizePath(location.pathname);u(this,w,i.pathname),document.documentElement.setAttribute("data-current-pathname",e(this,w)),document.documentElement.setAttribute("data-current-leaf",i.leaf),m(this,c,Q).call(this),addEventListener("popstate",e(this,B))}}get currentPathname(){return e(this,w)}get links(){return e(this,H)}normalizePath(t){return G.splitPath(t,e(this,S))}beforeNavigationEvent(t){return e(this,_).subscribe(t)}afterNavigationEvent(t){return e(this,D).subscribe(t)}prefetch(t){return T(this,null,function*(){const i=this.normalizePath(t);return m(this,c,J).call(this,i.pathname)})}navigate(t,i="push"){return T(this,null,function*(){var E;const r=this.normalizePath(t);let{pathname:s,hash:d,parameters:g,leaf:p}=r;if(e(this,L)===s||e(this,w)===s)return;u(this,L,s);const l=e(this,P).has(s);try{at.loading.add("__morph");let R=!0;if(e(this,_).notify({pathname:s,isCached:l}),this.preprocessor)try{yield new Promise((a,b)=>{var v;(v=this.preprocessor)==null||v.call(this,{pathname:s,resolve:a,reject:b,isCached:l})})}catch(a){a?console.error(a):console.log("Route change canceled"),R=!1}if(!R||e(this,L)!==s)return;const X=e(this,P).get(s)||(yield m(this,c,J).call(this,s));if(e(this,L)!==s)return;const Z=Array.from(document.head.children),$=Array.from(X.head.cloneNode(!0).children),tt=m(this,c,ot).call(this,Z,$),ht=m(this,c,V).call(this,Z,tt),F=m(this,c,V).call(this,$,tt);F.forEach((a,b)=>{if(a.tagName==="SCRIPT"&&a.getAttribute("src")){const v=document.createElement("script");v.type="module",v.src=a.getAttribute("src"),F[b]=v}}),F.forEach(a=>{document.head.appendChild(a)});const W=F.filter(a=>(a.tagName==="STYLE"||a.tagName==="SCRIPT"||a.tagName==="LINK")&&a.getAttribute("rel")!=="canonical");e(this,z)&&W.length&&(yield new Promise(a=>T(this,null,function*(){let b=0;try{for(var v=st(W),lt,j,I;lt=!(j=yield v.next()).done;lt=!1){const N=j.value;N.onload=()=>{b++,b===W.length&&a()}}}catch(j){I=[j]}finally{try{lt&&(j=v.return)&&(yield j.call(v))}finally{if(I)throw I[0]}}}))),ht.forEach(a=>{a.hasAttribute("data-permanent")||a.remove()}),u(this,w,s),G.changeHistory(i,s,g,d);const ct=m(this,c,U).call(this,X.body.cloneNode(!0));e(this,x).forEach((a,b)=>{const v=ct[b];let lt=[...a.childNodes],j=[...v.childNodes];lt.forEach(I=>{if(I instanceof HTMLElement){const N=I.getAttribute("data-remain");let et;j=j.filter(K=>K instanceof HTMLElement&&N&&K.getAttribute("data-remain")===N?(et=K,!1):!0),N&&et||I.remove()}else I.remove()}),a.append(...j)}),m(this,c,Q).call(this),document.documentElement.setAttribute("data-current-pathname",s),document.documentElement.setAttribute("data-current-leaf",p),(E=this.postprocessor)==null||E.call(this,{pathname:s,isCached:l}),e(this,D).notify({pathname:s,isCached:l}),at.loading.complete("__morph")}catch(R){console.error(R)}u(this,L,void 0)})}}S=new WeakMap,z=new WeakMap,q=new WeakMap,x=new WeakMap,H=new WeakMap,O=new WeakMap,P=new WeakMap,L=new WeakMap,w=new WeakMap,_=new WeakMap,D=new WeakMap,c=new WeakSet,J=function(t){return T(this,null,function*(){const i=e(this,P).get(t);if(i)return i;const s=yield(yield fetch(t)).text(),d=e(this,O).parseFromString(s,"text/html");return e(this,q)&&e(this,P).set(t,d),d})},Q=function(){const t=[...document.documentElement.querySelectorAll("a")].filter(i=>{var r;return(r=i.getAttribute("href"))==null?void 0:r.startsWith("/")});e(this,H).forEach(i=>i.destroy()),u(this,H,t.map(i=>new dt(i,this)))},U=function(t){return[...t.querySelectorAll("[data-morph]")]},ot=function(t,i){return t.filter(r=>i.find(s=>s.outerHTML===r.outerHTML))},V=function(t,i){return t.filter(r=>!i.find(s=>s.outerHTML===r.outerHTML))},B=new WeakMap;exports.Morph=mt;
|