@dan-uni/dan-any 1.4.8 → 2.0.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.
Files changed (200) hide show
  1. package/README.md +87 -43
  2. package/dist/adapters.d.mts +2 -0
  3. package/dist/adapters.mjs +1 -0
  4. package/dist/chunk-0Lt9GpW0.mjs +1 -0
  5. package/dist/core/db/schema.d.mts +2 -0
  6. package/dist/core/db/schema.mjs +2 -0
  7. package/dist/core/db/schema.mjs.map +1 -0
  8. package/dist/core/db/utils.d.mts +1707 -0
  9. package/dist/core/db/utils.d.mts.map +1 -0
  10. package/dist/core/db/utils.mjs +1 -0
  11. package/dist/core-D7LMAB5h.mjs +2 -0
  12. package/dist/core-D7LMAB5h.mjs.map +1 -0
  13. package/dist/core.d.mts +2 -0
  14. package/dist/core.mjs +1 -0
  15. package/dist/db-DWWzkRBb.mjs +41 -0
  16. package/dist/db-DWWzkRBb.mjs.map +1 -0
  17. package/dist/dm-extra-DrAQCrFv.d.mts +135 -0
  18. package/dist/dm-extra-DrAQCrFv.d.mts.map +1 -0
  19. package/dist/dm-tkTdR_W6.mjs +2 -0
  20. package/dist/dm-tkTdR_W6.mjs.map +1 -0
  21. package/dist/index-vAs4qV9A.d.mts +6195 -0
  22. package/dist/index-vAs4qV9A.d.mts.map +1 -0
  23. package/dist/index.d.mts +4 -0
  24. package/dist/index.mjs +1 -0
  25. package/dist/isSame-D4G9eoE4.mjs +2 -0
  26. package/dist/isSame-D4G9eoE4.mjs.map +1 -0
  27. package/dist/plugins.d.mts +105 -0
  28. package/dist/plugins.d.mts.map +1 -0
  29. package/dist/plugins.mjs +2 -0
  30. package/dist/plugins.mjs.map +1 -0
  31. package/dist/schema-BuenbDx9.d.mts +1619 -0
  32. package/dist/schema-BuenbDx9.d.mts.map +1 -0
  33. package/dist/utils.d.mts +25 -0
  34. package/dist/utils.d.mts.map +1 -0
  35. package/dist/utils.mjs +2 -0
  36. package/dist/utils.mjs.map +1 -0
  37. package/package.json +65 -37
  38. package/.babelrc.json +0 -12
  39. package/buf.gen.yaml +0 -10
  40. package/buf.yaml +0 -12
  41. package/dist/browser/1~rslib-runtime.min.js +0 -49
  42. package/dist/browser/index.min.js +0 -13523
  43. package/dist/browser/index.min.js.LICENSE.txt +0 -17
  44. package/dist/browser/plugins/bili.min.js +0 -1
  45. package/dist/browser/plugins/index.min.js +0 -2
  46. package/dist/browser/plugins/stats.min.js +0 -10
  47. package/dist/browser/src/ass-gen/__tests__/canvas.test.d.ts +0 -1
  48. package/dist/browser/src/ass-gen/__tests__/generate.test.d.ts +0 -1
  49. package/dist/browser/src/ass-gen/ass/create.d.ts +0 -4
  50. package/dist/browser/src/ass-gen/ass/dialogue.d.ts +0 -16
  51. package/dist/browser/src/ass-gen/ass/event.d.ts +0 -2
  52. package/dist/browser/src/ass-gen/ass/info.d.ts +0 -8
  53. package/dist/browser/src/ass-gen/ass/raw.d.ts +0 -14
  54. package/dist/browser/src/ass-gen/ass/style.d.ts +0 -2
  55. package/dist/browser/src/ass-gen/config.d.ts +0 -2
  56. package/dist/browser/src/ass-gen/index.d.ts +0 -30
  57. package/dist/browser/src/ass-gen/types.d.ts +0 -71
  58. package/dist/browser/src/ass-gen/util/color.d.ts +0 -18
  59. package/dist/browser/src/ass-gen/util/danconvert.d.ts +0 -5
  60. package/dist/browser/src/ass-gen/util/index.d.ts +0 -4
  61. package/dist/browser/src/ass-gen/util/lang.d.ts +0 -3
  62. package/dist/browser/src/ass-gen/util/layout.d.ts +0 -4
  63. package/dist/browser/src/index.d.ts +0 -283
  64. package/dist/browser/src/index.test.d.ts +0 -1
  65. package/dist/browser/src/plugins/bili/dedupe.d.ts +0 -3
  66. package/dist/browser/src/plugins/bili/history-danmaku-fast-forward.d.ts +0 -18
  67. package/dist/browser/src/plugins/bili/index.d.ts +0 -2
  68. package/dist/browser/src/plugins/bili/index.test.d.ts +0 -1
  69. package/dist/browser/src/plugins/index.d.ts +0 -2
  70. package/dist/browser/src/plugins/stats/getLatestDan.d.ts +0 -6
  71. package/dist/browser/src/plugins/stats/index.d.ts +0 -1
  72. package/dist/browser/src/plugins/stats/index.test.d.ts +0 -1
  73. package/dist/browser/src/proto/gen/bilibili/community/service/dm/v1/dm_pb.d.ts +0 -3426
  74. package/dist/browser/src/proto/gen/danuni/danmaku/v1/danmaku_pb.d.ts +0 -176
  75. package/dist/browser/src/utils/dm-gen.d.ts +0 -309
  76. package/dist/browser/src/utils/dm-gen.test.d.ts +0 -1
  77. package/dist/browser/src/utils/fileParser.d.ts +0 -3
  78. package/dist/browser/src/utils/id-gen.d.ts +0 -50
  79. package/dist/browser/src/utils/platform.d.ts +0 -24
  80. package/dist/node/0~rslib-runtime.js +0 -23
  81. package/dist/node/index.js +0 -2099
  82. package/dist/node/plugins/bili.js +0 -1
  83. package/dist/node/plugins/index.js +0 -2
  84. package/dist/node/plugins/stats.js +0 -10
  85. package/dist/node/src/ass-gen/__tests__/canvas.test.d.ts +0 -1
  86. package/dist/node/src/ass-gen/__tests__/generate.test.d.ts +0 -1
  87. package/dist/node/src/ass-gen/ass/create.d.ts +0 -4
  88. package/dist/node/src/ass-gen/ass/dialogue.d.ts +0 -16
  89. package/dist/node/src/ass-gen/ass/event.d.ts +0 -2
  90. package/dist/node/src/ass-gen/ass/info.d.ts +0 -8
  91. package/dist/node/src/ass-gen/ass/raw.d.ts +0 -14
  92. package/dist/node/src/ass-gen/ass/style.d.ts +0 -2
  93. package/dist/node/src/ass-gen/config.d.ts +0 -2
  94. package/dist/node/src/ass-gen/index.d.ts +0 -30
  95. package/dist/node/src/ass-gen/types.d.ts +0 -71
  96. package/dist/node/src/ass-gen/util/color.d.ts +0 -18
  97. package/dist/node/src/ass-gen/util/danconvert.d.ts +0 -5
  98. package/dist/node/src/ass-gen/util/index.d.ts +0 -4
  99. package/dist/node/src/ass-gen/util/lang.d.ts +0 -3
  100. package/dist/node/src/ass-gen/util/layout.d.ts +0 -4
  101. package/dist/node/src/index.d.ts +0 -283
  102. package/dist/node/src/index.test.d.ts +0 -1
  103. package/dist/node/src/plugins/bili/dedupe.d.ts +0 -3
  104. package/dist/node/src/plugins/bili/history-danmaku-fast-forward.d.ts +0 -18
  105. package/dist/node/src/plugins/bili/index.d.ts +0 -2
  106. package/dist/node/src/plugins/bili/index.test.d.ts +0 -1
  107. package/dist/node/src/plugins/index.d.ts +0 -2
  108. package/dist/node/src/plugins/stats/getLatestDan.d.ts +0 -6
  109. package/dist/node/src/plugins/stats/index.d.ts +0 -1
  110. package/dist/node/src/plugins/stats/index.test.d.ts +0 -1
  111. package/dist/node/src/proto/gen/bilibili/community/service/dm/v1/dm_pb.d.ts +0 -3426
  112. package/dist/node/src/proto/gen/danuni/danmaku/v1/danmaku_pb.d.ts +0 -176
  113. package/dist/node/src/utils/dm-gen.d.ts +0 -309
  114. package/dist/node/src/utils/dm-gen.test.d.ts +0 -1
  115. package/dist/node/src/utils/fileParser.d.ts +0 -3
  116. package/dist/node/src/utils/id-gen.d.ts +0 -50
  117. package/dist/node/src/utils/platform.d.ts +0 -24
  118. package/dist/umd/index.umd.min.js +0 -32093
  119. package/dist/umd/index.umd.min.js.LICENSE.txt +0 -34
  120. package/dist/umd/plugins/bili.umd.min.js +0 -32004
  121. package/dist/umd/plugins/bili.umd.min.js.LICENSE.txt +0 -34
  122. package/dist/umd/plugins/index.umd.min.js +0 -32020
  123. package/dist/umd/plugins/index.umd.min.js.LICENSE.txt +0 -34
  124. package/dist/umd/plugins/stats.umd.min.js +0 -39
  125. package/dist/umd/src/ass-gen/__tests__/canvas.test.d.ts +0 -1
  126. package/dist/umd/src/ass-gen/__tests__/generate.test.d.ts +0 -1
  127. package/dist/umd/src/ass-gen/ass/create.d.ts +0 -4
  128. package/dist/umd/src/ass-gen/ass/dialogue.d.ts +0 -16
  129. package/dist/umd/src/ass-gen/ass/event.d.ts +0 -2
  130. package/dist/umd/src/ass-gen/ass/info.d.ts +0 -8
  131. package/dist/umd/src/ass-gen/ass/raw.d.ts +0 -14
  132. package/dist/umd/src/ass-gen/ass/style.d.ts +0 -2
  133. package/dist/umd/src/ass-gen/config.d.ts +0 -2
  134. package/dist/umd/src/ass-gen/index.d.ts +0 -30
  135. package/dist/umd/src/ass-gen/types.d.ts +0 -71
  136. package/dist/umd/src/ass-gen/util/color.d.ts +0 -18
  137. package/dist/umd/src/ass-gen/util/danconvert.d.ts +0 -5
  138. package/dist/umd/src/ass-gen/util/index.d.ts +0 -4
  139. package/dist/umd/src/ass-gen/util/lang.d.ts +0 -3
  140. package/dist/umd/src/ass-gen/util/layout.d.ts +0 -4
  141. package/dist/umd/src/index.d.ts +0 -283
  142. package/dist/umd/src/index.test.d.ts +0 -1
  143. package/dist/umd/src/plugins/bili/dedupe.d.ts +0 -3
  144. package/dist/umd/src/plugins/bili/history-danmaku-fast-forward.d.ts +0 -18
  145. package/dist/umd/src/plugins/bili/index.d.ts +0 -2
  146. package/dist/umd/src/plugins/bili/index.test.d.ts +0 -1
  147. package/dist/umd/src/plugins/index.d.ts +0 -2
  148. package/dist/umd/src/plugins/stats/getLatestDan.d.ts +0 -6
  149. package/dist/umd/src/plugins/stats/index.d.ts +0 -1
  150. package/dist/umd/src/plugins/stats/index.test.d.ts +0 -1
  151. package/dist/umd/src/proto/gen/bilibili/community/service/dm/v1/dm_pb.d.ts +0 -3426
  152. package/dist/umd/src/proto/gen/danuni/danmaku/v1/danmaku_pb.d.ts +0 -176
  153. package/dist/umd/src/utils/dm-gen.d.ts +0 -309
  154. package/dist/umd/src/utils/dm-gen.test.d.ts +0 -1
  155. package/dist/umd/src/utils/fileParser.d.ts +0 -3
  156. package/dist/umd/src/utils/id-gen.d.ts +0 -50
  157. package/dist/umd/src/utils/platform.d.ts +0 -24
  158. package/plugins/package.json +0 -6
  159. package/rslib.config.ts +0 -101
  160. package/src/ass-gen/__tests__/898651903.xml +0 -1619
  161. package/src/ass-gen/__tests__/898651903.xml.ass +0 -1516
  162. package/src/ass-gen/__tests__/canvas.test.ts +0 -15
  163. package/src/ass-gen/__tests__/generate.test.ts +0 -26
  164. package/src/ass-gen/ass/create.ts +0 -37
  165. package/src/ass-gen/ass/dialogue.ts +0 -90
  166. package/src/ass-gen/ass/event.ts +0 -57
  167. package/src/ass-gen/ass/info.ts +0 -27
  168. package/src/ass-gen/ass/raw.ts +0 -78
  169. package/src/ass-gen/ass/style.ts +0 -66
  170. package/src/ass-gen/config.ts +0 -45
  171. package/src/ass-gen/index.ts +0 -73
  172. package/src/ass-gen/types.ts +0 -76
  173. package/src/ass-gen/util/color.ts +0 -55
  174. package/src/ass-gen/util/danconvert.ts +0 -43
  175. package/src/ass-gen/util/index.ts +0 -10
  176. package/src/ass-gen/util/lang.ts +0 -35
  177. package/src/ass-gen/util/layout.ts +0 -242
  178. package/src/index.test.ts +0 -157
  179. package/src/index.ts +0 -1144
  180. package/src/plugins/bili/README.md +0 -87
  181. package/src/plugins/bili/dedupe.ts +0 -29
  182. package/src/plugins/bili/history-danmaku-fast-forward.ts +0 -86
  183. package/src/plugins/bili/index.test.ts +0 -129
  184. package/src/plugins/bili/index.ts +0 -2
  185. package/src/plugins/index.ts +0 -2
  186. package/src/plugins/stats/README.md +0 -44
  187. package/src/plugins/stats/getLatestDan.ts +0 -13
  188. package/src/plugins/stats/index.test.ts +0 -39
  189. package/src/plugins/stats/index.ts +0 -1
  190. package/src/proto/gen/bilibili/community/service/dm/v1/dm_pb.ts +0 -4072
  191. package/src/proto/gen/danuni/danmaku/v1/danmaku_pb.ts +0 -223
  192. package/src/proto/src/bilibili/community/service/dm/v1/dm.proto +0 -1095
  193. package/src/proto/src/danuni/danmaku/v1/danmaku.proto +0 -52
  194. package/src/utils/dm-gen.test.ts +0 -129
  195. package/src/utils/dm-gen.ts +0 -1082
  196. package/src/utils/fileParser.ts +0 -37
  197. package/src/utils/id-gen.ts +0 -73
  198. package/src/utils/platform.ts +0 -38
  199. package/tsconfig.json +0 -108
  200. package/types/tsconfig.tsbuildinfo +0 -1
