@dan-uni/dan-any 1.2.7 → 1.3.3

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 (46) hide show
  1. package/README.md +1 -0
  2. package/buf.gen.yaml +4 -2
  3. package/buf.yaml +12 -0
  4. package/dist/browser/index.min.js +13384 -1
  5. package/dist/browser/plugins/bili.min.js +77 -1
  6. package/dist/browser/plugins/index.min.js +2 -2
  7. package/dist/browser/plugins/stats.min.js +10 -1
  8. package/dist/browser/rslib-runtime.min.js +5 -5
  9. package/dist/browser/src/index.d.ts +10 -7
  10. package/dist/browser/src/proto/gen/{bili → bilibili/community/service/dm/v1}/dm_pb.d.ts +2 -2
  11. package/dist/browser/src/proto/gen/{danuni_pb.d.ts → danuni/danmaku/v1/danmaku_pb.d.ts} +45 -41
  12. package/dist/browser/src/utils/fileParser.d.ts +3 -0
  13. package/dist/node/index.js +1959 -1
  14. package/dist/node/plugins/bili.js +77 -1
  15. package/dist/node/plugins/index.js +2 -2
  16. package/dist/node/plugins/stats.js +10 -1
  17. package/dist/node/rslib-runtime.js +5 -5
  18. package/dist/node/src/index.d.ts +10 -7
  19. package/dist/node/src/proto/gen/{bili → bilibili/community/service/dm/v1}/dm_pb.d.ts +2 -2
  20. package/dist/{umd/src/proto/gen/danuni_pb.d.ts → node/src/proto/gen/danuni/danmaku/v1/danmaku_pb.d.ts} +45 -41
  21. package/dist/node/src/utils/fileParser.d.ts +3 -0
  22. package/dist/umd/index.umd.min.js +1146 -336
  23. package/dist/umd/plugins/bili.umd.min.js +1143 -334
  24. package/dist/umd/plugins/index.umd.min.js +1143 -334
  25. package/dist/umd/src/index.d.ts +10 -7
  26. package/dist/umd/src/proto/gen/{bili → bilibili/community/service/dm/v1}/dm_pb.d.ts +2 -2
  27. package/dist/{node/src/proto/gen/danuni_pb.d.ts → umd/src/proto/gen/danuni/danmaku/v1/danmaku_pb.d.ts} +45 -41
  28. package/dist/umd/src/utils/fileParser.d.ts +3 -0
  29. package/package.json +5 -7
  30. package/src/index.test.ts +23 -1
  31. package/src/index.ts +153 -59
  32. package/src/proto/gen/{bili → bilibili/community/service/dm/v1}/dm_pb.ts +104 -104
  33. package/src/proto/gen/danuni/danmaku/v1/danmaku_pb.ts +223 -0
  34. package/src/proto/src/danuni/danmaku/v1/danmaku.proto +52 -0
  35. package/src/utils/dm-gen.ts +1 -1
  36. package/src/utils/fileParser.ts +37 -0
  37. package/dist/browser/17.min.js +0 -13299
  38. package/dist/browser/705.min.js +0 -77
  39. package/dist/browser/898.min.js +0 -10
  40. package/dist/node/17.js +0 -1874
  41. package/dist/node/705.js +0 -77
  42. package/dist/node/898.js +0 -10
  43. package/src/proto/gen/danuni_pb.ts +0 -219
  44. package/src/proto/src/danuni.proto +0 -50
  45. /package/dist/browser/{17.min.js.LICENSE.txt → index.min.js.LICENSE.txt} +0 -0
  46. /package/src/proto/src/{bili → bilibili/community/service/dm/v1}/dm.proto +0 -0
