@alpha-video-kit/svg 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +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>
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,C)}" 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,C)})">
15
+ <video></video>
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>
18
+ :host{display:inline-block;overflow:hidden}
19
+ video{position:absolute;opacity:0;pointer-events:none;width:0;height:0}
20
+ canvas{display:block;width:100%}
21
+ </style>
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;
@@ -1,11 +1,11 @@
1
- var Q = Object.defineProperty;
2
- var U = (h) => {
3
- throw TypeError(h);
1
+ var X = Object.defineProperty;
2
+ var j = (n) => {
3
+ throw TypeError(n);
4
4
  };
5
- var X = (h, n, t) => n in h ? Q(h, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[n] = t;
6
- var I = (h, n, t) => X(h, typeof n != "symbol" ? n + "" : n, t), F = (h, n, t) => n.has(h) || U("Cannot " + t);
7
- var e = (h, n, t) => (F(h, n, "read from private field"), t ? t.call(h) : n.get(h)), u = (h, n, t) => n.has(h) ? U("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(h) : n.set(h, t), a = (h, n, t, r) => (F(h, n, "write to private field"), r ? r.call(h, t) : n.set(h, t), t), d = (h, n, t) => (F(h, n, "access private method"), t);
8
- const j = [
5
+ var Z = (n, l, t) => l in n ? X(n, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[l] = t;
6
+ var V = (n, l, t) => Z(n, typeof l != "symbol" ? l + "" : l, t), $ = (n, l, t) => l.has(n) || j("Cannot " + t);
7
+ 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);
8
+ const Y = [
9
9
  "src",
10
10
  "crossorigin",
11
11
  "preload",
@@ -16,7 +16,7 @@ const j = [
16
16
  "poster",
17
17
  "width",
18
18
  "height"
19
- ], Z = /* @__PURE__ */ new Set(["autoplay", "loop", "muted", "playsinline"]), tt = [
19
+ ], tt = /* @__PURE__ */ new Set(["autoplay", "loop", "muted", "playsinline"]), et = [
20
20
  "loadstart",
21
21
  "progress",
22
22
  "suspend",
@@ -41,53 +41,53 @@ const j = [
41
41
  "resize",
42
42
  "volumechange"
43
43
  ];
44
- var s, L, w, E, x, y, O, c, V, _, D;
45
- class et extends HTMLElement {
44
+ var s, L, E, O, N, y, T, c, _, G, W;
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, w);
52
51
  u(this, E);
53
- u(this, x);
54
- u(this, y, null);
55
52
  u(this, O);
53
+ u(this, N);
54
+ u(this, y, null);
55
+ u(this, T);
56
56
  const t = this.attachShadow({ mode: "open" });
57
- a(this, O, `avk-${Math.random().toString(36).slice(2, 8)}`), t.innerHTML = `<style>
57
+ a(this, T, `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, O)}" filterUnits="userSpaceOnUse" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">
64
+ <filter id="${e(this, T)}" 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, O)})">
70
+ <foreignObject width="1" height="1" filter="url(#${e(this, T)})">
71
71
  <video></video>
72
72
  </foreignObject>
73
- </svg>`, a(this, L, t.querySelector("svg")), a(this, w, t.querySelector("foreignObject")), a(this, E, t.querySelector("filter")), a(this, x, t.querySelector("feOffset")), a(this, s, t.querySelector("video"));
74
- for (const r of tt)
75
- e(this, s).addEventListener(r, (l) => {
76
- this.dispatchEvent(new Event(l.type, { bubbles: !1, cancelable: !1 }));
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"));
74
+ for (const r of et)
75
+ e(this, s).addEventListener(r, (o) => {
76
+ this.dispatchEvent(new Event(o.type, { bubbles: !1, cancelable: !1 }));
77
77
  });
78
- e(this, s).addEventListener("loadedmetadata", () => d(this, c, V).call(this)), e(this, s).addEventListener("resize", () => d(this, c, V).call(this));
78
+ e(this, s).addEventListener("loadedmetadata", () => d(this, c, _).call(this)), e(this, s).addEventListener("resize", () => d(this, c, _).call(this));
79
79
  }
80
80
  connectedCallback() {
81
- for (const t of j)
82
- this.hasAttribute(t) && d(this, c, _).call(this, t, this.getAttribute(t));
83
- d(this, c, D).call(this), a(this, y, new MutationObserver(() => d(this, c, D).call(this))), e(this, y).observe(this, { childList: !0 });
81
+ for (const t of Y)
82
+ this.hasAttribute(t) && d(this, c, G).call(this, t, this.getAttribute(t));
83
+ d(this, c, W).call(this), a(this, y, new MutationObserver(() => d(this, c, W).call(this))), e(this, y).observe(this, { childList: !0 });
84
84
  }
85
85
  disconnectedCallback() {
86
86
  var t;
87
87
  (t = e(this, y)) == null || t.disconnect(), a(this, y, null);
88
88
  }
89
- attributeChangedCallback(t, r, l) {
90
- d(this, c, _).call(this, t, l);
89
+ attributeChangedCallback(t, r, o) {
90
+ d(this, c, G).call(this, t, o);
91
91
  }
92
92
  // --- Proxied properties ---
93
93
  get src() {
@@ -203,19 +203,19 @@ 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(), w = new WeakMap(), E = new WeakMap(), x = new WeakMap(), y = new WeakMap(), O = new WeakMap(), c = new WeakSet(), V = function() {
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() {
207
207
  const t = e(this, s).videoWidth, r = e(this, s).videoHeight;
208
208
  if (!t || !r) return;
209
- const l = Math.floor(r / 2);
210
- e(this, L).setAttribute("viewBox", `0 0 ${t} ${l}`), e(this, w).setAttribute("width", String(t)), e(this, w).setAttribute("height", String(r)), e(this, E).setAttribute("width", String(t)), e(this, E).setAttribute("height", String(r)), e(this, x).setAttribute("dy", String(-l));
211
- }, _ = function(t, r) {
212
- Z.has(t) ? e(this, s)[t] = r !== null : r === null ? e(this, s).removeAttribute(t) : e(this, s).setAttribute(t, r);
213
- }, D = function() {
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));
211
+ }, G = function(t, r) {
212
+ tt.has(t) ? e(this, s)[t] = r !== null : r === null ? e(this, s).removeAttribute(t) : e(this, s).setAttribute(t, r);
213
+ }, W = function() {
214
214
  e(this, s).querySelectorAll("source").forEach((t) => t.remove()), this.querySelectorAll("source").forEach((t) => {
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
- }, I(et, "observedAttributes", [...j]);
218
- const k = "http://www.w3.org/2000/svg", Y = [
217
+ }, V(it, "observedAttributes", [...Y]);
218
+ const w = "http://www.w3.org/2000/svg", J = [
219
219
  "src",
220
220
  "crossorigin",
221
221
  "preload",
@@ -226,7 +226,7 @@ const k = "http://www.w3.org/2000/svg", Y = [
226
226
  "poster",
227
227
  "width",
228
228
  "height"
229
- ], it = /* @__PURE__ */ new Set(["autoplay", "loop", "muted", "playsinline"]), st = [
229
+ ], st = /* @__PURE__ */ new Set(["autoplay", "loop", "muted", "playsinline"]), rt = [
230
230
  "loadstart",
231
231
  "progress",
232
232
  "suspend",
@@ -251,56 +251,56 @@ const k = "http://www.w3.org/2000/svg", Y = [
251
251
  "resize",
252
252
  "volumechange"
253
253
  ];
254
- var i, p, T, H, m, v, g, b, f, C, A, S, R, o, G, J, P, W, B, K, $, z;
255
- class rt extends HTMLElement {
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;
255
+ class at extends HTMLElement {
256
256
  constructor() {
257
257
  super();
258
- u(this, o);
258
+ u(this, h);
259
259
  u(this, i);
260
- u(this, p);
261
- u(this, T);
262
- u(this, H);
263
- u(this, m, null);
260
+ u(this, m);
261
+ u(this, C);
262
+ u(this, g);
263
+ u(this, R);
264
264
  u(this, v, null);
265
- u(this, g, !1);
265
+ u(this, A, null);
266
+ u(this, p, !1);
266
267
  u(this, b, 0);
267
268
  u(this, f, 0);
268
269
  // SVG filter (lives in document.body so ctx.filter url() can resolve it)
269
- u(this, C);
270
- u(this, A, null);
270
+ u(this, M);
271
271
  u(this, S, null);
272
- u(this, R, null);
272
+ u(this, k, null);
273
+ u(this, q, null);
273
274
  const t = this.attachShadow({ mode: "open" });
274
- a(this, C, `avk-c-${Math.random().toString(36).slice(2, 8)}`), t.innerHTML = `<style>
275
+ a(this, M, `avk-c-${Math.random().toString(36).slice(2, 8)}`), t.innerHTML = `<style>
275
276
  :host{display:inline-block;overflow:hidden}
276
277
  video{position:absolute;opacity:0;pointer-events:none;width:0;height:0}
277
- .clip{overflow:hidden;width:100%}
278
278
  canvas{display:block;width:100%}
279
279
  </style>
280
280
  <video></video>
281
- <div class="clip"><canvas></canvas></div>`, a(this, i, t.querySelector("video")), a(this, H, t.querySelector(".clip")), a(this, p, t.querySelector("canvas")), a(this, T, e(this, p).getContext("2d"));
282
- for (const r of st)
283
- e(this, i).addEventListener(r, (l) => {
284
- this.dispatchEvent(new Event(l.type, { bubbles: !1, cancelable: !1 }));
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"));
282
+ for (const r of rt)
283
+ e(this, i).addEventListener(r, (o) => {
284
+ this.dispatchEvent(new Event(o.type, { bubbles: !1, cancelable: !1 }));
285
285
  });
286
- e(this, i).addEventListener("loadedmetadata", () => d(this, o, P).call(this)), e(this, i).addEventListener("resize", () => d(this, o, P).call(this));
286
+ e(this, i).addEventListener("loadedmetadata", () => d(this, h, P).call(this)), e(this, i).addEventListener("resize", () => d(this, h, P).call(this));
287
287
  }
288
288
  connectedCallback() {
289
- for (const t of Y)
290
- this.hasAttribute(t) && d(this, o, W).call(this, t, this.getAttribute(t));
291
- d(this, o, B).call(this), a(this, v, new MutationObserver(() => d(this, o, B).call(this))), e(this, v).observe(this, { childList: !0 }), d(this, o, G).call(this), a(this, m, new IntersectionObserver(
289
+ for (const t of J)
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(
292
292
  ([t]) => {
293
- a(this, g, t.isIntersecting), e(this, g) ? d(this, o, K).call(this) : d(this, o, $).call(this);
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, m).observe(this);
296
+ )), e(this, v).observe(this);
297
297
  }
298
298
  disconnectedCallback() {
299
299
  var t, r;
300
- d(this, o, $).call(this), (t = e(this, m)) == null || t.disconnect(), a(this, m, null), (r = e(this, v)) == null || r.disconnect(), a(this, v, null), d(this, o, J).call(this);
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);
301
301
  }
302
- attributeChangedCallback(t, r, l) {
303
- d(this, o, W).call(this, t, l);
302
+ attributeChangedCallback(t, r, o) {
303
+ d(this, h, D).call(this, t, o);
304
304
  }
305
305
  // --- Proxied properties ---
306
306
  get src() {
@@ -416,54 +416,56 @@ canvas{display:block;width:100%}
416
416
  return e(this, i).canPlayType(t);
417
417
  }
418
418
  }
419
- i = new WeakMap(), p = new WeakMap(), T = new WeakMap(), H = new WeakMap(), m = new WeakMap(), v = new WeakMap(), g = new WeakMap(), b = new WeakMap(), f = new WeakMap(), C = new WeakMap(), A = new WeakMap(), S = new WeakMap(), R = new WeakMap(), o = new WeakSet(), G = function() {
420
- if (e(this, A)) return;
421
- const t = document.createElementNS(k, "svg");
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");
422
422
  t.setAttribute("width", "0"), t.setAttribute("height", "0"), t.style.cssText = "position:absolute;overflow:hidden";
423
- const r = document.createElementNS(k, "defs"), l = document.createElementNS(k, "filter");
424
- l.id = e(this, C), l.setAttribute("filterUnits", "userSpaceOnUse"), l.setAttribute("x", "0"), l.setAttribute("y", "0"), l.setAttribute("width", "1"), l.setAttribute("height", "1"), l.setAttribute("color-interpolation-filters", "sRGB");
425
- const q = document.createElementNS(k, "feOffset");
426
- q.setAttribute("in", "SourceGraphic"), q.setAttribute("dy", "0"), q.setAttribute("result", "s");
427
- const M = document.createElementNS(k, "feColorMatrix");
428
- M.setAttribute("in", "s"), M.setAttribute("type", "matrix"), M.setAttribute("values", "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"), M.setAttribute("result", "a");
429
- const N = document.createElementNS(k, "feComposite");
430
- N.setAttribute("in", "SourceGraphic"), N.setAttribute("in2", "a"), N.setAttribute("operator", "in"), l.append(q, M, N), r.appendChild(l), t.appendChild(r), document.body.appendChild(t), a(this, A, t), a(this, S, l), a(this, R, q);
431
- }, J = function() {
423
+ const r = document.createElementNS(w, "defs"), o = document.createElementNS(w, "filter");
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");
426
+ x.setAttribute("in", "SourceGraphic"), x.setAttribute("dy", "0"), x.setAttribute("result", "s");
427
+ const H = document.createElementNS(w, "feColorMatrix");
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);
431
+ }, K = function() {
432
432
  var t;
433
- (t = e(this, A)) == null || t.remove(), a(this, A, null), a(this, S, null), a(this, R, null);
433
+ (t = e(this, S)) == null || t.remove(), a(this, S, null), a(this, k, 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
- const l = Math.floor(r / 2);
438
- e(this, p).width = t, e(this, p).height = r, e(this, H).style.aspectRatio = `${t} / ${l}`, d(this, o, G).call(this), e(this, S).setAttribute("width", String(t)), e(this, S).setAttribute("height", String(r)), e(this, R).setAttribute("dy", String(-l));
439
- }, W = function(t, r) {
440
- it.has(t) ? e(this, i)[t] = r !== null : r === null ? e(this, i).removeAttribute(t) : e(this, i).setAttribute(t, r);
441
- }, B = function() {
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));
439
+ }, D = function(t, r) {
440
+ st.has(t) ? e(this, i)[t] = r !== null : r === null ? e(this, i).removeAttribute(t) : e(this, i).setAttribute(t, r);
441
+ }, z = function() {
442
442
  e(this, i).querySelectorAll("source").forEach((t) => t.remove()), this.querySelectorAll("source").forEach((t) => {
443
443
  e(this, i).appendChild(t.cloneNode(!0));
444
444
  }), e(this, i).querySelectorAll("source").length > 0 && !e(this, i).src && e(this, i).load();
445
- }, K = function() {
446
- if (e(this, g))
447
- if (d(this, o, $).call(this), "requestVideoFrameCallback" in e(this, i)) {
445
+ }, Q = function() {
446
+ if (e(this, p))
447
+ if (d(this, h, F).call(this), "requestVideoFrameCallback" in e(this, i)) {
448
448
  const t = () => {
449
- e(this, g) && (d(this, o, z).call(this), a(this, f, e(this, i).requestVideoFrameCallback(t)));
449
+ e(this, p) && (d(this, h, U).call(this), a(this, f, e(this, i).requestVideoFrameCallback(t)));
450
450
  };
451
451
  a(this, f, e(this, i).requestVideoFrameCallback(t));
452
452
  } else {
453
453
  const t = () => {
454
- e(this, g) && (d(this, o, z).call(this), a(this, b, requestAnimationFrame(t)));
454
+ e(this, p) && (d(this, h, U).call(this), a(this, b, requestAnimationFrame(t)));
455
455
  };
456
456
  a(this, b, requestAnimationFrame(t));
457
457
  }
458
- }, $ = function() {
458
+ }, F = function() {
459
459
  var t, r;
460
460
  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));
