@dxos/util 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +341 -417
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +341 -417
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +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/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/safe-stringify.d.ts +13 -0
- package/dist/types/src/safe-stringify.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +4 -0
- package/dist/types/src/types.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/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/binder.ts +2 -2
- package/src/error-format.ts +22 -0
- package/src/index.ts +2 -0
- package/src/safe-stringify.ts +104 -0
- package/src/types.ts +8 -1
- package/src/unit.test.ts +1 -1
- package/src/unit.ts +59 -28
|
@@ -103,10 +103,10 @@ function assumeType(value) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
// src/binder.ts
|
|
106
|
-
import
|
|
106
|
+
import { promisify } from "@dxos/node-std/util";
|
|
107
107
|
var createBinder = (obj) => ({
|
|
108
108
|
fn: (fn) => fn.bind(obj),
|
|
109
|
-
async: (fn) =>
|
|
109
|
+
async: (fn) => promisify(fn.bind(obj))
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
// src/bitfield.ts
|
|
@@ -180,92 +180,34 @@ var BitField = class _BitField {
|
|
|
180
180
|
};
|
|
181
181
|
|
|
182
182
|
// src/callback-collection.ts
|
|
183
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
184
|
-
if (privateCollection.has(obj)) {
|
|
185
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
189
|
-
if (descriptor.get) {
|
|
190
|
-
return descriptor.get.call(receiver);
|
|
191
|
-
}
|
|
192
|
-
return descriptor.value;
|
|
193
|
-
}
|
|
194
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
195
|
-
if (descriptor.set) {
|
|
196
|
-
descriptor.set.call(receiver, value);
|
|
197
|
-
} else {
|
|
198
|
-
if (!descriptor.writable) {
|
|
199
|
-
throw new TypeError("attempted to set read only private field");
|
|
200
|
-
}
|
|
201
|
-
descriptor.value = value;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
205
|
-
if (!privateMap.has(receiver)) {
|
|
206
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
207
|
-
}
|
|
208
|
-
return privateMap.get(receiver);
|
|
209
|
-
}
|
|
210
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
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();
|
|
224
183
|
var CallbackCollection = class {
|
|
184
|
+
#callbacks = [];
|
|
225
185
|
append(callback) {
|
|
226
|
-
|
|
186
|
+
this.#callbacks.push(callback);
|
|
227
187
|
}
|
|
228
188
|
prepend(callback) {
|
|
229
|
-
|
|
189
|
+
this.#callbacks.unshift(callback);
|
|
230
190
|
}
|
|
231
191
|
remove(callback) {
|
|
232
|
-
|
|
192
|
+
this.#callbacks = this.#callbacks.filter((c) => c !== callback);
|
|
233
193
|
}
|
|
234
194
|
callParallel(...args) {
|
|
235
|
-
return Promise.all(
|
|
195
|
+
return Promise.all(this.#callbacks.map((callback) => callback(...args)));
|
|
236
196
|
}
|
|
237
197
|
async callSerial(...args) {
|
|
238
198
|
const results = [];
|
|
239
|
-
for (const callback of
|
|
199
|
+
for (const callback of this.#callbacks) {
|
|
240
200
|
results.push(await callback(...args));
|
|
241
201
|
}
|
|
242
202
|
return results;
|
|
243
203
|
}
|
|
244
|
-
constructor() {
|
|
245
|
-
_class_private_field_init(this, _callbacks, {
|
|
246
|
-
writable: true,
|
|
247
|
-
value: []
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
204
|
};
|
|
251
205
|
|
|
252
206
|
// src/callback.ts
|
|
253
207
|
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
208
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/util/src/callback.ts";
|
|
268
209
|
var Callback = class {
|
|
210
|
+
_callback;
|
|
269
211
|
call(...args) {
|
|
270
212
|
invariant2(this._callback, "Callback not set", {
|
|
271
213
|
F: __dxlog_file2,
|
|
@@ -296,9 +238,6 @@ var Callback = class {
|
|
|
296
238
|
isSet() {
|
|
297
239
|
return !!this._callback;
|
|
298
240
|
}
|
|
299
|
-
constructor() {
|
|
300
|
-
_define_property(this, "_callback", void 0);
|
|
301
|
-
}
|
|
302
241
|
};
|
|
303
242
|
var createSetDispatch = ({ handlers }) => {
|
|
304
243
|
return new Proxy({
|
|
@@ -361,21 +300,23 @@ var chunkArray = (array, size) => {
|
|
|
361
300
|
|
|
362
301
|
// src/circular-buffer.ts
|
|
363
302
|
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
303
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/util/src/circular-buffer.ts";
|
|
378
304
|
var CircularBuffer = class {
|
|
305
|
+
_buffer;
|
|
306
|
+
_nextIndex = 0;
|
|
307
|
+
_elementCount = 0;
|
|
308
|
+
constructor(size) {
|
|
309
|
+
invariant3(size >= 1, void 0, {
|
|
310
|
+
F: __dxlog_file3,
|
|
311
|
+
L: 13,
|
|
312
|
+
S: this,
|
|
313
|
+
A: [
|
|
314
|
+
"size >= 1",
|
|
315
|
+
""
|
|
316
|
+
]
|
|
317
|
+
});
|
|
318
|
+
this._buffer = new Array(size);
|
|
319
|
+
}
|
|
379
320
|
push(element) {
|
|
380
321
|
const evicted = this._elementCount === this._buffer.length ? this._buffer[this._nextIndex] : void 0;
|
|
381
322
|
this._buffer[this._nextIndex] = element;
|
|
@@ -415,21 +356,6 @@ var CircularBuffer = class {
|
|
|
415
356
|
yield this._buffer[i];
|
|
416
357
|
}
|
|
417
358
|
}
|
|
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
359
|
};
|
|
434
360
|
|
|
435
361
|
// src/clear-undefined.ts
|
|
@@ -448,22 +374,19 @@ var clearUndefined = (obj) => {
|
|
|
448
374
|
// src/complex.ts
|
|
449
375
|
import { inspect } from "@dxos/node-std/util";
|
|
450
376
|
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
377
|
var MAX_SERIALIZATION_LENGTH = 10;
|
|
465
|
-
var _inspect_custom = inspect.custom;
|
|
466
378
|
var ComplexSet = class {
|
|
379
|
+
_projection;
|
|
380
|
+
_values = /* @__PURE__ */ new Map();
|
|
381
|
+
// prettier-ignore
|
|
382
|
+
constructor(_projection, values) {
|
|
383
|
+
this._projection = _projection;
|
|
384
|
+
if (values) {
|
|
385
|
+
for (const value of values) {
|
|
386
|
+
this.add(value);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
467
390
|
toString() {
|
|
468
391
|
return inspectObject(this);
|
|
469
392
|
}
|
|
@@ -472,7 +395,7 @@ var ComplexSet = class {
|
|
|
472
395
|
size: this._values.size
|
|
473
396
|
} : Array.from(this._values.values());
|
|
474
397
|
}
|
|
475
|
-
[
|
|
398
|
+
[inspect.custom]() {
|
|
476
399
|
return inspectObject(this);
|
|
477
400
|
}
|
|
478
401
|
add(value) {
|
|
@@ -538,18 +461,6 @@ var ComplexSet = class {
|
|
|
538
461
|
isDisjointFrom(other) {
|
|
539
462
|
throw new Error("Method not implemented.");
|
|
540
463
|
}
|
|
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
464
|
};
|
|
554
465
|
var makeSet = (projection) => {
|
|
555
466
|
return class BoundComplexSet extends ComplexSet {
|
|
@@ -558,8 +469,19 @@ var makeSet = (projection) => {
|
|
|
558
469
|
}
|
|
559
470
|
};
|
|
560
471
|
};
|
|
561
|
-
var _inspect_custom1 = inspect.custom;
|
|
562
472
|
var ComplexMap = class _ComplexMap {
|
|
473
|
+
_keyProjection;
|
|
474
|
+
_keys = /* @__PURE__ */ new Map();
|
|
475
|
+
_values = /* @__PURE__ */ new Map();
|
|
476
|
+
// prettier-ignore
|
|
477
|
+
constructor(_keyProjection, entries2) {
|
|
478
|
+
this._keyProjection = _keyProjection;
|
|
479
|
+
if (entries2) {
|
|
480
|
+
for (const [key, value] of entries2) {
|
|
481
|
+
this.set(key, value);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
563
485
|
toString() {
|
|
564
486
|
return inspectObject(this);
|
|
565
487
|
}
|
|
@@ -568,7 +490,7 @@ var ComplexMap = class _ComplexMap {
|
|
|
568
490
|
size: this._values.size
|
|
569
491
|
} : Array.from(this._values.values());
|
|
570
492
|
}
|
|
571
|
-
[
|
|
493
|
+
[inspect.custom]() {
|
|
572
494
|
return inspectObject(this);
|
|
573
495
|
}
|
|
574
496
|
clear() {
|
|
@@ -630,28 +552,11 @@ var ComplexMap = class _ComplexMap {
|
|
|
630
552
|
get [Symbol.toStringTag]() {
|
|
631
553
|
return "ComplexMap";
|
|
632
554
|
}
|
|
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
555
|
};
|
|
648
|
-
var makeMap = (keyProjection) => {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
super(keyProjection, entries2);
|
|
652
|
-
}
|
|
556
|
+
var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
|
|
557
|
+
constructor(entries2) {
|
|
558
|
+
super(keyProjection, entries2);
|
|
653
559
|
}
|
|
654
|
-
return BoundComplexMap;
|
|
655
560
|
};
|
|
656
561
|
|
|
657
562
|
// src/deep.ts
|
|
@@ -691,72 +596,50 @@ var getDeep = (obj, path) => {
|
|
|
691
596
|
// src/defer-function.ts
|
|
692
597
|
var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
|
|
693
598
|
|
|
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
599
|
// src/defer.ts
|
|
701
|
-
function _define_property4(obj, key, value) {
|
|
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
|
-
}
|
|
714
600
|
var defer = (fn) => new DeferGuard(fn);
|
|
715
601
|
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
|
-
}
|
|
602
|
+
_fn;
|
|
722
603
|
/**
|
|
723
604
|
* @internal
|
|
724
605
|
*/
|
|
725
606
|
constructor(_fn) {
|
|
726
|
-
_define_property4(this, "_fn", void 0);
|
|
727
607
|
this._fn = _fn;
|
|
728
608
|
}
|
|
609
|
+
[Symbol.dispose]() {
|
|
610
|
+
const result = this._fn();
|
|
611
|
+
if (result instanceof Promise) {
|
|
612
|
+
throw new Error("Async functions in defer are not supported. Use deferAsync instead.");
|
|
613
|
+
}
|
|
614
|
+
}
|
|
729
615
|
};
|
|
730
616
|
var deferAsync = (fn) => new DeferAsyncGuard(fn);
|
|
731
617
|
var DeferAsyncGuard = class {
|
|
732
|
-
|
|
733
|
-
await this._fn();
|
|
734
|
-
}
|
|
618
|
+
_fn;
|
|
735
619
|
/**
|
|
736
620
|
* @internal
|
|
737
621
|
*/
|
|
738
622
|
constructor(_fn) {
|
|
739
|
-
_define_property4(this, "_fn", void 0);
|
|
740
623
|
this._fn = _fn;
|
|
741
624
|
}
|
|
625
|
+
async [Symbol.asyncDispose]() {
|
|
626
|
+
await this._fn();
|
|
627
|
+
}
|
|
742
628
|
};
|
|
743
629
|
|
|
744
630
|
// 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
631
|
var entry = (map, key) => new MapEntry(map, key);
|
|
759
632
|
var MapEntry = class {
|
|
633
|
+
_map;
|
|
634
|
+
_key;
|
|
635
|
+
/**
|
|
636
|
+
* @internal
|
|
637
|
+
*/
|
|
638
|
+
// prettier-ignore
|
|
639
|
+
constructor(_map, _key) {
|
|
640
|
+
this._map = _map;
|
|
641
|
+
this._key = _key;
|
|
642
|
+
}
|
|
760
643
|
get key() {
|
|
761
644
|
return this._key;
|
|
762
645
|
}
|
|
@@ -772,16 +655,6 @@ var MapEntry = class {
|
|
|
772
655
|
deep(key) {
|
|
773
656
|
return entry(this.value, key);
|
|
774
657
|
}
|
|
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
658
|
};
|
|
786
659
|
|
|
787
660
|
// src/for-each-async.ts
|
|
@@ -789,19 +662,6 @@ var forEachAsync = (items, fn) => Promise.all(items.map(fn));
|
|
|
789
662
|
|
|
790
663
|
// src/human-hash.ts
|
|
791
664
|
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
665
|
var DEFAULT_WORDLIST = [
|
|
806
666
|
"ack",
|
|
807
667
|
"alabama",
|
|
@@ -1061,6 +921,27 @@ var DEFAULT_WORDLIST = [
|
|
|
1061
921
|
"zulu"
|
|
1062
922
|
];
|
|
1063
923
|
var HumanHasher = class {
|
|
924
|
+
wordlist;
|
|
925
|
+
/**
|
|
926
|
+
* Transforms hex digests to human-readable strings.
|
|
927
|
+
*
|
|
928
|
+
* The format of these strings will look something like:
|
|
929
|
+
* `victor-bacon-zulu-lima`. The output is obtained by compressing the input
|
|
930
|
+
* digest to a fixed number of bytes, then mapping those bytes to one of 256
|
|
931
|
+
* words. A default wordlist is provided, but you can override this if you
|
|
932
|
+
* prefer.
|
|
933
|
+
* As long as you use the same wordlist, the output will be consistent (i.e.
|
|
934
|
+
* the same digest will always render the same representation).
|
|
935
|
+
*
|
|
936
|
+
* @param wordlist A list of exactly 256 words to choose from
|
|
937
|
+
*/
|
|
938
|
+
constructor(wordlist = DEFAULT_WORDLIST) {
|
|
939
|
+
this.wordlist = wordlist;
|
|
940
|
+
if (wordlist.length !== 256) {
|
|
941
|
+
throw new Error("Wordlist must have exactly 256 items");
|
|
942
|
+
}
|
|
943
|
+
this.wordlist = wordlist;
|
|
944
|
+
}
|
|
1064
945
|
/**
|
|
1065
946
|
* Humanize a given hexadecimal digest.
|
|
1066
947
|
*
|
|
@@ -1100,27 +981,6 @@ var HumanHasher = class {
|
|
|
1100
981
|
const checksums = segments.map((x) => x.reduce((acc, curr) => acc ^ curr));
|
|
1101
982
|
return checksums;
|
|
1102
983
|
}
|
|
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
984
|
};
|
|
1125
985
|
var hasher = new HumanHasher();
|
|
1126
986
|
var humanize = (value) => {
|
|
@@ -1143,10 +1003,8 @@ var defaultMap = (map, key, def) => {
|
|
|
1143
1003
|
};
|
|
1144
1004
|
|
|
1145
1005
|
// src/instance-id.ts
|
|
1146
|
-
var _globalThis;
|
|
1147
|
-
var _symbol;
|
|
1148
1006
|
var symbol = Symbol.for("dxos.instance-contexts");
|
|
1149
|
-
var instanceContexts =
|
|
1007
|
+
var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
|
|
1150
1008
|
var getPrototypeSpecificInstanceId = (instance) => {
|
|
1151
1009
|
const prototype = Object.getPrototypeOf(instance);
|
|
1152
1010
|
const instanceCtx = defaultMap(instanceContexts, prototype, () => ({
|
|
@@ -1318,19 +1176,6 @@ var jsonKeyReplacer = (options = {}) => (key, value) => {
|
|
|
1318
1176
|
};
|
|
1319
1177
|
|
|
1320
1178
|
// 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
1179
|
var mapValues = (obj, fn) => {
|
|
1335
1180
|
const result = {};
|
|
1336
1181
|
Object.keys(obj).forEach((key) => {
|
|
@@ -1342,6 +1187,11 @@ var deepMapValues = (value, fn) => {
|
|
|
1342
1187
|
return new DeepMapper(fn).map(value);
|
|
1343
1188
|
};
|
|
1344
1189
|
var DeepMapper = class {
|
|
1190
|
+
_fn;
|
|
1191
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1192
|
+
constructor(_fn) {
|
|
1193
|
+
this._fn = _fn;
|
|
1194
|
+
}
|
|
1345
1195
|
map(value) {
|
|
1346
1196
|
return this._map(value, void 0);
|
|
1347
1197
|
}
|
|
@@ -1351,40 +1201,38 @@ var DeepMapper = class {
|
|
|
1351
1201
|
}
|
|
1352
1202
|
return this._fn(value, this._recurse, key);
|
|
1353
1203
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1204
|
+
_recurse = (value) => {
|
|
1205
|
+
if (this._cyclic.has(value)) {
|
|
1206
|
+
return this._cyclic.get(value);
|
|
1207
|
+
}
|
|
1208
|
+
if (Array.isArray(value)) {
|
|
1209
|
+
const res = new Array(value.length);
|
|
1210
|
+
this._cyclic.set(value, res);
|
|
1211
|
+
for (let i = 0; i < value.length; i++) {
|
|
1212
|
+
res[i] = this._map(value[i], i);
|
|
1363
1213
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
return res;
|
|
1371
|
-
} else if (value !== null && typeof value === "object") {
|
|
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;
|
|
1214
|
+
return res;
|
|
1215
|
+
} else if (value !== null && typeof value === "object") {
|
|
1216
|
+
const res = {};
|
|
1217
|
+
this._cyclic.set(value, res);
|
|
1218
|
+
for (const key in value) {
|
|
1219
|
+
res[key] = this._map(value[key], key);
|
|
1380
1220
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1221
|
+
return res;
|
|
1222
|
+
} else {
|
|
1223
|
+
return value;
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1383
1226
|
};
|
|
1384
1227
|
var deepMapValuesAsync = (value, fn) => {
|
|
1385
1228
|
return new DeepMapperAsync(fn).map(value);
|
|
1386
1229
|
};
|
|
1387
1230
|
var DeepMapperAsync = class {
|
|
1231
|
+
_fn;
|
|
1232
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1233
|
+
constructor(_fn) {
|
|
1234
|
+
this._fn = _fn;
|
|
1235
|
+
}
|
|
1388
1236
|
map(value) {
|
|
1389
1237
|
return this._map(value, void 0);
|
|
1390
1238
|
}
|
|
@@ -1394,35 +1242,28 @@ var DeepMapperAsync = class {
|
|
|
1394
1242
|
}
|
|
1395
1243
|
return this._fn(value, this._recurse, key);
|
|
1396
1244
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1245
|
+
_recurse = async (value) => {
|
|
1246
|
+
if (this._cyclic.has(value)) {
|
|
1247
|
+
return this._cyclic.get(value);
|
|
1248
|
+
}
|
|
1249
|
+
if (Array.isArray(value)) {
|
|
1250
|
+
const res = new Array(value.length);
|
|
1251
|
+
this._cyclic.set(value, res);
|
|
1252
|
+
for (let i = 0; i < value.length; i++) {
|
|
1253
|
+
res[i] = await this._map(value[i], i);
|
|
1406
1254
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
return res;
|
|
1414
|
-
} else if (value !== null && typeof value === "object") {
|
|
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;
|
|
1255
|
+
return res;
|
|
1256
|
+
} else if (value !== null && typeof value === "object") {
|
|
1257
|
+
const res = {};
|
|
1258
|
+
this._cyclic.set(value, res);
|
|
1259
|
+
for (const key in value) {
|
|
1260
|
+
res[key] = await this._map(value[key], key);
|
|
1423
1261
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1262
|
+
return res;
|
|
1263
|
+
} else {
|
|
1264
|
+
return value;
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1426
1267
|
};
|
|
1427
1268
|
var visitValues = (object, visitor) => {
|
|
1428
1269
|
if (Array.isArray(object)) {
|
|
@@ -1765,23 +1606,95 @@ var safeParseJson = (data, defaultValue) => {
|
|
|
1765
1606
|
return defaultValue;
|
|
1766
1607
|
};
|
|
1767
1608
|
|
|
1768
|
-
// src/
|
|
1769
|
-
|
|
1770
|
-
function
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1609
|
+
// src/safe-stringify.ts
|
|
1610
|
+
var SKIP = Object.freeze({});
|
|
1611
|
+
function safeStringify(obj, filter = defaultFilter, indent = 2) {
|
|
1612
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
1613
|
+
function replacer(key, value) {
|
|
1614
|
+
if (typeof value === "object" && value !== null) {
|
|
1615
|
+
if (seen.has(value)) {
|
|
1616
|
+
return "[Circular]";
|
|
1617
|
+
}
|
|
1618
|
+
seen.add(value);
|
|
1619
|
+
}
|
|
1620
|
+
if (filter) {
|
|
1621
|
+
const v2 = filter?.(key, value);
|
|
1622
|
+
if (v2 !== void 0) {
|
|
1623
|
+
return v2 === SKIP ? void 0 : v2;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return value;
|
|
1780
1627
|
}
|
|
1781
|
-
|
|
1628
|
+
let result = "";
|
|
1629
|
+
try {
|
|
1630
|
+
result = JSON.stringify(obj, replacer, indent);
|
|
1631
|
+
} catch (error) {
|
|
1632
|
+
result = `Error: ${error.message}`;
|
|
1633
|
+
}
|
|
1634
|
+
return result;
|
|
1782
1635
|
}
|
|
1636
|
+
var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen } = {}) => {
|
|
1637
|
+
let currentDepth = 0;
|
|
1638
|
+
const depthMap = /* @__PURE__ */ new WeakMap();
|
|
1639
|
+
return function(key, value) {
|
|
1640
|
+
if (key === "") {
|
|
1641
|
+
currentDepth = 0;
|
|
1642
|
+
} else if (this && typeof this === "object") {
|
|
1643
|
+
const parentDepth = depthMap.get(this) ?? 0;
|
|
1644
|
+
currentDepth = parentDepth + 1;
|
|
1645
|
+
}
|
|
1646
|
+
if (typeof value === "function") {
|
|
1647
|
+
return void 0;
|
|
1648
|
+
}
|
|
1649
|
+
if (value && typeof value === "object") {
|
|
1650
|
+
depthMap.set(value, currentDepth);
|
|
1651
|
+
if (maxDepth != null && currentDepth >= maxDepth) {
|
|
1652
|
+
return Array.isArray(value) ? `[{ length: ${value.length} }]` : `{ keys: ${Object.keys(value).length} }`;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
if (omit2?.includes(key)) {
|
|
1656
|
+
return void 0;
|
|
1657
|
+
}
|
|
1658
|
+
if (parse?.includes(key) && typeof value === "string") {
|
|
1659
|
+
try {
|
|
1660
|
+
return JSON.parse(value);
|
|
1661
|
+
} catch {
|
|
1662
|
+
return value;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
if (maxArrayLen != null && Array.isArray(value) && value.length > maxArrayLen) {
|
|
1666
|
+
return `[length: ${value.length}]`;
|
|
1667
|
+
}
|
|
1668
|
+
if (maxStringLen != null && typeof value === "string" && value.length > maxStringLen) {
|
|
1669
|
+
return value.slice(0, maxStringLen) + "...";
|
|
1670
|
+
}
|
|
1671
|
+
return value;
|
|
1672
|
+
};
|
|
1673
|
+
};
|
|
1674
|
+
var defaultFilter = createReplacer();
|
|
1675
|
+
|
|
1676
|
+
// src/sliding-window-summary.ts
|
|
1677
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1783
1678
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
|
|
1784
1679
|
var SlidingWindowSummary = class {
|
|
1680
|
+
_buffer;
|
|
1681
|
+
_sum = 0;
|
|
1682
|
+
_precision;
|
|
1683
|
+
constructor(options) {
|
|
1684
|
+
this._buffer = new CircularBuffer(options.dataPoints);
|
|
1685
|
+
if (options.precision != null) {
|
|
1686
|
+
invariant5(options.precision >= 0, void 0, {
|
|
1687
|
+
F: __dxlog_file5,
|
|
1688
|
+
L: 26,
|
|
1689
|
+
S: this,
|
|
1690
|
+
A: [
|
|
1691
|
+
"options.precision >= 0",
|
|
1692
|
+
""
|
|
1693
|
+
]
|
|
1694
|
+
});
|
|
1695
|
+
this._precision = Math.pow(10, options.precision);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1785
1698
|
record(value) {
|
|
1786
1699
|
const evicted = this._buffer.push(value);
|
|
1787
1700
|
this._sum += value - (evicted ?? 0);
|
|
@@ -1816,24 +1729,6 @@ var SlidingWindowSummary = class {
|
|
|
1816
1729
|
}
|
|
1817
1730
|
return Math.round(value * this._precision) / this._precision;
|
|
1818
1731
|
}
|
|
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
1732
|
};
|
|
1838
1733
|
|
|
1839
1734
|
// src/sort.ts
|
|
@@ -2080,20 +1975,9 @@ var toFallback = (hash) => {
|
|
|
2080
1975
|
};
|
|
2081
1976
|
|
|
2082
1977
|
// 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
1978
|
var Tracer = class {
|
|
1979
|
+
_events = /* @__PURE__ */ new Map();
|
|
1980
|
+
_recording = false;
|
|
2097
1981
|
// TODO(burdon): Start/stop methods for recording data? By id?
|
|
2098
1982
|
// Alternatively, enable subscriptions to track/compute series.
|
|
2099
1983
|
// TODO(burdon): Hierarchical traces?
|
|
@@ -2150,10 +2034,6 @@ var Tracer = class {
|
|
|
2150
2034
|
defaultMap(this._events, event.id, []).push(event);
|
|
2151
2035
|
}
|
|
2152
2036
|
}
|
|
2153
|
-
constructor() {
|
|
2154
|
-
_define_property9(this, "_events", /* @__PURE__ */ new Map());
|
|
2155
|
-
_define_property9(this, "_recording", false);
|
|
2156
|
-
}
|
|
2157
2037
|
};
|
|
2158
2038
|
var tracer = new Tracer();
|
|
2159
2039
|
|
|
@@ -2230,67 +2110,104 @@ var arrayMove = (array, from, to) => {
|
|
|
2230
2110
|
};
|
|
2231
2111
|
|
|
2232
2112
|
// src/unit.ts
|
|
2233
|
-
var
|
|
2234
|
-
return (n, precision =
|
|
2113
|
+
var createFormat = (unit) => {
|
|
2114
|
+
return (n, precision = unit.precision ?? 0) => {
|
|
2235
2115
|
const value = n / unit.quotient;
|
|
2236
|
-
return
|
|
2116
|
+
return {
|
|
2117
|
+
unit,
|
|
2118
|
+
value,
|
|
2119
|
+
formattedValue: value.toFixed(precision),
|
|
2120
|
+
toString: () => `${value.toFixed(precision)}${unit.symbol}`
|
|
2121
|
+
};
|
|
2237
2122
|
};
|
|
2238
2123
|
};
|
|
2124
|
+
var MS_SECONDS = 1e3;
|
|
2125
|
+
var MS_MINUTES = 60 * MS_SECONDS;
|
|
2126
|
+
var MS_HOURS = 60 * MS_MINUTES;
|
|
2239
2127
|
var Unit = {
|
|
2240
|
-
//
|
|
2241
|
-
|
|
2128
|
+
// General.
|
|
2129
|
+
Percent: createFormat({
|
|
2130
|
+
symbol: "%",
|
|
2131
|
+
quotient: 1 / 100,
|
|
2132
|
+
precision: 2
|
|
2133
|
+
}),
|
|
2134
|
+
Thousand: createFormat({
|
|
2135
|
+
symbol: "k",
|
|
2136
|
+
quotient: 1e3,
|
|
2137
|
+
precision: 2
|
|
2138
|
+
}),
|
|
2139
|
+
// Bytes (note KB vs KiB).
|
|
2140
|
+
Gigabyte: createFormat({
|
|
2141
|
+
symbol: "GB",
|
|
2142
|
+
quotient: 1e3 * 1e3 * 1e3,
|
|
2143
|
+
precision: 2
|
|
2144
|
+
}),
|
|
2145
|
+
Megabyte: createFormat({
|
|
2146
|
+
symbol: "MB",
|
|
2147
|
+
quotient: 1e3 * 1e3,
|
|
2148
|
+
precision: 2
|
|
2149
|
+
}),
|
|
2150
|
+
Kilobyte: createFormat({
|
|
2151
|
+
symbol: "KB",
|
|
2152
|
+
quotient: 1e3,
|
|
2153
|
+
precision: 2
|
|
2154
|
+
}),
|
|
2155
|
+
Byte: createFormat({
|
|
2156
|
+
symbol: "B",
|
|
2157
|
+
quotient: 1
|
|
2158
|
+
}),
|
|
2159
|
+
// Time.
|
|
2160
|
+
Hour: createFormat({
|
|
2242
2161
|
symbol: "h",
|
|
2243
|
-
quotient:
|
|
2162
|
+
quotient: MS_HOURS
|
|
2244
2163
|
}),
|
|
2245
|
-
Minute:
|
|
2164
|
+
Minute: createFormat({
|
|
2246
2165
|
symbol: "m",
|
|
2247
|
-
quotient:
|
|
2166
|
+
quotient: MS_MINUTES
|
|
2248
2167
|
}),
|
|
2249
|
-
Second:
|
|
2168
|
+
Second: createFormat({
|
|
2250
2169
|
symbol: "s",
|
|
2251
|
-
quotient:
|
|
2170
|
+
quotient: MS_SECONDS,
|
|
2171
|
+
precision: 1
|
|
2252
2172
|
}),
|
|
2253
|
-
Millisecond:
|
|
2173
|
+
Millisecond: createFormat({
|
|
2254
2174
|
symbol: "ms",
|
|
2255
2175
|
quotient: 1
|
|
2256
2176
|
}),
|
|
2257
2177
|
Duration: (n) => {
|
|
2258
|
-
const hours = Math.floor(n /
|
|
2259
|
-
const minutes = Math.floor(n %
|
|
2178
|
+
const hours = Math.floor(n / MS_HOURS);
|
|
2179
|
+
const minutes = Math.floor(n % MS_HOURS / MS_MINUTES);
|
|
2260
2180
|
if (hours) {
|
|
2261
|
-
|
|
2181
|
+
const formattedValue = minutes ? `${hours}h ${minutes}m` : `${hours}h`;
|
|
2182
|
+
return {
|
|
2183
|
+
unit: {
|
|
2184
|
+
symbol: "h",
|
|
2185
|
+
quotient: MS_HOURS
|
|
2186
|
+
},
|
|
2187
|
+
value: hours,
|
|
2188
|
+
formattedValue,
|
|
2189
|
+
toString: () => formattedValue
|
|
2190
|
+
};
|
|
2262
2191
|
}
|
|
2263
|
-
const seconds = Math.floor(n % (60 * 1e3) / 1e3);
|
|
2264
2192
|
if (minutes) {
|
|
2265
|
-
|
|
2193
|
+
const seconds2 = (n - MS_MINUTES * minutes) / MS_SECONDS;
|
|
2194
|
+
const formattedValue = seconds2 ? `${minutes}m ${seconds2}s` : `${minutes}m`;
|
|
2195
|
+
return {
|
|
2196
|
+
unit: {
|
|
2197
|
+
symbol: "m",
|
|
2198
|
+
quotient: MS_MINUTES
|
|
2199
|
+
},
|
|
2200
|
+
value: minutes,
|
|
2201
|
+
formattedValue,
|
|
2202
|
+
toString: () => formattedValue
|
|
2203
|
+
};
|
|
2266
2204
|
}
|
|
2205
|
+
const seconds = n >= MS_SECONDS;
|
|
2267
2206
|
if (seconds) {
|
|
2268
|
-
return
|
|
2207
|
+
return Unit.Second(n);
|
|
2269
2208
|
}
|
|
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
|
-
})
|
|
2209
|
+
return Unit.Millisecond(n);
|
|
2210
|
+
}
|
|
2294
2211
|
};
|
|
2295
2212
|
|
|
2296
2213
|
// src/url.ts
|
|
@@ -2303,20 +2220,18 @@ var createUrl = (url, search) => {
|
|
|
2303
2220
|
};
|
|
2304
2221
|
|
|
2305
2222
|
// 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
2223
|
var WeakDictionary = class {
|
|
2224
|
+
_internal = /* @__PURE__ */ new Map();
|
|
2225
|
+
_finalization = new FinalizationRegistry((cleanUpCallback) => {
|
|
2226
|
+
cleanUpCallback();
|
|
2227
|
+
});
|
|
2228
|
+
constructor(entries2) {
|
|
2229
|
+
this._internal = new Map(entries2?.map(([key, value]) => [
|
|
2230
|
+
key,
|
|
2231
|
+
new WeakRef(value)
|
|
2232
|
+
]));
|
|
2233
|
+
entries2?.forEach(([key, value]) => this._register(key, value));
|
|
2234
|
+
}
|
|
2320
2235
|
*entries() {
|
|
2321
2236
|
for (const [key, value] of this._internal) {
|
|
2322
2237
|
yield [
|
|
@@ -2397,17 +2312,21 @@ var WeakDictionary = class {
|
|
|
2397
2312
|
_unregister(value) {
|
|
2398
2313
|
this._finalization.unregister(value);
|
|
2399
2314
|
}
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2315
|
+
};
|
|
2316
|
+
|
|
2317
|
+
// src/error-format.ts
|
|
2318
|
+
var formatErrorWithCauses = (error) => {
|
|
2319
|
+
const lines = [];
|
|
2320
|
+
let current = error;
|
|
2321
|
+
let level = 0;
|
|
2322
|
+
while (current) {
|
|
2323
|
+
const prefix = level === 0 ? "" : `Caused by: `;
|
|
2324
|
+
lines.push(prefix + (current.stack ?? String(current)));
|
|
2325
|
+
if (!(current.cause instanceof Error)) break;
|
|
2326
|
+
current = current.cause;
|
|
2327
|
+
level += 1;
|
|
2328
|
+
}
|
|
2329
|
+
return lines.join("\n\n");
|
|
2411
2330
|
};
|
|
2412
2331
|
export {
|
|
2413
2332
|
BitField,
|
|
@@ -2418,6 +2337,7 @@ export {
|
|
|
2418
2337
|
ComplexSet,
|
|
2419
2338
|
HumanHasher,
|
|
2420
2339
|
MapEntry,
|
|
2340
|
+
SKIP,
|
|
2421
2341
|
SlidingWindowSummary,
|
|
2422
2342
|
Tracer,
|
|
2423
2343
|
Unit,
|
|
@@ -2442,11 +2362,13 @@ export {
|
|
|
2442
2362
|
createBinder,
|
|
2443
2363
|
createBucketReducer,
|
|
2444
2364
|
createGroupReducer,
|
|
2365
|
+
createReplacer,
|
|
2445
2366
|
createSetDispatch,
|
|
2446
2367
|
createUrl,
|
|
2447
2368
|
decamelize,
|
|
2448
2369
|
deepMapValues,
|
|
2449
2370
|
deepMapValuesAsync,
|
|
2371
|
+
defaultFilter,
|
|
2450
2372
|
defaultMap,
|
|
2451
2373
|
defer,
|
|
2452
2374
|
deferAsync,
|
|
@@ -2458,6 +2380,7 @@ export {
|
|
|
2458
2380
|
entry,
|
|
2459
2381
|
exponentialBackoffInterval,
|
|
2460
2382
|
forEachAsync,
|
|
2383
|
+
formatErrorWithCauses,
|
|
2461
2384
|
get,
|
|
2462
2385
|
getAsyncProviderValue,
|
|
2463
2386
|
getDate,
|
|
@@ -2517,6 +2440,7 @@ export {
|
|
|
2517
2440
|
safeParseFloat,
|
|
2518
2441
|
safeParseInt,
|
|
2519
2442
|
safeParseJson,
|
|
2443
|
+
safeStringify,
|
|
2520
2444
|
set,
|
|
2521
2445
|
setDeep,
|
|
2522
2446
|
sortKeys,
|