@spatialwalk/avatarkit 1.0.0-beta.6 → 1.0.0-beta.8
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 +26 -0
- package/dist/{StreamingAudioPlayer-BKTD97fl.js → StreamingAudioPlayer-fSZLLTe1.js} +2 -2
- package/dist/{StreamingAudioPlayer-BKTD97fl.js.map → StreamingAudioPlayer-fSZLLTe1.js.map} +1 -1
- package/dist/avatar_core_wasm.wasm +0 -0
- package/dist/core/AvatarController.d.ts.map +1 -1
- package/dist/core/AvatarView.d.ts +19 -4
- package/dist/core/AvatarView.d.ts.map +1 -1
- package/dist/core/NetworkLayer.d.ts.map +1 -1
- package/dist/{index-CX8f1bzw.js → index-B-JbfZD-.js} +484 -404
- package/dist/index-B-JbfZD-.js.map +1 -0
- package/dist/index.js +1 -1
- package/package.json +11 -12
- package/dist/index-CX8f1bzw.js.map +0 -1
|
@@ -3,14 +3,14 @@ var tn = (r, e, t) => e in r ? en(r, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var d = (r, e, t) => tn(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var rn = /* @__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))(rn || {});
|
|
5
5
|
function Bi(r) {
|
|
6
|
-
var e, t, n, i, a, o, s, l, g, c, u, m, v,
|
|
6
|
+
var e, t, n, i, a, o, s, l, g, c, u, m, v, w, y, S, x;
|
|
7
7
|
return {
|
|
8
8
|
camera: ((t = (e = r.camera) == null ? void 0 : e.resource) == null ? void 0 : t.remote) || null,
|
|
9
9
|
frameIdle: ((a = (i = (n = r.animations) == null ? void 0 : n.frameIdle) == null ? void 0 : i.resource) == null ? void 0 : a.remote) || null,
|
|
10
10
|
frameMono: ((l = (s = (o = r.animations) == null ? void 0 : o.frameMono) == null ? void 0 : s.resource) == null ? void 0 : l.remote) || null,
|
|
11
11
|
audioMono: ((u = (c = (g = r.animations) == null ? void 0 : g.audioMono) == null ? void 0 : c.resource) == null ? void 0 : u.remote) || null,
|
|
12
|
-
shape: ((
|
|
13
|
-
gsStandard: ((x = (
|
|
12
|
+
shape: ((w = (v = (m = r.models) == null ? void 0 : m.shape) == null ? void 0 : v.resource) == null ? void 0 : w.remote) || null,
|
|
13
|
+
gsStandard: ((x = (S = (y = r.models) == null ? void 0 : y.gsStandard) == null ? void 0 : S.resource) == null ? void 0 : x.remote) || null
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function Di(r) {
|
|
@@ -26,7 +26,7 @@ function Oi(r) {
|
|
|
26
26
|
return !1;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
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 || {}),
|
|
29
|
+
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 || {}), Se = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(Se || {}), Z = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r))(Z || {});
|
|
30
30
|
class se extends Error {
|
|
31
31
|
constructor(e, t) {
|
|
32
32
|
super(e), this.code = t, this.name = "SPAvatarError";
|
|
@@ -40,7 +40,7 @@ function an() {
|
|
|
40
40
|
function on() {
|
|
41
41
|
return an();
|
|
42
42
|
}
|
|
43
|
-
const
|
|
43
|
+
const k = {
|
|
44
44
|
testEnv: nn,
|
|
45
45
|
// Dynamic debug mode check (includes URL parameter)
|
|
46
46
|
get debug() {
|
|
@@ -152,49 +152,49 @@ function cn() {
|
|
|
152
152
|
(function(t, n) {
|
|
153
153
|
r.exports = n();
|
|
154
154
|
})(qt, function() {
|
|
155
|
-
function t(
|
|
156
|
-
return !isNaN(parseFloat(
|
|
155
|
+
function t(y) {
|
|
156
|
+
return !isNaN(parseFloat(y)) && isFinite(y);
|
|
157
157
|
}
|
|
158
|
-
function n(
|
|
159
|
-
return
|
|
158
|
+
function n(y) {
|
|
159
|
+
return y.charAt(0).toUpperCase() + y.substring(1);
|
|
160
160
|
}
|
|
161
|
-
function i(
|
|
161
|
+
function i(y) {
|
|
162
162
|
return function() {
|
|
163
|
-
return this[
|
|
163
|
+
return this[y];
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
var a = ["isConstructor", "isEval", "isNative", "isToplevel"], o = ["columnNumber", "lineNumber"], s = ["fileName", "functionName", "source"], l = ["args"], g = ["evalOrigin"], c = a.concat(o, s, l, g);
|
|
167
|
-
function u(
|
|
168
|
-
if (
|
|
169
|
-
for (var
|
|
170
|
-
|
|
167
|
+
function u(y) {
|
|
168
|
+
if (y)
|
|
169
|
+
for (var S = 0; S < c.length; S++)
|
|
170
|
+
y[c[S]] !== void 0 && this["set" + n(c[S])](y[c[S]]);
|
|
171
171
|
}
|
|
172
172
|
u.prototype = {
|
|
173
173
|
getArgs: function() {
|
|
174
174
|
return this.args;
|
|
175
175
|
},
|
|
176
|
-
setArgs: function(
|
|
177
|
-
if (Object.prototype.toString.call(
|
|
176
|
+
setArgs: function(y) {
|
|
177
|
+
if (Object.prototype.toString.call(y) !== "[object Array]")
|
|
178
178
|
throw new TypeError("Args must be an Array");
|
|
179
|
-
this.args =
|
|
179
|
+
this.args = y;
|
|
180
180
|
},
|
|
181
181
|
getEvalOrigin: function() {
|
|
182
182
|
return this.evalOrigin;
|
|
183
183
|
},
|
|
184
|
-
setEvalOrigin: function(
|
|
185
|
-
if (
|
|
186
|
-
this.evalOrigin =
|
|
187
|
-
else if (
|
|
188
|
-
this.evalOrigin = new u(
|
|
184
|
+
setEvalOrigin: function(y) {
|
|
185
|
+
if (y instanceof u)
|
|
186
|
+
this.evalOrigin = y;
|
|
187
|
+
else if (y instanceof Object)
|
|
188
|
+
this.evalOrigin = new u(y);
|
|
189
189
|
else
|
|
190
190
|
throw new TypeError("Eval Origin must be an Object or StackFrame");
|
|
191
191
|
},
|
|
192
192
|
toString: function() {
|
|
193
|
-
var
|
|
194
|
-
return this.getIsEval() ?
|
|
193
|
+
var y = this.getFileName() || "", S = this.getLineNumber() || "", x = this.getColumnNumber() || "", L = this.getFunctionName() || "";
|
|
194
|
+
return this.getIsEval() ? y ? "[eval] (" + y + ":" + S + ":" + x + ")" : "[eval]:" + S + ":" + x : L ? L + " (" + y + ":" + S + ":" + x + ")" : y + ":" + S + ":" + x;
|
|
195
195
|
}
|
|
196
|
-
}, u.fromString = function(
|
|
197
|
-
var x =
|
|
196
|
+
}, u.fromString = function(S) {
|
|
197
|
+
var x = S.indexOf("("), L = S.lastIndexOf(")"), _ = S.substring(0, x), Y = S.substring(x + 1, L).split(","), W = S.substring(L + 1);
|
|
198
198
|
if (W.indexOf("@") === 0)
|
|
199
199
|
var N = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(W, ""), G = N[1], X = N[2], K = N[3];
|
|
200
200
|
return new u({
|
|
@@ -206,25 +206,25 @@ function cn() {
|
|
|
206
206
|
});
|
|
207
207
|
};
|
|
208
208
|
for (var m = 0; m < a.length; m++)
|
|
209
|
-
u.prototype["get" + n(a[m])] = i(a[m]), u.prototype["set" + n(a[m])] = /* @__PURE__ */ function(
|
|
210
|
-
return function(
|
|
211
|
-
this[
|
|
209
|
+
u.prototype["get" + n(a[m])] = i(a[m]), u.prototype["set" + n(a[m])] = /* @__PURE__ */ function(y) {
|
|
210
|
+
return function(S) {
|
|
211
|
+
this[y] = !!S;
|
|
212
212
|
};
|
|
213
213
|
}(a[m]);
|
|
214
214
|
for (var v = 0; v < o.length; v++)
|
|
215
|
-
u.prototype["get" + n(o[v])] = i(o[v]), u.prototype["set" + n(o[v])] = /* @__PURE__ */ function(
|
|
216
|
-
return function(
|
|
217
|
-
if (!t(
|
|
218
|
-
throw new TypeError(
|
|
219
|
-
this[
|
|
215
|
+
u.prototype["get" + n(o[v])] = i(o[v]), u.prototype["set" + n(o[v])] = /* @__PURE__ */ function(y) {
|
|
216
|
+
return function(S) {
|
|
217
|
+
if (!t(S))
|
|
218
|
+
throw new TypeError(y + " must be a Number");
|
|
219
|
+
this[y] = Number(S);
|
|
220
220
|
};
|
|
221
221
|
}(o[v]);
|
|
222
|
-
for (var
|
|
223
|
-
u.prototype["get" + n(s[
|
|
224
|
-
return function(
|
|
225
|
-
this[
|
|
222
|
+
for (var w = 0; w < s.length; w++)
|
|
223
|
+
u.prototype["get" + n(s[w])] = i(s[w]), u.prototype["set" + n(s[w])] = /* @__PURE__ */ function(y) {
|
|
224
|
+
return function(S) {
|
|
225
|
+
this[y] = String(S);
|
|
226
226
|
};
|
|
227
|
-
}(s[
|
|
227
|
+
}(s[w]);
|
|
228
228
|
return u;
|
|
229
229
|
});
|
|
230
230
|
}(Be)), Be.exports;
|
|
@@ -266,10 +266,10 @@ function cn() {
|
|
|
266
266
|
c.indexOf("(eval ") > -1 && (c = c.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
|
|
267
267
|
var u = c.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), m = u.match(/ (\(.+\)$)/);
|
|
268
268
|
u = m ? u.replace(m[0], "") : u;
|
|
269
|
-
var v = this.extractLocation(m ? m[1] : u),
|
|
269
|
+
var v = this.extractLocation(m ? m[1] : u), w = m && u || void 0, y = ["eval", "<anonymous>"].indexOf(v[0]) > -1 ? void 0 : v[0];
|
|
270
270
|
return new n({
|
|
271
|
-
functionName:
|
|
272
|
-
fileName:
|
|
271
|
+
functionName: w,
|
|
272
|
+
fileName: y,
|
|
273
273
|
lineNumber: v[1],
|
|
274
274
|
columnNumber: v[2],
|
|
275
275
|
source: c
|
|
@@ -286,12 +286,12 @@ function cn() {
|
|
|
286
286
|
return new n({
|
|
287
287
|
functionName: c
|
|
288
288
|
});
|
|
289
|
-
var u = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(u), v = m && m[1] ? m[1] : void 0,
|
|
289
|
+
var u = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(u), v = m && m[1] ? m[1] : void 0, w = this.extractLocation(c.replace(u, ""));
|
|
290
290
|
return new n({
|
|
291
291
|
functionName: v,
|
|
292
|
-
fileName:
|
|
293
|
-
lineNumber:
|
|
294
|
-
columnNumber:
|
|
292
|
+
fileName: w[0],
|
|
293
|
+
lineNumber: w[1],
|
|
294
|
+
columnNumber: w[2],
|
|
295
295
|
source: c
|
|
296
296
|
});
|
|
297
297
|
}, this);
|
|
@@ -305,10 +305,10 @@ function cn() {
|
|
|
305
305
|
parseOpera9: function(l) {
|
|
306
306
|
for (var g = /Line (\d+).*script (?:in )?(\S+)/i, c = l.message.split(`
|
|
307
307
|
`), u = [], m = 2, v = c.length; m < v; m += 2) {
|
|
308
|
-
var
|
|
309
|
-
|
|
310
|
-
fileName:
|
|
311
|
-
lineNumber:
|
|
308
|
+
var w = g.exec(c[m]);
|
|
309
|
+
w && u.push(new n({
|
|
310
|
+
fileName: w[2],
|
|
311
|
+
lineNumber: w[1],
|
|
312
312
|
source: c[m]
|
|
313
313
|
}));
|
|
314
314
|
}
|
|
@@ -317,12 +317,12 @@ function cn() {
|
|
|
317
317
|
parseOpera10: function(l) {
|
|
318
318
|
for (var g = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, c = l.stacktrace.split(`
|
|
319
319
|
`), u = [], m = 0, v = c.length; m < v; m += 2) {
|
|
320
|
-
var
|
|
321
|
-
|
|
320
|
+
var w = g.exec(c[m]);
|
|
321
|
+
w && u.push(
|
|
322
322
|
new n({
|
|
323
|
-
functionName:
|
|
324
|
-
fileName:
|
|
325
|
-
lineNumber:
|
|
323
|
+
functionName: w[3] || void 0,
|
|
324
|
+
fileName: w[2],
|
|
325
|
+
lineNumber: w[1],
|
|
326
326
|
source: c[m]
|
|
327
327
|
})
|
|
328
328
|
);
|
|
@@ -336,12 +336,12 @@ function cn() {
|
|
|
336
336
|
return !!c.match(i) && !c.match(/^Error created at/);
|
|
337
337
|
}, this);
|
|
338
338
|
return g.map(function(c) {
|
|
339
|
-
var u = c.split("@"), m = this.extractLocation(u.pop()), v = u.shift() || "",
|
|
340
|
-
v.match(/\(([^)]*)\)/) && (
|
|
341
|
-
var
|
|
339
|
+
var u = c.split("@"), m = this.extractLocation(u.pop()), v = u.shift() || "", w = v.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, y;
|
|
340
|
+
v.match(/\(([^)]*)\)/) && (y = v.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
|
|
341
|
+
var S = y === void 0 || y === "[arguments not available]" ? void 0 : y.split(",");
|
|
342
342
|
return new n({
|
|
343
|
-
functionName:
|
|
344
|
-
args:
|
|
343
|
+
functionName: w,
|
|
344
|
+
args: S,
|
|
345
345
|
fileName: m[0],
|
|
346
346
|
lineNumber: m[1],
|
|
347
347
|
columnNumber: m[2],
|
|
@@ -357,108 +357,108 @@ const dn = /* @__PURE__ */ ln(un);
|
|
|
357
357
|
let ft = () => {
|
|
358
358
|
var r = (() => {
|
|
359
359
|
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, i = Object.prototype.hasOwnProperty, a = (f, p) => {
|
|
360
|
-
for (var
|
|
361
|
-
}, o = (f, p,
|
|
362
|
-
if (p && typeof p == "object" || typeof p == "function") for (let E of n(p)) !i.call(f, E) && E !==
|
|
360
|
+
for (var A in p) e(f, A, { get: p[A], enumerable: !0 });
|
|
361
|
+
}, o = (f, p, A, C) => {
|
|
362
|
+
if (p && typeof p == "object" || typeof p == "function") for (let E of n(p)) !i.call(f, E) && E !== A && e(f, E, { get: () => p[E], enumerable: !(C = t(p, E)) || C.enumerable });
|
|
363
363
|
return f;
|
|
364
364
|
}, s = (f) => o(e({}, "__esModule", { value: !0 }), f), l = {};
|
|
365
365
|
a(l, { default: () => Xr });
|
|
366
|
-
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,
|
|
366
|
+
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", S = (f) => f === void 0, x = (f) => {
|
|
367
367
|
const p = /* @__PURE__ */ new Map();
|
|
368
|
-
return (
|
|
369
|
-
const C = p.get(
|
|
368
|
+
return (A) => {
|
|
369
|
+
const C = p.get(A);
|
|
370
370
|
if (C) return C;
|
|
371
|
-
const E = f(
|
|
372
|
-
return p.set(
|
|
371
|
+
const E = f(A);
|
|
372
|
+
return p.set(A, E), E;
|
|
373
373
|
};
|
|
374
|
-
}, L = (f, p,
|
|
375
|
-
const C = { cache: {}, input: f, index: 0, indexMax: 0, options:
|
|
376
|
-
if (
|
|
374
|
+
}, L = (f, p, A = {}) => {
|
|
375
|
+
const C = { cache: {}, input: f, index: 0, indexMax: 0, options: A, output: [] };
|
|
376
|
+
if (z(p)(C) && C.index === f.length) return C.output;
|
|
377
377
|
throw new Error(`Failed to parse at index ${C.indexMax}`);
|
|
378
|
-
}, _ = (f, p) => g(f) ? Y(f, p) :
|
|
379
|
-
const
|
|
378
|
+
}, _ = (f, p) => g(f) ? Y(f, p) : y(f) ? N(f, p) : W(f, p), Y = (f, p) => {
|
|
379
|
+
const A = {};
|
|
380
380
|
for (const C of f) {
|
|
381
381
|
if (C.length !== 1) throw new Error(`Invalid character: "${C}"`);
|
|
382
382
|
const E = C.charCodeAt(0);
|
|
383
|
-
|
|
383
|
+
A[E] = !0;
|
|
384
384
|
}
|
|
385
385
|
return (C) => {
|
|
386
386
|
const E = C.index, P = C.input;
|
|
387
|
-
for (; C.index < P.length && P.charCodeAt(C.index) in
|
|
387
|
+
for (; C.index < P.length && P.charCodeAt(C.index) in A; ) C.index += 1;
|
|
388
388
|
const R = C.index;
|
|
389
389
|
if (R > E) {
|
|
390
|
-
if (!
|
|
390
|
+
if (!S(p) && !C.options.silent) {
|
|
391
391
|
const q = C.input.slice(E, R), j = c(p) ? p(q, P, String(E)) : p;
|
|
392
|
-
|
|
392
|
+
S(j) || C.output.push(j);
|
|
393
393
|
}
|
|
394
394
|
C.indexMax = Math.max(C.indexMax, C.index);
|
|
395
395
|
}
|
|
396
396
|
return !0;
|
|
397
397
|
};
|
|
398
398
|
}, W = (f, p) => {
|
|
399
|
-
const
|
|
399
|
+
const A = f.source, C = f.flags.replace(/y|$/, "y"), E = new RegExp(A, C);
|
|
400
400
|
return ne((P) => {
|
|
401
401
|
E.lastIndex = P.index;
|
|
402
402
|
const R = E.exec(P.input);
|
|
403
403
|
if (R) {
|
|
404
|
-
if (!
|
|
404
|
+
if (!S(p) && !P.options.silent) {
|
|
405
405
|
const q = c(p) ? p(...R, P.input, String(P.index)) : p;
|
|
406
|
-
|
|
406
|
+
S(q) || P.output.push(q);
|
|
407
407
|
}
|
|
408
408
|
return P.index += R[0].length, P.indexMax = Math.max(P.indexMax, P.index), !0;
|
|
409
409
|
} else return !1;
|
|
410
410
|
});
|
|
411
|
-
}, N = (f, p) => (
|
|
412
|
-
if (
|
|
413
|
-
if (!
|
|
414
|
-
const C = c(p) ? p(f,
|
|
415
|
-
|
|
411
|
+
}, N = (f, p) => (A) => {
|
|
412
|
+
if (A.input.startsWith(f, A.index)) {
|
|
413
|
+
if (!S(p) && !A.options.silent) {
|
|
414
|
+
const C = c(p) ? p(f, A.input, String(A.index)) : p;
|
|
415
|
+
S(C) || A.output.push(C);
|
|
416
416
|
}
|
|
417
|
-
return
|
|
417
|
+
return A.index += f.length, A.indexMax = Math.max(A.indexMax, A.index), !0;
|
|
418
418
|
} else return !1;
|
|
419
|
-
}, G = (f, p,
|
|
420
|
-
const E =
|
|
419
|
+
}, G = (f, p, A, C) => {
|
|
420
|
+
const E = z(f);
|
|
421
421
|
return ne(de(we((P) => {
|
|
422
422
|
let R = 0;
|
|
423
|
-
for (; R <
|
|
423
|
+
for (; R < A; ) {
|
|
424
424
|
const q = P.index;
|
|
425
425
|
if (!E(P) || (R += 1, P.index === q)) break;
|
|
426
426
|
}
|
|
427
427
|
return R >= p;
|
|
428
428
|
})));
|
|
429
429
|
}, X = (f, p) => G(f, 0, 1), K = (f, p) => G(f, 0, 1 / 0), re = (f, p) => {
|
|
430
|
-
const
|
|
430
|
+
const A = f.map(z);
|
|
431
431
|
return ne(de(we((C) => {
|
|
432
|
-
for (let E = 0, P =
|
|
432
|
+
for (let E = 0, P = A.length; E < P; E++) if (!A[E](C)) return !1;
|
|
433
433
|
return !0;
|
|
434
434
|
})));
|
|
435
435
|
}, U = (f, p) => {
|
|
436
|
-
const
|
|
436
|
+
const A = f.map(z);
|
|
437
437
|
return ne(de((C) => {
|
|
438
|
-
for (let E = 0, P =
|
|
438
|
+
for (let E = 0, P = A.length; E < P; E++) if (A[E](C)) return !0;
|
|
439
439
|
return !1;
|
|
440
440
|
}));
|
|
441
441
|
}, we = (f, p = !1) => {
|
|
442
|
-
const
|
|
442
|
+
const A = z(f);
|
|
443
443
|
return (C) => {
|
|
444
|
-
const E = C.index, P = C.output.length, R =
|
|
444
|
+
const E = C.index, P = C.output.length, R = A(C);
|
|
445
445
|
return (!R || p) && (C.index = E, C.output.length !== P && (C.output.length = P)), R;
|
|
446
446
|
};
|
|
447
|
-
}, de = (f, p) =>
|
|
447
|
+
}, de = (f, p) => z(f), ne = /* @__PURE__ */ (() => {
|
|
448
448
|
let f = 0;
|
|
449
449
|
return (p) => {
|
|
450
|
-
const
|
|
450
|
+
const A = z(p), C = f += 1;
|
|
451
451
|
return (E) => {
|
|
452
452
|
var st;
|
|
453
453
|
var P;
|
|
454
|
-
if (E.options.memoization === !1) return
|
|
454
|
+
if (E.options.memoization === !1) return A(E);
|
|
455
455
|
const R = E.index, q = (P = E.cache)[C] || (P[C] = /* @__PURE__ */ new Map()), j = q.get(R);
|
|
456
456
|
if (j === !1) return !1;
|
|
457
457
|
if (m(j)) return E.index = j, !0;
|
|
458
458
|
if (j) return E.index = j.index, (st = j.output) != null && st.length && E.output.push(...j.output), !0;
|
|
459
459
|
{
|
|
460
460
|
const lt = E.output.length;
|
|
461
|
-
if (
|
|
461
|
+
if (A(E)) {
|
|
462
462
|
const ct = E.index, ut = E.output.length;
|
|
463
463
|
if (ut > lt) {
|
|
464
464
|
const Qr = E.output.slice(lt, ut);
|
|
@@ -471,36 +471,36 @@ let ft = () => {
|
|
|
471
471
|
};
|
|
472
472
|
})(), T = (f) => {
|
|
473
473
|
let p;
|
|
474
|
-
return (
|
|
475
|
-
},
|
|
474
|
+
return (A) => (p || (p = z(f())), p(A));
|
|
475
|
+
}, z = x((f) => {
|
|
476
476
|
if (c(f)) return u(f) ? T(f) : f;
|
|
477
|
-
if (
|
|
477
|
+
if (y(f) || w(f)) return _(f);
|
|
478
478
|
if (g(f)) return re(f);
|
|
479
479
|
if (v(f)) return U(Object.values(f));
|
|
480
480
|
throw new Error("Invalid rule");
|
|
481
481
|
}), ie = "abcdefghijklmnopqrstuvwxyz", Fe = (f) => {
|
|
482
482
|
let p = "";
|
|
483
483
|
for (; f > 0; ) {
|
|
484
|
-
const
|
|
485
|
-
p = ie[
|
|
484
|
+
const A = (f - 1) % 26;
|
|
485
|
+
p = ie[A] + p, f = Math.floor((f - 1) / 26);
|
|
486
486
|
}
|
|
487
487
|
return p;
|
|
488
488
|
}, $ = (f) => {
|
|
489
489
|
let p = 0;
|
|
490
|
-
for (let
|
|
490
|
+
for (let A = 0, C = f.length; A < C; A++) p = p * 26 + ie.indexOf(f[A]) + 1;
|
|
491
491
|
return p;
|
|
492
492
|
}, Re = (f, p) => {
|
|
493
493
|
if (p < f) return Re(p, f);
|
|
494
|
-
const
|
|
495
|
-
for (; f <= p; )
|
|
496
|
-
return
|
|
497
|
-
}, ir = (f, p,
|
|
494
|
+
const A = [];
|
|
495
|
+
for (; f <= p; ) A.push(f++);
|
|
496
|
+
return A;
|
|
497
|
+
}, ir = (f, p, A) => Re(f, p).map((C) => String(C).padStart(A, "0")), Xe = (f, p) => Re($(f), $(p)).map(Fe), J = (f) => f, Qe = (f) => ar((p) => L(p, f, { memoization: !1 }).join("")), ar = (f) => {
|
|
498
498
|
const p = {};
|
|
499
|
-
return (
|
|
500
|
-
}, or = _(/^\*\*\/\*$/, ".*"), sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, p,
|
|
501
|
-
const
|
|
502
|
-
if (!
|
|
503
|
-
const C =
|
|
499
|
+
return (A) => p[A] ?? (p[A] = f(A));
|
|
500
|
+
}, or = _(/^\*\*\/\*$/, ".*"), sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, p, A) => `.*${p ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}`), lr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, p, A, C) => `.*${p ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Le = _(/\\./, J), cr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), ur = _(/./, J), dr = _(/^(?:!!)*!(.*)$/, (f, p) => `(?!^${ot(p)}$).*?`), hr = _(/^(!!)+/, ""), fr = U([dr, hr]), mr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = _(/^(\*\*\/)+/, "(?:^|.*/)"), pr = _(/\/(\*\*)$/, "(?:/.*|$)"), vr = _(/\*\*/, ".*"), et = U([mr, gr, pr, vr]), wr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = _(/\*/, "[^/]*"), tt = U([wr, yr]), rt = _("?", "[^/]"), Ar = _("[", J), Sr = _("]", J), br = _(/[!^]/, "^/"), Cr = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, J), _r = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), Er = _(/[^\]]/, J), xr = U([Le, _r, Cr, Er]), nt = re([Ar, X(br), K(xr), Sr]), Pr = _("{", "(?:"), Ir = _("}", ")"), kr = _(/(\d+)\.\.(\d+)/, (f, p, A) => ir(+p, +A, Math.min(p.length, A.length)).join("|")), Mr = _(/([a-z]+)\.\.([a-z]+)/, (f, p, A) => Xe(p, A).join("|")), Fr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, p, A) => Xe(p.toLowerCase(), A.toLowerCase()).join("|").toUpperCase()), Rr = U([kr, Mr, Fr]), it = re([Pr, Rr, Ir]), Lr = _("{", "(?:"), Tr = _("}", ")"), Br = _(",", "|"), Dr = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), Or = _(/[^}]/, J), Nr = T(() => at), Ur = U([et, tt, rt, nt, it, Nr, Le, Dr, Br, Or]), at = re([Lr, K(Ur), Tr]), zr = K(U([or, sr, lr, fr, et, tt, rt, nt, it, at, Le, cr, ur])), Vr = zr, $r = Qe(Vr), ot = $r, qr = _(/\\./, J), Wr = _(/./, J), Gr = _(/\*\*\*+/, "*"), jr = _(/([^/{[(!])\*\*/, (f, p) => `${p}*`), Hr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, p) => `${p}*`), Kr = K(U([qr, Gr, jr, Hr, Wr])), Jr = Kr, Zr = Qe(Jr), Yr = Zr, Te = (f, p) => {
|
|
501
|
+
const A = Array.isArray(f) ? f : [f];
|
|
502
|
+
if (!A.length) return !1;
|
|
503
|
+
const C = A.map(Te.compile), E = A.every((R) => /(\/(?:\*\*)?|\[\/\])$/.test(R)), P = p.replace(/[\\\/]+/g, "/").replace(/\/$/, E ? "/" : "");
|
|
504
504
|
return C.some((R) => R.test(P));
|
|
505
505
|
};
|
|
506
506
|
Te.compile = (f) => new RegExp(`^${ot(Yr(f))}$`, "s");
|
|
@@ -533,7 +533,7 @@ const mn = /^[/\\]{2}/, gn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,
|
|
|
533
533
|
function An() {
|
|
534
534
|
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
535
535
|
}
|
|
536
|
-
const
|
|
536
|
+
const ke = function(...r) {
|
|
537
537
|
r = r.map((n) => ce(n));
|
|
538
538
|
let e = "", t = !1;
|
|
539
539
|
for (let n = r.length - 1; n >= -1 && !t; n--) {
|
|
@@ -574,14 +574,14 @@ function Ke(r, e) {
|
|
|
574
574
|
}
|
|
575
575
|
const ve = function(r) {
|
|
576
576
|
return gn.test(r);
|
|
577
|
-
},
|
|
577
|
+
}, Sn = function(r) {
|
|
578
578
|
return ce(r);
|
|
579
579
|
}, jt = function(r) {
|
|
580
580
|
if (r === "..") return "";
|
|
581
581
|
const e = pn.exec(ce(r));
|
|
582
582
|
return e && e[1] || "";
|
|
583
|
-
},
|
|
584
|
-
const t =
|
|
583
|
+
}, bn = function(r, e) {
|
|
584
|
+
const t = ke(r).replace(mt, "$1").split("/"), n = ke(e).replace(mt, "$1").split("/");
|
|
585
585
|
if (n[0][1] === ":" && t[0][1] === ":" && t[0] !== n[0])
|
|
586
586
|
return n.join("/");
|
|
587
587
|
const i = [...t];
|
|
@@ -599,7 +599,7 @@ const ve = function(r) {
|
|
|
599
599
|
Boolean
|
|
600
600
|
);
|
|
601
601
|
return ce(
|
|
602
|
-
r.root ?
|
|
602
|
+
r.root ? ke(...t) : t.join("/")
|
|
603
603
|
);
|
|
604
604
|
}, Kt = function(r, e) {
|
|
605
605
|
const t = ce(r).split("/");
|
|
@@ -634,10 +634,10 @@ const ve = function(r) {
|
|
|
634
634
|
normalize: He,
|
|
635
635
|
normalizeString: Ke,
|
|
636
636
|
parse: _n,
|
|
637
|
-
relative:
|
|
638
|
-
resolve:
|
|
637
|
+
relative: bn,
|
|
638
|
+
resolve: ke,
|
|
639
639
|
sep: wn,
|
|
640
|
-
toNamespacedPath:
|
|
640
|
+
toNamespacedPath: Sn
|
|
641
641
|
}, xn = /* @__PURE__ */ (() => {
|
|
642
642
|
var r;
|
|
643
643
|
return ((r = globalThis.process) == null ? void 0 : r.platform) === "win32" ? ";" : ":";
|
|
@@ -646,8 +646,8 @@ const ve = function(r) {
|
|
|
646
646
|
return t === "delimiter" ? r : t === "posix" ? $e : t === "win32" ? In : Pn[t] || gt[t];
|
|
647
647
|
}
|
|
648
648
|
}), $e = /* @__PURE__ */ Jt(":"), In = /* @__PURE__ */ Jt(";");
|
|
649
|
-
var
|
|
650
|
-
const
|
|
649
|
+
var M = /* @__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))(M || {}), 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 || {});
|
|
650
|
+
const kn = !0;
|
|
651
651
|
function F(r, e, t = r) {
|
|
652
652
|
return (n) => {
|
|
653
653
|
const i = `${n}`, a = i.indexOf(e, r.length);
|
|
@@ -658,7 +658,7 @@ function Zt(r, e, t, n) {
|
|
|
658
658
|
const i = r.substring(0, n) + t, a = r.substring(n + e.length), o = a.indexOf(e);
|
|
659
659
|
return ~o ? i + Zt(a, e, t, o) : i + a;
|
|
660
660
|
}
|
|
661
|
-
function
|
|
661
|
+
function Mn(r = kn) {
|
|
662
662
|
return {
|
|
663
663
|
isColorSupported: r,
|
|
664
664
|
reset: r ? (e) => `\x1B[0m${e}\x1B[0m` : String,
|
|
@@ -688,36 +688,36 @@ function kn(r = Mn) {
|
|
|
688
688
|
bgWhite: r ? F("\x1B[47m", "\x1B[49m") : String
|
|
689
689
|
};
|
|
690
690
|
}
|
|
691
|
-
const B =
|
|
692
|
-
[
|
|
693
|
-
[
|
|
694
|
-
[
|
|
695
|
-
[
|
|
696
|
-
[
|
|
691
|
+
const B = Mn(), qe = {
|
|
692
|
+
[I.Error]: M.Error,
|
|
693
|
+
[I.Warning]: M.Warning,
|
|
694
|
+
[I.Log]: M.Log,
|
|
695
|
+
[I.Verbose]: M.Verbose,
|
|
696
|
+
[I.Debug]: M.Debug
|
|
697
697
|
}, Fn = {
|
|
698
|
-
[
|
|
699
|
-
[
|
|
700
|
-
[
|
|
701
|
-
[
|
|
702
|
-
[
|
|
698
|
+
[M.Error]: I.Error,
|
|
699
|
+
[M.Warning]: I.Warning,
|
|
700
|
+
[M.Log]: I.Log,
|
|
701
|
+
[M.Verbose]: I.Verbose,
|
|
702
|
+
[M.Debug]: I.Debug
|
|
703
703
|
}, pt = [
|
|
704
|
+
I.Error,
|
|
705
|
+
I.Warning,
|
|
706
|
+
I.Log,
|
|
707
|
+
I.Verbose,
|
|
708
|
+
I.Debug
|
|
709
|
+
], Rn = {
|
|
710
|
+
[M.Error]: B.red,
|
|
711
|
+
[M.Warning]: B.yellow,
|
|
712
|
+
[M.Log]: B.blue,
|
|
713
|
+
[M.Verbose]: B.cyan,
|
|
714
|
+
[M.Debug]: B.green
|
|
715
|
+
}, vt = [
|
|
704
716
|
M.Error,
|
|
705
717
|
M.Warning,
|
|
706
718
|
M.Log,
|
|
707
719
|
M.Verbose,
|
|
708
720
|
M.Debug
|
|
709
|
-
], Rn = {
|
|
710
|
-
[k.Error]: B.red,
|
|
711
|
-
[k.Warning]: B.yellow,
|
|
712
|
-
[k.Log]: B.blue,
|
|
713
|
-
[k.Verbose]: B.cyan,
|
|
714
|
-
[k.Debug]: B.green
|
|
715
|
-
}, vt = [
|
|
716
|
-
k.Error,
|
|
717
|
-
k.Warning,
|
|
718
|
-
k.Log,
|
|
719
|
-
k.Verbose,
|
|
720
|
-
k.Debug
|
|
721
721
|
], wt = [te.JSON, te.Pretty];
|
|
722
722
|
function Ln(r) {
|
|
723
723
|
return r.stack == null ? [] : r.stack.split(`
|
|
@@ -812,31 +812,31 @@ function Ee(r) {
|
|
|
812
812
|
${r.error.stack}`), i;
|
|
813
813
|
}
|
|
814
814
|
function Bn(r) {
|
|
815
|
-
return r >=
|
|
815
|
+
return r >= M.Debug;
|
|
816
816
|
}
|
|
817
817
|
function Dn(r) {
|
|
818
|
-
return r >=
|
|
818
|
+
return r >= M.Verbose;
|
|
819
819
|
}
|
|
820
820
|
function On(r) {
|
|
821
|
-
return r >=
|
|
821
|
+
return r >= M.Log;
|
|
822
822
|
}
|
|
823
823
|
function Nn(r) {
|
|
824
|
-
return r >=
|
|
824
|
+
return r >= M.Warning;
|
|
825
825
|
}
|
|
826
826
|
function Un(r) {
|
|
827
|
-
return r >=
|
|
827
|
+
return r >= M.Error;
|
|
828
828
|
}
|
|
829
829
|
function Qt() {
|
|
830
830
|
return typeof window < "u";
|
|
831
831
|
}
|
|
832
|
-
function
|
|
832
|
+
function zn() {
|
|
833
833
|
return !Qt() && We() === te.Pretty;
|
|
834
834
|
}
|
|
835
|
-
function
|
|
836
|
-
return
|
|
835
|
+
function Vn(r, e) {
|
|
836
|
+
return zn() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
|
|
837
837
|
}
|
|
838
838
|
const Je = {
|
|
839
|
-
logLevel:
|
|
839
|
+
logLevel: M.Debug,
|
|
840
840
|
format: te.JSON,
|
|
841
841
|
timeFormatter: (r) => r.toISOString()
|
|
842
842
|
};
|
|
@@ -853,7 +853,7 @@ function er(r) {
|
|
|
853
853
|
const e = {
|
|
854
854
|
fields: {},
|
|
855
855
|
context: r,
|
|
856
|
-
logLevel:
|
|
856
|
+
logLevel: M.Debug,
|
|
857
857
|
format: te.JSON,
|
|
858
858
|
shouldUseGlobalConfig: !1,
|
|
859
859
|
errorProcessor: (c) => c,
|
|
@@ -961,71 +961,71 @@ function er(r) {
|
|
|
961
961
|
const v = n();
|
|
962
962
|
if (Qt() && v === te.Pretty) {
|
|
963
963
|
c.fields = Object.fromEntries(
|
|
964
|
-
Object.entries(c.fields).filter(([
|
|
965
|
-
if (
|
|
966
|
-
return [
|
|
964
|
+
Object.entries(c.fields).filter(([S, x]) => {
|
|
965
|
+
if (S === "isNestSystemModule" || S === "nestSystemModule" || S === "context")
|
|
966
|
+
return [S, x];
|
|
967
967
|
})
|
|
968
968
|
);
|
|
969
|
-
const
|
|
970
|
-
Array.isArray(
|
|
969
|
+
const y = m ?? e.fields;
|
|
970
|
+
Array.isArray(y) && y.length > 0 ? console[u](Ee(c), ...y) : Object.keys(y).length > 0 ? console[u](Ee(c), y) : console[u](Ee(c));
|
|
971
971
|
return;
|
|
972
972
|
}
|
|
973
|
-
const
|
|
974
|
-
console[u](
|
|
973
|
+
const w = v === te.Pretty ? Ee(c) : JSON.stringify(c);
|
|
974
|
+
console[u](w);
|
|
975
975
|
}, s = {
|
|
976
|
-
[
|
|
977
|
-
[
|
|
978
|
-
[
|
|
979
|
-
[
|
|
976
|
+
[I.Debug]: Bn,
|
|
977
|
+
[I.Verbose]: Dn,
|
|
978
|
+
[I.Log]: On,
|
|
979
|
+
[I.Warning]: Nn
|
|
980
980
|
}, l = {
|
|
981
|
-
[
|
|
982
|
-
[
|
|
983
|
-
[
|
|
984
|
-
[
|
|
981
|
+
[I.Debug]: "debug",
|
|
982
|
+
[I.Verbose]: "log",
|
|
983
|
+
[I.Log]: "log",
|
|
984
|
+
[I.Warning]: "warn"
|
|
985
985
|
}, g = (c, u, m) => {
|
|
986
|
-
const v = t(),
|
|
987
|
-
if (!
|
|
986
|
+
const v = t(), w = s[c];
|
|
987
|
+
if (!w(v))
|
|
988
988
|
return;
|
|
989
|
-
const
|
|
989
|
+
const y = a(m), S = Xt(
|
|
990
990
|
c,
|
|
991
991
|
e.context,
|
|
992
|
-
|
|
992
|
+
y,
|
|
993
993
|
u,
|
|
994
994
|
i()
|
|
995
995
|
);
|
|
996
|
-
o(
|
|
996
|
+
o(S, l[c], y);
|
|
997
997
|
};
|
|
998
998
|
return e.debug = (c, ...u) => {
|
|
999
|
-
g(
|
|
999
|
+
g(I.Debug, c, u);
|
|
1000
1000
|
}, e.verbose = (c, ...u) => {
|
|
1001
|
-
g(
|
|
1001
|
+
g(I.Verbose, c, u);
|
|
1002
1002
|
}, e.log = (c, ...u) => {
|
|
1003
|
-
g(
|
|
1003
|
+
g(I.Log, c, u);
|
|
1004
1004
|
}, e.warn = (c, ...u) => {
|
|
1005
|
-
g(
|
|
1005
|
+
g(I.Warning, c, u);
|
|
1006
1006
|
}, e.error = (c, u, ...m) => {
|
|
1007
1007
|
const v = t();
|
|
1008
1008
|
if (!Un(v))
|
|
1009
1009
|
return;
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1010
|
+
const w = a(m), y = Tn(
|
|
1011
|
+
I.Error,
|
|
1012
1012
|
e.context,
|
|
1013
|
-
|
|
1013
|
+
w,
|
|
1014
1014
|
c,
|
|
1015
1015
|
u,
|
|
1016
1016
|
i()
|
|
1017
1017
|
);
|
|
1018
|
-
o(
|
|
1018
|
+
o(y, "error", w);
|
|
1019
1019
|
}, e.errorWithError = (c, u, ...m) => e.withError(u).error(c, void 0, ...m), e;
|
|
1020
1020
|
}
|
|
1021
1021
|
function qn(r) {
|
|
1022
1022
|
var a;
|
|
1023
1023
|
const t = dn.parse(new Error())[1], n = ((a = t.fileName) == null ? void 0 : a.replace("async", "").trim()) ?? "", i = $e.join(...n.split($e.sep).slice(-2));
|
|
1024
|
-
return r = r ?? `${i}:${t.lineNumber}`, er(
|
|
1024
|
+
return r = r ?? `${i}:${t.lineNumber}`, er(Vn(n, r));
|
|
1025
1025
|
}
|
|
1026
1026
|
const Wn = (r) => qn(r).useGlobalConfig();
|
|
1027
1027
|
let Q = [];
|
|
1028
|
-
const
|
|
1028
|
+
const St = 100;
|
|
1029
1029
|
async function Gn() {
|
|
1030
1030
|
if (Q.length === 0)
|
|
1031
1031
|
return;
|
|
@@ -1034,7 +1034,7 @@ async function Gn() {
|
|
|
1034
1034
|
try {
|
|
1035
1035
|
await jn();
|
|
1036
1036
|
} catch (e) {
|
|
1037
|
-
h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)), Q.unshift(...r), Q.length >
|
|
1037
|
+
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));
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
1040
|
async function jn(r) {
|
|
@@ -1174,36 +1174,36 @@ class Zn {
|
|
|
1174
1174
|
throw new Error("Failed to allocate AvatarFlameParams structure");
|
|
1175
1175
|
let i = 0;
|
|
1176
1176
|
for (let v = 0; v < 300; v++) {
|
|
1177
|
-
const
|
|
1178
|
-
this.module.setValue(n + i,
|
|
1177
|
+
const w = ((a = e.shape_params) == null ? void 0 : a[v]) || 0;
|
|
1178
|
+
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1179
1179
|
}
|
|
1180
1180
|
for (let v = 0; v < 100; v++) {
|
|
1181
|
-
const
|
|
1182
|
-
this.module.setValue(n + i,
|
|
1181
|
+
const w = ((o = e.expr_params) == null ? void 0 : o[v]) || 0;
|
|
1182
|
+
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1183
1183
|
}
|
|
1184
1184
|
for (let v = 0; v < 3; v++) {
|
|
1185
|
-
const
|
|
1186
|
-
this.module.setValue(n + i,
|
|
1185
|
+
const w = ((s = e.rotation) == null ? void 0 : s[v]) || 0;
|
|
1186
|
+
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1187
1187
|
}
|
|
1188
1188
|
for (let v = 0; v < 3; v++) {
|
|
1189
|
-
const
|
|
1190
|
-
this.module.setValue(n + i,
|
|
1189
|
+
const w = ((l = e.translation) == null ? void 0 : l[v]) || 0;
|
|
1190
|
+
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1191
1191
|
}
|
|
1192
1192
|
for (let v = 0; v < 3; v++) {
|
|
1193
|
-
const
|
|
1194
|
-
this.module.setValue(n + i,
|
|
1193
|
+
const w = ((g = e.neck_pose) == null ? void 0 : g[v]) || 0;
|
|
1194
|
+
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1195
1195
|
}
|
|
1196
1196
|
for (let v = 0; v < 3; v++) {
|
|
1197
|
-
const
|
|
1198
|
-
this.module.setValue(n + i,
|
|
1197
|
+
const w = ((c = e.jaw_pose) == null ? void 0 : c[v]) || 0;
|
|
1198
|
+
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1199
1199
|
}
|
|
1200
1200
|
for (let v = 0; v < 6; v++) {
|
|
1201
|
-
const
|
|
1202
|
-
this.module.setValue(n + i,
|
|
1201
|
+
const w = ((u = e.eyes_pose) == null ? void 0 : u[v]) || 0;
|
|
1202
|
+
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1203
1203
|
}
|
|
1204
1204
|
for (let v = 0; v < 2; v++) {
|
|
1205
|
-
const
|
|
1206
|
-
this.module.setValue(n + i,
|
|
1205
|
+
const w = ((m = e.eyelid) == null ? void 0 : m[v]) || 0;
|
|
1206
|
+
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1207
1207
|
}
|
|
1208
1208
|
return this.module.setValue(n + i, e.has_eyelid ? 1 : 0, "i32"), i += 4, n;
|
|
1209
1209
|
}
|
|
@@ -1793,7 +1793,7 @@ class Yn {
|
|
|
1793
1793
|
}
|
|
1794
1794
|
}
|
|
1795
1795
|
}
|
|
1796
|
-
class
|
|
1796
|
+
class b {
|
|
1797
1797
|
/**
|
|
1798
1798
|
* SDK 初始化
|
|
1799
1799
|
* @param appId 前端需要在 HTTP Headers 和 WebSocket Headers 中都带上
|
|
@@ -1960,7 +1960,7 @@ class S {
|
|
|
1960
1960
|
h[a](`[Telemetry] ${e}`, i);
|
|
1961
1961
|
}
|
|
1962
1962
|
}
|
|
1963
|
-
d(
|
|
1963
|
+
d(b, "_isInitialized", !1), d(b, "_configuration", null), d(b, "_sessionToken", null), d(b, "_userId", null), d(b, "_version", "1.0.0-beta.8"), d(b, "_avatarCore", null), d(b, "_dynamicSdkConfig", null), d(b, "_logLevels", {
|
|
1964
1964
|
debug: "log",
|
|
1965
1965
|
info: "log",
|
|
1966
1966
|
warning: "warn",
|
|
@@ -1971,7 +1971,7 @@ const Ce = class Ce {
|
|
|
1971
1971
|
d(this, "audio", null);
|
|
1972
1972
|
d(this, "streamingPlayer", null);
|
|
1973
1973
|
d(this, "_isPlaying", !1);
|
|
1974
|
-
d(this, "fps",
|
|
1974
|
+
d(this, "fps", k.animation.fps);
|
|
1975
1975
|
d(this, "onEndedCallback");
|
|
1976
1976
|
d(this, "useStreaming", !1);
|
|
1977
1977
|
}
|
|
@@ -2029,9 +2029,9 @@ const Ce = class Ce {
|
|
|
2029
2029
|
async createAndInitializeStreamingPlayer() {
|
|
2030
2030
|
if (this.streamingPlayer)
|
|
2031
2031
|
return;
|
|
2032
|
-
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-
|
|
2032
|
+
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-fSZLLTe1.js");
|
|
2033
2033
|
this.streamingPlayer = new e({
|
|
2034
|
-
sampleRate:
|
|
2034
|
+
sampleRate: k.audio.sampleRate,
|
|
2035
2035
|
channelCount: 1,
|
|
2036
2036
|
debug: !1
|
|
2037
2037
|
});
|
|
@@ -2039,7 +2039,7 @@ const Ce = class Ce {
|
|
|
2039
2039
|
await this.streamingPlayer.initialize();
|
|
2040
2040
|
} catch (t) {
|
|
2041
2041
|
const n = t instanceof Error ? t.message : String(t);
|
|
2042
|
-
throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n),
|
|
2042
|
+
throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n), b.logEvent("character_player", "error", {
|
|
2043
2043
|
event: "streaming_player_initialize_failed",
|
|
2044
2044
|
reason: n
|
|
2045
2045
|
}), t;
|
|
@@ -2105,7 +2105,7 @@ const Ce = class Ce {
|
|
|
2105
2105
|
}
|
|
2106
2106
|
};
|
|
2107
2107
|
d(Ce, "audioUnlocked", !1);
|
|
2108
|
-
let
|
|
2108
|
+
let be = Ce;
|
|
2109
2109
|
function Xn() {
|
|
2110
2110
|
let r = 0, e = 0;
|
|
2111
2111
|
for (let n = 0; n < 28; n += 7) {
|
|
@@ -2140,7 +2140,7 @@ function Oe(r, e, t) {
|
|
|
2140
2140
|
}
|
|
2141
2141
|
}
|
|
2142
2142
|
const Pe = 4294967296;
|
|
2143
|
-
function
|
|
2143
|
+
function bt(r) {
|
|
2144
2144
|
const e = r[0] === "-";
|
|
2145
2145
|
e && (r = r.slice(1));
|
|
2146
2146
|
const t = 1e6;
|
|
@@ -2257,10 +2257,10 @@ function ri() {
|
|
|
2257
2257
|
return typeof t != "string" && (t = t.toString()), xt(t), t;
|
|
2258
2258
|
},
|
|
2259
2259
|
enc(t) {
|
|
2260
|
-
return typeof t != "string" && (t = t.toString()), Et(t),
|
|
2260
|
+
return typeof t != "string" && (t = t.toString()), Et(t), bt(t);
|
|
2261
2261
|
},
|
|
2262
2262
|
uEnc(t) {
|
|
2263
|
-
return typeof t != "string" && (t = t.toString()), xt(t),
|
|
2263
|
+
return typeof t != "string" && (t = t.toString()), xt(t), bt(t);
|
|
2264
2264
|
},
|
|
2265
2265
|
dec(t, n) {
|
|
2266
2266
|
return Qn(t, n);
|
|
@@ -2713,9 +2713,9 @@ const he = {
|
|
|
2713
2713
|
},
|
|
2714
2714
|
fromJSON(r) {
|
|
2715
2715
|
return {
|
|
2716
|
-
reqId:
|
|
2717
|
-
audio:
|
|
2718
|
-
end:
|
|
2716
|
+
reqId: V(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
2717
|
+
audio: V(r.audio) ? di(r.audio) : new Uint8Array(0),
|
|
2718
|
+
end: V(r.end) ? globalThis.Boolean(r.end) : !1
|
|
2719
2719
|
};
|
|
2720
2720
|
},
|
|
2721
2721
|
toJSON(r) {
|
|
@@ -2730,7 +2730,7 @@ const he = {
|
|
|
2730
2730
|
return e.reqId = r.reqId ?? "", e.audio = r.audio ?? new Uint8Array(0), e.end = r.end ?? !1, e;
|
|
2731
2731
|
}
|
|
2732
2732
|
};
|
|
2733
|
-
function
|
|
2733
|
+
function kt() {
|
|
2734
2734
|
return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
|
|
2735
2735
|
}
|
|
2736
2736
|
const fe = {
|
|
@@ -2761,7 +2761,7 @@ const fe = {
|
|
|
2761
2761
|
decode(r, e) {
|
|
2762
2762
|
const t = r instanceof O ? r : new O(r);
|
|
2763
2763
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2764
|
-
const i =
|
|
2764
|
+
const i = kt();
|
|
2765
2765
|
for (; t.pos < n; ) {
|
|
2766
2766
|
const a = t.uint32();
|
|
2767
2767
|
switch (a >>> 3) {
|
|
@@ -2884,11 +2884,11 @@ const fe = {
|
|
|
2884
2884
|
},
|
|
2885
2885
|
fromPartial(r) {
|
|
2886
2886
|
var t, n, i, a, o, s, l;
|
|
2887
|
-
const e =
|
|
2887
|
+
const e = kt();
|
|
2888
2888
|
return e.translation = ((t = r.translation) == null ? void 0 : t.map((g) => g)) || [], e.rotation = ((n = r.rotation) == null ? void 0 : n.map((g) => g)) || [], e.neckPose = ((i = r.neckPose) == null ? void 0 : i.map((g) => g)) || [], e.jawPose = ((a = r.jawPose) == null ? void 0 : a.map((g) => g)) || [], e.eyePose = ((o = r.eyePose) == null ? void 0 : o.map((g) => g)) || [], e.eyeLid = ((s = r.eyeLid) == null ? void 0 : s.map((g) => g)) || [], e.expression = ((l = r.expression) == null ? void 0 : l.map((g) => g)) || [], e;
|
|
2889
2889
|
}
|
|
2890
2890
|
};
|
|
2891
|
-
function
|
|
2891
|
+
function Mt() {
|
|
2892
2892
|
return { keyframes: [] };
|
|
2893
2893
|
}
|
|
2894
2894
|
const me = {
|
|
@@ -2900,7 +2900,7 @@ const me = {
|
|
|
2900
2900
|
decode(r, e) {
|
|
2901
2901
|
const t = r instanceof O ? r : new O(r);
|
|
2902
2902
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2903
|
-
const i =
|
|
2903
|
+
const i = Mt();
|
|
2904
2904
|
for (; t.pos < n; ) {
|
|
2905
2905
|
const a = t.uint32();
|
|
2906
2906
|
switch (a >>> 3) {
|
|
@@ -2932,7 +2932,7 @@ const me = {
|
|
|
2932
2932
|
},
|
|
2933
2933
|
fromPartial(r) {
|
|
2934
2934
|
var t;
|
|
2935
|
-
const e =
|
|
2935
|
+
const e = Mt();
|
|
2936
2936
|
return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => fe.fromPartial(n))) || [], e;
|
|
2937
2937
|
}
|
|
2938
2938
|
};
|
|
@@ -2971,8 +2971,8 @@ const ge = {
|
|
|
2971
2971
|
},
|
|
2972
2972
|
fromJSON(r) {
|
|
2973
2973
|
return {
|
|
2974
|
-
reqId:
|
|
2975
|
-
animation:
|
|
2974
|
+
reqId: V(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
2975
|
+
animation: V(r.animation) ? me.fromJSON(r.animation) : void 0
|
|
2976
2976
|
};
|
|
2977
2977
|
},
|
|
2978
2978
|
toJSON(r) {
|
|
@@ -3028,9 +3028,9 @@ const pe = {
|
|
|
3028
3028
|
},
|
|
3029
3029
|
fromJSON(r) {
|
|
3030
3030
|
return {
|
|
3031
|
-
reqId:
|
|
3032
|
-
code:
|
|
3033
|
-
reason:
|
|
3031
|
+
reqId: V(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
3032
|
+
code: V(r.code) ? globalThis.Number(r.code) : 0,
|
|
3033
|
+
reason: V(r.reason) ? globalThis.String(r.reason) : ""
|
|
3034
3034
|
};
|
|
3035
3035
|
},
|
|
3036
3036
|
toJSON(r) {
|
|
@@ -3092,10 +3092,10 @@ const Ge = {
|
|
|
3092
3092
|
},
|
|
3093
3093
|
fromJSON(r) {
|
|
3094
3094
|
return {
|
|
3095
|
-
type:
|
|
3096
|
-
error:
|
|
3097
|
-
serverResponseAnimation:
|
|
3098
|
-
clientAudioInput:
|
|
3095
|
+
type: V(r.type) ? ci(r.type) : 0,
|
|
3096
|
+
error: V(r.error) ? pe.fromJSON(r.error) : void 0,
|
|
3097
|
+
serverResponseAnimation: V(r.serverResponseAnimation) ? ge.fromJSON(r.serverResponseAnimation) : void 0,
|
|
3098
|
+
clientAudioInput: V(r.clientAudioInput) ? he.fromJSON(r.clientAudioInput) : void 0
|
|
3099
3099
|
};
|
|
3100
3100
|
},
|
|
3101
3101
|
toJSON(r) {
|
|
@@ -3122,7 +3122,7 @@ function hi(r) {
|
|
|
3122
3122
|
e.push(globalThis.String.fromCharCode(t));
|
|
3123
3123
|
}), globalThis.btoa(e.join(""));
|
|
3124
3124
|
}
|
|
3125
|
-
function
|
|
3125
|
+
function V(r) {
|
|
3126
3126
|
return r != null;
|
|
3127
3127
|
}
|
|
3128
3128
|
let fi = (r) => crypto.getRandomValues(new Uint8Array(r)), mi = (r, e, t) => {
|
|
@@ -3191,7 +3191,7 @@ class yi extends wi {
|
|
|
3191
3191
|
try {
|
|
3192
3192
|
this.isConnecting = !0, this.currentCharacterId = t;
|
|
3193
3193
|
const n = this.buildWebSocketUrl(t);
|
|
3194
|
-
h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"),
|
|
3194
|
+
h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"), b.logEvent("character_animation_service", "info", {
|
|
3195
3195
|
characterId: t,
|
|
3196
3196
|
event: "connect_success",
|
|
3197
3197
|
url: n
|
|
@@ -3199,7 +3199,7 @@ class yi extends wi {
|
|
|
3199
3199
|
} catch (n) {
|
|
3200
3200
|
this.isConnecting = !1;
|
|
3201
3201
|
const i = n instanceof Error ? n.message : String(n);
|
|
3202
|
-
throw h.error("[AnimationWebSocketClient] Connection failed:", i),
|
|
3202
|
+
throw h.error("[AnimationWebSocketClient] Connection failed:", i), b.logEvent("character_animation_service", "error", {
|
|
3203
3203
|
characterId: t,
|
|
3204
3204
|
event: "connect_failed",
|
|
3205
3205
|
reason: i
|
|
@@ -3232,7 +3232,7 @@ class yi extends wi {
|
|
|
3232
3232
|
return this.ws.send(s), !0;
|
|
3233
3233
|
} catch (a) {
|
|
3234
3234
|
const o = a instanceof Error ? a.message : String(a);
|
|
3235
|
-
return h.error("[AnimationWebSocketClient] Failed to send audio data:", o),
|
|
3235
|
+
return h.error("[AnimationWebSocketClient] Failed to send audio data:", o), b.logEvent("character_animation_service", "warning", {
|
|
3236
3236
|
characterId: this.currentCharacterId,
|
|
3237
3237
|
event: "send_audio_failed",
|
|
3238
3238
|
reqId: t,
|
|
@@ -3271,19 +3271,19 @@ class yi extends wi {
|
|
|
3271
3271
|
this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"), n();
|
|
3272
3272
|
}, this.ws.onmessage = (a) => {
|
|
3273
3273
|
a.data instanceof ArrayBuffer ? this.handleMessage(a.data) : a.data instanceof Blob ? a.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((o) => {
|
|
3274
|
-
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", o),
|
|
3274
|
+
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", o), b.logEvent("character_animation_service", "error", {
|
|
3275
3275
|
characterId: this.currentCharacterId,
|
|
3276
3276
|
event: "decode_blob_failed",
|
|
3277
3277
|
reason: o instanceof Error ? o.message : String(o)
|
|
3278
3278
|
}), this.emit("error", o);
|
|
3279
3279
|
}) : h.warn("[AnimationWebSocketClient] Received non-binary data:", typeof a.data);
|
|
3280
3280
|
}, this.ws.onerror = (a) => {
|
|
3281
|
-
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", a),
|
|
3281
|
+
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", a), b.logEvent("character_animation_service", "error", {
|
|
3282
3282
|
characterId: this.currentCharacterId,
|
|
3283
3283
|
event: "websocket_error"
|
|
3284
3284
|
}), this.emit("error", new Error("WebSocket error")), !this.isManuallyDisconnected && this.currentRetryCount < this.reconnectAttempts && this.scheduleReconnect();
|
|
3285
3285
|
}, this.ws.onclose = (a) => {
|
|
3286
|
-
h.log("[AnimationWebSocketClient] WebSocket closed:", a.code, a.reason), this.emit("disconnected", a.reason || "Connection closed"), a.code === 1012 &&
|
|
3286
|
+
h.log("[AnimationWebSocketClient] WebSocket closed:", a.code, a.reason), this.emit("disconnected", a.reason || "Connection closed"), a.code === 1012 && b.logEvent("character_animation_service", "error", {
|
|
3287
3287
|
characterId: this.currentCharacterId,
|
|
3288
3288
|
event: "service_restart",
|
|
3289
3289
|
reason: a.reason || "service restart"
|
|
@@ -3298,7 +3298,7 @@ class yi extends wi {
|
|
|
3298
3298
|
try {
|
|
3299
3299
|
const n = new O(new Uint8Array(t)), i = Ge.decode(n);
|
|
3300
3300
|
if (i.error) {
|
|
3301
|
-
h.error(`[AnimationWebSocketClient] Server error: reqId=${i.error.reqId}, code=${i.error.code}, reason=${i.error.reason}`),
|
|
3301
|
+
h.error(`[AnimationWebSocketClient] Server error: reqId=${i.error.reqId}, code=${i.error.code}, reason=${i.error.reason}`), b.logEvent("character_animation_service", "error", {
|
|
3302
3302
|
characterId: this.currentCharacterId,
|
|
3303
3303
|
event: "server_error",
|
|
3304
3304
|
reqId: i.error.reqId,
|
|
@@ -3308,7 +3308,7 @@ class yi extends wi {
|
|
|
3308
3308
|
return;
|
|
3309
3309
|
}
|
|
3310
3310
|
if (i.type === _e.MESSAGE_ERROR) {
|
|
3311
|
-
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"),
|
|
3311
|
+
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), b.logEvent("character_animation_service", "warning", {
|
|
3312
3312
|
characterId: this.currentCharacterId,
|
|
3313
3313
|
event: "message_error_without_payload"
|
|
3314
3314
|
}), this.emit("error", new Error("Server returned error message without error details"));
|
|
@@ -3317,7 +3317,7 @@ class yi extends wi {
|
|
|
3317
3317
|
this.emit("message", i);
|
|
3318
3318
|
} catch (n) {
|
|
3319
3319
|
const i = n instanceof Error ? n.message : String(n);
|
|
3320
|
-
h.error("[AnimationWebSocketClient] Failed to decode message:", i),
|
|
3320
|
+
h.error("[AnimationWebSocketClient] Failed to decode message:", i), b.logEvent("character_animation_service", "error", {
|
|
3321
3321
|
characterId: this.currentCharacterId,
|
|
3322
3322
|
event: "decode_failed",
|
|
3323
3323
|
reason: i
|
|
@@ -3341,15 +3341,15 @@ class Ai {
|
|
|
3341
3341
|
// 组合播放层
|
|
3342
3342
|
d(this, "currentReqId", null);
|
|
3343
3343
|
d(this, "hasSentEnd", !1);
|
|
3344
|
-
d(this, "audioBytesPerSecond",
|
|
3344
|
+
d(this, "audioBytesPerSecond", k.audio.sampleRate * 2);
|
|
3345
3345
|
d(this, "audioMetrics", this.createAudioMetrics());
|
|
3346
3346
|
this.dataController = e;
|
|
3347
|
-
const t =
|
|
3347
|
+
const t = b.getEnvironmentConfig();
|
|
3348
3348
|
this.wsClient = new yi({
|
|
3349
3349
|
wsUrl: t.driveningressWsUrl,
|
|
3350
3350
|
reconnectAttempts: 5,
|
|
3351
3351
|
debug: !1,
|
|
3352
|
-
jwtToken:
|
|
3352
|
+
jwtToken: b.sessionToken || void 0
|
|
3353
3353
|
}), this.setupWebSocketListeners();
|
|
3354
3354
|
}
|
|
3355
3355
|
/**
|
|
@@ -3363,7 +3363,7 @@ class Ai {
|
|
|
3363
3363
|
*/
|
|
3364
3364
|
sendAudioData(e, t) {
|
|
3365
3365
|
var s, l;
|
|
3366
|
-
this.hasSentEnd && this.dataController.getIsPlaying() && this.currentReqId && this.dataController.interrupt(), this.currentReqId || (this.currentReqId = this.wsClient.generateReqId(), this.hasSentEnd = !1, this.resetAudioMetrics(),
|
|
3366
|
+
this.hasSentEnd && this.dataController.getIsPlaying() && this.currentReqId && this.dataController.interrupt(), this.currentReqId || (this.currentReqId = this.wsClient.generateReqId(), this.hasSentEnd = !1, this.resetAudioMetrics(), b.logEvent("character_manager", "info", {
|
|
3367
3367
|
characterId: this.dataController.getAvatarId(),
|
|
3368
3368
|
event: "conversation_started",
|
|
3369
3369
|
reqId: this.currentReqId
|
|
@@ -3373,7 +3373,7 @@ class Ai {
|
|
|
3373
3373
|
n.startTimestamp === 0 && (n.startTimestamp = Date.now(), i = !0), n.accumulatedBytes += e.byteLength;
|
|
3374
3374
|
const a = n.accumulatedBytes / this.audioBytesPerSecond;
|
|
3375
3375
|
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)) {
|
|
3376
|
-
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")),
|
|
3376
|
+
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")), b.logEvent("character_animation_service", "error", {
|
|
3377
3377
|
characterId: this.dataController.getAvatarId(),
|
|
3378
3378
|
event: "send_audio_failed",
|
|
3379
3379
|
reqId: this.currentReqId
|
|
@@ -3398,7 +3398,7 @@ class Ai {
|
|
|
3398
3398
|
* 重置请求ID(用于打断后清理)
|
|
3399
3399
|
*/
|
|
3400
3400
|
resetReqId() {
|
|
3401
|
-
this.currentReqId = null, this.hasSentEnd = !1;
|
|
3401
|
+
this.currentReqId = null, this.hasSentEnd = !1, this.resetAudioMetrics();
|
|
3402
3402
|
}
|
|
3403
3403
|
/**
|
|
3404
3404
|
* 设置 WebSocket 事件监听器
|
|
@@ -3406,29 +3406,29 @@ class Ai {
|
|
|
3406
3406
|
setupWebSocketListeners() {
|
|
3407
3407
|
this.wsClient.on("connected", async () => {
|
|
3408
3408
|
var e, t;
|
|
3409
|
-
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3409
|
+
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e, Se.connected), b.logEvent("character_animation_service", "info", {
|
|
3410
3410
|
characterId: this.dataController.getAvatarId(),
|
|
3411
3411
|
event: "connected"
|
|
3412
3412
|
});
|
|
3413
3413
|
}), this.wsClient.on("disconnected", () => {
|
|
3414
3414
|
var e, t;
|
|
3415
|
-
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3415
|
+
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e, Se.disconnected), b.logEvent("character_animation_service", "warning", {
|
|
3416
3416
|
characterId: this.dataController.getAvatarId(),
|
|
3417
3417
|
event: "disconnected"
|
|
3418
3418
|
});
|
|
3419
3419
|
}), this.wsClient.on("reconnecting", () => {
|
|
3420
|
-
|
|
3420
|
+
b.logEvent("character_animation_service", "info", {
|
|
3421
3421
|
characterId: this.dataController.getAvatarId(),
|
|
3422
3422
|
event: "reconnecting"
|
|
3423
3423
|
});
|
|
3424
3424
|
}), this.wsClient.on("error", (e) => {
|
|
3425
3425
|
var n, i, a, o;
|
|
3426
3426
|
const t = e instanceof Error ? e.message : String(e);
|
|
3427
|
-
h.error("[NetworkLayer] WebSocket error:", t),
|
|
3427
|
+
h.error("[NetworkLayer] WebSocket error:", t), b.logEvent("character_animation_service", "error", {
|
|
3428
3428
|
characterId: this.dataController.getAvatarId(),
|
|
3429
3429
|
event: "websocket_error",
|
|
3430
3430
|
reason: t
|
|
3431
|
-
}), (i = (n = this.dataController).onConnectionState) == null || i.call(n,
|
|
3431
|
+
}), (i = (n = this.dataController).onConnectionState) == null || i.call(n, Se.failed), (o = (a = this.dataController).onError) == null || o.call(a, e);
|
|
3432
3432
|
}), this.wsClient.on("message", (e) => {
|
|
3433
3433
|
this.handleMessage(e);
|
|
3434
3434
|
});
|
|
@@ -3448,7 +3448,7 @@ class Ai {
|
|
|
3448
3448
|
}
|
|
3449
3449
|
} catch (t) {
|
|
3450
3450
|
const n = t instanceof Error ? t.message : String(t);
|
|
3451
|
-
h.error("[NetworkLayer] Failed to handle message:", n),
|
|
3451
|
+
h.error("[NetworkLayer] Failed to handle message:", n), b.logEvent("character_manager", "error", {
|
|
3452
3452
|
characterId: this.dataController.getAvatarId(),
|
|
3453
3453
|
event: "handle_message_failed",
|
|
3454
3454
|
reason: n
|
|
@@ -3465,7 +3465,7 @@ class Ai {
|
|
|
3465
3465
|
}
|
|
3466
3466
|
const { reqId: t, animation: n } = e.serverResponseAnimation;
|
|
3467
3467
|
if (!this.currentReqId || t !== this.currentReqId) {
|
|
3468
|
-
h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected reqId: ${this.currentReqId}, received reqId: ${t}`),
|
|
3468
|
+
h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected reqId: ${this.currentReqId}, received reqId: ${t}`), b.logEvent("character_manager", "warning", {
|
|
3469
3469
|
characterId: this.dataController.getAvatarId(),
|
|
3470
3470
|
event: "animation_reqid_mismatch",
|
|
3471
3471
|
expectedReqId: this.currentReqId,
|
|
@@ -3477,7 +3477,7 @@ class Ai {
|
|
|
3477
3477
|
const i = n.keyframes;
|
|
3478
3478
|
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));
|
|
3479
3479
|
} else
|
|
3480
|
-
h.warn(`[NetworkLayer] Animation message has no keyframes - reqId: ${t}`),
|
|
3480
|
+
h.warn(`[NetworkLayer] Animation message has no keyframes - reqId: ${t}`), b.logEvent("character_manager", "warning", {
|
|
3481
3481
|
characterId: this.dataController.getAvatarId(),
|
|
3482
3482
|
event: "animation_empty_keyframes",
|
|
3483
3483
|
reqId: t
|
|
@@ -3489,13 +3489,13 @@ class Ai {
|
|
|
3489
3489
|
handleErrorMessage(e) {
|
|
3490
3490
|
var n, i, a, o;
|
|
3491
3491
|
if (!e.error) {
|
|
3492
|
-
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"),
|
|
3492
|
+
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"), b.logEvent("character_manager", "warning", {
|
|
3493
3493
|
characterId: this.dataController.getAvatarId(),
|
|
3494
3494
|
event: "message_error_with_payload"
|
|
3495
3495
|
}), this.handleAnimationMessage(e));
|
|
3496
3496
|
return;
|
|
3497
3497
|
}
|
|
3498
|
-
h.error(`[NetworkLayer] Server error: reqId=${e.error.reqId}, code=${e.error.code}, reason=${e.error.reason}`),
|
|
3498
|
+
h.error(`[NetworkLayer] Server error: reqId=${e.error.reqId}, code=${e.error.code}, reason=${e.error.reason}`), b.logEvent("character_manager", "error", {
|
|
3499
3499
|
characterId: this.dataController.getAvatarId(),
|
|
3500
3500
|
event: "server_error",
|
|
3501
3501
|
reqId: e.error.reqId,
|
|
@@ -3503,7 +3503,7 @@ class Ai {
|
|
|
3503
3503
|
reason: e.error.reason
|
|
3504
3504
|
});
|
|
3505
3505
|
const t = ((n = e.error.code) == null ? void 0 : n.toString().toLowerCase()) ?? "";
|
|
3506
|
-
(t.includes("unauth") || t === "401") &&
|
|
3506
|
+
(t.includes("unauth") || t === "401") && b.logEvent("sdk_verify", "error", {
|
|
3507
3507
|
characterId: this.dataController.getAvatarId(),
|
|
3508
3508
|
reqId: e.error.reqId,
|
|
3509
3509
|
reason: e.error.reason
|
|
@@ -3536,7 +3536,7 @@ class Ai {
|
|
|
3536
3536
|
* 上报音频指标
|
|
3537
3537
|
*/
|
|
3538
3538
|
reportAudioMetrics(e) {
|
|
3539
|
-
!e || this.audioMetrics.startTimestamp === 0 ||
|
|
3539
|
+
!e || this.audioMetrics.startTimestamp === 0 || b.logEvent("send_audio_measure", "info", {
|
|
3540
3540
|
reqId: e,
|
|
3541
3541
|
start: this.audioMetrics.startTimestamp,
|
|
3542
3542
|
tap2: this.audioMetrics.tap2Timestamp,
|
|
@@ -3546,7 +3546,7 @@ class Ai {
|
|
|
3546
3546
|
});
|
|
3547
3547
|
}
|
|
3548
3548
|
}
|
|
3549
|
-
class
|
|
3549
|
+
class Si {
|
|
3550
3550
|
constructor(e, t) {
|
|
3551
3551
|
// ========== Configuration and Composition ==========
|
|
3552
3552
|
d(this, "networkLayer");
|
|
@@ -3622,12 +3622,12 @@ class bi {
|
|
|
3622
3622
|
"NETWORK_LAYER_NOT_AVAILABLE"
|
|
3623
3623
|
);
|
|
3624
3624
|
if (!this.animationPlayer) {
|
|
3625
|
-
this.animationPlayer = new
|
|
3625
|
+
this.animationPlayer = new be();
|
|
3626
3626
|
try {
|
|
3627
3627
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
3628
3628
|
} catch (e) {
|
|
3629
3629
|
const t = e instanceof Error ? e.message : String(e);
|
|
3630
|
-
throw h.error("[AvatarController] Failed to create streaming player:", t),
|
|
3630
|
+
throw h.error("[AvatarController] Failed to create streaming player:", t), b.logEvent("character_player", "error", {
|
|
3631
3631
|
characterId: this.avatar.id,
|
|
3632
3632
|
event: "streaming_player_init_failed",
|
|
3633
3633
|
reason: t
|
|
@@ -3643,7 +3643,7 @@ class bi {
|
|
|
3643
3643
|
send(e, t = !1) {
|
|
3644
3644
|
var n, i;
|
|
3645
3645
|
if (!this.networkLayer || !this.isConnected) {
|
|
3646
|
-
(n = this.onError) == null || n.call(this, new se("Service not connected", "NOT_CONNECTED")),
|
|
3646
|
+
(n = this.onError) == null || n.call(this, new se("Service not connected", "NOT_CONNECTED")), b.logEvent("character_manager", "warning", {
|
|
3647
3647
|
characterId: this.avatar.id,
|
|
3648
3648
|
event: "send_not_connected"
|
|
3649
3649
|
});
|
|
@@ -3656,7 +3656,7 @@ class bi {
|
|
|
3656
3656
|
*/
|
|
3657
3657
|
close() {
|
|
3658
3658
|
var e, t;
|
|
3659
|
-
(e = this.networkLayer) == null || e.disconnect(), this.isConnected = !1, (t = this.onConnectionState) == null || t.call(this,
|
|
3659
|
+
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, Se.disconnected);
|
|
3660
3660
|
}
|
|
3661
3661
|
// ========== 外部数据模式接口 ==========
|
|
3662
3662
|
/**
|
|
@@ -3665,7 +3665,7 @@ class bi {
|
|
|
3665
3665
|
*/
|
|
3666
3666
|
async play(e, t) {
|
|
3667
3667
|
if (!this.isPlaying) {
|
|
3668
|
-
if (this.animationPlayer || (this.animationPlayer = new
|
|
3668
|
+
if (this.animationPlayer || (this.animationPlayer = new be()), this.animationPlayer.isStreamingReady() || await this.animationPlayer.createAndInitializeStreamingPlayer(), e && e.length > 0 && this.pendingAudioChunks.push(...e), t && t.length > 0 && (this.currentKeyframes.length === 0 ? this.currentKeyframes = t : this.currentKeyframes.push(...t), this.emit("keyframesUpdate", this.currentKeyframes)), this.currentKeyframes.length === 0)
|
|
3669
3669
|
throw new se("No animation keyframes to play", "NO_ANIMATION");
|
|
3670
3670
|
if (this.pendingAudioChunks.length === 0)
|
|
3671
3671
|
throw new se("No audio chunks to play", "NO_AUDIO");
|
|
@@ -3693,7 +3693,7 @@ class bi {
|
|
|
3693
3693
|
*/
|
|
3694
3694
|
interrupt() {
|
|
3695
3695
|
var e;
|
|
3696
|
-
this.stopPlayback(), this.emit("interrupt"), this.currentKeyframes = [], this.pendingAudioChunks = [], (e = this.onAvatarState) == null || e.call(this, Z.idle), this.networkLayer && this.networkLayer.resetReqId();
|
|
3696
|
+
this.stopPlayback(), this.emit("interrupt"), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, (e = this.onAvatarState) == null || e.call(this, Z.idle), this.networkLayer && this.networkLayer.resetReqId();
|
|
3697
3697
|
}
|
|
3698
3698
|
/**
|
|
3699
3699
|
* 清理所有数据和资源
|
|
@@ -3753,14 +3753,14 @@ class bi {
|
|
|
3753
3753
|
try {
|
|
3754
3754
|
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
3755
3755
|
var a, o;
|
|
3756
|
-
this.isPlaying = !1, (a = this.onAvatarState) == null || a.call(this, Z.idle), this.emit("stopRendering"),
|
|
3756
|
+
this.isPlaying = !1, (a = this.onAvatarState) == null || a.call(this, Z.idle), this.emit("stopRendering"), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.networkLayer && this.networkLayer.resetReqId(), b.logEvent("character_player", "info", {
|
|
3757
3757
|
characterId: this.avatar.id,
|
|
3758
3758
|
event: "playback_ended",
|
|
3759
3759
|
reqId: ((o = this.networkLayer) == null ? void 0 : o.getCurrentReqId()) || void 0
|
|
3760
3760
|
});
|
|
3761
3761
|
}), this.emit("startRendering");
|
|
3762
3762
|
const i = this.animationPlayer.getStreamingPlayer();
|
|
3763
|
-
i && i.setAutoStart(!1), i && await i.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, (e = this.onAvatarState) == null || e.call(this, Z.playing), this.startPlaybackLoop(),
|
|
3763
|
+
i && i.setAutoStart(!1), i && await i.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, (e = this.onAvatarState) == null || e.call(this, Z.playing), this.startPlaybackLoop(), b.logEvent("character_player", "info", {
|
|
3764
3764
|
characterId: this.avatar.id,
|
|
3765
3765
|
event: "playback_started",
|
|
3766
3766
|
reqId: ((t = this.networkLayer) == null ? void 0 : t.getCurrentReqId()) || void 0
|
|
@@ -3776,7 +3776,7 @@ class bi {
|
|
|
3776
3776
|
startPlaybackLoop() {
|
|
3777
3777
|
if (this.playbackLoopId)
|
|
3778
3778
|
return;
|
|
3779
|
-
const e =
|
|
3779
|
+
const e = k.animation.fps, t = async () => {
|
|
3780
3780
|
if (!this.isPlaying || !this.animationPlayer) {
|
|
3781
3781
|
this.playbackLoopId = null;
|
|
3782
3782
|
return;
|
|
@@ -3793,7 +3793,7 @@ class bi {
|
|
|
3793
3793
|
return;
|
|
3794
3794
|
}
|
|
3795
3795
|
if (this.lastRenderedFrameIndex = i, i >= 0 && i < this.currentKeyframes.length) {
|
|
3796
|
-
const a = this.currentKeyframes[i], o = $t(a), s =
|
|
3796
|
+
const a = this.currentKeyframes[i], o = $t(a), s = b.getAvatarCore();
|
|
3797
3797
|
if (s) {
|
|
3798
3798
|
const l = await s.computeFrameFlatFromParams(o);
|
|
3799
3799
|
l && this.renderCallback && this.renderCallback(l, i);
|
|
@@ -3835,7 +3835,7 @@ class bi {
|
|
|
3835
3835
|
* 添加音频块到缓冲区
|
|
3836
3836
|
*/
|
|
3837
3837
|
addAudioChunkToBuffer(e, t) {
|
|
3838
|
-
this.animationPlayer || (this.animationPlayer = new
|
|
3838
|
+
this.animationPlayer || (this.animationPlayer = new be()), this.isPlaying && this.animationPlayer.isStreamingReady() ? this.animationPlayer.addAudioChunk(e, t) : this.pendingAudioChunks.push({ data: e, isLast: t });
|
|
3839
3839
|
}
|
|
3840
3840
|
/**
|
|
3841
3841
|
* 事件系统
|
|
@@ -3867,7 +3867,7 @@ function je(r) {
|
|
|
3867
3867
|
}
|
|
3868
3868
|
return String(r);
|
|
3869
3869
|
}
|
|
3870
|
-
async function
|
|
3870
|
+
async function bi(r) {
|
|
3871
3871
|
try {
|
|
3872
3872
|
const e = await fetch(r);
|
|
3873
3873
|
if (!e.ok)
|
|
@@ -3879,11 +3879,11 @@ async function Si(r) {
|
|
|
3879
3879
|
}
|
|
3880
3880
|
}
|
|
3881
3881
|
const Tt = /* @__PURE__ */ new Map();
|
|
3882
|
-
async function
|
|
3882
|
+
async function ze(r) {
|
|
3883
3883
|
const e = Tt.get(r);
|
|
3884
3884
|
if (e)
|
|
3885
3885
|
return e;
|
|
3886
|
-
const t = await
|
|
3886
|
+
const t = await bi(r);
|
|
3887
3887
|
return Tt.set(r, t), t;
|
|
3888
3888
|
}
|
|
3889
3889
|
class Ci {
|
|
@@ -3920,20 +3920,20 @@ class Ci {
|
|
|
3920
3920
|
}
|
|
3921
3921
|
}, a = Object.keys(i).length;
|
|
3922
3922
|
let o = 0;
|
|
3923
|
-
const s = (
|
|
3924
|
-
t && (
|
|
3923
|
+
const s = (w, y) => {
|
|
3924
|
+
t && (y && o++, t({
|
|
3925
3925
|
stage: "template",
|
|
3926
|
-
filename:
|
|
3926
|
+
filename: w,
|
|
3927
3927
|
loaded: o,
|
|
3928
3928
|
total: a,
|
|
3929
3929
|
progress: Math.round(o / a * 100)
|
|
3930
3930
|
}));
|
|
3931
|
-
}, l = {}, g = Object.entries(i).map(async ([
|
|
3932
|
-
if (!
|
|
3933
|
-
throw new Error(`[loadTemplateResources] Missing CDN URL for ${
|
|
3934
|
-
s(
|
|
3935
|
-
const x = await
|
|
3936
|
-
h.log(`✅ ${
|
|
3931
|
+
}, l = {}, g = Object.entries(i).map(async ([w, { url: y, resourceName: S }]) => {
|
|
3932
|
+
if (!y)
|
|
3933
|
+
throw new Error(`[loadTemplateResources] Missing CDN URL for ${w} (${S})`);
|
|
3934
|
+
s(S, !1), h.log(`📥 Loading ${w} from API CDN: ${y}`);
|
|
3935
|
+
const x = await ze(y);
|
|
3936
|
+
h.log(`✅ ${w} loaded: ${x.byteLength} bytes`), l[w] = x, s(S, !0);
|
|
3937
3937
|
});
|
|
3938
3938
|
return await Promise.all(g), l;
|
|
3939
3939
|
}
|
|
@@ -3942,7 +3942,7 @@ class Ci {
|
|
|
3942
3942
|
* Uses centralized FLAME CDN config (shared across all characters)
|
|
3943
3943
|
*/
|
|
3944
3944
|
async loadGlobalFlameResources(e = null) {
|
|
3945
|
-
const { cdnBaseUrl: t, resources: n } =
|
|
3945
|
+
const { cdnBaseUrl: t, resources: n } = k.flame, i = {
|
|
3946
3946
|
flameModel: {
|
|
3947
3947
|
url: `${t}/${n.flameModel}`,
|
|
3948
3948
|
resourceName: n.flameModel
|
|
@@ -3971,7 +3971,7 @@ class Ci {
|
|
|
3971
3971
|
}));
|
|
3972
3972
|
}, l = {}, g = Object.entries(i).map(async ([c, { url: u, resourceName: m }]) => {
|
|
3973
3973
|
s(m, !1), h.log(`📥 Loading ${c} from global CDN: ${u}`);
|
|
3974
|
-
const v = await
|
|
3974
|
+
const v = await ze(u);
|
|
3975
3975
|
h.log(`✅ ${c} loaded: ${v.byteLength} bytes`), l[c] = v, s(m, !0);
|
|
3976
3976
|
});
|
|
3977
3977
|
return await Promise.all(g), l;
|
|
@@ -4002,11 +4002,11 @@ class Ci {
|
|
|
4002
4002
|
* Load character data from CharacterMeta (iOS compatible)
|
|
4003
4003
|
*/
|
|
4004
4004
|
async loadCharacterData(e, t) {
|
|
4005
|
-
var
|
|
4006
|
-
const { loadMonologue: n = !1, progressCallback: i = null } = t || {}, a = (L = (x = (
|
|
4005
|
+
var S, x, L, _, Y, W, N, G, X, K, re, U, we, de, ne;
|
|
4006
|
+
const { loadMonologue: n = !1, progressCallback: i = null } = t || {}, a = (L = (x = (S = e.models) == null ? void 0 : S.shape) == null ? void 0 : x.resource) == null ? void 0 : L.remote, o = (W = (Y = (_ = e.models) == null ? void 0 : _.gsStandard) == null ? void 0 : Y.resource) == null ? void 0 : W.remote, s = (X = (G = (N = e.animations) == null ? void 0 : N.frameIdle) == null ? void 0 : G.resource) == null ? void 0 : X.remote, l = (U = (re = (K = e.animations) == null ? void 0 : K.frameMono) == null ? void 0 : re.resource) == null ? void 0 : U.remote, g = (ne = (de = (we = e.animations) == null ? void 0 : we.audioMono) == null ? void 0 : de.resource) == null ? void 0 : ne.remote;
|
|
4007
4007
|
if (!a || !o) {
|
|
4008
4008
|
const T = "Missing required resources: shape or gsStandard (point cloud)";
|
|
4009
|
-
throw
|
|
4009
|
+
throw b.logEvent("character_load", "error", {
|
|
4010
4010
|
characterId: e.characterId ?? "unknown",
|
|
4011
4011
|
stage: "resource_validation",
|
|
4012
4012
|
reason: T
|
|
@@ -4018,34 +4018,34 @@ class Ci {
|
|
|
4018
4018
|
];
|
|
4019
4019
|
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)");
|
|
4020
4020
|
let u = 0;
|
|
4021
|
-
const m = c.length, v = (T,
|
|
4022
|
-
i && (
|
|
4021
|
+
const m = c.length, v = (T, z) => {
|
|
4022
|
+
i && (z && u++, i({
|
|
4023
4023
|
stage: "character",
|
|
4024
4024
|
filename: T,
|
|
4025
4025
|
loaded: u,
|
|
4026
4026
|
total: m,
|
|
4027
4027
|
progress: Math.round(u / m * 100)
|
|
4028
4028
|
}));
|
|
4029
|
-
},
|
|
4029
|
+
}, w = {}, y = c.map(async ({ key: T, url: z, filename: ie, optional: Fe }) => {
|
|
4030
4030
|
v(ie, !1);
|
|
4031
4031
|
try {
|
|
4032
|
-
const $ = await
|
|
4033
|
-
return T === "shape" ?
|
|
4032
|
+
const $ = await ze(z);
|
|
4033
|
+
return T === "shape" ? w.shape = $ : T === "pointCloud" ? w.pointCloud = $ : T === "idleAnimation" ? w.idleAnimation = $ : T === "monoAnimation" && (w.monoAnimation = $), this.characterAssets.set(T, $), v(ie, !0), { key: T, success: !0 };
|
|
4034
4034
|
} catch ($) {
|
|
4035
4035
|
if (!Fe)
|
|
4036
4036
|
throw $;
|
|
4037
4037
|
return h.warn(`⚠️ Optional resource ${ie} failed to load:`, $), v(ie, !0), { key: T, success: !1 };
|
|
4038
4038
|
}
|
|
4039
4039
|
});
|
|
4040
|
-
if (await Promise.all(
|
|
4040
|
+
if (await Promise.all(y), n && g && (w.monoAudioUrl = g), !w.shape || !w.pointCloud) {
|
|
4041
4041
|
const T = "Failed to load character data";
|
|
4042
|
-
throw
|
|
4042
|
+
throw b.logEvent("character_load", "error", {
|
|
4043
4043
|
characterId: e.characterId ?? "unknown",
|
|
4044
4044
|
stage: "download",
|
|
4045
4045
|
reason: T
|
|
4046
4046
|
}), new Error(T);
|
|
4047
4047
|
}
|
|
4048
|
-
return
|
|
4048
|
+
return w;
|
|
4049
4049
|
}
|
|
4050
4050
|
/**
|
|
4051
4051
|
* Preload all resources (template + character data + camera info + settings)
|
|
@@ -4096,7 +4096,7 @@ class Ci {
|
|
|
4096
4096
|
getMainAppClient() {
|
|
4097
4097
|
return {
|
|
4098
4098
|
async request(e, t = {}) {
|
|
4099
|
-
const a =
|
|
4099
|
+
const a = b.getEnvironmentConfig().realtimeApiBaseUrl + e;
|
|
4100
4100
|
try {
|
|
4101
4101
|
const o = await fetch(a, {
|
|
4102
4102
|
method: t.method || "GET",
|
|
@@ -4123,7 +4123,7 @@ class Ci {
|
|
|
4123
4123
|
getSdkApiClient() {
|
|
4124
4124
|
return {
|
|
4125
4125
|
async request(e, t = {}) {
|
|
4126
|
-
const a =
|
|
4126
|
+
const a = b.getEnvironmentConfig().sdkApiBaseUrl + e;
|
|
4127
4127
|
try {
|
|
4128
4128
|
const o = await fetch(a, {
|
|
4129
4129
|
method: t.method || "GET",
|
|
@@ -4158,7 +4158,7 @@ class Ci {
|
|
|
4158
4158
|
} catch (n) {
|
|
4159
4159
|
h.errorWithError("Failed to fetch character:", n);
|
|
4160
4160
|
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;
|
|
4161
|
-
throw
|
|
4161
|
+
throw b.logEvent("character_load", "error", {
|
|
4162
4162
|
characterId: e ?? "unknown",
|
|
4163
4163
|
stage: "fetch",
|
|
4164
4164
|
reason: a || i
|
|
@@ -4166,7 +4166,7 @@ class Ci {
|
|
|
4166
4166
|
}
|
|
4167
4167
|
}
|
|
4168
4168
|
}
|
|
4169
|
-
const
|
|
4169
|
+
const Me = class Me {
|
|
4170
4170
|
constructor() {
|
|
4171
4171
|
d(this, "avatarDownloader", null);
|
|
4172
4172
|
d(this, "_templateInitialized", !1);
|
|
@@ -4175,7 +4175,7 @@ const ke = class ke {
|
|
|
4175
4175
|
* 通过全局单例来访问
|
|
4176
4176
|
*/
|
|
4177
4177
|
static get shared() {
|
|
4178
|
-
return this._instance || (this._instance = new
|
|
4178
|
+
return this._instance || (this._instance = new Me()), this._instance;
|
|
4179
4179
|
}
|
|
4180
4180
|
/**
|
|
4181
4181
|
* 加载数字人
|
|
@@ -4187,7 +4187,7 @@ const ke = class ke {
|
|
|
4187
4187
|
async load(e, t, n) {
|
|
4188
4188
|
h.log(`[AvatarManager] Loading avatar with id: ${e}`);
|
|
4189
4189
|
try {
|
|
4190
|
-
if (!
|
|
4190
|
+
if (!b.isInitialized)
|
|
4191
4191
|
throw new Error("AvatarKit not initialized. Please call AvatarKit.initialize() first.");
|
|
4192
4192
|
this.avatarDownloader || (this.avatarDownloader = new Ci()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: oe.downloading, progress: 10 });
|
|
4193
4193
|
const i = await this.avatarDownloader.getCharacterById(e);
|
|
@@ -4201,18 +4201,18 @@ const ke = class ke {
|
|
|
4201
4201
|
progress: Math.round(g)
|
|
4202
4202
|
});
|
|
4203
4203
|
}
|
|
4204
|
-
}), o =
|
|
4204
|
+
}), o = b.getAvatarCore();
|
|
4205
4205
|
if (!o)
|
|
4206
4206
|
throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
|
|
4207
4207
|
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...");
|
|
4208
4208
|
const s = new sn(e, i, a);
|
|
4209
|
-
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: oe.completed }),
|
|
4209
|
+
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: oe.completed }), b.logEvent("character_load", "info", {
|
|
4210
4210
|
characterId: e,
|
|
4211
4211
|
event: "load_success"
|
|
4212
4212
|
}), s;
|
|
4213
4213
|
} catch (i) {
|
|
4214
4214
|
const a = i instanceof Error ? i.message : String(i);
|
|
4215
|
-
throw h.error("Failed to load avatar:", a),
|
|
4215
|
+
throw h.error("Failed to load avatar:", a), b.logEvent("character_load", "error", {
|
|
4216
4216
|
characterId: e,
|
|
4217
4217
|
reason: a
|
|
4218
4218
|
}), t == null || t({ type: oe.failed, error: i }), i;
|
|
@@ -4225,30 +4225,30 @@ const ke = class ke {
|
|
|
4225
4225
|
this.avatarDownloader && this.avatarDownloader.clear();
|
|
4226
4226
|
}
|
|
4227
4227
|
};
|
|
4228
|
-
d(
|
|
4229
|
-
let Bt =
|
|
4230
|
-
const Ye = 2048,
|
|
4228
|
+
d(Me, "_instance", null);
|
|
4229
|
+
let Bt = Me, ye = null, Dt = null, Ot = null, Nt = null, Ut = null, zt = null;
|
|
4230
|
+
const Ye = 2048, Vt = Ye - 1;
|
|
4231
4231
|
function _i(r, e, t) {
|
|
4232
4232
|
const i = r.length / 13;
|
|
4233
|
-
(!ye || ye.length !== i) && (ye = new Float32Array(i), Dt = new Uint32Array(ye.buffer), Ot = new Uint32Array(i), Nt = new Uint32Array(i), Ut = new Uint32Array(i),
|
|
4234
|
-
const a = ye, o = Dt, s = Ot, l = Nt, g = Ut, c =
|
|
4233
|
+
(!ye || ye.length !== i) && (ye = new Float32Array(i), Dt = new Uint32Array(ye.buffer), Ot = new Uint32Array(i), Nt = new Uint32Array(i), Ut = new Uint32Array(i), zt = new Uint32Array(Ye));
|
|
4234
|
+
const a = ye, o = Dt, s = Ot, l = Nt, g = Ut, c = zt, u = e[0], m = e[1], v = e[2], w = t[0], y = t[1], S = t[2];
|
|
4235
4235
|
for (let x = 0; x < i; x++) {
|
|
4236
4236
|
const L = x * 13;
|
|
4237
|
-
a[x] = (r[L] - u) *
|
|
4237
|
+
a[x] = (r[L] - u) * w + (r[L + 1] - m) * y + (r[L + 2] - v) * S, s[x] = x;
|
|
4238
4238
|
}
|
|
4239
4239
|
for (let x = 0; x < i; x++) {
|
|
4240
4240
|
const L = o[x];
|
|
4241
4241
|
o[x] = L ^ (-(L >> 31) | 2147483648);
|
|
4242
4242
|
}
|
|
4243
|
-
|
|
4243
|
+
Ve(o, s, l, c, 0, i), Ve(o, l, s, c, 11, i), Ve(o, s, l, c, 22, i);
|
|
4244
4244
|
for (let x = 0; x < i; x++)
|
|
4245
4245
|
g[x] = l[i - 1 - x];
|
|
4246
4246
|
return g;
|
|
4247
4247
|
}
|
|
4248
|
-
function
|
|
4248
|
+
function Ve(r, e, t, n, i, a) {
|
|
4249
4249
|
n.fill(0);
|
|
4250
4250
|
for (let s = 0; s < a; s++) {
|
|
4251
|
-
const l = r[e[s]] >> i &
|
|
4251
|
+
const l = r[e[s]] >> i & Vt;
|
|
4252
4252
|
n[l]++;
|
|
4253
4253
|
}
|
|
4254
4254
|
let o = 0;
|
|
@@ -4257,7 +4257,7 @@ function ze(r, e, t, n, i, a) {
|
|
|
4257
4257
|
n[s] = o, o += l;
|
|
4258
4258
|
}
|
|
4259
4259
|
for (let s = 0; s < a; s++) {
|
|
4260
|
-
const l = e[s], g = r[l] >> i &
|
|
4260
|
+
const l = e[s], g = r[l] >> i & Vt;
|
|
4261
4261
|
t[n[g]++] = l;
|
|
4262
4262
|
}
|
|
4263
4263
|
}
|
|
@@ -4699,7 +4699,7 @@ class Ii {
|
|
|
4699
4699
|
this.isInitialized = !1;
|
|
4700
4700
|
}
|
|
4701
4701
|
}
|
|
4702
|
-
const
|
|
4702
|
+
const ki = `/**
|
|
4703
4703
|
* WebGPU 3DGS 渲染着色器
|
|
4704
4704
|
*
|
|
4705
4705
|
* 实例化渲染:每个 splat 绘制一个四边形
|
|
@@ -4962,7 +4962,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4f {
|
|
|
4962
4962
|
return vec4f(input.color.rgb * alpha, alpha);
|
|
4963
4963
|
}
|
|
4964
4964
|
`;
|
|
4965
|
-
class
|
|
4965
|
+
class Mi {
|
|
4966
4966
|
constructor(e, t) {
|
|
4967
4967
|
d(this, "canvas");
|
|
4968
4968
|
d(this, "backgroundColor");
|
|
@@ -5049,7 +5049,7 @@ class ki {
|
|
|
5049
5049
|
return;
|
|
5050
5050
|
const e = this.device.createShaderModule({
|
|
5051
5051
|
label: "3DGS Render Shader",
|
|
5052
|
-
code:
|
|
5052
|
+
code: ki
|
|
5053
5053
|
}), t = this.device.createBindGroupLayout({
|
|
5054
5054
|
label: "Uniform Bind Group Layout",
|
|
5055
5055
|
entries: [
|
|
@@ -5269,7 +5269,7 @@ class Fi {
|
|
|
5269
5269
|
const { preferBackend: e, backgroundColor: t = [0, 0, 0, 0] } = this.options;
|
|
5270
5270
|
if (e !== "webgl" && await this.checkWebGPUSupport())
|
|
5271
5271
|
try {
|
|
5272
|
-
this.renderer = new
|
|
5272
|
+
this.renderer = new Mi(this.canvas, t), await this.renderer.initialize(), this.backend = "webgpu", h.log("✅ Using WebGPU renderer"), this.updateCameraAspect();
|
|
5273
5273
|
return;
|
|
5274
5274
|
} catch (i) {
|
|
5275
5275
|
h.warn("⚠️ WebGPU init failed, fallback to WebGL:", i);
|
|
@@ -5457,28 +5457,26 @@ class Ni {
|
|
|
5457
5457
|
d(this, "renderSystem", null);
|
|
5458
5458
|
d(this, "isInitialized", !1);
|
|
5459
5459
|
d(this, "cameraConfig", null);
|
|
5460
|
-
//
|
|
5461
|
-
d(this, "
|
|
5460
|
+
// Rendering state machine
|
|
5461
|
+
d(this, "renderingState", "idle");
|
|
5462
|
+
// Realtime animation data
|
|
5462
5463
|
d(this, "currentKeyframes", []);
|
|
5463
5464
|
d(this, "lastRenderedFrameIndex", -1);
|
|
5464
5465
|
d(this, "lastRealtimeProtoFrame", null);
|
|
5465
|
-
d(this, "idleResumeIndexPending", null);
|
|
5466
5466
|
// Animation loop types
|
|
5467
5467
|
d(this, "idleAnimationLoopId", null);
|
|
5468
5468
|
d(this, "realtimeAnimationLoopId", null);
|
|
5469
5469
|
d(this, "resizeObserver", null);
|
|
5470
5470
|
d(this, "onWindowResize", () => this.handleResize());
|
|
5471
|
-
// Transition
|
|
5471
|
+
// Transition animation data
|
|
5472
5472
|
d(this, "transitionKeyframes", []);
|
|
5473
|
-
d(this, "isTransitioning", !1);
|
|
5474
5473
|
d(this, "transitionStartTime", 0);
|
|
5475
5474
|
d(this, "transitionDurationMs", 200);
|
|
5476
|
-
d(this, "endToIdleAfterTransition", !1);
|
|
5477
5475
|
d(this, "cachedIdleFirstFrame", null);
|
|
5478
5476
|
d(this, "idleCurrentFrameIndex", 0);
|
|
5479
5477
|
this.avatar = e;
|
|
5480
5478
|
const n = (t == null ? void 0 : t.playbackMode) ?? Ie.network;
|
|
5481
|
-
this.playbackMode = n, this.avatarController = new
|
|
5479
|
+
this.playbackMode = n, this.avatarController = new Si(e, {
|
|
5482
5480
|
playbackMode: n
|
|
5483
5481
|
}), this.avatarController.setRenderCallback((i, a) => {
|
|
5484
5482
|
this.renderRealtimeFrame(i, a);
|
|
@@ -5536,7 +5534,7 @@ class Ni {
|
|
|
5536
5534
|
n.from,
|
|
5537
5535
|
n.to,
|
|
5538
5536
|
this.transitionDurationMs,
|
|
5539
|
-
|
|
5537
|
+
k.animation.fps
|
|
5540
5538
|
);
|
|
5541
5539
|
return i.length < 2 && (i = [n.from, n.to]), i[0] = n.from, i[i.length - 1] = n.to, i;
|
|
5542
5540
|
}
|
|
@@ -5545,7 +5543,7 @@ class Ni {
|
|
|
5545
5543
|
*/
|
|
5546
5544
|
async getCachedIdleFirstFrame() {
|
|
5547
5545
|
if (!this.cachedIdleFirstFrame) {
|
|
5548
|
-
const e =
|
|
5546
|
+
const e = b.getAvatarCore();
|
|
5549
5547
|
if (e)
|
|
5550
5548
|
try {
|
|
5551
5549
|
const t = await e.getCurrentFrameParams(0);
|
|
@@ -5586,17 +5584,17 @@ class Ni {
|
|
|
5586
5584
|
*/
|
|
5587
5585
|
async initializeView(e) {
|
|
5588
5586
|
try {
|
|
5589
|
-
|
|
5590
|
-
const t =
|
|
5587
|
+
k.debug && h.log("[AvatarView] Initializing avatar view...");
|
|
5588
|
+
const t = b.getAvatarCore();
|
|
5591
5589
|
if (!t)
|
|
5592
5590
|
throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
|
|
5593
5591
|
const n = e.getResources();
|
|
5594
|
-
|
|
5592
|
+
k.debug && h.log("[AvatarView] Loading character data..."), await t.loadCharacterFromBuffers(
|
|
5595
5593
|
n.characterData.shape,
|
|
5596
5594
|
n.characterData.pointCloud
|
|
5597
|
-
), n.characterData.idleAnimation && (
|
|
5595
|
+
), n.characterData.idleAnimation && (k.debug && h.log("[AvatarView] Loading idle animation..."), await t.loadAnimationFromBuffer(n.characterData.idleAnimation)), k.debug && h.log("[AvatarView] Initializing render system...");
|
|
5598
5596
|
const i = this.resolveCameraConfig(n);
|
|
5599
|
-
await this.initializeRenderSystem(i),
|
|
5597
|
+
await this.initializeRenderSystem(i), k.debug && h.log("[AvatarView] Starting rendering..."), await this.renderFirstFrame(), this.startIdleAnimationLoop(), this.isInitialized = !0, k.debug && h.log("[AvatarView] Avatar view initialized successfully");
|
|
5600
5598
|
} catch (t) {
|
|
5601
5599
|
throw h.error("[AvatarView] Failed to initialize avatar view:", t instanceof Error ? t.message : String(t)), t;
|
|
5602
5600
|
}
|
|
@@ -5610,13 +5608,13 @@ class Ni {
|
|
|
5610
5608
|
camera: this.cameraConfig,
|
|
5611
5609
|
backgroundColor: [0, 0, 0, 0]
|
|
5612
5610
|
// 透明背景,让 CSS 背景透出
|
|
5613
|
-
}), await this.renderSystem.initialize(),
|
|
5611
|
+
}), await this.renderSystem.initialize(), k.debug && h.log("[AvatarView] Render system initialized successfully");
|
|
5614
5612
|
}
|
|
5615
5613
|
/**
|
|
5616
5614
|
* 获取默认相机配置
|
|
5617
5615
|
*/
|
|
5618
5616
|
getDefaultCameraConfig() {
|
|
5619
|
-
return { ...
|
|
5617
|
+
return { ...k.camera };
|
|
5620
5618
|
}
|
|
5621
5619
|
/**
|
|
5622
5620
|
* 根据资源解析最终的相机配置,优先使用角色设置,其次 camera.json
|
|
@@ -5636,22 +5634,22 @@ class Ni {
|
|
|
5636
5634
|
const i = (G, X) => Number.isFinite(G) ? G : 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;
|
|
5637
5635
|
if (!c && !u && !m)
|
|
5638
5636
|
return h.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
|
|
5639
|
-
const v = Math.sin(l),
|
|
5637
|
+
const v = Math.sin(l), w = Math.cos(l), y = c ? [a, o, s] : [...t.position], S = [
|
|
5640
5638
|
-v,
|
|
5641
5639
|
0,
|
|
5642
|
-
-
|
|
5643
|
-
], x = Math.hypot(
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5640
|
+
-w
|
|
5641
|
+
], x = Math.hypot(S[0], S[1], S[2]) || 1, L = [
|
|
5642
|
+
S[0] / x,
|
|
5643
|
+
S[1] / x,
|
|
5644
|
+
S[2] / x
|
|
5647
5645
|
], _ = [
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5646
|
+
y[0] + L[0],
|
|
5647
|
+
y[1] + L[1],
|
|
5648
|
+
y[2] + L[2]
|
|
5651
5649
|
], Y = [0, 1, 0], W = u ? g * 180 / Math.PI : t.fov, N = {
|
|
5652
5650
|
...t,
|
|
5653
5651
|
// 自动继承 near/far 等配置(来自 APP_CONFIG.camera)
|
|
5654
|
-
position:
|
|
5652
|
+
position: y,
|
|
5655
5653
|
target: _,
|
|
5656
5654
|
up: Y,
|
|
5657
5655
|
fov: W
|
|
@@ -5661,7 +5659,7 @@ class Ni {
|
|
|
5661
5659
|
source: n,
|
|
5662
5660
|
translation: [a, o, s],
|
|
5663
5661
|
yawRadians: l,
|
|
5664
|
-
position:
|
|
5662
|
+
position: y,
|
|
5665
5663
|
target: _,
|
|
5666
5664
|
fov: W,
|
|
5667
5665
|
near: N.near,
|
|
@@ -5674,7 +5672,7 @@ class Ni {
|
|
|
5674
5672
|
async renderFirstFrame() {
|
|
5675
5673
|
if (!this.renderSystem)
|
|
5676
5674
|
throw new Error("Render system not initialized");
|
|
5677
|
-
const e =
|
|
5675
|
+
const e = b.getAvatarCore();
|
|
5678
5676
|
if (!e)
|
|
5679
5677
|
throw new Error("AvatarCore not available");
|
|
5680
5678
|
const t = {
|
|
@@ -5687,7 +5685,7 @@ class Ni {
|
|
|
5687
5685
|
eyes_pose: [0, 0, 0, 0, 0, 0]
|
|
5688
5686
|
}, n = await e.computeFrameFlatFromParams(t);
|
|
5689
5687
|
if (n)
|
|
5690
|
-
this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(),
|
|
5688
|
+
this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(), k.debug && h.log("[AvatarView] First frame rendered successfully");
|
|
5691
5689
|
else
|
|
5692
5690
|
throw new Error("Failed to compute first frame splat data");
|
|
5693
5691
|
}
|
|
@@ -5697,8 +5695,8 @@ class Ni {
|
|
|
5697
5695
|
startIdleAnimationLoop() {
|
|
5698
5696
|
if (this.idleAnimationLoopId)
|
|
5699
5697
|
return;
|
|
5700
|
-
if (this.
|
|
5701
|
-
|
|
5698
|
+
if (this.renderingState !== "idle") {
|
|
5699
|
+
k.debug && h.log("[AvatarView] Skip starting idle loop because not in idle state");
|
|
5702
5700
|
return;
|
|
5703
5701
|
}
|
|
5704
5702
|
this.idleCurrentFrameIndex = 0;
|
|
@@ -5707,7 +5705,7 @@ class Ni {
|
|
|
5707
5705
|
try {
|
|
5708
5706
|
if (!this.renderSystem)
|
|
5709
5707
|
return;
|
|
5710
|
-
if (this.
|
|
5708
|
+
if (this.renderingState !== "idle") {
|
|
5711
5709
|
this.idleAnimationLoopId = requestAnimationFrame(i);
|
|
5712
5710
|
return;
|
|
5713
5711
|
}
|
|
@@ -5716,12 +5714,12 @@ class Ni {
|
|
|
5716
5714
|
return;
|
|
5717
5715
|
}
|
|
5718
5716
|
e = a;
|
|
5719
|
-
const o =
|
|
5717
|
+
const o = b.getAvatarCore();
|
|
5720
5718
|
if (!o)
|
|
5721
5719
|
return;
|
|
5722
5720
|
const s = await o.computeCompleteFrameFlat({ frameIndex: this.idleCurrentFrameIndex });
|
|
5723
5721
|
if (this.idleCurrentFrameIndex++, s) {
|
|
5724
|
-
if (this.
|
|
5722
|
+
if (this.renderingState !== "idle")
|
|
5725
5723
|
return;
|
|
5726
5724
|
this.renderSystem.loadSplatsFromPackedData(s), this.renderSystem.renderFrame();
|
|
5727
5725
|
}
|
|
@@ -5730,7 +5728,7 @@ class Ni {
|
|
|
5730
5728
|
h.error("[AvatarView] Idle animation loop error:", o instanceof Error ? o.message : String(o)), this.stopIdleAnimationLoop();
|
|
5731
5729
|
}
|
|
5732
5730
|
};
|
|
5733
|
-
this.idleAnimationLoopId = requestAnimationFrame(i),
|
|
5731
|
+
this.idleAnimationLoopId = requestAnimationFrame(i), k.debug && h.log("[AvatarView] Idle animation loop started");
|
|
5734
5732
|
}
|
|
5735
5733
|
/**
|
|
5736
5734
|
* 开始实时对话动画循环
|
|
@@ -5741,7 +5739,8 @@ class Ni {
|
|
|
5741
5739
|
let e = 0;
|
|
5742
5740
|
const n = 1e3 / 25, i = async (a) => {
|
|
5743
5741
|
try {
|
|
5744
|
-
|
|
5742
|
+
const o = this.renderingState;
|
|
5743
|
+
if (!this.renderSystem || o === "idle") {
|
|
5745
5744
|
this.realtimeAnimationLoopId = null;
|
|
5746
5745
|
return;
|
|
5747
5746
|
}
|
|
@@ -5749,37 +5748,54 @@ class Ni {
|
|
|
5749
5748
|
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
5750
5749
|
return;
|
|
5751
5750
|
}
|
|
5752
|
-
if (e = a,
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
const v = await m.computeFrameFlatFromParams(u);
|
|
5756
|
-
v && (this.renderSystem.loadSplatsFromPackedData(v), this.renderSystem.renderFrame());
|
|
5757
|
-
}
|
|
5758
|
-
if (s >= 1 && (this.isTransitioning = !1, this.transitionKeyframes = [], this.avatarController.onTransitionComplete(), this.endToIdleAfterTransition)) {
|
|
5759
|
-
this.endToIdleAfterTransition = !1, this.isRealtimePlaying = !1, this.currentKeyframes = [], this.stopRealtimeAnimationLoop(), this.startIdleAnimationLoop();
|
|
5751
|
+
if (e = a, o === "transitioningToSpeaking" || o === "transitioningToIdle") {
|
|
5752
|
+
if (this.transitionKeyframes.length === 0) {
|
|
5753
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
5760
5754
|
return;
|
|
5761
5755
|
}
|
|
5756
|
+
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 = $t(u), v = b.getAvatarCore();
|
|
5757
|
+
if (v) {
|
|
5758
|
+
const w = await v.computeFrameFlatFromParams(m);
|
|
5759
|
+
w && (this.renderSystem.loadSplatsFromPackedData(w), this.renderSystem.renderFrame());
|
|
5760
|
+
}
|
|
5761
|
+
if (l >= 1) {
|
|
5762
|
+
if (o === "transitioningToSpeaking")
|
|
5763
|
+
this.setState(
|
|
5764
|
+
"speaking"
|
|
5765
|
+
/* Speaking */
|
|
5766
|
+
), this.transitionKeyframes = [], this.avatarController.onTransitionComplete();
|
|
5767
|
+
else if (o === "transitioningToIdle") {
|
|
5768
|
+
this.setState(
|
|
5769
|
+
"idle"
|
|
5770
|
+
/* Idle */
|
|
5771
|
+
), this.transitionKeyframes = [], this.stopRealtimeAnimationLoop(), this.startIdleAnimationLoop();
|
|
5772
|
+
return;
|
|
5773
|
+
}
|
|
5774
|
+
}
|
|
5775
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
5776
|
+
return;
|
|
5777
|
+
}
|
|
5778
|
+
if (o === "speaking") {
|
|
5762
5779
|
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
5763
5780
|
return;
|
|
5764
5781
|
}
|
|
5765
|
-
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
5766
5782
|
} catch (o) {
|
|
5767
5783
|
h.error("[AvatarView] Realtime animation loop error:", o instanceof Error ? o.message : String(o)), this.stopRealtimeAnimationLoop();
|
|
5768
5784
|
}
|
|
5769
5785
|
};
|
|
5770
|
-
this.realtimeAnimationLoopId = requestAnimationFrame(i),
|
|
5786
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(i), k.debug && h.log("[AvatarView] Realtime animation loop started");
|
|
5771
5787
|
}
|
|
5772
5788
|
/**
|
|
5773
5789
|
* 停止idle动画循环
|
|
5774
5790
|
*/
|
|
5775
5791
|
stopIdleAnimationLoop() {
|
|
5776
|
-
this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null,
|
|
5792
|
+
this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null, k.debug && h.log("[AvatarView] Idle animation loop stopped"));
|
|
5777
5793
|
}
|
|
5778
5794
|
/**
|
|
5779
5795
|
* 停止实时对话动画循环
|
|
5780
5796
|
*/
|
|
5781
5797
|
stopRealtimeAnimationLoop() {
|
|
5782
|
-
this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null,
|
|
5798
|
+
this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null, k.debug && h.log("[AvatarView] Realtime animation loop stopped"));
|
|
5783
5799
|
}
|
|
5784
5800
|
/**
|
|
5785
5801
|
* 停止所有动画循环
|
|
@@ -5791,18 +5807,49 @@ class Ni {
|
|
|
5791
5807
|
* 渲染实时帧(由播放层回调调用)
|
|
5792
5808
|
*/
|
|
5793
5809
|
renderRealtimeFrame(e, t) {
|
|
5794
|
-
!this.renderSystem ||
|
|
5810
|
+
!this.renderSystem || this.renderingState !== "speaking" || (this.renderSystem.loadSplatsFromPackedData(e), this.renderSystem.renderFrame(), this.lastRenderedFrameIndex = t, t >= 0 && t < this.currentKeyframes.length && (this.lastRealtimeProtoFrame = this.currentKeyframes[t]));
|
|
5795
5811
|
}
|
|
5796
5812
|
/**
|
|
5797
5813
|
* 过渡完成回调(通知播放层启动音频)
|
|
5798
5814
|
*/
|
|
5799
5815
|
onTransitionComplete() {
|
|
5800
5816
|
}
|
|
5817
|
+
/**
|
|
5818
|
+
* 状态转换方法
|
|
5819
|
+
* 统一管理状态转换,确保状态一致性
|
|
5820
|
+
*/
|
|
5821
|
+
setState(e) {
|
|
5822
|
+
const t = this.renderingState;
|
|
5823
|
+
this.renderingState = e, t === "transitioningToIdle" && e !== "transitioningToIdle" && (this.transitionKeyframes = []), t === "transitioningToSpeaking" && e !== "transitioningToSpeaking" && (this.transitionKeyframes = []), e === "idle" && (this.currentKeyframes = [], this.lastRenderedFrameIndex = -1, this.lastRealtimeProtoFrame = null, this.transitionKeyframes = [], this.transitionStartTime = 0);
|
|
5824
|
+
}
|
|
5825
|
+
/**
|
|
5826
|
+
* 检查是否在实时播放状态(Speaking 或过渡到 Speaking)
|
|
5827
|
+
*/
|
|
5828
|
+
get isRealtimePlaying() {
|
|
5829
|
+
return this.renderingState === "speaking" || this.renderingState === "transitioningToSpeaking";
|
|
5830
|
+
}
|
|
5831
|
+
/**
|
|
5832
|
+
* 检查是否在过渡中
|
|
5833
|
+
*/
|
|
5834
|
+
get isTransitioning() {
|
|
5835
|
+
return this.renderingState === "transitioningToSpeaking" || this.renderingState === "transitioningToIdle";
|
|
5836
|
+
}
|
|
5837
|
+
/**
|
|
5838
|
+
* 检查过渡结束后是否回到 Idle
|
|
5839
|
+
*/
|
|
5840
|
+
get endToIdleAfterTransition() {
|
|
5841
|
+
return this.renderingState === "transitioningToIdle";
|
|
5842
|
+
}
|
|
5801
5843
|
/**
|
|
5802
5844
|
* 处理打断
|
|
5845
|
+
* 打断时应该生成过渡动画,而不是直接跳回 Idle
|
|
5803
5846
|
*/
|
|
5804
5847
|
handleInterrupt() {
|
|
5805
|
-
|
|
5848
|
+
const e = this.renderingState;
|
|
5849
|
+
e !== "transitioningToIdle" && (e === "speaking" || e === "transitioningToSpeaking" ? this.stopRealtimeRendering() : (this.setState(
|
|
5850
|
+
"idle"
|
|
5851
|
+
/* Idle */
|
|
5852
|
+
), this.stopRealtimeAnimationLoop(), this.startIdleAnimationLoop()));
|
|
5806
5853
|
}
|
|
5807
5854
|
/**
|
|
5808
5855
|
* 设置 AvatarController 事件监听器
|
|
@@ -5827,21 +5874,33 @@ class Ni {
|
|
|
5827
5874
|
* 准备实时渲染(生成 Idle -> Speaking 过渡)
|
|
5828
5875
|
*/
|
|
5829
5876
|
async prepareRealtimeRendering(e) {
|
|
5830
|
-
|
|
5877
|
+
const t = this.renderingState;
|
|
5878
|
+
if ((t === "speaking" || t === "transitioningToSpeaking") && this.currentKeyframes.length > 0) {
|
|
5831
5879
|
this.currentKeyframes = e;
|
|
5832
5880
|
return;
|
|
5833
5881
|
}
|
|
5834
|
-
this.stopIdleAnimationLoop(), this.
|
|
5882
|
+
this.stopIdleAnimationLoop(), this.currentKeyframes = e, this.setState(
|
|
5883
|
+
"transitioningToSpeaking"
|
|
5884
|
+
/* TransitioningToSpeaking */
|
|
5885
|
+
);
|
|
5835
5886
|
try {
|
|
5836
|
-
const
|
|
5837
|
-
if (
|
|
5838
|
-
|
|
5887
|
+
const n = b.getAvatarCore();
|
|
5888
|
+
if (n && e.length > 0) {
|
|
5889
|
+
if (this.renderingState !== "transitioningToSpeaking")
|
|
5890
|
+
return;
|
|
5891
|
+
const i = await n.getCurrentFrameParams(this.idleCurrentFrameIndex), a = dt(i);
|
|
5839
5892
|
await this.getCachedIdleFirstFrame();
|
|
5840
|
-
const
|
|
5841
|
-
this.transitionKeyframes = this.generateAndAlignTransitionFrames(
|
|
5893
|
+
const o = e[0];
|
|
5894
|
+
this.transitionKeyframes = this.generateAndAlignTransitionFrames(a, o), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
|
|
5895
|
+
"speaking"
|
|
5896
|
+
/* Speaking */
|
|
5897
|
+
), this.avatarController.onTransitionComplete()) : k.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
|
|
5842
5898
|
}
|
|
5843
|
-
} catch (
|
|
5844
|
-
h.warn("[AvatarView] Transition generation failed:",
|
|
5899
|
+
} catch (n) {
|
|
5900
|
+
h.warn("[AvatarView] Transition generation failed:", n instanceof Error ? n.message : String(n)), this.renderingState === "transitioningToSpeaking" && (this.setState(
|
|
5901
|
+
"speaking"
|
|
5902
|
+
/* Speaking */
|
|
5903
|
+
), this.avatarController.onTransitionComplete());
|
|
5845
5904
|
}
|
|
5846
5905
|
this.startRealtimeAnimationLoop();
|
|
5847
5906
|
}
|
|
@@ -5849,7 +5908,7 @@ class Ni {
|
|
|
5849
5908
|
* 开始实时渲染循环
|
|
5850
5909
|
*/
|
|
5851
5910
|
startRealtimeRendering() {
|
|
5852
|
-
|
|
5911
|
+
k.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"), b.logEvent("character_view", "info", {
|
|
5853
5912
|
characterId: this.avatar.id,
|
|
5854
5913
|
event: "rendering_started",
|
|
5855
5914
|
keyframesCount: this.currentKeyframes.length
|
|
@@ -5859,38 +5918,59 @@ class Ni {
|
|
|
5859
5918
|
* 停止实时对话渲染
|
|
5860
5919
|
*/
|
|
5861
5920
|
stopRealtimeRendering() {
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5921
|
+
const e = this.renderingState;
|
|
5922
|
+
if (!(e === "idle" || e === "transitioningToIdle")) {
|
|
5923
|
+
if (e !== "speaking") {
|
|
5924
|
+
this.setState(
|
|
5925
|
+
"idle"
|
|
5926
|
+
/* Idle */
|
|
5927
|
+
), this.stopRealtimeAnimationLoop(), this.startIdleAnimationLoop();
|
|
5928
|
+
return;
|
|
5929
|
+
}
|
|
5930
|
+
this.setState(
|
|
5931
|
+
"transitioningToIdle"
|
|
5932
|
+
/* TransitioningToIdle */
|
|
5933
|
+
), (async () => {
|
|
5934
|
+
try {
|
|
5935
|
+
if (this.renderingState !== "transitioningToIdle")
|
|
5868
5936
|
return;
|
|
5937
|
+
if (b.getAvatarCore() && this.currentKeyframes.length > 0) {
|
|
5938
|
+
const n = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], i = await this.getCachedIdleFirstFrame();
|
|
5939
|
+
if (i && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(n, i), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
|
|
5940
|
+
k.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
|
|
5941
|
+
return;
|
|
5942
|
+
}
|
|
5869
5943
|
}
|
|
5944
|
+
} catch (t) {
|
|
5945
|
+
h.warn("[AvatarView] Return transition generation failed:", t instanceof Error ? t.message : String(t));
|
|
5870
5946
|
}
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5947
|
+
this.renderingState === "transitioningToIdle" && (this.setState(
|
|
5948
|
+
"idle"
|
|
5949
|
+
/* Idle */
|
|
5950
|
+
), this.stopRealtimeAnimationLoop(), this.startIdleAnimationLoop());
|
|
5951
|
+
})();
|
|
5952
|
+
}
|
|
5876
5953
|
}
|
|
5877
5954
|
/**
|
|
5878
5955
|
* 清理视图资源
|
|
5879
5956
|
* 关闭 avatarController 并清理所有相关资源
|
|
5880
5957
|
*/
|
|
5881
5958
|
dispose() {
|
|
5882
|
-
|
|
5959
|
+
k.debug && h.log("[AvatarView] Disposing avatar view..."), b.logEvent("character_view", "info", {
|
|
5883
5960
|
characterId: this.avatar.id,
|
|
5884
5961
|
event: "disposed"
|
|
5885
|
-
}), this.avatarController && this.avatarController.clear(), this.stopAllAnimationLoops()
|
|
5886
|
-
|
|
5962
|
+
}), this.avatarController && this.avatarController.clear(), this.stopAllAnimationLoops(), this.setState(
|
|
5963
|
+
"idle"
|
|
5964
|
+
/* Idle */
|
|
5965
|
+
);
|
|
5966
|
+
const e = b.getAvatarCore();
|
|
5887
5967
|
if (e)
|
|
5888
5968
|
try {
|
|
5889
|
-
e.releaseCurrentCharacter(),
|
|
5969
|
+
e.releaseCurrentCharacter(), k.debug && h.log("[AvatarView] AvatarCore character resources released");
|
|
5890
5970
|
} catch (t) {
|
|
5891
5971
|
h.error("[AvatarView] Failed to release AvatarCore resources:", t instanceof Error ? t.message : String(t));
|
|
5892
5972
|
}
|
|
5893
|
-
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,
|
|
5973
|
+
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, k.debug && h.log("[AvatarView] Avatar view disposed successfully");
|
|
5894
5974
|
}
|
|
5895
5975
|
/**
|
|
5896
5976
|
* 获取相机配置
|
|
@@ -5902,7 +5982,7 @@ class Ni {
|
|
|
5902
5982
|
* 更新相机配置
|
|
5903
5983
|
*/
|
|
5904
5984
|
updateCameraConfig(e) {
|
|
5905
|
-
this.cameraConfig = e,
|
|
5985
|
+
this.cameraConfig = e, k.debug && h.log("[AvatarView] Camera config updated:", e), this.renderSystem && (this.renderSystem.updateCamera(e), k.debug && h.log("[AvatarView] Applied new camera config to render system"));
|
|
5906
5986
|
}
|
|
5907
5987
|
/**
|
|
5908
5988
|
* 处理尺寸变化:通知渲染系统更新视口与投影
|
|
@@ -5924,15 +6004,15 @@ class Ni {
|
|
|
5924
6004
|
}
|
|
5925
6005
|
}
|
|
5926
6006
|
export {
|
|
5927
|
-
|
|
5928
|
-
|
|
6007
|
+
k as A,
|
|
6008
|
+
Se as C,
|
|
5929
6009
|
le as E,
|
|
5930
6010
|
oe as L,
|
|
5931
6011
|
rn as R,
|
|
5932
6012
|
se as S,
|
|
5933
|
-
|
|
6013
|
+
b as a,
|
|
5934
6014
|
sn as b,
|
|
5935
|
-
|
|
6015
|
+
Si as c,
|
|
5936
6016
|
Bt as d,
|
|
5937
6017
|
je as e,
|
|
5938
6018
|
Ni as f,
|
|
@@ -5943,4 +6023,4 @@ export {
|
|
|
5943
6023
|
Oi as k,
|
|
5944
6024
|
h as l
|
|
5945
6025
|
};
|
|
5946
|
-
//# sourceMappingURL=index-
|
|
6026
|
+
//# sourceMappingURL=index-B-JbfZD-.js.map
|