@hot-updater/console 0.28.0 → 0.29.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/.output/nitro.json +17 -0
- package/.output/public/apple-touch-icon.png +0 -0
- package/.output/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/.output/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/.output/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/.output/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/.output/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/.output/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/.output/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/.output/public/assets/main-Dlx8-qN-.js +61 -0
- package/.output/public/assets/routes-DB0tWmiJ.js +10 -0
- package/.output/public/assets/styles-Bfxg4M1x.css +2 -0
- package/.output/public/favicon-16x16.png +0 -0
- package/.output/public/favicon-32x32.png +0 -0
- package/.output/public/favicon.ico +0 -0
- package/.output/public/logo.svg +1 -0
- package/.output/public/manifest.json +30 -0
- package/.output/public/robots.txt +3 -0
- package/.output/server/_chunks/ssr-renderer.mjs +15 -0
- package/.output/server/_libs/@floating-ui/core+[...].mjs +698 -0
- package/.output/server/_libs/@floating-ui/dom+[...].mjs +644 -0
- package/.output/server/_libs/@floating-ui/react-dom+[...].mjs +839 -0
- package/.output/server/_libs/@radix-ui/react-alert-dialog+[...].mjs +2093 -0
- package/.output/server/_libs/@radix-ui/react-popper+[...].mjs +287 -0
- package/.output/server/_libs/@radix-ui/react-select+[...].mjs +1003 -0
- package/.output/server/_libs/@tanstack/devtools-event-client+[...].mjs +196 -0
- package/.output/server/_libs/@tanstack/form-core+[...].mjs +2396 -0
- package/.output/server/_libs/@tanstack/react-form+[...].mjs +298 -0
- package/.output/server/_libs/@tanstack/react-router+[...].mjs +13068 -0
- package/.output/server/_libs/@tanstack/react-table+[...].mjs +2372 -0
- package/.output/server/_libs/chownr.mjs +60 -0
- package/.output/server/_libs/class-variance-authority+clsx.mjs +69 -0
- package/.output/server/_libs/core-util-is.mjs +67 -0
- package/.output/server/_libs/dayjs.mjs +408 -0
- package/.output/server/_libs/h3+rou3+srvx.mjs +1158 -0
- package/.output/server/_libs/hookable.mjs +41 -0
- package/.output/server/_libs/immediate.mjs +57 -0
- package/.output/server/_libs/inherits.mjs +39 -0
- package/.output/server/_libs/isaacs__fs-minipass+minipass.mjs +1120 -0
- package/.output/server/_libs/isarray.mjs +10 -0
- package/.output/server/_libs/jszip+[...].mjs +8311 -0
- package/.output/server/_libs/lucide-react.mjs +371 -0
- package/.output/server/_libs/minizlib.mjs +345 -0
- package/.output/server/_libs/next-themes.mjs +49 -0
- package/.output/server/_libs/radix-ui__number.mjs +6 -0
- package/.output/server/_libs/radix-ui__primitive.mjs +9 -0
- package/.output/server/_libs/radix-ui__react-arrow.mjs +23 -0
- package/.output/server/_libs/radix-ui__react-collection.mjs +78 -0
- package/.output/server/_libs/radix-ui__react-direction.mjs +11 -0
- package/.output/server/_libs/radix-ui__react-label.mjs +22 -0
- package/.output/server/_libs/radix-ui__react-separator.mjs +31 -0
- package/.output/server/_libs/radix-ui__react-slider.mjs +451 -0
- package/.output/server/_libs/radix-ui__react-switch.mjs +118 -0
- package/.output/server/_libs/radix-ui__react-tooltip.mjs +491 -0
- package/.output/server/_libs/semver.mjs +1339 -0
- package/.output/server/_libs/sonner.mjs +908 -0
- package/.output/server/_libs/tailwind-merge.mjs +1962 -0
- package/.output/server/_libs/tanstack__history.mjs +322 -0
- package/.output/server/_libs/tanstack__query-core.mjs +2073 -0
- package/.output/server/_libs/tanstack__react-query.mjs +146 -0
- package/.output/server/_libs/tanstack__router-core.mjs +6 -0
- package/.output/server/_libs/tar.mjs +1996 -0
- package/.output/server/_libs/ufo.mjs +64 -0
- package/.output/server/_runtime.mjs +26 -0
- package/.output/server/_ssr/api-rpc-D3ZehMIN.mjs +217 -0
- package/.output/server/_ssr/config.server-JUYQ7UbI.mjs +26 -0
- package/.output/server/_ssr/deleteBundle-DWUxu9-K.mjs +22 -0
- package/.output/server/_ssr/extract-timestamp-from-uuidv7-B90UBADU.mjs +24 -0
- package/.output/server/_ssr/promoteBundle-DtMHuubR.mjs +1571 -0
- package/.output/server/_ssr/router-pgc7NX76.mjs +250 -0
- package/.output/server/_ssr/routes-PqTTQSoI.mjs +1833 -0
- package/.output/server/_ssr/sidebar-DXng0IOP.mjs +439 -0
- package/.output/server/_ssr/ssr.mjs +5050 -0
- package/.output/server/_ssr/start-DQK0r85G.mjs +4 -0
- package/.output/server/_tanstack-start-manifest_v-DTbQVOpU.mjs +17 -0
- package/.output/server/index.mjs +417 -0
- package/.output/server/node_modules/tslib/modules/index.js +70 -0
- package/.output/server/node_modules/tslib/modules/package.json +3 -0
- package/.output/server/node_modules/tslib/package.json +47 -0
- package/.output/server/node_modules/tslib/tslib.js +484 -0
- package/.output/server/package.json +9 -0
- package/README.md +191 -2
- package/package.json +77 -50
- package/dist/.gitkeep +0 -0
- package/dist/assets/favicon-BkwcEHsj.ico +0 -0
- package/dist/assets/index-DUlKsori.css +0 -1
- package/dist/assets/index-ijmIcyn1.js +0 -27
- package/dist/assets/logo-BYNFyja1.png +0 -0
- package/dist/index.cjs +0 -2129
- package/dist/index.d.cts +0 -218
- package/dist/index.d.ts +0 -218
- package/dist/index.html +0 -14
- package/dist/index.js +0 -2125
|
@@ -0,0 +1,1120 @@
|
|
|
1
|
+
import Stream from "node:stream";
|
|
2
|
+
import EE from "events";
|
|
3
|
+
import { StringDecoder } from "node:string_decoder";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { EventEmitter as EventEmitter$1 } from "node:events";
|
|
6
|
+
//#region ../../node_modules/.pnpm/minipass@7.1.3/node_modules/minipass/dist/esm/index.js
|
|
7
|
+
var proc = typeof process === "object" && process ? process : {
|
|
8
|
+
stdout: null,
|
|
9
|
+
stderr: null
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Return true if the argument is a Minipass stream, Node stream, or something
|
|
13
|
+
* else that Minipass can interact with.
|
|
14
|
+
*/
|
|
15
|
+
var isStream = (s) => !!s && typeof s === "object" && (s instanceof Minipass || s instanceof Stream || isReadable(s) || isWritable(s));
|
|
16
|
+
/**
|
|
17
|
+
* Return true if the argument is a valid {@link Minipass.Readable}
|
|
18
|
+
*/
|
|
19
|
+
var isReadable = (s) => !!s && typeof s === "object" && s instanceof EventEmitter$1 && typeof s.pipe === "function" && s.pipe !== Stream.Writable.prototype.pipe;
|
|
20
|
+
/**
|
|
21
|
+
* Return true if the argument is a valid {@link Minipass.Writable}
|
|
22
|
+
*/
|
|
23
|
+
var isWritable = (s) => !!s && typeof s === "object" && s instanceof EventEmitter$1 && typeof s.write === "function" && typeof s.end === "function";
|
|
24
|
+
var EOF = Symbol("EOF");
|
|
25
|
+
var MAYBE_EMIT_END = Symbol("maybeEmitEnd");
|
|
26
|
+
var EMITTED_END = Symbol("emittedEnd");
|
|
27
|
+
var EMITTING_END = Symbol("emittingEnd");
|
|
28
|
+
var EMITTED_ERROR = Symbol("emittedError");
|
|
29
|
+
var CLOSED = Symbol("closed");
|
|
30
|
+
var READ = Symbol("read");
|
|
31
|
+
var FLUSH = Symbol("flush");
|
|
32
|
+
var FLUSHCHUNK = Symbol("flushChunk");
|
|
33
|
+
var ENCODING = Symbol("encoding");
|
|
34
|
+
var DECODER = Symbol("decoder");
|
|
35
|
+
var FLOWING = Symbol("flowing");
|
|
36
|
+
var PAUSED = Symbol("paused");
|
|
37
|
+
var RESUME = Symbol("resume");
|
|
38
|
+
var BUFFER = Symbol("buffer");
|
|
39
|
+
var PIPES = Symbol("pipes");
|
|
40
|
+
var BUFFERLENGTH = Symbol("bufferLength");
|
|
41
|
+
var BUFFERPUSH = Symbol("bufferPush");
|
|
42
|
+
var BUFFERSHIFT = Symbol("bufferShift");
|
|
43
|
+
var OBJECTMODE = Symbol("objectMode");
|
|
44
|
+
var DESTROYED = Symbol("destroyed");
|
|
45
|
+
var ERROR = Symbol("error");
|
|
46
|
+
var EMITDATA = Symbol("emitData");
|
|
47
|
+
var EMITEND = Symbol("emitEnd");
|
|
48
|
+
var EMITEND2 = Symbol("emitEnd2");
|
|
49
|
+
var ASYNC = Symbol("async");
|
|
50
|
+
var ABORT = Symbol("abort");
|
|
51
|
+
var ABORTED = Symbol("aborted");
|
|
52
|
+
var SIGNAL = Symbol("signal");
|
|
53
|
+
var DATALISTENERS = Symbol("dataListeners");
|
|
54
|
+
var DISCARDED = Symbol("discarded");
|
|
55
|
+
var defer = (fn) => Promise.resolve().then(fn);
|
|
56
|
+
var nodefer = (fn) => fn();
|
|
57
|
+
var isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish";
|
|
58
|
+
var isArrayBufferLike = (b) => b instanceof ArrayBuffer || !!b && typeof b === "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0;
|
|
59
|
+
var isArrayBufferView = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b);
|
|
60
|
+
/**
|
|
61
|
+
* Internal class representing a pipe to a destination stream.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
var Pipe = class {
|
|
66
|
+
src;
|
|
67
|
+
dest;
|
|
68
|
+
opts;
|
|
69
|
+
ondrain;
|
|
70
|
+
constructor(src, dest, opts) {
|
|
71
|
+
this.src = src;
|
|
72
|
+
this.dest = dest;
|
|
73
|
+
this.opts = opts;
|
|
74
|
+
this.ondrain = () => src[RESUME]();
|
|
75
|
+
this.dest.on("drain", this.ondrain);
|
|
76
|
+
}
|
|
77
|
+
unpipe() {
|
|
78
|
+
this.dest.removeListener("drain", this.ondrain);
|
|
79
|
+
}
|
|
80
|
+
/* c8 ignore start */
|
|
81
|
+
proxyErrors(_er) {}
|
|
82
|
+
/* c8 ignore stop */
|
|
83
|
+
end() {
|
|
84
|
+
this.unpipe();
|
|
85
|
+
if (this.opts.end) this.dest.end();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Internal class representing a pipe to a destination stream where
|
|
90
|
+
* errors are proxied.
|
|
91
|
+
*
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
var PipeProxyErrors = class extends Pipe {
|
|
95
|
+
unpipe() {
|
|
96
|
+
this.src.removeListener("error", this.proxyErrors);
|
|
97
|
+
super.unpipe();
|
|
98
|
+
}
|
|
99
|
+
constructor(src, dest, opts) {
|
|
100
|
+
super(src, dest, opts);
|
|
101
|
+
this.proxyErrors = (er) => this.dest.emit("error", er);
|
|
102
|
+
src.on("error", this.proxyErrors);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var isObjectModeOptions = (o) => !!o.objectMode;
|
|
106
|
+
var isEncodingOptions = (o) => !o.objectMode && !!o.encoding && o.encoding !== "buffer";
|
|
107
|
+
/**
|
|
108
|
+
* Main export, the Minipass class
|
|
109
|
+
*
|
|
110
|
+
* `RType` is the type of data emitted, defaults to Buffer
|
|
111
|
+
*
|
|
112
|
+
* `WType` is the type of data to be written, if RType is buffer or string,
|
|
113
|
+
* then any {@link Minipass.ContiguousData} is allowed.
|
|
114
|
+
*
|
|
115
|
+
* `Events` is the set of event handler signatures that this object
|
|
116
|
+
* will emit, see {@link Minipass.Events}
|
|
117
|
+
*/
|
|
118
|
+
var Minipass = class extends EventEmitter$1 {
|
|
119
|
+
[FLOWING] = false;
|
|
120
|
+
[PAUSED] = false;
|
|
121
|
+
[PIPES] = [];
|
|
122
|
+
[BUFFER] = [];
|
|
123
|
+
[OBJECTMODE];
|
|
124
|
+
[ENCODING];
|
|
125
|
+
[ASYNC];
|
|
126
|
+
[DECODER];
|
|
127
|
+
[EOF] = false;
|
|
128
|
+
[EMITTED_END] = false;
|
|
129
|
+
[EMITTING_END] = false;
|
|
130
|
+
[CLOSED] = false;
|
|
131
|
+
[EMITTED_ERROR] = null;
|
|
132
|
+
[BUFFERLENGTH] = 0;
|
|
133
|
+
[DESTROYED] = false;
|
|
134
|
+
[SIGNAL];
|
|
135
|
+
[ABORTED] = false;
|
|
136
|
+
[DATALISTENERS] = 0;
|
|
137
|
+
[DISCARDED] = false;
|
|
138
|
+
/**
|
|
139
|
+
* true if the stream can be written
|
|
140
|
+
*/
|
|
141
|
+
writable = true;
|
|
142
|
+
/**
|
|
143
|
+
* true if the stream can be read
|
|
144
|
+
*/
|
|
145
|
+
readable = true;
|
|
146
|
+
/**
|
|
147
|
+
* If `RType` is Buffer, then options do not need to be provided.
|
|
148
|
+
* Otherwise, an options object must be provided to specify either
|
|
149
|
+
* {@link Minipass.SharedOptions.objectMode} or
|
|
150
|
+
* {@link Minipass.SharedOptions.encoding}, as appropriate.
|
|
151
|
+
*/
|
|
152
|
+
constructor(...args) {
|
|
153
|
+
const options = args[0] || {};
|
|
154
|
+
super();
|
|
155
|
+
if (options.objectMode && typeof options.encoding === "string") throw new TypeError("Encoding and objectMode may not be used together");
|
|
156
|
+
if (isObjectModeOptions(options)) {
|
|
157
|
+
this[OBJECTMODE] = true;
|
|
158
|
+
this[ENCODING] = null;
|
|
159
|
+
} else if (isEncodingOptions(options)) {
|
|
160
|
+
this[ENCODING] = options.encoding;
|
|
161
|
+
this[OBJECTMODE] = false;
|
|
162
|
+
} else {
|
|
163
|
+
this[OBJECTMODE] = false;
|
|
164
|
+
this[ENCODING] = null;
|
|
165
|
+
}
|
|
166
|
+
this[ASYNC] = !!options.async;
|
|
167
|
+
this[DECODER] = this[ENCODING] ? new StringDecoder(this[ENCODING]) : null;
|
|
168
|
+
if (options && options.debugExposeBuffer === true) Object.defineProperty(this, "buffer", { get: () => this[BUFFER] });
|
|
169
|
+
if (options && options.debugExposePipes === true) Object.defineProperty(this, "pipes", { get: () => this[PIPES] });
|
|
170
|
+
const { signal } = options;
|
|
171
|
+
if (signal) {
|
|
172
|
+
this[SIGNAL] = signal;
|
|
173
|
+
if (signal.aborted) this[ABORT]();
|
|
174
|
+
else signal.addEventListener("abort", () => this[ABORT]());
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The amount of data stored in the buffer waiting to be read.
|
|
179
|
+
*
|
|
180
|
+
* For Buffer strings, this will be the total byte length.
|
|
181
|
+
* For string encoding streams, this will be the string character length,
|
|
182
|
+
* according to JavaScript's `string.length` logic.
|
|
183
|
+
* For objectMode streams, this is a count of the items waiting to be
|
|
184
|
+
* emitted.
|
|
185
|
+
*/
|
|
186
|
+
get bufferLength() {
|
|
187
|
+
return this[BUFFERLENGTH];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The `BufferEncoding` currently in use, or `null`
|
|
191
|
+
*/
|
|
192
|
+
get encoding() {
|
|
193
|
+
return this[ENCODING];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @deprecated - This is a read only property
|
|
197
|
+
*/
|
|
198
|
+
set encoding(_enc) {
|
|
199
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* @deprecated - Encoding may only be set at instantiation time
|
|
203
|
+
*/
|
|
204
|
+
setEncoding(_enc) {
|
|
205
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* True if this is an objectMode stream
|
|
209
|
+
*/
|
|
210
|
+
get objectMode() {
|
|
211
|
+
return this[OBJECTMODE];
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* @deprecated - This is a read-only property
|
|
215
|
+
*/
|
|
216
|
+
set objectMode(_om) {
|
|
217
|
+
throw new Error("objectMode must be set at instantiation time");
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* true if this is an async stream
|
|
221
|
+
*/
|
|
222
|
+
get ["async"]() {
|
|
223
|
+
return this[ASYNC];
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Set to true to make this stream async.
|
|
227
|
+
*
|
|
228
|
+
* Once set, it cannot be unset, as this would potentially cause incorrect
|
|
229
|
+
* behavior. Ie, a sync stream can be made async, but an async stream
|
|
230
|
+
* cannot be safely made sync.
|
|
231
|
+
*/
|
|
232
|
+
set ["async"](a) {
|
|
233
|
+
this[ASYNC] = this[ASYNC] || !!a;
|
|
234
|
+
}
|
|
235
|
+
[ABORT]() {
|
|
236
|
+
this[ABORTED] = true;
|
|
237
|
+
this.emit("abort", this[SIGNAL]?.reason);
|
|
238
|
+
this.destroy(this[SIGNAL]?.reason);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* True if the stream has been aborted.
|
|
242
|
+
*/
|
|
243
|
+
get aborted() {
|
|
244
|
+
return this[ABORTED];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* No-op setter. Stream aborted status is set via the AbortSignal provided
|
|
248
|
+
* in the constructor options.
|
|
249
|
+
*/
|
|
250
|
+
set aborted(_) {}
|
|
251
|
+
write(chunk, encoding, cb) {
|
|
252
|
+
if (this[ABORTED]) return false;
|
|
253
|
+
if (this[EOF]) throw new Error("write after end");
|
|
254
|
+
if (this[DESTROYED]) {
|
|
255
|
+
this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" }));
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
if (typeof encoding === "function") {
|
|
259
|
+
cb = encoding;
|
|
260
|
+
encoding = "utf8";
|
|
261
|
+
}
|
|
262
|
+
if (!encoding) encoding = "utf8";
|
|
263
|
+
const fn = this[ASYNC] ? defer : nodefer;
|
|
264
|
+
if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) {
|
|
265
|
+
if (isArrayBufferView(chunk)) chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
266
|
+
else if (isArrayBufferLike(chunk)) chunk = Buffer.from(chunk);
|
|
267
|
+
else if (typeof chunk !== "string") throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
268
|
+
}
|
|
269
|
+
if (this[OBJECTMODE]) {
|
|
270
|
+
/* c8 ignore start */
|
|
271
|
+
if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true);
|
|
272
|
+
/* c8 ignore stop */
|
|
273
|
+
if (this[FLOWING]) this.emit("data", chunk);
|
|
274
|
+
else this[BUFFERPUSH](chunk);
|
|
275
|
+
if (this[BUFFERLENGTH] !== 0) this.emit("readable");
|
|
276
|
+
if (cb) fn(cb);
|
|
277
|
+
return this[FLOWING];
|
|
278
|
+
}
|
|
279
|
+
if (!chunk.length) {
|
|
280
|
+
if (this[BUFFERLENGTH] !== 0) this.emit("readable");
|
|
281
|
+
if (cb) fn(cb);
|
|
282
|
+
return this[FLOWING];
|
|
283
|
+
}
|
|
284
|
+
if (typeof chunk === "string" && !(encoding === this[ENCODING] && !this[DECODER]?.lastNeed)) chunk = Buffer.from(chunk, encoding);
|
|
285
|
+
if (Buffer.isBuffer(chunk) && this[ENCODING]) chunk = this[DECODER].write(chunk);
|
|
286
|
+
if (this[FLOWING] && this[BUFFERLENGTH] !== 0) this[FLUSH](true);
|
|
287
|
+
if (this[FLOWING]) this.emit("data", chunk);
|
|
288
|
+
else this[BUFFERPUSH](chunk);
|
|
289
|
+
if (this[BUFFERLENGTH] !== 0) this.emit("readable");
|
|
290
|
+
if (cb) fn(cb);
|
|
291
|
+
return this[FLOWING];
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Low-level explicit read method.
|
|
295
|
+
*
|
|
296
|
+
* In objectMode, the argument is ignored, and one item is returned if
|
|
297
|
+
* available.
|
|
298
|
+
*
|
|
299
|
+
* `n` is the number of bytes (or in the case of encoding streams,
|
|
300
|
+
* characters) to consume. If `n` is not provided, then the entire buffer
|
|
301
|
+
* is returned, or `null` is returned if no data is available.
|
|
302
|
+
*
|
|
303
|
+
* If `n` is greater that the amount of data in the internal buffer,
|
|
304
|
+
* then `null` is returned.
|
|
305
|
+
*/
|
|
306
|
+
read(n) {
|
|
307
|
+
if (this[DESTROYED]) return null;
|
|
308
|
+
this[DISCARDED] = false;
|
|
309
|
+
if (this[BUFFERLENGTH] === 0 || n === 0 || n && n > this[BUFFERLENGTH]) {
|
|
310
|
+
this[MAYBE_EMIT_END]();
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
if (this[OBJECTMODE]) n = null;
|
|
314
|
+
if (this[BUFFER].length > 1 && !this[OBJECTMODE]) this[BUFFER] = [this[ENCODING] ? this[BUFFER].join("") : Buffer.concat(this[BUFFER], this[BUFFERLENGTH])];
|
|
315
|
+
const ret = this[READ](n || null, this[BUFFER][0]);
|
|
316
|
+
this[MAYBE_EMIT_END]();
|
|
317
|
+
return ret;
|
|
318
|
+
}
|
|
319
|
+
[READ](n, chunk) {
|
|
320
|
+
if (this[OBJECTMODE]) this[BUFFERSHIFT]();
|
|
321
|
+
else {
|
|
322
|
+
const c = chunk;
|
|
323
|
+
if (n === c.length || n === null) this[BUFFERSHIFT]();
|
|
324
|
+
else if (typeof c === "string") {
|
|
325
|
+
this[BUFFER][0] = c.slice(n);
|
|
326
|
+
chunk = c.slice(0, n);
|
|
327
|
+
this[BUFFERLENGTH] -= n;
|
|
328
|
+
} else {
|
|
329
|
+
this[BUFFER][0] = c.subarray(n);
|
|
330
|
+
chunk = c.subarray(0, n);
|
|
331
|
+
this[BUFFERLENGTH] -= n;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
this.emit("data", chunk);
|
|
335
|
+
if (!this[BUFFER].length && !this[EOF]) this.emit("drain");
|
|
336
|
+
return chunk;
|
|
337
|
+
}
|
|
338
|
+
end(chunk, encoding, cb) {
|
|
339
|
+
if (typeof chunk === "function") {
|
|
340
|
+
cb = chunk;
|
|
341
|
+
chunk = void 0;
|
|
342
|
+
}
|
|
343
|
+
if (typeof encoding === "function") {
|
|
344
|
+
cb = encoding;
|
|
345
|
+
encoding = "utf8";
|
|
346
|
+
}
|
|
347
|
+
if (chunk !== void 0) this.write(chunk, encoding);
|
|
348
|
+
if (cb) this.once("end", cb);
|
|
349
|
+
this[EOF] = true;
|
|
350
|
+
this.writable = false;
|
|
351
|
+
if (this[FLOWING] || !this[PAUSED]) this[MAYBE_EMIT_END]();
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
[RESUME]() {
|
|
355
|
+
if (this[DESTROYED]) return;
|
|
356
|
+
if (!this[DATALISTENERS] && !this[PIPES].length) this[DISCARDED] = true;
|
|
357
|
+
this[PAUSED] = false;
|
|
358
|
+
this[FLOWING] = true;
|
|
359
|
+
this.emit("resume");
|
|
360
|
+
if (this[BUFFER].length) this[FLUSH]();
|
|
361
|
+
else if (this[EOF]) this[MAYBE_EMIT_END]();
|
|
362
|
+
else this.emit("drain");
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Resume the stream if it is currently in a paused state
|
|
366
|
+
*
|
|
367
|
+
* If called when there are no pipe destinations or `data` event listeners,
|
|
368
|
+
* this will place the stream in a "discarded" state, where all data will
|
|
369
|
+
* be thrown away. The discarded state is removed if a pipe destination or
|
|
370
|
+
* data handler is added, if pause() is called, or if any synchronous or
|
|
371
|
+
* asynchronous iteration is started.
|
|
372
|
+
*/
|
|
373
|
+
resume() {
|
|
374
|
+
return this[RESUME]();
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Pause the stream
|
|
378
|
+
*/
|
|
379
|
+
pause() {
|
|
380
|
+
this[FLOWING] = false;
|
|
381
|
+
this[PAUSED] = true;
|
|
382
|
+
this[DISCARDED] = false;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* true if the stream has been forcibly destroyed
|
|
386
|
+
*/
|
|
387
|
+
get destroyed() {
|
|
388
|
+
return this[DESTROYED];
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* true if the stream is currently in a flowing state, meaning that
|
|
392
|
+
* any writes will be immediately emitted.
|
|
393
|
+
*/
|
|
394
|
+
get flowing() {
|
|
395
|
+
return this[FLOWING];
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* true if the stream is currently in a paused state
|
|
399
|
+
*/
|
|
400
|
+
get paused() {
|
|
401
|
+
return this[PAUSED];
|
|
402
|
+
}
|
|
403
|
+
[BUFFERPUSH](chunk) {
|
|
404
|
+
if (this[OBJECTMODE]) this[BUFFERLENGTH] += 1;
|
|
405
|
+
else this[BUFFERLENGTH] += chunk.length;
|
|
406
|
+
this[BUFFER].push(chunk);
|
|
407
|
+
}
|
|
408
|
+
[BUFFERSHIFT]() {
|
|
409
|
+
if (this[OBJECTMODE]) this[BUFFERLENGTH] -= 1;
|
|
410
|
+
else this[BUFFERLENGTH] -= this[BUFFER][0].length;
|
|
411
|
+
return this[BUFFER].shift();
|
|
412
|
+
}
|
|
413
|
+
[FLUSH](noDrain = false) {
|
|
414
|
+
do ;
|
|
415
|
+
while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
|
|
416
|
+
if (!noDrain && !this[BUFFER].length && !this[EOF]) this.emit("drain");
|
|
417
|
+
}
|
|
418
|
+
[FLUSHCHUNK](chunk) {
|
|
419
|
+
this.emit("data", chunk);
|
|
420
|
+
return this[FLOWING];
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Pipe all data emitted by this stream into the destination provided.
|
|
424
|
+
*
|
|
425
|
+
* Triggers the flow of data.
|
|
426
|
+
*/
|
|
427
|
+
pipe(dest, opts) {
|
|
428
|
+
if (this[DESTROYED]) return dest;
|
|
429
|
+
this[DISCARDED] = false;
|
|
430
|
+
const ended = this[EMITTED_END];
|
|
431
|
+
opts = opts || {};
|
|
432
|
+
if (dest === proc.stdout || dest === proc.stderr) opts.end = false;
|
|
433
|
+
else opts.end = opts.end !== false;
|
|
434
|
+
opts.proxyErrors = !!opts.proxyErrors;
|
|
435
|
+
if (ended) {
|
|
436
|
+
if (opts.end) dest.end();
|
|
437
|
+
} else {
|
|
438
|
+
this[PIPES].push(!opts.proxyErrors ? new Pipe(this, dest, opts) : new PipeProxyErrors(this, dest, opts));
|
|
439
|
+
if (this[ASYNC]) defer(() => this[RESUME]());
|
|
440
|
+
else this[RESUME]();
|
|
441
|
+
}
|
|
442
|
+
return dest;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Fully unhook a piped destination stream.
|
|
446
|
+
*
|
|
447
|
+
* If the destination stream was the only consumer of this stream (ie,
|
|
448
|
+
* there are no other piped destinations or `'data'` event listeners)
|
|
449
|
+
* then the flow of data will stop until there is another consumer or
|
|
450
|
+
* {@link Minipass#resume} is explicitly called.
|
|
451
|
+
*/
|
|
452
|
+
unpipe(dest) {
|
|
453
|
+
const p = this[PIPES].find((p) => p.dest === dest);
|
|
454
|
+
if (p) {
|
|
455
|
+
if (this[PIPES].length === 1) {
|
|
456
|
+
if (this[FLOWING] && this[DATALISTENERS] === 0) this[FLOWING] = false;
|
|
457
|
+
this[PIPES] = [];
|
|
458
|
+
} else this[PIPES].splice(this[PIPES].indexOf(p), 1);
|
|
459
|
+
p.unpipe();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Alias for {@link Minipass#on}
|
|
464
|
+
*/
|
|
465
|
+
addListener(ev, handler) {
|
|
466
|
+
return this.on(ev, handler);
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Mostly identical to `EventEmitter.on`, with the following
|
|
470
|
+
* behavior differences to prevent data loss and unnecessary hangs:
|
|
471
|
+
*
|
|
472
|
+
* - Adding a 'data' event handler will trigger the flow of data
|
|
473
|
+
*
|
|
474
|
+
* - Adding a 'readable' event handler when there is data waiting to be read
|
|
475
|
+
* will cause 'readable' to be emitted immediately.
|
|
476
|
+
*
|
|
477
|
+
* - Adding an 'endish' event handler ('end', 'finish', etc.) which has
|
|
478
|
+
* already passed will cause the event to be emitted immediately and all
|
|
479
|
+
* handlers removed.
|
|
480
|
+
*
|
|
481
|
+
* - Adding an 'error' event handler after an error has been emitted will
|
|
482
|
+
* cause the event to be re-emitted immediately with the error previously
|
|
483
|
+
* raised.
|
|
484
|
+
*/
|
|
485
|
+
on(ev, handler) {
|
|
486
|
+
const ret = super.on(ev, handler);
|
|
487
|
+
if (ev === "data") {
|
|
488
|
+
this[DISCARDED] = false;
|
|
489
|
+
this[DATALISTENERS]++;
|
|
490
|
+
if (!this[PIPES].length && !this[FLOWING]) this[RESUME]();
|
|
491
|
+
} else if (ev === "readable" && this[BUFFERLENGTH] !== 0) super.emit("readable");
|
|
492
|
+
else if (isEndish(ev) && this[EMITTED_END]) {
|
|
493
|
+
super.emit(ev);
|
|
494
|
+
this.removeAllListeners(ev);
|
|
495
|
+
} else if (ev === "error" && this[EMITTED_ERROR]) {
|
|
496
|
+
const h = handler;
|
|
497
|
+
if (this[ASYNC]) defer(() => h.call(this, this[EMITTED_ERROR]));
|
|
498
|
+
else h.call(this, this[EMITTED_ERROR]);
|
|
499
|
+
}
|
|
500
|
+
return ret;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Alias for {@link Minipass#off}
|
|
504
|
+
*/
|
|
505
|
+
removeListener(ev, handler) {
|
|
506
|
+
return this.off(ev, handler);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Mostly identical to `EventEmitter.off`
|
|
510
|
+
*
|
|
511
|
+
* If a 'data' event handler is removed, and it was the last consumer
|
|
512
|
+
* (ie, there are no pipe destinations or other 'data' event listeners),
|
|
513
|
+
* then the flow of data will stop until there is another consumer or
|
|
514
|
+
* {@link Minipass#resume} is explicitly called.
|
|
515
|
+
*/
|
|
516
|
+
off(ev, handler) {
|
|
517
|
+
const ret = super.off(ev, handler);
|
|
518
|
+
if (ev === "data") {
|
|
519
|
+
this[DATALISTENERS] = this.listeners("data").length;
|
|
520
|
+
if (this[DATALISTENERS] === 0 && !this[DISCARDED] && !this[PIPES].length) this[FLOWING] = false;
|
|
521
|
+
}
|
|
522
|
+
return ret;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Mostly identical to `EventEmitter.removeAllListeners`
|
|
526
|
+
*
|
|
527
|
+
* If all 'data' event handlers are removed, and they were the last consumer
|
|
528
|
+
* (ie, there are no pipe destinations), then the flow of data will stop
|
|
529
|
+
* until there is another consumer or {@link Minipass#resume} is explicitly
|
|
530
|
+
* called.
|
|
531
|
+
*/
|
|
532
|
+
removeAllListeners(ev) {
|
|
533
|
+
const ret = super.removeAllListeners(ev);
|
|
534
|
+
if (ev === "data" || ev === void 0) {
|
|
535
|
+
this[DATALISTENERS] = 0;
|
|
536
|
+
if (!this[DISCARDED] && !this[PIPES].length) this[FLOWING] = false;
|
|
537
|
+
}
|
|
538
|
+
return ret;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* true if the 'end' event has been emitted
|
|
542
|
+
*/
|
|
543
|
+
get emittedEnd() {
|
|
544
|
+
return this[EMITTED_END];
|
|
545
|
+
}
|
|
546
|
+
[MAYBE_EMIT_END]() {
|
|
547
|
+
if (!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this[BUFFER].length === 0 && this[EOF]) {
|
|
548
|
+
this[EMITTING_END] = true;
|
|
549
|
+
this.emit("end");
|
|
550
|
+
this.emit("prefinish");
|
|
551
|
+
this.emit("finish");
|
|
552
|
+
if (this[CLOSED]) this.emit("close");
|
|
553
|
+
this[EMITTING_END] = false;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Mostly identical to `EventEmitter.emit`, with the following
|
|
558
|
+
* behavior differences to prevent data loss and unnecessary hangs:
|
|
559
|
+
*
|
|
560
|
+
* If the stream has been destroyed, and the event is something other
|
|
561
|
+
* than 'close' or 'error', then `false` is returned and no handlers
|
|
562
|
+
* are called.
|
|
563
|
+
*
|
|
564
|
+
* If the event is 'end', and has already been emitted, then the event
|
|
565
|
+
* is ignored. If the stream is in a paused or non-flowing state, then
|
|
566
|
+
* the event will be deferred until data flow resumes. If the stream is
|
|
567
|
+
* async, then handlers will be called on the next tick rather than
|
|
568
|
+
* immediately.
|
|
569
|
+
*
|
|
570
|
+
* If the event is 'close', and 'end' has not yet been emitted, then
|
|
571
|
+
* the event will be deferred until after 'end' is emitted.
|
|
572
|
+
*
|
|
573
|
+
* If the event is 'error', and an AbortSignal was provided for the stream,
|
|
574
|
+
* and there are no listeners, then the event is ignored, matching the
|
|
575
|
+
* behavior of node core streams in the presense of an AbortSignal.
|
|
576
|
+
*
|
|
577
|
+
* If the event is 'finish' or 'prefinish', then all listeners will be
|
|
578
|
+
* removed after emitting the event, to prevent double-firing.
|
|
579
|
+
*/
|
|
580
|
+
emit(ev, ...args) {
|
|
581
|
+
const data = args[0];
|
|
582
|
+
if (ev !== "error" && ev !== "close" && ev !== DESTROYED && this[DESTROYED]) return false;
|
|
583
|
+
else if (ev === "data") return !this[OBJECTMODE] && !data ? false : this[ASYNC] ? (defer(() => this[EMITDATA](data)), true) : this[EMITDATA](data);
|
|
584
|
+
else if (ev === "end") return this[EMITEND]();
|
|
585
|
+
else if (ev === "close") {
|
|
586
|
+
this[CLOSED] = true;
|
|
587
|
+
if (!this[EMITTED_END] && !this[DESTROYED]) return false;
|
|
588
|
+
const ret = super.emit("close");
|
|
589
|
+
this.removeAllListeners("close");
|
|
590
|
+
return ret;
|
|
591
|
+
} else if (ev === "error") {
|
|
592
|
+
this[EMITTED_ERROR] = data;
|
|
593
|
+
super.emit(ERROR, data);
|
|
594
|
+
const ret = !this[SIGNAL] || this.listeners("error").length ? super.emit("error", data) : false;
|
|
595
|
+
this[MAYBE_EMIT_END]();
|
|
596
|
+
return ret;
|
|
597
|
+
} else if (ev === "resume") {
|
|
598
|
+
const ret = super.emit("resume");
|
|
599
|
+
this[MAYBE_EMIT_END]();
|
|
600
|
+
return ret;
|
|
601
|
+
} else if (ev === "finish" || ev === "prefinish") {
|
|
602
|
+
const ret = super.emit(ev);
|
|
603
|
+
this.removeAllListeners(ev);
|
|
604
|
+
return ret;
|
|
605
|
+
}
|
|
606
|
+
const ret = super.emit(ev, ...args);
|
|
607
|
+
this[MAYBE_EMIT_END]();
|
|
608
|
+
return ret;
|
|
609
|
+
}
|
|
610
|
+
[EMITDATA](data) {
|
|
611
|
+
for (const p of this[PIPES]) if (p.dest.write(data) === false) this.pause();
|
|
612
|
+
const ret = this[DISCARDED] ? false : super.emit("data", data);
|
|
613
|
+
this[MAYBE_EMIT_END]();
|
|
614
|
+
return ret;
|
|
615
|
+
}
|
|
616
|
+
[EMITEND]() {
|
|
617
|
+
if (this[EMITTED_END]) return false;
|
|
618
|
+
this[EMITTED_END] = true;
|
|
619
|
+
this.readable = false;
|
|
620
|
+
return this[ASYNC] ? (defer(() => this[EMITEND2]()), true) : this[EMITEND2]();
|
|
621
|
+
}
|
|
622
|
+
[EMITEND2]() {
|
|
623
|
+
if (this[DECODER]) {
|
|
624
|
+
const data = this[DECODER].end();
|
|
625
|
+
if (data) {
|
|
626
|
+
for (const p of this[PIPES]) p.dest.write(data);
|
|
627
|
+
if (!this[DISCARDED]) super.emit("data", data);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
for (const p of this[PIPES]) p.end();
|
|
631
|
+
const ret = super.emit("end");
|
|
632
|
+
this.removeAllListeners("end");
|
|
633
|
+
return ret;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Return a Promise that resolves to an array of all emitted data once
|
|
637
|
+
* the stream ends.
|
|
638
|
+
*/
|
|
639
|
+
async collect() {
|
|
640
|
+
const buf = Object.assign([], { dataLength: 0 });
|
|
641
|
+
if (!this[OBJECTMODE]) buf.dataLength = 0;
|
|
642
|
+
const p = this.promise();
|
|
643
|
+
this.on("data", (c) => {
|
|
644
|
+
buf.push(c);
|
|
645
|
+
if (!this[OBJECTMODE]) buf.dataLength += c.length;
|
|
646
|
+
});
|
|
647
|
+
await p;
|
|
648
|
+
return buf;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Return a Promise that resolves to the concatenation of all emitted data
|
|
652
|
+
* once the stream ends.
|
|
653
|
+
*
|
|
654
|
+
* Not allowed on objectMode streams.
|
|
655
|
+
*/
|
|
656
|
+
async concat() {
|
|
657
|
+
if (this[OBJECTMODE]) throw new Error("cannot concat in objectMode");
|
|
658
|
+
const buf = await this.collect();
|
|
659
|
+
return this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength);
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Return a void Promise that resolves once the stream ends.
|
|
663
|
+
*/
|
|
664
|
+
async promise() {
|
|
665
|
+
return new Promise((resolve, reject) => {
|
|
666
|
+
this.on(DESTROYED, () => reject(/* @__PURE__ */ new Error("stream destroyed")));
|
|
667
|
+
this.on("error", (er) => reject(er));
|
|
668
|
+
this.on("end", () => resolve());
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Asynchronous `for await of` iteration.
|
|
673
|
+
*
|
|
674
|
+
* This will continue emitting all chunks until the stream terminates.
|
|
675
|
+
*/
|
|
676
|
+
[Symbol.asyncIterator]() {
|
|
677
|
+
this[DISCARDED] = false;
|
|
678
|
+
let stopped = false;
|
|
679
|
+
const stop = async () => {
|
|
680
|
+
this.pause();
|
|
681
|
+
stopped = true;
|
|
682
|
+
return {
|
|
683
|
+
value: void 0,
|
|
684
|
+
done: true
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
const next = () => {
|
|
688
|
+
if (stopped) return stop();
|
|
689
|
+
const res = this.read();
|
|
690
|
+
if (res !== null) return Promise.resolve({
|
|
691
|
+
done: false,
|
|
692
|
+
value: res
|
|
693
|
+
});
|
|
694
|
+
if (this[EOF]) return stop();
|
|
695
|
+
let resolve;
|
|
696
|
+
let reject;
|
|
697
|
+
const onerr = (er) => {
|
|
698
|
+
this.off("data", ondata);
|
|
699
|
+
this.off("end", onend);
|
|
700
|
+
this.off(DESTROYED, ondestroy);
|
|
701
|
+
stop();
|
|
702
|
+
reject(er);
|
|
703
|
+
};
|
|
704
|
+
const ondata = (value) => {
|
|
705
|
+
this.off("error", onerr);
|
|
706
|
+
this.off("end", onend);
|
|
707
|
+
this.off(DESTROYED, ondestroy);
|
|
708
|
+
this.pause();
|
|
709
|
+
resolve({
|
|
710
|
+
value,
|
|
711
|
+
done: !!this[EOF]
|
|
712
|
+
});
|
|
713
|
+
};
|
|
714
|
+
const onend = () => {
|
|
715
|
+
this.off("error", onerr);
|
|
716
|
+
this.off("data", ondata);
|
|
717
|
+
this.off(DESTROYED, ondestroy);
|
|
718
|
+
stop();
|
|
719
|
+
resolve({
|
|
720
|
+
done: true,
|
|
721
|
+
value: void 0
|
|
722
|
+
});
|
|
723
|
+
};
|
|
724
|
+
const ondestroy = () => onerr(/* @__PURE__ */ new Error("stream destroyed"));
|
|
725
|
+
return new Promise((res, rej) => {
|
|
726
|
+
reject = rej;
|
|
727
|
+
resolve = res;
|
|
728
|
+
this.once(DESTROYED, ondestroy);
|
|
729
|
+
this.once("error", onerr);
|
|
730
|
+
this.once("end", onend);
|
|
731
|
+
this.once("data", ondata);
|
|
732
|
+
});
|
|
733
|
+
};
|
|
734
|
+
return {
|
|
735
|
+
next,
|
|
736
|
+
throw: stop,
|
|
737
|
+
return: stop,
|
|
738
|
+
[Symbol.asyncIterator]() {
|
|
739
|
+
return this;
|
|
740
|
+
},
|
|
741
|
+
[Symbol.asyncDispose]: async () => {}
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Synchronous `for of` iteration.
|
|
746
|
+
*
|
|
747
|
+
* The iteration will terminate when the internal buffer runs out, even
|
|
748
|
+
* if the stream has not yet terminated.
|
|
749
|
+
*/
|
|
750
|
+
[Symbol.iterator]() {
|
|
751
|
+
this[DISCARDED] = false;
|
|
752
|
+
let stopped = false;
|
|
753
|
+
const stop = () => {
|
|
754
|
+
this.pause();
|
|
755
|
+
this.off(ERROR, stop);
|
|
756
|
+
this.off(DESTROYED, stop);
|
|
757
|
+
this.off("end", stop);
|
|
758
|
+
stopped = true;
|
|
759
|
+
return {
|
|
760
|
+
done: true,
|
|
761
|
+
value: void 0
|
|
762
|
+
};
|
|
763
|
+
};
|
|
764
|
+
const next = () => {
|
|
765
|
+
if (stopped) return stop();
|
|
766
|
+
const value = this.read();
|
|
767
|
+
return value === null ? stop() : {
|
|
768
|
+
done: false,
|
|
769
|
+
value
|
|
770
|
+
};
|
|
771
|
+
};
|
|
772
|
+
this.once("end", stop);
|
|
773
|
+
this.once(ERROR, stop);
|
|
774
|
+
this.once(DESTROYED, stop);
|
|
775
|
+
return {
|
|
776
|
+
next,
|
|
777
|
+
throw: stop,
|
|
778
|
+
return: stop,
|
|
779
|
+
[Symbol.iterator]() {
|
|
780
|
+
return this;
|
|
781
|
+
},
|
|
782
|
+
[Symbol.dispose]: () => {}
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Destroy a stream, preventing it from being used for any further purpose.
|
|
787
|
+
*
|
|
788
|
+
* If the stream has a `close()` method, then it will be called on
|
|
789
|
+
* destruction.
|
|
790
|
+
*
|
|
791
|
+
* After destruction, any attempt to write data, read data, or emit most
|
|
792
|
+
* events will be ignored.
|
|
793
|
+
*
|
|
794
|
+
* If an error argument is provided, then it will be emitted in an
|
|
795
|
+
* 'error' event.
|
|
796
|
+
*/
|
|
797
|
+
destroy(er) {
|
|
798
|
+
if (this[DESTROYED]) {
|
|
799
|
+
if (er) this.emit("error", er);
|
|
800
|
+
else this.emit(DESTROYED);
|
|
801
|
+
return this;
|
|
802
|
+
}
|
|
803
|
+
this[DESTROYED] = true;
|
|
804
|
+
this[DISCARDED] = true;
|
|
805
|
+
this[BUFFER].length = 0;
|
|
806
|
+
this[BUFFERLENGTH] = 0;
|
|
807
|
+
const wc = this;
|
|
808
|
+
if (typeof wc.close === "function" && !this[CLOSED]) wc.close();
|
|
809
|
+
if (er) this.emit("error", er);
|
|
810
|
+
else this.emit(DESTROYED);
|
|
811
|
+
return this;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Alias for {@link isStream}
|
|
815
|
+
*
|
|
816
|
+
* Former export location, maintained for backwards compatibility.
|
|
817
|
+
*
|
|
818
|
+
* @deprecated
|
|
819
|
+
*/
|
|
820
|
+
static get isStream() {
|
|
821
|
+
return isStream;
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
//#endregion
|
|
825
|
+
//#region ../../node_modules/.pnpm/@isaacs+fs-minipass@4.0.1/node_modules/@isaacs/fs-minipass/dist/esm/index.js
|
|
826
|
+
var writev = fs.writev;
|
|
827
|
+
var _autoClose = Symbol("_autoClose");
|
|
828
|
+
var _close = Symbol("_close");
|
|
829
|
+
var _ended = Symbol("_ended");
|
|
830
|
+
var _fd = Symbol("_fd");
|
|
831
|
+
var _finished = Symbol("_finished");
|
|
832
|
+
var _flags = Symbol("_flags");
|
|
833
|
+
var _flush = Symbol("_flush");
|
|
834
|
+
var _handleChunk = Symbol("_handleChunk");
|
|
835
|
+
var _makeBuf = Symbol("_makeBuf");
|
|
836
|
+
var _mode = Symbol("_mode");
|
|
837
|
+
var _needDrain = Symbol("_needDrain");
|
|
838
|
+
var _onerror = Symbol("_onerror");
|
|
839
|
+
var _onopen = Symbol("_onopen");
|
|
840
|
+
var _onread = Symbol("_onread");
|
|
841
|
+
var _onwrite = Symbol("_onwrite");
|
|
842
|
+
var _open = Symbol("_open");
|
|
843
|
+
var _path = Symbol("_path");
|
|
844
|
+
var _pos = Symbol("_pos");
|
|
845
|
+
var _queue = Symbol("_queue");
|
|
846
|
+
var _read = Symbol("_read");
|
|
847
|
+
var _readSize = Symbol("_readSize");
|
|
848
|
+
var _reading = Symbol("_reading");
|
|
849
|
+
var _remain = Symbol("_remain");
|
|
850
|
+
var _size = Symbol("_size");
|
|
851
|
+
var _write = Symbol("_write");
|
|
852
|
+
var _writing = Symbol("_writing");
|
|
853
|
+
var _defaultFlag = Symbol("_defaultFlag");
|
|
854
|
+
var _errored = Symbol("_errored");
|
|
855
|
+
var ReadStream = class extends Minipass {
|
|
856
|
+
[_errored] = false;
|
|
857
|
+
[_fd];
|
|
858
|
+
[_path];
|
|
859
|
+
[_readSize];
|
|
860
|
+
[_reading] = false;
|
|
861
|
+
[_size];
|
|
862
|
+
[_remain];
|
|
863
|
+
[_autoClose];
|
|
864
|
+
constructor(path, opt) {
|
|
865
|
+
opt = opt || {};
|
|
866
|
+
super(opt);
|
|
867
|
+
this.readable = true;
|
|
868
|
+
this.writable = false;
|
|
869
|
+
if (typeof path !== "string") throw new TypeError("path must be a string");
|
|
870
|
+
this[_errored] = false;
|
|
871
|
+
this[_fd] = typeof opt.fd === "number" ? opt.fd : void 0;
|
|
872
|
+
this[_path] = path;
|
|
873
|
+
this[_readSize] = opt.readSize || 16 * 1024 * 1024;
|
|
874
|
+
this[_reading] = false;
|
|
875
|
+
this[_size] = typeof opt.size === "number" ? opt.size : Infinity;
|
|
876
|
+
this[_remain] = this[_size];
|
|
877
|
+
this[_autoClose] = typeof opt.autoClose === "boolean" ? opt.autoClose : true;
|
|
878
|
+
if (typeof this[_fd] === "number") this[_read]();
|
|
879
|
+
else this[_open]();
|
|
880
|
+
}
|
|
881
|
+
get fd() {
|
|
882
|
+
return this[_fd];
|
|
883
|
+
}
|
|
884
|
+
get path() {
|
|
885
|
+
return this[_path];
|
|
886
|
+
}
|
|
887
|
+
write() {
|
|
888
|
+
throw new TypeError("this is a readable stream");
|
|
889
|
+
}
|
|
890
|
+
end() {
|
|
891
|
+
throw new TypeError("this is a readable stream");
|
|
892
|
+
}
|
|
893
|
+
[_open]() {
|
|
894
|
+
fs.open(this[_path], "r", (er, fd) => this[_onopen](er, fd));
|
|
895
|
+
}
|
|
896
|
+
[_onopen](er, fd) {
|
|
897
|
+
if (er) this[_onerror](er);
|
|
898
|
+
else {
|
|
899
|
+
this[_fd] = fd;
|
|
900
|
+
this.emit("open", fd);
|
|
901
|
+
this[_read]();
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
[_makeBuf]() {
|
|
905
|
+
return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
|
|
906
|
+
}
|
|
907
|
+
[_read]() {
|
|
908
|
+
if (!this[_reading]) {
|
|
909
|
+
this[_reading] = true;
|
|
910
|
+
const buf = this[_makeBuf]();
|
|
911
|
+
/* c8 ignore start */
|
|
912
|
+
if (buf.length === 0) return process.nextTick(() => this[_onread](null, 0, buf));
|
|
913
|
+
/* c8 ignore stop */
|
|
914
|
+
fs.read(this[_fd], buf, 0, buf.length, null, (er, br, b) => this[_onread](er, br, b));
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
[_onread](er, br, buf) {
|
|
918
|
+
this[_reading] = false;
|
|
919
|
+
if (er) this[_onerror](er);
|
|
920
|
+
else if (this[_handleChunk](br, buf)) this[_read]();
|
|
921
|
+
}
|
|
922
|
+
[_close]() {
|
|
923
|
+
if (this[_autoClose] && typeof this[_fd] === "number") {
|
|
924
|
+
const fd = this[_fd];
|
|
925
|
+
this[_fd] = void 0;
|
|
926
|
+
fs.close(fd, (er) => er ? this.emit("error", er) : this.emit("close"));
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
[_onerror](er) {
|
|
930
|
+
this[_reading] = true;
|
|
931
|
+
this[_close]();
|
|
932
|
+
this.emit("error", er);
|
|
933
|
+
}
|
|
934
|
+
[_handleChunk](br, buf) {
|
|
935
|
+
let ret = false;
|
|
936
|
+
this[_remain] -= br;
|
|
937
|
+
if (br > 0) ret = super.write(br < buf.length ? buf.subarray(0, br) : buf);
|
|
938
|
+
if (br === 0 || this[_remain] <= 0) {
|
|
939
|
+
ret = false;
|
|
940
|
+
this[_close]();
|
|
941
|
+
super.end();
|
|
942
|
+
}
|
|
943
|
+
return ret;
|
|
944
|
+
}
|
|
945
|
+
emit(ev, ...args) {
|
|
946
|
+
switch (ev) {
|
|
947
|
+
case "prefinish":
|
|
948
|
+
case "finish": return false;
|
|
949
|
+
case "drain":
|
|
950
|
+
if (typeof this[_fd] === "number") this[_read]();
|
|
951
|
+
return false;
|
|
952
|
+
case "error":
|
|
953
|
+
if (this[_errored]) return false;
|
|
954
|
+
this[_errored] = true;
|
|
955
|
+
return super.emit(ev, ...args);
|
|
956
|
+
default: return super.emit(ev, ...args);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
var ReadStreamSync = class extends ReadStream {
|
|
961
|
+
[_open]() {
|
|
962
|
+
let threw = true;
|
|
963
|
+
try {
|
|
964
|
+
this[_onopen](null, fs.openSync(this[_path], "r"));
|
|
965
|
+
threw = false;
|
|
966
|
+
} finally {
|
|
967
|
+
if (threw) this[_close]();
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
[_read]() {
|
|
971
|
+
let threw = true;
|
|
972
|
+
try {
|
|
973
|
+
if (!this[_reading]) {
|
|
974
|
+
this[_reading] = true;
|
|
975
|
+
do {
|
|
976
|
+
const buf = this[_makeBuf]();
|
|
977
|
+
/* c8 ignore start */
|
|
978
|
+
const br = buf.length === 0 ? 0 : fs.readSync(this[_fd], buf, 0, buf.length, null);
|
|
979
|
+
/* c8 ignore stop */
|
|
980
|
+
if (!this[_handleChunk](br, buf)) break;
|
|
981
|
+
} while (true);
|
|
982
|
+
this[_reading] = false;
|
|
983
|
+
}
|
|
984
|
+
threw = false;
|
|
985
|
+
} finally {
|
|
986
|
+
if (threw) this[_close]();
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
[_close]() {
|
|
990
|
+
if (this[_autoClose] && typeof this[_fd] === "number") {
|
|
991
|
+
const fd = this[_fd];
|
|
992
|
+
this[_fd] = void 0;
|
|
993
|
+
fs.closeSync(fd);
|
|
994
|
+
this.emit("close");
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
var WriteStream = class extends EE {
|
|
999
|
+
readable = false;
|
|
1000
|
+
writable = true;
|
|
1001
|
+
[_errored] = false;
|
|
1002
|
+
[_writing] = false;
|
|
1003
|
+
[_ended] = false;
|
|
1004
|
+
[_queue] = [];
|
|
1005
|
+
[_needDrain] = false;
|
|
1006
|
+
[_path];
|
|
1007
|
+
[_mode];
|
|
1008
|
+
[_autoClose];
|
|
1009
|
+
[_fd];
|
|
1010
|
+
[_defaultFlag];
|
|
1011
|
+
[_flags];
|
|
1012
|
+
[_finished] = false;
|
|
1013
|
+
[_pos];
|
|
1014
|
+
constructor(path, opt) {
|
|
1015
|
+
opt = opt || {};
|
|
1016
|
+
super(opt);
|
|
1017
|
+
this[_path] = path;
|
|
1018
|
+
this[_fd] = typeof opt.fd === "number" ? opt.fd : void 0;
|
|
1019
|
+
this[_mode] = opt.mode === void 0 ? 438 : opt.mode;
|
|
1020
|
+
this[_pos] = typeof opt.start === "number" ? opt.start : void 0;
|
|
1021
|
+
this[_autoClose] = typeof opt.autoClose === "boolean" ? opt.autoClose : true;
|
|
1022
|
+
const defaultFlag = this[_pos] !== void 0 ? "r+" : "w";
|
|
1023
|
+
this[_defaultFlag] = opt.flags === void 0;
|
|
1024
|
+
this[_flags] = opt.flags === void 0 ? defaultFlag : opt.flags;
|
|
1025
|
+
if (this[_fd] === void 0) this[_open]();
|
|
1026
|
+
}
|
|
1027
|
+
emit(ev, ...args) {
|
|
1028
|
+
if (ev === "error") {
|
|
1029
|
+
if (this[_errored]) return false;
|
|
1030
|
+
this[_errored] = true;
|
|
1031
|
+
}
|
|
1032
|
+
return super.emit(ev, ...args);
|
|
1033
|
+
}
|
|
1034
|
+
get fd() {
|
|
1035
|
+
return this[_fd];
|
|
1036
|
+
}
|
|
1037
|
+
get path() {
|
|
1038
|
+
return this[_path];
|
|
1039
|
+
}
|
|
1040
|
+
[_onerror](er) {
|
|
1041
|
+
this[_close]();
|
|
1042
|
+
this[_writing] = true;
|
|
1043
|
+
this.emit("error", er);
|
|
1044
|
+
}
|
|
1045
|
+
[_open]() {
|
|
1046
|
+
fs.open(this[_path], this[_flags], this[_mode], (er, fd) => this[_onopen](er, fd));
|
|
1047
|
+
}
|
|
1048
|
+
[_onopen](er, fd) {
|
|
1049
|
+
if (this[_defaultFlag] && this[_flags] === "r+" && er && er.code === "ENOENT") {
|
|
1050
|
+
this[_flags] = "w";
|
|
1051
|
+
this[_open]();
|
|
1052
|
+
} else if (er) this[_onerror](er);
|
|
1053
|
+
else {
|
|
1054
|
+
this[_fd] = fd;
|
|
1055
|
+
this.emit("open", fd);
|
|
1056
|
+
if (!this[_writing]) this[_flush]();
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
end(buf, enc) {
|
|
1060
|
+
if (buf) this.write(buf, enc);
|
|
1061
|
+
this[_ended] = true;
|
|
1062
|
+
if (!this[_writing] && !this[_queue].length && typeof this[_fd] === "number") this[_onwrite](null, 0);
|
|
1063
|
+
return this;
|
|
1064
|
+
}
|
|
1065
|
+
write(buf, enc) {
|
|
1066
|
+
if (typeof buf === "string") buf = Buffer.from(buf, enc);
|
|
1067
|
+
if (this[_ended]) {
|
|
1068
|
+
this.emit("error", /* @__PURE__ */ new Error("write() after end()"));
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
if (this[_fd] === void 0 || this[_writing] || this[_queue].length) {
|
|
1072
|
+
this[_queue].push(buf);
|
|
1073
|
+
this[_needDrain] = true;
|
|
1074
|
+
return false;
|
|
1075
|
+
}
|
|
1076
|
+
this[_writing] = true;
|
|
1077
|
+
this[_write](buf);
|
|
1078
|
+
return true;
|
|
1079
|
+
}
|
|
1080
|
+
[_write](buf) {
|
|
1081
|
+
fs.write(this[_fd], buf, 0, buf.length, this[_pos], (er, bw) => this[_onwrite](er, bw));
|
|
1082
|
+
}
|
|
1083
|
+
[_onwrite](er, bw) {
|
|
1084
|
+
if (er) this[_onerror](er);
|
|
1085
|
+
else {
|
|
1086
|
+
if (this[_pos] !== void 0 && typeof bw === "number") this[_pos] += bw;
|
|
1087
|
+
if (this[_queue].length) this[_flush]();
|
|
1088
|
+
else {
|
|
1089
|
+
this[_writing] = false;
|
|
1090
|
+
if (this[_ended] && !this[_finished]) {
|
|
1091
|
+
this[_finished] = true;
|
|
1092
|
+
this[_close]();
|
|
1093
|
+
this.emit("finish");
|
|
1094
|
+
} else if (this[_needDrain]) {
|
|
1095
|
+
this[_needDrain] = false;
|
|
1096
|
+
this.emit("drain");
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
[_flush]() {
|
|
1102
|
+
if (this[_queue].length === 0) {
|
|
1103
|
+
if (this[_ended]) this[_onwrite](null, 0);
|
|
1104
|
+
} else if (this[_queue].length === 1) this[_write](this[_queue].pop());
|
|
1105
|
+
else {
|
|
1106
|
+
const iovec = this[_queue];
|
|
1107
|
+
this[_queue] = [];
|
|
1108
|
+
writev(this[_fd], iovec, this[_pos], (er, bw) => this[_onwrite](er, bw));
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
[_close]() {
|
|
1112
|
+
if (this[_autoClose] && typeof this[_fd] === "number") {
|
|
1113
|
+
const fd = this[_fd];
|
|
1114
|
+
this[_fd] = void 0;
|
|
1115
|
+
fs.close(fd, (er) => er ? this.emit("error", er) : this.emit("close"));
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
//#endregion
|
|
1120
|
+
export { Minipass as i, ReadStreamSync as n, WriteStream as r, ReadStream as t };
|