@alpha-video-kit/svg 0.2.1 → 0.2.2

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.
@@ -0,0 +1,35 @@
1
+ "use strict";var U=Object.defineProperty;var G=o=>{throw TypeError(o)};var K=(o,h,t)=>h in o?U(o,h,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[h]=t;var H=(o,h,t)=>K(o,typeof h!="symbol"?h+"":h,t),$=(o,h,t)=>h.has(o)||G("Cannot "+t);var e=(o,h,t)=>($(o,h,"read from private field"),t?t.call(o):h.get(o)),l=(o,h,t)=>h.has(o)?G("Cannot add the same private member more than once"):h instanceof WeakSet?h.add(o):h.set(o,t),a=(o,h,t,r)=>($(o,h,"write to private field"),r?r.call(o,t):h.set(o,t),t),u=(o,h,t)=>($(o,h,"access private method"),t);const W=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],Y=new Set(["autoplay","loop","muted","playsinline"]),J=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","play","pause","ratechange","resize","volumechange"];var s,T,S,A,R,y,k,c,P,V,I;class D extends HTMLElement{constructor(){super();l(this,c);l(this,s);l(this,T);l(this,S);l(this,A);l(this,R);l(this,y,null);l(this,k);const t=this.attachShadow({mode:"open"});a(this,k,`avk-${Math.random().toString(36).slice(2,8)}`),t.innerHTML=`<style>
2
+ :host{display:inline-block;overflow:hidden}
3
+ svg{display:block;width:100%;height:auto}
4
+ video{display:block;width:100%;height:100%}
5
+ </style>
6
+ <svg viewBox="0 0 1 1" preserveAspectRatio="xMidYMid meet">
7
+ <defs>
8
+ <filter id="${e(this,k)}" filterUnits="userSpaceOnUse" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
9
+ <feOffset in="SourceGraphic" dy="0" result="s"/>
10
+ <feColorMatrix in="s" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0" result="a"/>
11
+ <feComposite in="SourceGraphic" in2="a" operator="in"/>
12
+ </filter>
13
+ </defs>
14
+ <foreignObject width="1" height="1" filter="url(#${e(this,k)})">
15
+ <video></video>
16
+ </foreignObject>
17
+ </svg>`,a(this,T,t.querySelector("svg")),a(this,S,t.querySelector("foreignObject")),a(this,A,t.querySelector("filter")),a(this,R,t.querySelector("feOffset")),a(this,s,t.querySelector("video"));for(const r of J)e(this,s).addEventListener(r,d=>{this.dispatchEvent(new Event(d.type,{bubbles:!1,cancelable:!1}))});e(this,s).addEventListener("loadedmetadata",()=>u(this,c,P).call(this)),e(this,s).addEventListener("resize",()=>u(this,c,P).call(this))}connectedCallback(){for(const t of W)this.hasAttribute(t)&&u(this,c,V).call(this,t,this.getAttribute(t));u(this,c,I).call(this),a(this,y,new MutationObserver(()=>u(this,c,I).call(this))),e(this,y).observe(this,{childList:!0})}disconnectedCallback(){var t;(t=e(this,y))==null||t.disconnect(),a(this,y,null)}attributeChangedCallback(t,r,d){u(this,c,V).call(this,t,d)}get src(){return e(this,s).src}set src(t){this.setAttribute("src",t)}get currentSrc(){return e(this,s).currentSrc}get currentTime(){return e(this,s).currentTime}set currentTime(t){e(this,s).currentTime=t}get duration(){return e(this,s).duration}get paused(){return e(this,s).paused}get ended(){return e(this,s).ended}get readyState(){return e(this,s).readyState}get videoWidth(){return e(this,s).videoWidth}get videoHeight(){return Math.floor(e(this,s).videoHeight/2)}get volume(){return e(this,s).volume}set volume(t){e(this,s).volume=t}get playbackRate(){return e(this,s).playbackRate}set playbackRate(t){e(this,s).playbackRate=t}get defaultPlaybackRate(){return e(this,s).defaultPlaybackRate}set defaultPlaybackRate(t){e(this,s).defaultPlaybackRate=t}get muted(){return e(this,s).muted}set muted(t){e(this,s).muted=t,this.toggleAttribute("muted",t)}get loop(){return e(this,s).loop}set loop(t){e(this,s).loop=t,this.toggleAttribute("loop",t)}get autoplay(){return e(this,s).autoplay}set autoplay(t){e(this,s).autoplay=t,this.toggleAttribute("autoplay",t)}get preload(){return e(this,s).preload}set preload(t){this.setAttribute("preload",t)}get crossOrigin(){return e(this,s).crossOrigin}set crossOrigin(t){t===null?this.removeAttribute("crossorigin"):this.setAttribute("crossorigin",t)}get buffered(){return e(this,s).buffered}get seekable(){return e(this,s).seekable}get played(){return e(this,s).played}get networkState(){return e(this,s).networkState}get error(){return e(this,s).error}get seeking(){return e(this,s).seeking}play(){return e(this,s).play()}pause(){e(this,s).pause()}load(){e(this,s).load()}canPlayType(t){return e(this,s).canPlayType(t)}}s=new WeakMap,T=new WeakMap,S=new WeakMap,A=new WeakMap,R=new WeakMap,y=new WeakMap,k=new WeakMap,c=new WeakSet,P=function(){const t=e(this,s).videoWidth,r=e(this,s).videoHeight;if(!t||!r)return;const d=Math.floor(r/2);e(this,T).setAttribute("viewBox",`0 0 ${t} ${d}`),e(this,S).setAttribute("width",String(t)),e(this,S).setAttribute("height",String(r)),e(this,A).setAttribute("width",String(t)),e(this,A).setAttribute("height",String(r)),e(this,R).setAttribute("dy",String(-d))},V=function(t,r){Y.has(t)?e(this,s)[t]=r!==null:r===null?e(this,s).removeAttribute(t):e(this,s).setAttribute(t,r)},I=function(){e(this,s).querySelectorAll("source").forEach(t=>t.remove()),this.querySelectorAll("source").forEach(t=>{e(this,s).appendChild(t.cloneNode(!0))}),e(this,s).querySelectorAll("source").length>0&&!e(this,s).src&&e(this,s).load()},H(D,"observedAttributes",[...W]);const j=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],Q=new Set(["autoplay","loop","muted","playsinline"]),X=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","play","pause","ratechange","resize","volumechange"];var i,g,q,C,w,O,M,v,m,p,f,b,E,n,x,B,F,z,L,_;class N extends HTMLElement{constructor(){super();l(this,n);l(this,i);l(this,g);l(this,q);l(this,C);l(this,w);l(this,O);l(this,M);l(this,v,null);l(this,m,null);l(this,p,!1);l(this,f,0);l(this,b,0);l(this,E);const t=this.attachShadow({mode:"open"});a(this,E,`avk-c-${Math.random().toString(36).slice(2,8)}`),t.innerHTML=`<style>
18
+ :host{display:inline-block;overflow:hidden}
19
+ video{position:absolute;opacity:0;pointer-events:none;width:0;height:0}
20
+ svg{display:block;width:100%;height:auto}
21
+ canvas{display:block;width:100%;height:100%}
22
+ </style>
23
+ <video></video>
24
+ <svg viewBox="0 0 1 1" preserveAspectRatio="xMidYMid meet">
25
+ <defs>
26
+ <filter id="${e(this,E)}" filterUnits="userSpaceOnUse" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
27
+ <feOffset in="SourceGraphic" dy="0" result="s"/>
28
+ <feColorMatrix in="s" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0" result="a"/>
29
+ <feComposite in="SourceGraphic" in2="a" operator="in"/>
30
+ </filter>
31
+ </defs>
32
+ <foreignObject width="1" height="1" filter="url(#${e(this,E)})">
33
+ <canvas xmlns="http://www.w3.org/1999/xhtml"></canvas>
34
+ </foreignObject>
35
+ </svg>`,a(this,i,t.querySelector("video")),a(this,C,t.querySelector("svg")),a(this,w,t.querySelector("foreignObject")),a(this,O,t.querySelector("filter")),a(this,M,t.querySelector("feOffset")),a(this,g,t.querySelector("canvas")),a(this,q,e(this,g).getContext("2d"));for(const r of X)e(this,i).addEventListener(r,d=>{this.dispatchEvent(new Event(d.type,{bubbles:!1,cancelable:!1}))});e(this,i).addEventListener("loadedmetadata",()=>u(this,n,x).call(this)),e(this,i).addEventListener("resize",()=>u(this,n,x).call(this))}connectedCallback(){for(const t of j)this.hasAttribute(t)&&u(this,n,B).call(this,t,this.getAttribute(t));u(this,n,F).call(this),a(this,m,new MutationObserver(()=>u(this,n,F).call(this))),e(this,m).observe(this,{childList:!0}),a(this,v,new IntersectionObserver(([t])=>{a(this,p,t.isIntersecting),e(this,p)?u(this,n,z).call(this):u(this,n,L).call(this)},{threshold:0})),e(this,v).observe(this)}disconnectedCallback(){var t,r;u(this,n,L).call(this),(t=e(this,v))==null||t.disconnect(),a(this,v,null),(r=e(this,m))==null||r.disconnect(),a(this,m,null)}attributeChangedCallback(t,r,d){u(this,n,B).call(this,t,d)}get src(){return e(this,i).src}set src(t){this.setAttribute("src",t)}get currentSrc(){return e(this,i).currentSrc}get currentTime(){return e(this,i).currentTime}set currentTime(t){e(this,i).currentTime=t}get duration(){return e(this,i).duration}get paused(){return e(this,i).paused}get ended(){return e(this,i).ended}get readyState(){return e(this,i).readyState}get videoWidth(){return e(this,i).videoWidth}get videoHeight(){return Math.floor(e(this,i).videoHeight/2)}get volume(){return e(this,i).volume}set volume(t){e(this,i).volume=t}get playbackRate(){return e(this,i).playbackRate}set playbackRate(t){e(this,i).playbackRate=t}get defaultPlaybackRate(){return e(this,i).defaultPlaybackRate}set defaultPlaybackRate(t){e(this,i).defaultPlaybackRate=t}get muted(){return e(this,i).muted}set muted(t){e(this,i).muted=t,this.toggleAttribute("muted",t)}get loop(){return e(this,i).loop}set loop(t){e(this,i).loop=t,this.toggleAttribute("loop",t)}get autoplay(){return e(this,i).autoplay}set autoplay(t){e(this,i).autoplay=t,this.toggleAttribute("autoplay",t)}get preload(){return e(this,i).preload}set preload(t){this.setAttribute("preload",t)}get crossOrigin(){return e(this,i).crossOrigin}set crossOrigin(t){t===null?this.removeAttribute("crossorigin"):this.setAttribute("crossorigin",t)}get buffered(){return e(this,i).buffered}get seekable(){return e(this,i).seekable}get played(){return e(this,i).played}get networkState(){return e(this,i).networkState}get error(){return e(this,i).error}get seeking(){return e(this,i).seeking}play(){return e(this,i).play()}pause(){e(this,i).pause()}load(){e(this,i).load()}canPlayType(t){return e(this,i).canPlayType(t)}}i=new WeakMap,g=new WeakMap,q=new WeakMap,C=new WeakMap,w=new WeakMap,O=new WeakMap,M=new WeakMap,v=new WeakMap,m=new WeakMap,p=new WeakMap,f=new WeakMap,b=new WeakMap,E=new WeakMap,n=new WeakSet,x=function(){const t=e(this,i).videoWidth,r=e(this,i).videoHeight;if(!t||!r)return;const d=Math.floor(r/2);e(this,C).setAttribute("viewBox",`0 0 ${t} ${d}`),e(this,w).setAttribute("width",String(t)),e(this,w).setAttribute("height",String(r)),e(this,O).setAttribute("width",String(t)),e(this,O).setAttribute("height",String(r)),e(this,M).setAttribute("dy",String(-d)),e(this,g).width=t,e(this,g).height=r},B=function(t,r){Q.has(t)?e(this,i)[t]=r!==null:r===null?e(this,i).removeAttribute(t):e(this,i).setAttribute(t,r)},F=function(){e(this,i).querySelectorAll("source").forEach(t=>t.remove()),this.querySelectorAll("source").forEach(t=>{e(this,i).appendChild(t.cloneNode(!0))}),e(this,i).querySelectorAll("source").length>0&&!e(this,i).src&&e(this,i).load()},z=function(){if(e(this,p))if(u(this,n,L).call(this),"requestVideoFrameCallback"in e(this,i)){const t=()=>{e(this,p)&&(u(this,n,_).call(this),a(this,b,e(this,i).requestVideoFrameCallback(t)))};a(this,b,e(this,i).requestVideoFrameCallback(t))}else{const t=()=>{e(this,p)&&(u(this,n,_).call(this),a(this,f,requestAnimationFrame(t)))};a(this,f,requestAnimationFrame(t))}},L=function(){var t,r;e(this,b)&&((r=(t=e(this,i)).cancelVideoFrameCallback)==null||r.call(t,e(this,b)),a(this,b,0)),e(this,f)&&(cancelAnimationFrame(e(this,f)),a(this,f,0))},_=function(){if(e(this,i).readyState<2)return;const t=e(this,i).videoWidth,r=e(this,i).videoHeight;!t||!r||((e(this,g).width!==t||e(this,g).height!==r)&&u(this,n,x).call(this),e(this,q).drawImage(e(this,i),0,0))},H(N,"observedAttributes",[...j]);exports.AlphaVideoKitCanvas=N;exports.AlphaVideoKitSVG=D;
@@ -0,0 +1,464 @@
1
+ var N = Object.defineProperty;
2
+ var W = (o) => {
3
+ throw TypeError(o);
4
+ };
5
+ var z = (o, h, t) => h in o ? N(o, h, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[h] = t;
6
+ var H = (o, h, t) => z(o, typeof h != "symbol" ? h + "" : h, t), $ = (o, h, t) => h.has(o) || W("Cannot " + t);
7
+ var e = (o, h, t) => ($(o, h, "read from private field"), t ? t.call(o) : h.get(o)), l = (o, h, t) => h.has(o) ? W("Cannot add the same private member more than once") : h instanceof WeakSet ? h.add(o) : h.set(o, t), a = (o, h, t, r) => ($(o, h, "write to private field"), r ? r.call(o, t) : h.set(o, t), t), u = (o, h, t) => ($(o, h, "access private method"), t);
8
+ const j = [
9
+ "src",
10
+ "crossorigin",
11
+ "preload",
12
+ "autoplay",
13
+ "loop",
14
+ "muted",
15
+ "playsinline",
16
+ "poster",
17
+ "width",
18
+ "height"
19
+ ], U = /* @__PURE__ */ new Set(["autoplay", "loop", "muted", "playsinline"]), Y = [
20
+ "loadstart",
21
+ "progress",
22
+ "suspend",
23
+ "abort",
24
+ "error",
25
+ "emptied",
26
+ "stalled",
27
+ "loadedmetadata",
28
+ "loadeddata",
29
+ "canplay",
30
+ "canplaythrough",
31
+ "playing",
32
+ "waiting",
33
+ "seeking",
34
+ "seeked",
35
+ "ended",
36
+ "durationchange",
37
+ "timeupdate",
38
+ "play",
39
+ "pause",
40
+ "ratechange",
41
+ "resize",
42
+ "volumechange"
43
+ ];
44
+ var s, T, S, A, R, y, k, c, P, I, V;
45
+ class J extends HTMLElement {
46
+ constructor() {
47
+ super();
48
+ l(this, c);
49
+ l(this, s);
50
+ l(this, T);
51
+ l(this, S);
52
+ l(this, A);
53
+ l(this, R);
54
+ l(this, y, null);
55
+ l(this, k);
56
+ const t = this.attachShadow({ mode: "open" });
57
+ a(this, k, `avk-${Math.random().toString(36).slice(2, 8)}`), t.innerHTML = `<style>
58
+ :host{display:inline-block;overflow:hidden}
59
+ svg{display:block;width:100%;height:auto}
60
+ video{display:block;width:100%;height:100%}
61
+ </style>
62
+ <svg viewBox="0 0 1 1" preserveAspectRatio="xMidYMid meet">
63
+ <defs>
64
+ <filter id="${e(this, k)}" filterUnits="userSpaceOnUse" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
65
+ <feOffset in="SourceGraphic" dy="0" result="s"/>
66
+ <feColorMatrix in="s" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0" result="a"/>
67
+ <feComposite in="SourceGraphic" in2="a" operator="in"/>
68
+ </filter>
69
+ </defs>
70
+ <foreignObject width="1" height="1" filter="url(#${e(this, k)})">
71
+ <video></video>
72
+ </foreignObject>
73
+ </svg>`, a(this, T, t.querySelector("svg")), a(this, S, t.querySelector("foreignObject")), a(this, A, t.querySelector("filter")), a(this, R, t.querySelector("feOffset")), a(this, s, t.querySelector("video"));
74
+ for (const r of Y)
75
+ e(this, s).addEventListener(r, (d) => {
76
+ this.dispatchEvent(new Event(d.type, { bubbles: !1, cancelable: !1 }));
77
+ });
78
+ e(this, s).addEventListener("loadedmetadata", () => u(this, c, P).call(this)), e(this, s).addEventListener("resize", () => u(this, c, P).call(this));
79
+ }
80
+ connectedCallback() {
81
+ for (const t of j)
82
+ this.hasAttribute(t) && u(this, c, I).call(this, t, this.getAttribute(t));
83
+ u(this, c, V).call(this), a(this, y, new MutationObserver(() => u(this, c, V).call(this))), e(this, y).observe(this, { childList: !0 });
84
+ }
85
+ disconnectedCallback() {
86
+ var t;
87
+ (t = e(this, y)) == null || t.disconnect(), a(this, y, null);
88
+ }
89
+ attributeChangedCallback(t, r, d) {
90
+ u(this, c, I).call(this, t, d);
91
+ }
92
+ // --- Proxied properties ---
93
+ get src() {
94
+ return e(this, s).src;
95
+ }
96
+ set src(t) {
97
+ this.setAttribute("src", t);
98
+ }
99
+ get currentSrc() {
100
+ return e(this, s).currentSrc;
101
+ }
102
+ get currentTime() {
103
+ return e(this, s).currentTime;
104
+ }
105
+ set currentTime(t) {
106
+ e(this, s).currentTime = t;
107
+ }
108
+ get duration() {
109
+ return e(this, s).duration;
110
+ }
111
+ get paused() {
112
+ return e(this, s).paused;
113
+ }
114
+ get ended() {
115
+ return e(this, s).ended;
116
+ }
117
+ get readyState() {
118
+ return e(this, s).readyState;
119
+ }
120
+ get videoWidth() {
121
+ return e(this, s).videoWidth;
122
+ }
123
+ get videoHeight() {
124
+ return Math.floor(e(this, s).videoHeight / 2);
125
+ }
126
+ get volume() {
127
+ return e(this, s).volume;
128
+ }
129
+ set volume(t) {
130
+ e(this, s).volume = t;
131
+ }
132
+ get playbackRate() {
133
+ return e(this, s).playbackRate;
134
+ }
135
+ set playbackRate(t) {
136
+ e(this, s).playbackRate = t;
137
+ }
138
+ get defaultPlaybackRate() {
139
+ return e(this, s).defaultPlaybackRate;
140
+ }
141
+ set defaultPlaybackRate(t) {
142
+ e(this, s).defaultPlaybackRate = t;
143
+ }
144
+ get muted() {
145
+ return e(this, s).muted;
146
+ }
147
+ set muted(t) {
148
+ e(this, s).muted = t, this.toggleAttribute("muted", t);
149
+ }
150
+ get loop() {
151
+ return e(this, s).loop;
152
+ }
153
+ set loop(t) {
154
+ e(this, s).loop = t, this.toggleAttribute("loop", t);
155
+ }
156
+ get autoplay() {
157
+ return e(this, s).autoplay;
158
+ }
159
+ set autoplay(t) {
160
+ e(this, s).autoplay = t, this.toggleAttribute("autoplay", t);
161
+ }
162
+ get preload() {
163
+ return e(this, s).preload;
164
+ }
165
+ set preload(t) {
166
+ this.setAttribute("preload", t);
167
+ }
168
+ get crossOrigin() {
169
+ return e(this, s).crossOrigin;
170
+ }
171
+ set crossOrigin(t) {
172
+ t === null ? this.removeAttribute("crossorigin") : this.setAttribute("crossorigin", t);
173
+ }
174
+ get buffered() {
175
+ return e(this, s).buffered;
176
+ }
177
+ get seekable() {
178
+ return e(this, s).seekable;
179
+ }
180
+ get played() {
181
+ return e(this, s).played;
182
+ }
183
+ get networkState() {
184
+ return e(this, s).networkState;
185
+ }
186
+ get error() {
187
+ return e(this, s).error;
188
+ }
189
+ get seeking() {
190
+ return e(this, s).seeking;
191
+ }
192
+ // --- Proxied methods ---
193
+ play() {
194
+ return e(this, s).play();
195
+ }
196
+ pause() {
197
+ e(this, s).pause();
198
+ }
199
+ load() {
200
+ e(this, s).load();
201
+ }
202
+ canPlayType(t) {
203
+ return e(this, s).canPlayType(t);
204
+ }
205
+ }
206
+ s = new WeakMap(), T = new WeakMap(), S = new WeakMap(), A = new WeakMap(), R = new WeakMap(), y = new WeakMap(), k = new WeakMap(), c = new WeakSet(), P = function() {
207
+ const t = e(this, s).videoWidth, r = e(this, s).videoHeight;
208
+ if (!t || !r) return;
209
+ const d = Math.floor(r / 2);
210
+ e(this, T).setAttribute("viewBox", `0 0 ${t} ${d}`), e(this, S).setAttribute("width", String(t)), e(this, S).setAttribute("height", String(r)), e(this, A).setAttribute("width", String(t)), e(this, A).setAttribute("height", String(r)), e(this, R).setAttribute("dy", String(-d));
211
+ }, I = function(t, r) {
212
+ U.has(t) ? e(this, s)[t] = r !== null : r === null ? e(this, s).removeAttribute(t) : e(this, s).setAttribute(t, r);
213
+ }, V = function() {
214
+ e(this, s).querySelectorAll("source").forEach((t) => t.remove()), this.querySelectorAll("source").forEach((t) => {
215
+ e(this, s).appendChild(t.cloneNode(!0));
216
+ }), e(this, s).querySelectorAll("source").length > 0 && !e(this, s).src && e(this, s).load();
217
+ }, H(J, "observedAttributes", [...j]);
218
+ const D = [
219
+ "src",
220
+ "crossorigin",
221
+ "preload",
222
+ "autoplay",
223
+ "loop",
224
+ "muted",
225
+ "playsinline",
226
+ "poster",
227
+ "width",
228
+ "height"
229
+ ], K = /* @__PURE__ */ new Set(["autoplay", "loop", "muted", "playsinline"]), Q = [
230
+ "loadstart",
231
+ "progress",
232
+ "suspend",
233
+ "abort",
234
+ "error",
235
+ "emptied",
236
+ "stalled",
237
+ "loadedmetadata",
238
+ "loadeddata",
239
+ "canplay",
240
+ "canplaythrough",
241
+ "playing",
242
+ "waiting",
243
+ "seeking",
244
+ "seeked",
245
+ "ended",
246
+ "durationchange",
247
+ "timeupdate",
248
+ "play",
249
+ "pause",
250
+ "ratechange",
251
+ "resize",
252
+ "volumechange"
253
+ ];
254
+ var i, g, q, C, w, O, M, v, m, p, f, b, E, n, x, B, F, G, L, _;
255
+ class X extends HTMLElement {
256
+ constructor() {
257
+ super();
258
+ l(this, n);
259
+ l(this, i);
260
+ l(this, g);
261
+ l(this, q);
262
+ l(this, C);
263
+ l(this, w);
264
+ l(this, O);
265
+ l(this, M);
266
+ l(this, v, null);
267
+ l(this, m, null);
268
+ l(this, p, !1);
269
+ l(this, f, 0);
270
+ l(this, b, 0);
271
+ l(this, E);
272
+ const t = this.attachShadow({ mode: "open" });
273
+ a(this, E, `avk-c-${Math.random().toString(36).slice(2, 8)}`), t.innerHTML = `<style>
274
+ :host{display:inline-block;overflow:hidden}
275
+ video{position:absolute;opacity:0;pointer-events:none;width:0;height:0}
276
+ svg{display:block;width:100%;height:auto}
277
+ canvas{display:block;width:100%;height:100%}
278
+ </style>
279
+ <video></video>
280
+ <svg viewBox="0 0 1 1" preserveAspectRatio="xMidYMid meet">
281
+ <defs>
282
+ <filter id="${e(this, E)}" filterUnits="userSpaceOnUse" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
283
+ <feOffset in="SourceGraphic" dy="0" result="s"/>
284
+ <feColorMatrix in="s" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0" result="a"/>
285
+ <feComposite in="SourceGraphic" in2="a" operator="in"/>
286
+ </filter>
287
+ </defs>
288
+ <foreignObject width="1" height="1" filter="url(#${e(this, E)})">
289
+ <canvas xmlns="http://www.w3.org/1999/xhtml"></canvas>
290
+ </foreignObject>
291
+ </svg>`, a(this, i, t.querySelector("video")), a(this, C, t.querySelector("svg")), a(this, w, t.querySelector("foreignObject")), a(this, O, t.querySelector("filter")), a(this, M, t.querySelector("feOffset")), a(this, g, t.querySelector("canvas")), a(this, q, e(this, g).getContext("2d"));
292
+ for (const r of Q)
293
+ e(this, i).addEventListener(r, (d) => {
294
+ this.dispatchEvent(new Event(d.type, { bubbles: !1, cancelable: !1 }));
295
+ });
296
+ e(this, i).addEventListener("loadedmetadata", () => u(this, n, x).call(this)), e(this, i).addEventListener("resize", () => u(this, n, x).call(this));
297
+ }
298
+ connectedCallback() {
299
+ for (const t of D)
300
+ this.hasAttribute(t) && u(this, n, B).call(this, t, this.getAttribute(t));
301
+ u(this, n, F).call(this), a(this, m, new MutationObserver(() => u(this, n, F).call(this))), e(this, m).observe(this, { childList: !0 }), a(this, v, new IntersectionObserver(
302
+ ([t]) => {
303
+ a(this, p, t.isIntersecting), e(this, p) ? u(this, n, G).call(this) : u(this, n, L).call(this);
304
+ },
305
+ { threshold: 0 }
306
+ )), e(this, v).observe(this);
307
+ }
308
+ disconnectedCallback() {
309
+ var t, r;
310
+ u(this, n, L).call(this), (t = e(this, v)) == null || t.disconnect(), a(this, v, null), (r = e(this, m)) == null || r.disconnect(), a(this, m, null);
311
+ }
312
+ attributeChangedCallback(t, r, d) {
313
+ u(this, n, B).call(this, t, d);
314
+ }
315
+ // --- Proxied properties ---
316
+ get src() {
317
+ return e(this, i).src;
318
+ }
319
+ set src(t) {
320
+ this.setAttribute("src", t);
321
+ }
322
+ get currentSrc() {
323
+ return e(this, i).currentSrc;
324
+ }
325
+ get currentTime() {
326
+ return e(this, i).currentTime;
327
+ }
328
+ set currentTime(t) {
329
+ e(this, i).currentTime = t;
330
+ }
331
+ get duration() {
332
+ return e(this, i).duration;
333
+ }
334
+ get paused() {
335
+ return e(this, i).paused;
336
+ }
337
+ get ended() {
338
+ return e(this, i).ended;
339
+ }
340
+ get readyState() {
341
+ return e(this, i).readyState;
342
+ }
343
+ get videoWidth() {
344
+ return e(this, i).videoWidth;
345
+ }
346
+ get videoHeight() {
347
+ return Math.floor(e(this, i).videoHeight / 2);
348
+ }
349
+ get volume() {
350
+ return e(this, i).volume;
351
+ }
352
+ set volume(t) {
353
+ e(this, i).volume = t;
354
+ }
355
+ get playbackRate() {
356
+ return e(this, i).playbackRate;
357
+ }
358
+ set playbackRate(t) {
359
+ e(this, i).playbackRate = t;
360
+ }
361
+ get defaultPlaybackRate() {
362
+ return e(this, i).defaultPlaybackRate;
363
+ }
364
+ set defaultPlaybackRate(t) {
365
+ e(this, i).defaultPlaybackRate = t;
366
+ }
367
+ get muted() {
368
+ return e(this, i).muted;
369
+ }
370
+ set muted(t) {
371
+ e(this, i).muted = t, this.toggleAttribute("muted", t);
372
+ }
373
+ get loop() {
374
+ return e(this, i).loop;
375
+ }
376
+ set loop(t) {
377
+ e(this, i).loop = t, this.toggleAttribute("loop", t);
378
+ }
379
+ get autoplay() {
380
+ return e(this, i).autoplay;
381
+ }
382
+ set autoplay(t) {
383
+ e(this, i).autoplay = t, this.toggleAttribute("autoplay", t);
384
+ }
385
+ get preload() {
386
+ return e(this, i).preload;
387
+ }
388
+ set preload(t) {
389
+ this.setAttribute("preload", t);
390
+ }
391
+ get crossOrigin() {
392
+ return e(this, i).crossOrigin;
393
+ }
394
+ set crossOrigin(t) {
395
+ t === null ? this.removeAttribute("crossorigin") : this.setAttribute("crossorigin", t);
396
+ }
397
+ get buffered() {
398
+ return e(this, i).buffered;
399
+ }
400
+ get seekable() {
401
+ return e(this, i).seekable;
402
+ }
403
+ get played() {
404
+ return e(this, i).played;
405
+ }
406
+ get networkState() {
407
+ return e(this, i).networkState;
408
+ }
409
+ get error() {
410
+ return e(this, i).error;
411
+ }
412
+ get seeking() {
413
+ return e(this, i).seeking;
414
+ }
415
+ // --- Proxied methods ---
416
+ play() {
417
+ return e(this, i).play();
418
+ }
419
+ pause() {
420
+ e(this, i).pause();
421
+ }
422
+ load() {
423
+ e(this, i).load();
424
+ }
425
+ canPlayType(t) {
426
+ return e(this, i).canPlayType(t);
427
+ }
428
+ }
429
+ i = new WeakMap(), g = new WeakMap(), q = new WeakMap(), C = new WeakMap(), w = new WeakMap(), O = new WeakMap(), M = new WeakMap(), v = new WeakMap(), m = new WeakMap(), p = new WeakMap(), f = new WeakMap(), b = new WeakMap(), E = new WeakMap(), n = new WeakSet(), x = function() {
430
+ const t = e(this, i).videoWidth, r = e(this, i).videoHeight;
431
+ if (!t || !r) return;
432
+ const d = Math.floor(r / 2);
433
+ e(this, C).setAttribute("viewBox", `0 0 ${t} ${d}`), e(this, w).setAttribute("width", String(t)), e(this, w).setAttribute("height", String(r)), e(this, O).setAttribute("width", String(t)), e(this, O).setAttribute("height", String(r)), e(this, M).setAttribute("dy", String(-d)), e(this, g).width = t, e(this, g).height = r;
434
+ }, B = function(t, r) {
435
+ K.has(t) ? e(this, i)[t] = r !== null : r === null ? e(this, i).removeAttribute(t) : e(this, i).setAttribute(t, r);
436
+ }, F = function() {
437
+ e(this, i).querySelectorAll("source").forEach((t) => t.remove()), this.querySelectorAll("source").forEach((t) => {
438
+ e(this, i).appendChild(t.cloneNode(!0));
439
+ }), e(this, i).querySelectorAll("source").length > 0 && !e(this, i).src && e(this, i).load();
440
+ }, G = function() {
441
+ if (e(this, p))
442
+ if (u(this, n, L).call(this), "requestVideoFrameCallback" in e(this, i)) {
443
+ const t = () => {
444
+ e(this, p) && (u(this, n, _).call(this), a(this, b, e(this, i).requestVideoFrameCallback(t)));
445
+ };
446
+ a(this, b, e(this, i).requestVideoFrameCallback(t));
447
+ } else {
448
+ const t = () => {
449
+ e(this, p) && (u(this, n, _).call(this), a(this, f, requestAnimationFrame(t)));
450
+ };
451
+ a(this, f, requestAnimationFrame(t));
452
+ }
453
+ }, L = function() {
454
+ var t, r;
455
+ e(this, b) && ((r = (t = e(this, i)).cancelVideoFrameCallback) == null || r.call(t, e(this, b)), a(this, b, 0)), e(this, f) && (cancelAnimationFrame(e(this, f)), a(this, f, 0));
456
+ }, _ = function() {
457
+ if (e(this, i).readyState < 2) return;
458
+ const t = e(this, i).videoWidth, r = e(this, i).videoHeight;
459
+ !t || !r || ((e(this, g).width !== t || e(this, g).height !== r) && u(this, n, x).call(this), e(this, q).drawImage(e(this, i), 0, 0));
460
+ }, H(X, "observedAttributes", [...D]);
461
+ export {
462
+ X as A,
463
+ J as a
464
+ };
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./canvas-component-CJM11n9O.cjs");function R(u){const{canvas:r}=u,c=r.getContext("2d"),l=document.createElement("canvas"),d=l.getContext("2d");let s=!1;function g(o,e,t,n){return`<svg xmlns="http://www.w3.org/2000/svg"
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./canvas-component-B4CLR7ME.cjs");function R(u){const{canvas:r}=u,c=r.getContext("2d"),l=document.createElement("canvas"),d=l.getContext("2d");let s=!1;function g(o,e,t,n){return`<svg xmlns="http://www.w3.org/2000/svg"
2
2
  xmlns:xlink="http://www.w3.org/1999/xlink"
