@dxos/util 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea
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 +178 -372
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +178 -372
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/string.d.ts +4 -0
- package/dist/types/src/string.d.ts.map +1 -1
- package/dist/types/src/to-fallback.d.ts.map +1 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/string.ts +7 -0
- package/src/to-fallback.ts +5 -4
- package/src/types.ts +0 -1
|
@@ -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
|
|
@@ -692,71 +597,53 @@ var getDeep = (obj, path) => {
|
|
|
692
597
|
var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
|
|
693
598
|
|
|
694
599
|
// src/explicit-resource-management-polyfill.ts
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
(_Symbol = Symbol).dispose ?? (_Symbol.dispose = Symbol("Symbol.dispose"));
|
|
698
|
-
(_Symbol1 = Symbol).asyncDispose ?? (_Symbol1.asyncDispose = Symbol("Symbol.asyncDispose"));
|
|
600
|
+
Symbol.dispose ??= Symbol("Symbol.dispose");
|
|
601
|
+
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
699
602
|
|
|
700
603
|
// 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
604
|
var defer = (fn) => new DeferGuard(fn);
|
|
715
605
|
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
|
-
}
|
|
606
|
+
_fn;
|
|
722
607
|
/**
|
|
723
608
|
* @internal
|
|
724
609
|
*/
|
|
725
610
|
constructor(_fn) {
|
|
726
|
-
_define_property4(this, "_fn", void 0);
|
|
727
611
|
this._fn = _fn;
|
|
728
612
|
}
|
|
613
|
+
[Symbol.dispose]() {
|
|
614
|
+
const result = this._fn();
|
|
615
|
+
if (result instanceof Promise) {
|
|
616
|
+
throw new Error("Async functions in defer are not supported. Use deferAsync instead.");
|
|
617
|
+
}
|
|
618
|
+
}
|
|
729
619
|
};
|
|
730
620
|
var deferAsync = (fn) => new DeferAsyncGuard(fn);
|
|
731
621
|
var DeferAsyncGuard = class {
|
|
732
|
-
|
|
733
|
-
await this._fn();
|
|
734
|
-
}
|
|
622
|
+
_fn;
|
|
735
623
|
/**
|
|
736
624
|
* @internal
|
|
737
625
|
*/
|
|
738
626
|
constructor(_fn) {
|
|
739
|
-
_define_property4(this, "_fn", void 0);
|
|
740
627
|
this._fn = _fn;
|
|
741
628
|
}
|
|
629
|
+
async [Symbol.asyncDispose]() {
|
|
630
|
+
await this._fn();
|
|
631
|
+
}
|
|
742
632
|
};
|
|
743
633
|
|
|
744
634
|
// 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
635
|
var entry = (map, key) => new MapEntry(map, key);
|
|
759
636
|
var MapEntry = class {
|
|
637
|
+
_map;
|
|
638
|
+
_key;
|
|
639
|
+
/**
|
|
640
|
+
* @internal
|
|
641
|
+
*/
|
|
642
|
+
// prettier-ignore
|
|
643
|
+
constructor(_map, _key) {
|
|
644
|
+
this._map = _map;
|
|
645
|
+
this._key = _key;
|
|
646
|
+
}
|
|
760
647
|
get key() {
|
|
761
648
|
return this._key;
|
|
762
649
|
}
|
|
@@ -772,16 +659,6 @@ var MapEntry = class {
|
|
|
772
659
|
deep(key) {
|
|
773
660
|
return entry(this.value, key);
|
|
774
661
|
}
|
|
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
662
|
};
|
|
786
663
|
|
|
787
664
|
// src/for-each-async.ts
|
|
@@ -789,19 +666,6 @@ var forEachAsync = (items, fn) => Promise.all(items.map(fn));
|
|
|
789
666
|
|
|
790
667
|
// src/human-hash.ts
|
|
791
668
|
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
669
|
var DEFAULT_WORDLIST = [
|
|
806
670
|
"ack",
|
|
807
671
|
"alabama",
|
|
@@ -1061,6 +925,27 @@ var DEFAULT_WORDLIST = [
|
|
|
1061
925
|
"zulu"
|
|
1062
926
|
];
|
|
1063
927
|
var HumanHasher = class {
|
|
928
|
+
wordlist;
|
|
929
|
+
/**
|
|
930
|
+
* Transforms hex digests to human-readable strings.
|
|
931
|
+
*
|
|
932
|
+
* The format of these strings will look something like:
|
|
933
|
+
* `victor-bacon-zulu-lima`. The output is obtained by compressing the input
|
|
934
|
+
* digest to a fixed number of bytes, then mapping those bytes to one of 256
|
|
935
|
+
* words. A default wordlist is provided, but you can override this if you
|
|
936
|
+
* prefer.
|
|
937
|
+
* As long as you use the same wordlist, the output will be consistent (i.e.
|
|
938
|
+
* the same digest will always render the same representation).
|
|
939
|
+
*
|
|
940
|
+
* @param wordlist A list of exactly 256 words to choose from
|
|
941
|
+
*/
|
|
942
|
+
constructor(wordlist = DEFAULT_WORDLIST) {
|
|
943
|
+
this.wordlist = wordlist;
|
|
944
|
+
if (wordlist.length !== 256) {
|
|
945
|
+
throw new Error("Wordlist must have exactly 256 items");
|
|
946
|
+
}
|
|
947
|
+
this.wordlist = wordlist;
|
|
948
|
+
}
|
|
1064
949
|
/**
|
|
1065
950
|
* Humanize a given hexadecimal digest.
|
|
1066
951
|
*
|
|
@@ -1100,27 +985,6 @@ var HumanHasher = class {
|
|
|
1100
985
|
const checksums = segments.map((x) => x.reduce((acc, curr) => acc ^ curr));
|
|
1101
986
|
return checksums;
|
|
1102
987
|
}
|
|
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
988
|
};
|
|
1125
989
|
var hasher = new HumanHasher();
|
|
1126
990
|
var humanize = (value) => {
|
|
@@ -1143,10 +1007,8 @@ var defaultMap = (map, key, def) => {
|
|
|
1143
1007
|
};
|
|
1144
1008
|
|
|
1145
1009
|
// src/instance-id.ts
|
|
1146
|
-
var _globalThis;
|
|
1147
|
-
var _symbol;
|
|
1148
1010
|
var symbol = Symbol.for("dxos.instance-contexts");
|
|
1149
|
-
var instanceContexts =
|
|
1011
|
+
var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
|
|
1150
1012
|
var getPrototypeSpecificInstanceId = (instance) => {
|
|
1151
1013
|
const prototype = Object.getPrototypeOf(instance);
|
|
1152
1014
|
const instanceCtx = defaultMap(instanceContexts, prototype, () => ({
|
|
@@ -1318,19 +1180,6 @@ var jsonKeyReplacer = (options = {}) => (key, value) => {
|
|
|
1318
1180
|
};
|
|
1319
1181
|
|
|
1320
1182
|
// 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
1183
|
var mapValues = (obj, fn) => {
|
|
1335
1184
|
const result = {};
|
|
1336
1185
|
Object.keys(obj).forEach((key) => {
|
|
@@ -1342,6 +1191,11 @@ var deepMapValues = (value, fn) => {
|
|
|
1342
1191
|
return new DeepMapper(fn).map(value);
|
|
1343
1192
|
};
|
|
1344
1193
|
var DeepMapper = class {
|
|
1194
|
+
_fn;
|
|
1195
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1196
|
+
constructor(_fn) {
|
|
1197
|
+
this._fn = _fn;
|
|
1198
|
+
}
|
|
1345
1199
|
map(value) {
|
|
1346
1200
|
return this._map(value, void 0);
|
|
1347
1201
|
}
|
|
@@ -1351,40 +1205,38 @@ var DeepMapper = class {
|
|
|
1351
1205
|
}
|
|
1352
1206
|
return this._fn(value, this._recurse, key);
|
|
1353
1207
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1208
|
+
_recurse = (value) => {
|
|
1209
|
+
if (this._cyclic.has(value)) {
|
|
1210
|
+
return this._cyclic.get(value);
|
|
1211
|
+
}
|
|
1212
|
+
if (Array.isArray(value)) {
|
|
1213
|
+
const res = new Array(value.length);
|
|
1214
|
+
this._cyclic.set(value, res);
|
|
1215
|
+
for (let i = 0; i < value.length; i++) {
|
|
1216
|
+
res[i] = this._map(value[i], i);
|
|
1363
1217
|
}
|
|
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;
|
|
1218
|
+
return res;
|
|
1219
|
+
} else if (value !== null && typeof value === "object") {
|
|
1220
|
+
const res = {};
|
|
1221
|
+
this._cyclic.set(value, res);
|
|
1222
|
+
for (const key in value) {
|
|
1223
|
+
res[key] = this._map(value[key], key);
|
|
1380
1224
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1225
|
+
return res;
|
|
1226
|
+
} else {
|
|
1227
|
+
return value;
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1383
1230
|
};
|
|
1384
1231
|
var deepMapValuesAsync = (value, fn) => {
|
|
1385
1232
|
return new DeepMapperAsync(fn).map(value);
|
|
1386
1233
|
};
|
|
1387
1234
|
var DeepMapperAsync = class {
|
|
1235
|
+
_fn;
|
|
1236
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1237
|
+
constructor(_fn) {
|
|
1238
|
+
this._fn = _fn;
|
|
1239
|
+
}
|
|
1388
1240
|
map(value) {
|
|
1389
1241
|
return this._map(value, void 0);
|
|
1390
1242
|
}
|
|
@@ -1394,35 +1246,28 @@ var DeepMapperAsync = class {
|
|
|
1394
1246
|
}
|
|
1395
1247
|
return this._fn(value, this._recurse, key);
|
|
1396
1248
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1249
|
+
_recurse = async (value) => {
|
|
1250
|
+
if (this._cyclic.has(value)) {
|
|
1251
|
+
return this._cyclic.get(value);
|
|
1252
|
+
}
|
|
1253
|
+
if (Array.isArray(value)) {
|
|
1254
|
+
const res = new Array(value.length);
|
|
1255
|
+
this._cyclic.set(value, res);
|
|
1256
|
+
for (let i = 0; i < value.length; i++) {
|
|
1257
|
+
res[i] = await this._map(value[i], i);
|
|
1406
1258
|
}
|
|
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;
|
|
1259
|
+
return res;
|
|
1260
|
+
} else if (value !== null && typeof value === "object") {
|
|
1261
|
+
const res = {};
|
|
1262
|
+
this._cyclic.set(value, res);
|
|
1263
|
+
for (const key in value) {
|
|
1264
|
+
res[key] = await this._map(value[key], key);
|
|
1423
1265
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1266
|
+
return res;
|
|
1267
|
+
} else {
|
|
1268
|
+
return value;
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1426
1271
|
};
|
|
1427
1272
|
var visitValues = (object, visitor) => {
|
|
1428
1273
|
if (Array.isArray(object)) {
|
|
@@ -1767,21 +1612,26 @@ var safeParseJson = (data, defaultValue) => {
|
|
|
1767
1612
|
|
|
1768
1613
|
// src/sliding-window-summary.ts
|
|
1769
1614
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1770
|
-
function _define_property8(obj, key, value) {
|
|
1771
|
-
if (key in obj) {
|
|
1772
|
-
Object.defineProperty(obj, key, {
|
|
1773
|
-
value,
|
|
1774
|
-
enumerable: true,
|
|
1775
|
-
configurable: true,
|
|
1776
|
-
writable: true
|
|
1777
|
-
});
|
|
1778
|
-
} else {
|
|
1779
|
-
obj[key] = value;
|
|
1780
|
-
}
|
|
1781
|
-
return obj;
|
|
1782
|
-
}
|
|
1783
1615
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
|
|
1784
1616
|
var SlidingWindowSummary = class {
|
|
1617
|
+
_buffer;
|
|
1618
|
+
_sum = 0;
|
|
1619
|
+
_precision;
|
|
1620
|
+
constructor(options) {
|
|
1621
|
+
this._buffer = new CircularBuffer(options.dataPoints);
|
|
1622
|
+
if (options.precision != null) {
|
|
1623
|
+
invariant5(options.precision >= 0, void 0, {
|
|
1624
|
+
F: __dxlog_file5,
|
|
1625
|
+
L: 26,
|
|
1626
|
+
S: this,
|
|
1627
|
+
A: [
|
|
1628
|
+
"options.precision >= 0",
|
|
1629
|
+
""
|
|
1630
|
+
]
|
|
1631
|
+
});
|
|
1632
|
+
this._precision = Math.pow(10, options.precision);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1785
1635
|
record(value) {
|
|
1786
1636
|
const evicted = this._buffer.push(value);
|
|
1787
1637
|
this._sum += value - (evicted ?? 0);
|
|
@@ -1816,24 +1666,6 @@ var SlidingWindowSummary = class {
|
|
|
1816
1666
|
}
|
|
1817
1667
|
return Math.round(value * this._precision) / this._precision;
|
|
1818
1668
|
}
|
|
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
1669
|
};
|
|
1838
1670
|
|
|
1839
1671
|
// src/sort.ts
|
|
@@ -1882,6 +1714,7 @@ function trim(strings, ...values) {
|
|
|
1882
1714
|
const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
|
|
1883
1715
|
return lines.map((l) => l.slice(minIndent)).join("\n");
|
|
1884
1716
|
}
|
|
1717
|
+
var kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
|
|
1885
1718
|
|
|
1886
1719
|
// src/sum.ts
|
|
1887
1720
|
var sum = (values) => values.reduce((a, b) => a + b, 0);
|
|
@@ -2079,20 +1912,9 @@ var toFallback = (hash) => {
|
|
|
2079
1912
|
};
|
|
2080
1913
|
|
|
2081
1914
|
// src/tracer.ts
|
|
2082
|
-
function _define_property9(obj, key, value) {
|
|
2083
|
-
if (key in obj) {
|
|
2084
|
-
Object.defineProperty(obj, key, {
|
|
2085
|
-
value,
|
|
2086
|
-
enumerable: true,
|
|
2087
|
-
configurable: true,
|
|
2088
|
-
writable: true
|
|
2089
|
-
});
|
|
2090
|
-
} else {
|
|
2091
|
-
obj[key] = value;
|
|
2092
|
-
}
|
|
2093
|
-
return obj;
|
|
2094
|
-
}
|
|
2095
1915
|
var Tracer = class {
|
|
1916
|
+
_events = /* @__PURE__ */ new Map();
|
|
1917
|
+
_recording = false;
|
|
2096
1918
|
// TODO(burdon): Start/stop methods for recording data? By id?
|
|
2097
1919
|
// Alternatively, enable subscriptions to track/compute series.
|
|
2098
1920
|
// TODO(burdon): Hierarchical traces?
|
|
@@ -2149,10 +1971,6 @@ var Tracer = class {
|
|
|
2149
1971
|
defaultMap(this._events, event.id, []).push(event);
|
|
2150
1972
|
}
|
|
2151
1973
|
}
|
|
2152
|
-
constructor() {
|
|
2153
|
-
_define_property9(this, "_events", /* @__PURE__ */ new Map());
|
|
2154
|
-
_define_property9(this, "_recording", false);
|
|
2155
|
-
}
|
|
2156
1974
|
};
|
|
2157
1975
|
var tracer = new Tracer();
|
|
2158
1976
|
|
|
@@ -2302,20 +2120,18 @@ var createUrl = (url, search) => {
|
|
|
2302
2120
|
};
|
|
2303
2121
|
|
|
2304
2122
|
// src/weak.ts
|
|
2305
|
-
function _define_property10(obj, key, value) {
|
|
2306
|
-
if (key in obj) {
|
|
2307
|
-
Object.defineProperty(obj, key, {
|
|
2308
|
-
value,
|
|
2309
|
-
enumerable: true,
|
|
2310
|
-
configurable: true,
|
|
2311
|
-
writable: true
|
|
2312
|
-
});
|
|
2313
|
-
} else {
|
|
2314
|
-
obj[key] = value;
|
|
2315
|
-
}
|
|
2316
|
-
return obj;
|
|
2317
|
-
}
|
|
2318
2123
|
var WeakDictionary = class {
|
|
2124
|
+
_internal = /* @__PURE__ */ new Map();
|
|
2125
|
+
_finalization = new FinalizationRegistry((cleanUpCallback) => {
|
|
2126
|
+
cleanUpCallback();
|
|
2127
|
+
});
|
|
2128
|
+
constructor(entries2) {
|
|
2129
|
+
this._internal = new Map(entries2?.map(([key, value]) => [
|
|
2130
|
+
key,
|
|
2131
|
+
new WeakRef(value)
|
|
2132
|
+
]));
|
|
2133
|
+
entries2?.forEach(([key, value]) => this._register(key, value));
|
|
2134
|
+
}
|
|
2319
2135
|
*entries() {
|
|
2320
2136
|
for (const [key, value] of this._internal) {
|
|
2321
2137
|
yield [
|
|
@@ -2396,17 +2212,6 @@ var WeakDictionary = class {
|
|
|
2396
2212
|
_unregister(value) {
|
|
2397
2213
|
this._finalization.unregister(value);
|
|
2398
2214
|
}
|
|
2399
|
-
constructor(entries2) {
|
|
2400
|
-
_define_property10(this, "_internal", /* @__PURE__ */ new Map());
|
|
2401
|
-
_define_property10(this, "_finalization", new FinalizationRegistry((cleanUpCallback) => {
|
|
2402
|
-
cleanUpCallback();
|
|
2403
|
-
}));
|
|
2404
|
-
this._internal = new Map(entries2?.map(([key, value]) => [
|
|
2405
|
-
key,
|
|
2406
|
-
new WeakRef(value)
|
|
2407
|
-
]));
|
|
2408
|
-
entries2?.forEach(([key, value]) => this._register(key, value));
|
|
2409
|
-
}
|
|
2410
2215
|
};
|
|
2411
2216
|
export {
|
|
2412
2217
|
BitField,
|
|
@@ -2485,6 +2290,7 @@ export {
|
|
|
2485
2290
|
jsonReplacer,
|
|
2486
2291
|
jsonify,
|
|
2487
2292
|
jsonlogify,
|
|
2293
|
+
kebabize,
|
|
2488
2294
|
keyToEmoji,
|
|
2489
2295
|
keyToFallback,
|
|
2490
2296
|
keyToHue,
|