@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.
- package/README.md +1 -1
- package/dist/index.js +225 -352
- package/dist/index.min.js +225 -352
- package/dist/index.umd.min.js +228 -354
- package/dist/src/index.d.ts +15 -41
- package/package.json +5 -5
- package/src/ass-gen/ass/create.ts +2 -2
- package/src/ass-gen/ass/raw.ts +19 -19
- package/src/index.test.ts +19 -12
- package/src/index.ts +100 -130
- package/src/proto/gen/bili/dm_pb.ts +1 -1
- package/src/proto/gen/danuni_pb.ts +1 -1
- package/src/utils/dm-gen.test.ts +3 -3
- package/src/utils/dm-gen.ts +30 -31
package/src/utils/dm-gen.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
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
|
|
756
|
-
|
|
757
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|