@dan-uni/dan-any 1.0.1 → 1.2.2
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/157.min.js +30 -0
- package/dist/{index.min.js → browser/17.min.js} +14 -8
- package/dist/browser/898.min.js +10 -0
- package/dist/browser/index.min.js +1 -0
- package/dist/browser/plugins/bili-dedupe.min.js +1 -0
- package/dist/browser/plugins/index.min.js +2 -0
- package/dist/browser/plugins/stats.min.js +1 -0
- package/dist/{src → browser/src}/index.d.ts +4 -4
- package/dist/browser/src/plugins/bili-dedupe/index.d.ts +3 -0
- package/dist/browser/src/plugins/index.d.ts +2 -0
- package/dist/browser/src/plugins/stats/getLatestDan.d.ts +6 -0
- package/dist/browser/src/plugins/stats/index.d.ts +1 -0
- package/dist/browser/src/plugins/stats/index.test.d.ts +1 -0
- package/dist/browser/src/utils/dm-gen.test.d.ts +1 -0
- package/dist/node/157.js +30 -0
- package/dist/{index.js → node/17.js} +2 -2
- package/dist/node/898.js +10 -0
- package/dist/node/index.js +1 -0
- package/dist/node/plugins/bili-dedupe.js +1 -0
- package/dist/node/plugins/index.js +2 -0
- package/dist/node/plugins/stats.js +1 -0
- package/dist/node/src/ass-gen/__tests__/canvas.test.d.ts +1 -0
- package/dist/node/src/ass-gen/__tests__/generate.test.d.ts +1 -0
- package/dist/node/src/ass-gen/ass/create.d.ts +4 -0
- package/dist/node/src/ass-gen/ass/dialogue.d.ts +16 -0
- package/dist/node/src/ass-gen/ass/event.d.ts +2 -0
- package/dist/node/src/ass-gen/ass/info.d.ts +8 -0
- package/dist/node/src/ass-gen/ass/raw.d.ts +14 -0
- package/dist/node/src/ass-gen/ass/style.d.ts +2 -0
- package/dist/node/src/ass-gen/config.d.ts +2 -0
- package/dist/node/src/ass-gen/index.d.ts +30 -0
- package/dist/node/src/ass-gen/types.d.ts +71 -0
- package/dist/node/src/ass-gen/util/color.d.ts +18 -0
- package/dist/node/src/ass-gen/util/danconvert.d.ts +5 -0
- package/dist/node/src/ass-gen/util/index.d.ts +4 -0
- package/dist/node/src/ass-gen/util/lang.d.ts +3 -0
- package/dist/node/src/ass-gen/util/layout.d.ts +4 -0
- package/dist/node/src/index.d.ts +255 -0
- package/dist/node/src/index.test.d.ts +1 -0
- package/dist/node/src/plugins/bili-dedupe/index.d.ts +3 -0
- package/dist/node/src/plugins/bili-dedupe/index.test.d.ts +1 -0
- package/dist/node/src/plugins/index.d.ts +2 -0
- package/dist/node/src/plugins/stats/getLatestDan.d.ts +6 -0
- package/dist/node/src/plugins/stats/index.d.ts +1 -0
- package/dist/node/src/plugins/stats/index.test.d.ts +1 -0
- package/dist/node/src/proto/gen/bili/dm_pb.d.ts +3426 -0
- package/dist/node/src/proto/gen/danuni_pb.d.ts +172 -0
- package/dist/node/src/utils/dm-gen.d.ts +309 -0
- package/dist/node/src/utils/dm-gen.test.d.ts +1 -0
- package/dist/node/src/utils/id-gen.d.ts +50 -0
- package/dist/node/src/utils/platform.d.ts +24 -0
- package/dist/{index.umd.min.js → umd/index.umd.min.js} +76 -67
- package/dist/umd/plugins/bili-dedupe.umd.min.js +25028 -0
- package/dist/umd/plugins/bili-dedupe.umd.min.js.LICENSE.txt +34 -0
- package/dist/umd/plugins/index.umd.min.js +25048 -0
- package/dist/umd/plugins/index.umd.min.js.LICENSE.txt +34 -0
- package/dist/umd/plugins/stats.umd.min.js +39 -0
- package/dist/umd/src/ass-gen/__tests__/canvas.test.d.ts +1 -0
- package/dist/umd/src/ass-gen/__tests__/generate.test.d.ts +1 -0
- package/dist/umd/src/ass-gen/ass/create.d.ts +4 -0
- package/dist/umd/src/ass-gen/ass/dialogue.d.ts +16 -0
- package/dist/umd/src/ass-gen/ass/event.d.ts +2 -0
- package/dist/umd/src/ass-gen/ass/info.d.ts +8 -0
- package/dist/umd/src/ass-gen/ass/raw.d.ts +14 -0
- package/dist/umd/src/ass-gen/ass/style.d.ts +2 -0
- package/dist/umd/src/ass-gen/config.d.ts +2 -0
- package/dist/umd/src/ass-gen/index.d.ts +30 -0
- package/dist/umd/src/ass-gen/types.d.ts +71 -0
- package/dist/umd/src/ass-gen/util/color.d.ts +18 -0
- package/dist/umd/src/ass-gen/util/danconvert.d.ts +5 -0
- package/dist/umd/src/ass-gen/util/index.d.ts +4 -0
- package/dist/umd/src/ass-gen/util/lang.d.ts +3 -0
- package/dist/umd/src/ass-gen/util/layout.d.ts +4 -0
- package/dist/umd/src/index.d.ts +255 -0
- package/dist/umd/src/index.test.d.ts +1 -0
- package/dist/umd/src/plugins/bili-dedupe/index.d.ts +3 -0
- package/dist/umd/src/plugins/bili-dedupe/index.test.d.ts +1 -0
- package/dist/umd/src/plugins/index.d.ts +2 -0
- package/dist/umd/src/plugins/stats/getLatestDan.d.ts +6 -0
- package/dist/umd/src/plugins/stats/index.d.ts +1 -0
- package/dist/umd/src/plugins/stats/index.test.d.ts +1 -0
- package/dist/umd/src/proto/gen/bili/dm_pb.d.ts +3426 -0
- package/dist/umd/src/proto/gen/danuni_pb.d.ts +172 -0
- package/dist/umd/src/utils/dm-gen.d.ts +309 -0
- package/dist/umd/src/utils/dm-gen.test.d.ts +1 -0
- package/dist/umd/src/utils/id-gen.d.ts +50 -0
- package/dist/umd/src/utils/platform.d.ts +24 -0
- package/package.json +8 -8
- package/plugins/package.json +6 -0
- package/rslib.config.ts +11 -0
- package/src/index.ts +8 -4
- package/src/plugins/bili-dedupe/index.test.ts +43 -0
- package/src/plugins/bili-dedupe/index.ts +29 -0
- package/src/plugins/index.ts +2 -0
- package/src/plugins/stats/getLatestDan.ts +13 -0
- package/src/plugins/stats/index.test.ts +39 -0
- package/src/plugins/stats/index.ts +1 -0
- package/src/proto/gen/bili/dm_pb.ts +1 -1
- package/src/proto/gen/danuni_pb.ts +1 -1
- /package/dist/{index.min.js.LICENSE.txt → browser/17.min.js.LICENSE.txt} +0 -0
- /package/dist/{rslib-runtime.min.js → browser/rslib-runtime.min.js} +0 -0
- /package/dist/{src → browser/src}/ass-gen/__tests__/canvas.test.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/__tests__/generate.test.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/ass/create.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/ass/dialogue.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/ass/event.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/ass/info.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/ass/raw.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/ass/style.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/config.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/index.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/types.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/util/color.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/util/danconvert.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/util/index.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/util/lang.d.ts +0 -0
- /package/dist/{src → browser/src}/ass-gen/util/layout.d.ts +0 -0
- /package/dist/{src → browser/src}/index.test.d.ts +0 -0
- /package/dist/{src/utils/dm-gen.test.d.ts → browser/src/plugins/bili-dedupe/index.test.d.ts} +0 -0
- /package/dist/{src → browser/src}/proto/gen/bili/dm_pb.d.ts +0 -0
- /package/dist/{src → browser/src}/proto/gen/danuni_pb.d.ts +0 -0
- /package/dist/{src → browser/src}/utils/dm-gen.d.ts +0 -0
- /package/dist/{src → browser/src}/utils/id-gen.d.ts +0 -0
- /package/dist/{src → browser/src}/utils/platform.d.ts +0 -0
- /package/dist/{rslib-runtime.js → node/rslib-runtime.js} +0 -0
- /package/dist/{index.umd.min.js.LICENSE.txt → umd/index.umd.min.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.min.js";
|
|
2
|
+
import { UniPool, platform_PlatformVideoSource } from "./17.min.js";
|
|
3
|
+
var bili_dedupe_namespaceObject = {};
|
|
4
|
+
__webpack_require__.r(bili_dedupe_namespaceObject);
|
|
5
|
+
__webpack_require__.d(bili_dedupe_namespaceObject, {
|
|
6
|
+
bili_dedupe: ()=>bili_dedupe,
|
|
7
|
+
to_bili_deduped: ()=>to_bili_deduped
|
|
8
|
+
});
|
|
9
|
+
function main(that) {
|
|
10
|
+
that.dans.forEach((d)=>{
|
|
11
|
+
if (d.platform !== platform_PlatformVideoSource.Bilibili) throw new Error('bili-dedupe: 仅支持B站(主站)的弹幕');
|
|
12
|
+
if (!d.extra.bili?.dmid) throw new Error('bili-dedupe: 弹幕缺少bili extra dmid字段');
|
|
13
|
+
});
|
|
14
|
+
const map = new Map();
|
|
15
|
+
that.dans.forEach((d)=>map.set(d.extra.bili.dmid, d));
|
|
16
|
+
return map;
|
|
17
|
+
}
|
|
18
|
+
function to_bili_deduped(that) {
|
|
19
|
+
const map = main(that);
|
|
20
|
+
return new UniPool([
|
|
21
|
+
...map.values()
|
|
22
|
+
], that.options, that.info);
|
|
23
|
+
}
|
|
24
|
+
function bili_dedupe(that) {
|
|
25
|
+
const map = main(that);
|
|
26
|
+
that.dans = [
|
|
27
|
+
...map.values()
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
export { bili_dedupe as bili_dedupe_0, bili_dedupe_namespaceObject as bili_dedupe, to_bili_deduped };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! For license information please see
|
|
1
|
+
/*! For license information please see 17.min.js.LICENSE.txt */
|
|
2
2
|
import { __webpack_require__ } from "./rslib-runtime.min.js";
|
|
3
3
|
import "reflect-metadata/lite";
|
|
4
4
|
import { IsDate, IsEmail, IsEnum, IsInt, IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min, isEmail, isJSON, isObject, isString, validateOrReject } from "class-validator";
|
|
@@ -4769,7 +4769,7 @@ __webpack_require__.add({
|
|
|
4769
4769
|
module.exports = fn;
|
|
4770
4770
|
},
|
|
4771
4771
|
"../../node_modules/.pnpm/is-typed-array@1.1.15/node_modules/is-typed-array/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
4772
|
-
var whichTypedArray = __webpack_require__("../../node_modules/.pnpm/which-typed-array@1.1.
|
|
4772
|
+
var whichTypedArray = __webpack_require__("../../node_modules/.pnpm/which-typed-array@1.1.20/node_modules/which-typed-array/index.js");
|
|
4773
4773
|
module.exports = function(value) {
|
|
4774
4774
|
return !!whichTypedArray(value);
|
|
4775
4775
|
};
|
|
@@ -10683,7 +10683,7 @@ __webpack_require__.add({
|
|
|
10683
10683
|
"../../node_modules/.pnpm/util@0.12.5/node_modules/util/support/types.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
10684
10684
|
var isArgumentsObject = __webpack_require__("../../node_modules/.pnpm/is-arguments@1.2.0/node_modules/is-arguments/index.js");
|
|
10685
10685
|
var isGeneratorFunction = __webpack_require__("../../node_modules/.pnpm/is-generator-function@1.1.2/node_modules/is-generator-function/index.js");
|
|
10686
|
-
var whichTypedArray = __webpack_require__("../../node_modules/.pnpm/which-typed-array@1.1.
|
|
10686
|
+
var whichTypedArray = __webpack_require__("../../node_modules/.pnpm/which-typed-array@1.1.20/node_modules/which-typed-array/index.js");
|
|
10687
10687
|
var isTypedArray = __webpack_require__("../../node_modules/.pnpm/is-typed-array@1.1.15/node_modules/is-typed-array/index.js");
|
|
10688
10688
|
function uncurryThis(f) {
|
|
10689
10689
|
return f.call.bind(f);
|
|
@@ -11349,7 +11349,7 @@ __webpack_require__.add({
|
|
|
11349
11349
|
}
|
|
11350
11350
|
exports.callbackify = callbackify;
|
|
11351
11351
|
},
|
|
11352
|
-
"../../node_modules/.pnpm/which-typed-array@1.1.
|
|
11352
|
+
"../../node_modules/.pnpm/which-typed-array@1.1.20/node_modules/which-typed-array/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
11353
11353
|
var forEach = __webpack_require__("../../node_modules/.pnpm/for-each@0.3.5/node_modules/for-each/index.js");
|
|
11354
11354
|
var availableTypedArrays = __webpack_require__("../../node_modules/.pnpm/available-typed-arrays@1.0.7/node_modules/available-typed-arrays/index.js");
|
|
11355
11355
|
var callBind = __webpack_require__("../../node_modules/.pnpm/call-bind@1.0.8/node_modules/call-bind/index.js");
|
|
@@ -11377,12 +11377,18 @@ __webpack_require__.add({
|
|
|
11377
11377
|
var superProto = getProto(proto);
|
|
11378
11378
|
descriptor = gOPD(superProto, Symbol.toStringTag);
|
|
11379
11379
|
}
|
|
11380
|
-
|
|
11380
|
+
if (descriptor && descriptor.get) {
|
|
11381
|
+
var bound = callBind(descriptor.get);
|
|
11382
|
+
cache['$' + typedArray] = bound;
|
|
11383
|
+
}
|
|
11381
11384
|
}
|
|
11382
11385
|
}) : forEach(typedArrays, function(typedArray) {
|
|
11383
11386
|
var arr = new g[typedArray]();
|
|
11384
11387
|
var fn = arr.slice || arr.set;
|
|
11385
|
-
if (fn)
|
|
11388
|
+
if (fn) {
|
|
11389
|
+
var bound = callBind(fn);
|
|
11390
|
+
cache['$' + typedArray] = bound;
|
|
11391
|
+
}
|
|
11386
11392
|
});
|
|
11387
11393
|
var tryTypedArrays = function(value) {
|
|
11388
11394
|
var found = false;
|
|
@@ -11455,7 +11461,7 @@ __webpack_require__.d(platform_namespaceObject, {
|
|
|
11455
11461
|
PlatformVideoSource: ()=>platform_PlatformVideoSource,
|
|
11456
11462
|
PlatformVideoSources: ()=>PlatformVideoSources
|
|
11457
11463
|
});
|
|
11458
|
-
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.
|
|
11464
|
+
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.2","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
|
|
11459
11465
|
const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
|
|
11460
11466
|
const decimalToHex = (n)=>color_pad(n.toString(16));
|
|
11461
11467
|
const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
|
|
@@ -13280,4 +13286,4 @@ class UniPool {
|
|
|
13280
13286
|
}, canvasCtx);
|
|
13281
13287
|
}
|
|
13282
13288
|
}
|
|
13283
|
-
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_namespaceObject as platform };
|
|
13289
|
+
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.min.js";
|
|
2
|
+
var stats_namespaceObject = {};
|
|
3
|
+
__webpack_require__.r(stats_namespaceObject);
|
|
4
|
+
__webpack_require__.d(stats_namespaceObject, {
|
|
5
|
+
getLatestDan: ()=>getLatestDan
|
|
6
|
+
});
|
|
7
|
+
function getLatestDan(that) {
|
|
8
|
+
return 0 === that.dans.length ? null : that.dans.reduce((latest, current)=>current.ctime > latest.ctime ? current : latest);
|
|
9
|
+
}
|
|
10
|
+
export { getLatestDan, stats_namespaceObject as stats };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.min.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { bili_dedupe_0 as bili_dedupe, to_bili_deduped } from "../157.min.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getLatestDan } from "../898.min.js";
|
|
@@ -120,8 +120,8 @@ export type DM_format = 'danuni.json' | 'danuni.pb.bin' | 'bili.xml' | 'bili.pb.
|
|
|
120
120
|
type shareItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'>>;
|
|
121
121
|
type statItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'mode' | 'fontsize' | 'color' | 'senderID' | 'content' | 'weight' | 'pool' | 'platform'>>;
|
|
122
122
|
type Stats<T extends keyof statItems> = Map<statItems[T], number>;
|
|
123
|
-
type UniPoolPipe = (that: UniPool) => Promise<
|
|
124
|
-
type UniPoolPipeSync = (that: UniPool) =>
|
|
123
|
+
type UniPoolPipe = (that: UniPool) => Promise<any>;
|
|
124
|
+
type UniPoolPipeSync = (that: UniPool) => any;
|
|
125
125
|
export interface Options {
|
|
126
126
|
dedupe?: boolean;
|
|
127
127
|
/**
|
|
@@ -145,8 +145,8 @@ export declare class UniPool {
|
|
|
145
145
|
*/
|
|
146
146
|
fromConverted: boolean;
|
|
147
147
|
});
|
|
148
|
-
pipe(fn:
|
|
149
|
-
pipeSync(fn:
|
|
148
|
+
pipe<T extends (...args: any) => any = UniPoolPipe>(fn: T): Promise<ReturnType<T>>;
|
|
149
|
+
pipeSync<T extends (...args: any) => any = UniPoolPipeSync>(fn: T): ReturnType<T>;
|
|
150
150
|
/**
|
|
151
151
|
* @deprecated 使用 `getShared` 代替
|
|
152
152
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as getLatestDan } from './getLatestDan';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/node/157.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
|
+
import { UniPool, platform_PlatformVideoSource } from "./17.js";
|
|
3
|
+
var bili_dedupe_namespaceObject = {};
|
|
4
|
+
__webpack_require__.r(bili_dedupe_namespaceObject);
|
|
5
|
+
__webpack_require__.d(bili_dedupe_namespaceObject, {
|
|
6
|
+
bili_dedupe: ()=>bili_dedupe,
|
|
7
|
+
to_bili_deduped: ()=>to_bili_deduped
|
|
8
|
+
});
|
|
9
|
+
function main(that) {
|
|
10
|
+
that.dans.forEach((d)=>{
|
|
11
|
+
if (d.platform !== platform_PlatformVideoSource.Bilibili) throw new Error('bili-dedupe: 仅支持B站(主站)的弹幕');
|
|
12
|
+
if (!d.extra.bili?.dmid) throw new Error('bili-dedupe: 弹幕缺少bili extra dmid字段');
|
|
13
|
+
});
|
|
14
|
+
const map = new Map();
|
|
15
|
+
that.dans.forEach((d)=>map.set(d.extra.bili.dmid, d));
|
|
16
|
+
return map;
|
|
17
|
+
}
|
|
18
|
+
function to_bili_deduped(that) {
|
|
19
|
+
const map = main(that);
|
|
20
|
+
return new UniPool([
|
|
21
|
+
...map.values()
|
|
22
|
+
], that.options, that.info);
|
|
23
|
+
}
|
|
24
|
+
function bili_dedupe(that) {
|
|
25
|
+
const map = main(that);
|
|
26
|
+
that.dans = [
|
|
27
|
+
...map.values()
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
export { bili_dedupe as bili_dedupe_0, bili_dedupe_namespaceObject as bili_dedupe, to_bili_deduped };
|
|
@@ -39,7 +39,7 @@ __webpack_require__.d(platform_namespaceObject, {
|
|
|
39
39
|
PlatformVideoSource: ()=>platform_PlatformVideoSource,
|
|
40
40
|
PlatformVideoSources: ()=>PlatformVideoSources
|
|
41
41
|
});
|
|
42
|
-
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.
|
|
42
|
+
var package_namespaceObject = JSON.parse('{"UU":"@dan-uni/dan-any","rE":"1.2.2","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
|
|
43
43
|
const color_pad = (s)=>s.length < 2 ? `0${s}` : s;
|
|
44
44
|
const decimalToHex = (n)=>color_pad(n.toString(16));
|
|
45
45
|
const isDarkColor = ({ r, g, b })=>0.299 * r + 0.587 * g + 0.114 * b < 0x30;
|
|
@@ -1861,4 +1861,4 @@ class UniPool {
|
|
|
1861
1861
|
}, canvasCtx);
|
|
1862
1862
|
}
|
|
1863
1863
|
}
|
|
1864
|
-
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_namespaceObject as platform };
|
|
1864
|
+
export { UniDM, UniPool, dm_gen_namespaceObject as UniDMTools, id_gen_namespaceObject as UniIDTools, platform_PlatformVideoSource, platform_namespaceObject as platform };
|
package/dist/node/898.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
|
+
var stats_namespaceObject = {};
|
|
3
|
+
__webpack_require__.r(stats_namespaceObject);
|
|
4
|
+
__webpack_require__.d(stats_namespaceObject, {
|
|
5
|
+
getLatestDan: ()=>getLatestDan
|
|
6
|
+
});
|
|
7
|
+
function getLatestDan(that) {
|
|
8
|
+
return 0 === that.dans.length ? null : that.dans.reduce((latest, current)=>current.ctime > latest.ctime ? current : latest);
|
|
9
|
+
}
|
|
10
|
+
export { getLatestDan, stats_namespaceObject as stats };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UniDM, UniDMTools, UniIDTools, UniPool, platform } from "./17.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { bili_dedupe_0 as bili_dedupe, to_bili_deduped } from "../157.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getLatestDan } from "../898.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { UniPool } from '../..';
|
|
2
|
+
import type { Context, SubtitleStyle } from '../types';
|
|
3
|
+
import type { RawConfig } from './raw';
|
|
4
|
+
export declare const ass: (list: UniPool, rawList: UniPool, config: SubtitleStyle, context?: Context, rawConfig?: RawConfig) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RGB } from '../types';
|
|
2
|
+
import { DanmakuType } from '../types';
|
|
3
|
+
export declare const dialogue: (danmaku: {
|
|
4
|
+
type: (typeof DanmakuType)[keyof typeof DanmakuType];
|
|
5
|
+
color: RGB;
|
|
6
|
+
fontSizeType: number;
|
|
7
|
+
content: string;
|
|
8
|
+
time: number;
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
top: number;
|
|
12
|
+
left: number;
|
|
13
|
+
}, config: {
|
|
14
|
+
scrollTime: number;
|
|
15
|
+
fixTime: number;
|
|
16
|
+
}) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Context, Danmaku, SubtitleStyle } from '../types';
|
|
2
|
+
type compressType = 'brotli' | 'gzip';
|
|
3
|
+
type baseType = 'base64' | 'base18384';
|
|
4
|
+
export interface RawConfig {
|
|
5
|
+
compressType: compressType;
|
|
6
|
+
baseType: baseType;
|
|
7
|
+
}
|
|
8
|
+
export declare function raw(list: Danmaku[], config: SubtitleStyle, context: Context, compressType?: compressType, baseType?: baseType): string;
|
|
9
|
+
export declare function deRaw(ass: string): {
|
|
10
|
+
list: Danmaku[];
|
|
11
|
+
config: SubtitleStyle;
|
|
12
|
+
context: Context;
|
|
13
|
+
} | undefined;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Options as UniPoolOptions } from '..';
|
|
2
|
+
import type { RawConfig } from './ass/raw';
|
|
3
|
+
import type { CanvasCtx, SubtitleStyle } from './types';
|
|
4
|
+
import { UniPool } from '..';
|
|
5
|
+
export { CanvasCtx };
|
|
6
|
+
export type Options = {
|
|
7
|
+
filename?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
substyle?: Partial<SubtitleStyle>;
|
|
10
|
+
raw?: RawConfig;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 使用bilibili弹幕(XMl)生成ASS字幕文件
|
|
14
|
+
* @param {string} danmaku XML弹幕文件内容
|
|
15
|
+
* @param {Options} options 杂项
|
|
16
|
+
* @returns {string} 返回ASS字幕文件内容
|
|
17
|
+
* @description 杂项相关
|
|
18
|
+
`filename`: 还原文件为XML时使用的默认文件名
|
|
19
|
+
`title`: ASS [Script Info] Title 项的值,显示于播放器字幕选择
|
|
20
|
+
`substyle`: ASS字幕样式
|
|
21
|
+
* @example ```ts
|
|
22
|
+
import fs from 'fs'
|
|
23
|
+
const filename = 'example.xml'
|
|
24
|
+
const xmlText = fs.readFileSync(filename, 'utf-8')
|
|
25
|
+
const assText = generateASS(xmlText, { filename, title: 'Quick Example' })
|
|
26
|
+
fs.writeFileSync(`${filename}.ass`, assText, 'utf-8')
|
|
27
|
+
```
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateASS(danmaku: UniPool, options: Options, canvasCtx: CanvasCtx): string;
|
|
30
|
+
export declare function parseAssRawField(ass: string, options?: UniPoolOptions): UniPool;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { CanvasRenderingContext2D as NodeCRCtx2D } from 'canvas';
|
|
2
|
+
import type { UniDM } from '../utils/dm-gen';
|
|
3
|
+
/**
|
|
4
|
+
* 请根据您的使用环境提供一个 50x50 的 2D Canvas 上下文
|
|
5
|
+
* @example
|
|
6
|
+
* // Node.js + canvas
|
|
7
|
+
* import { createCanvas } from 'canvas'
|
|
8
|
+
* const canvas = createCanvas(50, 50)
|
|
9
|
+
* const ctx = canvas.getContext('2d')
|
|
10
|
+
* @example
|
|
11
|
+
* // Node.js + Fabric.js
|
|
12
|
+
* import { StaticCanvas } from 'fabric/node'
|
|
13
|
+
* const ctx = new StaticCanvas(null, { width: 50, height: 50 }).getContext()
|
|
14
|
+
* @example
|
|
15
|
+
* // Browser + Native Canvas
|
|
16
|
+
* const canvas = document.createElement('canvas')
|
|
17
|
+
* canvas.width = 50
|
|
18
|
+
* canvas.height = 50
|
|
19
|
+
* const ctx = canvas.getContext('2d')
|
|
20
|
+
* @example
|
|
21
|
+
* // Browser + Fabric.js
|
|
22
|
+
* import { Canvas } from 'fabric'
|
|
23
|
+
* const ctx = new Canvas('canvas', { width: 50, height: 50 }).getContext()
|
|
24
|
+
*/
|
|
25
|
+
export type CanvasCtx = NodeCRCtx2D | CanvasRenderingContext2D;
|
|
26
|
+
export interface Context {
|
|
27
|
+
filename: string;
|
|
28
|
+
title: string;
|
|
29
|
+
}
|
|
30
|
+
export interface SubtitleStyle {
|
|
31
|
+
fontSize: number[];
|
|
32
|
+
fontName: string;
|
|
33
|
+
color: string;
|
|
34
|
+
outlineColor?: string;
|
|
35
|
+
backColor?: string;
|
|
36
|
+
outline: number;
|
|
37
|
+
shadow: number;
|
|
38
|
+
bold: boolean;
|
|
39
|
+
padding: number[];
|
|
40
|
+
playResX: number;
|
|
41
|
+
playResY: number;
|
|
42
|
+
scrollTime: number;
|
|
43
|
+
fixTime: number;
|
|
44
|
+
opacity: number;
|
|
45
|
+
bottomSpace: number;
|
|
46
|
+
includeRaw: boolean;
|
|
47
|
+
mergeIn: number;
|
|
48
|
+
}
|
|
49
|
+
export type RGB = {
|
|
50
|
+
r: number;
|
|
51
|
+
g: number;
|
|
52
|
+
b: number;
|
|
53
|
+
};
|
|
54
|
+
export declare const DanmakuType: {
|
|
55
|
+
SCROLL: number;
|
|
56
|
+
BOTTOM: number;
|
|
57
|
+
TOP: number;
|
|
58
|
+
};
|
|
59
|
+
export declare const FontSize: {
|
|
60
|
+
SMALL: number;
|
|
61
|
+
NORMAL: number;
|
|
62
|
+
LARGE: number;
|
|
63
|
+
};
|
|
64
|
+
export type Danmaku = {
|
|
65
|
+
time: number;
|
|
66
|
+
type: number;
|
|
67
|
+
fontSizeType: number;
|
|
68
|
+
color: RGB;
|
|
69
|
+
content: string;
|
|
70
|
+
extra: UniDM;
|
|
71
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RGB } from '../types';
|
|
2
|
+
export declare const hexColorToRGB: (hex: string) => {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const decimalColorToRGB: (decimal: number) => {
|
|
8
|
+
r: number;
|
|
9
|
+
g: number;
|
|
10
|
+
b: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const formatColor: ({ r, g, b }: RGB, opacity?: number) => string;
|
|
13
|
+
export declare const getDecoratingColor: (color: RGB) => {
|
|
14
|
+
r: number;
|
|
15
|
+
g: number;
|
|
16
|
+
b: number;
|
|
17
|
+
};
|
|
18
|
+
export declare const isWhite: (color: RGB) => boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Options as UniPoolOptions } from '../..';
|
|
2
|
+
import type { Danmaku } from '../types';
|
|
3
|
+
import { UniPool } from '../..';
|
|
4
|
+
export declare function UniPool2DanmakuLists(UP: UniPool): Danmaku[];
|
|
5
|
+
export declare function DanmakuList2UniPool(d: Danmaku[], options?: UniPoolOptions): UniPool;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { decimalColorToRGB, formatColor, getDecoratingColor, hexColorToRGB, isWhite, } from './color';
|
|
2
|
+
export { DanmakuList2UniPool, UniPool2DanmakuLists } from './danconvert';
|
|
3
|
+
export { arrayOfLength, assign, uniqueArray } from './lang';
|
|
4
|
+
export { layoutDanmaku } from './layout';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { UniPool } from '../..';
|
|
2
|
+
import type { CanvasCtx, SubtitleStyle } from '../types';
|
|
3
|
+
export declare const measureTextWidthConstructor: (canvasContext: CanvasCtx) => (fontName: string, fontSize: number, bold: boolean, text: string) => number;
|
|
4
|
+
export declare const layoutDanmaku: (inputList: UniPool, config: SubtitleStyle, canvasCtx: CanvasCtx) => UniPool;
|