@alpha-video-kit/svg 0.3.0 → 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.
- package/dist/{canvas-component-C3vC6FBw.js → canvas-component-BJ29dbCJ.js} +95 -93
- package/dist/canvas-component-BR3Vuf_h.cjs +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.js +26 -26
- package/dist/register.cjs +1 -1
- package/dist/register.js +1 -1
- package/package.json +1 -1
- package/dist/canvas-component-CE05m0PN.cjs +0 -24
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var X = Object.defineProperty;
|
|
2
|
+
var j = (n) => {
|
|
3
|
+
throw TypeError(n);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var e = (
|
|
8
|
-
const
|
|
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
|
-
],
|
|
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,
|
|
45
|
-
class
|
|
44
|
+
var s, L, O, T, N, y, C, 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
|
-
u(this, E);
|
|
53
|
-
u(this, x);
|
|
54
|
-
u(this, y, null);
|
|
55
51
|
u(this, O);
|
|
52
|
+
u(this, T);
|
|
53
|
+
u(this, N);
|
|
54
|
+
u(this, y, null);
|
|
55
|
+
u(this, C);
|
|
56
56
|
const t = this.attachShadow({ mode: "open" });
|
|
57
|
-
a(this,
|
|
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,
|
|
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,
|
|
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,
|
|
74
|
-
for (const r of
|
|
75
|
-
e(this, s).addEventListener(r, (
|
|
76
|
-
this.dispatchEvent(new Event(
|
|
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
|
+
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,
|
|
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
|
|
82
|
-
this.hasAttribute(t) && d(this, c,
|
|
83
|
-
d(this, c,
|
|
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,
|
|
90
|
-
d(this, c,
|
|
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(),
|
|
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
|
-
const
|
|
210
|
-
e(this, L).setAttribute("viewBox", `0 0 ${t} ${
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
},
|
|
209
|
+
const o = Math.floor(r / 2);
|
|
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
|
+
}, 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
|
-
},
|
|
218
|
-
const
|
|
217
|
+
}, V(it, "observedAttributes", [...Y]);
|
|
218
|
+
const E = "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
|
-
],
|
|
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,
|
|
255
|
-
class
|
|
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
|
+
class at extends HTMLElement {
|
|
256
256
|
constructor() {
|
|
257
257
|
super();
|
|
258
|
-
u(this,
|
|
258
|
+
u(this, h);
|
|
259
259
|
u(this, i);
|
|
260
|
-
u(this,
|
|
261
|
-
u(this,
|
|
262
|
-
u(this,
|
|
263
|
-
u(this,
|
|
264
|
-
u(this,
|
|
265
|
-
u(this,
|
|
260
|
+
u(this, m);
|
|
261
|
+
u(this, R);
|
|
262
|
+
u(this, g);
|
|
263
|
+
u(this, v);
|
|
264
|
+
u(this, A, null);
|
|
265
|
+
u(this, S, 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,
|
|
270
|
-
u(this,
|
|
271
|
-
u(this,
|
|
272
|
-
u(this,
|
|
270
|
+
u(this, M);
|
|
271
|
+
u(this, k, null);
|
|
272
|
+
u(this, w, null);
|
|
273
|
+
u(this, q, null);
|
|
273
274
|
const t = this.attachShadow({ mode: "open" });
|
|
274
|
-
a(this,
|
|
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
|
-
<
|
|
282
|
-
for (const r of
|
|
283
|
-
e(this, i).addEventListener(r, (
|
|
284
|
-
this.dispatchEvent(new Event(
|
|
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
|
+
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,
|
|
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
|
|
290
|
-
this.hasAttribute(t) && d(this,
|
|
291
|
-
d(this,
|
|
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, 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
|
-
a(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,
|
|
296
|
+
)), e(this, A).observe(this);
|
|
297
297
|
}
|
|
298
298
|
disconnectedCallback() {
|
|
299
299
|
var t, r;
|
|
300
|
-
d(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
|
-
attributeChangedCallback(t, r,
|
|
303
|
-
d(this,
|
|
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(),
|
|
420
|
-
if (e(this,
|
|
421
|
-
const t = document.createElementNS(
|
|
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(
|
|
424
|
-
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
},
|
|
423
|
+
const r = document.createElementNS(E, "defs"), o = document.createElementNS(E, "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(E, "feOffset");
|
|
426
|
+
x.setAttribute("in", "SourceGraphic"), x.setAttribute("dy", "0"), x.setAttribute("result", "s");
|
|
427
|
+
const H = document.createElementNS(E, "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(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
|
+
}, K = function() {
|
|
432
432
|
var t;
|
|
433
|
-
(t = e(this,
|
|
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
|
-
const
|
|
438
|
-
e(this,
|
|
439
|
-
},
|
|
440
|
-
|
|
441
|
-
},
|
|
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, w).setAttribute("width", String(t)), e(this, w).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
|
-
},
|
|
446
|
-
if (e(this,
|
|
447
|
-
if (d(this,
|
|
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,
|
|
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,
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
|
465
|
-
|
|
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, 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
|
+
}, V(at, "observedAttributes", [...J]);
|
|
466
468
|
export {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
+
at as A,
|
|
470
|
+
it as a
|
|
469
471
|
};
|
|
@@ -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,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
|
+
: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,T)}" 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,T)})">
|
|
15
|
+
<video></video>
|
|
16
|
+
</foreignObject>
|
|
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
|
+
: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,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
|
|
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.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
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
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
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const { canvas:
|
|
5
|
-
let
|
|
6
|
-
function
|
|
7
|
-
if (
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
t.id =
|
|
12
|
-
const r = document.createElementNS(
|
|
1
|
+
import { A as x, a as y } from "./canvas-component-BJ29dbCJ.js";
|
|
2
|
+
const o = "http://www.w3.org/2000/svg";
|
|
3
|
+
function g(f) {
|
|
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
|
+
function b() {
|
|
7
|
+
if (s) return;
|
|
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
|
+
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 r = document.createElementNS(o, "feOffset");
|
|
13
13
|
r.setAttribute("in", "SourceGraphic"), r.setAttribute("dy", "0"), r.setAttribute("result", "s");
|
|
14
|
-
const u = document.createElementNS(
|
|
14
|
+
const u = document.createElementNS(o, "feColorMatrix");
|
|
15
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
|
|
17
|
-
|
|
16
|
+
const d = document.createElementNS(o, "feComposite");
|
|
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(
|
|
20
|
+
drawFrame(i) {
|
|
21
21
|
if (a) return;
|
|
22
|
-
const
|
|
23
|
-
(
|
|
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(
|
|
25
|
+
setPremultipliedAlpha(i) {
|
|
26
26
|
},
|
|
27
27
|
destroy() {
|
|
28
|
-
a || (a = !0,
|
|
28
|
+
a || (a = !0, s == null || s.remove(), s = null, c = null, m = null);
|
|
29
29
|
},
|
|
30
30
|
get isDestroyed() {
|
|
31
31
|
return a;
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
35
|
+
function w(f) {
|
|
36
|
+
return g(f);
|
|
37
37
|
}
|
|
38
38
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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-
|
|
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-
|
|
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,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;
|