@dxos/util 0.8.3 → 0.8.4-main.1da679c

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.
Files changed (58) hide show
  1. package/dist/lib/browser/index.mjs +492 -192
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +492 -192
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/array.d.ts.map +1 -1
  8. package/dist/types/src/assume.d.ts.map +1 -1
  9. package/dist/types/src/di-key.d.ts +3 -3
  10. package/dist/types/src/di-key.d.ts.map +1 -1
  11. package/dist/types/src/index.d.ts +3 -2
  12. package/dist/types/src/index.d.ts.map +1 -1
  13. package/dist/types/src/json.d.ts +1 -1
  14. package/dist/types/src/json.d.ts.map +1 -1
  15. package/dist/types/src/object.d.ts +3 -0
  16. package/dist/types/src/object.d.ts.map +1 -1
  17. package/dist/types/src/safe-parse.d.ts.map +1 -1
  18. package/dist/types/src/string.d.ts +4 -0
  19. package/dist/types/src/string.d.ts.map +1 -1
  20. package/dist/types/src/string.test.d.ts +2 -0
  21. package/dist/types/src/string.test.d.ts.map +1 -0
  22. package/dist/types/src/types.d.ts +1 -0
  23. package/dist/types/src/types.d.ts.map +1 -1
  24. package/dist/types/src/unit.d.ts +15 -0
  25. package/dist/types/src/unit.d.ts.map +1 -0
  26. package/dist/types/src/unit.test.d.ts +2 -0
  27. package/dist/types/src/unit.test.d.ts.map +1 -0
  28. package/dist/types/src/url.d.ts +5 -0
  29. package/dist/types/src/url.d.ts.map +1 -0
  30. package/dist/types/src/url.test.d.ts +2 -0
  31. package/dist/types/src/url.test.d.ts.map +1 -0
  32. package/dist/types/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +8 -8
  34. package/src/array.test.ts +1 -1
  35. package/src/array.ts +0 -2
  36. package/src/assume.ts +0 -1
  37. package/src/circular-buffer.test.ts +1 -1
  38. package/src/complex.test.ts +1 -1
  39. package/src/human-hash.test.ts +1 -1
  40. package/src/index.ts +3 -2
  41. package/src/json.ts +2 -7
  42. package/src/object.ts +3 -0
  43. package/src/position.test.ts +2 -2
  44. package/src/safe-parse.ts +6 -3
  45. package/src/sort.test.ts +1 -1
  46. package/src/string.test.ts +19 -0
  47. package/src/string.ts +29 -0
  48. package/src/tree.test.ts +1 -1
  49. package/src/types.ts +1 -0
  50. package/src/uint8array.test.ts +1 -1
  51. package/src/unit.test.ts +25 -0
  52. package/src/unit.ts +52 -0
  53. package/src/url.test.ts +22 -0
  54. package/src/url.ts +15 -0
  55. package/src/weak.test.ts +1 -1
  56. package/dist/lib/node/index.cjs +0 -2309
  57. package/dist/lib/node/index.cjs.map +0 -7
  58. package/dist/lib/node/meta.json +0 -1
@@ -1,6 +1,6 @@
1
1
  import "@dxos/node-std/globals";
2
2
 
3
- // packages/common/util/src/array-to-hex.ts
3
+ // src/array-to-hex.ts
4
4
  var byteToHex = [];
