@spatialwalk/avatarkit 1.0.0-beta.13 → 1.0.0-beta.15
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 +38 -0
- package/README.md +13 -3
- package/dist/{StreamingAudioPlayer-CsVJinsO.js → StreamingAudioPlayer-Dj1w6HZz.js} +57 -41
- package/dist/StreamingAudioPlayer-Dj1w6HZz.js.map +1 -0
- package/dist/animation/AnimationWebSocketClient.d.ts +2 -0
- package/dist/animation/AnimationWebSocketClient.d.ts.map +1 -1
- package/dist/audio/AnimationPlayer.d.ts +8 -0
- package/dist/audio/AnimationPlayer.d.ts.map +1 -1
- package/dist/audio/StreamingAudioPlayer.d.ts +1 -0
- package/dist/audio/StreamingAudioPlayer.d.ts.map +1 -1
- package/dist/avatar_core_wasm-D-1WNg4B.js +1676 -0
- package/dist/avatar_core_wasm-D-1WNg4B.js.map +1 -0
- package/dist/avatar_core_wasm.wasm +0 -0
- package/dist/core/AvatarController.d.ts +31 -20
- package/dist/core/AvatarController.d.ts.map +1 -1
- package/dist/core/AvatarDownloader.d.ts.map +1 -1
- package/dist/core/AvatarView.d.ts.map +1 -1
- package/dist/{index-Cy9jPcQt.js → index-Bh6KkhoR.js} +636 -583
- package/dist/index-Bh6KkhoR.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/vanilla/vite.config.d.ts +3 -0
- package/dist/vanilla/vite.config.d.ts.map +1 -0
- package/package.json +12 -11
- package/dist/StreamingAudioPlayer-CsVJinsO.js.map +0 -1
- package/dist/avatar_core_wasm-D4eEi7Eh.js +0 -1666
- package/dist/avatar_core_wasm-D4eEi7Eh.js.map +0 -1
- package/dist/index-Cy9jPcQt.js.map +0 -1
|
@@ -31,14 +31,14 @@ class rn {
|
|
|
31
31
|
}
|
|
32
32
|
var nn = /* @__PURE__ */ ((r) => (r.CAMERA = "camera", r.ANIMATION_IDLE = "frameIdle", r.ANIMATION_MONO = "frameMono", r.AUDIO_MONO = "audioMono", r.MODEL_SHAPE = "shape", r.MODEL_GS = "gsStandard", r))(nn || {});
|
|
33
33
|
function Bi(r) {
|
|
34
|
-
var e, t, n, i, a, o,
|
|
34
|
+
var e, t, n, i, a, o, l, s, p, c, u, m, v, w, y, b, I;
|
|
35
35
|
return {
|
|
36
36
|
camera: ((t = (e = r.camera) == null ? void 0 : e.resource) == null ? void 0 : t.remote) || null,
|
|
37
37
|
frameIdle: ((a = (i = (n = r.animations) == null ? void 0 : n.frameIdle) == null ? void 0 : i.resource) == null ? void 0 : a.remote) || null,
|
|
38
|
-
frameMono: ((
|
|
39
|
-
audioMono: ((u = (c = (
|
|
38
|
+
frameMono: ((s = (l = (o = r.animations) == null ? void 0 : o.frameMono) == null ? void 0 : l.resource) == null ? void 0 : s.remote) || null,
|
|
39
|
+
audioMono: ((u = (c = (p = r.animations) == null ? void 0 : p.audioMono) == null ? void 0 : c.resource) == null ? void 0 : u.remote) || null,
|
|
40
40
|
shape: ((w = (v = (m = r.models) == null ? void 0 : m.shape) == null ? void 0 : v.resource) == null ? void 0 : w.remote) || null,
|
|
41
|
-
gsStandard: ((
|
|
41
|
+
gsStandard: ((I = (b = (y = r.models) == null ? void 0 : y.gsStandard) == null ? void 0 : b.resource) == null ? void 0 : I.remote) || null
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function Di(r) {
|
|
@@ -48,13 +48,13 @@ function Di(r) {
|
|
|
48
48
|
function Oi(r) {
|
|
49
49
|
var e, t, n, i, a, o;
|
|
50
50
|
try {
|
|
51
|
-
const
|
|
52
|
-
return !!((n = (t = (e =
|
|
51
|
+
const l = JSON.parse(r);
|
|
52
|
+
return !!((n = (t = (e = l == null ? void 0 : l.animations) == null ? void 0 : e.frameMono) == null ? void 0 : t.resource) != null && n.remote && ((o = (a = (i = l == null ? void 0 : l.animations) == null ? void 0 : i.audioMono) == null ? void 0 : a.resource) != null && o.remote));
|
|
53
53
|
} catch {
|
|
54
54
|
return !1;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
var le = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(le || {}), oe = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(oe || {}), Se = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(Se || {}),
|
|
57
|
+
var le = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(le || {}), oe = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(oe || {}), Se = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(Se || {}), T = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(T || {});
|
|
58
58
|
class se extends Error {
|
|
59
59
|
constructor(e, t) {
|
|
60
60
|
super(e), this.code = t, this.name = "SPAvatarError";
|
|
@@ -146,11 +146,11 @@ function ln() {
|
|
|
146
146
|
return this[y];
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
var a = ["isConstructor", "isEval", "isNative", "isToplevel"], o = ["columnNumber", "lineNumber"],
|
|
149
|
+
var a = ["isConstructor", "isEval", "isNative", "isToplevel"], o = ["columnNumber", "lineNumber"], l = ["fileName", "functionName", "source"], s = ["args"], p = ["evalOrigin"], c = a.concat(o, l, s, p);
|
|
150
150
|
function u(y) {
|
|
151
151
|
if (y)
|
|
152
|
-
for (var
|
|
153
|
-
y[c[
|
|
152
|
+
for (var b = 0; b < c.length; b++)
|
|
153
|
+
y[c[b]] !== void 0 && this["set" + n(c[b])](y[c[b]]);
|
|
154
154
|
}
|
|
155
155
|
u.prototype = {
|
|
156
156
|
getArgs: function() {
|
|
@@ -173,41 +173,41 @@ function ln() {
|
|
|
173
173
|
throw new TypeError("Eval Origin must be an Object or StackFrame");
|
|
174
174
|
},
|
|
175
175
|
toString: function() {
|
|
176
|
-
var y = this.getFileName() || "",
|
|
177
|
-
return this.getIsEval() ? y ? "[eval] (" + y + ":" +
|
|
176
|
+
var y = this.getFileName() || "", b = this.getLineNumber() || "", I = this.getColumnNumber() || "", L = this.getFunctionName() || "";
|
|
177
|
+
return this.getIsEval() ? y ? "[eval] (" + y + ":" + b + ":" + I + ")" : "[eval]:" + b + ":" + I : L ? L + " (" + y + ":" + b + ":" + I + ")" : y + ":" + b + ":" + I;
|
|
178
178
|
}
|
|
179
|
-
}, u.fromString = function(
|
|
180
|
-
var
|
|
181
|
-
if (
|
|
182
|
-
var
|
|
179
|
+
}, u.fromString = function(b) {
|
|
180
|
+
var I = b.indexOf("("), L = b.lastIndexOf(")"), _ = b.substring(0, I), X = b.substring(I + 1, L).split(","), G = b.substring(L + 1);
|
|
181
|
+
if (G.indexOf("@") === 0)
|
|
182
|
+
var U = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""), j = U[1], Y = U[2], J = U[3];
|
|
183
183
|
return new u({
|
|
184
184
|
functionName: _,
|
|
185
|
-
args:
|
|
186
|
-
fileName:
|
|
187
|
-
lineNumber:
|
|
188
|
-
columnNumber:
|
|
185
|
+
args: X || void 0,
|
|
186
|
+
fileName: j,
|
|
187
|
+
lineNumber: Y || void 0,
|
|
188
|
+
columnNumber: J || void 0
|
|
189
189
|
});
|
|
190
190
|
};
|
|
191
191
|
for (var m = 0; m < a.length; m++)
|
|
192
192
|
u.prototype["get" + n(a[m])] = i(a[m]), u.prototype["set" + n(a[m])] = /* @__PURE__ */ function(y) {
|
|
193
|
-
return function(
|
|
194
|
-
this[y] = !!
|
|
193
|
+
return function(b) {
|
|
194
|
+
this[y] = !!b;
|
|
195
195
|
};
|
|
196
196
|
}(a[m]);
|
|
197
197
|
for (var v = 0; v < o.length; v++)
|
|
198
198
|
u.prototype["get" + n(o[v])] = i(o[v]), u.prototype["set" + n(o[v])] = /* @__PURE__ */ function(y) {
|
|
199
|
-
return function(
|
|
200
|
-
if (!t(
|
|
199
|
+
return function(b) {
|
|
200
|
+
if (!t(b))
|
|
201
201
|
throw new TypeError(y + " must be a Number");
|
|
202
|
-
this[y] = Number(
|
|
202
|
+
this[y] = Number(b);
|
|
203
203
|
};
|
|
204
204
|
}(o[v]);
|
|
205
|
-
for (var w = 0; w <
|
|
206
|
-
u.prototype["get" + n(
|
|
207
|
-
return function(
|
|
208
|
-
this[y] = String(
|
|
205
|
+
for (var w = 0; w < l.length; w++)
|
|
206
|
+
u.prototype["get" + n(l[w])] = i(l[w]), u.prototype["set" + n(l[w])] = /* @__PURE__ */ function(y) {
|
|
207
|
+
return function(b) {
|
|
208
|
+
this[y] = String(b);
|
|
209
209
|
};
|
|
210
|
-
}(
|
|
210
|
+
}(l[w]);
|
|
211
211
|
return u;
|
|
212
212
|
});
|
|
213
213
|
}(Oe)), Oe.exports;
|
|
@@ -224,28 +224,28 @@ function ln() {
|
|
|
224
224
|
* @param {Error} error object
|
|
225
225
|
* @return {Array} of StackFrames
|
|
226
226
|
*/
|
|
227
|
-
parse: function(
|
|
228
|
-
if (typeof
|
|
229
|
-
return this.parseOpera(
|
|
230
|
-
if (
|
|
231
|
-
return this.parseV8OrIE(
|
|
232
|
-
if (
|
|
233
|
-
return this.parseFFOrSafari(
|
|
227
|
+
parse: function(s) {
|
|
228
|
+
if (typeof s.stacktrace < "u" || typeof s["opera#sourceloc"] < "u")
|
|
229
|
+
return this.parseOpera(s);
|
|
230
|
+
if (s.stack && s.stack.match(a))
|
|
231
|
+
return this.parseV8OrIE(s);
|
|
232
|
+
if (s.stack)
|
|
233
|
+
return this.parseFFOrSafari(s);
|
|
234
234
|
throw new Error("Cannot parse given Error object");
|
|
235
235
|
},
|
|
236
236
|
// Separate line and column numbers from a string of the form: (URI:Line:Column)
|
|
237
|
-
extractLocation: function(
|
|
238
|
-
if (
|
|
239
|
-
return [
|
|
240
|
-
var
|
|
237
|
+
extractLocation: function(s) {
|
|
238
|
+
if (s.indexOf(":") === -1)
|
|
239
|
+
return [s];
|
|
240
|
+
var p = /(.+?)(?::(\d+))?(?::(\d+))?$/, c = p.exec(s.replace(/[()]/g, ""));
|
|
241
241
|
return [c[1], c[2] || void 0, c[3] || void 0];
|
|
242
242
|
},
|
|
243
|
-
parseV8OrIE: function(
|
|
244
|
-
var
|
|
243
|
+
parseV8OrIE: function(s) {
|
|
244
|
+
var p = s.stack.split(`
|
|
245
245
|
`).filter(function(c) {
|
|
246
246
|
return !!c.match(a);
|
|
247
247
|
}, this);
|
|
248
|
-
return
|
|
248
|
+
return p.map(function(c) {
|
|
249
249
|
c.indexOf("(eval ") > -1 && (c = c.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
|
|
250
250
|
var u = c.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), m = u.match(/ (\(.+\)$)/);
|
|
251
251
|
u = m ? u.replace(m[0], "") : u;
|
|
@@ -259,12 +259,12 @@ function ln() {
|
|
|
259
259
|
});
|
|
260
260
|
}, this);
|
|
261
261
|
},
|
|
262
|
-
parseFFOrSafari: function(
|
|
263
|
-
var
|
|
262
|
+
parseFFOrSafari: function(s) {
|
|
263
|
+
var p = s.stack.split(`
|
|
264
264
|
`).filter(function(c) {
|
|
265
265
|
return !c.match(o);
|
|
266
266
|
}, this);
|
|
267
|
-
return
|
|
267
|
+
return p.map(function(c) {
|
|
268
268
|
if (c.indexOf(" > eval") > -1 && (c = c.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), c.indexOf("@") === -1 && c.indexOf(":") === -1)
|
|
269
269
|
return new n({
|
|
270
270
|
functionName: c
|
|
@@ -279,16 +279,16 @@ function ln() {
|
|
|
279
279
|
});
|
|
280
280
|
}, this);
|
|
281
281
|
},
|
|
282
|
-
parseOpera: function(
|
|
283
|
-
return !
|
|
284
|
-
`) > -1 &&
|
|
285
|
-
`).length >
|
|
286
|
-
`).length ? this.parseOpera9(
|
|
282
|
+
parseOpera: function(s) {
|
|
283
|
+
return !s.stacktrace || s.message.indexOf(`
|
|
284
|
+
`) > -1 && s.message.split(`
|
|
285
|
+
`).length > s.stacktrace.split(`
|
|
286
|
+
`).length ? this.parseOpera9(s) : s.stack ? this.parseOpera11(s) : this.parseOpera10(s);
|
|
287
287
|
},
|
|
288
|
-
parseOpera9: function(
|
|
289
|
-
for (var
|
|
288
|
+
parseOpera9: function(s) {
|
|
289
|
+
for (var p = /Line (\d+).*script (?:in )?(\S+)/i, c = s.message.split(`
|
|
290
290
|
`), u = [], m = 2, v = c.length; m < v; m += 2) {
|
|
291
|
-
var w =
|
|
291
|
+
var w = p.exec(c[m]);
|
|
292
292
|
w && u.push(new n({
|
|
293
293
|
fileName: w[2],
|
|
294
294
|
lineNumber: w[1],
|
|
@@ -297,10 +297,10 @@ function ln() {
|
|
|
297
297
|
}
|
|
298
298
|
return u;
|
|
299
299
|
},
|
|
300
|
-
parseOpera10: function(
|
|
301
|
-
for (var
|
|
300
|
+
parseOpera10: function(s) {
|
|
301
|
+
for (var p = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, c = s.stacktrace.split(`
|
|
302
302
|
`), u = [], m = 0, v = c.length; m < v; m += 2) {
|
|
303
|
-
var w =
|
|
303
|
+
var w = p.exec(c[m]);
|
|
304
304
|
w && u.push(
|
|
305
305
|
new n({
|
|
306
306
|
functionName: w[3] || void 0,
|
|
@@ -313,18 +313,18 @@ function ln() {
|
|
|
313
313
|
return u;
|
|
314
314
|
},
|
|
315
315
|
// Opera 10.65+ Error.stack very similar to FF/Safari
|
|
316
|
-
parseOpera11: function(
|
|
317
|
-
var
|
|
316
|
+
parseOpera11: function(s) {
|
|
317
|
+
var p = s.stack.split(`
|
|
318
318
|
`).filter(function(c) {
|
|
319
319
|
return !!c.match(i) && !c.match(/^Error created at/);
|
|
320
320
|
}, this);
|
|
321
|
-
return
|
|
321
|
+
return p.map(function(c) {
|
|
322
322
|
var u = c.split("@"), m = this.extractLocation(u.pop()), v = u.shift() || "", w = v.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, y;
|
|
323
323
|
v.match(/\(([^)]*)\)/) && (y = v.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
|
|
324
|
-
var
|
|
324
|
+
var b = y === void 0 || y === "[arguments not available]" ? void 0 : y.split(",");
|
|
325
325
|
return new n({
|
|
326
326
|
functionName: w,
|
|
327
|
-
args:
|
|
327
|
+
args: b,
|
|
328
328
|
fileName: m[0],
|
|
329
329
|
lineNumber: m[1],
|
|
330
330
|
columnNumber: m[2],
|
|
@@ -339,26 +339,26 @@ var cn = qt.exports;
|
|
|
339
339
|
const un = /* @__PURE__ */ sn(cn);
|
|
340
340
|
let ft = () => {
|
|
341
341
|
var r = (() => {
|
|
342
|
-
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, i = Object.prototype.hasOwnProperty, a = (f,
|
|
343
|
-
for (var A in
|
|
344
|
-
}, o = (f,
|
|
345
|
-
if (
|
|
342
|
+
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, i = Object.prototype.hasOwnProperty, a = (f, g) => {
|
|
343
|
+
for (var A in g) e(f, A, { get: g[A], enumerable: !0 });
|
|
344
|
+
}, o = (f, g, A, C) => {
|
|
345
|
+
if (g && typeof g == "object" || typeof g == "function") for (let E of n(g)) !i.call(f, E) && E !== A && e(f, E, { get: () => g[E], enumerable: !(C = t(g, E)) || C.enumerable });
|
|
346
346
|
return f;
|
|
347
|
-
},
|
|
348
|
-
a(
|
|
349
|
-
var
|
|
350
|
-
const
|
|
347
|
+
}, l = (f) => o(e({}, "__esModule", { value: !0 }), f), s = {};
|
|
348
|
+
a(s, { default: () => Yr });
|
|
349
|
+
var p = (f) => Array.isArray(f), c = (f) => typeof f == "function", u = (f) => f.length === 0, m = (f) => typeof f == "number", v = (f) => typeof f == "object" && f !== null, w = (f) => f instanceof RegExp, y = (f) => typeof f == "string", b = (f) => f === void 0, I = (f) => {
|
|
350
|
+
const g = /* @__PURE__ */ new Map();
|
|
351
351
|
return (A) => {
|
|
352
|
-
const C =
|
|
352
|
+
const C = g.get(A);
|
|
353
353
|
if (C) return C;
|
|
354
354
|
const E = f(A);
|
|
355
|
-
return
|
|
355
|
+
return g.set(A, E), E;
|
|
356
356
|
};
|
|
357
|
-
}, L = (f,
|
|
357
|
+
}, L = (f, g, A = {}) => {
|
|
358
358
|
const C = { cache: {}, input: f, index: 0, indexMax: 0, options: A, output: [] };
|
|
359
|
-
if (
|
|
359
|
+
if (V(g)(C) && C.index === f.length) return C.output;
|
|
360
360
|
throw new Error(`Failed to parse at index ${C.indexMax}`);
|
|
361
|
-
}, _ = (f,
|
|
361
|
+
}, _ = (f, g) => p(f) ? X(f, g) : y(f) ? U(f, g) : G(f, g), X = (f, g) => {
|
|
362
362
|
const A = {};
|
|
363
363
|
for (const C of f) {
|
|
364
364
|
if (C.length !== 1) throw new Error(`Invalid character: "${C}"`);
|
|
@@ -370,125 +370,125 @@ let ft = () => {
|
|
|
370
370
|
for (; C.index < P.length && P.charCodeAt(C.index) in A; ) C.index += 1;
|
|
371
371
|
const R = C.index;
|
|
372
372
|
if (R > E) {
|
|
373
|
-
if (!
|
|
374
|
-
const
|
|
375
|
-
|
|
373
|
+
if (!b(g) && !C.options.silent) {
|
|
374
|
+
const W = C.input.slice(E, R), H = c(g) ? g(W, P, String(E)) : g;
|
|
375
|
+
b(H) || C.output.push(H);
|
|
376
376
|
}
|
|
377
377
|
C.indexMax = Math.max(C.indexMax, C.index);
|
|
378
378
|
}
|
|
379
379
|
return !0;
|
|
380
380
|
};
|
|
381
|
-
},
|
|
381
|
+
}, G = (f, g) => {
|
|
382
382
|
const A = f.source, C = f.flags.replace(/y|$/, "y"), E = new RegExp(A, C);
|
|
383
383
|
return ne((P) => {
|
|
384
384
|
E.lastIndex = P.index;
|
|
385
385
|
const R = E.exec(P.input);
|
|
386
386
|
if (R) {
|
|
387
|
-
if (!
|
|
388
|
-
const
|
|
389
|
-
|
|
387
|
+
if (!b(g) && !P.options.silent) {
|
|
388
|
+
const W = c(g) ? g(...R, P.input, String(P.index)) : g;
|
|
389
|
+
b(W) || P.output.push(W);
|
|
390
390
|
}
|
|
391
391
|
return P.index += R[0].length, P.indexMax = Math.max(P.indexMax, P.index), !0;
|
|
392
392
|
} else return !1;
|
|
393
393
|
});
|
|
394
|
-
},
|
|
394
|
+
}, U = (f, g) => (A) => {
|
|
395
395
|
if (A.input.startsWith(f, A.index)) {
|
|
396
|
-
if (!
|
|
397
|
-
const C = c(
|
|
398
|
-
|
|
396
|
+
if (!b(g) && !A.options.silent) {
|
|
397
|
+
const C = c(g) ? g(f, A.input, String(A.index)) : g;
|
|
398
|
+
b(C) || A.output.push(C);
|
|
399
399
|
}
|
|
400
400
|
return A.index += f.length, A.indexMax = Math.max(A.indexMax, A.index), !0;
|
|
401
401
|
} else return !1;
|
|
402
|
-
},
|
|
403
|
-
const E =
|
|
402
|
+
}, j = (f, g, A, C) => {
|
|
403
|
+
const E = V(f);
|
|
404
404
|
return ne(de(we((P) => {
|
|
405
405
|
let R = 0;
|
|
406
406
|
for (; R < A; ) {
|
|
407
|
-
const
|
|
408
|
-
if (!E(P) || (R += 1, P.index ===
|
|
407
|
+
const W = P.index;
|
|
408
|
+
if (!E(P) || (R += 1, P.index === W)) break;
|
|
409
409
|
}
|
|
410
|
-
return R >=
|
|
410
|
+
return R >= g;
|
|
411
411
|
})));
|
|
412
|
-
},
|
|
413
|
-
const A = f.map(
|
|
412
|
+
}, Y = (f, g) => j(f, 0, 1), J = (f, g) => j(f, 0, 1 / 0), re = (f, g) => {
|
|
413
|
+
const A = f.map(V);
|
|
414
414
|
return ne(de(we((C) => {
|
|
415
415
|
for (let E = 0, P = A.length; E < P; E++) if (!A[E](C)) return !1;
|
|
416
416
|
return !0;
|
|
417
417
|
})));
|
|
418
|
-
},
|
|
419
|
-
const A = f.map(
|
|
418
|
+
}, z = (f, g) => {
|
|
419
|
+
const A = f.map(V);
|
|
420
420
|
return ne(de((C) => {
|
|
421
421
|
for (let E = 0, P = A.length; E < P; E++) if (A[E](C)) return !0;
|
|
422
422
|
return !1;
|
|
423
423
|
}));
|
|
424
|
-
}, we = (f,
|
|
425
|
-
const A =
|
|
424
|
+
}, we = (f, g = !1) => {
|
|
425
|
+
const A = V(f);
|
|
426
426
|
return (C) => {
|
|
427
427
|
const E = C.index, P = C.output.length, R = A(C);
|
|
428
|
-
return (!R ||
|
|
428
|
+
return (!R || g) && (C.index = E, C.output.length !== P && (C.output.length = P)), R;
|
|
429
429
|
};
|
|
430
|
-
}, de = (f,
|
|
430
|
+
}, de = (f, g) => V(f), ne = /* @__PURE__ */ (() => {
|
|
431
431
|
let f = 0;
|
|
432
|
-
return (
|
|
433
|
-
const A =
|
|
432
|
+
return (g) => {
|
|
433
|
+
const A = V(g), C = f += 1;
|
|
434
434
|
return (E) => {
|
|
435
435
|
var st;
|
|
436
436
|
var P;
|
|
437
437
|
if (E.options.memoization === !1) return A(E);
|
|
438
|
-
const R = E.index,
|
|
439
|
-
if (
|
|
440
|
-
if (m(
|
|
441
|
-
if (
|
|
438
|
+
const R = E.index, W = (P = E.cache)[C] || (P[C] = /* @__PURE__ */ new Map()), H = W.get(R);
|
|
439
|
+
if (H === !1) return !1;
|
|
440
|
+
if (m(H)) return E.index = H, !0;
|
|
441
|
+
if (H) return E.index = H.index, (st = H.output) != null && st.length && E.output.push(...H.output), !0;
|
|
442
442
|
{
|
|
443
443
|
const lt = E.output.length;
|
|
444
444
|
if (A(E)) {
|
|
445
445
|
const ct = E.index, ut = E.output.length;
|
|
446
446
|
if (ut > lt) {
|
|
447
447
|
const Qr = E.output.slice(lt, ut);
|
|
448
|
-
|
|
449
|
-
} else
|
|
448
|
+
W.set(R, { index: ct, output: Qr });
|
|
449
|
+
} else W.set(R, ct);
|
|
450
450
|
return !0;
|
|
451
|
-
} else return
|
|
451
|
+
} else return W.set(R, !1), !1;
|
|
452
452
|
}
|
|
453
453
|
};
|
|
454
454
|
};
|
|
455
|
-
})(),
|
|
456
|
-
let
|
|
457
|
-
return (A) => (
|
|
458
|
-
},
|
|
459
|
-
if (c(f)) return u(f) ?
|
|
455
|
+
})(), B = (f) => {
|
|
456
|
+
let g;
|
|
457
|
+
return (A) => (g || (g = V(f())), g(A));
|
|
458
|
+
}, V = I((f) => {
|
|
459
|
+
if (c(f)) return u(f) ? B(f) : f;
|
|
460
460
|
if (y(f) || w(f)) return _(f);
|
|
461
|
-
if (
|
|
462
|
-
if (v(f)) return
|
|
461
|
+
if (p(f)) return re(f);
|
|
462
|
+
if (v(f)) return z(Object.values(f));
|
|
463
463
|
throw new Error("Invalid rule");
|
|
464
464
|
}), ie = "abcdefghijklmnopqrstuvwxyz", Le = (f) => {
|
|
465
|
-
let
|
|
465
|
+
let g = "";
|
|
466
466
|
for (; f > 0; ) {
|
|
467
467
|
const A = (f - 1) % 26;
|
|
468
|
-
|
|
468
|
+
g = ie[A] + g, f = Math.floor((f - 1) / 26);
|
|
469
469
|
}
|
|
470
|
-
return
|
|
471
|
-
},
|
|
472
|
-
let
|
|
473
|
-
for (let A = 0, C = f.length; A < C; A++)
|
|
474
|
-
return
|
|
475
|
-
}, Te = (f,
|
|
476
|
-
if (
|
|
470
|
+
return g;
|
|
471
|
+
}, q = (f) => {
|
|
472
|
+
let g = 0;
|
|
473
|
+
for (let A = 0, C = f.length; A < C; A++) g = g * 26 + ie.indexOf(f[A]) + 1;
|
|
474
|
+
return g;
|
|
475
|
+
}, Te = (f, g) => {
|
|
476
|
+
if (g < f) return Te(g, f);
|
|
477
477
|
const A = [];
|
|
478
|
-
for (; f <=
|
|
478
|
+
for (; f <= g; ) A.push(f++);
|
|
479
479
|
return A;
|
|
480
|
-
}, ir = (f,
|
|
481
|
-
const
|
|
482
|
-
return (A) =>
|
|
483
|
-
}, or = _(/^\*\*\/\*$/, ".*"), sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f,
|
|
480
|
+
}, ir = (f, g, A) => Te(f, g).map((C) => String(C).padStart(A, "0")), Ye = (f, g) => Te(q(f), q(g)).map(Le), Z = (f) => f, Qe = (f) => ar((g) => L(g, f, { memoization: !1 }).join("")), ar = (f) => {
|
|
481
|
+
const g = {};
|
|
482
|
+
return (A) => g[A] ?? (g[A] = f(A));
|
|
483
|
+
}, or = _(/^\*\*\/\*$/, ".*"), sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, A) => `.*${g ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}`), lr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, A, C) => `.*${g ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Be = _(/\\./, Z), cr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), ur = _(/./, Z), dr = _(/^(?:!!)*!(.*)$/, (f, g) => `(?!^${ot(g)}$).*?`), hr = _(/^(!!)+/, ""), fr = z([dr, hr]), mr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), pr = _(/^(\*\*\/)+/, "(?:^|.*/)"), gr = _(/\/(\*\*)$/, "(?:/.*|$)"), vr = _(/\*\*/, ".*"), et = z([mr, pr, gr, vr]), wr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = _(/\*/, "[^/]*"), tt = z([wr, yr]), rt = _("?", "[^/]"), Ar = _("[", Z), Sr = _("]", Z), br = _(/[!^]/, "^/"), Cr = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, Z), _r = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), Er = _(/[^\]]/, Z), Ir = z([Be, _r, Cr, Er]), nt = re([Ar, Y(br), J(Ir), Sr]), Pr = _("{", "(?:"), xr = _("}", ")"), kr = _(/(\d+)\.\.(\d+)/, (f, g, A) => ir(+g, +A, Math.min(g.length, A.length)).join("|")), Mr = _(/([a-z]+)\.\.([a-z]+)/, (f, g, A) => Ye(g, A).join("|")), Fr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, g, A) => Ye(g.toLowerCase(), A.toLowerCase()).join("|").toUpperCase()), Rr = z([kr, Mr, Fr]), it = re([Pr, Rr, xr]), Lr = _("{", "(?:"), Tr = _("}", ")"), Br = _(",", "|"), Dr = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), Or = _(/[^}]/, Z), Nr = B(() => at), Ur = z([et, tt, rt, nt, it, Nr, Be, Dr, Br, Or]), at = re([Lr, J(Ur), Tr]), zr = J(z([or, sr, lr, fr, et, tt, rt, nt, it, at, Be, cr, ur])), Vr = zr, $r = Qe(Vr), ot = $r, qr = _(/\\./, Z), Wr = _(/./, Z), Gr = _(/\*\*\*+/, "*"), jr = _(/([^/{[(!])\*\*/, (f, g) => `${g}*`), Hr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, g) => `${g}*`), Kr = J(z([qr, Gr, jr, Hr, Wr])), Jr = Kr, Zr = Qe(Jr), Xr = Zr, De = (f, g) => {
|
|
484
484
|
const A = Array.isArray(f) ? f : [f];
|
|
485
485
|
if (!A.length) return !1;
|
|
486
|
-
const C = A.map(De.compile), E = A.every((R) => /(\/(?:\*\*)?|\[\/\])$/.test(R)), P =
|
|
486
|
+
const C = A.map(De.compile), E = A.every((R) => /(\/(?:\*\*)?|\[\/\])$/.test(R)), P = g.replace(/[\\\/]+/g, "/").replace(/\/$/, E ? "/" : "");
|
|
487
487
|
return C.some((R) => R.test(P));
|
|
488
488
|
};
|
|
489
|
-
De.compile = (f) => new RegExp(`^${ot(
|
|
490
|
-
var
|
|
491
|
-
return s
|
|
489
|
+
De.compile = (f) => new RegExp(`^${ot(Xr(f))}$`, "s");
|
|
490
|
+
var Yr = De;
|
|
491
|
+
return l(s);
|
|
492
492
|
})();
|
|
493
493
|
return r.default || r;
|
|
494
494
|
}, Ne;
|
|
@@ -496,7 +496,7 @@ const dn = (r, e) => (Ne || (Ne = ft(), ft = null), Ne(r, e)), hn = /^[A-Za-z]:\
|
|
|
496
496
|
function ce(r = "") {
|
|
497
497
|
return r && r.replace(/\\/g, "/").replace(hn, (e) => e.toUpperCase());
|
|
498
498
|
}
|
|
499
|
-
const fn = /^[/\\]{2}/, mn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, Wt = /^[A-Za-z]:$/, mt = /^\/([A-Za-z]:)?$/,
|
|
499
|
+
const fn = /^[/\\]{2}/, mn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, Wt = /^[A-Za-z]:$/, mt = /^\/([A-Za-z]:)?$/, pn = /.(\.[^./]+|\.)$/, gn = /^[/\\]|^[a-zA-Z]:[/\\]/, vn = "/", Ke = function(r) {
|
|
500
500
|
if (r.length === 0)
|
|
501
501
|
return ".";
|
|
502
502
|
r = ce(r);
|
|
@@ -527,30 +527,30 @@ const Me = function(...r) {
|
|
|
527
527
|
};
|
|
528
528
|
function Je(r, e) {
|
|
529
529
|
let t = "", n = 0, i = -1, a = 0, o = null;
|
|
530
|
-
for (let
|
|
531
|
-
if (
|
|
532
|
-
o = r[
|
|
530
|
+
for (let l = 0; l <= r.length; ++l) {
|
|
531
|
+
if (l < r.length)
|
|
532
|
+
o = r[l];
|
|
533
533
|
else {
|
|
534
534
|
if (o === "/")
|
|
535
535
|
break;
|
|
536
536
|
o = "/";
|
|
537
537
|
}
|
|
538
538
|
if (o === "/") {
|
|
539
|
-
if (!(i ===
|
|
539
|
+
if (!(i === l - 1 || a === 1)) if (a === 2) {
|
|
540
540
|
if (t.length < 2 || n !== 2 || t[t.length - 1] !== "." || t[t.length - 2] !== ".") {
|
|
541
541
|
if (t.length > 2) {
|
|
542
|
-
const
|
|
543
|
-
|
|
542
|
+
const s = t.lastIndexOf("/");
|
|
543
|
+
s === -1 ? (t = "", n = 0) : (t = t.slice(0, s), n = t.length - 1 - t.lastIndexOf("/")), i = l, a = 0;
|
|
544
544
|
continue;
|
|
545
545
|
} else if (t.length > 0) {
|
|
546
|
-
t = "", n = 0, i =
|
|
546
|
+
t = "", n = 0, i = l, a = 0;
|
|
547
547
|
continue;
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
e && (t += t.length > 0 ? "/.." : "..", n = 2);
|
|
551
551
|
} else
|
|
552
|
-
t.length > 0 ? t += `/${r.slice(i + 1,
|
|
553
|
-
i =
|
|
552
|
+
t.length > 0 ? t += `/${r.slice(i + 1, l)}` : t = r.slice(i + 1, l), n = l - i - 1;
|
|
553
|
+
i = l, a = 0;
|
|
554
554
|
} else o === "." && a !== -1 ? ++a : a = -1;
|
|
555
555
|
}
|
|
556
556
|
return t;
|
|
@@ -561,7 +561,7 @@ const ve = function(r) {
|
|
|
561
561
|
return ce(r);
|
|
562
562
|
}, Gt = function(r) {
|
|
563
563
|
if (r === "..") return "";
|
|
564
|
-
const e =
|
|
564
|
+
const e = pn.exec(ce(r));
|
|
565
565
|
return e && e[1] || "";
|
|
566
566
|
}, Sn = function(r, e) {
|
|
567
567
|
const t = Me(r).replace(mt, "$1").split("/"), n = Me(e).replace(mt, "$1").split("/");
|
|
@@ -597,7 +597,7 @@ const ve = function(r) {
|
|
|
597
597
|
return e && n.endsWith(e) ? n.slice(0, -e.length) : n;
|
|
598
598
|
}, Cn = function(r) {
|
|
599
599
|
var i, a;
|
|
600
|
-
const e = ((a = (i =
|
|
600
|
+
const e = ((a = (i = gn.exec(r)) == null ? void 0 : i[0]) == null ? void 0 : a.replace(/\\/g, "/")) || "", t = Ht(r), n = Gt(t);
|
|
601
601
|
return {
|
|
602
602
|
root: e,
|
|
603
603
|
dir: jt(r),
|
|
@@ -605,7 +605,7 @@ const ve = function(r) {
|
|
|
605
605
|
ext: n,
|
|
606
606
|
name: t.slice(0, t.length - n.length)
|
|
607
607
|
};
|
|
608
|
-
}, _n = (r, e) => dn(e, Ke(r)),
|
|
608
|
+
}, _n = (r, e) => dn(e, Ke(r)), pt = {
|
|
609
609
|
__proto__: null,
|
|
610
610
|
basename: Ht,
|
|
611
611
|
dirname: jt,
|
|
@@ -624,13 +624,13 @@ const ve = function(r) {
|
|
|
624
624
|
}, En = /* @__PURE__ */ (() => {
|
|
625
625
|
var r;
|
|
626
626
|
return ((r = globalThis.process) == null ? void 0 : r.platform) === "win32" ? ";" : ":";
|
|
627
|
-
})(),
|
|
627
|
+
})(), In = { posix: void 0, win32: void 0 }, Kt = (r = En) => new Proxy(pt, {
|
|
628
628
|
get(e, t) {
|
|
629
|
-
return t === "delimiter" ? r : t === "posix" ? We : t === "win32" ? Pn :
|
|
629
|
+
return t === "delimiter" ? r : t === "posix" ? We : t === "win32" ? Pn : In[t] || pt[t];
|
|
630
630
|
}
|
|
631
631
|
}), We = /* @__PURE__ */ Kt(":"), Pn = /* @__PURE__ */ Kt(";");
|
|
632
|
-
var k = /* @__PURE__ */ ((r) => (r[r.Error = 0] = "Error", r[r.Warning = 1] = "Warning", r[r.Log = 2] = "Log", r[r.Verbose = 3] = "Verbose", r[r.Debug = 4] = "Debug", r))(k || {}),
|
|
633
|
-
const
|
|
632
|
+
var k = /* @__PURE__ */ ((r) => (r[r.Error = 0] = "Error", r[r.Warning = 1] = "Warning", r[r.Log = 2] = "Log", r[r.Verbose = 3] = "Verbose", r[r.Debug = 4] = "Debug", r))(k || {}), x = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(x || {}), te = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(te || {});
|
|
633
|
+
const xn = !0;
|
|
634
634
|
function F(r, e, t = r) {
|
|
635
635
|
return (n) => {
|
|
636
636
|
const i = `${n}`, a = i.indexOf(e, r.length);
|
|
@@ -641,7 +641,7 @@ function Jt(r, e, t, n) {
|
|
|
641
641
|
const i = r.substring(0, n) + t, a = r.substring(n + e.length), o = a.indexOf(e);
|
|
642
642
|
return ~o ? i + Jt(a, e, t, o) : i + a;
|
|
643
643
|
}
|
|
644
|
-
function kn(r =
|
|
644
|
+
function kn(r = xn) {
|
|
645
645
|
return {
|
|
646
646
|
isColorSupported: r,
|
|
647
647
|
reset: r ? (e) => `\x1B[0m${e}\x1B[0m` : String,
|
|
@@ -671,30 +671,30 @@ function kn(r = In) {
|
|
|
671
671
|
bgWhite: r ? F("\x1B[47m", "\x1B[49m") : String
|
|
672
672
|
};
|
|
673
673
|
}
|
|
674
|
-
const
|
|
675
|
-
[
|
|
676
|
-
[
|
|
677
|
-
[
|
|
678
|
-
[
|
|
679
|
-
[
|
|
674
|
+
const D = kn(), Ge = {
|
|
675
|
+
[x.Error]: k.Error,
|
|
676
|
+
[x.Warning]: k.Warning,
|
|
677
|
+
[x.Log]: k.Log,
|
|
678
|
+
[x.Verbose]: k.Verbose,
|
|
679
|
+
[x.Debug]: k.Debug
|
|
680
680
|
}, Mn = {
|
|
681
|
-
[k.Error]:
|
|
682
|
-
[k.Warning]:
|
|
683
|
-
[k.Log]:
|
|
684
|
-
[k.Verbose]:
|
|
685
|
-
[k.Debug]:
|
|
686
|
-
},
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
681
|
+
[k.Error]: x.Error,
|
|
682
|
+
[k.Warning]: x.Warning,
|
|
683
|
+
[k.Log]: x.Log,
|
|
684
|
+
[k.Verbose]: x.Verbose,
|
|
685
|
+
[k.Debug]: x.Debug
|
|
686
|
+
}, gt = [
|
|
687
|
+
x.Error,
|
|
688
|
+
x.Warning,
|
|
689
|
+
x.Log,
|
|
690
|
+
x.Verbose,
|
|
691
|
+
x.Debug
|
|
692
692
|
], Fn = {
|
|
693
|
-
[k.Error]:
|
|
694
|
-
[k.Warning]:
|
|
695
|
-
[k.Log]:
|
|
696
|
-
[k.Verbose]:
|
|
697
|
-
[k.Debug]:
|
|
693
|
+
[k.Error]: D.red,
|
|
694
|
+
[k.Warning]: D.yellow,
|
|
695
|
+
[k.Log]: D.blue,
|
|
696
|
+
[k.Verbose]: D.cyan,
|
|
697
|
+
[k.Debug]: D.green
|
|
698
698
|
}, Fe = [
|
|
699
699
|
k.Error,
|
|
700
700
|
k.Warning,
|
|
@@ -728,7 +728,7 @@ function Rn(r) {
|
|
|
728
728
|
function Zt(r) {
|
|
729
729
|
return r == null ? !1 : r instanceof Error;
|
|
730
730
|
}
|
|
731
|
-
function
|
|
731
|
+
function Xt(r, e, t, n, i) {
|
|
732
732
|
let a = { context: "" };
|
|
733
733
|
typeof t < "u" && t !== null && (a = { ...t }), typeof e < "u" && e !== null && (a.context = e);
|
|
734
734
|
const o = /* @__PURE__ */ new Date();
|
|
@@ -741,23 +741,23 @@ function Yt(r, e, t, n, i) {
|
|
|
741
741
|
};
|
|
742
742
|
}
|
|
743
743
|
function Ln(r, e, t, n, i, a) {
|
|
744
|
-
const o =
|
|
744
|
+
const o = Xt(r, e, t, n, a);
|
|
745
745
|
return typeof i < "u" && i !== null && (o.errored = !0, o.error = { stack: i }), o;
|
|
746
746
|
}
|
|
747
747
|
function wt(r) {
|
|
748
748
|
let e = "";
|
|
749
749
|
switch (typeof r) {
|
|
750
750
|
case "number":
|
|
751
|
-
e =
|
|
751
|
+
e = D.yellow(r);
|
|
752
752
|
break;
|
|
753
753
|
case "object":
|
|
754
|
-
e =
|
|
754
|
+
e = D.green(JSON.stringify(r));
|
|
755
755
|
break;
|
|
756
756
|
case "boolean":
|
|
757
|
-
e =
|
|
757
|
+
e = D.yellow(String(r));
|
|
758
758
|
break;
|
|
759
759
|
case "undefined":
|
|
760
|
-
e =
|
|
760
|
+
e = D.gray("undefined");
|
|
761
761
|
break;
|
|
762
762
|
default:
|
|
763
763
|
e = String(r);
|
|
@@ -765,7 +765,7 @@ function wt(r) {
|
|
|
765
765
|
}
|
|
766
766
|
return e;
|
|
767
767
|
}
|
|
768
|
-
function
|
|
768
|
+
function Ie(r) {
|
|
769
769
|
const e = [];
|
|
770
770
|
e.push(r["@localetime"]), e.push(
|
|
771
771
|
Fn[Ge[r.level]](
|
|
@@ -773,21 +773,21 @@ function xe(r) {
|
|
|
773
773
|
)
|
|
774
774
|
);
|
|
775
775
|
let t = "";
|
|
776
|
-
r.fields.isNestSystemModule != null && (t =
|
|
776
|
+
r.fields.isNestSystemModule != null && (t = D.magenta(`[${r.fields.nestSystemModule}]`), delete r.fields.isNestSystemModule, delete r.fields.nestSystemModule), r.fields.context != null && (t = D.magenta(`[${r.fields.context}]`), delete r.fields.context), t.length > 0 && e.push(t), "module" in r.fields && r.fields.module != null && (e.push(D.magenta(`[${r.fields.module}]`)), delete r.fields.module), e.push(r.message);
|
|
777
777
|
const n = Object.entries(r.fields);
|
|
778
778
|
n.length > 0 && e.push(" {");
|
|
779
779
|
for (const [a, o] of n) {
|
|
780
|
-
let
|
|
780
|
+
let l = o;
|
|
781
781
|
if (Zt(o)) {
|
|
782
|
-
if (o.message && (
|
|
782
|
+
if (o.message && (l = wt(o.message)), l || (l = ""), o.cause != null)
|
|
783
783
|
try {
|
|
784
|
-
|
|
784
|
+
l += JSON.stringify(o.cause);
|
|
785
785
|
} catch {
|
|
786
|
-
|
|
786
|
+
l += String(o.cause);
|
|
787
787
|
}
|
|
788
788
|
} else
|
|
789
|
-
|
|
790
|
-
e.push(`${
|
|
789
|
+
l = wt(o);
|
|
790
|
+
e.push(`${D.gray(a)}${D.gray("=")}${l}`);
|
|
791
791
|
}
|
|
792
792
|
n.length > 0 && e.push("}");
|
|
793
793
|
let i = e.join(" ");
|
|
@@ -809,11 +809,11 @@ function On(r) {
|
|
|
809
809
|
function Nn(r) {
|
|
810
810
|
return r >= k.Error;
|
|
811
811
|
}
|
|
812
|
-
function
|
|
812
|
+
function Yt() {
|
|
813
813
|
return typeof window < "u";
|
|
814
814
|
}
|
|
815
815
|
function Un() {
|
|
816
|
-
return !
|
|
816
|
+
return !Yt() && je() === te.Pretty;
|
|
817
817
|
}
|
|
818
818
|
function zn(r, e) {
|
|
819
819
|
return Un() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
|
|
@@ -878,13 +878,13 @@ function Qt(r) {
|
|
|
878
878
|
},
|
|
879
879
|
withLogLevelString: (c) => {
|
|
880
880
|
const u = e.child();
|
|
881
|
-
if (
|
|
881
|
+
if (gt.includes(c))
|
|
882
882
|
u.logLevel = Ge[c], u.shouldUseGlobalConfig = !1, u.debug(
|
|
883
883
|
`setting log level to ${c} (${Ge[c]})`
|
|
884
884
|
);
|
|
885
885
|
else
|
|
886
886
|
throw new Error(
|
|
887
|
-
`log level ${c} is not available. available log levels are: ${
|
|
887
|
+
`log level ${c} is not available. available log levels are: ${gt.join(
|
|
888
888
|
", "
|
|
889
889
|
)}`
|
|
890
890
|
);
|
|
@@ -954,56 +954,56 @@ function Qt(r) {
|
|
|
954
954
|
}
|
|
955
955
|
}, t = () => e.shouldUseGlobalConfig ? yt() : e.logLevel, n = () => e.shouldUseGlobalConfig ? je() : e.format, i = () => e.shouldUseGlobalConfig ? $n() : e.timeFormatter ?? ((c) => c.toISOString()), a = (c) => c != null && c.length > 0 ? Object.keys(e.fields).length > 0 ? [e.fields, ...c] : c : e.fields, o = (c, u, m) => {
|
|
956
956
|
const v = n();
|
|
957
|
-
if (
|
|
957
|
+
if (Yt() && v === te.Pretty) {
|
|
958
958
|
c.fields = Object.fromEntries(
|
|
959
|
-
Object.entries(c.fields).filter(([
|
|
960
|
-
if (
|
|
961
|
-
return [
|
|
959
|
+
Object.entries(c.fields).filter(([b, I]) => {
|
|
960
|
+
if (b === "isNestSystemModule" || b === "nestSystemModule" || b === "context")
|
|
961
|
+
return [b, I];
|
|
962
962
|
})
|
|
963
963
|
);
|
|
964
964
|
const y = m ?? e.fields;
|
|
965
|
-
Array.isArray(y) && y.length > 0 ? console[u](
|
|
965
|
+
Array.isArray(y) && y.length > 0 ? console[u](Ie(c), ...y) : Object.keys(y).length > 0 ? console[u](Ie(c), y) : console[u](Ie(c));
|
|
966
966
|
return;
|
|
967
967
|
}
|
|
968
|
-
const w = v === te.Pretty ?
|
|
968
|
+
const w = v === te.Pretty ? Ie(c) : JSON.stringify(c);
|
|
969
969
|
console[u](w);
|
|
970
|
-
}, s = {
|
|
971
|
-
[I.Debug]: Tn,
|
|
972
|
-
[I.Verbose]: Bn,
|
|
973
|
-
[I.Log]: Dn,
|
|
974
|
-
[I.Warning]: On
|
|
975
970
|
}, l = {
|
|
976
|
-
[
|
|
977
|
-
[
|
|
978
|
-
[
|
|
979
|
-
[
|
|
980
|
-
},
|
|
981
|
-
|
|
971
|
+
[x.Debug]: Tn,
|
|
972
|
+
[x.Verbose]: Bn,
|
|
973
|
+
[x.Log]: Dn,
|
|
974
|
+
[x.Warning]: On
|
|
975
|
+
}, s = {
|
|
976
|
+
[x.Debug]: "debug",
|
|
977
|
+
[x.Verbose]: "log",
|
|
978
|
+
[x.Log]: "log",
|
|
979
|
+
[x.Warning]: "warn"
|
|
980
|
+
}, p = (c, u, m) => {
|
|
981
|
+
const v = t(), w = l[c];
|
|
982
982
|
if (!w(v))
|
|
983
983
|
return;
|
|
984
|
-
const y = a(m),
|
|
984
|
+
const y = a(m), b = Xt(
|
|
985
985
|
c,
|
|
986
986
|
e.context,
|
|
987
987
|
y,
|
|
988
988
|
u,
|
|
989
989
|
i()
|
|
990
990
|
);
|
|
991
|
-
o(
|
|
991
|
+
o(b, s[c], y);
|
|
992
992
|
};
|
|
993
993
|
return e.debug = (c, ...u) => {
|
|
994
|
-
|
|
994
|
+
p(x.Debug, c, u);
|
|
995
995
|
}, e.verbose = (c, ...u) => {
|
|
996
|
-
|
|
996
|
+
p(x.Verbose, c, u);
|
|
997
997
|
}, e.log = (c, ...u) => {
|
|
998
|
-
|
|
998
|
+
p(x.Log, c, u);
|
|
999
999
|
}, e.warn = (c, ...u) => {
|
|
1000
|
-
|
|
1000
|
+
p(x.Warning, c, u);
|
|
1001
1001
|
}, e.error = (c, u, ...m) => {
|
|
1002
1002
|
const v = t();
|
|
1003
1003
|
if (!Nn(v))
|
|
1004
1004
|
return;
|
|
1005
1005
|
const w = a(m), y = Ln(
|
|
1006
|
-
|
|
1006
|
+
x.Error,
|
|
1007
1007
|
e.context,
|
|
1008
1008
|
w,
|
|
1009
1009
|
c,
|
|
@@ -1038,12 +1038,12 @@ function Hn() {
|
|
|
1038
1038
|
Q.length > 0 && Gn(), h.log("[CLS] Cleaned up");
|
|
1039
1039
|
}
|
|
1040
1040
|
Vn(k.Warning);
|
|
1041
|
-
const h = Wn("Web").withErrorProcessor((r) => r).useGlobalConfig(),
|
|
1041
|
+
const h = Wn("Web").withErrorProcessor((r) => r).useGlobalConfig(), O = {
|
|
1042
1042
|
config: null,
|
|
1043
1043
|
promise: null
|
|
1044
1044
|
};
|
|
1045
1045
|
async function Kn(r) {
|
|
1046
|
-
return
|
|
1046
|
+
return O.promise ? (await O.promise, O.config || {}) : O.config ? O.config : (O.promise = (async () => {
|
|
1047
1047
|
try {
|
|
1048
1048
|
const t = typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") ? `/api/config/sdk?version=${r}` : `https://config.spatialwalk.top/sdk?version=${r}`;
|
|
1049
1049
|
h.log(`[SdkConfigLoader] Fetching SDK config from: ${t}`);
|
|
@@ -1059,16 +1059,16 @@ async function Kn(r) {
|
|
|
1059
1059
|
if (!i.endpoints)
|
|
1060
1060
|
throw new Error("Invalid config response: missing endpoints");
|
|
1061
1061
|
const a = {};
|
|
1062
|
-
i.endpoints.cn && (a[le.cn] = `https://${i.endpoints.cn}`), i.endpoints.us && (a[le.us] = `https://${i.endpoints.us}`), i.endpoints.test && (a[le.test] = `https://${i.endpoints.test}`),
|
|
1062
|
+
i.endpoints.cn && (a[le.cn] = `https://${i.endpoints.cn}`), i.endpoints.us && (a[le.us] = `https://${i.endpoints.us}`), i.endpoints.test && (a[le.test] = `https://${i.endpoints.test}`), O.config = a, h.log("[SdkConfigLoader] SDK config fetched successfully:", a);
|
|
1063
1063
|
} catch {
|
|
1064
|
-
|
|
1064
|
+
O.config = {};
|
|
1065
1065
|
} finally {
|
|
1066
|
-
|
|
1066
|
+
O.promise = null;
|
|
1067
1067
|
}
|
|
1068
|
-
})(), await
|
|
1068
|
+
})(), await O.promise, O.config || {});
|
|
1069
1069
|
}
|
|
1070
1070
|
function Jn() {
|
|
1071
|
-
|
|
1071
|
+
O.config = null, O.promise = null;
|
|
1072
1072
|
}
|
|
1073
1073
|
class Zn {
|
|
1074
1074
|
constructor(e) {
|
|
@@ -1102,9 +1102,9 @@ class Zn {
|
|
|
1102
1102
|
throw new Error("teethPb is missing or empty!");
|
|
1103
1103
|
if (!e.teethNpz || e.teethNpz.byteLength === 0)
|
|
1104
1104
|
throw new Error("teethNpz is missing or empty!");
|
|
1105
|
-
const i = this.allocateAndCopy(e.flameModel), a = this.allocateAndCopy(e.flameTemplate), o = this.allocateAndCopy(e.teethPb),
|
|
1106
|
-
let
|
|
1107
|
-
return this.module.setValue(n +
|
|
1105
|
+
const i = this.allocateAndCopy(e.flameModel), a = this.allocateAndCopy(e.flameTemplate), o = this.allocateAndCopy(e.teethPb), l = this.allocateAndCopy(e.teethNpz);
|
|
1106
|
+
let s = 0;
|
|
1107
|
+
return this.module.setValue(n + s, i.ptr, "i32"), s += 4, this.module.setValue(n + s, i.size, "i32"), s += 4, this.module.setValue(n + s, a.ptr, "i32"), s += 4, this.module.setValue(n + s, a.size, "i32"), s += 4, this.module.setValue(n + s, o.ptr, "i32"), s += 4, this.module.setValue(n + s, o.size, "i32"), s += 4, this.module.setValue(n + s, l.ptr, "i32"), s += 4, this.module.setValue(n + s, l.size, "i32"), s += 4, this.module.setValue(n + s, 0, "i32"), s += 4, this.module.setValue(n + s, 0, "i32"), s += 4, this.structPointers.set("template_config", n), n;
|
|
1108
1108
|
}
|
|
1109
1109
|
/**
|
|
1110
1110
|
* 创建 AvatarCharacterData 结构体 - 新版 Emscripten 方式
|
|
@@ -1114,8 +1114,8 @@ class Zn {
|
|
|
1114
1114
|
if (!i)
|
|
1115
1115
|
throw new Error("Failed to allocate AvatarCharacterData structure");
|
|
1116
1116
|
const a = this.allocateAndCopy(e), o = this.allocateAndCopy(t);
|
|
1117
|
-
let
|
|
1118
|
-
return this.module.setValue(i +
|
|
1117
|
+
let l = 0;
|
|
1118
|
+
return this.module.setValue(i + l, a.ptr, "i32"), l += 4, this.module.setValue(i + l, a.size, "i32"), l += 4, this.module.setValue(i + l, o.ptr, "i32"), l += 4, this.module.setValue(i + l, o.size, "i32"), l += 4, this.structPointers.set("character_data", i), i;
|
|
1119
1119
|
}
|
|
1120
1120
|
/**
|
|
1121
1121
|
* 读取 AvatarFlameParams 结构体数据
|
|
@@ -1135,15 +1135,15 @@ class Zn {
|
|
|
1135
1135
|
const o = [];
|
|
1136
1136
|
for (let m = 0; m < 3; m++)
|
|
1137
1137
|
o.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1138
|
-
const s = [];
|
|
1139
|
-
for (let m = 0; m < 3; m++)
|
|
1140
|
-
s.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1141
1138
|
const l = [];
|
|
1142
1139
|
for (let m = 0; m < 3; m++)
|
|
1143
1140
|
l.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1144
|
-
const
|
|
1141
|
+
const s = [];
|
|
1142
|
+
for (let m = 0; m < 3; m++)
|
|
1143
|
+
s.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1144
|
+
const p = [];
|
|
1145
1145
|
for (let m = 0; m < 6; m++)
|
|
1146
|
-
|
|
1146
|
+
p.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1147
1147
|
const c = [];
|
|
1148
1148
|
for (let m = 0; m < 2; m++)
|
|
1149
1149
|
c.push(this.module.getValue(e + t, "float")), t += 4;
|
|
@@ -1153,9 +1153,9 @@ class Zn {
|
|
|
1153
1153
|
expr_params: i,
|
|
1154
1154
|
rotation: a,
|
|
1155
1155
|
translation: o,
|
|
1156
|
-
neck_pose:
|
|
1157
|
-
jaw_pose:
|
|
1158
|
-
eyes_pose:
|
|
1156
|
+
neck_pose: l,
|
|
1157
|
+
jaw_pose: s,
|
|
1158
|
+
eyes_pose: p,
|
|
1159
1159
|
eyelid: c,
|
|
1160
1160
|
has_eyelid: u
|
|
1161
1161
|
};
|
|
@@ -1164,7 +1164,7 @@ class Zn {
|
|
|
1164
1164
|
* 创建 AvatarFlameParams 结构体 - 新版 Emscripten 方式
|
|
1165
1165
|
*/
|
|
1166
1166
|
createFlameParams(e) {
|
|
1167
|
-
var a, o,
|
|
1167
|
+
var a, o, l, s, p, c, u, m;
|
|
1168
1168
|
const n = this.module._malloc(1684);
|
|
1169
1169
|
if (!n)
|
|
1170
1170
|
throw new Error("Failed to allocate AvatarFlameParams structure");
|
|
@@ -1178,15 +1178,15 @@ class Zn {
|
|
|
1178
1178
|
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1179
1179
|
}
|
|
1180
1180
|
for (let v = 0; v < 3; v++) {
|
|
1181
|
-
const w = ((
|
|
1181
|
+
const w = ((l = e.rotation) == null ? void 0 : l[v]) || 0;
|
|
1182
1182
|
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1183
1183
|
}
|
|
1184
1184
|
for (let v = 0; v < 3; v++) {
|
|
1185
|
-
const w = ((
|
|
1185
|
+
const w = ((s = e.translation) == null ? void 0 : s[v]) || 0;
|
|
1186
1186
|
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1187
1187
|
}
|
|
1188
1188
|
for (let v = 0; v < 3; v++) {
|
|
1189
|
-
const w = ((
|
|
1189
|
+
const w = ((p = e.neck_pose) == null ? void 0 : p[v]) || 0;
|
|
1190
1190
|
this.module.setValue(n + i, w, "float"), i += 4;
|
|
1191
1191
|
}
|
|
1192
1192
|
for (let v = 0; v < 3; v++) {
|
|
@@ -1224,34 +1224,34 @@ class Zn {
|
|
|
1224
1224
|
const t = this.module.getValue(e, "i32"), n = this.module.getValue(e + 4, "i32");
|
|
1225
1225
|
if (n === 0 || !t)
|
|
1226
1226
|
return null;
|
|
1227
|
-
const a = n * 13, o = t / 4,
|
|
1228
|
-
return
|
|
1227
|
+
const a = n * 13, o = t / 4, l = new Float32Array(a);
|
|
1228
|
+
return l.set(this.module.HEAPF32.subarray(o, o + a)), l;
|
|
1229
1229
|
}
|
|
1230
1230
|
/**
|
|
1231
1231
|
* 读取AvatarMeshData结构体数据
|
|
1232
1232
|
*/
|
|
1233
1233
|
readMeshData(e) {
|
|
1234
|
-
const t = this.module.getValue(e + 0, "*"), n = this.module.getValue(e + 4, "i32"), i = this.module.getValue(e + 8, "*"), a = this.module.getValue(e + 12, "i32"), o = this.module.getValue(e + 16, "float"),
|
|
1234
|
+
const t = this.module.getValue(e + 0, "*"), n = this.module.getValue(e + 4, "i32"), i = this.module.getValue(e + 8, "*"), a = this.module.getValue(e + 12, "i32"), o = this.module.getValue(e + 16, "float"), l = this.module.getValue(e + 20, "*"), s = this.module.getValue(e + 24, "i32"), p = new Float32Array(n * 3);
|
|
1235
1235
|
if (t && n > 0)
|
|
1236
1236
|
for (let m = 0; m < n * 3; m++)
|
|
1237
|
-
|
|
1237
|
+
p[m] = this.module.getValue(t + m * 4, "float");
|
|
1238
1238
|
const c = new Uint32Array(a * 3);
|
|
1239
1239
|
if (i && a > 0)
|
|
1240
1240
|
for (let m = 0; m < a * 3; m++)
|
|
1241
1241
|
c[m] = this.module.getValue(i + m * 4, "i32");
|
|
1242
1242
|
let u = null;
|
|
1243
|
-
if (
|
|
1244
|
-
u = new Float32Array(
|
|
1245
|
-
for (let m = 0; m <
|
|
1246
|
-
u[m] = this.module.getValue(
|
|
1243
|
+
if (l && s > 0) {
|
|
1244
|
+
u = new Float32Array(s * 3);
|
|
1245
|
+
for (let m = 0; m < s * 3; m++)
|
|
1246
|
+
u[m] = this.module.getValue(l + m * 4, "float");
|
|
1247
1247
|
}
|
|
1248
1248
|
return {
|
|
1249
|
-
vertices:
|
|
1249
|
+
vertices: p,
|
|
1250
1250
|
vertexCount: n,
|
|
1251
1251
|
faces: c,
|
|
1252
1252
|
faceCount: a,
|
|
1253
1253
|
landmarks: u,
|
|
1254
|
-
landmarkCount:
|
|
1254
|
+
landmarkCount: s,
|
|
1255
1255
|
computeTime: o
|
|
1256
1256
|
};
|
|
1257
1257
|
}
|
|
@@ -1290,7 +1290,7 @@ class Zn {
|
|
|
1290
1290
|
};
|
|
1291
1291
|
}
|
|
1292
1292
|
}
|
|
1293
|
-
class
|
|
1293
|
+
class Xn {
|
|
1294
1294
|
constructor(e = {}) {
|
|
1295
1295
|
// 配置
|
|
1296
1296
|
d(this, "options");
|
|
@@ -1359,7 +1359,7 @@ class Yn {
|
|
|
1359
1359
|
*/
|
|
1360
1360
|
async loadWASMModule() {
|
|
1361
1361
|
try {
|
|
1362
|
-
const { default: e } = await import("./avatar_core_wasm-
|
|
1362
|
+
const { default: e } = await import("./avatar_core_wasm-D-1WNg4B.js");
|
|
1363
1363
|
this.wasmConfig && Object.keys(this.wasmConfig).length > 0 ? this.wasmModule = await e(this.wasmConfig) : this.wasmModule = await e(), this.validateWASMModule(), this.memoryManager = new Zn(this.wasmModule), this.setupCAPIFunctions(), h.log("✅ Created new WASM instance with clean C++ memory");
|
|
1364
1364
|
} catch (e) {
|
|
1365
1365
|
const t = e instanceof Error ? e.message : String(e);
|
|
@@ -1642,8 +1642,8 @@ class Yn {
|
|
|
1642
1642
|
n
|
|
1643
1643
|
);
|
|
1644
1644
|
this.checkError(i, "avatar_core_get_flame_info");
|
|
1645
|
-
const a = this.wasmModule.getValue(e, "i32"), o = this.wasmModule.getValue(t, "i32"),
|
|
1646
|
-
this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: a, faceCount: o, jointCount:
|
|
1645
|
+
const a = this.wasmModule.getValue(e, "i32"), o = this.wasmModule.getValue(t, "i32"), l = this.wasmModule.getValue(n, "i32");
|
|
1646
|
+
this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: a, faceCount: o, jointCount: l };
|
|
1647
1647
|
} catch (e) {
|
|
1648
1648
|
const t = e instanceof Error ? e.message : String(e);
|
|
1649
1649
|
h.errorWithError("❌ Failed to query FLAME info:", t);
|
|
@@ -1750,8 +1750,8 @@ class Yn {
|
|
|
1750
1750
|
n
|
|
1751
1751
|
);
|
|
1752
1752
|
this.checkError(o, "avatar_core_compute_frame_as_splat_points_flat");
|
|
1753
|
-
const
|
|
1754
|
-
return this.wasmTime =
|
|
1753
|
+
const l = this.memoryManager.readSplatPointFlatArray(n), s = performance.now() - t;
|
|
1754
|
+
return this.wasmTime = s, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += s, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, l;
|
|
1755
1755
|
} catch (a) {
|
|
1756
1756
|
h.errorWithError("❌ computeCompleteFrameFlat failed:", a);
|
|
1757
1757
|
const o = a instanceof Error ? a.message : String(a);
|
|
@@ -1778,8 +1778,8 @@ class Yn {
|
|
|
1778
1778
|
n
|
|
1779
1779
|
);
|
|
1780
1780
|
this.checkError(a, "avatar_core_compute_frame_as_splat_points_flat");
|
|
1781
|
-
const o = this.memoryManager.readSplatPointFlatArray(n),
|
|
1782
|
-
return this.wasmTime =
|
|
1781
|
+
const o = this.memoryManager.readSplatPointFlatArray(n), l = performance.now() - t;
|
|
1782
|
+
return this.wasmTime = l, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += l, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, o;
|
|
1783
1783
|
} catch (a) {
|
|
1784
1784
|
h.errorWithError("❌ computeFrameFlatFromParams failed:", a);
|
|
1785
1785
|
const o = a instanceof Error ? a.message : String(a);
|
|
@@ -1789,7 +1789,7 @@ class Yn {
|
|
|
1789
1789
|
}
|
|
1790
1790
|
}
|
|
1791
1791
|
}
|
|
1792
|
-
class
|
|
1792
|
+
class S {
|
|
1793
1793
|
/**
|
|
1794
1794
|
* SDK 初始化
|
|
1795
1795
|
* @param appId 前端需要在 HTTP Headers 和 WebSocket Headers 中都带上
|
|
@@ -1819,7 +1819,7 @@ class b {
|
|
|
1819
1819
|
*/
|
|
1820
1820
|
static async initializeWASMModule() {
|
|
1821
1821
|
try {
|
|
1822
|
-
h.log("[AvatarKit] Initializing WASM module..."), this._avatarCore = new
|
|
1822
|
+
h.log("[AvatarKit] Initializing WASM module..."), this._avatarCore = new Xn({
|
|
1823
1823
|
logLevel: "basic",
|
|
1824
1824
|
enableValidation: !0,
|
|
1825
1825
|
enablePerformanceMetrics: !0,
|
|
@@ -1953,7 +1953,7 @@ class b {
|
|
|
1953
1953
|
h[a](`[Telemetry] ${e}`, i);
|
|
1954
1954
|
}
|
|
1955
1955
|
}
|
|
1956
|
-
d(
|
|
1956
|
+
d(S, "_isInitialized", !1), d(S, "_appId", null), d(S, "_configuration", null), d(S, "_sessionToken", null), d(S, "_userId", null), d(S, "_version", "1.0.0-beta.15"), d(S, "_avatarCore", null), d(S, "_dynamicSdkConfig", null), d(S, "_logLevels", {
|
|
1957
1957
|
debug: "log",
|
|
1958
1958
|
info: "log",
|
|
1959
1959
|
warning: "warn",
|
|
@@ -2022,7 +2022,7 @@ const Ce = class Ce {
|
|
|
2022
2022
|
async createAndInitializeStreamingPlayer() {
|
|
2023
2023
|
if (this.streamingPlayer)
|
|
2024
2024
|
return;
|
|
2025
|
-
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-
|
|
2025
|
+
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-Dj1w6HZz.js");
|
|
2026
2026
|
this.streamingPlayer = new e({
|
|
2027
2027
|
sampleRate: M.audio.sampleRate,
|
|
2028
2028
|
channelCount: 1,
|
|
@@ -2032,7 +2032,7 @@ const Ce = class Ce {
|
|
|
2032
2032
|
await this.streamingPlayer.initialize();
|
|
2033
2033
|
} catch (t) {
|
|
2034
2034
|
const n = t instanceof Error ? t.message : String(t);
|
|
2035
|
-
throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n),
|
|
2035
|
+
throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n), S.logEvent("character_player", "error", {
|
|
2036
2036
|
event: "streaming_player_initialize_failed",
|
|
2037
2037
|
reason: n
|
|
2038
2038
|
}), t;
|
|
@@ -2093,13 +2093,27 @@ const Ce = class Ce {
|
|
|
2093
2093
|
addAudioChunk(e, t = !1) {
|
|
2094
2094
|
this.useStreaming && this.streamingPlayer ? this.streamingPlayer.addChunk(e, t) : h.warn("[AnimationPlayer] Cannot add audio chunk - streaming player not ready");
|
|
2095
2095
|
}
|
|
2096
|
+
/**
|
|
2097
|
+
* 暂停播放
|
|
2098
|
+
*/
|
|
2099
|
+
pause() {
|
|
2100
|
+
var e;
|
|
2101
|
+
this.useStreaming ? (e = this.streamingPlayer) == null || e.pause() : this.audio && this.audio.pause();
|
|
2102
|
+
}
|
|
2103
|
+
/**
|
|
2104
|
+
* 继续播放
|
|
2105
|
+
*/
|
|
2106
|
+
async resume() {
|
|
2107
|
+
var e;
|
|
2108
|
+
this.useStreaming ? await ((e = this.streamingPlayer) == null ? void 0 : e.resume()) : this.audio && await this.audio.play();
|
|
2109
|
+
}
|
|
2096
2110
|
dispose() {
|
|
2097
2111
|
this.stop(), this.audio && (this.audio.src = "", this.audio = null), this.streamingPlayer && (this.streamingPlayer.dispose(), this.streamingPlayer = null), this.onEndedCallback = void 0;
|
|
2098
2112
|
}
|
|
2099
2113
|
};
|
|
2100
2114
|
d(Ce, "audioUnlocked", !1);
|
|
2101
2115
|
let be = Ce;
|
|
2102
|
-
function
|
|
2116
|
+
function Yn() {
|
|
2103
2117
|
let r = 0, e = 0;
|
|
2104
2118
|
for (let n = 0; n < 28; n += 7) {
|
|
2105
2119
|
let i = this.buf[this.pos++];
|
|
@@ -2118,29 +2132,29 @@ function Xn() {
|
|
|
2118
2132
|
}
|
|
2119
2133
|
function Ue(r, e, t) {
|
|
2120
2134
|
for (let a = 0; a < 28; a = a + 7) {
|
|
2121
|
-
const o = r >>> a,
|
|
2122
|
-
if (t.push(
|
|
2135
|
+
const o = r >>> a, l = !(!(o >>> 7) && e == 0), s = (l ? o | 128 : o) & 255;
|
|
2136
|
+
if (t.push(s), !l)
|
|
2123
2137
|
return;
|
|
2124
2138
|
}
|
|
2125
2139
|
const n = r >>> 28 & 15 | (e & 7) << 4, i = !!(e >> 3);
|
|
2126
2140
|
if (t.push((i ? n | 128 : n) & 255), !!i) {
|
|
2127
2141
|
for (let a = 3; a < 31; a = a + 7) {
|
|
2128
|
-
const o = e >>> a,
|
|
2129
|
-
if (t.push(
|
|
2142
|
+
const o = e >>> a, l = !!(o >>> 7), s = (l ? o | 128 : o) & 255;
|
|
2143
|
+
if (t.push(s), !l)
|
|
2130
2144
|
return;
|
|
2131
2145
|
}
|
|
2132
2146
|
t.push(e >>> 31 & 1);
|
|
2133
2147
|
}
|
|
2134
2148
|
}
|
|
2135
|
-
const
|
|
2149
|
+
const xe = 4294967296;
|
|
2136
2150
|
function St(r) {
|
|
2137
2151
|
const e = r[0] === "-";
|
|
2138
2152
|
e && (r = r.slice(1));
|
|
2139
2153
|
const t = 1e6;
|
|
2140
2154
|
let n = 0, i = 0;
|
|
2141
|
-
function a(o,
|
|
2142
|
-
const
|
|
2143
|
-
i *= t, n = n * t +
|
|
2155
|
+
function a(o, l) {
|
|
2156
|
+
const s = Number(r.slice(o, l));
|
|
2157
|
+
i *= t, n = n * t + s, n >= xe && (i = i + (n / xe | 0), n = n % xe);
|
|
2144
2158
|
}
|
|
2145
2159
|
return a(-24, -18), a(-18, -12), a(-12, -6), a(-6), e ? tr(n, i) : Ze(n, i);
|
|
2146
2160
|
}
|
|
@@ -2153,11 +2167,11 @@ function Qn(r, e) {
|
|
|
2153
2167
|
}
|
|
2154
2168
|
function er(r, e) {
|
|
2155
2169
|
if ({ lo: r, hi: e } = ei(r, e), e <= 2097151)
|
|
2156
|
-
return String(
|
|
2170
|
+
return String(xe * e + r);
|
|
2157
2171
|
const t = r & 16777215, n = (r >>> 24 | e << 8) & 16777215, i = e >> 16 & 65535;
|
|
2158
|
-
let a = t + n * 6777216 + i * 6710656, o = n + i * 8147497,
|
|
2159
|
-
const
|
|
2160
|
-
return a >=
|
|
2172
|
+
let a = t + n * 6777216 + i * 6710656, o = n + i * 8147497, l = i * 2;
|
|
2173
|
+
const s = 1e7;
|
|
2174
|
+
return a >= s && (o += Math.floor(a / s), a %= s), o >= s && (l += Math.floor(o / s), o %= s), l.toString() + bt(o) + bt(a);
|
|
2161
2175
|
}
|
|
2162
2176
|
function ei(r, e) {
|
|
2163
2177
|
return { lo: r >>> 0, hi: e >>> 0 };
|
|
@@ -2200,7 +2214,7 @@ function ti() {
|
|
|
2200
2214
|
throw new Error("invalid varint");
|
|
2201
2215
|
return this.assertBounds(), e >>> 0;
|
|
2202
2216
|
}
|
|
2203
|
-
const
|
|
2217
|
+
const K = /* @__PURE__ */ ri();
|
|
2204
2218
|
function ri() {
|
|
2205
2219
|
const r = new DataView(new ArrayBuffer(8));
|
|
2206
2220
|
if (typeof BigInt == "function" && typeof r.getBigInt64 == "function" && typeof r.getBigUint64 == "function" && typeof r.setBigInt64 == "function" && typeof r.setBigUint64 == "function" && (!!globalThis.Deno || typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1")) {
|
|
@@ -2209,16 +2223,16 @@ function ri() {
|
|
|
2209
2223
|
zero: BigInt(0),
|
|
2210
2224
|
supported: !0,
|
|
2211
2225
|
parse(o) {
|
|
2212
|
-
const
|
|
2213
|
-
if (
|
|
2226
|
+
const l = typeof o == "bigint" ? o : BigInt(o);
|
|
2227
|
+
if (l > n || l < t)
|
|
2214
2228
|
throw new Error(`invalid int64: ${o}`);
|
|
2215
|
-
return
|
|
2229
|
+
return l;
|
|
2216
2230
|
},
|
|
2217
2231
|
uParse(o) {
|
|
2218
|
-
const
|
|
2219
|
-
if (
|
|
2232
|
+
const l = typeof o == "bigint" ? o : BigInt(o);
|
|
2233
|
+
if (l > a || l < i)
|
|
2220
2234
|
throw new Error(`invalid uint64: ${o}`);
|
|
2221
|
-
return
|
|
2235
|
+
return l;
|
|
2222
2236
|
},
|
|
2223
2237
|
enc(o) {
|
|
2224
2238
|
return r.setBigInt64(0, this.parse(o), !0), {
|
|
@@ -2232,11 +2246,11 @@ function ri() {
|
|
|
2232
2246
|
hi: r.getInt32(4, !0)
|
|
2233
2247
|
};
|
|
2234
2248
|
},
|
|
2235
|
-
dec(o,
|
|
2236
|
-
return r.setInt32(0, o, !0), r.setInt32(4,
|
|
2249
|
+
dec(o, l) {
|
|
2250
|
+
return r.setInt32(0, o, !0), r.setInt32(4, l, !0), r.getBigInt64(0, !0);
|
|
2237
2251
|
},
|
|
2238
|
-
uDec(o,
|
|
2239
|
-
return r.setInt32(0, o, !0), r.setInt32(4,
|
|
2252
|
+
uDec(o, l) {
|
|
2253
|
+
return r.setInt32(0, o, !0), r.setInt32(4, l, !0), r.getBigUint64(0, !0);
|
|
2240
2254
|
}
|
|
2241
2255
|
};
|
|
2242
2256
|
}
|
|
@@ -2354,7 +2368,7 @@ class ue {
|
|
|
2354
2368
|
* Write a `uint32` value, an unsigned 32 bit varint.
|
|
2355
2369
|
*/
|
|
2356
2370
|
uint32(e) {
|
|
2357
|
-
for (
|
|
2371
|
+
for (It(e); e > 127; )
|
|
2358
2372
|
this.buf.push(e & 127 | 128), e = e >>> 7;
|
|
2359
2373
|
return this.buf.push(e), this;
|
|
2360
2374
|
}
|
|
@@ -2402,7 +2416,7 @@ class ue {
|
|
|
2402
2416
|
* Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.
|
|
2403
2417
|
*/
|
|
2404
2418
|
fixed32(e) {
|
|
2405
|
-
|
|
2419
|
+
It(e);
|
|
2406
2420
|
let t = new Uint8Array(4);
|
|
2407
2421
|
return new DataView(t.buffer).setUint32(0, e, !0), this.raw(t);
|
|
2408
2422
|
}
|
|
@@ -2424,41 +2438,41 @@ class ue {
|
|
|
2424
2438
|
* Write a `fixed64` value, a signed, fixed-length 64-bit integer.
|
|
2425
2439
|
*/
|
|
2426
2440
|
sfixed64(e) {
|
|
2427
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), i =
|
|
2441
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), i = K.enc(e);
|
|
2428
2442
|
return n.setInt32(0, i.lo, !0), n.setInt32(4, i.hi, !0), this.raw(t);
|
|
2429
2443
|
}
|
|
2430
2444
|
/**
|
|
2431
2445
|
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
|
|
2432
2446
|
*/
|
|
2433
2447
|
fixed64(e) {
|
|
2434
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), i =
|
|
2448
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), i = K.uEnc(e);
|
|
2435
2449
|
return n.setInt32(0, i.lo, !0), n.setInt32(4, i.hi, !0), this.raw(t);
|
|
2436
2450
|
}
|
|
2437
2451
|
/**
|
|
2438
2452
|
* Write a `int64` value, a signed 64-bit varint.
|
|
2439
2453
|
*/
|
|
2440
2454
|
int64(e) {
|
|
2441
|
-
let t =
|
|
2455
|
+
let t = K.enc(e);
|
|
2442
2456
|
return Ue(t.lo, t.hi, this.buf), this;
|
|
2443
2457
|
}
|
|
2444
2458
|
/**
|
|
2445
2459
|
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
2446
2460
|
*/
|
|
2447
2461
|
sint64(e) {
|
|
2448
|
-
const t =
|
|
2462
|
+
const t = K.enc(e), n = t.hi >> 31, i = t.lo << 1 ^ n, a = (t.hi << 1 | t.lo >>> 31) ^ n;
|
|
2449
2463
|
return Ue(i, a, this.buf), this;
|
|
2450
2464
|
}
|
|
2451
2465
|
/**
|
|
2452
2466
|
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
2453
2467
|
*/
|
|
2454
2468
|
uint64(e) {
|
|
2455
|
-
const t =
|
|
2469
|
+
const t = K.uEnc(e);
|
|
2456
2470
|
return Ue(t.lo, t.hi, this.buf), this;
|
|
2457
2471
|
}
|
|
2458
2472
|
}
|
|
2459
|
-
class
|
|
2473
|
+
class N {
|
|
2460
2474
|
constructor(e, t = rr().decodeUtf8) {
|
|
2461
|
-
this.decodeUtf8 = t, this.varint64 =
|
|
2475
|
+
this.decodeUtf8 = t, this.varint64 = Yn, this.uint32 = ti, this.buf = e, this.len = e.length, this.pos = 0, this.view = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
2462
2476
|
}
|
|
2463
2477
|
/**
|
|
2464
2478
|
* Reads a tag - field number and wire type.
|
|
@@ -2531,20 +2545,20 @@ class O {
|
|
|
2531
2545
|
* Read a `int64` field, a signed 64-bit varint.
|
|
2532
2546
|
*/
|
|
2533
2547
|
int64() {
|
|
2534
|
-
return
|
|
2548
|
+
return K.dec(...this.varint64());
|
|
2535
2549
|
}
|
|
2536
2550
|
/**
|
|
2537
2551
|
* Read a `uint64` field, an unsigned 64-bit varint.
|
|
2538
2552
|
*/
|
|
2539
2553
|
uint64() {
|
|
2540
|
-
return
|
|
2554
|
+
return K.uDec(...this.varint64());
|
|
2541
2555
|
}
|
|
2542
2556
|
/**
|
|
2543
2557
|
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
|
2544
2558
|
*/
|
|
2545
2559
|
sint64() {
|
|
2546
2560
|
let [e, t] = this.varint64(), n = -(e & 1);
|
|
2547
|
-
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n,
|
|
2561
|
+
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n, K.dec(e, t);
|
|
2548
2562
|
}
|
|
2549
2563
|
/**
|
|
2550
2564
|
* Read a `bool` field, a variant.
|
|
@@ -2569,13 +2583,13 @@ class O {
|
|
|
2569
2583
|
* Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
|
|
2570
2584
|
*/
|
|
2571
2585
|
fixed64() {
|
|
2572
|
-
return
|
|
2586
|
+
return K.uDec(this.sfixed32(), this.sfixed32());
|
|
2573
2587
|
}
|
|
2574
2588
|
/**
|
|
2575
2589
|
* Read a `fixed64` field, a signed, fixed-length 64-bit integer.
|
|
2576
2590
|
*/
|
|
2577
2591
|
sfixed64() {
|
|
2578
|
-
return
|
|
2592
|
+
return K.dec(this.sfixed32(), this.sfixed32());
|
|
2579
2593
|
}
|
|
2580
2594
|
/**
|
|
2581
2595
|
* Read a `float` field, 32-bit floating point number.
|
|
@@ -2611,7 +2625,7 @@ function Ve(r) {
|
|
|
2611
2625
|
if (!Number.isInteger(r) || r > oi || r < si)
|
|
2612
2626
|
throw new Error("invalid int32: " + r);
|
|
2613
2627
|
}
|
|
2614
|
-
function
|
|
2628
|
+
function It(r) {
|
|
2615
2629
|
if (typeof r == "string")
|
|
2616
2630
|
r = Number(r);
|
|
2617
2631
|
else if (typeof r != "number")
|
|
@@ -2673,7 +2687,7 @@ const he = {
|
|
|
2673
2687
|
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.audio.length !== 0 && e.uint32(18).bytes(r.audio), r.end !== !1 && e.uint32(24).bool(r.end), e;
|
|
2674
2688
|
},
|
|
2675
2689
|
decode(r, e) {
|
|
2676
|
-
const t = r instanceof
|
|
2690
|
+
const t = r instanceof N ? r : new N(r);
|
|
2677
2691
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2678
2692
|
const i = Pt();
|
|
2679
2693
|
for (; t.pos < n; ) {
|
|
@@ -2706,9 +2720,9 @@ const he = {
|
|
|
2706
2720
|
},
|
|
2707
2721
|
fromJSON(r) {
|
|
2708
2722
|
return {
|
|
2709
|
-
reqId:
|
|
2710
|
-
audio:
|
|
2711
|
-
end:
|
|
2723
|
+
reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
2724
|
+
audio: $(r.audio) ? di(r.audio) : new Uint8Array(0),
|
|
2725
|
+
end: $(r.end) ? globalThis.Boolean(r.end) : !1
|
|
2712
2726
|
};
|
|
2713
2727
|
},
|
|
2714
2728
|
toJSON(r) {
|
|
@@ -2723,7 +2737,7 @@ const he = {
|
|
|
2723
2737
|
return e.reqId = r.reqId ?? "", e.audio = r.audio ?? new Uint8Array(0), e.end = r.end ?? !1, e;
|
|
2724
2738
|
}
|
|
2725
2739
|
};
|
|
2726
|
-
function
|
|
2740
|
+
function xt() {
|
|
2727
2741
|
return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
|
|
2728
2742
|
}
|
|
2729
2743
|
const fe = {
|
|
@@ -2752,9 +2766,9 @@ const fe = {
|
|
|
2752
2766
|
return e.join(), e;
|
|
2753
2767
|
},
|
|
2754
2768
|
decode(r, e) {
|
|
2755
|
-
const t = r instanceof
|
|
2769
|
+
const t = r instanceof N ? r : new N(r);
|
|
2756
2770
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2757
|
-
const i =
|
|
2771
|
+
const i = xt();
|
|
2758
2772
|
for (; t.pos < n; ) {
|
|
2759
2773
|
const a = t.uint32();
|
|
2760
2774
|
switch (a >>> 3) {
|
|
@@ -2868,17 +2882,17 @@ const fe = {
|
|
|
2868
2882
|
};
|
|
2869
2883
|
},
|
|
2870
2884
|
toJSON(r) {
|
|
2871
|
-
var t, n, i, a, o,
|
|
2885
|
+
var t, n, i, a, o, l, s;
|
|
2872
2886
|
const e = {};
|
|
2873
|
-
return (t = r.translation) != null && t.length && (e.translation = r.translation), (n = r.rotation) != null && n.length && (e.rotation = r.rotation), (i = r.neckPose) != null && i.length && (e.neckPose = r.neckPose), (a = r.jawPose) != null && a.length && (e.jawPose = r.jawPose), (o = r.eyePose) != null && o.length && (e.eyePose = r.eyePose), (
|
|
2887
|
+
return (t = r.translation) != null && t.length && (e.translation = r.translation), (n = r.rotation) != null && n.length && (e.rotation = r.rotation), (i = r.neckPose) != null && i.length && (e.neckPose = r.neckPose), (a = r.jawPose) != null && a.length && (e.jawPose = r.jawPose), (o = r.eyePose) != null && o.length && (e.eyePose = r.eyePose), (l = r.eyeLid) != null && l.length && (e.eyeLid = r.eyeLid), (s = r.expression) != null && s.length && (e.expression = r.expression), e;
|
|
2874
2888
|
},
|
|
2875
2889
|
create(r) {
|
|
2876
2890
|
return fe.fromPartial(r ?? {});
|
|
2877
2891
|
},
|
|
2878
2892
|
fromPartial(r) {
|
|
2879
|
-
var t, n, i, a, o,
|
|
2880
|
-
const e =
|
|
2881
|
-
return e.translation = ((t = r.translation) == null ? void 0 : t.map((
|
|
2893
|
+
var t, n, i, a, o, l, s;
|
|
2894
|
+
const e = xt();
|
|
2895
|
+
return e.translation = ((t = r.translation) == null ? void 0 : t.map((p) => p)) || [], e.rotation = ((n = r.rotation) == null ? void 0 : n.map((p) => p)) || [], e.neckPose = ((i = r.neckPose) == null ? void 0 : i.map((p) => p)) || [], e.jawPose = ((a = r.jawPose) == null ? void 0 : a.map((p) => p)) || [], e.eyePose = ((o = r.eyePose) == null ? void 0 : o.map((p) => p)) || [], e.eyeLid = ((l = r.eyeLid) == null ? void 0 : l.map((p) => p)) || [], e.expression = ((s = r.expression) == null ? void 0 : s.map((p) => p)) || [], e;
|
|
2882
2896
|
}
|
|
2883
2897
|
};
|
|
2884
2898
|
function kt() {
|
|
@@ -2891,7 +2905,7 @@ const me = {
|
|
|
2891
2905
|
return e;
|
|
2892
2906
|
},
|
|
2893
2907
|
decode(r, e) {
|
|
2894
|
-
const t = r instanceof
|
|
2908
|
+
const t = r instanceof N ? r : new N(r);
|
|
2895
2909
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2896
2910
|
const i = kt();
|
|
2897
2911
|
for (; t.pos < n; ) {
|
|
@@ -2932,12 +2946,12 @@ const me = {
|
|
|
2932
2946
|
function Mt() {
|
|
2933
2947
|
return { reqId: "", animation: void 0 };
|
|
2934
2948
|
}
|
|
2935
|
-
const
|
|
2949
|
+
const pe = {
|
|
2936
2950
|
encode(r, e = new ue()) {
|
|
2937
2951
|
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && me.encode(r.animation, e.uint32(18).fork()).join(), e;
|
|
2938
2952
|
},
|
|
2939
2953
|
decode(r, e) {
|
|
2940
|
-
const t = r instanceof
|
|
2954
|
+
const t = r instanceof N ? r : new N(r);
|
|
2941
2955
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2942
2956
|
const i = Mt();
|
|
2943
2957
|
for (; t.pos < n; ) {
|
|
@@ -2964,8 +2978,8 @@ const ge = {
|
|
|
2964
2978
|
},
|
|
2965
2979
|
fromJSON(r) {
|
|
2966
2980
|
return {
|
|
2967
|
-
reqId:
|
|
2968
|
-
animation:
|
|
2981
|
+
reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
2982
|
+
animation: $(r.animation) ? me.fromJSON(r.animation) : void 0
|
|
2969
2983
|
};
|
|
2970
2984
|
},
|
|
2971
2985
|
toJSON(r) {
|
|
@@ -2973,7 +2987,7 @@ const ge = {
|
|
|
2973
2987
|
return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation = me.toJSON(r.animation)), e;
|
|
2974
2988
|
},
|
|
2975
2989
|
create(r) {
|
|
2976
|
-
return
|
|
2990
|
+
return pe.fromPartial(r ?? {});
|
|
2977
2991
|
},
|
|
2978
2992
|
fromPartial(r) {
|
|
2979
2993
|
const e = Mt();
|
|
@@ -2983,12 +2997,12 @@ const ge = {
|
|
|
2983
2997
|
function Ft() {
|
|
2984
2998
|
return { reqId: "", code: 0, reason: "" };
|
|
2985
2999
|
}
|
|
2986
|
-
const
|
|
3000
|
+
const ge = {
|
|
2987
3001
|
encode(r, e = new ue()) {
|
|
2988
3002
|
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.code !== 0 && e.uint32(16).int32(r.code), r.reason !== "" && e.uint32(26).string(r.reason), e;
|
|
2989
3003
|
},
|
|
2990
3004
|
decode(r, e) {
|
|
2991
|
-
const t = r instanceof
|
|
3005
|
+
const t = r instanceof N ? r : new N(r);
|
|
2992
3006
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2993
3007
|
const i = Ft();
|
|
2994
3008
|
for (; t.pos < n; ) {
|
|
@@ -3021,9 +3035,9 @@ const pe = {
|
|
|
3021
3035
|
},
|
|
3022
3036
|
fromJSON(r) {
|
|
3023
3037
|
return {
|
|
3024
|
-
reqId:
|
|
3025
|
-
code:
|
|
3026
|
-
reason:
|
|
3038
|
+
reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
3039
|
+
code: $(r.code) ? globalThis.Number(r.code) : 0,
|
|
3040
|
+
reason: $(r.reason) ? globalThis.String(r.reason) : ""
|
|
3027
3041
|
};
|
|
3028
3042
|
},
|
|
3029
3043
|
toJSON(r) {
|
|
@@ -3031,7 +3045,7 @@ const pe = {
|
|
|
3031
3045
|
return r.reqId !== "" && (e.reqId = r.reqId), r.code !== 0 && (e.code = Math.round(r.code)), r.reason !== "" && (e.reason = r.reason), e;
|
|
3032
3046
|
},
|
|
3033
3047
|
create(r) {
|
|
3034
|
-
return
|
|
3048
|
+
return ge.fromPartial(r ?? {});
|
|
3035
3049
|
},
|
|
3036
3050
|
fromPartial(r) {
|
|
3037
3051
|
const e = Ft();
|
|
@@ -3043,10 +3057,10 @@ function Rt() {
|
|
|
3043
3057
|
}
|
|
3044
3058
|
const He = {
|
|
3045
3059
|
encode(r, e = new ue()) {
|
|
3046
|
-
return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 &&
|
|
3060
|
+
return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 && ge.encode(r.error, e.uint32(18).fork()).join(), r.serverResponseAnimation !== void 0 && pe.encode(r.serverResponseAnimation, e.uint32(26).fork()).join(), r.clientAudioInput !== void 0 && he.encode(r.clientAudioInput, e.uint32(34).fork()).join(), e;
|
|
3047
3061
|
},
|
|
3048
3062
|
decode(r, e) {
|
|
3049
|
-
const t = r instanceof
|
|
3063
|
+
const t = r instanceof N ? r : new N(r);
|
|
3050
3064
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
3051
3065
|
const i = Rt();
|
|
3052
3066
|
for (; t.pos < n; ) {
|
|
@@ -3061,13 +3075,13 @@ const He = {
|
|
|
3061
3075
|
case 2: {
|
|
3062
3076
|
if (a !== 18)
|
|
3063
3077
|
break;
|
|
3064
|
-
i.error =
|
|
3078
|
+
i.error = ge.decode(t, t.uint32());
|
|
3065
3079
|
continue;
|
|
3066
3080
|
}
|
|
3067
3081
|
case 3: {
|
|
3068
3082
|
if (a !== 26)
|
|
3069
3083
|
break;
|
|
3070
|
-
i.serverResponseAnimation =
|
|
3084
|
+
i.serverResponseAnimation = pe.decode(t, t.uint32());
|
|
3071
3085
|
continue;
|
|
3072
3086
|
}
|
|
3073
3087
|
case 4: {
|
|
@@ -3085,22 +3099,22 @@ const He = {
|
|
|
3085
3099
|
},
|
|
3086
3100
|
fromJSON(r) {
|
|
3087
3101
|
return {
|
|
3088
|
-
type:
|
|
3089
|
-
error:
|
|
3090
|
-
serverResponseAnimation:
|
|
3091
|
-
clientAudioInput:
|
|
3102
|
+
type: $(r.type) ? ci(r.type) : 0,
|
|
3103
|
+
error: $(r.error) ? ge.fromJSON(r.error) : void 0,
|
|
3104
|
+
serverResponseAnimation: $(r.serverResponseAnimation) ? pe.fromJSON(r.serverResponseAnimation) : void 0,
|
|
3105
|
+
clientAudioInput: $(r.clientAudioInput) ? he.fromJSON(r.clientAudioInput) : void 0
|
|
3092
3106
|
};
|
|
3093
3107
|
},
|
|
3094
3108
|
toJSON(r) {
|
|
3095
3109
|
const e = {};
|
|
3096
|
-
return r.type !== 0 && (e.type = ui(r.type)), r.error !== void 0 && (e.error =
|
|
3110
|
+
return r.type !== 0 && (e.type = ui(r.type)), r.error !== void 0 && (e.error = ge.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = pe.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = he.toJSON(r.clientAudioInput)), e;
|
|
3097
3111
|
},
|
|
3098
3112
|
create(r) {
|
|
3099
3113
|
return He.fromPartial(r ?? {});
|
|
3100
3114
|
},
|
|
3101
3115
|
fromPartial(r) {
|
|
3102
3116
|
const e = Rt();
|
|
3103
|
-
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ?
|
|
3117
|
+
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? ge.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? pe.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? he.fromPartial(r.clientAudioInput) : void 0, e;
|
|
3104
3118
|
}
|
|
3105
3119
|
};
|
|
3106
3120
|
function di(r) {
|
|
@@ -3115,7 +3129,7 @@ function hi(r) {
|
|
|
3115
3129
|
e.push(globalThis.String.fromCharCode(t));
|
|
3116
3130
|
}), globalThis.btoa(e.join(""));
|
|
3117
3131
|
}
|
|
3118
|
-
function
|
|
3132
|
+
function $(r) {
|
|
3119
3133
|
return r != null;
|
|
3120
3134
|
}
|
|
3121
3135
|
let fi = (r) => crypto.getRandomValues(new Uint8Array(r)), mi = (r, e, t) => {
|
|
@@ -3123,16 +3137,16 @@ let fi = (r) => crypto.getRandomValues(new Uint8Array(r)), mi = (r, e, t) => {
|
|
|
3123
3137
|
return (a = e) => {
|
|
3124
3138
|
let o = "";
|
|
3125
3139
|
for (; ; ) {
|
|
3126
|
-
let
|
|
3127
|
-
for (;
|
|
3128
|
-
if (o += r[s
|
|
3140
|
+
let l = t(i), s = i | 0;
|
|
3141
|
+
for (; s--; )
|
|
3142
|
+
if (o += r[l[s] & n] || "", o.length >= a) return o;
|
|
3129
3143
|
}
|
|
3130
3144
|
};
|
|
3131
|
-
},
|
|
3132
|
-
const
|
|
3145
|
+
}, pi = (r, e = 21) => mi(r, e | 0, fi);
|
|
3146
|
+
const gi = pi("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12);
|
|
3133
3147
|
function vi() {
|
|
3134
|
-
const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), i = String(r.getUTCHours()).padStart(2, "0"), a = String(r.getUTCMinutes()).padStart(2, "0"), o = String(r.getUTCSeconds()).padStart(2, "0"),
|
|
3135
|
-
return `${
|
|
3148
|
+
const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), i = String(r.getUTCHours()).padStart(2, "0"), a = String(r.getUTCMinutes()).padStart(2, "0"), o = String(r.getUTCSeconds()).padStart(2, "0"), l = `${e}${t}${n}${i}${a}${o}`, s = gi();
|
|
3149
|
+
return `${l}_${s}`;
|
|
3136
3150
|
}
|
|
3137
3151
|
class wi {
|
|
3138
3152
|
constructor() {
|
|
@@ -3161,13 +3175,14 @@ class yi extends wi {
|
|
|
3161
3175
|
d(this, "reconnectAttempts");
|
|
3162
3176
|
d(this, "debug");
|
|
3163
3177
|
d(this, "jwtToken");
|
|
3178
|
+
d(this, "appId");
|
|
3164
3179
|
d(this, "ws", null);
|
|
3165
3180
|
d(this, "currentCharacterId", "");
|
|
3166
3181
|
d(this, "currentRetryCount", 0);
|
|
3167
3182
|
d(this, "isConnecting", !1);
|
|
3168
3183
|
d(this, "isManuallyDisconnected", !1);
|
|
3169
3184
|
d(this, "reconnectTimer", null);
|
|
3170
|
-
this.wsUrl = t.wsUrl, this.reconnectAttempts = t.reconnectAttempts ?? 5, this.debug = t.debug ?? !1, this.jwtToken = t.jwtToken;
|
|
3185
|
+
this.wsUrl = t.wsUrl, this.reconnectAttempts = t.reconnectAttempts ?? 5, this.debug = t.debug ?? !1, this.jwtToken = t.jwtToken, this.appId = t.appId;
|
|
3171
3186
|
}
|
|
3172
3187
|
/**
|
|
3173
3188
|
* 连接WebSocket
|
|
@@ -3184,7 +3199,7 @@ class yi extends wi {
|
|
|
3184
3199
|
try {
|
|
3185
3200
|
this.isConnecting = !0, this.currentCharacterId = t;
|
|
3186
3201
|
const n = this.buildWebSocketUrl(t);
|
|
3187
|
-
h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"),
|
|
3202
|
+
h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"), S.logEvent("character_animation_service", "info", {
|
|
3188
3203
|
characterId: t,
|
|
3189
3204
|
event: "connect_success",
|
|
3190
3205
|
url: n
|
|
@@ -3192,7 +3207,7 @@ class yi extends wi {
|
|
|
3192
3207
|
} catch (n) {
|
|
3193
3208
|
this.isConnecting = !1;
|
|
3194
3209
|
const i = n instanceof Error ? n.message : String(n);
|
|
3195
|
-
throw h.error("[AnimationWebSocketClient] Connection failed:", i),
|
|
3210
|
+
throw h.error("[AnimationWebSocketClient] Connection failed:", i), S.logEvent("character_animation_service", "error", {
|
|
3196
3211
|
characterId: t,
|
|
3197
3212
|
event: "connect_failed",
|
|
3198
3213
|
reason: i
|
|
@@ -3221,11 +3236,11 @@ class yi extends wi {
|
|
|
3221
3236
|
}
|
|
3222
3237
|
}, o = new ue();
|
|
3223
3238
|
He.encode(a, o);
|
|
3224
|
-
const
|
|
3225
|
-
return this.ws.send(
|
|
3239
|
+
const l = o.finish();
|
|
3240
|
+
return this.ws.send(l), !0;
|
|
3226
3241
|
} catch (a) {
|
|
3227
3242
|
const o = a instanceof Error ? a.message : String(a);
|
|
3228
|
-
return h.error("[AnimationWebSocketClient] Failed to send audio data:", o),
|
|
3243
|
+
return h.error("[AnimationWebSocketClient] Failed to send audio data:", o), S.logEvent("character_animation_service", "warning", {
|
|
3229
3244
|
characterId: this.currentCharacterId,
|
|
3230
3245
|
event: "send_audio_failed",
|
|
3231
3246
|
reqId: t,
|
|
@@ -3255,7 +3270,7 @@ class yi extends wi {
|
|
|
3255
3270
|
// ========== 私有方法 ==========
|
|
3256
3271
|
buildWebSocketUrl(t) {
|
|
3257
3272
|
const n = new URL(this.wsUrl);
|
|
3258
|
-
return n.searchParams.set("id", t), this.jwtToken && n.searchParams.set("token", this.jwtToken), n.toString();
|
|
3273
|
+
return n.searchParams.set("id", t), this.jwtToken && n.searchParams.set("token", this.jwtToken), this.appId && n.searchParams.set("appId", this.appId), n.toString();
|
|
3259
3274
|
}
|
|
3260
3275
|
connectWebSocket(t) {
|
|
3261
3276
|
return new Promise((n, i) => {
|
|
@@ -3264,19 +3279,19 @@ class yi extends wi {
|
|
|
3264
3279
|
this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"), n();
|
|
3265
3280
|
}, this.ws.onmessage = (a) => {
|
|
3266
3281
|
a.data instanceof ArrayBuffer ? this.handleMessage(a.data) : a.data instanceof Blob ? a.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((o) => {
|
|
3267
|
-
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", o),
|
|
3282
|
+
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", o), S.logEvent("character_animation_service", "error", {
|
|
3268
3283
|
characterId: this.currentCharacterId,
|
|
3269
3284
|
event: "decode_blob_failed",
|
|
3270
3285
|
reason: o instanceof Error ? o.message : String(o)
|
|
3271
3286
|
}), this.emit("error", o);
|
|
3272
3287
|
}) : h.warn("[AnimationWebSocketClient] Received non-binary data:", typeof a.data);
|
|
3273
3288
|
}, this.ws.onerror = (a) => {
|
|
3274
|
-
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", a),
|
|
3289
|
+
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", a), S.logEvent("character_animation_service", "error", {
|
|
3275
3290
|
characterId: this.currentCharacterId,
|
|
3276
3291
|
event: "websocket_error"
|
|
3277
3292
|
}), this.emit("error", new Error("WebSocket error")), !this.isManuallyDisconnected && this.currentRetryCount < this.reconnectAttempts && this.scheduleReconnect();
|
|
3278
3293
|
}, this.ws.onclose = (a) => {
|
|
3279
|
-
h.log("[AnimationWebSocketClient] WebSocket closed:", a.code, a.reason), this.emit("disconnected", a.reason || "Connection closed"), a.code === 1012 &&
|
|
3294
|
+
h.log("[AnimationWebSocketClient] WebSocket closed:", a.code, a.reason), this.emit("disconnected", a.reason || "Connection closed"), a.code === 1012 && S.logEvent("character_animation_service", "error", {
|
|
3280
3295
|
characterId: this.currentCharacterId,
|
|
3281
3296
|
event: "service_restart",
|
|
3282
3297
|
reason: a.reason || "service restart"
|
|
@@ -3289,9 +3304,9 @@ class yi extends wi {
|
|
|
3289
3304
|
}
|
|
3290
3305
|
handleMessage(t) {
|
|
3291
3306
|
try {
|
|
3292
|
-
const n = new
|
|
3307
|
+
const n = new N(new Uint8Array(t)), i = He.decode(n);
|
|
3293
3308
|
if (i.error) {
|
|
3294
|
-
h.error(`[AnimationWebSocketClient] Server error: reqId=${i.error.reqId}, code=${i.error.code}, reason=${i.error.reason}`),
|
|
3309
|
+
h.error(`[AnimationWebSocketClient] Server error: reqId=${i.error.reqId}, code=${i.error.code}, reason=${i.error.reason}`), S.logEvent("character_animation_service", "error", {
|
|
3295
3310
|
characterId: this.currentCharacterId,
|
|
3296
3311
|
event: "server_error",
|
|
3297
3312
|
reqId: i.error.reqId,
|
|
@@ -3301,7 +3316,7 @@ class yi extends wi {
|
|
|
3301
3316
|
return;
|
|
3302
3317
|
}
|
|
3303
3318
|
if (i.type === Ee.MESSAGE_ERROR) {
|
|
3304
|
-
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"),
|
|
3319
|
+
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), S.logEvent("character_animation_service", "warning", {
|
|
3305
3320
|
characterId: this.currentCharacterId,
|
|
3306
3321
|
event: "message_error_without_payload"
|
|
3307
3322
|
}), this.emit("error", new Error("Server returned error message without error details"));
|
|
@@ -3310,7 +3325,7 @@ class yi extends wi {
|
|
|
3310
3325
|
this.emit("message", i);
|
|
3311
3326
|
} catch (n) {
|
|
3312
3327
|
const i = n instanceof Error ? n.message : String(n);
|
|
3313
|
-
h.error("[AnimationWebSocketClient] Failed to decode message:", i),
|
|
3328
|
+
h.error("[AnimationWebSocketClient] Failed to decode message:", i), S.logEvent("character_animation_service", "error", {
|
|
3314
3329
|
characterId: this.currentCharacterId,
|
|
3315
3330
|
event: "decode_failed",
|
|
3316
3331
|
reason: i
|
|
@@ -3337,26 +3352,27 @@ class Ai {
|
|
|
3337
3352
|
d(this, "audioBytesPerSecond", M.audio.sampleRate * 2);
|
|
3338
3353
|
d(this, "audioMetrics", this.createAudioMetrics());
|
|
3339
3354
|
this.dataController = e;
|
|
3340
|
-
const t =
|
|
3355
|
+
const t = S.getEnvironmentConfig();
|
|
3341
3356
|
this.wsClient = new yi({
|
|
3342
3357
|
wsUrl: t.driveningressWsUrl,
|
|
3343
3358
|
reconnectAttempts: 5,
|
|
3344
3359
|
debug: !1,
|
|
3345
|
-
jwtToken:
|
|
3360
|
+
jwtToken: S.sessionToken || void 0,
|
|
3361
|
+
appId: S.appId || void 0
|
|
3346
3362
|
}), this.setupWebSocketListeners();
|
|
3347
3363
|
}
|
|
3348
3364
|
/**
|
|
3349
3365
|
* 连接服务
|
|
3350
3366
|
*/
|
|
3351
3367
|
async connect(e) {
|
|
3352
|
-
await this.wsClient.connect(e);
|
|
3368
|
+
this.setupWebSocketListeners(), await this.wsClient.connect(e);
|
|
3353
3369
|
}
|
|
3354
3370
|
/**
|
|
3355
3371
|
* 发送音频数据到服务器
|
|
3356
3372
|
*/
|
|
3357
3373
|
sendAudioData(e, t) {
|
|
3358
|
-
var
|
|
3359
|
-
this.hasSentEnd && this.dataController.getIsPlaying() && this.currentReqId && this.dataController.interrupt(), this.currentReqId || (this.currentReqId = this.wsClient.generateReqId(), this.hasSentEnd = !1, this.resetAudioMetrics(),
|
|
3374
|
+
var l, s;
|
|
3375
|
+
this.hasSentEnd && this.dataController.getIsPlaying() && this.currentReqId && this.dataController.interrupt(), this.currentReqId || (this.currentReqId = this.wsClient.generateReqId(), this.hasSentEnd = !1, this.resetAudioMetrics(), S.logEvent("character_manager", "info", {
|
|
3360
3376
|
characterId: this.dataController.getAvatarId(),
|
|
3361
3377
|
event: "conversation_started",
|
|
3362
3378
|
reqId: this.currentReqId
|
|
@@ -3366,7 +3382,7 @@ class Ai {
|
|
|
3366
3382
|
n.startTimestamp === 0 && (n.startTimestamp = Date.now(), i = !0), n.accumulatedBytes += e.byteLength;
|
|
3367
3383
|
const a = n.accumulatedBytes / this.audioBytesPerSecond;
|
|
3368
3384
|
if (a >= 2 && n.tap2Timestamp === 0 && (n.tap2Timestamp = Date.now(), i = !0), a >= 4 && n.tap4Timestamp === 0 && (n.tap4Timestamp = Date.now(), i = !0), t && n.endTimestamp === 0 && (n.endTimestamp = Date.now(), i = !0), e.byteLength === 0 && !t && h.warn("[NetworkLayer] Warning: sending empty audio data (size=0, end=false)"), !this.wsClient.sendAudioData(this.currentReqId, e, t)) {
|
|
3369
|
-
h.error("[NetworkLayer] Failed to send audio data to WebSocket"), (
|
|
3385
|
+
h.error("[NetworkLayer] Failed to send audio data to WebSocket"), (s = (l = this.dataController).onError) == null || s.call(l, new se("Failed to send audio data to WebSocket", "SEND_FAILED")), S.logEvent("character_animation_service", "error", {
|
|
3370
3386
|
characterId: this.dataController.getAvatarId(),
|
|
3371
3387
|
event: "send_audio_failed",
|
|
3372
3388
|
reqId: this.currentReqId
|
|
@@ -3397,27 +3413,27 @@ class Ai {
|
|
|
3397
3413
|
* 设置 WebSocket 事件监听器
|
|
3398
3414
|
*/
|
|
3399
3415
|
setupWebSocketListeners() {
|
|
3400
|
-
this.wsClient.on("connected",
|
|
3416
|
+
this.wsClient.on("connected", () => {
|
|
3401
3417
|
var e, t;
|
|
3402
|
-
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e, Se.connected),
|
|
3418
|
+
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e, Se.connected), S.logEvent("character_animation_service", "info", {
|
|
3403
3419
|
characterId: this.dataController.getAvatarId(),
|
|
3404
3420
|
event: "connected"
|
|
3405
3421
|
});
|
|
3406
3422
|
}), this.wsClient.on("disconnected", () => {
|
|
3407
3423
|
var e, t;
|
|
3408
|
-
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e, Se.disconnected),
|
|
3424
|
+
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e, Se.disconnected), S.logEvent("character_animation_service", "warning", {
|
|
3409
3425
|
characterId: this.dataController.getAvatarId(),
|
|
3410
3426
|
event: "disconnected"
|
|
3411
3427
|
});
|
|
3412
3428
|
}), this.wsClient.on("reconnecting", () => {
|
|
3413
|
-
|
|
3429
|
+
S.logEvent("character_animation_service", "info", {
|
|
3414
3430
|
characterId: this.dataController.getAvatarId(),
|
|
3415
3431
|
event: "reconnecting"
|
|
3416
3432
|
});
|
|
3417
3433
|
}), this.wsClient.on("error", (e) => {
|
|
3418
3434
|
var n, i, a, o;
|
|
3419
3435
|
const t = e instanceof Error ? e.message : String(e);
|
|
3420
|
-
h.error("[NetworkLayer] WebSocket error:", t),
|
|
3436
|
+
h.error("[NetworkLayer] WebSocket error:", t), S.logEvent("character_animation_service", "error", {
|
|
3421
3437
|
characterId: this.dataController.getAvatarId(),
|
|
3422
3438
|
event: "websocket_error",
|
|
3423
3439
|
reason: t
|
|
@@ -3441,7 +3457,7 @@ class Ai {
|
|
|
3441
3457
|
}
|
|
3442
3458
|
} catch (t) {
|
|
3443
3459
|
const n = t instanceof Error ? t.message : String(t);
|
|
3444
|
-
h.error("[NetworkLayer] Failed to handle message:", n),
|
|
3460
|
+
h.error("[NetworkLayer] Failed to handle message:", n), S.logEvent("character_manager", "error", {
|
|
3445
3461
|
characterId: this.dataController.getAvatarId(),
|
|
3446
3462
|
event: "handle_message_failed",
|
|
3447
3463
|
reason: n
|
|
@@ -3458,7 +3474,7 @@ class Ai {
|
|
|
3458
3474
|
}
|
|
3459
3475
|
const { reqId: t, animation: n } = e.serverResponseAnimation;
|
|
3460
3476
|
if (!this.currentReqId || t !== this.currentReqId) {
|
|
3461
|
-
h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected reqId: ${this.currentReqId}, received reqId: ${t}`),
|
|
3477
|
+
h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected reqId: ${this.currentReqId}, received reqId: ${t}`), S.logEvent("character_manager", "warning", {
|
|
3462
3478
|
characterId: this.dataController.getAvatarId(),
|
|
3463
3479
|
event: "animation_reqid_mismatch",
|
|
3464
3480
|
expectedReqId: this.currentReqId,
|
|
@@ -3470,7 +3486,7 @@ class Ai {
|
|
|
3470
3486
|
const i = n.keyframes;
|
|
3471
3487
|
this.dataController.sendKeyframes(i), this.dataController.getIsPlaying() || this.dataController.startStreamingPlayback(), this.audioMetrics.didRecvFirstFlame || (this.audioMetrics.didRecvFirstFlame = !0, this.audioMetrics.recvFirstFlameTimestamp = Date.now(), this.currentReqId && this.reportAudioMetrics(this.currentReqId));
|
|
3472
3488
|
} else
|
|
3473
|
-
h.warn(`[NetworkLayer] Animation message has no keyframes - reqId: ${t}`),
|
|
3489
|
+
h.warn(`[NetworkLayer] Animation message has no keyframes - reqId: ${t}`), S.logEvent("character_manager", "warning", {
|
|
3474
3490
|
characterId: this.dataController.getAvatarId(),
|
|
3475
3491
|
event: "animation_empty_keyframes",
|
|
3476
3492
|
reqId: t
|
|
@@ -3482,13 +3498,13 @@ class Ai {
|
|
|
3482
3498
|
handleErrorMessage(e) {
|
|
3483
3499
|
var n, i, a, o;
|
|
3484
3500
|
if (!e.error) {
|
|
3485
|
-
h.warn("[NetworkLayer] MESSAGE_ERROR received but message.error is empty"), e.serverResponseAnimation && (h.warn("[NetworkLayer] MESSAGE_ERROR contains animation data, treating as animation message"),
|
|
3501
|
+
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"), S.logEvent("character_manager", "warning", {
|
|
3486
3502
|
characterId: this.dataController.getAvatarId(),
|
|
3487
3503
|
event: "message_error_with_payload"
|
|
3488
3504
|
}), this.handleAnimationMessage(e));
|
|
3489
3505
|
return;
|
|
3490
3506
|
}
|
|
3491
|
-
h.error(`[NetworkLayer] Server error: reqId=${e.error.reqId}, code=${e.error.code}, reason=${e.error.reason}`),
|
|
3507
|
+
h.error(`[NetworkLayer] Server error: reqId=${e.error.reqId}, code=${e.error.code}, reason=${e.error.reason}`), S.logEvent("character_manager", "error", {
|
|
3492
3508
|
characterId: this.dataController.getAvatarId(),
|
|
3493
3509
|
event: "server_error",
|
|
3494
3510
|
reqId: e.error.reqId,
|
|
@@ -3496,7 +3512,7 @@ class Ai {
|
|
|
3496
3512
|
reason: e.error.reason
|
|
3497
3513
|
});
|
|
3498
3514
|
const t = ((n = e.error.code) == null ? void 0 : n.toString().toLowerCase()) ?? "";
|
|
3499
|
-
(t.includes("unauth") || t === "401") &&
|
|
3515
|
+
(t.includes("unauth") || t === "401") && S.logEvent("sdk_verify", "error", {
|
|
3500
3516
|
characterId: this.dataController.getAvatarId(),
|
|
3501
3517
|
reqId: e.error.reqId,
|
|
3502
3518
|
reason: e.error.reason
|
|
@@ -3529,7 +3545,7 @@ class Ai {
|
|
|
3529
3545
|
* 上报音频指标
|
|
3530
3546
|
*/
|
|
3531
3547
|
reportAudioMetrics(e) {
|
|
3532
|
-
!e || this.audioMetrics.startTimestamp === 0 ||
|
|
3548
|
+
!e || this.audioMetrics.startTimestamp === 0 || S.logEvent("send_audio_measure", "info", {
|
|
3533
3549
|
reqId: e,
|
|
3534
3550
|
start: this.audioMetrics.startTimestamp,
|
|
3535
3551
|
tap2: this.audioMetrics.tap2Timestamp,
|
|
@@ -3552,7 +3568,7 @@ class Si {
|
|
|
3552
3568
|
d(this, "isPlaying", !1);
|
|
3553
3569
|
// ========== State Management ==========
|
|
3554
3570
|
d(this, "isConnected", !1);
|
|
3555
|
-
d(this, "currentState",
|
|
3571
|
+
d(this, "currentState", T.idle);
|
|
3556
3572
|
// ========== Event System ==========
|
|
3557
3573
|
d(this, "onConnectionState", null);
|
|
3558
3574
|
d(this, "onAvatarState", null);
|
|
@@ -3566,52 +3582,52 @@ class Si {
|
|
|
3566
3582
|
d(this, "lastRenderedFrameIndex", -1);
|
|
3567
3583
|
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? ke.network, this.playbackMode === ke.network && (this.networkLayer = new Ai(this));
|
|
3568
3584
|
}
|
|
3569
|
-
// ==========
|
|
3585
|
+
// ========== Internal Accessors (for NetworkLayer and AvatarView) ==========
|
|
3570
3586
|
/**
|
|
3571
|
-
*
|
|
3587
|
+
* Get Avatar ID (for NetworkLayer use)
|
|
3572
3588
|
* @internal
|
|
3573
3589
|
*/
|
|
3574
3590
|
getAvatarId() {
|
|
3575
3591
|
return this.avatar.id;
|
|
3576
3592
|
}
|
|
3577
3593
|
/**
|
|
3578
|
-
*
|
|
3594
|
+
* Get playback state (for NetworkLayer use)
|
|
3579
3595
|
* @internal
|
|
3580
3596
|
*/
|
|
3581
3597
|
getIsPlaying() {
|
|
3582
3598
|
return this.isPlaying;
|
|
3583
3599
|
}
|
|
3584
3600
|
/**
|
|
3585
|
-
*
|
|
3601
|
+
* Set connection state (for NetworkLayer use)
|
|
3586
3602
|
* @internal
|
|
3587
3603
|
*/
|
|
3588
3604
|
setConnected(e) {
|
|
3589
3605
|
this.isConnected = e;
|
|
3590
3606
|
}
|
|
3591
3607
|
/**
|
|
3592
|
-
*
|
|
3608
|
+
* Get connection state
|
|
3593
3609
|
* @internal
|
|
3594
3610
|
*/
|
|
3595
3611
|
get connected() {
|
|
3596
3612
|
return this.isConnected;
|
|
3597
3613
|
}
|
|
3598
3614
|
/**
|
|
3599
|
-
*
|
|
3615
|
+
* Get current state
|
|
3600
3616
|
* @internal
|
|
3601
3617
|
*/
|
|
3602
3618
|
get state() {
|
|
3603
3619
|
return this.currentState;
|
|
3604
3620
|
}
|
|
3605
3621
|
/**
|
|
3606
|
-
*
|
|
3622
|
+
* Get animation player instance
|
|
3607
3623
|
* @internal
|
|
3608
3624
|
*/
|
|
3609
3625
|
getAnimationPlayer() {
|
|
3610
3626
|
return this.animationPlayer;
|
|
3611
3627
|
}
|
|
3612
|
-
// ==========
|
|
3628
|
+
// ========== Network Mode Interface ==========
|
|
3613
3629
|
/**
|
|
3614
|
-
*
|
|
3630
|
+
* Start service (network mode only)
|
|
3615
3631
|
*/
|
|
3616
3632
|
async start() {
|
|
3617
3633
|
if (!this.networkLayer)
|
|
@@ -3625,7 +3641,7 @@ class Si {
|
|
|
3625
3641
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
3626
3642
|
} catch (e) {
|
|
3627
3643
|
const t = e instanceof Error ? e.message : String(e);
|
|
3628
|
-
throw h.error("[AvatarController] Failed to create streaming player:", t),
|
|
3644
|
+
throw h.error("[AvatarController] Failed to create streaming player:", t), S.logEvent("character_player", "error", {
|
|
3629
3645
|
characterId: this.avatar.id,
|
|
3630
3646
|
event: "streaming_player_init_failed",
|
|
3631
3647
|
reason: t
|
|
@@ -3635,31 +3651,31 @@ class Si {
|
|
|
3635
3651
|
await this.networkLayer.connect(this.avatar.id);
|
|
3636
3652
|
}
|
|
3637
3653
|
/**
|
|
3638
|
-
*
|
|
3639
|
-
*
|
|
3654
|
+
* Send audio to server (network mode only)
|
|
3655
|
+
* Also cache to data layer for playback
|
|
3640
3656
|
*/
|
|
3641
3657
|
send(e, t = !1) {
|
|
3642
3658
|
var n, i;
|
|
3643
3659
|
if (!this.networkLayer || !this.isConnected) {
|
|
3644
|
-
(n = this.onError) == null || n.call(this, new se("Service not connected", "NOT_CONNECTED")),
|
|
3660
|
+
(n = this.onError) == null || n.call(this, new se("Service not connected", "NOT_CONNECTED")), S.logEvent("character_manager", "warning", {
|
|
3645
3661
|
characterId: this.avatar.id,
|
|
3646
3662
|
event: "send_not_connected"
|
|
3647
3663
|
});
|
|
3648
3664
|
return;
|
|
3649
3665
|
}
|
|
3650
|
-
this.networkLayer.sendAudioData(e, t), this.addAudioChunkToBuffer(new Uint8Array(e), t), (i = this.onAvatarState) == null || i.call(this,
|
|
3666
|
+
this.networkLayer.sendAudioData(e, t), this.addAudioChunkToBuffer(new Uint8Array(e), t), (i = this.onAvatarState) == null || i.call(this, T.active);
|
|
3651
3667
|
}
|
|
3652
3668
|
/**
|
|
3653
|
-
*
|
|
3669
|
+
* Close service (network mode only)
|
|
3654
3670
|
*/
|
|
3655
3671
|
close() {
|
|
3656
3672
|
var e, t;
|
|
3657
|
-
this.isPlaying && this.stopPlayback(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, (e = this.networkLayer) == null || e.disconnect(), this.isConnected = !1, (t = this.onConnectionState) == null || t.call(this, Se.disconnected);
|
|
3673
|
+
(this.isPlaying || this.currentState === T.paused) && this.stopPlayback(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, (e = this.networkLayer) == null || e.disconnect(), this.isConnected = !1, (t = this.onConnectionState) == null || t.call(this, Se.disconnected);
|
|
3658
3674
|
}
|
|
3659
|
-
// ==========
|
|
3675
|
+
// ========== External Data Mode Interface ==========
|
|
3660
3676
|
/**
|
|
3661
|
-
*
|
|
3662
|
-
*
|
|
3677
|
+
* Start playback (external data mode)
|
|
3678
|
+
* Must call this method first with initial data to start playback
|
|
3663
3679
|
*/
|
|
3664
3680
|
async play(e, t) {
|
|
3665
3681
|
if (!this.isPlaying) {
|
|
@@ -3671,67 +3687,93 @@ class Si {
|
|
|
3671
3687
|
}
|
|
3672
3688
|
}
|
|
3673
3689
|
/**
|
|
3674
|
-
*
|
|
3675
|
-
*
|
|
3690
|
+
* Send audio data (external data mode)
|
|
3691
|
+
* Stream additional audio data after play()
|
|
3676
3692
|
*/
|
|
3677
3693
|
sendAudioChunk(e, t = !1) {
|
|
3678
3694
|
var n, i;
|
|
3679
|
-
this.isPlaying && ((n = this.animationPlayer) != null && n.isStreamingReady()) ? this.animationPlayer.addAudioChunk(e, t) : (e.length > 0 || t) && (this.pendingAudioChunks.push({ data: e, isLast: t }), (i = this.onAvatarState) == null || i.call(this,
|
|
3695
|
+
this.isPlaying && ((n = this.animationPlayer) != null && n.isStreamingReady()) ? this.animationPlayer.addAudioChunk(e, t) : (e.length > 0 || t) && (this.pendingAudioChunks.push({ data: e, isLast: t }), (i = this.onAvatarState) == null || i.call(this, T.active));
|
|
3680
3696
|
}
|
|
3681
3697
|
/**
|
|
3682
|
-
*
|
|
3683
|
-
*
|
|
3698
|
+
* Send animation keyframes (external data mode or network mode)
|
|
3699
|
+
* Stream additional animation data after play()
|
|
3684
3700
|
*/
|
|
3685
3701
|
sendKeyframes(e) {
|
|
3686
3702
|
this.currentKeyframes.length === 0 ? this.currentKeyframes = e : this.currentKeyframes.push(...e), this.emit("keyframesUpdate", this.currentKeyframes);
|
|
3687
3703
|
}
|
|
3688
|
-
// ==========
|
|
3704
|
+
// ========== Common Interface ==========
|
|
3705
|
+
/**
|
|
3706
|
+
* Pause playback (can be resumed later)
|
|
3707
|
+
* Pause audio playback and stop render loop, but preserve all state (keyframes, audio buffers, etc.)
|
|
3708
|
+
*/
|
|
3709
|
+
pause() {
|
|
3710
|
+
var e, t, n;
|
|
3711
|
+
!this.isPlaying || this.currentState === T.paused || (h.log("[AvatarController] Pausing playback"), (e = this.animationPlayer) == null || e.pause(), this.stopPlaybackLoop(), this.currentState = T.paused, (t = this.onAvatarState) == null || t.call(this, T.paused), h.log("[AvatarController] Playback paused"), S.logEvent("character_player", "info", {
|
|
3712
|
+
characterId: this.avatar.id,
|
|
3713
|
+
event: "playback_paused",
|
|
3714
|
+
reqId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentReqId()) || void 0
|
|
3715
|
+
}));
|
|
3716
|
+
}
|
|
3689
3717
|
/**
|
|
3690
|
-
*
|
|
3718
|
+
* Resume playback (from paused state)
|
|
3719
|
+
* Resume audio playback and restart render loop
|
|
3720
|
+
* Animation will continue from paused frame (because animation time base comes from audio, will auto-sync)
|
|
3721
|
+
*/
|
|
3722
|
+
async resume() {
|
|
3723
|
+
var e, t, n;
|
|
3724
|
+
!this.isPlaying || this.currentState !== T.paused || (h.log("[AvatarController] Resuming playback"), await ((e = this.animationPlayer) == null ? void 0 : e.resume()), this.startPlaybackLoop(), this.currentState = T.playing, (t = this.onAvatarState) == null || t.call(this, T.playing), h.log("[AvatarController] Playback resumed"), S.logEvent("character_player", "info", {
|
|
3725
|
+
characterId: this.avatar.id,
|
|
3726
|
+
event: "playback_resumed",
|
|
3727
|
+
reqId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentReqId()) || void 0
|
|
3728
|
+
}));
|
|
3729
|
+
}
|
|
3730
|
+
/**
|
|
3731
|
+
* Interrupt current playback
|
|
3691
3732
|
*/
|
|
3692
3733
|
interrupt() {
|
|
3693
3734
|
var e;
|
|
3694
|
-
this.
|
|
3735
|
+
this.currentState === T.paused && ((e = this.animationPlayer) == null || e.resume().catch(() => {
|
|
3736
|
+
})), this.stopPlayback(), this.emit("interrupt"), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.networkLayer && this.networkLayer.resetReqId();
|
|
3695
3737
|
}
|
|
3696
3738
|
/**
|
|
3697
|
-
*
|
|
3739
|
+
* Clear all data and resources
|
|
3698
3740
|
*/
|
|
3699
3741
|
clear() {
|
|
3700
3742
|
var e, t;
|
|
3701
|
-
this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.isConnected = !1, (t = this.onAvatarState) == null || t.call(this,
|
|
3743
|
+
this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.isConnected = !1, this.currentState = T.idle, (t = this.onAvatarState) == null || t.call(this, T.idle);
|
|
3702
3744
|
}
|
|
3703
3745
|
/**
|
|
3704
|
-
*
|
|
3705
|
-
*
|
|
3746
|
+
* Dispose controller, clean up all callbacks to avoid memory leaks
|
|
3747
|
+
* Should be called when AvatarView.dispose()
|
|
3706
3748
|
* @internal
|
|
3707
3749
|
*/
|
|
3708
3750
|
dispose() {
|
|
3709
3751
|
this.onConnectionState = null, this.onAvatarState = null, this.onError = null, this.renderCallback = void 0, this.transitionCompleteCallback = void 0, this.eventListeners.clear();
|
|
3710
3752
|
}
|
|
3711
|
-
// ==========
|
|
3753
|
+
// ========== Internal Methods (for NetworkLayer and AvatarView use) ==========
|
|
3712
3754
|
/**
|
|
3713
|
-
*
|
|
3755
|
+
* Start streaming playback (internal method, called by NetworkLayer or play())
|
|
3714
3756
|
* @internal
|
|
3715
3757
|
*/
|
|
3716
3758
|
startStreamingPlayback() {
|
|
3717
3759
|
return this.startStreamingPlaybackInternal();
|
|
3718
3760
|
}
|
|
3719
3761
|
/**
|
|
3720
|
-
*
|
|
3762
|
+
* Set render callback (called by AvatarView)
|
|
3721
3763
|
* @internal
|
|
3722
3764
|
*/
|
|
3723
3765
|
setRenderCallback(e) {
|
|
3724
3766
|
this.renderCallback = e;
|
|
3725
3767
|
}
|
|
3726
3768
|
/**
|
|
3727
|
-
*
|
|
3769
|
+
* Set transition complete callback (called by AvatarView)
|
|
3728
3770
|
* @internal
|
|
3729
3771
|
*/
|
|
3730
3772
|
setTransitionCompleteCallback(e) {
|
|
3731
3773
|
this.transitionCompleteCallback = e;
|
|
3732
3774
|
}
|
|
3733
3775
|
/**
|
|
3734
|
-
*
|
|
3776
|
+
* Transition complete notification (called by AvatarView)
|
|
3735
3777
|
* @internal
|
|
3736
3778
|
*/
|
|
3737
3779
|
onTransitionComplete() {
|
|
@@ -3740,15 +3782,15 @@ class Si {
|
|
|
3740
3782
|
e && e.play();
|
|
3741
3783
|
}
|
|
3742
3784
|
/**
|
|
3743
|
-
*
|
|
3785
|
+
* Provide interface for AvatarView to register internal events
|
|
3744
3786
|
* @internal
|
|
3745
3787
|
*/
|
|
3746
3788
|
setupInternalEventListeners(e) {
|
|
3747
3789
|
e.onKeyframesUpdate && this.registerEventListener("keyframesUpdate", e.onKeyframesUpdate), e.onStartRendering && this.registerEventListener("startRendering", e.onStartRendering), e.onStopRendering && this.registerEventListener("stopRendering", e.onStopRendering), e.onInterrupt && this.registerEventListener("interrupt", e.onInterrupt);
|
|
3748
3790
|
}
|
|
3749
|
-
// ==========
|
|
3791
|
+
// ========== Private Methods ==========
|
|
3750
3792
|
/**
|
|
3751
|
-
*
|
|
3793
|
+
* Start streaming playback (internal implementation)
|
|
3752
3794
|
*/
|
|
3753
3795
|
async startStreamingPlaybackInternal() {
|
|
3754
3796
|
var e, t, n;
|
|
@@ -3763,14 +3805,14 @@ class Si {
|
|
|
3763
3805
|
try {
|
|
3764
3806
|
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
3765
3807
|
var a, o;
|
|
3766
|
-
this.isPlaying = !1, (a = this.onAvatarState) == null || a.call(this,
|
|
3808
|
+
this.isPlaying = !1, this.currentState = T.idle, (a = this.onAvatarState) == null || a.call(this, T.idle), this.emit("stopRendering"), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.networkLayer && this.networkLayer.resetReqId(), S.logEvent("character_player", "info", {
|
|
3767
3809
|
characterId: this.avatar.id,
|
|
3768
3810
|
event: "playback_ended",
|
|
3769
3811
|
reqId: ((o = this.networkLayer) == null ? void 0 : o.getCurrentReqId()) || void 0
|
|
3770
3812
|
});
|
|
3771
3813
|
}), this.emit("startRendering");
|
|
3772
3814
|
const i = this.animationPlayer.getStreamingPlayer();
|
|
3773
|
-
i && i.setAutoStart(!1), i && await i.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, (e = this.onAvatarState) == null || e.call(this,
|
|
3815
|
+
i && i.setAutoStart(!1), i && await i.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = T.playing, (e = this.onAvatarState) == null || e.call(this, T.playing), this.startPlaybackLoop(), S.logEvent("character_player", "info", {
|
|
3774
3816
|
characterId: this.avatar.id,
|
|
3775
3817
|
event: "playback_started",
|
|
3776
3818
|
reqId: ((t = this.networkLayer) == null ? void 0 : t.getCurrentReqId()) || void 0
|
|
@@ -3781,13 +3823,13 @@ class Si {
|
|
|
3781
3823
|
}
|
|
3782
3824
|
}
|
|
3783
3825
|
/**
|
|
3784
|
-
*
|
|
3826
|
+
* Playback loop: Calculate animation frame based on audio time, notify render layer to render
|
|
3785
3827
|
*/
|
|
3786
3828
|
startPlaybackLoop() {
|
|
3787
3829
|
if (this.playbackLoopId)
|
|
3788
3830
|
return;
|
|
3789
3831
|
const e = M.animation.fps, t = async () => {
|
|
3790
|
-
if (!this.isPlaying || !this.animationPlayer) {
|
|
3832
|
+
if (!this.isPlaying || this.currentState === T.paused || !this.animationPlayer) {
|
|
3791
3833
|
this.playbackLoopId = null;
|
|
3792
3834
|
return;
|
|
3793
3835
|
}
|
|
@@ -3803,10 +3845,10 @@ class Si {
|
|
|
3803
3845
|
return;
|
|
3804
3846
|
}
|
|
3805
3847
|
if (this.lastRenderedFrameIndex = i, i >= 0 && i < this.currentKeyframes.length) {
|
|
3806
|
-
const a = this.currentKeyframes[i], o = Vt(a),
|
|
3807
|
-
if (
|
|
3808
|
-
const
|
|
3809
|
-
|
|
3848
|
+
const a = this.currentKeyframes[i], o = Vt(a), l = S.getAvatarCore();
|
|
3849
|
+
if (l) {
|
|
3850
|
+
const s = await l.computeFrameFlatFromParams(o);
|
|
3851
|
+
s && this.renderCallback && this.renderCallback(s, i);
|
|
3810
3852
|
}
|
|
3811
3853
|
}
|
|
3812
3854
|
} catch (n) {
|
|
@@ -3818,13 +3860,13 @@ class Si {
|
|
|
3818
3860
|
this.playbackLoopId = requestAnimationFrame(t);
|
|
3819
3861
|
}
|
|
3820
3862
|
/**
|
|
3821
|
-
*
|
|
3863
|
+
* Stop playback loop
|
|
3822
3864
|
*/
|
|
3823
3865
|
stopPlaybackLoop() {
|
|
3824
3866
|
this.playbackLoopId && (cancelAnimationFrame(this.playbackLoopId), this.playbackLoopId = null);
|
|
3825
3867
|
}
|
|
3826
3868
|
/**
|
|
3827
|
-
*
|
|
3869
|
+
* Stop playback
|
|
3828
3870
|
*/
|
|
3829
3871
|
stopPlayback() {
|
|
3830
3872
|
var e;
|
|
@@ -3833,28 +3875,28 @@ class Si {
|
|
|
3833
3875
|
const t = this.animationPlayer.getStreamingPlayer();
|
|
3834
3876
|
t == null || t.stop();
|
|
3835
3877
|
}
|
|
3836
|
-
this.emit("stopRendering"), this.isPlaying = !1, (e = this.onAvatarState) == null || e.call(this,
|
|
3878
|
+
this.emit("stopRendering"), this.isPlaying = !1, this.currentState = T.idle, (e = this.onAvatarState) == null || e.call(this, T.idle);
|
|
3837
3879
|
}
|
|
3838
3880
|
/**
|
|
3839
|
-
*
|
|
3881
|
+
* Clean up players
|
|
3840
3882
|
*/
|
|
3841
3883
|
cleanupPlayers() {
|
|
3842
3884
|
this.animationPlayer && (this.animationPlayer.dispose(), this.animationPlayer = null);
|
|
3843
3885
|
}
|
|
3844
3886
|
/**
|
|
3845
|
-
*
|
|
3887
|
+
* Add audio chunk to buffer
|
|
3846
3888
|
*/
|
|
3847
3889
|
addAudioChunkToBuffer(e, t) {
|
|
3848
3890
|
this.animationPlayer || (this.animationPlayer = new be()), this.isPlaying && this.animationPlayer.isStreamingReady() ? this.animationPlayer.addAudioChunk(e, t) : this.pendingAudioChunks.push({ data: e, isLast: t });
|
|
3849
3891
|
}
|
|
3850
3892
|
/**
|
|
3851
|
-
*
|
|
3893
|
+
* Event system
|
|
3852
3894
|
*/
|
|
3853
3895
|
registerEventListener(e, t) {
|
|
3854
3896
|
this.eventListeners.has(e) || this.eventListeners.set(e, /* @__PURE__ */ new Set()), this.eventListeners.get(e).add(t);
|
|
3855
3897
|
}
|
|
3856
3898
|
/**
|
|
3857
|
-
*
|
|
3899
|
+
* Emit event
|
|
3858
3900
|
*/
|
|
3859
3901
|
emit(e, t) {
|
|
3860
3902
|
const n = this.eventListeners.get(e);
|
|
@@ -3879,10 +3921,14 @@ function nr(r) {
|
|
|
3879
3921
|
}
|
|
3880
3922
|
async function bi(r) {
|
|
3881
3923
|
try {
|
|
3882
|
-
const e =
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3924
|
+
const e = {}, t = S.appId, n = S.sessionToken;
|
|
3925
|
+
t && (e["X-App-Id"] = t), n && (e.Authorization = `Bearer ${n}`);
|
|
3926
|
+
const i = await fetch(r, {
|
|
3927
|
+
headers: Object.keys(e).length > 0 ? e : void 0
|
|
3928
|
+
});
|
|
3929
|
+
if (!i.ok)
|
|
3930
|
+
throw new Error(`HTTP ${i.status} ${i.statusText}`);
|
|
3931
|
+
return await i.arrayBuffer();
|
|
3886
3932
|
} catch (e) {
|
|
3887
3933
|
const t = nr(e);
|
|
3888
3934
|
throw new Error(`[downloadResource] ${r} → ${t}`);
|
|
@@ -3930,7 +3976,7 @@ class Ci {
|
|
|
3930
3976
|
}
|
|
3931
3977
|
}, a = Object.keys(i).length;
|
|
3932
3978
|
let o = 0;
|
|
3933
|
-
const
|
|
3979
|
+
const l = (w, y) => {
|
|
3934
3980
|
t && (y && o++, t({
|
|
3935
3981
|
stage: "template",
|
|
3936
3982
|
filename: w,
|
|
@@ -3938,14 +3984,14 @@ class Ci {
|
|
|
3938
3984
|
total: a,
|
|
3939
3985
|
progress: Math.round(o / a * 100)
|
|
3940
3986
|
}));
|
|
3941
|
-
},
|
|
3987
|
+
}, s = {}, p = Object.entries(i).map(async ([w, { url: y, resourceName: b }]) => {
|
|
3942
3988
|
if (!y)
|
|
3943
|
-
throw new Error(`[loadTemplateResources] Missing CDN URL for ${w} (${
|
|
3944
|
-
|
|
3945
|
-
const
|
|
3946
|
-
h.log(`✅ ${w} loaded: ${
|
|
3989
|
+
throw new Error(`[loadTemplateResources] Missing CDN URL for ${w} (${b})`);
|
|
3990
|
+
l(b, !1), h.log(`📥 Loading ${w} from API CDN: ${y}`);
|
|
3991
|
+
const I = await $e(y);
|
|
3992
|
+
h.log(`✅ ${w} loaded: ${I.byteLength} bytes`), s[w] = I, l(b, !0);
|
|
3947
3993
|
});
|
|
3948
|
-
return await Promise.all(
|
|
3994
|
+
return await Promise.all(p), s;
|
|
3949
3995
|
}
|
|
3950
3996
|
/**
|
|
3951
3997
|
* Load global FLAME template resources from CDN
|
|
@@ -3971,7 +4017,7 @@ class Ci {
|
|
|
3971
4017
|
}
|
|
3972
4018
|
}, a = Object.keys(i).length;
|
|
3973
4019
|
let o = 0;
|
|
3974
|
-
const
|
|
4020
|
+
const l = (c, u) => {
|
|
3975
4021
|
e && (u && o++, e({
|
|
3976
4022
|
stage: "template",
|
|
3977
4023
|
filename: c,
|
|
@@ -3979,12 +4025,12 @@ class Ci {
|
|
|
3979
4025
|
total: a,
|
|
3980
4026
|
progress: Math.round(o / a * 100)
|
|
3981
4027
|
}));
|
|
3982
|
-
},
|
|
3983
|
-
|
|
4028
|
+
}, s = {}, p = Object.entries(i).map(async ([c, { url: u, resourceName: m }]) => {
|
|
4029
|
+
l(m, !1), h.log(`📥 Loading ${c} from global CDN: ${u}`);
|
|
3984
4030
|
const v = await $e(u);
|
|
3985
|
-
h.log(`✅ ${c} loaded: ${v.byteLength} bytes`),
|
|
4031
|
+
h.log(`✅ ${c} loaded: ${v.byteLength} bytes`), s[c] = v, l(m, !0);
|
|
3986
4032
|
});
|
|
3987
|
-
return await Promise.all(
|
|
4033
|
+
return await Promise.all(p), s;
|
|
3988
4034
|
}
|
|
3989
4035
|
/**
|
|
3990
4036
|
* Load camera settings from CharacterMeta (optional)
|
|
@@ -3998,11 +4044,15 @@ class Ci {
|
|
|
3998
4044
|
}
|
|
3999
4045
|
try {
|
|
4000
4046
|
h.log(`📥 Loading camera info from: ${t}`);
|
|
4001
|
-
const a =
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4047
|
+
const a = {}, o = S.appId, l = S.sessionToken;
|
|
4048
|
+
o && (a["X-App-Id"] = o), l && (a.Authorization = `Bearer ${l}`);
|
|
4049
|
+
const s = await fetch(t, {
|
|
4050
|
+
headers: Object.keys(a).length > 0 ? a : void 0
|
|
4051
|
+
});
|
|
4052
|
+
if (!s.ok)
|
|
4053
|
+
throw new Error(`Failed to fetch camera info: ${s.statusText}`);
|
|
4054
|
+
const p = await s.json();
|
|
4055
|
+
return h.log("✅ Camera info loaded:", p), p;
|
|
4006
4056
|
} catch (a) {
|
|
4007
4057
|
h.warn("⚠️ Failed to load camera info, using default:", a);
|
|
4008
4058
|
return;
|
|
@@ -4012,48 +4062,48 @@ class Ci {
|
|
|
4012
4062
|
* Load character data from CharacterMeta (iOS compatible)
|
|
4013
4063
|
*/
|
|
4014
4064
|
async loadCharacterData(e, t) {
|
|
4015
|
-
var
|
|
4016
|
-
const { loadMonologue: n = !1, progressCallback: i = null } = t || {}, a = (L = (
|
|
4065
|
+
var b, I, L, _, X, G, U, j, Y, J, re, z, we, de, ne;
|
|
4066
|
+
const { loadMonologue: n = !1, progressCallback: i = null } = t || {}, a = (L = (I = (b = e.models) == null ? void 0 : b.shape) == null ? void 0 : I.resource) == null ? void 0 : L.remote, o = (G = (X = (_ = e.models) == null ? void 0 : _.gsStandard) == null ? void 0 : X.resource) == null ? void 0 : G.remote, l = (Y = (j = (U = e.animations) == null ? void 0 : U.frameIdle) == null ? void 0 : j.resource) == null ? void 0 : Y.remote, s = (z = (re = (J = e.animations) == null ? void 0 : J.frameMono) == null ? void 0 : re.resource) == null ? void 0 : z.remote, p = (ne = (de = (we = e.animations) == null ? void 0 : we.audioMono) == null ? void 0 : de.resource) == null ? void 0 : ne.remote;
|
|
4017
4067
|
if (!a || !o) {
|
|
4018
|
-
const
|
|
4019
|
-
throw
|
|
4068
|
+
const B = "Missing required resources: shape or gsStandard (point cloud)";
|
|
4069
|
+
throw S.logEvent("character_load", "error", {
|
|
4020
4070
|
characterId: e.characterId ?? "unknown",
|
|
4021
4071
|
stage: "resource_validation",
|
|
4022
|
-
reason:
|
|
4023
|
-
}), new Error(
|
|
4072
|
+
reason: B
|
|
4073
|
+
}), new Error(B);
|
|
4024
4074
|
}
|
|
4025
4075
|
const c = [
|
|
4026
4076
|
{ key: "shape", url: a, filename: "shape.pb" },
|
|
4027
4077
|
{ key: "pointCloud", url: o, filename: "point_cloud.ply" }
|
|
4028
4078
|
];
|
|
4029
|
-
|
|
4079
|
+
l && c.push({ key: "idleAnimation", url: l, filename: "idle.pb", optional: !0 }), n && s ? (h.log("📥 Loading monologue animation (enabled by option)"), c.push({ key: "monoAnimation", url: s, filename: "mono.pb", optional: !0 })) : !n && s && h.log("⏭️ Skipping monologue animation (disabled by option)");
|
|
4030
4080
|
let u = 0;
|
|
4031
|
-
const m = c.length, v = (
|
|
4032
|
-
i && (
|
|
4081
|
+
const m = c.length, v = (B, V) => {
|
|
4082
|
+
i && (V && u++, i({
|
|
4033
4083
|
stage: "character",
|
|
4034
|
-
filename:
|
|
4084
|
+
filename: B,
|
|
4035
4085
|
loaded: u,
|
|
4036
4086
|
total: m,
|
|
4037
4087
|
progress: Math.round(u / m * 100)
|
|
4038
4088
|
}));
|
|
4039
|
-
}, w = {}, y = c.map(async ({ key:
|
|
4089
|
+
}, w = {}, y = c.map(async ({ key: B, url: V, filename: ie, optional: Le }) => {
|
|
4040
4090
|
v(ie, !1);
|
|
4041
4091
|
try {
|
|
4042
|
-
const
|
|
4043
|
-
return
|
|
4044
|
-
} catch (
|
|
4092
|
+
const q = await $e(V);
|
|
4093
|
+
return B === "shape" ? w.shape = q : B === "pointCloud" ? w.pointCloud = q : B === "idleAnimation" ? w.idleAnimation = q : B === "monoAnimation" && (w.monoAnimation = q), this.characterAssets.set(B, q), v(ie, !0), { key: B, success: !0 };
|
|
4094
|
+
} catch (q) {
|
|
4045
4095
|
if (!Le)
|
|
4046
|
-
throw
|
|
4047
|
-
return h.warn(`⚠️ Optional resource ${ie} failed to load:`,
|
|
4096
|
+
throw q;
|
|
4097
|
+
return h.warn(`⚠️ Optional resource ${ie} failed to load:`, q), v(ie, !0), { key: B, success: !1 };
|
|
4048
4098
|
}
|
|
4049
4099
|
});
|
|
4050
|
-
if (await Promise.all(y), n &&
|
|
4051
|
-
const
|
|
4052
|
-
throw
|
|
4100
|
+
if (await Promise.all(y), n && p && (w.monoAudioUrl = p), !w.shape || !w.pointCloud) {
|
|
4101
|
+
const B = "Failed to load character data";
|
|
4102
|
+
throw S.logEvent("character_load", "error", {
|
|
4053
4103
|
characterId: e.characterId ?? "unknown",
|
|
4054
4104
|
stage: "download",
|
|
4055
|
-
reason:
|
|
4056
|
-
}), new Error(
|
|
4105
|
+
reason: B
|
|
4106
|
+
}), new Error(B);
|
|
4057
4107
|
}
|
|
4058
4108
|
return w;
|
|
4059
4109
|
}
|
|
@@ -4061,19 +4111,19 @@ class Ci {
|
|
|
4061
4111
|
* Preload all resources (template + character data + camera info + settings)
|
|
4062
4112
|
*/
|
|
4063
4113
|
async preloadResources(e, t) {
|
|
4064
|
-
const { loadMonologue: n = !1, progressCallback: i = null } = t || {}, [a, o,
|
|
4065
|
-
this.loadTemplateResources(e.flame, (
|
|
4114
|
+
const { loadMonologue: n = !1, progressCallback: i = null } = t || {}, [a, o, l] = await Promise.all([
|
|
4115
|
+
this.loadTemplateResources(e.flame, (s) => {
|
|
4066
4116
|
i && i({
|
|
4067
|
-
...
|
|
4068
|
-
stage: `template-${
|
|
4117
|
+
...s,
|
|
4118
|
+
stage: `template-${s.stage}`
|
|
4069
4119
|
});
|
|
4070
4120
|
}),
|
|
4071
4121
|
this.loadCharacterData(e, {
|
|
4072
4122
|
loadMonologue: n,
|
|
4073
|
-
progressCallback: (
|
|
4123
|
+
progressCallback: (s) => {
|
|
4074
4124
|
i && i({
|
|
4075
|
-
...
|
|
4076
|
-
stage: `character-${
|
|
4125
|
+
...s,
|
|
4126
|
+
stage: `character-${s.stage}`
|
|
4077
4127
|
});
|
|
4078
4128
|
}
|
|
4079
4129
|
}),
|
|
@@ -4082,7 +4132,7 @@ class Ci {
|
|
|
4082
4132
|
return {
|
|
4083
4133
|
templateResources: a,
|
|
4084
4134
|
characterData: o,
|
|
4085
|
-
preloadCameraSettings:
|
|
4135
|
+
preloadCameraSettings: l,
|
|
4086
4136
|
characterSettings: e.characterSettings
|
|
4087
4137
|
};
|
|
4088
4138
|
}
|
|
@@ -4106,22 +4156,25 @@ class Ci {
|
|
|
4106
4156
|
getSdkApiClient() {
|
|
4107
4157
|
return {
|
|
4108
4158
|
async request(e, t = {}) {
|
|
4109
|
-
const a =
|
|
4159
|
+
const a = S.getEnvironmentConfig().sdkApiBaseUrl + e, o = {
|
|
4160
|
+
"Content-Type": "application/json"
|
|
4161
|
+
}, l = S.appId, s = S.sessionToken;
|
|
4162
|
+
l && (o["X-App-Id"] = l), s && (o.Authorization = `Bearer ${s}`);
|
|
4110
4163
|
try {
|
|
4111
|
-
const
|
|
4164
|
+
const p = await fetch(a, {
|
|
4112
4165
|
method: t.method || "GET",
|
|
4113
4166
|
headers: {
|
|
4114
|
-
|
|
4167
|
+
...o,
|
|
4115
4168
|
...t.headers
|
|
4116
4169
|
},
|
|
4117
4170
|
body: t.body ? JSON.stringify(t.body) : void 0
|
|
4118
4171
|
});
|
|
4119
|
-
if (!
|
|
4120
|
-
throw new Error(`HTTP ${
|
|
4121
|
-
return
|
|
4122
|
-
} catch (
|
|
4123
|
-
const
|
|
4124
|
-
throw new Error(`[SdkApiClient] ${a} → ${
|
|
4172
|
+
if (!p.ok)
|
|
4173
|
+
throw new Error(`HTTP ${p.status} ${p.statusText}`);
|
|
4174
|
+
return p.json();
|
|
4175
|
+
} catch (p) {
|
|
4176
|
+
const c = nr(p);
|
|
4177
|
+
throw new Error(`[SdkApiClient] ${a} → ${c}`);
|
|
4125
4178
|
}
|
|
4126
4179
|
}
|
|
4127
4180
|
};
|
|
@@ -4141,7 +4194,7 @@ class Ci {
|
|
|
4141
4194
|
} catch (n) {
|
|
4142
4195
|
h.errorWithError("Failed to fetch character:", n);
|
|
4143
4196
|
const i = n && typeof n == "object" && "message" in n ? String(n.message) : "Failed to fetch character", a = n && typeof n == "object" && "data" in n && typeof n.data == "object" && ((t = n.data) != null && t.message) ? String(n.data.message) : null;
|
|
4144
|
-
throw
|
|
4197
|
+
throw S.logEvent("character_load", "error", {
|
|
4145
4198
|
characterId: e ?? "unknown",
|
|
4146
4199
|
stage: "fetch",
|
|
4147
4200
|
reason: a || i
|
|
@@ -4170,32 +4223,32 @@ const Re = class Re {
|
|
|
4170
4223
|
async load(e, t, n) {
|
|
4171
4224
|
h.log(`[AvatarManager] Loading avatar with id: ${e}`);
|
|
4172
4225
|
try {
|
|
4173
|
-
if (!
|
|
4226
|
+
if (!S.isInitialized)
|
|
4174
4227
|
throw new Error("AvatarKit not initialized. Please call AvatarKit.initialize() first.");
|
|
4175
4228
|
this.avatarDownloader || (this.avatarDownloader = new Ci()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: oe.downloading, progress: 10 });
|
|
4176
4229
|
const i = await this.avatarDownloader.getCharacterById(e);
|
|
4177
4230
|
h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: oe.downloading, progress: 30 });
|
|
4178
4231
|
const a = await this.avatarDownloader.preloadResources(i, {
|
|
4179
4232
|
loadMonologue: (n == null ? void 0 : n.enableMonologue) ?? !1,
|
|
4180
|
-
progressCallback: (
|
|
4181
|
-
const
|
|
4233
|
+
progressCallback: (s) => {
|
|
4234
|
+
const p = 30 + s.progress / 100 * 50;
|
|
4182
4235
|
t == null || t({
|
|
4183
4236
|
type: oe.downloading,
|
|
4184
|
-
progress: Math.round(
|
|
4237
|
+
progress: Math.round(p)
|
|
4185
4238
|
});
|
|
4186
4239
|
}
|
|
4187
|
-
}), o =
|
|
4240
|
+
}), o = S.getAvatarCore();
|
|
4188
4241
|
if (!o)
|
|
4189
4242
|
throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
|
|
4190
4243
|
this._templateInitialized ? h.log("[AvatarManager] WASM Core template resources already initialized, skipping...") : (h.log("[AvatarManager] Step 3: Initializing WASM Core template resources (first time)..."), t == null || t({ type: oe.downloading, progress: 80 }), await o.loadTemplateResourcesFromBuffers(a.templateResources), this._templateInitialized = !0, h.log("[AvatarManager] WASM Core template resources initialized successfully")), h.log("[AvatarManager] Step 4: Creating Avatar instance...");
|
|
4191
|
-
const
|
|
4192
|
-
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: oe.completed }),
|
|
4244
|
+
const l = new rn(e, i, a);
|
|
4245
|
+
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: oe.completed }), S.logEvent("character_load", "info", {
|
|
4193
4246
|
characterId: e,
|
|
4194
4247
|
event: "load_success"
|
|
4195
|
-
}),
|
|
4248
|
+
}), l;
|
|
4196
4249
|
} catch (i) {
|
|
4197
4250
|
const a = i instanceof Error ? i.message : String(i);
|
|
4198
|
-
throw h.error("Failed to load avatar:", a),
|
|
4251
|
+
throw h.error("Failed to load avatar:", a), S.logEvent("character_load", "error", {
|
|
4199
4252
|
characterId: e,
|
|
4200
4253
|
reason: a
|
|
4201
4254
|
}), t == null || t({ type: oe.failed, error: i }), i;
|
|
@@ -4210,38 +4263,38 @@ const Re = class Re {
|
|
|
4210
4263
|
};
|
|
4211
4264
|
d(Re, "_instance", null);
|
|
4212
4265
|
let Tt = Re, ye = null, Bt = null, Dt = null, Ot = null, Nt = null, Ut = null;
|
|
4213
|
-
const
|
|
4266
|
+
const Xe = 2048, zt = Xe - 1;
|
|
4214
4267
|
function _i(r, e, t) {
|
|
4215
4268
|
const i = r.length / 13;
|
|
4216
|
-
(!ye || ye.length !== i) && (ye = new Float32Array(i), Bt = new Uint32Array(ye.buffer), Dt = new Uint32Array(i), Ot = new Uint32Array(i), Nt = new Uint32Array(i), Ut = new Uint32Array(
|
|
4217
|
-
const a = ye, o = Bt,
|
|
4218
|
-
for (let
|
|
4219
|
-
const L =
|
|
4220
|
-
a[
|
|
4221
|
-
}
|
|
4222
|
-
for (let
|
|
4223
|
-
const L = o[
|
|
4224
|
-
o[
|
|
4225
|
-
}
|
|
4226
|
-
qe(o,
|
|
4227
|
-
for (let
|
|
4228
|
-
|
|
4229
|
-
return
|
|
4269
|
+
(!ye || ye.length !== i) && (ye = new Float32Array(i), Bt = new Uint32Array(ye.buffer), Dt = new Uint32Array(i), Ot = new Uint32Array(i), Nt = new Uint32Array(i), Ut = new Uint32Array(Xe));
|
|
4270
|
+
const a = ye, o = Bt, l = Dt, s = Ot, p = Nt, c = Ut, u = e[0], m = e[1], v = e[2], w = t[0], y = t[1], b = t[2];
|
|
4271
|
+
for (let I = 0; I < i; I++) {
|
|
4272
|
+
const L = I * 13;
|
|
4273
|
+
a[I] = (r[L] - u) * w + (r[L + 1] - m) * y + (r[L + 2] - v) * b, l[I] = I;
|
|
4274
|
+
}
|
|
4275
|
+
for (let I = 0; I < i; I++) {
|
|
4276
|
+
const L = o[I];
|
|
4277
|
+
o[I] = L ^ (-(L >> 31) | 2147483648);
|
|
4278
|
+
}
|
|
4279
|
+
qe(o, l, s, c, 0, i), qe(o, s, l, c, 11, i), qe(o, l, s, c, 22, i);
|
|
4280
|
+
for (let I = 0; I < i; I++)
|
|
4281
|
+
p[I] = s[i - 1 - I];
|
|
4282
|
+
return p;
|
|
4230
4283
|
}
|
|
4231
4284
|
function qe(r, e, t, n, i, a) {
|
|
4232
4285
|
n.fill(0);
|
|
4233
|
-
for (let
|
|
4234
|
-
const
|
|
4235
|
-
n[
|
|
4286
|
+
for (let l = 0; l < a; l++) {
|
|
4287
|
+
const s = r[e[l]] >> i & zt;
|
|
4288
|
+
n[s]++;
|
|
4236
4289
|
}
|
|
4237
4290
|
let o = 0;
|
|
4238
|
-
for (let
|
|
4239
|
-
const
|
|
4240
|
-
n[
|
|
4291
|
+
for (let l = 0; l < Xe; l++) {
|
|
4292
|
+
const s = n[l];
|
|
4293
|
+
n[l] = o, o += s;
|
|
4241
4294
|
}
|
|
4242
|
-
for (let
|
|
4243
|
-
const
|
|
4244
|
-
t[n[
|
|
4295
|
+
for (let l = 0; l < a; l++) {
|
|
4296
|
+
const s = e[l], p = r[s] >> i & zt;
|
|
4297
|
+
t[n[p]++] = s;
|
|
4245
4298
|
}
|
|
4246
4299
|
}
|
|
4247
4300
|
const Pe = 13;
|
|
@@ -4250,13 +4303,13 @@ function Ei(r, e) {
|
|
|
4250
4303
|
const t = e.length, n = t * Pe;
|
|
4251
4304
|
(!Ae || Ae.length !== n) && (Ae = new Float32Array(n));
|
|
4252
4305
|
for (let i = 0; i < t; i++) {
|
|
4253
|
-
const o = e[i] * Pe,
|
|
4254
|
-
for (let
|
|
4255
|
-
Ae[
|
|
4306
|
+
const o = e[i] * Pe, l = i * Pe;
|
|
4307
|
+
for (let s = 0; s < Pe; s++)
|
|
4308
|
+
Ae[l + s] = r[o + s];
|
|
4256
4309
|
}
|
|
4257
4310
|
return Ae;
|
|
4258
4311
|
}
|
|
4259
|
-
const
|
|
4312
|
+
const Ii = `#version 300 es
|
|
4260
4313
|
precision highp float;
|
|
4261
4314
|
|
|
4262
4315
|
in vec2 v_relativePosition;
|
|
@@ -4454,7 +4507,7 @@ void main() {
|
|
|
4454
4507
|
v_relativePosition = relativeCoord * BOUNDS_RADIUS;
|
|
4455
4508
|
v_color = a_color;
|
|
4456
4509
|
}`;
|
|
4457
|
-
class
|
|
4510
|
+
class xi {
|
|
4458
4511
|
// 跟踪当前 buffer 大小
|
|
4459
4512
|
constructor(e, t) {
|
|
4460
4513
|
d(this, "canvas");
|
|
@@ -4653,7 +4706,7 @@ class Ii {
|
|
|
4653
4706
|
const n = e.createShader(e.FRAGMENT_SHADER);
|
|
4654
4707
|
if (!n)
|
|
4655
4708
|
throw e.deleteShader(t), new Error("Failed to create fragment shader");
|
|
4656
|
-
if (e.shaderSource(n,
|
|
4709
|
+
if (e.shaderSource(n, Ii), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) {
|
|
4657
4710
|
const a = e.getShaderInfoLog(n);
|
|
4658
4711
|
throw e.deleteShader(t), e.deleteShader(n), new Error(`Fragment shader compilation failed: ${a}`);
|
|
4659
4712
|
}
|
|
@@ -5257,7 +5310,7 @@ class Fi {
|
|
|
5257
5310
|
} catch (i) {
|
|
5258
5311
|
h.warn("⚠️ WebGPU init failed, fallback to WebGL:", i);
|
|
5259
5312
|
}
|
|
5260
|
-
this.renderer = new
|
|
5313
|
+
this.renderer = new xi(this.canvas, t), await this.renderer.initialize(), this.backend = "webgl", h.log("✅ Using WebGL renderer"), this.updateCameraAspect();
|
|
5261
5314
|
}
|
|
5262
5315
|
/**
|
|
5263
5316
|
* Load packed Splat data (zero-copy, GPU format)
|
|
@@ -5305,7 +5358,7 @@ class Fi {
|
|
|
5305
5358
|
* Handle window resize
|
|
5306
5359
|
*/
|
|
5307
5360
|
handleResize() {
|
|
5308
|
-
this.updateCameraAspect();
|
|
5361
|
+
this.updateCameraAspect(), this.updateCameraMatrices();
|
|
5309
5362
|
}
|
|
5310
5363
|
/**
|
|
5311
5364
|
* 获取当前使用的后端
|
|
@@ -5368,8 +5421,8 @@ class Fi {
|
|
|
5368
5421
|
* Update perspective projection matrix (reuse buffer)
|
|
5369
5422
|
*/
|
|
5370
5423
|
updatePerspectiveMatrix(e, t, n, i) {
|
|
5371
|
-
const a = e * Math.PI / 180, o = 1 / Math.tan(a / 2),
|
|
5372
|
-
|
|
5424
|
+
const a = e * Math.PI / 180, o = 1 / Math.tan(a / 2), l = i / (n - i), s = this.projectionMatrix;
|
|
5425
|
+
s[0] = o / t, s[1] = 0, s[2] = 0, s[3] = 0, s[4] = 0, s[5] = o, s[6] = 0, s[7] = 0, s[8] = 0, s[9] = 0, s[10] = l, s[11] = -1, s[12] = 0, s[13] = 0, s[14] = l * n, s[15] = 0;
|
|
5373
5426
|
}
|
|
5374
5427
|
/**
|
|
5375
5428
|
* Update view matrix (directly update pre-allocated buffer to avoid per-frame allocation)
|
|
@@ -5387,14 +5440,14 @@ class Fi {
|
|
|
5387
5440
|
i[1] * n[2] - i[2] * n[1],
|
|
5388
5441
|
i[2] * n[0] - i[0] * n[2],
|
|
5389
5442
|
i[0] * n[1] - i[1] * n[0]
|
|
5390
|
-
],
|
|
5391
|
-
o[0] /=
|
|
5392
|
-
const
|
|
5443
|
+
], l = Math.hypot(o[0], o[1], o[2]) || 1;
|
|
5444
|
+
o[0] /= l, o[1] /= l, o[2] /= l;
|
|
5445
|
+
const s = [
|
|
5393
5446
|
o[1] * i[2] - o[2] * i[1],
|
|
5394
5447
|
o[2] * i[0] - o[0] * i[2],
|
|
5395
5448
|
o[0] * i[1] - o[1] * i[0]
|
|
5396
|
-
],
|
|
5397
|
-
|
|
5449
|
+
], p = this.viewMatrix, c = -e[0], u = -e[1], m = -e[2];
|
|
5450
|
+
p[0] = o[0], p[1] = s[0], p[2] = -i[0], p[3] = 0, p[4] = o[1], p[5] = s[1], p[6] = -i[1], p[7] = 0, p[8] = o[2], p[9] = s[2], p[10] = -i[2], p[11] = 0, p[12] = c, p[13] = u, p[14] = m, p[15] = 1;
|
|
5398
5451
|
}
|
|
5399
5452
|
}
|
|
5400
5453
|
function ae(r, e, t) {
|
|
@@ -5421,8 +5474,8 @@ function Ri(r, e, t) {
|
|
|
5421
5474
|
function Li(r, e, t, n = 25) {
|
|
5422
5475
|
const i = Math.max(1, Math.floor(t / 1e3 * n)), a = Array.from({ length: i });
|
|
5423
5476
|
for (let o = 0; o < i; o++) {
|
|
5424
|
-
const
|
|
5425
|
-
a[o] = Ri(r, e,
|
|
5477
|
+
const l = o / (i - 1);
|
|
5478
|
+
a[o] = Ri(r, e, l);
|
|
5426
5479
|
}
|
|
5427
5480
|
return a;
|
|
5428
5481
|
}
|
|
@@ -5471,10 +5524,10 @@ class Ni {
|
|
|
5471
5524
|
* 对齐两端 Flame 维度:标量统一长度,expression 取最大长度并零填充
|
|
5472
5525
|
*/
|
|
5473
5526
|
alignFlamePair(e, t) {
|
|
5474
|
-
const n = (
|
|
5475
|
-
const
|
|
5476
|
-
for (;
|
|
5477
|
-
return
|
|
5527
|
+
const n = (l, s) => {
|
|
5528
|
+
const p = Array.isArray(l) ? l.slice(0, s) : [];
|
|
5529
|
+
for (; p.length < s; ) p.push(0);
|
|
5530
|
+
return p;
|
|
5478
5531
|
}, i = {
|
|
5479
5532
|
translation: n(e == null ? void 0 : e.translation, 3),
|
|
5480
5533
|
rotation: n(e == null ? void 0 : e.rotation, 3),
|
|
@@ -5526,7 +5579,7 @@ class Ni {
|
|
|
5526
5579
|
*/
|
|
5527
5580
|
async getCachedIdleFirstFrame() {
|
|
5528
5581
|
if (!this.cachedIdleFirstFrame) {
|
|
5529
|
-
const e =
|
|
5582
|
+
const e = S.getAvatarCore();
|
|
5530
5583
|
if (e)
|
|
5531
5584
|
try {
|
|
5532
5585
|
const t = await e.getCurrentFrameParams(0);
|
|
@@ -5550,10 +5603,10 @@ class Ni {
|
|
|
5550
5603
|
const t = document.createElement("canvas");
|
|
5551
5604
|
let n = 800, i = 600;
|
|
5552
5605
|
e && e instanceof HTMLElement && (n = e.offsetWidth || 800, i = e.offsetHeight || 600);
|
|
5553
|
-
const a =
|
|
5554
|
-
return t.width = Math.floor(
|
|
5555
|
-
const
|
|
5556
|
-
t.width = Math.floor(
|
|
5606
|
+
const a = window.devicePixelRatio || 1;
|
|
5607
|
+
return t.width = Math.floor(n * a), t.height = Math.floor(i * a), t.style.width = `${n}px`, t.style.height = `${i}px`, t.style.display = "block", t.style.margin = "0 auto", t.style.position = "", t.style.top = "", t.style.left = "", t.style.zIndex = "", t.style.background = "none", t.style.border = "none", e && e instanceof HTMLElement ? (e.appendChild(t), e.style.display = "flex", e.style.justifyContent = "center", e.style.alignItems = "center", e.style.position = "relative", this.resizeObserver = new ResizeObserver(() => {
|
|
5608
|
+
const o = window.devicePixelRatio || 1, l = Math.floor(e.offsetWidth || 0), s = Math.floor(e.offsetHeight || 0);
|
|
5609
|
+
t.width = Math.floor(l * o), t.height = Math.floor(s * o), t.style.width = `${l}px`, t.style.height = `${s}px`, this.handleResize();
|
|
5557
5610
|
}), this.resizeObserver.observe(e)) : document.body.appendChild(t), window.addEventListener("resize", this.onWindowResize), t;
|
|
5558
5611
|
}
|
|
5559
5612
|
/**
|
|
@@ -5569,7 +5622,7 @@ class Ni {
|
|
|
5569
5622
|
async initializeView(e) {
|
|
5570
5623
|
try {
|
|
5571
5624
|
M.debug && h.log("[AvatarView] Initializing avatar view...");
|
|
5572
|
-
const t =
|
|
5625
|
+
const t = S.getAvatarCore();
|
|
5573
5626
|
if (!t)
|
|
5574
5627
|
throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
|
|
5575
5628
|
const n = e.getResources();
|
|
@@ -5604,8 +5657,8 @@ class Ni {
|
|
|
5604
5657
|
* 根据资源解析最终的相机配置,优先使用角色设置,其次 camera.json
|
|
5605
5658
|
*/
|
|
5606
5659
|
resolveCameraConfig(e) {
|
|
5607
|
-
var
|
|
5608
|
-
const t = this.getDefaultCameraConfig(), n = ((
|
|
5660
|
+
var l, s;
|
|
5661
|
+
const t = this.getDefaultCameraConfig(), n = ((l = e.characterSettings) == null ? void 0 : l.camera) ?? null, i = ((s = e.preloadCameraSettings) == null ? void 0 : s.camera) ?? null, a = n ?? i;
|
|
5609
5662
|
if (!a)
|
|
5610
5663
|
return h.warn("[AvatarView] Camera settings not found in resources, falling back to default camera config"), t;
|
|
5611
5664
|
const o = n ? "characterSettings" : "camera.json";
|
|
@@ -5615,40 +5668,40 @@ class Ni {
|
|
|
5615
5668
|
* 从角色设置中推导相机配置
|
|
5616
5669
|
*/
|
|
5617
5670
|
deriveCameraConfigFromSettings(e, t, n) {
|
|
5618
|
-
const i = (
|
|
5671
|
+
const i = (j, Y) => Number.isFinite(j) ? j : Y, a = i(e.translationX, t.position[0]), o = i(e.translationY, t.position[1]), l = i(e.translationZ, t.position[2]), s = i(e.rotation, 0), p = i(e.fovYRadians, 0), c = Math.hypot(a, o, l) > 1e-4, u = p > 0, m = Math.abs(s) > 1e-4;
|
|
5619
5672
|
if (!c && !u && !m)
|
|
5620
5673
|
return h.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
|
|
5621
|
-
const v = Math.sin(
|
|
5674
|
+
const v = Math.sin(s), w = Math.cos(s), y = c ? [a, o, l] : [...t.position], b = [
|
|
5622
5675
|
-v,
|
|
5623
5676
|
0,
|
|
5624
5677
|
-w
|
|
5625
|
-
],
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5678
|
+
], I = Math.hypot(b[0], b[1], b[2]) || 1, L = [
|
|
5679
|
+
b[0] / I,
|
|
5680
|
+
b[1] / I,
|
|
5681
|
+
b[2] / I
|
|
5629
5682
|
], _ = [
|
|
5630
5683
|
y[0] + L[0],
|
|
5631
5684
|
y[1] + L[1],
|
|
5632
5685
|
y[2] + L[2]
|
|
5633
|
-
],
|
|
5686
|
+
], X = [0, 1, 0], G = u ? p * 180 / Math.PI : t.fov, U = {
|
|
5634
5687
|
...t,
|
|
5635
5688
|
// 自动继承 near/far 等配置(来自 APP_CONFIG.camera)
|
|
5636
5689
|
position: y,
|
|
5637
5690
|
target: _,
|
|
5638
|
-
up:
|
|
5639
|
-
fov:
|
|
5691
|
+
up: X,
|
|
5692
|
+
fov: G
|
|
5640
5693
|
// near/far 从 fallback 继承,无需硬编码
|
|
5641
5694
|
};
|
|
5642
5695
|
return h.log("[AvatarView] Applied camera settings from resources", {
|
|
5643
5696
|
source: n,
|
|
5644
|
-
translation: [a, o,
|
|
5645
|
-
yawRadians:
|
|
5697
|
+
translation: [a, o, l],
|
|
5698
|
+
yawRadians: s,
|
|
5646
5699
|
position: y,
|
|
5647
5700
|
target: _,
|
|
5648
|
-
fov:
|
|
5649
|
-
near:
|
|
5650
|
-
far:
|
|
5651
|
-
}),
|
|
5701
|
+
fov: G,
|
|
5702
|
+
near: U.near,
|
|
5703
|
+
far: U.far
|
|
5704
|
+
}), U;
|
|
5652
5705
|
}
|
|
5653
5706
|
/**
|
|
5654
5707
|
* 渲染第一帧
|
|
@@ -5656,7 +5709,7 @@ class Ni {
|
|
|
5656
5709
|
async renderFirstFrame() {
|
|
5657
5710
|
if (!this.renderSystem)
|
|
5658
5711
|
throw new Error("Render system not initialized");
|
|
5659
|
-
const e =
|
|
5712
|
+
const e = S.getAvatarCore();
|
|
5660
5713
|
if (!e)
|
|
5661
5714
|
throw new Error("AvatarCore not available");
|
|
5662
5715
|
const t = {
|
|
@@ -5698,14 +5751,14 @@ class Ni {
|
|
|
5698
5751
|
return;
|
|
5699
5752
|
}
|
|
5700
5753
|
e = a;
|
|
5701
|
-
const o =
|
|
5754
|
+
const o = S.getAvatarCore();
|
|
5702
5755
|
if (!o)
|
|
5703
5756
|
return;
|
|
5704
|
-
const
|
|
5705
|
-
if (this.idleCurrentFrameIndex++,
|
|
5757
|
+
const l = await o.computeCompleteFrameFlat({ frameIndex: this.idleCurrentFrameIndex });
|
|
5758
|
+
if (this.idleCurrentFrameIndex++, l) {
|
|
5706
5759
|
if (this.renderingState !== "idle")
|
|
5707
5760
|
return;
|
|
5708
|
-
this.renderSystem.loadSplatsFromPackedData(
|
|
5761
|
+
this.renderSystem.loadSplatsFromPackedData(l), this.renderSystem.renderFrame();
|
|
5709
5762
|
}
|
|
5710
5763
|
this.idleAnimationLoopId = requestAnimationFrame(i);
|
|
5711
5764
|
} catch (o) {
|
|
@@ -5737,12 +5790,12 @@ class Ni {
|
|
|
5737
5790
|
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
5738
5791
|
return;
|
|
5739
5792
|
}
|
|
5740
|
-
const
|
|
5793
|
+
const l = performance.now() - this.transitionStartTime, s = Math.min(1, Math.max(0, l / this.transitionDurationMs)), p = this.transitionKeyframes.length, c = Math.min(p - 1, Math.floor(s * (p - 1))), u = this.transitionKeyframes[c], m = Vt(u), v = S.getAvatarCore();
|
|
5741
5794
|
if (v) {
|
|
5742
5795
|
const w = await v.computeFrameFlatFromParams(m);
|
|
5743
5796
|
w && (this.renderSystem.loadSplatsFromPackedData(w), this.renderSystem.renderFrame());
|
|
5744
5797
|
}
|
|
5745
|
-
if (
|
|
5798
|
+
if (s >= 1) {
|
|
5746
5799
|
if (o === "transitioningToSpeaking")
|
|
5747
5800
|
this.setState(
|
|
5748
5801
|
"speaking"
|
|
@@ -5868,7 +5921,7 @@ class Ni {
|
|
|
5868
5921
|
/* TransitioningToSpeaking */
|
|
5869
5922
|
);
|
|
5870
5923
|
try {
|
|
5871
|
-
const n =
|
|
5924
|
+
const n = S.getAvatarCore();
|
|
5872
5925
|
if (n && e.length > 0) {
|
|
5873
5926
|
if (this.renderingState !== "transitioningToSpeaking")
|
|
5874
5927
|
return;
|
|
@@ -5892,7 +5945,7 @@ class Ni {
|
|
|
5892
5945
|
* 开始实时渲染循环
|
|
5893
5946
|
*/
|
|
5894
5947
|
startRealtimeRendering() {
|
|
5895
|
-
M.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"),
|
|
5948
|
+
M.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"), S.logEvent("character_view", "info", {
|
|
5896
5949
|
characterId: this.avatar.id,
|
|
5897
5950
|
event: "rendering_started",
|
|
5898
5951
|
keyframesCount: this.currentKeyframes.length
|
|
@@ -5918,7 +5971,7 @@ class Ni {
|
|
|
5918
5971
|
try {
|
|
5919
5972
|
if (this.renderingState !== "transitioningToIdle")
|
|
5920
5973
|
return;
|
|
5921
|
-
if (
|
|
5974
|
+
if (S.getAvatarCore() && this.currentKeyframes.length > 0) {
|
|
5922
5975
|
const n = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], i = await this.getCachedIdleFirstFrame();
|
|
5923
5976
|
if (i && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(n, i), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
|
|
5924
5977
|
M.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
|
|
@@ -5940,14 +5993,14 @@ class Ni {
|
|
|
5940
5993
|
* 关闭 avatarController 并清理所有相关资源
|
|
5941
5994
|
*/
|
|
5942
5995
|
dispose() {
|
|
5943
|
-
M.debug && h.log("[AvatarView] Disposing avatar view..."),
|
|
5996
|
+
M.debug && h.log("[AvatarView] Disposing avatar view..."), S.logEvent("character_view", "info", {
|
|
5944
5997
|
characterId: this.avatar.id,
|
|
5945
5998
|
event: "disposed"
|
|
5946
5999
|
}), this.avatarController && (this.avatarController.clear(), this.avatarController.dispose()), this.stopAllAnimationLoops(), this.setState(
|
|
5947
6000
|
"idle"
|
|
5948
6001
|
/* Idle */
|
|
5949
6002
|
), this.cachedIdleFirstFrame = null, this.idleCurrentFrameIndex = 0;
|
|
5950
|
-
const e =
|
|
6003
|
+
const e = S.getAvatarCore();
|
|
5951
6004
|
if (e)
|
|
5952
6005
|
try {
|
|
5953
6006
|
e.releaseCurrentCharacter(), M.debug && h.log("[AvatarView] AvatarCore character resources released");
|
|
@@ -5997,17 +6050,17 @@ export {
|
|
|
5997
6050
|
oe as L,
|
|
5998
6051
|
nn as R,
|
|
5999
6052
|
se as S,
|
|
6000
|
-
|
|
6053
|
+
S as a,
|
|
6001
6054
|
rn as b,
|
|
6002
6055
|
Si as c,
|
|
6003
6056
|
Tt as d,
|
|
6004
6057
|
nr as e,
|
|
6005
6058
|
Ni as f,
|
|
6006
|
-
|
|
6059
|
+
T as g,
|
|
6007
6060
|
ke as h,
|
|
6008
6061
|
Bi as i,
|
|
6009
6062
|
Di as j,
|
|
6010
6063
|
Oi as k,
|
|
6011
6064
|
h as l
|
|
6012
6065
|
};
|
|
6013
|
-
//# sourceMappingURL=index-
|
|
6066
|
+
//# sourceMappingURL=index-Bh6KkhoR.js.map
|