@tiktool/live 2.7.0 → 2.8.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.d.mts CHANGED
@@ -74,6 +74,24 @@ interface BattleEvent extends BaseEvent {
74
74
  battleDuration: number;
75
75
  teams: BattleTeam[];
76
76
  }
77
+ interface BattleContributor {
78
+ /** TikTok userId of the gifter */
79
+ userId: string;
80
+ /** Diamond score this gifter contributed to the host's team */
81
+ score: number;
82
+ /** Display nickname (may be empty if not set on the account) */
83
+ nickname: string;
84
+ }
85
+ interface BattleHost {
86
+ /** TikTok userId of the host on this PK side */
87
+ hostUserId: string;
88
+ /** Total diamonds for this host's team */
89
+ teamTotalScore: number;
90
+ /** Side index (0 = left side, 1 = right side, …) */
91
+ teamIdx: number;
92
+ /** Per-gifter breakdown, sorted MVP first (highest score → lowest). */
93
+ contributors: BattleContributor[];
94
+ }
77
95
  interface BattleArmiesEvent extends BaseEvent {
78
96
  type: 'battleArmies';
79
97
  battleId: string;
@@ -83,8 +101,62 @@ interface BattleArmiesEvent extends BaseEvent {
83
101
  battleStartMs: number;
84
102
  /** Total battle duration in seconds (from f18.f3, typically 300) */
85
103
  battleDurationSeconds: number;
86
- /** Seconds remaining in the battle, computed as max(0, duration - elapsed) */
104
+ /** Seconds remaining in the battle, computed as max(0, duration - elapsed). Note: uses VPS clock, may be off by up to 30s */
87
105
  timeLeftSeconds: number;
106
+ /** Battle end timestamp in milliseconds (battleStartMs + duration*1000). Use for clock-independent timer: Math.max(0, (endTimeMs - Date.now()) / 1000) */
107
+ endTimeMs: number;
108
+ /** Stable match ID across multi-round PK (from top-level field 2). */
109
+ matchId?: string;
110
+ /** Per-round session ID (from top-level field 4). */
111
+ sessionId?: string;
112
+ /** TikTok server-side clock at frame emit (ms epoch). */
113
+ serverTsMs?: number;
114
+ /** Hex string tag used by TikTok for per-session matching (~34 chars). */
115
+ sessionTag?: string;
116
+ /** Total battle duration in seconds (from f18.f3). Alias for battleDurationSeconds. */
117
+ durationSec?: number;
118
+ /** Seconds remaining computed using TikTok server clock (no VPS drift). */
119
+ secsRemaining?: number;
120
+ /**
121
+ * Multi-guest host breakdown — one entry per host on a PK side.
122
+ * Each entry includes per-gifter contributors sorted MVP first.
123
+ */
124
+ hosts?: BattleHost[];
125
+ }
126
+ /**
127
+ * Battle Item Card event — booster multipliers (x2/x3), gloves, mist, thunder,
128
+ * extra-time, match-guide, etc. Emitted on `battleItemCard`.
129
+ */
130
+ interface BattleItemCardEvent extends BaseEvent {
131
+ type: 'battleItemCard';
132
+ battleId: string;
133
+ /** 2=gloves/crit, 3=mist, 4=match_guide, 10=x2?, 11=x3, … */
134
+ cardType: number;
135
+ /** 'gloves' | 'mist' | 'booster_x2' | 'booster_x3' | 'match_guide' | 'thunder' | 'extra_time' | raw resource key */
136
+ effect: string;
137
+ /** Raw TikTok resource key (e.g. 'pm_mt_boost_crit_name'). */
138
+ effectKey: string;
139
+ /** 2 or 3 for booster_x2/x3, otherwise 0. */
140
+ multiplier: number;
141
+ senderUserId: string;
142
+ senderNickname: string;
143
+ senderUniqueId: string;
144
+ /** First CDN URL for sender's avatar (best-resolution). */
145
+ senderAvatarUrl: string;
146
+ /** Unix seconds when the buff activated. */
147
+ activatedAtSec: number;
148
+ /** Total active duration in seconds. */
149
+ durationSec: number;
150
+ /** Unix seconds when the buff ends. */
151
+ endsAtSec: number;
152
+ /** Comment template, e.g. "{0:user} sent 1 magic mist". */
153
+ commentTemplate: string;
154
+ /** Full TikTok CDN URL for the card art (webp/jpeg). */
155
+ iconUrl: string;
156
+ /** Short identifier e.g. 'card_mist_v3' / 'card_crit_v3' / 'top3_buffer'. */
157
+ iconKey: string;
158
+ /** Hex e.g. '#BCD9E0' (mist blue), '#E0D4BC' (gloves tan). */
159
+ accentColor: string;
88
160
  }
89
161
  interface SubscribeEvent extends BaseEvent {
90
162
  type: 'subscribe';
@@ -138,7 +210,7 @@ interface UnknownEvent extends BaseEvent {
138
210
  type: 'unknown';
139
211
  method: string;
140
212
  }
141
- type LiveEvent = ChatEvent | MemberEvent | LikeEvent | GiftEvent | SocialEvent | RoomUserSeqEvent | BattleEvent | BattleArmiesEvent | SubscribeEvent | EmoteChatEvent | EnvelopeEvent | QuestionEvent | ControlEvent | RoomEvent | LiveIntroEvent | RankUpdateEvent | LinkMicEvent | UnknownEvent;
213
+ type LiveEvent = ChatEvent | MemberEvent | LikeEvent | GiftEvent | SocialEvent | RoomUserSeqEvent | BattleEvent | BattleArmiesEvent | BattleItemCardEvent | SubscribeEvent | EmoteChatEvent | EnvelopeEvent | QuestionEvent | ControlEvent | RoomEvent | LiveIntroEvent | RankUpdateEvent | LinkMicEvent | UnknownEvent;
142
214
  interface TikTokLiveEvents {
143
215
  connected: () => void;
144
216
  disconnected: (code: number, reason: string) => void;
@@ -152,6 +224,7 @@ interface TikTokLiveEvents {
152
224
  roomUserSeq: (event: RoomUserSeqEvent) => void;
153
225
  battle: (event: BattleEvent) => void;
154
226
  battleArmies: (event: BattleArmiesEvent) => void;
227
+ battleItemCard: (event: BattleItemCardEvent) => void;
155
228
  subscribe: (event: SubscribeEvent) => void;
156
229
  emoteChat: (event: EmoteChatEvent) => void;
157
230
  envelope: (event: EnvelopeEvent) => void;
@@ -234,7 +307,7 @@ declare class TikTokLive extends EventEmitter {
234
307
  disconnect(): void;
235
308
  /**
236
309
  * Fully destroy the client, releasing all resources and listeners.
237
- * After calling destroy(), the instance cannot be reused — create a new one.
310
+ * After calling destroy(), the instance cannot be reused — create a new one.
238
311
  */
239
312
  destroy(): void;
240
313
  get connected(): boolean;
@@ -244,7 +317,7 @@ declare class TikTokLive extends EventEmitter {
244
317
  /**
245
318
  * Get live stream video URLs for a TikTok user.
246
319
  * Returns FLV & HLS URLs segmented by quality (FULL_HD1, HD1, SD1, SD2).
247
- * This is a standalone method — no WebSocket connection required.
320
+ * This is a standalone method — no WebSocket connection required.
248
321
  *
249
322
  * @example
250
323
  * ```ts
@@ -278,4 +351,4 @@ declare class TikTokLive extends EventEmitter {
278
351
  private stopHeartbeat;
279
352
  }
280
353
 
281
- export { type BaseEvent, type BattleArmiesEvent, type BattleEvent, type BattleTeam, type BattleTeamUser, type ChatEvent, type ControlEvent, type EmoteChatEvent, type EnvelopeEvent, type GiftEvent, type LikeEvent, type LinkMicEvent, type LiveEvent, type LiveIntroEvent, type MemberEvent, type QuestionEvent, type RankUpdateEvent, type RoomEvent, type RoomInfo, type RoomUserSeqEvent, type SocialEvent, type StreamInfo, type StreamQuality, type StreamUrls, type SubscribeEvent, TikTokLive, type TikTokLiveEvents, type TikTokLiveOptions, type TikTokUser, type UnknownEvent };
354
+ export { type BaseEvent, type BattleArmiesEvent, type BattleContributor, type BattleEvent, type BattleHost, type BattleItemCardEvent, type BattleTeam, type BattleTeamUser, type ChatEvent, type ControlEvent, type EmoteChatEvent, type EnvelopeEvent, type GiftEvent, type LikeEvent, type LinkMicEvent, type LiveEvent, type LiveIntroEvent, type MemberEvent, type QuestionEvent, type RankUpdateEvent, type RoomEvent, type RoomInfo, type RoomUserSeqEvent, type SocialEvent, type StreamInfo, type StreamQuality, type StreamUrls, type SubscribeEvent, TikTokLive, type TikTokLiveEvents, type TikTokLiveOptions, type TikTokUser, type UnknownEvent };
package/dist/index.d.ts CHANGED
@@ -74,6 +74,24 @@ interface BattleEvent extends BaseEvent {
74
74
  battleDuration: number;
75
75
  teams: BattleTeam[];
76
76
  }
77
+ interface BattleContributor {
78
+ /** TikTok userId of the gifter */
79
+ userId: string;
80
+ /** Diamond score this gifter contributed to the host's team */
81
+ score: number;
82
+ /** Display nickname (may be empty if not set on the account) */
83
+ nickname: string;
84
+ }
85
+ interface BattleHost {
86
+ /** TikTok userId of the host on this PK side */
87
+ hostUserId: string;
88
+ /** Total diamonds for this host's team */
89
+ teamTotalScore: number;
90
+ /** Side index (0 = left side, 1 = right side, …) */
91
+ teamIdx: number;
92
+ /** Per-gifter breakdown, sorted MVP first (highest score → lowest). */
93
+ contributors: BattleContributor[];
94
+ }
77
95
  interface BattleArmiesEvent extends BaseEvent {
78
96
  type: 'battleArmies';
79
97
  battleId: string;
@@ -83,8 +101,62 @@ interface BattleArmiesEvent extends BaseEvent {
83
101
  battleStartMs: number;
84
102
  /** Total battle duration in seconds (from f18.f3, typically 300) */
85
103
  battleDurationSeconds: number;
86
- /** Seconds remaining in the battle, computed as max(0, duration - elapsed) */
104
+ /** Seconds remaining in the battle, computed as max(0, duration - elapsed). Note: uses VPS clock, may be off by up to 30s */
87
105
  timeLeftSeconds: number;
106
+ /** Battle end timestamp in milliseconds (battleStartMs + duration*1000). Use for clock-independent timer: Math.max(0, (endTimeMs - Date.now()) / 1000) */
107
+ endTimeMs: number;
108
+ /** Stable match ID across multi-round PK (from top-level field 2). */
109
+ matchId?: string;
110
+ /** Per-round session ID (from top-level field 4). */
111
+ sessionId?: string;
112
+ /** TikTok server-side clock at frame emit (ms epoch). */
113
+ serverTsMs?: number;
114
+ /** Hex string tag used by TikTok for per-session matching (~34 chars). */
115
+ sessionTag?: string;
116
+ /** Total battle duration in seconds (from f18.f3). Alias for battleDurationSeconds. */
117
+ durationSec?: number;
118
+ /** Seconds remaining computed using TikTok server clock (no VPS drift). */
119
+ secsRemaining?: number;
120
+ /**
121
+ * Multi-guest host breakdown — one entry per host on a PK side.
122
+ * Each entry includes per-gifter contributors sorted MVP first.
123
+ */
124
+ hosts?: BattleHost[];
125
+ }
126
+ /**
127
+ * Battle Item Card event — booster multipliers (x2/x3), gloves, mist, thunder,
128
+ * extra-time, match-guide, etc. Emitted on `battleItemCard`.
129
+ */
130
+ interface BattleItemCardEvent extends BaseEvent {
131
+ type: 'battleItemCard';
132
+ battleId: string;
133
+ /** 2=gloves/crit, 3=mist, 4=match_guide, 10=x2?, 11=x3, … */
134
+ cardType: number;
135
+ /** 'gloves' | 'mist' | 'booster_x2' | 'booster_x3' | 'match_guide' | 'thunder' | 'extra_time' | raw resource key */
136
+ effect: string;
137
+ /** Raw TikTok resource key (e.g. 'pm_mt_boost_crit_name'). */
138
+ effectKey: string;
139
+ /** 2 or 3 for booster_x2/x3, otherwise 0. */
140
+ multiplier: number;
141
+ senderUserId: string;
142
+ senderNickname: string;
143
+ senderUniqueId: string;
144
+ /** First CDN URL for sender's avatar (best-resolution). */
145
+ senderAvatarUrl: string;
146
+ /** Unix seconds when the buff activated. */
147
+ activatedAtSec: number;
148
+ /** Total active duration in seconds. */
149
+ durationSec: number;
150
+ /** Unix seconds when the buff ends. */
151
+ endsAtSec: number;
152
+ /** Comment template, e.g. "{0:user} sent 1 magic mist". */
153
+ commentTemplate: string;
154
+ /** Full TikTok CDN URL for the card art (webp/jpeg). */
155
+ iconUrl: string;
156
+ /** Short identifier e.g. 'card_mist_v3' / 'card_crit_v3' / 'top3_buffer'. */
157
+ iconKey: string;
158
+ /** Hex e.g. '#BCD9E0' (mist blue), '#E0D4BC' (gloves tan). */
159
+ accentColor: string;
88
160
  }
89
161
  interface SubscribeEvent extends BaseEvent {
90
162
  type: 'subscribe';
@@ -138,7 +210,7 @@ interface UnknownEvent extends BaseEvent {
138
210
  type: 'unknown';
139
211
  method: string;
140
212
  }
141
- type LiveEvent = ChatEvent | MemberEvent | LikeEvent | GiftEvent | SocialEvent | RoomUserSeqEvent | BattleEvent | BattleArmiesEvent | SubscribeEvent | EmoteChatEvent | EnvelopeEvent | QuestionEvent | ControlEvent | RoomEvent | LiveIntroEvent | RankUpdateEvent | LinkMicEvent | UnknownEvent;
213
+ type LiveEvent = ChatEvent | MemberEvent | LikeEvent | GiftEvent | SocialEvent | RoomUserSeqEvent | BattleEvent | BattleArmiesEvent | BattleItemCardEvent | SubscribeEvent | EmoteChatEvent | EnvelopeEvent | QuestionEvent | ControlEvent | RoomEvent | LiveIntroEvent | RankUpdateEvent | LinkMicEvent | UnknownEvent;
142
214
  interface TikTokLiveEvents {
143
215
  connected: () => void;
144
216
  disconnected: (code: number, reason: string) => void;
@@ -152,6 +224,7 @@ interface TikTokLiveEvents {
152
224
  roomUserSeq: (event: RoomUserSeqEvent) => void;
153
225
  battle: (event: BattleEvent) => void;
154
226
  battleArmies: (event: BattleArmiesEvent) => void;
227
+ battleItemCard: (event: BattleItemCardEvent) => void;
155
228
  subscribe: (event: SubscribeEvent) => void;
156
229
  emoteChat: (event: EmoteChatEvent) => void;
157
230
  envelope: (event: EnvelopeEvent) => void;
@@ -234,7 +307,7 @@ declare class TikTokLive extends EventEmitter {
234
307
  disconnect(): void;
235
308
  /**
236
309
  * Fully destroy the client, releasing all resources and listeners.
237
- * After calling destroy(), the instance cannot be reused — create a new one.
310
+ * After calling destroy(), the instance cannot be reused — create a new one.
238
311
  */
239
312
  destroy(): void;
240
313
  get connected(): boolean;
@@ -244,7 +317,7 @@ declare class TikTokLive extends EventEmitter {
244
317
  /**
245
318
  * Get live stream video URLs for a TikTok user.
246
319
  * Returns FLV & HLS URLs segmented by quality (FULL_HD1, HD1, SD1, SD2).
247
- * This is a standalone method — no WebSocket connection required.
320
+ * This is a standalone method — no WebSocket connection required.
248
321
  *
249
322
  * @example
250
323
  * ```ts
@@ -278,4 +351,4 @@ declare class TikTokLive extends EventEmitter {
278
351
  private stopHeartbeat;
279
352
  }
280
353
 
281
- export { type BaseEvent, type BattleArmiesEvent, type BattleEvent, type BattleTeam, type BattleTeamUser, type ChatEvent, type ControlEvent, type EmoteChatEvent, type EnvelopeEvent, type GiftEvent, type LikeEvent, type LinkMicEvent, type LiveEvent, type LiveIntroEvent, type MemberEvent, type QuestionEvent, type RankUpdateEvent, type RoomEvent, type RoomInfo, type RoomUserSeqEvent, type SocialEvent, type StreamInfo, type StreamQuality, type StreamUrls, type SubscribeEvent, TikTokLive, type TikTokLiveEvents, type TikTokLiveOptions, type TikTokUser, type UnknownEvent };
354
+ export { type BaseEvent, type BattleArmiesEvent, type BattleContributor, type BattleEvent, type BattleHost, type BattleItemCardEvent, type BattleTeam, type BattleTeamUser, type ChatEvent, type ControlEvent, type EmoteChatEvent, type EnvelopeEvent, type GiftEvent, type LikeEvent, type LinkMicEvent, type LiveEvent, type LiveIntroEvent, type MemberEvent, type QuestionEvent, type RankUpdateEvent, type RoomEvent, type RoomInfo, type RoomUserSeqEvent, type SocialEvent, type StreamInfo, type StreamQuality, type StreamUrls, type SubscribeEvent, TikTokLive, type TikTokLiveEvents, type TikTokLiveOptions, type TikTokUser, type UnknownEvent };