461
- }, z = function() {
461
+ }, U = function() {
462
462
  if (e(this, i).readyState < 2) return;
463
463
  const t = e(this, i).videoWidth, r = e(this, i).videoHeight;
464
- !t || !r || ((e(this, p).width !== t || e(this, p).height !== r) && d(this, o, P).call(this), e(this, T).filter = `url(#${e(this, C)})`, e(this, T).drawImage(e(this, i), 0, 0));
465
- }, I(rt, "observedAttributes", [...Y]);
464
+ if (!t || !r) return;
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);
467
+ }, V(at, "observedAttributes", [...J]);
466
468
  export {
467
- rt as A,
468
- et as a
469
+ at as A,
470
+ it as a
469
471
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./canvas-component-CE05m0PN.cjs"),s="http://www.w3.org/2000/svg";function b(d){const{canvas:o}=d,f=o.getContext("2d"),p=`avk-f-${Math.random().toString(36).slice(2,8)}`;let i=null,u=null,h=null,a=!1;function m(){if(i)return;const e=document.createElementNS(s,"svg");e.setAttribute("width","0"),e.setAttribute("height","0"),e.style.cssText="position:absolute;overflow:hidden";const n=document.createElementNS(s,"defs"),t=document.createElementNS(s,"filter");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");const r=document.createElementNS(s,"feOffset");r.setAttribute("in","SourceGraphic"),r.setAttribute("dy","0"),r.setAttribute("result","s");const l=document.createElementNS(s,"feColorMatrix");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");const c=document.createElementNS(s,"feComposite");c.setAttribute("in","SourceGraphic"),c.setAttribute("in2","a"),c.setAttribute("operator","in"),t.append(r,l,c),n.appendChild(t),e.appendChild(n),document.body.appendChild(e),i=e,u=t,h=r}return{drawFrame(e){if(a)return;const n=e.videoWidth,t=e.videoHeight,r=Math.floor(t/2);(o.width!==n||o.height!==r)&&(o.width=n,o.height=r),m(),u.setAttribute("width",String(n)),u.setAttribute("height",String(t)),h.setAttribute("dy",String(-r)),f.filter=`url(#${p})`,f.drawImage(e,0,0)},setPremultipliedAlpha(e){},destroy(){a||(a=!0,i==null||i.remove(),i=null,u=null,h=null)},get isDestroyed(){return a}}}function g(d){return b(d)}exports.AlphaVideoKitCanvas=A.AlphaVideoKitCanvas;exports.AlphaVideoKitSVG=A.AlphaVideoKitSVG;exports.createRenderer=g;exports.createSvgFilterRenderer=b;
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;
package/dist/index.d.ts CHANGED
@@ -115,12 +115,9 @@ export declare function createRenderer(options: StackedAlphaRendererOptions): St
115
115
  /**
116
116
  * SVG filter renderer using ctx.filter on Canvas 2D.
117
117
  *
118
- * Injects an SVG <filter> into document.body, then on each frame:
119
- * ctx.filter = 'url(#id)';
120
- * ctx.drawImage(video, 0, 0);
121
- *
122
- * The filter shifts the bottom (alpha) half up, extracts R→alpha,
123
- * and composites it over the top (color) half.
118
+ * Uses an offscreen canvas at full (double) height so the filter can see
119
+ * both halves. The filter composites alpha, then the top half is copied
120
+ * to the visible canvas.
124
121
  */
125
122
  export declare function createSvgFilterRenderer(options: StackedAlphaRendererOptions): StackedAlphaRenderer;
126
123
 
package/dist/index.js CHANGED
@@ -1,43 +1,43 @@
1
- import { A as w, a as v } from "./canvas-component-C3vC6FBw.js";
2
- const s = "http://www.w3.org/2000/svg";
3
- function b(d) {
4
- const { canvas: o } = d, h = o.getContext("2d"), A = `avk-f-${Math.random().toString(36).slice(2, 8)}`;
5
- let i = null, l = null, f = null, a = !1;
6
- function p() {
7
- if (i) return;
8
- const e = document.createElementNS(s, "svg");
9
- e.setAttribute("width", "0"), e.setAttribute("height", "0"), e.style.cssText = "position:absolute;overflow:hidden";
10
- const n = document.createElementNS(s, "defs"), t = document.createElementNS(s, "filter");
11
- 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");
12
- const r = document.createElementNS(s, "feOffset");
13
- r.setAttribute("in", "SourceGraphic"), r.setAttribute("dy", "0"), r.setAttribute("result", "s");
14
- const u = document.createElementNS(s, "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
- const c = document.createElementNS(s, "feComposite");
17
- c.setAttribute("in", "SourceGraphic"), c.setAttribute("in2", "a"), c.setAttribute("operator", "in"), t.append(r, u, c), n.appendChild(t), e.appendChild(n), document.body.appendChild(e), i = e, l = t, f = r;
1
+ import { A as x, a as y } from "./canvas-component-zHBwAZuP.js";
2
+ const o = "http://www.w3.org/2000/svg";
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;
6
+ function b() {
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");
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");
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;
18
18
  }
19
19
  return {
20
- drawFrame(e) {
20
+ drawFrame(r) {
21
21
  if (a) return;
22
- const n = e.videoWidth, t = e.videoHeight, r = Math.floor(t / 2);
23
- (o.width !== n || o.height !== r) && (o.width = n, o.height = r), p(), l.setAttribute("width", String(n)), l.setAttribute("height", String(t)), f.setAttribute("dy", String(-r)), h.filter = `url(#${A})`, h.drawImage(e, 0, 0);
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);
24
24
  },
25
- setPremultipliedAlpha(e) {
25
+ setPremultipliedAlpha(r) {
26
26
  },
27
27
  destroy() {
28
- a || (a = !0, i == null || i.remove(), i = null, l = null, f = null);
28
+ a || (a = !0, s == null || s.remove(), s = null, c = null, h = null);
29
29
  },
30
30
  get isDestroyed() {
31
31
  return a;
32
32
  }
33
33
  };
34
34
  }
35
- function m(d) {
36
- return b(d);
35
+ function w(f) {
36
+ return g(f);
37
37
  }
38
38
  export {
39
- w as AlphaVideoKitCanvas,
40
- v as AlphaVideoKitSVG,
41
- m as createRenderer,
42
- b as createSvgFilterRenderer
39
+ x as AlphaVideoKitCanvas,
40
+ y as AlphaVideoKitSVG,
41
+ w as createRenderer,
42
+ g as createSvgFilterRenderer
43
43
  };
package/dist/register.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("./canvas-component-CE05m0PN.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-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);
package/dist/register.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as e, A as a } from "./canvas-component-C3vC6FBw.js";
1
+ import { a as e, A as a } from "./canvas-component-zHBwAZuP.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.0",
3
+ "version": "0.3.1",
4
4
  "description": "SVG filter-based renderer for stacked alpha videos",
5
5
  "type": "module",
6
6
  "files": ["dist", "react.d.ts"],
@@ -1,24 +0,0 @@
1
- "use strict";var Z=Object.defineProperty;var U=h=>{throw TypeError(h)};var tt=(h,n,t)=>n in h?Z(h,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[n]=t;var $=(h,n,t)=>tt(h,typeof n!="symbol"?n+"":n,t),I=(h,n,t)=>n.has(h)||U("Cannot "+t);var e=(h,n,t)=>(I(h,n,"read from private field"),t?t.call(h):n.get(h)),u=(h,n,t)=>n.has(h)?U("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(h):n.set(h,t),a=(h,n,t,r)=>(I(h,n,"write to private field"),r?r.call(h,t):n.set(h,t),t),d=(h,n,t)=>(I(h,n,"access private method"),t);const j=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],et=new Set(["autoplay","loop","muted","playsinline"]),it=["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,w,E,H,y,O,c,F,_,G;class Y extends HTMLElement{constructor(){super();u(this,c);u(this,s);u(this,L);u(this,w);u(this,E);u(this,H);u(this,y,null);u(this,O);const t=this.attachShadow({mode:"open"});a(this,O,`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,O)}" 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,O)})">
15
- <video></video>
16
- </foreignObject>
17
- </svg>`,a(this,L,t.querySelector("svg")),a(this,w,t.querySelector("foreignObject")),a(this,E,t.querySelector("filter")),a(this,H,t.querySelector("feOffset")),a(this,s,t.querySelector("video"));for(const r of it)e(this,s).addEventListener(r,l=>{this.dispatchEvent(new Event(l.type,{bubbles:!1,cancelable:!1}))});e(this,s).addEventListener("loadedmetadata",()=>d(this,c,F).call(this)),e(this,s).addEventListener("resize",()=>d(this,c,F).call(this))}connectedCallback(){for(const t of j)this.hasAttribute(t)&&d(this,c,_).call(this,t,this.getAttribute(t));d(this,c,G).call(this),a(this,y,new MutationObserver(()=>d(this,c,G).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,l){d(this,c,_).call(this,t,l)}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,w=new WeakMap,E=new WeakMap,H=new WeakMap,y=new WeakMap,O=new WeakMap,c=new WeakSet,F=function(){const t=e(this,s).videoWidth,r=e(this,s).videoHeight;if(!t||!r)return;const l=Math.floor(r/2);e(this,L).setAttribute("viewBox",`0 0 ${t} ${l}`),e(this,w).setAttribute("width",String(t)),e(this,w).setAttribute("height",String(r)),e(this,E).setAttribute("width",String(t)),e(this,E).setAttribute("height",String(r)),e(this,H).setAttribute("dy",String(-l))},_=function(t,r){et.has(t)?e(this,s)[t]=r!==null:r===null?e(this,s).removeAttribute(t):e(this,s).setAttribute(t,r)},G=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()},$(Y,"observedAttributes",[...j]);const k="http://www.w3.org/2000/svg",K=["src","crossorigin","preload","autoplay","loop","muted","playsinline","poster","width","height"],st=new Set(["autoplay","loop","muted","playsinline"]),rt=["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,p,T,x,m,v,g,b,f,C,A,S,R,o,D,Q,V,W,B,X,P,z;class J extends HTMLElement{constructor(){super();u(this,o);u(this,i);u(this,p);u(this,T);u(this,x);u(this,m,null);u(this,v,null);u(this,g,!1);u(this,b,0);u(this,f,0);u(this,C);u(this,A,null);u(this,S,null);u(this,R,null);const t=this.attachShadow({mode:"open"});a(this,C,`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
- .clip{overflow:hidden;width:100%}
21
- canvas{display:block;width:100%}
22
- </style>
23
- <video></video>
24
- <div class="clip"><canvas></canvas></div>`,a(this,i,t.querySelector("video")),a(this,x,t.querySelector(".clip")),a(this,p,t.querySelector("canvas")),a(this,T,e(this,p).getContext("2d"));for(const r of rt)e(this,i).addEventListener(r,l=>{this.dispatchEvent(new Event(l.type,{bubbles:!1,cancelable:!1}))});e(this,i).addEventListener("loadedmetadata",()=>d(this,o,V).call(this)),e(this,i).addEventListener("resize",()=>d(this,o,V).call(this))}connectedCallback(){for(const t of K)this.hasAttribute(t)&&d(this,o,W).call(this,t,this.getAttribute(t));d(this,o,B).call(this),a(this,v,new MutationObserver(()=>d(this,o,B).call(this))),e(this,v).observe(this,{childList:!0}),d(this,o,D).call(this),a(this,m,new IntersectionObserver(([t])=>{a(this,g,t.isIntersecting),e(this,g)?d(this,o,X).call(this):d(this,o,P).call(this)},{threshold:0})),e(this,m).observe(this)}disconnectedCallback(){var t,r;d(this,o,P).call(this),(t=e(this,m))==null||t.disconnect(),a(this,m,null),(r=e(this,v))==null||r.disconnect(),a(this,v,null),d(this,o,Q).call(this)}attributeChangedCallback(t,r,l){d(this,o,W).call(this,t,l)}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,p=new WeakMap,T=new WeakMap,x=new WeakMap,m=new WeakMap,v=new WeakMap,g=new WeakMap,b=new WeakMap,f=new WeakMap,C=new WeakMap,A=new WeakMap,S=new WeakMap,R=new WeakMap,o=new WeakSet,D=function(){if(e(this,A))return;const t=document.createElementNS(k,"svg");t.setAttribute("width","0"),t.setAttribute("height","0"),t.style.cssText="position:absolute;overflow:hidden";const r=document.createElementNS(k,"defs"),l=document.createElementNS(k,"filter");l.id=e(this,C),l.setAttribute("filterUnits","userSpaceOnUse"),l.setAttribute("x","0"),l.setAttribute("y","0"),l.setAttribute("width","1"),l.setAttribute("height","1"),l.setAttribute("color-interpolation-filters","sRGB");const q=document.createElementNS(k,"feOffset");q.setAttribute("in","SourceGraphic"),q.setAttribute("dy","0"),q.setAttribute("result","s");const M=document.createElementNS(k,"feColorMatrix");M.setAttribute("in","s"),M.setAttribute("type","matrix"),M.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"),M.setAttribute("result","a");const N=document.createElementNS(k,"feComposite");N.setAttribute("in","SourceGraphic"),N.setAttribute("in2","a"),N.setAttribute("operator","in"),l.append(q,M,N),r.appendChild(l),t.appendChild(r),document.body.appendChild(t),a(this,A,t),a(this,S,l),a(this,R,q)},Q=function(){var t;(t=e(this,A))==null||t.remove(),a(this,A,null),a(this,S,null),a(this,R,null)},V=function(){const t=e(this,i).videoWidth,r=e(this,i).videoHeight;if(!t||!r)return;const l=Math.floor(r/2);e(this,p).width=t,e(this,p).height=r,e(this,x).style.aspectRatio=`${t} / ${l}`,d(this,o,D).call(this),e(this,S).setAttribute("width",String(t)),e(this,S).setAttribute("height",String(r)),e(this,R).setAttribute("dy",String(-l))},W=function(t,r){st.has(t)?e(this,i)[t]=r!==null:r===null?e(this,i).removeAttribute(t):e(this,i).setAttribute(t,r)},B=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()},X=function(){if(e(this,g))if(d(this,o,P).call(this),"requestVideoFrameCallback"in e(this,i)){const t=()=>{e(this,g)&&(d(this,o,z).call(this),a(this,f,e(this,i).requestVideoFrameCallback(t)))};a(this,f,e(this,i).requestVideoFrameCallback(t))}else{const t=()=>{e(this,g)&&(d(this,o,z).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))},z=function(){if(e(this,i).readyState<2)return;const t=e(this,i).videoWidth,r=e(this,i).videoHeight;!t||!r||((e(this,p).width!==t||e(this,p).height!==r)&&d(this,o,V).call(this),e(this,T).filter=`url(#${e(this,C)})`,e(this,T).drawImage(e(this,i),0,0))},$(J,"observedAttributes",[...K]);exports.AlphaVideoKitCanvas=J;exports.AlphaVideoKitSVG=Y;