@factorialco/f0-react 1.413.1 → 1.414.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/{F0AiChat-CMz8oLke.js → F0AiChat-CBy7rZCW.js} +5283 -4978
- package/dist/F0ChatDashboard.d.ts +6 -6
- package/dist/{F0HILActionConfirmation-MJSEogqB.js → F0HILActionConfirmation-BvAjbJKj.js} +129 -123
- package/dist/ai.d.ts +18 -6
- package/dist/ai.js +2 -2
- package/dist/experimental.d.ts +12 -6
- package/dist/experimental.js +4 -4
- package/dist/f0.d.ts +18 -6
- package/dist/f0.js +5 -5
- package/dist/i18n-provider-defaults.d.ts +12 -6
- package/dist/i18n-provider-defaults.js +6 -0
- package/dist/{index-Brt3Hz6G.js → index-C0vtKpW9.js} +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx as q, jsxs as le } from "react/jsx-runtime";
|
|
2
|
-
import { useInsertionEffect as ze, createContext as
|
|
3
|
-
import { r as He, i as je, m as Ke, a as Qe, b as Me, d as Je, c as Ze, f as et, e as tt, s as rt, g as
|
|
2
|
+
import { useInsertionEffect as ze, createContext as Ye, useContext as Xe, useRef as B, useEffect as ie, useState as Ue, useCallback as $e, useMemo as qe } from "react";
|
|
3
|
+
import { r as He, i as je, m as Ke, a as Qe, b as Me, d as Je, c as Ze, f as et, e as tt, s as rt, g as Oe, p as nt, V as ot, h as it, j as st, k as at, S as ct, H as ut, v as se, l as lt, n as ft, o as ht, q as dt, t as mt, w as pt, F as fe, x as vt } from "./F0Input-C9w04Jpr.js";
|
|
4
4
|
import { useTrackVolume as gt } from "@livekit/components-react";
|
|
5
|
-
import { G as wt } from "./F0AiChat-
|
|
6
|
-
function
|
|
5
|
+
import { G as wt } from "./F0AiChat-CBy7rZCW.js";
|
|
6
|
+
function yt(t, e, r) {
|
|
7
7
|
ze(() => t.on(e, r), [t, e, r]);
|
|
8
8
|
}
|
|
9
9
|
function ue(t) {
|
|
10
10
|
return typeof t == "object" && !Array.isArray(t);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function Ne(t, e, r, n) {
|
|
13
13
|
return typeof t == "string" && ue(e) ? He(t, r, n) : t instanceof NodeList ? Array.from(t) : Array.isArray(t) ? t : [t];
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function Tt(t, e, r) {
|
|
16
16
|
return t * (e + 1);
|
|
17
17
|
}
|
|
18
18
|
function he(t, e, r, n) {
|
|
@@ -52,21 +52,21 @@ function Ct(t, { defaultTransition: e = {}, ...r } = {}, n, o) {
|
|
|
52
52
|
const c = e.duration || 0.3, m = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), v = {}, R = /* @__PURE__ */ new Map();
|
|
53
53
|
let p = 0, g = 0, x = 0;
|
|
54
54
|
for (let l = 0; l < t.length; l++) {
|
|
55
|
-
const
|
|
56
|
-
if (typeof
|
|
57
|
-
R.set(
|
|
55
|
+
const y = t[l];
|
|
56
|
+
if (typeof y == "string") {
|
|
57
|
+
R.set(y, g);
|
|
58
58
|
continue;
|
|
59
|
-
} else if (!Array.isArray(
|
|
60
|
-
R.set(
|
|
59
|
+
} else if (!Array.isArray(y)) {
|
|
60
|
+
R.set(y.name, he(g, y.at, p, R));
|
|
61
61
|
continue;
|
|
62
62
|
}
|
|
63
|
-
let [F, d, S = {}] =
|
|
63
|
+
let [F, d, S = {}] = y;
|
|
64
64
|
S.at !== void 0 && (g = he(g, S.at, p, R));
|
|
65
65
|
let C = 0;
|
|
66
|
-
const U = (
|
|
67
|
-
const A = It(
|
|
66
|
+
const U = (T, w, I, P = 0, D = 0) => {
|
|
67
|
+
const A = It(T), { delay: f = 0, times: _ = Je(A), type: N = "keyframes", repeat: W, repeatType: k, repeatDelay: H = 0, ...z } = w;
|
|
68
68
|
let { ease: M = e.ease || "easeOut", duration: L } = w;
|
|
69
|
-
const
|
|
69
|
+
const O = typeof f == "function" ? f(P, D) : f, j = A.length, Z = tt(N) ? N : o?.[N];
|
|
70
70
|
if (j <= 2 && Z) {
|
|
71
71
|
let K = 100;
|
|
72
72
|
if (j === 2 && Pt(A)) {
|
|
@@ -79,11 +79,11 @@ function Ct(t, { defaultTransition: e = {}, ...r } = {}, n, o) {
|
|
|
79
79
|
M = ee.ease, L = ee.duration;
|
|
80
80
|
}
|
|
81
81
|
L ?? (L = c);
|
|
82
|
-
const $ = g +
|
|
82
|
+
const $ = g + O;
|
|
83
83
|
_.length === 1 && _[0] === 0 && (_[1] = 1);
|
|
84
84
|
const re = _.length - A.length;
|
|
85
85
|
if (re > 0 && et(_, re), A.length === 1 && A.unshift(null), W) {
|
|
86
|
-
|
|
86
|
+
Oe(W < Lt, "Repeat count too high, must be less than 20"), L = Tt(L, W);
|
|
87
87
|
const K = [...A], Q = [..._];
|
|
88
88
|
M = Array.isArray(M) ? [...M] : [M];
|
|
89
89
|
const ee = [...M];
|
|
@@ -95,23 +95,23 @@ function Ct(t, { defaultTransition: e = {}, ...r } = {}, n, o) {
|
|
|
95
95
|
Rt(_, W);
|
|
96
96
|
}
|
|
97
97
|
const ne = $ + L;
|
|
98
|
-
At(I, A, M, _, $, ne), C = Math.max(
|
|
98
|
+
At(I, A, M, _, $, ne), C = Math.max(O + L, C), x = Math.max(ne, x);
|
|
99
99
|
};
|
|
100
100
|
if (Me(F)) {
|
|
101
|
-
const
|
|
102
|
-
U(d, S, me("default",
|
|
101
|
+
const T = de(F, b);
|
|
102
|
+
U(d, S, me("default", T));
|
|
103
103
|
} else {
|
|
104
|
-
const
|
|
104
|
+
const T = Ne(F, d, n, v), w = T.length;
|
|
105
105
|
for (let I = 0; I < w; I++) {
|
|
106
106
|
d = d, S = S;
|
|
107
|
-
const P =
|
|
107
|
+
const P = T[I], D = de(P, b);
|
|
108
108
|
for (const A in d)
|
|
109
109
|
U(d[A], _t(S, A), me(A, D), I, w);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
p = g, g += C;
|
|
113
113
|
}
|
|
114
|
-
return b.forEach((l,
|
|
114
|
+
return b.forEach((l, y) => {
|
|
115
115
|
for (const F in l) {
|
|
116
116
|
const d = l[F];
|
|
117
117
|
d.sort(xt);
|
|
@@ -120,12 +120,12 @@ function Ct(t, { defaultTransition: e = {}, ...r } = {}, n, o) {
|
|
|
120
120
|
const { at: I, value: P, easing: D } = d[w];
|
|
121
121
|
S.push(P), C.push(nt(0, x, I)), U.push(D || "easeOut");
|
|
122
122
|
}
|
|
123
|
-
C[0] !== 0 && (C.unshift(0), S.unshift(S[0]), U.unshift(St)), C[C.length - 1] !== 1 && (C.push(1), S.push(null)), m.has(
|
|
123
|
+
C[0] !== 0 && (C.unshift(0), S.unshift(S[0]), U.unshift(St)), C[C.length - 1] !== 1 && (C.push(1), S.push(null)), m.has(y) || m.set(y, {
|
|
124
124
|
keyframes: {},
|
|
125
125
|
transition: {}
|
|
126
126
|
});
|
|
127
|
-
const
|
|
128
|
-
|
|
127
|
+
const T = m.get(y);
|
|
128
|
+
T.keyframes[F] = S, T.transition[F] = {
|
|
129
129
|
...e,
|
|
130
130
|
duration: x,
|
|
131
131
|
ease: U,
|
|
@@ -183,7 +183,7 @@ class Mt extends ot {
|
|
|
183
183
|
return 0;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function Ot(t) {
|
|
187
187
|
const e = {
|
|
188
188
|
presenceContext: null,
|
|
189
189
|
props: {},
|
|
@@ -200,7 +200,7 @@ function Nt(t) {
|
|
|
200
200
|
}, r = st(t) && !at(t) ? new ct(e) : new ut(e);
|
|
201
201
|
r.mount(t), se.set(t, r);
|
|
202
202
|
}
|
|
203
|
-
function
|
|
203
|
+
function Nt(t) {
|
|
204
204
|
const e = {
|
|
205
205
|
presenceContext: null,
|
|
206
206
|
props: {},
|
|
@@ -221,10 +221,10 @@ function De(t, e, r, n) {
|
|
|
221
221
|
if (Bt(t, e))
|
|
222
222
|
o.push(lt(t, ue(e) && e.default || e, r && (r.default || r)));
|
|
223
223
|
else {
|
|
224
|
-
const c =
|
|
225
|
-
|
|
224
|
+
const c = Ne(t, e, n), m = c.length;
|
|
225
|
+
Oe(!!m, "No valid elements provided.");
|
|
226
226
|
for (let b = 0; b < m; b++) {
|
|
227
|
-
const v = c[b], R = v instanceof Element ?
|
|
227
|
+
const v = c[b], R = v instanceof Element ? Ot : Nt;
|
|
228
228
|
se.has(v) || R(v);
|
|
229
229
|
const p = se.get(v), g = { ...r };
|
|
230
230
|
"delay" in g && typeof g.delay == "function" && (g.delay = g.delay(b, m)), o.push(...ft(p, { ...e, transition: g }, {}));
|
|
@@ -379,11 +379,17 @@ const zt = Wt(), Er = ["xs", "sm", "md", "lg"], Ar = [
|
|
|
379
379
|
dataDownload: {
|
|
380
380
|
download: "Download {{format}}"
|
|
381
381
|
},
|
|
382
|
+
pong: {
|
|
383
|
+
ai: "AI",
|
|
384
|
+
you: "YOU",
|
|
385
|
+
youWin: "You win!",
|
|
386
|
+
youLose: "You lose!"
|
|
387
|
+
},
|
|
382
388
|
unsavedChanges: "Unsaved changes",
|
|
383
389
|
saveChanges: "Save changes",
|
|
384
390
|
discardChanges: "Discard"
|
|
385
391
|
}
|
|
386
|
-
}, Ve =
|
|
392
|
+
}, Ve = Ye(null);
|
|
387
393
|
function xr({
|
|
388
394
|
children: t,
|
|
389
395
|
translations: e
|
|
@@ -391,7 +397,7 @@ function xr({
|
|
|
391
397
|
return /* @__PURE__ */ q(Ve.Provider, { value: e, children: t });
|
|
392
398
|
}
|
|
393
399
|
function Sr() {
|
|
394
|
-
const t =
|
|
400
|
+
const t = Xe(Ve);
|
|
395
401
|
if (t === null)
|
|
396
402
|
throw new Error(
|
|
397
403
|
"useAiChatTranslations must be used within an AiChatTranslationsProvider"
|
|
@@ -399,41 +405,41 @@ function Sr() {
|
|
|
399
405
|
return t;
|
|
400
406
|
}
|
|
401
407
|
function pe(t, e, r, n) {
|
|
402
|
-
const o = Math.max(1, Math.min(t, e)), c = Math.min(r, 20), b = Math.min(c + n, o), v = Math.min(b, Math.floor(t / 2)), R = Math.min(b, Math.floor(e / 2)), p = ($) => $ / t * 2 - 1, g = ($) => $ / e * 2 - 1, x = 0, l = t,
|
|
408
|
+
const o = Math.max(1, Math.min(t, e)), c = Math.min(r, 20), b = Math.min(c + n, o), v = Math.min(b, Math.floor(t / 2)), R = Math.min(b, Math.floor(e / 2)), p = ($) => $ / t * 2 - 1, g = ($) => $ / e * 2 - 1, x = 0, l = t, y = 0, F = e, d = v, S = t - v, C = R, U = e - R, T = p(x), w = p(l), I = g(y), P = g(F), D = p(d), A = p(S), f = g(C), _ = g(U), N = 0, W = 0, k = 1, H = 1, z = v / t, M = 1 - v / t, L = R / e, O = 1 - R / e, j = new Float32Array([
|
|
403
409
|
// Top strip
|
|
404
|
-
|
|
410
|
+
T,
|
|
405
411
|
I,
|
|
406
412
|
w,
|
|
407
413
|
I,
|
|
408
|
-
|
|
414
|
+
T,
|
|
409
415
|
f,
|
|
410
|
-
|
|
416
|
+
T,
|
|
411
417
|
f,
|
|
412
418
|
w,
|
|
413
419
|
I,
|
|
414
420
|
w,
|
|
415
421
|
f,
|
|
416
422
|
// Bottom strip
|
|
417
|
-
|
|
423
|
+
T,
|
|
418
424
|
_,
|
|
419
425
|
w,
|
|
420
426
|
_,
|
|
421
|
-
|
|
427
|
+
T,
|
|
422
428
|
P,
|
|
423
|
-
|
|
429
|
+
T,
|
|
424
430
|
P,
|
|
425
431
|
w,
|
|
426
432
|
_,
|
|
427
433
|
w,
|
|
428
434
|
P,
|
|
429
435
|
// Left strip
|
|
430
|
-
|
|
436
|
+
T,
|
|
431
437
|
f,
|
|
432
438
|
D,
|
|
433
439
|
f,
|
|
434
|
-
|
|
440
|
+
T,
|
|
435
441
|
_,
|
|
436
|
-
|
|
442
|
+
T,
|
|
437
443
|
_,
|
|
438
444
|
D,
|
|
439
445
|
f,
|
|
@@ -454,57 +460,57 @@ function pe(t, e, r, n) {
|
|
|
454
460
|
_
|
|
455
461
|
]), Z = new Float32Array([
|
|
456
462
|
// Top strip
|
|
457
|
-
|
|
463
|
+
N,
|
|
458
464
|
W,
|
|
459
465
|
k,
|
|
460
466
|
W,
|
|
461
|
-
|
|
467
|
+
N,
|
|
462
468
|
L,
|
|
463
|
-
|
|
469
|
+
N,
|
|
464
470
|
L,
|
|
465
471
|
k,
|
|
466
472
|
W,
|
|
467
473
|
k,
|
|
468
474
|
L,
|
|
469
475
|
// Bottom strip
|
|
470
|
-
O,
|
|
471
476
|
N,
|
|
477
|
+
O,
|
|
472
478
|
k,
|
|
473
|
-
N,
|
|
474
479
|
O,
|
|
480
|
+
N,
|
|
475
481
|
H,
|
|
476
|
-
|
|
482
|
+
N,
|
|
477
483
|
H,
|
|
478
484
|
k,
|
|
479
|
-
|
|
485
|
+
O,
|
|
480
486
|
k,
|
|
481
487
|
H,
|
|
482
488
|
// Left strip
|
|
483
|
-
|
|
489
|
+
N,
|
|
484
490
|
L,
|
|
485
491
|
z,
|
|
486
492
|
L,
|
|
487
|
-
O,
|
|
488
493
|
N,
|
|
489
494
|
O,
|
|
490
495
|
N,
|
|
496
|
+
O,
|
|
491
497
|
z,
|
|
492
498
|
L,
|
|
493
499
|
z,
|
|
494
|
-
|
|
500
|
+
O,
|
|
495
501
|
// Right strip
|
|
496
502
|
M,
|
|
497
503
|
L,
|
|
498
504
|
k,
|
|
499
505
|
L,
|
|
500
506
|
M,
|
|
501
|
-
|
|
507
|
+
O,
|
|
502
508
|
M,
|
|
503
|
-
|
|
509
|
+
O,
|
|
504
510
|
k,
|
|
505
511
|
L,
|
|
506
512
|
k,
|
|
507
|
-
|
|
513
|
+
O
|
|
508
514
|
]);
|
|
509
515
|
return { positions: j, uvs: Z };
|
|
510
516
|
}
|
|
@@ -517,7 +523,7 @@ function ve(t, e, r) {
|
|
|
517
523
|
}
|
|
518
524
|
return n;
|
|
519
525
|
}
|
|
520
|
-
function
|
|
526
|
+
function Yt(t, e, r) {
|
|
521
527
|
const n = ve(t, t.VERTEX_SHADER, e), o = ve(t, t.FRAGMENT_SHADER, r), c = t.createProgram();
|
|
522
528
|
if (!c) throw new Error("Failed to create program");
|
|
523
529
|
if (t.attachShader(c, n), t.attachShader(c, o), t.linkProgram(c), !t.getProgramParameter(c, t.LINK_STATUS)) {
|
|
@@ -526,7 +532,7 @@ function Xt(t, e, r) {
|
|
|
526
532
|
}
|
|
527
533
|
return t.deleteShader(n), t.deleteShader(o), c;
|
|
528
534
|
}
|
|
529
|
-
const
|
|
535
|
+
const Xt = `#version 300 es
|
|
530
536
|
precision lowp float;
|
|
531
537
|
|
|
532
538
|
in vec2 vUV;
|
|
@@ -824,7 +830,7 @@ class Lr {
|
|
|
824
830
|
if (this.options.width = e, this.options.height = r, n && (this.options.ratio = n), !this.running) return;
|
|
825
831
|
const { gl: o, program: c, vao: m, positionBuffer: b, uvBuffer: v, uResolution: R } = this.glr, p = n ?? this.options.ratio ?? window.devicePixelRatio ?? 1, g = Math.max(1, Math.floor(e * p)), x = Math.max(1, Math.floor(r * p));
|
|
826
832
|
this.canvas.style.width = `${e}px`, this.canvas.style.height = `${r}px`, (this.canvas.width !== g || this.canvas.height !== x) && (this.canvas.width = g, this.canvas.height = x), o.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(o, "resize: after viewport setup");
|
|
827
|
-
const { positions: l, uvs:
|
|
833
|
+
const { positions: l, uvs: y } = pe(
|
|
828
834
|
this.canvas.width,
|
|
829
835
|
this.canvas.height,
|
|
830
836
|
this.options.borderWidth * p,
|
|
@@ -832,7 +838,7 @@ class Lr {
|
|
|
832
838
|
);
|
|
833
839
|
o.bindVertexArray(m), o.bindBuffer(o.ARRAY_BUFFER, b), o.bufferData(o.ARRAY_BUFFER, l, o.STATIC_DRAW);
|
|
834
840
|
const F = o.getAttribLocation(c, "aPosition");
|
|
835
|
-
o.enableVertexAttribArray(F), o.vertexAttribPointer(F, 2, o.FLOAT, !1, 0, 0), this.checkGLError(o, "resize: after position buffer update"), o.bindBuffer(o.ARRAY_BUFFER, v), o.bufferData(o.ARRAY_BUFFER,
|
|
841
|
+
o.enableVertexAttribArray(F), o.vertexAttribPointer(F, 2, o.FLOAT, !1, 0, 0), this.checkGLError(o, "resize: after position buffer update"), o.bindBuffer(o.ARRAY_BUFFER, v), o.bufferData(o.ARRAY_BUFFER, y, o.STATIC_DRAW);
|
|
836
842
|
const d = o.getAttribLocation(c, "aUV");
|
|
837
843
|
o.enableVertexAttribArray(d), o.vertexAttribPointer(d, 2, o.FLOAT, !1, 0, 0), this.checkGLError(o, "resize: after UV buffer update"), o.useProgram(c), o.uniform2f(R, this.canvas.width, this.canvas.height), o.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * p), o.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * p), o.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * p), this.checkGLError(o, "resize: after uniform updates");
|
|
838
844
|
const S = performance.now();
|
|
@@ -909,7 +915,7 @@ class Lr {
|
|
|
909
915
|
});
|
|
910
916
|
if (!e)
|
|
911
917
|
throw new Error("WebGL2 is required but not available.");
|
|
912
|
-
const r =
|
|
918
|
+
const r = Yt(e, $t, Xt);
|
|
913
919
|
this.checkGLError(e, "setupGL: after createProgram");
|
|
914
920
|
const n = e.createVertexArray();
|
|
915
921
|
e.bindVertexArray(n), this.checkGLError(e, "setupGL: after VAO creation");
|
|
@@ -926,13 +932,13 @@ class Lr {
|
|
|
926
932
|
e.bindBuffer(e.ARRAY_BUFFER, p), e.bufferData(e.ARRAY_BUFFER, b, e.STATIC_DRAW);
|
|
927
933
|
const g = e.getAttribLocation(r, "aUV");
|
|
928
934
|
e.enableVertexAttribArray(g), e.vertexAttribPointer(g, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
|
|
929
|
-
const x = e.getUniformLocation(r, "uResolution"), l = e.getUniformLocation(r, "uTime"),
|
|
930
|
-
e.useProgram(r), e.uniform1f(
|
|
931
|
-
const
|
|
932
|
-
for (let w = 0; w <
|
|
935
|
+
const x = e.getUniformLocation(r, "uResolution"), l = e.getUniformLocation(r, "uTime"), y = e.getUniformLocation(r, "uBorderWidth"), F = e.getUniformLocation(r, "uGlowWidth"), d = e.getUniformLocation(r, "uBorderRadius"), S = e.getUniformLocation(r, "uColors"), C = e.getUniformLocation(r, "uGlowExponent"), U = e.getUniformLocation(r, "uGlowFactor");
|
|
936
|
+
e.useProgram(r), e.uniform1f(y, this.options.borderWidth), e.uniform1f(F, this.options.glowWidth), e.uniform1f(d, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(C, 2), e.uniform1f(U, 1.8)) : (e.uniform1f(C, 1), e.uniform1f(U, 1));
|
|
937
|
+
const T = (this.options.colors || qt).map(Ht);
|
|
938
|
+
for (let w = 0; w < T.length; w++)
|
|
933
939
|
e.uniform3f(
|
|
934
940
|
e.getUniformLocation(r, `uColors[${w}]`),
|
|
935
|
-
...
|
|
941
|
+
...T[w]
|
|
936
942
|
);
|
|
937
943
|
this.checkGLError(e, "setupGL: after uniform setup"), e.bindVertexArray(null), e.bindBuffer(e.ARRAY_BUFFER, null), this.glr = {
|
|
938
944
|
gl: e,
|
|
@@ -942,7 +948,7 @@ class Lr {
|
|
|
942
948
|
uvBuffer: p,
|
|
943
949
|
uResolution: x,
|
|
944
950
|
uTime: l,
|
|
945
|
-
uBorderWidth:
|
|
951
|
+
uBorderWidth: y,
|
|
946
952
|
uGlowWidth: F,
|
|
947
953
|
uBorderRadius: d,
|
|
948
954
|
uColors: S
|
|
@@ -966,7 +972,7 @@ void main(void){
|
|
|
966
972
|
}`, we = `attribute vec3 aVertexPosition;
|
|
967
973
|
void main(void) {
|
|
968
974
|
gl_Position = vec4(aVertexPosition, 1.0);
|
|
969
|
-
}`,
|
|
975
|
+
}`, ye = "iTime", Te = "iTimeDelta", be = "iDate", Ee = "iFrame", Ae = "iMouse", Re = "iResolution", Qt = "iChannel", xe = "iChannelResolution", Se = "iDeviceOrientation";
|
|
970
976
|
function Jt(t, e) {
|
|
971
977
|
return t.includes("Matrix") && Array.isArray(e);
|
|
972
978
|
}
|
|
@@ -1060,7 +1066,7 @@ const tr = (t, e, r, n) => {
|
|
|
1060
1066
|
return "mat4";
|
|
1061
1067
|
default:
|
|
1062
1068
|
console.error(
|
|
1063
|
-
|
|
1069
|
+
X(
|
|
1064
1070
|
`The uniform type "${t}" is not valid, please make sure your uniform type is valid`
|
|
1065
1071
|
)
|
|
1066
1072
|
);
|
|
@@ -1123,7 +1129,7 @@ class or {
|
|
|
1123
1129
|
this.pow2canvas.width,
|
|
1124
1130
|
this.pow2canvas.height
|
|
1125
1131
|
), console.warn(
|
|
1126
|
-
|
|
1132
|
+
X(
|
|
1127
1133
|
`Image is not power of two ${e.width} x ${e.height}. Resized to ${this.pow2canvas.width} x ${this.pow2canvas.height};`
|
|
1128
1134
|
)
|
|
1129
1135
|
), this.pow2canvas) : e;
|
|
@@ -1139,7 +1145,7 @@ class or {
|
|
|
1139
1145
|
if (!n)
|
|
1140
1146
|
return Promise.reject(
|
|
1141
1147
|
new Error(
|
|
1142
|
-
|
|
1148
|
+
X(
|
|
1143
1149
|
"Missing url, please make sure to pass the url of your texture { url: ... }"
|
|
1144
1150
|
)
|
|
1145
1151
|
)
|
|
@@ -1148,19 +1154,19 @@ class or {
|
|
|
1148
1154
|
if (R === null && p === null)
|
|
1149
1155
|
return Promise.reject(
|
|
1150
1156
|
new Error(
|
|
1151
|
-
|
|
1157
|
+
X(
|
|
1152
1158
|
`Please upload a video or an image with a valid format (url: ${n})`
|
|
1153
1159
|
)
|
|
1154
1160
|
)
|
|
1155
1161
|
);
|
|
1156
1162
|
Object.assign(this, { url: n, wrapS: o, wrapT: c, minFilter: m, magFilter: b, flipY: v });
|
|
1157
|
-
const g = 0, x = r.RGBA, l = 1,
|
|
1163
|
+
const g = 0, x = r.RGBA, l = 1, y = 1, F = 0, d = r.RGBA, S = r.UNSIGNED_BYTE, C = new Uint8Array([255, 255, 255, 0]), U = r.createTexture();
|
|
1158
1164
|
if (r.bindTexture(r.TEXTURE_2D, U), r.texImage2D(
|
|
1159
1165
|
r.TEXTURE_2D,
|
|
1160
1166
|
g,
|
|
1161
1167
|
x,
|
|
1162
1168
|
l,
|
|
1163
|
-
|
|
1169
|
+
y,
|
|
1164
1170
|
F,
|
|
1165
1171
|
d,
|
|
1166
1172
|
S,
|
|
@@ -1169,17 +1175,17 @@ class or {
|
|
|
1169
1175
|
const P = this.setupVideo(n);
|
|
1170
1176
|
return r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MIN_FILTER, r.LINEAR), this._webglTexture = U, this.source = P, this.isVideo = !0, P.play().then(() => this);
|
|
1171
1177
|
}
|
|
1172
|
-
async function
|
|
1178
|
+
async function T() {
|
|
1173
1179
|
return new Promise((P, D) => {
|
|
1174
1180
|
const A = new Image();
|
|
1175
1181
|
A.crossOrigin = "anonymous", A.onload = () => {
|
|
1176
1182
|
P(A);
|
|
1177
1183
|
}, A.onerror = () => {
|
|
1178
|
-
D(new Error(
|
|
1184
|
+
D(new Error(X(`failed loading url: ${n}`)));
|
|
1179
1185
|
}, A.src = n ?? "";
|
|
1180
1186
|
});
|
|
1181
1187
|
}
|
|
1182
|
-
let w = await
|
|
1188
|
+
let w = await T(), I = (w.width & w.width - 1) === 0 && (w.height & w.height - 1) === 0;
|
|
1183
1189
|
return (e.wrapS !== Ce || e.wrapT !== Ce || e.minFilter !== Le && e.minFilter !== ce) && !I && (w = this.makePowerOf2(w), I = !0), r.bindTexture(r.TEXTURE_2D, U), r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL, v), r.texImage2D(
|
|
1184
1190
|
r.TEXTURE_2D,
|
|
1185
1191
|
g,
|
|
@@ -1206,7 +1212,7 @@ class or {
|
|
|
1206
1212
|
), this._webglTexture = U, this.source = w, this.isVideo = !1, this.isLoaded = !0, this.width = w.width || 0, this.height = w.height || 0, this;
|
|
1207
1213
|
};
|
|
1208
1214
|
}
|
|
1209
|
-
const
|
|
1215
|
+
const X = (t) => `react-shaders: ${t}`, _e = (t) => {
|
|
1210
1216
|
if ("changedTouches" in t) {
|
|
1211
1217
|
const e = t.changedTouches[0];
|
|
1212
1218
|
return [e?.clientX ?? 0, e?.clientY ?? 0];
|
|
@@ -1228,9 +1234,9 @@ function sr({
|
|
|
1228
1234
|
onError: g = console.error,
|
|
1229
1235
|
onWarning: x = console.warn
|
|
1230
1236
|
}) {
|
|
1231
|
-
const l = B(null),
|
|
1232
|
-
[Te]: { type: "float", isNeeded: !1, value: 0 },
|
|
1237
|
+
const l = B(null), y = B(null), F = B(null), d = B(null), S = B(void 0), C = B(void 0), U = B(!1), T = B(void 0), w = B(0), I = B([0, 0]), P = B([]), D = B(0), A = B(void 0), f = B({
|
|
1233
1238
|
[ye]: { type: "float", isNeeded: !1, value: 0 },
|
|
1239
|
+
[Te]: { type: "float", isNeeded: !1, value: 0 },
|
|
1234
1240
|
[be]: { type: "vec4", isNeeded: !1, value: [0, 0, 0, 0] },
|
|
1235
1241
|
[Ae]: { type: "vec4", isNeeded: !1, value: [0, 0, 0, 0] },
|
|
1236
1242
|
[Re]: { type: "vec2", isNeeded: !1, value: [0, 0] },
|
|
@@ -1240,18 +1246,18 @@ function sr({
|
|
|
1240
1246
|
isNeeded: !1,
|
|
1241
1247
|
value: [0, 0, 0, 0]
|
|
1242
1248
|
}
|
|
1243
|
-
}), _ = B(n),
|
|
1249
|
+
}), _ = B(n), N = (i, a) => {
|
|
1244
1250
|
const s = "width" in i ? i.width ?? 0 : 0, h = "height" in i ? i.height ?? 0 : 0, u = f.current.iChannelResolution;
|
|
1245
1251
|
if (!u) return;
|
|
1246
1252
|
const E = Array.isArray(u.value) ? u.value : u.value = [];
|
|
1247
1253
|
E[a * 3] = s * R, E[a * 3 + 1] = h * R, E[a * 3 + 2] = 0;
|
|
1248
1254
|
}, W = () => {
|
|
1249
|
-
l.current && (
|
|
1255
|
+
l.current && (y.current = l.current.getContext("webgl", b) || l.current.getContext(
|
|
1250
1256
|
"experimental-webgl",
|
|
1251
1257
|
b
|
|
1252
|
-
),
|
|
1258
|
+
), y.current?.getExtension("OES_standard_derivatives"), y.current?.getExtension("EXT_shader_texture_lod"));
|
|
1253
1259
|
}, k = () => {
|
|
1254
|
-
const i =
|
|
1260
|
+
const i = y.current;
|
|
1255
1261
|
F.current = i?.createBuffer() ?? null, i?.bindBuffer(i.ARRAY_BUFFER, F.current);
|
|
1256
1262
|
const a = [
|
|
1257
1263
|
1,
|
|
@@ -1280,13 +1286,13 @@ function sr({
|
|
|
1280
1286
|
window.orientation ?? 0
|
|
1281
1287
|
];
|
|
1282
1288
|
}, z = (i) => {
|
|
1283
|
-
const [a = 0, s = 0] = _e(i), h = a - (
|
|
1289
|
+
const [a = 0, s = 0] = _e(i), h = a - (T.current?.left ?? 0) - window.pageXOffset, u = (T.current?.height ?? 0) - s - (T.current?.top ?? 0) - window.pageYOffset;
|
|
1284
1290
|
U.current = !0;
|
|
1285
1291
|
const E = Array.isArray(f.current.iMouse?.value) ? f.current.iMouse.value : void 0;
|
|
1286
1292
|
E && (E[2] = h, E[3] = u), I.current[0] = h, I.current[1] = u;
|
|
1287
1293
|
}, M = (i) => {
|
|
1288
|
-
|
|
1289
|
-
const [a = 0, s = 0] = _e(i), h = a - (
|
|
1294
|
+
T.current = l.current?.getBoundingClientRect();
|
|
1295
|
+
const [a = 0, s = 0] = _e(i), h = a - (T.current?.left ?? 0), u = (T.current?.height ?? 0) - s - (T.current?.top ?? 0);
|
|
1290
1296
|
if (v !== 1)
|
|
1291
1297
|
I.current[0] = h, I.current[1] = u;
|
|
1292
1298
|
else {
|
|
@@ -1296,14 +1302,14 @@ function sr({
|
|
|
1296
1302
|
}, L = () => {
|
|
1297
1303
|
const i = Array.isArray(f.current.iMouse?.value) ? f.current.iMouse.value : void 0;
|
|
1298
1304
|
i && (i[2] = 0, i[3] = 0);
|
|
1299
|
-
},
|
|
1300
|
-
const i =
|
|
1305
|
+
}, O = () => {
|
|
1306
|
+
const i = y.current;
|
|
1301
1307
|
if (!i) return;
|
|
1302
|
-
|
|
1308
|
+
T.current = l.current?.getBoundingClientRect();
|
|
1303
1309
|
const a = R, s = Math.floor(
|
|
1304
|
-
(
|
|
1310
|
+
(T.current?.width ?? 1) * a
|
|
1305
1311
|
), h = Math.floor(
|
|
1306
|
-
(
|
|
1312
|
+
(T.current?.height ?? 1) * a
|
|
1307
1313
|
);
|
|
1308
1314
|
if (i.canvas.width = s, i.canvas.height = h, f.current.iResolution?.isNeeded && d.current) {
|
|
1309
1315
|
const u = i.getUniformLocation(
|
|
@@ -1313,25 +1319,25 @@ function sr({
|
|
|
1313
1319
|
i.uniform2fv(u, [i.canvas.width, i.canvas.height]);
|
|
1314
1320
|
}
|
|
1315
1321
|
}, j = (i, a) => {
|
|
1316
|
-
const s =
|
|
1322
|
+
const s = y.current;
|
|
1317
1323
|
if (!s) return null;
|
|
1318
1324
|
const h = s.createShader(i);
|
|
1319
1325
|
if (!h) return null;
|
|
1320
1326
|
if (s.shaderSource(h, a), s.compileShader(h), !s.getShaderParameter(h, s.COMPILE_STATUS)) {
|
|
1321
|
-
x?.(
|
|
1327
|
+
x?.(X(`Error compiling the shader:
|
|
1322
1328
|
${a}`));
|
|
1323
1329
|
const u = s.getShaderInfoLog(h);
|
|
1324
|
-
s.deleteShader(h), g?.(
|
|
1330
|
+
s.deleteShader(h), g?.(X(`Shader compiler log: ${u}`));
|
|
1325
1331
|
}
|
|
1326
1332
|
return h;
|
|
1327
1333
|
}, Z = (i, a) => {
|
|
1328
|
-
const s =
|
|
1334
|
+
const s = y.current;
|
|
1329
1335
|
if (!s) return;
|
|
1330
1336
|
const h = j(s.FRAGMENT_SHADER, i), u = j(s.VERTEX_SHADER, a);
|
|
1331
1337
|
if (d.current = s.createProgram(), !(!d.current || !u || !h)) {
|
|
1332
1338
|
if (s.attachShader(d.current, u), s.attachShader(d.current, h), s.linkProgram(d.current), !s.getProgramParameter(d.current, s.LINK_STATUS)) {
|
|
1333
1339
|
g?.(
|
|
1334
|
-
|
|
1340
|
+
X(
|
|
1335
1341
|
`Unable to initialize the shader program: ${s.getProgramInfoLog(
|
|
1336
1342
|
d.current
|
|
1337
1343
|
)}`
|
|
@@ -1353,8 +1359,8 @@ ${a}`));
|
|
|
1353
1359
|
if (!u) continue;
|
|
1354
1360
|
const E = {};
|
|
1355
1361
|
if (Jt(h, s)) {
|
|
1356
|
-
const V = h.length,
|
|
1357
|
-
s.length >
|
|
1362
|
+
const V = h.length, Y = Number.parseInt(h.charAt(V - 3)), te = Math.floor(s.length / (Y * Y));
|
|
1363
|
+
s.length > Y * Y && (E.arraySize = `[${te}]`);
|
|
1358
1364
|
} else Zt(h, s) && (E.arraySize = `[${Math.floor(s.length / Number.parseInt(h.charAt(0)))}]`);
|
|
1359
1365
|
f.current[i] = {
|
|
1360
1366
|
type: u,
|
|
@@ -1364,7 +1370,7 @@ ${a}`));
|
|
|
1364
1370
|
};
|
|
1365
1371
|
}
|
|
1366
1372
|
}, re = () => {
|
|
1367
|
-
const i =
|
|
1373
|
+
const i = y.current;
|
|
1368
1374
|
if (i)
|
|
1369
1375
|
if (r && r.length > 0) {
|
|
1370
1376
|
f.current[`${xe}`] = {
|
|
@@ -1377,8 +1383,8 @@ ${a}`));
|
|
|
1377
1383
|
(s, h) => (f.current[`${Qt}${h}`] = {
|
|
1378
1384
|
type: "sampler2D",
|
|
1379
1385
|
isNeeded: !1
|
|
1380
|
-
},
|
|
1381
|
-
|
|
1386
|
+
}, N(s, h), P.current[h] = new or(i), P.current[h]?.load(s).then((u) => {
|
|
1387
|
+
N(u, h);
|
|
1382
1388
|
}))
|
|
1383
1389
|
);
|
|
1384
1390
|
Promise.all(a).then(() => {
|
|
@@ -1391,7 +1397,7 @@ ${a}`));
|
|
|
1391
1397
|
const a = ge.includes(c ?? "highp"), s = `precision ${a ? c : ge[1]} float;
|
|
1392
1398
|
`;
|
|
1393
1399
|
a || x?.(
|
|
1394
|
-
|
|
1400
|
+
X(
|
|
1395
1401
|
`wrong precision type ${c}, please make sure to pass one of a valid precision lowp, mediump, highp, by default you shader precision will be set to highp.`
|
|
1396
1402
|
)
|
|
1397
1403
|
);
|
|
@@ -1410,7 +1416,7 @@ ${a}`));
|
|
|
1410
1416
|
}
|
|
1411
1417
|
return i.includes("mainImage") && (h = h.concat(jt)), h;
|
|
1412
1418
|
}, K = (i) => {
|
|
1413
|
-
const a =
|
|
1419
|
+
const a = y.current;
|
|
1414
1420
|
if (!a || !d.current) return;
|
|
1415
1421
|
const s = D.current ? (i - D.current) / 1e3 : 0;
|
|
1416
1422
|
D.current = i;
|
|
@@ -1463,23 +1469,23 @@ ${a}`));
|
|
|
1463
1469
|
if (f.current.iTime?.isNeeded) {
|
|
1464
1470
|
const u = a.getUniformLocation(
|
|
1465
1471
|
d.current,
|
|
1466
|
-
|
|
1472
|
+
ye
|
|
1467
1473
|
);
|
|
1468
1474
|
a.uniform1f(u, w.current += s);
|
|
1469
1475
|
}
|
|
1470
1476
|
if (f.current.iTimeDelta?.isNeeded) {
|
|
1471
1477
|
const u = a.getUniformLocation(
|
|
1472
1478
|
d.current,
|
|
1473
|
-
|
|
1479
|
+
Te
|
|
1474
1480
|
);
|
|
1475
1481
|
a.uniform1f(u, s);
|
|
1476
1482
|
}
|
|
1477
1483
|
if (f.current.iDate?.isNeeded) {
|
|
1478
|
-
const u = /* @__PURE__ */ new Date(), E = u.getMonth() + 1, V = u.getDate(),
|
|
1484
|
+
const u = /* @__PURE__ */ new Date(), E = u.getMonth() + 1, V = u.getDate(), Y = u.getFullYear(), te = u.getHours() * 60 * 60 + u.getMinutes() * 60 + u.getSeconds() + u.getMilliseconds() * 1e-3, ae = a.getUniformLocation(
|
|
1479
1485
|
d.current,
|
|
1480
1486
|
be
|
|
1481
1487
|
);
|
|
1482
|
-
a.uniform4fv(ae, [
|
|
1488
|
+
a.uniform4fv(ae, [Y, E, V, te]);
|
|
1483
1489
|
}
|
|
1484
1490
|
if (f.current.iFrame?.isNeeded) {
|
|
1485
1491
|
const u = a.getUniformLocation(
|
|
@@ -1492,23 +1498,23 @@ ${a}`));
|
|
|
1492
1498
|
for (let u = 0; u < P.current.length; u++) {
|
|
1493
1499
|
const E = P.current[u];
|
|
1494
1500
|
if (!E) return;
|
|
1495
|
-
const { isVideo: V, _webglTexture:
|
|
1496
|
-
if (!ke || !
|
|
1501
|
+
const { isVideo: V, _webglTexture: Y, source: te, flipY: ae, isLoaded: ke } = E;
|
|
1502
|
+
if (!ke || !Y || !te) return;
|
|
1497
1503
|
if (f.current[`iChannel${u}`]?.isNeeded) {
|
|
1498
1504
|
if (!d.current) return;
|
|
1499
1505
|
const We = a.getUniformLocation(
|
|
1500
1506
|
d.current,
|
|
1501
1507
|
`iChannel${u}`
|
|
1502
1508
|
);
|
|
1503
|
-
a.activeTexture(a.TEXTURE0 + u), a.bindTexture(a.TEXTURE_2D,
|
|
1504
|
-
|
|
1509
|
+
a.activeTexture(a.TEXTURE0 + u), a.bindTexture(a.TEXTURE_2D, Y), a.uniform1i(We, u), V && E.updateTexture(
|
|
1510
|
+
Y,
|
|
1505
1511
|
te,
|
|
1506
1512
|
ae
|
|
1507
1513
|
);
|
|
1508
1514
|
}
|
|
1509
1515
|
}
|
|
1510
1516
|
}, Q = (i) => {
|
|
1511
|
-
const a =
|
|
1517
|
+
const a = y.current;
|
|
1512
1518
|
if (!a) return;
|
|
1513
1519
|
a.viewport(0, 0, a.drawingBufferWidth, a.drawingBufferHeight), a.clear(a.COLOR_BUFFER_BIT | a.DEPTH_BUFFER_BIT), a.bindBuffer(a.ARRAY_BUFFER, F.current), a.vertexAttribPointer(
|
|
1514
1520
|
S.current ?? 0,
|
|
@@ -1530,14 +1536,14 @@ ${a}`));
|
|
|
1530
1536
|
"deviceorientation",
|
|
1531
1537
|
H,
|
|
1532
1538
|
i
|
|
1533
|
-
), l.current && (A.current = new ResizeObserver(
|
|
1539
|
+
), l.current && (A.current = new ResizeObserver(O), A.current.observe(l.current), window.addEventListener("resize", O, i));
|
|
1534
1540
|
}, J = () => {
|
|
1535
1541
|
const i = { passive: !0 };
|
|
1536
1542
|
f.current.iMouse?.isNeeded && l.current && (l.current.removeEventListener("mousemove", M, i), l.current.removeEventListener("mouseout", L, i), l.current.removeEventListener("mouseup", L, i), l.current.removeEventListener("mousedown", z, i), l.current.removeEventListener("touchmove", M, i), l.current.removeEventListener("touchend", L, i), l.current.removeEventListener("touchstart", z, i)), f.current.iDeviceOrientation?.isNeeded && window.removeEventListener(
|
|
1537
1543
|
"deviceorientation",
|
|
1538
1544
|
H,
|
|
1539
1545
|
i
|
|
1540
|
-
), A.current && (A.current.disconnect(), window.removeEventListener("resize",
|
|
1546
|
+
), A.current && (A.current.disconnect(), window.removeEventListener("resize", O, i));
|
|
1541
1547
|
};
|
|
1542
1548
|
return ie(() => {
|
|
1543
1549
|
_.current = n;
|
|
@@ -1545,11 +1551,11 @@ ${a}`));
|
|
|
1545
1551
|
const i = P.current;
|
|
1546
1552
|
function a() {
|
|
1547
1553
|
W();
|
|
1548
|
-
const s =
|
|
1549
|
-
s && l.current && (s.clearColor(...o), s.clearDepth(1), s.enable(s.DEPTH_TEST), s.depthFunc(s.LEQUAL), s.viewport(0, 0, l.current.width, l.current.height), l.current.height = l.current.clientHeight, l.current.width = l.current.clientWidth, $(), re(), Z(ne(t || Kt), e || we), k(), requestAnimationFrame(Q), ee(),
|
|
1554
|
+
const s = y.current;
|
|
1555
|
+
s && l.current && (s.clearColor(...o), s.clearDepth(1), s.enable(s.DEPTH_TEST), s.depthFunc(s.LEQUAL), s.viewport(0, 0, l.current.width, l.current.height), l.current.height = l.current.clientHeight, l.current.width = l.current.clientWidth, $(), re(), Z(ne(t || Kt), e || we), k(), requestAnimationFrame(Q), ee(), O());
|
|
1550
1556
|
}
|
|
1551
1557
|
return requestAnimationFrame(a), () => {
|
|
1552
|
-
const s =
|
|
1558
|
+
const s = y.current;
|
|
1553
1559
|
if (s) {
|
|
1554
1560
|
if (s.getExtension("WEBGL_lose_context")?.loseContext(), s.useProgram(null), s.deleteProgram(d.current ?? null), i.length > 0)
|
|
1555
1561
|
for (const h of i)
|
|
@@ -1744,7 +1750,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
|
1744
1750
|
};
|
|
1745
1751
|
function oe(t) {
|
|
1746
1752
|
const [e, r] = Ue(t), n = dt(t), o = B(null);
|
|
1747
|
-
|
|
1753
|
+
yt(n, "change", (m) => r(m));
|
|
1748
1754
|
const c = $e(
|
|
1749
1755
|
(m, b) => {
|
|
1750
1756
|
o.current = zt(n, m, b);
|
|
@@ -1881,11 +1887,11 @@ function Ge({
|
|
|
1881
1887
|
// Color
|
|
1882
1888
|
uColor: { type: "3fv", value: l ?? [0, 0.7, 1] }
|
|
1883
1889
|
},
|
|
1884
|
-
onError: (
|
|
1885
|
-
console.error("Shader error:",
|
|
1890
|
+
onError: (y) => {
|
|
1891
|
+
console.error("Shader error:", y);
|
|
1886
1892
|
},
|
|
1887
|
-
onWarning: (
|
|
1888
|
-
console.warn("Shader warning:",
|
|
1893
|
+
onWarning: (y) => {
|
|
1894
|
+
console.warn("Shader warning:", y);
|
|
1889
1895
|
},
|
|
1890
1896
|
style: { width: "100%", height: "100%" }
|
|
1891
1897
|
}
|