@spatialwalk/avatarkit 1.0.0-beta.7 → 1.0.0-beta.9

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.
@@ -40,7 +40,7 @@ function an() {
40
40
  function on() {
41
41
  return an();
42
42
  }
43
- const M = {
43
+ const k = {
44
44
  testEnv: nn,
45
45
  // Dynamic debug mode check (includes URL parameter)
46
46
  get debug() {
@@ -497,7 +497,7 @@ let ft = () => {
497
497
  }, ir = (f, p, A) => Re(f, p).map((C) => String(C).padStart(A, "0")), Xe = (f, p) => Re($(f), $(p)).map(Fe), J = (f) => f, Qe = (f) => ar((p) => L(p, f, { memoization: !1 }).join("")), ar = (f) => {
498
498
  const p = {};
499
499
  return (A) => p[A] ?? (p[A] = f(A));
500
- }, or = _(/^\*\*\/\*$/, ".*"), sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, p, A) => `.*${p ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}`), lr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, p, A, C) => `.*${p ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Le = _(/\\./, J), cr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), ur = _(/./, J), dr = _(/^(?:!!)*!(.*)$/, (f, p) => `(?!^${ot(p)}$).*?`), hr = _(/^(!!)+/, ""), fr = U([dr, hr]), mr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = _(/^(\*\*\/)+/, "(?:^|.*/)"), pr = _(/\/(\*\*)$/, "(?:/.*|$)"), vr = _(/\*\*/, ".*"), et = U([mr, gr, pr, vr]), wr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = _(/\*/, "[^/]*"), tt = U([wr, yr]), rt = _("?", "[^/]"), Ar = _("[", J), Sr = _("]", J), br = _(/[!^]/, "^/"), Cr = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, J), _r = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), Er = _(/[^\]]/, J), xr = U([Le, _r, Cr, Er]), nt = re([Ar, X(br), K(xr), Sr]), Pr = _("{", "(?:"), Ir = _("}", ")"), Mr = _(/(\d+)\.\.(\d+)/, (f, p, A) => ir(+p, +A, Math.min(p.length, A.length)).join("|")), kr = _(/([a-z]+)\.\.([a-z]+)/, (f, p, A) => Xe(p, A).join("|")), Fr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, p, A) => Xe(p.toLowerCase(), A.toLowerCase()).join("|").toUpperCase()), Rr = U([Mr, kr, Fr]), it = re([Pr, Rr, Ir]), Lr = _("{", "(?:"), Tr = _("}", ")"), Br = _(",", "|"), Dr = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), Or = _(/[^}]/, J), Nr = T(() => at), Ur = U([et, tt, rt, nt, it, Nr, Le, Dr, Br, Or]), at = re([Lr, K(Ur), Tr]), zr = K(U([or, sr, lr, fr, et, tt, rt, nt, it, at, Le, cr, ur])), Vr = zr, $r = Qe(Vr), ot = $r, qr = _(/\\./, J), Wr = _(/./, J), Gr = _(/\*\*\*+/, "*"), jr = _(/([^/{[(!])\*\*/, (f, p) => `${p}*`), Hr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, p) => `${p}*`), Kr = K(U([qr, Gr, jr, Hr, Wr])), Jr = Kr, Zr = Qe(Jr), Yr = Zr, Te = (f, p) => {
500
+ }, or = _(/^\*\*\/\*$/, ".*"), sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, p, A) => `.*${p ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}`), lr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, p, A, C) => `.*${p ? "" : "(?:^|/)"}${A.replaceAll(".", "\\.")}(?:${C.replaceAll(",", "|").replaceAll(".", "\\.")})`), Le = _(/\\./, J), cr = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), ur = _(/./, J), dr = _(/^(?:!!)*!(.*)$/, (f, p) => `(?!^${ot(p)}$).*?`), hr = _(/^(!!)+/, ""), fr = U([dr, hr]), mr = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = _(/^(\*\*\/)+/, "(?:^|.*/)"), pr = _(/\/(\*\*)$/, "(?:/.*|$)"), vr = _(/\*\*/, ".*"), et = U([mr, gr, pr, vr]), wr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = _(/\*/, "[^/]*"), tt = U([wr, yr]), rt = _("?", "[^/]"), Ar = _("[", J), Sr = _("]", J), br = _(/[!^]/, "^/"), Cr = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, J), _r = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), Er = _(/[^\]]/, J), xr = U([Le, _r, Cr, Er]), nt = re([Ar, X(br), K(xr), Sr]), Pr = _("{", "(?:"), Ir = _("}", ")"), kr = _(/(\d+)\.\.(\d+)/, (f, p, A) => ir(+p, +A, Math.min(p.length, A.length)).join("|")), Mr = _(/([a-z]+)\.\.([a-z]+)/, (f, p, A) => Xe(p, A).join("|")), Fr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, p, A) => Xe(p.toLowerCase(), A.toLowerCase()).join("|").toUpperCase()), Rr = U([kr, Mr, Fr]), it = re([Pr, Rr, Ir]), Lr = _("{", "(?:"), Tr = _("}", ")"), Br = _(",", "|"), Dr = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), Or = _(/[^}]/, J), Nr = T(() => at), Ur = U([et, tt, rt, nt, it, Nr, Le, Dr, Br, Or]), at = re([Lr, K(Ur), Tr]), zr = K(U([or, sr, lr, fr, et, tt, rt, nt, it, at, Le, cr, ur])), Vr = zr, $r = Qe(Vr), ot = $r, qr = _(/\\./, J), Wr = _(/./, J), Gr = _(/\*\*\*+/, "*"), jr = _(/([^/{[(!])\*\*/, (f, p) => `${p}*`), Hr = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, p) => `${p}*`), Kr = K(U([qr, Gr, jr, Hr, Wr])), Jr = Kr, Zr = Qe(Jr), Yr = Zr, Te = (f, p) => {
501
501
  const A = Array.isArray(f) ? f : [f];
502
502
  if (!A.length) return !1;
503
503
  const C = A.map(Te.compile), E = A.every((R) => /(\/(?:\*\*)?|\[\/\])$/.test(R)), P = p.replace(/[\\\/]+/g, "/").replace(/\/$/, E ? "/" : "");
@@ -533,7 +533,7 @@ const mn = /^[/\\]{2}/, gn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,
533
533
  function An() {
534
534
  return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
535
535
  }
536
- const Me = function(...r) {
536
+ const ke = function(...r) {
537
537
  r = r.map((n) => ce(n));
538
538
  let e = "", t = !1;
539
539
  for (let n = r.length - 1; n >= -1 && !t; n--) {
@@ -581,7 +581,7 @@ const ve = function(r) {
581
581
  const e = pn.exec(ce(r));
582
582
  return e && e[1] || "";
583
583
  }, bn = function(r, e) {
584
- const t = Me(r).replace(mt, "$1").split("/"), n = Me(e).replace(mt, "$1").split("/");
584
+ const t = ke(r).replace(mt, "$1").split("/"), n = ke(e).replace(mt, "$1").split("/");
585
585
  if (n[0][1] === ":" && t[0][1] === ":" && t[0] !== n[0])
586
586
  return n.join("/");
587
587
  const i = [...t];
@@ -599,7 +599,7 @@ const ve = function(r) {
599
599
  Boolean
600
600
  );
601
601
  return ce(
602
- r.root ? Me(...t) : t.join("/")
602
+ r.root ? ke(...t) : t.join("/")
603
603
  );
604
604
  }, Kt = function(r, e) {
605
605
  const t = ce(r).split("/");
@@ -635,7 +635,7 @@ const ve = function(r) {
635
635
  normalizeString: Ke,
636
636
  parse: _n,
637
637
  relative: bn,
638
- resolve: Me,
638
+ resolve: ke,
639
639
  sep: wn,
640
640
  toNamespacedPath: Sn
641
641
  }, xn = /* @__PURE__ */ (() => {
@@ -646,8 +646,8 @@ const ve = function(r) {
646
646
  return t === "delimiter" ? r : t === "posix" ? $e : t === "win32" ? In : Pn[t] || gt[t];
647
647
  }
648
648
  }), $e = /* @__PURE__ */ Jt(":"), In = /* @__PURE__ */ Jt(";");
649
- var k = /* @__PURE__ */ ((r) => (r[r.Error = 0] = "Error", r[r.Warning = 1] = "Warning", r[r.Log = 2] = "Log", r[r.Verbose = 3] = "Verbose", r[r.Debug = 4] = "Debug", r))(k || {}), I = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(I || {}), te = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(te || {});
650
- const Mn = !0;
649
+ var M = /* @__PURE__ */ ((r) => (r[r.Error = 0] = "Error", r[r.Warning = 1] = "Warning", r[r.Log = 2] = "Log", r[r.Verbose = 3] = "Verbose", r[r.Debug = 4] = "Debug", r))(M || {}), I = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(I || {}), te = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(te || {});
650
+ const kn = !0;
651
651
  function F(r, e, t = r) {
652
652
  return (n) => {
653
653
  const i = `${n}`, a = i.indexOf(e, r.length);
@@ -658,7 +658,7 @@ function Zt(r, e, t, n) {
658
658
  const i = r.substring(0, n) + t, a = r.substring(n + e.length), o = a.indexOf(e);
659
659
  return ~o ? i + Zt(a, e, t, o) : i + a;
660
660
  }
661
- function kn(r = Mn) {
661
+ function Mn(r = kn) {
662
662
  return {
663
663
  isColorSupported: r,
664
664
  reset: r ? (e) => `\x1B[0m${e}\x1B[0m` : String,
@@ -688,18 +688,18 @@ function kn(r = Mn) {
688
688
  bgWhite: r ? F("\x1B[47m", "\x1B[49m") : String
689
689
  };
690
690
  }
691
- const B = kn(), qe = {
692
- [I.Error]: k.Error,
693
- [I.Warning]: k.Warning,
694
- [I.Log]: k.Log,
695
- [I.Verbose]: k.Verbose,
696
- [I.Debug]: k.Debug
691
+ const B = Mn(), qe = {
692
+ [I.Error]: M.Error,
693
+ [I.Warning]: M.Warning,
694
+ [I.Log]: M.Log,
695
+ [I.Verbose]: M.Verbose,
696
+ [I.Debug]: M.Debug
697
697
  }, Fn = {
698
- [k.Error]: I.Error,
699
- [k.Warning]: I.Warning,
700
- [k.Log]: I.Log,
701
- [k.Verbose]: I.Verbose,
702
- [k.Debug]: I.Debug
698
+ [M.Error]: I.Error,
699
+ [M.Warning]: I.Warning,
700
+ [M.Log]: I.Log,
701
+ [M.Verbose]: I.Verbose,
702
+ [M.Debug]: I.Debug
703
703
  }, pt = [
704
704
  I.Error,
705
705
  I.Warning,
@@ -707,17 +707,17 @@ const B = kn(), qe = {
707
707
  I.Verbose,
708
708
  I.Debug
709
709
  ], Rn = {
710
- [k.Error]: B.red,
711
- [k.Warning]: B.yellow,
712
- [k.Log]: B.blue,
713
- [k.Verbose]: B.cyan,
714
- [k.Debug]: B.green
710
+ [M.Error]: B.red,
711
+ [M.Warning]: B.yellow,
712
+ [M.Log]: B.blue,
713
+ [M.Verbose]: B.cyan,
714
+ [M.Debug]: B.green
715
715
  }, vt = [
716
- k.Error,
717
- k.Warning,
718
- k.Log,
719
- k.Verbose,
720
- k.Debug
716
+ M.Error,
717
+ M.Warning,
718
+ M.Log,
719
+ M.Verbose,
720
+ M.Debug
721
721
  ], wt = [te.JSON, te.Pretty];
722
722
  function Ln(r) {
723
723
  return r.stack == null ? [] : r.stack.split(`
@@ -812,19 +812,19 @@ function Ee(r) {
812
812
  ${r.error.stack}`), i;
813
813
  }
814
814
  function Bn(r) {
815
- return r >= k.Debug;
815
+ return r >= M.Debug;
816
816
  }
817
817
  function Dn(r) {
818
- return r >= k.Verbose;
818
+ return r >= M.Verbose;
819
819
  }
820
820
  function On(r) {
821
- return r >= k.Log;
821
+ return r >= M.Log;
822
822
  }
823
823
  function Nn(r) {
824
- return r >= k.Warning;
824
+ return r >= M.Warning;
825
825
  }
826
826
  function Un(r) {
827
- return r >= k.Error;
827
+ return r >= M.Error;
828
828
  }
829
829
  function Qt() {
830
830
  return typeof window < "u";
@@ -836,7 +836,7 @@ function Vn(r, e) {
836
836
  return zn() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
837
837
  }
838
838
  const Je = {
839
- logLevel: k.Debug,
839
+ logLevel: M.Debug,
840
840
  format: te.JSON,
841
841
  timeFormatter: (r) => r.toISOString()
842
842
  };
@@ -853,7 +853,7 @@ function er(r) {
853
853
  const e = {
854
854
  fields: {},
855
855
  context: r,
856
- logLevel: k.Debug,
856
+ logLevel: M.Debug,
857
857
  format: te.JSON,
858
858
  shouldUseGlobalConfig: !1,
859
859
  errorProcessor: (c) => c,
@@ -1960,7 +1960,7 @@ class b {
1960
1960
  h[a](`[Telemetry] ${e}`, i);
1961
1961
  }
1962
1962
  }
1963
- d(b, "_isInitialized", !1), d(b, "_configuration", null), d(b, "_sessionToken", null), d(b, "_userId", null), d(b, "_version", "1.0.0-beta.7"), d(b, "_avatarCore", null), d(b, "_dynamicSdkConfig", null), d(b, "_logLevels", {
1963
+ d(b, "_isInitialized", !1), d(b, "_configuration", null), d(b, "_sessionToken", null), d(b, "_userId", null), d(b, "_version", "1.0.0-beta.9"), d(b, "_avatarCore", null), d(b, "_dynamicSdkConfig", null), d(b, "_logLevels", {
1964
1964
  debug: "log",
1965
1965
  info: "log",
1966
1966
  warning: "warn",
@@ -1971,7 +1971,7 @@ const Ce = class Ce {
1971
1971
  d(this, "audio", null);
1972
1972
  d(this, "streamingPlayer", null);
1973
1973
  d(this, "_isPlaying", !1);
1974
- d(this, "fps", M.animation.fps);
1974
+ d(this, "fps", k.animation.fps);
1975
1975
  d(this, "onEndedCallback");
1976
1976
  d(this, "useStreaming", !1);
1977
1977
  }
@@ -2029,9 +2029,9 @@ const Ce = class Ce {
2029
2029
  async createAndInitializeStreamingPlayer() {
2030
2030
  if (this.streamingPlayer)
2031
2031
  return;
2032
- const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-D7s8q5h0.js");
2032
+ const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-LW0pGK-E.js");
2033
2033
  this.streamingPlayer = new e({
2034
- sampleRate: M.audio.sampleRate,
2034
+ sampleRate: k.audio.sampleRate,
2035
2035
  channelCount: 1,
2036
2036
  debug: !1
2037
2037
  });
@@ -2730,7 +2730,7 @@ const he = {
2730
2730
  return e.reqId = r.reqId ?? "", e.audio = r.audio ?? new Uint8Array(0), e.end = r.end ?? !1, e;
2731
2731
  }
2732
2732
  };
2733
- function Mt() {
2733
+ function kt() {
2734
2734
  return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
2735
2735
  }
2736
2736
  const fe = {
@@ -2761,7 +2761,7 @@ const fe = {
2761
2761
  decode(r, e) {
2762
2762
  const t = r instanceof O ? r : new O(r);
2763
2763
  let n = e === void 0 ? t.len : t.pos + e;
2764
- const i = Mt();
2764
+ const i = kt();
2765
2765
  for (; t.pos < n; ) {
2766
2766
  const a = t.uint32();
2767
2767
  switch (a >>> 3) {
@@ -2884,11 +2884,11 @@ const fe = {
2884
2884
  },
2885
2885
  fromPartial(r) {
2886
2886
  var t, n, i, a, o, s, l;
2887
- const e = Mt();
2887
+ const e = kt();
2888
2888
  return e.translation = ((t = r.translation) == null ? void 0 : t.map((g) => g)) || [], e.rotation = ((n = r.rotation) == null ? void 0 : n.map((g) => g)) || [], e.neckPose = ((i = r.neckPose) == null ? void 0 : i.map((g) => g)) || [], e.jawPose = ((a = r.jawPose) == null ? void 0 : a.map((g) => g)) || [], e.eyePose = ((o = r.eyePose) == null ? void 0 : o.map((g) => g)) || [], e.eyeLid = ((s = r.eyeLid) == null ? void 0 : s.map((g) => g)) || [], e.expression = ((l = r.expression) == null ? void 0 : l.map((g) => g)) || [], e;
2889
2889
  }
2890
2890
  };
2891
- function kt() {
2891
+ function Mt() {
2892
2892
  return { keyframes: [] };
2893
2893
  }
2894
2894
  const me = {
@@ -2900,7 +2900,7 @@ const me = {
2900
2900
  decode(r, e) {
2901
2901
  const t = r instanceof O ? r : new O(r);
2902
2902
  let n = e === void 0 ? t.len : t.pos + e;
2903
- const i = kt();
2903
+ const i = Mt();
2904
2904
  for (; t.pos < n; ) {
2905
2905
  const a = t.uint32();
2906
2906
  switch (a >>> 3) {
@@ -2932,7 +2932,7 @@ const me = {
2932
2932
  },
2933
2933
  fromPartial(r) {
2934
2934
  var t;
2935
- const e = kt();
2935
+ const e = Mt();
2936
2936
  return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => fe.fromPartial(n))) || [], e;
2937
2937
  }
2938
2938
  };
@@ -3210,7 +3210,7 @@ class yi extends wi {
3210
3210
  * 断开连接
3211
3211
  */
3212
3212
  disconnect() {
3213
- this.ws && (this.ws.close(1e3, "Normal closure"), this.ws = null), this.currentRetryCount = 0, this.isConnecting = !1, this.isManuallyDisconnected = !0, this.reconnectTimer && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null), h.log("[AnimationWebSocketClient] Disconnected");
3213
+ this.ws && (this.ws.close(1e3, "Normal closure"), this.ws = null), this.removeAllListeners(), this.currentRetryCount = 0, this.isConnecting = !1, this.isManuallyDisconnected = !0, this.reconnectTimer && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null), h.log("[AnimationWebSocketClient] Disconnected");
3214
3214
  }
3215
3215
  /**
3216
3216
  * 发送音频数据
@@ -3341,7 +3341,7 @@ class Ai {
3341
3341
  // 组合播放层
3342
3342
  d(this, "currentReqId", null);
3343
3343
  d(this, "hasSentEnd", !1);
3344
- d(this, "audioBytesPerSecond", M.audio.sampleRate * 2);
3344
+ d(this, "audioBytesPerSecond", k.audio.sampleRate * 2);
3345
3345
  d(this, "audioMetrics", this.createAudioMetrics());
3346
3346
  this.dataController = e;
3347
3347
  const t = b.getEnvironmentConfig();
@@ -3386,7 +3386,7 @@ class Ai {
3386
3386
  * 断开连接
3387
3387
  */
3388
3388
  disconnect() {
3389
- this.wsClient.disconnect(), this.currentReqId = null, this.hasSentEnd = !1;
3389
+ this.wsClient.removeAllListeners(), this.wsClient.disconnect(), this.currentReqId = null, this.hasSentEnd = !1;
3390
3390
  }
3391
3391
  /**
3392
3392
  * 获取当前请求ID
@@ -3702,6 +3702,13 @@ class Si {
3702
3702
  var e, t;
3703
3703
  this.isPlaying && this.stopPlayback(), (e = this.networkLayer) == null || e.disconnect(), this.cleanupPlayers(), this.currentKeyframes = [], this.pendingAudioChunks = [], this.isConnected = !1, (t = this.onAvatarState) == null || t.call(this, Z.idle);
3704
3704
  }
3705
+ /**
3706
+ * 销毁控制器,清理所有回调避免内存泄漏
3707
+ * 应该在 AvatarView.dispose() 时调用
3708
+ */
3709
+ dispose() {
3710
+ this.onConnectionState = null, this.onAvatarState = null, this.onError = null, this.renderCallback = void 0, this.transitionCompleteCallback = void 0, this.eventListeners.clear();
3711
+ }
3705
3712
  // ========== 内部方法(供 NetworkLayer 和 AvatarView 使用)==========
3706
3713
  /**
3707
3714
  * 开始流式播放(内部方法,由 NetworkLayer 或 play() 调用)
@@ -3753,7 +3760,7 @@ class Si {
3753
3760
  try {
3754
3761
  await this.animationPlayer.prepareStreamingPlayer(() => {
3755
3762
  var a, o;
3756
- this.isPlaying = !1, (a = this.onAvatarState) == null || a.call(this, Z.idle), this.emit("stopRendering"), b.logEvent("character_player", "info", {
3763
+ this.isPlaying = !1, (a = this.onAvatarState) == null || a.call(this, Z.idle), this.emit("stopRendering"), this.currentKeyframes = [], this.pendingAudioChunks = [], this.lastRenderedFrameIndex = -1, this.networkLayer && this.networkLayer.resetReqId(), b.logEvent("character_player", "info", {
3757
3764
  characterId: this.avatar.id,
3758
3765
  event: "playback_ended",
3759
3766
  reqId: ((o = this.networkLayer) == null ? void 0 : o.getCurrentReqId()) || void 0
@@ -3776,7 +3783,7 @@ class Si {
3776
3783
  startPlaybackLoop() {
3777
3784
  if (this.playbackLoopId)
3778
3785
  return;
3779
- const e = M.animation.fps, t = async () => {
3786
+ const e = k.animation.fps, t = async () => {
3780
3787
  if (!this.isPlaying || !this.animationPlayer) {
3781
3788
  this.playbackLoopId = null;
3782
3789
  return;
@@ -3942,7 +3949,7 @@ class Ci {
3942
3949
  * Uses centralized FLAME CDN config (shared across all characters)
3943
3950
  */
3944
3951
  async loadGlobalFlameResources(e = null) {
3945
- const { cdnBaseUrl: t, resources: n } = M.flame, i = {
3952
+ const { cdnBaseUrl: t, resources: n } = k.flame, i = {
3946
3953
  flameModel: {
3947
3954
  url: `${t}/${n.flameModel}`,
3948
3955
  resourceName: n.flameModel
@@ -4166,7 +4173,7 @@ class Ci {
4166
4173
  }
4167
4174
  }
4168
4175
  }
4169
- const ke = class ke {
4176
+ const Me = class Me {
4170
4177
  constructor() {
4171
4178
  d(this, "avatarDownloader", null);
4172
4179
  d(this, "_templateInitialized", !1);
@@ -4175,7 +4182,7 @@ const ke = class ke {
4175
4182
  * 通过全局单例来访问
4176
4183
  */
4177
4184
  static get shared() {
4178
- return this._instance || (this._instance = new ke()), this._instance;
4185
+ return this._instance || (this._instance = new Me()), this._instance;
4179
4186
  }
4180
4187
  /**
4181
4188
  * 加载数字人
@@ -4225,8 +4232,8 @@ const ke = class ke {
4225
4232
  this.avatarDownloader && this.avatarDownloader.clear();
4226
4233
  }
4227
4234
  };
4228
- d(ke, "_instance", null);
4229
- let Bt = ke, ye = null, Dt = null, Ot = null, Nt = null, Ut = null, zt = null;
4235
+ d(Me, "_instance", null);
4236
+ let Bt = Me, ye = null, Dt = null, Ot = null, Nt = null, Ut = null, zt = null;
4230
4237
  const Ye = 2048, Vt = Ye - 1;
4231
4238
  function _i(r, e, t) {
4232
4239
  const i = r.length / 13;
@@ -4696,10 +4703,10 @@ class Ii {
4696
4703
  t && typeof t.loseContext == "function" && t.loseContext();
4697
4704
  } catch {
4698
4705
  }
4699
- this.isInitialized = !1;
4706
+ this.gl = null, this.isInitialized = !1;
4700
4707
  }
4701
4708
  }
4702
- const Mi = `/**
4709
+ const ki = `/**
4703
4710
  * WebGPU 3DGS 渲染着色器
4704
4711
  *
4705
4712
  * 实例化渲染:每个 splat 绘制一个四边形
@@ -4962,7 +4969,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4f {
4962
4969
  return vec4f(input.color.rgb * alpha, alpha);
4963
4970
  }
4964
4971
  `;
4965
- class ki {
4972
+ class Mi {
4966
4973
  constructor(e, t) {
4967
4974
  d(this, "canvas");
4968
4975
  d(this, "backgroundColor");
@@ -5049,7 +5056,7 @@ class ki {
5049
5056
  return;
5050
5057
  const e = this.device.createShaderModule({
5051
5058
  label: "3DGS Render Shader",
5052
- code: Mi
5059
+ code: ki
5053
5060
  }), t = this.device.createBindGroupLayout({
5054
5061
  label: "Uniform Bind Group Layout",
5055
5062
  entries: [
@@ -5269,7 +5276,7 @@ class Fi {
5269
5276
  const { preferBackend: e, backgroundColor: t = [0, 0, 0, 0] } = this.options;
5270
5277
  if (e !== "webgl" && await this.checkWebGPUSupport())
5271
5278
  try {
5272
- this.renderer = new ki(this.canvas, t), await this.renderer.initialize(), this.backend = "webgpu", h.log("✅ Using WebGPU renderer"), this.updateCameraAspect();
5279
+ this.renderer = new Mi(this.canvas, t), await this.renderer.initialize(), this.backend = "webgpu", h.log("✅ Using WebGPU renderer"), this.updateCameraAspect();
5273
5280
  return;
5274
5281
  } catch (i) {
5275
5282
  h.warn("⚠️ WebGPU init failed, fallback to WebGL:", i);
@@ -5335,7 +5342,7 @@ class Fi {
5335
5342
  */
5336
5343
  dispose() {
5337
5344
  var e;
5338
- (e = this.renderer) == null || e.dispose(), this.renderer = null;
5345
+ (e = this.renderer) == null || e.dispose(), this.renderer = null, this.originalPackedData = null;
5339
5346
  }
5340
5347
  // ========== 私有方法 ==========
5341
5348
  /**
@@ -5534,7 +5541,7 @@ class Ni {
5534
5541
  n.from,
5535
5542
  n.to,
5536
5543
  this.transitionDurationMs,
5537
- M.animation.fps
5544
+ k.animation.fps
5538
5545
  );
5539
5546
  return i.length < 2 && (i = [n.from, n.to]), i[0] = n.from, i[i.length - 1] = n.to, i;
5540
5547
  }
@@ -5584,17 +5591,17 @@ class Ni {
5584
5591
  */
5585
5592
  async initializeView(e) {
5586
5593
  try {
5587
- M.debug && h.log("[AvatarView] Initializing avatar view...");
5594
+ k.debug && h.log("[AvatarView] Initializing avatar view...");
5588
5595
  const t = b.getAvatarCore();
5589
5596
  if (!t)
5590
5597
  throw new Error("AvatarCore not available. AvatarKit initialization may have failed.");
5591
5598
  const n = e.getResources();
5592
- M.debug && h.log("[AvatarView] Loading character data..."), await t.loadCharacterFromBuffers(
5599
+ k.debug && h.log("[AvatarView] Loading character data..."), await t.loadCharacterFromBuffers(
5593
5600
  n.characterData.shape,
5594
5601
  n.characterData.pointCloud
5595
- ), n.characterData.idleAnimation && (M.debug && h.log("[AvatarView] Loading idle animation..."), await t.loadAnimationFromBuffer(n.characterData.idleAnimation)), M.debug && h.log("[AvatarView] Initializing render system...");
5602
+ ), n.characterData.idleAnimation && (k.debug && h.log("[AvatarView] Loading idle animation..."), await t.loadAnimationFromBuffer(n.characterData.idleAnimation)), k.debug && h.log("[AvatarView] Initializing render system...");
5596
5603
  const i = this.resolveCameraConfig(n);
5597
- await this.initializeRenderSystem(i), M.debug && h.log("[AvatarView] Starting rendering..."), await this.renderFirstFrame(), this.startIdleAnimationLoop(), this.isInitialized = !0, M.debug && h.log("[AvatarView] Avatar view initialized successfully");
5604
+ await this.initializeRenderSystem(i), k.debug && h.log("[AvatarView] Starting rendering..."), await this.renderFirstFrame(), this.startIdleAnimationLoop(), this.isInitialized = !0, k.debug && h.log("[AvatarView] Avatar view initialized successfully");
5598
5605
  } catch (t) {
5599
5606
  throw h.error("[AvatarView] Failed to initialize avatar view:", t instanceof Error ? t.message : String(t)), t;
5600
5607
  }
@@ -5608,13 +5615,13 @@ class Ni {
5608
5615
  camera: this.cameraConfig,
5609
5616
  backgroundColor: [0, 0, 0, 0]
5610
5617
  // 透明背景,让 CSS 背景透出
5611
- }), await this.renderSystem.initialize(), M.debug && h.log("[AvatarView] Render system initialized successfully");
5618
+ }), await this.renderSystem.initialize(), k.debug && h.log("[AvatarView] Render system initialized successfully");
5612
5619
  }
5613
5620
  /**
5614
5621
  * 获取默认相机配置
5615
5622
  */
5616
5623
  getDefaultCameraConfig() {
5617
- return { ...M.camera };
5624
+ return { ...k.camera };
5618
5625
  }
5619
5626
  /**
5620
5627
  * 根据资源解析最终的相机配置,优先使用角色设置,其次 camera.json
@@ -5685,7 +5692,7 @@ class Ni {
5685
5692
  eyes_pose: [0, 0, 0, 0, 0, 0]
5686
5693
  }, n = await e.computeFrameFlatFromParams(t);
5687
5694
  if (n)
5688
- this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(), M.debug && h.log("[AvatarView] First frame rendered successfully");
5695
+ this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(), k.debug && h.log("[AvatarView] First frame rendered successfully");
5689
5696
  else
5690
5697
  throw new Error("Failed to compute first frame splat data");
5691
5698
  }
@@ -5696,7 +5703,7 @@ class Ni {
5696
5703
  if (this.idleAnimationLoopId)
5697
5704
  return;
5698
5705
  if (this.renderingState !== "idle") {
5699
- M.debug && h.log("[AvatarView] Skip starting idle loop because not in idle state");
5706
+ k.debug && h.log("[AvatarView] Skip starting idle loop because not in idle state");
5700
5707
  return;
5701
5708
  }
5702
5709
  this.idleCurrentFrameIndex = 0;
@@ -5728,7 +5735,7 @@ class Ni {
5728
5735
  h.error("[AvatarView] Idle animation loop error:", o instanceof Error ? o.message : String(o)), this.stopIdleAnimationLoop();
5729
5736
  }
5730
5737
  };
5731
- this.idleAnimationLoopId = requestAnimationFrame(i), M.debug && h.log("[AvatarView] Idle animation loop started");
5738
+ this.idleAnimationLoopId = requestAnimationFrame(i), k.debug && h.log("[AvatarView] Idle animation loop started");
5732
5739
  }
5733
5740
  /**
5734
5741
  * 开始实时对话动画循环
@@ -5783,19 +5790,19 @@ class Ni {
5783
5790
  h.error("[AvatarView] Realtime animation loop error:", o instanceof Error ? o.message : String(o)), this.stopRealtimeAnimationLoop();
5784
5791
  }
5785
5792
  };
5786
- this.realtimeAnimationLoopId = requestAnimationFrame(i), M.debug && h.log("[AvatarView] Realtime animation loop started");
5793
+ this.realtimeAnimationLoopId = requestAnimationFrame(i), k.debug && h.log("[AvatarView] Realtime animation loop started");
5787
5794
  }
5788
5795
  /**
5789
5796
  * 停止idle动画循环
5790
5797
  */
5791
5798
  stopIdleAnimationLoop() {
5792
- this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null, M.debug && h.log("[AvatarView] Idle animation loop stopped"));
5799
+ this.idleAnimationLoopId && (cancelAnimationFrame(this.idleAnimationLoopId), this.idleAnimationLoopId = null, k.debug && h.log("[AvatarView] Idle animation loop stopped"));
5793
5800
  }
