@spatialwalk/avatarkit 1.0.0-beta.20 → 1.0.0-beta.21
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 +15 -0
- package/README.md +6 -4
- package/dist/{StreamingAudioPlayer-Dv4D0GIN.js → StreamingAudioPlayer-DEXcuhRW.js} +2 -2
- package/dist/{StreamingAudioPlayer-Dv4D0GIN.js.map → StreamingAudioPlayer-DEXcuhRW.js.map} +1 -1
- package/dist/core/AvatarController.d.ts.map +1 -1
- package/dist/{index-Cm5BwNVd.js → index-ChKhyUK4.js} +873 -831
- package/dist/index-ChKhyUK4.js.map +1 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/index-Cm5BwNVd.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var nn = Object.defineProperty;
|
|
2
2
|
var an = (r, e, t) => e in r ? nn(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
-
var
|
|
4
|
-
class
|
|
3
|
+
var u = (r, e, t) => an(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
class on {
|
|
5
5
|
/**
|
|
6
6
|
* 构造函数(内部使用)
|
|
7
7
|
* @param id 数字人 ID
|
|
@@ -9,9 +9,9 @@ class sn {
|
|
|
9
9
|
* @param resources 资源数据
|
|
10
10
|
*/
|
|
11
11
|
constructor(e, t, n) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
u(this, "id");
|
|
13
|
+
u(this, "characterMeta");
|
|
14
|
+
u(this, "resources");
|
|
15
15
|
this.id = e, this.characterMeta = t, this.resources = n;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -29,23 +29,23 @@ class sn {
|
|
|
29
29
|
return this.resources;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
var
|
|
32
|
+
var sn = /* @__PURE__ */ ((r) => (r.CAMERA = "camera", r.ANIMATION_IDLE = "frameIdle", r.MODEL_SHAPE = "shape", r.MODEL_GS = "gsStandard", r))(sn || {});
|
|
33
33
|
function Na(r) {
|
|
34
|
-
var e, t, n, a, i,
|
|
34
|
+
var e, t, n, a, i, o, s, l, p, c, d;
|
|
35
35
|
return {
|
|
36
36
|
camera: ((t = (e = r.camera) == null ? void 0 : e.resource) == null ? void 0 : t.remote) || null,
|
|
37
37
|
frameIdle: ((i = (a = (n = r.animations) == null ? void 0 : n.frameIdle) == null ? void 0 : a.resource) == null ? void 0 : i.remote) || null,
|
|
38
|
-
shape: ((l = (
|
|
39
|
-
gsStandard: ((
|
|
38
|
+
shape: ((l = (s = (o = r.models) == null ? void 0 : o.shape) == null ? void 0 : s.resource) == null ? void 0 : l.remote) || null,
|
|
39
|
+
gsStandard: ((d = (c = (p = r.models) == null ? void 0 : p.gsStandard) == null ? void 0 : c.resource) == null ? void 0 : d.remote) || null
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
var
|
|
43
|
-
class
|
|
42
|
+
var oe = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(oe || {}), ze = /* @__PURE__ */ ((r) => (r.sdk = "sdk", r.host = "host", r))(ze || {}), ce = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(ce || {}), ee = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(ee || {}), M = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(M || {});
|
|
43
|
+
class H extends Error {
|
|
44
44
|
constructor(e, t) {
|
|
45
45
|
super(e), this.code = t, this.name = "SPAvatarError";
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
var
|
|
48
|
+
var pe = /* @__PURE__ */ ((r) => (r.network = "network", r.external = "external", r))(pe || {});
|
|
49
49
|
function ln() {
|
|
50
50
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("debug") === "1";
|
|
51
51
|
}
|
|
@@ -131,13 +131,13 @@ function un() {
|
|
|
131
131
|
return this[A];
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
var i = ["isConstructor", "isEval", "isNative", "isToplevel"],
|
|
135
|
-
function
|
|
134
|
+
var i = ["isConstructor", "isEval", "isNative", "isToplevel"], o = ["columnNumber", "lineNumber"], s = ["fileName", "functionName", "source"], l = ["args"], p = ["evalOrigin"], c = i.concat(o, s, l, p);
|
|
135
|
+
function d(A) {
|
|
136
136
|
if (A)
|
|
137
|
-
for (var
|
|
138
|
-
A[c[
|
|
137
|
+
for (var S = 0; S < c.length; S++)
|
|
138
|
+
A[c[S]] !== void 0 && this["set" + n(c[S])](A[c[S]]);
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
d.prototype = {
|
|
141
141
|
getArgs: function() {
|
|
142
142
|
return this.args;
|
|
143
143
|
},
|
|
@@ -150,50 +150,50 @@ function un() {
|
|
|
150
150
|
return this.evalOrigin;
|
|
151
151
|
},
|
|
152
152
|
setEvalOrigin: function(A) {
|
|
153
|
-
if (A instanceof
|
|
153
|
+
if (A instanceof d)
|
|
154
154
|
this.evalOrigin = A;
|
|
155
155
|
else if (A instanceof Object)
|
|
156
|
-
this.evalOrigin = new
|
|
156
|
+
this.evalOrigin = new d(A);
|
|
157
157
|
else
|
|
158
158
|
throw new TypeError("Eval Origin must be an Object or StackFrame");
|
|
159
159
|
},
|
|
160
160
|
toString: function() {
|
|
161
|
-
var A = this.getFileName() || "",
|
|
162
|
-
return this.getIsEval() ? A ? "[eval] (" + A + ":" +
|
|
161
|
+
var A = this.getFileName() || "", S = this.getLineNumber() || "", P = this.getColumnNumber() || "", B = this.getFunctionName() || "";
|
|
162
|
+
return this.getIsEval() ? A ? "[eval] (" + A + ":" + S + ":" + P + ")" : "[eval]:" + S + ":" + P : B ? B + " (" + A + ":" + S + ":" + P + ")" : A + ":" + S + ":" + P;
|
|
163
163
|
}
|
|
164
|
-
},
|
|
165
|
-
var
|
|
164
|
+
}, d.fromString = function(S) {
|
|
165
|
+
var P = S.indexOf("("), B = S.lastIndexOf(")"), _ = S.substring(0, P), Y = S.substring(P + 1, B).split(","), G = S.substring(B + 1);
|
|
166
166
|
if (G.indexOf("@") === 0)
|
|
167
|
-
var R = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""), z = R[1], W = R[2],
|
|
168
|
-
return new
|
|
167
|
+
var R = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""), z = R[1], W = R[2], Z = R[3];
|
|
168
|
+
return new d({
|
|
169
169
|
functionName: _,
|
|
170
|
-
args:
|
|
170
|
+
args: Y || void 0,
|
|
171
171
|
fileName: z,
|
|
172
172
|
lineNumber: W || void 0,
|
|
173
|
-
columnNumber:
|
|
173
|
+
columnNumber: Z || void 0
|
|
174
174
|
});
|
|
175
175
|
};
|
|
176
176
|
for (var m = 0; m < i.length; m++)
|
|
177
|
-
|
|
178
|
-
return function(
|
|
179
|
-
this[A] = !!
|
|
177
|
+
d.prototype["get" + n(i[m])] = a(i[m]), d.prototype["set" + n(i[m])] = /* @__PURE__ */ function(A) {
|
|
178
|
+
return function(S) {
|
|
179
|
+
this[A] = !!S;
|
|
180
180
|
};
|
|
181
181
|
}(i[m]);
|
|
182
|
-
for (var v = 0; v <
|
|
183
|
-
|
|
184
|
-
return function(
|
|
185
|
-
if (!t(
|
|
182
|
+
for (var v = 0; v < o.length; v++)
|
|
183
|
+
d.prototype["get" + n(o[v])] = a(o[v]), d.prototype["set" + n(o[v])] = /* @__PURE__ */ function(A) {
|
|
184
|
+
return function(S) {
|
|
185
|
+
if (!t(S))
|
|
186
186
|
throw new TypeError(A + " must be a Number");
|
|
187
|
-
this[A] = Number(
|
|
187
|
+
this[A] = Number(S);
|
|
188
188
|
};
|
|
189
|
-
}(
|
|
190
|
-
for (var
|
|
191
|
-
|
|
192
|
-
return function(
|
|
193
|
-
this[A] = String(
|
|
189
|
+
}(o[v]);
|
|
190
|
+
for (var b = 0; b < s.length; b++)
|
|
191
|
+
d.prototype["get" + n(s[b])] = a(s[b]), d.prototype["set" + n(s[b])] = /* @__PURE__ */ function(A) {
|
|
192
|
+
return function(S) {
|
|
193
|
+
this[A] = String(S);
|
|
194
194
|
};
|
|
195
|
-
}(
|
|
196
|
-
return
|
|
195
|
+
}(s[b]);
|
|
196
|
+
return d;
|
|
197
197
|
});
|
|
198
198
|
}(Re)), Re.exports;
|
|
199
199
|
}
|
|
@@ -201,7 +201,7 @@ function un() {
|
|
|
201
201
|
(function(t, n) {
|
|
202
202
|
r.exports = n(un());
|
|
203
203
|
})($t, function(n) {
|
|
204
|
-
var a = /(^|@)\S+:\d+/, i = /^\s*at .*(\S+:\d+|\(native\))/m,
|
|
204
|
+
var a = /(^|@)\S+:\d+/, i = /^\s*at .*(\S+:\d+|\(native\))/m, o = /^(eval@)?(\[native code])?$/;
|
|
205
205
|
return {
|
|
206
206
|
/**
|
|
207
207
|
* Given an Error object, extract the most information from it.
|
|
@@ -232,11 +232,11 @@ function un() {
|
|
|
232
232
|
}, this);
|
|
233
233
|
return p.map(function(c) {
|
|
234
234
|
c.indexOf("(eval ") > -1 && (c = c.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
|
|
235
|
-
var
|
|
236
|
-
|
|
237
|
-
var v = this.extractLocation(m ? m[1] :
|
|
235
|
+
var d = c.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), m = d.match(/ (\(.+\)$)/);
|
|
236
|
+
d = m ? d.replace(m[0], "") : d;
|
|
237
|
+
var v = this.extractLocation(m ? m[1] : d), b = m && d || void 0, A = ["eval", "<anonymous>"].indexOf(v[0]) > -1 ? void 0 : v[0];
|
|
238
238
|
return new n({
|
|
239
|
-
functionName:
|
|
239
|
+
functionName: b,
|
|
240
240
|
fileName: A,
|
|
241
241
|
lineNumber: v[1],
|
|
242
242
|
columnNumber: v[2],
|
|
@@ -247,19 +247,19 @@ function un() {
|
|
|
247
247
|
parseFFOrSafari: function(l) {
|
|
248
248
|
var p = l.stack.split(`
|
|
249
249
|
`).filter(function(c) {
|
|
250
|
-
return !c.match(
|
|
250
|
+
return !c.match(o);
|
|
251
251
|
}, this);
|
|
252
252
|
return p.map(function(c) {
|
|
253
253
|
if (c.indexOf(" > eval") > -1 && (c = c.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), c.indexOf("@") === -1 && c.indexOf(":") === -1)
|
|
254
254
|
return new n({
|
|
255
255
|
functionName: c
|
|
256
256
|
});
|
|
257
|
-
var
|
|
257
|
+
var d = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(d), v = m && m[1] ? m[1] : void 0, b = this.extractLocation(c.replace(d, ""));
|
|
258
258
|
return new n({
|
|
259
259
|
functionName: v,
|
|
260
|
-
fileName:
|
|
261
|
-
lineNumber:
|
|
262
|
-
columnNumber:
|
|
260
|
+
fileName: b[0],
|
|
261
|
+
lineNumber: b[1],
|
|
262
|
+
columnNumber: b[2],
|
|
263
263
|
source: c
|
|
264
264
|
});
|
|
265
265
|
}, this);
|
|
@@ -272,30 +272,30 @@ function un() {
|
|
|
272
272
|
},
|
|
273
273
|
parseOpera9: function(l) {
|
|
274
274
|
for (var p = /Line (\d+).*script (?:in )?(\S+)/i, c = l.message.split(`
|
|
275
|
-
`),
|
|
276
|
-
var
|
|
277
|
-
|
|
278
|
-
fileName:
|
|
279
|
-
lineNumber:
|
|
275
|
+
`), d = [], m = 2, v = c.length; m < v; m += 2) {
|
|
276
|
+
var b = p.exec(c[m]);
|
|
277
|
+
b && d.push(new n({
|
|
278
|
+
fileName: b[2],
|
|
279
|
+
lineNumber: b[1],
|
|
280
280
|
source: c[m]
|
|
281
281
|
}));
|
|
282
282
|
}
|
|
283
|
-
return
|
|
283
|
+
return d;
|
|
284
284
|
},
|
|
285
285
|
parseOpera10: function(l) {
|
|
286
286
|
for (var p = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, c = l.stacktrace.split(`
|
|
287
|
-
`),
|
|
288
|
-
var
|
|
289
|
-
|
|
287
|
+
`), d = [], m = 0, v = c.length; m < v; m += 2) {
|
|
288
|
+
var b = p.exec(c[m]);
|
|
289
|
+
b && d.push(
|
|
290
290
|
new n({
|
|
291
|
-
functionName:
|
|
292
|
-
fileName:
|
|
293
|
-
lineNumber:
|
|
291
|
+
functionName: b[3] || void 0,
|
|
292
|
+
fileName: b[2],
|
|
293
|
+
lineNumber: b[1],
|
|
294
294
|
source: c[m]
|
|
295
295
|
})
|
|
296
296
|
);
|
|
297
297
|
}
|
|
298
|
-
return
|
|
298
|
+
return d;
|
|
299
299
|
},
|
|
300
300
|
// Opera 10.65+ Error.stack very similar to FF/Safari
|
|
301
301
|
parseOpera11: function(l) {
|
|
@@ -304,12 +304,12 @@ function un() {
|
|
|
304
304
|
return !!c.match(a) && !c.match(/^Error created at/);
|
|
305
305
|
}, this);
|
|
306
306
|
return p.map(function(c) {
|
|
307
|
-
var
|
|
307
|
+
var d = c.split("@"), m = this.extractLocation(d.pop()), v = d.shift() || "", b = v.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, A;
|
|
308
308
|
v.match(/\(([^)]*)\)/) && (A = v.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
|
|
309
|
-
var
|
|
309
|
+
var S = A === void 0 || A === "[arguments not available]" ? void 0 : A.split(",");
|
|
310
310
|
return new n({
|
|
311
|
-
functionName:
|
|
312
|
-
args:
|
|
311
|
+
functionName: b,
|
|
312
|
+
args: S,
|
|
313
313
|
fileName: m[0],
|
|
314
314
|
lineNumber: m[1],
|
|
315
315
|
columnNumber: m[2],
|
|
@@ -326,110 +326,110 @@ let mt = () => {
|
|
|
326
326
|
var r = (() => {
|
|
327
327
|
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, a = Object.prototype.hasOwnProperty, i = (f, g) => {
|
|
328
328
|
for (var w in g) e(f, w, { get: g[w], enumerable: !0 });
|
|
329
|
-
},
|
|
330
|
-
if (g && typeof g == "object" || typeof g == "function") for (let
|
|
329
|
+
}, o = (f, g, w, C) => {
|
|
330
|
+
if (g && typeof g == "object" || typeof g == "function") for (let E of n(g)) !a.call(f, E) && E !== w && e(f, E, { get: () => g[E], enumerable: !(C = t(g, E)) || C.enumerable });
|
|
331
331
|
return f;
|
|
332
|
-
},
|
|
332
|
+
}, s = (f) => o(e({}, "__esModule", { value: !0 }), f), l = {};
|
|
333
333
|
i(l, { default: () => tn });
|
|
334
|
-
var p = (f) => Array.isArray(f), c = (f) => typeof f == "function",
|
|
334
|
+
var p = (f) => Array.isArray(f), c = (f) => typeof f == "function", d = (f) => f.length === 0, m = (f) => typeof f == "number", v = (f) => typeof f == "object" && f !== null, b = (f) => f instanceof RegExp, A = (f) => typeof f == "string", S = (f) => f === void 0, P = (f) => {
|
|
335
335
|
const g = /* @__PURE__ */ new Map();
|
|
336
336
|
return (w) => {
|
|
337
337
|
const C = g.get(w);
|
|
338
338
|
if (C) return C;
|
|
339
|
-
const
|
|
340
|
-
return g.set(w,
|
|
339
|
+
const E = f(w);
|
|
340
|
+
return g.set(w, E), E;
|
|
341
341
|
};
|
|
342
342
|
}, B = (f, g, w = {}) => {
|
|
343
343
|
const C = { cache: {}, input: f, index: 0, indexMax: 0, options: w, output: [] };
|
|
344
|
-
if (
|
|
344
|
+
if (J(g)(C) && C.index === f.length) return C.output;
|
|
345
345
|
throw new Error(`Failed to parse at index ${C.indexMax}`);
|
|
346
|
-
}, _ = (f, g) => p(f) ?
|
|
346
|
+
}, _ = (f, g) => p(f) ? Y(f, g) : A(f) ? R(f, g) : G(f, g), Y = (f, g) => {
|
|
347
347
|
const w = {};
|
|
348
348
|
for (const C of f) {
|
|
349
349
|
if (C.length !== 1) throw new Error(`Invalid character: "${C}"`);
|
|
350
|
-
const
|
|
351
|
-
w[
|
|
350
|
+
const E = C.charCodeAt(0);
|
|
351
|
+
w[E] = !0;
|
|
352
352
|
}
|
|
353
353
|
return (C) => {
|
|
354
|
-
const
|
|
354
|
+
const E = C.index, I = C.input;
|
|
355
355
|
for (; C.index < I.length && I.charCodeAt(C.index) in w; ) C.index += 1;
|
|
356
356
|
const T = C.index;
|
|
357
|
-
if (T >
|
|
358
|
-
if (!
|
|
359
|
-
const $ = C.input.slice(
|
|
360
|
-
|
|
357
|
+
if (T > E) {
|
|
358
|
+
if (!S(g) && !C.options.silent) {
|
|
359
|
+
const $ = C.input.slice(E, T), q = c(g) ? g($, I, String(E)) : g;
|
|
360
|
+
S(q) || C.output.push(q);
|
|
361
361
|
}
|
|
362
362
|
C.indexMax = Math.max(C.indexMax, C.index);
|
|
363
363
|
}
|
|
364
364
|
return !0;
|
|
365
365
|
};
|
|
366
366
|
}, G = (f, g) => {
|
|
367
|
-
const w = f.source, C = f.flags.replace(/y|$/, "y"),
|
|
368
|
-
return
|
|
369
|
-
|
|
370
|
-
const T =
|
|
367
|
+
const w = f.source, C = f.flags.replace(/y|$/, "y"), E = new RegExp(w, C);
|
|
368
|
+
return Se((I) => {
|
|
369
|
+
E.lastIndex = I.index;
|
|
370
|
+
const T = E.exec(I.input);
|
|
371
371
|
if (T) {
|
|
372
|
-
if (!
|
|
372
|
+
if (!S(g) && !I.options.silent) {
|
|
373
373
|
const $ = c(g) ? g(...T, I.input, String(I.index)) : g;
|
|
374
|
-
|
|
374
|
+
S($) || I.output.push($);
|
|
375
375
|
}
|
|
376
376
|
return I.index += T[0].length, I.indexMax = Math.max(I.indexMax, I.index), !0;
|
|
377
377
|
} else return !1;
|
|
378
378
|
});
|
|
379
379
|
}, R = (f, g) => (w) => {
|
|
380
380
|
if (w.input.startsWith(f, w.index)) {
|
|
381
|
-
if (!
|
|
381
|
+
if (!S(g) && !w.options.silent) {
|
|
382
382
|
const C = c(g) ? g(f, w.input, String(w.index)) : g;
|
|
383
|
-
|
|
383
|
+
S(C) || w.output.push(C);
|
|
384
384
|
}
|
|
385
385
|
return w.index += f.length, w.indexMax = Math.max(w.indexMax, w.index), !0;
|
|
386
386
|
} else return !1;
|
|
387
387
|
}, z = (f, g, w, C) => {
|
|
388
|
-
const
|
|
389
|
-
return
|
|
388
|
+
const E = J(f);
|
|
389
|
+
return Se(xe(Xe((I) => {
|
|
390
390
|
let T = 0;
|
|
391
391
|
for (; T < w; ) {
|
|
392
392
|
const $ = I.index;
|
|
393
|
-
if (!
|
|
393
|
+
if (!E(I) || (T += 1, I.index === $)) break;
|
|
394
394
|
}
|
|
395
395
|
return T >= g;
|
|
396
396
|
})));
|
|
397
|
-
}, W = (f, g) => z(f, 0, 1),
|
|
398
|
-
const w = f.map(
|
|
399
|
-
return
|
|
400
|
-
for (let
|
|
397
|
+
}, W = (f, g) => z(f, 0, 1), Z = (f, g) => z(f, 0, 1 / 0), V = (f, g) => {
|
|
398
|
+
const w = f.map(J);
|
|
399
|
+
return Se(xe(Xe((C) => {
|
|
400
|
+
for (let E = 0, I = w.length; E < I; E++) if (!w[E](C)) return !1;
|
|
401
401
|
return !0;
|
|
402
402
|
})));
|
|
403
|
-
},
|
|
404
|
-
const w = f.map(
|
|
405
|
-
return
|
|
406
|
-
for (let
|
|
403
|
+
}, K = (f, g) => {
|
|
404
|
+
const w = f.map(J);
|
|
405
|
+
return Se(xe((C) => {
|
|
406
|
+
for (let E = 0, I = w.length; E < I; E++) if (w[E](C)) return !0;
|
|
407
407
|
return !1;
|
|
408
408
|
}));
|
|
409
409
|
}, Xe = (f, g = !1) => {
|
|
410
|
-
const w =
|
|
410
|
+
const w = J(f);
|
|
411
411
|
return (C) => {
|
|
412
|
-
const
|
|
413
|
-
return (!T || g) && (C.index =
|
|
412
|
+
const E = C.index, I = C.output.length, T = w(C);
|
|
413
|
+
return (!T || g) && (C.index = E, C.output.length !== I && (C.output.length = I)), T;
|
|
414
414
|
};
|
|
415
|
-
}, xe = (f, g) =>
|
|
415
|
+
}, xe = (f, g) => J(f), Se = /* @__PURE__ */ (() => {
|
|
416
416
|
let f = 0;
|
|
417
417
|
return (g) => {
|
|
418
|
-
const w =
|
|
419
|
-
return (
|
|
418
|
+
const w = J(g), C = f += 1;
|
|
419
|
+
return (E) => {
|
|
420
420
|
var lt;
|
|
421
421
|
var I;
|
|
422
|
-
if (
|
|
423
|
-
const T =
|
|
422
|
+
if (E.options.memoization === !1) return w(E);
|
|
423
|
+
const T = E.index, $ = (I = E.cache)[C] || (I[C] = /* @__PURE__ */ new Map()), q = $.get(T);
|
|
424
424
|
if (q === !1) return !1;
|
|
425
|
-
if (m(q)) return
|
|
426
|
-
if (q) return
|
|
425
|
+
if (m(q)) return E.index = q, !0;
|
|
426
|
+
if (q) return E.index = q.index, (lt = q.output) != null && lt.length && E.output.push(...q.output), !0;
|
|
427
427
|
{
|
|
428
|
-
const ct =
|
|
429
|
-
if (w(
|
|
430
|
-
const dt =
|
|
428
|
+
const ct = E.output.length;
|
|
429
|
+
if (w(E)) {
|
|
430
|
+
const dt = E.index, ut = E.output.length;
|
|
431
431
|
if (ut > ct) {
|
|
432
|
-
const rn =
|
|
432
|
+
const rn = E.output.slice(ct, ut);
|
|
433
433
|
$.set(T, { index: dt, output: rn });
|
|
434
434
|
} else $.set(T, dt);
|
|
435
435
|
return !0;
|
|
@@ -439,14 +439,14 @@ let mt = () => {
|
|
|
439
439
|
};
|
|
440
440
|
})(), Ye = (f) => {
|
|
441
441
|
let g;
|
|
442
|
-
return (w) => (g || (g =
|
|
443
|
-
},
|
|
444
|
-
if (c(f)) return
|
|
445
|
-
if (A(f) ||
|
|
442
|
+
return (w) => (g || (g = J(f())), g(w));
|
|
443
|
+
}, J = P((f) => {
|
|
444
|
+
if (c(f)) return d(f) ? Ye(f) : f;
|
|
445
|
+
if (A(f) || b(f)) return _(f);
|
|
446
446
|
if (p(f)) return V(f);
|
|
447
|
-
if (v(f)) return
|
|
447
|
+
if (v(f)) return K(Object.values(f));
|
|
448
448
|
throw new Error("Invalid rule");
|
|
449
|
-
}), Ze = "abcdefghijklmnopqrstuvwxyz",
|
|
449
|
+
}), Ze = "abcdefghijklmnopqrstuvwxyz", or = (f) => {
|
|
450
450
|
let g = "";
|
|
451
451
|
for (; f > 0; ) {
|
|
452
452
|
const w = (f - 1) % 26;
|
|
@@ -462,18 +462,18 @@ let mt = () => {
|
|
|
462
462
|
const w = [];
|
|
463
463
|
for (; f <= g; ) w.push(f++);
|
|
464
464
|
return w;
|
|
465
|
-
},
|
|
465
|
+
}, sr = (f, g, w) => Fe(f, g).map((C) => String(C).padStart(w, "0")), Qe = (f, g) => Fe(Je(f), Je(g)).map(or), X = (f) => f, et = (f) => lr((g) => B(g, f, { memoization: !1 }).join("")), lr = (f) => {
|
|
466
466
|
const g = {};
|
|
467
467
|
return (w) => g[w] ?? (g[w] = f(w));
|
|
468
|
-
}, cr = _(/^\*\*\/\*$/, ".*"), dr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, w) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}`), ur = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, w, C) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Me = _(/\\./,
|
|
468
|
+
}, cr = _(/^\*\*\/\*$/, ".*"), dr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, w) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}`), ur = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, w, C) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Me = _(/\\./, X), hr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), fr = _(/./, X), mr = _(/^(?:!!)*!(.*)$/, (f, g) => `(?!^${st(g)}$).*?`), pr = _(/^(!!)+/, ""), gr = K([mr, pr]), vr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), yr = _(/^(\*\*\/)+/, "(?:^|.*/)"), wr = _(/\/(\*\*)$/, "(?:/.*|$)"), Ar = _(/\*\*/, ".*"), tt = K([vr, yr, wr, Ar]), br = _(/\*\/(?!\*\*\/)/, "[^/]*/"), Sr = _(/\*/, "[^/]*"), rt = K([br, Sr]), nt = _("?", "[^/]"), Cr = _("[", X), _r = _("]", X), Er = _(/[!^]/, "^/"), Pr = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, X), Ir = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), kr = _(/[^\]]/, X), xr = K([Me, Ir, Pr, kr]), at = V([Cr, W(Er), Z(xr), _r]), Fr = _("{", "(?:"), Mr = _("}", ")"), Lr = _(/(\d+)\.\.(\d+)/, (f, g, w) => sr(+g, +w, Math.min(g.length, w.length)).join("|")), Rr = _(/([a-z]+)\.\.([a-z]+)/, (f, g, w) => Qe(g, w).join("|")), Tr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, g, w) => Qe(g.toLowerCase(), w.toLowerCase()).join("|").toUpperCase()), Br = K([Lr, Rr, Tr]), it = V([Fr, Br, Mr]), Dr = _("{", "(?:"), Or = _("}", ")"), Nr = _(",", "|"), Ur = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), zr = _(/[^}]/, X), Vr = Ye(() => ot), $r = K([tt, rt, nt, at, it, Vr, Me, Ur, Nr, zr]), ot = V([Dr, Z($r), Or]), Gr = Z(K([cr, dr, ur, gr, tt, rt, nt, at, it, ot, Me, hr, fr])), Wr = Gr, qr = et(Wr), st = qr, Hr = _(/\\./, X), jr = _(/./, X), Kr = _(/\*\*\*+/, "*"), Xr = _(/([^/{[(!])\*\*/, (f, g) => `${g}*`), Yr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, g) => `${g}*`), Zr = Z(K([Hr, Kr, Xr, Yr, jr])), Jr = Zr, Qr = et(Jr), en = Qr, Le = (f, g) => {
|
|
469
469
|
const w = Array.isArray(f) ? f : [f];
|
|
470
470
|
if (!w.length) return !1;
|
|
471
|
-
const C = w.map(Le.compile),
|
|
471
|
+
const C = w.map(Le.compile), E = w.every((T) => /(\/(?:\*\*)?|\[\/\])$/.test(T)), I = g.replace(/[\\\/]+/g, "/").replace(/\/$/, E ? "/" : "");
|
|
472
472
|
return C.some((T) => T.test(I));
|
|
473
473
|
};
|
|
474
|
-
Le.compile = (f) => new RegExp(`^${
|
|
474
|
+
Le.compile = (f) => new RegExp(`^${st(en(f))}$`, "s");
|
|
475
475
|
var tn = Le;
|
|
476
|
-
return
|
|
476
|
+
return s(l);
|
|
477
477
|
})();
|
|
478
478
|
return r.default || r;
|
|
479
479
|
}, Te;
|
|
@@ -485,9 +485,9 @@ const gn = /^[/\\]{2}/, vn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,
|
|
|
485
485
|
if (r.length === 0)
|
|
486
486
|
return ".";
|
|
487
487
|
r = se(r);
|
|
488
|
-
const e = r.match(gn), t =
|
|
489
|
-
return r = He(r, !t), r.length === 0 ? t ? "/" : n ? "./" : "." : (n && (r += "/"), Wt.test(r) && (r += "/"), e ? t ? `//${r}` : `//./${r}` : t && !
|
|
490
|
-
},
|
|
488
|
+
const e = r.match(gn), t = ge(r), n = r[r.length - 1] === "/";
|
|
489
|
+
return r = He(r, !t), r.length === 0 ? t ? "/" : n ? "./" : "." : (n && (r += "/"), Wt.test(r) && (r += "/"), e ? t ? `//${r}` : `//./${r}` : t && !ge(r) ? `/${r}` : r);
|
|
490
|
+
}, bn = function(...r) {
|
|
491
491
|
let e = "";
|
|
492
492
|
for (const t of r)
|
|
493
493
|
if (t)
|
|
@@ -498,49 +498,49 @@ const gn = /^[/\\]{2}/, vn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,
|
|
|
498
498
|
e += t;
|
|
499
499
|
return qe(e);
|
|
500
500
|
};
|
|
501
|
-
function
|
|
501
|
+
function Sn() {
|
|
502
502
|
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
503
503
|
}
|
|
504
|
-
const
|
|
504
|
+
const Pe = function(...r) {
|
|
505
505
|
r = r.map((n) => se(n));
|
|
506
506
|
let e = "", t = !1;
|
|
507
507
|
for (let n = r.length - 1; n >= -1 && !t; n--) {
|
|
508
|
-
const a = n >= 0 ? r[n] :
|
|
509
|
-
!a || a.length === 0 || (e = `${a}/${e}`, t =
|
|
508
|
+
const a = n >= 0 ? r[n] : Sn();
|
|
509
|
+
!a || a.length === 0 || (e = `${a}/${e}`, t = ge(a));
|
|
510
510
|
}
|
|
511
|
-
return e = He(e, !t), t && !
|
|
511
|
+
return e = He(e, !t), t && !ge(e) ? `/${e}` : e.length > 0 ? e : ".";
|
|
512
512
|
};
|
|
513
513
|
function He(r, e) {
|
|
514
|
-
let t = "", n = 0, a = -1, i = 0,
|
|
515
|
-
for (let
|
|
516
|
-
if (
|
|
517
|
-
|
|
514
|
+
let t = "", n = 0, a = -1, i = 0, o = null;
|
|
515
|
+
for (let s = 0; s <= r.length; ++s) {
|
|
516
|
+
if (s < r.length)
|
|
517
|
+
o = r[s];
|
|
518
518
|
else {
|
|
519
|
-
if (
|
|
519
|
+
if (o === "/")
|
|
520
520
|
break;
|
|
521
|
-
|
|
521
|
+
o = "/";
|
|
522
522
|
}
|
|
523
|
-
if (
|
|
524
|
-
if (!(a ===
|
|
523
|
+
if (o === "/") {
|
|
524
|
+
if (!(a === s - 1 || i === 1)) if (i === 2) {
|
|
525
525
|
if (t.length < 2 || n !== 2 || t[t.length - 1] !== "." || t[t.length - 2] !== ".") {
|
|
526
526
|
if (t.length > 2) {
|
|
527
527
|
const l = t.lastIndexOf("/");
|
|
528
|
-
l === -1 ? (t = "", n = 0) : (t = t.slice(0, l), n = t.length - 1 - t.lastIndexOf("/")), a =
|
|
528
|
+
l === -1 ? (t = "", n = 0) : (t = t.slice(0, l), n = t.length - 1 - t.lastIndexOf("/")), a = s, i = 0;
|
|
529
529
|
continue;
|
|
530
530
|
} else if (t.length > 0) {
|
|
531
|
-
t = "", n = 0, a =
|
|
531
|
+
t = "", n = 0, a = s, i = 0;
|
|
532
532
|
continue;
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
e && (t += t.length > 0 ? "/.." : "..", n = 2);
|
|
536
536
|
} else
|
|
537
|
-
t.length > 0 ? t += `/${r.slice(a + 1,
|
|
538
|
-
a =
|
|
539
|
-
} else
|
|
537
|
+
t.length > 0 ? t += `/${r.slice(a + 1, s)}` : t = r.slice(a + 1, s), n = s - a - 1;
|
|
538
|
+
a = s, i = 0;
|
|
539
|
+
} else o === "." && i !== -1 ? ++i : i = -1;
|
|
540
540
|
}
|
|
541
541
|
return t;
|
|
542
542
|
}
|
|
543
|
-
const
|
|
543
|
+
const ge = function(r) {
|
|
544
544
|
return vn.test(r);
|
|
545
545
|
}, Cn = function(r) {
|
|
546
546
|
return se(r);
|
|
@@ -549,7 +549,7 @@ const pe = function(r) {
|
|
|
549
549
|
const e = yn.exec(se(r));
|
|
550
550
|
return e && e[1] || "";
|
|
551
551
|
}, _n = function(r, e) {
|
|
552
|
-
const t =
|
|
552
|
+
const t = Pe(r).replace(pt, "$1").split("/"), n = Pe(e).replace(pt, "$1").split("/");
|
|
553
553
|
if (n[0][1] === ":" && t[0][1] === ":" && t[0] !== n[0])
|
|
554
554
|
return n.join("/");
|
|
555
555
|
const a = [...t];
|
|
@@ -561,13 +561,13 @@ const pe = function(r) {
|
|
|
561
561
|
return [...t.map(() => ".."), ...n].join("/");
|
|
562
562
|
}, Ht = function(r) {
|
|
563
563
|
const e = se(r).replace(/\/$/, "").split("/").slice(0, -1);
|
|
564
|
-
return e.length === 1 && Wt.test(e[0]) && (e[0] += "/"), e.join("/") || (
|
|
565
|
-
},
|
|
564
|
+
return e.length === 1 && Wt.test(e[0]) && (e[0] += "/"), e.join("/") || (ge(r) ? "/" : ".");
|
|
565
|
+
}, En = function(r) {
|
|
566
566
|
const e = r.ext ? r.ext.startsWith(".") ? r.ext : `.${r.ext}` : "", t = [r.root, r.dir, r.base ?? (r.name ?? "") + e].filter(
|
|
567
567
|
Boolean
|
|
568
568
|
);
|
|
569
569
|
return se(
|
|
570
|
-
r.root ?
|
|
570
|
+
r.root ? Pe(...t) : t.join("/")
|
|
571
571
|
);
|
|
572
572
|
}, jt = function(r, e) {
|
|
573
573
|
const t = se(r).split("/");
|
|
@@ -580,7 +580,7 @@ const pe = function(r) {
|
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
return e && n.endsWith(e) ? n.slice(0, -e.length) : n;
|
|
583
|
-
},
|
|
583
|
+
}, Pn = function(r) {
|
|
584
584
|
var a, i;
|
|
585
585
|
const e = ((i = (a = wn.exec(r)) == null ? void 0 : a[0]) == null ? void 0 : i.replace(/\\/g, "/")) || "", t = jt(r), n = qt(t);
|
|
586
586
|
return {
|
|
@@ -595,15 +595,15 @@ const pe = function(r) {
|
|
|
595
595
|
basename: jt,
|
|
596
596
|
dirname: Ht,
|
|
597
597
|
extname: qt,
|
|
598
|
-
format:
|
|
599
|
-
isAbsolute:
|
|
600
|
-
join:
|
|
598
|
+
format: En,
|
|
599
|
+
isAbsolute: ge,
|
|
600
|
+
join: bn,
|
|
601
601
|
matchesGlob: In,
|
|
602
602
|
normalize: qe,
|
|
603
603
|
normalizeString: He,
|
|
604
|
-
parse:
|
|
604
|
+
parse: Pn,
|
|
605
605
|
relative: _n,
|
|
606
|
-
resolve:
|
|
606
|
+
resolve: Pe,
|
|
607
607
|
sep: An,
|
|
608
608
|
toNamespacedPath: Cn
|
|
609
609
|
}, kn = /* @__PURE__ */ (() => {
|
|
@@ -614,7 +614,7 @@ const pe = function(r) {
|
|
|
614
614
|
return t === "delimiter" ? r : t === "posix" ? Ve : t === "win32" ? Fn : xn[t] || gt[t];
|
|
615
615
|
}
|
|
616
616
|
}), Ve = /* @__PURE__ */ Kt(":"), Fn = /* @__PURE__ */ Kt(";");
|
|
617
|
-
var F = /* @__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))(F || {}), x = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(x || {}),
|
|
617
|
+
var F = /* @__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))(F || {}), x = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(x || {}), re = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(re || {});
|
|
618
618
|
const Mn = !0;
|
|
619
619
|
function L(r, e, t = r) {
|
|
620
620
|
return (n) => {
|
|
@@ -623,8 +623,8 @@ function L(r, e, t = r) {
|
|
|
623
623
|
};
|
|
624
624
|
}
|
|
625
625
|
function Xt(r, e, t, n) {
|
|
626
|
-
const a = r.substring(0, n) + t, i = r.substring(n + e.length),
|
|
627
|
-
return ~
|
|
626
|
+
const a = r.substring(0, n) + t, i = r.substring(n + e.length), o = i.indexOf(e);
|
|
627
|
+
return ~o ? a + Xt(i, e, t, o) : a + i;
|
|
628
628
|
}
|
|
629
629
|
function Ln(r = Mn) {
|
|
630
630
|
return {
|
|
@@ -686,7 +686,7 @@ const D = Ln(), $e = {
|
|
|
686
686
|
F.Log,
|
|
687
687
|
F.Verbose,
|
|
688
688
|
F.Debug
|
|
689
|
-
], yt = [
|
|
689
|
+
], yt = [re.JSON, re.Pretty];
|
|
690
690
|
function Bn(r) {
|
|
691
691
|
return r.stack == null ? [] : r.stack.split(`
|
|
692
692
|
`).map((e) => e.trim()).slice(1).filter((e) => !!/^at (.*)( \(.*:(\d+):(\d+)\))|at (.*)(:(\d+):(\d+))/i.exec(e)).map((e) => {
|
|
@@ -716,18 +716,18 @@ function Yt(r) {
|
|
|
716
716
|
function Zt(r, e, t, n, a) {
|
|
717
717
|
let i = { context: "" };
|
|
718
718
|
typeof t < "u" && t !== null && (i = { ...t }), typeof e < "u" && e !== null && (i.context = e);
|
|
719
|
-
const
|
|
719
|
+
const o = /* @__PURE__ */ new Date();
|
|
720
720
|
return {
|
|
721
|
-
"@timestamp":
|
|
722
|
-
"@localetime": a ? a(
|
|
721
|
+
"@timestamp": o.getTime(),
|
|
722
|
+
"@localetime": a ? a(o) : o.toISOString(),
|
|
723
723
|
level: r,
|
|
724
724
|
fields: i,
|
|
725
725
|
message: n
|
|
726
726
|
};
|
|
727
727
|
}
|
|
728
728
|
function Dn(r, e, t, n, a, i) {
|
|
729
|
-
const
|
|
730
|
-
return typeof a < "u" && a !== null && (
|
|
729
|
+
const o = Zt(r, e, t, n, i);
|
|
730
|
+
return typeof a < "u" && a !== null && (o.errored = !0, o.error = { stack: a }), o;
|
|
731
731
|
}
|
|
732
732
|
function wt(r) {
|
|
733
733
|
let e = "";
|
|
@@ -761,18 +761,18 @@ function Ce(r) {
|
|
|
761
761
|
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);
|
|
762
762
|
const n = Object.entries(r.fields);
|
|
763
763
|
n.length > 0 && e.push(" {");
|
|
764
|
-
for (const [i,
|
|
765
|
-
let
|
|
766
|
-
if (Yt(
|
|
767
|
-
if (
|
|
764
|
+
for (const [i, o] of n) {
|
|
765
|
+
let s = o;
|
|
766
|
+
if (Yt(o)) {
|
|
767
|
+
if (o.message && (s = wt(o.message)), s || (s = ""), o.cause != null)
|
|
768
768
|
try {
|
|
769
|
-
|
|
769
|
+
s += JSON.stringify(o.cause);
|
|
770
770
|
} catch {
|
|
771
|
-
|
|
771
|
+
s += String(o.cause);
|
|
772
772
|
}
|
|
773
773
|
} else
|
|
774
|
-
|
|
775
|
-
e.push(`${D.gray(i)}${D.gray("=")}${
|
|
774
|
+
s = wt(o);
|
|
775
|
+
e.push(`${D.gray(i)}${D.gray("=")}${s}`);
|
|
776
776
|
}
|
|
777
777
|
n.length > 0 && e.push("}");
|
|
778
778
|
let a = e.join(" ");
|
|
@@ -798,7 +798,7 @@ function Jt() {
|
|
|
798
798
|
return typeof window < "u";
|
|
799
799
|
}
|
|
800
800
|
function $n() {
|
|
801
|
-
return !Jt() && Ge() ===
|
|
801
|
+
return !Jt() && Ge() === re.Pretty;
|
|
802
802
|
}
|
|
803
803
|
function Gn(r, e) {
|
|
804
804
|
return $n() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
|
|
@@ -806,7 +806,7 @@ function Gn(r, e) {
|
|
|
806
806
|
const Ae = {
|
|
807
807
|
configured: !1,
|
|
808
808
|
logLevel: F.Debug,
|
|
809
|
-
format:
|
|
809
|
+
format: re.JSON,
|
|
810
810
|
timeFormatter: (r) => r.toISOString()
|
|
811
811
|
};
|
|
812
812
|
function At() {
|
|
@@ -834,23 +834,23 @@ function Qt(r) {
|
|
|
834
834
|
fields: {},
|
|
835
835
|
context: r,
|
|
836
836
|
logLevel: F.Debug,
|
|
837
|
-
format:
|
|
837
|
+
format: re.JSON,
|
|
838
838
|
shouldUseGlobalConfig: !1,
|
|
839
839
|
errorProcessor: (c) => c,
|
|
840
840
|
timeFormatter: (c) => c.toISOString(),
|
|
841
841
|
useGlobalConfig: () => (e.shouldUseGlobalConfig = !0, e.format = Ge(), e.logLevel = At(), e.child()),
|
|
842
842
|
child: (c) => {
|
|
843
|
-
const
|
|
844
|
-
return c != null ?
|
|
843
|
+
const d = Qt(e.context);
|
|
844
|
+
return c != null ? d.fields = { ...e.fields, ...c } : d.fields = e.fields, d.fields != null && "context" in d.fields ? d.context = d.fields.context : d.context = e.context, d.logLevel = e.logLevel, d.format = e.format, d.shouldUseGlobalConfig = e.shouldUseGlobalConfig, d;
|
|
845
845
|
},
|
|
846
846
|
withContext: (c) => {
|
|
847
|
-
const
|
|
848
|
-
return
|
|
847
|
+
const d = e.child();
|
|
848
|
+
return d.context = c, d;
|
|
849
849
|
},
|
|
850
850
|
withLogLevel: (c) => {
|
|
851
|
-
const
|
|
851
|
+
const d = e.child();
|
|
852
852
|
if (Ie.includes(c))
|
|
853
|
-
|
|
853
|
+
d.logLevel = c, d.shouldUseGlobalConfig = !1, d.debug(
|
|
854
854
|
`setting log level to ${Rn[c]} (${c})`
|
|
855
855
|
);
|
|
856
856
|
else
|
|
@@ -859,12 +859,12 @@ function Qt(r) {
|
|
|
859
859
|
", "
|
|
860
860
|
)}`
|
|
861
861
|
);
|
|
862
|
-
return
|
|
862
|
+
return d;
|
|
863
863
|
},
|
|
864
864
|
withLogLevelString: (c) => {
|
|
865
|
-
const
|
|
865
|
+
const d = e.child();
|
|
866
866
|
if (vt.includes(c))
|
|
867
|
-
|
|
867
|
+
d.logLevel = $e[c], d.shouldUseGlobalConfig = !1, d.debug(
|
|
868
868
|
`setting log level to ${c} (${$e[c]})`
|
|
869
869
|
);
|
|
870
870
|
else
|
|
@@ -873,45 +873,45 @@ function Qt(r) {
|
|
|
873
873
|
", "
|
|
874
874
|
)}`
|
|
875
875
|
);
|
|
876
|
-
return
|
|
876
|
+
return d;
|
|
877
877
|
},
|
|
878
878
|
withFormat: (c) => {
|
|
879
|
-
const
|
|
879
|
+
const d = e.child();
|
|
880
880
|
if (yt.includes(c))
|
|
881
|
-
|
|
881
|
+
d.format = c, d.shouldUseGlobalConfig = !1, d.debug(`setting format to ${c}`);
|
|
882
882
|
else
|
|
883
883
|
throw new Error(
|
|
884
884
|
`format ${c} is not available. available formats are: ${yt.join(
|
|
885
885
|
", "
|
|
886
886
|
)}`
|
|
887
887
|
);
|
|
888
|
-
return
|
|
888
|
+
return d;
|
|
889
889
|
},
|
|
890
890
|
withFields: (c) => typeof c > "u" || c === null ? e.child({}) : e.child(c),
|
|
891
|
-
withField(c,
|
|
891
|
+
withField(c, d) {
|
|
892
892
|
if (typeof c > "u" || c === null)
|
|
893
893
|
throw new Error("key is required");
|
|
894
|
-
return e.child({ [c]:
|
|
894
|
+
return e.child({ [c]: d });
|
|
895
895
|
},
|
|
896
896
|
withError: (c) => {
|
|
897
897
|
if (c = e.errorProcessor(c), !Yt(c))
|
|
898
898
|
return e.withField("error", String(c));
|
|
899
|
-
let
|
|
900
|
-
if (
|
|
899
|
+
let d = e;
|
|
900
|
+
if (d = d.withField("error", c.message), c.stack != null && (d = d.withField("stack", c.stack)), c.cause != null)
|
|
901
901
|
try {
|
|
902
|
-
|
|
902
|
+
d = d.withField("cause", JSON.stringify(c.cause));
|
|
903
903
|
} catch {
|
|
904
|
-
|
|
904
|
+
d = d.withField("cause", String(c.cause));
|
|
905
905
|
}
|
|
906
|
-
return
|
|
906
|
+
return d;
|
|
907
907
|
},
|
|
908
908
|
withCallStack(c) {
|
|
909
|
-
const
|
|
910
|
-
return
|
|
911
|
-
function:
|
|
912
|
-
file: `${
|
|
913
|
-
line:
|
|
914
|
-
column:
|
|
909
|
+
const d = Bn(c).slice(2).filter((m) => !m.invalid);
|
|
910
|
+
return d.length === 0 ? e : e.child({
|
|
911
|
+
function: d[0].function,
|
|
912
|
+
file: `${d[0].file}:${d[0].line}:${d[0].column}`,
|
|
913
|
+
line: d[0].line,
|
|
914
|
+
column: d[0].column
|
|
915
915
|
});
|
|
916
916
|
},
|
|
917
917
|
// Placeholder implementations, will be overridden below
|
|
@@ -930,29 +930,29 @@ function Qt(r) {
|
|
|
930
930
|
// TODO: remove in next major release
|
|
931
931
|
withTimeFormat: (c) => e.child(),
|
|
932
932
|
withTimeFormatter: (c) => {
|
|
933
|
-
const
|
|
934
|
-
return
|
|
933
|
+
const d = e.child();
|
|
934
|
+
return d.timeFormatter = c, d;
|
|
935
935
|
},
|
|
936
936
|
withErrorProcessor: (c) => {
|
|
937
|
-
const
|
|
938
|
-
return
|
|
937
|
+
const d = e.child();
|
|
938
|
+
return d.errorProcessor = c, d;
|
|
939
939
|
}
|
|
940
|
-
}, t = () => e.shouldUseGlobalConfig ? At() : e.logLevel, n = () => e.shouldUseGlobalConfig ? Ge() : e.format, a = () => e.shouldUseGlobalConfig ? qn() : e.timeFormatter ?? ((c) => c.toISOString()), i = (c) => c != null && c.length > 0 ? Object.keys(e.fields).length > 0 ? [e.fields, ...c] : c : e.fields,
|
|
940
|
+
}, t = () => e.shouldUseGlobalConfig ? At() : e.logLevel, n = () => e.shouldUseGlobalConfig ? Ge() : e.format, a = () => e.shouldUseGlobalConfig ? qn() : e.timeFormatter ?? ((c) => c.toISOString()), i = (c) => c != null && c.length > 0 ? Object.keys(e.fields).length > 0 ? [e.fields, ...c] : c : e.fields, o = (c, d, m) => {
|
|
941
941
|
const v = n();
|
|
942
|
-
if (Jt() && v ===
|
|
942
|
+
if (Jt() && v === re.Pretty) {
|
|
943
943
|
c.fields = Object.fromEntries(
|
|
944
|
-
Object.entries(c.fields).filter(([
|
|
945
|
-
if (
|
|
946
|
-
return [
|
|
944
|
+
Object.entries(c.fields).filter(([S, P]) => {
|
|
945
|
+
if (S === "isNestSystemModule" || S === "nestSystemModule" || S === "context")
|
|
946
|
+
return [S, P];
|
|
947
947
|
})
|
|
948
948
|
);
|
|
949
949
|
const A = m ?? e.fields;
|
|
950
|
-
Array.isArray(A) && A.length > 0 ? console[
|
|
950
|
+
Array.isArray(A) && A.length > 0 ? console[d](Ce(c), ...A) : Object.keys(A).length > 0 ? console[d](Ce(c), A) : console[d](Ce(c));
|
|
951
951
|
return;
|
|
952
952
|
}
|
|
953
|
-
const
|
|
954
|
-
console[
|
|
955
|
-
},
|
|
953
|
+
const b = v === re.Pretty ? Ce(c) : JSON.stringify(c);
|
|
954
|
+
console[d](b);
|
|
955
|
+
}, s = {
|
|
956
956
|
[x.Debug]: On,
|
|
957
957
|
[x.Verbose]: Nn,
|
|
958
958
|
[x.Log]: Un,
|
|
@@ -962,41 +962,41 @@ function Qt(r) {
|
|
|
962
962
|
[x.Verbose]: "log",
|
|
963
963
|
[x.Log]: "log",
|
|
964
964
|
[x.Warning]: "warn"
|
|
965
|
-
}, p = (c,
|
|
966
|
-
const v = t(),
|
|
967
|
-
if (!
|
|
965
|
+
}, p = (c, d, m) => {
|
|
966
|
+
const v = t(), b = s[c];
|
|
967
|
+
if (!b(v))
|
|
968
968
|
return;
|
|
969
|
-
const A = i(m),
|
|
969
|
+
const A = i(m), S = Zt(
|
|
970
970
|
c,
|
|
971
971
|
e.context,
|
|
972
972
|
A,
|
|
973
|
-
|
|
973
|
+
d,
|
|
974
974
|
a()
|
|
975
975
|
);
|
|
976
|
-
|
|
976
|
+
o(S, l[c], A);
|
|
977
977
|
};
|
|
978
|
-
return e.debug = (c, ...
|
|
979
|
-
p(x.Debug, c,
|
|
980
|
-
}, e.verbose = (c, ...
|
|
981
|
-
p(x.Verbose, c,
|
|
982
|
-
}, e.log = (c, ...
|
|
983
|
-
p(x.Log, c,
|
|
984
|
-
}, e.warn = (c, ...
|
|
985
|
-
p(x.Warning, c,
|
|
986
|
-
}, e.error = (c,
|
|
978
|
+
return e.debug = (c, ...d) => {
|
|
979
|
+
p(x.Debug, c, d);
|
|
980
|
+
}, e.verbose = (c, ...d) => {
|
|
981
|
+
p(x.Verbose, c, d);
|
|
982
|
+
}, e.log = (c, ...d) => {
|
|
983
|
+
p(x.Log, c, d);
|
|
984
|
+
}, e.warn = (c, ...d) => {
|
|
985
|
+
p(x.Warning, c, d);
|
|
986
|
+
}, e.error = (c, d, ...m) => {
|
|
987
987
|
const v = t();
|
|
988
988
|
if (!Vn(v))
|
|
989
989
|
return;
|
|
990
|
-
const
|
|
990
|
+
const b = i(m), A = Dn(
|
|
991
991
|
x.Error,
|
|
992
992
|
e.context,
|
|
993
|
-
|
|
993
|
+
b,
|
|
994
994
|
c,
|
|
995
|
-
|
|
995
|
+
d,
|
|
996
996
|
a()
|
|
997
997
|
);
|
|
998
|
-
|
|
999
|
-
}, e.errorWithError = (c,
|
|
998
|
+
o(A, "error", b);
|
|
999
|
+
}, e.errorWithError = (c, d, ...m) => e.withError(d).error(c, void 0, ...m), e;
|
|
1000
1000
|
}
|
|
1001
1001
|
function Hn(r) {
|
|
1002
1002
|
var i;
|
|
@@ -1004,23 +1004,23 @@ function Hn(r) {
|
|
|
1004
1004
|
return r = r ?? `${a}:${t.lineNumber}`, Qt(Gn(n, r));
|
|
1005
1005
|
}
|
|
1006
1006
|
const jn = (r) => Hn(r).useGlobalConfig();
|
|
1007
|
-
let
|
|
1008
|
-
const
|
|
1007
|
+
let Q = [];
|
|
1008
|
+
const bt = 100;
|
|
1009
1009
|
async function Kn() {
|
|
1010
|
-
if (
|
|
1010
|
+
if (Q.length === 0)
|
|
1011
1011
|
return;
|
|
1012
|
-
const r = [...
|
|
1013
|
-
|
|
1012
|
+
const r = [...Q];
|
|
1013
|
+
Q = [];
|
|
1014
1014
|
try {
|
|
1015
1015
|
await Xn();
|
|
1016
1016
|
} catch (e) {
|
|
1017
|
-
h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)),
|
|
1017
|
+
h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)), Q.unshift(...r), Q.length > bt && (Q = Q.slice(0, bt));
|
|
1018
1018
|
}
|
|
1019
1019
|
}
|
|
1020
1020
|
async function Xn(r) {
|
|
1021
1021
|
}
|
|
1022
1022
|
function Yn() {
|
|
1023
|
-
|
|
1023
|
+
Q.length > 0 && Kn(), h.log("[CLS] Cleaned up");
|
|
1024
1024
|
}
|
|
1025
1025
|
Wn(F.Warning);
|
|
1026
1026
|
const h = jn("Web").withErrorProcessor((r) => r).useGlobalConfig(), O = {
|
|
@@ -1044,7 +1044,7 @@ async function Zn(r) {
|
|
|
1044
1044
|
if (!a.endpoints)
|
|
1045
1045
|
throw new Error("Invalid config response: missing endpoints");
|
|
1046
1046
|
const i = {};
|
|
1047
|
-
a.endpoints.cn && (i[
|
|
1047
|
+
a.endpoints.cn && (i[oe.cn] = `https://${a.endpoints.cn}`), a.endpoints.us && (i[oe.us] = `https://${a.endpoints.us}`), a.endpoints.test && (i[oe.test] = `https://${a.endpoints.test}`), O.config = i, h.log("[SdkConfigLoader] SDK config fetched successfully:", i);
|
|
1048
1048
|
} catch {
|
|
1049
1049
|
O.config = {};
|
|
1050
1050
|
} finally {
|
|
@@ -1057,9 +1057,9 @@ function Jn() {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
class Qn {
|
|
1059
1059
|
constructor(e) {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1060
|
+
u(this, "module");
|
|
1061
|
+
u(this, "allocatedPointers");
|
|
1062
|
+
u(this, "structPointers");
|
|
1063
1063
|
this.module = e, this.allocatedPointers = /* @__PURE__ */ new Set(), this.structPointers = /* @__PURE__ */ new Map();
|
|
1064
1064
|
}
|
|
1065
1065
|
/**
|
|
@@ -1087,9 +1087,9 @@ class Qn {
|
|
|
1087
1087
|
throw new Error("teethPb is missing or empty!");
|
|
1088
1088
|
if (!e.teethNpz || e.teethNpz.byteLength === 0)
|
|
1089
1089
|
throw new Error("teethNpz is missing or empty!");
|
|
1090
|
-
const a = this.allocateAndCopy(e.flameModel), i = this.allocateAndCopy(e.flameTemplate),
|
|
1090
|
+
const a = this.allocateAndCopy(e.flameModel), i = this.allocateAndCopy(e.flameTemplate), o = this.allocateAndCopy(e.teethPb), s = this.allocateAndCopy(e.teethNpz);
|
|
1091
1091
|
let l = 0;
|
|
1092
|
-
return this.module.setValue(n + l, a.ptr, "i32"), l += 4, this.module.setValue(n + l, a.size, "i32"), l += 4, this.module.setValue(n + l, i.ptr, "i32"), l += 4, this.module.setValue(n + l, i.size, "i32"), l += 4, this.module.setValue(n + l,
|
|
1092
|
+
return this.module.setValue(n + l, a.ptr, "i32"), l += 4, this.module.setValue(n + l, a.size, "i32"), l += 4, this.module.setValue(n + l, i.ptr, "i32"), l += 4, this.module.setValue(n + l, i.size, "i32"), l += 4, this.module.setValue(n + l, o.ptr, "i32"), l += 4, this.module.setValue(n + l, o.size, "i32"), l += 4, this.module.setValue(n + l, s.ptr, "i32"), l += 4, this.module.setValue(n + l, s.size, "i32"), l += 4, this.module.setValue(n + l, 0, "i32"), l += 4, this.module.setValue(n + l, 0, "i32"), l += 4, this.structPointers.set("template_config", n), n;
|
|
1093
1093
|
}
|
|
1094
1094
|
/**
|
|
1095
1095
|
* 创建 AvatarCharacterData 结构体 - 新版 Emscripten 方式
|
|
@@ -1098,11 +1098,11 @@ class Qn {
|
|
|
1098
1098
|
const i = this.module._malloc(16);
|
|
1099
1099
|
if (!i)
|
|
1100
1100
|
throw new Error("Failed to allocate AvatarCharacterData structure");
|
|
1101
|
-
const
|
|
1101
|
+
const o = this.allocateAndCopy(e), s = this.allocateAndCopy(t);
|
|
1102
1102
|
let l = 0;
|
|
1103
|
-
this.module.setValue(i + l,
|
|
1103
|
+
this.module.setValue(i + l, o.ptr, "i32"), l += 4, this.module.setValue(i + l, o.size, "i32"), l += 4, this.module.setValue(i + l, s.ptr, "i32"), l += 4, this.module.setValue(i + l, s.size, "i32"), l += 4;
|
|
1104
1104
|
const p = n ? `character_data_${n}` : "character_data";
|
|
1105
|
-
return this.structPointers.set(p, i), { dataPtr: i, shapePtr:
|
|
1105
|
+
return this.structPointers.set(p, i), { dataPtr: i, shapePtr: o.ptr, plyPtr: s.ptr };
|
|
1106
1106
|
}
|
|
1107
1107
|
/**
|
|
1108
1108
|
* 读取 AvatarFlameParams 结构体数据
|
|
@@ -1119,12 +1119,12 @@ class Qn {
|
|
|
1119
1119
|
const i = [];
|
|
1120
1120
|
for (let m = 0; m < 3; m++)
|
|
1121
1121
|
i.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1122
|
-
const s = [];
|
|
1123
|
-
for (let m = 0; m < 3; m++)
|
|
1124
|
-
s.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1125
1122
|
const o = [];
|
|
1126
1123
|
for (let m = 0; m < 3; m++)
|
|
1127
1124
|
o.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1125
|
+
const s = [];
|
|
1126
|
+
for (let m = 0; m < 3; m++)
|
|
1127
|
+
s.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1128
1128
|
const l = [];
|
|
1129
1129
|
for (let m = 0; m < 3; m++)
|
|
1130
1130
|
l.push(this.module.getValue(e + t, "float")), t += 4;
|
|
@@ -1134,59 +1134,59 @@ class Qn {
|
|
|
1134
1134
|
const c = [];
|
|
1135
1135
|
for (let m = 0; m < 2; m++)
|
|
1136
1136
|
c.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1137
|
-
const
|
|
1137
|
+
const d = this.module.getValue(e + t, "i32") !== 0;
|
|
1138
1138
|
return {
|
|
1139
1139
|
shape_params: n,
|
|
1140
1140
|
expr_params: a,
|
|
1141
1141
|
rotation: i,
|
|
1142
|
-
translation:
|
|
1143
|
-
neck_pose:
|
|
1142
|
+
translation: o,
|
|
1143
|
+
neck_pose: s,
|
|
1144
1144
|
jaw_pose: l,
|
|
1145
1145
|
eyes_pose: p,
|
|
1146
1146
|
eyelid: c,
|
|
1147
|
-
has_eyelid:
|
|
1147
|
+
has_eyelid: d
|
|
1148
1148
|
};
|
|
1149
1149
|
}
|
|
1150
1150
|
/**
|
|
1151
1151
|
* 创建 AvatarFlameParams 结构体 - 新版 Emscripten 方式
|
|
1152
1152
|
*/
|
|
1153
1153
|
createFlameParams(e) {
|
|
1154
|
-
var i,
|
|
1154
|
+
var i, o, s, l, p, c, d, m;
|
|
1155
1155
|
const n = this.module._malloc(1684);
|
|
1156
1156
|
if (!n)
|
|
1157
1157
|
throw new Error("Failed to allocate AvatarFlameParams structure");
|
|
1158
1158
|
let a = 0;
|
|
1159
1159
|
for (let v = 0; v < 300; v++) {
|
|
1160
|
-
const
|
|
1161
|
-
this.module.setValue(n + a,
|
|
1160
|
+
const b = ((i = e.shape_params) == null ? void 0 : i[v]) || 0;
|
|
1161
|
+
this.module.setValue(n + a, b, "float"), a += 4;
|
|
1162
1162
|
}
|
|
1163
1163
|
for (let v = 0; v < 100; v++) {
|
|
1164
|
-
const
|
|
1165
|
-
this.module.setValue(n + a,
|
|
1164
|
+
const b = ((o = e.expr_params) == null ? void 0 : o[v]) || 0;
|
|
1165
|
+
this.module.setValue(n + a, b, "float"), a += 4;
|
|
1166
1166
|
}
|
|
1167
1167
|
for (let v = 0; v < 3; v++) {
|
|
1168
|
-
const
|
|
1169
|
-
this.module.setValue(n + a,
|
|
1168
|
+
const b = ((s = e.rotation) == null ? void 0 : s[v]) || 0;
|
|
1169
|
+
this.module.setValue(n + a, b, "float"), a += 4;
|
|
1170
1170
|
}
|
|
1171
1171
|
for (let v = 0; v < 3; v++) {
|
|
1172
|
-
const
|
|
1173
|
-
this.module.setValue(n + a,
|
|
1172
|
+
const b = ((l = e.translation) == null ? void 0 : l[v]) || 0;
|
|
1173
|
+
this.module.setValue(n + a, b, "float"), a += 4;
|
|
1174
1174
|
}
|
|
1175
1175
|
for (let v = 0; v < 3; v++) {
|
|
1176
|
-
const
|
|
1177
|
-
this.module.setValue(n + a,
|
|
1176
|
+
const b = ((p = e.neck_pose) == null ? void 0 : p[v]) || 0;
|
|
1177
|
+
this.module.setValue(n + a, b, "float"), a += 4;
|
|
1178
1178
|
}
|
|
1179
1179
|
for (let v = 0; v < 3; v++) {
|
|
1180
|
-
const
|
|
1181
|
-
this.module.setValue(n + a,
|
|
1180
|
+
const b = ((c = e.jaw_pose) == null ? void 0 : c[v]) || 0;
|
|
1181
|
+
this.module.setValue(n + a, b, "float"), a += 4;
|
|
1182
1182
|
}
|
|
1183
1183
|
for (let v = 0; v < 6; v++) {
|
|
1184
|
-
const
|
|
1185
|
-
this.module.setValue(n + a,
|
|
1184
|
+
const b = ((d = e.eyes_pose) == null ? void 0 : d[v]) || 0;
|
|
1185
|
+
this.module.setValue(n + a, b, "float"), a += 4;
|
|
1186
1186
|
}
|
|
1187
1187
|
for (let v = 0; v < 2; v++) {
|
|
1188
|
-
const
|
|
1189
|
-
this.module.setValue(n + a,
|
|
1188
|
+
const b = ((m = e.eyelid) == null ? void 0 : m[v]) || 0;
|
|
1189
|
+
this.module.setValue(n + a, b, "float"), a += 4;
|
|
1190
1190
|
}
|
|
1191
1191
|
return this.module.setValue(n + a, e.has_eyelid ? 1 : 0, "i32"), a += 4, n;
|
|
1192
1192
|
}
|
|
@@ -1211,14 +1211,14 @@ class Qn {
|
|
|
1211
1211
|
const t = this.module.getValue(e, "i32"), n = this.module.getValue(e + 4, "i32");
|
|
1212
1212
|
if (n === 0 || !t)
|
|
1213
1213
|
return null;
|
|
1214
|
-
const i = n * 13,
|
|
1215
|
-
return
|
|
1214
|
+
const i = n * 13, o = t / 4, s = new Float32Array(i);
|
|
1215
|
+
return s.set(this.module.HEAPF32.subarray(o, o + i)), s;
|
|
1216
1216
|
}
|
|
1217
1217
|
/**
|
|
1218
1218
|
* 读取AvatarMeshData结构体数据
|
|
1219
1219
|
*/
|
|
1220
1220
|
readMeshData(e) {
|
|
1221
|
-
const t = this.module.getValue(e + 0, "*"), n = this.module.getValue(e + 4, "i32"), a = this.module.getValue(e + 8, "*"), i = this.module.getValue(e + 12, "i32"),
|
|
1221
|
+
const t = this.module.getValue(e + 0, "*"), n = this.module.getValue(e + 4, "i32"), a = this.module.getValue(e + 8, "*"), i = this.module.getValue(e + 12, "i32"), o = this.module.getValue(e + 16, "float"), s = this.module.getValue(e + 20, "*"), l = this.module.getValue(e + 24, "i32"), p = new Float32Array(n * 3);
|
|
1222
1222
|
if (t && n > 0)
|
|
1223
1223
|
for (let m = 0; m < n * 3; m++)
|
|
1224
1224
|
p[m] = this.module.getValue(t + m * 4, "float");
|
|
@@ -1226,20 +1226,20 @@ class Qn {
|
|
|
1226
1226
|
if (a && i > 0)
|
|
1227
1227
|
for (let m = 0; m < i * 3; m++)
|
|
1228
1228
|
c[m] = this.module.getValue(a + m * 4, "i32");
|
|
1229
|
-
let
|
|
1230
|
-
if (
|
|
1231
|
-
|
|
1229
|
+
let d = null;
|
|
1230
|
+
if (s && l > 0) {
|
|
1231
|
+
d = new Float32Array(l * 3);
|
|
1232
1232
|
for (let m = 0; m < l * 3; m++)
|
|
1233
|
-
|
|
1233
|
+
d[m] = this.module.getValue(s + m * 4, "float");
|
|
1234
1234
|
}
|
|
1235
1235
|
return {
|
|
1236
1236
|
vertices: p,
|
|
1237
1237
|
vertexCount: n,
|
|
1238
1238
|
faces: c,
|
|
1239
1239
|
faceCount: i,
|
|
1240
|
-
landmarks:
|
|
1240
|
+
landmarks: d,
|
|
1241
1241
|
landmarkCount: l,
|
|
1242
|
-
computeTime:
|
|
1242
|
+
computeTime: o
|
|
1243
1243
|
};
|
|
1244
1244
|
}
|
|
1245
1245
|
/**
|
|
@@ -1280,37 +1280,37 @@ class Qn {
|
|
|
1280
1280
|
class ea {
|
|
1281
1281
|
constructor(e = {}) {
|
|
1282
1282
|
// 配置
|
|
1283
|
-
|
|
1284
|
-
|
|
1283
|
+
u(this, "options");
|
|
1284
|
+
u(this, "wasmConfig");
|
|
1285
1285
|
// 核心组件
|
|
1286
1286
|
// eslint-disable-next-line ts/no-explicit-any
|
|
1287
|
-
|
|
1288
|
-
|
|
1287
|
+
u(this, "wasmModule");
|
|
1288
|
+
u(this, "memoryManager");
|
|
1289
1289
|
// Avatar Core handles
|
|
1290
|
-
|
|
1290
|
+
u(this, "coreHandle");
|
|
1291
1291
|
// Support multiple character handles (key: characterId, value: handle)
|
|
1292
|
-
|
|
1292
|
+
u(this, "characterHandles", /* @__PURE__ */ new Map());
|
|
1293
1293
|
// Animation handles per character (key: characterId, value: { handle, totalFrames })
|
|
1294
|
-
|
|
1294
|
+
u(this, "animationHandles", /* @__PURE__ */ new Map());
|
|
1295
1295
|
// Legacy single character support (deprecated, kept for backward compatibility)
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1296
|
+
u(this, "characterHandle");
|
|
1297
|
+
u(this, "animationHandle");
|
|
1298
|
+
u(this, "totalFrames");
|
|
1299
1299
|
// 状态管理
|
|
1300
|
-
|
|
1301
|
-
|
|
1300
|
+
u(this, "isInitialized");
|
|
1301
|
+
u(this, "isCharacterLoaded");
|
|
1302
1302
|
// C API 函数包装
|
|
1303
1303
|
// eslint-disable-next-line ts/no-explicit-any
|
|
1304
|
-
|
|
1304
|
+
u(this, "api");
|
|
1305
1305
|
// 性能监控
|
|
1306
|
-
|
|
1307
|
-
|
|
1306
|
+
u(this, "performanceMetrics");
|
|
1307
|
+
u(this, "wasmTime", 0);
|
|
1308
1308
|
// 最近一次 WASM 计算耗时
|
|
1309
1309
|
// 错误码映射
|
|
1310
|
-
|
|
1310
|
+
u(this, "errorCodes");
|
|
1311
1311
|
// 模型信息
|
|
1312
|
-
|
|
1313
|
-
|
|
1312
|
+
u(this, "flameInfo");
|
|
1313
|
+
u(this, "characterInfo");
|
|
1314
1314
|
this.options = {
|
|
1315
1315
|
logLevel: "basic",
|
|
1316
1316
|
enableValidation: !0,
|
|
@@ -1495,25 +1495,25 @@ class ea {
|
|
|
1495
1495
|
throw new Error("Avatar Core not initialized");
|
|
1496
1496
|
const a = performance.now();
|
|
1497
1497
|
try {
|
|
1498
|
-
const { dataPtr: i, shapePtr:
|
|
1498
|
+
const { dataPtr: i, shapePtr: o, plyPtr: s } = this.memoryManager.createCharacterData(
|
|
1499
1499
|
e,
|
|
1500
1500
|
t,
|
|
1501
1501
|
n
|
|
1502
1502
|
), l = this.api.loadCharacter(this.coreHandle, i);
|
|
1503
1503
|
if (!l) {
|
|
1504
|
-
this.memoryManager.free(
|
|
1505
|
-
const
|
|
1506
|
-
throw this.memoryManager.freeStruct(
|
|
1504
|
+
this.memoryManager.free(o), this.memoryManager.free(s);
|
|
1505
|
+
const d = n ? `character_data_${n}` : "character_data";
|
|
1506
|
+
throw this.memoryManager.freeStruct(d), new Error("avatar_core_load_character returned NULL - character loading failed");
|
|
1507
1507
|
}
|
|
1508
|
-
this.memoryManager.free(
|
|
1508
|
+
this.memoryManager.free(o), this.memoryManager.free(s);
|
|
1509
1509
|
const p = n ? `character_data_${n}` : "character_data";
|
|
1510
1510
|
this.memoryManager.freeStruct(p);
|
|
1511
1511
|
const c = n || "default";
|
|
1512
1512
|
return this.characterHandles.set(c, l), !n || c === "default" ? (this.characterHandle = l, this.isCharacterLoaded = !0, await this.queryCharacterInfo()) : this.characterHandle || (this.characterHandle = l, this.isCharacterLoaded = !0), this.performanceMetrics.loadTime = performance.now() - a, l;
|
|
1513
1513
|
} catch (i) {
|
|
1514
1514
|
h.errorWithError("❌ Character loading failed:", i);
|
|
1515
|
-
const
|
|
1516
|
-
throw new Error(`Character loading failed: ${
|
|
1515
|
+
const o = i instanceof Error ? i.message : String(i);
|
|
1516
|
+
throw new Error(`Character loading failed: ${o}`);
|
|
1517
1517
|
}
|
|
1518
1518
|
}
|
|
1519
1519
|
async loadAnimationFromData(e) {
|
|
@@ -1549,8 +1549,8 @@ class ea {
|
|
|
1549
1549
|
const t = `${this.options.baseAssetsPath}/${this.options.modelFolder}/${e}`, n = this.wasmConfig.baseUrl ? `${this.wasmConfig.baseUrl}${t}` : t, a = await fetch(n);
|
|
1550
1550
|
if (!a.ok)
|
|
1551
1551
|
throw new Error(`HTTP error! status: ${a.status}`);
|
|
1552
|
-
const i = await a.arrayBuffer(),
|
|
1553
|
-
return this.animationHandle =
|
|
1552
|
+
const i = await a.arrayBuffer(), o = await this.loadAnimationFromData(i);
|
|
1553
|
+
return this.animationHandle = o, this.totalFrames = null, await this.getAnimationTotalFrames(), this.totalFrames;
|
|
1554
1554
|
} catch (t) {
|
|
1555
1555
|
h.errorWithError(`❌ Failed to switch animation to ${e}:`, t);
|
|
1556
1556
|
const n = t instanceof Error ? t.message : String(t);
|
|
@@ -1569,8 +1569,8 @@ class ea {
|
|
|
1569
1569
|
const n = this.wasmModule._malloc(4), a = this.api.getAnimationFrameCount(t, n);
|
|
1570
1570
|
if (a !== 0) {
|
|
1571
1571
|
this.wasmModule._free(n);
|
|
1572
|
-
const
|
|
1573
|
-
throw new Error(`Failed to get animation frame count: ${
|
|
1572
|
+
const o = this.api.getErrorString(a);
|
|
1573
|
+
throw new Error(`Failed to get animation frame count: ${o}`);
|
|
1574
1574
|
}
|
|
1575
1575
|
const i = this.wasmModule.getValue(n, "i32");
|
|
1576
1576
|
return this.wasmModule._free(n), e || (this.totalFrames = i), i;
|
|
@@ -1589,24 +1589,24 @@ class ea {
|
|
|
1589
1589
|
const n = t || "default", a = this.animationHandles.get(n), i = (a == null ? void 0 : a.handle) || this.animationHandle;
|
|
1590
1590
|
if (!i)
|
|
1591
1591
|
throw new Error("No animation loaded");
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1592
|
+
const o = (a == null ? void 0 : a.totalFrames) ?? this.totalFrames;
|
|
1593
|
+
o !== null && o > 0 && (e = e % o, e < 0 && (e += o));
|
|
1594
1594
|
try {
|
|
1595
1595
|
const l = this.wasmModule._malloc(1684), p = this.api.getFrameFromAnimation(i, e, l);
|
|
1596
1596
|
if (p !== 0) {
|
|
1597
1597
|
this.wasmModule._free(l);
|
|
1598
|
-
const
|
|
1599
|
-
throw new Error(`Failed to get frame ${e}: ${
|
|
1598
|
+
const d = this.api.getErrorString(p);
|
|
1599
|
+
throw new Error(`Failed to get frame ${e}: ${d}`);
|
|
1600
1600
|
}
|
|
1601
1601
|
const c = this.characterHandles.get(n) || this.characterHandle;
|
|
1602
1602
|
if (c) {
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1603
|
+
const d = this.api.getCharacterShapeParams(c, l);
|
|
1604
|
+
d !== 0 && h.warn(`Failed to get character shape params: ${this.api.getErrorString(d)}`);
|
|
1605
1605
|
}
|
|
1606
1606
|
return l;
|
|
1607
|
-
} catch (
|
|
1608
|
-
h.errorWithError(`❌ Failed to get animation frame ${e}:`,
|
|
1609
|
-
const l =
|
|
1607
|
+
} catch (s) {
|
|
1608
|
+
h.errorWithError(`❌ Failed to get animation frame ${e}:`, s);
|
|
1609
|
+
const l = s instanceof Error ? s.message : String(s);
|
|
1610
1610
|
throw new Error(`Failed to get animation frame ${e}: ${l}`);
|
|
1611
1611
|
}
|
|
1612
1612
|
}
|
|
@@ -1669,8 +1669,8 @@ class ea {
|
|
|
1669
1669
|
n
|
|
1670
1670
|
);
|
|
1671
1671
|
this.checkError(a, "avatar_core_get_flame_info");
|
|
1672
|
-
const i = this.wasmModule.getValue(e, "i32"),
|
|
1673
|
-
this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: i, faceCount:
|
|
1672
|
+
const i = this.wasmModule.getValue(e, "i32"), o = this.wasmModule.getValue(t, "i32"), s = this.wasmModule.getValue(n, "i32");
|
|
1673
|
+
this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: i, faceCount: o, jointCount: s };
|
|
1674
1674
|
} catch (e) {
|
|
1675
1675
|
const t = e instanceof Error ? e.message : String(e);
|
|
1676
1676
|
h.errorWithError("❌ Failed to query FLAME info:", t);
|
|
@@ -1788,31 +1788,31 @@ class ea {
|
|
|
1788
1788
|
const n = performance.now();
|
|
1789
1789
|
let a = null, i = null;
|
|
1790
1790
|
try {
|
|
1791
|
-
const
|
|
1791
|
+
const o = (e == null ? void 0 : e.frameIndex) ?? 0, s = t || this.characterHandle;
|
|
1792
1792
|
let l;
|
|
1793
|
-
if (
|
|
1793
|
+
if (s) {
|
|
1794
1794
|
for (const [m, v] of this.characterHandles.entries())
|
|
1795
|
-
if (v ===
|
|
1795
|
+
if (v === s) {
|
|
1796
1796
|
l = m;
|
|
1797
1797
|
break;
|
|
1798
1798
|
}
|
|
1799
|
-
!l &&
|
|
1799
|
+
!l && s === this.characterHandle && (l = "default");
|
|
1800
1800
|
}
|
|
1801
|
-
if (i = await this.getAnimationFrameParams(
|
|
1801
|
+
if (i = await this.getAnimationFrameParams(o, l), a = this.wasmModule._malloc(16), !s)
|
|
1802
1802
|
throw new Error("No character loaded");
|
|
1803
1803
|
const p = this.api.computeFrameFlat(
|
|
1804
1804
|
this.coreHandle,
|
|
1805
|
-
|
|
1805
|
+
s,
|
|
1806
1806
|
i,
|
|
1807
1807
|
a
|
|
1808
1808
|
);
|
|
1809
1809
|
this.checkError(p, "avatar_core_compute_frame_as_splat_points_flat");
|
|
1810
|
-
const c = this.memoryManager.readSplatPointFlatArray(a),
|
|
1811
|
-
return this.wasmTime =
|
|
1812
|
-
} catch (
|
|
1813
|
-
h.errorWithError("❌ computeCompleteFrameFlat failed:",
|
|
1814
|
-
const
|
|
1815
|
-
throw new Error(`computeCompleteFrameFlat failed: ${
|
|
1810
|
+
const c = this.memoryManager.readSplatPointFlatArray(a), d = performance.now() - n;
|
|
1811
|
+
return this.wasmTime = d, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += d, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, c;
|
|
1812
|
+
} catch (o) {
|
|
1813
|
+
h.errorWithError("❌ computeCompleteFrameFlat failed:", o);
|
|
1814
|
+
const s = o instanceof Error ? o.message : String(o);
|
|
1815
|
+
throw new Error(`computeCompleteFrameFlat failed: ${s}`);
|
|
1816
1816
|
} finally {
|
|
1817
1817
|
a !== null && (this.api.freeSplatPointsFlat(a), this.wasmModule._free(a)), i !== null && this.wasmModule._free(i);
|
|
1818
1818
|
}
|
|
@@ -1833,22 +1833,22 @@ class ea {
|
|
|
1833
1833
|
let a = null, i = null;
|
|
1834
1834
|
try {
|
|
1835
1835
|
i = this.memoryManager.createFlameParams(e), a = this.wasmModule._malloc(16);
|
|
1836
|
-
const
|
|
1837
|
-
if (!
|
|
1836
|
+
const o = t || this.characterHandle;
|
|
1837
|
+
if (!o)
|
|
1838
1838
|
throw new Error("No character loaded");
|
|
1839
|
-
const
|
|
1839
|
+
const s = this.api.computeFrameFlat(
|
|
1840
1840
|
this.coreHandle,
|
|
1841
|
-
|
|
1841
|
+
o,
|
|
1842
1842
|
i,
|
|
1843
1843
|
a
|
|
1844
1844
|
);
|
|
1845
|
-
this.checkError(
|
|
1845
|
+
this.checkError(s, "avatar_core_compute_frame_as_splat_points_flat");
|
|
1846
1846
|
const l = this.memoryManager.readSplatPointFlatArray(a), p = performance.now() - n;
|
|
1847
1847
|
return this.wasmTime = p, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += p, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, l;
|
|
1848
|
-
} catch (
|
|
1849
|
-
h.errorWithError("❌ computeFrameFlatFromParams failed:",
|
|
1850
|
-
const
|
|
1851
|
-
throw new Error(`computeFrameFlatFromParams failed: ${
|
|
1848
|
+
} catch (o) {
|
|
1849
|
+
h.errorWithError("❌ computeFrameFlatFromParams failed:", o);
|
|
1850
|
+
const s = o instanceof Error ? o.message : String(o);
|
|
1851
|
+
throw new Error(`computeFrameFlatFromParams failed: ${s}`);
|
|
1852
1852
|
} finally {
|
|
1853
1853
|
a !== null && (this.api.freeSplatPointsFlat(a), this.wasmModule._free(a)), i !== null && this.wasmModule._free(i);
|
|
1854
1854
|
}
|
|
@@ -1933,7 +1933,7 @@ class y {
|
|
|
1933
1933
|
throw new Error("AvatarCore not available");
|
|
1934
1934
|
h.log("[AvatarKit] Loading template resources...");
|
|
1935
1935
|
try {
|
|
1936
|
-
const { AvatarDownloader: e } = await Promise.resolve().then(() =>
|
|
1936
|
+
const { AvatarDownloader: e } = await Promise.resolve().then(() => Pa), n = await new e().loadGlobalFlameResources();
|
|
1937
1937
|
await this._avatarCore.loadTemplateResourcesFromBuffers(n) ? h.log("[AvatarKit] Template resources initialized successfully") : h.log("[AvatarKit] Template resources already initialized, skipping...");
|
|
1938
1938
|
} catch (e) {
|
|
1939
1939
|
const t = e instanceof Error ? e.message : String(e);
|
|
@@ -2017,15 +2017,15 @@ class y {
|
|
|
2017
2017
|
if (!this._configuration)
|
|
2018
2018
|
throw new Error("AvatarKit not initialized");
|
|
2019
2019
|
const t = {
|
|
2020
|
-
[
|
|
2020
|
+
[oe.cn]: {
|
|
2021
2021
|
sdkApiBaseUrl: "https://api.spatialwalk.top",
|
|
2022
2022
|
driveningressWsUrl: "wss://api.spatialwalk.top/v1/driveningress/websocket"
|
|
2023
2023
|
},
|
|
2024
|
-
[
|
|
2024
|
+
[oe.us]: {
|
|
2025
2025
|
sdkApiBaseUrl: "https://api.spatialwalk.cloud",
|
|
2026
2026
|
driveningressWsUrl: "wss://api.spatialwalk.cloud/v1/driveningress/websocket"
|
|
2027
2027
|
},
|
|
2028
|
-
[
|
|
2028
|
+
[oe.test]: {
|
|
2029
2029
|
sdkApiBaseUrl: "https://api-test.spatialwalk.top",
|
|
2030
2030
|
driveningressWsUrl: "wss://api-test.spatialwalk.top/v1/driveningress/websocket"
|
|
2031
2031
|
}
|
|
@@ -2043,9 +2043,9 @@ class y {
|
|
|
2043
2043
|
* @internal
|
|
2044
2044
|
*/
|
|
2045
2045
|
static logEvent(e, t = "info", n = {}) {
|
|
2046
|
-
var
|
|
2046
|
+
var o;
|
|
2047
2047
|
const a = {
|
|
2048
|
-
environment: ((
|
|
2048
|
+
environment: ((o = this._configuration) == null ? void 0 : o.environment) ?? "unknown",
|
|
2049
2049
|
sessionToken: this._sessionToken ?? "",
|
|
2050
2050
|
userId: this._userId ?? "",
|
|
2051
2051
|
sdkVersion: this._version,
|
|
@@ -2054,7 +2054,7 @@ class y {
|
|
|
2054
2054
|
h[i](`[Telemetry] ${e}`, a);
|
|
2055
2055
|
}
|
|
2056
2056
|
}
|
|
2057
|
-
|
|
2057
|
+
u(y, "_isInitialized", !1), u(y, "_appId", null), u(y, "_configuration", null), u(y, "_sessionToken", null), u(y, "_userId", null), u(y, "_version", "1.0.0-beta.20"), u(y, "_avatarCore", null), u(y, "_dynamicSdkConfig", null), u(y, "_logLevels", {
|
|
2058
2058
|
debug: "log",
|
|
2059
2059
|
info: "log",
|
|
2060
2060
|
warning: "warn",
|
|
@@ -2062,12 +2062,12 @@ d(y, "_isInitialized", !1), d(y, "_appId", null), d(y, "_configuration", null),
|
|
|
2062
2062
|
});
|
|
2063
2063
|
const we = class we {
|
|
2064
2064
|
constructor() {
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2065
|
+
u(this, "audio", null);
|
|
2066
|
+
u(this, "streamingPlayer", null);
|
|
2067
|
+
u(this, "_isPlaying", !1);
|
|
2068
|
+
u(this, "fps", k.animation.fps);
|
|
2069
|
+
u(this, "onEndedCallback");
|
|
2070
|
+
u(this, "useStreaming", !1);
|
|
2071
2071
|
}
|
|
2072
2072
|
/**
|
|
2073
2073
|
* 解锁音频上下文(Safari 自动播放策略)
|
|
@@ -2123,7 +2123,7 @@ const we = class we {
|
|
|
2123
2123
|
async createAndInitializeStreamingPlayer() {
|
|
2124
2124
|
if (this.streamingPlayer)
|
|
2125
2125
|
return;
|
|
2126
|
-
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-
|
|
2126
|
+
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-DEXcuhRW.js");
|
|
2127
2127
|
this.streamingPlayer = new e({
|
|
2128
2128
|
sampleRate: k.audio.sampleRate,
|
|
2129
2129
|
channelCount: 1,
|
|
@@ -2212,22 +2212,22 @@ const we = class we {
|
|
|
2212
2212
|
this.stop(), this.audio && (this.audio.src = "", this.audio = null), this.streamingPlayer && (this.streamingPlayer.dispose(), this.streamingPlayer = null), this.onEndedCallback = void 0;
|
|
2213
2213
|
}
|
|
2214
2214
|
};
|
|
2215
|
-
|
|
2216
|
-
let
|
|
2215
|
+
u(we, "audioUnlocked", !1);
|
|
2216
|
+
let ie = we, ta = (r) => crypto.getRandomValues(new Uint8Array(r)), ra = (r, e, t) => {
|
|
2217
2217
|
let n = (2 << Math.log2(r.length - 1)) - 1, a = -~(1.6 * n * e / r.length);
|
|
2218
2218
|
return (i = e) => {
|
|
2219
|
-
let
|
|
2219
|
+
let o = "";
|
|
2220
2220
|
for (; ; ) {
|
|
2221
|
-
let
|
|
2221
|
+
let s = t(a), l = a | 0;
|
|
2222
2222
|
for (; l--; )
|
|
2223
|
-
if (
|
|
2223
|
+
if (o += r[s[l] & n] || "", o.length >= i) return o;
|
|
2224
2224
|
}
|
|
2225
2225
|
};
|
|
2226
2226
|
}, na = (r, e = 21) => ra(r, e | 0, ta);
|
|
2227
2227
|
const aa = na("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12);
|
|
2228
2228
|
function er() {
|
|
2229
|
-
const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), a = String(r.getUTCHours()).padStart(2, "0"), i = String(r.getUTCMinutes()).padStart(2, "0"),
|
|
2230
|
-
return `${
|
|
2229
|
+
const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), a = String(r.getUTCHours()).padStart(2, "0"), i = String(r.getUTCMinutes()).padStart(2, "0"), o = String(r.getUTCSeconds()).padStart(2, "0"), s = `${e}${t}${n}${a}${i}${o}`, l = aa();
|
|
2230
|
+
return `${s}_${l}`;
|
|
2231
2231
|
}
|
|
2232
2232
|
function ia() {
|
|
2233
2233
|
let r = 0, e = 0;
|
|
@@ -2248,33 +2248,33 @@ function ia() {
|
|
|
2248
2248
|
}
|
|
2249
2249
|
function Be(r, e, t) {
|
|
2250
2250
|
for (let i = 0; i < 28; i = i + 7) {
|
|
2251
|
-
const
|
|
2252
|
-
if (t.push(l), !
|
|
2251
|
+
const o = r >>> i, s = !(!(o >>> 7) && e == 0), l = (s ? o | 128 : o) & 255;
|
|
2252
|
+
if (t.push(l), !s)
|
|
2253
2253
|
return;
|
|
2254
2254
|
}
|
|
2255
2255
|
const n = r >>> 28 & 15 | (e & 7) << 4, a = !!(e >> 3);
|
|
2256
2256
|
if (t.push((a ? n | 128 : n) & 255), !!a) {
|
|
2257
2257
|
for (let i = 3; i < 31; i = i + 7) {
|
|
2258
|
-
const
|
|
2259
|
-
if (t.push(l), !
|
|
2258
|
+
const o = e >>> i, s = !!(o >>> 7), l = (s ? o | 128 : o) & 255;
|
|
2259
|
+
if (t.push(l), !s)
|
|
2260
2260
|
return;
|
|
2261
2261
|
}
|
|
2262
2262
|
t.push(e >>> 31 & 1);
|
|
2263
2263
|
}
|
|
2264
2264
|
}
|
|
2265
|
-
const
|
|
2266
|
-
function
|
|
2265
|
+
const Ee = 4294967296;
|
|
2266
|
+
function St(r) {
|
|
2267
2267
|
const e = r[0] === "-";
|
|
2268
2268
|
e && (r = r.slice(1));
|
|
2269
2269
|
const t = 1e6;
|
|
2270
2270
|
let n = 0, a = 0;
|
|
2271
|
-
function i(
|
|
2272
|
-
const l = Number(r.slice(
|
|
2273
|
-
a *= t, n = n * t + l, n >=
|
|
2271
|
+
function i(o, s) {
|
|
2272
|
+
const l = Number(r.slice(o, s));
|
|
2273
|
+
a *= t, n = n * t + l, n >= Ee && (a = a + (n / Ee | 0), n = n % Ee);
|
|
2274
2274
|
}
|
|
2275
2275
|
return i(-24, -18), i(-18, -12), i(-12, -6), i(-6), e ? rr(n, a) : je(n, a);
|
|
2276
2276
|
}
|
|
2277
|
-
function
|
|
2277
|
+
function oa(r, e) {
|
|
2278
2278
|
let t = je(r, e);
|
|
2279
2279
|
const n = t.hi & 2147483648;
|
|
2280
2280
|
n && (t = rr(t.lo, t.hi));
|
|
@@ -2282,14 +2282,14 @@ function sa(r, e) {
|
|
|
2282
2282
|
return n ? "-" + a : a;
|
|
2283
2283
|
}
|
|
2284
2284
|
function tr(r, e) {
|
|
2285
|
-
if ({ lo: r, hi: e } =
|
|
2286
|
-
return String(
|
|
2285
|
+
if ({ lo: r, hi: e } = sa(r, e), e <= 2097151)
|
|
2286
|
+
return String(Ee * e + r);
|
|
2287
2287
|
const t = r & 16777215, n = (r >>> 24 | e << 8) & 16777215, a = e >> 16 & 65535;
|
|
2288
|
-
let i = t + n * 6777216 + a * 6710656,
|
|
2288
|
+
let i = t + n * 6777216 + a * 6710656, o = n + a * 8147497, s = a * 2;
|
|
2289
2289
|
const l = 1e7;
|
|
2290
|
-
return i >= l && (
|
|
2290
|
+
return i >= l && (o += Math.floor(i / l), i %= l), o >= l && (s += Math.floor(o / l), o %= l), s.toString() + Ct(o) + Ct(i);
|
|
2291
2291
|
}
|
|
2292
|
-
function
|
|
2292
|
+
function sa(r, e) {
|
|
2293
2293
|
return { lo: r >>> 0, hi: e >>> 0 };
|
|
2294
2294
|
}
|
|
2295
2295
|
function je(r, e) {
|
|
@@ -2330,7 +2330,7 @@ function la() {
|
|
|
2330
2330
|
throw new Error("invalid varint");
|
|
2331
2331
|
return this.assertBounds(), e >>> 0;
|
|
2332
2332
|
}
|
|
2333
|
-
const
|
|
2333
|
+
const j = /* @__PURE__ */ ca();
|
|
2334
2334
|
function ca() {
|
|
2335
2335
|
const r = new DataView(new ArrayBuffer(8));
|
|
2336
2336
|
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")) {
|
|
@@ -2338,35 +2338,35 @@ function ca() {
|
|
|
2338
2338
|
return {
|
|
2339
2339
|
zero: BigInt(0),
|
|
2340
2340
|
supported: !0,
|
|
2341
|
-
parse(
|
|
2342
|
-
const
|
|
2343
|
-
if (
|
|
2344
|
-
throw new Error(`invalid int64: ${
|
|
2345
|
-
return
|
|
2341
|
+
parse(o) {
|
|
2342
|
+
const s = typeof o == "bigint" ? o : BigInt(o);
|
|
2343
|
+
if (s > n || s < t)
|
|
2344
|
+
throw new Error(`invalid int64: ${o}`);
|
|
2345
|
+
return s;
|
|
2346
2346
|
},
|
|
2347
|
-
uParse(
|
|
2348
|
-
const
|
|
2349
|
-
if (
|
|
2350
|
-
throw new Error(`invalid uint64: ${
|
|
2351
|
-
return
|
|
2347
|
+
uParse(o) {
|
|
2348
|
+
const s = typeof o == "bigint" ? o : BigInt(o);
|
|
2349
|
+
if (s > i || s < a)
|
|
2350
|
+
throw new Error(`invalid uint64: ${o}`);
|
|
2351
|
+
return s;
|
|
2352
2352
|
},
|
|
2353
|
-
enc(
|
|
2354
|
-
return r.setBigInt64(0, this.parse(
|
|
2353
|
+
enc(o) {
|
|
2354
|
+
return r.setBigInt64(0, this.parse(o), !0), {
|
|
2355
2355
|
lo: r.getInt32(0, !0),
|
|
2356
2356
|
hi: r.getInt32(4, !0)
|
|
2357
2357
|
};
|
|
2358
2358
|
},
|
|
2359
|
-
uEnc(
|
|
2360
|
-
return r.setBigInt64(0, this.uParse(
|
|
2359
|
+
uEnc(o) {
|
|
2360
|
+
return r.setBigInt64(0, this.uParse(o), !0), {
|
|
2361
2361
|
lo: r.getInt32(0, !0),
|
|
2362
2362
|
hi: r.getInt32(4, !0)
|
|
2363
2363
|
};
|
|
2364
2364
|
},
|
|
2365
|
-
dec(
|
|
2366
|
-
return r.setInt32(0,
|
|
2365
|
+
dec(o, s) {
|
|
2366
|
+
return r.setInt32(0, o, !0), r.setInt32(4, s, !0), r.getBigInt64(0, !0);
|
|
2367
2367
|
},
|
|
2368
|
-
uDec(
|
|
2369
|
-
return r.setInt32(0,
|
|
2368
|
+
uDec(o, s) {
|
|
2369
|
+
return r.setInt32(0, o, !0), r.setInt32(4, s, !0), r.getBigUint64(0, !0);
|
|
2370
2370
|
}
|
|
2371
2371
|
};
|
|
2372
2372
|
}
|
|
@@ -2374,30 +2374,30 @@ function ca() {
|
|
|
2374
2374
|
zero: "0",
|
|
2375
2375
|
supported: !1,
|
|
2376
2376
|
parse(t) {
|
|
2377
|
-
return typeof t != "string" && (t = t.toString()),
|
|
2377
|
+
return typeof t != "string" && (t = t.toString()), Et(t), t;
|
|
2378
2378
|
},
|
|
2379
2379
|
uParse(t) {
|
|
2380
|
-
return typeof t != "string" && (t = t.toString()),
|
|
2380
|
+
return typeof t != "string" && (t = t.toString()), Pt(t), t;
|
|
2381
2381
|
},
|
|
2382
2382
|
enc(t) {
|
|
2383
|
-
return typeof t != "string" && (t = t.toString()),
|
|
2383
|
+
return typeof t != "string" && (t = t.toString()), Et(t), St(t);
|
|
2384
2384
|
},
|
|
2385
2385
|
uEnc(t) {
|
|
2386
|
-
return typeof t != "string" && (t = t.toString()),
|
|
2386
|
+
return typeof t != "string" && (t = t.toString()), Pt(t), St(t);
|
|
2387
2387
|
},
|
|
2388
2388
|
dec(t, n) {
|
|
2389
|
-
return
|
|
2389
|
+
return oa(t, n);
|
|
2390
2390
|
},
|
|
2391
2391
|
uDec(t, n) {
|
|
2392
2392
|
return tr(t, n);
|
|
2393
2393
|
}
|
|
2394
2394
|
};
|
|
2395
2395
|
}
|
|
2396
|
-
function
|
|
2396
|
+
function Et(r) {
|
|
2397
2397
|
if (!/^-?[0-9]+$/.test(r))
|
|
2398
2398
|
throw new Error("invalid int64: " + r);
|
|
2399
2399
|
}
|
|
2400
|
-
function
|
|
2400
|
+
function Pt(r) {
|
|
2401
2401
|
if (!/^[0-9]+$/.test(r))
|
|
2402
2402
|
throw new Error("invalid uint64: " + r);
|
|
2403
2403
|
}
|
|
@@ -2423,12 +2423,12 @@ function nr() {
|
|
|
2423
2423
|
}
|
|
2424
2424
|
return globalThis[De];
|
|
2425
2425
|
}
|
|
2426
|
-
var
|
|
2426
|
+
var te;
|
|
2427
2427
|
(function(r) {
|
|
2428
2428
|
r[r.Varint = 0] = "Varint", r[r.Bit64 = 1] = "Bit64", r[r.LengthDelimited = 2] = "LengthDelimited", r[r.StartGroup = 3] = "StartGroup", r[r.EndGroup = 4] = "EndGroup", r[r.Bit32 = 5] = "Bit32";
|
|
2429
|
-
})(
|
|
2429
|
+
})(te || (te = {}));
|
|
2430
2430
|
const da = 34028234663852886e22, ua = -34028234663852886e22, ha = 4294967295, fa = 2147483647, ma = -2147483648;
|
|
2431
|
-
class
|
|
2431
|
+
class le {
|
|
2432
2432
|
constructor(e = nr().encodeUtf8) {
|
|
2433
2433
|
this.encodeUtf8 = e, this.stack = [], this.chunks = [], this.buf = [];
|
|
2434
2434
|
}
|
|
@@ -2554,35 +2554,35 @@ class oe {
|
|
|
2554
2554
|
* Write a `fixed64` value, a signed, fixed-length 64-bit integer.
|
|
2555
2555
|
*/
|
|
2556
2556
|
sfixed64(e) {
|
|
2557
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), a =
|
|
2557
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), a = j.enc(e);
|
|
2558
2558
|
return n.setInt32(0, a.lo, !0), n.setInt32(4, a.hi, !0), this.raw(t);
|
|
2559
2559
|
}
|
|
2560
2560
|
/**
|
|
2561
2561
|
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
|
|
2562
2562
|
*/
|
|
2563
2563
|
fixed64(e) {
|
|
2564
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), a =
|
|
2564
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), a = j.uEnc(e);
|
|
2565
2565
|
return n.setInt32(0, a.lo, !0), n.setInt32(4, a.hi, !0), this.raw(t);
|
|
2566
2566
|
}
|
|
2567
2567
|
/**
|
|
2568
2568
|
* Write a `int64` value, a signed 64-bit varint.
|
|
2569
2569
|
*/
|
|
2570
2570
|
int64(e) {
|
|
2571
|
-
let t =
|
|
2571
|
+
let t = j.enc(e);
|
|
2572
2572
|
return Be(t.lo, t.hi, this.buf), this;
|
|
2573
2573
|
}
|
|
2574
2574
|
/**
|
|
2575
2575
|
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
2576
2576
|
*/
|
|
2577
2577
|
sint64(e) {
|
|
2578
|
-
const t =
|
|
2578
|
+
const t = j.enc(e), n = t.hi >> 31, a = t.lo << 1 ^ n, i = (t.hi << 1 | t.lo >>> 31) ^ n;
|
|
2579
2579
|
return Be(a, i, this.buf), this;
|
|
2580
2580
|
}
|
|
2581
2581
|
/**
|
|
2582
2582
|
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
2583
2583
|
*/
|
|
2584
2584
|
uint64(e) {
|
|
2585
|
-
const t =
|
|
2585
|
+
const t = j.uEnc(e);
|
|
2586
2586
|
return Be(t.lo, t.hi, this.buf), this;
|
|
2587
2587
|
}
|
|
2588
2588
|
}
|
|
@@ -2608,28 +2608,28 @@ class N {
|
|
|
2608
2608
|
skip(e, t) {
|
|
2609
2609
|
let n = this.pos;
|
|
2610
2610
|
switch (e) {
|
|
2611
|
-
case
|
|
2611
|
+
case te.Varint:
|
|
2612
2612
|
for (; this.buf[this.pos++] & 128; )
|
|
2613
2613
|
;
|
|
2614
2614
|
break;
|
|
2615
|
-
case
|
|
2615
|
+
case te.Bit64:
|
|
2616
2616
|
this.pos += 4;
|
|
2617
|
-
case
|
|
2617
|
+
case te.Bit32:
|
|
2618
2618
|
this.pos += 4;
|
|
2619
2619
|
break;
|
|
2620
|
-
case
|
|
2620
|
+
case te.LengthDelimited:
|
|
2621
2621
|
let a = this.uint32();
|
|
2622
2622
|
this.pos += a;
|
|
2623
2623
|
break;
|
|
2624
|
-
case
|
|
2624
|
+
case te.StartGroup:
|
|
2625
2625
|
for (; ; ) {
|
|
2626
|
-
const [i,
|
|
2627
|
-
if (
|
|
2626
|
+
const [i, o] = this.tag();
|
|
2627
|
+
if (o === te.EndGroup) {
|
|
2628
2628
|
if (t !== void 0 && i !== t)
|
|
2629
2629
|
throw new Error("invalid end group tag");
|
|
2630
2630
|
break;
|
|
2631
2631
|
}
|
|
2632
|
-
this.skip(
|
|
2632
|
+
this.skip(o, i);
|
|
2633
2633
|
}
|
|
2634
2634
|
break;
|
|
2635
2635
|
default:
|
|
@@ -2661,20 +2661,20 @@ class N {
|
|
|
2661
2661
|
* Read a `int64` field, a signed 64-bit varint.
|
|
2662
2662
|
*/
|
|
2663
2663
|
int64() {
|
|
2664
|
-
return
|
|
2664
|
+
return j.dec(...this.varint64());
|
|
2665
2665
|
}
|
|
2666
2666
|
/**
|
|
2667
2667
|
* Read a `uint64` field, an unsigned 64-bit varint.
|
|
2668
2668
|
*/
|
|
2669
2669
|
uint64() {
|
|
2670
|
-
return
|
|
2670
|
+
return j.uDec(...this.varint64());
|
|
2671
2671
|
}
|
|
2672
2672
|
/**
|
|
2673
2673
|
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
|
2674
2674
|
*/
|
|
2675
2675
|
sint64() {
|
|
2676
2676
|
let [e, t] = this.varint64(), n = -(e & 1);
|
|
2677
|
-
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n,
|
|
2677
|
+
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n, j.dec(e, t);
|
|
2678
2678
|
}
|
|
2679
2679
|
/**
|
|
2680
2680
|
* Read a `bool` field, a variant.
|
|
@@ -2699,13 +2699,13 @@ class N {
|
|
|
2699
2699
|
* Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
|
|
2700
2700
|
*/
|
|
2701
2701
|
fixed64() {
|
|
2702
|
-
return
|
|
2702
|
+
return j.uDec(this.sfixed32(), this.sfixed32());
|
|
2703
2703
|
}
|
|
2704
2704
|
/**
|
|
2705
2705
|
* Read a `fixed64` field, a signed, fixed-length 64-bit integer.
|
|
2706
2706
|
*/
|
|
2707
2707
|
sfixed64() {
|
|
2708
|
-
return
|
|
2708
|
+
return j.dec(this.sfixed32(), this.sfixed32());
|
|
2709
2709
|
}
|
|
2710
2710
|
/**
|
|
2711
2711
|
* Read a `float` field, 32-bit floating point number.
|
|
@@ -2759,7 +2759,7 @@ function pa(r) {
|
|
|
2759
2759
|
if (Number.isFinite(r) && (r > da || r < ua))
|
|
2760
2760
|
throw new Error("invalid float32: " + r);
|
|
2761
2761
|
}
|
|
2762
|
-
var
|
|
2762
|
+
var be = /* @__PURE__ */ ((r) => (r[r.MESSAGE_UNSPECIFIED = 0] = "MESSAGE_UNSPECIFIED", r[r.MESSAGE_ERROR = 2] = "MESSAGE_ERROR", r[r.MESSAGE_SERVER_RESPONSE_ANIMATION = 1004] = "MESSAGE_SERVER_RESPONSE_ANIMATION", r[r.MESSAGE_CLIENT_AUDIO_INPUT = 2003] = "MESSAGE_CLIENT_AUDIO_INPUT", r[r.UNRECOGNIZED = -1] = "UNRECOGNIZED", r))(be || {});
|
|
2763
2763
|
function ga(r) {
|
|
2764
2764
|
switch (r) {
|
|
2765
2765
|
case 0:
|
|
@@ -2798,8 +2798,8 @@ function va(r) {
|
|
|
2798
2798
|
function kt() {
|
|
2799
2799
|
return { reqId: "", audio: new Uint8Array(0), end: !1 };
|
|
2800
2800
|
}
|
|
2801
|
-
const
|
|
2802
|
-
encode(r, e = new
|
|
2801
|
+
const de = {
|
|
2802
|
+
encode(r, e = new le()) {
|
|
2803
2803
|
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;
|
|
2804
2804
|
},
|
|
2805
2805
|
decode(r, e) {
|
|
@@ -2846,7 +2846,7 @@ const ce = {
|
|
|
2846
2846
|
return r.reqId !== "" && (e.reqId = r.reqId), r.audio.length !== 0 && (e.audio = wa(r.audio)), r.end !== !1 && (e.end = r.end), e;
|
|
2847
2847
|
},
|
|
2848
2848
|
create(r) {
|
|
2849
|
-
return
|
|
2849
|
+
return de.fromPartial(r ?? {});
|
|
2850
2850
|
},
|
|
2851
2851
|
fromPartial(r) {
|
|
2852
2852
|
const e = kt();
|
|
@@ -2856,8 +2856,8 @@ const ce = {
|
|
|
2856
2856
|
function xt() {
|
|
2857
2857
|
return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
|
|
2858
2858
|
}
|
|
2859
|
-
const
|
|
2860
|
-
encode(r, e = new
|
|
2859
|
+
const ue = {
|
|
2860
|
+
encode(r, e = new le()) {
|
|
2861
2861
|
e.uint32(18).fork();
|
|
2862
2862
|
for (const t of r.translation)
|
|
2863
2863
|
e.float(t);
|
|
@@ -2894,8 +2894,8 @@ const de = {
|
|
|
2894
2894
|
continue;
|
|
2895
2895
|
}
|
|
2896
2896
|
if (i === 18) {
|
|
2897
|
-
const
|
|
2898
|
-
for (; t.pos <
|
|
2897
|
+
const o = t.uint32() + t.pos;
|
|
2898
|
+
for (; t.pos < o; )
|
|
2899
2899
|
a.translation.push(t.float());
|
|
2900
2900
|
continue;
|
|
2901
2901
|
}
|
|
@@ -2907,8 +2907,8 @@ const de = {
|
|
|
2907
2907
|
continue;
|
|
2908
2908
|
}
|
|
2909
2909
|
if (i === 26) {
|
|
2910
|
-
const
|
|
2911
|
-
for (; t.pos <
|
|
2910
|
+
const o = t.uint32() + t.pos;
|
|
2911
|
+
for (; t.pos < o; )
|
|
2912
2912
|
a.rotation.push(t.float());
|
|
2913
2913
|
continue;
|
|
2914
2914
|
}
|
|
@@ -2920,8 +2920,8 @@ const de = {
|
|
|
2920
2920
|
continue;
|
|
2921
2921
|
}
|
|
2922
2922
|
if (i === 34) {
|
|
2923
|
-
const
|
|
2924
|
-
for (; t.pos <
|
|
2923
|
+
const o = t.uint32() + t.pos;
|
|
2924
|
+
for (; t.pos < o; )
|
|
2925
2925
|
a.neckPose.push(t.float());
|
|
2926
2926
|
continue;
|
|
2927
2927
|
}
|
|
@@ -2933,8 +2933,8 @@ const de = {
|
|
|
2933
2933
|
continue;
|
|
2934
2934
|
}
|
|
2935
2935
|
if (i === 42) {
|
|
2936
|
-
const
|
|
2937
|
-
for (; t.pos <
|
|
2936
|
+
const o = t.uint32() + t.pos;
|
|
2937
|
+
for (; t.pos < o; )
|
|
2938
2938
|
a.jawPose.push(t.float());
|
|
2939
2939
|
continue;
|
|
2940
2940
|
}
|
|
@@ -2946,8 +2946,8 @@ const de = {
|
|
|
2946
2946
|
continue;
|
|
2947
2947
|
}
|
|
2948
2948
|
if (i === 50) {
|
|
2949
|
-
const
|
|
2950
|
-
for (; t.pos <
|
|
2949
|
+
const o = t.uint32() + t.pos;
|
|
2950
|
+
for (; t.pos < o; )
|
|
2951
2951
|
a.eyePose.push(t.float());
|
|
2952
2952
|
continue;
|
|
2953
2953
|
}
|
|
@@ -2959,8 +2959,8 @@ const de = {
|
|
|
2959
2959
|
continue;
|
|
2960
2960
|
}
|
|
2961
2961
|
if (i === 58) {
|
|
2962
|
-
const
|
|
2963
|
-
for (; t.pos <
|
|
2962
|
+
const o = t.uint32() + t.pos;
|
|
2963
|
+
for (; t.pos < o; )
|
|
2964
2964
|
a.eyeLid.push(t.float());
|
|
2965
2965
|
continue;
|
|
2966
2966
|
}
|
|
@@ -2972,8 +2972,8 @@ const de = {
|
|
|
2972
2972
|
continue;
|
|
2973
2973
|
}
|
|
2974
2974
|
if (i === 66) {
|
|
2975
|
-
const
|
|
2976
|
-
for (; t.pos <
|
|
2975
|
+
const o = t.uint32() + t.pos;
|
|
2976
|
+
for (; t.pos < o; )
|
|
2977
2977
|
a.expression.push(t.float());
|
|
2978
2978
|
continue;
|
|
2979
2979
|
}
|
|
@@ -2998,26 +2998,26 @@ const de = {
|
|
|
2998
2998
|
};
|
|
2999
2999
|
},
|
|
3000
3000
|
toJSON(r) {
|
|
3001
|
-
var t, n, a, i,
|
|
3001
|
+
var t, n, a, i, o, s, l;
|
|
3002
3002
|
const e = {};
|
|
3003
|
-
return (t = r.translation) != null && t.length && (e.translation = r.translation), (n = r.rotation) != null && n.length && (e.rotation = r.rotation), (a = r.neckPose) != null && a.length && (e.neckPose = r.neckPose), (i = r.jawPose) != null && i.length && (e.jawPose = r.jawPose), (
|
|
3003
|
+
return (t = r.translation) != null && t.length && (e.translation = r.translation), (n = r.rotation) != null && n.length && (e.rotation = r.rotation), (a = r.neckPose) != null && a.length && (e.neckPose = r.neckPose), (i = r.jawPose) != null && i.length && (e.jawPose = r.jawPose), (o = r.eyePose) != null && o.length && (e.eyePose = r.eyePose), (s = r.eyeLid) != null && s.length && (e.eyeLid = r.eyeLid), (l = r.expression) != null && l.length && (e.expression = r.expression), e;
|
|
3004
3004
|
},
|
|
3005
3005
|
create(r) {
|
|
3006
|
-
return
|
|
3006
|
+
return ue.fromPartial(r ?? {});
|
|
3007
3007
|
},
|
|
3008
3008
|
fromPartial(r) {
|
|
3009
|
-
var t, n, a, i,
|
|
3009
|
+
var t, n, a, i, o, s, l;
|
|
3010
3010
|
const e = xt();
|
|
3011
|
-
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 = ((a = r.neckPose) == null ? void 0 : a.map((p) => p)) || [], e.jawPose = ((i = r.jawPose) == null ? void 0 : i.map((p) => p)) || [], e.eyePose = ((
|
|
3011
|
+
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 = ((a = r.neckPose) == null ? void 0 : a.map((p) => p)) || [], e.jawPose = ((i = r.jawPose) == null ? void 0 : i.map((p) => p)) || [], e.eyePose = ((o = r.eyePose) == null ? void 0 : o.map((p) => p)) || [], e.eyeLid = ((s = r.eyeLid) == null ? void 0 : s.map((p) => p)) || [], e.expression = ((l = r.expression) == null ? void 0 : l.map((p) => p)) || [], e;
|
|
3012
3012
|
}
|
|
3013
3013
|
};
|
|
3014
3014
|
function Ft() {
|
|
3015
3015
|
return { keyframes: [] };
|
|
3016
3016
|
}
|
|
3017
|
-
const
|
|
3018
|
-
encode(r, e = new
|
|
3017
|
+
const he = {
|
|
3018
|
+
encode(r, e = new le()) {
|
|
3019
3019
|
for (const t of r.keyframes)
|
|
3020
|
-
|
|
3020
|
+
ue.encode(t, e.uint32(10).fork()).join();
|
|
3021
3021
|
return e;
|
|
3022
3022
|
},
|
|
3023
3023
|
decode(r, e) {
|
|
@@ -3030,7 +3030,7 @@ const ue = {
|
|
|
3030
3030
|
case 1: {
|
|
3031
3031
|
if (i !== 10)
|
|
3032
3032
|
break;
|
|
3033
|
-
a.keyframes.push(
|
|
3033
|
+
a.keyframes.push(ue.decode(t, t.uint32()));
|
|
3034
3034
|
continue;
|
|
3035
3035
|
}
|
|
3036
3036
|
}
|
|
@@ -3042,29 +3042,29 @@ const ue = {
|
|
|
3042
3042
|
},
|
|
3043
3043
|
fromJSON(r) {
|
|
3044
3044
|
return {
|
|
3045
|
-
keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) =>
|
|
3045
|
+
keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) => ue.fromJSON(e)) : []
|
|
3046
3046
|
};
|
|
3047
3047
|
},
|
|
3048
3048
|
toJSON(r) {
|
|
3049
3049
|
var t;
|
|
3050
3050
|
const e = {};
|
|
3051
|
-
return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) =>
|
|
3051
|
+
return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) => ue.toJSON(n))), e;
|
|
3052
3052
|
},
|
|
3053
3053
|
create(r) {
|
|
3054
|
-
return
|
|
3054
|
+
return he.fromPartial(r ?? {});
|
|
3055
3055
|
},
|
|
3056
3056
|
fromPartial(r) {
|
|
3057
3057
|
var t;
|
|
3058
3058
|
const e = Ft();
|
|
3059
|
-
return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) =>
|
|
3059
|
+
return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => ue.fromPartial(n))) || [], e;
|
|
3060
3060
|
}
|
|
3061
3061
|
};
|
|
3062
3062
|
function Mt() {
|
|
3063
3063
|
return { reqId: "", animation: void 0 };
|
|
3064
3064
|
}
|
|
3065
|
-
const
|
|
3066
|
-
encode(r, e = new
|
|
3067
|
-
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 &&
|
|
3065
|
+
const fe = {
|
|
3066
|
+
encode(r, e = new le()) {
|
|
3067
|
+
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && he.encode(r.animation, e.uint32(18).fork()).join(), e;
|
|
3068
3068
|
},
|
|
3069
3069
|
decode(r, e) {
|
|
3070
3070
|
const t = r instanceof N ? r : new N(r);
|
|
@@ -3082,7 +3082,7 @@ const he = {
|
|
|
3082
3082
|
case 2: {
|
|
3083
3083
|
if (i !== 18)
|
|
3084
3084
|
break;
|
|
3085
|
-
a.animation =
|
|
3085
|
+
a.animation = he.decode(t, t.uint32());
|
|
3086
3086
|
continue;
|
|
3087
3087
|
}
|
|
3088
3088
|
}
|
|
@@ -3095,26 +3095,26 @@ const he = {
|
|
|
3095
3095
|
fromJSON(r) {
|
|
3096
3096
|
return {
|
|
3097
3097
|
reqId: U(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
3098
|
-
animation: U(r.animation) ?
|
|
3098
|
+
animation: U(r.animation) ? he.fromJSON(r.animation) : void 0
|
|
3099
3099
|
};
|
|
3100
3100
|
},
|
|
3101
3101
|
toJSON(r) {
|
|
3102
3102
|
const e = {};
|
|
3103
|
-
return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation =
|
|
3103
|
+
return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation = he.toJSON(r.animation)), e;
|
|
3104
3104
|
},
|
|
3105
3105
|
create(r) {
|
|
3106
|
-
return
|
|
3106
|
+
return fe.fromPartial(r ?? {});
|
|
3107
3107
|
},
|
|
3108
3108
|
fromPartial(r) {
|
|
3109
3109
|
const e = Mt();
|
|
3110
|
-
return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ?
|
|
3110
|
+
return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ? he.fromPartial(r.animation) : void 0, e;
|
|
3111
3111
|
}
|
|
3112
3112
|
};
|
|
3113
3113
|
function Lt() {
|
|
3114
3114
|
return { reqId: "", code: 0, reason: "" };
|
|
3115
3115
|
}
|
|
3116
|
-
const
|
|
3117
|
-
encode(r, e = new
|
|
3116
|
+
const me = {
|
|
3117
|
+
encode(r, e = new le()) {
|
|
3118
3118
|
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;
|
|
3119
3119
|
},
|
|
3120
3120
|
decode(r, e) {
|
|
@@ -3161,7 +3161,7 @@ const fe = {
|
|
|
3161
3161
|
return r.reqId !== "" && (e.reqId = r.reqId), r.code !== 0 && (e.code = Math.round(r.code)), r.reason !== "" && (e.reason = r.reason), e;
|
|
3162
3162
|
},
|
|
3163
3163
|
create(r) {
|
|
3164
|
-
return
|
|
3164
|
+
return me.fromPartial(r ?? {});
|
|
3165
3165
|
},
|
|
3166
3166
|
fromPartial(r) {
|
|
3167
3167
|
const e = Lt();
|
|
@@ -3172,8 +3172,8 @@ function Rt() {
|
|
|
3172
3172
|
return { type: 0, error: void 0, serverResponseAnimation: void 0, clientAudioInput: void 0 };
|
|
3173
3173
|
}
|
|
3174
3174
|
const We = {
|
|
3175
|
-
encode(r, e = new
|
|
3176
|
-
return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 &&
|
|
3175
|
+
encode(r, e = new le()) {
|
|
3176
|
+
return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 && me.encode(r.error, e.uint32(18).fork()).join(), r.serverResponseAnimation !== void 0 && fe.encode(r.serverResponseAnimation, e.uint32(26).fork()).join(), r.clientAudioInput !== void 0 && de.encode(r.clientAudioInput, e.uint32(34).fork()).join(), e;
|
|
3177
3177
|
},
|
|
3178
3178
|
decode(r, e) {
|
|
3179
3179
|
const t = r instanceof N ? r : new N(r);
|
|
@@ -3191,19 +3191,19 @@ const We = {
|
|
|
3191
3191
|
case 2: {
|
|
3192
3192
|
if (i !== 18)
|
|
3193
3193
|
break;
|
|
3194
|
-
a.error =
|
|
3194
|
+
a.error = me.decode(t, t.uint32());
|
|
3195
3195
|
continue;
|
|
3196
3196
|
}
|
|
3197
3197
|
case 3: {
|
|
3198
3198
|
if (i !== 26)
|
|
3199
3199
|
break;
|
|
3200
|
-
a.serverResponseAnimation =
|
|
3200
|
+
a.serverResponseAnimation = fe.decode(t, t.uint32());
|
|
3201
3201
|
continue;
|
|
3202
3202
|
}
|
|
3203
3203
|
case 4: {
|
|
3204
3204
|
if (i !== 34)
|
|
3205
3205
|
break;
|
|
3206
|
-
a.clientAudioInput =
|
|
3206
|
+
a.clientAudioInput = de.decode(t, t.uint32());
|
|
3207
3207
|
continue;
|
|
3208
3208
|
}
|
|
3209
3209
|
}
|
|
@@ -3216,21 +3216,21 @@ const We = {
|
|
|
3216
3216
|
fromJSON(r) {
|
|
3217
3217
|
return {
|
|
3218
3218
|
type: U(r.type) ? ga(r.type) : 0,
|
|
3219
|
-
error: U(r.error) ?
|
|
3220
|
-
serverResponseAnimation: U(r.serverResponseAnimation) ?
|
|
3221
|
-
clientAudioInput: U(r.clientAudioInput) ?
|
|
3219
|
+
error: U(r.error) ? me.fromJSON(r.error) : void 0,
|
|
3220
|
+
serverResponseAnimation: U(r.serverResponseAnimation) ? fe.fromJSON(r.serverResponseAnimation) : void 0,
|
|
3221
|
+
clientAudioInput: U(r.clientAudioInput) ? de.fromJSON(r.clientAudioInput) : void 0
|
|
3222
3222
|
};
|
|
3223
3223
|
},
|
|
3224
3224
|
toJSON(r) {
|
|
3225
3225
|
const e = {};
|
|
3226
|
-
return r.type !== 0 && (e.type = va(r.type)), r.error !== void 0 && (e.error =
|
|
3226
|
+
return r.type !== 0 && (e.type = va(r.type)), r.error !== void 0 && (e.error = me.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = fe.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = de.toJSON(r.clientAudioInput)), e;
|
|
3227
3227
|
},
|
|
3228
3228
|
create(r) {
|
|
3229
3229
|
return We.fromPartial(r ?? {});
|
|
3230
3230
|
},
|
|
3231
3231
|
fromPartial(r) {
|
|
3232
3232
|
const e = Rt();
|
|
3233
|
-
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ?
|
|
3233
|
+
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? me.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? fe.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? de.fromPartial(r.clientAudioInput) : void 0, e;
|
|
3234
3234
|
}
|
|
3235
3235
|
};
|
|
3236
3236
|
function ya(r) {
|
|
@@ -3250,7 +3250,7 @@ function U(r) {
|
|
|
3250
3250
|
}
|
|
3251
3251
|
class Aa {
|
|
3252
3252
|
constructor() {
|
|
3253
|
-
|
|
3253
|
+
u(this, "events", /* @__PURE__ */ new Map());
|
|
3254
3254
|
}
|
|
3255
3255
|
on(e, t) {
|
|
3256
3256
|
this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e).add(t);
|
|
@@ -3268,20 +3268,20 @@ class Aa {
|
|
|
3268
3268
|
e ? this.events.delete(e) : this.events.clear();
|
|
3269
3269
|
}
|
|
3270
3270
|
}
|
|
3271
|
-
class
|
|
3271
|
+
class ba extends Aa {
|
|
3272
3272
|
constructor(t) {
|
|
3273
3273
|
super();
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3274
|
+
u(this, "wsUrl");
|
|
3275
|
+
u(this, "reconnectAttempts");
|
|
3276
|
+
u(this, "debug");
|
|
3277
|
+
u(this, "jwtToken");
|
|
3278
|
+
u(this, "appId");
|
|
3279
|
+
u(this, "ws", null);
|
|
3280
|
+
u(this, "currentCharacterId", "");
|
|
3281
|
+
u(this, "currentRetryCount", 0);
|
|
3282
|
+
u(this, "isConnecting", !1);
|
|
3283
|
+
u(this, "isManuallyDisconnected", !1);
|
|
3284
|
+
u(this, "reconnectTimer", null);
|
|
3285
3285
|
this.wsUrl = t.wsUrl, this.reconnectAttempts = t.reconnectAttempts ?? 5, this.debug = t.debug ?? !1, this.jwtToken = t.jwtToken, this.appId = t.appId;
|
|
3286
3286
|
}
|
|
3287
3287
|
/**
|
|
@@ -3329,24 +3329,24 @@ class Sa extends Aa {
|
|
|
3329
3329
|
return h.error("[AnimationWebSocketClient] WebSocket not connected"), !1;
|
|
3330
3330
|
try {
|
|
3331
3331
|
const i = {
|
|
3332
|
-
type:
|
|
3332
|
+
type: be.MESSAGE_CLIENT_AUDIO_INPUT,
|
|
3333
3333
|
clientAudioInput: {
|
|
3334
3334
|
reqId: t,
|
|
3335
3335
|
// protobuf 协议中使用 reqId 字段名
|
|
3336
3336
|
audio: new Uint8Array(n),
|
|
3337
3337
|
end: a
|
|
3338
3338
|
}
|
|
3339
|
-
},
|
|
3340
|
-
We.encode(i,
|
|
3341
|
-
const
|
|
3342
|
-
return this.ws.send(
|
|
3339
|
+
}, o = new le();
|
|
3340
|
+
We.encode(i, o);
|
|
3341
|
+
const s = o.finish();
|
|
3342
|
+
return this.ws.send(s), !0;
|
|
3343
3343
|
} catch (i) {
|
|
3344
|
-
const
|
|
3345
|
-
return h.error("[AnimationWebSocketClient] Failed to send audio data:",
|
|
3344
|
+
const o = i instanceof Error ? i.message : String(i);
|
|
3345
|
+
return h.error("[AnimationWebSocketClient] Failed to send audio data:", o), y.logEvent("character_animation_service", "warning", {
|
|
3346
3346
|
characterId: this.currentCharacterId,
|
|
3347
3347
|
event: "send_audio_failed",
|
|
3348
3348
|
conversationId: t,
|
|
3349
|
-
reason:
|
|
3349
|
+
reason: o
|
|
3350
3350
|
}), this.emit("error", i), !1;
|
|
3351
3351
|
}
|
|
3352
3352
|
}
|
|
@@ -3380,12 +3380,12 @@ class Sa extends Aa {
|
|
|
3380
3380
|
this.ws = new WebSocket(t), this.ws.onopen = () => {
|
|
3381
3381
|
this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"), n();
|
|
3382
3382
|
}, this.ws.onmessage = (i) => {
|
|
3383
|
-
i.data instanceof ArrayBuffer ? this.handleMessage(i.data) : i.data instanceof Blob ? i.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((
|
|
3384
|
-
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:",
|
|
3383
|
+
i.data instanceof ArrayBuffer ? this.handleMessage(i.data) : i.data instanceof Blob ? i.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((o) => {
|
|
3384
|
+
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", o), y.logEvent("character_animation_service", "error", {
|
|
3385
3385
|
characterId: this.currentCharacterId,
|
|
3386
3386
|
event: "decode_blob_failed",
|
|
3387
|
-
reason:
|
|
3388
|
-
}), this.emit("error",
|
|
3387
|
+
reason: o instanceof Error ? o.message : String(o)
|
|
3388
|
+
}), this.emit("error", o);
|
|
3389
3389
|
}) : h.warn("[AnimationWebSocketClient] Received non-binary data:", typeof i.data);
|
|
3390
3390
|
}, this.ws.onerror = (i) => {
|
|
3391
3391
|
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", i), y.logEvent("character_animation_service", "error", {
|
|
@@ -3417,7 +3417,7 @@ class Sa extends Aa {
|
|
|
3417
3417
|
}), this.emit("error", new Error(a.error.reason || "Server error"));
|
|
3418
3418
|
return;
|
|
3419
3419
|
}
|
|
3420
|
-
if (a.type ===
|
|
3420
|
+
if (a.type === be.MESSAGE_ERROR) {
|
|
3421
3421
|
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), y.logEvent("character_animation_service", "warning", {
|
|
3422
3422
|
characterId: this.currentCharacterId,
|
|
3423
3423
|
event: "message_error_without_payload"
|
|
@@ -3444,17 +3444,21 @@ class Sa extends Aa {
|
|
|
3444
3444
|
}, t);
|
|
3445
3445
|
}
|
|
3446
3446
|
}
|
|
3447
|
-
class
|
|
3447
|
+
class Sa {
|
|
3448
|
+
// 避免并发连接
|
|
3448
3449
|
constructor(e) {
|
|
3449
|
-
|
|
3450
|
-
|
|
3450
|
+
u(this, "wsClient");
|
|
3451
|
+
u(this, "dataController");
|
|
3451
3452
|
// 组合播放层
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3453
|
+
u(this, "currentConversationId", null);
|
|
3454
|
+
u(this, "audioBytesPerSecond", k.audio.sampleRate * 2);
|
|
3455
|
+
u(this, "audioMetrics", this.createAudioMetrics());
|
|
3456
|
+
u(this, "isFallbackMode", !1);
|
|
3457
|
+
// 连接超时降级模式标记
|
|
3458
|
+
u(this, "isConnecting", !1);
|
|
3455
3459
|
this.dataController = e;
|
|
3456
3460
|
const t = y.getEnvironmentConfig();
|
|
3457
|
-
this.wsClient = new
|
|
3461
|
+
this.wsClient = new ba({
|
|
3458
3462
|
wsUrl: t.driveningressWsUrl,
|
|
3459
3463
|
reconnectAttempts: 5,
|
|
3460
3464
|
debug: !1,
|
|
@@ -3466,14 +3470,46 @@ class ba {
|
|
|
3466
3470
|
* 连接服务
|
|
3467
3471
|
*/
|
|
3468
3472
|
async connect(e) {
|
|
3469
|
-
|
|
3473
|
+
var o, s, l, p;
|
|
3474
|
+
if (this.isConnecting)
|
|
3475
|
+
throw h.warn("[NetworkLayer] Connection already in progress, waiting for current connection to complete"), new H("Connection already in progress", "CONNECTION_IN_PROGRESS");
|
|
3476
|
+
(s = (o = this.dataController).onConnectionState) == null || s.call(o, ee.connecting), this.isFallbackMode = !1, this.setupWebSocketListeners(), this.isConnecting = !0;
|
|
3477
|
+
const t = 15e3;
|
|
3478
|
+
let n = null;
|
|
3479
|
+
const a = this.wsClient.connect(e), i = new Promise((c) => {
|
|
3480
|
+
n = setTimeout(() => {
|
|
3481
|
+
var d, m;
|
|
3482
|
+
this.dataController.connected || (this.isFallbackMode = !0, h.warn(`[NetworkLayer] WebSocket connection timeout (${t}ms) - entering fallback mode`), y.logEvent("character_manager", "warning", {
|
|
3483
|
+
characterId: this.dataController.getAvatarId(),
|
|
3484
|
+
event: "websocket_connection_timeout_fallback",
|
|
3485
|
+
timeoutMs: t
|
|
3486
|
+
}), (m = (d = this.dataController).onConnectionState) == null || m.call(d, ee.failed)), c();
|
|
3487
|
+
}, t);
|
|
3488
|
+
});
|
|
3489
|
+
try {
|
|
3490
|
+
await Promise.race([a, i]), n && clearTimeout(n);
|
|
3491
|
+
} catch (c) {
|
|
3492
|
+
throw n && clearTimeout(n), this.isFallbackMode || (this.isFallbackMode = !0, h.warn("[NetworkLayer] WebSocket connection failed - entering fallback mode"), y.logEvent("character_manager", "warning", {
|
|
3493
|
+
characterId: this.dataController.getAvatarId(),
|
|
3494
|
+
event: "websocket_connection_failed_fallback"
|
|
3495
|
+
})), (p = (l = this.dataController).onConnectionState) == null || p.call(l, ee.failed), c;
|
|
3496
|
+
} finally {
|
|
3497
|
+
this.isConnecting = !1;
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
/**
|
|
3501
|
+
* 检查是否可以发送音频数据(包括降级模式)
|
|
3502
|
+
* @internal
|
|
3503
|
+
*/
|
|
3504
|
+
canSend() {
|
|
3505
|
+
return this.isFallbackMode || this.dataController.connected;
|
|
3470
3506
|
}
|
|
3471
3507
|
/**
|
|
3472
3508
|
* 发送音频数据到服务器
|
|
3473
3509
|
* 注意:打断逻辑由 AvatarController.send() 统一处理,这里只负责网络通信
|
|
3474
3510
|
*/
|
|
3475
3511
|
sendAudioData(e, t) {
|
|
3476
|
-
var
|
|
3512
|
+
var s, l;
|
|
3477
3513
|
this.currentConversationId || (this.currentConversationId = this.wsClient.generateConversationId(), this.resetAudioMetrics(), y.logEvent("character_manager", "info", {
|
|
3478
3514
|
characterId: this.dataController.getAvatarId(),
|
|
3479
3515
|
event: "conversation_started",
|
|
@@ -3483,8 +3519,12 @@ class ba {
|
|
|
3483
3519
|
let a = !1;
|
|
3484
3520
|
n.startTimestamp === 0 && (n.startTimestamp = Date.now(), a = !0), n.accumulatedBytes += e.byteLength;
|
|
3485
3521
|
const i = n.accumulatedBytes / this.audioBytesPerSecond;
|
|
3486
|
-
if (i >= 2 && n.tap2Timestamp === 0 && (n.tap2Timestamp = Date.now(), a = !0), i >= 4 && n.tap4Timestamp === 0 && (n.tap4Timestamp = Date.now(), a = !0), t && n.endTimestamp === 0 && (n.endTimestamp = Date.now(), a = !0), e.byteLength === 0 && !t && h.warn("[NetworkLayer] Warning: sending empty audio data (size=0, end=false)"),
|
|
3487
|
-
h.
|
|
3522
|
+
if (i >= 2 && n.tap2Timestamp === 0 && (n.tap2Timestamp = Date.now(), a = !0), i >= 4 && n.tap4Timestamp === 0 && (n.tap4Timestamp = Date.now(), a = !0), t && n.endTimestamp === 0 && (n.endTimestamp = Date.now(), a = !0), e.byteLength === 0 && !t && h.warn("[NetworkLayer] Warning: sending empty audio data (size=0, end=false)"), this.isFallbackMode) {
|
|
3523
|
+
this.currentConversationId && (h.warn("[NetworkLayer] Fallback mode: skipping WebSocket send, triggering audio-only mode"), this.dataController.yieldFramesData([], this.currentConversationId));
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
if (!this.wsClient.sendAudioData(this.currentConversationId, e, t)) {
|
|
3527
|
+
h.error("[NetworkLayer] Failed to send audio data to WebSocket"), (l = (s = this.dataController).onError) == null || l.call(s, new H("Failed to send audio data to WebSocket", "SEND_FAILED")), y.logEvent("character_animation_service", "error", {
|
|
3488
3528
|
characterId: this.dataController.getAvatarId(),
|
|
3489
3529
|
event: "send_audio_failed",
|
|
3490
3530
|
conversationId: this.currentConversationId
|
|
@@ -3497,7 +3537,7 @@ class ba {
|
|
|
3497
3537
|
* 断开连接
|
|
3498
3538
|
*/
|
|
3499
3539
|
disconnect() {
|
|
3500
|
-
this.wsClient.removeAllListeners(), this.wsClient.disconnect(), this.currentConversationId = null;
|
|
3540
|
+
this.isFallbackMode = !1, this.isConnecting = !1, this.wsClient.removeAllListeners(), this.wsClient.disconnect(), this.currentConversationId = null;
|
|
3501
3541
|
}
|
|
3502
3542
|
/**
|
|
3503
3543
|
* 获取当前会话ID
|
|
@@ -3518,13 +3558,13 @@ class ba {
|
|
|
3518
3558
|
setupWebSocketListeners() {
|
|
3519
3559
|
this.wsClient.removeAllListeners(), this.wsClient.on("connected", () => {
|
|
3520
3560
|
var e, t;
|
|
3521
|
-
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3561
|
+
this.isFallbackMode = !1, this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e, ee.connected), y.logEvent("character_animation_service", "info", {
|
|
3522
3562
|
characterId: this.dataController.getAvatarId(),
|
|
3523
3563
|
event: "connected"
|
|
3524
3564
|
});
|
|
3525
3565
|
}), this.wsClient.on("disconnected", () => {
|
|
3526
3566
|
var e, t;
|
|
3527
|
-
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3567
|
+
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e, ee.disconnected), y.logEvent("character_animation_service", "warning", {
|
|
3528
3568
|
characterId: this.dataController.getAvatarId(),
|
|
3529
3569
|
event: "disconnected"
|
|
3530
3570
|
});
|
|
@@ -3534,13 +3574,13 @@ class ba {
|
|
|
3534
3574
|
event: "reconnecting"
|
|
3535
3575
|
});
|
|
3536
3576
|
}), this.wsClient.on("error", (e) => {
|
|
3537
|
-
var n, a, i,
|
|
3577
|
+
var n, a, i, o;
|
|
3538
3578
|
const t = e instanceof Error ? e.message : String(e);
|
|
3539
3579
|
h.error("[NetworkLayer] WebSocket error:", t), y.logEvent("character_animation_service", "error", {
|
|
3540
3580
|
characterId: this.dataController.getAvatarId(),
|
|
3541
3581
|
event: "websocket_error",
|
|
3542
3582
|
reason: t
|
|
3543
|
-
}), (a = (n = this.dataController).onConnectionState) == null || a.call(n,
|
|
3583
|
+
}), (a = (n = this.dataController).onConnectionState) == null || a.call(n, ee.failed), (o = (i = this.dataController).onError) == null || o.call(i, e);
|
|
3544
3584
|
}), this.wsClient.on("message", (e) => {
|
|
3545
3585
|
this.handleMessage(e);
|
|
3546
3586
|
});
|
|
@@ -3551,10 +3591,10 @@ class ba {
|
|
|
3551
3591
|
handleMessage(e) {
|
|
3552
3592
|
try {
|
|
3553
3593
|
switch (e.type) {
|
|
3554
|
-
case
|
|
3594
|
+
case be.MESSAGE_SERVER_RESPONSE_ANIMATION:
|
|
3555
3595
|
this.handleAnimationMessage(e);
|
|
3556
3596
|
break;
|
|
3557
|
-
case
|
|
3597
|
+
case be.MESSAGE_ERROR:
|
|
3558
3598
|
this.handleErrorMessage(e);
|
|
3559
3599
|
break;
|
|
3560
3600
|
}
|
|
@@ -3599,7 +3639,7 @@ class ba {
|
|
|
3599
3639
|
* 处理错误消息
|
|
3600
3640
|
*/
|
|
3601
3641
|
handleErrorMessage(e) {
|
|
3602
|
-
var a, i,
|
|
3642
|
+
var a, i, o, s;
|
|
3603
3643
|
if (!e.error) {
|
|
3604
3644
|
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"), y.logEvent("character_manager", "warning", {
|
|
3605
3645
|
characterId: this.dataController.getAvatarId(),
|
|
@@ -3620,7 +3660,7 @@ class ba {
|
|
|
3620
3660
|
characterId: this.dataController.getAvatarId(),
|
|
3621
3661
|
conversationId: t,
|
|
3622
3662
|
reason: e.error.reason
|
|
3623
|
-
}), (
|
|
3663
|
+
}), (s = (o = this.dataController).onError) == null || s.call(o, new H(
|
|
3624
3664
|
e.error.reason || "Server error occurred",
|
|
3625
3665
|
((i = e.error.code) == null ? void 0 : i.toString()) || "SERVER_ERROR"
|
|
3626
3666
|
)), this.currentConversationId && t === this.currentConversationId && (h.warn("[NetworkLayer] Server error for current conversation - triggering audio-only mode via empty keyframes"), this.dataController.yieldFramesData([], t));
|
|
@@ -3663,44 +3703,44 @@ class Ca {
|
|
|
3663
3703
|
// 音频独立播放模式标志
|
|
3664
3704
|
constructor(e, t) {
|
|
3665
3705
|
// ========== Configuration and Composition ==========
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3706
|
+
u(this, "networkLayer");
|
|
3707
|
+
u(this, "playbackMode");
|
|
3708
|
+
u(this, "avatar");
|
|
3669
3709
|
// ========== Player Management ==========
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3710
|
+
u(this, "animationPlayer", null);
|
|
3711
|
+
u(this, "currentKeyframes", []);
|
|
3712
|
+
u(this, "pendingAudioChunks", []);
|
|
3713
|
+
u(this, "isPlaying", !1);
|
|
3674
3714
|
// ========== State Management ==========
|
|
3675
|
-
|
|
3676
|
-
|
|
3715
|
+
u(this, "isConnected", !1);
|
|
3716
|
+
u(this, "currentState", M.idle);
|
|
3677
3717
|
// ========== Conversation ID Management (for external data mode) ==========
|
|
3678
|
-
|
|
3679
|
-
|
|
3718
|
+
u(this, "currentConversationId", null);
|
|
3719
|
+
u(this, "reqEnd", !1);
|
|
3680
3720
|
// ========== Event System ==========
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3721
|
+
u(this, "onConnectionState", null);
|
|
3722
|
+
u(this, "onAvatarState", null);
|
|
3723
|
+
u(this, "onError", null);
|
|
3724
|
+
u(this, "eventListeners", /* @__PURE__ */ new Map());
|
|
3685
3725
|
// ========== Callbacks ==========
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3726
|
+
u(this, "renderCallback");
|
|
3727
|
+
u(this, "transitionCompleteCallback");
|
|
3728
|
+
u(this, "characterHandle", null);
|
|
3689
3729
|
// Character handle for multi-character support
|
|
3690
3730
|
// ========== Playback Loop ==========
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3731
|
+
u(this, "playbackLoopId", null);
|
|
3732
|
+
u(this, "lastRenderedFrameIndex", -1);
|
|
3733
|
+
u(this, "keyframesOffset", 0);
|
|
3694
3734
|
// Offset to track how many frames were removed from the beginning
|
|
3695
|
-
|
|
3735
|
+
u(this, "MAX_KEYFRAMES", 5e3);
|
|
3696
3736
|
// Maximum keyframes to keep in memory during playback
|
|
3697
|
-
|
|
3737
|
+
u(this, "KEYFRAMES_CLEANUP_THRESHOLD", 3e3);
|
|
3698
3738
|
// Cleanup threshold (keep some buffer)
|
|
3699
|
-
|
|
3739
|
+
u(this, "MAX_PENDING_AUDIO_CHUNKS", 100);
|
|
3700
3740
|
// Maximum pending audio chunks to prevent memory leak
|
|
3701
3741
|
// ========== Audio Only Mode ==========
|
|
3702
|
-
|
|
3703
|
-
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ??
|
|
3742
|
+
u(this, "isAudioOnlyMode", !1);
|
|
3743
|
+
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? pe.network, this.playbackMode === pe.network && (this.networkLayer = new Sa(this));
|
|
3704
3744
|
}
|
|
3705
3745
|
// ========== Internal Accessors (for NetworkLayer and AvatarView) ==========
|
|
3706
3746
|
/**
|
|
@@ -3759,12 +3799,12 @@ class Ca {
|
|
|
3759
3799
|
*/
|
|
3760
3800
|
async start() {
|
|
3761
3801
|
if (!this.networkLayer)
|
|
3762
|
-
throw new
|
|
3802
|
+
throw new H(
|
|
3763
3803
|
"Network layer not available. Use network playback mode.",
|
|
3764
3804
|
"NETWORK_LAYER_NOT_AVAILABLE"
|
|
3765
3805
|
);
|
|
3766
3806
|
if (!this.animationPlayer) {
|
|
3767
|
-
this.animationPlayer = new
|
|
3807
|
+
this.animationPlayer = new ie();
|
|
3768
3808
|
try {
|
|
3769
3809
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
3770
3810
|
} catch (e) {
|
|
@@ -3784,21 +3824,23 @@ class Ca {
|
|
|
3784
3824
|
* @returns conversationId - Conversation ID for this audio session
|
|
3785
3825
|
*/
|
|
3786
3826
|
send(e, t = !1) {
|
|
3787
|
-
var a, i;
|
|
3788
|
-
if (!this.networkLayer
|
|
3789
|
-
return (a = this.onError) == null || a.call(this, new
|
|
3827
|
+
var a, i, o;
|
|
3828
|
+
if (!this.networkLayer)
|
|
3829
|
+
return (a = this.onError) == null || a.call(this, new H("Network layer not available", "NETWORK_LAYER_NOT_AVAILABLE")), null;
|
|
3830
|
+
if (!this.networkLayer.canSend())
|
|
3831
|
+
return (i = this.onError) == null || i.call(this, new H("Service not connected", "NOT_CONNECTED")), y.logEvent("character_manager", "warning", {
|
|
3790
3832
|
characterId: this.avatar.id,
|
|
3791
3833
|
event: "send_not_connected"
|
|
3792
3834
|
}), null;
|
|
3793
3835
|
const n = this.networkLayer.getCurrentConversationId();
|
|
3794
|
-
return this.reqEnd && this.isPlaying && n && this.interrupt(), this.networkLayer.sendAudioData(e, t), t && (this.reqEnd = !0),
|
|
3836
|
+
return this.reqEnd && this.isPlaying && n && this.interrupt(), this.addAudioChunkToBuffer(new Uint8Array(e), t), this.networkLayer.sendAudioData(e, t), t && (this.reqEnd = !0), (o = this.onAvatarState) == null || o.call(this, M.active), this.networkLayer.getCurrentConversationId();
|
|
3795
3837
|
}
|
|
3796
3838
|
/**
|
|
3797
3839
|
* Close service (network mode only)
|
|
3798
3840
|
*/
|
|
3799
3841
|
close() {
|
|
3800
3842
|
var e;
|
|
3801
|
-
(this.isPlaying || this.currentState === M.paused) && this.stopPlayback(), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.disconnect() : this.currentConversationId = null, this.reqEnd = !1, this.isConnected = !1, (e = this.onConnectionState) == null || e.call(this,
|
|
3843
|
+
(this.isPlaying || this.currentState === M.paused) && this.stopPlayback(), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.disconnect() : this.currentConversationId = null, this.reqEnd = !1, this.isConnected = !1, (e = this.onConnectionState) == null || e.call(this, ee.disconnected);
|
|
3802
3844
|
}
|
|
3803
3845
|
// ========== External Data Mode Interface ==========
|
|
3804
3846
|
/**
|
|
@@ -3809,12 +3851,12 @@ class Ca {
|
|
|
3809
3851
|
* @returns conversationId - New conversation ID for this conversation session
|
|
3810
3852
|
*/
|
|
3811
3853
|
async playback(e, t) {
|
|
3812
|
-
if ((this.isPlaying || this.currentConversationId) && this.interrupt(), this.currentConversationId = this.generateAndLogNewConversationId(), this.reqEnd = !1, this.clearPlaybackData(), this.animationPlayer || (this.animationPlayer = new
|
|
3854
|
+
if ((this.isPlaying || this.currentConversationId) && this.interrupt(), this.currentConversationId = this.generateAndLogNewConversationId(), this.reqEnd = !1, this.clearPlaybackData(), this.animationPlayer || (this.animationPlayer = new ie()), this.animationPlayer.isStreamingReady() || await this.animationPlayer.createAndInitializeStreamingPlayer(), e && e.length > 0 && this.pendingAudioChunks.push(...e), t && t.length > 0 ? (this.currentKeyframes = t, this.emit("keyframesUpdate", this.currentKeyframes)) : (h.warn("[AvatarController] Empty animation data in playback - enabling audio-only mode"), y.logEvent("character_manager", "info", {
|
|
3813
3855
|
characterId: this.avatar.id,
|
|
3814
3856
|
event: "empty_animation_data_audio_only_fallback",
|
|
3815
3857
|
conversationId: this.currentConversationId
|
|
3816
3858
|
}), this.isAudioOnlyMode = !0), this.pendingAudioChunks.length === 0)
|
|
3817
|
-
throw new
|
|
3859
|
+
throw new H("No audio chunks to play", "NO_AUDIO");
|
|
3818
3860
|
return this.isAudioOnlyMode ? await this.startAudioOnlyPlayback() : await this.startStreamingPlayback(), this.currentConversationId;
|
|
3819
3861
|
}
|
|
3820
3862
|
/**
|
|
@@ -3828,7 +3870,7 @@ class Ca {
|
|
|
3828
3870
|
this.animationPlayer.addAudioChunk(e, t);
|
|
3829
3871
|
else if (e.length > 0 || t) {
|
|
3830
3872
|
if (this.pendingAudioChunks.length >= this.MAX_PENDING_AUDIO_CHUNKS) {
|
|
3831
|
-
const i = this.pendingAudioChunks.findIndex((
|
|
3873
|
+
const i = this.pendingAudioChunks.findIndex((o) => o.isLast);
|
|
3832
3874
|
i >= 0 && i < this.pendingAudioChunks.length - 1 ? this.pendingAudioChunks.splice(0, i) : this.pendingAudioChunks.shift(), h.warn(`[AvatarController] Pending audio chunks limit reached (${this.MAX_PENDING_AUDIO_CHUNKS}), removed oldest chunk`);
|
|
3833
3875
|
}
|
|
3834
3876
|
this.pendingAudioChunks.push({ data: e, isLast: t }), (a = this.onAvatarState) == null || a.call(this, M.active);
|
|
@@ -3879,7 +3921,7 @@ class Ca {
|
|
|
3879
3921
|
}
|
|
3880
3922
|
this.currentKeyframes.length === 0 ? this.currentKeyframes = e : this.currentKeyframes.push(...e), this.emit("keyframesUpdate", this.currentKeyframes), !this.isPlaying && this.pendingAudioChunks.length > 0 && this.currentKeyframes.length > 0 && this.startStreamingPlayback().catch((a) => {
|
|
3881
3923
|
var i;
|
|
3882
|
-
h.error("[AvatarController] Failed to auto-start playback:", a), (i = this.onError) == null || i.call(this, new
|
|
3924
|
+
h.error("[AvatarController] Failed to auto-start playback:", a), (i = this.onError) == null || i.call(this, new H("Failed to start playback", "PLAYBACK_START_FAILED"));
|
|
3883
3925
|
});
|
|
3884
3926
|
}
|
|
3885
3927
|
// ========== Common Interface ==========
|
|
@@ -3964,7 +4006,7 @@ class Ca {
|
|
|
3964
4006
|
*/
|
|
3965
4007
|
getEffectiveConversationId() {
|
|
3966
4008
|
var e;
|
|
3967
|
-
return this.playbackMode ===
|
|
4009
|
+
return this.playbackMode === pe.network ? ((e = this.networkLayer) == null ? void 0 : e.getCurrentConversationId()) || null : this.currentConversationId;
|
|
3968
4010
|
}
|
|
3969
4011
|
// ========== Internal Methods (for NetworkLayer and AvatarView use) ==========
|
|
3970
4012
|
/**
|
|
@@ -4010,7 +4052,7 @@ class Ca {
|
|
|
4010
4052
|
*/
|
|
4011
4053
|
async startStreamingPlaybackInternal() {
|
|
4012
4054
|
var e, t, n;
|
|
4013
|
-
if (this.animationPlayer || (this.animationPlayer = new
|
|
4055
|
+
if (this.animationPlayer || (this.animationPlayer = new ie()), !this.animationPlayer.isStreamingReady())
|
|
4014
4056
|
try {
|
|
4015
4057
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
4016
4058
|
} catch (a) {
|
|
@@ -4027,11 +4069,11 @@ class Ca {
|
|
|
4027
4069
|
}
|
|
4028
4070
|
try {
|
|
4029
4071
|
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
4030
|
-
var i,
|
|
4072
|
+
var i, o;
|
|
4031
4073
|
this.isPlaying = !1, this.currentState = M.idle, (i = this.onAvatarState) == null || i.call(this, M.idle), this.emit("stopRendering"), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.resetConversationId() : this.currentConversationId = null, this.reqEnd = !1, this.isAudioOnlyMode = !1, y.logEvent("character_player", "info", {
|
|
4032
4074
|
characterId: this.avatar.id,
|
|
4033
4075
|
event: "playback_ended",
|
|
4034
|
-
conversationId: ((
|
|
4076
|
+
conversationId: ((o = this.networkLayer) == null ? void 0 : o.getCurrentConversationId()) || void 0
|
|
4035
4077
|
});
|
|
4036
4078
|
}), this.emit("startRendering");
|
|
4037
4079
|
const a = this.animationPlayer.getStreamingPlayer();
|
|
@@ -4042,7 +4084,7 @@ class Ca {
|
|
|
4042
4084
|
});
|
|
4043
4085
|
} catch (a) {
|
|
4044
4086
|
const i = a instanceof Error ? a.message : String(a);
|
|
4045
|
-
h.error("[AvatarController] Failed to start streaming playback:", i), (n = this.onError) == null || n.call(this, new
|
|
4087
|
+
h.error("[AvatarController] Failed to start streaming playback:", i), (n = this.onError) == null || n.call(this, new H("Failed to start streaming playback", "INIT_FAILED")), this.isPlaying = !1;
|
|
4046
4088
|
}
|
|
4047
4089
|
}
|
|
4048
4090
|
/**
|
|
@@ -4070,13 +4112,13 @@ class Ca {
|
|
|
4070
4112
|
return;
|
|
4071
4113
|
}
|
|
4072
4114
|
if (this.lastRenderedFrameIndex = a, this.currentKeyframes.length > this.MAX_KEYFRAMES) {
|
|
4073
|
-
const
|
|
4074
|
-
|
|
4115
|
+
const o = this.KEYFRAMES_CLEANUP_THRESHOLD, s = a - o;
|
|
4116
|
+
s > 0 && s < a && (this.currentKeyframes.splice(0, s), this.keyframesOffset += s, i = a - this.keyframesOffset, i < 0 && (i = 0), i >= this.currentKeyframes.length && (i = this.currentKeyframes.length - 1), h.log(`[AvatarController] Cleaned up ${s} old keyframes (kept ${this.currentKeyframes.length} frames, offset: ${this.keyframesOffset})`));
|
|
4075
4117
|
}
|
|
4076
4118
|
if (i >= 0 && i < this.currentKeyframes.length) {
|
|
4077
|
-
const
|
|
4119
|
+
const o = this.currentKeyframes[i], s = Vt(o), l = y.getAvatarCore();
|
|
4078
4120
|
if (l) {
|
|
4079
|
-
const p = await l.computeFrameFlatFromParams(
|
|
4121
|
+
const p = await l.computeFrameFlatFromParams(s, this.characterHandle ?? void 0);
|
|
4080
4122
|
p && this.renderCallback && this.renderCallback(p, a);
|
|
4081
4123
|
}
|
|
4082
4124
|
}
|
|
@@ -4112,7 +4154,7 @@ class Ca {
|
|
|
4112
4154
|
*/
|
|
4113
4155
|
async startAudioOnlyPlayback() {
|
|
4114
4156
|
var e, t;
|
|
4115
|
-
if (this.animationPlayer || (this.animationPlayer = new
|
|
4157
|
+
if (this.animationPlayer || (this.animationPlayer = new ie()), !this.animationPlayer.isStreamingReady())
|
|
4116
4158
|
try {
|
|
4117
4159
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
4118
4160
|
} catch (n) {
|
|
@@ -4140,7 +4182,7 @@ class Ca {
|
|
|
4140
4182
|
});
|
|
4141
4183
|
} catch (n) {
|
|
4142
4184
|
const a = n instanceof Error ? n.message : String(n);
|
|
4143
|
-
throw h.error("[AvatarController] Failed to start audio-only playback:", a), (t = this.onError) == null || t.call(this, new
|
|
4185
|
+
throw h.error("[AvatarController] Failed to start audio-only playback:", a), (t = this.onError) == null || t.call(this, new H("Failed to start audio-only playback", "AUDIO_ONLY_INIT_FAILED")), this.isPlaying = !1, this.isAudioOnlyMode = !1, n;
|
|
4144
4186
|
}
|
|
4145
4187
|
}
|
|
4146
4188
|
/**
|
|
@@ -4183,7 +4225,7 @@ class Ca {
|
|
|
4183
4225
|
* Add audio chunk to buffer
|
|
4184
4226
|
*/
|
|
4185
4227
|
addAudioChunkToBuffer(e, t) {
|
|
4186
|
-
if (this.animationPlayer || (this.animationPlayer = new
|
|
4228
|
+
if (this.animationPlayer || (this.animationPlayer = new ie()), this.isPlaying && this.animationPlayer.isStreamingReady())
|
|
4187
4229
|
this.animationPlayer.addAudioChunk(e, t);
|
|
4188
4230
|
else {
|
|
4189
4231
|
if (this.pendingAudioChunks.length >= this.MAX_PENDING_AUDIO_CHUNKS) {
|
|
@@ -4238,21 +4280,21 @@ async function _a(r) {
|
|
|
4238
4280
|
throw new Error(`[downloadResource] ${r} → ${t}`);
|
|
4239
4281
|
}
|
|
4240
4282
|
}
|
|
4241
|
-
const
|
|
4283
|
+
const Ea = 50, ne = /* @__PURE__ */ new Map();
|
|
4242
4284
|
async function Ne(r) {
|
|
4243
|
-
const e =
|
|
4285
|
+
const e = ne.get(r);
|
|
4244
4286
|
if (e)
|
|
4245
|
-
return
|
|
4287
|
+
return ne.delete(r), ne.set(r, e), e;
|
|
4246
4288
|
const t = await _a(r);
|
|
4247
|
-
if (
|
|
4248
|
-
const n =
|
|
4249
|
-
n &&
|
|
4289
|
+
if (ne.size >= Ea) {
|
|
4290
|
+
const n = ne.keys().next().value;
|
|
4291
|
+
n && ne.delete(n);
|
|
4250
4292
|
}
|
|
4251
|
-
return
|
|
4293
|
+
return ne.set(r, t), t;
|
|
4252
4294
|
}
|
|
4253
4295
|
class ir {
|
|
4254
4296
|
constructor(e = "/") {
|
|
4255
|
-
|
|
4297
|
+
u(this, "baseAssetsPath");
|
|
4256
4298
|
this.baseAssetsPath = e;
|
|
4257
4299
|
}
|
|
4258
4300
|
/**
|
|
@@ -4260,7 +4302,7 @@ class ir {
|
|
|
4260
4302
|
* Falls back to global CDN config if not provided by API
|
|
4261
4303
|
*/
|
|
4262
4304
|
async loadTemplateResources(e, t = null) {
|
|
4263
|
-
var c,
|
|
4305
|
+
var c, d, m, v;
|
|
4264
4306
|
if (!(e && Object.keys(e).length > 0))
|
|
4265
4307
|
return h.log("⚠️ FLAME resources not provided in CharacterMeta, using global CDN config"), this.loadGlobalFlameResources(t);
|
|
4266
4308
|
h.log("✅ Using FLAME resources from CharacterMeta API");
|
|
@@ -4270,7 +4312,7 @@ class ir {
|
|
|
4270
4312
|
resourceName: "model.pb"
|
|
4271
4313
|
},
|
|
4272
4314
|
flameTemplate: {
|
|
4273
|
-
url: (
|
|
4315
|
+
url: (d = e.flameTemplate) == null ? void 0 : d.remote,
|
|
4274
4316
|
resourceName: "flame_template.pb"
|
|
4275
4317
|
},
|
|
4276
4318
|
teethPb: {
|
|
@@ -4282,21 +4324,21 @@ class ir {
|
|
|
4282
4324
|
resourceName: "teeth.npz"
|
|
4283
4325
|
}
|
|
4284
4326
|
}, i = Object.keys(a).length;
|
|
4285
|
-
let
|
|
4286
|
-
const
|
|
4287
|
-
t && (A &&
|
|
4327
|
+
let o = 0;
|
|
4328
|
+
const s = (b, A) => {
|
|
4329
|
+
t && (A && o++, t({
|
|
4288
4330
|
stage: "template",
|
|
4289
|
-
filename:
|
|
4290
|
-
loaded:
|
|
4331
|
+
filename: b,
|
|
4332
|
+
loaded: o,
|
|
4291
4333
|
total: i,
|
|
4292
|
-
progress: Math.round(
|
|
4334
|
+
progress: Math.round(o / i * 100)
|
|
4293
4335
|
}));
|
|
4294
|
-
}, l = {}, p = Object.entries(a).map(async ([
|
|
4336
|
+
}, l = {}, p = Object.entries(a).map(async ([b, { url: A, resourceName: S }]) => {
|
|
4295
4337
|
if (!A)
|
|
4296
|
-
throw new Error(`[loadTemplateResources] Missing CDN URL for ${
|
|
4297
|
-
|
|
4298
|
-
const
|
|
4299
|
-
h.log(`✅ ${
|
|
4338
|
+
throw new Error(`[loadTemplateResources] Missing CDN URL for ${b} (${S})`);
|
|
4339
|
+
s(S, !1), h.log(`📥 Loading ${b} from API CDN: ${A}`);
|
|
4340
|
+
const P = await Ne(A);
|
|
4341
|
+
h.log(`✅ ${b} loaded: ${P.byteLength} bytes`), l[b] = P, s(S, !0);
|
|
4300
4342
|
});
|
|
4301
4343
|
return await Promise.all(p), l;
|
|
4302
4344
|
}
|
|
@@ -4324,19 +4366,19 @@ class ir {
|
|
|
4324
4366
|
resourceName: n.teethNpz
|
|
4325
4367
|
}
|
|
4326
4368
|
}, i = Object.keys(a).length;
|
|
4327
|
-
let
|
|
4328
|
-
const
|
|
4329
|
-
e && (
|
|
4369
|
+
let o = 0;
|
|
4370
|
+
const s = (c, d) => {
|
|
4371
|
+
e && (d && o++, e({
|
|
4330
4372
|
stage: "template",
|
|
4331
4373
|
filename: c,
|
|
4332
|
-
loaded:
|
|
4374
|
+
loaded: o,
|
|
4333
4375
|
total: i,
|
|
4334
|
-
progress: Math.round(
|
|
4376
|
+
progress: Math.round(o / i * 100)
|
|
4335
4377
|
}));
|
|
4336
|
-
}, l = {}, p = Object.entries(a).map(async ([c, { url:
|
|
4337
|
-
|
|
4338
|
-
const v = await Ne(
|
|
4339
|
-
h.log(`✅ ${c} loaded: ${v.byteLength} bytes`), l[c] = v,
|
|
4378
|
+
}, l = {}, p = Object.entries(a).map(async ([c, { url: d, resourceName: m }]) => {
|
|
4379
|
+
s(m, !1), h.log(`📥 Loading ${c} from global CDN: ${d}`);
|
|
4380
|
+
const v = await Ne(d);
|
|
4381
|
+
h.log(`✅ ${c} loaded: ${v.byteLength} bytes`), l[c] = v, s(m, !0);
|
|
4340
4382
|
});
|
|
4341
4383
|
return await Promise.all(p), l;
|
|
4342
4384
|
}
|
|
@@ -4352,8 +4394,8 @@ class ir {
|
|
|
4352
4394
|
}
|
|
4353
4395
|
try {
|
|
4354
4396
|
h.log(`📥 Loading camera info from: ${t}`);
|
|
4355
|
-
const i = {},
|
|
4356
|
-
|
|
4397
|
+
const i = {}, o = y.appId, s = y.sessionToken;
|
|
4398
|
+
o && (i["X-App-Id"] = o), s && (i.Authorization = `Bearer ${s}`);
|
|
4357
4399
|
const l = await fetch(t, {
|
|
4358
4400
|
headers: Object.keys(i).length > 0 ? i : void 0
|
|
4359
4401
|
});
|
|
@@ -4370,8 +4412,8 @@ class ir {
|
|
|
4370
4412
|
* Load character data from CharacterMeta (iOS compatible)
|
|
4371
4413
|
*/
|
|
4372
4414
|
async loadCharacterData(e, t) {
|
|
4373
|
-
var v,
|
|
4374
|
-
const { progressCallback: n = null } = t || {}, a = (A = (
|
|
4415
|
+
var v, b, A, S, P, B, _, Y, G;
|
|
4416
|
+
const { progressCallback: n = null } = t || {}, a = (A = (b = (v = e.models) == null ? void 0 : v.shape) == null ? void 0 : b.resource) == null ? void 0 : A.remote, i = (B = (P = (S = e.models) == null ? void 0 : S.gsStandard) == null ? void 0 : P.resource) == null ? void 0 : B.remote, o = (G = (Y = (_ = e.animations) == null ? void 0 : _.frameIdle) == null ? void 0 : Y.resource) == null ? void 0 : G.remote;
|
|
4375
4417
|
if (!a || !i) {
|
|
4376
4418
|
const R = "Missing required resources: shape or gsStandard (point cloud)";
|
|
4377
4419
|
throw y.logEvent("character_load", "error", {
|
|
@@ -4380,13 +4422,13 @@ class ir {
|
|
|
4380
4422
|
reason: R
|
|
4381
4423
|
}), new Error(R);
|
|
4382
4424
|
}
|
|
4383
|
-
const
|
|
4425
|
+
const s = [
|
|
4384
4426
|
{ key: "shape", url: a, filename: "shape.pb" },
|
|
4385
4427
|
{ key: "pointCloud", url: i, filename: "point_cloud.ply" }
|
|
4386
4428
|
];
|
|
4387
|
-
|
|
4429
|
+
o && s.push({ key: "idleAnimation", url: o, filename: "idle.pb", optional: !0 });
|
|
4388
4430
|
let l = 0;
|
|
4389
|
-
const p =
|
|
4431
|
+
const p = s.length, c = (R, z) => {
|
|
4390
4432
|
n && (z && l++, n({
|
|
4391
4433
|
stage: "character",
|
|
4392
4434
|
filename: R,
|
|
@@ -4394,18 +4436,18 @@ class ir {
|
|
|
4394
4436
|
total: p,
|
|
4395
4437
|
progress: Math.round(l / p * 100)
|
|
4396
4438
|
}));
|
|
4397
|
-
},
|
|
4439
|
+
}, d = {}, m = s.map(async ({ key: R, url: z, filename: W, optional: Z }) => {
|
|
4398
4440
|
c(W, !1);
|
|
4399
4441
|
try {
|
|
4400
4442
|
const V = await Ne(z);
|
|
4401
|
-
return R === "shape" ?
|
|
4443
|
+
return R === "shape" ? d.shape = V : R === "pointCloud" ? d.pointCloud = V : R === "idleAnimation" && (d.idleAnimation = V), c(W, !0), { key: R, success: !0 };
|
|
4402
4444
|
} catch (V) {
|
|
4403
|
-
if (!
|
|
4445
|
+
if (!Z)
|
|
4404
4446
|
throw V;
|
|
4405
4447
|
return h.warn(`⚠️ Optional resource ${W} failed to load:`, V), c(W, !0), { key: R, success: !1 };
|
|
4406
4448
|
}
|
|
4407
4449
|
});
|
|
4408
|
-
if (await Promise.all(m), !
|
|
4450
|
+
if (await Promise.all(m), !d.shape || !d.pointCloud) {
|
|
4409
4451
|
const R = "Failed to load character data";
|
|
4410
4452
|
throw y.logEvent("character_load", "error", {
|
|
4411
4453
|
characterId: e.characterId ?? "unknown",
|
|
@@ -4413,24 +4455,24 @@ class ir {
|
|
|
4413
4455
|
reason: R
|
|
4414
4456
|
}), new Error(R);
|
|
4415
4457
|
}
|
|
4416
|
-
return
|
|
4458
|
+
return d;
|
|
4417
4459
|
}
|
|
4418
4460
|
/**
|
|
4419
4461
|
* Preload all resources (template + character data + camera info + settings)
|
|
4420
4462
|
*/
|
|
4421
4463
|
async preloadResources(e, t) {
|
|
4422
|
-
const { progressCallback: n = null } = t || {}, [a, i,
|
|
4423
|
-
this.loadTemplateResources(e.flame, (
|
|
4464
|
+
const { progressCallback: n = null } = t || {}, [a, i, o] = await Promise.all([
|
|
4465
|
+
this.loadTemplateResources(e.flame, (s) => {
|
|
4424
4466
|
n && n({
|
|
4425
|
-
...
|
|
4426
|
-
stage: `template-${
|
|
4467
|
+
...s,
|
|
4468
|
+
stage: `template-${s.stage}`
|
|
4427
4469
|
});
|
|
4428
4470
|
}),
|
|
4429
4471
|
this.loadCharacterData(e, {
|
|
4430
|
-
progressCallback: (
|
|
4472
|
+
progressCallback: (s) => {
|
|
4431
4473
|
n && n({
|
|
4432
|
-
...
|
|
4433
|
-
stage: `character-${
|
|
4474
|
+
...s,
|
|
4475
|
+
stage: `character-${s.stage}`
|
|
4434
4476
|
});
|
|
4435
4477
|
}
|
|
4436
4478
|
}),
|
|
@@ -4439,7 +4481,7 @@ class ir {
|
|
|
4439
4481
|
return {
|
|
4440
4482
|
templateResources: a,
|
|
4441
4483
|
characterData: i,
|
|
4442
|
-
preloadCameraSettings:
|
|
4484
|
+
preloadCameraSettings: o,
|
|
4443
4485
|
characterSettings: e.characterSettings
|
|
4444
4486
|
};
|
|
4445
4487
|
}
|
|
@@ -4456,15 +4498,15 @@ class ir {
|
|
|
4456
4498
|
getSdkApiClient() {
|
|
4457
4499
|
return {
|
|
4458
4500
|
async request(e, t = {}) {
|
|
4459
|
-
const i = y.getEnvironmentConfig().sdkApiBaseUrl + e,
|
|
4501
|
+
const i = y.getEnvironmentConfig().sdkApiBaseUrl + e, o = {
|
|
4460
4502
|
"Content-Type": "application/json"
|
|
4461
|
-
},
|
|
4462
|
-
|
|
4503
|
+
}, s = y.appId, l = y.sessionToken;
|
|
4504
|
+
s && (o["X-App-Id"] = s), l && (o.Authorization = `Bearer ${l}`);
|
|
4463
4505
|
try {
|
|
4464
4506
|
const p = await fetch(i, {
|
|
4465
4507
|
method: t.method || "GET",
|
|
4466
4508
|
headers: {
|
|
4467
|
-
...
|
|
4509
|
+
...o,
|
|
4468
4510
|
...t.headers
|
|
4469
4511
|
},
|
|
4470
4512
|
body: t.body ? JSON.stringify(t.body) : void 0
|
|
@@ -4502,12 +4544,12 @@ class ir {
|
|
|
4502
4544
|
}
|
|
4503
4545
|
}
|
|
4504
4546
|
}
|
|
4505
|
-
const
|
|
4547
|
+
const Pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4506
4548
|
__proto__: null,
|
|
4507
4549
|
AvatarDownloader: ir
|
|
4508
4550
|
}, Symbol.toStringTag, { value: "Module" })), ke = class ke {
|
|
4509
4551
|
constructor() {
|
|
4510
|
-
|
|
4552
|
+
u(this, "avatarDownloader", null);
|
|
4511
4553
|
}
|
|
4512
4554
|
/**
|
|
4513
4555
|
* 通过全局单例来访问
|
|
@@ -4527,21 +4569,21 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4527
4569
|
try {
|
|
4528
4570
|
if (!y.isInitialized)
|
|
4529
4571
|
throw new Error("AvatarKit not initialized. Please call AvatarKit.initialize() first.");
|
|
4530
|
-
this.avatarDownloader || (this.avatarDownloader = new ir()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type:
|
|
4572
|
+
this.avatarDownloader || (this.avatarDownloader = new ir()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: ce.downloading, progress: 10 });
|
|
4531
4573
|
const n = await this.avatarDownloader.getCharacterById(e);
|
|
4532
|
-
h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type:
|
|
4574
|
+
h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: ce.downloading, progress: 30 });
|
|
4533
4575
|
const a = await this.avatarDownloader.preloadResources(n, {
|
|
4534
|
-
progressCallback: (
|
|
4535
|
-
const
|
|
4576
|
+
progressCallback: (o) => {
|
|
4577
|
+
const s = 30 + o.progress / 100 * 70;
|
|
4536
4578
|
t == null || t({
|
|
4537
|
-
type:
|
|
4538
|
-
progress: Math.round(
|
|
4579
|
+
type: ce.downloading,
|
|
4580
|
+
progress: Math.round(s)
|
|
4539
4581
|
});
|
|
4540
4582
|
}
|
|
4541
4583
|
});
|
|
4542
4584
|
h.log("[AvatarManager] Step 3: Creating Avatar instance...");
|
|
4543
|
-
const i = new
|
|
4544
|
-
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type:
|
|
4585
|
+
const i = new on(e, n, a);
|
|
4586
|
+
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: ce.completed }), y.logEvent("character_load", "info", {
|
|
4545
4587
|
characterId: e,
|
|
4546
4588
|
event: "load_success"
|
|
4547
4589
|
}), i;
|
|
@@ -4550,7 +4592,7 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4550
4592
|
throw h.error("Failed to load avatar:", a), y.logEvent("character_load", "error", {
|
|
4551
4593
|
characterId: e,
|
|
4552
4594
|
reason: a
|
|
4553
|
-
}), t == null || t({ type:
|
|
4595
|
+
}), t == null || t({ type: ce.failed, error: n }), n;
|
|
4554
4596
|
}
|
|
4555
4597
|
}
|
|
4556
4598
|
/**
|
|
@@ -4560,55 +4602,55 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4560
4602
|
this.avatarDownloader && this.avatarDownloader.clear();
|
|
4561
4603
|
}
|
|
4562
4604
|
};
|
|
4563
|
-
|
|
4564
|
-
let Tt = ke,
|
|
4605
|
+
u(ke, "_instance", null);
|
|
4606
|
+
let Tt = ke, ve = null, Bt = null, Dt = null, Ot = null, Nt = null, Ut = null;
|
|
4565
4607
|
const Ke = 2048, zt = Ke - 1;
|
|
4566
4608
|
function Ia(r, e, t) {
|
|
4567
4609
|
const a = r.length / 13;
|
|
4568
|
-
(!
|
|
4569
|
-
const i =
|
|
4570
|
-
for (let
|
|
4571
|
-
const B =
|
|
4572
|
-
i[
|
|
4573
|
-
}
|
|
4574
|
-
for (let
|
|
4575
|
-
const B =
|
|
4576
|
-
|
|
4577
|
-
}
|
|
4578
|
-
Ue(
|
|
4579
|
-
for (let
|
|
4580
|
-
p[
|
|
4610
|
+
(!ve || ve.length !== a) && (ve = new Float32Array(a), Bt = new Uint32Array(ve.buffer), Dt = new Uint32Array(a), Ot = new Uint32Array(a), Nt = new Uint32Array(a), Ut = new Uint32Array(Ke));
|
|
4611
|
+
const i = ve, o = Bt, s = Dt, l = Ot, p = Nt, c = Ut, d = e[0], m = e[1], v = e[2], b = t[0], A = t[1], S = t[2];
|
|
4612
|
+
for (let P = 0; P < a; P++) {
|
|
4613
|
+
const B = P * 13;
|
|
4614
|
+
i[P] = (r[B] - d) * b + (r[B + 1] - m) * A + (r[B + 2] - v) * S, s[P] = P;
|
|
4615
|
+
}
|
|
4616
|
+
for (let P = 0; P < a; P++) {
|
|
4617
|
+
const B = o[P];
|
|
4618
|
+
o[P] = B ^ (-(B >> 31) | 2147483648);
|
|
4619
|
+
}
|
|
4620
|
+
Ue(o, s, l, c, 0, a), Ue(o, l, s, c, 11, a), Ue(o, s, l, c, 22, a);
|
|
4621
|
+
for (let P = 0; P < a; P++)
|
|
4622
|
+
p[P] = l[a - 1 - P];
|
|
4581
4623
|
return p;
|
|
4582
4624
|
}
|
|
4583
4625
|
function Ue(r, e, t, n, a, i) {
|
|
4584
4626
|
n.fill(0);
|
|
4585
|
-
for (let
|
|
4586
|
-
const l = r[e[
|
|
4627
|
+
for (let s = 0; s < i; s++) {
|
|
4628
|
+
const l = r[e[s]] >> a & zt;
|
|
4587
4629
|
n[l]++;
|
|
4588
4630
|
}
|
|
4589
|
-
let
|
|
4590
|
-
for (let
|
|
4591
|
-
const l = n[
|
|
4592
|
-
n[
|
|
4631
|
+
let o = 0;
|
|
4632
|
+
for (let s = 0; s < Ke; s++) {
|
|
4633
|
+
const l = n[s];
|
|
4634
|
+
n[s] = o, o += l;
|
|
4593
4635
|
}
|
|
4594
|
-
for (let
|
|
4595
|
-
const l = e[
|
|
4636
|
+
for (let s = 0; s < i; s++) {
|
|
4637
|
+
const l = e[s], p = r[l] >> a & zt;
|
|
4596
4638
|
t[n[p]++] = l;
|
|
4597
4639
|
}
|
|
4598
4640
|
}
|
|
4599
4641
|
const _e = 13;
|
|
4600
|
-
let
|
|
4642
|
+
let ye = null;
|
|
4601
4643
|
function ka(r, e) {
|
|
4602
4644
|
const t = e.length, n = t * _e;
|
|
4603
|
-
(!
|
|
4645
|
+
(!ye || ye.length !== n) && (ye = new Float32Array(n));
|
|
4604
4646
|
for (let a = 0; a < t; a++) {
|
|
4605
|
-
const
|
|
4606
|
-
|
|
4607
|
-
r.subarray(
|
|
4608
|
-
|
|
4647
|
+
const o = e[a] * _e, s = a * _e;
|
|
4648
|
+
ye.set(
|
|
4649
|
+
r.subarray(o, o + _e),
|
|
4650
|
+
s
|
|
4609
4651
|
);
|
|
4610
4652
|
}
|
|
4611
|
-
return
|
|
4653
|
+
return ye;
|
|
4612
4654
|
}
|
|
4613
4655
|
const xa = `#version 300 es
|
|
4614
4656
|
precision highp float;
|
|
@@ -4811,18 +4853,18 @@ void main() {
|
|
|
4811
4853
|
class Ma {
|
|
4812
4854
|
// 跟踪当前 buffer 大小
|
|
4813
4855
|
constructor(e, t) {
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4856
|
+
u(this, "canvas");
|
|
4857
|
+
u(this, "backgroundColor");
|
|
4858
|
+
u(this, "gl");
|
|
4859
|
+
u(this, "shaderProgram");
|
|
4860
|
+
u(this, "uniformLocations");
|
|
4861
|
+
u(this, "attributeLocations");
|
|
4862
|
+
u(this, "splatBuffer");
|
|
4863
|
+
u(this, "quadVertexBuffer");
|
|
4864
|
+
u(this, "vertexArray");
|
|
4865
|
+
u(this, "splatCount");
|
|
4866
|
+
u(this, "isInitialized");
|
|
4867
|
+
u(this, "splatBufferSize");
|
|
4826
4868
|
this.canvas = e, this.backgroundColor = t || [0, 0, 0, 0], this.gl = null, this.shaderProgram = null, this.uniformLocations = {}, this.attributeLocations = {}, this.splatBuffer = null, this.quadVertexBuffer = null, this.vertexArray = null, this.splatCount = 0, this.isInitialized = !1, this.splatBufferSize = 0;
|
|
4827
4869
|
}
|
|
4828
4870
|
/**
|
|
@@ -5301,24 +5343,24 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4f {
|
|
|
5301
5343
|
`;
|
|
5302
5344
|
class Ra {
|
|
5303
5345
|
constructor(e, t) {
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5346
|
+
u(this, "canvas");
|
|
5347
|
+
u(this, "backgroundColor");
|
|
5348
|
+
u(this, "device", null);
|
|
5349
|
+
u(this, "context", null);
|
|
5350
|
+
u(this, "renderPipeline", null);
|
|
5351
|
+
u(this, "quadVertexBuffer", null);
|
|
5352
|
+
u(this, "uniformBuffer", null);
|
|
5353
|
+
u(this, "uniformBindGroup", null);
|
|
5312
5354
|
// 🚀 间接索引渲染 buffers
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5355
|
+
u(this, "sortIndexBuffer", null);
|
|
5356
|
+
u(this, "splatDataBuffer", null);
|
|
5357
|
+
u(this, "storageBindGroup", null);
|
|
5358
|
+
u(this, "lastSortOrder", null);
|
|
5317
5359
|
// 缓存上次的排序索引
|
|
5318
|
-
|
|
5360
|
+
u(this, "bindGroupNeedsUpdate", !1);
|
|
5319
5361
|
// 标记 bind group 是否需要更新
|
|
5320
|
-
|
|
5321
|
-
|
|
5362
|
+
u(this, "splatCount", 0);
|
|
5363
|
+
u(this, "presentationFormat", "bgra8unorm");
|
|
5322
5364
|
this.canvas = e, this.backgroundColor = t || [0, 0, 0, 0];
|
|
5323
5365
|
}
|
|
5324
5366
|
/**
|
|
@@ -5509,10 +5551,10 @@ class Ra {
|
|
|
5509
5551
|
n.byteOffset,
|
|
5510
5552
|
n.byteLength
|
|
5511
5553
|
), this.lastSortOrder = n), this.bindGroupNeedsUpdate && this.renderPipeline && this.sortIndexBuffer && this.splatDataBuffer) {
|
|
5512
|
-
const
|
|
5554
|
+
const o = this.renderPipeline.getBindGroupLayout(1);
|
|
5513
5555
|
this.storageBindGroup = this.device.createBindGroup({
|
|
5514
5556
|
label: "Storage Bind Group",
|
|
5515
|
-
layout:
|
|
5557
|
+
layout: o,
|
|
5516
5558
|
entries: [
|
|
5517
5559
|
{
|
|
5518
5560
|
binding: 0,
|
|
@@ -5536,7 +5578,7 @@ class Ra {
|
|
|
5536
5578
|
this.updateUniforms(e, t, n);
|
|
5537
5579
|
const a = this.context.getCurrentTexture().createView(), i = this.device.createCommandEncoder({
|
|
5538
5580
|
label: "Render Command Encoder"
|
|
5539
|
-
}),
|
|
5581
|
+
}), o = i.beginRenderPass({
|
|
5540
5582
|
label: "Render Pass",
|
|
5541
5583
|
colorAttachments: [
|
|
5542
5584
|
{
|
|
@@ -5548,7 +5590,7 @@ class Ra {
|
|
|
5548
5590
|
}
|
|
5549
5591
|
]
|
|
5550
5592
|
});
|
|
5551
|
-
|
|
5593
|
+
o.setPipeline(this.renderPipeline), o.setBindGroup(0, this.uniformBindGroup), o.setBindGroup(1, this.storageBindGroup), o.setVertexBuffer(0, this.quadVertexBuffer), o.draw(4, this.splatCount), o.end(), this.device.queue.submit([i.finish()]);
|
|
5552
5594
|
}
|
|
5553
5595
|
/**
|
|
5554
5596
|
* 更新 Uniform Buffer
|
|
@@ -5556,8 +5598,8 @@ class Ra {
|
|
|
5556
5598
|
updateUniforms(e, t, n) {
|
|
5557
5599
|
if (!this.device || !this.uniformBuffer)
|
|
5558
5600
|
return;
|
|
5559
|
-
const a = new ArrayBuffer(160), i = new Float32Array(a),
|
|
5560
|
-
i.set(e, 0), i.set(t, 16), i[32] = n[0], i[33] = n[1],
|
|
5601
|
+
const a = new ArrayBuffer(160), i = new Float32Array(a), o = new Uint32Array(a);
|
|
5602
|
+
i.set(e, 0), i.set(t, 16), i[32] = n[0], i[33] = n[1], o[36] = 1, this.device.queue.writeBuffer(this.uniformBuffer, 0, a);
|
|
5561
5603
|
}
|
|
5562
5604
|
/**
|
|
5563
5605
|
* 清理资源
|
|
@@ -5570,31 +5612,31 @@ class Ra {
|
|
|
5570
5612
|
class Ta {
|
|
5571
5613
|
// 排序耗时
|
|
5572
5614
|
constructor(e) {
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5615
|
+
u(this, "renderer", null);
|
|
5616
|
+
u(this, "backend", null);
|
|
5617
|
+
u(this, "canvas");
|
|
5618
|
+
u(this, "options");
|
|
5577
5619
|
// Camera configuration
|
|
5578
|
-
|
|
5620
|
+
u(this, "camera");
|
|
5579
5621
|
// Matrix cache (reuse buffers to avoid per-frame allocation)
|
|
5580
|
-
|
|
5581
|
-
|
|
5622
|
+
u(this, "viewMatrix", new Float32Array(16));
|
|
5623
|
+
u(this, "projectionMatrix", new Float32Array(16));
|
|
5582
5624
|
// Camera forward vector cache (reuse to avoid per-frame allocation)
|
|
5583
|
-
|
|
5584
|
-
|
|
5625
|
+
u(this, "cachedForward", [0, 0, 1]);
|
|
5626
|
+
u(this, "forwardCacheValid", !1);
|
|
5585
5627
|
// Temporary vectors for view matrix calculation (reuse buffers)
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5628
|
+
u(this, "tempForward", [0, 0, 0]);
|
|
5629
|
+
u(this, "tempRight", [0, 0, 0]);
|
|
5630
|
+
u(this, "tempUp", [0, 0, 0]);
|
|
5589
5631
|
// Camera parameter cache for matrix update optimization
|
|
5590
|
-
|
|
5591
|
-
|
|
5632
|
+
u(this, "cachedCameraParams", null);
|
|
5633
|
+
u(this, "matricesCacheValid", !1);
|
|
5592
5634
|
// 当前数据(GPU 格式:[pos3, color4, cov6] x N)
|
|
5593
|
-
|
|
5635
|
+
u(this, "originalPackedData", null);
|
|
5594
5636
|
// 性能统计
|
|
5595
|
-
|
|
5637
|
+
u(this, "renderTime", 0);
|
|
5596
5638
|
// 总渲染耗时
|
|
5597
|
-
|
|
5639
|
+
u(this, "sortTime", 0);
|
|
5598
5640
|
this.options = e, this.canvas = e.canvas;
|
|
5599
5641
|
const t = e.camera || {
|
|
5600
5642
|
position: [-0.02, -0.013, 1.5],
|
|
@@ -5649,8 +5691,8 @@ class Ta {
|
|
|
5649
5691
|
if (this.sortTime = a, this.backend === "webgpu")
|
|
5650
5692
|
this.renderer.loadSplatsFromPackedData(this.originalPackedData, e, n);
|
|
5651
5693
|
else {
|
|
5652
|
-
const
|
|
5653
|
-
this.renderer.loadSplatsFromPackedData(
|
|
5694
|
+
const s = ka(this.originalPackedData, n);
|
|
5695
|
+
this.renderer.loadSplatsFromPackedData(s, e);
|
|
5654
5696
|
}
|
|
5655
5697
|
const i = performance.now();
|
|
5656
5698
|
this.renderer.render(
|
|
@@ -5658,8 +5700,8 @@ class Ta {
|
|
|
5658
5700
|
this.projectionMatrix,
|
|
5659
5701
|
[this.canvas.width, this.canvas.height]
|
|
5660
5702
|
);
|
|
5661
|
-
const
|
|
5662
|
-
this.renderTime =
|
|
5703
|
+
const o = performance.now() - i;
|
|
5704
|
+
this.renderTime = o;
|
|
5663
5705
|
}
|
|
5664
5706
|
/**
|
|
5665
5707
|
* Update camera parameters
|
|
@@ -5709,16 +5751,16 @@ class Ta {
|
|
|
5709
5751
|
* Update camera matrices (with caching to avoid unnecessary updates)
|
|
5710
5752
|
*/
|
|
5711
5753
|
updateCameraMatrices() {
|
|
5712
|
-
const { position: e, target: t, up: n, fov: a, aspect: i, near:
|
|
5713
|
-
!(!this.cachedCameraParams || this.cachedCameraParams.position[0] !== e[0] || this.cachedCameraParams.position[1] !== e[1] || this.cachedCameraParams.position[2] !== e[2] || this.cachedCameraParams.target[0] !== t[0] || this.cachedCameraParams.target[1] !== t[1] || this.cachedCameraParams.target[2] !== t[2] || this.cachedCameraParams.up[0] !== n[0] || this.cachedCameraParams.up[1] !== n[1] || this.cachedCameraParams.up[2] !== n[2] || this.cachedCameraParams.fov !== a || this.cachedCameraParams.aspect !== i || this.cachedCameraParams.near !==
|
|
5754
|
+
const { position: e, target: t, up: n, fov: a, aspect: i, near: o, far: s } = this.camera;
|
|
5755
|
+
!(!this.cachedCameraParams || this.cachedCameraParams.position[0] !== e[0] || this.cachedCameraParams.position[1] !== e[1] || this.cachedCameraParams.position[2] !== e[2] || this.cachedCameraParams.target[0] !== t[0] || this.cachedCameraParams.target[1] !== t[1] || this.cachedCameraParams.target[2] !== t[2] || this.cachedCameraParams.up[0] !== n[0] || this.cachedCameraParams.up[1] !== n[1] || this.cachedCameraParams.up[2] !== n[2] || this.cachedCameraParams.fov !== a || this.cachedCameraParams.aspect !== i || this.cachedCameraParams.near !== o || this.cachedCameraParams.far !== s) && this.matricesCacheValid || (this.cachedCameraParams ? (this.cachedCameraParams.position[0] = e[0], this.cachedCameraParams.position[1] = e[1], this.cachedCameraParams.position[2] = e[2], this.cachedCameraParams.target[0] = t[0], this.cachedCameraParams.target[1] = t[1], this.cachedCameraParams.target[2] = t[2], this.cachedCameraParams.up[0] = n[0], this.cachedCameraParams.up[1] = n[1], this.cachedCameraParams.up[2] = n[2], this.cachedCameraParams.fov = a, this.cachedCameraParams.aspect = i, this.cachedCameraParams.near = o, this.cachedCameraParams.far = s) : this.cachedCameraParams = {
|
|
5714
5756
|
position: [e[0], e[1], e[2]],
|
|
5715
5757
|
target: [t[0], t[1], t[2]],
|
|
5716
5758
|
up: [n[0], n[1], n[2]],
|
|
5717
5759
|
fov: a,
|
|
5718
5760
|
aspect: i,
|
|
5719
|
-
near:
|
|
5720
|
-
far:
|
|
5721
|
-
}, this.updatePerspectiveMatrix(a, i,
|
|
5761
|
+
near: o,
|
|
5762
|
+
far: s
|
|
5763
|
+
}, this.updatePerspectiveMatrix(a, i, o, s), this.forwardCacheValid = !1, this.updateViewMatrix(e, t, n), this.matricesCacheValid = !0);
|
|
5722
5764
|
}
|
|
5723
5765
|
/**
|
|
5724
5766
|
* Get camera forward vector (cached version)
|
|
@@ -5738,8 +5780,8 @@ class Ta {
|
|
|
5738
5780
|
* Update perspective projection matrix (reuse buffer)
|
|
5739
5781
|
*/
|
|
5740
5782
|
updatePerspectiveMatrix(e, t, n, a) {
|
|
5741
|
-
const i = e * Math.PI / 180,
|
|
5742
|
-
l[0] =
|
|
5783
|
+
const i = e * Math.PI / 180, o = 1 / Math.tan(i / 2), s = a / (n - a), l = this.projectionMatrix;
|
|
5784
|
+
l[0] = o / t, l[1] = 0, l[2] = 0, l[3] = 0, l[4] = 0, l[5] = o, l[6] = 0, l[7] = 0, l[8] = 0, l[9] = 0, l[10] = s, l[11] = -1, l[12] = 0, l[13] = 0, l[14] = s * n, l[15] = 0;
|
|
5743
5785
|
}
|
|
5744
5786
|
/**
|
|
5745
5787
|
* Update view matrix (directly update pre-allocated buffer to avoid per-frame allocation)
|
|
@@ -5753,11 +5795,11 @@ class Ta {
|
|
|
5753
5795
|
this.tempForward[0] /= a, this.tempForward[1] /= a, this.tempForward[2] /= a, this.tempRight[0] = this.tempForward[1] * n[2] - this.tempForward[2] * n[1], this.tempRight[1] = this.tempForward[2] * n[0] - this.tempForward[0] * n[2], this.tempRight[2] = this.tempForward[0] * n[1] - this.tempForward[1] * n[0];
|
|
5754
5796
|
const i = Math.hypot(this.tempRight[0], this.tempRight[1], this.tempRight[2]) || 1;
|
|
5755
5797
|
this.tempRight[0] /= i, this.tempRight[1] /= i, this.tempRight[2] /= i, this.tempUp[0] = this.tempRight[1] * this.tempForward[2] - this.tempRight[2] * this.tempForward[1], this.tempUp[1] = this.tempRight[2] * this.tempForward[0] - this.tempRight[0] * this.tempForward[2], this.tempUp[2] = this.tempRight[0] * this.tempForward[1] - this.tempRight[1] * this.tempForward[0];
|
|
5756
|
-
const
|
|
5757
|
-
|
|
5798
|
+
const o = this.viewMatrix, s = -e[0], l = -e[1], p = -e[2];
|
|
5799
|
+
o[0] = this.tempRight[0], o[1] = this.tempUp[0], o[2] = -this.tempForward[0], o[3] = 0, o[4] = this.tempRight[1], o[5] = this.tempUp[1], o[6] = -this.tempForward[1], o[7] = 0, o[8] = this.tempRight[2], o[9] = this.tempUp[2], o[10] = -this.tempForward[2], o[11] = 0, o[12] = s, o[13] = l, o[14] = p, o[15] = 1;
|
|
5758
5800
|
}
|
|
5759
5801
|
}
|
|
5760
|
-
function
|
|
5802
|
+
function ae(r, e, t) {
|
|
5761
5803
|
const n = Math.min(r.length, e.length), a = Array.from({ length: n });
|
|
5762
5804
|
for (let i = 0; i < n; i++)
|
|
5763
5805
|
a[i] = r[i] + (e[i] - r[i]) * t;
|
|
@@ -5766,23 +5808,23 @@ function ne(r, e, t) {
|
|
|
5766
5808
|
function Ba(r, e, t) {
|
|
5767
5809
|
const n = 0.5 - Math.cos(t * Math.PI) * 0.5;
|
|
5768
5810
|
return {
|
|
5769
|
-
translation:
|
|
5770
|
-
rotation:
|
|
5771
|
-
neckPose:
|
|
5772
|
-
jawPose:
|
|
5773
|
-
eyePose:
|
|
5811
|
+
translation: ae(r.translation || [0, 0, 0], e.translation || [0, 0, 0], n),
|
|
5812
|
+
rotation: ae(r.rotation || [0, 0, 0], e.rotation || [0, 0, 0], n),
|
|
5813
|
+
neckPose: ae(r.neckPose || [0, 0, 0], e.neckPose || [0, 0, 0], n),
|
|
5814
|
+
jawPose: ae(r.jawPose || [0, 0, 0], e.jawPose || [0, 0, 0], n),
|
|
5815
|
+
eyePose: ae(r.eyePose || [0, 0, 0, 0, 0, 0], e.eyePose || [0, 0, 0, 0, 0, 0], n),
|
|
5774
5816
|
eyeLid: (() => {
|
|
5775
5817
|
const a = r.eyeLid, i = e.eyeLid;
|
|
5776
|
-
return a && a.length > 0 && i && i.length > 0 ?
|
|
5818
|
+
return a && a.length > 0 && i && i.length > 0 ? ae(a, i, n) : a || i || [];
|
|
5777
5819
|
})(),
|
|
5778
|
-
expression:
|
|
5820
|
+
expression: ae(r.expression || [], e.expression || [], n)
|
|
5779
5821
|
};
|
|
5780
5822
|
}
|
|
5781
5823
|
function Da(r, e, t, n = 25) {
|
|
5782
5824
|
const a = Math.max(1, Math.floor(t / 1e3 * n)), i = Array.from({ length: a });
|
|
5783
|
-
for (let
|
|
5784
|
-
const
|
|
5785
|
-
i[
|
|
5825
|
+
for (let o = 0; o < a; o++) {
|
|
5826
|
+
const s = o / (a - 1);
|
|
5827
|
+
i[o] = Ba(r, e, s);
|
|
5786
5828
|
}
|
|
5787
5829
|
return i;
|
|
5788
5830
|
}
|
|
@@ -5798,49 +5840,49 @@ class Ua {
|
|
|
5798
5840
|
* @param container - Canvas 容器元素(必选)
|
|
5799
5841
|
*/
|
|
5800
5842
|
constructor(e, t) {
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5843
|
+
u(this, "avatarController");
|
|
5844
|
+
u(this, "playbackMode");
|
|
5845
|
+
u(this, "avatar");
|
|
5804
5846
|
// Initialization state
|
|
5805
|
-
|
|
5847
|
+
u(this, "ready");
|
|
5806
5848
|
// Canvas and rendering
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5849
|
+
u(this, "canvas");
|
|
5850
|
+
u(this, "renderSystem", null);
|
|
5851
|
+
u(this, "isInitialized", !1);
|
|
5852
|
+
u(this, "cameraConfig", null);
|
|
5811
5853
|
// Rendering state machine
|
|
5812
|
-
|
|
5854
|
+
u(this, "renderingState", "idle");
|
|
5813
5855
|
// Realtime animation data
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5856
|
+
u(this, "currentKeyframes", []);
|
|
5857
|
+
u(this, "lastRenderedFrameIndex", -1);
|
|
5858
|
+
u(this, "lastRealtimeProtoFrame", null);
|
|
5817
5859
|
// Animation loop types
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5860
|
+
u(this, "idleAnimationLoopId", null);
|
|
5861
|
+
u(this, "realtimeAnimationLoopId", null);
|
|
5862
|
+
u(this, "resizeObserver", null);
|
|
5863
|
+
u(this, "onWindowResize", () => this.handleResize());
|
|
5822
5864
|
// FPS 计算
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5865
|
+
u(this, "frameCount", 0);
|
|
5866
|
+
u(this, "lastFpsUpdate", 0);
|
|
5867
|
+
u(this, "currentFPS", 0);
|
|
5826
5868
|
// Transition animation data
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5869
|
+
u(this, "transitionKeyframes", []);
|
|
5870
|
+
u(this, "transitionStartTime", 0);
|
|
5871
|
+
u(this, "transitionDurationMs", 400);
|
|
5872
|
+
u(this, "cachedIdleFirstFrame", null);
|
|
5873
|
+
u(this, "idleCurrentFrameIndex", 0);
|
|
5832
5874
|
// Character handle for multi-character support
|
|
5833
|
-
|
|
5834
|
-
|
|
5875
|
+
u(this, "characterHandle", null);
|
|
5876
|
+
u(this, "characterId");
|
|
5835
5877
|
this.avatar = e, this.characterId = `${e.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
5836
5878
|
const n = y.configuration;
|
|
5837
5879
|
if (!n)
|
|
5838
5880
|
throw new Error("AvatarKit must be initialized before creating AvatarView. Call AvatarKit.initialize() first.");
|
|
5839
|
-
const i = (n.drivingServiceMode ?? ze.sdk) === ze.sdk ?
|
|
5881
|
+
const i = (n.drivingServiceMode ?? ze.sdk) === ze.sdk ? pe.network : pe.external;
|
|
5840
5882
|
this.playbackMode = i, this.avatarController = new Ca(e, {
|
|
5841
5883
|
playbackMode: i
|
|
5842
|
-
}), this.avatarController.setRenderCallback((
|
|
5843
|
-
this.renderRealtimeFrame(
|
|
5884
|
+
}), this.avatarController.setRenderCallback((o, s) => {
|
|
5885
|
+
this.renderRealtimeFrame(o, s);
|
|
5844
5886
|
}), this.avatarController.setTransitionCompleteCallback(() => {
|
|
5845
5887
|
this.onTransitionComplete();
|
|
5846
5888
|
}), this.canvas = this.createCanvas(t), this.ready = this.initializeView(e), this.setupControllerEventListeners();
|
|
@@ -5850,9 +5892,9 @@ class Ua {
|
|
|
5850
5892
|
* 对齐两端 Flame 维度:标量统一长度,expression 取最大长度并零填充
|
|
5851
5893
|
*/
|
|
5852
5894
|
alignFlamePair(e, t) {
|
|
5853
|
-
const n = (
|
|
5854
|
-
const p = Array.isArray(
|
|
5855
|
-
return p.length < l ? Array.from({ length: l }, (c,
|
|
5895
|
+
const n = (s, l) => {
|
|
5896
|
+
const p = Array.isArray(s) ? s.slice(0, l) : [];
|
|
5897
|
+
return p.length < l ? Array.from({ length: l }, (c, d) => p[d] ?? 0) : p;
|
|
5856
5898
|
}, a = {
|
|
5857
5899
|
translation: n(e == null ? void 0 : e.translation, 3),
|
|
5858
5900
|
rotation: n(e == null ? void 0 : e.rotation, 3),
|
|
@@ -5869,8 +5911,8 @@ class Ua {
|
|
|
5869
5911
|
eyePose: n(t == null ? void 0 : t.eyePose, 6),
|
|
5870
5912
|
eyeLid: n(t == null ? void 0 : t.eyeLid, 2),
|
|
5871
5913
|
expression: Array.isArray(t == null ? void 0 : t.expression) ? t.expression.slice() : []
|
|
5872
|
-
},
|
|
5873
|
-
return a.expression = n(a.expression,
|
|
5914
|
+
}, o = Math.max(a.expression.length, i.expression.length);
|
|
5915
|
+
return a.expression = n(a.expression, o), i.expression = n(i.expression, o), { from: a, to: i };
|
|
5874
5916
|
}
|
|
5875
5917
|
/**
|
|
5876
5918
|
* 生成并对齐过渡帧,确保首尾帧与起止帧完全一致
|
|
@@ -5913,8 +5955,8 @@ class Ua {
|
|
|
5913
5955
|
createCanvas(e) {
|
|
5914
5956
|
const t = document.createElement("canvas"), n = e.offsetWidth || 800, a = e.offsetHeight || 600, i = window.devicePixelRatio || 1;
|
|
5915
5957
|
return t.width = Math.floor(n * i), t.height = Math.floor(a * i), t.style.width = `${n}px`, t.style.height = `${a}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.appendChild(t), e.style.display = "flex", e.style.justifyContent = "center", e.style.alignItems = "center", e.style.position = "relative", this.resizeObserver = new ResizeObserver(() => {
|
|
5916
|
-
const
|
|
5917
|
-
t.width = Math.floor(
|
|
5958
|
+
const o = window.devicePixelRatio || 1, s = Math.floor(e.offsetWidth || 0), l = Math.floor(e.offsetHeight || 0);
|
|
5959
|
+
t.width = Math.floor(s * o), t.height = Math.floor(l * o), t.style.width = `${s}px`, t.style.height = `${l}px`, this.handleResize();
|
|
5918
5960
|
}), this.resizeObserver.observe(e), window.addEventListener("resize", this.onWindowResize), t;
|
|
5919
5961
|
}
|
|
5920
5962
|
/**
|
|
@@ -5939,8 +5981,8 @@ class Ua {
|
|
|
5939
5981
|
n.characterData.pointCloud,
|
|
5940
5982
|
this.characterId
|
|
5941
5983
|
), n.characterData.idleAnimation && (k.debug && h.log("[AvatarView] Loading idle animation..."), await t.loadAnimationFromBuffer(n.characterData.idleAnimation, this.characterId)), n.characterData.shape = new ArrayBuffer(0), n.characterData.pointCloud = new ArrayBuffer(0), n.characterData.idleAnimation && (n.characterData.idleAnimation = new ArrayBuffer(0)), this.avatarController.setRenderCallback(
|
|
5942
|
-
(i,
|
|
5943
|
-
this.renderRealtimeFrame(i,
|
|
5984
|
+
(i, o) => {
|
|
5985
|
+
this.renderRealtimeFrame(i, o);
|
|
5944
5986
|
},
|
|
5945
5987
|
this.characterHandle
|
|
5946
5988
|
), k.debug && h.log("[AvatarView] Initializing render system...");
|
|
@@ -5971,44 +6013,44 @@ class Ua {
|
|
|
5971
6013
|
* 根据资源解析最终的相机配置,优先使用角色设置,其次 camera.json
|
|
5972
6014
|
*/
|
|
5973
6015
|
resolveCameraConfig(e) {
|
|
5974
|
-
var
|
|
5975
|
-
const t = this.getDefaultCameraConfig(), n = ((
|
|
6016
|
+
var s, l;
|
|
6017
|
+
const t = this.getDefaultCameraConfig(), n = ((s = e.characterSettings) == null ? void 0 : s.camera) ?? null, a = ((l = e.preloadCameraSettings) == null ? void 0 : l.camera) ?? null, i = n ?? a;
|
|
5976
6018
|
if (!i)
|
|
5977
6019
|
return h.warn("[AvatarView] Camera settings not found in resources, falling back to default camera config"), t;
|
|
5978
|
-
const
|
|
5979
|
-
return this.deriveCameraConfigFromSettings(i, t,
|
|
6020
|
+
const o = n ? "characterSettings" : "camera.json";
|
|
6021
|
+
return this.deriveCameraConfigFromSettings(i, t, o);
|
|
5980
6022
|
}
|
|
5981
6023
|
/**
|
|
5982
6024
|
* 从角色设置中推导相机配置
|
|
5983
6025
|
*/
|
|
5984
6026
|
deriveCameraConfigFromSettings(e, t, n) {
|
|
5985
|
-
const a = (z, W) => Number.isFinite(z) ? z : W, i = a(e.translationX, t.position[0]),
|
|
5986
|
-
if (!c && !
|
|
6027
|
+
const a = (z, W) => Number.isFinite(z) ? z : W, i = a(e.translationX, t.position[0]), o = a(e.translationY, t.position[1]), s = a(e.translationZ, t.position[2]), l = a(e.rotation, 0), p = a(e.fovYRadians, 0), c = Math.hypot(i, o, s) > 1e-4, d = p > 0, m = Math.abs(l) > 1e-4;
|
|
6028
|
+
if (!c && !d && !m)
|
|
5987
6029
|
return h.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
|
|
5988
|
-
const v = Math.sin(l),
|
|
6030
|
+
const v = Math.sin(l), b = Math.cos(l), A = c ? [i, o, s] : [...t.position], S = [
|
|
5989
6031
|
-v,
|
|
5990
6032
|
0,
|
|
5991
|
-
-
|
|
5992
|
-
],
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
6033
|
+
-b
|
|
6034
|
+
], P = Math.hypot(S[0], S[1], S[2]) || 1, B = [
|
|
6035
|
+
S[0] / P,
|
|
6036
|
+
S[1] / P,
|
|
6037
|
+
S[2] / P
|
|
5996
6038
|
], _ = [
|
|
5997
6039
|
A[0] + B[0],
|
|
5998
6040
|
A[1] + B[1],
|
|
5999
6041
|
A[2] + B[2]
|
|
6000
|
-
],
|
|
6042
|
+
], Y = [0, 1, 0], G = d ? p * 180 / Math.PI : t.fov, R = {
|
|
6001
6043
|
...t,
|
|
6002
6044
|
// 自动继承 near/far 等配置(来自 APP_CONFIG.camera)
|
|
6003
6045
|
position: A,
|
|
6004
6046
|
target: _,
|
|
6005
|
-
up:
|
|
6047
|
+
up: Y,
|
|
6006
6048
|
fov: G
|
|
6007
6049
|
// near/far 从 fallback 继承,无需硬编码
|
|
6008
6050
|
};
|
|
6009
6051
|
return h.log("[AvatarView] Applied camera settings from resources", {
|
|
6010
6052
|
source: n,
|
|
6011
|
-
translation: [i,
|
|
6053
|
+
translation: [i, o, s],
|
|
6012
6054
|
yawRadians: l,
|
|
6013
6055
|
position: A,
|
|
6014
6056
|
target: _,
|
|
@@ -6079,18 +6121,18 @@ class Ua {
|
|
|
6079
6121
|
return;
|
|
6080
6122
|
}
|
|
6081
6123
|
e = i;
|
|
6082
|
-
const
|
|
6083
|
-
if (!
|
|
6124
|
+
const o = y.getAvatarCore();
|
|
6125
|
+
if (!o)
|
|
6084
6126
|
return;
|
|
6085
|
-
const
|
|
6086
|
-
if (this.idleCurrentFrameIndex++,
|
|
6127
|
+
const s = await o.computeCompleteFrameFlat({ frameIndex: this.idleCurrentFrameIndex }, this.characterHandle ?? void 0);
|
|
6128
|
+
if (this.idleCurrentFrameIndex++, s) {
|
|
6087
6129
|
if (this.renderingState !== "idle")
|
|
6088
6130
|
return;
|
|
6089
|
-
this.renderSystem.loadSplatsFromPackedData(
|
|
6131
|
+
this.renderSystem.loadSplatsFromPackedData(s), this.renderSystem.renderFrame();
|
|
6090
6132
|
}
|
|
6091
6133
|
this.idleAnimationLoopId = requestAnimationFrame(a);
|
|
6092
|
-
} catch (
|
|
6093
|
-
h.error("[AvatarView] Idle animation loop error:",
|
|
6134
|
+
} catch (o) {
|
|
6135
|
+
h.error("[AvatarView] Idle animation loop error:", o instanceof Error ? o.message : String(o)), this.stopIdleAnimationLoop();
|
|
6094
6136
|
}
|
|
6095
6137
|
};
|
|
6096
6138
|
this.idleAnimationLoopId = requestAnimationFrame(a), k.debug && h.log("[AvatarView] Idle animation loop started");
|
|
@@ -6105,8 +6147,8 @@ class Ua {
|
|
|
6105
6147
|
this.initFPS();
|
|
6106
6148
|
const a = async (i) => {
|
|
6107
6149
|
try {
|
|
6108
|
-
const
|
|
6109
|
-
if (this.updateFPS(), !this.renderSystem ||
|
|
6150
|
+
const o = this.renderingState;
|
|
6151
|
+
if (this.updateFPS(), !this.renderSystem || o === "idle") {
|
|
6110
6152
|
this.realtimeAnimationLoopId = null;
|
|
6111
6153
|
return;
|
|
6112
6154
|
}
|
|
@@ -6114,23 +6156,23 @@ class Ua {
|
|
|
6114
6156
|
this.realtimeAnimationLoopId = requestAnimationFrame(a);
|
|
6115
6157
|
return;
|
|
6116
6158
|
}
|
|
6117
|
-
if (e = i,
|
|
6159
|
+
if (e = i, o === "transitioningToSpeaking" || o === "transitioningToIdle") {
|
|
6118
6160
|
if (this.transitionKeyframes.length === 0) {
|
|
6119
6161
|
this.realtimeAnimationLoopId = requestAnimationFrame(a);
|
|
6120
6162
|
return;
|
|
6121
6163
|
}
|
|
6122
|
-
const
|
|
6164
|
+
const s = performance.now() - this.transitionStartTime, l = Math.min(1, Math.max(0, s / this.transitionDurationMs)), p = this.transitionKeyframes.length, c = Math.min(p - 1, Math.floor(l * (p - 1))), d = this.transitionKeyframes[c], m = Vt(d), v = y.getAvatarCore();
|
|
6123
6165
|
if (v) {
|
|
6124
|
-
const
|
|
6125
|
-
|
|
6166
|
+
const b = await v.computeFrameFlatFromParams(m, this.characterHandle ?? void 0);
|
|
6167
|
+
b && (this.renderSystem.loadSplatsFromPackedData(b), this.renderSystem.renderFrame());
|
|
6126
6168
|
}
|
|
6127
6169
|
if (l >= 1) {
|
|
6128
|
-
if (
|
|
6170
|
+
if (o === "transitioningToSpeaking")
|
|
6129
6171
|
this.setState(
|
|
6130
6172
|
"speaking"
|
|
6131
6173
|
/* Speaking */
|
|
6132
6174
|
), this.transitionKeyframes = [], this.avatarController.onTransitionComplete();
|
|
6133
|
-
else if (
|
|
6175
|
+
else if (o === "transitioningToIdle") {
|
|
6134
6176
|
this.setState(
|
|
6135
6177
|
"idle"
|
|
6136
6178
|
/* Idle */
|
|
@@ -6141,12 +6183,12 @@ class Ua {
|
|
|
6141
6183
|
this.realtimeAnimationLoopId = requestAnimationFrame(a);
|
|
6142
6184
|
return;
|
|
6143
6185
|
}
|
|
6144
|
-
if (
|
|
6186
|
+
if (o === "speaking") {
|
|
6145
6187
|
this.realtimeAnimationLoopId = requestAnimationFrame(a);
|
|
6146
6188
|
return;
|
|
6147
6189
|
}
|
|
6148
|
-
} catch (
|
|
6149
|
-
h.error("[AvatarView] Realtime animation loop error:",
|
|
6190
|
+
} catch (o) {
|
|
6191
|
+
h.error("[AvatarView] Realtime animation loop error:", o instanceof Error ? o.message : String(o)), this.stopRealtimeAnimationLoop();
|
|
6150
6192
|
}
|
|
6151
6193
|
};
|
|
6152
6194
|
this.realtimeAnimationLoopId = requestAnimationFrame(a), k.debug && h.log("[AvatarView] Realtime animation loop started");
|
|
@@ -6256,8 +6298,8 @@ class Ua {
|
|
|
6256
6298
|
return;
|
|
6257
6299
|
const a = await n.getCurrentFrameParams(this.idleCurrentFrameIndex, this.characterId), i = ht(a);
|
|
6258
6300
|
await this.getCachedIdleFirstFrame();
|
|
6259
|
-
const
|
|
6260
|
-
this.transitionKeyframes = this.generateAndAlignTransitionFrames(i,
|
|
6301
|
+
const o = e[0];
|
|
6302
|
+
this.transitionKeyframes = this.generateAndAlignTransitionFrames(i, o), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
|
|
6261
6303
|
"speaking"
|
|
6262
6304
|
/* Speaking */
|
|
6263
6305
|
), this.avatarController.onTransitionComplete()) : k.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
|
|
@@ -6375,21 +6417,21 @@ class Ua {
|
|
|
6375
6417
|
}
|
|
6376
6418
|
export {
|
|
6377
6419
|
k as A,
|
|
6378
|
-
|
|
6420
|
+
ee as C,
|
|
6379
6421
|
ze as D,
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6422
|
+
oe as E,
|
|
6423
|
+
ce as L,
|
|
6424
|
+
sn as R,
|
|
6425
|
+
H as S,
|
|
6384
6426
|
y as a,
|
|
6385
|
-
|
|
6427
|
+
on as b,
|
|
6386
6428
|
Ca as c,
|
|
6387
6429
|
Tt as d,
|
|
6388
6430
|
ar as e,
|
|
6389
6431
|
Ua as f,
|
|
6390
6432
|
M as g,
|
|
6391
|
-
|
|
6433
|
+
pe as h,
|
|
6392
6434
|
Na as i,
|
|
6393
6435
|
h as l
|
|
6394
6436
|
};
|
|
6395
|
-
//# sourceMappingURL=index-
|
|
6437
|
+
//# sourceMappingURL=index-ChKhyUK4.js.map
|