@dan-uni/dan-any 0.2.6 → 0.4.8

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/src/index.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { XMLParser } from 'fast-xml-parser'
1
+ import { XMLBuilder, XMLParser } from 'fast-xml-parser'
2
2
  import type { Options as AssGenOptions } from './ass-gen'
3
3
  import type { CommandDm as DM_JSON_BiliCommandGrpc } from './proto/gen/bili/dm_pb'
4
- // import type * as UniDMType from './utils/dm-gen'
5
- import type { platfrom } from './utils/id-gen'
6
4
 
7
5
  import { create, fromBinary, toBinary } from '@bufbuild/protobuf'
8
6
  import {
@@ -22,7 +20,9 @@ import { DanmakuReplySchema } from './proto/gen/danuni_pb'
22
20
 
23
21
  import { UniDM } from './utils/dm-gen'
24
22
  import * as UniDMTools from './utils/dm-gen'
23
+ import { UniID as ID } from './utils/id-gen'
25
24
  import * as UniIDTools from './utils/id-gen'
25
+ import * as platform from './utils/platform'
26
26
 
27
27
  export interface DM_XML_Bili {
28
28
  i: {
@@ -48,11 +48,11 @@ export interface DM_JSON_Dplayer {
48
48
  }
49
49
  export interface DM_JSON_Artplayer {
50
50
  text: string // 弹幕文本
51
- time?: number // 弹幕时间, 默认为当前播放器时间
52
- mode?: number // 弹幕模式: 0: 滚动(默认),1: 顶部,2: 底部
51
+ time?: number // 弹幕时间,默认为当前播放器时间
52
+ mode?: number // 弹幕模式:0: 滚动 (默认),1: 顶部,2: 底部
53
53
  color?: string // 弹幕颜色,默认为白色
54
- border?: boolean // 弹幕是否有描边, 默认为 false
55
- style?: {} // 弹幕自定义样式, 默认为空对象
54
+ border?: boolean // 弹幕是否有描边,默认为 false
55
+ style?: {} // 弹幕自定义样式,默认为空对象
56
56
  }
57
57
  export interface DM_JSON_DDPlay {
58
58
  count: number | string
@@ -78,22 +78,143 @@ export type DM_format =
78
78
  type shareItems = Partial<
79
79
  Pick<
80
80
  UniDMTools.UniDMObj,
81
- 'FCID' | 'senderID' | 'platform' | 'SPMO' | 'pool' | 'mode'
81
+ 'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'
82
82
  >
83
83
  >
84
84
 
85
+ type UniPoolPipe = (that: UniPool) => Promise<UniPool>
86
+ type UniPoolPipeSync = (that: UniPool) => UniPool
87
+
88
+ interface Options {
89
+ dedupe?: boolean
90
+ }
91
+
85
92
  export class UniPool {
86
- readonly shared: shareItems = {}
87
- constructor(public dans: UniDM[]) {
88
- function isShared(key: keyof UniDMTools.UniDMObj) {
89
- return new Set(dans.map((d) => d[key])).size === 1
93
+ constructor(
94
+ public dans: UniDM[],
95
+ public options: Options = {},
96
+ ) {
97
+ if (options.dedupe !== false) options.dedupe = true
98
+ if (this.options.dedupe) this.dedupe()
99
+ }
100
+ async pipe(fn: UniPoolPipe): Promise<UniPool> {
101
+ return fn(this)
102
+ }
103
+ pipeSync(fn: UniPoolPipeSync): UniPool {
104
+ return fn(this)
105
+ }
106
+ get shared(): shareItems {
107
+ const isShared = (key: keyof UniDMTools.UniDMObj) => {
108
+ return this.dans.every((d) => d[key])
109
+ }
110
+ return {
111
+ SOID: isShared('SOID') ? this.dans[0].SOID : undefined,
112
+ senderID: isShared('senderID') ? this.dans[0].senderID : undefined,
113
+ platform: isShared('platform') ? this.dans[0].platform : undefined,
114
+ pool: isShared('pool') ? this.dans[0].pool : undefined,
115
+ mode: isShared('mode') ? this.dans[0].mode : undefined,
116
+ color: isShared('color') ? this.dans[0].color : undefined,
117
+ }
118
+ }
119
+ get stat() {
120
+ const default_stat = {
121
+ SOID: [] as { val: string; count: number }[],
122
+ mode: [
123
+ { val: UniDMTools.Modes.Normal, count: 0 },
124
+ { val: UniDMTools.Modes.Bottom, count: 0 },
125
+ { val: UniDMTools.Modes.Top, count: 0 },
126
+ { val: UniDMTools.Modes.Reverse, count: 0 },
127
+ { val: UniDMTools.Modes.Ext, count: 0 },
128
+ ],
129
+ fontsize: [
130
+ // { val: 18, count: 0 },
131
+ // { val: 25, count: 0 },
132
+ // { val: 36, count: 0 },
133
+ ] as { val: number; count: number }[],
134
+ color: [] as { val: number; count: number }[],
135
+ senderID: [] as { val: string; count: number }[],
136
+ content: [] as { val: string; count: number }[],
137
+ weight: [] as { val: number; count: number }[],
138
+ pool: [
139
+ { val: UniDMTools.Pools.Def, count: 0 },
140
+ { val: UniDMTools.Pools.Sub, count: 0 },
141
+ { val: UniDMTools.Pools.Adv, count: 0 },
142
+ { val: UniDMTools.Pools.Ix, count: 0 },
143
+ ],
144
+ platform: [] as { val?: string; count: number }[],
145
+ }
146
+ type Stat = typeof default_stat
147
+ const stat = this.dans.reduce((s, d): Stat => {
148
+ const SOID = s.SOID.find((i) => i.val === d.SOID)
149
+ if (!SOID) {
150
+ s.SOID.push({ val: d.SOID, count: 1 })
151
+ } else {
152
+ SOID.count++
153
+ }
154
+ const mode = s.mode.find((i) => i.val === d.mode)
155
+ if (!mode) {
156
+ s.mode.push({ val: d.mode, count: 1 })
157
+ } else {
158
+ mode.count++
159
+ }
160
+ const fontsize = s.fontsize.find((i) => i.val === d.fontsize)
161
+ if (!fontsize) {
162
+ s.fontsize.push({ val: d.fontsize, count: 1 })
163
+ } else {
164
+ fontsize.count++
165
+ }
166
+ const color = s.color.find((i) => i.val === d.color)
167
+ if (!color) {
168
+ s.color.push({ val: d.color, count: 1 })
169
+ } else {
170
+ color.count++
171
+ }
172
+ const senderID = s.senderID.find((i) => i.val === d.senderID)
173
+ if (!senderID) {
174
+ s.senderID.push({ val: d.senderID, count: 1 })
175
+ } else {
176
+ senderID.count++
177
+ }
178
+ const content = s.content.find((i) => i.val === d.content)
179
+ if (!content) {
180
+ s.content.push({ val: d.content, count: 1 })
181
+ } else {
182
+ content.count++
183
+ }
184
+ const weight = s.weight.find((i) => i.val === d.weight)
185
+ if (!weight) {
186
+ s.weight.push({ val: d.weight, count: 1 })
187
+ } else {
188
+ weight.count++
189
+ }
190
+ const pool = s.pool.find((i) => i.val === d.pool)
191
+ if (!pool) {
192
+ s.pool.push({ val: d.pool, count: 1 })
193
+ } else {
194
+ pool.count++
195
+ }
196
+ const platform = s.platform.find((i) => i.val === d.platform)
197
+ if (!platform) {
198
+ s.platform.push({ val: d.platform, count: 1 })
199
+ } else {
200
+ platform.count++
201
+ }
202
+ return s
203
+ }, default_stat)
204
+ return stat
205
+ }
206
+ get most() {
207
+ const s = this.stat
208
+ return {
209
+ mode: s.mode.sort((a, b) => b.count - a.count)[0].val,
210
+ fontsize: s.fontsize.sort((a, b) => b.count - a.count)[0].val,
211
+ color: s.color.sort((a, b) => b.count - a.count)[0].val,
212
+ senderID: s.senderID.sort((a, b) => b.count - a.count)[0].val,
213
+ content: s.content.sort((a, b) => b.count - a.count)[0].val,
214
+ weight: s.weight.sort((a, b) => b.count - a.count)[0].val,
215
+ pool: s.pool.sort((a, b) => b.count - a.count)[0].val,
216
+ platform: s.platform.sort((a, b) => b.count - a.count)[0].val,
90
217
  }
91
- if (isShared('FCID')) this.shared.FCID = dans[0].FCID
92
- if (isShared('senderID')) this.shared.senderID = dans[0].senderID
93
- if (isShared('platform')) this.shared.platform = dans[0].platform
94
- if (isShared('SPMO')) this.shared.SPMO = dans[0].SPMO
95
- if (isShared('pool')) this.shared.pool = dans[0].pool
96
- if (isShared('mode')) this.shared.mode = dans[0].mode
97
218
  }
98
219
  static create() {
99
220
  return new UniPool([])
@@ -117,17 +238,29 @@ export class UniPool {
117
238
  if (this.shared[key]) return [this]
118
239
  const set = new Set(this.dans.map((d) => d[key]))
119
240
  return [...set].map((v) => {
120
- return new UniPool(this.dans.filter((d) => d[key] === v))
241
+ return new UniPool(
242
+ this.dans.filter((d) => d[key] === v),
243
+ { dedupe: false },
244
+ )
121
245
  })
122
246
  }
247
+ /**
248
+ * 基于DMID的基本去重功能,用于解决该class下dans为array而非Set的问题
249
+ */
250
+ private dedupe() {
251
+ const map = new Map()
252
+ this.dans.forEach((d) => map.set(d.DMID || d.toDMID(), d))
253
+ this.dans = [...map.values()]
254
+ this.options.dedupe = false
255
+ }
123
256
  /**
124
257
  * 合并一定时间段内的重复弹幕,防止同屏出现过多
125
- * @param lifetime 查重时间区段,单位秒 (默认为0,表示不查重)
258
+ * @param lifetime 查重时间区段,单位秒 (默认为 0,表示不查重)
126
259
  */
127
260
  merge(lifetime = 0) {
128
- if (!this.shared.FCID) {
261
+ if (!this.shared.SOID) {
129
262
  console.error(
130
- "本功能仅支持同弹幕库内使用,可先 .split('FCID') 在分别使用",
263
+ "本功能仅支持同弹幕库内使用,可先 .split('SOID') 在分别使用",
131
264
  )
132
265
  return this
133
266
  }
@@ -140,7 +273,7 @@ export class UniPool {
140
273
  ]
141
274
  >(
142
275
  ([result, cache, mergeObj], danmaku) => {
143
- const key = ['content', 'mode', 'platform', 'pool', 'SPMO']
276
+ const key = ['SOID', 'content', 'mode', 'platform', 'pool']
144
277
  .map((k) => danmaku[k as keyof UniDM])
145
278
  .join('|')
146
279
  const cached = cache[key]
@@ -158,6 +291,8 @@ export class UniPool {
158
291
  count: senders.length,
159
292
  duration: danmaku.progress - cached.progress,
160
293
  senders,
294
+ taolu_count: senders.length,
295
+ taolu_senders: senders,
161
296
  }
162
297
  danmaku.extraStr = JSON.stringify(extra)
163
298
  cache[key] = danmaku
@@ -168,6 +303,8 @@ export class UniPool {
168
303
  count: 1,
169
304
  duration: 0,
170
305
  senders: [danmaku.senderID],
306
+ taolu_count: 1,
307
+ taolu_senders: [danmaku.senderID],
171
308
  }
172
309
  cache[key] = danmaku
173
310
  // 初始化merge信息,包含第一个sender
@@ -184,7 +321,7 @@ export class UniPool {
184
321
  // 处理结果,删除senders<=1的merge字段
185
322
  const [result, _cache, mergeObj] = mergeContext
186
323
  result.forEach((danmaku, i) => {
187
- const key = ['content', 'mode', 'platform', 'pool', 'SPMO']
324
+ const key = ['SOID', 'content', 'mode', 'platform', 'pool']
188
325
  .map((k) => danmaku[k as keyof UniDM])
189
326
  .join('|')
190
327
  const extra = result[i].extra,
@@ -210,7 +347,10 @@ export class UniPool {
210
347
  ? JSON.stringify(updatedExtra)
211
348
  : undefined
212
349
  } else {
213
- result[i].senderID = 'merge@bot'
350
+ result[i].senderID = 'merge[bot]@dan-any'
351
+ result[i].attr
352
+ ? result[i].attr.push('Protect')
353
+ : (result[i].attr = ['Protect'])
214
354
  }
215
355
  }
216
356
  })
@@ -252,7 +392,7 @@ export class UniPool {
252
392
  data.danmakus.map(
253
393
  (d) =>
254
394
  new UniDM(
255
- d.FCID,
395
+ d.SOID,
256
396
  d.progress,
257
397
  d.mode as number,
258
398
  d.fontsize,
@@ -264,7 +404,6 @@ export class UniPool {
264
404
  d.pool as number,
265
405
  d.attr as UniDMTools.DMAttr[],
266
406
  d.platform,
267
- d.SPMO,
268
407
  d.extra,
269
408
  d.DMID,
270
409
  ),
@@ -280,7 +419,7 @@ export class UniPool {
280
419
  create(DanmakuReplySchema, {
281
420
  danmakus: this.dans.map((d) => {
282
421
  return {
283
- FCID: d.FCID,
422
+ SOID: d.SOID,
284
423
  DMID: d.DMID,
285
424
  progress: d.progress,
286
425
  mode: d.mode as number,
@@ -293,14 +432,13 @@ export class UniPool {
293
432
  pool: d.pool as number,
294
433
  attr: d.attr,
295
434
  platform: d.platform,
296
- SPMO: d.SPMO,
297
435
  extra: d.extraStr,
298
436
  }
299
437
  }),
300
438
  }),
301
439
  )
302
440
  }
303
- static fromBiliXML(xml: string, SPMO?: string) {
441
+ static fromBiliXML(xml: string) {
304
442
  const parser = new XMLParser({ ignoreAttributes: false }),
305
443
  oriData: DM_XML_Bili = parser.parse(xml),
306
444
  dans = oriData.i.d
@@ -321,32 +459,56 @@ export class UniPool {
321
459
  id: BigInt(p_arr[7]),
322
460
  weight: Number.parseInt(p_arr[8]),
323
461
  },
324
- SPMO,
325
462
  BigInt(oriData.i.chatid),
326
463
  )
327
464
  }),
328
465
  )
329
466
  }
330
- static fromBiliGrpc(bin: Uint8Array | ArrayBuffer, SPMO?: string) {
467
+ toBiliXML(): string {
468
+ const genCID = (id: string) => {
469
+ const UniID = ID.fromString(id)
470
+ if (UniID.domain === platform.PlatformVideoSource.Bilibili) {
471
+ const cid = Number(UniID.id.replaceAll('def::', ''))
472
+ if (cid) return cid
473
+ }
474
+ return Number.parseInt(Buffer.from(id).toString('hex'), 16)
475
+ }
476
+ const builder = new XMLBuilder({ ignoreAttributes: false })
477
+ return builder.build({
478
+ '?xml': {
479
+ '@_version': '1.0',
480
+ '@_encoding': 'UTF-8',
481
+ },
482
+ i: {
483
+ chatserver: 'chat.bilibili.com',
484
+ chatid: genCID(this.dans[0].SOID),
485
+ mission: 0,
486
+ maxlimit: this.dans.length,
487
+ state: 0,
488
+ real_name: 0,
489
+ source: 'k-v',
490
+ d: this.dans.map((dan) => dan.toBiliXML()),
491
+ },
492
+ })
493
+ }
494
+ static fromBiliGrpc(bin: Uint8Array | ArrayBuffer) {
331
495
  const data = fromBinary(DmSegMobileReplySchema, new Uint8Array(bin)),
332
496
  json = data.elems
333
497
  return new UniPool(
334
498
  json.map((d) => {
335
- return UniDM.fromBili(d, SPMO)
499
+ return UniDM.fromBili({ ...d, progress: d.progress / 1000 })
336
500
  }),
337
501
  )
338
502
  }
339
503
  /**
340
- *
341
504
  * @param bin 符合`DmWebViewReplySchema`(bili视频meta)的protobuf二进制
342
- * @param SPMO
343
505
  */
344
- static fromBiliCommandGrpc(bin: Uint8Array | ArrayBuffer, SPMO?: string) {
506
+ static fromBiliCommandGrpc(bin: Uint8Array | ArrayBuffer) {
345
507
  const data = fromBinary(DmWebViewReplySchema, new Uint8Array(bin)),
346
508
  json = data.commandDms
347
509
  return new UniPool(
348
510
  json.map((d) => {
349
- return UniDM.fromBiliCommand(d, SPMO)
511
+ return UniDM.fromBiliCommand(d)
350
512
  }),
351
513
  )
352
514
  }
@@ -420,7 +582,7 @@ export class UniPool {
420
582
  }
421
583
  })
422
584
  }
423
- static fromDDPlay(json: DM_JSON_DDPlay, episodeId: string, domain?: string) {
585
+ static fromDDPlay(json: DM_JSON_DDPlay, episodeId: string) {
424
586
  return new UniPool(
425
587
  json.comments.map((d) => {
426
588
  const p_arr = d.p.split(',')
@@ -434,7 +596,6 @@ export class UniPool {
434
596
  uid: p_arr[3],
435
597
  },
436
598
  episodeId,
437
- domain,
438
599
  )
439
600
  }),
440
601
  )
@@ -456,18 +617,18 @@ export class UniPool {
456
617
  return parseAssRawField(ass)
457
618
  }
458
619
  toASS(options: AssGenOptions = { substyle: {} }): string {
459
- const fn = this.shared.FCID
620
+ const fn = this.shared.SOID
460
621
  return generateASS(this, { filename: fn, title: fn, ...options })
461
622
  }
462
623
  }
463
624
 
464
625
  export {
626
+ platform,
465
627
  // UniPool,
466
628
  UniDM,
467
629
  UniDMTools,
468
630
  UniIDTools,
469
631
  type DM_JSON_BiliCommandGrpc,
470
- type platfrom,
471
632
  // type UniDMType,
472
633
  // type UniIDType,
473
634
  }
@@ -1,9 +1,9 @@
1
- // @generated by protoc-gen-es v2.2.3 with parameter "target=ts"
1
+ // @generated by protoc-gen-es v2.6.0 with parameter "target=ts"
2
2
  // @generated from file bili/dm.proto (package bilibili.community.service.dm.v1, syntax proto3)
3
3
  /* eslint-disable */
4
4
 
5
- import type { GenEnum, GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv1";
6
- import { enumDesc, fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv1";
5
+ import type { GenEnum, GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
6
+ import { enumDesc, fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
7
7
  import type { Message } from "@bufbuild/protobuf";
8
8
 
9
9
  /**
@@ -1,9 +1,9 @@
1
- // @generated by protoc-gen-es v2.2.3 with parameter "target=ts"
1
+ // @generated by protoc-gen-es v2.6.0 with parameter "target=ts"
2
2
  // @generated from file danuni.proto (package danuni.danmaku.v1, syntax proto3)
3
3
  /* eslint-disable */
4
4
 
5
- import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv1";
6
- import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv1";
5
+ import type { GenEnum, GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
6
+ import { enumDesc, fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
7
7
  import type { Timestamp } from "@bufbuild/protobuf/wkt";
8
8
  import { file_google_protobuf_timestamp } from "@bufbuild/protobuf/wkt";
9
9
  import type { Message } from "@bufbuild/protobuf";
@@ -12,16 +12,38 @@ import type { Message } from "@bufbuild/protobuf";
12
12
  * Describes the file danuni.proto.
13
13
  */
14
14
  export const file_danuni: GenFile = /*@__PURE__*/
15
- fileDesc("CgxkYW51bmkucHJvdG8SEWRhbnVuaS5kYW5tYWt1LnYxIt4CCgdEYW5tYWt1EgwKBEZDSUQYASABKAkSDAoERE1JRBgCIAEoCRIQCghwcm9ncmVzcxgDIAEoBRIlCgRtb2RlGAQgASgOMhcuZGFudW5pLmRhbm1ha3UudjEuTW9kZRIQCghmb250c2l6ZRgFIAEoBRINCgVjb2xvchgGIAEoBRIQCghzZW5kZXJJRBgHIAEoCRIPCgdjb250ZW50GAggASgJEikKBWN0aW1lGAkgASgLMhouZ29vZ2xlLnByb3RvYnVmLlRpbWVzdGFtcBIOCgZ3ZWlnaHQYCiABKAUSJQoEcG9vbBgLIAEoDjIXLmRhbnVuaS5kYW5tYWt1LnYxLlBvb2wSDAoEYXR0chgMIAMoCRIQCghwbGF0Zm9ybRgNIAEoCRIRCgRTUE1PGA4gASgJSACIAQESEgoFZXh0cmEYDyABKAlIAYgBAUIHCgVfU1BNT0IICgZfZXh0cmEiPAoMRGFubWFrdVJlcGx5EiwKCGRhbm1ha3VzGAEgAygLMhouZGFudW5pLmRhbm1ha3UudjEuRGFubWFrdSo9CgRNb2RlEgoKBk5vcm1hbBAAEgoKBkJvdHRvbRABEgcKA1RvcBACEgsKB1JldmVyc2UQAxIHCgNFeHQQBCopCgRQb29sEgcKA0RlZhAAEgcKA1N1YhABEgcKA0FkdhACEgYKAkl4EANQAGIGcHJvdG8z", [file_google_protobuf_timestamp]);
15
+ fileDesc("CgxkYW51bmkucHJvdG8SEWRhbnVuaS5kYW5tYWt1LnYxIjIKCmxpc3REYW5SZXESCgoCSUQYASABKAkSEAoDc2VnGAIgASgFSACIAQFCBgoEX3NlZyLCAgoHRGFubWFrdRIMCgRTT0lEGAEgASgJEgwKBERNSUQYAiABKAkSEAoIcHJvZ3Jlc3MYAyABKAUSJQoEbW9kZRgEIAEoDjIXLmRhbnVuaS5kYW5tYWt1LnYxLk1vZGUSEAoIZm9udHNpemUYBSABKAUSDQoFY29sb3IYBiABKAUSEAoIc2VuZGVySUQYByABKAkSDwoHY29udGVudBgIIAEoCRIpCgVjdGltZRgJIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASDgoGd2VpZ2h0GAogASgFEiUKBHBvb2wYCyABKA4yFy5kYW51bmkuZGFubWFrdS52MS5Qb29sEgwKBGF0dHIYDCADKAkSEAoIcGxhdGZvcm0YDSABKAkSEgoFZXh0cmEYDiABKAlIAIgBAUIICgZfZXh0cmEiPAoMRGFubWFrdVJlcGx5EiwKCGRhbm1ha3VzGAEgAygLMhouZGFudW5pLmRhbm1ha3UudjEuRGFubWFrdSo9CgRNb2RlEgoKBk5vcm1hbBAAEgoKBkJvdHRvbRABEgcKA1RvcBACEgsKB1JldmVyc2UQAxIHCgNFeHQQBCopCgRQb29sEgcKA0RlZhAAEgcKA1N1YhABEgcKA0FkdhACEgYKAkl4EAMyXQoORGFubWFrdVNlcnZpY2USSwoHbGlzdERhbhIdLmRhbnVuaS5kYW5tYWt1LnYxLmxpc3REYW5SZXEaHy5kYW51bmkuZGFubWFrdS52MS5EYW5tYWt1UmVwbHkiAFAAYgZwcm90bzM", [file_google_protobuf_timestamp]);
16
+
17
+ /**
18
+ * @generated from message danuni.danmaku.v1.listDanReq
19
+ */
20
+ export type listDanReq = Message<"danuni.danmaku.v1.listDanReq"> & {
21
+ /**
22
+ * @generated from field: string ID = 1;
23
+ */
24
+ ID: string;
25
+
26
+ /**
27
+ * @generated from field: optional int32 seg = 2;
28
+ */
29
+ seg?: number;
30
+ };
31
+
32
+ /**
33
+ * Describes the message danuni.danmaku.v1.listDanReq.
34
+ * Use `create(listDanReqSchema)` to create a new message.
35
+ */
36
+ export const listDanReqSchema: GenMessage<listDanReq> = /*@__PURE__*/
37
+ messageDesc(file_danuni, 0);
16
38
 
17
39
  /**
18
40
  * @generated from message danuni.danmaku.v1.Danmaku
19
41
  */
20
42
  export type Danmaku = Message<"danuni.danmaku.v1.Danmaku"> & {
21
43
  /**
22
- * @generated from field: string FCID = 1;
44
+ * @generated from field: string SOID = 1;
23
45
  */
24
- FCID: string;
46
+ SOID: string;
25
47
 
26
48
  /**
27
49
  * @generated from field: string DMID = 2;
@@ -84,12 +106,7 @@ export type Danmaku = Message<"danuni.danmaku.v1.Danmaku"> & {
84
106
  platform: string;
85
107
 
86
108
  /**
87
- * @generated from field: optional string SPMO = 14;
88
- */
89
- SPMO?: string;
90
-
91
- /**
92
- * @generated from field: optional string extra = 15;
109
+ * @generated from field: optional string extra = 14;
93
110
  */
94
111
  extra?: string;
95
112
  };
@@ -99,7 +116,7 @@ export type Danmaku = Message<"danuni.danmaku.v1.Danmaku"> & {
99
116
  * Use `create(DanmakuSchema)` to create a new message.
100
117
  */
101
118
  export const DanmakuSchema: GenMessage<Danmaku> = /*@__PURE__*/
102
- messageDesc(file_danuni, 0);
119
+ messageDesc(file_danuni, 1);
103
120
 
104
121
  /**
105
122
  * @generated from message danuni.danmaku.v1.DanmakuReply
@@ -116,7 +133,7 @@ export type DanmakuReply = Message<"danuni.danmaku.v1.DanmakuReply"> & {
116
133
  * Use `create(DanmakuReplySchema)` to create a new message.
117
134
  */
118
135
  export const DanmakuReplySchema: GenMessage<DanmakuReply> = /*@__PURE__*/
119
- messageDesc(file_danuni, 1);
136
+ messageDesc(file_danuni, 2);
120
137
 
121
138
  /**
122
139
  * @generated from enum danuni.danmaku.v1.Mode
@@ -185,3 +202,18 @@ export enum Pool {
185
202
  export const PoolSchema: GenEnum<Pool> = /*@__PURE__*/
186
203
  enumDesc(file_danuni, 1);
187
204
 
205
+ /**
206
+ * @generated from service danuni.danmaku.v1.DanmakuService
207
+ */
208
+ export const DanmakuService: GenService<{
209
+ /**
210
+ * @generated from rpc danuni.danmaku.v1.DanmakuService.listDan
211
+ */
212
+ listDan: {
213
+ methodKind: "unary";
214
+ input: typeof listDanReqSchema;
215
+ output: typeof DanmakuReplySchema;
216
+ },
217
+ }> = /*@__PURE__*/
218
+ serviceDesc(file_danuni, 0);
219
+
@@ -4,6 +4,15 @@ package danuni.danmaku.v1;
4
4
 
5
5
  import public "google/protobuf/timestamp.proto";
6
6
 
7
+ service DanmakuService {
8
+ rpc listDan (listDanReq) returns (DanmakuReply) {}
9
+ }
10
+
11
+ message listDanReq {
12
+ string ID = 1;
13
+ optional int32 seg = 2;
14
+ }
15
+
7
16
  enum Mode {
8
17
  Normal = 0;
9
18
  Bottom = 1;
@@ -20,7 +29,7 @@ enum Pool {
20
29
  }
21
30
 
22
31
  message Danmaku {
23
- string FCID = 1;
32
+ string SOID = 1;
24
33
  string DMID = 2;
25
34
  int32 progress = 3;
26
35
  Mode mode = 4;
@@ -33,8 +42,7 @@ message Danmaku {
33
42
  Pool pool = 11;
34
43
  repeated string attr = 12;
35
44
  string platform = 13;
36
- optional string SPMO = 14;
37
- optional string extra = 15;
45
+ optional string extra = 14;
38
46
  }
39
47
 
40
48
  message DanmakuReply {
@@ -1,4 +1,3 @@
1
- //基于以下注释,根据vitest生成测试用例
2
1
  import { describe, expect, it } from 'vitest'
3
2
  import type { UniDMObj } from './dm-gen'
4
3
 
@@ -24,7 +23,15 @@ describe('弹幕降级', () => {
24
23
  UniDM.create({
25
24
  content: 'test',
26
25
  extra: {
27
- danuni: { merge: { count: 100, duration: 10, senders: [] } },
26
+ danuni: {
27
+ merge: {
28
+ count: 100,
29
+ duration: 10,
30
+ senders: [],
31
+ taolu_count: 100,
32
+ taolu_senders: [],
33
+ },
34
+ },
28
35
  },
29
36
  }),
30
37
  UniDM.create({
@@ -86,7 +93,7 @@ describe('其它', () => {
86
93
  })
87
94
  it('比较(extra)', () => {
88
95
  const commonSample = {
89
- FCID: 'test@du',
96
+ SOID: 'test@du',
90
97
  content: 'T Sample',
91
98
  extra: {
92
99
  danuni: {
@@ -94,6 +101,8 @@ describe('其它', () => {
94
101
  count: 1,
95
102
  duration: 0,
96
103
  senders: ['test@du'],
104
+ taolu_count: 1,
105
+ taolu_senders: ['test@du'],
97
106
  },
98
107
  },
99
108
  },