zeed 0.8.2 → 0.8.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.
- package/dist/chunk-AITOWUS2.cjs +3305 -0
- package/dist/{chunk-3LN7HI45.js.map → chunk-AITOWUS2.cjs.map} +0 -0
- package/dist/chunk-C66X5FP6.cjs +516 -0
- package/dist/chunk-C66X5FP6.cjs.map +1 -0
- package/dist/chunk-CCZIVE22.cjs +657 -0
- package/dist/chunk-CCZIVE22.cjs.map +1 -0
- package/dist/chunk-KG3OKVAH.cjs +254 -0
- package/dist/chunk-KG3OKVAH.cjs.map +1 -0
- package/dist/{chunk-IFNHRAHG.js → chunk-QCWYJ7FQ.js} +9 -2
- package/dist/chunk-QCWYJ7FQ.js.map +1 -0
- package/dist/chunk-RHL3RQGE.cjs +320 -0
- package/dist/chunk-RHL3RQGE.cjs.map +1 -0
- package/dist/{chunk-3LN7HI45.js → chunk-RIAAIUAZ.js} +1 -1
- package/dist/chunk-RIAAIUAZ.js.map +1 -0
- package/dist/{chunk-HI3XD4NV.js → chunk-S5JPRTZ4.js} +30 -7
- package/dist/chunk-S5JPRTZ4.js.map +1 -0
- package/dist/index.all.cjs +1135 -5026
- package/dist/index.all.cjs.map +1 -1
- package/dist/index.all.js +3 -3
- package/dist/index.browser.cjs +1046 -4378
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +2 -2
- package/dist/index.log.cjs +20 -650
- package/dist/index.log.cjs.map +1 -1
- package/dist/index.node.cjs +1097 -4474
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-HI3XD4NV.js.map +0 -1
- package/dist/chunk-IFNHRAHG.js.map +0 -1
|
@@ -0,0 +1,3305 @@
|
|
|
1
|
+
"use strict"; function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var chunkC66X5FP6_cjs = require('./chunk-C66X5FP6.cjs');
|
|
6
|
+
|
|
7
|
+
// src/common/data/bin.ts
|
|
8
|
+
var log = chunkC66X5FP6_cjs.Logger("bin");
|
|
9
|
+
function _encodeUtf8Polyfill(str) {
|
|
10
|
+
const encodedString = unescape(encodeURIComponent(str));
|
|
11
|
+
const len = encodedString.length;
|
|
12
|
+
const buf = new Uint8Array(len);
|
|
13
|
+
for (let i = 0; i < len; i++) {
|
|
14
|
+
buf[i] = encodedString.codePointAt(i) || 0;
|
|
15
|
+
}
|
|
16
|
+
return buf;
|
|
17
|
+
}
|
|
18
|
+
chunkC66X5FP6_cjs.__name(_encodeUtf8Polyfill, "_encodeUtf8Polyfill");
|
|
19
|
+
function _decodeUtf8Polyfill(buf) {
|
|
20
|
+
let remainingLen = buf.length;
|
|
21
|
+
let encodedString = "";
|
|
22
|
+
let bufPos = 0;
|
|
23
|
+
while (remainingLen > 0) {
|
|
24
|
+
const nextLen = remainingLen < 1e4 ? remainingLen : 1e4;
|
|
25
|
+
const bytes = buf.subarray(bufPos, bufPos + nextLen);
|
|
26
|
+
bufPos += nextLen;
|
|
27
|
+
encodedString += String.fromCodePoint.apply(null, bytes);
|
|
28
|
+
remainingLen -= nextLen;
|
|
29
|
+
}
|
|
30
|
+
return decodeURIComponent(escape(encodedString));
|
|
31
|
+
}
|
|
32
|
+
chunkC66X5FP6_cjs.__name(_decodeUtf8Polyfill, "_decodeUtf8Polyfill");
|
|
33
|
+
var _textEncoder;
|
|
34
|
+
function stringToUInt8Array(text) {
|
|
35
|
+
if (_textEncoder == null) {
|
|
36
|
+
_textEncoder = _encodeUtf8Polyfill;
|
|
37
|
+
if (typeof TextEncoder !== "undefined") {
|
|
38
|
+
const encoder = new TextEncoder();
|
|
39
|
+
_textEncoder = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((data) => encoder.encode(data), "_textEncoder");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return _textEncoder(text.normalize("NFC"));
|
|
43
|
+
}
|
|
44
|
+
chunkC66X5FP6_cjs.__name(stringToUInt8Array, "stringToUInt8Array");
|
|
45
|
+
var _textDecoder;
|
|
46
|
+
function Uint8ArrayToString(bin) {
|
|
47
|
+
if (_textDecoder == null) {
|
|
48
|
+
_textDecoder = _decodeUtf8Polyfill;
|
|
49
|
+
if (typeof TextDecoder !== "undefined") {
|
|
50
|
+
const decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
51
|
+
_textDecoder = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((data) => decoder.decode(data), "_textDecoder");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return _textDecoder(bin).normalize("NFC");
|
|
55
|
+
}
|
|
56
|
+
chunkC66X5FP6_cjs.__name(Uint8ArrayToString, "Uint8ArrayToString");
|
|
57
|
+
function toUint8Array(data) {
|
|
58
|
+
if (data instanceof ArrayBuffer)
|
|
59
|
+
return new Uint8Array(data);
|
|
60
|
+
if (typeof data === "string")
|
|
61
|
+
return stringToUInt8Array(data);
|
|
62
|
+
if (data.length)
|
|
63
|
+
return new Uint8Array(data);
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
chunkC66X5FP6_cjs.__name(toUint8Array, "toUint8Array");
|
|
67
|
+
function joinToUint8Array(...args) {
|
|
68
|
+
let length = 0;
|
|
69
|
+
const bins = args.flat(1).map((d) => {
|
|
70
|
+
const b = toUint8Array(d);
|
|
71
|
+
length += b.length;
|
|
72
|
+
return b;
|
|
73
|
+
});
|
|
74
|
+
let bin = new Uint8Array(length);
|
|
75
|
+
let cursor = 0;
|
|
76
|
+
for (let b of bins) {
|
|
77
|
+
bin.set(b, cursor);
|
|
78
|
+
cursor += b.length;
|
|
79
|
+
}
|
|
80
|
+
return bin;
|
|
81
|
+
}
|
|
82
|
+
chunkC66X5FP6_cjs.__name(joinToUint8Array, "joinToUint8Array");
|
|
83
|
+
function toHex(bin) {
|
|
84
|
+
if (typeof Buffer !== "undefined") {
|
|
85
|
+
return Buffer.from(toUint8Array(bin)).toString("hex");
|
|
86
|
+
}
|
|
87
|
+
const h = "0123456789abcdef";
|
|
88
|
+
let s = "";
|
|
89
|
+
for (const v of [...toUint8Array(bin)]) {
|
|
90
|
+
s += h[v >> 4] + h[v & 15];
|
|
91
|
+
}
|
|
92
|
+
return s;
|
|
93
|
+
}
|
|
94
|
+
chunkC66X5FP6_cjs.__name(toHex, "toHex");
|
|
95
|
+
function toBase64(bin) {
|
|
96
|
+
const bytes = toUint8Array(bin);
|
|
97
|
+
if (typeof Buffer !== "undefined") {
|
|
98
|
+
return Buffer.from(bytes).toString("base64");
|
|
99
|
+
}
|
|
100
|
+
let s = "";
|
|
101
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
102
|
+
s += String.fromCharCode(bytes[i]);
|
|
103
|
+
}
|
|
104
|
+
return btoa(s);
|
|
105
|
+
}
|
|
106
|
+
chunkC66X5FP6_cjs.__name(toBase64, "toBase64");
|
|
107
|
+
function toBase64Url(bin) {
|
|
108
|
+
const bytes = toUint8Array(bin);
|
|
109
|
+
if (typeof Buffer !== "undefined") {
|
|
110
|
+
return Buffer.from(bytes).toString("base64url");
|
|
111
|
+
}
|
|
112
|
+
let s = "";
|
|
113
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
114
|
+
s += String.fromCharCode(bytes[i]);
|
|
115
|
+
}
|
|
116
|
+
return btoa(s).replace(/\+/g, "-").replace(/\//g, "_");
|
|
117
|
+
}
|
|
118
|
+
chunkC66X5FP6_cjs.__name(toBase64Url, "toBase64Url");
|
|
119
|
+
function fromBase64(s) {
|
|
120
|
+
if (typeof Buffer !== "undefined") {
|
|
121
|
+
const buf = Buffer.from(s, "base64");
|
|
122
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
123
|
+
}
|
|
124
|
+
const a = atob(s);
|
|
125
|
+
const bytes = new Uint8Array(a.length);
|
|
126
|
+
for (let i = 0; i < a.length; i++) {
|
|
127
|
+
bytes[i] = a.charCodeAt(i);
|
|
128
|
+
}
|
|
129
|
+
return bytes;
|
|
130
|
+
}
|
|
131
|
+
chunkC66X5FP6_cjs.__name(fromBase64, "fromBase64");
|
|
132
|
+
function equalBinary(a, b) {
|
|
133
|
+
if (a.byteLength !== b.byteLength)
|
|
134
|
+
return false;
|
|
135
|
+
const aa = toUint8Array(a);
|
|
136
|
+
const bb = toUint8Array(b);
|
|
137
|
+
for (let i = 0; i < aa.length; i++) {
|
|
138
|
+
if (aa[i] !== bb[i]) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
chunkC66X5FP6_cjs.__name(equalBinary, "equalBinary");
|
|
145
|
+
function jsonToUint8Array(json) {
|
|
146
|
+
try {
|
|
147
|
+
return stringToUInt8Array(JSON.stringify(json));
|
|
148
|
+
} catch (err) {
|
|
149
|
+
log.warn("jsonToUint8Array", json);
|
|
150
|
+
throw err;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
chunkC66X5FP6_cjs.__name(jsonToUint8Array, "jsonToUint8Array");
|
|
154
|
+
function Uint8ArrayToJson(data) {
|
|
155
|
+
try {
|
|
156
|
+
return JSON.parse(Uint8ArrayToString(data));
|
|
157
|
+
} catch (err) {
|
|
158
|
+
log.warn("Uint8ArrayToJson", data);
|
|
159
|
+
throw err;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
chunkC66X5FP6_cjs.__name(Uint8ArrayToJson, "Uint8ArrayToJson");
|
|
163
|
+
function Uint8ArrayToHexDump(buffer, blockSize) {
|
|
164
|
+
if (typeof buffer === "string") ; else if (buffer instanceof ArrayBuffer && buffer.byteLength !== void 0) {
|
|
165
|
+
buffer = String.fromCharCode.apply(
|
|
166
|
+
String,
|
|
167
|
+
[].slice.call(new Uint8Array(buffer))
|
|
168
|
+
);
|
|
169
|
+
} else if (Array.isArray(buffer)) {
|
|
170
|
+
buffer = String.fromCharCode.apply(String, buffer);
|
|
171
|
+
} else if (buffer.constructor === Uint8Array) {
|
|
172
|
+
buffer = String.fromCharCode.apply(String, [].slice.call(buffer));
|
|
173
|
+
} else {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
blockSize = blockSize || 16;
|
|
177
|
+
var lines = [];
|
|
178
|
+
var hex = "0123456789ABCDEF";
|
|
179
|
+
for (var b = 0; b < buffer.length; b += blockSize) {
|
|
180
|
+
var block = buffer.slice(b, Math.min(b + blockSize, buffer.length));
|
|
181
|
+
var addr = ("0000" + b.toString(16)).slice(-4);
|
|
182
|
+
var codes = block.split("").map((ch) => {
|
|
183
|
+
var code = ch.charCodeAt(0);
|
|
184
|
+
return " " + hex[(240 & code) >> 4] + hex[15 & code];
|
|
185
|
+
}).join("");
|
|
186
|
+
codes += " ".repeat(blockSize - block.length);
|
|
187
|
+
var chars = block.replace(/[\x00-\x1F\x20]/g, ".");
|
|
188
|
+
chars += " ".repeat(blockSize - block.length);
|
|
189
|
+
lines.push(addr + " " + codes + " " + chars);
|
|
190
|
+
}
|
|
191
|
+
return lines.join("\n");
|
|
192
|
+
}
|
|
193
|
+
chunkC66X5FP6_cjs.__name(Uint8ArrayToHexDump, "Uint8ArrayToHexDump");
|
|
194
|
+
|
|
195
|
+
// src/common/crypto.ts
|
|
196
|
+
function randomUint8Array(length = 16) {
|
|
197
|
+
let randomBytes = new Uint8Array(length);
|
|
198
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
199
|
+
crypto.getRandomValues(randomBytes);
|
|
200
|
+
} else {
|
|
201
|
+
for (let i = 0; i < length; i++) {
|
|
202
|
+
randomBytes[i] = Math.floor(Math.random() * 256);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return randomBytes;
|
|
206
|
+
}
|
|
207
|
+
chunkC66X5FP6_cjs.__name(randomUint8Array, "randomUint8Array");
|
|
208
|
+
var DEFAULT_HASH_ALG = "SHA-256";
|
|
209
|
+
var DEFAULT_CRYPTO_ALG = "AES-GCM";
|
|
210
|
+
var DEFAULT_DERIVE_ALG = "PBKDF2";
|
|
211
|
+
async function digest(message, algorithm = DEFAULT_HASH_ALG) {
|
|
212
|
+
return toUint8Array(
|
|
213
|
+
await crypto.subtle.digest(algorithm, toUint8Array(message))
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
chunkC66X5FP6_cjs.__name(digest, "digest");
|
|
217
|
+
async function deriveKeyPbkdf2(secret, opt = {}) {
|
|
218
|
+
const secretBuffer = toUint8Array(secret);
|
|
219
|
+
const keyMaterial = await crypto.subtle.importKey(
|
|
220
|
+
"raw",
|
|
221
|
+
secretBuffer,
|
|
222
|
+
DEFAULT_DERIVE_ALG,
|
|
223
|
+
false,
|
|
224
|
+
["deriveKey"]
|
|
225
|
+
);
|
|
226
|
+
return await crypto.subtle.deriveKey(
|
|
227
|
+
{
|
|
228
|
+
name: DEFAULT_DERIVE_ALG,
|
|
229
|
+
salt: opt.salt ? toUint8Array(opt.salt) : new Uint8Array(0),
|
|
230
|
+
iterations: _nullishCoalesce(opt.iterations, () => ( 1e5)),
|
|
231
|
+
hash: DEFAULT_HASH_ALG
|
|
232
|
+
},
|
|
233
|
+
keyMaterial,
|
|
234
|
+
{
|
|
235
|
+
name: DEFAULT_CRYPTO_ALG,
|
|
236
|
+
length: 256
|
|
237
|
+
},
|
|
238
|
+
true,
|
|
239
|
+
["encrypt", "decrypt"]
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
chunkC66X5FP6_cjs.__name(deriveKeyPbkdf2, "deriveKeyPbkdf2");
|
|
243
|
+
var MAGIC_ID = new Uint8Array([1, 1]);
|
|
244
|
+
async function encrypt(data, key) {
|
|
245
|
+
const iv = randomUint8Array(12);
|
|
246
|
+
const cipher = await crypto.subtle.encrypt(
|
|
247
|
+
{ name: DEFAULT_CRYPTO_ALG, iv },
|
|
248
|
+
key,
|
|
249
|
+
data
|
|
250
|
+
);
|
|
251
|
+
const binCypher = new Uint8Array(cipher);
|
|
252
|
+
const bufferLength = MAGIC_ID.length + iv.length + binCypher.length;
|
|
253
|
+
const buffer = new Uint8Array(bufferLength);
|
|
254
|
+
let pos = 0;
|
|
255
|
+
buffer.set(MAGIC_ID, pos);
|
|
256
|
+
pos += MAGIC_ID.length;
|
|
257
|
+
buffer.set(iv, pos);
|
|
258
|
+
pos += iv.length;
|
|
259
|
+
buffer.set(binCypher, pos);
|
|
260
|
+
return buffer;
|
|
261
|
+
}
|
|
262
|
+
chunkC66X5FP6_cjs.__name(encrypt, "encrypt");
|
|
263
|
+
async function decrypt(data, key) {
|
|
264
|
+
let magic = data.subarray(0, 2);
|
|
265
|
+
if (!equalBinary(magic, MAGIC_ID)) {
|
|
266
|
+
return Promise.reject(`Unknown magic ${magic}`);
|
|
267
|
+
}
|
|
268
|
+
let iv = data.subarray(2, 2 + 12);
|
|
269
|
+
let cipher = data.subarray(2 + 12, data.length);
|
|
270
|
+
const plain = await crypto.subtle.decrypt(
|
|
271
|
+
{ name: DEFAULT_CRYPTO_ALG, iv },
|
|
272
|
+
key,
|
|
273
|
+
cipher
|
|
274
|
+
);
|
|
275
|
+
return new Uint8Array(plain);
|
|
276
|
+
}
|
|
277
|
+
chunkC66X5FP6_cjs.__name(decrypt, "decrypt");
|
|
278
|
+
|
|
279
|
+
// src/common/csv.ts
|
|
280
|
+
var separator = ",";
|
|
281
|
+
function filterFloat(value) {
|
|
282
|
+
if (/^([-+])?([0-9]+(\.[0-9]+)?|Infinity)$/.test(value)) {
|
|
283
|
+
return Number(value);
|
|
284
|
+
}
|
|
285
|
+
return NaN;
|
|
286
|
+
}
|
|
287
|
+
chunkC66X5FP6_cjs.__name(filterFloat, "filterFloat");
|
|
288
|
+
function escape2(field) {
|
|
289
|
+
if (field == void 0) {
|
|
290
|
+
return "";
|
|
291
|
+
}
|
|
292
|
+
if (!isNaN(filterFloat(field)) && isFinite(field)) {
|
|
293
|
+
return parseFloat(field);
|
|
294
|
+
}
|
|
295
|
+
return '"' + String(field).replace(/"/g, '""') + '"';
|
|
296
|
+
}
|
|
297
|
+
chunkC66X5FP6_cjs.__name(escape2, "escape");
|
|
298
|
+
function csv(data, headerRow) {
|
|
299
|
+
let body = "";
|
|
300
|
+
if (headerRow) {
|
|
301
|
+
body = headerRow.join(separator) + "\r\n";
|
|
302
|
+
}
|
|
303
|
+
for (let i = 0; i < data.length; i++) {
|
|
304
|
+
body += data[i].map(escape2).join(separator) + "\r\n";
|
|
305
|
+
}
|
|
306
|
+
return body;
|
|
307
|
+
}
|
|
308
|
+
chunkC66X5FP6_cjs.__name(csv, "csv");
|
|
309
|
+
|
|
310
|
+
// src/common/data/math.ts
|
|
311
|
+
function getSecureRandom() {
|
|
312
|
+
return crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295;
|
|
313
|
+
}
|
|
314
|
+
chunkC66X5FP6_cjs.__name(getSecureRandom, "getSecureRandom");
|
|
315
|
+
function getSecureRandomIfPossible() {
|
|
316
|
+
return typeof crypto !== "undefined" ? getSecureRandom() : Math.random();
|
|
317
|
+
}
|
|
318
|
+
chunkC66X5FP6_cjs.__name(getSecureRandomIfPossible, "getSecureRandomIfPossible");
|
|
319
|
+
function randomBoolean(bias = 0.25) {
|
|
320
|
+
return getSecureRandomIfPossible() < bias;
|
|
321
|
+
}
|
|
322
|
+
chunkC66X5FP6_cjs.__name(randomBoolean, "randomBoolean");
|
|
323
|
+
function randomInt(max = 100, min = 0) {
|
|
324
|
+
return min + Math.floor(getSecureRandomIfPossible() * (max - min));
|
|
325
|
+
}
|
|
326
|
+
chunkC66X5FP6_cjs.__name(randomInt, "randomInt");
|
|
327
|
+
function randomFloat(max = 100, min = 0) {
|
|
328
|
+
return min + getSecureRandomIfPossible() * (max - min);
|
|
329
|
+
}
|
|
330
|
+
chunkC66X5FP6_cjs.__name(randomFloat, "randomFloat");
|
|
331
|
+
function between(min, value, max) {
|
|
332
|
+
return Math.max(min, Math.min(max, value));
|
|
333
|
+
}
|
|
334
|
+
chunkC66X5FP6_cjs.__name(between, "between");
|
|
335
|
+
function sum(array) {
|
|
336
|
+
return array.reduce((acc, value) => acc + value, 0);
|
|
337
|
+
}
|
|
338
|
+
chunkC66X5FP6_cjs.__name(sum, "sum");
|
|
339
|
+
function avg(array) {
|
|
340
|
+
return sum(array) / array.length;
|
|
341
|
+
}
|
|
342
|
+
chunkC66X5FP6_cjs.__name(avg, "avg");
|
|
343
|
+
function isPrimeRX(value) {
|
|
344
|
+
return !/^1?$|^(11+?)\1+$/.test("1".repeat(value));
|
|
345
|
+
}
|
|
346
|
+
chunkC66X5FP6_cjs.__name(isPrimeRX, "isPrimeRX");
|
|
347
|
+
function isPrime(value) {
|
|
348
|
+
for (var i = 2; i < value; i++)
|
|
349
|
+
if (value % i === 0)
|
|
350
|
+
return false;
|
|
351
|
+
return value > 1;
|
|
352
|
+
}
|
|
353
|
+
chunkC66X5FP6_cjs.__name(isPrime, "isPrime");
|
|
354
|
+
|
|
355
|
+
// src/common/data/orderby.ts
|
|
356
|
+
function parseOrderby(value = "") {
|
|
357
|
+
let [field = "", orderby = "asc"] = value.split(" ");
|
|
358
|
+
orderby = orderby.toLowerCase();
|
|
359
|
+
return {
|
|
360
|
+
field,
|
|
361
|
+
orderby,
|
|
362
|
+
asc: orderby !== "desc",
|
|
363
|
+
desc: orderby === "desc"
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
chunkC66X5FP6_cjs.__name(parseOrderby, "parseOrderby");
|
|
367
|
+
function composeOrderby(field, asc = true) {
|
|
368
|
+
return `${field} ${asc ? "asc" : "desc"}`;
|
|
369
|
+
}
|
|
370
|
+
chunkC66X5FP6_cjs.__name(composeOrderby, "composeOrderby");
|
|
371
|
+
function cmp(a, b, asc = true) {
|
|
372
|
+
const aa = a || 0;
|
|
373
|
+
const bb = b || 0;
|
|
374
|
+
return aa > bb ? asc ? 1 : -1 : aa < bb ? asc ? -1 : 1 : 0;
|
|
375
|
+
}
|
|
376
|
+
chunkC66X5FP6_cjs.__name(cmp, "cmp");
|
|
377
|
+
function sortedOrderby(values, ...orderby) {
|
|
378
|
+
if (orderby.length > 0) {
|
|
379
|
+
let orderByList = orderby.map(parseOrderby);
|
|
380
|
+
let sortValues = Array.from(values);
|
|
381
|
+
sortValues.sort((a, b) => {
|
|
382
|
+
for (let { field, asc } of orderByList) {
|
|
383
|
+
const result = cmp(a[field], b[field], asc);
|
|
384
|
+
if (result !== 0)
|
|
385
|
+
return result;
|
|
386
|
+
}
|
|
387
|
+
return 0;
|
|
388
|
+
});
|
|
389
|
+
return sortValues;
|
|
390
|
+
}
|
|
391
|
+
return values;
|
|
392
|
+
}
|
|
393
|
+
chunkC66X5FP6_cjs.__name(sortedOrderby, "sortedOrderby");
|
|
394
|
+
|
|
395
|
+
// src/common/data/array.ts
|
|
396
|
+
function arrayUnique(x) {
|
|
397
|
+
return x.filter((n, index) => x.indexOf(n) === index);
|
|
398
|
+
}
|
|
399
|
+
chunkC66X5FP6_cjs.__name(arrayUnique, "arrayUnique");
|
|
400
|
+
function arrayMinus(x, y) {
|
|
401
|
+
return arrayUnique(x.filter((n) => !y.includes(n)));
|
|
402
|
+
}
|
|
403
|
+
chunkC66X5FP6_cjs.__name(arrayMinus, "arrayMinus");
|
|
404
|
+
function arrayUnion(...a) {
|
|
405
|
+
return arrayUnique(a.reduce((acc = [], value) => acc.concat(value), []));
|
|
406
|
+
}
|
|
407
|
+
chunkC66X5FP6_cjs.__name(arrayUnion, "arrayUnion");
|
|
408
|
+
function arrayFlatten(...list) {
|
|
409
|
+
return list.flat(Infinity);
|
|
410
|
+
}
|
|
411
|
+
chunkC66X5FP6_cjs.__name(arrayFlatten, "arrayFlatten");
|
|
412
|
+
function arrayIntersection(x, y) {
|
|
413
|
+
return arrayUnique(x).filter((n) => y.includes(n));
|
|
414
|
+
}
|
|
415
|
+
chunkC66X5FP6_cjs.__name(arrayIntersection, "arrayIntersection");
|
|
416
|
+
function arraySymmetricDifference(x, y) {
|
|
417
|
+
return arrayMinus(arrayUnion(x, y), arrayIntersection(x, y));
|
|
418
|
+
}
|
|
419
|
+
chunkC66X5FP6_cjs.__name(arraySymmetricDifference, "arraySymmetricDifference");
|
|
420
|
+
function arrayRemoveElement(arr, el) {
|
|
421
|
+
if (arr && Array.isArray(arr)) {
|
|
422
|
+
let index;
|
|
423
|
+
while ((index = arr.indexOf(el)) !== -1) {
|
|
424
|
+
arr.splice(index, 1);
|
|
425
|
+
}
|
|
426
|
+
return arr;
|
|
427
|
+
}
|
|
428
|
+
return [];
|
|
429
|
+
}
|
|
430
|
+
chunkC66X5FP6_cjs.__name(arrayRemoveElement, "arrayRemoveElement");
|
|
431
|
+
function arraySetElement(arr, el) {
|
|
432
|
+
if (!arr.includes(el))
|
|
433
|
+
arr.push(el);
|
|
434
|
+
return arr;
|
|
435
|
+
}
|
|
436
|
+
chunkC66X5FP6_cjs.__name(arraySetElement, "arraySetElement");
|
|
437
|
+
function arrayFilterInPlace(array, fn) {
|
|
438
|
+
array.splice(0, array.length, ...array.filter(fn));
|
|
439
|
+
return array;
|
|
440
|
+
}
|
|
441
|
+
chunkC66X5FP6_cjs.__name(arrayFilterInPlace, "arrayFilterInPlace");
|
|
442
|
+
function arrayToggleInPlace(array, el) {
|
|
443
|
+
const index = array.findIndex((e) => e === el);
|
|
444
|
+
if (index >= 0)
|
|
445
|
+
array.splice(index, 1);
|
|
446
|
+
else
|
|
447
|
+
array.push(el);
|
|
448
|
+
return array;
|
|
449
|
+
}
|
|
450
|
+
chunkC66X5FP6_cjs.__name(arrayToggleInPlace, "arrayToggleInPlace");
|
|
451
|
+
function arrayEmptyInPlace(array) {
|
|
452
|
+
array.splice(0, array.length);
|
|
453
|
+
return array;
|
|
454
|
+
}
|
|
455
|
+
chunkC66X5FP6_cjs.__name(arrayEmptyInPlace, "arrayEmptyInPlace");
|
|
456
|
+
function arraySorted(arr, cond = cmp) {
|
|
457
|
+
return Array.from(arr).sort(cond);
|
|
458
|
+
}
|
|
459
|
+
chunkC66X5FP6_cjs.__name(arraySorted, "arraySorted");
|
|
460
|
+
function arraySortedNumbers(arr) {
|
|
461
|
+
return arraySorted(arr, (l, r) => l - r);
|
|
462
|
+
}
|
|
463
|
+
chunkC66X5FP6_cjs.__name(arraySortedNumbers, "arraySortedNumbers");
|
|
464
|
+
function arrayIsEqual(array1, array2) {
|
|
465
|
+
return array1.length === array2.length && array1.every((value, index) => value === array2[index]);
|
|
466
|
+
}
|
|
467
|
+
chunkC66X5FP6_cjs.__name(arrayIsEqual, "arrayIsEqual");
|
|
468
|
+
function arrayShuffleInPlace(array) {
|
|
469
|
+
array.sort(() => getSecureRandomIfPossible() > 0.5 ? 1 : -1);
|
|
470
|
+
return array;
|
|
471
|
+
}
|
|
472
|
+
chunkC66X5FP6_cjs.__name(arrayShuffleInPlace, "arrayShuffleInPlace");
|
|
473
|
+
function arrayShuffle(array) {
|
|
474
|
+
return arrayShuffleInPlace(Array.from(array));
|
|
475
|
+
}
|
|
476
|
+
chunkC66X5FP6_cjs.__name(arrayShuffle, "arrayShuffle");
|
|
477
|
+
function arrayShuffleForce(array) {
|
|
478
|
+
while (array.length > 1) {
|
|
479
|
+
const copy = Array.from(array);
|
|
480
|
+
arrayShuffleInPlace(copy);
|
|
481
|
+
if (!arrayIsEqual(array, copy))
|
|
482
|
+
return copy;
|
|
483
|
+
}
|
|
484
|
+
return array;
|
|
485
|
+
}
|
|
486
|
+
chunkC66X5FP6_cjs.__name(arrayShuffleForce, "arrayShuffleForce");
|
|
487
|
+
function arrayRandomElement(array) {
|
|
488
|
+
return array[Math.floor(getSecureRandomIfPossible() * array.length)];
|
|
489
|
+
}
|
|
490
|
+
chunkC66X5FP6_cjs.__name(arrayRandomElement, "arrayRandomElement");
|
|
491
|
+
function arrayMax(...array) {
|
|
492
|
+
return arrayFlatten(array).reduce(
|
|
493
|
+
(acc, value) => acc != null ? value > acc ? value : acc : value,
|
|
494
|
+
void 0
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
chunkC66X5FP6_cjs.__name(arrayMax, "arrayMax");
|
|
498
|
+
function arrayMin(...array) {
|
|
499
|
+
return arrayFlatten(array).reduce(
|
|
500
|
+
(acc, value) => acc != null ? value < acc ? value : acc : value,
|
|
501
|
+
void 0
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
chunkC66X5FP6_cjs.__name(arrayMin, "arrayMin");
|
|
505
|
+
function arraySum(...array) {
|
|
506
|
+
return arrayFlatten(array).reduce((acc, value) => acc + value, 0);
|
|
507
|
+
}
|
|
508
|
+
chunkC66X5FP6_cjs.__name(arraySum, "arraySum");
|
|
509
|
+
function arrayAvg(...array) {
|
|
510
|
+
let flatArray = arrayFlatten(array);
|
|
511
|
+
return flatArray.reduce((acc, value) => acc + value, 0) / flatArray.length;
|
|
512
|
+
}
|
|
513
|
+
chunkC66X5FP6_cjs.__name(arrayAvg, "arrayAvg");
|
|
514
|
+
function arrayBatches(array, chunckLength) {
|
|
515
|
+
let chunks = [];
|
|
516
|
+
let i = 0;
|
|
517
|
+
const n = array.length;
|
|
518
|
+
while (i < n) {
|
|
519
|
+
chunks.push(array.slice(i, i += chunckLength));
|
|
520
|
+
}
|
|
521
|
+
return chunks;
|
|
522
|
+
}
|
|
523
|
+
chunkC66X5FP6_cjs.__name(arrayBatches, "arrayBatches");
|
|
524
|
+
function createArray(size2 = 0, item) {
|
|
525
|
+
if (size2 <= 0)
|
|
526
|
+
return [];
|
|
527
|
+
let arr = new Array(size2);
|
|
528
|
+
for (let i = 0; i < size2; i++) {
|
|
529
|
+
arr[i] = item instanceof Function ? item(i) : item;
|
|
530
|
+
}
|
|
531
|
+
return arr;
|
|
532
|
+
}
|
|
533
|
+
chunkC66X5FP6_cjs.__name(createArray, "createArray");
|
|
534
|
+
|
|
535
|
+
// src/common/data/basex.ts
|
|
536
|
+
var log2 = chunkC66X5FP6_cjs.Logger("zeed:basex");
|
|
537
|
+
var alphabets = {
|
|
538
|
+
"2": "01",
|
|
539
|
+
"8": "01234567",
|
|
540
|
+
"11": "0123456789a",
|
|
541
|
+
"16": "0123456789abcdef",
|
|
542
|
+
"32": "0123456789ABCDEFGHJKMNPQRSTVWXYZ",
|
|
543
|
+
"32-rfc": "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
|
|
544
|
+
"32-hex": "0123456789ABCDEFGHIJKLMNOPQRSTUV",
|
|
545
|
+
"32-zbase": "ybndrfg8ejkmcpqxot1uwisza345h769",
|
|
546
|
+
"36": "0123456789abcdefghijklmnopqrstuvwxyz",
|
|
547
|
+
"58": "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",
|
|
548
|
+
"62": "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
549
|
+
"64": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
550
|
+
"64-url": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
|
|
551
|
+
"66": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~",
|
|
552
|
+
"85": "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"
|
|
553
|
+
};
|
|
554
|
+
function useBase(alphaOrBase) {
|
|
555
|
+
let ALPHABET;
|
|
556
|
+
if (typeof alphaOrBase === "string") {
|
|
557
|
+
ALPHABET = alphaOrBase;
|
|
558
|
+
} else {
|
|
559
|
+
ALPHABET = alphabets[String(alphaOrBase)];
|
|
560
|
+
if (ALPHABET == null)
|
|
561
|
+
throw new Error(`Unknown base ${alphaOrBase}`);
|
|
562
|
+
}
|
|
563
|
+
if (ALPHABET.length >= 255)
|
|
564
|
+
throw new TypeError("Alphabet too long");
|
|
565
|
+
const BASE_MAP = new Uint8Array(256);
|
|
566
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
567
|
+
BASE_MAP[j] = 255;
|
|
568
|
+
}
|
|
569
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
570
|
+
const x = ALPHABET.charAt(i);
|
|
571
|
+
const xc = x.charCodeAt(0);
|
|
572
|
+
if (BASE_MAP[xc] !== 255)
|
|
573
|
+
throw new TypeError(x + " is ambiguous");
|
|
574
|
+
BASE_MAP[xc] = i;
|
|
575
|
+
}
|
|
576
|
+
const BASE = ALPHABET.length;
|
|
577
|
+
const LEADER = ALPHABET.charAt(0);
|
|
578
|
+
const FACTOR = Math.log(BASE) / Math.log(256);
|
|
579
|
+
const iFACTOR = Math.log(256) / Math.log(BASE);
|
|
580
|
+
function encode(source, padToLength = -1) {
|
|
581
|
+
let data = toUint8Array(source);
|
|
582
|
+
if (data.byteLength === 0)
|
|
583
|
+
return "";
|
|
584
|
+
let length = 0;
|
|
585
|
+
let pbegin = 0;
|
|
586
|
+
const pend = data.byteLength;
|
|
587
|
+
while (pbegin !== pend && data[pbegin] === 0)
|
|
588
|
+
pbegin++;
|
|
589
|
+
const size2 = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
590
|
+
const dataEncoded = new Uint8Array(size2);
|
|
591
|
+
while (pbegin !== pend) {
|
|
592
|
+
let carry = data[pbegin];
|
|
593
|
+
let i = 0;
|
|
594
|
+
for (let it1 = size2 - 1; (carry !== 0 || i < length) && it1 !== -1; it1--, i++) {
|
|
595
|
+
carry += 256 * dataEncoded[it1] >>> 0;
|
|
596
|
+
dataEncoded[it1] = carry % BASE >>> 0;
|
|
597
|
+
carry = carry / BASE >>> 0;
|
|
598
|
+
}
|
|
599
|
+
if (carry !== 0) {
|
|
600
|
+
log2.warn("Non-zero carry", data, padToLength, i, size2);
|
|
601
|
+
throw new Error("Non-zero carry");
|
|
602
|
+
}
|
|
603
|
+
length = i;
|
|
604
|
+
pbegin++;
|
|
605
|
+
}
|
|
606
|
+
let it2 = size2 - length;
|
|
607
|
+
while (it2 !== size2 && dataEncoded[it2] === 0) {
|
|
608
|
+
it2++;
|
|
609
|
+
}
|
|
610
|
+
let str = "";
|
|
611
|
+
for (; it2 < size2; ++it2)
|
|
612
|
+
str += ALPHABET.charAt(dataEncoded[it2]);
|
|
613
|
+
if (padToLength > 0) {
|
|
614
|
+
return str.padStart(padToLength, LEADER);
|
|
615
|
+
}
|
|
616
|
+
return str;
|
|
617
|
+
}
|
|
618
|
+
chunkC66X5FP6_cjs.__name(encode, "encode");
|
|
619
|
+
function decode(source, padToLength = -1) {
|
|
620
|
+
if (typeof source !== "string")
|
|
621
|
+
throw new TypeError("Expected String");
|
|
622
|
+
if (source.length === 0)
|
|
623
|
+
return new Uint8Array();
|
|
624
|
+
source = source.replace(/\s+/gi, "");
|
|
625
|
+
let psz = 0;
|
|
626
|
+
let length = 0;
|
|
627
|
+
while (source[psz] === LEADER) {
|
|
628
|
+
psz++;
|
|
629
|
+
}
|
|
630
|
+
const size2 = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
631
|
+
const dataDecoded = new Uint8Array(size2);
|
|
632
|
+
while (source[psz]) {
|
|
633
|
+
let carry = BASE_MAP[source.charCodeAt(psz)];
|
|
634
|
+
if (carry === 255)
|
|
635
|
+
throw new Error(`Unsupported character "${source[psz]}"`);
|
|
636
|
+
let i = 0;
|
|
637
|
+
for (let it3 = size2 - 1; (carry !== 0 || i < length) && it3 !== -1; it3--, i++) {
|
|
638
|
+
carry += BASE * dataDecoded[it3] >>> 0;
|
|
639
|
+
dataDecoded[it3] = carry % 256 >>> 0;
|
|
640
|
+
carry = carry / 256 >>> 0;
|
|
641
|
+
}
|
|
642
|
+
if (carry !== 0)
|
|
643
|
+
throw new Error("Non-zero carry");
|
|
644
|
+
length = i;
|
|
645
|
+
psz++;
|
|
646
|
+
}
|
|
647
|
+
let it4 = size2 - length;
|
|
648
|
+
while (it4 !== size2 && dataDecoded[it4] === 0) {
|
|
649
|
+
it4++;
|
|
650
|
+
}
|
|
651
|
+
if (padToLength > 0) {
|
|
652
|
+
return new Uint8Array([
|
|
653
|
+
...new Uint8Array(padToLength - dataDecoded.length + it4),
|
|
654
|
+
...dataDecoded.slice(it4)
|
|
655
|
+
]);
|
|
656
|
+
}
|
|
657
|
+
return dataDecoded.slice(it4);
|
|
658
|
+
}
|
|
659
|
+
chunkC66X5FP6_cjs.__name(decode, "decode");
|
|
660
|
+
return {
|
|
661
|
+
encode,
|
|
662
|
+
decode
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
chunkC66X5FP6_cjs.__name(useBase, "useBase");
|
|
666
|
+
var { encode: encodeBase16, decode: decodeBase16 } = useBase(16);
|
|
667
|
+
var { encode: encodeBase32, decode: decodeBase32 } = useBase(32);
|
|
668
|
+
var { encode: encodeBase58, decode: decodeBase58 } = useBase(58);
|
|
669
|
+
var { encode: encodeBase62, decode: decodeBase62 } = useBase(62);
|
|
670
|
+
var { encode: encodeBase64, decode: decodeBase64 } = useBase(62);
|
|
671
|
+
|
|
672
|
+
// src/common/data/camelcase.ts
|
|
673
|
+
var toCamelCase = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((s) => {
|
|
674
|
+
if (s.length > 0) {
|
|
675
|
+
if (/^[A-Z0-9_\-\ ]*$/g.test(s)) {
|
|
676
|
+
s = s.toLowerCase();
|
|
677
|
+
}
|
|
678
|
+
s = s.replace(/^[-_\ ]+/gi, "").replace(/[-_\ ]+$/gi, "").replace(/[-_\ ]+([a-z0-9])/gi, ($0, $1) => $1.toUpperCase());
|
|
679
|
+
s = s[0].toLowerCase() + s.substring(1);
|
|
680
|
+
}
|
|
681
|
+
return s;
|
|
682
|
+
}, "toCamelCase");
|
|
683
|
+
function toCapitalize(s) {
|
|
684
|
+
return s.charAt(0).toUpperCase() + s.toLowerCase().slice(1);
|
|
685
|
+
}
|
|
686
|
+
chunkC66X5FP6_cjs.__name(toCapitalize, "toCapitalize");
|
|
687
|
+
function toCapitalizeWords(s) {
|
|
688
|
+
return s.replace(/\w\S*/g, toCapitalize);
|
|
689
|
+
}
|
|
690
|
+
chunkC66X5FP6_cjs.__name(toCapitalizeWords, "toCapitalizeWords");
|
|
691
|
+
function fromCamelCase(str, separator2 = "-") {
|
|
692
|
+
separator2 = typeof separator2 === "undefined" ? "_" : separator2;
|
|
693
|
+
return str.replace(/([a-z\d])([A-Z])/g, "$1" + separator2 + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + separator2 + "$2").toLowerCase();
|
|
694
|
+
}
|
|
695
|
+
chunkC66X5FP6_cjs.__name(fromCamelCase, "fromCamelCase");
|
|
696
|
+
|
|
697
|
+
// src/common/data/json.ts
|
|
698
|
+
function serializer(replacer, cycleReplacer) {
|
|
699
|
+
var stack = [], keys = [];
|
|
700
|
+
if (cycleReplacer == null)
|
|
701
|
+
cycleReplacer = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(function(key, value) {
|
|
702
|
+
if (stack[0] === value)
|
|
703
|
+
return "[Circular ~]";
|
|
704
|
+
return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
|
|
705
|
+
}, "cycleReplacer");
|
|
706
|
+
return function(key, value) {
|
|
707
|
+
if (stack.length > 0) {
|
|
708
|
+
var thisPos = stack.indexOf(this);
|
|
709
|
+
~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
|
|
710
|
+
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
|
|
711
|
+
if (~stack.indexOf(value))
|
|
712
|
+
value = cycleReplacer == null ? void 0 : cycleReplacer.call(this, key, value);
|
|
713
|
+
} else
|
|
714
|
+
stack.push(value);
|
|
715
|
+
return replacer == null ? value : replacer.call(this, key, value);
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
chunkC66X5FP6_cjs.__name(serializer, "serializer");
|
|
719
|
+
function jsonStringify(obj, replacer, spaces, cycleReplacer) {
|
|
720
|
+
return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces);
|
|
721
|
+
}
|
|
722
|
+
chunkC66X5FP6_cjs.__name(jsonStringify, "jsonStringify");
|
|
723
|
+
|
|
724
|
+
// src/common/data/convert.ts
|
|
725
|
+
var TRUE_VALUES_LIST = ["1", "true", "yes", "y", "on"];
|
|
726
|
+
function stringToBoolean(value, defaultValue = false) {
|
|
727
|
+
if (value == null || typeof value !== "string")
|
|
728
|
+
return defaultValue;
|
|
729
|
+
return TRUE_VALUES_LIST.includes(String(value).trim().toLowerCase());
|
|
730
|
+
}
|
|
731
|
+
chunkC66X5FP6_cjs.__name(stringToBoolean, "stringToBoolean");
|
|
732
|
+
function stringToInteger(value, defaultValue = 0) {
|
|
733
|
+
if (value == null || typeof value !== "string")
|
|
734
|
+
return defaultValue;
|
|
735
|
+
return _nullishCoalesce(parseInt(value.trim(), 10), () => ( defaultValue));
|
|
736
|
+
}
|
|
737
|
+
chunkC66X5FP6_cjs.__name(stringToInteger, "stringToInteger");
|
|
738
|
+
function stringToFloat(value, defaultValue = 0) {
|
|
739
|
+
if (value == null || typeof value !== "string")
|
|
740
|
+
return defaultValue;
|
|
741
|
+
return _nullishCoalesce(parseFloat(value.trim()), () => ( defaultValue));
|
|
742
|
+
}
|
|
743
|
+
chunkC66X5FP6_cjs.__name(stringToFloat, "stringToFloat");
|
|
744
|
+
function valueToBoolean(value, defaultValue = false) {
|
|
745
|
+
if (value == null)
|
|
746
|
+
return defaultValue;
|
|
747
|
+
if (typeof value === "boolean")
|
|
748
|
+
return value;
|
|
749
|
+
if (typeof value === "number")
|
|
750
|
+
return value !== 0;
|
|
751
|
+
return TRUE_VALUES_LIST.includes(String(value).trim().toLowerCase());
|
|
752
|
+
}
|
|
753
|
+
chunkC66X5FP6_cjs.__name(valueToBoolean, "valueToBoolean");
|
|
754
|
+
function valueToInteger(value, defaultValue = 0) {
|
|
755
|
+
if (value == null)
|
|
756
|
+
return defaultValue;
|
|
757
|
+
if (typeof value === "boolean")
|
|
758
|
+
return value ? 1 : 0;
|
|
759
|
+
if (typeof value === "number")
|
|
760
|
+
return Math.floor(value);
|
|
761
|
+
return _nullishCoalesce(parseInt(String(value).trim(), 10), () => ( defaultValue));
|
|
762
|
+
}
|
|
763
|
+
chunkC66X5FP6_cjs.__name(valueToInteger, "valueToInteger");
|
|
764
|
+
function valueToFloat(value, defaultValue = 0) {
|
|
765
|
+
if (value == null)
|
|
766
|
+
return defaultValue;
|
|
767
|
+
if (typeof value === "boolean")
|
|
768
|
+
return value ? 1 : 0;
|
|
769
|
+
if (typeof value === "number")
|
|
770
|
+
return Math.floor(value);
|
|
771
|
+
return _nullishCoalesce(parseFloat(String(value).trim()), () => ( defaultValue));
|
|
772
|
+
}
|
|
773
|
+
chunkC66X5FP6_cjs.__name(valueToFloat, "valueToFloat");
|
|
774
|
+
function valueToString(value, defaultValue = "") {
|
|
775
|
+
if (value == null)
|
|
776
|
+
return defaultValue;
|
|
777
|
+
return _nullishCoalesce(String(value), () => ( defaultValue));
|
|
778
|
+
}
|
|
779
|
+
chunkC66X5FP6_cjs.__name(valueToString, "valueToString");
|
|
780
|
+
var toFloat = valueToFloat;
|
|
781
|
+
var toInt = valueToInteger;
|
|
782
|
+
var toString = valueToString;
|
|
783
|
+
var toBool = valueToBoolean;
|
|
784
|
+
function formatMessages(messages2, opt = {}) {
|
|
785
|
+
const { trace = true, pretty = true } = opt;
|
|
786
|
+
return messages2.map((obj) => {
|
|
787
|
+
if (obj && typeof obj === "object") {
|
|
788
|
+
if (pretty && (obj instanceof Uint8Array || obj instanceof ArrayBuffer)) {
|
|
789
|
+
return "\n" + Uint8ArrayToHexDump(obj) + "\n";
|
|
790
|
+
}
|
|
791
|
+
if (obj instanceof Error) {
|
|
792
|
+
if (!trace) {
|
|
793
|
+
return `${obj.name || "Error"}: ${obj.message}`;
|
|
794
|
+
}
|
|
795
|
+
return `${obj.name || "Error"}: ${obj.message}
|
|
796
|
+
${obj.stack}`;
|
|
797
|
+
}
|
|
798
|
+
return pretty ? jsonStringify(obj, null, 2) : jsonStringify(obj);
|
|
799
|
+
}
|
|
800
|
+
return String(obj);
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
chunkC66X5FP6_cjs.__name(formatMessages, "formatMessages");
|
|
804
|
+
function renderMessages(messages2, opt = {}) {
|
|
805
|
+
return formatMessages(messages2, opt).join(" ");
|
|
806
|
+
}
|
|
807
|
+
chunkC66X5FP6_cjs.__name(renderMessages, "renderMessages");
|
|
808
|
+
function fixBrokenUth8String(brokenString) {
|
|
809
|
+
try {
|
|
810
|
+
return decodeURIComponent(escape(brokenString));
|
|
811
|
+
} catch (e) {
|
|
812
|
+
}
|
|
813
|
+
return brokenString;
|
|
814
|
+
}
|
|
815
|
+
chunkC66X5FP6_cjs.__name(fixBrokenUth8String, "fixBrokenUth8String");
|
|
816
|
+
|
|
817
|
+
// src/common/data/currency.ts
|
|
818
|
+
var defaults = {
|
|
819
|
+
symbol: "$",
|
|
820
|
+
separator: ",",
|
|
821
|
+
decimal: ".",
|
|
822
|
+
errorOnInvalid: false,
|
|
823
|
+
precision: 2,
|
|
824
|
+
pattern: "!#",
|
|
825
|
+
negativePattern: "-!#",
|
|
826
|
+
format,
|
|
827
|
+
fromCents: false
|
|
828
|
+
};
|
|
829
|
+
var round = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((v) => Math.round(v), "round");
|
|
830
|
+
var pow = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((p) => Math.pow(10, p), "pow");
|
|
831
|
+
var rounding = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value, increment) => round(value / increment) * increment, "rounding");
|
|
832
|
+
var groupRegex = /(\d)(?=(\d{3})+\b)/g;
|
|
833
|
+
var vedicRegex = /(\d)(?=(\d\d)+\d\b)/g;
|
|
834
|
+
function currency(value, opts = {}) {
|
|
835
|
+
return new Currency(value, opts);
|
|
836
|
+
}
|
|
837
|
+
chunkC66X5FP6_cjs.__name(currency, "currency");
|
|
838
|
+
var _Currency = class {
|
|
839
|
+
constructor(value, opts = {}) {
|
|
840
|
+
let settings = Object.assign({}, defaults, opts);
|
|
841
|
+
let precision = pow(_nullishCoalesce(settings.precision, () => ( 2)));
|
|
842
|
+
let v = parse(value, settings);
|
|
843
|
+
this.intValue = v;
|
|
844
|
+
this.value = v / precision;
|
|
845
|
+
settings.increment = settings.increment || 1 / precision;
|
|
846
|
+
if (settings.useVedic) {
|
|
847
|
+
settings.groups = vedicRegex;
|
|
848
|
+
} else {
|
|
849
|
+
settings.groups = groupRegex;
|
|
850
|
+
}
|
|
851
|
+
this._settings = settings;
|
|
852
|
+
this._precision = precision;
|
|
853
|
+
}
|
|
854
|
+
add(number) {
|
|
855
|
+
let { intValue, _settings, _precision } = this;
|
|
856
|
+
return currency(
|
|
857
|
+
(intValue += parse(number, _settings)) / (_settings.fromCents ? 1 : _precision),
|
|
858
|
+
_settings
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
subtract(number) {
|
|
862
|
+
let { intValue, _settings, _precision } = this;
|
|
863
|
+
return currency(
|
|
864
|
+
(intValue -= parse(number, _settings)) / (_settings.fromCents ? 1 : _precision),
|
|
865
|
+
_settings
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
multiply(number) {
|
|
869
|
+
let { intValue, _settings, _precision } = this;
|
|
870
|
+
return currency(
|
|
871
|
+
(intValue *= number) / (_settings.fromCents ? 1 : pow(_precision)),
|
|
872
|
+
_settings
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
divide(number) {
|
|
876
|
+
let { intValue, _settings } = this;
|
|
877
|
+
return currency(intValue /= parse(number, _settings, false), _settings);
|
|
878
|
+
}
|
|
879
|
+
distribute(count) {
|
|
880
|
+
let { intValue, _precision, _settings } = this, distribution = [], split = Math[intValue >= 0 ? "floor" : "ceil"](intValue / count), pennies = Math.abs(intValue - split * count), precision = _settings.fromCents ? 1 : _precision;
|
|
881
|
+
for (; count !== 0; count--) {
|
|
882
|
+
let item = currency(split / precision, _settings);
|
|
883
|
+
pennies-- > 0 && (item = item[intValue >= 0 ? "add" : "subtract"](1 / precision));
|
|
884
|
+
distribution.push(item);
|
|
885
|
+
}
|
|
886
|
+
return distribution;
|
|
887
|
+
}
|
|
888
|
+
dollars() {
|
|
889
|
+
return ~~this.value;
|
|
890
|
+
}
|
|
891
|
+
cents() {
|
|
892
|
+
let { intValue, _precision } = this;
|
|
893
|
+
return ~~(intValue % _precision);
|
|
894
|
+
}
|
|
895
|
+
format(options) {
|
|
896
|
+
let { _settings } = this;
|
|
897
|
+
if (typeof options === "function") {
|
|
898
|
+
return options(this, _settings);
|
|
899
|
+
}
|
|
900
|
+
return _settings.format(this, Object.assign({}, _settings, options));
|
|
901
|
+
}
|
|
902
|
+
toString() {
|
|
903
|
+
let { intValue, _precision, _settings } = this;
|
|
904
|
+
return rounding(intValue / _precision, _settings.increment).toFixed(
|
|
905
|
+
_settings.precision
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
toJSON() {
|
|
909
|
+
return this.value;
|
|
910
|
+
}
|
|
911
|
+
static sum(...array) {
|
|
912
|
+
return arrayFlatten(array).reduce(
|
|
913
|
+
(acc, value) => currency(acc).add(value),
|
|
914
|
+
this.zero
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
static avg(...array) {
|
|
918
|
+
let arr = arrayFlatten(array);
|
|
919
|
+
return arr.reduce((acc, value) => currency(acc).add(value), this.zero).divide(arr.length);
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
var Currency = _Currency;
|
|
923
|
+
chunkC66X5FP6_cjs.__name(Currency, "Currency");
|
|
924
|
+
Currency.zero = new _Currency(0);
|
|
925
|
+
Currency.one = new _Currency(1);
|
|
926
|
+
Currency.hundred = new _Currency(100);
|
|
927
|
+
function parse(value, opts, useRounding = true) {
|
|
928
|
+
let v = 0, { decimal: decimal2, errorOnInvalid, precision: decimals, fromCents } = opts, precision = pow(decimals), isNumber = typeof value === "number";
|
|
929
|
+
if (value instanceof Currency && fromCents) {
|
|
930
|
+
return value.intValue;
|
|
931
|
+
}
|
|
932
|
+
if (isNumber || value instanceof Currency) {
|
|
933
|
+
v = value instanceof Currency ? value.value : value;
|
|
934
|
+
} else if (typeof value === "string") {
|
|
935
|
+
let regex = new RegExp("[^-\\d" + decimal2 + "]", "g"), decimalString = new RegExp("\\" + decimal2, "g");
|
|
936
|
+
v = value.replace(/\((.*)\)/, "-$1").replace(regex, "").replace(decimalString, ".");
|
|
937
|
+
v = v || 0;
|
|
938
|
+
} else {
|
|
939
|
+
if (errorOnInvalid) {
|
|
940
|
+
throw Error("Invalid Input");
|
|
941
|
+
}
|
|
942
|
+
v = 0;
|
|
943
|
+
}
|
|
944
|
+
if (!fromCents) {
|
|
945
|
+
v *= precision;
|
|
946
|
+
v = v.toFixed(4);
|
|
947
|
+
}
|
|
948
|
+
return useRounding ? round(v) : v;
|
|
949
|
+
}
|
|
950
|
+
chunkC66X5FP6_cjs.__name(parse, "parse");
|
|
951
|
+
function format(currency2, settings) {
|
|
952
|
+
let { pattern: pattern2, negativePattern, symbol, separator: separator2, decimal: decimal2, groups } = settings, split = ("" + currency2).replace(/^-/, "").split("."), dollars = split[0], cents = split[1];
|
|
953
|
+
return (currency2.value >= 0 ? pattern2 : negativePattern).replace("!", symbol).replace(
|
|
954
|
+
"#",
|
|
955
|
+
dollars.replace(groups, "$1" + separator2) + (cents ? decimal2 + cents : "")
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
chunkC66X5FP6_cjs.__name(format, "format");
|
|
959
|
+
|
|
960
|
+
// src/common/data/day.ts
|
|
961
|
+
var DAY_MS = 864e5;
|
|
962
|
+
function dayYear(day2) {
|
|
963
|
+
return Math.floor(day2 / 1e4);
|
|
964
|
+
}
|
|
965
|
+
chunkC66X5FP6_cjs.__name(dayYear, "dayYear");
|
|
966
|
+
function dayMonth(day2) {
|
|
967
|
+
return Math.floor(day2 / 100 % 100);
|
|
968
|
+
}
|
|
969
|
+
chunkC66X5FP6_cjs.__name(dayMonth, "dayMonth");
|
|
970
|
+
function dayDay(day2) {
|
|
971
|
+
return Math.floor(day2 % 100);
|
|
972
|
+
}
|
|
973
|
+
chunkC66X5FP6_cjs.__name(dayDay, "dayDay");
|
|
974
|
+
function dayToParts(day2) {
|
|
975
|
+
return [dayYear(day2), dayMonth(day2), dayDay(day2)];
|
|
976
|
+
}
|
|
977
|
+
chunkC66X5FP6_cjs.__name(dayToParts, "dayToParts");
|
|
978
|
+
function dayToDate(day2, gmt = false) {
|
|
979
|
+
return gmt ? new Date(`${dayToString(day2)}T00:00:00.000Z`) : new Date(
|
|
980
|
+
day2 / 1e4,
|
|
981
|
+
day2 / 100 % 100 - 1,
|
|
982
|
+
day2 % 100
|
|
983
|
+
);
|
|
984
|
+
}
|
|
985
|
+
chunkC66X5FP6_cjs.__name(dayToDate, "dayToDate");
|
|
986
|
+
function dayFromToday() {
|
|
987
|
+
return dayFromDate(new Date());
|
|
988
|
+
}
|
|
989
|
+
chunkC66X5FP6_cjs.__name(dayFromToday, "dayFromToday");
|
|
990
|
+
function dayFromAny(value, gmt = false) {
|
|
991
|
+
if (typeof value === "number") {
|
|
992
|
+
if (value < 100)
|
|
993
|
+
return;
|
|
994
|
+
return value;
|
|
995
|
+
} else if (typeof value === "string") {
|
|
996
|
+
return dayFromString(value);
|
|
997
|
+
} else if (Array.isArray(value) && value.length === 3) {
|
|
998
|
+
const [year, month, day2] = value;
|
|
999
|
+
return dayFromParts(year, month, day2);
|
|
1000
|
+
} else if (value instanceof Date) {
|
|
1001
|
+
return dayFromDate(value, gmt);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
chunkC66X5FP6_cjs.__name(dayFromAny, "dayFromAny");
|
|
1005
|
+
function dayToDateGMT(day2) {
|
|
1006
|
+
return dayToDate(day2, true);
|
|
1007
|
+
}
|
|
1008
|
+
chunkC66X5FP6_cjs.__name(dayToDateGMT, "dayToDateGMT");
|
|
1009
|
+
function dayFromDate(date, gmt = false) {
|
|
1010
|
+
return gmt ? dayFromString(date.toISOString()) : date.getFullYear() * 1e4 + (date.getMonth() + 1) * 100 + date.getDate();
|
|
1011
|
+
}
|
|
1012
|
+
chunkC66X5FP6_cjs.__name(dayFromDate, "dayFromDate");
|
|
1013
|
+
function dayFromDateGMT(date) {
|
|
1014
|
+
return dayFromDate(date, true);
|
|
1015
|
+
}
|
|
1016
|
+
chunkC66X5FP6_cjs.__name(dayFromDateGMT, "dayFromDateGMT");
|
|
1017
|
+
function dayToTimestamp(day2, gmt = true) {
|
|
1018
|
+
return dayToDate(day2, gmt).getTime();
|
|
1019
|
+
}
|
|
1020
|
+
chunkC66X5FP6_cjs.__name(dayToTimestamp, "dayToTimestamp");
|
|
1021
|
+
function dayFromTimestamp(ms, gmt = true) {
|
|
1022
|
+
return dayFromDate(new Date(ms), gmt);
|
|
1023
|
+
}
|
|
1024
|
+
chunkC66X5FP6_cjs.__name(dayFromTimestamp, "dayFromTimestamp");
|
|
1025
|
+
function dayToString(day2, sep = "-") {
|
|
1026
|
+
let baseString = String(day2);
|
|
1027
|
+
return baseString.slice(0, 4) + sep + baseString.slice(4, 6) + sep + baseString.slice(6, 8);
|
|
1028
|
+
}
|
|
1029
|
+
chunkC66X5FP6_cjs.__name(dayToString, "dayToString");
|
|
1030
|
+
function dayFromParts(year, month = 1, day2 = 1) {
|
|
1031
|
+
if (month < 1 || month > 12 || day2 < 1 || day2 > 31)
|
|
1032
|
+
return;
|
|
1033
|
+
return year * 1e4 + month * 100 + day2;
|
|
1034
|
+
}
|
|
1035
|
+
chunkC66X5FP6_cjs.__name(dayFromParts, "dayFromParts");
|
|
1036
|
+
function dayFromString(value) {
|
|
1037
|
+
const string = String(value).replace(/[^0-9]/g, "").slice(0, 8);
|
|
1038
|
+
if (string.length === 8)
|
|
1039
|
+
return +string;
|
|
1040
|
+
}
|
|
1041
|
+
chunkC66X5FP6_cjs.__name(dayFromString, "dayFromString");
|
|
1042
|
+
function dayMonthStart(day2, offset = 0) {
|
|
1043
|
+
let year = dayYear(day2);
|
|
1044
|
+
let month = dayMonth(day2);
|
|
1045
|
+
if (offset !== 0) {
|
|
1046
|
+
month += offset;
|
|
1047
|
+
year += Math.floor((month - 1) / 12);
|
|
1048
|
+
month = Math.floor((month - 1) % 12) + 1;
|
|
1049
|
+
if (month === 0)
|
|
1050
|
+
month = 12;
|
|
1051
|
+
}
|
|
1052
|
+
return dayFromParts(year, month, 1);
|
|
1053
|
+
}
|
|
1054
|
+
chunkC66X5FP6_cjs.__name(dayMonthStart, "dayMonthStart");
|
|
1055
|
+
function dayYearStart(day2, offset = 0) {
|
|
1056
|
+
let year = dayYear(day2);
|
|
1057
|
+
return dayFromParts(year + offset, 1, 1);
|
|
1058
|
+
}
|
|
1059
|
+
chunkC66X5FP6_cjs.__name(dayYearStart, "dayYearStart");
|
|
1060
|
+
function dayOffset(day2, offset) {
|
|
1061
|
+
return dayFromTimestamp(dayToTimestamp(day2) + offset * DAY_MS);
|
|
1062
|
+
}
|
|
1063
|
+
chunkC66X5FP6_cjs.__name(dayOffset, "dayOffset");
|
|
1064
|
+
function dayDiff(left, right) {
|
|
1065
|
+
return Math.round((dayToTimestamp(right) - dayToTimestamp(left)) / DAY_MS);
|
|
1066
|
+
}
|
|
1067
|
+
chunkC66X5FP6_cjs.__name(dayDiff, "dayDiff");
|
|
1068
|
+
|
|
1069
|
+
// src/common/exec/promise.ts
|
|
1070
|
+
var { warn } = chunkC66X5FP6_cjs.Logger("zeed:promise");
|
|
1071
|
+
function createPromise() {
|
|
1072
|
+
let resolve, reject;
|
|
1073
|
+
let promise = new Promise((_resolve, _reject) => {
|
|
1074
|
+
resolve = _resolve;
|
|
1075
|
+
reject = _reject;
|
|
1076
|
+
});
|
|
1077
|
+
return [promise, resolve, reject];
|
|
1078
|
+
}
|
|
1079
|
+
chunkC66X5FP6_cjs.__name(createPromise, "createPromise");
|
|
1080
|
+
async function sleep(milliSeconds) {
|
|
1081
|
+
return new Promise((resolve) => setTimeout(resolve, milliSeconds));
|
|
1082
|
+
}
|
|
1083
|
+
chunkC66X5FP6_cjs.__name(sleep, "sleep");
|
|
1084
|
+
async function immediate() {
|
|
1085
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
1086
|
+
}
|
|
1087
|
+
chunkC66X5FP6_cjs.__name(immediate, "immediate");
|
|
1088
|
+
var timeoutReached = Symbol("timeout");
|
|
1089
|
+
async function timeout(promise, milliSeconds, timeoutValue = timeoutReached) {
|
|
1090
|
+
return new Promise(async (resolve, reject) => {
|
|
1091
|
+
let done = false;
|
|
1092
|
+
const timeout2 = setTimeout(() => {
|
|
1093
|
+
done = true;
|
|
1094
|
+
resolve(timeoutValue);
|
|
1095
|
+
}, milliSeconds);
|
|
1096
|
+
try {
|
|
1097
|
+
let result = await promise;
|
|
1098
|
+
clearTimeout(timeout2);
|
|
1099
|
+
if (!done)
|
|
1100
|
+
resolve(result);
|
|
1101
|
+
} catch (err) {
|
|
1102
|
+
clearTimeout(timeout2);
|
|
1103
|
+
if (!done)
|
|
1104
|
+
reject(err);
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
chunkC66X5FP6_cjs.__name(timeout, "timeout");
|
|
1109
|
+
var timoutError = new Error("Timeout reached");
|
|
1110
|
+
function isTimeout(value) {
|
|
1111
|
+
return value === timeoutReached || value === timoutError;
|
|
1112
|
+
}
|
|
1113
|
+
chunkC66X5FP6_cjs.__name(isTimeout, "isTimeout");
|
|
1114
|
+
async function tryTimeout(promise, milliSeconds) {
|
|
1115
|
+
if (milliSeconds <= 0) {
|
|
1116
|
+
return await promise;
|
|
1117
|
+
}
|
|
1118
|
+
return new Promise(async (resolve, reject) => {
|
|
1119
|
+
let done = false;
|
|
1120
|
+
const timeout2 = setTimeout(() => {
|
|
1121
|
+
done = true;
|
|
1122
|
+
reject(timoutError);
|
|
1123
|
+
}, milliSeconds);
|
|
1124
|
+
try {
|
|
1125
|
+
let result = await promise;
|
|
1126
|
+
clearTimeout(timeout2);
|
|
1127
|
+
if (!done)
|
|
1128
|
+
resolve(result);
|
|
1129
|
+
} catch (err) {
|
|
1130
|
+
clearTimeout(timeout2);
|
|
1131
|
+
if (!done)
|
|
1132
|
+
reject(err);
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
chunkC66X5FP6_cjs.__name(tryTimeout, "tryTimeout");
|
|
1137
|
+
function waitOn(obj, event, timeoutMS = 1e3) {
|
|
1138
|
+
return new Promise((resolve, reject) => {
|
|
1139
|
+
let fn = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => {
|
|
1140
|
+
if (timer) {
|
|
1141
|
+
clearTimeout(timer);
|
|
1142
|
+
done();
|
|
1143
|
+
resolve(value);
|
|
1144
|
+
}
|
|
1145
|
+
}, "fn");
|
|
1146
|
+
let done = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(() => {
|
|
1147
|
+
timer = null;
|
|
1148
|
+
if (obj.off) {
|
|
1149
|
+
obj.off(event, fn);
|
|
1150
|
+
} else if (obj.removeEventListener) {
|
|
1151
|
+
obj.removeEventListener(event, fn);
|
|
1152
|
+
} else {
|
|
1153
|
+
warn("No remove listener method found for", obj, event);
|
|
1154
|
+
}
|
|
1155
|
+
}, "done");
|
|
1156
|
+
let timer = setTimeout(() => {
|
|
1157
|
+
done();
|
|
1158
|
+
reject(new Error(`Did not response in time`));
|
|
1159
|
+
}, timeoutMS);
|
|
1160
|
+
if (obj.on) {
|
|
1161
|
+
obj.on(event, fn);
|
|
1162
|
+
} else if (obj.addEventListener) {
|
|
1163
|
+
obj.addEventListener(event, fn);
|
|
1164
|
+
} else {
|
|
1165
|
+
warn("No listener method found for", obj);
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
chunkC66X5FP6_cjs.__name(waitOn, "waitOn");
|
|
1170
|
+
function isPromise(value) {
|
|
1171
|
+
return Boolean(
|
|
1172
|
+
value && (value instanceof Promise || typeof value.then === "function")
|
|
1173
|
+
);
|
|
1174
|
+
}
|
|
1175
|
+
chunkC66X5FP6_cjs.__name(isPromise, "isPromise");
|
|
1176
|
+
function promisify(value) {
|
|
1177
|
+
return Promise.resolve(value);
|
|
1178
|
+
}
|
|
1179
|
+
chunkC66X5FP6_cjs.__name(promisify, "promisify");
|
|
1180
|
+
|
|
1181
|
+
// src/common/data/day-legacy.ts
|
|
1182
|
+
var Day = class {
|
|
1183
|
+
get value() {
|
|
1184
|
+
return this.days;
|
|
1185
|
+
}
|
|
1186
|
+
constructor(days) {
|
|
1187
|
+
var _a;
|
|
1188
|
+
if (typeof days === "number") {
|
|
1189
|
+
this.days = days;
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
if (days != null) {
|
|
1193
|
+
days = (_a = Day.from(days)) == null ? void 0 : _a.days;
|
|
1194
|
+
}
|
|
1195
|
+
if (days == null) {
|
|
1196
|
+
const date = new Date();
|
|
1197
|
+
this.days = date.getFullYear() * 1e4 + (date.getMonth() + 1) * 100 + date.getDate();
|
|
1198
|
+
} else {
|
|
1199
|
+
this.days = days;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
static fromNumber(n) {
|
|
1203
|
+
return new Day(n);
|
|
1204
|
+
}
|
|
1205
|
+
static fromString(dateString) {
|
|
1206
|
+
return Day.from(+dateString.replace(/[^0-9]/g, "").slice(0, 8));
|
|
1207
|
+
}
|
|
1208
|
+
static fromDate(date, gmt = false) {
|
|
1209
|
+
return gmt ? Day.fromString(date.toISOString().substr(0, 10)) : Day.from(
|
|
1210
|
+
date.getFullYear() * 1e4 + (date.getMonth() + 1) * 100 + date.getDate()
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
static fromDateGMT(date) {
|
|
1214
|
+
return Day.fromDate(date, true);
|
|
1215
|
+
}
|
|
1216
|
+
static from(value, gmt = false) {
|
|
1217
|
+
if (typeof value === "number") {
|
|
1218
|
+
if (value < 100)
|
|
1219
|
+
return;
|
|
1220
|
+
return new Day(value);
|
|
1221
|
+
} else if (typeof value === "string") {
|
|
1222
|
+
return Day.fromString(value);
|
|
1223
|
+
} else if (Array.isArray(value) && value.length === 3) {
|
|
1224
|
+
const [year, month = 1, day2 = 1] = value;
|
|
1225
|
+
if (month < 1 || month > 12 || day2 < 1 || day2 > 31)
|
|
1226
|
+
return;
|
|
1227
|
+
return new Day(year * 1e4 + month * 100 + day2);
|
|
1228
|
+
} else if (value instanceof Date) {
|
|
1229
|
+
return Day.fromDate(value, gmt);
|
|
1230
|
+
} else if (value instanceof Day) {
|
|
1231
|
+
return value;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
toNumber() {
|
|
1235
|
+
return this.days;
|
|
1236
|
+
}
|
|
1237
|
+
toJson() {
|
|
1238
|
+
return this.days;
|
|
1239
|
+
}
|
|
1240
|
+
toString(sep = "-") {
|
|
1241
|
+
let baseString = String(this.days);
|
|
1242
|
+
return baseString.slice(0, 4) + sep + baseString.slice(4, 6) + sep + baseString.slice(6, 8);
|
|
1243
|
+
}
|
|
1244
|
+
toDate(gmt = false) {
|
|
1245
|
+
return gmt ? new Date(`${this.toString()}T00:00:00.000Z`) : new Date(
|
|
1246
|
+
this.days / 1e4,
|
|
1247
|
+
this.days / 100 % 100 - 1,
|
|
1248
|
+
this.days % 100
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1251
|
+
toDateGMT() {
|
|
1252
|
+
return this.toDate(true);
|
|
1253
|
+
}
|
|
1254
|
+
get year() {
|
|
1255
|
+
return Math.floor(this.days / 1e4);
|
|
1256
|
+
}
|
|
1257
|
+
get month() {
|
|
1258
|
+
return Math.floor(this.days / 100 % 100);
|
|
1259
|
+
}
|
|
1260
|
+
get day() {
|
|
1261
|
+
return Math.floor(this.days % 100);
|
|
1262
|
+
}
|
|
1263
|
+
dayOffset(offset) {
|
|
1264
|
+
return Day.fromDateGMT(
|
|
1265
|
+
new Date(this.toDateGMT().getTime() + offset * DAY_MS)
|
|
1266
|
+
);
|
|
1267
|
+
}
|
|
1268
|
+
monthStart() {
|
|
1269
|
+
return Day.from([this.year, this.month, 1]);
|
|
1270
|
+
}
|
|
1271
|
+
yearStart() {
|
|
1272
|
+
return Day.from([this.year, 1, 1]);
|
|
1273
|
+
}
|
|
1274
|
+
monthOffset(offset) {
|
|
1275
|
+
let m = this.month + offset;
|
|
1276
|
+
let mm = Math.floor((m - 1) % 12) + 1;
|
|
1277
|
+
if (mm === 0)
|
|
1278
|
+
mm = 12;
|
|
1279
|
+
let yy = Math.floor((m - 1) / 12);
|
|
1280
|
+
return Day.from([this.year + yy, mm, this.day]);
|
|
1281
|
+
}
|
|
1282
|
+
daysUntil(otherDay) {
|
|
1283
|
+
var _a;
|
|
1284
|
+
return Math.round(
|
|
1285
|
+
(((_a = new Day(otherDay)) == null ? void 0 : _a.toDateGMT().getTime()) - this.toDateGMT().getTime()) / DAY_MS
|
|
1286
|
+
);
|
|
1287
|
+
}
|
|
1288
|
+
yesterday() {
|
|
1289
|
+
return this.dayOffset(-1);
|
|
1290
|
+
}
|
|
1291
|
+
tomorrow() {
|
|
1292
|
+
return this.dayOffset(1);
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
chunkC66X5FP6_cjs.__name(Day, "Day");
|
|
1296
|
+
async function forEachDay(from, to, handler) {
|
|
1297
|
+
let start = Day.from(from);
|
|
1298
|
+
let end = Day.from(to);
|
|
1299
|
+
while (start && end && (start == null ? void 0 : start.days) <= (end == null ? void 0 : end.days)) {
|
|
1300
|
+
let result = handler(start);
|
|
1301
|
+
if (isPromise(result)) {
|
|
1302
|
+
await result;
|
|
1303
|
+
}
|
|
1304
|
+
start = start.dayOffset(1);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
chunkC66X5FP6_cjs.__name(forEachDay, "forEachDay");
|
|
1308
|
+
function today() {
|
|
1309
|
+
return new Day();
|
|
1310
|
+
}
|
|
1311
|
+
chunkC66X5FP6_cjs.__name(today, "today");
|
|
1312
|
+
function day(days) {
|
|
1313
|
+
return new Day(days);
|
|
1314
|
+
}
|
|
1315
|
+
chunkC66X5FP6_cjs.__name(day, "day");
|
|
1316
|
+
function dateStringToDays(dateString) {
|
|
1317
|
+
return Day.fromDate(new Date(dateString)).days;
|
|
1318
|
+
}
|
|
1319
|
+
chunkC66X5FP6_cjs.__name(dateStringToDays, "dateStringToDays");
|
|
1320
|
+
|
|
1321
|
+
// src/common/data/decimal.ts
|
|
1322
|
+
function decimal(value, decimalPlaces = 2) {
|
|
1323
|
+
return +(+value).toFixed(decimalPlaces);
|
|
1324
|
+
}
|
|
1325
|
+
chunkC66X5FP6_cjs.__name(decimal, "decimal");
|
|
1326
|
+
function decimalFromCents(value, decimalPlaces = 2) {
|
|
1327
|
+
return +(+value / Math.pow(10, decimalPlaces)).toFixed(decimalPlaces);
|
|
1328
|
+
}
|
|
1329
|
+
chunkC66X5FP6_cjs.__name(decimalFromCents, "decimalFromCents");
|
|
1330
|
+
function decimalToCents(value, decimalPlaces = 2) {
|
|
1331
|
+
return Math.round(+value * Math.pow(10, decimalPlaces));
|
|
1332
|
+
}
|
|
1333
|
+
chunkC66X5FP6_cjs.__name(decimalToCents, "decimalToCents");
|
|
1334
|
+
function decimalCentsPart(value, decimalPlaces = 2) {
|
|
1335
|
+
return decimalPlaces * (decimal(value, decimalPlaces) % 1);
|
|
1336
|
+
}
|
|
1337
|
+
chunkC66X5FP6_cjs.__name(decimalCentsPart, "decimalCentsPart");
|
|
1338
|
+
|
|
1339
|
+
// src/common/data/html.ts
|
|
1340
|
+
var escapeHTML = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/"/g, """), "escapeHTML");
|
|
1341
|
+
var unescapeHTML = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((s) => s.replace(/</gi, "<").replace(/>/gi, ">").replace(/"/gi, '"').replace(/'/gi, "'").replace(/&/gi, "&"), "unescapeHTML");
|
|
1342
|
+
|
|
1343
|
+
// src/common/data/path.ts
|
|
1344
|
+
var MAX_FILENAME_LENGTH = 100;
|
|
1345
|
+
var reControlChars = /[\u0000-\u001F\u0080-\u009F]/g;
|
|
1346
|
+
var reRelativePath = /^\.+/;
|
|
1347
|
+
var reTrailingPeriods = /\.+$/;
|
|
1348
|
+
function filenameReservedRegex() {
|
|
1349
|
+
return /[<>:"/\\|?*\u0000-\u001F]/g;
|
|
1350
|
+
}
|
|
1351
|
+
chunkC66X5FP6_cjs.__name(filenameReservedRegex, "filenameReservedRegex");
|
|
1352
|
+
function windowsReservedNameRegex() {
|
|
1353
|
+
return /^(con|prn|aux|nul|com\d|lpt\d)$/i;
|
|
1354
|
+
}
|
|
1355
|
+
chunkC66X5FP6_cjs.__name(windowsReservedNameRegex, "windowsReservedNameRegex");
|
|
1356
|
+
function toValidFilename(string) {
|
|
1357
|
+
if (typeof string !== "string") {
|
|
1358
|
+
throw new TypeError("Expected a string");
|
|
1359
|
+
}
|
|
1360
|
+
const replacement = "_";
|
|
1361
|
+
if (filenameReservedRegex().test(replacement) && reControlChars.test(replacement)) {
|
|
1362
|
+
throw new Error(
|
|
1363
|
+
"Replacement string cannot contain reserved filename characters"
|
|
1364
|
+
);
|
|
1365
|
+
}
|
|
1366
|
+
string = string.replace(filenameReservedRegex(), replacement).replace(reControlChars, replacement).replace(reRelativePath, replacement).replace(reTrailingPeriods, "");
|
|
1367
|
+
string = windowsReservedNameRegex().test(string) ? string + replacement : string;
|
|
1368
|
+
return string.slice(0, MAX_FILENAME_LENGTH);
|
|
1369
|
+
}
|
|
1370
|
+
chunkC66X5FP6_cjs.__name(toValidFilename, "toValidFilename");
|
|
1371
|
+
|
|
1372
|
+
// src/common/data/regexp.ts
|
|
1373
|
+
var rxEscape = /[\\\-\[\]\/{}()*+?.^$|]/g;
|
|
1374
|
+
function escapeRegExp(value) {
|
|
1375
|
+
if (!value)
|
|
1376
|
+
return "";
|
|
1377
|
+
if (value instanceof RegExp) {
|
|
1378
|
+
return value.source;
|
|
1379
|
+
}
|
|
1380
|
+
return value.replace(rxEscape, "\\$&");
|
|
1381
|
+
}
|
|
1382
|
+
chunkC66X5FP6_cjs.__name(escapeRegExp, "escapeRegExp");
|
|
1383
|
+
|
|
1384
|
+
// src/common/data/rounding.ts
|
|
1385
|
+
var isHalf = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => Math.abs(value) % 1 === 0.5, "isHalf");
|
|
1386
|
+
var isEven = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => value % 2 === 0, "isEven");
|
|
1387
|
+
var roundUp = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => Math.ceil(value), "roundUp");
|
|
1388
|
+
var roundDown = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => Math.floor(value), "roundDown");
|
|
1389
|
+
var roundHalfUp = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => Math.round(value), "roundHalfUp");
|
|
1390
|
+
var roundHalfOdd = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => {
|
|
1391
|
+
const rounded = Math.round(value);
|
|
1392
|
+
if (!isHalf(value)) {
|
|
1393
|
+
return rounded;
|
|
1394
|
+
}
|
|
1395
|
+
return isEven(rounded) ? rounded - 1 : rounded;
|
|
1396
|
+
}, "roundHalfOdd");
|
|
1397
|
+
var roundHalfAwayFromZero = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => {
|
|
1398
|
+
return isHalf(value) ? Math.sign(value) * Math.ceil(Math.abs(value)) : Math.round(value);
|
|
1399
|
+
}, "roundHalfAwayFromZero");
|
|
1400
|
+
var roundHalfDown = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => isHalf(value) ? Math.floor(value) : Math.round(value), "roundHalfDown");
|
|
1401
|
+
var roundHalfEven = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => {
|
|
1402
|
+
const rounded = Math.round(value);
|
|
1403
|
+
if (!isHalf(value)) {
|
|
1404
|
+
return rounded;
|
|
1405
|
+
}
|
|
1406
|
+
return isEven(rounded) ? rounded : rounded - 1;
|
|
1407
|
+
}, "roundHalfEven");
|
|
1408
|
+
var roundHalfTowardsZero = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((value) => isHalf(value) ? Math.sign(value) * Math.floor(Math.abs(value)) : Math.round(value), "roundHalfTowardsZero");
|
|
1409
|
+
|
|
1410
|
+
// src/common/data/sortable.ts
|
|
1411
|
+
function startSortWeight(items) {
|
|
1412
|
+
return items.reduce((acc, item) => Math.min(acc, item.sort_weight || 0), 0) - 1 - getSecureRandomIfPossible();
|
|
1413
|
+
}
|
|
1414
|
+
chunkC66X5FP6_cjs.__name(startSortWeight, "startSortWeight");
|
|
1415
|
+
function endSortWeight(items) {
|
|
1416
|
+
return items.reduce((acc, item) => Math.max(acc, item.sort_weight || 0), 0) + 1 + getSecureRandomIfPossible();
|
|
1417
|
+
}
|
|
1418
|
+
chunkC66X5FP6_cjs.__name(endSortWeight, "endSortWeight");
|
|
1419
|
+
function moveSortWeight(newIndex, oldIndex, items) {
|
|
1420
|
+
let count = items.length;
|
|
1421
|
+
const moveLower = newIndex < oldIndex;
|
|
1422
|
+
if (count <= 0 || newIndex >= count - 1) {
|
|
1423
|
+
return endSortWeight(items);
|
|
1424
|
+
}
|
|
1425
|
+
if (newIndex <= 0) {
|
|
1426
|
+
return startSortWeight(items);
|
|
1427
|
+
}
|
|
1428
|
+
items = sortedItems([...items]);
|
|
1429
|
+
const step = moveLower ? -1 : 0;
|
|
1430
|
+
const lower = items[newIndex + step].sort_weight || 0;
|
|
1431
|
+
const upper = items[newIndex + step + 1].sort_weight || 0;
|
|
1432
|
+
const distance = upper - lower;
|
|
1433
|
+
if (distance === 0) {
|
|
1434
|
+
if (moveLower) {
|
|
1435
|
+
return startSortWeight(items);
|
|
1436
|
+
}
|
|
1437
|
+
return endSortWeight(items);
|
|
1438
|
+
}
|
|
1439
|
+
const middle = lower + distance / 2;
|
|
1440
|
+
const fuzzy = distance * 0.01 * (getSecureRandomIfPossible() - 0.5);
|
|
1441
|
+
return middle + fuzzy;
|
|
1442
|
+
}
|
|
1443
|
+
chunkC66X5FP6_cjs.__name(moveSortWeight, "moveSortWeight");
|
|
1444
|
+
function sortedItems(items) {
|
|
1445
|
+
items.sort((a, b) => (a.sort_weight || 0) - (b.sort_weight || 0));
|
|
1446
|
+
return items;
|
|
1447
|
+
}
|
|
1448
|
+
chunkC66X5FP6_cjs.__name(sortedItems, "sortedItems");
|
|
1449
|
+
|
|
1450
|
+
// src/common/data/url.ts
|
|
1451
|
+
var findURL = /((?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?)/gim;
|
|
1452
|
+
function linkifyPlainText(text) {
|
|
1453
|
+
return text.split(findURL).map((part, i) => {
|
|
1454
|
+
const escapedPart = escapeHTML(part);
|
|
1455
|
+
return i % 2 ? `<a target="_blank" href="${escapedPart}">${toHumanReadableUrl(
|
|
1456
|
+
escapedPart
|
|
1457
|
+
)}</a>` : escapedPart;
|
|
1458
|
+
}).join("");
|
|
1459
|
+
}
|
|
1460
|
+
chunkC66X5FP6_cjs.__name(linkifyPlainText, "linkifyPlainText");
|
|
1461
|
+
function toHumanReadableUrl(url) {
|
|
1462
|
+
return url.replace(/^https?:\/\/(www\.)?/, "").replace(/\/$/, "");
|
|
1463
|
+
}
|
|
1464
|
+
chunkC66X5FP6_cjs.__name(toHumanReadableUrl, "toHumanReadableUrl");
|
|
1465
|
+
function encodeQuery(data) {
|
|
1466
|
+
let pairs = [];
|
|
1467
|
+
for (let [key, value] of Object.entries(data)) {
|
|
1468
|
+
if (value != null) {
|
|
1469
|
+
if (!Array.isArray(value)) {
|
|
1470
|
+
value = [value];
|
|
1471
|
+
}
|
|
1472
|
+
for (let v of value) {
|
|
1473
|
+
if (v != null) {
|
|
1474
|
+
pairs.push(
|
|
1475
|
+
encodeURIComponent(key) + "=" + encodeURIComponent(String(v))
|
|
1476
|
+
);
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
return pairs.join("&");
|
|
1482
|
+
}
|
|
1483
|
+
chunkC66X5FP6_cjs.__name(encodeQuery, "encodeQuery");
|
|
1484
|
+
function parseQuery(queryString) {
|
|
1485
|
+
let query = {};
|
|
1486
|
+
let pairs = (queryString[0] === "?" ? queryString.substr(1) : queryString).split("&");
|
|
1487
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
1488
|
+
let pair = pairs[i].split("=");
|
|
1489
|
+
let key = decodeURIComponent(pair[0]);
|
|
1490
|
+
let value = decodeURIComponent(pair[1] || "");
|
|
1491
|
+
if (query[key] != null) {
|
|
1492
|
+
if (!Array.isArray(query[key])) {
|
|
1493
|
+
query[key] = [query[key]];
|
|
1494
|
+
}
|
|
1495
|
+
query[key].push(value);
|
|
1496
|
+
} else {
|
|
1497
|
+
query[key] = value;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
return query;
|
|
1501
|
+
}
|
|
1502
|
+
chunkC66X5FP6_cjs.__name(parseQuery, "parseQuery");
|
|
1503
|
+
|
|
1504
|
+
// src/common/data/utils.ts
|
|
1505
|
+
function ensureKey(obj, key, createFn) {
|
|
1506
|
+
let value = obj[key];
|
|
1507
|
+
if (value === void 0) {
|
|
1508
|
+
value = createFn(key, obj);
|
|
1509
|
+
obj[key] = value;
|
|
1510
|
+
}
|
|
1511
|
+
return value;
|
|
1512
|
+
}
|
|
1513
|
+
chunkC66X5FP6_cjs.__name(ensureKey, "ensureKey");
|
|
1514
|
+
async function ensureKeyAsync(obj, key, createFn) {
|
|
1515
|
+
let value = obj[key];
|
|
1516
|
+
if (value === void 0) {
|
|
1517
|
+
value = await createFn(key, obj);
|
|
1518
|
+
obj[key] = value;
|
|
1519
|
+
}
|
|
1520
|
+
return value;
|
|
1521
|
+
}
|
|
1522
|
+
chunkC66X5FP6_cjs.__name(ensureKeyAsync, "ensureKeyAsync");
|
|
1523
|
+
function size(obj) {
|
|
1524
|
+
if (obj != null) {
|
|
1525
|
+
if (obj.size != null) {
|
|
1526
|
+
return obj.size;
|
|
1527
|
+
}
|
|
1528
|
+
if (obj.length != null) {
|
|
1529
|
+
return obj.length;
|
|
1530
|
+
}
|
|
1531
|
+
return Object.keys(obj).length;
|
|
1532
|
+
}
|
|
1533
|
+
return 0;
|
|
1534
|
+
}
|
|
1535
|
+
chunkC66X5FP6_cjs.__name(size, "size");
|
|
1536
|
+
function last(array) {
|
|
1537
|
+
return array != null && array.length > 0 ? array[array.length - 1] : void 0;
|
|
1538
|
+
}
|
|
1539
|
+
chunkC66X5FP6_cjs.__name(last, "last");
|
|
1540
|
+
function empty(value) {
|
|
1541
|
+
try {
|
|
1542
|
+
if (value != null) {
|
|
1543
|
+
if (Array.isArray(value)) {
|
|
1544
|
+
return value.length <= 0;
|
|
1545
|
+
} else if (typeof value === "string") {
|
|
1546
|
+
return value.length <= 0;
|
|
1547
|
+
} else if ((value == null ? void 0 : value.size) != null) {
|
|
1548
|
+
return value.size <= 0;
|
|
1549
|
+
} else {
|
|
1550
|
+
return Object.keys(value).length <= 0;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
} catch (err) {
|
|
1554
|
+
console.warn("Failed to check if empty for", value, err);
|
|
1555
|
+
}
|
|
1556
|
+
return true;
|
|
1557
|
+
}
|
|
1558
|
+
chunkC66X5FP6_cjs.__name(empty, "empty");
|
|
1559
|
+
function cloneObject(obj) {
|
|
1560
|
+
if (Object(obj) !== obj)
|
|
1561
|
+
return obj;
|
|
1562
|
+
return JSON.parse(JSON.stringify(obj));
|
|
1563
|
+
}
|
|
1564
|
+
chunkC66X5FP6_cjs.__name(cloneObject, "cloneObject");
|
|
1565
|
+
function cloneJsonObject(obj) {
|
|
1566
|
+
if (Object(obj) !== obj)
|
|
1567
|
+
return obj;
|
|
1568
|
+
return JSON.parse(JSON.stringify(obj));
|
|
1569
|
+
}
|
|
1570
|
+
chunkC66X5FP6_cjs.__name(cloneJsonObject, "cloneJsonObject");
|
|
1571
|
+
function memoize(fn) {
|
|
1572
|
+
let cache = /* @__PURE__ */ new Map();
|
|
1573
|
+
return (n) => {
|
|
1574
|
+
if (cache.has(n)) {
|
|
1575
|
+
return cache.get(n);
|
|
1576
|
+
}
|
|
1577
|
+
let result = fn(n);
|
|
1578
|
+
cache.set(n, result);
|
|
1579
|
+
return result;
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
chunkC66X5FP6_cjs.__name(memoize, "memoize");
|
|
1583
|
+
function forTimes(count, fn) {
|
|
1584
|
+
let result = [];
|
|
1585
|
+
for (let i = 0; i < count; i++) {
|
|
1586
|
+
result.push(fn(i, count));
|
|
1587
|
+
}
|
|
1588
|
+
return result;
|
|
1589
|
+
}
|
|
1590
|
+
chunkC66X5FP6_cjs.__name(forTimes, "forTimes");
|
|
1591
|
+
|
|
1592
|
+
// src/common/data/xrx.ts
|
|
1593
|
+
var RX_WHITESPACE = /\\\s|\s+|#[^\n]*\n?/gm;
|
|
1594
|
+
var RX_REAL_GROUPS = /\(\?P?<(\w[\w\d_]+)>|\((?!\?(:|\!|=|<=|<\!))/gm;
|
|
1595
|
+
var RX_LOOK_BEHIND = /^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*?)\)/gm;
|
|
1596
|
+
var log3 = chunkC66X5FP6_cjs.Logger("xrx");
|
|
1597
|
+
function regExpString(rx) {
|
|
1598
|
+
return typeof rx === "string" ? rx : rx.source || "";
|
|
1599
|
+
}
|
|
1600
|
+
chunkC66X5FP6_cjs.__name(regExpString, "regExpString");
|
|
1601
|
+
function regExpEscape(str) {
|
|
1602
|
+
return str.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1603
|
+
}
|
|
1604
|
+
chunkC66X5FP6_cjs.__name(regExpEscape, "regExpEscape");
|
|
1605
|
+
var XRX = class {
|
|
1606
|
+
constructor(pattern2, flags) {
|
|
1607
|
+
this.namedGroups = {};
|
|
1608
|
+
this.names = [];
|
|
1609
|
+
let _flags = _nullishCoalesce(flags, () => ( ""));
|
|
1610
|
+
let _rx;
|
|
1611
|
+
if (pattern2 instanceof RegExp) {
|
|
1612
|
+
if (flags == null) {
|
|
1613
|
+
_flags = pattern2.flags;
|
|
1614
|
+
}
|
|
1615
|
+
_rx = pattern2.source;
|
|
1616
|
+
} else {
|
|
1617
|
+
_rx = pattern2;
|
|
1618
|
+
}
|
|
1619
|
+
const extended = _flags && _flags.indexOf("x") !== -1;
|
|
1620
|
+
if (extended) {
|
|
1621
|
+
_flags = _flags.replace("x", "");
|
|
1622
|
+
_rx = _rx.replace(RX_WHITESPACE, (r) => {
|
|
1623
|
+
return r[0] === "\\" ? r : "";
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1626
|
+
if (!(pattern2 instanceof RegExp)) {
|
|
1627
|
+
let index = 0;
|
|
1628
|
+
_rx = _rx.replace(RX_REAL_GROUPS, (str, name) => {
|
|
1629
|
+
index += 1;
|
|
1630
|
+
if (name) {
|
|
1631
|
+
if (name !== "index" && name !== "length" && !this.namedGroups[name]) {
|
|
1632
|
+
this.namedGroups[name] = index;
|
|
1633
|
+
} else {
|
|
1634
|
+
log3.error(`Unallowed or duplicate group name: ${name}`);
|
|
1635
|
+
}
|
|
1636
|
+
return "(";
|
|
1637
|
+
}
|
|
1638
|
+
return str;
|
|
1639
|
+
});
|
|
1640
|
+
this.names = Object.keys(this.namedGroups);
|
|
1641
|
+
}
|
|
1642
|
+
_rx = regExpString(_rx);
|
|
1643
|
+
RX_LOOK_BEHIND.lastIndex = 0;
|
|
1644
|
+
let parts = RX_LOOK_BEHIND.exec(_rx);
|
|
1645
|
+
if (parts) {
|
|
1646
|
+
this.lookBehind = {
|
|
1647
|
+
rx: new RegExp(`${parts[3]}$(?!\\s)`),
|
|
1648
|
+
expect: parts ? parts[2] === "=" : !parts
|
|
1649
|
+
};
|
|
1650
|
+
_rx = _rx.substr(parts[0].length);
|
|
1651
|
+
}
|
|
1652
|
+
this.rx = new RegExp(_rx, _flags);
|
|
1653
|
+
}
|
|
1654
|
+
get lastIndex() {
|
|
1655
|
+
return this.rx.lastIndex;
|
|
1656
|
+
}
|
|
1657
|
+
set lastIndex(index) {
|
|
1658
|
+
this.rx.lastIndex = index;
|
|
1659
|
+
}
|
|
1660
|
+
_handleMatch(m) {
|
|
1661
|
+
if (this.lookBehind) {
|
|
1662
|
+
let leftContext = m.input.slice(0, m.index);
|
|
1663
|
+
if (this.lookBehind.expect !== this.lookBehind.rx.test(leftContext)) {
|
|
1664
|
+
return null;
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
for (let name of this.names) {
|
|
1668
|
+
m[name] = m[this.namedGroups[name]];
|
|
1669
|
+
}
|
|
1670
|
+
return m;
|
|
1671
|
+
}
|
|
1672
|
+
exec(str) {
|
|
1673
|
+
let m;
|
|
1674
|
+
while (m = this.rx.exec(str)) {
|
|
1675
|
+
if (this.rx.lastIndex === m.index) {
|
|
1676
|
+
this.rx.lastIndex++;
|
|
1677
|
+
}
|
|
1678
|
+
m = this._handleMatch(m);
|
|
1679
|
+
if (m != null) {
|
|
1680
|
+
return m;
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
execAll(str) {
|
|
1685
|
+
let matches = [];
|
|
1686
|
+
let m;
|
|
1687
|
+
this.rx.lastIndex = 0;
|
|
1688
|
+
while (m = this.exec(str)) {
|
|
1689
|
+
matches.push(m);
|
|
1690
|
+
}
|
|
1691
|
+
this.rx.lastIndex = 0;
|
|
1692
|
+
return matches;
|
|
1693
|
+
}
|
|
1694
|
+
replace(str, replacement) {
|
|
1695
|
+
let fn = typeof replacement === "function" ? replacement : () => replacement;
|
|
1696
|
+
return str.replace(this.rx, (m) => {
|
|
1697
|
+
return fn(m);
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
chunkC66X5FP6_cjs.__name(XRX, "XRX");
|
|
1702
|
+
|
|
1703
|
+
// src/common/dispose-defer.ts
|
|
1704
|
+
var log4 = chunkC66X5FP6_cjs.Logger("dispose");
|
|
1705
|
+
async function callDisposer(disposable) {
|
|
1706
|
+
if (typeof disposable === "function") {
|
|
1707
|
+
await promisify(disposable());
|
|
1708
|
+
} else if (isPromise(disposable)) {
|
|
1709
|
+
await disposable;
|
|
1710
|
+
} else if (typeof disposable.dispose === "function") {
|
|
1711
|
+
await promisify(disposable.dispose());
|
|
1712
|
+
} else if (isPromise(disposable.dispose)) {
|
|
1713
|
+
await disposable.dispose;
|
|
1714
|
+
} else if (typeof disposable.cleanup === "function") {
|
|
1715
|
+
await promisify(disposable.cleanup());
|
|
1716
|
+
} else if (isPromise(disposable.cleanup)) {
|
|
1717
|
+
await disposable.cleanup;
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
chunkC66X5FP6_cjs.__name(callDisposer, "callDisposer");
|
|
1721
|
+
function useDispose(config) {
|
|
1722
|
+
const { name } = typeof config === "string" ? { name: config } : _nullishCoalesce(config, () => ( {}));
|
|
1723
|
+
let tracked = [];
|
|
1724
|
+
const untrack = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(async (disposable) => {
|
|
1725
|
+
if (disposable != null && tracked.includes(disposable)) {
|
|
1726
|
+
arrayFilterInPlace(tracked, (el) => el !== disposable);
|
|
1727
|
+
await callDisposer(disposable);
|
|
1728
|
+
}
|
|
1729
|
+
}, "untrack");
|
|
1730
|
+
const dispose = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(async () => {
|
|
1731
|
+
if (name)
|
|
1732
|
+
log4.debug(`dispose ${name}: ${tracked.length} entries`);
|
|
1733
|
+
while (tracked.length > 0) {
|
|
1734
|
+
await untrack(tracked[0]);
|
|
1735
|
+
}
|
|
1736
|
+
}, "dispose");
|
|
1737
|
+
const track = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((obj) => {
|
|
1738
|
+
if (obj == null)
|
|
1739
|
+
return;
|
|
1740
|
+
tracked.unshift(obj);
|
|
1741
|
+
return () => untrack(obj);
|
|
1742
|
+
}, "track");
|
|
1743
|
+
return Object.assign(dispose, {
|
|
1744
|
+
track,
|
|
1745
|
+
add: track,
|
|
1746
|
+
untrack,
|
|
1747
|
+
dispose,
|
|
1748
|
+
exec: dispose,
|
|
1749
|
+
getSize() {
|
|
1750
|
+
return tracked.length;
|
|
1751
|
+
}
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
chunkC66X5FP6_cjs.__name(useDispose, "useDispose");
|
|
1755
|
+
var useDisposer = useDispose;
|
|
1756
|
+
function useDefer(config = {}) {
|
|
1757
|
+
const { mode = "fifo" } = config;
|
|
1758
|
+
let steps = [];
|
|
1759
|
+
const exec = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(async (expectSync = false) => {
|
|
1760
|
+
while (steps.length > 0) {
|
|
1761
|
+
let step = steps[0];
|
|
1762
|
+
arrayFilterInPlace(steps, (el) => el !== step);
|
|
1763
|
+
if (typeof step === "function") {
|
|
1764
|
+
let result = step();
|
|
1765
|
+
if (isPromise(result)) {
|
|
1766
|
+
if (expectSync)
|
|
1767
|
+
throw new Error(
|
|
1768
|
+
`Expected sync only function, but found async: ${step}`
|
|
1769
|
+
);
|
|
1770
|
+
await result;
|
|
1771
|
+
}
|
|
1772
|
+
} else if (isPromise(step)) {
|
|
1773
|
+
if (expectSync)
|
|
1774
|
+
throw new Error(
|
|
1775
|
+
`Expected sync only function, but found async: ${step}`
|
|
1776
|
+
);
|
|
1777
|
+
await step;
|
|
1778
|
+
} else {
|
|
1779
|
+
throw new Error(`Unhandled disposable: ${step}`);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
}, "exec");
|
|
1783
|
+
const add = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((obj) => {
|
|
1784
|
+
if (mode === "lifo") {
|
|
1785
|
+
steps.unshift(obj);
|
|
1786
|
+
} else {
|
|
1787
|
+
steps.push(obj);
|
|
1788
|
+
}
|
|
1789
|
+
}, "add");
|
|
1790
|
+
return Object.assign(exec, {
|
|
1791
|
+
add,
|
|
1792
|
+
exec,
|
|
1793
|
+
getSize() {
|
|
1794
|
+
return steps.length;
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
chunkC66X5FP6_cjs.__name(useDefer, "useDefer");
|
|
1799
|
+
function useTimeout(fn, timeout2 = 0) {
|
|
1800
|
+
let timeoutHandle = setTimeout(fn, timeout2);
|
|
1801
|
+
return () => {
|
|
1802
|
+
if (timeoutHandle) {
|
|
1803
|
+
clearTimeout(timeoutHandle);
|
|
1804
|
+
timeoutHandle = void 0;
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
}
|
|
1808
|
+
chunkC66X5FP6_cjs.__name(useTimeout, "useTimeout");
|
|
1809
|
+
function useInterval(fn, interval) {
|
|
1810
|
+
let intervalHandle = setInterval(fn, interval);
|
|
1811
|
+
return () => {
|
|
1812
|
+
if (intervalHandle) {
|
|
1813
|
+
clearInterval(intervalHandle);
|
|
1814
|
+
intervalHandle = void 0;
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
chunkC66X5FP6_cjs.__name(useInterval, "useInterval");
|
|
1819
|
+
function useEventListener(emitter, eventName, fn, ...args) {
|
|
1820
|
+
if (emitter == null)
|
|
1821
|
+
return () => {
|
|
1822
|
+
};
|
|
1823
|
+
if (emitter.on) {
|
|
1824
|
+
emitter.on(eventName, fn, ...args);
|
|
1825
|
+
} else if (emitter.addEventListener) {
|
|
1826
|
+
emitter.addEventListener(eventName, fn, ...args);
|
|
1827
|
+
}
|
|
1828
|
+
return () => {
|
|
1829
|
+
if (emitter.off) {
|
|
1830
|
+
emitter.off(eventName, fn, ...args);
|
|
1831
|
+
} else if (emitter.removeEventListener) {
|
|
1832
|
+
emitter.removeEventListener(eventName, fn, ...args);
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
chunkC66X5FP6_cjs.__name(useEventListener, "useEventListener");
|
|
1837
|
+
|
|
1838
|
+
// src/common/exec/mutex.ts
|
|
1839
|
+
function useMutex() {
|
|
1840
|
+
let token = true;
|
|
1841
|
+
return (fn, elseFn) => {
|
|
1842
|
+
let executed = false;
|
|
1843
|
+
if (token) {
|
|
1844
|
+
token = false;
|
|
1845
|
+
try {
|
|
1846
|
+
fn();
|
|
1847
|
+
executed = true;
|
|
1848
|
+
} finally {
|
|
1849
|
+
token = true;
|
|
1850
|
+
}
|
|
1851
|
+
} else if (elseFn !== void 0) {
|
|
1852
|
+
elseFn();
|
|
1853
|
+
}
|
|
1854
|
+
return executed;
|
|
1855
|
+
};
|
|
1856
|
+
}
|
|
1857
|
+
chunkC66X5FP6_cjs.__name(useMutex, "useMutex");
|
|
1858
|
+
function useAsyncMutex() {
|
|
1859
|
+
let token = true;
|
|
1860
|
+
return async (fn, elseFn) => {
|
|
1861
|
+
let executed = false;
|
|
1862
|
+
if (token) {
|
|
1863
|
+
token = false;
|
|
1864
|
+
try {
|
|
1865
|
+
let result = fn();
|
|
1866
|
+
if (isPromise(result))
|
|
1867
|
+
await result;
|
|
1868
|
+
executed = true;
|
|
1869
|
+
} finally {
|
|
1870
|
+
token = true;
|
|
1871
|
+
}
|
|
1872
|
+
} else if (elseFn !== void 0) {
|
|
1873
|
+
let result = elseFn();
|
|
1874
|
+
if (isPromise(result))
|
|
1875
|
+
await result;
|
|
1876
|
+
}
|
|
1877
|
+
return executed;
|
|
1878
|
+
};
|
|
1879
|
+
}
|
|
1880
|
+
chunkC66X5FP6_cjs.__name(useAsyncMutex, "useAsyncMutex");
|
|
1881
|
+
|
|
1882
|
+
// src/common/msg/emitter.ts
|
|
1883
|
+
var log5 = chunkC66X5FP6_cjs.Logger("zeed:emitter");
|
|
1884
|
+
var Emitter = class {
|
|
1885
|
+
constructor() {
|
|
1886
|
+
this.subscribers = {};
|
|
1887
|
+
this.subscribersOnAny = [];
|
|
1888
|
+
this.dispose = useDispose();
|
|
1889
|
+
this.call = new Proxy({}, {
|
|
1890
|
+
get: (target, name) => (...args) => this.emit(name, ...args)
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
async emit(event, ...args) {
|
|
1894
|
+
let ok = false;
|
|
1895
|
+
this.dispose.add(() => {
|
|
1896
|
+
this.subscribers = {};
|
|
1897
|
+
this.subscribersOnAny = [];
|
|
1898
|
+
});
|
|
1899
|
+
try {
|
|
1900
|
+
let subscribers = this.subscribers[event] || [];
|
|
1901
|
+
this.subscribersOnAny.forEach((fn) => fn(event, ...args));
|
|
1902
|
+
if (subscribers.length > 0) {
|
|
1903
|
+
let all = subscribers.map((fn) => {
|
|
1904
|
+
try {
|
|
1905
|
+
return promisify(fn(...args));
|
|
1906
|
+
} catch (err) {
|
|
1907
|
+
log5.warn("emit warning:", err);
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
ok = true;
|
|
1911
|
+
await Promise.all(all);
|
|
1912
|
+
}
|
|
1913
|
+
} catch (err) {
|
|
1914
|
+
log5.error("emit exception", err);
|
|
1915
|
+
}
|
|
1916
|
+
return ok;
|
|
1917
|
+
}
|
|
1918
|
+
onAny(fn) {
|
|
1919
|
+
this.subscribersOnAny.push(fn);
|
|
1920
|
+
}
|
|
1921
|
+
on(event, listener) {
|
|
1922
|
+
let subscribers = this.subscribers[event] || [];
|
|
1923
|
+
subscribers.push(listener);
|
|
1924
|
+
this.subscribers[event] = subscribers;
|
|
1925
|
+
return () => {
|
|
1926
|
+
this.off(event, listener);
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
onCall(handlers) {
|
|
1930
|
+
for (const [name, handler] of Object.entries(handlers)) {
|
|
1931
|
+
this.on(name, handler);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
once(event, listener) {
|
|
1935
|
+
const onceListener = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(async (...args) => {
|
|
1936
|
+
this.off(event, onceListener);
|
|
1937
|
+
return await promisify(listener(...args));
|
|
1938
|
+
}, "onceListener");
|
|
1939
|
+
this.on(event, onceListener);
|
|
1940
|
+
return () => {
|
|
1941
|
+
this.off(event, listener);
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1944
|
+
off(event, listener) {
|
|
1945
|
+
this.subscribers[event] = (this.subscribers[event] || []).filter(
|
|
1946
|
+
(f) => listener && f !== listener
|
|
1947
|
+
);
|
|
1948
|
+
return this;
|
|
1949
|
+
}
|
|
1950
|
+
removeAllListeners() {
|
|
1951
|
+
this.subscribers = {};
|
|
1952
|
+
return this;
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
chunkC66X5FP6_cjs.__name(Emitter, "Emitter");
|
|
1956
|
+
function getGlobalEmitter() {
|
|
1957
|
+
let emitter = chunkC66X5FP6_cjs.getGlobalContext().emitter;
|
|
1958
|
+
if (!emitter) {
|
|
1959
|
+
emitter = new Emitter();
|
|
1960
|
+
chunkC66X5FP6_cjs.getGlobalContext().emitter = emitter;
|
|
1961
|
+
}
|
|
1962
|
+
return emitter;
|
|
1963
|
+
}
|
|
1964
|
+
chunkC66X5FP6_cjs.__name(getGlobalEmitter, "getGlobalEmitter");
|
|
1965
|
+
var messages = new Emitter();
|
|
1966
|
+
function lazyListener(emitter, listenerKey) {
|
|
1967
|
+
const name = Math.round(getSecureRandomIfPossible() * 100);
|
|
1968
|
+
var events = [];
|
|
1969
|
+
var lazyResolve;
|
|
1970
|
+
const incoming = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((key, obj) => {
|
|
1971
|
+
let ev = { key, obj };
|
|
1972
|
+
events.push(ev);
|
|
1973
|
+
lazyResolve && lazyResolve();
|
|
1974
|
+
}, "incoming");
|
|
1975
|
+
if (listenerKey) {
|
|
1976
|
+
if (emitter.on) {
|
|
1977
|
+
emitter.on(listenerKey, (obj) => {
|
|
1978
|
+
incoming(listenerKey, obj);
|
|
1979
|
+
});
|
|
1980
|
+
} else if (emitter.addEventListener) {
|
|
1981
|
+
emitter.addEventListener(listenerKey, (obj) => {
|
|
1982
|
+
incoming(listenerKey, obj);
|
|
1983
|
+
});
|
|
1984
|
+
} else {
|
|
1985
|
+
log5.error(name, "Cannot listen to key");
|
|
1986
|
+
}
|
|
1987
|
+
} else {
|
|
1988
|
+
if (emitter.onAny) {
|
|
1989
|
+
emitter.onAny((key, obj) => {
|
|
1990
|
+
incoming(key, obj);
|
|
1991
|
+
});
|
|
1992
|
+
} else {
|
|
1993
|
+
log5.error(name, "cannot listen to all for", emitter);
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
let on = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((key, skipUnmatched = true) => {
|
|
1997
|
+
return new Promise((resolve, reject) => {
|
|
1998
|
+
if (!key) {
|
|
1999
|
+
key = listenerKey;
|
|
2000
|
+
if (!key) {
|
|
2001
|
+
if (events.length) {
|
|
2002
|
+
key = events[0].key;
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
lazyResolve = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(() => {
|
|
2007
|
+
while (events.length > 0) {
|
|
2008
|
+
let ev = events.shift();
|
|
2009
|
+
if (ev.key === key) {
|
|
2010
|
+
lazyResolve = void 0;
|
|
2011
|
+
resolve(ev.obj);
|
|
2012
|
+
} else {
|
|
2013
|
+
if (skipUnmatched) {
|
|
2014
|
+
log5.warn(name, `Unhandled event ${key} with value: ${ev.obj}`);
|
|
2015
|
+
continue;
|
|
2016
|
+
}
|
|
2017
|
+
reject(`Expected ${key}, but found ${ev.key} with value=${ev.obj}`);
|
|
2018
|
+
log5.error(name, `Unhandled event ${key} with value: ${ev.obj}`);
|
|
2019
|
+
}
|
|
2020
|
+
break;
|
|
2021
|
+
}
|
|
2022
|
+
}, "lazyResolve");
|
|
2023
|
+
lazyResolve();
|
|
2024
|
+
});
|
|
2025
|
+
}, "on");
|
|
2026
|
+
return on;
|
|
2027
|
+
}
|
|
2028
|
+
chunkC66X5FP6_cjs.__name(lazyListener, "lazyListener");
|
|
2029
|
+
|
|
2030
|
+
// src/common/uuid.ts
|
|
2031
|
+
var { encode: encode62, decode: decode62 } = useBase(62);
|
|
2032
|
+
var { encode: encode32, decode: decode32 } = useBase(32);
|
|
2033
|
+
function uuidBytes() {
|
|
2034
|
+
return randomUint8Array(16);
|
|
2035
|
+
}
|
|
2036
|
+
chunkC66X5FP6_cjs.__name(uuidBytes, "uuidBytes");
|
|
2037
|
+
var uuid32bit = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(() => new Uint32Array(randomUint8Array(4))[0], "uuid32bit");
|
|
2038
|
+
function uuid() {
|
|
2039
|
+
return encode62(uuidBytes(), 22);
|
|
2040
|
+
}
|
|
2041
|
+
chunkC66X5FP6_cjs.__name(uuid, "uuid");
|
|
2042
|
+
function uuidEncode(bytes) {
|
|
2043
|
+
return encode62(bytes, 22);
|
|
2044
|
+
}
|
|
2045
|
+
chunkC66X5FP6_cjs.__name(uuidEncode, "uuidEncode");
|
|
2046
|
+
function uuidDecode(uuid2) {
|
|
2047
|
+
return decode62(uuid2, 16);
|
|
2048
|
+
}
|
|
2049
|
+
chunkC66X5FP6_cjs.__name(uuidDecode, "uuidDecode");
|
|
2050
|
+
function uuidB32() {
|
|
2051
|
+
return encode32(uuidBytes(), 26);
|
|
2052
|
+
}
|
|
2053
|
+
chunkC66X5FP6_cjs.__name(uuidB32, "uuidB32");
|
|
2054
|
+
function uuid32Encode(bytes) {
|
|
2055
|
+
return encode32(bytes, 26);
|
|
2056
|
+
}
|
|
2057
|
+
chunkC66X5FP6_cjs.__name(uuid32Encode, "uuid32Encode");
|
|
2058
|
+
function uuid32Decode(uuid2) {
|
|
2059
|
+
return decode32(uuid2, 16);
|
|
2060
|
+
}
|
|
2061
|
+
chunkC66X5FP6_cjs.__name(uuid32Decode, "uuid32Decode");
|
|
2062
|
+
var _unameCounters = {};
|
|
2063
|
+
function uname(name = "id") {
|
|
2064
|
+
if (_unameCounters[name] == null) {
|
|
2065
|
+
_unameCounters[name] = 0;
|
|
2066
|
+
}
|
|
2067
|
+
return `${name}-${_unameCounters[name]++}`;
|
|
2068
|
+
}
|
|
2069
|
+
chunkC66X5FP6_cjs.__name(uname, "uname");
|
|
2070
|
+
var _qid = 0;
|
|
2071
|
+
function qid() {
|
|
2072
|
+
return `id-${_qid++}`;
|
|
2073
|
+
}
|
|
2074
|
+
chunkC66X5FP6_cjs.__name(qid, "qid");
|
|
2075
|
+
var pattern = "10000000-1000-4000-8000-100000000000";
|
|
2076
|
+
var uuidv4 = typeof crypto !== "undefined" && crypto.randomUUID != null ? crypto.randomUUID : () => pattern.replace(
|
|
2077
|
+
/[018]/g,
|
|
2078
|
+
(c) => (c ^ randomUint8Array(1)[0] & 15 >> c / 4).toString(16)
|
|
2079
|
+
);
|
|
2080
|
+
var ReferenceDateInMS = 16e11;
|
|
2081
|
+
function longToByteArray(long) {
|
|
2082
|
+
var byteArray = new Uint8Array([0, 0, 0, 0, 0, 0]);
|
|
2083
|
+
const bytes = byteArray.length - 1;
|
|
2084
|
+
for (var index = 0; index < byteArray.length; index++) {
|
|
2085
|
+
var byte = long & 255;
|
|
2086
|
+
byteArray[bytes - index] = byte;
|
|
2087
|
+
long = (long - byte) / 256;
|
|
2088
|
+
}
|
|
2089
|
+
return byteArray;
|
|
2090
|
+
}
|
|
2091
|
+
chunkC66X5FP6_cjs.__name(longToByteArray, "longToByteArray");
|
|
2092
|
+
function suidBytes() {
|
|
2093
|
+
const ms = chunkC66X5FP6_cjs.getTimestamp() - ReferenceDateInMS;
|
|
2094
|
+
return new Uint8Array([...longToByteArray(ms), ...randomUint8Array(10)]);
|
|
2095
|
+
}
|
|
2096
|
+
chunkC66X5FP6_cjs.__name(suidBytes, "suidBytes");
|
|
2097
|
+
function suid() {
|
|
2098
|
+
return encode62(suidBytes(), 22);
|
|
2099
|
+
}
|
|
2100
|
+
chunkC66X5FP6_cjs.__name(suid, "suid");
|
|
2101
|
+
function suidDate(id) {
|
|
2102
|
+
return suidBytesDate(decode62(id, 16));
|
|
2103
|
+
}
|
|
2104
|
+
chunkC66X5FP6_cjs.__name(suidDate, "suidDate");
|
|
2105
|
+
function suidBytesDate(id) {
|
|
2106
|
+
return new Date(
|
|
2107
|
+
ReferenceDateInMS + id.slice(0, 6).reduce((acc, byte) => {
|
|
2108
|
+
return acc * 256 + byte;
|
|
2109
|
+
}, 0)
|
|
2110
|
+
);
|
|
2111
|
+
}
|
|
2112
|
+
chunkC66X5FP6_cjs.__name(suidBytesDate, "suidBytesDate");
|
|
2113
|
+
|
|
2114
|
+
// src/common/exec/pool.ts
|
|
2115
|
+
var PoolTaskState = /* @__PURE__ */ ((PoolTaskState2) => {
|
|
2116
|
+
PoolTaskState2[PoolTaskState2["waiting"] = 0] = "waiting";
|
|
2117
|
+
PoolTaskState2[PoolTaskState2["running"] = 1] = "running";
|
|
2118
|
+
PoolTaskState2[PoolTaskState2["finished"] = 2] = "finished";
|
|
2119
|
+
return PoolTaskState2;
|
|
2120
|
+
})(PoolTaskState || {});
|
|
2121
|
+
var PoolTaskIdConflictResolution = /* @__PURE__ */ ((PoolTaskIdConflictResolution2) => {
|
|
2122
|
+
PoolTaskIdConflictResolution2[PoolTaskIdConflictResolution2["replace"] = 0] = "replace";
|
|
2123
|
+
PoolTaskIdConflictResolution2[PoolTaskIdConflictResolution2["memoize"] = 1] = "memoize";
|
|
2124
|
+
PoolTaskIdConflictResolution2[PoolTaskIdConflictResolution2["error"] = 2] = "error";
|
|
2125
|
+
return PoolTaskIdConflictResolution2;
|
|
2126
|
+
})(PoolTaskIdConflictResolution || {});
|
|
2127
|
+
function usePool(config = {}) {
|
|
2128
|
+
const { maxParallel = 3 } = config;
|
|
2129
|
+
const events = new Emitter();
|
|
2130
|
+
let countMax = 0;
|
|
2131
|
+
let countResolved = 0;
|
|
2132
|
+
let currentParallel = 0;
|
|
2133
|
+
let priority = 0;
|
|
2134
|
+
let tasks = {};
|
|
2135
|
+
async function waitFinishAll() {
|
|
2136
|
+
if (countMax > 0) {
|
|
2137
|
+
const [promise, resolve] = createPromise();
|
|
2138
|
+
events.once("didFinish", resolve);
|
|
2139
|
+
return promise;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
chunkC66X5FP6_cjs.__name(waitFinishAll, "waitFinishAll");
|
|
2143
|
+
function didFinish() {
|
|
2144
|
+
events.emit("didFinish");
|
|
2145
|
+
countMax = 0;
|
|
2146
|
+
countResolved = 0;
|
|
2147
|
+
}
|
|
2148
|
+
chunkC66X5FP6_cjs.__name(didFinish, "didFinish");
|
|
2149
|
+
function didUpdate() {
|
|
2150
|
+
let presentMax = 0;
|
|
2151
|
+
let presentResolved = 0;
|
|
2152
|
+
for (const { max, resolved, state } of Object.values(tasks)) {
|
|
2153
|
+
presentMax += max;
|
|
2154
|
+
presentResolved += state === 2 /* finished */ ? max : Math.min(max, resolved);
|
|
2155
|
+
}
|
|
2156
|
+
events.emit(
|
|
2157
|
+
"didUpdate",
|
|
2158
|
+
countMax,
|
|
2159
|
+
countResolved,
|
|
2160
|
+
presentMax,
|
|
2161
|
+
presentResolved
|
|
2162
|
+
);
|
|
2163
|
+
}
|
|
2164
|
+
chunkC66X5FP6_cjs.__name(didUpdate, "didUpdate");
|
|
2165
|
+
function performNext() {
|
|
2166
|
+
didUpdate();
|
|
2167
|
+
if (countMax > 0 && countMax === countResolved)
|
|
2168
|
+
didFinish();
|
|
2169
|
+
if (currentParallel >= maxParallel)
|
|
2170
|
+
return;
|
|
2171
|
+
let waitingTasks = Object.values(tasks).filter(
|
|
2172
|
+
(t) => t.state === 0 /* waiting */
|
|
2173
|
+
);
|
|
2174
|
+
if (waitingTasks.length > 0) {
|
|
2175
|
+
let taskInfo;
|
|
2176
|
+
for (let t of waitingTasks) {
|
|
2177
|
+
if (taskInfo == null || t.priority < taskInfo.priority) {
|
|
2178
|
+
taskInfo = t;
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
if (taskInfo != null) {
|
|
2182
|
+
const id = taskInfo.id;
|
|
2183
|
+
const done = taskInfo.done;
|
|
2184
|
+
taskInfo.state = 1 /* running */;
|
|
2185
|
+
++currentParallel;
|
|
2186
|
+
events.emit("didStart", id);
|
|
2187
|
+
const taskFinished = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((result) => {
|
|
2188
|
+
if (taskInfo) {
|
|
2189
|
+
taskInfo.result = result;
|
|
2190
|
+
taskInfo.state = 2 /* finished */;
|
|
2191
|
+
taskInfo.resolved = taskInfo.max;
|
|
2192
|
+
}
|
|
2193
|
+
--currentParallel;
|
|
2194
|
+
++countResolved;
|
|
2195
|
+
performNext();
|
|
2196
|
+
}, "taskFinished");
|
|
2197
|
+
taskInfo.task(taskInfo).then((r) => {
|
|
2198
|
+
done(r);
|
|
2199
|
+
events.emit("didResolve", id, r);
|
|
2200
|
+
taskFinished(r);
|
|
2201
|
+
}).catch((err) => {
|
|
2202
|
+
done();
|
|
2203
|
+
events.emit("didReject", id, err);
|
|
2204
|
+
taskFinished();
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
chunkC66X5FP6_cjs.__name(performNext, "performNext");
|
|
2210
|
+
function cancel(id) {
|
|
2211
|
+
let taskInfo = tasks[id];
|
|
2212
|
+
if (taskInfo && taskInfo.state === 0 /* waiting */) {
|
|
2213
|
+
tasks[id].state = 2 /* finished */;
|
|
2214
|
+
++countResolved;
|
|
2215
|
+
events.emit("didCancel", id);
|
|
2216
|
+
didUpdate();
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
chunkC66X5FP6_cjs.__name(cancel, "cancel");
|
|
2220
|
+
function cancelAll() {
|
|
2221
|
+
Object.keys(tasks).forEach(cancel);
|
|
2222
|
+
}
|
|
2223
|
+
chunkC66X5FP6_cjs.__name(cancelAll, "cancelAll");
|
|
2224
|
+
function enqueue(task, config2 = {}) {
|
|
2225
|
+
let done;
|
|
2226
|
+
let promise = new Promise((resolve) => done = resolve);
|
|
2227
|
+
let id = _nullishCoalesce(config2.id, () => ( uuid()));
|
|
2228
|
+
if (tasks[id] != null) {
|
|
2229
|
+
const resolution = _nullishCoalesce(config2.idConflictResolution, () => ( 1)) /* memoize */;
|
|
2230
|
+
if (resolution === 0 /* replace */) {
|
|
2231
|
+
cancel(id);
|
|
2232
|
+
} else if (resolution === 1 /* memoize */) {
|
|
2233
|
+
let runningTask = tasks[id];
|
|
2234
|
+
return {
|
|
2235
|
+
id,
|
|
2236
|
+
promise: (async () => {
|
|
2237
|
+
if (runningTask.state === 2 /* finished */) {
|
|
2238
|
+
return tasks[id].result;
|
|
2239
|
+
}
|
|
2240
|
+
})(),
|
|
2241
|
+
dispose: () => cancel(id),
|
|
2242
|
+
cancel: () => cancel(id)
|
|
2243
|
+
};
|
|
2244
|
+
} else {
|
|
2245
|
+
throw new Error(`Pool task with id=${id} already exists!`);
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
tasks[id] = {
|
|
2249
|
+
id,
|
|
2250
|
+
task,
|
|
2251
|
+
priority: ++priority,
|
|
2252
|
+
state: 0 /* waiting */,
|
|
2253
|
+
max: _nullishCoalesce(config2.max, () => ( 1)),
|
|
2254
|
+
resolved: _nullishCoalesce(config2.resolved, () => ( 0)),
|
|
2255
|
+
done,
|
|
2256
|
+
payload: config2.payload,
|
|
2257
|
+
setMax(max) {
|
|
2258
|
+
tasks[id].max = max;
|
|
2259
|
+
didUpdate();
|
|
2260
|
+
},
|
|
2261
|
+
setResolved(max) {
|
|
2262
|
+
tasks[id].resolved = max;
|
|
2263
|
+
didUpdate();
|
|
2264
|
+
},
|
|
2265
|
+
incResolved(inc = 1) {
|
|
2266
|
+
tasks[id].resolved += inc;
|
|
2267
|
+
didUpdate();
|
|
2268
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
++countMax;
|
|
2271
|
+
performNext();
|
|
2272
|
+
return {
|
|
2273
|
+
id,
|
|
2274
|
+
promise,
|
|
2275
|
+
dispose: () => cancel(id),
|
|
2276
|
+
cancel: () => cancel(id)
|
|
2277
|
+
};
|
|
2278
|
+
}
|
|
2279
|
+
chunkC66X5FP6_cjs.__name(enqueue, "enqueue");
|
|
2280
|
+
return {
|
|
2281
|
+
events,
|
|
2282
|
+
cancel,
|
|
2283
|
+
cancelAll,
|
|
2284
|
+
enqueue,
|
|
2285
|
+
dispose: cancelAll,
|
|
2286
|
+
waitFinishAll
|
|
2287
|
+
};
|
|
2288
|
+
}
|
|
2289
|
+
chunkC66X5FP6_cjs.__name(usePool, "usePool");
|
|
2290
|
+
|
|
2291
|
+
// src/common/exec/queue.ts
|
|
2292
|
+
var SerialQueue = class extends Emitter {
|
|
2293
|
+
constructor(opt = {}) {
|
|
2294
|
+
super();
|
|
2295
|
+
this.queue = [];
|
|
2296
|
+
this.waitToFinish = [];
|
|
2297
|
+
this.countMax = 0;
|
|
2298
|
+
this.countResolved = 0;
|
|
2299
|
+
this.paused = false;
|
|
2300
|
+
const { name = uname("queue"), logLevel } = opt;
|
|
2301
|
+
this.name = name;
|
|
2302
|
+
this.log = chunkC66X5FP6_cjs.Logger(`zeed:queue:${name}`, _nullishCoalesce(logLevel, () => ( Infinity)) /* off */);
|
|
2303
|
+
}
|
|
2304
|
+
async performNext() {
|
|
2305
|
+
this.log(`performNext, queue.length =`, this.queue.length);
|
|
2306
|
+
if (this.currentTask != null) {
|
|
2307
|
+
this.log(`performNext => skip while another task is running`);
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
if (this.paused) {
|
|
2311
|
+
this.log(`performNext => skip while is paused`);
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2314
|
+
while (this.currentTask == null && !this.paused) {
|
|
2315
|
+
let info = this.queue.shift();
|
|
2316
|
+
this.log(`performNext => ${info == null ? void 0 : info.name}`);
|
|
2317
|
+
if (info == null) {
|
|
2318
|
+
break;
|
|
2319
|
+
}
|
|
2320
|
+
if (this.countResolved === 0) {
|
|
2321
|
+
this.emit("didStart", this.countMax);
|
|
2322
|
+
}
|
|
2323
|
+
const { name, task, resolve } = info;
|
|
2324
|
+
this.currentTask = task();
|
|
2325
|
+
let result = void 0;
|
|
2326
|
+
try {
|
|
2327
|
+
this.log.info(`start task ${name}`);
|
|
2328
|
+
result = await this.currentTask;
|
|
2329
|
+
this.log(`finished task ${name} with result =`, result);
|
|
2330
|
+
} catch (err) {
|
|
2331
|
+
this.log.warn("Error performing task", err);
|
|
2332
|
+
}
|
|
2333
|
+
resolve(result);
|
|
2334
|
+
this.currentTask = void 0;
|
|
2335
|
+
this.countResolved += 1;
|
|
2336
|
+
this.emit("didUpdate", this.countMax, this.countResolved);
|
|
2337
|
+
}
|
|
2338
|
+
if (this.queue.length === 0) {
|
|
2339
|
+
this.emit("didFinish");
|
|
2340
|
+
this.countMax = 0;
|
|
2341
|
+
this.countResolved = 0;
|
|
2342
|
+
}
|
|
2343
|
+
while (this.waitToFinish.length > 0) {
|
|
2344
|
+
this.waitToFinish.shift()();
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
async enqueue(task, opt = {}) {
|
|
2348
|
+
const { immediate: immediate2 = false, name = uname(this.name) } = opt;
|
|
2349
|
+
if (immediate2) {
|
|
2350
|
+
this.log.info(`immediate execution ${name}`);
|
|
2351
|
+
return await task();
|
|
2352
|
+
}
|
|
2353
|
+
this.log(`enqueue ${name}`);
|
|
2354
|
+
return new Promise((resolve) => {
|
|
2355
|
+
this.queue.push({
|
|
2356
|
+
name,
|
|
2357
|
+
task,
|
|
2358
|
+
resolve
|
|
2359
|
+
});
|
|
2360
|
+
this.countMax += 1;
|
|
2361
|
+
this.emit("didUpdate", this.countMax, this.countResolved);
|
|
2362
|
+
this.performNext();
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
async enqueueReentrant(task, opt = {}) {
|
|
2366
|
+
return this.enqueue(task, {
|
|
2367
|
+
immediate: this.currentTask != null,
|
|
2368
|
+
name: opt.name
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
async cancelAll(unblock = true) {
|
|
2372
|
+
this.log(`cancelAll`);
|
|
2373
|
+
this.emit("didCancel");
|
|
2374
|
+
let resolver = this.queue.map((task) => task.resolve);
|
|
2375
|
+
this.queue = [];
|
|
2376
|
+
resolver.forEach((r) => r(void 0));
|
|
2377
|
+
await this.wait();
|
|
2378
|
+
}
|
|
2379
|
+
async pause() {
|
|
2380
|
+
this.log(`pause`);
|
|
2381
|
+
this.paused = true;
|
|
2382
|
+
await this.wait();
|
|
2383
|
+
}
|
|
2384
|
+
resume() {
|
|
2385
|
+
this.log(`resume`);
|
|
2386
|
+
this.paused = false;
|
|
2387
|
+
this.performNext();
|
|
2388
|
+
}
|
|
2389
|
+
async wait() {
|
|
2390
|
+
this.log(`wait`);
|
|
2391
|
+
if (this.currentTask == null && (this.queue.length === 0 || this.paused)) {
|
|
2392
|
+
return;
|
|
2393
|
+
}
|
|
2394
|
+
return new Promise((resolve) => {
|
|
2395
|
+
this.waitToFinish.push(resolve);
|
|
2396
|
+
});
|
|
2397
|
+
}
|
|
2398
|
+
get isPaused() {
|
|
2399
|
+
return this.paused;
|
|
2400
|
+
}
|
|
2401
|
+
get hasTasks() {
|
|
2402
|
+
return this.queue.length !== 0;
|
|
2403
|
+
}
|
|
2404
|
+
};
|
|
2405
|
+
chunkC66X5FP6_cjs.__name(SerialQueue, "SerialQueue");
|
|
2406
|
+
var log6 = () => {
|
|
2407
|
+
};
|
|
2408
|
+
function throttle(callback, opt = {}) {
|
|
2409
|
+
const { delay = 100, trailing = true, leading = true } = opt;
|
|
2410
|
+
let timeoutID = 0;
|
|
2411
|
+
let checkpoint = 0;
|
|
2412
|
+
let visited = 0;
|
|
2413
|
+
let trailingExec;
|
|
2414
|
+
let debugCheckpoint = Date.now();
|
|
2415
|
+
function clearExistingTimeout() {
|
|
2416
|
+
if (timeoutID) {
|
|
2417
|
+
clearTimeout(timeoutID);
|
|
2418
|
+
timeoutID = void 0;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
chunkC66X5FP6_cjs.__name(clearExistingTimeout, "clearExistingTimeout");
|
|
2422
|
+
function wrapper(...args) {
|
|
2423
|
+
const now = Date.now();
|
|
2424
|
+
let self2 = this;
|
|
2425
|
+
let elapsed = now - checkpoint;
|
|
2426
|
+
function debugElapsed() {
|
|
2427
|
+
const dnow = Date.now();
|
|
2428
|
+
return `total ${(dnow - debugCheckpoint).toFixed(1)}ms - elapsed ${(dnow - checkpoint).toFixed(1)}ms - visited ${visited}x`;
|
|
2429
|
+
}
|
|
2430
|
+
chunkC66X5FP6_cjs.__name(debugElapsed, "debugElapsed");
|
|
2431
|
+
function exec() {
|
|
2432
|
+
visited = 0;
|
|
2433
|
+
checkpoint = Date.now();
|
|
2434
|
+
callback.apply(self2, args);
|
|
2435
|
+
}
|
|
2436
|
+
chunkC66X5FP6_cjs.__name(exec, "exec");
|
|
2437
|
+
trailingExec = exec;
|
|
2438
|
+
if (elapsed > delay || !timeoutID) {
|
|
2439
|
+
if (leading) {
|
|
2440
|
+
if (elapsed > delay) {
|
|
2441
|
+
exec();
|
|
2442
|
+
} else {
|
|
2443
|
+
++visited;
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
const timeout2 = elapsed > delay ? delay : delay - elapsed;
|
|
2447
|
+
log6(`\u23F1 start timeout with ${timeout2.toFixed(1)}ms`, debugElapsed());
|
|
2448
|
+
clearExistingTimeout();
|
|
2449
|
+
checkpoint = now;
|
|
2450
|
+
timeoutID = setTimeout(() => {
|
|
2451
|
+
timeoutID = 0;
|
|
2452
|
+
if (trailing && (!leading || visited > 0)) {
|
|
2453
|
+
trailingExec == null ? void 0 : trailingExec();
|
|
2454
|
+
}
|
|
2455
|
+
}, timeout2);
|
|
2456
|
+
} else {
|
|
2457
|
+
++visited;
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
chunkC66X5FP6_cjs.__name(wrapper, "wrapper");
|
|
2461
|
+
wrapper.cancel = clearExistingTimeout;
|
|
2462
|
+
wrapper.dispose = clearExistingTimeout;
|
|
2463
|
+
return wrapper;
|
|
2464
|
+
}
|
|
2465
|
+
chunkC66X5FP6_cjs.__name(throttle, "throttle");
|
|
2466
|
+
function debounce(callback, opt = {}) {
|
|
2467
|
+
const { delay = 100 } = opt;
|
|
2468
|
+
let timeoutID = 0;
|
|
2469
|
+
function clearExistingTimeout() {
|
|
2470
|
+
if (timeoutID) {
|
|
2471
|
+
clearTimeout(timeoutID);
|
|
2472
|
+
timeoutID = 0;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
chunkC66X5FP6_cjs.__name(clearExistingTimeout, "clearExistingTimeout");
|
|
2476
|
+
function wrapper(...arguments_) {
|
|
2477
|
+
let self2 = this;
|
|
2478
|
+
clearExistingTimeout();
|
|
2479
|
+
timeoutID = setTimeout(() => {
|
|
2480
|
+
timeoutID = 0;
|
|
2481
|
+
callback.apply(self2, arguments_);
|
|
2482
|
+
}, delay);
|
|
2483
|
+
}
|
|
2484
|
+
chunkC66X5FP6_cjs.__name(wrapper, "wrapper");
|
|
2485
|
+
wrapper.cancel = clearExistingTimeout;
|
|
2486
|
+
wrapper.dispose = clearExistingTimeout;
|
|
2487
|
+
return wrapper;
|
|
2488
|
+
}
|
|
2489
|
+
chunkC66X5FP6_cjs.__name(debounce, "debounce");
|
|
2490
|
+
|
|
2491
|
+
// src/common/localhost.ts
|
|
2492
|
+
function isLocalHost(hostname = _nullishCoalesce(((_a) => (_a = globalThis == null ? void 0 : globalThis.location) == null ? void 0 : _a.hostname)(), () => ( ""))) {
|
|
2493
|
+
return ["::ffff:127.0.0.1", "localhost", "127.0.0.1", "", "::1", "::"].includes(
|
|
2494
|
+
hostname
|
|
2495
|
+
) || hostname.startsWith("192.168.") || hostname.startsWith("10.0.") || hostname.endsWith(".local");
|
|
2496
|
+
}
|
|
2497
|
+
chunkC66X5FP6_cjs.__name(isLocalHost, "isLocalHost");
|
|
2498
|
+
|
|
2499
|
+
// src/common/log-memory.ts
|
|
2500
|
+
function LoggerMemoryHandler(opt) {
|
|
2501
|
+
let { level = void 0, filter = void 0, messages: messages2 = [] } = opt;
|
|
2502
|
+
const matchesNamespace = chunkC66X5FP6_cjs.useNamespaceFilter(filter);
|
|
2503
|
+
const matchesLevel = chunkC66X5FP6_cjs.useLevelFilter(level);
|
|
2504
|
+
return (msg) => {
|
|
2505
|
+
if (!matchesLevel(msg.level))
|
|
2506
|
+
return;
|
|
2507
|
+
if (!matchesNamespace(msg.name))
|
|
2508
|
+
return;
|
|
2509
|
+
messages2.push(msg);
|
|
2510
|
+
};
|
|
2511
|
+
}
|
|
2512
|
+
chunkC66X5FP6_cjs.__name(LoggerMemoryHandler, "LoggerMemoryHandler");
|
|
2513
|
+
|
|
2514
|
+
// src/common/msg/channel.ts
|
|
2515
|
+
var Channel = class extends Emitter {
|
|
2516
|
+
constructor() {
|
|
2517
|
+
super(...arguments);
|
|
2518
|
+
this.id = uuid();
|
|
2519
|
+
}
|
|
2520
|
+
close() {
|
|
2521
|
+
this.dispose();
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
chunkC66X5FP6_cjs.__name(Channel, "Channel");
|
|
2525
|
+
var LocalChannel = class extends Channel {
|
|
2526
|
+
constructor() {
|
|
2527
|
+
super(...arguments);
|
|
2528
|
+
this.isConnected = true;
|
|
2529
|
+
}
|
|
2530
|
+
postMessage(data) {
|
|
2531
|
+
var _a;
|
|
2532
|
+
(_a = this.other) == null ? void 0 : _a.emit("message", {
|
|
2533
|
+
data,
|
|
2534
|
+
origin: "local",
|
|
2535
|
+
lastEventId: uuid()
|
|
2536
|
+
});
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
chunkC66X5FP6_cjs.__name(LocalChannel, "LocalChannel");
|
|
2540
|
+
function createLocalChannelPair() {
|
|
2541
|
+
let w1 = new LocalChannel();
|
|
2542
|
+
let w2 = new LocalChannel();
|
|
2543
|
+
w1.other = w2;
|
|
2544
|
+
w2.other = w1;
|
|
2545
|
+
return [w1, w2];
|
|
2546
|
+
}
|
|
2547
|
+
chunkC66X5FP6_cjs.__name(createLocalChannelPair, "createLocalChannelPair");
|
|
2548
|
+
|
|
2549
|
+
// src/common/msg/encoder.ts
|
|
2550
|
+
var NoopEncoder = class {
|
|
2551
|
+
async encode(data) {
|
|
2552
|
+
return data;
|
|
2553
|
+
}
|
|
2554
|
+
async decode(data) {
|
|
2555
|
+
return data;
|
|
2556
|
+
}
|
|
2557
|
+
};
|
|
2558
|
+
chunkC66X5FP6_cjs.__name(NoopEncoder, "NoopEncoder");
|
|
2559
|
+
var JsonEncoder = class {
|
|
2560
|
+
async encode(data) {
|
|
2561
|
+
return jsonToUint8Array(data);
|
|
2562
|
+
}
|
|
2563
|
+
async decode(data) {
|
|
2564
|
+
return Uint8ArrayToJson(data);
|
|
2565
|
+
}
|
|
2566
|
+
};
|
|
2567
|
+
chunkC66X5FP6_cjs.__name(JsonEncoder, "JsonEncoder");
|
|
2568
|
+
var CryptoEncoder = class {
|
|
2569
|
+
constructor(key) {
|
|
2570
|
+
this.key = key;
|
|
2571
|
+
}
|
|
2572
|
+
async encode(data) {
|
|
2573
|
+
const plain = jsonToUint8Array(data);
|
|
2574
|
+
return await encrypt(plain, this.key);
|
|
2575
|
+
}
|
|
2576
|
+
async decode(data) {
|
|
2577
|
+
const plain = await decrypt(data, this.key);
|
|
2578
|
+
return Uint8ArrayToJson(plain);
|
|
2579
|
+
}
|
|
2580
|
+
};
|
|
2581
|
+
chunkC66X5FP6_cjs.__name(CryptoEncoder, "CryptoEncoder");
|
|
2582
|
+
|
|
2583
|
+
// src/common/msg/messages.ts
|
|
2584
|
+
var createPromiseProxy = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((fn, opt, predefinedMethods = {}) => new Proxy(predefinedMethods, {
|
|
2585
|
+
get: (target, name) => {
|
|
2586
|
+
if (name in target)
|
|
2587
|
+
return target[name];
|
|
2588
|
+
return (...args) => fn(name, args, opt);
|
|
2589
|
+
}
|
|
2590
|
+
}), "createPromiseProxy");
|
|
2591
|
+
function useMessageHub(opt = {}) {
|
|
2592
|
+
let {
|
|
2593
|
+
name = uname("hub"),
|
|
2594
|
+
encoder = new JsonEncoder(),
|
|
2595
|
+
retryAfter = 1e3,
|
|
2596
|
+
ignoreUnhandled = true,
|
|
2597
|
+
logLevel = false
|
|
2598
|
+
} = opt;
|
|
2599
|
+
const log9 = chunkC66X5FP6_cjs.Logger(name, logLevel);
|
|
2600
|
+
let handlers = {};
|
|
2601
|
+
let channel;
|
|
2602
|
+
let queue = [];
|
|
2603
|
+
let queueRetryTimer;
|
|
2604
|
+
let waitingForResponse = {};
|
|
2605
|
+
const dispose = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(() => {
|
|
2606
|
+
clearTimeout(queueRetryTimer);
|
|
2607
|
+
}, "dispose");
|
|
2608
|
+
const postNext = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(async () => {
|
|
2609
|
+
clearTimeout(queueRetryTimer);
|
|
2610
|
+
if (channel) {
|
|
2611
|
+
if (channel.isConnected) {
|
|
2612
|
+
while (queue.length) {
|
|
2613
|
+
let message = queue[0];
|
|
2614
|
+
try {
|
|
2615
|
+
channel.postMessage(await encoder.encode(message));
|
|
2616
|
+
queue.shift();
|
|
2617
|
+
} catch (err) {
|
|
2618
|
+
log9.warn("postMessage", err);
|
|
2619
|
+
break;
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
if (queue.length > 0 && retryAfter > 0) {
|
|
2624
|
+
queueRetryTimer = setTimeout(postNext, retryAfter);
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
}, "postNext");
|
|
2628
|
+
const postMessage = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(async (message) => {
|
|
2629
|
+
log9("enqueue postMessage", message);
|
|
2630
|
+
queue.push(message);
|
|
2631
|
+
await postNext();
|
|
2632
|
+
}, "postMessage");
|
|
2633
|
+
const connect = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(async (newChannel) => {
|
|
2634
|
+
channel = newChannel;
|
|
2635
|
+
channel.on("connect", postNext);
|
|
2636
|
+
channel.on("message", async (msg) => {
|
|
2637
|
+
log9("onmessage", typeof msg);
|
|
2638
|
+
const { name: name2, args, id, result, error } = await encoder.decode(msg.data);
|
|
2639
|
+
if (name2) {
|
|
2640
|
+
log9(`name ${name2} id ${id}`);
|
|
2641
|
+
try {
|
|
2642
|
+
if (handlers[name2] == null) {
|
|
2643
|
+
throw new Error(`handler for ${name2} was not found`);
|
|
2644
|
+
}
|
|
2645
|
+
let result2 = handlers[name2](...args);
|
|
2646
|
+
if (isPromise(result2))
|
|
2647
|
+
result2 = await result2;
|
|
2648
|
+
log9(`result ${result2}`);
|
|
2649
|
+
if (id) {
|
|
2650
|
+
postMessage({ id, result: result2 });
|
|
2651
|
+
}
|
|
2652
|
+
} catch (error2) {
|
|
2653
|
+
let err = error2 instanceof Error ? error2 : new Error(valueToString(error2));
|
|
2654
|
+
log9.warn("execution error", err.name);
|
|
2655
|
+
postMessage({
|
|
2656
|
+
id,
|
|
2657
|
+
error: {
|
|
2658
|
+
message: err.message,
|
|
2659
|
+
stack: err.stack,
|
|
2660
|
+
name: err.name
|
|
2661
|
+
}
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2664
|
+
} else if (id) {
|
|
2665
|
+
log9(`response for id=${id}: result=${result}, error=${error}`);
|
|
2666
|
+
if (waitingForResponse[id] == null) {
|
|
2667
|
+
if (result === void 0) {
|
|
2668
|
+
log9(`skip response for ${id}`);
|
|
2669
|
+
} else {
|
|
2670
|
+
log9.warn(`no response hook for ${id}`);
|
|
2671
|
+
}
|
|
2672
|
+
} else {
|
|
2673
|
+
const [resolve, reject] = waitingForResponse[id];
|
|
2674
|
+
if (resolve && reject) {
|
|
2675
|
+
delete waitingForResponse[id];
|
|
2676
|
+
if (error) {
|
|
2677
|
+
let err = new Error(error.message);
|
|
2678
|
+
err.stack = error.stack;
|
|
2679
|
+
err.name = error.name;
|
|
2680
|
+
log9.warn("reject", err.name);
|
|
2681
|
+
reject(err);
|
|
2682
|
+
} else {
|
|
2683
|
+
log9("resolve", result);
|
|
2684
|
+
resolve(result);
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
} else if (!ignoreUnhandled) {
|
|
2689
|
+
log9.warn("Unhandled message", msg);
|
|
2690
|
+
}
|
|
2691
|
+
});
|
|
2692
|
+
postNext();
|
|
2693
|
+
}, "connect");
|
|
2694
|
+
const fetchMessage = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(async (name2, args, opt2 = {}) => {
|
|
2695
|
+
const { timeout: timeout2 = 5e3 } = opt2;
|
|
2696
|
+
const id = uuid();
|
|
2697
|
+
postMessage({
|
|
2698
|
+
name: name2,
|
|
2699
|
+
args,
|
|
2700
|
+
id
|
|
2701
|
+
});
|
|
2702
|
+
return tryTimeout(
|
|
2703
|
+
new Promise(
|
|
2704
|
+
(resolve, reject) => waitingForResponse[id] = [resolve, reject]
|
|
2705
|
+
),
|
|
2706
|
+
timeout2
|
|
2707
|
+
);
|
|
2708
|
+
}, "fetchMessage");
|
|
2709
|
+
if (opt.channel) {
|
|
2710
|
+
connect(opt.channel);
|
|
2711
|
+
}
|
|
2712
|
+
return {
|
|
2713
|
+
dispose,
|
|
2714
|
+
connect,
|
|
2715
|
+
listen(newHandlers) {
|
|
2716
|
+
Object.assign(handlers, newHandlers);
|
|
2717
|
+
},
|
|
2718
|
+
send() {
|
|
2719
|
+
return createPromiseProxy(fetchMessage, {}, {
|
|
2720
|
+
options(perCallopt) {
|
|
2721
|
+
return createPromiseProxy(fetchMessage, { ...perCallopt });
|
|
2722
|
+
}
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
};
|
|
2726
|
+
}
|
|
2727
|
+
chunkC66X5FP6_cjs.__name(useMessageHub, "useMessageHub");
|
|
2728
|
+
|
|
2729
|
+
// src/common/msg/pubsub.ts
|
|
2730
|
+
var PubSub = class extends Emitter {
|
|
2731
|
+
constructor(opt) {
|
|
2732
|
+
super();
|
|
2733
|
+
this.publish = this.emit;
|
|
2734
|
+
this.subscribe = this.on;
|
|
2735
|
+
let { name, encoder = new JsonEncoder(), channel, debug = false } = opt;
|
|
2736
|
+
this.channel = channel;
|
|
2737
|
+
this.encoder = encoder;
|
|
2738
|
+
this.debug = debug;
|
|
2739
|
+
this.name = _nullishCoalesce(_nullishCoalesce(name, () => ( this.channel.id)), () => ( uname("pubsub")));
|
|
2740
|
+
this.log = chunkC66X5FP6_cjs.Logger(`${this.shortId}`);
|
|
2741
|
+
if (this.debug) {
|
|
2742
|
+
this.channel.on("connect", () => {
|
|
2743
|
+
this.log("channel connected");
|
|
2744
|
+
});
|
|
2745
|
+
this.channel.on("disconnect", () => {
|
|
2746
|
+
this.log("channel disconnected");
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
this.channel.on("message", async ({ data }) => {
|
|
2750
|
+
let info = await this.encoder.decode(data);
|
|
2751
|
+
if (this.debug)
|
|
2752
|
+
this.log(`channel message, event=${info == null ? void 0 : info.event}, info=`, info);
|
|
2753
|
+
else
|
|
2754
|
+
this.log(`channel message, event=${info == null ? void 0 : info.event}`);
|
|
2755
|
+
if (info) {
|
|
2756
|
+
const { event, args } = info;
|
|
2757
|
+
await this.emitSuper(event, ...args);
|
|
2758
|
+
}
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2761
|
+
get shortId() {
|
|
2762
|
+
return this.name.substr(0, 6);
|
|
2763
|
+
}
|
|
2764
|
+
async emitSuper(event, ...args) {
|
|
2765
|
+
return await super.emit(event, ...args);
|
|
2766
|
+
}
|
|
2767
|
+
async emit(event, ...args) {
|
|
2768
|
+
try {
|
|
2769
|
+
if (this.debug)
|
|
2770
|
+
this.log(`emit(${String(event)})`, event);
|
|
2771
|
+
else
|
|
2772
|
+
this.log(`emit(${String(event)})`, args.length);
|
|
2773
|
+
if (!this.channel.isConnected) {
|
|
2774
|
+
this.log.warn("channel not connected");
|
|
2775
|
+
return false;
|
|
2776
|
+
}
|
|
2777
|
+
const data = await this.encoder.encode({ event, args });
|
|
2778
|
+
this.channel.postMessage(data);
|
|
2779
|
+
return true;
|
|
2780
|
+
} catch (err) {
|
|
2781
|
+
this.log.warn(`emit(${String(event)})`, err);
|
|
2782
|
+
}
|
|
2783
|
+
return false;
|
|
2784
|
+
}
|
|
2785
|
+
};
|
|
2786
|
+
chunkC66X5FP6_cjs.__name(PubSub, "PubSub");
|
|
2787
|
+
function usePubSub(opt) {
|
|
2788
|
+
return new PubSub(opt);
|
|
2789
|
+
}
|
|
2790
|
+
chunkC66X5FP6_cjs.__name(usePubSub, "usePubSub");
|
|
2791
|
+
|
|
2792
|
+
// src/common/msg/rpc.ts
|
|
2793
|
+
var rpcCounter = 1;
|
|
2794
|
+
var defaultSerialize = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((i) => i, "defaultSerialize");
|
|
2795
|
+
var defaultDeserialize = defaultSerialize;
|
|
2796
|
+
function useRPC(functions, options) {
|
|
2797
|
+
const {
|
|
2798
|
+
post,
|
|
2799
|
+
on,
|
|
2800
|
+
eventNames = [],
|
|
2801
|
+
serialize = defaultSerialize,
|
|
2802
|
+
deserialize = defaultDeserialize
|
|
2803
|
+
} = options;
|
|
2804
|
+
const rpcPromiseMap = /* @__PURE__ */ new Map();
|
|
2805
|
+
on(async (data) => {
|
|
2806
|
+
const msg = deserialize(data);
|
|
2807
|
+
const [mode, args, id, method] = msg;
|
|
2808
|
+
if (mode === 1 /* request */ || mode === 2 /* event */) {
|
|
2809
|
+
let result, error;
|
|
2810
|
+
if (method != null) {
|
|
2811
|
+
try {
|
|
2812
|
+
result = await functions[method](...args);
|
|
2813
|
+
} catch (e) {
|
|
2814
|
+
error = String(e);
|
|
2815
|
+
}
|
|
2816
|
+
} else {
|
|
2817
|
+
error = "Method implementation missing";
|
|
2818
|
+
}
|
|
2819
|
+
if (mode === 1 /* request */ && id) {
|
|
2820
|
+
if (error) {
|
|
2821
|
+
post(serialize([4 /* reject */, error, id]));
|
|
2822
|
+
} else {
|
|
2823
|
+
post(serialize([3 /* resolve */, result, id]));
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
} else if (id) {
|
|
2827
|
+
const promise = rpcPromiseMap.get(id);
|
|
2828
|
+
if (promise != null) {
|
|
2829
|
+
if (mode === 4 /* reject */)
|
|
2830
|
+
promise.reject(args);
|
|
2831
|
+
else
|
|
2832
|
+
promise.resolve(args);
|
|
2833
|
+
}
|
|
2834
|
+
rpcPromiseMap.delete(id);
|
|
2835
|
+
}
|
|
2836
|
+
});
|
|
2837
|
+
return new Proxy(
|
|
2838
|
+
{},
|
|
2839
|
+
{
|
|
2840
|
+
get(_, method) {
|
|
2841
|
+
const sendEvent = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((...args) => {
|
|
2842
|
+
post(serialize([2 /* event */, args, null, method]));
|
|
2843
|
+
}, "sendEvent");
|
|
2844
|
+
if (options.onlyEvents || eventNames.includes(method)) {
|
|
2845
|
+
sendEvent.asEvent = sendEvent;
|
|
2846
|
+
return sendEvent;
|
|
2847
|
+
}
|
|
2848
|
+
const sendCall = /* @__PURE__ */ chunkC66X5FP6_cjs.__name((...args) => {
|
|
2849
|
+
return new Promise((resolve, reject) => {
|
|
2850
|
+
const id = rpcCounter++;
|
|
2851
|
+
rpcPromiseMap.set(id, { resolve, reject });
|
|
2852
|
+
post(serialize([1 /* request */, args, id, method]));
|
|
2853
|
+
});
|
|
2854
|
+
}, "sendCall");
|
|
2855
|
+
sendCall.asEvent = sendEvent;
|
|
2856
|
+
return sendCall;
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
);
|
|
2860
|
+
}
|
|
2861
|
+
chunkC66X5FP6_cjs.__name(useRPC, "useRPC");
|
|
2862
|
+
|
|
2863
|
+
// src/common/network.ts
|
|
2864
|
+
var log7 = chunkC66X5FP6_cjs.Logger("network");
|
|
2865
|
+
var defaultOptions = {
|
|
2866
|
+
cache: "no-cache",
|
|
2867
|
+
redirect: "follow",
|
|
2868
|
+
headers: {}
|
|
2869
|
+
};
|
|
2870
|
+
function parseBasicAuth(url) {
|
|
2871
|
+
let m = /:\/\/([^@]*)@/gi.exec(url);
|
|
2872
|
+
if (m && m[1]) {
|
|
2873
|
+
let [username, password] = m[1].split(":", 2);
|
|
2874
|
+
return {
|
|
2875
|
+
url: url.replace(m[1] + "@", ""),
|
|
2876
|
+
username,
|
|
2877
|
+
password
|
|
2878
|
+
};
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
chunkC66X5FP6_cjs.__name(parseBasicAuth, "parseBasicAuth");
|
|
2882
|
+
async function fetchBasic(url, fetchOptions = {}, fetchFn = fetch) {
|
|
2883
|
+
try {
|
|
2884
|
+
if (chunkC66X5FP6_cjs.isArray(fetchOptions)) {
|
|
2885
|
+
fetchOptions = chunkC66X5FP6_cjs.deepMerge({}, ...arrayFlatten(fetchOptions));
|
|
2886
|
+
}
|
|
2887
|
+
let auth = parseBasicAuth(String(url));
|
|
2888
|
+
if (auth) {
|
|
2889
|
+
url = auth.url;
|
|
2890
|
+
fetchOptions = chunkC66X5FP6_cjs.deepMerge(
|
|
2891
|
+
{},
|
|
2892
|
+
fetchOptions,
|
|
2893
|
+
fetchOptionsBasicAuth(auth.username, auth.password)
|
|
2894
|
+
);
|
|
2895
|
+
}
|
|
2896
|
+
if (fetchOptions.headers != null && !(fetchOptions.headers instanceof Headers)) {
|
|
2897
|
+
fetchOptions.headers = new Headers(fetchOptions.headers);
|
|
2898
|
+
}
|
|
2899
|
+
log7("fetch", url, fetchOptions);
|
|
2900
|
+
const response = await fetchFn(String(url), fetchOptions);
|
|
2901
|
+
if (response.status < 400) {
|
|
2902
|
+
return response;
|
|
2903
|
+
}
|
|
2904
|
+
try {
|
|
2905
|
+
log7.warn(
|
|
2906
|
+
`Fetch of ${url} with ${fetchOptions} returned status=${response.status}`
|
|
2907
|
+
);
|
|
2908
|
+
log7.warn(`Response: ${await response.text()}`);
|
|
2909
|
+
} catch (err) {
|
|
2910
|
+
log7.error("Exception:", err);
|
|
2911
|
+
}
|
|
2912
|
+
} catch (err) {
|
|
2913
|
+
log7.error("fetchBasic", err);
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
chunkC66X5FP6_cjs.__name(fetchBasic, "fetchBasic");
|
|
2917
|
+
async function fetchJson(url, fetchOptions = {}, fetchFn = fetch) {
|
|
2918
|
+
try {
|
|
2919
|
+
let res = await fetchBasic(
|
|
2920
|
+
url,
|
|
2921
|
+
[
|
|
2922
|
+
{
|
|
2923
|
+
method: "GET",
|
|
2924
|
+
headers: {
|
|
2925
|
+
Accept: "application/json"
|
|
2926
|
+
}
|
|
2927
|
+
},
|
|
2928
|
+
fetchOptions
|
|
2929
|
+
],
|
|
2930
|
+
fetchFn
|
|
2931
|
+
);
|
|
2932
|
+
if (res) {
|
|
2933
|
+
return await res.json();
|
|
2934
|
+
}
|
|
2935
|
+
} catch (err) {
|
|
2936
|
+
log7.error("fetchJSON error:", err);
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
chunkC66X5FP6_cjs.__name(fetchJson, "fetchJson");
|
|
2940
|
+
async function fetchText(url, fetchOptions = {}, fetchFn = fetch) {
|
|
2941
|
+
try {
|
|
2942
|
+
let res = await fetchBasic(
|
|
2943
|
+
url,
|
|
2944
|
+
[defaultOptions, { method: "GET" }, fetchOptions],
|
|
2945
|
+
fetchFn
|
|
2946
|
+
);
|
|
2947
|
+
if (res) {
|
|
2948
|
+
return await res.text();
|
|
2949
|
+
}
|
|
2950
|
+
} catch (err) {
|
|
2951
|
+
log7.error("fetchHTML error:", err);
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
chunkC66X5FP6_cjs.__name(fetchText, "fetchText");
|
|
2955
|
+
function fetchOptionsFormURLEncoded(data, method = "POST") {
|
|
2956
|
+
return {
|
|
2957
|
+
method,
|
|
2958
|
+
...defaultOptions,
|
|
2959
|
+
headers: {
|
|
2960
|
+
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
|
|
2961
|
+
},
|
|
2962
|
+
body: encodeQuery(data)
|
|
2963
|
+
};
|
|
2964
|
+
}
|
|
2965
|
+
chunkC66X5FP6_cjs.__name(fetchOptionsFormURLEncoded, "fetchOptionsFormURLEncoded");
|
|
2966
|
+
function fetchOptionsJson(data, method = "POST") {
|
|
2967
|
+
return {
|
|
2968
|
+
method,
|
|
2969
|
+
...defaultOptions,
|
|
2970
|
+
headers: {
|
|
2971
|
+
"Content-Type": "application/json; charset=utf-8"
|
|
2972
|
+
},
|
|
2973
|
+
body: JSON.stringify(data)
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
chunkC66X5FP6_cjs.__name(fetchOptionsJson, "fetchOptionsJson");
|
|
2977
|
+
function fetchOptionsBasicAuth(username, password) {
|
|
2978
|
+
return {
|
|
2979
|
+
headers: {
|
|
2980
|
+
Authorization: "Basic " + toBase64(username + ":" + password)
|
|
2981
|
+
}
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
chunkC66X5FP6_cjs.__name(fetchOptionsBasicAuth, "fetchOptionsBasicAuth");
|
|
2985
|
+
|
|
2986
|
+
// src/common/platform.ts
|
|
2987
|
+
function getWindow() {
|
|
2988
|
+
if (typeof window !== "undefined")
|
|
2989
|
+
return window;
|
|
2990
|
+
}
|
|
2991
|
+
chunkC66X5FP6_cjs.__name(getWindow, "getWindow");
|
|
2992
|
+
function getNavigator() {
|
|
2993
|
+
if (typeof navigator !== "undefined")
|
|
2994
|
+
return navigator;
|
|
2995
|
+
}
|
|
2996
|
+
chunkC66X5FP6_cjs.__name(getNavigator, "getNavigator");
|
|
2997
|
+
function getGlobal() {
|
|
2998
|
+
return _nullishCoalesce(getWindow(), () => ( typeof WorkerGlobalScope !== "undefined")) ? self : typeof global !== "undefined" ? global : Function("return this;")();
|
|
2999
|
+
}
|
|
3000
|
+
chunkC66X5FP6_cjs.__name(getGlobal, "getGlobal");
|
|
3001
|
+
var _navigator = getNavigator();
|
|
3002
|
+
var _window = getWindow();
|
|
3003
|
+
function detect(info = {
|
|
3004
|
+
ios: false,
|
|
3005
|
+
macos: false,
|
|
3006
|
+
windows: false,
|
|
3007
|
+
beaker: false,
|
|
3008
|
+
electron: false,
|
|
3009
|
+
wkwebview: false,
|
|
3010
|
+
pwa: false,
|
|
3011
|
+
pwaInstalled: false,
|
|
3012
|
+
browser: false,
|
|
3013
|
+
node: false,
|
|
3014
|
+
worker: false,
|
|
3015
|
+
test: false,
|
|
3016
|
+
jest: false,
|
|
3017
|
+
macosNative: false,
|
|
3018
|
+
iosNative: false,
|
|
3019
|
+
appleNative: false,
|
|
3020
|
+
touch: false
|
|
3021
|
+
}) {
|
|
3022
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
3023
|
+
info.ios = ((_a = _navigator == null ? void 0 : _navigator.platform) == null ? void 0 : _a.match(/(iPhone|iPod|iPad)/i)) != null;
|
|
3024
|
+
info.macos = !!((_b = _navigator == null ? void 0 : _navigator.platform) == null ? void 0 : _b.startsWith("Mac"));
|
|
3025
|
+
info.windows = !!((_c = _navigator == null ? void 0 : _navigator.platform) == null ? void 0 : _c.startsWith("Win"));
|
|
3026
|
+
info.beaker = (_window == null ? void 0 : _window["beaker"]) != null;
|
|
3027
|
+
info.electron = (((_e = (_d = _navigator == null ? void 0 : _navigator.userAgent) == null ? void 0 : _d.toLowerCase()) == null ? void 0 : _e.indexOf(" electron/")) || -1) > -1 && !info.beaker;
|
|
3028
|
+
info.wkwebview = ((_f = _window == null ? void 0 : _window.webkit) == null ? void 0 : _f["messageHandlers"]) != null;
|
|
3029
|
+
info.pwa = (_navigator == null ? void 0 : _navigator.serviceWorker) != null;
|
|
3030
|
+
info.pwaInstalled = (_navigator == null ? void 0 : _navigator.standalone) || ((_h = (_g = _window == null ? void 0 : _window.matchMedia) == null ? void 0 : _g.call(_window, "(display-mode: standalone)")) == null ? void 0 : _h.matches);
|
|
3031
|
+
info.node = typeof process !== "undefined" && ((_i = process == null ? void 0 : process.release) == null ? void 0 : _i.name) === "node";
|
|
3032
|
+
info.browser = !info.electron && !info.wkwebview && !info.node;
|
|
3033
|
+
info.worker = typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
|
|
3034
|
+
info.jest = typeof jest !== "undefined" || typeof vitest !== "undefined";
|
|
3035
|
+
info.test = info.jest;
|
|
3036
|
+
info.macosNative = info.wkwebview && info.macos;
|
|
3037
|
+
info.iosNative = info.wkwebview && info.ios;
|
|
3038
|
+
info.appleNative = info.wkwebview;
|
|
3039
|
+
info.touch = _window && "ontouchstart" in _window || ((_navigator == null ? void 0 : _navigator.maxTouchPoints) || 0) > 1 || (_navigator == null ? void 0 : _navigator.msPointerEnabled) && (_window == null ? void 0 : _window.MSGesture) || (_window == null ? void 0 : _window.DocumentTouch) && document instanceof DocumentTouch;
|
|
3040
|
+
return info;
|
|
3041
|
+
}
|
|
3042
|
+
chunkC66X5FP6_cjs.__name(detect, "detect");
|
|
3043
|
+
var isBrowser = /* @__PURE__ */ chunkC66X5FP6_cjs.__name(() => typeof window !== "undefined" && globalThis === window, "isBrowser");
|
|
3044
|
+
var platform = detect();
|
|
3045
|
+
function useExitHandler(handler) {
|
|
3046
|
+
if (isBrowser()) {
|
|
3047
|
+
window.addEventListener("beforeunload", handler);
|
|
3048
|
+
} else if (typeof process !== "undefined") {
|
|
3049
|
+
process.on("exit", () => handler);
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
chunkC66X5FP6_cjs.__name(useExitHandler, "useExitHandler");
|
|
3053
|
+
|
|
3054
|
+
// src/common/storage/memstorage.ts
|
|
3055
|
+
chunkC66X5FP6_cjs.Logger("zeed:memstorage");
|
|
3056
|
+
var MemStorage = class {
|
|
3057
|
+
constructor(opt = {}) {
|
|
3058
|
+
this.store = {};
|
|
3059
|
+
}
|
|
3060
|
+
setItem(key, value) {
|
|
3061
|
+
this.store[key] = cloneObject(value);
|
|
3062
|
+
}
|
|
3063
|
+
getItem(key) {
|
|
3064
|
+
if (this.store.hasOwnProperty(key)) {
|
|
3065
|
+
return cloneObject(this.store[key]);
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
removeItem(key) {
|
|
3069
|
+
delete this.store[key];
|
|
3070
|
+
}
|
|
3071
|
+
clear() {
|
|
3072
|
+
this.store = {};
|
|
3073
|
+
}
|
|
3074
|
+
allKeys() {
|
|
3075
|
+
return Object.keys(this.store);
|
|
3076
|
+
}
|
|
3077
|
+
};
|
|
3078
|
+
chunkC66X5FP6_cjs.__name(MemStorage, "MemStorage");
|
|
3079
|
+
|
|
3080
|
+
exports.Channel = Channel;
|
|
3081
|
+
exports.CryptoEncoder = CryptoEncoder;
|
|
3082
|
+
exports.Currency = Currency;
|
|
3083
|
+
exports.DAY_MS = DAY_MS;
|
|
3084
|
+
exports.Day = Day;
|
|
3085
|
+
exports.Emitter = Emitter;
|
|
3086
|
+
exports.JsonEncoder = JsonEncoder;
|
|
3087
|
+
exports.LocalChannel = LocalChannel;
|
|
3088
|
+
exports.LoggerMemoryHandler = LoggerMemoryHandler;
|
|
3089
|
+
exports.MemStorage = MemStorage;
|
|
3090
|
+
exports.NoopEncoder = NoopEncoder;
|
|
3091
|
+
exports.PoolTaskIdConflictResolution = PoolTaskIdConflictResolution;
|
|
3092
|
+
exports.PoolTaskState = PoolTaskState;
|
|
3093
|
+
exports.PubSub = PubSub;
|
|
3094
|
+
exports.SerialQueue = SerialQueue;
|
|
3095
|
+
exports.Uint8ArrayToHexDump = Uint8ArrayToHexDump;
|
|
3096
|
+
exports.Uint8ArrayToJson = Uint8ArrayToJson;
|
|
3097
|
+
exports.Uint8ArrayToString = Uint8ArrayToString;
|
|
3098
|
+
exports.XRX = XRX;
|
|
3099
|
+
exports._decodeUtf8Polyfill = _decodeUtf8Polyfill;
|
|
3100
|
+
exports._encodeUtf8Polyfill = _encodeUtf8Polyfill;
|
|
3101
|
+
exports.arrayAvg = arrayAvg;
|
|
3102
|
+
exports.arrayBatches = arrayBatches;
|
|
3103
|
+
exports.arrayEmptyInPlace = arrayEmptyInPlace;
|
|
3104
|
+
exports.arrayFilterInPlace = arrayFilterInPlace;
|
|
3105
|
+
exports.arrayFlatten = arrayFlatten;
|
|
3106
|
+
exports.arrayIntersection = arrayIntersection;
|
|
3107
|
+
exports.arrayIsEqual = arrayIsEqual;
|
|
3108
|
+
exports.arrayMax = arrayMax;
|
|
3109
|
+
exports.arrayMin = arrayMin;
|
|
3110
|
+
exports.arrayMinus = arrayMinus;
|
|
3111
|
+
exports.arrayRandomElement = arrayRandomElement;
|
|
3112
|
+
exports.arrayRemoveElement = arrayRemoveElement;
|
|
3113
|
+
exports.arraySetElement = arraySetElement;
|
|
3114
|
+
exports.arrayShuffle = arrayShuffle;
|
|
3115
|
+
exports.arrayShuffleForce = arrayShuffleForce;
|
|
3116
|
+
exports.arrayShuffleInPlace = arrayShuffleInPlace;
|
|
3117
|
+
exports.arraySorted = arraySorted;
|
|
3118
|
+
exports.arraySortedNumbers = arraySortedNumbers;
|
|
3119
|
+
exports.arraySum = arraySum;
|
|
3120
|
+
exports.arraySymmetricDifference = arraySymmetricDifference;
|
|
3121
|
+
exports.arrayToggleInPlace = arrayToggleInPlace;
|
|
3122
|
+
exports.arrayUnion = arrayUnion;
|
|
3123
|
+
exports.arrayUnique = arrayUnique;
|
|
3124
|
+
exports.avg = avg;
|
|
3125
|
+
exports.between = between;
|
|
3126
|
+
exports.cloneJsonObject = cloneJsonObject;
|
|
3127
|
+
exports.cloneObject = cloneObject;
|
|
3128
|
+
exports.cmp = cmp;
|
|
3129
|
+
exports.composeOrderby = composeOrderby;
|
|
3130
|
+
exports.createArray = createArray;
|
|
3131
|
+
exports.createLocalChannelPair = createLocalChannelPair;
|
|
3132
|
+
exports.createPromise = createPromise;
|
|
3133
|
+
exports.createPromiseProxy = createPromiseProxy;
|
|
3134
|
+
exports.csv = csv;
|
|
3135
|
+
exports.currency = currency;
|
|
3136
|
+
exports.dateStringToDays = dateStringToDays;
|
|
3137
|
+
exports.day = day;
|
|
3138
|
+
exports.dayDay = dayDay;
|
|
3139
|
+
exports.dayDiff = dayDiff;
|
|
3140
|
+
exports.dayFromAny = dayFromAny;
|
|
3141
|
+
exports.dayFromDate = dayFromDate;
|
|
3142
|
+
exports.dayFromDateGMT = dayFromDateGMT;
|
|
3143
|
+
exports.dayFromParts = dayFromParts;
|
|
3144
|
+
exports.dayFromString = dayFromString;
|
|
3145
|
+
exports.dayFromTimestamp = dayFromTimestamp;
|
|
3146
|
+
exports.dayFromToday = dayFromToday;
|
|
3147
|
+
exports.dayMonth = dayMonth;
|
|
3148
|
+
exports.dayMonthStart = dayMonthStart;
|
|
3149
|
+
exports.dayOffset = dayOffset;
|
|
3150
|
+
exports.dayToDate = dayToDate;
|
|
3151
|
+
exports.dayToDateGMT = dayToDateGMT;
|
|
3152
|
+
exports.dayToParts = dayToParts;
|
|
3153
|
+
exports.dayToString = dayToString;
|
|
3154
|
+
exports.dayToTimestamp = dayToTimestamp;
|
|
3155
|
+
exports.dayYear = dayYear;
|
|
3156
|
+
exports.dayYearStart = dayYearStart;
|
|
3157
|
+
exports.debounce = debounce;
|
|
3158
|
+
exports.decimal = decimal;
|
|
3159
|
+
exports.decimalCentsPart = decimalCentsPart;
|
|
3160
|
+
exports.decimalFromCents = decimalFromCents;
|
|
3161
|
+
exports.decimalToCents = decimalToCents;
|
|
3162
|
+
exports.decodeBase16 = decodeBase16;
|
|
3163
|
+
exports.decodeBase32 = decodeBase32;
|
|
3164
|
+
exports.decodeBase58 = decodeBase58;
|
|
3165
|
+
exports.decodeBase62 = decodeBase62;
|
|
3166
|
+
exports.decodeBase64 = decodeBase64;
|
|
3167
|
+
exports.decrypt = decrypt;
|
|
3168
|
+
exports.deriveKeyPbkdf2 = deriveKeyPbkdf2;
|
|
3169
|
+
exports.detect = detect;
|
|
3170
|
+
exports.digest = digest;
|
|
3171
|
+
exports.empty = empty;
|
|
3172
|
+
exports.encodeBase16 = encodeBase16;
|
|
3173
|
+
exports.encodeBase32 = encodeBase32;
|
|
3174
|
+
exports.encodeBase58 = encodeBase58;
|
|
3175
|
+
exports.encodeBase62 = encodeBase62;
|
|
3176
|
+
exports.encodeBase64 = encodeBase64;
|
|
3177
|
+
exports.encodeQuery = encodeQuery;
|
|
3178
|
+
exports.encrypt = encrypt;
|
|
3179
|
+
exports.endSortWeight = endSortWeight;
|
|
3180
|
+
exports.ensureKey = ensureKey;
|
|
3181
|
+
exports.ensureKeyAsync = ensureKeyAsync;
|
|
3182
|
+
exports.equalBinary = equalBinary;
|
|
3183
|
+
exports.escapeHTML = escapeHTML;
|
|
3184
|
+
exports.escapeRegExp = escapeRegExp;
|
|
3185
|
+
exports.fetchBasic = fetchBasic;
|
|
3186
|
+
exports.fetchJson = fetchJson;
|
|
3187
|
+
exports.fetchOptionsBasicAuth = fetchOptionsBasicAuth;
|
|
3188
|
+
exports.fetchOptionsFormURLEncoded = fetchOptionsFormURLEncoded;
|
|
3189
|
+
exports.fetchOptionsJson = fetchOptionsJson;
|
|
3190
|
+
exports.fetchText = fetchText;
|
|
3191
|
+
exports.fixBrokenUth8String = fixBrokenUth8String;
|
|
3192
|
+
exports.forEachDay = forEachDay;
|
|
3193
|
+
exports.forTimes = forTimes;
|
|
3194
|
+
exports.formatMessages = formatMessages;
|
|
3195
|
+
exports.fromBase64 = fromBase64;
|
|
3196
|
+
exports.fromCamelCase = fromCamelCase;
|
|
3197
|
+
exports.getGlobal = getGlobal;
|
|
3198
|
+
exports.getGlobalEmitter = getGlobalEmitter;
|
|
3199
|
+
exports.getNavigator = getNavigator;
|
|
3200
|
+
exports.getSecureRandom = getSecureRandom;
|
|
3201
|
+
exports.getSecureRandomIfPossible = getSecureRandomIfPossible;
|
|
3202
|
+
exports.getWindow = getWindow;
|
|
3203
|
+
exports.immediate = immediate;
|
|
3204
|
+
exports.isBrowser = isBrowser;
|
|
3205
|
+
exports.isEven = isEven;
|
|
3206
|
+
exports.isHalf = isHalf;
|
|
3207
|
+
exports.isLocalHost = isLocalHost;
|
|
3208
|
+
exports.isPrime = isPrime;
|
|
3209
|
+
exports.isPrimeRX = isPrimeRX;
|
|
3210
|
+
exports.isPromise = isPromise;
|
|
3211
|
+
exports.isTimeout = isTimeout;
|
|
3212
|
+
exports.joinToUint8Array = joinToUint8Array;
|
|
3213
|
+
exports.jsonStringify = jsonStringify;
|
|
3214
|
+
exports.jsonToUint8Array = jsonToUint8Array;
|
|
3215
|
+
exports.last = last;
|
|
3216
|
+
exports.lazyListener = lazyListener;
|
|
3217
|
+
exports.linkifyPlainText = linkifyPlainText;
|
|
3218
|
+
exports.memoize = memoize;
|
|
3219
|
+
exports.messages = messages;
|
|
3220
|
+
exports.moveSortWeight = moveSortWeight;
|
|
3221
|
+
exports.parseBasicAuth = parseBasicAuth;
|
|
3222
|
+
exports.parseOrderby = parseOrderby;
|
|
3223
|
+
exports.parseQuery = parseQuery;
|
|
3224
|
+
exports.platform = platform;
|
|
3225
|
+
exports.promisify = promisify;
|
|
3226
|
+
exports.qid = qid;
|
|
3227
|
+
exports.randomBoolean = randomBoolean;
|
|
3228
|
+
exports.randomFloat = randomFloat;
|
|
3229
|
+
exports.randomInt = randomInt;
|
|
3230
|
+
exports.randomUint8Array = randomUint8Array;
|
|
3231
|
+
exports.regExpEscape = regExpEscape;
|
|
3232
|
+
exports.regExpString = regExpString;
|
|
3233
|
+
exports.renderMessages = renderMessages;
|
|
3234
|
+
exports.roundDown = roundDown;
|
|
3235
|
+
exports.roundHalfAwayFromZero = roundHalfAwayFromZero;
|
|
3236
|
+
exports.roundHalfDown = roundHalfDown;
|
|
3237
|
+
exports.roundHalfEven = roundHalfEven;
|
|
3238
|
+
exports.roundHalfOdd = roundHalfOdd;
|
|
3239
|
+
exports.roundHalfTowardsZero = roundHalfTowardsZero;
|
|
3240
|
+
exports.roundHalfUp = roundHalfUp;
|
|
3241
|
+
exports.roundUp = roundUp;
|
|
3242
|
+
exports.size = size;
|
|
3243
|
+
exports.sleep = sleep;
|
|
3244
|
+
exports.sortedItems = sortedItems;
|
|
3245
|
+
exports.sortedOrderby = sortedOrderby;
|
|
3246
|
+
exports.startSortWeight = startSortWeight;
|
|
3247
|
+
exports.stringToBoolean = stringToBoolean;
|
|
3248
|
+
exports.stringToFloat = stringToFloat;
|
|
3249
|
+
exports.stringToInteger = stringToInteger;
|
|
3250
|
+
exports.stringToUInt8Array = stringToUInt8Array;
|
|
3251
|
+
exports.suid = suid;
|
|
3252
|
+
exports.suidBytes = suidBytes;
|
|
3253
|
+
exports.suidBytesDate = suidBytesDate;
|
|
3254
|
+
exports.suidDate = suidDate;
|
|
3255
|
+
exports.sum = sum;
|
|
3256
|
+
exports.throttle = throttle;
|
|
3257
|
+
exports.timeout = timeout;
|
|
3258
|
+
exports.timeoutReached = timeoutReached;
|
|
3259
|
+
exports.timoutError = timoutError;
|
|
3260
|
+
exports.toBase64 = toBase64;
|
|
3261
|
+
exports.toBase64Url = toBase64Url;
|
|
3262
|
+
exports.toBool = toBool;
|
|
3263
|
+
exports.toCamelCase = toCamelCase;
|
|
3264
|
+
exports.toCapitalize = toCapitalize;
|
|
3265
|
+
exports.toCapitalizeWords = toCapitalizeWords;
|
|
3266
|
+
exports.toFloat = toFloat;
|
|
3267
|
+
exports.toHex = toHex;
|
|
3268
|
+
exports.toHumanReadableUrl = toHumanReadableUrl;
|
|
3269
|
+
exports.toInt = toInt;
|
|
3270
|
+
exports.toString = toString;
|
|
3271
|
+
exports.toUint8Array = toUint8Array;
|
|
3272
|
+
exports.toValidFilename = toValidFilename;
|
|
3273
|
+
exports.today = today;
|
|
3274
|
+
exports.tryTimeout = tryTimeout;
|
|
3275
|
+
exports.uname = uname;
|
|
3276
|
+
exports.unescapeHTML = unescapeHTML;
|
|
3277
|
+
exports.useAsyncMutex = useAsyncMutex;
|
|
3278
|
+
exports.useBase = useBase;
|
|
3279
|
+
exports.useDefer = useDefer;
|
|
3280
|
+
exports.useDispose = useDispose;
|
|
3281
|
+
exports.useDisposer = useDisposer;
|
|
3282
|
+
exports.useEventListener = useEventListener;
|
|
3283
|
+
exports.useExitHandler = useExitHandler;
|
|
3284
|
+
exports.useInterval = useInterval;
|
|
3285
|
+
exports.useMessageHub = useMessageHub;
|
|
3286
|
+
exports.useMutex = useMutex;
|
|
3287
|
+
exports.usePool = usePool;
|
|
3288
|
+
exports.usePubSub = usePubSub;
|
|
3289
|
+
exports.useRPC = useRPC;
|
|
3290
|
+
exports.useTimeout = useTimeout;
|
|
3291
|
+
exports.uuid = uuid;
|
|
3292
|
+
exports.uuid32Decode = uuid32Decode;
|
|
3293
|
+
exports.uuid32Encode = uuid32Encode;
|
|
3294
|
+
exports.uuid32bit = uuid32bit;
|
|
3295
|
+
exports.uuidB32 = uuidB32;
|
|
3296
|
+
exports.uuidBytes = uuidBytes;
|
|
3297
|
+
exports.uuidDecode = uuidDecode;
|
|
3298
|
+
exports.uuidEncode = uuidEncode;
|
|
3299
|
+
exports.uuidv4 = uuidv4;
|
|
3300
|
+
exports.valueToBoolean = valueToBoolean;
|
|
3301
|
+
exports.valueToFloat = valueToFloat;
|
|
3302
|
+
exports.valueToInteger = valueToInteger;
|
|
3303
|
+
exports.valueToString = valueToString;
|
|
3304
|
+
exports.waitOn = waitOn;
|
|
3305
|
+
//# sourceMappingURL=chunk-AITOWUS2.cjs.map
|