@@ -1,34 +0,0 @@
1
- /*!
2
- * The buffer module from node.js, for the browser.
3
- *
4
- * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
5
- * @license MIT
6
- */
7
-
8
- /*!
9
- * The buffer module from node.js, for the browser.
10
- *
11
- * @author Feross Aboukhadijeh <https://feross.org>
12
- * @license MIT
13
- */
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
-
30
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
31
-
32
- /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
33
-
34
- /*! zero-fill. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -1,39 +0,0 @@
1
- (function(root, factory) {
2
- if ('object' == typeof exports && 'object' == typeof module) module.exports = factory();
3
- else if ('function' == typeof define && define.amd) define([], factory);
4
- else if ('object' == typeof exports) exports["@dan-uni/dan-any"] = factory();
5
- else root["@dan-uni/dan-any"] = factory();
6
- })(globalThis, ()=>(()=>{
7
- "use strict";
8
- var __webpack_require__ = {};
9
- (()=>{
10
- __webpack_require__.d = (exports1, definition)=>{
11
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
12
- enumerable: true,
13
- get: definition[key]
14
- });
15
- };
16
- })();
17
- (()=>{
18
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
19
- })();
20
- (()=>{
21
- __webpack_require__.r = (exports1)=>{
22
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
23
- value: 'Module'
24
- });
25
- Object.defineProperty(exports1, '__esModule', {
26
- value: true
27
- });
28
- };
29
- })();
30
- var __webpack_exports__ = {};
31
- __webpack_require__.r(__webpack_exports__);
32
- __webpack_require__.d(__webpack_exports__, {
33
- getLatestDan: ()=>getLatestDan
34
- });
35
- function getLatestDan(that) {
36
- return 0 === that.dans.length ? null : that.dans.reduce((latest, current)=>current.ctime > latest.ctime ? current : latest);
37
- }
38
- return __webpack_exports__;
39
- })());
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
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;
@@ -1,16 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import type { Danmaku, SubtitleStyle } from '../types';
2
- export declare const event: (list: Danmaku[], config: SubtitleStyle) => string;
@@ -1,8 +0,0 @@
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 {};
@@ -1,14 +0,0 @@
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 {};
@@ -1,2 +0,0 @@
1
- import type { SubtitleStyle } from '../types';
2
- export declare const style: ({ fontName, fontSize, color: configColor, outlineColor, backColor, bold, outline, shadow, opacity, }: SubtitleStyle) => string;
@@ -1,2 +0,0 @@
1
- import type { SubtitleStyle } from './types';
2
- export declare const getConfig: (overrides?: {}) => SubtitleStyle;
@@ -1,30 +0,0 @@
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;
@@ -1,71 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
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;
@@ -1,5 +0,0 @@
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;
@@ -1,4 +0,0 @@
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';
@@ -1,3 +0,0 @@
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[];
@@ -1,4 +0,0 @@
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;
@@ -1,283 +0,0 @@
1
- import 'reflect-metadata/lite';
2
- import type { Options as AssGenOptions, CanvasCtx } from './ass-gen';
3
- import type { CommandDm as DM_JSON_BiliCommandGrpc } from './proto/gen/bilibili/community/service/dm/v1/dm_pb';
4
- import { UniDM } from './utils/dm-gen';
5
- import * as UniDMTools from './utils/dm-gen';
6
- import * as UniIDTools from './utils/id-gen';
7
- import * as platform from './utils/platform';
8
- interface DanUniConvertTip {
9
- meassage: string;
10
- version: string;
11
- data?: string;
12
- }
13
- export type DM_JSON_DanuniMin = Partial<UniDMTools.UniDMObj>[];
14
- export interface DM_XML_Bili {
15
- i: {
16
- chatserver: string;
17
- chatid: bigint;
18
- mission: number;
19
- maxlimit: number;
20
- state: number;
21
- real_name: number;
22
- source: string;
23
- d: {
24
- '#text': string;
25
- '@_p': string;
26
- }[];
27
- };
28
- }
29
- export interface DM_JSON_BiliUp {
30
- /** 接口状态码,0 表示成功 */
31
- code: number;
32
- /** 文本形式的状态码,约定为字符串 "0" */
33
- message: string;
34
- /** TTL(time to live) 标识,本接口常量为 1 */
35
- ttl: number;
36
- data: {
37
- /** 分页元信息 */
38
- page: {
39
- /** 当前页序号,从 1 开始 */
40
- num: number;
41
- /** 每页返回的弹幕条数 */
42
- size: number;
43
- /** 总页数 */
44
- total: number;
45
- };
46
- result: {
47
- /** 弹幕 ID,int64 */
48
- id: bigint;
49
- /** 弹幕 ID 字符串形式 */
50
- id_str: string;
51
- /** 弹幕类型:1 表示视频弹幕(当前接口恒为 1) */
52
- type: number;
53
- aid: bigint;
54
- bvid: string;
55
- oid: bigint;
56
- mid: bigint;
57
- /** 发送者 mid 的 CRC 哈希(正常接口里用的是这个,保护隐私) */
58
- mid_hash: string;
59
- /** 弹幕池 */
60
- pool: number;
61
- /** 属性位字符串,逗号分隔的数字列表,对应 attr 二进制位 */
62
- attrs: string;
63
- /** 弹幕出现时间,单位毫秒(注意,此处与protobuf接口保持一致,但xml中progress是秒) */
64
- progress: number;
65
- mode: number;
66
- /** 弹幕内容, content */
67
- msg: string;
68
- state: number;
69
- fontsize: number;
70
- /** 弹幕颜色,需将16进制转化为普通弹幕的10进制,示例:"ffffff" */
71
- color: string;
72
- /** 发送时间戳,单位秒 */
73
- ctime: number;
74
- /** 发送者昵称 */
75
- uname: string;
76
- /** 发送者头像链接 */
77
- uface: string;
78
- /** 视频主标题 */
79
- title: string;
80
- self_seen: boolean;
81
- /** 弹幕点赞数 */
82
- like_count: number;
83
- user_like: number;
84
- /** 分 P 标题 */
85
- p_title: string;
86
- /** 视频封面链接 */
87
- cover: string;
88
- is_charge: boolean;
89
- is_charge_plus: boolean;
90
- following: boolean;
91
- extra_cps: null;
92
- }[];
93
- };
94
- }
95
- export interface DM_JSON_Dplayer {
96
- code: number;
97
- /**
98
- * progress,mode,color,midHash,content
99
- */
100
- data: [number, number, number, string, string][];
101
- }
102
- export interface DM_JSON_Artplayer {
103
- danmuku: {
104
- text: string;
105
- time?: number;
106
- mode?: number;
107
- color?: string;
108
- border?: boolean;
109
- style?: {};
110
- }[];
111
- }
112
- export interface DM_JSON_DDPlay {
113
- count: number | string;
114
- comments: {
115
- cid: bigint;
116
- p: string;
117
- m: string;
118
- }[];
119
- }
120
- export declare enum DM_format {
121
- DanuniJson = "danuni.json",
122
- DanuniMinJson = "danuni.min.json",
123
- DanuniPbBin = "danuni.binpb",
124
- BiliXml = "bili.xml",
125
- BiliPbBin = "bili.binpb",
126
- BiliCmdPbBin = "bili.cmd.binpb",
127
- BiliUpJson = "bili.up.json",
128
- DplayerJson = "dplayer.json",
129
- ArtplayerJson = "artplayer.json",
130
- DDPlayJson = "ddplay.json",
131
- CommonAss = "common.ass"
132
- }
133
- type shareItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'senderID' | 'platform' | 'SOID' | 'pool' | 'mode' | 'color'>>;
134
- type statItems = Partial<Pick<UniDMTools.UniDMObj, 'SOID' | 'mode' | 'fontsize' | 'color' | 'senderID' | 'content' | 'weight' | 'pool' | 'platform'>>;
135
- type Stats<T extends keyof statItems> = Map<statItems[T], number>;
136
- export interface Options {
137
- dedupe?: boolean;
138
- /**
139
- * @description
140
- * 当为`false`时,关闭DMID生成; 当为正整数时,表示生成DMID的截取位数; 或可传入一个DMID生成器实例
141
- */
142
- dmid?: boolean | number | UniIDTools.DMIDGenerator;
143
- }
144
- export declare const convert2Formats: readonly [DM_format.DanuniJson, DM_format.DanuniMinJson, DM_format.DanuniPbBin, DM_format.BiliXml, DM_format.DplayerJson, DM_format.ArtplayerJson, DM_format.DDPlayJson];
145
- export type Convert2Formats = DM_format.DanuniJson | DM_format.DanuniMinJson | DM_format.DanuniPbBin | DM_format.BiliXml | DM_format.DplayerJson | DM_format.ArtplayerJson | DM_format.DDPlayJson;
146
- type Convert2ResultMap = {
147
- [DM_format.DanuniJson]: UniDM[];
148
- [DM_format.DanuniMinJson]: DM_JSON_DanuniMin;
149
- [DM_format.DanuniPbBin]: Uint8Array;
150
- [DM_format.BiliXml]: string;
151
- [DM_format.DplayerJson]: DM_JSON_Dplayer & {
152
- danuni?: DanUniConvertTip;
153
- };
154
- [DM_format.ArtplayerJson]: DM_JSON_Artplayer & {
155
- danuni?: DanUniConvertTip;
156
- };
157
- [DM_format.DDPlayJson]: DM_JSON_DDPlay & {
158
- danuni?: DanUniConvertTip;
159
- };
160
- };
161
- export declare class UniPool {
162
- dans: UniDM[];
163
- options: Options;
164
- info: {
165
- /**
166
- * 是否从已被转换过的第三方格式弹幕再次转换而来
167
- */
168
- fromConverted: boolean;
169
- };
170
- constructor(dans: UniDM[], options?: Options, info?: {
171
- /**
172
- * 是否从已被转换过的第三方格式弹幕再次转换而来
173
- */
174
- fromConverted: boolean;
175
- });
176
- pipe<T extends (...args: any) => any>(fn: T): ReturnType<T>;
177
- /**
178
- * @deprecated 使用 `getShared` 代替
179
- */
180
- get shared(): shareItems;
181
- getShared<K extends keyof shareItems>(key: K): shareItems[K];
182
- getStat<K extends keyof statItems>(key: K): Stats<K>;
183
- getMost<K extends keyof statItems>(key: K): {
184
- val: Partial<Pick<UniDMTools.UniDMObj, "SOID" | "mode" | "fontsize" | "color" | "senderID" | "content" | "weight" | "pool" | "platform">>[K] | undefined;
185
- count: number;
186
- };
187
- /**
188
- * @deprecated 使用 `getMost` 代替
189
- */
190
- get most(): {
191
- mode: UniDMTools.Modes;
192
- fontsize: number;
193
- color: number;
194
- senderID: string;
195
- content: string;
196
- weight: number;
197
- pool: UniDMTools.Pools;
198
- platform: string | undefined;
199
- };
200
- static create(options?: Options): UniPool;
201
- /**
202
- * 合并弹幕/弹幕库
203
- */
204
- assign(dans: UniPool | UniDM | UniDM[]): UniPool;
205
- /**
206
- * 按共通属性拆分弹幕库
207
- */
208
- split(key: keyof shareItems): UniPool[];
209
- /**
210
- * 基于DMID的基本去重功能,用于解决该class下dans为array而非Set的问题
211
- */
212
- private dedupe;
213
- /**
214
- * 合并一定时间段内的重复弹幕,防止同屏出现过多
215
- * @param lifetime 查重时间区段,单位秒 (默认为 0,表示不查重)
216
- */
217
- merge(lifetime?: number): UniPool;
218
- static import(file: unknown, options?: Options,
219
- /**
220
- * 加载指定解析模块,为空则全选,为字符串则视为文件名解析加载模块
221
- */
222
- mod?: string | ('json' | 'str' | 'bin')[]): {
223
- pool: UniPool;
224
- fmt: DM_format;
225
- };
226
- convert2<T extends Convert2Formats>(format: T, file_wrapper: true, continue_on_error?: boolean): File;
227
- convert2<T extends Convert2Formats>(format: T, file_wrapper?: false, continue_on_error?: boolean): Convert2ResultMap[T];
228
- minify(): (Partial<UniDMTools.UniDMObj> & Pick<UniDMTools.UniDMObj, "SOID">)[];
229
- static fromMin(json: DM_JSON_DanuniMin, options?: Options): UniPool;
230
- static fromPb(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
231
- /**
232
- * 转为 protobuf 二进制
233
- */
234
- toPb(): Uint8Array<ArrayBuffer>;
235
- static fromBiliXML(xml: string, options?: Options): UniPool;
236
- toBiliXML(options?: {
237
- /**
238
- * 当SOID非来源bili时,若此处指定则使用该值为cid,否则使用SOID
239
- */
240
- cid?: bigint;
241
- /**
242
- * 跳过command类型的特殊弹幕
243
- */
244
- skipBiliCommand?: boolean;
245
- /**
246
- * 当仅含有来自bili的弹幕时,启用将保持发送者标识不含`@`
247
- * @description
248
- * bili的弹幕含midHash(crc),不启用该处使用senderID填充,启用则去除`@bili`部分,提高兼容性
249
- */
250
- avoidSenderIDWithAt?: boolean;
251
- }): string;
252
- static fromBiliGrpc(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
253
- /**
254
- * @param bin 符合`DmWebViewReplySchema`(bili视频meta)的protobuf二进制
255
- */
256
- static fromBiliCommandGrpc(bin: Uint8Array | ArrayBuffer, options?: Options): UniPool;
257
- static fromBiliUp(json: DM_JSON_BiliUp, options?: Options): UniPool;
258
- static fromDplayer(json: DM_JSON_Dplayer & {
259
- danuni?: DanUniConvertTip;
260
- }, playerID: string, domain?: string, options?: Options): UniPool;
261
- toDplayer(): DM_JSON_Dplayer & {
262
- danuni?: DanUniConvertTip;
263
- };
264
- static fromArtplayer(json: DM_JSON_Artplayer & {
265
- danuni?: DanUniConvertTip;
266
- }, playerID: string, domain?: string, options?: Options): UniPool;
267
- toArtplayer(): DM_JSON_Artplayer & {
268
- danuni?: DanUniConvertTip;
269
- };
270
- static fromDDPlay(json: DM_JSON_DDPlay & {
271
- danuni?: DanUniConvertTip;
272
- }, episodeId: string, options?: Options): UniPool;
273
- toDDPlay(): DM_JSON_DDPlay & {
274
- danuni?: DanUniConvertTip;
275
- };
276
- static fromASS(ass: string, options?: Options): UniPool;
277
- /**
278
- * 转换为ASS字幕格式的弹幕,需播放器支持多行ASS渲染
279
- */
280
- toASS(canvasCtx: CanvasCtx, options?: AssGenOptions): string;
281
- }
282
- export { platform, UniDM, UniDMTools, UniIDTools, type DM_JSON_BiliCommandGrpc, };
283
- export * as plugins from './plugins';
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { UniPool } from '../..';
2
- export declare function to_bili_deduped(that: UniPool): UniPool;
3
- export declare function bili_dedupe(that: UniPool): void;
@@ -1,18 +0,0 @@
1
- /**
2
- * 注:该方法受BiliPlus全弹幕下载器启发
3
- * 详情参考以下链接
4
- * @see https://github.com/HengXin666/BiLiBiLi_DanMu_Crawling/issues/14
5
- */
6
- import type { UniPool } from '../..';
7
- interface BiliHistoryDanmakuFastForwardResult {
8
- earliest: string | null;
9
- FastForward: string[];
10
- skip: string[];
11
- SpecificDate: string;
12
- }
13
- export declare function bili_history_fast_forward(
14
- /**
15
- * 请求api时使用的日期(UTC+8, yyyy-MM-dd)
16
- */
17
- query_history_date: string): (that: UniPool) => BiliHistoryDanmakuFastForwardResult;
18
- export {};
@@ -1,2 +0,0 @@
1
- export * as bili_dedupe from './dedupe';
2
- export { bili_history_fast_forward } from './history-danmaku-fast-forward';
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export * as bili from './bili';
2
- export * as stats from './stats';
@@ -1,6 +0,0 @@
1
- import type { UniDM, UniPool } from '../..';
2
- /**
3
- * 从弹幕池中查找出最新的一条弹幕
4
- * 按照弹幕的创建时间(ctime)排序,返回最新的一条
5
- */
6
- export default function getLatestDan(that: UniPool): UniDM | null;
@@ -1 +0,0 @@
1
- export { default as getLatestDan } from './getLatestDan';
@@ -1 +0,0 @@
1
- export {};