@avaturn-live/web-sdk 0.0.21 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +6 -0
- package/dist/extra.cjs +48 -0
- package/dist/extra.d.ts +21 -0
- package/dist/extra.js +221 -0
- package/dist/gl-helpers.d.ts +15 -0
- package/dist/main.cjs +8 -8
- package/dist/main.d.ts +7 -0
- package/dist/main.js +79 -70
- package/dist/type.d.ts +22 -0
- package/package.json +7 -1
package/dist/.vite/manifest.json
CHANGED
package/dist/extra.cjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";var G=Object.defineProperty;var x=t=>{throw TypeError(t)};var X=(t,r,e)=>r in t?G(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var R=(t,r,e)=>X(t,typeof r!="symbol"?r+"":r,e),C=(t,r,e)=>r.has(t)||x("Cannot "+e);var i=(t,r,e)=>(C(t,r,"read from private field"),e?e.call(t):r.get(t)),l=(t,r,e)=>r.has(t)?x("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(t):r.set(t,e),h=(t,r,e,a)=>(C(t,r,"write to private field"),a?a.call(t,e):r.set(t,e),e),d=(t,r,e)=>(C(t,r,"access private method"),e);const k=`
|
|
2
|
+
precision mediump float;
|
|
3
|
+
|
|
4
|
+
// our textures
|
|
5
|
+
uniform sampler2D u_frame;
|
|
6
|
+
|
|
7
|
+
// data
|
|
8
|
+
uniform float u_premultipliedAlpha;
|
|
9
|
+
|
|
10
|
+
// the texCoords passed in from the vertex shader.
|
|
11
|
+
varying vec2 v_texCoord;
|
|
12
|
+
|
|
13
|
+
void main() {
|
|
14
|
+
// Calculate the coordinates for the color and alpha
|
|
15
|
+
vec2 colorCoord = vec2(v_texCoord.x, v_texCoord.y * 0.5);
|
|
16
|
+
vec2 alphaCoord = vec2(v_texCoord.x, 0.5 + v_texCoord.y * 0.5);
|
|
17
|
+
|
|
18
|
+
vec4 color = texture2D(u_frame, colorCoord);
|
|
19
|
+
float alpha = texture2D(u_frame, alphaCoord).r;
|
|
20
|
+
|
|
21
|
+
gl_FragColor = vec4(color.rgb * mix(alpha, 1.0, u_premultipliedAlpha), alpha);
|
|
22
|
+
}
|
|
23
|
+
`,B=`
|
|
24
|
+
precision mediump float;
|
|
25
|
+
attribute vec2 a_position;
|
|
26
|
+
uniform mat3 u_matrix;
|
|
27
|
+
varying vec2 v_texCoord;
|
|
28
|
+
|
|
29
|
+
void main() {
|
|
30
|
+
gl_Position = vec4(u_matrix * vec3(a_position, 1), 1);
|
|
31
|
+
|
|
32
|
+
// because we're using a unit quad we can just use
|
|
33
|
+
// the same data for our texcoords.
|
|
34
|
+
v_texCoord = a_position;
|
|
35
|
+
}
|
|
36
|
+
`;function P(t,r,e){const a=t.createShader(e);if(!a)throw Error("Unable to create shader");if(t.shaderSource(a,r),t.compileShader(a),!t.getShaderParameter(a,t.COMPILE_STATUS)){const o=t.getShaderInfoLog(a);throw t.deleteShader(a),Error(o||"unknown error")}return a}function N(t,r){const e=t.createProgram();if(!e)throw Error("Unable to create program");for(const a of r)t.attachShader(e,a);if(t.linkProgram(e),!t.getProgramParameter(e,t.LINK_STATUS)){const a=t.getProgramInfoLog(e);throw t.deleteProgram(e),Error(a||"unknown error")}return e}const L=new WeakMap;function O(t){const r={antialias:!1,powerPreference:"low-power",depth:!1,premultipliedAlpha:!0},e=t.getContext("webgl2",r)??t.getContext("webgl",r);if(!e)throw Error("Couldn't create GL context");const a=P(e,k,e.FRAGMENT_SHADER),o=P(e,B,e.VERTEX_SHADER),c=N(e,[a,o]);e.useProgram(c);const g=e.getAttribLocation(c,"a_position"),U=e.getUniformLocation(c,"u_frame");e.uniform1i(U,0);const D=e.getUniformLocation(c,"u_matrix");L.set(e,e.getUniformLocation(c,"u_premultipliedAlpha")),S(e,!1);const I=e.createBuffer(),F=new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]);e.bindBuffer(e.ARRAY_BUFFER,I),e.bufferData(e.ARRAY_BUFFER,F,e.STATIC_DRAW),e.enableVertexAttribArray(g),e.vertexAttribPointer(g,2,e.FLOAT,!1,0,0),e.uniformMatrix3fv(D,!1,[2,0,0,0,-2,0,-1,1,1]);const M=e.createTexture();return e.bindTexture(e.TEXTURE_2D,M),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e}function S(t,r){t.uniform1f(L.get(t),r?1:0)}function H(t,r){const e=t.canvas,a=r.videoWidth,o=Math.floor(r.videoHeight/2);(e.width!==a||e.height!==o)&&(e.width=a,e.height=o,t.viewport(0,0,a,o)),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r),t.drawArrays(t.TRIANGLES,0,6)}const w=new CSSStyleSheet;w.replaceSync(`
|
|
37
|
+
:host {
|
|
38
|
+
display: inline-block;
|
|
39
|
+
height: auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
canvas {
|
|
43
|
+
display: block;
|
|
44
|
+
width: 100%;
|
|
45
|
+
object-fit: cover;
|
|
46
|
+
height: 100%;
|
|
47
|
+
}
|
|
48
|
+
`);function W(t){return!t.paused&&!t.ended&&t.readyState>2}var v,u,n,p,E,A,T,_,s,f,m,b;class y extends HTMLElement{constructor(){super();l(this,s);l(this,v,this.attachShadow({mode:"closed"}));l(this,u,document.createElement("canvas"));l(this,n,null);l(this,p,null);l(this,E,0);l(this,A,()=>{if(i(this,p)){if(!i(this,n)){i(this,u).remove(),h(this,u,document.createElement("canvas")),i(this,v).append(i(this,u));try{h(this,n,O(i(this,u)))}catch{console.warn("<avaturn-video> Couldn't create GL context")}if(!i(this,n))return;S(i(this,n),this.premultipliedAlpha)}H(i(this,n),i(this,p)),h(this,E,requestAnimationFrame(i(this,A)))}});l(this,T,{videoPlaying:!1,intersecting:!1,connected:!1});l(this,_,!1);l(this,m,null);i(this,v).adoptedStyleSheets=[w],i(this,v).append(i(this,u)),new IntersectionObserver(([e])=>{d(this,s,f).call(this,{intersecting:e.isIntersecting})}).observe(this),new MutationObserver(()=>{this.firstElementChild!==i(this,p)&&d(this,s,b).call(this,this.firstElementChild)}).observe(this,{childList:!0}),d(this,s,b).call(this,this.firstElementChild)}connectedCallback(){d(this,s,f).call(this,{connected:!0})}disconnectedCallback(){d(this,s,f).call(this,{connected:!1})}attributeChangedCallback(e,a,o){if(e==="premultipliedalpha"){if(!i(this,n))return;S(i(this,n),o!==null)}}get premultipliedAlpha(){return this.hasAttribute("premultipliedalpha")}set premultipliedAlpha(e){e?this.setAttribute("premultipliedalpha",""):this.removeAttribute("premultipliedalpha")}}v=new WeakMap,u=new WeakMap,n=new WeakMap,p=new WeakMap,E=new WeakMap,A=new WeakMap,T=new WeakMap,_=new WeakMap,s=new WeakSet,f=function(e){Object.assign(i(this,T),e),!i(this,_)&&(h(this,_,!0),queueMicrotask(()=>{var g;h(this,_,!1);const{videoPlaying:a,connected:o,intersecting:c}=i(this,T);if(cancelAnimationFrame(i(this,E)),!o||!a||!c){i(this,n)&&((g=i(this,n).getExtension("WEBGL_lose_context"))==null||g.loseContext(),h(this,n,null));return}h(this,E,requestAnimationFrame(i(this,A)))}))},m=new WeakMap,b=function(e){if(i(this,m)&&i(this,m).abort(),e&&!(e instanceof HTMLVideoElement)){console.warn("<avaturn-video> Child must be a <video>"),h(this,p,null),d(this,s,f).call(this,{videoPlaying:!1});return}if(h(this,p,e),!e){d(this,s,f).call(this,{videoPlaying:!1});return}e.autoplay&&setTimeout(()=>{e.play()},0);const a=()=>{d(this,s,f).call(this,{videoPlaying:W(e)})};a(),h(this,m,new AbortController);const o=i(this,m).signal;for(const c of["playing","stalled","emptied","ended","pause"])e.addEventListener(c,a,{signal:o})},R(y,"observedAttributes",["premultipliedalpha"]);customElements.define("avaturn-video",y);
|
package/dist/extra.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface HTMLElementTagNameMap {
|
|
3
|
+
"avaturn-video": StackedAlphaVideo;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
declare class StackedAlphaVideo extends HTMLElement {
|
|
7
|
+
#private;
|
|
8
|
+
static observedAttributes: string[];
|
|
9
|
+
constructor();
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
disconnectedCallback(): void;
|
|
12
|
+
attributeChangedCallback(name: string, _: string, newValue: string): void;
|
|
13
|
+
get premultipliedAlpha(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Set whether the source video uses premultiplied alpha.
|
|
16
|
+
*
|
|
17
|
+
* Set this to `true` if semi-transparent areas or outlines look too dark.
|
|
18
|
+
*/
|
|
19
|
+
set premultipliedAlpha(value: boolean);
|
|
20
|
+
}
|
|
21
|
+
export {};
|
package/dist/extra.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
var G = Object.defineProperty;
|
|
2
|
+
var x = (t) => {
|
|
3
|
+
throw TypeError(t);
|
|
4
|
+
};
|
|
5
|
+
var X = (t, r, e) => r in t ? G(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
|
|
6
|
+
var R = (t, r, e) => X(t, typeof r != "symbol" ? r + "" : r, e), C = (t, r, e) => r.has(t) || x("Cannot " + e);
|
|
7
|
+
var i = (t, r, e) => (C(t, r, "read from private field"), e ? e.call(t) : r.get(t)), l = (t, r, e) => r.has(t) ? x("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(t) : r.set(t, e), h = (t, r, e, a) => (C(t, r, "write to private field"), a ? a.call(t, e) : r.set(t, e), e), d = (t, r, e) => (C(t, r, "access private method"), e);
|
|
8
|
+
const k = `
|
|
9
|
+
precision mediump float;
|
|
10
|
+
|
|
11
|
+
// our textures
|
|
12
|
+
uniform sampler2D u_frame;
|
|
13
|
+
|
|
14
|
+
// data
|
|
15
|
+
uniform float u_premultipliedAlpha;
|
|
16
|
+
|
|
17
|
+
// the texCoords passed in from the vertex shader.
|
|
18
|
+
varying vec2 v_texCoord;
|
|
19
|
+
|
|
20
|
+
void main() {
|
|
21
|
+
// Calculate the coordinates for the color and alpha
|
|
22
|
+
vec2 colorCoord = vec2(v_texCoord.x, v_texCoord.y * 0.5);
|
|
23
|
+
vec2 alphaCoord = vec2(v_texCoord.x, 0.5 + v_texCoord.y * 0.5);
|
|
24
|
+
|
|
25
|
+
vec4 color = texture2D(u_frame, colorCoord);
|
|
26
|
+
float alpha = texture2D(u_frame, alphaCoord).r;
|
|
27
|
+
|
|
28
|
+
gl_FragColor = vec4(color.rgb * mix(alpha, 1.0, u_premultipliedAlpha), alpha);
|
|
29
|
+
}
|
|
30
|
+
`, B = `
|
|
31
|
+
precision mediump float;
|
|
32
|
+
attribute vec2 a_position;
|
|
33
|
+
uniform mat3 u_matrix;
|
|
34
|
+
varying vec2 v_texCoord;
|
|
35
|
+
|
|
36
|
+
void main() {
|
|
37
|
+
gl_Position = vec4(u_matrix * vec3(a_position, 1), 1);
|
|
38
|
+
|
|
39
|
+
// because we're using a unit quad we can just use
|
|
40
|
+
// the same data for our texcoords.
|
|
41
|
+
v_texCoord = a_position;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
function P(t, r, e) {
|
|
45
|
+
const a = t.createShader(e);
|
|
46
|
+
if (!a)
|
|
47
|
+
throw Error("Unable to create shader");
|
|
48
|
+
if (t.shaderSource(a, r), t.compileShader(a), !t.getShaderParameter(a, t.COMPILE_STATUS)) {
|
|
49
|
+
const o = t.getShaderInfoLog(a);
|
|
50
|
+
throw t.deleteShader(a), Error(o || "unknown error");
|
|
51
|
+
}
|
|
52
|
+
return a;
|
|
53
|
+
}
|
|
54
|
+
function N(t, r) {
|
|
55
|
+
const e = t.createProgram();
|
|
56
|
+
if (!e)
|
|
57
|
+
throw Error("Unable to create program");
|
|
58
|
+
for (const a of r)
|
|
59
|
+
t.attachShader(e, a);
|
|
60
|
+
if (t.linkProgram(e), !t.getProgramParameter(e, t.LINK_STATUS)) {
|
|
61
|
+
const a = t.getProgramInfoLog(e);
|
|
62
|
+
throw t.deleteProgram(e), Error(a || "unknown error");
|
|
63
|
+
}
|
|
64
|
+
return e;
|
|
65
|
+
}
|
|
66
|
+
const L = /* @__PURE__ */ new WeakMap();
|
|
67
|
+
function O(t) {
|
|
68
|
+
const r = {
|
|
69
|
+
antialias: !1,
|
|
70
|
+
powerPreference: "low-power",
|
|
71
|
+
depth: !1,
|
|
72
|
+
premultipliedAlpha: !0
|
|
73
|
+
}, e = t.getContext("webgl2", r) ?? t.getContext("webgl", r);
|
|
74
|
+
if (!e)
|
|
75
|
+
throw Error("Couldn't create GL context");
|
|
76
|
+
const a = P(e, k, e.FRAGMENT_SHADER), o = P(e, B, e.VERTEX_SHADER), c = N(e, [a, o]);
|
|
77
|
+
e.useProgram(c);
|
|
78
|
+
const g = e.getAttribLocation(c, "a_position"), U = e.getUniformLocation(c, "u_frame");
|
|
79
|
+
e.uniform1i(U, 0);
|
|
80
|
+
const D = e.getUniformLocation(c, "u_matrix");
|
|
81
|
+
L.set(e, e.getUniformLocation(c, "u_premultipliedAlpha")), S(e, !1);
|
|
82
|
+
const I = e.createBuffer(), F = new Float32Array([
|
|
83
|
+
0,
|
|
84
|
+
0,
|
|
85
|
+
1,
|
|
86
|
+
0,
|
|
87
|
+
0,
|
|
88
|
+
1,
|
|
89
|
+
0,
|
|
90
|
+
1,
|
|
91
|
+
1,
|
|
92
|
+
0,
|
|
93
|
+
1,
|
|
94
|
+
1
|
|
95
|
+
]);
|
|
96
|
+
e.bindBuffer(e.ARRAY_BUFFER, I), e.bufferData(e.ARRAY_BUFFER, F, e.STATIC_DRAW), e.enableVertexAttribArray(g), e.vertexAttribPointer(g, 2, e.FLOAT, !1, 0, 0), e.uniformMatrix3fv(D, !1, [2, 0, 0, 0, -2, 0, -1, 1, 1]);
|
|
97
|
+
const M = e.createTexture();
|
|
98
|
+
return e.bindTexture(e.TEXTURE_2D, M), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e;
|
|
99
|
+
}
|
|
100
|
+
function S(t, r) {
|
|
101
|
+
t.uniform1f(L.get(t), r ? 1 : 0);
|
|
102
|
+
}
|
|
103
|
+
function H(t, r) {
|
|
104
|
+
const e = t.canvas, a = r.videoWidth, o = Math.floor(r.videoHeight / 2);
|
|
105
|
+
(e.width !== a || e.height !== o) && (e.width = a, e.height = o, t.viewport(0, 0, a, o)), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, r), t.drawArrays(t.TRIANGLES, 0, 6);
|
|
106
|
+
}
|
|
107
|
+
const w = new CSSStyleSheet();
|
|
108
|
+
w.replaceSync(`
|
|
109
|
+
:host {
|
|
110
|
+
display: inline-block;
|
|
111
|
+
height: auto;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
canvas {
|
|
115
|
+
display: block;
|
|
116
|
+
width: 100%;
|
|
117
|
+
object-fit: cover;
|
|
118
|
+
height: 100%;
|
|
119
|
+
}
|
|
120
|
+
`);
|
|
121
|
+
function W(t) {
|
|
122
|
+
return !t.paused && !t.ended && t.readyState > 2;
|
|
123
|
+
}
|
|
124
|
+
var v, u, n, p, E, A, T, _, s, f, m, b;
|
|
125
|
+
class y extends HTMLElement {
|
|
126
|
+
constructor() {
|
|
127
|
+
super();
|
|
128
|
+
l(this, s);
|
|
129
|
+
l(this, v, this.attachShadow({ mode: "closed" }));
|
|
130
|
+
l(this, u, document.createElement("canvas"));
|
|
131
|
+
l(this, n, null);
|
|
132
|
+
l(this, p, null);
|
|
133
|
+
l(this, E, 0);
|
|
134
|
+
l(this, A, () => {
|
|
135
|
+
if (i(this, p)) {
|
|
136
|
+
if (!i(this, n)) {
|
|
137
|
+
i(this, u).remove(), h(this, u, document.createElement("canvas")), i(this, v).append(i(this, u));
|
|
138
|
+
try {
|
|
139
|
+
h(this, n, O(i(this, u)));
|
|
140
|
+
} catch {
|
|
141
|
+
console.warn("<avaturn-video> Couldn't create GL context");
|
|
142
|
+
}
|
|
143
|
+
if (!i(this, n))
|
|
144
|
+
return;
|
|
145
|
+
S(i(this, n), this.premultipliedAlpha);
|
|
146
|
+
}
|
|
147
|
+
H(i(this, n), i(this, p)), h(this, E, requestAnimationFrame(i(this, A)));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
l(this, T, {
|
|
151
|
+
videoPlaying: !1,
|
|
152
|
+
intersecting: !1,
|
|
153
|
+
connected: !1
|
|
154
|
+
});
|
|
155
|
+
l(this, _, !1);
|
|
156
|
+
l(this, m, null);
|
|
157
|
+
i(this, v).adoptedStyleSheets = [w], i(this, v).append(i(this, u)), new IntersectionObserver(([e]) => {
|
|
158
|
+
d(this, s, f).call(this, { intersecting: e.isIntersecting });
|
|
159
|
+
}).observe(this), new MutationObserver(() => {
|
|
160
|
+
this.firstElementChild !== i(this, p) && d(this, s, b).call(this, this.firstElementChild);
|
|
161
|
+
}).observe(this, {
|
|
162
|
+
childList: !0
|
|
163
|
+
}), d(this, s, b).call(this, this.firstElementChild);
|
|
164
|
+
}
|
|
165
|
+
connectedCallback() {
|
|
166
|
+
d(this, s, f).call(this, { connected: !0 });
|
|
167
|
+
}
|
|
168
|
+
disconnectedCallback() {
|
|
169
|
+
d(this, s, f).call(this, { connected: !1 });
|
|
170
|
+
}
|
|
171
|
+
attributeChangedCallback(e, a, o) {
|
|
172
|
+
if (e === "premultipliedalpha") {
|
|
173
|
+
if (!i(this, n))
|
|
174
|
+
return;
|
|
175
|
+
S(i(this, n), o !== null);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
get premultipliedAlpha() {
|
|
179
|
+
return this.hasAttribute("premultipliedalpha");
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Set whether the source video uses premultiplied alpha.
|
|
183
|
+
*
|
|
184
|
+
* Set this to `true` if semi-transparent areas or outlines look too dark.
|
|
185
|
+
*/
|
|
186
|
+
set premultipliedAlpha(e) {
|
|
187
|
+
e ? this.setAttribute("premultipliedalpha", "") : this.removeAttribute("premultipliedalpha");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
v = new WeakMap(), u = new WeakMap(), n = new WeakMap(), p = new WeakMap(), E = new WeakMap(), A = new WeakMap(), T = new WeakMap(), _ = new WeakMap(), s = new WeakSet(), f = function(e) {
|
|
191
|
+
Object.assign(i(this, T), e), !i(this, _) && (h(this, _, !0), queueMicrotask(() => {
|
|
192
|
+
var g;
|
|
193
|
+
h(this, _, !1);
|
|
194
|
+
const { videoPlaying: a, connected: o, intersecting: c } = i(this, T);
|
|
195
|
+
if (cancelAnimationFrame(i(this, E)), !o || !a || !c) {
|
|
196
|
+
i(this, n) && ((g = i(this, n).getExtension("WEBGL_lose_context")) == null || g.loseContext(), h(this, n, null));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
h(this, E, requestAnimationFrame(i(this, A)));
|
|
200
|
+
}));
|
|
201
|
+
}, m = new WeakMap(), b = function(e) {
|
|
202
|
+
if (i(this, m) && i(this, m).abort(), e && !(e instanceof HTMLVideoElement)) {
|
|
203
|
+
console.warn("<avaturn-video> Child must be a <video>"), h(this, p, null), d(this, s, f).call(this, { videoPlaying: !1 });
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (h(this, p, e), !e) {
|
|
207
|
+
d(this, s, f).call(this, { videoPlaying: !1 });
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
e.autoplay && setTimeout(() => {
|
|
211
|
+
e.play();
|
|
212
|
+
}, 0);
|
|
213
|
+
const a = () => {
|
|
214
|
+
d(this, s, f).call(this, { videoPlaying: W(e) });
|
|
215
|
+
};
|
|
216
|
+
a(), h(this, m, new AbortController());
|
|
217
|
+
const o = i(this, m).signal;
|
|
218
|
+
for (const c of ["playing", "stalled", "emptied", "ended", "pause"])
|
|
219
|
+
e.addEventListener(c, a, { signal: o });
|
|
220
|
+
}, R(y, "observedAttributes", ["premultipliedalpha"]);
|
|
221
|
+
customElements.define("avaturn-video", y);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a GL context for a canvas.
|
|
3
|
+
* This only needs to be done once per canvas.
|
|
4
|
+
*/
|
|
5
|
+
export declare function setupGLContext(canvas: HTMLCanvasElement | OffscreenCanvas): WebGLRenderingContext | WebGL2RenderingContext;
|
|
6
|
+
/**
|
|
7
|
+
* Set whether the source video uses premultiplied alpha.
|
|
8
|
+
*
|
|
9
|
+
* Set this to `true` if semi-transparent areas or outlines look too dark.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setPremultipliedAlpha(context: WebGLRenderingContext | WebGL2RenderingContext, premultipliedAlpha: boolean): void;
|
|
12
|
+
/**
|
|
13
|
+
* Draw a stacked-alpha video frame to a GL context.
|
|
14
|
+
*/
|
|
15
|
+
export declare function drawVideo(context: WebGLRenderingContext | WebGL2RenderingContext, video: HTMLVideoElement): void;
|