@bod.ee/ai-avatar 1.0.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 +444 -0
- package/dist/PlaybackSync-CZsM--xy.js +2029 -0
- package/dist/PlaybackSync-DwFiX-W4.cjs +1 -0
- package/dist/avatar-react.d.ts +9 -0
- package/dist/components/Avatar.d.ts +24 -0
- package/dist/core.cjs +1 -0
- package/dist/core.js +20 -0
- package/dist/favicon.ico +0 -0
- package/dist/hooks/useCursorTracking.d.ts +24 -0
- package/dist/hooks/useGlitchEffect.d.ts +34 -0
- package/dist/hooks/useSpeech.d.ts +31 -0
- package/dist/lib/avatar/AvatarController.d.ts +203 -0
- package/dist/lib/avatar/PlaybackSync.d.ts +50 -0
- package/dist/lib/avatar/SpeechBubbleGrouper.d.ts +42 -0
- package/dist/lib/avatar/SpeechController.d.ts +75 -0
- package/dist/lib/avatar/emotions.d.ts +11 -0
- package/dist/lib/avatar/expressions.d.ts +9 -0
- package/dist/lib/avatar/index.d.ts +35 -0
- package/dist/lib/avatar/sequences.d.ts +8 -0
- package/dist/lib/avatar/types.d.ts +101 -0
- package/dist/lib/avatar/useAvatarController.d.ts +28 -0
- package/dist/lib/utils/EventEmitter.d.ts +13 -0
- package/dist/placeholder.svg +1 -0
- package/dist/react.cjs +1 -0
- package/dist/react.js +503 -0
- package/dist/robots.txt +14 -0
- package/package.json +121 -0
package/dist/react.js
ADDED
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
import { c as I, g as j, a as tt } from "./PlaybackSync-CZsM--xy.js";
|
|
2
|
+
import { A as mt, E as ft, F as xt, P as yt, S as gt, e as vt, b as bt, d as $t, r as Et, s as Mt, f as St, u as Pt, u as wt, w as Gt } from "./PlaybackSync-CZsM--xy.js";
|
|
3
|
+
import { jsxs as C, jsx as v } from "react/jsx-runtime";
|
|
4
|
+
import { useState as D, useRef as G, useCallback as m, useEffect as N, useMemo as b } from "react";
|
|
5
|
+
const et = (t = {}) => {
|
|
6
|
+
const {
|
|
7
|
+
enabled: o = !0,
|
|
8
|
+
maxOffset: i = 0.35,
|
|
9
|
+
smoothing: $ = 0.15,
|
|
10
|
+
containerRef: d,
|
|
11
|
+
deadZone: g = 0.1
|
|
12
|
+
} = t, [A, F] = D({ x: 0, y: 0 }), c = G({ x: 0, y: 0 }), n = G(), e = G({ x: 0, y: 0 }), u = m(() => {
|
|
13
|
+
const s = c.current.x - e.current.x, y = c.current.y - e.current.y;
|
|
14
|
+
e.current.x += s * $, e.current.y += y * $, (Math.abs(s) > 1e-3 || Math.abs(y) > 1e-3) && F({
|
|
15
|
+
x: e.current.x,
|
|
16
|
+
y: e.current.y
|
|
17
|
+
}), n.current = requestAnimationFrame(u);
|
|
18
|
+
}, [$]), f = m(
|
|
19
|
+
(s) => {
|
|
20
|
+
if (!o) return;
|
|
21
|
+
let y, S, a, q;
|
|
22
|
+
if (d != null && d.current) {
|
|
23
|
+
const r = d.current.getBoundingClientRect();
|
|
24
|
+
y = r.left + r.width / 2, S = r.top + r.height / 2, a = r.width / 2, q = r.height / 2;
|
|
25
|
+
} else
|
|
26
|
+
y = window.innerWidth / 2, S = window.innerHeight / 2, a = window.innerWidth / 2, q = window.innerHeight / 2;
|
|
27
|
+
let P = (s.clientX - y) / a, p = (s.clientY - S) / q;
|
|
28
|
+
Math.abs(P) < g ? P = 0 : P = (P - Math.sign(P) * g) / (1 - g), Math.abs(p) < g ? p = 0 : p = (p - Math.sign(p) * g) / (1 - g), c.current = {
|
|
29
|
+
x: Math.max(-1, Math.min(1, P)) * i,
|
|
30
|
+
y: Math.max(-1, Math.min(1, p)) * i * 0.6
|
|
31
|
+
// Less vertical movement
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
[o, d, i, g]
|
|
35
|
+
), x = m(() => {
|
|
36
|
+
c.current = { x: 0, y: 0 };
|
|
37
|
+
}, []);
|
|
38
|
+
N(() => {
|
|
39
|
+
if (!o) {
|
|
40
|
+
c.current = { x: 0, y: 0 };
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
return n.current = requestAnimationFrame(u), window.addEventListener("mousemove", f), document.addEventListener("mouseleave", x), () => {
|
|
44
|
+
n.current && cancelAnimationFrame(n.current), window.removeEventListener("mousemove", f), document.removeEventListener("mouseleave", x);
|
|
45
|
+
};
|
|
46
|
+
}, [o, u, f, x]);
|
|
47
|
+
const E = m(() => {
|
|
48
|
+
c.current = { x: 0, y: 0 }, e.current = { x: 0, y: 0 }, F({ x: 0, y: 0 });
|
|
49
|
+
}, []), T = m((s) => {
|
|
50
|
+
c.current = s;
|
|
51
|
+
}, []);
|
|
52
|
+
return {
|
|
53
|
+
eyePosition: A,
|
|
54
|
+
resetPosition: E,
|
|
55
|
+
setPosition: T,
|
|
56
|
+
isTracking: o
|
|
57
|
+
};
|
|
58
|
+
}, W = {
|
|
59
|
+
shakeX: 0,
|
|
60
|
+
shakeY: 0,
|
|
61
|
+
scaleDistort: 1,
|
|
62
|
+
isGlitching: !1,
|
|
63
|
+
opacity: 1
|
|
64
|
+
}, st = () => {
|
|
65
|
+
const [t, o] = D(W), i = G([]), $ = m(() => {
|
|
66
|
+
i.current.forEach(clearTimeout), i.current = [];
|
|
67
|
+
}, []), d = m(
|
|
68
|
+
(n = {}) => {
|
|
69
|
+
const { duration: e = 300, intensity: u = 0.8, frames: f = 8 } = n;
|
|
70
|
+
return new Promise((x) => {
|
|
71
|
+
$(), o((s) => ({ ...s, isGlitching: !0 }));
|
|
72
|
+
const E = e / f;
|
|
73
|
+
for (let s = 0; s < f; s++) {
|
|
74
|
+
const y = setTimeout(() => {
|
|
75
|
+
const S = s / f, a = u * (1 - S * 0.5);
|
|
76
|
+
o({
|
|
77
|
+
shakeX: (Math.random() - 0.5) * 20 * a,
|
|
78
|
+
shakeY: (Math.random() - 0.5) * 10 * a,
|
|
79
|
+
scaleDistort: 1 + (Math.random() - 0.5) * 0.1 * a,
|
|
80
|
+
isGlitching: !0,
|
|
81
|
+
opacity: Math.random() > 0.3 ? 1 : 0.7 + Math.random() * 0.3
|
|
82
|
+
});
|
|
83
|
+
}, s * E);
|
|
84
|
+
i.current.push(y);
|
|
85
|
+
}
|
|
86
|
+
const T = setTimeout(() => {
|
|
87
|
+
o(W), x();
|
|
88
|
+
}, e);
|
|
89
|
+
i.current.push(T);
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
[$]
|
|
93
|
+
), g = m(() => d({ duration: 100, intensity: 0.3, frames: 3 }), [d]), A = m(() => d({ duration: 500, intensity: 1, frames: 12 }), [d]), F = m(() => new Promise((n) => {
|
|
94
|
+
$(), o((x) => ({ ...x, isGlitching: !0 }));
|
|
95
|
+
const e = [50, 30, 80, 20, 60, 40];
|
|
96
|
+
let u = 0;
|
|
97
|
+
e.forEach((x, E) => {
|
|
98
|
+
const T = setTimeout(() => {
|
|
99
|
+
o({
|
|
100
|
+
shakeX: E % 2 === 0 ? (Math.random() - 0.5) * 15 : 0,
|
|
101
|
+
shakeY: E % 2 === 0 ? (Math.random() - 0.5) * 8 : 0,
|
|
102
|
+
scaleDistort: E % 2 === 0 ? 0.95 + Math.random() * 0.1 : 1,
|
|
103
|
+
isGlitching: !0,
|
|
104
|
+
opacity: E % 2 === 0 ? 0.8 : 1
|
|
105
|
+
});
|
|
106
|
+
}, u);
|
|
107
|
+
i.current.push(T), u += x;
|
|
108
|
+
});
|
|
109
|
+
const f = setTimeout(() => {
|
|
110
|
+
o(W), n();
|
|
111
|
+
}, u);
|
|
112
|
+
i.current.push(f);
|
|
113
|
+
}), [$]), c = m(
|
|
114
|
+
(n = "") => {
|
|
115
|
+
if (!t.isGlitching) return n;
|
|
116
|
+
const e = `translate(${t.shakeX}px, ${t.shakeY}px) scale(${t.scaleDistort})`;
|
|
117
|
+
return n ? `${n} ${e}` : e;
|
|
118
|
+
},
|
|
119
|
+
[t]
|
|
120
|
+
);
|
|
121
|
+
return {
|
|
122
|
+
glitchState: t,
|
|
123
|
+
triggerGlitch: d,
|
|
124
|
+
microGlitch: g,
|
|
125
|
+
heavyGlitch: A,
|
|
126
|
+
stutterGlitch: F,
|
|
127
|
+
getGlitchTransform: c,
|
|
128
|
+
isGlitching: t.isGlitching
|
|
129
|
+
};
|
|
130
|
+
}, nt = {
|
|
131
|
+
closed: 1,
|
|
132
|
+
M: 1,
|
|
133
|
+
neutral: 1.2,
|
|
134
|
+
O: 1.2,
|
|
135
|
+
open: 1.5,
|
|
136
|
+
A: 1.5,
|
|
137
|
+
F: 1.5,
|
|
138
|
+
E: 2,
|
|
139
|
+
I: 2,
|
|
140
|
+
smile: 2.5,
|
|
141
|
+
W: 0.8,
|
|
142
|
+
U: 0.8
|
|
143
|
+
}, it = {
|
|
144
|
+
closed: 0,
|
|
145
|
+
M: 0.05,
|
|
146
|
+
F: 0.15,
|
|
147
|
+
E: 0.35,
|
|
148
|
+
I: 0.3,
|
|
149
|
+
neutral: 0.4,
|
|
150
|
+
smile: 0.55,
|
|
151
|
+
W: 0.65,
|
|
152
|
+
U: 0.65,
|
|
153
|
+
open: 0.8,
|
|
154
|
+
A: 0.85,
|
|
155
|
+
O: 0.95
|
|
156
|
+
};
|
|
157
|
+
function at(t) {
|
|
158
|
+
if (t.shape) {
|
|
159
|
+
const o = t.openness ?? it[t.shape], i = t.width ?? nt[t.shape];
|
|
160
|
+
return { shape: t.shape, openness: o, widthMultiplier: i };
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
shape: t.visible ? "open" : "closed",
|
|
164
|
+
openness: t.scale ?? 1,
|
|
165
|
+
widthMultiplier: 1
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const ht = ({
|
|
169
|
+
controller: t,
|
|
170
|
+
state: o,
|
|
171
|
+
expression: i,
|
|
172
|
+
autoAnimate: $ = !1,
|
|
173
|
+
className: d = "",
|
|
174
|
+
eyeSize: g,
|
|
175
|
+
eyeGap: A,
|
|
176
|
+
mouthSize: F,
|
|
177
|
+
glowColor: c,
|
|
178
|
+
glowIntensity: n = 0.4,
|
|
179
|
+
cursorTracking: e = !0,
|
|
180
|
+
enableGlitch: u = !0,
|
|
181
|
+
speechText: f,
|
|
182
|
+
playIntro: x,
|
|
183
|
+
onIntroComplete: E
|
|
184
|
+
}) => {
|
|
185
|
+
const T = G(null), [s, y] = D(
|
|
186
|
+
x === void 0 ? "done" : "pixel"
|
|
187
|
+
), S = G(E);
|
|
188
|
+
S.current = E, N(() => {
|
|
189
|
+
if (x === void 0) {
|
|
190
|
+
y("done");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (!x) return;
|
|
194
|
+
y("pixel");
|
|
195
|
+
const h = [
|
|
196
|
+
setTimeout(() => y("grow"), 900),
|
|
197
|
+
setTimeout(() => y("split"), 1400),
|
|
198
|
+
setTimeout(() => {
|
|
199
|
+
var M;
|
|
200
|
+
y("done"), (M = S.current) == null || M.call(S);
|
|
201
|
+
}, 1900)
|
|
202
|
+
];
|
|
203
|
+
return () => h.forEach(clearTimeout);
|
|
204
|
+
}, [x]);
|
|
205
|
+
const a = g ?? 90, q = A ?? 120, P = F ?? 40, { eyePosition: p } = et({
|
|
206
|
+
enabled: e && !(t != null && t.isPlaying),
|
|
207
|
+
containerRef: T,
|
|
208
|
+
maxOffset: 0.4,
|
|
209
|
+
smoothing: 0.12,
|
|
210
|
+
deadZone: 0.08
|
|
211
|
+
}), { glitchState: r, getGlitchTransform: X } = st(), l = b(() => {
|
|
212
|
+
var h;
|
|
213
|
+
return t ? t.state : o || (i ? ((h = I(i)) == null ? void 0 : h.state) ?? j() : j());
|
|
214
|
+
}, [t, o, i]), _ = G({ x: 0, y: 0, tilt: 0 }), B = G(l.face);
|
|
215
|
+
B.current !== l.face && (B.current = l.face, _.current = {
|
|
216
|
+
x: (Math.random() - 0.5) * 0.08,
|
|
217
|
+
y: (Math.random() - 0.5) * 0.08,
|
|
218
|
+
tilt: (Math.random() - 0.5) * 3
|
|
219
|
+
});
|
|
220
|
+
const z = b(() => {
|
|
221
|
+
const h = l.face ?? { x: 0, y: 0, tilt: 0 }, M = e && !(t != null && t.isPlaying) ? 0.15 : 0, O = _.current;
|
|
222
|
+
return {
|
|
223
|
+
x: h.x + p.x * M + O.x,
|
|
224
|
+
y: h.y + p.y * M + O.y,
|
|
225
|
+
tilt: (h.tilt ?? 0) + O.tilt
|
|
226
|
+
};
|
|
227
|
+
}, [l.face, p, e, t == null ? void 0 : t.isPlaying]), R = b(() => {
|
|
228
|
+
const h = l.eyes.position ?? { x: 0, y: 0 };
|
|
229
|
+
return t != null && t.isPlaying ? h : {
|
|
230
|
+
x: h.x + p.x,
|
|
231
|
+
y: h.y + p.y
|
|
232
|
+
};
|
|
233
|
+
}, [l.eyes.position, p, t == null ? void 0 : t.isPlaying]), L = b(() => ({
|
|
234
|
+
x: R.x * (a * 0.4),
|
|
235
|
+
y: R.y * (a * 0.4)
|
|
236
|
+
}), [R, a]), k = b(() => {
|
|
237
|
+
if (!e || t != null && t.isPlaying)
|
|
238
|
+
return { squintFactor: 1, crossEyeFactor: 0 };
|
|
239
|
+
const h = Math.sqrt(p.x ** 2 + p.y ** 2);
|
|
240
|
+
if (h < 0.15) {
|
|
241
|
+
const M = 1 - h / 0.15;
|
|
242
|
+
return {
|
|
243
|
+
// Squint up to 60% (scaleY from 1.0 to 0.4)
|
|
244
|
+
squintFactor: 1 - M * 0.6,
|
|
245
|
+
// Cross eyes inward (cute effect)
|
|
246
|
+
crossEyeFactor: M * 0.35
|
|
247
|
+
// Max 35% inward
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return { squintFactor: 1, crossEyeFactor: 0 };
|
|
251
|
+
}, [p, e, t == null ? void 0 : t.isPlaying]), w = b(() => ({
|
|
252
|
+
width: `min(${a}px, 12vmin)`,
|
|
253
|
+
height: `min(${a}px, 12vmin)`,
|
|
254
|
+
transition: r.isGlitching ? "none" : "transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1)",
|
|
255
|
+
boxShadow: c ? `0 0 ${25 * n}px ${4 * n}px ${c}` : `0 0 ${25 * n}px ${4 * n}px hsl(var(--avatar-glow) / ${n})`,
|
|
256
|
+
opacity: r.opacity
|
|
257
|
+
}), [a, c, n, r]), U = b(() => ({
|
|
258
|
+
...w,
|
|
259
|
+
transform: X(
|
|
260
|
+
`scaleY(${(l.eyes.leftScaleY ?? l.eyes.scaleY) * k.squintFactor}) scaleX(${l.eyes.scaleX ?? 1})`
|
|
261
|
+
)
|
|
262
|
+
}), [w, l.eyes, X, k.squintFactor]), V = b(() => ({
|
|
263
|
+
...w,
|
|
264
|
+
transform: X(
|
|
265
|
+
`scaleY(${(l.eyes.rightScaleY ?? l.eyes.scaleY) * k.squintFactor}) scaleX(${l.eyes.scaleX ?? 1})`
|
|
266
|
+
)
|
|
267
|
+
}), [w, l.eyes, X, k.squintFactor]), K = b(
|
|
268
|
+
() => ({
|
|
269
|
+
transform: `translate(${L.x + k.crossEyeFactor * a * 0.4}px, ${L.y}px)`,
|
|
270
|
+
transition: r.isGlitching ? "none" : "transform 0.08s ease-out"
|
|
271
|
+
}),
|
|
272
|
+
[L, k.crossEyeFactor, a, r.isGlitching]
|
|
273
|
+
), Z = b(
|
|
274
|
+
() => ({
|
|
275
|
+
transform: `translate(${L.x - k.crossEyeFactor * a * 0.4}px, ${L.y}px)`,
|
|
276
|
+
transition: r.isGlitching ? "none" : "transform 0.08s ease-out"
|
|
277
|
+
}),
|
|
278
|
+
[L, k.crossEyeFactor, a, r.isGlitching]
|
|
279
|
+
), Y = b(() => at(l.mouth), [l.mouth]), J = b(
|
|
280
|
+
() => {
|
|
281
|
+
const h = Y.openness, M = Y.widthMultiplier * (0.6 + h * 0.4), O = P * M, H = h * 0.9 + 0.1, Q = P * H;
|
|
282
|
+
return {
|
|
283
|
+
width: `min(${O}px, ${4 * M}vmin)`,
|
|
284
|
+
height: `min(${Q}px, ${4 * H}vmin)`,
|
|
285
|
+
marginTop: `min(${a * 0.6}px, 7.2vmin)`,
|
|
286
|
+
opacity: Y.shape === "closed" ? 0 : r.opacity,
|
|
287
|
+
transform: X(
|
|
288
|
+
`scale(${Y.shape === "closed" ? 0 : 1})`
|
|
289
|
+
),
|
|
290
|
+
transition: r.isGlitching ? "none" : "opacity 0.05s, transform 0.08s cubic-bezier(0.68, -0.55, 0.265, 1.55), width 0.1s ease-out, height 0.1s ease-out",
|
|
291
|
+
boxShadow: c ? `0 0 ${20 * n}px ${3 * n}px ${c}` : `0 0 ${20 * n}px ${3 * n}px hsl(var(--avatar-glow) / ${n})`
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
[P, a, Y.shape, Y.openness, Y.widthMultiplier, c, n, X, r]
|
|
295
|
+
);
|
|
296
|
+
return /* @__PURE__ */ C(
|
|
297
|
+
"div",
|
|
298
|
+
{
|
|
299
|
+
ref: T,
|
|
300
|
+
className: d || void 0,
|
|
301
|
+
style: {
|
|
302
|
+
...{
|
|
303
|
+
"--avatar-bg": "var(--background, #000)",
|
|
304
|
+
"--avatar-fg": "var(--foreground, #fff)",
|
|
305
|
+
"--avatar-glow-color": c || "var(--avatar-glow, 210 100% 60%)"
|
|
306
|
+
},
|
|
307
|
+
position: "relative",
|
|
308
|
+
width: "100%",
|
|
309
|
+
height: "100%",
|
|
310
|
+
backgroundColor: "hsl(var(--avatar-bg))",
|
|
311
|
+
overflow: "hidden"
|
|
312
|
+
},
|
|
313
|
+
children: [
|
|
314
|
+
/* @__PURE__ */ v(
|
|
315
|
+
"div",
|
|
316
|
+
{
|
|
317
|
+
style: {
|
|
318
|
+
position: "absolute",
|
|
319
|
+
inset: 0,
|
|
320
|
+
pointerEvents: "none",
|
|
321
|
+
background: "radial-gradient(ellipse at center, transparent 35%, hsl(var(--avatar-bg) / 0.3) 70%, hsl(var(--avatar-bg) / 0.6) 100%)"
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
),
|
|
325
|
+
/* @__PURE__ */ v(
|
|
326
|
+
"div",
|
|
327
|
+
{
|
|
328
|
+
style: {
|
|
329
|
+
position: "absolute",
|
|
330
|
+
inset: 0,
|
|
331
|
+
pointerEvents: "none",
|
|
332
|
+
opacity: 0.03,
|
|
333
|
+
backgroundImage: "repeating-linear-gradient(0deg, transparent, transparent 2px, hsl(var(--avatar-fg)) 2px, hsl(var(--avatar-fg)) 4px)"
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
),
|
|
337
|
+
f && /* @__PURE__ */ v("div", { style: {
|
|
338
|
+
position: "absolute",
|
|
339
|
+
bottom: 32,
|
|
340
|
+
left: "50%",
|
|
341
|
+
transform: "translateX(-50%)",
|
|
342
|
+
zIndex: 10
|
|
343
|
+
}, children: /* @__PURE__ */ C("div", { style: {
|
|
344
|
+
position: "relative",
|
|
345
|
+
backgroundColor: "hsl(var(--avatar-bg))",
|
|
346
|
+
border: "2px solid hsl(var(--avatar-fg))",
|
|
347
|
+
borderRadius: 16,
|
|
348
|
+
padding: "12px 24px",
|
|
349
|
+
boxShadow: "0 -10px 15px -3px rgba(0,0,0,0.1)",
|
|
350
|
+
maxWidth: 448
|
|
351
|
+
}, children: [
|
|
352
|
+
/* @__PURE__ */ v("div", { style: {
|
|
353
|
+
position: "absolute",
|
|
354
|
+
top: -12,
|
|
355
|
+
left: "50%",
|
|
356
|
+
transform: "translateX(-50%)",
|
|
357
|
+
width: 0,
|
|
358
|
+
height: 0,
|
|
359
|
+
borderLeft: "12px solid transparent",
|
|
360
|
+
borderRight: "12px solid transparent",
|
|
361
|
+
borderBottom: "12px solid hsl(var(--avatar-fg))"
|
|
362
|
+
} }),
|
|
363
|
+
/* @__PURE__ */ v("div", { style: {
|
|
364
|
+
position: "absolute",
|
|
365
|
+
top: -10,
|
|
366
|
+
left: "50%",
|
|
367
|
+
transform: "translateX(-50%)",
|
|
368
|
+
width: 0,
|
|
369
|
+
height: 0,
|
|
370
|
+
borderLeft: "10px solid transparent",
|
|
371
|
+
borderRight: "10px solid transparent",
|
|
372
|
+
borderBottom: "10px solid hsl(var(--avatar-bg))"
|
|
373
|
+
} }),
|
|
374
|
+
/* @__PURE__ */ v("p", { style: { fontSize: 14, fontWeight: 500, color: "hsl(var(--avatar-fg))", margin: 0 }, children: f })
|
|
375
|
+
] }) }),
|
|
376
|
+
/* @__PURE__ */ v("div", { style: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ C(
|
|
377
|
+
"div",
|
|
378
|
+
{
|
|
379
|
+
style: {
|
|
380
|
+
position: "relative",
|
|
381
|
+
display: "flex",
|
|
382
|
+
flexDirection: "column",
|
|
383
|
+
alignItems: "center",
|
|
384
|
+
marginTop: "-5%",
|
|
385
|
+
transform: s !== "done" ? "none" : r.isGlitching ? `translate(${r.shakeX * 0.5}px, ${r.shakeY * 0.5}px)` : `translate(calc(${z.x * 60}px + ${z.x * 8}vmin), calc(${z.y * 60}px + ${z.y * 8}vmin)) rotate(${z.tilt}deg)`,
|
|
386
|
+
transition: r.isGlitching ? "none" : "transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)"
|
|
387
|
+
},
|
|
388
|
+
children: [
|
|
389
|
+
/* @__PURE__ */ C("div", { style: {
|
|
390
|
+
display: "flex",
|
|
391
|
+
alignItems: "center",
|
|
392
|
+
justifyContent: "center",
|
|
393
|
+
gap: s === "split" || s === "done" ? `min(${q}px, 16vmin)` : "0px",
|
|
394
|
+
transition: "gap 0.5s cubic-bezier(0.34, 1.56, 0.64, 1)"
|
|
395
|
+
}, children: [
|
|
396
|
+
/* @__PURE__ */ v("div", { style: {
|
|
397
|
+
position: "relative",
|
|
398
|
+
...s === "done" ? U : {
|
|
399
|
+
...w,
|
|
400
|
+
width: s === "pixel" ? "20px" : w.width,
|
|
401
|
+
height: s === "pixel" ? "20px" : w.height,
|
|
402
|
+
transform: "scaleY(1)",
|
|
403
|
+
transition: "all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1)"
|
|
404
|
+
}
|
|
405
|
+
}, children: /* @__PURE__ */ v(
|
|
406
|
+
"div",
|
|
407
|
+
{
|
|
408
|
+
style: {
|
|
409
|
+
position: "absolute",
|
|
410
|
+
inset: 0,
|
|
411
|
+
backgroundColor: "hsl(var(--avatar-fg))",
|
|
412
|
+
...s === "done" ? K : {}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
) }),
|
|
416
|
+
/* @__PURE__ */ v("div", { style: {
|
|
417
|
+
position: "relative",
|
|
418
|
+
...s === "done" ? V : {
|
|
419
|
+
...w,
|
|
420
|
+
width: s === "pixel" ? "20px" : w.width,
|
|
421
|
+
height: s === "pixel" ? "20px" : w.height,
|
|
422
|
+
transform: "scaleY(1)",
|
|
423
|
+
transition: "all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1)",
|
|
424
|
+
marginLeft: s === "pixel" ? "-20px" : s === "grow" ? `calc(-1 * min(${a}px, 12vmin))` : void 0
|
|
425
|
+
}
|
|
426
|
+
}, children: /* @__PURE__ */ v(
|
|
427
|
+
"div",
|
|
428
|
+
{
|
|
429
|
+
style: {
|
|
430
|
+
position: "absolute",
|
|
431
|
+
inset: 0,
|
|
432
|
+
backgroundColor: "hsl(var(--avatar-fg))",
|
|
433
|
+
...s === "done" ? Z : {}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
) })
|
|
437
|
+
] }),
|
|
438
|
+
/* @__PURE__ */ v("div", { style: {
|
|
439
|
+
backgroundColor: "hsl(var(--avatar-fg))",
|
|
440
|
+
...J,
|
|
441
|
+
...s !== "done" ? { opacity: 0, transform: "scale(0)" } : {}
|
|
442
|
+
} })
|
|
443
|
+
]
|
|
444
|
+
}
|
|
445
|
+
) })
|
|
446
|
+
]
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
};
|
|
450
|
+
function lt(t, o) {
|
|
451
|
+
const i = G(null), [$, d] = D(!1);
|
|
452
|
+
N(() => (i.current = new tt(t, o), () => {
|
|
453
|
+
var e;
|
|
454
|
+
(e = i.current) == null || e.destroy(), i.current = null;
|
|
455
|
+
}), [t]);
|
|
456
|
+
const g = m((e) => {
|
|
457
|
+
var u;
|
|
458
|
+
(u = i.current) == null || u.feedTimestamps(e);
|
|
459
|
+
}, []), A = m((e) => {
|
|
460
|
+
var u;
|
|
461
|
+
(u = i.current) == null || u.connectElement(e);
|
|
462
|
+
}, []), F = m((e, u) => {
|
|
463
|
+
var f;
|
|
464
|
+
(f = i.current) == null || f.connectSource(e, u);
|
|
465
|
+
}, []), c = m(() => {
|
|
466
|
+
var e;
|
|
467
|
+
(e = i.current) == null || e.start(), d(!0);
|
|
468
|
+
}, []), n = m(() => {
|
|
469
|
+
var e;
|
|
470
|
+
(e = i.current) == null || e.stop(), d(!1);
|
|
471
|
+
}, []);
|
|
472
|
+
return {
|
|
473
|
+
feedTimestamps: g,
|
|
474
|
+
connectElement: A,
|
|
475
|
+
connectSource: F,
|
|
476
|
+
start: c,
|
|
477
|
+
stop: n,
|
|
478
|
+
isSpeaking: $
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
export {
|
|
482
|
+
ht as Avatar,
|
|
483
|
+
mt as AvatarControllerClass,
|
|
484
|
+
ft as EMOTION_ACTIONS,
|
|
485
|
+
xt as FALLBACK_MAP,
|
|
486
|
+
yt as PlaybackSync,
|
|
487
|
+
gt as SpeechBubbleGrouper,
|
|
488
|
+
tt as SpeechController,
|
|
489
|
+
vt as expressionList,
|
|
490
|
+
bt as expressions,
|
|
491
|
+
j as getDefaultState,
|
|
492
|
+
I as getExpression,
|
|
493
|
+
$t as getSequence,
|
|
494
|
+
Et as resolveEmotionKey,
|
|
495
|
+
Mt as sequenceList,
|
|
496
|
+
St as sequences,
|
|
497
|
+
Pt as useAvatarController,
|
|
498
|
+
wt as useAvatarControllerDefault,
|
|
499
|
+
et as useCursorTracking,
|
|
500
|
+
st as useGlitchEffect,
|
|
501
|
+
lt as useSpeech,
|
|
502
|
+
Gt as wordToViseme
|
|
503
|
+
};
|
package/dist/robots.txt
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bod.ee/ai-avatar",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/core.cjs",
|
|
6
|
+
"module": "./dist/core.js",
|
|
7
|
+
"types": "./dist/lib/avatar/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/lib/avatar/index.d.ts",
|
|
11
|
+
"import": "./dist/core.js",
|
|
12
|
+
"require": "./dist/core.cjs"
|
|
13
|
+
},
|
|
14
|
+
"./react": {
|
|
15
|
+
"types": "./dist/avatar-react.d.ts",
|
|
16
|
+
"import": "./dist/react.js",
|
|
17
|
+
"require": "./dist/react.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "vite",
|
|
26
|
+
"dev:lib": "chokidar 'src/lib/avatar/**/*' 'src/components/Avatar.tsx' -c 'bun run build:lib' --initial",
|
|
27
|
+
"build": "vite build",
|
|
28
|
+
"build:dev": "vite build --mode development",
|
|
29
|
+
"build:lib": "vite build --config vite.lib.config.ts && tsc --project tsconfig.lib.json",
|
|
30
|
+
"lint": "eslint .",
|
|
31
|
+
"preview": "vite preview",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:watch": "vitest"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
37
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"react": {
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
"react-dom": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@hookform/resolvers": "^3.10.0",
|
|
49
|
+
"@radix-ui/react-accordion": "^1.2.11",
|
|
50
|
+
"@radix-ui/react-alert-dialog": "^1.1.14",
|
|
51
|
+
"@radix-ui/react-aspect-ratio": "^1.1.7",
|
|
52
|
+
"@radix-ui/react-avatar": "^1.1.10",
|
|
53
|
+
"@radix-ui/react-checkbox": "^1.3.2",
|
|
54
|
+
"@radix-ui/react-collapsible": "^1.1.11",
|
|
55
|
+
"@radix-ui/react-context-menu": "^2.2.15",
|
|
56
|
+
"@radix-ui/react-dialog": "^1.1.14",
|
|
57
|
+
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
|
58
|
+
"@radix-ui/react-hover-card": "^1.1.14",
|
|
59
|
+
"@radix-ui/react-label": "^2.1.7",
|
|
60
|
+
"@radix-ui/react-menubar": "^1.1.15",
|
|
61
|
+
"@radix-ui/react-navigation-menu": "^1.2.13",
|
|
62
|
+
"@radix-ui/react-popover": "^1.1.14",
|
|
63
|
+
"@radix-ui/react-progress": "^1.1.7",
|
|
64
|
+
"@radix-ui/react-radio-group": "^1.3.7",
|
|
65
|
+
"@radix-ui/react-scroll-area": "^1.2.9",
|
|
66
|
+
"@radix-ui/react-select": "^2.2.5",
|
|
67
|
+
"@radix-ui/react-separator": "^1.1.7",
|
|
68
|
+
"@radix-ui/react-slider": "^1.3.5",
|
|
69
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
70
|
+
"@radix-ui/react-switch": "^1.2.5",
|
|
71
|
+
"@radix-ui/react-tabs": "^1.1.12",
|
|
72
|
+
"@radix-ui/react-toast": "^1.2.14",
|
|
73
|
+
"@radix-ui/react-toggle": "^1.1.9",
|
|
74
|
+
"@radix-ui/react-toggle-group": "^1.1.10",
|
|
75
|
+
"@radix-ui/react-tooltip": "^1.2.7",
|
|
76
|
+
"@tanstack/react-query": "^5.83.0",
|
|
77
|
+
"class-variance-authority": "^0.7.1",
|
|
78
|
+
"clsx": "^2.1.1",
|
|
79
|
+
"cmdk": "^1.1.1",
|
|
80
|
+
"date-fns": "^3.6.0",
|
|
81
|
+
"embla-carousel-react": "^8.6.0",
|
|
82
|
+
"input-otp": "^1.4.2",
|
|
83
|
+
"lucide-react": "^0.462.0",
|
|
84
|
+
"next-themes": "^0.3.0",
|
|
85
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
86
|
+
"react-day-picker": "^8.10.1",
|
|
87
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
88
|
+
"react-hook-form": "^7.61.1",
|
|
89
|
+
"react-resizable-panels": "^2.1.9",
|
|
90
|
+
"react-router-dom": "^6.30.1",
|
|
91
|
+
"recharts": "^2.15.4",
|
|
92
|
+
"sonner": "^1.7.4",
|
|
93
|
+
"tailwind-merge": "^2.6.0",
|
|
94
|
+
"tailwindcss-animate": "^1.0.7",
|
|
95
|
+
"vaul": "^0.9.9",
|
|
96
|
+
"zod": "^3.25.76"
|
|
97
|
+
},
|
|
98
|
+
"devDependencies": {
|
|
99
|
+
"@eslint/js": "^9.32.0",
|
|
100
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
101
|
+
"@testing-library/jest-dom": "^6.6.0",
|
|
102
|
+
"@testing-library/react": "^16.0.0",
|
|
103
|
+
"@types/node": "^22.16.5",
|
|
104
|
+
"@types/react": "^18.3.23",
|
|
105
|
+
"@types/react-dom": "^18.3.7",
|
|
106
|
+
"@vitejs/plugin-react-swc": "^3.11.0",
|
|
107
|
+
"autoprefixer": "^10.4.21",
|
|
108
|
+
"chokidar-cli": "^3.0.0",
|
|
109
|
+
"eslint": "^9.32.0",
|
|
110
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
111
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
112
|
+
"globals": "^15.15.0",
|
|
113
|
+
"jsdom": "^20.0.3",
|
|
114
|
+
"postcss": "^8.5.6",
|
|
115
|
+
"tailwindcss": "^3.4.17",
|
|
116
|
+
"typescript": "^5.8.3",
|
|
117
|
+
"typescript-eslint": "^8.38.0",
|
|
118
|
+
"vite": "^5.4.19",
|
|
119
|
+
"vitest": "^3.2.4"
|
|
120
|
+
}
|
|
121
|
+
}
|