@alpha-video-kit/svg 0.3.1 → 0.3.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.
@@ -41,36 +41,36 @@ const Y = [
41
41
  "resize",
42
42
  "volumechange"
43
43
  ];
44
- var s, L, E, O, N, y, T, c, _, G, W;
44
+ var s, L, O, T, N, y, C, c, _, G, W;
45
45
  class it extends HTMLElement {
46
46
  constructor() {
47
47
  super();
48
48
  u(this, c);
49
49
  u(this, s);
50
50
  u(this, L);
51
- u(this, E);
52
51
  u(this, O);
52
+ u(this, T);
53
53
  u(this, N);
54
54
  u(this, y, null);
55
- u(this, T);
55
+ u(this, C);
56
56
  const t = this.attachShadow({ mode: "open" });
57
- a(this, T, `avk-${Math.random().toString(36).slice(2, 8)}`), t.innerHTML = `<style>
57
+ a(this, C, `avk-${Math.random().toString(36).slice(2, 8)}`), t.innerHTML = `<style>
58
58
  :host{display:inline-block;overflow:hidden}
59
59
  svg{display:block;width:100%;height:auto}
60
60
  video{display:block;width:100%;height:100%}
61
61
  </style>
62
62
  <svg viewBox="0 0 1 1" preserveAspectRatio="xMidYMid meet">
63
63
  <defs>
64
- <filter id="${e(this, T)}" filterUnits="userSpaceOnUse" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
64
+ <filter id="${e(this, C)}" filterUnits="userSpaceOnUse" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
65
65
  <feOffset in="SourceGraphic" dy="0" result="s"/>
66
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
67
  <feComposite in="SourceGraphic" in2="a" operator="in"/>
68
68
  </filter>
69
69
  </defs>
70
- <foreignObject width="1" height="1" filter="url(#${e(this, T)})">
70
+ <foreignObject width="1" height="1" filter="url(#${e(this, C)})">
71
71
  <video></video>
72
72
  </foreignObject>
73
- </svg>`, a(this, L, t.querySelector("svg")), a(this, E, t.querySelector("foreignObject")), a(this, O, t.querySelector("filter")), a(this, N, t.querySelector("feOffset")), a(this, s, t.querySelector("video"));
73
+ </svg>`, a(this, L, t.querySelector("svg")), a(this, O, t.querySelector("foreignObject")), a(this, T, t.querySelector("filter")), a(this, N, t.querySelector("feOffset")), a(this, s, t.querySelector("video"));
74
74
  for (const r of et)
75
75
  e(this, s).addEventListener(r, (o) => {
76
76
  this.dispatchEvent(new Event(o.type, { bubbles: !1, cancelable: !1 }));
@@ -203,11 +203,11 @@ video{display:block;width:100%;height:100%}
203
203
  return e(this, s).canPlayType(t);
204
204
  }
205
205
  }
206
- s = new WeakMap(), L = new WeakMap(), E = new WeakMap(), O = new WeakMap(), N = new WeakMap(), y = new WeakMap(), T = new WeakMap(), c = new WeakSet(), _ = function() {
206
+ s = new WeakMap(), L = new WeakMap(), O = new WeakMap(), T = new WeakMap(), N = new WeakMap(), y = new WeakMap(), C = new WeakMap(), c = new WeakSet(), _ = function() {
207
207
  const t = e(this, s).videoWidth, r = e(this, s).videoHeight;
208
208
  if (!t || !r) return;
209
209
  const o = Math.floor(r / 2);
210
- e(this, L).setAttribute("viewBox", `0 0 ${t} ${o}`), e(this, E).setAttribute("width", String(t)), e(this, E).setAttribute("height", String(r)), e(this, O).setAttribute("width", String(t)), e(this, O).setAttribute("height", String(r)), e(this, N).setAttribute("dy", String(-o));
210
+ e(this, L).setAttribute("viewBox", `0 0 ${t} ${o}`), e(this, O).setAttribute("width", String(t)), e(this, O).setAttribute("height", String(r)), e(this, T).setAttribute("width", String(t)), e(this, T).setAttribute("height", String(r)), e(this, N).setAttribute("dy", String(-o));
211
211
  }, G = function(t, r) {
212
212
  tt.has(t) ? e(this, s)[t] = r !== null : r === null ? e(this, s).removeAttribute(t) : e(this, s).setAttribute(t, r);
213
213
  }, W = function() {
@@ -215,7 +215,7 @@ s = new WeakMap(), L = new WeakMap(), E = new WeakMap(), O = new WeakMap(), N =
215
215
  e(this, s).appendChild(t.cloneNode(!0));
216
216
  }), e(this, s).querySelectorAll("source").length > 0 && !e(this, s).src && e(this, s).load();
217
217
  }, V(it, "observedAttributes", [...Y]);
218
- const w = "http://www.w3.org/2000/svg", J = [
218
+ const E = "http://www.w3.org/2000/svg", J = [
219
219
  "src",
220
220
  "crossorigin",
221
221
  "preload",
@@ -251,25 +251,25 @@ const w = "http://www.w3.org/2000/svg", J = [
251
251
  "resize",
252
252
  "volumechange"
253
253
  ];
254
- var i, m, C, g, R, v, A, p, b, f, M, S, k, q, h, B, K, P, D, z, Q, F, U;
254
+ var i, m, R, g, v, A, S, p, b, f, M, k, w, q, h, B, K, P, D, z, Q, F, U;
255
255
  class at extends HTMLElement {
256
256
  constructor() {
257
257
  super();
258
258
  u(this, h);
259
259
  u(this, i);
260
260
  u(this, m);
261
- u(this, C);
262
- u(this, g);
263
261
  u(this, R);
264
- u(this, v, null);
262
+ u(this, g);
263
+ u(this, v);
265
264
  u(this, A, null);
265
+ u(this, S, null);
266
266
  u(this, p, !1);
267
267
  u(this, b, 0);
268
268
  u(this, f, 0);
269
269
  // SVG filter (lives in document.body so ctx.filter url() can resolve it)
270
270
  u(this, M);
271
- u(this, S, null);
272
271
  u(this, k, null);
272
+ u(this, w, null);
273
273
  u(this, q, null);
274
274
  const t = this.attachShadow({ mode: "open" });
275
275
  a(this, M, `avk-c-${Math.random().toString(36).slice(2, 8)}`), t.innerHTML = `<style>
@@ -278,7 +278,7 @@ video{position:absolute;opacity:0;pointer-events:none;width:0;height:0}
278
278
  canvas{display:block;width:100%}
279
279
  </style>
280
280
  <video></video>
281
- <canvas></canvas>`, a(this, i, t.querySelector("video")), a(this, m, t.querySelector("canvas")), a(this, C, e(this, m).getContext("2d")), a(this, g, document.createElement("canvas")), a(this, R, e(this, g).getContext("2d"));
281
+ <canvas></canvas>`, a(this, i, t.querySelector("video")), a(this, m, t.querySelector("canvas")), a(this, R, e(this, m).getContext("2d")), a(this, g, document.createElement("canvas")), a(this, v, e(this, g).getContext("2d"));
282
282
  for (const r of rt)
283
283
  e(this, i).addEventListener(r, (o) => {
284
284
  this.dispatchEvent(new Event(o.type, { bubbles: !1, cancelable: !1 }));
@@ -288,16 +288,16 @@ canvas{display:block;width:100%}
288
288
  connectedCallback() {
289
289
  for (const t of J)
290
290
  this.hasAttribute(t) && d(this, h, D).call(this, t, this.getAttribute(t));
291
- d(this, h, z).call(this), a(this, A, new MutationObserver(() => d(this, h, z).call(this))), e(this, A).observe(this, { childList: !0 }), d(this, h, B).call(this), a(this, v, new IntersectionObserver(
291
+ d(this, h, z).call(this), a(this, S, new MutationObserver(() => d(this, h, z).call(this))), e(this, S).observe(this, { childList: !0 }), d(this, h, B).call(this), a(this, A, new IntersectionObserver(
292
292
  ([t]) => {
293
293
  a(this, p, t.isIntersecting), e(this, p) ? d(this, h, Q).call(this) : d(this, h, F).call(this);
294
294
  },
295
295
  { threshold: 0 }
296
- )), e(this, v).observe(this);
296
+ )), e(this, A).observe(this);
297
297
  }
298
298
  disconnectedCallback() {
299
299
  var t, r;
300
- d(this, h, F).call(this), (t = e(this, v)) == null || t.disconnect(), a(this, v, null), (r = e(this, A)) == null || r.disconnect(), a(this, A, null), d(this, h, K).call(this);
300
+ d(this, h, F).call(this), (t = e(this, A)) == null || t.disconnect(), a(this, A, null), (r = e(this, S)) == null || r.disconnect(), a(this, S, null), d(this, h, K).call(this);
301
301
  }
302
302
  attributeChangedCallback(t, r, o) {
303
303
  d(this, h, D).call(this, t, o);
@@ -416,26 +416,26 @@ canvas{display:block;width:100%}
416
416
  return e(this, i).canPlayType(t);
417
417
  }
418
418
  }
419
- i = new WeakMap(), m = new WeakMap(), C = new WeakMap(), g = new WeakMap(), R = new WeakMap(), v = new WeakMap(), A = new WeakMap(), p = new WeakMap(), b = new WeakMap(), f = new WeakMap(), M = new WeakMap(), S = new WeakMap(), k = new WeakMap(), q = new WeakMap(), h = new WeakSet(), B = function() {
420
- if (e(this, S)) return;
421
- const t = document.createElementNS(w, "svg");
419
+ i = new WeakMap(), m = new WeakMap(), R = new WeakMap(), g = new WeakMap(), v = new WeakMap(), A = new WeakMap(), S = new WeakMap(), p = new WeakMap(), b = new WeakMap(), f = new WeakMap(), M = new WeakMap(), k = new WeakMap(), w = new WeakMap(), q = new WeakMap(), h = new WeakSet(), B = function() {
420
+ if (e(this, k)) return;
421
+ const t = document.createElementNS(E, "svg");
422
422
  t.setAttribute("width", "0"), t.setAttribute("height", "0"), t.style.cssText = "position:absolute;overflow:hidden";
423
- const r = document.createElementNS(w, "defs"), o = document.createElementNS(w, "filter");
423
+ const r = document.createElementNS(E, "defs"), o = document.createElementNS(E, "filter");
424
424
  o.id = e(this, M), o.setAttribute("filterUnits", "userSpaceOnUse"), o.setAttribute("x", "0"), o.setAttribute("y", "0"), o.setAttribute("width", "1"), o.setAttribute("height", "1"), o.setAttribute("color-interpolation-filters", "sRGB");
425
- const x = document.createElementNS(w, "feOffset");
425
+ const x = document.createElementNS(E, "feOffset");
426
426
  x.setAttribute("in", "SourceGraphic"), x.setAttribute("dy", "0"), x.setAttribute("result", "s");
427
- const H = document.createElementNS(w, "feColorMatrix");
427
+ const H = document.createElementNS(E, "feColorMatrix");
428
428
  H.setAttribute("in", "s"), H.setAttribute("type", "matrix"), H.setAttribute("values", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"), H.setAttribute("result", "a");
429
- const I = document.createElementNS(w, "feComposite");
430
- I.setAttribute("in", "SourceGraphic"), I.setAttribute("in2", "a"), I.setAttribute("operator", "in"), o.append(x, H, I), r.appendChild(o), t.appendChild(r), document.body.appendChild(t), a(this, S, t), a(this, k, o), a(this, q, x);
429
+ const I = document.createElementNS(E, "feComposite");
430
+ I.setAttribute("in", "SourceGraphic"), I.setAttribute("in2", "a"), I.setAttribute("operator", "in"), o.append(x, H, I), r.appendChild(o), t.appendChild(r), document.body.appendChild(t), a(this, k, t), a(this, w, o), a(this, q, x);
431
431
  }, K = function() {
432
432
  var t;
433
- (t = e(this, S)) == null || t.remove(), a(this, S, null), a(this, k, null), a(this, q, null);
433
+ (t = e(this, k)) == null || t.remove(), a(this, k, null), a(this, w, null), a(this, q, null);
434
434
  }, P = function() {
435
435
  const t = e(this, i).videoWidth, r = e(this, i).videoHeight;
436
436
  if (!t || !r) return;
437
437
  const o = Math.floor(r / 2);
438
- e(this, m).width = t, e(this, m).height = o, e(this, g).width = t, e(this, g).height = r, d(this, h, B).call(this), e(this, k).setAttribute("width", String(t)), e(this, k).setAttribute("height", String(r)), e(this, q).setAttribute("dy", String(-o));
438
+ e(this, m).width = t, e(this, m).height = o, e(this, g).width = t, e(this, g).height = r, d(this, h, B).call(this), e(this, w).setAttribute("width", String(t)), e(this, w).setAttribute("height", String(r)), e(this, q).setAttribute("dy", String(-o));
439
439
  }, D = function(t, r) {
440
440
  st.has(t) ? e(this, i)[t] = r !== null : r === null ? e(this, i).removeAttribute(t) : e(this, i).setAttribute(t, r);
441
441
  }, z = function() {
@@ -463,7 +463,7 @@ i = new WeakMap(), m = new WeakMap(), C = new WeakMap(), g = new WeakMap(), R =
463
463
  const t = e(this, i).videoWidth, r = e(this, i).videoHeight;
464
464
  if (!t || !r) return;
465
465
  const o = Math.floor(r / 2);
466
- (e(this, g).width !== t || e(this, g).height !== r) && d(this, h, P).call(this), e(this, R).filter = `url(#${e(this, M)})`, e(this, R).drawImage(e(this, i), 0, 0), e(this, C).clearRect(0, 0, t, o), e(this, C).drawImage(e(this, g), 0, 0, t, o, 0, 0, t, o);
466
+ (e(this, g).width !== t || e(this, g).height !== r) && d(this, h, P).call(this), e(this, v).clearRect(0, 0, t, r), e(this, v).filter = `url(#${e(this, M)})`, e(this, v).drawImage(e(this, i), 0, 0), e(this, R).clearRect(0, 0, t, o), e(this, R).drawImage(e(this, g), 0, 0, t, o, 0, 0, t, o);
467
467
  }, V(at, "observedAttributes", [...J]);
468
468
  export {
469
469
  at as A,
@@ -1,23 +1,23 @@
1
- "use strict";var tt=Object.defineProperty;var j=n=>{throw TypeError(n)};var et=(n,l,t)=>l in n?tt(n,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[l]=t;var F=(n,l,t)=>et(n,typeof l!="symbol"?l+"":l,t),$=(n,l,t)=>l.has(n)||j("Cannot "+t);var e=(n,l,t)=>($(n,l,"read from private field"),t?t.call(n):l.get(n)),u=(n,l,t)=>l.has(n)?j("Cannot add the same private member more than once"):l instanceof WeakSet?l.add(n):l.set(n,t),a=(n,l,t,r)=>($(n,l,"write to private field"),r?r.call(n,t):l.set(n,t),t),d=(n,l,t)=>($(n,l,"access private method"),t);const K=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],it=new Set(["autoplay","loop","muted","playsinline"]),st=["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,L,E,O,N,y,C,c,_,G,W;class J extends HTMLElement{constructor(){super();u(this,c);u(this,s);u(this,L);u(this,E);u(this,O);u(this,N);u(this,y,null);u(this,C);const t=this.attachShadow({mode:"open"});a(this,C,`avk-${Math.random().toString(36).slice(2,8)}`),t.innerHTML=`<style>
1
+ "use strict";var tt=Object.defineProperty;var j=n=>{throw TypeError(n)};var et=(n,l,t)=>l in n?tt(n,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[l]=t;var F=(n,l,t)=>et(n,typeof l!="symbol"?l+"":l,t),$=(n,l,t)=>l.has(n)||j("Cannot "+t);var e=(n,l,t)=>($(n,l,"read from private field"),t?t.call(n):l.get(n)),u=(n,l,t)=>l.has(n)?j("Cannot add the same private member more than once"):l instanceof WeakSet?l.add(n):l.set(n,t),a=(n,l,t,r)=>($(n,l,"write to private field"),r?r.call(n,t):l.set(n,t),t),d=(n,l,t)=>($(n,l,"access private method"),t);const K=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],it=new Set(["autoplay","loop","muted","playsinline"]),st=["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,L,O,C,N,y,T,c,_,G,W;class J extends HTMLElement{constructor(){super();u(this,c);u(this,s);u(this,L);u(this,O);u(this,C);u(this,N);u(this,y,null);u(this,T);const t=this.attachShadow({mode:"open"});a(this,T,`avk-${Math.random().toString(36).slice(2,8)}`),t.innerHTML=`<style>
2
2
  :host{display:inline-block;overflow:hidden}
3
3
  svg{display:block;width:100%;height:auto}
4
4
  video{display:block;width:100%;height:100%}
5
5
  </style>
6
6
  <svg viewBox="0 0 1 1" preserveAspectRatio="xMidYMid meet">
7
7
  <defs>
8
- <filter id="${e(this,C)}" filterUnits="userSpaceOnUse" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
8
+ <filter id="${e(this,T)}" filterUnits="userSpaceOnUse" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
9
9
  <feOffset in="SourceGraphic" dy="0" result="s"/>
10
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
11
  <feComposite in="SourceGraphic" in2="a" operator="in"/>
12
12
  </filter>
13
13
  </defs>
14
- <foreignObject width="1" height="1" filter="url(#${e(this,C)})">
14
+ <foreignObject width="1" height="1" filter="url(#${e(this,T)})">
15
15
  <video></video>
16
16
  </foreignObject>
17
- </svg>`,a(this,L,t.querySelector("svg")),a(this,E,t.querySelector("foreignObject")),a(this,O,t.querySelector("filter")),a(this,N,t.querySelector("feOffset")),a(this,s,t.querySelector("video"));for(const r of st)e(this,s).addEventListener(r,o=>{this.dispatchEvent(new Event(o.type,{bubbles:!1,cancelable:!1}))});e(this,s).addEventListener("loadedmetadata",()=>d(this,c,_).call(this)),e(this,s).addEventListener("resize",()=>d(this,c,_).call(this))}connectedCallback(){for(const t of K)this.hasAttribute(t)&&d(this,c,G).call(this,t,this.getAttribute(t));d(this,c,W).call(this),a(this,y,new MutationObserver(()=>d(this,c,W).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,o){d(this,c,G).call(this,t,o)}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,L=new WeakMap,E=new WeakMap,O=new WeakMap,N=new WeakMap,y=new WeakMap,C=new WeakMap,c=new WeakSet,_=function(){const t=e(this,s).videoWidth,r=e(this,s).videoHeight;if(!t||!r)return;const o=Math.floor(r/2);e(this,L).setAttribute("viewBox",`0 0 ${t} ${o}`),e(this,E).setAttribute("width",String(t)),e(this,E).setAttribute("height",String(r)),e(this,O).setAttribute("width",String(t)),e(this,O).setAttribute("height",String(r)),e(this,N).setAttribute("dy",String(-o))},G=function(t,r){it.has(t)?e(this,s)[t]=r!==null:r===null?e(this,s).removeAttribute(t):e(this,s).setAttribute(t,r)},W=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()},F(J,"observedAttributes",[...K]);const w="http://www.w3.org/2000/svg",Y=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],rt=new Set(["autoplay","loop","muted","playsinline"]),at=["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,m,T,g,R,v,A,p,b,f,M,S,k,q,h,B,X,I,D,z,Z,P,U;class Q extends HTMLElement{constructor(){super();u(this,h);u(this,i);u(this,m);u(this,T);u(this,g);u(this,R);u(this,v,null);u(this,A,null);u(this,p,!1);u(this,b,0);u(this,f,0);u(this,M);u(this,S,null);u(this,k,null);u(this,q,null);const t=this.attachShadow({mode:"open"});a(this,M,`avk-c-${Math.random().toString(36).slice(2,8)}`),t.innerHTML=`<style>
17
+ </svg>`,a(this,L,t.querySelector("svg")),a(this,O,t.querySelector("foreignObject")),a(this,C,t.querySelector("filter")),a(this,N,t.querySelector("feOffset")),a(this,s,t.querySelector("video"));for(const r of st)e(this,s).addEventListener(r,o=>{this.dispatchEvent(new Event(o.type,{bubbles:!1,cancelable:!1}))});e(this,s).addEventListener("loadedmetadata",()=>d(this,c,_).call(this)),e(this,s).addEventListener("resize",()=>d(this,c,_).call(this))}connectedCallback(){for(const t of K)this.hasAttribute(t)&&d(this,c,G).call(this,t,this.getAttribute(t));d(this,c,W).call(this),a(this,y,new MutationObserver(()=>d(this,c,W).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,o){d(this,c,G).call(this,t,o)}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,L=new WeakMap,O=new WeakMap,C=new WeakMap,N=new WeakMap,y=new WeakMap,T=new WeakMap,c=new WeakSet,_=function(){const t=e(this,s).videoWidth,r=e(this,s).videoHeight;if(!t||!r)return;const o=Math.floor(r/2);e(this,L).setAttribute("viewBox",`0 0 ${t} ${o}`),e(this,O).setAttribute("width",String(t)),e(this,O).setAttribute("height",String(r)),e(this,C).setAttribute("width",String(t)),e(this,C).setAttribute("height",String(r)),e(this,N).setAttribute("dy",String(-o))},G=function(t,r){it.has(t)?e(this,s)[t]=r!==null:r===null?e(this,s).removeAttribute(t):e(this,s).setAttribute(t,r)},W=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()},F(J,"observedAttributes",[...K]);const E="http://www.w3.org/2000/svg",Y=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],rt=new Set(["autoplay","loop","muted","playsinline"]),at=["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,m,R,g,v,A,S,p,b,f,M,k,w,q,h,B,X,I,D,z,Z,P,U;class Q extends HTMLElement{constructor(){super();u(this,h);u(this,i);u(this,m);u(this,R);u(this,g);u(this,v);u(this,A,null);u(this,S,null);u(this,p,!1);u(this,b,0);u(this,f,0);u(this,M);u(this,k,null);u(this,w,null);u(this,q,null);const t=this.attachShadow({mode:"open"});a(this,M,`avk-c-${Math.random().toString(36).slice(2,8)}`),t.innerHTML=`<style>
18
18
  :host{display:inline-block;overflow:hidden}
19
19
  video{position:absolute;opacity:0;pointer-events:none;width:0;height:0}
20
20
  canvas{display:block;width:100%}
21
21
  </style>
22
22
  <video></video>
23
- <canvas></canvas>`,a(this,i,t.querySelector("video")),a(this,m,t.querySelector("canvas")),a(this,T,e(this,m).getContext("2d")),a(this,g,document.createElement("canvas")),a(this,R,e(this,g).getContext("2d"));for(const r of at)e(this,i).addEventListener(r,o=>{this.dispatchEvent(new Event(o.type,{bubbles:!1,cancelable:!1}))});e(this,i).addEventListener("loadedmetadata",()=>d(this,h,I).call(this)),e(this,i).addEventListener("resize",()=>d(this,h,I).call(this))}connectedCallback(){for(const t of Y)this.hasAttribute(t)&&d(this,h,D).call(this,t,this.getAttribute(t));d(this,h,z).call(this),a(this,A,new MutationObserver(()=>d(this,h,z).call(this))),e(this,A).observe(this,{childList:!0}),d(this,h,B).call(this),a(this,v,new IntersectionObserver(([t])=>{a(this,p,t.isIntersecting),e(this,p)?d(this,h,Z).call(this):d(this,h,P).call(this)},{threshold:0})),e(this,v).observe(this)}disconnectedCallback(){var t,r;d(this,h,P).call(this),(t=e(this,v))==null||t.disconnect(),a(this,v,null),(r=e(this,A))==null||r.disconnect(),a(this,A,null),d(this,h,X).call(this)}attributeChangedCallback(t,r,o){d(this,h,D).call(this,t,o)}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,m=new WeakMap,T=new WeakMap,g=new WeakMap,R=new WeakMap,v=new WeakMap,A=new WeakMap,p=new WeakMap,b=new WeakMap,f=new WeakMap,M=new WeakMap,S=new WeakMap,k=new WeakMap,q=new WeakMap,h=new WeakSet,B=function(){if(e(this,S))return;const t=document.createElementNS(w,"svg");t.setAttribute("width","0"),t.setAttribute("height","0"),t.style.cssText="position:absolute;overflow:hidden";const r=document.createElementNS(w,"defs"),o=document.createElementNS(w,"filter");o.id=e(this,M),o.setAttribute("filterUnits","userSpaceOnUse"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("width","1"),o.setAttribute("height","1"),o.setAttribute("color-interpolation-filters","sRGB");const H=document.createElementNS(w,"feOffset");H.setAttribute("in","SourceGraphic"),H.setAttribute("dy","0"),H.setAttribute("result","s");const x=document.createElementNS(w,"feColorMatrix");x.setAttribute("in","s"),x.setAttribute("type","matrix"),x.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"),x.setAttribute("result","a");const V=document.createElementNS(w,"feComposite");V.setAttribute("in","SourceGraphic"),V.setAttribute("in2","a"),V.setAttribute("operator","in"),o.append(H,x,V),r.appendChild(o),t.appendChild(r),document.body.appendChild(t),a(this,S,t),a(this,k,o),a(this,q,H)},X=function(){var t;(t=e(this,S))==null||t.remove(),a(this,S,null),a(this,k,null),a(this,q,null)},I=function(){const t=e(this,i).videoWidth,r=e(this,i).videoHeight;if(!t||!r)return;const o=Math.floor(r/2);e(this,m).width=t,e(this,m).height=o,e(this,g).width=t,e(this,g).height=r,d(this,h,B).call(this),e(this,k).setAttribute("width",String(t)),e(this,k).setAttribute("height",String(r)),e(this,q).setAttribute("dy",String(-o))},D=function(t,r){rt.has(t)?e(this,i)[t]=r!==null:r===null?e(this,i).removeAttribute(t):e(this,i).setAttribute(t,r)},z=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(d(this,h,P).call(this),"requestVideoFrameCallback"in e(this,i)){const t=()=>{e(this,p)&&(d(this,h,U).call(this),a(this,f,e(this,i).requestVideoFrameCallback(t)))};a(this,f,e(this,i).requestVideoFrameCallback(t))}else{const t=()=>{e(this,p)&&(d(this,h,U).call(this),a(this,b,requestAnimationFrame(t)))};a(this,b,requestAnimationFrame(t))}},P=function(){var t,r;e(this,f)&&((r=(t=e(this,i)).cancelVideoFrameCallback)==null||r.call(t,e(this,f)),a(this,f,0)),e(this,b)&&(cancelAnimationFrame(e(this,b)),a(this,b,0))},U=function(){if(e(this,i).readyState<2)return;const t=e(this,i).videoWidth,r=e(this,i).videoHeight;if(!t||!r)return;const o=Math.floor(r/2);(e(this,g).width!==t||e(this,g).height!==r)&&d(this,h,I).call(this),e(this,R).filter=`url(#${e(this,M)})`,e(this,R).drawImage(e(this,i),0,0),e(this,T).clearRect(0,0,t,o),e(this,T).drawImage(e(this,g),0,0,t,o,0,0,t,o)},F(Q,"observedAttributes",[...Y]);exports.AlphaVideoKitCanvas=Q;exports.AlphaVideoKitSVG=J;
23
+ <canvas></canvas>`,a(this,i,t.querySelector("video")),a(this,m,t.querySelector("canvas")),a(this,R,e(this,m).getContext("2d")),a(this,g,document.createElement("canvas")),a(this,v,e(this,g).getContext("2d"));for(const r of at)e(this,i).addEventListener(r,o=>{this.dispatchEvent(new Event(o.type,{bubbles:!1,cancelable:!1}))});e(this,i).addEventListener("loadedmetadata",()=>d(this,h,I).call(this)),e(this,i).addEventListener("resize",()=>d(this,h,I).call(this))}connectedCallback(){for(const t of Y)this.hasAttribute(t)&&d(this,h,D).call(this,t,this.getAttribute(t));d(this,h,z).call(this),a(this,S,new MutationObserver(()=>d(this,h,z).call(this))),e(this,S).observe(this,{childList:!0}),d(this,h,B).call(this),a(this,A,new IntersectionObserver(([t])=>{a(this,p,t.isIntersecting),e(this,p)?d(this,h,Z).call(this):d(this,h,P).call(this)},{threshold:0})),e(this,A).observe(this)}disconnectedCallback(){var t,r;d(this,h,P).call(this),(t=e(this,A))==null||t.disconnect(),a(this,A,null),(r=e(this,S))==null||r.disconnect(),a(this,S,null),d(this,h,X).call(this)}attributeChangedCallback(t,r,o){d(this,h,D).call(this,t,o)}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,m=new WeakMap,R=new WeakMap,g=new WeakMap,v=new WeakMap,A=new WeakMap,S=new WeakMap,p=new WeakMap,b=new WeakMap,f=new WeakMap,M=new WeakMap,k=new WeakMap,w=new WeakMap,q=new WeakMap,h=new WeakSet,B=function(){if(e(this,k))return;const t=document.createElementNS(E,"svg");t.setAttribute("width","0"),t.setAttribute("height","0"),t.style.cssText="position:absolute;overflow:hidden";const r=document.createElementNS(E,"defs"),o=document.createElementNS(E,"filter");o.id=e(this,M),o.setAttribute("filterUnits","userSpaceOnUse"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("width","1"),o.setAttribute("height","1"),o.setAttribute("color-interpolation-filters","sRGB");const H=document.createElementNS(E,"feOffset");H.setAttribute("in","SourceGraphic"),H.setAttribute("dy","0"),H.setAttribute("result","s");const x=document.createElementNS(E,"feColorMatrix");x.setAttribute("in","s"),x.setAttribute("type","matrix"),x.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"),x.setAttribute("result","a");const V=document.createElementNS(E,"feComposite");V.setAttribute("in","SourceGraphic"),V.setAttribute("in2","a"),V.setAttribute("operator","in"),o.append(H,x,V),r.appendChild(o),t.appendChild(r),document.body.appendChild(t),a(this,k,t),a(this,w,o),a(this,q,H)},X=function(){var t;(t=e(this,k))==null||t.remove(),a(this,k,null),a(this,w,null),a(this,q,null)},I=function(){const t=e(this,i).videoWidth,r=e(this,i).videoHeight;if(!t||!r)return;const o=Math.floor(r/2);e(this,m).width=t,e(this,m).height=o,e(this,g).width=t,e(this,g).height=r,d(this,h,B).call(this),e(this,w).setAttribute("width",String(t)),e(this,w).setAttribute("height",String(r)),e(this,q).setAttribute("dy",String(-o))},D=function(t,r){rt.has(t)?e(this,i)[t]=r!==null:r===null?e(this,i).removeAttribute(t):e(this,i).setAttribute(t,r)},z=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(d(this,h,P).call(this),"requestVideoFrameCallback"in e(this,i)){const t=()=>{e(this,p)&&(d(this,h,U).call(this),a(this,f,e(this,i).requestVideoFrameCallback(t)))};a(this,f,e(this,i).requestVideoFrameCallback(t))}else{const t=()=>{e(this,p)&&(d(this,h,U).call(this),a(this,b,requestAnimationFrame(t)))};a(this,b,requestAnimationFrame(t))}},P=function(){var t,r;e(this,f)&&((r=(t=e(this,i)).cancelVideoFrameCallback)==null||r.call(t,e(this,f)),a(this,f,0)),e(this,b)&&(cancelAnimationFrame(e(this,b)),a(this,b,0))},U=function(){if(e(this,i).readyState<2)return;const t=e(this,i).videoWidth,r=e(this,i).videoHeight;if(!t||!r)return;const o=Math.floor(r/2);(e(this,g).width!==t||e(this,g).height!==r)&&d(this,h,I).call(this),e(this,v).clearRect(0,0,t,r),e(this,v).filter=`url(#${e(this,M)})`,e(this,v).drawImage(e(this,i),0,0),e(this,R).clearRect(0,0,t,o),e(this,R).drawImage(e(this,g),0,0,t,o,0,0,t,o)},F(Q,"observedAttributes",[...Y]);exports.AlphaVideoKitCanvas=Q;exports.AlphaVideoKitSVG=J;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./canvas-component-Cu612Agl.cjs"),o="http://www.w3.org/2000/svg";function g(h){const{canvas:l}=h,m=l.getContext("2d"),n=document.createElement("canvas"),p=n.getContext("2d"),A=`avk-f-${Math.random().toString(36).slice(2,8)}`;let s=null,a=null,f=null,c=!1;function S(){if(s)return;const r=document.createElementNS(o,"svg");r.setAttribute("width","0"),r.setAttribute("height","0"),r.style.cssText="position:absolute;overflow:hidden";const i=document.createElementNS(o,"defs"),t=document.createElementNS(o,"filter");t.id=A,t.setAttribute("filterUnits","userSpaceOnUse"),t.setAttribute("x","0"),t.setAttribute("y","0"),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("color-interpolation-filters","sRGB");const e=document.createElementNS(o,"feOffset");e.setAttribute("in","SourceGraphic"),e.setAttribute("dy","0"),e.setAttribute("result","s");const u=document.createElementNS(o,"feColorMatrix");u.setAttribute("in","s"),u.setAttribute("type","matrix"),u.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"),u.setAttribute("result","a");const d=document.createElementNS(o,"feComposite");d.setAttribute("in","SourceGraphic"),d.setAttribute("in2","a"),d.setAttribute("operator","in"),t.append(e,u,d),i.appendChild(t),r.appendChild(i),document.body.appendChild(r),s=r,a=t,f=e}return{drawFrame(r){if(c)return;const i=r.videoWidth,t=r.videoHeight,e=Math.floor(t/2);(l.width!==i||l.height!==e)&&(l.width=i,l.height=e),(n.width!==i||n.height!==t)&&(n.width=i,n.height=t),S(),a.setAttribute("width",String(i)),a.setAttribute("height",String(t)),f.setAttribute("dy",String(-e)),p.filter=`url(#${A})`,p.drawImage(r,0,0),m.clearRect(0,0,i,e),m.drawImage(n,0,0,i,e,0,0,i,e)},setPremultipliedAlpha(r){},destroy(){c||(c=!0,s==null||s.remove(),s=null,a=null,f=null)},get isDestroyed(){return c}}}function w(h){return g(h)}exports.AlphaVideoKitCanvas=b.AlphaVideoKitCanvas;exports.AlphaVideoKitSVG=b.AlphaVideoKitSVG;exports.createRenderer=w;exports.createSvgFilterRenderer=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./canvas-component-BR3Vuf_h.cjs"),o="http://www.w3.org/2000/svg";function g(h){const{canvas:l}=h,p=l.getContext("2d"),n=document.createElement("canvas"),f=n.getContext("2d"),A=`avk-f-${Math.random().toString(36).slice(2,8)}`;let s=null,c=null,m=null,a=!1;function S(){if(s)return;const i=document.createElementNS(o,"svg");i.setAttribute("width","0"),i.setAttribute("height","0"),i.style.cssText="position:absolute;overflow:hidden";const e=document.createElementNS(o,"defs"),t=document.createElementNS(o,"filter");t.id=A,t.setAttribute("filterUnits","userSpaceOnUse"),t.setAttribute("x","0"),t.setAttribute("y","0"),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("color-interpolation-filters","sRGB");const r=document.createElementNS(o,"feOffset");r.setAttribute("in","SourceGraphic"),r.setAttribute("dy","0"),r.setAttribute("result","s");const u=document.createElementNS(o,"feColorMatrix");u.setAttribute("in","s"),u.setAttribute("type","matrix"),u.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"),u.setAttribute("result","a");const d=document.createElementNS(o,"feComposite");d.setAttribute("in","SourceGraphic"),d.setAttribute("in2","a"),d.setAttribute("operator","in"),t.append(r,u,d),e.appendChild(t),i.appendChild(e),document.body.appendChild(i),s=i,c=t,m=r}return{drawFrame(i){if(a)return;const e=i.videoWidth,t=i.videoHeight,r=Math.floor(t/2);(l.width!==e||l.height!==r)&&(l.width=e,l.height=r),(n.width!==e||n.height!==t)&&(n.width=e,n.height=t),S(),c.setAttribute("width",String(e)),c.setAttribute("height",String(t)),m.setAttribute("dy",String(-r)),f.clearRect(0,0,e,t),f.filter=`url(#${A})`,f.drawImage(i,0,0),p.clearRect(0,0,e,r),p.drawImage(n,0,0,e,r,0,0,e,r)},setPremultipliedAlpha(i){},destroy(){a||(a=!0,s==null||s.remove(),s=null,c=null,m=null)},get isDestroyed(){return a}}}function w(h){return g(h)}exports.AlphaVideoKitCanvas=b.AlphaVideoKitCanvas;exports.AlphaVideoKitSVG=b.AlphaVideoKitSVG;exports.createRenderer=w;exports.createSvgFilterRenderer=g;
package/dist/index.js CHANGED
@@ -1,31 +1,31 @@
1
- import { A as x, a as y } from "./canvas-component-zHBwAZuP.js";
1
+ import { A as x, a as y } from "./canvas-component-BJ29dbCJ.js";
2
2
  const o = "http://www.w3.org/2000/svg";
3
3
  function g(f) {
4
- const { canvas: u } = f, m = u.getContext("2d"), n = document.createElement("canvas"), A = n.getContext("2d"), p = `avk-f-${Math.random().toString(36).slice(2, 8)}`;
5
- let s = null, c = null, h = null, a = !1;
4
+ const { canvas: l } = f, A = l.getContext("2d"), n = document.createElement("canvas"), h = n.getContext("2d"), p = `avk-f-${Math.random().toString(36).slice(2, 8)}`;
5
+ let s = null, c = null, m = null, a = !1;
6
6
  function b() {
7
7
  if (s) return;
8
- const r = document.createElementNS(o, "svg");
9
- r.setAttribute("width", "0"), r.setAttribute("height", "0"), r.style.cssText = "position:absolute;overflow:hidden";
10
- const i = document.createElementNS(o, "defs"), t = document.createElementNS(o, "filter");
8
+ const i = document.createElementNS(o, "svg");
9
+ i.setAttribute("width", "0"), i.setAttribute("height", "0"), i.style.cssText = "position:absolute;overflow:hidden";
10
+ const e = document.createElementNS(o, "defs"), t = document.createElementNS(o, "filter");
11
11
  t.id = p, t.setAttribute("filterUnits", "userSpaceOnUse"), t.setAttribute("x", "0"), t.setAttribute("y", "0"), t.setAttribute("width", "1"), t.setAttribute("height", "1"), t.setAttribute("color-interpolation-filters", "sRGB");
12
- const e = document.createElementNS(o, "feOffset");
13
- e.setAttribute("in", "SourceGraphic"), e.setAttribute("dy", "0"), e.setAttribute("result", "s");
14
- const l = document.createElementNS(o, "feColorMatrix");
15
- l.setAttribute("in", "s"), l.setAttribute("type", "matrix"), l.setAttribute("values", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"), l.setAttribute("result", "a");
12
+ const r = document.createElementNS(o, "feOffset");
13
+ r.setAttribute("in", "SourceGraphic"), r.setAttribute("dy", "0"), r.setAttribute("result", "s");
14
+ const u = document.createElementNS(o, "feColorMatrix");
15
+ u.setAttribute("in", "s"), u.setAttribute("type", "matrix"), u.setAttribute("values", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"), u.setAttribute("result", "a");
16
16
  const d = document.createElementNS(o, "feComposite");
17
- d.setAttribute("in", "SourceGraphic"), d.setAttribute("in2", "a"), d.setAttribute("operator", "in"), t.append(e, l, d), i.appendChild(t), r.appendChild(i), document.body.appendChild(r), s = r, c = t, h = e;
17
+ d.setAttribute("in", "SourceGraphic"), d.setAttribute("in2", "a"), d.setAttribute("operator", "in"), t.append(r, u, d), e.appendChild(t), i.appendChild(e), document.body.appendChild(i), s = i, c = t, m = r;
18
18
  }
19
19
  return {
20
- drawFrame(r) {
20
+ drawFrame(i) {
21
21
  if (a) return;
22
- const i = r.videoWidth, t = r.videoHeight, e = Math.floor(t / 2);
23
- (u.width !== i || u.height !== e) && (u.width = i, u.height = e), (n.width !== i || n.height !== t) && (n.width = i, n.height = t), b(), c.setAttribute("width", String(i)), c.setAttribute("height", String(t)), h.setAttribute("dy", String(-e)), A.filter = `url(#${p})`, A.drawImage(r, 0, 0), m.clearRect(0, 0, i, e), m.drawImage(n, 0, 0, i, e, 0, 0, i, e);
22
+ const e = i.videoWidth, t = i.videoHeight, r = Math.floor(t / 2);
23
+ (l.width !== e || l.height !== r) && (l.width = e, l.height = r), (n.width !== e || n.height !== t) && (n.width = e, n.height = t), b(), c.setAttribute("width", String(e)), c.setAttribute("height", String(t)), m.setAttribute("dy", String(-r)), h.clearRect(0, 0, e, t), h.filter = `url(#${p})`, h.drawImage(i, 0, 0), A.clearRect(0, 0, e, r), A.drawImage(n, 0, 0, e, r, 0, 0, e, r);
24
24
  },
25
- setPremultipliedAlpha(r) {
25
+ setPremultipliedAlpha(i) {
26
26
  },
27
27
  destroy() {
28
- a || (a = !0, s == null || s.remove(), s = null, c = null, h = null);
28
+ a || (a = !0, s == null || s.remove(), s = null, c = null, m = null);
29
29
  },
30
30
  get isDestroyed() {
31
31
  return a;
package/dist/register.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("./canvas-component-Cu612Agl.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-BR3Vuf_h.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-zHBwAZuP.js";
1
+ import { a as e, A as a } from "./canvas-component-BJ29dbCJ.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.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "SVG filter-based renderer for stacked alpha videos",
5
5
  "type": "module",
6
6
  "files": ["dist", "react.d.ts"],