@floating-live/bilibili 0.16.0 → 0.16.1
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/index.d.ts +0 -1
- package/index.js +0 -1
- package/package.json +9 -5
- package/parser.d.ts +2 -2
- package/plugin.d.ts +18 -2
- package/plugin.js +116 -16
- package/room.d.ts +7 -10
- package/room.js +53 -74
- package/utils/crypto.d.ts +1 -0
- package/utils/crypto.js +10 -0
- package/utils/request.d.ts +176 -31
- package/utils/request.js +84 -169
- package/utils/fingerprint.d.ts +0 -98
- package/utils/fingerprint.js +0 -642
- package/utils/fp2.d.ts +0 -7
- package/utils/fp2.js +0 -234
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -1
- package/utils/lsid.d.ts +0 -1
- package/utils/lsid.js +0 -15
- package/utils/randomImage.d.ts +0 -2
- package/utils/randomImage.js +0 -107
- package/utils/uuid.d.ts +0 -1
- package/utils/uuid.js +0 -45
package/utils/fp2.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const x64Add: (m: any[], n: any[]) => number[];
|
|
2
|
-
export declare const x64Multiply: (m: any[], n: number[]) => number[];
|
|
3
|
-
export declare const x64Rotl: (m: any[], n: number) => any[];
|
|
4
|
-
export declare const x64LeftShift: (m: any[], n: number) => any[];
|
|
5
|
-
export declare const x64Xor: (m: any[], n: any[]) => number[];
|
|
6
|
-
export declare const x64Fmix: (h: any[]) => any[];
|
|
7
|
-
export declare const x64hash128: (key: string, seed: number) => string;
|
package/utils/fp2.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/// MurmurHash3 related functions
|
|
2
|
-
//
|
|
3
|
-
// Given two 64bit ints (as an array of two 32bit ints) returns the two
|
|
4
|
-
// added together as a 64bit int (as an array of two 32bit ints).
|
|
5
|
-
//
|
|
6
|
-
export const x64Add = function (m, n) {
|
|
7
|
-
m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];
|
|
8
|
-
n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];
|
|
9
|
-
var o = [0, 0, 0, 0];
|
|
10
|
-
o[3] += m[3] + n[3];
|
|
11
|
-
o[2] += o[3] >>> 16;
|
|
12
|
-
o[3] &= 0xffff;
|
|
13
|
-
o[2] += m[2] + n[2];
|
|
14
|
-
o[1] += o[2] >>> 16;
|
|
15
|
-
o[2] &= 0xffff;
|
|
16
|
-
o[1] += m[1] + n[1];
|
|
17
|
-
o[0] += o[1] >>> 16;
|
|
18
|
-
o[1] &= 0xffff;
|
|
19
|
-
o[0] += m[0] + n[0];
|
|
20
|
-
o[0] &= 0xffff;
|
|
21
|
-
return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];
|
|
22
|
-
};
|
|
23
|
-
//
|
|
24
|
-
// Given two 64bit ints (as an array of two 32bit ints) returns the two
|
|
25
|
-
// multiplied together as a 64bit int (as an array of two 32bit ints).
|
|
26
|
-
//
|
|
27
|
-
export const x64Multiply = function (m, n) {
|
|
28
|
-
m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];
|
|
29
|
-
n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];
|
|
30
|
-
var o = [0, 0, 0, 0];
|
|
31
|
-
o[3] += m[3] * n[3];
|
|
32
|
-
o[2] += o[3] >>> 16;
|
|
33
|
-
o[3] &= 0xffff;
|
|
34
|
-
o[2] += m[2] * n[3];
|
|
35
|
-
o[1] += o[2] >>> 16;
|
|
36
|
-
o[2] &= 0xffff;
|
|
37
|
-
o[2] += m[3] * n[2];
|
|
38
|
-
o[1] += o[2] >>> 16;
|
|
39
|
-
o[2] &= 0xffff;
|
|
40
|
-
o[1] += m[1] * n[3];
|
|
41
|
-
o[0] += o[1] >>> 16;
|
|
42
|
-
o[1] &= 0xffff;
|
|
43
|
-
o[1] += m[2] * n[2];
|
|
44
|
-
o[0] += o[1] >>> 16;
|
|
45
|
-
o[1] &= 0xffff;
|
|
46
|
-
o[1] += m[3] * n[1];
|
|
47
|
-
o[0] += o[1] >>> 16;
|
|
48
|
-
o[1] &= 0xffff;
|
|
49
|
-
o[0] += m[0] * n[3] + m[1] * n[2] + m[2] * n[1] + m[3] * n[0];
|
|
50
|
-
o[0] &= 0xffff;
|
|
51
|
-
return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];
|
|
52
|
-
};
|
|
53
|
-
//
|
|
54
|
-
// Given a 64bit int (as an array of two 32bit ints) and an int
|
|
55
|
-
// representing a number of bit positions, returns the 64bit int (as an
|
|
56
|
-
// array of two 32bit ints) rotated left by that number of positions.
|
|
57
|
-
//
|
|
58
|
-
export const x64Rotl = function (m, n) {
|
|
59
|
-
n %= 64;
|
|
60
|
-
if (n === 32) {
|
|
61
|
-
return [m[1], m[0]];
|
|
62
|
-
}
|
|
63
|
-
else if (n < 32) {
|
|
64
|
-
return [
|
|
65
|
-
(m[0] << n) | (m[1] >>> (32 - n)),
|
|
66
|
-
(m[1] << n) | (m[0] >>> (32 - n)),
|
|
67
|
-
];
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
n -= 32;
|
|
71
|
-
return [
|
|
72
|
-
(m[1] << n) | (m[0] >>> (32 - n)),
|
|
73
|
-
(m[0] << n) | (m[1] >>> (32 - n)),
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
//
|
|
78
|
-
// Given a 64bit int (as an array of two 32bit ints) and an int
|
|
79
|
-
// representing a number of bit positions, returns the 64bit int (as an
|
|
80
|
-
// array of two 32bit ints) shifted left by that number of positions.
|
|
81
|
-
//
|
|
82
|
-
export const x64LeftShift = function (m, n) {
|
|
83
|
-
n %= 64;
|
|
84
|
-
if (n === 0) {
|
|
85
|
-
return m;
|
|
86
|
-
}
|
|
87
|
-
else if (n < 32) {
|
|
88
|
-
return [(m[0] << n) | (m[1] >>> (32 - n)), m[1] << n];
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return [m[1] << (n - 32), 0];
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
//
|
|
95
|
-
// Given two 64bit ints (as an array of two 32bit ints) returns the two
|
|
96
|
-
// xored together as a 64bit int (as an array of two 32bit ints).
|
|
97
|
-
//
|
|
98
|
-
export const x64Xor = function (m, n) {
|
|
99
|
-
return [m[0] ^ n[0], m[1] ^ n[1]];
|
|
100
|
-
};
|
|
101
|
-
//
|
|
102
|
-
// Given a block, returns murmurHash3's final x64 mix of that block.
|
|
103
|
-
// (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the
|
|
104
|
-
// only place where we need to right shift 64bit ints.)
|
|
105
|
-
//
|
|
106
|
-
export const x64Fmix = function (h) {
|
|
107
|
-
h = x64Xor(h, [0, h[0] >>> 1]);
|
|
108
|
-
h = x64Multiply(h, [0xff51afd7, 0xed558ccd]);
|
|
109
|
-
h = x64Xor(h, [0, h[0] >>> 1]);
|
|
110
|
-
h = x64Multiply(h, [0xc4ceb9fe, 0x1a85ec53]);
|
|
111
|
-
h = x64Xor(h, [0, h[0] >>> 1]);
|
|
112
|
-
return h;
|
|
113
|
-
};
|
|
114
|
-
//
|
|
115
|
-
// Given a string and an optional seed as an int, returns a 128 bit
|
|
116
|
-
// hash using the x64 flavor of MurmurHash3, as an unsigned hex.
|
|
117
|
-
//
|
|
118
|
-
export const x64hash128 = function (key, seed) {
|
|
119
|
-
key = key || "";
|
|
120
|
-
seed = seed || 0;
|
|
121
|
-
var remainder = key.length % 16;
|
|
122
|
-
var bytes = key.length - remainder;
|
|
123
|
-
var h1 = [0, seed];
|
|
124
|
-
var h2 = [0, seed];
|
|
125
|
-
var k1 = [0, 0];
|
|
126
|
-
var k2 = [0, 0];
|
|
127
|
-
var c1 = [0x87c37b91, 0x114253d5];
|
|
128
|
-
var c2 = [0x4cf5ad43, 0x2745937f];
|
|
129
|
-
for (var i = 0; i < bytes; i = i + 16) {
|
|
130
|
-
k1 = [
|
|
131
|
-
(key.charCodeAt(i + 4) & 0xff) |
|
|
132
|
-
((key.charCodeAt(i + 5) & 0xff) << 8) |
|
|
133
|
-
((key.charCodeAt(i + 6) & 0xff) << 16) |
|
|
134
|
-
((key.charCodeAt(i + 7) & 0xff) << 24),
|
|
135
|
-
(key.charCodeAt(i) & 0xff) |
|
|
136
|
-
((key.charCodeAt(i + 1) & 0xff) << 8) |
|
|
137
|
-
((key.charCodeAt(i + 2) & 0xff) << 16) |
|
|
138
|
-
((key.charCodeAt(i + 3) & 0xff) << 24),
|
|
139
|
-
];
|
|
140
|
-
k2 = [
|
|
141
|
-
(key.charCodeAt(i + 12) & 0xff) |
|
|
142
|
-
((key.charCodeAt(i + 13) & 0xff) << 8) |
|
|
143
|
-
((key.charCodeAt(i + 14) & 0xff) << 16) |
|
|
144
|
-
((key.charCodeAt(i + 15) & 0xff) << 24),
|
|
145
|
-
(key.charCodeAt(i + 8) & 0xff) |
|
|
146
|
-
((key.charCodeAt(i + 9) & 0xff) << 8) |
|
|
147
|
-
((key.charCodeAt(i + 10) & 0xff) << 16) |
|
|
148
|
-
((key.charCodeAt(i + 11) & 0xff) << 24),
|
|
149
|
-
];
|
|
150
|
-
k1 = x64Multiply(k1, c1);
|
|
151
|
-
k1 = x64Rotl(k1, 31);
|
|
152
|
-
k1 = x64Multiply(k1, c2);
|
|
153
|
-
h1 = x64Xor(h1, k1);
|
|
154
|
-
h1 = x64Rotl(h1, 27);
|
|
155
|
-
h1 = x64Add(h1, h2);
|
|
156
|
-
h1 = x64Add(x64Multiply(h1, [0, 5]), [0, 0x52dce729]);
|
|
157
|
-
k2 = x64Multiply(k2, c2);
|
|
158
|
-
k2 = x64Rotl(k2, 33);
|
|
159
|
-
k2 = x64Multiply(k2, c1);
|
|
160
|
-
h2 = x64Xor(h2, k2);
|
|
161
|
-
h2 = x64Rotl(h2, 31);
|
|
162
|
-
h2 = x64Add(h2, h1);
|
|
163
|
-
h2 = x64Add(x64Multiply(h2, [0, 5]), [0, 0x38495ab5]);
|
|
164
|
-
}
|
|
165
|
-
k1 = [0, 0];
|
|
166
|
-
k2 = [0, 0];
|
|
167
|
-
switch (remainder) {
|
|
168
|
-
case 15:
|
|
169
|
-
k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 14)], 48));
|
|
170
|
-
// fallthrough
|
|
171
|
-
case 14:
|
|
172
|
-
k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 13)], 40));
|
|
173
|
-
// fallthrough
|
|
174
|
-
case 13:
|
|
175
|
-
k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 12)], 32));
|
|
176
|
-
// fallthrough
|
|
177
|
-
case 12:
|
|
178
|
-
k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 11)], 24));
|
|
179
|
-
// fallthrough
|
|
180
|
-
case 11:
|
|
181
|
-
k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 10)], 16));
|
|
182
|
-
// fallthrough
|
|
183
|
-
case 10:
|
|
184
|
-
k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 9)], 8));
|
|
185
|
-
// fallthrough
|
|
186
|
-
case 9:
|
|
187
|
-
k2 = x64Xor(k2, [0, key.charCodeAt(i + 8)]);
|
|
188
|
-
k2 = x64Multiply(k2, c2);
|
|
189
|
-
k2 = x64Rotl(k2, 33);
|
|
190
|
-
k2 = x64Multiply(k2, c1);
|
|
191
|
-
h2 = x64Xor(h2, k2);
|
|
192
|
-
// fallthrough
|
|
193
|
-
case 8:
|
|
194
|
-
k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 7)], 56));
|
|
195
|
-
// fallthrough
|
|
196
|
-
case 7:
|
|
197
|
-
k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 6)], 48));
|
|
198
|
-
// fallthrough
|
|
199
|
-
case 6:
|
|
200
|
-
k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 5)], 40));
|
|
201
|
-
// fallthrough
|
|
202
|
-
case 5:
|
|
203
|
-
k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 4)], 32));
|
|
204
|
-
// fallthrough
|
|
205
|
-
case 4:
|
|
206
|
-
k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 3)], 24));
|
|
207
|
-
// fallthrough
|
|
208
|
-
case 3:
|
|
209
|
-
k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 2)], 16));
|
|
210
|
-
// fallthrough
|
|
211
|
-
case 2:
|
|
212
|
-
k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 1)], 8));
|
|
213
|
-
// fallthrough
|
|
214
|
-
case 1:
|
|
215
|
-
k1 = x64Xor(k1, [0, key.charCodeAt(i)]);
|
|
216
|
-
k1 = x64Multiply(k1, c1);
|
|
217
|
-
k1 = x64Rotl(k1, 31);
|
|
218
|
-
k1 = x64Multiply(k1, c2);
|
|
219
|
-
h1 = x64Xor(h1, k1);
|
|
220
|
-
// fallthrough
|
|
221
|
-
}
|
|
222
|
-
h1 = x64Xor(h1, [0, key.length]);
|
|
223
|
-
h2 = x64Xor(h2, [0, key.length]);
|
|
224
|
-
h1 = x64Add(h1, h2);
|
|
225
|
-
h2 = x64Add(h2, h1);
|
|
226
|
-
h1 = x64Fmix(h1);
|
|
227
|
-
h2 = x64Fmix(h2);
|
|
228
|
-
h1 = x64Add(h1, h2);
|
|
229
|
-
h2 = x64Add(h2, h1);
|
|
230
|
-
return (("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) +
|
|
231
|
-
("00000000" + (h1[1] >>> 0).toString(16)).slice(-8) +
|
|
232
|
-
("00000000" + (h2[0] >>> 0).toString(16)).slice(-8) +
|
|
233
|
-
("00000000" + (h2[1] >>> 0).toString(16)).slice(-8));
|
|
234
|
-
};
|
package/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./request";
|
package/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./request";
|
package/utils/lsid.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function generateLsid(): string;
|
package/utils/lsid.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// 模拟Rust的random_string!宏
|
|
2
|
-
function randomString(len, charset) {
|
|
3
|
-
const chars = charset.split("");
|
|
4
|
-
const charsetLength = chars.length;
|
|
5
|
-
return Array.from({ length: len }, () => chars[Math.floor(Math.random() * charsetLength)]).join("");
|
|
6
|
-
}
|
|
7
|
-
// 主函数
|
|
8
|
-
export function generateLsid() {
|
|
9
|
-
const randomPart = randomString(8, "0123456789ABCDEF" // 保持全大写十六进制特征
|
|
10
|
-
);
|
|
11
|
-
const timestampPart = Date.now()
|
|
12
|
-
.toString(16) // 转换为十六进制
|
|
13
|
-
.toUpperCase(); // 保持与Rust的:X格式一致
|
|
14
|
-
return `${randomPart}_${timestampPart}`;
|
|
15
|
-
}
|
package/utils/randomImage.d.ts
DELETED
package/utils/randomImage.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
// Generated by Deepseek
|
|
2
|
-
/** 生成随机的base64图片数据 */
|
|
3
|
-
export function generateRandomPngBase64() {
|
|
4
|
-
// 生成带过滤头的随机像素数据
|
|
5
|
-
const pixelData = new Uint8Array(20 * (20 * 4 + 1));
|
|
6
|
-
for (let y = 0, offset = 0; y < 20; y++) {
|
|
7
|
-
pixelData[offset++] = 0; // 过滤类型
|
|
8
|
-
for (let x = 0; x < 20; x++) {
|
|
9
|
-
pixelData[offset++] = Math.floor(Math.random() * 256); // R
|
|
10
|
-
pixelData[offset++] = Math.floor(Math.random() * 256); // G
|
|
11
|
-
pixelData[offset++] = Math.floor(Math.random() * 256); // B
|
|
12
|
-
pixelData[offset++] = 255; // A
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
// 计算Adler32校验和
|
|
16
|
-
const computeAdler32 = (data) => {
|
|
17
|
-
let s1 = 1, s2 = 0;
|
|
18
|
-
for (const byte of data) {
|
|
19
|
-
s1 = (s1 + byte) % 65521;
|
|
20
|
-
s2 = (s2 + s1) % 65521;
|
|
21
|
-
}
|
|
22
|
-
return (s2 << 16) | s1;
|
|
23
|
-
};
|
|
24
|
-
// 构造Deflate流
|
|
25
|
-
const deflateStream = new Uint8Array([
|
|
26
|
-
0x78,
|
|
27
|
-
0x01, // Zlib头
|
|
28
|
-
0x00, // BFINAL=0,BTYPE=00(非最后块)
|
|
29
|
-
0x54,
|
|
30
|
-
0x06, // LEN=1620
|
|
31
|
-
0xab,
|
|
32
|
-
0xf9, // NLEN=~1620
|
|
33
|
-
...pixelData,
|
|
34
|
-
...new Uint8Array([
|
|
35
|
-
// Adler32
|
|
36
|
-
(computeAdler32(pixelData) >> 24) & 0xff,
|
|
37
|
-
(computeAdler32(pixelData) >> 16) & 0xff,
|
|
38
|
-
(computeAdler32(pixelData) >> 8) & 0xff,
|
|
39
|
-
computeAdler32(pixelData) & 0xff,
|
|
40
|
-
]),
|
|
41
|
-
]);
|
|
42
|
-
// 计算CRC32
|
|
43
|
-
const computeCRC32 = (data) => {
|
|
44
|
-
let crc = 0xffffffff;
|
|
45
|
-
const table = new Uint32Array(256);
|
|
46
|
-
for (let i = 0; i < 256; i++) {
|
|
47
|
-
let c = i;
|
|
48
|
-
for (let j = 0; j < 8; j++) {
|
|
49
|
-
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
50
|
-
}
|
|
51
|
-
table[i] = c;
|
|
52
|
-
}
|
|
53
|
-
for (const byte of data) {
|
|
54
|
-
crc = table[(crc ^ byte) & 0xff] ^ (crc >>> 8);
|
|
55
|
-
}
|
|
56
|
-
return crc ^ 0xffffffff;
|
|
57
|
-
};
|
|
58
|
-
// 创建PNG块
|
|
59
|
-
const createChunk = (type, data) => {
|
|
60
|
-
const typeBytes = new TextEncoder().encode(type);
|
|
61
|
-
const length = new Uint8Array(4);
|
|
62
|
-
length[0] = (data.length >> 24) & 0xff;
|
|
63
|
-
length[1] = (data.length >> 16) & 0xff;
|
|
64
|
-
length[2] = (data.length >> 8) & 0xff;
|
|
65
|
-
length[3] = data.length & 0xff;
|
|
66
|
-
const chunkData = new Uint8Array([...typeBytes, ...data]);
|
|
67
|
-
const crc = computeCRC32(chunkData);
|
|
68
|
-
const crcBytes = new Uint8Array(4);
|
|
69
|
-
crcBytes[0] = (crc >> 24) & 0xff;
|
|
70
|
-
crcBytes[1] = (crc >> 16) & 0xff;
|
|
71
|
-
crcBytes[2] = (crc >> 8) & 0xff;
|
|
72
|
-
crcBytes[3] = crc & 0xff;
|
|
73
|
-
return new Uint8Array([...length, ...chunkData, ...crcBytes]);
|
|
74
|
-
};
|
|
75
|
-
// 构建PNG结构
|
|
76
|
-
const signature = new Uint8Array([
|
|
77
|
-
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
|
|
78
|
-
]);
|
|
79
|
-
const ihdrData = new Uint8Array([
|
|
80
|
-
0x00,
|
|
81
|
-
0x00,
|
|
82
|
-
0x00,
|
|
83
|
-
0x14, // 宽度20
|
|
84
|
-
0x00,
|
|
85
|
-
0x00,
|
|
86
|
-
0x00,
|
|
87
|
-
0x14, // 高度20
|
|
88
|
-
0x08, // 位深度
|
|
89
|
-
0x06, // 颜色类型(RGBA)
|
|
90
|
-
0x00, // 压缩方法
|
|
91
|
-
0x00, // 滤波方法
|
|
92
|
-
0x00, // 隔行扫描
|
|
93
|
-
]);
|
|
94
|
-
const ihdrChunk = createChunk("IHDR", ihdrData);
|
|
95
|
-
const idatChunk = createChunk("IDAT", deflateStream);
|
|
96
|
-
const iendChunk = createChunk("IEND", new Uint8Array(0));
|
|
97
|
-
// 合并所有数据
|
|
98
|
-
const pngData = new Uint8Array([
|
|
99
|
-
...signature,
|
|
100
|
-
...ihdrChunk,
|
|
101
|
-
...idatChunk,
|
|
102
|
-
...iendChunk,
|
|
103
|
-
]);
|
|
104
|
-
// 转换为Base64
|
|
105
|
-
const base64 = btoa(String.fromCharCode(...pngData));
|
|
106
|
-
return `data:image/png;base64,${base64}`;
|
|
107
|
-
}
|
package/utils/uuid.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function generateUuid(): string;
|
package/utils/uuid.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Refactored by Deepseek
|
|
2
|
-
// from `https://github.com/SocialSisterYi/bilibili-API-collect/issues/933#issue-2073916390`
|
|
3
|
-
// Copyright (c) 2024 Hantong Chen(cxw620). MIT license.
|
|
4
|
-
// RE from `https://s1.hdslb.com/bfs/seed/log/report/log-reporter.js`
|
|
5
|
-
// 工具函数代替Rust宏
|
|
6
|
-
const DIGIT_MAP = [
|
|
7
|
-
"1",
|
|
8
|
-
"2",
|
|
9
|
-
"3",
|
|
10
|
-
"4",
|
|
11
|
-
"5",
|
|
12
|
-
"6",
|
|
13
|
-
"7",
|
|
14
|
-
"8",
|
|
15
|
-
"9",
|
|
16
|
-
"A",
|
|
17
|
-
"B",
|
|
18
|
-
"C",
|
|
19
|
-
"D",
|
|
20
|
-
"E",
|
|
21
|
-
"F",
|
|
22
|
-
"10", // 保持原始数据不变
|
|
23
|
-
];
|
|
24
|
-
// 代替random_choice!宏
|
|
25
|
-
function randomChoice(...args) {
|
|
26
|
-
// 参数解析
|
|
27
|
-
const hasSeparator = typeof args[args.length - 2] === "string";
|
|
28
|
-
const [choiceSet, separator, lengths] = hasSeparator
|
|
29
|
-
? [args.pop(), args.pop(), args]
|
|
30
|
-
: [args.pop(), undefined, args];
|
|
31
|
-
// 生成随机段
|
|
32
|
-
const segments = lengths.map((length) => Array.from({ length }, () => choiceSet[Math.floor(Math.random() * choiceSet.length)]).join(""));
|
|
33
|
-
return separator ? segments.join(separator) : segments.join("");
|
|
34
|
-
}
|
|
35
|
-
// 代替now!宏
|
|
36
|
-
function getTimestamp() {
|
|
37
|
-
return Date.now() % 100000;
|
|
38
|
-
}
|
|
39
|
-
// 代替UuidInfoc结构体
|
|
40
|
-
export function generateUuid() {
|
|
41
|
-
const t = getTimestamp().toString().padStart(5, "0");
|
|
42
|
-
// 生成符合原始格式的各个部分
|
|
43
|
-
const parts = [randomChoice(8, 4, 4, 4, 12, "-", DIGIT_MAP), t, "infoc"];
|
|
44
|
-
return parts.join("");
|
|
45
|
-
}
|