@wener/utils 1.1.2 → 1.1.4
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/dist/cjs/index.js +1 -578
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server.js +2 -0
- package/dist/cjs/server.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/server.js +2 -0
- package/dist/esm/server.js.map +1 -0
- package/dist/system/index.js +2 -0
- package/dist/system/index.js.map +1 -0
- package/dist/system/server.js +2 -0
- package/dist/system/server.js.map +1 -0
- package/index.ts +1 -0
- package/lib/arrays/MaybeArray.js +30 -0
- package/lib/arrays/MaybeArray.js.map +1 -0
- package/lib/asyncs/AsyncInterval.js +15 -0
- package/lib/asyncs/AsyncInterval.js.map +1 -0
- package/lib/asyncs/LazyPromise.js +27 -0
- package/lib/asyncs/LazyPromise.js.map +1 -0
- package/lib/asyncs/isPromise.js +6 -0
- package/lib/asyncs/isPromise.js.map +1 -0
- package/lib/{esm/asyncs/sleep.mjs → asyncs/sleep.js} +1 -1
- package/lib/asyncs/sleep.js.map +1 -0
- package/lib/asyncs/timeout.js +27 -0
- package/lib/asyncs/timeout.js.map +1 -0
- package/lib/browsers/copy.js +51 -0
- package/lib/browsers/copy.js.map +1 -0
- package/lib/browsers/download.js +28 -0
- package/lib/browsers/download.js.map +1 -0
- package/lib/browsers/getFileFromDataTransfer.js +31 -0
- package/lib/browsers/getFileFromDataTransfer.js.map +1 -0
- package/lib/browsers/loaders.js +50 -0
- package/lib/browsers/loaders.js.map +1 -0
- package/lib/crypto/hashing.js +24 -0
- package/lib/crypto/hashing.js.map +1 -0
- package/lib/crypto/hex.js +6 -0
- package/lib/crypto/hex.js.map +1 -0
- package/lib/crypto/randomUUID.js +13 -0
- package/lib/crypto/randomUUID.js.map +1 -0
- package/lib/formats/formatBytes.js +17 -0
- package/lib/formats/formatBytes.js.map +1 -0
- package/lib/index.js +31 -0
- package/lib/index.js.map +1 -0
- package/lib/io/isBuffer.js +6 -0
- package/lib/io/isBuffer.js.map +1 -0
- package/lib/isomorphics/getGlobalThis.js +14 -0
- package/lib/isomorphics/getGlobalThis.js.map +1 -0
- package/lib/logging/createChildLogger.js +18 -0
- package/lib/logging/createChildLogger.js.map +1 -0
- package/lib/logging/createNoopLogger.js +14 -0
- package/lib/logging/createNoopLogger.js.map +1 -0
- package/lib/logging/createWriteLogger.js +13 -0
- package/lib/logging/createWriteLogger.js.map +1 -0
- package/lib/maths/random.js +17 -0
- package/lib/maths/random.js.map +1 -0
- package/lib/modules/isModule.js +6 -0
- package/lib/modules/isModule.js.map +1 -0
- package/lib/modules/parseModuleId.js +31 -0
- package/lib/modules/parseModuleId.js.map +1 -0
- package/lib/server/polyfill.js +8 -0
- package/lib/server/polyfill.js.map +1 -0
- package/lib/server.js +2 -0
- package/lib/server.js.map +1 -0
- package/lib/shim/urljoin.js +51 -0
- package/lib/shim/urljoin.js.map +1 -0
- package/lib/strings/camelCase.js +56 -0
- package/lib/strings/camelCase.js.map +1 -0
- package/lib/strings/templates.js +8 -0
- package/lib/strings/templates.js.map +1 -0
- package/lib/validations/dequal.js +95 -0
- package/lib/validations/dequal.js.map +1 -0
- package/lib/validations/isClass.js +6 -0
- package/lib/validations/isClass.js.map +1 -0
- package/lib/validations/isDefined.js +6 -0
- package/lib/validations/isDefined.js.map +1 -0
- package/lib/validations/isEmptyObject.js +9 -0
- package/lib/validations/isEmptyObject.js.map +1 -0
- package/lib/validations/shallow.js +21 -0
- package/lib/validations/shallow.js.map +1 -0
- package/package.json +37 -34
- package/server.ts +1 -0
- package/src/arrays/MaybeArray.ts +8 -4
- package/src/crypto/randomUUID.ts +3 -0
- package/src/index.ts +20 -1
- package/src/logging/Logger.ts +19 -0
- package/src/logging/createChildLogger.ts +16 -0
- package/src/logging/createNoopLogger.ts +13 -0
- package/src/logging/createWriteLogger.ts +15 -0
- package/src/logging/logger.test.ts +16 -0
- package/src/modules/isModule.ts +3 -0
- package/src/modules/parseModuleId.test.ts +68 -0
- package/src/modules/parseModuleId.ts +46 -0
- package/src/server/polyfill.ts +5 -0
- package/src/server.ts +1 -0
- package/src/shim/urljoin.test.ts +1 -1
- package/src/validations/dequal.test.ts +17 -0
- package/src/validations/dequal.ts +105 -0
- package/src/validations/shallow.ts +26 -0
- package/dist/esm/index.development.js +0 -545
- package/dist/esm/index.development.js.map +0 -1
- package/dist/esm/index.min.js +0 -2
- package/dist/esm/index.min.js.map +0 -1
- package/dist/system/index.development.js +0 -585
- package/dist/system/index.development.js.map +0 -1
- package/dist/system/index.min.js +0 -2
- package/dist/system/index.min.js.map +0 -1
- package/lib/esm/arrays/MaybeArray.mjs +0 -30
- package/lib/esm/arrays/MaybeArray.mjs.map +0 -1
- package/lib/esm/asyncs/AsyncInterval.mjs +0 -15
- package/lib/esm/asyncs/AsyncInterval.mjs.map +0 -1
- package/lib/esm/asyncs/LazyPromise.mjs +0 -24
- package/lib/esm/asyncs/LazyPromise.mjs.map +0 -1
- package/lib/esm/asyncs/isPromise.mjs +0 -6
- package/lib/esm/asyncs/isPromise.mjs.map +0 -1
- package/lib/esm/asyncs/sleep.mjs.map +0 -1
- package/lib/esm/asyncs/timeout.mjs +0 -24
- package/lib/esm/asyncs/timeout.mjs.map +0 -1
- package/lib/esm/browsers/copy.mjs +0 -57
- package/lib/esm/browsers/copy.mjs.map +0 -1
- package/lib/esm/browsers/download.mjs +0 -40
- package/lib/esm/browsers/download.mjs.map +0 -1
- package/lib/esm/browsers/getFileFromDataTransfer.mjs +0 -39
- package/lib/esm/browsers/getFileFromDataTransfer.mjs.map +0 -1
- package/lib/esm/browsers/loaders.mjs +0 -52
- package/lib/esm/browsers/loaders.mjs.map +0 -1
- package/lib/esm/crypto/hashing.mjs +0 -25
- package/lib/esm/crypto/hashing.mjs.map +0 -1
- package/lib/esm/crypto/hex.mjs +0 -8
- package/lib/esm/crypto/hex.mjs.map +0 -1
- package/lib/esm/crypto/randomUUID.mjs +0 -13
- package/lib/esm/crypto/randomUUID.mjs.map +0 -1
- package/lib/esm/formats/formatBytes.mjs +0 -29
- package/lib/esm/formats/formatBytes.mjs.map +0 -1
- package/lib/esm/index.mjs +0 -24
- package/lib/esm/index.mjs.map +0 -1
- package/lib/esm/io/isBuffer.mjs +0 -10
- package/lib/esm/io/isBuffer.mjs.map +0 -1
- package/lib/esm/isomorphics/getGlobalThis.mjs +0 -23
- package/lib/esm/isomorphics/getGlobalThis.mjs.map +0 -1
- package/lib/esm/maths/random.mjs +0 -18
- package/lib/esm/maths/random.mjs.map +0 -1
- package/lib/esm/shim/urljoin.mjs +0 -65
- package/lib/esm/shim/urljoin.mjs.map +0 -1
- package/lib/esm/strings/camelCase.mjs +0 -70
- package/lib/esm/strings/camelCase.mjs.map +0 -1
- package/lib/esm/strings/templates.mjs +0 -16
- package/lib/esm/strings/templates.mjs.map +0 -1
- package/lib/esm/validations/isClass.mjs +0 -6
- package/lib/esm/validations/isClass.mjs.map +0 -1
- package/lib/esm/validations/isDefined.mjs +0 -6
- package/lib/esm/validations/isDefined.mjs.map +0 -1
- package/lib/esm/validations/isEmptyObject.mjs +0 -9
- package/lib/esm/validations/isEmptyObject.mjs.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,579 +1,2 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function objectOfMaybeArray(o, keys = null, picker = firstOfMaybeArray) {
|
|
4
|
-
if (keys === null) {
|
|
5
|
-
return Object.fromEntries(Object.entries(o).map(([k, v]) => [k, picker(v)]));
|
|
6
|
-
}
|
|
7
|
-
return Object.fromEntries(keys.map((v) => [v, picker(v)]));
|
|
8
|
-
}
|
|
9
|
-
function firstOfMaybeArray(v) {
|
|
10
|
-
if (Array.isArray(v)) {
|
|
11
|
-
return v[0];
|
|
12
|
-
}
|
|
13
|
-
return v;
|
|
14
|
-
}
|
|
15
|
-
function lastOfMaybeArray(v) {
|
|
16
|
-
if (Array.isArray(v)) {
|
|
17
|
-
return v[v.length - 1];
|
|
18
|
-
}
|
|
19
|
-
return v;
|
|
20
|
-
}
|
|
21
|
-
function arrayOfMaybeArray(v) {
|
|
22
|
-
if (Array.isArray(v)) {
|
|
23
|
-
return v;
|
|
24
|
-
}
|
|
25
|
-
if (v === null || v === undefined) {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
return [v];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function createLazyPromise() {
|
|
32
|
-
const holder = {
|
|
33
|
-
resolve(_) {
|
|
34
|
-
throw new Error('pending resolve');
|
|
35
|
-
},
|
|
36
|
-
reject(_) {
|
|
37
|
-
throw new Error('pending reject');
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
return Object.assign(new Promise((resolve, reject) => {
|
|
41
|
-
holder.reject = reject;
|
|
42
|
-
holder.resolve = resolve;
|
|
43
|
-
}), {
|
|
44
|
-
resolve(v) {
|
|
45
|
-
holder.resolve(v);
|
|
46
|
-
},
|
|
47
|
-
reject(v) {
|
|
48
|
-
holder.resolve(v);
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function setAsyncInterval(cb, interval, initial = interval) {
|
|
54
|
-
let id;
|
|
55
|
-
const handler = async () => {
|
|
56
|
-
await cb();
|
|
57
|
-
id = setTimeout(handler, interval);
|
|
58
|
-
};
|
|
59
|
-
id = setTimeout(handler, initial);
|
|
60
|
-
return () => id;
|
|
61
|
-
}
|
|
62
|
-
function clearAsyncInterval(v) {
|
|
63
|
-
clearTimeout(v?.());
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
67
|
-
|
|
68
|
-
function timeout(v, ms) {
|
|
69
|
-
const error = new TimeoutError();
|
|
70
|
-
let timeout;
|
|
71
|
-
return Promise.race([
|
|
72
|
-
v,
|
|
73
|
-
new Promise((_, reject) => {
|
|
74
|
-
timeout = setTimeout(() => reject(error), ms);
|
|
75
|
-
}),
|
|
76
|
-
]).then((v) => {
|
|
77
|
-
clearTimeout(timeout);
|
|
78
|
-
return v;
|
|
79
|
-
}, (e) => {
|
|
80
|
-
clearTimeout(timeout);
|
|
81
|
-
throw e;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
class TimeoutError extends Error {
|
|
85
|
-
constructor() {
|
|
86
|
-
super('TimeoutError');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function isPromise(v) {
|
|
91
|
-
return v && (v instanceof Promise || (v.then && v.catch));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function isClass(func) {
|
|
95
|
-
return typeof func === 'function' && /^class\s/.test(Function.prototype.toString.call(func));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function isDefined(v) {
|
|
99
|
-
return v !== null && v !== undefined;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function isEmptyObject(o) {
|
|
103
|
-
if (o === null || o === undefined) {
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
return o.constructor === Object && Object.keys(o).length === 0;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// https://github.com/sindresorhus/camelcase/blob/master/index.js
|
|
110
|
-
function preserveCamelCase(string) {
|
|
111
|
-
let isLastCharLower = false;
|
|
112
|
-
let isLastCharUpper = false;
|
|
113
|
-
let isLastLastCharUpper = false;
|
|
114
|
-
for (let i = 0; i < string.length; i++) {
|
|
115
|
-
const character = string[i];
|
|
116
|
-
if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) {
|
|
117
|
-
string = string.slice(0, i) + '-' + string.slice(i);
|
|
118
|
-
isLastCharLower = false;
|
|
119
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
120
|
-
isLastCharUpper = true;
|
|
121
|
-
i++;
|
|
122
|
-
}
|
|
123
|
-
else if (isLastCharUpper &&
|
|
124
|
-
isLastLastCharUpper &&
|
|
125
|
-
/[a-zA-Z]/.test(character) &&
|
|
126
|
-
character.toLowerCase() === character) {
|
|
127
|
-
string = string.slice(0, i - 1) + '-' + string.slice(i - 1);
|
|
128
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
129
|
-
isLastCharUpper = false;
|
|
130
|
-
isLastCharLower = true;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
|
|
134
|
-
isLastLastCharUpper = isLastCharUpper;
|
|
135
|
-
isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return string;
|
|
139
|
-
}
|
|
140
|
-
function pascalCase(input) {
|
|
141
|
-
return camelCase(input, { pascalCase: true });
|
|
142
|
-
}
|
|
143
|
-
function camelCase(input, options = {
|
|
144
|
-
pascalCase: false,
|
|
145
|
-
}) {
|
|
146
|
-
if (!(typeof input === 'string' || Array.isArray(input))) {
|
|
147
|
-
throw new TypeError('Expected the input to be `string | string[]`');
|
|
148
|
-
}
|
|
149
|
-
const postProcess = (x) => (options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x);
|
|
150
|
-
if (Array.isArray(input)) {
|
|
151
|
-
input = input
|
|
152
|
-
.map((x) => x.trim())
|
|
153
|
-
.filter((x) => x.length)
|
|
154
|
-
.join('-');
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
input = input.trim();
|
|
158
|
-
}
|
|
159
|
-
if (input.length === 0) {
|
|
160
|
-
return '';
|
|
161
|
-
}
|
|
162
|
-
if (input.length === 1) {
|
|
163
|
-
return options.pascalCase ? input.toUpperCase() : input.toLowerCase();
|
|
164
|
-
}
|
|
165
|
-
const hasUpperCase = input !== input.toLowerCase();
|
|
166
|
-
if (hasUpperCase) {
|
|
167
|
-
input = preserveCamelCase(input);
|
|
168
|
-
}
|
|
169
|
-
input = input
|
|
170
|
-
.replace(/^[_.\- ]+/, '')
|
|
171
|
-
.toLowerCase()
|
|
172
|
-
.replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase())
|
|
173
|
-
.replace(/\d+(\w|$)/g, (m) => m.toUpperCase());
|
|
174
|
-
return postProcess(input);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* 替换类似于 JS 的模板字符串
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* templateString('My name is ${name}',{name:'wener'})
|
|
182
|
-
*/
|
|
183
|
-
function templateString(template, getter) {
|
|
184
|
-
return template.replace(/\${(.*?)}/g, (_, g) => {
|
|
185
|
-
// variables[g.trim()]
|
|
186
|
-
// 支持路径 - 例如 a.b[0]
|
|
187
|
-
return getter(g.trim());
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/// javascript pseudo random
|
|
192
|
-
function createRandom(o = {}) {
|
|
193
|
-
let seed = typeof o.seed === 'string' ? 0 : o.seed ?? 0;
|
|
194
|
-
if (typeof o.seed === 'string') {
|
|
195
|
-
let sum = 0;
|
|
196
|
-
for (let i = 0; i < o.seed.length; i++) {
|
|
197
|
-
sum += o.seed.charCodeAt(i);
|
|
198
|
-
}
|
|
199
|
-
seed = sum;
|
|
200
|
-
}
|
|
201
|
-
return () => {
|
|
202
|
-
const x = Math.sin(seed++) * 10000;
|
|
203
|
-
return x - Math.floor(x);
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// https://github.com/feross/is-buffer/blob/master/index.js
|
|
208
|
-
function isBuffer(obj) {
|
|
209
|
-
return (obj != null &&
|
|
210
|
-
obj.constructor != null &&
|
|
211
|
-
typeof obj.constructor.isBuffer === 'function' &&
|
|
212
|
-
obj.constructor.isBuffer(obj));
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// https://gist.github.com/rproenca/64781c6a1329b48a455b645d361a9aa3
|
|
216
|
-
let _copy;
|
|
217
|
-
function initCopy() {
|
|
218
|
-
let textArea;
|
|
219
|
-
function isIOS() {
|
|
220
|
-
return navigator.userAgent.match(/ipad|iphone/i);
|
|
221
|
-
}
|
|
222
|
-
function createTextArea(text) {
|
|
223
|
-
textArea = document.createElement('textArea');
|
|
224
|
-
textArea.value = text;
|
|
225
|
-
document.body.appendChild(textArea);
|
|
226
|
-
}
|
|
227
|
-
function selectText() {
|
|
228
|
-
let range, selection;
|
|
229
|
-
if (isIOS()) {
|
|
230
|
-
range = document.createRange();
|
|
231
|
-
range.selectNodeContents(textArea);
|
|
232
|
-
selection = window.getSelection();
|
|
233
|
-
if (selection === null) {
|
|
234
|
-
console.error(`no selection`);
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
selection.removeAllRanges();
|
|
238
|
-
selection.addRange(range);
|
|
239
|
-
textArea.setSelectionRange(0, 999999);
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
textArea.select();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
function copyToClipboard() {
|
|
246
|
-
document.execCommand('copy');
|
|
247
|
-
document.body.removeChild(textArea);
|
|
248
|
-
}
|
|
249
|
-
_copy = (text) => {
|
|
250
|
-
createTextArea(text);
|
|
251
|
-
selectText();
|
|
252
|
-
copyToClipboard();
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Write text to clipboard
|
|
257
|
-
* @param content content
|
|
258
|
-
*/
|
|
259
|
-
function copy(content) {
|
|
260
|
-
if (window.navigator?.clipboard?.writeText) {
|
|
261
|
-
window.navigator.clipboard.writeText(content);
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
if (!_copy) {
|
|
265
|
-
initCopy();
|
|
266
|
-
}
|
|
267
|
-
_copy(content);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Trigger browser download
|
|
272
|
-
* @param filename download as filename
|
|
273
|
-
* @param data data or url to download
|
|
274
|
-
* @param type content type
|
|
275
|
-
* @param raw if true, data is treated as raw data, not url
|
|
276
|
-
*/
|
|
277
|
-
function download(filename, data, { type = 'application/octet-stream', raw = false } = {}) {
|
|
278
|
-
const a = document.createElement('a');
|
|
279
|
-
let closer = () => null;
|
|
280
|
-
try {
|
|
281
|
-
a.download = filename;
|
|
282
|
-
// console.info(`downloading ${name}`, data);
|
|
283
|
-
// url or data url
|
|
284
|
-
if (typeof data === 'string' && /^(https?:|data:)/.test(data) && !raw) {
|
|
285
|
-
a.href = data;
|
|
286
|
-
}
|
|
287
|
-
else if (typeof data === 'string') {
|
|
288
|
-
data = new TextEncoder().encode(data);
|
|
289
|
-
}
|
|
290
|
-
if (data instanceof Uint8Array) {
|
|
291
|
-
data = new Blob([data], { type });
|
|
292
|
-
}
|
|
293
|
-
if (data instanceof File || data instanceof Blob || data instanceof MediaSource) {
|
|
294
|
-
a.href = URL.createObjectURL(data);
|
|
295
|
-
closer = () => URL.revokeObjectURL(a.href);
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
console.error(`invalid download data`, data);
|
|
299
|
-
throw new Error(`can not download ${Object.getPrototypeOf(data)}`);
|
|
300
|
-
}
|
|
301
|
-
a.click();
|
|
302
|
-
}
|
|
303
|
-
finally {
|
|
304
|
-
closer();
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function load(el, resolve, reject, options) {
|
|
309
|
-
el.onload = () => resolve(el);
|
|
310
|
-
el.onerror = (e) => {
|
|
311
|
-
el.remove();
|
|
312
|
-
reject(e);
|
|
313
|
-
};
|
|
314
|
-
const { attributes = {} } = options || {};
|
|
315
|
-
Object.entries(attributes).forEach(([k, v]) => el.setAttribute(k, v));
|
|
316
|
-
document.head.appendChild(el);
|
|
317
|
-
}
|
|
318
|
-
function loadScripts(src, options) {
|
|
319
|
-
if (Array.isArray(src)) {
|
|
320
|
-
return new Promise(async (resolve, reject) => {
|
|
321
|
-
const all = [];
|
|
322
|
-
try {
|
|
323
|
-
for (let s of src) {
|
|
324
|
-
all.push(await loadScripts(s));
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
catch (e) {
|
|
328
|
-
reject(e);
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
resolve(all);
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
// todo quote ?
|
|
335
|
-
let $ele = document.querySelector(`script[src="${src}"]`);
|
|
336
|
-
if ($ele) {
|
|
337
|
-
return Promise.resolve($ele);
|
|
338
|
-
}
|
|
339
|
-
return new Promise((resolve, reject) => {
|
|
340
|
-
const el = document.createElement('script');
|
|
341
|
-
el.src = src;
|
|
342
|
-
load(el, resolve, reject, options);
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
function loadStyles(href, options) {
|
|
346
|
-
let $ele = document.querySelector(`link[href="${href}"]`);
|
|
347
|
-
if ($ele) {
|
|
348
|
-
return Promise.resolve($ele);
|
|
349
|
-
}
|
|
350
|
-
return new Promise((resolve, reject) => {
|
|
351
|
-
const el = document.createElement('link');
|
|
352
|
-
el.rel = 'stylesheet';
|
|
353
|
-
el.href = href;
|
|
354
|
-
load(el, resolve, reject, options);
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function getFileFromDataTransfer(dataTransfer) {
|
|
359
|
-
if (!dataTransfer) {
|
|
360
|
-
return {};
|
|
361
|
-
}
|
|
362
|
-
const items = dataTransfer.items ?? [];
|
|
363
|
-
if (items.length >= 2 && items[0].kind === 'string' && items[1].kind === 'file') {
|
|
364
|
-
// name, file
|
|
365
|
-
const text = dataTransfer.getData('text');
|
|
366
|
-
const file = items[1].getAsFile() ?? dataTransfer.files?.item(0);
|
|
367
|
-
if (!file) {
|
|
368
|
-
console.error(`no file ${text}`, items[1]);
|
|
369
|
-
return {};
|
|
370
|
-
}
|
|
371
|
-
// let type = file.type;
|
|
372
|
-
// // fix type
|
|
373
|
-
// type = type;
|
|
374
|
-
// // NOTE paste file can not parse by libs
|
|
375
|
-
// if (type !== file.type) {
|
|
376
|
-
// const blob = file.slice(0, file.size);
|
|
377
|
-
// file = new File([blob], text, {type});
|
|
378
|
-
// }
|
|
379
|
-
return { file, name: text };
|
|
380
|
-
}
|
|
381
|
-
else if (items[0].kind === 'file') {
|
|
382
|
-
const file = items[0].getAsFile();
|
|
383
|
-
if (!file) {
|
|
384
|
-
console.error(`no file`, items[0]);
|
|
385
|
-
return {};
|
|
386
|
-
}
|
|
387
|
-
return { file, name: file.name };
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
console.debug(`file item not match`, Array.from(items).map((v) => ({ type: v.type, kind: v.kind })));
|
|
391
|
-
}
|
|
392
|
-
return {};
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* isomorphic globalThis
|
|
397
|
-
*
|
|
398
|
-
* globalThis supported by ff 65, Chrome 71, Node 12, babel
|
|
399
|
-
*
|
|
400
|
-
* @see https://caniuse.com/#search=globalThis
|
|
401
|
-
* @see https://v8.dev/features/globalthis
|
|
402
|
-
*/
|
|
403
|
-
const getGlobalThis = () => {
|
|
404
|
-
if (typeof globalThis !== 'undefined')
|
|
405
|
-
return globalThis;
|
|
406
|
-
if (typeof self !== 'undefined')
|
|
407
|
-
return self;
|
|
408
|
-
if (typeof window !== 'undefined')
|
|
409
|
-
return window;
|
|
410
|
-
if (typeof global !== 'undefined')
|
|
411
|
-
return global;
|
|
412
|
-
// if (typeof this !== 'undefined') return this;
|
|
413
|
-
throw new Error('Unable to locate global `this`');
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Format bytes as human-readable text.
|
|
418
|
-
*
|
|
419
|
-
* @param bytes Number of bytes.
|
|
420
|
-
* @param si True to use metric (SI) units, aka powers of 1000. False to use
|
|
421
|
-
* binary (IEC), aka powers of 1024.
|
|
422
|
-
* @param dp Number of decimal places to display.
|
|
423
|
-
*
|
|
424
|
-
* @return Formatted string.
|
|
425
|
-
*/
|
|
426
|
-
function formatBytes(bytes, si = false, dp = 1) {
|
|
427
|
-
const thresh = si ? 1000 : 1024;
|
|
428
|
-
if (Math.abs(bytes) < thresh) {
|
|
429
|
-
return bytes + ' B';
|
|
430
|
-
}
|
|
431
|
-
const units = si
|
|
432
|
-
? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
|
433
|
-
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
|
434
|
-
let u = -1;
|
|
435
|
-
const r = 10 ** dp;
|
|
436
|
-
do {
|
|
437
|
-
bytes /= thresh;
|
|
438
|
-
++u;
|
|
439
|
-
} while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
|
|
440
|
-
return bytes.toFixed(dp) + ' ' + units[u];
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* @see {@link https://github.com/jfromaniello/url-join}
|
|
445
|
-
*/
|
|
446
|
-
function urljoin(...args) {
|
|
447
|
-
if (Array.isArray(args[0])) {
|
|
448
|
-
return normalize(args[0]);
|
|
449
|
-
}
|
|
450
|
-
else {
|
|
451
|
-
return normalize(args);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
function normalize(strArray) {
|
|
455
|
-
const resultArray = [];
|
|
456
|
-
if (strArray.length === 0) {
|
|
457
|
-
return '';
|
|
458
|
-
}
|
|
459
|
-
if (typeof strArray[0] !== 'string') {
|
|
460
|
-
throw new TypeError('Url must be a string. Received ' + strArray[0]);
|
|
461
|
-
}
|
|
462
|
-
// If the first part is a plain protocol, we combine it with the next part.
|
|
463
|
-
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
|
|
464
|
-
const first = strArray.shift();
|
|
465
|
-
strArray[0] = first + strArray[0];
|
|
466
|
-
}
|
|
467
|
-
// There must be two or three slashes in the file protocol, two slashes in anything else.
|
|
468
|
-
if (strArray[0].match(/^file:\/\/\//)) {
|
|
469
|
-
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///');
|
|
470
|
-
}
|
|
471
|
-
else {
|
|
472
|
-
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://');
|
|
473
|
-
}
|
|
474
|
-
for (let i = 0; i < strArray.length; i++) {
|
|
475
|
-
let component = strArray[i];
|
|
476
|
-
if (typeof component !== 'string') {
|
|
477
|
-
throw new TypeError('Url must be a string. Received ' + component);
|
|
478
|
-
}
|
|
479
|
-
if (component === '') {
|
|
480
|
-
continue;
|
|
481
|
-
}
|
|
482
|
-
if (i > 0) {
|
|
483
|
-
// Removing the starting slashes for each component but the first.
|
|
484
|
-
component = component.replace(/^[\/]+/, '');
|
|
485
|
-
}
|
|
486
|
-
if (i < strArray.length - 1) {
|
|
487
|
-
// Removing the ending slashes for each component but the last.
|
|
488
|
-
component = component.replace(/[\/]+$/, '');
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
// For the last component we will combine multiple slashes to a single one.
|
|
492
|
-
component = component.replace(/[\/]+$/, '/');
|
|
493
|
-
}
|
|
494
|
-
resultArray.push(component);
|
|
495
|
-
}
|
|
496
|
-
let str = resultArray.join('/');
|
|
497
|
-
// Each input component is now separated by a single slash except the possible first plain protocol part.
|
|
498
|
-
// remove trailing slash before parameters or hash
|
|
499
|
-
str = str.replace(/\/(\?|&|#[^!])/g, '$1');
|
|
500
|
-
// replace ? in parameters with &
|
|
501
|
-
const parts = str.split('?');
|
|
502
|
-
str = parts.shift() + (parts.length > 0 ? '?' : '') + parts.join('&');
|
|
503
|
-
return str;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function randomUUID() {
|
|
507
|
-
if ('randomUUID' in crypto) {
|
|
508
|
-
return crypto.randomUUID();
|
|
509
|
-
}
|
|
510
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
511
|
-
const r = (Math.random() * 16) | 0;
|
|
512
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
513
|
-
return v.toString(16);
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
async function sha1(s) {
|
|
518
|
-
return digestOf('SHA-1', s);
|
|
519
|
-
}
|
|
520
|
-
async function sha256(s) {
|
|
521
|
-
return digestOf('SHA-256', s);
|
|
522
|
-
}
|
|
523
|
-
async function sha384(s) {
|
|
524
|
-
return digestOf('SHA-384', s);
|
|
525
|
-
}
|
|
526
|
-
async function sha512(s) {
|
|
527
|
-
return digestOf('SHA-512', s);
|
|
528
|
-
}
|
|
529
|
-
function digestOf(a, s) {
|
|
530
|
-
return crypto.subtle.digest(a, bufferOf(s));
|
|
531
|
-
}
|
|
532
|
-
function bufferOf(s) {
|
|
533
|
-
// ArrayBuffer, TypedArray, DataView
|
|
534
|
-
if (typeof s === 'string') {
|
|
535
|
-
return new TextEncoder().encode(s);
|
|
536
|
-
}
|
|
537
|
-
return s;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
function hex(s) {
|
|
541
|
-
return Array.from(new Uint8Array(s))
|
|
542
|
-
.map((v) => v.toString(16).padStart(2, '0'))
|
|
543
|
-
.join('');
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
exports.TimeoutError = TimeoutError;
|
|
547
|
-
exports.arrayOfMaybeArray = arrayOfMaybeArray;
|
|
548
|
-
exports.camelCase = camelCase;
|
|
549
|
-
exports.clearAsyncInterval = clearAsyncInterval;
|
|
550
|
-
exports.copy = copy;
|
|
551
|
-
exports.createLazyPromise = createLazyPromise;
|
|
552
|
-
exports.createRandom = createRandom;
|
|
553
|
-
exports.download = download;
|
|
554
|
-
exports.firstOfMaybeArray = firstOfMaybeArray;
|
|
555
|
-
exports.formatBytes = formatBytes;
|
|
556
|
-
exports.getFileFromDataTransfer = getFileFromDataTransfer;
|
|
557
|
-
exports.getGlobalThis = getGlobalThis;
|
|
558
|
-
exports.hex = hex;
|
|
559
|
-
exports.isBuffer = isBuffer;
|
|
560
|
-
exports.isClass = isClass;
|
|
561
|
-
exports.isDefined = isDefined;
|
|
562
|
-
exports.isEmptyObject = isEmptyObject;
|
|
563
|
-
exports.isPromise = isPromise;
|
|
564
|
-
exports.lastOfMaybeArray = lastOfMaybeArray;
|
|
565
|
-
exports.loadScripts = loadScripts;
|
|
566
|
-
exports.loadStyles = loadStyles;
|
|
567
|
-
exports.objectOfMaybeArray = objectOfMaybeArray;
|
|
568
|
-
exports.pascalCase = pascalCase;
|
|
569
|
-
exports.randomUUID = randomUUID;
|
|
570
|
-
exports.setAsyncInterval = setAsyncInterval;
|
|
571
|
-
exports.sha1 = sha1;
|
|
572
|
-
exports.sha256 = sha256;
|
|
573
|
-
exports.sha384 = sha384;
|
|
574
|
-
exports.sha512 = sha512;
|
|
575
|
-
exports.sleep = sleep;
|
|
576
|
-
exports.templateString = templateString;
|
|
577
|
-
exports.timeout = timeout;
|
|
578
|
-
exports.urljoin = urljoin;
|
|
1
|
+
"use strict";function O(e,t=null,r=d){return Object.fromEntries(t===null?Object.entries(e).map(([n,o])=>[n,r(o)]):t.map(n=>[n,r(n)]))}function d(e){return Array.isArray(e)?e[0]:e}function T(e){return Array.isArray(e)?e[e.length-1]:e}function E(e){return Array.isArray(e)?e:e==null?[]:[e]}function U(){const e={resolve(t){throw new Error("pending resolve")},reject(t){throw new Error("pending reject")}};return Object.assign(new Promise((t,r)=>{e.reject=r,e.resolve=t}),{resolve(t){e.resolve(t)},reject(t){e.resolve(t)}})}function B(e,t,r=t){let n;const o=async()=>{await e(),n=setTimeout(o,t)};return n=setTimeout(o,r),()=>n}function S(e){clearTimeout(e==null?void 0:e())}const M=e=>new Promise(t=>setTimeout(t,e));function L(e,t){const r=new g;let n;return Promise.race([e,new Promise((o,i)=>{n=setTimeout(()=>i(r),t)})]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}class g extends Error{constructor(){super("TimeoutError")}}function $(e){return e&&(e instanceof Promise||e.then&&e.catch)}function k(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}function P(e){return e!=null}function z(e){return e==null?!0:e.constructor===Object&&Object.keys(e).length===0}function R(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(t,r[n])||!Object.is(e[r[n]],t[r[n]]))return!1;return!0}const h=Object.prototype.hasOwnProperty,I=typeof Element<"u";function m(e,t,r){for(r of e.keys())if(c(r,t))return r}function c(e,t){let r,n,o;if(e===t)return!0;if(e&&t&&(r=e.constructor)===t.constructor){if(r===Date)return e.getTime()===t.getTime();if(r===RegExp)return e.toString()===t.toString();if(r===Array){if((n=e.length)===t.length)for(;n--&&c(e[n],t[n]););return n===-1}if(r===Set){if(e.size!==t.size)return!1;for(n of e)if(o=n,o&&typeof o=="object"&&(o=m(t,o),!o)||!t.has(o))return!1;return!0}if(r===Map){if(e.size!==t.size)return!1;for(n of e)if(o=n[0],o&&typeof o=="object"&&(o=m(t,o),!o)||!c(n[1],t.get(o)))return!1;return!0}if(r===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(r===DataView){if((n=e.byteLength)===t.byteLength)for(;n--&&e.getInt8(n)===t.getInt8(n););return n===-1}if(ArrayBuffer.isView(e)){if((n=e.byteLength)===t.byteLength)for(;n--&&e[n]===t[n];);return n===-1}if(I&&e instanceof Element)return!1;if(!r||typeof e=="object"){n=0;for(r in e)if(!((r==="_owner"||r==="__v"||r==="__o")&&e.$$typeof)&&(h.call(e,r)&&++n&&!h.call(t,r)||!(r in t)||!c(e[r],t[r])))return!1;return Object.keys(t).length===n}}return e!==e&&t!==t}const D=/^(?<n>(?:@(?<org>[a-z0-9-~][a-z0-9-._~]*)\/)?(?<pkg>[a-z0-9-~][a-z0-9-._~]*))(?:@(?<v>[-a-z0-9><=_.^~]+))?(?<p>\/[^\r\n]*)?$/;function _(e){var t;const r=(t=e.match(D))==null?void 0:t.groups;if(!r)return;const{n,v:o,p:i,org:a,pkg:j}=r;let C=Boolean(a);const p=/^\d+\.\d+\.\d+/.test(o)?o:void 0;let y=o||"latest";const s={id:`${n}@${y}`,name:n,range:y,scoped:C,pkg:j};return p&&(s.version=p),i&&(s.path=i),s.scoped&&(s.org=a),s}function F(e){return e&&e[Symbol.toStringTag]==="Module"}function u(e,t={}){return{trace:(...r)=>e({...t,level:"trace",values:r}),debug:(...r)=>e({...t,level:"debug",values:r}),info:(...r)=>e({...t,level:"info",values:r}),warn:(...r)=>e({...t,level:"warn",values:r}),error:(...r)=>e({...t,level:"error",values:r}),child:r=>u(e,{...t,...r})}}function w(){const e=(...t)=>{};return{trace:e,debug:e,info:e,warn:e,error:e,child:()=>w()}}function q(e,t){return e.child?e.child(t):u(r=>{const{level:n,values:o,...i}=r;Object.keys(i).length?e[n](i,...o):e[n](...o)},t)}function G(e){let t=!1,r=!1,n=!1;for(let o=0;o<e.length;o++){const i=e[o];t&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(e=e.slice(0,o)+"-"+e.slice(o),t=!1,n=r,r=!0,o++):r&&n&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(e=e.slice(0,o-1)+"-"+e.slice(o-1),n=r,r=!1,t=!0):(t=i.toLowerCase()===i&&i.toUpperCase()!==i,n=r,r=i.toUpperCase()===i&&i.toLowerCase()!==i)}return e}function H(e){return b(e,{pascalCase:!0})}function b(e,t={pascalCase:!1}){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");const r=n=>t.pascalCase?n.charAt(0).toUpperCase()+n.slice(1):n;return Array.isArray(e)?e=e.map(n=>n.trim()).filter(n=>n.length).join("-"):e=e.trim(),e.length===0?"":e.length===1?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=G(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(n,o)=>o.toUpperCase()).replace(/\d+(\w|$)/g,n=>n.toUpperCase()),r(e))}function Z(e,t){return e.replace(/\${(.*?)}/g,(r,n)=>t(n.trim()))}function N(e={}){let t=typeof e.seed=="string"?0:e.seed??0;if(typeof e.seed=="string"){let r=0;for(let n=0;n<e.seed.length;n++)r+=e.seed.charCodeAt(n);t=r}return()=>{const r=Math.sin(t++)*1e4;return r-Math.floor(r)}}function V(e){return e!=null&&e.constructor!=null&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}let f;function W(){let e;function t(){return navigator.userAgent.match(/ipad|iphone/i)}function r(i){e=document.createElement("textArea"),e.value=i,document.body.appendChild(e)}function n(){let i,a;if(t()){if(i=document.createRange(),i.selectNodeContents(e),a=window.getSelection(),a===null){console.error("no selection");return}a.removeAllRanges(),a.addRange(i),e.setSelectionRange(0,999999)}else e.select()}function o(){document.execCommand("copy"),document.body.removeChild(e)}f=i=>{r(i),n(),o()}}function Y(e){var t,r;if((r=(t=window.navigator)==null?void 0:t.clipboard)!=null&&r.writeText){window.navigator.clipboard.writeText(e);return}f||W(),f(e)}function K(e,t,{type:r="application/octet-stream",raw:n=!1}={}){const o=document.createElement("a");let i=()=>null;try{if(o.download=e,typeof t=="string"&&/^(https?:|data:)/.test(t)&&!n?o.href=t:typeof t=="string"&&(t=new TextEncoder().encode(t)),t instanceof Uint8Array&&(t=new Blob([t],{type:r})),t instanceof File||t instanceof Blob||t instanceof MediaSource)o.href=URL.createObjectURL(t),i=()=>URL.revokeObjectURL(o.href);else throw console.error("invalid download data",t),new Error(`can not download ${Object.getPrototypeOf(t)}`);o.click()}finally{i()}}function A(e,t,r,n){e.onload=()=>t(e),e.onerror=i=>{e.remove(),r(i)};const{attributes:o={}}=n||{};Object.entries(o).forEach(([i,a])=>e.setAttribute(i,a)),document.head.appendChild(e)}function v(e,t){if(Array.isArray(e))return new Promise(async(n,o)=>{const i=[];try{for(let a of e)i.push(await v(a))}catch(a){o(a);return}n(i)});let r=document.querySelector(`script[src="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const i=document.createElement("script");i.src=e,A(i,n,o,t)})}function J(e,t){let r=document.querySelector(`link[href="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const i=document.createElement("link");i.rel="stylesheet",i.href=e,A(i,n,o,t)})}function Q(e){var t;if(!e)return{};const r=e.items??[];if(r.length>=2&&r[0].kind==="string"&&r[1].kind==="file"){const n=e.getData("text"),o=r[1].getAsFile()??((t=e.files)==null?void 0:t.item(0));return o?{file:o,name:n}:(console.error(`no file ${n}`,r[1]),{})}else if(r[0].kind==="file"){const n=r[0].getAsFile();return n?{file:n,name:n.name}:(console.error("no file",r[0]),{})}else console.debug("file item not match",Array.from(r).map(n=>({type:n.type,kind:n.kind})));return{}}const X=()=>{if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global `this`")};function ee(e,t=!1,r=1){const n=t?1e3:1024;if(Math.abs(e)<n)return e+" B";const o=t?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let i=-1;const a=10**r;do e/=n,++i;while(Math.round(Math.abs(e)*a)/a>=n&&i<o.length-1);return e.toFixed(r)+" "+o[i]}function te(...e){return Array.isArray(e[0])?x(e[0]):x(e)}function x(e){const t=[];if(e.length===0)return"";if(typeof e[0]!="string")throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){const o=e.shift();e[0]=o+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(let o=0;o<e.length;o++){let i=e[o];if(typeof i!="string")throw new TypeError("Url must be a string. Received "+i);i!==""&&(o>0&&(i=i.replace(/^[\/]+/,"")),o<e.length-1?i=i.replace(/[\/]+$/,""):i=i.replace(/[\/]+$/,"/"),t.push(i))}let r=t.join("/");r=r.replace(/\/(\?|&|#[^!])/g,"$1");const n=r.split("?");return r=n.shift()+(n.length>0?"?":"")+n.join("&"),r}function re(){return"randomUUID"in crypto?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}async function ne(e){return l("SHA-1",e)}async function oe(e){return l("SHA-256",e)}async function ie(e){return l("SHA-384",e)}async function ae(e){return l("SHA-512",e)}function l(e,t){return crypto.subtle.digest(e,se(t))}function se(e){return typeof e=="string"?new TextEncoder().encode(e):e}function ce(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}exports.TimeoutError=g,exports.arrayOfMaybeArray=E,exports.camelCase=b,exports.clearAsyncInterval=S,exports.copy=Y,exports.createChildLogger=q,exports.createLazyPromise=U,exports.createNoopLogger=w,exports.createRandom=N,exports.createWriteLogger=u,exports.dequal=c,exports.download=K,exports.firstOfMaybeArray=d,exports.formatBytes=ee,exports.getFileFromDataTransfer=Q,exports.getGlobalThis=X,exports.hex=ce,exports.isBuffer=V,exports.isClass=k,exports.isDefined=P,exports.isEmptyObject=z,exports.isModule=F,exports.isPromise=$,exports.lastOfMaybeArray=T,exports.loadScripts=v,exports.loadStyles=J,exports.objectOfMaybeArray=O,exports.parseModuleId=_,exports.pascalCase=H,exports.randomUUID=re,exports.setAsyncInterval=B,exports.sha1=ne,exports.sha256=oe,exports.sha384=ie,exports.sha512=ae,exports.shallow=R,exports.sleep=M,exports.templateString=Z,exports.timeout=L,exports.urljoin=te;
|
|
579
2
|
//# sourceMappingURL=index.js.map
|