@dan-uni/dan-any 0.4.8 → 0.5.0
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 +4 -1
- package/dist/index.js +8 -7
- package/dist/index.umd.min.js +8 -7
- package/dist/src/utils/dm-gen.d.ts +9 -0
- package/package.json +1 -1
- package/src/utils/dm-gen.ts +19 -10
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
|
|
31
31
|
- [dan-any-plugin-detalu](https://github.com/ani-uni/danuni/tree/master/packages/dan-any-plugin-detalu): 基于pakku.js的弹幕过滤器
|
|
32
32
|
|
|
33
|
+
## 特殊字段提示
|
|
34
|
+
|
|
33
35
|
### ASS Raw 字段
|
|
34
36
|
|
|
35
37
|
为便于由ASS格式还原,由本工具生成的ASS弹幕格式中,包含以下字段:`RawCompressType` `RawBaseType` `Raw`
|
|
@@ -38,7 +40,8 @@
|
|
|
38
40
|
|
|
39
41
|
## TODO
|
|
40
42
|
|
|
41
|
-
- [ ]
|
|
43
|
+
- [ ] 完善弹幕降级显示功能(使高级弹幕有损转换为普通弹幕)
|
|
44
|
+
- [ ] 完善使用文档
|
|
42
45
|
|
|
43
46
|
## License 许可证
|
|
44
47
|
|
package/dist/index.js
CHANGED
|
@@ -4948,7 +4948,7 @@ const toBits = (number)=>{
|
|
|
4948
4948
|
bits.unshift(!!(1 & number));
|
|
4949
4949
|
number >>= 1;
|
|
4950
4950
|
}while (number);
|
|
4951
|
-
return bits;
|
|
4951
|
+
return bits.reverse();
|
|
4952
4952
|
};
|
|
4953
4953
|
const DMAttrUtils = {
|
|
4954
4954
|
fromBin (bin = 0, format) {
|
|
@@ -5051,9 +5051,9 @@ class UniDM {
|
|
|
5051
5051
|
this.DMID = DMID;
|
|
5052
5052
|
if (progress < 0) this.progress = 0;
|
|
5053
5053
|
if (mode < 0 || mode > 4) this.mode = 0;
|
|
5054
|
-
if (fontsize
|
|
5054
|
+
if (fontsize < 10 || fontsize > 127) this.fontsize = 25;
|
|
5055
5055
|
if (color <= 0) this.color = 16777215;
|
|
5056
|
-
if (weight < 0 || weight >
|
|
5056
|
+
if (weight < 0 || weight > 11) this.weight = 5;
|
|
5057
5057
|
if (pool < 0 || pool > 3) this.pool = 0;
|
|
5058
5058
|
if (!DMID) DMID = this.toDMID();
|
|
5059
5059
|
this.progress = Number.parseFloat(progress.toFixed(3));
|
|
@@ -5218,7 +5218,8 @@ class UniDM {
|
|
|
5218
5218
|
const pool = args.pool, extra = {
|
|
5219
5219
|
bili: {
|
|
5220
5220
|
mode: args.mode,
|
|
5221
|
-
pool: args.pool
|
|
5221
|
+
pool: args.pool,
|
|
5222
|
+
dmid: args.id
|
|
5222
5223
|
}
|
|
5223
5224
|
};
|
|
5224
5225
|
switch(args.mode){
|
|
@@ -5281,7 +5282,7 @@ class UniDM {
|
|
|
5281
5282
|
return 1;
|
|
5282
5283
|
}
|
|
5283
5284
|
};
|
|
5284
|
-
const rMode = recMode(this.mode, this.extra?.bili);
|
|
5285
|
+
const rMode = this.extra.bili?.mode || recMode(this.mode, this.extra?.bili);
|
|
5285
5286
|
let content;
|
|
5286
5287
|
switch(rMode){
|
|
5287
5288
|
case 7:
|
|
@@ -5305,9 +5306,9 @@ class UniDM {
|
|
|
5305
5306
|
this.fontsize,
|
|
5306
5307
|
this.color,
|
|
5307
5308
|
this.ctime.getTime() / 1000,
|
|
5308
|
-
this.pool,
|
|
5309
|
+
this.extra.bili?.pool || this.pool,
|
|
5309
5310
|
this.senderID,
|
|
5310
|
-
this.DMID || this.toDMID(),
|
|
5311
|
+
this.extra.bili?.dmid || this.DMID || this.toDMID(),
|
|
5311
5312
|
this.weight
|
|
5312
5313
|
].join(',')
|
|
5313
5314
|
};
|
package/dist/index.umd.min.js
CHANGED
|
@@ -18993,7 +18993,7 @@
|
|
|
18993
18993
|
bits.unshift(!!(1 & number));
|
|
18994
18994
|
number >>= 1;
|
|
18995
18995
|
}while (number);
|
|
18996
|
-
return bits;
|
|
18996
|
+
return bits.reverse();
|
|
18997
18997
|
};
|
|
18998
18998
|
const DMAttrUtils = {
|
|
18999
18999
|
fromBin (bin = 0, format) {
|
|
@@ -19096,9 +19096,9 @@
|
|
|
19096
19096
|
this.DMID = DMID;
|
|
19097
19097
|
if (progress < 0) this.progress = 0;
|
|
19098
19098
|
if (mode < 0 || mode > 4) this.mode = 0;
|
|
19099
|
-
if (fontsize
|
|
19099
|
+
if (fontsize < 10 || fontsize > 127) this.fontsize = 25;
|
|
19100
19100
|
if (color <= 0) this.color = 16777215;
|
|
19101
|
-
if (weight < 0 || weight >
|
|
19101
|
+
if (weight < 0 || weight > 11) this.weight = 5;
|
|
19102
19102
|
if (pool < 0 || pool > 3) this.pool = 0;
|
|
19103
19103
|
if (!DMID) DMID = this.toDMID();
|
|
19104
19104
|
this.progress = Number.parseFloat(progress.toFixed(3));
|
|
@@ -19263,7 +19263,8 @@
|
|
|
19263
19263
|
const pool = args.pool, extra = {
|
|
19264
19264
|
bili: {
|
|
19265
19265
|
mode: args.mode,
|
|
19266
|
-
pool: args.pool
|
|
19266
|
+
pool: args.pool,
|
|
19267
|
+
dmid: args.id
|
|
19267
19268
|
}
|
|
19268
19269
|
};
|
|
19269
19270
|
switch(args.mode){
|
|
@@ -19326,7 +19327,7 @@
|
|
|
19326
19327
|
return 1;
|
|
19327
19328
|
}
|
|
19328
19329
|
};
|
|
19329
|
-
const rMode = recMode(this.mode, this.extra?.bili);
|
|
19330
|
+
const rMode = this.extra.bili?.mode || recMode(this.mode, this.extra?.bili);
|
|
19330
19331
|
let content;
|
|
19331
19332
|
switch(rMode){
|
|
19332
19333
|
case 7:
|
|
@@ -19350,9 +19351,9 @@
|
|
|
19350
19351
|
this.fontsize,
|
|
19351
19352
|
this.color,
|
|
19352
19353
|
this.ctime.getTime() / 1000,
|
|
19353
|
-
this.pool,
|
|
19354
|
+
this.extra.bili?.pool || this.pool,
|
|
19354
19355
|
this.senderID,
|
|
19355
|
-
this.DMID || this.toDMID(),
|
|
19356
|
+
this.extra.bili?.dmid || this.DMID || this.toDMID(),
|
|
19356
19357
|
this.weight
|
|
19357
19358
|
].join(',')
|
|
19358
19359
|
};
|
|
@@ -86,6 +86,7 @@ interface ExtraArtplayer {
|
|
|
86
86
|
interface ExtraBili {
|
|
87
87
|
mode?: number;
|
|
88
88
|
pool?: number;
|
|
89
|
+
dmid?: bigint;
|
|
89
90
|
adv?: string;
|
|
90
91
|
code?: string;
|
|
91
92
|
bas?: string;
|
|
@@ -175,9 +176,13 @@ export declare class UniDM {
|
|
|
175
176
|
/**
|
|
176
177
|
* 字号
|
|
177
178
|
* @default 25
|
|
179
|
+
* - 12
|
|
180
|
+
* - 16
|
|
178
181
|
* - 18:小
|
|
179
182
|
* - 25:标准
|
|
180
183
|
* - 36:大
|
|
184
|
+
* - 45
|
|
185
|
+
* - 64
|
|
181
186
|
*/
|
|
182
187
|
fontsize: number;
|
|
183
188
|
/**
|
|
@@ -247,9 +252,13 @@ export declare class UniDM {
|
|
|
247
252
|
/**
|
|
248
253
|
* 字号
|
|
249
254
|
* @default 25
|
|
255
|
+
* - 12
|
|
256
|
+
* - 16
|
|
250
257
|
* - 18:小
|
|
251
258
|
* - 25:标准
|
|
252
259
|
* - 36:大
|
|
260
|
+
* - 45
|
|
261
|
+
* - 64
|
|
253
262
|
*/
|
|
254
263
|
fontsize?: number,
|
|
255
264
|
/**
|
package/package.json
CHANGED
package/src/utils/dm-gen.ts
CHANGED
|
@@ -42,6 +42,11 @@ class SetBin {
|
|
|
42
42
|
this.bin &= ~(1 << bit)
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 获得数字的二进制,每位以boolean(true/false)表示1/0,从低位向高位
|
|
48
|
+
* @param number 任意进制数字
|
|
49
|
+
*/
|
|
45
50
|
const toBits = (number: number) => {
|
|
46
51
|
// 低速方案
|
|
47
52
|
// return [...number.toString(2)].map(Number)
|
|
@@ -52,7 +57,7 @@ const toBits = (number: number) => {
|
|
|
52
57
|
// bits.unshift(number & 1) // (0|1)[]
|
|
53
58
|
number >>= 1
|
|
54
59
|
} while (number)
|
|
55
|
-
return bits
|
|
60
|
+
return bits.reverse()
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
export type DMAttr =
|
|
@@ -217,6 +222,7 @@ interface ExtraArtplayer {
|
|
|
217
222
|
interface ExtraBili {
|
|
218
223
|
mode?: number //原弹幕类型
|
|
219
224
|
pool?: number //原弹幕池
|
|
225
|
+
dmid?: bigint //原弹幕ID
|
|
220
226
|
adv?: string
|
|
221
227
|
code?: string
|
|
222
228
|
bas?: string
|
|
@@ -338,9 +344,13 @@ export class UniDM {
|
|
|
338
344
|
/**
|
|
339
345
|
* 字号
|
|
340
346
|
* @default 25
|
|
347
|
+
* - 12
|
|
348
|
+
* - 16
|
|
341
349
|
* - 18:小
|
|
342
350
|
* - 25:标准
|
|
343
351
|
* - 36:大
|
|
352
|
+
* - 45
|
|
353
|
+
* - 64
|
|
344
354
|
*/
|
|
345
355
|
public fontsize: number = 25,
|
|
346
356
|
/**
|
|
@@ -395,10 +405,10 @@ export class UniDM {
|
|
|
395
405
|
//TODO 引入class-validator
|
|
396
406
|
if (progress < 0) this.progress = 0
|
|
397
407
|
if (mode < Modes.Normal || mode > Modes.Ext) this.mode = Modes.Normal
|
|
398
|
-
if (fontsize
|
|
408
|
+
if (fontsize < 10 || fontsize > 127) this.fontsize = 25
|
|
399
409
|
if (color <= 0) this.color = 16777215 //虽然不知道为0是否为可用值,但过为少见,利用其作为默认位
|
|
400
410
|
// if (ctime <= 0n) this.ctime = BigInt(Date.now())
|
|
401
|
-
if (weight < 0 || weight >
|
|
411
|
+
if (weight < 0 || weight > 11) this.weight = 5
|
|
402
412
|
if (pool < Pools.Def || pool > Pools.Ix) this.pool = Pools.Def
|
|
403
413
|
// if (attr < 0 || attr > 0b111) this.attr = 0
|
|
404
414
|
if (!DMID) DMID = this.toDMID()
|
|
@@ -658,7 +668,9 @@ export class UniDM {
|
|
|
658
668
|
senderID = ID.fromBili({ midHash: args.midHash })
|
|
659
669
|
let mode = Modes.Normal
|
|
660
670
|
const pool = args.pool, //暂时不做处理,兼容bili的pool格式
|
|
661
|
-
extra: TExtra = {
|
|
671
|
+
extra: TExtra = {
|
|
672
|
+
bili: { mode: args.mode, pool: args.pool, dmid: args.id },
|
|
673
|
+
}
|
|
662
674
|
//重复 transMode ,但此处有关于extra的额外处理
|
|
663
675
|
switch (args.mode) {
|
|
664
676
|
case 4:
|
|
@@ -687,9 +699,6 @@ export class UniDM {
|
|
|
687
699
|
mode = Modes.Normal
|
|
688
700
|
break
|
|
689
701
|
}
|
|
690
|
-
// if (args.mode === 7) extra.bili.adv = args.content
|
|
691
|
-
// else if (args.mode === 8) extra.bili.code = args.content
|
|
692
|
-
// else if (args.mode === 9) extra.bili.bas = args.content
|
|
693
702
|
return this.create({
|
|
694
703
|
...args,
|
|
695
704
|
SOID: SOID.toString(),
|
|
@@ -732,7 +741,7 @@ export class UniDM {
|
|
|
732
741
|
return 1
|
|
733
742
|
}
|
|
734
743
|
}
|
|
735
|
-
const rMode = recMode(this.mode, this.extra?.bili)
|
|
744
|
+
const rMode = this.extra.bili?.mode || recMode(this.mode, this.extra?.bili)
|
|
736
745
|
let content
|
|
737
746
|
switch (rMode) {
|
|
738
747
|
case 7:
|
|
@@ -756,9 +765,9 @@ export class UniDM {
|
|
|
756
765
|
this.fontsize,
|
|
757
766
|
this.color,
|
|
758
767
|
this.ctime.getTime() / 1000,
|
|
759
|
-
this.pool, // 目前pool与bili兼容
|
|
768
|
+
this.extra.bili?.pool || this.pool, // 目前pool与bili兼容
|
|
760
769
|
this.senderID,
|
|
761
|
-
this.DMID || this.toDMID(),
|
|
770
|
+
this.extra.bili?.dmid || this.DMID || this.toDMID(),
|
|
762
771
|
this.weight,
|
|
763
772
|
].join(','),
|
|
764
773
|
}
|