3
3
  width="${e}" height="${t}"
4
4
  viewBox="0 0 ${e} ${t}">
package/dist/index.d.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  /**
2
- * `<alpha-video-kit-canvas>` — Canvas 2D with the same SVG filter applied via CSS.
2
+ * `<alpha-video-kit-canvas>` — Canvas 2D wrapped in an SVG with an inline filter.
3
3
  *
4
- * A hidden <video> feeds a visible <canvas> via drawImage (full stacked frame).
5
- * The CSS SVG filter composites the stacked-alpha halves.
6
- * The host element clips to the top half via overflow:hidden + aspect-ratio.
4
+ * Structure:
5
+ * <video hidden> ← source, not displayed
6
+ * <svg viewBox="0 0 W H/2"> ← clips to top half
7
+ * <filter> ← feOffset + feColorMatrix + feComposite
8
+ * <foreignObject W×H filter> ← full-height canvas with filter applied
9
+ * <canvas>
10
+ *
11
+ * A hidden <video> feeds frames to <canvas> via drawImage (full stacked frame).
12
+ * The SVG filter composites the stacked-alpha halves.
13
+ * SVG viewBox clips to the top (color) half.
7
14
  */
8
15
  export declare class AlphaVideoKitCanvas extends HTMLElement {
9
16
  #private;
@@ -52,11 +59,16 @@ export declare class AlphaVideoKitCanvas extends HTMLElement {
52
59
  }
53
60
 
54
61
  /**
55
- * `<alpha-video-kit-svg>` — SVG filter applied directly to a `<video>` element.
62
+ * `<alpha-video-kit-svg>` — video wrapped in an SVG with an inline filter.
63
+ *
64
+ * Structure:
65
+ * <svg viewBox="0 0 W H/2"> ← clips to top half
66
+ * <filter> ← feOffset + feColorMatrix + feComposite
67
+ * <foreignObject W×H filter> ← full-height video with filter applied
68
+ * <video>
56
69
  *
57
- * No canvas, no rendering loop. The browser applies the CSS SVG filter on every
58
- * paint, compositing the stacked-alpha halves in real time.
59
- * The host element clips to the top half via overflow:hidden + aspect-ratio.
70
+ * No canvas, no render loop. The browser composites the stacked-alpha halves
71
+ * via the SVG filter pipeline on every paint.
60
72
  */
61
73
  export declare class AlphaVideoKitSVG extends HTMLElement {
62
74
  #private;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as k, a as b } from "./canvas-component-DMsm7VdA.js";
1
+ import { A as k, a as b } from "./canvas-component-ChQNZXEV.js";
2
2
  function x(u) {
3
3
  const { canvas: r } = u, c = r.getContext("2d"), l = document.createElement("canvas"), d = l.getContext("2d");
4
4
  let i = !1;
package/dist/register.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("./canvas-component-CJM11n9O.cjs");customElements.get("alpha-video-kit-svg")||customElements.define("alpha-video-kit-svg",e.AlphaVideoKitSVG);customElements.get("alpha-video-kit-canvas")||customElements.define("alpha-video-kit-canvas",e.AlphaVideoKitCanvas);
1
+ "use strict";const e=require("./canvas-component-B4CLR7ME.cjs");customElements.get("alpha-video-kit-svg")||customElements.define("alpha-video-kit-svg",e.AlphaVideoKitSVG);customElements.get("alpha-video-kit-canvas")||customElements.define("alpha-video-kit-canvas",e.AlphaVideoKitCanvas);
package/dist/register.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as e, A as a } from "./canvas-component-DMsm7VdA.js";
1
+ import { a as e, A as a } from "./canvas-component-ChQNZXEV.js";
2
2
  customElements.get("alpha-video-kit-svg") || customElements.define("alpha-video-kit-svg", e);
3
3
  customElements.get("alpha-video-kit-canvas") || customElements.define("alpha-video-kit-canvas", a);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpha-video-kit/svg",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "SVG filter-based renderer for stacked alpha videos",
5
5
  "type": "module",
6
6
  "files": ["dist", "react.d.ts"],
@@ -1,8 +0,0 @@
1
- "use strict";var x=Object.defineProperty;var M=r=>{throw TypeError(r)};var _=(r,o,t)=>o in r?x(r,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[o]=t;var w=(r,o,t)=>_(r,typeof o!="symbol"?o+"":o,t),T=(r,o,t)=>o.has(r)||M("Cannot "+t);var e=(r,o,t)=>(T(r,o,"read from private field"),t?t.call(r):o.get(r)),u=(r,o,t)=>o.has(r)?M("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,t),n=(r,o,t,a)=>(T(r,o,"write to private field"),a?a.call(r,t):o.set(r,t),t),h=(r,o,t)=>(T(r,o,"access private method"),t);const S="avk-stacked-alpha";let E=!1;function P(){if(E)return;if(document.getElementById(S)){E=!0;return}E=!0;const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("style","position:absolute;width:0;height:0;overflow:hidden"),r.setAttribute("aria-hidden","true"),r.innerHTML=`<defs><filter id="${S}" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB"><feOffset in="SourceGraphic" dy="-0.5" result="s"/><feColorMatrix in="s" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0" result="a"/><feComposite in="SourceGraphic" in2="a" operator="in"/></filter></defs>`,document.body.prepend(r)}const H=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],B=new Set(["autoplay","loop","muted","playsinline"]),N=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","play","pause","ratechange","resize","volumechange"];var s,f,b,R,C;class V extends HTMLElement{constructor(){super();u(this,b);u(this,s);u(this,f,null);const t=this.attachShadow({mode:"open"});t.innerHTML=`<style>
2
- :host{display:inline-block;overflow:hidden}
3
- video{display:block;width:100%;filter:url(#${S})}
4
- </style><video></video>`,n(this,s,t.querySelector("video"));for(const a of N)e(this,s).addEventListener(a,y=>{this.dispatchEvent(new Event(y.type,{bubbles:!1,cancelable:!1}))});e(this,s).addEventListener("loadedmetadata",()=>{this.style.aspectRatio=`${e(this,s).videoWidth} / ${Math.floor(e(this,s).videoHeight/2)}`})}connectedCallback(){P();for(const t of H)this.hasAttribute(t)&&h(this,b,R).call(this,t,this.getAttribute(t));h(this,b,C).call(this),n(this,f,new MutationObserver(()=>h(this,b,C).call(this))),e(this,f).observe(this,{childList:!0})}disconnectedCallback(){var t;(t=e(this,f))==null||t.disconnect(),n(this,f,null)}attributeChangedCallback(t,a,y){h(this,b,R).call(this,t,y)}get src(){return e(this,s).src}set src(t){this.setAttribute("src",t)}get currentSrc(){return e(this,s).currentSrc}get currentTime(){return e(this,s).currentTime}set currentTime(t){e(this,s).currentTime=t}get duration(){return e(this,s).duration}get paused(){return e(this,s).paused}get ended(){return e(this,s).ended}get readyState(){return e(this,s).readyState}get videoWidth(){return e(this,s).videoWidth}get videoHeight(){return Math.floor(e(this,s).videoHeight/2)}get volume(){return e(this,s).volume}set volume(t){e(this,s).volume=t}get playbackRate(){return e(this,s).playbackRate}set playbackRate(t){e(this,s).playbackRate=t}get defaultPlaybackRate(){return e(this,s).defaultPlaybackRate}set defaultPlaybackRate(t){e(this,s).defaultPlaybackRate=t}get muted(){return e(this,s).muted}set muted(t){e(this,s).muted=t,this.toggleAttribute("muted",t)}get loop(){return e(this,s).loop}set loop(t){e(this,s).loop=t,this.toggleAttribute("loop",t)}get autoplay(){return e(this,s).autoplay}set autoplay(t){e(this,s).autoplay=t,this.toggleAttribute("autoplay",t)}get preload(){return e(this,s).preload}set preload(t){this.setAttribute("preload",t)}get crossOrigin(){return e(this,s).crossOrigin}set crossOrigin(t){t===null?this.removeAttribute("crossorigin"):this.setAttribute("crossorigin",t)}get buffered(){return e(this,s).buffered}get seekable(){return e(this,s).seekable}get played(){return e(this,s).played}get networkState(){return e(this,s).networkState}get error(){return e(this,s).error}get seeking(){return e(this,s).seeking}play(){return e(this,s).play()}pause(){e(this,s).pause()}load(){e(this,s).load()}canPlayType(t){return e(this,s).canPlayType(t)}}s=new WeakMap,f=new WeakMap,b=new WeakSet,R=function(t,a){B.has(t)?e(this,s)[t]=a!==null:a===null?e(this,s).removeAttribute(t):e(this,s).setAttribute(t,a)},C=function(){e(this,s).querySelectorAll("source").forEach(t=>t.remove()),this.querySelectorAll("source").forEach(t=>{e(this,s).appendChild(t.cloneNode(!0))}),e(this,s).querySelectorAll("source").length>0&&!e(this,s).src&&e(this,s).load()},w(V,"observedAttributes",[...H]);const I=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],W=new Set(["autoplay","loop","muted","playsinline"]),D=["loadstart","progress","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","play","pause","ratechange","resize","volumechange"];var i,d,k,m,v,c,p,g,l,O,L,$,A,q;class F extends HTMLElement{constructor(){super();u(this,l);u(this,i);u(this,d);u(this,k);u(this,m,null);u(this,v,null);u(this,c,!1);u(this,p,0);u(this,g,0);const t=this.attachShadow({mode:"open"});t.innerHTML=`<style>
5
- :host{display:inline-block;overflow:hidden}
6
- video{position:absolute;opacity:0;pointer-events:none;width:0;height:0}
7
- canvas{display:block;width:100%;filter:url(#${S})}
8
- </style><video></video><canvas></canvas>`,n(this,i,t.querySelector("video")),n(this,d,t.querySelector("canvas")),n(this,k,e(this,d).getContext("2d"));for(const a of D)e(this,i).addEventListener(a,y=>{this.dispatchEvent(new Event(y.type,{bubbles:!1,cancelable:!1}))});e(this,i).addEventListener("loadedmetadata",()=>{this.style.aspectRatio=`${e(this,i).videoWidth} / ${Math.floor(e(this,i).videoHeight/2)}`})}connectedCallback(){P();for(const t of I)this.hasAttribute(t)&&h(this,l,O).call(this,t,this.getAttribute(t));h(this,l,L).call(this),n(this,v,new MutationObserver(()=>h(this,l,L).call(this))),e(this,v).observe(this,{childList:!0}),n(this,m,new IntersectionObserver(([t])=>{n(this,c,t.isIntersecting),e(this,c)?h(this,l,$).call(this):h(this,l,A).call(this)},{threshold:0})),e(this,m).observe(this)}disconnectedCallback(){var t,a;h(this,l,A).call(this),(t=e(this,m))==null||t.disconnect(),n(this,m,null),(a=e(this,v))==null||a.disconnect(),n(this,v,null)}attributeChangedCallback(t,a,y){h(this,l,O).call(this,t,y)}get src(){return e(this,i).src}set src(t){this.setAttribute("src",t)}get currentSrc(){return e(this,i).currentSrc}get currentTime(){return e(this,i).currentTime}set currentTime(t){e(this,i).currentTime=t}get duration(){return e(this,i).duration}get paused(){return e(this,i).paused}get ended(){return e(this,i).ended}get readyState(){return e(this,i).readyState}get videoWidth(){return e(this,i).videoWidth}get videoHeight(){return Math.floor(e(this,i).videoHeight/2)}get volume(){return e(this,i).volume}set volume(t){e(this,i).volume=t}get playbackRate(){return e(this,i).playbackRate}set playbackRate(t){e(this,i).playbackRate=t}get defaultPlaybackRate(){return e(this,i).defaultPlaybackRate}set defaultPlaybackRate(t){e(this,i).defaultPlaybackRate=t}get muted(){return e(this,i).muted}set muted(t){e(this,i).muted=t,this.toggleAttribute("muted",t)}get loop(){return e(this,i).loop}set loop(t){e(this,i).loop=t,this.toggleAttribute("loop",t)}get autoplay(){return e(this,i).autoplay}set autoplay(t){e(this,i).autoplay=t,this.toggleAttribute("autoplay",t)}get preload(){return e(this,i).preload}set preload(t){this.setAttribute("preload",t)}get crossOrigin(){return e(this,i).crossOrigin}set crossOrigin(t){t===null?this.removeAttribute("crossorigin"):this.setAttribute("crossorigin",t)}get buffered(){return e(this,i).buffered}get seekable(){return e(this,i).seekable}get played(){return e(this,i).played}get networkState(){return e(this,i).networkState}get error(){return e(this,i).error}get seeking(){return e(this,i).seeking}play(){return e(this,i).play()}pause(){e(this,i).pause()}load(){e(this,i).load()}canPlayType(t){return e(this,i).canPlayType(t)}}i=new WeakMap,d=new WeakMap,k=new WeakMap,m=new WeakMap,v=new WeakMap,c=new WeakMap,p=new WeakMap,g=new WeakMap,l=new WeakSet,O=function(t,a){W.has(t)?e(this,i)[t]=a!==null:a===null?e(this,i).removeAttribute(t):e(this,i).setAttribute(t,a)},L=function(){e(this,i).querySelectorAll("source").forEach(t=>t.remove()),this.querySelectorAll("source").forEach(t=>{e(this,i).appendChild(t.cloneNode(!0))}),e(this,i).querySelectorAll("source").length>0&&!e(this,i).src&&e(this,i).load()},$=function(){if(e(this,c))if(h(this,l,A).call(this),"requestVideoFrameCallback"in e(this,i)){const t=()=>{e(this,c)&&(h(this,l,q).call(this),n(this,g,e(this,i).requestVideoFrameCallback(t)))};n(this,g,e(this,i).requestVideoFrameCallback(t))}else{const t=()=>{e(this,c)&&(h(this,l,q).call(this),n(this,p,requestAnimationFrame(t)))};n(this,p,requestAnimationFrame(t))}},A=function(){var t,a;e(this,g)&&((a=(t=e(this,i)).cancelVideoFrameCallback)==null||a.call(t,e(this,g)),n(this,g,0)),e(this,p)&&(cancelAnimationFrame(e(this,p)),n(this,p,0))},q=function(){if(e(this,i).readyState<2)return;const t=e(this,i).videoWidth,a=e(this,i).videoHeight;(e(this,d).width!==t||e(this,d).height!==a)&&(e(this,d).width=t,e(this,d).height=a),e(this,k).drawImage(e(this,i),0,0)},w(F,"observedAttributes",[...I]);exports.AlphaVideoKitCanvas=F;exports.AlphaVideoKitSVG=V;
@@ -1,435 +0,0 @@
1
- var F = Object.defineProperty;
2
- var M = (r) => {
3
- throw TypeError(r);
4
- };
5
- var $ = (r, o, t) => o in r ? F(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t;
6
- var w = (r, o, t) => $(r, typeof o != "symbol" ? o + "" : o, t), T = (r, o, t) => o.has(r) || M("Cannot " + t);
7
- var e = (r, o, t) => (T(r, o, "read from private field"), t ? t.call(r) : o.get(r)), u = (r, o, t) => o.has(r) ? M("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(r) : o.set(r, t), n = (r, o, t, a) => (T(r, o, "write to private field"), a ? a.call(r, t) : o.set(r, t), t), h = (r, o, t) => (T(r, o, "access private method"), t);
8
- const S = "avk-stacked-alpha";
9
- let E = !1;
10
- function P() {
11
- if (E) return;
12
- if (document.getElementById(S)) {
13
- E = !0;
14
- return;
15
- }
16
- E = !0;
17
- const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
18
- r.setAttribute("style", "position:absolute;width:0;height:0;overflow:hidden"), r.setAttribute("aria-hidden", "true"), r.innerHTML = `<defs><filter id="${S}" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB"><feOffset in="SourceGraphic" dy="-0.5" result="s"/><feColorMatrix in="s" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0" result="a"/><feComposite in="SourceGraphic" in2="a" operator="in"/></filter></defs>`, document.body.prepend(r);
19
- }
20
- const H = [
21
- "src",
22
- "crossorigin",
23
- "preload",
24
- "autoplay",
25
- "loop",
26
- "muted",
27
- "playsinline",
28
- "poster",
29
- "width",
30
- "height"
31
- ], V = /* @__PURE__ */ new Set(["autoplay", "loop", "muted", "playsinline"]), _ = [
32
- "loadstart",
33
- "progress",
34
- "suspend",
35
- "abort",
36
- "error",
37
- "emptied",
38
- "stalled",
39
- "loadedmetadata",
40
- "loadeddata",
41
- "canplay",
42
- "canplaythrough",
43
- "playing",
44
- "waiting",
45
- "seeking",
46
- "seeked",
47
- "ended",
48
- "durationchange",
49
- "timeupdate",
50
- "play",
51
- "pause",
52
- "ratechange",
53
- "resize",
54
- "volumechange"
55
- ];
56
- var s, f, b, R, C;
57
- class B extends HTMLElement {
58
- constructor() {
59
- super();
60
- u(this, b);
61
- u(this, s);
62
- u(this, f, null);
63
- const t = this.attachShadow({ mode: "open" });
64
- t.innerHTML = `<style>
65
- :host{display:inline-block;overflow:hidden}
66
- video{display:block;width:100%;filter:url(#${S})}
67
- </style><video></video>`, n(this, s, t.querySelector("video"));
68
- for (const a of _)
69
- e(this, s).addEventListener(a, (y) => {
70
- this.dispatchEvent(new Event(y.type, { bubbles: !1, cancelable: !1 }));
71
- });
72
- e(this, s).addEventListener("loadedmetadata", () => {
73
- this.style.aspectRatio = `${e(this, s).videoWidth} / ${Math.floor(e(this, s).videoHeight / 2)}`;
74
- });
75
- }
76
- connectedCallback() {
77
- P();
78
- for (const t of H)
79
- this.hasAttribute(t) && h(this, b, R).call(this, t, this.getAttribute(t));
80
- h(this, b, C).call(this), n(this, f, new MutationObserver(() => h(this, b, C).call(this))), e(this, f).observe(this, { childList: !0 });
81
- }
82
- disconnectedCallback() {
83
- var t;
84
- (t = e(this, f)) == null || t.disconnect(), n(this, f, null);
85
- }
86
- attributeChangedCallback(t, a, y) {
87
- h(this, b, R).call(this, t, y);
88
- }
89
- // --- Proxied properties ---
90
- get src() {
91
- return e(this, s).src;
92
- }
93
- set src(t) {
94
- this.setAttribute("src", t);
95
- }
96
- get currentSrc() {
97
- return e(this, s).currentSrc;
98
- }
99
- get currentTime() {
100
- return e(this, s).currentTime;
101
- }
102
- set currentTime(t) {
103
- e(this, s).currentTime = t;
104
- }
105
- get duration() {
106
- return e(this, s).duration;
107
- }
108
- get paused() {
109
- return e(this, s).paused;
110
- }
111
- get ended() {
112
- return e(this, s).ended;
113
- }
114
- get readyState() {
115
- return e(this, s).readyState;
116
- }
117
- get videoWidth() {
118
- return e(this, s).videoWidth;
119
- }
120
- get videoHeight() {
121
- return Math.floor(e(this, s).videoHeight / 2);
122
- }
123
- get volume() {
124
- return e(this, s).volume;
125
- }
126
- set volume(t) {
127
- e(this, s).volume = t;
128
- }
129
- get playbackRate() {
130
- return e(this, s).playbackRate;
131
- }
132
- set playbackRate(t) {
133
- e(this, s).playbackRate = t;
134
- }
135
- get defaultPlaybackRate() {
136
- return e(this, s).defaultPlaybackRate;
137
- }
138
- set defaultPlaybackRate(t) {
139
- e(this, s).defaultPlaybackRate = t;
140
- }
141
- get muted() {
142
- return e(this, s).muted;
143
- }
144
- set muted(t) {
145
- e(this, s).muted = t, this.toggleAttribute("muted", t);
146
- }
147
- get loop() {
148
- return e(this, s).loop;
149
- }
150
- set loop(t) {
151
- e(this, s).loop = t, this.toggleAttribute("loop", t);
152
- }
153
- get autoplay() {
154
- return e(this, s).autoplay;
155
- }
156
- set autoplay(t) {
157
- e(this, s).autoplay = t, this.toggleAttribute("autoplay", t);
158
- }
159
- get preload() {
160
- return e(this, s).preload;
161
- }
162
- set preload(t) {
163
- this.setAttribute("preload", t);
164
- }
165
- get crossOrigin() {
166
- return e(this, s).crossOrigin;
167
- }
168
- set crossOrigin(t) {
169
- t === null ? this.removeAttribute("crossorigin") : this.setAttribute("crossorigin", t);
170
- }
171
- get buffered() {
172
- return e(this, s).buffered;
173
- }
174
- get seekable() {
175
- return e(this, s).seekable;
176
- }
177
- get played() {
178
- return e(this, s).played;
179
- }
180
- get networkState() {
181
- return e(this, s).networkState;
182
- }
183
- get error() {
184
- return e(this, s).error;
185
- }
186
- get seeking() {
187
- return e(this, s).seeking;
188
- }
189
- // --- Proxied methods ---
190
- play() {
191
- return e(this, s).play();
192
- }
193
- pause() {
194
- e(this, s).pause();
195
- }
196
- load() {
197
- e(this, s).load();
198
- }
199
- canPlayType(t) {
200
- return e(this, s).canPlayType(t);
201
- }
202
- }
203
- s = new WeakMap(), f = new WeakMap(), b = new WeakSet(), R = function(t, a) {
204
- V.has(t) ? e(this, s)[t] = a !== null : a === null ? e(this, s).removeAttribute(t) : e(this, s).setAttribute(t, a);
205
- }, C = function() {
206
- e(this, s).querySelectorAll("source").forEach((t) => t.remove()), this.querySelectorAll("source").forEach((t) => {
207
- e(this, s).appendChild(t.cloneNode(!0));
208
- }), e(this, s).querySelectorAll("source").length > 0 && !e(this, s).src && e(this, s).load();
209
- }, w(B, "observedAttributes", [...H]);
210
- const I = [
211
- "src",
212
- "crossorigin",
213
- "preload",
214
- "autoplay",
215
- "loop",
216
- "muted",
217
- "playsinline",
218
- "poster",
219
- "width",
220
- "height"
221
- ], N = /* @__PURE__ */ new Set(["autoplay", "loop", "muted", "playsinline"]), W = [
222
- "loadstart",
223
- "progress",
224
- "suspend",
225
- "abort",
226
- "error",
227
- "emptied",
228
- "stalled",
229
- "loadedmetadata",
230
- "loadeddata",
231
- "canplay",
232
- "canplaythrough",
233
- "playing",
234
- "waiting",
235
- "seeking",
236
- "seeked",
237
- "ended",
238
- "durationchange",
239
- "timeupdate",
240
- "play",
241
- "pause",
242
- "ratechange",
243
- "resize",
244
- "volumechange"
245
- ];
246
- var i, d, k, m, v, c, p, g, l, O, L, x, A, q;
247
- class D extends HTMLElement {
248
- constructor() {
249
- super();
250
- u(this, l);
251
- u(this, i);
252
- u(this, d);
253
- u(this, k);
254
- u(this, m, null);
255
- u(this, v, null);
256
- u(this, c, !1);
257
- u(this, p, 0);
258
- u(this, g, 0);
259
- const t = this.attachShadow({ mode: "open" });
260
- t.innerHTML = `<style>
261
- :host{display:inline-block;overflow:hidden}
262
- video{position:absolute;opacity:0;pointer-events:none;width:0;height:0}
263
- canvas{display:block;width:100%;filter:url(#${S})}
264
- </style><video></video><canvas></canvas>`, n(this, i, t.querySelector("video")), n(this, d, t.querySelector("canvas")), n(this, k, e(this, d).getContext("2d"));
265
- for (const a of W)
266
- e(this, i).addEventListener(a, (y) => {
267
- this.dispatchEvent(new Event(y.type, { bubbles: !1, cancelable: !1 }));
268
- });
269
- e(this, i).addEventListener("loadedmetadata", () => {
270
- this.style.aspectRatio = `${e(this, i).videoWidth} / ${Math.floor(e(this, i).videoHeight / 2)}`;
271
- });
272
- }
273
- connectedCallback() {
274
- P();
275
- for (const t of I)
276
- this.hasAttribute(t) && h(this, l, O).call(this, t, this.getAttribute(t));
277
- h(this, l, L).call(this), n(this, v, new MutationObserver(() => h(this, l, L).call(this))), e(this, v).observe(this, { childList: !0 }), n(this, m, new IntersectionObserver(
278
- ([t]) => {
279
- n(this, c, t.isIntersecting), e(this, c) ? h(this, l, x).call(this) : h(this, l, A).call(this);
280
- },
281
- { threshold: 0 }
282
- )), e(this, m).observe(this);
283
- }
284
- disconnectedCallback() {
285
- var t, a;
286
- h(this, l, A).call(this), (t = e(this, m)) == null || t.disconnect(), n(this, m, null), (a = e(this, v)) == null || a.disconnect(), n(this, v, null);
287
- }
288
- attributeChangedCallback(t, a, y) {
289
- h(this, l, O).call(this, t, y);
290
- }
291
- // --- Proxied properties ---
292
- get src() {
293
- return e(this, i).src;
294
- }
295
- set src(t) {
296
- this.setAttribute("src", t);
297
- }
298
- get currentSrc() {
299
- return e(this, i).currentSrc;
300
- }
301
- get currentTime() {
302
- return e(this, i).currentTime;
303
- }
304
- set currentTime(t) {
305
- e(this, i).currentTime = t;
306
- }
307
- get duration() {
308
- return e(this, i).duration;
309
- }
310
- get paused() {
311
- return e(this, i).paused;
312
- }
313
- get ended() {
314
- return e(this, i).ended;
315
- }
316
- get readyState() {
317
- return e(this, i).readyState;
318
- }
319
- get videoWidth() {
320
- return e(this, i).videoWidth;
321
- }
322
- get videoHeight() {
323
- return Math.floor(e(this, i).videoHeight / 2);
324
- }
325
- get volume() {
326
- return e(this, i).volume;
327
- }
328
- set volume(t) {
329
- e(this, i).volume = t;
330
- }
331
- get playbackRate() {
332
- return e(this, i).playbackRate;
333
- }
334
- set playbackRate(t) {
335
- e(this, i).playbackRate = t;
336
- }
337
- get defaultPlaybackRate() {
338
- return e(this, i).defaultPlaybackRate;
339
- }
340
- set defaultPlaybackRate(t) {
341
- e(this, i).defaultPlaybackRate = t;
342
- }
343
- get muted() {
344
- return e(this, i).muted;
345
- }
346
- set muted(t) {
347
- e(this, i).muted = t, this.toggleAttribute("muted", t);
348
- }
349
- get loop() {
350
- return e(this, i).loop;
351
- }
352
- set loop(t) {
353
- e(this, i).loop = t, this.toggleAttribute("loop", t);
354
- }
355
- get autoplay() {
356
- return e(this, i).autoplay;
357
- }
358
- set autoplay(t) {
359
- e(this, i).autoplay = t, this.toggleAttribute("autoplay", t);
360
- }
361
- get preload() {
362
- return e(this, i).preload;
363
- }
364
- set preload(t) {
365
- this.setAttribute("preload", t);
366
- }
367
- get crossOrigin() {
368
- return e(this, i).crossOrigin;
369
- }
370
- set crossOrigin(t) {
371
- t === null ? this.removeAttribute("crossorigin") : this.setAttribute("crossorigin", t);
372
- }
373
- get buffered() {
374
- return e(this, i).buffered;
375
- }
376
- get seekable() {
377
- return e(this, i).seekable;
378
- }
379
- get played() {
380
- return e(this, i).played;
381
- }
382
- get networkState() {
383
- return e(this, i).networkState;
384
- }
385
- get error() {
386
- return e(this, i).error;
387
- }
388
- get seeking() {
389
- return e(this, i).seeking;
390
- }
391
- // --- Proxied methods ---
392
- play() {
393
- return e(this, i).play();
394
- }
395
- pause() {
396
- e(this, i).pause();
397
- }
398
- load() {
399
- e(this, i).load();
400
- }
401
- canPlayType(t) {
402
- return e(this, i).canPlayType(t);
403
- }
404
- }
405
- i = new WeakMap(), d = new WeakMap(), k = new WeakMap(), m = new WeakMap(), v = new WeakMap(), c = new WeakMap(), p = new WeakMap(), g = new WeakMap(), l = new WeakSet(), O = function(t, a) {
406
- N.has(t) ? e(this, i)[t] = a !== null : a === null ? e(this, i).removeAttribute(t) : e(this, i).setAttribute(t, a);
407
- }, L = function() {
408
- e(this, i).querySelectorAll("source").forEach((t) => t.remove()), this.querySelectorAll("source").forEach((t) => {
409
- e(this, i).appendChild(t.cloneNode(!0));
410
- }), e(this, i).querySelectorAll("source").length > 0 && !e(this, i).src && e(this, i).load();
411
- }, x = function() {
412
- if (e(this, c))
413
- if (h(this, l, A).call(this), "requestVideoFrameCallback" in e(this, i)) {
414
- const t = () => {
415
- e(this, c) && (h(this, l, q).call(this), n(this, g, e(this, i).requestVideoFrameCallback(t)));
416
- };
417
- n(this, g, e(this, i).requestVideoFrameCallback(t));
418
- } else {
419
- const t = () => {
420
- e(this, c) && (h(this, l, q).call(this), n(this, p, requestAnimationFrame(t)));
421
- };
422
- n(this, p, requestAnimationFrame(t));
423
- }
424
- }, A = function() {
425
- var t, a;
426
- e(this, g) && ((a = (t = e(this, i)).cancelVideoFrameCallback) == null || a.call(t, e(this, g)), n(this, g, 0)), e(this, p) && (cancelAnimationFrame(e(this, p)), n(this, p, 0));
427
- }, q = function() {
428
- if (e(this, i).readyState < 2) return;
429
- const t = e(this, i).videoWidth, a = e(this, i).videoHeight;
430
- (e(this, d).width !== t || e(this, d).height !== a) && (e(this, d).width = t, e(this, d).height = a), e(this, k).drawImage(e(this, i), 0, 0);
431
- }, w(D, "observedAttributes", [...I]);
432
- export {
433
- D as A,
434
- B as a
435
- };