neoctl 0.2.62 → 0.2.63

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/web/index.js CHANGED
@@ -855,7 +855,7 @@ export class WebRepl {
855
855
  });
856
856
  if (clientInfo)
857
857
  this.send(subscriber, "client.version", clientInfo);
858
- this.send(subscriber, "sync", this.snapshot(true));
858
+ this.sendSubscriberSnapshot(subscriber, this.snapshot(true));
859
859
  this.publishRuntimeContext([subscriber]);
860
860
  reqKeepAlive(res);
861
861
  res.on("close", () => this.subscribers.delete(subscriber));
@@ -2707,7 +2707,7 @@ export class WebRepl {
2707
2707
  }
2708
2708
  if (subscriber.needsSync) {
2709
2709
  subscriber.needsSync = false;
2710
- this.send(subscriber, "sync", this.snapshot(false));
2710
+ this.sendSubscriberSnapshot(subscriber, this.snapshot(false));
2711
2711
  }
2712
2712
  if (subscriber.pendingFastModeFallback) {
2713
2713
  const payload = subscriber.pendingFastModeFallback;
@@ -2773,7 +2773,8 @@ export class WebRepl {
2773
2773
  this.pendingDeltaTimer = undefined;
2774
2774
  if (this.pendingDeltaOperations.length === 0 && !this.pendingDeltaStatus)
2775
2775
  return;
2776
- const operations = compactLineOperations(this.pendingDeltaOperations);
2776
+ const pending = this.pendingDeltaOperations;
2777
+ const operations = compactLineOperations(pending);
2777
2778
  this.pendingDeltaOperations = [];
2778
2779
  this.pendingDeltaStatus = false;
2779
2780
  const payload = {
@@ -2782,8 +2783,12 @@ export class WebRepl {
2782
2783
  operations,
2783
2784
  status: this.timedStatus(),
2784
2785
  };
2785
- for (const subscriber of this.subscribers)
2786
- this.send(subscriber, "delta", payload);
2786
+ for (const subscriber of this.subscribers) {
2787
+ const offset = subscriber.snapshotDeltaOffset ?? 0;
2788
+ subscriber.snapshotDeltaOffset = undefined;
2789
+ // Text appends are not idempotent: skip operations its own snapshot already contains.
2790
+ this.send(subscriber, "delta", offset > 0 ? { ...payload, operations: compactLineOperations(pending.slice(offset)) } : payload);
2791
+ }
2787
2792
  }
2788
2793
  discardPendingDeltaOperations() {
2789
2794
  if (this.pendingDeltaTimer)
@@ -2791,6 +2796,13 @@ export class WebRepl {
2791
2796
  this.pendingDeltaTimer = undefined;
2792
2797
  this.pendingDeltaOperations = [];
2793
2798
  this.pendingDeltaStatus = false;
2799
+ for (const subscriber of this.subscribers)
2800
+ subscriber.snapshotDeltaOffset = undefined;
2801
+ }
2802
+ /** Snapshot for one subscriber; it already includes every currently queued delta operation. */
2803
+ sendSubscriberSnapshot(subscriber, snapshot) {
2804
+ subscriber.snapshotDeltaOffset = this.pendingDeltaOperations.length;
2805
+ this.send(subscriber, "sync", snapshot);
2794
2806
  }
2795
2807
  dropInactiveTerminalOutput() {
2796
2808
  for (const sessionId of this.pendingTerminalOutput.keys()) {