@laplace.live/internal 1.3.21 → 1.3.23

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.23",
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,97 @@ 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 `payloadArgs` (see `Msgpack`).
268
+ *
269
+ * - 0 `None`: 无负载(控制 / 进场事件)
270
+ * - 1 `TextMessage`: 纯文本弹幕 → `rawText`
271
+ * - 2 `RoomEmojiMessage`: 房间表情 → `roomEmojiId`
272
+ * - 3 `Gift`: 礼物 → `name`, `count`, `price`, `mysteryBoxName`, `mysteryBoxPrice`
273
+ * - 4 `Guard`: 上舰 → `name`, `count`, `price`
274
+ * - 5 `SuperChat`: → `text`, `price`
275
+ * - 6 `TitleChange`: 标题变动 → `previousTitle`, `currentTitle`
276
+ * - 7 `AreaChange`: 分区变动 → `previous(Parent)Area`, `current(Parent)Area`
277
+ * - 8 `Warning`: 超管警告 → `text`
278
+ * - 9 `RecordStart`: 录制开始 → `text`
279
+ * - 10 `RecordInterrupt`: 录制中断 → `text`
283
280
  */
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
281
+ export type DanmakuPayloadKind = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
288
282
 
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
- }
375
-
376
- /** v3 弹幕发送者 (`ActorV3`) */
283
+ /** Interned speaker (`ActorV3`), referenced by `DanmakuRecordV3.actorId` */
377
284
  export interface ActorV3 {
378
285
  uid: number
379
286
  name: string
380
287
  }
381
288
 
382
- /** v3 直播间表情 (`RoomEmojiV3`) */
289
+ /** Interned room emoji (`RoomEmojiV3`), referenced by `payload.roomEmojiId` */
383
290
  export interface RoomEmojiV3 {
384
291
  name: string
385
292
  resource: string
386
293
  }
387
294
 
388
- /**
389
- * v3 弹幕负载 (`DanmakuPayloadV3`)
390
- *
391
- * 各字段按 {@link DanmakuRecordV3.payloadKind} 的不同而有所取舍,多数字段可缺省。
392
- */
295
+ /** Variant payload of a danmaku record (`DanmakuPayloadV3`); see `DanmakuPayloadKind` */
393
296
  export interface DanmakuPayloadV3 {
297
+ /** kind 1: 弹幕正文 */
394
298
  rawText?: string
299
+ /** kind 2: 0-based index into `DanmakuFrameV3.roomEmojis` */
395
300
  roomEmojiId?: number
301
+ /** kind 3/4: 礼物 / 大航海名称 */
396
302
  name?: string
397
303
  count?: number
304
+ /** kind 3/4/5: 金额,单位元(人民币) */
398
305
  price?: number
399
306
  mysteryBoxName?: string
400
307
  mysteryBoxPrice?: number
308
+ /** kind 6 */
401
309
  previousTitle?: string
310
+ /** kind 6 */
402
311
  currentTitle?: string
312
+ /** kind 7 */
403
313
  previousParentArea?: string
404
314
  previousArea?: string
405
315
  currentParentArea?: string
406
316
  currentArea?: string
317
+ /** kind 5: SuperChat 正文;kind 8/9/10: 提示文本 */
407
318
  text?: string
408
319
  }
409
320
 
410
- /** v3 弹幕记录 (`DanmakuRecordV3`) */
321
+ /**
322
+ * A single danmaku/event record (`DanmakuRecordV3`).
323
+ *
324
+ * Note (vs the MessagePack transport): here `ts` is absolute and `actorId`
325
+ * is a **0-based** index into `DanmakuFrameV3.actors` with `undefined` = 系统;
326
+ * the msgpack wire is 1-based with `0` = 系统. See {@link Msgpack}.
327
+ */
411
328
  export interface DanmakuRecordV3 {
329
+ /** 绝对时间戳,unix ms */
412
330
  ts: number
413
- type: DanmakuTypeV3
414
- /** index into `DanmakuFrameV3.actors`, nullable */
331
+ type: DanmakuProps['type']
332
+ /** 0-based index into `DanmakuFrameV3.actors`; `undefined` = 系统 / 无主体 */
415
333
  actorId?: number
416
334
  /** 如存在,这条弹幕由用户补充上传,非本站直接采集 */
417
335
  uploadAccountId?: number
418
- payloadKind: DanmakuPayloadKindV3
419
- payload: DanmakuPayloadV3
336
+ payloadKind: DanmakuPayloadKind
337
+ payload?: DanmakuPayloadV3 | null
420
338
  }
