@dan-uni/dan-any 1.0.0 → 1.0.1
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 +283 -861
- package/dist/index.min.js +370 -967
- package/dist/index.umd.min.js +442 -986
- package/dist/rslib-runtime.js +37 -0
- package/dist/rslib-runtime.min.js +49 -0
- package/dist/src/ass-gen/util/index.d.ts +2 -2
- package/dist/src/index.d.ts +6 -6
- package/dist/src/utils/dm-gen.d.ts +3 -3
- package/package.json +18 -18
- package/rslib.config.ts +3 -3
- package/src/ass-gen/util/index.ts +2 -2
- package/src/index.ts +6 -6
- 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 +2 -2
- package/src/utils/dm-gen.ts +30 -5
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __webpack_module_cache__ = {};
|
|
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
|
+
}
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.add = function(modules) {
|
|
13
|
+
Object.assign(__webpack_require__.m, modules);
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.d = (exports, definition)=>{
|
|
18
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: definition[key]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
export { __webpack_require__ };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __webpack_modules__ = {};
|
|
2
|
+
var __webpack_module_cache__ = {};
|
|
3
|
+
function __webpack_require__(moduleId) {
|
|
4
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
+
exports: {}
|
|
8
|
+
};
|
|
9
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
10
|
+
return module.exports;
|
|
11
|
+
}
|
|
12
|
+
__webpack_require__.m = __webpack_modules__;
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.add = function(modules) {
|
|
15
|
+
Object.assign(__webpack_require__.m, modules);
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.d = (exports, definition)=>{
|
|
20
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: definition[key]
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.g = (()=>{
|
|
28
|
+
if ('object' == typeof globalThis) return globalThis;
|
|
29
|
+
try {
|
|
30
|
+
return this || new Function('return this')();
|
|
31
|
+
} catch (e) {
|
|
32
|
+
if ('object' == typeof window) return window;
|
|
33
|
+
}
|
|
34
|
+
})();
|
|
35
|
+
})();
|
|
36
|
+
(()=>{
|
|
37
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
38
|
+
})();
|
|
39
|
+
(()=>{
|
|
40
|
+
__webpack_require__.r = (exports)=>{
|
|
41
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
42
|
+
value: 'Module'
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, '__esModule', {
|
|
45
|
+
value: true
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
export { __webpack_require__ };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { decimalColorToRGB, formatColor, getDecoratingColor, hexColorToRGB, isWhite, } from './color';
|
|
2
|
-
export { layoutDanmaku } from './layout';
|
|
3
|
-
export { arrayOfLength, assign, uniqueArray } from './lang';
|
|
4
2
|
export { DanmakuList2UniPool, UniPool2DanmakuLists } from './danconvert';
|
|
3
|
+
export { arrayOfLength, assign, uniqueArray } from './lang';
|
|
4
|
+
export { layoutDanmaku } from './layout';
|
package/dist/src/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ interface DanUniConvertTip {
|
|
|
13
13
|
export interface DM_XML_Bili {
|
|
14
14
|
i: {
|
|
15
15
|
chatserver: string;
|
|
16
|
-
chatid:
|
|
16
|
+
chatid: bigint;
|
|
17
17
|
mission: number;
|
|
18
18
|
maxlimit: number;
|
|
19
19
|
state: number;
|
|
@@ -44,15 +44,15 @@ export interface DM_JSON_BiliUp {
|
|
|
44
44
|
};
|
|
45
45
|
result: {
|
|
46
46
|
/** 弹幕 ID,int64 */
|
|
47
|
-
id:
|
|
47
|
+
id: bigint;
|
|
48
48
|
/** 弹幕 ID 字符串形式 */
|
|
49
49
|
id_str: string;
|
|
50
50
|
/** 弹幕类型:1 表示视频弹幕(当前接口恒为 1) */
|
|
51
51
|
type: number;
|
|
52
|
-
aid:
|
|
52
|
+
aid: bigint;
|
|
53
53
|
bvid: string;
|
|
54
|
-
oid:
|
|
55
|
-
mid:
|
|
54
|
+
oid: bigint;
|
|
55
|
+
mid: bigint;
|
|
56
56
|
/** 发送者 mid 的 CRC 哈希(正常接口里用的是这个,保护隐私) */
|
|
57
57
|
mid_hash: string;
|
|
58
58
|
/** 弹幕池 */
|
|
@@ -111,7 +111,7 @@ export interface DM_JSON_Artplayer {
|
|
|
111
111
|
export interface DM_JSON_DDPlay {
|
|
112
112
|
count: number | string;
|
|
113
113
|
comments: {
|
|
114
|
-
cid:
|
|
114
|
+
cid: bigint;
|
|
115
115
|
p: string;
|
|
116
116
|
m: string;
|
|
117
117
|
}[];
|
|
@@ -18,7 +18,7 @@ interface DMBili {
|
|
|
18
18
|
mode: number;
|
|
19
19
|
fontsize: number;
|
|
20
20
|
color: number;
|
|
21
|
-
mid?:
|
|
21
|
+
mid?: bigint;
|
|
22
22
|
midHash: string;
|
|
23
23
|
/**
|
|
24
24
|
* 特殊类型解析:
|
|
@@ -63,7 +63,7 @@ interface DMArtplayer {
|
|
|
63
63
|
style?: object;
|
|
64
64
|
}
|
|
65
65
|
interface DMDDplay {
|
|
66
|
-
cid:
|
|
66
|
+
cid: bigint;
|
|
67
67
|
/**
|
|
68
68
|
* content
|
|
69
69
|
*/
|
|
@@ -99,7 +99,7 @@ interface ExtraBili {
|
|
|
99
99
|
pool?: number;
|
|
100
100
|
dmid?: bigint;
|
|
101
101
|
attr?: number;
|
|
102
|
-
mid?:
|
|
102
|
+
mid?: bigint;
|
|
103
103
|
adv?: string;
|
|
104
104
|
code?: string;
|
|
105
105
|
bas?: string;
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dan-uni/dan-any",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "A danmaku transformer lib, supporting danmaku from different platforms.",
|
|
5
3
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
],
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"description": "A danmaku transformer lib, supporting danmaku from different platforms.",
|
|
6
|
+
"author": "rinne",
|
|
10
7
|
"license": "LGPL-3.0-or-later",
|
|
11
8
|
"homepage": "https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme",
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/ani-uni/danuni/issues"
|
|
14
|
-
},
|
|
15
9
|
"repository": {
|
|
16
10
|
"type": "git",
|
|
17
11
|
"url": "git+https://github.com/ani-uni/danuni.git"
|
|
18
12
|
},
|
|
19
|
-
"
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ani-uni/danuni/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"bangumi",
|
|
18
|
+
"danmaku"
|
|
19
|
+
],
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"module": "dist/index.js",
|
|
22
22
|
"types": "dist/src/index.d.ts",
|
|
@@ -32,24 +32,24 @@
|
|
|
32
32
|
"buf": "buf generate"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@bufbuild/protobuf": "^2.10.
|
|
35
|
+
"@bufbuild/protobuf": "^2.10.2",
|
|
36
36
|
"base16384": "^1.0.0",
|
|
37
37
|
"class-transformer": "^0.5.1",
|
|
38
|
-
"class-validator": "^0.14.
|
|
39
|
-
"fast-xml-parser": "^5.3.
|
|
40
|
-
"fs-extra": "^11.3.
|
|
38
|
+
"class-validator": "^0.14.3",
|
|
39
|
+
"fast-xml-parser": "^5.3.3",
|
|
40
|
+
"fs-extra": "^11.3.3",
|
|
41
41
|
"hh-mm-ss": "^1.2.0",
|
|
42
42
|
"json-bigint": "^1.0.0",
|
|
43
43
|
"jssha": "^3.3.1",
|
|
44
44
|
"reflect-metadata": "^0.2.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@bufbuild/buf": "^1.
|
|
48
|
-
"@bufbuild/protoc-gen-es": "^2.10.
|
|
47
|
+
"@bufbuild/buf": "^1.63.0",
|
|
48
|
+
"@bufbuild/protoc-gen-es": "^2.10.2",
|
|
49
49
|
"@types/fs-extra": "^11.0.4",
|
|
50
50
|
"@types/hh-mm-ss": "^1.2.3",
|
|
51
51
|
"@types/json-bigint": "^1.0.4",
|
|
52
|
-
"canvas": "^3.2.
|
|
53
|
-
"protobufjs": "^
|
|
52
|
+
"canvas": "^3.2.1",
|
|
53
|
+
"protobufjs": "^8.0.0"
|
|
54
54
|
}
|
|
55
55
|
}
|
package/rslib.config.ts
CHANGED
|
@@ -8,7 +8,7 @@ export default defineConfig({
|
|
|
8
8
|
{
|
|
9
9
|
format: 'esm',
|
|
10
10
|
output: {
|
|
11
|
-
filename: { js: '
|
|
11
|
+
filename: { js: '[name].js' },
|
|
12
12
|
target: 'node',
|
|
13
13
|
},
|
|
14
14
|
dts: true,
|
|
@@ -16,7 +16,7 @@ export default defineConfig({
|
|
|
16
16
|
{
|
|
17
17
|
format: 'esm',
|
|
18
18
|
output: {
|
|
19
|
-
filename: { js: '
|
|
19
|
+
filename: { js: '[name].min.js' },
|
|
20
20
|
target: 'web',
|
|
21
21
|
},
|
|
22
22
|
dts: true,
|
|
@@ -25,7 +25,7 @@ export default defineConfig({
|
|
|
25
25
|
{
|
|
26
26
|
format: 'umd',
|
|
27
27
|
output: {
|
|
28
|
-
filename: { js: '
|
|
28
|
+
filename: { js: '[name].umd.min.js' },
|
|
29
29
|
target: 'web',
|
|
30
30
|
},
|
|
31
31
|
dts: true,
|
|
@@ -5,6 +5,6 @@ export {
|
|
|
5
5
|
hexColorToRGB,
|
|
6
6
|
isWhite,
|
|
7
7
|
} from './color'
|
|
8
|
-
export { layoutDanmaku } from './layout'
|
|
9
|
-
export { arrayOfLength, assign, uniqueArray } from './lang'
|
|
10
8
|
export { DanmakuList2UniPool, UniPool2DanmakuLists } from './danconvert'
|
|
9
|
+
export { arrayOfLength, assign, uniqueArray } from './lang'
|
|
10
|
+
export { layoutDanmaku } from './layout'
|
package/src/index.ts
CHANGED
|
@@ -47,7 +47,7 @@ interface DanUniConvertTip {
|
|
|
47
47
|
export interface DM_XML_Bili {
|
|
48
48
|
i: {
|
|
49
49
|
chatserver: string
|
|
50
|
-
chatid:
|
|
50
|
+
chatid: bigint
|
|
51
51
|
mission: number
|
|
52
52
|
maxlimit: number
|
|
53
53
|
state: number
|
|
@@ -78,15 +78,15 @@ export interface DM_JSON_BiliUp {
|
|
|
78
78
|
}
|
|
79
79
|
result: {
|
|
80
80
|
/** 弹幕 ID,int64 */
|
|
81
|
-
id:
|
|
81
|
+
id: bigint
|
|
82
82
|
/** 弹幕 ID 字符串形式 */
|
|
83
83
|
id_str: string
|
|
84
84
|
/** 弹幕类型:1 表示视频弹幕(当前接口恒为 1) */
|
|
85
85
|
type: number
|
|
86
|
-
aid:
|
|
86
|
+
aid: bigint
|
|
87
87
|
bvid: string
|
|
88
|
-
oid:
|
|
89
|
-
mid:
|
|
88
|
+
oid: bigint
|
|
89
|
+
mid: bigint
|
|
90
90
|
/** 发送者 mid 的 CRC 哈希(正常接口里用的是这个,保护隐私) */
|
|
91
91
|
mid_hash: string
|
|
92
92
|
/** 弹幕池 */
|
|
@@ -145,7 +145,7 @@ export interface DM_JSON_Artplayer {
|
|
|
145
145
|
export interface DM_JSON_DDPlay {
|
|
146
146
|
count: number | string
|
|
147
147
|
comments: {
|
|
148
|
-
cid:
|
|
148
|
+
cid: bigint
|
|
149
149
|
p: string
|
|
150
150
|
m: string
|
|
151
151
|
}[]
|
package/src/utils/dm-gen.test.ts
CHANGED
|
@@ -88,8 +88,8 @@ describe('其它', () => {
|
|
|
88
88
|
const c = pool.dans[1].isSameAs(pool.dans[3])
|
|
89
89
|
console.info(a, b, c)
|
|
90
90
|
expect(a).toBe(false)
|
|
91
|
-
expect(b).toBe(
|
|
92
|
-
expect(c).toBe(
|
|
91
|
+
expect(b).toBe(false)
|
|
92
|
+
expect(c).toBe(false)
|
|
93
93
|
})
|
|
94
94
|
it('比较(extra)', () => {
|
|
95
95
|
const commonSample = {
|
package/src/utils/dm-gen.ts
CHANGED
|
@@ -160,7 +160,7 @@ interface DMBili {
|
|
|
160
160
|
mode: number // xml 1
|
|
161
161
|
fontsize: number // xml 2
|
|
162
162
|
color: number // xml 3
|
|
163
|
-
mid?:
|
|
163
|
+
mid?: bigint // 仅创作中心源
|
|
164
164
|
midHash: string // xml 6
|
|
165
165
|
/**
|
|
166
166
|
* 特殊类型解析:
|
|
@@ -204,7 +204,7 @@ interface DMArtplayer {
|
|
|
204
204
|
style?: object
|
|
205
205
|
}
|
|
206
206
|
interface DMDDplay {
|
|
207
|
-
cid:
|
|
207
|
+
cid: bigint
|
|
208
208
|
/**
|
|
209
209
|
* content
|
|
210
210
|
*/
|
|
@@ -241,7 +241,7 @@ interface ExtraBili {
|
|
|
241
241
|
pool?: number //原弹幕池
|
|
242
242
|
dmid?: bigint //原弹幕ID
|
|
243
243
|
attr?: number //原弹幕属性
|
|
244
|
-
mid?:
|
|
244
|
+
mid?: bigint //发送者mid(仅创作中心源)
|
|
245
245
|
adv?: string
|
|
246
246
|
code?: string
|
|
247
247
|
bas?: string
|
|
@@ -572,6 +572,31 @@ export class UniDM {
|
|
|
572
572
|
(this.extra.danuni?.merge || dan.extra.danuni?.merge)
|
|
573
573
|
)
|
|
574
574
|
return false
|
|
575
|
+
// 如果是bili弹幕,则以dmid判断是否相同
|
|
576
|
+
if (this.extra.bili?.dmid && dan.extra.bili?.dmid) {
|
|
577
|
+
// 当来源不同(标准源/创作中心源)时,视为不同弹幕
|
|
578
|
+
if (
|
|
579
|
+
(this.extra.bili.dmid && !dan.extra.bili.dmid) ||
|
|
580
|
+
(!this.extra.bili.dmid && dan.extra.bili.dmid)
|
|
581
|
+
)
|
|
582
|
+
return false
|
|
583
|
+
if (this.extra.bili.dmid === dan.extra.bili.dmid) return true
|
|
584
|
+
else return false
|
|
585
|
+
}
|
|
586
|
+
// 如果是artplayer弹幕,需额外比较extra项目
|
|
587
|
+
if (
|
|
588
|
+
(this.extra.artplayer && !dan.extra.artplayer) ||
|
|
589
|
+
(!this.extra.artplayer && dan.extra.artplayer)
|
|
590
|
+
)
|
|
591
|
+
return false
|
|
592
|
+
else if (
|
|
593
|
+
this.extra.artplayer &&
|
|
594
|
+
dan.extra.artplayer &&
|
|
595
|
+
(this.extra.artplayer.border !== dan.extra.artplayer.border ||
|
|
596
|
+
JSON.stringify(this.extra.artplayer.style) !==
|
|
597
|
+
JSON.stringify(dan.extra.artplayer.style))
|
|
598
|
+
)
|
|
599
|
+
return false
|
|
575
600
|
const isSame = (k: keyof UniDMObj) => this[k] === dan[k]
|
|
576
601
|
const checks = (
|
|
577
602
|
[
|
|
@@ -1042,8 +1067,8 @@ export class UniDM {
|
|
|
1042
1067
|
uid: this.senderID,
|
|
1043
1068
|
m: this.content,
|
|
1044
1069
|
cid: this.DMID
|
|
1045
|
-
?
|
|
1046
|
-
:
|
|
1070
|
+
? BigInt(`0x${Buffer.from(this.DMID).toString('hex')}`)
|
|
1071
|
+
: 0n,
|
|
1047
1072
|
}
|
|
1048
1073
|
}
|
|
1049
1074
|
}
|