@spatialwalk/avatarkit 1.0.0-beta.13 → 1.0.0-beta.14
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/CHANGELOG.md +12 -0
- package/README.md +10 -3
- package/dist/{StreamingAudioPlayer-CsVJinsO.js → StreamingAudioPlayer-zd5a2zg4.js} +57 -41
- package/dist/StreamingAudioPlayer-zd5a2zg4.js.map +1 -0
- package/dist/audio/AnimationPlayer.d.ts +8 -0
- package/dist/audio/AnimationPlayer.d.ts.map +1 -1
- package/dist/audio/StreamingAudioPlayer.d.ts +1 -0
- package/dist/audio/StreamingAudioPlayer.d.ts.map +1 -1
- package/dist/core/AvatarController.d.ts +31 -20
- package/dist/core/AvatarController.d.ts.map +1 -1
- package/dist/{index-Cy9jPcQt.js → index-CXkdiMjt.js} +347 -307
- package/dist/index-CXkdiMjt.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/vanilla/vite.config.d.ts +3 -0
- package/dist/vanilla/vite.config.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/StreamingAudioPlayer-CsVJinsO.js.map +0 -1
- package/dist/index-Cy9jPcQt.js.map +0 -1
|
@@ -31,14 +31,14 @@ class rn {
|
|
|
31
31
|
}
|
|
32
32
|
var nn = /* @__PURE__ */ ((r) => (r.CAMERA = "camera", r.ANIMATION_IDLE = "frameIdle", r.ANIMATION_MONO = "frameMono", r.AUDIO_MONO = "audioMono", r.MODEL_SHAPE = "shape", r.MODEL_GS = "gsStandard", r))(nn || {});
|
|
33
33
|
function Bi(r) {
|
|
34
|
-
var e, t, n, i, a, o, s, l, g, c, u, m, v, w, y,
|
|
34
|
+
var e, t, n, i, a, o, s, l, g, c, u, m, v, w, y, b, x;
|
|
35
35
|
return {
|
|
36
36
|
camera: ((t = (e = r.camera) == null ? void 0 : e.resource) == null ? void 0 : t.remote) || null,
|
|
37
37
|
frameIdle: ((a = (i = (n = r.animations) == null ? void 0 : n.frameIdle) == null ? void 0 : i.resource) == null ? void 0 : a.remote) || null,
|
|
38
38
|
frameMono: ((l = (s = (o = r.animations) == null ? void 0 : o.frameMono) == null ? void 0 : s.resource) == null ? void 0 : l.remote) || null,
|
|
39
39
|
audioMono: ((u = (c = (g = r.animations) == null ? void 0 : g.audioMono) == null ? void 0 : c.resource) == null ? void 0 : u.remote) || null,
|
|
40
40
|
shape: ((w = (v = (m = r.models) == null ? void 0 : m.shape) == null ? void 0 : v.resource) == null ? void 0 : w.remote) || null,
|
|
41
|
-
gsStandard: ((x = (
|
|
41
|
+
gsStandard: ((x = (b = (y = r.models) == null ? void 0 : y.gsStandard) == null ? void 0 : b.resource) == null ? void 0 : x.remote) || null
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function Di(r) {
|
|
@@ -54,7 +54,7 @@ function Oi(r) {
|
|
|
54
54
|
return !1;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
var le = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(le || {}), oe = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(oe || {}),
|
|
57
|
+
var le = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(le || {}), oe = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(oe || {}), Ae = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(Ae || {}), T = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(T || {});
|
|
58
58
|
class se extends Error {
|
|
59
59
|
constructor(e, t) {
|
|
60
60
|
super(e), this.code = t, this.name = "SPAvatarError";
|
|
@@ -149,8 +149,8 @@ function ln() {
|
|
|
149
149
|
var a = ["isConstructor", "isEval", "isNative", "isToplevel"], o = ["columnNumber", "lineNumber"], s = ["fileName", "functionName", "source"], l = ["args"], g = ["evalOrigin"], c = a.concat(o, s, l, g);
|
|
150
150
|
function u(y) {
|
|
151
151
|
if (y)
|
|
152
|
-
for (var
|
|
153
|
-
y[c[
|
|
152
|
+
for (var b = 0; b < c.length; b++)
|
|
153
|
+
y[c[b]] !== void 0 && this["set" + n(c[b])](y[c[b]]);
|
|
154
154
|
}
|
|
155
155
|
u.prototype = {
|
|
156
156
|
getArgs: function() {
|
|
@@ -173,39 +173,39 @@ function ln() {
|
|
|
173
173
|
throw new TypeError("Eval Origin must be an Object or StackFrame");
|
|
174
174
|
},
|
|
175
175
|
toString: function() {
|
|
176
|
-
var y = this.getFileName() || "",
|
|
177
|
-
return this.getIsEval() ? y ? "[eval] (" + y + ":" +
|
|
176
|
+
var y = this.getFileName() || "", b = this.getLineNumber() || "", x = this.getColumnNumber() || "", L = this.getFunctionName() || "";
|
|
177
|
+
return this.getIsEval() ? y ? "[eval] (" + y + ":" + b + ":" + x + ")" : "[eval]:" + b + ":" + x : L ? L + " (" + y + ":" + b + ":" + x + ")" : y + ":" + b + ":" + x;
|
|
178
178
|
}
|
|
179
|
-
}, u.fromString = function(
|
|
180
|
-
var x =
|
|
181
|
-
if (
|
|
182
|
-
var
|
|
179
|
+
}, u.fromString = function(b) {
|
|
180
|
+
var x = b.indexOf("("), L = b.lastIndexOf(")"), _ = b.substring(0, x), Y = b.substring(x + 1, L).split(","), G = b.substring(L + 1);
|
|
181
|
+
if (G.indexOf("@") === 0)
|
|
182
|
+
var U = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""), j = U[1], X = U[2], J = U[3];
|
|
183
183
|
return new u({
|
|
184
184
|
functionName: _,
|
|
185
185
|
args: Y || void 0,
|
|
186
|
-
fileName:
|
|
186
|
+
fileName: j,
|
|
187
187
|
lineNumber: X || void 0,
|
|
188
|
-
columnNumber:
|
|
188
|
+
columnNumber: J || void 0
|
|
189
189
|
});
|
|
190
190
|
};
|
|
191
191
|
for (var m = 0; m < a.length; m++)
|
|
192
192
|
u.prototype["get" + n(a[m])] = i(a[m]), u.prototype["set" + n(a[m])] = /* @__PURE__ */ function(y) {
|
|
193
|
-
return function(
|
|
194
|
-
this[y] = !!
|
|
193
|
+
return function(b) {
|
|
194
|
+
this[y] = !!b;
|
|
195
195
|
};
|
|
196
196
|
}(a[m]);
|
|
197
197
|
for (var v = 0; v < o.length; v++)
|
|
198
198
|
u.prototype["get" + n(o[v])] = i(o[v]), u.prototype["set" + n(o[v])] = /* @__PURE__ */ function(y) {
|
|
199
|
-
return function(
|
|
200
|
-
if (!t(
|
|
199
|
+
return function(b) {
|
|
200
|
+
if (!t(b))
|
|
201
201
|
throw new TypeError(y + " must be a Number");
|
|
202
|
-
this[y] = Number(
|
|
202
|
+
this[y] = Number(b);
|
|
203
203
|
};
|
|
204
204
|
}(o[v]);
|
|
205
205
|
for (var w = 0; w < s.length; w++)
|
|
206
206
|
u.prototype["get" + n(s[w])] = i(s[w]), u.prototype["set" + n(s[w])] = /* @__PURE__ */ function(y) {
|
|
207
|
-
return function(
|
|
208
|
-
this[y] = String(
|
|
207
|
+
return function(b) {
|
|
208
|
+
this[y] = String(b);
|
|
209
209
|
};
|
|
210
210
|
}(s[w]);
|
|
211
211
|
return u;
|
|
@@ -321,10 +321,10 @@ function ln() {
|
|
|
321
321
|
return g.map(function(c) {
|
|
322
322
|
var u = c.split("@"), m = this.extractLocation(u.pop()), v = u.shift() || "", w = v.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, y;
|
|
323
323
|
v.match(/\(([^)]*)\)/) && (y = v.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
|
|
324
|
-
var
|
|
324
|
+
var b = y === void 0 || y === "[arguments not available]" ? void 0 : y.split(",");
|
|
325
325
|
return new n({
|
|
326
326
|
functionName: w,
|
|
327
|
-
args:
|
|
327
|
+
args: b,
|
|
328
328
|
fileName: m[0],
|
|
329
329
|
lineNumber: m[1],
|
|
330
330
|
columnNumber: m[2],
|
|
@@ -340,150 +340,150 @@ const un = /* @__PURE__ */ sn(cn);
|
|
|
340
340
|
let ft = () => {
|
|
341
341
|
var r = (() => {
|
|
342
342
|
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, i = Object.prototype.hasOwnProperty, a = (f, p) => {
|
|
343
|
-
for (var
|
|
344
|
-
}, o = (f, p,
|
|
345
|
-
if (p && typeof p == "object" || typeof p == "function") for (let E of n(p)) !i.call(f, E) && E !==
|
|
343
|
+
for (var S in p) e(f, S, { get: p[S], enumerable: !0 });
|
|
344
|
+
}, o = (f, p, S, C) => {
|
|
345
|
+
if (p && typeof p == "object" || typeof p == "function") for (let E of n(p)) !i.call(f, E) && E !== S && e(f, E, { get: () => p[E], enumerable: !(C = t(p, E)) || C.enumerable });
|
|
346
346
|
return f;
|
|
347
347
|
}, s = (f) => o(e({}, "__esModule", { value: !0 }), f), l = {};
|
|
348
348
|
a(l, { default: () => Xr });
|
|
349
|
-
var g = (f) => Array.isArray(f), c = (f) => typeof f == "function", u = (f) => f.length === 0, m = (f) => typeof f == "number", v = (f) => typeof f == "object" && f !== null, w = (f) => f instanceof RegExp, y = (f) => typeof f == "string",
|
|
349
|
+
var g = (f) => Array.isArray(f), c = (f) => typeof f == "function", u = (f) => f.length === 0, m = (f) => typeof f == "number", v = (f) => typeof f == "object" && f !== null, w = (f) => f instanceof RegExp, y = (f) => typeof f == "string", b = (f) => f === void 0, x = (f) => {
|
|
350
350
|
const p = /* @__PURE__ */ new Map();
|
|
351
|
-
return (
|
|
352
|
-
const C = p.get(
|
|
351
|
+
return (S) => {
|
|
352
|
+
const C = p.get(S);
|
|
353
353
|
if (C) return C;
|
|
354
|
-
const E = f(
|
|
355
|
-
return p.set(
|
|
354
|
+
const E = f(S);
|
|
355
|
+
return p.set(S, E), E;
|
|
356
356
|
};
|
|
357
|
-
}, L = (f, p,
|
|
358
|
-
const C = { cache: {}, input: f, index: 0, indexMax: 0, options:
|
|
359
|
-
if (
|
|
357
|
+
}, L = (f, p, S = {}) => {
|
|
358
|
+
const C = { cache: {}, input: f, index: 0, indexMax: 0, options: S, output: [] };
|
|
359
|
+
if (V(p)(C) && C.index === f.length) return C.output;
|
|
360
360
|
throw new Error(`Failed to parse at index ${C.indexMax}`);
|
|
361
|
-
}, _ = (f, p) => g(f) ? Y(f, p) : y(f) ?
|
|
362
|
-
const
|
|
361
|
+
}, _ = (f, p) => g(f) ? Y(f, p) : y(f) ? U(f, p) : G(f, p), Y = (f, p) => {
|
|
362
|
+
const S = {};
|
|
363
363
|
for (const C of f) {
|
|
364
364
|
if (C.length !== 1) throw new Error(`Invalid character: "${C}"`);
|
|
365
365
|
const E = C.charCodeAt(0);
|
|
366
|
-
|
|
366
|
+
S[E] = !0;
|
|
367
367
|
}
|
|
368
368
|
return (C) => {
|
|
369
369
|
const E = C.index, P = C.input;
|
|
370
|
-
for (; C.index < P.length && P.charCodeAt(C.index) in
|
|
370
|
+
for (; C.index < P.length && P.charCodeAt(C.index) in S; ) C.index += 1;
|
|
371
371
|
const R = C.index;
|
|
372
372
|
if (R > E) {
|
|
373
|
-
if (!
|
|
374
|
-
const
|
|
375
|
-
|
|
373
|
+
if (!b(p) && !C.options.silent) {
|
|
374
|
+
const W = C.input.slice(E, R), H = c(p) ? p(W, P, String(E)) : p;
|
|
375
|
+
b(H) || C.output.push(H);
|
|
376
376
|
}
|
|
377
377
|
C.indexMax = Math.max(C.indexMax, C.index);
|
|
378
378
|
}
|
|
379
379
|
return !0;
|
|
380
380
|
};
|
|
381
|
-
},
|
|
382
|
-
const
|
|
381
|
+
}, G = (f, p) => {
|
|
382
|
+
const S = f.source, C = f.flags.replace(/y|$/, "y"), E = new RegExp(S, C);
|
|
383
383
|
return ne((P) => {
|
|
384
384
|
E.lastIndex = P.index;
|
|
385
385
|
const R = E.exec(P.input);
|
|
386
386
|
if (R) {
|
|
387
|
-
if (!
|
|
388
|
-
const
|
|
389
|
-
|
|
387
|
+
if (!b(p) && !P.options.silent) {
|
|
388
|
+
const W = c(p) ? p(...R, P.input, String(P.index)) : p;
|
|
389
|
+
b(W) || P.output.push(W);
|
|
390
390
|
}
|
|
391
391
|
return P.index += R[0].length, P.indexMax = Math.max(P.indexMax, P.index), !0;
|
|
392
392
|
} else return !1;
|
|
393
393
|
});
|
|
394
|
-
},
|
|
395
|
-
if (
|
|
396
|
-
if (!
|
|
397
|
-
const C = c(p) ? p(f,
|
|
398
|
-
|
|
394
|
+
}, U = (f, p) => (S) => {
|
|
395
|
+
if (S.input.startsWith(f, S.index)) {
|
|
396
|
+
if (!b(p) && !S.options.silent) {
|
|
397
|
+
const C = c(p) ? p(f, S.input, String(S.index)) : p;
|
|
398
|
+
b(C) || S.output.push(C);
|
|
399
399
|
}
|
|
400
|
-
return
|
|
400
|
+
return S.index += f.length, S.indexMax = Math.max(S.indexMax, S.index), !0;
|
|
401
401
|
} else return !1;
|
|
402
|
-
},
|
|
403
|
-
const E =
|
|
402
|
+
}, j = (f, p, S, C) => {
|
|
403
|
+
const E = V(f);
|
|
404
404
|
return ne(de(we((P) => {
|
|
405
405
|
let R = 0;
|
|
406
|
-
for (; R <
|
|
407
|
-
const
|
|
408
|
-
if (!E(P) || (R += 1, P.index ===
|
|
406
|
+
for (; R < S; ) {
|
|
407
|
+
const W = P.index;
|
|
408
|
+
if (!E(P) || (R += 1, P.index === W)) break;
|
|
409
409
|
}
|
|
410
410
|
return R >= p;
|
|
411
411
|
})));
|
|
412
|
-
}, X = (f, p) =>
|
|
413
|
-
const
|
|
412
|
+
}, X = (f, p) => j(f, 0, 1), J = (f, p) => j(f, 0, 1 / 0), re = (f, p) => {
|
|
413
|
+
const S = f.map(V);
|
|
414
414
|
return ne(de(we((C) => {
|
|
415
|
-
for (let E = 0, P =
|
|
415
|
+
for (let E = 0, P = S.length; E < P; E++) if (!S[E](C)) return !1;
|
|
416
416
|
return !0;
|
|
417
417
|
})));
|
|
418
|
-
},
|
|
419
|
-
const
|
|
418
|
+
}, z = (f, p) => {
|
|
419
|
+
const S = f.map(V);
|
|
420
420
|
return ne(de((C) => {
|
|
421
|
-
for (let E = 0, P =
|
|
421
|
+
for (let E = 0, P = S.length; E < P; E++) if (S[E](C)) return !0;
|
|
422
422
|
return !1;
|
|
423
423
|
}));
|
|
424
424
|
}, we = (f, p = !1) => {
|
|
425
|
-
const
|
|
425
|
+
const S = V(f);
|
|
426
426
|
return (C) => {
|
|
427
|
-
const E = C.index, P = C.output.length, R =
|
|
427
|
+
const E = C.index, P = C.output.length, R = S(C);
|
|
428
428
|
return (!R || p) && (C.index = E, C.output.length !== P && (C.output.length = P)), R;
|
|
429
429
|
};
|
|
430
|
-
}, de = (f, p) =>
|
|
430
|
+
}, de = (f, p) => V(f), ne = /* @__PURE__ */ (() => {
|
|
431
431
|
let f = 0;
|
|
432
432
|
return (p) => {
|
|
433
|
-
const
|
|
433
|
+
const S = V(p), C = f += 1;
|
|
434
434
|
return (E) => {
|
|
435
435
|
var st;
|
|
436
436
|
var P;
|
|
437
|
-
if (E.options.memoization === !1) return
|
|
438
|
-
const R = E.index,
|
|
439
|
-
if (
|
|
440
|
-
if (m(
|
|
441
|
-
if (
|
|
437
|
+
if (E.options.memoization === !1) return S(E);
|
|
438
|
+
const R = E.index, W = (P = E.cache)[C] || (P[C] = /* @__PURE__ */ new Map()), H = W.get(R);
|
|
439
|
+
if (H === !1) return !1;
|
|
440
|
+
if (m(H)) return E.index = H, !0;
|
|
441
|
+
if (H) return E.index = H.index, (st = H.output) != null && st.length && E.output.push(...H.output), !0;
|
|
442
442
|
{
|
|
443
443
|
const lt = E.output.length;
|
|
444
|
-
if (
|
|
444
|
+
if (S(E)) {
|
|
445
445
|
const ct = E.index, ut = E.output.length;
|
|
446
446
|
if (ut > lt) {
|
|
447
447
|
const Qr = E.output.slice(lt, ut);
|
|
448
|
-
|
|
449
|
-
} else
|
|
448
|
+
W.set(R, { index: ct, output: Qr });
|
|
449
|
+
} else W.set(R, ct);
|
|
450
450
|
return !0;
|
|
451
|
-
} else return
|
|
451
|
+
} else return W.set(R, !1), !1;
|
|
452
452
|
}
|
|
453
453
|
};
|
|
454
454
|
};
|
|
455
|
-
})(),
|
|
455
|
+
})(), B = (f) => {
|
|
456
456
|
let p;
|
|
457
|
-
return (
|
|
458
|
-
},
|
|
459
|
-
if (c(f)) return u(f) ?
|
|
457
|
+
return (S) => (p || (p = V(f())), p(S));
|
|
458
|
+
}, V = x((f) => {
|
|
459
|
+
if (c(f)) return u(f) ? B(f) : f;
|
|
460
460
|
if (y(f) || w(f)) return _(f);
|
|
461
461
|
if (g(f)) return re(f);
|
|
462
|
-
if (v(f)) return
|
|
462
|
+
if (v(f)) return z(Object.values(f));
|
|
463
463
|
throw new Error("Invalid rule");
|
|
464
464
|
}), ie = "abcdefghijklmnopqrstuvwxyz", Le = (f) => {
|
|
465
465
|
let p = "";
|
|
466
466
|
for (; f > 0; ) {
|
|
467
|
-
const
|
|
468
|
-
p = ie[
|
|
467
|
+
const S = (f - 1) % 26;
|
|
468
|
+
p = ie[S] + p, f = Math.floor((f - 1) / 26);
|
|
469
469
|
}
|
|
470
470
|
return p;
|
|
471
|
-
},
|
|
471
|
+
}, q = (f) => {
|
|
472
472
|
let p = 0;
|
|
473
|
-
for (let
|
|
473
|
+
for (let S = 0, C = f.length; S < C; S++) p = p * 26 + ie.indexOf(f[S]) + 1;
|
|
474
474
|
return p;
|
|
475
475
|
}, Te = (f, p) => {
|
|
476
476
|
if (p < f) return Te(p, f);
|
|
477
|
-
const
|
|
478
|
-
for (; f <= p; )
|
|
479
|
-
return
|
|
480
|
-
}, ir = (f, p,
|
|
477
|
+
const S = [];
|
|
478
|
+
for (; f <= p; ) S.push(f++);
|
|
479
|
+
return S;
|
|
480
|
+
}, ir = (f, p, S) => Te(f, p).map((C) => String(C).padStart(S, "0")), Xe = (f, p) => Te(q(f), q(p)).map(Le), Z = (f) => f, Qe = (f) => ar((p) => L(p, f, { memoization: !1 }).join("")), ar = (f) => {
|
|
481
481
|
const p = {};
|
|
482
|
-
return (
|
|
483
|
-
}, or = _(/^\*\*\/\*$/, ".*"), sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, p,
|
|
484
|
-
const
|
|
485
|
-
if (!
|
|
486
|
-
const C =
|
|
482
|
+
return (S) => p[S] ?? (p[S] = f(S));
|
|
483
|
+
}, or = _(/^\*\*\/\*$/, ".*"), sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, p, S) => `.*${p ? "" : "(?:^|/)"}${S.replaceAll(".", "\\.")}`), lr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, p, S, C) => `.*${p ? "" : "(?:^|/)"}${S.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Be = _(/\\./, Z), cr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), ur = _(/./, Z), dr = _(/^(?:!!)*!(.*)$/, (f, p) => `(?!^${ot(p)}$).*?`), hr = _(/^(!!)+/, ""), fr = z([dr, hr]), mr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = _(/^(\*\*\/)+/, "(?:^|.*/)"), pr = _(/\/(\*\*)$/, "(?:/.*|$)"), vr = _(/\*\*/, ".*"), et = z([mr, gr, pr, vr]), wr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = _(/\*/, "[^/]*"), tt = z([wr, yr]), rt = _("?", "[^/]"), Sr = _("[", Z), Ar = _("]", Z), br = _(/[!^]/, "^/"), Cr = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, Z), _r = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), Er = _(/[^\]]/, Z), xr = z([Be, _r, Cr, Er]), nt = re([Sr, X(br), J(xr), Ar]), Pr = _("{", "(?:"), Ir = _("}", ")"), kr = _(/(\d+)\.\.(\d+)/, (f, p, S) => ir(+p, +S, Math.min(p.length, S.length)).join("|")), Mr = _(/([a-z]+)\.\.([a-z]+)/, (f, p, S) => Xe(p, S).join("|")), Fr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, p, S) => Xe(p.toLowerCase(), S.toLowerCase()).join("|").toUpperCase()), Rr = z([kr, Mr, Fr]), it = re([Pr, Rr, Ir]), Lr = _("{", "(?:"), Tr = _("}", ")"), Br = _(",", "|"), Dr = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), Or = _(/[^}]/, Z), Nr = B(() => at), Ur = z([et, tt, rt, nt, it, Nr, Be, Dr, Br, Or]), at = re([Lr, J(Ur), Tr]), zr = J(z([or, sr, lr, fr, et, tt, rt, nt, it, at, Be, cr, ur])), Vr = zr, $r = Qe(Vr), ot = $r, qr = _(/\\./, Z), Wr = _(/./, Z), Gr = _(/\*\*\*+/, "*"), jr = _(/([^/{[(!])\*\*/, (f, p) => `${p}*`), Hr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, p) => `${p}*`), Kr = J(z([qr, Gr, jr, Hr, Wr])), Jr = Kr, Zr = Qe(Jr), Yr = Zr, De = (f, p) => {
|
|
484
|
+
const S = Array.isArray(f) ? f : [f];
|
|
485
|
+
if (!S.length) return !1;
|
|
486
|
+
const C = S.map(De.compile), E = S.every((R) => /(\/(?:\*\*)?|\[\/\])$/.test(R)), P = p.replace(/[\\\/]+/g, "/").replace(/\/$/, E ? "/" : "");
|
|
487
487
|
return C.some((R) => R.test(P));
|
|
488
488
|
};
|
|
489
489
|
De.compile = (f) => new RegExp(`^${ot(Yr(f))}$`, "s");
|
|
@@ -557,13 +557,13 @@ function Je(r, e) {
|
|
|
557
557
|
}
|
|
558
558
|
const ve = function(r) {
|
|
559
559
|
return mn.test(r);
|
|
560
|
-
},
|
|
560
|
+
}, Sn = function(r) {
|
|
561
561
|
return ce(r);
|
|
562
562
|
}, Gt = function(r) {
|
|
563
563
|
if (r === "..") return "";
|
|
564
564
|
const e = gn.exec(ce(r));
|
|
565
565
|
return e && e[1] || "";
|
|
566
|
-
},
|
|
566
|
+
}, An = function(r, e) {
|
|
567
567
|
const t = Me(r).replace(mt, "$1").split("/"), n = Me(e).replace(mt, "$1").split("/");
|
|
568
568
|
if (n[0][1] === ":" && t[0][1] === ":" && t[0] !== n[0])
|
|
569
569
|
return n.join("/");
|
|
@@ -617,10 +617,10 @@ const ve = function(r) {
|
|
|
617
617
|
normalize: Ke,
|
|
618
618
|
normalizeString: Je,
|
|
619
619
|
parse: Cn,
|
|
620
|
-
relative:
|
|
620
|
+
relative: An,
|
|
621
621
|
resolve: Me,
|
|
622
622
|
sep: vn,
|
|
623
|
-
toNamespacedPath:
|
|
623
|
+
toNamespacedPath: Sn
|
|
624
624
|
}, En = /* @__PURE__ */ (() => {
|
|
625
625
|
var r;
|
|
626
626
|
return ((r = globalThis.process) == null ? void 0 : r.platform) === "win32" ? ";" : ":";
|
|
@@ -671,7 +671,7 @@ function kn(r = In) {
|
|
|
671
671
|
bgWhite: r ? F("\x1B[47m", "\x1B[49m") : String
|
|
672
672
|
};
|
|
673
673
|
}
|
|
674
|
-
const
|
|
674
|
+
const D = kn(), Ge = {
|
|
675
675
|
[I.Error]: k.Error,
|
|
676
676
|
[I.Warning]: k.Warning,
|
|
677
677
|
[I.Log]: k.Log,
|
|
@@ -690,11 +690,11 @@ const B = kn(), Ge = {
|
|
|
690
690
|
I.Verbose,
|
|
691
691
|
I.Debug
|
|
692
692
|
], Fn = {
|
|
693
|
-
[k.Error]:
|
|
694
|
-
[k.Warning]:
|
|
695
|
-
[k.Log]:
|
|
696
|
-
[k.Verbose]:
|
|
697
|
-
[k.Debug]:
|
|
693
|
+
[k.Error]: D.red,
|
|
694
|
+
[k.Warning]: D.yellow,
|
|
695
|
+
[k.Log]: D.blue,
|
|
696
|
+
[k.Verbose]: D.cyan,
|
|
697
|
+
[k.Debug]: D.green
|
|
698
698
|
}, Fe = [
|
|
699
699
|
k.Error,
|
|
700
700
|
k.Warning,
|
|
@@ -748,16 +748,16 @@ function wt(r) {
|
|
|
748
748
|
let e = "";
|
|
749
749
|
switch (typeof r) {
|
|
750
750
|
case "number":
|
|
751
|
-
e =
|
|
751
|
+
e = D.yellow(r);
|
|
752
752
|
break;
|
|
753
753
|
case "object":
|
|
754
|
-
e =
|
|
754
|
+
e = D.green(JSON.stringify(r));
|
|
755
755
|
break;
|
|
756
756
|
case "boolean":
|
|
757
|
-
e =
|
|
757
|
+
e = D.yellow(String(r));
|
|
758
758
|
break;
|
|
759
759
|
case "undefined":
|
|
760
|
-
e =
|
|
760
|
+
e = D.gray("undefined");
|
|
761
761
|
break;
|
|
762
762
|
default:
|
|
763
763
|
e = String(r);
|
|
@@ -773,7 +773,7 @@ function xe(r) {
|
|
|
773
773
|
)
|
|
774
774
|
);
|
|
775
775
|
let t = "";
|
|
776
|
-
r.fields.isNestSystemModule != null && (t =
|
|
776
|
+
r.fields.isNestSystemModule != null && (t = D.magenta(`[${r.fields.nestSystemModule}]`), delete r.fields.isNestSystemModule, delete r.fields.nestSystemModule), r.fields.context != null && (t = D.magenta(`[${r.fields.context}]`), delete r.fields.context), t.length > 0 && e.push(t), "module" in r.fields && r.fields.module != null && (e.push(D.magenta(`[${r.fields.module}]`)), delete r.fields.module), e.push(r.message);
|
|
777
777
|
const n = Object.entries(r.fields);
|
|
778
778
|
n.length > 0 && e.push(" {");
|
|
779
779
|
for (const [a, o] of n) {
|
|
@@ -787,7 +787,7 @@ function xe(r) {
|
|
|
787
787
|
}
|
|
788
788
|
} else
|
|
789
789
|
s = wt(o);
|
|
790
|
-
e.push(`${
|
|
790
|
+
e.push(`${D.gray(a)}${D.gray("=")}${s}`);
|
|
791
791
|
}
|
|
792
792
|
n.length > 0 && e.push("}");
|
|
793
793
|
let i = e.join(" ");
|
|
@@ -956,9 +956,9 @@ function Qt(r) {
|
|
|
956
956
|
const v = n();
|
|
957
957
|
if (Xt() && v === te.Pretty) {
|
|
958
958
|
c.fields = Object.fromEntries(
|
|
959
|
-
Object.entries(c.fields).filter(([
|
|
960
|
-
if (
|
|
961
|
-
return [
|
|
959
|
+
Object.entries(c.fields).filter(([b, x]) => {
|
|
960
|
+
if (b === "isNestSystemModule" || b === "nestSystemModule" || b === "context")
|
|
961
|
+
return [b, x];
|
|
962
962
|
})
|
|
963
963
|
);
|
|
964
964
|
const y = m ?? e.fields;
|
|
@@ -981,14 +981,14 @@ function Qt(r) {
|
|
|
981
981
|
const v = t(), w = s[c];
|
|
982
982
|
if (!w(v))
|
|
983
983
|
return;
|
|
984
|
-
const y = a(m),
|
|
984
|
+
const y = a(m), b = Yt(
|
|
985
985
|
c,
|
|
986
986
|
e.context,
|
|
987
987
|
y,
|
|
988
988
|
u,
|
|
989
989
|
i()
|
|
990
990
|
);
|
|
991
|
-
o(
|
|
991
|
+
o(b, l[c], y);
|
|
992
992
|
};
|
|
993
993
|
return e.debug = (c, ...u) => {
|
|
994
994
|
g(I.Debug, c, u);
|
|
@@ -1020,7 +1020,7 @@ function qn(r) {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
const Wn = (r) => qn(r).useGlobalConfig();
|
|
1022
1022
|
let Q = [];
|
|
1023
|
-
const
|
|
1023
|
+
const St = 100;
|
|
1024
1024
|
async function Gn() {
|
|
1025
1025
|
if (Q.length === 0)
|
|
1026
1026
|
return;
|
|
@@ -1029,7 +1029,7 @@ async function Gn() {
|
|
|
1029
1029
|
try {
|
|
1030
1030
|
await jn();
|
|
1031
1031
|
} catch (e) {
|
|
1032
|
-
h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)), Q.unshift(...r), Q.length >
|
|
1032
|
+
h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)), Q.unshift(...r), Q.length > St && (Q = Q.slice(0, St));
|
|
1033
1033
|
}
|
|
1034
1034
|
}
|
|
1035
1035
|
async function jn(r) {
|
|
@@ -1038,12 +1038,12 @@ function Hn() {
|
|
|
1038
1038
|
Q.length > 0 && Gn(), h.log("[CLS] Cleaned up");
|
|
1039
1039
|
}
|
|
1040
1040
|
Vn(k.Warning);
|
|
1041
|
-
const h = Wn("Web").withErrorProcessor((r) => r).useGlobalConfig(),
|
|
1041
|
+
const h = Wn("Web").withErrorProcessor((r) => r).useGlobalConfig(), O = {
|
|
1042
1042
|
config: null,
|
|
1043
1043
|
promise: null
|
|
1044
1044
|
};
|
|
1045
1045
|
async function Kn(r) {
|
|
1046
|
-
return
|
|
1046
|
+
return O.promise ? (await O.promise, O.config || {}) : O.config ? O.config : (O.promise = (async () => {
|
|
1047
1047
|
try {
|
|
1048
1048
|
const t = typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") ? `/api/config/sdk?version=${r}` : `https://config.spatialwalk.top/sdk?version=${r}`;
|
|
1049
1049
|
h.log(`[SdkConfigLoader] Fetching SDK config from: ${t}`);
|
|
@@ -1059,16 +1059,16 @@ async function Kn(r) {
|
|
|
1059
1059
|
if (!i.endpoints)
|
|
1060
1060
|
throw new Error("Invalid config response: missing endpoints");
|
|
1061
1061
|
const a = {};
|
|
1062
|
-
i.endpoints.cn && (a[le.cn] = `https://${i.endpoints.cn}`), i.endpoints.us && (a[le.us] = `https://${i.endpoints.us}`), i.endpoints.test && (a[le.test] = `https://${i.endpoints.test}`),
|
|
1062
|
+
i.endpoints.cn && (a[le.cn] = `https://${i.endpoints.cn}`), i.endpoints.us && (a[le.us] = `https://${i.endpoints.us}`), i.endpoints.test && (a[le.test] = `https://${i.endpoints.test}`), O.config = a, h.log("[SdkConfigLoader] SDK config fetched successfully:", a);
|
|
1063
1063
|
} catch {
|
|
1064
|
-
|
|
1064
|
+
O.config = {};
|
|
1065
1065
|
} finally {
|
|
1066
|
-
|
|
1066
|
+
O.promise = null;
|
|
1067
1067
|
}
|
|
1068
|
-
})(), await
|
|
1068
|
+
})(), await O.promise, O.config || {});
|
|
1069
1069
|
}
|
|
1070
1070
|
function Jn() {
|
|
1071
|
-
|
|
1071
|
+
O.config = null, O.promise = null;
|
|
1072
1072
|
}
|
|
1073
1073
|
class Zn {
|
|
1074
1074
|
constructor(e) {
|
|
@@ -1789,7 +1789,7 @@ class Yn {
|
|
|
1789
1789
|
}
|
|
1790
1790
|
}
|
|
1791
1791
|
}
|
|
1792
|
-
class
|
|
1792
|
+
class A {
|
|
1793
1793
|
/**
|
|
1794
1794
|
* SDK 初始化
|
|
1795
1795
|
* @param appId 前端需要在 HTTP Headers 和 WebSocket Headers 中都带上
|
|
@@ -1953,7 +1953,7 @@ class b {
|
|
|
1953
1953
|
h[a](`[Telemetry] ${e}`, i);
|
|
1954
1954
|
}
|
|
1955
1955
|
}
|
|
1956
|
-
d(
|
|
1956
|
+
d(A, "_isInitialized", !1), d(A, "_appId", null), d(A, "_configuration", null), d(A, "_sessionToken", null), d(A, "_userId", null), d(A, "_version", "1.0.0-beta.14"), d(A, "_avatarCore", null), d(A, "_dynamicSdkConfig", null), d(A, "_logLevels", {
|
|
1957
1957
|
debug: "log",
|
|
1958
1958
|
info: "log",
|
|
1959
1959
|
warning: "warn",
|
|
@@ -2022,7 +2022,7 @@ const Ce = class Ce {
|
|
|
2022
2022
|
async createAndInitializeStreamingPlayer() {
|
|
2023
2023
|
if (this.streamingPlayer)
|
|
2024
2024
|
return;
|
|
2025
|
-
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-
|
|
2025
|
+
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-zd5a2zg4.js");
|
|
2026
2026
|
this.streamingPlayer = new e({
|
|
2027
2027
|
sampleRate: M.audio.sampleRate,
|
|
2028
2028
|
channelCount: 1,
|
|
@@ -2032,7 +2032,7 @@ const Ce = class Ce {
|
|
|
2032
2032
|
await this.streamingPlayer.initialize();
|
|
2033
2033
|
} catch (t) {
|
|
2034
2034
|
const n = t instanceof Error ? t.message : String(t);
|
|
2035
|
-
throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n),
|
|
2035
|
+
throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n), A.logEvent("character_player", "error", {
|
|
2036
2036
|
event: "streaming_player_initialize_failed",
|
|
2037
2037
|
reason: n
|
|
2038
2038
|
}), t;
|
|
@@ -2093,6 +2093,20 @@ const Ce = class Ce {
|
|
|
2093
2093
|
addAudioChunk(e, t = !1) {
|
|
2094
2094
|
this.useStreaming && this.streamingPlayer ? this.streamingPlayer.addChunk(e, t) : h.warn("[AnimationPlayer] Cannot add audio chunk - streaming player not ready");
|
|
2095
2095
|
}
|
|
2096
|
+
/**
|
|
2097
|
+
* 暂停播放
|
|
2098
|
+
*/
|
|
2099
|
+
pause() {
|
|
2100
|
+
var e;
|
|
2101
|
+
this.useStreaming ? (e = this.streamingPlayer) == null || e.pause() : this.audio && this.audio.pause();
|
|
2102
|
+
}
|
|
2103
|
+
/**
|
|
2104
|
+
* 继续播放
|
|
2105
|
+
*/
|
|
2106
|
+
async resume() {
|
|
2107
|
+
var e;
|
|
2108
|
+
this.useStreaming ? await ((e = this.streamingPlayer) == null ? void 0 : e.resume()) : this.audio && await this.audio.play();
|
|
2109
|
+
}
|
|
2096
2110
|
dispose() {
|
|
2097
2111
|
this.stop(), this.audio && (this.audio.src = "", this.audio = null), this.streamingPlayer && (this.streamingPlayer.dispose(), this.streamingPlayer = null), this.onEndedCallback = void 0;
|
|
2098
2112
|
}
|
|
@@ -2133,7 +2147,7 @@ function Ue(r, e, t) {
|
|
|
2133
2147
|
}
|
|
2134
2148
|
}
|
|
2135
2149
|
const Ie = 4294967296;
|
|
2136
|
-
function
|
|
2150
|
+
function At(r) {
|
|
2137
2151
|
const e = r[0] === "-";
|
|
2138
2152
|
e && (r = r.slice(1));
|
|
2139
2153
|
const t = 1e6;
|
|
@@ -2200,7 +2214,7 @@ function ti() {
|
|
|
2200
2214
|
throw new Error("invalid varint");
|
|
2201
2215
|
return this.assertBounds(), e >>> 0;
|
|
2202
2216
|
}
|
|
2203
|
-
const
|
|
2217
|
+
const K = /* @__PURE__ */ ri();
|
|
2204
2218
|
function ri() {
|
|
2205
2219
|
const r = new DataView(new ArrayBuffer(8));
|
|
2206
2220
|
if (typeof BigInt == "function" && typeof r.getBigInt64 == "function" && typeof r.getBigUint64 == "function" && typeof r.setBigInt64 == "function" && typeof r.setBigUint64 == "function" && (!!globalThis.Deno || typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1")) {
|
|
@@ -2250,10 +2264,10 @@ function ri() {
|
|
|
2250
2264
|
return typeof t != "string" && (t = t.toString()), Et(t), t;
|
|
2251
2265
|
},
|
|
2252
2266
|
enc(t) {
|
|
2253
|
-
return typeof t != "string" && (t = t.toString()), _t(t),
|
|
2267
|
+
return typeof t != "string" && (t = t.toString()), _t(t), At(t);
|
|
2254
2268
|
},
|
|
2255
2269
|
uEnc(t) {
|
|
2256
|
-
return typeof t != "string" && (t = t.toString()), Et(t),
|
|
2270
|
+
return typeof t != "string" && (t = t.toString()), Et(t), At(t);
|
|
2257
2271
|
},
|
|
2258
2272
|
dec(t, n) {
|
|
2259
2273
|
return Qn(t, n);
|
|
@@ -2424,39 +2438,39 @@ class ue {
|
|
|
2424
2438
|
* Write a `fixed64` value, a signed, fixed-length 64-bit integer.
|
|
2425
2439
|
*/
|
|
2426
2440
|
sfixed64(e) {
|
|
2427
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), i =
|
|
2441
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), i = K.enc(e);
|
|
2428
2442
|
return n.setInt32(0, i.lo, !0), n.setInt32(4, i.hi, !0), this.raw(t);
|
|
2429
2443
|
}
|
|
2430
2444
|
/**
|
|
2431
2445
|
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
|
|
2432
2446
|
*/
|
|
2433
2447
|
fixed64(e) {
|
|
2434
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), i =
|
|
2448
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), i = K.uEnc(e);
|
|
2435
2449
|
return n.setInt32(0, i.lo, !0), n.setInt32(4, i.hi, !0), this.raw(t);
|
|
2436
2450
|
}
|
|
2437
2451
|
/**
|
|
2438
2452
|
* Write a `int64` value, a signed 64-bit varint.
|
|
2439
2453
|
*/
|
|
2440
2454
|
int64(e) {
|
|
2441
|
-
let t =
|
|
2455
|
+
let t = K.enc(e);
|
|
2442
2456
|
return Ue(t.lo, t.hi, this.buf), this;
|
|
2443
2457
|
}
|
|
2444
2458
|
/**
|
|
2445
2459
|
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
2446
2460
|
*/
|
|
2447
2461
|
sint64(e) {
|
|
2448
|
-
const t =
|
|
2462
|
+
const t = K.enc(e), n = t.hi >> 31, i = t.lo << 1 ^ n, a = (t.hi << 1 | t.lo >>> 31) ^ n;
|
|
2449
2463
|
return Ue(i, a, this.buf), this;
|
|
2450
2464
|
}
|
|
2451
2465
|
/**
|
|
2452
2466
|
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
2453
2467
|
*/
|
|
2454
2468
|
uint64(e) {
|
|
2455
|
-
const t =
|
|
2469
|
+
const t = K.uEnc(e);
|
|
2456
2470
|
return Ue(t.lo, t.hi, this.buf), this;
|
|
2457
2471
|
}
|
|
2458
2472
|
}
|
|
2459
|
-
class
|
|
2473
|
+
class N {
|
|
2460
2474
|
constructor(e, t = rr().decodeUtf8) {
|
|
2461
2475
|
this.decodeUtf8 = t, this.varint64 = Xn, this.uint32 = ti, this.buf = e, this.len = e.length, this.pos = 0, this.view = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
2462
2476
|
}
|
|
@@ -2531,20 +2545,20 @@ class O {
|
|
|
2531
2545
|
* Read a `int64` field, a signed 64-bit varint.
|
|
2532
2546
|
*/
|
|
2533
2547
|
int64() {
|
|
2534
|
-
return
|
|
2548
|
+
return K.dec(...this.varint64());
|
|
2535
2549
|
}
|
|
2536
2550
|
/**
|
|
2537
2551
|
* Read a `uint64` field, an unsigned 64-bit varint.
|
|
2538
2552
|
*/
|
|
2539
2553
|
uint64() {
|
|
2540
|
-
return
|
|
2554
|
+
return K.uDec(...this.varint64());
|
|
2541
2555
|
}
|
|
2542
2556
|
/**
|
|
2543
2557
|
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
|
2544
2558
|
*/
|
|
2545
2559
|
sint64() {
|
|
2546
2560
|
let [e, t] = this.varint64(), n = -(e & 1);
|
|
2547
|
-
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n,
|
|
2561
|
+
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n, K.dec(e, t);
|
|
2548
2562
|
}
|
|
2549
2563
|
/**
|
|
2550
2564
|
* Read a `bool` field, a variant.
|
|
@@ -2569,13 +2583,13 @@ class O {
|
|
|
2569
2583
|
* Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
|
|
2570
2584
|
*/
|
|
2571
2585
|
fixed64() {
|
|
2572
|
-
return
|
|
2586
|
+
return K.uDec(this.sfixed32(), this.sfixed32());
|
|
2573
2587
|
}
|
|
2574
2588
|
/**
|
|
2575
2589
|
* Read a `fixed64` field, a signed, fixed-length 64-bit integer.
|
|
2576
2590
|
*/
|
|
2577
2591
|
sfixed64() {
|
|
2578
|
-
return
|
|
2592
|
+
return K.dec(this.sfixed32(), this.sfixed32());
|
|
2579
2593
|
}
|
|
2580
2594
|
/**
|
|
2581
2595
|
* Read a `float` field, 32-bit floating point number.
|
|
@@ -2673,7 +2687,7 @@ const he = {
|
|
|
2673
2687
|
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.audio.length !== 0 && e.uint32(18).bytes(r.audio), r.end !== !1 && e.uint32(24).bool(r.end), e;
|
|
2674
2688
|
},
|
|
2675
2689
|
decode(r, e) {
|
|
2676
|
-
const t = r instanceof
|
|
2690
|
+
const t = r instanceof N ? r : new N(r);
|
|
2677
2691
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2678
2692
|
const i = Pt();
|
|
2679
2693
|
for (; t.pos < n; ) {
|
|
@@ -2706,9 +2720,9 @@ const he = {
|
|
|
2706
2720
|
},
|
|
2707
2721
|
fromJSON(r) {
|
|
2708
2722
|
return {
|
|
2709
|
-
reqId:
|
|
2710
|
-
audio:
|
|
2711
|
-
end:
|
|
2723
|
+
reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
2724
|
+
audio: $(r.audio) ? di(r.audio) : new Uint8Array(0),
|
|
2725
|
+
end: $(r.end) ? globalThis.Boolean(r.end) : !1
|
|
2712
2726
|
};
|
|
2713
2727
|
},
|
|
2714
2728
|
toJSON(r) {
|
|
@@ -2752,7 +2766,7 @@ const fe = {
|
|
|
2752
2766
|
return e.join(), e;
|
|
2753
2767
|
},
|
|
2754
2768
|
decode(r, e) {
|
|
2755
|
-
const t = r instanceof
|
|
2769
|
+
const t = r instanceof N ? r : new N(r);
|
|
2756
2770
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2757
2771
|
const i = It();
|
|
2758
2772
|
for (; t.pos < n; ) {
|
|
@@ -2891,7 +2905,7 @@ const me = {
|
|
|
2891
2905
|
return e;
|
|
2892
2906
|
},
|
|
2893
2907
|
decode(r, e) {
|
|
2894
|
-
const t = r instanceof
|
|
2908
|
+
const t = r instanceof N ? r : new N(r);
|
|
2895
2909
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2896
2910
|
const i = kt();
|
|
2897
2911
|
for (; t.pos < n; ) {
|
|
@@ -2937,7 +2951,7 @@ const ge = {
|
|
|
2937
2951
|
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && me.encode(r.animation, e.uint32(18).fork()).join(), e;
|
|
2938
2952
|
},
|
|
2939
2953
|
decode(r, e) {
|
|
2940
|
-
const t = r instanceof
|
|
2954
|
+
const t = r instanceof N ? r : new N(r);
|
|
2941
2955
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2942
2956
|
const i = Mt();
|
|
2943
2957
|
for (; t.pos < n; ) {
|
|
@@ -2964,8 +2978,8 @@ const ge = {
|
|
|
2964
2978
|
},
|
|
2965
2979
|
fromJSON(r) {
|
|
2966
2980
|
return {
|
|
2967
|
-
reqId:
|
|
2968
|
-
animation:
|
|
2981
|
+
reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
2982
|
+
animation: $(r.animation) ? me.fromJSON(r.animation) : void 0
|
|
2969
2983
|
};
|
|
2970
2984
|
},
|
|
2971
2985
|
toJSON(r) {
|
|
@@ -2988,7 +3002,7 @@ const pe = {
|
|
|
2988
3002
|
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.code !== 0 && e.uint32(16).int32(r.code), r.reason !== "" && e.uint32(26).string(r.reason), e;
|
|
2989
3003
|
},
|
|
2990
3004
|
decode(r, e) {
|
|
2991
|
-
const t = r instanceof
|
|
3005
|
+
const t = r instanceof N ? r : new N(r);
|
|
2992
3006
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2993
3007
|
const i = Ft();
|
|
2994
3008
|
for (; t.pos < n; ) {
|
|
@@ -3021,9 +3035,9 @@ const pe = {
|
|
|
3021
3035
|
},
|
|
3022
3036
|
fromJSON(r) {
|
|
3023
3037
|
return {
|
|
3024
|
-
reqId:
|
|
3025
|
-
code:
|
|
3026
|
-
reason:
|
|
3038
|
+
reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
3039
|
+
code: $(r.code) ? globalThis.Number(r.code) : 0,
|
|
3040
|
+
reason: $(r.reason) ? globalThis.String(r.reason) : ""
|
|
3027
3041
|
};
|
|
3028
3042
|
},
|
|
3029
3043
|
toJSON(r) {
|
|
@@ -3046,7 +3060,7 @@ const He = {
|
|
|
3046
3060
|
return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 && pe.encode(r.error, e.uint32(18).fork()).join(), r.serverResponseAnimation !== void 0 && ge.encode(r.serverResponseAnimation, e.uint32(26).fork()).join(), r.clientAudioInput !== void 0 && he.encode(r.clientAudioInput, e.uint32(34).fork()).join(), e;
|
|
3047
3061
|
},
|
|
3048
3062
|
decode(r, e) {
|
|
3049
|
-
const t = r instanceof
|
|
3063
|
+
const t = r instanceof N ? r : new N(r);
|
|
3050
3064
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
3051
3065
|
const i = Rt();
|
|
3052
3066
|
for (; t.pos < n; ) {
|
|
@@ -3085,10 +3099,10 @@ const He = {
|
|
|
3085
3099
|
},
|
|
3086
3100
|
fromJSON(r) {
|
|
3087
3101
|
return {
|
|
3088
|
-
type:
|
|
3089
|
-
error:
|
|
3090
|
-
serverResponseAnimation:
|
|
3091
|
-
clientAudioInput:
|
|
3102
|
+
type: $(r.type) ? ci(r.type) : 0,
|
|
3103
|
+
error: $(r.error) ? pe.fromJSON(r.error) : void 0,
|
|
3104
|
+
serverResponseAnimation: $(r.serverResponseAnimation) ? ge.fromJSON(r.serverResponseAnimation) : void 0,
|
|
3105
|
+
clientAudioInput: $(r.clientAudioInput) ? he.fromJSON(r.clientAudioInput) : void 0
|
|
3092
3106
|
};
|
|
3093
3107
|
},
|
|
3094
3108
|
toJSON(r) {
|
|
@@ -3115,7 +3129,7 @@ function hi(r) {
|
|
|
3115
3129
|
e.push(globalThis.String.fromCharCode(t));
|
|
3116
3130
|
}), globalThis.btoa(e.join(""));
|
|
3117
3131
|
}
|
|
3118
|
-
function
|
|
3132
|
+
function $(r) {
|
|
3119
3133
|
return r != null;
|
|
3120
3134
|
}
|
|
3121
3135
|
let fi = (r) => crypto.getRandomValues(new Uint8Array(r)), mi = (r, e, t) => {
|
|
@@ -3184,7 +3198,7 @@ class yi extends wi {
|
|
|
3184
3198
|
try {
|
|
3185
3199
|
this.isConnecting = !0, this.currentCharacterId = t;
|
|
3186
3200
|
const n = this.buildWebSocketUrl(t);
|
|
3187
|
-
h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"),
|
|
3201
|
+
h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"), A.logEvent("character_animation_service", "info", {
|
|
3188
3202
|
characterId: t,
|
|
3189
3203
|
event: "connect_success",
|
|
3190
3204
|
url: n
|
|
@@ -3192,7 +3206,7 @@ class yi extends wi {
|
|
|
3192
3206
|
} catch (n) {
|
|
3193
3207
|
this.isConnecting = !1;
|
|
3194
3208
|
const i = n instanceof Error ? n.message : String(n);
|
|
3195
|
-
throw h.error("[AnimationWebSocketClient] Connection failed:", i),
|
|
3209
|
+
throw h.error("[AnimationWebSocketClient] Connection failed:", i), A.logEvent("character_animation_service", "error", {
|
|
3196
3210
|
characterId: t,
|
|
3197
3211
|
event: "connect_failed",
|
|
3198
3212
|
reason: i
|
|
@@ -3225,7 +3239,7 @@ class yi extends wi {
|
|
|
3225
3239
|
return this.ws.send(s), !0;
|
|
3226
3240
|
} catch (a) {
|
|
3227
3241
|
const o = a instanceof Error ? a.message : String(a);
|
|
3228
|
-
return h.error("[AnimationWebSocketClient] Failed to send audio data:", o),
|
|
3242
|
+
return h.error("[AnimationWebSocketClient] Failed to send audio data:", o), A.logEvent("character_animation_service", "warning", {
|
|
3229
3243
|
characterId: this.currentCharacterId,
|
|
3230
3244
|
event: "send_audio_failed",
|
|
3231
3245
|
reqId: t,
|
|
@@ -3264,19 +3278,19 @@ class yi extends wi {
|
|
|
3264
3278
|
this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"), n();
|
|
3265
3279
|
}, this.ws.onmessage = (a) => {
|
|
3266
3280
|
a.data instanceof ArrayBuffer ? this.handleMessage(a.data) : a.data instanceof Blob ? a.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((o) => {
|
|
3267
|
-
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", o),
|
|
3281
|
+
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", o), A.logEvent("character_animation_service", "error", {
|
|
3268
3282
|
characterId: this.currentCharacterId,
|
|
3269
3283
|
event: "decode_blob_failed",
|
|
3270
3284
|
reason: o instanceof Error ? o.message : String(o)
|
|
3271
3285
|
}), this.emit("error", o);
|
|
3272
3286
|
}) : h.warn("[AnimationWebSocketClient] Received non-binary data:", typeof a.data);
|
|
3273
3287
|
}, this.ws.onerror = (a) => {
|
|
3274
|
-
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", a),
|
|
3288
|
+
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", a), A.logEvent("character_animation_service", "error", {
|
|
3275
3289
|
characterId: this.currentCharacterId,
|
|
3276
3290
|
event: "websocket_error"
|
|
3277
3291
|
}), this.emit("error", new Error("WebSocket error")), !this.isManuallyDisconnected && this.currentRetryCount < this.reconnectAttempts && this.scheduleReconnect();
|
|
3278
3292
|
}, this.ws.onclose = (a) => {
|
|
3279
|
-
h.log("[AnimationWebSocketClient] WebSocket closed:", a.code, a.reason), this.emit("disconnected", a.reason || "Connection closed"), a.code === 1012 &&
|
|
3293
|
+
h.log("[AnimationWebSocketClient] WebSocket closed:", a.code, a.reason), this.emit("disconnected", a.reason || "Connection closed"), a.code === 1012 && A.logEvent("character_animation_service", "error", {
|
|
3280
3294
|
characterId: this.currentCharacterId,
|
|
3281
3295
|
event: "service_restart",
|
|
3282
3296
|
reason: a.reason || "service restart"
|
|
@@ -3289,9 +3303,9 @@ class yi extends wi {
|
|
|
3289
3303
|
}
|
|
3290
3304
|
handleMessage(t) {
|
|
3291
3305
|
try {
|
|
3292
|
-
const n = new
|
|
3306
|
+
const n = new N(new Uint8Array(t)), i = He.decode(n);
|
|
3293
3307
|
if (i.error) {
|
|
3294
|
-
h.error(`[AnimationWebSocketClient] Server error: reqId=${i.error.reqId}, code=${i.error.code}, reason=${i.error.reason}`),
|
|
3308
|
+
h.error(`[AnimationWebSocketClient] Server error: reqId=${i.error.reqId}, code=${i.error.code}, reason=${i.error.reason}`), A.logEvent("character_animation_service", "error", {
|
|
3295
3309
|
characterId: this.currentCharacterId,
|
|
3296
3310
|
event: "server_error",
|
|
3297
3311
|
reqId: i.error.reqId,
|
|
@@ -3301,7 +3315,7 @@ class yi extends wi {
|
|
|
3301
3315
|
return;
|
|
3302
3316
|
}
|
|
3303
3317
|
if (i.type === Ee.MESSAGE_ERROR) {
|
|
3304
|
-
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"),
|
|
3318
|
+
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), A.logEvent("character_animation_service", "warning", {
|
|
3305
3319
|
characterId: this.currentCharacterId,
|
|
3306
3320
|
event: "message_error_without_payload"
|
|
3307
3321
|
}), this.emit("error", new Error("Server returned error message without error details"));
|
|
@@ -3310,7 +3324,7 @@ class yi extends wi {
|
|
|
3310
3324
|
this.emit("message", i);
|
|
3311
3325
|
} catch (n) {
|
|
3312
3326
|
const i = n instanceof Error ? n.message : String(n);
|
|
3313
|
-
h.error("[AnimationWebSocketClient] Failed to decode message:", i),
|
|
3327
|
+
h.error("[AnimationWebSocketClient] Failed to decode message:", i), A.logEvent("character_animation_service", "error", {
|
|
3314
3328
|
characterId: this.currentCharacterId,
|
|
3315
3329
|
event: "decode_failed",
|
|
3316
3330
|
reason: i
|
|
@@ -3327,7 +3341,7 @@ class yi extends wi {
|
|
|
3327
3341
|
}, t);
|
|
3328
3342
|
}
|
|
3329
3343
|
}
|
|
3330
|
-
class
|
|
3344
|
+
class Si {
|
|
3331
3345
|
constructor(e) {
|
|
3332
3346
|
d(this, "wsClient");
|
|
3333
3347
|
d(this, "dataController");
|
|
@@ -3337,26 +3351,26 @@ class Ai {
|
|
|
3337
3351
|
d(this, "audioBytesPerSecond", M.audio.sampleRate * 2);
|
|
3338
3352
|
d(this, "audioMetrics", this.createAudioMetrics());
|
|
3339
3353
|
this.dataController = e;
|
|
3340
|
-
const t =
|
|
3354
|
+
const t = A.getEnvironmentConfig();
|
|
3341
3355
|
this.wsClient = new yi({
|
|
3342
3356
|
wsUrl: t.driveningressWsUrl,
|
|
3343
3357
|
reconnectAttempts: 5,
|
|
3344
3358
|
debug: !1,
|
|
3345
|
-
jwtToken:
|
|
3359
|
+
jwtToken: A.sessionToken || void 0
|
|
3346
3360
|
}), this.setupWebSocketListeners();
|
|
3347
3361
|
}
|
|
3348
3362
|
/**
|
|
3349
3363
|
* 连接服务
|
|
3350
3364
|
*/
|
|
3351
3365
|
async connect(e) {
|
|
3352
|
-
await this.wsClient.connect(e);
|
|
3366
|
+
this.setupWebSocketListeners(), await this.wsClient.connect(e);
|
|
3353
3367
|
}
|
|
3354
3368
|
/**
|
|
3355
3369
|
* 发送音频数据到服务器
|
|
3356
3370
|
*/
|
|
3357
3371
|
sendAudioData(e, t) {
|
|
3358
3372
|
var s, l;
|
|
3359
|
-
this.hasSentEnd && this.dataController.getIsPlaying() && this.currentReqId && this.dataController.interrupt(), this.currentReqId || (this.currentReqId = this.wsClient.generateReqId(), this.hasSentEnd = !1, this.resetAudioMetrics(),
|
|
3373
|
+
this.hasSentEnd && this.dataController.getIsPlaying() && this.currentReqId && this.dataController.interrupt(), this.currentReqId || (this.currentReqId = this.wsClient.generateReqId(), this.hasSentEnd = !1, this.resetAudioMetrics(), A.logEvent("character_manager", "info", {
|
|
3360
3374
|
characterId: this.dataController.getAvatarId(),
|
|
3361
3375
|
event: "conversation_started",
|
|
3362
3376
|
reqId: this.currentReqId
|
|
@@ -3366,7 +3380,7 @@ class Ai {
|
|
|
3366
3380
|
n.startTimestamp === 0 && (n.startTimestamp = Date.now(), i = !0), n.accumulatedBytes += e.byteLength;
|
|
3367
3381
|
const a = n.accumulatedBytes / this.audioBytesPerSecond;
|
|
3368
3382
|
if (a >= 2 && n.tap2Timestamp === 0 && (n.tap2Timestamp = Date.now(), i = !0), a >= 4 && n.tap4Timestamp === 0 && (n.tap4Timestamp = Date.now(), i = !0), t && n.endTimestamp === 0 && (n.endTimestamp = Date.now(), i = !0), e.byteLength === 0 && !t && h.warn("[NetworkLayer] Warning: sending empty audio data (size=0, end=false)"), !this.wsClient.sendAudioData(this.currentReqId, e, t)) {
|
|
3369
|
-
h.error("[NetworkLayer] Failed to send audio data to WebSocket"), (l = (s = this.dataController).onError) == null || l.call(s, new se("Failed to send audio data to WebSocket", "SEND_FAILED")),
|
|
3383
|
+
h.error("[NetworkLayer] Failed to send audio data to WebSocket"), (l = (s = this.dataController).onError) == null || l.call(s, new se("Failed to send audio data to WebSocket", "SEND_FAILED")), A.logEvent("character_animation_service", "error", {
|
|
3370
3384
|
characterId: this.dataController.getAvatarId(),
|
|
3371
3385
|
event: "send_audio_failed",
|
|
3372
3386
|
reqId: this.currentReqId
|
|
@@ -3397,31 +3411,31 @@ class Ai {
|
|
|
3397
3411
|
* 设置 WebSocket 事件监听器
|
|
3398
3412
|
*/
|
|
3399
3413
|
setupWebSocketListeners() {
|
|
3400
|
-
this.wsClient.on("connected",
|
|
3414
|
+
this.wsClient.on("connected", () => {
|
|
3401
3415
|
var e, t;
|
|
3402
|
-
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3416
|
+
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e, Ae.connected), A.logEvent("character_animation_service", "info", {
|
|
3403
3417
|
characterId: this.dataController.getAvatarId(),
|
|
3404
3418
|
event: "connected"
|
|
3405
3419
|
});
|
|
3406
3420
|
}), this.wsClient.on("disconnected", () => {
|
|
3407
3421
|
var e, t;
|
|
3408
|
-
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3422
|
+
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e, Ae.disconnected), A.logEvent("character_animation_service", "warning", {
|
|
3409
3423
|
characterId: this.dataController.getAvatarId(),
|
|
3410
3424
|
event: "disconnected"
|
|
3411
3425
|
});
|
|
3412
3426
|
}), this.wsClient.on("reconnecting", () => {
|
|
3413
|
-
|
|
3427
|
+
A.logEvent("character_animation_service", "info", {
|
|
3414
3428
|
characterId: this.dataController.getAvatarId(),
|
|
3415
3429
|
event: "reconnecting"
|
|
3416
3430
|
});
|
|
3417
3431
|
}), this.wsClient.on("error", (e) => {
|
|
3418
3432
|
var n, i, a, o;
|
|
3419
3433
|
const t = e instanceof Error ? e.message : String(e);
|
|
3420
|
-
h.error("[NetworkLayer] WebSocket error:", t),
|
|
3434
|
+
h.error("[NetworkLayer] WebSocket error:", t), A.logEvent("character_animation_service", "error", {
|
|
3421
3435
|
characterId: this.dataController.getAvatarId(),
|
|
3422
3436
|
event: "websocket_error",
|
|
3423
3437
|
reason: t
|
|
3424
|
-
}), (i = (n = this.dataController).onConnectionState) == null || i.call(n,
|
|
3438
|
+
}), (i = (n = this.dataController).onConnectionState) == null || i.call(n, Ae.failed), (o = (a = this.dataController).onError) == null || o.call(a, e);
|
|
3425
3439
|
}), this.wsClient.on("message", (e) => {
|
|
3426
3440
|
this.handleMessage(e);
|
|
3427
3441
|
});
|
|
@@ -3441,7 +3455,7 @@ class Ai {
|
|
|
3441
3455
|
}
|
|
3442
3456
|
} catch (t) {
|
|
3443
3457
|
const n = t instanceof Error ? t.message : String(t);
|
|
3444
|
-
h.error("[NetworkLayer] Failed to handle message:", n),
|
|
3458
|
+
h.error("[NetworkLayer] Failed to handle message:", n), A.logEvent("character_manager", "error", {
|
|
3445
3459
|
characterId: this.dataController.getAvatarId(),
|
|
3446
3460
|
event: "handle_message_failed",
|
|
3447
3461
|
reason: n
|
|
@@ -3458,7 +3472,7 @@ class Ai {
|
|
|
3458
3472
|
}
|
|
3459
3473
|
const { reqId: t, animation: n } = e.serverResponseAnimation;
|
|
3460
3474
|
if (!this.currentReqId || t !== this.currentReqId) {
|
|
3461
|
-
h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected reqId: ${this.currentReqId}, received reqId: ${t}`),
|
|
3475
|
+
h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected reqId: ${this.currentReqId}, received reqId: ${t}`), A.logEvent("character_manager", "warning", {
|
|
3462
3476
|
characterId: this.dataController.getAvatarId(),
|
|
3463
3477
|
event: "animation_reqid_mismatch",
|
|
3464
3478
|
expectedReqId: this.currentReqId,
|
|
@@ -3470,7 +3484,7 @@ class Ai {
|
|
|
3470
3484
|
const i = n.keyframes;
|
|
3471
3485
|
this.dataController.sendKeyframes(i), this.dataController.getIsPlaying() || this.dataController.startStreamingPlayback(), this.audioMetrics.didRecvFirstFlame || (this.audioMetrics.didRecvFirstFlame = !0, this.audioMetrics.recvFirstFlameTimestamp = Date.now(), this.currentReqId && this.reportAudioMetrics(this.currentReqId));
|
|
3472
3486
|
} else
|
|
3473
|
-
h.warn(`[NetworkLayer] Animation message has no keyframes - reqId: ${t}`),
|
|
3487
|
+
h.warn(`[NetworkLayer] Animation message has no keyframes - reqId: ${t}`), A.logEvent("character_manager", "warning", {
|
|
3474
3488
|
characterId: this.dataController.getAvatarId(),
|
|
3475
3489
|
event: "animation_empty_keyframes",
|
|
3476
3490
|
reqId: t
|
|
@@ -3482,13 +3496,13 @@ class Ai {
|
|
|
3482
3496
|
handleErrorMessage(e) {
|
|
3483
3497
|
var n, i, a, o;
|
|
3484
3498
|
if (!e.error) {
|
|
3485
|
-
h.warn("[NetworkLayer] MESSAGE_ERROR received but message.error is empty"), e.serverResponseAnimation && (h.warn("[NetworkLayer] MESSAGE_ERROR contains animation data, treating as animation message"),
|
|
3499
|
+
h.warn("[NetworkLayer] MESSAGE_ERROR received but message.error is empty"), e.serverResponseAnimation && (h.warn("[NetworkLayer] MESSAGE_ERROR contains animation data, treating as animation message"), A.logEvent("character_manager", "warning", {
|
|
3486
3500
|
characterId: this.dataController.getAvatarId(),
|
|
3487
3501
|
event: "message_error_with_payload"
|
|
3488
3502
|
}), this.handleAnimationMessage(e));
|
|
3489
3503
|
return;
|
|
3490
3504
|
}
|
|
3491
|
-
h.error(`[NetworkLayer] Server error: reqId=${e.error.reqId}, code=${e.error.code}, reason=${e.error.reason}`),
|
|
3505
|
+
h.error(`[NetworkLayer] Server error: reqId=${e.error.reqId}, code=${e.error.code}, reason=${e.error.reason}`), A.logEvent("character_manager", "error", {
|
|
3492
3506
|
characterId: this.dataController.getAvatarId(),
|
|
3493
3507
|
event: "server_error",
|
|
3494
3508
|
reqId: e.error.reqId,
|
|
@@ -3496,7 +3510,7 @@ class Ai {
|
|
|
3496
3510
|
reason: e.error.reason
|
|
3497
3511
|
});
|
|
3498
3512
|
const t = ((n = e.error.code) == null ? void 0 : n.toString().toLowerCase()) ?? "";
|
|
3499
|
-
(t.includes("unauth") || t === "401") &&
|
|
3513
|
+
(t.includes("unauth") || t === "401") && A.logEvent("sdk_verify", "error", {
|
|
3500
3514
|
characterId: this.dataController.getAvatarId(),
|
|
3501
3515
|
reqId: e.error.reqId,
|
|
3502
3516
|
reason: e.error.reason
|
|
@@ -3529,7 +3543,7 @@ class Ai {
|
|
|
3529
3543
|
* 上报音频指标
|
|
3530
3544
|
*/
|
|
3531
3545
|
reportAudioMetrics(e) {
|
|
3532
|
-
!e || this.audioMetrics.startTimestamp === 0 ||
|
|
3546
|
+
!e || this.audioMetrics.startTimestamp === 0 || A.logEvent("send_audio_measure", "info", {
|
|
3533
3547
|
reqId: e,
|
|
3534
3548
|
start: this.audioMetrics.startTimestamp,
|
|
3535
3549
|
tap2: this.audioMetrics.tap2Timestamp,
|
|
@@ -3539,7 +3553,7 @@ class Ai {
|
|
|
3539
3553
|
});
|
|
3540
3554
|
}
|
|
3541
3555
|
}
|
|
3542
|
-
class
|
|
3556
|
+
class Ai {
|
|
3543
3557
|
constructor(e, t) {
|
|
3544
3558
|
// ========== Configuration and Composition ==========
|
|
3545
3559
|
d(this, "networkLayer");
|
|
@@ -3552,7 +3566,7 @@ class Si {
|
|
|
3552
3566
|
d(this, "isPlaying", !1);
|
|
3553
3567
|
// ========== State Management ==========
|
|
3554
3568
|
d(this, "isConnected", !1);
|
|
3555
|
-
d(this, "currentState",
|
|
3569
|
+
d(this, "currentState", T.idle);
|
|
3556
3570
|
// ========== Event System ==========
|
|
3557
3571
|
d(this, "onConnectionState", null);
|
|
3558
3572
|
d(this, "onAvatarState", null);
|
|
@@ -3564,54 +3578,54 @@ class Si {
|
|
|
3564
3578
|
// ========== Playback Loop ==========
|
|
3565
3579
|
d(this, "playbackLoopId", null);
|
|
3566
3580
|
d(this, "lastRenderedFrameIndex", -1);
|
|
3567
|
-
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? ke.network, this.playbackMode === ke.network && (this.networkLayer = new
|
|
3581
|
+
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? ke.network, this.playbackMode === ke.network && (this.networkLayer = new Si(this));
|
|
3568
3582
|
}
|
|
3569
|
-
// ==========
|
|
3583
|
+
// ========== Internal Accessors (for NetworkLayer and AvatarView) ==========
|
|
3570
3584
|
/**
|
|
3571
|
-
*
|
|
3585
|
+
* Get Avatar ID (for NetworkLayer use)
|
|
3572
3586
|
* @internal
|
|
3573
3587
|
*/
|
|
3574
3588
|
getAvatarId() {
|
|
3575
3589
|
return this.avatar.id;
|
|
3576
3590
|
}
|
|
3577
3591
|
/**
|
|
3578
|
-
*
|
|
3592
|
+
* Get playback state (for NetworkLayer use)
|
|
3579
3593
|
* @internal
|
|
3580
3594
|
*/
|
|
3581
3595
|
getIsPlaying() {
|
|
3582
3596
|
return this.isPlaying;
|
|
3583
3597
|
}
|
|
3584
3598
|
/**
|
|
3585
|
-
*
|
|
3599
|
+
* Set connection state (for NetworkLayer use)
|
|
3586
3600
|
* @internal
|
|
3587
3601
|
*/
|
|
3588
3602
|
setConnected(e) {
|
|
3589
3603
|
this.isConnected = e;
|
|
3590
3604
|
}
|
|
3591
3605
|
/**
|
|
3592
|
-
*
|
|
3606
|
+
* Get connection state
|
|
3593
3607
|
* @internal
|
|
3594
3608
|
*/
|
|
3595
3609
|
get connected() {
|
|
3596
3610
|
return this.isConnected;
|
|
3597
3611
|
}
|
|
3598
3612
|
/**
|
|
3599
|
-
*
|
|
3613
|
+
* Get current state
|
|
3600
3614
|
* @internal
|
|
3601
3615
|
*/
|
|
3602
3616
|
get state() {
|
|
3603
3617
|
return this.currentState;
|
|
3604
3618
|
}
|
|
3605
3619
|
/**
|
|
3606
|
-
*
|
|
3620
|
+
* Get animation player instance
|
|
3607
3621
|
* @internal
|
|
3608
3622
|
*/
|
|
3609
3623
|
getAnimationPlayer() {
|
|
3610
3624
|
return this.animationPlayer;
|
|
3611
3625
|
}
|
|
3612
|
-
// ==========
|
|
3626
|
+
// ========== Network Mode Interface ==========
|
|
3613
3627
|
/**
|
|
3614
|
-
*
|
|
3628
|
+
* Start service (network mode only)
|
|
3615
3629
|
*/
|
|
3616
3630
|
async start() {
|
|
3617
3631
|
if (!this.networkLayer)
|
|
@@ -3625,7 +3639,7 @@ class Si {
|
|
|
3625
3639
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
3626
3640
|
} catch (e) {
|
|
3627
3641
|
const t = e instanceof Error ? e.message : String(e);
|
|
3628
|
-
throw h.error("[AvatarController] Failed to create streaming player:", t),
|
|
3642
|
+
throw h.error("[AvatarController] Failed to create streaming player:", t), A.logEvent("character_player", "error", {
|
|
3629
3643
|
characterId: this.avatar.id,
|
|
3630
3644
|
event: "streaming_player_init_failed",
|
|
3631
3645
|
reason: t
|
|
@@ -3635,31 +3649,31 @@ class Si {
|
|
|
3635
3649
|
await this.networkLayer.connect(this.avatar.id);
|
|
3636
3650
|
}
|
|
3637
3651
|
/**
|
|
3638
|
-
*
|
|
3639
|
-
*
|
|
3652
|
+
* Send audio to server (network mode only)
|
|
3653
|
+
* Also cache to data layer for playback
|
|
3640
3654
|
*/
|
|
3641
3655
|
send(e, t = !1) {
|
|
3642
3656
|
var n, i;
|
|
3643
3657
|
if (!this.networkLayer || !this.isConnected) {
|
|
3644
|
-
(n = this.onError) == null || n.call(this, new se("Service not connected", "NOT_CONNECTED")),
|
|
3658
|
+
(n = this.onError) == null || n.call(this, new se("Service not connected", "NOT_CONNECTED")), A.logEvent("character_manager", "warning", {
|
|
3645
3659
|
characterId: this.avatar.id,
|
|
3646
3660
|
event: "send_not_connected"
|
|
3647
3661
|
});
|
|
3648
3662
|
return;
|
|
3649
3663
|
}
|
|
3650
|
-
this.networkLayer.sendAudioData(e, t), this.addAudioChunkToBuffer(new Uint8Array(e), t), (i = this.onAvatarState) == null || i.call(this,
|
|
3664
|
+
this.networkLayer.sendAudioData(e, t), this.addAudioChunkToBuffer(new Uint8Array(e), t), (i = this.onAvatarState) == null || i.call(this, T.active);
|
|
3651
3665
|
}
|
|
3652
3666
|
/**
|
|
3653
|
-
*
|
|
3667
|
+
* Close service (network mode only)
|
|
3654
3668
|
*/
|
|
3655
3669
|
close() {
|
|
3656
3670
|
var e, t;
|
|
3657
|
-
this.isPlaying && this.stopPlayback(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, (e = this.networkLayer) == null || e.disconnect(), this.isConnected = !1, (t = this.onConnectionState) == null || t.call(this,
|
|
3671
|
+
(this.isPlaying || this.currentState === T.paused) && this.stopPlayback(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, (e = this.networkLayer) == null || e.disconnect(), this.isConnected = !1, (t = this.onConnectionState) == null || t.call(this, Ae.disconnected);
|
|
3658
3672
|
}
|
|
3659
|
-
// ==========
|
|
3673
|
+
// ========== External Data Mode Interface ==========
|
|
3660
3674
|
/**
|
|
3661
|
-
*
|
|
3662
|
-
*
|
|
3675
|
+
* Start playback (external data mode)
|
|
3676
|
+
* Must call this method first with initial data to start playback
|
|
3663
3677
|
*/
|
|
3664
3678
|
async play(e, t) {
|
|
3665
3679
|
if (!this.isPlaying) {
|
|
@@ -3671,67 +3685,93 @@ class Si {
|
|
|
3671
3685
|
}
|
|
3672
3686
|
}
|
|
3673
3687
|
/**
|
|
3674
|
-
*
|
|
3675
|
-
*
|
|
3688
|
+
* Send audio data (external data mode)
|
|
3689
|
+
* Stream additional audio data after play()
|
|
3676
3690
|
*/
|
|
3677
3691
|
sendAudioChunk(e, t = !1) {
|
|
3678
3692
|
var n, i;
|
|
3679
|
-
this.isPlaying && ((n = this.animationPlayer) != null && n.isStreamingReady()) ? this.animationPlayer.addAudioChunk(e, t) : (e.length > 0 || t) && (this.pendingAudioChunks.push({ data: e, isLast: t }), (i = this.onAvatarState) == null || i.call(this,
|
|
3693
|
+
this.isPlaying && ((n = this.animationPlayer) != null && n.isStreamingReady()) ? this.animationPlayer.addAudioChunk(e, t) : (e.length > 0 || t) && (this.pendingAudioChunks.push({ data: e, isLast: t }), (i = this.onAvatarState) == null || i.call(this, T.active));
|
|
3680
3694
|
}
|
|
3681
3695
|
/**
|
|
3682
|
-
*
|
|
3683
|
-
*
|
|
3696
|
+
* Send animation keyframes (external data mode or network mode)
|
|
3697
|
+
* Stream additional animation data after play()
|
|
3684
3698
|
*/
|
|
3685
3699
|
sendKeyframes(e) {
|
|
3686
3700
|
this.currentKeyframes.length === 0 ? this.currentKeyframes = e : this.currentKeyframes.push(...e), this.emit("keyframesUpdate", this.currentKeyframes);
|
|
3687
3701
|
}
|
|
3688
|
-
// ==========
|
|
3702
|
+
// ========== Common Interface ==========
|
|
3689
3703
|
/**
|
|
3690
|
-
*
|
|
3704
|
+
* Pause playback (can be resumed later)
|
|
3705
|
+
* Pause audio playback and stop render loop, but preserve all state (keyframes, audio buffers, etc.)
|
|
3706
|
+
*/
|
|
3707
|
+
pause() {
|
|
3708
|
+
var e, t, n;
|
|
3709
|
+
!this.isPlaying || this.currentState === T.paused || (h.log("[AvatarController] Pausing playback"), (e = this.animationPlayer) == null || e.pause(), this.stopPlaybackLoop(), this.currentState = T.paused, (t = this.onAvatarState) == null || t.call(this, T.paused), h.log("[AvatarController] Playback paused"), A.logEvent("character_player", "info", {
|
|
3710
|
+
characterId: this.avatar.id,
|
|
3711
|
+
event: "playback_paused",
|
|
3712
|
+
reqId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentReqId()) || void 0
|
|
3713
|
+
}));
|
|
3714
|
+
}
|
|
3715
|
+
/**
|
|
3716
|
+
* Resume playback (from paused state)
|
|
3717
|
+
* Resume audio playback and restart render loop
|
|
3718
|
+
* Animation will continue from paused frame (because animation time base comes from audio, will auto-sync)
|
|
3719
|
+
*/
|
|
3720
|
+
async resume() {
|
|
3721
|
+
var e, t, n;
|
|
3722
|
+
!this.isPlaying || this.currentState !== T.paused || (h.log("[AvatarController] Resuming playback"), await ((e = this.animationPlayer) == null ? void 0 : e.resume()), this.startPlaybackLoop(), this.currentState = T.playing, (t = this.onAvatarState) == null || t.call(this, T.playing), h.log("[AvatarController] Playback resumed"), A.logEvent("character_player", "info", {
|
|
3723
|
+
characterId: this.avatar.id,
|
|
3724
|
+
event: "playback_resumed",
|
|
3725
|
+
reqId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentReqId()) || void 0
|
|
3726
|
+
}));
|
|
3727
|
+
}
|
|
3728
|
+
/**
|
|
3729
|
+
* Interrupt current playback
|
|
3691
3730
|
*/
|
|
3692
3731
|
interrupt() {
|
|
3693
3732
|
var e;
|
|
3694
|
-
this.
|
|
3733
|
+
this.currentState === T.paused && ((e = this.animationPlayer) == null || e.resume().catch(() => {
|
|
3734
|
+
})), this.stopPlayback(), this.emit("interrupt"), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.networkLayer && this.networkLayer.resetReqId();
|
|
3695
3735
|
}
|
|
3696
3736
|
/**
|
|
3697
|
-
*
|
|
3737
|
+
* Clear all data and resources
|
|
3698
3738
|
*/
|
|
3699
3739
|
clear() {
|
|
3700
3740
|
var e, t;
|
|
3701
|
-
this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.isConnected = !1, (t = this.onAvatarState) == null || t.call(this,
|
|
3741
|
+
this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.isConnected = !1, this.currentState = T.idle, (t = this.onAvatarState) == null || t.call(this, T.idle);
|
|
3702
3742
|
}
|
|
3703
3743
|
/**
|
|
3704
|
-
*
|
|
3705
|
-
*
|
|
3744
|
+
* Dispose controller, clean up all callbacks to avoid memory leaks
|
|
3745
|
+
* Should be called when AvatarView.dispose()
|
|
3706
3746
|
* @internal
|
|
3707
3747
|
*/
|
|
3708
3748
|
dispose() {
|
|
3709
3749
|
this.onConnectionState = null, this.onAvatarState = null, this.onError = null, this.renderCallback = void 0, this.transitionCompleteCallback = void 0, this.eventListeners.clear();
|
|
3710
3750
|
}
|
|
3711
|
-
// ==========
|
|
3751
|
+
// ========== Internal Methods (for NetworkLayer and AvatarView use) ==========
|
|
3712
3752
|
/**
|
|
3713
|
-
*
|
|
3753
|
+
* Start streaming playback (internal method, called by NetworkLayer or play())
|
|
3714
3754
|
* @internal
|
|
3715
3755
|
*/
|
|
3716
3756
|
startStreamingPlayback() {
|
|
3717
3757
|
return this.startStreamingPlaybackInternal();
|
|
3718
3758
|
}
|
|
3719
3759
|
/**
|
|
3720
|
-
*
|
|
3760
|
+
* Set render callback (called by AvatarView)
|
|
3721
3761
|
* @internal
|
|
3722
3762
|
*/
|
|
3723
3763
|
setRenderCallback(e) {
|
|
3724
3764
|
this.renderCallback = e;
|
|
3725
3765
|
}
|
|
3726
3766
|
/**
|
|
3727
|
-
*
|
|
3767
|
+
* Set transition complete callback (called by AvatarView)
|
|
3728
3768
|
* @internal
|
|
3729
3769
|
*/
|
|
3730
3770
|
setTransitionCompleteCallback(e) {
|
|
3731
3771
|
this.transitionCompleteCallback = e;
|
|
3732
3772
|
}
|
|
3733
3773
|
/**
|
|
3734
|
-
*
|
|
3774
|
+
* Transition complete notification (called by AvatarView)
|
|
3735
3775
|
* @internal
|
|
3736
3776
|
*/
|
|
3737
3777
|
onTransitionComplete() {
|
|
@@ -3740,15 +3780,15 @@ class Si {
|
|
|
3740
3780
|
e && e.play();
|
|
3741
3781
|
}
|
|
3742
3782
|
/**
|
|
3743
|
-
*
|
|
3783
|
+
* Provide interface for AvatarView to register internal events
|
|
3744
3784
|
* @internal
|
|
3745
3785
|
*/
|
|
3746
3786
|
setupInternalEventListeners(e) {
|
|
3747
3787
|
e.onKeyframesUpdate && this.registerEventListener("keyframesUpdate", e.onKeyframesUpdate), e.onStartRendering && this.registerEventListener("startRendering", e.onStartRendering), e.onStopRendering && this.registerEventListener("stopRendering", e.onStopRendering), e.onInterrupt && this.registerEventListener("interrupt", e.onInterrupt);
|
|
3748
3788
|
}
|
|
3749
|
-
// ==========
|
|
3789
|
+
// ========== Private Methods ==========
|
|
3750
3790
|
/**
|
|
3751
|
-
*
|
|
3791
|
+
* Start streaming playback (internal implementation)
|
|
3752
3792
|
*/
|
|
3753
3793
|
async startStreamingPlaybackInternal() {
|
|
3754
3794
|
var e, t, n;
|
|
@@ -3763,14 +3803,14 @@ class Si {
|
|
|
3763
3803
|
try {
|
|
3764
3804
|
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
3765
3805
|
var a, o;
|
|
3766
|
-
this.isPlaying = !1, (a = this.onAvatarState) == null || a.call(this,
|
|
3806
|
+
this.isPlaying = !1, this.currentState = T.idle, (a = this.onAvatarState) == null || a.call(this, T.idle), this.emit("stopRendering"), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.networkLayer && this.networkLayer.resetReqId(), A.logEvent("character_player", "info", {
|
|
3767
3807
|
characterId: this.avatar.id,
|
|
3768
3808
|
event: "playback_ended",
|
|
3769
3809
|
reqId: ((o = this.networkLayer) == null ? void 0 : o.getCurrentReqId()) || void 0
|
|
3770
3810
|
});
|
|
3771
3811
|
}), this.emit("startRendering");
|
|
3772
3812
|
const i = this.animationPlayer.getStreamingPlayer();
|
|
3773
|
-
i && i.setAutoStart(!1), i && await i.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, (e = this.onAvatarState) == null || e.call(this,
|
|
3813
|
+
i && i.setAutoStart(!1), i && await i.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = T.playing, (e = this.onAvatarState) == null || e.call(this, T.playing), this.startPlaybackLoop(), A.logEvent("character_player", "info", {
|
|
3774
3814
|
characterId: this.avatar.id,
|
|
3775
3815
|
event: "playback_started",
|
|
3776
3816
|
reqId: ((t = this.networkLayer) == null ? void 0 : t.getCurrentReqId()) || void 0
|
|
@@ -3781,13 +3821,13 @@ class Si {
|
|
|
3781
3821
|
}
|
|
3782
3822
|
}
|
|
3783
3823
|
/**
|
|
3784
|
-
*
|
|
3824
|
+
* Playback loop: Calculate animation frame based on audio time, notify render layer to render
|
|
3785
3825
|
*/
|
|
3786
3826
|
startPlaybackLoop() {
|
|
3787
3827
|
if (this.playbackLoopId)
|
|
3788
3828
|
return;
|
|
3789
3829
|
const e = M.animation.fps, t = async () => {
|
|
3790
|
-
if (!this.isPlaying || !this.animationPlayer) {
|
|
3830
|
+
if (!this.isPlaying || this.currentState === T.paused || !this.animationPlayer) {
|
|
3791
3831
|
this.playbackLoopId = null;
|
|
3792
3832
|
return;
|
|
3793
3833
|
}
|
|
@@ -3803,7 +3843,7 @@ class Si {
|
|
|
3803
3843
|
return;
|
|
3804
3844
|
}
|
|
3805
3845
|
if (this.lastRenderedFrameIndex = i, i >= 0 && i < this.currentKeyframes.length) {
|
|
3806
|
-
const a = this.currentKeyframes[i], o = Vt(a), s =
|
|
3846
|
+
const a = this.currentKeyframes[i], o = Vt(a), s = A.getAvatarCore();
|
|
3807
3847
|
if (s) {
|
|
3808
3848
|
const l = await s.computeFrameFlatFromParams(o);
|
|
3809
3849
|
l && this.renderCallback && this.renderCallback(l, i);
|
|
@@ -3818,13 +3858,13 @@ class Si {
|
|
|
3818
3858
|
this.playbackLoopId = requestAnimationFrame(t);
|
|
3819
3859
|
}
|
|
3820
3860
|
/**
|
|
3821
|
-
*
|
|
3861
|
+
* Stop playback loop
|
|
3822
3862
|
*/
|
|
3823
3863
|
stopPlaybackLoop() {
|
|
3824
3864
|
this.playbackLoopId && (cancelAnimationFrame(this.playbackLoopId), this.playbackLoopId = null);
|
|
3825
3865
|
}
|
|
3826
3866
|
/**
|
|
3827
|
-
*
|
|
3867
|
+
* Stop playback
|
|
3828
3868
|
*/
|
|
3829
3869
|
stopPlayback() {
|
|
3830
3870
|
var e;
|
|
@@ -3833,28 +3873,28 @@ class Si {
|
|
|
3833
3873
|
const t = this.animationPlayer.getStreamingPlayer();
|
|
3834
3874
|
t == null || t.stop();
|
|
3835
3875
|
}
|
|
3836
|
-
this.emit("stopRendering"), this.isPlaying = !1, (e = this.onAvatarState) == null || e.call(this,
|
|
3876
|
+
this.emit("stopRendering"), this.isPlaying = !1, this.currentState = T.idle, (e = this.onAvatarState) == null || e.call(this, T.idle);
|
|
3837
3877
|
}
|
|
3838
3878
|
/**
|
|
3839
|
-
*
|
|
3879
|
+
* Clean up players
|
|
3840
3880
|
*/
|
|
3841
3881
|
cleanupPlayers() {
|
|
3842
3882
|
this.animationPlayer && (this.animationPlayer.dispose(), this.animationPlayer = null);
|
|
3843
3883
|
}
|
|
3844
3884
|
/**
|
|
3845
|
-
*
|
|
3885
|
+
* Add audio chunk to buffer
|
|
3846
3886
|
*/
|
|
3847
3887
|
addAudioChunkToBuffer(e, t) {
|
|
3848
3888
|
this.animationPlayer || (this.animationPlayer = new be()), this.isPlaying && this.animationPlayer.isStreamingReady() ? this.animationPlayer.addAudioChunk(e, t) : this.pendingAudioChunks.push({ data: e, isLast: t });
|
|
3849
3889
|
}
|
|
3850
3890
|
/**
|
|
3851
|
-
*
|
|
3891
|
+
* Event system
|
|
3852
3892
|
*/
|
|
3853
3893
|
registerEventListener(e, t) {
|
|
3854
3894
|
this.eventListeners.has(e) || this.eventListeners.set(e, /* @__PURE__ */ new Set()), this.eventListeners.get(e).add(t);
|
|
3855
3895
|
}
|
|
3856
3896
|
/**
|
|
3857
|
-
*
|
|
3897
|
+
* Emit event
|
|
3858
3898
|
*/
|
|
3859
3899
|
emit(e, t) {
|
|
3860
3900
|
const n = this.eventListeners.get(e);
|
|
@@ -3938,12 +3978,12 @@ class Ci {
|
|
|
3938
3978
|
total: a,
|
|
3939
3979
|
progress: Math.round(o / a * 100)
|
|
3940
3980
|
}));
|
|
3941
|
-
}, l = {}, g = Object.entries(i).map(async ([w, { url: y, resourceName:
|
|
3981
|
+
}, l = {}, g = Object.entries(i).map(async ([w, { url: y, resourceName: b }]) => {
|
|
3942
3982
|
if (!y)
|
|
3943
|
-
throw new Error(`[loadTemplateResources] Missing CDN URL for ${w} (${
|
|
3944
|
-
s(
|
|
3983
|
+
throw new Error(`[loadTemplateResources] Missing CDN URL for ${w} (${b})`);
|
|
3984
|
+
s(b, !1), h.log(`📥 Loading ${w} from API CDN: ${y}`);
|
|
3945
3985
|
const x = await $e(y);
|
|
3946
|
-
h.log(`✅ ${w} loaded: ${x.byteLength} bytes`), l[w] = x, s(
|
|
3986
|
+
h.log(`✅ ${w} loaded: ${x.byteLength} bytes`), l[w] = x, s(b, !0);
|
|
3947
3987
|
});
|
|
3948
3988
|
return await Promise.all(g), l;
|
|
3949
3989
|
}
|
|
@@ -4012,15 +4052,15 @@ class Ci {
|
|
|
4012
4052
|
* Load character data from CharacterMeta (iOS compatible)
|
|
4013
4053
|
*/
|
|
4014
4054
|
async loadCharacterData(e, t) {
|
|
4015
|
-
var
|
|
4016
|
-
const { loadMonologue: n = !1, progressCallback: i = null } = t || {}, a = (L = (x = (
|
|
4055
|
+
var b, x, L, _, Y, G, U, j, X, J, re, z, we, de, ne;
|
|
4056
|
+
const { loadMonologue: n = !1, progressCallback: i = null } = t || {}, a = (L = (x = (b = e.models) == null ? void 0 : b.shape) == null ? void 0 : x.resource) == null ? void 0 : L.remote, o = (G = (Y = (_ = e.models) == null ? void 0 : _.gsStandard) == null ? void 0 : Y.resource) == null ? void 0 : G.remote, s = (X = (j = (U = e.animations) == null ? void 0 : U.frameIdle) == null ? void 0 : j.resource) == null ? void 0 : X.remote, l = (z = (re = (J = e.animations) == null ? void 0 : J.frameMono) == null ? void 0 : re.resource) == null ? void 0 : z.remote, g = (ne = (de = (we = e.animations) == null ? void 0 : we.audioMono) == null ? void 0 : de.resource) == null ? void 0 : ne.remote;
|
|
4017
4057
|
if (!a || !o) {
|
|
4018
|
-
const
|
|
4019
|
-
throw
|
|
4058
|
+
const B = "Missing required resources: shape or gsStandard (point cloud)";
|
|
4059
|
+
throw A.logEvent("character_load", "error", {
|
|
4020
4060
|
characterId: e.characterId ?? "unknown",
|
|
4021
4061
|
stage: "resource_validation",
|
|
4022
|
-
reason:
|
|
4023
|
-
}), new Error(
|
|
4062
|
+
reason: B
|
|
4063
|
+
}), new Error(B);
|
|
4024
4064
|
}
|
|
4025
4065
|
const c = [
|
|
4026
4066
|
{ key: "shape", url: a, filename: "shape.pb" },
|
|
@@ -4028,32 +4068,32 @@ class Ci {
|
|
|
4028
4068
|
];
|
|
4029
4069
|
s && c.push({ key: "idleAnimation", url: s, filename: "idle.pb", optional: !0 }), n && l ? (h.log("📥 Loading monologue animation (enabled by option)"), c.push({ key: "monoAnimation", url: l, filename: "mono.pb", optional: !0 })) : !n && l && h.log("⏭️ Skipping monologue animation (disabled by option)");
|
|
4030
4070
|
let u = 0;
|
|
4031
|
-
const m = c.length, v = (
|
|
4032
|
-
i && (
|
|
4071
|
+
const m = c.length, v = (B, V) => {
|
|
4072
|
+
i && (V && u++, i({
|
|
4033
4073
|
stage: "character",
|
|
4034
|
-
filename:
|
|
4074
|
+
filename: B,
|
|
4035
4075
|
loaded: u,
|
|
4036
4076
|
total: m,
|
|
4037
4077
|
progress: Math.round(u / m * 100)
|
|
4038
4078
|
}));
|
|
4039
|
-
}, w = {}, y = c.map(async ({ key:
|
|
4079
|
+
}, w = {}, y = c.map(async ({ key: B, url: V, filename: ie, optional: Le }) => {
|
|
4040
4080
|
v(ie, !1);
|
|
4041
4081
|
try {
|
|
4042
|
-
const
|
|
4043
|
-
return
|
|
4044
|
-
} catch (
|
|
4082
|
+
const q = await $e(V);
|
|
4083
|
+
return B === "shape" ? w.shape = q : B === "pointCloud" ? w.pointCloud = q : B === "idleAnimation" ? w.idleAnimation = q : B === "monoAnimation" && (w.monoAnimation = q), this.characterAssets.set(B, q), v(ie, !0), { key: B, success: !0 };
|
|
4084
|
+
} catch (q) {
|
|
4045
4085
|
if (!Le)
|
|
4046
|
-
throw
|
|
4047
|
-
return h.warn(`⚠️ Optional resource ${ie} failed to load:`,
|
|
4086
|
+
throw q;
|
|
4087
|
+
return h.warn(`⚠️ Optional resource ${ie} failed to load:`, q), v(ie, !0), { key: B, success: !1 };
|
|
4048
4088
|
}
|
|
4049
4089
|
});
|
|
4050
4090
|
if (await Promise.all(y), n && g && (w.monoAudioUrl = g), !w.shape || !w.pointCloud) {
|
|
4051
|
-
const
|
|
4052
|
-
throw
|
|
4091
|
+
const B = "Failed to load character data";
|
|
4092
|
+
throw A.logEvent("character_load", "error", {
|
|
4053
4093
|
characterId: e.characterId ?? "unknown",
|
|
4054
4094
|
stage: "download",
|
|
4055
|
-
reason:
|
|
4056
|
-
}), new Error(
|
|
4095
|
+
reason: B
|
|
4096
|
+
}), new Error(B);
|
|
4057
4097
|
}
|
|
4058
4098
|
return w;
|
|
4059
4099
|
}
|
|
@@ -4106,7 +4146,7 @@ class Ci {
|
|
|
4106
4146
|
getSdkApiClient() {
|
|
4107
4147
|
return {
|
|
4108
4148
|
async request(e, t = {}) {
|
|
4109
|
-
const a =
|
|
4149
|
+
const a = A.getEnvironmentConfig().sdkApiBaseUrl + e;
|
|
4110
4150
|
try {
|
|
4111
4151
|
const o = await fetch(a, {
|
|
4112
4152
|
method: t.method || "GET",
|
|
@@ -4141,7 +4181,7 @@ class Ci {
|
|
|
4141
4181
|
} catch (n) {
|
|
4142
4182
|
h.errorWithError("Failed to fetch character:", n);
|
|
4143
4183
|
const i = n && typeof n == "object" && "message" in n ? String(n.message) : "Failed to fetch character", a = n && typeof n == "object" && "data" in n && typeof n.data == "object" && ((t = n.data) != null && t.message) ? String(n.data.message) : null;
|
|
4144
|
-
throw
|
|
4184
|
+
throw A.logEvent("character_load", "error", {
|
|
4145
4185
|
characterId: e ?? "unknown",
|
|
4146
4186
|
stage: "fetch",
|
|
4147
4187
|
reason: a || i
|
|
@@ -4170,7 +4210,7 @@ const Re = class Re {
|
|
|
4170
4210
|
async load(e, t, n) {
|
|
4171
4211
|
h.log(`[AvatarManager] Loading avatar with id: ${e}`);
|
|
4172
4212
|
try {
|
|
4173
|
-
if (!
|
|
4213
|
+
if (!A.isInitialized)
|
|
4174
4214
|
throw new Error("AvatarKit not initialized. Please call AvatarKit.initialize() first.");
|
|
4175
4215
|
this.avatarDownloader || (this.avatarDownloader = new Ci()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: oe.downloading, progress: 10 });
|
|
4176
4216
|
const i = await this.avatarDownloader.getCharacterById(e);
|
|
@@ -4184,18 +4224,18 @@ const Re = class Re {
|
|
|
4184
4224
|
progress: Math.round(g)
|
|
4185
4225
|
});
|
|
4186
4226
|
}
|
|
4187
|
-
}), o =
|
|
4227
|
+
}), o = A.getAvatarCore();
|
|
4188
4228
|
if (!o)
|
|
4189
4229
|
throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
|
|
4190
4230
|
this._templateInitialized ? h.log("[AvatarManager] WASM Core template resources already initialized, skipping...") : (h.log("[AvatarManager] Step 3: Initializing WASM Core template resources (first time)..."), t == null || t({ type: oe.downloading, progress: 80 }), await o.loadTemplateResourcesFromBuffers(a.templateResources), this._templateInitialized = !0, h.log("[AvatarManager] WASM Core template resources initialized successfully")), h.log("[AvatarManager] Step 4: Creating Avatar instance...");
|
|
4191
4231
|
const s = new rn(e, i, a);
|
|
4192
|
-
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: oe.completed }),
|
|
4232
|
+
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: oe.completed }), A.logEvent("character_load", "info", {
|
|
4193
4233
|
characterId: e,
|
|
4194
4234
|
event: "load_success"
|
|
4195
4235
|
}), s;
|
|
4196
4236
|
} catch (i) {
|
|
4197
4237
|
const a = i instanceof Error ? i.message : String(i);
|
|
4198
|
-
throw h.error("Failed to load avatar:", a),
|
|
4238
|
+
throw h.error("Failed to load avatar:", a), A.logEvent("character_load", "error", {
|
|
4199
4239
|
characterId: e,
|
|
4200
4240
|
reason: a
|
|
4201
4241
|
}), t == null || t({ type: oe.failed, error: i }), i;
|
|
@@ -4214,10 +4254,10 @@ const Ye = 2048, zt = Ye - 1;
|
|
|
4214
4254
|
function _i(r, e, t) {
|
|
4215
4255
|
const i = r.length / 13;
|
|
4216
4256
|
(!ye || ye.length !== i) && (ye = new Float32Array(i), Bt = new Uint32Array(ye.buffer), Dt = new Uint32Array(i), Ot = new Uint32Array(i), Nt = new Uint32Array(i), Ut = new Uint32Array(Ye));
|
|
4217
|
-
const a = ye, o = Bt, s = Dt, l = Ot, g = Nt, c = Ut, u = e[0], m = e[1], v = e[2], w = t[0], y = t[1],
|
|
4257
|
+
const a = ye, o = Bt, s = Dt, l = Ot, g = Nt, c = Ut, u = e[0], m = e[1], v = e[2], w = t[0], y = t[1], b = t[2];
|
|
4218
4258
|
for (let x = 0; x < i; x++) {
|
|
4219
4259
|
const L = x * 13;
|
|
4220
|
-
a[x] = (r[L] - u) * w + (r[L + 1] - m) * y + (r[L + 2] - v) *
|
|
4260
|
+
a[x] = (r[L] - u) * w + (r[L + 1] - m) * y + (r[L + 2] - v) * b, s[x] = x;
|
|
4221
4261
|
}
|
|
4222
4262
|
for (let x = 0; x < i; x++) {
|
|
4223
4263
|
const L = o[x];
|
|
@@ -4245,16 +4285,16 @@ function qe(r, e, t, n, i, a) {
|
|
|
4245
4285
|
}
|
|
4246
4286
|
}
|
|
4247
4287
|
const Pe = 13;
|
|
4248
|
-
let
|
|
4288
|
+
let Se = null;
|
|
4249
4289
|
function Ei(r, e) {
|
|
4250
4290
|
const t = e.length, n = t * Pe;
|
|
4251
|
-
(!
|
|
4291
|
+
(!Se || Se.length !== n) && (Se = new Float32Array(n));
|
|
4252
4292
|
for (let i = 0; i < t; i++) {
|
|
4253
4293
|
const o = e[i] * Pe, s = i * Pe;
|
|
4254
4294
|
for (let l = 0; l < Pe; l++)
|
|
4255
|
-
|
|
4295
|
+
Se[s + l] = r[o + l];
|
|
4256
4296
|
}
|
|
4257
|
-
return
|
|
4297
|
+
return Se;
|
|
4258
4298
|
}
|
|
4259
4299
|
const xi = `#version 300 es
|
|
4260
4300
|
precision highp float;
|
|
@@ -5459,7 +5499,7 @@ class Ni {
|
|
|
5459
5499
|
d(this, "idleCurrentFrameIndex", 0);
|
|
5460
5500
|
this.avatar = e;
|
|
5461
5501
|
const n = (t == null ? void 0 : t.playbackMode) ?? ke.network;
|
|
5462
|
-
this.playbackMode = n, this.avatarController = new
|
|
5502
|
+
this.playbackMode = n, this.avatarController = new Ai(e, {
|
|
5463
5503
|
playbackMode: n
|
|
5464
5504
|
}), this.avatarController.setRenderCallback((i, a) => {
|
|
5465
5505
|
this.renderRealtimeFrame(i, a);
|
|
@@ -5526,7 +5566,7 @@ class Ni {
|
|
|
5526
5566
|
*/
|
|
5527
5567
|
async getCachedIdleFirstFrame() {
|
|
5528
5568
|
if (!this.cachedIdleFirstFrame) {
|
|
5529
|
-
const e =
|
|
5569
|
+
const e = A.getAvatarCore();
|
|
5530
5570
|
if (e)
|
|
5531
5571
|
try {
|
|
5532
5572
|
const t = await e.getCurrentFrameParams(0);
|
|
@@ -5569,7 +5609,7 @@ class Ni {
|
|
|
5569
5609
|
async initializeView(e) {
|
|
5570
5610
|
try {
|
|
5571
5611
|
M.debug && h.log("[AvatarView] Initializing avatar view...");
|
|
5572
|
-
const t =
|
|
5612
|
+
const t = A.getAvatarCore();
|
|
5573
5613
|
if (!t)
|
|
5574
5614
|
throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
|
|
5575
5615
|
const n = e.getResources();
|
|
@@ -5615,28 +5655,28 @@ class Ni {
|
|
|
5615
5655
|
* 从角色设置中推导相机配置
|
|
5616
5656
|
*/
|
|
5617
5657
|
deriveCameraConfigFromSettings(e, t, n) {
|
|
5618
|
-
const i = (
|
|
5658
|
+
const i = (j, X) => Number.isFinite(j) ? j : X, a = i(e.translationX, t.position[0]), o = i(e.translationY, t.position[1]), s = i(e.translationZ, t.position[2]), l = i(e.rotation, 0), g = i(e.fovYRadians, 0), c = Math.hypot(a, o, s) > 1e-4, u = g > 0, m = Math.abs(l) > 1e-4;
|
|
5619
5659
|
if (!c && !u && !m)
|
|
5620
5660
|
return h.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
|
|
5621
|
-
const v = Math.sin(l), w = Math.cos(l), y = c ? [a, o, s] : [...t.position],
|
|
5661
|
+
const v = Math.sin(l), w = Math.cos(l), y = c ? [a, o, s] : [...t.position], b = [
|
|
5622
5662
|
-v,
|
|
5623
5663
|
0,
|
|
5624
5664
|
-w
|
|
5625
|
-
], x = Math.hypot(
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5665
|
+
], x = Math.hypot(b[0], b[1], b[2]) || 1, L = [
|
|
5666
|
+
b[0] / x,
|
|
5667
|
+
b[1] / x,
|
|
5668
|
+
b[2] / x
|
|
5629
5669
|
], _ = [
|
|
5630
5670
|
y[0] + L[0],
|
|
5631
5671
|
y[1] + L[1],
|
|
5632
5672
|
y[2] + L[2]
|
|
5633
|
-
], Y = [0, 1, 0],
|
|
5673
|
+
], Y = [0, 1, 0], G = u ? g * 180 / Math.PI : t.fov, U = {
|
|
5634
5674
|
...t,
|
|
5635
5675
|
// 自动继承 near/far 等配置(来自 APP_CONFIG.camera)
|
|
5636
5676
|
position: y,
|
|
5637
5677
|
target: _,
|
|
5638
5678
|
up: Y,
|
|
5639
|
-
fov:
|
|
5679
|
+
fov: G
|
|
5640
5680
|
// near/far 从 fallback 继承,无需硬编码
|
|
5641
5681
|
};
|
|
5642
5682
|
return h.log("[AvatarView] Applied camera settings from resources", {
|
|
@@ -5645,10 +5685,10 @@ class Ni {
|
|
|
5645
5685
|
yawRadians: l,
|
|
5646
5686
|
position: y,
|
|
5647
5687
|
target: _,
|
|
5648
|
-
fov:
|
|
5649
|
-
near:
|
|
5650
|
-
far:
|
|
5651
|
-
}),
|
|
5688
|
+
fov: G,
|
|
5689
|
+
near: U.near,
|
|
5690
|
+
far: U.far
|
|
5691
|
+
}), U;
|
|
5652
5692
|
}
|
|
5653
5693
|
/**
|
|
5654
5694
|
* 渲染第一帧
|
|
@@ -5656,7 +5696,7 @@ class Ni {
|
|
|
5656
5696
|
async renderFirstFrame() {
|
|
5657
5697
|
if (!this.renderSystem)
|
|
5658
5698
|
throw new Error("Render system not initialized");
|
|
5659
|
-
const e =
|
|
5699
|
+
const e = A.getAvatarCore();
|
|
5660
5700
|
if (!e)
|
|
5661
5701
|
throw new Error("AvatarCore not available");
|
|
5662
5702
|
const t = {
|
|
@@ -5698,7 +5738,7 @@ class Ni {
|
|
|
5698
5738
|
return;
|
|
5699
5739
|
}
|
|
5700
5740
|
e = a;
|
|
5701
|
-
const o =
|
|
5741
|
+
const o = A.getAvatarCore();
|
|
5702
5742
|
if (!o)
|
|
5703
5743
|
return;
|
|
5704
5744
|
const s = await o.computeCompleteFrameFlat({ frameIndex: this.idleCurrentFrameIndex });
|
|
@@ -5737,7 +5777,7 @@ class Ni {
|
|
|
5737
5777
|
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
5738
5778
|
return;
|
|
5739
5779
|
}
|
|
5740
|
-
const s = performance.now() - this.transitionStartTime, l = Math.min(1, Math.max(0, s / this.transitionDurationMs)), g = this.transitionKeyframes.length, c = Math.min(g - 1, Math.floor(l * (g - 1))), u = this.transitionKeyframes[c], m = Vt(u), v =
|
|
5780
|
+
const s = performance.now() - this.transitionStartTime, l = Math.min(1, Math.max(0, s / this.transitionDurationMs)), g = this.transitionKeyframes.length, c = Math.min(g - 1, Math.floor(l * (g - 1))), u = this.transitionKeyframes[c], m = Vt(u), v = A.getAvatarCore();
|
|
5741
5781
|
if (v) {
|
|
5742
5782
|
const w = await v.computeFrameFlatFromParams(m);
|
|
5743
5783
|
w && (this.renderSystem.loadSplatsFromPackedData(w), this.renderSystem.renderFrame());
|
|
@@ -5868,7 +5908,7 @@ class Ni {
|
|
|
5868
5908
|
/* TransitioningToSpeaking */
|
|
5869
5909
|
);
|
|
5870
5910
|
try {
|
|
5871
|
-
const n =
|
|
5911
|
+
const n = A.getAvatarCore();
|
|
5872
5912
|
if (n && e.length > 0) {
|
|
5873
5913
|
if (this.renderingState !== "transitioningToSpeaking")
|
|
5874
5914
|
return;
|
|
@@ -5892,7 +5932,7 @@ class Ni {
|
|
|
5892
5932
|
* 开始实时渲染循环
|
|
5893
5933
|
*/
|
|
5894
5934
|
startRealtimeRendering() {
|
|
5895
|
-
M.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"),
|
|
5935
|
+
M.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"), A.logEvent("character_view", "info", {
|
|
5896
5936
|
characterId: this.avatar.id,
|
|
5897
5937
|
event: "rendering_started",
|
|
5898
5938
|
keyframesCount: this.currentKeyframes.length
|
|
@@ -5918,7 +5958,7 @@ class Ni {
|
|
|
5918
5958
|
try {
|
|
5919
5959
|
if (this.renderingState !== "transitioningToIdle")
|
|
5920
5960
|
return;
|
|
5921
|
-
if (
|
|
5961
|
+
if (A.getAvatarCore() && this.currentKeyframes.length > 0) {
|
|
5922
5962
|
const n = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], i = await this.getCachedIdleFirstFrame();
|
|
5923
5963
|
if (i && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(n, i), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
|
|
5924
5964
|
M.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
|
|
@@ -5940,14 +5980,14 @@ class Ni {
|
|
|
5940
5980
|
* 关闭 avatarController 并清理所有相关资源
|
|
5941
5981
|
*/
|
|
5942
5982
|
dispose() {
|
|
5943
|
-
M.debug && h.log("[AvatarView] Disposing avatar view..."),
|
|
5983
|
+
M.debug && h.log("[AvatarView] Disposing avatar view..."), A.logEvent("character_view", "info", {
|
|
5944
5984
|
characterId: this.avatar.id,
|
|
5945
5985
|
event: "disposed"
|
|
5946
5986
|
}), this.avatarController && (this.avatarController.clear(), this.avatarController.dispose()), this.stopAllAnimationLoops(), this.setState(
|
|
5947
5987
|
"idle"
|
|
5948
5988
|
/* Idle */
|
|
5949
5989
|
), this.cachedIdleFirstFrame = null, this.idleCurrentFrameIndex = 0;
|
|
5950
|
-
const e =
|
|
5990
|
+
const e = A.getAvatarCore();
|
|
5951
5991
|
if (e)
|
|
5952
5992
|
try {
|
|
5953
5993
|
e.releaseCurrentCharacter(), M.debug && h.log("[AvatarView] AvatarCore character resources released");
|
|
@@ -5992,22 +6032,22 @@ class Ni {
|
|
|
5992
6032
|
}
|
|
5993
6033
|
export {
|
|
5994
6034
|
M as A,
|
|
5995
|
-
|
|
6035
|
+
Ae as C,
|
|
5996
6036
|
le as E,
|
|
5997
6037
|
oe as L,
|
|
5998
6038
|
nn as R,
|
|
5999
6039
|
se as S,
|
|
6000
|
-
|
|
6040
|
+
A as a,
|
|
6001
6041
|
rn as b,
|
|
6002
|
-
|
|
6042
|
+
Ai as c,
|
|
6003
6043
|
Tt as d,
|
|
6004
6044
|
nr as e,
|
|
6005
6045
|
Ni as f,
|
|
6006
|
-
|
|
6046
|
+
T as g,
|
|
6007
6047
|
ke as h,
|
|
6008
6048
|
Bi as i,
|
|
6009
6049
|
Di as j,
|
|
6010
6050
|
Oi as k,
|
|
6011
6051
|
h as l
|
|
6012
6052
|
};
|
|
6013
|
-
//# sourceMappingURL=index-
|
|
6053
|
+
//# sourceMappingURL=index-CXkdiMjt.js.map
|