@spatialwalk/avatarkit 1.0.0-beta.12 → 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 +27 -0
- package/README.md +10 -3
- package/dist/{StreamingAudioPlayer-BT7Qa8Ow.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/config/sdk-config-loader.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-CDG7huUa.js → index-CXkdiMjt.js} +585 -532
- 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/utils/logger.d.ts +2 -10
- package/dist/utils/logger.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-BT7Qa8Ow.js.map +0 -1
- package/dist/index-CDG7huUa.js.map +0 -1
|
@@ -30,22 +30,22 @@ class rn {
|
|
|
30
30
|
}
|
|
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
|
-
function
|
|
34
|
-
var e, t, n, i, a, o, s, l, g, c, u, m, v, w, y,
|
|
33
|
+
function Bi(r) {
|
|
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
|
-
function
|
|
44
|
+
function Di(r) {
|
|
45
45
|
var e, t, n, i, a, o;
|
|
46
46
|
return !!((n = (t = (e = r.animations) == null ? void 0 : e.frameMono) == null ? void 0 : t.resource) != null && n.remote && ((o = (a = (i = r.animations) == null ? void 0 : i.audioMono) == null ? void 0 : a.resource) != null && o.remote));
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function Oi(r) {
|
|
49
49
|
var e, t, n, i, a, o;
|
|
50
50
|
try {
|
|
51
51
|
const s = JSON.parse(r);
|
|
@@ -54,20 +54,20 @@ function Di(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";
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
var
|
|
63
|
+
var ke = /* @__PURE__ */ ((r) => (r.network = "network", r.external = "external", r))(ke || {});
|
|
64
64
|
function an() {
|
|
65
65
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("debug") === "1";
|
|
66
66
|
}
|
|
67
67
|
function on() {
|
|
68
68
|
return an();
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const M = {
|
|
71
71
|
// Dynamic debug mode check (includes URL parameter)
|
|
72
72
|
get debug() {
|
|
73
73
|
return on();
|
|
@@ -114,7 +114,7 @@ function Vt(r) {
|
|
|
114
114
|
has_eyelid: (((e = r.eyeLid) == null ? void 0 : e.length) || 0) > 0
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function dt(r) {
|
|
118
118
|
return {
|
|
119
119
|
translation: r.translation || [0, 0, 0],
|
|
120
120
|
rotation: r.rotation || [0, 0, 0],
|
|
@@ -129,9 +129,9 @@ var $t = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
|
|
|
129
129
|
function sn(r) {
|
|
130
130
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
131
131
|
}
|
|
132
|
-
var qt = { exports: {} },
|
|
132
|
+
var qt = { exports: {} }, Oe = { exports: {} }, ht;
|
|
133
133
|
function ln() {
|
|
134
|
-
return
|
|
134
|
+
return ht || (ht = 1, function(r, e) {
|
|
135
135
|
(function(t, n) {
|
|
136
136
|
r.exports = n();
|
|
137
137
|
})($t, function() {
|
|
@@ -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,44 +173,44 @@ 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;
|
|
212
212
|
});
|
|
213
|
-
}(
|
|
213
|
+
}(Oe)), Oe.exports;
|
|
214
214
|
}
|
|
215
215
|
(function(r, e) {
|
|
216
216
|
(function(t, n) {
|
|
@@ -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],
|
|
@@ -337,171 +337,171 @@ function ln() {
|
|
|
337
337
|
})(qt);
|
|
338
338
|
var cn = qt.exports;
|
|
339
339
|
const un = /* @__PURE__ */ sn(cn);
|
|
340
|
-
let
|
|
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
|
-
var
|
|
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
|
-
const
|
|
444
|
-
if (
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
const Qr = E.output.slice(
|
|
448
|
-
|
|
449
|
-
} else
|
|
443
|
+
const lt = E.output.length;
|
|
444
|
+
if (S(E)) {
|
|
445
|
+
const ct = E.index, ut = E.output.length;
|
|
446
|
+
if (ut > lt) {
|
|
447
|
+
const Qr = E.output.slice(lt, ut);
|
|
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
|
-
}), ie = "abcdefghijklmnopqrstuvwxyz",
|
|
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
|
-
},
|
|
476
|
-
if (p < f) return
|
|
477
|
-
const
|
|
478
|
-
for (; f <= p; )
|
|
479
|
-
return
|
|
480
|
-
}, ir = (f, p,
|
|
475
|
+
}, Te = (f, p) => {
|
|
476
|
+
if (p < f) return Te(p, f);
|
|
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
|
-
|
|
490
|
-
var Xr =
|
|
489
|
+
De.compile = (f) => new RegExp(`^${ot(Yr(f))}$`, "s");
|
|
490
|
+
var Xr = De;
|
|
491
491
|
return s(l);
|
|
492
492
|
})();
|
|
493
493
|
return r.default || r;
|
|
494
|
-
},
|
|
495
|
-
const dn = (r, e) => (
|
|
494
|
+
}, Ne;
|
|
495
|
+
const dn = (r, e) => (Ne || (Ne = ft(), ft = null), Ne(r, e)), hn = /^[A-Za-z]:\//;
|
|
496
496
|
function ce(r = "") {
|
|
497
497
|
return r && r.replace(/\\/g, "/").replace(hn, (e) => e.toUpperCase());
|
|
498
498
|
}
|
|
499
|
-
const fn = /^[/\\]{2}/, mn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, Wt = /^[A-Za-z]:$/,
|
|
499
|
+
const fn = /^[/\\]{2}/, mn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, Wt = /^[A-Za-z]:$/, mt = /^\/([A-Za-z]:)?$/, gn = /.(\.[^./]+|\.)$/, pn = /^[/\\]|^[a-zA-Z]:[/\\]/, vn = "/", Ke = function(r) {
|
|
500
500
|
if (r.length === 0)
|
|
501
501
|
return ".";
|
|
502
502
|
r = ce(r);
|
|
503
503
|
const e = r.match(fn), t = ve(r), n = r[r.length - 1] === "/";
|
|
504
|
-
return r =
|
|
504
|
+
return r = Je(r, !t), r.length === 0 ? t ? "/" : n ? "./" : "." : (n && (r += "/"), Wt.test(r) && (r += "/"), e ? t ? `//${r}` : `//./${r}` : t && !ve(r) ? `/${r}` : r);
|
|
505
505
|
}, wn = function(...r) {
|
|
506
506
|
let e = "";
|
|
507
507
|
for (const t of r)
|
|
@@ -511,21 +511,21 @@ const fn = /^[/\\]{2}/, mn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,
|
|
|
511
511
|
n && i ? e += t.slice(1) : e += n || i ? t : `/${t}`;
|
|
512
512
|
} else
|
|
513
513
|
e += t;
|
|
514
|
-
return
|
|
514
|
+
return Ke(e);
|
|
515
515
|
};
|
|
516
516
|
function yn() {
|
|
517
517
|
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
518
518
|
}
|
|
519
|
-
const
|
|
519
|
+
const Me = function(...r) {
|
|
520
520
|
r = r.map((n) => ce(n));
|
|
521
521
|
let e = "", t = !1;
|
|
522
522
|
for (let n = r.length - 1; n >= -1 && !t; n--) {
|
|
523
523
|
const i = n >= 0 ? r[n] : yn();
|
|
524
524
|
!i || i.length === 0 || (e = `${i}/${e}`, t = ve(i));
|
|
525
525
|
}
|
|
526
|
-
return e =
|
|
526
|
+
return e = Je(e, !t), t && !ve(e) ? `/${e}` : e.length > 0 ? e : ".";
|
|
527
527
|
};
|
|
528
|
-
function
|
|
528
|
+
function Je(r, e) {
|
|
529
529
|
let t = "", n = 0, i = -1, a = 0, o = null;
|
|
530
530
|
for (let s = 0; s <= r.length; ++s) {
|
|
531
531
|
if (s < r.length)
|
|
@@ -557,14 +557,14 @@ function He(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
|
-
},
|
|
567
|
-
const t =
|
|
566
|
+
}, An = function(r, e) {
|
|
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("/");
|
|
570
570
|
const i = [...t];
|
|
@@ -582,7 +582,7 @@ const ve = function(r) {
|
|
|
582
582
|
Boolean
|
|
583
583
|
);
|
|
584
584
|
return ce(
|
|
585
|
-
r.root ?
|
|
585
|
+
r.root ? Me(...t) : t.join("/")
|
|
586
586
|
);
|
|
587
587
|
}, Ht = function(r, e) {
|
|
588
588
|
const t = ce(r).split("/");
|
|
@@ -605,7 +605,7 @@ const ve = function(r) {
|
|
|
605
605
|
ext: n,
|
|
606
606
|
name: t.slice(0, t.length - n.length)
|
|
607
607
|
};
|
|
608
|
-
}, _n = (r, e) => dn(e,
|
|
608
|
+
}, _n = (r, e) => dn(e, Ke(r)), gt = {
|
|
609
609
|
__proto__: null,
|
|
610
610
|
basename: Ht,
|
|
611
611
|
dirname: jt,
|
|
@@ -614,22 +614,22 @@ const ve = function(r) {
|
|
|
614
614
|
isAbsolute: ve,
|
|
615
615
|
join: wn,
|
|
616
616
|
matchesGlob: _n,
|
|
617
|
-
normalize:
|
|
618
|
-
normalizeString:
|
|
617
|
+
normalize: Ke,
|
|
618
|
+
normalizeString: Je,
|
|
619
619
|
parse: Cn,
|
|
620
|
-
relative:
|
|
621
|
-
resolve:
|
|
620
|
+
relative: An,
|
|
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" ? ";" : ":";
|
|
627
|
-
})(), xn = { posix: void 0, win32: void 0 }, Kt = (r = En) => new Proxy(
|
|
627
|
+
})(), xn = { posix: void 0, win32: void 0 }, Kt = (r = En) => new Proxy(gt, {
|
|
628
628
|
get(e, t) {
|
|
629
|
-
return t === "delimiter" ? r : t === "posix" ?
|
|
629
|
+
return t === "delimiter" ? r : t === "posix" ? We : t === "win32" ? Pn : xn[t] || gt[t];
|
|
630
630
|
}
|
|
631
|
-
}),
|
|
632
|
-
var
|
|
631
|
+
}), We = /* @__PURE__ */ Kt(":"), Pn = /* @__PURE__ */ Kt(";");
|
|
632
|
+
var k = /* @__PURE__ */ ((r) => (r[r.Error = 0] = "Error", r[r.Warning = 1] = "Warning", r[r.Log = 2] = "Log", r[r.Verbose = 3] = "Verbose", r[r.Debug = 4] = "Debug", r))(k || {}), I = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(I || {}), te = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(te || {});
|
|
633
633
|
const In = !0;
|
|
634
634
|
function F(r, e, t = r) {
|
|
635
635
|
return (n) => {
|
|
@@ -671,36 +671,36 @@ function kn(r = In) {
|
|
|
671
671
|
bgWhite: r ? F("\x1B[47m", "\x1B[49m") : String
|
|
672
672
|
};
|
|
673
673
|
}
|
|
674
|
-
const
|
|
675
|
-
[I.Error]:
|
|
676
|
-
[I.Warning]:
|
|
677
|
-
[I.Log]:
|
|
678
|
-
[I.Verbose]:
|
|
679
|
-
[I.Debug]:
|
|
674
|
+
const D = kn(), Ge = {
|
|
675
|
+
[I.Error]: k.Error,
|
|
676
|
+
[I.Warning]: k.Warning,
|
|
677
|
+
[I.Log]: k.Log,
|
|
678
|
+
[I.Verbose]: k.Verbose,
|
|
679
|
+
[I.Debug]: k.Debug
|
|
680
680
|
}, Mn = {
|
|
681
|
-
[
|
|
682
|
-
[
|
|
683
|
-
[
|
|
684
|
-
[
|
|
685
|
-
[
|
|
686
|
-
},
|
|
681
|
+
[k.Error]: I.Error,
|
|
682
|
+
[k.Warning]: I.Warning,
|
|
683
|
+
[k.Log]: I.Log,
|
|
684
|
+
[k.Verbose]: I.Verbose,
|
|
685
|
+
[k.Debug]: I.Debug
|
|
686
|
+
}, pt = [
|
|
687
687
|
I.Error,
|
|
688
688
|
I.Warning,
|
|
689
689
|
I.Log,
|
|
690
690
|
I.Verbose,
|
|
691
691
|
I.Debug
|
|
692
692
|
], Fn = {
|
|
693
|
-
[
|
|
694
|
-
[
|
|
695
|
-
[
|
|
696
|
-
[
|
|
697
|
-
[
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
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
|
+
}, Fe = [
|
|
699
|
+
k.Error,
|
|
700
|
+
k.Warning,
|
|
701
|
+
k.Log,
|
|
702
|
+
k.Verbose,
|
|
703
|
+
k.Debug
|
|
704
704
|
], vt = [te.JSON, te.Pretty];
|
|
705
705
|
function Rn(r) {
|
|
706
706
|
return r.stack == null ? [] : r.stack.split(`
|
|
@@ -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);
|
|
@@ -765,15 +765,15 @@ function wt(r) {
|
|
|
765
765
|
}
|
|
766
766
|
return e;
|
|
767
767
|
}
|
|
768
|
-
function
|
|
768
|
+
function xe(r) {
|
|
769
769
|
const e = [];
|
|
770
770
|
e.push(r["@localetime"]), e.push(
|
|
771
|
-
Fn[
|
|
771
|
+
Fn[Ge[r.level]](
|
|
772
772
|
`[${r.level}]`
|
|
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 Ee(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(" ");
|
|
@@ -795,53 +795,65 @@ function Ee(r) {
|
|
|
795
795
|
${r.error.stack}`), i;
|
|
796
796
|
}
|
|
797
797
|
function Tn(r) {
|
|
798
|
-
return r >=
|
|
798
|
+
return r >= k.Debug;
|
|
799
799
|
}
|
|
800
800
|
function Bn(r) {
|
|
801
|
-
return r >=
|
|
801
|
+
return r >= k.Verbose;
|
|
802
802
|
}
|
|
803
803
|
function Dn(r) {
|
|
804
|
-
return r >=
|
|
804
|
+
return r >= k.Log;
|
|
805
805
|
}
|
|
806
806
|
function On(r) {
|
|
807
|
-
return r >=
|
|
807
|
+
return r >= k.Warning;
|
|
808
808
|
}
|
|
809
809
|
function Nn(r) {
|
|
810
|
-
return r >=
|
|
810
|
+
return r >= k.Error;
|
|
811
811
|
}
|
|
812
812
|
function Xt() {
|
|
813
813
|
return typeof window < "u";
|
|
814
814
|
}
|
|
815
815
|
function Un() {
|
|
816
|
-
return !Xt() &&
|
|
816
|
+
return !Xt() && je() === te.Pretty;
|
|
817
817
|
}
|
|
818
818
|
function zn(r, e) {
|
|
819
819
|
return Un() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
|
|
820
820
|
}
|
|
821
|
-
const
|
|
822
|
-
|
|
821
|
+
const _e = {
|
|
822
|
+
configured: !1,
|
|
823
|
+
logLevel: k.Debug,
|
|
823
824
|
format: te.JSON,
|
|
824
825
|
timeFormatter: (r) => r.toISOString()
|
|
825
826
|
};
|
|
826
827
|
function yt() {
|
|
827
|
-
return
|
|
828
|
+
return _e.logLevel;
|
|
828
829
|
}
|
|
829
|
-
function
|
|
830
|
-
|
|
830
|
+
function Vn(r) {
|
|
831
|
+
if (Fe.includes(r))
|
|
832
|
+
_e.logLevel = r;
|
|
833
|
+
else
|
|
834
|
+
throw new Error(
|
|
835
|
+
`log level ${r} is not available. available log levels are: ${Fe.join(
|
|
836
|
+
", "
|
|
837
|
+
)}`
|
|
838
|
+
);
|
|
839
|
+
_e.configured = !0;
|
|
840
|
+
}
|
|
841
|
+
function je() {
|
|
842
|
+
return _e.format;
|
|
831
843
|
}
|
|
832
|
-
function
|
|
833
|
-
return
|
|
844
|
+
function $n() {
|
|
845
|
+
return _e.timeFormatter;
|
|
834
846
|
}
|
|
835
847
|
function Qt(r) {
|
|
836
848
|
const e = {
|
|
837
849
|
fields: {},
|
|
838
850
|
context: r,
|
|
839
|
-
logLevel:
|
|
851
|
+
logLevel: k.Debug,
|
|
840
852
|
format: te.JSON,
|
|
841
853
|
shouldUseGlobalConfig: !1,
|
|
842
854
|
errorProcessor: (c) => c,
|
|
843
855
|
timeFormatter: (c) => c.toISOString(),
|
|
844
|
-
useGlobalConfig: () => (e.shouldUseGlobalConfig = !0, e.format =
|
|
856
|
+
useGlobalConfig: () => (e.shouldUseGlobalConfig = !0, e.format = je(), e.logLevel = yt(), e.child()),
|
|
845
857
|
child: (c) => {
|
|
846
858
|
const u = Qt(e.context);
|
|
847
859
|
return c != null ? u.fields = { ...e.fields, ...c } : u.fields = e.fields, u.fields != null && "context" in u.fields ? u.context = u.fields.context : u.context = e.context, u.logLevel = e.logLevel, u.format = e.format, u.shouldUseGlobalConfig = e.shouldUseGlobalConfig, u;
|
|
@@ -852,13 +864,13 @@ function Qt(r) {
|
|
|
852
864
|
},
|
|
853
865
|
withLogLevel: (c) => {
|
|
854
866
|
const u = e.child();
|
|
855
|
-
if (
|
|
867
|
+
if (Fe.includes(c))
|
|
856
868
|
u.logLevel = c, u.shouldUseGlobalConfig = !1, u.debug(
|
|
857
869
|
`setting log level to ${Mn[c]} (${c})`
|
|
858
870
|
);
|
|
859
871
|
else
|
|
860
872
|
throw new Error(
|
|
861
|
-
`log level ${c} is not available. available log levels are: ${
|
|
873
|
+
`log level ${c} is not available. available log levels are: ${Fe.join(
|
|
862
874
|
", "
|
|
863
875
|
)}`
|
|
864
876
|
);
|
|
@@ -866,13 +878,13 @@ function Qt(r) {
|
|
|
866
878
|
},
|
|
867
879
|
withLogLevelString: (c) => {
|
|
868
880
|
const u = e.child();
|
|
869
|
-
if (
|
|
870
|
-
u.logLevel =
|
|
871
|
-
`setting log level to ${c} (${
|
|
881
|
+
if (pt.includes(c))
|
|
882
|
+
u.logLevel = Ge[c], u.shouldUseGlobalConfig = !1, u.debug(
|
|
883
|
+
`setting log level to ${c} (${Ge[c]})`
|
|
872
884
|
);
|
|
873
885
|
else
|
|
874
886
|
throw new Error(
|
|
875
|
-
`log level ${c} is not available. available log levels are: ${
|
|
887
|
+
`log level ${c} is not available. available log levels are: ${pt.join(
|
|
876
888
|
", "
|
|
877
889
|
)}`
|
|
878
890
|
);
|
|
@@ -940,20 +952,20 @@ function Qt(r) {
|
|
|
940
952
|
const u = e.child();
|
|
941
953
|
return u.errorProcessor = c, u;
|
|
942
954
|
}
|
|
943
|
-
}, t = () => e.shouldUseGlobalConfig ? yt() : e.logLevel, n = () => e.shouldUseGlobalConfig ?
|
|
955
|
+
}, t = () => e.shouldUseGlobalConfig ? yt() : e.logLevel, n = () => e.shouldUseGlobalConfig ? je() : e.format, i = () => e.shouldUseGlobalConfig ? $n() : e.timeFormatter ?? ((c) => c.toISOString()), a = (c) => c != null && c.length > 0 ? Object.keys(e.fields).length > 0 ? [e.fields, ...c] : c : e.fields, o = (c, u, m) => {
|
|
944
956
|
const v = n();
|
|
945
957
|
if (Xt() && v === te.Pretty) {
|
|
946
958
|
c.fields = Object.fromEntries(
|
|
947
|
-
Object.entries(c.fields).filter(([
|
|
948
|
-
if (
|
|
949
|
-
return [
|
|
959
|
+
Object.entries(c.fields).filter(([b, x]) => {
|
|
960
|
+
if (b === "isNestSystemModule" || b === "nestSystemModule" || b === "context")
|
|
961
|
+
return [b, x];
|
|
950
962
|
})
|
|
951
963
|
);
|
|
952
964
|
const y = m ?? e.fields;
|
|
953
|
-
Array.isArray(y) && y.length > 0 ? console[u](
|
|
965
|
+
Array.isArray(y) && y.length > 0 ? console[u](xe(c), ...y) : Object.keys(y).length > 0 ? console[u](xe(c), y) : console[u](xe(c));
|
|
954
966
|
return;
|
|
955
967
|
}
|
|
956
|
-
const w = v === te.Pretty ?
|
|
968
|
+
const w = v === te.Pretty ? xe(c) : JSON.stringify(c);
|
|
957
969
|
console[u](w);
|
|
958
970
|
}, s = {
|
|
959
971
|
[I.Debug]: Tn,
|
|
@@ -969,14 +981,14 @@ function Qt(r) {
|
|
|
969
981
|
const v = t(), w = s[c];
|
|
970
982
|
if (!w(v))
|
|
971
983
|
return;
|
|
972
|
-
const y = a(m),
|
|
984
|
+
const y = a(m), b = Yt(
|
|
973
985
|
c,
|
|
974
986
|
e.context,
|
|
975
987
|
y,
|
|
976
988
|
u,
|
|
977
989
|
i()
|
|
978
990
|
);
|
|
979
|
-
o(
|
|
991
|
+
o(b, l[c], y);
|
|
980
992
|
};
|
|
981
993
|
return e.debug = (c, ...u) => {
|
|
982
994
|
g(I.Debug, c, u);
|
|
@@ -1001,36 +1013,37 @@ function Qt(r) {
|
|
|
1001
1013
|
o(y, "error", w);
|
|
1002
1014
|
}, e.errorWithError = (c, u, ...m) => e.withError(u).error(c, void 0, ...m), e;
|
|
1003
1015
|
}
|
|
1004
|
-
function
|
|
1016
|
+
function qn(r) {
|
|
1005
1017
|
var a;
|
|
1006
|
-
const t = un.parse(new Error())[1], n = ((a = t.fileName) == null ? void 0 : a.replace("async", "").trim()) ?? "", i =
|
|
1018
|
+
const t = un.parse(new Error())[1], n = ((a = t.fileName) == null ? void 0 : a.replace("async", "").trim()) ?? "", i = We.join(...n.split(We.sep).slice(-2));
|
|
1007
1019
|
return r = r ?? `${i}:${t.lineNumber}`, Qt(zn(n, r));
|
|
1008
1020
|
}
|
|
1009
|
-
const
|
|
1021
|
+
const Wn = (r) => qn(r).useGlobalConfig();
|
|
1010
1022
|
let Q = [];
|
|
1011
|
-
const
|
|
1012
|
-
async function
|
|
1023
|
+
const St = 100;
|
|
1024
|
+
async function Gn() {
|
|
1013
1025
|
if (Q.length === 0)
|
|
1014
1026
|
return;
|
|
1015
1027
|
const r = [...Q];
|
|
1016
1028
|
Q = [];
|
|
1017
1029
|
try {
|
|
1018
|
-
await
|
|
1030
|
+
await jn();
|
|
1019
1031
|
} catch (e) {
|
|
1020
|
-
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));
|
|
1021
1033
|
}
|
|
1022
1034
|
}
|
|
1023
|
-
async function
|
|
1035
|
+
async function jn(r) {
|
|
1024
1036
|
}
|
|
1025
|
-
function
|
|
1026
|
-
Q.length > 0 &&
|
|
1037
|
+
function Hn() {
|
|
1038
|
+
Q.length > 0 && Gn(), h.log("[CLS] Cleaned up");
|
|
1027
1039
|
}
|
|
1028
|
-
|
|
1040
|
+
Vn(k.Warning);
|
|
1041
|
+
const h = Wn("Web").withErrorProcessor((r) => r).useGlobalConfig(), O = {
|
|
1029
1042
|
config: null,
|
|
1030
1043
|
promise: null
|
|
1031
1044
|
};
|
|
1032
|
-
async function
|
|
1033
|
-
return
|
|
1045
|
+
async function Kn(r) {
|
|
1046
|
+
return O.promise ? (await O.promise, O.config || {}) : O.config ? O.config : (O.promise = (async () => {
|
|
1034
1047
|
try {
|
|
1035
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}`;
|
|
1036
1049
|
h.log(`[SdkConfigLoader] Fetching SDK config from: ${t}`);
|
|
@@ -1046,18 +1059,18 @@ async function Hn(r) {
|
|
|
1046
1059
|
if (!i.endpoints)
|
|
1047
1060
|
throw new Error("Invalid config response: missing endpoints");
|
|
1048
1061
|
const a = {};
|
|
1049
|
-
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}`),
|
|
1050
|
-
} catch
|
|
1051
|
-
|
|
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
|
+
} catch {
|
|
1064
|
+
O.config = {};
|
|
1052
1065
|
} finally {
|
|
1053
|
-
|
|
1066
|
+
O.promise = null;
|
|
1054
1067
|
}
|
|
1055
|
-
})(), await
|
|
1068
|
+
})(), await O.promise, O.config || {});
|
|
1056
1069
|
}
|
|
1057
|
-
function
|
|
1058
|
-
|
|
1070
|
+
function Jn() {
|
|
1071
|
+
O.config = null, O.promise = null;
|
|
1059
1072
|
}
|
|
1060
|
-
class
|
|
1073
|
+
class Zn {
|
|
1061
1074
|
constructor(e) {
|
|
1062
1075
|
d(this, "module");
|
|
1063
1076
|
d(this, "allocatedPointers");
|
|
@@ -1277,7 +1290,7 @@ class Jn {
|
|
|
1277
1290
|
};
|
|
1278
1291
|
}
|
|
1279
1292
|
}
|
|
1280
|
-
class
|
|
1293
|
+
class Yn {
|
|
1281
1294
|
constructor(e = {}) {
|
|
1282
1295
|
// 配置
|
|
1283
1296
|
d(this, "options");
|
|
@@ -1347,7 +1360,7 @@ class Zn {
|
|
|
1347
1360
|
async loadWASMModule() {
|
|
1348
1361
|
try {
|
|
1349
1362
|
const { default: e } = await import("./avatar_core_wasm-D4eEi7Eh.js");
|
|
1350
|
-
this.wasmConfig && Object.keys(this.wasmConfig).length > 0 ? this.wasmModule = await e(this.wasmConfig) : this.wasmModule = await e(), this.validateWASMModule(), this.memoryManager = new
|
|
1363
|
+
this.wasmConfig && Object.keys(this.wasmConfig).length > 0 ? this.wasmModule = await e(this.wasmConfig) : this.wasmModule = await e(), this.validateWASMModule(), this.memoryManager = new Zn(this.wasmModule), this.setupCAPIFunctions(), h.log("✅ Created new WASM instance with clean C++ memory");
|
|
1351
1364
|
} catch (e) {
|
|
1352
1365
|
const t = e instanceof Error ? e.message : String(e);
|
|
1353
1366
|
throw new Error(`Failed to load WASM module: ${t}`);
|
|
@@ -1776,7 +1789,7 @@ class Zn {
|
|
|
1776
1789
|
}
|
|
1777
1790
|
}
|
|
1778
1791
|
}
|
|
1779
|
-
class
|
|
1792
|
+
class A {
|
|
1780
1793
|
/**
|
|
1781
1794
|
* SDK 初始化
|
|
1782
1795
|
* @param appId 前端需要在 HTTP Headers 和 WebSocket Headers 中都带上
|
|
@@ -1806,7 +1819,7 @@ class b {
|
|
|
1806
1819
|
*/
|
|
1807
1820
|
static async initializeWASMModule() {
|
|
1808
1821
|
try {
|
|
1809
|
-
h.log("[AvatarKit] Initializing WASM module..."), this._avatarCore = new
|
|
1822
|
+
h.log("[AvatarKit] Initializing WASM module..."), this._avatarCore = new Yn({
|
|
1810
1823
|
logLevel: "basic",
|
|
1811
1824
|
enableValidation: !0,
|
|
1812
1825
|
enablePerformanceMetrics: !0,
|
|
@@ -1876,7 +1889,7 @@ class b {
|
|
|
1876
1889
|
static cleanup() {
|
|
1877
1890
|
if (this._isInitialized)
|
|
1878
1891
|
try {
|
|
1879
|
-
this._avatarCore && (this._avatarCore.release(), this._avatarCore = null), this._appId = null, this._configuration = null, this._sessionToken = null, this._userId = null, this._dynamicSdkConfig = null, this._isInitialized = !1,
|
|
1892
|
+
this._avatarCore && (this._avatarCore.release(), this._avatarCore = null), this._appId = null, this._configuration = null, this._sessionToken = null, this._userId = null, this._dynamicSdkConfig = null, this._isInitialized = !1, Jn(), Hn(), h.log("[AvatarKit] Cleanup completed");
|
|
1880
1893
|
} catch (e) {
|
|
1881
1894
|
h.error("Failed to cleanup AvatarKit:", e instanceof Error ? e.message : String(e));
|
|
1882
1895
|
}
|
|
@@ -1886,7 +1899,7 @@ class b {
|
|
|
1886
1899
|
*/
|
|
1887
1900
|
static async _fetchSdkConfig() {
|
|
1888
1901
|
try {
|
|
1889
|
-
this._dynamicSdkConfig = await
|
|
1902
|
+
this._dynamicSdkConfig = await Kn(this._version);
|
|
1890
1903
|
} catch (e) {
|
|
1891
1904
|
const t = e instanceof Error ? e.message : String(e);
|
|
1892
1905
|
h.warn("Failed to fetch SDK config from remote, using defaults:", t), this.logEvent("sdk_config", "warning", {
|
|
@@ -1940,7 +1953,7 @@ class b {
|
|
|
1940
1953
|
h[a](`[Telemetry] ${e}`, i);
|
|
1941
1954
|
}
|
|
1942
1955
|
}
|
|
1943
|
-
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", {
|
|
1944
1957
|
debug: "log",
|
|
1945
1958
|
info: "log",
|
|
1946
1959
|
warning: "warn",
|
|
@@ -1951,7 +1964,7 @@ const Ce = class Ce {
|
|
|
1951
1964
|
d(this, "audio", null);
|
|
1952
1965
|
d(this, "streamingPlayer", null);
|
|
1953
1966
|
d(this, "_isPlaying", !1);
|
|
1954
|
-
d(this, "fps",
|
|
1967
|
+
d(this, "fps", M.animation.fps);
|
|
1955
1968
|
d(this, "onEndedCallback");
|
|
1956
1969
|
d(this, "useStreaming", !1);
|
|
1957
1970
|
}
|
|
@@ -2009,9 +2022,9 @@ const Ce = class Ce {
|
|
|
2009
2022
|
async createAndInitializeStreamingPlayer() {
|
|
2010
2023
|
if (this.streamingPlayer)
|
|
2011
2024
|
return;
|
|
2012
|
-
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-
|
|
2025
|
+
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-zd5a2zg4.js");
|
|
2013
2026
|
this.streamingPlayer = new e({
|
|
2014
|
-
sampleRate:
|
|
2027
|
+
sampleRate: M.audio.sampleRate,
|
|
2015
2028
|
channelCount: 1,
|
|
2016
2029
|
debug: !1
|
|
2017
2030
|
});
|
|
@@ -2019,7 +2032,7 @@ const Ce = class Ce {
|
|
|
2019
2032
|
await this.streamingPlayer.initialize();
|
|
2020
2033
|
} catch (t) {
|
|
2021
2034
|
const n = t instanceof Error ? t.message : String(t);
|
|
2022
|
-
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", {
|
|
2023
2036
|
event: "streaming_player_initialize_failed",
|
|
2024
2037
|
reason: n
|
|
2025
2038
|
}), t;
|
|
@@ -2080,13 +2093,27 @@ const Ce = class Ce {
|
|
|
2080
2093
|
addAudioChunk(e, t = !1) {
|
|
2081
2094
|
this.useStreaming && this.streamingPlayer ? this.streamingPlayer.addChunk(e, t) : h.warn("[AnimationPlayer] Cannot add audio chunk - streaming player not ready");
|
|
2082
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
|
+
}
|
|
2083
2110
|
dispose() {
|
|
2084
2111
|
this.stop(), this.audio && (this.audio.src = "", this.audio = null), this.streamingPlayer && (this.streamingPlayer.dispose(), this.streamingPlayer = null), this.onEndedCallback = void 0;
|
|
2085
2112
|
}
|
|
2086
2113
|
};
|
|
2087
2114
|
d(Ce, "audioUnlocked", !1);
|
|
2088
2115
|
let be = Ce;
|
|
2089
|
-
function
|
|
2116
|
+
function Xn() {
|
|
2090
2117
|
let r = 0, e = 0;
|
|
2091
2118
|
for (let n = 0; n < 28; n += 7) {
|
|
2092
2119
|
let i = this.buf[this.pos++];
|
|
@@ -2103,7 +2130,7 @@ function Yn() {
|
|
|
2103
2130
|
}
|
|
2104
2131
|
throw new Error("invalid varint");
|
|
2105
2132
|
}
|
|
2106
|
-
function
|
|
2133
|
+
function Ue(r, e, t) {
|
|
2107
2134
|
for (let a = 0; a < 28; a = a + 7) {
|
|
2108
2135
|
const o = r >>> a, s = !(!(o >>> 7) && e == 0), l = (s ? o | 128 : o) & 255;
|
|
2109
2136
|
if (t.push(l), !s)
|
|
@@ -2119,41 +2146,41 @@ function Oe(r, e, t) {
|
|
|
2119
2146
|
t.push(e >>> 31 & 1);
|
|
2120
2147
|
}
|
|
2121
2148
|
}
|
|
2122
|
-
const
|
|
2123
|
-
function
|
|
2149
|
+
const Ie = 4294967296;
|
|
2150
|
+
function At(r) {
|
|
2124
2151
|
const e = r[0] === "-";
|
|
2125
2152
|
e && (r = r.slice(1));
|
|
2126
2153
|
const t = 1e6;
|
|
2127
2154
|
let n = 0, i = 0;
|
|
2128
2155
|
function a(o, s) {
|
|
2129
2156
|
const l = Number(r.slice(o, s));
|
|
2130
|
-
i *= t, n = n * t + l, n >=
|
|
2157
|
+
i *= t, n = n * t + l, n >= Ie && (i = i + (n / Ie | 0), n = n % Ie);
|
|
2131
2158
|
}
|
|
2132
|
-
return a(-24, -18), a(-18, -12), a(-12, -6), a(-6), e ? tr(n, i) :
|
|
2159
|
+
return a(-24, -18), a(-18, -12), a(-12, -6), a(-6), e ? tr(n, i) : Ze(n, i);
|
|
2133
2160
|
}
|
|
2134
|
-
function
|
|
2135
|
-
let t =
|
|
2161
|
+
function Qn(r, e) {
|
|
2162
|
+
let t = Ze(r, e);
|
|
2136
2163
|
const n = t.hi & 2147483648;
|
|
2137
2164
|
n && (t = tr(t.lo, t.hi));
|
|
2138
2165
|
const i = er(t.lo, t.hi);
|
|
2139
2166
|
return n ? "-" + i : i;
|
|
2140
2167
|
}
|
|
2141
2168
|
function er(r, e) {
|
|
2142
|
-
if ({ lo: r, hi: e } =
|
|
2143
|
-
return String(
|
|
2169
|
+
if ({ lo: r, hi: e } = ei(r, e), e <= 2097151)
|
|
2170
|
+
return String(Ie * e + r);
|
|
2144
2171
|
const t = r & 16777215, n = (r >>> 24 | e << 8) & 16777215, i = e >> 16 & 65535;
|
|
2145
2172
|
let a = t + n * 6777216 + i * 6710656, o = n + i * 8147497, s = i * 2;
|
|
2146
2173
|
const l = 1e7;
|
|
2147
2174
|
return a >= l && (o += Math.floor(a / l), a %= l), o >= l && (s += Math.floor(o / l), o %= l), s.toString() + bt(o) + bt(a);
|
|
2148
2175
|
}
|
|
2149
|
-
function
|
|
2176
|
+
function ei(r, e) {
|
|
2150
2177
|
return { lo: r >>> 0, hi: e >>> 0 };
|
|
2151
2178
|
}
|
|
2152
|
-
function
|
|
2179
|
+
function Ze(r, e) {
|
|
2153
2180
|
return { lo: r | 0, hi: e | 0 };
|
|
2154
2181
|
}
|
|
2155
2182
|
function tr(r, e) {
|
|
2156
|
-
return e = ~e, r ? r = ~r + 1 : e += 1,
|
|
2183
|
+
return e = ~e, r ? r = ~r + 1 : e += 1, Ze(r, e);
|
|
2157
2184
|
}
|
|
2158
2185
|
const bt = (r) => {
|
|
2159
2186
|
const e = String(r);
|
|
@@ -2170,7 +2197,7 @@ function Ct(r, e) {
|
|
|
2170
2197
|
e.push(1);
|
|
2171
2198
|
}
|
|
2172
2199
|
}
|
|
2173
|
-
function
|
|
2200
|
+
function ti() {
|
|
2174
2201
|
let r = this.buf[this.pos++], e = r & 127;
|
|
2175
2202
|
if (!(r & 128))
|
|
2176
2203
|
return this.assertBounds(), e;
|
|
@@ -2187,8 +2214,8 @@ function ei() {
|
|
|
2187
2214
|
throw new Error("invalid varint");
|
|
2188
2215
|
return this.assertBounds(), e >>> 0;
|
|
2189
2216
|
}
|
|
2190
|
-
const
|
|
2191
|
-
function
|
|
2217
|
+
const K = /* @__PURE__ */ ri();
|
|
2218
|
+
function ri() {
|
|
2192
2219
|
const r = new DataView(new ArrayBuffer(8));
|
|
2193
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")) {
|
|
2194
2221
|
const t = BigInt("-9223372036854775808"), n = BigInt("9223372036854775807"), i = BigInt("0"), a = BigInt("18446744073709551615");
|
|
@@ -2237,13 +2264,13 @@ function ti() {
|
|
|
2237
2264
|
return typeof t != "string" && (t = t.toString()), Et(t), t;
|
|
2238
2265
|
},
|
|
2239
2266
|
enc(t) {
|
|
2240
|
-
return typeof t != "string" && (t = t.toString()), _t(t),
|
|
2267
|
+
return typeof t != "string" && (t = t.toString()), _t(t), At(t);
|
|
2241
2268
|
},
|
|
2242
2269
|
uEnc(t) {
|
|
2243
|
-
return typeof t != "string" && (t = t.toString()), Et(t),
|
|
2270
|
+
return typeof t != "string" && (t = t.toString()), Et(t), At(t);
|
|
2244
2271
|
},
|
|
2245
2272
|
dec(t, n) {
|
|
2246
|
-
return
|
|
2273
|
+
return Qn(t, n);
|
|
2247
2274
|
},
|
|
2248
2275
|
uDec(t, n) {
|
|
2249
2276
|
return er(t, n);
|
|
@@ -2258,11 +2285,11 @@ function Et(r) {
|
|
|
2258
2285
|
if (!/^[0-9]+$/.test(r))
|
|
2259
2286
|
throw new Error("invalid uint64: " + r);
|
|
2260
2287
|
}
|
|
2261
|
-
const
|
|
2288
|
+
const ze = Symbol.for("@bufbuild/protobuf/text-encoding");
|
|
2262
2289
|
function rr() {
|
|
2263
|
-
if (globalThis[
|
|
2290
|
+
if (globalThis[ze] == null) {
|
|
2264
2291
|
const r = new globalThis.TextEncoder(), e = new globalThis.TextDecoder();
|
|
2265
|
-
globalThis[
|
|
2292
|
+
globalThis[ze] = {
|
|
2266
2293
|
encodeUtf8(t) {
|
|
2267
2294
|
return r.encode(t);
|
|
2268
2295
|
},
|
|
@@ -2278,13 +2305,13 @@ function rr() {
|
|
|
2278
2305
|
}
|
|
2279
2306
|
};
|
|
2280
2307
|
}
|
|
2281
|
-
return globalThis[
|
|
2308
|
+
return globalThis[ze];
|
|
2282
2309
|
}
|
|
2283
2310
|
var ee;
|
|
2284
2311
|
(function(r) {
|
|
2285
2312
|
r[r.Varint = 0] = "Varint", r[r.Bit64 = 1] = "Bit64", r[r.LengthDelimited = 2] = "LengthDelimited", r[r.StartGroup = 3] = "StartGroup", r[r.EndGroup = 4] = "EndGroup", r[r.Bit32 = 5] = "Bit32";
|
|
2286
2313
|
})(ee || (ee = {}));
|
|
2287
|
-
const
|
|
2314
|
+
const ni = 34028234663852886e22, ii = -34028234663852886e22, ai = 4294967295, oi = 2147483647, si = -2147483648;
|
|
2288
2315
|
class ue {
|
|
2289
2316
|
constructor(e = rr().encodeUtf8) {
|
|
2290
2317
|
this.encodeUtf8 = e, this.stack = [], this.chunks = [], this.buf = [];
|
|
@@ -2349,7 +2376,7 @@ class ue {
|
|
|
2349
2376
|
* Write a `int32` value, a signed 32 bit varint.
|
|
2350
2377
|
*/
|
|
2351
2378
|
int32(e) {
|
|
2352
|
-
return
|
|
2379
|
+
return Ve(e), Ct(e, this.buf), this;
|
|
2353
2380
|
}
|
|
2354
2381
|
/**
|
|
2355
2382
|
* Write a `bool` value, a variant.
|
|
@@ -2374,7 +2401,7 @@ class ue {
|
|
|
2374
2401
|
* Write a `float` value, 32-bit floating point number.
|
|
2375
2402
|
*/
|
|
2376
2403
|
float(e) {
|
|
2377
|
-
|
|
2404
|
+
li(e);
|
|
2378
2405
|
let t = new Uint8Array(4);
|
|
2379
2406
|
return new DataView(t.buffer).setFloat32(0, e, !0), this.raw(t);
|
|
2380
2407
|
}
|
|
@@ -2397,7 +2424,7 @@ class ue {
|
|
|
2397
2424
|
* Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
|
|
2398
2425
|
*/
|
|
2399
2426
|
sfixed32(e) {
|
|
2400
|
-
|
|
2427
|
+
Ve(e);
|
|
2401
2428
|
let t = new Uint8Array(4);
|
|
2402
2429
|
return new DataView(t.buffer).setInt32(0, e, !0), this.raw(t);
|
|
2403
2430
|
}
|
|
@@ -2405,47 +2432,47 @@ class ue {
|
|
|
2405
2432
|
* Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
|
|
2406
2433
|
*/
|
|
2407
2434
|
sint32(e) {
|
|
2408
|
-
return
|
|
2435
|
+
return Ve(e), e = (e << 1 ^ e >> 31) >>> 0, Ct(e, this.buf), this;
|
|
2409
2436
|
}
|
|
2410
2437
|
/**
|
|
2411
2438
|
* Write a `fixed64` value, a signed, fixed-length 64-bit integer.
|
|
2412
2439
|
*/
|
|
2413
2440
|
sfixed64(e) {
|
|
2414
|
-
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);
|
|
2415
2442
|
return n.setInt32(0, i.lo, !0), n.setInt32(4, i.hi, !0), this.raw(t);
|
|
2416
2443
|
}
|
|
2417
2444
|
/**
|
|
2418
2445
|
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
|
|
2419
2446
|
*/
|
|
2420
2447
|
fixed64(e) {
|
|
2421
|
-
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);
|
|
2422
2449
|
return n.setInt32(0, i.lo, !0), n.setInt32(4, i.hi, !0), this.raw(t);
|
|
2423
2450
|
}
|
|
2424
2451
|
/**
|
|
2425
2452
|
* Write a `int64` value, a signed 64-bit varint.
|
|
2426
2453
|
*/
|
|
2427
2454
|
int64(e) {
|
|
2428
|
-
let t =
|
|
2429
|
-
return
|
|
2455
|
+
let t = K.enc(e);
|
|
2456
|
+
return Ue(t.lo, t.hi, this.buf), this;
|
|
2430
2457
|
}
|
|
2431
2458
|
/**
|
|
2432
2459
|
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
2433
2460
|
*/
|
|
2434
2461
|
sint64(e) {
|
|
2435
|
-
const t =
|
|
2436
|
-
return
|
|
2462
|
+
const t = K.enc(e), n = t.hi >> 31, i = t.lo << 1 ^ n, a = (t.hi << 1 | t.lo >>> 31) ^ n;
|
|
2463
|
+
return Ue(i, a, this.buf), this;
|
|
2437
2464
|
}
|
|
2438
2465
|
/**
|
|
2439
2466
|
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
2440
2467
|
*/
|
|
2441
2468
|
uint64(e) {
|
|
2442
|
-
const t =
|
|
2443
|
-
return
|
|
2469
|
+
const t = K.uEnc(e);
|
|
2470
|
+
return Ue(t.lo, t.hi, this.buf), this;
|
|
2444
2471
|
}
|
|
2445
2472
|
}
|
|
2446
|
-
class
|
|
2473
|
+
class N {
|
|
2447
2474
|
constructor(e, t = rr().decodeUtf8) {
|
|
2448
|
-
this.decodeUtf8 = t, this.varint64 =
|
|
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);
|
|
2449
2476
|
}
|
|
2450
2477
|
/**
|
|
2451
2478
|
* Reads a tag - field number and wire type.
|
|
@@ -2518,20 +2545,20 @@ class O {
|
|
|
2518
2545
|
* Read a `int64` field, a signed 64-bit varint.
|
|
2519
2546
|
*/
|
|
2520
2547
|
int64() {
|
|
2521
|
-
return
|
|
2548
|
+
return K.dec(...this.varint64());
|
|
2522
2549
|
}
|
|
2523
2550
|
/**
|
|
2524
2551
|
* Read a `uint64` field, an unsigned 64-bit varint.
|
|
2525
2552
|
*/
|
|
2526
2553
|
uint64() {
|
|
2527
|
-
return
|
|
2554
|
+
return K.uDec(...this.varint64());
|
|
2528
2555
|
}
|
|
2529
2556
|
/**
|
|
2530
2557
|
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
|
2531
2558
|
*/
|
|
2532
2559
|
sint64() {
|
|
2533
2560
|
let [e, t] = this.varint64(), n = -(e & 1);
|
|
2534
|
-
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);
|
|
2535
2562
|
}
|
|
2536
2563
|
/**
|
|
2537
2564
|
* Read a `bool` field, a variant.
|
|
@@ -2556,13 +2583,13 @@ class O {
|
|
|
2556
2583
|
* Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
|
|
2557
2584
|
*/
|
|
2558
2585
|
fixed64() {
|
|
2559
|
-
return
|
|
2586
|
+
return K.uDec(this.sfixed32(), this.sfixed32());
|
|
2560
2587
|
}
|
|
2561
2588
|
/**
|
|
2562
2589
|
* Read a `fixed64` field, a signed, fixed-length 64-bit integer.
|
|
2563
2590
|
*/
|
|
2564
2591
|
sfixed64() {
|
|
2565
|
-
return
|
|
2592
|
+
return K.dec(this.sfixed32(), this.sfixed32());
|
|
2566
2593
|
}
|
|
2567
2594
|
/**
|
|
2568
2595
|
* Read a `float` field, 32-bit floating point number.
|
|
@@ -2590,12 +2617,12 @@ class O {
|
|
|
2590
2617
|
return this.decodeUtf8(this.bytes());
|
|
2591
2618
|
}
|
|
2592
2619
|
}
|
|
2593
|
-
function
|
|
2620
|
+
function Ve(r) {
|
|
2594
2621
|
if (typeof r == "string")
|
|
2595
2622
|
r = Number(r);
|
|
2596
2623
|
else if (typeof r != "number")
|
|
2597
2624
|
throw new Error("invalid int32: " + typeof r);
|
|
2598
|
-
if (!Number.isInteger(r) || r >
|
|
2625
|
+
if (!Number.isInteger(r) || r > oi || r < si)
|
|
2599
2626
|
throw new Error("invalid int32: " + r);
|
|
2600
2627
|
}
|
|
2601
2628
|
function xt(r) {
|
|
@@ -2603,21 +2630,21 @@ function xt(r) {
|
|
|
2603
2630
|
r = Number(r);
|
|
2604
2631
|
else if (typeof r != "number")
|
|
2605
2632
|
throw new Error("invalid uint32: " + typeof r);
|
|
2606
|
-
if (!Number.isInteger(r) || r >
|
|
2633
|
+
if (!Number.isInteger(r) || r > ai || r < 0)
|
|
2607
2634
|
throw new Error("invalid uint32: " + r);
|
|
2608
2635
|
}
|
|
2609
|
-
function
|
|
2636
|
+
function li(r) {
|
|
2610
2637
|
if (typeof r == "string") {
|
|
2611
2638
|
const e = r;
|
|
2612
2639
|
if (r = Number(r), Number.isNaN(r) && e !== "NaN")
|
|
2613
2640
|
throw new Error("invalid float32: " + e);
|
|
2614
2641
|
} else if (typeof r != "number")
|
|
2615
2642
|
throw new Error("invalid float32: " + typeof r);
|
|
2616
|
-
if (Number.isFinite(r) && (r >
|
|
2643
|
+
if (Number.isFinite(r) && (r > ni || r < ii))
|
|
2617
2644
|
throw new Error("invalid float32: " + r);
|
|
2618
2645
|
}
|
|
2619
|
-
var
|
|
2620
|
-
function
|
|
2646
|
+
var Ee = /* @__PURE__ */ ((r) => (r[r.MESSAGE_UNSPECIFIED = 0] = "MESSAGE_UNSPECIFIED", r[r.MESSAGE_ERROR = 2] = "MESSAGE_ERROR", r[r.MESSAGE_SERVER_RESPONSE_ANIMATION = 1004] = "MESSAGE_SERVER_RESPONSE_ANIMATION", r[r.MESSAGE_CLIENT_AUDIO_INPUT = 2003] = "MESSAGE_CLIENT_AUDIO_INPUT", r[r.UNRECOGNIZED = -1] = "UNRECOGNIZED", r))(Ee || {});
|
|
2647
|
+
function ci(r) {
|
|
2621
2648
|
switch (r) {
|
|
2622
2649
|
case 0:
|
|
2623
2650
|
case "MESSAGE_UNSPECIFIED":
|
|
@@ -2637,7 +2664,7 @@ function li(r) {
|
|
|
2637
2664
|
return -1;
|
|
2638
2665
|
}
|
|
2639
2666
|
}
|
|
2640
|
-
function
|
|
2667
|
+
function ui(r) {
|
|
2641
2668
|
switch (r) {
|
|
2642
2669
|
case 0:
|
|
2643
2670
|
return "MESSAGE_UNSPECIFIED";
|
|
@@ -2660,7 +2687,7 @@ const he = {
|
|
|
2660
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;
|
|
2661
2688
|
},
|
|
2662
2689
|
decode(r, e) {
|
|
2663
|
-
const t = r instanceof
|
|
2690
|
+
const t = r instanceof N ? r : new N(r);
|
|
2664
2691
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2665
2692
|
const i = Pt();
|
|
2666
2693
|
for (; t.pos < n; ) {
|
|
@@ -2693,14 +2720,14 @@ const he = {
|
|
|
2693
2720
|
},
|
|
2694
2721
|
fromJSON(r) {
|
|
2695
2722
|
return {
|
|
2696
|
-
reqId:
|
|
2697
|
-
audio:
|
|
2698
|
-
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
|
|
2699
2726
|
};
|
|
2700
2727
|
},
|
|
2701
2728
|
toJSON(r) {
|
|
2702
2729
|
const e = {};
|
|
2703
|
-
return r.reqId !== "" && (e.reqId = r.reqId), r.audio.length !== 0 && (e.audio =
|
|
2730
|
+
return r.reqId !== "" && (e.reqId = r.reqId), r.audio.length !== 0 && (e.audio = hi(r.audio)), r.end !== !1 && (e.end = r.end), e;
|
|
2704
2731
|
},
|
|
2705
2732
|
create(r) {
|
|
2706
2733
|
return he.fromPartial(r ?? {});
|
|
@@ -2739,7 +2766,7 @@ const fe = {
|
|
|
2739
2766
|
return e.join(), e;
|
|
2740
2767
|
},
|
|
2741
2768
|
decode(r, e) {
|
|
2742
|
-
const t = r instanceof
|
|
2769
|
+
const t = r instanceof N ? r : new N(r);
|
|
2743
2770
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2744
2771
|
const i = It();
|
|
2745
2772
|
for (; t.pos < n; ) {
|
|
@@ -2878,7 +2905,7 @@ const me = {
|
|
|
2878
2905
|
return e;
|
|
2879
2906
|
},
|
|
2880
2907
|
decode(r, e) {
|
|
2881
|
-
const t = r instanceof
|
|
2908
|
+
const t = r instanceof N ? r : new N(r);
|
|
2882
2909
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2883
2910
|
const i = kt();
|
|
2884
2911
|
for (; t.pos < n; ) {
|
|
@@ -2924,7 +2951,7 @@ const ge = {
|
|
|
2924
2951
|
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && me.encode(r.animation, e.uint32(18).fork()).join(), e;
|
|
2925
2952
|
},
|
|
2926
2953
|
decode(r, e) {
|
|
2927
|
-
const t = r instanceof
|
|
2954
|
+
const t = r instanceof N ? r : new N(r);
|
|
2928
2955
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2929
2956
|
const i = Mt();
|
|
2930
2957
|
for (; t.pos < n; ) {
|
|
@@ -2951,8 +2978,8 @@ const ge = {
|
|
|
2951
2978
|
},
|
|
2952
2979
|
fromJSON(r) {
|
|
2953
2980
|
return {
|
|
2954
|
-
reqId:
|
|
2955
|
-
animation:
|
|
2981
|
+
reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
2982
|
+
animation: $(r.animation) ? me.fromJSON(r.animation) : void 0
|
|
2956
2983
|
};
|
|
2957
2984
|
},
|
|
2958
2985
|
toJSON(r) {
|
|
@@ -2975,7 +3002,7 @@ const pe = {
|
|
|
2975
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;
|
|
2976
3003
|
},
|
|
2977
3004
|
decode(r, e) {
|
|
2978
|
-
const t = r instanceof
|
|
3005
|
+
const t = r instanceof N ? r : new N(r);
|
|
2979
3006
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2980
3007
|
const i = Ft();
|
|
2981
3008
|
for (; t.pos < n; ) {
|
|
@@ -3008,9 +3035,9 @@ const pe = {
|
|
|
3008
3035
|
},
|
|
3009
3036
|
fromJSON(r) {
|
|
3010
3037
|
return {
|
|
3011
|
-
reqId:
|
|
3012
|
-
code:
|
|
3013
|
-
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) : ""
|
|
3014
3041
|
};
|
|
3015
3042
|
},
|
|
3016
3043
|
toJSON(r) {
|
|
@@ -3028,12 +3055,12 @@ const pe = {
|
|
|
3028
3055
|
function Rt() {
|
|
3029
3056
|
return { type: 0, error: void 0, serverResponseAnimation: void 0, clientAudioInput: void 0 };
|
|
3030
3057
|
}
|
|
3031
|
-
const
|
|
3058
|
+
const He = {
|
|
3032
3059
|
encode(r, e = new ue()) {
|
|
3033
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;
|
|
3034
3061
|
},
|
|
3035
3062
|
decode(r, e) {
|
|
3036
|
-
const t = r instanceof
|
|
3063
|
+
const t = r instanceof N ? r : new N(r);
|
|
3037
3064
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
3038
3065
|
const i = Rt();
|
|
3039
3066
|
for (; t.pos < n; ) {
|
|
@@ -3072,40 +3099,40 @@ const Ge = {
|
|
|
3072
3099
|
},
|
|
3073
3100
|
fromJSON(r) {
|
|
3074
3101
|
return {
|
|
3075
|
-
type:
|
|
3076
|
-
error:
|
|
3077
|
-
serverResponseAnimation:
|
|
3078
|
-
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
|
|
3079
3106
|
};
|
|
3080
3107
|
},
|
|
3081
3108
|
toJSON(r) {
|
|
3082
3109
|
const e = {};
|
|
3083
|
-
return r.type !== 0 && (e.type =
|
|
3110
|
+
return r.type !== 0 && (e.type = ui(r.type)), r.error !== void 0 && (e.error = pe.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = ge.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = he.toJSON(r.clientAudioInput)), e;
|
|
3084
3111
|
},
|
|
3085
3112
|
create(r) {
|
|
3086
|
-
return
|
|
3113
|
+
return He.fromPartial(r ?? {});
|
|
3087
3114
|
},
|
|
3088
3115
|
fromPartial(r) {
|
|
3089
3116
|
const e = Rt();
|
|
3090
3117
|
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? pe.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? ge.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? he.fromPartial(r.clientAudioInput) : void 0, e;
|
|
3091
3118
|
}
|
|
3092
3119
|
};
|
|
3093
|
-
function
|
|
3120
|
+
function di(r) {
|
|
3094
3121
|
const e = globalThis.atob(r), t = new Uint8Array(e.length);
|
|
3095
3122
|
for (let n = 0; n < e.length; ++n)
|
|
3096
3123
|
t[n] = e.charCodeAt(n);
|
|
3097
3124
|
return t;
|
|
3098
3125
|
}
|
|
3099
|
-
function
|
|
3126
|
+
function hi(r) {
|
|
3100
3127
|
const e = [];
|
|
3101
3128
|
return r.forEach((t) => {
|
|
3102
3129
|
e.push(globalThis.String.fromCharCode(t));
|
|
3103
3130
|
}), globalThis.btoa(e.join(""));
|
|
3104
3131
|
}
|
|
3105
|
-
function
|
|
3132
|
+
function $(r) {
|
|
3106
3133
|
return r != null;
|
|
3107
3134
|
}
|
|
3108
|
-
let
|
|
3135
|
+
let fi = (r) => crypto.getRandomValues(new Uint8Array(r)), mi = (r, e, t) => {
|
|
3109
3136
|
let n = (2 << Math.log2(r.length - 1)) - 1, i = -~(1.6 * n * e / r.length);
|
|
3110
3137
|
return (a = e) => {
|
|
3111
3138
|
let o = "";
|
|
@@ -3115,13 +3142,13 @@ let hi = (r) => crypto.getRandomValues(new Uint8Array(r)), fi = (r, e, t) => {
|
|
|
3115
3142
|
if (o += r[s[l] & n] || "", o.length >= a) return o;
|
|
3116
3143
|
}
|
|
3117
3144
|
};
|
|
3118
|
-
},
|
|
3119
|
-
const
|
|
3120
|
-
function
|
|
3121
|
-
const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), i = String(r.getUTCHours()).padStart(2, "0"), a = String(r.getUTCMinutes()).padStart(2, "0"), o = String(r.getUTCSeconds()).padStart(2, "0"), s = `${e}${t}${n}${i}${a}${o}`, l =
|
|
3145
|
+
}, gi = (r, e = 21) => mi(r, e | 0, fi);
|
|
3146
|
+
const pi = gi("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12);
|
|
3147
|
+
function vi() {
|
|
3148
|
+
const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), i = String(r.getUTCHours()).padStart(2, "0"), a = String(r.getUTCMinutes()).padStart(2, "0"), o = String(r.getUTCSeconds()).padStart(2, "0"), s = `${e}${t}${n}${i}${a}${o}`, l = pi();
|
|
3122
3149
|
return `${s}_${l}`;
|
|
3123
3150
|
}
|
|
3124
|
-
class
|
|
3151
|
+
class wi {
|
|
3125
3152
|
constructor() {
|
|
3126
3153
|
d(this, "events", /* @__PURE__ */ new Map());
|
|
3127
3154
|
}
|
|
@@ -3141,7 +3168,7 @@ class vi {
|
|
|
3141
3168
|
e ? this.events.delete(e) : this.events.clear();
|
|
3142
3169
|
}
|
|
3143
3170
|
}
|
|
3144
|
-
class
|
|
3171
|
+
class yi extends wi {
|
|
3145
3172
|
constructor(t) {
|
|
3146
3173
|
super();
|
|
3147
3174
|
d(this, "wsUrl");
|
|
@@ -3171,7 +3198,7 @@ class wi extends vi {
|
|
|
3171
3198
|
try {
|
|
3172
3199
|
this.isConnecting = !0, this.currentCharacterId = t;
|
|
3173
3200
|
const n = this.buildWebSocketUrl(t);
|
|
3174
|
-
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", {
|
|
3175
3202
|
characterId: t,
|
|
3176
3203
|
event: "connect_success",
|
|
3177
3204
|
url: n
|
|
@@ -3179,7 +3206,7 @@ class wi extends vi {
|
|
|
3179
3206
|
} catch (n) {
|
|
3180
3207
|
this.isConnecting = !1;
|
|
3181
3208
|
const i = n instanceof Error ? n.message : String(n);
|
|
3182
|
-
throw h.error("[AnimationWebSocketClient] Connection failed:", i),
|
|
3209
|
+
throw h.error("[AnimationWebSocketClient] Connection failed:", i), A.logEvent("character_animation_service", "error", {
|
|
3183
3210
|
characterId: t,
|
|
3184
3211
|
event: "connect_failed",
|
|
3185
3212
|
reason: i
|
|
@@ -3200,19 +3227,19 @@ class wi extends vi {
|
|
|
3200
3227
|
return h.error("[AnimationWebSocketClient] WebSocket not connected"), !1;
|
|
3201
3228
|
try {
|
|
3202
3229
|
const a = {
|
|
3203
|
-
type:
|
|
3230
|
+
type: Ee.MESSAGE_CLIENT_AUDIO_INPUT,
|
|
3204
3231
|
clientAudioInput: {
|
|
3205
3232
|
reqId: t,
|
|
3206
3233
|
audio: new Uint8Array(n),
|
|
3207
3234
|
end: i
|
|
3208
3235
|
}
|
|
3209
3236
|
}, o = new ue();
|
|
3210
|
-
|
|
3237
|
+
He.encode(a, o);
|
|
3211
3238
|
const s = o.finish();
|
|
3212
3239
|
return this.ws.send(s), !0;
|
|
3213
3240
|
} catch (a) {
|
|
3214
3241
|
const o = a instanceof Error ? a.message : String(a);
|
|
3215
|
-
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", {
|
|
3216
3243
|
characterId: this.currentCharacterId,
|
|
3217
3244
|
event: "send_audio_failed",
|
|
3218
3245
|
reqId: t,
|
|
@@ -3225,7 +3252,7 @@ class wi extends vi {
|
|
|
3225
3252
|
* 使用统一的 ReqID 生成规则:YYYYMMDDHHmmss_nanoid
|
|
3226
3253
|
*/
|
|
3227
3254
|
generateReqId() {
|
|
3228
|
-
return
|
|
3255
|
+
return vi();
|
|
3229
3256
|
}
|
|
3230
3257
|
/**
|
|
3231
3258
|
* 获取连接状态
|
|
@@ -3251,19 +3278,19 @@ class wi extends vi {
|
|
|
3251
3278
|
this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"), n();
|
|
3252
3279
|
}, this.ws.onmessage = (a) => {
|
|
3253
3280
|
a.data instanceof ArrayBuffer ? this.handleMessage(a.data) : a.data instanceof Blob ? a.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((o) => {
|
|
3254
|
-
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", {
|
|
3255
3282
|
characterId: this.currentCharacterId,
|
|
3256
3283
|
event: "decode_blob_failed",
|
|
3257
3284
|
reason: o instanceof Error ? o.message : String(o)
|
|
3258
3285
|
}), this.emit("error", o);
|
|
3259
3286
|
}) : h.warn("[AnimationWebSocketClient] Received non-binary data:", typeof a.data);
|
|
3260
3287
|
}, this.ws.onerror = (a) => {
|
|
3261
|
-
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", a),
|
|
3288
|
+
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", a), A.logEvent("character_animation_service", "error", {
|
|
3262
3289
|
characterId: this.currentCharacterId,
|
|
3263
3290
|
event: "websocket_error"
|
|
3264
3291
|
}), this.emit("error", new Error("WebSocket error")), !this.isManuallyDisconnected && this.currentRetryCount < this.reconnectAttempts && this.scheduleReconnect();
|
|
3265
3292
|
}, this.ws.onclose = (a) => {
|
|
3266
|
-
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", {
|
|
3267
3294
|
characterId: this.currentCharacterId,
|
|
3268
3295
|
event: "service_restart",
|
|
3269
3296
|
reason: a.reason || "service restart"
|
|
@@ -3276,9 +3303,9 @@ class wi extends vi {
|
|
|
3276
3303
|
}
|
|
3277
3304
|
handleMessage(t) {
|
|
3278
3305
|
try {
|
|
3279
|
-
const n = new
|
|
3306
|
+
const n = new N(new Uint8Array(t)), i = He.decode(n);
|
|
3280
3307
|
if (i.error) {
|
|
3281
|
-
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", {
|
|
3282
3309
|
characterId: this.currentCharacterId,
|
|
3283
3310
|
event: "server_error",
|
|
3284
3311
|
reqId: i.error.reqId,
|
|
@@ -3287,8 +3314,8 @@ class wi extends vi {
|
|
|
3287
3314
|
}), this.emit("error", new Error(i.error.reason || "Server error"));
|
|
3288
3315
|
return;
|
|
3289
3316
|
}
|
|
3290
|
-
if (i.type ===
|
|
3291
|
-
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"),
|
|
3317
|
+
if (i.type === Ee.MESSAGE_ERROR) {
|
|
3318
|
+
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), A.logEvent("character_animation_service", "warning", {
|
|
3292
3319
|
characterId: this.currentCharacterId,
|
|
3293
3320
|
event: "message_error_without_payload"
|
|
3294
3321
|
}), this.emit("error", new Error("Server returned error message without error details"));
|
|
@@ -3297,7 +3324,7 @@ class wi extends vi {
|
|
|
3297
3324
|
this.emit("message", i);
|
|
3298
3325
|
} catch (n) {
|
|
3299
3326
|
const i = n instanceof Error ? n.message : String(n);
|
|
3300
|
-
h.error("[AnimationWebSocketClient] Failed to decode message:", i),
|
|
3327
|
+
h.error("[AnimationWebSocketClient] Failed to decode message:", i), A.logEvent("character_animation_service", "error", {
|
|
3301
3328
|
characterId: this.currentCharacterId,
|
|
3302
3329
|
event: "decode_failed",
|
|
3303
3330
|
reason: i
|
|
@@ -3314,36 +3341,36 @@ class wi extends vi {
|
|
|
3314
3341
|
}, t);
|
|
3315
3342
|
}
|
|
3316
3343
|
}
|
|
3317
|
-
class
|
|
3344
|
+
class Si {
|
|
3318
3345
|
constructor(e) {
|
|
3319
3346
|
d(this, "wsClient");
|
|
3320
3347
|
d(this, "dataController");
|
|
3321
3348
|
// 组合播放层
|
|
3322
3349
|
d(this, "currentReqId", null);
|
|
3323
3350
|
d(this, "hasSentEnd", !1);
|
|
3324
|
-
d(this, "audioBytesPerSecond",
|
|
3351
|
+
d(this, "audioBytesPerSecond", M.audio.sampleRate * 2);
|
|
3325
3352
|
d(this, "audioMetrics", this.createAudioMetrics());
|
|
3326
3353
|
this.dataController = e;
|
|
3327
|
-
const t =
|
|
3328
|
-
this.wsClient = new
|
|
3354
|
+
const t = A.getEnvironmentConfig();
|
|
3355
|
+
this.wsClient = new yi({
|
|
3329
3356
|
wsUrl: t.driveningressWsUrl,
|
|
3330
3357
|
reconnectAttempts: 5,
|
|
3331
3358
|
debug: !1,
|
|
3332
|
-
jwtToken:
|
|
3359
|
+
jwtToken: A.sessionToken || void 0
|
|
3333
3360
|
}), this.setupWebSocketListeners();
|
|
3334
3361
|
}
|
|
3335
3362
|
/**
|
|
3336
3363
|
* 连接服务
|
|
3337
3364
|
*/
|
|
3338
3365
|
async connect(e) {
|
|
3339
|
-
await this.wsClient.connect(e);
|
|
3366
|
+
this.setupWebSocketListeners(), await this.wsClient.connect(e);
|
|
3340
3367
|
}
|
|
3341
3368
|
/**
|
|
3342
3369
|
* 发送音频数据到服务器
|
|
3343
3370
|
*/
|
|
3344
3371
|
sendAudioData(e, t) {
|
|
3345
3372
|
var s, l;
|
|
3346
|
-
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", {
|
|
3347
3374
|
characterId: this.dataController.getAvatarId(),
|
|
3348
3375
|
event: "conversation_started",
|
|
3349
3376
|
reqId: this.currentReqId
|
|
@@ -3353,7 +3380,7 @@ class yi {
|
|
|
3353
3380
|
n.startTimestamp === 0 && (n.startTimestamp = Date.now(), i = !0), n.accumulatedBytes += e.byteLength;
|
|
3354
3381
|
const a = n.accumulatedBytes / this.audioBytesPerSecond;
|
|
3355
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)) {
|
|
3356
|
-
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", {
|
|
3357
3384
|
characterId: this.dataController.getAvatarId(),
|
|
3358
3385
|
event: "send_audio_failed",
|
|
3359
3386
|
reqId: this.currentReqId
|
|
@@ -3384,31 +3411,31 @@ class yi {
|
|
|
3384
3411
|
* 设置 WebSocket 事件监听器
|
|
3385
3412
|
*/
|
|
3386
3413
|
setupWebSocketListeners() {
|
|
3387
|
-
this.wsClient.on("connected",
|
|
3414
|
+
this.wsClient.on("connected", () => {
|
|
3388
3415
|
var e, t;
|
|
3389
|
-
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", {
|
|
3390
3417
|
characterId: this.dataController.getAvatarId(),
|
|
3391
3418
|
event: "connected"
|
|
3392
3419
|
});
|
|
3393
3420
|
}), this.wsClient.on("disconnected", () => {
|
|
3394
3421
|
var e, t;
|
|
3395
|
-
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", {
|
|
3396
3423
|
characterId: this.dataController.getAvatarId(),
|
|
3397
3424
|
event: "disconnected"
|
|
3398
3425
|
});
|
|
3399
3426
|
}), this.wsClient.on("reconnecting", () => {
|
|
3400
|
-
|
|
3427
|
+
A.logEvent("character_animation_service", "info", {
|
|
3401
3428
|
characterId: this.dataController.getAvatarId(),
|
|
3402
3429
|
event: "reconnecting"
|
|
3403
3430
|
});
|
|
3404
3431
|
}), this.wsClient.on("error", (e) => {
|
|
3405
3432
|
var n, i, a, o;
|
|
3406
3433
|
const t = e instanceof Error ? e.message : String(e);
|
|
3407
|
-
h.error("[NetworkLayer] WebSocket error:", t),
|
|
3434
|
+
h.error("[NetworkLayer] WebSocket error:", t), A.logEvent("character_animation_service", "error", {
|
|
3408
3435
|
characterId: this.dataController.getAvatarId(),
|
|
3409
3436
|
event: "websocket_error",
|
|
3410
3437
|
reason: t
|
|
3411
|
-
}), (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);
|
|
3412
3439
|
}), this.wsClient.on("message", (e) => {
|
|
3413
3440
|
this.handleMessage(e);
|
|
3414
3441
|
});
|
|
@@ -3419,16 +3446,16 @@ class yi {
|
|
|
3419
3446
|
handleMessage(e) {
|
|
3420
3447
|
try {
|
|
3421
3448
|
switch (e.type) {
|
|
3422
|
-
case
|
|
3449
|
+
case Ee.MESSAGE_SERVER_RESPONSE_ANIMATION:
|
|
3423
3450
|
this.handleAnimationMessage(e);
|
|
3424
3451
|
break;
|
|
3425
|
-
case
|
|
3452
|
+
case Ee.MESSAGE_ERROR:
|
|
3426
3453
|
this.handleErrorMessage(e);
|
|
3427
3454
|
break;
|
|
3428
3455
|
}
|
|
3429
3456
|
} catch (t) {
|
|
3430
3457
|
const n = t instanceof Error ? t.message : String(t);
|
|
3431
|
-
h.error("[NetworkLayer] Failed to handle message:", n),
|
|
3458
|
+
h.error("[NetworkLayer] Failed to handle message:", n), A.logEvent("character_manager", "error", {
|
|
3432
3459
|
characterId: this.dataController.getAvatarId(),
|
|
3433
3460
|
event: "handle_message_failed",
|
|
3434
3461
|
reason: n
|
|
@@ -3445,7 +3472,7 @@ class yi {
|
|
|
3445
3472
|
}
|
|
3446
3473
|
const { reqId: t, animation: n } = e.serverResponseAnimation;
|
|
3447
3474
|
if (!this.currentReqId || t !== this.currentReqId) {
|
|
3448
|
-
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", {
|
|
3449
3476
|
characterId: this.dataController.getAvatarId(),
|
|
3450
3477
|
event: "animation_reqid_mismatch",
|
|
3451
3478
|
expectedReqId: this.currentReqId,
|
|
@@ -3457,7 +3484,7 @@ class yi {
|
|
|
3457
3484
|
const i = n.keyframes;
|
|
3458
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));
|
|
3459
3486
|
} else
|
|
3460
|
-
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", {
|
|
3461
3488
|
characterId: this.dataController.getAvatarId(),
|
|
3462
3489
|
event: "animation_empty_keyframes",
|
|
3463
3490
|
reqId: t
|
|
@@ -3469,13 +3496,13 @@ class yi {
|
|
|
3469
3496
|
handleErrorMessage(e) {
|
|
3470
3497
|
var n, i, a, o;
|
|
3471
3498
|
if (!e.error) {
|
|
3472
|
-
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", {
|
|
3473
3500
|
characterId: this.dataController.getAvatarId(),
|
|
3474
3501
|
event: "message_error_with_payload"
|
|
3475
3502
|
}), this.handleAnimationMessage(e));
|
|
3476
3503
|
return;
|
|
3477
3504
|
}
|
|
3478
|
-
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", {
|
|
3479
3506
|
characterId: this.dataController.getAvatarId(),
|
|
3480
3507
|
event: "server_error",
|
|
3481
3508
|
reqId: e.error.reqId,
|
|
@@ -3483,7 +3510,7 @@ class yi {
|
|
|
3483
3510
|
reason: e.error.reason
|
|
3484
3511
|
});
|
|
3485
3512
|
const t = ((n = e.error.code) == null ? void 0 : n.toString().toLowerCase()) ?? "";
|
|
3486
|
-
(t.includes("unauth") || t === "401") &&
|
|
3513
|
+
(t.includes("unauth") || t === "401") && A.logEvent("sdk_verify", "error", {
|
|
3487
3514
|
characterId: this.dataController.getAvatarId(),
|
|
3488
3515
|
reqId: e.error.reqId,
|
|
3489
3516
|
reason: e.error.reason
|
|
@@ -3516,7 +3543,7 @@ class yi {
|
|
|
3516
3543
|
* 上报音频指标
|
|
3517
3544
|
*/
|
|
3518
3545
|
reportAudioMetrics(e) {
|
|
3519
|
-
!e || this.audioMetrics.startTimestamp === 0 ||
|
|
3546
|
+
!e || this.audioMetrics.startTimestamp === 0 || A.logEvent("send_audio_measure", "info", {
|
|
3520
3547
|
reqId: e,
|
|
3521
3548
|
start: this.audioMetrics.startTimestamp,
|
|
3522
3549
|
tap2: this.audioMetrics.tap2Timestamp,
|
|
@@ -3539,7 +3566,7 @@ class Ai {
|
|
|
3539
3566
|
d(this, "isPlaying", !1);
|
|
3540
3567
|
// ========== State Management ==========
|
|
3541
3568
|
d(this, "isConnected", !1);
|
|
3542
|
-
d(this, "currentState",
|
|
3569
|
+
d(this, "currentState", T.idle);
|
|
3543
3570
|
// ========== Event System ==========
|
|
3544
3571
|
d(this, "onConnectionState", null);
|
|
3545
3572
|
d(this, "onAvatarState", null);
|
|
@@ -3551,54 +3578,54 @@ class Ai {
|
|
|
3551
3578
|
// ========== Playback Loop ==========
|
|
3552
3579
|
d(this, "playbackLoopId", null);
|
|
3553
3580
|
d(this, "lastRenderedFrameIndex", -1);
|
|
3554
|
-
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ??
|
|
3581
|
+
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? ke.network, this.playbackMode === ke.network && (this.networkLayer = new Si(this));
|
|
3555
3582
|
}
|
|
3556
|
-
// ==========
|
|
3583
|
+
// ========== Internal Accessors (for NetworkLayer and AvatarView) ==========
|
|
3557
3584
|
/**
|
|
3558
|
-
*
|
|
3585
|
+
* Get Avatar ID (for NetworkLayer use)
|
|
3559
3586
|
* @internal
|
|
3560
3587
|
*/
|
|
3561
3588
|
getAvatarId() {
|
|
3562
3589
|
return this.avatar.id;
|
|
3563
3590
|
}
|
|
3564
3591
|
/**
|
|
3565
|
-
*
|
|
3592
|
+
* Get playback state (for NetworkLayer use)
|
|
3566
3593
|
* @internal
|
|
3567
3594
|
*/
|
|
3568
3595
|
getIsPlaying() {
|
|
3569
3596
|
return this.isPlaying;
|
|
3570
3597
|
}
|
|
3571
3598
|
/**
|
|
3572
|
-
*
|
|
3599
|
+
* Set connection state (for NetworkLayer use)
|
|
3573
3600
|
* @internal
|
|
3574
3601
|
*/
|
|
3575
3602
|
setConnected(e) {
|
|
3576
3603
|
this.isConnected = e;
|
|
3577
3604
|
}
|
|
3578
3605
|
/**
|
|
3579
|
-
*
|
|
3606
|
+
* Get connection state
|
|
3580
3607
|
* @internal
|
|
3581
3608
|
*/
|
|
3582
3609
|
get connected() {
|
|
3583
3610
|
return this.isConnected;
|
|
3584
3611
|
}
|
|
3585
3612
|
/**
|
|
3586
|
-
*
|
|
3613
|
+
* Get current state
|
|
3587
3614
|
* @internal
|
|
3588
3615
|
*/
|
|
3589
3616
|
get state() {
|
|
3590
3617
|
return this.currentState;
|
|
3591
3618
|
}
|
|
3592
3619
|
/**
|
|
3593
|
-
*
|
|
3620
|
+
* Get animation player instance
|
|
3594
3621
|
* @internal
|
|
3595
3622
|
*/
|
|
3596
3623
|
getAnimationPlayer() {
|
|
3597
3624
|
return this.animationPlayer;
|
|
3598
3625
|
}
|
|
3599
|
-
// ==========
|
|
3626
|
+
// ========== Network Mode Interface ==========
|
|
3600
3627
|
/**
|
|
3601
|
-
*
|
|
3628
|
+
* Start service (network mode only)
|
|
3602
3629
|
*/
|
|
3603
3630
|
async start() {
|
|
3604
3631
|
if (!this.networkLayer)
|
|
@@ -3612,7 +3639,7 @@ class Ai {
|
|
|
3612
3639
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
3613
3640
|
} catch (e) {
|
|
3614
3641
|
const t = e instanceof Error ? e.message : String(e);
|
|
3615
|
-
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", {
|
|
3616
3643
|
characterId: this.avatar.id,
|
|
3617
3644
|
event: "streaming_player_init_failed",
|
|
3618
3645
|
reason: t
|
|
@@ -3622,31 +3649,31 @@ class Ai {
|
|
|
3622
3649
|
await this.networkLayer.connect(this.avatar.id);
|
|
3623
3650
|
}
|
|
3624
3651
|
/**
|
|
3625
|
-
*
|
|
3626
|
-
*
|
|
3652
|
+
* Send audio to server (network mode only)
|
|
3653
|
+
* Also cache to data layer for playback
|
|
3627
3654
|
*/
|
|
3628
3655
|
send(e, t = !1) {
|
|
3629
3656
|
var n, i;
|
|
3630
3657
|
if (!this.networkLayer || !this.isConnected) {
|
|
3631
|
-
(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", {
|
|
3632
3659
|
characterId: this.avatar.id,
|
|
3633
3660
|
event: "send_not_connected"
|
|
3634
3661
|
});
|
|
3635
3662
|
return;
|
|
3636
3663
|
}
|
|
3637
|
-
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);
|
|
3638
3665
|
}
|
|
3639
3666
|
/**
|
|
3640
|
-
*
|
|
3667
|
+
* Close service (network mode only)
|
|
3641
3668
|
*/
|
|
3642
3669
|
close() {
|
|
3643
3670
|
var e, t;
|
|
3644
|
-
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);
|
|
3645
3672
|
}
|
|
3646
|
-
// ==========
|
|
3673
|
+
// ========== External Data Mode Interface ==========
|
|
3647
3674
|
/**
|
|
3648
|
-
*
|
|
3649
|
-
*
|
|
3675
|
+
* Start playback (external data mode)
|
|
3676
|
+
* Must call this method first with initial data to start playback
|
|
3650
3677
|
*/
|
|
3651
3678
|
async play(e, t) {
|
|
3652
3679
|
if (!this.isPlaying) {
|
|
@@ -3658,67 +3685,93 @@ class Ai {
|
|
|
3658
3685
|
}
|
|
3659
3686
|
}
|
|
3660
3687
|
/**
|
|
3661
|
-
*
|
|
3662
|
-
*
|
|
3688
|
+
* Send audio data (external data mode)
|
|
3689
|
+
* Stream additional audio data after play()
|
|
3663
3690
|
*/
|
|
3664
3691
|
sendAudioChunk(e, t = !1) {
|
|
3665
3692
|
var n, i;
|
|
3666
|
-
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));
|
|
3667
3694
|
}
|
|
3668
3695
|
/**
|
|
3669
|
-
*
|
|
3670
|
-
*
|
|
3696
|
+
* Send animation keyframes (external data mode or network mode)
|
|
3697
|
+
* Stream additional animation data after play()
|
|
3671
3698
|
*/
|
|
3672
3699
|
sendKeyframes(e) {
|
|
3673
3700
|
this.currentKeyframes.length === 0 ? this.currentKeyframes = e : this.currentKeyframes.push(...e), this.emit("keyframesUpdate", this.currentKeyframes);
|
|
3674
3701
|
}
|
|
3675
|
-
// ==========
|
|
3702
|
+
// ========== Common Interface ==========
|
|
3676
3703
|
/**
|
|
3677
|
-
*
|
|
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
|
|
3678
3730
|
*/
|
|
3679
3731
|
interrupt() {
|
|
3680
3732
|
var e;
|
|
3681
|
-
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();
|
|
3682
3735
|
}
|
|
3683
3736
|
/**
|
|
3684
|
-
*
|
|
3737
|
+
* Clear all data and resources
|
|
3685
3738
|
*/
|
|
3686
3739
|
clear() {
|
|
3687
3740
|
var e, t;
|
|
3688
|
-
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);
|
|
3689
3742
|
}
|
|
3690
3743
|
/**
|
|
3691
|
-
*
|
|
3692
|
-
*
|
|
3744
|
+
* Dispose controller, clean up all callbacks to avoid memory leaks
|
|
3745
|
+
* Should be called when AvatarView.dispose()
|
|
3693
3746
|
* @internal
|
|
3694
3747
|
*/
|
|
3695
3748
|
dispose() {
|
|
3696
3749
|
this.onConnectionState = null, this.onAvatarState = null, this.onError = null, this.renderCallback = void 0, this.transitionCompleteCallback = void 0, this.eventListeners.clear();
|
|
3697
3750
|
}
|
|
3698
|
-
// ==========
|
|
3751
|
+
// ========== Internal Methods (for NetworkLayer and AvatarView use) ==========
|
|
3699
3752
|
/**
|
|
3700
|
-
*
|
|
3753
|
+
* Start streaming playback (internal method, called by NetworkLayer or play())
|
|
3701
3754
|
* @internal
|
|
3702
3755
|
*/
|
|
3703
3756
|
startStreamingPlayback() {
|
|
3704
3757
|
return this.startStreamingPlaybackInternal();
|
|
3705
3758
|
}
|
|
3706
3759
|
/**
|
|
3707
|
-
*
|
|
3760
|
+
* Set render callback (called by AvatarView)
|
|
3708
3761
|
* @internal
|
|
3709
3762
|
*/
|
|
3710
3763
|
setRenderCallback(e) {
|
|
3711
3764
|
this.renderCallback = e;
|
|
3712
3765
|
}
|
|
3713
3766
|
/**
|
|
3714
|
-
*
|
|
3767
|
+
* Set transition complete callback (called by AvatarView)
|
|
3715
3768
|
* @internal
|
|
3716
3769
|
*/
|
|
3717
3770
|
setTransitionCompleteCallback(e) {
|
|
3718
3771
|
this.transitionCompleteCallback = e;
|
|
3719
3772
|
}
|
|
3720
3773
|
/**
|
|
3721
|
-
*
|
|
3774
|
+
* Transition complete notification (called by AvatarView)
|
|
3722
3775
|
* @internal
|
|
3723
3776
|
*/
|
|
3724
3777
|
onTransitionComplete() {
|
|
@@ -3727,15 +3780,15 @@ class Ai {
|
|
|
3727
3780
|
e && e.play();
|
|
3728
3781
|
}
|
|
3729
3782
|
/**
|
|
3730
|
-
*
|
|
3783
|
+
* Provide interface for AvatarView to register internal events
|
|
3731
3784
|
* @internal
|
|
3732
3785
|
*/
|
|
3733
3786
|
setupInternalEventListeners(e) {
|
|
3734
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);
|
|
3735
3788
|
}
|
|
3736
|
-
// ==========
|
|
3789
|
+
// ========== Private Methods ==========
|
|
3737
3790
|
/**
|
|
3738
|
-
*
|
|
3791
|
+
* Start streaming playback (internal implementation)
|
|
3739
3792
|
*/
|
|
3740
3793
|
async startStreamingPlaybackInternal() {
|
|
3741
3794
|
var e, t, n;
|
|
@@ -3750,14 +3803,14 @@ class Ai {
|
|
|
3750
3803
|
try {
|
|
3751
3804
|
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
3752
3805
|
var a, o;
|
|
3753
|
-
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", {
|
|
3754
3807
|
characterId: this.avatar.id,
|
|
3755
3808
|
event: "playback_ended",
|
|
3756
3809
|
reqId: ((o = this.networkLayer) == null ? void 0 : o.getCurrentReqId()) || void 0
|
|
3757
3810
|
});
|
|
3758
3811
|
}), this.emit("startRendering");
|
|
3759
3812
|
const i = this.animationPlayer.getStreamingPlayer();
|
|
3760
|
-
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", {
|
|
3761
3814
|
characterId: this.avatar.id,
|
|
3762
3815
|
event: "playback_started",
|
|
3763
3816
|
reqId: ((t = this.networkLayer) == null ? void 0 : t.getCurrentReqId()) || void 0
|
|
@@ -3768,13 +3821,13 @@ class Ai {
|
|
|
3768
3821
|
}
|
|
3769
3822
|
}
|
|
3770
3823
|
/**
|
|
3771
|
-
*
|
|
3824
|
+
* Playback loop: Calculate animation frame based on audio time, notify render layer to render
|
|
3772
3825
|
*/
|
|
3773
3826
|
startPlaybackLoop() {
|
|
3774
3827
|
if (this.playbackLoopId)
|
|
3775
3828
|
return;
|
|
3776
|
-
const e =
|
|
3777
|
-
if (!this.isPlaying || !this.animationPlayer) {
|
|
3829
|
+
const e = M.animation.fps, t = async () => {
|
|
3830
|
+
if (!this.isPlaying || this.currentState === T.paused || !this.animationPlayer) {
|
|
3778
3831
|
this.playbackLoopId = null;
|
|
3779
3832
|
return;
|
|
3780
3833
|
}
|
|
@@ -3790,7 +3843,7 @@ class Ai {
|
|
|
3790
3843
|
return;
|
|
3791
3844
|
}
|
|
3792
3845
|
if (this.lastRenderedFrameIndex = i, i >= 0 && i < this.currentKeyframes.length) {
|
|
3793
|
-
const a = this.currentKeyframes[i], o = Vt(a), s =
|
|
3846
|
+
const a = this.currentKeyframes[i], o = Vt(a), s = A.getAvatarCore();
|
|
3794
3847
|
if (s) {
|
|
3795
3848
|
const l = await s.computeFrameFlatFromParams(o);
|
|
3796
3849
|
l && this.renderCallback && this.renderCallback(l, i);
|
|
@@ -3805,13 +3858,13 @@ class Ai {
|
|
|
3805
3858
|
this.playbackLoopId = requestAnimationFrame(t);
|
|
3806
3859
|
}
|
|
3807
3860
|
/**
|
|
3808
|
-
*
|
|
3861
|
+
* Stop playback loop
|
|
3809
3862
|
*/
|
|
3810
3863
|
stopPlaybackLoop() {
|
|
3811
3864
|
this.playbackLoopId && (cancelAnimationFrame(this.playbackLoopId), this.playbackLoopId = null);
|
|
3812
3865
|
}
|
|
3813
3866
|
/**
|
|
3814
|
-
*
|
|
3867
|
+
* Stop playback
|
|
3815
3868
|
*/
|
|
3816
3869
|
stopPlayback() {
|
|
3817
3870
|
var e;
|
|
@@ -3820,28 +3873,28 @@ class Ai {
|
|
|
3820
3873
|
const t = this.animationPlayer.getStreamingPlayer();
|
|
3821
3874
|
t == null || t.stop();
|
|
3822
3875
|
}
|
|
3823
|
-
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);
|
|
3824
3877
|
}
|
|
3825
3878
|
/**
|
|
3826
|
-
*
|
|
3879
|
+
* Clean up players
|
|
3827
3880
|
*/
|
|
3828
3881
|
cleanupPlayers() {
|
|
3829
3882
|
this.animationPlayer && (this.animationPlayer.dispose(), this.animationPlayer = null);
|
|
3830
3883
|
}
|
|
3831
3884
|
/**
|
|
3832
|
-
*
|
|
3885
|
+
* Add audio chunk to buffer
|
|
3833
3886
|
*/
|
|
3834
3887
|
addAudioChunkToBuffer(e, t) {
|
|
3835
3888
|
this.animationPlayer || (this.animationPlayer = new be()), this.isPlaying && this.animationPlayer.isStreamingReady() ? this.animationPlayer.addAudioChunk(e, t) : this.pendingAudioChunks.push({ data: e, isLast: t });
|
|
3836
3889
|
}
|
|
3837
3890
|
/**
|
|
3838
|
-
*
|
|
3891
|
+
* Event system
|
|
3839
3892
|
*/
|
|
3840
3893
|
registerEventListener(e, t) {
|
|
3841
3894
|
this.eventListeners.has(e) || this.eventListeners.set(e, /* @__PURE__ */ new Set()), this.eventListeners.get(e).add(t);
|
|
3842
3895
|
}
|
|
3843
3896
|
/**
|
|
3844
|
-
*
|
|
3897
|
+
* Emit event
|
|
3845
3898
|
*/
|
|
3846
3899
|
emit(e, t) {
|
|
3847
3900
|
const n = this.eventListeners.get(e);
|
|
@@ -3864,7 +3917,7 @@ function nr(r) {
|
|
|
3864
3917
|
}
|
|
3865
3918
|
return String(r);
|
|
3866
3919
|
}
|
|
3867
|
-
async function
|
|
3920
|
+
async function bi(r) {
|
|
3868
3921
|
try {
|
|
3869
3922
|
const e = await fetch(r);
|
|
3870
3923
|
if (!e.ok)
|
|
@@ -3876,14 +3929,14 @@ async function Si(r) {
|
|
|
3876
3929
|
}
|
|
3877
3930
|
}
|
|
3878
3931
|
const Lt = /* @__PURE__ */ new Map();
|
|
3879
|
-
async function
|
|
3932
|
+
async function $e(r) {
|
|
3880
3933
|
const e = Lt.get(r);
|
|
3881
3934
|
if (e)
|
|
3882
3935
|
return e;
|
|
3883
|
-
const t = await
|
|
3936
|
+
const t = await bi(r);
|
|
3884
3937
|
return Lt.set(r, t), t;
|
|
3885
3938
|
}
|
|
3886
|
-
class
|
|
3939
|
+
class Ci {
|
|
3887
3940
|
constructor(e = "/") {
|
|
3888
3941
|
d(this, "baseAssetsPath");
|
|
3889
3942
|
d(this, "characterAssets");
|
|
@@ -3925,12 +3978,12 @@ class bi {
|
|
|
3925
3978
|
total: a,
|
|
3926
3979
|
progress: Math.round(o / a * 100)
|
|
3927
3980
|
}));
|
|
3928
|
-
}, l = {}, g = Object.entries(i).map(async ([w, { url: y, resourceName:
|
|
3981
|
+
}, l = {}, g = Object.entries(i).map(async ([w, { url: y, resourceName: b }]) => {
|
|
3929
3982
|
if (!y)
|
|
3930
|
-
throw new Error(`[loadTemplateResources] Missing CDN URL for ${w} (${
|
|
3931
|
-
s(
|
|
3932
|
-
const x = await
|
|
3933
|
-
h.log(`✅ ${w} loaded: ${x.byteLength} bytes`), l[w] = x, s(
|
|
3983
|
+
throw new Error(`[loadTemplateResources] Missing CDN URL for ${w} (${b})`);
|
|
3984
|
+
s(b, !1), h.log(`📥 Loading ${w} from API CDN: ${y}`);
|
|
3985
|
+
const x = await $e(y);
|
|
3986
|
+
h.log(`✅ ${w} loaded: ${x.byteLength} bytes`), l[w] = x, s(b, !0);
|
|
3934
3987
|
});
|
|
3935
3988
|
return await Promise.all(g), l;
|
|
3936
3989
|
}
|
|
@@ -3939,7 +3992,7 @@ class bi {
|
|
|
3939
3992
|
* Uses centralized FLAME CDN config (shared across all characters)
|
|
3940
3993
|
*/
|
|
3941
3994
|
async loadGlobalFlameResources(e = null) {
|
|
3942
|
-
const { cdnBaseUrl: t, resources: n } =
|
|
3995
|
+
const { cdnBaseUrl: t, resources: n } = M.flame, i = {
|
|
3943
3996
|
flameModel: {
|
|
3944
3997
|
url: `${t}/${n.flameModel}`,
|
|
3945
3998
|
resourceName: n.flameModel
|
|
@@ -3968,7 +4021,7 @@ class bi {
|
|
|
3968
4021
|
}));
|
|
3969
4022
|
}, l = {}, g = Object.entries(i).map(async ([c, { url: u, resourceName: m }]) => {
|
|
3970
4023
|
s(m, !1), h.log(`📥 Loading ${c} from global CDN: ${u}`);
|
|
3971
|
-
const v = await
|
|
4024
|
+
const v = await $e(u);
|
|
3972
4025
|
h.log(`✅ ${c} loaded: ${v.byteLength} bytes`), l[c] = v, s(m, !0);
|
|
3973
4026
|
});
|
|
3974
4027
|
return await Promise.all(g), l;
|
|
@@ -3999,15 +4052,15 @@ class bi {
|
|
|
3999
4052
|
* Load character data from CharacterMeta (iOS compatible)
|
|
4000
4053
|
*/
|
|
4001
4054
|
async loadCharacterData(e, t) {
|
|
4002
|
-
var
|
|
4003
|
-
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;
|
|
4004
4057
|
if (!a || !o) {
|
|
4005
|
-
const
|
|
4006
|
-
throw
|
|
4058
|
+
const B = "Missing required resources: shape or gsStandard (point cloud)";
|
|
4059
|
+
throw A.logEvent("character_load", "error", {
|
|
4007
4060
|
characterId: e.characterId ?? "unknown",
|
|
4008
4061
|
stage: "resource_validation",
|
|
4009
|
-
reason:
|
|
4010
|
-
}), new Error(
|
|
4062
|
+
reason: B
|
|
4063
|
+
}), new Error(B);
|
|
4011
4064
|
}
|
|
4012
4065
|
const c = [
|
|
4013
4066
|
{ key: "shape", url: a, filename: "shape.pb" },
|
|
@@ -4015,32 +4068,32 @@ class bi {
|
|
|
4015
4068
|
];
|
|
4016
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)");
|
|
4017
4070
|
let u = 0;
|
|
4018
|
-
const m = c.length, v = (
|
|
4019
|
-
i && (
|
|
4071
|
+
const m = c.length, v = (B, V) => {
|
|
4072
|
+
i && (V && u++, i({
|
|
4020
4073
|
stage: "character",
|
|
4021
|
-
filename:
|
|
4074
|
+
filename: B,
|
|
4022
4075
|
loaded: u,
|
|
4023
4076
|
total: m,
|
|
4024
4077
|
progress: Math.round(u / m * 100)
|
|
4025
4078
|
}));
|
|
4026
|
-
}, w = {}, y = c.map(async ({ key:
|
|
4079
|
+
}, w = {}, y = c.map(async ({ key: B, url: V, filename: ie, optional: Le }) => {
|
|
4027
4080
|
v(ie, !1);
|
|
4028
4081
|
try {
|
|
4029
|
-
const
|
|
4030
|
-
return
|
|
4031
|
-
} catch (
|
|
4032
|
-
if (!
|
|
4033
|
-
throw
|
|
4034
|
-
return h.warn(`⚠️ Optional resource ${ie} failed to load:`,
|
|
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) {
|
|
4085
|
+
if (!Le)
|
|
4086
|
+
throw q;
|
|
4087
|
+
return h.warn(`⚠️ Optional resource ${ie} failed to load:`, q), v(ie, !0), { key: B, success: !1 };
|
|
4035
4088
|
}
|
|
4036
4089
|
});
|
|
4037
4090
|
if (await Promise.all(y), n && g && (w.monoAudioUrl = g), !w.shape || !w.pointCloud) {
|
|
4038
|
-
const
|
|
4039
|
-
throw
|
|
4091
|
+
const B = "Failed to load character data";
|
|
4092
|
+
throw A.logEvent("character_load", "error", {
|
|
4040
4093
|
characterId: e.characterId ?? "unknown",
|
|
4041
4094
|
stage: "download",
|
|
4042
|
-
reason:
|
|
4043
|
-
}), new Error(
|
|
4095
|
+
reason: B
|
|
4096
|
+
}), new Error(B);
|
|
4044
4097
|
}
|
|
4045
4098
|
return w;
|
|
4046
4099
|
}
|
|
@@ -4093,7 +4146,7 @@ class bi {
|
|
|
4093
4146
|
getSdkApiClient() {
|
|
4094
4147
|
return {
|
|
4095
4148
|
async request(e, t = {}) {
|
|
4096
|
-
const a =
|
|
4149
|
+
const a = A.getEnvironmentConfig().sdkApiBaseUrl + e;
|
|
4097
4150
|
try {
|
|
4098
4151
|
const o = await fetch(a, {
|
|
4099
4152
|
method: t.method || "GET",
|
|
@@ -4128,7 +4181,7 @@ class bi {
|
|
|
4128
4181
|
} catch (n) {
|
|
4129
4182
|
h.errorWithError("Failed to fetch character:", n);
|
|
4130
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;
|
|
4131
|
-
throw
|
|
4184
|
+
throw A.logEvent("character_load", "error", {
|
|
4132
4185
|
characterId: e ?? "unknown",
|
|
4133
4186
|
stage: "fetch",
|
|
4134
4187
|
reason: a || i
|
|
@@ -4136,7 +4189,7 @@ class bi {
|
|
|
4136
4189
|
}
|
|
4137
4190
|
}
|
|
4138
4191
|
}
|
|
4139
|
-
const
|
|
4192
|
+
const Re = class Re {
|
|
4140
4193
|
constructor() {
|
|
4141
4194
|
d(this, "avatarDownloader", null);
|
|
4142
4195
|
d(this, "_templateInitialized", !1);
|
|
@@ -4145,7 +4198,7 @@ const Me = class Me {
|
|
|
4145
4198
|
* 通过全局单例来访问
|
|
4146
4199
|
*/
|
|
4147
4200
|
static get shared() {
|
|
4148
|
-
return this._instance || (this._instance = new
|
|
4201
|
+
return this._instance || (this._instance = new Re()), this._instance;
|
|
4149
4202
|
}
|
|
4150
4203
|
/**
|
|
4151
4204
|
* 加载数字人
|
|
@@ -4157,9 +4210,9 @@ const Me = class Me {
|
|
|
4157
4210
|
async load(e, t, n) {
|
|
4158
4211
|
h.log(`[AvatarManager] Loading avatar with id: ${e}`);
|
|
4159
4212
|
try {
|
|
4160
|
-
if (!
|
|
4213
|
+
if (!A.isInitialized)
|
|
4161
4214
|
throw new Error("AvatarKit not initialized. Please call AvatarKit.initialize() first.");
|
|
4162
|
-
this.avatarDownloader || (this.avatarDownloader = new
|
|
4215
|
+
this.avatarDownloader || (this.avatarDownloader = new Ci()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: oe.downloading, progress: 10 });
|
|
4163
4216
|
const i = await this.avatarDownloader.getCharacterById(e);
|
|
4164
4217
|
h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: oe.downloading, progress: 30 });
|
|
4165
4218
|
const a = await this.avatarDownloader.preloadResources(i, {
|
|
@@ -4171,18 +4224,18 @@ const Me = class Me {
|
|
|
4171
4224
|
progress: Math.round(g)
|
|
4172
4225
|
});
|
|
4173
4226
|
}
|
|
4174
|
-
}), o =
|
|
4227
|
+
}), o = A.getAvatarCore();
|
|
4175
4228
|
if (!o)
|
|
4176
4229
|
throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
|
|
4177
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...");
|
|
4178
4231
|
const s = new rn(e, i, a);
|
|
4179
|
-
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", {
|
|
4180
4233
|
characterId: e,
|
|
4181
4234
|
event: "load_success"
|
|
4182
4235
|
}), s;
|
|
4183
4236
|
} catch (i) {
|
|
4184
4237
|
const a = i instanceof Error ? i.message : String(i);
|
|
4185
|
-
throw h.error("Failed to load avatar:", a),
|
|
4238
|
+
throw h.error("Failed to load avatar:", a), A.logEvent("character_load", "error", {
|
|
4186
4239
|
characterId: e,
|
|
4187
4240
|
reason: a
|
|
4188
4241
|
}), t == null || t({ type: oe.failed, error: i }), i;
|
|
@@ -4195,34 +4248,34 @@ const Me = class Me {
|
|
|
4195
4248
|
this.avatarDownloader && this.avatarDownloader.clear();
|
|
4196
4249
|
}
|
|
4197
4250
|
};
|
|
4198
|
-
d(
|
|
4199
|
-
let Tt =
|
|
4200
|
-
const
|
|
4201
|
-
function
|
|
4251
|
+
d(Re, "_instance", null);
|
|
4252
|
+
let Tt = Re, ye = null, Bt = null, Dt = null, Ot = null, Nt = null, Ut = null;
|
|
4253
|
+
const Ye = 2048, zt = Ye - 1;
|
|
4254
|
+
function _i(r, e, t) {
|
|
4202
4255
|
const i = r.length / 13;
|
|
4203
|
-
(!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(
|
|
4204
|
-
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],
|
|
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));
|
|
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];
|
|
4205
4258
|
for (let x = 0; x < i; x++) {
|
|
4206
4259
|
const L = x * 13;
|
|
4207
|
-
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;
|
|
4208
4261
|
}
|
|
4209
4262
|
for (let x = 0; x < i; x++) {
|
|
4210
4263
|
const L = o[x];
|
|
4211
4264
|
o[x] = L ^ (-(L >> 31) | 2147483648);
|
|
4212
4265
|
}
|
|
4213
|
-
|
|
4266
|
+
qe(o, s, l, c, 0, i), qe(o, l, s, c, 11, i), qe(o, s, l, c, 22, i);
|
|
4214
4267
|
for (let x = 0; x < i; x++)
|
|
4215
4268
|
g[x] = l[i - 1 - x];
|
|
4216
4269
|
return g;
|
|
4217
4270
|
}
|
|
4218
|
-
function
|
|
4271
|
+
function qe(r, e, t, n, i, a) {
|
|
4219
4272
|
n.fill(0);
|
|
4220
4273
|
for (let s = 0; s < a; s++) {
|
|
4221
4274
|
const l = r[e[s]] >> i & zt;
|
|
4222
4275
|
n[l]++;
|
|
4223
4276
|
}
|
|
4224
4277
|
let o = 0;
|
|
4225
|
-
for (let s = 0; s <
|
|
4278
|
+
for (let s = 0; s < Ye; s++) {
|
|
4226
4279
|
const l = n[s];
|
|
4227
4280
|
n[s] = o, o += l;
|
|
4228
4281
|
}
|
|
@@ -4231,19 +4284,19 @@ function Ve(r, e, t, n, i, a) {
|
|
|
4231
4284
|
t[n[g]++] = l;
|
|
4232
4285
|
}
|
|
4233
4286
|
}
|
|
4234
|
-
const
|
|
4235
|
-
let
|
|
4236
|
-
function
|
|
4237
|
-
const t = e.length, n = t *
|
|
4238
|
-
(!
|
|
4287
|
+
const Pe = 13;
|
|
4288
|
+
let Se = null;
|
|
4289
|
+
function Ei(r, e) {
|
|
4290
|
+
const t = e.length, n = t * Pe;
|
|
4291
|
+
(!Se || Se.length !== n) && (Se = new Float32Array(n));
|
|
4239
4292
|
for (let i = 0; i < t; i++) {
|
|
4240
|
-
const o = e[i] *
|
|
4241
|
-
for (let l = 0; l <
|
|
4242
|
-
|
|
4293
|
+
const o = e[i] * Pe, s = i * Pe;
|
|
4294
|
+
for (let l = 0; l < Pe; l++)
|
|
4295
|
+
Se[s + l] = r[o + l];
|
|
4243
4296
|
}
|
|
4244
|
-
return
|
|
4297
|
+
return Se;
|
|
4245
4298
|
}
|
|
4246
|
-
const
|
|
4299
|
+
const xi = `#version 300 es
|
|
4247
4300
|
precision highp float;
|
|
4248
4301
|
|
|
4249
4302
|
in vec2 v_relativePosition;
|
|
@@ -4273,7 +4326,7 @@ void main() {
|
|
|
4273
4326
|
// 预乘 alpha 输出(匹配 premultipliedAlpha: true)
|
|
4274
4327
|
// 颜色值需要乘以 alpha,这样 WebGL 才能正确混合
|
|
4275
4328
|
fragColor = vec4(v_color.rgb * alpha, alpha);
|
|
4276
|
-
}`,
|
|
4329
|
+
}`, Pi = `#version 300 es
|
|
4277
4330
|
precision highp float;
|
|
4278
4331
|
|
|
4279
4332
|
// 基础四边形顶点属性(共享4个顶点)
|
|
@@ -4441,7 +4494,7 @@ void main() {
|
|
|
4441
4494
|
v_relativePosition = relativeCoord * BOUNDS_RADIUS;
|
|
4442
4495
|
v_color = a_color;
|
|
4443
4496
|
}`;
|
|
4444
|
-
class
|
|
4497
|
+
class Ii {
|
|
4445
4498
|
// 跟踪当前 buffer 大小
|
|
4446
4499
|
constructor(e, t) {
|
|
4447
4500
|
d(this, "canvas");
|
|
@@ -4633,14 +4686,14 @@ class Pi {
|
|
|
4633
4686
|
const t = e.createShader(e.VERTEX_SHADER);
|
|
4634
4687
|
if (!t)
|
|
4635
4688
|
throw new Error("Failed to create vertex shader");
|
|
4636
|
-
if (e.shaderSource(t,
|
|
4689
|
+
if (e.shaderSource(t, Pi), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS)) {
|
|
4637
4690
|
const a = e.getShaderInfoLog(t);
|
|
4638
4691
|
throw e.deleteShader(t), new Error(`Vertex shader compilation failed: ${a}`);
|
|
4639
4692
|
}
|
|
4640
4693
|
const n = e.createShader(e.FRAGMENT_SHADER);
|
|
4641
4694
|
if (!n)
|
|
4642
4695
|
throw e.deleteShader(t), new Error("Failed to create fragment shader");
|
|
4643
|
-
if (e.shaderSource(n,
|
|
4696
|
+
if (e.shaderSource(n, xi), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) {
|
|
4644
4697
|
const a = e.getShaderInfoLog(n);
|
|
4645
4698
|
throw e.deleteShader(t), e.deleteShader(n), new Error(`Fragment shader compilation failed: ${a}`);
|
|
4646
4699
|
}
|
|
@@ -4669,7 +4722,7 @@ class Pi {
|
|
|
4669
4722
|
this.gl = null, this.isInitialized = !1;
|
|
4670
4723
|
}
|
|
4671
4724
|
}
|
|
4672
|
-
const
|
|
4725
|
+
const ki = `/**
|
|
4673
4726
|
* WebGPU 3DGS 渲染着色器
|
|
4674
4727
|
*
|
|
4675
4728
|
* 实例化渲染:每个 splat 绘制一个四边形
|
|
@@ -4932,7 +4985,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4f {
|
|
|
4932
4985
|
return vec4f(input.color.rgb * alpha, alpha);
|
|
4933
4986
|
}
|
|
4934
4987
|
`;
|
|
4935
|
-
class
|
|
4988
|
+
class Mi {
|
|
4936
4989
|
constructor(e, t) {
|
|
4937
4990
|
d(this, "canvas");
|
|
4938
4991
|
d(this, "backgroundColor");
|
|
@@ -5019,7 +5072,7 @@ class ki {
|
|
|
5019
5072
|
return;
|
|
5020
5073
|
const e = this.device.createShaderModule({
|
|
5021
5074
|
label: "3DGS Render Shader",
|
|
5022
|
-
code:
|
|
5075
|
+
code: ki
|
|
5023
5076
|
}), t = this.device.createBindGroupLayout({
|
|
5024
5077
|
label: "Uniform Bind Group Layout",
|
|
5025
5078
|
entries: [
|
|
@@ -5200,7 +5253,7 @@ class ki {
|
|
|
5200
5253
|
(e = this.sortIndexBuffer) == null || e.destroy(), (t = this.splatDataBuffer) == null || t.destroy(), (n = this.quadVertexBuffer) == null || n.destroy(), (i = this.uniformBuffer) == null || i.destroy(), (a = this.device) == null || a.destroy(), this.sortIndexBuffer = null, this.splatDataBuffer = null, this.quadVertexBuffer = null, this.uniformBuffer = null, this.uniformBindGroup = null, this.storageBindGroup = null, this.device = null, this.context = null, this.renderPipeline = null;
|
|
5201
5254
|
}
|
|
5202
5255
|
}
|
|
5203
|
-
class
|
|
5256
|
+
class Fi {
|
|
5204
5257
|
// 排序耗时
|
|
5205
5258
|
constructor(e) {
|
|
5206
5259
|
d(this, "renderer", null);
|
|
@@ -5239,12 +5292,12 @@ class Mi {
|
|
|
5239
5292
|
const { preferBackend: e, backgroundColor: t = [0, 0, 0, 0] } = this.options;
|
|
5240
5293
|
if (e !== "webgl" && await this.checkWebGPUSupport())
|
|
5241
5294
|
try {
|
|
5242
|
-
this.renderer = new
|
|
5295
|
+
this.renderer = new Mi(this.canvas, t), await this.renderer.initialize(), this.backend = "webgpu", h.log("✅ Using WebGPU renderer"), this.updateCameraAspect();
|
|
5243
5296
|
return;
|
|
5244
5297
|
} catch (i) {
|
|
5245
5298
|
h.warn("⚠️ WebGPU init failed, fallback to WebGL:", i);
|
|
5246
5299
|
}
|
|
5247
|
-
this.renderer = new
|
|
5300
|
+
this.renderer = new Ii(this.canvas, t), await this.renderer.initialize(), this.backend = "webgl", h.log("✅ Using WebGL renderer"), this.updateCameraAspect();
|
|
5248
5301
|
}
|
|
5249
5302
|
/**
|
|
5250
5303
|
* Load packed Splat data (zero-copy, GPU format)
|
|
@@ -5265,7 +5318,7 @@ class Mi {
|
|
|
5265
5318
|
return;
|
|
5266
5319
|
const e = performance.now();
|
|
5267
5320
|
this.updateCameraMatrices();
|
|
5268
|
-
const t = Math.floor(this.originalPackedData.length / 13), n = performance.now(), i =
|
|
5321
|
+
const t = Math.floor(this.originalPackedData.length / 13), n = performance.now(), i = _i(
|
|
5269
5322
|
this.originalPackedData,
|
|
5270
5323
|
this.camera.position,
|
|
5271
5324
|
this.getCameraForward()
|
|
@@ -5273,7 +5326,7 @@ class Mi {
|
|
|
5273
5326
|
if (this.sortTime = performance.now() - n, this.backend === "webgpu")
|
|
5274
5327
|
this.renderer.loadSplatsFromPackedData(this.originalPackedData, t, i);
|
|
5275
5328
|
else {
|
|
5276
|
-
const a =
|
|
5329
|
+
const a = Ei(this.originalPackedData, i);
|
|
5277
5330
|
this.renderer.loadSplatsFromPackedData(a, t);
|
|
5278
5331
|
}
|
|
5279
5332
|
this.renderer.render(
|
|
@@ -5390,7 +5443,7 @@ function ae(r, e, t) {
|
|
|
5390
5443
|
i[a] = r[a] + (e[a] - r[a]) * t;
|
|
5391
5444
|
return i;
|
|
5392
5445
|
}
|
|
5393
|
-
function
|
|
5446
|
+
function Ri(r, e, t) {
|
|
5394
5447
|
const n = 0.5 - Math.cos(t * Math.PI) * 0.5;
|
|
5395
5448
|
return {
|
|
5396
5449
|
translation: ae(r.translation || [0, 0, 0], e.translation || [0, 0, 0], n),
|
|
@@ -5405,15 +5458,15 @@ function Fi(r, e, t) {
|
|
|
5405
5458
|
expression: ae(r.expression || [], e.expression || [], n)
|
|
5406
5459
|
};
|
|
5407
5460
|
}
|
|
5408
|
-
function
|
|
5461
|
+
function Li(r, e, t, n = 25) {
|
|
5409
5462
|
const i = Math.max(1, Math.floor(t / 1e3 * n)), a = Array.from({ length: i });
|
|
5410
5463
|
for (let o = 0; o < i; o++) {
|
|
5411
5464
|
const s = o / (i - 1);
|
|
5412
|
-
a[o] =
|
|
5465
|
+
a[o] = Ri(r, e, s);
|
|
5413
5466
|
}
|
|
5414
5467
|
return a;
|
|
5415
5468
|
}
|
|
5416
|
-
class
|
|
5469
|
+
class Ni {
|
|
5417
5470
|
/**
|
|
5418
5471
|
* 构造函数
|
|
5419
5472
|
* 创建统一的 AvatarController,内部根据配置自动组合网络层
|
|
@@ -5445,7 +5498,7 @@ class Oi {
|
|
|
5445
5498
|
d(this, "cachedIdleFirstFrame", null);
|
|
5446
5499
|
d(this, "idleCurrentFrameIndex", 0);
|
|
5447
5500
|
this.avatar = e;
|
|
5448
|
-
const n = (t == null ? void 0 : t.playbackMode) ??
|
|
5501
|
+
const n = (t == null ? void 0 : t.playbackMode) ?? ke.network;
|
|
5449
5502
|
this.playbackMode = n, this.avatarController = new Ai(e, {
|
|
5450
5503
|
playbackMode: n
|
|
5451
5504
|
}), this.avatarController.setRenderCallback((i, a) => {
|
|
@@ -5500,11 +5553,11 @@ class Oi {
|
|
|
5500
5553
|
*/
|
|
5501
5554
|
generateAndAlignTransitionFrames(e, t) {
|
|
5502
5555
|
const n = this.alignFlamePair(e, t);
|
|
5503
|
-
let i =
|
|
5556
|
+
let i = Li(
|
|
5504
5557
|
n.from,
|
|
5505
5558
|
n.to,
|
|
5506
5559
|
this.transitionDurationMs,
|
|
5507
|
-
|
|
5560
|
+
M.animation.fps
|
|
5508
5561
|
);
|
|
5509
5562
|
return i.length < 2 && (i = [n.from, n.to]), i[0] = n.from, i[i.length - 1] = n.to, i;
|
|
5510
5563
|
}
|
|
@@ -5513,11 +5566,11 @@ class Oi {
|
|
|
5513
5566
|
*/
|
|
5514
5567
|
async getCachedIdleFirstFrame() {
|
|
5515
5568
|
if (!this.cachedIdleFirstFrame) {
|
|
5516
|
-
const e =
|
|
5569
|
+
const e = A.getAvatarCore();
|
|
5517
5570
|
if (e)
|
|
5518
5571
|
try {
|
|
5519
5572
|
const t = await e.getCurrentFrameParams(0);
|
|
5520
|
-
this.cachedIdleFirstFrame =
|
|
5573
|
+
this.cachedIdleFirstFrame = dt(t);
|
|
5521
5574
|
} catch (t) {
|
|
5522
5575
|
h.warn("[AvatarView] Failed to get idle first frame:", t instanceof Error ? t.message : String(t));
|
|
5523
5576
|
}
|
|
@@ -5555,17 +5608,17 @@ class Oi {
|
|
|
5555
5608
|
*/
|
|
5556
5609
|
async initializeView(e) {
|
|
5557
5610
|
try {
|
|
5558
|
-
|
|
5559
|
-
const t =
|
|
5611
|
+
M.debug && h.log("[AvatarView] Initializing avatar view...");
|
|
5612
|
+
const t = A.getAvatarCore();
|
|
5560
5613
|
if (!t)
|
|
5561
5614
|
throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
|
|
5562
5615
|
const n = e.getResources();
|
|
5563
|
-
|
|
5616
|
+
M.debug && h.log("[AvatarView] Loading character data..."), await t.loadCharacterFromBuffers(
|
|
5564
5617
|
n.characterData.shape,
|
|
5565
5618
|
n.characterData.pointCloud
|
|
5566
|
-
), n.characterData.idleAnimation && (
|
|
5619
|
+
), n.characterData.idleAnimation && (M.debug && h.log("[AvatarView] Loading idle animation..."), await t.loadAnimationFromBuffer(n.characterData.idleAnimation)), M.debug && h.log("[AvatarView] Initializing render system...");
|
|
5567
5620
|
const i = this.resolveCameraConfig(n);
|
|
5568
|
-
await this.initializeRenderSystem(i),
|
|
5621
|
+
await this.initializeRenderSystem(i), M.debug && h.log("[AvatarView] Starting rendering..."), await this.renderFirstFrame(), this.startIdleAnimationLoop(), this.isInitialized = !0, M.debug && h.log("[AvatarView] Avatar view initialized successfully");
|
|
5569
5622
|
} catch (t) {
|
|
5570
5623
|
throw h.error("[AvatarView] Failed to initialize avatar view:", t instanceof Error ? t.message : String(t)), t;
|
|
5571
5624
|
}
|
|
@@ -5574,18 +5627,18 @@ class Oi {
|
|
|
5574
5627
|
* 初始化渲染系统
|
|
5575
5628
|
*/
|
|
5576
5629
|
async initializeRenderSystem(e) {
|
|
5577
|
-
this.cameraConfig = e || this.getDefaultCameraConfig(), e ? h.log("[AvatarView] Using resolved camera config:", e) : h.log("[AvatarView] No camera config in resources, using default static config:", this.cameraConfig), this.renderSystem = new
|
|
5630
|
+
this.cameraConfig = e || this.getDefaultCameraConfig(), e ? h.log("[AvatarView] Using resolved camera config:", e) : h.log("[AvatarView] No camera config in resources, using default static config:", this.cameraConfig), this.renderSystem = new Fi({
|
|
5578
5631
|
canvas: this.canvas,
|
|
5579
5632
|
camera: this.cameraConfig,
|
|
5580
5633
|
backgroundColor: [0, 0, 0, 0]
|
|
5581
5634
|
// 透明背景,让 CSS 背景透出
|
|
5582
|
-
}), await this.renderSystem.initialize(),
|
|
5635
|
+
}), await this.renderSystem.initialize(), M.debug && h.log("[AvatarView] Render system initialized successfully");
|
|
5583
5636
|
}
|
|
5584
5637
|
/**
|
|
5585
5638
|
* 获取默认相机配置
|
|
5586
5639
|
*/
|
|
5587
5640
|
getDefaultCameraConfig() {
|
|
5588
|
-
return { ...
|
|
5641
|
+
return { ...M.camera };
|
|
5589
5642
|
}
|
|
5590
5643
|
/**
|
|
5591
5644
|
* 根据资源解析最终的相机配置,优先使用角色设置,其次 camera.json
|
|
@@ -5602,28 +5655,28 @@ class Oi {
|
|
|
5602
5655
|
* 从角色设置中推导相机配置
|
|
5603
5656
|
*/
|
|
5604
5657
|
deriveCameraConfigFromSettings(e, t, n) {
|
|
5605
|
-
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;
|
|
5606
5659
|
if (!c && !u && !m)
|
|
5607
5660
|
return h.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
|
|
5608
|
-
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 = [
|
|
5609
5662
|
-v,
|
|
5610
5663
|
0,
|
|
5611
5664
|
-w
|
|
5612
|
-
], x = Math.hypot(
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5665
|
+
], x = Math.hypot(b[0], b[1], b[2]) || 1, L = [
|
|
5666
|
+
b[0] / x,
|
|
5667
|
+
b[1] / x,
|
|
5668
|
+
b[2] / x
|
|
5616
5669
|
], _ = [
|
|
5617
5670
|
y[0] + L[0],
|
|
5618
5671
|
y[1] + L[1],
|
|
5619
5672
|
y[2] + L[2]
|
|
5620
|
-
], Y = [0, 1, 0],
|
|
5673
|
+
], Y = [0, 1, 0], G = u ? g * 180 / Math.PI : t.fov, U = {
|
|
5621
5674
|
...t,
|
|
5622
5675
|
// 自动继承 near/far 等配置(来自 APP_CONFIG.camera)
|
|
5623
5676
|
position: y,
|
|
5624
5677
|
target: _,
|
|
5625
5678
|
up: Y,
|
|
5626
|
-
fov:
|
|
5679
|
+
fov: G
|
|
5627
5680
|
// near/far 从 fallback 继承,无需硬编码
|
|
5628
5681
|
};
|
|
5629
5682
|
return h.log("[AvatarView] Applied camera settings from resources", {
|
|
@@ -5632,10 +5685,10 @@ class Oi {
|
|
|
5632
5685
|
yawRadians: l,
|
|
5633
5686
|
position: y,
|
|
5634
5687
|
target: _,
|
|
5635
|
-
fov:
|
|
5636
|
-
near:
|
|
5637
|
-
far:
|
|
5638
|
-
}),
|
|
5688
|
+
fov: G,
|
|
5689
|
+
near: U.near,
|
|
5690
|
+
far: U.far
|
|
5691
|
+
}), U;
|
|
5639
5692
|
}
|
|
5640
5693
|
/**
|
|
5641
5694
|
* 渲染第一帧
|
|
@@ -5643,7 +5696,7 @@ class Oi {
|
|
|
5643
5696
|
async renderFirstFrame() {
|
|
5644
5697
|
if (!this.renderSystem)
|
|
5645
5698
|
throw new Error("Render system not initialized");
|
|
5646
|
-
const e =
|
|
5699
|
+
const e = A.getAvatarCore();
|
|
5647
5700
|
if (!e)
|
|
5648
5701
|
throw new Error("AvatarCore not available");
|
|
5649
5702
|
const t = {
|
|
@@ -5656,7 +5709,7 @@ class Oi {
|
|
|
5656
5709
|
eyes_pose: [0, 0, 0, 0, 0, 0]
|
|
5657
5710
|
}, n = await e.computeFrameFlatFromParams(t);
|
|
5658
5711
|
if (n)
|
|
5659
|
-
this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(),
|
|
5712
|
+
this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(), M.debug && h.log("[AvatarView] First frame rendered successfully");
|
|
5660
5713
|
else
|
|
5661
5714
|
throw new Error("Failed to compute first frame splat data");
|
|
5662
5715
|
}
|
|
@@ -5667,7 +5720,7 @@ class Oi {
|
|
|
5667
5720
|
if (this.idleAnimationLoopId)
|
|
5668
5721
|
return;
|
|
5669
5722
|
if (this.renderingState !== "idle") {
|
|
5670
|
-
|
|
5723
|
+
M.debug && h.log("[AvatarView] Skip starting idle loop because not in idle state");
|
|
5671
5724
|
return;
|
|
5672
5725
|
}
|
|
5673
5726
|
this.idleCurrentFrameIndex = 0;
|
|
@@ -5685,7 +5738,7 @@ class Oi {
|
|
|
5685
5738
|
return;
|
|
5686
5739
|
}
|
|
5687
5740
|
e = a;
|
|
5688
|
-
const o =
|
|
5741
|
+
const o = A.getAvatarCore();
|
|
5689
5742
|
if (!o)
|
|
5690
5743
|
return;
|
|
5691
5744
|
const s = await o.computeCompleteFrameFlat({ frameIndex: this.idleCurrentFrameIndex });
|
|
@@ -5699,7 +5752,7 @@ class Oi {
|
|
|
5699
5752
|
h.error("[AvatarView] Idle animation loop error:", o instanceof Error ? o.message : String(o)), this.stopIdleAnimationLoop();
|
|
5700
5753
|
}
|
|
5701
5754
|
};
|
|
5702
|
-
this.idleAnimationLoopId = requestAnimationFrame(i),
|
|
5755
|
+
this.idleAnimationLoopId = requestAnimationFrame(i), M.debug && h.log("[AvatarView] Idle animation loop started");
|
|
5703
5756
|
}
|
|
5704
5757
|
/**
|
|
5705
5758
|
* 开始实时对话动画循环
|
|
@@ -5724,7 +5777,7 @@ class Oi {
|
|
|
5724
5777
|
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
5725
5778
|
return;
|
|
5726
5779
|
}
|
|
5727
|
-
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();
|
|
5728
5781
|
if (v) {
|
|
5729
5782
|
const w = await v.computeFrameFlatFromParams(m);
|
|
5730
5783
|
w && (this.renderSystem.loadSplatsFromPackedData(w), this.renderSystem.renderFrame());
|
|
@@ -5754,19 +5807,19 @@ class Oi {
|
|
|
5754
5807
|
h.error("[AvatarView] Realtime animation loop error:", o instanceof Error ? o.message : String(o)), this.stopRealtimeAnimationLoop();
|
|
5755
5808
|
}
|
|
5756
5809
|
};
|
|
5757
|
-
this.realtimeAnimationLoopId = requestAnimationFrame(i),
|
|
5810
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(i), M.debug && h.log("[AvatarView] Realtime animation loop started");
|
|
5758
5811
|
}
|
|
5759
5812
|
/**
|
|
5760
5813
|
* 停止idle动画循环
|
|
5761
5814
|
*/
|
|
5762
5815
|
stopIdleAnimationLoop() {
|
|
5763
|
-
this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null,
|
|
5816
|
+
this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null, M.debug && h.log("[AvatarView] Idle animation loop stopped"));
|
|
5764
5817
|
}
|
|
5765
5818
|
/**
|
|
5766
5819
|
* 停止实时对话动画循环
|
|
5767
5820
|
*/
|
|
5768
5821
|
stopRealtimeAnimationLoop() {
|
|
5769
|
-
this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null,
|
|
5822
|
+
this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null, M.debug && h.log("[AvatarView] Realtime animation loop stopped"));
|
|
5770
5823
|
}
|
|
5771
5824
|
/**
|
|
5772
5825
|
* 停止所有动画循环
|
|
@@ -5855,17 +5908,17 @@ class Oi {
|
|
|
5855
5908
|
/* TransitioningToSpeaking */
|
|
5856
5909
|
);
|
|
5857
5910
|
try {
|
|
5858
|
-
const n =
|
|
5911
|
+
const n = A.getAvatarCore();
|
|
5859
5912
|
if (n && e.length > 0) {
|
|
5860
5913
|
if (this.renderingState !== "transitioningToSpeaking")
|
|
5861
5914
|
return;
|
|
5862
|
-
const i = await n.getCurrentFrameParams(this.idleCurrentFrameIndex), a =
|
|
5915
|
+
const i = await n.getCurrentFrameParams(this.idleCurrentFrameIndex), a = dt(i);
|
|
5863
5916
|
await this.getCachedIdleFirstFrame();
|
|
5864
5917
|
const o = e[0];
|
|
5865
5918
|
this.transitionKeyframes = this.generateAndAlignTransitionFrames(a, o), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
|
|
5866
5919
|
"speaking"
|
|
5867
5920
|
/* Speaking */
|
|
5868
|
-
), this.avatarController.onTransitionComplete()) :
|
|
5921
|
+
), this.avatarController.onTransitionComplete()) : M.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
|
|
5869
5922
|
}
|
|
5870
5923
|
} catch (n) {
|
|
5871
5924
|
h.warn("[AvatarView] Transition generation failed:", n instanceof Error ? n.message : String(n)), this.renderingState === "transitioningToSpeaking" && (this.setState(
|
|
@@ -5879,7 +5932,7 @@ class Oi {
|
|
|
5879
5932
|
* 开始实时渲染循环
|
|
5880
5933
|
*/
|
|
5881
5934
|
startRealtimeRendering() {
|
|
5882
|
-
|
|
5935
|
+
M.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"), A.logEvent("character_view", "info", {
|
|
5883
5936
|
characterId: this.avatar.id,
|
|
5884
5937
|
event: "rendering_started",
|
|
5885
5938
|
keyframesCount: this.currentKeyframes.length
|
|
@@ -5905,10 +5958,10 @@ class Oi {
|
|
|
5905
5958
|
try {
|
|
5906
5959
|
if (this.renderingState !== "transitioningToIdle")
|
|
5907
5960
|
return;
|
|
5908
|
-
if (
|
|
5961
|
+
if (A.getAvatarCore() && this.currentKeyframes.length > 0) {
|
|
5909
5962
|
const n = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], i = await this.getCachedIdleFirstFrame();
|
|
5910
5963
|
if (i && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(n, i), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
|
|
5911
|
-
|
|
5964
|
+
M.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
|
|
5912
5965
|
return;
|
|
5913
5966
|
}
|
|
5914
5967
|
}
|
|
@@ -5927,21 +5980,21 @@ class Oi {
|
|
|
5927
5980
|
* 关闭 avatarController 并清理所有相关资源
|
|
5928
5981
|
*/
|
|
5929
5982
|
dispose() {
|
|
5930
|
-
|
|
5983
|
+
M.debug && h.log("[AvatarView] Disposing avatar view..."), A.logEvent("character_view", "info", {
|
|
5931
5984
|
characterId: this.avatar.id,
|
|
5932
5985
|
event: "disposed"
|
|
5933
5986
|
}), this.avatarController && (this.avatarController.clear(), this.avatarController.dispose()), this.stopAllAnimationLoops(), this.setState(
|
|
5934
5987
|
"idle"
|
|
5935
5988
|
/* Idle */
|
|
5936
5989
|
), this.cachedIdleFirstFrame = null, this.idleCurrentFrameIndex = 0;
|
|
5937
|
-
const e =
|
|
5990
|
+
const e = A.getAvatarCore();
|
|
5938
5991
|
if (e)
|
|
5939
5992
|
try {
|
|
5940
|
-
e.releaseCurrentCharacter(),
|
|
5993
|
+
e.releaseCurrentCharacter(), M.debug && h.log("[AvatarView] AvatarCore character resources released");
|
|
5941
5994
|
} catch (t) {
|
|
5942
5995
|
h.error("[AvatarView] Failed to release AvatarCore resources:", t instanceof Error ? t.message : String(t));
|
|
5943
5996
|
}
|
|
5944
|
-
this.renderSystem && (this.renderSystem.dispose(), this.renderSystem = null), this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), window.removeEventListener("resize", this.onWindowResize), this.isInitialized = !1,
|
|
5997
|
+
this.renderSystem && (this.renderSystem.dispose(), this.renderSystem = null), this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), window.removeEventListener("resize", this.onWindowResize), this.isInitialized = !1, M.debug && h.log("[AvatarView] Avatar view disposed successfully");
|
|
5945
5998
|
}
|
|
5946
5999
|
/**
|
|
5947
6000
|
* 获取相机配置
|
|
@@ -5955,7 +6008,7 @@ class Oi {
|
|
|
5955
6008
|
* @internal
|
|
5956
6009
|
*/
|
|
5957
6010
|
updateCameraConfig(e) {
|
|
5958
|
-
this.cameraConfig = e,
|
|
6011
|
+
this.cameraConfig = e, M.debug && h.log("[AvatarView] Camera config updated:", e), this.renderSystem && (this.renderSystem.updateCamera(e), M.debug && h.log("[AvatarView] Applied new camera config to render system"));
|
|
5959
6012
|
}
|
|
5960
6013
|
/**
|
|
5961
6014
|
* 处理尺寸变化:通知渲染系统更新视口与投影
|
|
@@ -5978,23 +6031,23 @@ class Oi {
|
|
|
5978
6031
|
}
|
|
5979
6032
|
}
|
|
5980
6033
|
export {
|
|
5981
|
-
|
|
5982
|
-
|
|
6034
|
+
M as A,
|
|
6035
|
+
Ae as C,
|
|
5983
6036
|
le as E,
|
|
5984
6037
|
oe as L,
|
|
5985
6038
|
nn as R,
|
|
5986
6039
|
se as S,
|
|
5987
|
-
|
|
6040
|
+
A as a,
|
|
5988
6041
|
rn as b,
|
|
5989
6042
|
Ai as c,
|
|
5990
6043
|
Tt as d,
|
|
5991
6044
|
nr as e,
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
6045
|
+
Ni as f,
|
|
6046
|
+
T as g,
|
|
6047
|
+
ke as h,
|
|
6048
|
+
Bi as i,
|
|
6049
|
+
Di as j,
|
|
6050
|
+
Oi as k,
|
|
5998
6051
|
h as l
|
|
5999
6052
|
};
|
|
6000
|
-
//# sourceMappingURL=index-
|
|
6053
|
+
//# sourceMappingURL=index-CXkdiMjt.js.map
|