react-websocket 4.22.1 → 4.22.3

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 (60) hide show
  1. package/dist/ag-ui.cjs +8 -9
  2. package/dist/ag-ui.cjs.map +1 -1
  3. package/dist/ag-ui.d.cts +3 -8
  4. package/dist/ag-ui.d.ts +0 -2
  5. package/dist/ag-ui.js +8 -9
  6. package/dist/ag-ui.js.map +1 -1
  7. package/dist/chaos.cjs +60 -13
  8. package/dist/chaos.cjs.map +1 -1
  9. package/dist/chaos.d.cts +1 -2
  10. package/dist/chaos.d.ts +1 -2
  11. package/dist/chaos.js +60 -13
  12. package/dist/chaos.js.map +1 -1
  13. package/dist/core.cjs +93 -65
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.d.cts +4 -25
  16. package/dist/core.d.ts +4 -25
  17. package/dist/core.js +93 -65
  18. package/dist/core.js.map +1 -1
  19. package/dist/devtools.cjs +1 -2
  20. package/dist/devtools.d.cts +0 -2
  21. package/dist/devtools.d.ts +0 -2
  22. package/dist/devtools.js +1 -2
  23. package/dist/index.cjs +1 -2
  24. package/dist/index.d.cts +4 -31
  25. package/dist/index.d.ts +3 -24
  26. package/dist/index.development.cjs +1 -2
  27. package/dist/index.development.js +1 -2
  28. package/dist/index.js +1 -2
  29. package/dist/outbox.cjs +15 -10
  30. package/dist/outbox.cjs.map +1 -1
  31. package/dist/outbox.d.cts +1 -3
  32. package/dist/outbox.d.ts +0 -2
  33. package/dist/outbox.js +15 -10
  34. package/dist/outbox.js.map +1 -1
  35. package/dist/replay.cjs +13 -9
  36. package/dist/replay.cjs.map +1 -1
  37. package/dist/replay.d.cts +8 -4
  38. package/dist/replay.d.ts +8 -4
  39. package/dist/replay.js +13 -9
  40. package/dist/replay.js.map +1 -1
  41. package/dist/tabs.cjs +12 -16
  42. package/dist/tabs.cjs.map +1 -1
  43. package/dist/tabs.d.cts +0 -2
  44. package/dist/tabs.d.ts +0 -2
  45. package/dist/tabs.js +12 -16
  46. package/dist/tabs.js.map +1 -1
  47. package/dist/timeline.cjs +4 -3
  48. package/dist/timeline.cjs.map +1 -1
  49. package/dist/timeline.d.cts +3 -7
  50. package/dist/timeline.d.ts +2 -4
  51. package/dist/timeline.js +4 -3
  52. package/dist/timeline.js.map +1 -1
  53. package/dist/{types-paLT8yQF.d.cts → types-DyZm2F7B.d.cts} +4 -5
  54. package/dist/webtransport.cjs +13 -12
  55. package/dist/webtransport.cjs.map +1 -1
  56. package/dist/webtransport.d.cts +0 -2
  57. package/dist/webtransport.d.ts +0 -2
  58. package/dist/webtransport.js +13 -12
  59. package/dist/webtransport.js.map +1 -1
  60. package/package.json +9 -9
package/dist/core.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/types.ts
2
+ // src/types.ts
3
3
  /**
4
4
  * Reported via the `error` event (and `onError`) when an incoming message can't be
5
5
  * decoded by `parse`/`json` or fails `schema` validation. The message is not delivered.
@@ -23,8 +23,7 @@ var MessageError = class extends Error {
23
23
  this.issues = options?.issues;
24
24
  }
25
25
  };
26
- //#endregion
27
- //#region src/client.ts
26
+ // src/client.ts
28
27
  const OPEN = 1;
29
28
  const RECONNECT_DEFAULTS = {
30
29
  maxAttempts: Infinity,
@@ -35,7 +34,7 @@ const RECONNECT_DEFAULTS = {
35
34
  minUptime: 5e3
36
35
  };
37
36
  const QUEUE_LIMIT = 100;
38
- const MAX_TIMEOUT = 2 ** 31 - 1;
37
+ const MAX_TIMEOUT$2 = 2 ** 31 - 1;
39
38
  /**
40
39
  * The default `reconnect.shouldReconnect`: retry every close except `1002` (protocol error),
41
40
  * `1003` (unsupported data) and `1008` (policy violation, often a rejected login), which
@@ -114,8 +113,11 @@ function isThenable(value) {
114
113
  const ON_TEARDOWN = Symbol.for("react-websocket.onTeardown");
115
114
  /** @internal Method key on a socket that sends `volatile` messages as datagrams (WebTransport). */
