aptechka 0.37.2 → 0.37.3

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.
@@ -1,5 +1,5 @@
1
- "use strict";var X=r=>{throw TypeError(r)};var F=(r,s,t)=>s.has(r)||X("Cannot "+t);var e=(r,s,t)=>(F(r,s,"read from private field"),t?t.call(r):s.get(r)),i=(r,s,t)=>s.has(r)?X("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(r):s.set(r,t),a=(r,s,t,n)=>(F(r,s,"write to private field"),n?n.call(r,t):s.set(r,t),t),B=(r,s,t)=>(F(r,s,"access private method"),t);var Y=(r,s,t)=>new Promise((n,l)=>{var y=d=>{try{g(t.next(d))}catch(c){l(c)}},T=d=>{try{g(t.throw(d))}catch(c){l(c)}},g=d=>d.done?n(d.value):Promise.resolve(d.value).then(y,T);g((t=t.apply(r,s)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ie=require("../device/index.cjs"),re=require("../source/index.cjs"),ne=require("../class-linked-status/index.cjs"),Q=require("../browser-CpzFX2xg.cjs"),K=require("../events-KVanG9sR.cjs"),oe=require("../string-DhgS_iFl.cjs"),U=require("../loading/index.cjs"),H=require("../css-property/index.cjs"),G=require("../element-resizer/vanilla/index.cjs"),J=require("../canvas-CU5Xjahf.cjs"),ae=require("../canvas/index.cjs"),D=require("../ticker/vanilla/index.cjs");let ce=0;var u,o,p,q,m,z,C,h,I,P,O,W,_,V;class j extends HTMLElement{constructor(){super();i(this,P);i(this,u,null);i(this,o,null);i(this,p,!1);i(this,q,!1);i(this,m,!1);i(this,z,"");i(this,C,"");i(this,h,new ne.ClassLinkedStatus(this,{loading:!1,loaded:!1,error:!1}));i(this,I,null);i(this,W,t=>{const n=t[0];e(this,m)&&(!e(this,q)||this.hasAttribute("reload-source"))&&n.isIntersecting&&this.triggerLazyLoad(),n.isIntersecting?K.dispatchEvent(this,"sourceCapture",{custom:!0}):(this.hasAttribute("reload-source")&&B(this,P,O).call(this,void 0),K.dispatchEvent(this,"sourceRelease",{custom:!0}))});i(this,_,()=>{e(this,h).set("loaded",!0),e(this,h).set("error",!1),e(this,h).set("loading",!1),!e(this,m)&&!e(this,p)&&U.loading.complete(e(this,C)),a(this,p,!0)});i(this,V,t=>{e(this,h).set("loaded",!1),e(this,h).set("error",!0),e(this,h).set("loading",!1),!e(this,m)&&!e(this,p)&&U.loading.error(e(this,C)),a(this,p,!0)});Q.isBrowser&&window.IntersectionObserver&&(a(this,z,`source-consumer-${++ce}`),a(this,I,new IntersectionObserver(e(this,W))))}get consumerElement(){return e(this,o)}get sourceManager(){return e(this,u)}get status(){return e(this,h)}get isLazy(){return e(this,m)}triggerLazyLoad(){e(this,u).current&&e(this,u).current!==e(this,u).previous&&B(this,P,O).call(this,e(this,u).current),a(this,q,!0)}connectedCallback(){const t=this.getAttribute("srcset");t&&(a(this,o,this.createConsumer()),e(this,o).style.cssText=`
1
+ "use strict";var Y=r=>{throw TypeError(r)};var D=(r,i,t)=>i.has(r)||Y("Cannot "+t);var e=(r,i,t)=>(D(r,i,"read from private field"),t?t.call(r):i.get(r)),s=(r,i,t)=>i.has(r)?Y("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(r):i.set(r,t),a=(r,i,t,n)=>(D(r,i,"write to private field"),n?n.call(r,t):i.set(r,t),t),H=(r,i,t)=>(D(r,i,"access private method"),t);var G=(r,i,t)=>new Promise((n,l)=>{var S=d=>{try{b(t.next(d))}catch(h){l(h)}},$=d=>{try{b(t.throw(d))}catch(h){l(h)}},b=d=>d.done?n(d.value):Promise.resolve(d.value).then(S,$);b((t=t.apply(r,i)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("../device/index.cjs"),ne=require("../source/index.cjs"),ae=require("../class-linked-status/index.cjs"),Z=require("../browser-CpzFX2xg.cjs"),N=require("../events-KVanG9sR.cjs"),oe=require("../string-DhgS_iFl.cjs"),U=require("../loading/index.cjs"),O=require("../css-property/index.cjs"),J=require("../element-resizer/vanilla/index.cjs"),Q=require("../canvas-CU5Xjahf.cjs"),ce=require("../canvas/index.cjs"),K=require("../ticker/vanilla/index.cjs");let he=0;var u,o,p,I,m,_,C,c,q,P,R,V,W,T,F;class j extends HTMLElement{constructor(){super();s(this,R);s(this,u,null);s(this,o,null);s(this,p,!1);s(this,I,!1);s(this,m,!1);s(this,_,"");s(this,C,"");s(this,c,new ae.ClassLinkedStatus(this,{loading:!1,loaded:!1,error:!1,clear:!1}));s(this,q,null);s(this,P);s(this,W,t=>{const n=t[0];e(this,m)&&(!e(this,I)||this.hasAttribute("reload-source"))&&n.isIntersecting&&this.triggerLazyLoad(),n.isIntersecting?N.dispatchEvent(this,"sourceCapture",{custom:!0}):(this.hasAttribute("reload-source")&&H(this,R,V).call(this,void 0),N.dispatchEvent(this,"sourceRelease",{custom:!0}))});s(this,T,()=>{e(this,c).set("loaded",!0),e(this,c).set("error",!1),e(this,c).set("loading",!1),!e(this,m)&&!e(this,p)&&U.loading.complete(e(this,C));const t=getComputedStyle(this).getPropertyValue("--clear-duration");t&&a(this,P,setTimeout(()=>e(this,c).set("clear",!0),parseFloat(t)*1e3)),a(this,p,!0)});s(this,F,t=>{e(this,c).set("loaded",!1),e(this,c).set("error",!0),e(this,c).set("loading",!1),!e(this,m)&&!e(this,p)&&U.loading.error(e(this,C)),a(this,p,!0)});Z.isBrowser&&window.IntersectionObserver&&(a(this,_,`source-consumer-${++he}`),a(this,q,new IntersectionObserver(e(this,W))))}get consumerElement(){return e(this,o)}get sourceManager(){return e(this,u)}get status(){return e(this,c)}get isLazy(){return e(this,m)}triggerLazyLoad(){e(this,u).current&&e(this,u).current!==e(this,u).previous&&H(this,R,V).call(this,e(this,u).current),a(this,I,!0)}connectedCallback(){const t=this.getAttribute("srcset");t&&(a(this,o,this.createConsumer()),e(this,o).style.cssText=`
2
2
  display: block;
3
3
  width: 100%;
4
4
  height: 100%;
5
- `,e(this,o).classList.add("source-consumer"),Array.from(this.attributes).forEach(n=>{if(n.name!=="srcset"){const l=n.nodeValue||"",y=oe.kebabToCamel(n.name);y in e(this,o)&&(e(this,o)[y]=l||!0)}}),this.appendChild(e(this,o)),a(this,u,new re.SourceManager({srcset:t})),a(this,m,this.hasAttribute("lazy")),e(this,u).subscribe(n=>{(!e(this,m)||e(this,m)&&e(this,q))&&B(this,P,O).call(this,n.current)}),e(this,I).observe(this),e(this,u).connect())}disconnectedCallback(){e(this,I).disconnect(),e(this,u).close(),e(this,o).onloadeddata=null,e(this,o).onload=null,e(this,o).onerror=null,e(this,o).remove(),e(this,h).reset()}}u=new WeakMap,o=new WeakMap,p=new WeakMap,q=new WeakMap,m=new WeakMap,z=new WeakMap,C=new WeakMap,h=new WeakMap,I=new WeakMap,P=new WeakSet,O=function(t){if(e(this,o).onloadeddata=null,e(this,o).onload=null,e(this,o).onerror=null,e(this,h).set("loaded",!1),e(this,h).set("error",!1),e(this,h).set("loading",!1),t){a(this,C,`${e(this,z)}-${t.url}`);const n=this.hasAttribute("keep-source-parameters");e(this,h).set("loading",!0);const l=n?t.url:t.name+t.extension;this.consumeSource(l),!e(this,m)&&!e(this,p)&&U.loading.add(e(this,C)),e(this,o).onloadeddata=()=>{e(this,_).call(this)},e(this,o).onload=()=>{e(this,_).call(this)},e(this,o).onerror=()=>{e(this,V).call(this,l)}}else this.consumeSource(null)},W=new WeakMap,_=new WeakMap,V=new WeakMap;class Z extends j{createConsumer(){return document.createElement("img")}consumeSource(s){if(s&&this.hasAttribute("webp")&&ie.device.isWebp){const t=s.split(".").slice(0,-1).join(".")+".webp";this.consumerElement.src=t}else this.consumerElement.src=s||""}}customElements.get("e-image")||customElements.define("e-image",Z);function he(r){const s=r.match(/\{([\d-]+)\}/);if(s){const t=s[1].split("-");if(t.length===2){const n=parseInt(t[0],10),l=parseInt(t[1],10);return{start:n,end:l}}}return null}var f,w,R,E,v,L,k,M,b,S;class ee extends j{constructor(t){super();i(this,f,[]);i(this,w,new H.CSSProperty(this,"--fit","contain"));i(this,R,new H.CSSProperty(this,"--autoplay",!1));i(this,E,new H.CSSProperty(this,"--offset-x",.5));i(this,v,new H.CSSProperty(this,"--offset-y",.5));i(this,L,null);i(this,k,0);i(this,M,1);i(this,b,()=>{if(e(this,f).length){const t=e(this,f)[0];e(this,w).current==="cover"?a(this,L,J.cover(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,E).current,e(this,v).current)):a(this,L,J.contain(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,E).current,e(this,v).current))}});i(this,S,t=>{if(this.status.isFalse("loaded")||!e(this,L))return;t.detail.context.clearRect(0,0,t.detail.width,t.detail.height);const n=e(this,f)[e(this,k)];n&&t.detail.context.drawImage(n,...e(this,L)),e(this,R).current&&a(this,k,(e(this,k)+1)%e(this,f).length)});Q.isBrowser&&(a(this,M,parseInt(((t==null?void 0:t.pad)||this.getAttribute("pad")||"1").toString())),e(this,w).subscribe(e(this,b)),e(this,E).subscribe(e(this,b)),e(this,v).subscribe(e(this,b)),this.addEventListener("sourceCapture",n=>{this.consumerElement.addEventListener("canvasRender",e(this,S))}),this.addEventListener("sourceRelease",n=>{this.consumerElement.removeEventListener("canvasRender",e(this,S))}))}setProgress(t){e(this,f).length&&a(this,k,Math.floor((e(this,f).length-1)*t))}connectedCallback(){super.connectedCallback(),e(this,R).observe(),e(this,w).observe(),e(this,E).observe(),e(this,v).observe(),G.elementResizer.subscribe(this,e(this,b))}disconnectedCallback(){super.disconnectedCallback(),e(this,R).unobserve(),e(this,w).unobserve(),e(this,E).unobserve(),e(this,v).unobserve(),a(this,f,[]),G.elementResizer.unsubscribe(e(this,b)),this.consumerElement.removeEventListener("canvasRender",e(this,S))}createConsumer(){return new ae.CanvasElement}consumeSource(t){return Y(this,null,function*(){var n,l,y,T;if(t){this.consumerElement.removeEventListener("canvasRender",e(this,S));const g=[],d=he(t);if(d)for(let c=d.start;c<=d.end;c++){const N=t.replace(/\{([^}]+)\}/,c.toString().padStart(e(this,M),"0")),$=new Image;$.src=N,g.push($)}else{const c=new Image;c.src=t,g.push(c)}try{yield Promise.all(g.map((c,N)=>new Promise(($,se)=>{c.onload=()=>{$()},c.onerror=le=>{se(`${c.src} Image not found`)}}))),a(this,f,g),e(this,b).call(this),(l=(n=this.consumerElement).onload)==null||l.call(n,new Event("load")),this.isLazy||this.consumerElement.addEventListener("canvasRender",e(this,S))}catch(c){console.error(c),(T=(y=this.consumerElement).onerror)==null||T.call(y,new Event("error"))}}})}}f=new WeakMap,w=new WeakMap,R=new WeakMap,E=new WeakMap,v=new WeakMap,L=new WeakMap,k=new WeakMap,M=new WeakMap,b=new WeakMap,S=new WeakMap;customElements.get("e-sequence")||customElements.define("e-sequence",ee);var x,A;class te extends j{constructor(){super(...arguments);i(this,x,0);i(this,A,()=>{this.classList.add(`state-${this.consumerElement.readyState}`);const t=this.consumerElement.readyState/4;t>e(this,x)&&a(this,x,t),K.dispatchEvent(this,"videoReadyStateChange",{detail:{readyState:this.consumerElement.readyState,progress:e(this,x)}}),this.consumerElement.readyState===4&&D.ticker.unsubscribe(e(this,A))})}connectedCallback(){super.connectedCallback(),this.addEventListener("sourceCapture",()=>{D.ticker.subscribe(e(this,A)),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(),D.ticker.unsubscribe(e(this,A)),a(this,x,0)}createConsumer(){return document.createElement("video")}consumeSource(t){this.consumerElement.src=t||"",this.consumerElement.autoplay=!0}}x=new WeakMap,A=new WeakMap;customElements.get("e-video")||customElements.define("e-video",te);exports.ImageElement=Z;exports.SequenceElement=ee;exports.SourceElement=j;exports.VideoElement=te;
5
+ `,e(this,o).classList.add("source-consumer"),Array.from(this.attributes).forEach(n=>{if(n.name!=="srcset"){const l=n.nodeValue||"",S=oe.kebabToCamel(n.name);S in e(this,o)&&(e(this,o)[S]=l||!0)}}),this.appendChild(e(this,o)),a(this,u,new ne.SourceManager({srcset:t})),a(this,m,this.hasAttribute("lazy")),e(this,u).subscribe(n=>{(!e(this,m)||e(this,m)&&e(this,I))&&H(this,R,V).call(this,n.current)}),e(this,q).observe(this),e(this,u).connect())}disconnectedCallback(){e(this,q).disconnect(),e(this,u).close(),e(this,o).onloadeddata=null,e(this,o).onload=null,e(this,o).onerror=null,e(this,o).remove(),e(this,c).reset(),clearTimeout(e(this,P))}}u=new WeakMap,o=new WeakMap,p=new WeakMap,I=new WeakMap,m=new WeakMap,_=new WeakMap,C=new WeakMap,c=new WeakMap,q=new WeakMap,P=new WeakMap,R=new WeakSet,V=function(t){if(clearTimeout(e(this,P)),e(this,o).onloadeddata=null,e(this,o).onload=null,e(this,o).onerror=null,e(this,c).set("loaded",!1),e(this,c).set("error",!1),e(this,c).set("loading",!1),e(this,c).set("clear",!1),t){a(this,C,`${e(this,_)}-${t.url}`);const n=this.hasAttribute("keep-source-parameters");e(this,c).set("loading",!0);const l=n?t.url:t.name+t.extension;this.consumeSource(l),!e(this,m)&&!e(this,p)&&U.loading.add(e(this,C)),e(this,o).onloadeddata=()=>{e(this,T).call(this)},e(this,o).onload=()=>{e(this,T).call(this)},e(this,o).onerror=()=>{e(this,F).call(this,l)}}else this.consumeSource(null)},W=new WeakMap,T=new WeakMap,F=new WeakMap;class ee extends j{createConsumer(){return document.createElement("img")}consumeSource(i){if(i&&this.hasAttribute("webp")&&re.device.isWebp){const t=i.split(".").slice(0,-1).join(".")+".webp";this.consumerElement.src=t}else this.consumerElement.src=i||""}}customElements.get("e-image")||customElements.define("e-image",ee);function le(r){const i=r.match(/\{([\d-]+)\}/);if(i){const t=i[1].split("-");if(t.length===2){const n=parseInt(t[0],10),l=parseInt(t[1],10);return{start:n,end:l}}}return null}var f,w,A,E,v,L,k,M,g,y;class te extends j{constructor(t){super();s(this,f,[]);s(this,w,new O.CSSProperty(this,"--fit","contain"));s(this,A,new O.CSSProperty(this,"--autoplay",!1));s(this,E,new O.CSSProperty(this,"--offset-x",.5));s(this,v,new O.CSSProperty(this,"--offset-y",.5));s(this,L,null);s(this,k,0);s(this,M,1);s(this,g,()=>{if(e(this,f).length){const t=e(this,f)[0];e(this,w).current==="cover"?a(this,L,Q.cover(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,E).current,e(this,v).current)):a(this,L,Q.contain(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,E).current,e(this,v).current))}});s(this,y,t=>{if(this.status.isFalse("loaded")||!e(this,L))return;t.detail.context.clearRect(0,0,t.detail.width,t.detail.height);const n=e(this,f)[e(this,k)];n&&t.detail.context.drawImage(n,...e(this,L)),e(this,A).current&&a(this,k,(e(this,k)+1)%e(this,f).length)});Z.isBrowser&&(a(this,M,parseInt(((t==null?void 0:t.pad)||this.getAttribute("pad")||"1").toString())),e(this,w).subscribe(e(this,g)),e(this,E).subscribe(e(this,g)),e(this,v).subscribe(e(this,g)),this.addEventListener("sourceCapture",n=>{this.consumerElement.addEventListener("canvasRender",e(this,y))}),this.addEventListener("sourceRelease",n=>{this.consumerElement.removeEventListener("canvasRender",e(this,y))}))}setProgress(t){e(this,f).length&&a(this,k,Math.floor((e(this,f).length-1)*t))}connectedCallback(){super.connectedCallback(),e(this,A).observe(),e(this,w).observe(),e(this,E).observe(),e(this,v).observe(),J.elementResizer.subscribe(this,e(this,g))}disconnectedCallback(){super.disconnectedCallback(),e(this,A).unobserve(),e(this,w).unobserve(),e(this,E).unobserve(),e(this,v).unobserve(),a(this,f,[]),J.elementResizer.unsubscribe(e(this,g)),this.consumerElement.removeEventListener("canvasRender",e(this,y))}createConsumer(){return new ce.CanvasElement}consumeSource(t){return G(this,null,function*(){var n,l,S,$;if(t){this.consumerElement.removeEventListener("canvasRender",e(this,y));const b=[],d=le(t);if(d)for(let h=d.start;h<=d.end;h++){const X=t.replace(/\{([^}]+)\}/,h.toString().padStart(e(this,M),"0")),B=new Image;B.src=X,b.push(B)}else{const h=new Image;h.src=t,b.push(h)}try{yield Promise.all(b.map((h,X)=>new Promise((B,ie)=>{h.onload=()=>{B()},h.onerror=ue=>{ie(`${h.src} Image not found`)}}))),a(this,f,b),e(this,g).call(this),(l=(n=this.consumerElement).onload)==null||l.call(n,new Event("load")),this.isLazy||this.consumerElement.addEventListener("canvasRender",e(this,y))}catch(h){console.error(h),($=(S=this.consumerElement).onerror)==null||$.call(S,new Event("error"))}}})}}f=new WeakMap,w=new WeakMap,A=new WeakMap,E=new WeakMap,v=new WeakMap,L=new WeakMap,k=new WeakMap,M=new WeakMap,g=new WeakMap,y=new WeakMap;customElements.get("e-sequence")||customElements.define("e-sequence",te);var x,z;class se extends j{constructor(){super(...arguments);s(this,x,0);s(this,z,()=>{this.classList.add(`state-${this.consumerElement.readyState}`);const t=this.consumerElement.readyState/4;t>e(this,x)&&a(this,x,t),N.dispatchEvent(this,"videoReadyStateChange",{detail:{readyState:this.consumerElement.readyState,progress:e(this,x)}}),this.consumerElement.readyState===4&&K.ticker.unsubscribe(e(this,z))})}connectedCallback(){super.connectedCallback(),this.addEventListener("sourceCapture",()=>{K.ticker.subscribe(e(this,z)),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(),K.ticker.unsubscribe(e(this,z)),a(this,x,0)}createConsumer(){return document.createElement("video")}consumeSource(t){this.consumerElement.src=t||"",this.consumerElement.autoplay=!0}}x=new WeakMap,z=new WeakMap;customElements.get("e-video")||customElements.define("e-video",se);exports.ImageElement=ee;exports.SequenceElement=te;exports.SourceElement=j;exports.VideoElement=se;
@@ -1,138 +1,145 @@
1
- var Y = (r) => {
1
+ var G = (r) => {
2
2
  throw TypeError(r);
3
3
  };
4
- var V = (r, s, t) => s.has(r) || Y("Cannot " + t);
5
- var e = (r, s, t) => (V(r, s, "read from private field"), t ? t.call(r) : s.get(r)), i = (r, s, t) => s.has(r) ? Y("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(r) : s.set(r, t), a = (r, s, t, n) => (V(r, s, "write to private field"), n ? n.call(r, t) : s.set(r, t), t), q = (r, s, t) => (V(r, s, "access private method"), t);
6
- var G = (r, s, t) => new Promise((n, l) => {
4
+ var U = (r, i, t) => i.has(r) || G("Cannot " + t);
5
+ var e = (r, i, t) => (U(r, i, "read from private field"), t ? t.call(r) : i.get(r)), s = (r, i, t) => i.has(r) ? G("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(r) : i.set(r, t), o = (r, i, t, n) => (U(r, i, "write to private field"), n ? n.call(r, t) : i.set(r, t), t), B = (r, i, t) => (U(r, i, "access private method"), t);
6
+ var J = (r, i, t) => new Promise((n, l) => {
7
7
  var S = (m) => {
8
8
  try {
9
9
  b(t.next(m));
10
- } catch (h) {
11
- l(h);
10
+ } catch (c) {
11
+ l(c);
12
12
  }
13
- }, T = (m) => {
13
+ }, W = (m) => {
14
14
  try {
15
15
  b(t.throw(m));
16
- } catch (h) {
17
- l(h);
16
+ } catch (c) {
17
+ l(c);
18
18
  }
19
- }, b = (m) => m.done ? n(m.value) : Promise.resolve(m.value).then(S, T);
20
- b((t = t.apply(r, s)).next());
19
+ }, b = (m) => m.done ? n(m.value) : Promise.resolve(m.value).then(S, W);
20
+ b((t = t.apply(r, i)).next());
21
21
  });
22
- import { device as _ } from "../device/index.js";
23
- import { SourceManager as ee } from "../source/index.js";
24
- import { ClassLinkedStatus as te } from "../class-linked-status/index.js";
25
- import { i as Q } from "../browser-0zX67oeU.js";
26
- import { d as K } from "../events-CsVF98U6.js";
27
- import { k as se } from "../string-f0Dnk0L1.js";
22
+ import { device as ee } from "../device/index.js";
23
+ import { SourceManager as te } from "../source/index.js";
24
+ import { ClassLinkedStatus as se } from "../class-linked-status/index.js";
25
+ import { i as Z } from "../browser-0zX67oeU.js";
26
+ import { d as N } from "../events-CsVF98U6.js";
27
+ import { k as ie } from "../string-f0Dnk0L1.js";
28
28
  import { loading as j } from "../loading/index.js";
29
- import { CSSProperty as B } from "../css-property/index.js";
30
- import { elementResizer as J } from "../element-resizer/vanilla/index.js";
31
- import { c as ie, a as re } from "../canvas-DeZ0SLUJ.js";
32
- import { CanvasElement as ne } from "../canvas/index.js";
33
- import { ticker as D } from "../ticker/vanilla/index.js";
34
- let oe = 0;
35
- var u, o, g, x, d, M, C, c, A, R, O, F, $, U;
36
- class N extends HTMLElement {
29
+ import { CSSProperty as F } from "../css-property/index.js";
30
+ import { elementResizer as Q } from "../element-resizer/vanilla/index.js";
31
+ import { c as re, a as ne } from "../canvas-DeZ0SLUJ.js";
32
+ import { CanvasElement as oe } from "../canvas/index.js";
33
+ import { ticker as K } from "../ticker/vanilla/index.js";
34
+ let ae = 0;
35
+ var u, a, g, x, d, M, C, h, A, R, P, O, V, $, D;
36
+ class X extends HTMLElement {
37
37
  constructor() {
38
38
  super();
39
- i(this, R);
40
- i(this, u, null);
41
- i(this, o, null);
42
- i(this, g, !1);
43
- i(this, x, !1);
44
- i(this, d, !1);
45
- i(this, M, "");
46
- i(this, C, "");
47
- i(this, c, new te(this, {
39
+ s(this, P);
40
+ s(this, u, null);
41
+ s(this, a, null);
42
+ s(this, g, !1);
43
+ s(this, x, !1);
44
+ s(this, d, !1);
45
+ s(this, M, "");
46
+ s(this, C, "");
47
+ s(this, h, new se(this, {
48
48
  loading: !1,
49
49
  loaded: !1,
50
- error: !1
50
+ error: !1,
51
+ clear: !1
51
52
  }));
52
- i(this, A, null);
53
- i(this, F, (t) => {
53
+ s(this, A, null);
54
+ s(this, R);
55
+ s(this, V, (t) => {
54
56
  const n = t[0];
55
- e(this, d) && (!e(this, x) || this.hasAttribute("reload-source")) && n.isIntersecting && this.triggerLazyLoad(), n.isIntersecting ? K(this, "sourceCapture", { custom: !0 }) : (this.hasAttribute("reload-source") && q(this, R, O).call(this, void 0), K(this, "sourceRelease", { custom: !0 }));
57
+ e(this, d) && (!e(this, x) || this.hasAttribute("reload-source")) && n.isIntersecting && this.triggerLazyLoad(), n.isIntersecting ? N(this, "sourceCapture", { custom: !0 }) : (this.hasAttribute("reload-source") && B(this, P, O).call(this, void 0), N(this, "sourceRelease", { custom: !0 }));
56
58
  });
57
- i(this, $, () => {
58
- e(this, c).set("loaded", !0), e(this, c).set("error", !1), e(this, c).set("loading", !1), !e(this, d) && !e(this, g) && j.complete(e(this, C)), a(this, g, !0);
59
+ s(this, $, () => {
60
+ e(this, h).set("loaded", !0), e(this, h).set("error", !1), e(this, h).set("loading", !1), !e(this, d) && !e(this, g) && j.complete(e(this, C));
61
+ const t = getComputedStyle(this).getPropertyValue("--clear-duration");
62
+ t && o(this, R, setTimeout(
63
+ () => e(this, h).set("clear", !0),
64
+ parseFloat(t) * 1e3
65
+ )), o(this, g, !0);
59
66
  });
60
- i(this, U, (t) => {
61
- e(this, c).set("loaded", !1), e(this, c).set("error", !0), e(this, c).set("loading", !1), !e(this, d) && !e(this, g) && j.error(e(this, C)), a(this, g, !0);
67
+ s(this, D, (t) => {
68
+ e(this, h).set("loaded", !1), e(this, h).set("error", !0), e(this, h).set("loading", !1), !e(this, d) && !e(this, g) && j.error(e(this, C)), o(this, g, !0);
62
69
  });
63
- Q && window.IntersectionObserver && (a(this, M, `source-consumer-${++oe}`), a(this, A, new IntersectionObserver(
64
- e(this, F)
70
+ Z && window.IntersectionObserver && (o(this, M, `source-consumer-${++ae}`), o(this, A, new IntersectionObserver(
71
+ e(this, V)
65
72
  )));
66
73
  }
67
74
  get consumerElement() {
68
- return e(this, o);
75
+ return e(this, a);
69
76
  }
70
77
  get sourceManager() {
71
78
  return e(this, u);
72
79
  }
73
80
  get status() {
74
- return e(this, c);
81
+ return e(this, h);
75
82
  }
76
83
  get isLazy() {
77
84
  return e(this, d);
78
85
  }
79
86
  triggerLazyLoad() {
80
- e(this, u).current && e(this, u).current !== e(this, u).previous && q(this, R, O).call(this, e(this, u).current), a(this, x, !0);
87
+ e(this, u).current && e(this, u).current !== e(this, u).previous && B(this, P, O).call(this, e(this, u).current), o(this, x, !0);
81
88
  }
82
89
  connectedCallback() {
83
90
  const t = this.getAttribute("srcset");
84
- t && (a(this, o, this.createConsumer()), e(this, o).style.cssText = `
91
+ t && (o(this, a, this.createConsumer()), e(this, a).style.cssText = `
85
92
  display: block;
86
93
  width: 100%;
87
94
  height: 100%;
88
- `, e(this, o).classList.add("source-consumer"), Array.from(this.attributes).forEach((n) => {
95
+ `, e(this, a).classList.add("source-consumer"), Array.from(this.attributes).forEach((n) => {
89
96
  if (n.name !== "srcset") {
90
- const l = n.nodeValue || "", S = se(n.name);
91
- S in e(this, o) && (e(this, o)[S] = l || !0);
97
+ const l = n.nodeValue || "", S = ie(n.name);
98
+ S in e(this, a) && (e(this, a)[S] = l || !0);
92
99
  }
93
- }), this.appendChild(e(this, o)), a(this, u, new ee({
100
+ }), this.appendChild(e(this, a)), o(this, u, new te({
94
101
  srcset: t
95
- })), a(this, d, this.hasAttribute("lazy")), e(this, u).subscribe((n) => {
96
- (!e(this, d) || e(this, d) && e(this, x)) && q(this, R, O).call(this, n.current);
102
+ })), o(this, d, this.hasAttribute("lazy")), e(this, u).subscribe((n) => {
103
+ (!e(this, d) || e(this, d) && e(this, x)) && B(this, P, O).call(this, n.current);
97
104
  }), e(this, A).observe(this), e(this, u).connect());
98
105
  }
99
106
  disconnectedCallback() {
100
- e(this, A).disconnect(), e(this, u).close(), e(this, o).onloadeddata = null, e(this, o).onload = null, e(this, o).onerror = null, e(this, o).remove(), e(this, c).reset();
107
+ e(this, A).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, h).reset(), clearTimeout(e(this, R));
101
108
  }
102
109
  }
103
- u = new WeakMap(), o = new WeakMap(), g = new WeakMap(), x = new WeakMap(), d = new WeakMap(), M = new WeakMap(), C = new WeakMap(), c = new WeakMap(), A = new WeakMap(), R = new WeakSet(), O = function(t) {
104
- if (e(this, o).onloadeddata = null, e(this, o).onload = null, e(this, o).onerror = null, e(this, c).set("loaded", !1), e(this, c).set("error", !1), e(this, c).set("loading", !1), t) {
105
- a(this, C, `${e(this, M)}-${t.url}`);
110
+ u = new WeakMap(), a = new WeakMap(), g = new WeakMap(), x = new WeakMap(), d = new WeakMap(), M = new WeakMap(), C = new WeakMap(), h = new WeakMap(), A = new WeakMap(), R = new WeakMap(), P = new WeakSet(), O = function(t) {
111
+ if (clearTimeout(e(this, R)), e(this, a).onloadeddata = null, e(this, a).onload = null, e(this, a).onerror = null, e(this, h).set("loaded", !1), e(this, h).set("error", !1), e(this, h).set("loading", !1), e(this, h).set("clear", !1), t) {
112
+ o(this, C, `${e(this, M)}-${t.url}`);
106
113
  const n = this.hasAttribute("keep-source-parameters");
107
- e(this, c).set("loading", !0);
114
+ e(this, h).set("loading", !0);
108
115
  const l = n ? t.url : t.name + t.extension;
109
- this.consumeSource(l), !e(this, d) && !e(this, g) && j.add(e(this, C)), e(this, o).onloadeddata = () => {
116
+ this.consumeSource(l), !e(this, d) && !e(this, g) && j.add(e(this, C)), e(this, a).onloadeddata = () => {
110
117
  e(this, $).call(this);
111
- }, e(this, o).onload = () => {
118
+ }, e(this, a).onload = () => {
112
119
  e(this, $).call(this);
113
- }, e(this, o).onerror = () => {
114
- e(this, U).call(this, l);
120
+ }, e(this, a).onerror = () => {
121
+ e(this, D).call(this, l);
115
122
  };
116
123
  } else
117
124
  this.consumeSource(null);
118
- }, F = new WeakMap(), $ = new WeakMap(), U = new WeakMap();
119
- class ae extends N {
125
+ }, V = new WeakMap(), $ = new WeakMap(), D = new WeakMap();
126
+ class he extends X {
120
127
  createConsumer() {
121
128
  return document.createElement("img");
122
129
  }
123
- consumeSource(s) {
124
- if (s && this.hasAttribute("webp") && _.isWebp) {
125
- const t = s.split(".").slice(0, -1).join(".") + ".webp";
130
+ consumeSource(i) {
131
+ if (i && this.hasAttribute("webp") && ee.isWebp) {
132
+ const t = i.split(".").slice(0, -1).join(".") + ".webp";
126
133
  this.consumerElement.src = t;
127
134
  } else
128
- this.consumerElement.src = s || "";
135
+ this.consumerElement.src = i || "";
129
136
  }
130
137
  }
131
- customElements.get("e-image") || customElements.define("e-image", ae);
132
- function he(r) {
133
- const s = r.match(/\{([\d-]+)\}/);
134
- if (s) {
135
- const t = s[1].split("-");
138
+ customElements.get("e-image") || customElements.define("e-image", he);
139
+ function ce(r) {
140
+ const i = r.match(/\{([\d-]+)\}/);
141
+ if (i) {
142
+ const t = i[1].split("-");
136
143
  if (t.length === 2) {
137
144
  const n = parseInt(t[0], 10), l = parseInt(t[1], 10);
138
145
  return { start: n, end: l };
@@ -140,33 +147,33 @@ function he(r) {
140
147
  }
141
148
  return null;
142
149
  }
143
- var f, w, P, E, v, L, k, H, p, y;
144
- class ce extends N {
150
+ var f, w, z, E, v, L, k, H, p, y;
151
+ class le extends X {
145
152
  constructor(t) {
146
153
  super();
147
- i(this, f, []);
148
- i(this, w, new B(
154
+ s(this, f, []);
155
+ s(this, w, new F(
149
156
  this,
150
157
  "--fit",
151
158
  "contain"
152
159
  ));
153
- i(this, P, new B(this, "--autoplay", !1));
154
- i(this, E, new B(this, "--offset-x", 0.5));
155
- i(this, v, new B(this, "--offset-y", 0.5));
156
- i(this, L, null);
157
- i(this, k, 0);
158
- i(this, H, 1);
159
- i(this, p, () => {
160
+ s(this, z, new F(this, "--autoplay", !1));
161
+ s(this, E, new F(this, "--offset-x", 0.5));
162
+ s(this, v, new F(this, "--offset-y", 0.5));
163
+ s(this, L, null);
164
+ s(this, k, 0);
165
+ s(this, H, 1);
166
+ s(this, p, () => {
160
167
  if (e(this, f).length) {
161
168
  const t = e(this, f)[0];
162
- e(this, w).current === "cover" ? a(this, L, ie(
169
+ e(this, w).current === "cover" ? o(this, L, re(
163
170
  t.naturalWidth,
164
171
  t.naturalHeight,
165
172
  this.consumerElement.width,
166
173
  this.consumerElement.height,
167
174
  e(this, E).current,
168
175
  e(this, v).current
169
- )) : a(this, L, re(
176
+ )) : o(this, L, ne(
170
177
  t.naturalWidth,
171
178
  t.naturalHeight,
172
179
  this.consumerElement.width,
@@ -176,14 +183,14 @@ class ce extends N {
176
183
  ));
177
184
  }
178
185
  });
179
- i(this, y, (t) => {
186
+ s(this, y, (t) => {
180
187
  if (this.status.isFalse("loaded") || !e(this, L))
181
188
  return;
182
189
  t.detail.context.clearRect(0, 0, t.detail.width, t.detail.height);
183
190
  const n = e(this, f)[e(this, k)];
184
- n && t.detail.context.drawImage(n, ...e(this, L)), e(this, P).current && a(this, k, (e(this, k) + 1) % e(this, f).length);
191
+ n && t.detail.context.drawImage(n, ...e(this, L)), e(this, z).current && o(this, k, (e(this, k) + 1) % e(this, f).length);
185
192
  });
186
- Q && (a(this, H, parseInt(
193
+ Z && (o(this, H, parseInt(
187
194
  ((t == null ? void 0 : t.pad) || this.getAttribute("pad") || "1").toString()
188
195
  )), e(this, w).subscribe(e(this, p)), e(this, E).subscribe(e(this, p)), e(this, v).subscribe(e(this, p)), this.addEventListener("sourceCapture", (n) => {
189
196
  this.consumerElement.addEventListener(
@@ -198,82 +205,82 @@ class ce extends N {
198
205
  }));
199
206
  }
200
207
  setProgress(t) {
201
- e(this, f).length && a(this, k, Math.floor((e(this, f).length - 1) * t));
208
+ e(this, f).length && o(this, k, Math.floor((e(this, f).length - 1) * t));
202
209
  }
203
210
  connectedCallback() {
204
- super.connectedCallback(), e(this, P).observe(), e(this, w).observe(), e(this, E).observe(), e(this, v).observe(), J.subscribe(this, e(this, p));
211
+ super.connectedCallback(), e(this, z).observe(), e(this, w).observe(), e(this, E).observe(), e(this, v).observe(), Q.subscribe(this, e(this, p));
205
212
  }
206
213
  disconnectedCallback() {
207
- super.disconnectedCallback(), e(this, P).unobserve(), e(this, w).unobserve(), e(this, E).unobserve(), e(this, v).unobserve(), a(this, f, []), J.unsubscribe(e(this, p)), this.consumerElement.removeEventListener(
214
+ super.disconnectedCallback(), e(this, z).unobserve(), e(this, w).unobserve(), e(this, E).unobserve(), e(this, v).unobserve(), o(this, f, []), Q.unsubscribe(e(this, p)), this.consumerElement.removeEventListener(
208
215
  "canvasRender",
209
216
  e(this, y)
210
217
  );
211
218
  }
212
219
  createConsumer() {
213
- return new ne();
220
+ return new oe();
214
221
  }
215
222
  consumeSource(t) {
216
- return G(this, null, function* () {
217
- var n, l, S, T;
223
+ return J(this, null, function* () {
224
+ var n, l, S, W;
218
225
  if (t) {
219
226
  this.consumerElement.removeEventListener(
220
227
  "canvasRender",
221
228
  e(this, y)
222
229
  );
223
- const b = [], m = he(t);
230
+ const b = [], m = ce(t);
224
231
  if (m)
225
- for (let h = m.start; h <= m.end; h++) {
226
- const X = t.replace(
232
+ for (let c = m.start; c <= m.end; c++) {
233
+ const Y = t.replace(
227
234
  /\{([^}]+)\}/,
228
- h.toString().padStart(e(this, H), "0")
229
- ), W = new Image();
230
- W.src = X, b.push(W);
235
+ c.toString().padStart(e(this, H), "0")
236
+ ), q = new Image();
237
+ q.src = Y, b.push(q);
231
238
  }
232
239
  else {
233
- const h = new Image();
234
- h.src = t, b.push(h);
240
+ const c = new Image();
241
+ c.src = t, b.push(c);
235
242
  }
236
243
  try {
237
244
  yield Promise.all(
238
- b.map((h, X) => new Promise((W, Z) => {
239
- h.onload = () => {
240
- W();
241
- }, h.onerror = (ue) => {
242
- Z(`${h.src} Image not found`);
245
+ b.map((c, Y) => new Promise((q, _) => {
246
+ c.onload = () => {
247
+ q();
248
+ }, c.onerror = (me) => {
249
+ _(`${c.src} Image not found`);
243
250
  };
244
251
  }))
245
- ), a(this, f, b), e(this, p).call(this), (l = (n = this.consumerElement).onload) == null || l.call(n, new Event("load")), this.isLazy || this.consumerElement.addEventListener(
252
+ ), o(this, f, b), e(this, p).call(this), (l = (n = this.consumerElement).onload) == null || l.call(n, new Event("load")), this.isLazy || this.consumerElement.addEventListener(
246
253
  "canvasRender",
247
254
  e(this, y)
248
255
  );
249
- } catch (h) {
250
- console.error(h), (T = (S = this.consumerElement).onerror) == null || T.call(S, new Event("error"));
256
+ } catch (c) {
257
+ console.error(c), (W = (S = this.consumerElement).onerror) == null || W.call(S, new Event("error"));
251
258
  }
252
259
  }
253
260
  });
254
261
  }
255
262
  }
256
- f = new WeakMap(), w = new WeakMap(), P = new WeakMap(), E = new WeakMap(), v = new WeakMap(), L = new WeakMap(), k = new WeakMap(), H = new WeakMap(), p = new WeakMap(), y = new WeakMap();
257
- customElements.get("e-sequence") || customElements.define("e-sequence", ce);
258
- var I, z;
259
- class le extends N {
263
+ f = new WeakMap(), w = new WeakMap(), z = new WeakMap(), E = new WeakMap(), v = new WeakMap(), L = new WeakMap(), k = new WeakMap(), H = new WeakMap(), p = new WeakMap(), y = new WeakMap();
264
+ customElements.get("e-sequence") || customElements.define("e-sequence", le);
265
+ var I, T;
266
+ class ue extends X {
260
267
  constructor() {
261
268
  super(...arguments);
262
- i(this, I, 0);
263
- i(this, z, () => {
269
+ s(this, I, 0);
270
+ s(this, T, () => {
264
271
  this.classList.add(`state-${this.consumerElement.readyState}`);
265
272
  const t = this.consumerElement.readyState / 4;
266
- t > e(this, I) && a(this, I, t), K(this, "videoReadyStateChange", {
273
+ t > e(this, I) && o(this, I, t), N(this, "videoReadyStateChange", {
267
274
  detail: {
268
275
  readyState: this.consumerElement.readyState,
269
276
  progress: e(this, I)
270
277
  }
271
- }), this.consumerElement.readyState === 4 && D.unsubscribe(e(this, z));
278
+ }), this.consumerElement.readyState === 4 && K.unsubscribe(e(this, T));
272
279
  });
273
280
  }
274
281
  connectedCallback() {
275
282
  super.connectedCallback(), this.addEventListener("sourceCapture", () => {
276
- D.subscribe(e(this, z)), this.hasAttribute("capture-autoplay") && this.consumerElement.play();
283
+ K.subscribe(e(this, T)), this.hasAttribute("capture-autoplay") && this.consumerElement.play();
277
284
  }), this.addEventListener("sourceRelease", () => {
278
285
  this.hasAttribute("capture-autoplay") && (this.consumerElement.pause(), this.hasAttribute("replay") && (this.consumerElement.currentTime = 0)), this.hasAttribute("reload-source") && this.classList.remove(
279
286
  "state-0",
@@ -285,7 +292,7 @@ class le extends N {
285
292
  });
286
293
  }
287
294
  disconnectedCallback() {
288
- super.disconnectedCallback(), D.unsubscribe(e(this, z)), a(this, I, 0);
295
+ super.disconnectedCallback(), K.unsubscribe(e(this, T)), o(this, I, 0);
289
296
  }
290
297
  createConsumer() {
291
298
  return document.createElement("video");
@@ -294,11 +301,11 @@ class le extends N {
294
301
  this.consumerElement.src = t || "", this.consumerElement.autoplay = !0;
295
302
  }
296
303
  }
297
- I = new WeakMap(), z = new WeakMap();
298
- customElements.get("e-video") || customElements.define("e-video", le);
304
+ I = new WeakMap(), T = new WeakMap();
305
+ customElements.get("e-video") || customElements.define("e-video", ue);
299
306
  export {
300
- ae as ImageElement,
301
- ce as SequenceElement,
302
- N as SourceElement,
303
- le as VideoElement
307
+ he as ImageElement,
308
+ le as SequenceElement,
309
+ X as SourceElement,
310
+ ue as VideoElement
304
311
  };
@@ -14,6 +14,7 @@ export declare abstract class SourceElement<T extends HTMLElement> extends HTMLE
14
14
  loading: false;
15
15
  loaded: false;
16
16
  error: false;
17
+ clear: false;
17
18
  }>;
18
19
  get isLazy(): boolean;
19
20
  triggerLazyLoad(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.37.2",
3
+ "version": "0.37.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"