@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
package/dist/node/705.js DELETED
@@ -1,77 +0,0 @@
1
- import { __webpack_require__ } from "./rslib-runtime.js";
2
- import { DateTime } from "luxon";
3
- import { UniPool, platform_PlatformVideoSource } from "./17.js";
4
- var dedupe_namespaceObject = {};
5
- __webpack_require__.r(dedupe_namespaceObject);
6
- __webpack_require__.d(dedupe_namespaceObject, {
7
- bili_dedupe: ()=>bili_dedupe,
8
- to_bili_deduped: ()=>to_bili_deduped
9
- });
10
- var bili_namespaceObject = {};
11
- __webpack_require__.r(bili_namespaceObject);
12
- __webpack_require__.d(bili_namespaceObject, {
13
- bili_dedupe: ()=>dedupe_namespaceObject,
14
- bili_history_fast_forward: ()=>bili_history_fast_forward
15
- });
16
- function main(that) {
17
- that.dans.forEach((d)=>{
18
- if (d.platform !== platform_PlatformVideoSource.Bilibili) throw new Error('bili-dedupe: 仅支持B站(主站)的弹幕');
19
- if (!d.extra.bili?.dmid) throw new Error('bili-dedupe: 弹幕缺少bili extra dmid字段');
20
- });
21
- const map = new Map();
22
- that.dans.forEach((d)=>map.set(d.extra.bili.dmid, d));
23
- return map;
24
- }
25
- function to_bili_deduped(that) {
26
- const map = main(that);
27
- return new UniPool([
28
- ...map.values()
29
- ], that.options, that.info);
30
- }
31
- function bili_dedupe(that) {
32
- const map = main(that);
33
- that.dans = [
34
- ...map.values()
35
- ];
36
- }
37
- function history_danmaku_fast_forward_main(that, query_history_date) {
38
- const qhd = DateTime.fromFormat(query_history_date, 'yyyy-MM-dd', {
39
- zone: 'Asia/Shanghai'
40
- }).setZone('Asia/Shanghai');
41
- if (!qhd.isValid) throw new Error('Invalid query_history_date');
42
- const s = qhd.startOf('day');
43
- const before = that.dans.filter((d)=>d.ctime < s.toJSDate());
44
- if (0 === before.length) return {
45
- earliest: null,
46
- FastForward: [],
47
- skip: [],
48
- SpecificDate: qhd.toFormat('yyyy-MM-dd')
49
- };
50
- const earliestCtime = before.toSorted((a, b)=>a.ctime.getTime() - b.ctime.getTime())[0].ctime;
51
- const earliestDate = DateTime.fromJSDate(earliestCtime).setZone('Asia/Shanghai').startOf('day');
52
- const datesWithDanmaku = new Set();
53
- for (const dan of before){
54
- const dateStr = DateTime.fromJSDate(dan.ctime).setZone('Asia/Shanghai').toFormat('yyyy-MM-dd');
55
- datesWithDanmaku.add(dateStr);
56
- }
57
- let current = earliestDate;
58
- const allDates = [];
59
- while(current < s){
60
- allDates.push(current.toFormat('yyyy-MM-dd'));
61
- current = current.plus({
62
- days: 1
63
- });
64
- }
65
- const FastForward = allDates.filter((d)=>datesWithDanmaku.has(d));
66
- const skip = allDates.filter((d)=>!datesWithDanmaku.has(d));
67
- return {
68
- earliest: earliestDate.toFormat('yyyy-MM-dd'),
69
- FastForward,
70
- skip,
71
- SpecificDate: qhd.toFormat('yyyy-MM-dd')
72
- };
73
- }
74
- function bili_history_fast_forward(query_history_date) {
75
- return (that)=>history_danmaku_fast_forward_main(that, query_history_date);
76
- }
77
- export { bili_history_fast_forward, bili_namespaceObject as bili, dedupe_namespaceObject as bili_dedupe };
package/dist/node/898.js DELETED
@@ -1,10 +0,0 @@
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 };
@@ -1,219 +0,0 @@
1
- // @generated by protoc-gen-es v2.11.0 with parameter "target=ts"
2
- // @generated from file danuni.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.proto.
13
- */
14
- export const file_danuni: GenFile = /*@__PURE__*/
15
- fileDesc("CgxkYW51bmkucHJvdG8SEWRhbnVuaS5kYW5tYWt1LnYxIjIKCmxpc3REYW5SZXESCgoCSUQYASABKAkSEAoDc2VnGAIgASgFSACIAQFCBgoEX3NlZyLUAgoHRGFubWFrdRIMCgRTT0lEGAEgASgJEgwKBERNSUQYAiABKAkSEAoIcHJvZ3Jlc3MYAyABKAUSJQoEbW9kZRgEIAEoDjIXLmRhbnVuaS5kYW5tYWt1LnYxLk1vZGUSEAoIZm9udHNpemUYBSABKAUSDQoFY29sb3IYBiABKAUSEAoIc2VuZGVySUQYByABKAkSDwoHY29udGVudBgIIAEoCRIpCgVjdGltZRgJIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASDgoGd2VpZ2h0GAogASgFEiUKBHBvb2wYCyABKA4yFy5kYW51bmkuZGFubWFrdS52MS5Qb29sEgwKBGF0dHIYDCADKAkSFQoIcGxhdGZvcm0YDSABKAlIAIgBARISCgVleHRyYRgOIAEoCUgBiAEBQgsKCV9wbGF0Zm9ybUIICgZfZXh0cmEiPAoMRGFubWFrdVJlcGx5EiwKCGRhbm1ha3VzGAEgAygLMhouZGFudW5pLmRhbm1ha3UudjEuRGFubWFrdSo9CgRNb2RlEgoKBk5vcm1hbBAAEgoKBkJvdHRvbRABEgcKA1RvcBACEgsKB1JldmVyc2UQAxIHCgNFeHQQBCopCgRQb29sEgcKA0RlZhAAEgcKA1N1YhABEgcKA0FkdhACEgYKAkl4EAMyXQoORGFubWFrdVNlcnZpY2USSwoHbGlzdERhbhIdLmRhbnVuaS5kYW5tYWt1LnYxLmxpc3REYW5SZXEaHy5kYW51bmkuZGFubWFrdS52MS5EYW5tYWt1UmVwbHkiAFAAYgZwcm90bzM", [file_google_protobuf_timestamp]);
16
-
17
- /**
18
- * @generated from message danuni.danmaku.v1.listDanReq
19
- */
20
- export type listDanReq = Message<"danuni.danmaku.v1.listDanReq"> & {
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.listDanReq.
34
- * Use `create(listDanReqSchema)` to create a new message.
35
- */
36
- export const listDanReqSchema: GenMessage<listDanReq> = /*@__PURE__*/
37
- messageDesc(file_danuni, 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;
45
- */
46
- SOID: string;
47
-
48
- /**
49
- * @generated from field: string DMID = 2;
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 senderID = 7;
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, 1);
120
-
121
- /**
122
- * @generated from message danuni.danmaku.v1.DanmakuReply
123
- */
124
- export type DanmakuReply = Message<"danuni.danmaku.v1.DanmakuReply"> & {
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.DanmakuReply.
133
- * Use `create(DanmakuReplySchema)` to create a new message.
134
- */
135
- export const DanmakuReplySchema: GenMessage<DanmakuReply> = /*@__PURE__*/
136
- messageDesc(file_danuni, 2);
137
-
138
- /**
139
- * @generated from enum danuni.danmaku.v1.Mode
140
- */
141
- export enum Mode {
142
- /**
143
- * @generated from enum value: Normal = 0;
144
- */
145
- Normal = 0,
146
-
147
- /**
148
- * @generated from enum value: Bottom = 1;
149
- */
150
- Bottom = 1,
151
-
152
- /**
153
- * @generated from enum value: Top = 2;
154
- */
155
- Top = 2,
156
-
157
- /**
158
- * @generated from enum value: Reverse = 3;
159
- */
160
- Reverse = 3,
161
-
162
- /**
163
- * @generated from enum value: Ext = 4;
164
- */
165
- Ext = 4,
166
- }
167
-
168
- /**
169
- * Describes the enum danuni.danmaku.v1.Mode.
170
- */
171
- export const ModeSchema: GenEnum<Mode> = /*@__PURE__*/
172
- enumDesc(file_danuni, 0);
173
-
174
- /**
175
- * @generated from enum danuni.danmaku.v1.Pool
176
- */
177
- export enum Pool {
178
- /**
179
- * @generated from enum value: Def = 0;
180
- */
181
- Def = 0,
182
-
183
- /**
184
- * @generated from enum value: Sub = 1;
185
- */
186
- Sub = 1,
187
-
188
- /**
189
- * @generated from enum value: Adv = 2;
190
- */
191
- Adv = 2,
192
-
193
- /**
194
- * @generated from enum value: Ix = 3;
195
- */
196
- Ix = 3,
197
- }
198
-
199
- /**
200
- * Describes the enum danuni.danmaku.v1.Pool.
201
- */
202
- export const PoolSchema: GenEnum<Pool> = /*@__PURE__*/
203
- enumDesc(file_danuni, 1);
204
-
205
- /**
206
- * @generated from service danuni.danmaku.v1.DanmakuService
207
- */
208
- export const DanmakuService: GenService<{
209
- /**
210
- * @generated from rpc danuni.danmaku.v1.DanmakuService.listDan
211
- */
212
- listDan: {
213
- methodKind: "unary";
214
- input: typeof listDanReqSchema;
215
- output: typeof DanmakuReplySchema;
216
- },
217
- }> = /*@__PURE__*/
218
- serviceDesc(file_danuni, 0);
219
-
@@ -1,50 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package danuni.danmaku.v1;
4
-
5
- import public "google/protobuf/timestamp.proto";
6
-
7
- service DanmakuService {
8
- rpc listDan (listDanReq) returns (DanmakuReply) {}
9
- }
10
-
11
- message listDanReq {
12
- string ID = 1;
13
- optional int32 seg = 2;
14
- }
15
-
16
- enum Mode {
17
- Normal = 0;
18
- Bottom = 1;
19
- Top = 2;
20
- Reverse = 3;
21
- Ext = 4;
22
- }
23
-
24
- enum Pool {
25
- Def = 0;
26
- Sub = 1;
27
- Adv = 2;
28
- Ix = 3;
29
- }
30
-
31
- message Danmaku {
32
- string SOID = 1;
33
- string DMID = 2;
34
- int32 progress = 3;
35
- Mode mode = 4;
36
- int32 fontsize = 5;
37
- int32 color = 6;
38
- string senderID = 7;
39
- string content = 8;
40
- google.protobuf.Timestamp ctime = 9;
41
- int32 weight = 10;
42
- Pool pool = 11;
43
- repeated string attr = 12;
44
- optional string platform = 13;
45
- optional string extra = 14;
46
- }
47
-
48
- message DanmakuReply {
49
- repeated Danmaku danmakus = 1;
50
- }