116
115
  const DATAGRAM = Symbol.for("react-websocket.datagram");
117
- /** @internal Method key for what `react-websocket/devtools` shows that the snapshot doesn't. */
118
- const INSPECT = Symbol.for("react-websocket.inspect");
116
+ /**
117
+ * @internal Method key for what `react-websocket/devtools` shows that the snapshot doesn't. Requests
118
+ * read its queue length too, to tell a dropped message from a queued one.
119
+ */
120
+ const INSPECT$1 = Symbol.for("react-websocket.inspect");
119
121
  function createClient(url, options = {}) {
120
122
  const onTeardown = options[ON_TEARDOWN];
121
123
  const log = options.logger ?? (() => {});
@@ -145,6 +147,7 @@ function createClient(url, options = {}) {
145
147
  let wanted = false;
146
148
  let refs = 0;
147
149
  let pinned = false;
150
+ let unpinned = false;
148
151
  let unheldStop = false;
149
152
  let pending = [];
150
153
  let ready = null;
@@ -387,7 +390,7 @@ function createClient(url, options = {}) {
387
390
  const attempt = ++failures;
388
391
  const asked = (retry.retryAfter ?? retryAfter)(info);
389
392
  const named = asked >= 0;
390
- const delay = Math.min(MAX_TIMEOUT, named ? asked + backoff(attempt, false) : backoff(attempt, info.code === 1013));
393
+ const delay = Math.min(MAX_TIMEOUT$2, named ? asked + backoff(attempt, false) : backoff(attempt, info.code === 1013));
391
394
  serverWait = named || info.code === 1013;
392
395
  set({
393
396
  status: "reconnecting",
@@ -412,12 +415,13 @@ function createClient(url, options = {}) {
412
415
  if (!wanted) return;
413
416
  if (to !== void 0) moved = to;
414
417
  if (snapshot.status === "open") open(true);
415
- }, Math.min(MAX_TIMEOUT, Math.random() * (within ?? 0)));
418
+ }, Math.min(MAX_TIMEOUT$2, Math.random() * (within ?? 0)));
416
419
  }
417
420
  function fail(reason) {
418
421
  wanted = false;
419
422
  opened = false;
420
423
  unheldStop = refs === 0;
424
+ clearTimeout(teardownTimer);
421
425
  unbindWindow();
422
426
  stopMigrating();
423
427
  pending = [];
@@ -532,6 +536,7 @@ function createClient(url, options = {}) {
532
536
  function begin() {
533
537
  wanted = true;
534
538
  unheldStop = false;
539
+ unpinned = false;
535
540
  if (snapshot.status === "idle" || snapshot.status === "closed") {
536
541
  opened = false;
537
542
  if (ready?.settled) ready = null;
@@ -570,9 +575,11 @@ function createClient(url, options = {}) {
570
575
  }
571
576
  function close(code = 1e3, reason) {
572
577
  stop(code, reason);
578
+ unpinned ||= pinned;
573
579
  pinned = false;
574
580
  opened = false;
575
581
  unheldStop = refs === 0;
582
+ clearTimeout(teardownTimer);
576
583
  set({
577
584
  status: "closed",
578
585
  attempt: 0,
@@ -582,6 +589,7 @@ function createClient(url, options = {}) {
582
589
  }
583
590
  function reconnect() {
584
591
  if (!getImpl()) return;
592
+ if (unpinned) pinned = true;
585
593
  clearTimeout(retryTimer);
586
594
  retryTimer = void 0;
587
595
  stopSocketTimers();
@@ -663,7 +671,7 @@ function createClient(url, options = {}) {
663
671
  reconnect,
664
672
  migrate,
665
673
  acquire,
666
- [INSPECT]: () => ({ queued: pending.length })
674
+ [INSPECT$1]: () => ({ queued: pending.length })
667
675
  };
668
676
  }
669
677
  /**
@@ -688,8 +696,7 @@ function createClient(url, options = {}) {
688
696
  function createWebSocket(url, options) {
689
697
  return createClient(url, options);
690
698
  }
691
- //#endregion
692
- //#region src/topics.ts
699
+ // src/topics.ts
693
700
  /** @internal Option key for a callback run when nothing holds a topic anymore. Used by feeds. */
694
701
  const ON_RELEASE = Symbol("react-websocket.onRelease");
695
702
  /**
@@ -737,8 +744,6 @@ function createWebSocketTopics(client, options) {
737
744
  if (options.unsubscribe) client.send(options.unsubscribe(topic));
738
745
  }
739
746
  const off = client.on("open", () => {
740
- sentOn = client.socket;
741
- sent = /* @__PURE__ */ new Set();
742
747
  for (const topic of counts.keys()) subscribe(topic);
743
748
  });
744
749
  return {
@@ -776,8 +781,7 @@ function createWebSocketTopics(client, options) {
776
781
  }
777
782
  };
778
783
  }
779
- //#endregion
780
- //#region src/feeds.ts
784
+ // src/feeds.ts
781
785
  /**
782
786
  * Subscribe to topics whose messages carry a sequence number, and get each message once, in
783
787
  * order, across reconnects:
@@ -866,8 +870,7 @@ function createWebSocketFeeds(client, options) {
866
870
  }
867
871
  };
868
872
  }
869
- //#endregion
870
- //#region src/latency.ts
873
+ // src/latency.ts
871
874
  const EMPTY = Object.freeze({
872
875
  rtt: void 0,
873
876
  offset: void 0
@@ -921,6 +924,7 @@ function createWebSocketLatency(client, options) {
921
924
  stop();
922
925
  inFlight.clear();
923
926
  samples = [];
927
+ if (client.getSnapshot().status !== "open") return;
924
928
  ping();
925
929
  timer = setInterval(ping, interval);
926
930
  }
@@ -975,8 +979,7 @@ function createWebSocketLatency(client, options) {
975
979
  }
976
980
  };
977
981
  }
978
- //#endregion
979
- //#region src/presence.ts
982
+ // src/presence.ts
980
983
  const VOLATILE$1 = { volatile: true };
981
984
  /**
982
985
  * Share per-peer state that expires, for presence, live cursors and selections.
@@ -1003,6 +1006,7 @@ const VOLATILE$1 = { volatile: true };
1003
1006
  */
1004
1007
  function createWebSocketPresence(client, options) {
1005
1008
  const timeout = options.timeout ?? 3e4;
1009
+ const refresh = options.refresh ?? timeout / 3;
1006
1010
  const interval = 1e3 / (options.maxRate ?? 20);
1007
1011
  const peers = /* @__PURE__ */ new Map();
1008
1012
  const listeners = /* @__PURE__ */ new Set();
@@ -1012,16 +1016,21 @@ function createWebSocketPresence(client, options) {
1012
1016
  let sendTimer;
1013
1017
  let refreshTimer;
1014
1018
  let expiryTimer;
1019
+ let disposed = false;
1015
1020
  function changed() {
1016
1021
  snapshot = [...peers.values()];
1017
1022
  for (const listener of [...listeners]) listener();
1018
1023
  }
1019
- function sendNow() {
1024
+ function stopSending() {
1020
1025
  clearTimeout(sendTimer);
1021
- sendTimer = void 0;
1026
+ clearTimeout(refreshTimer);
1027
+ sendTimer = refreshTimer = void 0;
1028
+ }
1029
+ function sendNow() {
1030
+ stopSending();
1022
1031
  if (!own) return;
1023
1032
  lastSent = Date.now();
1024
- client.send(options.send(own.state), VOLATILE$1);
1033
+ if (client.send(options.send(own.state), VOLATILE$1)) refreshTimer = setTimeout(sendNow, refresh);
1025
1034
  }
1026
1035
  function expire() {
1027
1036
  expiryTimer = void 0;
@@ -1036,26 +1045,36 @@ function createWebSocketPresence(client, options) {
1036
1045
  if (next < Infinity) expiryTimer = setTimeout(expire, next - now);
1037
1046
  if (removed) changed();
1038
1047
  }
1039
- const offs = [client.on("open", sendNow), client.on("message", (message) => {
1040
- const update = options.receive(message);
1041
- if (!update) return;
1042
- if (update.state === null) {
1043
- if (!peers.delete(update.peer)) return;
1044
- } else {
1045
- peers.set(update.peer, {
1046
- peer: update.peer,
1047
- state: update.state,
1048
- updatedAt: Date.now()
1049
- });
1050
- expiryTimer ??= setTimeout(expire, timeout);
1051
- }
1052
- changed();
1053
- })];
1048
+ const offs = [
1049
+ client.on("open", sendNow),
1050
+ client.on("message", (message) => {
1051
+ const update = options.receive(message);
1052
+ if (!update) return;
1053
+ if (update.state === null) {
1054
+ if (!peers.delete(update.peer)) return;
1055
+ } else {
1056
+ peers.set(update.peer, {
1057
+ peer: update.peer,
1058
+ state: update.state,
1059
+ updatedAt: Date.now()
1060
+ });
1061
+ expiryTimer ??= setTimeout(expire, timeout);
1062
+ }
1063
+ changed();
1064
+ }),
1065
+ client.subscribe(() => {
1066
+ if (client.getSnapshot().status !== "closed" || !peers.size) return;
1067
+ peers.clear();
1068
+ clearTimeout(expiryTimer);
1069
+ expiryTimer = void 0;
1070
+ changed();
1071
+ })
1072
+ ];
1054
1073
  return {
1055
1074
  client,
1056
1075
  set(state) {
1076
+ if (disposed) return;
1057
1077
  own = { state };
1058
- refreshTimer ??= setInterval(sendNow, options.refresh ?? timeout / 3);
1059
1078
  if (sendTimer !== void 0) return;
1060
1079
  const wait = lastSent + interval - Date.now();
1061
1080
  if (wait <= 0) sendNow();
@@ -1063,10 +1082,7 @@ function createWebSocketPresence(client, options) {
1063
1082
  },
1064
1083
  leave() {
1065
1084
  own = void 0;
1066
- clearTimeout(sendTimer);
1067
- sendTimer = void 0;
1068
- clearInterval(refreshTimer);
1069
- refreshTimer = void 0;
1085
+ stopSending();
1070
1086
  if (options.leave) client.send(options.leave(), VOLATILE$1);
1071
1087
  },
1072
1088
  getSnapshot: () => snapshot,
@@ -1077,17 +1093,20 @@ function createWebSocketPresence(client, options) {
1077
1093
  };
1078
1094
  },
1079
1095
  dispose() {
1080
- own = void 0;
1081
- clearTimeout(sendTimer);
1082
- clearInterval(refreshTimer);
1096
+ disposed = true;
1097
+ stopSending();
1083
1098
  clearTimeout(expiryTimer);
1084
1099
  for (const off of offs) off();
1085
1100
  }
1086
1101
  };
1087
1102
  }
1088
- //#endregion
1089
- //#region src/requests.ts
1103
+ // src/requests.ts
1090
1104
  const lastIds = /* @__PURE__ */ new WeakMap();
1105
+ /** @internal Method key on the client for what the devtools show, such as its queue length. */
1106
+ const INSPECT = Symbol.for("react-websocket.inspect");
1107
+ /** How many messages `client` holds in its send queue, if it tells. */
1108
+ const queued = (client) => client[INSPECT]?.().queued;
1109
+ const MAX_TIMEOUT$1 = 2 ** 31 - 1;
1091
1110
  const noop = () => {};
1092
1111
  /**
1093
1112
  * Send requests and await their replies, matched by an id the library generates.
@@ -1109,6 +1128,7 @@ const noop = () => {};
1109
1128
  */
1110
1129
  function createWebSocketRequests(client, options) {
1111
1130
  const waiting = /* @__PURE__ */ new Map();
1131
+ let disposed = false;
1112
1132
  function endWhere(test, reason, cancel) {
1113
1133
  for (const entry of [...waiting.values()]) if (test(entry)) entry.end(true, reason(), cancel);
1114
1134
  }
@@ -1141,6 +1161,10 @@ function createWebSocketRequests(client, options) {
1141
1161
  done(true, signal.reason);
1142
1162
  return noop;
1143
1163
  }
1164
+ if (disposed) {
1165
+ done(true, /* @__PURE__ */ new Error("Requests were disposed"));
1166
+ return noop;
1167
+ }
1144
1168
  if (client.getSnapshot().status === "closed") {
1145
1169
  done(true, /* @__PURE__ */ new Error("WebSocket is closed: request not sent"));
1146
1170
  return noop;
@@ -1154,7 +1178,7 @@ function createWebSocketRequests(client, options) {
1154
1178
  const onAbort = () => entry.end(true, signal.reason, true);
1155
1179
  function arm() {
1156
1180
  clearTimeout(timer);
1157
- if (timeout > 0 && timeout < Infinity) timer = setTimeout(() => entry.end(true, new DOMException(`Request ${id} timed out after ${timeout}ms`, "TimeoutError"), true), timeout);
1181
+ if (timeout > 0 && timeout <= MAX_TIMEOUT$1) timer = setTimeout(() => entry.end(true, new DOMException(`Request ${id} timed out after ${timeout}ms`, "TimeoutError"), true), timeout);
1158
1182
  }
1159
1183
  const entry = {
1160
1184
  socket: null,
@@ -1181,7 +1205,8 @@ function createWebSocketRequests(client, options) {
1181
1205
  waiting.set(key, entry);
1182
1206
  signal?.addEventListener("abort", onAbort, { once: true });
1183
1207
  arm();
1184
- if (client.getSnapshot().status === "idle") entry.end(true, /* @__PURE__ */ new Error("WebSocket is idle: request not sent"));
1208
+ const { status } = client.getSnapshot();
1209
+ if (status === "idle" || status === "closed") entry.end(true, /* @__PURE__ */ new Error(`WebSocket is ${status}: request not sent`));
1185
1210
  else try {
1186
1211
  if (client.send(options.send(message, id), {
1187
1212
  ...requestOptions,
@@ -1191,7 +1216,7 @@ function createWebSocketRequests(client, options) {
1191
1216
  }
1192
1217
  })) entry.socket = client.socket;
1193
1218
  else if (client.socket?.readyState === 1) entry.end(true, /* @__PURE__ */ new Error("WebSocket send buffer is full: request dropped"));
1194
- else if (requestOptions.volatile) entry.end(true, /* @__PURE__ */ new Error("WebSocket is not open: request dropped"));
1219
+ else if (requestOptions.volatile || queued(client) === 0) entry.end(true, /* @__PURE__ */ new Error("WebSocket is not open: request dropped"));
1195
1220
  } catch (error) {
1196
1221
  entry.end(true, error);
1197
1222
  }
@@ -1245,14 +1270,15 @@ function createWebSocketRequests(client, options) {
1245
1270
  },
1246
1271
  pending: () => waiting.size,
1247
1272
  dispose() {
1273
+ disposed = true;
1248
1274
  offs.forEach((off) => off());
1249
1275
  endWhere(() => true, () => /* @__PURE__ */ new Error("Requests were disposed"), true);
1250
1276
  }
1251
1277
  };
1252
1278
  }
1253
- //#endregion
1254
- //#region src/responder.ts
1279
+ // src/responder.ts
1255
1280
  const abortError = (message) => new DOMException(message, "AbortError");
1281
+ const MAX_TIMEOUT = 2 ** 31 - 1;
1256
1282
  /**
1257
1283
  * Answer requests the server sends: run a handler for tools that only exist in the browser
1258
1284
  * (selection, clipboard, geolocation), or let a person answer, e.g. to approve an agent's action.
@@ -1311,6 +1337,7 @@ function createWebSocketResponder(client, options) {
1311
1337
  reply(id, () => options.error(id, error));
1312
1338
  return;
1313
1339
  }
1340
+ const socket = client.socket;
1314
1341
  const controller = new AbortController();
1315
1342
  let timer;
1316
1343
  let done = false;
@@ -1322,7 +1349,7 @@ function createWebSocketResponder(client, options) {
1322
1349
  clearTimeout(timer);
1323
1350
  if (waiting.includes(request)) setWaiting(waiting.filter((entry) => entry !== request));
1324
1351
  if (reason !== void 0) controller.abort(reason);
1325
- return build ? reply(id, build) : false;
1352
+ return build && socket === client.socket ? reply(id, build) : false;
1326
1353
  }
1327
1354
  const answeredElsewhere = () => running ? abortError(`Request ${id} was answered elsewhere`) : void 0;
1328
1355
  const request = {
@@ -1337,14 +1364,14 @@ function createWebSocketResponder(client, options) {
1337
1364
  settle(() => options.error(id, error), error);
1338
1365
  };
1339
1366
  entries.set(key, {
1340
- socket: client.socket,
1367
+ socket,
1341
1368
  drop: (reason) => {
1342
1369
  settle(null, reason);
1343
1370
  },
1344
1371
  fail
1345
1372
  });
1346
1373
  const timeout = incoming.timeout ?? options.timeout ?? Infinity;
1347
- if (timeout > 0 && timeout < Infinity) timer = setTimeout(() => fail(new DOMException(`Request ${id} was not answered within ${timeout}ms`, "TimeoutError")), timeout);
1374
+ if (timeout > 0 && timeout <= MAX_TIMEOUT) timer = setTimeout(() => fail(new DOMException(`Request ${id} was not answered within ${timeout}ms`, "TimeoutError")), timeout);
1348
1375
  const { handler } = registration;
1349
1376
  if (!handler) {
1350
1377
  setWaiting([...waiting, request]);
@@ -1359,7 +1386,10 @@ function createWebSocketResponder(client, options) {
1359
1386
  request.reject(error);
1360
1387
  });
1361
1388
  }
1362
- const offs = [client.on("message", (message) => {
1389
+ const gone = /* @__PURE__ */ new WeakSet();
1390
+ let current = client.socket;
1391
+ const offs = [client.on("message", (message, event) => {
1392
+ if (gone.has(event.target)) return;
1363
1393
  const incoming = options.request(message);
1364
1394
  if (incoming != null) {
1365
1395
  receive(incoming);
@@ -1368,6 +1398,8 @@ function createWebSocketResponder(client, options) {
1368
1398
  const id = options.cancel?.(message);
1369
1399
  if (id != null) entries.get(String(id))?.drop(abortError(`Request ${id} was cancelled`));
1370
1400
  }), client.subscribe(() => {
1401
+ if (current && current !== client.socket) gone.add(current);
1402
+ current = client.socket;
1371
1403
  for (const entry of [...entries.values()]) if (entry.socket !== client.socket) entry.drop(abortError("WebSocket connection was lost before the request was answered"));
1372
1404
  })];
1373
1405
  return {
@@ -1396,8 +1428,7 @@ function createWebSocketResponder(client, options) {
1396
1428
  }
1397
1429
  };
1398
1430
  }
1399
- //#endregion
1400
- //#region src/runs.ts
1431
+ // src/runs.ts
1401
1432
  function randomId() {
1402
1433
  return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
1403
1434
  }
@@ -1504,8 +1535,8 @@ function createWebSocketRuns(client, options) {
1504
1535
  function follow(runId, policy, value = options.initial) {
1505
1536
  policies.set(runId, policy);
1506
1537
  remember(runId, policy);
1507
- set(runId, { value });
1508
1538
  releases.set(runId, feeds.acquire(runId));
1539
+ set(runId, { value });
1509
1540
  }
1510
1541
  function cancel(runId) {
1511
1542
  const message = options.cancel;
@@ -1553,7 +1584,7 @@ function createWebSocketRuns(client, options) {
1553
1584
  const previous = status;
1554
1585
  status = client.getSnapshot().status;
1555
1586
  if (previous !== "open" || status === "open") return;
1556
- for (const [runId, policy] of policies) if (policy === "cancel") abort(runId);
1587
+ for (const [runId, policy] of [...policies]) if (policy === "cancel") abort(runId);
1557
1588
  }),
1558
1589
  feeds.dispose
1559
1590
  ];
@@ -1634,8 +1665,7 @@ function createWebSocketRuns(client, options) {
1634
1665
  }
1635
1666
  };
1636
1667
  }
1637
- //#endregion
1638
- //#region src/sendrate.ts
1668
+ // src/sendrate.ts
1639
1669
  const VOLATILE = { volatile: true };
1640
1670
  /**
1641
1671
  * Send high-rate state, such as aim, cursor or position, at a rate that adapts to the
@@ -1751,8 +1781,7 @@ function createWebSocketSendRate(client, options = {}) {
1751
1781
  }
1752
1782
  };
1753
1783
  }
1754
- //#endregion
1755
- //#region src/state.ts
1784
+ // src/state.ts
1756
1785
  /**
1757
1786
  * Keep state derived from a client's messages, like a reducer that runs on every message.
1758
1787
  * It starts listening immediately and keeps the state across reconnects; it doesn't open
@@ -1816,7 +1845,6 @@ function createWebSocketState(source, options) {
1816
1845
  dispose: source.on("message", (message) => update((current) => reduce(current, message), batch === "frame"))
1817
1846
  };
1818
1847
  }
1819
- //#endregion
1820
1848
  exports.MessageError = MessageError;
1821
1849
  exports.createWebSocket = createWebSocket;
1822
1850
  exports.createWebSocketFeeds = createWebSocketFeeds;