@spatialwalk/avatarkit 1.0.0-beta.20 → 1.0.0-beta.22
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 +33 -2
- package/README.md +32 -27
- package/dist/{StreamingAudioPlayer-Dv4D0GIN.js → StreamingAudioPlayer-DjPD7f6u.js} +61 -42
- package/dist/StreamingAudioPlayer-DjPD7f6u.js.map +1 -0
- package/dist/audio/AnimationPlayer.d.ts +11 -0
- package/dist/audio/AnimationPlayer.d.ts.map +1 -1
- package/dist/audio/StreamingAudioPlayer.d.ts +13 -0
- package/dist/audio/StreamingAudioPlayer.d.ts.map +1 -1
- package/dist/core/AvatarController.d.ts +22 -12
- package/dist/core/AvatarController.d.ts.map +1 -1
- package/dist/core/AvatarKit.d.ts.map +1 -1
- package/dist/core/AvatarView.d.ts +0 -6
- package/dist/core/AvatarView.d.ts.map +1 -1
- package/dist/{index-Cm5BwNVd.js → index-BB9yoGY2.js} +956 -869
- package/dist/index-BB9yoGY2.js.map +1 -0
- package/dist/index.js +11 -11
- package/dist/types/index.d.ts +10 -19
- package/dist/types/index.d.ts.map +1 -1
- package/dist/vanilla/vite.config.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/StreamingAudioPlayer-Dv4D0GIN.js.map +0 -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,22 @@ 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 se = /* @__PURE__ */ ((r) => (r.cn = "cn", r.intl = "intl", r.test = "test", r))(se || {}), we = /* @__PURE__ */ ((r) => (r.sdk = "sdk", r.host = "host", r))(we || {}), de = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(de || {}), ee = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(ee || {}), re = /* @__PURE__ */ ((r) => (r.idle = "idle", r.playing = "playing", r))(re || {}), x = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(x || {});
|
|
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 me = /* @__PURE__ */ ((r) => (r.network = "network", r.external = "external", r))(me || {});
|
|
49
48
|
function ln() {
|
|
50
49
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("debug") === "1";
|
|
51
50
|
}
|
|
@@ -84,7 +83,7 @@ const k = {
|
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
};
|
|
87
|
-
function
|
|
86
|
+
function zt(r) {
|
|
88
87
|
var e;
|
|
89
88
|
return {
|
|
90
89
|
translation: r.translation || [0, 0, 0],
|
|
@@ -114,7 +113,7 @@ var $t = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
|
|
|
114
113
|
function dn(r) {
|
|
115
114
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
116
115
|
}
|
|
117
|
-
var Gt = { exports: {} },
|
|
116
|
+
var Gt = { exports: {} }, Te = { exports: {} }, ft;
|
|
118
117
|
function un() {
|
|
119
118
|
return ft || (ft = 1, function(r, e) {
|
|
120
119
|
(function(t, n) {
|
|
@@ -131,13 +130,13 @@ function un() {
|
|
|
131
130
|
return this[A];
|
|
132
131
|
};
|
|
133
132
|
}
|
|
134
|
-
var i = ["isConstructor", "isEval", "isNative", "isToplevel"],
|
|
135
|
-
function
|
|
133
|
+
var i = ["isConstructor", "isEval", "isNative", "isToplevel"], o = ["columnNumber", "lineNumber"], s = ["fileName", "functionName", "source"], l = ["args"], p = ["evalOrigin"], c = i.concat(o, s, l, p);
|
|
134
|
+
function d(A) {
|
|
136
135
|
if (A)
|
|
137
136
|
for (var b = 0; b < c.length; b++)
|
|
138
137
|
A[c[b]] !== void 0 && this["set" + n(c[b])](A[c[b]]);
|
|
139
138
|
}
|
|
140
|
-
|
|
139
|
+
d.prototype = {
|
|
141
140
|
getArgs: function() {
|
|
142
141
|
return this.args;
|
|
143
142
|
},
|
|
@@ -150,10 +149,10 @@ function un() {
|
|
|
150
149
|
return this.evalOrigin;
|
|
151
150
|
},
|
|
152
151
|
setEvalOrigin: function(A) {
|
|
153
|
-
if (A instanceof
|
|
152
|
+
if (A instanceof d)
|
|
154
153
|
this.evalOrigin = A;
|
|
155
154
|
else if (A instanceof Object)
|
|
156
|
-
this.evalOrigin = new
|
|
155
|
+
this.evalOrigin = new d(A);
|
|
157
156
|
else
|
|
158
157
|
throw new TypeError("Eval Origin must be an Object or StackFrame");
|
|
159
158
|
},
|
|
@@ -161,47 +160,47 @@ function un() {
|
|
|
161
160
|
var A = this.getFileName() || "", b = this.getLineNumber() || "", E = this.getColumnNumber() || "", B = this.getFunctionName() || "";
|
|
162
161
|
return this.getIsEval() ? A ? "[eval] (" + A + ":" + b + ":" + E + ")" : "[eval]:" + b + ":" + E : B ? B + " (" + A + ":" + b + ":" + E + ")" : A + ":" + b + ":" + E;
|
|
163
162
|
}
|
|
164
|
-
},
|
|
165
|
-
var E = b.indexOf("("), B = b.lastIndexOf(")"), _ = b.substring(0, E),
|
|
163
|
+
}, d.fromString = function(b) {
|
|
164
|
+
var E = b.indexOf("("), B = b.lastIndexOf(")"), _ = b.substring(0, E), Y = b.substring(E + 1, B).split(","), G = b.substring(B + 1);
|
|
166
165
|
if (G.indexOf("@") === 0)
|
|
167
|
-
var R = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""),
|
|
168
|
-
return new
|
|
166
|
+
var R = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""), V = R[1], W = R[2], Z = R[3];
|
|
167
|
+
return new d({
|
|
169
168
|
functionName: _,
|
|
170
|
-
args:
|
|
171
|
-
fileName:
|
|
169
|
+
args: Y || void 0,
|
|
170
|
+
fileName: V,
|
|
172
171
|
lineNumber: W || void 0,
|
|
173
|
-
columnNumber:
|
|
172
|
+
columnNumber: Z || void 0
|
|
174
173
|
});
|
|
175
174
|
};
|
|
176
175
|
for (var m = 0; m < i.length; m++)
|
|
177
|
-
|
|
176
|
+
d.prototype["get" + n(i[m])] = a(i[m]), d.prototype["set" + n(i[m])] = /* @__PURE__ */ function(A) {
|
|
178
177
|
return function(b) {
|
|
179
178
|
this[A] = !!b;
|
|
180
179
|
};
|
|
181
180
|
}(i[m]);
|
|
182
|
-
for (var v = 0; v <
|
|
183
|
-
|
|
181
|
+
for (var v = 0; v < o.length; v++)
|
|
182
|
+
d.prototype["get" + n(o[v])] = a(o[v]), d.prototype["set" + n(o[v])] = /* @__PURE__ */ function(A) {
|
|
184
183
|
return function(b) {
|
|
185
184
|
if (!t(b))
|
|
186
185
|
throw new TypeError(A + " must be a Number");
|
|
187
186
|
this[A] = Number(b);
|
|
188
187
|
};
|
|
189
|
-
}(
|
|
190
|
-
for (var S = 0; S <
|
|
191
|
-
|
|
188
|
+
}(o[v]);
|
|
189
|
+
for (var S = 0; S < s.length; S++)
|
|
190
|
+
d.prototype["get" + n(s[S])] = a(s[S]), d.prototype["set" + n(s[S])] = /* @__PURE__ */ function(A) {
|
|
192
191
|
return function(b) {
|
|
193
192
|
this[A] = String(b);
|
|
194
193
|
};
|
|
195
|
-
}(
|
|
196
|
-
return
|
|
194
|
+
}(s[S]);
|
|
195
|
+
return d;
|
|
197
196
|
});
|
|
198
|
-
}(
|
|
197
|
+
}(Te)), Te.exports;
|
|
199
198
|
}
|
|
200
199
|
(function(r, e) {
|
|
201
200
|
(function(t, n) {
|
|
202
201
|
r.exports = n(un());
|
|
203
202
|
})($t, function(n) {
|
|
204
|
-
var a = /(^|@)\S+:\d+/, i = /^\s*at .*(\S+:\d+|\(native\))/m,
|
|
203
|
+
var a = /(^|@)\S+:\d+/, i = /^\s*at .*(\S+:\d+|\(native\))/m, o = /^(eval@)?(\[native code])?$/;
|
|
205
204
|
return {
|
|
206
205
|
/**
|
|
207
206
|
* Given an Error object, extract the most information from it.
|
|
@@ -232,9 +231,9 @@ function un() {
|
|
|
232
231
|
}, this);
|
|
233
232
|
return p.map(function(c) {
|
|
234
233
|
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] :
|
|
234
|
+
var d = c.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), m = d.match(/ (\(.+\)$)/);
|
|
235
|
+
d = m ? d.replace(m[0], "") : d;
|
|
236
|
+
var v = this.extractLocation(m ? m[1] : d), S = m && d || void 0, A = ["eval", "<anonymous>"].indexOf(v[0]) > -1 ? void 0 : v[0];
|
|
238
237
|
return new n({
|
|
239
238
|
functionName: S,
|
|
240
239
|
fileName: A,
|
|
@@ -247,14 +246,14 @@ function un() {
|
|
|
247
246
|
parseFFOrSafari: function(l) {
|
|
248
247
|
var p = l.stack.split(`
|
|
249
248
|
`).filter(function(c) {
|
|
250
|
-
return !c.match(
|
|
249
|
+
return !c.match(o);
|
|
251
250
|
}, this);
|
|
252
251
|
return p.map(function(c) {
|
|
253
252
|
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
253
|
return new n({
|
|
255
254
|
functionName: c
|
|
256
255
|
});
|
|
257
|
-
var
|
|
256
|
+
var d = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(d), v = m && m[1] ? m[1] : void 0, S = this.extractLocation(c.replace(d, ""));
|
|
258
257
|
return new n({
|
|
259
258
|
functionName: v,
|
|
260
259
|
fileName: S[0],
|
|
@@ -272,21 +271,21 @@ function un() {
|
|
|
272
271
|
},
|
|
273
272
|
parseOpera9: function(l) {
|
|
274
273
|
for (var p = /Line (\d+).*script (?:in )?(\S+)/i, c = l.message.split(`
|
|
275
|
-
`),
|
|
274
|
+
`), d = [], m = 2, v = c.length; m < v; m += 2) {
|
|
276
275
|
var S = p.exec(c[m]);
|
|
277
|
-
S &&
|
|
276
|
+
S && d.push(new n({
|
|
278
277
|
fileName: S[2],
|
|
279
278
|
lineNumber: S[1],
|
|
280
279
|
source: c[m]
|
|
281
280
|
}));
|
|
282
281
|
}
|
|
283
|
-
return
|
|
282
|
+
return d;
|
|
284
283
|
},
|
|
285
284
|
parseOpera10: function(l) {
|
|
286
285
|
for (var p = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, c = l.stacktrace.split(`
|
|
287
|
-
`),
|
|
286
|
+
`), d = [], m = 0, v = c.length; m < v; m += 2) {
|
|
288
287
|
var S = p.exec(c[m]);
|
|
289
|
-
S &&
|
|
288
|
+
S && d.push(
|
|
290
289
|
new n({
|
|
291
290
|
functionName: S[3] || void 0,
|
|
292
291
|
fileName: S[2],
|
|
@@ -295,7 +294,7 @@ function un() {
|
|
|
295
294
|
})
|
|
296
295
|
);
|
|
297
296
|
}
|
|
298
|
-
return
|
|
297
|
+
return d;
|
|
299
298
|
},
|
|
300
299
|
// Opera 10.65+ Error.stack very similar to FF/Safari
|
|
301
300
|
parseOpera11: function(l) {
|
|
@@ -304,7 +303,7 @@ function un() {
|
|
|
304
303
|
return !!c.match(a) && !c.match(/^Error created at/);
|
|
305
304
|
}, this);
|
|
306
305
|
return p.map(function(c) {
|
|
307
|
-
var
|
|
306
|
+
var d = c.split("@"), m = this.extractLocation(d.pop()), v = d.shift() || "", S = v.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, A;
|
|
308
307
|
v.match(/\(([^)]*)\)/) && (A = v.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
|
|
309
308
|
var b = A === void 0 || A === "[arguments not available]" ? void 0 : A.split(",");
|
|
310
309
|
return new n({
|
|
@@ -326,12 +325,12 @@ let mt = () => {
|
|
|
326
325
|
var r = (() => {
|
|
327
326
|
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, a = Object.prototype.hasOwnProperty, i = (f, g) => {
|
|
328
327
|
for (var w in g) e(f, w, { get: g[w], enumerable: !0 });
|
|
329
|
-
},
|
|
328
|
+
}, o = (f, g, w, C) => {
|
|
330
329
|
if (g && typeof g == "object" || typeof g == "function") for (let P of n(g)) !a.call(f, P) && P !== w && e(f, P, { get: () => g[P], enumerable: !(C = t(g, P)) || C.enumerable });
|
|
331
330
|
return f;
|
|
332
|
-
},
|
|
331
|
+
}, s = (f) => o(e({}, "__esModule", { value: !0 }), f), l = {};
|
|
333
332
|
i(l, { default: () => tn });
|
|
334
|
-
var p = (f) => Array.isArray(f), c = (f) => typeof f == "function",
|
|
333
|
+
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, S = (f) => f instanceof RegExp, A = (f) => typeof f == "string", b = (f) => f === void 0, E = (f) => {
|
|
335
334
|
const g = /* @__PURE__ */ new Map();
|
|
336
335
|
return (w) => {
|
|
337
336
|
const C = g.get(w);
|
|
@@ -341,9 +340,9 @@ let mt = () => {
|
|
|
341
340
|
};
|
|
342
341
|
}, B = (f, g, w = {}) => {
|
|
343
342
|
const C = { cache: {}, input: f, index: 0, indexMax: 0, options: w, output: [] };
|
|
344
|
-
if (
|
|
343
|
+
if (J(g)(C) && C.index === f.length) return C.output;
|
|
345
344
|
throw new Error(`Failed to parse at index ${C.indexMax}`);
|
|
346
|
-
}, _ = (f, g) => p(f) ?
|
|
345
|
+
}, _ = (f, g) => p(f) ? Y(f, g) : A(f) ? R(f, g) : G(f, g), Y = (f, g) => {
|
|
347
346
|
const w = {};
|
|
348
347
|
for (const C of f) {
|
|
349
348
|
if (C.length !== 1) throw new Error(`Invalid character: "${C}"`);
|
|
@@ -365,7 +364,7 @@ let mt = () => {
|
|
|
365
364
|
};
|
|
366
365
|
}, G = (f, g) => {
|
|
367
366
|
const w = f.source, C = f.flags.replace(/y|$/, "y"), P = new RegExp(w, C);
|
|
368
|
-
return
|
|
367
|
+
return Ce((I) => {
|
|
369
368
|
P.lastIndex = I.index;
|
|
370
369
|
const T = P.exec(I.input);
|
|
371
370
|
if (T) {
|
|
@@ -384,9 +383,9 @@ let mt = () => {
|
|
|
384
383
|
}
|
|
385
384
|
return w.index += f.length, w.indexMax = Math.max(w.indexMax, w.index), !0;
|
|
386
385
|
} else return !1;
|
|
387
|
-
},
|
|
388
|
-
const P =
|
|
389
|
-
return
|
|
386
|
+
}, V = (f, g, w, C) => {
|
|
387
|
+
const P = J(f);
|
|
388
|
+
return Ce(Me(Xe((I) => {
|
|
390
389
|
let T = 0;
|
|
391
390
|
for (; T < w; ) {
|
|
392
391
|
const $ = I.index;
|
|
@@ -394,28 +393,28 @@ let mt = () => {
|
|
|
394
393
|
}
|
|
395
394
|
return T >= g;
|
|
396
395
|
})));
|
|
397
|
-
}, W = (f, g) =>
|
|
398
|
-
const w = f.map(
|
|
399
|
-
return
|
|
396
|
+
}, W = (f, g) => V(f, 0, 1), Z = (f, g) => V(f, 0, 1 / 0), z = (f, g) => {
|
|
397
|
+
const w = f.map(J);
|
|
398
|
+
return Ce(Me(Xe((C) => {
|
|
400
399
|
for (let P = 0, I = w.length; P < I; P++) if (!w[P](C)) return !1;
|
|
401
400
|
return !0;
|
|
402
401
|
})));
|
|
403
|
-
},
|
|
404
|
-
const w = f.map(
|
|
405
|
-
return
|
|
402
|
+
}, K = (f, g) => {
|
|
403
|
+
const w = f.map(J);
|
|
404
|
+
return Ce(Me((C) => {
|
|
406
405
|
for (let P = 0, I = w.length; P < I; P++) if (w[P](C)) return !0;
|
|
407
406
|
return !1;
|
|
408
407
|
}));
|
|
409
408
|
}, Xe = (f, g = !1) => {
|
|
410
|
-
const w =
|
|
409
|
+
const w = J(f);
|
|
411
410
|
return (C) => {
|
|
412
411
|
const P = C.index, I = C.output.length, T = w(C);
|
|
413
412
|
return (!T || g) && (C.index = P, C.output.length !== I && (C.output.length = I)), T;
|
|
414
413
|
};
|
|
415
|
-
},
|
|
414
|
+
}, Me = (f, g) => J(f), Ce = /* @__PURE__ */ (() => {
|
|
416
415
|
let f = 0;
|
|
417
416
|
return (g) => {
|
|
418
|
-
const w =
|
|
417
|
+
const w = J(g), C = f += 1;
|
|
419
418
|
return (P) => {
|
|
420
419
|
var lt;
|
|
421
420
|
var I;
|
|
@@ -439,14 +438,14 @@ let mt = () => {
|
|
|
439
438
|
};
|
|
440
439
|
})(), Ye = (f) => {
|
|
441
440
|
let g;
|
|
442
|
-
return (w) => (g || (g =
|
|
443
|
-
},
|
|
444
|
-
if (c(f)) return
|
|
441
|
+
return (w) => (g || (g = J(f())), g(w));
|
|
442
|
+
}, J = E((f) => {
|
|
443
|
+
if (c(f)) return d(f) ? Ye(f) : f;
|
|
445
444
|
if (A(f) || S(f)) return _(f);
|
|
446
|
-
if (p(f)) return
|
|
447
|
-
if (v(f)) return
|
|
445
|
+
if (p(f)) return z(f);
|
|
446
|
+
if (v(f)) return K(Object.values(f));
|
|
448
447
|
throw new Error("Invalid rule");
|
|
449
|
-
}), Ze = "abcdefghijklmnopqrstuvwxyz",
|
|
448
|
+
}), Ze = "abcdefghijklmnopqrstuvwxyz", or = (f) => {
|
|
450
449
|
let g = "";
|
|
451
450
|
for (; f > 0; ) {
|
|
452
451
|
const w = (f - 1) % 26;
|
|
@@ -462,31 +461,31 @@ let mt = () => {
|
|
|
462
461
|
const w = [];
|
|
463
462
|
for (; f <= g; ) w.push(f++);
|
|
464
463
|
return w;
|
|
465
|
-
},
|
|
464
|
+
}, 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
465
|
const g = {};
|
|
467
466
|
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(".", "\\.")})`),
|
|
467
|
+
}, 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(".", "\\.")})`), Le = _(/\\./, 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]), Sr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), br = _(/\*/, "[^/]*"), rt = K([Sr, br]), nt = _("?", "[^/]"), Cr = _("[", X), _r = _("]", X), Pr = _(/[!^]/, "^/"), Er = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, X), Ir = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), kr = _(/[^\]]/, X), xr = K([Le, Ir, Er, kr]), at = z([Cr, W(Pr), Z(xr), _r]), Mr = _("{", "(?:"), Fr = _("}", ")"), 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 = z([Mr, Br, Fr]), Dr = _("{", "(?:"), Or = _("}", ")"), Nr = _(",", "|"), Ur = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), Vr = _(/[^}]/, X), zr = Ye(() => ot), $r = K([tt, rt, nt, at, it, zr, Le, Ur, Nr, Vr]), ot = z([Dr, Z($r), Or]), Gr = Z(K([cr, dr, ur, gr, tt, rt, nt, at, it, ot, Le, 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, Re = (f, g) => {
|
|
469
468
|
const w = Array.isArray(f) ? f : [f];
|
|
470
469
|
if (!w.length) return !1;
|
|
471
|
-
const C = w.map(
|
|
470
|
+
const C = w.map(Re.compile), P = w.every((T) => /(\/(?:\*\*)?|\[\/\])$/.test(T)), I = g.replace(/[\\\/]+/g, "/").replace(/\/$/, P ? "/" : "");
|
|
472
471
|
return C.some((T) => T.test(I));
|
|
473
472
|
};
|
|
474
|
-
|
|
475
|
-
var tn =
|
|
476
|
-
return
|
|
473
|
+
Re.compile = (f) => new RegExp(`^${st(en(f))}$`, "s");
|
|
474
|
+
var tn = Re;
|
|
475
|
+
return s(l);
|
|
477
476
|
})();
|
|
478
477
|
return r.default || r;
|
|
479
|
-
},
|
|
480
|
-
const mn = (r, e) => (
|
|
481
|
-
function
|
|
478
|
+
}, Be;
|
|
479
|
+
const mn = (r, e) => (Be || (Be = mt(), mt = null), Be(r, e)), pn = /^[A-Za-z]:\//;
|
|
480
|
+
function le(r = "") {
|
|
482
481
|
return r && r.replace(/\\/g, "/").replace(pn, (e) => e.toUpperCase());
|
|
483
482
|
}
|
|
484
483
|
const gn = /^[/\\]{2}/, vn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, Wt = /^[A-Za-z]:$/, pt = /^\/([A-Za-z]:)?$/, yn = /.(\.[^./]+|\.)$/, wn = /^[/\\]|^[a-zA-Z]:[/\\]/, An = "/", qe = function(r) {
|
|
485
484
|
if (r.length === 0)
|
|
486
485
|
return ".";
|
|
487
|
-
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 && !
|
|
486
|
+
r = le(r);
|
|
487
|
+
const e = r.match(gn), t = ge(r), n = r[r.length - 1] === "/";
|
|
488
|
+
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
489
|
}, Sn = function(...r) {
|
|
491
490
|
let e = "";
|
|
492
491
|
for (const t of r)
|
|
@@ -501,55 +500,55 @@ const gn = /^[/\\]{2}/, vn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,
|
|
|
501
500
|
function bn() {
|
|
502
501
|
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
503
502
|
}
|
|
504
|
-
const
|
|
505
|
-
r = r.map((n) =>
|
|
503
|
+
const Ie = function(...r) {
|
|
504
|
+
r = r.map((n) => le(n));
|
|
506
505
|
let e = "", t = !1;
|
|
507
506
|
for (let n = r.length - 1; n >= -1 && !t; n--) {
|
|
508
507
|
const a = n >= 0 ? r[n] : bn();
|
|
509
|
-
!a || a.length === 0 || (e = `${a}/${e}`, t =
|
|
508
|
+
!a || a.length === 0 || (e = `${a}/${e}`, t = ge(a));
|
|
510
509
|
}
|
|
511
|
-
return e = He(e, !t), t && !
|
|
510
|
+
return e = He(e, !t), t && !ge(e) ? `/${e}` : e.length > 0 ? e : ".";
|
|
512
511
|
};
|
|
513
512
|
function He(r, e) {
|
|
514
|
-
let t = "", n = 0, a = -1, i = 0,
|
|
515
|
-
for (let
|
|
516
|
-
if (
|
|
517
|
-
|
|
513
|
+
let t = "", n = 0, a = -1, i = 0, o = null;
|
|
514
|
+
for (let s = 0; s <= r.length; ++s) {
|
|
515
|
+
if (s < r.length)
|
|
516
|
+
o = r[s];
|
|
518
517
|
else {
|
|
519
|
-
if (
|
|
518
|
+
if (o === "/")
|
|
520
519
|
break;
|
|
521
|
-
|
|
520
|
+
o = "/";
|
|
522
521
|
}
|
|
523
|
-
if (
|
|
524
|
-
if (!(a ===
|
|
522
|
+
if (o === "/") {
|
|
523
|
+
if (!(a === s - 1 || i === 1)) if (i === 2) {
|
|
525
524
|
if (t.length < 2 || n !== 2 || t[t.length - 1] !== "." || t[t.length - 2] !== ".") {
|
|
526
525
|
if (t.length > 2) {
|
|
527
526
|
const l = t.lastIndexOf("/");
|
|
528
|
-
l === -1 ? (t = "", n = 0) : (t = t.slice(0, l), n = t.length - 1 - t.lastIndexOf("/")), a =
|
|
527
|
+
l === -1 ? (t = "", n = 0) : (t = t.slice(0, l), n = t.length - 1 - t.lastIndexOf("/")), a = s, i = 0;
|
|
529
528
|
continue;
|
|
530
529
|
} else if (t.length > 0) {
|
|
531
|
-
t = "", n = 0, a =
|
|
530
|
+
t = "", n = 0, a = s, i = 0;
|
|
532
531
|
continue;
|
|
533
532
|
}
|
|
534
533
|
}
|
|
535
534
|
e && (t += t.length > 0 ? "/.." : "..", n = 2);
|
|
536
535
|
} else
|
|
537
|
-
t.length > 0 ? t += `/${r.slice(a + 1,
|
|
538
|
-
a =
|
|
539
|
-
} else
|
|
536
|
+
t.length > 0 ? t += `/${r.slice(a + 1, s)}` : t = r.slice(a + 1, s), n = s - a - 1;
|
|
537
|
+
a = s, i = 0;
|
|
538
|
+
} else o === "." && i !== -1 ? ++i : i = -1;
|
|
540
539
|
}
|
|
541
540
|
return t;
|
|
542
541
|
}
|
|
543
|
-
const
|
|
542
|
+
const ge = function(r) {
|
|
544
543
|
return vn.test(r);
|
|
545
544
|
}, Cn = function(r) {
|
|
546
|
-
return
|
|
545
|
+
return le(r);
|
|
547
546
|
}, qt = function(r) {
|
|
548
547
|
if (r === "..") return "";
|
|
549
|
-
const e = yn.exec(
|
|
548
|
+
const e = yn.exec(le(r));
|
|
550
549
|
return e && e[1] || "";
|
|
551
550
|
}, _n = function(r, e) {
|
|
552
|
-
const t =
|
|
551
|
+
const t = Ie(r).replace(pt, "$1").split("/"), n = Ie(e).replace(pt, "$1").split("/");
|
|
553
552
|
if (n[0][1] === ":" && t[0][1] === ":" && t[0] !== n[0])
|
|
554
553
|
return n.join("/");
|
|
555
554
|
const a = [...t];
|
|
@@ -560,17 +559,17 @@ const pe = function(r) {
|
|
|
560
559
|
}
|
|
561
560
|
return [...t.map(() => ".."), ...n].join("/");
|
|
562
561
|
}, Ht = function(r) {
|
|
563
|
-
const e =
|
|
564
|
-
return e.length === 1 && Wt.test(e[0]) && (e[0] += "/"), e.join("/") || (
|
|
562
|
+
const e = le(r).replace(/\/$/, "").split("/").slice(0, -1);
|
|
563
|
+
return e.length === 1 && Wt.test(e[0]) && (e[0] += "/"), e.join("/") || (ge(r) ? "/" : ".");
|
|
565
564
|
}, Pn = function(r) {
|
|
566
565
|
const e = r.ext ? r.ext.startsWith(".") ? r.ext : `.${r.ext}` : "", t = [r.root, r.dir, r.base ?? (r.name ?? "") + e].filter(
|
|
567
566
|
Boolean
|
|
568
567
|
);
|
|
569
|
-
return
|
|
570
|
-
r.root ?
|
|
568
|
+
return le(
|
|
569
|
+
r.root ? Ie(...t) : t.join("/")
|
|
571
570
|
);
|
|
572
571
|
}, jt = function(r, e) {
|
|
573
|
-
const t =
|
|
572
|
+
const t = le(r).split("/");
|
|
574
573
|
let n = "";
|
|
575
574
|
for (let a = t.length - 1; a >= 0; a--) {
|
|
576
575
|
const i = t[a];
|
|
@@ -596,14 +595,14 @@ const pe = function(r) {
|
|
|
596
595
|
dirname: Ht,
|
|
597
596
|
extname: qt,
|
|
598
597
|
format: Pn,
|
|
599
|
-
isAbsolute:
|
|
598
|
+
isAbsolute: ge,
|
|
600
599
|
join: Sn,
|
|
601
600
|
matchesGlob: In,
|
|
602
601
|
normalize: qe,
|
|
603
602
|
normalizeString: He,
|
|
604
603
|
parse: En,
|
|
605
604
|
relative: _n,
|
|
606
|
-
resolve:
|
|
605
|
+
resolve: Ie,
|
|
607
606
|
sep: An,
|
|
608
607
|
toNamespacedPath: Cn
|
|
609
608
|
}, kn = /* @__PURE__ */ (() => {
|
|
@@ -611,11 +610,11 @@ const pe = function(r) {
|
|
|
611
610
|
return ((r = globalThis.process) == null ? void 0 : r.platform) === "win32" ? ";" : ":";
|
|
612
611
|
})(), xn = { posix: void 0, win32: void 0 }, Kt = (r = kn) => new Proxy(gt, {
|
|
613
612
|
get(e, t) {
|
|
614
|
-
return t === "delimiter" ? r : t === "posix" ?
|
|
613
|
+
return t === "delimiter" ? r : t === "posix" ? ze : t === "win32" ? Mn : xn[t] || gt[t];
|
|
615
614
|
}
|
|
616
|
-
}),
|
|
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 || {}),
|
|
618
|
-
const
|
|
615
|
+
}), ze = /* @__PURE__ */ Kt(":"), Mn = /* @__PURE__ */ Kt(";");
|
|
616
|
+
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 || {}), M = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(M || {}), ne = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(ne || {});
|
|
617
|
+
const Fn = !0;
|
|
619
618
|
function L(r, e, t = r) {
|
|
620
619
|
return (n) => {
|
|
621
620
|
const a = `${n}`, i = a.indexOf(e, r.length);
|
|
@@ -623,10 +622,10 @@ function L(r, e, t = r) {
|
|
|
623
622
|
};
|
|
624
623
|
}
|
|
625
624
|
function Xt(r, e, t, n) {
|
|
626
|
-
const a = r.substring(0, n) + t, i = r.substring(n + e.length),
|
|
627
|
-
return ~
|
|
625
|
+
const a = r.substring(0, n) + t, i = r.substring(n + e.length), o = i.indexOf(e);
|
|
626
|
+
return ~o ? a + Xt(i, e, t, o) : a + i;
|
|
628
627
|
}
|
|
629
|
-
function Ln(r =
|
|
628
|
+
function Ln(r = Fn) {
|
|
630
629
|
return {
|
|
631
630
|
isColorSupported: r,
|
|
632
631
|
reset: r ? (e) => `\x1B[0m${e}\x1B[0m` : String,
|
|
@@ -657,36 +656,36 @@ function Ln(r = Mn) {
|
|
|
657
656
|
};
|
|
658
657
|
}
|
|
659
658
|
const D = Ln(), $e = {
|
|
660
|
-
[
|
|
661
|
-
[
|
|
662
|
-
[
|
|
663
|
-
[
|
|
664
|
-
[
|
|
659
|
+
[M.Error]: F.Error,
|
|
660
|
+
[M.Warning]: F.Warning,
|
|
661
|
+
[M.Log]: F.Log,
|
|
662
|
+
[M.Verbose]: F.Verbose,
|
|
663
|
+
[M.Debug]: F.Debug
|
|
665
664
|
}, Rn = {
|
|
666
|
-
[F.Error]:
|
|
667
|
-
[F.Warning]:
|
|
668
|
-
[F.Log]:
|
|
669
|
-
[F.Verbose]:
|
|
670
|
-
[F.Debug]:
|
|
665
|
+
[F.Error]: M.Error,
|
|
666
|
+
[F.Warning]: M.Warning,
|
|
667
|
+
[F.Log]: M.Log,
|
|
668
|
+
[F.Verbose]: M.Verbose,
|
|
669
|
+
[F.Debug]: M.Debug
|
|
671
670
|
}, vt = [
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
671
|
+
M.Error,
|
|
672
|
+
M.Warning,
|
|
673
|
+
M.Log,
|
|
674
|
+
M.Verbose,
|
|
675
|
+
M.Debug
|
|
677
676
|
], Tn = {
|
|
678
677
|
[F.Error]: D.red,
|
|
679
678
|
[F.Warning]: D.yellow,
|
|
680
679
|
[F.Log]: D.blue,
|
|
681
680
|
[F.Verbose]: D.cyan,
|
|
682
681
|
[F.Debug]: D.green
|
|
683
|
-
},
|
|
682
|
+
}, ke = [
|
|
684
683
|
F.Error,
|
|
685
684
|
F.Warning,
|
|
686
685
|
F.Log,
|
|
687
686
|
F.Verbose,
|
|
688
687
|
F.Debug
|
|
689
|
-
], yt = [
|
|
688
|
+
], yt = [ne.JSON, ne.Pretty];
|
|
690
689
|
function Bn(r) {
|
|
691
690
|
return r.stack == null ? [] : r.stack.split(`
|
|
692
691
|
`).map((e) => e.trim()).slice(1).filter((e) => !!/^at (.*)( \(.*:(\d+):(\d+)\))|at (.*)(:(\d+):(\d+))/i.exec(e)).map((e) => {
|
|
@@ -716,18 +715,18 @@ function Yt(r) {
|
|
|
716
715
|
function Zt(r, e, t, n, a) {
|
|
717
716
|
let i = { context: "" };
|
|
718
717
|
typeof t < "u" && t !== null && (i = { ...t }), typeof e < "u" && e !== null && (i.context = e);
|
|
719
|
-
const
|
|
718
|
+
const o = /* @__PURE__ */ new Date();
|
|
720
719
|
return {
|
|
721
|
-
"@timestamp":
|
|
722
|
-
"@localetime": a ? a(
|
|
720
|
+
"@timestamp": o.getTime(),
|
|
721
|
+
"@localetime": a ? a(o) : o.toISOString(),
|
|
723
722
|
level: r,
|
|
724
723
|
fields: i,
|
|
725
724
|
message: n
|
|
726
725
|
};
|
|
727
726
|
}
|
|
728
727
|
function Dn(r, e, t, n, a, i) {
|
|
729
|
-
const
|
|
730
|
-
return typeof a < "u" && a !== null && (
|
|
728
|
+
const o = Zt(r, e, t, n, i);
|
|
729
|
+
return typeof a < "u" && a !== null && (o.errored = !0, o.error = { stack: a }), o;
|
|
731
730
|
}
|
|
732
731
|
function wt(r) {
|
|
733
732
|
let e = "";
|
|
@@ -750,7 +749,7 @@ function wt(r) {
|
|
|
750
749
|
}
|
|
751
750
|
return e;
|
|
752
751
|
}
|
|
753
|
-
function
|
|
752
|
+
function _e(r) {
|
|
754
753
|
const e = [];
|
|
755
754
|
e.push(r["@localetime"]), e.push(
|
|
756
755
|
Tn[$e[r.level]](
|
|
@@ -761,18 +760,18 @@ function Ce(r) {
|
|
|
761
760
|
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
761
|
const n = Object.entries(r.fields);
|
|
763
762
|
n.length > 0 && e.push(" {");
|
|
764
|
-
for (const [i,
|
|
765
|
-
let
|
|
766
|
-
if (Yt(
|
|
767
|
-
if (
|
|
763
|
+
for (const [i, o] of n) {
|
|
764
|
+
let s = o;
|
|
765
|
+
if (Yt(o)) {
|
|
766
|
+
if (o.message && (s = wt(o.message)), s || (s = ""), o.cause != null)
|
|
768
767
|
try {
|
|
769
|
-
|
|
768
|
+
s += JSON.stringify(o.cause);
|
|
770
769
|
} catch {
|
|
771
|
-
|
|
770
|
+
s += String(o.cause);
|
|
772
771
|
}
|
|
773
772
|
} else
|
|
774
|
-
|
|
775
|
-
e.push(`${D.gray(i)}${D.gray("=")}${
|
|
773
|
+
s = wt(o);
|
|
774
|
+
e.push(`${D.gray(i)}${D.gray("=")}${s}`);
|
|
776
775
|
}
|
|
777
776
|
n.length > 0 && e.push("}");
|
|
778
777
|
let a = e.join(" ");
|
|
@@ -788,83 +787,83 @@ function Nn(r) {
|
|
|
788
787
|
function Un(r) {
|
|
789
788
|
return r >= F.Log;
|
|
790
789
|
}
|
|
791
|
-
function
|
|
790
|
+
function Vn(r) {
|
|
792
791
|
return r >= F.Warning;
|
|
793
792
|
}
|
|
794
|
-
function
|
|
793
|
+
function zn(r) {
|
|
795
794
|
return r >= F.Error;
|
|
796
795
|
}
|
|
797
796
|
function Jt() {
|
|
798
797
|
return typeof window < "u";
|
|
799
798
|
}
|
|
800
799
|
function $n() {
|
|
801
|
-
return !Jt() && Ge() ===
|
|
800
|
+
return !Jt() && Ge() === ne.Pretty;
|
|
802
801
|
}
|
|
803
802
|
function Gn(r, e) {
|
|
804
803
|
return $n() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
|
|
805
804
|
}
|
|
806
|
-
const
|
|
805
|
+
const Se = {
|
|
807
806
|
configured: !1,
|
|
808
807
|
logLevel: F.Debug,
|
|
809
|
-
format:
|
|
808
|
+
format: ne.JSON,
|
|
810
809
|
timeFormatter: (r) => r.toISOString()
|
|
811
810
|
};
|
|
812
811
|
function At() {
|
|
813
|
-
return
|
|
812
|
+
return Se.logLevel;
|
|
814
813
|
}
|
|
815
814
|
function Wn(r) {
|
|
816
|
-
if (
|
|
817
|
-
|
|
815
|
+
if (ke.includes(r))
|
|
816
|
+
Se.logLevel = r;
|
|
818
817
|
else
|
|
819
818
|
throw new Error(
|
|
820
|
-
`log level ${r} is not available. available log levels are: ${
|
|
819
|
+
`log level ${r} is not available. available log levels are: ${ke.join(
|
|
821
820
|
", "
|
|
822
821
|
)}`
|
|
823
822
|
);
|
|
824
|
-
|
|
823
|
+
Se.configured = !0;
|
|
825
824
|
}
|
|
826
825
|
function Ge() {
|
|
827
|
-
return
|
|
826
|
+
return Se.format;
|
|
828
827
|
}
|
|
829
828
|
function qn() {
|
|
830
|
-
return
|
|
829
|
+
return Se.timeFormatter;
|
|
831
830
|
}
|
|
832
831
|
function Qt(r) {
|
|
833
832
|
const e = {
|
|
834
833
|
fields: {},
|
|
835
834
|
context: r,
|
|
836
835
|
logLevel: F.Debug,
|
|
837
|
-
format:
|
|
836
|
+
format: ne.JSON,
|
|
838
837
|
shouldUseGlobalConfig: !1,
|
|
839
838
|
errorProcessor: (c) => c,
|
|
840
839
|
timeFormatter: (c) => c.toISOString(),
|
|
841
840
|
useGlobalConfig: () => (e.shouldUseGlobalConfig = !0, e.format = Ge(), e.logLevel = At(), e.child()),
|
|
842
841
|
child: (c) => {
|
|
843
|
-
const
|
|
844
|
-
return c != null ?
|
|
842
|
+
const d = Qt(e.context);
|
|
843
|
+
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
844
|
},
|
|
846
845
|
withContext: (c) => {
|
|
847
|
-
const
|
|
848
|
-
return
|
|
846
|
+
const d = e.child();
|
|
847
|
+
return d.context = c, d;
|
|
849
848
|
},
|
|
850
849
|
withLogLevel: (c) => {
|
|
851
|
-
const
|
|
852
|
-
if (
|
|
853
|
-
|
|
850
|
+
const d = e.child();
|
|
851
|
+
if (ke.includes(c))
|
|
852
|
+
d.logLevel = c, d.shouldUseGlobalConfig = !1, d.debug(
|
|
854
853
|
`setting log level to ${Rn[c]} (${c})`
|
|
855
854
|
);
|
|
856
855
|
else
|
|
857
856
|
throw new Error(
|
|
858
|
-
`log level ${c} is not available. available log levels are: ${
|
|
857
|
+
`log level ${c} is not available. available log levels are: ${ke.join(
|
|
859
858
|
", "
|
|
860
859
|
)}`
|
|
861
860
|
);
|
|
862
|
-
return
|
|
861
|
+
return d;
|
|
863
862
|
},
|
|
864
863
|
withLogLevelString: (c) => {
|
|
865
|
-
const
|
|
864
|
+
const d = e.child();
|
|
866
865
|
if (vt.includes(c))
|
|
867
|
-
|
|
866
|
+
d.logLevel = $e[c], d.shouldUseGlobalConfig = !1, d.debug(
|
|
868
867
|
`setting log level to ${c} (${$e[c]})`
|
|
869
868
|
);
|
|
870
869
|
else
|
|
@@ -873,45 +872,45 @@ function Qt(r) {
|
|
|
873
872
|
", "
|
|
874
873
|
)}`
|
|
875
874
|
);
|
|
876
|
-
return
|
|
875
|
+
return d;
|
|
877
876
|
},
|
|
878
877
|
withFormat: (c) => {
|
|
879
|
-
const
|
|
878
|
+
const d = e.child();
|
|
880
879
|
if (yt.includes(c))
|
|
881
|
-
|
|
880
|
+
d.format = c, d.shouldUseGlobalConfig = !1, d.debug(`setting format to ${c}`);
|
|
882
881
|
else
|
|
883
882
|
throw new Error(
|
|
884
883
|
`format ${c} is not available. available formats are: ${yt.join(
|
|
885
884
|
", "
|
|
886
885
|
)}`
|
|
887
886
|
);
|
|
888
|
-
return
|
|
887
|
+
return d;
|
|
889
888
|
},
|
|
890
889
|
withFields: (c) => typeof c > "u" || c === null ? e.child({}) : e.child(c),
|
|
891
|
-
withField(c,
|
|
890
|
+
withField(c, d) {
|
|
892
891
|
if (typeof c > "u" || c === null)
|
|
893
892
|
throw new Error("key is required");
|
|
894
|
-
return e.child({ [c]:
|
|
893
|
+
return e.child({ [c]: d });
|
|
895
894
|
},
|
|
896
895
|
withError: (c) => {
|
|
897
896
|
if (c = e.errorProcessor(c), !Yt(c))
|
|
898
897
|
return e.withField("error", String(c));
|
|
899
|
-
let
|
|
900
|
-
if (
|
|
898
|
+
let d = e;
|
|
899
|
+
if (d = d.withField("error", c.message), c.stack != null && (d = d.withField("stack", c.stack)), c.cause != null)
|
|
901
900
|
try {
|
|
902
|
-
|
|
901
|
+
d = d.withField("cause", JSON.stringify(c.cause));
|
|
903
902
|
} catch {
|
|
904
|
-
|
|
903
|
+
d = d.withField("cause", String(c.cause));
|
|
905
904
|
}
|
|
906
|
-
return
|
|
905
|
+
return d;
|
|
907
906
|
},
|
|
908
907
|
withCallStack(c) {
|
|
909
|
-
const
|
|
910
|
-
return
|
|
911
|
-
function:
|
|
912
|
-
file: `${
|
|
913
|
-
line:
|
|
914
|
-
column:
|
|
908
|
+
const d = Bn(c).slice(2).filter((m) => !m.invalid);
|
|
909
|
+
return d.length === 0 ? e : e.child({
|
|
910
|
+
function: d[0].function,
|
|
911
|
+
file: `${d[0].file}:${d[0].line}:${d[0].column}`,
|
|
912
|
+
line: d[0].line,
|
|
913
|
+
column: d[0].column
|
|
915
914
|
});
|
|
916
915
|
},
|
|
917
916
|
// Placeholder implementations, will be overridden below
|
|
@@ -930,16 +929,16 @@ function Qt(r) {
|
|
|
930
929
|
// TODO: remove in next major release
|
|
931
930
|
withTimeFormat: (c) => e.child(),
|
|
932
931
|
withTimeFormatter: (c) => {
|
|
933
|
-
const
|
|
934
|
-
return
|
|
932
|
+
const d = e.child();
|
|
933
|
+
return d.timeFormatter = c, d;
|
|
935
934
|
},
|
|
936
935
|
withErrorProcessor: (c) => {
|
|
937
|
-
const
|
|
938
|
-
return
|
|
936
|
+
const d = e.child();
|
|
937
|
+
return d.errorProcessor = c, d;
|
|
939
938
|
}
|
|
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,
|
|
939
|
+
}, 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
940
|
const v = n();
|
|
942
|
-
if (Jt() && v ===
|
|
941
|
+
if (Jt() && v === ne.Pretty) {
|
|
943
942
|
c.fields = Object.fromEntries(
|
|
944
943
|
Object.entries(c.fields).filter(([b, E]) => {
|
|
945
944
|
if (b === "isNestSystemModule" || b === "nestSystemModule" || b === "context")
|
|
@@ -947,80 +946,80 @@ function Qt(r) {
|
|
|
947
946
|
})
|
|
948
947
|
);
|
|
949
948
|
const A = m ?? e.fields;
|
|
950
|
-
Array.isArray(A) && A.length > 0 ? console[
|
|
949
|
+
Array.isArray(A) && A.length > 0 ? console[d](_e(c), ...A) : Object.keys(A).length > 0 ? console[d](_e(c), A) : console[d](_e(c));
|
|
951
950
|
return;
|
|
952
951
|
}
|
|
953
|
-
const S = v ===
|
|
954
|
-
console[
|
|
955
|
-
},
|
|
956
|
-
[
|
|
957
|
-
[
|
|
958
|
-
[
|
|
959
|
-
[
|
|
952
|
+
const S = v === ne.Pretty ? _e(c) : JSON.stringify(c);
|
|
953
|
+
console[d](S);
|
|
954
|
+
}, s = {
|
|
955
|
+
[M.Debug]: On,
|
|
956
|
+
[M.Verbose]: Nn,
|
|
957
|
+
[M.Log]: Un,
|
|
958
|
+
[M.Warning]: Vn
|
|
960
959
|
}, l = {
|
|
961
|
-
[
|
|
962
|
-
[
|
|
963
|
-
[
|
|
964
|
-
[
|
|
965
|
-
}, p = (c,
|
|
966
|
-
const v = t(), S =
|
|
960
|
+
[M.Debug]: "debug",
|
|
961
|
+
[M.Verbose]: "log",
|
|
962
|
+
[M.Log]: "log",
|
|
963
|
+
[M.Warning]: "warn"
|
|
964
|
+
}, p = (c, d, m) => {
|
|
965
|
+
const v = t(), S = s[c];
|
|
967
966
|
if (!S(v))
|
|
968
967
|
return;
|
|
969
968
|
const A = i(m), b = Zt(
|
|
970
969
|
c,
|
|
971
970
|
e.context,
|
|
972
971
|
A,
|
|
973
|
-
|
|
972
|
+
d,
|
|
974
973
|
a()
|
|
975
974
|
);
|
|
976
|
-
|
|
975
|
+
o(b, l[c], A);
|
|
977
976
|
};
|
|
978
|
-
return e.debug = (c, ...
|
|
979
|
-
p(
|
|
980
|
-
}, e.verbose = (c, ...
|
|
981
|
-
p(
|
|
982
|
-
}, e.log = (c, ...
|
|
983
|
-
p(
|
|
984
|
-
}, e.warn = (c, ...
|
|
985
|
-
p(
|
|
986
|
-
}, e.error = (c,
|
|
977
|
+
return e.debug = (c, ...d) => {
|
|
978
|
+
p(M.Debug, c, d);
|
|
979
|
+
}, e.verbose = (c, ...d) => {
|
|
980
|
+
p(M.Verbose, c, d);
|
|
981
|
+
}, e.log = (c, ...d) => {
|
|
982
|
+
p(M.Log, c, d);
|
|
983
|
+
}, e.warn = (c, ...d) => {
|
|
984
|
+
p(M.Warning, c, d);
|
|
985
|
+
}, e.error = (c, d, ...m) => {
|
|
987
986
|
const v = t();
|
|
988
|
-
if (!
|
|
987
|
+
if (!zn(v))
|
|
989
988
|
return;
|
|
990
989
|
const S = i(m), A = Dn(
|
|
991
|
-
|
|
990
|
+
M.Error,
|
|
992
991
|
e.context,
|
|
993
992
|
S,
|
|
994
993
|
c,
|
|
995
|
-
|
|
994
|
+
d,
|
|
996
995
|
a()
|
|
997
996
|
);
|
|
998
|
-
|
|
999
|
-
}, e.errorWithError = (c,
|
|
997
|
+
o(A, "error", S);
|
|
998
|
+
}, e.errorWithError = (c, d, ...m) => e.withError(d).error(c, void 0, ...m), e;
|
|
1000
999
|
}
|
|
1001
1000
|
function Hn(r) {
|
|
1002
1001
|
var i;
|
|
1003
|
-
const t = fn.parse(new Error())[1], n = ((i = t.fileName) == null ? void 0 : i.replace("async", "").trim()) ?? "", a =
|
|
1002
|
+
const t = fn.parse(new Error())[1], n = ((i = t.fileName) == null ? void 0 : i.replace("async", "").trim()) ?? "", a = ze.join(...n.split(ze.sep).slice(-2));
|
|
1004
1003
|
return r = r ?? `${a}:${t.lineNumber}`, Qt(Gn(n, r));
|
|
1005
1004
|
}
|
|
1006
1005
|
const jn = (r) => Hn(r).useGlobalConfig();
|
|
1007
|
-
let
|
|
1006
|
+
let Q = [];
|
|
1008
1007
|
const St = 100;
|
|
1009
1008
|
async function Kn() {
|
|
1010
|
-
if (
|
|
1009
|
+
if (Q.length === 0)
|
|
1011
1010
|
return;
|
|
1012
|
-
const r = [...
|
|
1013
|
-
|
|
1011
|
+
const r = [...Q];
|
|
1012
|
+
Q = [];
|
|
1014
1013
|
try {
|
|
1015
1014
|
await Xn();
|
|
1016
1015
|
} catch (e) {
|
|
1017
|
-
h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)),
|
|
1016
|
+
h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)), Q.unshift(...r), Q.length > St && (Q = Q.slice(0, St));
|
|
1018
1017
|
}
|
|
1019
1018
|
}
|
|
1020
1019
|
async function Xn(r) {
|
|
1021
1020
|
}
|
|
1022
1021
|
function Yn() {
|
|
1023
|
-
|
|
1022
|
+
Q.length > 0 && Kn(), h.log("[CLS] Cleaned up");
|
|
1024
1023
|
}
|
|
1025
1024
|
Wn(F.Warning);
|
|
1026
1025
|
const h = jn("Web").withErrorProcessor((r) => r).useGlobalConfig(), O = {
|
|
@@ -1044,7 +1043,7 @@ async function Zn(r) {
|
|
|
1044
1043
|
if (!a.endpoints)
|
|
1045
1044
|
throw new Error("Invalid config response: missing endpoints");
|
|
1046
1045
|
const i = {};
|
|
1047
|
-
a.endpoints.cn && (i[
|
|
1046
|
+
a.endpoints.cn && (i[se.cn] = `https://${a.endpoints.cn}`), a.endpoints.intl && (i[se.intl] = `https://${a.endpoints.intl}`), a.endpoints.test && (i[se.test] = `https://${a.endpoints.test}`), O.config = i, h.log("[SdkConfigLoader] SDK config fetched successfully:", i);
|
|
1048
1047
|
} catch {
|
|
1049
1048
|
O.config = {};
|
|
1050
1049
|
} finally {
|
|
@@ -1057,9 +1056,9 @@ function Jn() {
|
|
|
1057
1056
|
}
|
|
1058
1057
|
class Qn {
|
|
1059
1058
|
constructor(e) {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1059
|
+
u(this, "module");
|
|
1060
|
+
u(this, "allocatedPointers");
|
|
1061
|
+
u(this, "structPointers");
|
|
1063
1062
|
this.module = e, this.allocatedPointers = /* @__PURE__ */ new Set(), this.structPointers = /* @__PURE__ */ new Map();
|
|
1064
1063
|
}
|
|
1065
1064
|
/**
|
|
@@ -1087,9 +1086,9 @@ class Qn {
|
|
|
1087
1086
|
throw new Error("teethPb is missing or empty!");
|
|
1088
1087
|
if (!e.teethNpz || e.teethNpz.byteLength === 0)
|
|
1089
1088
|
throw new Error("teethNpz is missing or empty!");
|
|
1090
|
-
const a = this.allocateAndCopy(e.flameModel), i = this.allocateAndCopy(e.flameTemplate),
|
|
1089
|
+
const a = this.allocateAndCopy(e.flameModel), i = this.allocateAndCopy(e.flameTemplate), o = this.allocateAndCopy(e.teethPb), s = this.allocateAndCopy(e.teethNpz);
|
|
1091
1090
|
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,
|
|
1091
|
+
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
1092
|
}
|
|
1094
1093
|
/**
|
|
1095
1094
|
* 创建 AvatarCharacterData 结构体 - 新版 Emscripten 方式
|
|
@@ -1098,11 +1097,11 @@ class Qn {
|
|
|
1098
1097
|
const i = this.module._malloc(16);
|
|
1099
1098
|
if (!i)
|
|
1100
1099
|
throw new Error("Failed to allocate AvatarCharacterData structure");
|
|
1101
|
-
const
|
|
1100
|
+
const o = this.allocateAndCopy(e), s = this.allocateAndCopy(t);
|
|
1102
1101
|
let l = 0;
|
|
1103
|
-
this.module.setValue(i + l,
|
|
1102
|
+
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
1103
|
const p = n ? `character_data_${n}` : "character_data";
|
|
1105
|
-
return this.structPointers.set(p, i), { dataPtr: i, shapePtr:
|
|
1104
|
+
return this.structPointers.set(p, i), { dataPtr: i, shapePtr: o.ptr, plyPtr: s.ptr };
|
|
1106
1105
|
}
|
|
1107
1106
|
/**
|
|
1108
1107
|
* 读取 AvatarFlameParams 结构体数据
|
|
@@ -1119,12 +1118,12 @@ class Qn {
|
|
|
1119
1118
|
const i = [];
|
|
1120
1119
|
for (let m = 0; m < 3; m++)
|
|
1121
1120
|
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
1121
|
const o = [];
|
|
1126
1122
|
for (let m = 0; m < 3; m++)
|
|
1127
1123
|
o.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1124
|
+
const s = [];
|
|
1125
|
+
for (let m = 0; m < 3; m++)
|
|
1126
|
+
s.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1128
1127
|
const l = [];
|
|
1129
1128
|
for (let m = 0; m < 3; m++)
|
|
1130
1129
|
l.push(this.module.getValue(e + t, "float")), t += 4;
|
|
@@ -1134,24 +1133,24 @@ class Qn {
|
|
|
1134
1133
|
const c = [];
|
|
1135
1134
|
for (let m = 0; m < 2; m++)
|
|
1136
1135
|
c.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1137
|
-
const
|
|
1136
|
+
const d = this.module.getValue(e + t, "i32") !== 0;
|
|
1138
1137
|
return {
|
|
1139
1138
|
shape_params: n,
|
|
1140
1139
|
expr_params: a,
|
|
1141
1140
|
rotation: i,
|
|
1142
|
-
translation:
|
|
1143
|
-
neck_pose:
|
|
1141
|
+
translation: o,
|
|
1142
|
+
neck_pose: s,
|
|
1144
1143
|
jaw_pose: l,
|
|
1145
1144
|
eyes_pose: p,
|
|
1146
1145
|
eyelid: c,
|
|
1147
|
-
has_eyelid:
|
|
1146
|
+
has_eyelid: d
|
|
1148
1147
|
};
|
|
1149
1148
|
}
|
|
1150
1149
|
/**
|
|
1151
1150
|
* 创建 AvatarFlameParams 结构体 - 新版 Emscripten 方式
|
|
1152
1151
|
*/
|
|
1153
1152
|
createFlameParams(e) {
|
|
1154
|
-
var i,
|
|
1153
|
+
var i, o, s, l, p, c, d, m;
|
|
1155
1154
|
const n = this.module._malloc(1684);
|
|
1156
1155
|
if (!n)
|
|
1157
1156
|
throw new Error("Failed to allocate AvatarFlameParams structure");
|
|
@@ -1161,11 +1160,11 @@ class Qn {
|
|
|
1161
1160
|
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1162
1161
|
}
|
|
1163
1162
|
for (let v = 0; v < 100; v++) {
|
|
1164
|
-
const S = ((
|
|
1163
|
+
const S = ((o = e.expr_params) == null ? void 0 : o[v]) || 0;
|
|
1165
1164
|
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1166
1165
|
}
|
|
1167
1166
|
for (let v = 0; v < 3; v++) {
|
|
1168
|
-
const S = ((
|
|
1167
|
+
const S = ((s = e.rotation) == null ? void 0 : s[v]) || 0;
|
|
1169
1168
|
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1170
1169
|
}
|
|
1171
1170
|
for (let v = 0; v < 3; v++) {
|
|
@@ -1181,7 +1180,7 @@ class Qn {
|
|
|
1181
1180
|
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1182
1181
|
}
|
|
1183
1182
|
for (let v = 0; v < 6; v++) {
|
|
1184
|
-
const S = ((
|
|
1183
|
+
const S = ((d = e.eyes_pose) == null ? void 0 : d[v]) || 0;
|
|
1185
1184
|
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1186
1185
|
}
|
|
1187
1186
|
for (let v = 0; v < 2; v++) {
|
|
@@ -1211,14 +1210,14 @@ class Qn {
|
|
|
1211
1210
|
const t = this.module.getValue(e, "i32"), n = this.module.getValue(e + 4, "i32");
|
|
1212
1211
|
if (n === 0 || !t)
|
|
1213
1212
|
return null;
|
|
1214
|
-
const i = n * 13,
|
|
1215
|
-
return
|
|
1213
|
+
const i = n * 13, o = t / 4, s = new Float32Array(i);
|
|
1214
|
+
return s.set(this.module.HEAPF32.subarray(o, o + i)), s;
|
|
1216
1215
|
}
|
|
1217
1216
|
/**
|
|
1218
1217
|
* 读取AvatarMeshData结构体数据
|
|
1219
1218
|
*/
|
|
1220
1219
|
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"),
|
|
1220
|
+
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
1221
|
if (t && n > 0)
|
|
1223
1222
|
for (let m = 0; m < n * 3; m++)
|
|
1224
1223
|
p[m] = this.module.getValue(t + m * 4, "float");
|
|
@@ -1226,20 +1225,20 @@ class Qn {
|
|
|
1226
1225
|
if (a && i > 0)
|
|
1227
1226
|
for (let m = 0; m < i * 3; m++)
|
|
1228
1227
|
c[m] = this.module.getValue(a + m * 4, "i32");
|
|
1229
|
-
let
|
|
1230
|
-
if (
|
|
1231
|
-
|
|
1228
|
+
let d = null;
|
|
1229
|
+
if (s && l > 0) {
|
|
1230
|
+
d = new Float32Array(l * 3);
|
|
1232
1231
|
for (let m = 0; m < l * 3; m++)
|
|
1233
|
-
|
|
1232
|
+
d[m] = this.module.getValue(s + m * 4, "float");
|
|
1234
1233
|
}
|
|
1235
1234
|
return {
|
|
1236
1235
|
vertices: p,
|
|
1237
1236
|
vertexCount: n,
|
|
1238
1237
|
faces: c,
|
|
1239
1238
|
faceCount: i,
|
|
1240
|
-
landmarks:
|
|
1239
|
+
landmarks: d,
|
|
1241
1240
|
landmarkCount: l,
|
|
1242
|
-
computeTime:
|
|
1241
|
+
computeTime: o
|
|
1243
1242
|
};
|
|
1244
1243
|
}
|
|
1245
1244
|
/**
|
|
@@ -1280,37 +1279,37 @@ class Qn {
|
|
|
1280
1279
|
class ea {
|
|
1281
1280
|
constructor(e = {}) {
|
|
1282
1281
|
// 配置
|
|
1283
|
-
|
|
1284
|
-
|
|
1282
|
+
u(this, "options");
|
|
1283
|
+
u(this, "wasmConfig");
|
|
1285
1284
|
// 核心组件
|
|
1286
1285
|
// eslint-disable-next-line ts/no-explicit-any
|
|
1287
|
-
|
|
1288
|
-
|
|
1286
|
+
u(this, "wasmModule");
|
|
1287
|
+
u(this, "memoryManager");
|
|
1289
1288
|
// Avatar Core handles
|
|
1290
|
-
|
|
1289
|
+
u(this, "coreHandle");
|
|
1291
1290
|
// Support multiple character handles (key: characterId, value: handle)
|
|
1292
|
-
|
|
1291
|
+
u(this, "characterHandles", /* @__PURE__ */ new Map());
|
|
1293
1292
|
// Animation handles per character (key: characterId, value: { handle, totalFrames })
|
|
1294
|
-
|
|
1293
|
+
u(this, "animationHandles", /* @__PURE__ */ new Map());
|
|
1295
1294
|
// Legacy single character support (deprecated, kept for backward compatibility)
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1295
|
+
u(this, "characterHandle");
|
|
1296
|
+
u(this, "animationHandle");
|
|
1297
|
+
u(this, "totalFrames");
|
|
1299
1298
|
// 状态管理
|
|
1300
|
-
|
|
1301
|
-
|
|
1299
|
+
u(this, "isInitialized");
|
|
1300
|
+
u(this, "isCharacterLoaded");
|
|
1302
1301
|
// C API 函数包装
|
|
1303
1302
|
// eslint-disable-next-line ts/no-explicit-any
|
|
1304
|
-
|
|
1303
|
+
u(this, "api");
|
|
1305
1304
|
// 性能监控
|
|
1306
|
-
|
|
1307
|
-
|
|
1305
|
+
u(this, "performanceMetrics");
|
|
1306
|
+
u(this, "wasmTime", 0);
|
|
1308
1307
|
// 最近一次 WASM 计算耗时
|
|
1309
1308
|
// 错误码映射
|
|
1310
|
-
|
|
1309
|
+
u(this, "errorCodes");
|
|
1311
1310
|
// 模型信息
|
|
1312
|
-
|
|
1313
|
-
|
|
1311
|
+
u(this, "flameInfo");
|
|
1312
|
+
u(this, "characterInfo");
|
|
1314
1313
|
this.options = {
|
|
1315
1314
|
logLevel: "basic",
|
|
1316
1315
|
enableValidation: !0,
|
|
@@ -1495,25 +1494,25 @@ class ea {
|
|
|
1495
1494
|
throw new Error("Avatar Core not initialized");
|
|
1496
1495
|
const a = performance.now();
|
|
1497
1496
|
try {
|
|
1498
|
-
const { dataPtr: i, shapePtr:
|
|
1497
|
+
const { dataPtr: i, shapePtr: o, plyPtr: s } = this.memoryManager.createCharacterData(
|
|
1499
1498
|
e,
|
|
1500
1499
|
t,
|
|
1501
1500
|
n
|
|
1502
1501
|
), l = this.api.loadCharacter(this.coreHandle, i);
|
|
1503
1502
|
if (!l) {
|
|
1504
|
-
this.memoryManager.free(
|
|
1505
|
-
const
|
|
1506
|
-
throw this.memoryManager.freeStruct(
|
|
1503
|
+
this.memoryManager.free(o), this.memoryManager.free(s);
|
|
1504
|
+
const d = n ? `character_data_${n}` : "character_data";
|
|
1505
|
+
throw this.memoryManager.freeStruct(d), new Error("avatar_core_load_character returned NULL - character loading failed");
|
|
1507
1506
|
}
|
|
1508
|
-
this.memoryManager.free(
|
|
1507
|
+
this.memoryManager.free(o), this.memoryManager.free(s);
|
|
1509
1508
|
const p = n ? `character_data_${n}` : "character_data";
|
|
1510
1509
|
this.memoryManager.freeStruct(p);
|
|
1511
1510
|
const c = n || "default";
|
|
1512
1511
|
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
1512
|
} catch (i) {
|
|
1514
1513
|
h.errorWithError("❌ Character loading failed:", i);
|
|
1515
|
-
const
|
|
1516
|
-
throw new Error(`Character loading failed: ${
|
|
1514
|
+
const o = i instanceof Error ? i.message : String(i);
|
|
1515
|
+
throw new Error(`Character loading failed: ${o}`);
|
|
1517
1516
|
}
|
|
1518
1517
|
}
|
|
1519
1518
|
async loadAnimationFromData(e) {
|
|
@@ -1549,8 +1548,8 @@ class ea {
|
|
|
1549
1548
|
const t = `${this.options.baseAssetsPath}/${this.options.modelFolder}/${e}`, n = this.wasmConfig.baseUrl ? `${this.wasmConfig.baseUrl}${t}` : t, a = await fetch(n);
|
|
1550
1549
|
if (!a.ok)
|
|
1551
1550
|
throw new Error(`HTTP error! status: ${a.status}`);
|
|
1552
|
-
const i = await a.arrayBuffer(),
|
|
1553
|
-
return this.animationHandle =
|
|
1551
|
+
const i = await a.arrayBuffer(), o = await this.loadAnimationFromData(i);
|
|
1552
|
+
return this.animationHandle = o, this.totalFrames = null, await this.getAnimationTotalFrames(), this.totalFrames;
|
|
1554
1553
|
} catch (t) {
|
|
1555
1554
|
h.errorWithError(`❌ Failed to switch animation to ${e}:`, t);
|
|
1556
1555
|
const n = t instanceof Error ? t.message : String(t);
|
|
@@ -1569,8 +1568,8 @@ class ea {
|
|
|
1569
1568
|
const n = this.wasmModule._malloc(4), a = this.api.getAnimationFrameCount(t, n);
|
|
1570
1569
|
if (a !== 0) {
|
|
1571
1570
|
this.wasmModule._free(n);
|
|
1572
|
-
const
|
|
1573
|
-
throw new Error(`Failed to get animation frame count: ${
|
|
1571
|
+
const o = this.api.getErrorString(a);
|
|
1572
|
+
throw new Error(`Failed to get animation frame count: ${o}`);
|
|
1574
1573
|
}
|
|
1575
1574
|
const i = this.wasmModule.getValue(n, "i32");
|
|
1576
1575
|
return this.wasmModule._free(n), e || (this.totalFrames = i), i;
|
|
@@ -1589,24 +1588,24 @@ class ea {
|
|
|
1589
1588
|
const n = t || "default", a = this.animationHandles.get(n), i = (a == null ? void 0 : a.handle) || this.animationHandle;
|
|
1590
1589
|
if (!i)
|
|
1591
1590
|
throw new Error("No animation loaded");
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1591
|
+
const o = (a == null ? void 0 : a.totalFrames) ?? this.totalFrames;
|
|
1592
|
+
o !== null && o > 0 && (e = e % o, e < 0 && (e += o));
|
|
1594
1593
|
try {
|
|
1595
1594
|
const l = this.wasmModule._malloc(1684), p = this.api.getFrameFromAnimation(i, e, l);
|
|
1596
1595
|
if (p !== 0) {
|
|
1597
1596
|
this.wasmModule._free(l);
|
|
1598
|
-
const
|
|
1599
|
-
throw new Error(`Failed to get frame ${e}: ${
|
|
1597
|
+
const d = this.api.getErrorString(p);
|
|
1598
|
+
throw new Error(`Failed to get frame ${e}: ${d}`);
|
|
1600
1599
|
}
|
|
1601
1600
|
const c = this.characterHandles.get(n) || this.characterHandle;
|
|
1602
1601
|
if (c) {
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1602
|
+
const d = this.api.getCharacterShapeParams(c, l);
|
|
1603
|
+
d !== 0 && h.warn(`Failed to get character shape params: ${this.api.getErrorString(d)}`);
|
|
1605
1604
|
}
|
|
1606
1605
|
return l;
|
|
1607
|
-
} catch (
|
|
1608
|
-
h.errorWithError(`❌ Failed to get animation frame ${e}:`,
|
|
1609
|
-
const l =
|
|
1606
|
+
} catch (s) {
|
|
1607
|
+
h.errorWithError(`❌ Failed to get animation frame ${e}:`, s);
|
|
1608
|
+
const l = s instanceof Error ? s.message : String(s);
|
|
1610
1609
|
throw new Error(`Failed to get animation frame ${e}: ${l}`);
|
|
1611
1610
|
}
|
|
1612
1611
|
}
|
|
@@ -1669,8 +1668,8 @@ class ea {
|
|
|
1669
1668
|
n
|
|
1670
1669
|
);
|
|
1671
1670
|
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:
|
|
1671
|
+
const i = this.wasmModule.getValue(e, "i32"), o = this.wasmModule.getValue(t, "i32"), s = this.wasmModule.getValue(n, "i32");
|
|
1672
|
+
this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: i, faceCount: o, jointCount: s };
|
|
1674
1673
|
} catch (e) {
|
|
1675
1674
|
const t = e instanceof Error ? e.message : String(e);
|
|
1676
1675
|
h.errorWithError("❌ Failed to query FLAME info:", t);
|
|
@@ -1788,31 +1787,31 @@ class ea {
|
|
|
1788
1787
|
const n = performance.now();
|
|
1789
1788
|
let a = null, i = null;
|
|
1790
1789
|
try {
|
|
1791
|
-
const
|
|
1790
|
+
const o = (e == null ? void 0 : e.frameIndex) ?? 0, s = t || this.characterHandle;
|
|
1792
1791
|
let l;
|
|
1793
|
-
if (
|
|
1792
|
+
if (s) {
|
|
1794
1793
|
for (const [m, v] of this.characterHandles.entries())
|
|
1795
|
-
if (v ===
|
|
1794
|
+
if (v === s) {
|
|
1796
1795
|
l = m;
|
|
1797
1796
|
break;
|
|
1798
1797
|
}
|
|
1799
|
-
!l &&
|
|
1798
|
+
!l && s === this.characterHandle && (l = "default");
|
|
1800
1799
|
}
|
|
1801
|
-
if (i = await this.getAnimationFrameParams(
|
|
1800
|
+
if (i = await this.getAnimationFrameParams(o, l), a = this.wasmModule._malloc(16), !s)
|
|
1802
1801
|
throw new Error("No character loaded");
|
|
1803
1802
|
const p = this.api.computeFrameFlat(
|
|
1804
1803
|
this.coreHandle,
|
|
1805
|
-
|
|
1804
|
+
s,
|
|
1806
1805
|
i,
|
|
1807
1806
|
a
|
|
1808
1807
|
);
|
|
1809
1808
|
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: ${
|
|
1809
|
+
const c = this.memoryManager.readSplatPointFlatArray(a), d = performance.now() - n;
|
|
1810
|
+
return this.wasmTime = d, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += d, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, c;
|
|
1811
|
+
} catch (o) {
|
|
1812
|
+
h.errorWithError("❌ computeCompleteFrameFlat failed:", o);
|
|
1813
|
+
const s = o instanceof Error ? o.message : String(o);
|
|
1814
|
+
throw new Error(`computeCompleteFrameFlat failed: ${s}`);
|
|
1816
1815
|
} finally {
|
|
1817
1816
|
a !== null && (this.api.freeSplatPointsFlat(a), this.wasmModule._free(a)), i !== null && this.wasmModule._free(i);
|
|
1818
1817
|
}
|
|
@@ -1833,22 +1832,22 @@ class ea {
|
|
|
1833
1832
|
let a = null, i = null;
|
|
1834
1833
|
try {
|
|
1835
1834
|
i = this.memoryManager.createFlameParams(e), a = this.wasmModule._malloc(16);
|
|
1836
|
-
const
|
|
1837
|
-
if (!
|
|
1835
|
+
const o = t || this.characterHandle;
|
|
1836
|
+
if (!o)
|
|
1838
1837
|
throw new Error("No character loaded");
|
|
1839
|
-
const
|
|
1838
|
+
const s = this.api.computeFrameFlat(
|
|
1840
1839
|
this.coreHandle,
|
|
1841
|
-
|
|
1840
|
+
o,
|
|
1842
1841
|
i,
|
|
1843
1842
|
a
|
|
1844
1843
|
);
|
|
1845
|
-
this.checkError(
|
|
1844
|
+
this.checkError(s, "avatar_core_compute_frame_as_splat_points_flat");
|
|
1846
1845
|
const l = this.memoryManager.readSplatPointFlatArray(a), p = performance.now() - n;
|
|
1847
1846
|
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: ${
|
|
1847
|
+
} catch (o) {
|
|
1848
|
+
h.errorWithError("❌ computeFrameFlatFromParams failed:", o);
|
|
1849
|
+
const s = o instanceof Error ? o.message : String(o);
|
|
1850
|
+
throw new Error(`computeFrameFlatFromParams failed: ${s}`);
|
|
1852
1851
|
} finally {
|
|
1853
1852
|
a !== null && (this.api.freeSplatPointsFlat(a), this.wasmModule._free(a)), i !== null && this.wasmModule._free(i);
|
|
1854
1853
|
}
|
|
@@ -1977,6 +1976,14 @@ class y {
|
|
|
1977
1976
|
static get version() {
|
|
1978
1977
|
return this._version;
|
|
1979
1978
|
}
|
|
1979
|
+
/**
|
|
1980
|
+
* 获取播放模式(根据 drivingServiceMode)
|
|
1981
|
+
* @internal
|
|
1982
|
+
*/
|
|
1983
|
+
static getPlaybackMode() {
|
|
1984
|
+
var e;
|
|
1985
|
+
return ((e = this._configuration) == null ? void 0 : e.drivingServiceMode) ?? we.sdk;
|
|
1986
|
+
}
|
|
1980
1987
|
/**
|
|
1981
1988
|
* 获取AvatarCore实例(仅供 SDK 内部使用)
|
|
1982
1989
|
* @internal
|
|
@@ -2017,15 +2024,15 @@ class y {
|
|
|
2017
2024
|
if (!this._configuration)
|
|
2018
2025
|
throw new Error("AvatarKit not initialized");
|
|
2019
2026
|
const t = {
|
|
2020
|
-
[
|
|
2027
|
+
[se.cn]: {
|
|
2021
2028
|
sdkApiBaseUrl: "https://api.spatialwalk.top",
|
|
2022
2029
|
driveningressWsUrl: "wss://api.spatialwalk.top/v1/driveningress/websocket"
|
|
2023
2030
|
},
|
|
2024
|
-
[
|
|
2031
|
+
[se.intl]: {
|
|
2025
2032
|
sdkApiBaseUrl: "https://api.spatialwalk.cloud",
|
|
2026
2033
|
driveningressWsUrl: "wss://api.spatialwalk.cloud/v1/driveningress/websocket"
|
|
2027
2034
|
},
|
|
2028
|
-
[
|
|
2035
|
+
[se.test]: {
|
|
2029
2036
|
sdkApiBaseUrl: "https://api-test.spatialwalk.top",
|
|
2030
2037
|
driveningressWsUrl: "wss://api-test.spatialwalk.top/v1/driveningress/websocket"
|
|
2031
2038
|
}
|
|
@@ -2043,9 +2050,9 @@ class y {
|
|
|
2043
2050
|
* @internal
|
|
2044
2051
|
*/
|
|
2045
2052
|
static logEvent(e, t = "info", n = {}) {
|
|
2046
|
-
var
|
|
2053
|
+
var o;
|
|
2047
2054
|
const a = {
|
|
2048
|
-
environment: ((
|
|
2055
|
+
environment: ((o = this._configuration) == null ? void 0 : o.environment) ?? "unknown",
|
|
2049
2056
|
sessionToken: this._sessionToken ?? "",
|
|
2050
2057
|
userId: this._userId ?? "",
|
|
2051
2058
|
sdkVersion: this._version,
|
|
@@ -2054,30 +2061,30 @@ class y {
|
|
|
2054
2061
|
h[i](`[Telemetry] ${e}`, a);
|
|
2055
2062
|
}
|
|
2056
2063
|
}
|
|
2057
|
-
|
|
2064
|
+
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.22"), u(y, "_avatarCore", null), u(y, "_dynamicSdkConfig", null), u(y, "_logLevels", {
|
|
2058
2065
|
debug: "log",
|
|
2059
2066
|
info: "log",
|
|
2060
2067
|
warning: "warn",
|
|
2061
2068
|
error: "error"
|
|
2062
2069
|
});
|
|
2063
|
-
const
|
|
2070
|
+
const Ae = class Ae {
|
|
2064
2071
|
constructor() {
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2072
|
+
u(this, "audio", null);
|
|
2073
|
+
u(this, "streamingPlayer", null);
|
|
2074
|
+
u(this, "_isPlaying", !1);
|
|
2075
|
+
u(this, "fps", k.animation.fps);
|
|
2076
|
+
u(this, "onEndedCallback");
|
|
2077
|
+
u(this, "useStreaming", !1);
|
|
2071
2078
|
}
|
|
2072
2079
|
/**
|
|
2073
2080
|
* 解锁音频上下文(Safari 自动播放策略)
|
|
2074
2081
|
* 必须在用户交互事件(如 click)中调用
|
|
2075
2082
|
*/
|
|
2076
2083
|
static async unlockAudioContext() {
|
|
2077
|
-
if (!
|
|
2084
|
+
if (!Ae.audioUnlocked)
|
|
2078
2085
|
try {
|
|
2079
2086
|
const e = new Audio();
|
|
2080
|
-
e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", e.volume = 0, await e.play(), e.pause(), e.currentTime = 0,
|
|
2087
|
+
e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", e.volume = 0, await e.play(), e.pause(), e.currentTime = 0, Ae.audioUnlocked = !0, h.log("✅ Audio context unlocked for Safari");
|
|
2081
2088
|
} catch (e) {
|
|
2082
2089
|
h.warn("⚠️ Failed to unlock audio context:", e);
|
|
2083
2090
|
}
|
|
@@ -2123,7 +2130,7 @@ const we = class we {
|
|
|
2123
2130
|
async createAndInitializeStreamingPlayer() {
|
|
2124
2131
|
if (this.streamingPlayer)
|
|
2125
2132
|
return;
|
|
2126
|
-
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-
|
|
2133
|
+
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-DjPD7f6u.js");
|
|
2127
2134
|
this.streamingPlayer = new e({
|
|
2128
2135
|
sampleRate: k.audio.sampleRate,
|
|
2129
2136
|
channelCount: 1,
|
|
@@ -2208,26 +2215,42 @@ const we = class we {
|
|
|
2208
2215
|
var e;
|
|
2209
2216
|
this.useStreaming ? await ((e = this.streamingPlayer) == null ? void 0 : e.resume()) : this.audio && await this.audio.play();
|
|
2210
2217
|
}
|
|
2218
|
+
/**
|
|
2219
|
+
* 设置音量 (0.0 - 1.0)
|
|
2220
|
+
* 注意:这仅控制数字人音频播放器的音量,不影响系统音量
|
|
2221
|
+
* @param volume 音量值,范围 0.0 到 1.0(0.0 为静音,1.0 为最大音量)
|
|
2222
|
+
*/
|
|
2223
|
+
setVolume(e) {
|
|
2224
|
+
this.useStreaming && this.streamingPlayer ? this.streamingPlayer.setVolume(e) : this.audio && (this.audio.volume = Math.max(0, Math.min(1, e)));
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* 获取当前音量
|
|
2228
|
+
* @returns 当前音量值 (0.0 - 1.0)
|
|
2229
|
+
*/
|
|
2230
|
+
getVolume() {
|
|
2231
|
+
var e;
|
|
2232
|
+
return this.useStreaming && this.streamingPlayer ? this.streamingPlayer.getVolume() : ((e = this.audio) == null ? void 0 : e.volume) ?? 1;
|
|
2233
|
+
}
|
|
2211
2234
|
dispose() {
|
|
2212
2235
|
this.stop(), this.audio && (this.audio.src = "", this.audio = null), this.streamingPlayer && (this.streamingPlayer.dispose(), this.streamingPlayer = null), this.onEndedCallback = void 0;
|
|
2213
2236
|
}
|
|
2214
2237
|
};
|
|
2215
|
-
|
|
2216
|
-
let
|
|
2238
|
+
u(Ae, "audioUnlocked", !1);
|
|
2239
|
+
let oe = Ae, ta = (r) => crypto.getRandomValues(new Uint8Array(r)), ra = (r, e, t) => {
|
|
2217
2240
|
let n = (2 << Math.log2(r.length - 1)) - 1, a = -~(1.6 * n * e / r.length);
|
|
2218
2241
|
return (i = e) => {
|
|
2219
|
-
let
|
|
2242
|
+
let o = "";
|
|
2220
2243
|
for (; ; ) {
|
|
2221
|
-
let
|
|
2244
|
+
let s = t(a), l = a | 0;
|
|
2222
2245
|
for (; l--; )
|
|
2223
|
-
if (
|
|
2246
|
+
if (o += r[s[l] & n] || "", o.length >= i) return o;
|
|
2224
2247
|
}
|
|
2225
2248
|
};
|
|
2226
2249
|
}, na = (r, e = 21) => ra(r, e | 0, ta);
|
|
2227
2250
|
const aa = na("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12);
|
|
2228
2251
|
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 `${
|
|
2252
|
+
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();
|
|
2253
|
+
return `${s}_${l}`;
|
|
2231
2254
|
}
|
|
2232
2255
|
function ia() {
|
|
2233
2256
|
let r = 0, e = 0;
|
|
@@ -2246,35 +2269,35 @@ function ia() {
|
|
|
2246
2269
|
}
|
|
2247
2270
|
throw new Error("invalid varint");
|
|
2248
2271
|
}
|
|
2249
|
-
function
|
|
2272
|
+
function De(r, e, t) {
|
|
2250
2273
|
for (let i = 0; i < 28; i = i + 7) {
|
|
2251
|
-
const
|
|
2252
|
-
if (t.push(l), !
|
|
2274
|
+
const o = r >>> i, s = !(!(o >>> 7) && e == 0), l = (s ? o | 128 : o) & 255;
|
|
2275
|
+
if (t.push(l), !s)
|
|
2253
2276
|
return;
|
|
2254
2277
|
}
|
|
2255
2278
|
const n = r >>> 28 & 15 | (e & 7) << 4, a = !!(e >> 3);
|
|
2256
2279
|
if (t.push((a ? n | 128 : n) & 255), !!a) {
|
|
2257
2280
|
for (let i = 3; i < 31; i = i + 7) {
|
|
2258
|
-
const
|
|
2259
|
-
if (t.push(l), !
|
|
2281
|
+
const o = e >>> i, s = !!(o >>> 7), l = (s ? o | 128 : o) & 255;
|
|
2282
|
+
if (t.push(l), !s)
|
|
2260
2283
|
return;
|
|
2261
2284
|
}
|
|
2262
2285
|
t.push(e >>> 31 & 1);
|
|
2263
2286
|
}
|
|
2264
2287
|
}
|
|
2265
|
-
const
|
|
2288
|
+
const Ee = 4294967296;
|
|
2266
2289
|
function bt(r) {
|
|
2267
2290
|
const e = r[0] === "-";
|
|
2268
2291
|
e && (r = r.slice(1));
|
|
2269
2292
|
const t = 1e6;
|
|
2270
2293
|
let n = 0, a = 0;
|
|
2271
|
-
function i(
|
|
2272
|
-
const l = Number(r.slice(
|
|
2273
|
-
a *= t, n = n * t + l, n >=
|
|
2294
|
+
function i(o, s) {
|
|
2295
|
+
const l = Number(r.slice(o, s));
|
|
2296
|
+
a *= t, n = n * t + l, n >= Ee && (a = a + (n / Ee | 0), n = n % Ee);
|
|
2274
2297
|
}
|
|
2275
2298
|
return i(-24, -18), i(-18, -12), i(-12, -6), i(-6), e ? rr(n, a) : je(n, a);
|
|
2276
2299
|
}
|
|
2277
|
-
function
|
|
2300
|
+
function oa(r, e) {
|
|
2278
2301
|
let t = je(r, e);
|
|
2279
2302
|
const n = t.hi & 2147483648;
|
|
2280
2303
|
n && (t = rr(t.lo, t.hi));
|
|
@@ -2282,14 +2305,14 @@ function sa(r, e) {
|
|
|
2282
2305
|
return n ? "-" + a : a;
|
|
2283
2306
|
}
|
|
2284
2307
|
function tr(r, e) {
|
|
2285
|
-
if ({ lo: r, hi: e } =
|
|
2286
|
-
return String(
|
|
2308
|
+
if ({ lo: r, hi: e } = sa(r, e), e <= 2097151)
|
|
2309
|
+
return String(Ee * e + r);
|
|
2287
2310
|
const t = r & 16777215, n = (r >>> 24 | e << 8) & 16777215, a = e >> 16 & 65535;
|
|
2288
|
-
let i = t + n * 6777216 + a * 6710656,
|
|
2311
|
+
let i = t + n * 6777216 + a * 6710656, o = n + a * 8147497, s = a * 2;
|
|
2289
2312
|
const l = 1e7;
|
|
2290
|
-
return i >= l && (
|
|
2313
|
+
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
2314
|
}
|
|
2292
|
-
function
|
|
2315
|
+
function sa(r, e) {
|
|
2293
2316
|
return { lo: r >>> 0, hi: e >>> 0 };
|
|
2294
2317
|
}
|
|
2295
2318
|
function je(r, e) {
|
|
@@ -2330,7 +2353,7 @@ function la() {
|
|
|
2330
2353
|
throw new Error("invalid varint");
|
|
2331
2354
|
return this.assertBounds(), e >>> 0;
|
|
2332
2355
|
}
|
|
2333
|
-
const
|
|
2356
|
+
const j = /* @__PURE__ */ ca();
|
|
2334
2357
|
function ca() {
|
|
2335
2358
|
const r = new DataView(new ArrayBuffer(8));
|
|
2336
2359
|
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 +2361,35 @@ function ca() {
|
|
|
2338
2361
|
return {
|
|
2339
2362
|
zero: BigInt(0),
|
|
2340
2363
|
supported: !0,
|
|
2341
|
-
parse(
|
|
2342
|
-
const
|
|
2343
|
-
if (
|
|
2344
|
-
throw new Error(`invalid int64: ${
|
|
2345
|
-
return
|
|
2364
|
+
parse(o) {
|
|
2365
|
+
const s = typeof o == "bigint" ? o : BigInt(o);
|
|
2366
|
+
if (s > n || s < t)
|
|
2367
|
+
throw new Error(`invalid int64: ${o}`);
|
|
2368
|
+
return s;
|
|
2346
2369
|
},
|
|
2347
|
-
uParse(
|
|
2348
|
-
const
|
|
2349
|
-
if (
|
|
2350
|
-
throw new Error(`invalid uint64: ${
|
|
2351
|
-
return
|
|
2370
|
+
uParse(o) {
|
|
2371
|
+
const s = typeof o == "bigint" ? o : BigInt(o);
|
|
2372
|
+
if (s > i || s < a)
|
|
2373
|
+
throw new Error(`invalid uint64: ${o}`);
|
|
2374
|
+
return s;
|
|
2352
2375
|
},
|
|
2353
|
-
enc(
|
|
2354
|
-
return r.setBigInt64(0, this.parse(
|
|
2376
|
+
enc(o) {
|
|
2377
|
+
return r.setBigInt64(0, this.parse(o), !0), {
|
|
2355
2378
|
lo: r.getInt32(0, !0),
|
|
2356
2379
|
hi: r.getInt32(4, !0)
|
|
2357
2380
|
};
|
|
2358
2381
|
},
|
|
2359
|
-
uEnc(
|
|
2360
|
-
return r.setBigInt64(0, this.uParse(
|
|
2382
|
+
uEnc(o) {
|
|
2383
|
+
return r.setBigInt64(0, this.uParse(o), !0), {
|
|
2361
2384
|
lo: r.getInt32(0, !0),
|
|
2362
2385
|
hi: r.getInt32(4, !0)
|
|
2363
2386
|
};
|
|
2364
2387
|
},
|
|
2365
|
-
dec(
|
|
2366
|
-
return r.setInt32(0,
|
|
2388
|
+
dec(o, s) {
|
|
2389
|
+
return r.setInt32(0, o, !0), r.setInt32(4, s, !0), r.getBigInt64(0, !0);
|
|
2367
2390
|
},
|
|
2368
|
-
uDec(
|
|
2369
|
-
return r.setInt32(0,
|
|
2391
|
+
uDec(o, s) {
|
|
2392
|
+
return r.setInt32(0, o, !0), r.setInt32(4, s, !0), r.getBigUint64(0, !0);
|
|
2370
2393
|
}
|
|
2371
2394
|
};
|
|
2372
2395
|
}
|
|
@@ -2386,7 +2409,7 @@ function ca() {
|
|
|
2386
2409
|
return typeof t != "string" && (t = t.toString()), Et(t), bt(t);
|
|
2387
2410
|
},
|
|
2388
2411
|
dec(t, n) {
|
|
2389
|
-
return
|
|
2412
|
+
return oa(t, n);
|
|
2390
2413
|
},
|
|
2391
2414
|
uDec(t, n) {
|
|
2392
2415
|
return tr(t, n);
|
|
@@ -2401,11 +2424,11 @@ function Et(r) {
|
|
|
2401
2424
|
if (!/^[0-9]+$/.test(r))
|
|
2402
2425
|
throw new Error("invalid uint64: " + r);
|
|
2403
2426
|
}
|
|
2404
|
-
const
|
|
2427
|
+
const Oe = Symbol.for("@bufbuild/protobuf/text-encoding");
|
|
2405
2428
|
function nr() {
|
|
2406
|
-
if (globalThis[
|
|
2429
|
+
if (globalThis[Oe] == null) {
|
|
2407
2430
|
const r = new globalThis.TextEncoder(), e = new globalThis.TextDecoder();
|
|
2408
|
-
globalThis[
|
|
2431
|
+
globalThis[Oe] = {
|
|
2409
2432
|
encodeUtf8(t) {
|
|
2410
2433
|
return r.encode(t);
|
|
2411
2434
|
},
|
|
@@ -2421,14 +2444,14 @@ function nr() {
|
|
|
2421
2444
|
}
|
|
2422
2445
|
};
|
|
2423
2446
|
}
|
|
2424
|
-
return globalThis[
|
|
2447
|
+
return globalThis[Oe];
|
|
2425
2448
|
}
|
|
2426
|
-
var
|
|
2449
|
+
var te;
|
|
2427
2450
|
(function(r) {
|
|
2428
2451
|
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
|
-
})(
|
|
2452
|
+
})(te || (te = {}));
|
|
2430
2453
|
const da = 34028234663852886e22, ua = -34028234663852886e22, ha = 4294967295, fa = 2147483647, ma = -2147483648;
|
|
2431
|
-
class
|
|
2454
|
+
class ce {
|
|
2432
2455
|
constructor(e = nr().encodeUtf8) {
|
|
2433
2456
|
this.encodeUtf8 = e, this.stack = [], this.chunks = [], this.buf = [];
|
|
2434
2457
|
}
|
|
@@ -2492,7 +2515,7 @@ class oe {
|
|
|
2492
2515
|
* Write a `int32` value, a signed 32 bit varint.
|
|
2493
2516
|
*/
|
|
2494
2517
|
int32(e) {
|
|
2495
|
-
return
|
|
2518
|
+
return Ne(e), _t(e, this.buf), this;
|
|
2496
2519
|
}
|
|
2497
2520
|
/**
|
|
2498
2521
|
* Write a `bool` value, a variant.
|
|
@@ -2540,7 +2563,7 @@ class oe {
|
|
|
2540
2563
|
* Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
|
|
2541
2564
|
*/
|
|
2542
2565
|
sfixed32(e) {
|
|
2543
|
-
|
|
2566
|
+
Ne(e);
|
|
2544
2567
|
let t = new Uint8Array(4);
|
|
2545
2568
|
return new DataView(t.buffer).setInt32(0, e, !0), this.raw(t);
|
|
2546
2569
|
}
|
|
@@ -2548,42 +2571,42 @@ class oe {
|
|
|
2548
2571
|
* Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
|
|
2549
2572
|
*/
|
|
2550
2573
|
sint32(e) {
|
|
2551
|
-
return
|
|
2574
|
+
return Ne(e), e = (e << 1 ^ e >> 31) >>> 0, _t(e, this.buf), this;
|
|
2552
2575
|
}
|
|
2553
2576
|
/**
|
|
2554
2577
|
* Write a `fixed64` value, a signed, fixed-length 64-bit integer.
|
|
2555
2578
|
*/
|
|
2556
2579
|
sfixed64(e) {
|
|
2557
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), a =
|
|
2580
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), a = j.enc(e);
|
|
2558
2581
|
return n.setInt32(0, a.lo, !0), n.setInt32(4, a.hi, !0), this.raw(t);
|
|
2559
2582
|
}
|
|
2560
2583
|
/**
|
|
2561
2584
|
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
|
|
2562
2585
|
*/
|
|
2563
2586
|
fixed64(e) {
|
|
2564
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), a =
|
|
2587
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), a = j.uEnc(e);
|
|
2565
2588
|
return n.setInt32(0, a.lo, !0), n.setInt32(4, a.hi, !0), this.raw(t);
|
|
2566
2589
|
}
|
|
2567
2590
|
/**
|
|
2568
2591
|
* Write a `int64` value, a signed 64-bit varint.
|
|
2569
2592
|
*/
|
|
2570
2593
|
int64(e) {
|
|
2571
|
-
let t =
|
|
2572
|
-
return
|
|
2594
|
+
let t = j.enc(e);
|
|
2595
|
+
return De(t.lo, t.hi, this.buf), this;
|
|
2573
2596
|
}
|
|
2574
2597
|
/**
|
|
2575
2598
|
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
2576
2599
|
*/
|
|
2577
2600
|
sint64(e) {
|
|
2578
|
-
const t =
|
|
2579
|
-
return
|
|
2601
|
+
const t = j.enc(e), n = t.hi >> 31, a = t.lo << 1 ^ n, i = (t.hi << 1 | t.lo >>> 31) ^ n;
|
|
2602
|
+
return De(a, i, this.buf), this;
|
|
2580
2603
|
}
|
|
2581
2604
|
/**
|
|
2582
2605
|
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
2583
2606
|
*/
|
|
2584
2607
|
uint64(e) {
|
|
2585
|
-
const t =
|
|
2586
|
-
return
|
|
2608
|
+
const t = j.uEnc(e);
|
|
2609
|
+
return De(t.lo, t.hi, this.buf), this;
|
|
2587
2610
|
}
|
|
2588
2611
|
}
|
|
2589
2612
|
class N {
|
|
@@ -2608,28 +2631,28 @@ class N {
|
|
|
2608
2631
|
skip(e, t) {
|
|
2609
2632
|
let n = this.pos;
|
|
2610
2633
|
switch (e) {
|
|
2611
|
-
case
|
|
2634
|
+
case te.Varint:
|
|
2612
2635
|
for (; this.buf[this.pos++] & 128; )
|
|
2613
2636
|
;
|
|
2614
2637
|
break;
|
|
2615
|
-
case
|
|
2638
|
+
case te.Bit64:
|
|
2616
2639
|
this.pos += 4;
|
|
2617
|
-
case
|
|
2640
|
+
case te.Bit32:
|
|
2618
2641
|
this.pos += 4;
|
|
2619
2642
|
break;
|
|
2620
|
-
case
|
|
2643
|
+
case te.LengthDelimited:
|
|
2621
2644
|
let a = this.uint32();
|
|
2622
2645
|
this.pos += a;
|
|
2623
2646
|
break;
|
|
2624
|
-
case
|
|
2647
|
+
case te.StartGroup:
|
|
2625
2648
|
for (; ; ) {
|
|
2626
|
-
const [i,
|
|
2627
|
-
if (
|
|
2649
|
+
const [i, o] = this.tag();
|
|
2650
|
+
if (o === te.EndGroup) {
|
|
2628
2651
|
if (t !== void 0 && i !== t)
|
|
2629
2652
|
throw new Error("invalid end group tag");
|
|
2630
2653
|
break;
|
|
2631
2654
|
}
|
|
2632
|
-
this.skip(
|
|
2655
|
+
this.skip(o, i);
|
|
2633
2656
|
}
|
|
2634
2657
|
break;
|
|
2635
2658
|
default:
|
|
@@ -2661,20 +2684,20 @@ class N {
|
|
|
2661
2684
|
* Read a `int64` field, a signed 64-bit varint.
|
|
2662
2685
|
*/
|
|
2663
2686
|
int64() {
|
|
2664
|
-
return
|
|
2687
|
+
return j.dec(...this.varint64());
|
|
2665
2688
|
}
|
|
2666
2689
|
/**
|
|
2667
2690
|
* Read a `uint64` field, an unsigned 64-bit varint.
|
|
2668
2691
|
*/
|
|
2669
2692
|
uint64() {
|
|
2670
|
-
return
|
|
2693
|
+
return j.uDec(...this.varint64());
|
|
2671
2694
|
}
|
|
2672
2695
|
/**
|
|
2673
2696
|
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
|
2674
2697
|
*/
|
|
2675
2698
|
sint64() {
|
|
2676
2699
|
let [e, t] = this.varint64(), n = -(e & 1);
|
|
2677
|
-
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n,
|
|
2700
|
+
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n, j.dec(e, t);
|
|
2678
2701
|
}
|
|
2679
2702
|
/**
|
|
2680
2703
|
* Read a `bool` field, a variant.
|
|
@@ -2699,13 +2722,13 @@ class N {
|
|
|
2699
2722
|
* Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
|
|
2700
2723
|
*/
|
|
2701
2724
|
fixed64() {
|
|
2702
|
-
return
|
|
2725
|
+
return j.uDec(this.sfixed32(), this.sfixed32());
|
|
2703
2726
|
}
|
|
2704
2727
|
/**
|
|
2705
2728
|
* Read a `fixed64` field, a signed, fixed-length 64-bit integer.
|
|
2706
2729
|
*/
|
|
2707
2730
|
sfixed64() {
|
|
2708
|
-
return
|
|
2731
|
+
return j.dec(this.sfixed32(), this.sfixed32());
|
|
2709
2732
|
}
|
|
2710
2733
|
/**
|
|
2711
2734
|
* Read a `float` field, 32-bit floating point number.
|
|
@@ -2733,7 +2756,7 @@ class N {
|
|
|
2733
2756
|
return this.decodeUtf8(this.bytes());
|
|
2734
2757
|
}
|
|
2735
2758
|
}
|
|
2736
|
-
function
|
|
2759
|
+
function Ne(r) {
|
|
2737
2760
|
if (typeof r == "string")
|
|
2738
2761
|
r = Number(r);
|
|
2739
2762
|
else if (typeof r != "number")
|
|
@@ -2759,7 +2782,7 @@ function pa(r) {
|
|
|
2759
2782
|
if (Number.isFinite(r) && (r > da || r < ua))
|
|
2760
2783
|
throw new Error("invalid float32: " + r);
|
|
2761
2784
|
}
|
|
2762
|
-
var
|
|
2785
|
+
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
2786
|
function ga(r) {
|
|
2764
2787
|
switch (r) {
|
|
2765
2788
|
case 0:
|
|
@@ -2798,8 +2821,8 @@ function va(r) {
|
|
|
2798
2821
|
function kt() {
|
|
2799
2822
|
return { reqId: "", audio: new Uint8Array(0), end: !1 };
|
|
2800
2823
|
}
|
|
2801
|
-
const
|
|
2802
|
-
encode(r, e = new
|
|
2824
|
+
const ue = {
|
|
2825
|
+
encode(r, e = new ce()) {
|
|
2803
2826
|
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
2827
|
},
|
|
2805
2828
|
decode(r, e) {
|
|
@@ -2846,7 +2869,7 @@ const ce = {
|
|
|
2846
2869
|
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
2870
|
},
|
|
2848
2871
|
create(r) {
|
|
2849
|
-
return
|
|
2872
|
+
return ue.fromPartial(r ?? {});
|
|
2850
2873
|
},
|
|
2851
2874
|
fromPartial(r) {
|
|
2852
2875
|
const e = kt();
|
|
@@ -2856,8 +2879,8 @@ const ce = {
|
|
|
2856
2879
|
function xt() {
|
|
2857
2880
|
return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
|
|
2858
2881
|
}
|
|
2859
|
-
const
|
|
2860
|
-
encode(r, e = new
|
|
2882
|
+
const he = {
|
|
2883
|
+
encode(r, e = new ce()) {
|
|
2861
2884
|
e.uint32(18).fork();
|
|
2862
2885
|
for (const t of r.translation)
|
|
2863
2886
|
e.float(t);
|
|
@@ -2894,8 +2917,8 @@ const de = {
|
|
|
2894
2917
|
continue;
|
|
2895
2918
|
}
|
|
2896
2919
|
if (i === 18) {
|
|
2897
|
-
const
|
|
2898
|
-
for (; t.pos <
|
|
2920
|
+
const o = t.uint32() + t.pos;
|
|
2921
|
+
for (; t.pos < o; )
|
|
2899
2922
|
a.translation.push(t.float());
|
|
2900
2923
|
continue;
|
|
2901
2924
|
}
|
|
@@ -2907,8 +2930,8 @@ const de = {
|
|
|
2907
2930
|
continue;
|
|
2908
2931
|
}
|
|
2909
2932
|
if (i === 26) {
|
|
2910
|
-
const
|
|
2911
|
-
for (; t.pos <
|
|
2933
|
+
const o = t.uint32() + t.pos;
|
|
2934
|
+
for (; t.pos < o; )
|
|
2912
2935
|
a.rotation.push(t.float());
|
|
2913
2936
|
continue;
|
|
2914
2937
|
}
|
|
@@ -2920,8 +2943,8 @@ const de = {
|
|
|
2920
2943
|
continue;
|
|
2921
2944
|
}
|
|
2922
2945
|
if (i === 34) {
|
|
2923
|
-
const
|
|
2924
|
-
for (; t.pos <
|
|
2946
|
+
const o = t.uint32() + t.pos;
|
|
2947
|
+
for (; t.pos < o; )
|
|
2925
2948
|
a.neckPose.push(t.float());
|
|
2926
2949
|
continue;
|
|
2927
2950
|
}
|
|
@@ -2933,8 +2956,8 @@ const de = {
|
|
|
2933
2956
|
continue;
|
|
2934
2957
|
}
|
|
2935
2958
|
if (i === 42) {
|
|
2936
|
-
const
|
|
2937
|
-
for (; t.pos <
|
|
2959
|
+
const o = t.uint32() + t.pos;
|
|
2960
|
+
for (; t.pos < o; )
|
|
2938
2961
|
a.jawPose.push(t.float());
|
|
2939
2962
|
continue;
|
|
2940
2963
|
}
|
|
@@ -2946,8 +2969,8 @@ const de = {
|
|
|
2946
2969
|
continue;
|
|
2947
2970
|
}
|
|
2948
2971
|
if (i === 50) {
|
|
2949
|
-
const
|
|
2950
|
-
for (; t.pos <
|
|
2972
|
+
const o = t.uint32() + t.pos;
|
|
2973
|
+
for (; t.pos < o; )
|
|
2951
2974
|
a.eyePose.push(t.float());
|
|
2952
2975
|
continue;
|
|
2953
2976
|
}
|
|
@@ -2959,8 +2982,8 @@ const de = {
|
|
|
2959
2982
|
continue;
|
|
2960
2983
|
}
|
|
2961
2984
|
if (i === 58) {
|
|
2962
|
-
const
|
|
2963
|
-
for (; t.pos <
|
|
2985
|
+
const o = t.uint32() + t.pos;
|
|
2986
|
+
for (; t.pos < o; )
|
|
2964
2987
|
a.eyeLid.push(t.float());
|
|
2965
2988
|
continue;
|
|
2966
2989
|
}
|
|
@@ -2972,8 +2995,8 @@ const de = {
|
|
|
2972
2995
|
continue;
|
|
2973
2996
|
}
|
|
2974
2997
|
if (i === 66) {
|
|
2975
|
-
const
|
|
2976
|
-
for (; t.pos <
|
|
2998
|
+
const o = t.uint32() + t.pos;
|
|
2999
|
+
for (; t.pos < o; )
|
|
2977
3000
|
a.expression.push(t.float());
|
|
2978
3001
|
continue;
|
|
2979
3002
|
}
|
|
@@ -2998,39 +3021,39 @@ const de = {
|
|
|
2998
3021
|
};
|
|
2999
3022
|
},
|
|
3000
3023
|
toJSON(r) {
|
|
3001
|
-
var t, n, a, i,
|
|
3024
|
+
var t, n, a, i, o, s, l;
|
|
3002
3025
|
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), (
|
|
3026
|
+
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
3027
|
},
|
|
3005
3028
|
create(r) {
|
|
3006
|
-
return
|
|
3029
|
+
return he.fromPartial(r ?? {});
|
|
3007
3030
|
},
|
|
3008
3031
|
fromPartial(r) {
|
|
3009
|
-
var t, n, a, i,
|
|
3032
|
+
var t, n, a, i, o, s, l;
|
|
3010
3033
|
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 = ((
|
|
3034
|
+
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
3035
|
}
|
|
3013
3036
|
};
|
|
3014
|
-
function
|
|
3037
|
+
function Mt() {
|
|
3015
3038
|
return { keyframes: [] };
|
|
3016
3039
|
}
|
|
3017
|
-
const
|
|
3018
|
-
encode(r, e = new
|
|
3040
|
+
const fe = {
|
|
3041
|
+
encode(r, e = new ce()) {
|
|
3019
3042
|
for (const t of r.keyframes)
|
|
3020
|
-
|
|
3043
|
+
he.encode(t, e.uint32(10).fork()).join();
|
|
3021
3044
|
return e;
|
|
3022
3045
|
},
|
|
3023
3046
|
decode(r, e) {
|
|
3024
3047
|
const t = r instanceof N ? r : new N(r);
|
|
3025
3048
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
3026
|
-
const a =
|
|
3049
|
+
const a = Mt();
|
|
3027
3050
|
for (; t.pos < n; ) {
|
|
3028
3051
|
const i = t.uint32();
|
|
3029
3052
|
switch (i >>> 3) {
|
|
3030
3053
|
case 1: {
|
|
3031
3054
|
if (i !== 10)
|
|
3032
3055
|
break;
|
|
3033
|
-
a.keyframes.push(
|
|
3056
|
+
a.keyframes.push(he.decode(t, t.uint32()));
|
|
3034
3057
|
continue;
|
|
3035
3058
|
}
|
|
3036
3059
|
}
|
|
@@ -3042,34 +3065,34 @@ const ue = {
|
|
|
3042
3065
|
},
|
|
3043
3066
|
fromJSON(r) {
|
|
3044
3067
|
return {
|
|
3045
|
-
keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) =>
|
|
3068
|
+
keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) => he.fromJSON(e)) : []
|
|
3046
3069
|
};
|
|
3047
3070
|
},
|
|
3048
3071
|
toJSON(r) {
|
|
3049
3072
|
var t;
|
|
3050
3073
|
const e = {};
|
|
3051
|
-
return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) =>
|
|
3074
|
+
return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) => he.toJSON(n))), e;
|
|
3052
3075
|
},
|
|
3053
3076
|
create(r) {
|
|
3054
|
-
return
|
|
3077
|
+
return fe.fromPartial(r ?? {});
|
|
3055
3078
|
},
|
|
3056
3079
|
fromPartial(r) {
|
|
3057
3080
|
var t;
|
|
3058
|
-
const e =
|
|
3059
|
-
return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) =>
|
|
3081
|
+
const e = Mt();
|
|
3082
|
+
return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => he.fromPartial(n))) || [], e;
|
|
3060
3083
|
}
|
|
3061
3084
|
};
|
|
3062
|
-
function
|
|
3085
|
+
function Ft() {
|
|
3063
3086
|
return { reqId: "", animation: void 0 };
|
|
3064
3087
|
}
|
|
3065
|
-
const
|
|
3066
|
-
encode(r, e = new
|
|
3067
|
-
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 &&
|
|
3088
|
+
const me = {
|
|
3089
|
+
encode(r, e = new ce()) {
|
|
3090
|
+
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && fe.encode(r.animation, e.uint32(18).fork()).join(), e;
|
|
3068
3091
|
},
|
|
3069
3092
|
decode(r, e) {
|
|
3070
3093
|
const t = r instanceof N ? r : new N(r);
|
|
3071
3094
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
3072
|
-
const a =
|
|
3095
|
+
const a = Ft();
|
|
3073
3096
|
for (; t.pos < n; ) {
|
|
3074
3097
|
const i = t.uint32();
|
|
3075
3098
|
switch (i >>> 3) {
|
|
@@ -3082,7 +3105,7 @@ const he = {
|
|
|
3082
3105
|
case 2: {
|
|
3083
3106
|
if (i !== 18)
|
|
3084
3107
|
break;
|
|
3085
|
-
a.animation =
|
|
3108
|
+
a.animation = fe.decode(t, t.uint32());
|
|
3086
3109
|
continue;
|
|
3087
3110
|
}
|
|
3088
3111
|
}
|
|
@@ -3095,26 +3118,26 @@ const he = {
|
|
|
3095
3118
|
fromJSON(r) {
|
|
3096
3119
|
return {
|
|
3097
3120
|
reqId: U(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
3098
|
-
animation: U(r.animation) ?
|
|
3121
|
+
animation: U(r.animation) ? fe.fromJSON(r.animation) : void 0
|
|
3099
3122
|
};
|
|
3100
3123
|
},
|
|
3101
3124
|
toJSON(r) {
|
|
3102
3125
|
const e = {};
|
|
3103
|
-
return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation =
|
|
3126
|
+
return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation = fe.toJSON(r.animation)), e;
|
|
3104
3127
|
},
|
|
3105
3128
|
create(r) {
|
|
3106
|
-
return
|
|
3129
|
+
return me.fromPartial(r ?? {});
|
|
3107
3130
|
},
|
|
3108
3131
|
fromPartial(r) {
|
|
3109
|
-
const e =
|
|
3110
|
-
return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ?
|
|
3132
|
+
const e = Ft();
|
|
3133
|
+
return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ? fe.fromPartial(r.animation) : void 0, e;
|
|
3111
3134
|
}
|
|
3112
3135
|
};
|
|
3113
3136
|
function Lt() {
|
|
3114
3137
|
return { reqId: "", code: 0, reason: "" };
|
|
3115
3138
|
}
|
|
3116
|
-
const
|
|
3117
|
-
encode(r, e = new
|
|
3139
|
+
const pe = {
|
|
3140
|
+
encode(r, e = new ce()) {
|
|
3118
3141
|
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
3142
|
},
|
|
3120
3143
|
decode(r, e) {
|
|
@@ -3161,7 +3184,7 @@ const fe = {
|
|
|
3161
3184
|
return r.reqId !== "" && (e.reqId = r.reqId), r.code !== 0 && (e.code = Math.round(r.code)), r.reason !== "" && (e.reason = r.reason), e;
|
|
3162
3185
|
},
|
|
3163
3186
|
create(r) {
|
|
3164
|
-
return
|
|
3187
|
+
return pe.fromPartial(r ?? {});
|
|
3165
3188
|
},
|
|
3166
3189
|
fromPartial(r) {
|
|
3167
3190
|
const e = Lt();
|
|
@@ -3172,8 +3195,8 @@ function Rt() {
|
|
|
3172
3195
|
return { type: 0, error: void 0, serverResponseAnimation: void 0, clientAudioInput: void 0 };
|
|
3173
3196
|
}
|
|
3174
3197
|
const We = {
|
|
3175
|
-
encode(r, e = new
|
|
3176
|
-
return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 &&
|
|
3198
|
+
encode(r, e = new ce()) {
|
|
3199
|
+
return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 && pe.encode(r.error, e.uint32(18).fork()).join(), r.serverResponseAnimation !== void 0 && me.encode(r.serverResponseAnimation, e.uint32(26).fork()).join(), r.clientAudioInput !== void 0 && ue.encode(r.clientAudioInput, e.uint32(34).fork()).join(), e;
|
|
3177
3200
|
},
|
|
3178
3201
|
decode(r, e) {
|
|
3179
3202
|
const t = r instanceof N ? r : new N(r);
|
|
@@ -3191,19 +3214,19 @@ const We = {
|
|
|
3191
3214
|
case 2: {
|
|
3192
3215
|
if (i !== 18)
|
|
3193
3216
|
break;
|
|
3194
|
-
a.error =
|
|
3217
|
+
a.error = pe.decode(t, t.uint32());
|
|
3195
3218
|
continue;
|
|
3196
3219
|
}
|
|
3197
3220
|
case 3: {
|
|
3198
3221
|
if (i !== 26)
|
|
3199
3222
|
break;
|
|
3200
|
-
a.serverResponseAnimation =
|
|
3223
|
+
a.serverResponseAnimation = me.decode(t, t.uint32());
|
|
3201
3224
|
continue;
|
|
3202
3225
|
}
|
|
3203
3226
|
case 4: {
|
|
3204
3227
|
if (i !== 34)
|
|
3205
3228
|
break;
|
|
3206
|
-
a.clientAudioInput =
|
|
3229
|
+
a.clientAudioInput = ue.decode(t, t.uint32());
|
|
3207
3230
|
continue;
|
|
3208
3231
|
}
|
|
3209
3232
|
}
|
|
@@ -3216,21 +3239,21 @@ const We = {
|
|
|
3216
3239
|
fromJSON(r) {
|
|
3217
3240
|
return {
|
|
3218
3241
|
type: U(r.type) ? ga(r.type) : 0,
|
|
3219
|
-
error: U(r.error) ?
|
|
3220
|
-
serverResponseAnimation: U(r.serverResponseAnimation) ?
|
|
3221
|
-
clientAudioInput: U(r.clientAudioInput) ?
|
|
3242
|
+
error: U(r.error) ? pe.fromJSON(r.error) : void 0,
|
|
3243
|
+
serverResponseAnimation: U(r.serverResponseAnimation) ? me.fromJSON(r.serverResponseAnimation) : void 0,
|
|
3244
|
+
clientAudioInput: U(r.clientAudioInput) ? ue.fromJSON(r.clientAudioInput) : void 0
|
|
3222
3245
|
};
|
|
3223
3246
|
},
|
|
3224
3247
|
toJSON(r) {
|
|
3225
3248
|
const e = {};
|
|
3226
|
-
return r.type !== 0 && (e.type = va(r.type)), r.error !== void 0 && (e.error =
|
|
3249
|
+
return r.type !== 0 && (e.type = va(r.type)), r.error !== void 0 && (e.error = pe.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = me.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = ue.toJSON(r.clientAudioInput)), e;
|
|
3227
3250
|
},
|
|
3228
3251
|
create(r) {
|
|
3229
3252
|
return We.fromPartial(r ?? {});
|
|
3230
3253
|
},
|
|
3231
3254
|
fromPartial(r) {
|
|
3232
3255
|
const e = Rt();
|
|
3233
|
-
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ?
|
|
3256
|
+
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? pe.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? me.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? ue.fromPartial(r.clientAudioInput) : void 0, e;
|
|
3234
3257
|
}
|
|
3235
3258
|
};
|
|
3236
3259
|
function ya(r) {
|
|
@@ -3250,7 +3273,7 @@ function U(r) {
|
|
|
3250
3273
|
}
|
|
3251
3274
|
class Aa {
|
|
3252
3275
|
constructor() {
|
|
3253
|
-
|
|
3276
|
+
u(this, "events", /* @__PURE__ */ new Map());
|
|
3254
3277
|
}
|
|
3255
3278
|
on(e, t) {
|
|
3256
3279
|
this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e).add(t);
|
|
@@ -3271,17 +3294,17 @@ class Aa {
|
|
|
3271
3294
|
class Sa extends Aa {
|
|
3272
3295
|
constructor(t) {
|
|
3273
3296
|
super();
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3297
|
+
u(this, "wsUrl");
|
|
3298
|
+
u(this, "reconnectAttempts");
|
|
3299
|
+
u(this, "debug");
|
|
3300
|
+
u(this, "jwtToken");
|
|
3301
|
+
u(this, "appId");
|
|
3302
|
+
u(this, "ws", null);
|
|
3303
|
+
u(this, "currentCharacterId", "");
|
|
3304
|
+
u(this, "currentRetryCount", 0);
|
|
3305
|
+
u(this, "isConnecting", !1);
|
|
3306
|
+
u(this, "isManuallyDisconnected", !1);
|
|
3307
|
+
u(this, "reconnectTimer", null);
|
|
3285
3308
|
this.wsUrl = t.wsUrl, this.reconnectAttempts = t.reconnectAttempts ?? 5, this.debug = t.debug ?? !1, this.jwtToken = t.jwtToken, this.appId = t.appId;
|
|
3286
3309
|
}
|
|
3287
3310
|
/**
|
|
@@ -3329,24 +3352,24 @@ class Sa extends Aa {
|
|
|
3329
3352
|
return h.error("[AnimationWebSocketClient] WebSocket not connected"), !1;
|
|
3330
3353
|
try {
|
|
3331
3354
|
const i = {
|
|
3332
|
-
type:
|
|
3355
|
+
type: be.MESSAGE_CLIENT_AUDIO_INPUT,
|
|
3333
3356
|
clientAudioInput: {
|
|
3334
3357
|
reqId: t,
|
|
3335
3358
|
// protobuf 协议中使用 reqId 字段名
|
|
3336
3359
|
audio: new Uint8Array(n),
|
|
3337
3360
|
end: a
|
|
3338
3361
|
}
|
|
3339
|
-
},
|
|
3340
|
-
We.encode(i,
|
|
3341
|
-
const
|
|
3342
|
-
return this.ws.send(
|
|
3362
|
+
}, o = new ce();
|
|
3363
|
+
We.encode(i, o);
|
|
3364
|
+
const s = o.finish();
|
|
3365
|
+
return this.ws.send(s), !0;
|
|
3343
3366
|
} catch (i) {
|
|
3344
|
-
const
|
|
3345
|
-
return h.error("[AnimationWebSocketClient] Failed to send audio data:",
|
|
3367
|
+
const o = i instanceof Error ? i.message : String(i);
|
|
3368
|
+
return h.error("[AnimationWebSocketClient] Failed to send audio data:", o), y.logEvent("character_animation_service", "warning", {
|
|
3346
3369
|
characterId: this.currentCharacterId,
|
|
3347
3370
|
event: "send_audio_failed",
|
|
3348
3371
|
conversationId: t,
|
|
3349
|
-
reason:
|
|
3372
|
+
reason: o
|
|
3350
3373
|
}), this.emit("error", i), !1;
|
|
3351
3374
|
}
|
|
3352
3375
|
}
|
|
@@ -3380,12 +3403,12 @@ class Sa extends Aa {
|
|
|
3380
3403
|
this.ws = new WebSocket(t), this.ws.onopen = () => {
|
|
3381
3404
|
this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"), n();
|
|
3382
3405
|
}, 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:",
|
|
3406
|
+
i.data instanceof ArrayBuffer ? this.handleMessage(i.data) : i.data instanceof Blob ? i.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((o) => {
|
|
3407
|
+
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", o), y.logEvent("character_animation_service", "error", {
|
|
3385
3408
|
characterId: this.currentCharacterId,
|
|
3386
3409
|
event: "decode_blob_failed",
|
|
3387
|
-
reason:
|
|
3388
|
-
}), this.emit("error",
|
|
3410
|
+
reason: o instanceof Error ? o.message : String(o)
|
|
3411
|
+
}), this.emit("error", o);
|
|
3389
3412
|
}) : h.warn("[AnimationWebSocketClient] Received non-binary data:", typeof i.data);
|
|
3390
3413
|
}, this.ws.onerror = (i) => {
|
|
3391
3414
|
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", i), y.logEvent("character_animation_service", "error", {
|
|
@@ -3417,7 +3440,7 @@ class Sa extends Aa {
|
|
|
3417
3440
|
}), this.emit("error", new Error(a.error.reason || "Server error"));
|
|
3418
3441
|
return;
|
|
3419
3442
|
}
|
|
3420
|
-
if (a.type ===
|
|
3443
|
+
if (a.type === be.MESSAGE_ERROR) {
|
|
3421
3444
|
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), y.logEvent("character_animation_service", "warning", {
|
|
3422
3445
|
characterId: this.currentCharacterId,
|
|
3423
3446
|
event: "message_error_without_payload"
|
|
@@ -3445,13 +3468,17 @@ class Sa extends Aa {
|
|
|
3445
3468
|
}
|
|
3446
3469
|
}
|
|
3447
3470
|
class ba {
|
|
3471
|
+
// 避免并发连接
|
|
3448
3472
|
constructor(e) {
|
|
3449
|
-
|
|
3450
|
-
|
|
3473
|
+
u(this, "wsClient");
|
|
3474
|
+
u(this, "dataController");
|
|
3451
3475
|
// 组合播放层
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3476
|
+
u(this, "currentConversationId", null);
|
|
3477
|
+
u(this, "audioBytesPerSecond", k.audio.sampleRate * 2);
|
|
3478
|
+
u(this, "audioMetrics", this.createAudioMetrics());
|
|
3479
|
+
u(this, "isFallbackMode", !1);
|
|
3480
|
+
// 连接超时降级模式标记
|
|
3481
|
+
u(this, "isConnecting", !1);
|
|
3455
3482
|
this.dataController = e;
|
|
3456
3483
|
const t = y.getEnvironmentConfig();
|
|
3457
3484
|
this.wsClient = new Sa({
|
|
@@ -3466,14 +3493,46 @@ class ba {
|
|
|
3466
3493
|
* 连接服务
|
|
3467
3494
|
*/
|
|
3468
3495
|
async connect(e) {
|
|
3469
|
-
|
|
3496
|
+
var o, s, l, p;
|
|
3497
|
+
if (this.isConnecting)
|
|
3498
|
+
throw h.warn("[NetworkLayer] Connection already in progress, waiting for current connection to complete"), new H("Connection already in progress", "CONNECTION_IN_PROGRESS");
|
|
3499
|
+
(s = (o = this.dataController).onConnectionState) == null || s.call(o, ee.connecting), this.isFallbackMode = !1, this.setupWebSocketListeners(), this.isConnecting = !0;
|
|
3500
|
+
const t = 15e3;
|
|
3501
|
+
let n = null;
|
|
3502
|
+
const a = this.wsClient.connect(e), i = new Promise((c) => {
|
|
3503
|
+
n = setTimeout(() => {
|
|
3504
|
+
var d, m;
|
|
3505
|
+
this.dataController.connected || (this.isFallbackMode = !0, h.warn(`[NetworkLayer] WebSocket connection timeout (${t}ms) - entering fallback mode`), y.logEvent("character_manager", "warning", {
|
|
3506
|
+
characterId: this.dataController.getAvatarId(),
|
|
3507
|
+
event: "websocket_connection_timeout_fallback",
|
|
3508
|
+
timeoutMs: t
|
|
3509
|
+
}), (m = (d = this.dataController).onConnectionState) == null || m.call(d, ee.failed)), c();
|
|
3510
|
+
}, t);
|
|
3511
|
+
});
|
|
3512
|
+
try {
|
|
3513
|
+
await Promise.race([a, i]), n && clearTimeout(n);
|
|
3514
|
+
} catch (c) {
|
|
3515
|
+
throw n && clearTimeout(n), this.isFallbackMode || (this.isFallbackMode = !0, h.warn("[NetworkLayer] WebSocket connection failed - entering fallback mode"), y.logEvent("character_manager", "warning", {
|
|
3516
|
+
characterId: this.dataController.getAvatarId(),
|
|
3517
|
+
event: "websocket_connection_failed_fallback"
|
|
3518
|
+
})), (p = (l = this.dataController).onConnectionState) == null || p.call(l, ee.failed), c;
|
|
3519
|
+
} finally {
|
|
3520
|
+
this.isConnecting = !1;
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
/**
|
|
3524
|
+
* 检查是否可以发送音频数据(包括降级模式)
|
|
3525
|
+
* @internal
|
|
3526
|
+
*/
|
|
3527
|
+
canSend() {
|
|
3528
|
+
return this.isFallbackMode || this.dataController.connected;
|
|
3470
3529
|
}
|
|
3471
3530
|
/**
|
|
3472
3531
|
* 发送音频数据到服务器
|
|
3473
3532
|
* 注意:打断逻辑由 AvatarController.send() 统一处理,这里只负责网络通信
|
|
3474
3533
|
*/
|
|
3475
3534
|
sendAudioData(e, t) {
|
|
3476
|
-
var
|
|
3535
|
+
var s, l;
|
|
3477
3536
|
this.currentConversationId || (this.currentConversationId = this.wsClient.generateConversationId(), this.resetAudioMetrics(), y.logEvent("character_manager", "info", {
|
|
3478
3537
|
characterId: this.dataController.getAvatarId(),
|
|
3479
3538
|
event: "conversation_started",
|
|
@@ -3483,8 +3542,12 @@ class ba {
|
|
|
3483
3542
|
let a = !1;
|
|
3484
3543
|
n.startTimestamp === 0 && (n.startTimestamp = Date.now(), a = !0), n.accumulatedBytes += e.byteLength;
|
|
3485
3544
|
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.
|
|
3545
|
+
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) {
|
|
3546
|
+
this.currentConversationId && (h.warn("[NetworkLayer] Fallback mode: skipping WebSocket send, triggering audio-only mode"), this.dataController.yieldFramesData([], this.currentConversationId));
|
|
3547
|
+
return;
|
|
3548
|
+
}
|
|
3549
|
+
if (!this.wsClient.sendAudioData(this.currentConversationId, e, t)) {
|
|
3550
|
+
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
3551
|
characterId: this.dataController.getAvatarId(),
|
|
3489
3552
|
event: "send_audio_failed",
|
|
3490
3553
|
conversationId: this.currentConversationId
|
|
@@ -3497,7 +3560,7 @@ class ba {
|
|
|
3497
3560
|
* 断开连接
|
|
3498
3561
|
*/
|
|
3499
3562
|
disconnect() {
|
|
3500
|
-
this.wsClient.removeAllListeners(), this.wsClient.disconnect(), this.currentConversationId = null;
|
|
3563
|
+
this.isFallbackMode = !1, this.isConnecting = !1, this.wsClient.removeAllListeners(), this.wsClient.disconnect(), this.currentConversationId = null;
|
|
3501
3564
|
}
|
|
3502
3565
|
/**
|
|
3503
3566
|
* 获取当前会话ID
|
|
@@ -3518,13 +3581,13 @@ class ba {
|
|
|
3518
3581
|
setupWebSocketListeners() {
|
|
3519
3582
|
this.wsClient.removeAllListeners(), this.wsClient.on("connected", () => {
|
|
3520
3583
|
var e, t;
|
|
3521
|
-
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3584
|
+
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
3585
|
characterId: this.dataController.getAvatarId(),
|
|
3523
3586
|
event: "connected"
|
|
3524
3587
|
});
|
|
3525
3588
|
}), this.wsClient.on("disconnected", () => {
|
|
3526
3589
|
var e, t;
|
|
3527
|
-
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3590
|
+
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e, ee.disconnected), y.logEvent("character_animation_service", "warning", {
|
|
3528
3591
|
characterId: this.dataController.getAvatarId(),
|
|
3529
3592
|
event: "disconnected"
|
|
3530
3593
|
});
|
|
@@ -3534,13 +3597,13 @@ class ba {
|
|
|
3534
3597
|
event: "reconnecting"
|
|
3535
3598
|
});
|
|
3536
3599
|
}), this.wsClient.on("error", (e) => {
|
|
3537
|
-
var n, a, i,
|
|
3600
|
+
var n, a, i, o;
|
|
3538
3601
|
const t = e instanceof Error ? e.message : String(e);
|
|
3539
3602
|
h.error("[NetworkLayer] WebSocket error:", t), y.logEvent("character_animation_service", "error", {
|
|
3540
3603
|
characterId: this.dataController.getAvatarId(),
|
|
3541
3604
|
event: "websocket_error",
|
|
3542
3605
|
reason: t
|
|
3543
|
-
}), (a = (n = this.dataController).onConnectionState) == null || a.call(n,
|
|
3606
|
+
}), (a = (n = this.dataController).onConnectionState) == null || a.call(n, ee.failed), (o = (i = this.dataController).onError) == null || o.call(i, e);
|
|
3544
3607
|
}), this.wsClient.on("message", (e) => {
|
|
3545
3608
|
this.handleMessage(e);
|
|
3546
3609
|
});
|
|
@@ -3551,10 +3614,10 @@ class ba {
|
|
|
3551
3614
|
handleMessage(e) {
|
|
3552
3615
|
try {
|
|
3553
3616
|
switch (e.type) {
|
|
3554
|
-
case
|
|
3617
|
+
case be.MESSAGE_SERVER_RESPONSE_ANIMATION:
|
|
3555
3618
|
this.handleAnimationMessage(e);
|
|
3556
3619
|
break;
|
|
3557
|
-
case
|
|
3620
|
+
case be.MESSAGE_ERROR:
|
|
3558
3621
|
this.handleErrorMessage(e);
|
|
3559
3622
|
break;
|
|
3560
3623
|
}
|
|
@@ -3599,7 +3662,7 @@ class ba {
|
|
|
3599
3662
|
* 处理错误消息
|
|
3600
3663
|
*/
|
|
3601
3664
|
handleErrorMessage(e) {
|
|
3602
|
-
var a, i,
|
|
3665
|
+
var a, i, o, s;
|
|
3603
3666
|
if (!e.error) {
|
|
3604
3667
|
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
3668
|
characterId: this.dataController.getAvatarId(),
|
|
@@ -3620,7 +3683,7 @@ class ba {
|
|
|
3620
3683
|
characterId: this.dataController.getAvatarId(),
|
|
3621
3684
|
conversationId: t,
|
|
3622
3685
|
reason: e.error.reason
|
|
3623
|
-
}), (
|
|
3686
|
+
}), (s = (o = this.dataController).onError) == null || s.call(o, new H(
|
|
3624
3687
|
e.error.reason || "Server error occurred",
|
|
3625
3688
|
((i = e.error.code) == null ? void 0 : i.toString()) || "SERVER_ERROR"
|
|
3626
3689
|
)), 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 +3726,43 @@ class Ca {
|
|
|
3663
3726
|
// 音频独立播放模式标志
|
|
3664
3727
|
constructor(e, t) {
|
|
3665
3728
|
// ========== Configuration and Composition ==========
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3729
|
+
u(this, "networkLayer");
|
|
3730
|
+
u(this, "playbackMode");
|
|
3731
|
+
u(this, "avatar");
|
|
3669
3732
|
// ========== Player Management ==========
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3733
|
+
u(this, "animationPlayer", null);
|
|
3734
|
+
u(this, "currentKeyframes", []);
|
|
3735
|
+
u(this, "pendingAudioChunks", []);
|
|
3736
|
+
u(this, "isPlaying", !1);
|
|
3674
3737
|
// ========== State Management ==========
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
// ========== Conversation ID Management (for
|
|
3678
|
-
|
|
3679
|
-
|
|
3738
|
+
u(this, "isConnected", !1);
|
|
3739
|
+
u(this, "currentState", x.idle);
|
|
3740
|
+
// ========== Conversation ID Management (for host mode) ==========
|
|
3741
|
+
u(this, "currentConversationId", null);
|
|
3742
|
+
u(this, "reqEnd", !1);
|
|
3680
3743
|
// ========== Event System ==========
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3744
|
+
u(this, "onConnectionState", null);
|
|
3745
|
+
u(this, "onConversationState", null);
|
|
3746
|
+
u(this, "onError", null);
|
|
3747
|
+
u(this, "eventListeners", /* @__PURE__ */ new Map());
|
|
3685
3748
|
// ========== Callbacks ==========
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
d(this, "characterHandle", null);
|
|
3749
|
+
u(this, "renderCallback");
|
|
3750
|
+
u(this, "characterHandle", null);
|
|
3689
3751
|
// Character handle for multi-character support
|
|
3690
3752
|
// ========== Playback Loop ==========
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3753
|
+
u(this, "playbackLoopId", null);
|
|
3754
|
+
u(this, "lastRenderedFrameIndex", -1);
|
|
3755
|
+
u(this, "keyframesOffset", 0);
|
|
3694
3756
|
// Offset to track how many frames were removed from the beginning
|
|
3695
|
-
|
|
3757
|
+
u(this, "MAX_KEYFRAMES", 5e3);
|
|
3696
3758
|
// Maximum keyframes to keep in memory during playback
|
|
3697
|
-
|
|
3759
|
+
u(this, "KEYFRAMES_CLEANUP_THRESHOLD", 3e3);
|
|
3698
3760
|
// Cleanup threshold (keep some buffer)
|
|
3699
|
-
|
|
3761
|
+
u(this, "MAX_PENDING_AUDIO_CHUNKS", 100);
|
|
3700
3762
|
// Maximum pending audio chunks to prevent memory leak
|
|
3701
3763
|
// ========== Audio Only Mode ==========
|
|
3702
|
-
|
|
3703
|
-
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ??
|
|
3764
|
+
u(this, "isAudioOnlyMode", !1);
|
|
3765
|
+
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? we.sdk, this.playbackMode === we.sdk && (this.networkLayer = new ba(this));
|
|
3704
3766
|
}
|
|
3705
3767
|
// ========== Internal Accessors (for NetworkLayer and AvatarView) ==========
|
|
3706
3768
|
/**
|
|
@@ -3738,6 +3800,23 @@ class Ca {
|
|
|
3738
3800
|
get state() {
|
|
3739
3801
|
return this.currentState;
|
|
3740
3802
|
}
|
|
3803
|
+
/**
|
|
3804
|
+
* 将内部 AvatarState 映射到外部 ConversationState
|
|
3805
|
+
* @internal
|
|
3806
|
+
*/
|
|
3807
|
+
mapToConversationState(e) {
|
|
3808
|
+
switch (e) {
|
|
3809
|
+
case x.idle:
|
|
3810
|
+
return re.idle;
|
|
3811
|
+
case x.active:
|
|
3812
|
+
return this.isPlaying ? re.playing : re.idle;
|
|
3813
|
+
case x.playing:
|
|
3814
|
+
case x.paused:
|
|
3815
|
+
return re.playing;
|
|
3816
|
+
default:
|
|
3817
|
+
return re.idle;
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3741
3820
|
/**
|
|
3742
3821
|
* Get animation player instance
|
|
3743
3822
|
* @internal
|
|
@@ -3753,18 +3832,18 @@ class Ca {
|
|
|
3753
3832
|
getCurrentConversationId() {
|
|
3754
3833
|
return this.getEffectiveConversationId();
|
|
3755
3834
|
}
|
|
3756
|
-
// ==========
|
|
3835
|
+
// ========== SDK Mode Interface ==========
|
|
3757
3836
|
/**
|
|
3758
|
-
* Start service (
|
|
3837
|
+
* Start service (SDK mode only)
|
|
3759
3838
|
*/
|
|
3760
3839
|
async start() {
|
|
3761
3840
|
if (!this.networkLayer)
|
|
3762
|
-
throw new
|
|
3763
|
-
"Network layer not available. Use
|
|
3841
|
+
throw new H(
|
|
3842
|
+
"Network layer not available. Use SDK mode.",
|
|
3764
3843
|
"NETWORK_LAYER_NOT_AVAILABLE"
|
|
3765
3844
|
);
|
|
3766
3845
|
if (!this.animationPlayer) {
|
|
3767
|
-
this.animationPlayer = new
|
|
3846
|
+
this.animationPlayer = new oe();
|
|
3768
3847
|
try {
|
|
3769
3848
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
3770
3849
|
} catch (e) {
|
|
@@ -3779,46 +3858,48 @@ class Ca {
|
|
|
3779
3858
|
await this.networkLayer.connect(this.avatar.id);
|
|
3780
3859
|
}
|
|
3781
3860
|
/**
|
|
3782
|
-
* Send audio to server (
|
|
3861
|
+
* Send audio to server (SDK mode only)
|
|
3783
3862
|
* Also cache to data layer for playback
|
|
3784
3863
|
* @returns conversationId - Conversation ID for this audio session
|
|
3785
3864
|
*/
|
|
3786
3865
|
send(e, t = !1) {
|
|
3787
|
-
var a, i;
|
|
3788
|
-
if (!this.networkLayer
|
|
3789
|
-
return (a = this.onError) == null || a.call(this, new
|
|
3866
|
+
var a, i, o;
|
|
3867
|
+
if (!this.networkLayer)
|
|
3868
|
+
return (a = this.onError) == null || a.call(this, new H("Network layer not available", "NETWORK_LAYER_NOT_AVAILABLE")), null;
|
|
3869
|
+
if (!this.networkLayer.canSend())
|
|
3870
|
+
return (i = this.onError) == null || i.call(this, new H("Service not connected", "NOT_CONNECTED")), y.logEvent("character_manager", "warning", {
|
|
3790
3871
|
characterId: this.avatar.id,
|
|
3791
3872
|
event: "send_not_connected"
|
|
3792
3873
|
}), null;
|
|
3793
3874
|
const n = this.networkLayer.getCurrentConversationId();
|
|
3794
|
-
return this.reqEnd && this.isPlaying && n && this.interrupt(), this.networkLayer.sendAudioData(e, t), t && (this.reqEnd = !0),
|
|
3875
|
+
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.onConversationState) == null || o.call(this, this.mapToConversationState(x.active)), this.networkLayer.getCurrentConversationId();
|
|
3795
3876
|
}
|
|
3796
3877
|
/**
|
|
3797
|
-
* Close service (
|
|
3878
|
+
* Close service (SDK mode only)
|
|
3798
3879
|
*/
|
|
3799
3880
|
close() {
|
|
3800
3881
|
var e;
|
|
3801
|
-
(this.isPlaying || this.currentState ===
|
|
3882
|
+
(this.isPlaying || this.currentState === x.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
3883
|
}
|
|
3803
|
-
// ==========
|
|
3884
|
+
// ========== Host Mode Interface ==========
|
|
3804
3885
|
/**
|
|
3805
|
-
* Playback existing audio and animation data (
|
|
3886
|
+
* Playback existing audio and animation data (host mode)
|
|
3806
3887
|
* Starts a new conversation by generating a new conversation ID and interrupting any existing conversation
|
|
3807
3888
|
* @param initialAudioChunks - Existing audio chunks to playback
|
|
3808
3889
|
* @param initialKeyframes - Existing animation keyframes to playback
|
|
3809
3890
|
* @returns conversationId - New conversation ID for this conversation session
|
|
3810
3891
|
*/
|
|
3811
3892
|
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
|
|
3893
|
+
if ((this.isPlaying || this.currentConversationId) && this.interrupt(), this.currentConversationId = this.generateAndLogNewConversationId(), this.reqEnd = !1, this.clearPlaybackData(), this.animationPlayer || (this.animationPlayer = new oe()), 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
3894
|
characterId: this.avatar.id,
|
|
3814
3895
|
event: "empty_animation_data_audio_only_fallback",
|
|
3815
3896
|
conversationId: this.currentConversationId
|
|
3816
3897
|
}), this.isAudioOnlyMode = !0), this.pendingAudioChunks.length === 0)
|
|
3817
|
-
throw new
|
|
3898
|
+
throw new H("No audio chunks to play", "NO_AUDIO");
|
|
3818
3899
|
return this.isAudioOnlyMode ? await this.startAudioOnlyPlayback() : await this.startStreamingPlayback(), this.currentConversationId;
|
|
3819
3900
|
}
|
|
3820
3901
|
/**
|
|
3821
|
-
* Send audio data (
|
|
3902
|
+
* Send audio data (host mode)
|
|
3822
3903
|
* Stream additional audio data after playback()
|
|
3823
3904
|
* @returns conversationId - Conversation ID for this audio session
|
|
3824
3905
|
*/
|
|
@@ -3828,15 +3909,15 @@ class Ca {
|
|
|
3828
3909
|
this.animationPlayer.addAudioChunk(e, t);
|
|
3829
3910
|
else if (e.length > 0 || t) {
|
|
3830
3911
|
if (this.pendingAudioChunks.length >= this.MAX_PENDING_AUDIO_CHUNKS) {
|
|
3831
|
-
const i = this.pendingAudioChunks.findIndex((
|
|
3912
|
+
const i = this.pendingAudioChunks.findIndex((o) => o.isLast);
|
|
3832
3913
|
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
3914
|
}
|
|
3834
|
-
this.pendingAudioChunks.push({ data: e, isLast: t }), (a = this.
|
|
3915
|
+
this.pendingAudioChunks.push({ data: e, isLast: t }), (a = this.onConversationState) == null || a.call(this, this.mapToConversationState(x.active));
|
|
3835
3916
|
}
|
|
3836
3917
|
return this.currentConversationId;
|
|
3837
3918
|
}
|
|
3838
3919
|
/**
|
|
3839
|
-
* Send animation keyframes (
|
|
3920
|
+
* Send animation keyframes (host mode or SDK mode)
|
|
3840
3921
|
* Stream additional animation data after playback()
|
|
3841
3922
|
* @param keyframes - Animation keyframes to send
|
|
3842
3923
|
* @param conversationId - Conversation ID (required). If conversationId doesn't match current conversationId, keyframes will be discarded.
|
|
@@ -3879,7 +3960,7 @@ class Ca {
|
|
|
3879
3960
|
}
|
|
3880
3961
|
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
3962
|
var i;
|
|
3882
|
-
h.error("[AvatarController] Failed to auto-start playback:", a), (i = this.onError) == null || i.call(this, new
|
|
3963
|
+
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
3964
|
});
|
|
3884
3965
|
}
|
|
3885
3966
|
// ========== Common Interface ==========
|
|
@@ -3889,7 +3970,7 @@ class Ca {
|
|
|
3889
3970
|
*/
|
|
3890
3971
|
pause() {
|
|
3891
3972
|
var e, t, n;
|
|
3892
|
-
!this.isPlaying || this.currentState ===
|
|
3973
|
+
!this.isPlaying || this.currentState === x.paused || (h.log("[AvatarController] Pausing playback"), (e = this.animationPlayer) == null || e.pause(), this.stopPlaybackLoop(), this.currentState = x.paused, (t = this.onConversationState) == null || t.call(this, this.mapToConversationState(x.paused)), h.log("[AvatarController] Playback paused"), y.logEvent("character_player", "info", {
|
|
3893
3974
|
characterId: this.avatar.id,
|
|
3894
3975
|
event: "playback_paused",
|
|
3895
3976
|
conversationId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentConversationId()) || void 0
|
|
@@ -3902,7 +3983,7 @@ class Ca {
|
|
|
3902
3983
|
*/
|
|
3903
3984
|
async resume() {
|
|
3904
3985
|
var e, t, n;
|
|
3905
|
-
!this.isPlaying || this.currentState !==
|
|
3986
|
+
!this.isPlaying || this.currentState !== x.paused || (h.log("[AvatarController] Resuming playback"), await ((e = this.animationPlayer) == null ? void 0 : e.resume()), this.startPlaybackLoop(), this.currentState = x.playing, (t = this.onConversationState) == null || t.call(this, this.mapToConversationState(x.playing)), h.log("[AvatarController] Playback resumed"), y.logEvent("character_player", "info", {
|
|
3906
3987
|
characterId: this.avatar.id,
|
|
3907
3988
|
event: "playback_resumed",
|
|
3908
3989
|
conversationId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentConversationId()) || void 0
|
|
@@ -3913,7 +3994,7 @@ class Ca {
|
|
|
3913
3994
|
*/
|
|
3914
3995
|
interrupt() {
|
|
3915
3996
|
var e;
|
|
3916
|
-
this.currentState ===
|
|
3997
|
+
this.currentState === x.paused && ((e = this.animationPlayer) == null || e.resume().catch(() => {
|
|
3917
3998
|
})), this.stopPlayback(), this.emit("interrupt"), this.clearPlaybackData(), this.resetConversationIdState(), this.isAudioOnlyMode = !1;
|
|
3918
3999
|
}
|
|
3919
4000
|
/**
|
|
@@ -3921,7 +4002,7 @@ class Ca {
|
|
|
3921
4002
|
*/
|
|
3922
4003
|
clear() {
|
|
3923
4004
|
var e, t;
|
|
3924
|
-
this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.clearPlaybackData(), this.isConnected = !1, this.currentState =
|
|
4005
|
+
this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.clearPlaybackData(), this.isConnected = !1, this.currentState = x.idle, (t = this.onConversationState) == null || t.call(this, this.mapToConversationState(x.idle)), this.networkLayer || (this.currentConversationId = null), this.reqEnd = !1;
|
|
3925
4006
|
}
|
|
3926
4007
|
/**
|
|
3927
4008
|
* Dispose controller, clean up all callbacks to avoid memory leaks
|
|
@@ -3929,7 +4010,7 @@ class Ca {
|
|
|
3929
4010
|
* @internal
|
|
3930
4011
|
*/
|
|
3931
4012
|
dispose() {
|
|
3932
|
-
this.onConnectionState = null, this.
|
|
4013
|
+
this.onConnectionState = null, this.onConversationState = null, this.onError = null, this.renderCallback = void 0, this.eventListeners.clear();
|
|
3933
4014
|
}
|
|
3934
4015
|
// ========== Internal Helper Methods ==========
|
|
3935
4016
|
/**
|
|
@@ -3959,12 +4040,12 @@ class Ca {
|
|
|
3959
4040
|
this.networkLayer ? this.networkLayer.resetConversationId() : this.currentConversationId = null, this.reqEnd = !1, this.isAudioOnlyMode = !1;
|
|
3960
4041
|
}
|
|
3961
4042
|
/**
|
|
3962
|
-
* Get effective conversation ID (handles both
|
|
4043
|
+
* Get effective conversation ID (handles both SDK and host modes)
|
|
3963
4044
|
* @private
|
|
3964
4045
|
*/
|
|
3965
4046
|
getEffectiveConversationId() {
|
|
3966
4047
|
var e;
|
|
3967
|
-
return this.playbackMode ===
|
|
4048
|
+
return this.playbackMode === we.sdk ? ((e = this.networkLayer) == null ? void 0 : e.getCurrentConversationId()) || null : this.currentConversationId;
|
|
3968
4049
|
}
|
|
3969
4050
|
// ========== Internal Methods (for NetworkLayer and AvatarView use) ==========
|
|
3970
4051
|
/**
|
|
@@ -3981,13 +4062,6 @@ class Ca {
|
|
|
3981
4062
|
setRenderCallback(e, t) {
|
|
3982
4063
|
this.renderCallback = e, t !== void 0 && (this.characterHandle = t);
|
|
3983
4064
|
}
|
|
3984
|
-
/**
|
|
3985
|
-
* Set transition complete callback (called by AvatarView)
|
|
3986
|
-
* @internal
|
|
3987
|
-
*/
|
|
3988
|
-
setTransitionCompleteCallback(e) {
|
|
3989
|
-
this.transitionCompleteCallback = e;
|
|
3990
|
-
}
|
|
3991
4065
|
/**
|
|
3992
4066
|
* Transition complete notification (called by AvatarView)
|
|
3993
4067
|
* @internal
|
|
@@ -3997,6 +4071,27 @@ class Ca {
|
|
|
3997
4071
|
const e = (t = this.animationPlayer) == null ? void 0 : t.getStreamingPlayer();
|
|
3998
4072
|
e && e.play();
|
|
3999
4073
|
}
|
|
4074
|
+
/**
|
|
4075
|
+
* 设置音频播放音量
|
|
4076
|
+
* 注意:这仅控制数字人音频播放器的音量,不影响系统音量
|
|
4077
|
+
* @param volume 音量值,范围 0.0 到 1.0(0.0 为静音,1.0 为最大音量)
|
|
4078
|
+
*/
|
|
4079
|
+
setVolume(e) {
|
|
4080
|
+
var t;
|
|
4081
|
+
(e < 0 || e > 1) && (h.warn(`[AvatarController] Volume out of range: ${e}, clamping to [0, 1]`), e = Math.max(0, Math.min(1, e))), (t = this.animationPlayer) == null || t.setVolume(e), y.logEvent("character_player", "info", {
|
|
4082
|
+
characterId: this.avatar.id,
|
|
4083
|
+
event: "volume_changed",
|
|
4084
|
+
volume: e
|
|
4085
|
+
});
|
|
4086
|
+
}
|
|
4087
|
+
/**
|
|
4088
|
+
* 获取当前音频播放音量
|
|
4089
|
+
* @returns 当前音量值 (0.0 - 1.0)
|
|
4090
|
+
*/
|
|
4091
|
+
getVolume() {
|
|
4092
|
+
var e;
|
|
4093
|
+
return ((e = this.animationPlayer) == null ? void 0 : e.getVolume()) ?? 1;
|
|
4094
|
+
}
|
|
4000
4095
|
/**
|
|
4001
4096
|
* Provide interface for AvatarView to register internal events
|
|
4002
4097
|
* @internal
|
|
@@ -4010,7 +4105,7 @@ class Ca {
|
|
|
4010
4105
|
*/
|
|
4011
4106
|
async startStreamingPlaybackInternal() {
|
|
4012
4107
|
var e, t, n;
|
|
4013
|
-
if (this.animationPlayer || (this.animationPlayer = new
|
|
4108
|
+
if (this.animationPlayer || (this.animationPlayer = new oe()), !this.animationPlayer.isStreamingReady())
|
|
4014
4109
|
try {
|
|
4015
4110
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
4016
4111
|
} catch (a) {
|
|
@@ -4027,22 +4122,22 @@ class Ca {
|
|
|
4027
4122
|
}
|
|
4028
4123
|
try {
|
|
4029
4124
|
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
4030
|
-
var i,
|
|
4031
|
-
this.isPlaying = !1, this.currentState =
|
|
4125
|
+
var i, o;
|
|
4126
|
+
this.isPlaying = !1, this.currentState = x.idle, (i = this.onConversationState) == null || i.call(this, this.mapToConversationState(x.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
4127
|
characterId: this.avatar.id,
|
|
4033
4128
|
event: "playback_ended",
|
|
4034
|
-
conversationId: ((
|
|
4129
|
+
conversationId: ((o = this.networkLayer) == null ? void 0 : o.getCurrentConversationId()) || void 0
|
|
4035
4130
|
});
|
|
4036
4131
|
}), this.emit("startRendering");
|
|
4037
4132
|
const a = this.animationPlayer.getStreamingPlayer();
|
|
4038
|
-
a && a.setAutoStart(!1), a && await a.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState =
|
|
4133
|
+
a && a.setAutoStart(!1), a && await a.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = x.playing, (e = this.onConversationState) == null || e.call(this, this.mapToConversationState(x.playing)), this.startPlaybackLoop(), y.logEvent("character_player", "info", {
|
|
4039
4134
|
characterId: this.avatar.id,
|
|
4040
4135
|
event: "playback_started",
|
|
4041
4136
|
conversationId: ((t = this.networkLayer) == null ? void 0 : t.getCurrentConversationId()) || void 0
|
|
4042
4137
|
});
|
|
4043
4138
|
} catch (a) {
|
|
4044
4139
|
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
|
|
4140
|
+
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
4141
|
}
|
|
4047
4142
|
}
|
|
4048
4143
|
/**
|
|
@@ -4052,7 +4147,7 @@ class Ca {
|
|
|
4052
4147
|
if (this.playbackLoopId)
|
|
4053
4148
|
return;
|
|
4054
4149
|
const e = k.animation.fps, t = async () => {
|
|
4055
|
-
if (!this.isPlaying || this.currentState ===
|
|
4150
|
+
if (!this.isPlaying || this.currentState === x.paused || !this.animationPlayer) {
|
|
4056
4151
|
this.playbackLoopId = null;
|
|
4057
4152
|
return;
|
|
4058
4153
|
}
|
|
@@ -4070,13 +4165,13 @@ class Ca {
|
|
|
4070
4165
|
return;
|
|
4071
4166
|
}
|
|
4072
4167
|
if (this.lastRenderedFrameIndex = a, this.currentKeyframes.length > this.MAX_KEYFRAMES) {
|
|
4073
|
-
const
|
|
4074
|
-
|
|
4168
|
+
const o = this.KEYFRAMES_CLEANUP_THRESHOLD, s = a - o;
|
|
4169
|
+
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
4170
|
}
|
|
4076
4171
|
if (i >= 0 && i < this.currentKeyframes.length) {
|
|
4077
|
-
const
|
|
4172
|
+
const o = this.currentKeyframes[i], s = zt(o), l = y.getAvatarCore();
|
|
4078
4173
|
if (l) {
|
|
4079
|
-
const p = await l.computeFrameFlatFromParams(
|
|
4174
|
+
const p = await l.computeFrameFlatFromParams(s, this.characterHandle ?? void 0);
|
|
4080
4175
|
p && this.renderCallback && this.renderCallback(p, a);
|
|
4081
4176
|
}
|
|
4082
4177
|
}
|
|
@@ -4112,7 +4207,7 @@ class Ca {
|
|
|
4112
4207
|
*/
|
|
4113
4208
|
async startAudioOnlyPlayback() {
|
|
4114
4209
|
var e, t;
|
|
4115
|
-
if (this.animationPlayer || (this.animationPlayer = new
|
|
4210
|
+
if (this.animationPlayer || (this.animationPlayer = new oe()), !this.animationPlayer.isStreamingReady())
|
|
4116
4211
|
try {
|
|
4117
4212
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
4118
4213
|
} catch (n) {
|
|
@@ -4126,21 +4221,21 @@ class Ca {
|
|
|
4126
4221
|
try {
|
|
4127
4222
|
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
4128
4223
|
var a;
|
|
4129
|
-
this.isPlaying = !1, this.currentState =
|
|
4224
|
+
this.isPlaying = !1, this.currentState = x.idle, (a = this.onConversationState) == null || a.call(this, this.mapToConversationState(x.idle)), this.isAudioOnlyMode = !1, this.clearPlaybackData(), this.resetConversationIdState(), y.logEvent("character_player", "info", {
|
|
4130
4225
|
characterId: this.avatar.id,
|
|
4131
4226
|
event: "audio_only_playback_ended",
|
|
4132
4227
|
conversationId: this.getEffectiveConversationId() || void 0
|
|
4133
4228
|
});
|
|
4134
4229
|
});
|
|
4135
4230
|
const n = this.animationPlayer.getStreamingPlayer();
|
|
4136
|
-
n && n.setAutoStart(!0), n && await n.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState =
|
|
4231
|
+
n && n.setAutoStart(!0), n && await n.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = x.playing, (e = this.onConversationState) == null || e.call(this, this.mapToConversationState(x.playing)), this.startAudioMonitoringLoop(), y.logEvent("character_player", "info", {
|
|
4137
4232
|
characterId: this.avatar.id,
|
|
4138
4233
|
event: "audio_only_playback_started",
|
|
4139
4234
|
conversationId: this.getEffectiveConversationId() || void 0
|
|
4140
4235
|
});
|
|
4141
4236
|
} catch (n) {
|
|
4142
4237
|
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
|
|
4238
|
+
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
4239
|
}
|
|
4145
4240
|
}
|
|
4146
4241
|
/**
|
|
@@ -4171,7 +4266,7 @@ class Ca {
|
|
|
4171
4266
|
const t = this.animationPlayer.getStreamingPlayer();
|
|
4172
4267
|
t == null || t.stop();
|
|
4173
4268
|
}
|
|
4174
|
-
this.emit("stopRendering"), this.isPlaying = !1, this.currentState =
|
|
4269
|
+
this.emit("stopRendering"), this.isPlaying = !1, this.currentState = x.idle, (e = this.onConversationState) == null || e.call(this, this.mapToConversationState(x.idle));
|
|
4175
4270
|
}
|
|
4176
4271
|
/**
|
|
4177
4272
|
* Clean up players
|
|
@@ -4183,7 +4278,7 @@ class Ca {
|
|
|
4183
4278
|
* Add audio chunk to buffer
|
|
4184
4279
|
*/
|
|
4185
4280
|
addAudioChunkToBuffer(e, t) {
|
|
4186
|
-
if (this.animationPlayer || (this.animationPlayer = new
|
|
4281
|
+
if (this.animationPlayer || (this.animationPlayer = new oe()), this.isPlaying && this.animationPlayer.isStreamingReady())
|
|
4187
4282
|
this.animationPlayer.addAudioChunk(e, t);
|
|
4188
4283
|
else {
|
|
4189
4284
|
if (this.pendingAudioChunks.length >= this.MAX_PENDING_AUDIO_CHUNKS) {
|
|
@@ -4238,21 +4333,21 @@ async function _a(r) {
|
|
|
4238
4333
|
throw new Error(`[downloadResource] ${r} → ${t}`);
|
|
4239
4334
|
}
|
|
4240
4335
|
}
|
|
4241
|
-
const Pa = 50,
|
|
4242
|
-
async function
|
|
4243
|
-
const e =
|
|
4336
|
+
const Pa = 50, ae = /* @__PURE__ */ new Map();
|
|
4337
|
+
async function Ue(r) {
|
|
4338
|
+
const e = ae.get(r);
|
|
4244
4339
|
if (e)
|
|
4245
|
-
return
|
|
4340
|
+
return ae.delete(r), ae.set(r, e), e;
|
|
4246
4341
|
const t = await _a(r);
|
|
4247
|
-
if (
|
|
4248
|
-
const n =
|
|
4249
|
-
n &&
|
|
4342
|
+
if (ae.size >= Pa) {
|
|
4343
|
+
const n = ae.keys().next().value;
|
|
4344
|
+
n && ae.delete(n);
|
|
4250
4345
|
}
|
|
4251
|
-
return
|
|
4346
|
+
return ae.set(r, t), t;
|
|
4252
4347
|
}
|
|
4253
4348
|
class ir {
|
|
4254
4349
|
constructor(e = "/") {
|
|
4255
|
-
|
|
4350
|
+
u(this, "baseAssetsPath");
|
|
4256
4351
|
this.baseAssetsPath = e;
|
|
4257
4352
|
}
|
|
4258
4353
|
/**
|
|
@@ -4260,7 +4355,7 @@ class ir {
|
|
|
4260
4355
|
* Falls back to global CDN config if not provided by API
|
|
4261
4356
|
*/
|
|
4262
4357
|
async loadTemplateResources(e, t = null) {
|
|
4263
|
-
var c,
|
|
4358
|
+
var c, d, m, v;
|
|
4264
4359
|
if (!(e && Object.keys(e).length > 0))
|
|
4265
4360
|
return h.log("⚠️ FLAME resources not provided in CharacterMeta, using global CDN config"), this.loadGlobalFlameResources(t);
|
|
4266
4361
|
h.log("✅ Using FLAME resources from CharacterMeta API");
|
|
@@ -4270,7 +4365,7 @@ class ir {
|
|
|
4270
4365
|
resourceName: "model.pb"
|
|
4271
4366
|
},
|
|
4272
4367
|
flameTemplate: {
|
|
4273
|
-
url: (
|
|
4368
|
+
url: (d = e.flameTemplate) == null ? void 0 : d.remote,
|
|
4274
4369
|
resourceName: "flame_template.pb"
|
|
4275
4370
|
},
|
|
4276
4371
|
teethPb: {
|
|
@@ -4282,21 +4377,21 @@ class ir {
|
|
|
4282
4377
|
resourceName: "teeth.npz"
|
|
4283
4378
|
}
|
|
4284
4379
|
}, i = Object.keys(a).length;
|
|
4285
|
-
let
|
|
4286
|
-
const
|
|
4287
|
-
t && (A &&
|
|
4380
|
+
let o = 0;
|
|
4381
|
+
const s = (S, A) => {
|
|
4382
|
+
t && (A && o++, t({
|
|
4288
4383
|
stage: "template",
|
|
4289
4384
|
filename: S,
|
|
4290
|
-
loaded:
|
|
4385
|
+
loaded: o,
|
|
4291
4386
|
total: i,
|
|
4292
|
-
progress: Math.round(
|
|
4387
|
+
progress: Math.round(o / i * 100)
|
|
4293
4388
|
}));
|
|
4294
4389
|
}, l = {}, p = Object.entries(a).map(async ([S, { url: A, resourceName: b }]) => {
|
|
4295
4390
|
if (!A)
|
|
4296
4391
|
throw new Error(`[loadTemplateResources] Missing CDN URL for ${S} (${b})`);
|
|
4297
|
-
|
|
4298
|
-
const E = await
|
|
4299
|
-
h.log(`✅ ${S} loaded: ${E.byteLength} bytes`), l[S] = E,
|
|
4392
|
+
s(b, !1), h.log(`📥 Loading ${S} from API CDN: ${A}`);
|
|
4393
|
+
const E = await Ue(A);
|
|
4394
|
+
h.log(`✅ ${S} loaded: ${E.byteLength} bytes`), l[S] = E, s(b, !0);
|
|
4300
4395
|
});
|
|
4301
4396
|
return await Promise.all(p), l;
|
|
4302
4397
|
}
|
|
@@ -4324,19 +4419,19 @@ class ir {
|
|
|
4324
4419
|
resourceName: n.teethNpz
|
|
4325
4420
|
}
|
|
4326
4421
|
}, i = Object.keys(a).length;
|
|
4327
|
-
let
|
|
4328
|
-
const
|
|
4329
|
-
e && (
|
|
4422
|
+
let o = 0;
|
|
4423
|
+
const s = (c, d) => {
|
|
4424
|
+
e && (d && o++, e({
|
|
4330
4425
|
stage: "template",
|
|
4331
4426
|
filename: c,
|
|
4332
|
-
loaded:
|
|
4427
|
+
loaded: o,
|
|
4333
4428
|
total: i,
|
|
4334
|
-
progress: Math.round(
|
|
4429
|
+
progress: Math.round(o / i * 100)
|
|
4335
4430
|
}));
|
|
4336
|
-
}, l = {}, p = Object.entries(a).map(async ([c, { url:
|
|
4337
|
-
|
|
4338
|
-
const v = await
|
|
4339
|
-
h.log(`✅ ${c} loaded: ${v.byteLength} bytes`), l[c] = v,
|
|
4431
|
+
}, l = {}, p = Object.entries(a).map(async ([c, { url: d, resourceName: m }]) => {
|
|
4432
|
+
s(m, !1), h.log(`📥 Loading ${c} from global CDN: ${d}`);
|
|
4433
|
+
const v = await Ue(d);
|
|
4434
|
+
h.log(`✅ ${c} loaded: ${v.byteLength} bytes`), l[c] = v, s(m, !0);
|
|
4340
4435
|
});
|
|
4341
4436
|
return await Promise.all(p), l;
|
|
4342
4437
|
}
|
|
@@ -4352,8 +4447,8 @@ class ir {
|
|
|
4352
4447
|
}
|
|
4353
4448
|
try {
|
|
4354
4449
|
h.log(`📥 Loading camera info from: ${t}`);
|
|
4355
|
-
const i = {},
|
|
4356
|
-
|
|
4450
|
+
const i = {}, o = y.appId, s = y.sessionToken;
|
|
4451
|
+
o && (i["X-App-Id"] = o), s && (i.Authorization = `Bearer ${s}`);
|
|
4357
4452
|
const l = await fetch(t, {
|
|
4358
4453
|
headers: Object.keys(i).length > 0 ? i : void 0
|
|
4359
4454
|
});
|
|
@@ -4370,8 +4465,8 @@ class ir {
|
|
|
4370
4465
|
* Load character data from CharacterMeta (iOS compatible)
|
|
4371
4466
|
*/
|
|
4372
4467
|
async loadCharacterData(e, t) {
|
|
4373
|
-
var v, S, A, b, E, B, _,
|
|
4374
|
-
const { progressCallback: n = null } = t || {}, a = (A = (S = (v = e.models) == null ? void 0 : v.shape) == null ? void 0 : S.resource) == null ? void 0 : A.remote, i = (B = (E = (b = e.models) == null ? void 0 : b.gsStandard) == null ? void 0 : E.resource) == null ? void 0 : B.remote,
|
|
4468
|
+
var v, S, A, b, E, B, _, Y, G;
|
|
4469
|
+
const { progressCallback: n = null } = t || {}, a = (A = (S = (v = e.models) == null ? void 0 : v.shape) == null ? void 0 : S.resource) == null ? void 0 : A.remote, i = (B = (E = (b = e.models) == null ? void 0 : b.gsStandard) == null ? void 0 : E.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
4470
|
if (!a || !i) {
|
|
4376
4471
|
const R = "Missing required resources: shape or gsStandard (point cloud)";
|
|
4377
4472
|
throw y.logEvent("character_load", "error", {
|
|
@@ -4380,32 +4475,32 @@ class ir {
|
|
|
4380
4475
|
reason: R
|
|
4381
4476
|
}), new Error(R);
|
|
4382
4477
|
}
|
|
4383
|
-
const
|
|
4478
|
+
const s = [
|
|
4384
4479
|
{ key: "shape", url: a, filename: "shape.pb" },
|
|
4385
4480
|
{ key: "pointCloud", url: i, filename: "point_cloud.ply" }
|
|
4386
4481
|
];
|
|
4387
|
-
|
|
4482
|
+
o && s.push({ key: "idleAnimation", url: o, filename: "idle.pb", optional: !0 });
|
|
4388
4483
|
let l = 0;
|
|
4389
|
-
const p =
|
|
4390
|
-
n && (
|
|
4484
|
+
const p = s.length, c = (R, V) => {
|
|
4485
|
+
n && (V && l++, n({
|
|
4391
4486
|
stage: "character",
|
|
4392
4487
|
filename: R,
|
|
4393
4488
|
loaded: l,
|
|
4394
4489
|
total: p,
|
|
4395
4490
|
progress: Math.round(l / p * 100)
|
|
4396
4491
|
}));
|
|
4397
|
-
},
|
|
4492
|
+
}, d = {}, m = s.map(async ({ key: R, url: V, filename: W, optional: Z }) => {
|
|
4398
4493
|
c(W, !1);
|
|
4399
4494
|
try {
|
|
4400
|
-
const
|
|
4401
|
-
return R === "shape" ?
|
|
4402
|
-
} catch (
|
|
4403
|
-
if (!
|
|
4404
|
-
throw
|
|
4405
|
-
return h.warn(`⚠️ Optional resource ${W} failed to load:`,
|
|
4495
|
+
const z = await Ue(V);
|
|
4496
|
+
return R === "shape" ? d.shape = z : R === "pointCloud" ? d.pointCloud = z : R === "idleAnimation" && (d.idleAnimation = z), c(W, !0), { key: R, success: !0 };
|
|
4497
|
+
} catch (z) {
|
|
4498
|
+
if (!Z)
|
|
4499
|
+
throw z;
|
|
4500
|
+
return h.warn(`⚠️ Optional resource ${W} failed to load:`, z), c(W, !0), { key: R, success: !1 };
|
|
4406
4501
|
}
|
|
4407
4502
|
});
|
|
4408
|
-
if (await Promise.all(m), !
|
|
4503
|
+
if (await Promise.all(m), !d.shape || !d.pointCloud) {
|
|
4409
4504
|
const R = "Failed to load character data";
|
|
4410
4505
|
throw y.logEvent("character_load", "error", {
|
|
4411
4506
|
characterId: e.characterId ?? "unknown",
|
|
@@ -4413,24 +4508,24 @@ class ir {
|
|
|
4413
4508
|
reason: R
|
|
4414
4509
|
}), new Error(R);
|
|
4415
4510
|
}
|
|
4416
|
-
return
|
|
4511
|
+
return d;
|
|
4417
4512
|
}
|
|
4418
4513
|
/**
|
|
4419
4514
|
* Preload all resources (template + character data + camera info + settings)
|
|
4420
4515
|
*/
|
|
4421
4516
|
async preloadResources(e, t) {
|
|
4422
|
-
const { progressCallback: n = null } = t || {}, [a, i,
|
|
4423
|
-
this.loadTemplateResources(e.flame, (
|
|
4517
|
+
const { progressCallback: n = null } = t || {}, [a, i, o] = await Promise.all([
|
|
4518
|
+
this.loadTemplateResources(e.flame, (s) => {
|
|
4424
4519
|
n && n({
|
|
4425
|
-
...
|
|
4426
|
-
stage: `template-${
|
|
4520
|
+
...s,
|
|
4521
|
+
stage: `template-${s.stage}`
|
|
4427
4522
|
});
|
|
4428
4523
|
}),
|
|
4429
4524
|
this.loadCharacterData(e, {
|
|
4430
|
-
progressCallback: (
|
|
4525
|
+
progressCallback: (s) => {
|
|
4431
4526
|
n && n({
|
|
4432
|
-
...
|
|
4433
|
-
stage: `character-${
|
|
4527
|
+
...s,
|
|
4528
|
+
stage: `character-${s.stage}`
|
|
4434
4529
|
});
|
|
4435
4530
|
}
|
|
4436
4531
|
}),
|
|
@@ -4439,7 +4534,7 @@ class ir {
|
|
|
4439
4534
|
return {
|
|
4440
4535
|
templateResources: a,
|
|
4441
4536
|
characterData: i,
|
|
4442
|
-
preloadCameraSettings:
|
|
4537
|
+
preloadCameraSettings: o,
|
|
4443
4538
|
characterSettings: e.characterSettings
|
|
4444
4539
|
};
|
|
4445
4540
|
}
|
|
@@ -4456,15 +4551,15 @@ class ir {
|
|
|
4456
4551
|
getSdkApiClient() {
|
|
4457
4552
|
return {
|
|
4458
4553
|
async request(e, t = {}) {
|
|
4459
|
-
const i = y.getEnvironmentConfig().sdkApiBaseUrl + e,
|
|
4554
|
+
const i = y.getEnvironmentConfig().sdkApiBaseUrl + e, o = {
|
|
4460
4555
|
"Content-Type": "application/json"
|
|
4461
|
-
},
|
|
4462
|
-
|
|
4556
|
+
}, s = y.appId, l = y.sessionToken;
|
|
4557
|
+
s && (o["X-App-Id"] = s), l && (o.Authorization = `Bearer ${l}`);
|
|
4463
4558
|
try {
|
|
4464
4559
|
const p = await fetch(i, {
|
|
4465
4560
|
method: t.method || "GET",
|
|
4466
4561
|
headers: {
|
|
4467
|
-
...
|
|
4562
|
+
...o,
|
|
4468
4563
|
...t.headers
|
|
4469
4564
|
},
|
|
4470
4565
|
body: t.body ? JSON.stringify(t.body) : void 0
|
|
@@ -4505,15 +4600,15 @@ class ir {
|
|
|
4505
4600
|
const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4506
4601
|
__proto__: null,
|
|
4507
4602
|
AvatarDownloader: ir
|
|
4508
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
4603
|
+
}, Symbol.toStringTag, { value: "Module" })), xe = class xe {
|
|
4509
4604
|
constructor() {
|
|
4510
|
-
|
|
4605
|
+
u(this, "avatarDownloader", null);
|
|
4511
4606
|
}
|
|
4512
4607
|
/**
|
|
4513
4608
|
* 通过全局单例来访问
|
|
4514
4609
|
*/
|
|
4515
4610
|
static get shared() {
|
|
4516
|
-
return this._instance || (this._instance = new
|
|
4611
|
+
return this._instance || (this._instance = new xe()), this._instance;
|
|
4517
4612
|
}
|
|
4518
4613
|
/**
|
|
4519
4614
|
* 加载数字人
|
|
@@ -4527,21 +4622,21 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4527
4622
|
try {
|
|
4528
4623
|
if (!y.isInitialized)
|
|
4529
4624
|
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:
|
|
4625
|
+
this.avatarDownloader || (this.avatarDownloader = new ir()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: de.downloading, progress: 10 });
|
|
4531
4626
|
const n = await this.avatarDownloader.getCharacterById(e);
|
|
4532
|
-
h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type:
|
|
4627
|
+
h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: de.downloading, progress: 30 });
|
|
4533
4628
|
const a = await this.avatarDownloader.preloadResources(n, {
|
|
4534
|
-
progressCallback: (
|
|
4535
|
-
const
|
|
4629
|
+
progressCallback: (o) => {
|
|
4630
|
+
const s = 30 + o.progress / 100 * 70;
|
|
4536
4631
|
t == null || t({
|
|
4537
|
-
type:
|
|
4538
|
-
progress: Math.round(
|
|
4632
|
+
type: de.downloading,
|
|
4633
|
+
progress: Math.round(s)
|
|
4539
4634
|
});
|
|
4540
4635
|
}
|
|
4541
4636
|
});
|
|
4542
4637
|
h.log("[AvatarManager] Step 3: Creating Avatar instance...");
|
|
4543
|
-
const i = new
|
|
4544
|
-
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type:
|
|
4638
|
+
const i = new on(e, n, a);
|
|
4639
|
+
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: de.completed }), y.logEvent("character_load", "info", {
|
|
4545
4640
|
characterId: e,
|
|
4546
4641
|
event: "load_success"
|
|
4547
4642
|
}), i;
|
|
@@ -4550,7 +4645,7 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4550
4645
|
throw h.error("Failed to load avatar:", a), y.logEvent("character_load", "error", {
|
|
4551
4646
|
characterId: e,
|
|
4552
4647
|
reason: a
|
|
4553
|
-
}), t == null || t({ type:
|
|
4648
|
+
}), t == null || t({ type: de.failed, error: n }), n;
|
|
4554
4649
|
}
|
|
4555
4650
|
}
|
|
4556
4651
|
/**
|
|
@@ -4560,55 +4655,55 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4560
4655
|
this.avatarDownloader && this.avatarDownloader.clear();
|
|
4561
4656
|
}
|
|
4562
4657
|
};
|
|
4563
|
-
|
|
4564
|
-
let Tt =
|
|
4565
|
-
const Ke = 2048,
|
|
4658
|
+
u(xe, "_instance", null);
|
|
4659
|
+
let Tt = xe, ve = null, Bt = null, Dt = null, Ot = null, Nt = null, Ut = null;
|
|
4660
|
+
const Ke = 2048, Vt = Ke - 1;
|
|
4566
4661
|
function Ia(r, e, t) {
|
|
4567
4662
|
const a = r.length / 13;
|
|
4568
|
-
(!
|
|
4569
|
-
const i =
|
|
4663
|
+
(!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));
|
|
4664
|
+
const i = ve, o = Bt, s = Dt, l = Ot, p = Nt, c = Ut, d = e[0], m = e[1], v = e[2], S = t[0], A = t[1], b = t[2];
|
|
4570
4665
|
for (let E = 0; E < a; E++) {
|
|
4571
4666
|
const B = E * 13;
|
|
4572
|
-
i[E] = (r[B] -
|
|
4667
|
+
i[E] = (r[B] - d) * S + (r[B + 1] - m) * A + (r[B + 2] - v) * b, s[E] = E;
|
|
4573
4668
|
}
|
|
4574
4669
|
for (let E = 0; E < a; E++) {
|
|
4575
|
-
const B =
|
|
4576
|
-
|
|
4670
|
+
const B = o[E];
|
|
4671
|
+
o[E] = B ^ (-(B >> 31) | 2147483648);
|
|
4577
4672
|
}
|
|
4578
|
-
|
|
4673
|
+
Ve(o, s, l, c, 0, a), Ve(o, l, s, c, 11, a), Ve(o, s, l, c, 22, a);
|
|
4579
4674
|
for (let E = 0; E < a; E++)
|
|
4580
4675
|
p[E] = l[a - 1 - E];
|
|
4581
4676
|
return p;
|
|
4582
4677
|
}
|
|
4583
|
-
function
|
|
4678
|
+
function Ve(r, e, t, n, a, i) {
|
|
4584
4679
|
n.fill(0);
|
|
4585
|
-
for (let
|
|
4586
|
-
const l = r[e[
|
|
4680
|
+
for (let s = 0; s < i; s++) {
|
|
4681
|
+
const l = r[e[s]] >> a & Vt;
|
|
4587
4682
|
n[l]++;
|
|
4588
4683
|
}
|
|
4589
|
-
let
|
|
4590
|
-
for (let
|
|
4591
|
-
const l = n[
|
|
4592
|
-
n[
|
|
4684
|
+
let o = 0;
|
|
4685
|
+
for (let s = 0; s < Ke; s++) {
|
|
4686
|
+
const l = n[s];
|
|
4687
|
+
n[s] = o, o += l;
|
|
4593
4688
|
}
|
|
4594
|
-
for (let
|
|
4595
|
-
const l = e[
|
|
4689
|
+
for (let s = 0; s < i; s++) {
|
|
4690
|
+
const l = e[s], p = r[l] >> a & Vt;
|
|
4596
4691
|
t[n[p]++] = l;
|
|
4597
4692
|
}
|
|
4598
4693
|
}
|
|
4599
|
-
const
|
|
4600
|
-
let
|
|
4694
|
+
const Pe = 13;
|
|
4695
|
+
let ye = null;
|
|
4601
4696
|
function ka(r, e) {
|
|
4602
|
-
const t = e.length, n = t *
|
|
4603
|
-
(!
|
|
4697
|
+
const t = e.length, n = t * Pe;
|
|
4698
|
+
(!ye || ye.length !== n) && (ye = new Float32Array(n));
|
|
4604
4699
|
for (let a = 0; a < t; a++) {
|
|
4605
|
-
const
|
|
4606
|
-
|
|
4607
|
-
r.subarray(
|
|
4608
|
-
|
|
4700
|
+
const o = e[a] * Pe, s = a * Pe;
|
|
4701
|
+
ye.set(
|
|
4702
|
+
r.subarray(o, o + Pe),
|
|
4703
|
+
s
|
|
4609
4704
|
);
|
|
4610
4705
|
}
|
|
4611
|
-
return
|
|
4706
|
+
return ye;
|
|
4612
4707
|
}
|
|
4613
4708
|
const xa = `#version 300 es
|
|
4614
4709
|
precision highp float;
|
|
@@ -4640,7 +4735,7 @@ void main() {
|
|
|
4640
4735
|
// 预乘 alpha 输出(匹配 premultipliedAlpha: true)
|
|
4641
4736
|
// 颜色值需要乘以 alpha,这样 WebGL 才能正确混合
|
|
4642
4737
|
fragColor = vec4(v_color.rgb * alpha, alpha);
|
|
4643
|
-
}`,
|
|
4738
|
+
}`, Ma = `#version 300 es
|
|
4644
4739
|
precision highp float;
|
|
4645
4740
|
|
|
4646
4741
|
// 基础四边形顶点属性(共享4个顶点)
|
|
@@ -4808,21 +4903,21 @@ void main() {
|
|
|
4808
4903
|
v_relativePosition = relativeCoord * BOUNDS_RADIUS;
|
|
4809
4904
|
v_color = a_color;
|
|
4810
4905
|
}`;
|
|
4811
|
-
class
|
|
4906
|
+
class Fa {
|
|
4812
4907
|
// 跟踪当前 buffer 大小
|
|
4813
4908
|
constructor(e, t) {
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4909
|
+
u(this, "canvas");
|
|
4910
|
+
u(this, "backgroundColor");
|
|
4911
|
+
u(this, "gl");
|
|
4912
|
+
u(this, "shaderProgram");
|
|
4913
|
+
u(this, "uniformLocations");
|
|
4914
|
+
u(this, "attributeLocations");
|
|
4915
|
+
u(this, "splatBuffer");
|
|
4916
|
+
u(this, "quadVertexBuffer");
|
|
4917
|
+
u(this, "vertexArray");
|
|
4918
|
+
u(this, "splatCount");
|
|
4919
|
+
u(this, "isInitialized");
|
|
4920
|
+
u(this, "splatBufferSize");
|
|
4826
4921
|
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
4922
|
}
|
|
4828
4923
|
/**
|
|
@@ -5000,7 +5095,7 @@ class Ma {
|
|
|
5000
5095
|
const t = e.createShader(e.VERTEX_SHADER);
|
|
5001
5096
|
if (!t)
|
|
5002
5097
|
throw new Error("Failed to create vertex shader");
|
|
5003
|
-
if (e.shaderSource(t,
|
|
5098
|
+
if (e.shaderSource(t, Ma), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS)) {
|
|
5004
5099
|
const i = e.getShaderInfoLog(t);
|
|
5005
5100
|
throw e.deleteShader(t), new Error(`Vertex shader compilation failed: ${i}`);
|
|
5006
5101
|
}
|
|
@@ -5301,24 +5396,24 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4f {
|
|
|
5301
5396
|
`;
|
|
5302
5397
|
class Ra {
|
|
5303
5398
|
constructor(e, t) {
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5399
|
+
u(this, "canvas");
|
|
5400
|
+
u(this, "backgroundColor");
|
|
5401
|
+
u(this, "device", null);
|
|
5402
|
+
u(this, "context", null);
|
|
5403
|
+
u(this, "renderPipeline", null);
|
|
5404
|
+
u(this, "quadVertexBuffer", null);
|
|
5405
|
+
u(this, "uniformBuffer", null);
|
|
5406
|
+
u(this, "uniformBindGroup", null);
|
|
5312
5407
|
// 🚀 间接索引渲染 buffers
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5408
|
+
u(this, "sortIndexBuffer", null);
|
|
5409
|
+
u(this, "splatDataBuffer", null);
|
|
5410
|
+
u(this, "storageBindGroup", null);
|
|
5411
|
+
u(this, "lastSortOrder", null);
|
|
5317
5412
|
// 缓存上次的排序索引
|
|
5318
|
-
|
|
5413
|
+
u(this, "bindGroupNeedsUpdate", !1);
|
|
5319
5414
|
// 标记 bind group 是否需要更新
|
|
5320
|
-
|
|
5321
|
-
|
|
5415
|
+
u(this, "splatCount", 0);
|
|
5416
|
+
u(this, "presentationFormat", "bgra8unorm");
|
|
5322
5417
|
this.canvas = e, this.backgroundColor = t || [0, 0, 0, 0];
|
|
5323
5418
|
}
|
|
5324
5419
|
/**
|
|
@@ -5509,10 +5604,10 @@ class Ra {
|
|
|
5509
5604
|
n.byteOffset,
|
|
5510
5605
|
n.byteLength
|
|
5511
5606
|
), this.lastSortOrder = n), this.bindGroupNeedsUpdate && this.renderPipeline && this.sortIndexBuffer && this.splatDataBuffer) {
|
|
5512
|
-
const
|
|
5607
|
+
const o = this.renderPipeline.getBindGroupLayout(1);
|
|
5513
5608
|
this.storageBindGroup = this.device.createBindGroup({
|
|
5514
5609
|
label: "Storage Bind Group",
|
|
5515
|
-
layout:
|
|
5610
|
+
layout: o,
|
|
5516
5611
|
entries: [
|
|
5517
5612
|
{
|
|
5518
5613
|
binding: 0,
|
|
@@ -5536,7 +5631,7 @@ class Ra {
|
|
|
5536
5631
|
this.updateUniforms(e, t, n);
|
|
5537
5632
|
const a = this.context.getCurrentTexture().createView(), i = this.device.createCommandEncoder({
|
|
5538
5633
|
label: "Render Command Encoder"
|
|
5539
|
-
}),
|
|
5634
|
+
}), o = i.beginRenderPass({
|
|
5540
5635
|
label: "Render Pass",
|
|
5541
5636
|
colorAttachments: [
|
|
5542
5637
|
{
|
|
@@ -5548,7 +5643,7 @@ class Ra {
|
|
|
5548
5643
|
}
|
|
5549
5644
|
]
|
|
5550
5645
|
});
|
|
5551
|
-
|
|
5646
|
+
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
5647
|
}
|
|
5553
5648
|
/**
|
|
5554
5649
|
* 更新 Uniform Buffer
|
|
@@ -5556,8 +5651,8 @@ class Ra {
|
|
|
5556
5651
|
updateUniforms(e, t, n) {
|
|
5557
5652
|
if (!this.device || !this.uniformBuffer)
|
|
5558
5653
|
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],
|
|
5654
|
+
const a = new ArrayBuffer(160), i = new Float32Array(a), o = new Uint32Array(a);
|
|
5655
|
+
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
5656
|
}
|
|
5562
5657
|
/**
|
|
5563
5658
|
* 清理资源
|
|
@@ -5570,31 +5665,31 @@ class Ra {
|
|
|
5570
5665
|
class Ta {
|
|
5571
5666
|
// 排序耗时
|
|
5572
5667
|
constructor(e) {
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5668
|
+
u(this, "renderer", null);
|
|
5669
|
+
u(this, "backend", null);
|
|
5670
|
+
u(this, "canvas");
|
|
5671
|
+
u(this, "options");
|
|
5577
5672
|
// Camera configuration
|
|
5578
|
-
|
|
5673
|
+
u(this, "camera");
|
|
5579
5674
|
// Matrix cache (reuse buffers to avoid per-frame allocation)
|
|
5580
|
-
|
|
5581
|
-
|
|
5675
|
+
u(this, "viewMatrix", new Float32Array(16));
|
|
5676
|
+
u(this, "projectionMatrix", new Float32Array(16));
|
|
5582
5677
|
// Camera forward vector cache (reuse to avoid per-frame allocation)
|
|
5583
|
-
|
|
5584
|
-
|
|
5678
|
+
u(this, "cachedForward", [0, 0, 1]);
|
|
5679
|
+
u(this, "forwardCacheValid", !1);
|
|
5585
5680
|
// Temporary vectors for view matrix calculation (reuse buffers)
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5681
|
+
u(this, "tempForward", [0, 0, 0]);
|
|
5682
|
+
u(this, "tempRight", [0, 0, 0]);
|
|
5683
|
+
u(this, "tempUp", [0, 0, 0]);
|
|
5589
5684
|
// Camera parameter cache for matrix update optimization
|
|
5590
|
-
|
|
5591
|
-
|
|
5685
|
+
u(this, "cachedCameraParams", null);
|
|
5686
|
+
u(this, "matricesCacheValid", !1);
|
|
5592
5687
|
// 当前数据(GPU 格式:[pos3, color4, cov6] x N)
|
|
5593
|
-
|
|
5688
|
+
u(this, "originalPackedData", null);
|
|
5594
5689
|
// 性能统计
|
|
5595
|
-
|
|
5690
|
+
u(this, "renderTime", 0);
|
|
5596
5691
|
// 总渲染耗时
|
|
5597
|
-
|
|
5692
|
+
u(this, "sortTime", 0);
|
|
5598
5693
|
this.options = e, this.canvas = e.canvas;
|
|
5599
5694
|
const t = e.camera || {
|
|
5600
5695
|
position: [-0.02, -0.013, 1.5],
|
|
@@ -5621,7 +5716,7 @@ class Ta {
|
|
|
5621
5716
|
} catch (a) {
|
|
5622
5717
|
h.warn("⚠️ WebGPU init failed, fallback to WebGL:", a);
|
|
5623
5718
|
}
|
|
5624
|
-
this.renderer = new
|
|
5719
|
+
this.renderer = new Fa(this.canvas, t), await this.renderer.initialize(), this.backend = "webgl", h.log("✅ Using WebGL renderer"), this.updateCameraAspect();
|
|
5625
5720
|
}
|
|
5626
5721
|
/**
|
|
5627
5722
|
* Load packed Splat data (zero-copy, GPU format)
|
|
@@ -5649,8 +5744,8 @@ class Ta {
|
|
|
5649
5744
|
if (this.sortTime = a, this.backend === "webgpu")
|
|
5650
5745
|
this.renderer.loadSplatsFromPackedData(this.originalPackedData, e, n);
|
|
5651
5746
|
else {
|
|
5652
|
-
const
|
|
5653
|
-
this.renderer.loadSplatsFromPackedData(
|
|
5747
|
+
const s = ka(this.originalPackedData, n);
|
|
5748
|
+
this.renderer.loadSplatsFromPackedData(s, e);
|
|
5654
5749
|
}
|
|
5655
5750
|
const i = performance.now();
|
|
5656
5751
|
this.renderer.render(
|
|
@@ -5658,8 +5753,8 @@ class Ta {
|
|
|
5658
5753
|
this.projectionMatrix,
|
|
5659
5754
|
[this.canvas.width, this.canvas.height]
|
|
5660
5755
|
);
|
|
5661
|
-
const
|
|
5662
|
-
this.renderTime =
|
|
5756
|
+
const o = performance.now() - i;
|
|
5757
|
+
this.renderTime = o;
|
|
5663
5758
|
}
|
|
5664
5759
|
/**
|
|
5665
5760
|
* Update camera parameters
|
|
@@ -5709,16 +5804,16 @@ class Ta {
|
|
|
5709
5804
|
* Update camera matrices (with caching to avoid unnecessary updates)
|
|
5710
5805
|
*/
|
|
5711
5806
|
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 !==
|
|
5807
|
+
const { position: e, target: t, up: n, fov: a, aspect: i, near: o, far: s } = this.camera;
|
|
5808
|
+
!(!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
5809
|
position: [e[0], e[1], e[2]],
|
|
5715
5810
|
target: [t[0], t[1], t[2]],
|
|
5716
5811
|
up: [n[0], n[1], n[2]],
|
|
5717
5812
|
fov: a,
|
|
5718
5813
|
aspect: i,
|
|
5719
|
-
near:
|
|
5720
|
-
far:
|
|
5721
|
-
}, this.updatePerspectiveMatrix(a, i,
|
|
5814
|
+
near: o,
|
|
5815
|
+
far: s
|
|
5816
|
+
}, this.updatePerspectiveMatrix(a, i, o, s), this.forwardCacheValid = !1, this.updateViewMatrix(e, t, n), this.matricesCacheValid = !0);
|
|
5722
5817
|
}
|
|
5723
5818
|
/**
|
|
5724
5819
|
* Get camera forward vector (cached version)
|
|
@@ -5738,8 +5833,8 @@ class Ta {
|
|
|
5738
5833
|
* Update perspective projection matrix (reuse buffer)
|
|
5739
5834
|
*/
|
|
5740
5835
|
updatePerspectiveMatrix(e, t, n, a) {
|
|
5741
|
-
const i = e * Math.PI / 180,
|
|
5742
|
-
l[0] =
|
|
5836
|
+
const i = e * Math.PI / 180, o = 1 / Math.tan(i / 2), s = a / (n - a), l = this.projectionMatrix;
|
|
5837
|
+
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
5838
|
}
|
|
5744
5839
|
/**
|
|
5745
5840
|
* Update view matrix (directly update pre-allocated buffer to avoid per-frame allocation)
|
|
@@ -5753,11 +5848,11 @@ class Ta {
|
|
|
5753
5848
|
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
5849
|
const i = Math.hypot(this.tempRight[0], this.tempRight[1], this.tempRight[2]) || 1;
|
|
5755
5850
|
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
|
-
|
|
5851
|
+
const o = this.viewMatrix, s = -e[0], l = -e[1], p = -e[2];
|
|
5852
|
+
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
5853
|
}
|
|
5759
5854
|
}
|
|
5760
|
-
function
|
|
5855
|
+
function ie(r, e, t) {
|
|
5761
5856
|
const n = Math.min(r.length, e.length), a = Array.from({ length: n });
|
|
5762
5857
|
for (let i = 0; i < n; i++)
|
|
5763
5858
|
a[i] = r[i] + (e[i] - r[i]) * t;
|
|
@@ -5766,23 +5861,23 @@ function ne(r, e, t) {
|
|
|
5766
5861
|
function Ba(r, e, t) {
|
|
5767
5862
|
const n = 0.5 - Math.cos(t * Math.PI) * 0.5;
|
|
5768
5863
|
return {
|
|
5769
|
-
translation:
|
|
5770
|
-
rotation:
|
|
5771
|
-
neckPose:
|
|
5772
|
-
jawPose:
|
|
5773
|
-
eyePose:
|
|
5864
|
+
translation: ie(r.translation || [0, 0, 0], e.translation || [0, 0, 0], n),
|
|
5865
|
+
rotation: ie(r.rotation || [0, 0, 0], e.rotation || [0, 0, 0], n),
|
|
5866
|
+
neckPose: ie(r.neckPose || [0, 0, 0], e.neckPose || [0, 0, 0], n),
|
|
5867
|
+
jawPose: ie(r.jawPose || [0, 0, 0], e.jawPose || [0, 0, 0], n),
|
|
5868
|
+
eyePose: ie(r.eyePose || [0, 0, 0, 0, 0, 0], e.eyePose || [0, 0, 0, 0, 0, 0], n),
|
|
5774
5869
|
eyeLid: (() => {
|
|
5775
5870
|
const a = r.eyeLid, i = e.eyeLid;
|
|
5776
|
-
return a && a.length > 0 && i && i.length > 0 ?
|
|
5871
|
+
return a && a.length > 0 && i && i.length > 0 ? ie(a, i, n) : a || i || [];
|
|
5777
5872
|
})(),
|
|
5778
|
-
expression:
|
|
5873
|
+
expression: ie(r.expression || [], e.expression || [], n)
|
|
5779
5874
|
};
|
|
5780
5875
|
}
|
|
5781
5876
|
function Da(r, e, t, n = 25) {
|
|
5782
5877
|
const a = Math.max(1, Math.floor(t / 1e3 * n)), i = Array.from({ length: a });
|
|
5783
|
-
for (let
|
|
5784
|
-
const
|
|
5785
|
-
i[
|
|
5878
|
+
for (let o = 0; o < a; o++) {
|
|
5879
|
+
const s = o / (a - 1);
|
|
5880
|
+
i[o] = Ba(r, e, s);
|
|
5786
5881
|
}
|
|
5787
5882
|
return i;
|
|
5788
5883
|
}
|
|
@@ -5798,51 +5893,46 @@ class Ua {
|
|
|
5798
5893
|
* @param container - Canvas 容器元素(必选)
|
|
5799
5894
|
*/
|
|
5800
5895
|
constructor(e, t) {
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
d(this, "avatar");
|
|
5896
|
+
u(this, "avatarController");
|
|
5897
|
+
u(this, "avatar");
|
|
5804
5898
|
// Initialization state
|
|
5805
|
-
|
|
5899
|
+
u(this, "ready");
|
|
5806
5900
|
// Canvas and rendering
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5901
|
+
u(this, "canvas");
|
|
5902
|
+
u(this, "renderSystem", null);
|
|
5903
|
+
u(this, "isInitialized", !1);
|
|
5904
|
+
u(this, "cameraConfig", null);
|
|
5811
5905
|
// Rendering state machine
|
|
5812
|
-
|
|
5906
|
+
u(this, "renderingState", "idle");
|
|
5813
5907
|
// Realtime animation data
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5908
|
+
u(this, "currentKeyframes", []);
|
|
5909
|
+
u(this, "lastRenderedFrameIndex", -1);
|
|
5910
|
+
u(this, "lastRealtimeProtoFrame", null);
|
|
5817
5911
|
// Animation loop types
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5912
|
+
u(this, "idleAnimationLoopId", null);
|
|
5913
|
+
u(this, "realtimeAnimationLoopId", null);
|
|
5914
|
+
u(this, "resizeObserver", null);
|
|
5915
|
+
u(this, "onWindowResize", () => this.handleResize());
|
|
5822
5916
|
// FPS 计算
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5917
|
+
u(this, "frameCount", 0);
|
|
5918
|
+
u(this, "lastFpsUpdate", 0);
|
|
5919
|
+
u(this, "currentFPS", 0);
|
|
5826
5920
|
// Transition animation data
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5921
|
+
u(this, "transitionKeyframes", []);
|
|
5922
|
+
u(this, "transitionStartTime", 0);
|
|
5923
|
+
u(this, "transitionDurationMs", 400);
|
|
5924
|
+
u(this, "cachedIdleFirstFrame", null);
|
|
5925
|
+
u(this, "idleCurrentFrameIndex", 0);
|
|
5832
5926
|
// Character handle for multi-character support
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
this.avatar = e, this.characterId = `${e.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}
|
|
5836
|
-
const n = y.configuration;
|
|
5837
|
-
if (!n)
|
|
5927
|
+
u(this, "characterHandle", null);
|
|
5928
|
+
u(this, "characterId");
|
|
5929
|
+
if (this.avatar = e, this.characterId = `${e.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, !y.configuration)
|
|
5838
5930
|
throw new Error("AvatarKit must be initialized before creating AvatarView. Call AvatarKit.initialize() first.");
|
|
5839
|
-
const
|
|
5840
|
-
this.
|
|
5841
|
-
playbackMode:
|
|
5842
|
-
}), this.avatarController.setRenderCallback((
|
|
5843
|
-
this.renderRealtimeFrame(
|
|
5844
|
-
}), this.avatarController.setTransitionCompleteCallback(() => {
|
|
5845
|
-
this.onTransitionComplete();
|
|
5931
|
+
const n = y.getPlaybackMode();
|
|
5932
|
+
this.avatarController = new Ca(e, {
|
|
5933
|
+
playbackMode: n
|
|
5934
|
+
}), this.avatarController.setRenderCallback((a, i) => {
|
|
5935
|
+
this.renderRealtimeFrame(a, i);
|
|
5846
5936
|
}), this.canvas = this.createCanvas(t), this.ready = this.initializeView(e), this.setupControllerEventListeners();
|
|
5847
5937
|
}
|
|
5848
5938
|
// Unique ID for this character instance
|
|
@@ -5850,9 +5940,9 @@ class Ua {
|
|
|
5850
5940
|
* 对齐两端 Flame 维度:标量统一长度,expression 取最大长度并零填充
|
|
5851
5941
|
*/
|
|
5852
5942
|
alignFlamePair(e, t) {
|
|
5853
|
-
const n = (
|
|
5854
|
-
const p = Array.isArray(
|
|
5855
|
-
return p.length < l ? Array.from({ length: l }, (c,
|
|
5943
|
+
const n = (s, l) => {
|
|
5944
|
+
const p = Array.isArray(s) ? s.slice(0, l) : [];
|
|
5945
|
+
return p.length < l ? Array.from({ length: l }, (c, d) => p[d] ?? 0) : p;
|
|
5856
5946
|
}, a = {
|
|
5857
5947
|
translation: n(e == null ? void 0 : e.translation, 3),
|
|
5858
5948
|
rotation: n(e == null ? void 0 : e.rotation, 3),
|
|
@@ -5869,8 +5959,8 @@ class Ua {
|
|
|
5869
5959
|
eyePose: n(t == null ? void 0 : t.eyePose, 6),
|
|
5870
5960
|
eyeLid: n(t == null ? void 0 : t.eyeLid, 2),
|
|
5871
5961
|
expression: Array.isArray(t == null ? void 0 : t.expression) ? t.expression.slice() : []
|
|
5872
|
-
},
|
|
5873
|
-
return a.expression = n(a.expression,
|
|
5962
|
+
}, o = Math.max(a.expression.length, i.expression.length);
|
|
5963
|
+
return a.expression = n(a.expression, o), i.expression = n(i.expression, o), { from: a, to: i };
|
|
5874
5964
|
}
|
|
5875
5965
|
/**
|
|
5876
5966
|
* 生成并对齐过渡帧,确保首尾帧与起止帧完全一致
|
|
@@ -5913,8 +6003,8 @@ class Ua {
|
|
|
5913
6003
|
createCanvas(e) {
|
|
5914
6004
|
const t = document.createElement("canvas"), n = e.offsetWidth || 800, a = e.offsetHeight || 600, i = window.devicePixelRatio || 1;
|
|
5915
6005
|
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(
|
|
6006
|
+
const o = window.devicePixelRatio || 1, s = Math.floor(e.offsetWidth || 0), l = Math.floor(e.offsetHeight || 0);
|
|
6007
|
+
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
6008
|
}), this.resizeObserver.observe(e), window.addEventListener("resize", this.onWindowResize), t;
|
|
5919
6009
|
}
|
|
5920
6010
|
/**
|
|
@@ -5939,8 +6029,8 @@ class Ua {
|
|
|
5939
6029
|
n.characterData.pointCloud,
|
|
5940
6030
|
this.characterId
|
|
5941
6031
|
), 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,
|
|
6032
|
+
(i, o) => {
|
|
6033
|
+
this.renderRealtimeFrame(i, o);
|
|
5944
6034
|
},
|
|
5945
6035
|
this.characterHandle
|
|
5946
6036
|
), k.debug && h.log("[AvatarView] Initializing render system...");
|
|
@@ -5971,21 +6061,21 @@ class Ua {
|
|
|
5971
6061
|
* 根据资源解析最终的相机配置,优先使用角色设置,其次 camera.json
|
|
5972
6062
|
*/
|
|
5973
6063
|
resolveCameraConfig(e) {
|
|
5974
|
-
var
|
|
5975
|
-
const t = this.getDefaultCameraConfig(), n = ((
|
|
6064
|
+
var s, l;
|
|
6065
|
+
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
6066
|
if (!i)
|
|
5977
6067
|
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,
|
|
6068
|
+
const o = n ? "characterSettings" : "camera.json";
|
|
6069
|
+
return this.deriveCameraConfigFromSettings(i, t, o);
|
|
5980
6070
|
}
|
|
5981
6071
|
/**
|
|
5982
6072
|
* 从角色设置中推导相机配置
|
|
5983
6073
|
*/
|
|
5984
6074
|
deriveCameraConfigFromSettings(e, t, n) {
|
|
5985
|
-
const a = (
|
|
5986
|
-
if (!c && !
|
|
6075
|
+
const a = (V, W) => Number.isFinite(V) ? V : 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;
|
|
6076
|
+
if (!c && !d && !m)
|
|
5987
6077
|
return h.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
|
|
5988
|
-
const v = Math.sin(l), S = Math.cos(l), A = c ? [i,
|
|
6078
|
+
const v = Math.sin(l), S = Math.cos(l), A = c ? [i, o, s] : [...t.position], b = [
|
|
5989
6079
|
-v,
|
|
5990
6080
|
0,
|
|
5991
6081
|
-S
|
|
@@ -5997,18 +6087,18 @@ class Ua {
|
|
|
5997
6087
|
A[0] + B[0],
|
|
5998
6088
|
A[1] + B[1],
|
|
5999
6089
|
A[2] + B[2]
|
|
6000
|
-
],
|
|
6090
|
+
], Y = [0, 1, 0], G = d ? p * 180 / Math.PI : t.fov, R = {
|
|
6001
6091
|
...t,
|
|
6002
6092
|
// 自动继承 near/far 等配置(来自 APP_CONFIG.camera)
|
|
6003
6093
|
position: A,
|
|
6004
6094
|
target: _,
|
|
6005
|
-
up:
|
|
6095
|
+
up: Y,
|
|
6006
6096
|
fov: G
|
|
6007
6097
|
// near/far 从 fallback 继承,无需硬编码
|
|
6008
6098
|
};
|
|
6009
6099
|
return h.log("[AvatarView] Applied camera settings from resources", {
|
|
6010
6100
|
source: n,
|
|
6011
|
-
translation: [i,
|
|
6101
|
+
translation: [i, o, s],
|
|
6012
6102
|
yawRadians: l,
|
|
6013
6103
|
position: A,
|
|
6014
6104
|
target: _,
|
|
@@ -6079,18 +6169,18 @@ class Ua {
|
|
|
6079
6169
|
return;
|
|
6080
6170
|
}
|
|
6081
6171
|
e = i;
|
|
6082
|
-
const
|
|
6083
|
-
if (!
|
|
6172
|
+
const o = y.getAvatarCore();
|
|
6173
|
+
if (!o)
|
|
6084
6174
|
return;
|
|
6085
|
-
const
|
|
6086
|
-
if (this.idleCurrentFrameIndex++,
|
|
6175
|
+
const s = await o.computeCompleteFrameFlat({ frameIndex: this.idleCurrentFrameIndex }, this.characterHandle ?? void 0);
|
|
6176
|
+
if (this.idleCurrentFrameIndex++, s) {
|
|
6087
6177
|
if (this.renderingState !== "idle")
|
|
6088
6178
|
return;
|
|
6089
|
-
this.renderSystem.loadSplatsFromPackedData(
|
|
6179
|
+
this.renderSystem.loadSplatsFromPackedData(s), this.renderSystem.renderFrame();
|
|
6090
6180
|
}
|
|
6091
6181
|
this.idleAnimationLoopId = requestAnimationFrame(a);
|
|
6092
|
-
} catch (
|
|
6093
|
-
h.error("[AvatarView] Idle animation loop error:",
|
|
6182
|
+
} catch (o) {
|
|
6183
|
+
h.error("[AvatarView] Idle animation loop error:", o instanceof Error ? o.message : String(o)), this.stopIdleAnimationLoop();
|
|
6094
6184
|
}
|
|
6095
6185
|
};
|
|
6096
6186
|
this.idleAnimationLoopId = requestAnimationFrame(a), k.debug && h.log("[AvatarView] Idle animation loop started");
|
|
@@ -6105,8 +6195,8 @@ class Ua {
|
|
|
6105
6195
|
this.initFPS();
|
|
6106
6196
|
const a = async (i) => {
|
|
6107
6197
|
try {
|
|
6108
|
-
const
|
|
6109
|
-
if (this.updateFPS(), !this.renderSystem ||
|
|
6198
|
+
const o = this.renderingState;
|
|
6199
|
+
if (this.updateFPS(), !this.renderSystem || o === "idle") {
|
|
6110
6200
|
this.realtimeAnimationLoopId = null;
|
|
6111
6201
|
return;
|
|
6112
6202
|
}
|
|
@@ -6114,23 +6204,23 @@ class Ua {
|
|
|
6114
6204
|
this.realtimeAnimationLoopId = requestAnimationFrame(a);
|
|
6115
6205
|
return;
|
|
6116
6206
|
}
|
|
6117
|
-
if (e = i,
|
|
6207
|
+
if (e = i, o === "transitioningToSpeaking" || o === "transitioningToIdle") {
|
|
6118
6208
|
if (this.transitionKeyframes.length === 0) {
|
|
6119
6209
|
this.realtimeAnimationLoopId = requestAnimationFrame(a);
|
|
6120
6210
|
return;
|
|
6121
6211
|
}
|
|
6122
|
-
const
|
|
6212
|
+
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 = zt(d), v = y.getAvatarCore();
|
|
6123
6213
|
if (v) {
|
|
6124
6214
|
const S = await v.computeFrameFlatFromParams(m, this.characterHandle ?? void 0);
|
|
6125
6215
|
S && (this.renderSystem.loadSplatsFromPackedData(S), this.renderSystem.renderFrame());
|
|
6126
6216
|
}
|
|
6127
6217
|
if (l >= 1) {
|
|
6128
|
-
if (
|
|
6218
|
+
if (o === "transitioningToSpeaking")
|
|
6129
6219
|
this.setState(
|
|
6130
6220
|
"speaking"
|
|
6131
6221
|
/* Speaking */
|
|
6132
6222
|
), this.transitionKeyframes = [], this.avatarController.onTransitionComplete();
|
|
6133
|
-
else if (
|
|
6223
|
+
else if (o === "transitioningToIdle") {
|
|
6134
6224
|
this.setState(
|
|
6135
6225
|
"idle"
|
|
6136
6226
|
/* Idle */
|
|
@@ -6141,12 +6231,12 @@ class Ua {
|
|
|
6141
6231
|
this.realtimeAnimationLoopId = requestAnimationFrame(a);
|
|
6142
6232
|
return;
|
|
6143
6233
|
}
|
|
6144
|
-
if (
|
|
6234
|
+
if (o === "speaking") {
|
|
6145
6235
|
this.realtimeAnimationLoopId = requestAnimationFrame(a);
|
|
6146
6236
|
return;
|
|
6147
6237
|
}
|
|
6148
|
-
} catch (
|
|
6149
|
-
h.error("[AvatarView] Realtime animation loop error:",
|
|
6238
|
+
} catch (o) {
|
|
6239
|
+
h.error("[AvatarView] Realtime animation loop error:", o instanceof Error ? o.message : String(o)), this.stopRealtimeAnimationLoop();
|
|
6150
6240
|
}
|
|
6151
6241
|
};
|
|
6152
6242
|
this.realtimeAnimationLoopId = requestAnimationFrame(a), k.debug && h.log("[AvatarView] Realtime animation loop started");
|
|
@@ -6175,11 +6265,6 @@ class Ua {
|
|
|
6175
6265
|
renderRealtimeFrame(e, t) {
|
|
6176
6266
|
!this.renderSystem || this.renderingState !== "speaking" || (this.renderSystem.loadSplatsFromPackedData(e), this.renderSystem.renderFrame(), this.lastRenderedFrameIndex = t, t >= 0 && t < this.currentKeyframes.length && (this.lastRealtimeProtoFrame = this.currentKeyframes[t]));
|
|
6177
6267
|
}
|
|
6178
|
-
/**
|
|
6179
|
-
* 过渡完成回调(通知播放层启动音频)
|
|
6180
|
-
*/
|
|
6181
|
-
onTransitionComplete() {
|
|
6182
|
-
}
|
|
6183
6268
|
/**
|
|
6184
6269
|
* 状态转换方法
|
|
6185
6270
|
* 统一管理状态转换,确保状态一致性
|
|
@@ -6240,6 +6325,7 @@ class Ua {
|
|
|
6240
6325
|
* 准备实时渲染(生成 Idle -> Speaking 过渡)
|
|
6241
6326
|
*/
|
|
6242
6327
|
async prepareRealtimeRendering(e) {
|
|
6328
|
+
var n, a;
|
|
6243
6329
|
const t = this.renderingState;
|
|
6244
6330
|
if ((t === "speaking" || t === "transitioningToSpeaking") && this.currentKeyframes.length > 0) {
|
|
6245
6331
|
this.currentKeyframes = e;
|
|
@@ -6248,22 +6334,22 @@ class Ua {
|
|
|
6248
6334
|
this.stopIdleAnimationLoop(), this.currentKeyframes = e, this.setState(
|
|
6249
6335
|
"transitioningToSpeaking"
|
|
6250
6336
|
/* TransitioningToSpeaking */
|
|
6251
|
-
);
|
|
6337
|
+
), (a = (n = this.avatarController).onConversationState) == null || a.call(n, re.playing);
|
|
6252
6338
|
try {
|
|
6253
|
-
const
|
|
6254
|
-
if (
|
|
6339
|
+
const i = y.getAvatarCore();
|
|
6340
|
+
if (i && e.length > 0) {
|
|
6255
6341
|
if (this.renderingState !== "transitioningToSpeaking")
|
|
6256
6342
|
return;
|
|
6257
|
-
const
|
|
6343
|
+
const o = await i.getCurrentFrameParams(this.idleCurrentFrameIndex, this.characterId), s = ht(o);
|
|
6258
6344
|
await this.getCachedIdleFirstFrame();
|
|
6259
|
-
const
|
|
6260
|
-
this.transitionKeyframes = this.generateAndAlignTransitionFrames(
|
|
6345
|
+
const l = e[0];
|
|
6346
|
+
this.transitionKeyframes = this.generateAndAlignTransitionFrames(s, l), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
|
|
6261
6347
|
"speaking"
|
|
6262
6348
|
/* Speaking */
|
|
6263
6349
|
), this.avatarController.onTransitionComplete()) : k.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
|
|
6264
6350
|
}
|
|
6265
|
-
} catch (
|
|
6266
|
-
h.warn("[AvatarView] Transition generation failed:",
|
|
6351
|
+
} catch (i) {
|
|
6352
|
+
h.warn("[AvatarView] Transition generation failed:", i instanceof Error ? i.message : String(i)), this.renderingState === "transitioningToSpeaking" && (this.setState(
|
|
6267
6353
|
"speaking"
|
|
6268
6354
|
/* Speaking */
|
|
6269
6355
|
), this.avatarController.onTransitionComplete());
|
|
@@ -6284,6 +6370,7 @@ class Ua {
|
|
|
6284
6370
|
* 停止实时对话渲染
|
|
6285
6371
|
*/
|
|
6286
6372
|
stopRealtimeRendering() {
|
|
6373
|
+
var t, n;
|
|
6287
6374
|
const e = this.renderingState;
|
|
6288
6375
|
if (!(e === "idle" || e === "transitioningToIdle")) {
|
|
6289
6376
|
if (e !== "speaking") {
|
|
@@ -6296,19 +6383,19 @@ class Ua {
|
|
|
6296
6383
|
this.setState(
|
|
6297
6384
|
"transitioningToIdle"
|
|
6298
6385
|
/* TransitioningToIdle */
|
|
6299
|
-
), (async () => {
|
|
6386
|
+
), (n = (t = this.avatarController).onConversationState) == null || n.call(t, re.idle), (async () => {
|
|
6300
6387
|
try {
|
|
6301
6388
|
if (this.renderingState !== "transitioningToIdle")
|
|
6302
6389
|
return;
|
|
6303
6390
|
if (y.getAvatarCore() && this.currentKeyframes.length > 0) {
|
|
6304
|
-
const
|
|
6305
|
-
if (
|
|
6391
|
+
const i = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], o = await this.getCachedIdleFirstFrame();
|
|
6392
|
+
if (o && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(i, o), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
|
|
6306
6393
|
k.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
|
|
6307
6394
|
return;
|
|
6308
6395
|
}
|
|
6309
6396
|
}
|
|
6310
|
-
} catch (
|
|
6311
|
-
h.warn("[AvatarView] Return transition generation failed:",
|
|
6397
|
+
} catch (a) {
|
|
6398
|
+
h.warn("[AvatarView] Return transition generation failed:", a instanceof Error ? a.message : String(a));
|
|
6312
6399
|
}
|
|
6313
6400
|
this.renderingState === "transitioningToIdle" && (this.setState(
|
|
6314
6401
|
"idle"
|
|
@@ -6375,21 +6462,21 @@ class Ua {
|
|
|
6375
6462
|
}
|
|
6376
6463
|
export {
|
|
6377
6464
|
k as A,
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6465
|
+
ee as C,
|
|
6466
|
+
we as D,
|
|
6467
|
+
se as E,
|
|
6468
|
+
de as L,
|
|
6469
|
+
sn as R,
|
|
6470
|
+
H as S,
|
|
6384
6471
|
y as a,
|
|
6385
|
-
|
|
6472
|
+
on as b,
|
|
6386
6473
|
Ca as c,
|
|
6387
6474
|
Tt as d,
|
|
6388
6475
|
ar as e,
|
|
6389
6476
|
Ua as f,
|
|
6390
|
-
|
|
6391
|
-
|
|
6477
|
+
re as g,
|
|
6478
|
+
x as h,
|
|
6392
6479
|
Na as i,
|
|
6393
6480
|
h as l
|
|
6394
6481
|
};
|
|
6395
|
-
//# sourceMappingURL=index-
|
|
6482
|
+
//# sourceMappingURL=index-BB9yoGY2.js.map
|