simple-zstd 2.0.0 → 2.1.0
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/.github/workflows/ci.yml +5 -3
- package/.github/workflows/release.yml +9 -3
- package/CHANGELOG.md +6 -0
- package/README.md +39 -2
- package/dist/src/buffer-writable.js +6 -19
- package/dist/src/buffer-writable.js.map +1 -0
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.js +173 -83
- package/dist/src/index.js.map +1 -0
- package/dist/src/peek-transform.js +85 -98
- package/dist/src/peek-transform.js.map +1 -0
- package/dist/src/process-duplex.d.ts +13 -2
- package/dist/src/process-duplex.js +128 -108
- package/dist/src/process-duplex.js.map +1 -0
- package/dist/src/process-queue.js +41 -54
- package/dist/src/process-queue.js.map +1 -0
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -0
- package/package.json +16 -16
- package/src/index.ts +193 -48
- package/src/process-duplex.ts +112 -63
- package/src/types.ts +7 -0
- package/tsconfig.json +32 -99
|
@@ -1,54 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _PeekPassThrough_instances, _PeekPassThrough_maxBuffer, _PeekPassThrough_buffer, _PeekPassThrough_bufferedLength, _PeekPassThrough_peeked, _PeekPassThrough_peekCallback, _PeekPassThrough_swappedStream, _PeekPassThrough_ended, _PeekPassThrough_performPeek;
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
const node_stream_1 = require("node:stream");
|
|
16
4
|
class PeekPassThrough extends node_stream_1.Duplex {
|
|
5
|
+
#maxBuffer;
|
|
6
|
+
#buffer;
|
|
7
|
+
#bufferedLength;
|
|
8
|
+
#peeked;
|
|
9
|
+
#peekCallback;
|
|
10
|
+
#swappedStream;
|
|
11
|
+
#ended;
|
|
17
12
|
constructor(options, peekCallback) {
|
|
18
13
|
super(options);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
_PeekPassThrough_ended.set(this, void 0);
|
|
27
|
-
__classPrivateFieldSet(this, _PeekPassThrough_maxBuffer, options.maxBuffer || 65536, "f");
|
|
28
|
-
__classPrivateFieldSet(this, _PeekPassThrough_buffer, [], "f");
|
|
29
|
-
__classPrivateFieldSet(this, _PeekPassThrough_bufferedLength, 0, "f");
|
|
30
|
-
__classPrivateFieldSet(this, _PeekPassThrough_peeked, false, "f");
|
|
31
|
-
__classPrivateFieldSet(this, _PeekPassThrough_peekCallback, peekCallback, "f");
|
|
32
|
-
__classPrivateFieldSet(this, _PeekPassThrough_swappedStream, null, "f");
|
|
33
|
-
__classPrivateFieldSet(this, _PeekPassThrough_ended, false, "f");
|
|
14
|
+
this.#maxBuffer = options.maxBuffer || 65536;
|
|
15
|
+
this.#buffer = [];
|
|
16
|
+
this.#bufferedLength = 0;
|
|
17
|
+
this.#peeked = false;
|
|
18
|
+
this.#peekCallback = peekCallback;
|
|
19
|
+
this.#swappedStream = null;
|
|
20
|
+
this.#ended = false;
|
|
34
21
|
}
|
|
35
22
|
_write(chunk, encoding, callback) {
|
|
36
23
|
// If we already peeked and have a swapped stream, write to it
|
|
37
|
-
if (
|
|
38
|
-
|
|
24
|
+
if (this.#peeked && this.#swappedStream) {
|
|
25
|
+
this.#swappedStream.write(chunk, encoding, callback);
|
|
39
26
|
return;
|
|
40
27
|
}
|
|
41
28
|
// If we already peeked but no swap, just pass through
|
|
42
|
-
if (
|
|
29
|
+
if (this.#peeked) {
|
|
43
30
|
this.push(chunk);
|
|
44
31
|
callback();
|
|
45
32
|
return;
|
|
46
33
|
}
|
|
47
34
|
// Buffer chunks until we have enough to peek
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
35
|
+
this.#buffer.push(chunk);
|
|
36
|
+
this.#bufferedLength += chunk.length;
|
|
37
|
+
if (this.#bufferedLength >= this.#maxBuffer) {
|
|
38
|
+
this.#performPeek(callback);
|
|
52
39
|
}
|
|
53
40
|
else {
|
|
54
41
|
callback();
|
|
@@ -56,17 +43,17 @@ class PeekPassThrough extends node_stream_1.Duplex {
|
|
|
56
43
|
}
|
|
57
44
|
_final(callback) {
|
|
58
45
|
// If we haven't peeked yet and stream is ending, peek now
|
|
59
|
-
if (!
|
|
60
|
-
|
|
46
|
+
if (!this.#peeked) {
|
|
47
|
+
this.#performPeek(callback);
|
|
61
48
|
}
|
|
62
|
-
else if (
|
|
49
|
+
else if (this.#swappedStream) {
|
|
63
50
|
// End the swapped stream
|
|
64
|
-
|
|
51
|
+
this.#swappedStream.end(callback);
|
|
65
52
|
}
|
|
66
53
|
else {
|
|
67
54
|
// No swap - signal EOF for passthrough case
|
|
68
|
-
if (!
|
|
69
|
-
|
|
55
|
+
if (!this.#ended) {
|
|
56
|
+
this.#ended = true;
|
|
70
57
|
this.push(null);
|
|
71
58
|
}
|
|
72
59
|
callback();
|
|
@@ -74,72 +61,72 @@ class PeekPassThrough extends node_stream_1.Duplex {
|
|
|
74
61
|
}
|
|
75
62
|
_read(_size) {
|
|
76
63
|
// If we have a swapped stream, resume it if paused
|
|
77
|
-
if (
|
|
78
|
-
if (
|
|
79
|
-
|
|
64
|
+
if (this.#swappedStream) {
|
|
65
|
+
if (this.#swappedStream.isPaused && this.#swappedStream.isPaused()) {
|
|
66
|
+
this.#swappedStream.resume();
|
|
80
67
|
}
|
|
81
68
|
}
|
|
82
69
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
70
|
+
#performPeek(callback) {
|
|
71
|
+
this.#peeked = true;
|
|
72
|
+
const peekData = Buffer.concat(this.#buffer);
|
|
73
|
+
// Call the peek callback to determine which stream to use
|
|
74
|
+
this.#peekCallback(peekData, (err, swappedStream) => {
|
|
75
|
+
if (err) {
|
|
76
|
+
callback(err);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (swappedStream) {
|
|
80
|
+
// We have a swapped stream
|
|
81
|
+
this.#swappedStream = swappedStream;
|
|
82
|
+
// Pipe swapped stream's output to our output
|
|
83
|
+
swappedStream.on('data', (chunk) => {
|
|
84
|
+
if (!this.push(chunk)) {
|
|
85
|
+
swappedStream.pause();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
swappedStream.on('end', () => {
|
|
89
|
+
if (!this.#ended) {
|
|
90
|
+
this.#ended = true;
|
|
91
|
+
this.push(null);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
swappedStream.on('error', (streamErr) => {
|
|
95
|
+
this.destroy(streamErr);
|
|
96
|
+
});
|
|
97
|
+
// Resume reading when downstream is ready
|
|
98
|
+
this.on('drain', () => {
|
|
99
|
+
if (swappedStream.isPaused && swappedStream.isPaused()) {
|
|
100
|
+
swappedStream.resume();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
// Write all buffered data to the swapped stream
|
|
104
|
+
for (const bufferedChunk of this.#buffer) {
|
|
105
|
+
swappedStream.write(bufferedChunk);
|
|
112
106
|
}
|
|
113
|
-
|
|
114
|
-
swappedStream.on('error', (streamErr) => {
|
|
115
|
-
this.destroy(streamErr);
|
|
116
|
-
});
|
|
117
|
-
// Resume reading when downstream is ready
|
|
118
|
-
this.on('drain', () => {
|
|
107
|
+
// Ensure the swapped stream is in flowing mode
|
|
119
108
|
if (swappedStream.isPaused && swappedStream.isPaused()) {
|
|
120
109
|
swappedStream.resume();
|
|
121
110
|
}
|
|
122
|
-
});
|
|
123
|
-
// Write all buffered data to the swapped stream
|
|
124
|
-
for (const bufferedChunk of __classPrivateFieldGet(this, _PeekPassThrough_buffer, "f")) {
|
|
125
|
-
swappedStream.write(bufferedChunk);
|
|
126
|
-
}
|
|
127
|
-
// Ensure the swapped stream is in flowing mode
|
|
128
|
-
if (swappedStream.isPaused && swappedStream.isPaused()) {
|
|
129
|
-
swappedStream.resume();
|
|
130
111
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
112
|
+
else {
|
|
113
|
+
// No swap - just push buffered data through
|
|
114
|
+
for (const bufferedChunk of this.#buffer) {
|
|
115
|
+
this.push(bufferedChunk);
|
|
116
|
+
}
|
|
136
117
|
}
|
|
118
|
+
// Clear the buffer
|
|
119
|
+
this.#buffer = [];
|
|
120
|
+
this.#bufferedLength = 0;
|
|
121
|
+
callback();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
_destroy(error, callback) {
|
|
125
|
+
if (this.#swappedStream && !this.#swappedStream.destroyed) {
|
|
126
|
+
this.#swappedStream.destroy();
|
|
137
127
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
callback();
|
|
142
|
-
});
|
|
143
|
-
};
|
|
128
|
+
callback(error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
144
131
|
exports.default = PeekPassThrough;
|
|
145
|
-
//# sourceMappingURL=
|
|
132
|
+
//# sourceMappingURL=peek-transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peek-transform.js","sourceRoot":"","sources":["../../src/peek-transform.ts"],"names":[],"mappings":";;AAAA,6CAAqC;AAUrC,MAAqB,eAAgB,SAAQ,oBAAM;IACjD,UAAU,CAAS;IACnB,OAAO,CAAW;IAClB,eAAe,CAAS;IACxB,OAAO,CAAU;IACjB,aAAa,CAAe;IAC5B,cAAc,CAAgB;IAC9B,MAAM,CAAU;IAEhB,YAAY,OAAoB,EAAE,YAA0B;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,QAAwB,EAAE,QAAwC;QACtF,8DAA8D;QAC9D,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;QAED,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;gBACH,CAAC,CAAC,CAAC;gBAEH,gDAAgD;gBAChD,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACzC,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBACrC,CAAC;gBAED,+CAA+C;gBAC/C,IAAI,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC;oBACvD,aAAa,CAAC,MAAM,EAAE,CAAC;gBACzB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,4CAA4C;gBAC5C,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACzC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBAC3B,CAAC;YACH,CAAC;YAED,mBAAmB;YACnB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;YAClB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;YAEzB,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ,CAAC,KAAmB,EAAE,QAAuC;QACnE,IAAI,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;YAC1D,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC;QACD,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;CACF;AA9ID,kCA8IC"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { Duplex } from 'node:stream';
|
|
2
|
-
import { SpawnOptions } from 'node:child_process';
|
|
2
|
+
import { ChildProcess, SpawnOptions } from 'node:child_process';
|
|
3
3
|
import type { DuplexOptions } from 'node:stream';
|
|
4
|
+
type SpawnProcessFn = (command: string, args: string[], options?: SpawnOptions) => ChildProcess;
|
|
5
|
+
type NonZeroExitPolicy = boolean | ((code: number | null, signal: NodeJS.Signals | null) => boolean);
|
|
6
|
+
interface ProcessDuplexOptions {
|
|
7
|
+
command: string;
|
|
8
|
+
args: string[];
|
|
9
|
+
spawnOptions?: SpawnOptions;
|
|
10
|
+
streamOptions?: DuplexOptions;
|
|
11
|
+
nonZeroExitPolicy?: NonZeroExitPolicy;
|
|
12
|
+
spawnProcess?: SpawnProcessFn;
|
|
13
|
+
}
|
|
4
14
|
export default class ProcessDuplex extends Duplex {
|
|
5
15
|
#private;
|
|
6
|
-
constructor(
|
|
16
|
+
constructor(options: ProcessDuplexOptions);
|
|
7
17
|
_read(_size: number): void;
|
|
8
18
|
_write(chunk: Buffer, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
9
19
|
_final(callback: (error?: Error | null) => void): void;
|
|
10
20
|
_destroy(error: Error | null, callback: (error: Error | null) => void): void;
|
|
11
21
|
}
|
|
22
|
+
export {};
|
|
@@ -1,87 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _ProcessDuplex_process, _ProcessDuplex_stdoutDataHandler, _ProcessDuplex_stdoutEndHandler, _ProcessDuplex_stdoutErrorHandler, _ProcessDuplex_stdoutCloseHandler, _ProcessDuplex_stderrDataHandler, _ProcessDuplex_processExitHandler, _ProcessDuplex_processErrorHandler;
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
const node_stream_1 = require("node:stream");
|
|
16
4
|
const node_child_process_1 = require("node:child_process");
|
|
17
5
|
class ProcessDuplex extends node_stream_1.Duplex {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
#process;
|
|
7
|
+
#nonZeroExitPolicy;
|
|
8
|
+
#stdoutDataHandler;
|
|
9
|
+
#stdoutErrorHandler;
|
|
10
|
+
#stderrDataHandler;
|
|
11
|
+
#processCloseHandler;
|
|
12
|
+
#processErrorHandler;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super(options.streamOptions);
|
|
15
|
+
const { command, args, spawnOptions } = options;
|
|
16
|
+
const spawnProcess = options.spawnProcess ?? node_child_process_1.spawn;
|
|
17
|
+
this.#nonZeroExitPolicy = options.nonZeroExitPolicy;
|
|
28
18
|
// Spawn the child process
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
this.#process = spawnProcess(command, args, spawnOptions || {});
|
|
20
|
+
this.#setupProcessHandlers();
|
|
21
|
+
}
|
|
22
|
+
#setupProcessHandlers() {
|
|
23
|
+
this.#attachStdinHandler();
|
|
24
|
+
this.#attachStdoutHandler();
|
|
25
|
+
this.#attachStderrHandler();
|
|
26
|
+
this.#attachLifecycleHandlers();
|
|
27
|
+
}
|
|
28
|
+
#attachStdinHandler() {
|
|
29
|
+
if (this.#process.stdin) {
|
|
30
|
+
this.#process.stdin.on('error', (err) => {
|
|
31
|
+
if (!this.destroyed) {
|
|
32
|
+
this.destroy(err);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
#attachStdoutHandler() {
|
|
38
|
+
if (this.#process.stdout) {
|
|
39
|
+
this.#stdoutDataHandler = (chunk) => {
|
|
33
40
|
const canPushMore = this.push(chunk);
|
|
34
41
|
if (!canPushMore) {
|
|
35
|
-
|
|
42
|
+
this.#process.stdout?.pause();
|
|
36
43
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// Signal end of readable side
|
|
41
|
-
this.push(null);
|
|
42
|
-
}, "f");
|
|
43
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").stdout.on('end', __classPrivateFieldGet(this, _ProcessDuplex_stdoutEndHandler, "f"));
|
|
44
|
-
__classPrivateFieldSet(this, _ProcessDuplex_stdoutErrorHandler, (err) => {
|
|
44
|
+
};
|
|
45
|
+
this.#process.stdout.on('data', this.#stdoutDataHandler);
|
|
46
|
+
this.#stdoutErrorHandler = (err) => {
|
|
45
47
|
this.destroy(err);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
__classPrivateFieldSet(this, _ProcessDuplex_stdoutCloseHandler, () => {
|
|
49
|
-
// Ensure we signal end if not already done
|
|
50
|
-
this.push(null);
|
|
51
|
-
}, "f");
|
|
52
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").stdout.on('close', __classPrivateFieldGet(this, _ProcessDuplex_stdoutCloseHandler, "f"));
|
|
48
|
+
};
|
|
49
|
+
this.#process.stdout.on('error', this.#stdoutErrorHandler);
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
}
|
|
52
|
+
#attachStderrHandler() {
|
|
53
|
+
if (this.#process.stderr) {
|
|
54
|
+
this.#stderrDataHandler = (chunk) => {
|
|
57
55
|
// Emit stderr as a warning or error event
|
|
58
56
|
this.emit('stderr', chunk.toString());
|
|
59
|
-
}
|
|
60
|
-
|
|
57
|
+
};
|
|
58
|
+
this.#process.stderr.on('data', this.#stderrDataHandler);
|
|
61
59
|
}
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
}
|
|
61
|
+
#attachLifecycleHandlers() {
|
|
62
|
+
this.#processCloseHandler = (code, signal) => {
|
|
64
63
|
this.emit('exit', code, signal);
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
// Only end readable side after successful process completion.
|
|
65
|
+
if (code === 0 && signal === null && !this.readableEnded) {
|
|
66
|
+
this.push(null);
|
|
67
|
+
}
|
|
68
|
+
else if (this.#shouldErrorOnNonZeroExit(code, signal) && !this.destroyed) {
|
|
69
|
+
setImmediate(() => {
|
|
70
|
+
if (!this.destroyed) {
|
|
71
|
+
this.destroy(new Error(`zstd exited non zero. code: ${code} signal: ${signal}`));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
this.#process.on('close', this.#processCloseHandler);
|
|
67
77
|
// Handle process errors
|
|
68
|
-
|
|
78
|
+
this.#processErrorHandler = (err) => {
|
|
69
79
|
this.destroy(err);
|
|
70
|
-
}
|
|
71
|
-
|
|
80
|
+
};
|
|
81
|
+
this.#process.on('error', this.#processErrorHandler);
|
|
82
|
+
}
|
|
83
|
+
#shouldErrorOnNonZeroExit(code, signal) {
|
|
84
|
+
const policy = this.#nonZeroExitPolicy;
|
|
85
|
+
return typeof policy === 'function' ? policy(code, signal) : policy === true;
|
|
72
86
|
}
|
|
73
87
|
_read(_size) {
|
|
74
88
|
// Resume stdout if it was paused
|
|
75
|
-
if (
|
|
76
|
-
|
|
89
|
+
if (this.#process.stdout && this.#process.stdout.isPaused()) {
|
|
90
|
+
this.#process.stdout.resume();
|
|
77
91
|
}
|
|
78
92
|
}
|
|
79
93
|
_write(chunk, encoding, callback) {
|
|
80
94
|
// Write to the process stdin
|
|
81
|
-
if (
|
|
82
|
-
if (!
|
|
95
|
+
if (this.#process.stdin) {
|
|
96
|
+
if (!this.#process.stdin.write(chunk, encoding)) {
|
|
83
97
|
// If the write buffer is full, wait for drain
|
|
84
|
-
|
|
98
|
+
this.#process.stdin.once('drain', callback);
|
|
85
99
|
}
|
|
86
100
|
else {
|
|
87
101
|
callback();
|
|
@@ -93,65 +107,71 @@ class ProcessDuplex extends node_stream_1.Duplex {
|
|
|
93
107
|
}
|
|
94
108
|
_final(callback) {
|
|
95
109
|
// Close stdin when the writable side is finished
|
|
96
|
-
if (
|
|
97
|
-
|
|
110
|
+
if (this.#process.stdin) {
|
|
111
|
+
this.#process.stdin.end(callback);
|
|
98
112
|
}
|
|
99
113
|
else {
|
|
100
114
|
callback();
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
117
|
_destroy(error, callback) {
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").stdout.removeListener('error', __classPrivateFieldGet(this, _ProcessDuplex_stdoutErrorHandler, "f"));
|
|
112
|
-
if (__classPrivateFieldGet(this, _ProcessDuplex_stdoutCloseHandler, "f"))
|
|
113
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").stdout.removeListener('close', __classPrivateFieldGet(this, _ProcessDuplex_stdoutCloseHandler, "f"));
|
|
114
|
-
}
|
|
115
|
-
if (__classPrivateFieldGet(this, _ProcessDuplex_process, "f").stderr && __classPrivateFieldGet(this, _ProcessDuplex_stderrDataHandler, "f")) {
|
|
116
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").stderr.removeListener('data', __classPrivateFieldGet(this, _ProcessDuplex_stderrDataHandler, "f"));
|
|
117
|
-
}
|
|
118
|
-
if (__classPrivateFieldGet(this, _ProcessDuplex_processExitHandler, "f")) {
|
|
119
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").removeListener('exit', __classPrivateFieldGet(this, _ProcessDuplex_processExitHandler, "f"));
|
|
120
|
-
}
|
|
121
|
-
if (__classPrivateFieldGet(this, _ProcessDuplex_processErrorHandler, "f")) {
|
|
122
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").removeListener('error', __classPrivateFieldGet(this, _ProcessDuplex_processErrorHandler, "f"));
|
|
123
|
-
}
|
|
124
|
-
// Kill the child process and wait for it to exit
|
|
125
|
-
if (__classPrivateFieldGet(this, _ProcessDuplex_process, "f") && !__classPrivateFieldGet(this, _ProcessDuplex_process, "f").killed) {
|
|
126
|
-
// Close stdin first so the process receives EOF and can exit cleanly
|
|
127
|
-
if (__classPrivateFieldGet(this, _ProcessDuplex_process, "f").stdin && !__classPrivateFieldGet(this, _ProcessDuplex_process, "f").stdin.destroyed) {
|
|
128
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").stdin.end();
|
|
129
|
-
}
|
|
130
|
-
// Wait for the process to fully exit before calling callback
|
|
131
|
-
const onClose = () => {
|
|
132
|
-
clearTimeout(forceKillTimeout);
|
|
133
|
-
callback(error);
|
|
134
|
-
};
|
|
135
|
-
// Set up close listener
|
|
136
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").once('close', onClose);
|
|
137
|
-
// Kill the process (should exit quickly now that stdin is closed)
|
|
138
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").kill();
|
|
139
|
-
// Force kill if process doesn't exit within 1 second
|
|
140
|
-
const forceKillTimeout = setTimeout(() => {
|
|
141
|
-
if (!__classPrivateFieldGet(this, _ProcessDuplex_process, "f").killed) {
|
|
142
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").kill('SIGKILL');
|
|
143
|
-
}
|
|
144
|
-
// Remove the close listener and call callback
|
|
145
|
-
__classPrivateFieldGet(this, _ProcessDuplex_process, "f").removeListener('close', onClose);
|
|
146
|
-
callback(error);
|
|
147
|
-
}, 1000);
|
|
118
|
+
this.#removeEventListeners();
|
|
119
|
+
if (this.#hasExited()) {
|
|
120
|
+
callback(error);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (this.#process && !this.#process.killed) {
|
|
124
|
+
this.#terminateProcess(error, callback);
|
|
148
125
|
}
|
|
149
126
|
else {
|
|
150
|
-
// Process already killed or doesn't exist
|
|
151
127
|
callback(error);
|
|
152
128
|
}
|
|
153
129
|
}
|
|
130
|
+
#removeEventListeners() {
|
|
131
|
+
if (this.#process.stdout) {
|
|
132
|
+
if (this.#stdoutDataHandler)
|
|
133
|
+
this.#process.stdout.removeListener('data', this.#stdoutDataHandler);
|
|
134
|
+
if (this.#stdoutErrorHandler)
|
|
135
|
+
this.#process.stdout.removeListener('error', this.#stdoutErrorHandler);
|
|
136
|
+
}
|
|
137
|
+
if (this.#process.stderr && this.#stderrDataHandler) {
|
|
138
|
+
this.#process.stderr.removeListener('data', this.#stderrDataHandler);
|
|
139
|
+
}
|
|
140
|
+
if (this.#processCloseHandler) {
|
|
141
|
+
this.#process.removeListener('close', this.#processCloseHandler);
|
|
142
|
+
}
|
|
143
|
+
if (this.#processErrorHandler) {
|
|
144
|
+
this.#process.removeListener('error', this.#processErrorHandler);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
#hasExited() {
|
|
148
|
+
return this.#process.exitCode !== null || this.#process.signalCode !== null;
|
|
149
|
+
}
|
|
150
|
+
#terminateProcess(error, callback) {
|
|
151
|
+
let callbackCalled = false;
|
|
152
|
+
const finishDestroy = () => {
|
|
153
|
+
if (callbackCalled)
|
|
154
|
+
return;
|
|
155
|
+
callbackCalled = true;
|
|
156
|
+
this.#process.removeListener('close', onClose);
|
|
157
|
+
callback(error);
|
|
158
|
+
};
|
|
159
|
+
if (this.#process.stdin && !this.#process.stdin.destroyed) {
|
|
160
|
+
this.#process.stdin.end();
|
|
161
|
+
}
|
|
162
|
+
const onClose = () => {
|
|
163
|
+
clearTimeout(forceKillTimeout);
|
|
164
|
+
finishDestroy();
|
|
165
|
+
};
|
|
166
|
+
this.#process.once('close', onClose);
|
|
167
|
+
this.#process.kill();
|
|
168
|
+
const forceKillTimeout = setTimeout(() => {
|
|
169
|
+
if (!this.#hasExited()) {
|
|
170
|
+
this.#process.kill('SIGKILL');
|
|
171
|
+
}
|
|
172
|
+
setTimeout(finishDestroy, 100);
|
|
173
|
+
}, 1000);
|
|
174
|
+
}
|
|
154
175
|
}
|
|
155
|
-
_ProcessDuplex_process = new WeakMap(), _ProcessDuplex_stdoutDataHandler = new WeakMap(), _ProcessDuplex_stdoutEndHandler = new WeakMap(), _ProcessDuplex_stdoutErrorHandler = new WeakMap(), _ProcessDuplex_stdoutCloseHandler = new WeakMap(), _ProcessDuplex_stderrDataHandler = new WeakMap(), _ProcessDuplex_processExitHandler = new WeakMap(), _ProcessDuplex_processErrorHandler = new WeakMap();
|
|
156
176
|
exports.default = ProcessDuplex;
|
|
157
|
-
//# sourceMappingURL=
|
|
177
|
+
//# sourceMappingURL=process-duplex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-duplex.js","sourceRoot":"","sources":["../../src/process-duplex.ts"],"names":[],"mappings":";;AAAA,6CAAqC;AACrC,2DAAuE;AAiBvE,MAAqB,aAAc,SAAQ,oBAAM;IAC/C,QAAQ,CAAe;IACvB,kBAAkB,CAAqB;IACvC,kBAAkB,CAA2B;IAC7C,mBAAmB,CAAwB;IAC3C,kBAAkB,CAA2B;IAC7C,oBAAoB,CAAgE;IACpF,oBAAoB,CAAwB;IAE5C,YAAY,OAA6B;QACvC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAE7B,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QAChD,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAK,0BAAmC,CAAC;QAClF,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;QAEpD,0BAA0B;QAC1B,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC/B,CAAC;IA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