@dan-uni/dan-any 1.3.8 → 1.4.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/dist/browser/index.min.js +97 -12
- package/dist/browser/plugins/bili.min.js +1 -77
- package/dist/browser/plugins/index.min.js +1 -1
- package/dist/browser/plugins/stats.min.js +1 -1
- package/dist/browser/src/index.d.ts +5 -0
- package/dist/node/{rslib-runtime.js → 0~rslib-runtime.js} +1 -15
- package/dist/node/index.js +93 -7
- package/dist/node/plugins/bili.js +1 -77
- package/dist/node/plugins/index.js +1 -1
- package/dist/node/plugins/stats.js +1 -1
- package/dist/node/src/index.d.ts +5 -0
- package/dist/umd/index.umd.min.js +16777 -11984
- package/dist/umd/plugins/bili.umd.min.js +5628 -5492
- package/dist/umd/plugins/index.umd.min.js +428 -296
- package/dist/umd/src/index.d.ts +5 -0
- package/package.json +5 -5
- package/src/index.ts +8 -1
- package/src/plugins/bili/dedupe.ts +1 -1
- package/src/utils/dm-gen.ts +4 -1
- package/tsconfig.json +10 -8
- package/types/tsconfig.tsbuildinfo +1 -1
- /package/dist/browser/{rslib-runtime.min.js → 1~rslib-runtime.min.js} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/*! LICENSE: index.min.js.LICENSE.txt */
|
|
2
|
-
import { __webpack_require__ } from "./rslib-runtime.min.js";
|
|
3
2
|
import "reflect-metadata/lite";
|
|
4
3
|
import { IsDate, IsEmail, IsEnum, IsInt, IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min, isEmail, isJSON, isString, validateOrReject } from "class-validator";
|
|
5
4
|
import { XMLBuilder, XMLParser } from "fast-xml-parser";
|
|
@@ -9,8 +8,11 @@ import { file_google_protobuf_timestamp, timestampDate, timestampFromDate, times
|
|
|
9
8
|
import { Expose, plainToInstance } from "class-transformer";
|
|
10
9
|
import hh_mm_ss from "hh-mm-ss";
|
|
11
10
|
import jssha from "jssha";
|
|
12
|
-
import { decode, encode as external_base16384_encode } from "base16384";
|
|
13
11
|
import { fileDesc, messageDesc as codegenv2_messageDesc } from "@bufbuild/protobuf/codegenv2";
|
|
12
|
+
import { DateTime } from "luxon";
|
|
13
|
+
import { __webpack_require__ } from "./1~rslib-runtime.min.js";
|
|
14
|
+
import "./plugins/stats.min.js";
|
|
15
|
+
import * as __rspack_external_base16384 from "base16384";
|
|
14
16
|
__webpack_require__.add({
|
|
15
17
|
"../../node_modules/.pnpm/assert@2.1.0/node_modules/assert/build/assert.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
16
18
|
var process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
|
|
@@ -1234,7 +1236,6 @@ __webpack_require__.add({
|
|
|
1234
1236
|
if (y < x) return 1;
|
|
1235
1237
|
return 0;
|
|
1236
1238
|
}
|
|
1237
|
-
var ONLY_ENUMERABLE = void 0;
|
|
1238
1239
|
var kStrict = true;
|
|
1239
1240
|
var kLoose = false;
|
|
1240
1241
|
var kNoIterator = 0;
|
|
@@ -1284,8 +1285,8 @@ __webpack_require__.add({
|
|
|
1284
1285
|
if (val1Tag !== val2Tag) return false;
|
|
1285
1286
|
if (Array.isArray(val1)) {
|
|
1286
1287
|
if (val1.length !== val2.length) return false;
|
|
1287
|
-
var keys1 = getOwnNonIndexProperties(val1
|
|
1288
|
-
var keys2 = getOwnNonIndexProperties(val2
|
|
1288
|
+
var keys1 = getOwnNonIndexProperties(val1);
|
|
1289
|
+
var keys2 = getOwnNonIndexProperties(val2);
|
|
1289
1290
|
if (keys1.length !== keys2.length) return false;
|
|
1290
1291
|
return keyCheck(val1, val2, strict, memos, kIsArray, keys1);
|
|
1291
1292
|
}
|
|
@@ -1302,8 +1303,8 @@ __webpack_require__.add({
|
|
|
1302
1303
|
if (!strict && (isFloat32Array(val1) || isFloat64Array(val1))) {
|
|
1303
1304
|
if (!areSimilarFloatArrays(val1, val2)) return false;
|
|
1304
1305
|
} else if (!areSimilarTypedArrays(val1, val2)) return false;
|
|
1305
|
-
var _keys = getOwnNonIndexProperties(val1
|
|
1306
|
-
var _keys2 = getOwnNonIndexProperties(val2
|
|
1306
|
+
var _keys = getOwnNonIndexProperties(val1);
|
|
1307
|
+
var _keys2 = getOwnNonIndexProperties(val2);
|
|
1307
1308
|
if (_keys.length !== _keys2.length) return false;
|
|
1308
1309
|
return keyCheck(val1, val2, strict, memos, kNoIterator, _keys);
|
|
1309
1310
|
} else if (isSet(val1)) {
|
|
@@ -11433,6 +11434,24 @@ __webpack_require__.add({
|
|
|
11433
11434
|
};
|
|
11434
11435
|
}
|
|
11435
11436
|
});
|
|
11437
|
+
var dedupe_namespaceObject = {};
|
|
11438
|
+
__webpack_require__.r(dedupe_namespaceObject);
|
|
11439
|
+
__webpack_require__.d(dedupe_namespaceObject, {
|
|
11440
|
+
bili_dedupe: ()=>bili_dedupe,
|
|
11441
|
+
to_bili_deduped: ()=>to_bili_deduped
|
|
11442
|
+
});
|
|
11443
|
+
var bili_namespaceObject = {};
|
|
11444
|
+
__webpack_require__.r(bili_namespaceObject);
|
|
11445
|
+
__webpack_require__.d(bili_namespaceObject, {
|
|
11446
|
+
bili_dedupe: ()=>dedupe_namespaceObject,
|
|
11447
|
+
bili_history_fast_forward: ()=>bili_history_fast_forward
|
|
11448
|
+
});
|
|
11449
|
+
var plugins_namespaceObject = {};
|
|
11450
|
+
__webpack_require__.r(plugins_namespaceObject);
|
|
11451
|
+
__webpack_require__.d(plugins_namespaceObject, {
|
|
11452
|
+
bili: ()=>bili_namespaceObject,
|
|
11453
|
+
stats: ()=>stats_namespaceObject
|
|
11454
|
+
});
|
|
11436
11455
|
var dm_gen_namespaceObject = {};
|
|
11437
11456
|
__webpack_require__.r(dm_gen_namespaceObject);
|
|
11438
11457
|
__webpack_require__.d(dm_gen_namespaceObject, {
|
|
@@ -11461,7 +11480,7 @@ __webpack_require__.d(platform_namespaceObject, {
|
|
|
11461
11480
|
PlatformVideoSource: ()=>platform_PlatformVideoSource,
|
|
11462
11481
|
PlatformVideoSources: ()=>PlatformVideoSources
|
|
11463
11482
|
});
|
|
11464
|
-
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.
|
|
11483
|
+
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.4.0","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
|
|
11465
11484
|
const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
|
|
11466
11485
|
const decimalToHex = (n)=>color_pad(n.toString(16));
|
|
11467
11486
|
const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
|
|
@@ -12017,6 +12036,9 @@ class UniDM {
|
|
|
12017
12036
|
platform: platform_PlatformVideoSource.Bilibili,
|
|
12018
12037
|
extra: {
|
|
12019
12038
|
bili: {
|
|
12039
|
+
dmid: args.id,
|
|
12040
|
+
attr: args.attr,
|
|
12041
|
+
mid: args.mid,
|
|
12020
12042
|
command: args
|
|
12021
12043
|
}
|
|
12022
12044
|
}
|
|
@@ -12585,7 +12607,7 @@ function raw_raw(list, config, context, compressType = 'brotli', baseType = 'bas
|
|
|
12585
12607
|
const rawText = JSON.stringify(raw1);
|
|
12586
12608
|
let compress;
|
|
12587
12609
|
compress = 'brotli' === compressType ? (0, lib.brotliCompressSync)(rawText) : (0, lib.gzipSync)(rawText);
|
|
12588
|
-
return `;RawCompressType: ${compressType}\n;RawBaseType: ${baseType}\n;Raw: ${'base64' === baseType ? compress.toString('base64') : fromUint16Array(
|
|
12610
|
+
return `;RawCompressType: ${compressType}\n;RawBaseType: ${baseType}\n;Raw: ${'base64' === baseType ? compress.toString('base64') : fromUint16Array(__rspack_external_base16384.encode(compress))}`;
|
|
12589
12611
|
}
|
|
12590
12612
|
function deRaw(ass) {
|
|
12591
12613
|
const arr = ass.split('\n');
|
|
@@ -12599,7 +12621,7 @@ function deRaw(ass) {
|
|
|
12599
12621
|
if (!compressTypes.has(compressType)) compressType = 'gzip';
|
|
12600
12622
|
if (!baseTypes.has(baseType)) baseType = 'base64';
|
|
12601
12623
|
const text = lineRaw.replace(';Raw: ', '').trim();
|
|
12602
|
-
const buffer = 'base64' === baseType ? raw_Buffer.from(text, 'base64') : raw_Buffer.from(decode(raw_Buffer.from(text, 'utf8').toString('utf8')));
|
|
12624
|
+
const buffer = 'base64' === baseType ? raw_Buffer.from(text, 'base64') : raw_Buffer.from(__rspack_external_base16384.decode(raw_Buffer.from(text, 'utf8').toString('utf8')));
|
|
12603
12625
|
let decompress;
|
|
12604
12626
|
decompress = 'brotli' === compressType ? (0, lib.brotliDecompressSync)(buffer) : (0, lib.gunzipSync)(buffer);
|
|
12605
12627
|
try {
|
|
@@ -12747,6 +12769,67 @@ function fileParser(file, mod) {
|
|
|
12747
12769
|
throw new Error(`Unsupported mod "${mod}"`);
|
|
12748
12770
|
}
|
|
12749
12771
|
}
|
|
12772
|
+
function main(that) {
|
|
12773
|
+
that.dans.forEach((d)=>{
|
|
12774
|
+
if (d.platform !== platform_PlatformVideoSource.Bilibili) throw new Error('bili-dedupe: 仅支持B站(主站)的弹幕');
|
|
12775
|
+
if (!d.extra.bili?.dmid && !d.extra.bili?.command?.id) throw new Error('bili-dedupe: 弹幕缺少bili extra dmid字段');
|
|
12776
|
+
});
|
|
12777
|
+
const map = new Map();
|
|
12778
|
+
that.dans.forEach((d)=>map.set(d.extra.bili.dmid, d));
|
|
12779
|
+
return map;
|
|
12780
|
+
}
|
|
12781
|
+
function to_bili_deduped(that) {
|
|
12782
|
+
const map = main(that);
|
|
12783
|
+
return new UniPool([
|
|
12784
|
+
...map.values()
|
|
12785
|
+
], that.options, that.info);
|
|
12786
|
+
}
|
|
12787
|
+
function bili_dedupe(that) {
|
|
12788
|
+
const map = main(that);
|
|
12789
|
+
that.dans = [
|
|
12790
|
+
...map.values()
|
|
12791
|
+
];
|
|
12792
|
+
}
|
|
12793
|
+
function history_danmaku_fast_forward_main(that, query_history_date) {
|
|
12794
|
+
const qhd = DateTime.fromFormat(query_history_date, 'yyyy-MM-dd', {
|
|
12795
|
+
zone: 'Asia/Shanghai'
|
|
12796
|
+
}).setZone('Asia/Shanghai');
|
|
12797
|
+
if (!qhd.isValid) throw new Error('Invalid query_history_date');
|
|
12798
|
+
const s = qhd.startOf('day');
|
|
12799
|
+
const before = that.dans.filter((d)=>d.ctime < s.toJSDate());
|
|
12800
|
+
if (0 === before.length) return {
|
|
12801
|
+
earliest: null,
|
|
12802
|
+
FastForward: [],
|
|
12803
|
+
skip: [],
|
|
12804
|
+
SpecificDate: qhd.toFormat('yyyy-MM-dd')
|
|
12805
|
+
};
|
|
12806
|
+
const earliestCtime = before.toSorted((a, b)=>a.ctime.getTime() - b.ctime.getTime())[0].ctime;
|
|
12807
|
+
const earliestDate = DateTime.fromJSDate(earliestCtime).setZone('Asia/Shanghai').startOf('day');
|
|
12808
|
+
const datesWithDanmaku = new Set();
|
|
12809
|
+
for (const dan of before){
|
|
12810
|
+
const dateStr = DateTime.fromJSDate(dan.ctime).setZone('Asia/Shanghai').toFormat('yyyy-MM-dd');
|
|
12811
|
+
datesWithDanmaku.add(dateStr);
|
|
12812
|
+
}
|
|
12813
|
+
let current = earliestDate;
|
|
12814
|
+
const allDates = [];
|
|
12815
|
+
while(current < s){
|
|
12816
|
+
allDates.push(current.toFormat('yyyy-MM-dd'));
|
|
12817
|
+
current = current.plus({
|
|
12818
|
+
days: 1
|
|
12819
|
+
});
|
|
12820
|
+
}
|
|
12821
|
+
const FastForward = allDates.filter((d)=>datesWithDanmaku.has(d));
|
|
12822
|
+
const skip = allDates.filter((d)=>!datesWithDanmaku.has(d));
|
|
12823
|
+
return {
|
|
12824
|
+
earliest: earliestDate.toFormat('yyyy-MM-dd'),
|
|
12825
|
+
FastForward,
|
|
12826
|
+
skip,
|
|
12827
|
+
SpecificDate: qhd.toFormat('yyyy-MM-dd')
|
|
12828
|
+
};
|
|
12829
|
+
}
|
|
12830
|
+
function bili_history_fast_forward(query_history_date) {
|
|
12831
|
+
return (that)=>history_danmaku_fast_forward_main(that, query_history_date);
|
|
12832
|
+
}
|
|
12750
12833
|
const src_JSON = json_bigint({
|
|
12751
12834
|
useNativeBigInt: true
|
|
12752
12835
|
});
|
|
@@ -13254,6 +13337,8 @@ class UniPool {
|
|
|
13254
13337
|
const ok = this.dans.every((d)=>d.senderID.endsWith(`@${platform_PlatformVideoSource.Bilibili}`));
|
|
13255
13338
|
if (!ok) throw new Error('存在其他来源的senderID,请关闭该功能再试!');
|
|
13256
13339
|
}
|
|
13340
|
+
let ds = this.dans.map((dan)=>dan.toBiliXML(options));
|
|
13341
|
+
if (options?.skipBiliCommand) ds = ds.filter((d)=>null !== d);
|
|
13257
13342
|
const builder = new XMLBuilder({
|
|
13258
13343
|
ignoreAttributes: false
|
|
13259
13344
|
});
|
|
@@ -13274,7 +13359,7 @@ class UniPool {
|
|
|
13274
13359
|
...DanUniConvertTipTemplate,
|
|
13275
13360
|
data: this.getShared('SOID')
|
|
13276
13361
|
},
|
|
13277
|
-
d:
|
|
13362
|
+
d: ds
|
|
13278
13363
|
}
|
|
13279
13364
|
});
|
|
13280
13365
|
}
|
|
@@ -13419,4 +13504,4 @@ class UniPool {
|
|
|
13419
13504
|
}, canvasCtx);
|
|
13420
13505
|
}
|
|
13421
13506
|
}
|
|
13422
|
-
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools,
|
|
13507
|
+
export { UniDM, UniPool, bili_history_fast_forward, bili_namespaceObject as bili, dedupe_namespaceObject as bili_dedupe, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_namespaceObject as platform, plugins_namespaceObject as plugins, src_DM_format as DM_format };
|
|
@@ -1,77 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { DateTime } from "luxon";
|
|
3
|
-
import { UniPool, platform_PlatformVideoSource } from "../index.min.js";
|
|
4
|
-
var dedupe_namespaceObject = {};
|
|
5
|
-
__webpack_require__.r(dedupe_namespaceObject);
|
|
6
|
-
__webpack_require__.d(dedupe_namespaceObject, {
|
|
7
|
-
bili_dedupe: ()=>bili_dedupe,
|
|
8
|
-
to_bili_deduped: ()=>to_bili_deduped
|
|
9
|
-
});
|
|
10
|
-
var bili_namespaceObject = {};
|
|
11
|
-
__webpack_require__.r(bili_namespaceObject);
|
|
12
|
-
__webpack_require__.d(bili_namespaceObject, {
|
|
13
|
-
bili_dedupe: ()=>dedupe_namespaceObject,
|
|
14
|
-
bili_history_fast_forward: ()=>bili_history_fast_forward
|
|
15
|
-
});
|
|
16
|
-
function main(that) {
|
|
17
|
-
that.dans.forEach((d)=>{
|
|
18
|
-
if (d.platform !== platform_PlatformVideoSource.Bilibili) throw new Error('bili-dedupe: 仅支持B站(主站)的弹幕');
|
|
19
|
-
if (!d.extra.bili?.dmid) throw new Error('bili-dedupe: 弹幕缺少bili extra dmid字段');
|
|
20
|
-
});
|
|
21
|
-
const map = new Map();
|
|
22
|
-
that.dans.forEach((d)=>map.set(d.extra.bili.dmid, d));
|
|
23
|
-
return map;
|
|
24
|
-
}
|
|
25
|
-
function to_bili_deduped(that) {
|
|
26
|
-
const map = main(that);
|
|
27
|
-
return new UniPool([
|
|
28
|
-
...map.values()
|
|
29
|
-
], that.options, that.info);
|
|
30
|
-
}
|
|
31
|
-
function bili_dedupe(that) {
|
|
32
|
-
const map = main(that);
|
|
33
|
-
that.dans = [
|
|
34
|
-
...map.values()
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
function history_danmaku_fast_forward_main(that, query_history_date) {
|
|
38
|
-
const qhd = DateTime.fromFormat(query_history_date, 'yyyy-MM-dd', {
|
|
39
|
-
zone: 'Asia/Shanghai'
|
|
40
|
-
}).setZone('Asia/Shanghai');
|
|
41
|
-
if (!qhd.isValid) throw new Error('Invalid query_history_date');
|
|
42
|
-
const s = qhd.startOf('day');
|
|
43
|
-
const before = that.dans.filter((d)=>d.ctime < s.toJSDate());
|
|
44
|
-
if (0 === before.length) return {
|
|
45
|
-
earliest: null,
|
|
46
|
-
FastForward: [],
|
|
47
|
-
skip: [],
|
|
48
|
-
SpecificDate: qhd.toFormat('yyyy-MM-dd')
|
|
49
|
-
};
|
|
50
|
-
const earliestCtime = before.toSorted((a, b)=>a.ctime.getTime() - b.ctime.getTime())[0].ctime;
|
|
51
|
-
const earliestDate = DateTime.fromJSDate(earliestCtime).setZone('Asia/Shanghai').startOf('day');
|
|
52
|
-
const datesWithDanmaku = new Set();
|
|
53
|
-
for (const dan of before){
|
|
54
|
-
const dateStr = DateTime.fromJSDate(dan.ctime).setZone('Asia/Shanghai').toFormat('yyyy-MM-dd');
|
|
55
|
-
datesWithDanmaku.add(dateStr);
|
|
56
|
-
}
|
|
57
|
-
let current = earliestDate;
|
|
58
|
-
const allDates = [];
|
|
59
|
-
while(current < s){
|
|
60
|
-
allDates.push(current.toFormat('yyyy-MM-dd'));
|
|
61
|
-
current = current.plus({
|
|
62
|
-
days: 1
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const FastForward = allDates.filter((d)=>datesWithDanmaku.has(d));
|
|
66
|
-
const skip = allDates.filter((d)=>!datesWithDanmaku.has(d));
|
|
67
|
-
return {
|
|
68
|
-
earliest: earliestDate.toFormat('yyyy-MM-dd'),
|
|
69
|
-
FastForward,
|
|
70
|
-
skip,
|
|
71
|
-
SpecificDate: qhd.toFormat('yyyy-MM-dd')
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function bili_history_fast_forward(query_history_date) {
|
|
75
|
-
return (that)=>history_danmaku_fast_forward_main(that, query_history_date);
|
|
76
|
-
}
|
|
77
|
-
export { bili_history_fast_forward, bili_namespaceObject as bili, dedupe_namespaceObject as bili_dedupe };
|
|
1
|
+
export { bili_dedupe, bili_history_fast_forward } from "../index.min.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { bili } from "
|
|
1
|
+
export { bili } from "../index.min.js";
|
|
2
2
|
export { stats } from "./stats.min.js";
|
|
@@ -237,6 +237,10 @@ export declare class UniPool {
|
|
|
237
237
|
* 当SOID非来源bili时,若此处指定则使用该值为cid,否则使用SOID
|
|
238
238
|
*/
|
|
239
239
|
cid?: bigint;
|
|
240
|
+
/**
|
|
241
|
+
* 跳过command类型的特殊弹幕
|
|
242
|
+
*/
|
|
243
|
+
skipBiliCommand?: boolean;
|
|
240
244
|
/**
|
|
241
245
|
* 当仅含有来自bili的弹幕时,启用将保持发送者标识不含`@`
|
|
242
246
|
* @description
|
|
@@ -275,3 +279,4 @@ export declare class UniPool {
|
|
|
275
279
|
toASS(canvasCtx: CanvasCtx, options?: AssGenOptions): string;
|
|
276
280
|
}
|
|
277
281
|
export { platform, UniDM, UniDMTools, UniIDTools, type DM_JSON_BiliCommandGrpc, };
|
|
282
|
+
export * as plugins from './plugins';
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
function __webpack_require__(moduleId) {
|
|
3
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
4
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
5
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
6
|
-
exports: {}
|
|
7
|
-
};
|
|
8
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
9
|
-
return module.exports;
|
|
10
|
-
}
|
|
1
|
+
var __webpack_require__ = {};
|
|
11
2
|
(()=>{
|
|
12
3
|
__webpack_require__.d = (exports, definition)=>{
|
|
13
4
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
@@ -16,11 +7,6 @@ function __webpack_require__(moduleId) {
|
|
|
16
7
|
});
|
|
17
8
|
};
|
|
18
9
|
})();
|
|
19
|
-
(()=>{
|
|
20
|
-
__webpack_require__.add = function(modules) {
|
|
21
|
-
Object.assign(__webpack_require__.m, modules);
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
10
|
(()=>{
|
|
25
11
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
12
|
})();
|
package/dist/node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
1
|
+
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
2
2
|
import "reflect-metadata/lite";
|
|
3
3
|
import { IsDate, IsEmail, IsEnum, IsInt, IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min, isEmail, isJSON, isString, validateOrReject } from "class-validator";
|
|
4
4
|
import { XMLBuilder, XMLParser } from "fast-xml-parser";
|
|
@@ -9,8 +9,28 @@ import { Expose, plainToInstance } from "class-transformer";
|
|
|
9
9
|
import hh_mm_ss from "hh-mm-ss";
|
|
10
10
|
import jssha from "jssha";
|
|
11
11
|
import { brotliCompressSync, brotliDecompressSync, gunzipSync, gzipSync } from "node:zlib";
|
|
12
|
-
import { decode, encode as external_base16384_encode } from "base16384";
|
|
13
12
|
import { fileDesc, messageDesc as codegenv2_messageDesc } from "@bufbuild/protobuf/codegenv2";
|
|
13
|
+
import { DateTime } from "luxon";
|
|
14
|
+
import "./plugins/stats.js";
|
|
15
|
+
import * as __rspack_external_base16384 from "base16384";
|
|
16
|
+
var dedupe_namespaceObject = {};
|
|
17
|
+
__webpack_require__.r(dedupe_namespaceObject);
|
|
18
|
+
__webpack_require__.d(dedupe_namespaceObject, {
|
|
19
|
+
bili_dedupe: ()=>bili_dedupe,
|
|
20
|
+
to_bili_deduped: ()=>to_bili_deduped
|
|
21
|
+
});
|
|
22
|
+
var bili_namespaceObject = {};
|
|
23
|
+
__webpack_require__.r(bili_namespaceObject);
|
|
24
|
+
__webpack_require__.d(bili_namespaceObject, {
|
|
25
|
+
bili_dedupe: ()=>dedupe_namespaceObject,
|
|
26
|
+
bili_history_fast_forward: ()=>bili_history_fast_forward
|
|
27
|
+
});
|
|
28
|
+
var plugins_namespaceObject = {};
|
|
29
|
+
__webpack_require__.r(plugins_namespaceObject);
|
|
30
|
+
__webpack_require__.d(plugins_namespaceObject, {
|
|
31
|
+
bili: ()=>bili_namespaceObject,
|
|
32
|
+
stats: ()=>stats_namespaceObject
|
|
33
|
+
});
|
|
14
34
|
var dm_gen_namespaceObject = {};
|
|
15
35
|
__webpack_require__.r(dm_gen_namespaceObject);
|
|
16
36
|
__webpack_require__.d(dm_gen_namespaceObject, {
|
|
@@ -39,7 +59,7 @@ __webpack_require__.d(platform_namespaceObject, {
|
|
|
39
59
|
PlatformVideoSource: ()=>platform_PlatformVideoSource,
|
|
40
60
|
PlatformVideoSources: ()=>PlatformVideoSources
|
|
41
61
|
});
|
|
42
|
-
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.
|
|
62
|
+
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.4.0","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
|
|
43
63
|
const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
|
|
44
64
|
const decimalToHex = (n)=>color_pad(n.toString(16));
|
|
45
65
|
const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
|
|
@@ -594,6 +614,9 @@ class UniDM {
|
|
|
594
614
|
platform: platform_PlatformVideoSource.Bilibili,
|
|
595
615
|
extra: {
|
|
596
616
|
bili: {
|
|
617
|
+
dmid: args.id,
|
|
618
|
+
attr: args.attr,
|
|
619
|
+
mid: args.mid,
|
|
597
620
|
command: args
|
|
598
621
|
}
|
|
599
622
|
}
|
|
@@ -1160,7 +1183,7 @@ function raw_raw(list, config, context, compressType = 'brotli', baseType = 'bas
|
|
|
1160
1183
|
const rawText = JSON.stringify(raw1);
|
|
1161
1184
|
let compress;
|
|
1162
1185
|
compress = 'brotli' === compressType ? brotliCompressSync(rawText) : gzipSync(rawText);
|
|
1163
|
-
return `;RawCompressType: ${compressType}\n;RawBaseType: ${baseType}\n;Raw: ${'base64' === baseType ? compress.toString('base64') : fromUint16Array(
|
|
1186
|
+
return `;RawCompressType: ${compressType}\n;RawBaseType: ${baseType}\n;Raw: ${'base64' === baseType ? compress.toString('base64') : fromUint16Array(__rspack_external_base16384.encode(compress))}`;
|
|
1164
1187
|
}
|
|
1165
1188
|
function deRaw(ass) {
|
|
1166
1189
|
const arr = ass.split('\n');
|
|
@@ -1174,7 +1197,7 @@ function deRaw(ass) {
|
|
|
1174
1197
|
if (!compressTypes.has(compressType)) compressType = 'gzip';
|
|
1175
1198
|
if (!baseTypes.has(baseType)) baseType = 'base64';
|
|
1176
1199
|
const text = lineRaw.replace(';Raw: ', '').trim();
|
|
1177
|
-
const buffer = 'base64' === baseType ? Buffer.from(text, 'base64') : Buffer.from(decode(Buffer.from(text, 'utf8').toString('utf8')));
|
|
1200
|
+
const buffer = 'base64' === baseType ? Buffer.from(text, 'base64') : Buffer.from(__rspack_external_base16384.decode(Buffer.from(text, 'utf8').toString('utf8')));
|
|
1178
1201
|
let decompress;
|
|
1179
1202
|
decompress = 'brotli' === compressType ? brotliDecompressSync(buffer) : gunzipSync(buffer);
|
|
1180
1203
|
try {
|
|
@@ -1322,6 +1345,67 @@ function fileParser(file, mod) {
|
|
|
1322
1345
|
throw new Error(`Unsupported mod "${mod}"`);
|
|
1323
1346
|
}
|
|
1324
1347
|
}
|
|
1348
|
+
function main(that) {
|
|
1349
|
+
that.dans.forEach((d)=>{
|
|
1350
|
+
if (d.platform !== platform_PlatformVideoSource.Bilibili) throw new Error('bili-dedupe: 仅支持B站(主站)的弹幕');
|
|
1351
|
+
if (!d.extra.bili?.dmid && !d.extra.bili?.command?.id) throw new Error('bili-dedupe: 弹幕缺少bili extra dmid字段');
|
|
1352
|
+
});
|
|
1353
|
+
const map = new Map();
|
|
1354
|
+
that.dans.forEach((d)=>map.set(d.extra.bili.dmid, d));
|
|
1355
|
+
return map;
|
|
1356
|
+
}
|
|
1357
|
+
function to_bili_deduped(that) {
|
|
1358
|
+
const map = main(that);
|
|
1359
|
+
return new UniPool([
|
|
1360
|
+
...map.values()
|
|
1361
|
+
], that.options, that.info);
|
|
1362
|
+
}
|
|
1363
|
+
function bili_dedupe(that) {
|
|
1364
|
+
const map = main(that);
|
|
1365
|
+
that.dans = [
|
|
1366
|
+
...map.values()
|
|
1367
|
+
];
|
|
1368
|
+
}
|
|
1369
|
+
function history_danmaku_fast_forward_main(that, query_history_date) {
|
|
1370
|
+
const qhd = DateTime.fromFormat(query_history_date, 'yyyy-MM-dd', {
|
|
1371
|
+
zone: 'Asia/Shanghai'
|
|
1372
|
+
}).setZone('Asia/Shanghai');
|
|
1373
|
+
if (!qhd.isValid) throw new Error('Invalid query_history_date');
|
|
1374
|
+
const s = qhd.startOf('day');
|
|
1375
|
+
const before = that.dans.filter((d)=>d.ctime < s.toJSDate());
|
|
1376
|
+
if (0 === before.length) return {
|
|
1377
|
+
earliest: null,
|
|
1378
|
+
FastForward: [],
|
|
1379
|
+
skip: [],
|
|
1380
|
+
SpecificDate: qhd.toFormat('yyyy-MM-dd')
|
|
1381
|
+
};
|
|
1382
|
+
const earliestCtime = before.toSorted((a, b)=>a.ctime.getTime() - b.ctime.getTime())[0].ctime;
|
|
1383
|
+
const earliestDate = DateTime.fromJSDate(earliestCtime).setZone('Asia/Shanghai').startOf('day');
|
|
1384
|
+
const datesWithDanmaku = new Set();
|
|
1385
|
+
for (const dan of before){
|
|
1386
|
+
const dateStr = DateTime.fromJSDate(dan.ctime).setZone('Asia/Shanghai').toFormat('yyyy-MM-dd');
|
|
1387
|
+
datesWithDanmaku.add(dateStr);
|
|
1388
|
+
}
|
|
1389
|
+
let current = earliestDate;
|
|
1390
|
+
const allDates = [];
|
|
1391
|
+
while(current < s){
|
|
1392
|
+
allDates.push(current.toFormat('yyyy-MM-dd'));
|
|
1393
|
+
current = current.plus({
|
|
1394
|
+
days: 1
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
const FastForward = allDates.filter((d)=>datesWithDanmaku.has(d));
|
|
1398
|
+
const skip = allDates.filter((d)=>!datesWithDanmaku.has(d));
|
|
1399
|
+
return {
|
|
1400
|
+
earliest: earliestDate.toFormat('yyyy-MM-dd'),
|
|
1401
|
+
FastForward,
|
|
1402
|
+
skip,
|
|
1403
|
+
SpecificDate: qhd.toFormat('yyyy-MM-dd')
|
|
1404
|
+
};
|
|
1405
|
+
}
|
|
1406
|
+
function bili_history_fast_forward(query_history_date) {
|
|
1407
|
+
return (that)=>history_danmaku_fast_forward_main(that, query_history_date);
|
|
1408
|
+
}
|
|
1325
1409
|
const src_JSON = json_bigint({
|
|
1326
1410
|
useNativeBigInt: true
|
|
1327
1411
|
});
|
|
@@ -1829,6 +1913,8 @@ class UniPool {
|
|
|
1829
1913
|
const ok = this.dans.every((d)=>d.senderID.endsWith(`@${platform_PlatformVideoSource.Bilibili}`));
|
|
1830
1914
|
if (!ok) throw new Error('存在其他来源的senderID,请关闭该功能再试!');
|
|
1831
1915
|
}
|
|
1916
|
+
let ds = this.dans.map((dan)=>dan.toBiliXML(options));
|
|
1917
|
+
if (options?.skipBiliCommand) ds = ds.filter((d)=>null !== d);
|
|
1832
1918
|
const builder = new XMLBuilder({
|
|
1833
1919
|
ignoreAttributes: false
|
|
1834
1920
|
});
|
|
@@ -1849,7 +1935,7 @@ class UniPool {
|
|
|
1849
1935
|
...DanUniConvertTipTemplate,
|
|
1850
1936
|
data: this.getShared('SOID')
|
|
1851
1937
|
},
|
|
1852
|
-
d:
|
|
1938
|
+
d: ds
|
|
1853
1939
|
}
|
|
1854
1940
|
});
|
|
1855
1941
|
}
|
|
@@ -1994,4 +2080,4 @@ class UniPool {
|
|
|
1994
2080
|
}, canvasCtx);
|
|
1995
2081
|
}
|
|
1996
2082
|
}
|
|
1997
|
-
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools,
|
|
2083
|
+
export { UniDM, UniPool, bili_history_fast_forward, bili_namespaceObject as bili, dedupe_namespaceObject as bili_dedupe, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_namespaceObject as platform, plugins_namespaceObject as plugins, src_DM_format as DM_format };
|
|
@@ -1,77 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { DateTime } from "luxon";
|
|
3
|
-
import { UniPool, platform_PlatformVideoSource } from "../index.js";
|
|
4
|
-
var dedupe_namespaceObject = {};
|
|
5
|
-
__webpack_require__.r(dedupe_namespaceObject);
|
|
6
|
-
__webpack_require__.d(dedupe_namespaceObject, {
|
|
7
|
-
bili_dedupe: ()=>bili_dedupe,
|
|
8
|
-
to_bili_deduped: ()=>to_bili_deduped
|
|
9
|
-
});
|
|
10
|
-
var bili_namespaceObject = {};
|
|
11
|
-
__webpack_require__.r(bili_namespaceObject);
|
|
12
|
-
__webpack_require__.d(bili_namespaceObject, {
|
|
13
|
-
bili_dedupe: ()=>dedupe_namespaceObject,
|
|
14
|
-
bili_history_fast_forward: ()=>bili_history_fast_forward
|
|
15
|
-
});
|
|
16
|
-
function main(that) {
|
|
17
|
-
that.dans.forEach((d)=>{
|
|
18
|
-
if (d.platform !== platform_PlatformVideoSource.Bilibili) throw new Error('bili-dedupe: 仅支持B站(主站)的弹幕');
|
|
19
|
-
if (!d.extra.bili?.dmid) throw new Error('bili-dedupe: 弹幕缺少bili extra dmid字段');
|
|
20
|
-
});
|
|
21
|
-
const map = new Map();
|
|
22
|
-
that.dans.forEach((d)=>map.set(d.extra.bili.dmid, d));
|
|
23
|
-
return map;
|
|
24
|
-
}
|
|
25
|
-
function to_bili_deduped(that) {
|
|
26
|
-
const map = main(that);
|
|
27
|
-
return new UniPool([
|
|
28
|
-
...map.values()
|
|
29
|
-
], that.options, that.info);
|
|
30
|
-
}
|
|
31
|
-
function bili_dedupe(that) {
|
|
32
|
-
const map = main(that);
|
|
33
|
-
that.dans = [
|
|
34
|
-
...map.values()
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
function history_danmaku_fast_forward_main(that, query_history_date) {
|
|
38
|
-
const qhd = DateTime.fromFormat(query_history_date, 'yyyy-MM-dd', {
|
|
39
|
-
zone: 'Asia/Shanghai'
|
|
40
|
-
}).setZone('Asia/Shanghai');
|
|
41
|
-
if (!qhd.isValid) throw new Error('Invalid query_history_date');
|
|
42
|
-
const s = qhd.startOf('day');
|
|
43
|
-
const before = that.dans.filter((d)=>d.ctime < s.toJSDate());
|
|
44
|
-
if (0 === before.length) return {
|
|
45
|
-
earliest: null,
|
|
46
|
-
FastForward: [],
|
|
47
|
-
skip: [],
|
|
48
|
-
SpecificDate: qhd.toFormat('yyyy-MM-dd')
|
|
49
|
-
};
|
|
50
|
-
const earliestCtime = before.toSorted((a, b)=>a.ctime.getTime() - b.ctime.getTime())[0].ctime;
|
|
51
|
-
const earliestDate = DateTime.fromJSDate(earliestCtime).setZone('Asia/Shanghai').startOf('day');
|
|
52
|
-
const datesWithDanmaku = new Set();
|
|
53
|
-
for (const dan of before){
|
|
54
|
-
const dateStr = DateTime.fromJSDate(dan.ctime).setZone('Asia/Shanghai').toFormat('yyyy-MM-dd');
|
|
55
|
-
datesWithDanmaku.add(dateStr);
|
|
56
|
-
}
|
|
57
|
-
let current = earliestDate;
|
|
58
|
-
const allDates = [];
|
|
59
|
-
while(current < s){
|
|
60
|
-
allDates.push(current.toFormat('yyyy-MM-dd'));
|
|
61
|
-
current = current.plus({
|
|
62
|
-
days: 1
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const FastForward = allDates.filter((d)=>datesWithDanmaku.has(d));
|
|
66
|
-
const skip = allDates.filter((d)=>!datesWithDanmaku.has(d));
|
|
67
|
-
return {
|
|
68
|
-
earliest: earliestDate.toFormat('yyyy-MM-dd'),
|
|
69
|
-
FastForward,
|
|
70
|
-
skip,
|
|
71
|
-
SpecificDate: qhd.toFormat('yyyy-MM-dd')
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function bili_history_fast_forward(query_history_date) {
|
|
75
|
-
return (that)=>history_danmaku_fast_forward_main(that, query_history_date);
|
|
76
|
-
}
|
|
77
|
-
export { bili_history_fast_forward, bili_namespaceObject as bili, dedupe_namespaceObject as bili_dedupe };
|
|
1
|
+
export { bili_dedupe, bili_history_fast_forward } from "../index.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { bili } from "
|
|
1
|
+
export { bili } from "../index.js";
|
|
2
2
|
export { stats } from "./stats.js";
|
package/dist/node/src/index.d.ts
CHANGED
|
@@ -237,6 +237,10 @@ export declare class UniPool {
|
|
|
237
237
|
* 当SOID非来源bili时,若此处指定则使用该值为cid,否则使用SOID
|
|
238
238
|
*/
|
|
239
239
|
cid?: bigint;
|
|
240
|
+
/**
|
|
241
|
+
* 跳过command类型的特殊弹幕
|
|
242
|
+
*/
|
|
243
|
+
skipBiliCommand?: boolean;
|
|
240
244
|
/**
|
|
241
245
|
* 当仅含有来自bili的弹幕时,启用将保持发送者标识不含`@`
|
|
242
246
|
* @description
|
|
@@ -275,3 +279,4 @@ export declare class UniPool {
|
|
|
275
279
|
toASS(canvasCtx: CanvasCtx, options?: AssGenOptions): string;
|
|
276
280
|
}
|
|
277
281
|
export { platform, UniDM, UniDMTools, UniIDTools, type DM_JSON_BiliCommandGrpc, };
|
|
282
|
+
export * as plugins from './plugins';
|