5794
5801
  /**
5795
5802
  * 停止实时对话动画循环
5796
5803
  */
5797
5804
  stopRealtimeAnimationLoop() {
5798
- this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null, M.debug && h.log("[AvatarView] Realtime animation loop stopped"));
5805
+ this.realtimeAnimationLoopId && (cancelAnimationFrame(this.realtimeAnimationLoopId), this.realtimeAnimationLoopId = null, k.debug && h.log("[AvatarView] Realtime animation loop stopped"));
5799
5806
  }
5800
5807
  /**
5801
5808
  * 停止所有动画循环
@@ -5894,7 +5901,7 @@ class Ni {
5894
5901
  this.transitionKeyframes = this.generateAndAlignTransitionFrames(a, o), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
5895
5902
  "speaking"
5896
5903
  /* Speaking */
5897
- ), this.avatarController.onTransitionComplete()) : M.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
5904
+ ), this.avatarController.onTransitionComplete()) : k.debug && h.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
5898
5905
  }
5899
5906
  } catch (n) {
5900
5907
  h.warn("[AvatarView] Transition generation failed:", n instanceof Error ? n.message : String(n)), this.renderingState === "transitioningToSpeaking" && (this.setState(
@@ -5908,7 +5915,7 @@ class Ni {
5908
5915
  * 开始实时渲染循环
5909
5916
  */
5910
5917
  startRealtimeRendering() {
5911
- M.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"), b.logEvent("character_view", "info", {
5918
+ k.debug && h.log("[AvatarView] Starting realtime rendering with", this.currentKeyframes.length, "keyframes"), b.logEvent("character_view", "info", {
5912
5919
  characterId: this.avatar.id,
5913
5920
  event: "rendering_started",
5914
5921
  keyframesCount: this.currentKeyframes.length
@@ -5937,7 +5944,7 @@ class Ni {
5937
5944
  if (b.getAvatarCore() && this.currentKeyframes.length > 0) {
5938
5945
  const n = this.lastRealtimeProtoFrame || this.currentKeyframes[Math.max(0, this.lastRenderedFrameIndex)], i = await this.getCachedIdleFirstFrame();
5939
5946
  if (i && (this.transitionKeyframes = this.generateAndAlignTransitionFrames(n, i), this.transitionStartTime = performance.now(), this.transitionKeyframes.length > 0 && this.renderingState === "transitioningToIdle")) {
5940
- M.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
5947
+ k.debug && h.log("[AvatarView] Return transition started:", this.transitionKeyframes.length, "frames"), this.realtimeAnimationLoopId || this.startRealtimeAnimationLoop();
5941
5948
  return;
5942
5949
  }
5943
5950
  }
@@ -5956,21 +5963,21 @@ class Ni {
5956
5963
  * 关闭 avatarController 并清理所有相关资源
5957
5964
  */
5958
5965
  dispose() {
5959
- M.debug && h.log("[AvatarView] Disposing avatar view..."), b.logEvent("character_view", "info", {
5966
+ k.debug && h.log("[AvatarView] Disposing avatar view..."), b.logEvent("character_view", "info", {
5960
5967
  characterId: this.avatar.id,
5961
5968
  event: "disposed"
5962
- }), this.avatarController && this.avatarController.clear(), this.stopAllAnimationLoops(), this.setState(
5969
+ }), this.avatarController && (this.avatarController.clear(), this.avatarController.dispose()), this.stopAllAnimationLoops(), this.setState(
5963
5970
  "idle"
5964
5971
  /* Idle */
5965
- );
5972
+ ), this.cachedIdleFirstFrame = null, this.idleCurrentFrameIndex = 0;
5966
5973
  const e = b.getAvatarCore();
5967
5974
  if (e)
5968
5975
  try {
5969
- e.releaseCurrentCharacter(), M.debug && h.log("[AvatarView] AvatarCore character resources released");
5976
+ e.releaseCurrentCharacter(), k.debug && h.log("[AvatarView] AvatarCore character resources released");
5970
5977
  } catch (t) {
5971
5978
  h.error("[AvatarView] Failed to release AvatarCore resources:", t instanceof Error ? t.message : String(t));
5972
5979
  }
5973
- this.renderSystem && (this.renderSystem.dispose(), this.renderSystem = null), this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), window.removeEventListener("resize", this.onWindowResize), this.isInitialized = !1, M.debug && h.log("[AvatarView] Avatar view disposed successfully");
5980
+ this.renderSystem && (this.renderSystem.dispose(), this.renderSystem = null), this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), window.removeEventListener("resize", this.onWindowResize), this.isInitialized = !1, k.debug && h.log("[AvatarView] Avatar view disposed successfully");
5974
5981
  }
5975
5982
  /**
5976
5983
  * 获取相机配置
@@ -5982,7 +5989,7 @@ class Ni {
5982
5989
  * 更新相机配置
5983
5990
  */
5984
5991
  updateCameraConfig(e) {
5985
- this.cameraConfig = e, M.debug && h.log("[AvatarView] Camera config updated:", e), this.renderSystem && (this.renderSystem.updateCamera(e), M.debug && h.log("[AvatarView] Applied new camera config to render system"));
5992
+ this.cameraConfig = e, k.debug && h.log("[AvatarView] Camera config updated:", e), this.renderSystem && (this.renderSystem.updateCamera(e), k.debug && h.log("[AvatarView] Applied new camera config to render system"));
5986
5993
  }
5987
5994
  /**
5988
5995
  * 处理尺寸变化:通知渲染系统更新视口与投影
@@ -6004,7 +6011,7 @@ class Ni {
6004
6011
  }
6005
6012
  }
6006
6013
  export {
6007
- M as A,
6014
+ k as A,
6008
6015
  Se as C,
6009
6016
  le as E,
6010
6017
  oe as L,
@@ -6023,4 +6030,4 @@ export {
6023
6030
  Oi as k,
6024
6031
  h as l
6025
6032
  };
6026
- //# sourceMappingURL=index-CpSvWi6A.js.map
6033
+ //# sourceMappingURL=index-8jCKHF1q.js.map