@dxos/util 0.8.4-main.3f58842 → 0.8.4-main.40e3dcdf1b
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/lib/browser/index.mjs +418 -140
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +418 -140
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/array.d.ts +3 -2
- package/dist/types/src/array.d.ts.map +1 -1
- package/dist/types/src/circular-buffer.d.ts +1 -0
- package/dist/types/src/circular-buffer.d.ts.map +1 -1
- package/dist/types/src/deep.d.ts +0 -3
- package/dist/types/src/deep.d.ts.map +1 -1
- package/dist/types/src/defer.d.ts +1 -1
- package/dist/types/src/defer.d.ts.map +1 -1
- package/dist/types/src/di-key.d.ts +3 -3
- package/dist/types/src/di-key.d.ts.map +1 -1
- package/dist/types/src/error-format.d.ts +5 -0
- package/dist/types/src/error-format.d.ts.map +1 -0
- package/dist/types/src/filename.d.ts +9 -0
- package/dist/types/src/filename.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/platform.d.ts +4 -1
- package/dist/types/src/platform.d.ts.map +1 -1
- package/dist/types/src/retry.d.ts +32 -0
- package/dist/types/src/retry.d.ts.map +1 -0
- package/dist/types/src/safe-parse.d.ts +7 -4
- package/dist/types/src/safe-parse.d.ts.map +1 -1
- package/dist/types/src/safe-stringify.d.ts +22 -0
- package/dist/types/src/safe-stringify.d.ts.map +1 -0
- package/dist/types/src/safe-stringify.test.d.ts +2 -0
- package/dist/types/src/safe-stringify.test.d.ts.map +1 -0
- package/dist/types/src/string.d.ts +5 -1
- package/dist/types/src/string.d.ts.map +1 -1
- package/dist/types/src/to-fallback.d.ts +18 -4
- package/dist/types/src/to-fallback.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +24 -6
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/unit.d.ts +14 -0
- package/dist/types/src/unit.d.ts.map +1 -0
- package/dist/types/src/unit.test.d.ts +2 -0
- package/dist/types/src/unit.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -13
- package/src/array.test.ts +1 -1
- package/src/array.ts +9 -2
- package/src/binder.ts +2 -2
- package/src/circular-buffer.test.ts +27 -1
- package/src/circular-buffer.ts +5 -0
- package/src/complex.test.ts +1 -1
- package/src/deep.ts +2 -6
- package/src/defer.ts +1 -1
- package/src/error-format.ts +22 -0
- package/src/filename.ts +16 -0
- package/src/human-hash.test.ts +1 -1
- package/src/index.ts +5 -1
- package/src/platform.ts +35 -3
- package/src/position.test.ts +2 -2
- package/src/retry.ts +74 -0
- package/src/safe-parse.ts +29 -17
- package/src/safe-stringify.test.ts +96 -0
- package/src/safe-stringify.ts +153 -0
- package/src/sort.test.ts +1 -1
- package/src/string.test.ts +1 -1
- package/src/string.ts +32 -6
- package/src/to-fallback.ts +44 -160
- package/src/tree.test.ts +1 -1
- package/src/types.test.ts +11 -1
- package/src/types.ts +40 -12
- package/src/uint8array.test.ts +1 -1
- package/src/unit.test.ts +25 -0
- package/src/unit.ts +83 -0
- package/src/weak.test.ts +1 -1
- package/dist/types/src/explicit-resource-management-polyfill.d.ts +0 -1
- package/dist/types/src/explicit-resource-management-polyfill.d.ts.map +0 -1
- package/dist/types/src/first-two-chars.d.ts +0 -9
- package/dist/types/src/first-two-chars.d.ts.map +0 -1
- package/src/explicit-resource-management-polyfill.ts +0 -13
- package/src/first-two-chars.ts +0 -44
|
@@ -97,16 +97,24 @@ var intersectBy = (arrays, selector) => {
|
|
|
97
97
|
return lookups.every((lookup) => lookup.has(key));
|
|
98
98
|
});
|
|
99
99
|
};
|
|
100
|
+
var coerceArray = (arr) => {
|
|
101
|
+
if (arr === void 0) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
return Array.isArray(arr) ? arr : [
|
|
105
|
+
arr
|
|
106
|
+
];
|
|
107
|
+
};
|
|
100
108
|
|
|
101
109
|
// src/assume.ts
|
|
102
110
|
function assumeType(value) {
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
// src/binder.ts
|
|
106
|
-
import
|
|
114
|
+
import { promisify } from "@dxos/node-std/util";
|
|
107
115
|
var createBinder = (obj) => ({
|
|
108
116
|
fn: (fn) => fn.bind(obj),
|
|
109
|
-
async: (fn) =>
|
|
117
|
+
async: (fn) => promisify(fn.bind(obj))
|
|
110
118
|
});
|
|
111
119
|
|
|
112
120
|
// src/bitfield.ts
|
|
@@ -207,6 +215,7 @@ var CallbackCollection = class {
|
|
|
207
215
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
208
216
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/util/src/callback.ts";
|
|
209
217
|
var Callback = class {
|
|
218
|
+
_callback;
|
|
210
219
|
call(...args) {
|
|
211
220
|
invariant2(this._callback, "Callback not set", {
|
|
212
221
|
F: __dxlog_file2,
|
|
@@ -301,9 +310,10 @@ var chunkArray = (array, size) => {
|
|
|
301
310
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
302
311
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/util/src/circular-buffer.ts";
|
|
303
312
|
var CircularBuffer = class {
|
|
313
|
+
_buffer;
|
|
314
|
+
_nextIndex = 0;
|
|
315
|
+
_elementCount = 0;
|
|
304
316
|
constructor(size) {
|
|
305
|
-
this._nextIndex = 0;
|
|
306
|
-
this._elementCount = 0;
|
|
307
317
|
invariant3(size >= 1, void 0, {
|
|
308
318
|
F: __dxlog_file3,
|
|
309
319
|
L: 13,
|
|
@@ -325,6 +335,10 @@ var CircularBuffer = class {
|
|
|
325
335
|
get elementCount() {
|
|
326
336
|
return this._elementCount;
|
|
327
337
|
}
|
|
338
|
+
clear() {
|
|
339
|
+
this._nextIndex = 0;
|
|
340
|
+
this._elementCount = 0;
|
|
341
|
+
}
|
|
328
342
|
getLast() {
|
|
329
343
|
if (this._elementCount === 0) {
|
|
330
344
|
return void 0;
|
|
@@ -374,10 +388,11 @@ import { inspect } from "@dxos/node-std/util";
|
|
|
374
388
|
import { inspectObject, raise } from "@dxos/debug";
|
|
375
389
|
var MAX_SERIALIZATION_LENGTH = 10;
|
|
376
390
|
var ComplexSet = class {
|
|
391
|
+
_projection;
|
|
392
|
+
_values = /* @__PURE__ */ new Map();
|
|
377
393
|
// prettier-ignore
|
|
378
394
|
constructor(_projection, values) {
|
|
379
395
|
this._projection = _projection;
|
|
380
|
-
this._values = /* @__PURE__ */ new Map();
|
|
381
396
|
if (values) {
|
|
382
397
|
for (const value of values) {
|
|
383
398
|
this.add(value);
|
|
@@ -467,11 +482,12 @@ var makeSet = (projection) => {
|
|
|
467
482
|
};
|
|
468
483
|
};
|
|
469
484
|
var ComplexMap = class _ComplexMap {
|
|
485
|
+
_keyProjection;
|
|
486
|
+
_keys = /* @__PURE__ */ new Map();
|
|
487
|
+
_values = /* @__PURE__ */ new Map();
|
|
470
488
|
// prettier-ignore
|
|
471
489
|
constructor(_keyProjection, entries2) {
|
|
472
490
|
this._keyProjection = _keyProjection;
|
|
473
|
-
this._keys = /* @__PURE__ */ new Map();
|
|
474
|
-
this._values = /* @__PURE__ */ new Map();
|
|
475
491
|
if (entries2) {
|
|
476
492
|
for (const [key, value] of entries2) {
|
|
477
493
|
this.set(key, value);
|
|
@@ -556,14 +572,12 @@ var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
|
|
|
556
572
|
};
|
|
557
573
|
|
|
558
574
|
// src/deep.ts
|
|
559
|
-
import get from "lodash.get";
|
|
560
|
-
import set from "lodash.set";
|
|
561
575
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
562
576
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/common/util/src/deep.ts";
|
|
563
577
|
var setDeep = (obj, path, value) => {
|
|
564
578
|
invariant4(path.length > 0, void 0, {
|
|
565
579
|
F: __dxlog_file4,
|
|
566
|
-
L:
|
|
580
|
+
L: 12,
|
|
567
581
|
S: void 0,
|
|
568
582
|
A: [
|
|
569
583
|
"path.length > 0",
|
|
@@ -592,13 +606,11 @@ var getDeep = (obj, path) => {
|
|
|
592
606
|
// src/defer-function.ts
|
|
593
607
|
var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
|
|
594
608
|
|
|
595
|
-
// src/explicit-resource-management-polyfill.ts
|
|
596
|
-
Symbol.dispose ??= Symbol("Symbol.dispose");
|
|
597
|
-
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
598
|
-
|
|
599
609
|
// src/defer.ts
|
|
610
|
+
import "@hazae41/symbol-dispose-polyfill";
|
|
600
611
|
var defer = (fn) => new DeferGuard(fn);
|
|
601
612
|
var DeferGuard = class {
|
|
613
|
+
_fn;
|
|
602
614
|
/**
|
|
603
615
|
* @internal
|
|
604
616
|
*/
|
|
@@ -614,6 +626,7 @@ var DeferGuard = class {
|
|
|
614
626
|
};
|
|
615
627
|
var deferAsync = (fn) => new DeferAsyncGuard(fn);
|
|
616
628
|
var DeferAsyncGuard = class {
|
|
629
|
+
_fn;
|
|
617
630
|
/**
|
|
618
631
|
* @internal
|
|
619
632
|
*/
|
|
@@ -628,6 +641,8 @@ var DeferAsyncGuard = class {
|
|
|
628
641
|
// src/entry.ts
|
|
629
642
|
var entry = (map, key) => new MapEntry(map, key);
|
|
630
643
|
var MapEntry = class {
|
|
644
|
+
_map;
|
|
645
|
+
_key;
|
|
631
646
|
/**
|
|
632
647
|
* @internal
|
|
633
648
|
*/
|
|
@@ -653,32 +668,11 @@ var MapEntry = class {
|
|
|
653
668
|
}
|
|
654
669
|
};
|
|
655
670
|
|
|
656
|
-
// src/
|
|
657
|
-
var
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
"",
|
|
662
|
-
""
|
|
663
|
-
];
|
|
664
|
-
let foundFirst = false;
|
|
665
|
-
for (let i = 0; i < characters.length; i++) {
|
|
666
|
-
const char = characters[i];
|
|
667
|
-
if (renderableCharRegex.test(char)) {
|
|
668
|
-
if (!foundFirst) {
|
|
669
|
-
result[0] = char;
|
|
670
|
-
foundFirst = true;
|
|
671
|
-
} else {
|
|
672
|
-
const textBetween = characters.slice(result[0].length, i).join("");
|
|
673
|
-
if (/[^\p{L}\p{N}_]/u.test(textBetween)) {
|
|
674
|
-
result[1] = char;
|
|
675
|
-
break;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
return result;
|
|
681
|
-
};
|
|
671
|
+
// src/filename.ts
|
|
672
|
+
var createFilename = ({ parts = [], ext, date = /* @__PURE__ */ new Date() }) => [
|
|
673
|
+
date.toISOString().replace(/[:.]/g, "-"),
|
|
674
|
+
...parts
|
|
675
|
+
].join("_") + (ext ? `.${ext}` : "");
|
|
682
676
|
|
|
683
677
|
// src/for-each-async.ts
|
|
684
678
|
var forEachAsync = (items, fn) => Promise.all(items.map(fn));
|
|
@@ -944,6 +938,7 @@ var DEFAULT_WORDLIST = [
|
|
|
944
938
|
"zulu"
|
|
945
939
|
];
|
|
946
940
|
var HumanHasher = class {
|
|
941
|
+
wordlist;
|
|
947
942
|
/**
|
|
948
943
|
* Transforms hex digests to human-readable strings.
|
|
949
944
|
*
|
|
@@ -1025,7 +1020,7 @@ var defaultMap = (map, key, def) => {
|
|
|
1025
1020
|
};
|
|
1026
1021
|
|
|
1027
1022
|
// src/instance-id.ts
|
|
1028
|
-
var symbol = Symbol.for("dxos.instance-contexts");
|
|
1023
|
+
var symbol = /* @__PURE__ */ Symbol.for("dxos.instance-contexts");
|
|
1029
1024
|
var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
|
|
1030
1025
|
var getPrototypeSpecificInstanceId = (instance) => {
|
|
1031
1026
|
const prototype = Object.getPrototypeOf(instance);
|
|
@@ -1209,31 +1204,10 @@ var deepMapValues = (value, fn) => {
|
|
|
1209
1204
|
return new DeepMapper(fn).map(value);
|
|
1210
1205
|
};
|
|
1211
1206
|
var DeepMapper = class {
|
|
1207
|
+
_fn;
|
|
1208
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1212
1209
|
constructor(_fn) {
|
|
1213
1210
|
this._fn = _fn;
|
|
1214
|
-
this._cyclic = /* @__PURE__ */ new Map();
|
|
1215
|
-
this._recurse = (value) => {
|
|
1216
|
-
if (this._cyclic.has(value)) {
|
|
1217
|
-
return this._cyclic.get(value);
|
|
1218
|
-
}
|
|
1219
|
-
if (Array.isArray(value)) {
|
|
1220
|
-
const res = new Array(value.length);
|
|
1221
|
-
this._cyclic.set(value, res);
|
|
1222
|
-
for (let i = 0; i < value.length; i++) {
|
|
1223
|
-
res[i] = this._map(value[i], i);
|
|
1224
|
-
}
|
|
1225
|
-
return res;
|
|
1226
|
-
} else if (value !== null && typeof value === "object") {
|
|
1227
|
-
const res = {};
|
|
1228
|
-
this._cyclic.set(value, res);
|
|
1229
|
-
for (const key in value) {
|
|
1230
|
-
res[key] = this._map(value[key], key);
|
|
1231
|
-
}
|
|
1232
|
-
return res;
|
|
1233
|
-
} else {
|
|
1234
|
-
return value;
|
|
1235
|
-
}
|
|
1236
|
-
};
|
|
1237
1211
|
}
|
|
1238
1212
|
map(value) {
|
|
1239
1213
|
return this._map(value, void 0);
|
|
@@ -1244,36 +1218,37 @@ var DeepMapper = class {
|
|
|
1244
1218
|
}
|
|
1245
1219
|
return this._fn(value, this._recurse, key);
|
|
1246
1220
|
}
|
|
1221
|
+
_recurse = (value) => {
|
|
1222
|
+
if (this._cyclic.has(value)) {
|
|
1223
|
+
return this._cyclic.get(value);
|
|
1224
|
+
}
|
|
1225
|
+
if (Array.isArray(value)) {
|
|
1226
|
+
const res = new Array(value.length);
|
|
1227
|
+
this._cyclic.set(value, res);
|
|
1228
|
+
for (let i = 0; i < value.length; i++) {
|
|
1229
|
+
res[i] = this._map(value[i], i);
|
|
1230
|
+
}
|
|
1231
|
+
return res;
|
|
1232
|
+
} else if (value !== null && typeof value === "object") {
|
|
1233
|
+
const res = {};
|
|
1234
|
+
this._cyclic.set(value, res);
|
|
1235
|
+
for (const key in value) {
|
|
1236
|
+
res[key] = this._map(value[key], key);
|
|
1237
|
+
}
|
|
1238
|
+
return res;
|
|
1239
|
+
} else {
|
|
1240
|
+
return value;
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1247
1243
|
};
|
|
1248
1244
|
var deepMapValuesAsync = (value, fn) => {
|
|
1249
1245
|
return new DeepMapperAsync(fn).map(value);
|
|
1250
1246
|
};
|
|
1251
1247
|
var DeepMapperAsync = class {
|
|
1248
|
+
_fn;
|
|
1249
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1252
1250
|
constructor(_fn) {
|
|
1253
1251
|
this._fn = _fn;
|
|
1254
|
-
this._cyclic = /* @__PURE__ */ new Map();
|
|
1255
|
-
this._recurse = async (value) => {
|
|
1256
|
-
if (this._cyclic.has(value)) {
|
|
1257
|
-
return this._cyclic.get(value);
|
|
1258
|
-
}
|
|
1259
|
-
if (Array.isArray(value)) {
|
|
1260
|
-
const res = new Array(value.length);
|
|
1261
|
-
this._cyclic.set(value, res);
|
|
1262
|
-
for (let i = 0; i < value.length; i++) {
|
|
1263
|
-
res[i] = await this._map(value[i], i);
|
|
1264
|
-
}
|
|
1265
|
-
return res;
|
|
1266
|
-
} else if (value !== null && typeof value === "object") {
|
|
1267
|
-
const res = {};
|
|
1268
|
-
this._cyclic.set(value, res);
|
|
1269
|
-
for (const key in value) {
|
|
1270
|
-
res[key] = await this._map(value[key], key);
|
|
1271
|
-
}
|
|
1272
|
-
return res;
|
|
1273
|
-
} else {
|
|
1274
|
-
return value;
|
|
1275
|
-
}
|
|
1276
|
-
};
|
|
1277
1252
|
}
|
|
1278
1253
|
map(value) {
|
|
1279
1254
|
return this._map(value, void 0);
|
|
@@ -1284,6 +1259,28 @@ var DeepMapperAsync = class {
|
|
|
1284
1259
|
}
|
|
1285
1260
|
return this._fn(value, this._recurse, key);
|
|
1286
1261
|
}
|
|
1262
|
+
_recurse = async (value) => {
|
|
1263
|
+
if (this._cyclic.has(value)) {
|
|
1264
|
+
return this._cyclic.get(value);
|
|
1265
|
+
}
|
|
1266
|
+
if (Array.isArray(value)) {
|
|
1267
|
+
const res = new Array(value.length);
|
|
1268
|
+
this._cyclic.set(value, res);
|
|
1269
|
+
for (let i = 0; i < value.length; i++) {
|
|
1270
|
+
res[i] = await this._map(value[i], i);
|
|
1271
|
+
}
|
|
1272
|
+
return res;
|
|
1273
|
+
} else if (value !== null && typeof value === "object") {
|
|
1274
|
+
const res = {};
|
|
1275
|
+
this._cyclic.set(value, res);
|
|
1276
|
+
for (const key in value) {
|
|
1277
|
+
res[key] = await this._map(value[key], key);
|
|
1278
|
+
}
|
|
1279
|
+
return res;
|
|
1280
|
+
} else {
|
|
1281
|
+
return value;
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1287
1284
|
};
|
|
1288
1285
|
var visitValues = (object, visitor) => {
|
|
1289
1286
|
if (Array.isArray(object)) {
|
|
@@ -1372,7 +1369,18 @@ var omit = (obj, keys2) => {
|
|
|
1372
1369
|
|
|
1373
1370
|
// src/platform.ts
|
|
1374
1371
|
var isNode = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
1375
|
-
var
|
|
1372
|
+
var isBun = () => globalThis.Bun !== void 0;
|
|
1373
|
+
var isTauri = () => !!globalThis.__TAURI__;
|
|
1374
|
+
var isMobile = () => {
|
|
1375
|
+
let check = false;
|
|
1376
|
+
(function(a) {
|
|
1377
|
+
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) {
|
|
1378
|
+
check = true;
|
|
1379
|
+
}
|
|
1380
|
+
})(navigator.userAgent || navigator.vendor || window.opera);
|
|
1381
|
+
return check;
|
|
1382
|
+
};
|
|
1383
|
+
var isMobileOrTablet = () => {
|
|
1376
1384
|
let check = false;
|
|
1377
1385
|
((a) => {
|
|
1378
1386
|
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) {
|
|
@@ -1394,7 +1402,7 @@ var iosCheck = () => {
|
|
|
1394
1402
|
};
|
|
1395
1403
|
var safariCheck = () => typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1396
1404
|
var getHostPlatform = () => {
|
|
1397
|
-
if (!("navigator" in
|
|
1405
|
+
if (!("navigator" in globalThis)) {
|
|
1398
1406
|
return "unknown";
|
|
1399
1407
|
}
|
|
1400
1408
|
const platform = (navigator.userAgentData?.platform || navigator.platform)?.toLowerCase();
|
|
@@ -1589,7 +1597,7 @@ var safeAwaitAll = async (source, taskFactory, onError) => {
|
|
|
1589
1597
|
};
|
|
1590
1598
|
|
|
1591
1599
|
// src/safe-instanceof.ts
|
|
1592
|
-
var instanceTag = Symbol("instanceTag");
|
|
1600
|
+
var instanceTag = /* @__PURE__ */ Symbol("instanceTag");
|
|
1593
1601
|
var safeInstanceof = (tag) => (target) => {
|
|
1594
1602
|
target.prototype[instanceTag] = tag;
|
|
1595
1603
|
Object.defineProperty(target.prototype, Symbol.hasInstance, {
|
|
@@ -1601,37 +1609,137 @@ var safeInstanceof = (tag) => (target) => {
|
|
|
1601
1609
|
};
|
|
1602
1610
|
|
|
1603
1611
|
// src/safe-parse.ts
|
|
1604
|
-
|
|
1612
|
+
function safeParseInt(str, defaultValue) {
|
|
1613
|
+
try {
|
|
1614
|
+
const value = parseInt(str ?? "");
|
|
1615
|
+
return isNaN(value) ? defaultValue : value;
|
|
1616
|
+
} catch {
|
|
1617
|
+
return defaultValue;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
function safeParseFloat(str, defaultValue) {
|
|
1605
1621
|
try {
|
|
1606
|
-
const
|
|
1607
|
-
return isNaN(
|
|
1608
|
-
} catch
|
|
1622
|
+
const value = parseFloat(str ?? "");
|
|
1623
|
+
return isNaN(value) ? defaultValue : value;
|
|
1624
|
+
} catch {
|
|
1609
1625
|
return defaultValue;
|
|
1610
1626
|
}
|
|
1627
|
+
}
|
|
1628
|
+
var safeParseJson = (str, defaultValue) => {
|
|
1629
|
+
if (str && str.length > 0) {
|
|
1630
|
+
try {
|
|
1631
|
+
return JSON.parse(str);
|
|
1632
|
+
} catch {
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
return defaultValue;
|
|
1611
1636
|
};
|
|
1612
|
-
var
|
|
1637
|
+
var safeUrl = (str) => {
|
|
1613
1638
|
try {
|
|
1614
|
-
return
|
|
1639
|
+
return new URL(str ?? "");
|
|
1615
1640
|
} catch {
|
|
1616
|
-
return
|
|
1641
|
+
return void 0;
|
|
1617
1642
|
}
|
|
1618
1643
|
};
|
|
1619
|
-
|
|
1620
|
-
|
|
1644
|
+
|
|
1645
|
+
// src/safe-stringify.ts
|
|
1646
|
+
var SKIP = Object.freeze({});
|
|
1647
|
+
function safeStringify(obj, filter = defaultFilter, indent = 2) {
|
|
1648
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
1649
|
+
function replacer(key, value) {
|
|
1621
1650
|
try {
|
|
1622
|
-
|
|
1623
|
-
|
|
1651
|
+
let path = key;
|
|
1652
|
+
if (!key) {
|
|
1653
|
+
path = "$";
|
|
1654
|
+
if (value != null && typeof value === "object") {
|
|
1655
|
+
seen.set(value, path);
|
|
1656
|
+
}
|
|
1657
|
+
return value;
|
|
1658
|
+
} else if (this) {
|
|
1659
|
+
const parentPath = seen.get(this);
|
|
1660
|
+
path = parentPath ? `${parentPath}.${key}` : key;
|
|
1661
|
+
}
|
|
1662
|
+
if (value == null) {
|
|
1663
|
+
return value;
|
|
1664
|
+
}
|
|
1665
|
+
if (typeof value === "function") {
|
|
1666
|
+
return void 0;
|
|
1667
|
+
}
|
|
1668
|
+
if (typeof value === "object" && Object.getPrototypeOf(value) !== Object.prototype && !Array.isArray(value)) {
|
|
1669
|
+
return void 0;
|
|
1670
|
+
}
|
|
1671
|
+
if (typeof value === "object" && value !== null) {
|
|
1672
|
+
const exists = seen.get(value);
|
|
1673
|
+
if (exists) {
|
|
1674
|
+
return `[${path} => ${exists}]`;
|
|
1675
|
+
}
|
|
1676
|
+
seen.set(value, path);
|
|
1677
|
+
}
|
|
1678
|
+
if (filter) {
|
|
1679
|
+
const filteredValue = filter?.(key, value);
|
|
1680
|
+
if (filteredValue !== void 0) {
|
|
1681
|
+
return filteredValue === SKIP ? void 0 : filteredValue;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
return value;
|
|
1685
|
+
} catch (error) {
|
|
1686
|
+
return `ERROR: ${error.message}`;
|
|
1624
1687
|
}
|
|
1625
1688
|
}
|
|
1626
|
-
|
|
1689
|
+
try {
|
|
1690
|
+
return JSON.stringify(obj, replacer, indent);
|
|
1691
|
+
} catch (error) {
|
|
1692
|
+
return `ERROR: ${error.message}`;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen } = {}) => {
|
|
1696
|
+
let currentDepth = 0;
|
|
1697
|
+
const depthMap = /* @__PURE__ */ new WeakMap();
|
|
1698
|
+
return function(key, value) {
|
|
1699
|
+
if (key === "") {
|
|
1700
|
+
currentDepth = 0;
|
|
1701
|
+
} else if (this && typeof this === "object") {
|
|
1702
|
+
const parentDepth = depthMap.get(this) ?? 0;
|
|
1703
|
+
currentDepth = parentDepth + 1;
|
|
1704
|
+
}
|
|
1705
|
+
if (typeof value === "function") {
|
|
1706
|
+
return SKIP;
|
|
1707
|
+
}
|
|
1708
|
+
if (maxArrayLen != null && Array.isArray(value) && value.length > maxArrayLen) {
|
|
1709
|
+
return `[length: ${value.length}]`;
|
|
1710
|
+
}
|
|
1711
|
+
if (value && typeof value === "object") {
|
|
1712
|
+
depthMap.set(value, currentDepth);
|
|
1713
|
+
if (maxDepth != null && currentDepth >= maxDepth) {
|
|
1714
|
+
return Array.isArray(value) ? `[{ length: ${value.length} }]` : `{ keys: ${Object.keys(value).length} }`;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
if (omit2?.includes(key)) {
|
|
1718
|
+
return SKIP;
|
|
1719
|
+
}
|
|
1720
|
+
if (parse?.includes(key) && typeof value === "string") {
|
|
1721
|
+
try {
|
|
1722
|
+
return JSON.parse(value);
|
|
1723
|
+
} catch {
|
|
1724
|
+
return value;
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
if (maxStringLen != null && typeof value === "string" && value.length > maxStringLen) {
|
|
1728
|
+
return value.slice(0, maxStringLen) + "...";
|
|
1729
|
+
}
|
|
1730
|
+
return value;
|
|
1731
|
+
};
|
|
1627
1732
|
};
|
|
1733
|
+
var defaultFilter = createReplacer();
|
|
1628
1734
|
|
|
1629
1735
|
// src/sliding-window-summary.ts
|
|
1630
1736
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1631
1737
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
|
|
1632
1738
|
var SlidingWindowSummary = class {
|
|
1739
|
+
_buffer;
|
|
1740
|
+
_sum = 0;
|
|
1741
|
+
_precision;
|
|
1633
1742
|
constructor(options) {
|
|
1634
|
-
this._sum = 0;
|
|
1635
1743
|
this._buffer = new CircularBuffer(options.dataPoints);
|
|
1636
1744
|
if (options.precision != null) {
|
|
1637
1745
|
invariant5(options.precision >= 0, void 0, {
|
|
@@ -1711,12 +1819,24 @@ var capitalize = (str) => {
|
|
|
1711
1819
|
}
|
|
1712
1820
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1713
1821
|
};
|
|
1714
|
-
|
|
1715
|
-
const
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1822
|
+
function trim(strings, ...values) {
|
|
1823
|
+
const raw = strings.reduce((out, str, i) => {
|
|
1824
|
+
out += str;
|
|
1825
|
+
if (i < values.length) {
|
|
1826
|
+
const match = str.match(/(^|\n)([ \t]*)$/);
|
|
1827
|
+
const baseIndent = match ? match[2] : "";
|
|
1828
|
+
const val = String(values[i]).replace(/\r?\n/g, "\n" + baseIndent);
|
|
1829
|
+
out += val;
|
|
1830
|
+
}
|
|
1831
|
+
return out;
|
|
1832
|
+
}, "");
|
|
1833
|
+
const lines = raw.split("\n");
|
|
1834
|
+
while (lines.length && !lines[0].trim()) lines.shift();
|
|
1835
|
+
while (lines.length && !lines[lines.length - 1].trim()) lines.pop();
|
|
1836
|
+
const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
|
|
1837
|
+
return lines.map((l) => l.slice(minIndent)).join("\n");
|
|
1838
|
+
}
|
|
1839
|
+
var kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
|
|
1720
1840
|
|
|
1721
1841
|
// src/sum.ts
|
|
1722
1842
|
var sum = (values) => values.reduce((a, b) => a + b, 0);
|
|
@@ -1730,18 +1850,6 @@ var throwUnhandledError = (error) => {
|
|
|
1730
1850
|
|
|
1731
1851
|
// src/to-fallback.ts
|
|
1732
1852
|
var idEmoji = [
|
|
1733
|
-
// When changing this set, please check the result in a console or e.g. RunKit (https://runkit.com/thure/642214441dd6ae000855a8de)
|
|
1734
|
-
// Emoji sometimes use a combination of code points, and some code points aren't visible on their own, so by adding or deleting you may unintentionally create non-visible items.
|
|
1735
|
-
// This set was chosen from the characters in Unicode Emoji v15.0 based on the following criteria:
|
|
1736
|
-
// – not people or isolated anthropomorphic faces
|
|
1737
|
-
// – not flags
|
|
1738
|
-
// – more concrete than abstract
|
|
1739
|
-
// – less culturally specific
|
|
1740
|
-
// – less easily confused with another emoji in the set
|
|
1741
|
-
// – requires less special knowledge to identify
|
|
1742
|
-
// – less likely to evoke negative feelings (no meat, no drugs, no weapons, etc)
|
|
1743
|
-
// – less common as a signifier in UX
|
|
1744
|
-
// NOTE that this is intentionally an array of strings because of the way emoji graphemes work.
|
|
1745
1853
|
"\u{1F47B}",
|
|
1746
1854
|
"\u{1F479}",
|
|
1747
1855
|
"\u{1F47D}",
|
|
@@ -1877,17 +1985,18 @@ var idEmoji = [
|
|
|
1877
1985
|
];
|
|
1878
1986
|
var idHue = [
|
|
1879
1987
|
"red",
|
|
1880
|
-
|
|
1988
|
+
"orange",
|
|
1881
1989
|
"amber",
|
|
1882
|
-
|
|
1990
|
+
"yellow",
|
|
1883
1991
|
"lime",
|
|
1884
1992
|
"green",
|
|
1885
1993
|
"emerald",
|
|
1886
1994
|
"teal",
|
|
1887
1995
|
"cyan",
|
|
1888
|
-
//
|
|
1889
|
-
// '
|
|
1890
|
-
// '
|
|
1996
|
+
// Omit colors similar to primary accent.
|
|
1997
|
+
// 'sky' as const,
|
|
1998
|
+
// 'blue' as const,
|
|
1999
|
+
// 'indigo' as const,
|
|
1891
2000
|
"violet",
|
|
1892
2001
|
"purple",
|
|
1893
2002
|
"fuchsia",
|
|
@@ -1915,10 +2024,8 @@ var toFallback = (hash) => {
|
|
|
1915
2024
|
|
|
1916
2025
|
// src/tracer.ts
|
|
1917
2026
|
var Tracer = class {
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
this._recording = false;
|
|
1921
|
-
}
|
|
2027
|
+
_events = /* @__PURE__ */ new Map();
|
|
2028
|
+
_recording = false;
|
|
1922
2029
|
// TODO(burdon): Start/stop methods for recording data? By id?
|
|
1923
2030
|
// Alternatively, enable subscriptions to track/compute series.
|
|
1924
2031
|
// TODO(burdon): Hierarchical traces?
|
|
@@ -2019,7 +2126,7 @@ var stringifyTree = (node, ancestors = [], rows = []) => {
|
|
|
2019
2126
|
};
|
|
2020
2127
|
|
|
2021
2128
|
// src/types.ts
|
|
2022
|
-
var
|
|
2129
|
+
var isTruthy = (value) => !!value;
|
|
2023
2130
|
var isNonNullable = (value) => value != null;
|
|
2024
2131
|
var doAsync = async (fn) => fn();
|
|
2025
2132
|
var getProviderValue = (provider, arg) => {
|
|
@@ -2049,6 +2156,113 @@ var arrayMove = (array, from, to) => {
|
|
|
2049
2156
|
array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
|
|
2050
2157
|
return array;
|
|
2051
2158
|
};
|
|
2159
|
+
function arraySwap(array, from, to) {
|
|
2160
|
+
const current = array[from];
|
|
2161
|
+
array[from] = array[to];
|
|
2162
|
+
array[to] = current;
|
|
2163
|
+
return array;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
// src/unit.ts
|
|
2167
|
+
var createFormat = (unit) => {
|
|
2168
|
+
return (n, precision = unit.precision ?? 0) => {
|
|
2169
|
+
const value = n / unit.quotient;
|
|
2170
|
+
return {
|
|
2171
|
+
unit,
|
|
2172
|
+
value,
|
|
2173
|
+
formattedValue: value.toFixed(precision),
|
|
2174
|
+
toString: () => `${value.toFixed(precision)}${unit.symbol}`
|
|
2175
|
+
};
|
|
2176
|
+
};
|
|
2177
|
+
};
|
|
2178
|
+
var MS_SECONDS = 1e3;
|
|
2179
|
+
var MS_MINUTES = 60 * MS_SECONDS;
|
|
2180
|
+
var MS_HOURS = 60 * MS_MINUTES;
|
|
2181
|
+
var Unit = {
|
|
2182
|
+
// General.
|
|
2183
|
+
Percent: createFormat({
|
|
2184
|
+
symbol: "%",
|
|
2185
|
+
quotient: 1 / 100,
|
|
2186
|
+
precision: 2
|
|
2187
|
+
}),
|
|
2188
|
+
Thousand: createFormat({
|
|
2189
|
+
symbol: "k",
|
|
2190
|
+
quotient: 1e3,
|
|
2191
|
+
precision: 2
|
|
2192
|
+
}),
|
|
2193
|
+
// Bytes (note KB vs KiB).
|
|
2194
|
+
Gigabyte: createFormat({
|
|
2195
|
+
symbol: "GB",
|
|
2196
|
+
quotient: 1e3 * 1e3 * 1e3,
|
|
2197
|
+
precision: 2
|
|
2198
|
+
}),
|
|
2199
|
+
Megabyte: createFormat({
|
|
2200
|
+
symbol: "MB",
|
|
2201
|
+
quotient: 1e3 * 1e3,
|
|
2202
|
+
precision: 2
|
|
2203
|
+
}),
|
|
2204
|
+
Kilobyte: createFormat({
|
|
2205
|
+
symbol: "KB",
|
|
2206
|
+
quotient: 1e3,
|
|
2207
|
+
precision: 2
|
|
2208
|
+
}),
|
|
2209
|
+
Byte: createFormat({
|
|
2210
|
+
symbol: "B",
|
|
2211
|
+
quotient: 1
|
|
2212
|
+
}),
|
|
2213
|
+
// Time.
|
|
2214
|
+
Hour: createFormat({
|
|
2215
|
+
symbol: "h",
|
|
2216
|
+
quotient: MS_HOURS
|
|
2217
|
+
}),
|
|
2218
|
+
Minute: createFormat({
|
|
2219
|
+
symbol: "m",
|
|
2220
|
+
quotient: MS_MINUTES
|
|
2221
|
+
}),
|
|
2222
|
+
Second: createFormat({
|
|
2223
|
+
symbol: "s",
|
|
2224
|
+
quotient: MS_SECONDS,
|
|
2225
|
+
precision: 1
|
|
2226
|
+
}),
|
|
2227
|
+
Millisecond: createFormat({
|
|
2228
|
+
symbol: "ms",
|
|
2229
|
+
quotient: 1
|
|
2230
|
+
}),
|
|
2231
|
+
Duration: (n) => {
|
|
2232
|
+
const hours = Math.floor(n / MS_HOURS);
|
|
2233
|
+
const minutes = Math.floor(n % MS_HOURS / MS_MINUTES);
|
|
2234
|
+
if (hours) {
|
|
2235
|
+
const formattedValue = minutes ? `${hours}h ${minutes}m` : `${hours}h`;
|
|
2236
|
+
return {
|
|
2237
|
+
unit: {
|
|
2238
|
+
symbol: "h",
|
|
2239
|
+
quotient: MS_HOURS
|
|
2240
|
+
},
|
|
2241
|
+
value: hours,
|
|
2242
|
+
formattedValue,
|
|
2243
|
+
toString: () => formattedValue
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
if (minutes) {
|
|
2247
|
+
const seconds2 = (n - MS_MINUTES * minutes) / MS_SECONDS;
|
|
2248
|
+
const formattedValue = seconds2 ? `${minutes}m ${seconds2}s` : `${minutes}m`;
|
|
2249
|
+
return {
|
|
2250
|
+
unit: {
|
|
2251
|
+
symbol: "m",
|
|
2252
|
+
quotient: MS_MINUTES
|
|
2253
|
+
},
|
|
2254
|
+
value: minutes,
|
|
2255
|
+
formattedValue,
|
|
2256
|
+
toString: () => formattedValue
|
|
2257
|
+
};
|
|
2258
|
+
}
|
|
2259
|
+
const seconds = n >= MS_SECONDS;
|
|
2260
|
+
if (seconds) {
|
|
2261
|
+
return Unit.Second(n);
|
|
2262
|
+
}
|
|
2263
|
+
return Unit.Millisecond(n);
|
|
2264
|
+
}
|
|
2265
|
+
};
|
|
2052
2266
|
|
|
2053
2267
|
// src/url.ts
|
|
2054
2268
|
var createUrl = (url, search) => {
|
|
@@ -2061,11 +2275,11 @@ var createUrl = (url, search) => {
|
|
|
2061
2275
|
|
|
2062
2276
|
// src/weak.ts
|
|
2063
2277
|
var WeakDictionary = class {
|
|
2278
|
+
_internal = /* @__PURE__ */ new Map();
|
|
2279
|
+
_finalization = new FinalizationRegistry((cleanUpCallback) => {
|
|
2280
|
+
cleanUpCallback();
|
|
2281
|
+
});
|
|
2064
2282
|
constructor(entries2) {
|
|
2065
|
-
this._internal = /* @__PURE__ */ new Map();
|
|
2066
|
-
this._finalization = new FinalizationRegistry((cleanUpCallback) => {
|
|
2067
|
-
cleanUpCallback();
|
|
2068
|
-
});
|
|
2069
2283
|
this._internal = new Map(entries2?.map(([key, value]) => [
|
|
2070
2284
|
key,
|
|
2071
2285
|
new WeakRef(value)
|
|
@@ -2153,6 +2367,58 @@ var WeakDictionary = class {
|
|
|
2153
2367
|
this._finalization.unregister(value);
|
|
2154
2368
|
}
|
|
2155
2369
|
};
|
|
2370
|
+
|
|
2371
|
+
// src/error-format.ts
|
|
2372
|
+
var formatErrorWithCauses = (error) => {
|
|
2373
|
+
const lines = [];
|
|
2374
|
+
let current = error;
|
|
2375
|
+
let level = 0;
|
|
2376
|
+
while (current) {
|
|
2377
|
+
const prefix = level === 0 ? "" : `Caused by: `;
|
|
2378
|
+
lines.push(prefix + (current.stack ?? String(current)));
|
|
2379
|
+
if (!(current.cause instanceof Error)) break;
|
|
2380
|
+
current = current.cause;
|
|
2381
|
+
level += 1;
|
|
2382
|
+
}
|
|
2383
|
+
return lines.join("\n\n");
|
|
2384
|
+
};
|
|
2385
|
+
|
|
2386
|
+
// src/retry.ts
|
|
2387
|
+
var DEFAULT_RETRY_OPTIONS = {
|
|
2388
|
+
count: 3,
|
|
2389
|
+
delayMs: 100,
|
|
2390
|
+
exponent: 2,
|
|
2391
|
+
retryOnError: async () => true,
|
|
2392
|
+
retryOnValue: async () => false
|
|
2393
|
+
};
|
|
2394
|
+
var retry = async (options, cb) => {
|
|
2395
|
+
const fullOptions = {
|
|
2396
|
+
...DEFAULT_RETRY_OPTIONS,
|
|
2397
|
+
...options
|
|
2398
|
+
};
|
|
2399
|
+
let numRetries = 0, currentDelay = fullOptions.delayMs;
|
|
2400
|
+
while (true) {
|
|
2401
|
+
let result;
|
|
2402
|
+
try {
|
|
2403
|
+
result = await cb();
|
|
2404
|
+
} catch (err) {
|
|
2405
|
+
if (numRetries > fullOptions.count || !await fullOptions.retryOnError(err)) {
|
|
2406
|
+
throw err;
|
|
2407
|
+
}
|
|
2408
|
+
await new Promise((resolve) => setTimeout(resolve, currentDelay));
|
|
2409
|
+
currentDelay *= fullOptions.exponent;
|
|
2410
|
+
numRetries++;
|
|
2411
|
+
continue;
|
|
2412
|
+
}
|
|
2413
|
+
if (!await fullOptions.retryOnValue(result)) {
|
|
2414
|
+
return result;
|
|
2415
|
+
}
|
|
2416
|
+
await new Promise((resolve) => setTimeout(resolve, currentDelay));
|
|
2417
|
+
currentDelay *= fullOptions.exponent;
|
|
2418
|
+
numRetries++;
|
|
2419
|
+
continue;
|
|
2420
|
+
}
|
|
2421
|
+
};
|
|
2156
2422
|
export {
|
|
2157
2423
|
BitField,
|
|
2158
2424
|
Callback,
|
|
@@ -2162,11 +2428,14 @@ export {
|
|
|
2162
2428
|
ComplexSet,
|
|
2163
2429
|
HumanHasher,
|
|
2164
2430
|
MapEntry,
|
|
2431
|
+
SKIP,
|
|
2165
2432
|
SlidingWindowSummary,
|
|
2166
2433
|
Tracer,
|
|
2434
|
+
Unit,
|
|
2167
2435
|
WeakDictionary,
|
|
2168
2436
|
accessBy,
|
|
2169
2437
|
arrayMove,
|
|
2438
|
+
arraySwap,
|
|
2170
2439
|
arrayToBuffer,
|
|
2171
2440
|
arrayToHex,
|
|
2172
2441
|
arrayToString,
|
|
@@ -2178,18 +2447,22 @@ export {
|
|
|
2178
2447
|
chunkArray,
|
|
2179
2448
|
clamp,
|
|
2180
2449
|
clearUndefined,
|
|
2450
|
+
coerceArray,
|
|
2181
2451
|
compareMulti,
|
|
2182
2452
|
compareObject,
|
|
2183
2453
|
compareScalar,
|
|
2184
2454
|
compareString,
|
|
2185
2455
|
createBinder,
|
|
2186
2456
|
createBucketReducer,
|
|
2457
|
+
createFilename,
|
|
2187
2458
|
createGroupReducer,
|
|
2459
|
+
createReplacer,
|
|
2188
2460
|
createSetDispatch,
|
|
2189
2461
|
createUrl,
|
|
2190
2462
|
decamelize,
|
|
2191
2463
|
deepMapValues,
|
|
2192
2464
|
deepMapValuesAsync,
|
|
2465
|
+
defaultFilter,
|
|
2193
2466
|
defaultMap,
|
|
2194
2467
|
defer,
|
|
2195
2468
|
deferAsync,
|
|
@@ -2201,12 +2474,11 @@ export {
|
|
|
2201
2474
|
entry,
|
|
2202
2475
|
exponentialBackoffInterval,
|
|
2203
2476
|
forEachAsync,
|
|
2204
|
-
|
|
2477
|
+
formatErrorWithCauses,
|
|
2205
2478
|
getAsyncProviderValue,
|
|
2206
2479
|
getDate,
|
|
2207
2480
|
getDebugName,
|
|
2208
2481
|
getDeep,
|
|
2209
|
-
getFirstTwoRenderableChars,
|
|
2210
2482
|
getHostPlatform,
|
|
2211
2483
|
getPrototypeSpecificInstanceId,
|
|
2212
2484
|
getProviderValue,
|
|
@@ -2222,14 +2494,19 @@ export {
|
|
|
2222
2494
|
intersectBy,
|
|
2223
2495
|
intersection,
|
|
2224
2496
|
iosCheck,
|
|
2497
|
+
isBun,
|
|
2498
|
+
isMobile,
|
|
2499
|
+
isMobileOrTablet,
|
|
2225
2500
|
isNode,
|
|
2226
2501
|
isNonNullable,
|
|
2227
|
-
|
|
2502
|
+
isTauri,
|
|
2503
|
+
isTruthy,
|
|
2228
2504
|
joinTables,
|
|
2229
2505
|
jsonKeyReplacer,
|
|
2230
2506
|
jsonReplacer,
|
|
2231
2507
|
jsonify,
|
|
2232
2508
|
jsonlogify,
|
|
2509
|
+
kebabize,
|
|
2233
2510
|
keyToEmoji,
|
|
2234
2511
|
keyToFallback,
|
|
2235
2512
|
keyToHue,
|
|
@@ -2238,7 +2515,6 @@ export {
|
|
|
2238
2515
|
makeSet,
|
|
2239
2516
|
mapValues,
|
|
2240
2517
|
median,
|
|
2241
|
-
mobileAndTabletCheck,
|
|
2242
2518
|
numericalValues,
|
|
2243
2519
|
omit,
|
|
2244
2520
|
orderKeys,
|
|
@@ -2254,13 +2530,15 @@ export {
|
|
|
2254
2530
|
removeBy,
|
|
2255
2531
|
removeProperties,
|
|
2256
2532
|
removeUndefinedProperties,
|
|
2533
|
+
retry,
|
|
2257
2534
|
safariCheck,
|
|
2258
2535
|
safeAwaitAll,
|
|
2259
2536
|
safeInstanceof,
|
|
2260
2537
|
safeParseFloat,
|
|
2261
2538
|
safeParseInt,
|
|
2262
2539
|
safeParseJson,
|
|
2263
|
-
|
|
2540
|
+
safeStringify,
|
|
2541
|
+
safeUrl,
|
|
2264
2542
|
setDeep,
|
|
2265
2543
|
sortKeys,
|
|
2266
2544
|
stringToArray,
|