@laplace.live/internal 1.3.21 → 1.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laplace.live/internal",
3
- "version": "1.3.21",
3
+ "version": "1.3.22",
4
4
  "module": "src/index.d.ts",
5
5
  "exports": {
6
6
  ".": "./src/index.d.ts",
@@ -16,32 +16,52 @@ export declare namespace Danmakus {
16
16
  data: RankingItem[]
17
17
  }
18
18
 
19
- /** Item of `RankingProps` */
20
- export interface RankingItem {
19
+ /**
20
+ * Channel info, shared by `RankingItem`, `ChannelInfoProps` and
21
+ * `WatchedChannelsItem` (maps to `APIChannelInfo` in the spec).
22
+ */
23
+ export interface ChannelInfo {
21
24
  uId: number
22
25
  uName: string
23
26
  roomId: number
24
27
  faceUrl: string
25
28
  frameUrl: string
26
29
  isLiving: boolean
30
+ isDeleted: boolean
27
31
  title: string
28
32
  tags: string[]
29
33
  lastLiveDate: number
30
34
  lastLiveDanmakuCount: number
31
35
  totalDanmakuCount: number
32
- totalIncome: {
33
- value: string
34
- type: 'Big Number'
35
- }
36
+ totalIncome: number
36
37
  totalLiveCount: number
37
38
  totalLiveSecond: number
38
39
  addDate: Date
39
40
  /** can be empty in some rare case due to some program error */
40
41
  livingInfo?: LiveItem
41
42
  commentCount: number
43
+ fansCount: number
44
+ followCount: number
45
+ lastUpdateStatAt: number
42
46
  lastLiveIncome: number
47
+ recordingStatus?: ChannelRecordingStatus | null
48
+ }
49
+
50
+ /** Recording status of a channel (`APIChannelRecordingStatus`) */
51
+ export interface ChannelRecordingStatus {
52
+ publicUsers: ChannelRecordingUser[]
53
+ privateCount: number
54
+ }
55
+
56
+ /** Item of `ChannelRecordingStatus.publicUsers` (`APIChannelRecordingUser`) */
57
+ export interface ChannelRecordingUser {
58
+ accountId: number
59
+ name: string
43
60
  }
44
61
 
62
+ /** Item of `RankingProps` */
63
+ export interface RankingItem extends ChannelInfo {}
64
+
45
65
  /**
46
66
  * 频道信息(直播记录列表)
47
67
  * @link https://ukamnads.icu/api/v2/channel?uId=2132180406
@@ -74,45 +94,42 @@ export declare namespace Danmakus {
74
94
  }
75
95
 
76
96
  /** Props of `ChannelData` */
77
- export interface ChannelInfoProps {
78
- uId: number
79
- uName: string
80
- roomId: number
81
- faceUrl: string
82
- frameUrl: string
83
- isLiving: boolean
84
- title: string
85
- tags: string[]
86
- lastLiveDate: number
87
- lastLiveDanmakuCount: number
88
- totalDanmakuCount: number
89
- totalIncome: number
90
- totalLiveCount: number
91
- totalLiveSecond: number
92
- addDate: Date
93
- commentCount: number
94
- lastLiveIncome: number
95
- }
97
+ export interface ChannelInfoProps extends ChannelInfo {}
96
98
 
97
- /** General live stream item */
99
+ /** General live stream item (`APILiveInfo`) */
98
100
  export interface LiveItem {
99
101
  liveId: string
100
102
  isFinish: boolean
101
103
  isFull: boolean
104
+ isMerged: boolean
102
105
  parentArea: string
103
106
  area: string
104
107
  coverUrl: string
105
108
  danmakusCount: number
106
109
  startDate: number
107
- stopDate: number
110
+ stopDate: number | null
108
111
  title: string
109
112
  totalIncome: number
110
113
  watchCount: number
111
114
  likeCount: number
112
115
  payCount: number
113
116
  interactionCount: number
114
- onlineRank: number
117
+ onlineRank: number | null
115
118
  maxOnlineCount: number
119
+ commentCount: number
120
+ /** present when requested with `includeExtra=true` */
121
+ extra?: ExtraProps
122
+ versions?: LiveVersionInfo[]
123
+ }
124
+
125
+ /** Item of `LiveItem.versions` (`APILiveVersionInfo`) */
126
+ export interface LiveVersionInfo {
127
+ live: LiveItem
128
+ userName: string
129
+ userId: number
130
+ isOfficial: boolean
131
+ isFull: boolean
132
+ rangeDanmakusCount: number
116
133
  }
117
134
 
118
135
  /** General danmaku event props */
@@ -130,17 +147,23 @@ export declare namespace Danmakus {
130
147
  * - 7: 直播中止
131
148
  * - 8: 直播继续
132
149
  * - 9: 用户封禁
150
+ * - 10, 11, 12: 见 API(未公开说明)
133
151
  */
134
- type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
152
+ type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
135
153
  sendDate: number
136
154
  message: string
137
- price: number
155
+ price: number | null
138
156
  ct: string
139
- count: number
157
+ count: number | null
140
158
  /**
141
159
  * 如存在,这条弹幕由用户补充上传,非本站直接采集,内容和时间可能存在偏差,本站不保证准确性。
142
160
  */
143
161
  uploadAccountId?: number
162
+ /** 盲盒名称 */
163
+ mysteryBoxName?: string
164
+ /** 盲盒价格 */
165
+ mysteryBoxPrice?: number
166
+ debugSourceFingerprint?: number
144
167
  }
145
168
 
146
169
  /** Extra props for live item */
@@ -171,26 +194,7 @@ export declare namespace Danmakus {
171
194
  hasMore: boolean
172
195
  data: {
173
196
  channel: ChannelInfoProps
174
- live: {
175
- liveId: string
176
- isFinish: boolean
177
- isFull: boolean
178
- parentArea: string
179
- area: string
180
- coverUrl: string
181
- danmakusCount: number
182
- startDate: number
183
- stopDate: number
184
- title: string
185
- totalIncome: number
186
- watchCount: number
187
- likeCount: number
188
- payCount: number
189
- interactionCount: number
190
- onlineRank: number
191
- maxOnlineCount: number
192
- extra: ExtraProps
193
- }
197
+ live: LiveItem
194
198
  danmakus: DanmakuProps[]
195
199
  }
196
200
  }
@@ -208,26 +212,13 @@ export declare namespace Danmakus {
208
212
  data: WatchedChannelsItem[]
209
213
  }
210
214
 
211
- /** Item of `WatchedChannels` */
212
- export interface WatchedChannelsItem {
213
- uId: number
214
- uName: string
215
- roomId: number
216
- faceUrl: string
217
- frameUrl: string
218
- isLiving: boolean
219
- title: string
220
- tags: string[]
221
- lastLiveDate: number
222
- lastLiveDanmakuCount: number
223
- totalDanmakuCount: number
224
- totalIncome: number
225
- totalLiveCount: number
226
- totalLiveSecond: number
227
- addDate: Date
228
- commentCount: number
229
- lastLiveIncome: number
230
- }
215
+ /**
216
+ * Item of `WatchedChannels`.
217
+ *
218
+ * Note: the spec types `/api/v2/user/watchedChannels` `data` loosely as
219
+ * `any`; this mirrors the channel info actually returned (`APIChannelInfo`).
220
+ */
221
+ export interface WatchedChannelsItem extends ChannelInfo {}
231
222
 
232
223
  /**
233
224
  * 用户观看/事件记录
@@ -256,170 +247,84 @@ export declare namespace Danmakus {
256
247
  danmakus: DanmakuProps[]
257
248
  }
258
249
 
259
- /* ----------------------------------------------------------------------------
260
- * v3 API (`/api/v3/*`)
261
- * @link https://ukamnads.icu/swagger/v3/swagger.json
262
- * -------------------------------------------------------------------------- */
263
-
264
- /**
265
- * v3 弹幕负载类型 `DanmakuRecordV3.payloadKind`
266
- * - 0: 普通消息
267
- * - 1: 礼物
268
- * - 2: 上舰
269
- * - 3: SuperChat
270
- * - 4: 进入直播间
271
- * - 5: 标题变动
272
- * - 6: 分区变动
273
- * - 7: 直播中止
274
- * - 8: 直播继续
275
- * - 9: 用户封禁
276
- * - 10: 盲盒
277
- */
278
- export type DanmakuPayloadKindV3 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
250
+ // ──────────────────────────────────────────────────────────────────────────
251
+ // v3 API
252
+ //
253
+ // The v3 endpoints replace the flat `DanmakuProps[]` list with a normalized
254
+ // "frame": danmaku records reference interned `actors` and `roomEmojis`
255
+ // tables by index, which dramatically shrinks the payload for long lives.
256
+ //
257
+ // Two transports exist for the same data:
258
+ // - JSON (`GET /api/v3/lives/{liveId}/danmakus`) — readable, fields named
259
+ // - MessagePack (`GET /api/v3/lives/{liveId}/full|delta`) — compact, fields positional
260
+ //
261
+ // The MessagePack endpoints are documented in the `Msgpack` block below.
262
+ // ──────────────────────────────────────────────────────────────────────────
279
263
 
280
264
  /**
281
- * v3 弹幕事件类型 `DanmakuRecordV3.type`
282
- * 0-10 与 {@link DanmakuPayloadKindV3} 含义一致,11/12 为 v3 新增类型(spec 未标注具体含义)
265
+ * Payload shape discriminator (`DanmakuPayloadKindV3`). Selects which
266
+ * `DanmakuPayloadV3` fields are populated — and, in the MessagePack
267
+ * transport, the positional layout of the payload tuple (see `Msgpack`).
268
+ *
269
+ * - 0: 无负载(控制 / 进场事件,如直播中止、进入直播间)
270
+ * - 1: 纯文本弹幕 → `rawText`
271
+ * - 2: 房间表情 → `roomEmojiId`
272
+ * - 3: 礼物 → `name`, `count`, `price`, `mysteryBoxName`, `mysteryBoxPrice`
273
+ * - 4: 上舰 → `name`, `count`, `price`
274
+ * - 5: SuperChat → `text`, `price`
275
+ * - 6–10: 标题 / 分区变动等(见 `DanmakuPayloadV3` 的 `previous*` / `current*` 字段)
283
276
  */
284
- export type DanmakuTypeV3 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
285
-
286
- /** 用户分析任务状态 `UserAnalyzeJobV3Summary.status`(spec 未标注枚举含义) */
287
- export type UserAnalyzeJobStatusV3 = 0 | 1 | 2 | 3 | 4
288
-
289
- /** 用户分析任务事件类型 `UserAnalyzeEventV3.type`(spec 未标注枚举含义) */
290
- export type UserAnalyzeEventTypeV3 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
291
-
292
- /** v3 频道信息 (`APIChannelInfo`) */
293
- export interface ChannelInfoV3 {
294
- uId: number
295
- uName: string
296
- roomId: number
297
- faceUrl: string
298
- frameUrl: string
299
- isLiving: boolean
300
- isDeleted: boolean
301
- title: string
302
- tags: string[]
303
- lastLiveDate: number
304
- lastLiveDanmakuCount: number
305
- totalDanmakuCount: number
306
- totalIncome: number
307
- totalLiveCount: number
308
- totalLiveSecond: number
309
- addDate: Date
310
- /** present only when the channel is currently living */
311
- livingInfo?: LiveInfoV3
312
- commentCount: number
313
- fansCount: number
314
- followCount: number
315
- lastUpdateStatAt: number
316
- lastLiveIncome: number
317
- recordingStatus?: ChannelRecordingStatusV3
318
- }
319
-
320
- /** v3 录播状态 (`APIChannelRecordingStatus`) */
321
- export interface ChannelRecordingStatusV3 {
322
- publicUsers: ChannelRecordingUserV3[]
323
- privateCount: number
324
- }
325
-
326
- /** Item of `ChannelRecordingStatusV3` (`APIChannelRecordingUser`) */
327
- export interface ChannelRecordingUserV3 {
328
- accountId: number
329
- name: string
330
- }
331
-
332
- /** v3 单场直播信息 (`APILiveInfo`) */
333
- export interface LiveInfoV3 {
334
- liveId: string
335
- isFinish: boolean
336
- isFull: boolean
337
- isMerged: boolean
338
- parentArea: string
339
- area: string
340
- coverUrl: string
341
- danmakusCount: number
342
- startDate: number
343
- /** null while the live is still ongoing */
344
- stopDate: number
345
- title: string
346
- totalIncome: number
347
- watchCount: number
348
- likeCount: number
349
- payCount: number
350
- interactionCount: number
351
- /** nullable */
352
- onlineRank: number
353
- maxOnlineCount: number
354
- commentCount: number
355
- extra?: LiveExtraDataV3
356
- versions?: LiveVersionInfoV3[]
357
- }
358
-
359
- /** v3 直播版本信息 (`APILiveVersionInfo`) */
360
- export interface LiveVersionInfoV3 {
361
- live: LiveInfoV3
362
- userName: string
363
- userId: number
364
- isOfficial: boolean
365
- isFull: boolean
366
- rangeDanmakusCount: number
367
- }
368
-
369
- /** v3 直播扩展数据 (`LiveResponeExtraData`) */
370
- export interface LiveExtraDataV3 {
371
- wordCloud: { [key: string]: number }
372
- onlineRank: { [key: string]: number }
373
- blockUsers: number[]
374
- }
277
+ export type DanmakuPayloadKind = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
375
278
 
376
- /** v3 弹幕发送者 (`ActorV3`) */
279
+ /** Interned speaker (`ActorV3`), referenced by `DanmakuRecordV3.actorId` */
377
280
  export interface ActorV3 {
378
281
  uid: number
379
282
  name: string
380
283
  }
381
284
 
382
- /** v3 直播间表情 (`RoomEmojiV3`) */
285
+ /** Interned room emoji (`RoomEmojiV3`), referenced by `payload.roomEmojiId` */
383
286
  export interface RoomEmojiV3 {
384
287
  name: string
385
288
  resource: string
386
289
  }
387
290
 
388
- /**
389
- * v3 弹幕负载 (`DanmakuPayloadV3`)
390
- *
391
- * 各字段按 {@link DanmakuRecordV3.payloadKind} 的不同而有所取舍,多数字段可缺省。
392
- */
291
+ /** Variant payload of a danmaku record (`DanmakuPayloadV3`); see `DanmakuPayloadKind` */
393
292
  export interface DanmakuPayloadV3 {
394
- rawText?: string
395
- roomEmojiId?: number
396
- name?: string
397
- count?: number
398
- price?: number
399
- mysteryBoxName?: string
400
- mysteryBoxPrice?: number
401
- previousTitle?: string
402
- currentTitle?: string
403
- previousParentArea?: string
404
- previousArea?: string
405
- currentParentArea?: string
406
- currentArea?: string
407
- text?: string
408
- }
409
-
410
- /** v3 弹幕记录 (`DanmakuRecordV3`) */
293
+ /** kind 1: 弹幕正文 */
294
+ rawText: string | null
295
+ /** kind 2: 0-based index into `DanmakuFrameV3.roomEmojis` */
296
+ roomEmojiId: number | null
297
+ /** kind 3/4: 礼物 / 大航海名称 */
298
+ name: string | null
299
+ count: number | null
300
+ /** kind 3/4/5: 金额,单位元(人民币) */
301
+ price: number | null
302
+ mysteryBoxName: string | null
303
+ mysteryBoxPrice: number | null
304
+ previousTitle: string | null
305
+ currentTitle: string | null
306
+ previousParentArea: string | null
307
+ previousArea: string | null
308
+ currentParentArea: string | null
309
+ currentArea: string | null
310
+ /** kind 5: SuperChat 正文 */
311
+ text: string | null
312
+ }
313
+
314
+ /** A single danmaku/event record (`DanmakuRecordV3`) */
411
315
  export interface DanmakuRecordV3 {
316
+ /** 绝对时间戳,unix ms */
412
317
  ts: number
413
- type: DanmakuTypeV3
414
- /** index into `DanmakuFrameV3.actors`, nullable */
415
- actorId?: number
318
+ type: DanmakuProps['type']
319
+ /** 0-based index into `DanmakuFrameV3.actors`; `null` = 系统 / 无主体 */
320
+ actorId: number | null
416
321
  /** 如存在,这条弹幕由用户补充上传,非本站直接采集 */
417
- uploadAccountId?: number
418
- payloadKind: DanmakuPayloadKindV3
322
+ uploadAccountId: number | null
323
+ payloadKind: DanmakuPayloadKind
419
324
  payload: DanmakuPayloadV3
420
325
  }
421
326
 
422
- /** v3 弹幕帧(共享 actor / emoji 池的弹幕集合)(`DanmakuFrameV3`) */
327
+ /** Normalized danmaku frame (`DanmakuFrameV3`) shared by the v3 endpoints */
423
328
  export interface DanmakuFrameV3 {
424
329
  actors: ActorV3[]
425
330
  roomEmojis: RoomEmojiV3[]
@@ -427,302 +332,257 @@ export declare namespace Danmakus {
427
332
  }
428
333
 
429
334
  /**
430
- * 单场直播信息
431
- * @link https://ukamnads.icu/api/v3/lives/{liveId}?include=extra
432
- */
433
- export interface LiveV3Props {
434
- /** 200: success */
435
- code: number
436
- message: string
437
- data: LiveV3Data
438
- }
439
-
440
- /** Data of `LiveV3Props` (`LiveResponseV3`) */
441
- export interface LiveV3Data {
442
- channel: ChannelInfoV3
443
- live: LiveInfoV3
444
- }
445
-
446
- /**
447
- * 单场直播弹幕(分页)
448
- * @link https://ukamnads.icu/api/v3/lives/{liveId}/danmakus?offset=0&limit=2000
335
+ * 单场直播弹幕切片(JSON)
336
+ * @link https://ukamnads.icu/api/v3/lives/{liveId}/danmakus
337
+ *
338
+ * Query: `offset` (default 0), `limit` (default 2000, max 1e7),
339
+ * `userId` (filter by speaker), `type` (repeatable, filter by event type).
449
340
  */
450
- export interface LiveDanmakusV3Props {
451
- /** 200: success */
341
+ export interface LiveDanmakusPageV3 {
452
342
  code: number
453
343
  message: string
454
- data: LiveDanmakusV3Data
455
- }
456
-
457
- /** Data of `LiveDanmakusV3Props` (`LiveDanmakusPageV3`) */
458
- export interface LiveDanmakusV3Data {
459
- total: number
460
- offset: number
461
- limit: number
462
- hasMore: boolean
463
- frame: DanmakuFrameV3
344
+ data: {
345
+ total: number
346
+ offset: number
347
+ limit: number
348
+ hasMore: boolean
349
+ frame: DanmakuFrameV3
350
+ }
464
351
  }
465
352
 
466
353
  /**
467
- * 用户观看/事件历史(分页)
468
- * @link https://ukamnads.icu/api/v3/users/{userId}/history?page=1&pageSize=10
354
+ * 单场直播元数据(JSON,无弹幕)
355
+ * @link https://ukamnads.icu/api/v3/lives/{liveId}
356
+ *
357
+ * Query: `include` (`extra` to populate `live.extra`). This is the
358
+ * authoritative, typed source for live/channel metadata — prefer it over
359
+ * decoding the positional header of the MessagePack endpoints.
469
360
  */
470
- export interface UserHistoryV3Props {
471
- /** 200: success */
361
+ export interface LiveResponseV3 {
472
362
  code: number
473
363
  message: string
474
- data: UserHistoryV3Data
475
- }
476
-
477
- /** Data of `UserHistoryV3Props` (`UserHistoryResponseV3`) */
478
- export interface UserHistoryV3Data {
479
- total: number
480
- page: number
481
- pageSize: number
482
- hasMore: boolean
483
- items: UserHistoryItemV3[]
484
- }
485
-
486
- /** Item of `UserHistoryV3Data` (`UserHistoryItemV3`) */
487
- export interface UserHistoryItemV3 {
488
- channel: ChannelInfoV3
489
- live: LiveInfoV3
490
- danmakus: DanmakuFrameV3
364
+ data: {
365
+ channel: ChannelInfoProps
366
+ live: LiveItem
367
+ }
491
368
  }
492
369
 
493
370
  /**
494
- * 用户首屏聚合数据(历史 + 看过的主播 + 封禁记录)
495
- * @link https://ukamnads.icu/api/v3/users/{userId}/bootstrap?page=1&pageSize=10
371
+ * 用户历史记录(JSON)
372
+ * @link https://ukamnads.icu/api/v3/users/{userId}/history
373
+ *
374
+ * Query: `page` (1-based, default 1), `pageSize` (default 10),
375
+ * `channelUserId` (filter by streamer).
496
376
  */
497
- export interface UserBootstrapV3Props {
498
- /** 200: success */
377
+ export interface UserHistoryResponseV3 {
499
378
  code: number
500
379
  message: string
501
- data: UserBootstrapV3Data
502
- }
503
-
504
- /** Data of `UserBootstrapV3Props` (`UserBootstrapResponseV3`) */
505
- export interface UserBootstrapV3Data {
506
- history: UserHistoryV3Data
507
- watchedChannels: WatchedChannelSummaryV3[]
508
- blocks: UserBlockHistoryItemV3[]
509
- historyUserNames: string[]
510
- }
511
-
512
- /** Item of `UserBootstrapV3Data.watchedChannels` (`WatchedChannelSummaryV3`) */
513
- export interface WatchedChannelSummaryV3 {
514
- uName: string
515
- uId: number
516
- faceUrl: string
517
- count: number
518
- }
519
-
520
- /** Item of `UserBootstrapV3Data.blocks` (`UserBlockHistoryItemV3`) */
521
- export interface UserBlockHistoryItemV3 {
522
- uName: string
523
- uId: number
524
- faceUrl: string
525
- date: number
526
- liveId: string
380
+ data: {
381
+ total: number
382
+ page: number
383
+ pageSize: number
384
+ hasMore: boolean
385
+ items: {
386
+ channel: ChannelInfoProps
387
+ live: LiveItem
388
+ danmakus: DanmakuFrameV3
389
+ }[]
390
+ }
527
391
  }
528
392
 
529
393
  /**
530
- * 内置表情元数据
531
- * @link https://ukamnads.icu/api/v3/meta/emoicons
394
+ * 用户页聚合数据(JSON)
395
+ * @link https://ukamnads.icu/api/v3/users/{userId}/bootstrap
532
396
  */
533
- export interface EmoiconsMetaV3Props {
534
- /** 200: success */
397
+ export interface UserBootstrapResponseV3 {
535
398
  code: number
536
399
  message: string
537
- data: EmoiconsMetaV3Data
538
- }
539
-
540
- /** Data of `EmoiconsMetaV3Props` (`EmoiconsMetaResponseV3`) */
541
- export interface EmoiconsMetaV3Data {
542
- version: number
543
- builtinEmojis: BuiltinEmojiMetaV3[]
544
- }
545
-
546
- /** Item of `EmoiconsMetaV3Data.builtinEmojis` (`BuiltinEmojiMetaV3`) */
547
- export interface BuiltinEmojiMetaV3 {
548
- token: string
549
- url: string
550
- }
551
-
552
- /**
553
- * 创建用户分析任务请求体
554
- * @link https://ukamnads.icu/api/v3/user-analysis-jobs
555
- */
556
- export interface CreateUserAnalyzeJobV3Request {
557
- userId: number
558
- startTime: number
559
- endTime: number
560
- }
561
-
562
- /** Response of `POST /api/v3/user-analysis-jobs` (`CreateUserAnalyzeJobResponse`) */
563
- export interface CreateUserAnalyzeJobV3Response {
564
- jobId: string
400
+ data: {
401
+ history: UserHistoryResponseV3['data']
402
+ watchedChannels: {
403
+ uName: string
404
+ uId: number
405
+ faceUrl: string
406
+ count: number
407
+ }[]
408
+ blocks: {
409
+ uName: string
410
+ uId: number
411
+ faceUrl: string
412
+ date: number
413
+ liveId: string
414
+ }[]
415
+ historyUserNames: string[]
416
+ }
565
417
  }
566
418
 
567
419
  /**
568
- * 用户分析任务状态
569
- * @link https://ukamnads.icu/api/v3/user-analysis-jobs/{jobId}
570
- */
571
- export interface UserAnalyzeJobV3Summary {
572
- jobId: string
573
- status: UserAnalyzeJobStatusV3
574
- latestEvent: UserAnalyzeEventV3
575
- }
576
-
577
- /** Progress event of a user analysis job (`UserAnalyzeEvent`) */
578
- export interface UserAnalyzeEventV3 {
579
- type: UserAnalyzeEventTypeV3
580
- message: string
581
- progress: number
582
- loadedLives: number
583
- totalLives: number
584
- loadedDanmakus: number
585
- }
586
-
587
- /* ----------------------------------------------------------------------------
588
- * v3 msgpack endpoints (`application/x-msgpack`)
420
+ * MessagePack transport for the v3 live endpoints.
589
421
  *
590
- * `/full`, `/delta`, `/result` and `/meta/index-background` respond with
591
- * MessagePack-encoded binary, NOT JSON. The OpenAPI spec only declares them as
592
- * `{ type: string, format: binary }` with no decoded object schema, so the
593
- * tuple types below are reverse-engineered from real responses. Decode the
594
- * binary body (e.g. `@msgpack/msgpack`'s `decode`) before applying them.
422
+ * ## Endpoints (all respond with `application/x-msgpack`)
595
423
  *
596
- * The payload is a **positional tuple** (array), not a keyed object. Verified
597
- * positions are named; positions that can't be resolved by inspection alone
598
- * are marked `inferred`.
599
- * -------------------------------------------------------------------------- */
600
-
601
- /** Channel tuple in `LiveFullV3` — `[uId, uName, roomId]` */
602
- export type ChannelTupleV3 = [uId: number, uName: string, roomId: number]
603
-
604
- /**
605
- * Live tuple in `LiveFullV3`.
424
+ * | Endpoint | Body type | Use |
425
+ * | --------------------------------------- | -------------------- | --- |
426
+ * | `GET /api/v3/lives/{liveId}/full` | {@link Msgpack.LiveSnapshot} | 一次性拉取整场直播 |
427
+ * | `GET /api/v3/lives/{liveId}/delta` | {@link Msgpack.LiveSnapshot} | 轮询进行中的直播增量 |
428
+ * | `GET /api/v3/meta/index-background` | msgpack | 首页背景图列表 |
429
+ * | `GET /api/v3/user-analysis-jobs/{id}/result` | msgpack | 用户分析任务结果 |
606
430
  *
607
- * Note: in the merged `/full` view, counts aggregate every contributed
608
- * version, so they differ from the `/api/v3/lives/{liveId}` JSON view.
609
- */
610
- export type LiveTupleV3 = [
611
- liveId: string,
612
- title: string,
613
- coverUrl: string,
614
- startDate: number,
615
- /** 0 while still ongoing */
616
- stopDate: number,
617
- isFinish: boolean,
618
- isFull: boolean,
619
- isMerged: boolean,
620
- danmakusCount: number,
621
- /** inferred — commentCount */
622
- commentCount: number,
623
- interactionCount: number,
624
- watchCount: number,
625
- /** integer milli-units; divide by 1000 for 元 (e.g. 1200 → 1.2) */
626
- totalIncomeMilli: number,
627
- maxOnlineCount: number,
628
- /** inferred — onlineRank */
629
- onlineRank: number,
630
- area: string,
631
- parentArea: string,
632
- /** extra data when `include=extra`: `[onlineRankHistory, wordCloud]` (maps of `ts → value`, either may be null) */
633
- extra: [
634
- onlineRank: { [ts: number]: number } | null,
635
- wordCloud: { [word: string]: number } | null,
636
- ],
637
- versions: LiveVersionTupleV3[],
638
- /** inferred — total record count */
639
- totalCount: number,
640
- ]
641
-
642
- /** Version tuple in `LiveTupleV3.versions` */
643
- export type LiveVersionTupleV3 = [
644
- liveId: string,
645
- startDate: number,
646
- stopDate: number,
647
- rangeDanmakusCount: number,
648
- userName: string,
649
- /** 0 for the official ("本站") version */
650
- userId: number,
651
- isOfficial: boolean,
652
- isFull: boolean,
653
- danmakusCount: number,
654
- ]
655
-
656
- /** Actor tuple in `DanmakuFrameTupleV3.actors` — `[uid, name]` */
657
- export type ActorTupleV3 = [uid: number, name: string]
658
-
659
- /** Room-emoji tuple in `DanmakuFrameTupleV3.roomEmojis` — `[resource]` */
660
- export type RoomEmojiTupleV3 = [resource: string]
661
-
662
- /**
663
- * Danmaku record tuple in `DanmakuFrameTupleV3.records`.
431
+ * `/full` query: `include=extra` (populate `live[17]`), `includeEnter=true`
432
+ * (include 进场 events, default false).
433
+ * `/delta` query: `afterSeq` (cursor, default 0), `includeEnter`.
664
434
  *
665
- * `payload` shape depends on `payloadKind`:
666
- * - `null` — no payload (e.g. enter / live stop / continue)
667
- * - text kinds → `[text]`
668
- * - 上舰 → `[guardLevel]`
669
- * - 礼物 / SC → `[name, count, price, ...]`
670
- * - 标题/分区变动 → `[current, previous]`
671
- */
672
- export type DanmakuRecordTupleV3 = [
673
- /** ms offset from `startDate` */
674
- ts: number,
675
- type: DanmakuTypeV3,
676
- /** index into `DanmakuFrameTupleV3.actors` */
677
- actorIndex: number,
678
- /** contributor account id; 0 = 本站直接采集 */
679
- uploadAccountId: number,
680
- payloadKind: DanmakuPayloadKindV3,
681
- payload: Array<string | number | null> | null,
682
- ]
683
-
684
- /** Frame tuple in `LiveFullV3` — `[serverTs, actors, roomEmojis, records]` */
685
- export type DanmakuFrameTupleV3 = [
686
- serverTs: number,
687
- actors: ActorTupleV3[],
688
- roomEmojis: RoomEmojiTupleV3[],
689
- records: DanmakuRecordTupleV3[],
690
- ]
691
-
692
- /**
693
- * 单场直播完整数据(msgpack 二进制)
435
+ * ## Fetching & decoding
694
436
  *
695
- * 解码后为 `[channel, live, frame]` 三元组(无 code/message/data 信封)。
696
- * `/delta` 返回相同结构(仅 `records` 为增量)。
697
- * @link https://ukamnads.icu/api/v3/lives/{liveId}/full
698
- * @link https://ukamnads.icu/api/v3/lives/{liveId}/delta
699
- */
700
- export type LiveFullV3 = [
701
- channel: ChannelTupleV3,
702
- live: LiveTupleV3,
703
- frame: DanmakuFrameTupleV3,
704
- ]
705
-
706
- /** Alias of {@link LiveFullV3} for the incremental `/delta` endpoint */
707
- export type LiveDeltaV3 = LiveFullV3
708
-
709
- /** Item tuple in `IndexBackgroundV3` */
710
- export type IndexBackgroundItemTupleV3 = [
711
- /** composite key `liveIdHex:ts:uId:seq` */
712
- key: string,
713
- liveId: string,
714
- uId: number,
715
- title: string,
716
- /** highlighted danmaku message */
717
- message: string,
718
- ts: number,
719
- ]
720
-
721
- /**
722
- * 首页背景轮播条目(msgpack 二进制)
437
+ * ```ts
438
+ * import { decode } from '@msgpack/msgpack'
439
+ *
440
+ * const res = await fetch(
441
+ * `https://ukamnads.icu/api/v3/lives/${liveId}/full`,
442
+ * { headers: { Accept: 'application/x-msgpack' } },
443
+ * )
444
+ * const [channel, live, frame] = decode(
445
+ * new Uint8Array(await res.arrayBuffer()),
446
+ * ) as Danmakus.Msgpack.LiveSnapshot
447
+ * ```
448
+ *
449
+ * Note: the body is a positional **array**, not an object, and `live[17]`
450
+ * (extra) contains integer-keyed maps — pick a decoder that allows non-string
451
+ * map keys (`@msgpack/msgpack` does by default; python `msgpack` needs
452
+ * `strict_map_key=False`).
453
+ *
454
+ * ## Wire-format rules (differ from the JSON transport!)
455
+ *
456
+ * 1. **Records are positional tuples**, see {@link Msgpack.Record}.
457
+ * 2. **Indices are 1-based**; `0` means "none". `actorId`/`roomEmojiId` index
458
+ * into `frame[1]` / `frame[2]` as `table[id - 1]`. (The JSON transport is
459
+ * 0-based and uses `null` for "none".)
460
+ * 3. **Timestamps are delta-encoded.** `frame[0]` is a base unix-ms; each
461
+ * record's `tsDelta` is the gap from the previous record. Reconstruct with
462
+ * a running sum: `absTs = base + Σ tsDelta` up to and including that record.
463
+ * 4. **Prices are integer milli-yuan** (`price / 1000` = 元). The JSON
464
+ * transport already divides (e.g. msgpack `30000` ⇄ JSON `30`).
465
+ * 5. Each `/delta` response is **self-contained**: its records reference that
466
+ * response's own `actors`/`roomEmojis` tables, not a global one.
723
467
  *
724
- * 解码后为单元素数组,包裹条目列表:`[items]`。
725
- * @link https://ukamnads.icu/api/v3/meta/index-background
468
+ * ## Reconstructing records
469
+ *
470
+ * ```ts
471
+ * const [base, actors, emojis, records] = frame
472
+ * let ts = base
473
+ * for (const [dt, type, actorId, , kind, payload] of records) {
474
+ * ts += dt
475
+ * const actor = actorId ? actors[actorId - 1] : null // [uid, name]
476
+ * // kind 1 → [text]; kind 2 → [emojiId]; kind 3 → [name, count, priceMilli, ...]
477
+ * }
478
+ * ```
479
+ *
480
+ * ## Polling `/delta` for a live stream
481
+ *
482
+ * Call with `afterSeq=0` for the full frame so far, then advance the cursor
483
+ * past the records you have already consumed (in practice, the cumulative
484
+ * record count) and poll periodically; each call returns only newer records.
726
485
  */
727
- export type IndexBackgroundV3 = [items: IndexBackgroundItemTupleV3[]]
486
+ export namespace Msgpack {
487
+ /** `[uId, uName, roomId]` */
488
+ export type Channel = [uId: number, uName: string, roomId: number]
489
+
490
+ /** `[uid, name]` — element of `Frame[1]` */
491
+ export type Actor = [uid: number, name: string]
492
+
493
+ /** `[resource]` — element of `Frame[2]` (note: `name` is dropped vs JSON) */
494
+ export type RoomEmoji = [resource: string]
495
+
496
+ /**
497
+ * Variant payload, keyed by the record's `payloadKind`. `price` /
498
+ * `mysteryBoxPrice` are in **milli-yuan** (divide by 1000 for 元).
499
+ */
500
+ export type Payload =
501
+ | null // kind 0 — 控制 / 进场事件
502
+ | [rawText: string] // kind 1 — 纯文本弹幕
503
+ | [roomEmojiId: number] // kind 2 — 房间表情(1-based index)
504
+ | [
505
+ name: string,
506
+ count: number,
507
+ priceMilli: number,
508
+ mysteryBoxName: string | null,
509
+ mysteryBoxPriceMilli: number | null,
510
+ ] // kind 3 — 礼物
511
+ | [name: string, count: number, priceMilli: number] // kind 4 — 上舰
512
+ | [text: string, priceMilli: number] // kind 5 — SuperChat
513
+
514
+ /** `[tsDelta, type, actorId, uploadAccountId, payloadKind, payload]` */
515
+ export type Record = [
516
+ /** 距上一条记录的毫秒增量;绝对值 = `Frame[0]` + 累加和 */
517
+ tsDelta: number,
518
+ type: DanmakuProps['type'],
519
+ /** 1-based index into `Frame[1]`; `0` = 系统 / 无主体 */
520
+ actorId: number,
521
+ /** 1-based account id of an uploader; `0` = 本站采集 */
522
+ uploadAccountId: number,
523
+ payloadKind: DanmakuPayloadKind,
524
+ payload: Payload,
525
+ ]
526
+
527
+ /** `[baseTs, actors, roomEmojis, records]` */
528
+ export type Frame = [
529
+ /** 基准时间戳,unix ms */
530
+ baseTs: number,
531
+ actors: Actor[],
532
+ roomEmojis: RoomEmoji[],
533
+ records: Record[],
534
+ ]
535
+
536
+ /**
537
+ * Contributed recording (`APILiveVersionInfo`), flattened.
538
+ * `[liveId, startDate, stopDate, danmakusCount, contributorName,
539
+ * contributorId, isOfficial, isFull, rangeDanmakusCount]`
540
+ */
541
+ export type LiveVersion = [
542
+ liveId: string,
543
+ startDate: number,
544
+ stopDate: number,
545
+ danmakusCount: number,
546
+ contributorName: string,
547
+ contributorId: number,
548
+ isOfficial: boolean,
549
+ isFull: boolean,
550
+ rangeDanmakusCount: number,
551
+ ]
552
+
553
+ /**
554
+ * Positional projection of the live's metadata. For authoritative typed
555
+ * metadata prefer the JSON `GET /api/v3/lives/{liveId}` ({@link LiveResponseV3}).
556
+ */
557
+ export type Live = [
558
+ liveId: string,
559
+ title: string,
560
+ coverUrl: string,
561
+ startDate: number,
562
+ stopDate: number,
563
+ isFinish: boolean,
564
+ isFull: boolean,
565
+ isMerged: boolean,
566
+ /** 帧内事件总数(含礼物/SC/控制事件,≥ `danmakusCount`) */
567
+ eventCount: number,
568
+ /** [9] 观看人数(看过)— 推断字段 */
569
+ viewCount: number,
570
+ interactionCount: number,
571
+ watchCount: number,
572
+ /** 收益,单位 milli-yuan(/1000 = 元) */
573
+ totalIncomeMilli: number,
574
+ maxOnlineCount: number,
575
+ commentCount: number,
576
+ area: string,
577
+ parentArea: string,
578
+ /** 仅当 `include=extra` 时存在,否则为 `null`(在线人数曲线等) */
579
+ extra: unknown | null,
580
+ versions: LiveVersion[],
581
+ /** [19] 与 `viewCount` 重复 — 推断字段 */
582
+ viewCountDup: number,
583
+ ]
584
+
585
+ /** msgpack body of `/api/v3/lives/{liveId}/full` and `/delta`: `[channel, live, frame]` */
586
+ export type LiveSnapshot = [channel: Channel, live: Live, frame: Frame]
587
+ }
728
588
  }