@nextclaw/remote 0.1.24 → 0.1.26

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 (2) hide show
  1. package/dist/index.js +5 -37
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -437,30 +437,11 @@ function parseRemoteSseFrame(frame) {
437
437
  return { event, payload: data };
438
438
  }
439
439
  }
440
- function readRemoteStreamError(payload, fallback) {
441
- if (typeof payload === "object" && payload && "error" in payload) {
442
- const typed = payload;
443
- if (typed.error?.message) {
444
- return typed.error.message;
445
- }
446
- }
447
- if (typeof payload === "string" && payload.trim()) {
448
- return payload.trim();
449
- }
450
- return fallback;
451
- }
452
440
  function processRemoteStreamFrame(params) {
453
441
  const frame = parseRemoteSseFrame(params.rawFrame);
454
442
  if (!frame) {
455
443
  return;
456
444
  }
457
- if (frame.event === "final") {
458
- params.setFinalResult(frame.payload);
459
- return;
460
- }
461
- if (frame.event === "error") {
462
- throw new Error(readRemoteStreamError(frame.payload, "stream failed"));
463
- }
464
445
  params.onEvent(frame);
465
446
  }
466
447
  function flushRemoteStreamFrames(params) {
@@ -468,8 +449,7 @@ function flushRemoteStreamFrames(params) {
468
449
  while (boundary !== -1) {
469
450
  processRemoteStreamFrame({
470
451
  rawFrame: params.bufferState.value.slice(0, boundary),
471
- onEvent: params.onEvent,
472
- setFinalResult: params.setFinalResult
452
+ onEvent: params.onEvent
473
453
  });
474
454
  params.bufferState.value = params.bufferState.value.slice(boundary + 2);
475
455
  boundary = params.bufferState.value.indexOf("\n\n");
@@ -482,7 +462,6 @@ async function readRemoteAppStreamResult(params) {
482
462
  }
483
463
  const decoder = new TextDecoder();
484
464
  const bufferState = { value: "" };
485
- let finalResult = void 0;
486
465
  try {
487
466
  while (true) {
488
467
  const { value, done } = await reader.read();
@@ -492,28 +471,18 @@ async function readRemoteAppStreamResult(params) {
492
471
  bufferState.value += decoder.decode(value, { stream: true });
493
472
  flushRemoteStreamFrames({
494
473
  bufferState,
495
- onEvent: params.onEvent,
496
- setFinalResult: (nextValue) => {
497
- finalResult = nextValue;
498
- }
474
+ onEvent: params.onEvent
499
475
  });
500
476
  }
501
477
  if (bufferState.value.trim()) {
502
478
  processRemoteStreamFrame({
503
479
  rawFrame: bufferState.value,
504
- onEvent: params.onEvent,
505
- setFinalResult: (nextValue) => {
506
- finalResult = nextValue;
507
- }
480
+ onEvent: params.onEvent
508
481
  });
509
482
  }
510
483
  } finally {
511
484
  reader.releaseLock();
512
485
  }
513
- if (finalResult === void 0) {
514
- throw new Error("stream ended without final event");
515
- }
516
- return finalResult;
517
486
  }
518
487
 
519
488
  // src/remote-app.adapter.ts
@@ -604,7 +573,7 @@ var RemoteAppAdapter = class {
604
573
  if (!response) {
605
574
  return;
606
575
  }
607
- const finalResult = await readRemoteAppStreamResult({
576
+ await readRemoteAppStreamResult({
608
577
  response,
609
578
  onEvent: (event) => {
610
579
  this.send({
@@ -619,8 +588,7 @@ var RemoteAppAdapter = class {
619
588
  this.send({
620
589
  type: "client.stream.end",
621
590
  clientId: frame.clientId,
622
- streamId: frame.streamId,
623
- result: finalResult
591
+ streamId: frame.streamId
624
592
  });
625
593
  } catch (error) {
626
594
  if (controller.signal.aborted) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/remote",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "private": false,
5
5
  "description": "Remote access runtime for NextClaw device registration, relay bridging, and service-managed connectivity.",
6
6
  "type": "module",
@@ -30,8 +30,8 @@
30
30
  "dependencies": {
31
31
  "commander": "^12.1.0",
32
32
  "ws": "^8.18.0",
33
- "@nextclaw/core": "0.9.11",
34
- "@nextclaw/server": "0.10.28"
33
+ "@nextclaw/server": "0.10.32",
34
+ "@nextclaw/core": "0.9.11"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^20.17.6",