orb-ui 0.2.4 → 0.4.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/README.md +153 -10
- package/dist/adapters/audio-level.d.ts +23 -0
- package/dist/adapters/gemini-live/index.d.ts +70 -0
- package/dist/adapters/index.d.ts +6 -1
- package/dist/adapters/livekit/index.d.ts +129 -0
- package/dist/adapters/openai-realtime/index.d.ts +37 -0
- package/dist/adapters/pipecat/index.d.ts +46 -0
- package/dist/adapters/types.d.ts +4 -8
- package/dist/adapters/vapi/index.d.ts +2 -2
- package/dist/adapters.cjs +1 -1
- package/dist/adapters.js +983 -66
- package/dist/components/Orb/Orb.d.ts +1 -1
- package/dist/components/Orb/Orb.types.d.ts +31 -10
- package/dist/components/Orb/index.d.ts +1 -1
- package/dist/components/Orb/signals.d.ts +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/orb-ui.cjs +2 -2
- package/dist/orb-ui.js +126 -147
- package/package.json +16 -4
package/dist/orb-ui.js
CHANGED
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
import { useCallback as e, useEffect as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
2
2
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
3
|
-
//#region src/
|
|
4
|
-
function s(e) {
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
//#region src/components/Orb/signals.ts
|
|
4
|
+
function s(e, t, n) {
|
|
5
|
+
return e ?? t?.state ?? n.state;
|
|
6
|
+
}
|
|
7
|
+
function c(e, t, n) {
|
|
8
|
+
return e === void 0 ? t === "listening" ? n.inputVolume ?? n.volume ?? 0 : t === "speaking" ? n.outputVolume ?? n.volume ?? 0 : n.volume ?? 0 : e;
|
|
9
|
+
}
|
|
10
|
+
function l(e, t) {
|
|
11
|
+
let n = { state: "idle" }, r = (t) => {
|
|
12
|
+
n = t, e(t);
|
|
13
|
+
}, i = ((e) => {
|
|
14
|
+
r(e);
|
|
15
|
+
});
|
|
16
|
+
return i.onStateChange = (e) => {
|
|
17
|
+
t(), r({
|
|
18
|
+
...n,
|
|
19
|
+
state: e
|
|
20
|
+
});
|
|
21
|
+
}, i.onVolumeChange = (e) => {
|
|
22
|
+
t(), r({
|
|
23
|
+
...n,
|
|
24
|
+
volume: e
|
|
25
|
+
});
|
|
26
|
+
}, i;
|
|
7
27
|
}
|
|
8
28
|
//#endregion
|
|
9
29
|
//#region src/themes/debug/DebugTheme.tsx
|
|
10
|
-
var
|
|
30
|
+
var u = [
|
|
11
31
|
"idle",
|
|
12
32
|
"connecting",
|
|
13
33
|
"listening",
|
|
34
|
+
"thinking",
|
|
14
35
|
"speaking",
|
|
15
36
|
"error"
|
|
16
|
-
],
|
|
37
|
+
], d = {
|
|
17
38
|
idle: "#888",
|
|
18
39
|
connecting: "#f0c040",
|
|
19
40
|
listening: "#40c0f0",
|
|
41
|
+
thinking: "#c084fc",
|
|
20
42
|
speaking: "#40f080",
|
|
21
43
|
error: "#f04040"
|
|
22
44
|
};
|
|
23
|
-
function
|
|
45
|
+
function f({ state: e, volume: t, size: n, className: r, style: i, disabled: s = !1, onStart: c, onStop: l, ...f }) {
|
|
24
46
|
return /* @__PURE__ */ o("div", {
|
|
25
47
|
...f,
|
|
26
48
|
className: r,
|
|
@@ -54,7 +76,7 @@ function u({ state: e, volume: t, size: n, className: r, style: i, disabled: s =
|
|
|
54
76
|
children: "state "
|
|
55
77
|
}), /* @__PURE__ */ a("span", {
|
|
56
78
|
style: {
|
|
57
|
-
color:
|
|
79
|
+
color: d[e],
|
|
58
80
|
fontWeight: "bold"
|
|
59
81
|
},
|
|
60
82
|
children: e
|
|
@@ -82,7 +104,7 @@ function u({ state: e, volume: t, size: n, className: r, style: i, disabled: s =
|
|
|
82
104
|
children: /* @__PURE__ */ a("div", { style: {
|
|
83
105
|
height: "100%",
|
|
84
106
|
width: `${t * 100}%`,
|
|
85
|
-
background:
|
|
107
|
+
background: d[e],
|
|
86
108
|
borderRadius: 2,
|
|
87
109
|
transition: "width 50ms linear"
|
|
88
110
|
} })
|
|
@@ -104,14 +126,14 @@ function u({ state: e, volume: t, size: n, className: r, style: i, disabled: s =
|
|
|
104
126
|
flexWrap: "wrap",
|
|
105
127
|
gap: 4
|
|
106
128
|
},
|
|
107
|
-
children:
|
|
129
|
+
children: u.map((t) => /* @__PURE__ */ a("button", {
|
|
108
130
|
disabled: s,
|
|
109
131
|
style: {
|
|
110
132
|
fontSize: 10,
|
|
111
133
|
padding: "2px 6px",
|
|
112
|
-
background: e === t ?
|
|
134
|
+
background: e === t ? d[t] : "#222",
|
|
113
135
|
color: e === t ? "#000" : "#888",
|
|
114
|
-
border: `1px solid ${e === t ?
|
|
136
|
+
border: `1px solid ${e === t ? d[t] : "#333"}`,
|
|
115
137
|
borderRadius: 3,
|
|
116
138
|
cursor: s ? "not-allowed" : "pointer"
|
|
117
139
|
},
|
|
@@ -129,7 +151,7 @@ function u({ state: e, volume: t, size: n, className: r, style: i, disabled: s =
|
|
|
129
151
|
},
|
|
130
152
|
children: [/* @__PURE__ */ a("button", {
|
|
131
153
|
disabled: s,
|
|
132
|
-
onClick:
|
|
154
|
+
onClick: c,
|
|
133
155
|
style: {
|
|
134
156
|
flex: 1,
|
|
135
157
|
padding: "4px 0",
|
|
@@ -143,7 +165,7 @@ function u({ state: e, volume: t, size: n, className: r, style: i, disabled: s =
|
|
|
143
165
|
children: "Start"
|
|
144
166
|
}), /* @__PURE__ */ a("button", {
|
|
145
167
|
disabled: s,
|
|
146
|
-
onClick:
|
|
168
|
+
onClick: l,
|
|
147
169
|
style: {
|
|
148
170
|
flex: 1,
|
|
149
171
|
padding: "4px 0",
|
|
@@ -162,53 +184,54 @@ function u({ state: e, volume: t, size: n, className: r, style: i, disabled: s =
|
|
|
162
184
|
}
|
|
163
185
|
//#endregion
|
|
164
186
|
//#region src/themes/circle/CircleTheme.tsx
|
|
165
|
-
var
|
|
166
|
-
function
|
|
187
|
+
var p = typeof window < "u" ? n : t;
|
|
188
|
+
function m(e) {
|
|
167
189
|
return [
|
|
168
190
|
parseInt(e.slice(1, 3), 16),
|
|
169
191
|
parseInt(e.slice(3, 5), 16),
|
|
170
192
|
parseInt(e.slice(5, 7), 16)
|
|
171
193
|
];
|
|
172
194
|
}
|
|
173
|
-
var
|
|
195
|
+
var h = {
|
|
174
196
|
idle: "#cccccc",
|
|
175
197
|
connecting: "#cccccc",
|
|
176
198
|
listening: "#999999",
|
|
199
|
+
thinking: "#d8d8d8",
|
|
177
200
|
speaking: "#e8e8e8",
|
|
178
201
|
error: "#f87171"
|
|
179
|
-
},
|
|
180
|
-
function
|
|
202
|
+
}, g = "\n@keyframes orb-circle-idle-pulse {\n from { transform: scale(1); }\n to { transform: scale(1.06); }\n}\n@keyframes orb-circle-connecting-pulse {\n 0% { opacity: 1; transform: scale(1); }\n 50% { opacity: 0.6; transform: scale(0.95); }\n 100% { opacity: 1; transform: scale(1); }\n}\n", _ = .95, v = .08, y = .82, b = .18, x = 24, S = 0, C = .55, w = .12, T = .002;
|
|
203
|
+
function E({ state: e, volume: n, size: i, className: s, style: c, disabled: l = !1, interactive: u = !1, onClick: d, ...f }) {
|
|
181
204
|
let E = r(null), D = r(null), O = r(null), k = r(0), A = r(n);
|
|
182
|
-
|
|
205
|
+
p(() => {
|
|
183
206
|
A.current = n;
|
|
184
207
|
}, [n]);
|
|
185
|
-
let j = r(1), M = r(0), N = r(
|
|
208
|
+
let j = r(1), M = r(0), N = r(m(h.idle)), P = .06, F = r(y), I = r(b);
|
|
186
209
|
t(() => {
|
|
187
210
|
let e = "orb-circle-keyframes";
|
|
188
211
|
if (!document.getElementById(e)) {
|
|
189
212
|
let t = document.createElement("style");
|
|
190
|
-
t.id = e, t.textContent =
|
|
213
|
+
t.id = e, t.textContent = g, document.head.appendChild(t);
|
|
191
214
|
}
|
|
192
215
|
}, []), t(() => {
|
|
193
216
|
let t = E.current;
|
|
194
217
|
if (t) if (e === "listening" || e === "speaking") {
|
|
195
|
-
let n = e === "speaking" ?
|
|
218
|
+
let n = e === "speaking" ? _ : y, r = e === "speaking" ? v : b, i = e === "speaking" ? x : S, a = () => {
|
|
196
219
|
let o = A.current;
|
|
197
220
|
F.current += (n - F.current) * P, I.current += (r - I.current) * P;
|
|
198
221
|
let s = F.current + o * I.current, c = o * i;
|
|
199
|
-
e === "listening" ? (j.current += (s - j.current) *
|
|
200
|
-
let l =
|
|
222
|
+
e === "listening" ? (j.current += (s - j.current) * C, M.current += (c - M.current) * C) : (j.current = s, M.current = c);
|
|
223
|
+
let l = m(h[e]), [u, d, f] = N.current;
|
|
201
224
|
N.current = [
|
|
202
225
|
u + (l[0] - u) * .05,
|
|
203
226
|
d + (l[1] - d) * .05,
|
|
204
|
-
|
|
227
|
+
f + (l[2] - f) * .05
|
|
205
228
|
];
|
|
206
|
-
let [
|
|
207
|
-
t.style.transform = `scale(${j.current})`, t.style.background = `rgb(${
|
|
229
|
+
let [p, g, _] = N.current.map(Math.round);
|
|
230
|
+
t.style.transform = `scale(${j.current})`, t.style.background = `rgb(${p},${g},${_})`, t.style.boxShadow = "none", t.style.animation = "none";
|
|
208
231
|
let v = D.current;
|
|
209
232
|
if (v) {
|
|
210
233
|
let e = M.current;
|
|
211
|
-
v.style.transform = `scale(${j.current})`, v.style.boxShadow = e > .5 ? `0 0 ${e}px ${e * .4}px rgb(${
|
|
234
|
+
v.style.transform = `scale(${j.current})`, v.style.boxShadow = e > .5 ? `0 0 ${e}px ${e * .4}px rgb(${p},${g},${_})` : "none";
|
|
212
235
|
}
|
|
213
236
|
k.current = requestAnimationFrame(a);
|
|
214
237
|
};
|
|
@@ -217,19 +240,19 @@ function w({ state: e, volume: n, size: i, className: s, style: c, disabled: l =
|
|
|
217
240
|
};
|
|
218
241
|
} else {
|
|
219
242
|
cancelAnimationFrame(k.current);
|
|
220
|
-
let n =
|
|
221
|
-
j.current += (1 - j.current) *
|
|
243
|
+
let n = h[e] ?? h.idle, r = m(n), i = () => {
|
|
244
|
+
j.current += (1 - j.current) * w, M.current += (0 - M.current) * w;
|
|
222
245
|
let [a, o, s] = N.current;
|
|
223
246
|
N.current = [
|
|
224
|
-
a + (r[0] - a) *
|
|
225
|
-
o + (r[1] - o) *
|
|
226
|
-
s + (r[2] - s) *
|
|
247
|
+
a + (r[0] - a) * w,
|
|
248
|
+
o + (r[1] - o) * w,
|
|
249
|
+
s + (r[2] - s) * w
|
|
227
250
|
];
|
|
228
251
|
let [c, l, u] = N.current.map(Math.round);
|
|
229
252
|
t.style.transform = `scale(${j.current})`, t.style.background = `rgb(${c},${l},${u})`, t.style.boxShadow = "none", t.style.animation = "none", D.current && (D.current.style.transform = `scale(${j.current})`, D.current.style.boxShadow = "none");
|
|
230
|
-
let d = Math.abs(j.current - 1) <
|
|
253
|
+
let d = Math.abs(j.current - 1) < T, f = M.current < .1, p = N.current.every((e, t) => Math.abs(e - r[t]) < 1);
|
|
231
254
|
if (d && f && p) {
|
|
232
|
-
j.current = 1, M.current = 0, N.current = r, t.style.transform = "", t.style.boxShadow = "none", t.style.background = n, D.current && (D.current.style.transform = "scale(1)", D.current.style.boxShadow = "none"), e === "idle" ? t.style.animation = "orb-circle-idle-pulse 3s ease-in-out infinite alternate" : e === "connecting" ? t.style.animation = "orb-circle-connecting-pulse 1.5s ease-in-out infinite" : t.style.animation = "none";
|
|
255
|
+
j.current = 1, M.current = 0, N.current = r, t.style.transform = "", t.style.boxShadow = "none", t.style.background = n, D.current && (D.current.style.transform = "scale(1)", D.current.style.boxShadow = "none"), e === "idle" ? t.style.animation = "orb-circle-idle-pulse 3s ease-in-out infinite alternate" : e === "connecting" || e === "thinking" ? t.style.animation = "orb-circle-connecting-pulse 1.5s ease-in-out infinite" : t.style.animation = "none";
|
|
233
256
|
return;
|
|
234
257
|
}
|
|
235
258
|
k.current = requestAnimationFrame(i);
|
|
@@ -284,16 +307,16 @@ function w({ state: e, volume: n, size: i, className: s, style: c, disabled: l =
|
|
|
284
307
|
width: L,
|
|
285
308
|
height: L,
|
|
286
309
|
borderRadius: "50%",
|
|
287
|
-
background:
|
|
310
|
+
background: h[e]
|
|
288
311
|
}
|
|
289
312
|
})]
|
|
290
313
|
});
|
|
291
314
|
return u ? /* @__PURE__ */ a("button", {
|
|
292
|
-
...
|
|
315
|
+
...f,
|
|
293
316
|
type: "button",
|
|
294
317
|
className: s,
|
|
295
318
|
disabled: l,
|
|
296
|
-
onClick: l ? void 0 :
|
|
319
|
+
onClick: l ? void 0 : d,
|
|
297
320
|
style: {
|
|
298
321
|
appearance: "none",
|
|
299
322
|
WebkitAppearance: "none",
|
|
@@ -308,7 +331,7 @@ function w({ state: e, volume: n, size: i, className: s, style: c, disabled: l =
|
|
|
308
331
|
},
|
|
309
332
|
children: z
|
|
310
333
|
}) : /* @__PURE__ */ a("div", {
|
|
311
|
-
...
|
|
334
|
+
...f,
|
|
312
335
|
className: s,
|
|
313
336
|
style: R,
|
|
314
337
|
children: z
|
|
@@ -316,43 +339,44 @@ function w({ state: e, volume: n, size: i, className: s, style: c, disabled: l =
|
|
|
316
339
|
}
|
|
317
340
|
//#endregion
|
|
318
341
|
//#region src/themes/bars/BarsTheme.tsx
|
|
319
|
-
var
|
|
342
|
+
var D = 5, O = 1.4, k = Math.PI * 2 / D, A = {
|
|
320
343
|
idle: "#cccccc",
|
|
321
344
|
connecting: "#cccccc",
|
|
322
345
|
listening: "#999999",
|
|
346
|
+
thinking: "#d8d8d8",
|
|
323
347
|
speaking: "#e8e8e8",
|
|
324
348
|
error: "#f87171"
|
|
325
349
|
};
|
|
326
|
-
function
|
|
350
|
+
function j(e) {
|
|
327
351
|
return [
|
|
328
352
|
parseInt(e.slice(1, 3), 16),
|
|
329
353
|
parseInt(e.slice(3, 5), 16),
|
|
330
354
|
parseInt(e.slice(5, 7), 16)
|
|
331
355
|
];
|
|
332
356
|
}
|
|
333
|
-
function
|
|
334
|
-
let f = r([]), p = r(null), m = r(0), h = r(Array(
|
|
357
|
+
function M({ state: e, volume: n, size: i, className: o, style: s, disabled: c = !1, interactive: l = !1, onClick: u, ...d }) {
|
|
358
|
+
let f = r([]), p = r(null), m = r(0), h = r(Array(D).fill(0)), g = r(n), _ = r(!1), v = r(0), y = r(j(A.idle)), b = r(null), x = r(Array(D).fill(0)), S = r(e);
|
|
335
359
|
t(() => {
|
|
336
360
|
e !== S.current && (x.current = [...h.current], b.current = Date.now(), S.current = e);
|
|
337
361
|
}, [e]), t(() => {
|
|
338
362
|
g.current = n;
|
|
339
363
|
}, [n]), t(() => {
|
|
340
|
-
let t = i * .55, n = i * .06, r =
|
|
341
|
-
let n = (
|
|
364
|
+
let t = i * .55, n = i * .06, r = A[e] ?? A.idle, a = i * .1, o = Array.from({ length: D }, (e, t) => {
|
|
365
|
+
let n = (D - 1) / 2;
|
|
342
366
|
return 1 - .7 * (Math.abs(t - n) / n);
|
|
343
367
|
}), s = () => {
|
|
344
368
|
let e = _.current ? a : 0;
|
|
345
369
|
v.current += (e - v.current) * .15;
|
|
346
370
|
}, c = (n, r) => {
|
|
347
371
|
s();
|
|
348
|
-
let i =
|
|
372
|
+
let i = j(r), [a, c, l] = y.current;
|
|
349
373
|
y.current = [
|
|
350
374
|
a + (i[0] - a) * .08,
|
|
351
375
|
c + (i[1] - c) * .08,
|
|
352
376
|
l + (i[2] - l) * .08
|
|
353
377
|
];
|
|
354
378
|
let [u, d, p] = y.current.map(Math.round), m = `rgb(${u},${d},${p})`;
|
|
355
|
-
for (let r = 0; r <
|
|
379
|
+
for (let r = 0; r < D; r++) {
|
|
356
380
|
let i = f.current[r];
|
|
357
381
|
if (!i) continue;
|
|
358
382
|
let a = e === "idle" ? o[r] : 1, s = v.current * a;
|
|
@@ -362,8 +386,8 @@ function A({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
|
|
|
362
386
|
if (e === "listening" || e === "speaking") {
|
|
363
387
|
let i = e === "speaking" ? 1 : .4, a = () => {
|
|
364
388
|
let o = g.current, s = Date.now() / 1e3;
|
|
365
|
-
for (let r = 0; r <
|
|
366
|
-
let a = .5 + .15 * Math.sin(s *
|
|
389
|
+
for (let r = 0; r < D; r++) {
|
|
390
|
+
let a = .5 + .15 * Math.sin(s * O * i * Math.PI * 2 + r * k), c = n + (t - n) * o * a;
|
|
367
391
|
if (b.current !== null) {
|
|
368
392
|
let e = Date.now() - b.current, t = Math.min(e / 300, 1), n = 1 - (1 - t) * (1 - t);
|
|
369
393
|
c = x.current[r] + (c - x.current[r]) * n, t >= 1 && (b.current = null);
|
|
@@ -375,12 +399,12 @@ function A({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
|
|
|
375
399
|
};
|
|
376
400
|
return m.current = requestAnimationFrame(a), () => cancelAnimationFrame(m.current);
|
|
377
401
|
}
|
|
378
|
-
if (e === "connecting") {
|
|
402
|
+
if (e === "connecting" || e === "thinking") {
|
|
379
403
|
let e = Date.now(), i = () => {
|
|
380
404
|
let a = (Date.now() - e) / 1e3;
|
|
381
405
|
s();
|
|
382
|
-
for (let e = 0; e <
|
|
383
|
-
let r = (a * .6 + e /
|
|
406
|
+
for (let e = 0; e < D; e++) {
|
|
407
|
+
let r = (a * .6 + e / D * .5) % 1, i = r < .5 ? Math.sin(r / .5 * Math.PI) : 0, o = n + (t * .4 - n) * i;
|
|
384
408
|
h.current[e] += (o - h.current[e]) * .15;
|
|
385
409
|
}
|
|
386
410
|
c(h.current, r), m.current = requestAnimationFrame(i);
|
|
@@ -390,12 +414,12 @@ function A({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
|
|
|
390
414
|
cancelAnimationFrame(m.current);
|
|
391
415
|
let l = () => {
|
|
392
416
|
s();
|
|
393
|
-
for (let e = 0; e <
|
|
417
|
+
for (let e = 0; e < D; e++) h.current[e] += (n - h.current[e]) * .16;
|
|
394
418
|
c(h.current, r), m.current = requestAnimationFrame(l);
|
|
395
419
|
};
|
|
396
420
|
return m.current = requestAnimationFrame(l), () => cancelAnimationFrame(m.current);
|
|
397
421
|
}, [e, i]);
|
|
398
|
-
let C = i * .055, w = i * .035,
|
|
422
|
+
let C = i * .055, w = i * .035, T = i * .03, E = i * .55, M = i * .06, N = {
|
|
399
423
|
width: i,
|
|
400
424
|
height: i,
|
|
401
425
|
display: "flex",
|
|
@@ -424,17 +448,17 @@ function A({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
|
|
|
424
448
|
transition: "filter 0.3s ease",
|
|
425
449
|
cursor: l ? c ? "not-allowed" : "pointer" : "default"
|
|
426
450
|
},
|
|
427
|
-
children: Array.from({ length:
|
|
451
|
+
children: Array.from({ length: D }, (t, n) => /* @__PURE__ */ a("span", {
|
|
428
452
|
ref: (e) => {
|
|
429
453
|
f.current[n] = e;
|
|
430
454
|
},
|
|
431
455
|
style: {
|
|
432
456
|
width: C,
|
|
433
457
|
minHeight: M,
|
|
434
|
-
maxHeight:
|
|
458
|
+
maxHeight: E,
|
|
435
459
|
height: M,
|
|
436
|
-
borderRadius:
|
|
437
|
-
background:
|
|
460
|
+
borderRadius: T,
|
|
461
|
+
background: A[e] ?? A.idle
|
|
438
462
|
}
|
|
439
463
|
}, n))
|
|
440
464
|
});
|
|
@@ -466,101 +490,56 @@ function A({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
|
|
|
466
490
|
}
|
|
467
491
|
//#endregion
|
|
468
492
|
//#region src/components/Orb/Orb.tsx
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
let e = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
|
|
473
|
-
navigator.mediaDevices.getUserMedia = async (t) => {
|
|
474
|
-
let n = await e(t);
|
|
475
|
-
return t?.audio && (a = n), n;
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
function o(o) {
|
|
479
|
-
if (!(!a || t)) try {
|
|
480
|
-
e = new AudioContext(), t = e.createAnalyser(), t.fftSize = 256, n = e.createMediaStreamSource(a), n.connect(t);
|
|
481
|
-
let c = new Uint8Array(t.frequencyBinCount), l = () => {
|
|
482
|
-
if (!t) return;
|
|
483
|
-
t.getByteFrequencyData(c);
|
|
484
|
-
let e = 0;
|
|
485
|
-
for (let t = 0; t < c.length; t++) e += c[t] * c[t];
|
|
486
|
-
let n = Math.sqrt(e / c.length) / 255, a = n > i ? .7 : .3;
|
|
487
|
-
i += (n - i) * a, o(s(i)), r = requestAnimationFrame(l);
|
|
488
|
-
};
|
|
489
|
-
r = requestAnimationFrame(l);
|
|
490
|
-
} catch (e) {
|
|
491
|
-
console.warn("[orb-ui] Mic monitor failed:", e);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
function c() {
|
|
495
|
-
cancelAnimationFrame(r), r = 0, i = 0, n?.disconnect(), n = null, t = null;
|
|
496
|
-
}
|
|
497
|
-
function l() {
|
|
498
|
-
c(), e &&= (e.close().catch(() => {}), null), a?.getTracks().forEach((e) => {
|
|
499
|
-
e.readyState === "live" && e.stop();
|
|
500
|
-
}), a = null;
|
|
501
|
-
}
|
|
502
|
-
return {
|
|
503
|
-
start: o,
|
|
504
|
-
stop: c,
|
|
505
|
-
release: l
|
|
506
|
-
};
|
|
493
|
+
var N = !1;
|
|
494
|
+
function P() {
|
|
495
|
+
return globalThis.process?.env?.NODE_ENV === "production";
|
|
507
496
|
}
|
|
508
|
-
function
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
onVolumeChange: b
|
|
514
|
-
});
|
|
515
|
-
}, [s]);
|
|
516
|
-
let E = n ?? _;
|
|
497
|
+
function F() {
|
|
498
|
+
N || P() || (N = !0, console.warn("[orb-ui] Callback-object adapters are deprecated. Use subscribe(listener) and emit OrbSignal objects instead. Legacy adapters will be removed in 0.5.0."));
|
|
499
|
+
}
|
|
500
|
+
function I({ signal: n, state: r, volume: o, adapter: u, theme: d = "debug", size: p = 200, className: m, style: h, disabled: g = !1, onStart: _, onStop: v, ...y }) {
|
|
501
|
+
let [b, x] = i({ state: "idle" });
|
|
517
502
|
t(() => {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
clearTimeout(t), e.stop(), T.current = !1, S(0);
|
|
525
|
-
};
|
|
526
|
-
} else e.stop(), T.current = !1, S(0);
|
|
527
|
-
}, [E, s]), t(() => () => C.current.release(), []);
|
|
528
|
-
let D = o ?? (E === "listening" && T.current ? x : y), O = E !== "idle" && E !== "error", k = e(() => {
|
|
529
|
-
p || (O ? h ? h() : s?.stop?.() : m ? m() : s?.start?.());
|
|
503
|
+
if (x({ state: "idle" }), !u) return;
|
|
504
|
+
let e = l(x, F);
|
|
505
|
+
return u.subscribe(e);
|
|
506
|
+
}, [u]);
|
|
507
|
+
let S = n ?? b, C = s(r, n, b), w = c(o, C, S), T = C !== "idle" && C !== "error", D = e(() => {
|
|
508
|
+
g || (T ? v ? v() : u?.stop?.() : _ ? _() : u?.start?.());
|
|
530
509
|
}, [
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
]),
|
|
537
|
-
state:
|
|
538
|
-
volume:
|
|
539
|
-
size:
|
|
540
|
-
className:
|
|
541
|
-
style:
|
|
542
|
-
disabled:
|
|
543
|
-
...
|
|
544
|
-
"aria-label":
|
|
545
|
-
},
|
|
546
|
-
...
|
|
547
|
-
interactive:
|
|
510
|
+
u,
|
|
511
|
+
g,
|
|
512
|
+
T,
|
|
513
|
+
_,
|
|
514
|
+
v
|
|
515
|
+
]), O = T ? !!(u?.stop || v) : !!(u?.start || _), k = O && !g ? D : void 0, A = {
|
|
516
|
+
state: C,
|
|
517
|
+
volume: w,
|
|
518
|
+
size: p,
|
|
519
|
+
className: m,
|
|
520
|
+
style: h,
|
|
521
|
+
disabled: g,
|
|
522
|
+
...y,
|
|
523
|
+
"aria-label": y["aria-label"] ?? (O ? `${T ? "Stop" : "Start"} voice session` : void 0)
|
|
524
|
+
}, j = {
|
|
525
|
+
...A,
|
|
526
|
+
interactive: O
|
|
548
527
|
};
|
|
549
|
-
switch (
|
|
550
|
-
case "circle": return /* @__PURE__ */ a(
|
|
551
|
-
...
|
|
552
|
-
onClick:
|
|
528
|
+
switch (d) {
|
|
529
|
+
case "circle": return /* @__PURE__ */ a(E, {
|
|
530
|
+
...j,
|
|
531
|
+
onClick: k
|
|
553
532
|
});
|
|
554
|
-
case "bars": return /* @__PURE__ */ a(
|
|
555
|
-
...
|
|
556
|
-
onClick:
|
|
533
|
+
case "bars": return /* @__PURE__ */ a(M, {
|
|
534
|
+
...j,
|
|
535
|
+
onClick: k
|
|
557
536
|
});
|
|
558
|
-
default: return /* @__PURE__ */ a(
|
|
559
|
-
...
|
|
560
|
-
onStart:
|
|
561
|
-
onStop:
|
|
537
|
+
default: return /* @__PURE__ */ a(f, {
|
|
538
|
+
...A,
|
|
539
|
+
onStart: g ? void 0 : _ ?? (() => u?.start?.()),
|
|
540
|
+
onStop: g ? void 0 : v ?? (() => u?.stop?.())
|
|
562
541
|
});
|
|
563
542
|
}
|
|
564
543
|
}
|
|
565
544
|
//#endregion
|
|
566
|
-
export {
|
|
545
|
+
export { I as Orb, I as VoiceOrb };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orb-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "React voice agent UI components with
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "React voice agent UI components with audio-reactive adapters for Vapi, ElevenLabs, LiveKit, Pipecat, OpenAI Realtime, Gemini Live, and custom voice AI apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/orb-ui.cjs",
|
|
7
7
|
"module": "./dist/orb-ui.js",
|
|
@@ -29,12 +29,17 @@
|
|
|
29
29
|
"@changesets/cli": "^2.31.0",
|
|
30
30
|
"@elevenlabs/client": "1.9.0",
|
|
31
31
|
"@eslint/js": "^10.0.1",
|
|
32
|
+
"@google/genai": "2.11.0",
|
|
33
|
+
"@pipecat-ai/client-js": "1.12.0",
|
|
34
|
+
"@pipecat-ai/small-webrtc-transport": "1.10.5",
|
|
35
|
+
"@playwright/test": "1.61.1",
|
|
32
36
|
"@types/react": "^18.3.29",
|
|
33
37
|
"@types/react-dom": "^18.3.7",
|
|
34
38
|
"@vapi-ai/web": "2.5.2",
|
|
35
39
|
"@vitejs/plugin-react": "^6.0.2",
|
|
36
40
|
"eslint": "^10.4.0",
|
|
37
41
|
"globals": "^17.6.0",
|
|
42
|
+
"livekit-client": "2.20.0",
|
|
38
43
|
"prettier": "^3.8.3",
|
|
39
44
|
"react": "^18.3.1",
|
|
40
45
|
"react-dom": "^18.3.1",
|
|
@@ -61,7 +66,11 @@
|
|
|
61
66
|
"realtime-voice",
|
|
62
67
|
"state-machine",
|
|
63
68
|
"vapi",
|
|
64
|
-
"elevenlabs"
|
|
69
|
+
"elevenlabs",
|
|
70
|
+
"livekit",
|
|
71
|
+
"pipecat",
|
|
72
|
+
"openai-realtime",
|
|
73
|
+
"gemini-live"
|
|
65
74
|
],
|
|
66
75
|
"license": "MIT",
|
|
67
76
|
"author": "Alexander Chen",
|
|
@@ -81,17 +90,20 @@
|
|
|
81
90
|
"build": "tsc && vite build",
|
|
82
91
|
"build:demo": "pnpm --filter orb-ui-demo build",
|
|
83
92
|
"changeset": "changeset",
|
|
84
|
-
"check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm typecheck:examples && pnpm test && pnpm build && pnpm typecheck:package && pnpm build:demo",
|
|
93
|
+
"check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm typecheck:examples && pnpm test && pnpm build && pnpm typecheck:package && pnpm typecheck:demo && pnpm build:demo && pnpm test:e2e:built",
|
|
85
94
|
"dev": "vite build --watch",
|
|
86
95
|
"dev:demo": "pnpm --filter orb-ui-demo dev",
|
|
87
96
|
"format": "prettier . --write",
|
|
88
97
|
"format:check": "prettier . --check",
|
|
89
98
|
"typecheck": "tsc --noEmit",
|
|
99
|
+
"typecheck:demo": "pnpm --filter orb-ui-demo typecheck",
|
|
90
100
|
"typecheck:examples": "tsc -p tsconfig.type-tests.json --noEmit",
|
|
91
101
|
"typecheck:package": "tsc -p tsconfig.package-types.json --noEmit",
|
|
92
102
|
"lint": "eslint .",
|
|
93
103
|
"release": "pnpm build && changeset publish",
|
|
94
104
|
"test": "vitest run --passWithNoTests",
|
|
105
|
+
"test:e2e": "pnpm build && pnpm test:e2e:built",
|
|
106
|
+
"test:e2e:built": "tsc -p tests/e2e/tsconfig.json --noEmit && playwright test",
|
|
95
107
|
"test:watch": "vitest"
|
|
96
108
|
}
|
|
97
109
|
}
|