@dxos/util 0.8.4-main.72ec0f3 → 0.8.4-main.7996785055
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 +182 -58
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +182 -58
- 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/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 +4 -0
- 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 +10 -1
- package/dist/types/src/safe-stringify.d.ts.map +1 -1
- 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/to-fallback.d.ts +18 -4
- package/dist/types/src/to-fallback.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +23 -5
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/unit.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -10
- package/src/array.ts +9 -2
- package/src/circular-buffer.test.ts +26 -0
- package/src/circular-buffer.ts +5 -0
- 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/index.ts +4 -0
- package/src/platform.ts +35 -3
- package/src/retry.ts +74 -0
- package/src/safe-parse.ts +27 -16
- package/src/safe-stringify.test.ts +96 -0
- package/src/safe-stringify.ts +74 -25
- package/src/to-fallback.ts +39 -156
- package/src/types.test.ts +11 -1
- package/src/types.ts +39 -11
- package/src/unit.ts +1 -0
- 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/src/explicit-resource-management-polyfill.ts +0 -13
|
@@ -97,6 +97,14 @@ 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) {
|
|
@@ -327,6 +335,10 @@ var CircularBuffer = class {
|
|
|
327
335
|
get elementCount() {
|
|
328
336
|
return this._elementCount;
|
|
329
337
|
}
|
|
338
|
+
clear() {
|
|
339
|
+
this._nextIndex = 0;
|
|
340
|
+
this._elementCount = 0;
|
|
341
|
+
}
|
|
330
342
|
getLast() {
|
|
331
343
|
if (this._elementCount === 0) {
|
|
332
344
|
return void 0;
|
|
@@ -559,15 +571,18 @@ var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
|
|
|
559
571
|
}
|
|
560
572
|
};
|
|
561
573
|
|
|
574
|
+
// src/composite-key.ts
|
|
575
|
+
var SEPARATOR = ":";
|
|
576
|
+
var compositeKey = (...parts) => parts.join(SEPARATOR);
|
|
577
|
+
var splitCompositeKey = (key) => key.split(SEPARATOR);
|
|
578
|
+
|
|
562
579
|
// src/deep.ts
|
|
563
|
-
import get from "lodash.get";
|
|
564
|
-
import set from "lodash.set";
|
|
565
580
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
566
581
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/common/util/src/deep.ts";
|
|
567
582
|
var setDeep = (obj, path, value) => {
|
|
568
583
|
invariant4(path.length > 0, void 0, {
|
|
569
584
|
F: __dxlog_file4,
|
|
570
|
-
L:
|
|
585
|
+
L: 12,
|
|
571
586
|
S: void 0,
|
|
572
587
|
A: [
|
|
573
588
|
"path.length > 0",
|
|
@@ -597,6 +612,7 @@ var getDeep = (obj, path) => {
|
|
|
597
612
|
var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
|
|
598
613
|
|
|
599
614
|
// src/defer.ts
|
|
615
|
+
import "@hazae41/symbol-dispose-polyfill";
|
|
600
616
|
var defer = (fn) => new DeferGuard(fn);
|
|
601
617
|
var DeferGuard = class {
|
|
602
618
|
_fn;
|
|
@@ -657,6 +673,12 @@ var MapEntry = class {
|
|
|
657
673
|
}
|
|
658
674
|
};
|
|
659
675
|
|
|
676
|
+
// src/filename.ts
|
|
677
|
+
var createFilename = ({ parts = [], ext, date = /* @__PURE__ */ new Date() }) => [
|
|
678
|
+
date.toISOString().replace(/[:.]/g, "-"),
|
|
679
|
+
...parts
|
|
680
|
+
].join("_") + (ext ? `.${ext}` : "");
|
|
681
|
+
|
|
660
682
|
// src/for-each-async.ts
|
|
661
683
|
var forEachAsync = (items, fn) => Promise.all(items.map(fn));
|
|
662
684
|
|
|
@@ -1003,7 +1025,7 @@ var defaultMap = (map, key, def) => {
|
|
|
1003
1025
|
};
|
|
1004
1026
|
|
|
1005
1027
|
// src/instance-id.ts
|
|
1006
|
-
var symbol = Symbol.for("dxos.instance-contexts");
|
|
1028
|
+
var symbol = /* @__PURE__ */ Symbol.for("dxos.instance-contexts");
|
|
1007
1029
|
var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
|
|
1008
1030
|
var getPrototypeSpecificInstanceId = (instance) => {
|
|
1009
1031
|
const prototype = Object.getPrototypeOf(instance);
|
|
@@ -1352,7 +1374,18 @@ var omit = (obj, keys2) => {
|
|
|
1352
1374
|
|
|
1353
1375
|
// src/platform.ts
|
|
1354
1376
|
var isNode = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
1355
|
-
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 = () => {
|
|
1356
1389
|
let check = false;
|
|
1357
1390
|
((a) => {
|
|
1358
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))) {
|
|
@@ -1374,7 +1407,7 @@ var iosCheck = () => {
|
|
|
1374
1407
|
};
|
|
1375
1408
|
var safariCheck = () => typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1376
1409
|
var getHostPlatform = () => {
|
|
1377
|
-
if (!("navigator" in
|
|
1410
|
+
if (!("navigator" in globalThis)) {
|
|
1378
1411
|
return "unknown";
|
|
1379
1412
|
}
|
|
1380
1413
|
const platform = (navigator.userAgentData?.platform || navigator.platform)?.toLowerCase();
|
|
@@ -1569,7 +1602,7 @@ var safeAwaitAll = async (source, taskFactory, onError) => {
|
|
|
1569
1602
|
};
|
|
1570
1603
|
|
|
1571
1604
|
// src/safe-instanceof.ts
|
|
1572
|
-
var instanceTag = Symbol("instanceTag");
|
|
1605
|
+
var instanceTag = /* @__PURE__ */ Symbol("instanceTag");
|
|
1573
1606
|
var safeInstanceof = (tag) => (target) => {
|
|
1574
1607
|
target.prototype[instanceTag] = tag;
|
|
1575
1608
|
Object.defineProperty(target.prototype, Symbol.hasInstance, {
|
|
@@ -1581,57 +1614,88 @@ var safeInstanceof = (tag) => (target) => {
|
|
|
1581
1614
|
};
|
|
1582
1615
|
|
|
1583
1616
|
// src/safe-parse.ts
|
|
1584
|
-
|
|
1617
|
+
function safeParseInt(str, defaultValue) {
|
|
1585
1618
|
try {
|
|
1586
|
-
const
|
|
1587
|
-
return isNaN(
|
|
1619
|
+
const value = parseInt(str ?? "");
|
|
1620
|
+
return isNaN(value) ? defaultValue : value;
|
|
1588
1621
|
} catch {
|
|
1589
1622
|
return defaultValue;
|
|
1590
1623
|
}
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1624
|
+
}
|
|
1625
|
+
function safeParseFloat(str, defaultValue) {
|
|
1593
1626
|
try {
|
|
1594
|
-
|
|
1627
|
+
const value = parseFloat(str ?? "");
|
|
1628
|
+
return isNaN(value) ? defaultValue : value;
|
|
1595
1629
|
} catch {
|
|
1596
|
-
return defaultValue
|
|
1630
|
+
return defaultValue;
|
|
1597
1631
|
}
|
|
1598
|
-
}
|
|
1599
|
-
var safeParseJson = (
|
|
1600
|
-
if (
|
|
1632
|
+
}
|
|
1633
|
+
var safeParseJson = (str, defaultValue) => {
|
|
1634
|
+
if (str && str.length > 0) {
|
|
1601
1635
|
try {
|
|
1602
|
-
return JSON.parse(
|
|
1636
|
+
return JSON.parse(str);
|
|
1603
1637
|
} catch {
|
|
1604
1638
|
}
|
|
1605
1639
|
}
|
|
1606
1640
|
return defaultValue;
|
|
1607
1641
|
};
|
|
1642
|
+
var safeUrl = (str) => {
|
|
1643
|
+
try {
|
|
1644
|
+
return new URL(str ?? "");
|
|
1645
|
+
} catch {
|
|
1646
|
+
return void 0;
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1608
1649
|
|
|
1609
1650
|
// src/safe-stringify.ts
|
|
1610
1651
|
var SKIP = Object.freeze({});
|
|
1611
1652
|
function safeStringify(obj, filter = defaultFilter, indent = 2) {
|
|
1612
|
-
const seen = /* @__PURE__ */ new
|
|
1653
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
1613
1654
|
function replacer(key, value) {
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1655
|
+
try {
|
|
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;
|
|
1617
1666
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
return v2 === SKIP ? void 0 : v2;
|
|
1667
|
+
if (value == null) {
|
|
1668
|
+
return value;
|
|
1669
|
+
}
|
|
1670
|
+
if (typeof value === "function") {
|
|
1671
|
+
return void 0;
|
|
1624
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}`;
|
|
1625
1692
|
}
|
|
1626
|
-
return value;
|
|
1627
1693
|
}
|
|
1628
|
-
let result = "";
|
|
1629
1694
|
try {
|
|
1630
|
-
|
|
1695
|
+
return JSON.stringify(obj, replacer, indent);
|
|
1631
1696
|
} catch (error) {
|
|
1632
|
-
|
|
1697
|
+
return `ERROR: ${error.message}`;
|
|
1633
1698
|
}
|
|
1634
|
-
return result;
|
|
1635
1699
|
}
|
|
1636
1700
|
var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen } = {}) => {
|
|
1637
1701
|
let currentDepth = 0;
|
|
@@ -1644,7 +1708,10 @@ var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen
|
|
|
1644
1708
|
currentDepth = parentDepth + 1;
|
|
1645
1709
|
}
|
|
1646
1710
|
if (typeof value === "function") {
|
|
1647
|
-
return
|
|
1711
|
+
return SKIP;
|
|
1712
|
+
}
|
|
1713
|
+
if (maxArrayLen != null && Array.isArray(value) && value.length > maxArrayLen) {
|
|
1714
|
+
return `[length: ${value.length}]`;
|
|
1648
1715
|
}
|
|
1649
1716
|
if (value && typeof value === "object") {
|
|
1650
1717
|
depthMap.set(value, currentDepth);
|
|
@@ -1653,7 +1720,7 @@ var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen
|
|
|
1653
1720
|
}
|
|
1654
1721
|
}
|
|
1655
1722
|
if (omit2?.includes(key)) {
|
|
1656
|
-
return
|
|
1723
|
+
return SKIP;
|
|
1657
1724
|
}
|
|
1658
1725
|
if (parse?.includes(key) && typeof value === "string") {
|
|
1659
1726
|
try {
|
|
@@ -1662,9 +1729,6 @@ var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen
|
|
|
1662
1729
|
return value;
|
|
1663
1730
|
}
|
|
1664
1731
|
}
|
|
1665
|
-
if (maxArrayLen != null && Array.isArray(value) && value.length > maxArrayLen) {
|
|
1666
|
-
return `[length: ${value.length}]`;
|
|
1667
|
-
}
|
|
1668
1732
|
if (maxStringLen != null && typeof value === "string" && value.length > maxStringLen) {
|
|
1669
1733
|
return value.slice(0, maxStringLen) + "...";
|
|
1670
1734
|
}
|
|
@@ -1791,18 +1855,6 @@ var throwUnhandledError = (error) => {
|
|
|
1791
1855
|
|
|
1792
1856
|
// src/to-fallback.ts
|
|
1793
1857
|
var idEmoji = [
|
|
1794
|
-
// When changing this set, please check the result in a console or e.g. RunKit (https://runkit.com/thure/642214441dd6ae000855a8de)
|
|
1795
|
-
// 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.
|
|
1796
|
-
// This set was chosen from the characters in Unicode Emoji v15.0 based on the following criteria:
|
|
1797
|
-
// – not people or isolated anthropomorphic faces
|
|
1798
|
-
// – not flags
|
|
1799
|
-
// – more concrete than abstract
|
|
1800
|
-
// – less culturally specific
|
|
1801
|
-
// – less easily confused with another emoji in the set
|
|
1802
|
-
// – requires less special knowledge to identify
|
|
1803
|
-
// – less likely to evoke negative feelings (no meat, no drugs, no weapons, etc)
|
|
1804
|
-
// – less common as a signifier in UX
|
|
1805
|
-
// NOTE that this is intentionally an array of strings because of the way emoji graphemes work.
|
|
1806
1858
|
"\u{1F47B}",
|
|
1807
1859
|
"\u{1F479}",
|
|
1808
1860
|
"\u{1F47D}",
|
|
@@ -1938,17 +1990,18 @@ var idEmoji = [
|
|
|
1938
1990
|
];
|
|
1939
1991
|
var idHue = [
|
|
1940
1992
|
"red",
|
|
1941
|
-
|
|
1993
|
+
"orange",
|
|
1942
1994
|
"amber",
|
|
1943
|
-
|
|
1995
|
+
"yellow",
|
|
1944
1996
|
"lime",
|
|
1945
1997
|
"green",
|
|
1946
1998
|
"emerald",
|
|
1947
1999
|
"teal",
|
|
1948
2000
|
"cyan",
|
|
1949
|
-
//
|
|
1950
|
-
// '
|
|
1951
|
-
// '
|
|
2001
|
+
// Omit colors similar to primary accent.
|
|
2002
|
+
// 'sky' as const,
|
|
2003
|
+
// 'blue' as const,
|
|
2004
|
+
// 'indigo' as const,
|
|
1952
2005
|
"violet",
|
|
1953
2006
|
"purple",
|
|
1954
2007
|
"fuchsia",
|
|
@@ -2108,6 +2161,12 @@ var arrayMove = (array, from, to) => {
|
|
|
2108
2161
|
array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
|
|
2109
2162
|
return array;
|
|
2110
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
|
+
}
|
|
2111
2170
|
|
|
2112
2171
|
// src/unit.ts
|
|
2113
2172
|
var createFormat = (unit) => {
|
|
@@ -2152,6 +2211,10 @@ var Unit = {
|
|
|
2152
2211
|
quotient: 1e3,
|
|
2153
2212
|
precision: 2
|
|
2154
2213
|
}),
|
|
2214
|
+
Byte: createFormat({
|
|
2215
|
+
symbol: "B",
|
|
2216
|
+
quotient: 1
|
|
2217
|
+
}),
|
|
2155
2218
|
// Time.
|
|
2156
2219
|
Hour: createFormat({
|
|
2157
2220
|
symbol: "h",
|
|
@@ -2309,6 +2372,58 @@ var WeakDictionary = class {
|
|
|
2309
2372
|
this._finalization.unregister(value);
|
|
2310
2373
|
}
|
|
2311
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
|
+
};
|
|
2312
2427
|
export {
|
|
2313
2428
|
BitField,
|
|
2314
2429
|
Callback,
|
|
@@ -2325,6 +2440,7 @@ export {
|
|
|
2325
2440
|
WeakDictionary,
|
|
2326
2441
|
accessBy,
|
|
2327
2442
|
arrayMove,
|
|
2443
|
+
arraySwap,
|
|
2328
2444
|
arrayToBuffer,
|
|
2329
2445
|
arrayToHex,
|
|
2330
2446
|
arrayToString,
|
|
@@ -2336,12 +2452,15 @@ export {
|
|
|
2336
2452
|
chunkArray,
|
|
2337
2453
|
clamp,
|
|
2338
2454
|
clearUndefined,
|
|
2455
|
+
coerceArray,
|
|
2339
2456
|
compareMulti,
|
|
2340
2457
|
compareObject,
|
|
2341
2458
|
compareScalar,
|
|
2342
2459
|
compareString,
|
|
2460
|
+
compositeKey,
|
|
2343
2461
|
createBinder,
|
|
2344
2462
|
createBucketReducer,
|
|
2463
|
+
createFilename,
|
|
2345
2464
|
createGroupReducer,
|
|
2346
2465
|
createReplacer,
|
|
2347
2466
|
createSetDispatch,
|
|
@@ -2361,7 +2480,7 @@ export {
|
|
|
2361
2480
|
entry,
|
|
2362
2481
|
exponentialBackoffInterval,
|
|
2363
2482
|
forEachAsync,
|
|
2364
|
-
|
|
2483
|
+
formatErrorWithCauses,
|
|
2365
2484
|
getAsyncProviderValue,
|
|
2366
2485
|
getDate,
|
|
2367
2486
|
getDebugName,
|
|
@@ -2381,8 +2500,12 @@ export {
|
|
|
2381
2500
|
intersectBy,
|
|
2382
2501
|
intersection,
|
|
2383
2502
|
iosCheck,
|
|
2503
|
+
isBun,
|
|
2504
|
+
isMobile,
|
|
2505
|
+
isMobileOrTablet,
|
|
2384
2506
|
isNode,
|
|
2385
2507
|
isNonNullable,
|
|
2508
|
+
isTauri,
|
|
2386
2509
|
isTruthy,
|
|
2387
2510
|
joinTables,
|
|
2388
2511
|
jsonKeyReplacer,
|
|
@@ -2398,7 +2521,6 @@ export {
|
|
|
2398
2521
|
makeSet,
|
|
2399
2522
|
mapValues,
|
|
2400
2523
|
median,
|
|
2401
|
-
mobileAndTabletCheck,
|
|
2402
2524
|
numericalValues,
|
|
2403
2525
|
omit,
|
|
2404
2526
|
orderKeys,
|
|
@@ -2414,6 +2536,7 @@ export {
|
|
|
2414
2536
|
removeBy,
|
|
2415
2537
|
removeProperties,
|
|
2416
2538
|
removeUndefinedProperties,
|
|
2539
|
+
retry,
|
|
2417
2540
|
safariCheck,
|
|
2418
2541
|
safeAwaitAll,
|
|
2419
2542
|
safeInstanceof,
|
|
@@ -2421,9 +2544,10 @@ export {
|
|
|
2421
2544
|
safeParseInt,
|
|
2422
2545
|
safeParseJson,
|
|
2423
2546
|
safeStringify,
|
|
2424
|
-
|
|
2547
|
+
safeUrl,
|
|
2425
2548
|
setDeep,
|
|
2426
2549
|
sortKeys,
|
|
2550
|
+
splitCompositeKey,
|
|
2427
2551
|
stringToArray,
|
|
2428
2552
|
stringifyTree,
|
|
2429
2553
|
stripUndefined,
|