@superdoc/sdk 2.13.0-next.11 → 2.13.0-next.13

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.
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var node_child_process = require('node:child_process');
4
- var node_readline = require('node:readline');
5
4
  var transportCommon = require('./transport-common.cjs');
6
5
  var errors = require('./errors.cjs');
7
6
  var documentEvidence = require('./document-evidence.cjs');
@@ -96,7 +95,8 @@ class HostTransport {
96
95
  user;
97
96
  documentRpcEnabled;
98
97
  child = null;
99
- stdoutReader = null;
98
+ stdoutBuffer = '';
99
+ stdoutDataListener = null;
100
100
  pending = new Map();
101
101
  nextRequestId = 1;
102
102
  connecting = null;
@@ -418,14 +418,12 @@ class HostTransport {
418
418
  stdio: ['pipe', 'pipe', 'pipe'],
419
419
  });
420
420
  this.child = child;
421
- const stdoutReader = node_readline.createInterface({
422
- input: child.stdout,
423
- crlfDelay: Number.POSITIVE_INFINITY,
424
- });
425
- this.stdoutReader = stdoutReader;
426
- stdoutReader.on('line', (line) => {
427
- this.onStdoutLine(line);
428
- });
421
+ // JSON-RPC is framed by ASCII LF; Node 24 readline also splits on a raw
422
+ // U+2028 inside otherwise valid JSON string data.
423
+ child.stdout.setEncoding('utf8');
424
+ const stdoutDataListener = (chunk) => this.onStdoutChunk(chunk);
425
+ this.stdoutDataListener = stdoutDataListener;
426
+ child.stdout.on('data', stdoutDataListener);
429
427
  child.stderr.on('data', (chunk) => {
430
428
  if (!FORWARD_HOST_STDERR) {
431
429
  return;
@@ -672,6 +670,18 @@ class HostTransport {
672
670
  }
673
671
  pending.resolve(record.result);
674
672
  }
673
+ onStdoutChunk(chunk) {
674
+ this.stdoutBuffer += chunk;
675
+ let newlineIndex = this.stdoutBuffer.indexOf('\n');
676
+ while (newlineIndex !== -1) {
677
+ let line = this.stdoutBuffer.slice(0, newlineIndex);
678
+ this.stdoutBuffer = this.stdoutBuffer.slice(newlineIndex + 1);
679
+ if (line.endsWith('\r'))
680
+ line = line.slice(0, -1);
681
+ this.onStdoutLine(line);
682
+ newlineIndex = this.stdoutBuffer.indexOf('\n');
683
+ }
684
+ }
675
685
  mapJsonRpcError(rawError) {
676
686
  if (typeof rawError !== 'object' || rawError == null || Array.isArray(rawError)) {
677
687
  return new errors.SuperDocCliError('Host returned an unknown JSON-RPC error.', {
@@ -730,15 +740,14 @@ class HostTransport {
730
740
  this.indeterminateDiscardCloses.clear();
731
741
  const child = this.child;
732
742
  if (child) {
743
+ if (this.stdoutDataListener)
744
+ child.stdout.off('data', this.stdoutDataListener);
733
745
  child.removeAllListeners();
734
746
  child.kill('SIGKILL');
735
747
  }
736
748
  this.child = null;
737
- if (this.stdoutReader) {
738
- this.stdoutReader.removeAllListeners();
739
- this.stdoutReader.close();
740
- this.stdoutReader = null;
741
- }
749
+ this.stdoutBuffer = '';
750
+ this.stdoutDataListener = null;
742
751
  const pendingEntries = Array.from(this.pending.values());
743
752
  this.pending.clear();
744
753
  const rejection = error ??
@@ -43,7 +43,8 @@ export declare class HostTransport {
43
43
  private readonly user?;
44
44
  private readonly documentRpcEnabled;
45
45
  private child;
46
- private stdoutReader;
46
+ private stdoutBuffer;
47
+ private stdoutDataListener;
47
48
  private readonly pending;
48
49
  private nextRequestId;
49
50
  private connecting;
@@ -82,6 +83,7 @@ export declare class HostTransport {
82
83
  private reconcileIndeterminateDiscardCloses;
83
84
  private sendJsonRpcRequest;
84
85
  private onStdoutLine;
86
+ private onStdoutChunk;
85
87
  private mapJsonRpcError;
86
88
  private handleDisconnect;
87
89
  private cleanupProcess;
@@ -1,5 +1,4 @@
1
1
  import { spawn } from 'node:child_process';
2
- import { createInterface } from 'node:readline';
3
2
  import { buildOperationArgv, normalizeCollaborationAuth, resolveInvocation, } from './transport-common.js';
4
3
  import { SuperDocCliError } from './errors.js';
5
4
  import { registerMutationRevision } from './document-evidence.js';
@@ -93,7 +92,8 @@ export class HostTransport {
93
92
  user;
94
93
  documentRpcEnabled;
95
94
  child = null;
96
- stdoutReader = null;
95
+ stdoutBuffer = '';
96
+ stdoutDataListener = null;
97
97
  pending = new Map();
98
98
  nextRequestId = 1;
99
99
  connecting = null;
@@ -415,14 +415,12 @@ export class HostTransport {
415
415
  stdio: ['pipe', 'pipe', 'pipe'],
416
416
  });
417
417
  this.child = child;
418
- const stdoutReader = createInterface({
419
- input: child.stdout,
420
- crlfDelay: Number.POSITIVE_INFINITY,
421
- });
422
- this.stdoutReader = stdoutReader;
423
- stdoutReader.on('line', (line) => {
424
- this.onStdoutLine(line);
425
- });
418
+ // JSON-RPC is framed by ASCII LF; Node 24 readline also splits on a raw
419
+ // U+2028 inside otherwise valid JSON string data.
420
+ child.stdout.setEncoding('utf8');
421
+ const stdoutDataListener = (chunk) => this.onStdoutChunk(chunk);
422
+ this.stdoutDataListener = stdoutDataListener;
423
+ child.stdout.on('data', stdoutDataListener);
426
424
  child.stderr.on('data', (chunk) => {
427
425
  if (!FORWARD_HOST_STDERR) {
428
426
  return;
@@ -669,6 +667,18 @@ export class HostTransport {
669
667
  }
670
668
  pending.resolve(record.result);
671
669
  }
670
+ onStdoutChunk(chunk) {
671
+ this.stdoutBuffer += chunk;
672
+ let newlineIndex = this.stdoutBuffer.indexOf('\n');
673
+ while (newlineIndex !== -1) {
674
+ let line = this.stdoutBuffer.slice(0, newlineIndex);
675
+ this.stdoutBuffer = this.stdoutBuffer.slice(newlineIndex + 1);
676
+ if (line.endsWith('\r'))
677
+ line = line.slice(0, -1);
678
+ this.onStdoutLine(line);
679
+ newlineIndex = this.stdoutBuffer.indexOf('\n');
680
+ }
681
+ }
672
682
  mapJsonRpcError(rawError) {
673
683
  if (typeof rawError !== 'object' || rawError == null || Array.isArray(rawError)) {
674
684
  return new SuperDocCliError('Host returned an unknown JSON-RPC error.', {
@@ -727,15 +737,14 @@ export class HostTransport {
727
737
  this.indeterminateDiscardCloses.clear();
728
738
  const child = this.child;
729
739
  if (child) {
740
+ if (this.stdoutDataListener)
741
+ child.stdout.off('data', this.stdoutDataListener);
730
742
  child.removeAllListeners();
731
743
  child.kill('SIGKILL');
732
744
  }
733
745
  this.child = null;
734
- if (this.stdoutReader) {
735
- this.stdoutReader.removeAllListeners();
736
- this.stdoutReader.close();
737
- this.stdoutReader = null;
738
- }
746
+ this.stdoutBuffer = '';
747
+ this.stdoutDataListener = null;
739
748
  const pendingEntries = Array.from(this.pending.values());
740
749
  this.pending.clear();
741
750
  const rejection = error ??
@@ -3,6 +3,6 @@
3
3
  // AUTO-GENERATED by scripts/embed-version.mjs — DO NOT EDIT.
4
4
  // Source of truth: package.json. Regenerated on every SDK build so the
5
5
  // SDK retains its own version identity when bundled into another package.
6
- const SDK_VERSION = '2.13.0-next.11';
6
+ const SDK_VERSION = '2.13.0-next.13';
7
7
 
8
8
  exports.SDK_VERSION = SDK_VERSION;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.13.0-next.11";
1
+ export declare const SDK_VERSION = "2.13.0-next.13";
@@ -1,4 +1,4 @@
1
1
  // AUTO-GENERATED by scripts/embed-version.mjs — DO NOT EDIT.
2
2
  // Source of truth: package.json. Regenerated on every SDK build so the
3
3
  // SDK retains its own version identity when bundled into another package.
4
- export const SDK_VERSION = '2.13.0-next.11';
4
+ export const SDK_VERSION = '2.13.0-next.13';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/sdk",
3
- "version": "2.13.0-next.11",
3
+ "version": "2.13.0-next.13",
4
4
  "description": "Node SDK for SuperDoc, wrapping the SuperDoc CLI to read and edit .docx files from JavaScript and TypeScript.",
5
5
  "private": false,
6
6
  "license": "AGPL-3.0",
@@ -38,11 +38,11 @@
38
38
  "typescript": "^5.9.2"
39
39
  },
40
40
  "optionalDependencies": {
41
- "@superdoc/sdk-darwin-arm64": "2.13.0-next.11",
42
- "@superdoc/sdk-darwin-x64": "2.13.0-next.11",
43
- "@superdoc/sdk-linux-x64": "2.13.0-next.11",
44
- "@superdoc/sdk-linux-arm64": "2.13.0-next.11",
45
- "@superdoc/sdk-windows-x64": "2.13.0-next.11"
41
+ "@superdoc/sdk-darwin-arm64": "2.13.0-next.13",
42
+ "@superdoc/sdk-darwin-x64": "2.13.0-next.13",
43
+ "@superdoc/sdk-linux-x64": "2.13.0-next.13",
44
+ "@superdoc/sdk-linux-arm64": "2.13.0-next.13",
45
+ "@superdoc/sdk-windows-x64": "2.13.0-next.13"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public"
@@ -43,5 +43,5 @@
43
43
  "mutates": true
44
44
  }
45
45
  ],
46
- "contractHash": "6ef0c6c7eda5352f27c1908e39b11cd8bca73535a321a750ef6866eb01cfd26f"
46
+ "contractHash": "bb8c2d16cd5b801eb5ff07c6c5b948bde1ea261cc86491bae31f2e2182806783"
47
47
  }