@dan-uni/dan-any 0.9.2 → 0.9.4

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.
@@ -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