@dan-uni/dan-any 0.6.9 → 0.7.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/dist/index.js +84 -70
- package/dist/index.umd.min.js +84 -70
- package/dist/src/index.d.ts +9 -8
- package/dist/src/utils/dm-gen.d.ts +13 -8
- package/dist/src/utils/id-gen.d.ts +2 -1
- package/package.json +2 -2
- package/src/ass-gen/__tests__/898651903.xml.ass +1 -1
- package/src/ass-gen/ass/raw.ts +2 -2
- package/src/index.test.ts +22 -0
- package/src/index.ts +47 -19
- package/src/utils/dm-gen.ts +136 -84
- package/src/utils/id-gen.ts +10 -2
- package/tsconfig.json +1 -1
- package/types/tsconfig.tsbuildinfo +1 -1
package/dist/index.js
CHANGED
|
@@ -125,7 +125,7 @@ class id_gen_UniID {
|
|
|
125
125
|
return this.fromNull(domain);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
function createDMID(content = '', senderID, ctime, extraStr, slice = 8) {
|
|
128
|
+
function createDMID(content = '', senderID = id_gen_UniID.fromNull().toString(), ctime = new Date().toISOString(), extraStr, slice = 8) {
|
|
129
129
|
return new jssha('SHA3-256', 'TEXT').update(`${content}|${senderID}|${UniDM.transCtime(ctime).toISOString()}|${extraStr}`).getHash('HEX').slice(0, slice);
|
|
130
130
|
}
|
|
131
131
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -167,7 +167,7 @@ const toBits = (number)=>{
|
|
|
167
167
|
bits.unshift(!!(1 & number));
|
|
168
168
|
number >>= 1;
|
|
169
169
|
}while (number);
|
|
170
|
-
return bits.
|
|
170
|
+
return bits.toReversed();
|
|
171
171
|
};
|
|
172
172
|
var dm_gen_DMAttr = /*#__PURE__*/ function(DMAttr) {
|
|
173
173
|
DMAttr["Protect"] = "Protect";
|
|
@@ -250,8 +250,10 @@ var dm_gen_Pools = /*#__PURE__*/ function(Pools) {
|
|
|
250
250
|
return Pools;
|
|
251
251
|
}({});
|
|
252
252
|
class UniDM {
|
|
253
|
-
init() {
|
|
253
|
+
init(options) {
|
|
254
|
+
this.options = options || this.options;
|
|
254
255
|
const def = new UniDM();
|
|
256
|
+
if (void 0 === this.options.dmid || true === this.options.dmid) this.options.dmid = createDMID;
|
|
255
257
|
if (!this.SOID) this.SOID = def.SOID;
|
|
256
258
|
if (!this.progress) this.progress = def.progress;
|
|
257
259
|
if (!this.mode) this.mode = def.mode;
|
|
@@ -263,7 +265,7 @@ class UniDM {
|
|
|
263
265
|
if (!this.weight) this.weight = def.weight;
|
|
264
266
|
if (!this.pool) this.pool = def.pool;
|
|
265
267
|
if (!this.attr) this.attr = def.attr;
|
|
266
|
-
if (!this.DMID) this.DMID = this.toDMID();
|
|
268
|
+
if (!this.DMID && false !== this.options.dmid) this.DMID = this.toDMID();
|
|
267
269
|
this.progress = Number.parseFloat(this.progress.toFixed(3));
|
|
268
270
|
if (this.extraStr) this.extraStr = dm_gen_JSON.stringify(cleanEmptyObjects(dm_gen_JSON.parse(this.extraStr)));
|
|
269
271
|
if ('{}' === this.extraStr) this.extraStr = void 0;
|
|
@@ -281,13 +283,13 @@ class UniDM {
|
|
|
281
283
|
async validate() {
|
|
282
284
|
return validateOrReject(this);
|
|
283
285
|
}
|
|
284
|
-
static create(pjson) {
|
|
286
|
+
static create(pjson, options) {
|
|
285
287
|
return pjson ? plainToInstance(UniDM, pjson.extra ? {
|
|
286
288
|
...pjson,
|
|
287
289
|
extraStr: pjson.extra ? dm_gen_JSON.stringify(pjson.extra) : pjson.extraStr
|
|
288
290
|
} : pjson, {
|
|
289
291
|
excludeExtraneousValues: true
|
|
290
|
-
}).init() : new UniDM();
|
|
292
|
+
}).init(options) : new UniDM();
|
|
291
293
|
}
|
|
292
294
|
get extra() {
|
|
293
295
|
const extra = dm_gen_JSON.parse(this.extraStr || '{}');
|
|
@@ -298,7 +300,10 @@ class UniDM {
|
|
|
298
300
|
return false;
|
|
299
301
|
}
|
|
300
302
|
toDMID() {
|
|
301
|
-
|
|
303
|
+
if (false === this.options.dmid) return;
|
|
304
|
+
if (true === this.options.dmid) return createDMID(this.content, this.senderID, this.ctime, this.extraStr);
|
|
305
|
+
if ('number' == typeof this.options.dmid) return createDMID(this.content, this.senderID, this.ctime, this.extraStr, this.options.dmid);
|
|
306
|
+
return this.options.dmid(this.content, this.senderID, this.ctime, this.extraStr);
|
|
302
307
|
}
|
|
303
308
|
isSameAs(dan, options) {
|
|
304
309
|
if (4 === this.mode || 4 === dan.mode) return false;
|
|
@@ -416,7 +421,7 @@ class UniDM {
|
|
|
416
421
|
}
|
|
417
422
|
return mode;
|
|
418
423
|
}
|
|
419
|
-
static fromBili(args, cid) {
|
|
424
|
+
static fromBili(args, cid, options) {
|
|
420
425
|
if (args.oid && !cid) cid = args.oid;
|
|
421
426
|
const SOID = `def_${platform_PlatformVideoSource.Bilibili}+${id_gen_UniID.fromBili({
|
|
422
427
|
cid
|
|
@@ -459,7 +464,7 @@ class UniDM {
|
|
|
459
464
|
}
|
|
460
465
|
return this.create({
|
|
461
466
|
...args,
|
|
462
|
-
SOID
|
|
467
|
+
SOID,
|
|
463
468
|
mode,
|
|
464
469
|
senderID: senderID.toString(),
|
|
465
470
|
ctime: this.transCtime(args.ctime, 's'),
|
|
@@ -468,7 +473,7 @@ class UniDM {
|
|
|
468
473
|
attr: DMAttrUtils.fromBin(args.attr, platform_PlatformVideoSource.Bilibili),
|
|
469
474
|
platform: platform_PlatformVideoSource.Bilibili,
|
|
470
475
|
extra
|
|
471
|
-
});
|
|
476
|
+
}, options);
|
|
472
477
|
}
|
|
473
478
|
toBiliXML(options) {
|
|
474
479
|
if (options?.skipBiliCommand && this.extra.bili?.command) return null;
|
|
@@ -523,16 +528,16 @@ class UniDM {
|
|
|
523
528
|
].join(',')
|
|
524
529
|
};
|
|
525
530
|
}
|
|
526
|
-
static fromBiliCommand(args, cid) {
|
|
531
|
+
static fromBiliCommand(args, cid, options) {
|
|
527
532
|
if (args.oid && !cid) cid = args.oid;
|
|
528
|
-
const SOID = id_gen_UniID.fromBili({
|
|
533
|
+
const SOID = `def_${platform_PlatformVideoSource.Bilibili}+${id_gen_UniID.fromBili({
|
|
529
534
|
cid
|
|
530
|
-
})
|
|
535
|
+
})}`, senderID = id_gen_UniID.fromBili({
|
|
531
536
|
mid: args.mid
|
|
532
537
|
});
|
|
533
538
|
return this.create({
|
|
534
539
|
...args,
|
|
535
|
-
SOID
|
|
540
|
+
SOID,
|
|
536
541
|
mode: 4,
|
|
537
542
|
senderID: senderID.toString(),
|
|
538
543
|
ctime: new Date(`${args.ctime} GMT+0800`),
|
|
@@ -547,9 +552,9 @@ class UniDM {
|
|
|
547
552
|
command: args
|
|
548
553
|
}
|
|
549
554
|
}
|
|
550
|
-
});
|
|
555
|
+
}, options);
|
|
551
556
|
}
|
|
552
|
-
static fromDplayer(args, playerID, domain) {
|
|
557
|
+
static fromDplayer(args, playerID, domain, options) {
|
|
553
558
|
const SOID = id_gen_UniID.fromUnknown(playerID, domain), senderID = id_gen_UniID.fromUnknown(args.midHash, domain);
|
|
554
559
|
return this.create({
|
|
555
560
|
...args,
|
|
@@ -557,7 +562,7 @@ class UniDM {
|
|
|
557
562
|
mode: this.transMode(args.mode, 'dplayer'),
|
|
558
563
|
senderID: senderID.toString(),
|
|
559
564
|
platform: domain
|
|
560
|
-
});
|
|
565
|
+
}, options);
|
|
561
566
|
}
|
|
562
567
|
toDplayer() {
|
|
563
568
|
let mode = 0;
|
|
@@ -571,7 +576,7 @@ class UniDM {
|
|
|
571
576
|
content: this.content
|
|
572
577
|
};
|
|
573
578
|
}
|
|
574
|
-
static fromArtplayer(args, playerID, domain) {
|
|
579
|
+
static fromArtplayer(args, playerID, domain, options) {
|
|
575
580
|
const SOID = id_gen_UniID.fromUnknown(playerID, domain), senderID = id_gen_UniID.fromUnknown('', domain);
|
|
576
581
|
let extra = args.border ? {
|
|
577
582
|
artplayer: {
|
|
@@ -597,7 +602,7 @@ class UniDM {
|
|
|
597
602
|
senderID: senderID.toString(),
|
|
598
603
|
platform: domain,
|
|
599
604
|
extra
|
|
600
|
-
});
|
|
605
|
+
}, options);
|
|
601
606
|
}
|
|
602
607
|
toArtplayer() {
|
|
603
608
|
let mode = 0;
|
|
@@ -611,7 +616,7 @@ class UniDM {
|
|
|
611
616
|
style: this.extra.artplayer?.style
|
|
612
617
|
};
|
|
613
618
|
}
|
|
614
|
-
static fromDDplay(args, episodeId, domain = platform_PlatformDanmakuOnlySource.DanDanPlay) {
|
|
619
|
+
static fromDDplay(args, episodeId, domain = platform_PlatformDanmakuOnlySource.DanDanPlay, options) {
|
|
615
620
|
const SOID = id_gen_UniID.fromUnknown(`def_${platform_PlatformDanmakuOnlySource.DanDanPlay}+${episodeId}`, domain);
|
|
616
621
|
return this.create({
|
|
617
622
|
...args,
|
|
@@ -621,7 +626,7 @@ class UniDM {
|
|
|
621
626
|
content: args.m,
|
|
622
627
|
platform: domain,
|
|
623
628
|
DMID: args.cid.toString()
|
|
624
|
-
});
|
|
629
|
+
}, options);
|
|
625
630
|
}
|
|
626
631
|
toDDplay() {
|
|
627
632
|
let mode = 1;
|
|
@@ -648,6 +653,9 @@ class UniDM {
|
|
|
648
653
|
this.weight = 0;
|
|
649
654
|
this.pool = 0;
|
|
650
655
|
this.attr = [];
|
|
656
|
+
this.options = {
|
|
657
|
+
dmid: createDMID
|
|
658
|
+
};
|
|
651
659
|
}
|
|
652
660
|
}
|
|
653
661
|
_ts_decorate([
|
|
@@ -750,7 +758,9 @@ _ts_decorate([
|
|
|
750
758
|
_ts_decorate([
|
|
751
759
|
Expose(),
|
|
752
760
|
_ts_metadata("design:type", Function),
|
|
753
|
-
_ts_metadata("design:paramtypes", [
|
|
761
|
+
_ts_metadata("design:paramtypes", [
|
|
762
|
+
"undefined" == typeof Options ? Object : Options
|
|
763
|
+
]),
|
|
754
764
|
_ts_metadata("design:returntype", void 0)
|
|
755
765
|
], UniDM.prototype, "init", null);
|
|
756
766
|
_ts_decorate([
|
|
@@ -973,8 +983,8 @@ class UniPool {
|
|
|
973
983
|
platform: s.platform.sort((a, b)=>b.count - a.count)[0].val
|
|
974
984
|
};
|
|
975
985
|
}
|
|
976
|
-
static create() {
|
|
977
|
-
return new UniPool([]);
|
|
986
|
+
static create(options) {
|
|
987
|
+
return new UniPool([], options);
|
|
978
988
|
}
|
|
979
989
|
assign(dans) {
|
|
980
990
|
if (dans instanceof UniPool) return new UniPool([
|
|
@@ -1003,11 +1013,13 @@ class UniPool {
|
|
|
1003
1013
|
}));
|
|
1004
1014
|
}
|
|
1005
1015
|
dedupe() {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1016
|
+
if (false !== this.options.dmid) {
|
|
1017
|
+
const map = new Map();
|
|
1018
|
+
this.dans.forEach((d)=>map.set(d.DMID || d.toDMID(), d));
|
|
1019
|
+
this.dans = [
|
|
1020
|
+
...map.values()
|
|
1021
|
+
];
|
|
1022
|
+
}
|
|
1011
1023
|
this.options.dedupe = false;
|
|
1012
1024
|
}
|
|
1013
1025
|
merge(lifetime = 0) {
|
|
@@ -1136,7 +1148,7 @@ class UniPool {
|
|
|
1136
1148
|
}
|
|
1137
1149
|
}
|
|
1138
1150
|
}
|
|
1139
|
-
static fromPb(bin) {
|
|
1151
|
+
static fromPb(bin, options) {
|
|
1140
1152
|
const data = fromBinary(DanmakuReplySchema, new Uint8Array(bin));
|
|
1141
1153
|
return new UniPool(data.danmakus.map((d)=>UniDM.create({
|
|
1142
1154
|
...d,
|
|
@@ -1144,7 +1156,7 @@ class UniPool {
|
|
|
1144
1156
|
ctime: timestampDate(d.ctime || timestampNow()),
|
|
1145
1157
|
pool: d.pool,
|
|
1146
1158
|
attr: d.attr
|
|
1147
|
-
})));
|
|
1159
|
+
}, options)), options);
|
|
1148
1160
|
}
|
|
1149
1161
|
toPb() {
|
|
1150
1162
|
return toBinary(DanmakuReplySchema, create(DanmakuReplySchema, {
|
|
@@ -1166,7 +1178,7 @@ class UniPool {
|
|
|
1166
1178
|
}))
|
|
1167
1179
|
}));
|
|
1168
1180
|
}
|
|
1169
|
-
static fromBiliXML(xml) {
|
|
1181
|
+
static fromBiliXML(xml, options) {
|
|
1170
1182
|
const parser = new XMLParser({
|
|
1171
1183
|
ignoreAttributes: false
|
|
1172
1184
|
}), oriData = parser.parse(xml), dans = oriData.i.d;
|
|
@@ -1183,8 +1195,8 @@ class UniPool {
|
|
|
1183
1195
|
midHash: p_arr[6],
|
|
1184
1196
|
id: BigInt(p_arr[7]),
|
|
1185
1197
|
weight: Number.parseInt(p_arr[8])
|
|
1186
|
-
}, BigInt(oriData.i.chatid));
|
|
1187
|
-
}).filter((d)=>null !== d));
|
|
1198
|
+
}, BigInt(oriData.i.chatid), options);
|
|
1199
|
+
}).filter((d)=>null !== d), options);
|
|
1188
1200
|
}
|
|
1189
1201
|
toBiliXML() {
|
|
1190
1202
|
const genCID = (id)=>{
|
|
@@ -1215,25 +1227,25 @@ class UniPool {
|
|
|
1215
1227
|
}
|
|
1216
1228
|
});
|
|
1217
1229
|
}
|
|
1218
|
-
static fromBiliGrpc(bin) {
|
|
1230
|
+
static fromBiliGrpc(bin, options) {
|
|
1219
1231
|
const data = fromBinary(DmSegMobileReplySchema, new Uint8Array(bin)), json = data.elems;
|
|
1220
1232
|
return new UniPool(json.map((d)=>UniDM.fromBili({
|
|
1221
1233
|
...d,
|
|
1222
1234
|
progress: d.progress / 1000
|
|
1223
|
-
})));
|
|
1235
|
+
}, d.oid, options)), options);
|
|
1224
1236
|
}
|
|
1225
|
-
static fromBiliCommandGrpc(bin) {
|
|
1237
|
+
static fromBiliCommandGrpc(bin, options) {
|
|
1226
1238
|
const data = fromBinary(DmWebViewReplySchema, new Uint8Array(bin)), json = data.commandDms;
|
|
1227
|
-
return new UniPool(json.map((d)=>UniDM.fromBiliCommand(d)));
|
|
1239
|
+
return new UniPool(json.map((d)=>UniDM.fromBiliCommand(d, d.oid, options)), options);
|
|
1228
1240
|
}
|
|
1229
|
-
static fromDplayer(json, playerID, domain = 'other') {
|
|
1241
|
+
static fromDplayer(json, playerID, domain = 'other', options) {
|
|
1230
1242
|
return new UniPool(json.data.map((d)=>UniDM.fromDplayer({
|
|
1231
1243
|
content: d[4],
|
|
1232
1244
|
progress: d[0],
|
|
1233
1245
|
mode: d[1],
|
|
1234
1246
|
color: d[2],
|
|
1235
1247
|
midHash: d[3]
|
|
1236
|
-
}, playerID, domain)));
|
|
1248
|
+
}, playerID, domain, options)), options);
|
|
1237
1249
|
}
|
|
1238
1250
|
toDplayer() {
|
|
1239
1251
|
return {
|
|
@@ -1250,14 +1262,14 @@ class UniPool {
|
|
|
1250
1262
|
})
|
|
1251
1263
|
};
|
|
1252
1264
|
}
|
|
1253
|
-
static fromArtplayer(json, playerID, domain = 'other') {
|
|
1265
|
+
static fromArtplayer(json, playerID, domain = 'other', options) {
|
|
1254
1266
|
return new UniPool(json.map((d)=>UniDM.fromArtplayer({
|
|
1255
1267
|
content: d.text,
|
|
1256
1268
|
progress: d.time || 0,
|
|
1257
1269
|
mode: d.mode || 0,
|
|
1258
1270
|
color: Number((d.color || 'FFFFFF').replace('#', '0x')),
|
|
1259
1271
|
style: d.style
|
|
1260
|
-
}, playerID, domain)));
|
|
1272
|
+
}, playerID, domain, options)), options);
|
|
1261
1273
|
}
|
|
1262
1274
|
toArtplayer() {
|
|
1263
1275
|
return this.dans.map((dan)=>{
|
|
@@ -1272,7 +1284,7 @@ class UniPool {
|
|
|
1272
1284
|
};
|
|
1273
1285
|
});
|
|
1274
1286
|
}
|
|
1275
|
-
static fromDDPlay(json, episodeId) {
|
|
1287
|
+
static fromDDPlay(json, episodeId, options) {
|
|
1276
1288
|
return new UniPool(json.comments.map((d)=>{
|
|
1277
1289
|
const p_arr = d.p.split(',');
|
|
1278
1290
|
return UniDM.fromDDplay({
|
|
@@ -1282,8 +1294,8 @@ class UniPool {
|
|
|
1282
1294
|
mode: Number.parseInt(p_arr[1]),
|
|
1283
1295
|
progress: Number.parseFloat(p_arr[0]),
|
|
1284
1296
|
uid: p_arr[3]
|
|
1285
|
-
}, episodeId);
|
|
1286
|
-
}));
|
|
1297
|
+
}, episodeId, void 0, options);
|
|
1298
|
+
}), options);
|
|
1287
1299
|
}
|
|
1288
1300
|
toDDplay() {
|
|
1289
1301
|
return {
|
|
@@ -1625,7 +1637,7 @@ function raw_raw(list, config, context, compressType = 'brotli', baseType = 'bas
|
|
|
1625
1637
|
config,
|
|
1626
1638
|
context
|
|
1627
1639
|
}, rawText = JSON.stringify(raw1);
|
|
1628
|
-
let compress
|
|
1640
|
+
let compress;
|
|
1629
1641
|
compress = 'brotli' === compressType ? brotliCompressSync(rawText) : gzipSync(rawText);
|
|
1630
1642
|
return `;RawCompressType: ${compressType}\n;RawBaseType: ${baseType}\n;Raw: ${'base64' === baseType ? compress.toString('base64') : fromUint16Array(external_base16384_encode(compress))}`;
|
|
1631
1643
|
}
|
|
@@ -1637,7 +1649,7 @@ function deRaw(ass) {
|
|
|
1637
1649
|
if (!compressTypes.includes(compressType)) compressType = 'gzip';
|
|
1638
1650
|
if (!baseTypes.includes(baseType)) baseType = 'base64';
|
|
1639
1651
|
const text = lineRaw.replace(';Raw: ', '').trim(), buffer = 'base64' === baseType ? Buffer.from(text, 'base64') : Buffer.from(decode(Buffer.from(text, 'utf-8').toString('utf-8')));
|
|
1640
|
-
let decompress
|
|
1652
|
+
let decompress;
|
|
1641
1653
|
decompress = 'brotli' === compressType ? brotliDecompressSync(buffer) : gunzipSync(buffer);
|
|
1642
1654
|
try {
|
|
1643
1655
|
return JSON.parse(decompress.toString('utf-8'));
|
|
@@ -1899,8 +1911,8 @@ class src_UniPool {
|
|
|
1899
1911
|
platform: s.platform.sort((a, b)=>b.count - a.count)[0].val
|
|
1900
1912
|
};
|
|
1901
1913
|
}
|
|
1902
|
-
static create() {
|
|
1903
|
-
return new src_UniPool([]);
|
|
1914
|
+
static create(options) {
|
|
1915
|
+
return new src_UniPool([], options);
|
|
1904
1916
|
}
|
|
1905
1917
|
assign(dans) {
|
|
1906
1918
|
if (dans instanceof src_UniPool) return new src_UniPool([
|
|
@@ -1929,11 +1941,13 @@ class src_UniPool {
|
|
|
1929
1941
|
}));
|
|
1930
1942
|
}
|
|
1931
1943
|
dedupe() {
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1944
|
+
if (false !== this.options.dmid) {
|
|
1945
|
+
const map = new Map();
|
|
1946
|
+
this.dans.forEach((d)=>map.set(d.DMID || d.toDMID(), d));
|
|
1947
|
+
this.dans = [
|
|
1948
|
+
...map.values()
|
|
1949
|
+
];
|
|
1950
|
+
}
|
|
1937
1951
|
this.options.dedupe = false;
|
|
1938
1952
|
}
|
|
1939
1953
|
merge(lifetime = 0) {
|
|
@@ -2062,7 +2076,7 @@ class src_UniPool {
|
|
|
2062
2076
|
}
|
|
2063
2077
|
}
|
|
2064
2078
|
}
|
|
2065
|
-
static fromPb(bin) {
|
|
2079
|
+
static fromPb(bin, options) {
|
|
2066
2080
|
const data = fromBinary(DanmakuReplySchema, new Uint8Array(bin));
|
|
2067
2081
|
return new src_UniPool(data.danmakus.map((d)=>UniDM.create({
|
|
2068
2082
|
...d,
|
|
@@ -2070,7 +2084,7 @@ class src_UniPool {
|
|
|
2070
2084
|
ctime: timestampDate(d.ctime || timestampNow()),
|
|
2071
2085
|
pool: d.pool,
|
|
2072
2086
|
attr: d.attr
|
|
2073
|
-
})));
|
|
2087
|
+
}, options)), options);
|
|
2074
2088
|
}
|
|
2075
2089
|
toPb() {
|
|
2076
2090
|
return toBinary(DanmakuReplySchema, create(DanmakuReplySchema, {
|
|
@@ -2092,7 +2106,7 @@ class src_UniPool {
|
|
|
2092
2106
|
}))
|
|
2093
2107
|
}));
|
|
2094
2108
|
}
|
|
2095
|
-
static fromBiliXML(xml) {
|
|
2109
|
+
static fromBiliXML(xml, options) {
|
|
2096
2110
|
const parser = new XMLParser({
|
|
2097
2111
|
ignoreAttributes: false
|
|
2098
2112
|
}), oriData = parser.parse(xml), dans = oriData.i.d;
|
|
@@ -2109,8 +2123,8 @@ class src_UniPool {
|
|
|
2109
2123
|
midHash: p_arr[6],
|
|
2110
2124
|
id: BigInt(p_arr[7]),
|
|
2111
2125
|
weight: Number.parseInt(p_arr[8])
|
|
2112
|
-
}, BigInt(oriData.i.chatid));
|
|
2113
|
-
}).filter((d)=>null !== d));
|
|
2126
|
+
}, BigInt(oriData.i.chatid), options);
|
|
2127
|
+
}).filter((d)=>null !== d), options);
|
|
2114
2128
|
}
|
|
2115
2129
|
toBiliXML() {
|
|
2116
2130
|
const genCID = (id)=>{
|
|
@@ -2141,25 +2155,25 @@ class src_UniPool {
|
|
|
2141
2155
|
}
|
|
2142
2156
|
});
|
|
2143
2157
|
}
|
|
2144
|
-
static fromBiliGrpc(bin) {
|
|
2158
|
+
static fromBiliGrpc(bin, options) {
|
|
2145
2159
|
const data = fromBinary(DmSegMobileReplySchema, new Uint8Array(bin)), json = data.elems;
|
|
2146
2160
|
return new src_UniPool(json.map((d)=>UniDM.fromBili({
|
|
2147
2161
|
...d,
|
|
2148
2162
|
progress: d.progress / 1000
|
|
2149
|
-
})));
|
|
2163
|
+
}, d.oid, options)), options);
|
|
2150
2164
|
}
|
|
2151
|
-
static fromBiliCommandGrpc(bin) {
|
|
2165
|
+
static fromBiliCommandGrpc(bin, options) {
|
|
2152
2166
|
const data = fromBinary(DmWebViewReplySchema, new Uint8Array(bin)), json = data.commandDms;
|
|
2153
|
-
return new src_UniPool(json.map((d)=>UniDM.fromBiliCommand(d)));
|
|
2167
|
+
return new src_UniPool(json.map((d)=>UniDM.fromBiliCommand(d, d.oid, options)), options);
|
|
2154
2168
|
}
|
|
2155
|
-
static fromDplayer(json, playerID, domain = 'other') {
|
|
2169
|
+
static fromDplayer(json, playerID, domain = 'other', options) {
|
|
2156
2170
|
return new src_UniPool(json.data.map((d)=>UniDM.fromDplayer({
|
|
2157
2171
|
content: d[4],
|
|
2158
2172
|
progress: d[0],
|
|
2159
2173
|
mode: d[1],
|
|
2160
2174
|
color: d[2],
|
|
2161
2175
|
midHash: d[3]
|
|
2162
|
-
}, playerID, domain)));
|
|
2176
|
+
}, playerID, domain, options)), options);
|
|
2163
2177
|
}
|
|
2164
2178
|
toDplayer() {
|
|
2165
2179
|
return {
|
|
@@ -2176,14 +2190,14 @@ class src_UniPool {
|
|
|
2176
2190
|
})
|
|
2177
2191
|
};
|
|
2178
2192
|
}
|
|
2179
|
-
static fromArtplayer(json, playerID, domain = 'other') {
|
|
2193
|
+
static fromArtplayer(json, playerID, domain = 'other', options) {
|
|
2180
2194
|
return new src_UniPool(json.map((d)=>UniDM.fromArtplayer({
|
|
2181
2195
|
content: d.text,
|
|
2182
2196
|
progress: d.time || 0,
|
|
2183
2197
|
mode: d.mode || 0,
|
|
2184
2198
|
color: Number((d.color || 'FFFFFF').replace('#', '0x')),
|
|
2185
2199
|
style: d.style
|
|
2186
|
-
}, playerID, domain)));
|
|
2200
|
+
}, playerID, domain, options)), options);
|
|
2187
2201
|
}
|
|
2188
2202
|
toArtplayer() {
|
|
2189
2203
|
return this.dans.map((dan)=>{
|
|
@@ -2198,7 +2212,7 @@ class src_UniPool {
|
|
|
2198
2212
|
};
|
|
2199
2213
|
});
|
|
2200
2214
|
}
|
|
2201
|
-
static fromDDPlay(json, episodeId) {
|
|
2215
|
+
static fromDDPlay(json, episodeId, options) {
|
|
2202
2216
|
return new src_UniPool(json.comments.map((d)=>{
|
|
2203
2217
|
const p_arr = d.p.split(',');
|
|
2204
2218
|
return UniDM.fromDDplay({
|
|
@@ -2208,8 +2222,8 @@ class src_UniPool {
|
|
|
2208
2222
|
mode: Number.parseInt(p_arr[1]),
|
|
2209
2223
|
progress: Number.parseFloat(p_arr[0]),
|
|
2210
2224
|
uid: p_arr[3]
|
|
2211
|
-
}, episodeId);
|
|
2212
|
-
}));
|
|
2225
|
+
}, episodeId, void 0, options);
|
|
2226
|
+
}), options);
|
|
2213
2227
|
}
|
|
2214
2228
|
toDDplay() {
|
|
2215
2229
|
return {
|