@dxos/util 0.8.4-main.72ec0f3 → 0.8.4-main.765dc60934
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/LICENSE +102 -5
- package/dist/lib/browser/index.mjs +368 -154
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +368 -154
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/array-to-hex.d.ts.map +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/binder.d.ts.map +1 -1
- package/dist/types/src/bitfield.d.ts.map +1 -1
- package/dist/types/src/browser-storage.d.ts +9 -0
- package/dist/types/src/browser-storage.d.ts.map +1 -0
- package/dist/types/src/callback-collection.d.ts.map +1 -1
- package/dist/types/src/callback.d.ts.map +1 -1
- package/dist/types/src/case.d.ts.map +1 -1
- package/dist/types/src/chunk-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/clear-undefined.d.ts.map +1 -1
- package/dist/types/src/complex.d.ts +15 -0
- package/dist/types/src/complex.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-function.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-container.d.ts.map +1 -1
- package/dist/types/src/di-key.d.ts +7 -5
- package/dist/types/src/di-key.d.ts.map +1 -1
- package/dist/types/src/entry.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/for-each-async.d.ts.map +1 -1
- package/dist/types/src/human-hash.d.ts.map +1 -1
- package/dist/types/src/id.d.ts +30 -0
- package/dist/types/src/id.d.ts.map +1 -0
- package/dist/types/src/id.test.d.ts +2 -0
- package/dist/types/src/id.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +6 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/instance-id.d.ts.map +1 -1
- package/dist/types/src/interval.d.ts.map +1 -1
- package/dist/types/src/join-tables.d.ts.map +1 -1
- package/dist/types/src/json.d.ts.map +1 -1
- package/dist/types/src/map-values.d.ts.map +1 -1
- package/dist/types/src/map.d.ts.map +1 -1
- package/dist/types/src/object.d.ts.map +1 -1
- package/dist/types/src/order-keys.d.ts.map +1 -1
- package/dist/types/src/order.d.ts.map +1 -1
- package/dist/types/src/pick.d.ts.map +1 -1
- package/dist/types/src/platform.d.ts +5 -2
- package/dist/types/src/platform.d.ts.map +1 -1
- package/dist/types/src/position.d.ts +1 -1
- package/dist/types/src/position.d.ts.map +1 -1
- package/dist/types/src/random.d.ts.map +1 -1
- package/dist/types/src/range.d.ts.map +1 -1
- package/dist/types/src/reducers.d.ts.map +1 -1
- package/dist/types/src/remove-undefined-keys.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-await.d.ts.map +1 -1
- package/dist/types/src/safe-instanceof.d.ts.map +1 -1
- 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/sliding-window-summary.d.ts.map +1 -1
- package/dist/types/src/sort.d.ts.map +1 -1
- package/dist/types/src/string.d.ts.map +1 -1
- package/dist/types/src/sum.d.ts.map +1 -1
- package/dist/types/src/throw-unhandled-error.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/tracer.d.ts.map +1 -1
- package/dist/types/src/tree.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/uint8array.d.ts.map +1 -1
- package/dist/types/src/unit.d.ts.map +1 -1
- package/dist/types/src/url.d.ts.map +1 -1
- package/dist/types/src/weak.d.ts +15 -0
- package/dist/types/src/weak.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -14
- package/src/array.ts +9 -2
- package/src/browser-storage.ts +60 -0
- package/src/circular-buffer.test.ts +26 -0
- package/src/circular-buffer.ts +5 -0
- package/src/complex.ts +32 -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/di-key.ts +10 -8
- package/src/error-format.ts +24 -0
- package/src/filename.ts +16 -0
- package/src/id.test.ts +109 -0
- package/src/id.ts +48 -0
- package/src/index.ts +6 -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/string.ts +6 -2
- package/src/to-fallback.ts +39 -156
- package/src/types.test.ts +11 -1
- package/src/types.ts +39 -11
- package/src/unit.ts +7 -2
- package/src/weak.ts +52 -14
- 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) {
|
|
@@ -111,7 +119,6 @@ var createBinder = (obj) => ({
|
|
|
111
119
|
|
|
112
120
|
// src/bitfield.ts
|
|
113
121
|
import { invariant } from "@dxos/invariant";
|
|
114
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/common/util/src/bitfield.ts";
|
|
115
122
|
var BitField = class _BitField {
|
|
116
123
|
static get(data, idx) {
|
|
117
124
|
const bit = data[idx >> 3] >> 7 - idx % 8 & 1;
|
|
@@ -143,15 +150,7 @@ var BitField = class _BitField {
|
|
|
143
150
|
return result;
|
|
144
151
|
}
|
|
145
152
|
static and(first, second) {
|
|
146
|
-
invariant(first.length === second.length, "Bitfields must be of the same length"
|
|
147
|
-
F: __dxlog_file,
|
|
148
|
-
L: 52,
|
|
149
|
-
S: this,
|
|
150
|
-
A: [
|
|
151
|
-
"first.length === second.length",
|
|
152
|
-
"'Bitfields must be of the same length'"
|
|
153
|
-
]
|
|
154
|
-
});
|
|
153
|
+
invariant(first.length === second.length, "Bitfields must be of the same length");
|
|
155
154
|
const result = new Uint8Array(first.length);
|
|
156
155
|
for (let i = 0; i < first.length; i++) {
|
|
157
156
|
result[i] = first[i] & second[i];
|
|
@@ -179,6 +178,49 @@ var BitField = class _BitField {
|
|
|
179
178
|
}
|
|
180
179
|
};
|
|
181
180
|
|
|
181
|
+
// src/browser-storage.ts
|
|
182
|
+
var clearIndexedDB = async () => {
|
|
183
|
+
const dbs = await indexedDB.databases();
|
|
184
|
+
const results = await Promise.allSettled(dbs.filter((db) => db.name != null).map((db) => new Promise((resolve, reject) => {
|
|
185
|
+
const request = indexedDB.deleteDatabase(db.name);
|
|
186
|
+
request.onsuccess = () => resolve();
|
|
187
|
+
request.onerror = () => reject(request.error);
|
|
188
|
+
request.onblocked = () => reject(new Error(`IndexedDB deletion blocked: ${db.name}`));
|
|
189
|
+
})));
|
|
190
|
+
const failures = results.filter((r) => r.status === "rejected");
|
|
191
|
+
if (failures.length > 0) {
|
|
192
|
+
throw new AggregateError(failures.map((r) => r.reason), "Failed to delete some IndexedDB databases");
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var clearOPFS = async () => {
|
|
196
|
+
const root = await navigator.storage.getDirectory();
|
|
197
|
+
const errors = [];
|
|
198
|
+
for await (const [name] of root.entries()) {
|
|
199
|
+
try {
|
|
200
|
+
await root.removeEntry(name, {
|
|
201
|
+
recursive: true
|
|
202
|
+
});
|
|
203
|
+
} catch (err) {
|
|
204
|
+
errors.push(err);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (errors.length > 0) {
|
|
208
|
+
throw new AggregateError(errors, "Failed to remove some OPFS entries");
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
var clearServiceWorkers = async () => {
|
|
212
|
+
const regs = await navigator.serviceWorker.getRegistrations();
|
|
213
|
+
for (const reg of regs) {
|
|
214
|
+
await reg.unregister();
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var clearCaches = async () => {
|
|
218
|
+
const keys2 = await caches.keys();
|
|
219
|
+
for (const key of keys2) {
|
|
220
|
+
await caches.delete(key);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
182
224
|
// src/callback-collection.ts
|
|
183
225
|
var CallbackCollection = class {
|
|
184
226
|
#callbacks = [];
|
|
@@ -205,34 +247,17 @@ var CallbackCollection = class {
|
|
|
205
247
|
|
|
206
248
|
// src/callback.ts
|
|
207
249
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
208
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/util/src/callback.ts";
|
|
209
250
|
var Callback = class {
|
|
210
251
|
_callback;
|
|
211
252
|
call(...args) {
|
|
212
|
-
invariant2(this._callback, "Callback not set"
|
|
213
|
-
F: __dxlog_file2,
|
|
214
|
-
L: 20,
|
|
215
|
-
S: this,
|
|
216
|
-
A: [
|
|
217
|
-
"this._callback",
|
|
218
|
-
"'Callback not set'"
|
|
219
|
-
]
|
|
220
|
-
});
|
|
253
|
+
invariant2(this._callback, "Callback not set");
|
|
221
254
|
return this._callback(...args);
|
|
222
255
|
}
|
|
223
256
|
callIfSet(...args) {
|
|
224
257
|
return this._callback?.(...args);
|
|
225
258
|
}
|
|
226
259
|
set(callback) {
|
|
227
|
-
invariant2(!this._callback, "Callback already set"
|
|
228
|
-
F: __dxlog_file2,
|
|
229
|
-
L: 29,
|
|
230
|
-
S: this,
|
|
231
|
-
A: [
|
|
232
|
-
"!this._callback",
|
|
233
|
-
"'Callback already set'"
|
|
234
|
-
]
|
|
235
|
-
});
|
|
260
|
+
invariant2(!this._callback, "Callback already set");
|
|
236
261
|
this._callback = callback;
|
|
237
262
|
}
|
|
238
263
|
isSet() {
|
|
@@ -300,21 +325,12 @@ var chunkArray = (array, size) => {
|
|
|
300
325
|
|
|
301
326
|
// src/circular-buffer.ts
|
|
302
327
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
303
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/util/src/circular-buffer.ts";
|
|
304
328
|
var CircularBuffer = class {
|
|
305
329
|
_buffer;
|
|
306
330
|
_nextIndex = 0;
|
|
307
331
|
_elementCount = 0;
|
|
308
332
|
constructor(size) {
|
|
309
|
-
invariant3(size >= 1
|
|
310
|
-
F: __dxlog_file3,
|
|
311
|
-
L: 13,
|
|
312
|
-
S: this,
|
|
313
|
-
A: [
|
|
314
|
-
"size >= 1",
|
|
315
|
-
""
|
|
316
|
-
]
|
|
317
|
-
});
|
|
333
|
+
invariant3(size >= 1);
|
|
318
334
|
this._buffer = new Array(size);
|
|
319
335
|
}
|
|
320
336
|
push(element) {
|
|
@@ -327,6 +343,10 @@ var CircularBuffer = class {
|
|
|
327
343
|
get elementCount() {
|
|
328
344
|
return this._elementCount;
|
|
329
345
|
}
|
|
346
|
+
clear() {
|
|
347
|
+
this._nextIndex = 0;
|
|
348
|
+
this._elementCount = 0;
|
|
349
|
+
}
|
|
330
350
|
getLast() {
|
|
331
351
|
if (this._elementCount === 0) {
|
|
332
352
|
return void 0;
|
|
@@ -520,6 +540,36 @@ var ComplexMap = class _ComplexMap {
|
|
|
520
540
|
this._values.set(primitive, value);
|
|
521
541
|
return this;
|
|
522
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Returns the value for the given key if present, otherwise inserts and returns the default value.
|
|
545
|
+
* @param key - The key to look up or insert.
|
|
546
|
+
* @param defaultValue - The value to insert if the key is not present.
|
|
547
|
+
* @returns The existing or newly inserted value.
|
|
548
|
+
*/
|
|
549
|
+
getOrInsert(key, defaultValue) {
|
|
550
|
+
const primitive = this._keyProjection(key);
|
|
551
|
+
if (this._values.has(primitive)) {
|
|
552
|
+
return this._values.get(primitive);
|
|
553
|
+
}
|
|
554
|
+
this.set(key, defaultValue);
|
|
555
|
+
return defaultValue;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Returns the value for the given key if present, otherwise computes, inserts, and returns a new value.
|
|
559
|
+
* The callback is only invoked when the key is missing.
|
|
560
|
+
* @param key - The key to look up or insert.
|
|
561
|
+
* @param callbackfn - Function to compute the value if the key is not present.
|
|
562
|
+
* @returns The existing or newly computed value.
|
|
563
|
+
*/
|
|
564
|
+
getOrInsertComputed(key, callbackfn) {
|
|
565
|
+
const primitive = this._keyProjection(key);
|
|
566
|
+
if (this._values.has(primitive)) {
|
|
567
|
+
return this._values.get(primitive);
|
|
568
|
+
}
|
|
569
|
+
const value = callbackfn(key);
|
|
570
|
+
this.set(key, value);
|
|
571
|
+
return value;
|
|
572
|
+
}
|
|
523
573
|
get size() {
|
|
524
574
|
return this._keys.size;
|
|
525
575
|
}
|
|
@@ -559,21 +609,15 @@ var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
|
|
|
559
609
|
}
|
|
560
610
|
};
|
|
561
611
|
|
|
612
|
+
// src/composite-key.ts
|
|
613
|
+
var SEPARATOR = ":";
|
|
614
|
+
var compositeKey = (...parts) => parts.join(SEPARATOR);
|
|
615
|
+
var splitCompositeKey = (key) => key.split(SEPARATOR);
|
|
616
|
+
|
|
562
617
|
// src/deep.ts
|
|
563
|
-
import get from "lodash.get";
|
|
564
|
-
import set from "lodash.set";
|
|
565
618
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
566
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/common/util/src/deep.ts";
|
|
567
619
|
var setDeep = (obj, path, value) => {
|
|
568
|
-
invariant4(path.length > 0
|
|
569
|
-
F: __dxlog_file4,
|
|
570
|
-
L: 18,
|
|
571
|
-
S: void 0,
|
|
572
|
-
A: [
|
|
573
|
-
"path.length > 0",
|
|
574
|
-
""
|
|
575
|
-
]
|
|
576
|
-
});
|
|
620
|
+
invariant4(path.length > 0);
|
|
577
621
|
let parent = obj;
|
|
578
622
|
for (const key of path.slice(0, -1)) {
|
|
579
623
|
if (parent[key] === void 0) {
|
|
@@ -597,6 +641,7 @@ var getDeep = (obj, path) => {
|
|
|
597
641
|
var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
|
|
598
642
|
|
|
599
643
|
// src/defer.ts
|
|
644
|
+
import "@hazae41/symbol-dispose-polyfill";
|
|
600
645
|
var defer = (fn) => new DeferGuard(fn);
|
|
601
646
|
var DeferGuard = class {
|
|
602
647
|
_fn;
|
|
@@ -657,6 +702,29 @@ var MapEntry = class {
|
|
|
657
702
|
}
|
|
658
703
|
};
|
|
659
704
|
|
|
705
|
+
// src/error-format.ts
|
|
706
|
+
var formatErrorWithCauses = (error) => {
|
|
707
|
+
const lines = [];
|
|
708
|
+
let current = error;
|
|
709
|
+
let level = 0;
|
|
710
|
+
while (current) {
|
|
711
|
+
const prefix = level === 0 ? "" : `Caused by: `;
|
|
712
|
+
lines.push(prefix + (current.stack ?? String(current)));
|
|
713
|
+
if (!(current.cause instanceof Error)) {
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
current = current.cause;
|
|
717
|
+
level += 1;
|
|
718
|
+
}
|
|
719
|
+
return lines.join("\n\n");
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
// src/filename.ts
|
|
723
|
+
var createFilename = ({ parts = [], ext, date = /* @__PURE__ */ new Date() }) => [
|
|
724
|
+
date.toISOString().replace(/[:.]/g, "-"),
|
|
725
|
+
...parts
|
|
726
|
+
].join("_") + (ext ? `.${ext}` : "");
|
|
727
|
+
|
|
660
728
|
// src/for-each-async.ts
|
|
661
729
|
var forEachAsync = (items, fn) => Promise.all(items.map(fn));
|
|
662
730
|
|
|
@@ -992,6 +1060,19 @@ var humanize = (value) => {
|
|
|
992
1060
|
return hasher.humanize(value);
|
|
993
1061
|
};
|
|
994
1062
|
|
|
1063
|
+
// src/id.ts
|
|
1064
|
+
var PART = /^[a-zA-Z][a-zA-Z0-9]{0,62}$/;
|
|
1065
|
+
var ID = /^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)$/;
|
|
1066
|
+
function id(strings, ...values) {
|
|
1067
|
+
const raw = strings.reduce((out, str, i) => out + str + (i < values.length ? String(values[i]) : ""), "");
|
|
1068
|
+
if (!ID.test(raw)) {
|
|
1069
|
+
throw new Error(`Invalid id (expected AT Protocol NSID): ${JSON.stringify(raw)}`);
|
|
1070
|
+
}
|
|
1071
|
+
return raw;
|
|
1072
|
+
}
|
|
1073
|
+
var isWellFormedId = (value) => ID.test(value);
|
|
1074
|
+
var isWellFormedIdPart = (value) => PART.test(value);
|
|
1075
|
+
|
|
995
1076
|
// src/map.ts
|
|
996
1077
|
var defaultMap = (map, key, def) => {
|
|
997
1078
|
let value = map.get(key);
|
|
@@ -1003,7 +1084,7 @@ var defaultMap = (map, key, def) => {
|
|
|
1003
1084
|
};
|
|
1004
1085
|
|
|
1005
1086
|
// src/instance-id.ts
|
|
1006
|
-
var symbol = Symbol.for("dxos.instance-contexts");
|
|
1087
|
+
var symbol = /* @__PURE__ */ Symbol.for("dxos.instance-contexts");
|
|
1007
1088
|
var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
|
|
1008
1089
|
var getPrototypeSpecificInstanceId = (instance) => {
|
|
1009
1090
|
const prototype = Object.getPrototypeOf(instance);
|
|
@@ -1011,12 +1092,12 @@ var getPrototypeSpecificInstanceId = (instance) => {
|
|
|
1011
1092
|
nextId: 0,
|
|
1012
1093
|
instanceIds: /* @__PURE__ */ new WeakMap()
|
|
1013
1094
|
}));
|
|
1014
|
-
let
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1017
|
-
instanceCtx.instanceIds.set(instance,
|
|
1095
|
+
let id2 = instanceCtx.instanceIds.get(instance);
|
|
1096
|
+
if (id2 === void 0) {
|
|
1097
|
+
id2 = instanceCtx.nextId++;
|
|
1098
|
+
instanceCtx.instanceIds.set(instance, id2);
|
|
1018
1099
|
}
|
|
1019
|
-
return
|
|
1100
|
+
return id2;
|
|
1020
1101
|
};
|
|
1021
1102
|
var getDebugName = (instance) => {
|
|
1022
1103
|
if (instance == null) {
|
|
@@ -1297,27 +1378,27 @@ var orderKeys = (obj, order) => {
|
|
|
1297
1378
|
|
|
1298
1379
|
// src/order.ts
|
|
1299
1380
|
var inferObjectOrder = (objectMap, order = []) => {
|
|
1300
|
-
const orderedObjects = order.reduce((acc,
|
|
1301
|
-
if (
|
|
1302
|
-
acc.objects.push(objectMap[
|
|
1303
|
-
acc.ids.add(
|
|
1381
|
+
const orderedObjects = order.reduce((acc, id2) => {
|
|
1382
|
+
if (id2 in objectMap) {
|
|
1383
|
+
acc.objects.push(objectMap[id2]);
|
|
1384
|
+
acc.ids.add(id2);
|
|
1304
1385
|
}
|
|
1305
1386
|
return acc;
|
|
1306
1387
|
}, {
|
|
1307
1388
|
objects: [],
|
|
1308
1389
|
ids: /* @__PURE__ */ new Set()
|
|
1309
1390
|
});
|
|
1310
|
-
const { objects } = Object.keys(objectMap).reduce((acc,
|
|
1311
|
-
if (!acc.ids.has(
|
|
1312
|
-
acc.objects.push(objectMap[
|
|
1391
|
+
const { objects } = Object.keys(objectMap).reduce((acc, id2) => {
|
|
1392
|
+
if (!acc.ids.has(id2)) {
|
|
1393
|
+
acc.objects.push(objectMap[id2]);
|
|
1313
1394
|
}
|
|
1314
1395
|
return acc;
|
|
1315
1396
|
}, orderedObjects);
|
|
1316
1397
|
return objects;
|
|
1317
1398
|
};
|
|
1318
1399
|
var inferRecordOrder = (objectMap, order = []) => {
|
|
1319
|
-
return Object.assign(order.filter((
|
|
1320
|
-
acc[
|
|
1400
|
+
return Object.assign(order.filter((id2) => id2 in objectMap).reduce((acc, id2) => {
|
|
1401
|
+
acc[id2] = null;
|
|
1321
1402
|
return acc;
|
|
1322
1403
|
}, {}), objectMap);
|
|
1323
1404
|
};
|
|
@@ -1352,7 +1433,18 @@ var omit = (obj, keys2) => {
|
|
|
1352
1433
|
|
|
1353
1434
|
// src/platform.ts
|
|
1354
1435
|
var isNode = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
1355
|
-
var
|
|
1436
|
+
var isBun = () => globalThis.Bun !== void 0;
|
|
1437
|
+
var isTauri = () => !!globalThis.__TAURI__;
|
|
1438
|
+
var isMobile = () => {
|
|
1439
|
+
let check = false;
|
|
1440
|
+
(function(a) {
|
|
1441
|
+
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))) {
|
|
1442
|
+
check = true;
|
|
1443
|
+
}
|
|
1444
|
+
})(navigator.userAgent || navigator.vendor || window.opera);
|
|
1445
|
+
return check;
|
|
1446
|
+
};
|
|
1447
|
+
var isMobileOrTablet = () => {
|
|
1356
1448
|
let check = false;
|
|
1357
1449
|
((a) => {
|
|
1358
1450
|
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 +1466,7 @@ var iosCheck = () => {
|
|
|
1374
1466
|
};
|
|
1375
1467
|
var safariCheck = () => typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1376
1468
|
var getHostPlatform = () => {
|
|
1377
|
-
if (!("navigator" in
|
|
1469
|
+
if (!("navigator" in globalThis)) {
|
|
1378
1470
|
return "unknown";
|
|
1379
1471
|
}
|
|
1380
1472
|
const platform = (navigator.userAgentData?.platform || navigator.platform)?.toLowerCase();
|
|
@@ -1550,6 +1642,43 @@ var removeProperties = (root, condition) => {
|
|
|
1550
1642
|
return result;
|
|
1551
1643
|
};
|
|
1552
1644
|
|
|
1645
|
+
// src/retry.ts
|
|
1646
|
+
var DEFAULT_RETRY_OPTIONS = {
|
|
1647
|
+
count: 3,
|
|
1648
|
+
delayMs: 100,
|
|
1649
|
+
exponent: 2,
|
|
1650
|
+
retryOnError: async () => true,
|
|
1651
|
+
retryOnValue: async () => false
|
|
1652
|
+
};
|
|
1653
|
+
var retry = async (options, cb) => {
|
|
1654
|
+
const fullOptions = {
|
|
1655
|
+
...DEFAULT_RETRY_OPTIONS,
|
|
1656
|
+
...options
|
|
1657
|
+
};
|
|
1658
|
+
let numRetries = 0, currentDelay = fullOptions.delayMs;
|
|
1659
|
+
while (true) {
|
|
1660
|
+
let result;
|
|
1661
|
+
try {
|
|
1662
|
+
result = await cb();
|
|
1663
|
+
} catch (err) {
|
|
1664
|
+
if (numRetries > fullOptions.count || !await fullOptions.retryOnError(err)) {
|
|
1665
|
+
throw err;
|
|
1666
|
+
}
|
|
1667
|
+
await new Promise((resolve) => setTimeout(resolve, currentDelay));
|
|
1668
|
+
currentDelay *= fullOptions.exponent;
|
|
1669
|
+
numRetries++;
|
|
1670
|
+
continue;
|
|
1671
|
+
}
|
|
1672
|
+
if (!await fullOptions.retryOnValue(result)) {
|
|
1673
|
+
return result;
|
|
1674
|
+
}
|
|
1675
|
+
await new Promise((resolve) => setTimeout(resolve, currentDelay));
|
|
1676
|
+
currentDelay *= fullOptions.exponent;
|
|
1677
|
+
numRetries++;
|
|
1678
|
+
continue;
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
|
|
1553
1682
|
// src/safe-await.ts
|
|
1554
1683
|
var safeAwaitAll = async (source, taskFactory, onError) => {
|
|
1555
1684
|
const failedItems = [];
|
|
@@ -1569,7 +1698,7 @@ var safeAwaitAll = async (source, taskFactory, onError) => {
|
|
|
1569
1698
|
};
|
|
1570
1699
|
|
|
1571
1700
|
// src/safe-instanceof.ts
|
|
1572
|
-
var instanceTag = Symbol("instanceTag");
|
|
1701
|
+
var instanceTag = /* @__PURE__ */ Symbol("instanceTag");
|
|
1573
1702
|
var safeInstanceof = (tag) => (target) => {
|
|
1574
1703
|
target.prototype[instanceTag] = tag;
|
|
1575
1704
|
Object.defineProperty(target.prototype, Symbol.hasInstance, {
|
|
@@ -1581,57 +1710,88 @@ var safeInstanceof = (tag) => (target) => {
|
|
|
1581
1710
|
};
|
|
1582
1711
|
|
|
1583
1712
|
// src/safe-parse.ts
|
|
1584
|
-
|
|
1713
|
+
function safeParseInt(str, defaultValue) {
|
|
1585
1714
|
try {
|
|
1586
|
-
const
|
|
1587
|
-
return isNaN(
|
|
1715
|
+
const value = parseInt(str ?? "");
|
|
1716
|
+
return isNaN(value) ? defaultValue : value;
|
|
1588
1717
|
} catch {
|
|
1589
1718
|
return defaultValue;
|
|
1590
1719
|
}
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1720
|
+
}
|
|
1721
|
+
function safeParseFloat(str, defaultValue) {
|
|
1593
1722
|
try {
|
|
1594
|
-
|
|
1723
|
+
const value = parseFloat(str ?? "");
|
|
1724
|
+
return isNaN(value) ? defaultValue : value;
|
|
1595
1725
|
} catch {
|
|
1596
|
-
return defaultValue
|
|
1726
|
+
return defaultValue;
|
|
1597
1727
|
}
|
|
1598
|
-
}
|
|
1599
|
-
var safeParseJson = (
|
|
1600
|
-
if (
|
|
1728
|
+
}
|
|
1729
|
+
var safeParseJson = (str, defaultValue) => {
|
|
1730
|
+
if (str && str.length > 0) {
|
|
1601
1731
|
try {
|
|
1602
|
-
return JSON.parse(
|
|
1732
|
+
return JSON.parse(str);
|
|
1603
1733
|
} catch {
|
|
1604
1734
|
}
|
|
1605
1735
|
}
|
|
1606
1736
|
return defaultValue;
|
|
1607
1737
|
};
|
|
1738
|
+
var safeUrl = (str) => {
|
|
1739
|
+
try {
|
|
1740
|
+
return new URL(str ?? "");
|
|
1741
|
+
} catch {
|
|
1742
|
+
return void 0;
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1608
1745
|
|
|
1609
1746
|
// src/safe-stringify.ts
|
|
1610
1747
|
var SKIP = Object.freeze({});
|
|
1611
1748
|
function safeStringify(obj, filter = defaultFilter, indent = 2) {
|
|
1612
|
-
const seen = /* @__PURE__ */ new
|
|
1749
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
1613
1750
|
function replacer(key, value) {
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1751
|
+
try {
|
|
1752
|
+
let path = key;
|
|
1753
|
+
if (!key) {
|
|
1754
|
+
path = "$";
|
|
1755
|
+
if (value != null && typeof value === "object") {
|
|
1756
|
+
seen.set(value, path);
|
|
1757
|
+
}
|
|
1758
|
+
return value;
|
|
1759
|
+
} else if (this) {
|
|
1760
|
+
const parentPath = seen.get(this);
|
|
1761
|
+
path = parentPath ? `${parentPath}.${key}` : key;
|
|
1617
1762
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1763
|
+
if (value == null) {
|
|
1764
|
+
return value;
|
|
1765
|
+
}
|
|
1766
|
+
if (typeof value === "function") {
|
|
1767
|
+
return void 0;
|
|
1768
|
+
}
|
|
1769
|
+
if (typeof value === "object" && Object.getPrototypeOf(value) !== Object.prototype && !Array.isArray(value)) {
|
|
1770
|
+
return void 0;
|
|
1771
|
+
}
|
|
1772
|
+
if (typeof value === "object" && value !== null) {
|
|
1773
|
+
const exists = seen.get(value);
|
|
1774
|
+
if (exists) {
|
|
1775
|
+
return `[${path} => ${exists}]`;
|
|
1776
|
+
}
|
|
1777
|
+
seen.set(value, path);
|
|
1624
1778
|
}
|
|
1779
|
+
if (filter) {
|
|
1780
|
+
const filteredValue = filter?.(key, value);
|
|
1781
|
+
if (filteredValue !== void 0) {
|
|
1782
|
+
return filteredValue === SKIP ? void 0 : filteredValue;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
return value;
|
|
1786
|
+
} catch (error) {
|
|
1787
|
+
return `ERROR: ${error.message}`;
|
|
1625
1788
|
}
|
|
1626
|
-
return value;
|
|
1627
1789
|
}
|
|
1628
|
-
let result = "";
|
|
1629
1790
|
try {
|
|
1630
|
-
|
|
1791
|
+
return JSON.stringify(obj, replacer, indent);
|
|
1631
1792
|
} catch (error) {
|
|
1632
|
-
|
|
1793
|
+
return `ERROR: ${error.message}`;
|
|
1633
1794
|
}
|
|
1634
|
-
return result;
|
|
1635
1795
|
}
|
|
1636
1796
|
var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen } = {}) => {
|
|
1637
1797
|
let currentDepth = 0;
|
|
@@ -1644,7 +1804,10 @@ var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen
|
|
|
1644
1804
|
currentDepth = parentDepth + 1;
|
|
1645
1805
|
}
|
|
1646
1806
|
if (typeof value === "function") {
|
|
1647
|
-
return
|
|
1807
|
+
return SKIP;
|
|
1808
|
+
}
|
|
1809
|
+
if (maxArrayLen != null && Array.isArray(value) && value.length > maxArrayLen) {
|
|
1810
|
+
return `[length: ${value.length}]`;
|
|
1648
1811
|
}
|
|
1649
1812
|
if (value && typeof value === "object") {
|
|
1650
1813
|
depthMap.set(value, currentDepth);
|
|
@@ -1653,7 +1816,7 @@ var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen
|
|
|
1653
1816
|
}
|
|
1654
1817
|
}
|
|
1655
1818
|
if (omit2?.includes(key)) {
|
|
1656
|
-
return
|
|
1819
|
+
return SKIP;
|
|
1657
1820
|
}
|
|
1658
1821
|
if (parse?.includes(key) && typeof value === "string") {
|
|
1659
1822
|
try {
|
|
@@ -1662,9 +1825,6 @@ var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen
|
|
|
1662
1825
|
return value;
|
|
1663
1826
|
}
|
|
1664
1827
|
}
|
|
1665
|
-
if (maxArrayLen != null && Array.isArray(value) && value.length > maxArrayLen) {
|
|
1666
|
-
return `[length: ${value.length}]`;
|
|
1667
|
-
}
|
|
1668
1828
|
if (maxStringLen != null && typeof value === "string" && value.length > maxStringLen) {
|
|
1669
1829
|
return value.slice(0, maxStringLen) + "...";
|
|
1670
1830
|
}
|
|
@@ -1675,7 +1835,6 @@ var defaultFilter = createReplacer();
|
|
|
1675
1835
|
|
|
1676
1836
|
// src/sliding-window-summary.ts
|
|
1677
1837
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1678
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
|
|
1679
1838
|
var SlidingWindowSummary = class {
|
|
1680
1839
|
_buffer;
|
|
1681
1840
|
_sum = 0;
|
|
@@ -1683,15 +1842,7 @@ var SlidingWindowSummary = class {
|
|
|
1683
1842
|
constructor(options) {
|
|
1684
1843
|
this._buffer = new CircularBuffer(options.dataPoints);
|
|
1685
1844
|
if (options.precision != null) {
|
|
1686
|
-
invariant5(options.precision >= 0
|
|
1687
|
-
F: __dxlog_file5,
|
|
1688
|
-
L: 26,
|
|
1689
|
-
S: this,
|
|
1690
|
-
A: [
|
|
1691
|
-
"options.precision >= 0",
|
|
1692
|
-
""
|
|
1693
|
-
]
|
|
1694
|
-
});
|
|
1845
|
+
invariant5(options.precision >= 0);
|
|
1695
1846
|
this._precision = Math.pow(10, options.precision);
|
|
1696
1847
|
}
|
|
1697
1848
|
}
|
|
@@ -1772,8 +1923,12 @@ function trim(strings, ...values) {
|
|
|
1772
1923
|
return out;
|
|
1773
1924
|
}, "");
|
|
1774
1925
|
const lines = raw.split("\n");
|
|
1775
|
-
while (lines.length && !lines[0].trim())
|
|
1776
|
-
|
|
1926
|
+
while (lines.length && !lines[0].trim()) {
|
|
1927
|
+
lines.shift();
|
|
1928
|
+
}
|
|
1929
|
+
while (lines.length && !lines[lines.length - 1].trim()) {
|
|
1930
|
+
lines.pop();
|
|
1931
|
+
}
|
|
1777
1932
|
const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
|
|
1778
1933
|
return lines.map((l) => l.slice(minIndent)).join("\n");
|
|
1779
1934
|
}
|
|
@@ -1791,18 +1946,6 @@ var throwUnhandledError = (error) => {
|
|
|
1791
1946
|
|
|
1792
1947
|
// src/to-fallback.ts
|
|
1793
1948
|
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
1949
|
"\u{1F47B}",
|
|
1807
1950
|
"\u{1F479}",
|
|
1808
1951
|
"\u{1F47D}",
|
|
@@ -1938,17 +2081,18 @@ var idEmoji = [
|
|
|
1938
2081
|
];
|
|
1939
2082
|
var idHue = [
|
|
1940
2083
|
"red",
|
|
1941
|
-
|
|
2084
|
+
"orange",
|
|
1942
2085
|
"amber",
|
|
1943
|
-
|
|
2086
|
+
"yellow",
|
|
1944
2087
|
"lime",
|
|
1945
2088
|
"green",
|
|
1946
2089
|
"emerald",
|
|
1947
2090
|
"teal",
|
|
1948
2091
|
"cyan",
|
|
1949
|
-
//
|
|
1950
|
-
// '
|
|
1951
|
-
// '
|
|
2092
|
+
// Omit colors similar to primary accent.
|
|
2093
|
+
// 'sky' as const,
|
|
2094
|
+
// 'blue' as const,
|
|
2095
|
+
// 'indigo' as const,
|
|
1952
2096
|
"violet",
|
|
1953
2097
|
"purple",
|
|
1954
2098
|
"fuchsia",
|
|
@@ -1987,8 +2131,8 @@ var Tracer = class {
|
|
|
1987
2131
|
keys() {
|
|
1988
2132
|
return Array.from(this._events.keys());
|
|
1989
2133
|
}
|
|
1990
|
-
get(
|
|
1991
|
-
const events = this._events.get(
|
|
2134
|
+
get(id2, filter) {
|
|
2135
|
+
const events = this._events.get(id2);
|
|
1992
2136
|
if (filter) {
|
|
1993
2137
|
return events?.filter((event) => Object.entries(filter).every(([key, value]) => event?.value[key] === value));
|
|
1994
2138
|
}
|
|
@@ -2005,11 +2149,11 @@ var Tracer = class {
|
|
|
2005
2149
|
this._recording = false;
|
|
2006
2150
|
return this;
|
|
2007
2151
|
}
|
|
2008
|
-
emit(
|
|
2009
|
-
this._post(this._createEvent(
|
|
2152
|
+
emit(id2, value) {
|
|
2153
|
+
this._post(this._createEvent(id2, value));
|
|
2010
2154
|
}
|
|
2011
|
-
mark(
|
|
2012
|
-
const event = this._createEvent(
|
|
2155
|
+
mark(id2, value) {
|
|
2156
|
+
const event = this._createEvent(id2, value);
|
|
2013
2157
|
const start = performance.now();
|
|
2014
2158
|
return {
|
|
2015
2159
|
start,
|
|
@@ -2019,9 +2163,9 @@ var Tracer = class {
|
|
|
2019
2163
|
}
|
|
2020
2164
|
};
|
|
2021
2165
|
}
|
|
2022
|
-
_createEvent(
|
|
2166
|
+
_createEvent(id2, value) {
|
|
2023
2167
|
const event = {
|
|
2024
|
-
id,
|
|
2168
|
+
id: id2,
|
|
2025
2169
|
timestamp: Date.now()
|
|
2026
2170
|
};
|
|
2027
2171
|
if (value !== void 0) {
|
|
@@ -2108,16 +2252,26 @@ var arrayMove = (array, from, to) => {
|
|
|
2108
2252
|
array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
|
|
2109
2253
|
return array;
|
|
2110
2254
|
};
|
|
2255
|
+
function arraySwap(array, from, to) {
|
|
2256
|
+
const current = array[from];
|
|
2257
|
+
array[from] = array[to];
|
|
2258
|
+
array[to] = current;
|
|
2259
|
+
return array;
|
|
2260
|
+
}
|
|
2111
2261
|
|
|
2112
2262
|
// src/unit.ts
|
|
2113
2263
|
var createFormat = (unit) => {
|
|
2114
2264
|
return (n, precision = unit.precision ?? 0) => {
|
|
2115
2265
|
const value = n / unit.quotient;
|
|
2266
|
+
const formattedValue = value.toLocaleString("en-US", {
|
|
2267
|
+
minimumFractionDigits: precision,
|
|
2268
|
+
maximumFractionDigits: precision
|
|
2269
|
+
});
|
|
2116
2270
|
return {
|
|
2117
2271
|
unit,
|
|
2118
2272
|
value,
|
|
2119
|
-
formattedValue
|
|
2120
|
-
toString: () => `${
|
|
2273
|
+
formattedValue,
|
|
2274
|
+
toString: () => `${formattedValue}${unit.symbol}`
|
|
2121
2275
|
};
|
|
2122
2276
|
};
|
|
2123
2277
|
};
|
|
@@ -2152,6 +2306,10 @@ var Unit = {
|
|
|
2152
2306
|
quotient: 1e3,
|
|
2153
2307
|
precision: 2
|
|
2154
2308
|
}),
|
|
2309
|
+
Byte: createFormat({
|
|
2310
|
+
symbol: "B",
|
|
2311
|
+
quotient: 1
|
|
2312
|
+
}),
|
|
2155
2313
|
// Time.
|
|
2156
2314
|
Hour: createFormat({
|
|
2157
2315
|
symbol: "h",
|
|
@@ -2218,15 +2376,19 @@ var createUrl = (url, search) => {
|
|
|
2218
2376
|
// src/weak.ts
|
|
2219
2377
|
var WeakDictionary = class {
|
|
2220
2378
|
_internal = /* @__PURE__ */ new Map();
|
|
2221
|
-
_finalization = new FinalizationRegistry((
|
|
2222
|
-
|
|
2379
|
+
_finalization = new FinalizationRegistry(({ key, ref }) => {
|
|
2380
|
+
if (this._internal.get(key) === ref) {
|
|
2381
|
+
this._internal.delete(key);
|
|
2382
|
+
}
|
|
2223
2383
|
});
|
|
2224
2384
|
constructor(entries2) {
|
|
2225
|
-
|
|
2226
|
-
key,
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2385
|
+
if (entries2) {
|
|
2386
|
+
for (const [key, value] of entries2) {
|
|
2387
|
+
const ref = new WeakRef(value);
|
|
2388
|
+
this._internal.set(key, ref);
|
|
2389
|
+
this._register(key, value, ref);
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2230
2392
|
}
|
|
2231
2393
|
*entries() {
|
|
2232
2394
|
for (const [key, value] of this._internal) {
|
|
@@ -2266,10 +2428,45 @@ var WeakDictionary = class {
|
|
|
2266
2428
|
return this._internal.get(key)?.deref();
|
|
2267
2429
|
}
|
|
2268
2430
|
set(key, value) {
|
|
2269
|
-
this._internal.
|
|
2270
|
-
|
|
2431
|
+
const previous = this._internal.get(key)?.deref();
|
|
2432
|
+
if (previous) {
|
|
2433
|
+
this._unregister(previous);
|
|
2434
|
+
}
|
|
2435
|
+
const ref = new WeakRef(value);
|
|
2436
|
+
this._internal.set(key, ref);
|
|
2437
|
+
this._register(key, value, ref);
|
|
2271
2438
|
return this;
|
|
2272
2439
|
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Returns the value for the given key if present, otherwise inserts and returns the default value.
|
|
2442
|
+
* @param key - The key to look up or insert.
|
|
2443
|
+
* @param defaultValue - The value to insert if the key is not present.
|
|
2444
|
+
* @returns The existing or newly inserted value.
|
|
2445
|
+
*/
|
|
2446
|
+
getOrInsert(key, defaultValue) {
|
|
2447
|
+
const existing = this.get(key);
|
|
2448
|
+
if (existing !== void 0) {
|
|
2449
|
+
return existing;
|
|
2450
|
+
}
|
|
2451
|
+
this.set(key, defaultValue);
|
|
2452
|
+
return defaultValue;
|
|
2453
|
+
}
|
|
2454
|
+
/**
|
|
2455
|
+
* Returns the value for the given key if present, otherwise computes, inserts, and returns a new value.
|
|
2456
|
+
* The callback is only invoked when the key is missing.
|
|
2457
|
+
* @param key - The key to look up or insert.
|
|
2458
|
+
* @param callbackfn - Function to compute the value if the key is not present.
|
|
2459
|
+
* @returns The existing or newly computed value.
|
|
2460
|
+
*/
|
|
2461
|
+
getOrInsertComputed(key, callbackfn) {
|
|
2462
|
+
const existing = this.get(key);
|
|
2463
|
+
if (existing !== void 0) {
|
|
2464
|
+
return existing;
|
|
2465
|
+
}
|
|
2466
|
+
const value = callbackfn(key);
|
|
2467
|
+
this.set(key, value);
|
|
2468
|
+
return value;
|
|
2469
|
+
}
|
|
2273
2470
|
has(key) {
|
|
2274
2471
|
return this._internal.has(key) && this._internal.get(key).deref() !== void 0;
|
|
2275
2472
|
}
|
|
@@ -2300,9 +2497,10 @@ var WeakDictionary = class {
|
|
|
2300
2497
|
}
|
|
2301
2498
|
});
|
|
2302
2499
|
}
|
|
2303
|
-
_register(key, value) {
|
|
2304
|
-
this._finalization.register(value,
|
|
2305
|
-
|
|
2500
|
+
_register(key, value, ref) {
|
|
2501
|
+
this._finalization.register(value, {
|
|
2502
|
+
key,
|
|
2503
|
+
ref
|
|
2306
2504
|
}, value);
|
|
2307
2505
|
}
|
|
2308
2506
|
_unregister(value) {
|
|
@@ -2325,6 +2523,7 @@ export {
|
|
|
2325
2523
|
WeakDictionary,
|
|
2326
2524
|
accessBy,
|
|
2327
2525
|
arrayMove,
|
|
2526
|
+
arraySwap,
|
|
2328
2527
|
arrayToBuffer,
|
|
2329
2528
|
arrayToHex,
|
|
2330
2529
|
arrayToString,
|
|
@@ -2335,13 +2534,20 @@ export {
|
|
|
2335
2534
|
capitalize,
|
|
2336
2535
|
chunkArray,
|
|
2337
2536
|
clamp,
|
|
2537
|
+
clearCaches,
|
|
2538
|
+
clearIndexedDB,
|
|
2539
|
+
clearOPFS,
|
|
2540
|
+
clearServiceWorkers,
|
|
2338
2541
|
clearUndefined,
|
|
2542
|
+
coerceArray,
|
|
2339
2543
|
compareMulti,
|
|
2340
2544
|
compareObject,
|
|
2341
2545
|
compareScalar,
|
|
2342
2546
|
compareString,
|
|
2547
|
+
compositeKey,
|
|
2343
2548
|
createBinder,
|
|
2344
2549
|
createBucketReducer,
|
|
2550
|
+
createFilename,
|
|
2345
2551
|
createGroupReducer,
|
|
2346
2552
|
createReplacer,
|
|
2347
2553
|
createSetDispatch,
|
|
@@ -2361,7 +2567,7 @@ export {
|
|
|
2361
2567
|
entry,
|
|
2362
2568
|
exponentialBackoffInterval,
|
|
2363
2569
|
forEachAsync,
|
|
2364
|
-
|
|
2570
|
+
formatErrorWithCauses,
|
|
2365
2571
|
getAsyncProviderValue,
|
|
2366
2572
|
getDate,
|
|
2367
2573
|
getDebugName,
|
|
@@ -2374,6 +2580,7 @@ export {
|
|
|
2374
2580
|
hexToHue,
|
|
2375
2581
|
humanize,
|
|
2376
2582
|
hyphenize,
|
|
2583
|
+
id,
|
|
2377
2584
|
idEmoji,
|
|
2378
2585
|
idHue,
|
|
2379
2586
|
inferObjectOrder,
|
|
@@ -2381,9 +2588,15 @@ export {
|
|
|
2381
2588
|
intersectBy,
|
|
2382
2589
|
intersection,
|
|
2383
2590
|
iosCheck,
|
|
2591
|
+
isBun,
|
|
2592
|
+
isMobile,
|
|
2593
|
+
isMobileOrTablet,
|
|
2384
2594
|
isNode,
|
|
2385
2595
|
isNonNullable,
|
|
2596
|
+
isTauri,
|
|
2386
2597
|
isTruthy,
|
|
2598
|
+
isWellFormedId,
|
|
2599
|
+
isWellFormedIdPart,
|
|
2387
2600
|
joinTables,
|
|
2388
2601
|
jsonKeyReplacer,
|
|
2389
2602
|
jsonReplacer,
|
|
@@ -2398,7 +2611,6 @@ export {
|
|
|
2398
2611
|
makeSet,
|
|
2399
2612
|
mapValues,
|
|
2400
2613
|
median,
|
|
2401
|
-
mobileAndTabletCheck,
|
|
2402
2614
|
numericalValues,
|
|
2403
2615
|
omit,
|
|
2404
2616
|
orderKeys,
|
|
@@ -2414,6 +2626,7 @@ export {
|
|
|
2414
2626
|
removeBy,
|
|
2415
2627
|
removeProperties,
|
|
2416
2628
|
removeUndefinedProperties,
|
|
2629
|
+
retry,
|
|
2417
2630
|
safariCheck,
|
|
2418
2631
|
safeAwaitAll,
|
|
2419
2632
|
safeInstanceof,
|
|
@@ -2421,9 +2634,10 @@ export {
|
|
|
2421
2634
|
safeParseInt,
|
|
2422
2635
|
safeParseJson,
|
|
2423
2636
|
safeStringify,
|
|
2424
|
-
|
|
2637
|
+
safeUrl,
|
|
2425
2638
|
setDeep,
|
|
2426
2639
|
sortKeys,
|
|
2640
|
+
splitCompositeKey,
|
|
2427
2641
|
stringToArray,
|
|
2428
2642
|
stringifyTree,
|
|
2429
2643
|
stripUndefined,
|