@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.
Files changed (126) hide show
  1. package/dist/browser/157.min.js +30 -0
  2. package/dist/{index.min.js → browser/17.min.js} +14 -8
  3. package/dist/browser/898.min.js +10 -0
  4. package/dist/browser/index.min.js +1 -0
  5. package/dist/browser/plugins/bili-dedupe.min.js +1 -0
  6. package/dist/browser/plugins/index.min.js +2 -0
  7. package/dist/browser/plugins/stats.min.js +1 -0
  8. package/dist/{src → browser/src}/index.d.ts +4 -4
  9. package/dist/browser/src/plugins/bili-dedupe/index.d.ts +3 -0
  10. package/dist/browser/src/plugins/index.d.ts +2 -0
  11. package/dist/browser/src/plugins/stats/getLatestDan.d.ts +6 -0
  12. package/dist/browser/src/plugins/stats/index.d.ts +1 -0
  13. package/dist/browser/src/plugins/stats/index.test.d.ts +1 -0
  14. package/dist/browser/src/utils/dm-gen.test.d.ts +1 -0
  15. package/dist/node/157.js +30 -0
  16. package/dist/{index.js → node/17.js} +2 -2
  17. package/dist/node/898.js +10 -0
  18. package/dist/node/index.js +1 -0
  19. package/dist/node/plugins/bili-dedupe.js +1 -0
  20. package/dist/node/plugins/index.js +2 -0
  21. package/dist/node/plugins/stats.js +1 -0
  22. package/dist/node/src/ass-gen/__tests__/canvas.test.d.ts +1 -0
  23. package/dist/node/src/ass-gen/__tests__/generate.test.d.ts +1 -0
  24. package/dist/node/src/ass-gen/ass/create.d.ts +4 -0
  25. package/dist/node/src/ass-gen/ass/dialogue.d.ts +16 -0
  26. package/dist/node/src/ass-gen/ass/event.d.ts +2 -0
  27. package/dist/node/src/ass-gen/ass/info.d.ts +8 -0
  28. package/dist/node/src/ass-gen/ass/raw.d.ts +14 -0
  29. package/dist/node/src/ass-gen/ass/style.d.ts +2 -0
  30. package/dist/node/src/ass-gen/config.d.ts +2 -0
  31. package/dist/node/src/ass-gen/index.d.ts +30 -0
  32. package/dist/node/src/ass-gen/types.d.ts +71 -0
  33. package/dist/node/src/ass-gen/util/color.d.ts +18 -0
  34. package/dist/node/src/ass-gen/util/danconvert.d.ts +5 -0
  35. package/dist/node/src/ass-gen/util/index.d.ts +4 -0
  36. package/dist/node/src/ass-gen/util/lang.d.ts +3 -0
  37. package/dist/node/src/ass-gen/util/layout.d.ts +4 -0
  38. package/dist/node/src/index.d.ts +255 -0
  39. package/dist/node/src/index.test.d.ts +1 -0
  40. package/dist/node/src/plugins/bili-dedupe/index.d.ts +3 -0
  41. package/dist/node/src/plugins/bili-dedupe/index.test.d.ts +1 -0
  42. package/dist/node/src/plugins/index.d.ts +2 -0
  43. package/dist/node/src/plugins/stats/getLatestDan.d.ts +6 -0
  44. package/dist/node/src/plugins/stats/index.d.ts +1 -0
  45. package/dist/node/src/plugins/stats/index.test.d.ts +1 -0
  46. package/dist/node/src/proto/gen/bili/dm_pb.d.ts +3426 -0
  47. package/dist/node/src/proto/gen/danuni_pb.d.ts +172 -0
  48. package/dist/node/src/utils/dm-gen.d.ts +309 -0
  49. package/dist/node/src/utils/dm-gen.test.d.ts +1 -0
  50. package/dist/node/src/utils/id-gen.d.ts +50 -0
  51. package/dist/node/src/utils/platform.d.ts +24 -0
  52. package/dist/{index.umd.min.js → umd/index.umd.min.js} +76 -67
  53. package/dist/umd/plugins/bili-dedupe.umd.min.js +25028 -0
  54. package/dist/umd/plugins/bili-dedupe.umd.min.js.LICENSE.txt +34 -0
  55. package/dist/umd/plugins/index.umd.min.js +25048 -0
  56. package/dist/umd/plugins/index.umd.min.js.LICENSE.txt +34 -0
  57. package/dist/umd/plugins/stats.umd.min.js +39 -0
  58. package/dist/umd/src/ass-gen/__tests__/canvas.test.d.ts +1 -0
  59. package/dist/umd/src/ass-gen/__tests__/generate.test.d.ts +1 -0
  60. package/dist/umd/src/ass-gen/ass/create.d.ts +4 -0
  61. package/dist/umd/src/ass-gen/ass/dialogue.d.ts +16 -0
  62. package/dist/umd/src/ass-gen/ass/event.d.ts +2 -0
  63. package/dist/umd/src/ass-gen/ass/info.d.ts +8 -0
  64. package/dist/umd/src/ass-gen/ass/raw.d.ts +14 -0
  65. package/dist/umd/src/ass-gen/ass/style.d.ts +2 -0
  66. package/dist/umd/src/ass-gen/config.d.ts +2 -0
  67. package/dist/umd/src/ass-gen/index.d.ts +30 -0
  68. package/dist/umd/src/ass-gen/types.d.ts +71 -0
  69. package/dist/umd/src/ass-gen/util/color.d.ts +18 -0
  70. package/dist/umd/src/ass-gen/util/danconvert.d.ts +5 -0
  71. package/dist/umd/src/ass-gen/util/index.d.ts +4 -0
  72. package/dist/umd/src/ass-gen/util/lang.d.ts +3 -0
  73. package/dist/umd/src/ass-gen/util/layout.d.ts +4 -0
  74. package/dist/umd/src/index.d.ts +255 -0
  75. package/dist/umd/src/index.test.d.ts +1 -0
  76. package/dist/umd/src/plugins/bili-dedupe/index.d.ts +3 -0
  77. package/dist/umd/src/plugins/bili-dedupe/index.test.d.ts +1 -0
  78. package/dist/umd/src/plugins/index.d.ts +2 -0
  79. package/dist/umd/src/plugins/stats/getLatestDan.d.ts +6 -0
  80. package/dist/umd/src/plugins/stats/index.d.ts +1 -0
  81. package/dist/umd/src/plugins/stats/index.test.d.ts +1 -0
  82. package/dist/umd/src/proto/gen/bili/dm_pb.d.ts +3426 -0
  83. package/dist/umd/src/proto/gen/danuni_pb.d.ts +172 -0
  84. package/dist/umd/src/utils/dm-gen.d.ts +309 -0
  85. package/dist/umd/src/utils/dm-gen.test.d.ts +1 -0
  86. package/dist/umd/src/utils/id-gen.d.ts +50 -0
  87. package/dist/umd/src/utils/platform.d.ts +24 -0
  88. package/package.json +8 -8
  89. package/plugins/package.json +6 -0
  90. package/rslib.config.ts +11 -0
  91. package/src/index.ts +8 -4
  92. package/src/plugins/bili-dedupe/index.test.ts +43 -0
  93. package/src/plugins/bili-dedupe/index.ts +29 -0
  94. package/src/plugins/index.ts +2 -0
  95. package/src/plugins/stats/getLatestDan.ts +13 -0
  96. package/src/plugins/stats/index.test.ts +39 -0
  97. package/src/plugins/stats/index.ts +1 -0
  98. package/src/proto/gen/bili/dm_pb.ts +1 -1
  99. package/src/proto/gen/danuni_pb.ts +1 -1
  100. /package/dist/{index.min.js.LICENSE.txt → browser/17.min.js.LICENSE.txt} +0 -0
  101. /package/dist/{rslib-runtime.min.js → browser/rslib-runtime.min.js} +0 -0
  102. /package/dist/{src → browser/src}/ass-gen/__tests__/canvas.test.d.ts +0 -0
  103. /package/dist/{src → browser/src}/ass-gen/__tests__/generate.test.d.ts +0 -0
  104. /package/dist/{src → browser/src}/ass-gen/ass/create.d.ts +0 -0
  105. /package/dist/{src → browser/src}/ass-gen/ass/dialogue.d.ts +0 -0
  106. /package/dist/{src → browser/src}/ass-gen/ass/event.d.ts +0 -0
  107. /package/dist/{src → browser/src}/ass-gen/ass/info.d.ts +0 -0
  108. /package/dist/{src → browser/src}/ass-gen/ass/raw.d.ts +0 -0
  109. /package/dist/{src → browser/src}/ass-gen/ass/style.d.ts +0 -0
  110. /package/dist/{src → browser/src}/ass-gen/config.d.ts +0 -0
  111. /package/dist/{src → browser/src}/ass-gen/index.d.ts +0 -0
  112. /package/dist/{src → browser/src}/ass-gen/types.d.ts +0 -0
  113. /package/dist/{src → browser/src}/ass-gen/util/color.d.ts +0 -0
  114. /package/dist/{src → browser/src}/ass-gen/util/danconvert.d.ts +0 -0
  115. /package/dist/{src → browser/src}/ass-gen/util/index.d.ts +0 -0
  116. /package/dist/{src → browser/src}/ass-gen/util/lang.d.ts +0 -0
  117. /package/dist/{src → browser/src}/ass-gen/util/layout.d.ts +0 -0
  118. /package/dist/{src → browser/src}/index.test.d.ts +0 -0
  119. /package/dist/{src/utils/dm-gen.test.d.ts → browser/src/plugins/bili-dedupe/index.test.d.ts} +0 -0
  120. /package/dist/{src → browser/src}/proto/gen/bili/dm_pb.d.ts +0 -0
  121. /package/dist/{src → browser/src}/proto/gen/danuni_pb.d.ts +0 -0
  122. /package/dist/{src → browser/src}/utils/dm-gen.d.ts +0 -0
  123. /package/dist/{src → browser/src}/utils/id-gen.d.ts +0 -0
  124. /package/dist/{src → browser/src}/utils/platform.d.ts +0 -0
  125. /package/dist/{rslib-runtime.js → node/rslib-runtime.js} +0 -0
  126. /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 index.min.js.LICENSE.txt */
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.19/node_modules/which-typed-array/index.js");
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.19/node_modules/which-typed-array/index.js");
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.19/node_modules/which-typed-array/index.js" (module, __unused_rspack_exports, __webpack_require__) {
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
- cache['$' + typedArray] = callBind(descriptor.get);
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) cache['$' + typedArray] = callBind(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.0.1","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
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,2 @@
1
+ export { bili_dedupe } from "../157.min.js";
2
+ export { stats } from "../898.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<UniPool>;
124
- type UniPoolPipeSync = (that: UniPool) => 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: UniPoolPipe): Promise<UniPool>;
149
- pipeSync(fn: UniPoolPipeSync): UniPool;
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,3 @@
1
+ import { UniPool } from '../..';
2
+ export declare function to_bili_deduped(that: UniPool): UniPool;
3
+ export declare function bili_dedupe(that: UniPool): void;
@@ -0,0 +1,2 @@
1
+ export * as bili_dedupe from './bili-dedupe';
2
+ export * as stats from './stats';
@@ -0,0 +1,6 @@
1
+ import type { UniDM, UniPool } from '../..';
2
+ /**
3
+ * 从弹幕池中查找出最新的一条弹幕
4
+ * 按照弹幕的创建时间(ctime)排序,返回最新的一条
5
+ */
6
+ export default function getLatestDan(that: UniPool): UniDM | null;
@@ -0,0 +1 @@
1
+ export { default as getLatestDan } from './getLatestDan';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -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.0.1","TB":"https://github.com/ani-uni/danuni/tree/master/packages/dan-any#readme"}');
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 };
@@ -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,2 @@
1
+ export { bili_dedupe } from "../157.js";
2
+ export { stats } from "../898.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,2 @@
1
+ import type { Danmaku, SubtitleStyle } from '../types';
2
+ export declare const event: (list: Danmaku[], config: SubtitleStyle) => string;
@@ -0,0 +1,8 @@
1
+ import type { Context } from '../types';
2
+ type ExtraInfo = Context;
3
+ type Resolution = {
4
+ playResX: number;
5
+ playResY: number;
6
+ };
7
+ export declare const info: ({ playResX, playResY }: Resolution, { filename, title }: ExtraInfo) => string;
8
+ export {};
@@ -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,2 @@
1
+ import type { SubtitleStyle } from '../types';
2
+ export declare const style: ({ fontName, fontSize, color: configColor, outlineColor, backColor, bold, outline, shadow, opacity, }: SubtitleStyle) => string;
@@ -0,0 +1,2 @@
1
+ import type { SubtitleStyle } from './types';
2
+ export declare const getConfig: (overrides?: {}) => SubtitleStyle;
@@ -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,3 @@
1
+ export declare const assign: <T extends object>(source: T, ...targets: Partial<T>[]) => T;
2
+ export declare const arrayOfLength: <T>(length: number, defaultValue: T) => T[];
3
+ export declare const uniqueArray: <T>(array: T[]) => T[];
@@ -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;