421
339
 
422
- /** v3 弹幕帧(共享 actor / emoji 池的弹幕集合)(`DanmakuFrameV3`) */
340
+ /** Normalized danmaku frame (`DanmakuFrameV3`) shared by the v3 endpoints */
423
341
  export interface DanmakuFrameV3 {
424
342
  actors: ActorV3[]
425
343
  roomEmojis: RoomEmojiV3[]
@@ -427,156 +345,340 @@ export declare namespace Danmakus {
427
345
  }
428
346
 
429
347
  /**
430
- * 单场直播信息
431
- * @link https://ukamnads.icu/api/v3/lives/{liveId}?include=extra
348
+ * 单场直播弹幕切片(JSON)
349
+ * @link https://ukamnads.icu/api/v3/lives/{liveId}/danmakus
350
+ *
351
+ * Query: `offset` (default 0), `limit` (default 2000, max 1e7),
352
+ * `userId` (filter by speaker), `type` (repeatable, filter by event type).
432
353
  */
433
- export interface LiveV3Props {
434
- /** 200: success */
354
+ export interface LiveDanmakusPageV3 {
435
355
  code: number
436
356
  message: string
437
- data: LiveV3Data
438
- }
439
-
440
- /** Data of `LiveV3Props` (`LiveResponseV3`) */
441
- export interface LiveV3Data {
442
- channel: ChannelInfoV3
443
- live: LiveInfoV3
357
+ data: {
358
+ total: number
359
+ offset: number
360
+ limit: number
361
+ hasMore: boolean
362
+ frame: DanmakuFrameV3
363
+ }
444
364
  }
445
365
 
446
366
  /**
447
- * 单场直播弹幕(分页)
448
- * @link https://ukamnads.icu/api/v3/lives/{liveId}/danmakus?offset=0&limit=2000
367
+ * 单场直播元数据(JSON,无弹幕)
368
+ * @link https://ukamnads.icu/api/v3/lives/{liveId}
369
+ *
370
+ * Query: `include` (`extra` to populate `live.extra`). This is the
371
+ * authoritative, typed source for live/channel metadata — prefer it over
372
+ * decoding the positional header of the MessagePack endpoints.
449
373
  */
450
- export interface LiveDanmakusV3Props {
451
- /** 200: success */
374
+ export interface LiveResponseV3 {
452
375
  code: number
453
376
  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
377
+ data: {
378
+ channel: ChannelInfoProps
379
+ live: LiveItem
380
+ }
464
381
  }
465
382
 
466
383
  /**
467
- * 用户观看/事件历史(分页)
468
- * @link https://ukamnads.icu/api/v3/users/{userId}/history?page=1&pageSize=10
384
+ * 用户历史记录(JSON)
385
+ * @link https://ukamnads.icu/api/v3/users/{userId}/history
386
+ *
387
+ * Query: `page` (1-based, default 1), `pageSize` (default 10),
388
+ * `channelUserId` (filter by streamer).
469
389
  */
470
- export interface UserHistoryV3Props {
471
- /** 200: success */
390
+ export interface UserHistoryResponseV3 {
472
391
  code: number
473
392
  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
393
+ data: {
394
+ total: number
395
+ page: number
396
+ pageSize: number
397
+ hasMore: boolean
398
+ items: {
399
+ channel: ChannelInfoProps
400
+ live: LiveItem
401
+ danmakus: DanmakuFrameV3
402
+ }[]
403
+ }
491
404
  }
492
405
 
493
406
  /**
494
- * 用户首屏聚合数据(历史 + 看过的主播 + 封禁记录)
495
- * @link https://ukamnads.icu/api/v3/users/{userId}/bootstrap?page=1&pageSize=10
407
+ * 用户页聚合数据(JSON)
408
+ * @link https://ukamnads.icu/api/v3/users/{userId}/bootstrap
496
409
  */
497
- export interface UserBootstrapV3Props {
498
- /** 200: success */
410
+ export interface UserBootstrapResponseV3 {
499
411
  code: number
500
412
  message: string
501
- data: UserBootstrapV3Data
413
+ data: {
414
+ history: UserHistoryResponseV3['data']
415
+ watchedChannels: {
416
+ uName: string
417
+ uId: number
418
+ faceUrl: string
419
+ count: number
420
+ }[]
421
+ blocks: {
422
+ uName: string
423
+ uId: number
424
+ faceUrl: string
425
+ date: number
426
+ liveId: string
427
+ }[]
428
+ historyUserNames: string[]
429
+ }
502
430
  }
503
431
 
504
- /** Data of `UserBootstrapV3Props` (`UserBootstrapResponseV3`) */
505
- export interface UserBootstrapV3Data {
506
- history: UserHistoryV3Data
507
- watchedChannels: WatchedChannelSummaryV3[]
508
- blocks: UserBlockHistoryItemV3[]
509
- historyUserNames: string[]
510
- }
432
+ /**
433
+ * MessagePack transport for the v3 endpoints.
434
+ *
435
+ * The wire layout is **not fully described by swagger** (msgpack bodies show
436
+ * up as opaque schemas there). The authoritative definitions are the official
437
+ * web client's models, which this namespace mirrors 1:1:
438
+ * - `DanmakuVue/src/api/DanmakuMessagePackModels.ts` (the `*Wire` tuples)
439
+ * - `DanmakuVue/src/api/DanmakuMessagePackDecoder.ts` (decode semantics)
440
+ * - `DanmakuVue/src/api/IndexBackgroundModels.ts`
441
+ *
442
+ * ## Endpoints (all respond with `application/x-msgpack`)
443
+ *
444
+ * | Endpoint | Decoded as | Encoding |
445
+ * | -------------------------------------------- | ---------- | -------- |
446
+ * | `GET /api/v3/lives/{liveId}/full` | {@link Msgpack.LiveFullEnvelopeWire} | positional |
447
+ * | `GET /api/v3/lives/{liveId}/delta` | {@link Msgpack.LiveDeltaEnvelopeWire} | positional |
448
+ * | `GET /api/v3/meta/index-background` | {@link Msgpack.IndexBackgroundDanmakuEnvelopeWire} | positional |
449
+ * | `GET /api/v3/user-analysis-jobs/{id}/result` | {@link UserAnalyzeResult} | keyed map |
450
+ *
451
+ * The live & index-background bodies are **positional arrays** (field order =
452
+ * the tuple order below); the user-analysis result is an ordinary **keyed
453
+ * map** that decodes straight to its object shape.
454
+ *
455
+ * `/full` query: `include=extra` (populate `live[17]`), `includeEnter=true`
456
+ * (include 进场 events, default false).
457
+ * `/delta` query: `afterSeq` (cursor, default 0), `includeEnter`.
458
+ *
459
+ * ## Fetching & decoding
460
+ *
461
+ * ```ts
462
+ * import { decode } from '@msgpack/msgpack'
463
+ *
464
+ * const res = await fetch(
465
+ * `https://ukamnads.icu/api/v3/lives/${liveId}/full`,
466
+ * { headers: { Accept: 'application/x-msgpack' } },
467
+ * )
468
+ * const [channel, live, frame] = decode(
469
+ * new Uint8Array(await res.arrayBuffer()),
470
+ * ) as Danmakus.Msgpack.LiveFullEnvelopeWire
471
+ * ```
472
+ *
473
+ * Note: the body is a positional **array**, not an object, and `extra[0]`
474
+ * (`onlineRank`) is an integer-keyed map (keyed by unix-ms) — use a decoder
475
+ * that allows non-string map keys (`@msgpack/msgpack` with `{ useMap: true }`,
476
+ * or python `msgpack` with `strict_map_key=False`).
477
+ *
478
+ * ## Wire-format rules (differ from the JSON transport!)
479
+ *
480
+ * 1. **Records are positional tuples**, see {@link Msgpack.LiveFullRecordWire}.
481
+ * 2. **Indices are 1-based**; `0`/`<=0` means "none". `actorId`/`roomEmojiId`
482
+ * resolve as `table[id - 1]`. (The JSON transport is 0-based and uses
483
+ * `undefined` for "none".)
484
+ * 3. **Timestamps are delta-encoded.** `frame[0]` (`baseTs`) is a base
485
+ * unix-ms; each record's `dt` is the gap from the previous record.
486
+ * Reconstruct with a running sum: `absTs = baseTs + Σ dt` up to and
487
+ * including that record.
488
+ * 4. **Prices are integer milli-yuan** (value `/ 1000` = 元) — both
489
+ * `live.totalIncomeMilli` and the price slots in `payloadArgs`. The JSON
490
+ * transport already divides (e.g. msgpack `30000` ⇄ JSON `30`).
491
+ * 5. `stopDate <= 0` means the live is ongoing (decode to `null`).
492
+ * 6. Each `/delta` response is **self-contained**: its records reference that
493
+ * response's own `actors`/`roomEmojis` tables, not a global one.
494
+ *
495
+ * ## Reconstructing records
496
+ *
497
+ * ```ts
498
+ * const [baseTs, actors, emojis, records] = frame
499
+ * let ts = baseTs
500
+ * for (const [dt, type, actorId, , kind, args] of records) {
501
+ * ts += dt
502
+ * const actor = actorId > 0 ? actors[actorId - 1] : undefined // [uid, name]
503
+ * // kind 1 → [text]; kind 2 → [emojiId]; kind 3 → [name, count, priceMilli, ...]
504
+ * }
505
+ * ```
506
+ *
507
+ * ## Polling `/delta` for a live stream
508
+ *
509
+ * Call with `afterSeq=0` for the full frame so far, then on each poll pass the
510
+ * previous response's `live.latestSeq` (`live[19]`) as the next `afterSeq`;
511
+ * each call returns only records newer than that sequence.
512
+ */
513
+ export namespace Msgpack {
514
+ /** `[uid, name, roomId]` */
515
+ export type LiveFullChannelWire = [uid: number, name: string, roomId: number]
511
516
 
512
- /** Item of `UserBootstrapV3Data.watchedChannels` (`WatchedChannelSummaryV3`) */
513
- export interface WatchedChannelSummaryV3 {
514
- uName: string
515
- uId: number
516
- faceUrl: string
517
- count: number
518
- }
517
+ /** `[uid, name]` — element of `LiveFullFrameWire[1]` */
518
+ export type LiveFullActorWire = [uid: number, name: string]
519
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
527
- }
520
+ /** `[resource]` — element of `LiveFullFrameWire[2]` (`name` dropped vs JSON) */
521
+ export type LiveFullRoomEmojiWire = [resource: string]
528
522
 
529
- /**
530
- * 内置表情元数据
531
- * @link https://ukamnads.icu/api/v3/meta/emoicons
532
- */
533
- export interface EmoiconsMetaV3Props {
534
- /** 200: success */
535
- code: number
536
- message: string
537
- data: EmoiconsMetaV3Data
538
- }
523
+ /**
524
+ * `[onlineRank, wordCloud]` — present only when `/full?include=extra`,
525
+ * otherwise `null`; either slot may itself be `null`.
526
+ */
527
+ export type LiveFullExtraWire = [
528
+ /** unix-ms → 在线人数 */
529
+ onlineRank?: Record<string, number> | null,
530
+ /** 词 → 次数 */
531
+ wordCloud?: Record<string, number> | null,
532
+ ]
539
533
 
540
- /** Data of `EmoiconsMetaV3Props` (`EmoiconsMetaResponseV3`) */
541
- export interface EmoiconsMetaV3Data {
542
- version: number
543
- builtinEmojis: BuiltinEmojiMetaV3[]
544
- }
534
+ /**
535
+ * `LiveFullRecordWire[5]` (`payloadArgs`) — variant tuple selected by
536
+ * `payloadKind`. The source types this loosely as `unknown[] | null`; the
537
+ * union below is the exact per-kind layout used by the decoder. `price*`
538
+ * slots are **milli-yuan**; `roomEmojiId` is a 1-based index.
539
+ */
540
+ export type PayloadArgs =
541
+ | [rawText: string] // kind 1 — 纯文本弹幕
542
+ | [roomEmojiId: number] // kind 2 — 房间表情
543
+ | [
544
+ name: string,
545
+ count: number,
546
+ priceMilli: number,
547
+ mysteryBoxName: string | null,
548
+ mysteryBoxPriceMilli: number | null,
549
+ ] // kind 3 — 礼物
550
+ | [name: string, count: number, priceMilli: number] // kind 4 — 上舰
551
+ | [text: string, priceMilli: number] // kind 5 — SuperChat
552
+ | [previousTitle: string, currentTitle: string] // kind 6 — 标题变动
553
+ | [previousParentArea: string, previousArea: string, currentParentArea: string, currentArea: string] // kind 7 — 分区变动
554
+ | [text: string] // kind 8/9/10 — 警告 / 录制开始 / 录制中断
555
+
556
+ /** `[dt, type, actorId, uploadAccountId, payloadKind, payloadArgs?]` */
557
+ export type LiveFullRecordWire = [
558
+ /** 距上一条记录的毫秒增量;绝对值 = `LiveFullFrameWire[0]` + 累加和 */
559
+ dt: number,
560
+ type: DanmakuProps['type'],
561
+ /** 1-based index into `LiveFullFrameWire[1]`; `<=0` = 系统 / 无主体 */
562
+ actorId: number,
563
+ /** 1-based account id of an uploader; `<=0` = 本站采集 */
564
+ uploadAccountId: number,
565
+ payloadKind: DanmakuPayloadKind,
566
+ payloadArgs?: PayloadArgs | null,
567
+ ]
568
+
569
+ /** `[baseTs, actors, roomEmojis, records]` */
570
+ export type LiveFullFrameWire = [
571
+ /** 基准时间戳,unix ms */
572
+ baseTs: number,
573
+ actors: LiveFullActorWire[],
574
+ roomEmojis: LiveFullRoomEmojiWire[],
575
+ records: LiveFullRecordWire[],
576
+ ]
577
+
578
+ /**
579
+ * A contributed recording, flattened.
580
+ * `[liveId, startDate, stopDate, danmakusCount, userName, userId,
581
+ * isOfficial, isFull, rangeDanmakusCount]`
582
+ */
583
+ export type LiveFullVersionWire = [
584
+ liveId: string,
585
+ startDate: number,
586
+ stopDate: number,
587
+ danmakusCount: number,
588
+ userName: string,
589
+ userId: number,
590
+ isOfficial: boolean,
591
+ isFull: boolean,
592
+ rangeDanmakusCount: number,
593
+ ]
545
594
 
546
- /** Item of `EmoiconsMetaV3Data.builtinEmojis` (`BuiltinEmojiMetaV3`) */
547
- export interface BuiltinEmojiMetaV3 {
548
- token: string
549
- url: string
595
+ /**
596
+ * Positional projection of the live's metadata. For the full typed metadata
597
+ * prefer JSON `GET /api/v3/lives/{liveId}` ({@link LiveResponseV3}); this
598
+ * drops `likeCount`/`payCount`/`onlineRank` and adds
599
+ * `totalDanmakusCount`/`latestSeq`.
600
+ */
601
+ export type LiveFullLiveWire = [
602
+ liveId: string,
603
+ title: string,
604
+ coverUrl: string,
605
+ startDate: number,
606
+ stopDate: number,
607
+ isFinish: boolean,
608
+ isFull: boolean,
609
+ isMerged: boolean,
610
+ /** 本帧弹幕数 */
611
+ danmakusCount: number,
612
+ /** 所有版本合并后的弹幕总数 */
613
+ totalDanmakusCount: number,
614
+ interactionCount: number,
615
+ watchCount: number,
616
+ /** 收益,单位 milli-yuan(/1000 = 元) */
617
+ totalIncomeMilli: number,
618
+ maxOnlineCount: number,
619
+ commentCount: number,
620
+ area?: string | null,
621
+ parentArea?: string | null,
622
+ /** 仅当 `include=extra` 时存在 */
623
+ extra?: LiveFullExtraWire | null,
624
+ versions?: LiveFullVersionWire[] | null,
625
+ /** 最新序号;轮询 `/delta` 时作为下一次的 `afterSeq` */
626
+ latestSeq?: number,
627
+ ]
628
+
629
+ /** msgpack body of `/api/v3/lives/{liveId}/full`: `[channel, live, frame]` */
630
+ export type LiveFullEnvelopeWire = [channel: LiveFullChannelWire, live: LiveFullLiveWire, frame: LiveFullFrameWire]
631
+
632
+ /** msgpack body of `/api/v3/lives/{liveId}/delta` — identical shape to {@link LiveFullEnvelopeWire} */
633
+ export type LiveDeltaEnvelopeWire = LiveFullEnvelopeWire
634
+
635
+ /** `[id, liveId, uId, liveTitle, message, sendDate]` */
636
+ export type IndexBackgroundDanmakuCardWire = [
637
+ id: string,
638
+ liveId: string,
639
+ uId: number,
640
+ liveTitle: string,
641
+ message: string,
642
+ sendDate: number,
643
+ ]
644
+
645
+ /** msgpack body of `/api/v3/meta/index-background`: `[cards]` */
646
+ export type IndexBackgroundDanmakuEnvelopeWire = [cards: IndexBackgroundDanmakuCardWire[]]
550
647
  }
551
648
 
552
649
  /**
553
- * 创建用户分析任务请求体
554
- * @link https://ukamnads.icu/api/v3/user-analysis-jobs
650
+ * 创建用户分析任务请求体(JSON)
651
+ * @link https://ukamnads.icu/api/v3/user-analysis-jobs (POST,需鉴权)
555
652
  */
556
- export interface CreateUserAnalyzeJobV3Request {
653
+ export interface CreateUserAnalyzeJobRequest {
557
654
  userId: number
558
- startTime: number
559
- endTime: number
655
+ startTime?: number
656
+ endTime?: number
560
657
  }
561
658
 
562
- /** Response of `POST /api/v3/user-analysis-jobs` (`CreateUserAnalyzeJobResponse`) */
563
- export interface CreateUserAnalyzeJobV3Response {
659
+ /** Response of `POST /api/v3/user-analysis-jobs` */
660
+ export interface CreateUserAnalyzeJobResponse {
564
661
  jobId: string
565
662
  }
566
663
 
664
+ /** 用户分析任务事件类型(SSE event name / `UserAnalyzeEvent.type`) */
665
+ export type UserAnalyzeEventType =
666
+ | 'created'
667
+ | 'queued'
668
+ | 'indexing'
669
+ | 'loading'
670
+ | 'aggregating'
671
+ | 'completed'
672
+ | 'failed'
673
+ | 'canceled'
674
+
567
675
  /**
568
- * 用户分析任务状态
569
- * @link https://ukamnads.icu/api/v3/user-analysis-jobs/{jobId}
676
+ * 进度事件。通过 SSE 推送:
677
+ * @link https://ukamnads.icu/api/v3/user-analysis-jobs/{jobId}/events
678
+ * 也可轮询 `GET /api/v3/user-analysis-jobs/{jobId}` 获取最新状态。
570
679
  */
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
680
+ export interface UserAnalyzeEvent {
681
+ type: UserAnalyzeEventType
580
682
  message: string
581
683
  progress: number
582
684
  loadedLives: number
@@ -584,145 +686,41 @@ export declare namespace Danmakus {
584
686
  loadedDanmakus: number
585
687
  }
586
688
 
587
- /* ----------------------------------------------------------------------------
588
- * v3 msgpack endpoints (`application/x-msgpack`)
589
- *
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.
595
- *
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`.
606
- *
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]
689
+ /** `UserAnalyzeSummary` */
690
+ export interface UserAnalyzeSummary {
691
+ totalMessages: number
692
+ /** 元 */
693
+ totalPayment: number
694
+ blockCount: number
695
+ activeDays: number
696
+ }
661
697
 
662
- /**
663
- * Danmaku record tuple in `DanmakuFrameTupleV3.records`.
664
- *
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
- ]
698
+ /** Item of `UserAnalyzeChannelResult.lives` */
699
+ export interface UserAnalyzeLiveResult {
700
+ live: LiveItem
701
+ danmakus: DanmakuProps[]
702
+ }
691
703
 
692
- /**
693
- * 单场直播完整数据(msgpack 二进制)
694
- *
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
- ]
704
+ /** Item of `UserAnalyzeResult.channels` */
705
+ export interface UserAnalyzeChannelResult {
706
+ channel: ChannelInfo
707
+ lives: UserAnalyzeLiveResult[]
708
+ }
720
709
 
721
710
  /**
722
- * 首页背景轮播条目(msgpack 二进制)
711
+ * 用户分析结果(msgpack,keyed map — 直接 decode 成对象)
712
+ * @link https://ukamnads.icu/api/v3/user-analysis-jobs/{jobId}/result
723
713
  *
724
- * 解码后为单元素数组,包裹条目列表:`[items]`。
725
- * @link https://ukamnads.icu/api/v3/meta/index-background
714
+ * Fetch with `Accept: application/x-msgpack` and decode; unlike the live
715
+ * endpoints this body is an ordinary keyed map, not a positional tuple.
726
716
  */
727
- export type IndexBackgroundV3 = [items: IndexBackgroundItemTupleV3[]]
717
+ export interface UserAnalyzeResult {
718
+ userId: number
719
+ startTime: number
720
+ endTime: number
721
+ nameHistory: string[]
722
+ wordCloud: Record<string, number>
723
+ summary: UserAnalyzeSummary
724
+ channels: UserAnalyzeChannelResult[]
725
+ }
728
726
  }