@gui-chat-plugin/avatar 0.0.2 → 0.0.4

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/react.js CHANGED
@@ -1,378 +1,329 @@
1
- import { S as ae, P as ie, W as se, a as le, A as ce, D as ue, C as de, b as J, G as fe, V as me } from "./three-vrm.module-DJ7DURJm.js";
2
- import { TOOL_NAME as he, pluginCore as pe } from "./core.js";
3
- import { SAMPLES as ye, TOOL_DEFINITION as je, executeAvatar as Oe } from "./core.js";
4
- import ge, { useRef as T, useState as ee, useEffect as Q, useCallback as V } from "react";
5
- var X = { exports: {} }, Y = {};
6
- var re;
7
- function ve() {
8
- if (re) return Y;
9
- re = 1;
10
- var u = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.fragment");
11
- function s(P, c, p) {
12
- var k = null;
13
- if (p !== void 0 && (k = "" + p), c.key !== void 0 && (k = "" + c.key), "key" in c) {
14
- p = {};
15
- for (var g in c)
16
- g !== "key" && (p[g] = c[g]);
17
- } else p = c;
18
- return c = p.ref, {
19
- $$typeof: u,
20
- type: P,
21
- key: k,
22
- ref: c !== void 0 ? c : null,
23
- props: p
24
- };
25
- }
26
- return Y.Fragment = v, Y.jsx = s, Y.jsxs = s, Y;
1
+ import { a as e, i as t, n, r, t as i } from "./plugin-Cezk5ZnX.js";
2
+ import { a, c as o, i as s, l as c, n as l, o as u, r as d, s as f, t as p, u as m } from "./three-vrm.module-BlO9zbj_.js";
3
+ import { useCallback as h, useEffect as g, useRef as _, useState as v } from "react";
4
+ //#region \0rolldown/runtime.js
5
+ var y = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), b = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
6
+ if (typeof require < "u") return require.apply(this, arguments);
7
+ throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
8
+ }), x = /* @__PURE__ */ y(((e) => {
9
+ var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
10
+ function r(e, n, r) {
11
+ var i = null;
12
+ if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
13
+ else r = n;
14
+ return n = r.ref, {
15
+ $$typeof: t,
16
+ type: e,
17
+ key: i,
18
+ ref: n === void 0 ? null : n,
19
+ props: r
20
+ };
21
+ }
22
+ e.Fragment = n, e.jsx = r, e.jsxs = r;
23
+ })), S = /* @__PURE__ */ y(((e) => {
24
+ process.env.NODE_ENV !== "production" && (function() {
25
+ function t(e) {
26
+ if (e == null) return null;
27
+ if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
28
+ if (typeof e == "string") return e;
29
+ switch (e) {
30
+ case _: return "Fragment";
31
+ case y: return "Profiler";
32
+ case v: return "StrictMode";
33
+ case w: return "Suspense";
34
+ case T: return "SuspenseList";
35
+ case O: return "Activity";
36
+ }
37
+ if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
38
+ case g: return "Portal";
39
+ case S: return e.displayName || "Context";
40
+ case x: return (e._context.displayName || "Context") + ".Consumer";
41
+ case C:
42
+ var n = e.render;
43
+ return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
44
+ case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
45
+ case D:
46
+ n = e._payload, e = e._init;
47
+ try {
48
+ return t(e(n));
49
+ } catch {}
50
+ }
51
+ return null;
52
+ }
53
+ function n(e) {
54
+ return "" + e;
55
+ }
56
+ function r(e) {
57
+ try {
58
+ n(e);
59
+ var t = !1;
60
+ } catch {
61
+ t = !0;
62
+ }
63
+ if (t) {
64
+ t = console;
65
+ var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
66
+ return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
67
+ }
68
+ }
69
+ function i(e) {
70
+ if (e === _) return "<>";
71
+ if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
72
+ try {
73
+ var n = t(e);
74
+ return n ? "<" + n + ">" : "<...>";
75
+ } catch {
76
+ return "<...>";
77
+ }
78
+ }
79
+ function a() {
80
+ var e = A.A;
81
+ return e === null ? null : e.getOwner();
82
+ }
83
+ function o() {
84
+ return Error("react-stack-top-frame");
85
+ }
86
+ function s(e) {
87
+ if (j.call(e, "key")) {
88
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
89
+ if (t && t.isReactWarning) return !1;
90
+ }
91
+ return e.key !== void 0;
92
+ }
93
+ function c(e, t) {
94
+ function n() {
95
+ P || (P = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
96
+ }
97
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
98
+ get: n,
99
+ configurable: !0
100
+ });
101
+ }
102
+ function l() {
103
+ var e = t(this.type);
104
+ return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
105
+ }
106
+ function u(e, t, n, r, i, a) {
107
+ var o = n.ref;
108
+ return e = {
109
+ $$typeof: h,
110
+ type: e,
111
+ key: t,
112
+ props: n,
113
+ _owner: r
114
+ }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
115
+ enumerable: !1,
116
+ value: null
117
+ }) : Object.defineProperty(e, "ref", {
118
+ enumerable: !1,
119
+ get: l
120
+ }), e._store = {}, Object.defineProperty(e._store, "validated", {
121
+ configurable: !1,
122
+ enumerable: !1,
123
+ writable: !0,
124
+ value: 0
125
+ }), Object.defineProperty(e, "_debugInfo", {
126
+ configurable: !1,
127
+ enumerable: !1,
128
+ writable: !0,
129
+ value: null
130
+ }), Object.defineProperty(e, "_debugStack", {
131
+ configurable: !1,
132
+ enumerable: !1,
133
+ writable: !0,
134
+ value: i
135
+ }), Object.defineProperty(e, "_debugTask", {
136
+ configurable: !1,
137
+ enumerable: !1,
138
+ writable: !0,
139
+ value: a
140
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
141
+ }
142
+ function d(e, n, i, o, l, d) {
143
+ var p = n.children;
144
+ if (p !== void 0) if (o) if (M(p)) {
145
+ for (o = 0; o < p.length; o++) f(p[o]);
146
+ Object.freeze && Object.freeze(p);
147
+ } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
148
+ else f(p);
149
+ if (j.call(n, "key")) {
150
+ p = t(e);
151
+ var m = Object.keys(n).filter(function(e) {
152
+ return e !== "key";
153
+ });
154
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[p + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, p, m, p), R[p + o] = !0);
155
+ }
156
+ if (p = null, i !== void 0 && (r(i), p = "" + i), s(n) && (r(n.key), p = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
157
+ else i = n;
158
+ return p && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), u(e, p, i, a(), l, d);
159
+ }
160
+ function f(e) {
161
+ p(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? p(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
162
+ }
163
+ function p(e) {
164
+ return typeof e == "object" && !!e && e.$$typeof === h;
165
+ }
166
+ var m = b("react"), h = Symbol.for("react.transitional.element"), g = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
167
+ return null;
168
+ };
169
+ m = { react_stack_bottom_frame: function(e) {
170
+ return e();
171
+ } };
172
+ var P, F = {}, I = m.react_stack_bottom_frame.bind(m, o)(), L = N(i(o)), R = {};
173
+ e.Fragment = _, e.jsx = function(e, t, n) {
174
+ var r = 1e4 > A.recentlyCreatedOwnerStacks++;
175
+ return d(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
176
+ }, e.jsxs = function(e, t, n) {
177
+ var r = 1e4 > A.recentlyCreatedOwnerStacks++;
178
+ return d(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
179
+ };
180
+ })();
181
+ })), C = (/* @__PURE__ */ y(((e, t) => {
182
+ process.env.NODE_ENV === "production" ? t.exports = x() : t.exports = S();
183
+ })))();
184
+ function w({ selectedResult: e, isAudioPlaying: t }) {
185
+ let n = _(null), [r, i] = v(!1), [y, b] = v(null), x = _(null), S = _(null), w = _(null), T = _(null), E = _(null), D = _(null), O = _(0), k = _(t);
186
+ g(() => {
187
+ k.current = t;
188
+ }, [t]);
189
+ let A = h(() => {
190
+ if (!n.current) return;
191
+ let e = n.current, t = e.clientWidth, r = e.clientHeight;
192
+ x.current = new m(), S.current = new o(30, t / r, .1, 100), S.current.position.set(0, 1.3, 1.5), S.current.lookAt(0, 1.2, 0), w.current = new s({
193
+ antialias: !0,
194
+ alpha: !0
195
+ }), w.current.setSize(t, r), w.current.setPixelRatio(window.devicePixelRatio), w.current.outputColorSpace = c, e.appendChild(w.current.domElement);
196
+ let i = new a(16777215, .6);
197
+ x.current.add(i);
198
+ let l = new f(16777215, .8);
199
+ l.position.set(1, 1, 1), x.current.add(l), E.current = new u();
200
+ }, []), j = h(() => {
201
+ if (!n.current || !S.current || !w.current) return;
202
+ let e = n.current.clientWidth, t = n.current.clientHeight;
203
+ S.current.aspect = e / t, S.current.updateProjectionMatrix(), w.current.setSize(e, t);
204
+ }, []), M = h(() => {
205
+ D.current = requestAnimationFrame(M);
206
+ let e = E.current, t = w.current, n = x.current, r = S.current, i = T.current;
207
+ if (!e || !t || !n || !r) return;
208
+ let a = e.getDelta(), o = e.getElapsedTime();
209
+ if (i) {
210
+ if (i.update(a), k.current) {
211
+ O.current += a * 10;
212
+ let e = (Math.sin(O.current) + 1) * .3;
213
+ i.expressionManager?.setValue(p.Aa, e);
214
+ let t = i.humanoid?.getNormalizedBoneNode("head"), n = i.humanoid?.getNormalizedBoneNode("neck"), r = i.humanoid?.getNormalizedBoneNode("spine");
215
+ t && (t.rotation.x = Math.sin(o * 2) * .08, t.rotation.z = Math.sin(o * 1.5) * .05), n && (n.rotation.y = Math.sin(o * .8) * .05), r && (r.rotation.z = Math.sin(o * .5) * .03);
216
+ let s = i.humanoid?.getNormalizedBoneNode("leftShoulder"), c = i.humanoid?.getNormalizedBoneNode("rightShoulder"), l = i.humanoid?.getNormalizedBoneNode("leftUpperArm"), u = i.humanoid?.getNormalizedBoneNode("rightUpperArm"), d = i.humanoid?.getNormalizedBoneNode("leftLowerArm"), f = i.humanoid?.getNormalizedBoneNode("rightLowerArm");
217
+ s && (s.rotation.z = .1), c && (c.rotation.z = -.1), l && (l.rotation.z = -.8 + Math.sin(o * 1.2) * .1, l.rotation.x = .4 + Math.sin(o * .9) * .15, l.rotation.y = Math.sin(o * .7) * .1), u && (u.rotation.z = .8 + Math.sin(o * 1.3) * .1, u.rotation.x = .4 + Math.sin(o * 1) * .15, u.rotation.y = Math.sin(o * .8) * .1), d && (d.rotation.y = -1 - Math.sin(o * 1.5) * .2, d.rotation.z = Math.sin(o * 1.1) * .1), f && (f.rotation.y = 1 + Math.sin(o * 1.4) * .2, f.rotation.z = Math.sin(o * 1.2) * .1);
218
+ } else {
219
+ O.current = 0, i.expressionManager?.setValue(p.Aa, 0);
220
+ let e = i.humanoid?.getNormalizedBoneNode("spine"), t = i.humanoid?.getNormalizedBoneNode("head");
221
+ e && (e.rotation.x = Math.sin(o * .8) * .02), t && (t.rotation.x = Math.sin(o * .3) * .03, t.rotation.z = Math.sin(o * .2) * .02);
222
+ let n = i.humanoid?.getNormalizedBoneNode("leftShoulder"), r = i.humanoid?.getNormalizedBoneNode("rightShoulder"), a = i.humanoid?.getNormalizedBoneNode("leftUpperArm"), s = i.humanoid?.getNormalizedBoneNode("rightUpperArm"), c = i.humanoid?.getNormalizedBoneNode("leftLowerArm"), l = i.humanoid?.getNormalizedBoneNode("rightLowerArm");
223
+ n && (n.rotation.z = .1), r && (r.rotation.z = -.1), a && (a.rotation.z = -.9, a.rotation.x = .2, a.rotation.y = 0), s && (s.rotation.z = .9, s.rotation.x = .2, s.rotation.y = 0), c && (c.rotation.y = -.8), l && (l.rotation.y = .8);
224
+ }
225
+ o % 4 < .1 ? i.expressionManager?.setValue(p.Blink, 1) : i.expressionManager?.setValue(p.Blink, 0);
226
+ }
227
+ t.render(n, r);
228
+ }, []), N = h(async (e) => {
229
+ let t = x.current;
230
+ if (t) {
231
+ i(!0), b(null), T.current &&= (t.remove(T.current.scene), null);
232
+ try {
233
+ let n = new d();
234
+ n.register((e) => new l(e));
235
+ let r = (await n.loadAsync(e)).userData.vrm;
236
+ if (!r) throw Error("Failed to load VRM data");
237
+ t.add(r.scene), T.current = r, i(!1);
238
+ } catch (e) {
239
+ console.error("Failed to load VRM:", e), b(`Failed to load avatar: ${e instanceof Error ? e.message : "Unknown error"}`), i(!1);
240
+ }
241
+ }
242
+ }, []), P = h(() => {
243
+ D.current !== null && (cancelAnimationFrame(D.current), D.current = null), window.removeEventListener("resize", j), w.current && n.current && (n.current.removeChild(w.current.domElement), w.current.dispose(), w.current = null), T.current = null, x.current = null, S.current = null, E.current = null;
244
+ }, [j]);
245
+ return g(() => (A(), window.addEventListener("resize", j), M(), () => {
246
+ P();
247
+ }), [
248
+ A,
249
+ j,
250
+ M,
251
+ P
252
+ ]), g(() => {
253
+ if (e?.toolName === "receptron_avatar" && e.data) {
254
+ let t = e.data;
255
+ t.avatarUrl && N(t.avatarUrl);
256
+ }
257
+ }, [e, N]), /* @__PURE__ */ (0, C.jsxs)("div", {
258
+ className: "w-full h-full bg-gradient-to-b from-slate-800 to-slate-900 relative",
259
+ children: [
260
+ /* @__PURE__ */ (0, C.jsx)("div", {
261
+ ref: n,
262
+ className: "w-full h-full"
263
+ }),
264
+ r && /* @__PURE__ */ (0, C.jsx)("div", {
265
+ className: "absolute inset-0 flex items-center justify-center bg-slate-900/80",
266
+ children: /* @__PURE__ */ (0, C.jsx)("div", {
267
+ className: "text-white text-lg",
268
+ children: "Loading Avatar..."
269
+ })
270
+ }),
271
+ y && /* @__PURE__ */ (0, C.jsx)("div", {
272
+ className: "absolute inset-0 flex items-center justify-center bg-slate-900/80",
273
+ children: /* @__PURE__ */ (0, C.jsx)("div", {
274
+ className: "text-red-400 text-lg text-center p-4",
275
+ children: y
276
+ })
277
+ }),
278
+ t && /* @__PURE__ */ (0, C.jsx)("div", {
279
+ className: "absolute top-4 right-4 px-3 py-1 bg-green-600 text-white text-sm rounded-full",
280
+ children: "Speaking..."
281
+ })
282
+ ]
283
+ });
27
284
  }
28
- var I = {};
29
- var te;
30
- function xe() {
31
- return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
32
- function u(e) {
33
- if (e == null) return null;
34
- if (typeof e == "function")
35
- return e.$$typeof === K ? null : e.displayName || e.name || null;
36
- if (typeof e == "string") return e;
37
- switch (e) {
38
- case y:
39
- return "Fragment";
40
- case W:
41
- return "Profiler";
42
- case U:
43
- return "StrictMode";
44
- case m:
45
- return "Suspense";
46
- case z:
47
- return "SuspenseList";
48
- case o:
49
- return "Activity";
50
- }
51
- if (typeof e == "object")
52
- switch (typeof e.tag == "number" && console.error(
53
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
54
- ), e.$$typeof) {
55
- case $:
56
- return "Portal";
57
- case l:
58
- return e.displayName || "Context";
59
- case G:
60
- return (e._context.displayName || "Context") + ".Consumer";
61
- case f:
62
- var r = e.render;
63
- return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
64
- case t:
65
- return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
66
- case j:
67
- r = e._payload, e = e._init;
68
- try {
69
- return u(e(r));
70
- } catch {
71
- }
72
- }
73
- return null;
74
- }
75
- function v(e) {
76
- return "" + e;
77
- }
78
- function s(e) {
79
- try {
80
- v(e);
81
- var r = !1;
82
- } catch {
83
- r = !0;
84
- }
85
- if (r) {
86
- r = console;
87
- var n = r.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
88
- return n.call(
89
- r,
90
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
91
- a
92
- ), v(e);
93
- }
94
- }
95
- function P(e) {
96
- if (e === y) return "<>";
97
- if (typeof e == "object" && e !== null && e.$$typeof === j)
98
- return "<...>";
99
- try {
100
- var r = u(e);
101
- return r ? "<" + r + ">" : "<...>";
102
- } catch {
103
- return "<...>";
104
- }
105
- }
106
- function c() {
107
- var e = O.A;
108
- return e === null ? null : e.getOwner();
109
- }
110
- function p() {
111
- return Error("react-stack-top-frame");
112
- }
113
- function k(e) {
114
- if (E.call(e, "key")) {
115
- var r = Object.getOwnPropertyDescriptor(e, "key").get;
116
- if (r && r.isReactWarning) return !1;
117
- }
118
- return e.key !== void 0;
119
- }
120
- function g(e, r) {
121
- function n() {
122
- b || (b = !0, console.error(
123
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
124
- r
125
- ));
126
- }
127
- n.isReactWarning = !0, Object.defineProperty(e, "key", {
128
- get: n,
129
- configurable: !0
130
- });
131
- }
132
- function x() {
133
- var e = u(this.type);
134
- return R[e] || (R[e] = !0, console.error(
135
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
136
- )), e = this.props.ref, e !== void 0 ? e : null;
137
- }
138
- function d(e, r, n, a, q, H) {
139
- var i = n.ref;
140
- return e = {
141
- $$typeof: F,
142
- type: e,
143
- key: r,
144
- props: n,
145
- _owner: a
146
- }, (i !== void 0 ? i : null) !== null ? Object.defineProperty(e, "ref", {
147
- enumerable: !1,
148
- get: x
149
- }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
150
- configurable: !1,
151
- enumerable: !1,
152
- writable: !0,
153
- value: 0
154
- }), Object.defineProperty(e, "_debugInfo", {
155
- configurable: !1,
156
- enumerable: !1,
157
- writable: !0,
158
- value: null
159
- }), Object.defineProperty(e, "_debugStack", {
160
- configurable: !1,
161
- enumerable: !1,
162
- writable: !0,
163
- value: q
164
- }), Object.defineProperty(e, "_debugTask", {
165
- configurable: !1,
166
- enumerable: !1,
167
- writable: !0,
168
- value: H
169
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
170
- }
171
- function w(e, r, n, a, q, H) {
172
- var i = r.children;
173
- if (i !== void 0)
174
- if (a)
175
- if (C(i)) {
176
- for (a = 0; a < i.length; a++)
177
- L(i[a]);
178
- Object.freeze && Object.freeze(i);
179
- } else
180
- console.error(
181
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
182
- );
183
- else L(i);
184
- if (E.call(r, "key")) {
185
- i = u(e);
186
- var D = Object.keys(r).filter(function(oe) {
187
- return oe !== "key";
188
- });
189
- a = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", B[i + a] || (D = 0 < D.length ? "{" + D.join(": ..., ") + ": ...}" : "{}", console.error(
190
- `A props object containing a "key" prop is being spread into JSX:
191
- let props = %s;
192
- <%s {...props} />
193
- React keys must be passed directly to JSX without using spread:
194
- let props = %s;
195
- <%s key={someKey} {...props} />`,
196
- a,
197
- i,
198
- D,
199
- i
200
- ), B[i + a] = !0);
201
- }
202
- if (i = null, n !== void 0 && (s(n), i = "" + n), k(r) && (s(r.key), i = "" + r.key), "key" in r) {
203
- n = {};
204
- for (var Z in r)
205
- Z !== "key" && (n[Z] = r[Z]);
206
- } else n = r;
207
- return i && g(
208
- n,
209
- typeof e == "function" ? e.displayName || e.name || "Unknown" : e
210
- ), d(
211
- e,
212
- i,
213
- n,
214
- c(),
215
- q,
216
- H
217
- );
218
- }
219
- function L(e) {
220
- M(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === j && (e._payload.status === "fulfilled" ? M(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
221
- }
222
- function M(e) {
223
- return typeof e == "object" && e !== null && e.$$typeof === F;
224
- }
225
- var S = ge, F = /* @__PURE__ */ Symbol.for("react.transitional.element"), $ = /* @__PURE__ */ Symbol.for("react.portal"), y = /* @__PURE__ */ Symbol.for("react.fragment"), U = /* @__PURE__ */ Symbol.for("react.strict_mode"), W = /* @__PURE__ */ Symbol.for("react.profiler"), G = /* @__PURE__ */ Symbol.for("react.consumer"), l = /* @__PURE__ */ Symbol.for("react.context"), f = /* @__PURE__ */ Symbol.for("react.forward_ref"), m = /* @__PURE__ */ Symbol.for("react.suspense"), z = /* @__PURE__ */ Symbol.for("react.suspense_list"), t = /* @__PURE__ */ Symbol.for("react.memo"), j = /* @__PURE__ */ Symbol.for("react.lazy"), o = /* @__PURE__ */ Symbol.for("react.activity"), K = /* @__PURE__ */ Symbol.for("react.client.reference"), O = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, E = Object.prototype.hasOwnProperty, C = Array.isArray, A = console.createTask ? console.createTask : function() {
226
- return null;
227
- };
228
- S = {
229
- react_stack_bottom_frame: function(e) {
230
- return e();
231
- }
232
- };
233
- var b, R = {}, N = S.react_stack_bottom_frame.bind(
234
- S,
235
- p
236
- )(), _ = A(P(p)), B = {};
237
- I.Fragment = y, I.jsx = function(e, r, n) {
238
- var a = 1e4 > O.recentlyCreatedOwnerStacks++;
239
- return w(
240
- e,
241
- r,
242
- n,
243
- !1,
244
- a ? Error("react-stack-top-frame") : N,
245
- a ? A(P(e)) : _
246
- );
247
- }, I.jsxs = function(e, r, n) {
248
- var a = 1e4 > O.recentlyCreatedOwnerStacks++;
249
- return w(
250
- e,
251
- r,
252
- n,
253
- !0,
254
- a ? Error("react-stack-top-frame") : N,
255
- a ? A(P(e)) : _
256
- );
257
- };
258
- })()), I;
285
+ //#endregion
286
+ //#region src/react/Preview.tsx
287
+ function T({ result: e }) {
288
+ let t = e.data?.emotion || "neutral";
289
+ return /* @__PURE__ */ (0, C.jsx)("div", {
290
+ className: "p-3 bg-gradient-to-br from-slate-700 to-slate-800 rounded-md",
291
+ children: /* @__PURE__ */ (0, C.jsxs)("div", {
292
+ className: "flex flex-col items-center gap-2",
293
+ children: [
294
+ /* @__PURE__ */ (0, C.jsx)("div", {
295
+ className: "w-12 h-12 bg-slate-600 rounded-full flex items-center justify-center",
296
+ children: /* @__PURE__ */ (0, C.jsx)("svg", {
297
+ className: "w-8 h-8 text-slate-300",
298
+ fill: "none",
299
+ stroke: "currentColor",
300
+ viewBox: "0 0 24 24",
301
+ children: /* @__PURE__ */ (0, C.jsx)("path", {
302
+ strokeLinecap: "round",
303
+ strokeLinejoin: "round",
304
+ strokeWidth: 2,
305
+ d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
306
+ })
307
+ })
308
+ }),
309
+ /* @__PURE__ */ (0, C.jsx)("div", {
310
+ className: "text-sm font-semibold text-white text-center",
311
+ children: "3D Avatar"
312
+ }),
313
+ t && t !== "neutral" && /* @__PURE__ */ (0, C.jsx)("div", {
314
+ className: "text-xs px-2 py-0.5 bg-blue-500 text-white rounded-full",
315
+ children: t
316
+ })
317
+ ]
318
+ })
319
+ });
259
320
  }
260
- var ne;
261
- function Ee() {
262
- return ne || (ne = 1, process.env.NODE_ENV === "production" ? X.exports = ve() : X.exports = xe()), X.exports;
263
- }
264
- var h = Ee();
265
- function be({ selectedResult: u, isAudioPlaying: v }) {
266
- const s = T(null), [P, c] = ee(!1), [p, k] = ee(null), g = T(null), x = T(null), d = T(null), w = T(null), L = T(null), M = T(null), S = T(0), F = T(v);
267
- Q(() => {
268
- F.current = v;
269
- }, [v]);
270
- const $ = V(() => {
271
- if (!s.current) return;
272
- const l = s.current, f = l.clientWidth, m = l.clientHeight;
273
- g.current = new ae(), x.current = new ie(30, f / m, 0.1, 100), x.current.position.set(0, 1.3, 1.5), x.current.lookAt(0, 1.2, 0), d.current = new se({ antialias: !0, alpha: !0 }), d.current.setSize(f, m), d.current.setPixelRatio(window.devicePixelRatio), d.current.outputColorSpace = le, l.appendChild(d.current.domElement);
274
- const z = new ce(16777215, 0.6);
275
- g.current.add(z);
276
- const t = new ue(16777215, 0.8);
277
- t.position.set(1, 1, 1), g.current.add(t), L.current = new de();
278
- }, []), y = V(() => {
279
- if (!s.current || !x.current || !d.current) return;
280
- const l = s.current.clientWidth, f = s.current.clientHeight;
281
- x.current.aspect = l / f, x.current.updateProjectionMatrix(), d.current.setSize(l, f);
282
- }, []), U = V(() => {
283
- M.current = requestAnimationFrame(U);
284
- const l = L.current, f = d.current, m = g.current, z = x.current, t = w.current;
285
- if (!l || !f || !m || !z) return;
286
- const j = l.getDelta(), o = l.getElapsedTime();
287
- if (t) {
288
- if (t.update(j), F.current) {
289
- S.current += j * 10;
290
- const O = (Math.sin(S.current) + 1) * 0.3;
291
- t.expressionManager?.setValue(J.Aa, O);
292
- const E = t.humanoid?.getNormalizedBoneNode("head"), C = t.humanoid?.getNormalizedBoneNode("neck"), A = t.humanoid?.getNormalizedBoneNode("spine");
293
- E && (E.rotation.x = Math.sin(o * 2) * 0.08, E.rotation.z = Math.sin(o * 1.5) * 0.05), C && (C.rotation.y = Math.sin(o * 0.8) * 0.05), A && (A.rotation.z = Math.sin(o * 0.5) * 0.03);
294
- const b = t.humanoid?.getNormalizedBoneNode("leftShoulder"), R = t.humanoid?.getNormalizedBoneNode("rightShoulder"), N = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), _ = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), B = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), e = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
295
- b && (b.rotation.z = 0.1), R && (R.rotation.z = -0.1), N && (N.rotation.z = -0.8 + Math.sin(o * 1.2) * 0.1, N.rotation.x = 0.4 + Math.sin(o * 0.9) * 0.15, N.rotation.y = Math.sin(o * 0.7) * 0.1), _ && (_.rotation.z = 0.8 + Math.sin(o * 1.3) * 0.1, _.rotation.x = 0.4 + Math.sin(o * 1) * 0.15, _.rotation.y = Math.sin(o * 0.8) * 0.1), B && (B.rotation.y = -1 - Math.sin(o * 1.5) * 0.2, B.rotation.z = Math.sin(o * 1.1) * 0.1), e && (e.rotation.y = 1 + Math.sin(o * 1.4) * 0.2, e.rotation.z = Math.sin(o * 1.2) * 0.1);
296
- } else {
297
- S.current = 0, t.expressionManager?.setValue(J.Aa, 0);
298
- const O = t.humanoid?.getNormalizedBoneNode("spine"), E = t.humanoid?.getNormalizedBoneNode("head");
299
- O && (O.rotation.x = Math.sin(o * 0.8) * 0.02), E && (E.rotation.x = Math.sin(o * 0.3) * 0.03, E.rotation.z = Math.sin(o * 0.2) * 0.02);
300
- const C = t.humanoid?.getNormalizedBoneNode("leftShoulder"), A = t.humanoid?.getNormalizedBoneNode("rightShoulder"), b = t.humanoid?.getNormalizedBoneNode("leftUpperArm"), R = t.humanoid?.getNormalizedBoneNode("rightUpperArm"), N = t.humanoid?.getNormalizedBoneNode("leftLowerArm"), _ = t.humanoid?.getNormalizedBoneNode("rightLowerArm");
301
- C && (C.rotation.z = 0.1), A && (A.rotation.z = -0.1), b && (b.rotation.z = -0.9, b.rotation.x = 0.2, b.rotation.y = 0), R && (R.rotation.z = 0.9, R.rotation.x = 0.2, R.rotation.y = 0), N && (N.rotation.y = -0.8), _ && (_.rotation.y = 0.8);
302
- }
303
- o % 4 < 0.1 ? t.expressionManager?.setValue(J.Blink, 1) : t.expressionManager?.setValue(J.Blink, 0);
304
- }
305
- f.render(m, z);
306
- }, []), W = V(async (l) => {
307
- const f = g.current;
308
- if (f) {
309
- c(!0), k(null), w.current && (f.remove(w.current.scene), w.current = null);
310
- try {
311
- const m = new fe();
312
- m.register((j) => new me(j));
313
- const t = (await m.loadAsync(l)).userData.vrm;
314
- if (!t)
315
- throw new Error("Failed to load VRM data");
316
- f.add(t.scene), w.current = t, c(!1);
317
- } catch (m) {
318
- console.error("Failed to load VRM:", m), k(`Failed to load avatar: ${m instanceof Error ? m.message : "Unknown error"}`), c(!1);
319
- }
320
- }
321
- }, []), G = V(() => {
322
- M.current !== null && (cancelAnimationFrame(M.current), M.current = null), window.removeEventListener("resize", y), d.current && s.current && (s.current.removeChild(d.current.domElement), d.current.dispose(), d.current = null), w.current = null, g.current = null, x.current = null, L.current = null;
323
- }, [y]);
324
- return Q(() => ($(), window.addEventListener("resize", y), U(), () => {
325
- G();
326
- }), [$, y, U, G]), Q(() => {
327
- if (u?.toolName === he && u.data) {
328
- const l = u.data;
329
- l.avatarUrl && W(l.avatarUrl);
330
- }
331
- }, [u, W]), /* @__PURE__ */ h.jsxs("div", { className: "w-full h-full bg-gradient-to-b from-slate-800 to-slate-900 relative", children: [
332
- /* @__PURE__ */ h.jsx("div", { ref: s, className: "w-full h-full" }),
333
- P && /* @__PURE__ */ h.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-slate-900/80", children: /* @__PURE__ */ h.jsx("div", { className: "text-white text-lg", children: "Loading Avatar..." }) }),
334
- p && /* @__PURE__ */ h.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-slate-900/80", children: /* @__PURE__ */ h.jsx("div", { className: "text-red-400 text-lg text-center p-4", children: p }) }),
335
- v && /* @__PURE__ */ h.jsx("div", { className: "absolute top-4 right-4 px-3 py-1 bg-green-600 text-white text-sm rounded-full", children: "Speaking..." })
336
- ] });
337
- }
338
- function Re({ result: u }) {
339
- const s = u.data?.emotion || "neutral";
340
- return /* @__PURE__ */ h.jsx("div", { className: "p-3 bg-gradient-to-br from-slate-700 to-slate-800 rounded-md", children: /* @__PURE__ */ h.jsxs("div", { className: "flex flex-col items-center gap-2", children: [
341
- /* @__PURE__ */ h.jsx("div", { className: "w-12 h-12 bg-slate-600 rounded-full flex items-center justify-center", children: /* @__PURE__ */ h.jsx(
342
- "svg",
343
- {
344
- className: "w-8 h-8 text-slate-300",
345
- fill: "none",
346
- stroke: "currentColor",
347
- viewBox: "0 0 24 24",
348
- children: /* @__PURE__ */ h.jsx(
349
- "path",
350
- {
351
- strokeLinecap: "round",
352
- strokeLinejoin: "round",
353
- strokeWidth: 2,
354
- d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
355
- }
356
- )
357
- }
358
- ) }),
359
- /* @__PURE__ */ h.jsx("div", { className: "text-sm font-semibold text-white text-center", children: "3D Avatar" }),
360
- s !== "neutral" && /* @__PURE__ */ h.jsx("div", { className: "text-xs px-2 py-0.5 bg-blue-500 text-white rounded-full", children: s })
361
- ] }) });
362
- }
363
- const Ne = {
364
- ...pe,
365
- ViewComponent: be,
366
- PreviewComponent: Re
367
- }, Te = { plugin: Ne };
368
- export {
369
- Re as Preview,
370
- ye as SAMPLES,
371
- je as TOOL_DEFINITION,
372
- he as TOOL_NAME,
373
- be as View,
374
- Te as default,
375
- Oe as executeAvatar,
376
- Ne as plugin,
377
- pe as pluginCore
378
- };
321
+ //#endregion
322
+ //#region src/react/index.ts
323
+ var E = {
324
+ ...n,
325
+ ViewComponent: w,
326
+ PreviewComponent: T
327
+ }, D = { plugin: E };
328
+ //#endregion
329
+ export { T as Preview, r as SAMPLES, t as TOOL_DEFINITION, e as TOOL_NAME, w as View, D as default, i as executeAvatar, E as plugin, n as pluginCore };