@dxos/util 0.8.4-main.b97322e → 0.8.4-main.bcb3aa67d6
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 +425 -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 +425 -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/composite-key.d.ts +10 -0
- package/dist/types/src/composite-key.d.ts.map +1 -0
- package/dist/types/src/composite-key.test.d.ts +2 -0
- package/dist/types/src/composite-key.test.d.ts.map +1 -0
- 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 +6 -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/composite-key.test.ts +31 -0
- package/src/composite-key.ts +16 -0
- 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 +6 -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);
|
|
@@ -555,15 +571,18 @@ var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
|
|
|
555
571
|
}
|
|
556
572
|
};
|
|
557
573
|
|
|
574
|
+
// src/composite-key.ts
|
|
575
|
+
var SEPARATOR = ":";
|
|
576
|
+
var compositeKey = (...parts) => parts.join(SEPARATOR);
|
|
577
|
+
var splitCompositeKey = (key) => key.split(SEPARATOR);
|
|
578
|
+
|
|
558
579
|
// src/deep.ts
|
|
559
|
-
import get from "lodash.get";
|
|
560
|
-
import set from "lodash.set";
|
|
561
580
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
562
581
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/common/util/src/deep.ts";
|
|
563
582
|
var setDeep = (obj, path, value) => {
|
|
564
583
|
invariant4(path.length > 0, void 0, {
|
|
565
584
|
F: __dxlog_file4,
|
|
566
|
-
L:
|
|
585
|
+
L: 12,
|
|
567
586
|
S: void 0,
|
|
568
587
|
A: [
|
|
569
588
|
"path.length > 0",
|
|
@@ -592,13 +611,11 @@ var getDeep = (obj, path) => {
|
|
|
592
611
|
// src/defer-function.ts
|
|
593
612
|
var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
|
|
594
613
|
|
|
595
|
-
// src/explicit-resource-management-polyfill.ts
|
|
596
|
-
Symbol.dispose ??= Symbol("Symbol.dispose");
|
|
597
|
-
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
598
|
-
|
|
599
614
|
// src/defer.ts
|
|
615
|
+
import "@hazae41/symbol-dispose-polyfill";
|
|
600
616
|
var defer = (fn) => new DeferGuard(fn);
|
|
601
617
|
var DeferGuard = class {
|
|
618
|
+
_fn;
|
|
602
619
|
/**
|
|
603
620
|
* @internal
|
|
604
621
|
*/
|
|
@@ -614,6 +631,7 @@ var DeferGuard = class {
|
|
|
614
631
|
};
|
|
615
632
|
var deferAsync = (fn) => new DeferAsyncGuard(fn);
|
|
616
633
|
var DeferAsyncGuard = class {
|
|
634
|
+
_fn;
|
|
617
635
|
/**
|
|
618
636
|
* @internal
|
|
619
637
|
*/
|
|
@@ -628,6 +646,8 @@ var DeferAsyncGuard = class {
|
|
|
628
646
|
// src/entry.ts
|
|
629
647
|
var entry = (map, key) => new MapEntry(map, key);
|
|
630
648
|
var MapEntry = class {
|
|
649
|
+
_map;
|
|
650
|
+
_key;
|
|
631
651
|
/**
|
|
632
652
|
* @internal
|
|
633
653
|
*/
|
|
@@ -653,32 +673,11 @@ var MapEntry = class {
|
|
|
653
673
|
}
|
|
654
674
|
};
|
|
655
675
|
|
|
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
|
-
};
|
|
676
|
+
// src/filename.ts
|
|
677
|
+
var createFilename = ({ parts = [], ext, date = /* @__PURE__ */ new Date() }) => [
|
|
678
|
+
date.toISOString().replace(/[:.]/g, "-"),
|
|
679
|
+
...parts
|
|
680
|
+
].join("_") + (ext ? `.${ext}` : "");
|
|
682
681
|
|
|
683
682
|
// src/for-each-async.ts
|
|
684
683
|
var forEachAsync = (items, fn) => Promise.all(items.map(fn));
|
|
@@ -944,6 +943,7 @@ var DEFAULT_WORDLIST = [
|
|
|
944
943
|
"zulu"
|
|
945
944
|
];
|
|
946
945
|
var HumanHasher = class {
|
|
946
|
+
wordlist;
|
|
947
947
|
/**
|
|
948
948
|
* Transforms hex digests to human-readable strings.
|
|
949
949
|
*
|
|
@@ -1025,7 +1025,7 @@ var defaultMap = (map, key, def) => {
|
|
|
1025
1025
|
};
|
|
1026
1026
|
|
|
1027
1027
|
// src/instance-id.ts
|
|
1028
|
-
var symbol = Symbol.for("dxos.instance-contexts");
|
|
1028
|
+
var symbol = /* @__PURE__ */ Symbol.for("dxos.instance-contexts");
|
|
1029
1029
|
var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
|
|
1030
1030
|
var getPrototypeSpecificInstanceId = (instance) => {
|
|
1031
1031
|
const prototype = Object.getPrototypeOf(instance);
|
|
@@ -1209,31 +1209,10 @@ var deepMapValues = (value, fn) => {
|
|
|
1209
1209
|
return new DeepMapper(fn).map(value);
|
|
1210
1210
|
};
|
|
1211
1211
|
var DeepMapper = class {
|
|
1212
|
+
_fn;
|
|
1213
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1212
1214
|
constructor(_fn) {
|
|
1213
1215
|
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
1216
|
}
|
|
1238
1217
|
map(value) {
|
|
1239
1218
|
return this._map(value, void 0);
|
|
@@ -1244,36 +1223,37 @@ var DeepMapper = class {
|
|
|
1244
1223
|
}
|
|
1245
1224
|
return this._fn(value, this._recurse, key);
|
|
1246
1225
|
}
|
|
1226
|
+
_recurse = (value) => {
|
|
1227
|
+
if (this._cyclic.has(value)) {
|
|
1228
|
+
return this._cyclic.get(value);
|
|
1229
|
+
}
|
|
1230
|
+
if (Array.isArray(value)) {
|
|
1231
|
+
const res = new Array(value.length);
|
|
1232
|
+
this._cyclic.set(value, res);
|
|
1233
|
+
for (let i = 0; i < value.length; i++) {
|
|
1234
|
+
res[i] = this._map(value[i], i);
|
|
1235
|
+
}
|
|
1236
|
+
return res;
|
|
1237
|
+
} else if (value !== null && typeof value === "object") {
|
|
1238
|
+
const res = {};
|
|
1239
|
+
this._cyclic.set(value, res);
|
|
1240
|
+
for (const key in value) {
|
|
1241
|
+
res[key] = this._map(value[key], key);
|
|
1242
|
+
}
|
|
1243
|
+
return res;
|
|
1244
|
+
} else {
|
|
1245
|
+
return value;
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1247
1248
|
};
|
|
1248
1249
|
var deepMapValuesAsync = (value, fn) => {
|
|
1249
1250
|
return new DeepMapperAsync(fn).map(value);
|
|
1250
1251
|
};
|
|
1251
1252
|
var DeepMapperAsync = class {
|
|
1253
|
+
_fn;
|
|
1254
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1252
1255
|
constructor(_fn) {
|
|
1253
1256
|
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
1257
|
}
|
|
1278
1258
|
map(value) {
|
|
1279
1259
|
return this._map(value, void 0);
|
|
@@ -1284,6 +1264,28 @@ var DeepMapperAsync = class {
|
|
|
1284
1264
|
}
|
|
1285
1265
|
return this._fn(value, this._recurse, key);
|
|
1286
1266
|
}
|
|
1267
|
+
_recurse = async (value) => {
|
|
1268
|
+
if (this._cyclic.has(value)) {
|
|
1269
|
+
return this._cyclic.get(value);
|
|
1270
|
+
}
|
|
1271
|
+
if (Array.isArray(value)) {
|
|
1272
|
+
const res = new Array(value.length);
|
|
1273
|
+
this._cyclic.set(value, res);
|
|
1274
|
+
for (let i = 0; i < value.length; i++) {
|
|
1275
|
+
res[i] = await this._map(value[i], i);
|
|
1276
|
+
}
|
|
1277
|
+
return res;
|
|
1278
|
+
} else if (value !== null && typeof value === "object") {
|
|
1279
|
+
const res = {};
|
|
1280
|
+
this._cyclic.set(value, res);
|
|
1281
|
+
for (const key in value) {
|
|
1282
|
+
res[key] = await this._map(value[key], key);
|
|
1283
|
+
}
|
|
1284
|
+
return res;
|
|
1285
|
+
} else {
|
|
1286
|
+
return value;
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1287
1289
|
};
|
|
1288
1290
|
var visitValues = (object, visitor) => {
|
|
1289
1291
|
if (Array.isArray(object)) {
|
|
@@ -1372,7 +1374,18 @@ var omit = (obj, keys2) => {
|
|
|
1372
1374
|
|
|
1373
1375
|
// src/platform.ts
|
|
1374
1376
|
var isNode = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
1375
|
-
var
|
|
1377
|
+
var isBun = () => globalThis.Bun !== void 0;
|
|
1378
|
+
var isTauri = () => !!globalThis.__TAURI__;
|
|
1379
|
+
var isMobile = () => {
|
|
1380
|
+
let check = false;
|
|
1381
|
+
(function(a) {
|
|
1382
|
+
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))) {
|
|
1383
|
+
check = true;
|
|
1384
|
+
}
|
|
1385
|
+
})(navigator.userAgent || navigator.vendor || window.opera);
|
|
1386
|
+
return check;
|
|
1387
|
+
};
|
|
1388
|
+
var isMobileOrTablet = () => {
|
|
1376
1389
|
let check = false;
|
|
1377
1390
|
((a) => {
|
|
1378
1391
|
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 +1407,7 @@ var iosCheck = () => {
|
|
|
1394
1407
|
};
|
|
1395
1408
|
var safariCheck = () => typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1396
1409
|
var getHostPlatform = () => {
|
|
1397
|
-
if (!("navigator" in
|
|
1410
|
+
if (!("navigator" in globalThis)) {
|
|
1398
1411
|
return "unknown";
|
|
1399
1412
|
}
|
|
1400
1413
|
const platform = (navigator.userAgentData?.platform || navigator.platform)?.toLowerCase();
|
|
@@ -1589,7 +1602,7 @@ var safeAwaitAll = async (source, taskFactory, onError) => {
|
|
|
1589
1602
|
};
|
|
1590
1603
|
|
|
1591
1604
|
// src/safe-instanceof.ts
|
|
1592
|
-
var instanceTag = Symbol("instanceTag");
|
|
1605
|
+
var instanceTag = /* @__PURE__ */ Symbol("instanceTag");
|
|
1593
1606
|
var safeInstanceof = (tag) => (target) => {
|
|
1594
1607
|
target.prototype[instanceTag] = tag;
|
|
1595
1608
|
Object.defineProperty(target.prototype, Symbol.hasInstance, {
|
|
@@ -1601,37 +1614,137 @@ var safeInstanceof = (tag) => (target) => {
|
|
|
1601
1614
|
};
|
|
1602
1615
|
|
|
1603
1616
|
// src/safe-parse.ts
|
|
1604
|
-
|
|
1617
|
+
function safeParseInt(str, defaultValue) {
|
|
1605
1618
|
try {
|
|
1606
|
-
const
|
|
1607
|
-
return isNaN(
|
|
1608
|
-
} catch
|
|
1619
|
+
const value = parseInt(str ?? "");
|
|
1620
|
+
return isNaN(value) ? defaultValue : value;
|
|
1621
|
+
} catch {
|
|
1609
1622
|
return defaultValue;
|
|
1610
1623
|
}
|
|
1624
|
+
}
|
|
1625
|
+
function safeParseFloat(str, defaultValue) {
|
|
1626
|
+
try {
|
|
1627
|
+
const value = parseFloat(str ?? "");
|
|
1628
|
+
return isNaN(value) ? defaultValue : value;
|
|
1629
|
+
} catch {
|
|
1630
|
+
return defaultValue;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
var safeParseJson = (str, defaultValue) => {
|
|
1634
|
+
if (str && str.length > 0) {
|
|
1635
|
+
try {
|
|
1636
|
+
return JSON.parse(str);
|
|
1637
|
+
} catch {
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
return defaultValue;
|
|
1611
1641
|
};
|
|
1612
|
-
var
|
|
1642
|
+
var safeUrl = (str) => {
|
|
1613
1643
|
try {
|
|
1614
|
-
return
|
|
1644
|
+
return new URL(str ?? "");
|
|
1615
1645
|
} catch {
|
|
1616
|
-
return
|
|
1646
|
+
return void 0;
|
|
1617
1647
|
}
|
|
1618
1648
|
};
|
|
1619
|
-
|
|
1620
|
-
|
|
1649
|
+
|
|
1650
|
+
// src/safe-stringify.ts
|
|
1651
|
+
var SKIP = Object.freeze({});
|
|
1652
|
+
function safeStringify(obj, filter = defaultFilter, indent = 2) {
|
|
1653
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
1654
|
+
function replacer(key, value) {
|
|
1621
1655
|
try {
|
|
1622
|
-
|
|
1623
|
-
|
|
1656
|
+
let path = key;
|
|
1657
|
+
if (!key) {
|
|
1658
|
+
path = "$";
|
|
1659
|
+
if (value != null && typeof value === "object") {
|
|
1660
|
+
seen.set(value, path);
|
|
1661
|
+
}
|
|
1662
|
+
return value;
|
|
1663
|
+
} else if (this) {
|
|
1664
|
+
const parentPath = seen.get(this);
|
|
1665
|
+
path = parentPath ? `${parentPath}.${key}` : key;
|
|
1666
|
+
}
|
|
1667
|
+
if (value == null) {
|
|
1668
|
+
return value;
|
|
1669
|
+
}
|
|
1670
|
+
if (typeof value === "function") {
|
|
1671
|
+
return void 0;
|
|
1672
|
+
}
|
|
1673
|
+
if (typeof value === "object" && Object.getPrototypeOf(value) !== Object.prototype && !Array.isArray(value)) {
|
|
1674
|
+
return void 0;
|
|
1675
|
+
}
|
|
1676
|
+
if (typeof value === "object" && value !== null) {
|
|
1677
|
+
const exists = seen.get(value);
|
|
1678
|
+
if (exists) {
|
|
1679
|
+
return `[${path} => ${exists}]`;
|
|
1680
|
+
}
|
|
1681
|
+
seen.set(value, path);
|
|
1682
|
+
}
|
|
1683
|
+
if (filter) {
|
|
1684
|
+
const filteredValue = filter?.(key, value);
|
|
1685
|
+
if (filteredValue !== void 0) {
|
|
1686
|
+
return filteredValue === SKIP ? void 0 : filteredValue;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
return value;
|
|
1690
|
+
} catch (error) {
|
|
1691
|
+
return `ERROR: ${error.message}`;
|
|
1624
1692
|
}
|
|
1625
1693
|
}
|
|
1626
|
-
|
|
1694
|
+
try {
|
|
1695
|
+
return JSON.stringify(obj, replacer, indent);
|
|
1696
|
+
} catch (error) {
|
|
1697
|
+
return `ERROR: ${error.message}`;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen } = {}) => {
|
|
1701
|
+
let currentDepth = 0;
|
|
1702
|
+
const depthMap = /* @__PURE__ */ new WeakMap();
|
|
1703
|
+
return function(key, value) {
|
|
1704
|
+
if (key === "") {
|
|
1705
|
+
currentDepth = 0;
|
|
1706
|
+
} else if (this && typeof this === "object") {
|
|
1707
|
+
const parentDepth = depthMap.get(this) ?? 0;
|
|
1708
|
+
currentDepth = parentDepth + 1;
|
|
1709
|
+
}
|
|
1710
|
+
if (typeof value === "function") {
|
|
1711
|
+
return SKIP;
|
|
1712
|
+
}
|
|
1713
|
+
if (maxArrayLen != null && Array.isArray(value) && value.length > maxArrayLen) {
|
|
1714
|
+
return `[length: ${value.length}]`;
|
|
1715
|
+
}
|
|
1716
|
+
if (value && typeof value === "object") {
|
|
1717
|
+
depthMap.set(value, currentDepth);
|
|
1718
|
+
if (maxDepth != null && currentDepth >= maxDepth) {
|
|
1719
|
+
return Array.isArray(value) ? `[{ length: ${value.length} }]` : `{ keys: ${Object.keys(value).length} }`;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
if (omit2?.includes(key)) {
|
|
1723
|
+
return SKIP;
|
|
1724
|
+
}
|
|
1725
|
+
if (parse?.includes(key) && typeof value === "string") {
|
|
1726
|
+
try {
|
|
1727
|
+
return JSON.parse(value);
|
|
1728
|
+
} catch {
|
|
1729
|
+
return value;
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
if (maxStringLen != null && typeof value === "string" && value.length > maxStringLen) {
|
|
1733
|
+
return value.slice(0, maxStringLen) + "...";
|
|
1734
|
+
}
|
|
1735
|
+
return value;
|
|
1736
|
+
};
|
|
1627
1737
|
};
|
|
1738
|
+
var defaultFilter = createReplacer();
|
|
1628
1739
|
|
|
1629
1740
|
// src/sliding-window-summary.ts
|
|
1630
1741
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1631
1742
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
|
|
1632
1743
|
var SlidingWindowSummary = class {
|
|
1744
|
+
_buffer;
|
|
1745
|
+
_sum = 0;
|
|
1746
|
+
_precision;
|
|
1633
1747
|
constructor(options) {
|
|
1634
|
-
this._sum = 0;
|
|
1635
1748
|
this._buffer = new CircularBuffer(options.dataPoints);
|
|
1636
1749
|
if (options.precision != null) {
|
|
1637
1750
|
invariant5(options.precision >= 0, void 0, {
|
|
@@ -1711,12 +1824,24 @@ var capitalize = (str) => {
|
|
|
1711
1824
|
}
|
|
1712
1825
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1713
1826
|
};
|
|
1714
|
-
|
|
1715
|
-
const
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1827
|
+
function trim(strings, ...values) {
|
|
1828
|
+
const raw = strings.reduce((out, str, i) => {
|
|
1829
|
+
out += str;
|
|
1830
|
+
if (i < values.length) {
|
|
1831
|
+
const match = str.match(/(^|\n)([ \t]*)$/);
|
|
1832
|
+
const baseIndent = match ? match[2] : "";
|
|
1833
|
+
const val = String(values[i]).replace(/\r?\n/g, "\n" + baseIndent);
|
|
1834
|
+
out += val;
|
|
1835
|
+
}
|
|
1836
|
+
return out;
|
|
1837
|
+
}, "");
|
|
1838
|
+
const lines = raw.split("\n");
|
|
1839
|
+
while (lines.length && !lines[0].trim()) lines.shift();
|
|
1840
|
+
while (lines.length && !lines[lines.length - 1].trim()) lines.pop();
|
|
1841
|
+
const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
|
|
1842
|
+
return lines.map((l) => l.slice(minIndent)).join("\n");
|
|
1843
|
+
}
|
|
1844
|
+
var kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
|
|
1720
1845
|
|
|
1721
1846
|
// src/sum.ts
|
|
1722
1847
|
var sum = (values) => values.reduce((a, b) => a + b, 0);
|
|
@@ -1730,18 +1855,6 @@ var throwUnhandledError = (error) => {
|
|
|
1730
1855
|
|
|
1731
1856
|
// src/to-fallback.ts
|
|
1732
1857
|
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
1858
|
"\u{1F47B}",
|
|
1746
1859
|
"\u{1F479}",
|
|
1747
1860
|
"\u{1F47D}",
|
|
@@ -1877,17 +1990,18 @@ var idEmoji = [
|
|
|
1877
1990
|
];
|
|
1878
1991
|
var idHue = [
|
|
1879
1992
|
"red",
|
|
1880
|
-
|
|
1993
|
+
"orange",
|
|
1881
1994
|
"amber",
|
|
1882
|
-
|
|
1995
|
+
"yellow",
|
|
1883
1996
|
"lime",
|
|
1884
1997
|
"green",
|
|
1885
1998
|
"emerald",
|
|
1886
1999
|
"teal",
|
|
1887
2000
|
"cyan",
|
|
1888
|
-
//
|
|
1889
|
-
// '
|
|
1890
|
-
// '
|
|
2001
|
+
// Omit colors similar to primary accent.
|
|
2002
|
+
// 'sky' as const,
|
|
2003
|
+
// 'blue' as const,
|
|
2004
|
+
// 'indigo' as const,
|
|
1891
2005
|
"violet",
|
|
1892
2006
|
"purple",
|
|
1893
2007
|
"fuchsia",
|
|
@@ -1915,10 +2029,8 @@ var toFallback = (hash) => {
|
|
|
1915
2029
|
|
|
1916
2030
|
// src/tracer.ts
|
|
1917
2031
|
var Tracer = class {
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
this._recording = false;
|
|
1921
|
-
}
|
|
2032
|
+
_events = /* @__PURE__ */ new Map();
|
|
2033
|
+
_recording = false;
|
|
1922
2034
|
// TODO(burdon): Start/stop methods for recording data? By id?
|
|
1923
2035
|
// Alternatively, enable subscriptions to track/compute series.
|
|
1924
2036
|
// TODO(burdon): Hierarchical traces?
|
|
@@ -2019,7 +2131,7 @@ var stringifyTree = (node, ancestors = [], rows = []) => {
|
|
|
2019
2131
|
};
|
|
2020
2132
|
|
|
2021
2133
|
// src/types.ts
|
|
2022
|
-
var
|
|
2134
|
+
var isTruthy = (value) => !!value;
|
|
2023
2135
|
var isNonNullable = (value) => value != null;
|
|
2024
2136
|
var doAsync = async (fn) => fn();
|
|
2025
2137
|
var getProviderValue = (provider, arg) => {
|
|
@@ -2049,6 +2161,113 @@ var arrayMove = (array, from, to) => {
|
|
|
2049
2161
|
array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
|
|
2050
2162
|
return array;
|
|
2051
2163
|
};
|
|
2164
|
+
function arraySwap(array, from, to) {
|
|
2165
|
+
const current = array[from];
|
|
2166
|
+
array[from] = array[to];
|
|
2167
|
+
array[to] = current;
|
|
2168
|
+
return array;
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
// src/unit.ts
|
|
2172
|
+
var createFormat = (unit) => {
|
|
2173
|
+
return (n, precision = unit.precision ?? 0) => {
|
|
2174
|
+
const value = n / unit.quotient;
|
|
2175
|
+
return {
|
|
2176
|
+
unit,
|
|
2177
|
+
value,
|
|
2178
|
+
formattedValue: value.toFixed(precision),
|
|
2179
|
+
toString: () => `${value.toFixed(precision)}${unit.symbol}`
|
|
2180
|
+
};
|
|
2181
|
+
};
|
|
2182
|
+
};
|
|
2183
|
+
var MS_SECONDS = 1e3;
|
|
2184
|
+
var MS_MINUTES = 60 * MS_SECONDS;
|
|
2185
|
+
var MS_HOURS = 60 * MS_MINUTES;
|
|
2186
|
+
var Unit = {
|
|
2187
|
+
// General.
|
|
2188
|
+
Percent: createFormat({
|
|
2189
|
+
symbol: "%",
|
|
2190
|
+
quotient: 1 / 100,
|
|
2191
|
+
precision: 2
|
|
2192
|
+
}),
|
|
2193
|
+
Thousand: createFormat({
|
|
2194
|
+
symbol: "k",
|
|
2195
|
+
quotient: 1e3,
|
|
2196
|
+
precision: 2
|
|
2197
|
+
}),
|
|
2198
|
+
// Bytes (note KB vs KiB).
|
|
2199
|
+
Gigabyte: createFormat({
|
|
2200
|
+
symbol: "GB",
|
|
2201
|
+
quotient: 1e3 * 1e3 * 1e3,
|
|
2202
|
+
precision: 2
|
|
2203
|
+
}),
|
|
2204
|
+
Megabyte: createFormat({
|
|
2205
|
+
symbol: "MB",
|
|
2206
|
+
quotient: 1e3 * 1e3,
|
|
2207
|
+
precision: 2
|
|
2208
|
+
}),
|
|
2209
|
+
Kilobyte: createFormat({
|
|
2210
|
+
symbol: "KB",
|
|
2211
|
+
quotient: 1e3,
|
|
2212
|
+
precision: 2
|
|
2213
|
+
}),
|
|
2214
|
+
Byte: createFormat({
|
|
2215
|
+
symbol: "B",
|
|
2216
|
+
quotient: 1
|
|
2217
|
+
}),
|
|
2218
|
+
// Time.
|
|
2219
|
+
Hour: createFormat({
|
|
2220
|
+
symbol: "h",
|
|
2221
|
+
quotient: MS_HOURS
|
|
2222
|
+
}),
|
|
2223
|
+
Minute: createFormat({
|
|
2224
|
+
symbol: "m",
|
|
2225
|
+
quotient: MS_MINUTES
|
|
2226
|
+
}),
|
|
2227
|
+
Second: createFormat({
|
|
2228
|
+
symbol: "s",
|
|
2229
|
+
quotient: MS_SECONDS,
|
|
2230
|
+
precision: 1
|
|
2231
|
+
}),
|
|
2232
|
+
Millisecond: createFormat({
|
|
2233
|
+
symbol: "ms",
|
|
2234
|
+
quotient: 1
|
|
2235
|
+
}),
|
|
2236
|
+
Duration: (n) => {
|
|
2237
|
+
const hours = Math.floor(n / MS_HOURS);
|
|
2238
|
+
const minutes = Math.floor(n % MS_HOURS / MS_MINUTES);
|
|
2239
|
+
if (hours) {
|
|
2240
|
+
const formattedValue = minutes ? `${hours}h ${minutes}m` : `${hours}h`;
|
|
2241
|
+
return {
|
|
2242
|
+
unit: {
|
|
2243
|
+
symbol: "h",
|
|
2244
|
+
quotient: MS_HOURS
|
|
2245
|
+
},
|
|
2246
|
+
value: hours,
|
|
2247
|
+
formattedValue,
|
|
2248
|
+
toString: () => formattedValue
|
|
2249
|
+
};
|
|
2250
|
+
}
|
|
2251
|
+
if (minutes) {
|
|
2252
|
+
const seconds2 = (n - MS_MINUTES * minutes) / MS_SECONDS;
|
|
2253
|
+
const formattedValue = seconds2 ? `${minutes}m ${seconds2}s` : `${minutes}m`;
|
|
2254
|
+
return {
|
|
2255
|
+
unit: {
|
|
2256
|
+
symbol: "m",
|
|
2257
|
+
quotient: MS_MINUTES
|
|
2258
|
+
},
|
|
2259
|
+
value: minutes,
|
|
2260
|
+
formattedValue,
|
|
2261
|
+
toString: () => formattedValue
|
|
2262
|
+
};
|
|
2263
|
+
}
|
|
2264
|
+
const seconds = n >= MS_SECONDS;
|
|
2265
|
+
if (seconds) {
|
|
2266
|
+
return Unit.Second(n);
|
|
2267
|
+
}
|
|
2268
|
+
return Unit.Millisecond(n);
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2052
2271
|
|
|
2053
2272
|
// src/url.ts
|
|
2054
2273
|
var createUrl = (url, search) => {
|
|
@@ -2061,11 +2280,11 @@ var createUrl = (url, search) => {
|
|
|
2061
2280
|
|
|
2062
2281
|
// src/weak.ts
|
|
2063
2282
|
var WeakDictionary = class {
|
|
2283
|
+
_internal = /* @__PURE__ */ new Map();
|
|
2284
|
+
_finalization = new FinalizationRegistry((cleanUpCallback) => {
|
|
2285
|
+
cleanUpCallback();
|
|
2286
|
+
});
|
|
2064
2287
|
constructor(entries2) {
|
|
2065
|
-
this._internal = /* @__PURE__ */ new Map();
|
|
2066
|
-
this._finalization = new FinalizationRegistry((cleanUpCallback) => {
|
|
2067
|
-
cleanUpCallback();
|
|
2068
|
-
});
|
|
2069
2288
|
this._internal = new Map(entries2?.map(([key, value]) => [
|
|
2070
2289
|
key,
|
|
2071
2290
|
new WeakRef(value)
|
|
@@ -2153,6 +2372,58 @@ var WeakDictionary = class {
|
|
|
2153
2372
|
this._finalization.unregister(value);
|
|
2154
2373
|
}
|
|
2155
2374
|
};
|
|
2375
|
+
|
|
2376
|
+
// src/error-format.ts
|
|
2377
|
+
var formatErrorWithCauses = (error) => {
|
|
2378
|
+
const lines = [];
|
|
2379
|
+
let current = error;
|
|
2380
|
+
let level = 0;
|
|
2381
|
+
while (current) {
|
|
2382
|
+
const prefix = level === 0 ? "" : `Caused by: `;
|
|
2383
|
+
lines.push(prefix + (current.stack ?? String(current)));
|
|
2384
|
+
if (!(current.cause instanceof Error)) break;
|
|
2385
|
+
current = current.cause;
|
|
2386
|
+
level += 1;
|
|
2387
|
+
}
|
|
2388
|
+
return lines.join("\n\n");
|
|
2389
|
+
};
|
|
2390
|
+
|
|
2391
|
+
// src/retry.ts
|
|
2392
|
+
var DEFAULT_RETRY_OPTIONS = {
|
|
2393
|
+
count: 3,
|
|
2394
|
+
delayMs: 100,
|
|
2395
|
+
exponent: 2,
|
|
2396
|
+
retryOnError: async () => true,
|
|
2397
|
+
retryOnValue: async () => false
|
|
2398
|
+
};
|
|
2399
|
+
var retry = async (options, cb) => {
|
|
2400
|
+
const fullOptions = {
|
|
2401
|
+
...DEFAULT_RETRY_OPTIONS,
|
|
2402
|
+
...options
|
|
2403
|
+
};
|
|
2404
|
+
let numRetries = 0, currentDelay = fullOptions.delayMs;
|
|
2405
|
+
while (true) {
|
|
2406
|
+
let result;
|
|
2407
|
+
try {
|
|
2408
|
+
result = await cb();
|
|
2409
|
+
} catch (err) {
|
|
2410
|
+
if (numRetries > fullOptions.count || !await fullOptions.retryOnError(err)) {
|
|
2411
|
+
throw err;
|
|
2412
|
+
}
|
|
2413
|
+
await new Promise((resolve) => setTimeout(resolve, currentDelay));
|
|
2414
|
+
currentDelay *= fullOptions.exponent;
|
|
2415
|
+
numRetries++;
|
|
2416
|
+
continue;
|
|
2417
|
+
}
|
|
2418
|
+
if (!await fullOptions.retryOnValue(result)) {
|
|
2419
|
+
return result;
|
|
2420
|
+
}
|
|
2421
|
+
await new Promise((resolve) => setTimeout(resolve, currentDelay));
|
|
2422
|
+
currentDelay *= fullOptions.exponent;
|
|
2423
|
+
numRetries++;
|
|
2424
|
+
continue;
|
|
2425
|
+
}
|
|
2426
|
+
};
|
|
2156
2427
|
export {
|
|
2157
2428
|
BitField,
|
|
2158
2429
|
Callback,
|
|
@@ -2162,11 +2433,14 @@ export {
|
|
|
2162
2433
|
ComplexSet,
|
|
2163
2434
|
HumanHasher,
|
|
2164
2435
|
MapEntry,
|
|
2436
|
+
SKIP,
|
|
2165
2437
|
SlidingWindowSummary,
|
|
2166
2438
|
Tracer,
|
|
2439
|
+
Unit,
|
|
2167
2440
|
WeakDictionary,
|
|
2168
2441
|
accessBy,
|
|
2169
2442
|
arrayMove,
|
|
2443
|
+
arraySwap,
|
|
2170
2444
|
arrayToBuffer,
|
|
2171
2445
|
arrayToHex,
|
|
2172
2446
|
arrayToString,
|
|
@@ -2178,18 +2452,23 @@ export {
|
|
|
2178
2452
|
chunkArray,
|
|
2179
2453
|
clamp,
|
|
2180
2454
|
clearUndefined,
|
|
2455
|
+
coerceArray,
|
|
2181
2456
|
compareMulti,
|
|
2182
2457
|
compareObject,
|
|
2183
2458
|
compareScalar,
|
|
2184
2459
|
compareString,
|
|
2460
|
+
compositeKey,
|
|
2185
2461
|
createBinder,
|
|
2186
2462
|
createBucketReducer,
|
|
2463
|
+
createFilename,
|
|
2187
2464
|
createGroupReducer,
|
|
2465
|
+
createReplacer,
|
|
2188
2466
|
createSetDispatch,
|
|
2189
2467
|
createUrl,
|
|
2190
2468
|
decamelize,
|
|
2191
2469
|
deepMapValues,
|
|
2192
2470
|
deepMapValuesAsync,
|
|
2471
|
+
defaultFilter,
|
|
2193
2472
|
defaultMap,
|
|
2194
2473
|
defer,
|
|
2195
2474
|
deferAsync,
|
|
@@ -2201,12 +2480,11 @@ export {
|
|
|
2201
2480
|
entry,
|
|
2202
2481
|
exponentialBackoffInterval,
|
|
2203
2482
|
forEachAsync,
|
|
2204
|
-
|
|
2483
|
+
formatErrorWithCauses,
|
|
2205
2484
|
getAsyncProviderValue,
|
|
2206
2485
|
getDate,
|
|
2207
2486
|
getDebugName,
|
|
2208
2487
|
getDeep,
|
|
2209
|
-
getFirstTwoRenderableChars,
|
|
2210
2488
|
getHostPlatform,
|
|
2211
2489
|
getPrototypeSpecificInstanceId,
|
|
2212
2490
|
getProviderValue,
|
|
@@ -2222,14 +2500,19 @@ export {
|
|
|
2222
2500
|
intersectBy,
|
|
2223
2501
|
intersection,
|
|
2224
2502
|
iosCheck,
|
|
2503
|
+
isBun,
|
|
2504
|
+
isMobile,
|
|
2505
|
+
isMobileOrTablet,
|
|
2225
2506
|
isNode,
|
|
2226
2507
|
isNonNullable,
|
|
2227
|
-
|
|
2508
|
+
isTauri,
|
|
2509
|
+
isTruthy,
|
|
2228
2510
|
joinTables,
|
|
2229
2511
|
jsonKeyReplacer,
|
|
2230
2512
|
jsonReplacer,
|
|
2231
2513
|
jsonify,
|
|
2232
2514
|
jsonlogify,
|
|
2515
|
+
kebabize,
|
|
2233
2516
|
keyToEmoji,
|
|
2234
2517
|
keyToFallback,
|
|
2235
2518
|
keyToHue,
|
|
@@ -2238,7 +2521,6 @@ export {
|
|
|
2238
2521
|
makeSet,
|
|
2239
2522
|
mapValues,
|
|
2240
2523
|
median,
|
|
2241
|
-
mobileAndTabletCheck,
|
|
2242
2524
|
numericalValues,
|
|
2243
2525
|
omit,
|
|
2244
2526
|
orderKeys,
|
|
@@ -2254,15 +2536,18 @@ export {
|
|
|
2254
2536
|
removeBy,
|
|
2255
2537
|
removeProperties,
|
|
2256
2538
|
removeUndefinedProperties,
|
|
2539
|
+
retry,
|
|
2257
2540
|
safariCheck,
|
|
2258
2541
|
safeAwaitAll,
|
|
2259
2542
|
safeInstanceof,
|
|
2260
2543
|
safeParseFloat,
|
|
2261
2544
|
safeParseInt,
|
|
2262
2545
|
safeParseJson,
|
|
2263
|
-
|
|
2546
|
+
safeStringify,
|
|
2547
|
+
safeUrl,
|
|
2264
2548
|
setDeep,
|
|
2265
2549
|
sortKeys,
|
|
2550
|
+
splitCompositeKey,
|
|
2266
2551
|
stringToArray,
|
|
2267
2552
|
stringifyTree,
|
|
2268
2553
|
stripUndefined,
|