@spatialwalk/avatarkit 1.0.0-beta.16 → 1.0.0-beta.18
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 +49 -1
- package/README.md +179 -115
- package/dist/{StreamingAudioPlayer-COgQTrz3.js → StreamingAudioPlayer-D5P7mU8B.js} +2 -2
- package/dist/{StreamingAudioPlayer-COgQTrz3.js.map → StreamingAudioPlayer-D5P7mU8B.js.map} +1 -1
- package/dist/animation/AnimationWebSocketClient.d.ts +5 -4
- package/dist/animation/AnimationWebSocketClient.d.ts.map +1 -1
- package/dist/avatar_core_wasm.wasm +0 -0
- package/dist/core/AvatarController.d.ts +64 -9
- package/dist/core/AvatarController.d.ts.map +1 -1
- package/dist/core/AvatarDownloader.d.ts +0 -4
- package/dist/core/AvatarDownloader.d.ts.map +1 -1
- package/dist/core/AvatarManager.d.ts +1 -3
- package/dist/core/AvatarManager.d.ts.map +1 -1
- package/dist/core/AvatarView.d.ts +9 -2
- package/dist/core/AvatarView.d.ts.map +1 -1
- package/dist/{index-Dsokgngg.js → index-CuR_S9Ng.js} +1284 -1121
- package/dist/index-CuR_S9Ng.js.map +1 -0
- package/dist/index.js +14 -15
- package/dist/types/character.d.ts +0 -11
- package/dist/types/character.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/{reqId.d.ts → conversationId.d.ts} +6 -6
- package/dist/utils/conversationId.d.ts.map +1 -0
- package/dist/vanilla/vite.config.d.ts.map +1 -1
- package/package.json +13 -12
- package/dist/index-Dsokgngg.js.map +0 -1
- package/dist/utils/reqId.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (r, e, t) =>
|
|
4
|
-
class
|
|
1
|
+
var nn = Object.defineProperty;
|
|
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 d = (r, e, t) => an(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
class sn {
|
|
5
5
|
/**
|
|
6
6
|
* 构造函数(内部使用)
|
|
7
7
|
* @param id 数字人 ID
|
|
@@ -29,48 +29,33 @@ class nn {
|
|
|
29
29
|
return this.resources;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
var
|
|
33
|
-
function
|
|
34
|
-
var e, t, n, a, i, s,
|
|
32
|
+
var on = /* @__PURE__ */ ((r) => (r.CAMERA = "camera", r.ANIMATION_IDLE = "frameIdle", r.MODEL_SHAPE = "shape", r.MODEL_GS = "gsStandard", r))(on || {});
|
|
33
|
+
function Na(r) {
|
|
34
|
+
var e, t, n, a, i, s, o, l, p, c, u;
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
shape: ((v = (w = (m = r.models) == null ? void 0 : m.shape) == null ? void 0 : w.resource) == null ? void 0 : v.remote) || null,
|
|
41
|
-
gsStandard: ((P = (b = (y = r.models) == null ? void 0 : y.gsStandard) == null ? void 0 : b.resource) == null ? void 0 : P.remote) || null
|
|
38
|
+
shape: ((l = (o = (s = r.models) == null ? void 0 : s.shape) == null ? void 0 : o.resource) == null ? void 0 : l.remote) || null,
|
|
39
|
+
gsStandard: ((u = (c = (p = r.models) == null ? void 0 : p.gsStandard) == null ? void 0 : c.resource) == null ? void 0 : u.remote) || null
|
|
42
40
|
};
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return !!((n = (t = (e = r.animations) == null ? void 0 : e.frameMono) == null ? void 0 : t.resource) != null && n.remote && ((s = (i = (a = r.animations) == null ? void 0 : a.audioMono) == null ? void 0 : i.resource) != null && s.remote));
|
|
47
|
-
}
|
|
48
|
-
function Ua(r) {
|
|
49
|
-
var e, t, n, a, i, s;
|
|
50
|
-
try {
|
|
51
|
-
const l = JSON.parse(r);
|
|
52
|
-
return !!((n = (t = (e = l == null ? void 0 : l.animations) == null ? void 0 : e.frameMono) == null ? void 0 : t.resource) != null && n.remote && ((s = (i = (a = l == null ? void 0 : l.animations) == null ? void 0 : a.audioMono) == null ? void 0 : i.resource) != null && s.remote));
|
|
53
|
-
} catch {
|
|
54
|
-
return !1;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
var le = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(le || {}), he = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(he || {}), be = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(be || {}), T = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(T || {});
|
|
58
|
-
class oe extends Error {
|
|
42
|
+
var ie = /* @__PURE__ */ ((r) => (r.cn = "cn", r.us = "us", r.test = "test", r))(ie || {}), ze = /* @__PURE__ */ ((r) => (r.sdk = "sdk", r.host = "host", r))(ze || {}), le = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(le || {}), ye = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(ye || {}), M = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(M || {});
|
|
43
|
+
class Q extends Error {
|
|
59
44
|
constructor(e, t) {
|
|
60
45
|
super(e), this.code = t, this.name = "SPAvatarError";
|
|
61
46
|
}
|
|
62
47
|
}
|
|
63
|
-
var
|
|
64
|
-
function
|
|
48
|
+
var me = /* @__PURE__ */ ((r) => (r.network = "network", r.external = "external", r))(me || {});
|
|
49
|
+
function ln() {
|
|
65
50
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("debug") === "1";
|
|
66
51
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
52
|
+
function cn() {
|
|
53
|
+
return ln();
|
|
69
54
|
}
|
|
70
|
-
const
|
|
55
|
+
const I = {
|
|
71
56
|
// Dynamic debug mode check (includes URL parameter)
|
|
72
57
|
get debug() {
|
|
73
|
-
return
|
|
58
|
+
return cn();
|
|
74
59
|
},
|
|
75
60
|
camera: {
|
|
76
61
|
position: [-0.02, -0.013, 1.5],
|
|
@@ -99,7 +84,7 @@ const x = {
|
|
|
99
84
|
}
|
|
100
85
|
}
|
|
101
86
|
};
|
|
102
|
-
function
|
|
87
|
+
function Vt(r) {
|
|
103
88
|
var e;
|
|
104
89
|
return {
|
|
105
90
|
translation: r.translation || [0, 0, 0],
|
|
@@ -126,95 +111,95 @@ function ht(r) {
|
|
|
126
111
|
};
|
|
127
112
|
}
|
|
128
113
|
var $t = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
129
|
-
function
|
|
114
|
+
function dn(r) {
|
|
130
115
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
131
116
|
}
|
|
132
|
-
var
|
|
133
|
-
function
|
|
117
|
+
var Gt = { exports: {} }, Re = { exports: {} }, ft;
|
|
118
|
+
function un() {
|
|
134
119
|
return ft || (ft = 1, function(r, e) {
|
|
135
120
|
(function(t, n) {
|
|
136
121
|
r.exports = n();
|
|
137
122
|
})($t, function() {
|
|
138
|
-
function t(
|
|
139
|
-
return !isNaN(parseFloat(
|
|
123
|
+
function t(A) {
|
|
124
|
+
return !isNaN(parseFloat(A)) && isFinite(A);
|
|
140
125
|
}
|
|
141
|
-
function n(
|
|
142
|
-
return
|
|
126
|
+
function n(A) {
|
|
127
|
+
return A.charAt(0).toUpperCase() + A.substring(1);
|
|
143
128
|
}
|
|
144
|
-
function a(
|
|
129
|
+
function a(A) {
|
|
145
130
|
return function() {
|
|
146
|
-
return this[
|
|
131
|
+
return this[A];
|
|
147
132
|
};
|
|
148
133
|
}
|
|
149
|
-
var i = ["isConstructor", "isEval", "isNative", "isToplevel"], s = ["columnNumber", "lineNumber"],
|
|
150
|
-
function u(
|
|
151
|
-
if (
|
|
134
|
+
var i = ["isConstructor", "isEval", "isNative", "isToplevel"], s = ["columnNumber", "lineNumber"], o = ["fileName", "functionName", "source"], l = ["args"], p = ["evalOrigin"], c = i.concat(s, o, l, p);
|
|
135
|
+
function u(A) {
|
|
136
|
+
if (A)
|
|
152
137
|
for (var b = 0; b < c.length; b++)
|
|
153
|
-
|
|
138
|
+
A[c[b]] !== void 0 && this["set" + n(c[b])](A[c[b]]);
|
|
154
139
|
}
|
|
155
140
|
u.prototype = {
|
|
156
141
|
getArgs: function() {
|
|
157
142
|
return this.args;
|
|
158
143
|
},
|
|
159
|
-
setArgs: function(
|
|
160
|
-
if (Object.prototype.toString.call(
|
|
144
|
+
setArgs: function(A) {
|
|
145
|
+
if (Object.prototype.toString.call(A) !== "[object Array]")
|
|
161
146
|
throw new TypeError("Args must be an Array");
|
|
162
|
-
this.args =
|
|
147
|
+
this.args = A;
|
|
163
148
|
},
|
|
164
149
|
getEvalOrigin: function() {
|
|
165
150
|
return this.evalOrigin;
|
|
166
151
|
},
|
|
167
|
-
setEvalOrigin: function(
|
|
168
|
-
if (
|
|
169
|
-
this.evalOrigin =
|
|
170
|
-
else if (
|
|
171
|
-
this.evalOrigin = new u(
|
|
152
|
+
setEvalOrigin: function(A) {
|
|
153
|
+
if (A instanceof u)
|
|
154
|
+
this.evalOrigin = A;
|
|
155
|
+
else if (A instanceof Object)
|
|
156
|
+
this.evalOrigin = new u(A);
|
|
172
157
|
else
|
|
173
158
|
throw new TypeError("Eval Origin must be an Object or StackFrame");
|
|
174
159
|
},
|
|
175
160
|
toString: function() {
|
|
176
|
-
var
|
|
177
|
-
return this.getIsEval() ?
|
|
161
|
+
var A = this.getFileName() || "", b = this.getLineNumber() || "", E = this.getColumnNumber() || "", B = this.getFunctionName() || "";
|
|
162
|
+
return this.getIsEval() ? A ? "[eval] (" + A + ":" + b + ":" + E + ")" : "[eval]:" + b + ":" + E : B ? B + " (" + A + ":" + b + ":" + E + ")" : A + ":" + b + ":" + E;
|
|
178
163
|
}
|
|
179
164
|
}, u.fromString = function(b) {
|
|
180
|
-
var
|
|
165
|
+
var E = b.indexOf("("), B = b.lastIndexOf(")"), _ = b.substring(0, E), X = b.substring(E + 1, B).split(","), G = b.substring(B + 1);
|
|
181
166
|
if (G.indexOf("@") === 0)
|
|
182
|
-
var
|
|
167
|
+
var R = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(G, ""), z = R[1], W = R[2], Y = R[3];
|
|
183
168
|
return new u({
|
|
184
169
|
functionName: _,
|
|
185
|
-
args:
|
|
186
|
-
fileName:
|
|
187
|
-
lineNumber:
|
|
188
|
-
columnNumber:
|
|
170
|
+
args: X || void 0,
|
|
171
|
+
fileName: z,
|
|
172
|
+
lineNumber: W || void 0,
|
|
173
|
+
columnNumber: Y || void 0
|
|
189
174
|
});
|
|
190
175
|
};
|
|
191
176
|
for (var m = 0; m < i.length; m++)
|
|
192
|
-
u.prototype["get" + n(i[m])] = a(i[m]), u.prototype["set" + n(i[m])] = /* @__PURE__ */ function(
|
|
177
|
+
u.prototype["get" + n(i[m])] = a(i[m]), u.prototype["set" + n(i[m])] = /* @__PURE__ */ function(A) {
|
|
193
178
|
return function(b) {
|
|
194
|
-
this[
|
|
179
|
+
this[A] = !!b;
|
|
195
180
|
};
|
|
196
181
|
}(i[m]);
|
|
197
|
-
for (var
|
|
198
|
-
u.prototype["get" + n(s[
|
|
182
|
+
for (var v = 0; v < s.length; v++)
|
|
183
|
+
u.prototype["get" + n(s[v])] = a(s[v]), u.prototype["set" + n(s[v])] = /* @__PURE__ */ function(A) {
|
|
199
184
|
return function(b) {
|
|
200
185
|
if (!t(b))
|
|
201
|
-
throw new TypeError(
|
|
202
|
-
this[
|
|
186
|
+
throw new TypeError(A + " must be a Number");
|
|
187
|
+
this[A] = Number(b);
|
|
203
188
|
};
|
|
204
|
-
}(s[
|
|
205
|
-
for (var
|
|
206
|
-
u.prototype["get" + n(
|
|
189
|
+
}(s[v]);
|
|
190
|
+
for (var S = 0; S < o.length; S++)
|
|
191
|
+
u.prototype["get" + n(o[S])] = a(o[S]), u.prototype["set" + n(o[S])] = /* @__PURE__ */ function(A) {
|
|
207
192
|
return function(b) {
|
|
208
|
-
this[
|
|
193
|
+
this[A] = String(b);
|
|
209
194
|
};
|
|
210
|
-
}(
|
|
195
|
+
}(o[S]);
|
|
211
196
|
return u;
|
|
212
197
|
});
|
|
213
|
-
}(
|
|
198
|
+
}(Re)), Re.exports;
|
|
214
199
|
}
|
|
215
200
|
(function(r, e) {
|
|
216
201
|
(function(t, n) {
|
|
217
|
-
r.exports = n(
|
|
202
|
+
r.exports = n(un());
|
|
218
203
|
})($t, function(n) {
|
|
219
204
|
var a = /(^|@)\S+:\d+/, i = /^\s*at .*(\S+:\d+|\(native\))/m, s = /^(eval@)?(\[native code])?$/;
|
|
220
205
|
return {
|
|
@@ -224,24 +209,24 @@ function cn() {
|
|
|
224
209
|
* @param {Error} error object
|
|
225
210
|
* @return {Array} of StackFrames
|
|
226
211
|
*/
|
|
227
|
-
parse: function(
|
|
228
|
-
if (typeof
|
|
229
|
-
return this.parseOpera(
|
|
230
|
-
if (
|
|
231
|
-
return this.parseV8OrIE(
|
|
232
|
-
if (
|
|
233
|
-
return this.parseFFOrSafari(
|
|
212
|
+
parse: function(l) {
|
|
213
|
+
if (typeof l.stacktrace < "u" || typeof l["opera#sourceloc"] < "u")
|
|
214
|
+
return this.parseOpera(l);
|
|
215
|
+
if (l.stack && l.stack.match(i))
|
|
216
|
+
return this.parseV8OrIE(l);
|
|
217
|
+
if (l.stack)
|
|
218
|
+
return this.parseFFOrSafari(l);
|
|
234
219
|
throw new Error("Cannot parse given Error object");
|
|
235
220
|
},
|
|
236
221
|
// Separate line and column numbers from a string of the form: (URI:Line:Column)
|
|
237
|
-
extractLocation: function(
|
|
238
|
-
if (
|
|
239
|
-
return [
|
|
240
|
-
var p = /(.+?)(?::(\d+))?(?::(\d+))?$/, c = p.exec(
|
|
222
|
+
extractLocation: function(l) {
|
|
223
|
+
if (l.indexOf(":") === -1)
|
|
224
|
+
return [l];
|
|
225
|
+
var p = /(.+?)(?::(\d+))?(?::(\d+))?$/, c = p.exec(l.replace(/[()]/g, ""));
|
|
241
226
|
return [c[1], c[2] || void 0, c[3] || void 0];
|
|
242
227
|
},
|
|
243
|
-
parseV8OrIE: function(
|
|
244
|
-
var p =
|
|
228
|
+
parseV8OrIE: function(l) {
|
|
229
|
+
var p = l.stack.split(`
|
|
245
230
|
`).filter(function(c) {
|
|
246
231
|
return !!c.match(i);
|
|
247
232
|
}, this);
|
|
@@ -249,18 +234,18 @@ function cn() {
|
|
|
249
234
|
c.indexOf("(eval ") > -1 && (c = c.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
|
|
250
235
|
var u = c.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), m = u.match(/ (\(.+\)$)/);
|
|
251
236
|
u = m ? u.replace(m[0], "") : u;
|
|
252
|
-
var
|
|
237
|
+
var v = this.extractLocation(m ? m[1] : u), S = m && u || void 0, A = ["eval", "<anonymous>"].indexOf(v[0]) > -1 ? void 0 : v[0];
|
|
253
238
|
return new n({
|
|
254
|
-
functionName:
|
|
255
|
-
fileName:
|
|
256
|
-
lineNumber:
|
|
257
|
-
columnNumber:
|
|
239
|
+
functionName: S,
|
|
240
|
+
fileName: A,
|
|
241
|
+
lineNumber: v[1],
|
|
242
|
+
columnNumber: v[2],
|
|
258
243
|
source: c
|
|
259
244
|
});
|
|
260
245
|
}, this);
|
|
261
246
|
},
|
|
262
|
-
parseFFOrSafari: function(
|
|
263
|
-
var p =
|
|
247
|
+
parseFFOrSafari: function(l) {
|
|
248
|
+
var p = l.stack.split(`
|
|
264
249
|
`).filter(function(c) {
|
|
265
250
|
return !c.match(s);
|
|
266
251
|
}, this);
|
|
@@ -269,43 +254,43 @@ function cn() {
|
|
|
269
254
|
return new n({
|
|
270
255
|
functionName: c
|
|
271
256
|
});
|
|
272
|
-
var u = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(u),
|
|
257
|
+
var u = /((.*".+"[^@]*)?[^@]*)(?:@)/, m = c.match(u), v = m && m[1] ? m[1] : void 0, S = this.extractLocation(c.replace(u, ""));
|
|
273
258
|
return new n({
|
|
274
|
-
functionName:
|
|
275
|
-
fileName:
|
|
276
|
-
lineNumber:
|
|
277
|
-
columnNumber:
|
|
259
|
+
functionName: v,
|
|
260
|
+
fileName: S[0],
|
|
261
|
+
lineNumber: S[1],
|
|
262
|
+
columnNumber: S[2],
|
|
278
263
|
source: c
|
|
279
264
|
});
|
|
280
265
|
}, this);
|
|
281
266
|
},
|
|
282
|
-
parseOpera: function(
|
|
283
|
-
return !
|
|
284
|
-
`) > -1 &&
|
|
285
|
-
`).length >
|
|
286
|
-
`).length ? this.parseOpera9(
|
|
267
|
+
parseOpera: function(l) {
|
|
268
|
+
return !l.stacktrace || l.message.indexOf(`
|
|
269
|
+
`) > -1 && l.message.split(`
|
|
270
|
+
`).length > l.stacktrace.split(`
|
|
271
|
+
`).length ? this.parseOpera9(l) : l.stack ? this.parseOpera11(l) : this.parseOpera10(l);
|
|
287
272
|
},
|
|
288
|
-
parseOpera9: function(
|
|
289
|
-
for (var p = /Line (\d+).*script (?:in )?(\S+)/i, c =
|
|
290
|
-
`), u = [], m = 2,
|
|
291
|
-
var
|
|
292
|
-
|
|
293
|
-
fileName:
|
|
294
|
-
lineNumber:
|
|
273
|
+
parseOpera9: function(l) {
|
|
274
|
+
for (var p = /Line (\d+).*script (?:in )?(\S+)/i, c = l.message.split(`
|
|
275
|
+
`), u = [], m = 2, v = c.length; m < v; m += 2) {
|
|
276
|
+
var S = p.exec(c[m]);
|
|
277
|
+
S && u.push(new n({
|
|
278
|
+
fileName: S[2],
|
|
279
|
+
lineNumber: S[1],
|
|
295
280
|
source: c[m]
|
|
296
281
|
}));
|
|
297
282
|
}
|
|
298
283
|
return u;
|
|
299
284
|
},
|
|
300
|
-
parseOpera10: function(
|
|
301
|
-
for (var p = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, c =
|
|
302
|
-
`), u = [], m = 0,
|
|
303
|
-
var
|
|
304
|
-
|
|
285
|
+
parseOpera10: function(l) {
|
|
286
|
+
for (var p = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, c = l.stacktrace.split(`
|
|
287
|
+
`), u = [], m = 0, v = c.length; m < v; m += 2) {
|
|
288
|
+
var S = p.exec(c[m]);
|
|
289
|
+
S && u.push(
|
|
305
290
|
new n({
|
|
306
|
-
functionName:
|
|
307
|
-
fileName:
|
|
308
|
-
lineNumber:
|
|
291
|
+
functionName: S[3] || void 0,
|
|
292
|
+
fileName: S[2],
|
|
293
|
+
lineNumber: S[1],
|
|
309
294
|
source: c[m]
|
|
310
295
|
})
|
|
311
296
|
);
|
|
@@ -313,17 +298,17 @@ function cn() {
|
|
|
313
298
|
return u;
|
|
314
299
|
},
|
|
315
300
|
// Opera 10.65+ Error.stack very similar to FF/Safari
|
|
316
|
-
parseOpera11: function(
|
|
317
|
-
var p =
|
|
301
|
+
parseOpera11: function(l) {
|
|
302
|
+
var p = l.stack.split(`
|
|
318
303
|
`).filter(function(c) {
|
|
319
304
|
return !!c.match(a) && !c.match(/^Error created at/);
|
|
320
305
|
}, this);
|
|
321
306
|
return p.map(function(c) {
|
|
322
|
-
var u = c.split("@"), m = this.extractLocation(u.pop()),
|
|
323
|
-
|
|
324
|
-
var b =
|
|
307
|
+
var u = c.split("@"), m = this.extractLocation(u.pop()), v = u.shift() || "", S = v.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, A;
|
|
308
|
+
v.match(/\(([^)]*)\)/) && (A = v.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
|
|
309
|
+
var b = A === void 0 || A === "[arguments not available]" ? void 0 : A.split(",");
|
|
325
310
|
return new n({
|
|
326
|
-
functionName:
|
|
311
|
+
functionName: S,
|
|
327
312
|
args: b,
|
|
328
313
|
fileName: m[0],
|
|
329
314
|
lineNumber: m[1],
|
|
@@ -334,175 +319,175 @@ function cn() {
|
|
|
334
319
|
}
|
|
335
320
|
};
|
|
336
321
|
});
|
|
337
|
-
})(
|
|
338
|
-
var
|
|
339
|
-
const
|
|
322
|
+
})(Gt);
|
|
323
|
+
var hn = Gt.exports;
|
|
324
|
+
const fn = /* @__PURE__ */ dn(hn);
|
|
340
325
|
let mt = () => {
|
|
341
326
|
var r = (() => {
|
|
342
327
|
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, a = Object.prototype.hasOwnProperty, i = (f, g) => {
|
|
343
|
-
for (var
|
|
344
|
-
}, s = (f, g,
|
|
345
|
-
if (g && typeof g == "object" || typeof g == "function") for (let
|
|
328
|
+
for (var w in g) e(f, w, { get: g[w], enumerable: !0 });
|
|
329
|
+
}, s = (f, g, w, C) => {
|
|
330
|
+
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 });
|
|
346
331
|
return f;
|
|
347
|
-
},
|
|
348
|
-
i(
|
|
349
|
-
var p = (f) => Array.isArray(f), c = (f) => typeof f == "function", u = (f) => f.length === 0, m = (f) => typeof f == "number",
|
|
332
|
+
}, o = (f) => s(e({}, "__esModule", { value: !0 }), f), l = {};
|
|
333
|
+
i(l, { default: () => tn });
|
|
334
|
+
var p = (f) => Array.isArray(f), c = (f) => typeof f == "function", u = (f) => f.length === 0, m = (f) => typeof f == "number", v = (f) => typeof f == "object" && f !== null, S = (f) => f instanceof RegExp, A = (f) => typeof f == "string", b = (f) => f === void 0, E = (f) => {
|
|
350
335
|
const g = /* @__PURE__ */ new Map();
|
|
351
|
-
return (
|
|
352
|
-
const C = g.get(
|
|
336
|
+
return (w) => {
|
|
337
|
+
const C = g.get(w);
|
|
353
338
|
if (C) return C;
|
|
354
|
-
const
|
|
355
|
-
return g.set(
|
|
339
|
+
const P = f(w);
|
|
340
|
+
return g.set(w, P), P;
|
|
356
341
|
};
|
|
357
|
-
},
|
|
358
|
-
const C = { cache: {}, input: f, index: 0, indexMax: 0, options:
|
|
359
|
-
if (
|
|
342
|
+
}, B = (f, g, w = {}) => {
|
|
343
|
+
const C = { cache: {}, input: f, index: 0, indexMax: 0, options: w, output: [] };
|
|
344
|
+
if (Z(g)(C) && C.index === f.length) return C.output;
|
|
360
345
|
throw new Error(`Failed to parse at index ${C.indexMax}`);
|
|
361
|
-
}, _ = (f, g) => p(f) ?
|
|
362
|
-
const
|
|
346
|
+
}, _ = (f, g) => p(f) ? X(f, g) : A(f) ? R(f, g) : G(f, g), X = (f, g) => {
|
|
347
|
+
const w = {};
|
|
363
348
|
for (const C of f) {
|
|
364
349
|
if (C.length !== 1) throw new Error(`Invalid character: "${C}"`);
|
|
365
|
-
const
|
|
366
|
-
|
|
350
|
+
const P = C.charCodeAt(0);
|
|
351
|
+
w[P] = !0;
|
|
367
352
|
}
|
|
368
353
|
return (C) => {
|
|
369
|
-
const
|
|
370
|
-
for (; C.index <
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
354
|
+
const P = C.index, k = C.input;
|
|
355
|
+
for (; C.index < k.length && k.charCodeAt(C.index) in w; ) C.index += 1;
|
|
356
|
+
const T = C.index;
|
|
357
|
+
if (T > P) {
|
|
373
358
|
if (!b(g) && !C.options.silent) {
|
|
374
|
-
const
|
|
375
|
-
b(
|
|
359
|
+
const $ = C.input.slice(P, T), q = c(g) ? g($, k, String(P)) : g;
|
|
360
|
+
b(q) || C.output.push(q);
|
|
376
361
|
}
|
|
377
362
|
C.indexMax = Math.max(C.indexMax, C.index);
|
|
378
363
|
}
|
|
379
364
|
return !0;
|
|
380
365
|
};
|
|
381
366
|
}, G = (f, g) => {
|
|
382
|
-
const
|
|
383
|
-
return
|
|
384
|
-
|
|
385
|
-
const
|
|
386
|
-
if (
|
|
387
|
-
if (!b(g) && !
|
|
388
|
-
const
|
|
389
|
-
b(
|
|
367
|
+
const w = f.source, C = f.flags.replace(/y|$/, "y"), P = new RegExp(w, C);
|
|
368
|
+
return be((k) => {
|
|
369
|
+
P.lastIndex = k.index;
|
|
370
|
+
const T = P.exec(k.input);
|
|
371
|
+
if (T) {
|
|
372
|
+
if (!b(g) && !k.options.silent) {
|
|
373
|
+
const $ = c(g) ? g(...T, k.input, String(k.index)) : g;
|
|
374
|
+
b($) || k.output.push($);
|
|
390
375
|
}
|
|
391
|
-
return
|
|
376
|
+
return k.index += T[0].length, k.indexMax = Math.max(k.indexMax, k.index), !0;
|
|
392
377
|
} else return !1;
|
|
393
378
|
});
|
|
394
|
-
},
|
|
395
|
-
if (
|
|
396
|
-
if (!b(g) && !
|
|
397
|
-
const C = c(g) ? g(f,
|
|
398
|
-
b(C) ||
|
|
379
|
+
}, R = (f, g) => (w) => {
|
|
380
|
+
if (w.input.startsWith(f, w.index)) {
|
|
381
|
+
if (!b(g) && !w.options.silent) {
|
|
382
|
+
const C = c(g) ? g(f, w.input, String(w.index)) : g;
|
|
383
|
+
b(C) || w.output.push(C);
|
|
399
384
|
}
|
|
400
|
-
return
|
|
385
|
+
return w.index += f.length, w.indexMax = Math.max(w.indexMax, w.index), !0;
|
|
401
386
|
} else return !1;
|
|
402
|
-
},
|
|
403
|
-
const
|
|
404
|
-
return
|
|
405
|
-
let
|
|
406
|
-
for (;
|
|
407
|
-
const
|
|
408
|
-
if (!
|
|
387
|
+
}, z = (f, g, w, C) => {
|
|
388
|
+
const P = Z(f);
|
|
389
|
+
return be(xe(Xe((k) => {
|
|
390
|
+
let T = 0;
|
|
391
|
+
for (; T < w; ) {
|
|
392
|
+
const $ = k.index;
|
|
393
|
+
if (!P(k) || (T += 1, k.index === $)) break;
|
|
409
394
|
}
|
|
410
|
-
return
|
|
395
|
+
return T >= g;
|
|
411
396
|
})));
|
|
412
|
-
},
|
|
413
|
-
const
|
|
414
|
-
return
|
|
415
|
-
for (let
|
|
397
|
+
}, W = (f, g) => z(f, 0, 1), Y = (f, g) => z(f, 0, 1 / 0), V = (f, g) => {
|
|
398
|
+
const w = f.map(Z);
|
|
399
|
+
return be(xe(Xe((C) => {
|
|
400
|
+
for (let P = 0, k = w.length; P < k; P++) if (!w[P](C)) return !1;
|
|
416
401
|
return !0;
|
|
417
402
|
})));
|
|
418
|
-
},
|
|
419
|
-
const
|
|
420
|
-
return
|
|
421
|
-
for (let
|
|
403
|
+
}, j = (f, g) => {
|
|
404
|
+
const w = f.map(Z);
|
|
405
|
+
return be(xe((C) => {
|
|
406
|
+
for (let P = 0, k = w.length; P < k; P++) if (w[P](C)) return !0;
|
|
422
407
|
return !1;
|
|
423
408
|
}));
|
|
424
|
-
},
|
|
425
|
-
const
|
|
409
|
+
}, Xe = (f, g = !1) => {
|
|
410
|
+
const w = Z(f);
|
|
426
411
|
return (C) => {
|
|
427
|
-
const
|
|
428
|
-
return (!
|
|
412
|
+
const P = C.index, k = C.output.length, T = w(C);
|
|
413
|
+
return (!T || g) && (C.index = P, C.output.length !== k && (C.output.length = k)), T;
|
|
429
414
|
};
|
|
430
|
-
},
|
|
415
|
+
}, xe = (f, g) => Z(f), be = /* @__PURE__ */ (() => {
|
|
431
416
|
let f = 0;
|
|
432
417
|
return (g) => {
|
|
433
|
-
const
|
|
434
|
-
return (
|
|
418
|
+
const w = Z(g), C = f += 1;
|
|
419
|
+
return (P) => {
|
|
435
420
|
var lt;
|
|
436
|
-
var
|
|
437
|
-
if (
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
-
if (m(
|
|
441
|
-
if (
|
|
421
|
+
var k;
|
|
422
|
+
if (P.options.memoization === !1) return w(P);
|
|
423
|
+
const T = P.index, $ = (k = P.cache)[C] || (k[C] = /* @__PURE__ */ new Map()), q = $.get(T);
|
|
424
|
+
if (q === !1) return !1;
|
|
425
|
+
if (m(q)) return P.index = q, !0;
|
|
426
|
+
if (q) return P.index = q.index, (lt = q.output) != null && lt.length && P.output.push(...q.output), !0;
|
|
442
427
|
{
|
|
443
|
-
const ct =
|
|
444
|
-
if (
|
|
445
|
-
const dt =
|
|
428
|
+
const ct = P.output.length;
|
|
429
|
+
if (w(P)) {
|
|
430
|
+
const dt = P.index, ut = P.output.length;
|
|
446
431
|
if (ut > ct) {
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
} else
|
|
432
|
+
const rn = P.output.slice(ct, ut);
|
|
433
|
+
$.set(T, { index: dt, output: rn });
|
|
434
|
+
} else $.set(T, dt);
|
|
450
435
|
return !0;
|
|
451
|
-
} else return
|
|
436
|
+
} else return $.set(T, !1), !1;
|
|
452
437
|
}
|
|
453
438
|
};
|
|
454
439
|
};
|
|
455
|
-
})(),
|
|
440
|
+
})(), Ye = (f) => {
|
|
456
441
|
let g;
|
|
457
|
-
return (
|
|
458
|
-
},
|
|
459
|
-
if (c(f)) return u(f) ?
|
|
460
|
-
if (
|
|
461
|
-
if (p(f)) return
|
|
462
|
-
if (
|
|
442
|
+
return (w) => (g || (g = Z(f())), g(w));
|
|
443
|
+
}, Z = E((f) => {
|
|
444
|
+
if (c(f)) return u(f) ? Ye(f) : f;
|
|
445
|
+
if (A(f) || S(f)) return _(f);
|
|
446
|
+
if (p(f)) return V(f);
|
|
447
|
+
if (v(f)) return j(Object.values(f));
|
|
463
448
|
throw new Error("Invalid rule");
|
|
464
|
-
}),
|
|
449
|
+
}), Ze = "abcdefghijklmnopqrstuvwxyz", sr = (f) => {
|
|
465
450
|
let g = "";
|
|
466
451
|
for (; f > 0; ) {
|
|
467
|
-
const
|
|
468
|
-
g =
|
|
452
|
+
const w = (f - 1) % 26;
|
|
453
|
+
g = Ze[w] + g, f = Math.floor((f - 1) / 26);
|
|
469
454
|
}
|
|
470
455
|
return g;
|
|
471
|
-
},
|
|
456
|
+
}, Je = (f) => {
|
|
472
457
|
let g = 0;
|
|
473
|
-
for (let
|
|
458
|
+
for (let w = 0, C = f.length; w < C; w++) g = g * 26 + Ze.indexOf(f[w]) + 1;
|
|
474
459
|
return g;
|
|
475
|
-
},
|
|
476
|
-
if (g < f) return
|
|
477
|
-
const
|
|
478
|
-
for (; f <= g; )
|
|
479
|
-
return
|
|
480
|
-
},
|
|
460
|
+
}, Fe = (f, g) => {
|
|
461
|
+
if (g < f) return Fe(g, f);
|
|
462
|
+
const w = [];
|
|
463
|
+
for (; f <= g; ) w.push(f++);
|
|
464
|
+
return w;
|
|
465
|
+
}, or = (f, g, w) => Fe(f, g).map((C) => String(C).padStart(w, "0")), Qe = (f, g) => Fe(Je(f), Je(g)).map(sr), K = (f) => f, et = (f) => lr((g) => B(g, f, { memoization: !1 }).join("")), lr = (f) => {
|
|
481
466
|
const g = {};
|
|
482
|
-
return (
|
|
483
|
-
},
|
|
484
|
-
const
|
|
485
|
-
if (!
|
|
486
|
-
const C =
|
|
487
|
-
return C.some((
|
|
467
|
+
return (w) => g[w] ?? (g[w] = f(w));
|
|
468
|
+
}, cr = _(/^\*\*\/\*$/, ".*"), dr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, w) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}`), ur = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, w, C) => `.*${g ? "" : "(?:^|/)"}${w.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Me = _(/\\./, K), hr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), fr = _(/./, K), mr = _(/^(?:!!)*!(.*)$/, (f, g) => `(?!^${ot(g)}$).*?`), pr = _(/^(!!)+/, ""), gr = j([mr, pr]), vr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), yr = _(/^(\*\*\/)+/, "(?:^|.*/)"), wr = _(/\/(\*\*)$/, "(?:/.*|$)"), Ar = _(/\*\*/, ".*"), tt = j([vr, yr, wr, Ar]), Sr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), br = _(/\*/, "[^/]*"), rt = j([Sr, br]), nt = _("?", "[^/]"), Cr = _("[", K), _r = _("]", K), Pr = _(/[!^]/, "^/"), Er = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, K), Ir = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), kr = _(/[^\]]/, K), xr = j([Me, Ir, Er, kr]), at = V([Cr, W(Pr), Y(xr), _r]), Fr = _("{", "(?:"), Mr = _("}", ")"), Lr = _(/(\d+)\.\.(\d+)/, (f, g, w) => or(+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 = j([Lr, Rr, Tr]), it = V([Fr, Br, Mr]), Dr = _("{", "(?:"), Or = _("}", ")"), Nr = _(",", "|"), Ur = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), zr = _(/[^}]/, K), Vr = Ye(() => st), $r = j([tt, rt, nt, at, it, Vr, Me, Ur, Nr, zr]), st = V([Dr, Y($r), Or]), Gr = Y(j([cr, dr, ur, gr, tt, rt, nt, at, it, st, Me, hr, fr])), Wr = Gr, qr = et(Wr), ot = qr, Hr = _(/\\./, K), jr = _(/./, K), Kr = _(/\*\*\*+/, "*"), Xr = _(/([^/{[(!])\*\*/, (f, g) => `${g}*`), Yr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, g) => `${g}*`), Zr = Y(j([Hr, Kr, Xr, Yr, jr])), Jr = Zr, Qr = et(Jr), en = Qr, Le = (f, g) => {
|
|
469
|
+
const w = Array.isArray(f) ? f : [f];
|
|
470
|
+
if (!w.length) return !1;
|
|
471
|
+
const C = w.map(Le.compile), P = w.every((T) => /(\/(?:\*\*)?|\[\/\])$/.test(T)), k = g.replace(/[\\\/]+/g, "/").replace(/\/$/, P ? "/" : "");
|
|
472
|
+
return C.some((T) => T.test(k));
|
|
488
473
|
};
|
|
489
|
-
|
|
490
|
-
var
|
|
491
|
-
return l
|
|
474
|
+
Le.compile = (f) => new RegExp(`^${ot(en(f))}$`, "s");
|
|
475
|
+
var tn = Le;
|
|
476
|
+
return o(l);
|
|
492
477
|
})();
|
|
493
478
|
return r.default || r;
|
|
494
|
-
},
|
|
495
|
-
const
|
|
496
|
-
function
|
|
497
|
-
return r && r.replace(/\\/g, "/").replace(
|
|
479
|
+
}, Te;
|
|
480
|
+
const mn = (r, e) => (Te || (Te = mt(), mt = null), Te(r, e)), pn = /^[A-Za-z]:\//;
|
|
481
|
+
function se(r = "") {
|
|
482
|
+
return r && r.replace(/\\/g, "/").replace(pn, (e) => e.toUpperCase());
|
|
498
483
|
}
|
|
499
|
-
const
|
|
484
|
+
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) {
|
|
500
485
|
if (r.length === 0)
|
|
501
486
|
return ".";
|
|
502
|
-
r =
|
|
503
|
-
const e = r.match(
|
|
504
|
-
return r =
|
|
505
|
-
},
|
|
487
|
+
r = se(r);
|
|
488
|
+
const e = r.match(gn), t = pe(r), n = r[r.length - 1] === "/";
|
|
489
|
+
return r = He(r, !t), r.length === 0 ? t ? "/" : n ? "./" : "." : (n && (r += "/"), Wt.test(r) && (r += "/"), e ? t ? `//${r}` : `//./${r}` : t && !pe(r) ? `/${r}` : r);
|
|
490
|
+
}, Sn = function(...r) {
|
|
506
491
|
let e = "";
|
|
507
492
|
for (const t of r)
|
|
508
493
|
if (t)
|
|
@@ -511,60 +496,60 @@ const mn = /^[/\\]{2}/, pn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,
|
|
|
511
496
|
n && a ? e += t.slice(1) : e += n || a ? t : `/${t}`;
|
|
512
497
|
} else
|
|
513
498
|
e += t;
|
|
514
|
-
return
|
|
499
|
+
return qe(e);
|
|
515
500
|
};
|
|
516
|
-
function
|
|
501
|
+
function bn() {
|
|
517
502
|
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
518
503
|
}
|
|
519
|
-
const
|
|
520
|
-
r = r.map((n) =>
|
|
504
|
+
const Ee = function(...r) {
|
|
505
|
+
r = r.map((n) => se(n));
|
|
521
506
|
let e = "", t = !1;
|
|
522
507
|
for (let n = r.length - 1; n >= -1 && !t; n--) {
|
|
523
|
-
const a = n >= 0 ? r[n] :
|
|
524
|
-
!a || a.length === 0 || (e = `${a}/${e}`, t =
|
|
508
|
+
const a = n >= 0 ? r[n] : bn();
|
|
509
|
+
!a || a.length === 0 || (e = `${a}/${e}`, t = pe(a));
|
|
525
510
|
}
|
|
526
|
-
return e =
|
|
511
|
+
return e = He(e, !t), t && !pe(e) ? `/${e}` : e.length > 0 ? e : ".";
|
|
527
512
|
};
|
|
528
|
-
function
|
|
513
|
+
function He(r, e) {
|
|
529
514
|
let t = "", n = 0, a = -1, i = 0, s = null;
|
|
530
|
-
for (let
|
|
531
|
-
if (
|
|
532
|
-
s = r[
|
|
515
|
+
for (let o = 0; o <= r.length; ++o) {
|
|
516
|
+
if (o < r.length)
|
|
517
|
+
s = r[o];
|
|
533
518
|
else {
|
|
534
519
|
if (s === "/")
|
|
535
520
|
break;
|
|
536
521
|
s = "/";
|
|
537
522
|
}
|
|
538
523
|
if (s === "/") {
|
|
539
|
-
if (!(a ===
|
|
524
|
+
if (!(a === o - 1 || i === 1)) if (i === 2) {
|
|
540
525
|
if (t.length < 2 || n !== 2 || t[t.length - 1] !== "." || t[t.length - 2] !== ".") {
|
|
541
526
|
if (t.length > 2) {
|
|
542
|
-
const
|
|
543
|
-
|
|
527
|
+
const l = t.lastIndexOf("/");
|
|
528
|
+
l === -1 ? (t = "", n = 0) : (t = t.slice(0, l), n = t.length - 1 - t.lastIndexOf("/")), a = o, i = 0;
|
|
544
529
|
continue;
|
|
545
530
|
} else if (t.length > 0) {
|
|
546
|
-
t = "", n = 0, a =
|
|
531
|
+
t = "", n = 0, a = o, i = 0;
|
|
547
532
|
continue;
|
|
548
533
|
}
|
|
549
534
|
}
|
|
550
535
|
e && (t += t.length > 0 ? "/.." : "..", n = 2);
|
|
551
536
|
} else
|
|
552
|
-
t.length > 0 ? t += `/${r.slice(a + 1,
|
|
553
|
-
a =
|
|
537
|
+
t.length > 0 ? t += `/${r.slice(a + 1, o)}` : t = r.slice(a + 1, o), n = o - a - 1;
|
|
538
|
+
a = o, i = 0;
|
|
554
539
|
} else s === "." && i !== -1 ? ++i : i = -1;
|
|
555
540
|
}
|
|
556
541
|
return t;
|
|
557
542
|
}
|
|
558
|
-
const
|
|
559
|
-
return
|
|
560
|
-
},
|
|
561
|
-
return
|
|
562
|
-
},
|
|
543
|
+
const pe = function(r) {
|
|
544
|
+
return vn.test(r);
|
|
545
|
+
}, Cn = function(r) {
|
|
546
|
+
return se(r);
|
|
547
|
+
}, qt = function(r) {
|
|
563
548
|
if (r === "..") return "";
|
|
564
|
-
const e =
|
|
549
|
+
const e = yn.exec(se(r));
|
|
565
550
|
return e && e[1] || "";
|
|
566
|
-
},
|
|
567
|
-
const t =
|
|
551
|
+
}, _n = function(r, e) {
|
|
552
|
+
const t = Ee(r).replace(pt, "$1").split("/"), n = Ee(e).replace(pt, "$1").split("/");
|
|
568
553
|
if (n[0][1] === ":" && t[0][1] === ":" && t[0] !== n[0])
|
|
569
554
|
return n.join("/");
|
|
570
555
|
const a = [...t];
|
|
@@ -575,17 +560,17 @@ const ve = function(r) {
|
|
|
575
560
|
}
|
|
576
561
|
return [...t.map(() => ".."), ...n].join("/");
|
|
577
562
|
}, Ht = function(r) {
|
|
578
|
-
const e =
|
|
579
|
-
return e.length === 1 &&
|
|
580
|
-
},
|
|
563
|
+
const e = se(r).replace(/\/$/, "").split("/").slice(0, -1);
|
|
564
|
+
return e.length === 1 && Wt.test(e[0]) && (e[0] += "/"), e.join("/") || (pe(r) ? "/" : ".");
|
|
565
|
+
}, Pn = function(r) {
|
|
581
566
|
const e = r.ext ? r.ext.startsWith(".") ? r.ext : `.${r.ext}` : "", t = [r.root, r.dir, r.base ?? (r.name ?? "") + e].filter(
|
|
582
567
|
Boolean
|
|
583
568
|
);
|
|
584
|
-
return
|
|
585
|
-
r.root ?
|
|
569
|
+
return se(
|
|
570
|
+
r.root ? Ee(...t) : t.join("/")
|
|
586
571
|
);
|
|
587
572
|
}, jt = function(r, e) {
|
|
588
|
-
const t =
|
|
573
|
+
const t = se(r).split("/");
|
|
589
574
|
let n = "";
|
|
590
575
|
for (let a = t.length - 1; a >= 0; a--) {
|
|
591
576
|
const i = t[a];
|
|
@@ -595,9 +580,9 @@ const ve = function(r) {
|
|
|
595
580
|
}
|
|
596
581
|
}
|
|
597
582
|
return e && n.endsWith(e) ? n.slice(0, -e.length) : n;
|
|
598
|
-
},
|
|
583
|
+
}, En = function(r) {
|
|
599
584
|
var a, i;
|
|
600
|
-
const e = ((i = (a = wn.exec(r)) == null ? void 0 : a[0]) == null ? void 0 : i.replace(/\\/g, "/")) || "", t = jt(r), n =
|
|
585
|
+
const e = ((i = (a = wn.exec(r)) == null ? void 0 : a[0]) == null ? void 0 : i.replace(/\\/g, "/")) || "", t = jt(r), n = qt(t);
|
|
601
586
|
return {
|
|
602
587
|
root: e,
|
|
603
588
|
dir: Ht(r),
|
|
@@ -605,33 +590,33 @@ const ve = function(r) {
|
|
|
605
590
|
ext: n,
|
|
606
591
|
name: t.slice(0, t.length - n.length)
|
|
607
592
|
};
|
|
608
|
-
},
|
|
593
|
+
}, In = (r, e) => mn(e, qe(r)), gt = {
|
|
609
594
|
__proto__: null,
|
|
610
595
|
basename: jt,
|
|
611
596
|
dirname: Ht,
|
|
612
|
-
extname:
|
|
613
|
-
format:
|
|
614
|
-
isAbsolute:
|
|
615
|
-
join:
|
|
616
|
-
matchesGlob:
|
|
617
|
-
normalize:
|
|
618
|
-
normalizeString:
|
|
619
|
-
parse:
|
|
620
|
-
relative:
|
|
621
|
-
resolve:
|
|
622
|
-
sep:
|
|
623
|
-
toNamespacedPath:
|
|
624
|
-
},
|
|
597
|
+
extname: qt,
|
|
598
|
+
format: Pn,
|
|
599
|
+
isAbsolute: pe,
|
|
600
|
+
join: Sn,
|
|
601
|
+
matchesGlob: In,
|
|
602
|
+
normalize: qe,
|
|
603
|
+
normalizeString: He,
|
|
604
|
+
parse: En,
|
|
605
|
+
relative: _n,
|
|
606
|
+
resolve: Ee,
|
|
607
|
+
sep: An,
|
|
608
|
+
toNamespacedPath: Cn
|
|
609
|
+
}, kn = /* @__PURE__ */ (() => {
|
|
625
610
|
var r;
|
|
626
611
|
return ((r = globalThis.process) == null ? void 0 : r.platform) === "win32" ? ";" : ":";
|
|
627
|
-
})(),
|
|
612
|
+
})(), xn = { posix: void 0, win32: void 0 }, Kt = (r = kn) => new Proxy(gt, {
|
|
628
613
|
get(e, t) {
|
|
629
|
-
return t === "delimiter" ? r : t === "posix" ?
|
|
614
|
+
return t === "delimiter" ? r : t === "posix" ? Ve : t === "win32" ? Fn : xn[t] || gt[t];
|
|
630
615
|
}
|
|
631
|
-
}),
|
|
632
|
-
var
|
|
633
|
-
const
|
|
634
|
-
function
|
|
616
|
+
}), Ve = /* @__PURE__ */ Kt(":"), Fn = /* @__PURE__ */ Kt(";");
|
|
617
|
+
var F = /* @__PURE__ */ ((r) => (r[r.Error = 0] = "Error", r[r.Warning = 1] = "Warning", r[r.Log = 2] = "Log", r[r.Verbose = 3] = "Verbose", r[r.Debug = 4] = "Debug", r))(F || {}), x = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(x || {}), te = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(te || {});
|
|
618
|
+
const Mn = !0;
|
|
619
|
+
function L(r, e, t = r) {
|
|
635
620
|
return (n) => {
|
|
636
621
|
const a = `${n}`, i = a.indexOf(e, r.length);
|
|
637
622
|
return ~i ? r + Xt(a, e, t, i) + e : r + a + e;
|
|
@@ -641,68 +626,68 @@ function Xt(r, e, t, n) {
|
|
|
641
626
|
const a = r.substring(0, n) + t, i = r.substring(n + e.length), s = i.indexOf(e);
|
|
642
627
|
return ~s ? a + Xt(i, e, t, s) : a + i;
|
|
643
628
|
}
|
|
644
|
-
function
|
|
629
|
+
function Ln(r = Mn) {
|
|
645
630
|
return {
|
|
646
631
|
isColorSupported: r,
|
|
647
632
|
reset: r ? (e) => `\x1B[0m${e}\x1B[0m` : String,
|
|
648
|
-
bold: r ?
|
|
649
|
-
dim: r ?
|
|
650
|
-
italic: r ?
|
|
651
|
-
underline: r ?
|
|
652
|
-
inverse: r ?
|
|
653
|
-
hidden: r ?
|
|
654
|
-
strikethrough: r ?
|
|
655
|
-
black: r ?
|
|
656
|
-
red: r ?
|
|
657
|
-
green: r ?
|
|
658
|
-
yellow: r ?
|
|
659
|
-
blue: r ?
|
|
660
|
-
magenta: r ?
|
|
661
|
-
cyan: r ?
|
|
662
|
-
white: r ?
|
|
663
|
-
gray: r ?
|
|
664
|
-
bgBlack: r ?
|
|
665
|
-
bgRed: r ?
|
|
666
|
-
bgGreen: r ?
|
|
667
|
-
bgYellow: r ?
|
|
668
|
-
bgBlue: r ?
|
|
669
|
-
bgMagenta: r ?
|
|
670
|
-
bgCyan: r ?
|
|
671
|
-
bgWhite: r ?
|
|
633
|
+
bold: r ? L("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String,
|
|
634
|
+
dim: r ? L("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String,
|
|
635
|
+
italic: r ? L("\x1B[3m", "\x1B[23m") : String,
|
|
636
|
+
underline: r ? L("\x1B[4m", "\x1B[24m") : String,
|
|
637
|
+
inverse: r ? L("\x1B[7m", "\x1B[27m") : String,
|
|
638
|
+
hidden: r ? L("\x1B[8m", "\x1B[28m") : String,
|
|
639
|
+
strikethrough: r ? L("\x1B[9m", "\x1B[29m") : String,
|
|
640
|
+
black: r ? L("\x1B[30m", "\x1B[39m") : String,
|
|
641
|
+
red: r ? L("\x1B[31m", "\x1B[39m") : String,
|
|
642
|
+
green: r ? L("\x1B[32m", "\x1B[39m") : String,
|
|
643
|
+
yellow: r ? L("\x1B[33m", "\x1B[39m") : String,
|
|
644
|
+
blue: r ? L("\x1B[34m", "\x1B[39m") : String,
|
|
645
|
+
magenta: r ? L("\x1B[35m", "\x1B[39m") : String,
|
|
646
|
+
cyan: r ? L("\x1B[36m", "\x1B[39m") : String,
|
|
647
|
+
white: r ? L("\x1B[37m", "\x1B[39m") : String,
|
|
648
|
+
gray: r ? L("\x1B[90m", "\x1B[39m") : String,
|
|
649
|
+
bgBlack: r ? L("\x1B[40m", "\x1B[49m") : String,
|
|
650
|
+
bgRed: r ? L("\x1B[41m", "\x1B[49m") : String,
|
|
651
|
+
bgGreen: r ? L("\x1B[42m", "\x1B[49m") : String,
|
|
652
|
+
bgYellow: r ? L("\x1B[43m", "\x1B[49m") : String,
|
|
653
|
+
bgBlue: r ? L("\x1B[44m", "\x1B[49m") : String,
|
|
654
|
+
bgMagenta: r ? L("\x1B[45m", "\x1B[49m") : String,
|
|
655
|
+
bgCyan: r ? L("\x1B[46m", "\x1B[49m") : String,
|
|
656
|
+
bgWhite: r ? L("\x1B[47m", "\x1B[49m") : String
|
|
672
657
|
};
|
|
673
658
|
}
|
|
674
|
-
const D =
|
|
675
|
-
[
|
|
676
|
-
[
|
|
677
|
-
[
|
|
678
|
-
[
|
|
679
|
-
[
|
|
680
|
-
},
|
|
681
|
-
[
|
|
682
|
-
[
|
|
683
|
-
[
|
|
684
|
-
[
|
|
685
|
-
[
|
|
686
|
-
},
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
],
|
|
693
|
-
[
|
|
694
|
-
[
|
|
695
|
-
[
|
|
696
|
-
[
|
|
697
|
-
[
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
],
|
|
705
|
-
function
|
|
659
|
+
const D = Ln(), $e = {
|
|
660
|
+
[x.Error]: F.Error,
|
|
661
|
+
[x.Warning]: F.Warning,
|
|
662
|
+
[x.Log]: F.Log,
|
|
663
|
+
[x.Verbose]: F.Verbose,
|
|
664
|
+
[x.Debug]: F.Debug
|
|
665
|
+
}, Rn = {
|
|
666
|
+
[F.Error]: x.Error,
|
|
667
|
+
[F.Warning]: x.Warning,
|
|
668
|
+
[F.Log]: x.Log,
|
|
669
|
+
[F.Verbose]: x.Verbose,
|
|
670
|
+
[F.Debug]: x.Debug
|
|
671
|
+
}, vt = [
|
|
672
|
+
x.Error,
|
|
673
|
+
x.Warning,
|
|
674
|
+
x.Log,
|
|
675
|
+
x.Verbose,
|
|
676
|
+
x.Debug
|
|
677
|
+
], Tn = {
|
|
678
|
+
[F.Error]: D.red,
|
|
679
|
+
[F.Warning]: D.yellow,
|
|
680
|
+
[F.Log]: D.blue,
|
|
681
|
+
[F.Verbose]: D.cyan,
|
|
682
|
+
[F.Debug]: D.green
|
|
683
|
+
}, Ie = [
|
|
684
|
+
F.Error,
|
|
685
|
+
F.Warning,
|
|
686
|
+
F.Log,
|
|
687
|
+
F.Verbose,
|
|
688
|
+
F.Debug
|
|
689
|
+
], yt = [te.JSON, te.Pretty];
|
|
690
|
+
function Bn(r) {
|
|
706
691
|
return r.stack == null ? [] : r.stack.split(`
|
|
707
692
|
`).map((e) => e.trim()).slice(1).filter((e) => !!/^at (.*)( \(.*:(\d+):(\d+)\))|at (.*)(:(\d+):(\d+))/i.exec(e)).map((e) => {
|
|
708
693
|
const t = /at (.*)( \((.*):(\d+):(\d+)\))|at (.*)(:(\d+):(\d+))/i.exec(e);
|
|
@@ -725,10 +710,10 @@ function Ln(r) {
|
|
|
725
710
|
};
|
|
726
711
|
});
|
|
727
712
|
}
|
|
728
|
-
function
|
|
713
|
+
function Yt(r) {
|
|
729
714
|
return r == null ? !1 : r instanceof Error;
|
|
730
715
|
}
|
|
731
|
-
function
|
|
716
|
+
function Zt(r, e, t, n, a) {
|
|
732
717
|
let i = { context: "" };
|
|
733
718
|
typeof t < "u" && t !== null && (i = { ...t }), typeof e < "u" && e !== null && (i.context = e);
|
|
734
719
|
const s = /* @__PURE__ */ new Date();
|
|
@@ -740,11 +725,11 @@ function Yt(r, e, t, n, a) {
|
|
|
740
725
|
message: n
|
|
741
726
|
};
|
|
742
727
|
}
|
|
743
|
-
function
|
|
744
|
-
const s =
|
|
728
|
+
function Dn(r, e, t, n, a, i) {
|
|
729
|
+
const s = Zt(r, e, t, n, i);
|
|
745
730
|
return typeof a < "u" && a !== null && (s.errored = !0, s.error = { stack: a }), s;
|
|
746
731
|
}
|
|
747
|
-
function
|
|
732
|
+
function wt(r) {
|
|
748
733
|
let e = "";
|
|
749
734
|
switch (typeof r) {
|
|
750
735
|
case "number":
|
|
@@ -765,10 +750,10 @@ function yt(r) {
|
|
|
765
750
|
}
|
|
766
751
|
return e;
|
|
767
752
|
}
|
|
768
|
-
function
|
|
753
|
+
function Ce(r) {
|
|
769
754
|
const e = [];
|
|
770
755
|
e.push(r["@localetime"]), e.push(
|
|
771
|
-
|
|
756
|
+
Tn[$e[r.level]](
|
|
772
757
|
`[${r.level}]`
|
|
773
758
|
)
|
|
774
759
|
);
|
|
@@ -777,83 +762,83 @@ function Ie(r) {
|
|
|
777
762
|
const n = Object.entries(r.fields);
|
|
778
763
|
n.length > 0 && e.push(" {");
|
|
779
764
|
for (const [i, s] of n) {
|
|
780
|
-
let
|
|
781
|
-
if (
|
|
782
|
-
if (s.message && (
|
|
765
|
+
let o = s;
|
|
766
|
+
if (Yt(s)) {
|
|
767
|
+
if (s.message && (o = wt(s.message)), o || (o = ""), s.cause != null)
|
|
783
768
|
try {
|
|
784
|
-
|
|
769
|
+
o += JSON.stringify(s.cause);
|
|
785
770
|
} catch {
|
|
786
|
-
|
|
771
|
+
o += String(s.cause);
|
|
787
772
|
}
|
|
788
773
|
} else
|
|
789
|
-
|
|
790
|
-
e.push(`${D.gray(i)}${D.gray("=")}${
|
|
774
|
+
o = wt(s);
|
|
775
|
+
e.push(`${D.gray(i)}${D.gray("=")}${o}`);
|
|
791
776
|
}
|
|
792
777
|
n.length > 0 && e.push("}");
|
|
793
778
|
let a = e.join(" ");
|
|
794
779
|
return r.errored != null && r.errored && r.error && r.error.stack != null && r.error.stack && (a += `
|
|
795
780
|
${r.error.stack}`), a;
|
|
796
781
|
}
|
|
797
|
-
function Bn(r) {
|
|
798
|
-
return r >= M.Debug;
|
|
799
|
-
}
|
|
800
|
-
function Dn(r) {
|
|
801
|
-
return r >= M.Verbose;
|
|
802
|
-
}
|
|
803
782
|
function On(r) {
|
|
804
|
-
return r >=
|
|
783
|
+
return r >= F.Debug;
|
|
805
784
|
}
|
|
806
785
|
function Nn(r) {
|
|
807
|
-
return r >=
|
|
786
|
+
return r >= F.Verbose;
|
|
808
787
|
}
|
|
809
788
|
function Un(r) {
|
|
810
|
-
return r >=
|
|
789
|
+
return r >= F.Log;
|
|
790
|
+
}
|
|
791
|
+
function zn(r) {
|
|
792
|
+
return r >= F.Warning;
|
|
811
793
|
}
|
|
812
|
-
function
|
|
794
|
+
function Vn(r) {
|
|
795
|
+
return r >= F.Error;
|
|
796
|
+
}
|
|
797
|
+
function Jt() {
|
|
813
798
|
return typeof window < "u";
|
|
814
799
|
}
|
|
815
|
-
function
|
|
816
|
-
return !
|
|
800
|
+
function $n() {
|
|
801
|
+
return !Jt() && Ge() === te.Pretty;
|
|
817
802
|
}
|
|
818
|
-
function
|
|
819
|
-
return
|
|
803
|
+
function Gn(r, e) {
|
|
804
|
+
return $n() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
|
|
820
805
|
}
|
|
821
|
-
const
|
|
806
|
+
const Ae = {
|
|
822
807
|
configured: !1,
|
|
823
|
-
logLevel:
|
|
808
|
+
logLevel: F.Debug,
|
|
824
809
|
format: te.JSON,
|
|
825
810
|
timeFormatter: (r) => r.toISOString()
|
|
826
811
|
};
|
|
827
812
|
function At() {
|
|
828
|
-
return
|
|
813
|
+
return Ae.logLevel;
|
|
829
814
|
}
|
|
830
|
-
function
|
|
831
|
-
if (
|
|
832
|
-
|
|
815
|
+
function Wn(r) {
|
|
816
|
+
if (Ie.includes(r))
|
|
817
|
+
Ae.logLevel = r;
|
|
833
818
|
else
|
|
834
819
|
throw new Error(
|
|
835
|
-
`log level ${r} is not available. available log levels are: ${
|
|
820
|
+
`log level ${r} is not available. available log levels are: ${Ie.join(
|
|
836
821
|
", "
|
|
837
822
|
)}`
|
|
838
823
|
);
|
|
839
|
-
|
|
824
|
+
Ae.configured = !0;
|
|
840
825
|
}
|
|
841
|
-
function
|
|
842
|
-
return
|
|
826
|
+
function Ge() {
|
|
827
|
+
return Ae.format;
|
|
843
828
|
}
|
|
844
829
|
function qn() {
|
|
845
|
-
return
|
|
830
|
+
return Ae.timeFormatter;
|
|
846
831
|
}
|
|
847
832
|
function Qt(r) {
|
|
848
833
|
const e = {
|
|
849
834
|
fields: {},
|
|
850
835
|
context: r,
|
|
851
|
-
logLevel:
|
|
836
|
+
logLevel: F.Debug,
|
|
852
837
|
format: te.JSON,
|
|
853
838
|
shouldUseGlobalConfig: !1,
|
|
854
839
|
errorProcessor: (c) => c,
|
|
855
840
|
timeFormatter: (c) => c.toISOString(),
|
|
856
|
-
useGlobalConfig: () => (e.shouldUseGlobalConfig = !0, e.format =
|
|
841
|
+
useGlobalConfig: () => (e.shouldUseGlobalConfig = !0, e.format = Ge(), e.logLevel = At(), e.child()),
|
|
857
842
|
child: (c) => {
|
|
858
843
|
const u = Qt(e.context);
|
|
859
844
|
return c != null ? u.fields = { ...e.fields, ...c } : u.fields = e.fields, u.fields != null && "context" in u.fields ? u.context = u.fields.context : u.context = e.context, u.logLevel = e.logLevel, u.format = e.format, u.shouldUseGlobalConfig = e.shouldUseGlobalConfig, u;
|
|
@@ -864,13 +849,13 @@ function Qt(r) {
|
|
|
864
849
|
},
|
|
865
850
|
withLogLevel: (c) => {
|
|
866
851
|
const u = e.child();
|
|
867
|
-
if (
|
|
852
|
+
if (Ie.includes(c))
|
|
868
853
|
u.logLevel = c, u.shouldUseGlobalConfig = !1, u.debug(
|
|
869
|
-
`setting log level to ${
|
|
854
|
+
`setting log level to ${Rn[c]} (${c})`
|
|
870
855
|
);
|
|
871
856
|
else
|
|
872
857
|
throw new Error(
|
|
873
|
-
`log level ${c} is not available. available log levels are: ${
|
|
858
|
+
`log level ${c} is not available. available log levels are: ${Ie.join(
|
|
874
859
|
", "
|
|
875
860
|
)}`
|
|
876
861
|
);
|
|
@@ -878,13 +863,13 @@ function Qt(r) {
|
|
|
878
863
|
},
|
|
879
864
|
withLogLevelString: (c) => {
|
|
880
865
|
const u = e.child();
|
|
881
|
-
if (
|
|
882
|
-
u.logLevel =
|
|
883
|
-
`setting log level to ${c} (${
|
|
866
|
+
if (vt.includes(c))
|
|
867
|
+
u.logLevel = $e[c], u.shouldUseGlobalConfig = !1, u.debug(
|
|
868
|
+
`setting log level to ${c} (${$e[c]})`
|
|
884
869
|
);
|
|
885
870
|
else
|
|
886
871
|
throw new Error(
|
|
887
|
-
`log level ${c} is not available. available log levels are: ${
|
|
872
|
+
`log level ${c} is not available. available log levels are: ${vt.join(
|
|
888
873
|
", "
|
|
889
874
|
)}`
|
|
890
875
|
);
|
|
@@ -892,11 +877,11 @@ function Qt(r) {
|
|
|
892
877
|
},
|
|
893
878
|
withFormat: (c) => {
|
|
894
879
|
const u = e.child();
|
|
895
|
-
if (
|
|
880
|
+
if (yt.includes(c))
|
|
896
881
|
u.format = c, u.shouldUseGlobalConfig = !1, u.debug(`setting format to ${c}`);
|
|
897
882
|
else
|
|
898
883
|
throw new Error(
|
|
899
|
-
`format ${c} is not available. available formats are: ${
|
|
884
|
+
`format ${c} is not available. available formats are: ${yt.join(
|
|
900
885
|
", "
|
|
901
886
|
)}`
|
|
902
887
|
);
|
|
@@ -909,7 +894,7 @@ function Qt(r) {
|
|
|
909
894
|
return e.child({ [c]: u });
|
|
910
895
|
},
|
|
911
896
|
withError: (c) => {
|
|
912
|
-
if (c = e.errorProcessor(c), !
|
|
897
|
+
if (c = e.errorProcessor(c), !Yt(c))
|
|
913
898
|
return e.withField("error", String(c));
|
|
914
899
|
let u = e;
|
|
915
900
|
if (u = u.withField("error", c.message), c.stack != null && (u = u.withField("stack", c.stack)), c.cause != null)
|
|
@@ -921,7 +906,7 @@ function Qt(r) {
|
|
|
921
906
|
return u;
|
|
922
907
|
},
|
|
923
908
|
withCallStack(c) {
|
|
924
|
-
const u =
|
|
909
|
+
const u = Bn(c).slice(2).filter((m) => !m.invalid);
|
|
925
910
|
return u.length === 0 ? e : e.child({
|
|
926
911
|
function: u[0].function,
|
|
927
912
|
file: `${u[0].file}:${u[0].line}:${u[0].column}`,
|
|
@@ -952,97 +937,97 @@ function Qt(r) {
|
|
|
952
937
|
const u = e.child();
|
|
953
938
|
return u.errorProcessor = c, u;
|
|
954
939
|
}
|
|
955
|
-
}, t = () => e.shouldUseGlobalConfig ? At() : e.logLevel, n = () => e.shouldUseGlobalConfig ?
|
|
956
|
-
const
|
|
957
|
-
if (
|
|
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, s = (c, u, m) => {
|
|
941
|
+
const v = n();
|
|
942
|
+
if (Jt() && v === te.Pretty) {
|
|
958
943
|
c.fields = Object.fromEntries(
|
|
959
|
-
Object.entries(c.fields).filter(([b,
|
|
944
|
+
Object.entries(c.fields).filter(([b, E]) => {
|
|
960
945
|
if (b === "isNestSystemModule" || b === "nestSystemModule" || b === "context")
|
|
961
|
-
return [b,
|
|
946
|
+
return [b, E];
|
|
962
947
|
})
|
|
963
948
|
);
|
|
964
|
-
const
|
|
965
|
-
Array.isArray(
|
|
949
|
+
const A = m ?? e.fields;
|
|
950
|
+
Array.isArray(A) && A.length > 0 ? console[u](Ce(c), ...A) : Object.keys(A).length > 0 ? console[u](Ce(c), A) : console[u](Ce(c));
|
|
966
951
|
return;
|
|
967
952
|
}
|
|
968
|
-
const
|
|
969
|
-
console[u](
|
|
970
|
-
}, l = {
|
|
971
|
-
[k.Debug]: Bn,
|
|
972
|
-
[k.Verbose]: Dn,
|
|
973
|
-
[k.Log]: On,
|
|
974
|
-
[k.Warning]: Nn
|
|
953
|
+
const S = v === te.Pretty ? Ce(c) : JSON.stringify(c);
|
|
954
|
+
console[u](S);
|
|
975
955
|
}, o = {
|
|
976
|
-
[
|
|
977
|
-
[
|
|
978
|
-
[
|
|
979
|
-
[
|
|
956
|
+
[x.Debug]: On,
|
|
957
|
+
[x.Verbose]: Nn,
|
|
958
|
+
[x.Log]: Un,
|
|
959
|
+
[x.Warning]: zn
|
|
960
|
+
}, l = {
|
|
961
|
+
[x.Debug]: "debug",
|
|
962
|
+
[x.Verbose]: "log",
|
|
963
|
+
[x.Log]: "log",
|
|
964
|
+
[x.Warning]: "warn"
|
|
980
965
|
}, p = (c, u, m) => {
|
|
981
|
-
const
|
|
982
|
-
if (!v
|
|
966
|
+
const v = t(), S = o[c];
|
|
967
|
+
if (!S(v))
|
|
983
968
|
return;
|
|
984
|
-
const
|
|
969
|
+
const A = i(m), b = Zt(
|
|
985
970
|
c,
|
|
986
971
|
e.context,
|
|
987
|
-
|
|
972
|
+
A,
|
|
988
973
|
u,
|
|
989
974
|
a()
|
|
990
975
|
);
|
|
991
|
-
s(b,
|
|
976
|
+
s(b, l[c], A);
|
|
992
977
|
};
|
|
993
978
|
return e.debug = (c, ...u) => {
|
|
994
|
-
p(
|
|
979
|
+
p(x.Debug, c, u);
|
|
995
980
|
}, e.verbose = (c, ...u) => {
|
|
996
|
-
p(
|
|
981
|
+
p(x.Verbose, c, u);
|
|
997
982
|
}, e.log = (c, ...u) => {
|
|
998
|
-
p(
|
|
983
|
+
p(x.Log, c, u);
|
|
999
984
|
}, e.warn = (c, ...u) => {
|
|
1000
|
-
p(
|
|
985
|
+
p(x.Warning, c, u);
|
|
1001
986
|
}, e.error = (c, u, ...m) => {
|
|
1002
|
-
const
|
|
1003
|
-
if (!
|
|
987
|
+
const v = t();
|
|
988
|
+
if (!Vn(v))
|
|
1004
989
|
return;
|
|
1005
|
-
const
|
|
1006
|
-
|
|
990
|
+
const S = i(m), A = Dn(
|
|
991
|
+
x.Error,
|
|
1007
992
|
e.context,
|
|
1008
|
-
|
|
993
|
+
S,
|
|
1009
994
|
c,
|
|
1010
995
|
u,
|
|
1011
996
|
a()
|
|
1012
997
|
);
|
|
1013
|
-
s(
|
|
998
|
+
s(A, "error", S);
|
|
1014
999
|
}, e.errorWithError = (c, u, ...m) => e.withError(u).error(c, void 0, ...m), e;
|
|
1015
1000
|
}
|
|
1016
|
-
function
|
|
1001
|
+
function Hn(r) {
|
|
1017
1002
|
var i;
|
|
1018
|
-
const t =
|
|
1019
|
-
return r = r ?? `${a}:${t.lineNumber}`, Qt(
|
|
1003
|
+
const t = fn.parse(new Error())[1], n = ((i = t.fileName) == null ? void 0 : i.replace("async", "").trim()) ?? "", a = Ve.join(...n.split(Ve.sep).slice(-2));
|
|
1004
|
+
return r = r ?? `${a}:${t.lineNumber}`, Qt(Gn(n, r));
|
|
1020
1005
|
}
|
|
1021
|
-
const
|
|
1022
|
-
let
|
|
1006
|
+
const jn = (r) => Hn(r).useGlobalConfig();
|
|
1007
|
+
let J = [];
|
|
1023
1008
|
const St = 100;
|
|
1024
|
-
async function
|
|
1025
|
-
if (
|
|
1009
|
+
async function Kn() {
|
|
1010
|
+
if (J.length === 0)
|
|
1026
1011
|
return;
|
|
1027
|
-
const r = [...
|
|
1028
|
-
|
|
1012
|
+
const r = [...J];
|
|
1013
|
+
J = [];
|
|
1029
1014
|
try {
|
|
1030
|
-
await
|
|
1015
|
+
await Xn();
|
|
1031
1016
|
} catch (e) {
|
|
1032
|
-
h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)),
|
|
1017
|
+
h.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)), J.unshift(...r), J.length > St && (J = J.slice(0, St));
|
|
1033
1018
|
}
|
|
1034
1019
|
}
|
|
1035
|
-
async function
|
|
1020
|
+
async function Xn(r) {
|
|
1036
1021
|
}
|
|
1037
|
-
function
|
|
1038
|
-
|
|
1022
|
+
function Yn() {
|
|
1023
|
+
J.length > 0 && Kn(), h.log("[CLS] Cleaned up");
|
|
1039
1024
|
}
|
|
1040
|
-
|
|
1041
|
-
const h =
|
|
1025
|
+
Wn(F.Warning);
|
|
1026
|
+
const h = jn("Web").withErrorProcessor((r) => r).useGlobalConfig(), O = {
|
|
1042
1027
|
config: null,
|
|
1043
1028
|
promise: null
|
|
1044
1029
|
};
|
|
1045
|
-
async function
|
|
1030
|
+
async function Zn(r) {
|
|
1046
1031
|
return O.promise ? (await O.promise, O.config || {}) : O.config ? O.config : (O.promise = (async () => {
|
|
1047
1032
|
try {
|
|
1048
1033
|
const t = typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") ? `/api/config/sdk?version=${r}` : `https://config.spatialwalk.top/sdk?version=${r}`;
|
|
@@ -1059,7 +1044,7 @@ async function Xn(r) {
|
|
|
1059
1044
|
if (!a.endpoints)
|
|
1060
1045
|
throw new Error("Invalid config response: missing endpoints");
|
|
1061
1046
|
const i = {};
|
|
1062
|
-
a.endpoints.cn && (i[
|
|
1047
|
+
a.endpoints.cn && (i[ie.cn] = `https://${a.endpoints.cn}`), a.endpoints.us && (i[ie.us] = `https://${a.endpoints.us}`), a.endpoints.test && (i[ie.test] = `https://${a.endpoints.test}`), O.config = i, h.log("[SdkConfigLoader] SDK config fetched successfully:", i);
|
|
1063
1048
|
} catch {
|
|
1064
1049
|
O.config = {};
|
|
1065
1050
|
} finally {
|
|
@@ -1070,7 +1055,7 @@ async function Xn(r) {
|
|
|
1070
1055
|
function Jn() {
|
|
1071
1056
|
O.config = null, O.promise = null;
|
|
1072
1057
|
}
|
|
1073
|
-
class
|
|
1058
|
+
class Qn {
|
|
1074
1059
|
constructor(e) {
|
|
1075
1060
|
d(this, "module");
|
|
1076
1061
|
d(this, "allocatedPointers");
|
|
@@ -1102,9 +1087,9 @@ class Yn {
|
|
|
1102
1087
|
throw new Error("teethPb is missing or empty!");
|
|
1103
1088
|
if (!e.teethNpz || e.teethNpz.byteLength === 0)
|
|
1104
1089
|
throw new Error("teethNpz is missing or empty!");
|
|
1105
|
-
const a = this.allocateAndCopy(e.flameModel), i = this.allocateAndCopy(e.flameTemplate), s = this.allocateAndCopy(e.teethPb),
|
|
1106
|
-
let
|
|
1107
|
-
return this.module.setValue(n +
|
|
1090
|
+
const a = this.allocateAndCopy(e.flameModel), i = this.allocateAndCopy(e.flameTemplate), s = this.allocateAndCopy(e.teethPb), o = this.allocateAndCopy(e.teethNpz);
|
|
1091
|
+
let l = 0;
|
|
1092
|
+
return this.module.setValue(n + l, a.ptr, "i32"), l += 4, this.module.setValue(n + l, a.size, "i32"), l += 4, this.module.setValue(n + l, i.ptr, "i32"), l += 4, this.module.setValue(n + l, i.size, "i32"), l += 4, this.module.setValue(n + l, s.ptr, "i32"), l += 4, this.module.setValue(n + l, s.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, 0, "i32"), l += 4, this.module.setValue(n + l, 0, "i32"), l += 4, this.structPointers.set("template_config", n), n;
|
|
1108
1093
|
}
|
|
1109
1094
|
/**
|
|
1110
1095
|
* 创建 AvatarCharacterData 结构体 - 新版 Emscripten 方式
|
|
@@ -1113,11 +1098,11 @@ class Yn {
|
|
|
1113
1098
|
const i = this.module._malloc(16);
|
|
1114
1099
|
if (!i)
|
|
1115
1100
|
throw new Error("Failed to allocate AvatarCharacterData structure");
|
|
1116
|
-
const s = this.allocateAndCopy(e),
|
|
1117
|
-
let
|
|
1118
|
-
this.module.setValue(i +
|
|
1101
|
+
const s = this.allocateAndCopy(e), o = this.allocateAndCopy(t);
|
|
1102
|
+
let l = 0;
|
|
1103
|
+
this.module.setValue(i + l, s.ptr, "i32"), l += 4, this.module.setValue(i + l, s.size, "i32"), l += 4, this.module.setValue(i + l, o.ptr, "i32"), l += 4, this.module.setValue(i + l, o.size, "i32"), l += 4;
|
|
1119
1104
|
const p = n ? `character_data_${n}` : "character_data";
|
|
1120
|
-
return this.structPointers.set(p, i), { dataPtr: i, shapePtr: s.ptr, plyPtr:
|
|
1105
|
+
return this.structPointers.set(p, i), { dataPtr: i, shapePtr: s.ptr, plyPtr: o.ptr };
|
|
1121
1106
|
}
|
|
1122
1107
|
/**
|
|
1123
1108
|
* 读取 AvatarFlameParams 结构体数据
|
|
@@ -1137,12 +1122,12 @@ class Yn {
|
|
|
1137
1122
|
const s = [];
|
|
1138
1123
|
for (let m = 0; m < 3; m++)
|
|
1139
1124
|
s.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1140
|
-
const l = [];
|
|
1141
|
-
for (let m = 0; m < 3; m++)
|
|
1142
|
-
l.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1143
1125
|
const o = [];
|
|
1144
1126
|
for (let m = 0; m < 3; m++)
|
|
1145
1127
|
o.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1128
|
+
const l = [];
|
|
1129
|
+
for (let m = 0; m < 3; m++)
|
|
1130
|
+
l.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1146
1131
|
const p = [];
|
|
1147
1132
|
for (let m = 0; m < 6; m++)
|
|
1148
1133
|
p.push(this.module.getValue(e + t, "float")), t += 4;
|
|
@@ -1155,8 +1140,8 @@ class Yn {
|
|
|
1155
1140
|
expr_params: a,
|
|
1156
1141
|
rotation: i,
|
|
1157
1142
|
translation: s,
|
|
1158
|
-
neck_pose:
|
|
1159
|
-
jaw_pose:
|
|
1143
|
+
neck_pose: o,
|
|
1144
|
+
jaw_pose: l,
|
|
1160
1145
|
eyes_pose: p,
|
|
1161
1146
|
eyelid: c,
|
|
1162
1147
|
has_eyelid: u
|
|
@@ -1166,42 +1151,42 @@ class Yn {
|
|
|
1166
1151
|
* 创建 AvatarFlameParams 结构体 - 新版 Emscripten 方式
|
|
1167
1152
|
*/
|
|
1168
1153
|
createFlameParams(e) {
|
|
1169
|
-
var i, s,
|
|
1154
|
+
var i, s, o, l, p, c, u, m;
|
|
1170
1155
|
const n = this.module._malloc(1684);
|
|
1171
1156
|
if (!n)
|
|
1172
1157
|
throw new Error("Failed to allocate AvatarFlameParams structure");
|
|
1173
1158
|
let a = 0;
|
|
1174
|
-
for (let
|
|
1175
|
-
const
|
|
1176
|
-
this.module.setValue(n + a,
|
|
1159
|
+
for (let v = 0; v < 300; v++) {
|
|
1160
|
+
const S = ((i = e.shape_params) == null ? void 0 : i[v]) || 0;
|
|
1161
|
+
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1177
1162
|
}
|
|
1178
|
-
for (let
|
|
1179
|
-
const
|
|
1180
|
-
this.module.setValue(n + a,
|
|
1163
|
+
for (let v = 0; v < 100; v++) {
|
|
1164
|
+
const S = ((s = e.expr_params) == null ? void 0 : s[v]) || 0;
|
|
1165
|
+
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1181
1166
|
}
|
|
1182
|
-
for (let
|
|
1183
|
-
const
|
|
1184
|
-
this.module.setValue(n + a,
|
|
1167
|
+
for (let v = 0; v < 3; v++) {
|
|
1168
|
+
const S = ((o = e.rotation) == null ? void 0 : o[v]) || 0;
|
|
1169
|
+
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1185
1170
|
}
|
|
1186
|
-
for (let
|
|
1187
|
-
const
|
|
1188
|
-
this.module.setValue(n + a,
|
|
1171
|
+
for (let v = 0; v < 3; v++) {
|
|
1172
|
+
const S = ((l = e.translation) == null ? void 0 : l[v]) || 0;
|
|
1173
|
+
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1189
1174
|
}
|
|
1190
|
-
for (let
|
|
1191
|
-
const
|
|
1192
|
-
this.module.setValue(n + a,
|
|
1175
|
+
for (let v = 0; v < 3; v++) {
|
|
1176
|
+
const S = ((p = e.neck_pose) == null ? void 0 : p[v]) || 0;
|
|
1177
|
+
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1193
1178
|
}
|
|
1194
|
-
for (let
|
|
1195
|
-
const
|
|
1196
|
-
this.module.setValue(n + a,
|
|
1179
|
+
for (let v = 0; v < 3; v++) {
|
|
1180
|
+
const S = ((c = e.jaw_pose) == null ? void 0 : c[v]) || 0;
|
|
1181
|
+
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1197
1182
|
}
|
|
1198
|
-
for (let
|
|
1199
|
-
const
|
|
1200
|
-
this.module.setValue(n + a,
|
|
1183
|
+
for (let v = 0; v < 6; v++) {
|
|
1184
|
+
const S = ((u = e.eyes_pose) == null ? void 0 : u[v]) || 0;
|
|
1185
|
+
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1201
1186
|
}
|
|
1202
|
-
for (let
|
|
1203
|
-
const
|
|
1204
|
-
this.module.setValue(n + a,
|
|
1187
|
+
for (let v = 0; v < 2; v++) {
|
|
1188
|
+
const S = ((m = e.eyelid) == null ? void 0 : m[v]) || 0;
|
|
1189
|
+
this.module.setValue(n + a, S, "float"), a += 4;
|
|
1205
1190
|
}
|
|
1206
1191
|
return this.module.setValue(n + a, e.has_eyelid ? 1 : 0, "i32"), a += 4, n;
|
|
1207
1192
|
}
|
|
@@ -1226,14 +1211,14 @@ class Yn {
|
|
|
1226
1211
|
const t = this.module.getValue(e, "i32"), n = this.module.getValue(e + 4, "i32");
|
|
1227
1212
|
if (n === 0 || !t)
|
|
1228
1213
|
return null;
|
|
1229
|
-
const i = n * 13, s = t / 4,
|
|
1230
|
-
return
|
|
1214
|
+
const i = n * 13, s = t / 4, o = new Float32Array(i);
|
|
1215
|
+
return o.set(this.module.HEAPF32.subarray(s, s + i)), o;
|
|
1231
1216
|
}
|
|
1232
1217
|
/**
|
|
1233
1218
|
* 读取AvatarMeshData结构体数据
|
|
1234
1219
|
*/
|
|
1235
1220
|
readMeshData(e) {
|
|
1236
|
-
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"), s = this.module.getValue(e + 16, "float"),
|
|
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"), s = this.module.getValue(e + 16, "float"), o = this.module.getValue(e + 20, "*"), l = this.module.getValue(e + 24, "i32"), p = new Float32Array(n * 3);
|
|
1237
1222
|
if (t && n > 0)
|
|
1238
1223
|
for (let m = 0; m < n * 3; m++)
|
|
1239
1224
|
p[m] = this.module.getValue(t + m * 4, "float");
|
|
@@ -1242,10 +1227,10 @@ class Yn {
|
|
|
1242
1227
|
for (let m = 0; m < i * 3; m++)
|
|
1243
1228
|
c[m] = this.module.getValue(a + m * 4, "i32");
|
|
1244
1229
|
let u = null;
|
|
1245
|
-
if (
|
|
1246
|
-
u = new Float32Array(
|
|
1247
|
-
for (let m = 0; m <
|
|
1248
|
-
u[m] = this.module.getValue(
|
|
1230
|
+
if (o && l > 0) {
|
|
1231
|
+
u = new Float32Array(l * 3);
|
|
1232
|
+
for (let m = 0; m < l * 3; m++)
|
|
1233
|
+
u[m] = this.module.getValue(o + m * 4, "float");
|
|
1249
1234
|
}
|
|
1250
1235
|
return {
|
|
1251
1236
|
vertices: p,
|
|
@@ -1253,7 +1238,7 @@ class Yn {
|
|
|
1253
1238
|
faces: c,
|
|
1254
1239
|
faceCount: i,
|
|
1255
1240
|
landmarks: u,
|
|
1256
|
-
landmarkCount:
|
|
1241
|
+
landmarkCount: l,
|
|
1257
1242
|
computeTime: s
|
|
1258
1243
|
};
|
|
1259
1244
|
}
|
|
@@ -1292,7 +1277,7 @@ class Yn {
|
|
|
1292
1277
|
};
|
|
1293
1278
|
}
|
|
1294
1279
|
}
|
|
1295
|
-
class
|
|
1280
|
+
class ea {
|
|
1296
1281
|
constructor(e = {}) {
|
|
1297
1282
|
// 配置
|
|
1298
1283
|
d(this, "options");
|
|
@@ -1367,7 +1352,7 @@ class Zn {
|
|
|
1367
1352
|
async loadWASMModule() {
|
|
1368
1353
|
try {
|
|
1369
1354
|
const { default: e } = await import("./avatar_core_wasm-BPIbbUx_.js");
|
|
1370
|
-
this.wasmConfig && Object.keys(this.wasmConfig).length > 0 ? this.wasmModule = await e(this.wasmConfig) : this.wasmModule = await e(), this.validateWASMModule(), this.memoryManager = new
|
|
1355
|
+
this.wasmConfig && Object.keys(this.wasmConfig).length > 0 ? this.wasmModule = await e(this.wasmConfig) : this.wasmModule = await e(), this.validateWASMModule(), this.memoryManager = new Qn(this.wasmModule), this.setupCAPIFunctions(), h.log("✅ Created new WASM instance with clean C++ memory");
|
|
1371
1356
|
} catch (e) {
|
|
1372
1357
|
const t = e instanceof Error ? e.message : String(e);
|
|
1373
1358
|
throw new Error(`Failed to load WASM module: ${t}`);
|
|
@@ -1510,21 +1495,21 @@ class Zn {
|
|
|
1510
1495
|
throw new Error("Avatar Core not initialized");
|
|
1511
1496
|
const a = performance.now();
|
|
1512
1497
|
try {
|
|
1513
|
-
const { dataPtr: i, shapePtr: s, plyPtr:
|
|
1498
|
+
const { dataPtr: i, shapePtr: s, plyPtr: o } = this.memoryManager.createCharacterData(
|
|
1514
1499
|
e,
|
|
1515
1500
|
t,
|
|
1516
1501
|
n
|
|
1517
|
-
),
|
|
1518
|
-
if (!
|
|
1519
|
-
this.memoryManager.free(s), this.memoryManager.free(
|
|
1502
|
+
), l = this.api.loadCharacter(this.coreHandle, i);
|
|
1503
|
+
if (!l) {
|
|
1504
|
+
this.memoryManager.free(s), this.memoryManager.free(o);
|
|
1520
1505
|
const u = n ? `character_data_${n}` : "character_data";
|
|
1521
1506
|
throw this.memoryManager.freeStruct(u), new Error("avatar_core_load_character returned NULL - character loading failed");
|
|
1522
1507
|
}
|
|
1523
|
-
this.memoryManager.free(s), this.memoryManager.free(
|
|
1508
|
+
this.memoryManager.free(s), this.memoryManager.free(o);
|
|
1524
1509
|
const p = n ? `character_data_${n}` : "character_data";
|
|
1525
1510
|
this.memoryManager.freeStruct(p);
|
|
1526
1511
|
const c = n || "default";
|
|
1527
|
-
return this.characterHandles.set(c,
|
|
1512
|
+
return this.characterHandles.set(c, l), !n || c === "default" ? (this.characterHandle = l, this.isCharacterLoaded = !0, await this.queryCharacterInfo()) : this.characterHandle || (this.characterHandle = l, this.isCharacterLoaded = !0), this.performanceMetrics.loadTime = performance.now() - a, l;
|
|
1528
1513
|
} catch (i) {
|
|
1529
1514
|
h.errorWithError("❌ Character loading failed:", i);
|
|
1530
1515
|
const s = i instanceof Error ? i.message : String(i);
|
|
@@ -1607,22 +1592,22 @@ class Zn {
|
|
|
1607
1592
|
const s = (a == null ? void 0 : a.totalFrames) ?? this.totalFrames;
|
|
1608
1593
|
s !== null && s > 0 && (e = e % s, e < 0 && (e += s));
|
|
1609
1594
|
try {
|
|
1610
|
-
const
|
|
1595
|
+
const l = this.wasmModule._malloc(1684), p = this.api.getFrameFromAnimation(i, e, l);
|
|
1611
1596
|
if (p !== 0) {
|
|
1612
|
-
this.wasmModule._free(
|
|
1597
|
+
this.wasmModule._free(l);
|
|
1613
1598
|
const u = this.api.getErrorString(p);
|
|
1614
1599
|
throw new Error(`Failed to get frame ${e}: ${u}`);
|
|
1615
1600
|
}
|
|
1616
1601
|
const c = this.characterHandles.get(n) || this.characterHandle;
|
|
1617
1602
|
if (c) {
|
|
1618
|
-
const u = this.api.getCharacterShapeParams(c,
|
|
1603
|
+
const u = this.api.getCharacterShapeParams(c, l);
|
|
1619
1604
|
u !== 0 && h.warn(`Failed to get character shape params: ${this.api.getErrorString(u)}`);
|
|
1620
1605
|
}
|
|
1621
|
-
return
|
|
1622
|
-
} catch (
|
|
1623
|
-
h.errorWithError(`❌ Failed to get animation frame ${e}:`,
|
|
1624
|
-
const
|
|
1625
|
-
throw new Error(`Failed to get animation frame ${e}: ${
|
|
1606
|
+
return l;
|
|
1607
|
+
} catch (o) {
|
|
1608
|
+
h.errorWithError(`❌ Failed to get animation frame ${e}:`, o);
|
|
1609
|
+
const l = o instanceof Error ? o.message : String(o);
|
|
1610
|
+
throw new Error(`Failed to get animation frame ${e}: ${l}`);
|
|
1626
1611
|
}
|
|
1627
1612
|
}
|
|
1628
1613
|
/**
|
|
@@ -1684,8 +1669,8 @@ class Zn {
|
|
|
1684
1669
|
n
|
|
1685
1670
|
);
|
|
1686
1671
|
this.checkError(a, "avatar_core_get_flame_info");
|
|
1687
|
-
const i = this.wasmModule.getValue(e, "i32"), s = this.wasmModule.getValue(t, "i32"),
|
|
1688
|
-
this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: i, faceCount: s, jointCount:
|
|
1672
|
+
const i = this.wasmModule.getValue(e, "i32"), s = this.wasmModule.getValue(t, "i32"), o = this.wasmModule.getValue(n, "i32");
|
|
1673
|
+
this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: i, faceCount: s, jointCount: o };
|
|
1689
1674
|
} catch (e) {
|
|
1690
1675
|
const t = e instanceof Error ? e.message : String(e);
|
|
1691
1676
|
h.errorWithError("❌ Failed to query FLAME info:", t);
|
|
@@ -1803,21 +1788,21 @@ class Zn {
|
|
|
1803
1788
|
const n = performance.now();
|
|
1804
1789
|
let a = null, i = null;
|
|
1805
1790
|
try {
|
|
1806
|
-
const s = (e == null ? void 0 : e.frameIndex) ?? 0,
|
|
1807
|
-
let
|
|
1808
|
-
if (
|
|
1809
|
-
for (const [m,
|
|
1810
|
-
if (
|
|
1811
|
-
|
|
1791
|
+
const s = (e == null ? void 0 : e.frameIndex) ?? 0, o = t || this.characterHandle;
|
|
1792
|
+
let l;
|
|
1793
|
+
if (o) {
|
|
1794
|
+
for (const [m, v] of this.characterHandles.entries())
|
|
1795
|
+
if (v === o) {
|
|
1796
|
+
l = m;
|
|
1812
1797
|
break;
|
|
1813
1798
|
}
|
|
1814
|
-
!
|
|
1799
|
+
!l && o === this.characterHandle && (l = "default");
|
|
1815
1800
|
}
|
|
1816
|
-
if (i = await this.getAnimationFrameParams(s,
|
|
1801
|
+
if (i = await this.getAnimationFrameParams(s, l), a = this.wasmModule._malloc(16), !o)
|
|
1817
1802
|
throw new Error("No character loaded");
|
|
1818
1803
|
const p = this.api.computeFrameFlat(
|
|
1819
1804
|
this.coreHandle,
|
|
1820
|
-
|
|
1805
|
+
o,
|
|
1821
1806
|
i,
|
|
1822
1807
|
a
|
|
1823
1808
|
);
|
|
@@ -1826,8 +1811,8 @@ class Zn {
|
|
|
1826
1811
|
return this.wasmTime = u, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += u, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, c;
|
|
1827
1812
|
} catch (s) {
|
|
1828
1813
|
h.errorWithError("❌ computeCompleteFrameFlat failed:", s);
|
|
1829
|
-
const
|
|
1830
|
-
throw new Error(`computeCompleteFrameFlat failed: ${
|
|
1814
|
+
const o = s instanceof Error ? s.message : String(s);
|
|
1815
|
+
throw new Error(`computeCompleteFrameFlat failed: ${o}`);
|
|
1831
1816
|
} finally {
|
|
1832
1817
|
a !== null && (this.api.freeSplatPointsFlat(a), this.wasmModule._free(a)), i !== null && this.wasmModule._free(i);
|
|
1833
1818
|
}
|
|
@@ -1851,19 +1836,19 @@ class Zn {
|
|
|
1851
1836
|
const s = t || this.characterHandle;
|
|
1852
1837
|
if (!s)
|
|
1853
1838
|
throw new Error("No character loaded");
|
|
1854
|
-
const
|
|
1839
|
+
const o = this.api.computeFrameFlat(
|
|
1855
1840
|
this.coreHandle,
|
|
1856
1841
|
s,
|
|
1857
1842
|
i,
|
|
1858
1843
|
a
|
|
1859
1844
|
);
|
|
1860
|
-
this.checkError(
|
|
1861
|
-
const
|
|
1862
|
-
return this.wasmTime = p, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += p, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames,
|
|
1845
|
+
this.checkError(o, "avatar_core_compute_frame_as_splat_points_flat");
|
|
1846
|
+
const l = this.memoryManager.readSplatPointFlatArray(a), p = performance.now() - n;
|
|
1847
|
+
return this.wasmTime = p, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += p, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, l;
|
|
1863
1848
|
} catch (s) {
|
|
1864
1849
|
h.errorWithError("❌ computeFrameFlatFromParams failed:", s);
|
|
1865
|
-
const
|
|
1866
|
-
throw new Error(`computeFrameFlatFromParams failed: ${
|
|
1850
|
+
const o = s instanceof Error ? s.message : String(s);
|
|
1851
|
+
throw new Error(`computeFrameFlatFromParams failed: ${o}`);
|
|
1867
1852
|
} finally {
|
|
1868
1853
|
a !== null && (this.api.freeSplatPointsFlat(a), this.wasmModule._free(a)), i !== null && this.wasmModule._free(i);
|
|
1869
1854
|
}
|
|
@@ -1886,7 +1871,7 @@ class Zn {
|
|
|
1886
1871
|
return null;
|
|
1887
1872
|
}
|
|
1888
1873
|
}
|
|
1889
|
-
class
|
|
1874
|
+
class y {
|
|
1890
1875
|
/**
|
|
1891
1876
|
* SDK 初始化
|
|
1892
1877
|
* @param appId 前端需要在 HTTP Headers 和 WebSocket Headers 中都带上
|
|
@@ -1916,7 +1901,7 @@ class S {
|
|
|
1916
1901
|
*/
|
|
1917
1902
|
static async initializeWASMModule() {
|
|
1918
1903
|
try {
|
|
1919
|
-
h.log("[AvatarKit] Initializing WASM module..."), this._avatarCore = new
|
|
1904
|
+
h.log("[AvatarKit] Initializing WASM module..."), this._avatarCore = new ea({
|
|
1920
1905
|
logLevel: "basic",
|
|
1921
1906
|
enableValidation: !0,
|
|
1922
1907
|
enablePerformanceMetrics: !0,
|
|
@@ -2005,7 +1990,7 @@ class S {
|
|
|
2005
1990
|
static cleanup() {
|
|
2006
1991
|
if (this._isInitialized)
|
|
2007
1992
|
try {
|
|
2008
|
-
this._avatarCore && (this._avatarCore.release(), this._avatarCore = null), this._appId = null, this._configuration = null, this._sessionToken = null, this._userId = null, this._dynamicSdkConfig = null, this._isInitialized = !1, Jn(),
|
|
1993
|
+
this._avatarCore && (this._avatarCore.release(), this._avatarCore = null), this._appId = null, this._configuration = null, this._sessionToken = null, this._userId = null, this._dynamicSdkConfig = null, this._isInitialized = !1, Jn(), Yn(), h.log("[AvatarKit] Cleanup completed");
|
|
2009
1994
|
} catch (e) {
|
|
2010
1995
|
h.error("Failed to cleanup AvatarKit:", e instanceof Error ? e.message : String(e));
|
|
2011
1996
|
}
|
|
@@ -2015,7 +2000,7 @@ class S {
|
|
|
2015
2000
|
*/
|
|
2016
2001
|
static async _fetchSdkConfig() {
|
|
2017
2002
|
try {
|
|
2018
|
-
this._dynamicSdkConfig = await
|
|
2003
|
+
this._dynamicSdkConfig = await Zn(this._version);
|
|
2019
2004
|
} catch (e) {
|
|
2020
2005
|
const t = e instanceof Error ? e.message : String(e);
|
|
2021
2006
|
h.warn("Failed to fetch SDK config from remote, using defaults:", t), this.logEvent("sdk_config", "warning", {
|
|
@@ -2032,15 +2017,15 @@ class S {
|
|
|
2032
2017
|
if (!this._configuration)
|
|
2033
2018
|
throw new Error("AvatarKit not initialized");
|
|
2034
2019
|
const t = {
|
|
2035
|
-
[
|
|
2020
|
+
[ie.cn]: {
|
|
2036
2021
|
sdkApiBaseUrl: "https://api.spatialwalk.top",
|
|
2037
2022
|
driveningressWsUrl: "wss://api.spatialwalk.top/v1/driveningress/websocket"
|
|
2038
2023
|
},
|
|
2039
|
-
[
|
|
2024
|
+
[ie.us]: {
|
|
2040
2025
|
sdkApiBaseUrl: "https://api.spatialwalk.cloud",
|
|
2041
2026
|
driveningressWsUrl: "wss://api.spatialwalk.cloud/v1/driveningress/websocket"
|
|
2042
2027
|
},
|
|
2043
|
-
[
|
|
2028
|
+
[ie.test]: {
|
|
2044
2029
|
sdkApiBaseUrl: "https://api-test.spatialwalk.top",
|
|
2045
2030
|
driveningressWsUrl: "wss://api-test.spatialwalk.top/v1/driveningress/websocket"
|
|
2046
2031
|
}
|
|
@@ -2069,18 +2054,18 @@ class S {
|
|
|
2069
2054
|
h[i](`[Telemetry] ${e}`, a);
|
|
2070
2055
|
}
|
|
2071
2056
|
}
|
|
2072
|
-
d(
|
|
2057
|
+
d(y, "_isInitialized", !1), d(y, "_appId", null), d(y, "_configuration", null), d(y, "_sessionToken", null), d(y, "_userId", null), d(y, "_version", "1.0.0-beta.18"), d(y, "_avatarCore", null), d(y, "_dynamicSdkConfig", null), d(y, "_logLevels", {
|
|
2073
2058
|
debug: "log",
|
|
2074
2059
|
info: "log",
|
|
2075
2060
|
warning: "warn",
|
|
2076
2061
|
error: "error"
|
|
2077
2062
|
});
|
|
2078
|
-
const
|
|
2063
|
+
const we = class we {
|
|
2079
2064
|
constructor() {
|
|
2080
2065
|
d(this, "audio", null);
|
|
2081
2066
|
d(this, "streamingPlayer", null);
|
|
2082
2067
|
d(this, "_isPlaying", !1);
|
|
2083
|
-
d(this, "fps",
|
|
2068
|
+
d(this, "fps", I.animation.fps);
|
|
2084
2069
|
d(this, "onEndedCallback");
|
|
2085
2070
|
d(this, "useStreaming", !1);
|
|
2086
2071
|
}
|
|
@@ -2089,10 +2074,10 @@ const _e = class _e {
|
|
|
2089
2074
|
* 必须在用户交互事件(如 click)中调用
|
|
2090
2075
|
*/
|
|
2091
2076
|
static async unlockAudioContext() {
|
|
2092
|
-
if (!
|
|
2077
|
+
if (!we.audioUnlocked)
|
|
2093
2078
|
try {
|
|
2094
2079
|
const e = new Audio();
|
|
2095
|
-
e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", e.volume = 0, await e.play(), e.pause(), e.currentTime = 0,
|
|
2080
|
+
e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", e.volume = 0, await e.play(), e.pause(), e.currentTime = 0, we.audioUnlocked = !0, h.log("✅ Audio context unlocked for Safari");
|
|
2096
2081
|
} catch (e) {
|
|
2097
2082
|
h.warn("⚠️ Failed to unlock audio context:", e);
|
|
2098
2083
|
}
|
|
@@ -2138,9 +2123,9 @@ const _e = class _e {
|
|
|
2138
2123
|
async createAndInitializeStreamingPlayer() {
|
|
2139
2124
|
if (this.streamingPlayer)
|
|
2140
2125
|
return;
|
|
2141
|
-
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-
|
|
2126
|
+
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-D5P7mU8B.js");
|
|
2142
2127
|
this.streamingPlayer = new e({
|
|
2143
|
-
sampleRate:
|
|
2128
|
+
sampleRate: I.audio.sampleRate,
|
|
2144
2129
|
channelCount: 1,
|
|
2145
2130
|
debug: !1
|
|
2146
2131
|
});
|
|
@@ -2148,7 +2133,7 @@ const _e = class _e {
|
|
|
2148
2133
|
await this.streamingPlayer.initialize();
|
|
2149
2134
|
} catch (t) {
|
|
2150
2135
|
const n = t instanceof Error ? t.message : String(t);
|
|
2151
|
-
throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n),
|
|
2136
|
+
throw h.error("[AnimationPlayer] Failed to initialize streaming player:", n), y.logEvent("character_player", "error", {
|
|
2152
2137
|
event: "streaming_player_initialize_failed",
|
|
2153
2138
|
reason: n
|
|
2154
2139
|
}), t;
|
|
@@ -2227,9 +2212,24 @@ const _e = class _e {
|
|
|
2227
2212
|
this.stop(), this.audio && (this.audio.src = "", this.audio = null), this.streamingPlayer && (this.streamingPlayer.dispose(), this.streamingPlayer = null), this.onEndedCallback = void 0;
|
|
2228
2213
|
}
|
|
2229
2214
|
};
|
|
2230
|
-
d(
|
|
2231
|
-
let
|
|
2232
|
-
|
|
2215
|
+
d(we, "audioUnlocked", !1);
|
|
2216
|
+
let ae = we, ta = (r) => crypto.getRandomValues(new Uint8Array(r)), ra = (r, e, t) => {
|
|
2217
|
+
let n = (2 << Math.log2(r.length - 1)) - 1, a = -~(1.6 * n * e / r.length);
|
|
2218
|
+
return (i = e) => {
|
|
2219
|
+
let s = "";
|
|
2220
|
+
for (; ; ) {
|
|
2221
|
+
let o = t(a), l = a | 0;
|
|
2222
|
+
for (; l--; )
|
|
2223
|
+
if (s += r[o[l] & n] || "", s.length >= i) return s;
|
|
2224
|
+
}
|
|
2225
|
+
};
|
|
2226
|
+
}, na = (r, e = 21) => ra(r, e | 0, ta);
|
|
2227
|
+
const aa = na("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12);
|
|
2228
|
+
function er() {
|
|
2229
|
+
const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), a = String(r.getUTCHours()).padStart(2, "0"), i = String(r.getUTCMinutes()).padStart(2, "0"), s = String(r.getUTCSeconds()).padStart(2, "0"), o = `${e}${t}${n}${a}${i}${s}`, l = aa();
|
|
2230
|
+
return `${o}_${l}`;
|
|
2231
|
+
}
|
|
2232
|
+
function ia() {
|
|
2233
2233
|
let r = 0, e = 0;
|
|
2234
2234
|
for (let n = 0; n < 28; n += 7) {
|
|
2235
2235
|
let a = this.buf[this.pos++];
|
|
@@ -2246,57 +2246,57 @@ function Qn() {
|
|
|
2246
2246
|
}
|
|
2247
2247
|
throw new Error("invalid varint");
|
|
2248
2248
|
}
|
|
2249
|
-
function
|
|
2249
|
+
function Be(r, e, t) {
|
|
2250
2250
|
for (let i = 0; i < 28; i = i + 7) {
|
|
2251
|
-
const s = r >>> i,
|
|
2252
|
-
if (t.push(
|
|
2251
|
+
const s = r >>> i, o = !(!(s >>> 7) && e == 0), l = (o ? s | 128 : s) & 255;
|
|
2252
|
+
if (t.push(l), !o)
|
|
2253
2253
|
return;
|
|
2254
2254
|
}
|
|
2255
2255
|
const n = r >>> 28 & 15 | (e & 7) << 4, a = !!(e >> 3);
|
|
2256
2256
|
if (t.push((a ? n | 128 : n) & 255), !!a) {
|
|
2257
2257
|
for (let i = 3; i < 31; i = i + 7) {
|
|
2258
|
-
const s = e >>> i,
|
|
2259
|
-
if (t.push(
|
|
2258
|
+
const s = e >>> i, o = !!(s >>> 7), l = (o ? s | 128 : s) & 255;
|
|
2259
|
+
if (t.push(l), !o)
|
|
2260
2260
|
return;
|
|
2261
2261
|
}
|
|
2262
2262
|
t.push(e >>> 31 & 1);
|
|
2263
2263
|
}
|
|
2264
2264
|
}
|
|
2265
|
-
const
|
|
2265
|
+
const Pe = 4294967296;
|
|
2266
2266
|
function bt(r) {
|
|
2267
2267
|
const e = r[0] === "-";
|
|
2268
2268
|
e && (r = r.slice(1));
|
|
2269
2269
|
const t = 1e6;
|
|
2270
2270
|
let n = 0, a = 0;
|
|
2271
|
-
function i(s,
|
|
2272
|
-
const
|
|
2273
|
-
a *= t, n = n * t +
|
|
2271
|
+
function i(s, o) {
|
|
2272
|
+
const l = Number(r.slice(s, o));
|
|
2273
|
+
a *= t, n = n * t + l, n >= Pe && (a = a + (n / Pe | 0), n = n % Pe);
|
|
2274
2274
|
}
|
|
2275
|
-
return i(-24, -18), i(-18, -12), i(-12, -6), i(-6), e ?
|
|
2275
|
+
return i(-24, -18), i(-18, -12), i(-12, -6), i(-6), e ? rr(n, a) : je(n, a);
|
|
2276
2276
|
}
|
|
2277
|
-
function
|
|
2278
|
-
let t =
|
|
2277
|
+
function sa(r, e) {
|
|
2278
|
+
let t = je(r, e);
|
|
2279
2279
|
const n = t.hi & 2147483648;
|
|
2280
|
-
n && (t =
|
|
2281
|
-
const a =
|
|
2280
|
+
n && (t = rr(t.lo, t.hi));
|
|
2281
|
+
const a = tr(t.lo, t.hi);
|
|
2282
2282
|
return n ? "-" + a : a;
|
|
2283
2283
|
}
|
|
2284
|
-
function
|
|
2285
|
-
if ({ lo: r, hi: e } =
|
|
2286
|
-
return String(
|
|
2284
|
+
function tr(r, e) {
|
|
2285
|
+
if ({ lo: r, hi: e } = oa(r, e), e <= 2097151)
|
|
2286
|
+
return String(Pe * e + r);
|
|
2287
2287
|
const t = r & 16777215, n = (r >>> 24 | e << 8) & 16777215, a = e >> 16 & 65535;
|
|
2288
|
-
let i = t + n * 6777216 + a * 6710656, s = n + a * 8147497,
|
|
2289
|
-
const
|
|
2290
|
-
return i >=
|
|
2288
|
+
let i = t + n * 6777216 + a * 6710656, s = n + a * 8147497, o = a * 2;
|
|
2289
|
+
const l = 1e7;
|
|
2290
|
+
return i >= l && (s += Math.floor(i / l), i %= l), s >= l && (o += Math.floor(s / l), s %= l), o.toString() + Ct(s) + Ct(i);
|
|
2291
2291
|
}
|
|
2292
|
-
function
|
|
2292
|
+
function oa(r, e) {
|
|
2293
2293
|
return { lo: r >>> 0, hi: e >>> 0 };
|
|
2294
2294
|
}
|
|
2295
|
-
function
|
|
2295
|
+
function je(r, e) {
|
|
2296
2296
|
return { lo: r | 0, hi: e | 0 };
|
|
2297
2297
|
}
|
|
2298
|
-
function
|
|
2299
|
-
return e = ~e, r ? r = ~r + 1 : e += 1,
|
|
2298
|
+
function rr(r, e) {
|
|
2299
|
+
return e = ~e, r ? r = ~r + 1 : e += 1, je(r, e);
|
|
2300
2300
|
}
|
|
2301
2301
|
const Ct = (r) => {
|
|
2302
2302
|
const e = String(r);
|
|
@@ -2313,7 +2313,7 @@ function _t(r, e) {
|
|
|
2313
2313
|
e.push(1);
|
|
2314
2314
|
}
|
|
2315
2315
|
}
|
|
2316
|
-
function
|
|
2316
|
+
function la() {
|
|
2317
2317
|
let r = this.buf[this.pos++], e = r & 127;
|
|
2318
2318
|
if (!(r & 128))
|
|
2319
2319
|
return this.assertBounds(), e;
|
|
@@ -2330,8 +2330,8 @@ function ra() {
|
|
|
2330
2330
|
throw new Error("invalid varint");
|
|
2331
2331
|
return this.assertBounds(), e >>> 0;
|
|
2332
2332
|
}
|
|
2333
|
-
const
|
|
2334
|
-
function
|
|
2333
|
+
const H = /* @__PURE__ */ ca();
|
|
2334
|
+
function ca() {
|
|
2335
2335
|
const r = new DataView(new ArrayBuffer(8));
|
|
2336
2336
|
if (typeof BigInt == "function" && typeof r.getBigInt64 == "function" && typeof r.getBigUint64 == "function" && typeof r.setBigInt64 == "function" && typeof r.setBigUint64 == "function" && (!!globalThis.Deno || typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1")) {
|
|
2337
2337
|
const t = BigInt("-9223372036854775808"), n = BigInt("9223372036854775807"), a = BigInt("0"), i = BigInt("18446744073709551615");
|
|
@@ -2339,16 +2339,16 @@ function na() {
|
|
|
2339
2339
|
zero: BigInt(0),
|
|
2340
2340
|
supported: !0,
|
|
2341
2341
|
parse(s) {
|
|
2342
|
-
const
|
|
2343
|
-
if (
|
|
2342
|
+
const o = typeof s == "bigint" ? s : BigInt(s);
|
|
2343
|
+
if (o > n || o < t)
|
|
2344
2344
|
throw new Error(`invalid int64: ${s}`);
|
|
2345
|
-
return
|
|
2345
|
+
return o;
|
|
2346
2346
|
},
|
|
2347
2347
|
uParse(s) {
|
|
2348
|
-
const
|
|
2349
|
-
if (
|
|
2348
|
+
const o = typeof s == "bigint" ? s : BigInt(s);
|
|
2349
|
+
if (o > i || o < a)
|
|
2350
2350
|
throw new Error(`invalid uint64: ${s}`);
|
|
2351
|
-
return
|
|
2351
|
+
return o;
|
|
2352
2352
|
},
|
|
2353
2353
|
enc(s) {
|
|
2354
2354
|
return r.setBigInt64(0, this.parse(s), !0), {
|
|
@@ -2362,11 +2362,11 @@ function na() {
|
|
|
2362
2362
|
hi: r.getInt32(4, !0)
|
|
2363
2363
|
};
|
|
2364
2364
|
},
|
|
2365
|
-
dec(s,
|
|
2366
|
-
return r.setInt32(0, s, !0), r.setInt32(4,
|
|
2365
|
+
dec(s, o) {
|
|
2366
|
+
return r.setInt32(0, s, !0), r.setInt32(4, o, !0), r.getBigInt64(0, !0);
|
|
2367
2367
|
},
|
|
2368
|
-
uDec(s,
|
|
2369
|
-
return r.setInt32(0, s, !0), r.setInt32(4,
|
|
2368
|
+
uDec(s, o) {
|
|
2369
|
+
return r.setInt32(0, s, !0), r.setInt32(4, o, !0), r.getBigUint64(0, !0);
|
|
2370
2370
|
}
|
|
2371
2371
|
};
|
|
2372
2372
|
}
|
|
@@ -2374,38 +2374,38 @@ function na() {
|
|
|
2374
2374
|
zero: "0",
|
|
2375
2375
|
supported: !1,
|
|
2376
2376
|
parse(t) {
|
|
2377
|
-
return typeof t != "string" && (t = t.toString()),
|
|
2377
|
+
return typeof t != "string" && (t = t.toString()), Pt(t), t;
|
|
2378
2378
|
},
|
|
2379
2379
|
uParse(t) {
|
|
2380
|
-
return typeof t != "string" && (t = t.toString()),
|
|
2380
|
+
return typeof t != "string" && (t = t.toString()), Et(t), t;
|
|
2381
2381
|
},
|
|
2382
2382
|
enc(t) {
|
|
2383
|
-
return typeof t != "string" && (t = t.toString()),
|
|
2383
|
+
return typeof t != "string" && (t = t.toString()), Pt(t), bt(t);
|
|
2384
2384
|
},
|
|
2385
2385
|
uEnc(t) {
|
|
2386
|
-
return typeof t != "string" && (t = t.toString()),
|
|
2386
|
+
return typeof t != "string" && (t = t.toString()), Et(t), bt(t);
|
|
2387
2387
|
},
|
|
2388
2388
|
dec(t, n) {
|
|
2389
|
-
return
|
|
2389
|
+
return sa(t, n);
|
|
2390
2390
|
},
|
|
2391
2391
|
uDec(t, n) {
|
|
2392
|
-
return
|
|
2392
|
+
return tr(t, n);
|
|
2393
2393
|
}
|
|
2394
2394
|
};
|
|
2395
2395
|
}
|
|
2396
|
-
function
|
|
2396
|
+
function Pt(r) {
|
|
2397
2397
|
if (!/^-?[0-9]+$/.test(r))
|
|
2398
2398
|
throw new Error("invalid int64: " + r);
|
|
2399
2399
|
}
|
|
2400
|
-
function
|
|
2400
|
+
function Et(r) {
|
|
2401
2401
|
if (!/^[0-9]+$/.test(r))
|
|
2402
2402
|
throw new Error("invalid uint64: " + r);
|
|
2403
2403
|
}
|
|
2404
|
-
const
|
|
2405
|
-
function
|
|
2406
|
-
if (globalThis[
|
|
2404
|
+
const De = Symbol.for("@bufbuild/protobuf/text-encoding");
|
|
2405
|
+
function nr() {
|
|
2406
|
+
if (globalThis[De] == null) {
|
|
2407
2407
|
const r = new globalThis.TextEncoder(), e = new globalThis.TextDecoder();
|
|
2408
|
-
globalThis[
|
|
2408
|
+
globalThis[De] = {
|
|
2409
2409
|
encodeUtf8(t) {
|
|
2410
2410
|
return r.encode(t);
|
|
2411
2411
|
},
|
|
@@ -2421,15 +2421,15 @@ function rr() {
|
|
|
2421
2421
|
}
|
|
2422
2422
|
};
|
|
2423
2423
|
}
|
|
2424
|
-
return globalThis[
|
|
2424
|
+
return globalThis[De];
|
|
2425
2425
|
}
|
|
2426
2426
|
var ee;
|
|
2427
2427
|
(function(r) {
|
|
2428
2428
|
r[r.Varint = 0] = "Varint", r[r.Bit64 = 1] = "Bit64", r[r.LengthDelimited = 2] = "LengthDelimited", r[r.StartGroup = 3] = "StartGroup", r[r.EndGroup = 4] = "EndGroup", r[r.Bit32 = 5] = "Bit32";
|
|
2429
2429
|
})(ee || (ee = {}));
|
|
2430
|
-
const
|
|
2431
|
-
class
|
|
2432
|
-
constructor(e =
|
|
2430
|
+
const da = 34028234663852886e22, ua = -34028234663852886e22, ha = 4294967295, fa = 2147483647, ma = -2147483648;
|
|
2431
|
+
class oe {
|
|
2432
|
+
constructor(e = nr().encodeUtf8) {
|
|
2433
2433
|
this.encodeUtf8 = e, this.stack = [], this.chunks = [], this.buf = [];
|
|
2434
2434
|
}
|
|
2435
2435
|
/**
|
|
@@ -2492,7 +2492,7 @@ class de {
|
|
|
2492
2492
|
* Write a `int32` value, a signed 32 bit varint.
|
|
2493
2493
|
*/
|
|
2494
2494
|
int32(e) {
|
|
2495
|
-
return
|
|
2495
|
+
return Oe(e), _t(e, this.buf), this;
|
|
2496
2496
|
}
|
|
2497
2497
|
/**
|
|
2498
2498
|
* Write a `bool` value, a variant.
|
|
@@ -2517,7 +2517,7 @@ class de {
|
|
|
2517
2517
|
* Write a `float` value, 32-bit floating point number.
|
|
2518
2518
|
*/
|
|
2519
2519
|
float(e) {
|
|
2520
|
-
|
|
2520
|
+
pa(e);
|
|
2521
2521
|
let t = new Uint8Array(4);
|
|
2522
2522
|
return new DataView(t.buffer).setFloat32(0, e, !0), this.raw(t);
|
|
2523
2523
|
}
|
|
@@ -2540,7 +2540,7 @@ class de {
|
|
|
2540
2540
|
* Write a `sfixed32` value, a signed, fixed-length 32-bit integer.
|
|
2541
2541
|
*/
|
|
2542
2542
|
sfixed32(e) {
|
|
2543
|
-
|
|
2543
|
+
Oe(e);
|
|
2544
2544
|
let t = new Uint8Array(4);
|
|
2545
2545
|
return new DataView(t.buffer).setInt32(0, e, !0), this.raw(t);
|
|
2546
2546
|
}
|
|
@@ -2548,47 +2548,47 @@ class de {
|
|
|
2548
2548
|
* Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.
|
|
2549
2549
|
*/
|
|
2550
2550
|
sint32(e) {
|
|
2551
|
-
return
|
|
2551
|
+
return Oe(e), e = (e << 1 ^ e >> 31) >>> 0, _t(e, this.buf), this;
|
|
2552
2552
|
}
|
|
2553
2553
|
/**
|
|
2554
2554
|
* Write a `fixed64` value, a signed, fixed-length 64-bit integer.
|
|
2555
2555
|
*/
|
|
2556
2556
|
sfixed64(e) {
|
|
2557
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), a =
|
|
2557
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), a = H.enc(e);
|
|
2558
2558
|
return n.setInt32(0, a.lo, !0), n.setInt32(4, a.hi, !0), this.raw(t);
|
|
2559
2559
|
}
|
|
2560
2560
|
/**
|
|
2561
2561
|
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
|
|
2562
2562
|
*/
|
|
2563
2563
|
fixed64(e) {
|
|
2564
|
-
let t = new Uint8Array(8), n = new DataView(t.buffer), a =
|
|
2564
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), a = H.uEnc(e);
|
|
2565
2565
|
return n.setInt32(0, a.lo, !0), n.setInt32(4, a.hi, !0), this.raw(t);
|
|
2566
2566
|
}
|
|
2567
2567
|
/**
|
|
2568
2568
|
* Write a `int64` value, a signed 64-bit varint.
|
|
2569
2569
|
*/
|
|
2570
2570
|
int64(e) {
|
|
2571
|
-
let t =
|
|
2572
|
-
return
|
|
2571
|
+
let t = H.enc(e);
|
|
2572
|
+
return Be(t.lo, t.hi, this.buf), this;
|
|
2573
2573
|
}
|
|
2574
2574
|
/**
|
|
2575
2575
|
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
2576
2576
|
*/
|
|
2577
2577
|
sint64(e) {
|
|
2578
|
-
const t =
|
|
2579
|
-
return
|
|
2578
|
+
const t = H.enc(e), n = t.hi >> 31, a = t.lo << 1 ^ n, i = (t.hi << 1 | t.lo >>> 31) ^ n;
|
|
2579
|
+
return Be(a, i, this.buf), this;
|
|
2580
2580
|
}
|
|
2581
2581
|
/**
|
|
2582
2582
|
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
2583
2583
|
*/
|
|
2584
2584
|
uint64(e) {
|
|
2585
|
-
const t =
|
|
2586
|
-
return
|
|
2585
|
+
const t = H.uEnc(e);
|
|
2586
|
+
return Be(t.lo, t.hi, this.buf), this;
|
|
2587
2587
|
}
|
|
2588
2588
|
}
|
|
2589
2589
|
class N {
|
|
2590
|
-
constructor(e, t =
|
|
2591
|
-
this.decodeUtf8 = t, this.varint64 =
|
|
2590
|
+
constructor(e, t = nr().decodeUtf8) {
|
|
2591
|
+
this.decodeUtf8 = t, this.varint64 = ia, this.uint32 = la, this.buf = e, this.len = e.length, this.pos = 0, this.view = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
2592
2592
|
}
|
|
2593
2593
|
/**
|
|
2594
2594
|
* Reads a tag - field number and wire type.
|
|
@@ -2661,20 +2661,20 @@ class N {
|
|
|
2661
2661
|
* Read a `int64` field, a signed 64-bit varint.
|
|
2662
2662
|
*/
|
|
2663
2663
|
int64() {
|
|
2664
|
-
return
|
|
2664
|
+
return H.dec(...this.varint64());
|
|
2665
2665
|
}
|
|
2666
2666
|
/**
|
|
2667
2667
|
* Read a `uint64` field, an unsigned 64-bit varint.
|
|
2668
2668
|
*/
|
|
2669
2669
|
uint64() {
|
|
2670
|
-
return
|
|
2670
|
+
return H.uDec(...this.varint64());
|
|
2671
2671
|
}
|
|
2672
2672
|
/**
|
|
2673
2673
|
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
|
2674
2674
|
*/
|
|
2675
2675
|
sint64() {
|
|
2676
2676
|
let [e, t] = this.varint64(), n = -(e & 1);
|
|
2677
|
-
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n,
|
|
2677
|
+
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n, H.dec(e, t);
|
|
2678
2678
|
}
|
|
2679
2679
|
/**
|
|
2680
2680
|
* Read a `bool` field, a variant.
|
|
@@ -2699,13 +2699,13 @@ class N {
|
|
|
2699
2699
|
* Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.
|
|
2700
2700
|
*/
|
|
2701
2701
|
fixed64() {
|
|
2702
|
-
return
|
|
2702
|
+
return H.uDec(this.sfixed32(), this.sfixed32());
|
|
2703
2703
|
}
|
|
2704
2704
|
/**
|
|
2705
2705
|
* Read a `fixed64` field, a signed, fixed-length 64-bit integer.
|
|
2706
2706
|
*/
|
|
2707
2707
|
sfixed64() {
|
|
2708
|
-
return
|
|
2708
|
+
return H.dec(this.sfixed32(), this.sfixed32());
|
|
2709
2709
|
}
|
|
2710
2710
|
/**
|
|
2711
2711
|
* Read a `float` field, 32-bit floating point number.
|
|
@@ -2733,12 +2733,12 @@ class N {
|
|
|
2733
2733
|
return this.decodeUtf8(this.bytes());
|
|
2734
2734
|
}
|
|
2735
2735
|
}
|
|
2736
|
-
function
|
|
2736
|
+
function Oe(r) {
|
|
2737
2737
|
if (typeof r == "string")
|
|
2738
2738
|
r = Number(r);
|
|
2739
2739
|
else if (typeof r != "number")
|
|
2740
2740
|
throw new Error("invalid int32: " + typeof r);
|
|
2741
|
-
if (!Number.isInteger(r) || r >
|
|
2741
|
+
if (!Number.isInteger(r) || r > fa || r < ma)
|
|
2742
2742
|
throw new Error("invalid int32: " + r);
|
|
2743
2743
|
}
|
|
2744
2744
|
function It(r) {
|
|
@@ -2746,21 +2746,21 @@ function It(r) {
|
|
|
2746
2746
|
r = Number(r);
|
|
2747
2747
|
else if (typeof r != "number")
|
|
2748
2748
|
throw new Error("invalid uint32: " + typeof r);
|
|
2749
|
-
if (!Number.isInteger(r) || r >
|
|
2749
|
+
if (!Number.isInteger(r) || r > ha || r < 0)
|
|
2750
2750
|
throw new Error("invalid uint32: " + r);
|
|
2751
2751
|
}
|
|
2752
|
-
function
|
|
2752
|
+
function pa(r) {
|
|
2753
2753
|
if (typeof r == "string") {
|
|
2754
2754
|
const e = r;
|
|
2755
2755
|
if (r = Number(r), Number.isNaN(r) && e !== "NaN")
|
|
2756
2756
|
throw new Error("invalid float32: " + e);
|
|
2757
2757
|
} else if (typeof r != "number")
|
|
2758
2758
|
throw new Error("invalid float32: " + typeof r);
|
|
2759
|
-
if (Number.isFinite(r) && (r >
|
|
2759
|
+
if (Number.isFinite(r) && (r > da || r < ua))
|
|
2760
2760
|
throw new Error("invalid float32: " + r);
|
|
2761
2761
|
}
|
|
2762
|
-
var
|
|
2763
|
-
function
|
|
2762
|
+
var Se = /* @__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))(Se || {});
|
|
2763
|
+
function ga(r) {
|
|
2764
2764
|
switch (r) {
|
|
2765
2765
|
case 0:
|
|
2766
2766
|
case "MESSAGE_UNSPECIFIED":
|
|
@@ -2780,7 +2780,7 @@ function da(r) {
|
|
|
2780
2780
|
return -1;
|
|
2781
2781
|
}
|
|
2782
2782
|
}
|
|
2783
|
-
function
|
|
2783
|
+
function va(r) {
|
|
2784
2784
|
switch (r) {
|
|
2785
2785
|
case 0:
|
|
2786
2786
|
return "MESSAGE_UNSPECIFIED";
|
|
@@ -2795,17 +2795,17 @@ function ua(r) {
|
|
|
2795
2795
|
return "UNRECOGNIZED";
|
|
2796
2796
|
}
|
|
2797
2797
|
}
|
|
2798
|
-
function
|
|
2798
|
+
function kt() {
|
|
2799
2799
|
return { reqId: "", audio: new Uint8Array(0), end: !1 };
|
|
2800
2800
|
}
|
|
2801
|
-
const
|
|
2802
|
-
encode(r, e = new
|
|
2801
|
+
const ce = {
|
|
2802
|
+
encode(r, e = new oe()) {
|
|
2803
2803
|
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.audio.length !== 0 && e.uint32(18).bytes(r.audio), r.end !== !1 && e.uint32(24).bool(r.end), e;
|
|
2804
2804
|
},
|
|
2805
2805
|
decode(r, e) {
|
|
2806
2806
|
const t = r instanceof N ? r : new N(r);
|
|
2807
2807
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2808
|
-
const a =
|
|
2808
|
+
const a = kt();
|
|
2809
2809
|
for (; t.pos < n; ) {
|
|
2810
2810
|
const i = t.uint32();
|
|
2811
2811
|
switch (i >>> 3) {
|
|
@@ -2836,28 +2836,28 @@ const fe = {
|
|
|
2836
2836
|
},
|
|
2837
2837
|
fromJSON(r) {
|
|
2838
2838
|
return {
|
|
2839
|
-
reqId:
|
|
2840
|
-
audio:
|
|
2841
|
-
end:
|
|
2839
|
+
reqId: U(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
2840
|
+
audio: U(r.audio) ? ya(r.audio) : new Uint8Array(0),
|
|
2841
|
+
end: U(r.end) ? globalThis.Boolean(r.end) : !1
|
|
2842
2842
|
};
|
|
2843
2843
|
},
|
|
2844
2844
|
toJSON(r) {
|
|
2845
2845
|
const e = {};
|
|
2846
|
-
return r.reqId !== "" && (e.reqId = r.reqId), r.audio.length !== 0 && (e.audio =
|
|
2846
|
+
return r.reqId !== "" && (e.reqId = r.reqId), r.audio.length !== 0 && (e.audio = wa(r.audio)), r.end !== !1 && (e.end = r.end), e;
|
|
2847
2847
|
},
|
|
2848
2848
|
create(r) {
|
|
2849
|
-
return
|
|
2849
|
+
return ce.fromPartial(r ?? {});
|
|
2850
2850
|
},
|
|
2851
2851
|
fromPartial(r) {
|
|
2852
|
-
const e =
|
|
2852
|
+
const e = kt();
|
|
2853
2853
|
return e.reqId = r.reqId ?? "", e.audio = r.audio ?? new Uint8Array(0), e.end = r.end ?? !1, e;
|
|
2854
2854
|
}
|
|
2855
2855
|
};
|
|
2856
|
-
function
|
|
2856
|
+
function xt() {
|
|
2857
2857
|
return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
|
|
2858
2858
|
}
|
|
2859
|
-
const
|
|
2860
|
-
encode(r, e = new
|
|
2859
|
+
const de = {
|
|
2860
|
+
encode(r, e = new oe()) {
|
|
2861
2861
|
e.uint32(18).fork();
|
|
2862
2862
|
for (const t of r.translation)
|
|
2863
2863
|
e.float(t);
|
|
@@ -2884,7 +2884,7 @@ const me = {
|
|
|
2884
2884
|
decode(r, e) {
|
|
2885
2885
|
const t = r instanceof N ? r : new N(r);
|
|
2886
2886
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
2887
|
-
const a =
|
|
2887
|
+
const a = xt();
|
|
2888
2888
|
for (; t.pos < n; ) {
|
|
2889
2889
|
const i = t.uint32();
|
|
2890
2890
|
switch (i >>> 3) {
|
|
@@ -2998,39 +2998,39 @@ const me = {
|
|
|
2998
2998
|
};
|
|
2999
2999
|
},
|
|
3000
3000
|
toJSON(r) {
|
|
3001
|
-
var t, n, a, i, s,
|
|
3001
|
+
var t, n, a, i, s, o, l;
|
|
3002
3002
|
const e = {};
|
|
3003
|
-
return (t = r.translation) != null && t.length && (e.translation = r.translation), (n = r.rotation) != null && n.length && (e.rotation = r.rotation), (a = r.neckPose) != null && a.length && (e.neckPose = r.neckPose), (i = r.jawPose) != null && i.length && (e.jawPose = r.jawPose), (s = r.eyePose) != null && s.length && (e.eyePose = r.eyePose), (
|
|
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), (s = r.eyePose) != null && s.length && (e.eyePose = r.eyePose), (o = r.eyeLid) != null && o.length && (e.eyeLid = r.eyeLid), (l = r.expression) != null && l.length && (e.expression = r.expression), e;
|
|
3004
3004
|
},
|
|
3005
3005
|
create(r) {
|
|
3006
|
-
return
|
|
3006
|
+
return de.fromPartial(r ?? {});
|
|
3007
3007
|
},
|
|
3008
3008
|
fromPartial(r) {
|
|
3009
|
-
var t, n, a, i, s,
|
|
3010
|
-
const e =
|
|
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 = ((s = r.eyePose) == null ? void 0 : s.map((p) => p)) || [], e.eyeLid = ((
|
|
3009
|
+
var t, n, a, i, s, o, l;
|
|
3010
|
+
const e = xt();
|
|
3011
|
+
return e.translation = ((t = r.translation) == null ? void 0 : t.map((p) => p)) || [], e.rotation = ((n = r.rotation) == null ? void 0 : n.map((p) => p)) || [], e.neckPose = ((a = r.neckPose) == null ? void 0 : a.map((p) => p)) || [], e.jawPose = ((i = r.jawPose) == null ? void 0 : i.map((p) => p)) || [], e.eyePose = ((s = r.eyePose) == null ? void 0 : s.map((p) => p)) || [], e.eyeLid = ((o = r.eyeLid) == null ? void 0 : o.map((p) => p)) || [], e.expression = ((l = r.expression) == null ? void 0 : l.map((p) => p)) || [], e;
|
|
3012
3012
|
}
|
|
3013
3013
|
};
|
|
3014
|
-
function
|
|
3014
|
+
function Ft() {
|
|
3015
3015
|
return { keyframes: [] };
|
|
3016
3016
|
}
|
|
3017
|
-
const
|
|
3018
|
-
encode(r, e = new
|
|
3017
|
+
const ue = {
|
|
3018
|
+
encode(r, e = new oe()) {
|
|
3019
3019
|
for (const t of r.keyframes)
|
|
3020
|
-
|
|
3020
|
+
de.encode(t, e.uint32(10).fork()).join();
|
|
3021
3021
|
return e;
|
|
3022
3022
|
},
|
|
3023
3023
|
decode(r, e) {
|
|
3024
3024
|
const t = r instanceof N ? r : new N(r);
|
|
3025
3025
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
3026
|
-
const a =
|
|
3026
|
+
const a = Ft();
|
|
3027
3027
|
for (; t.pos < n; ) {
|
|
3028
3028
|
const i = t.uint32();
|
|
3029
3029
|
switch (i >>> 3) {
|
|
3030
3030
|
case 1: {
|
|
3031
3031
|
if (i !== 10)
|
|
3032
3032
|
break;
|
|
3033
|
-
a.keyframes.push(
|
|
3033
|
+
a.keyframes.push(de.decode(t, t.uint32()));
|
|
3034
3034
|
continue;
|
|
3035
3035
|
}
|
|
3036
3036
|
}
|
|
@@ -3042,34 +3042,34 @@ const pe = {
|
|
|
3042
3042
|
},
|
|
3043
3043
|
fromJSON(r) {
|
|
3044
3044
|
return {
|
|
3045
|
-
keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) =>
|
|
3045
|
+
keyframes: globalThis.Array.isArray(r == null ? void 0 : r.keyframes) ? r.keyframes.map((e) => de.fromJSON(e)) : []
|
|
3046
3046
|
};
|
|
3047
3047
|
},
|
|
3048
3048
|
toJSON(r) {
|
|
3049
3049
|
var t;
|
|
3050
3050
|
const e = {};
|
|
3051
|
-
return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) =>
|
|
3051
|
+
return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) => de.toJSON(n))), e;
|
|
3052
3052
|
},
|
|
3053
3053
|
create(r) {
|
|
3054
|
-
return
|
|
3054
|
+
return ue.fromPartial(r ?? {});
|
|
3055
3055
|
},
|
|
3056
3056
|
fromPartial(r) {
|
|
3057
3057
|
var t;
|
|
3058
|
-
const e =
|
|
3059
|
-
return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) =>
|
|
3058
|
+
const e = Ft();
|
|
3059
|
+
return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => de.fromPartial(n))) || [], e;
|
|
3060
3060
|
}
|
|
3061
3061
|
};
|
|
3062
|
-
function
|
|
3062
|
+
function Mt() {
|
|
3063
3063
|
return { reqId: "", animation: void 0 };
|
|
3064
3064
|
}
|
|
3065
|
-
const
|
|
3066
|
-
encode(r, e = new
|
|
3067
|
-
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 &&
|
|
3065
|
+
const he = {
|
|
3066
|
+
encode(r, e = new oe()) {
|
|
3067
|
+
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.animation !== void 0 && ue.encode(r.animation, e.uint32(18).fork()).join(), e;
|
|
3068
3068
|
},
|
|
3069
3069
|
decode(r, e) {
|
|
3070
3070
|
const t = r instanceof N ? r : new N(r);
|
|
3071
3071
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
3072
|
-
const a =
|
|
3072
|
+
const a = Mt();
|
|
3073
3073
|
for (; t.pos < n; ) {
|
|
3074
3074
|
const i = t.uint32();
|
|
3075
3075
|
switch (i >>> 3) {
|
|
@@ -3082,7 +3082,7 @@ const ge = {
|
|
|
3082
3082
|
case 2: {
|
|
3083
3083
|
if (i !== 18)
|
|
3084
3084
|
break;
|
|
3085
|
-
a.animation =
|
|
3085
|
+
a.animation = ue.decode(t, t.uint32());
|
|
3086
3086
|
continue;
|
|
3087
3087
|
}
|
|
3088
3088
|
}
|
|
@@ -3094,33 +3094,33 @@ const ge = {
|
|
|
3094
3094
|
},
|
|
3095
3095
|
fromJSON(r) {
|
|
3096
3096
|
return {
|
|
3097
|
-
reqId:
|
|
3098
|
-
animation:
|
|
3097
|
+
reqId: U(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
3098
|
+
animation: U(r.animation) ? ue.fromJSON(r.animation) : void 0
|
|
3099
3099
|
};
|
|
3100
3100
|
},
|
|
3101
3101
|
toJSON(r) {
|
|
3102
3102
|
const e = {};
|
|
3103
|
-
return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation =
|
|
3103
|
+
return r.reqId !== "" && (e.reqId = r.reqId), r.animation !== void 0 && (e.animation = ue.toJSON(r.animation)), e;
|
|
3104
3104
|
},
|
|
3105
3105
|
create(r) {
|
|
3106
|
-
return
|
|
3106
|
+
return he.fromPartial(r ?? {});
|
|
3107
3107
|
},
|
|
3108
3108
|
fromPartial(r) {
|
|
3109
|
-
const e =
|
|
3110
|
-
return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ?
|
|
3109
|
+
const e = Mt();
|
|
3110
|
+
return e.reqId = r.reqId ?? "", e.animation = r.animation !== void 0 && r.animation !== null ? ue.fromPartial(r.animation) : void 0, e;
|
|
3111
3111
|
}
|
|
3112
3112
|
};
|
|
3113
|
-
function
|
|
3113
|
+
function Lt() {
|
|
3114
3114
|
return { reqId: "", code: 0, reason: "" };
|
|
3115
3115
|
}
|
|
3116
|
-
const
|
|
3117
|
-
encode(r, e = new
|
|
3116
|
+
const fe = {
|
|
3117
|
+
encode(r, e = new oe()) {
|
|
3118
3118
|
return r.reqId !== "" && e.uint32(10).string(r.reqId), r.code !== 0 && e.uint32(16).int32(r.code), r.reason !== "" && e.uint32(26).string(r.reason), e;
|
|
3119
3119
|
},
|
|
3120
3120
|
decode(r, e) {
|
|
3121
3121
|
const t = r instanceof N ? r : new N(r);
|
|
3122
3122
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
3123
|
-
const a =
|
|
3123
|
+
const a = Lt();
|
|
3124
3124
|
for (; t.pos < n; ) {
|
|
3125
3125
|
const i = t.uint32();
|
|
3126
3126
|
switch (i >>> 3) {
|
|
@@ -3151,9 +3151,9 @@ const we = {
|
|
|
3151
3151
|
},
|
|
3152
3152
|
fromJSON(r) {
|
|
3153
3153
|
return {
|
|
3154
|
-
reqId:
|
|
3155
|
-
code:
|
|
3156
|
-
reason:
|
|
3154
|
+
reqId: U(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
3155
|
+
code: U(r.code) ? globalThis.Number(r.code) : 0,
|
|
3156
|
+
reason: U(r.reason) ? globalThis.String(r.reason) : ""
|
|
3157
3157
|
};
|
|
3158
3158
|
},
|
|
3159
3159
|
toJSON(r) {
|
|
@@ -3161,24 +3161,24 @@ const we = {
|
|
|
3161
3161
|
return r.reqId !== "" && (e.reqId = r.reqId), r.code !== 0 && (e.code = Math.round(r.code)), r.reason !== "" && (e.reason = r.reason), e;
|
|
3162
3162
|
},
|
|
3163
3163
|
create(r) {
|
|
3164
|
-
return
|
|
3164
|
+
return fe.fromPartial(r ?? {});
|
|
3165
3165
|
},
|
|
3166
3166
|
fromPartial(r) {
|
|
3167
|
-
const e =
|
|
3167
|
+
const e = Lt();
|
|
3168
3168
|
return e.reqId = r.reqId ?? "", e.code = r.code ?? 0, e.reason = r.reason ?? "", e;
|
|
3169
3169
|
}
|
|
3170
3170
|
};
|
|
3171
|
-
function
|
|
3171
|
+
function Rt() {
|
|
3172
3172
|
return { type: 0, error: void 0, serverResponseAnimation: void 0, clientAudioInput: void 0 };
|
|
3173
3173
|
}
|
|
3174
|
-
const
|
|
3175
|
-
encode(r, e = new
|
|
3176
|
-
return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 &&
|
|
3174
|
+
const We = {
|
|
3175
|
+
encode(r, e = new oe()) {
|
|
3176
|
+
return r.type !== 0 && e.uint32(8).int32(r.type), r.error !== void 0 && fe.encode(r.error, e.uint32(18).fork()).join(), r.serverResponseAnimation !== void 0 && he.encode(r.serverResponseAnimation, e.uint32(26).fork()).join(), r.clientAudioInput !== void 0 && ce.encode(r.clientAudioInput, e.uint32(34).fork()).join(), e;
|
|
3177
3177
|
},
|
|
3178
3178
|
decode(r, e) {
|
|
3179
3179
|
const t = r instanceof N ? r : new N(r);
|
|
3180
3180
|
let n = e === void 0 ? t.len : t.pos + e;
|
|
3181
|
-
const a =
|
|
3181
|
+
const a = Rt();
|
|
3182
3182
|
for (; t.pos < n; ) {
|
|
3183
3183
|
const i = t.uint32();
|
|
3184
3184
|
switch (i >>> 3) {
|
|
@@ -3191,19 +3191,19 @@ const Ke = {
|
|
|
3191
3191
|
case 2: {
|
|
3192
3192
|
if (i !== 18)
|
|
3193
3193
|
break;
|
|
3194
|
-
a.error =
|
|
3194
|
+
a.error = fe.decode(t, t.uint32());
|
|
3195
3195
|
continue;
|
|
3196
3196
|
}
|
|
3197
3197
|
case 3: {
|
|
3198
3198
|
if (i !== 26)
|
|
3199
3199
|
break;
|
|
3200
|
-
a.serverResponseAnimation =
|
|
3200
|
+
a.serverResponseAnimation = he.decode(t, t.uint32());
|
|
3201
3201
|
continue;
|
|
3202
3202
|
}
|
|
3203
3203
|
case 4: {
|
|
3204
3204
|
if (i !== 34)
|
|
3205
3205
|
break;
|
|
3206
|
-
a.clientAudioInput =
|
|
3206
|
+
a.clientAudioInput = ce.decode(t, t.uint32());
|
|
3207
3207
|
continue;
|
|
3208
3208
|
}
|
|
3209
3209
|
}
|
|
@@ -3215,56 +3215,40 @@ const Ke = {
|
|
|
3215
3215
|
},
|
|
3216
3216
|
fromJSON(r) {
|
|
3217
3217
|
return {
|
|
3218
|
-
type:
|
|
3219
|
-
error:
|
|
3220
|
-
serverResponseAnimation:
|
|
3221
|
-
clientAudioInput:
|
|
3218
|
+
type: U(r.type) ? ga(r.type) : 0,
|
|
3219
|
+
error: U(r.error) ? fe.fromJSON(r.error) : void 0,
|
|
3220
|
+
serverResponseAnimation: U(r.serverResponseAnimation) ? he.fromJSON(r.serverResponseAnimation) : void 0,
|
|
3221
|
+
clientAudioInput: U(r.clientAudioInput) ? ce.fromJSON(r.clientAudioInput) : void 0
|
|
3222
3222
|
};
|
|
3223
3223
|
},
|
|
3224
3224
|
toJSON(r) {
|
|
3225
3225
|
const e = {};
|
|
3226
|
-
return r.type !== 0 && (e.type =
|
|
3226
|
+
return r.type !== 0 && (e.type = va(r.type)), r.error !== void 0 && (e.error = fe.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = he.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = ce.toJSON(r.clientAudioInput)), e;
|
|
3227
3227
|
},
|
|
3228
3228
|
create(r) {
|
|
3229
|
-
return
|
|
3229
|
+
return We.fromPartial(r ?? {});
|
|
3230
3230
|
},
|
|
3231
3231
|
fromPartial(r) {
|
|
3232
|
-
const e =
|
|
3233
|
-
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ?
|
|
3232
|
+
const e = Rt();
|
|
3233
|
+
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? fe.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? he.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? ce.fromPartial(r.clientAudioInput) : void 0, e;
|
|
3234
3234
|
}
|
|
3235
3235
|
};
|
|
3236
|
-
function
|
|
3236
|
+
function ya(r) {
|
|
3237
3237
|
const e = globalThis.atob(r), t = new Uint8Array(e.length);
|
|
3238
3238
|
for (let n = 0; n < e.length; ++n)
|
|
3239
3239
|
t[n] = e.charCodeAt(n);
|
|
3240
3240
|
return t;
|
|
3241
3241
|
}
|
|
3242
|
-
function
|
|
3242
|
+
function wa(r) {
|
|
3243
3243
|
const e = [];
|
|
3244
3244
|
return r.forEach((t) => {
|
|
3245
3245
|
e.push(globalThis.String.fromCharCode(t));
|
|
3246
3246
|
}), globalThis.btoa(e.join(""));
|
|
3247
3247
|
}
|
|
3248
|
-
function
|
|
3248
|
+
function U(r) {
|
|
3249
3249
|
return r != null;
|
|
3250
3250
|
}
|
|
3251
|
-
|
|
3252
|
-
let n = (2 << Math.log2(r.length - 1)) - 1, a = -~(1.6 * n * e / r.length);
|
|
3253
|
-
return (i = e) => {
|
|
3254
|
-
let s = "";
|
|
3255
|
-
for (; ; ) {
|
|
3256
|
-
let l = t(a), o = a | 0;
|
|
3257
|
-
for (; o--; )
|
|
3258
|
-
if (s += r[l[o] & n] || "", s.length >= i) return s;
|
|
3259
|
-
}
|
|
3260
|
-
};
|
|
3261
|
-
}, ga = (r, e = 21) => pa(r, e | 0, ma);
|
|
3262
|
-
const wa = ga("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12);
|
|
3263
|
-
function va() {
|
|
3264
|
-
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"), s = String(r.getUTCSeconds()).padStart(2, "0"), l = `${e}${t}${n}${a}${i}${s}`, o = wa();
|
|
3265
|
-
return `${l}_${o}`;
|
|
3266
|
-
}
|
|
3267
|
-
class ya {
|
|
3251
|
+
class Aa {
|
|
3268
3252
|
constructor() {
|
|
3269
3253
|
d(this, "events", /* @__PURE__ */ new Map());
|
|
3270
3254
|
}
|
|
@@ -3284,7 +3268,7 @@ class ya {
|
|
|
3284
3268
|
e ? this.events.delete(e) : this.events.clear();
|
|
3285
3269
|
}
|
|
3286
3270
|
}
|
|
3287
|
-
class
|
|
3271
|
+
class Sa extends Aa {
|
|
3288
3272
|
constructor(t) {
|
|
3289
3273
|
super();
|
|
3290
3274
|
d(this, "wsUrl");
|
|
@@ -3315,7 +3299,7 @@ class Aa extends ya {
|
|
|
3315
3299
|
try {
|
|
3316
3300
|
this.isConnecting = !0, this.currentCharacterId = t;
|
|
3317
3301
|
const n = this.buildWebSocketUrl(t);
|
|
3318
|
-
h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"),
|
|
3302
|
+
h.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), h.log("[AnimationWebSocketClient] Connected successfully"), y.logEvent("character_animation_service", "info", {
|
|
3319
3303
|
characterId: t,
|
|
3320
3304
|
event: "connect_success",
|
|
3321
3305
|
url: n
|
|
@@ -3323,7 +3307,7 @@ class Aa extends ya {
|
|
|
3323
3307
|
} catch (n) {
|
|
3324
3308
|
this.isConnecting = !1;
|
|
3325
3309
|
const a = n instanceof Error ? n.message : String(n);
|
|
3326
|
-
throw h.error("[AnimationWebSocketClient] Connection failed:", a),
|
|
3310
|
+
throw h.error("[AnimationWebSocketClient] Connection failed:", a), y.logEvent("character_animation_service", "error", {
|
|
3327
3311
|
characterId: t,
|
|
3328
3312
|
event: "connect_failed",
|
|
3329
3313
|
reason: a
|
|
@@ -3338,38 +3322,40 @@ class Aa extends ya {
|
|
|
3338
3322
|
}
|
|
3339
3323
|
/**
|
|
3340
3324
|
* 发送音频数据
|
|
3325
|
+
* @param conversationId - 会话ID(在 protobuf 协议中映射为 reqId 字段)
|
|
3341
3326
|
*/
|
|
3342
3327
|
sendAudioData(t, n, a) {
|
|
3343
3328
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN)
|
|
3344
3329
|
return h.error("[AnimationWebSocketClient] WebSocket not connected"), !1;
|
|
3345
3330
|
try {
|
|
3346
3331
|
const i = {
|
|
3347
|
-
type:
|
|
3332
|
+
type: Se.MESSAGE_CLIENT_AUDIO_INPUT,
|
|
3348
3333
|
clientAudioInput: {
|
|
3349
3334
|
reqId: t,
|
|
3335
|
+
// protobuf 协议中使用 reqId 字段名
|
|
3350
3336
|
audio: new Uint8Array(n),
|
|
3351
3337
|
end: a
|
|
3352
3338
|
}
|
|
3353
|
-
}, s = new
|
|
3354
|
-
|
|
3355
|
-
const
|
|
3356
|
-
return this.ws.send(
|
|
3339
|
+
}, s = new oe();
|
|
3340
|
+
We.encode(i, s);
|
|
3341
|
+
const o = s.finish();
|
|
3342
|
+
return this.ws.send(o), !0;
|
|
3357
3343
|
} catch (i) {
|
|
3358
3344
|
const s = i instanceof Error ? i.message : String(i);
|
|
3359
|
-
return h.error("[AnimationWebSocketClient] Failed to send audio data:", s),
|
|
3345
|
+
return h.error("[AnimationWebSocketClient] Failed to send audio data:", s), y.logEvent("character_animation_service", "warning", {
|
|
3360
3346
|
characterId: this.currentCharacterId,
|
|
3361
3347
|
event: "send_audio_failed",
|
|
3362
|
-
|
|
3348
|
+
conversationId: t,
|
|
3363
3349
|
reason: s
|
|
3364
3350
|
}), this.emit("error", i), !1;
|
|
3365
3351
|
}
|
|
3366
3352
|
}
|
|
3367
3353
|
/**
|
|
3368
|
-
*
|
|
3369
|
-
*
|
|
3354
|
+
* 生成会话ID
|
|
3355
|
+
* 使用统一的会话ID生成规则:YYYYMMDDHHmmss_nanoid
|
|
3370
3356
|
*/
|
|
3371
|
-
|
|
3372
|
-
return
|
|
3357
|
+
generateConversationId() {
|
|
3358
|
+
return er();
|
|
3373
3359
|
}
|
|
3374
3360
|
/**
|
|
3375
3361
|
* 获取连接状态
|
|
@@ -3395,19 +3381,19 @@ class Aa extends ya {
|
|
|
3395
3381
|
this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"), n();
|
|
3396
3382
|
}, this.ws.onmessage = (i) => {
|
|
3397
3383
|
i.data instanceof ArrayBuffer ? this.handleMessage(i.data) : i.data instanceof Blob ? i.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((s) => {
|
|
3398
|
-
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", s),
|
|
3384
|
+
h.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", s), y.logEvent("character_animation_service", "error", {
|
|
3399
3385
|
characterId: this.currentCharacterId,
|
|
3400
3386
|
event: "decode_blob_failed",
|
|
3401
3387
|
reason: s instanceof Error ? s.message : String(s)
|
|
3402
3388
|
}), this.emit("error", s);
|
|
3403
3389
|
}) : h.warn("[AnimationWebSocketClient] Received non-binary data:", typeof i.data);
|
|
3404
3390
|
}, this.ws.onerror = (i) => {
|
|
3405
|
-
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", i),
|
|
3391
|
+
h.errorWithError("[AnimationWebSocketClient] WebSocket error:", i), y.logEvent("character_animation_service", "error", {
|
|
3406
3392
|
characterId: this.currentCharacterId,
|
|
3407
3393
|
event: "websocket_error"
|
|
3408
3394
|
}), this.emit("error", new Error("WebSocket error")), !this.isManuallyDisconnected && this.currentRetryCount < this.reconnectAttempts && this.scheduleReconnect();
|
|
3409
3395
|
}, this.ws.onclose = (i) => {
|
|
3410
|
-
h.log("[AnimationWebSocketClient] WebSocket closed:", i.code, i.reason), this.emit("disconnected", i.reason || "Connection closed"), i.code === 1012 &&
|
|
3396
|
+
h.log("[AnimationWebSocketClient] WebSocket closed:", i.code, i.reason), this.emit("disconnected", i.reason || "Connection closed"), i.code === 1012 && y.logEvent("character_animation_service", "error", {
|
|
3411
3397
|
characterId: this.currentCharacterId,
|
|
3412
3398
|
event: "service_restart",
|
|
3413
3399
|
reason: i.reason || "service restart"
|
|
@@ -3420,9 +3406,9 @@ class Aa extends ya {
|
|
|
3420
3406
|
}
|
|
3421
3407
|
handleMessage(t) {
|
|
3422
3408
|
try {
|
|
3423
|
-
const n = new N(new Uint8Array(t)), a =
|
|
3409
|
+
const n = new N(new Uint8Array(t)), a = We.decode(n);
|
|
3424
3410
|
if (a.error) {
|
|
3425
|
-
h.error(`[AnimationWebSocketClient] Server error: reqId=${a.error.reqId}, code=${a.error.code}, reason=${a.error.reason}`),
|
|
3411
|
+
h.error(`[AnimationWebSocketClient] Server error: reqId=${a.error.reqId}, code=${a.error.code}, reason=${a.error.reason}`), y.logEvent("character_animation_service", "error", {
|
|
3426
3412
|
characterId: this.currentCharacterId,
|
|
3427
3413
|
event: "server_error",
|
|
3428
3414
|
reqId: a.error.reqId,
|
|
@@ -3431,8 +3417,8 @@ class Aa extends ya {
|
|
|
3431
3417
|
}), this.emit("error", new Error(a.error.reason || "Server error"));
|
|
3432
3418
|
return;
|
|
3433
3419
|
}
|
|
3434
|
-
if (a.type ===
|
|
3435
|
-
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"),
|
|
3420
|
+
if (a.type === Se.MESSAGE_ERROR) {
|
|
3421
|
+
h.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), y.logEvent("character_animation_service", "warning", {
|
|
3436
3422
|
characterId: this.currentCharacterId,
|
|
3437
3423
|
event: "message_error_without_payload"
|
|
3438
3424
|
}), this.emit("error", new Error("Server returned error message without error details"));
|
|
@@ -3441,7 +3427,7 @@ class Aa extends ya {
|
|
|
3441
3427
|
this.emit("message", a);
|
|
3442
3428
|
} catch (n) {
|
|
3443
3429
|
const a = n instanceof Error ? n.message : String(n);
|
|
3444
|
-
h.error("[AnimationWebSocketClient] Failed to decode message:", a),
|
|
3430
|
+
h.error("[AnimationWebSocketClient] Failed to decode message:", a), y.logEvent("character_animation_service", "error", {
|
|
3445
3431
|
characterId: this.currentCharacterId,
|
|
3446
3432
|
event: "decode_failed",
|
|
3447
3433
|
reason: a
|
|
@@ -3458,23 +3444,22 @@ class Aa extends ya {
|
|
|
3458
3444
|
}, t);
|
|
3459
3445
|
}
|
|
3460
3446
|
}
|
|
3461
|
-
class
|
|
3447
|
+
class ba {
|
|
3462
3448
|
constructor(e) {
|
|
3463
3449
|
d(this, "wsClient");
|
|
3464
3450
|
d(this, "dataController");
|
|
3465
3451
|
// 组合播放层
|
|
3466
|
-
d(this, "
|
|
3467
|
-
d(this, "
|
|
3468
|
-
d(this, "audioBytesPerSecond", x.audio.sampleRate * 2);
|
|
3452
|
+
d(this, "currentConversationId", null);
|
|
3453
|
+
d(this, "audioBytesPerSecond", I.audio.sampleRate * 2);
|
|
3469
3454
|
d(this, "audioMetrics", this.createAudioMetrics());
|
|
3470
3455
|
this.dataController = e;
|
|
3471
|
-
const t =
|
|
3472
|
-
this.wsClient = new
|
|
3456
|
+
const t = y.getEnvironmentConfig();
|
|
3457
|
+
this.wsClient = new Sa({
|
|
3473
3458
|
wsUrl: t.driveningressWsUrl,
|
|
3474
3459
|
reconnectAttempts: 5,
|
|
3475
3460
|
debug: !1,
|
|
3476
|
-
jwtToken:
|
|
3477
|
-
appId:
|
|
3461
|
+
jwtToken: y.sessionToken || void 0,
|
|
3462
|
+
appId: y.appId || void 0
|
|
3478
3463
|
}), this.setupWebSocketListeners();
|
|
3479
3464
|
}
|
|
3480
3465
|
/**
|
|
@@ -3485,45 +3470,46 @@ class Sa {
|
|
|
3485
3470
|
}
|
|
3486
3471
|
/**
|
|
3487
3472
|
* 发送音频数据到服务器
|
|
3473
|
+
* 注意:打断逻辑由 AvatarController.send() 统一处理,这里只负责网络通信
|
|
3488
3474
|
*/
|
|
3489
3475
|
sendAudioData(e, t) {
|
|
3490
|
-
var
|
|
3491
|
-
this.
|
|
3476
|
+
var o, l;
|
|
3477
|
+
this.currentConversationId || (this.currentConversationId = this.wsClient.generateConversationId(), this.resetAudioMetrics(), y.logEvent("character_manager", "info", {
|
|
3492
3478
|
characterId: this.dataController.getAvatarId(),
|
|
3493
3479
|
event: "conversation_started",
|
|
3494
|
-
|
|
3495
|
-
}))
|
|
3480
|
+
conversationId: this.currentConversationId
|
|
3481
|
+
}));
|
|
3496
3482
|
const n = this.audioMetrics;
|
|
3497
3483
|
let a = !1;
|
|
3498
3484
|
n.startTimestamp === 0 && (n.startTimestamp = Date.now(), a = !0), n.accumulatedBytes += e.byteLength;
|
|
3499
3485
|
const i = n.accumulatedBytes / this.audioBytesPerSecond;
|
|
3500
|
-
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.wsClient.sendAudioData(this.
|
|
3501
|
-
h.error("[NetworkLayer] Failed to send audio data to WebSocket"), (
|
|
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)"), !this.wsClient.sendAudioData(this.currentConversationId, e, t)) {
|
|
3487
|
+
h.error("[NetworkLayer] Failed to send audio data to WebSocket"), (l = (o = this.dataController).onError) == null || l.call(o, new Q("Failed to send audio data to WebSocket", "SEND_FAILED")), y.logEvent("character_animation_service", "error", {
|
|
3502
3488
|
characterId: this.dataController.getAvatarId(),
|
|
3503
3489
|
event: "send_audio_failed",
|
|
3504
|
-
|
|
3490
|
+
conversationId: this.currentConversationId
|
|
3505
3491
|
});
|
|
3506
3492
|
return;
|
|
3507
3493
|
}
|
|
3508
|
-
a && this.
|
|
3494
|
+
a && this.currentConversationId && this.reportAudioMetrics(this.currentConversationId);
|
|
3509
3495
|
}
|
|
3510
3496
|
/**
|
|
3511
3497
|
* 断开连接
|
|
3512
3498
|
*/
|
|
3513
3499
|
disconnect() {
|
|
3514
|
-
this.wsClient.removeAllListeners(), this.wsClient.disconnect(), this.
|
|
3500
|
+
this.wsClient.removeAllListeners(), this.wsClient.disconnect(), this.currentConversationId = null;
|
|
3515
3501
|
}
|
|
3516
3502
|
/**
|
|
3517
|
-
*
|
|
3503
|
+
* 获取当前会话ID
|
|
3518
3504
|
*/
|
|
3519
|
-
|
|
3520
|
-
return this.
|
|
3505
|
+
getCurrentConversationId() {
|
|
3506
|
+
return this.currentConversationId;
|
|
3521
3507
|
}
|
|
3522
3508
|
/**
|
|
3523
|
-
*
|
|
3509
|
+
* 重置会话ID(用于打断后清理)
|
|
3524
3510
|
*/
|
|
3525
|
-
|
|
3526
|
-
this.
|
|
3511
|
+
resetConversationId() {
|
|
3512
|
+
this.currentConversationId = null, this.resetAudioMetrics();
|
|
3527
3513
|
}
|
|
3528
3514
|
/**
|
|
3529
3515
|
* 设置 WebSocket 事件监听器
|
|
@@ -3532,29 +3518,29 @@ class Sa {
|
|
|
3532
3518
|
setupWebSocketListeners() {
|
|
3533
3519
|
this.wsClient.removeAllListeners(), this.wsClient.on("connected", () => {
|
|
3534
3520
|
var e, t;
|
|
3535
|
-
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3521
|
+
this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e, ye.connected), y.logEvent("character_animation_service", "info", {
|
|
3536
3522
|
characterId: this.dataController.getAvatarId(),
|
|
3537
3523
|
event: "connected"
|
|
3538
3524
|
});
|
|
3539
3525
|
}), this.wsClient.on("disconnected", () => {
|
|
3540
3526
|
var e, t;
|
|
3541
|
-
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3527
|
+
this.dataController.setConnected(!1), (t = (e = this.dataController).onConnectionState) == null || t.call(e, ye.disconnected), y.logEvent("character_animation_service", "warning", {
|
|
3542
3528
|
characterId: this.dataController.getAvatarId(),
|
|
3543
3529
|
event: "disconnected"
|
|
3544
3530
|
});
|
|
3545
3531
|
}), this.wsClient.on("reconnecting", () => {
|
|
3546
|
-
|
|
3532
|
+
y.logEvent("character_animation_service", "info", {
|
|
3547
3533
|
characterId: this.dataController.getAvatarId(),
|
|
3548
3534
|
event: "reconnecting"
|
|
3549
3535
|
});
|
|
3550
3536
|
}), this.wsClient.on("error", (e) => {
|
|
3551
3537
|
var n, a, i, s;
|
|
3552
3538
|
const t = e instanceof Error ? e.message : String(e);
|
|
3553
|
-
h.error("[NetworkLayer] WebSocket error:", t),
|
|
3539
|
+
h.error("[NetworkLayer] WebSocket error:", t), y.logEvent("character_animation_service", "error", {
|
|
3554
3540
|
characterId: this.dataController.getAvatarId(),
|
|
3555
3541
|
event: "websocket_error",
|
|
3556
3542
|
reason: t
|
|
3557
|
-
}), (a = (n = this.dataController).onConnectionState) == null || a.call(n,
|
|
3543
|
+
}), (a = (n = this.dataController).onConnectionState) == null || a.call(n, ye.failed), (s = (i = this.dataController).onError) == null || s.call(i, e);
|
|
3558
3544
|
}), this.wsClient.on("message", (e) => {
|
|
3559
3545
|
this.handleMessage(e);
|
|
3560
3546
|
});
|
|
@@ -3565,16 +3551,16 @@ class Sa {
|
|
|
3565
3551
|
handleMessage(e) {
|
|
3566
3552
|
try {
|
|
3567
3553
|
switch (e.type) {
|
|
3568
|
-
case
|
|
3554
|
+
case Se.MESSAGE_SERVER_RESPONSE_ANIMATION:
|
|
3569
3555
|
this.handleAnimationMessage(e);
|
|
3570
3556
|
break;
|
|
3571
|
-
case
|
|
3557
|
+
case Se.MESSAGE_ERROR:
|
|
3572
3558
|
this.handleErrorMessage(e);
|
|
3573
3559
|
break;
|
|
3574
3560
|
}
|
|
3575
3561
|
} catch (t) {
|
|
3576
3562
|
const n = t instanceof Error ? t.message : String(t);
|
|
3577
|
-
h.error("[NetworkLayer] Failed to handle message:", n),
|
|
3563
|
+
h.error("[NetworkLayer] Failed to handle message:", n), y.logEvent("character_manager", "error", {
|
|
3578
3564
|
characterId: this.dataController.getAvatarId(),
|
|
3579
3565
|
event: "handle_message_failed",
|
|
3580
3566
|
reason: n
|
|
@@ -3589,54 +3575,55 @@ class Sa {
|
|
|
3589
3575
|
h.error("[NetworkLayer] Invalid animation message");
|
|
3590
3576
|
return;
|
|
3591
3577
|
}
|
|
3592
|
-
const { reqId: t, animation: n } = e.serverResponseAnimation;
|
|
3593
|
-
if (!this.
|
|
3594
|
-
h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected
|
|
3578
|
+
const { reqId: t, animation: n } = e.serverResponseAnimation, a = t;
|
|
3579
|
+
if (!this.currentConversationId || a !== this.currentConversationId) {
|
|
3580
|
+
h.warn(`[NetworkLayer] Ignoring mismatched animation message - expected conversationId: ${this.currentConversationId}, received conversationId: ${a}`), y.logEvent("character_manager", "warning", {
|
|
3595
3581
|
characterId: this.dataController.getAvatarId(),
|
|
3596
|
-
event: "
|
|
3597
|
-
|
|
3598
|
-
|
|
3582
|
+
event: "animation_conversationid_mismatch",
|
|
3583
|
+
expectedConversationId: this.currentConversationId,
|
|
3584
|
+
receivedConversationId: a
|
|
3599
3585
|
});
|
|
3600
3586
|
return;
|
|
3601
3587
|
}
|
|
3602
3588
|
if (n != null && n.keyframes && n.keyframes.length > 0) {
|
|
3603
|
-
const
|
|
3604
|
-
this.dataController.
|
|
3589
|
+
const i = n.keyframes;
|
|
3590
|
+
this.dataController.yieldFramesData(i, a), this.dataController.getIsPlaying() || this.dataController.startStreamingPlayback(), this.audioMetrics.didRecvFirstFlame || (this.audioMetrics.didRecvFirstFlame = !0, this.audioMetrics.recvFirstFlameTimestamp = Date.now(), this.currentConversationId && this.reportAudioMetrics(this.currentConversationId));
|
|
3605
3591
|
} else
|
|
3606
|
-
h.warn(`[NetworkLayer] Animation message has no keyframes -
|
|
3592
|
+
h.warn(`[NetworkLayer] Animation message has no keyframes - conversationId: ${a}`), y.logEvent("character_manager", "warning", {
|
|
3607
3593
|
characterId: this.dataController.getAvatarId(),
|
|
3608
3594
|
event: "animation_empty_keyframes",
|
|
3609
|
-
|
|
3595
|
+
conversationId: a
|
|
3610
3596
|
});
|
|
3611
3597
|
}
|
|
3612
3598
|
/**
|
|
3613
3599
|
* 处理错误消息
|
|
3614
3600
|
*/
|
|
3615
3601
|
handleErrorMessage(e) {
|
|
3616
|
-
var
|
|
3602
|
+
var a, i, s, o;
|
|
3617
3603
|
if (!e.error) {
|
|
3618
|
-
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"),
|
|
3604
|
+
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", {
|
|
3619
3605
|
characterId: this.dataController.getAvatarId(),
|
|
3620
3606
|
event: "message_error_with_payload"
|
|
3621
3607
|
}), this.handleAnimationMessage(e));
|
|
3622
3608
|
return;
|
|
3623
3609
|
}
|
|
3624
|
-
|
|
3610
|
+
const t = e.error.reqId;
|
|
3611
|
+
h.error(`[NetworkLayer] Server error: conversationId=${t}, code=${e.error.code}, reason=${e.error.reason}`), y.logEvent("character_manager", "error", {
|
|
3625
3612
|
characterId: this.dataController.getAvatarId(),
|
|
3626
3613
|
event: "server_error",
|
|
3627
|
-
|
|
3614
|
+
conversationId: t,
|
|
3628
3615
|
code: e.error.code,
|
|
3629
3616
|
reason: e.error.reason
|
|
3630
3617
|
});
|
|
3631
|
-
const
|
|
3632
|
-
(
|
|
3618
|
+
const n = ((a = e.error.code) == null ? void 0 : a.toString().toLowerCase()) ?? "";
|
|
3619
|
+
(n.includes("unauth") || n === "401") && y.logEvent("sdk_verify", "error", {
|
|
3633
3620
|
characterId: this.dataController.getAvatarId(),
|
|
3634
|
-
|
|
3621
|
+
conversationId: t,
|
|
3635
3622
|
reason: e.error.reason
|
|
3636
|
-
}), (
|
|
3623
|
+
}), (o = (s = this.dataController).onError) == null || o.call(s, new Q(
|
|
3637
3624
|
e.error.reason || "Server error occurred",
|
|
3638
|
-
((
|
|
3639
|
-
)), this.
|
|
3625
|
+
((i = e.error.code) == null ? void 0 : i.toString()) || "SERVER_ERROR"
|
|
3626
|
+
)), this.currentConversationId && t === this.currentConversationId && (h.warn("[NetworkLayer] Server error for current conversation - triggering audio-only mode via empty keyframes"), this.dataController.yieldFramesData([], t));
|
|
3640
3627
|
}
|
|
3641
3628
|
/**
|
|
3642
3629
|
* 创建音频指标
|
|
@@ -3662,8 +3649,8 @@ class Sa {
|
|
|
3662
3649
|
* 上报音频指标
|
|
3663
3650
|
*/
|
|
3664
3651
|
reportAudioMetrics(e) {
|
|
3665
|
-
!e || this.audioMetrics.startTimestamp === 0 ||
|
|
3666
|
-
|
|
3652
|
+
!e || this.audioMetrics.startTimestamp === 0 || y.logEvent("send_audio_measure", "info", {
|
|
3653
|
+
conversationId: e,
|
|
3667
3654
|
start: this.audioMetrics.startTimestamp,
|
|
3668
3655
|
tap2: this.audioMetrics.tap2Timestamp,
|
|
3669
3656
|
tap4: this.audioMetrics.tap4Timestamp,
|
|
@@ -3672,8 +3659,8 @@ class Sa {
|
|
|
3672
3659
|
});
|
|
3673
3660
|
}
|
|
3674
3661
|
}
|
|
3675
|
-
class
|
|
3676
|
-
//
|
|
3662
|
+
class Ca {
|
|
3663
|
+
// 音频独立播放模式标志
|
|
3677
3664
|
constructor(e, t) {
|
|
3678
3665
|
// ========== Configuration and Composition ==========
|
|
3679
3666
|
d(this, "networkLayer");
|
|
@@ -3686,7 +3673,10 @@ class ba {
|
|
|
3686
3673
|
d(this, "isPlaying", !1);
|
|
3687
3674
|
// ========== State Management ==========
|
|
3688
3675
|
d(this, "isConnected", !1);
|
|
3689
|
-
d(this, "currentState",
|
|
3676
|
+
d(this, "currentState", M.idle);
|
|
3677
|
+
// ========== Conversation ID Management (for external data mode) ==========
|
|
3678
|
+
d(this, "currentConversationId", null);
|
|
3679
|
+
d(this, "reqEnd", !1);
|
|
3690
3680
|
// ========== Event System ==========
|
|
3691
3681
|
d(this, "onConnectionState", null);
|
|
3692
3682
|
d(this, "onAvatarState", null);
|
|
@@ -3707,7 +3697,10 @@ class ba {
|
|
|
3707
3697
|
d(this, "KEYFRAMES_CLEANUP_THRESHOLD", 3e3);
|
|
3708
3698
|
// Cleanup threshold (keep some buffer)
|
|
3709
3699
|
d(this, "MAX_PENDING_AUDIO_CHUNKS", 100);
|
|
3710
|
-
|
|
3700
|
+
// Maximum pending audio chunks to prevent memory leak
|
|
3701
|
+
// ========== Audio Only Mode ==========
|
|
3702
|
+
d(this, "isAudioOnlyMode", !1);
|
|
3703
|
+
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? me.network, this.playbackMode === me.network && (this.networkLayer = new ba(this));
|
|
3711
3704
|
}
|
|
3712
3705
|
// ========== Internal Accessors (for NetworkLayer and AvatarView) ==========
|
|
3713
3706
|
/**
|
|
@@ -3752,23 +3745,31 @@ class ba {
|
|
|
3752
3745
|
getAnimationPlayer() {
|
|
3753
3746
|
return this.animationPlayer;
|
|
3754
3747
|
}
|
|
3748
|
+
/**
|
|
3749
|
+
* Get current conversation ID
|
|
3750
|
+
* Returns the current conversation ID for the active audio session
|
|
3751
|
+
* @returns Current conversation ID, or null if no active session
|
|
3752
|
+
*/
|
|
3753
|
+
getCurrentConversationId() {
|
|
3754
|
+
return this.getEffectiveConversationId();
|
|
3755
|
+
}
|
|
3755
3756
|
// ========== Network Mode Interface ==========
|
|
3756
3757
|
/**
|
|
3757
3758
|
* Start service (network mode only)
|
|
3758
3759
|
*/
|
|
3759
3760
|
async start() {
|
|
3760
3761
|
if (!this.networkLayer)
|
|
3761
|
-
throw new
|
|
3762
|
+
throw new Q(
|
|
3762
3763
|
"Network layer not available. Use network playback mode.",
|
|
3763
3764
|
"NETWORK_LAYER_NOT_AVAILABLE"
|
|
3764
3765
|
);
|
|
3765
3766
|
if (!this.animationPlayer) {
|
|
3766
|
-
this.animationPlayer = new
|
|
3767
|
+
this.animationPlayer = new ae();
|
|
3767
3768
|
try {
|
|
3768
3769
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
3769
3770
|
} catch (e) {
|
|
3770
3771
|
const t = e instanceof Error ? e.message : String(e);
|
|
3771
|
-
throw h.error("[AvatarController] Failed to create streaming player:", t),
|
|
3772
|
+
throw h.error("[AvatarController] Failed to create streaming player:", t), y.logEvent("character_player", "error", {
|
|
3772
3773
|
characterId: this.avatar.id,
|
|
3773
3774
|
event: "streaming_player_init_failed",
|
|
3774
3775
|
reason: t
|
|
@@ -3780,61 +3781,109 @@ class ba {
|
|
|
3780
3781
|
/**
|
|
3781
3782
|
* Send audio to server (network mode only)
|
|
3782
3783
|
* Also cache to data layer for playback
|
|
3784
|
+
* @returns conversationId - Conversation ID for this audio session
|
|
3783
3785
|
*/
|
|
3784
3786
|
send(e, t = !1) {
|
|
3785
|
-
var
|
|
3786
|
-
if (!this.networkLayer || !this.isConnected)
|
|
3787
|
-
(
|
|
3787
|
+
var a, i;
|
|
3788
|
+
if (!this.networkLayer || !this.isConnected)
|
|
3789
|
+
return (a = this.onError) == null || a.call(this, new Q("Service not connected", "NOT_CONNECTED")), y.logEvent("character_manager", "warning", {
|
|
3788
3790
|
characterId: this.avatar.id,
|
|
3789
3791
|
event: "send_not_connected"
|
|
3790
|
-
});
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
this.networkLayer.sendAudioData(e, t), this.addAudioChunkToBuffer(new Uint8Array(e), t), (a = this.onAvatarState) == null || a.call(this, T.active);
|
|
3792
|
+
}), null;
|
|
3793
|
+
const n = this.networkLayer.getCurrentConversationId();
|
|
3794
|
+
return this.reqEnd && this.isPlaying && n && this.interrupt(), this.networkLayer.sendAudioData(e, t), t && (this.reqEnd = !0), this.addAudioChunkToBuffer(new Uint8Array(e), t), (i = this.onAvatarState) == null || i.call(this, M.active), this.networkLayer.getCurrentConversationId();
|
|
3794
3795
|
}
|
|
3795
3796
|
/**
|
|
3796
3797
|
* Close service (network mode only)
|
|
3797
3798
|
*/
|
|
3798
3799
|
close() {
|
|
3799
|
-
var e
|
|
3800
|
-
(this.isPlaying || this.currentState ===
|
|
3800
|
+
var e;
|
|
3801
|
+
(this.isPlaying || this.currentState === M.paused) && this.stopPlayback(), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.disconnect() : this.currentConversationId = null, this.reqEnd = !1, this.isConnected = !1, (e = this.onConnectionState) == null || e.call(this, ye.disconnected);
|
|
3801
3802
|
}
|
|
3802
3803
|
// ========== External Data Mode Interface ==========
|
|
3803
3804
|
/**
|
|
3804
|
-
*
|
|
3805
|
-
*
|
|
3805
|
+
* Playback existing audio and animation data (external data mode)
|
|
3806
|
+
* Starts a new conversation by generating a new conversation ID and interrupting any existing conversation
|
|
3807
|
+
* @param initialAudioChunks - Existing audio chunks to playback
|
|
3808
|
+
* @param initialKeyframes - Existing animation keyframes to playback
|
|
3809
|
+
* @returns conversationId - New conversation ID for this conversation session
|
|
3806
3810
|
*/
|
|
3807
|
-
async
|
|
3808
|
-
if (
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3811
|
+
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 ae()), 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
|
+
characterId: this.avatar.id,
|
|
3814
|
+
event: "empty_animation_data_audio_only_fallback",
|
|
3815
|
+
conversationId: this.currentConversationId
|
|
3816
|
+
}), this.isAudioOnlyMode = !0), this.pendingAudioChunks.length === 0)
|
|
3817
|
+
throw new Q("No audio chunks to play", "NO_AUDIO");
|
|
3818
|
+
return this.isAudioOnlyMode ? await this.startAudioOnlyPlayback() : await this.startStreamingPlayback(), this.currentConversationId;
|
|
3815
3819
|
}
|
|
3816
3820
|
/**
|
|
3817
3821
|
* Send audio data (external data mode)
|
|
3818
|
-
* Stream additional audio data after
|
|
3822
|
+
* Stream additional audio data after playback()
|
|
3823
|
+
* @returns conversationId - Conversation ID for this audio session
|
|
3819
3824
|
*/
|
|
3820
|
-
|
|
3825
|
+
yieldAudioData(e, t = !1) {
|
|
3821
3826
|
var n, a;
|
|
3822
|
-
if (this.isPlaying && ((n = this.animationPlayer) != null && n.isStreamingReady()))
|
|
3827
|
+
if (this.reqEnd && this.isPlaying && this.currentConversationId && (this.interrupt(), this.currentConversationId = this.generateAndLogNewConversationId(), this.reqEnd = !1), this.currentConversationId || (this.isPlaying && this.interrupt(), this.currentConversationId = this.generateAndLogNewConversationId(), this.reqEnd = !1, this.clearPlaybackData()), t && (this.reqEnd = !0), this.isPlaying && ((n = this.animationPlayer) != null && n.isStreamingReady()))
|
|
3823
3828
|
this.animationPlayer.addAudioChunk(e, t);
|
|
3824
3829
|
else if (e.length > 0 || t) {
|
|
3825
3830
|
if (this.pendingAudioChunks.length >= this.MAX_PENDING_AUDIO_CHUNKS) {
|
|
3826
3831
|
const i = this.pendingAudioChunks.findIndex((s) => s.isLast);
|
|
3827
3832
|
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`);
|
|
3828
3833
|
}
|
|
3829
|
-
this.pendingAudioChunks.push({ data: e, isLast: t }), (a = this.onAvatarState) == null || a.call(this,
|
|
3834
|
+
this.pendingAudioChunks.push({ data: e, isLast: t }), (a = this.onAvatarState) == null || a.call(this, M.active);
|
|
3830
3835
|
}
|
|
3836
|
+
return this.currentConversationId;
|
|
3831
3837
|
}
|
|
3832
3838
|
/**
|
|
3833
3839
|
* Send animation keyframes (external data mode or network mode)
|
|
3834
|
-
* Stream additional animation data after
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3840
|
+
* Stream additional animation data after playback()
|
|
3841
|
+
* @param keyframes - Animation keyframes to send
|
|
3842
|
+
* @param conversationId - Conversation ID (required). If conversationId doesn't match current conversationId, keyframes will be discarded.
|
|
3843
|
+
* Use getCurrentConversationId() to get the current conversationId.
|
|
3844
|
+
*/
|
|
3845
|
+
yieldFramesData(e, t) {
|
|
3846
|
+
if (!t || typeof t != "string") {
|
|
3847
|
+
h.error("[AvatarController] yieldFramesData requires a valid conversationId. Use getCurrentConversationId() to get the current conversationId."), y.logEvent("character_manager", "error", {
|
|
3848
|
+
characterId: this.avatar.id,
|
|
3849
|
+
event: "keyframes_missing_conversationid",
|
|
3850
|
+
receivedConversationId: t
|
|
3851
|
+
});
|
|
3852
|
+
return;
|
|
3853
|
+
}
|
|
3854
|
+
const n = this.getEffectiveConversationId();
|
|
3855
|
+
if (!n || t !== n) {
|
|
3856
|
+
h.warn(`[AvatarController] Ignoring mismatched keyframes - expected conversationId: ${n}, received conversationId: ${t}`), y.logEvent("character_manager", "warning", {
|
|
3857
|
+
characterId: this.avatar.id,
|
|
3858
|
+
event: "keyframes_conversationid_mismatch",
|
|
3859
|
+
expectedConversationId: n,
|
|
3860
|
+
receivedConversationId: t
|
|
3861
|
+
});
|
|
3862
|
+
return;
|
|
3863
|
+
}
|
|
3864
|
+
if (this.isAudioOnlyMode) {
|
|
3865
|
+
h.warn("[AvatarController] Ignoring animation data in audio-only mode"), y.logEvent("character_manager", "info", {
|
|
3866
|
+
characterId: this.avatar.id,
|
|
3867
|
+
event: "animation_data_ignored_audio_only",
|
|
3868
|
+
conversationId: t
|
|
3869
|
+
});
|
|
3870
|
+
return;
|
|
3871
|
+
}
|
|
3872
|
+
if (!e || e.length === 0) {
|
|
3873
|
+
h.warn("[AvatarController] Empty animation data received - enabling audio-only mode"), y.logEvent("character_manager", "info", {
|
|
3874
|
+
characterId: this.avatar.id,
|
|
3875
|
+
event: "empty_animation_data_audio_only_fallback",
|
|
3876
|
+
conversationId: t
|
|
3877
|
+
}), this.enableAudioOnlyMode();
|
|
3878
|
+
return;
|
|
3879
|
+
}
|
|
3880
|
+
if (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) {
|
|
3881
|
+
const a = I.audio.sampleRate * 2;
|
|
3882
|
+
this.pendingAudioChunks.reduce((s, o) => s + o.data.length, 0) >= a && this.startStreamingPlayback().catch((s) => {
|
|
3883
|
+
var o;
|
|
3884
|
+
h.error("[AvatarController] Failed to auto-start playback:", s), (o = this.onError) == null || o.call(this, new Q("Failed to start playback", "PLAYBACK_START_FAILED"));
|
|
3885
|
+
});
|
|
3886
|
+
}
|
|
3838
3887
|
}
|
|
3839
3888
|
// ========== Common Interface ==========
|
|
3840
3889
|
/**
|
|
@@ -3843,10 +3892,10 @@ class ba {
|
|
|
3843
3892
|
*/
|
|
3844
3893
|
pause() {
|
|
3845
3894
|
var e, t, n;
|
|
3846
|
-
!this.isPlaying || this.currentState ===
|
|
3895
|
+
!this.isPlaying || this.currentState === M.paused || (h.log("[AvatarController] Pausing playback"), (e = this.animationPlayer) == null || e.pause(), this.stopPlaybackLoop(), this.currentState = M.paused, (t = this.onAvatarState) == null || t.call(this, M.paused), h.log("[AvatarController] Playback paused"), y.logEvent("character_player", "info", {
|
|
3847
3896
|
characterId: this.avatar.id,
|
|
3848
3897
|
event: "playback_paused",
|
|
3849
|
-
|
|
3898
|
+
conversationId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentConversationId()) || void 0
|
|
3850
3899
|
}));
|
|
3851
3900
|
}
|
|
3852
3901
|
/**
|
|
@@ -3856,10 +3905,10 @@ class ba {
|
|
|
3856
3905
|
*/
|
|
3857
3906
|
async resume() {
|
|
3858
3907
|
var e, t, n;
|
|
3859
|
-
!this.isPlaying || this.currentState !==
|
|
3908
|
+
!this.isPlaying || this.currentState !== M.paused || (h.log("[AvatarController] Resuming playback"), await ((e = this.animationPlayer) == null ? void 0 : e.resume()), this.startPlaybackLoop(), this.currentState = M.playing, (t = this.onAvatarState) == null || t.call(this, M.playing), h.log("[AvatarController] Playback resumed"), y.logEvent("character_player", "info", {
|
|
3860
3909
|
characterId: this.avatar.id,
|
|
3861
3910
|
event: "playback_resumed",
|
|
3862
|
-
|
|
3911
|
+
conversationId: ((n = this.networkLayer) == null ? void 0 : n.getCurrentConversationId()) || void 0
|
|
3863
3912
|
}));
|
|
3864
3913
|
}
|
|
3865
3914
|
/**
|
|
@@ -3867,15 +3916,15 @@ class ba {
|
|
|
3867
3916
|
*/
|
|
3868
3917
|
interrupt() {
|
|
3869
3918
|
var e;
|
|
3870
|
-
this.currentState ===
|
|
3871
|
-
})), this.stopPlayback(), this.emit("interrupt"), this.
|
|
3919
|
+
this.currentState === M.paused && ((e = this.animationPlayer) == null || e.resume().catch(() => {
|
|
3920
|
+
})), this.stopPlayback(), this.emit("interrupt"), this.clearPlaybackData(), this.resetConversationIdState(), this.isAudioOnlyMode = !1;
|
|
3872
3921
|
}
|
|
3873
3922
|
/**
|
|
3874
3923
|
* Clear all data and resources
|
|
3875
3924
|
*/
|
|
3876
3925
|
clear() {
|
|
3877
3926
|
var e, t;
|
|
3878
|
-
this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.
|
|
3927
|
+
this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.clearPlaybackData(), this.isConnected = !1, this.currentState = M.idle, (t = this.onAvatarState) == null || t.call(this, M.idle), this.networkLayer || (this.currentConversationId = null), this.reqEnd = !1;
|
|
3879
3928
|
}
|
|
3880
3929
|
/**
|
|
3881
3930
|
* Dispose controller, clean up all callbacks to avoid memory leaks
|
|
@@ -3885,9 +3934,44 @@ class ba {
|
|
|
3885
3934
|
dispose() {
|
|
3886
3935
|
this.onConnectionState = null, this.onAvatarState = null, this.onError = null, this.renderCallback = void 0, this.transitionCompleteCallback = void 0, this.eventListeners.clear();
|
|
3887
3936
|
}
|
|
3937
|
+
// ========== Internal Helper Methods ==========
|
|
3938
|
+
/**
|
|
3939
|
+
* Generate new conversation ID and log conversation started event
|
|
3940
|
+
* @private
|
|
3941
|
+
*/
|
|
3942
|
+
generateAndLogNewConversationId() {
|
|
3943
|
+
const e = er();
|
|
3944
|
+
return y.logEvent("character_manager", "info", {
|
|
3945
|
+
characterId: this.avatar.id,
|
|
3946
|
+
event: "conversation_started",
|
|
3947
|
+
conversationId: e
|
|
3948
|
+
}), e;
|
|
3949
|
+
}
|
|
3950
|
+
/**
|
|
3951
|
+
* Clear playback data (keyframes, audio chunks, and playback state)
|
|
3952
|
+
* @private
|
|
3953
|
+
*/
|
|
3954
|
+
clearPlaybackData() {
|
|
3955
|
+
this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.keyframesOffset = 0, this.isAudioOnlyMode = !1;
|
|
3956
|
+
}
|
|
3957
|
+
/**
|
|
3958
|
+
* Reset conversation ID state (for both network and external modes)
|
|
3959
|
+
* @private
|
|
3960
|
+
*/
|
|
3961
|
+
resetConversationIdState() {
|
|
3962
|
+
this.networkLayer ? this.networkLayer.resetConversationId() : this.currentConversationId = null, this.reqEnd = !1, this.isAudioOnlyMode = !1;
|
|
3963
|
+
}
|
|
3964
|
+
/**
|
|
3965
|
+
* Get effective conversation ID (handles both network and external modes)
|
|
3966
|
+
* @private
|
|
3967
|
+
*/
|
|
3968
|
+
getEffectiveConversationId() {
|
|
3969
|
+
var e;
|
|
3970
|
+
return this.playbackMode === me.network ? ((e = this.networkLayer) == null ? void 0 : e.getCurrentConversationId()) || null : this.currentConversationId;
|
|
3971
|
+
}
|
|
3888
3972
|
// ========== Internal Methods (for NetworkLayer and AvatarView use) ==========
|
|
3889
3973
|
/**
|
|
3890
|
-
* Start streaming playback (internal method, called by NetworkLayer or
|
|
3974
|
+
* Start streaming playback (internal method, called by NetworkLayer or playback())
|
|
3891
3975
|
* @internal
|
|
3892
3976
|
*/
|
|
3893
3977
|
startStreamingPlayback() {
|
|
@@ -3929,10 +4013,17 @@ class ba {
|
|
|
3929
4013
|
*/
|
|
3930
4014
|
async startStreamingPlaybackInternal() {
|
|
3931
4015
|
var e, t, n;
|
|
3932
|
-
if (!this.animationPlayer)
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
4016
|
+
if (this.animationPlayer || (this.animationPlayer = new ae()), !this.animationPlayer.isStreamingReady())
|
|
4017
|
+
try {
|
|
4018
|
+
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
4019
|
+
} catch (a) {
|
|
4020
|
+
const i = a instanceof Error ? a.message : String(a);
|
|
4021
|
+
throw h.error("[AvatarController] Failed to create streaming player:", i), y.logEvent("character_player", "error", {
|
|
4022
|
+
characterId: this.avatar.id,
|
|
4023
|
+
event: "streaming_player_init_failed",
|
|
4024
|
+
reason: i
|
|
4025
|
+
}), a;
|
|
4026
|
+
}
|
|
3936
4027
|
if (!this.currentKeyframes || this.currentKeyframes.length === 0) {
|
|
3937
4028
|
h.warn("[AvatarController] No animation keyframes to play");
|
|
3938
4029
|
return;
|
|
@@ -3940,21 +4031,21 @@ class ba {
|
|
|
3940
4031
|
try {
|
|
3941
4032
|
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
3942
4033
|
var i, s;
|
|
3943
|
-
this.isPlaying = !1, this.currentState =
|
|
4034
|
+
this.isPlaying = !1, this.currentState = M.idle, (i = this.onAvatarState) == null || i.call(this, M.idle), this.emit("stopRendering"), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.resetConversationId() : this.currentConversationId = null, this.reqEnd = !1, this.isAudioOnlyMode = !1, y.logEvent("character_player", "info", {
|
|
3944
4035
|
characterId: this.avatar.id,
|
|
3945
4036
|
event: "playback_ended",
|
|
3946
|
-
|
|
4037
|
+
conversationId: ((s = this.networkLayer) == null ? void 0 : s.getCurrentConversationId()) || void 0
|
|
3947
4038
|
});
|
|
3948
4039
|
}), this.emit("startRendering");
|
|
3949
4040
|
const a = this.animationPlayer.getStreamingPlayer();
|
|
3950
|
-
a && a.setAutoStart(!1), a && await a.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState =
|
|
4041
|
+
a && a.setAutoStart(!1), a && await a.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = M.playing, (e = this.onAvatarState) == null || e.call(this, M.playing), this.startPlaybackLoop(), y.logEvent("character_player", "info", {
|
|
3951
4042
|
characterId: this.avatar.id,
|
|
3952
4043
|
event: "playback_started",
|
|
3953
|
-
|
|
4044
|
+
conversationId: ((t = this.networkLayer) == null ? void 0 : t.getCurrentConversationId()) || void 0
|
|
3954
4045
|
});
|
|
3955
4046
|
} catch (a) {
|
|
3956
4047
|
const i = a instanceof Error ? a.message : String(a);
|
|
3957
|
-
h.error("[AvatarController] Failed to start streaming playback:", i), (n = this.onError) == null || n.call(this, new
|
|
4048
|
+
h.error("[AvatarController] Failed to start streaming playback:", i), (n = this.onError) == null || n.call(this, new Q("Failed to start streaming playback", "INIT_FAILED")), this.isPlaying = !1;
|
|
3958
4049
|
}
|
|
3959
4050
|
}
|
|
3960
4051
|
/**
|
|
@@ -3963,8 +4054,8 @@ class ba {
|
|
|
3963
4054
|
startPlaybackLoop() {
|
|
3964
4055
|
if (this.playbackLoopId)
|
|
3965
4056
|
return;
|
|
3966
|
-
const e =
|
|
3967
|
-
if (!this.isPlaying || this.currentState ===
|
|
4057
|
+
const e = I.animation.fps, t = async () => {
|
|
4058
|
+
if (!this.isPlaying || this.currentState === M.paused || !this.animationPlayer) {
|
|
3968
4059
|
this.playbackLoopId = null;
|
|
3969
4060
|
return;
|
|
3970
4061
|
}
|
|
@@ -3982,13 +4073,13 @@ class ba {
|
|
|
3982
4073
|
return;
|
|
3983
4074
|
}
|
|
3984
4075
|
if (this.lastRenderedFrameIndex = a, this.currentKeyframes.length > this.MAX_KEYFRAMES) {
|
|
3985
|
-
const s = this.KEYFRAMES_CLEANUP_THRESHOLD,
|
|
3986
|
-
|
|
4076
|
+
const s = this.KEYFRAMES_CLEANUP_THRESHOLD, o = a - s;
|
|
4077
|
+
o > 0 && o < a && (this.currentKeyframes.splice(0, o), this.keyframesOffset += o, i = a - this.keyframesOffset, i < 0 && (i = 0), i >= this.currentKeyframes.length && (i = this.currentKeyframes.length - 1), h.log(`[AvatarController] Cleaned up ${o} old keyframes (kept ${this.currentKeyframes.length} frames, offset: ${this.keyframesOffset})`));
|
|
3987
4078
|
}
|
|
3988
4079
|
if (i >= 0 && i < this.currentKeyframes.length) {
|
|
3989
|
-
const s = this.currentKeyframes[i],
|
|
3990
|
-
if (
|
|
3991
|
-
const p = await
|
|
4080
|
+
const s = this.currentKeyframes[i], o = Vt(s), l = y.getAvatarCore();
|
|
4081
|
+
if (l) {
|
|
4082
|
+
const p = await l.computeFrameFlatFromParams(o, this.characterHandle ?? void 0);
|
|
3992
4083
|
p && this.renderCallback && this.renderCallback(p, a);
|
|
3993
4084
|
}
|
|
3994
4085
|
}
|
|
@@ -4006,6 +4097,73 @@ class ba {
|
|
|
4006
4097
|
stopPlaybackLoop() {
|
|
4007
4098
|
this.playbackLoopId && (cancelAnimationFrame(this.playbackLoopId), this.playbackLoopId = null);
|
|
4008
4099
|
}
|
|
4100
|
+
// ========== Audio Only Mode ==========
|
|
4101
|
+
/**
|
|
4102
|
+
* 启用音频独立播放模式(当服务器错误或超时时调用)
|
|
4103
|
+
* 此模式下,音频会独立播放,不依赖动画数据
|
|
4104
|
+
* 一旦启用,本次会话后续的动画数据将被忽略
|
|
4105
|
+
* @private
|
|
4106
|
+
*/
|
|
4107
|
+
enableAudioOnlyMode() {
|
|
4108
|
+
this.isAudioOnlyMode || (h.warn("[AvatarController] Enabling audio-only playback mode"), this.isAudioOnlyMode = !0, !this.isPlaying && this.pendingAudioChunks.length > 0 && this.startAudioOnlyPlayback().catch((e) => {
|
|
4109
|
+
h.error("[AvatarController] Failed to start audio-only playback:", e), this.isAudioOnlyMode = !1;
|
|
4110
|
+
}));
|
|
4111
|
+
}
|
|
4112
|
+
/**
|
|
4113
|
+
* 音频独立播放(完全独立的逻辑,不影响正常播放流程)
|
|
4114
|
+
* @private
|
|
4115
|
+
*/
|
|
4116
|
+
async startAudioOnlyPlayback() {
|
|
4117
|
+
var e, t;
|
|
4118
|
+
if (this.animationPlayer || (this.animationPlayer = new ae()), !this.animationPlayer.isStreamingReady())
|
|
4119
|
+
try {
|
|
4120
|
+
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
4121
|
+
} catch (n) {
|
|
4122
|
+
const a = n instanceof Error ? n.message : String(n);
|
|
4123
|
+
throw h.error("[AvatarController] Failed to create streaming player for audio-only mode:", a), y.logEvent("character_player", "error", {
|
|
4124
|
+
characterId: this.avatar.id,
|
|
4125
|
+
event: "audio_only_streaming_player_init_failed",
|
|
4126
|
+
reason: a
|
|
4127
|
+
}), n;
|
|
4128
|
+
}
|
|
4129
|
+
try {
|
|
4130
|
+
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
4131
|
+
var a;
|
|
4132
|
+
this.isPlaying = !1, this.currentState = M.idle, (a = this.onAvatarState) == null || a.call(this, M.idle), this.isAudioOnlyMode = !1, this.clearPlaybackData(), this.resetConversationIdState(), y.logEvent("character_player", "info", {
|
|
4133
|
+
characterId: this.avatar.id,
|
|
4134
|
+
event: "audio_only_playback_ended",
|
|
4135
|
+
conversationId: this.getEffectiveConversationId() || void 0
|
|
4136
|
+
});
|
|
4137
|
+
});
|
|
4138
|
+
const n = this.animationPlayer.getStreamingPlayer();
|
|
4139
|
+
n && n.setAutoStart(!0), n && await n.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = M.playing, (e = this.onAvatarState) == null || e.call(this, M.playing), this.startAudioMonitoringLoop(), y.logEvent("character_player", "info", {
|
|
4140
|
+
characterId: this.avatar.id,
|
|
4141
|
+
event: "audio_only_playback_started",
|
|
4142
|
+
conversationId: this.getEffectiveConversationId() || void 0
|
|
4143
|
+
});
|
|
4144
|
+
} catch (n) {
|
|
4145
|
+
const a = n instanceof Error ? n.message : String(n);
|
|
4146
|
+
throw h.error("[AvatarController] Failed to start audio-only playback:", a), (t = this.onError) == null || t.call(this, new Q("Failed to start audio-only playback", "AUDIO_ONLY_INIT_FAILED")), this.isPlaying = !1, this.isAudioOnlyMode = !1, n;
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
/**
|
|
4150
|
+
* 音频监控循环(仅用于音频独立模式)
|
|
4151
|
+
* 只检测音频是否结束,不进行动画渲染
|
|
4152
|
+
* @private
|
|
4153
|
+
*/
|
|
4154
|
+
startAudioMonitoringLoop() {
|
|
4155
|
+
if (this.playbackLoopId)
|
|
4156
|
+
return;
|
|
4157
|
+
const e = () => {
|
|
4158
|
+
var t;
|
|
4159
|
+
if (!this.isAudioOnlyMode || !this.isPlaying) {
|
|
4160
|
+
this.playbackLoopId = null;
|
|
4161
|
+
return;
|
|
4162
|
+
}
|
|
4163
|
+
(t = this.animationPlayer) != null && t.isPlaying() ? this.playbackLoopId = requestAnimationFrame(e) : this.playbackLoopId = null;
|
|
4164
|
+
};
|
|
4165
|
+
this.playbackLoopId = requestAnimationFrame(e);
|
|
4166
|
+
}
|
|
4009
4167
|
/**
|
|
4010
4168
|
* Stop playback
|
|
4011
4169
|
*/
|
|
@@ -4016,7 +4174,7 @@ class ba {
|
|
|
4016
4174
|
const t = this.animationPlayer.getStreamingPlayer();
|
|
4017
4175
|
t == null || t.stop();
|
|
4018
4176
|
}
|
|
4019
|
-
this.emit("stopRendering"), this.isPlaying = !1, this.currentState =
|
|
4177
|
+
this.emit("stopRendering"), this.isPlaying = !1, this.currentState = M.idle, (e = this.onAvatarState) == null || e.call(this, M.idle);
|
|
4020
4178
|
}
|
|
4021
4179
|
/**
|
|
4022
4180
|
* Clean up players
|
|
@@ -4028,7 +4186,7 @@ class ba {
|
|
|
4028
4186
|
* Add audio chunk to buffer
|
|
4029
4187
|
*/
|
|
4030
4188
|
addAudioChunkToBuffer(e, t) {
|
|
4031
|
-
if (this.animationPlayer || (this.animationPlayer = new
|
|
4189
|
+
if (this.animationPlayer || (this.animationPlayer = new ae()), this.isPlaying && this.animationPlayer.isStreamingReady())
|
|
4032
4190
|
this.animationPlayer.addAudioChunk(e, t);
|
|
4033
4191
|
else {
|
|
4034
4192
|
if (this.pendingAudioChunks.length >= this.MAX_PENDING_AUDIO_CHUNKS) {
|
|
@@ -4052,7 +4210,7 @@ class ba {
|
|
|
4052
4210
|
n && n.forEach((a) => a(t));
|
|
4053
4211
|
}
|
|
4054
4212
|
}
|
|
4055
|
-
function
|
|
4213
|
+
function ar(r) {
|
|
4056
4214
|
if (r instanceof Error)
|
|
4057
4215
|
return r.message;
|
|
4058
4216
|
if (typeof r == "string")
|
|
@@ -4068,9 +4226,9 @@ function nr(r) {
|
|
|
4068
4226
|
}
|
|
4069
4227
|
return String(r);
|
|
4070
4228
|
}
|
|
4071
|
-
async function
|
|
4229
|
+
async function _a(r) {
|
|
4072
4230
|
try {
|
|
4073
|
-
const e = {}, t =
|
|
4231
|
+
const e = {}, t = y.appId, n = y.sessionToken;
|
|
4074
4232
|
t && (e["X-App-Id"] = t), n && (e.Authorization = `Bearer ${n}`);
|
|
4075
4233
|
const a = await fetch(r, {
|
|
4076
4234
|
headers: Object.keys(e).length > 0 ? e : void 0
|
|
@@ -4079,23 +4237,23 @@ async function Ca(r) {
|
|
|
4079
4237
|
throw new Error(`HTTP ${a.status} ${a.statusText}`);
|
|
4080
4238
|
return await a.arrayBuffer();
|
|
4081
4239
|
} catch (e) {
|
|
4082
|
-
const t =
|
|
4240
|
+
const t = ar(e);
|
|
4083
4241
|
throw new Error(`[downloadResource] ${r} → ${t}`);
|
|
4084
4242
|
}
|
|
4085
4243
|
}
|
|
4086
|
-
const
|
|
4087
|
-
async function
|
|
4088
|
-
const e =
|
|
4244
|
+
const Pa = 50, re = /* @__PURE__ */ new Map();
|
|
4245
|
+
async function Ne(r) {
|
|
4246
|
+
const e = re.get(r);
|
|
4089
4247
|
if (e)
|
|
4090
|
-
return
|
|
4091
|
-
const t = await
|
|
4092
|
-
if (
|
|
4093
|
-
const n =
|
|
4094
|
-
n &&
|
|
4248
|
+
return re.delete(r), re.set(r, e), e;
|
|
4249
|
+
const t = await _a(r);
|
|
4250
|
+
if (re.size >= Pa) {
|
|
4251
|
+
const n = re.keys().next().value;
|
|
4252
|
+
n && re.delete(n);
|
|
4095
4253
|
}
|
|
4096
|
-
return
|
|
4254
|
+
return re.set(r, t), t;
|
|
4097
4255
|
}
|
|
4098
|
-
class
|
|
4256
|
+
class ir {
|
|
4099
4257
|
constructor(e = "/") {
|
|
4100
4258
|
d(this, "baseAssetsPath");
|
|
4101
4259
|
this.baseAssetsPath = e;
|
|
@@ -4105,7 +4263,7 @@ class ar {
|
|
|
4105
4263
|
* Falls back to global CDN config if not provided by API
|
|
4106
4264
|
*/
|
|
4107
4265
|
async loadTemplateResources(e, t = null) {
|
|
4108
|
-
var c, u, m,
|
|
4266
|
+
var c, u, m, v;
|
|
4109
4267
|
if (!(e && Object.keys(e).length > 0))
|
|
4110
4268
|
return h.log("⚠️ FLAME resources not provided in CharacterMeta, using global CDN config"), this.loadGlobalFlameResources(t);
|
|
4111
4269
|
h.log("✅ Using FLAME resources from CharacterMeta API");
|
|
@@ -4123,27 +4281,27 @@ class ar {
|
|
|
4123
4281
|
resourceName: "teeth.pb"
|
|
4124
4282
|
},
|
|
4125
4283
|
teethNpz: {
|
|
4126
|
-
url: (
|
|
4284
|
+
url: (v = e.teethNpz) == null ? void 0 : v.remote,
|
|
4127
4285
|
resourceName: "teeth.npz"
|
|
4128
4286
|
}
|
|
4129
4287
|
}, i = Object.keys(a).length;
|
|
4130
4288
|
let s = 0;
|
|
4131
|
-
const
|
|
4132
|
-
t && (
|
|
4289
|
+
const o = (S, A) => {
|
|
4290
|
+
t && (A && s++, t({
|
|
4133
4291
|
stage: "template",
|
|
4134
|
-
filename:
|
|
4292
|
+
filename: S,
|
|
4135
4293
|
loaded: s,
|
|
4136
4294
|
total: i,
|
|
4137
4295
|
progress: Math.round(s / i * 100)
|
|
4138
4296
|
}));
|
|
4139
|
-
},
|
|
4140
|
-
if (!
|
|
4141
|
-
throw new Error(`[loadTemplateResources] Missing CDN URL for ${
|
|
4142
|
-
|
|
4143
|
-
const
|
|
4144
|
-
h.log(`✅ ${
|
|
4297
|
+
}, l = {}, p = Object.entries(a).map(async ([S, { url: A, resourceName: b }]) => {
|
|
4298
|
+
if (!A)
|
|
4299
|
+
throw new Error(`[loadTemplateResources] Missing CDN URL for ${S} (${b})`);
|
|
4300
|
+
o(b, !1), h.log(`📥 Loading ${S} from API CDN: ${A}`);
|
|
4301
|
+
const E = await Ne(A);
|
|
4302
|
+
h.log(`✅ ${S} loaded: ${E.byteLength} bytes`), l[S] = E, o(b, !0);
|
|
4145
4303
|
});
|
|
4146
|
-
return await Promise.all(p),
|
|
4304
|
+
return await Promise.all(p), l;
|
|
4147
4305
|
}
|
|
4148
4306
|
/**
|
|
4149
4307
|
* Load global FLAME template resources from CDN
|
|
@@ -4151,7 +4309,7 @@ class ar {
|
|
|
4151
4309
|
* @internal 供 AvatarKit 使用
|
|
4152
4310
|
*/
|
|
4153
4311
|
async loadGlobalFlameResources(e = null) {
|
|
4154
|
-
const { cdnBaseUrl: t, resources: n } =
|
|
4312
|
+
const { cdnBaseUrl: t, resources: n } = I.flame, a = {
|
|
4155
4313
|
flameModel: {
|
|
4156
4314
|
url: `${t}/${n.flameModel}`,
|
|
4157
4315
|
resourceName: n.flameModel
|
|
@@ -4170,7 +4328,7 @@ class ar {
|
|
|
4170
4328
|
}
|
|
4171
4329
|
}, i = Object.keys(a).length;
|
|
4172
4330
|
let s = 0;
|
|
4173
|
-
const
|
|
4331
|
+
const o = (c, u) => {
|
|
4174
4332
|
e && (u && s++, e({
|
|
4175
4333
|
stage: "template",
|
|
4176
4334
|
filename: c,
|
|
@@ -4178,12 +4336,12 @@ class ar {
|
|
|
4178
4336
|
total: i,
|
|
4179
4337
|
progress: Math.round(s / i * 100)
|
|
4180
4338
|
}));
|
|
4181
|
-
},
|
|
4182
|
-
|
|
4183
|
-
const
|
|
4184
|
-
h.log(`✅ ${c} loaded: ${
|
|
4339
|
+
}, l = {}, p = Object.entries(a).map(async ([c, { url: u, resourceName: m }]) => {
|
|
4340
|
+
o(m, !1), h.log(`📥 Loading ${c} from global CDN: ${u}`);
|
|
4341
|
+
const v = await Ne(u);
|
|
4342
|
+
h.log(`✅ ${c} loaded: ${v.byteLength} bytes`), l[c] = v, o(m, !0);
|
|
4185
4343
|
});
|
|
4186
|
-
return await Promise.all(p),
|
|
4344
|
+
return await Promise.all(p), l;
|
|
4187
4345
|
}
|
|
4188
4346
|
/**
|
|
4189
4347
|
* Load camera settings from CharacterMeta (optional)
|
|
@@ -4197,14 +4355,14 @@ class ar {
|
|
|
4197
4355
|
}
|
|
4198
4356
|
try {
|
|
4199
4357
|
h.log(`📥 Loading camera info from: ${t}`);
|
|
4200
|
-
const i = {}, s =
|
|
4201
|
-
s && (i["X-App-Id"] = s),
|
|
4202
|
-
const
|
|
4358
|
+
const i = {}, s = y.appId, o = y.sessionToken;
|
|
4359
|
+
s && (i["X-App-Id"] = s), o && (i.Authorization = `Bearer ${o}`);
|
|
4360
|
+
const l = await fetch(t, {
|
|
4203
4361
|
headers: Object.keys(i).length > 0 ? i : void 0
|
|
4204
4362
|
});
|
|
4205
|
-
if (!
|
|
4206
|
-
throw new Error(`Failed to fetch camera info: ${
|
|
4207
|
-
const p = await
|
|
4363
|
+
if (!l.ok)
|
|
4364
|
+
throw new Error(`Failed to fetch camera info: ${l.statusText}`);
|
|
4365
|
+
const p = await l.json();
|
|
4208
4366
|
return h.log("✅ Camera info loaded:", p), p;
|
|
4209
4367
|
} catch (i) {
|
|
4210
4368
|
h.warn("⚠️ Failed to load camera info, using default:", i);
|
|
@@ -4215,66 +4373,65 @@ class ar {
|
|
|
4215
4373
|
* Load character data from CharacterMeta (iOS compatible)
|
|
4216
4374
|
*/
|
|
4217
4375
|
async loadCharacterData(e, t) {
|
|
4218
|
-
var
|
|
4219
|
-
const {
|
|
4220
|
-
if (!
|
|
4221
|
-
const
|
|
4222
|
-
throw
|
|
4376
|
+
var v, S, A, b, E, B, _, X, G;
|
|
4377
|
+
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, s = (G = (X = (_ = e.animations) == null ? void 0 : _.frameIdle) == null ? void 0 : X.resource) == null ? void 0 : G.remote;
|
|
4378
|
+
if (!a || !i) {
|
|
4379
|
+
const R = "Missing required resources: shape or gsStandard (point cloud)";
|
|
4380
|
+
throw y.logEvent("character_load", "error", {
|
|
4223
4381
|
characterId: e.characterId ?? "unknown",
|
|
4224
4382
|
stage: "resource_validation",
|
|
4225
|
-
reason:
|
|
4226
|
-
}), new Error(
|
|
4383
|
+
reason: R
|
|
4384
|
+
}), new Error(R);
|
|
4227
4385
|
}
|
|
4228
|
-
const
|
|
4229
|
-
{ key: "shape", url:
|
|
4230
|
-
{ key: "pointCloud", url:
|
|
4386
|
+
const o = [
|
|
4387
|
+
{ key: "shape", url: a, filename: "shape.pb" },
|
|
4388
|
+
{ key: "pointCloud", url: i, filename: "point_cloud.ply" }
|
|
4231
4389
|
];
|
|
4232
|
-
|
|
4233
|
-
let
|
|
4234
|
-
const
|
|
4235
|
-
|
|
4390
|
+
s && o.push({ key: "idleAnimation", url: s, filename: "idle.pb", optional: !0 });
|
|
4391
|
+
let l = 0;
|
|
4392
|
+
const p = o.length, c = (R, z) => {
|
|
4393
|
+
n && (z && l++, n({
|
|
4236
4394
|
stage: "character",
|
|
4237
|
-
filename:
|
|
4238
|
-
loaded:
|
|
4239
|
-
total:
|
|
4240
|
-
progress: Math.round(
|
|
4395
|
+
filename: R,
|
|
4396
|
+
loaded: l,
|
|
4397
|
+
total: p,
|
|
4398
|
+
progress: Math.round(l / p * 100)
|
|
4241
4399
|
}));
|
|
4242
|
-
},
|
|
4243
|
-
|
|
4400
|
+
}, u = {}, m = o.map(async ({ key: R, url: z, filename: W, optional: Y }) => {
|
|
4401
|
+
c(W, !1);
|
|
4244
4402
|
try {
|
|
4245
|
-
const
|
|
4246
|
-
return
|
|
4247
|
-
} catch (
|
|
4248
|
-
if (!
|
|
4249
|
-
throw
|
|
4250
|
-
return h.warn(`⚠️ Optional resource ${
|
|
4403
|
+
const V = await Ne(z);
|
|
4404
|
+
return R === "shape" ? u.shape = V : R === "pointCloud" ? u.pointCloud = V : R === "idleAnimation" && (u.idleAnimation = V), c(W, !0), { key: R, success: !0 };
|
|
4405
|
+
} catch (V) {
|
|
4406
|
+
if (!Y)
|
|
4407
|
+
throw V;
|
|
4408
|
+
return h.warn(`⚠️ Optional resource ${W} failed to load:`, V), c(W, !0), { key: R, success: !1 };
|
|
4251
4409
|
}
|
|
4252
4410
|
});
|
|
4253
|
-
if (await Promise.all(
|
|
4254
|
-
const
|
|
4255
|
-
throw
|
|
4411
|
+
if (await Promise.all(m), !u.shape || !u.pointCloud) {
|
|
4412
|
+
const R = "Failed to load character data";
|
|
4413
|
+
throw y.logEvent("character_load", "error", {
|
|
4256
4414
|
characterId: e.characterId ?? "unknown",
|
|
4257
4415
|
stage: "download",
|
|
4258
|
-
reason:
|
|
4259
|
-
}), new Error(
|
|
4416
|
+
reason: R
|
|
4417
|
+
}), new Error(R);
|
|
4260
4418
|
}
|
|
4261
|
-
return
|
|
4419
|
+
return u;
|
|
4262
4420
|
}
|
|
4263
4421
|
/**
|
|
4264
4422
|
* Preload all resources (template + character data + camera info + settings)
|
|
4265
4423
|
*/
|
|
4266
4424
|
async preloadResources(e, t) {
|
|
4267
|
-
const {
|
|
4425
|
+
const { progressCallback: n = null } = t || {}, [a, i, s] = await Promise.all([
|
|
4268
4426
|
this.loadTemplateResources(e.flame, (o) => {
|
|
4269
|
-
|
|
4427
|
+
n && n({
|
|
4270
4428
|
...o,
|
|
4271
4429
|
stage: `template-${o.stage}`
|
|
4272
4430
|
});
|
|
4273
4431
|
}),
|
|
4274
4432
|
this.loadCharacterData(e, {
|
|
4275
|
-
loadMonologue: n,
|
|
4276
4433
|
progressCallback: (o) => {
|
|
4277
|
-
|
|
4434
|
+
n && n({
|
|
4278
4435
|
...o,
|
|
4279
4436
|
stage: `character-${o.stage}`
|
|
4280
4437
|
});
|
|
@@ -4283,9 +4440,9 @@ class ar {
|
|
|
4283
4440
|
this.loadCameraSettings(e)
|
|
4284
4441
|
]);
|
|
4285
4442
|
return {
|
|
4286
|
-
templateResources:
|
|
4287
|
-
characterData:
|
|
4288
|
-
preloadCameraSettings:
|
|
4443
|
+
templateResources: a,
|
|
4444
|
+
characterData: i,
|
|
4445
|
+
preloadCameraSettings: s,
|
|
4289
4446
|
characterSettings: e.characterSettings
|
|
4290
4447
|
};
|
|
4291
4448
|
}
|
|
@@ -4302,10 +4459,10 @@ class ar {
|
|
|
4302
4459
|
getSdkApiClient() {
|
|
4303
4460
|
return {
|
|
4304
4461
|
async request(e, t = {}) {
|
|
4305
|
-
const i =
|
|
4462
|
+
const i = y.getEnvironmentConfig().sdkApiBaseUrl + e, s = {
|
|
4306
4463
|
"Content-Type": "application/json"
|
|
4307
|
-
},
|
|
4308
|
-
|
|
4464
|
+
}, o = y.appId, l = y.sessionToken;
|
|
4465
|
+
o && (s["X-App-Id"] = o), l && (s.Authorization = `Bearer ${l}`);
|
|
4309
4466
|
try {
|
|
4310
4467
|
const p = await fetch(i, {
|
|
4311
4468
|
method: t.method || "GET",
|
|
@@ -4319,7 +4476,7 @@ class ar {
|
|
|
4319
4476
|
throw new Error(`HTTP ${p.status} ${p.statusText}`);
|
|
4320
4477
|
return p.json();
|
|
4321
4478
|
} catch (p) {
|
|
4322
|
-
const c =
|
|
4479
|
+
const c = ar(p);
|
|
4323
4480
|
throw new Error(`[SdkApiClient] ${i} → ${c}`);
|
|
4324
4481
|
}
|
|
4325
4482
|
}
|
|
@@ -4340,7 +4497,7 @@ class ar {
|
|
|
4340
4497
|
} catch (n) {
|
|
4341
4498
|
h.errorWithError("Failed to fetch character:", n);
|
|
4342
4499
|
const a = n && typeof n == "object" && "message" in n ? String(n.message) : "Failed to fetch character", i = n && typeof n == "object" && "data" in n && typeof n.data == "object" && ((t = n.data) != null && t.message) ? String(n.data.message) : null;
|
|
4343
|
-
throw
|
|
4500
|
+
throw y.logEvent("character_load", "error", {
|
|
4344
4501
|
characterId: e ?? "unknown",
|
|
4345
4502
|
stage: "fetch",
|
|
4346
4503
|
reason: i || a
|
|
@@ -4350,8 +4507,8 @@ class ar {
|
|
|
4350
4507
|
}
|
|
4351
4508
|
const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4352
4509
|
__proto__: null,
|
|
4353
|
-
AvatarDownloader:
|
|
4354
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
4510
|
+
AvatarDownloader: ir
|
|
4511
|
+
}, Symbol.toStringTag, { value: "Module" })), ke = class ke {
|
|
4355
4512
|
constructor() {
|
|
4356
4513
|
d(this, "avatarDownloader", null);
|
|
4357
4514
|
}
|
|
@@ -4359,7 +4516,7 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4359
4516
|
* 通过全局单例来访问
|
|
4360
4517
|
*/
|
|
4361
4518
|
static get shared() {
|
|
4362
|
-
return this._instance || (this._instance = new
|
|
4519
|
+
return this._instance || (this._instance = new ke()), this._instance;
|
|
4363
4520
|
}
|
|
4364
4521
|
/**
|
|
4365
4522
|
* 加载数字人
|
|
@@ -4368,36 +4525,35 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4368
4525
|
* @param options 加载选项
|
|
4369
4526
|
* @returns Promise<Avatar>
|
|
4370
4527
|
*/
|
|
4371
|
-
async load(e, t
|
|
4528
|
+
async load(e, t) {
|
|
4372
4529
|
h.log(`[AvatarManager] Loading avatar with id: ${e}`);
|
|
4373
4530
|
try {
|
|
4374
|
-
if (!
|
|
4531
|
+
if (!y.isInitialized)
|
|
4375
4532
|
throw new Error("AvatarKit not initialized. Please call AvatarKit.initialize() first.");
|
|
4376
|
-
this.avatarDownloader || (this.avatarDownloader = new
|
|
4377
|
-
const
|
|
4378
|
-
h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type:
|
|
4379
|
-
const
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
const o = 30 + l.progress / 100 * 70;
|
|
4533
|
+
this.avatarDownloader || (this.avatarDownloader = new ir()), h.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: le.downloading, progress: 10 });
|
|
4534
|
+
const n = await this.avatarDownloader.getCharacterById(e);
|
|
4535
|
+
h.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: le.downloading, progress: 30 });
|
|
4536
|
+
const a = await this.avatarDownloader.preloadResources(n, {
|
|
4537
|
+
progressCallback: (s) => {
|
|
4538
|
+
const o = 30 + s.progress / 100 * 70;
|
|
4383
4539
|
t == null || t({
|
|
4384
|
-
type:
|
|
4540
|
+
type: le.downloading,
|
|
4385
4541
|
progress: Math.round(o)
|
|
4386
4542
|
});
|
|
4387
4543
|
}
|
|
4388
4544
|
});
|
|
4389
4545
|
h.log("[AvatarManager] Step 3: Creating Avatar instance...");
|
|
4390
|
-
const
|
|
4391
|
-
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type:
|
|
4546
|
+
const i = new sn(e, n, a);
|
|
4547
|
+
return h.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: le.completed }), y.logEvent("character_load", "info", {
|
|
4392
4548
|
characterId: e,
|
|
4393
4549
|
event: "load_success"
|
|
4394
|
-
}),
|
|
4395
|
-
} catch (
|
|
4396
|
-
const
|
|
4397
|
-
throw h.error("Failed to load avatar:",
|
|
4550
|
+
}), i;
|
|
4551
|
+
} catch (n) {
|
|
4552
|
+
const a = n instanceof Error ? n.message : String(n);
|
|
4553
|
+
throw h.error("Failed to load avatar:", a), y.logEvent("character_load", "error", {
|
|
4398
4554
|
characterId: e,
|
|
4399
|
-
reason:
|
|
4400
|
-
}), t == null || t({ type:
|
|
4555
|
+
reason: a
|
|
4556
|
+
}), t == null || t({ type: le.failed, error: n }), n;
|
|
4401
4557
|
}
|
|
4402
4558
|
}
|
|
4403
4559
|
/**
|
|
@@ -4407,55 +4563,55 @@ const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4407
4563
|
this.avatarDownloader && this.avatarDownloader.clear();
|
|
4408
4564
|
}
|
|
4409
4565
|
};
|
|
4410
|
-
d(
|
|
4411
|
-
let Tt =
|
|
4412
|
-
const
|
|
4413
|
-
function
|
|
4566
|
+
d(ke, "_instance", null);
|
|
4567
|
+
let Tt = ke, ge = null, Bt = null, Dt = null, Ot = null, Nt = null, Ut = null;
|
|
4568
|
+
const Ke = 2048, zt = Ke - 1;
|
|
4569
|
+
function Ia(r, e, t) {
|
|
4414
4570
|
const a = r.length / 13;
|
|
4415
|
-
(!
|
|
4416
|
-
const i =
|
|
4417
|
-
for (let
|
|
4418
|
-
const
|
|
4419
|
-
i[
|
|
4420
|
-
}
|
|
4421
|
-
for (let
|
|
4422
|
-
const
|
|
4423
|
-
s[
|
|
4424
|
-
}
|
|
4425
|
-
|
|
4426
|
-
for (let
|
|
4427
|
-
p[
|
|
4571
|
+
(!ge || ge.length !== a) && (ge = new Float32Array(a), Bt = new Uint32Array(ge.buffer), Dt = new Uint32Array(a), Ot = new Uint32Array(a), Nt = new Uint32Array(a), Ut = new Uint32Array(Ke));
|
|
4572
|
+
const i = ge, s = Bt, o = Dt, l = Ot, p = Nt, c = Ut, u = e[0], m = e[1], v = e[2], S = t[0], A = t[1], b = t[2];
|
|
4573
|
+
for (let E = 0; E < a; E++) {
|
|
4574
|
+
const B = E * 13;
|
|
4575
|
+
i[E] = (r[B] - u) * S + (r[B + 1] - m) * A + (r[B + 2] - v) * b, o[E] = E;
|
|
4576
|
+
}
|
|
4577
|
+
for (let E = 0; E < a; E++) {
|
|
4578
|
+
const B = s[E];
|
|
4579
|
+
s[E] = B ^ (-(B >> 31) | 2147483648);
|
|
4580
|
+
}
|
|
4581
|
+
Ue(s, o, l, c, 0, a), Ue(s, l, o, c, 11, a), Ue(s, o, l, c, 22, a);
|
|
4582
|
+
for (let E = 0; E < a; E++)
|
|
4583
|
+
p[E] = l[a - 1 - E];
|
|
4428
4584
|
return p;
|
|
4429
4585
|
}
|
|
4430
|
-
function
|
|
4586
|
+
function Ue(r, e, t, n, a, i) {
|
|
4431
4587
|
n.fill(0);
|
|
4432
|
-
for (let
|
|
4433
|
-
const
|
|
4434
|
-
n[
|
|
4588
|
+
for (let o = 0; o < i; o++) {
|
|
4589
|
+
const l = r[e[o]] >> a & zt;
|
|
4590
|
+
n[l]++;
|
|
4435
4591
|
}
|
|
4436
4592
|
let s = 0;
|
|
4437
|
-
for (let
|
|
4438
|
-
const
|
|
4439
|
-
n[
|
|
4593
|
+
for (let o = 0; o < Ke; o++) {
|
|
4594
|
+
const l = n[o];
|
|
4595
|
+
n[o] = s, s += l;
|
|
4440
4596
|
}
|
|
4441
|
-
for (let
|
|
4442
|
-
const
|
|
4443
|
-
t[n[p]++] =
|
|
4597
|
+
for (let o = 0; o < i; o++) {
|
|
4598
|
+
const l = e[o], p = r[l] >> a & zt;
|
|
4599
|
+
t[n[p]++] = l;
|
|
4444
4600
|
}
|
|
4445
4601
|
}
|
|
4446
|
-
const
|
|
4447
|
-
let
|
|
4448
|
-
function
|
|
4449
|
-
const t = e.length, n = t *
|
|
4450
|
-
(!
|
|
4602
|
+
const _e = 13;
|
|
4603
|
+
let ve = null;
|
|
4604
|
+
function ka(r, e) {
|
|
4605
|
+
const t = e.length, n = t * _e;
|
|
4606
|
+
(!ve || ve.length !== n) && (ve = new Float32Array(n));
|
|
4451
4607
|
for (let a = 0; a < t; a++) {
|
|
4452
|
-
const s = e[a] *
|
|
4453
|
-
|
|
4454
|
-
r.subarray(s, s +
|
|
4455
|
-
|
|
4608
|
+
const s = e[a] * _e, o = a * _e;
|
|
4609
|
+
ve.set(
|
|
4610
|
+
r.subarray(s, s + _e),
|
|
4611
|
+
o
|
|
4456
4612
|
);
|
|
4457
4613
|
}
|
|
4458
|
-
return
|
|
4614
|
+
return ve;
|
|
4459
4615
|
}
|
|
4460
4616
|
const xa = `#version 300 es
|
|
4461
4617
|
precision highp float;
|
|
@@ -4487,7 +4643,7 @@ void main() {
|
|
|
4487
4643
|
// 预乘 alpha 输出(匹配 premultipliedAlpha: true)
|
|
4488
4644
|
// 颜色值需要乘以 alpha,这样 WebGL 才能正确混合
|
|
4489
4645
|
fragColor = vec4(v_color.rgb * alpha, alpha);
|
|
4490
|
-
}`,
|
|
4646
|
+
}`, Fa = `#version 300 es
|
|
4491
4647
|
precision highp float;
|
|
4492
4648
|
|
|
4493
4649
|
// 基础四边形顶点属性(共享4个顶点)
|
|
@@ -4847,7 +5003,7 @@ class Ma {
|
|
|
4847
5003
|
const t = e.createShader(e.VERTEX_SHADER);
|
|
4848
5004
|
if (!t)
|
|
4849
5005
|
throw new Error("Failed to create vertex shader");
|
|
4850
|
-
if (e.shaderSource(t,
|
|
5006
|
+
if (e.shaderSource(t, Fa), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS)) {
|
|
4851
5007
|
const i = e.getShaderInfoLog(t);
|
|
4852
5008
|
throw e.deleteShader(t), new Error(`Vertex shader compilation failed: ${i}`);
|
|
4853
5009
|
}
|
|
@@ -4883,7 +5039,7 @@ class Ma {
|
|
|
4883
5039
|
this.gl = null, this.isInitialized = !1;
|
|
4884
5040
|
}
|
|
4885
5041
|
}
|
|
4886
|
-
const
|
|
5042
|
+
const La = `/**
|
|
4887
5043
|
* WebGPU 3DGS 渲染着色器
|
|
4888
5044
|
*
|
|
4889
5045
|
* 实例化渲染:每个 splat 绘制一个四边形
|
|
@@ -5233,7 +5389,7 @@ class Ra {
|
|
|
5233
5389
|
return;
|
|
5234
5390
|
const e = this.device.createShaderModule({
|
|
5235
5391
|
label: "3DGS Render Shader",
|
|
5236
|
-
code:
|
|
5392
|
+
code: La
|
|
5237
5393
|
}), t = this.device.createBindGroupLayout({
|
|
5238
5394
|
label: "Uniform Bind Group Layout",
|
|
5239
5395
|
entries: [
|
|
@@ -5414,7 +5570,7 @@ class Ra {
|
|
|
5414
5570
|
(e = this.sortIndexBuffer) == null || e.destroy(), (t = this.splatDataBuffer) == null || t.destroy(), (n = this.quadVertexBuffer) == null || n.destroy(), (a = this.uniformBuffer) == null || a.destroy(), (i = this.device) == null || i.destroy(), this.sortIndexBuffer = null, this.splatDataBuffer = null, this.quadVertexBuffer = null, this.uniformBuffer = null, this.uniformBindGroup = null, this.storageBindGroup = null, this.device = null, this.context = null, this.renderPipeline = null;
|
|
5415
5571
|
}
|
|
5416
5572
|
}
|
|
5417
|
-
class
|
|
5573
|
+
class Ta {
|
|
5418
5574
|
// 排序耗时
|
|
5419
5575
|
constructor(e) {
|
|
5420
5576
|
d(this, "renderer", null);
|
|
@@ -5488,7 +5644,7 @@ class La {
|
|
|
5488
5644
|
if (!this.renderer || !this.originalPackedData)
|
|
5489
5645
|
return;
|
|
5490
5646
|
this.updateCameraMatrices();
|
|
5491
|
-
const e = Math.floor(this.originalPackedData.length / 13), t = performance.now(), n =
|
|
5647
|
+
const e = Math.floor(this.originalPackedData.length / 13), t = performance.now(), n = Ia(
|
|
5492
5648
|
this.originalPackedData,
|
|
5493
5649
|
this.camera.position,
|
|
5494
5650
|
this.getCameraForward()
|
|
@@ -5496,8 +5652,8 @@ class La {
|
|
|
5496
5652
|
if (this.sortTime = a, this.backend === "webgpu")
|
|
5497
5653
|
this.renderer.loadSplatsFromPackedData(this.originalPackedData, e, n);
|
|
5498
5654
|
else {
|
|
5499
|
-
const
|
|
5500
|
-
this.renderer.loadSplatsFromPackedData(
|
|
5655
|
+
const o = ka(this.originalPackedData, n);
|
|
5656
|
+
this.renderer.loadSplatsFromPackedData(o, e);
|
|
5501
5657
|
}
|
|
5502
5658
|
const i = performance.now();
|
|
5503
5659
|
this.renderer.render(
|
|
@@ -5556,16 +5712,16 @@ class La {
|
|
|
5556
5712
|
* Update camera matrices (with caching to avoid unnecessary updates)
|
|
5557
5713
|
*/
|
|
5558
5714
|
updateCameraMatrices() {
|
|
5559
|
-
const { position: e, target: t, up: n, fov: a, aspect: i, near: s, far:
|
|
5560
|
-
!(!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 !== s || this.cachedCameraParams.far !==
|
|
5715
|
+
const { position: e, target: t, up: n, fov: a, aspect: i, near: s, far: o } = this.camera;
|
|
5716
|
+
!(!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 !== s || this.cachedCameraParams.far !== o) && 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 = s, this.cachedCameraParams.far = o) : this.cachedCameraParams = {
|
|
5561
5717
|
position: [e[0], e[1], e[2]],
|
|
5562
5718
|
target: [t[0], t[1], t[2]],
|
|
5563
5719
|
up: [n[0], n[1], n[2]],
|
|
5564
5720
|
fov: a,
|
|
5565
5721
|
aspect: i,
|
|
5566
5722
|
near: s,
|
|
5567
|
-
far:
|
|
5568
|
-
}, this.updatePerspectiveMatrix(a, i, s,
|
|
5723
|
+
far: o
|
|
5724
|
+
}, this.updatePerspectiveMatrix(a, i, s, o), this.forwardCacheValid = !1, this.updateViewMatrix(e, t, n), this.matricesCacheValid = !0);
|
|
5569
5725
|
}
|
|
5570
5726
|
/**
|
|
5571
5727
|
* Get camera forward vector (cached version)
|
|
@@ -5585,8 +5741,8 @@ class La {
|
|
|
5585
5741
|
* Update perspective projection matrix (reuse buffer)
|
|
5586
5742
|
*/
|
|
5587
5743
|
updatePerspectiveMatrix(e, t, n, a) {
|
|
5588
|
-
const i = e * Math.PI / 180, s = 1 / Math.tan(i / 2),
|
|
5589
|
-
|
|
5744
|
+
const i = e * Math.PI / 180, s = 1 / Math.tan(i / 2), o = a / (n - a), l = this.projectionMatrix;
|
|
5745
|
+
l[0] = s / t, l[1] = 0, l[2] = 0, l[3] = 0, l[4] = 0, l[5] = s, l[6] = 0, l[7] = 0, l[8] = 0, l[9] = 0, l[10] = o, l[11] = -1, l[12] = 0, l[13] = 0, l[14] = o * n, l[15] = 0;
|
|
5590
5746
|
}
|
|
5591
5747
|
/**
|
|
5592
5748
|
* Update view matrix (directly update pre-allocated buffer to avoid per-frame allocation)
|
|
@@ -5600,48 +5756,56 @@ class La {
|
|
|
5600
5756
|
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];
|
|
5601
5757
|
const i = Math.hypot(this.tempRight[0], this.tempRight[1], this.tempRight[2]) || 1;
|
|
5602
5758
|
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];
|
|
5603
|
-
const s = this.viewMatrix,
|
|
5604
|
-
s[0] = this.tempRight[0], s[1] = this.tempUp[0], s[2] = -this.tempForward[0], s[3] = 0, s[4] = this.tempRight[1], s[5] = this.tempUp[1], s[6] = -this.tempForward[1], s[7] = 0, s[8] = this.tempRight[2], s[9] = this.tempUp[2], s[10] = -this.tempForward[2], s[11] = 0, s[12] =
|
|
5759
|
+
const s = this.viewMatrix, o = -e[0], l = -e[1], p = -e[2];
|
|
5760
|
+
s[0] = this.tempRight[0], s[1] = this.tempUp[0], s[2] = -this.tempForward[0], s[3] = 0, s[4] = this.tempRight[1], s[5] = this.tempUp[1], s[6] = -this.tempForward[1], s[7] = 0, s[8] = this.tempRight[2], s[9] = this.tempUp[2], s[10] = -this.tempForward[2], s[11] = 0, s[12] = o, s[13] = l, s[14] = p, s[15] = 1;
|
|
5605
5761
|
}
|
|
5606
5762
|
}
|
|
5607
|
-
function
|
|
5763
|
+
function ne(r, e, t) {
|
|
5608
5764
|
const n = Math.min(r.length, e.length), a = Array.from({ length: n });
|
|
5609
5765
|
for (let i = 0; i < n; i++)
|
|
5610
5766
|
a[i] = r[i] + (e[i] - r[i]) * t;
|
|
5611
5767
|
return a;
|
|
5612
5768
|
}
|
|
5613
|
-
function
|
|
5769
|
+
function Ba(r, e, t) {
|
|
5614
5770
|
const n = 0.5 - Math.cos(t * Math.PI) * 0.5;
|
|
5615
5771
|
return {
|
|
5616
|
-
translation:
|
|
5617
|
-
rotation:
|
|
5618
|
-
neckPose:
|
|
5619
|
-
jawPose:
|
|
5620
|
-
eyePose:
|
|
5772
|
+
translation: ne(r.translation || [0, 0, 0], e.translation || [0, 0, 0], n),
|
|
5773
|
+
rotation: ne(r.rotation || [0, 0, 0], e.rotation || [0, 0, 0], n),
|
|
5774
|
+
neckPose: ne(r.neckPose || [0, 0, 0], e.neckPose || [0, 0, 0], n),
|
|
5775
|
+
jawPose: ne(r.jawPose || [0, 0, 0], e.jawPose || [0, 0, 0], n),
|
|
5776
|
+
eyePose: ne(r.eyePose || [0, 0, 0, 0, 0, 0], e.eyePose || [0, 0, 0, 0, 0, 0], n),
|
|
5621
5777
|
eyeLid: (() => {
|
|
5622
5778
|
const a = r.eyeLid, i = e.eyeLid;
|
|
5623
|
-
return a && a.length > 0 && i && i.length > 0 ?
|
|
5779
|
+
return a && a.length > 0 && i && i.length > 0 ? ne(a, i, n) : a || i || [];
|
|
5624
5780
|
})(),
|
|
5625
|
-
expression:
|
|
5781
|
+
expression: ne(r.expression || [], e.expression || [], n)
|
|
5626
5782
|
};
|
|
5627
5783
|
}
|
|
5628
|
-
function
|
|
5784
|
+
function Da(r, e, t, n = 25) {
|
|
5629
5785
|
const a = Math.max(1, Math.floor(t / 1e3 * n)), i = Array.from({ length: a });
|
|
5630
5786
|
for (let s = 0; s < a; s++) {
|
|
5631
|
-
const
|
|
5632
|
-
i[s] =
|
|
5787
|
+
const o = s / (a - 1);
|
|
5788
|
+
i[s] = Ba(r, e, o);
|
|
5633
5789
|
}
|
|
5634
5790
|
return i;
|
|
5635
5791
|
}
|
|
5636
|
-
class
|
|
5792
|
+
class Ua {
|
|
5793
|
+
/**
|
|
5794
|
+
* 构造函数
|
|
5795
|
+
* 创建统一的 AvatarController,内部根据配置自动组合网络层
|
|
5796
|
+
*/
|
|
5637
5797
|
/**
|
|
5638
5798
|
* 构造函数
|
|
5639
5799
|
* 创建统一的 AvatarController,内部根据配置自动组合网络层
|
|
5800
|
+
* @param avatar - Avatar 实例
|
|
5801
|
+
* @param container - Canvas 容器元素(必选)
|
|
5640
5802
|
*/
|
|
5641
5803
|
constructor(e, t) {
|
|
5642
5804
|
d(this, "avatarController");
|
|
5643
5805
|
d(this, "playbackMode");
|
|
5644
5806
|
d(this, "avatar");
|
|
5807
|
+
// Initialization state
|
|
5808
|
+
d(this, "ready");
|
|
5645
5809
|
// Canvas and rendering
|
|
5646
5810
|
d(this, "canvas");
|
|
5647
5811
|
d(this, "renderSystem", null);
|
|
@@ -5665,30 +5829,33 @@ class Va {
|
|
|
5665
5829
|
// Transition animation data
|
|
5666
5830
|
d(this, "transitionKeyframes", []);
|
|
5667
5831
|
d(this, "transitionStartTime", 0);
|
|
5668
|
-
d(this, "transitionDurationMs",
|
|
5832
|
+
d(this, "transitionDurationMs", 400);
|
|
5669
5833
|
d(this, "cachedIdleFirstFrame", null);
|
|
5670
5834
|
d(this, "idleCurrentFrameIndex", 0);
|
|
5671
5835
|
// Character handle for multi-character support
|
|
5672
5836
|
d(this, "characterHandle", null);
|
|
5673
5837
|
d(this, "characterId");
|
|
5674
5838
|
this.avatar = e, this.characterId = `${e.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
5675
|
-
const n =
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5839
|
+
const n = y.configuration;
|
|
5840
|
+
if (!n)
|
|
5841
|
+
throw new Error("AvatarKit must be initialized before creating AvatarView. Call AvatarKit.initialize() first.");
|
|
5842
|
+
const i = (n.drivingServiceMode ?? ze.sdk) === ze.sdk ? me.network : me.external;
|
|
5843
|
+
this.playbackMode = i, this.avatarController = new Ca(e, {
|
|
5844
|
+
playbackMode: i
|
|
5845
|
+
}), this.avatarController.setRenderCallback((s, o) => {
|
|
5846
|
+
this.renderRealtimeFrame(s, o);
|
|
5680
5847
|
}), this.avatarController.setTransitionCompleteCallback(() => {
|
|
5681
5848
|
this.onTransitionComplete();
|
|
5682
|
-
}), this.canvas = this.createCanvas(t
|
|
5849
|
+
}), this.canvas = this.createCanvas(t), this.ready = this.initializeView(e), this.setupControllerEventListeners();
|
|
5683
5850
|
}
|
|
5684
5851
|
// Unique ID for this character instance
|
|
5685
5852
|
/**
|
|
5686
5853
|
* 对齐两端 Flame 维度:标量统一长度,expression 取最大长度并零填充
|
|
5687
5854
|
*/
|
|
5688
5855
|
alignFlamePair(e, t) {
|
|
5689
|
-
const n = (
|
|
5690
|
-
const p = Array.isArray(
|
|
5691
|
-
return p.length <
|
|
5856
|
+
const n = (o, l) => {
|
|
5857
|
+
const p = Array.isArray(o) ? o.slice(0, l) : [];
|
|
5858
|
+
return p.length < l ? Array.from({ length: l }, (c, u) => p[u] ?? 0) : p;
|
|
5692
5859
|
}, a = {
|
|
5693
5860
|
translation: n(e == null ? void 0 : e.translation, 3),
|
|
5694
5861
|
rotation: n(e == null ? void 0 : e.rotation, 3),
|
|
@@ -5713,11 +5880,11 @@ class Va {
|
|
|
5713
5880
|
*/
|
|
5714
5881
|
generateAndAlignTransitionFrames(e, t) {
|
|
5715
5882
|
const n = this.alignFlamePair(e, t);
|
|
5716
|
-
let a =
|
|
5883
|
+
let a = Da(
|
|
5717
5884
|
n.from,
|
|
5718
5885
|
n.to,
|
|
5719
5886
|
this.transitionDurationMs,
|
|
5720
|
-
|
|
5887
|
+
I.animation.fps
|
|
5721
5888
|
);
|
|
5722
5889
|
return a.length < 2 && (a = [n.from, n.to]), a[0] = n.from, a[a.length - 1] = n.to, a;
|
|
5723
5890
|
}
|
|
@@ -5726,7 +5893,7 @@ class Va {
|
|
|
5726
5893
|
*/
|
|
5727
5894
|
async getCachedIdleFirstFrame() {
|
|
5728
5895
|
if (!this.cachedIdleFirstFrame) {
|
|
5729
|
-
const e =
|
|
5896
|
+
const e = y.getAvatarCore();
|
|
5730
5897
|
if (e)
|
|
5731
5898
|
try {
|
|
5732
5899
|
const t = await e.getCurrentFrameParams(0, this.characterId);
|
|
@@ -5747,14 +5914,11 @@ class Va {
|
|
|
5747
5914
|
* 创建canvas元素
|
|
5748
5915
|
*/
|
|
5749
5916
|
createCanvas(e) {
|
|
5750
|
-
const t = document.createElement("canvas");
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
const s = window.devicePixelRatio || 1, l = Math.floor(e.offsetWidth || 0), o = Math.floor(e.offsetHeight || 0);
|
|
5756
|
-
t.width = Math.floor(l * s), t.height = Math.floor(o * s), t.style.width = `${l}px`, t.style.height = `${o}px`, this.handleResize();
|
|
5757
|
-
}), this.resizeObserver.observe(e)) : document.body.appendChild(t), window.addEventListener("resize", this.onWindowResize), t;
|
|
5917
|
+
const t = document.createElement("canvas"), n = e.offsetWidth || 800, a = e.offsetHeight || 600, i = window.devicePixelRatio || 1;
|
|
5918
|
+
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(() => {
|
|
5919
|
+
const s = window.devicePixelRatio || 1, o = Math.floor(e.offsetWidth || 0), l = Math.floor(e.offsetHeight || 0);
|
|
5920
|
+
t.width = Math.floor(o * s), t.height = Math.floor(l * s), t.style.width = `${o}px`, t.style.height = `${l}px`, this.handleResize();
|
|
5921
|
+
}), this.resizeObserver.observe(e), window.addEventListener("resize", this.onWindowResize), t;
|
|
5758
5922
|
}
|
|
5759
5923
|
/**
|
|
5760
5924
|
* 获取canvas元素(供外部访问)
|
|
@@ -5768,23 +5932,23 @@ class Va {
|
|
|
5768
5932
|
*/
|
|
5769
5933
|
async initializeView(e) {
|
|
5770
5934
|
try {
|
|
5771
|
-
|
|
5772
|
-
const t =
|
|
5935
|
+
I.debug && h.log("[AvatarView] Initializing avatar view...");
|
|
5936
|
+
const t = y.getAvatarCore();
|
|
5773
5937
|
if (!t)
|
|
5774
5938
|
throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
|
|
5775
5939
|
const n = e.getResources();
|
|
5776
|
-
|
|
5940
|
+
I.debug && h.log("[AvatarView] Loading character data..."), this.characterHandle = await t.loadCharacterFromBuffers(
|
|
5777
5941
|
n.characterData.shape,
|
|
5778
5942
|
n.characterData.pointCloud,
|
|
5779
5943
|
this.characterId
|
|
5780
|
-
), n.characterData.idleAnimation && (
|
|
5944
|
+
), n.characterData.idleAnimation && (I.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(
|
|
5781
5945
|
(i, s) => {
|
|
5782
5946
|
this.renderRealtimeFrame(i, s);
|
|
5783
5947
|
},
|
|
5784
5948
|
this.characterHandle
|
|
5785
|
-
),
|
|
5949
|
+
), I.debug && h.log("[AvatarView] Initializing render system...");
|
|
5786
5950
|
const a = this.resolveCameraConfig(n);
|
|
5787
|
-
await this.initializeRenderSystem(a),
|
|
5951
|
+
await this.initializeRenderSystem(a), I.debug && h.log("[AvatarView] Starting rendering..."), await this.renderFirstFrame(), this.startIdleAnimationLoop(), this.isInitialized = !0, I.debug && h.log("[AvatarView] Avatar view initialized successfully");
|
|
5788
5952
|
} catch (t) {
|
|
5789
5953
|
throw h.error("[AvatarView] Failed to initialize avatar view:", t instanceof Error ? t.message : String(t)), t;
|
|
5790
5954
|
}
|
|
@@ -5793,25 +5957,25 @@ class Va {
|
|
|
5793
5957
|
* 初始化渲染系统
|
|
5794
5958
|
*/
|
|
5795
5959
|
async initializeRenderSystem(e) {
|
|
5796
|
-
this.cameraConfig = e || this.getDefaultCameraConfig(), e ? h.log("[AvatarView] Using resolved camera config:", e) : h.log("[AvatarView] No camera config in resources, using default static config:", this.cameraConfig), this.renderSystem = new
|
|
5960
|
+
this.cameraConfig = e || this.getDefaultCameraConfig(), e ? h.log("[AvatarView] Using resolved camera config:", e) : h.log("[AvatarView] No camera config in resources, using default static config:", this.cameraConfig), this.renderSystem = new Ta({
|
|
5797
5961
|
canvas: this.canvas,
|
|
5798
5962
|
camera: this.cameraConfig,
|
|
5799
5963
|
backgroundColor: [0, 0, 0, 0]
|
|
5800
5964
|
// 透明背景,让 CSS 背景透出
|
|
5801
|
-
}), await this.renderSystem.initialize(),
|
|
5965
|
+
}), await this.renderSystem.initialize(), I.debug && h.log("[AvatarView] Render system initialized successfully");
|
|
5802
5966
|
}
|
|
5803
5967
|
/**
|
|
5804
5968
|
* 获取默认相机配置
|
|
5805
5969
|
*/
|
|
5806
5970
|
getDefaultCameraConfig() {
|
|
5807
|
-
return { ...
|
|
5971
|
+
return { ...I.camera };
|
|
5808
5972
|
}
|
|
5809
5973
|
/**
|
|
5810
5974
|
* 根据资源解析最终的相机配置,优先使用角色设置,其次 camera.json
|
|
5811
5975
|
*/
|
|
5812
5976
|
resolveCameraConfig(e) {
|
|
5813
|
-
var
|
|
5814
|
-
const t = this.getDefaultCameraConfig(), n = ((
|
|
5977
|
+
var o, l;
|
|
5978
|
+
const t = this.getDefaultCameraConfig(), n = ((o = e.characterSettings) == null ? void 0 : o.camera) ?? null, a = ((l = e.preloadCameraSettings) == null ? void 0 : l.camera) ?? null, i = n ?? a;
|
|
5815
5979
|
if (!i)
|
|
5816
5980
|
return h.warn("[AvatarView] Camera settings not found in resources, falling back to default camera config"), t;
|
|
5817
5981
|
const s = n ? "characterSettings" : "camera.json";
|
|
@@ -5821,40 +5985,40 @@ class Va {
|
|
|
5821
5985
|
* 从角色设置中推导相机配置
|
|
5822
5986
|
*/
|
|
5823
5987
|
deriveCameraConfigFromSettings(e, t, n) {
|
|
5824
|
-
const a = (
|
|
5988
|
+
const a = (z, W) => Number.isFinite(z) ? z : W, i = a(e.translationX, t.position[0]), s = a(e.translationY, t.position[1]), o = a(e.translationZ, t.position[2]), l = a(e.rotation, 0), p = a(e.fovYRadians, 0), c = Math.hypot(i, s, o) > 1e-4, u = p > 0, m = Math.abs(l) > 1e-4;
|
|
5825
5989
|
if (!c && !u && !m)
|
|
5826
5990
|
return h.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
|
|
5827
|
-
const
|
|
5828
|
-
-
|
|
5991
|
+
const v = Math.sin(l), S = Math.cos(l), A = c ? [i, s, o] : [...t.position], b = [
|
|
5992
|
+
-v,
|
|
5829
5993
|
0,
|
|
5830
|
-
-
|
|
5831
|
-
],
|
|
5832
|
-
b[0] /
|
|
5833
|
-
b[1] /
|
|
5834
|
-
b[2] /
|
|
5994
|
+
-S
|
|
5995
|
+
], E = Math.hypot(b[0], b[1], b[2]) || 1, B = [
|
|
5996
|
+
b[0] / E,
|
|
5997
|
+
b[1] / E,
|
|
5998
|
+
b[2] / E
|
|
5835
5999
|
], _ = [
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
],
|
|
6000
|
+
A[0] + B[0],
|
|
6001
|
+
A[1] + B[1],
|
|
6002
|
+
A[2] + B[2]
|
|
6003
|
+
], X = [0, 1, 0], G = u ? p * 180 / Math.PI : t.fov, R = {
|
|
5840
6004
|
...t,
|
|
5841
6005
|
// 自动继承 near/far 等配置(来自 APP_CONFIG.camera)
|
|
5842
|
-
position:
|
|
6006
|
+
position: A,
|
|
5843
6007
|
target: _,
|
|
5844
|
-
up:
|
|
6008
|
+
up: X,
|
|
5845
6009
|
fov: G
|
|
5846
6010
|
// near/far 从 fallback 继承,无需硬编码
|
|
5847
6011
|
};
|
|
5848
6012
|
return h.log("[AvatarView] Applied camera settings from resources", {
|
|
5849
6013
|
source: n,
|
|
5850
|
-
translation: [i, s,
|
|
5851
|
-
yawRadians:
|
|
5852
|
-
position:
|
|
6014
|
+
translation: [i, s, o],
|
|
6015
|
+
yawRadians: l,
|
|
6016
|
+
position: A,
|
|
5853
6017
|
target: _,
|
|
5854
6018
|
fov: G,
|
|
5855
|
-
near:
|
|
5856
|
-
far:
|
|
5857
|
-
}),
|
|
6019
|
+
near: R.near,
|
|
6020
|
+
far: R.far
|
|
6021
|
+
}), R;
|
|
5858
6022
|
}
|
|
5859
6023
|
/**
|
|
5860
6024
|
* 渲染第一帧
|
|
@@ -5862,7 +6026,7 @@ class Va {
|
|
|
5862
6026
|
async renderFirstFrame() {
|
|
5863
6027
|
if (!this.renderSystem)
|
|
5864
6028
|
throw new Error("Render system not initialized");
|
|
5865
|
-
const e =
|
|
6029
|
+
const e = y.getAvatarCore();
|
|
5866
6030
|
if (!e)
|
|
5867
6031
|
throw new Error("AvatarCore not available");
|
|
5868
6032
|
const t = {
|
|
@@ -5875,7 +6039,7 @@ class Va {
|
|
|
5875
6039
|
eyes_pose: [0, 0, 0, 0, 0, 0]
|
|
5876
6040
|
}, n = await e.computeFrameFlatFromParams(t, this.characterHandle ?? void 0);
|
|
5877
6041
|
if (n)
|
|
5878
|
-
this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(),
|
|
6042
|
+
this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(), I.debug && h.log("[AvatarView] First frame rendered successfully");
|
|
5879
6043
|
else
|
|
5880
6044
|
throw new Error("Failed to compute first frame splat data");
|
|
5881
6045
|
}
|
|
@@ -5898,12 +6062,12 @@ class Va {
|
|
|
5898
6062
|
*/
|
|
5899
6063
|
startIdleAnimationLoop() {
|
|
5900
6064
|
if (this.idleAnimationLoopId && this.stopIdleAnimationLoop(), this.renderingState !== "idle") {
|
|
5901
|
-
|
|
6065
|
+
I.debug && h.log("[AvatarView] Skip starting idle loop because not in idle state");
|
|
5902
6066
|
return;
|
|
5903
6067
|
}
|
|
5904
6068
|
this.idleCurrentFrameIndex = 0;
|
|
5905
6069
|
let e = 0;
|
|
5906
|
-
const n = 1e3 /
|
|
6070
|
+
const n = 1e3 / I.animation.fps;
|
|
5907
6071
|
this.initFPS();
|
|
5908
6072
|
const a = async (i) => {
|
|
5909
6073
|
try {
|
|
@@ -5918,21 +6082,21 @@ class Va {
|
|
|
5918
6082
|
return;
|
|
5919
6083
|
}
|
|
5920
6084
|
e = i;
|
|
5921
|
-
const s =
|
|
6085
|
+
const s = y.getAvatarCore();
|
|
5922
6086
|
if (!s)
|
|
5923
6087
|
return;
|
|
5924
|
-
const
|
|
5925
|
-
if (this.idleCurrentFrameIndex++,
|
|
6088
|
+
const o = await s.computeCompleteFrameFlat({ frameIndex: this.idleCurrentFrameIndex }, this.characterHandle ?? void 0);
|
|
6089
|
+
if (this.idleCurrentFrameIndex++, o) {
|
|
5926
6090
|
if (this.renderingState !== "idle")
|
|
5927
6091
|
return;
|
|
5928
|
-
this.renderSystem.loadSplatsFromPackedData(
|
|
6092
|
+
this.renderSystem.loadSplatsFromPackedData(o), this.renderSystem.renderFrame();
|
|
5929
6093
|
}
|
|
5930
6094
|
this.idleAnimationLoopId = requestAnimationFrame(a);
|
|
5931
6095
|
} catch (s) {
|
|
5932
6096
|
h.error("[AvatarView] Idle animation loop error:", s instanceof Error ? s.message : String(s)), this.stopIdleAnimationLoop();
|
|
5933
6097
|
}
|
|
5934
6098
|
};
|
|
5935
|
-
this.idleAnimationLoopId = requestAnimationFrame(a),
|
|
6099
|
+
this.idleAnimationLoopId = requestAnimationFrame(a), I.debug && h.log("[AvatarView] Idle animation loop started");
|
|
5936
6100
|
}
|
|
5937
6101
|
/**
|
|
5938
6102
|
* 开始实时对话动画循环
|
|
@@ -5940,7 +6104,7 @@ class Va {
|
|
|
5940
6104
|
startRealtimeAnimationLoop() {
|
|
5941
6105
|
this.realtimeAnimationLoopId && this.stopRealtimeAnimationLoop();
|
|
5942
6106
|
let e = 0;
|
|
5943
|
-
const n = 1e3 /
|
|
6107
|
+
const n = 1e3 / I.animation.fps;
|
|
5944
6108
|
this.initFPS();
|
|
5945
6109
|
const a = async (i) => {
|
|
5946
6110
|
try {
|
|
@@ -5958,12 +6122,12 @@ class Va {
|
|
|
5958
6122
|
this.realtimeAnimationLoopId = requestAnimationFrame(a);
|
|
5959
6123
|
return;
|
|
5960
6124
|
}
|
|
5961
|
-
const
|
|
5962
|
-
if (
|
|
5963
|
-
const
|
|
5964
|
-
|
|
6125
|
+
const o = performance.now() - this.transitionStartTime, l = Math.min(1, Math.max(0, o / this.transitionDurationMs)), p = this.transitionKeyframes.length, c = Math.min(p - 1, Math.floor(l * (p - 1))), u = this.transitionKeyframes[c], m = Vt(u), v = y.getAvatarCore();
|
|
6126
|
+
if (v) {
|
|
6127
|
+
const S = await v.computeFrameFlatFromParams(m, this.characterHandle ?? void 0);
|
|
6128
|
+
S && (this.renderSystem.loadSplatsFromPackedData(S), this.renderSystem.renderFrame());
|
|
5965
6129
|
}
|
|
5966
|
-
if (
|
|
6130
|
+
if (l >= 1) {
|
|
5967
6131
|
if (s === "transitioningToSpeaking")
|
|
5968
6132
|
this.setState(
|
|
5969
6133
|
"speaking"
|
|
@@ -5988,19 +6152,19 @@ class Va {
|
|
|
5988
6152
|
h.error("[AvatarView] Realtime animation loop error:", s instanceof Error ? s.message : String(s)), this.stopRealtimeAnimationLoop();
|
|
5989
6153
|
}
|
|
5990
6154
|
};
|
|
5991
|
-
this.realtimeAnimationLoopId = requestAnimationFrame(a),
|
|
6155
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(a), I.debug && h.log("[AvatarView] Realtime animation loop started");
|
|
5992
6156
|
}
|
|
5993
6157
|
/**
|
|
5994
6158
|
* 停止idle动画循环
|
|
5995
6159
|
*/
|
|
5996
6160
|
stopIdleAnimationLoop() {
|
|
5997
|
-
this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null,
|
|
6161
|
+
this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null, I.debug && h.log("[AvatarView] Idle animation loop stopped"));
|
|
5998
6162
|
}
|
|
5999
6163
|
/**
|
|
6000
6164
|
* 停止实时对话动画循环
|
|
6001
6165
|
*/
|
|
6002
6166
|
stopRealtimeAnimationLoop() {
|
|
6003
|
-
this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null,
|
|
6167
|
+
this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null, I.debug && h.log("[AvatarView] Realtime animation loop stopped"));
|
|
6004
6168
|
}
|
|
6005
6169
|
/**
|
|
6006
6170
|
* 停止所有动画循环
|
|
@@ -6089,7 +6253,7 @@ class Va {
|
|
|
6089
6253
|
/* TransitioningToSpeaking */
|
|
6090
6254
|
);
|
|
6091
6255
|
try {
|
|
6092
|
-
const n =
|
|
6256
|
+
const n = y.getAvatarCore();
|
|
6093
6257
|
if (n && e.length > 0) {
|
|
6094
6258
|
if (this.renderingState !== "transitioningToSpeaking")
|
|
6095
6259
|
return;
|
|
@@ -6099,7 +6263,7 @@ class Va {
|
|
|
6099
6263
|
this.transitionKeyframes = this.generateAndAlignTransitionFrames(i, s), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
|
|
6100
6264
|
"speaking"
|
|
6101
6265
|
/* Speaking */
|
|
6102
|
-
), this.avatarController.onTransitionComplete()) :
|
|
6266
|
+
), this.avatarController.onTransitionComplete()) : I.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
|
|
6103
6267
|
}
|
|
6104
6268
|
} catch (n) {
|
|
6105
6269
|
h.warn("[AvatarView] Transition generation failed:", n instanceof Error ? n.message : String(n)), this.renderingState === "transitioningToSpeaking" && (this.setState(
|
|
@@ -6113,7 +6277,7 @@ class Va {
|
|
|
6113
6277
|
* 开始实时渲染循环
|
|
6114
6278
|
*/
|
|
6115
6279
|
startRealtimeRendering() {
|
|
6116
|
-
|
|
6280
|
+
I.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"), y.logEvent("character_view", "info", {
|
|
6117
6281
|
characterId: this.avatar.id,
|
|
6118
6282
|
event: "rendering_started",
|
|
6119
6283
|
keyframesCount: this.currentKeyframes.length
|
|
@@ -6139,10 +6303,10 @@ class Va {
|
|
|
6139
6303
|
try {
|
|
6140
6304
|
if (this.renderingState !== "transitioningToIdle")
|
|
6141
6305
|
return;
|
|
6142
|
-
if (
|
|
6306
|
+
if (y.getAvatarCore() && this.currentKeyframes.length > 0) {
|
|
6143
6307
|
const n = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], a = await this.getCachedIdleFirstFrame();
|
|
6144
6308
|
if (a && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(n, a), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
|
|
6145
|
-
|
|
6309
|
+
I.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
|
|
6146
6310
|
return;
|
|
6147
6311
|
}
|
|
6148
6312
|
}
|
|
@@ -6161,21 +6325,21 @@ class Va {
|
|
|
6161
6325
|
* 关闭 avatarController 并清理所有相关资源
|
|
6162
6326
|
*/
|
|
6163
6327
|
dispose() {
|
|
6164
|
-
|
|
6328
|
+
I.debug && h.log("[AvatarView] Disposing avatar view..."), y.logEvent("character_view", "info", {
|
|
6165
6329
|
characterId: this.avatar.id,
|
|
6166
6330
|
event: "disposed"
|
|
6167
6331
|
}), this.avatarController && (this.avatarController.clear(), this.avatarController.dispose()), this.stopAllAnimationLoops(), this.setState(
|
|
6168
6332
|
"idle"
|
|
6169
6333
|
/* Idle */
|
|
6170
6334
|
), this.cachedIdleFirstFrame = null, this.idleCurrentFrameIndex = 0;
|
|
6171
|
-
const e =
|
|
6335
|
+
const e = y.getAvatarCore();
|
|
6172
6336
|
if (e && this.characterHandle)
|
|
6173
6337
|
try {
|
|
6174
|
-
e.removeCharacter(this.characterHandle, this.characterId),
|
|
6338
|
+
e.removeCharacter(this.characterHandle, this.characterId), I.debug && h.log("[AvatarView] AvatarCore character resources released"), this.characterHandle = null;
|
|
6175
6339
|
} catch (t) {
|
|
6176
6340
|
h.error("[AvatarView] Failed to release AvatarCore resources:", t instanceof Error ? t.message : String(t));
|
|
6177
6341
|
}
|
|
6178
|
-
this.renderSystem && (this.renderSystem.dispose(), this.renderSystem = null), this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), window.removeEventListener("resize", this.onWindowResize), this.isInitialized = !1,
|
|
6342
|
+
this.renderSystem && (this.renderSystem.dispose(), this.renderSystem = null), this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), window.removeEventListener("resize", this.onWindowResize), this.isInitialized = !1, I.debug && h.log("[AvatarView] Avatar view disposed successfully");
|
|
6179
6343
|
}
|
|
6180
6344
|
/**
|
|
6181
6345
|
* 获取相机配置
|
|
@@ -6189,7 +6353,7 @@ class Va {
|
|
|
6189
6353
|
* @internal
|
|
6190
6354
|
*/
|
|
6191
6355
|
updateCameraConfig(e) {
|
|
6192
|
-
this.cameraConfig = e,
|
|
6356
|
+
this.cameraConfig = e, I.debug && h.log("[AvatarView] Camera config updated:", e), this.renderSystem && (this.renderSystem.updateCamera(e), I.debug && h.log("[AvatarView] Applied new camera config to render system"));
|
|
6193
6357
|
}
|
|
6194
6358
|
/**
|
|
6195
6359
|
* 处理尺寸变化:通知渲染系统更新视口与投影
|
|
@@ -6213,23 +6377,22 @@ class Va {
|
|
|
6213
6377
|
}
|
|
6214
6378
|
}
|
|
6215
6379
|
export {
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6380
|
+
I as A,
|
|
6381
|
+
ye as C,
|
|
6382
|
+
ze as D,
|
|
6383
|
+
ie as E,
|
|
6384
|
+
le as L,
|
|
6385
|
+
on as R,
|
|
6386
|
+
Q as S,
|
|
6387
|
+
y as a,
|
|
6388
|
+
sn as b,
|
|
6389
|
+
Ca as c,
|
|
6225
6390
|
Tt as d,
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
Na as j,
|
|
6232
|
-
Ua as k,
|
|
6391
|
+
ar as e,
|
|
6392
|
+
Ua as f,
|
|
6393
|
+
M as g,
|
|
6394
|
+
me as h,
|
|
6395
|
+
Na as i,
|
|
6233
6396
|
h as l
|
|
6234
6397
|
};
|
|
6235
|
-
//# sourceMappingURL=index-
|
|
6398
|
+
//# sourceMappingURL=index-CuR_S9Ng.js.map
|