@dxos/util 0.8.4-main.ead640a → 0.8.4-main.effb148878
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 +674 -524
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +674 -524
- 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 +7 -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 +5 -5
- 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 +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/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 +12 -0
- 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 +27 -0
- package/dist/types/src/uint8array.d.ts.map +1 -1
- package/dist/types/src/unit.d.ts +12 -13
- 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 +13 -15
- package/src/array.ts +9 -2
- package/src/binder.ts +2 -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 +7 -0
- package/src/map-values.ts +6 -0
- package/src/platform.ts +35 -3
- package/src/position.test.ts +38 -44
- package/src/position.ts +7 -11
- 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 +153 -0
- package/src/string.test.ts +24 -1
- package/src/string.ts +22 -2
- package/src/to-fallback.ts +39 -156
- package/src/types.test.ts +11 -1
- package/src/types.ts +39 -11
- package/src/uint8array.ts +44 -0
- package/src/unit.test.ts +1 -1
- package/src/unit.ts +63 -28
- 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,21 +97,28 @@ 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 "node: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
|
|
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,126 +178,91 @@ var BitField = class _BitField {
|
|
|
179
178
|
}
|
|
180
179
|
};
|
|
181
180
|
|
|
182
|
-
// src/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
+
}
|
|
186
206
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (descriptor.get) {
|
|
190
|
-
return descriptor.get.call(receiver);
|
|
207
|
+
if (errors.length > 0) {
|
|
208
|
+
throw new AggregateError(errors, "Failed to remove some OPFS entries");
|
|
191
209
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
} else {
|
|
198
|
-
if (!descriptor.writable) {
|
|
199
|
-
throw new TypeError("attempted to set read only private field");
|
|
200
|
-
}
|
|
201
|
-
descriptor.value = value;
|
|
210
|
+
};
|
|
211
|
+
var clearServiceWorkers = async () => {
|
|
212
|
+
const regs = await navigator.serviceWorker.getRegistrations();
|
|
213
|
+
for (const reg of regs) {
|
|
214
|
+
await reg.unregister();
|
|
202
215
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
216
|
+
};
|
|
217
|
+
var clearCaches = async () => {
|
|
218
|
+
const keys2 = await caches.keys();
|
|
219
|
+
for (const key of keys2) {
|
|
220
|
+
await caches.delete(key);
|
|
207
221
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
212
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
213
|
-
}
|
|
214
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
215
|
-
_check_private_redeclaration(obj, privateMap);
|
|
216
|
-
privateMap.set(obj, value);
|
|
217
|
-
}
|
|
218
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
219
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
220
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
221
|
-
return value;
|
|
222
|
-
}
|
|
223
|
-
var _callbacks = /* @__PURE__ */ new WeakMap();
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// src/callback-collection.ts
|
|
224
225
|
var CallbackCollection = class {
|
|
226
|
+
#callbacks = [];
|
|
225
227
|
append(callback) {
|
|
226
|
-
|
|
228
|
+
this.#callbacks.push(callback);
|
|
227
229
|
}
|
|
228
230
|
prepend(callback) {
|
|
229
|
-
|
|
231
|
+
this.#callbacks.unshift(callback);
|
|
230
232
|
}
|
|
231
233
|
remove(callback) {
|
|
232
|
-
|
|
234
|
+
this.#callbacks = this.#callbacks.filter((c) => c !== callback);
|
|
233
235
|
}
|
|
234
236
|
callParallel(...args) {
|
|
235
|
-
return Promise.all(
|
|
237
|
+
return Promise.all(this.#callbacks.map((callback) => callback(...args)));
|
|
236
238
|
}
|
|
237
239
|
async callSerial(...args) {
|
|
238
240
|
const results = [];
|
|
239
|
-
for (const callback of
|
|
241
|
+
for (const callback of this.#callbacks) {
|
|
240
242
|
results.push(await callback(...args));
|
|
241
243
|
}
|
|
242
244
|
return results;
|
|
243
245
|
}
|
|
244
|
-
constructor() {
|
|
245
|
-
_class_private_field_init(this, _callbacks, {
|
|
246
|
-
writable: true,
|
|
247
|
-
value: []
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
246
|
};
|
|
251
247
|
|
|
252
248
|
// src/callback.ts
|
|
253
249
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
254
|
-
function _define_property(obj, key, value) {
|
|
255
|
-
if (key in obj) {
|
|
256
|
-
Object.defineProperty(obj, key, {
|
|
257
|
-
value,
|
|
258
|
-
enumerable: true,
|
|
259
|
-
configurable: true,
|
|
260
|
-
writable: true
|
|
261
|
-
});
|
|
262
|
-
} else {
|
|
263
|
-
obj[key] = value;
|
|
264
|
-
}
|
|
265
|
-
return obj;
|
|
266
|
-
}
|
|
267
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/util/src/callback.ts";
|
|
268
250
|
var Callback = class {
|
|
251
|
+
_callback;
|
|
269
252
|
call(...args) {
|
|
270
|
-
invariant2(this._callback, "Callback not set"
|
|
271
|
-
F: __dxlog_file2,
|
|
272
|
-
L: 20,
|
|
273
|
-
S: this,
|
|
274
|
-
A: [
|
|
275
|
-
"this._callback",
|
|
276
|
-
"'Callback not set'"
|
|
277
|
-
]
|
|
278
|
-
});
|
|
253
|
+
invariant2(this._callback, "Callback not set");
|
|
279
254
|
return this._callback(...args);
|
|
280
255
|
}
|
|
281
256
|
callIfSet(...args) {
|
|
282
257
|
return this._callback?.(...args);
|
|
283
258
|
}
|
|
284
259
|
set(callback) {
|
|
285
|
-
invariant2(!this._callback, "Callback already set"
|
|
286
|
-
F: __dxlog_file2,
|
|
287
|
-
L: 29,
|
|
288
|
-
S: this,
|
|
289
|
-
A: [
|
|
290
|
-
"!this._callback",
|
|
291
|
-
"'Callback already set'"
|
|
292
|
-
]
|
|
293
|
-
});
|
|
260
|
+
invariant2(!this._callback, "Callback already set");
|
|
294
261
|
this._callback = callback;
|
|
295
262
|
}
|
|
296
263
|
isSet() {
|
|
297
264
|
return !!this._callback;
|
|
298
265
|
}
|
|
299
|
-
constructor() {
|
|
300
|
-
_define_property(this, "_callback", void 0);
|
|
301
|
-
}
|
|
302
266
|
};
|
|
303
267
|
var createSetDispatch = ({ handlers }) => {
|
|
304
268
|
return new Proxy({
|
|
@@ -361,21 +325,14 @@ var chunkArray = (array, size) => {
|
|
|
361
325
|
|
|
362
326
|
// src/circular-buffer.ts
|
|
363
327
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
364
|
-
function _define_property2(obj, key, value) {
|
|
365
|
-
if (key in obj) {
|
|
366
|
-
Object.defineProperty(obj, key, {
|
|
367
|
-
value,
|
|
368
|
-
enumerable: true,
|
|
369
|
-
configurable: true,
|
|
370
|
-
writable: true
|
|
371
|
-
});
|
|
372
|
-
} else {
|
|
373
|
-
obj[key] = value;
|
|
374
|
-
}
|
|
375
|
-
return obj;
|
|
376
|
-
}
|
|
377
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/util/src/circular-buffer.ts";
|
|
378
328
|
var CircularBuffer = class {
|
|
329
|
+
_buffer;
|
|
330
|
+
_nextIndex = 0;
|
|
331
|
+
_elementCount = 0;
|
|
332
|
+
constructor(size) {
|
|
333
|
+
invariant3(size >= 1);
|
|
334
|
+
this._buffer = new Array(size);
|
|
335
|
+
}
|
|
379
336
|
push(element) {
|
|
380
337
|
const evicted = this._elementCount === this._buffer.length ? this._buffer[this._nextIndex] : void 0;
|
|
381
338
|
this._buffer[this._nextIndex] = element;
|
|
@@ -386,6 +343,10 @@ var CircularBuffer = class {
|
|
|
386
343
|
get elementCount() {
|
|
387
344
|
return this._elementCount;
|
|
388
345
|
}
|
|
346
|
+
clear() {
|
|
347
|
+
this._nextIndex = 0;
|
|
348
|
+
this._elementCount = 0;
|
|
349
|
+
}
|
|
389
350
|
getLast() {
|
|
390
351
|
if (this._elementCount === 0) {
|
|
391
352
|
return void 0;
|
|
@@ -415,21 +376,6 @@ var CircularBuffer = class {
|
|
|
415
376
|
yield this._buffer[i];
|
|
416
377
|
}
|
|
417
378
|
}
|
|
418
|
-
constructor(size) {
|
|
419
|
-
_define_property2(this, "_buffer", void 0);
|
|
420
|
-
_define_property2(this, "_nextIndex", 0);
|
|
421
|
-
_define_property2(this, "_elementCount", 0);
|
|
422
|
-
invariant3(size >= 1, void 0, {
|
|
423
|
-
F: __dxlog_file3,
|
|
424
|
-
L: 13,
|
|
425
|
-
S: this,
|
|
426
|
-
A: [
|
|
427
|
-
"size >= 1",
|
|
428
|
-
""
|
|
429
|
-
]
|
|
430
|
-
});
|
|
431
|
-
this._buffer = new Array(size);
|
|
432
|
-
}
|
|
433
379
|
};
|
|
434
380
|
|
|
435
381
|
// src/clear-undefined.ts
|
|
@@ -448,22 +394,19 @@ var clearUndefined = (obj) => {
|
|
|
448
394
|
// src/complex.ts
|
|
449
395
|
import { inspect } from "node:util";
|
|
450
396
|
import { inspectObject, raise } from "@dxos/debug";
|
|
451
|
-
function _define_property3(obj, key, value) {
|
|
452
|
-
if (key in obj) {
|
|
453
|
-
Object.defineProperty(obj, key, {
|
|
454
|
-
value,
|
|
455
|
-
enumerable: true,
|
|
456
|
-
configurable: true,
|
|
457
|
-
writable: true
|
|
458
|
-
});
|
|
459
|
-
} else {
|
|
460
|
-
obj[key] = value;
|
|
461
|
-
}
|
|
462
|
-
return obj;
|
|
463
|
-
}
|
|
464
397
|
var MAX_SERIALIZATION_LENGTH = 10;
|
|
465
|
-
var _inspect_custom = inspect.custom;
|
|
466
398
|
var ComplexSet = class {
|
|
399
|
+
_projection;
|
|
400
|
+
_values = /* @__PURE__ */ new Map();
|
|
401
|
+
// prettier-ignore
|
|
402
|
+
constructor(_projection, values) {
|
|
403
|
+
this._projection = _projection;
|
|
404
|
+
if (values) {
|
|
405
|
+
for (const value of values) {
|
|
406
|
+
this.add(value);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
467
410
|
toString() {
|
|
468
411
|
return inspectObject(this);
|
|
469
412
|
}
|
|
@@ -472,7 +415,7 @@ var ComplexSet = class {
|
|
|
472
415
|
size: this._values.size
|
|
473
416
|
} : Array.from(this._values.values());
|
|
474
417
|
}
|
|
475
|
-
[
|
|
418
|
+
[inspect.custom]() {
|
|
476
419
|
return inspectObject(this);
|
|
477
420
|
}
|
|
478
421
|
add(value) {
|
|
@@ -538,18 +481,6 @@ var ComplexSet = class {
|
|
|
538
481
|
isDisjointFrom(other) {
|
|
539
482
|
throw new Error("Method not implemented.");
|
|
540
483
|
}
|
|
541
|
-
// prettier-ignore
|
|
542
|
-
constructor(_projection, values) {
|
|
543
|
-
_define_property3(this, "_projection", void 0);
|
|
544
|
-
_define_property3(this, "_values", void 0);
|
|
545
|
-
this._projection = _projection;
|
|
546
|
-
this._values = /* @__PURE__ */ new Map();
|
|
547
|
-
if (values) {
|
|
548
|
-
for (const value of values) {
|
|
549
|
-
this.add(value);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
484
|
};
|
|
554
485
|
var makeSet = (projection) => {
|
|
555
486
|
return class BoundComplexSet extends ComplexSet {
|
|
@@ -558,8 +489,19 @@ var makeSet = (projection) => {
|
|
|
558
489
|
}
|
|
559
490
|
};
|
|
560
491
|
};
|
|
561
|
-
var _inspect_custom1 = inspect.custom;
|
|
562
492
|
var ComplexMap = class _ComplexMap {
|
|
493
|
+
_keyProjection;
|
|
494
|
+
_keys = /* @__PURE__ */ new Map();
|
|
495
|
+
_values = /* @__PURE__ */ new Map();
|
|
496
|
+
// prettier-ignore
|
|
497
|
+
constructor(_keyProjection, entries2) {
|
|
498
|
+
this._keyProjection = _keyProjection;
|
|
499
|
+
if (entries2) {
|
|
500
|
+
for (const [key, value] of entries2) {
|
|
501
|
+
this.set(key, value);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
563
505
|
toString() {
|
|
564
506
|
return inspectObject(this);
|
|
565
507
|
}
|
|
@@ -568,7 +510,7 @@ var ComplexMap = class _ComplexMap {
|
|
|
568
510
|
size: this._values.size
|
|
569
511
|
} : Array.from(this._values.values());
|
|
570
512
|
}
|
|
571
|
-
[
|
|
513
|
+
[inspect.custom]() {
|
|
572
514
|
return inspectObject(this);
|
|
573
515
|
}
|
|
574
516
|
clear() {
|
|
@@ -598,6 +540,36 @@ var ComplexMap = class _ComplexMap {
|
|
|
598
540
|
this._values.set(primitive, value);
|
|
599
541
|
return this;
|
|
600
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
|
+
}
|
|
601
573
|
get size() {
|
|
602
574
|
return this._keys.size;
|
|
603
575
|
}
|
|
@@ -630,45 +602,22 @@ var ComplexMap = class _ComplexMap {
|
|
|
630
602
|
get [Symbol.toStringTag]() {
|
|
631
603
|
return "ComplexMap";
|
|
632
604
|
}
|
|
633
|
-
// prettier-ignore
|
|
634
|
-
constructor(_keyProjection, entries2) {
|
|
635
|
-
_define_property3(this, "_keyProjection", void 0);
|
|
636
|
-
_define_property3(this, "_keys", void 0);
|
|
637
|
-
_define_property3(this, "_values", void 0);
|
|
638
|
-
this._keyProjection = _keyProjection;
|
|
639
|
-
this._keys = /* @__PURE__ */ new Map();
|
|
640
|
-
this._values = /* @__PURE__ */ new Map();
|
|
641
|
-
if (entries2) {
|
|
642
|
-
for (const [key, value] of entries2) {
|
|
643
|
-
this.set(key, value);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
605
|
};
|
|
648
|
-
var makeMap = (keyProjection) => {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
super(keyProjection, entries2);
|
|
652
|
-
}
|
|
606
|
+
var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
|
|
607
|
+
constructor(entries2) {
|
|
608
|
+
super(keyProjection, entries2);
|
|
653
609
|
}
|
|
654
|
-
return BoundComplexMap;
|
|
655
610
|
};
|
|
656
611
|
|
|
612
|
+
// src/composite-key.ts
|
|
613
|
+
var SEPARATOR = ":";
|
|
614
|
+
var compositeKey = (...parts) => parts.join(SEPARATOR);
|
|
615
|
+
var splitCompositeKey = (key) => key.split(SEPARATOR);
|
|
616
|
+
|
|
657
617
|
// src/deep.ts
|
|
658
|
-
import get from "lodash.get";
|
|
659
|
-
import set from "lodash.set";
|
|
660
618
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
661
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/common/util/src/deep.ts";
|
|
662
619
|
var setDeep = (obj, path, value) => {
|
|
663
|
-
invariant4(path.length > 0
|
|
664
|
-
F: __dxlog_file4,
|
|
665
|
-
L: 18,
|
|
666
|
-
S: void 0,
|
|
667
|
-
A: [
|
|
668
|
-
"path.length > 0",
|
|
669
|
-
""
|
|
670
|
-
]
|
|
671
|
-
});
|
|
620
|
+
invariant4(path.length > 0);
|
|
672
621
|
let parent = obj;
|
|
673
622
|
for (const key of path.slice(0, -1)) {
|
|
674
623
|
if (parent[key] === void 0) {
|
|
@@ -691,72 +640,51 @@ var getDeep = (obj, path) => {
|
|
|
691
640
|
// src/defer-function.ts
|
|
692
641
|
var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
|
|
693
642
|
|
|
694
|
-
// src/explicit-resource-management-polyfill.ts
|
|
695
|
-
var _Symbol;
|
|
696
|
-
var _Symbol1;
|
|
697
|
-
(_Symbol = Symbol).dispose ?? (_Symbol.dispose = Symbol("Symbol.dispose"));
|
|
698
|
-
(_Symbol1 = Symbol).asyncDispose ?? (_Symbol1.asyncDispose = Symbol("Symbol.asyncDispose"));
|
|
699
|
-
|
|
700
643
|
// src/defer.ts
|
|
701
|
-
|
|
702
|
-
if (key in obj) {
|
|
703
|
-
Object.defineProperty(obj, key, {
|
|
704
|
-
value,
|
|
705
|
-
enumerable: true,
|
|
706
|
-
configurable: true,
|
|
707
|
-
writable: true
|
|
708
|
-
});
|
|
709
|
-
} else {
|
|
710
|
-
obj[key] = value;
|
|
711
|
-
}
|
|
712
|
-
return obj;
|
|
713
|
-
}
|
|
644
|
+
import "@hazae41/symbol-dispose-polyfill";
|
|
714
645
|
var defer = (fn) => new DeferGuard(fn);
|
|
715
646
|
var DeferGuard = class {
|
|
716
|
-
|
|
717
|
-
const result = this._fn();
|
|
718
|
-
if (result instanceof Promise) {
|
|
719
|
-
throw new Error("Async functions in defer are not supported. Use deferAsync instead.");
|
|
720
|
-
}
|
|
721
|
-
}
|
|
647
|
+
_fn;
|
|
722
648
|
/**
|
|
723
649
|
* @internal
|
|
724
650
|
*/
|
|
725
651
|
constructor(_fn) {
|
|
726
|
-
_define_property4(this, "_fn", void 0);
|
|
727
652
|
this._fn = _fn;
|
|
728
653
|
}
|
|
654
|
+
[Symbol.dispose]() {
|
|
655
|
+
const result = this._fn();
|
|
656
|
+
if (result instanceof Promise) {
|
|
657
|
+
throw new Error("Async functions in defer are not supported. Use deferAsync instead.");
|
|
658
|
+
}
|
|
659
|
+
}
|
|
729
660
|
};
|
|
730
661
|
var deferAsync = (fn) => new DeferAsyncGuard(fn);
|
|
731
662
|
var DeferAsyncGuard = class {
|
|
732
|
-
|
|
733
|
-
await this._fn();
|
|
734
|
-
}
|
|
663
|
+
_fn;
|
|
735
664
|
/**
|
|
736
665
|
* @internal
|
|
737
666
|
*/
|
|
738
667
|
constructor(_fn) {
|
|
739
|
-
_define_property4(this, "_fn", void 0);
|
|
740
668
|
this._fn = _fn;
|
|
741
669
|
}
|
|
670
|
+
async [Symbol.asyncDispose]() {
|
|
671
|
+
await this._fn();
|
|
672
|
+
}
|
|
742
673
|
};
|
|
743
674
|
|
|
744
675
|
// src/entry.ts
|
|
745
|
-
function _define_property5(obj, key, value) {
|
|
746
|
-
if (key in obj) {
|
|
747
|
-
Object.defineProperty(obj, key, {
|
|
748
|
-
value,
|
|
749
|
-
enumerable: true,
|
|
750
|
-
configurable: true,
|
|
751
|
-
writable: true
|
|
752
|
-
});
|
|
753
|
-
} else {
|
|
754
|
-
obj[key] = value;
|
|
755
|
-
}
|
|
756
|
-
return obj;
|
|
757
|
-
}
|
|
758
676
|
var entry = (map, key) => new MapEntry(map, key);
|
|
759
677
|
var MapEntry = class {
|
|
678
|
+
_map;
|
|
679
|
+
_key;
|
|
680
|
+
/**
|
|
681
|
+
* @internal
|
|
682
|
+
*/
|
|
683
|
+
// prettier-ignore
|
|
684
|
+
constructor(_map, _key) {
|
|
685
|
+
this._map = _map;
|
|
686
|
+
this._key = _key;
|
|
687
|
+
}
|
|
760
688
|
get key() {
|
|
761
689
|
return this._key;
|
|
762
690
|
}
|
|
@@ -772,36 +700,36 @@ var MapEntry = class {
|
|
|
772
700
|
deep(key) {
|
|
773
701
|
return entry(this.value, key);
|
|
774
702
|
}
|
|
775
|
-
/**
|
|
776
|
-
* @internal
|
|
777
|
-
*/
|
|
778
|
-
// prettier-ignore
|
|
779
|
-
constructor(_map, _key) {
|
|
780
|
-
_define_property5(this, "_map", void 0);
|
|
781
|
-
_define_property5(this, "_key", void 0);
|
|
782
|
-
this._map = _map;
|
|
783
|
-
this._key = _key;
|
|
784
|
-
}
|
|
785
703
|
};
|
|
786
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
|
+
|
|
787
728
|
// src/for-each-async.ts
|
|
788
729
|
var forEachAsync = (items, fn) => Promise.all(items.map(fn));
|
|
789
730
|
|
|
790
731
|
// src/human-hash.ts
|
|
791
732
|
import { PublicKey } from "@dxos/keys";
|
|
792
|
-
function _define_property6(obj, key, value) {
|
|
793
|
-
if (key in obj) {
|
|
794
|
-
Object.defineProperty(obj, key, {
|
|
795
|
-
value,
|
|
796
|
-
enumerable: true,
|
|
797
|
-
configurable: true,
|
|
798
|
-
writable: true
|
|
799
|
-
});
|
|
800
|
-
} else {
|
|
801
|
-
obj[key] = value;
|
|
802
|
-
}
|
|
803
|
-
return obj;
|
|
804
|
-
}
|
|
805
733
|
var DEFAULT_WORDLIST = [
|
|
806
734
|
"ack",
|
|
807
735
|
"alabama",
|
|
@@ -1061,6 +989,27 @@ var DEFAULT_WORDLIST = [
|
|
|
1061
989
|
"zulu"
|
|
1062
990
|
];
|
|
1063
991
|
var HumanHasher = class {
|
|
992
|
+
wordlist;
|
|
993
|
+
/**
|
|
994
|
+
* Transforms hex digests to human-readable strings.
|
|
995
|
+
*
|
|
996
|
+
* The format of these strings will look something like:
|
|
997
|
+
* `victor-bacon-zulu-lima`. The output is obtained by compressing the input
|
|
998
|
+
* digest to a fixed number of bytes, then mapping those bytes to one of 256
|
|
999
|
+
* words. A default wordlist is provided, but you can override this if you
|
|
1000
|
+
* prefer.
|
|
1001
|
+
* As long as you use the same wordlist, the output will be consistent (i.e.
|
|
1002
|
+
* the same digest will always render the same representation).
|
|
1003
|
+
*
|
|
1004
|
+
* @param wordlist A list of exactly 256 words to choose from
|
|
1005
|
+
*/
|
|
1006
|
+
constructor(wordlist = DEFAULT_WORDLIST) {
|
|
1007
|
+
this.wordlist = wordlist;
|
|
1008
|
+
if (wordlist.length !== 256) {
|
|
1009
|
+
throw new Error("Wordlist must have exactly 256 items");
|
|
1010
|
+
}
|
|
1011
|
+
this.wordlist = wordlist;
|
|
1012
|
+
}
|
|
1064
1013
|
/**
|
|
1065
1014
|
* Humanize a given hexadecimal digest.
|
|
1066
1015
|
*
|
|
@@ -1100,27 +1049,6 @@ var HumanHasher = class {
|
|
|
1100
1049
|
const checksums = segments.map((x) => x.reduce((acc, curr) => acc ^ curr));
|
|
1101
1050
|
return checksums;
|
|
1102
1051
|
}
|
|
1103
|
-
/**
|
|
1104
|
-
* Transforms hex digests to human-readable strings.
|
|
1105
|
-
*
|
|
1106
|
-
* The format of these strings will look something like:
|
|
1107
|
-
* `victor-bacon-zulu-lima`. The output is obtained by compressing the input
|
|
1108
|
-
* digest to a fixed number of bytes, then mapping those bytes to one of 256
|
|
1109
|
-
* words. A default wordlist is provided, but you can override this if you
|
|
1110
|
-
* prefer.
|
|
1111
|
-
* As long as you use the same wordlist, the output will be consistent (i.e.
|
|
1112
|
-
* the same digest will always render the same representation).
|
|
1113
|
-
*
|
|
1114
|
-
* @param wordlist A list of exactly 256 words to choose from
|
|
1115
|
-
*/
|
|
1116
|
-
constructor(wordlist = DEFAULT_WORDLIST) {
|
|
1117
|
-
_define_property6(this, "wordlist", void 0);
|
|
1118
|
-
this.wordlist = wordlist;
|
|
1119
|
-
if (wordlist.length !== 256) {
|
|
1120
|
-
throw new Error("Wordlist must have exactly 256 items");
|
|
1121
|
-
}
|
|
1122
|
-
this.wordlist = wordlist;
|
|
1123
|
-
}
|
|
1124
1052
|
};
|
|
1125
1053
|
var hasher = new HumanHasher();
|
|
1126
1054
|
var humanize = (value) => {
|
|
@@ -1132,6 +1060,19 @@ var humanize = (value) => {
|
|
|
1132
1060
|
return hasher.humanize(value);
|
|
1133
1061
|
};
|
|
1134
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
|
+
|
|
1135
1076
|
// src/map.ts
|
|
1136
1077
|
var defaultMap = (map, key, def) => {
|
|
1137
1078
|
let value = map.get(key);
|
|
@@ -1143,22 +1084,20 @@ var defaultMap = (map, key, def) => {
|
|
|
1143
1084
|
};
|
|
1144
1085
|
|
|
1145
1086
|
// src/instance-id.ts
|
|
1146
|
-
var
|
|
1147
|
-
var
|
|
1148
|
-
var symbol = Symbol.for("dxos.instance-contexts");
|
|
1149
|
-
var instanceContexts = (_globalThis = globalThis)[_symbol = symbol] ?? (_globalThis[_symbol] = /* @__PURE__ */ new WeakMap());
|
|
1087
|
+
var symbol = /* @__PURE__ */ Symbol.for("dxos.instance-contexts");
|
|
1088
|
+
var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
|
|
1150
1089
|
var getPrototypeSpecificInstanceId = (instance) => {
|
|
1151
1090
|
const prototype = Object.getPrototypeOf(instance);
|
|
1152
1091
|
const instanceCtx = defaultMap(instanceContexts, prototype, () => ({
|
|
1153
1092
|
nextId: 0,
|
|
1154
1093
|
instanceIds: /* @__PURE__ */ new WeakMap()
|
|
1155
1094
|
}));
|
|
1156
|
-
let
|
|
1157
|
-
if (
|
|
1158
|
-
|
|
1159
|
-
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);
|
|
1160
1099
|
}
|
|
1161
|
-
return
|
|
1100
|
+
return id2;
|
|
1162
1101
|
};
|
|
1163
1102
|
var getDebugName = (instance) => {
|
|
1164
1103
|
if (instance == null) {
|
|
@@ -1225,6 +1164,26 @@ var bufferToArray = (buffer) => {
|
|
|
1225
1164
|
};
|
|
1226
1165
|
var stringToArray = (string) => bufferToArray(Buffer.from(string, "hex"));
|
|
1227
1166
|
var arrayToString = (array) => arrayToBuffer(array).toString("hex");
|
|
1167
|
+
var toUnpaddedBase64 = (bytes) => arrayToBuffer(bytes).toString("base64").replace(/=+$/, "");
|
|
1168
|
+
var encodeUint8ArrayToJson = (bytes) => ({
|
|
1169
|
+
"/": {
|
|
1170
|
+
bytes: toUnpaddedBase64(bytes)
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
var isEncodedUint8Array = (value) => {
|
|
1174
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
if (Object.keys(value).length !== 1) {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
const inner = value["/"];
|
|
1181
|
+
if (typeof inner !== "object" || inner === null || Array.isArray(inner)) {
|
|
1182
|
+
return false;
|
|
1183
|
+
}
|
|
1184
|
+
return Object.keys(inner).length === 1 && typeof inner.bytes === "string";
|
|
1185
|
+
};
|
|
1186
|
+
var decodeUint8ArrayFromJson = (encoded) => bufferToArray(Buffer.from(encoded["/"].bytes, "base64"));
|
|
1228
1187
|
|
|
1229
1188
|
// src/json.ts
|
|
1230
1189
|
var MAX_DEPTH = 5;
|
|
@@ -1318,19 +1277,6 @@ var jsonKeyReplacer = (options = {}) => (key, value) => {
|
|
|
1318
1277
|
};
|
|
1319
1278
|
|
|
1320
1279
|
// src/map-values.ts
|
|
1321
|
-
function _define_property7(obj, key, value) {
|
|
1322
|
-
if (key in obj) {
|
|
1323
|
-
Object.defineProperty(obj, key, {
|
|
1324
|
-
value,
|
|
1325
|
-
enumerable: true,
|
|
1326
|
-
configurable: true,
|
|
1327
|
-
writable: true
|
|
1328
|
-
});
|
|
1329
|
-
} else {
|
|
1330
|
-
obj[key] = value;
|
|
1331
|
-
}
|
|
1332
|
-
return obj;
|
|
1333
|
-
}
|
|
1334
1280
|
var mapValues = (obj, fn) => {
|
|
1335
1281
|
const result = {};
|
|
1336
1282
|
Object.keys(obj).forEach((key) => {
|
|
@@ -1342,6 +1288,11 @@ var deepMapValues = (value, fn) => {
|
|
|
1342
1288
|
return new DeepMapper(fn).map(value);
|
|
1343
1289
|
};
|
|
1344
1290
|
var DeepMapper = class {
|
|
1291
|
+
_fn;
|
|
1292
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1293
|
+
constructor(_fn) {
|
|
1294
|
+
this._fn = _fn;
|
|
1295
|
+
}
|
|
1345
1296
|
map(value) {
|
|
1346
1297
|
return this._map(value, void 0);
|
|
1347
1298
|
}
|
|
@@ -1351,40 +1302,40 @@ var DeepMapper = class {
|
|
|
1351
1302
|
}
|
|
1352
1303
|
return this._fn(value, this._recurse, key);
|
|
1353
1304
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1305
|
+
_recurse = (value) => {
|
|
1306
|
+
if (this._cyclic.has(value)) {
|
|
1307
|
+
return this._cyclic.get(value);
|
|
1308
|
+
}
|
|
1309
|
+
if (Array.isArray(value)) {
|
|
1310
|
+
const res = new Array(value.length);
|
|
1311
|
+
this._cyclic.set(value, res);
|
|
1312
|
+
for (let i = 0; i < value.length; i++) {
|
|
1313
|
+
res[i] = this._map(value[i], i);
|
|
1363
1314
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
const res = {};
|
|
1373
|
-
this._cyclic.set(value, res);
|
|
1374
|
-
for (const key in value) {
|
|
1375
|
-
res[key] = this._map(value[key], key);
|
|
1376
|
-
}
|
|
1377
|
-
return res;
|
|
1378
|
-
} else {
|
|
1379
|
-
return value;
|
|
1315
|
+
return res;
|
|
1316
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
1317
|
+
return value;
|
|
1318
|
+
} else if (value !== null && typeof value === "object") {
|
|
1319
|
+
const res = {};
|
|
1320
|
+
this._cyclic.set(value, res);
|
|
1321
|
+
for (const key in value) {
|
|
1322
|
+
res[key] = this._map(value[key], key);
|
|
1380
1323
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1324
|
+
return res;
|
|
1325
|
+
} else {
|
|
1326
|
+
return value;
|
|
1327
|
+
}
|
|
1328
|
+
};
|
|
1383
1329
|
};
|
|
1384
1330
|
var deepMapValuesAsync = (value, fn) => {
|
|
1385
1331
|
return new DeepMapperAsync(fn).map(value);
|
|
1386
1332
|
};
|
|
1387
1333
|
var DeepMapperAsync = class {
|
|
1334
|
+
_fn;
|
|
1335
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1336
|
+
constructor(_fn) {
|
|
1337
|
+
this._fn = _fn;
|
|
1338
|
+
}
|
|
1388
1339
|
map(value) {
|
|
1389
1340
|
return this._map(value, void 0);
|
|
1390
1341
|
}
|
|
@@ -1394,35 +1345,30 @@ var DeepMapperAsync = class {
|
|
|
1394
1345
|
}
|
|
1395
1346
|
return this._fn(value, this._recurse, key);
|
|
1396
1347
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1348
|
+
_recurse = async (value) => {
|
|
1349
|
+
if (this._cyclic.has(value)) {
|
|
1350
|
+
return this._cyclic.get(value);
|
|
1351
|
+
}
|
|
1352
|
+
if (Array.isArray(value)) {
|
|
1353
|
+
const res = new Array(value.length);
|
|
1354
|
+
this._cyclic.set(value, res);
|
|
1355
|
+
for (let i = 0; i < value.length; i++) {
|
|
1356
|
+
res[i] = await this._map(value[i], i);
|
|
1406
1357
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
const res = {};
|
|
1416
|
-
this._cyclic.set(value, res);
|
|
1417
|
-
for (const key in value) {
|
|
1418
|
-
res[key] = await this._map(value[key], key);
|
|
1419
|
-
}
|
|
1420
|
-
return res;
|
|
1421
|
-
} else {
|
|
1422
|
-
return value;
|
|
1358
|
+
return res;
|
|
1359
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
1360
|
+
return value;
|
|
1361
|
+
} else if (value !== null && typeof value === "object") {
|
|
1362
|
+
const res = {};
|
|
1363
|
+
this._cyclic.set(value, res);
|
|
1364
|
+
for (const key in value) {
|
|
1365
|
+
res[key] = await this._map(value[key], key);
|
|
1423
1366
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1367
|
+
return res;
|
|
1368
|
+
} else {
|
|
1369
|
+
return value;
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1426
1372
|
};
|
|
1427
1373
|
var visitValues = (object, visitor) => {
|
|
1428
1374
|
if (Array.isArray(object)) {
|
|
@@ -1456,27 +1402,27 @@ var orderKeys = (obj, order) => {
|
|
|
1456
1402
|
|
|
1457
1403
|
// src/order.ts
|
|
1458
1404
|
var inferObjectOrder = (objectMap, order = []) => {
|
|
1459
|
-
const orderedObjects = order.reduce((acc,
|
|
1460
|
-
if (
|
|
1461
|
-
acc.objects.push(objectMap[
|
|
1462
|
-
acc.ids.add(
|
|
1405
|
+
const orderedObjects = order.reduce((acc, id2) => {
|
|
1406
|
+
if (id2 in objectMap) {
|
|
1407
|
+
acc.objects.push(objectMap[id2]);
|
|
1408
|
+
acc.ids.add(id2);
|
|
1463
1409
|
}
|
|
1464
1410
|
return acc;
|
|
1465
1411
|
}, {
|
|
1466
1412
|
objects: [],
|
|
1467
1413
|
ids: /* @__PURE__ */ new Set()
|
|
1468
1414
|
});
|
|
1469
|
-
const { objects } = Object.keys(objectMap).reduce((acc,
|
|
1470
|
-
if (!acc.ids.has(
|
|
1471
|
-
acc.objects.push(objectMap[
|
|
1415
|
+
const { objects } = Object.keys(objectMap).reduce((acc, id2) => {
|
|
1416
|
+
if (!acc.ids.has(id2)) {
|
|
1417
|
+
acc.objects.push(objectMap[id2]);
|
|
1472
1418
|
}
|
|
1473
1419
|
return acc;
|
|
1474
1420
|
}, orderedObjects);
|
|
1475
1421
|
return objects;
|
|
1476
1422
|
};
|
|
1477
1423
|
var inferRecordOrder = (objectMap, order = []) => {
|
|
1478
|
-
return Object.assign(order.filter((
|
|
1479
|
-
acc[
|
|
1424
|
+
return Object.assign(order.filter((id2) => id2 in objectMap).reduce((acc, id2) => {
|
|
1425
|
+
acc[id2] = null;
|
|
1480
1426
|
return acc;
|
|
1481
1427
|
}, {}), objectMap);
|
|
1482
1428
|
};
|
|
@@ -1511,7 +1457,18 @@ var omit = (obj, keys2) => {
|
|
|
1511
1457
|
|
|
1512
1458
|
// src/platform.ts
|
|
1513
1459
|
var isNode = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
1514
|
-
var
|
|
1460
|
+
var isBun = () => globalThis.Bun !== void 0;
|
|
1461
|
+
var isTauri = () => !!globalThis.__TAURI__;
|
|
1462
|
+
var isMobile = () => {
|
|
1463
|
+
let check = false;
|
|
1464
|
+
(function(a) {
|
|
1465
|
+
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))) {
|
|
1466
|
+
check = true;
|
|
1467
|
+
}
|
|
1468
|
+
})(navigator.userAgent || navigator.vendor || window.opera);
|
|
1469
|
+
return check;
|
|
1470
|
+
};
|
|
1471
|
+
var isMobileOrTablet = () => {
|
|
1515
1472
|
let check = false;
|
|
1516
1473
|
((a) => {
|
|
1517
1474
|
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))) {
|
|
@@ -1533,7 +1490,7 @@ var iosCheck = () => {
|
|
|
1533
1490
|
};
|
|
1534
1491
|
var safariCheck = () => typeof navigator !== "undefined" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1535
1492
|
var getHostPlatform = () => {
|
|
1536
|
-
if (!("navigator" in
|
|
1493
|
+
if (!("navigator" in globalThis)) {
|
|
1537
1494
|
return "unknown";
|
|
1538
1495
|
}
|
|
1539
1496
|
const platform = (navigator.userAgentData?.platform || navigator.platform)?.toLowerCase();
|
|
@@ -1551,12 +1508,12 @@ var getHostPlatform = () => {
|
|
|
1551
1508
|
};
|
|
1552
1509
|
|
|
1553
1510
|
// src/position.ts
|
|
1554
|
-
var byPosition = ({ position: a
|
|
1511
|
+
var byPosition = ({ position: a }, { position: b }) => {
|
|
1555
1512
|
if (a === b) {
|
|
1556
1513
|
return 0;
|
|
1557
|
-
} else if (a === "
|
|
1514
|
+
} else if (a === "first" || b === "last") {
|
|
1558
1515
|
return -1;
|
|
1559
|
-
} else if (b === "
|
|
1516
|
+
} else if (b === "first" || a === "last") {
|
|
1560
1517
|
return 1;
|
|
1561
1518
|
} else {
|
|
1562
1519
|
return 0;
|
|
@@ -1709,6 +1666,43 @@ var removeProperties = (root, condition) => {
|
|
|
1709
1666
|
return result;
|
|
1710
1667
|
};
|
|
1711
1668
|
|
|
1669
|
+
// src/retry.ts
|
|
1670
|
+
var DEFAULT_RETRY_OPTIONS = {
|
|
1671
|
+
count: 3,
|
|
1672
|
+
delayMs: 100,
|
|
1673
|
+
exponent: 2,
|
|
1674
|
+
retryOnError: async () => true,
|
|
1675
|
+
retryOnValue: async () => false
|
|
1676
|
+
};
|
|
1677
|
+
var retry = async (options, cb) => {
|
|
1678
|
+
const fullOptions = {
|
|
1679
|
+
...DEFAULT_RETRY_OPTIONS,
|
|
1680
|
+
...options
|
|
1681
|
+
};
|
|
1682
|
+
let numRetries = 0, currentDelay = fullOptions.delayMs;
|
|
1683
|
+
while (true) {
|
|
1684
|
+
let result;
|
|
1685
|
+
try {
|
|
1686
|
+
result = await cb();
|
|
1687
|
+
} catch (err) {
|
|
1688
|
+
if (numRetries > fullOptions.count || !await fullOptions.retryOnError(err)) {
|
|
1689
|
+
throw err;
|
|
1690
|
+
}
|
|
1691
|
+
await new Promise((resolve) => setTimeout(resolve, currentDelay));
|
|
1692
|
+
currentDelay *= fullOptions.exponent;
|
|
1693
|
+
numRetries++;
|
|
1694
|
+
continue;
|
|
1695
|
+
}
|
|
1696
|
+
if (!await fullOptions.retryOnValue(result)) {
|
|
1697
|
+
return result;
|
|
1698
|
+
}
|
|
1699
|
+
await new Promise((resolve) => setTimeout(resolve, currentDelay));
|
|
1700
|
+
currentDelay *= fullOptions.exponent;
|
|
1701
|
+
numRetries++;
|
|
1702
|
+
continue;
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
|
|
1712
1706
|
// src/safe-await.ts
|
|
1713
1707
|
var safeAwaitAll = async (source, taskFactory, onError) => {
|
|
1714
1708
|
const failedItems = [];
|
|
@@ -1728,7 +1722,7 @@ var safeAwaitAll = async (source, taskFactory, onError) => {
|
|
|
1728
1722
|
};
|
|
1729
1723
|
|
|
1730
1724
|
// src/safe-instanceof.ts
|
|
1731
|
-
var instanceTag = Symbol("instanceTag");
|
|
1725
|
+
var instanceTag = /* @__PURE__ */ Symbol("instanceTag");
|
|
1732
1726
|
var safeInstanceof = (tag) => (target) => {
|
|
1733
1727
|
target.prototype[instanceTag] = tag;
|
|
1734
1728
|
Object.defineProperty(target.prototype, Symbol.hasInstance, {
|
|
@@ -1740,48 +1734,142 @@ var safeInstanceof = (tag) => (target) => {
|
|
|
1740
1734
|
};
|
|
1741
1735
|
|
|
1742
1736
|
// src/safe-parse.ts
|
|
1743
|
-
|
|
1737
|
+
function safeParseInt(str, defaultValue) {
|
|
1744
1738
|
try {
|
|
1745
|
-
const
|
|
1746
|
-
return isNaN(
|
|
1739
|
+
const value = parseInt(str ?? "");
|
|
1740
|
+
return isNaN(value) ? defaultValue : value;
|
|
1747
1741
|
} catch {
|
|
1748
1742
|
return defaultValue;
|
|
1749
1743
|
}
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1744
|
+
}
|
|
1745
|
+
function safeParseFloat(str, defaultValue) {
|
|
1752
1746
|
try {
|
|
1753
|
-
|
|
1747
|
+
const value = parseFloat(str ?? "");
|
|
1748
|
+
return isNaN(value) ? defaultValue : value;
|
|
1754
1749
|
} catch {
|
|
1755
|
-
return defaultValue
|
|
1750
|
+
return defaultValue;
|
|
1756
1751
|
}
|
|
1757
|
-
}
|
|
1758
|
-
var safeParseJson = (
|
|
1759
|
-
if (
|
|
1752
|
+
}
|
|
1753
|
+
var safeParseJson = (str, defaultValue) => {
|
|
1754
|
+
if (str && str.length > 0) {
|
|
1760
1755
|
try {
|
|
1761
|
-
return JSON.parse(
|
|
1756
|
+
return JSON.parse(str);
|
|
1762
1757
|
} catch {
|
|
1763
1758
|
}
|
|
1764
1759
|
}
|
|
1765
1760
|
return defaultValue;
|
|
1766
1761
|
};
|
|
1762
|
+
var safeUrl = (str) => {
|
|
1763
|
+
try {
|
|
1764
|
+
return new URL(str ?? "");
|
|
1765
|
+
} catch {
|
|
1766
|
+
return void 0;
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1767
1769
|
|
|
1768
|
-
// src/
|
|
1769
|
-
|
|
1770
|
-
function
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1770
|
+
// src/safe-stringify.ts
|
|
1771
|
+
var SKIP = Object.freeze({});
|
|
1772
|
+
function safeStringify(obj, filter = defaultFilter, indent = 2) {
|
|
1773
|
+
const seen = /* @__PURE__ */ new WeakMap();
|
|
1774
|
+
function replacer(key, value) {
|
|
1775
|
+
try {
|
|
1776
|
+
let path = key;
|
|
1777
|
+
if (!key) {
|
|
1778
|
+
path = "$";
|
|
1779
|
+
if (value != null && typeof value === "object") {
|
|
1780
|
+
seen.set(value, path);
|
|
1781
|
+
}
|
|
1782
|
+
return value;
|
|
1783
|
+
} else if (this) {
|
|
1784
|
+
const parentPath = seen.get(this);
|
|
1785
|
+
path = parentPath ? `${parentPath}.${key}` : key;
|
|
1786
|
+
}
|
|
1787
|
+
if (value == null) {
|
|
1788
|
+
return value;
|
|
1789
|
+
}
|
|
1790
|
+
if (typeof value === "function") {
|
|
1791
|
+
return void 0;
|
|
1792
|
+
}
|
|
1793
|
+
if (typeof value === "object" && Object.getPrototypeOf(value) !== Object.prototype && !Array.isArray(value)) {
|
|
1794
|
+
return void 0;
|
|
1795
|
+
}
|
|
1796
|
+
if (typeof value === "object" && value !== null) {
|
|
1797
|
+
const exists = seen.get(value);
|
|
1798
|
+
if (exists) {
|
|
1799
|
+
return `[${path} => ${exists}]`;
|
|
1800
|
+
}
|
|
1801
|
+
seen.set(value, path);
|
|
1802
|
+
}
|
|
1803
|
+
if (filter) {
|
|
1804
|
+
const filteredValue = filter?.(key, value);
|
|
1805
|
+
if (filteredValue !== void 0) {
|
|
1806
|
+
return filteredValue === SKIP ? void 0 : filteredValue;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
return value;
|
|
1810
|
+
} catch (error) {
|
|
1811
|
+
return `ERROR: ${error.message}`;
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
try {
|
|
1815
|
+
return JSON.stringify(obj, replacer, indent);
|
|
1816
|
+
} catch (error) {
|
|
1817
|
+
return `ERROR: ${error.message}`;
|
|
1780
1818
|
}
|
|
1781
|
-
return obj;
|
|
1782
1819
|
}
|
|
1783
|
-
var
|
|
1820
|
+
var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen } = {}) => {
|
|
1821
|
+
let currentDepth = 0;
|
|
1822
|
+
const depthMap = /* @__PURE__ */ new WeakMap();
|
|
1823
|
+
return function(key, value) {
|
|
1824
|
+
if (key === "") {
|
|
1825
|
+
currentDepth = 0;
|
|
1826
|
+
} else if (this && typeof this === "object") {
|
|
1827
|
+
const parentDepth = depthMap.get(this) ?? 0;
|
|
1828
|
+
currentDepth = parentDepth + 1;
|
|
1829
|
+
}
|
|
1830
|
+
if (typeof value === "function") {
|
|
1831
|
+
return SKIP;
|
|
1832
|
+
}
|
|
1833
|
+
if (maxArrayLen != null && Array.isArray(value) && value.length > maxArrayLen) {
|
|
1834
|
+
return `[length: ${value.length}]`;
|
|
1835
|
+
}
|
|
1836
|
+
if (value && typeof value === "object") {
|
|
1837
|
+
depthMap.set(value, currentDepth);
|
|
1838
|
+
if (maxDepth != null && currentDepth >= maxDepth) {
|
|
1839
|
+
return Array.isArray(value) ? `[{ length: ${value.length} }]` : `{ keys: ${Object.keys(value).length} }`;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
if (omit2?.includes(key)) {
|
|
1843
|
+
return SKIP;
|
|
1844
|
+
}
|
|
1845
|
+
if (parse?.includes(key) && typeof value === "string") {
|
|
1846
|
+
try {
|
|
1847
|
+
return JSON.parse(value);
|
|
1848
|
+
} catch {
|
|
1849
|
+
return value;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
if (maxStringLen != null && typeof value === "string" && value.length > maxStringLen) {
|
|
1853
|
+
return value.slice(0, maxStringLen) + "...";
|
|
1854
|
+
}
|
|
1855
|
+
return value;
|
|
1856
|
+
};
|
|
1857
|
+
};
|
|
1858
|
+
var defaultFilter = createReplacer();
|
|
1859
|
+
|
|
1860
|
+
// src/sliding-window-summary.ts
|
|
1861
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1784
1862
|
var SlidingWindowSummary = class {
|
|
1863
|
+
_buffer;
|
|
1864
|
+
_sum = 0;
|
|
1865
|
+
_precision;
|
|
1866
|
+
constructor(options) {
|
|
1867
|
+
this._buffer = new CircularBuffer(options.dataPoints);
|
|
1868
|
+
if (options.precision != null) {
|
|
1869
|
+
invariant5(options.precision >= 0);
|
|
1870
|
+
this._precision = Math.pow(10, options.precision);
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1785
1873
|
record(value) {
|
|
1786
1874
|
const evicted = this._buffer.push(value);
|
|
1787
1875
|
this._sum += value - (evicted ?? 0);
|
|
@@ -1816,24 +1904,6 @@ var SlidingWindowSummary = class {
|
|
|
1816
1904
|
}
|
|
1817
1905
|
return Math.round(value * this._precision) / this._precision;
|
|
1818
1906
|
}
|
|
1819
|
-
constructor(options) {
|
|
1820
|
-
_define_property8(this, "_buffer", void 0);
|
|
1821
|
-
_define_property8(this, "_sum", 0);
|
|
1822
|
-
_define_property8(this, "_precision", void 0);
|
|
1823
|
-
this._buffer = new CircularBuffer(options.dataPoints);
|
|
1824
|
-
if (options.precision != null) {
|
|
1825
|
-
invariant5(options.precision >= 0, void 0, {
|
|
1826
|
-
F: __dxlog_file5,
|
|
1827
|
-
L: 26,
|
|
1828
|
-
S: this,
|
|
1829
|
-
A: [
|
|
1830
|
-
"options.precision >= 0",
|
|
1831
|
-
""
|
|
1832
|
-
]
|
|
1833
|
-
});
|
|
1834
|
-
this._precision = Math.pow(10, options.precision);
|
|
1835
|
-
}
|
|
1836
|
-
}
|
|
1837
1907
|
};
|
|
1838
1908
|
|
|
1839
1909
|
// src/sort.ts
|
|
@@ -1865,6 +1935,10 @@ var capitalize = (str) => {
|
|
|
1865
1935
|
}
|
|
1866
1936
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1867
1937
|
};
|
|
1938
|
+
function inline(strings, ...values) {
|
|
1939
|
+
const raw = strings.reduce((out, str, i) => out + str + (i < values.length ? String(values[i]) : ""), "");
|
|
1940
|
+
return raw.replace(/\s+/g, " ").trim();
|
|
1941
|
+
}
|
|
1868
1942
|
function trim(strings, ...values) {
|
|
1869
1943
|
const raw = strings.reduce((out, str, i) => {
|
|
1870
1944
|
out += str;
|
|
@@ -1877,8 +1951,12 @@ function trim(strings, ...values) {
|
|
|
1877
1951
|
return out;
|
|
1878
1952
|
}, "");
|
|
1879
1953
|
const lines = raw.split("\n");
|
|
1880
|
-
while (lines.length && !lines[0].trim())
|
|
1881
|
-
|
|
1954
|
+
while (lines.length && !lines[0].trim()) {
|
|
1955
|
+
lines.shift();
|
|
1956
|
+
}
|
|
1957
|
+
while (lines.length && !lines[lines.length - 1].trim()) {
|
|
1958
|
+
lines.pop();
|
|
1959
|
+
}
|
|
1882
1960
|
const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
|
|
1883
1961
|
return lines.map((l) => l.slice(minIndent)).join("\n");
|
|
1884
1962
|
}
|
|
@@ -1896,18 +1974,6 @@ var throwUnhandledError = (error) => {
|
|
|
1896
1974
|
|
|
1897
1975
|
// src/to-fallback.ts
|
|
1898
1976
|
var idEmoji = [
|
|
1899
|
-
// When changing this set, please check the result in a console or e.g. RunKit (https://runkit.com/thure/642214441dd6ae000855a8de)
|
|
1900
|
-
// 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.
|
|
1901
|
-
// This set was chosen from the characters in Unicode Emoji v15.0 based on the following criteria:
|
|
1902
|
-
// – not people or isolated anthropomorphic faces
|
|
1903
|
-
// – not flags
|
|
1904
|
-
// – more concrete than abstract
|
|
1905
|
-
// – less culturally specific
|
|
1906
|
-
// – less easily confused with another emoji in the set
|
|
1907
|
-
// – requires less special knowledge to identify
|
|
1908
|
-
// – less likely to evoke negative feelings (no meat, no drugs, no weapons, etc)
|
|
1909
|
-
// – less common as a signifier in UX
|
|
1910
|
-
// NOTE that this is intentionally an array of strings because of the way emoji graphemes work.
|
|
1911
1977
|
"\u{1F47B}",
|
|
1912
1978
|
"\u{1F479}",
|
|
1913
1979
|
"\u{1F47D}",
|
|
@@ -2043,17 +2109,18 @@ var idEmoji = [
|
|
|
2043
2109
|
];
|
|
2044
2110
|
var idHue = [
|
|
2045
2111
|
"red",
|
|
2046
|
-
|
|
2112
|
+
"orange",
|
|
2047
2113
|
"amber",
|
|
2048
|
-
|
|
2114
|
+
"yellow",
|
|
2049
2115
|
"lime",
|
|
2050
2116
|
"green",
|
|
2051
2117
|
"emerald",
|
|
2052
2118
|
"teal",
|
|
2053
2119
|
"cyan",
|
|
2054
|
-
//
|
|
2055
|
-
// '
|
|
2056
|
-
// '
|
|
2120
|
+
// Omit colors similar to primary accent.
|
|
2121
|
+
// 'sky' as const,
|
|
2122
|
+
// 'blue' as const,
|
|
2123
|
+
// 'indigo' as const,
|
|
2057
2124
|
"violet",
|
|
2058
2125
|
"purple",
|
|
2059
2126
|
"fuchsia",
|
|
@@ -2080,20 +2147,9 @@ var toFallback = (hash) => {
|
|
|
2080
2147
|
};
|
|
2081
2148
|
|
|
2082
2149
|
// src/tracer.ts
|
|
2083
|
-
function _define_property9(obj, key, value) {
|
|
2084
|
-
if (key in obj) {
|
|
2085
|
-
Object.defineProperty(obj, key, {
|
|
2086
|
-
value,
|
|
2087
|
-
enumerable: true,
|
|
2088
|
-
configurable: true,
|
|
2089
|
-
writable: true
|
|
2090
|
-
});
|
|
2091
|
-
} else {
|
|
2092
|
-
obj[key] = value;
|
|
2093
|
-
}
|
|
2094
|
-
return obj;
|
|
2095
|
-
}
|
|
2096
2150
|
var Tracer = class {
|
|
2151
|
+
_events = /* @__PURE__ */ new Map();
|
|
2152
|
+
_recording = false;
|
|
2097
2153
|
// TODO(burdon): Start/stop methods for recording data? By id?
|
|
2098
2154
|
// Alternatively, enable subscriptions to track/compute series.
|
|
2099
2155
|
// TODO(burdon): Hierarchical traces?
|
|
@@ -2103,8 +2159,8 @@ var Tracer = class {
|
|
|
2103
2159
|
keys() {
|
|
2104
2160
|
return Array.from(this._events.keys());
|
|
2105
2161
|
}
|
|
2106
|
-
get(
|
|
2107
|
-
const events = this._events.get(
|
|
2162
|
+
get(id2, filter) {
|
|
2163
|
+
const events = this._events.get(id2);
|
|
2108
2164
|
if (filter) {
|
|
2109
2165
|
return events?.filter((event) => Object.entries(filter).every(([key, value]) => event?.value[key] === value));
|
|
2110
2166
|
}
|
|
@@ -2121,11 +2177,11 @@ var Tracer = class {
|
|
|
2121
2177
|
this._recording = false;
|
|
2122
2178
|
return this;
|
|
2123
2179
|
}
|
|
2124
|
-
emit(
|
|
2125
|
-
this._post(this._createEvent(
|
|
2180
|
+
emit(id2, value) {
|
|
2181
|
+
this._post(this._createEvent(id2, value));
|
|
2126
2182
|
}
|
|
2127
|
-
mark(
|
|
2128
|
-
const event = this._createEvent(
|
|
2183
|
+
mark(id2, value) {
|
|
2184
|
+
const event = this._createEvent(id2, value);
|
|
2129
2185
|
const start = performance.now();
|
|
2130
2186
|
return {
|
|
2131
2187
|
start,
|
|
@@ -2135,9 +2191,9 @@ var Tracer = class {
|
|
|
2135
2191
|
}
|
|
2136
2192
|
};
|
|
2137
2193
|
}
|
|
2138
|
-
_createEvent(
|
|
2194
|
+
_createEvent(id2, value) {
|
|
2139
2195
|
const event = {
|
|
2140
|
-
id,
|
|
2196
|
+
id: id2,
|
|
2141
2197
|
timestamp: Date.now()
|
|
2142
2198
|
};
|
|
2143
2199
|
if (value !== void 0) {
|
|
@@ -2150,10 +2206,6 @@ var Tracer = class {
|
|
|
2150
2206
|
defaultMap(this._events, event.id, []).push(event);
|
|
2151
2207
|
}
|
|
2152
2208
|
}
|
|
2153
|
-
constructor() {
|
|
2154
|
-
_define_property9(this, "_events", /* @__PURE__ */ new Map());
|
|
2155
|
-
_define_property9(this, "_recording", false);
|
|
2156
|
-
}
|
|
2157
2209
|
};
|
|
2158
2210
|
var tracer = new Tracer();
|
|
2159
2211
|
|
|
@@ -2228,69 +2280,116 @@ var arrayMove = (array, from, to) => {
|
|
|
2228
2280
|
array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
|
|
2229
2281
|
return array;
|
|
2230
2282
|
};
|
|
2283
|
+
function arraySwap(array, from, to) {
|
|
2284
|
+
const current = array[from];
|
|
2285
|
+
array[from] = array[to];
|
|
2286
|
+
array[to] = current;
|
|
2287
|
+
return array;
|
|
2288
|
+
}
|
|
2231
2289
|
|
|
2232
2290
|
// src/unit.ts
|
|
2233
|
-
var
|
|
2234
|
-
return (n, precision =
|
|
2291
|
+
var createFormat = (unit) => {
|
|
2292
|
+
return (n, precision = unit.precision ?? 0) => {
|
|
2235
2293
|
const value = n / unit.quotient;
|
|
2236
|
-
|
|
2294
|
+
const formattedValue = value.toLocaleString("en-US", {
|
|
2295
|
+
minimumFractionDigits: precision,
|
|
2296
|
+
maximumFractionDigits: precision
|
|
2297
|
+
});
|
|
2298
|
+
return {
|
|
2299
|
+
unit,
|
|
2300
|
+
value,
|
|
2301
|
+
formattedValue,
|
|
2302
|
+
toString: () => `${formattedValue}${unit.symbol}`
|
|
2303
|
+
};
|
|
2237
2304
|
};
|
|
2238
2305
|
};
|
|
2306
|
+
var MS_SECONDS = 1e3;
|
|
2307
|
+
var MS_MINUTES = 60 * MS_SECONDS;
|
|
2308
|
+
var MS_HOURS = 60 * MS_MINUTES;
|
|
2239
2309
|
var Unit = {
|
|
2240
|
-
//
|
|
2241
|
-
|
|
2310
|
+
// General.
|
|
2311
|
+
Percent: createFormat({
|
|
2312
|
+
symbol: "%",
|
|
2313
|
+
quotient: 1 / 100,
|
|
2314
|
+
precision: 2
|
|
2315
|
+
}),
|
|
2316
|
+
Thousand: createFormat({
|
|
2317
|
+
symbol: "k",
|
|
2318
|
+
quotient: 1e3,
|
|
2319
|
+
precision: 2
|
|
2320
|
+
}),
|
|
2321
|
+
// Bytes (note KB vs KiB).
|
|
2322
|
+
Gigabyte: createFormat({
|
|
2323
|
+
symbol: "GB",
|
|
2324
|
+
quotient: 1e3 * 1e3 * 1e3,
|
|
2325
|
+
precision: 2
|
|
2326
|
+
}),
|
|
2327
|
+
Megabyte: createFormat({
|
|
2328
|
+
symbol: "MB",
|
|
2329
|
+
quotient: 1e3 * 1e3,
|
|
2330
|
+
precision: 2
|
|
2331
|
+
}),
|
|
2332
|
+
Kilobyte: createFormat({
|
|
2333
|
+
symbol: "KB",
|
|
2334
|
+
quotient: 1e3,
|
|
2335
|
+
precision: 2
|
|
2336
|
+
}),
|
|
2337
|
+
Byte: createFormat({
|
|
2338
|
+
symbol: "B",
|
|
2339
|
+
quotient: 1
|
|
2340
|
+
}),
|
|
2341
|
+
// Time.
|
|
2342
|
+
Hour: createFormat({
|
|
2242
2343
|
symbol: "h",
|
|
2243
|
-
quotient:
|
|
2344
|
+
quotient: MS_HOURS
|
|
2244
2345
|
}),
|
|
2245
|
-
Minute:
|
|
2346
|
+
Minute: createFormat({
|
|
2246
2347
|
symbol: "m",
|
|
2247
|
-
quotient:
|
|
2348
|
+
quotient: MS_MINUTES
|
|
2248
2349
|
}),
|
|
2249
|
-
Second:
|
|
2350
|
+
Second: createFormat({
|
|
2250
2351
|
symbol: "s",
|
|
2251
|
-
quotient:
|
|
2352
|
+
quotient: MS_SECONDS,
|
|
2353
|
+
precision: 1
|
|
2252
2354
|
}),
|
|
2253
|
-
Millisecond:
|
|
2355
|
+
Millisecond: createFormat({
|
|
2254
2356
|
symbol: "ms",
|
|
2255
2357
|
quotient: 1
|
|
2256
2358
|
}),
|
|
2257
2359
|
Duration: (n) => {
|
|
2258
|
-
const hours = Math.floor(n /
|
|
2259
|
-
const minutes = Math.floor(n %
|
|
2360
|
+
const hours = Math.floor(n / MS_HOURS);
|
|
2361
|
+
const minutes = Math.floor(n % MS_HOURS / MS_MINUTES);
|
|
2260
2362
|
if (hours) {
|
|
2261
|
-
|
|
2363
|
+
const formattedValue = minutes ? `${hours}h ${minutes}m` : `${hours}h`;
|
|
2364
|
+
return {
|
|
2365
|
+
unit: {
|
|
2366
|
+
symbol: "h",
|
|
2367
|
+
quotient: MS_HOURS
|
|
2368
|
+
},
|
|
2369
|
+
value: hours,
|
|
2370
|
+
formattedValue,
|
|
2371
|
+
toString: () => formattedValue
|
|
2372
|
+
};
|
|
2262
2373
|
}
|
|
2263
|
-
const seconds = Math.floor(n % (60 * 1e3) / 1e3);
|
|
2264
2374
|
if (minutes) {
|
|
2265
|
-
|
|
2375
|
+
const seconds2 = (n - MS_MINUTES * minutes) / MS_SECONDS;
|
|
2376
|
+
const formattedValue = seconds2 ? `${minutes}m ${seconds2}s` : `${minutes}m`;
|
|
2377
|
+
return {
|
|
2378
|
+
unit: {
|
|
2379
|
+
symbol: "m",
|
|
2380
|
+
quotient: MS_MINUTES
|
|
2381
|
+
},
|
|
2382
|
+
value: minutes,
|
|
2383
|
+
formattedValue,
|
|
2384
|
+
toString: () => formattedValue
|
|
2385
|
+
};
|
|
2266
2386
|
}
|
|
2387
|
+
const seconds = n >= MS_SECONDS;
|
|
2267
2388
|
if (seconds) {
|
|
2268
|
-
return
|
|
2389
|
+
return Unit.Second(n);
|
|
2269
2390
|
}
|
|
2270
|
-
return
|
|
2271
|
-
}
|
|
2272
|
-
// bytes (note KB via KiB).
|
|
2273
|
-
Gigabyte: Formatter({
|
|
2274
|
-
symbol: "GB",
|
|
2275
|
-
quotient: 1e3 * 1e3 * 1e3
|
|
2276
|
-
}),
|
|
2277
|
-
Megabyte: Formatter({
|
|
2278
|
-
symbol: "MB",
|
|
2279
|
-
quotient: 1e3 * 1e3
|
|
2280
|
-
}),
|
|
2281
|
-
Kilobyte: Formatter({
|
|
2282
|
-
symbol: "KB",
|
|
2283
|
-
quotient: 1e3
|
|
2284
|
-
}),
|
|
2285
|
-
// general.
|
|
2286
|
-
Thousand: Formatter({
|
|
2287
|
-
symbol: "k",
|
|
2288
|
-
quotient: 1e3
|
|
2289
|
-
}),
|
|
2290
|
-
Percent: Formatter({
|
|
2291
|
-
symbol: "%",
|
|
2292
|
-
quotient: 1 / 100
|
|
2293
|
-
})
|
|
2391
|
+
return Unit.Millisecond(n);
|
|
2392
|
+
}
|
|
2294
2393
|
};
|
|
2295
2394
|
|
|
2296
2395
|
// src/url.ts
|
|
@@ -2303,20 +2402,22 @@ var createUrl = (url, search) => {
|
|
|
2303
2402
|
};
|
|
2304
2403
|
|
|
2305
2404
|
// src/weak.ts
|
|
2306
|
-
function _define_property10(obj, key, value) {
|
|
2307
|
-
if (key in obj) {
|
|
2308
|
-
Object.defineProperty(obj, key, {
|
|
2309
|
-
value,
|
|
2310
|
-
enumerable: true,
|
|
2311
|
-
configurable: true,
|
|
2312
|
-
writable: true
|
|
2313
|
-
});
|
|
2314
|
-
} else {
|
|
2315
|
-
obj[key] = value;
|
|
2316
|
-
}
|
|
2317
|
-
return obj;
|
|
2318
|
-
}
|
|
2319
2405
|
var WeakDictionary = class {
|
|
2406
|
+
_internal = /* @__PURE__ */ new Map();
|
|
2407
|
+
_finalization = new FinalizationRegistry(({ key, ref }) => {
|
|
2408
|
+
if (this._internal.get(key) === ref) {
|
|
2409
|
+
this._internal.delete(key);
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
constructor(entries2) {
|
|
2413
|
+
if (entries2) {
|
|
2414
|
+
for (const [key, value] of entries2) {
|
|
2415
|
+
const ref = new WeakRef(value);
|
|
2416
|
+
this._internal.set(key, ref);
|
|
2417
|
+
this._register(key, value, ref);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2320
2421
|
*entries() {
|
|
2321
2422
|
for (const [key, value] of this._internal) {
|
|
2322
2423
|
yield [
|
|
@@ -2355,10 +2456,45 @@ var WeakDictionary = class {
|
|
|
2355
2456
|
return this._internal.get(key)?.deref();
|
|
2356
2457
|
}
|
|
2357
2458
|
set(key, value) {
|
|
2358
|
-
this._internal.
|
|
2359
|
-
|
|
2459
|
+
const previous = this._internal.get(key)?.deref();
|
|
2460
|
+
if (previous) {
|
|
2461
|
+
this._unregister(previous);
|
|
2462
|
+
}
|
|
2463
|
+
const ref = new WeakRef(value);
|
|
2464
|
+
this._internal.set(key, ref);
|
|
2465
|
+
this._register(key, value, ref);
|
|
2360
2466
|
return this;
|
|
2361
2467
|
}
|
|
2468
|
+
/**
|
|
2469
|
+
* Returns the value for the given key if present, otherwise inserts and returns the default value.
|
|
2470
|
+
* @param key - The key to look up or insert.
|
|
2471
|
+
* @param defaultValue - The value to insert if the key is not present.
|
|
2472
|
+
* @returns The existing or newly inserted value.
|
|
2473
|
+
*/
|
|
2474
|
+
getOrInsert(key, defaultValue) {
|
|
2475
|
+
const existing = this.get(key);
|
|
2476
|
+
if (existing !== void 0) {
|
|
2477
|
+
return existing;
|
|
2478
|
+
}
|
|
2479
|
+
this.set(key, defaultValue);
|
|
2480
|
+
return defaultValue;
|
|
2481
|
+
}
|
|
2482
|
+
/**
|
|
2483
|
+
* Returns the value for the given key if present, otherwise computes, inserts, and returns a new value.
|
|
2484
|
+
* The callback is only invoked when the key is missing.
|
|
2485
|
+
* @param key - The key to look up or insert.
|
|
2486
|
+
* @param callbackfn - Function to compute the value if the key is not present.
|
|
2487
|
+
* @returns The existing or newly computed value.
|
|
2488
|
+
*/
|
|
2489
|
+
getOrInsertComputed(key, callbackfn) {
|
|
2490
|
+
const existing = this.get(key);
|
|
2491
|
+
if (existing !== void 0) {
|
|
2492
|
+
return existing;
|
|
2493
|
+
}
|
|
2494
|
+
const value = callbackfn(key);
|
|
2495
|
+
this.set(key, value);
|
|
2496
|
+
return value;
|
|
2497
|
+
}
|
|
2362
2498
|
has(key) {
|
|
2363
2499
|
return this._internal.has(key) && this._internal.get(key).deref() !== void 0;
|
|
2364
2500
|
}
|
|
@@ -2389,25 +2525,15 @@ var WeakDictionary = class {
|
|
|
2389
2525
|
}
|
|
2390
2526
|
});
|
|
2391
2527
|
}
|
|
2392
|
-
_register(key, value) {
|
|
2393
|
-
this._finalization.register(value,
|
|
2394
|
-
|
|
2528
|
+
_register(key, value, ref) {
|
|
2529
|
+
this._finalization.register(value, {
|
|
2530
|
+
key,
|
|
2531
|
+
ref
|
|
2395
2532
|
}, value);
|
|
2396
2533
|
}
|
|
2397
2534
|
_unregister(value) {
|
|
2398
2535
|
this._finalization.unregister(value);
|
|
2399
2536
|
}
|
|
2400
|
-
constructor(entries2) {
|
|
2401
|
-
_define_property10(this, "_internal", /* @__PURE__ */ new Map());
|
|
2402
|
-
_define_property10(this, "_finalization", new FinalizationRegistry((cleanUpCallback) => {
|
|
2403
|
-
cleanUpCallback();
|
|
2404
|
-
}));
|
|
2405
|
-
this._internal = new Map(entries2?.map(([key, value]) => [
|
|
2406
|
-
key,
|
|
2407
|
-
new WeakRef(value)
|
|
2408
|
-
]));
|
|
2409
|
-
entries2?.forEach(([key, value]) => this._register(key, value));
|
|
2410
|
-
}
|
|
2411
2537
|
};
|
|
2412
2538
|
export {
|
|
2413
2539
|
BitField,
|
|
@@ -2418,12 +2544,14 @@ export {
|
|
|
2418
2544
|
ComplexSet,
|
|
2419
2545
|
HumanHasher,
|
|
2420
2546
|
MapEntry,
|
|
2547
|
+
SKIP,
|
|
2421
2548
|
SlidingWindowSummary,
|
|
2422
2549
|
Tracer,
|
|
2423
2550
|
Unit,
|
|
2424
2551
|
WeakDictionary,
|
|
2425
2552
|
accessBy,
|
|
2426
2553
|
arrayMove,
|
|
2554
|
+
arraySwap,
|
|
2427
2555
|
arrayToBuffer,
|
|
2428
2556
|
arrayToHex,
|
|
2429
2557
|
arrayToString,
|
|
@@ -2434,19 +2562,29 @@ export {
|
|
|
2434
2562
|
capitalize,
|
|
2435
2563
|
chunkArray,
|
|
2436
2564
|
clamp,
|
|
2565
|
+
clearCaches,
|
|
2566
|
+
clearIndexedDB,
|
|
2567
|
+
clearOPFS,
|
|
2568
|
+
clearServiceWorkers,
|
|
2437
2569
|
clearUndefined,
|
|
2570
|
+
coerceArray,
|
|
2438
2571
|
compareMulti,
|
|
2439
2572
|
compareObject,
|
|
2440
2573
|
compareScalar,
|
|
2441
2574
|
compareString,
|
|
2575
|
+
compositeKey,
|
|
2442
2576
|
createBinder,
|
|
2443
2577
|
createBucketReducer,
|
|
2578
|
+
createFilename,
|
|
2444
2579
|
createGroupReducer,
|
|
2580
|
+
createReplacer,
|
|
2445
2581
|
createSetDispatch,
|
|
2446
2582
|
createUrl,
|
|
2447
2583
|
decamelize,
|
|
2584
|
+
decodeUint8ArrayFromJson,
|
|
2448
2585
|
deepMapValues,
|
|
2449
2586
|
deepMapValuesAsync,
|
|
2587
|
+
defaultFilter,
|
|
2450
2588
|
defaultMap,
|
|
2451
2589
|
defer,
|
|
2452
2590
|
deferAsync,
|
|
@@ -2454,11 +2592,12 @@ export {
|
|
|
2454
2592
|
diff,
|
|
2455
2593
|
distinctBy,
|
|
2456
2594
|
doAsync,
|
|
2595
|
+
encodeUint8ArrayToJson,
|
|
2457
2596
|
entries,
|
|
2458
2597
|
entry,
|
|
2459
2598
|
exponentialBackoffInterval,
|
|
2460
2599
|
forEachAsync,
|
|
2461
|
-
|
|
2600
|
+
formatErrorWithCauses,
|
|
2462
2601
|
getAsyncProviderValue,
|
|
2463
2602
|
getDate,
|
|
2464
2603
|
getDebugName,
|
|
@@ -2471,16 +2610,25 @@ export {
|
|
|
2471
2610
|
hexToHue,
|
|
2472
2611
|
humanize,
|
|
2473
2612
|
hyphenize,
|
|
2613
|
+
id,
|
|
2474
2614
|
idEmoji,
|
|
2475
2615
|
idHue,
|
|
2476
2616
|
inferObjectOrder,
|
|
2477
2617
|
inferRecordOrder,
|
|
2618
|
+
inline,
|
|
2478
2619
|
intersectBy,
|
|
2479
2620
|
intersection,
|
|
2480
2621
|
iosCheck,
|
|
2622
|
+
isBun,
|
|
2623
|
+
isEncodedUint8Array,
|
|
2624
|
+
isMobile,
|
|
2625
|
+
isMobileOrTablet,
|
|
2481
2626
|
isNode,
|
|
2482
2627
|
isNonNullable,
|
|
2628
|
+
isTauri,
|
|
2483
2629
|
isTruthy,
|
|
2630
|
+
isWellFormedId,
|
|
2631
|
+
isWellFormedIdPart,
|
|
2484
2632
|
joinTables,
|
|
2485
2633
|
jsonKeyReplacer,
|
|
2486
2634
|
jsonReplacer,
|
|
@@ -2495,7 +2643,6 @@ export {
|
|
|
2495
2643
|
makeSet,
|
|
2496
2644
|
mapValues,
|
|
2497
2645
|
median,
|
|
2498
|
-
mobileAndTabletCheck,
|
|
2499
2646
|
numericalValues,
|
|
2500
2647
|
omit,
|
|
2501
2648
|
orderKeys,
|
|
@@ -2511,15 +2658,18 @@ export {
|
|
|
2511
2658
|
removeBy,
|
|
2512
2659
|
removeProperties,
|
|
2513
2660
|
removeUndefinedProperties,
|
|
2661
|
+
retry,
|
|
2514
2662
|
safariCheck,
|
|
2515
2663
|
safeAwaitAll,
|
|
2516
2664
|
safeInstanceof,
|
|
2517
2665
|
safeParseFloat,
|
|
2518
2666
|
safeParseInt,
|
|
2519
2667
|
safeParseJson,
|
|
2520
|
-
|
|
2668
|
+
safeStringify,
|
|
2669
|
+
safeUrl,
|
|
2521
2670
|
setDeep,
|
|
2522
2671
|
sortKeys,
|
|
2672
|
+
splitCompositeKey,
|
|
2523
2673
|
stringToArray,
|
|
2524
2674
|
stringifyTree,
|
|
2525
2675
|
stripUndefined,
|