5
5
  for (let n = 0; n <= 255; ++n) {
6
6
  const hexOctet = n.toString(16).padStart(2, "0");
@@ -15,7 +15,7 @@ var arrayToHex = (buf) => {
15
15
  return hexOctets.join("");
16
16
  };
17
17
 
18
- // packages/common/util/src/array.ts
18
+ // src/array.ts
19
19
  var diff = (previous, next, comparator) => {
20
20
  const remaining = [
21
21
  ...previous
@@ -98,16 +98,20 @@ var intersectBy = (arrays, selector) => {
98
98
  });
99
99
  };
100
100
 
101
- // packages/common/util/src/binder.ts
101
+ // src/assume.ts
102
+ function assumeType(value) {
103
+ }
104
+
105
+ // src/binder.ts
102
106
  import util from "@dxos/node-std/util";
103
107
  var createBinder = (obj) => ({
104
108
  fn: (fn) => fn.bind(obj),
105
109
  async: (fn) => util.promisify(fn.bind(obj))
106
110
  });
107
111
 
108
- // packages/common/util/src/bitfield.ts
112
+ // src/bitfield.ts
109
113
  import { invariant } from "@dxos/invariant";
110
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/util/src/bitfield.ts";
114
+ var __dxlog_file = "/__w/dxos/dxos/packages/common/util/src/bitfield.ts";
111
115
  var BitField = class _BitField {
112
116
  static get(data, idx) {
113
117
  const bit = data[idx >> 3] >> 7 - idx % 8 & 1;
@@ -175,33 +179,92 @@ var BitField = class _BitField {
175
179
  }
176
180
  };
177
181
 
178
- // packages/common/util/src/callback-collection.ts
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();
179
224
  var CallbackCollection = class {
180
- #callbacks = [];
181
225
  append(callback) {
182
- this.#callbacks.push(callback);
226
+ _class_private_field_get(this, _callbacks).push(callback);
183
227
  }
184
228
  prepend(callback) {
185
- this.#callbacks.unshift(callback);
229
+ _class_private_field_get(this, _callbacks).unshift(callback);
186
230
  }
187
231
  remove(callback) {
188
- this.#callbacks = this.#callbacks.filter((c) => c !== callback);
232
+ _class_private_field_set(this, _callbacks, _class_private_field_get(this, _callbacks).filter((c) => c !== callback));
189
233
  }
190
234
  callParallel(...args) {
191
- return Promise.all(this.#callbacks.map((callback) => callback(...args)));
235
+ return Promise.all(_class_private_field_get(this, _callbacks).map((callback) => callback(...args)));
192
236
  }
193
237
  async callSerial(...args) {
194
238
  const results = [];
195
- for (const callback of this.#callbacks) {
239
+ for (const callback of _class_private_field_get(this, _callbacks)) {
196
240
  results.push(await callback(...args));
197
241
  }
198
242
  return results;
199
243
  }
244
+ constructor() {
245
+ _class_private_field_init(this, _callbacks, {
246
+ writable: true,
247
+ value: []
248
+ });
249
+ }
200
250
  };
201
251
 
202
- // packages/common/util/src/callback.ts
252
+ // src/callback.ts
203
253
  import { invariant as invariant2 } from "@dxos/invariant";
204
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/util/src/callback.ts";
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";
205
268
  var Callback = class {
206
269
  call(...args) {
207
270
  invariant2(this._callback, "Callback not set", {
@@ -233,6 +296,9 @@ var Callback = class {
233
296
  isSet() {
234
297
  return !!this._callback;
235
298
  }
299
+ constructor() {
300
+ _define_property(this, "_callback", void 0);
301
+ }
236
302
  };
237
303
  var createSetDispatch = ({ handlers }) => {
238
304
  return new Proxy({
@@ -251,7 +317,7 @@ var createSetDispatch = ({ handlers }) => {
251
317
  });
252
318
  };
253
319
 
254
- // packages/common/util/src/case.ts
320
+ // src/case.ts
255
321
  var LOW_DASH = "_".codePointAt(0);
256
322
  var HI_DASH = "-".codePointAt(0);
257
323
  var SMALL_A = "a".codePointAt(0);
@@ -284,7 +350,7 @@ var changeCase = (str, delim) => {
284
350
  var decamelize = (str) => changeCase(str, LOW_DASH);
285
351
  var hyphenize = (str) => changeCase(str, HI_DASH);
286
352
 
287
- // packages/common/util/src/chunk-array.ts
353
+ // src/chunk-array.ts
288
354
  var chunkArray = (array, size) => {
289
355
  const result = [];
290
356
  for (let i = 0; i < array.length; i += size) {
@@ -293,24 +359,23 @@ var chunkArray = (array, size) => {
293
359
  return result;
294
360
  };
295
361
 
296
- // packages/common/util/src/circular-buffer.ts
362
+ // src/circular-buffer.ts
297
363
  import { invariant as invariant3 } from "@dxos/invariant";
298
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/common/util/src/circular-buffer.ts";
299
- var CircularBuffer = class {
300
- constructor(size) {
301
- this._nextIndex = 0;
302
- this._elementCount = 0;
303
- invariant3(size >= 1, void 0, {
304
- F: __dxlog_file3,
305
- L: 13,
306
- S: this,
307
- A: [
308
- "size >= 1",
309
- ""
310
- ]
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
311
371
  });
312
- this._buffer = new Array(size);
372
+ } else {
373
+ obj[key] = value;
313
374
  }
375
+ return obj;
376
+ }
377
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/common/util/src/circular-buffer.ts";
378
+ var CircularBuffer = class {
314
379
  push(element) {
315
380
  const evicted = this._elementCount === this._buffer.length ? this._buffer[this._nextIndex] : void 0;
316
381
  this._buffer[this._nextIndex] = element;
@@ -350,9 +415,24 @@ var CircularBuffer = class {
350
415
  yield this._buffer[i];
351
416
  }
352
417
  }
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
+ }
353
433
  };
354
434
 
355
- // packages/common/util/src/clear-undefined.ts
435
+ // src/clear-undefined.ts
356
436
  var clearUndefined = (obj) => {
357
437
  for (const key of [
358
438
  ...Object.getOwnPropertyNames(obj),
@@ -365,21 +445,25 @@ var clearUndefined = (obj) => {
365
445
  return obj;
366
446
  };
367
447
 
368
- // packages/common/util/src/complex.ts
448
+ // src/complex.ts
369
449
  import { inspect } from "@dxos/node-std/util";
370
450
  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
+ }
371
464
  var MAX_SERIALIZATION_LENGTH = 10;
465
+ var _inspect_custom = inspect.custom;
372
466
  var ComplexSet = class {
373
- // prettier-ignore
374
- constructor(_projection, values) {
375
- this._projection = _projection;
376
- this._values = /* @__PURE__ */ new Map();
377
- if (values) {
378
- for (const value of values) {
379
- this.add(value);
380
- }
381
- }
382
- }
383
467
  toString() {
384
468
  return inspectObject(this);
385
469
  }
@@ -388,7 +472,7 @@ var ComplexSet = class {
388
472
  size: this._values.size
389
473
  } : Array.from(this._values.values());
390
474
  }
391
- [inspect.custom]() {
475
+ [_inspect_custom]() {
392
476
  return inspectObject(this);
393
477
  }
394
478
  add(value) {
@@ -454,6 +538,18 @@ var ComplexSet = class {
454
538
  isDisjointFrom(other) {
455
539
  throw new Error("Method not implemented.");
456
540
  }
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
+ }
457
553
  };
458
554
  var makeSet = (projection) => {
459
555
  return class BoundComplexSet extends ComplexSet {
@@ -462,18 +558,8 @@ var makeSet = (projection) => {
462
558
  }
463
559
  };
464
560
  };
561
+ var _inspect_custom1 = inspect.custom;
465
562
  var ComplexMap = class _ComplexMap {
466
- // prettier-ignore
467
- constructor(_keyProjection, entries2) {
468
- this._keyProjection = _keyProjection;
469
- this._keys = /* @__PURE__ */ new Map();
470
- this._values = /* @__PURE__ */ new Map();
471
- if (entries2) {
472
- for (const [key, value] of entries2) {
473
- this.set(key, value);
474
- }
475
- }
476
- }
477
563
  toString() {
478
564
  return inspectObject(this);
479
565
  }
@@ -482,7 +568,7 @@ var ComplexMap = class _ComplexMap {
482
568
  size: this._values.size
483
569
  } : Array.from(this._values.values());
484
570
  }
485
- [inspect.custom]() {
571
+ [_inspect_custom1]() {
486
572
  return inspectObject(this);
487
573
  }
488
574
  clear() {
@@ -544,18 +630,35 @@ var ComplexMap = class _ComplexMap {
544
630
  get [Symbol.toStringTag]() {
545
631
  return "ComplexMap";
546
632
  }
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
+ }
547
647
  };
548
- var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
549
- constructor(entries2) {
550
- super(keyProjection, entries2);
648
+ var makeMap = (keyProjection) => {
649
+ class BoundComplexMap extends ComplexMap {
650
+ constructor(entries2) {
651
+ super(keyProjection, entries2);
652
+ }
551
653
  }
654
+ return BoundComplexMap;
552
655
  };
553
656
 
554
- // packages/common/util/src/deep.ts
657
+ // src/deep.ts
555
658
  import get from "lodash.get";
556
659
  import set from "lodash.set";
557
660
  import { invariant as invariant4 } from "@dxos/invariant";
558
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/common/util/src/deep.ts";
661
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/common/util/src/deep.ts";
559
662
  var setDeep = (obj, path, value) => {
560
663
  invariant4(path.length > 0, void 0, {
561
664
  F: __dxlog_file4,
@@ -585,53 +688,75 @@ var getDeep = (obj, path) => {
585
688
  return parent;
586
689
  };
587
690
 
588
- // packages/common/util/src/defer-function.ts
691
+ // src/defer-function.ts
589
692
  var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
590
693
 
591
- // packages/common/util/src/explicit-resource-management-polyfill.ts
592
- Symbol.dispose ??= Symbol("Symbol.dispose");
593
- Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
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"));
594
699
 
595
- // packages/common/util/src/defer.ts
700
+ // 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
+ }
596
714
  var defer = (fn) => new DeferGuard(fn);
597
715
  var DeferGuard = class {
598
- /**
599
- * @internal
600
- */
601
- constructor(_fn) {
602
- this._fn = _fn;
603
- }
604
716
  [Symbol.dispose]() {
605
717
  const result = this._fn();
606
718
  if (result instanceof Promise) {
607
719
  throw new Error("Async functions in defer are not supported. Use deferAsync instead.");
608
720
  }
609
721
  }
610
- };
611
- var deferAsync = (fn) => new DeferAsyncGuard(fn);
612
- var DeferAsyncGuard = class {
613
722
  /**
614
723
  * @internal
615
724
  */
616
725
  constructor(_fn) {
726
+ _define_property4(this, "_fn", void 0);
617
727
  this._fn = _fn;
618
728
  }
729
+ };
730
+ var deferAsync = (fn) => new DeferAsyncGuard(fn);
731
+ var DeferAsyncGuard = class {
619
732
  async [Symbol.asyncDispose]() {
620
733
  await this._fn();
621
734
  }
622
- };
623
-
624
- // packages/common/util/src/entry.ts
625
- var entry = (map, key) => new MapEntry(map, key);
626
- var MapEntry = class {
627
735
  /**
628
736
  * @internal
629
737
  */
630
- // prettier-ignore
631
- constructor(_map, _key) {
632
- this._map = _map;
633
- this._key = _key;
738
+ constructor(_fn) {
739
+ _define_property4(this, "_fn", void 0);
740
+ this._fn = _fn;
741
+ }
742
+ };
743
+
744
+ // 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;
634
755
  }
756
+ return obj;
757
+ }
758
+ var entry = (map, key) => new MapEntry(map, key);
759
+ var MapEntry = class {
635
760
  get key() {
636
761
  return this._key;
637
762
  }
@@ -647,9 +772,19 @@ var MapEntry = class {
647
772
  deep(key) {
648
773
  return entry(this.value, key);
649
774
  }
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
+ }
650
785
  };
651
786
 
652
- // packages/common/util/src/first-two-chars.ts
787
+ // src/first-two-chars.ts
653
788
  var renderableCharRegex = /^(?![\p{Control}\p{Mark}\p{Separator}\p{Surrogate}\p{Unassigned}\p{P}])[\p{L}\p{N}\p{S}\p{Emoji}]$/u;
654
789
  var getFirstTwoRenderableChars = (label) => {
655
790
  const characters = Array.from(label);
@@ -676,11 +811,24 @@ var getFirstTwoRenderableChars = (label) => {
676
811
  return result;
677
812
  };
678
813
 
679
- // packages/common/util/src/for-each-async.ts
814
+ // src/for-each-async.ts
680
815
  var forEachAsync = (items, fn) => Promise.all(items.map(fn));
681
816
 
682
- // packages/common/util/src/human-hash.ts
817
+ // src/human-hash.ts
683
818
  import { PublicKey } from "@dxos/keys";
819
+ function _define_property6(obj, key, value) {
820
+ if (key in obj) {
821
+ Object.defineProperty(obj, key, {
822
+ value,
823
+ enumerable: true,
824
+ configurable: true,
825
+ writable: true
826
+ });
827
+ } else {
828
+ obj[key] = value;
829
+ }
830
+ return obj;
831
+ }
684
832
  var DEFAULT_WORDLIST = [
685
833
  "ack",
686
834
  "alabama",
@@ -940,26 +1088,6 @@ var DEFAULT_WORDLIST = [
940
1088
  "zulu"
941
1089
  ];
942
1090
  var HumanHasher = class {
943
- /**
944
- * Transforms hex digests to human-readable strings.
945
- *
946
- * The format of these strings will look something like:
947
- * `victor-bacon-zulu-lima`. The output is obtained by compressing the input
948
- * digest to a fixed number of bytes, then mapping those bytes to one of 256
949
- * words. A default wordlist is provided, but you can override this if you
950
- * prefer.
951
- * As long as you use the same wordlist, the output will be consistent (i.e.
952
- * the same digest will always render the same representation).
953
- *
954
- * @param wordlist A list of exactly 256 words to choose from
955
- */
956
- constructor(wordlist = DEFAULT_WORDLIST) {
957
- this.wordlist = wordlist;
958
- if (wordlist.length !== 256) {
959
- throw new Error("Wordlist must have exactly 256 items");
960
- }
961
- this.wordlist = wordlist;
962
- }
963
1091
  /**
964
1092
  * Humanize a given hexadecimal digest.
965
1093
  *
@@ -999,6 +1127,27 @@ var HumanHasher = class {
999
1127
  const checksums = segments.map((x) => x.reduce((acc, curr) => acc ^ curr));
1000
1128
  return checksums;
1001
1129
  }
1130
+ /**
1131
+ * Transforms hex digests to human-readable strings.
1132
+ *
1133
+ * The format of these strings will look something like:
1134
+ * `victor-bacon-zulu-lima`. The output is obtained by compressing the input
1135
+ * digest to a fixed number of bytes, then mapping those bytes to one of 256
1136
+ * words. A default wordlist is provided, but you can override this if you
1137
+ * prefer.
1138
+ * As long as you use the same wordlist, the output will be consistent (i.e.
1139
+ * the same digest will always render the same representation).
1140
+ *
1141
+ * @param wordlist A list of exactly 256 words to choose from
1142
+ */
1143
+ constructor(wordlist = DEFAULT_WORDLIST) {
1144
+ _define_property6(this, "wordlist", void 0);
1145
+ this.wordlist = wordlist;
1146
+ if (wordlist.length !== 256) {
1147
+ throw new Error("Wordlist must have exactly 256 items");
1148
+ }
1149
+ this.wordlist = wordlist;
1150
+ }
1002
1151
  };
1003
1152
  var hasher = new HumanHasher();
1004
1153
  var humanize = (value) => {
@@ -1010,7 +1159,7 @@ var humanize = (value) => {
1010
1159
  return hasher.humanize(value);
1011
1160
  };
1012
1161
 
1013
- // packages/common/util/src/map.ts
1162
+ // src/map.ts
1014
1163
  var defaultMap = (map, key, def) => {
1015
1164
  let value = map.get(key);
1016
1165
  if (value === void 0) {
@@ -1020,9 +1169,11 @@ var defaultMap = (map, key, def) => {
1020
1169
  return value;
1021
1170
  };
1022
1171
 
1023
- // packages/common/util/src/instance-id.ts
1172
+ // src/instance-id.ts
1173
+ var _globalThis;
1174
+ var _symbol;
1024
1175
  var symbol = Symbol.for("dxos.instance-contexts");
1025
- var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
1176
+ var instanceContexts = (_globalThis = globalThis)[_symbol = symbol] ?? (_globalThis[_symbol] = /* @__PURE__ */ new WeakMap());
1026
1177
  var getPrototypeSpecificInstanceId = (instance) => {
1027
1178
  const prototype = Object.getPrototypeOf(instance);
1028
1179
  const instanceCtx = defaultMap(instanceContexts, prototype, () => ({
@@ -1044,7 +1195,7 @@ var getDebugName = (instance) => {
1044
1195
  return `${prototype.constructor?.name ?? "Object"}#${getPrototypeSpecificInstanceId(instance)}`;
1045
1196
  };
1046
1197
 
1047
- // packages/common/util/src/interval.ts
1198
+ // src/interval.ts
1048
1199
  var exponentialBackoffInterval = (cb, initialInterval) => {
1049
1200
  let interval = initialInterval;
1050
1201
  const repeat = () => {
@@ -1056,7 +1207,7 @@ var exponentialBackoffInterval = (cb, initialInterval) => {
1056
1207
  return () => clearTimeout(timeoutId);
1057
1208
  };
1058
1209
 
1059
- // packages/common/util/src/join-tables.ts
1210
+ // src/join-tables.ts
1060
1211
  var joinTables = (leftColumn, rightColumn, left, right) => {
1061
1212
  const map = /* @__PURE__ */ new Map();
1062
1213
  const used = /* @__PURE__ */ new Set();
@@ -1077,11 +1228,11 @@ var joinTables = (leftColumn, rightColumn, left, right) => {
1077
1228
  return result;
1078
1229
  };
1079
1230
 
1080
- // packages/common/util/src/json.ts
1231
+ // src/json.ts
1081
1232
  import { inspect as inspect2 } from "@dxos/node-std/util";
1082
1233
  import { PublicKey as PublicKey2 } from "@dxos/keys";
1083
1234
 
1084
- // packages/common/util/src/uint8array.ts
1235
+ // src/uint8array.ts
1085
1236
  var arraysEqual = (a, b) => {
1086
1237
  if (a.length !== b.length) {
1087
1238
  return false;
@@ -1102,10 +1253,10 @@ var bufferToArray = (buffer) => {
1102
1253
  var stringToArray = (string) => bufferToArray(Buffer.from(string, "hex"));
1103
1254
  var arrayToString = (array) => arrayToBuffer(array).toString("hex");
1104
1255
 
1105
- // packages/common/util/src/json.ts
1256
+ // src/json.ts
1106
1257
  var MAX_DEPTH = 5;
1107
1258
  var LOG_MAX_DEPTH = 7;
1108
- function jsonReplacer(key, value) {
1259
+ var jsonReplacer = (key, value) => {
1109
1260
  if (value !== null && typeof value === "object" && typeof value[inspect2.custom] === "function") {
1110
1261
  return value[inspect2.custom]();
1111
1262
  }
@@ -1118,7 +1269,7 @@ function jsonReplacer(key, value) {
1118
1269
  }
1119
1270
  }
1120
1271
  return value;
1121
- }
1272
+ };
1122
1273
  var jsonify = (value, depth = 0, visitedObjects = /* @__PURE__ */ new WeakSet()) => {
1123
1274
  if (depth > MAX_DEPTH) {
1124
1275
  return null;
@@ -1193,7 +1344,20 @@ var jsonKeyReplacer = (options = {}) => (key, value) => {
1193
1344
  return value;
1194
1345
  };
1195
1346
 
1196
- // packages/common/util/src/map-values.ts
1347
+ // src/map-values.ts
1348
+ function _define_property7(obj, key, value) {
1349
+ if (key in obj) {
1350
+ Object.defineProperty(obj, key, {
1351
+ value,
1352
+ enumerable: true,
1353
+ configurable: true,
1354
+ writable: true
1355
+ });
1356
+ } else {
1357
+ obj[key] = value;
1358
+ }
1359
+ return obj;
1360
+ }
1197
1361
  var mapValues = (obj, fn) => {
1198
1362
  const result = {};
1199
1363
  Object.keys(obj).forEach((key) => {
@@ -1205,7 +1369,19 @@ var deepMapValues = (value, fn) => {
1205
1369
  return new DeepMapper(fn).map(value);
1206
1370
  };
1207
1371
  var DeepMapper = class {
1372
+ map(value) {
1373
+ return this._map(value, void 0);
1374
+ }
1375
+ _map(value, key) {
1376
+ if (this._cyclic.has(value)) {
1377
+ return this._cyclic.get(value);
1378
+ }
1379
+ return this._fn(value, this._recurse, key);
1380
+ }
1208
1381
  constructor(_fn) {
1382
+ _define_property7(this, "_fn", void 0);
1383
+ _define_property7(this, "_cyclic", void 0);
1384
+ _define_property7(this, "_recurse", void 0);
1209
1385
  this._fn = _fn;
1210
1386
  this._cyclic = /* @__PURE__ */ new Map();
1211
1387
  this._recurse = (value) => {
@@ -1231,6 +1407,11 @@ var DeepMapper = class {
1231
1407
  }
1232
1408
  };
1233
1409
  }
1410
+ };
1411
+ var deepMapValuesAsync = (value, fn) => {
1412
+ return new DeepMapperAsync(fn).map(value);
1413
+ };
1414
+ var DeepMapperAsync = class {
1234
1415
  map(value) {
1235
1416
  return this._map(value, void 0);
1236
1417
  }
@@ -1240,12 +1421,10 @@ var DeepMapper = class {
1240
1421
  }
1241
1422
  return this._fn(value, this._recurse, key);
1242
1423
  }
1243
- };
1244
- var deepMapValuesAsync = (value, fn) => {
1245
- return new DeepMapperAsync(fn).map(value);
1246
- };
1247
- var DeepMapperAsync = class {
1248
1424
  constructor(_fn) {
1425
+ _define_property7(this, "_fn", void 0);
1426
+ _define_property7(this, "_cyclic", void 0);
1427
+ _define_property7(this, "_recurse", void 0);
1249
1428
  this._fn = _fn;
1250
1429
  this._cyclic = /* @__PURE__ */ new Map();
1251
1430
  this._recurse = async (value) => {
@@ -1271,15 +1450,6 @@ var DeepMapperAsync = class {
1271
1450
  }
1272
1451
  };
1273
1452
  }
1274
- map(value) {
1275
- return this._map(value, void 0);
1276
- }
1277
- _map(value, key) {
1278
- if (this._cyclic.has(value)) {
1279
- return this._cyclic.get(value);
1280
- }
1281
- return this._fn(value, this._recurse, key);
1282
- }
1283
1453
  };
1284
1454
  var visitValues = (object, visitor) => {
1285
1455
  if (Array.isArray(object)) {
@@ -1291,11 +1461,11 @@ var visitValues = (object, visitor) => {
1291
1461
  }
1292
1462
  };
1293
1463
 
1294
- // packages/common/util/src/object.ts
1464
+ // src/object.ts
1295
1465
  var keys = (obj) => Object.keys(obj);
1296
1466
  var entries = (obj) => Object.entries(obj);
1297
1467
 
1298
- // packages/common/util/src/order-keys.ts
1468
+ // src/order-keys.ts
1299
1469
  var orderKeys = (obj, order) => {
1300
1470
  const ordered = {};
1301
1471
  for (const key of order) {
@@ -1311,7 +1481,7 @@ var orderKeys = (obj, order) => {
1311
1481
  return ordered;
1312
1482
  };
1313
1483
 
1314
- // packages/common/util/src/order.ts
1484
+ // src/order.ts
1315
1485
  var inferObjectOrder = (objectMap, order = []) => {
1316
1486
  const orderedObjects = order.reduce((acc, id) => {
1317
1487
  if (id in objectMap) {
@@ -1338,7 +1508,7 @@ var inferRecordOrder = (objectMap, order = []) => {
1338
1508
  }, {}), objectMap);
1339
1509
  };
1340
1510
 
1341
- // packages/common/util/src/pick.ts
1511
+ // src/pick.ts
1342
1512
  var pick = (obj, keys2) => {
1343
1513
  return keys2.reduce((result, key) => {
1344
1514
  if (obj && key in obj) {
@@ -1366,7 +1536,7 @@ var omit = (obj, keys2) => {
1366
1536
  return result;
1367
1537
  };
1368
1538
 
1369
- // packages/common/util/src/platform.ts
1539
+ // src/platform.ts
1370
1540
  var isNode = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null;
1371
1541
  var mobileAndTabletCheck = () => {
1372
1542
  let check = false;
@@ -1407,7 +1577,7 @@ var getHostPlatform = () => {
1407
1577
  }
1408
1578
  };
1409
1579
 
1410
- // packages/common/util/src/position.ts
1580
+ // src/position.ts
1411
1581
  var byPosition = ({ position: a = "static" }, { position: b = "static" }) => {
1412
1582
  if (a === b) {
1413
1583
  return 0;
@@ -1420,14 +1590,14 @@ var byPosition = ({ position: a = "static" }, { position: b = "static" }) => {
1420
1590
  }
1421
1591
  };
1422
1592
 
1423
- // packages/common/util/src/random.ts
1593
+ // src/random.ts
1424
1594
  var randomInt = (max, min = 0) => {
1425
1595
  min = Math.ceil(min);
1426
1596
  max = Math.floor(max);
1427
1597
  return Math.floor(Math.random() * (max - min + 1)) + min;
1428
1598
  };
1429
1599
 
1430
- // packages/common/util/src/range.ts
1600
+ // src/range.ts
1431
1601
  var range = (n = 0, mapper) => {
1432
1602
  const range2 = Array.from(Array(n).keys());
1433
1603
  return mapper == null ? range2 : range2.map(mapper);
@@ -1439,7 +1609,7 @@ var clamp = (value, min, max) => {
1439
1609
  return Math.min(Math.max(value, min), max);
1440
1610
  };
1441
1611
 
1442
- // packages/common/util/src/reducers.ts
1612
+ // src/reducers.ts
1443
1613
  var accessBy = (value, accessor) => typeof accessor === "function" ? accessor(value) : value[accessor];
1444
1614
  var median = (values) => {
1445
1615
  const mid = Math.floor(values.length / 2);
@@ -1525,7 +1695,7 @@ var createBucketReducer = (period) => ({
1525
1695
  }
1526
1696
  });
1527
1697
 
1528
- // packages/common/util/src/remove-undefined-keys.ts
1698
+ // src/remove-undefined-keys.ts
1529
1699
  var removeUndefinedProperties = (object) => {
1530
1700
  for (const prop of [
1531
1701
  ...Object.getOwnPropertyNames(object),
@@ -1566,7 +1736,7 @@ var removeProperties = (root, condition) => {
1566
1736
  return result;
1567
1737
  };
1568
1738
 
1569
- // packages/common/util/src/safe-await.ts
1739
+ // src/safe-await.ts
1570
1740
  var safeAwaitAll = async (source, taskFactory, onError) => {
1571
1741
  const failedItems = [];
1572
1742
  await Promise.all([
@@ -1584,7 +1754,7 @@ var safeAwaitAll = async (source, taskFactory, onError) => {
1584
1754
  return failedItems;
1585
1755
  };
1586
1756
 
1587
- // packages/common/util/src/safe-instanceof.ts
1757
+ // src/safe-instanceof.ts
1588
1758
  var instanceTag = Symbol("instanceTag");
1589
1759
  var safeInstanceof = (tag) => (target) => {
1590
1760
  target.prototype[instanceTag] = tag;
@@ -1596,12 +1766,12 @@ var safeInstanceof = (tag) => (target) => {
1596
1766
  });
1597
1767
  };
1598
1768
 
1599
- // packages/common/util/src/safe-parse.ts
1769
+ // src/safe-parse.ts
1600
1770
  var safeParseInt = (value, defaultValue) => {
1601
1771
  try {
1602
1772
  const n = parseInt(value ?? "");
1603
1773
  return isNaN(n) ? defaultValue : n;
1604
- } catch (err) {
1774
+ } catch {
1605
1775
  return defaultValue;
1606
1776
  }
1607
1777
  };
@@ -1616,32 +1786,29 @@ var safeParseJson = (data, defaultValue) => {
1616
1786
  if (data && data.length > 0) {
1617
1787
  try {
1618
1788
  return JSON.parse(data);
1619
- } catch (err) {
1789
+ } catch {
1620
1790
  }
1621
1791
  }
1622
1792
  return defaultValue;
1623
1793
  };
1624
1794
 
1625
- // packages/common/util/src/sliding-window-summary.ts
1795
+ // src/sliding-window-summary.ts
1626
1796
  import { invariant as invariant5 } from "@dxos/invariant";
1627
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
1628
- var SlidingWindowSummary = class {
1629
- constructor(options) {
1630
- this._sum = 0;
1631
- this._buffer = new CircularBuffer(options.dataPoints);
1632
- if (options.precision != null) {
1633
- invariant5(options.precision >= 0, void 0, {
1634
- F: __dxlog_file5,
1635
- L: 26,
1636
- S: this,
1637
- A: [
1638
- "options.precision >= 0",
1639
- ""
1640
- ]
1641
- });
1642
- this._precision = Math.pow(10, options.precision);
1643
- }
1797
+ function _define_property8(obj, key, value) {
1798
+ if (key in obj) {
1799
+ Object.defineProperty(obj, key, {
1800
+ value,
1801
+ enumerable: true,
1802
+ configurable: true,
1803
+ writable: true
1804
+ });
1805
+ } else {
1806
+ obj[key] = value;
1644
1807
  }
1808
+ return obj;
1809
+ }
1810
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
1811
+ var SlidingWindowSummary = class {
1645
1812
  record(value) {
1646
1813
  const evicted = this._buffer.push(value);
1647
1814
  this._sum += value - (evicted ?? 0);
@@ -1676,9 +1843,27 @@ var SlidingWindowSummary = class {
1676
1843
  }
1677
1844
  return Math.round(value * this._precision) / this._precision;
1678
1845
  }
1846
+ constructor(options) {
1847
+ _define_property8(this, "_buffer", void 0);
1848
+ _define_property8(this, "_sum", 0);
1849
+ _define_property8(this, "_precision", void 0);
1850
+ this._buffer = new CircularBuffer(options.dataPoints);
1851
+ if (options.precision != null) {
1852
+ invariant5(options.precision >= 0, void 0, {
1853
+ F: __dxlog_file5,
1854
+ L: 26,
1855
+ S: this,
1856
+ A: [
1857
+ "options.precision >= 0",
1858
+ ""
1859
+ ]
1860
+ });
1861
+ this._precision = Math.pow(10, options.precision);
1862
+ }
1863
+ }
1679
1864
  };
1680
1865
 
1681
- // packages/common/util/src/sort.ts
1866
+ // src/sort.ts
1682
1867
  var compareScalar = (inc = true) => (a, b) => (inc ? 1 : -1) * (a < b ? -1 : a > b ? 1 : 0);
1683
1868
  var compareString = (inc = true, caseInsensitive = true) => (a, b) => {
1684
1869
  if (caseInsensitive) {
@@ -1700,25 +1885,42 @@ var compareMulti = (sorters) => (a, b) => {
1700
1885
  return sort();
1701
1886
  };
1702
1887
 
1703
- // packages/common/util/src/string.ts
1888
+ // src/string.ts
1704
1889
  var capitalize = (str) => {
1705
1890
  if (str.length === 0) {
1706
1891
  return "";
1707
1892
  }
1708
1893
  return str.charAt(0).toUpperCase() + str.slice(1);
1709
1894
  };
1895
+ function trim(strings, ...values) {
1896
+ const raw = strings.reduce((out, str, i) => {
1897
+ out += str;
1898
+ if (i < values.length) {
1899
+ const match = str.match(/(^|\n)([ \t]*)$/);
1900
+ const baseIndent = match ? match[2] : "";
1901
+ const val = String(values[i]).replace(/\r?\n/g, "\n" + baseIndent);
1902
+ out += val;
1903
+ }
1904
+ return out;
1905
+ }, "");
1906
+ const lines = raw.split("\n");
1907
+ while (lines.length && !lines[0].trim()) lines.shift();
1908
+ while (lines.length && !lines[lines.length - 1].trim()) lines.pop();
1909
+ const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
1910
+ return lines.map((l) => l.slice(minIndent)).join("\n");
1911
+ }
1710
1912
 
1711
- // packages/common/util/src/sum.ts
1913
+ // src/sum.ts
1712
1914
  var sum = (values) => values.reduce((a, b) => a + b, 0);
1713
1915
 
1714
- // packages/common/util/src/throw-unhandled-error.ts
1916
+ // src/throw-unhandled-error.ts
1715
1917
  var throwUnhandledError = (error) => {
1716
1918
  queueMicrotask(() => {
1717
1919
  throw error;
1718
1920
  });
1719
1921
  };
1720
1922
 
1721
- // packages/common/util/src/to-fallback.ts
1923
+ // src/to-fallback.ts
1722
1924
  var idEmoji = [
1723
1925
  // When changing this set, please check the result in a console or e.g. RunKit (https://runkit.com/thure/642214441dd6ae000855a8de)
1724
1926
  // 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.
@@ -1903,12 +2105,21 @@ var toFallback = (hash) => {
1903
2105
  };
1904
2106
  };
1905
2107
 
1906
- // packages/common/util/src/tracer.ts
1907
- var Tracer = class {
1908
- constructor() {
1909
- this._events = /* @__PURE__ */ new Map();
1910
- this._recording = false;
2108
+ // src/tracer.ts
2109
+ function _define_property9(obj, key, value) {
2110
+ if (key in obj) {
2111
+ Object.defineProperty(obj, key, {
2112
+ value,
2113
+ enumerable: true,
2114
+ configurable: true,
2115
+ writable: true
2116
+ });
2117
+ } else {
2118
+ obj[key] = value;
1911
2119
  }
2120
+ return obj;
2121
+ }
2122
+ var Tracer = class {
1912
2123
  // TODO(burdon): Start/stop methods for recording data? By id?
1913
2124
  // Alternatively, enable subscriptions to track/compute series.
1914
2125
  // TODO(burdon): Hierarchical traces?
@@ -1965,10 +2176,14 @@ var Tracer = class {
1965
2176
  defaultMap(this._events, event.id, []).push(event);
1966
2177
  }
1967
2178
  }
2179
+ constructor() {
2180
+ _define_property9(this, "_events", /* @__PURE__ */ new Map());
2181
+ _define_property9(this, "_recording", false);
2182
+ }
1968
2183
  };
1969
2184
  var tracer = new Tracer();
1970
2185
 
1971
- // packages/common/util/src/tree.ts
2186
+ // src/tree.ts
1972
2187
  import { truncateKey } from "@dxos/debug";
1973
2188
  var stringifyTree = (node, ancestors = [], rows = []) => {
1974
2189
  if (node.children?.length) {
@@ -2008,7 +2223,7 @@ var stringifyTree = (node, ancestors = [], rows = []) => {
2008
2223
  return rows;
2009
2224
  };
2010
2225
 
2011
- // packages/common/util/src/types.ts
2226
+ // src/types.ts
2012
2227
  var isNotFalsy = (value) => !!value;
2013
2228
  var isNonNullable = (value) => value != null;
2014
2229
  var doAsync = async (fn) => fn();
@@ -2040,19 +2255,94 @@ var arrayMove = (array, from, to) => {
2040
2255
  return array;
2041
2256
  };
2042
2257
 
2043
- // packages/common/util/src/weak.ts
2044
- var WeakDictionary = class {
2045
- constructor(entries2) {
2046
- this._internal = /* @__PURE__ */ new Map();
2047
- this._finalization = new FinalizationRegistry((cleanUpCallback) => {
2048
- cleanUpCallback();
2258
+ // src/unit.ts
2259
+ var Formatter = (unit) => {
2260
+ return (n, precision = 2) => {
2261
+ const value = n / unit.quotient;
2262
+ return `${value.toFixed(precision)}${unit.symbol}`;
2263
+ };
2264
+ };
2265
+ var Unit = {
2266
+ // ms.
2267
+ Hour: Formatter({
2268
+ symbol: "h",
2269
+ quotient: 60 * 60 * 1e3
2270
+ }),
2271
+ Minute: Formatter({
2272
+ symbol: "m",
2273
+ quotient: 60 * 1e3
2274
+ }),
2275
+ Second: Formatter({
2276
+ symbol: "s",
2277
+ quotient: 1e3
2278
+ }),
2279
+ Millisecond: Formatter({
2280
+ symbol: "ms",
2281
+ quotient: 1
2282
+ }),
2283
+ Duration: (n) => {
2284
+ const hours = Math.floor(n / (60 * 60 * 1e3));
2285
+ const minutes = Math.floor(n % (60 * 60 * 1e3) / (60 * 1e3));
2286
+ if (hours) {
2287
+ return minutes ? `${hours}h ${minutes}m` : `${hours}h`;
2288
+ }
2289
+ const seconds = Math.floor(n % (60 * 1e3) / 1e3);
2290
+ if (minutes) {
2291
+ return seconds ? `${minutes}m ${seconds}s` : `${minutes}m`;
2292
+ }
2293
+ if (seconds) {
2294
+ return `${(n / 1e3).toFixed(1)}s`;
2295
+ }
2296
+ return `${n}ms`;
2297
+ },
2298
+ // bytes (note KB via KiB).
2299
+ Gigabyte: Formatter({
2300
+ symbol: "GB",
2301
+ quotient: 1e3 * 1e3 * 1e3
2302
+ }),
2303
+ Megabyte: Formatter({
2304
+ symbol: "MB",
2305
+ quotient: 1e3 * 1e3
2306
+ }),
2307
+ Kilobyte: Formatter({
2308
+ symbol: "KB",
2309
+ quotient: 1e3
2310
+ }),
2311
+ // general.
2312
+ Thousand: Formatter({
2313
+ symbol: "k",
2314
+ quotient: 1e3
2315
+ }),
2316
+ Percent: Formatter({
2317
+ symbol: "%",
2318
+ quotient: 1 / 100
2319
+ })
2320
+ };
2321
+
2322
+ // src/url.ts
2323
+ var createUrl = (url, search) => {
2324
+ const base = typeof url === "string" ? new URL(url) : url;
2325
+ if (search) {
2326
+ base.search = new URLSearchParams(Object.entries(search).filter(([_, value]) => value != null)).toString();
2327
+ }
2328
+ return base;
2329
+ };
2330
+
2331
+ // src/weak.ts
2332
+ function _define_property10(obj, key, value) {
2333
+ if (key in obj) {
2334
+ Object.defineProperty(obj, key, {
2335
+ value,
2336
+ enumerable: true,
2337
+ configurable: true,
2338
+ writable: true
2049
2339
  });
2050
- this._internal = new Map(entries2?.map(([key, value]) => [
2051
- key,
2052
- new WeakRef(value)
2053
- ]));
2054
- entries2?.forEach(([key, value]) => this._register(key, value));
2340
+ } else {
2341
+ obj[key] = value;
2055
2342
  }
2343
+ return obj;
2344
+ }
2345
+ var WeakDictionary = class {
2056
2346
  *entries() {
2057
2347
  for (const [key, value] of this._internal) {
2058
2348
  yield [
@@ -2133,11 +2423,18 @@ var WeakDictionary = class {
2133
2423
  _unregister(value) {
2134
2424
  this._finalization.unregister(value);
2135
2425
  }
2426
+ constructor(entries2) {
2427
+ _define_property10(this, "_internal", /* @__PURE__ */ new Map());
2428
+ _define_property10(this, "_finalization", new FinalizationRegistry((cleanUpCallback) => {
2429
+ cleanUpCallback();
2430
+ }));
2431
+ this._internal = new Map(entries2?.map(([key, value]) => [
2432
+ key,
2433
+ new WeakRef(value)
2434
+ ]));
2435
+ entries2?.forEach(([key, value]) => this._register(key, value));
2436
+ }
2136
2437
  };
2137
-
2138
- // packages/common/util/src/assume.ts
2139
- function assumeType(value) {
2140
- }
2141
2438
  export {
2142
2439
  BitField,
2143
2440
  Callback,
@@ -2149,6 +2446,7 @@ export {
2149
2446
  MapEntry,
2150
2447
  SlidingWindowSummary,
2151
2448
  Tracer,
2449
+ Unit,
2152
2450
  WeakDictionary,
2153
2451
  accessBy,
2154
2452
  arrayMove,
@@ -2171,6 +2469,7 @@ export {
2171
2469
  createBucketReducer,
2172
2470
  createGroupReducer,
2173
2471
  createSetDispatch,
2472
+ createUrl,
2174
2473
  decamelize,
2175
2474
  deepMapValues,
2176
2475
  deepMapValuesAsync,
@@ -2256,6 +2555,7 @@ export {
2256
2555
  toFallback,
2257
2556
  toHue,
2258
2557
  tracer,
2558
+ trim,
2259
2559
  visitValues
2260
2560
  };
2261
2561
  //# sourceMappingURL=index.mjs.map