@dan-uni/dan-any 0.9.1 → 0.9.3

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.
@@ -52,6 +52,11 @@ export interface DM_JSON_DDPlay {
52
52
  }
53
53
  export type DM_format = 'danuni.json' | 'danuni.pb.bin' | 'bili.xml' | 'bili.pb.bin' | 'bili.cmd.pb.bin' | 'dplayer.json' | 'artplayer.json' | 'ddplay.json' | 'common.ass';
54
54
  type shareItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'>>;
55
+ type statItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'mode' | 'fontsize' | 'color' | 'senderID' | 'content' | 'weight' | 'pool' | 'platform'>>;
56
+ interface Stat {
57
+ val: statItems[keyof statItems];
58
+ count: number;
59
+ }
55
60
  type UniPoolPipe = (that: UniPool) => Promise<UniPool>;
56
61
  type UniPoolPipeSync = (that: UniPool) => UniPool;
57
62
  export interface Options {
@@ -76,44 +81,9 @@ export declare class UniPool {
76
81
  pipe(fn: UniPoolPipe): Promise<UniPool>;
77
82
  pipeSync(fn: UniPoolPipeSync): UniPool;
78
83
  get shared(): shareItems;
79
- get stat(): {
80
- SOID: {
81
- val: string;
82
- count: number;
83
- }[];
84
- mode: {
85
- val: UniDMTools.Modes;
86
- count: number;
87
- }[];
88
- fontsize: {
89
- val: number;
90
- count: number;
91
- }[];
92
- color: {
93
- val: number;
94
- count: number;
95
- }[];
96
- senderID: {
97
- val: string;
98
- count: number;
99
- }[];
100
- content: {
101
- val: string;
102
- count: number;
103
- }[];
104
- weight: {
105
- val: number;
106
- count: number;
107
- }[];
108
- pool: {
109
- val: UniDMTools.Pools;
110
- count: number;
111
- }[];
112
- platform: {
113
- val?: string;
114
- count: number;
115
- }[];
116
- };
84
+ getShared(key: keyof shareItems): shareItems[keyof shareItems];
85
+ getStat(key: keyof statItems): Stat[];
86
+ getMost(key: keyof statItems): Stat;
117
87
  get most(): {
118
88
  mode: UniDMTools.Modes;
119
89
  fontsize: number;
@@ -147,7 +117,7 @@ export declare class UniPool {
147
117
  pool: UniPool;
148
118
  fmt: DM_format;
149
119
  };
150
- convert2(format: DM_format, continue_on_error?: boolean): string | Uint8Array<ArrayBufferLike> | UniDM[] | (DM_JSON_Dplayer & {
120
+ convert2(format: DM_format, continue_on_error?: boolean): string | Uint8Array<ArrayBuffer> | UniDM[] | (DM_JSON_Dplayer & {
151
121
  danuni?: DanUniConvertTip;
152
122
  }) | (DM_JSON_Artplayer & {
153
123
  danuni?: DanUniConvertTip;
@@ -158,7 +128,7 @@ export declare class UniPool {
158
128
  /**
159
129
  * 转为 protobuf 二进制
160
130
  */
161
- toPb(): Uint8Array<ArrayBufferLike>;
131
+ toPb(): Uint8Array<ArrayBuffer>;
162
132
  static fromBiliXML(xml: string, options?: Options): UniPool;
163
133
  toBiliXML(options?: {
164
134
  /**
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@dan-uni/dan-any",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "A danmaku transformer lib, supporting danmaku from different platforms.",
5
+ "type": "module",
5
6
  "keywords": [
6
7
  "bangumi",
7
8
  "danmaku"
@@ -19,7 +20,7 @@
19
20
  "main": "dist/index.js",
20
21
  "module": "dist/index.js",
21
22
  "types": "dist/src/index.d.ts",
22
- "browser": "dist/index.umd.min.js",
23
+ "browser": "dist/index.min.js",
23
24
  "scripts": {
24
25
  "test": "vitest",
25
26
  "test:ui": "vitest --ui",
@@ -31,12 +32,12 @@
31
32
  "buf": "buf generate"
32
33
  },
33
34
  "dependencies": {
34
- "@bufbuild/protobuf": "^2.6.3",
35
+ "@bufbuild/protobuf": "^2.7.0",
35
36
  "base16384": "^1.0.0",
36
37
  "class-transformer": "^0.5.1",
37
38
  "class-validator": "^0.14.2",
38
39
  "fast-xml-parser": "^5.2.5",
39
- "fs-extra": "^11.3.0",
40
+ "fs-extra": "^11.3.1",
40
41
  "hh-mm-ss": "^1.2.0",
41
42
  "json-bigint": "^1.0.0",
42
43
  "jssha": "^3.3.1",
@@ -44,11 +45,11 @@
44
45
  },
45
46
  "devDependencies": {
46
47
  "@bufbuild/buf": "^1.56.0",
47
- "@bufbuild/protoc-gen-es": "^2.6.3",
48
+ "@bufbuild/protoc-gen-es": "^2.7.0",
48
49
  "@types/fs-extra": "^11.0.4",
49
50
  "@types/hh-mm-ss": "^1.2.3",
50
51
  "@types/json-bigint": "^1.0.4",
51
- "canvas": "^3.1.2",
52
- "protobufjs": "^7.5.3"
52
+ "canvas": "^3.2.0",
53
+ "protobufjs": "^7.5.4"
53
54
  }
54
55
  }
package/rslib.config.ts CHANGED
@@ -13,6 +13,15 @@ export default defineConfig({
13
13
  },
14
14
  dts: true,
15
15
  },
16
+ {
17
+ format: 'esm',
18
+ output: {
19
+ filename: { js: 'index.min.js' },
20
+ target: 'web',
21
+ },
22
+ dts: true,
23
+ plugins: [pluginNodePolyfill()],
24
+ },
16
25
  {
17
26
  format: 'umd',
18
27
  output: {
@@ -16,8 +16,8 @@ export default (
16
16
  context: Context = { filename: 'unknown', title: 'unknown' },
17
17
  rawConfig?: RawConfig,
18
18
  ) => {
19
- const Elist = UniPool2DanmakuLists(list),
20
- ErawList = UniPool2DanmakuLists(rawList)
19
+ const Elist = UniPool2DanmakuLists(list)
20
+ const ErawList = UniPool2DanmakuLists(rawList)
21
21
  const content = [info(config, context), style(config), event(Elist, config)]
22
22
 
23
23
  if (config.includeRaw) {
@@ -9,8 +9,8 @@ import type { Context, Danmaku, SubtitleStyle } from '../types'
9
9
 
10
10
  type compressType = 'brotli' | 'gzip'
11
11
  type baseType = 'base64' | 'base18384'
12
- const compressTypes = ['brotli', 'gzip'],
13
- baseTypes = ['base64', 'base18384']
12
+ const compressTypes = ['brotli', 'gzip']
13
+ const baseTypes = ['base64', 'base18384']
14
14
 
15
15
  export interface RawConfig {
16
16
  compressType: compressType
@@ -32,8 +32,8 @@ export function raw(
32
32
  compressType: compressType = 'brotli',
33
33
  baseType: baseType = 'base18384',
34
34
  ) {
35
- const raw = { list, config, context },
36
- rawText = JSON.stringify(raw)
35
+ const raw = { list, config, context }
36
+ const rawText = JSON.stringify(raw)
37
37
  let compress: Buffer
38
38
  if (compressType === 'brotli') compress = brotliCompressSync(rawText)
39
39
  else compress = gzipSync(rawText)
@@ -47,25 +47,25 @@ export function deRaw(ass: string):
47
47
  context: Context
48
48
  }
49
49
  | undefined {
50
- const arr = ass.split('\n'),
51
- lineCompressType = arr.find((line) => line.startsWith(';RawCompressType:')),
52
- lineBaseType = arr.find((line) => line.startsWith(';RawBaseType:')),
53
- lineRaw = arr.find((line) => line.startsWith(';Raw:'))
50
+ const arr = ass.split('\n')
51
+ const lineCompressType = arr.find((line) =>
52
+ line.startsWith(';RawCompressType:'),
53
+ )
54
+ const lineBaseType = arr.find((line) => line.startsWith(';RawBaseType:'))
55
+ const lineRaw = arr.find((line) => line.startsWith(';Raw:'))
54
56
  if (!lineCompressType || !lineBaseType || !lineRaw) return undefined
55
57
  else {
56
- let compressType = lineCompressType
57
- .replace(';RawCompressType: ', '')
58
- .trim(),
59
- baseType = lineBaseType.replace(';RawBaseType: ', '').trim()
58
+ let compressType = lineCompressType.replace(';RawCompressType: ', '').trim()
59
+ let baseType = lineBaseType.replace(';RawBaseType: ', '').trim()
60
60
  if (!compressTypes.includes(compressType)) compressType = 'gzip'
61
61
  if (!baseTypes.includes(baseType)) baseType = 'base64'
62
- const text = lineRaw.replace(';Raw: ', '').trim(),
63
- buffer =
64
- baseType === 'base64'
65
- ? Buffer.from(text, 'base64')
66
- : Buffer.from(
67
- base16384.decode(Buffer.from(text, 'utf-8').toString('utf-8')),
68
- )
62
+ const text = lineRaw.replace(';Raw: ', '').trim()
63
+ const buffer =
64
+ baseType === 'base64'
65
+ ? Buffer.from(text, 'base64')
66
+ : Buffer.from(
67
+ base16384.decode(Buffer.from(text, 'utf-8').toString('utf-8')),
68
+ )
69
69
  let decompress: Buffer
70
70
  if (compressType === 'brotli') decompress = brotliDecompressSync(buffer)
71
71
  else decompress = gunzipSync(buffer)
package/src/index.test.ts CHANGED
@@ -41,18 +41,18 @@ describe('转化自', () => {
41
41
  })
42
42
  it('artplayer(json)', () => {
43
43
  const json = {
44
- danmuku: [
45
- {
46
- text: 'artplayer测试弹幕', // 弹幕文本
47
- time: 10, // 弹幕时间, 默认为当前播放器时间
48
- mode: 0, // 弹幕模式: 0: 滚动(默认),1: 顶部,2: 底部
49
- color: '#FFFFFF', // 弹幕颜色,默认为白色
50
- border: false, // 弹幕是否有描边, 默认为 false
51
- style: { border: '10rem' }, // 弹幕自定义样式, 默认为空对象
52
- },
53
- ],
54
- },
55
- pool = UniPool.fromArtplayer(json, 'playerid-test', 'acfun')
44
+ danmuku: [
45
+ {
46
+ text: 'artplayer测试弹幕', // 弹幕文本
47
+ time: 10, // 弹幕时间, 默认为当前播放器时间
48
+ mode: 0, // 弹幕模式: 0: 滚动(默认),1: 顶部,2: 底部
49
+ color: '#FFFFFF', // 弹幕颜色,默认为白色
50
+ border: false, // 弹幕是否有描边, 默认为 false
51
+ style: { border: '10rem' }, // 弹幕自定义样式, 默认为空对象
52
+ },
53
+ ],
54
+ }
55
+ const pool = UniPool.fromArtplayer(json, 'playerid-test', 'acfun')
56
56
  console.info(json)
57
57
  console.info(pool)
58
58
  const imp = UniPool.import(json)
@@ -90,7 +90,14 @@ describe('转化自', () => {
90
90
  describe('共通值', () => {
91
91
  const pool = UniPool.fromBiliXML(xml)
92
92
  it('获取shared', () => {
93
+ console.info(pool.getMost('SOID'))
93
94
  console.info(pool.shared)
95
+ expect(pool.getShared('SOID')).toBe(pool.shared.SOID)
96
+ })
97
+ it('获取most', () => {
98
+ console.info(pool.getMost('senderID'))
99
+ console.info(pool.most)
100
+ expect(pool.getMost('senderID').val).toBe(pool.most.senderID)
94
101
  })
95
102
  it('按pool分组', () => {
96
103
  console.info(pool.split('pool'))
package/src/index.ts CHANGED
@@ -102,6 +102,24 @@ type shareItems = Partial<
102
102
  'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'
103
103
  >
104
104
  >
105
+ type statItems = Partial<
106
+ Pick<
107
+ UniDMTools.UniDMObj,
108
+ | 'SOID'
109
+ | 'mode'
110
+ | 'fontsize'
111
+ | 'color'
112
+ | 'senderID'
113
+ | 'content'
114
+ | 'weight'
115
+ | 'pool'
116
+ | 'platform'
117
+ >
118
+ >
119
+ interface Stat {
120
+ val: statItems[keyof statItems]
121
+ count: number
122
+ }
105
123
 
106
124
  type UniPoolPipe = (that: UniPool) => Promise<UniPool>
107
125
  type UniPoolPipeSync = (that: UniPool) => UniPool
@@ -144,104 +162,38 @@ export class UniPool {
144
162
  color: isShared('color') ? this.dans[0].color : undefined,
145
163
  }
146
164
  }
147
- get stat() {
148
- const default_stat = {
149
- SOID: [] as { val: string; count: number }[],
150
- mode: [
151
- { val: UniDMTools.Modes.Normal, count: 0 },
152
- { val: UniDMTools.Modes.Bottom, count: 0 },
153
- { val: UniDMTools.Modes.Top, count: 0 },
154
- { val: UniDMTools.Modes.Reverse, count: 0 },
155
- { val: UniDMTools.Modes.Ext, count: 0 },
156
- ],
157
- fontsize: [
158
- // { val: 18, count: 0 },
159
- // { val: 25, count: 0 },
160
- // { val: 36, count: 0 },
161
- ] as { val: number; count: number }[],
162
- color: [] as { val: number; count: number }[],
163
- senderID: [] as { val: string; count: number }[],
164
- content: [] as { val: string; count: number }[],
165
- weight: [] as { val: number; count: number }[],
166
- pool: [
167
- { val: UniDMTools.Pools.Def, count: 0 },
168
- { val: UniDMTools.Pools.Sub, count: 0 },
169
- { val: UniDMTools.Pools.Adv, count: 0 },
170
- { val: UniDMTools.Pools.Ix, count: 0 },
171
- ],
172
- platform: [] as { val?: string; count: number }[],
165
+ getShared(key: keyof shareItems): shareItems[keyof shareItems] {
166
+ const isShared = (key: keyof UniDMTools.UniDMObj) => {
167
+ return this.dans.every((d) => d[key])
173
168
  }
174
- type Stat = typeof default_stat
175
- const stat = this.dans.reduce((s, d): Stat => {
176
- const SOID = s.SOID.find((i) => i.val === d.SOID)
177
- if (!SOID) {
178
- s.SOID.push({ val: d.SOID, count: 1 })
179
- } else {
180
- SOID.count++
181
- }
182
- const mode = s.mode.find((i) => i.val === d.mode)
183
- if (!mode) {
184
- s.mode.push({ val: d.mode, count: 1 })
185
- } else {
186
- mode.count++
187
- }
188
- const fontsize = s.fontsize.find((i) => i.val === d.fontsize)
189
- if (!fontsize) {
190
- s.fontsize.push({ val: d.fontsize, count: 1 })
191
- } else {
192
- fontsize.count++
193
- }
194
- const color = s.color.find((i) => i.val === d.color)
195
- if (!color) {
196
- s.color.push({ val: d.color, count: 1 })
197
- } else {
198
- color.count++
199
- }
200
- const senderID = s.senderID.find((i) => i.val === d.senderID)
201
- if (!senderID) {
202
- s.senderID.push({ val: d.senderID, count: 1 })
203
- } else {
204
- senderID.count++
205
- }
206
- const content = s.content.find((i) => i.val === d.content)
207
- if (!content) {
208
- s.content.push({ val: d.content, count: 1 })
209
- } else {
210
- content.count++
211
- }
212
- const weight = s.weight.find((i) => i.val === d.weight)
213
- if (!weight) {
214
- s.weight.push({ val: d.weight, count: 1 })
215
- } else {
216
- weight.count++
217
- }
218
- const pool = s.pool.find((i) => i.val === d.pool)
219
- if (!pool) {
220
- s.pool.push({ val: d.pool, count: 1 })
221
- } else {
222
- pool.count++
223
- }
224
- const platform = s.platform.find((i) => i.val === d.platform)
225
- if (!platform) {
226
- s.platform.push({ val: d.platform, count: 1 })
169
+ return isShared(key) ? this.dans[0][key] : undefined
170
+ }
171
+ getStat(key: keyof statItems): Stat[] {
172
+ const default_stat: Stat[] = []
173
+ const stats = this.dans.reduce((stat, dan) => {
174
+ const valWithCount = stat.find((i) => i.val === dan[key])
175
+ if (!valWithCount) {
176
+ stat.push({ val: dan[key], count: 1 })
227
177
  } else {
228
- platform.count++
178
+ valWithCount.count++
229
179
  }
230
- return s
180
+ return stat
231
181
  }, default_stat)
232
- return stat
182
+ return stats
183
+ }
184
+ getMost(key: keyof statItems) {
185
+ return this.getStat(key).sort((a, b) => b.count - a.count)[0]
233
186
  }
234
187
  get most() {
235
- const s = this.stat
236
188
  return {
237
- mode: s.mode.sort((a, b) => b.count - a.count)[0].val,
238
- fontsize: s.fontsize.sort((a, b) => b.count - a.count)[0].val,
239
- color: s.color.sort((a, b) => b.count - a.count)[0].val,
240
- senderID: s.senderID.sort((a, b) => b.count - a.count)[0].val,
241
- content: s.content.sort((a, b) => b.count - a.count)[0].val,
242
- weight: s.weight.sort((a, b) => b.count - a.count)[0].val,
243
- pool: s.pool.sort((a, b) => b.count - a.count)[0].val,
244
- platform: s.platform.sort((a, b) => b.count - a.count)[0].val,
189
+ mode: this.getMost('mode').val as UniDMTools.Modes,
190
+ fontsize: this.getMost('fontsize').val as number,
191
+ color: this.getMost('color').val as number,
192
+ senderID: this.getMost('senderID').val as string,
193
+ content: this.getMost('content').val as string,
194
+ weight: this.getMost('weight').val as number,
195
+ pool: this.getMost('pool').val as UniDMTools.Pools,
196
+ platform: this.getMost('platform').val as string | undefined,
245
197
  }
246
198
  }
247
199
  static create(options?: Options) {
@@ -361,8 +313,8 @@ export class UniPool {
361
313
  const key = ['content', 'mode', 'platform', 'pool']
362
314
  .map((k) => danmaku[k as keyof UniDM])
363
315
  .join('|')
364
- const extra = result[i].extra,
365
- mergeData = mergeObj[key]
316
+ const extra = result[i].extra
317
+ const mergeData = mergeObj[key]
366
318
  result[i].extraStr = JSON.stringify({
367
319
  ...extra,
368
320
  danuni: {
@@ -574,16 +526,17 @@ export class UniPool {
574
526
  )
575
527
  }
576
528
  static fromBiliXML(xml: string, options?: Options) {
577
- const parser = new XMLParser({ ignoreAttributes: false }),
578
- oriData: DM_XML_Bili & { danuni?: DanUniConvertTip } = parser.parse(xml),
579
- dans = oriData.i.d,
580
- fromConverted = !!oriData.danuni,
581
- cid = BigInt(oriData.i.chatid)
529
+ const parser = new XMLParser({ ignoreAttributes: false })
530
+ const oriData: DM_XML_Bili & { danuni?: DanUniConvertTip } =
531
+ parser.parse(xml)
532
+ const dans = oriData.i.d
533
+ const fromConverted = !!oriData.danuni
534
+ const cid = BigInt(oriData.i.chatid)
582
535
  return new UniPool(
583
536
  dans
584
537
  .map((d) => {
585
- const p_str = d['@_p'],
586
- p_arr = p_str.split(',')
538
+ const p_str = d['@_p']
539
+ const p_arr = p_str.split(',')
587
540
  return UniDM.fromBili(
588
541
  {
589
542
  content: d['#text'],
@@ -657,8 +610,8 @@ export class UniPool {
657
610
  })
658
611
  }
659
612
  static fromBiliGrpc(bin: Uint8Array | ArrayBuffer, options?: Options) {
660
- const data = fromBinary(DmSegMobileReplySchema, new Uint8Array(bin)),
661
- json = data.elems
613
+ const data = fromBinary(DmSegMobileReplySchema, new Uint8Array(bin))
614
+ const json = data.elems
662
615
  return new UniPool(
663
616
  json.map((d) => {
664
617
  return UniDM.fromBili(
@@ -674,8 +627,8 @@ export class UniPool {
674
627
  * @param bin 符合`DmWebViewReplySchema`(bili视频meta)的protobuf二进制
675
628
  */
676
629
  static fromBiliCommandGrpc(bin: Uint8Array | ArrayBuffer, options?: Options) {
677
- const data = fromBinary(DmWebViewReplySchema, new Uint8Array(bin)),
678
- json = data.commandDms
630
+ const data = fromBinary(DmWebViewReplySchema, new Uint8Array(bin))
631
+ const json = data.commandDms
679
632
  return new UniPool(
680
633
  json.map((d) => {
681
634
  return UniDM.fromBiliCommand(d, d.oid, options)
@@ -1,4 +1,4 @@
1
- // @generated by protoc-gen-es v2.6.3 with parameter "target=ts"
1
+ // @generated by protoc-gen-es v2.7.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
 
@@ -1,4 +1,4 @@
1
- // @generated by protoc-gen-es v2.6.3 with parameter "target=ts"
1
+ // @generated by protoc-gen-es v2.7.0 with parameter "target=ts"
2
2
  // @generated from file danuni.proto (package danuni.danmaku.v1, syntax proto3)
3
3
  /* eslint-disable */
4
4
 
@@ -83,9 +83,9 @@ describe('其它', () => {
83
83
  expect(pool.dans[0].content).toBe('喜欢')
84
84
  expect(pool.dans[1].content).toBe('不喜欢')
85
85
  // 正式测试
86
- const a = pool.dans[0].isSameAs(pool.dans[1]),
87
- b = pool.dans[1].isSameAs(pool.dans[2]),
88
- c = pool.dans[1].isSameAs(pool.dans[3])
86
+ const a = pool.dans[0].isSameAs(pool.dans[1])
87
+ const b = pool.dans[1].isSameAs(pool.dans[2])
88
+ const c = pool.dans[1].isSameAs(pool.dans[3])
89
89
  console.info(a, b, c)
90
90
  expect(a).toBe(false)
91
91
  expect(b).toBe(true)
@@ -87,8 +87,8 @@ export enum DMAttr {
87
87
  }
88
88
  const DMAttrUtils = {
89
89
  fromBin(bin: number = 0, format?: PlatformDanmakuSource) {
90
- const array = toBits(bin),
91
- attr: DMAttr[] = []
90
+ const array = toBits(bin)
91
+ const attr: DMAttr[] = []
92
92
  if (format === 'bili') {
93
93
  if (array[0]) attr.push(DMAttr.Protect)
94
94
  if (array[1]) attr.push(DMAttr.FromLive)
@@ -567,28 +567,28 @@ export class UniDM {
567
567
  (this.extra.danuni?.merge || dan.extra.danuni?.merge)
568
568
  )
569
569
  return false
570
- const isSame = (k: keyof UniDMObj) => this[k] === dan[k],
571
- checks = (
572
- [
573
- 'SOID',
574
- 'content',
575
- 'mode',
576
- 'pool',
577
- 'platform',
578
- ] satisfies (keyof UniDMObj)[]
579
- ).every((k) => isSame(k))
570
+ const isSame = (k: keyof UniDMObj) => this[k] === dan[k]
571
+ const checks = (
572
+ [
573
+ 'SOID',
574
+ 'content',
575
+ 'mode',
576
+ 'pool',
577
+ 'platform',
578
+ ] satisfies (keyof UniDMObj)[]
579
+ ).every((k) => isSame(k))
580
580
  // 忽略使用了extra字段却不在mode里标记的弹幕
581
581
  return checks
582
582
  }
583
583
  @Expose()
584
584
  minify() {
585
585
  type UObj = Partial<UniDMObj> & Pick<UniDMObj, 'SOID'>
586
- const def: UObj = UniDM.create(),
587
- dan: UObj = UniDM.create(this)
586
+ const def: UObj = UniDM.create()
587
+ const dan: UObj = UniDM.create(this)
588
588
  // const prototypes = Object.getOwnPropertyNames(this)
589
589
  for (const key in dan) {
590
- const k = key as keyof UObj,
591
- v = dan[k]
590
+ const k = key as keyof UObj
591
+ const v = dan[k]
592
592
  // if (key in prototypes) continue
593
593
  if (key === 'SOID') continue
594
594
  else if (!v) delete dan[k]
@@ -746,16 +746,15 @@ export class UniDM {
746
746
  }
747
747
  if (args.oid && !cid) cid = args.oid
748
748
  const SOID =
749
- recSOID ||
750
- `def_${PlatformVideoSource.Bilibili}+${ID.fromBili({ cid })}`,
751
- senderID = isEmail(args.midHash, { require_tld: false })
752
- ? args.midHash
753
- : ID.fromBili({ midHash: args.midHash })
749
+ recSOID || `def_${PlatformVideoSource.Bilibili}+${ID.fromBili({ cid })}`
750
+ const senderID = isEmail(args.midHash, { require_tld: false })
751
+ ? args.midHash
752
+ : ID.fromBili({ midHash: args.midHash })
754
753
  let mode = Modes.Normal
755
- const pool = args.pool, //暂时不做处理,兼容bili的pool格式
756
- extra: TExtra = {
757
- bili: { mode: args.mode, pool: args.pool, dmid: args.id },
758
- }
754
+ const pool = args.pool //暂时不做处理,兼容bili的pool格式
755
+ const extra: TExtra = {
756
+ bili: { mode: args.mode, pool: args.pool, dmid: args.id },
757
+ }
759
758
  //重复 transMode ,但此处有关于extra的额外处理
760
759
  switch (args.mode) {
761
760
  case 4:
@@ -873,8 +872,8 @@ export class UniDM {
873
872
  }
874
873
  static fromBiliCommand(args: DMBiliCommand, cid?: bigint, options?: Options) {
875
874
  if (args.oid && !cid) cid = args.oid
876
- const SOID = `def_${PlatformVideoSource.Bilibili}+${ID.fromBili({ cid })}`,
877
- senderID = ID.fromBili({ mid: args.mid })
875
+ const SOID = `def_${PlatformVideoSource.Bilibili}+${ID.fromBili({ cid })}`
876
+ const senderID = ID.fromBili({ mid: args.mid })
878
877
  return this.create(
879
878
  {
880
879
  ...args,
@@ -905,8 +904,8 @@ export class UniDM {
905
904
  domain: string,
906
905
  options?: Options,
907
906
  ) {
908
- const SOID = ID.fromUnknown(playerID, domain),
909
- senderID = ID.fromUnknown(args.midHash, domain)
907
+ const SOID = ID.fromUnknown(playerID, domain)
908
+ const senderID = ID.fromUnknown(args.midHash, domain)
910
909
  return this.create(
911
910
  {
912
911
  ...args,
@@ -941,8 +940,8 @@ export class UniDM {
941
940
  domain: string,
942
941
  options?: Options,
943
942
  ) {
944
- const SOID = ID.fromUnknown(playerID, domain),
945
- senderID = ID.fromUnknown('', domain)
943
+ const SOID = ID.fromUnknown(playerID, domain)
944
+ const senderID = ID.fromUnknown('', domain)
946
945
  let extra = args.border
947
946
  ? ({ artplayer: { border: args.border, style: {} } } as Extra)
948
947
  : undefined