aptechka 0.37.2 → 0.38.0
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/media-elements/index.cjs +2 -2
- package/lib/media-elements/index.d.ts +1 -0
- package/lib/media-elements/index.js +233 -157
- package/lib/media-elements/source/index.d.ts +2 -0
- package/lib/media-elements/youtube/index.d.ts +23 -0
- package/lib/source/index.cjs +1 -1
- package/lib/source/index.js +58 -57
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var oe=a=>{throw TypeError(a)};var se=(a,r,t)=>r.has(a)||oe("Cannot "+t);var e=(a,r,t)=>(se(a,r,"read from private field"),t?t.call(a):r.get(a)),s=(a,r,t)=>r.has(a)?oe("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(a):r.set(a,t),n=(a,r,t,i)=>(se(a,r,"write to private field"),i?i.call(a,t):r.set(a,t),t),x=(a,r,t)=>(se(a,r,"access private method"),t);var he=(a,r,t)=>new Promise((i,c)=>{var b=m=>{try{g(t.next(m))}catch(l){c(l)}},N=m=>{try{g(t.throw(m))}catch(l){c(l)}},g=m=>m.done?i(m.value):Promise.resolve(m.value).then(b,N);g((t=t.apply(a,r)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ye=require("../device/index.cjs"),ge=require("../source/index.cjs"),Ee=require("../class-linked-status/index.cjs"),le=require("../browser-CpzFX2xg.cjs"),X=require("../events-KVanG9sR.cjs"),de=require("../string-DhgS_iFl.cjs"),ie=require("../loading/index.cjs"),D=require("../css-property/index.cjs"),ce=require("../element-resizer/vanilla/index.cjs"),ue=require("../canvas-CU5Xjahf.cjs"),ve=require("../canvas/index.cjs"),re=require("../ticker/vanilla/index.cjs");let Se=0;var d,o,E,_,f,$,C,u,q,V,v,z,K,J,H,Q;class F extends HTMLElement{constructor(){super();s(this,z);s(this,d,null);s(this,o,null);s(this,E,!1);s(this,_,!1);s(this,f,!1);s(this,$,"");s(this,C,"");s(this,u,new Ee.ClassLinkedStatus(this,{loading:!1,loaded:!1,error:!1,clear:!1}));s(this,q,null);s(this,V);s(this,v,null);s(this,J,t=>{const i=t[0];e(this,f)&&(!e(this,_)||this.hasAttribute("reload-source"))&&i.isIntersecting&&this.triggerLazyLoad(),i.isIntersecting?X.dispatchEvent(this,"sourceCapture",{custom:!0}):(this.hasAttribute("reload-source")&&x(this,z,K).call(this,void 0),X.dispatchEvent(this,"sourceRelease",{custom:!0}))});s(this,H,()=>{e(this,u).set("loaded",!0),e(this,u).set("error",!1),e(this,u).set("loading",!1),!e(this,f)&&!e(this,E)&&ie.loading.complete(e(this,C));const t=getComputedStyle(this).getPropertyValue("--clear-duration");t&&n(this,V,setTimeout(()=>{e(this,u).set("clear",!0)},parseFloat(t)*1e3)),n(this,E,!0)});s(this,Q,t=>{e(this,u).set("loaded",!1),e(this,u).set("error",!0),e(this,u).set("loading",!1),!e(this,f)&&!e(this,E)&&ie.loading.error(e(this,C)),n(this,E,!0)});le.isBrowser&&window.IntersectionObserver&&(n(this,$,`source-consumer-${++Se}`),n(this,q,new IntersectionObserver(e(this,J))))}get consumerElement(){return e(this,o)}get sourceManager(){return e(this,d)}get status(){return e(this,u)}get isLazy(){return e(this,f)}get currentURL(){return e(this,v)}triggerLazyLoad(){e(this,d).current&&e(this,d).current!==e(this,d).previous&&x(this,z,K).call(this,e(this,d).current),n(this,_,!0)}connectedCallback(){const t=this.getAttribute("srcset");t&&(n(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(
|
|
5
|
+
`,e(this,o).classList.add("source-consumer"),Array.from(this.attributes).forEach(i=>{if(i.name!=="srcset"){const c=i.nodeValue||"",b=de.kebabToCamel(i.name);b in e(this,o)&&(e(this,o)[b]=c||!0)}}),this.appendChild(e(this,o)),n(this,d,new ge.SourceManager({srcset:t})),n(this,f,this.hasAttribute("lazy")),e(this,d).subscribe(i=>{(!e(this,f)||e(this,f)&&e(this,_))&&x(this,z,K).call(this,i.current)}),e(this,q).observe(this),e(this,d).connect())}disconnectedCallback(){e(this,q).disconnect(),e(this,d).close(),e(this,o).onloadeddata=null,e(this,o).onload=null,e(this,o).onerror=null,e(this,o).remove(),e(this,u).reset(),clearTimeout(e(this,V))}}d=new WeakMap,o=new WeakMap,E=new WeakMap,_=new WeakMap,f=new WeakMap,$=new WeakMap,C=new WeakMap,u=new WeakMap,q=new WeakMap,V=new WeakMap,v=new WeakMap,z=new WeakSet,K=function(t){if(clearTimeout(e(this,V)),e(this,o).onloadeddata=null,e(this,o).onload=null,e(this,o).onerror=null,e(this,u).set("loaded",!1),e(this,u).set("error",!1),e(this,u).set("loading",!1),e(this,u).set("clear",!1),t){n(this,C,`${e(this,$)}-${t.url}`);const i=this.hasAttribute("keep-source-parameters");e(this,u).set("loading",!0),n(this,v,i?t.url:t.name+t.extension),this.consumeSource(e(this,v)),!e(this,f)&&!e(this,E)&&ie.loading.add(e(this,C)),e(this,o).onloadeddata=()=>{e(this,H).call(this)},e(this,o).onload=()=>{e(this,H).call(this)},e(this,o).onerror=()=>{e(this,Q).call(this,e(this,v))}}else n(this,v,null),this.consumeSource(null)},J=new WeakMap,H=new WeakMap,Q=new WeakMap;class me extends F{createConsumer(){return document.createElement("img")}consumeSource(r){if(r&&this.hasAttribute("webp")&&ye.device.isWebp){const t=r.split(".").slice(0,-1).join(".")+".webp";this.consumerElement.src=t}else this.consumerElement.src=r||""}}customElements.get("e-image")||customElements.define("e-image",me);function we(a){const r=a.match(/\{([\d-]+)\}/);if(r){const t=r[1].split("-");if(t.length===2){const i=parseInt(t[0],10),c=parseInt(t[1],10);return{start:i,end:c}}}return null}var p,R,U,S,w,I,A,O,y,L;class fe extends F{constructor(t){super();s(this,p,[]);s(this,R,new D.CSSProperty(this,"--fit","contain"));s(this,U,new D.CSSProperty(this,"--autoplay",!1));s(this,S,new D.CSSProperty(this,"--offset-x",.5));s(this,w,new D.CSSProperty(this,"--offset-y",.5));s(this,I,null);s(this,A,0);s(this,O,1);s(this,y,()=>{if(e(this,p).length){const t=e(this,p)[0];e(this,R).current==="cover"?n(this,I,ue.cover(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,S).current,e(this,w).current)):n(this,I,ue.contain(t.naturalWidth,t.naturalHeight,this.consumerElement.width,this.consumerElement.height,e(this,S).current,e(this,w).current))}});s(this,L,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,p)[e(this,A)];i&&t.detail.context.drawImage(i,...e(this,I)),e(this,U).current&&n(this,A,(e(this,A)+1)%e(this,p).length)});le.isBrowser&&(n(this,O,parseInt(((t==null?void 0:t.pad)||this.getAttribute("pad")||"1").toString())),e(this,R).subscribe(e(this,y)),e(this,S).subscribe(e(this,y)),e(this,w).subscribe(e(this,y)),this.addEventListener("sourceCapture",i=>{this.consumerElement.addEventListener("canvasRender",e(this,L))}),this.addEventListener("sourceRelease",i=>{this.consumerElement.removeEventListener("canvasRender",e(this,L))}))}setProgress(t){e(this,p).length&&n(this,A,Math.floor((e(this,p).length-1)*t))}connectedCallback(){super.connectedCallback(),e(this,U).observe(),e(this,R).observe(),e(this,S).observe(),e(this,w).observe(),ce.elementResizer.subscribe(this,e(this,y))}disconnectedCallback(){super.disconnectedCallback(),e(this,U).unobserve(),e(this,R).unobserve(),e(this,S).unobserve(),e(this,w).unobserve(),n(this,p,[]),ce.elementResizer.unsubscribe(e(this,y)),this.consumerElement.removeEventListener("canvasRender",e(this,L))}createConsumer(){return new ve.CanvasElement}consumeSource(t){return he(this,null,function*(){var i,c,b,N;if(t){this.consumerElement.removeEventListener("canvasRender",e(this,L));const g=[],m=we(t);if(m)for(let l=m.start;l<=m.end;l++){const ae=t.replace(/\{([^}]+)\}/,l.toString().padStart(e(this,O),"0")),j=new Image;j.src=ae,g.push(j)}else{const l=new Image;l.src=t,g.push(l)}try{yield Promise.all(g.map((l,ae)=>new Promise((j,be)=>{l.onload=()=>{j()},l.onerror=Le=>{be(`${l.src} Image not found`)}}))),n(this,p,g),e(this,y).call(this),(c=(i=this.consumerElement).onload)==null||c.call(i,new Event("load")),this.isLazy||this.consumerElement.addEventListener("canvasRender",e(this,L))}catch(l){console.error(l),(N=(b=this.consumerElement).onerror)==null||N.call(b,new Event("error"))}}})}}p=new WeakMap,R=new WeakMap,U=new WeakMap,S=new WeakMap,w=new WeakMap,I=new WeakMap,A=new WeakMap,O=new WeakMap,y=new WeakMap,L=new WeakMap;customElements.get("e-sequence")||customElements.define("e-sequence",fe);var P,B;class pe extends F{constructor(){super(...arguments);s(this,P,0);s(this,B,()=>{this.classList.add(`state-${this.consumerElement.readyState}`);const t=this.consumerElement.readyState/4;t>e(this,P)&&n(this,P,t),X.dispatchEvent(this,"videoReadyStateChange",{detail:{readyState:this.consumerElement.readyState,progress:e(this,P)}}),this.consumerElement.readyState===4&&re.ticker.unsubscribe(e(this,B))})}connectedCallback(){super.connectedCallback(),this.addEventListener("sourceCapture",()=>{re.ticker.subscribe(e(this,B)),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(),re.ticker.unsubscribe(e(this,B)),n(this,P,0)}createConsumer(){return document.createElement("video")}consumeSource(t){this.consumerElement.src=t||"",this.consumerElement.autoplay=!0}}P=new WeakMap,B=new WeakMap;customElements.get("e-video")||customElements.define("e-video",pe);var h,M,k,W,Z,ee,te,Y,ne;const T=class T extends F{constructor(){super();s(this,Y);s(this,h);s(this,M);s(this,k,!1);s(this,W,()=>{n(this,k,this.hasAttribute("autoplay")&&!this.hasAttribute("capture-autoplay")),n(this,h,new window.YT.Player(e(this,M),{playerVars:{mute:this.hasAttribute("muted")?1:0,controls:this.hasAttribute("controls")?1:0},events:{onReady:e(this,Z),onError:e(this,ee),onStateChange:e(this,te)}}))});s(this,Z,()=>{x(this,Y,ne).call(this)});s(this,ee,t=>{var i,c;console.error("YouTube: Ошибка при загрузке видео:",this.currentURL,t),(c=(i=this.consumerElement).onerror)==null||c.call(i,new Event("error"))});s(this,te,()=>{});n(this,M,"yt-"+de.generateId(10)),T.__apiReady||(window.onYouTubeIframeAPIReady=()=>{T.__apiReady=!0,X.dispatchEvent(window,"youTubeIframeAPIReady")}),this.addEventListener("sourceCapture",()=>{this.hasAttribute("capture-autoplay")&&(e(this,h)?e(this,h).playVideo():n(this,k,!0))}),this.addEventListener("sourceRelease",()=>{e(this,h)&&this.hasAttribute("capture-autoplay")&&(e(this,h).pauseVideo(),this.hasAttribute("replay")&&e(this,h).seekTo(0))})}static __onYouTubeIframeAPIReady(){this.__apiReady=!0}createConsumer(){const t=document.createElement("div");return t.id=e(this,M),t}consumeSource(t){var i;if(t){if(!document.getElementById("youtube-script")){const c=document.createElement("script");c.id,c.src="https://www.youtube.com/iframe_api";const b=document.getElementsByTagName("script")[0];(i=b.parentNode)==null||i.insertBefore(c,b)}e(this,h)?x(this,Y,ne).call(this):T.__apiReady?e(this,W).call(this):addEventListener("youTubeIframeAPIReady",e(this,W))}else e(this,h)&&e(this,h).stopVideo()}disconnectedCallback(){super.disconnectedCallback(),e(this,h)&&e(this,h).destroy(),removeEventListener("youTubeIframeAPIReady",e(this,W))}};h=new WeakMap,M=new WeakMap,k=new WeakMap,W=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,Y=new WeakSet,ne=function(){var t,i;this.currentURL&&(this.currentURL.startsWith("http")?e(this,h).loadVideoByUrl(this.currentURL):e(this,h).loadVideoById(this.currentURL)),e(this,k)?e(this,h).playVideo():e(this,h).stopVideo(),n(this,k,!1),(i=(t=this.consumerElement).onload)==null||i.call(t,new Event("load"))},T.__apiReady=!1;let G=T;customElements.get("e-youtube")||customElements.define("e-youtube",G);exports.ImageElement=me;exports.SequenceElement=fe;exports.SourceElement=F;exports.VideoElement=pe;exports.YouTubeElement=G;
|
|
@@ -2,3 +2,4 @@ export { ImageElement } from './image';
|
|
|
2
2
|
export { SequenceElement, type SequenceElementParameters } from './sequence';
|
|
3
3
|
export { SourceElement, type SourceEvents } from './source';
|
|
4
4
|
export { VideoElement, type VideoEvents } from './video';
|
|
5
|
+
export { YouTubeElement } from './youtube';
|
|
@@ -1,279 +1,287 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var oe = (a) => {
|
|
2
|
+
throw TypeError(a);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var e = (
|
|
6
|
-
var
|
|
7
|
-
var
|
|
4
|
+
var te = (a, r, t) => r.has(a) || oe("Cannot " + t);
|
|
5
|
+
var e = (a, r, t) => (te(a, r, "read from private field"), t ? t.call(a) : r.get(a)), s = (a, r, t) => r.has(a) ? oe("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(a) : r.set(a, t), n = (a, r, t, i) => (te(a, r, "write to private field"), i ? i.call(a, t) : r.set(a, t), t), T = (a, r, t) => (te(a, r, "access private method"), t);
|
|
6
|
+
var he = (a, r, t) => new Promise((i, c) => {
|
|
7
|
+
var b = (m) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
} catch (
|
|
11
|
-
l
|
|
9
|
+
g(t.next(m));
|
|
10
|
+
} catch (l) {
|
|
11
|
+
c(l);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, O = (m) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
l
|
|
15
|
+
g(t.throw(m));
|
|
16
|
+
} catch (l) {
|
|
17
|
+
c(l);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, g = (m) => m.done ? i(m.value) : Promise.resolve(m.value).then(b, O);
|
|
20
|
+
g((t = t.apply(a, r)).next());
|
|
21
21
|
});
|
|
22
|
-
import { device as
|
|
23
|
-
import { SourceManager as
|
|
24
|
-
import { ClassLinkedStatus as
|
|
25
|
-
import { i as
|
|
22
|
+
import { device as de } from "../device/index.js";
|
|
23
|
+
import { SourceManager as me } from "../source/index.js";
|
|
24
|
+
import { ClassLinkedStatus as fe } from "../class-linked-status/index.js";
|
|
25
|
+
import { i as ue } from "../browser-0zX67oeU.js";
|
|
26
26
|
import { d as K } from "../events-CsVF98U6.js";
|
|
27
|
-
import { k as
|
|
28
|
-
import { loading as
|
|
29
|
-
import { CSSProperty as
|
|
30
|
-
import { elementResizer as
|
|
31
|
-
import { c as
|
|
32
|
-
import { CanvasElement as
|
|
33
|
-
import { ticker as
|
|
34
|
-
let
|
|
35
|
-
var
|
|
36
|
-
class
|
|
27
|
+
import { k as pe, g as be } from "../string-f0Dnk0L1.js";
|
|
28
|
+
import { loading as se } from "../loading/index.js";
|
|
29
|
+
import { CSSProperty as D } from "../css-property/index.js";
|
|
30
|
+
import { elementResizer as ce } from "../element-resizer/vanilla/index.js";
|
|
31
|
+
import { c as ye, a as ge } from "../canvas-DeZ0SLUJ.js";
|
|
32
|
+
import { CanvasElement as Ee } from "../canvas/index.js";
|
|
33
|
+
import { ticker as ie } from "../ticker/vanilla/index.js";
|
|
34
|
+
let ve = 0;
|
|
35
|
+
var d, o, E, V, f, H, S, u, U, z, v, _, j, X, q, G;
|
|
36
|
+
class ee extends HTMLElement {
|
|
37
37
|
constructor() {
|
|
38
38
|
super();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
s(this, _);
|
|
40
|
+
s(this, d, null);
|
|
41
|
+
s(this, o, null);
|
|
42
|
+
s(this, E, !1);
|
|
43
|
+
s(this, V, !1);
|
|
44
|
+
s(this, f, !1);
|
|
45
|
+
s(this, H, "");
|
|
46
|
+
s(this, S, "");
|
|
47
|
+
s(this, u, new fe(this, {
|
|
48
48
|
loading: !1,
|
|
49
49
|
loaded: !1,
|
|
50
|
-
error: !1
|
|
50
|
+
error: !1,
|
|
51
|
+
clear: !1
|
|
51
52
|
}));
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
s(this, U, null);
|
|
54
|
+
s(this, z);
|
|
55
|
+
s(this, v, null);
|
|
56
|
+
s(this, X, (t) => {
|
|
57
|
+
const i = t[0];
|
|
58
|
+
e(this, f) && (!e(this, V) || this.hasAttribute("reload-source")) && i.isIntersecting && this.triggerLazyLoad(), i.isIntersecting ? K(this, "sourceCapture", { custom: !0 }) : (this.hasAttribute("reload-source") && T(this, _, j).call(this, void 0), K(this, "sourceRelease", { custom: !0 }));
|
|
56
59
|
});
|
|
57
|
-
|
|
58
|
-
e(this,
|
|
60
|
+
s(this, q, () => {
|
|
61
|
+
e(this, u).set("loaded", !0), e(this, u).set("error", !1), e(this, u).set("loading", !1), !e(this, f) && !e(this, E) && se.complete(e(this, S));
|
|
62
|
+
const t = getComputedStyle(this).getPropertyValue("--clear-duration");
|
|
63
|
+
t && n(this, z, setTimeout(() => {
|
|
64
|
+
e(this, u).set("clear", !0);
|
|
65
|
+
}, parseFloat(t) * 1e3)), n(this, E, !0);
|
|
59
66
|
});
|
|
60
|
-
|
|
61
|
-
e(this,
|
|
67
|
+
s(this, G, (t) => {
|
|
68
|
+
e(this, u).set("loaded", !1), e(this, u).set("error", !0), e(this, u).set("loading", !1), !e(this, f) && !e(this, E) && se.error(e(this, S)), n(this, E, !0);
|
|
62
69
|
});
|
|
63
|
-
|
|
64
|
-
e(this,
|
|
70
|
+
ue && window.IntersectionObserver && (n(this, H, `source-consumer-${++ve}`), n(this, U, new IntersectionObserver(
|
|
71
|
+
e(this, X)
|
|
65
72
|
)));
|
|
66
73
|
}
|
|
67
74
|
get consumerElement() {
|
|
68
75
|
return e(this, o);
|
|
69
76
|
}
|
|
70
77
|
get sourceManager() {
|
|
71
|
-
return e(this,
|
|
78
|
+
return e(this, d);
|
|
72
79
|
}
|
|
73
80
|
get status() {
|
|
74
|
-
return e(this,
|
|
81
|
+
return e(this, u);
|
|
75
82
|
}
|
|
76
83
|
get isLazy() {
|
|
77
|
-
return e(this,
|
|
84
|
+
return e(this, f);
|
|
85
|
+
}
|
|
86
|
+
get currentURL() {
|
|
87
|
+
return e(this, v);
|
|
78
88
|
}
|
|
79
89
|
triggerLazyLoad() {
|
|
80
|
-
e(this,
|
|
90
|
+
e(this, d).current && e(this, d).current !== e(this, d).previous && T(this, _, j).call(this, e(this, d).current), n(this, V, !0);
|
|
81
91
|
}
|
|
82
92
|
connectedCallback() {
|
|
83
93
|
const t = this.getAttribute("srcset");
|
|
84
|
-
t && (
|
|
94
|
+
t && (n(this, o, this.createConsumer()), e(this, o).style.cssText = `
|
|
85
95
|
display: block;
|
|
86
96
|
width: 100%;
|
|
87
97
|
height: 100%;
|
|
88
|
-
`, e(this, o).classList.add("source-consumer"), Array.from(this.attributes).forEach((
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
91
|
-
|
|
98
|
+
`, e(this, o).classList.add("source-consumer"), Array.from(this.attributes).forEach((i) => {
|
|
99
|
+
if (i.name !== "srcset") {
|
|
100
|
+
const c = i.nodeValue || "", b = pe(i.name);
|
|
101
|
+
b in e(this, o) && (e(this, o)[b] = c || !0);
|
|
92
102
|
}
|
|
93
|
-
}), this.appendChild(e(this, o)),
|
|
103
|
+
}), this.appendChild(e(this, o)), n(this, d, new me({
|
|
94
104
|
srcset: t
|
|
95
|
-
})),
|
|
96
|
-
(!e(this,
|
|
97
|
-
}), e(this,
|
|
105
|
+
})), n(this, f, this.hasAttribute("lazy")), e(this, d).subscribe((i) => {
|
|
106
|
+
(!e(this, f) || e(this, f) && e(this, V)) && T(this, _, j).call(this, i.current);
|
|
107
|
+
}), e(this, U).observe(this), e(this, d).connect());
|
|
98
108
|
}
|
|
99
109
|
disconnectedCallback() {
|
|
100
|
-
e(this,
|
|
110
|
+
e(this, U).disconnect(), e(this, d).close(), e(this, o).onloadeddata = null, e(this, o).onload = null, e(this, o).onerror = null, e(this, o).remove(), e(this, u).reset(), clearTimeout(e(this, z));
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
|
-
|
|
104
|
-
if (e(this, o).onloadeddata = null, e(this, o).onload = null, e(this, o).onerror = null, e(this,
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
e(this,
|
|
108
|
-
|
|
109
|
-
this.consumeSource(l), !e(this, d) && !e(this, g) && j.add(e(this, C)), e(this, o).onloadeddata = () => {
|
|
110
|
-
e(this, $).call(this);
|
|
113
|
+
d = new WeakMap(), o = new WeakMap(), E = new WeakMap(), V = new WeakMap(), f = new WeakMap(), H = new WeakMap(), S = new WeakMap(), u = new WeakMap(), U = new WeakMap(), z = new WeakMap(), v = new WeakMap(), _ = new WeakSet(), j = function(t) {
|
|
114
|
+
if (clearTimeout(e(this, z)), e(this, o).onloadeddata = null, e(this, o).onload = null, e(this, o).onerror = null, e(this, u).set("loaded", !1), e(this, u).set("error", !1), e(this, u).set("loading", !1), e(this, u).set("clear", !1), t) {
|
|
115
|
+
n(this, S, `${e(this, H)}-${t.url}`);
|
|
116
|
+
const i = this.hasAttribute("keep-source-parameters");
|
|
117
|
+
e(this, u).set("loading", !0), n(this, v, i ? t.url : t.name + t.extension), this.consumeSource(e(this, v)), !e(this, f) && !e(this, E) && se.add(e(this, S)), e(this, o).onloadeddata = () => {
|
|
118
|
+
e(this, q).call(this);
|
|
111
119
|
}, e(this, o).onload = () => {
|
|
112
|
-
e(this,
|
|
120
|
+
e(this, q).call(this);
|
|
113
121
|
}, e(this, o).onerror = () => {
|
|
114
|
-
e(this,
|
|
122
|
+
e(this, G).call(this, e(this, v));
|
|
115
123
|
};
|
|
116
124
|
} else
|
|
117
|
-
this.consumeSource(null);
|
|
118
|
-
},
|
|
119
|
-
class
|
|
125
|
+
n(this, v, null), this.consumeSource(null);
|
|
126
|
+
}, X = new WeakMap(), q = new WeakMap(), G = new WeakMap();
|
|
127
|
+
class we extends ee {
|
|
120
128
|
createConsumer() {
|
|
121
129
|
return document.createElement("img");
|
|
122
130
|
}
|
|
123
|
-
consumeSource(
|
|
124
|
-
if (
|
|
125
|
-
const t =
|
|
131
|
+
consumeSource(r) {
|
|
132
|
+
if (r && this.hasAttribute("webp") && de.isWebp) {
|
|
133
|
+
const t = r.split(".").slice(0, -1).join(".") + ".webp";
|
|
126
134
|
this.consumerElement.src = t;
|
|
127
135
|
} else
|
|
128
|
-
this.consumerElement.src =
|
|
136
|
+
this.consumerElement.src = r || "";
|
|
129
137
|
}
|
|
130
138
|
}
|
|
131
|
-
customElements.get("e-image") || customElements.define("e-image",
|
|
132
|
-
function
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
const t =
|
|
139
|
+
customElements.get("e-image") || customElements.define("e-image", we);
|
|
140
|
+
function Le(a) {
|
|
141
|
+
const r = a.match(/\{([\d-]+)\}/);
|
|
142
|
+
if (r) {
|
|
143
|
+
const t = r[1].split("-");
|
|
136
144
|
if (t.length === 2) {
|
|
137
|
-
const
|
|
138
|
-
return { start:
|
|
145
|
+
const i = parseInt(t[0], 10), c = parseInt(t[1], 10);
|
|
146
|
+
return { start: i, end: c };
|
|
139
147
|
}
|
|
140
148
|
}
|
|
141
149
|
return null;
|
|
142
150
|
}
|
|
143
|
-
var
|
|
144
|
-
class
|
|
151
|
+
var p, R, B, w, L, I, A, F, y, C;
|
|
152
|
+
class Ce extends ee {
|
|
145
153
|
constructor(t) {
|
|
146
154
|
super();
|
|
147
|
-
|
|
148
|
-
|
|
155
|
+
s(this, p, []);
|
|
156
|
+
s(this, R, new D(
|
|
149
157
|
this,
|
|
150
158
|
"--fit",
|
|
151
159
|
"contain"
|
|
152
160
|
));
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (e(this,
|
|
161
|
-
const t = e(this,
|
|
162
|
-
e(this,
|
|
161
|
+
s(this, B, new D(this, "--autoplay", !1));
|
|
162
|
+
s(this, w, new D(this, "--offset-x", 0.5));
|
|
163
|
+
s(this, L, new D(this, "--offset-y", 0.5));
|
|
164
|
+
s(this, I, null);
|
|
165
|
+
s(this, A, 0);
|
|
166
|
+
s(this, F, 1);
|
|
167
|
+
s(this, y, () => {
|
|
168
|
+
if (e(this, p).length) {
|
|
169
|
+
const t = e(this, p)[0];
|
|
170
|
+
e(this, R).current === "cover" ? n(this, I, ye(
|
|
163
171
|
t.naturalWidth,
|
|
164
172
|
t.naturalHeight,
|
|
165
173
|
this.consumerElement.width,
|
|
166
174
|
this.consumerElement.height,
|
|
167
|
-
e(this,
|
|
168
|
-
e(this,
|
|
169
|
-
)) :
|
|
175
|
+
e(this, w).current,
|
|
176
|
+
e(this, L).current
|
|
177
|
+
)) : n(this, I, ge(
|
|
170
178
|
t.naturalWidth,
|
|
171
179
|
t.naturalHeight,
|
|
172
180
|
this.consumerElement.width,
|
|
173
181
|
this.consumerElement.height,
|
|
174
|
-
e(this,
|
|
175
|
-
e(this,
|
|
182
|
+
e(this, w).current,
|
|
183
|
+
e(this, L).current
|
|
176
184
|
));
|
|
177
185
|
}
|
|
178
186
|
});
|
|
179
|
-
|
|
180
|
-
if (this.status.isFalse("loaded") || !e(this,
|
|
187
|
+
s(this, C, (t) => {
|
|
188
|
+
if (this.status.isFalse("loaded") || !e(this, I))
|
|
181
189
|
return;
|
|
182
190
|
t.detail.context.clearRect(0, 0, t.detail.width, t.detail.height);
|
|
183
|
-
const
|
|
184
|
-
|
|
191
|
+
const i = e(this, p)[e(this, A)];
|
|
192
|
+
i && t.detail.context.drawImage(i, ...e(this, I)), e(this, B).current && n(this, A, (e(this, A) + 1) % e(this, p).length);
|
|
185
193
|
});
|
|
186
|
-
|
|
194
|
+
ue && (n(this, F, parseInt(
|
|
187
195
|
((t == null ? void 0 : t.pad) || this.getAttribute("pad") || "1").toString()
|
|
188
|
-
)), e(this,
|
|
196
|
+
)), e(this, R).subscribe(e(this, y)), e(this, w).subscribe(e(this, y)), e(this, L).subscribe(e(this, y)), this.addEventListener("sourceCapture", (i) => {
|
|
189
197
|
this.consumerElement.addEventListener(
|
|
190
198
|
"canvasRender",
|
|
191
|
-
e(this,
|
|
199
|
+
e(this, C)
|
|
192
200
|
);
|
|
193
|
-
}), this.addEventListener("sourceRelease", (
|
|
201
|
+
}), this.addEventListener("sourceRelease", (i) => {
|
|
194
202
|
this.consumerElement.removeEventListener(
|
|
195
203
|
"canvasRender",
|
|
196
|
-
e(this,
|
|
204
|
+
e(this, C)
|
|
197
205
|
);
|
|
198
206
|
}));
|
|
199
207
|
}
|
|
200
208
|
setProgress(t) {
|
|
201
|
-
e(this,
|
|
209
|
+
e(this, p).length && n(this, A, Math.floor((e(this, p).length - 1) * t));
|
|
202
210
|
}
|
|
203
211
|
connectedCallback() {
|
|
204
|
-
super.connectedCallback(), e(this,
|
|
212
|
+
super.connectedCallback(), e(this, B).observe(), e(this, R).observe(), e(this, w).observe(), e(this, L).observe(), ce.subscribe(this, e(this, y));
|
|
205
213
|
}
|
|
206
214
|
disconnectedCallback() {
|
|
207
|
-
super.disconnectedCallback(), e(this,
|
|
215
|
+
super.disconnectedCallback(), e(this, B).unobserve(), e(this, R).unobserve(), e(this, w).unobserve(), e(this, L).unobserve(), n(this, p, []), ce.unsubscribe(e(this, y)), this.consumerElement.removeEventListener(
|
|
208
216
|
"canvasRender",
|
|
209
|
-
e(this,
|
|
217
|
+
e(this, C)
|
|
210
218
|
);
|
|
211
219
|
}
|
|
212
220
|
createConsumer() {
|
|
213
|
-
return new
|
|
221
|
+
return new Ee();
|
|
214
222
|
}
|
|
215
223
|
consumeSource(t) {
|
|
216
|
-
return
|
|
217
|
-
var
|
|
224
|
+
return he(this, null, function* () {
|
|
225
|
+
var i, c, b, O;
|
|
218
226
|
if (t) {
|
|
219
227
|
this.consumerElement.removeEventListener(
|
|
220
228
|
"canvasRender",
|
|
221
|
-
e(this,
|
|
229
|
+
e(this, C)
|
|
222
230
|
);
|
|
223
|
-
const
|
|
231
|
+
const g = [], m = Le(t);
|
|
224
232
|
if (m)
|
|
225
|
-
for (let
|
|
226
|
-
const
|
|
233
|
+
for (let l = m.start; l <= m.end; l++) {
|
|
234
|
+
const ae = t.replace(
|
|
227
235
|
/\{([^}]+)\}/,
|
|
228
|
-
|
|
229
|
-
),
|
|
230
|
-
|
|
236
|
+
l.toString().padStart(e(this, F), "0")
|
|
237
|
+
), Y = new Image();
|
|
238
|
+
Y.src = ae, g.push(Y);
|
|
231
239
|
}
|
|
232
240
|
else {
|
|
233
|
-
const
|
|
234
|
-
|
|
241
|
+
const l = new Image();
|
|
242
|
+
l.src = t, g.push(l);
|
|
235
243
|
}
|
|
236
244
|
try {
|
|
237
245
|
yield Promise.all(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
},
|
|
242
|
-
|
|
246
|
+
g.map((l, ae) => new Promise((Y, le) => {
|
|
247
|
+
l.onload = () => {
|
|
248
|
+
Y();
|
|
249
|
+
}, l.onerror = (Re) => {
|
|
250
|
+
le(`${l.src} Image not found`);
|
|
243
251
|
};
|
|
244
252
|
}))
|
|
245
|
-
),
|
|
253
|
+
), n(this, p, g), e(this, y).call(this), (c = (i = this.consumerElement).onload) == null || c.call(i, new Event("load")), this.isLazy || this.consumerElement.addEventListener(
|
|
246
254
|
"canvasRender",
|
|
247
|
-
e(this,
|
|
255
|
+
e(this, C)
|
|
248
256
|
);
|
|
249
|
-
} catch (
|
|
250
|
-
console.error(
|
|
257
|
+
} catch (l) {
|
|
258
|
+
console.error(l), (O = (b = this.consumerElement).onerror) == null || O.call(b, new Event("error"));
|
|
251
259
|
}
|
|
252
260
|
}
|
|
253
261
|
});
|
|
254
262
|
}
|
|
255
263
|
}
|
|
256
|
-
|
|
257
|
-
customElements.get("e-sequence") || customElements.define("e-sequence",
|
|
258
|
-
var
|
|
259
|
-
class
|
|
264
|
+
p = new WeakMap(), R = new WeakMap(), B = new WeakMap(), w = new WeakMap(), L = new WeakMap(), I = new WeakMap(), A = new WeakMap(), F = new WeakMap(), y = new WeakMap(), C = new WeakMap();
|
|
265
|
+
customElements.get("e-sequence") || customElements.define("e-sequence", Ce);
|
|
266
|
+
var k, M;
|
|
267
|
+
class Se extends ee {
|
|
260
268
|
constructor() {
|
|
261
269
|
super(...arguments);
|
|
262
|
-
|
|
263
|
-
|
|
270
|
+
s(this, k, 0);
|
|
271
|
+
s(this, M, () => {
|
|
264
272
|
this.classList.add(`state-${this.consumerElement.readyState}`);
|
|
265
273
|
const t = this.consumerElement.readyState / 4;
|
|
266
|
-
t > e(this,
|
|
274
|
+
t > e(this, k) && n(this, k, t), K(this, "videoReadyStateChange", {
|
|
267
275
|
detail: {
|
|
268
276
|
readyState: this.consumerElement.readyState,
|
|
269
|
-
progress: e(this,
|
|
277
|
+
progress: e(this, k)
|
|
270
278
|
}
|
|
271
|
-
}), this.consumerElement.readyState === 4 &&
|
|
279
|
+
}), this.consumerElement.readyState === 4 && ie.unsubscribe(e(this, M));
|
|
272
280
|
});
|
|
273
281
|
}
|
|
274
282
|
connectedCallback() {
|
|
275
283
|
super.connectedCallback(), this.addEventListener("sourceCapture", () => {
|
|
276
|
-
|
|
284
|
+
ie.subscribe(e(this, M)), this.hasAttribute("capture-autoplay") && this.consumerElement.play();
|
|
277
285
|
}), this.addEventListener("sourceRelease", () => {
|
|
278
286
|
this.hasAttribute("capture-autoplay") && (this.consumerElement.pause(), this.hasAttribute("replay") && (this.consumerElement.currentTime = 0)), this.hasAttribute("reload-source") && this.classList.remove(
|
|
279
287
|
"state-0",
|
|
@@ -285,7 +293,7 @@ class le extends N {
|
|
|
285
293
|
});
|
|
286
294
|
}
|
|
287
295
|
disconnectedCallback() {
|
|
288
|
-
super.disconnectedCallback(),
|
|
296
|
+
super.disconnectedCallback(), ie.unsubscribe(e(this, M)), n(this, k, 0);
|
|
289
297
|
}
|
|
290
298
|
createConsumer() {
|
|
291
299
|
return document.createElement("video");
|
|
@@ -294,11 +302,79 @@ class le extends N {
|
|
|
294
302
|
this.consumerElement.src = t || "", this.consumerElement.autoplay = !0;
|
|
295
303
|
}
|
|
296
304
|
}
|
|
297
|
-
|
|
298
|
-
customElements.get("e-video") || customElements.define("e-video",
|
|
305
|
+
k = new WeakMap(), M = new WeakMap();
|
|
306
|
+
customElements.get("e-video") || customElements.define("e-video", Se);
|
|
307
|
+
var h, W, P, $, J, Q, Z, N, ne;
|
|
308
|
+
const x = class x extends ee {
|
|
309
|
+
constructor() {
|
|
310
|
+
super();
|
|
311
|
+
s(this, N);
|
|
312
|
+
s(this, h);
|
|
313
|
+
s(this, W);
|
|
314
|
+
s(this, P, !1);
|
|
315
|
+
s(this, $, () => {
|
|
316
|
+
n(this, P, this.hasAttribute("autoplay") && !this.hasAttribute("capture-autoplay")), n(this, h, new window.YT.Player(e(this, W), {
|
|
317
|
+
playerVars: {
|
|
318
|
+
mute: this.hasAttribute("muted") ? 1 : 0,
|
|
319
|
+
controls: this.hasAttribute("controls") ? 1 : 0
|
|
320
|
+
},
|
|
321
|
+
events: {
|
|
322
|
+
onReady: e(this, J),
|
|
323
|
+
onError: e(this, Q),
|
|
324
|
+
onStateChange: e(this, Z)
|
|
325
|
+
}
|
|
326
|
+
}));
|
|
327
|
+
});
|
|
328
|
+
s(this, J, () => {
|
|
329
|
+
T(this, N, ne).call(this);
|
|
330
|
+
});
|
|
331
|
+
s(this, Q, (t) => {
|
|
332
|
+
var i, c;
|
|
333
|
+
console.error("YouTube: Ошибка при загрузке видео:", this.currentURL, t), (c = (i = this.consumerElement).onerror) == null || c.call(i, new Event("error"));
|
|
334
|
+
});
|
|
335
|
+
s(this, Z, () => {
|
|
336
|
+
});
|
|
337
|
+
n(this, W, "yt-" + be(10)), x.__apiReady || (window.onYouTubeIframeAPIReady = () => {
|
|
338
|
+
x.__apiReady = !0, K(window, "youTubeIframeAPIReady");
|
|
339
|
+
}), this.addEventListener("sourceCapture", () => {
|
|
340
|
+
this.hasAttribute("capture-autoplay") && (e(this, h) ? e(this, h).playVideo() : n(this, P, !0));
|
|
341
|
+
}), this.addEventListener("sourceRelease", () => {
|
|
342
|
+
e(this, h) && this.hasAttribute("capture-autoplay") && (e(this, h).pauseVideo(), this.hasAttribute("replay") && e(this, h).seekTo(0));
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
static __onYouTubeIframeAPIReady() {
|
|
346
|
+
this.__apiReady = !0;
|
|
347
|
+
}
|
|
348
|
+
createConsumer() {
|
|
349
|
+
const t = document.createElement("div");
|
|
350
|
+
return t.id = e(this, W), t;
|
|
351
|
+
}
|
|
352
|
+
consumeSource(t) {
|
|
353
|
+
var i;
|
|
354
|
+
if (t) {
|
|
355
|
+
if (!document.getElementById("youtube-script")) {
|
|
356
|
+
const c = document.createElement("script");
|
|
357
|
+
c.id, c.src = "https://www.youtube.com/iframe_api";
|
|
358
|
+
const b = document.getElementsByTagName("script")[0];
|
|
359
|
+
(i = b.parentNode) == null || i.insertBefore(c, b);
|
|
360
|
+
}
|
|
361
|
+
e(this, h) ? T(this, N, ne).call(this) : x.__apiReady ? e(this, $).call(this) : addEventListener("youTubeIframeAPIReady", e(this, $));
|
|
362
|
+
} else e(this, h) && e(this, h).stopVideo();
|
|
363
|
+
}
|
|
364
|
+
disconnectedCallback() {
|
|
365
|
+
super.disconnectedCallback(), e(this, h) && e(this, h).destroy(), removeEventListener("youTubeIframeAPIReady", e(this, $));
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
h = new WeakMap(), W = new WeakMap(), P = new WeakMap(), $ = new WeakMap(), J = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), N = new WeakSet(), ne = function() {
|
|
369
|
+
var t, i;
|
|
370
|
+
this.currentURL && (this.currentURL.startsWith("http") ? e(this, h).loadVideoByUrl(this.currentURL) : e(this, h).loadVideoById(this.currentURL)), e(this, P) ? e(this, h).playVideo() : e(this, h).stopVideo(), n(this, P, !1), (i = (t = this.consumerElement).onload) == null || i.call(t, new Event("load"));
|
|
371
|
+
}, x.__apiReady = !1;
|
|
372
|
+
let re = x;
|
|
373
|
+
customElements.get("e-youtube") || customElements.define("e-youtube", re);
|
|
299
374
|
export {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
375
|
+
we as ImageElement,
|
|
376
|
+
Ce as SequenceElement,
|
|
377
|
+
ee as SourceElement,
|
|
378
|
+
Se as VideoElement,
|
|
379
|
+
re as YouTubeElement
|
|
304
380
|
};
|
|
@@ -14,8 +14,10 @@ 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;
|
|
20
|
+
get currentURL(): string | null;
|
|
19
21
|
triggerLazyLoad(): void;
|
|
20
22
|
protected abstract createConsumer(): T;
|
|
21
23
|
protected abstract consumeSource(url: string | null): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SourceElement } from '../source';
|
|
2
|
+
|
|
3
|
+
export declare class YouTubeElement extends SourceElement<HTMLDivElement> {
|
|
4
|
+
#private;
|
|
5
|
+
static __apiReady: boolean;
|
|
6
|
+
static __onYouTubeIframeAPIReady(): void;
|
|
7
|
+
constructor();
|
|
8
|
+
protected createConsumer(): HTMLDivElement;
|
|
9
|
+
protected consumeSource(id: string | null): void;
|
|
10
|
+
protected disconnectedCallback(): void;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface Window {
|
|
14
|
+
onYouTubeIframeAPIReady: () => void;
|
|
15
|
+
YT: any;
|
|
16
|
+
}
|
|
17
|
+
interface WindowEventMap {
|
|
18
|
+
youTubeIframeAPIReady: CustomEvent;
|
|
19
|
+
}
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
'e-youtube': YouTubeElement;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/lib/source/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var b=
|
|
1
|
+
"use strict";var b=r=>{throw TypeError(r)};var I=(r,n,t)=>n.has(r)||b("Cannot "+t);var e=(r,n,t)=>(I(r,n,"read from private field"),t?t.call(r):n.get(r)),o=(r,n,t)=>n.has(r)?b("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(r):n.set(r,t),i=(r,n,t,h)=>(I(r,n,"write to private field"),h?h.call(r,t):n.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("../order/index.cjs"),T=require("../window-resizer/vanilla/index.cjs"),A=require("../Store-CDb6RMce.cjs");var q,x,w,d,a,u,f;class _{constructor(n){o(this,q);o(this,x);o(this,w);o(this,d);o(this,a);o(this,u);o(this,f);i(this,q,n);const t=n.split(".");i(this,x,t.length>1?t.slice(0,-1).join("."):t.join("."));const h=/\d+x/g,p=t.find(l=>l.match(h));i(this,w,p?parseInt(p):1);const c=/\d+max/g,g=/\d+min/g,S=/\d+mar/g,s=/\d+mir/g,m=t.find(l=>l.match(c)),E=t.find(l=>l.match(g)),$=t.find(l=>l.match(S)),V=t.find(l=>l.match(s));$?(i(this,a,parseInt($)),i(this,u,"max"),i(this,d,`(max-aspect-ratio: ${e(this,a)})`)):V?(i(this,a,parseInt(V)),i(this,u,"max"),i(this,d,`(min-aspect-ratio: ${e(this,a)})`)):m?(i(this,a,parseInt(m)),i(this,u,"max"),i(this,d,`(max-width: ${e(this,a)}px)`)):E?(i(this,a,parseInt(E)),i(this,d,`(min-width: ${e(this,a)}px)`),i(this,u,"min")):(i(this,a,0),i(this,d,`(min-width: ${e(this,a)}px)`),i(this,u,"min")),i(this,x,e(this,x).replace(`.${e(this,a)}${e(this,u)}`,"")),i(this,f,t[t.length-1]===e(this,x)?"":"."+t[t.length-1]),i(this,f,e(this,f).replace(`.${e(this,a)}${e(this,u)}`,""))}get url(){return e(this,q)}get name(){return e(this,x)}get density(){return e(this,w)}get query(){return e(this,d)}get extension(){return e(this,f)}get queryType(){return e(this,u)}get queryValue(){return e(this,a)}}q=new WeakMap,x=new WeakMap,w=new WeakMap,d=new WeakMap,a=new WeakMap,u=new WeakMap,f=new WeakMap;var y;class k{constructor(n){o(this,y);i(this,y,new Map);const t=typeof n=="string"?n.trim().split(",").map(s=>s.trim()).filter(s=>!!s):n,h=[];t.forEach(s=>{const m=new _(s);h.push([m.query,m])});const p=h.filter(s=>s[1].queryType.includes("max")).sort((s,m)=>m[1].queryValue-s[1].queryValue),c=h.filter(s=>s[1].queryType.includes("min")&&s[1].queryValue!==0).sort((s,m)=>s[1].queryValue-m[1].queryValue),g=h.filter(s=>s[0]==="(min-width: 0px)");(g?[...g,...p,...c]:[...p,...c]).forEach(s=>{e(this,y).has(s[0])||e(this,y).set(s[0],[]),e(this,y).get(s[0]).push(s[1])})}get mediaBuckets(){return e(this,y)}}y=new WeakMap;var R,M;class B extends A.Store{constructor(t){super(void 0);o(this,R);o(this,M,()=>{let t;e(this,R).mediaBuckets.forEach((c,g)=>{matchMedia(g).matches&&(t=c)});let h,p=0;t==null||t.forEach(c=>{c.density>p&&c.density<=Math.max(devicePixelRatio,1)&&(p=c.density,h=c)}),t!=null&&t.length&&!h&&(h=t[0]),this.current=h});i(this,R,new k(t.srcset))}close(){super.close(),this.disconnect()}connect(){T.windowResizer.subscribe(e(this,M),z.RESIZE_ORDER.SOURCE_MANAGER)}disconnect(){T.windowResizer.unsubscribe(e(this,M))}}R=new WeakMap,M=new WeakMap;exports.Source=_;exports.SourceManager=B;exports.SourceSet=k;
|
package/lib/source/index.js
CHANGED
|
@@ -1,107 +1,108 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var b = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import { RESIZE_ORDER as
|
|
7
|
-
import { windowResizer as
|
|
8
|
-
import { S
|
|
9
|
-
var
|
|
10
|
-
class
|
|
11
|
-
constructor(
|
|
12
|
-
o(this, g);
|
|
13
|
-
o(this, x);
|
|
4
|
+
var k = (r, n, t) => n.has(r) || b("Cannot " + t);
|
|
5
|
+
var e = (r, n, t) => (k(r, n, "read from private field"), t ? t.call(r) : n.get(r)), o = (r, n, t) => n.has(r) ? b("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(r) : n.set(r, t), s = (r, n, t, a) => (k(r, n, "write to private field"), a ? a.call(r, t) : n.set(r, t), t);
|
|
6
|
+
import { RESIZE_ORDER as B } from "../order/index.js";
|
|
7
|
+
import { windowResizer as A } from "../window-resizer/vanilla/index.js";
|
|
8
|
+
import { S } from "../Store-OTdcl6SX.js";
|
|
9
|
+
var q, f, w, p, h, m, y;
|
|
10
|
+
class T {
|
|
11
|
+
constructor(n) {
|
|
14
12
|
o(this, q);
|
|
15
|
-
o(this,
|
|
13
|
+
o(this, f);
|
|
14
|
+
o(this, w);
|
|
15
|
+
o(this, p);
|
|
16
16
|
o(this, h);
|
|
17
17
|
o(this, m);
|
|
18
|
-
o(this,
|
|
19
|
-
|
|
20
|
-
const t =
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
$ ? (n(this, h, parseInt($)), n(this, m, "max"), n(this, d, `(max-aspect-ratio: ${i(this, h)})`)) : b ? (n(this, h, parseInt(b)), n(this, m, "max"), n(this, d, `(min-aspect-ratio: ${i(this, h)})`)) : I ? (n(this, h, parseInt(I)), n(this, m, "max"), n(this, d, `(max-width: ${i(this, h)}px)`)) : V ? (n(this, h, parseInt(V)), n(this, d, `(min-width: ${i(this, h)}px)`), n(this, m, "min")) : (n(this, h, 0), n(this, d, `(min-width: ${i(this, h)}px)`), n(this, m, "min")), n(this, x, i(this, x).replace(
|
|
28
|
-
`.${i(this, h)}${i(this, m)}`,
|
|
18
|
+
o(this, y);
|
|
19
|
+
s(this, q, n);
|
|
20
|
+
const t = n.split(".");
|
|
21
|
+
s(this, f, t.length > 1 ? t.slice(0, -1).join(".") : t.join("."));
|
|
22
|
+
const a = /\d+x/g, d = t.find((l) => l.match(a));
|
|
23
|
+
s(this, w, d ? parseInt(d) : 1);
|
|
24
|
+
const c = /\d+max/g, g = /\d+min/g, $ = /\d+mar/g, i = /\d+mir/g, u = t.find((l) => l.match(c)), M = t.find((l) => l.match(g)), V = t.find((l) => l.match($)), I = t.find((l) => l.match(i));
|
|
25
|
+
V ? (s(this, h, parseInt(V)), s(this, m, "max"), s(this, p, `(max-aspect-ratio: ${e(this, h)})`)) : I ? (s(this, h, parseInt(I)), s(this, m, "max"), s(this, p, `(min-aspect-ratio: ${e(this, h)})`)) : u ? (s(this, h, parseInt(u)), s(this, m, "max"), s(this, p, `(max-width: ${e(this, h)}px)`)) : M ? (s(this, h, parseInt(M)), s(this, p, `(min-width: ${e(this, h)}px)`), s(this, m, "min")) : (s(this, h, 0), s(this, p, `(min-width: ${e(this, h)}px)`), s(this, m, "min")), s(this, f, e(this, f).replace(
|
|
26
|
+
`.${e(this, h)}${e(this, m)}`,
|
|
29
27
|
""
|
|
30
|
-
)),
|
|
28
|
+
)), s(this, y, t[t.length - 1] === e(this, f) ? "" : "." + t[t.length - 1]), s(this, y, e(this, y).replace(
|
|
29
|
+
`.${e(this, h)}${e(this, m)}`,
|
|
30
|
+
""
|
|
31
|
+
));
|
|
31
32
|
}
|
|
32
33
|
get url() {
|
|
33
|
-
return
|
|
34
|
+
return e(this, q);
|
|
34
35
|
}
|
|
35
36
|
get name() {
|
|
36
|
-
return
|
|
37
|
+
return e(this, f);
|
|
37
38
|
}
|
|
38
39
|
get density() {
|
|
39
|
-
return
|
|
40
|
+
return e(this, w);
|
|
40
41
|
}
|
|
41
42
|
get query() {
|
|
42
|
-
return
|
|
43
|
+
return e(this, p);
|
|
43
44
|
}
|
|
44
45
|
get extension() {
|
|
45
|
-
return
|
|
46
|
+
return e(this, y);
|
|
46
47
|
}
|
|
47
48
|
get queryType() {
|
|
48
|
-
return
|
|
49
|
+
return e(this, m);
|
|
49
50
|
}
|
|
50
51
|
get queryValue() {
|
|
51
|
-
return
|
|
52
|
+
return e(this, h);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
var
|
|
55
|
+
q = new WeakMap(), f = new WeakMap(), w = new WeakMap(), p = new WeakMap(), h = new WeakMap(), m = new WeakMap(), y = new WeakMap();
|
|
56
|
+
var x;
|
|
56
57
|
class P {
|
|
57
|
-
constructor(
|
|
58
|
-
o(this,
|
|
59
|
-
|
|
60
|
-
const t = typeof
|
|
61
|
-
t.forEach((
|
|
62
|
-
const
|
|
63
|
-
|
|
58
|
+
constructor(n) {
|
|
59
|
+
o(this, x);
|
|
60
|
+
s(this, x, /* @__PURE__ */ new Map());
|
|
61
|
+
const t = typeof n == "string" ? n.trim().split(",").map((i) => i.trim()).filter((i) => !!i) : n, a = [];
|
|
62
|
+
t.forEach((i) => {
|
|
63
|
+
const u = new T(i);
|
|
64
|
+
a.push([u.query, u]);
|
|
64
65
|
});
|
|
65
|
-
const
|
|
66
|
-
(
|
|
67
|
-
|
|
66
|
+
const d = a.filter((i) => i[1].queryType.includes("max")).sort((i, u) => u[1].queryValue - i[1].queryValue), c = a.filter((i) => i[1].queryType.includes("min") && i[1].queryValue !== 0).sort((i, u) => i[1].queryValue - u[1].queryValue), g = a.filter((i) => i[0] === "(min-width: 0px)");
|
|
67
|
+
(g ? [...g, ...d, ...c] : [...d, ...c]).forEach((i) => {
|
|
68
|
+
e(this, x).has(i[0]) || e(this, x).set(i[0], []), e(this, x).get(i[0]).push(i[1]);
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
get mediaBuckets() {
|
|
71
|
-
return
|
|
72
|
+
return e(this, x);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
x = new WeakMap();
|
|
75
76
|
var E, R;
|
|
76
|
-
class
|
|
77
|
+
class _ extends S {
|
|
77
78
|
constructor(t) {
|
|
78
79
|
super(void 0);
|
|
79
80
|
o(this, E);
|
|
80
81
|
o(this, R, () => {
|
|
81
82
|
let t;
|
|
82
|
-
|
|
83
|
-
matchMedia(
|
|
83
|
+
e(this, E).mediaBuckets.forEach((c, g) => {
|
|
84
|
+
matchMedia(g).matches && (t = c);
|
|
84
85
|
});
|
|
85
|
-
let
|
|
86
|
+
let a, d = 0;
|
|
86
87
|
t == null || t.forEach((c) => {
|
|
87
|
-
c.density >
|
|
88
|
-
}), t != null && t.length && !
|
|
88
|
+
c.density > d && c.density <= Math.max(devicePixelRatio, 1) && (d = c.density, a = c);
|
|
89
|
+
}), t != null && t.length && !a && (a = t[0]), this.current = a;
|
|
89
90
|
});
|
|
90
|
-
|
|
91
|
+
s(this, E, new P(t.srcset));
|
|
91
92
|
}
|
|
92
93
|
close() {
|
|
93
94
|
super.close(), this.disconnect();
|
|
94
95
|
}
|
|
95
96
|
connect() {
|
|
96
|
-
|
|
97
|
+
A.subscribe(e(this, R), B.SOURCE_MANAGER);
|
|
97
98
|
}
|
|
98
99
|
disconnect() {
|
|
99
|
-
|
|
100
|
+
A.unsubscribe(e(this, R));
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
E = new WeakMap(), R = new WeakMap();
|
|
103
104
|
export {
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
T as Source,
|
|
106
|
+
_ as SourceManager,
|
|
106
107
|
P as SourceSet
|
|
107
108
|
};
|