zeed 0.7.133 → 0.7.134
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-SJ7ULW32.js → chunk-AA43JNUH.js} +116 -269
- package/dist/chunk-AA43JNUH.js.map +1 -0
- package/dist/{chunk-62MZKF4H.js → chunk-AJ6EUXLS.js} +4 -21
- package/dist/{chunk-62MZKF4H.js.map → chunk-AJ6EUXLS.js.map} +1 -1
- package/dist/{chunk-6KA6X4AH.js → chunk-BYNB5A2G.js} +5 -29
- package/dist/{chunk-6KA6X4AH.js.map → chunk-BYNB5A2G.js.map} +1 -1
- package/dist/{chunk-QT2FSGEN.js → chunk-ROJ32F7D.js} +6 -11
- package/dist/{chunk-QT2FSGEN.js.map → chunk-ROJ32F7D.js.map} +1 -1
- package/dist/{chunk-KOWTF5XP.js → chunk-UV633OX2.js} +3 -23
- package/dist/{chunk-KOWTF5XP.js.map → chunk-UV633OX2.js.map} +1 -1
- package/dist/index.all.cjs +123 -338
- package/dist/index.all.cjs.map +1 -1
- package/dist/index.all.d.ts +3 -3
- package/dist/index.all.js +7 -5
- package/dist/index.browser.cjs +123 -320
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.ts +2 -2
- package/dist/index.browser.js +6 -4
- package/dist/index.log.cjs +8 -26
- package/dist/index.log.cjs.map +1 -1
- package/dist/index.log.js +2 -2
- package/dist/index.node.cjs +119 -313
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +2 -2
- package/dist/index.node.js +5 -3
- package/dist/{log-colors-d07f5d7c.d.ts → log-colors-75759250.d.ts} +1 -1
- package/dist/{log-util-be565e6c.d.ts → log-util-5f476a7d.d.ts} +1 -1
- package/dist/{uuid-d079c66c.d.ts → uuid-0c370777.d.ts} +8 -1
- package/package.json +3 -3
- package/dist/chunk-SJ7ULW32.js.map +0 -1
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getTimestamp,
|
|
8
8
|
useLevelFilter,
|
|
9
9
|
useNamespaceFilter
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-BYNB5A2G.js";
|
|
11
11
|
|
|
12
12
|
// src/common/data/bin.ts
|
|
13
13
|
var log = Logger("bin");
|
|
@@ -20,7 +20,6 @@ function _encodeUtf8Polyfill(str) {
|
|
|
20
20
|
}
|
|
21
21
|
return buf;
|
|
22
22
|
}
|
|
23
|
-
__name(_encodeUtf8Polyfill, "_encodeUtf8Polyfill");
|
|
24
23
|
function _decodeUtf8Polyfill(buf) {
|
|
25
24
|
let remainingLen = buf.length;
|
|
26
25
|
let encodedString = "";
|
|
@@ -34,7 +33,6 @@ function _decodeUtf8Polyfill(buf) {
|
|
|
34
33
|
}
|
|
35
34
|
return decodeURIComponent(escape(encodedString));
|
|
36
35
|
}
|
|
37
|
-
__name(_decodeUtf8Polyfill, "_decodeUtf8Polyfill");
|
|
38
36
|
var _textEncoder;
|
|
39
37
|
function stringToUInt8Array(text) {
|
|
40
38
|
if (_textEncoder == null) {
|
|
@@ -46,7 +44,6 @@ function stringToUInt8Array(text) {
|
|
|
46
44
|
}
|
|
47
45
|
return _textEncoder(text.normalize("NFC"));
|
|
48
46
|
}
|
|
49
|
-
__name(stringToUInt8Array, "stringToUInt8Array");
|
|
50
47
|
var _textDecoder;
|
|
51
48
|
function Uint8ArrayToString(bin) {
|
|
52
49
|
if (_textDecoder == null) {
|
|
@@ -58,7 +55,6 @@ function Uint8ArrayToString(bin) {
|
|
|
58
55
|
}
|
|
59
56
|
return _textDecoder(bin).normalize("NFC");
|
|
60
57
|
}
|
|
61
|
-
__name(Uint8ArrayToString, "Uint8ArrayToString");
|
|
62
58
|
function toUint8Array(data) {
|
|
63
59
|
if (data instanceof ArrayBuffer)
|
|
64
60
|
return new Uint8Array(data);
|
|
@@ -68,7 +64,6 @@ function toUint8Array(data) {
|
|
|
68
64
|
return new Uint8Array(data);
|
|
69
65
|
return data;
|
|
70
66
|
}
|
|
71
|
-
__name(toUint8Array, "toUint8Array");
|
|
72
67
|
function toHex(bin) {
|
|
73
68
|
if (typeof Buffer !== "undefined") {
|
|
74
69
|
return Buffer.from(toUint8Array(bin)).toString("hex");
|
|
@@ -80,7 +75,6 @@ function toHex(bin) {
|
|
|
80
75
|
}
|
|
81
76
|
return s;
|
|
82
77
|
}
|
|
83
|
-
__name(toHex, "toHex");
|
|
84
78
|
function toBase64(bin) {
|
|
85
79
|
const bytes = toUint8Array(bin);
|
|
86
80
|
if (typeof Buffer !== "undefined") {
|
|
@@ -92,7 +86,6 @@ function toBase64(bin) {
|
|
|
92
86
|
}
|
|
93
87
|
return btoa(s);
|
|
94
88
|
}
|
|
95
|
-
__name(toBase64, "toBase64");
|
|
96
89
|
function toBase64Url(bin) {
|
|
97
90
|
const bytes = toUint8Array(bin);
|
|
98
91
|
if (typeof Buffer !== "undefined") {
|
|
@@ -104,7 +97,6 @@ function toBase64Url(bin) {
|
|
|
104
97
|
}
|
|
105
98
|
return btoa(s).replace(/\+/g, "-").replace(/\//g, "_");
|
|
106
99
|
}
|
|
107
|
-
__name(toBase64Url, "toBase64Url");
|
|
108
100
|
function fromBase64(s) {
|
|
109
101
|
if (typeof Buffer !== "undefined") {
|
|
110
102
|
const buf = Buffer.from(s, "base64");
|
|
@@ -117,7 +109,6 @@ function fromBase64(s) {
|
|
|
117
109
|
}
|
|
118
110
|
return bytes;
|
|
119
111
|
}
|
|
120
|
-
__name(fromBase64, "fromBase64");
|
|
121
112
|
function equalBinary(a, b) {
|
|
122
113
|
if (a.byteLength !== b.byteLength)
|
|
123
114
|
return false;
|
|
@@ -130,7 +121,6 @@ function equalBinary(a, b) {
|
|
|
130
121
|
}
|
|
131
122
|
return true;
|
|
132
123
|
}
|
|
133
|
-
__name(equalBinary, "equalBinary");
|
|
134
124
|
function jsonToUint8Array(json) {
|
|
135
125
|
try {
|
|
136
126
|
return stringToUInt8Array(JSON.stringify(json));
|
|
@@ -139,7 +129,6 @@ function jsonToUint8Array(json) {
|
|
|
139
129
|
throw err;
|
|
140
130
|
}
|
|
141
131
|
}
|
|
142
|
-
__name(jsonToUint8Array, "jsonToUint8Array");
|
|
143
132
|
function Uint8ArrayToJson(data) {
|
|
144
133
|
try {
|
|
145
134
|
return JSON.parse(Uint8ArrayToString(data));
|
|
@@ -148,7 +137,6 @@ function Uint8ArrayToJson(data) {
|
|
|
148
137
|
throw err;
|
|
149
138
|
}
|
|
150
139
|
}
|
|
151
|
-
__name(Uint8ArrayToJson, "Uint8ArrayToJson");
|
|
152
140
|
|
|
153
141
|
// src/common/crypto.ts
|
|
154
142
|
function randomUint8Array(length = 16) {
|
|
@@ -162,14 +150,12 @@ function randomUint8Array(length = 16) {
|
|
|
162
150
|
}
|
|
163
151
|
return randomBytes;
|
|
164
152
|
}
|
|
165
|
-
__name(randomUint8Array, "randomUint8Array");
|
|
166
153
|
var DEFAULT_HASH_ALG = "SHA-256";
|
|
167
154
|
var DEFAULT_CRYPTO_ALG = "AES-GCM";
|
|
168
155
|
var DEFAULT_DERIVE_ALG = "PBKDF2";
|
|
169
156
|
async function digest(message, algorithm = DEFAULT_HASH_ALG) {
|
|
170
157
|
return toUint8Array(await crypto.subtle.digest(algorithm, toUint8Array(message)));
|
|
171
158
|
}
|
|
172
|
-
__name(digest, "digest");
|
|
173
159
|
async function deriveKeyPbkdf2(secret, opt = {}) {
|
|
174
160
|
var _a;
|
|
175
161
|
const secretBuffer = toUint8Array(secret);
|
|
@@ -184,7 +170,6 @@ async function deriveKeyPbkdf2(secret, opt = {}) {
|
|
|
184
170
|
length: 256
|
|
185
171
|
}, true, ["encrypt", "decrypt"]);
|
|
186
172
|
}
|
|
187
|
-
__name(deriveKeyPbkdf2, "deriveKeyPbkdf2");
|
|
188
173
|
var MAGIC_ID = new Uint8Array([1, 1]);
|
|
189
174
|
async function encrypt(data, key) {
|
|
190
175
|
const iv = randomUint8Array(12);
|
|
@@ -200,7 +185,6 @@ async function encrypt(data, key) {
|
|
|
200
185
|
buffer.set(binCypher, pos);
|
|
201
186
|
return buffer;
|
|
202
187
|
}
|
|
203
|
-
__name(encrypt, "encrypt");
|
|
204
188
|
async function decrypt(data, key) {
|
|
205
189
|
let magic = data.subarray(0, 2);
|
|
206
190
|
if (!equalBinary(magic, MAGIC_ID)) {
|
|
@@ -211,7 +195,6 @@ async function decrypt(data, key) {
|
|
|
211
195
|
const plain = await crypto.subtle.decrypt({ name: DEFAULT_CRYPTO_ALG, iv }, key, cipher);
|
|
212
196
|
return new Uint8Array(plain);
|
|
213
197
|
}
|
|
214
|
-
__name(decrypt, "decrypt");
|
|
215
198
|
|
|
216
199
|
// src/common/csv.ts
|
|
217
200
|
var separator = ",";
|
|
@@ -223,7 +206,6 @@ function filterFloat(value) {
|
|
|
223
206
|
}
|
|
224
207
|
return NaN;
|
|
225
208
|
}
|
|
226
|
-
__name(filterFloat, "filterFloat");
|
|
227
209
|
function escape2(field) {
|
|
228
210
|
if (ignoreNullOrUndefined && field == void 0) {
|
|
229
211
|
return "";
|
|
@@ -247,42 +229,33 @@ function csv(data, headerRow) {
|
|
|
247
229
|
}
|
|
248
230
|
return body;
|
|
249
231
|
}
|
|
250
|
-
__name(csv, "csv");
|
|
251
232
|
|
|
252
233
|
// src/common/data/math.ts
|
|
253
234
|
function getSecureRandom() {
|
|
254
235
|
return crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295;
|
|
255
236
|
}
|
|
256
|
-
__name(getSecureRandom, "getSecureRandom");
|
|
257
237
|
function getSecureRandomIfPossible() {
|
|
258
238
|
return typeof crypto !== "undefined" ? getSecureRandom() : Math.random();
|
|
259
239
|
}
|
|
260
|
-
__name(getSecureRandomIfPossible, "getSecureRandomIfPossible");
|
|
261
240
|
function randomBoolean(bias = 0.25) {
|
|
262
241
|
return getSecureRandomIfPossible() < bias;
|
|
263
242
|
}
|
|
264
|
-
__name(randomBoolean, "randomBoolean");
|
|
265
243
|
function randomInt(max = 100, min = 0) {
|
|
266
244
|
return min + Math.floor(getSecureRandomIfPossible() * (max - min));
|
|
267
245
|
}
|
|
268
|
-
__name(randomInt, "randomInt");
|
|
269
246
|
function randomFloat(max = 100, min = 0) {
|
|
270
247
|
return min + getSecureRandomIfPossible() * (max - min);
|
|
271
248
|
}
|
|
272
|
-
__name(randomFloat, "randomFloat");
|
|
273
249
|
function between(min, value, max) {
|
|
274
250
|
return Math.max(min, Math.min(max, value));
|
|
275
251
|
}
|
|
276
|
-
__name(between, "between");
|
|
277
252
|
function sum(array) {
|
|
278
253
|
return array.reduce((acc, value) => acc + value, 0);
|
|
279
254
|
}
|
|
280
|
-
__name(sum, "sum");
|
|
281
255
|
function avg(array) {
|
|
282
256
|
return sum(array) / array.length;
|
|
283
257
|
}
|
|
284
|
-
|
|
285
|
-
var isPrimeRX = /* @__PURE__ */ __name((val) => !/^1?$|^(11+?)\1+$/.test("1".repeat(val)), "isPrimeRX");
|
|
258
|
+
var isPrimeRX = (val) => !/^1?$|^(11+?)\1+$/.test("1".repeat(val));
|
|
286
259
|
|
|
287
260
|
// src/common/data/orderby.ts
|
|
288
261
|
function parseOrderby(value = "") {
|
|
@@ -295,17 +268,14 @@ function parseOrderby(value = "") {
|
|
|
295
268
|
desc: orderby === "desc"
|
|
296
269
|
};
|
|
297
270
|
}
|
|
298
|
-
__name(parseOrderby, "parseOrderby");
|
|
299
271
|
function composeOrderby(field, asc = true) {
|
|
300
272
|
return `${field} ${asc ? "asc" : "desc"}`;
|
|
301
273
|
}
|
|
302
|
-
__name(composeOrderby, "composeOrderby");
|
|
303
274
|
function cmp(a, b, asc = true) {
|
|
304
275
|
const aa = a || 0;
|
|
305
276
|
const bb = b || 0;
|
|
306
277
|
return aa > bb ? asc ? 1 : -1 : aa < bb ? asc ? -1 : 1 : 0;
|
|
307
278
|
}
|
|
308
|
-
__name(cmp, "cmp");
|
|
309
279
|
function sortedOrderby(values, ...orderby) {
|
|
310
280
|
if (orderby.length > 0) {
|
|
311
281
|
let orderByList = orderby.map(parseOrderby);
|
|
@@ -322,33 +292,26 @@ function sortedOrderby(values, ...orderby) {
|
|
|
322
292
|
}
|
|
323
293
|
return values;
|
|
324
294
|
}
|
|
325
|
-
__name(sortedOrderby, "sortedOrderby");
|
|
326
295
|
|
|
327
296
|
// src/common/data/array.ts
|
|
328
297
|
function arrayUnique(x) {
|
|
329
298
|
return x.filter((n, index) => x.indexOf(n) === index);
|
|
330
299
|
}
|
|
331
|
-
__name(arrayUnique, "arrayUnique");
|
|
332
300
|
function arrayMinus(x, y) {
|
|
333
301
|
return arrayUnique(x.filter((n) => !y.includes(n)));
|
|
334
302
|
}
|
|
335
|
-
__name(arrayMinus, "arrayMinus");
|
|
336
303
|
function arrayUnion(...a) {
|
|
337
304
|
return arrayUnique(a.reduce((acc = [], value) => acc.concat(value), []));
|
|
338
305
|
}
|
|
339
|
-
__name(arrayUnion, "arrayUnion");
|
|
340
306
|
function arrayFlatten(...list) {
|
|
341
307
|
return list.flat(Infinity);
|
|
342
308
|
}
|
|
343
|
-
__name(arrayFlatten, "arrayFlatten");
|
|
344
309
|
function arrayIntersection(x, y) {
|
|
345
310
|
return arrayUnique(x).filter((n) => y.includes(n));
|
|
346
311
|
}
|
|
347
|
-
__name(arrayIntersection, "arrayIntersection");
|
|
348
312
|
function arraySymmetricDifference(x, y) {
|
|
349
313
|
return arrayMinus(arrayUnion(x, y), arrayIntersection(x, y));
|
|
350
314
|
}
|
|
351
|
-
__name(arraySymmetricDifference, "arraySymmetricDifference");
|
|
352
315
|
function arrayRemoveElement(arr, el) {
|
|
353
316
|
if (arr && Array.isArray(arr)) {
|
|
354
317
|
let index;
|
|
@@ -359,18 +322,15 @@ function arrayRemoveElement(arr, el) {
|
|
|
359
322
|
}
|
|
360
323
|
return [];
|
|
361
324
|
}
|
|
362
|
-
__name(arrayRemoveElement, "arrayRemoveElement");
|
|
363
325
|
function arraySetElement(arr, el) {
|
|
364
326
|
if (!arr.includes(el))
|
|
365
327
|
arr.push(el);
|
|
366
328
|
return arr;
|
|
367
329
|
}
|
|
368
|
-
__name(arraySetElement, "arraySetElement");
|
|
369
330
|
function arrayFilterInPlace(array, fn) {
|
|
370
331
|
array.splice(0, array.length, ...array.filter(fn));
|
|
371
332
|
return array;
|
|
372
333
|
}
|
|
373
|
-
__name(arrayFilterInPlace, "arrayFilterInPlace");
|
|
374
334
|
function arrayToggleInPlace(array, el) {
|
|
375
335
|
const index = array.findIndex((e) => e === el);
|
|
376
336
|
if (index >= 0)
|
|
@@ -379,33 +339,26 @@ function arrayToggleInPlace(array, el) {
|
|
|
379
339
|
array.push(el);
|
|
380
340
|
return array;
|
|
381
341
|
}
|
|
382
|
-
__name(arrayToggleInPlace, "arrayToggleInPlace");
|
|
383
342
|
function arrayEmptyInPlace(array) {
|
|
384
343
|
array.splice(0, array.length);
|
|
385
344
|
return array;
|
|
386
345
|
}
|
|
387
|
-
__name(arrayEmptyInPlace, "arrayEmptyInPlace");
|
|
388
346
|
function arraySorted(arr, cond = cmp) {
|
|
389
347
|
return Array.from(arr).sort(cond);
|
|
390
348
|
}
|
|
391
|
-
__name(arraySorted, "arraySorted");
|
|
392
349
|
function arraySortedNumbers(arr) {
|
|
393
350
|
return arraySorted(arr, (l, r) => l - r);
|
|
394
351
|
}
|
|
395
|
-
__name(arraySortedNumbers, "arraySortedNumbers");
|
|
396
352
|
function arrayIsEqual(array1, array2) {
|
|
397
353
|
return array1.length === array2.length && array1.every((value, index) => value === array2[index]);
|
|
398
354
|
}
|
|
399
|
-
__name(arrayIsEqual, "arrayIsEqual");
|
|
400
355
|
function arrayShuffleInPlace(array) {
|
|
401
356
|
array.sort(() => getSecureRandomIfPossible() > 0.5 ? 1 : -1);
|
|
402
357
|
return array;
|
|
403
358
|
}
|
|
404
|
-
__name(arrayShuffleInPlace, "arrayShuffleInPlace");
|
|
405
359
|
function arrayShuffle(array) {
|
|
406
360
|
return arrayShuffleInPlace(Array.from(array));
|
|
407
361
|
}
|
|
408
|
-
__name(arrayShuffle, "arrayShuffle");
|
|
409
362
|
function arrayShuffleForce(array) {
|
|
410
363
|
while (array.length > 1) {
|
|
411
364
|
const copy = Array.from(array);
|
|
@@ -415,28 +368,22 @@ function arrayShuffleForce(array) {
|
|
|
415
368
|
}
|
|
416
369
|
return array;
|
|
417
370
|
}
|
|
418
|
-
__name(arrayShuffleForce, "arrayShuffleForce");
|
|
419
371
|
function arrayRandomElement(array) {
|
|
420
372
|
return array[Math.floor(getSecureRandomIfPossible() * array.length)];
|
|
421
373
|
}
|
|
422
|
-
__name(arrayRandomElement, "arrayRandomElement");
|
|
423
374
|
function arrayMax(...array) {
|
|
424
375
|
return arrayFlatten(array).reduce((acc, value) => acc != null ? value > acc ? value : acc : value, void 0);
|
|
425
376
|
}
|
|
426
|
-
__name(arrayMax, "arrayMax");
|
|
427
377
|
function arrayMin(...array) {
|
|
428
378
|
return arrayFlatten(array).reduce((acc, value) => acc != null ? value < acc ? value : acc : value, void 0);
|
|
429
379
|
}
|
|
430
|
-
__name(arrayMin, "arrayMin");
|
|
431
380
|
function arraySum(...array) {
|
|
432
381
|
return arrayFlatten(array).reduce((acc, value) => acc + value, 0);
|
|
433
382
|
}
|
|
434
|
-
__name(arraySum, "arraySum");
|
|
435
383
|
function arrayAvg(...array) {
|
|
436
384
|
let flatArray = arrayFlatten(array);
|
|
437
385
|
return flatArray.reduce((acc, value) => acc + value, 0) / flatArray.length;
|
|
438
386
|
}
|
|
439
|
-
__name(arrayAvg, "arrayAvg");
|
|
440
387
|
function arrayBatches(array, chunckLength) {
|
|
441
388
|
let chunks = [];
|
|
442
389
|
let i = 0;
|
|
@@ -446,7 +393,6 @@ function arrayBatches(array, chunckLength) {
|
|
|
446
393
|
}
|
|
447
394
|
return chunks;
|
|
448
395
|
}
|
|
449
|
-
__name(arrayBatches, "arrayBatches");
|
|
450
396
|
function createArray(size2 = 0, item) {
|
|
451
397
|
if (size2 <= 0)
|
|
452
398
|
return [];
|
|
@@ -456,7 +402,6 @@ function createArray(size2 = 0, item) {
|
|
|
456
402
|
}
|
|
457
403
|
return arr;
|
|
458
404
|
}
|
|
459
|
-
__name(createArray, "createArray");
|
|
460
405
|
|
|
461
406
|
// src/common/data/basex.ts
|
|
462
407
|
var log2 = Logger("zeed:basex");
|
|
@@ -541,7 +486,6 @@ function useBase(alphaOrBase) {
|
|
|
541
486
|
}
|
|
542
487
|
return str;
|
|
543
488
|
}
|
|
544
|
-
__name(encode, "encode");
|
|
545
489
|
function decode(source, padToLength = -1) {
|
|
546
490
|
if (typeof source !== "string")
|
|
547
491
|
throw new TypeError("Expected String");
|
|
@@ -582,13 +526,11 @@ function useBase(alphaOrBase) {
|
|
|
582
526
|
}
|
|
583
527
|
return dataDecoded.slice(it4);
|
|
584
528
|
}
|
|
585
|
-
__name(decode, "decode");
|
|
586
529
|
return {
|
|
587
530
|
encode,
|
|
588
531
|
decode
|
|
589
532
|
};
|
|
590
533
|
}
|
|
591
|
-
__name(useBase, "useBase");
|
|
592
534
|
var { encode: encodeBase16, decode: decodeBase16 } = useBase(16);
|
|
593
535
|
var { encode: encodeBase32, decode: decodeBase32 } = useBase(32);
|
|
594
536
|
var { encode: encodeBase58, decode: decodeBase58 } = useBase(58);
|
|
@@ -596,7 +538,7 @@ var { encode: encodeBase62, decode: decodeBase62 } = useBase(62);
|
|
|
596
538
|
var { encode: encodeBase64, decode: decodeBase64 } = useBase(62);
|
|
597
539
|
|
|
598
540
|
// src/common/data/camelcase.ts
|
|
599
|
-
var toCamelCase =
|
|
541
|
+
var toCamelCase = (s) => {
|
|
600
542
|
if (s.length > 0) {
|
|
601
543
|
if (/^[A-Z0-9_\-\ ]*$/g.test(s)) {
|
|
602
544
|
s = s.toLowerCase();
|
|
@@ -605,20 +547,17 @@ var toCamelCase = /* @__PURE__ */ __name((s) => {
|
|
|
605
547
|
s = s[0].toLowerCase() + s.substring(1);
|
|
606
548
|
}
|
|
607
549
|
return s;
|
|
608
|
-
}
|
|
550
|
+
};
|
|
609
551
|
function toCapitalize(s) {
|
|
610
552
|
return s.charAt(0).toUpperCase() + s.toLowerCase().slice(1);
|
|
611
553
|
}
|
|
612
|
-
__name(toCapitalize, "toCapitalize");
|
|
613
554
|
function toCapitalizeWords(s) {
|
|
614
555
|
return s.replace(/\w\S*/g, toCapitalize);
|
|
615
556
|
}
|
|
616
|
-
__name(toCapitalizeWords, "toCapitalizeWords");
|
|
617
557
|
function fromCamelCase(str, separator2 = "-") {
|
|
618
558
|
separator2 = typeof separator2 === "undefined" ? "_" : separator2;
|
|
619
559
|
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();
|
|
620
560
|
}
|
|
621
|
-
__name(fromCamelCase, "fromCamelCase");
|
|
622
561
|
|
|
623
562
|
// src/common/data/json.ts
|
|
624
563
|
function serializer(replacer, cycleReplacer) {
|
|
@@ -641,11 +580,9 @@ function serializer(replacer, cycleReplacer) {
|
|
|
641
580
|
return replacer == null ? value : replacer.call(this, key, value);
|
|
642
581
|
};
|
|
643
582
|
}
|
|
644
|
-
__name(serializer, "serializer");
|
|
645
583
|
function jsonStringify(obj, replacer, spaces, cycleReplacer) {
|
|
646
584
|
return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces);
|
|
647
585
|
}
|
|
648
|
-
__name(jsonStringify, "jsonStringify");
|
|
649
586
|
|
|
650
587
|
// src/common/data/convert.ts
|
|
651
588
|
var TRUE_VALUES_LIST = ["1", "true", "yes", "y", "on"];
|
|
@@ -654,21 +591,18 @@ function stringToBoolean(value, defaultValue = false) {
|
|
|
654
591
|
return defaultValue;
|
|
655
592
|
return TRUE_VALUES_LIST.includes(String(value).trim().toLowerCase());
|
|
656
593
|
}
|
|
657
|
-
__name(stringToBoolean, "stringToBoolean");
|
|
658
594
|
function stringToInteger(value, defaultValue = 0) {
|
|
659
595
|
var _a;
|
|
660
596
|
if (value == null || typeof value !== "string")
|
|
661
597
|
return defaultValue;
|
|
662
598
|
return (_a = parseInt(value.trim(), 10)) != null ? _a : defaultValue;
|
|
663
599
|
}
|
|
664
|
-
__name(stringToInteger, "stringToInteger");
|
|
665
600
|
function stringToFloat(value, defaultValue = 0) {
|
|
666
601
|
var _a;
|
|
667
602
|
if (value == null || typeof value !== "string")
|
|
668
603
|
return defaultValue;
|
|
669
604
|
return (_a = parseFloat(value.trim())) != null ? _a : defaultValue;
|
|
670
605
|
}
|
|
671
|
-
__name(stringToFloat, "stringToFloat");
|
|
672
606
|
function valueToBoolean(value, defaultValue = false) {
|
|
673
607
|
if (value == null)
|
|
674
608
|
return defaultValue;
|
|
@@ -678,7 +612,6 @@ function valueToBoolean(value, defaultValue = false) {
|
|
|
678
612
|
return value !== 0;
|
|
679
613
|
return TRUE_VALUES_LIST.includes(String(value).trim().toLowerCase());
|
|
680
614
|
}
|
|
681
|
-
__name(valueToBoolean, "valueToBoolean");
|
|
682
615
|
function valueToInteger(value, defaultValue = 0) {
|
|
683
616
|
var _a;
|
|
684
617
|
if (value == null)
|
|
@@ -689,7 +622,6 @@ function valueToInteger(value, defaultValue = 0) {
|
|
|
689
622
|
return Math.floor(value);
|
|
690
623
|
return (_a = parseInt(String(value).trim(), 10)) != null ? _a : defaultValue;
|
|
691
624
|
}
|
|
692
|
-
__name(valueToInteger, "valueToInteger");
|
|
693
625
|
function valueToFloat(value, defaultValue = 0) {
|
|
694
626
|
var _a;
|
|
695
627
|
if (value == null)
|
|
@@ -700,14 +632,12 @@ function valueToFloat(value, defaultValue = 0) {
|
|
|
700
632
|
return Math.floor(value);
|
|
701
633
|
return (_a = parseFloat(String(value).trim())) != null ? _a : defaultValue;
|
|
702
634
|
}
|
|
703
|
-
__name(valueToFloat, "valueToFloat");
|
|
704
635
|
function valueToString(value, defaultValue = "") {
|
|
705
636
|
var _a;
|
|
706
637
|
if (value == null)
|
|
707
638
|
return defaultValue;
|
|
708
639
|
return (_a = String(value)) != null ? _a : defaultValue;
|
|
709
640
|
}
|
|
710
|
-
__name(valueToString, "valueToString");
|
|
711
641
|
var toFloat = valueToFloat;
|
|
712
642
|
var toInt = valueToInteger;
|
|
713
643
|
var toString = valueToString;
|
|
@@ -728,11 +658,9 @@ ${obj.stack}`;
|
|
|
728
658
|
return String(obj);
|
|
729
659
|
});
|
|
730
660
|
}
|
|
731
|
-
__name(formatMessages, "formatMessages");
|
|
732
661
|
function renderMessages(messages2, opt = {}) {
|
|
733
662
|
return formatMessages(messages2, opt).join(" ");
|
|
734
663
|
}
|
|
735
|
-
__name(renderMessages, "renderMessages");
|
|
736
664
|
function fixBrokenUth8String(brokenString) {
|
|
737
665
|
try {
|
|
738
666
|
return decodeURIComponent(escape(brokenString));
|
|
@@ -740,7 +668,6 @@ function fixBrokenUth8String(brokenString) {
|
|
|
740
668
|
}
|
|
741
669
|
return brokenString;
|
|
742
670
|
}
|
|
743
|
-
__name(fixBrokenUth8String, "fixBrokenUth8String");
|
|
744
671
|
|
|
745
672
|
// src/common/data/currency.ts
|
|
746
673
|
var defaults = {
|
|
@@ -754,15 +681,14 @@ var defaults = {
|
|
|
754
681
|
format,
|
|
755
682
|
fromCents: false
|
|
756
683
|
};
|
|
757
|
-
var round =
|
|
758
|
-
var pow =
|
|
759
|
-
var rounding =
|
|
684
|
+
var round = (v) => Math.round(v);
|
|
685
|
+
var pow = (p) => Math.pow(10, p);
|
|
686
|
+
var rounding = (value, increment) => round(value / increment) * increment;
|
|
760
687
|
var groupRegex = /(\d)(?=(\d{3})+\b)/g;
|
|
761
688
|
var vedicRegex = /(\d)(?=(\d\d)+\d\b)/g;
|
|
762
689
|
function currency(value, opts = {}) {
|
|
763
690
|
return new Currency(value, opts);
|
|
764
691
|
}
|
|
765
|
-
__name(currency, "currency");
|
|
766
692
|
var _Currency = class {
|
|
767
693
|
constructor(value, opts = {}) {
|
|
768
694
|
var _a;
|
|
@@ -835,7 +761,6 @@ var _Currency = class {
|
|
|
835
761
|
}
|
|
836
762
|
};
|
|
837
763
|
var Currency = _Currency;
|
|
838
|
-
__name(Currency, "Currency");
|
|
839
764
|
Currency.zero = new _Currency(0);
|
|
840
765
|
Currency.one = new _Currency(1);
|
|
841
766
|
Currency.hundred = new _Currency(100);
|
|
@@ -862,36 +787,34 @@ function parse(value, opts, useRounding = true) {
|
|
|
862
787
|
}
|
|
863
788
|
return useRounding ? round(v) : v;
|
|
864
789
|
}
|
|
865
|
-
__name(parse, "parse");
|
|
866
790
|
function format(currency2, settings) {
|
|
867
791
|
let { pattern: pattern2, negativePattern, symbol, separator: separator2, decimal, groups } = settings, split = ("" + currency2).replace(/^-/, "").split("."), dollars = split[0], cents = split[1];
|
|
868
792
|
return (currency2.value >= 0 ? pattern2 : negativePattern).replace("!", symbol).replace("#", dollars.replace(groups, "$1" + separator2) + (cents ? decimal + cents : ""));
|
|
869
793
|
}
|
|
870
|
-
|
|
871
|
-
var
|
|
872
|
-
var
|
|
873
|
-
var
|
|
874
|
-
var
|
|
875
|
-
var
|
|
876
|
-
var roundHalfOdd = /* @__PURE__ */ __name((value) => {
|
|
794
|
+
var isHalf = (value) => Math.abs(value) % 1 === 0.5;
|
|
795
|
+
var isEven = (value) => value % 2 === 0;
|
|
796
|
+
var roundUp = (value) => Math.ceil(value);
|
|
797
|
+
var roundDown = (value) => Math.floor(value);
|
|
798
|
+
var roundHalfUp = (value) => Math.round(value);
|
|
799
|
+
var roundHalfOdd = (value) => {
|
|
877
800
|
const rounded = Math.round(value);
|
|
878
801
|
if (!isHalf(value)) {
|
|
879
802
|
return rounded;
|
|
880
803
|
}
|
|
881
804
|
return isEven(rounded) ? rounded - 1 : rounded;
|
|
882
|
-
}
|
|
883
|
-
var roundHalfAwayFromZero =
|
|
805
|
+
};
|
|
806
|
+
var roundHalfAwayFromZero = (value) => {
|
|
884
807
|
return isHalf(value) ? Math.sign(value) * Math.ceil(Math.abs(value)) : Math.round(value);
|
|
885
|
-
}
|
|
886
|
-
var roundHalfDown =
|
|
887
|
-
var roundHalfEven =
|
|
808
|
+
};
|
|
809
|
+
var roundHalfDown = (value) => isHalf(value) ? Math.floor(value) : Math.round(value);
|
|
810
|
+
var roundHalfEven = (value) => {
|
|
888
811
|
const rounded = Math.round(value);
|
|
889
812
|
if (!isHalf(value)) {
|
|
890
813
|
return rounded;
|
|
891
814
|
}
|
|
892
815
|
return isEven(rounded) ? rounded : rounded - 1;
|
|
893
|
-
}
|
|
894
|
-
var roundHalfTowardsZero =
|
|
816
|
+
};
|
|
817
|
+
var roundHalfTowardsZero = (value) => isHalf(value) ? Math.sign(value) * Math.floor(Math.abs(value)) : Math.round(value);
|
|
895
818
|
|
|
896
819
|
// src/common/exec/promise.ts
|
|
897
820
|
var { warn } = Logger("zeed:promise");
|
|
@@ -903,15 +826,12 @@ function createPromise() {
|
|
|
903
826
|
});
|
|
904
827
|
return [promise, resolve, reject];
|
|
905
828
|
}
|
|
906
|
-
__name(createPromise, "createPromise");
|
|
907
829
|
async function sleep(milliSeconds) {
|
|
908
830
|
return new Promise((resolve) => setTimeout(resolve, milliSeconds));
|
|
909
831
|
}
|
|
910
|
-
__name(sleep, "sleep");
|
|
911
832
|
async function immediate() {
|
|
912
833
|
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
913
834
|
}
|
|
914
|
-
__name(immediate, "immediate");
|
|
915
835
|
var timeoutReached = Symbol("timeout");
|
|
916
836
|
async function timeout(promise, milliSeconds, timeoutValue = timeoutReached) {
|
|
917
837
|
return new Promise(async (resolve, reject) => {
|
|
@@ -932,12 +852,10 @@ async function timeout(promise, milliSeconds, timeoutValue = timeoutReached) {
|
|
|
932
852
|
}
|
|
933
853
|
});
|
|
934
854
|
}
|
|
935
|
-
__name(timeout, "timeout");
|
|
936
855
|
var timoutError = new Error("Timeout reached");
|
|
937
856
|
function isTimeout(value) {
|
|
938
857
|
return value === timeoutReached || value === timoutError;
|
|
939
858
|
}
|
|
940
|
-
__name(isTimeout, "isTimeout");
|
|
941
859
|
async function tryTimeout(promise, milliSeconds) {
|
|
942
860
|
if (milliSeconds <= 0) {
|
|
943
861
|
return await promise;
|
|
@@ -960,17 +878,16 @@ async function tryTimeout(promise, milliSeconds) {
|
|
|
960
878
|
}
|
|
961
879
|
});
|
|
962
880
|
}
|
|
963
|
-
__name(tryTimeout, "tryTimeout");
|
|
964
881
|
function waitOn(obj, event, timeoutMS = 1e3) {
|
|
965
882
|
return new Promise((resolve, reject) => {
|
|
966
|
-
let fn =
|
|
883
|
+
let fn = (value) => {
|
|
967
884
|
if (timer) {
|
|
968
885
|
clearTimeout(timer);
|
|
969
886
|
done();
|
|
970
887
|
resolve(value);
|
|
971
888
|
}
|
|
972
|
-
}
|
|
973
|
-
let done =
|
|
889
|
+
};
|
|
890
|
+
let done = () => {
|
|
974
891
|
timer = null;
|
|
975
892
|
if (obj.off) {
|
|
976
893
|
obj.off(event, fn);
|
|
@@ -979,7 +896,7 @@ function waitOn(obj, event, timeoutMS = 1e3) {
|
|
|
979
896
|
} else {
|
|
980
897
|
warn("No remove listener method found for", obj, event);
|
|
981
898
|
}
|
|
982
|
-
}
|
|
899
|
+
};
|
|
983
900
|
let timer = setTimeout(() => {
|
|
984
901
|
done();
|
|
985
902
|
reject(new Error(`Did not response in time`));
|
|
@@ -993,15 +910,12 @@ function waitOn(obj, event, timeoutMS = 1e3) {
|
|
|
993
910
|
}
|
|
994
911
|
});
|
|
995
912
|
}
|
|
996
|
-
__name(waitOn, "waitOn");
|
|
997
913
|
function isPromise(value) {
|
|
998
914
|
return Boolean(value && (value instanceof Promise || typeof value.then === "function"));
|
|
999
915
|
}
|
|
1000
|
-
__name(isPromise, "isPromise");
|
|
1001
916
|
function promisify(value) {
|
|
1002
917
|
return Promise.resolve(value);
|
|
1003
918
|
}
|
|
1004
|
-
__name(promisify, "promisify");
|
|
1005
919
|
|
|
1006
920
|
// src/common/data/day.ts
|
|
1007
921
|
var DAY_MS = 1e3 * 60 * 60 * 24;
|
|
@@ -1099,7 +1013,6 @@ var Day = class {
|
|
|
1099
1013
|
return this.dayOffset(1);
|
|
1100
1014
|
}
|
|
1101
1015
|
};
|
|
1102
|
-
__name(Day, "Day");
|
|
1103
1016
|
async function forEachDay(from, to, handler) {
|
|
1104
1017
|
let start = Day.from(from);
|
|
1105
1018
|
let end = Day.from(to);
|
|
@@ -1111,19 +1024,16 @@ async function forEachDay(from, to, handler) {
|
|
|
1111
1024
|
start = start.dayOffset(1);
|
|
1112
1025
|
}
|
|
1113
1026
|
}
|
|
1114
|
-
__name(forEachDay, "forEachDay");
|
|
1115
1027
|
function today() {
|
|
1116
1028
|
return new Day();
|
|
1117
1029
|
}
|
|
1118
|
-
__name(today, "today");
|
|
1119
1030
|
function day(days) {
|
|
1120
1031
|
return new Day(days);
|
|
1121
1032
|
}
|
|
1122
|
-
__name(day, "day");
|
|
1123
1033
|
|
|
1124
1034
|
// src/common/data/html.ts
|
|
1125
|
-
var escapeHTML =
|
|
1126
|
-
var unescapeHTML =
|
|
1035
|
+
var escapeHTML = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/"/g, """);
|
|
1036
|
+
var unescapeHTML = (s) => s.replace(/</gi, "<").replace(/>/gi, ">").replace(/"/gi, '"').replace(/'/gi, "'").replace(/&/gi, "&");
|
|
1127
1037
|
|
|
1128
1038
|
// src/common/data/path.ts
|
|
1129
1039
|
var MAX_FILENAME_LENGTH = 100;
|
|
@@ -1133,11 +1043,9 @@ var reTrailingPeriods = /\.+$/;
|
|
|
1133
1043
|
function filenameReservedRegex() {
|
|
1134
1044
|
return /[<>:"/\\|?*\u0000-\u001F]/g;
|
|
1135
1045
|
}
|
|
1136
|
-
__name(filenameReservedRegex, "filenameReservedRegex");
|
|
1137
1046
|
function windowsReservedNameRegex() {
|
|
1138
1047
|
return /^(con|prn|aux|nul|com\d|lpt\d)$/i;
|
|
1139
1048
|
}
|
|
1140
|
-
__name(windowsReservedNameRegex, "windowsReservedNameRegex");
|
|
1141
1049
|
function toValidFilename(string) {
|
|
1142
1050
|
if (typeof string !== "string") {
|
|
1143
1051
|
throw new TypeError("Expected a string");
|
|
@@ -1150,7 +1058,6 @@ function toValidFilename(string) {
|
|
|
1150
1058
|
string = windowsReservedNameRegex().test(string) ? string + replacement : string;
|
|
1151
1059
|
return string.slice(0, MAX_FILENAME_LENGTH);
|
|
1152
1060
|
}
|
|
1153
|
-
__name(toValidFilename, "toValidFilename");
|
|
1154
1061
|
|
|
1155
1062
|
// src/common/data/regexp.ts
|
|
1156
1063
|
var rxEscape = /[\\\-\[\]\/{}()*+?.^$|]/g;
|
|
@@ -1162,17 +1069,14 @@ function escapeRegExp(value) {
|
|
|
1162
1069
|
}
|
|
1163
1070
|
return value.replace(rxEscape, "\\$&");
|
|
1164
1071
|
}
|
|
1165
|
-
__name(escapeRegExp, "escapeRegExp");
|
|
1166
1072
|
|
|
1167
1073
|
// src/common/data/sortable.ts
|
|
1168
1074
|
function startSortWeight(items) {
|
|
1169
1075
|
return items.reduce((acc, item) => Math.min(acc, item.sort_weight || 0), 0) - 1 - getSecureRandomIfPossible();
|
|
1170
1076
|
}
|
|
1171
|
-
__name(startSortWeight, "startSortWeight");
|
|
1172
1077
|
function endSortWeight(items) {
|
|
1173
1078
|
return items.reduce((acc, item) => Math.max(acc, item.sort_weight || 0), 0) + 1 + getSecureRandomIfPossible();
|
|
1174
1079
|
}
|
|
1175
|
-
__name(endSortWeight, "endSortWeight");
|
|
1176
1080
|
function moveSortWeight(newIndex, oldIndex, items) {
|
|
1177
1081
|
let count = items.length;
|
|
1178
1082
|
const moveLower = newIndex < oldIndex;
|
|
@@ -1197,12 +1101,10 @@ function moveSortWeight(newIndex, oldIndex, items) {
|
|
|
1197
1101
|
const fuzzy = distance * 0.01 * (getSecureRandomIfPossible() - 0.5);
|
|
1198
1102
|
return middle + fuzzy;
|
|
1199
1103
|
}
|
|
1200
|
-
__name(moveSortWeight, "moveSortWeight");
|
|
1201
1104
|
function sortedItems(items) {
|
|
1202
1105
|
items.sort((a, b) => (a.sort_weight || 0) - (b.sort_weight || 0));
|
|
1203
1106
|
return items;
|
|
1204
1107
|
}
|
|
1205
|
-
__name(sortedItems, "sortedItems");
|
|
1206
1108
|
|
|
1207
1109
|
// src/common/data/url.ts
|
|
1208
1110
|
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;
|
|
@@ -1212,11 +1114,9 @@ function linkifyPlainText(text) {
|
|
|
1212
1114
|
return i % 2 ? `<a target="_blank" href="${escapedPart}">${toHumanReadableUrl(escapedPart)}</a>` : escapedPart;
|
|
1213
1115
|
}).join("");
|
|
1214
1116
|
}
|
|
1215
|
-
__name(linkifyPlainText, "linkifyPlainText");
|
|
1216
1117
|
function toHumanReadableUrl(url) {
|
|
1217
1118
|
return url.replace(/^https?:\/\/(www\.)?/, "").replace(/\/$/, "");
|
|
1218
1119
|
}
|
|
1219
|
-
__name(toHumanReadableUrl, "toHumanReadableUrl");
|
|
1220
1120
|
function encodeQuery(data) {
|
|
1221
1121
|
let pairs = [];
|
|
1222
1122
|
for (let [key, value] of Object.entries(data)) {
|
|
@@ -1233,7 +1133,6 @@ function encodeQuery(data) {
|
|
|
1233
1133
|
}
|
|
1234
1134
|
return pairs.join("&");
|
|
1235
1135
|
}
|
|
1236
|
-
__name(encodeQuery, "encodeQuery");
|
|
1237
1136
|
function parseQuery(queryString) {
|
|
1238
1137
|
let query = {};
|
|
1239
1138
|
let pairs = (queryString[0] === "?" ? queryString.substr(1) : queryString).split("&");
|
|
@@ -1252,7 +1151,6 @@ function parseQuery(queryString) {
|
|
|
1252
1151
|
}
|
|
1253
1152
|
return query;
|
|
1254
1153
|
}
|
|
1255
|
-
__name(parseQuery, "parseQuery");
|
|
1256
1154
|
|
|
1257
1155
|
// src/common/data/utils.ts
|
|
1258
1156
|
function ensureKey(obj, key, createFn) {
|
|
@@ -1263,7 +1161,6 @@ function ensureKey(obj, key, createFn) {
|
|
|
1263
1161
|
}
|
|
1264
1162
|
return value;
|
|
1265
1163
|
}
|
|
1266
|
-
__name(ensureKey, "ensureKey");
|
|
1267
1164
|
async function ensureKeyAsync(obj, key, createFn) {
|
|
1268
1165
|
let value = obj[key];
|
|
1269
1166
|
if (value === void 0) {
|
|
@@ -1272,7 +1169,6 @@ async function ensureKeyAsync(obj, key, createFn) {
|
|
|
1272
1169
|
}
|
|
1273
1170
|
return value;
|
|
1274
1171
|
}
|
|
1275
|
-
__name(ensureKeyAsync, "ensureKeyAsync");
|
|
1276
1172
|
function size(obj) {
|
|
1277
1173
|
if (obj != null) {
|
|
1278
1174
|
if (obj.size != null) {
|
|
@@ -1285,11 +1181,9 @@ function size(obj) {
|
|
|
1285
1181
|
}
|
|
1286
1182
|
return 0;
|
|
1287
1183
|
}
|
|
1288
|
-
__name(size, "size");
|
|
1289
1184
|
function last(array) {
|
|
1290
1185
|
return array != null && array.length > 0 ? array[array.length - 1] : void 0;
|
|
1291
1186
|
}
|
|
1292
|
-
__name(last, "last");
|
|
1293
1187
|
function empty(value) {
|
|
1294
1188
|
try {
|
|
1295
1189
|
if (value != null) {
|
|
@@ -1308,19 +1202,16 @@ function empty(value) {
|
|
|
1308
1202
|
}
|
|
1309
1203
|
return true;
|
|
1310
1204
|
}
|
|
1311
|
-
__name(empty, "empty");
|
|
1312
1205
|
function cloneObject(obj) {
|
|
1313
1206
|
if (Object(obj) !== obj)
|
|
1314
1207
|
return obj;
|
|
1315
1208
|
return JSON.parse(JSON.stringify(obj));
|
|
1316
1209
|
}
|
|
1317
|
-
__name(cloneObject, "cloneObject");
|
|
1318
1210
|
function cloneJsonObject(obj) {
|
|
1319
1211
|
if (Object(obj) !== obj)
|
|
1320
1212
|
return obj;
|
|
1321
1213
|
return JSON.parse(JSON.stringify(obj));
|
|
1322
1214
|
}
|
|
1323
|
-
__name(cloneJsonObject, "cloneJsonObject");
|
|
1324
1215
|
function memoize(fn) {
|
|
1325
1216
|
let cache = /* @__PURE__ */ new Map();
|
|
1326
1217
|
return (n) => {
|
|
@@ -1332,13 +1223,11 @@ function memoize(fn) {
|
|
|
1332
1223
|
return result;
|
|
1333
1224
|
};
|
|
1334
1225
|
}
|
|
1335
|
-
__name(memoize, "memoize");
|
|
1336
1226
|
function forTimes(count, fn) {
|
|
1337
1227
|
for (let i = 0; i < count; i++) {
|
|
1338
1228
|
fn(i, count);
|
|
1339
1229
|
}
|
|
1340
1230
|
}
|
|
1341
|
-
__name(forTimes, "forTimes");
|
|
1342
1231
|
|
|
1343
1232
|
// src/common/data/xrx.ts
|
|
1344
1233
|
var RX_WHITESPACE = /\\\s|\s+|#[^\n]*\n?/gm;
|
|
@@ -1348,11 +1237,9 @@ var log3 = Logger("xrx");
|
|
|
1348
1237
|
function regExpString(rx) {
|
|
1349
1238
|
return typeof rx === "string" ? rx : rx.source || "";
|
|
1350
1239
|
}
|
|
1351
|
-
__name(regExpString, "regExpString");
|
|
1352
1240
|
function regExpEscape(str) {
|
|
1353
1241
|
return str.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1354
1242
|
}
|
|
1355
|
-
__name(regExpEscape, "regExpEscape");
|
|
1356
1243
|
var XRX = class {
|
|
1357
1244
|
constructor(pattern2, flags) {
|
|
1358
1245
|
this.namedGroups = {};
|
|
@@ -1449,7 +1336,6 @@ var XRX = class {
|
|
|
1449
1336
|
});
|
|
1450
1337
|
}
|
|
1451
1338
|
};
|
|
1452
|
-
__name(XRX, "XRX");
|
|
1453
1339
|
|
|
1454
1340
|
// src/common/dispose-defer.ts
|
|
1455
1341
|
var log4 = Logger("dispose");
|
|
@@ -1468,27 +1354,26 @@ async function callDisposer(disposable) {
|
|
|
1468
1354
|
await disposable.cleanup;
|
|
1469
1355
|
}
|
|
1470
1356
|
}
|
|
1471
|
-
__name(callDisposer, "callDisposer");
|
|
1472
1357
|
function useDispose(config) {
|
|
1473
1358
|
const { name } = typeof config === "string" ? { name: config } : config != null ? config : {};
|
|
1474
1359
|
let tracked = [];
|
|
1475
|
-
const untrack =
|
|
1360
|
+
const untrack = async (disposable) => {
|
|
1476
1361
|
if (tracked.includes(disposable)) {
|
|
1477
1362
|
arrayFilterInPlace(tracked, (el) => el !== disposable);
|
|
1478
1363
|
await callDisposer(disposable);
|
|
1479
1364
|
}
|
|
1480
|
-
}
|
|
1481
|
-
const dispose =
|
|
1365
|
+
};
|
|
1366
|
+
const dispose = async () => {
|
|
1482
1367
|
if (name)
|
|
1483
1368
|
log4.debug(`dispose ${name}: ${tracked.length} entries`);
|
|
1484
1369
|
while (tracked.length > 0) {
|
|
1485
1370
|
await untrack(tracked[0]);
|
|
1486
1371
|
}
|
|
1487
|
-
}
|
|
1488
|
-
const track =
|
|
1372
|
+
};
|
|
1373
|
+
const track = (obj) => {
|
|
1489
1374
|
tracked.unshift(obj);
|
|
1490
1375
|
return () => untrack(obj);
|
|
1491
|
-
}
|
|
1376
|
+
};
|
|
1492
1377
|
return Object.assign(dispose, {
|
|
1493
1378
|
track,
|
|
1494
1379
|
add: track,
|
|
@@ -1500,12 +1385,11 @@ function useDispose(config) {
|
|
|
1500
1385
|
}
|
|
1501
1386
|
});
|
|
1502
1387
|
}
|
|
1503
|
-
__name(useDispose, "useDispose");
|
|
1504
1388
|
var useDisposer = useDispose;
|
|
1505
1389
|
function useDefer(config = {}) {
|
|
1506
1390
|
const { mode = "fifo" } = config;
|
|
1507
1391
|
let steps = [];
|
|
1508
|
-
const exec =
|
|
1392
|
+
const exec = async (expectSync = false) => {
|
|
1509
1393
|
while (steps.length > 0) {
|
|
1510
1394
|
let step = steps[0];
|
|
1511
1395
|
arrayFilterInPlace(steps, (el) => el !== step);
|
|
@@ -1524,14 +1408,14 @@ function useDefer(config = {}) {
|
|
|
1524
1408
|
throw new Error(`Unhandled disposable: ${step}`);
|
|
1525
1409
|
}
|
|
1526
1410
|
}
|
|
1527
|
-
}
|
|
1528
|
-
const add =
|
|
1411
|
+
};
|
|
1412
|
+
const add = (obj) => {
|
|
1529
1413
|
if (mode === "lifo") {
|
|
1530
1414
|
steps.unshift(obj);
|
|
1531
1415
|
} else {
|
|
1532
1416
|
steps.push(obj);
|
|
1533
1417
|
}
|
|
1534
|
-
}
|
|
1418
|
+
};
|
|
1535
1419
|
return Object.assign(exec, {
|
|
1536
1420
|
add,
|
|
1537
1421
|
exec,
|
|
@@ -1540,7 +1424,6 @@ function useDefer(config = {}) {
|
|
|
1540
1424
|
}
|
|
1541
1425
|
});
|
|
1542
1426
|
}
|
|
1543
|
-
__name(useDefer, "useDefer");
|
|
1544
1427
|
function useTimeout(fn, timeout2 = 0) {
|
|
1545
1428
|
let timeoutHandle = setTimeout(fn, timeout2);
|
|
1546
1429
|
return () => {
|
|
@@ -1550,7 +1433,6 @@ function useTimeout(fn, timeout2 = 0) {
|
|
|
1550
1433
|
}
|
|
1551
1434
|
};
|
|
1552
1435
|
}
|
|
1553
|
-
__name(useTimeout, "useTimeout");
|
|
1554
1436
|
function useInterval(fn, interval) {
|
|
1555
1437
|
let intervalHandle = setInterval(fn, interval);
|
|
1556
1438
|
return () => {
|
|
@@ -1560,7 +1442,6 @@ function useInterval(fn, interval) {
|
|
|
1560
1442
|
}
|
|
1561
1443
|
};
|
|
1562
1444
|
}
|
|
1563
|
-
__name(useInterval, "useInterval");
|
|
1564
1445
|
function useEventListener(emitter, eventName, fn, ...args) {
|
|
1565
1446
|
if (emitter == null)
|
|
1566
1447
|
return () => {
|
|
@@ -1578,7 +1459,6 @@ function useEventListener(emitter, eventName, fn, ...args) {
|
|
|
1578
1459
|
}
|
|
1579
1460
|
};
|
|
1580
1461
|
}
|
|
1581
|
-
__name(useEventListener, "useEventListener");
|
|
1582
1462
|
|
|
1583
1463
|
// src/common/exec/mutex.ts
|
|
1584
1464
|
function useMutex() {
|
|
@@ -1599,7 +1479,6 @@ function useMutex() {
|
|
|
1599
1479
|
return executed;
|
|
1600
1480
|
};
|
|
1601
1481
|
}
|
|
1602
|
-
__name(useMutex, "useMutex");
|
|
1603
1482
|
function useAsyncMutex() {
|
|
1604
1483
|
let token = true;
|
|
1605
1484
|
return async (fn, elseFn) => {
|
|
@@ -1622,7 +1501,6 @@ function useAsyncMutex() {
|
|
|
1622
1501
|
return executed;
|
|
1623
1502
|
};
|
|
1624
1503
|
}
|
|
1625
|
-
__name(useAsyncMutex, "useAsyncMutex");
|
|
1626
1504
|
|
|
1627
1505
|
// src/common/msg/emitter.ts
|
|
1628
1506
|
var log5 = Logger("zeed:emitter");
|
|
@@ -1672,10 +1550,10 @@ var Emitter = class {
|
|
|
1672
1550
|
}
|
|
1673
1551
|
}
|
|
1674
1552
|
once(event, listener) {
|
|
1675
|
-
const onceListener =
|
|
1553
|
+
const onceListener = async (...args) => {
|
|
1676
1554
|
this.off(event, onceListener);
|
|
1677
1555
|
return await promisify(listener(...args));
|
|
1678
|
-
}
|
|
1556
|
+
};
|
|
1679
1557
|
this.on(event, onceListener);
|
|
1680
1558
|
return () => {
|
|
1681
1559
|
this.off(event, listener);
|
|
@@ -1694,7 +1572,6 @@ var Emitter = class {
|
|
|
1694
1572
|
this.subscribersOnAny = [];
|
|
1695
1573
|
}
|
|
1696
1574
|
};
|
|
1697
|
-
__name(Emitter, "Emitter");
|
|
1698
1575
|
function getGlobalEmitter() {
|
|
1699
1576
|
let emitter = getGlobalContext().emitter;
|
|
1700
1577
|
if (!emitter) {
|
|
@@ -1703,17 +1580,16 @@ function getGlobalEmitter() {
|
|
|
1703
1580
|
}
|
|
1704
1581
|
return emitter;
|
|
1705
1582
|
}
|
|
1706
|
-
__name(getGlobalEmitter, "getGlobalEmitter");
|
|
1707
1583
|
var messages = new Emitter();
|
|
1708
1584
|
function lazyListener(emitter, listenerKey) {
|
|
1709
1585
|
const name = Math.round(getSecureRandomIfPossible() * 100);
|
|
1710
1586
|
var events = [];
|
|
1711
1587
|
var lazyResolve;
|
|
1712
|
-
const incoming =
|
|
1588
|
+
const incoming = (key, obj) => {
|
|
1713
1589
|
let ev = { key, obj };
|
|
1714
1590
|
events.push(ev);
|
|
1715
1591
|
lazyResolve && lazyResolve();
|
|
1716
|
-
}
|
|
1592
|
+
};
|
|
1717
1593
|
if (listenerKey) {
|
|
1718
1594
|
if (emitter.on) {
|
|
1719
1595
|
emitter.on(listenerKey, (obj) => {
|
|
@@ -1735,7 +1611,7 @@ function lazyListener(emitter, listenerKey) {
|
|
|
1735
1611
|
log5.error(name, "cannot listen to all for", emitter);
|
|
1736
1612
|
}
|
|
1737
1613
|
}
|
|
1738
|
-
let on =
|
|
1614
|
+
let on = (key, skipUnmatched = true) => {
|
|
1739
1615
|
return new Promise((resolve, reject) => {
|
|
1740
1616
|
if (!key) {
|
|
1741
1617
|
key = listenerKey;
|
|
@@ -1764,10 +1640,9 @@ function lazyListener(emitter, listenerKey) {
|
|
|
1764
1640
|
}, "lazyResolve");
|
|
1765
1641
|
lazyResolve();
|
|
1766
1642
|
});
|
|
1767
|
-
}
|
|
1643
|
+
};
|
|
1768
1644
|
return on;
|
|
1769
1645
|
}
|
|
1770
|
-
__name(lazyListener, "lazyListener");
|
|
1771
1646
|
|
|
1772
1647
|
// src/common/uuid.ts
|
|
1773
1648
|
var { encode: encode62, decode: decode62 } = useBase(62);
|
|
@@ -1775,32 +1650,25 @@ var { encode: encode32, decode: decode32 } = useBase(32);
|
|
|
1775
1650
|
function uuidBytes() {
|
|
1776
1651
|
return randomUint8Array(16);
|
|
1777
1652
|
}
|
|
1778
|
-
|
|
1779
|
-
var uuid32bit = /* @__PURE__ */ __name(() => new Uint32Array(randomUint8Array(4))[0], "uuid32bit");
|
|
1653
|
+
var uuid32bit = () => new Uint32Array(randomUint8Array(4))[0];
|
|
1780
1654
|
function uuid() {
|
|
1781
1655
|
return encode62(uuidBytes(), 22);
|
|
1782
1656
|
}
|
|
1783
|
-
__name(uuid, "uuid");
|
|
1784
1657
|
function uuidEncode(bytes) {
|
|
1785
1658
|
return encode62(bytes, 22);
|
|
1786
1659
|
}
|
|
1787
|
-
__name(uuidEncode, "uuidEncode");
|
|
1788
1660
|
function uuidDecode(uuid2) {
|
|
1789
1661
|
return decode62(uuid2, 16);
|
|
1790
1662
|
}
|
|
1791
|
-
__name(uuidDecode, "uuidDecode");
|
|
1792
1663
|
function uuidB32() {
|
|
1793
1664
|
return encode32(uuidBytes(), 26);
|
|
1794
1665
|
}
|
|
1795
|
-
__name(uuidB32, "uuidB32");
|
|
1796
1666
|
function uuid32Encode(bytes) {
|
|
1797
1667
|
return encode32(bytes, 26);
|
|
1798
1668
|
}
|
|
1799
|
-
__name(uuid32Encode, "uuid32Encode");
|
|
1800
1669
|
function uuid32Decode(uuid2) {
|
|
1801
1670
|
return decode32(uuid2, 16);
|
|
1802
1671
|
}
|
|
1803
|
-
__name(uuid32Decode, "uuid32Decode");
|
|
1804
1672
|
var _unameCounters = {};
|
|
1805
1673
|
function uname(name = "id") {
|
|
1806
1674
|
if (_unameCounters[name] == null) {
|
|
@@ -1808,14 +1676,12 @@ function uname(name = "id") {
|
|
|
1808
1676
|
}
|
|
1809
1677
|
return `${name}-${_unameCounters[name]++}`;
|
|
1810
1678
|
}
|
|
1811
|
-
__name(uname, "uname");
|
|
1812
1679
|
var _qid = 0;
|
|
1813
1680
|
function qid() {
|
|
1814
1681
|
return `id-${_qid++}`;
|
|
1815
1682
|
}
|
|
1816
|
-
__name(qid, "qid");
|
|
1817
1683
|
var pattern = "10000000-1000-4000-8000-100000000000";
|
|
1818
|
-
var uuidv4 =
|
|
1684
|
+
var uuidv4 = () => pattern.replace(/[018]/g, (c) => (c ^ randomUint8Array(1)[0] & 15 >> c / 4).toString(16));
|
|
1819
1685
|
var ReferenceDateInMS = 16e11;
|
|
1820
1686
|
function longToByteArray(long) {
|
|
1821
1687
|
var byteArray = new Uint8Array([0, 0, 0, 0, 0, 0]);
|
|
@@ -1827,26 +1693,21 @@ function longToByteArray(long) {
|
|
|
1827
1693
|
}
|
|
1828
1694
|
return byteArray;
|
|
1829
1695
|
}
|
|
1830
|
-
__name(longToByteArray, "longToByteArray");
|
|
1831
1696
|
function suidBytes() {
|
|
1832
1697
|
const ms = getTimestamp() - ReferenceDateInMS;
|
|
1833
1698
|
return new Uint8Array([...longToByteArray(ms), ...randomUint8Array(10)]);
|
|
1834
1699
|
}
|
|
1835
|
-
__name(suidBytes, "suidBytes");
|
|
1836
1700
|
function suid() {
|
|
1837
1701
|
return encode62(suidBytes(), 22);
|
|
1838
1702
|
}
|
|
1839
|
-
__name(suid, "suid");
|
|
1840
1703
|
function suidDate(id) {
|
|
1841
1704
|
return suidBytesDate(decode62(id, 16));
|
|
1842
1705
|
}
|
|
1843
|
-
__name(suidDate, "suidDate");
|
|
1844
1706
|
function suidBytesDate(id) {
|
|
1845
1707
|
return new Date(ReferenceDateInMS + id.slice(0, 6).reduce((acc, byte) => {
|
|
1846
1708
|
return acc * 256 + byte;
|
|
1847
1709
|
}, 0));
|
|
1848
1710
|
}
|
|
1849
|
-
__name(suidBytesDate, "suidBytesDate");
|
|
1850
1711
|
|
|
1851
1712
|
// src/common/exec/pool.ts
|
|
1852
1713
|
var PoolTaskState = /* @__PURE__ */ ((PoolTaskState2) => {
|
|
@@ -1855,6 +1716,12 @@ var PoolTaskState = /* @__PURE__ */ ((PoolTaskState2) => {
|
|
|
1855
1716
|
PoolTaskState2[PoolTaskState2["finished"] = 2] = "finished";
|
|
1856
1717
|
return PoolTaskState2;
|
|
1857
1718
|
})(PoolTaskState || {});
|
|
1719
|
+
var PoolTaskIdConflictResolution = /* @__PURE__ */ ((PoolTaskIdConflictResolution2) => {
|
|
1720
|
+
PoolTaskIdConflictResolution2[PoolTaskIdConflictResolution2["replace"] = 0] = "replace";
|
|
1721
|
+
PoolTaskIdConflictResolution2[PoolTaskIdConflictResolution2["memoize"] = 1] = "memoize";
|
|
1722
|
+
PoolTaskIdConflictResolution2[PoolTaskIdConflictResolution2["error"] = 2] = "error";
|
|
1723
|
+
return PoolTaskIdConflictResolution2;
|
|
1724
|
+
})(PoolTaskIdConflictResolution || {});
|
|
1858
1725
|
function usePool(config = {}) {
|
|
1859
1726
|
const { maxParallel = 3 } = config;
|
|
1860
1727
|
const events = new Emitter();
|
|
@@ -1870,13 +1737,11 @@ function usePool(config = {}) {
|
|
|
1870
1737
|
return promise;
|
|
1871
1738
|
}
|
|
1872
1739
|
}
|
|
1873
|
-
__name(waitFinishAll, "waitFinishAll");
|
|
1874
1740
|
function didFinish() {
|
|
1875
1741
|
events.emit("didFinish");
|
|
1876
1742
|
countMax = 0;
|
|
1877
1743
|
countResolved = 0;
|
|
1878
1744
|
}
|
|
1879
|
-
__name(didFinish, "didFinish");
|
|
1880
1745
|
function didUpdate() {
|
|
1881
1746
|
let presentMax = 0;
|
|
1882
1747
|
let presentResolved = 0;
|
|
@@ -1886,7 +1751,6 @@ function usePool(config = {}) {
|
|
|
1886
1751
|
}
|
|
1887
1752
|
events.emit("didUpdate", countMax, countResolved, presentMax, presentResolved);
|
|
1888
1753
|
}
|
|
1889
|
-
__name(didUpdate, "didUpdate");
|
|
1890
1754
|
function performNext() {
|
|
1891
1755
|
didUpdate();
|
|
1892
1756
|
if (countMax > 0 && countMax === countResolved)
|
|
@@ -1907,19 +1771,20 @@ function usePool(config = {}) {
|
|
|
1907
1771
|
taskInfo.state = 1 /* running */;
|
|
1908
1772
|
++currentParallel;
|
|
1909
1773
|
events.emit("didStart", id);
|
|
1910
|
-
const taskFinished =
|
|
1774
|
+
const taskFinished = (result) => {
|
|
1911
1775
|
if (taskInfo) {
|
|
1776
|
+
taskInfo.result = result;
|
|
1912
1777
|
taskInfo.state = 2 /* finished */;
|
|
1913
1778
|
taskInfo.resolved = taskInfo.max;
|
|
1914
1779
|
}
|
|
1915
1780
|
--currentParallel;
|
|
1916
1781
|
++countResolved;
|
|
1917
1782
|
performNext();
|
|
1918
|
-
}
|
|
1783
|
+
};
|
|
1919
1784
|
taskInfo.task(taskInfo).then((r) => {
|
|
1920
1785
|
done(r);
|
|
1921
1786
|
events.emit("didResolve", id, r);
|
|
1922
|
-
taskFinished();
|
|
1787
|
+
taskFinished(r);
|
|
1923
1788
|
}).catch((err) => {
|
|
1924
1789
|
done();
|
|
1925
1790
|
events.emit("didReject", id, err);
|
|
@@ -1928,7 +1793,6 @@ function usePool(config = {}) {
|
|
|
1928
1793
|
}
|
|
1929
1794
|
}
|
|
1930
1795
|
}
|
|
1931
|
-
__name(performNext, "performNext");
|
|
1932
1796
|
function cancel(id) {
|
|
1933
1797
|
let taskInfo = tasks[id];
|
|
1934
1798
|
if (taskInfo && taskInfo.state === 0 /* waiting */) {
|
|
@@ -1938,41 +1802,57 @@ function usePool(config = {}) {
|
|
|
1938
1802
|
didUpdate();
|
|
1939
1803
|
}
|
|
1940
1804
|
}
|
|
1941
|
-
__name(cancel, "cancel");
|
|
1942
1805
|
function cancelAll() {
|
|
1943
1806
|
Object.keys(tasks).forEach(cancel);
|
|
1944
1807
|
}
|
|
1945
|
-
__name(cancelAll, "cancelAll");
|
|
1946
1808
|
function enqueue(task, config2 = {}) {
|
|
1947
|
-
var _a, _b, _c;
|
|
1809
|
+
var _a, _b, _c, _d;
|
|
1948
1810
|
let done;
|
|
1949
1811
|
let promise = new Promise((resolve) => done = resolve);
|
|
1950
1812
|
let id = (_a = config2.id) != null ? _a : uuid();
|
|
1951
|
-
if (tasks[id]
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
didUpdate();
|
|
1971
|
-
}
|
|
1972
|
-
};
|
|
1973
|
-
++countMax;
|
|
1974
|
-
performNext();
|
|
1813
|
+
if (tasks[id] != null) {
|
|
1814
|
+
const resolution = (_b = config2.idConflictResolution) != null ? _b : 1 /* memoize */;
|
|
1815
|
+
if (resolution === 0 /* replace */) {
|
|
1816
|
+
cancel(id);
|
|
1817
|
+
} else if (resolution === 1 /* memoize */) {
|
|
1818
|
+
let runningTask = tasks[id];
|
|
1819
|
+
return {
|
|
1820
|
+
id,
|
|
1821
|
+
promise: (async () => {
|
|
1822
|
+
if (runningTask.state === 2 /* finished */) {
|
|
1823
|
+
return tasks[id].result;
|
|
1824
|
+
}
|
|
1825
|
+
})(),
|
|
1826
|
+
dispose: () => cancel(id),
|
|
1827
|
+
cancel: () => cancel(id)
|
|
1828
|
+
};
|
|
1829
|
+
} else {
|
|
1830
|
+
throw new Error(`Pool task with id=${id} already exists!`);
|
|
1831
|
+
}
|
|
1975
1832
|
}
|
|
1833
|
+
tasks[id] = {
|
|
1834
|
+
id,
|
|
1835
|
+
task,
|
|
1836
|
+
priority: ++priority,
|
|
1837
|
+
state: 0 /* waiting */,
|
|
1838
|
+
max: (_c = config2.max) != null ? _c : 1,
|
|
1839
|
+
resolved: (_d = config2.resolved) != null ? _d : 0,
|
|
1840
|
+
done,
|
|
1841
|
+
setMax(max) {
|
|
1842
|
+
tasks[id].max = max;
|
|
1843
|
+
didUpdate();
|
|
1844
|
+
},
|
|
1845
|
+
setResolved(max) {
|
|
1846
|
+
tasks[id].resolved = max;
|
|
1847
|
+
didUpdate();
|
|
1848
|
+
},
|
|
1849
|
+
incResolved(inc = 1) {
|
|
1850
|
+
tasks[id].resolved += inc;
|
|
1851
|
+
didUpdate();
|
|
1852
|
+
}
|
|
1853
|
+
};
|
|
1854
|
+
++countMax;
|
|
1855
|
+
performNext();
|
|
1976
1856
|
return {
|
|
1977
1857
|
id,
|
|
1978
1858
|
promise,
|
|
@@ -1980,7 +1860,6 @@ function usePool(config = {}) {
|
|
|
1980
1860
|
cancel: () => cancel(id)
|
|
1981
1861
|
};
|
|
1982
1862
|
}
|
|
1983
|
-
__name(enqueue, "enqueue");
|
|
1984
1863
|
return {
|
|
1985
1864
|
events,
|
|
1986
1865
|
cancel,
|
|
@@ -1990,7 +1869,6 @@ function usePool(config = {}) {
|
|
|
1990
1869
|
waitFinishAll
|
|
1991
1870
|
};
|
|
1992
1871
|
}
|
|
1993
|
-
__name(usePool, "usePool");
|
|
1994
1872
|
|
|
1995
1873
|
// src/common/exec/queue.ts
|
|
1996
1874
|
var log6 = Logger("zeed:queue");
|
|
@@ -2108,7 +1986,6 @@ var SerialQueue = class extends Emitter {
|
|
|
2108
1986
|
return this.queue.length !== 0;
|
|
2109
1987
|
}
|
|
2110
1988
|
};
|
|
2111
|
-
__name(SerialQueue, "SerialQueue");
|
|
2112
1989
|
|
|
2113
1990
|
// src/common/exec/throttle-debounce.ts
|
|
2114
1991
|
var DEBUG = false;
|
|
@@ -2127,7 +2004,6 @@ function throttle(callback, opt = {}) {
|
|
|
2127
2004
|
timeoutID = void 0;
|
|
2128
2005
|
}
|
|
2129
2006
|
}
|
|
2130
|
-
__name(clearExistingTimeout, "clearExistingTimeout");
|
|
2131
2007
|
function wrapper(...args) {
|
|
2132
2008
|
const now = Date.now();
|
|
2133
2009
|
let self2 = this;
|
|
@@ -2136,13 +2012,11 @@ function throttle(callback, opt = {}) {
|
|
|
2136
2012
|
const dnow = Date.now();
|
|
2137
2013
|
return `total ${(dnow - debugCheckpoint).toFixed(1)}ms - elapsed ${(dnow - checkpoint).toFixed(1)}ms - visited ${visited}x`;
|
|
2138
2014
|
}
|
|
2139
|
-
__name(debugElapsed, "debugElapsed");
|
|
2140
2015
|
function exec() {
|
|
2141
2016
|
visited = 0;
|
|
2142
2017
|
checkpoint = Date.now();
|
|
2143
2018
|
callback.apply(self2, args);
|
|
2144
2019
|
}
|
|
2145
|
-
__name(exec, "exec");
|
|
2146
2020
|
trailingExec = exec;
|
|
2147
2021
|
if (elapsed > delay || !timeoutID) {
|
|
2148
2022
|
DEBUG && log7("elapsed", debugElapsed());
|
|
@@ -2171,12 +2045,10 @@ function throttle(callback, opt = {}) {
|
|
|
2171
2045
|
DEBUG && log7("visited", debugElapsed());
|
|
2172
2046
|
}
|
|
2173
2047
|
}
|
|
2174
|
-
__name(wrapper, "wrapper");
|
|
2175
2048
|
wrapper.cancel = clearExistingTimeout;
|
|
2176
2049
|
wrapper.dispose = clearExistingTimeout;
|
|
2177
2050
|
return wrapper;
|
|
2178
2051
|
}
|
|
2179
|
-
__name(throttle, "throttle");
|
|
2180
2052
|
function debounce(callback, opt = {}) {
|
|
2181
2053
|
const { delay = 100 } = opt;
|
|
2182
2054
|
let timeoutID = 0;
|
|
@@ -2186,7 +2058,6 @@ function debounce(callback, opt = {}) {
|
|
|
2186
2058
|
timeoutID = 0;
|
|
2187
2059
|
}
|
|
2188
2060
|
}
|
|
2189
|
-
__name(clearExistingTimeout, "clearExistingTimeout");
|
|
2190
2061
|
function wrapper(...arguments_) {
|
|
2191
2062
|
let self2 = this;
|
|
2192
2063
|
clearExistingTimeout();
|
|
@@ -2195,18 +2066,15 @@ function debounce(callback, opt = {}) {
|
|
|
2195
2066
|
callback.apply(self2, arguments_);
|
|
2196
2067
|
}, delay);
|
|
2197
2068
|
}
|
|
2198
|
-
__name(wrapper, "wrapper");
|
|
2199
2069
|
wrapper.cancel = clearExistingTimeout;
|
|
2200
2070
|
wrapper.dispose = clearExistingTimeout;
|
|
2201
2071
|
return wrapper;
|
|
2202
2072
|
}
|
|
2203
|
-
__name(debounce, "debounce");
|
|
2204
2073
|
|
|
2205
2074
|
// src/common/localhost.ts
|
|
2206
2075
|
function isLocalHost(hostname = ((_b) => (_b = ((_a) => (_a = globalThis == null ? void 0 : globalThis.location) == null ? void 0 : _a.hostname)()) != null ? _b : "")()) {
|
|
2207
2076
|
return ["localhost", "127.0.0.1", "", "::1", "::"].includes(hostname) || hostname.startsWith("192.168.") || hostname.startsWith("10.0.") || hostname.endsWith(".local");
|
|
2208
2077
|
}
|
|
2209
|
-
__name(isLocalHost, "isLocalHost");
|
|
2210
2078
|
|
|
2211
2079
|
// src/common/log-memory.ts
|
|
2212
2080
|
function LoggerMemoryHandler(opt) {
|
|
@@ -2221,7 +2089,6 @@ function LoggerMemoryHandler(opt) {
|
|
|
2221
2089
|
messages2.push(msg);
|
|
2222
2090
|
};
|
|
2223
2091
|
}
|
|
2224
|
-
__name(LoggerMemoryHandler, "LoggerMemoryHandler");
|
|
2225
2092
|
|
|
2226
2093
|
// src/common/msg/channel.ts
|
|
2227
2094
|
var Channel = class extends Emitter {
|
|
@@ -2232,7 +2099,6 @@ var Channel = class extends Emitter {
|
|
|
2232
2099
|
close() {
|
|
2233
2100
|
}
|
|
2234
2101
|
};
|
|
2235
|
-
__name(Channel, "Channel");
|
|
2236
2102
|
var LocalChannel = class extends Channel {
|
|
2237
2103
|
constructor() {
|
|
2238
2104
|
super(...arguments);
|
|
@@ -2247,7 +2113,6 @@ var LocalChannel = class extends Channel {
|
|
|
2247
2113
|
});
|
|
2248
2114
|
}
|
|
2249
2115
|
};
|
|
2250
|
-
__name(LocalChannel, "LocalChannel");
|
|
2251
2116
|
function fakeWorkerPair() {
|
|
2252
2117
|
let w1 = new LocalChannel();
|
|
2253
2118
|
let w2 = new LocalChannel();
|
|
@@ -2255,7 +2120,6 @@ function fakeWorkerPair() {
|
|
|
2255
2120
|
w2.other = w1;
|
|
2256
2121
|
return [w1, w2];
|
|
2257
2122
|
}
|
|
2258
|
-
__name(fakeWorkerPair, "fakeWorkerPair");
|
|
2259
2123
|
|
|
2260
2124
|
// src/common/msg/encoder.ts
|
|
2261
2125
|
var NoopEncoder = class {
|
|
@@ -2266,7 +2130,6 @@ var NoopEncoder = class {
|
|
|
2266
2130
|
return data;
|
|
2267
2131
|
}
|
|
2268
2132
|
};
|
|
2269
|
-
__name(NoopEncoder, "NoopEncoder");
|
|
2270
2133
|
var JsonEncoder = class {
|
|
2271
2134
|
async encode(data) {
|
|
2272
2135
|
return jsonToUint8Array(data);
|
|
@@ -2275,7 +2138,6 @@ var JsonEncoder = class {
|
|
|
2275
2138
|
return Uint8ArrayToJson(data);
|
|
2276
2139
|
}
|
|
2277
2140
|
};
|
|
2278
|
-
__name(JsonEncoder, "JsonEncoder");
|
|
2279
2141
|
var CryptoEncoder = class {
|
|
2280
2142
|
constructor(key) {
|
|
2281
2143
|
this.key = key;
|
|
@@ -2289,16 +2151,15 @@ var CryptoEncoder = class {
|
|
|
2289
2151
|
return Uint8ArrayToJson(plain);
|
|
2290
2152
|
}
|
|
2291
2153
|
};
|
|
2292
|
-
__name(CryptoEncoder, "CryptoEncoder");
|
|
2293
2154
|
|
|
2294
2155
|
// src/common/msg/messages.ts
|
|
2295
|
-
var createPromiseProxy =
|
|
2156
|
+
var createPromiseProxy = (fn, opt, predefinedMethods = {}) => new Proxy(predefinedMethods, {
|
|
2296
2157
|
get: (target, name) => {
|
|
2297
2158
|
if (name in target)
|
|
2298
2159
|
return target[name];
|
|
2299
2160
|
return (...args) => fn(name, args, opt);
|
|
2300
2161
|
}
|
|
2301
|
-
})
|
|
2162
|
+
});
|
|
2302
2163
|
function useMessageHub(opt = {}) {
|
|
2303
2164
|
let {
|
|
2304
2165
|
name = uname("hub"),
|
|
@@ -2312,10 +2173,10 @@ function useMessageHub(opt = {}) {
|
|
|
2312
2173
|
let queue = [];
|
|
2313
2174
|
let queueRetryTimer;
|
|
2314
2175
|
let waitingForResponse = {};
|
|
2315
|
-
const dispose =
|
|
2176
|
+
const dispose = () => {
|
|
2316
2177
|
clearTimeout(queueRetryTimer);
|
|
2317
|
-
}
|
|
2318
|
-
const postNext =
|
|
2178
|
+
};
|
|
2179
|
+
const postNext = async () => {
|
|
2319
2180
|
clearTimeout(queueRetryTimer);
|
|
2320
2181
|
if (channel) {
|
|
2321
2182
|
if (channel.isConnected) {
|
|
@@ -2334,13 +2195,13 @@ function useMessageHub(opt = {}) {
|
|
|
2334
2195
|
queueRetryTimer = setTimeout(postNext, retryAfter);
|
|
2335
2196
|
}
|
|
2336
2197
|
}
|
|
2337
|
-
}
|
|
2338
|
-
const postMessage =
|
|
2198
|
+
};
|
|
2199
|
+
const postMessage = async (message) => {
|
|
2339
2200
|
log10("enqueue postMessage", message);
|
|
2340
2201
|
queue.push(message);
|
|
2341
2202
|
await postNext();
|
|
2342
|
-
}
|
|
2343
|
-
const connect =
|
|
2203
|
+
};
|
|
2204
|
+
const connect = async (newChannel) => {
|
|
2344
2205
|
channel = newChannel;
|
|
2345
2206
|
channel.on("connect", postNext);
|
|
2346
2207
|
channel.on("message", async (msg) => {
|
|
@@ -2400,8 +2261,8 @@ function useMessageHub(opt = {}) {
|
|
|
2400
2261
|
}
|
|
2401
2262
|
});
|
|
2402
2263
|
postNext();
|
|
2403
|
-
}
|
|
2404
|
-
const fetchMessage =
|
|
2264
|
+
};
|
|
2265
|
+
const fetchMessage = async (name2, args, opt2 = {}) => {
|
|
2405
2266
|
const { timeout: timeout2 = 5e3 } = opt2;
|
|
2406
2267
|
const id = uuid();
|
|
2407
2268
|
postMessage({
|
|
@@ -2410,7 +2271,7 @@ function useMessageHub(opt = {}) {
|
|
|
2410
2271
|
id
|
|
2411
2272
|
});
|
|
2412
2273
|
return tryTimeout(new Promise((resolve, reject) => waitingForResponse[id] = [resolve, reject]), timeout2);
|
|
2413
|
-
}
|
|
2274
|
+
};
|
|
2414
2275
|
if (opt.channel) {
|
|
2415
2276
|
connect(opt.channel);
|
|
2416
2277
|
}
|
|
@@ -2429,7 +2290,6 @@ function useMessageHub(opt = {}) {
|
|
|
2429
2290
|
}
|
|
2430
2291
|
};
|
|
2431
2292
|
}
|
|
2432
|
-
__name(useMessageHub, "useMessageHub");
|
|
2433
2293
|
|
|
2434
2294
|
// src/common/msg/pubsub.ts
|
|
2435
2295
|
var PubSub = class extends Emitter {
|
|
@@ -2489,11 +2349,9 @@ var PubSub = class extends Emitter {
|
|
|
2489
2349
|
return false;
|
|
2490
2350
|
}
|
|
2491
2351
|
};
|
|
2492
|
-
__name(PubSub, "PubSub");
|
|
2493
2352
|
function usePubSub(opt) {
|
|
2494
2353
|
return new PubSub(opt);
|
|
2495
2354
|
}
|
|
2496
|
-
__name(usePubSub, "usePubSub");
|
|
2497
2355
|
|
|
2498
2356
|
// src/common/msg/rpc.ts
|
|
2499
2357
|
var rpcCounter = 1;
|
|
@@ -2534,26 +2392,25 @@ function useRPC(functions, options) {
|
|
|
2534
2392
|
});
|
|
2535
2393
|
return new Proxy({}, {
|
|
2536
2394
|
get(_, method) {
|
|
2537
|
-
const sendEvent =
|
|
2395
|
+
const sendEvent = (...args) => {
|
|
2538
2396
|
post(serialize([2 /* event */, args, null, method]));
|
|
2539
|
-
}
|
|
2397
|
+
};
|
|
2540
2398
|
if (options.onlyEvents || eventNames.includes(method)) {
|
|
2541
2399
|
sendEvent.asEvent = sendEvent;
|
|
2542
2400
|
return sendEvent;
|
|
2543
2401
|
}
|
|
2544
|
-
const sendCall =
|
|
2402
|
+
const sendCall = (...args) => {
|
|
2545
2403
|
return new Promise((resolve, reject) => {
|
|
2546
2404
|
const id = rpcCounter++;
|
|
2547
2405
|
rpcPromiseMap.set(id, { resolve, reject });
|
|
2548
2406
|
post(serialize([1 /* request */, args, id, method]));
|
|
2549
2407
|
});
|
|
2550
|
-
}
|
|
2408
|
+
};
|
|
2551
2409
|
sendCall.asEvent = sendEvent;
|
|
2552
2410
|
return sendCall;
|
|
2553
2411
|
}
|
|
2554
2412
|
});
|
|
2555
2413
|
}
|
|
2556
|
-
__name(useRPC, "useRPC");
|
|
2557
2414
|
|
|
2558
2415
|
// src/common/network.ts
|
|
2559
2416
|
var log8 = Logger("network");
|
|
@@ -2577,7 +2434,6 @@ async function fetchBasic(url, fetchOptions = {}, fetchFn = fetch) {
|
|
|
2577
2434
|
log8.error("fetchBasic", err);
|
|
2578
2435
|
}
|
|
2579
2436
|
}
|
|
2580
|
-
__name(fetchBasic, "fetchBasic");
|
|
2581
2437
|
async function fetchJson(url, opts = {}, fetchFn = fetch) {
|
|
2582
2438
|
try {
|
|
2583
2439
|
let res = await fetchBasic(url, __spreadValues(__spreadProps(__spreadValues({
|
|
@@ -2592,7 +2448,6 @@ async function fetchJson(url, opts = {}, fetchFn = fetch) {
|
|
|
2592
2448
|
log8.error("fetchJSON error:", err);
|
|
2593
2449
|
}
|
|
2594
2450
|
}
|
|
2595
|
-
__name(fetchJson, "fetchJson");
|
|
2596
2451
|
function fetchOptionsFormURLEncoded(data, method = "POST") {
|
|
2597
2452
|
return __spreadProps(__spreadValues({
|
|
2598
2453
|
method
|
|
@@ -2603,7 +2458,6 @@ function fetchOptionsFormURLEncoded(data, method = "POST") {
|
|
|
2603
2458
|
body: encodeQuery(data)
|
|
2604
2459
|
});
|
|
2605
2460
|
}
|
|
2606
|
-
__name(fetchOptionsFormURLEncoded, "fetchOptionsFormURLEncoded");
|
|
2607
2461
|
function fetchOptionsJson(data, method = "POST") {
|
|
2608
2462
|
return __spreadProps(__spreadValues({
|
|
2609
2463
|
method
|
|
@@ -2615,7 +2469,6 @@ function fetchOptionsJson(data, method = "POST") {
|
|
|
2615
2469
|
body: JSON.stringify(data)
|
|
2616
2470
|
});
|
|
2617
2471
|
}
|
|
2618
|
-
__name(fetchOptionsJson, "fetchOptionsJson");
|
|
2619
2472
|
async function fetchText(url, opts = {}, fetchFn = fetch) {
|
|
2620
2473
|
try {
|
|
2621
2474
|
let res = await fetchBasic(url, __spreadValues(__spreadProps(__spreadValues({
|
|
@@ -2630,24 +2483,20 @@ async function fetchText(url, opts = {}, fetchFn = fetch) {
|
|
|
2630
2483
|
log8.error("fetchHTML error:", err);
|
|
2631
2484
|
}
|
|
2632
2485
|
}
|
|
2633
|
-
__name(fetchText, "fetchText");
|
|
2634
2486
|
|
|
2635
2487
|
// src/common/platform.ts
|
|
2636
2488
|
function getWindow() {
|
|
2637
2489
|
if (typeof window !== "undefined")
|
|
2638
2490
|
return window;
|
|
2639
2491
|
}
|
|
2640
|
-
__name(getWindow, "getWindow");
|
|
2641
2492
|
function getNavigator() {
|
|
2642
2493
|
if (typeof navigator !== "undefined")
|
|
2643
2494
|
return navigator;
|
|
2644
2495
|
}
|
|
2645
|
-
__name(getNavigator, "getNavigator");
|
|
2646
2496
|
function getGlobal() {
|
|
2647
2497
|
var _a;
|
|
2648
2498
|
return ((_a = getWindow()) != null ? _a : typeof WorkerGlobalScope !== "undefined") ? self : typeof global !== "undefined" ? global : Function("return this;")();
|
|
2649
2499
|
}
|
|
2650
|
-
__name(getGlobal, "getGlobal");
|
|
2651
2500
|
var _navigator = getNavigator();
|
|
2652
2501
|
var _window = getWindow();
|
|
2653
2502
|
function detect(info = {
|
|
@@ -2689,8 +2538,7 @@ function detect(info = {
|
|
|
2689
2538
|
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;
|
|
2690
2539
|
return info;
|
|
2691
2540
|
}
|
|
2692
|
-
|
|
2693
|
-
var isBrowser = /* @__PURE__ */ __name(() => typeof window !== "undefined" && globalThis === window, "isBrowser");
|
|
2541
|
+
var isBrowser = () => typeof window !== "undefined" && globalThis === window;
|
|
2694
2542
|
var platform = detect();
|
|
2695
2543
|
function useExitHandler(handler) {
|
|
2696
2544
|
if (isBrowser()) {
|
|
@@ -2699,7 +2547,6 @@ function useExitHandler(handler) {
|
|
|
2699
2547
|
process.on("exit", () => handler);
|
|
2700
2548
|
}
|
|
2701
2549
|
}
|
|
2702
|
-
__name(useExitHandler, "useExitHandler");
|
|
2703
2550
|
|
|
2704
2551
|
// src/common/storage/memstorage.ts
|
|
2705
2552
|
var log9 = Logger("zeed:memstorage");
|
|
@@ -2725,7 +2572,6 @@ var MemStorage = class {
|
|
|
2725
2572
|
return Object.keys(this.store);
|
|
2726
2573
|
}
|
|
2727
2574
|
};
|
|
2728
|
-
__name(MemStorage, "MemStorage");
|
|
2729
2575
|
|
|
2730
2576
|
export {
|
|
2731
2577
|
_encodeUtf8Polyfill,
|
|
@@ -2893,6 +2739,7 @@ export {
|
|
|
2893
2739
|
suidDate,
|
|
2894
2740
|
suidBytesDate,
|
|
2895
2741
|
PoolTaskState,
|
|
2742
|
+
PoolTaskIdConflictResolution,
|
|
2896
2743
|
usePool,
|
|
2897
2744
|
SerialQueue,
|
|
2898
2745
|
throttle,
|
|
@@ -2924,4 +2771,4 @@ export {
|
|
|
2924
2771
|
useExitHandler,
|
|
2925
2772
|
MemStorage
|
|
2926
2773
|
};
|
|
2927
|
-
//# sourceMappingURL=chunk-
|
|
2774
|
+
//# sourceMappingURL=chunk-AA43JNUH.js.map
|