@dan-uni/dan-any 0.5.0 → 0.6.6
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 +321 -4911
- package/dist/index.umd.min.js +4603 -268
- package/dist/index.umd.min.js.LICENSE.txt +15 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/utils/dm-gen.d.ts +22 -87
- package/dist/src/utils/id-gen.d.ts +1 -1
- package/package.json +9 -4
- package/src/ass-gen/__tests__/898651903.xml.ass +1 -1
- package/src/index.test.ts +1 -1
- package/src/index.ts +44 -41
- 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 +4 -1
- package/src/utils/dm-gen.ts +237 -180
- package/src/utils/id-gen.ts +4 -1
- package/tsconfig.json +3 -3
- package/types/tsconfig.tsbuildinfo +1 -0
|
@@ -12,6 +12,21 @@
|
|
|
12
12
|
* @license MIT
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
/*! *****************************************************************************
|
|
16
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
17
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
18
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
19
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
|
|
21
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
22
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
23
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
24
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
25
|
+
|
|
26
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
27
|
+
and limitations under the License.
|
|
28
|
+
***************************************************************************** */
|
|
29
|
+
|
|
15
30
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
16
31
|
|
|
17
32
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { DM_JSON_BiliCommandGrpc } from '..';
|
|
2
2
|
import type { PlatformDanmakuSource } from './platform';
|
|
3
3
|
import { PlatformDanmakuOnlySource } from './platform';
|
|
4
|
-
export
|
|
4
|
+
export declare enum DMAttr {
|
|
5
|
+
Protect = "Protect",
|
|
6
|
+
FromLive = "FromLive",
|
|
7
|
+
HighLike = "HighLike",
|
|
8
|
+
Compatible = "Compatible",// 由dan-any进行过兼容处理的弹幕,可能丢失部分信息
|
|
9
|
+
Reported = "Reported",// 在DanUni上被多人举报过的弹幕
|
|
10
|
+
Unchecked = "Unchecked",// 在DanUni上未被审核过的弹幕
|
|
11
|
+
HasEvent = "HasEvent",// 该弹幕当前在DanUni上存在事件(如点赞/举报等)
|
|
12
|
+
Hide = "Hide"
|
|
13
|
+
}
|
|
5
14
|
interface DMBili {
|
|
6
15
|
id: bigint;
|
|
7
16
|
progress: number;
|
|
@@ -156,9 +165,6 @@ export interface UniDMObj {
|
|
|
156
165
|
extraStr: string;
|
|
157
166
|
DMID: string;
|
|
158
167
|
}
|
|
159
|
-
/**
|
|
160
|
-
* 所有 number/bigint 值设为0自动转换为默认
|
|
161
|
-
*/
|
|
162
168
|
export declare class UniDM {
|
|
163
169
|
/**
|
|
164
170
|
* 资源ID
|
|
@@ -204,7 +210,7 @@ export declare class UniDM {
|
|
|
204
210
|
*/
|
|
205
211
|
ctime: Date;
|
|
206
212
|
/**
|
|
207
|
-
* 权重 用于屏蔽等级 区间:[
|
|
213
|
+
* 权重 用于屏蔽等级 区间:[0,11]
|
|
208
214
|
* @description 参考B站,源弹幕有该参数则直接利用,
|
|
209
215
|
* 本实现默认取5,再经过ruleset匹配加减分数
|
|
210
216
|
* @description 为0时表示暂时未计算权重
|
|
@@ -223,91 +229,18 @@ export declare class UniDM {
|
|
|
223
229
|
* 初始来源平台
|
|
224
230
|
* `danuni`与任意空值(可隐式转换为false的值)等价
|
|
225
231
|
*/
|
|
226
|
-
platform?:
|
|
227
|
-
/**
|
|
228
|
-
* 弹幕原始数据(不推荐使用)
|
|
229
|
-
* @description 适用于无法解析的B站代码弹幕、Artplayer弹幕样式等
|
|
230
|
-
* @description 初步约定:
|
|
231
|
-
* - Artplayer: style不为空时,将其JSON.stringify()存入
|
|
232
|
-
*/
|
|
233
|
-
extraStr?: string | undefined;
|
|
234
|
-
DMID?: string | undefined;
|
|
235
|
-
/**
|
|
236
|
-
* 同步时确认位置的参数
|
|
237
|
-
*/
|
|
238
|
-
constructor(
|
|
239
|
-
/**
|
|
240
|
-
* 资源ID
|
|
241
|
-
* @description 由某一danuni服务确定的某一剧集下不同资源(不同视频站/字幕组具有细节差异)的ID
|
|
242
|
-
*/
|
|
243
|
-
SOID: string,
|
|
244
|
-
/**
|
|
245
|
-
* 弹幕出现位置(单位s;精度为ms,即保留三位小数)
|
|
246
|
-
*/
|
|
247
|
-
progress?: number,
|
|
248
|
-
/**
|
|
249
|
-
* 弹幕类型
|
|
250
|
-
*/
|
|
251
|
-
mode?: Modes,
|
|
252
|
-
/**
|
|
253
|
-
* 字号
|
|
254
|
-
* @default 25
|
|
255
|
-
* - 12
|
|
256
|
-
* - 16
|
|
257
|
-
* - 18:小
|
|
258
|
-
* - 25:标准
|
|
259
|
-
* - 36:大
|
|
260
|
-
* - 45
|
|
261
|
-
* - 64
|
|
262
|
-
*/
|
|
263
|
-
fontsize?: number,
|
|
264
|
-
/**
|
|
265
|
-
* 颜色
|
|
266
|
-
* @description 为DEC值(十进制RGB888值),默认白色
|
|
267
|
-
* @default 16777215
|
|
268
|
-
*/
|
|
269
|
-
color?: number,
|
|
270
|
-
/**
|
|
271
|
-
* 发送者 senderID
|
|
272
|
-
*/
|
|
273
|
-
senderID?: string,
|
|
274
|
-
/**
|
|
275
|
-
* 正文
|
|
276
|
-
*/
|
|
277
|
-
content?: string,
|
|
278
|
-
/**
|
|
279
|
-
* 发送时间
|
|
280
|
-
*/
|
|
281
|
-
ctime?: Date,
|
|
282
|
-
/**
|
|
283
|
-
* 权重 用于屏蔽等级 区间:[1,10]
|
|
284
|
-
* @description 参考B站,源弹幕有该参数则直接利用,
|
|
285
|
-
* 本实现默认取5,再经过ruleset匹配加减分数
|
|
286
|
-
* @description 为0时表示暂时未计算权重
|
|
287
|
-
*/
|
|
288
|
-
weight?: number,
|
|
289
|
-
/**
|
|
290
|
-
* 弹幕池 0:普通池 1:字幕池 2:特殊池(代码/BAS弹幕) 3:互动池(互动弹幕中选择投票快速发送的弹幕)
|
|
291
|
-
*/
|
|
292
|
-
pool?: Pools,
|
|
293
|
-
/**
|
|
294
|
-
* 弹幕属性位(bin求AND)
|
|
295
|
-
* bit0:保护 bit1:直播 bit2:高赞
|
|
296
|
-
*/
|
|
297
|
-
attr?: DMAttr[],
|
|
298
|
-
/**
|
|
299
|
-
* 初始来源平台
|
|
300
|
-
* `danuni`与任意空值(可隐式转换为false的值)等价
|
|
301
|
-
*/
|
|
302
|
-
platform?: (PlatformDanmakuSource | string) | undefined,
|
|
232
|
+
platform?: PlatformDanmakuSource | string;
|
|
303
233
|
/**
|
|
304
234
|
* 弹幕原始数据(不推荐使用)
|
|
305
235
|
* @description 适用于无法解析的B站代码弹幕、Artplayer弹幕样式等
|
|
306
236
|
* @description 初步约定:
|
|
307
237
|
* - Artplayer: style不为空时,将其JSON.stringify()存入
|
|
308
238
|
*/
|
|
309
|
-
extraStr?: string
|
|
310
|
-
|
|
239
|
+
extraStr?: string;
|
|
240
|
+
DMID?: string;
|
|
241
|
+
init(): this;
|
|
242
|
+
validate(): Promise<void>;
|
|
243
|
+
static create(pjson?: Partial<UniDMObj>): UniDM;
|
|
311
244
|
get extra(): Extra;
|
|
312
245
|
get isFrom3rdPlatform(): boolean;
|
|
313
246
|
/**
|
|
@@ -316,7 +249,7 @@ export declare class UniDM {
|
|
|
316
249
|
* @description 同一SOID下唯一
|
|
317
250
|
*/
|
|
318
251
|
toDMID(): string;
|
|
319
|
-
isSameAs(dan: UniDM
|
|
252
|
+
isSameAs(dan: UniDM): boolean;
|
|
320
253
|
minify(): Partial<UniDMObj> & Pick<UniDMObj, "SOID">;
|
|
321
254
|
downgradeAdvcancedDan({ include, exclude, cleanExtra, }?: {
|
|
322
255
|
include?: (keyof Extra)[];
|
|
@@ -333,10 +266,12 @@ export declare class UniDM {
|
|
|
333
266
|
static transCtime(oriCtime: ctime, tsUnit?: 'ms' | 's'): Date;
|
|
334
267
|
static transMode(oriMode: number, fmt: 'bili' | 'dplayer' | 'artplayer' | 'ddplay'): Modes;
|
|
335
268
|
static fromBili(args: DMBili, cid?: bigint): UniDM;
|
|
336
|
-
toBiliXML(
|
|
269
|
+
toBiliXML(options?: {
|
|
270
|
+
skipBiliCommand: boolean;
|
|
271
|
+
}): {
|
|
337
272
|
'#text': string;
|
|
338
273
|
'@_p': string;
|
|
339
|
-
};
|
|
274
|
+
} | null;
|
|
340
275
|
static fromBiliCommand(args: DMBiliCommand, cid?: bigint): UniDM;
|
|
341
276
|
static fromDplayer(args: DMDplayer, playerID: string, domain: string): UniDM;
|
|
342
277
|
toDplayer(): DMDplayer;
|
|
@@ -46,4 +46,4 @@ export declare class UniID {
|
|
|
46
46
|
*/
|
|
47
47
|
domain: PlatformSource | string): UniID;
|
|
48
48
|
}
|
|
49
|
-
export declare function createDMID(content: string | undefined, senderID: string, ctime: ctime, slice?: number): string;
|
|
49
|
+
export declare function createDMID(content: string | undefined, senderID: string, ctime: ctime, extraStr?: string, slice?: number): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dan-uni/dan-any",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "A danmaku transformer lib, supporting danmaku from different platforms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bangumi",
|
|
@@ -31,19 +31,24 @@
|
|
|
31
31
|
"buf": "buf generate"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@bufbuild/protobuf": "^2.6.2",
|
|
34
35
|
"base16384": "^1.0.0",
|
|
35
36
|
"canvas": "^3.1.2",
|
|
37
|
+
"class-transformer": "^0.5.1",
|
|
38
|
+
"class-validator": "^0.14.2",
|
|
36
39
|
"fast-xml-parser": "^5.2.5",
|
|
37
40
|
"fs-extra": "^11.3.0",
|
|
38
41
|
"hh-mm-ss": "^1.2.0",
|
|
39
|
-
"
|
|
42
|
+
"json-bigint": "^1.0.0",
|
|
43
|
+
"jssha": "^3.3.1",
|
|
44
|
+
"reflect-metadata": "^0.2.2"
|
|
40
45
|
},
|
|
41
46
|
"devDependencies": {
|
|
42
47
|
"@bufbuild/buf": "^1.55.1",
|
|
43
|
-
"@bufbuild/
|
|
44
|
-
"@bufbuild/protoc-gen-es": "^2.6.0",
|
|
48
|
+
"@bufbuild/protoc-gen-es": "^2.6.2",
|
|
45
49
|
"@types/fs-extra": "^11.0.4",
|
|
46
50
|
"@types/hh-mm-ss": "^1.2.3",
|
|
51
|
+
"@types/json-bigint": "^1.0.4",
|
|
47
52
|
"protobufjs": "^7.5.3"
|
|
48
53
|
}
|
|
49
54
|
}
|