@@ -0,0 +1,223 @@
1
+ // @generated by protoc-gen-es v2.11.0 with parameter "target=ts"
2
+ // @generated from file danuni/danmaku/v1/danmaku.proto (package danuni.danmaku.v1, syntax proto3)
3
+ /* eslint-disable */
4
+
5
+ import type { GenEnum, GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
6
+ import { enumDesc, fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2";
7
+ import type { Timestamp } from "@bufbuild/protobuf/wkt";
8
+ import { file_google_protobuf_timestamp } from "@bufbuild/protobuf/wkt";
9
+ import type { Message } from "@bufbuild/protobuf";
10
+
11
+ /**
12
+ * Describes the file danuni/danmaku/v1/danmaku.proto.
13
+ */
14
+ export const file_danuni_danmaku_v1_danmaku: GenFile = /*@__PURE__*/
15
+ fileDesc("Ch9kYW51bmkvZGFubWFrdS92MS9kYW5tYWt1LnByb3RvEhFkYW51bmkuZGFubWFrdS52MSI2Cg5MaXN0RGFuUmVxdWVzdBIKCgJpZBgBIAEoCRIQCgN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VuaVxEYW5tYWt1XFYxXEdQQk1ldGFkYXRh6gITRGFudW5pOjpEYW5tYWt1OjpWMWIGcHJvdG8z", [file_google_protobuf_timestamp]);
16
+
17
+ /**
18
+ * @generated from message danuni.danmaku.v1.ListDanRequest
19
+ */
20
+ export type ListDanRequest = Message<"danuni.danmaku.v1.ListDanRequest"> & {
21
+ /**
22
+ * @generated from field: string id = 1;
23
+ */
24
+ id: string;
25
+
26
+ /**
27
+ * @generated from field: optional int32 seg = 2;
28
+ */
29
+ seg?: number;
30
+ };
31
+
32
+ /**
33
+ * Describes the message danuni.danmaku.v1.ListDanRequest.
34
+ * Use `create(ListDanRequestSchema)` to create a new message.
35
+ */
36
+ export const ListDanRequestSchema: GenMessage<ListDanRequest> = /*@__PURE__*/
37
+ messageDesc(file_danuni_danmaku_v1_danmaku, 0);
38
+
39
+ /**
40
+ * @generated from message danuni.danmaku.v1.Danmaku
41
+ */
42
+ export type Danmaku = Message<"danuni.danmaku.v1.Danmaku"> & {
43
+ /**
44
+ * @generated from field: string soid = 1 [json_name = "SOID"];
45
+ */
46
+ soid: string;
47
+
48
+ /**
49
+ * @generated from field: string dmid = 2 [json_name = "DMID"];
50
+ */
51
+ dmid: string;
52
+
53
+ /**
54
+ * @generated from field: int32 progress = 3;
55
+ */
56
+ progress: number;
57
+
58
+ /**
59
+ * @generated from field: danuni.danmaku.v1.Mode mode = 4;
60
+ */
61
+ mode: Mode;
62
+
63
+ /**
64
+ * @generated from field: int32 fontsize = 5;
65
+ */
66
+ fontsize: number;
67
+
68
+ /**
69
+ * @generated from field: int32 color = 6;
70
+ */
71
+ color: number;
72
+
73
+ /**
74
+ * @generated from field: string sender_id = 7 [json_name = "senderID"];
75
+ */
76
+ senderId: string;
77
+
78
+ /**
79
+ * @generated from field: string content = 8;
80
+ */
81
+ content: string;
82
+
83
+ /**
84
+ * @generated from field: google.protobuf.Timestamp ctime = 9;
85
+ */
86
+ ctime?: Timestamp;
87
+
88
+ /**
89
+ * @generated from field: int32 weight = 10;
90
+ */
91
+ weight: number;
92
+
93
+ /**
94
+ * @generated from field: danuni.danmaku.v1.Pool pool = 11;
95
+ */
96
+ pool: Pool;
97
+
98
+ /**
99
+ * @generated from field: repeated string attr = 12;
100
+ */
101
+ attr: string[];
102
+
103
+ /**
104
+ * @generated from field: optional string platform = 13;
105
+ */
106
+ platform?: string;
107
+
108
+ /**
109
+ * @generated from field: optional string extra = 14;
110
+ */
111
+ extra?: string;
112
+ };
113
+
114
+ /**
115
+ * Describes the message danuni.danmaku.v1.Danmaku.
116
+ * Use `create(DanmakuSchema)` to create a new message.
117
+ */
118
+ export const DanmakuSchema: GenMessage<Danmaku> = /*@__PURE__*/
119
+ messageDesc(file_danuni_danmaku_v1_danmaku, 1);
120
+
121
+ /**
122
+ * @generated from message danuni.danmaku.v1.ListDanResponse
123
+ */
124
+ export type ListDanResponse = Message<"danuni.danmaku.v1.ListDanResponse"> & {
125
+ /**
126
+ * @generated from field: repeated danuni.danmaku.v1.Danmaku danmakus = 1;
127
+ */
128
+ danmakus: Danmaku[];
129
+ };
130
+
131
+ /**
132
+ * Describes the message danuni.danmaku.v1.ListDanResponse.
133
+ * Use `create(ListDanResponseSchema)` to create a new message.
134
+ */
135
+ export const ListDanResponseSchema: GenMessage<ListDanResponse> = /*@__PURE__*/
136
+ messageDesc(file_danuni_danmaku_v1_danmaku, 2);
137
+
138
+ /**
139
+ * 此处作为数字应与danuni库相应类型一一对应
140
+ *
141
+ * @generated from enum danuni.danmaku.v1.Mode
142
+ */
143
+ export enum Mode {
144
+ /**
145
+ * @generated from enum value: MODE_NORMAL_UNSPECIFIED = 0;
146
+ */
147
+ NORMAL_UNSPECIFIED = 0,
148
+
149
+ /**
150
+ * @generated from enum value: MODE_BOTTOM = 1;
151
+ */
152
+ BOTTOM = 1,
153
+
154
+ /**
155
+ * @generated from enum value: MODE_TOP = 2;
156
+ */
157
+ TOP = 2,
158
+
159
+ /**
160
+ * @generated from enum value: MODE_REVERSE = 3;
161
+ */
162
+ REVERSE = 3,
163
+
164
+ /**
165
+ * @generated from enum value: MODE_EXT = 4;
166
+ */
167
+ EXT = 4,
168
+ }
169
+
170
+ /**
171
+ * Describes the enum danuni.danmaku.v1.Mode.
172
+ */
173
+ export const ModeSchema: GenEnum<Mode> = /*@__PURE__*/
174
+ enumDesc(file_danuni_danmaku_v1_danmaku, 0);
175
+
176
+ /**
177
+ * 此处作为数字应与danuni库相应类型一一对应
178
+ *
179
+ * @generated from enum danuni.danmaku.v1.Pool
180
+ */
181
+ export enum Pool {
182
+ /**
183
+ * @generated from enum value: POOL_DEF_UNSPECIFIED = 0;
184
+ */
185
+ DEF_UNSPECIFIED = 0,
186
+
187
+ /**
188
+ * @generated from enum value: POOL_SUB = 1;
189
+ */
190
+ SUB = 1,
191
+
192
+ /**
193
+ * @generated from enum value: POOL_ADV = 2;
194
+ */
195
+ ADV = 2,
196
+
197
+ /**
198
+ * @generated from enum value: POOL_IX = 3;
199
+ */
200
+ IX = 3,
201
+ }
202
+
203
+ /**
204
+ * Describes the enum danuni.danmaku.v1.Pool.
205
+ */
206
+ export const PoolSchema: GenEnum<Pool> = /*@__PURE__*/
207
+ enumDesc(file_danuni_danmaku_v1_danmaku, 1);
208
+
209
+ /**
210
+ * @generated from service danuni.danmaku.v1.DanmakuService
211
+ */
212
+ export const DanmakuService: GenService<{
213
+ /**
214
+ * @generated from rpc danuni.danmaku.v1.DanmakuService.ListDan
215
+ */
216
+ listDan: {
217
+ methodKind: "unary";
218
+ input: typeof ListDanRequestSchema;
219
+ output: typeof ListDanResponseSchema;
220
+ },
221
+ }> = /*@__PURE__*/
222
+ serviceDesc(file_danuni_danmaku_v1_danmaku, 0);
223
+
@@ -0,0 +1,52 @@
1
+ syntax = "proto3";
2
+
3
+ package danuni.danmaku.v1;
4
+
5
+ import "google/protobuf/timestamp.proto";
6
+
7
+ service DanmakuService {
8
+ rpc ListDan(ListDanRequest) returns (ListDanResponse) {}
9
+ }
10
+
11
+ message ListDanRequest {
12
+ string id = 1;
13
+ optional int32 seg = 2;
14
+ }
15
+
16
+ // 此处作为数字应与danuni库相应类型一一对应
17
+ enum Mode {
18
+ MODE_NORMAL_UNSPECIFIED = 0;
19
+ MODE_BOTTOM = 1;
20
+ MODE_TOP = 2;
21
+ MODE_REVERSE = 3;
22
+ MODE_EXT = 4;
23
+ }
24
+
25
+ // 此处作为数字应与danuni库相应类型一一对应
26
+ enum Pool {
27
+ POOL_DEF_UNSPECIFIED = 0;
28
+ POOL_SUB = 1;
29
+ POOL_ADV = 2;
30
+ POOL_IX = 3;
31
+ }
32
+
33
+ message Danmaku {
34
+ string soid = 1 [json_name = "SOID"];
35
+ string dmid = 2 [json_name = "DMID"];
36
+ int32 progress = 3;
37
+ Mode mode = 4;
38
+ int32 fontsize = 5;
39
+ int32 color = 6;
40
+ string sender_id = 7 [json_name = "senderID"];
41
+ string content = 8;
42
+ google.protobuf.Timestamp ctime = 9;
43
+ int32 weight = 10;
44
+ Pool pool = 11;
45
+ repeated string attr = 12;
46
+ optional string platform = 13;
47
+ optional string extra = 14;
48
+ }
49
+
50
+ message ListDanResponse {
51
+ repeated Danmaku danmakus = 1;
52
+ }
@@ -479,7 +479,7 @@ export class UniDM {
479
479
  if (!this.SOID) this.SOID = def.SOID
480
480
  if (!this.progress) this.progress = def.progress
481
481
  if (!this.mode) this.mode = def.mode
482
- if (!this.fontsize) this.fontsize = def.mode
482
+ if (!this.fontsize) this.fontsize = def.fontsize
483
483
  if (!this.color) this.color = def.color
484
484
  if (!this.senderID) this.senderID = def.senderID
485
485
  if (!this.content) this.content = def.content
@@ -0,0 +1,37 @@
1
+ export function fileParser(file: unknown, mod: 'bin'): ArrayBuffer | Uint8Array
2
+ export function fileParser(file: unknown, mod: 'string'): string
3
+ export function fileParser<T extends object>(file: unknown, mod: 'json'): T
4
+ export function fileParser(
5
+ file: unknown,
6
+ mod: 'bin' | 'string' | 'json',
7
+ ): ArrayBuffer | Uint8Array | string | object {
8
+ const isBinary = file instanceof ArrayBuffer || file instanceof Uint8Array
9
+ switch (mod) {
10
+ case 'bin': {
11
+ if (isBinary) return file
12
+ throw new TypeError('Expected binary data for mod "bin"')
13
+ }
14
+ case 'string': {
15
+ if (typeof file === 'string') return file
16
+ if (isBinary) return new TextDecoder().decode(file)
17
+ throw new TypeError('Expected binary data or string for mod "string"')
18
+ }
19
+ case 'json': {
20
+ if (typeof file === 'object' && file !== null && !isBinary) return file
21
+ if (typeof file !== 'string' && !isBinary) {
22
+ throw new TypeError(
23
+ 'Expected object, JSON string, or binary data for mod "json"',
24
+ )
25
+ }
26
+ const str =
27
+ typeof file === 'string' ? file : new TextDecoder().decode(file)
28
+ try {
29
+ return JSON.parse(str)
30
+ } catch {
31
+ throw new Error('Invalid JSON string')
32
+ }
33
+ }
34
+ default:
35
+ throw new Error(`Unsupported mod "${mod}"`)
36
+ }
37
+ }