@tiktool/live 2.12.3 → 2.13.0

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/dist/index.mjs CHANGED
@@ -1598,12 +1598,18 @@ function parseWebcastMessage(method, payload) {
1598
1598
  }
1599
1599
  }
1600
1600
  let toUserId = "";
1601
+ const receiverBuf = getBytes(f, 8);
1602
+ if (receiverBuf) {
1603
+ const r = parseUser(receiverBuf);
1604
+ if (r.id && r.id !== "0") toUserId = r.id;
1605
+ }
1601
1606
  const extraBuf = getBytes(f, 23);
1602
- if (extraBuf) {
1603
- const ef = decodeProto(extraBuf);
1604
- toUserId = String(getInt(ef, 8));
1607
+ if (!toUserId && extraBuf) {
1608
+ const id = getIntStr(decodeProto(extraBuf), 8);
1609
+ if (id !== "0") toUserId = id;
1605
1610
  }
1606
- const groupId = toUserId || getStr(f, 11);
1611
+ const rawGroup = getIntStr(f, 11);
1612
+ const groupId = getStr(f, 11) || (rawGroup !== "0" ? rawGroup : "");
1607
1613
  return {
1608
1614
  ...base,
1609
1615
  type: "gift",
@@ -1615,7 +1621,9 @@ function parseWebcastMessage(method, payload) {
1615
1621
  repeatEnd,
1616
1622
  combo: repeatCount > 1 && !repeatEnd,
1617
1623
  giftType,
1618
- groupId
1624
+ groupId,
1625
+ toUserId,
1626
+ receiverUserId: toUserId
1619
1627
  };
1620
1628
  }
1621
1629
  // Proto: WebcastSocialMessage { User user=2, WebcastMessageEvent event=1 }
@@ -1641,7 +1649,7 @@ function parseWebcastMessage(method, payload) {
1641
1649
  // Proto: WebcastRoomUserSeqMessage { int32 viewerCount=3 }
1642
1650
  case "WebcastRoomUserSeqMessage": {
1643
1651
  const viewerCount = getInt(f, 3) || getInt(f, 2);
1644
- const totalViewers = getInt(f, 1) || viewerCount;
1652
+ const totalViewers = getInt(f, 7) || viewerCount;
1645
1653
  return { ...base, type: "roomUserSeq", totalViewers, viewerCount };
1646
1654
  }
1647
1655
  // Proto: WebcastLinkMicBattle { repeated WebcastLinkMicBattleItems battleUsers=10 }
@@ -2155,6 +2163,11 @@ var TikTokLive = class _TikTokLive extends EventEmitter {
2155
2163
  if (this._destroyed) throw new Error("Client has been destroyed. Create a new instance.");
2156
2164
  this.intentionalClose = false;
2157
2165
  if (this.mode === "relayed") {
2166
+ if (this._presetRoomId) {
2167
+ console.warn(
2168
+ `[TikTokLive] roomId=${this._presetRoomId} is ignored in mode:'relayed' - the managed relay resolves the room itself. Use mode:'direct' with roomId to pin an exact room (resolve it first via /webcast/bulk_live_check).`
2169
+ );
2170
+ }
2158
2171
  return this._connectRelayed();
2159
2172
  }
2160
2173
  let ttwid = this._presetSessionId;
@@ -2590,6 +2603,9 @@ var TikTokLive = class _TikTokLive extends EventEmitter {
2590
2603
  }
2591
2604
  this.emit("event", evt);
2592
2605
  this.emit(evt.type, evt);
2606
+ if (evt.type === "control" && evt.action === 3) {
2607
+ this.emit("streamEnd", { type: "streamEnd", uniqueId: this.uniqueId, reason: "creator_offline" });
2608
+ }
2593
2609
  }
2594
2610
  }
2595
2611
  } catch {