@dxos/util 0.8.4-staging.ac66bdf99f → 0.9.1-main.c7dcc2e112

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 (86) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/index.mjs +96 -90
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +96 -90
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/array-to-hex.d.ts.map +1 -1
  9. package/dist/types/src/array.d.ts.map +1 -1
  10. package/dist/types/src/binder.d.ts.map +1 -1
  11. package/dist/types/src/bitfield.d.ts.map +1 -1
  12. package/dist/types/src/callback-collection.d.ts.map +1 -1
  13. package/dist/types/src/callback.d.ts.map +1 -1
  14. package/dist/types/src/case.d.ts.map +1 -1
  15. package/dist/types/src/chunk-array.d.ts.map +1 -1
  16. package/dist/types/src/circular-buffer.d.ts.map +1 -1
  17. package/dist/types/src/clear-undefined.d.ts.map +1 -1
  18. package/dist/types/src/complex.d.ts.map +1 -1
  19. package/dist/types/src/composite-key.d.ts.map +1 -1
  20. package/dist/types/src/deep.d.ts.map +1 -1
  21. package/dist/types/src/defer-function.d.ts.map +1 -1
  22. package/dist/types/src/defer.d.ts.map +1 -1
  23. package/dist/types/src/di-container.d.ts.map +1 -1
  24. package/dist/types/src/di-key.d.ts.map +1 -1
  25. package/dist/types/src/entry.d.ts.map +1 -1
  26. package/dist/types/src/error-format.d.ts.map +1 -1
  27. package/dist/types/src/filename.d.ts.map +1 -1
  28. package/dist/types/src/for-each-async.d.ts.map +1 -1
  29. package/dist/types/src/human-hash.d.ts.map +1 -1
  30. package/dist/types/src/id.d.ts +30 -0
  31. package/dist/types/src/id.d.ts.map +1 -0
  32. package/dist/types/src/id.test.d.ts +2 -0
  33. package/dist/types/src/id.test.d.ts.map +1 -0
  34. package/dist/types/src/index.d.ts +1 -0
  35. package/dist/types/src/index.d.ts.map +1 -1
  36. package/dist/types/src/instance-id.d.ts.map +1 -1
  37. package/dist/types/src/interval.d.ts.map +1 -1
  38. package/dist/types/src/join-tables.d.ts.map +1 -1
  39. package/dist/types/src/json.d.ts.map +1 -1
  40. package/dist/types/src/map-values.d.ts.map +1 -1
  41. package/dist/types/src/map.d.ts.map +1 -1
  42. package/dist/types/src/object.d.ts.map +1 -1
  43. package/dist/types/src/order-keys.d.ts.map +1 -1
  44. package/dist/types/src/order.d.ts.map +1 -1
  45. package/dist/types/src/pick.d.ts.map +1 -1
  46. package/dist/types/src/platform.d.ts +1 -1
  47. package/dist/types/src/position.d.ts +5 -5
  48. package/dist/types/src/position.d.ts.map +1 -1
  49. package/dist/types/src/random.d.ts.map +1 -1
  50. package/dist/types/src/range.d.ts.map +1 -1
  51. package/dist/types/src/reducers.d.ts.map +1 -1
  52. package/dist/types/src/remove-undefined-keys.d.ts.map +1 -1
  53. package/dist/types/src/retry.d.ts.map +1 -1
  54. package/dist/types/src/safe-await.d.ts.map +1 -1
  55. package/dist/types/src/safe-instanceof.d.ts.map +1 -1
  56. package/dist/types/src/safe-parse.d.ts.map +1 -1
  57. package/dist/types/src/safe-stringify.d.ts.map +1 -1
  58. package/dist/types/src/sliding-window-summary.d.ts.map +1 -1
  59. package/dist/types/src/sort.d.ts.map +1 -1
  60. package/dist/types/src/string.d.ts +12 -0
  61. package/dist/types/src/string.d.ts.map +1 -1
  62. package/dist/types/src/sum.d.ts.map +1 -1
  63. package/dist/types/src/throw-unhandled-error.d.ts.map +1 -1
  64. package/dist/types/src/to-fallback.d.ts +4 -4
  65. package/dist/types/src/to-fallback.d.ts.map +1 -1
  66. package/dist/types/src/tracer.d.ts.map +1 -1
  67. package/dist/types/src/tree.d.ts.map +1 -1
  68. package/dist/types/src/types.d.ts.map +1 -1
  69. package/dist/types/src/uint8array.d.ts +27 -0
  70. package/dist/types/src/uint8array.d.ts.map +1 -1
  71. package/dist/types/src/unit.d.ts.map +1 -1
  72. package/dist/types/src/url.d.ts.map +1 -1
  73. package/dist/types/src/weak.d.ts.map +1 -1
  74. package/dist/types/tsconfig.tsbuildinfo +1 -1
  75. package/package.json +8 -10
  76. package/src/error-format.ts +3 -1
  77. package/src/id.test.ts +109 -0
  78. package/src/id.ts +48 -0
  79. package/src/index.ts +1 -0
  80. package/src/map-values.ts +6 -0
  81. package/src/position.test.ts +38 -44
  82. package/src/position.ts +7 -11
  83. package/src/string.test.ts +24 -1
  84. package/src/string.ts +22 -2
  85. package/src/uint8array.ts +44 -0
  86. package/src/unit.ts +9 -3
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
@@ -119,7 +119,6 @@ var createBinder = (obj) => ({
119
119
 
120
120
  // src/bitfield.ts
121
121
  import { invariant } from "@dxos/invariant";
122
- var __dxlog_file = "/__w/dxos/dxos/packages/common/util/src/bitfield.ts";
123
122
  var BitField = class _BitField {
124
123
  static get(data, idx) {
125
124
  const bit = data[idx >> 3] >> 7 - idx % 8 & 1;
@@ -151,15 +150,7 @@ var BitField = class _BitField {
151
150
  return result;
152
151
  }
153
152
  static and(first, second) {
154
- invariant(first.length === second.length, "Bitfields must be of the same length", {
155
- F: __dxlog_file,
156
- L: 52,
157
- S: this,
158
- A: [
159
- "first.length === second.length",
160
- "'Bitfields must be of the same length'"
161
- ]
162
- });
153
+ invariant(first.length === second.length, "Bitfields must be of the same length");
163
154
  const result = new Uint8Array(first.length);
164
155
  for (let i = 0; i < first.length; i++) {
165
156
  result[i] = first[i] & second[i];
@@ -256,34 +247,17 @@ var CallbackCollection = class {
256
247
 
257
248
  // src/callback.ts
258
249
  import { invariant as invariant2 } from "@dxos/invariant";
259
- var __dxlog_file2 = "/__w/dxos/dxos/packages/common/util/src/callback.ts";
260
250
  var Callback = class {
261
251
  _callback;
262
252
  call(...args) {
263
- invariant2(this._callback, "Callback not set", {
264
- F: __dxlog_file2,
265
- L: 20,
266
- S: this,
267
- A: [
268
- "this._callback",
269
- "'Callback not set'"
270
- ]
271
- });
253
+ invariant2(this._callback, "Callback not set");
272
254
  return this._callback(...args);
273
255
  }
274
256
  callIfSet(...args) {
275
257
  return this._callback?.(...args);
276
258
  }
277
259
  set(callback) {
278
- invariant2(!this._callback, "Callback already set", {
279
- F: __dxlog_file2,
280
- L: 29,
281
- S: this,
282
- A: [
283
- "!this._callback",
284
- "'Callback already set'"
285
- ]
286
- });
260
+ invariant2(!this._callback, "Callback already set");
287
261
  this._callback = callback;
288
262
  }
289
263
  isSet() {
@@ -351,21 +325,12 @@ var chunkArray = (array, size) => {
351
325
 
352
326
  // src/circular-buffer.ts
353
327
  import { invariant as invariant3 } from "@dxos/invariant";
354
- var __dxlog_file3 = "/__w/dxos/dxos/packages/common/util/src/circular-buffer.ts";
355
328
  var CircularBuffer = class {
356
329
  _buffer;
357
330
  _nextIndex = 0;
358
331
  _elementCount = 0;
359
332
  constructor(size) {
360
- invariant3(size >= 1, void 0, {
361
- F: __dxlog_file3,
362
- L: 13,
363
- S: this,
364
- A: [
365
- "size >= 1",
366
- ""
367
- ]
368
- });
333
+ invariant3(size >= 1);
369
334
  this._buffer = new Array(size);
370
335
  }
371
336
  push(element) {
@@ -651,17 +616,8 @@ var splitCompositeKey = (key) => key.split(SEPARATOR);
651
616
 
652
617
  // src/deep.ts
653
618
  import { invariant as invariant4 } from "@dxos/invariant";
654
- var __dxlog_file4 = "/__w/dxos/dxos/packages/common/util/src/deep.ts";
655
619
  var setDeep = (obj, path, value) => {
656
- invariant4(path.length > 0, void 0, {
657
- F: __dxlog_file4,
658
- L: 12,
659
- S: void 0,
660
- A: [
661
- "path.length > 0",
662
- ""
663
- ]
664
- });
620
+ invariant4(path.length > 0);
665
621
  let parent = obj;
666
622
  for (const key of path.slice(0, -1)) {
667
623
  if (parent[key] === void 0) {
@@ -754,7 +710,9 @@ var formatErrorWithCauses = (error) => {
754
710
  while (current) {
755
711
  const prefix = level === 0 ? "" : `Caused by: `;
756
712
  lines.push(prefix + (current.stack ?? String(current)));
757
- if (!(current.cause instanceof Error)) break;
713
+ if (!(current.cause instanceof Error)) {
714
+ break;
715
+ }
758
716
  current = current.cause;
759
717
  level += 1;
760
718
  }
@@ -1102,6 +1060,19 @@ var humanize = (value) => {
1102
1060
  return hasher.humanize(value);
1103
1061
  };
1104
1062
 
1063
+ // src/id.ts
1064
+ var PART = /^[a-zA-Z][a-zA-Z0-9]{0,62}$/;
1065
+ var ID = /^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)$/;
1066
+ function id(strings, ...values) {
1067
+ const raw = strings.reduce((out, str, i) => out + str + (i < values.length ? String(values[i]) : ""), "");
1068
+ if (!ID.test(raw)) {
1069
+ throw new Error(`Invalid id (expected AT Protocol NSID): ${JSON.stringify(raw)}`);
1070
+ }
1071
+ return raw;
1072
+ }
1073
+ var isWellFormedId = (value) => ID.test(value);
1074
+ var isWellFormedIdPart = (value) => PART.test(value);
1075
+
1105
1076
  // src/map.ts
1106
1077
  var defaultMap = (map, key, def) => {
1107
1078
  let value = map.get(key);
@@ -1121,12 +1092,12 @@ var getPrototypeSpecificInstanceId = (instance) => {
1121
1092
  nextId: 0,
1122
1093
  instanceIds: /* @__PURE__ */ new WeakMap()
1123
1094
  }));
1124
- let id = instanceCtx.instanceIds.get(instance);
1125
- if (id === void 0) {
1126
- id = instanceCtx.nextId++;
1127
- instanceCtx.instanceIds.set(instance, id);
1095
+ let id2 = instanceCtx.instanceIds.get(instance);
1096
+ if (id2 === void 0) {
1097
+ id2 = instanceCtx.nextId++;
1098
+ instanceCtx.instanceIds.set(instance, id2);
1128
1099
  }
1129
- return id;
1100
+ return id2;
1130
1101
  };
1131
1102
  var getDebugName = (instance) => {
1132
1103
  if (instance == null) {
@@ -1193,6 +1164,26 @@ var bufferToArray = (buffer) => {
1193
1164
  };
1194
1165
  var stringToArray = (string) => bufferToArray(Buffer.from(string, "hex"));
1195
1166
  var arrayToString = (array) => arrayToBuffer(array).toString("hex");
1167
+ var toUnpaddedBase64 = (bytes) => arrayToBuffer(bytes).toString("base64").replace(/=+$/, "");
1168
+ var encodeUint8ArrayToJson = (bytes) => ({
1169
+ "/": {
1170
+ bytes: toUnpaddedBase64(bytes)
1171
+ }
1172
+ });
1173
+ var isEncodedUint8Array = (value) => {
1174
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
1175
+ return false;
1176
+ }
1177
+ if (Object.keys(value).length !== 1) {
1178
+ return false;
1179
+ }
1180
+ const inner = value["/"];
1181
+ if (typeof inner !== "object" || inner === null || Array.isArray(inner)) {
1182
+ return false;
1183
+ }
1184
+ return Object.keys(inner).length === 1 && typeof inner.bytes === "string";
1185
+ };
1186
+ var decodeUint8ArrayFromJson = (encoded) => bufferToArray(Buffer.from(encoded["/"].bytes, "base64"));
1196
1187
 
1197
1188
  // src/json.ts
1198
1189
  var MAX_DEPTH = 5;
@@ -1322,6 +1313,8 @@ var DeepMapper = class {
1322
1313
  res[i] = this._map(value[i], i);
1323
1314
  }
1324
1315
  return res;
1316
+ } else if (ArrayBuffer.isView(value)) {
1317
+ return value;
1325
1318
  } else if (value !== null && typeof value === "object") {
1326
1319
  const res = {};
1327
1320
  this._cyclic.set(value, res);
@@ -1363,6 +1356,8 @@ var DeepMapperAsync = class {
1363
1356
  res[i] = await this._map(value[i], i);
1364
1357
  }
1365
1358
  return res;
1359
+ } else if (ArrayBuffer.isView(value)) {
1360
+ return value;
1366
1361
  } else if (value !== null && typeof value === "object") {
1367
1362
  const res = {};
1368
1363
  this._cyclic.set(value, res);
@@ -1407,27 +1402,27 @@ var orderKeys = (obj, order) => {
1407
1402
 
1408
1403
  // src/order.ts
1409
1404
  var inferObjectOrder = (objectMap, order = []) => {
1410
- const orderedObjects = order.reduce((acc, id) => {
1411
- if (id in objectMap) {
1412
- acc.objects.push(objectMap[id]);
1413
- acc.ids.add(id);
1405
+ const orderedObjects = order.reduce((acc, id2) => {
1406
+ if (id2 in objectMap) {
1407
+ acc.objects.push(objectMap[id2]);
1408
+ acc.ids.add(id2);
1414
1409
  }
1415
1410
  return acc;
1416
1411
  }, {
1417
1412
  objects: [],
1418
1413
  ids: /* @__PURE__ */ new Set()
1419
1414
  });
1420
- const { objects } = Object.keys(objectMap).reduce((acc, id) => {
1421
- if (!acc.ids.has(id)) {
1422
- acc.objects.push(objectMap[id]);
1415
+ const { objects } = Object.keys(objectMap).reduce((acc, id2) => {
1416
+ if (!acc.ids.has(id2)) {
1417
+ acc.objects.push(objectMap[id2]);
1423
1418
  }
1424
1419
  return acc;
1425
1420
  }, orderedObjects);
1426
1421
  return objects;
1427
1422
  };
1428
1423
  var inferRecordOrder = (objectMap, order = []) => {
1429
- return Object.assign(order.filter((id) => id in objectMap).reduce((acc, id) => {
1430
- acc[id] = null;
1424
+ return Object.assign(order.filter((id2) => id2 in objectMap).reduce((acc, id2) => {
1425
+ acc[id2] = null;
1431
1426
  return acc;
1432
1427
  }, {}), objectMap);
1433
1428
  };
@@ -1513,12 +1508,12 @@ var getHostPlatform = () => {
1513
1508
  };
1514
1509
 
1515
1510
  // src/position.ts
1516
- var byPosition = ({ position: a = "static" }, { position: b = "static" }) => {
1511
+ var byPosition = ({ position: a }, { position: b }) => {
1517
1512
  if (a === b) {
1518
1513
  return 0;
1519
- } else if (a === "hoist" || b === "fallback") {
1514
+ } else if (a === "first" || b === "last") {
1520
1515
  return -1;
1521
- } else if (b === "hoist" || a === "fallback") {
1516
+ } else if (b === "first" || a === "last") {
1522
1517
  return 1;
1523
1518
  } else {
1524
1519
  return 0;
@@ -1864,7 +1859,6 @@ var defaultFilter = createReplacer();
1864
1859
 
1865
1860
  // src/sliding-window-summary.ts
1866
1861
  import { invariant as invariant5 } from "@dxos/invariant";
1867
- var __dxlog_file5 = "/__w/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
1868
1862
  var SlidingWindowSummary = class {
1869
1863
  _buffer;
1870
1864
  _sum = 0;
@@ -1872,15 +1866,7 @@ var SlidingWindowSummary = class {
1872
1866
  constructor(options) {
1873
1867
  this._buffer = new CircularBuffer(options.dataPoints);
1874
1868
  if (options.precision != null) {
1875
- invariant5(options.precision >= 0, void 0, {
1876
- F: __dxlog_file5,
1877
- L: 26,
1878
- S: this,
1879
- A: [
1880
- "options.precision >= 0",
1881
- ""
1882
- ]
1883
- });
1869
+ invariant5(options.precision >= 0);
1884
1870
  this._precision = Math.pow(10, options.precision);
1885
1871
  }
1886
1872
  }
@@ -1949,6 +1935,10 @@ var capitalize = (str) => {
1949
1935
  }
1950
1936
  return str.charAt(0).toUpperCase() + str.slice(1);
1951
1937
  };
1938
+ function inline(strings, ...values) {
1939
+ const raw = strings.reduce((out, str, i) => out + str + (i < values.length ? String(values[i]) : ""), "");
1940
+ return raw.replace(/\s+/g, " ").trim();
1941
+ }
1952
1942
  function trim(strings, ...values) {
1953
1943
  const raw = strings.reduce((out, str, i) => {
1954
1944
  out += str;
@@ -1961,8 +1951,12 @@ function trim(strings, ...values) {
1961
1951
  return out;
1962
1952
  }, "");
1963
1953
  const lines = raw.split("\n");
1964
- while (lines.length && !lines[0].trim()) lines.shift();
1965
- while (lines.length && !lines[lines.length - 1].trim()) lines.pop();
1954
+ while (lines.length && !lines[0].trim()) {
1955
+ lines.shift();
1956
+ }
1957
+ while (lines.length && !lines[lines.length - 1].trim()) {
1958
+ lines.pop();
1959
+ }
1966
1960
  const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
1967
1961
  return lines.map((l) => l.slice(minIndent)).join("\n");
1968
1962
  }
@@ -2165,8 +2159,8 @@ var Tracer = class {
2165
2159
  keys() {
2166
2160
  return Array.from(this._events.keys());
2167
2161
  }
2168
- get(id, filter) {
2169
- const events = this._events.get(id);
2162
+ get(id2, filter) {
2163
+ const events = this._events.get(id2);
2170
2164
  if (filter) {
2171
2165
  return events?.filter((event) => Object.entries(filter).every(([key, value]) => event?.value[key] === value));
2172
2166
  }
@@ -2183,11 +2177,11 @@ var Tracer = class {
2183
2177
  this._recording = false;
2184
2178
  return this;
2185
2179
  }
2186
- emit(id, value) {
2187
- this._post(this._createEvent(id, value));
2180
+ emit(id2, value) {
2181
+ this._post(this._createEvent(id2, value));
2188
2182
  }
2189
- mark(id, value) {
2190
- const event = this._createEvent(id, value);
2183
+ mark(id2, value) {
2184
+ const event = this._createEvent(id2, value);
2191
2185
  const start = performance.now();
2192
2186
  return {
2193
2187
  start,
@@ -2197,9 +2191,9 @@ var Tracer = class {
2197
2191
  }
2198
2192
  };
2199
2193
  }
2200
- _createEvent(id, value) {
2194
+ _createEvent(id2, value) {
2201
2195
  const event = {
2202
- id,
2196
+ id: id2,
2203
2197
  timestamp: Date.now()
2204
2198
  };
2205
2199
  if (value !== void 0) {
@@ -2297,11 +2291,15 @@ function arraySwap(array, from, to) {
2297
2291
  var createFormat = (unit) => {
2298
2292
  return (n, precision = unit.precision ?? 0) => {
2299
2293
  const value = n / unit.quotient;
2294
+ const formattedValue = value.toLocaleString("en-US", {
2295
+ minimumFractionDigits: precision,
2296
+ maximumFractionDigits: precision
2297
+ });
2300
2298
  return {
2301
2299
  unit,
2302
2300
  value,
2303
- formattedValue: value.toFixed(precision),
2304
- toString: () => `${value.toFixed(precision)}${unit.symbol}`
2301
+ formattedValue,
2302
+ toString: () => `${formattedValue}${unit.symbol}`
2305
2303
  };
2306
2304
  };
2307
2305
  };
@@ -2358,6 +2356,7 @@ var Unit = {
2358
2356
  symbol: "ms",
2359
2357
  quotient: 1
2360
2358
  }),
2359
+ // TODO(burdon): Inconsistent formattedValue.
2361
2360
  Duration: (n) => {
2362
2361
  const hours = Math.floor(n / MS_HOURS);
2363
2362
  const minutes = Math.floor(n % MS_HOURS / MS_MINUTES);
@@ -2375,7 +2374,7 @@ var Unit = {
2375
2374
  }
2376
2375
  if (minutes) {
2377
2376
  const seconds2 = (n - MS_MINUTES * minutes) / MS_SECONDS;
2378
- const formattedValue = seconds2 ? `${minutes}m ${seconds2}s` : `${minutes}m`;
2377
+ const formattedValue = seconds2 ? `${minutes}m ${Math.round(seconds2)}s` : `${minutes}m`;
2379
2378
  return {
2380
2379
  unit: {
2381
2380
  symbol: "m",
@@ -2583,6 +2582,7 @@ export {
2583
2582
  createSetDispatch,
2584
2583
  createUrl,
2585
2584
  decamelize,
2585
+ decodeUint8ArrayFromJson,
2586
2586
  deepMapValues,
2587
2587
  deepMapValuesAsync,
2588
2588
  defaultFilter,
@@ -2593,6 +2593,7 @@ export {
2593
2593
  diff,
2594
2594
  distinctBy,
2595
2595
  doAsync,
2596
+ encodeUint8ArrayToJson,
2596
2597
  entries,
2597
2598
  entry,
2598
2599
  exponentialBackoffInterval,
@@ -2610,20 +2611,25 @@ export {
2610
2611
  hexToHue,
2611
2612
  humanize,
2612
2613
  hyphenize,
2614
+ id,
2613
2615
  idEmoji,
2614
2616
  idHue,
2615
2617
  inferObjectOrder,
2616
2618
  inferRecordOrder,
2619
+ inline,
2617
2620
  intersectBy,
2618
2621
  intersection,
2619
2622
  iosCheck,
2620
2623
  isBun,
2624
+ isEncodedUint8Array,
2621
2625
  isMobile,
2622
2626
  isMobileOrTablet,
2623
2627
  isNode,
2624
2628
  isNonNullable,
2625
2629
  isTauri,
2626
2630
  isTruthy,
2631
+ isWellFormedId,
2632
+ isWellFormedIdPart,
2627
2633
  joinTables,
2628
2634
  jsonKeyReplacer,
2629
2635
  jsonReplacer,