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/cli/index.js CHANGED
@@ -79728,8 +79728,12 @@ function sendToPeer(peer, data) {
79728
79728
  }
79729
79729
  return false;
79730
79730
  }
79731
+ const json2 = JSON.stringify(data);
79732
+ if (messageType === "command_result" && json2.length > MAX_INLINE_JSON_MESSAGE_CHARS) {
79733
+ return sendChunkedCommandResult(peer, peerId, requestId, json2);
79734
+ }
79731
79735
  try {
79732
- peer.dataChannel.sendMessage(JSON.stringify(data));
79736
+ peer.dataChannel.sendMessage(json2);
79733
79737
  return true;
79734
79738
  } catch (error48) {
79735
79739
  if (messageType === "command_result") {
@@ -79738,6 +79742,28 @@ function sendToPeer(peer, data) {
79738
79742
  return false;
79739
79743
  }
79740
79744
  }
79745
+ function sendChunkedCommandResult(peer, peerId, requestId, json2) {
79746
+ const chunkId = requestId || `command_result_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
79747
+ const total = Math.ceil(json2.length / JSON_CHUNK_PAYLOAD_CHARS);
79748
+ logDebug(`command_result chunked: peer=${peerId} id=${requestId || "-"} chars=${json2.length} chunks=${total}`);
79749
+ for (let index = 0; index < total; index += 1) {
79750
+ const chunk = json2.slice(index * JSON_CHUNK_PAYLOAD_CHARS, (index + 1) * JSON_CHUNK_PAYLOAD_CHARS);
79751
+ try {
79752
+ peer.dataChannel?.sendMessage(JSON.stringify({
79753
+ type: "command_result_chunk",
79754
+ id: requestId,
79755
+ chunkId,
79756
+ index,
79757
+ total,
79758
+ data: chunk
79759
+ }));
79760
+ } catch (error48) {
79761
+ log(`command_result send failed: peer=${peerId} id=${requestId || "-"} chunk=${index + 1}/${total} error=${error48?.message || error48}`);
79762
+ return false;
79763
+ }
79764
+ }
79765
+ return true;
79766
+ }
79741
79767
  function routeDataChannelMessage(peerId, msg, peers, handlers) {
79742
79768
  const text = typeof msg === "string" ? msg : msg.toString("utf-8");
79743
79769
  try {
@@ -80018,11 +80044,14 @@ async function handleFileRequest(peerId, req, peers, handlers) {
80018
80044
  }
80019
80045
  sendToPeer(peer, response);
80020
80046
  }
80047
+ var MAX_INLINE_JSON_MESSAGE_CHARS, JSON_CHUNK_PAYLOAD_CHARS;
80021
80048
  var init_data_channel_router = __esm({
80022
80049
  "src/daemon-p2p/data-channel-router.ts"() {
80023
80050
  "use strict";
80024
80051
  init_permission();
80025
80052
  init_log();
80053
+ MAX_INLINE_JSON_MESSAGE_CHARS = 6e4;
80054
+ JSON_CHUNK_PAYLOAD_CHARS = 32e3;
80026
80055
  }
80027
80056
  });
80028
80057
 
@@ -88411,7 +88440,7 @@ var init_adhdev_daemon = __esm({
88411
88440
  init_version();
88412
88441
  init_src();
88413
88442
  init_runtime_defaults();
88414
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.42" });
88443
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.43" });
88415
88444
  AdhdevDaemon = class _AdhdevDaemon {
88416
88445
  localHttpServer = null;
88417
88446
  localWss = null;