adhdev 0.9.42 → 0.9.43

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/index.js CHANGED
@@ -47513,8 +47513,12 @@ function sendToPeer(peer, data) {
47513
47513
  }
47514
47514
  return false;
47515
47515
  }
47516
+ const json2 = JSON.stringify(data);
47517
+ if (messageType === "command_result" && json2.length > MAX_INLINE_JSON_MESSAGE_CHARS) {
47518
+ return sendChunkedCommandResult(peer, peerId, requestId, json2);
47519
+ }
47516
47520
  try {
47517
- peer.dataChannel.sendMessage(JSON.stringify(data));
47521
+ peer.dataChannel.sendMessage(json2);
47518
47522
  return true;
47519
47523
  } catch (error48) {
47520
47524
  if (messageType === "command_result") {
@@ -47523,6 +47527,28 @@ function sendToPeer(peer, data) {
47523
47527
  return false;
47524
47528
  }
47525
47529
  }
47530
+ function sendChunkedCommandResult(peer, peerId, requestId, json2) {
47531
+ const chunkId = requestId || `command_result_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
47532
+ const total = Math.ceil(json2.length / JSON_CHUNK_PAYLOAD_CHARS);
47533
+ logDebug(`command_result chunked: peer=${peerId} id=${requestId || "-"} chars=${json2.length} chunks=${total}`);
47534
+ for (let index = 0; index < total; index += 1) {
47535
+ const chunk = json2.slice(index * JSON_CHUNK_PAYLOAD_CHARS, (index + 1) * JSON_CHUNK_PAYLOAD_CHARS);
47536
+ try {
47537
+ peer.dataChannel?.sendMessage(JSON.stringify({
47538
+ type: "command_result_chunk",
47539
+ id: requestId,
47540
+ chunkId,
47541
+ index,
47542
+ total,
47543
+ data: chunk
47544
+ }));
47545
+ } catch (error48) {
47546
+ log(`command_result send failed: peer=${peerId} id=${requestId || "-"} chunk=${index + 1}/${total} error=${error48?.message || error48}`);
47547
+ return false;
47548
+ }
47549
+ }
47550
+ return true;
47551
+ }
47526
47552
  function routeDataChannelMessage(peerId, msg, peers, handlers) {
47527
47553
  const text = typeof msg === "string" ? msg : msg.toString("utf-8");
47528
47554
  try {
@@ -47803,11 +47829,14 @@ async function handleFileRequest(peerId, req, peers, handlers) {
47803
47829
  }
47804
47830
  sendToPeer(peer, response);
47805
47831
  }
47832
+ var MAX_INLINE_JSON_MESSAGE_CHARS, JSON_CHUNK_PAYLOAD_CHARS;
47806
47833
  var init_data_channel_router = __esm({
47807
47834
  "src/daemon-p2p/data-channel-router.ts"() {
47808
47835
  "use strict";
47809
47836
  init_permission();
47810
47837
  init_log();
47838
+ MAX_INLINE_JSON_MESSAGE_CHARS = 6e4;
47839
+ JSON_CHUNK_PAYLOAD_CHARS = 32e3;
47811
47840
  }
47812
47841
  });
47813
47842
 
@@ -56690,7 +56719,7 @@ var init_adhdev_daemon = __esm({
56690
56719
  init_version();
56691
56720
  init_src();
56692
56721
  init_runtime_defaults();
56693
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.42" });
56722
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.43" });
56694
56723
  AdhdevDaemon = class _AdhdevDaemon {
56695
56724
  localHttpServer = null;
56696
56725
  localWss = null;