@kasperpeulen/vitest-plugin-nextjs 0.0.0-stage → 0.1.0-alpha.1
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/README.md +249 -2
- package/dist/_virtual/_rolldown/runtime.js +14 -0
- package/dist/action-ids.d.ts +18 -0
- package/dist/action-ids.js +44 -0
- package/dist/adapter.d.ts +8 -0
- package/dist/adapter.js +12 -0
- package/dist/app-requests.d.ts +63 -0
- package/dist/app-requests.js +253 -0
- package/dist/browser-context.d.ts +24 -0
- package/dist/browser-context.js +157 -0
- package/dist/build-output.d.ts +68 -0
- package/dist/build-output.js +216 -0
- package/dist/build.d.ts +26 -0
- package/dist/build.js +39 -0
- package/dist/built-files.d.ts +9 -0
- package/dist/built-files.js +22 -0
- package/dist/cache.d.ts +44 -0
- package/dist/cache.js +99 -0
- package/dist/client-components.d.ts +3 -0
- package/dist/client-components.js +4 -0
- package/dist/client-file-key.d.ts +5 -0
- package/dist/client-file-key.js +5 -0
- package/dist/client-files.d.ts +83 -0
- package/dist/client-files.js +186 -0
- package/dist/client-graph.d.ts +94 -0
- package/dist/client-graph.js +266 -0
- package/dist/client-modules.d.ts +10 -0
- package/dist/client-modules.js +43 -0
- package/dist/client.d.ts +42 -0
- package/dist/client.js +263 -0
- package/dist/commonjs.d.ts +44 -0
- package/dist/commonjs.js +111 -0
- package/dist/compat/browser/client.d.ts +19 -0
- package/dist/compat/browser/client.js +13 -0
- package/dist/compat/build.d.ts +145 -0
- package/dist/compat/build.js +149 -0
- package/dist/compat/checks.d.ts +16 -0
- package/dist/compat/checks.js +148 -0
- package/dist/compat/patches.d.ts +13 -0
- package/dist/compat/patches.js +30 -0
- package/dist/compat/paths.d.ts +74 -0
- package/dist/compat/paths.js +160 -0
- package/dist/compat/rsc/handlers.d.ts +2 -0
- package/dist/compat/rsc/handlers.js +2 -0
- package/dist/compat/rsc/prerender.d.ts +10 -0
- package/dist/compat/rsc/prerender.js +9 -0
- package/dist/compat/server/headers.d.ts +3 -0
- package/dist/compat/server/headers.js +3 -0
- package/dist/compat/ssr/build-output.d.ts +4 -0
- package/dist/compat/ssr/build-output.js +3 -0
- package/dist/compat/ssr/cache.d.ts +6 -0
- package/dist/compat/ssr/cache.js +6 -0
- package/dist/compat/ssr/handler.d.ts +8 -0
- package/dist/compat/ssr/handler.js +8 -0
- package/dist/compat/ssr/node-server.d.ts +5 -0
- package/dist/compat/ssr/node-server.js +4 -0
- package/dist/compat/ssr/render-errors.d.ts +4 -0
- package/dist/compat/ssr/render-errors.js +4 -0
- package/dist/compat/ssr/senders.d.ts +6 -0
- package/dist/compat/ssr/senders.js +6 -0
- package/dist/compat/types.d.ts +8 -0
- package/dist/compat/types.js +1 -0
- package/dist/compile.d.ts +39 -0
- package/dist/compile.js +175 -0
- package/dist/disk.d.ts +16 -0
- package/dist/disk.js +13 -0
- package/dist/document-loads.d.ts +15 -0
- package/dist/document-loads.js +53 -0
- package/dist/document.d.ts +79 -0
- package/dist/document.js +330 -0
- package/dist/downloads.d.ts +15 -0
- package/dist/downloads.js +71 -0
- package/dist/esm-require.d.ts +11 -0
- package/dist/esm-require.js +32 -0
- package/dist/fast-crypto/index.js +1093 -0
- package/dist/fast-crypto.d.ts +20 -0
- package/dist/fast-crypto.js +151 -0
- package/dist/flight.d.ts +19 -0
- package/dist/flight.js +42 -0
- package/dist/form-submission.d.ts +15 -0
- package/dist/form-submission.js +27 -0
- package/dist/from-page.d.ts +5 -0
- package/dist/from-page.js +44 -0
- package/dist/globals.d.ts +1 -0
- package/dist/globals.js +197 -0
- package/dist/host-document.d.ts +26 -0
- package/dist/host-document.js +34 -0
- package/dist/host-return-shared.d.ts +5 -0
- package/dist/host-return-shared.js +5 -0
- package/dist/host-return.d.ts +5 -0
- package/dist/host-return.js +16 -0
- package/dist/index.d.ts +280 -0
- package/dist/index.js +281 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +3 -0
- package/dist/leftovers.d.ts +11 -0
- package/dist/leftovers.js +55 -0
- package/dist/mode.d.ts +169 -0
- package/dist/mode.js +31 -0
- package/dist/node/LICENSES.md +3540 -0
- package/dist/node/assert/strict.js +29 -0
- package/dist/node/assert.js +3044 -0
- package/dist/node/buffer.js +1499 -0
- package/dist/node/child_process.js +45 -0
- package/dist/node/cluster.js +85 -0
- package/dist/node/console.js +96 -0
- package/dist/node/constants.js +495 -0
- package/dist/node/crypto.js +1388 -0
- package/dist/node/dgram.js +78 -0
- package/dist/node/diagnostics_channel.js +122 -0
- package/dist/node/dns/promises.js +129 -0
- package/dist/node/dns.js +137 -0
- package/dist/node/domain.js +43 -0
- package/dist/node/events.js +1155 -0
- package/dist/node/fs/promises.js +40 -0
- package/dist/node/fs.js +10375 -0
- package/dist/node/http.js +326 -0
- package/dist/node/http2.js +305 -0
- package/dist/node/https.js +57 -0
- package/dist/node/inspector/promises.js +66 -0
- package/dist/node/inspector.js +76 -0
- package/dist/node/module.js +205 -0
- package/dist/node/net.js +392 -0
- package/dist/node/os.js +259 -0
- package/dist/node/path/posix.js +25 -0
- package/dist/node/path/win32.js +25 -0
- package/dist/node/path.js +384 -0
- package/dist/node/perf_hooks.js +313 -0
- package/dist/node/process.js +452 -0
- package/dist/node/punycode.js +178 -0
- package/dist/node/querystring.js +934 -0
- package/dist/node/readline/promises.js +71 -0
- package/dist/node/readline.js +56 -0
- package/dist/node/repl.js +44 -0
- package/dist/node/sqlite.js +22 -0
- package/dist/node/stream/consumers.js +47 -0
- package/dist/node/stream/promises.js +6 -0
- package/dist/node/stream/web.js +52 -0
- package/dist/node/stream.js +4323 -0
- package/dist/node/string_decoder.js +276 -0
- package/dist/node/sys.js +6 -0
- package/dist/node/timers/promises.js +71 -0
- package/dist/node/timers.js +133 -0
- package/dist/node/tls.js +122 -0
- package/dist/node/trace_events.js +23 -0
- package/dist/node/tty.js +69 -0
- package/dist/node/url.js +1426 -0
- package/dist/node/util/types.js +1456 -0
- package/dist/node/util.js +4807 -0
- package/dist/node/v8.js +160 -0
- package/dist/node/vm.js +88 -0
- package/dist/node/wasi.js +16 -0
- package/dist/node/worker_threads.js +123 -0
- package/dist/node/zlib.js +1396 -0
- package/dist/node-builtins.d.ts +40 -0
- package/dist/node-builtins.js +74 -0
- package/dist/node-on-page.d.ts +46 -0
- package/dist/node-on-page.js +101 -0
- package/dist/node-platform.d.ts +36 -0
- package/dist/node-platform.js +152 -0
- package/dist/node-rendered.d.ts +21 -0
- package/dist/node-rendered.js +26 -0
- package/dist/node-server.d.ts +46 -0
- package/dist/node-server.js +193 -0
- package/dist/not-found-page.d.ts +19 -0
- package/dist/not-found-page.js +74 -0
- package/dist/optimizer-cache-key.d.ts +26 -0
- package/dist/optimizer-cache-key.js +73 -0
- package/dist/own-package.d.ts +1 -0
- package/dist/own-package.js +6 -0
- package/dist/page-store.d.ts +33 -0
- package/dist/page-store.js +80 -0
- package/dist/page-timers.d.ts +22 -0
- package/dist/page-timers.js +47 -0
- package/dist/page.d.ts +112 -0
- package/dist/page.js +549 -0
- package/dist/paths.d.ts +13 -0
- package/dist/paths.js +47 -0
- package/dist/plugin.d.ts +23 -0
- package/dist/plugin.js +1006 -0
- package/dist/prerender-verdict.d.ts +8 -0
- package/dist/prerender-verdict.js +67 -0
- package/dist/project/context.d.ts +546 -0
- package/dist/project/context.js +111 -0
- package/dist/project/entries.d.ts +42 -0
- package/dist/project/entries.js +189 -0
- package/dist/project/env-worker.d.ts +1 -0
- package/dist/project/env-worker.js +9 -0
- package/dist/project/env.d.ts +36 -0
- package/dist/project/env.js +82 -0
- package/dist/project/layers.d.ts +31 -0
- package/dist/project/layers.js +150 -0
- package/dist/project/loaders.d.ts +71 -0
- package/dist/project/loaders.js +300 -0
- package/dist/project/metadata.d.ts +8 -0
- package/dist/project/metadata.js +34 -0
- package/dist/project/module-exports.d.ts +29 -0
- package/dist/project/module-exports.js +77 -0
- package/dist/project/routes.d.ts +19 -0
- package/dist/project/routes.js +92 -0
- package/dist/project/routing.d.ts +46 -0
- package/dist/project/routing.js +280 -0
- package/dist/project/transform.d.ts +8 -0
- package/dist/project/transform.js +110 -0
- package/dist/project/webpack.d.ts +65 -0
- package/dist/project/webpack.js +191 -0
- package/dist/project.d.ts +269 -0
- package/dist/project.js +58 -0
- package/dist/registry-global.d.ts +5 -0
- package/dist/registry-global.js +5 -0
- package/dist/registry.d.ts +241 -0
- package/dist/registry.js +30 -0
- package/dist/route-chunks.d.ts +13 -0
- package/dist/route-chunks.js +32 -0
- package/dist/route-lookup.d.ts +34 -0
- package/dist/route-lookup.js +207 -0
- package/dist/routes-ahead-shared.d.ts +17 -0
- package/dist/routes-ahead-shared.js +9 -0
- package/dist/routes-ahead.d.ts +10 -0
- package/dist/routes-ahead.js +54 -0
- package/dist/rsc.d.ts +19 -0
- package/dist/rsc.js +171 -0
- package/dist/server-action.d.ts +9 -0
- package/dist/server-action.js +15 -0
- package/dist/server-code.d.ts +176 -0
- package/dist/server-code.js +357 -0
- package/dist/server-in-front.d.ts +37 -0
- package/dist/server-in-front.js +90 -0
- package/dist/server-layers.d.ts +22 -0
- package/dist/server-layers.js +33 -0
- package/dist/setup-browser.d.ts +1 -0
- package/dist/setup-browser.js +8 -0
- package/dist/setup-node.d.ts +1 -0
- package/dist/setup-node.js +6 -0
- package/dist/setup.d.ts +8 -0
- package/dist/setup.js +62 -0
- package/dist/speed-features.d.ts +13 -0
- package/dist/speed-features.js +95 -0
- package/dist/ssr.d.ts +70 -0
- package/dist/ssr.js +480 -0
- package/dist/static-build.d.ts +36 -0
- package/dist/static-build.js +92 -0
- package/dist/storage.d.ts +31 -0
- package/dist/storage.js +94 -0
- package/dist/styles-shared.d.ts +137 -0
- package/dist/styles-shared.js +124 -0
- package/dist/styles.d.ts +102 -0
- package/dist/styles.js +730 -0
- package/dist/stylesheet-versions.d.ts +17 -0
- package/dist/stylesheet-versions.js +43 -0
- package/dist/tester.html +10 -0
- package/dist/use-cache.d.ts +15 -0
- package/dist/use-cache.js +93 -0
- package/dist/vitest-version.d.ts +6 -0
- package/dist/vitest-version.js +12 -0
- package/package.json +125 -3
|
@@ -0,0 +1,4323 @@
|
|
|
1
|
+
import * as m$3 from "buffer";
|
|
2
|
+
import * as m$2 from "events";
|
|
3
|
+
import * as m$1 from "process";
|
|
4
|
+
import * as m from "string_decoder";
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region \0require-as-import:buffer
|
|
9
|
+
var require__require_as_import_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10
|
+
module.exports = m$3.default;
|
|
11
|
+
}));
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/ours/primordials.js
|
|
14
|
+
var require_primordials = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
15
|
+
var AggregateError = class extends Error {
|
|
16
|
+
constructor(errors) {
|
|
17
|
+
if (!Array.isArray(errors)) throw new TypeError(`Expected input to be an Array, got ${typeof errors}`);
|
|
18
|
+
let message = "";
|
|
19
|
+
for (let i = 0; i < errors.length; i++) message += ` ${errors[i].stack}\n`;
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "AggregateError";
|
|
22
|
+
this.errors = errors;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
module.exports = {
|
|
26
|
+
AggregateError,
|
|
27
|
+
ArrayIsArray(self) {
|
|
28
|
+
return Array.isArray(self);
|
|
29
|
+
},
|
|
30
|
+
ArrayPrototypeIncludes(self, el) {
|
|
31
|
+
return self.includes(el);
|
|
32
|
+
},
|
|
33
|
+
ArrayPrototypeIndexOf(self, el) {
|
|
34
|
+
return self.indexOf(el);
|
|
35
|
+
},
|
|
36
|
+
ArrayPrototypeJoin(self, sep) {
|
|
37
|
+
return self.join(sep);
|
|
38
|
+
},
|
|
39
|
+
ArrayPrototypeMap(self, fn) {
|
|
40
|
+
return self.map(fn);
|
|
41
|
+
},
|
|
42
|
+
ArrayPrototypePop(self, el) {
|
|
43
|
+
return self.pop(el);
|
|
44
|
+
},
|
|
45
|
+
ArrayPrototypePush(self, el) {
|
|
46
|
+
return self.push(el);
|
|
47
|
+
},
|
|
48
|
+
ArrayPrototypeSlice(self, start, end) {
|
|
49
|
+
return self.slice(start, end);
|
|
50
|
+
},
|
|
51
|
+
Error,
|
|
52
|
+
FunctionPrototypeCall(fn, thisArgs, ...args) {
|
|
53
|
+
return fn.call(thisArgs, ...args);
|
|
54
|
+
},
|
|
55
|
+
FunctionPrototypeSymbolHasInstance(self, instance) {
|
|
56
|
+
return Function.prototype[Symbol.hasInstance].call(self, instance);
|
|
57
|
+
},
|
|
58
|
+
MathFloor: Math.floor,
|
|
59
|
+
Number,
|
|
60
|
+
NumberIsInteger: Number.isInteger,
|
|
61
|
+
NumberIsNaN: Number.isNaN,
|
|
62
|
+
NumberMAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER,
|
|
63
|
+
NumberMIN_SAFE_INTEGER: Number.MIN_SAFE_INTEGER,
|
|
64
|
+
NumberParseInt: Number.parseInt,
|
|
65
|
+
ObjectDefineProperties(self, props) {
|
|
66
|
+
return Object.defineProperties(self, props);
|
|
67
|
+
},
|
|
68
|
+
ObjectDefineProperty(self, name, prop) {
|
|
69
|
+
return Object.defineProperty(self, name, prop);
|
|
70
|
+
},
|
|
71
|
+
ObjectGetOwnPropertyDescriptor(self, name) {
|
|
72
|
+
return Object.getOwnPropertyDescriptor(self, name);
|
|
73
|
+
},
|
|
74
|
+
ObjectKeys(obj) {
|
|
75
|
+
return Object.keys(obj);
|
|
76
|
+
},
|
|
77
|
+
ObjectSetPrototypeOf(target, proto) {
|
|
78
|
+
return Object.setPrototypeOf(target, proto);
|
|
79
|
+
},
|
|
80
|
+
Promise,
|
|
81
|
+
PromisePrototypeCatch(self, fn) {
|
|
82
|
+
return self.catch(fn);
|
|
83
|
+
},
|
|
84
|
+
PromisePrototypeThen(self, thenFn, catchFn) {
|
|
85
|
+
return self.then(thenFn, catchFn);
|
|
86
|
+
},
|
|
87
|
+
PromiseReject(err) {
|
|
88
|
+
return Promise.reject(err);
|
|
89
|
+
},
|
|
90
|
+
PromiseResolve(val) {
|
|
91
|
+
return Promise.resolve(val);
|
|
92
|
+
},
|
|
93
|
+
ReflectApply: Reflect.apply,
|
|
94
|
+
RegExpPrototypeTest(self, value) {
|
|
95
|
+
return self.test(value);
|
|
96
|
+
},
|
|
97
|
+
SafeSet: Set,
|
|
98
|
+
String,
|
|
99
|
+
StringPrototypeSlice(self, start, end) {
|
|
100
|
+
return self.slice(start, end);
|
|
101
|
+
},
|
|
102
|
+
StringPrototypeToLowerCase(self) {
|
|
103
|
+
return self.toLowerCase();
|
|
104
|
+
},
|
|
105
|
+
StringPrototypeToUpperCase(self) {
|
|
106
|
+
return self.toUpperCase();
|
|
107
|
+
},
|
|
108
|
+
StringPrototypeTrim(self) {
|
|
109
|
+
return self.trim();
|
|
110
|
+
},
|
|
111
|
+
Symbol,
|
|
112
|
+
SymbolFor: Symbol.for,
|
|
113
|
+
SymbolAsyncIterator: Symbol.asyncIterator,
|
|
114
|
+
SymbolHasInstance: Symbol.hasInstance,
|
|
115
|
+
SymbolIterator: Symbol.iterator,
|
|
116
|
+
SymbolDispose: Symbol.dispose || Symbol("Symbol.dispose"),
|
|
117
|
+
SymbolAsyncDispose: Symbol.asyncDispose || Symbol("Symbol.asyncDispose"),
|
|
118
|
+
TypedArrayPrototypeSet(self, buf, len) {
|
|
119
|
+
return self.set(buf, len);
|
|
120
|
+
},
|
|
121
|
+
Boolean,
|
|
122
|
+
Uint8Array
|
|
123
|
+
};
|
|
124
|
+
}));
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/ours/util/inspect.js
|
|
127
|
+
var require_inspect = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
128
|
+
module.exports = {
|
|
129
|
+
format(format, ...args) {
|
|
130
|
+
return format.replace(/%([sdifj])/g, function(...[_unused, type]) {
|
|
131
|
+
const replacement = args.shift();
|
|
132
|
+
if (type === "f") return replacement.toFixed(6);
|
|
133
|
+
else if (type === "j") return JSON.stringify(replacement);
|
|
134
|
+
else if (type === "s" && typeof replacement === "object") return `${replacement.constructor !== Object ? replacement.constructor.name : ""} {}`.trim();
|
|
135
|
+
else return replacement.toString();
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
inspect(value) {
|
|
139
|
+
switch (typeof value) {
|
|
140
|
+
case "string":
|
|
141
|
+
if (value.includes("'")) {
|
|
142
|
+
if (!value.includes("\"")) return `"${value}"`;
|
|
143
|
+
else if (!value.includes("`") && !value.includes("${")) return `\`${value}\``;
|
|
144
|
+
}
|
|
145
|
+
return `'${value}'`;
|
|
146
|
+
case "number":
|
|
147
|
+
if (isNaN(value)) return "NaN";
|
|
148
|
+
else if (Object.is(value, -0)) return String(value);
|
|
149
|
+
return value;
|
|
150
|
+
case "bigint": return `${String(value)}n`;
|
|
151
|
+
case "boolean":
|
|
152
|
+
case "undefined": return String(value);
|
|
153
|
+
case "object": return "{}";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}));
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/ours/errors.js
|
|
160
|
+
var require_errors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
161
|
+
const { format, inspect } = require_inspect();
|
|
162
|
+
const { AggregateError: CustomAggregateError } = require_primordials();
|
|
163
|
+
const AggregateError = globalThis.AggregateError || CustomAggregateError;
|
|
164
|
+
const kIsNodeError = Symbol("kIsNodeError");
|
|
165
|
+
const kTypes = [
|
|
166
|
+
"string",
|
|
167
|
+
"function",
|
|
168
|
+
"number",
|
|
169
|
+
"object",
|
|
170
|
+
"Function",
|
|
171
|
+
"Object",
|
|
172
|
+
"boolean",
|
|
173
|
+
"bigint",
|
|
174
|
+
"symbol"
|
|
175
|
+
];
|
|
176
|
+
const classRegExp = /^([A-Z][a-z0-9]*)+$/;
|
|
177
|
+
const nodeInternalPrefix = "__node_internal_";
|
|
178
|
+
const codes = {};
|
|
179
|
+
function assert(value, message) {
|
|
180
|
+
if (!value) throw new codes.ERR_INTERNAL_ASSERTION(message);
|
|
181
|
+
}
|
|
182
|
+
function addNumericalSeparator(val) {
|
|
183
|
+
let res = "";
|
|
184
|
+
let i = val.length;
|
|
185
|
+
const start = val[0] === "-" ? 1 : 0;
|
|
186
|
+
for (; i >= start + 4; i -= 3) res = `_${val.slice(i - 3, i)}${res}`;
|
|
187
|
+
return `${val.slice(0, i)}${res}`;
|
|
188
|
+
}
|
|
189
|
+
function getMessage(key, msg, args) {
|
|
190
|
+
if (typeof msg === "function") {
|
|
191
|
+
assert(msg.length <= args.length, `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${msg.length}).`);
|
|
192
|
+
return msg(...args);
|
|
193
|
+
}
|
|
194
|
+
const expectedLength = (msg.match(/%[dfijoOs]/g) || []).length;
|
|
195
|
+
assert(expectedLength === args.length, `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`);
|
|
196
|
+
if (args.length === 0) return msg;
|
|
197
|
+
return format(msg, ...args);
|
|
198
|
+
}
|
|
199
|
+
function E(code, message, Base) {
|
|
200
|
+
if (!Base) Base = Error;
|
|
201
|
+
class NodeError extends Base {
|
|
202
|
+
constructor(...args) {
|
|
203
|
+
super(getMessage(code, message, args));
|
|
204
|
+
}
|
|
205
|
+
toString() {
|
|
206
|
+
return `${this.name} [${code}]: ${this.message}`;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
Object.defineProperties(NodeError.prototype, {
|
|
210
|
+
name: {
|
|
211
|
+
value: Base.name,
|
|
212
|
+
writable: true,
|
|
213
|
+
enumerable: false,
|
|
214
|
+
configurable: true
|
|
215
|
+
},
|
|
216
|
+
toString: {
|
|
217
|
+
value() {
|
|
218
|
+
return `${this.name} [${code}]: ${this.message}`;
|
|
219
|
+
},
|
|
220
|
+
writable: true,
|
|
221
|
+
enumerable: false,
|
|
222
|
+
configurable: true
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
NodeError.prototype.code = code;
|
|
226
|
+
NodeError.prototype[kIsNodeError] = true;
|
|
227
|
+
codes[code] = NodeError;
|
|
228
|
+
}
|
|
229
|
+
function hideStackFrames(fn) {
|
|
230
|
+
const hidden = nodeInternalPrefix + fn.name;
|
|
231
|
+
Object.defineProperty(fn, "name", { value: hidden });
|
|
232
|
+
return fn;
|
|
233
|
+
}
|
|
234
|
+
function aggregateTwoErrors(innerError, outerError) {
|
|
235
|
+
if (innerError && outerError && innerError !== outerError) {
|
|
236
|
+
if (Array.isArray(outerError.errors)) {
|
|
237
|
+
outerError.errors.push(innerError);
|
|
238
|
+
return outerError;
|
|
239
|
+
}
|
|
240
|
+
const err = new AggregateError([outerError, innerError], outerError.message);
|
|
241
|
+
err.code = outerError.code;
|
|
242
|
+
return err;
|
|
243
|
+
}
|
|
244
|
+
return innerError || outerError;
|
|
245
|
+
}
|
|
246
|
+
var AbortError = class extends Error {
|
|
247
|
+
constructor(message = "The operation was aborted", options = void 0) {
|
|
248
|
+
if (options !== void 0 && typeof options !== "object") throw new codes.ERR_INVALID_ARG_TYPE("options", "Object", options);
|
|
249
|
+
super(message, options);
|
|
250
|
+
this.code = "ABORT_ERR";
|
|
251
|
+
this.name = "AbortError";
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
E("ERR_ASSERTION", "%s", Error);
|
|
255
|
+
E("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
|
|
256
|
+
assert(typeof name === "string", "'name' must be a string");
|
|
257
|
+
if (!Array.isArray(expected)) expected = [expected];
|
|
258
|
+
let msg = "The ";
|
|
259
|
+
if (name.endsWith(" argument")) msg += `${name} `;
|
|
260
|
+
else msg += `"${name}" ${name.includes(".") ? "property" : "argument"} `;
|
|
261
|
+
msg += "must be ";
|
|
262
|
+
const types = [];
|
|
263
|
+
const instances = [];
|
|
264
|
+
const other = [];
|
|
265
|
+
for (const value of expected) {
|
|
266
|
+
assert(typeof value === "string", "All expected entries have to be of type string");
|
|
267
|
+
if (kTypes.includes(value)) types.push(value.toLowerCase());
|
|
268
|
+
else if (classRegExp.test(value)) instances.push(value);
|
|
269
|
+
else {
|
|
270
|
+
assert(value !== "object", "The value \"object\" should be written as \"Object\"");
|
|
271
|
+
other.push(value);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (instances.length > 0) {
|
|
275
|
+
const pos = types.indexOf("object");
|
|
276
|
+
if (pos !== -1) {
|
|
277
|
+
types.splice(types, pos, 1);
|
|
278
|
+
instances.push("Object");
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (types.length > 0) {
|
|
282
|
+
switch (types.length) {
|
|
283
|
+
case 1:
|
|
284
|
+
msg += `of type ${types[0]}`;
|
|
285
|
+
break;
|
|
286
|
+
case 2:
|
|
287
|
+
msg += `one of type ${types[0]} or ${types[1]}`;
|
|
288
|
+
break;
|
|
289
|
+
default: {
|
|
290
|
+
const last = types.pop();
|
|
291
|
+
msg += `one of type ${types.join(", ")}, or ${last}`;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (instances.length > 0 || other.length > 0) msg += " or ";
|
|
295
|
+
}
|
|
296
|
+
if (instances.length > 0) {
|
|
297
|
+
switch (instances.length) {
|
|
298
|
+
case 1:
|
|
299
|
+
msg += `an instance of ${instances[0]}`;
|
|
300
|
+
break;
|
|
301
|
+
case 2:
|
|
302
|
+
msg += `an instance of ${instances[0]} or ${instances[1]}`;
|
|
303
|
+
break;
|
|
304
|
+
default: {
|
|
305
|
+
const last = instances.pop();
|
|
306
|
+
msg += `an instance of ${instances.join(", ")}, or ${last}`;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (other.length > 0) msg += " or ";
|
|
310
|
+
}
|
|
311
|
+
switch (other.length) {
|
|
312
|
+
case 0: break;
|
|
313
|
+
case 1:
|
|
314
|
+
if (other[0].toLowerCase() !== other[0]) msg += "an ";
|
|
315
|
+
msg += `${other[0]}`;
|
|
316
|
+
break;
|
|
317
|
+
case 2:
|
|
318
|
+
msg += `one of ${other[0]} or ${other[1]}`;
|
|
319
|
+
break;
|
|
320
|
+
default: {
|
|
321
|
+
const last = other.pop();
|
|
322
|
+
msg += `one of ${other.join(", ")}, or ${last}`;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (actual == null) msg += `. Received ${actual}`;
|
|
326
|
+
else if (typeof actual === "function" && actual.name) msg += `. Received function ${actual.name}`;
|
|
327
|
+
else if (typeof actual === "object") {
|
|
328
|
+
var _actual$constructor;
|
|
329
|
+
if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) msg += `. Received an instance of ${actual.constructor.name}`;
|
|
330
|
+
else {
|
|
331
|
+
const inspected = inspect(actual, { depth: -1 });
|
|
332
|
+
msg += `. Received ${inspected}`;
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
let inspected = inspect(actual, { colors: false });
|
|
336
|
+
if (inspected.length > 25) inspected = `${inspected.slice(0, 25)}...`;
|
|
337
|
+
msg += `. Received type ${typeof actual} (${inspected})`;
|
|
338
|
+
}
|
|
339
|
+
return msg;
|
|
340
|
+
}, TypeError);
|
|
341
|
+
E("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
|
|
342
|
+
let inspected = inspect(value);
|
|
343
|
+
if (inspected.length > 128) inspected = inspected.slice(0, 128) + "...";
|
|
344
|
+
return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
|
|
345
|
+
}, TypeError);
|
|
346
|
+
E("ERR_INVALID_RETURN_VALUE", (input, name, value) => {
|
|
347
|
+
var _value$constructor;
|
|
348
|
+
return `Expected ${input} to be returned from the "${name}" function but got ${value !== null && value !== void 0 && (_value$constructor = value.constructor) !== null && _value$constructor !== void 0 && _value$constructor.name ? `instance of ${value.constructor.name}` : `type ${typeof value}`}.`;
|
|
349
|
+
}, TypeError);
|
|
350
|
+
E("ERR_MISSING_ARGS", (...args) => {
|
|
351
|
+
assert(args.length > 0, "At least one arg needs to be specified");
|
|
352
|
+
let msg;
|
|
353
|
+
const len = args.length;
|
|
354
|
+
args = (Array.isArray(args) ? args : [args]).map((a) => `"${a}"`).join(" or ");
|
|
355
|
+
switch (len) {
|
|
356
|
+
case 1:
|
|
357
|
+
msg += `The ${args[0]} argument`;
|
|
358
|
+
break;
|
|
359
|
+
case 2:
|
|
360
|
+
msg += `The ${args[0]} and ${args[1]} arguments`;
|
|
361
|
+
break;
|
|
362
|
+
default: {
|
|
363
|
+
const last = args.pop();
|
|
364
|
+
msg += `The ${args.join(", ")}, and ${last} arguments`;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return `${msg} must be specified`;
|
|
368
|
+
}, TypeError);
|
|
369
|
+
E("ERR_OUT_OF_RANGE", (str, range, input) => {
|
|
370
|
+
assert(range, "Missing \"range\" argument");
|
|
371
|
+
let received;
|
|
372
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) received = addNumericalSeparator(String(input));
|
|
373
|
+
else if (typeof input === "bigint") {
|
|
374
|
+
received = String(input);
|
|
375
|
+
const limit = BigInt(2) ** BigInt(32);
|
|
376
|
+
if (input > limit || input < -limit) received = addNumericalSeparator(received);
|
|
377
|
+
received += "n";
|
|
378
|
+
} else received = inspect(input);
|
|
379
|
+
return `The value of "${str}" is out of range. It must be ${range}. Received ${received}`;
|
|
380
|
+
}, RangeError);
|
|
381
|
+
E("ERR_MULTIPLE_CALLBACK", "Callback called multiple times", Error);
|
|
382
|
+
E("ERR_METHOD_NOT_IMPLEMENTED", "The %s method is not implemented", Error);
|
|
383
|
+
E("ERR_STREAM_ALREADY_FINISHED", "Cannot call %s after a stream was finished", Error);
|
|
384
|
+
E("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable", Error);
|
|
385
|
+
E("ERR_STREAM_DESTROYED", "Cannot call %s after a stream was destroyed", Error);
|
|
386
|
+
E("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError);
|
|
387
|
+
E("ERR_STREAM_PREMATURE_CLOSE", "Premature close", Error);
|
|
388
|
+
E("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF", Error);
|
|
389
|
+
E("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event", Error);
|
|
390
|
+
E("ERR_STREAM_WRITE_AFTER_END", "write after end", Error);
|
|
391
|
+
E("ERR_UNKNOWN_ENCODING", "Unknown encoding: %s", TypeError);
|
|
392
|
+
module.exports = {
|
|
393
|
+
AbortError,
|
|
394
|
+
aggregateTwoErrors: hideStackFrames(aggregateTwoErrors),
|
|
395
|
+
hideStackFrames,
|
|
396
|
+
codes
|
|
397
|
+
};
|
|
398
|
+
}));
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region \0empty-module
|
|
401
|
+
var require__empty_module = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
402
|
+
module.exports = {};
|
|
403
|
+
}));
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region \0require-as-import:events
|
|
406
|
+
var require__require_as_import_events = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
407
|
+
module.exports = m$2.default;
|
|
408
|
+
}));
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/ours/util.js
|
|
411
|
+
var require_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
412
|
+
const bufferModule = require__require_as_import_buffer();
|
|
413
|
+
const { format, inspect } = require_inspect();
|
|
414
|
+
const { codes: { ERR_INVALID_ARG_TYPE } } = require_errors();
|
|
415
|
+
const { kResistStopPropagation, AggregateError, SymbolDispose } = require_primordials();
|
|
416
|
+
const AbortSignal = globalThis.AbortSignal || require__empty_module().AbortSignal;
|
|
417
|
+
const AbortController = globalThis.AbortController || require__empty_module().AbortController;
|
|
418
|
+
const AsyncFunction = Object.getPrototypeOf(async function() {}).constructor;
|
|
419
|
+
const Blob = globalThis.Blob || bufferModule.Blob;
|
|
420
|
+
const isBlob = typeof Blob !== "undefined" ? function isBlob(b) {
|
|
421
|
+
return b instanceof Blob;
|
|
422
|
+
} : function isBlob(b) {
|
|
423
|
+
return false;
|
|
424
|
+
};
|
|
425
|
+
const validateAbortSignal = (signal, name) => {
|
|
426
|
+
if (signal !== void 0 && (signal === null || typeof signal !== "object" || !("aborted" in signal))) throw new ERR_INVALID_ARG_TYPE(name, "AbortSignal", signal);
|
|
427
|
+
};
|
|
428
|
+
const validateFunction = (value, name) => {
|
|
429
|
+
if (typeof value !== "function") throw new ERR_INVALID_ARG_TYPE(name, "Function", value);
|
|
430
|
+
};
|
|
431
|
+
module.exports = {
|
|
432
|
+
AggregateError,
|
|
433
|
+
kEmptyObject: Object.freeze({}),
|
|
434
|
+
once(callback) {
|
|
435
|
+
let called = false;
|
|
436
|
+
return function(...args) {
|
|
437
|
+
if (called) return;
|
|
438
|
+
called = true;
|
|
439
|
+
callback.apply(this, args);
|
|
440
|
+
};
|
|
441
|
+
},
|
|
442
|
+
createDeferredPromise: function() {
|
|
443
|
+
let resolve;
|
|
444
|
+
let reject;
|
|
445
|
+
return {
|
|
446
|
+
promise: new Promise((res, rej) => {
|
|
447
|
+
resolve = res;
|
|
448
|
+
reject = rej;
|
|
449
|
+
}),
|
|
450
|
+
resolve,
|
|
451
|
+
reject
|
|
452
|
+
};
|
|
453
|
+
},
|
|
454
|
+
promisify(fn) {
|
|
455
|
+
return new Promise((resolve, reject) => {
|
|
456
|
+
fn((err, ...args) => {
|
|
457
|
+
if (err) return reject(err);
|
|
458
|
+
return resolve(...args);
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
},
|
|
462
|
+
debuglog() {
|
|
463
|
+
return function() {};
|
|
464
|
+
},
|
|
465
|
+
format,
|
|
466
|
+
inspect,
|
|
467
|
+
types: {
|
|
468
|
+
isAsyncFunction(fn) {
|
|
469
|
+
return fn instanceof AsyncFunction;
|
|
470
|
+
},
|
|
471
|
+
isArrayBufferView(arr) {
|
|
472
|
+
return ArrayBuffer.isView(arr);
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
isBlob,
|
|
476
|
+
deprecate(fn, message) {
|
|
477
|
+
return fn;
|
|
478
|
+
},
|
|
479
|
+
addAbortListener: require__require_as_import_events().addAbortListener || function addAbortListener(signal, listener) {
|
|
480
|
+
if (signal === void 0) throw new ERR_INVALID_ARG_TYPE("signal", "AbortSignal", signal);
|
|
481
|
+
validateAbortSignal(signal, "signal");
|
|
482
|
+
validateFunction(listener, "listener");
|
|
483
|
+
let removeEventListener;
|
|
484
|
+
if (signal.aborted) queueMicrotask(() => listener());
|
|
485
|
+
else {
|
|
486
|
+
signal.addEventListener("abort", listener, {
|
|
487
|
+
__proto__: null,
|
|
488
|
+
once: true,
|
|
489
|
+
[kResistStopPropagation]: true
|
|
490
|
+
});
|
|
491
|
+
removeEventListener = () => {
|
|
492
|
+
signal.removeEventListener("abort", listener);
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
return {
|
|
496
|
+
__proto__: null,
|
|
497
|
+
[SymbolDispose]() {
|
|
498
|
+
var _removeEventListener;
|
|
499
|
+
(_removeEventListener = removeEventListener) === null || _removeEventListener === void 0 || _removeEventListener();
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
},
|
|
503
|
+
AbortSignalAny: AbortSignal.any || function AbortSignalAny(signals) {
|
|
504
|
+
if (signals.length === 1) return signals[0];
|
|
505
|
+
const ac = new AbortController();
|
|
506
|
+
const abort = () => ac.abort();
|
|
507
|
+
signals.forEach((signal) => {
|
|
508
|
+
validateAbortSignal(signal, "signals");
|
|
509
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
510
|
+
});
|
|
511
|
+
ac.signal.addEventListener("abort", () => {
|
|
512
|
+
signals.forEach((signal) => signal.removeEventListener("abort", abort));
|
|
513
|
+
}, { once: true });
|
|
514
|
+
return ac.signal;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
module.exports.promisify.custom = Symbol.for("nodejs.util.promisify.custom");
|
|
518
|
+
}));
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/validators.js
|
|
521
|
+
var require_validators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
522
|
+
const { ArrayIsArray, ArrayPrototypeIncludes, ArrayPrototypeJoin, ArrayPrototypeMap, NumberIsInteger, NumberIsNaN, NumberMAX_SAFE_INTEGER, NumberMIN_SAFE_INTEGER, NumberParseInt, ObjectPrototypeHasOwnProperty, RegExpPrototypeExec, String, StringPrototypeToUpperCase, StringPrototypeTrim } = require_primordials();
|
|
523
|
+
const { hideStackFrames, codes: { ERR_SOCKET_BAD_PORT, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_OUT_OF_RANGE, ERR_UNKNOWN_SIGNAL } } = require_errors();
|
|
524
|
+
const { normalizeEncoding } = require_util();
|
|
525
|
+
const { isAsyncFunction, isArrayBufferView } = require_util().types;
|
|
526
|
+
const signals = {};
|
|
527
|
+
function isInt32(value) {
|
|
528
|
+
return value === (value | 0);
|
|
529
|
+
}
|
|
530
|
+
function isUint32(value) {
|
|
531
|
+
return value === value >>> 0;
|
|
532
|
+
}
|
|
533
|
+
const octalReg = /^[0-7]+$/;
|
|
534
|
+
const modeDesc = "must be a 32-bit unsigned integer or an octal string";
|
|
535
|
+
function parseFileMode(value, name, def) {
|
|
536
|
+
if (typeof value === "undefined") value = def;
|
|
537
|
+
if (typeof value === "string") {
|
|
538
|
+
if (RegExpPrototypeExec(octalReg, value) === null) throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc);
|
|
539
|
+
value = NumberParseInt(value, 8);
|
|
540
|
+
}
|
|
541
|
+
validateUint32(value, name);
|
|
542
|
+
return value;
|
|
543
|
+
}
|
|
544
|
+
const validateInteger = hideStackFrames((value, name, min = NumberMIN_SAFE_INTEGER, max = NumberMAX_SAFE_INTEGER) => {
|
|
545
|
+
if (typeof value !== "number") throw new ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
546
|
+
if (!NumberIsInteger(value)) throw new ERR_OUT_OF_RANGE(name, "an integer", value);
|
|
547
|
+
if (value < min || value > max) throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
|
|
548
|
+
});
|
|
549
|
+
const validateInt32 = hideStackFrames((value, name, min = -2147483648, max = 2147483647) => {
|
|
550
|
+
if (typeof value !== "number") throw new ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
551
|
+
if (!NumberIsInteger(value)) throw new ERR_OUT_OF_RANGE(name, "an integer", value);
|
|
552
|
+
if (value < min || value > max) throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
|
|
553
|
+
});
|
|
554
|
+
const validateUint32 = hideStackFrames((value, name, positive = false) => {
|
|
555
|
+
if (typeof value !== "number") throw new ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
556
|
+
if (!NumberIsInteger(value)) throw new ERR_OUT_OF_RANGE(name, "an integer", value);
|
|
557
|
+
const min = positive ? 1 : 0;
|
|
558
|
+
const max = 4294967295;
|
|
559
|
+
if (value < min || value > max) throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
|
|
560
|
+
});
|
|
561
|
+
function validateString(value, name) {
|
|
562
|
+
if (typeof value !== "string") throw new ERR_INVALID_ARG_TYPE(name, "string", value);
|
|
563
|
+
}
|
|
564
|
+
function validateNumber(value, name, min = void 0, max) {
|
|
565
|
+
if (typeof value !== "number") throw new ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
566
|
+
if (min != null && value < min || max != null && value > max || (min != null || max != null) && NumberIsNaN(value)) throw new ERR_OUT_OF_RANGE(name, `${min != null ? `>= ${min}` : ""}${min != null && max != null ? " && " : ""}${max != null ? `<= ${max}` : ""}`, value);
|
|
567
|
+
}
|
|
568
|
+
const validateOneOf = hideStackFrames((value, name, oneOf) => {
|
|
569
|
+
if (!ArrayPrototypeIncludes(oneOf, value)) {
|
|
570
|
+
const reason = "must be one of: " + ArrayPrototypeJoin(ArrayPrototypeMap(oneOf, (v) => typeof v === "string" ? `'${v}'` : String(v)), ", ");
|
|
571
|
+
throw new ERR_INVALID_ARG_VALUE(name, value, reason);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
function validateBoolean(value, name) {
|
|
575
|
+
if (typeof value !== "boolean") throw new ERR_INVALID_ARG_TYPE(name, "boolean", value);
|
|
576
|
+
}
|
|
577
|
+
function getOwnPropertyValueOrDefault(options, key, defaultValue) {
|
|
578
|
+
return options == null || !ObjectPrototypeHasOwnProperty(options, key) ? defaultValue : options[key];
|
|
579
|
+
}
|
|
580
|
+
const validateObject = hideStackFrames((value, name, options = null) => {
|
|
581
|
+
const allowArray = getOwnPropertyValueOrDefault(options, "allowArray", false);
|
|
582
|
+
const allowFunction = getOwnPropertyValueOrDefault(options, "allowFunction", false);
|
|
583
|
+
if (!getOwnPropertyValueOrDefault(options, "nullable", false) && value === null || !allowArray && ArrayIsArray(value) || typeof value !== "object" && (!allowFunction || typeof value !== "function")) throw new ERR_INVALID_ARG_TYPE(name, "Object", value);
|
|
584
|
+
});
|
|
585
|
+
const validateDictionary = hideStackFrames((value, name) => {
|
|
586
|
+
if (value != null && typeof value !== "object" && typeof value !== "function") throw new ERR_INVALID_ARG_TYPE(name, "a dictionary", value);
|
|
587
|
+
});
|
|
588
|
+
const validateArray = hideStackFrames((value, name, minLength = 0) => {
|
|
589
|
+
if (!ArrayIsArray(value)) throw new ERR_INVALID_ARG_TYPE(name, "Array", value);
|
|
590
|
+
if (value.length < minLength) {
|
|
591
|
+
const reason = `must be longer than ${minLength}`;
|
|
592
|
+
throw new ERR_INVALID_ARG_VALUE(name, value, reason);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
function validateStringArray(value, name) {
|
|
596
|
+
validateArray(value, name);
|
|
597
|
+
for (let i = 0; i < value.length; i++) validateString(value[i], `${name}[${i}]`);
|
|
598
|
+
}
|
|
599
|
+
function validateBooleanArray(value, name) {
|
|
600
|
+
validateArray(value, name);
|
|
601
|
+
for (let i = 0; i < value.length; i++) validateBoolean(value[i], `${name}[${i}]`);
|
|
602
|
+
}
|
|
603
|
+
function validateAbortSignalArray(value, name) {
|
|
604
|
+
validateArray(value, name);
|
|
605
|
+
for (let i = 0; i < value.length; i++) {
|
|
606
|
+
const signal = value[i];
|
|
607
|
+
const indexedName = `${name}[${i}]`;
|
|
608
|
+
if (signal == null) throw new ERR_INVALID_ARG_TYPE(indexedName, "AbortSignal", signal);
|
|
609
|
+
validateAbortSignal(signal, indexedName);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
function validateSignalName(signal, name = "signal") {
|
|
613
|
+
validateString(signal, name);
|
|
614
|
+
if (signals[signal] === void 0) {
|
|
615
|
+
if (signals[StringPrototypeToUpperCase(signal)] !== void 0) throw new ERR_UNKNOWN_SIGNAL(signal + " (signals must use all capital letters)");
|
|
616
|
+
throw new ERR_UNKNOWN_SIGNAL(signal);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
const validateBuffer = hideStackFrames((buffer, name = "buffer") => {
|
|
620
|
+
if (!isArrayBufferView(buffer)) throw new ERR_INVALID_ARG_TYPE(name, [
|
|
621
|
+
"Buffer",
|
|
622
|
+
"TypedArray",
|
|
623
|
+
"DataView"
|
|
624
|
+
], buffer);
|
|
625
|
+
});
|
|
626
|
+
function validateEncoding(data, encoding) {
|
|
627
|
+
const normalizedEncoding = normalizeEncoding(encoding);
|
|
628
|
+
const length = data.length;
|
|
629
|
+
if (normalizedEncoding === "hex" && length % 2 !== 0) throw new ERR_INVALID_ARG_VALUE("encoding", encoding, `is invalid for data of length ${length}`);
|
|
630
|
+
}
|
|
631
|
+
function validatePort(port, name = "Port", allowZero = true) {
|
|
632
|
+
if (typeof port !== "number" && typeof port !== "string" || typeof port === "string" && StringPrototypeTrim(port).length === 0 || +port !== +port >>> 0 || port > 65535 || port === 0 && !allowZero) throw new ERR_SOCKET_BAD_PORT(name, port, allowZero);
|
|
633
|
+
return port | 0;
|
|
634
|
+
}
|
|
635
|
+
const validateAbortSignal = hideStackFrames((signal, name) => {
|
|
636
|
+
if (signal !== void 0 && (signal === null || typeof signal !== "object" || !("aborted" in signal))) throw new ERR_INVALID_ARG_TYPE(name, "AbortSignal", signal);
|
|
637
|
+
});
|
|
638
|
+
const validateFunction = hideStackFrames((value, name) => {
|
|
639
|
+
if (typeof value !== "function") throw new ERR_INVALID_ARG_TYPE(name, "Function", value);
|
|
640
|
+
});
|
|
641
|
+
const validatePlainFunction = hideStackFrames((value, name) => {
|
|
642
|
+
if (typeof value !== "function" || isAsyncFunction(value)) throw new ERR_INVALID_ARG_TYPE(name, "Function", value);
|
|
643
|
+
});
|
|
644
|
+
const validateUndefined = hideStackFrames((value, name) => {
|
|
645
|
+
if (value !== void 0) throw new ERR_INVALID_ARG_TYPE(name, "undefined", value);
|
|
646
|
+
});
|
|
647
|
+
function validateUnion(value, name, union) {
|
|
648
|
+
if (!ArrayPrototypeIncludes(union, value)) throw new ERR_INVALID_ARG_TYPE(name, `('${ArrayPrototypeJoin(union, "|")}')`, value);
|
|
649
|
+
}
|
|
650
|
+
const linkValueRegExp = /^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;
|
|
651
|
+
function validateLinkHeaderFormat(value, name) {
|
|
652
|
+
if (typeof value === "undefined" || !RegExpPrototypeExec(linkValueRegExp, value)) throw new ERR_INVALID_ARG_VALUE(name, value, "must be an array or string of format \"</styles.css>; rel=preload; as=style\"");
|
|
653
|
+
}
|
|
654
|
+
function validateLinkHeaderValue(hints) {
|
|
655
|
+
if (typeof hints === "string") {
|
|
656
|
+
validateLinkHeaderFormat(hints, "hints");
|
|
657
|
+
return hints;
|
|
658
|
+
} else if (ArrayIsArray(hints)) {
|
|
659
|
+
const hintsLength = hints.length;
|
|
660
|
+
let result = "";
|
|
661
|
+
if (hintsLength === 0) return result;
|
|
662
|
+
for (let i = 0; i < hintsLength; i++) {
|
|
663
|
+
const link = hints[i];
|
|
664
|
+
validateLinkHeaderFormat(link, "hints");
|
|
665
|
+
result += link;
|
|
666
|
+
if (i !== hintsLength - 1) result += ", ";
|
|
667
|
+
}
|
|
668
|
+
return result;
|
|
669
|
+
}
|
|
670
|
+
throw new ERR_INVALID_ARG_VALUE("hints", hints, "must be an array or string of format \"</styles.css>; rel=preload; as=style\"");
|
|
671
|
+
}
|
|
672
|
+
module.exports = {
|
|
673
|
+
isInt32,
|
|
674
|
+
isUint32,
|
|
675
|
+
parseFileMode,
|
|
676
|
+
validateArray,
|
|
677
|
+
validateStringArray,
|
|
678
|
+
validateBooleanArray,
|
|
679
|
+
validateAbortSignalArray,
|
|
680
|
+
validateBoolean,
|
|
681
|
+
validateBuffer,
|
|
682
|
+
validateDictionary,
|
|
683
|
+
validateEncoding,
|
|
684
|
+
validateFunction,
|
|
685
|
+
validateInt32,
|
|
686
|
+
validateInteger,
|
|
687
|
+
validateNumber,
|
|
688
|
+
validateObject,
|
|
689
|
+
validateOneOf,
|
|
690
|
+
validatePlainFunction,
|
|
691
|
+
validatePort,
|
|
692
|
+
validateSignalName,
|
|
693
|
+
validateString,
|
|
694
|
+
validateUint32,
|
|
695
|
+
validateUndefined,
|
|
696
|
+
validateUnion,
|
|
697
|
+
validateAbortSignal,
|
|
698
|
+
validateLinkHeaderValue
|
|
699
|
+
};
|
|
700
|
+
}));
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region \0require-as-import:process
|
|
703
|
+
var require__require_as_import_process = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
704
|
+
module.exports = m$1.default;
|
|
705
|
+
}));
|
|
706
|
+
//#endregion
|
|
707
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/shims/process.js
|
|
708
|
+
var require_process = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
709
|
+
module.exports = ((base, esmKey, keys, isValid) => {
|
|
710
|
+
if (esmKey in base && base[esmKey] === true) {
|
|
711
|
+
let candidate;
|
|
712
|
+
for (const key of keys) {
|
|
713
|
+
if (!(key in base)) continue;
|
|
714
|
+
candidate = base[key];
|
|
715
|
+
if (isValid(candidate)) return candidate;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return base;
|
|
719
|
+
})(require__require_as_import_process(), "__esModule", ["default", "process"], (candidate) => "nextTick" in candidate);
|
|
720
|
+
}));
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/utils.js
|
|
723
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
724
|
+
const { SymbolAsyncIterator, SymbolIterator, SymbolFor } = require_primordials();
|
|
725
|
+
const kIsDestroyed = SymbolFor("nodejs.stream.destroyed");
|
|
726
|
+
const kIsErrored = SymbolFor("nodejs.stream.errored");
|
|
727
|
+
const kIsReadable = SymbolFor("nodejs.stream.readable");
|
|
728
|
+
const kIsWritable = SymbolFor("nodejs.stream.writable");
|
|
729
|
+
const kIsDisturbed = SymbolFor("nodejs.stream.disturbed");
|
|
730
|
+
const kIsClosedPromise = SymbolFor("nodejs.webstream.isClosedPromise");
|
|
731
|
+
const kControllerErrorFunction = SymbolFor("nodejs.webstream.controllerErrorFunction");
|
|
732
|
+
function isReadableNodeStream(obj, strict = false) {
|
|
733
|
+
var _obj$_readableState;
|
|
734
|
+
return !!(obj && typeof obj.pipe === "function" && typeof obj.on === "function" && (!strict || typeof obj.pause === "function" && typeof obj.resume === "function") && (!obj._writableState || ((_obj$_readableState = obj._readableState) === null || _obj$_readableState === void 0 ? void 0 : _obj$_readableState.readable) !== false) && (!obj._writableState || obj._readableState));
|
|
735
|
+
}
|
|
736
|
+
function isWritableNodeStream(obj) {
|
|
737
|
+
var _obj$_writableState;
|
|
738
|
+
return !!(obj && typeof obj.write === "function" && typeof obj.on === "function" && (!obj._readableState || ((_obj$_writableState = obj._writableState) === null || _obj$_writableState === void 0 ? void 0 : _obj$_writableState.writable) !== false));
|
|
739
|
+
}
|
|
740
|
+
function isDuplexNodeStream(obj) {
|
|
741
|
+
return !!(obj && typeof obj.pipe === "function" && obj._readableState && typeof obj.on === "function" && typeof obj.write === "function");
|
|
742
|
+
}
|
|
743
|
+
function isNodeStream(obj) {
|
|
744
|
+
return obj && (obj._readableState || obj._writableState || typeof obj.write === "function" && typeof obj.on === "function" || typeof obj.pipe === "function" && typeof obj.on === "function");
|
|
745
|
+
}
|
|
746
|
+
function isReadableStream(obj) {
|
|
747
|
+
return !!(obj && !isNodeStream(obj) && typeof obj.pipeThrough === "function" && typeof obj.getReader === "function" && typeof obj.cancel === "function");
|
|
748
|
+
}
|
|
749
|
+
function isWritableStream(obj) {
|
|
750
|
+
return !!(obj && !isNodeStream(obj) && typeof obj.getWriter === "function" && typeof obj.abort === "function");
|
|
751
|
+
}
|
|
752
|
+
function isTransformStream(obj) {
|
|
753
|
+
return !!(obj && !isNodeStream(obj) && typeof obj.readable === "object" && typeof obj.writable === "object");
|
|
754
|
+
}
|
|
755
|
+
function isWebStream(obj) {
|
|
756
|
+
return isReadableStream(obj) || isWritableStream(obj) || isTransformStream(obj);
|
|
757
|
+
}
|
|
758
|
+
function isIterable(obj, isAsync) {
|
|
759
|
+
if (obj == null) return false;
|
|
760
|
+
if (isAsync === true) return typeof obj[SymbolAsyncIterator] === "function";
|
|
761
|
+
if (isAsync === false) return typeof obj[SymbolIterator] === "function";
|
|
762
|
+
return typeof obj[SymbolAsyncIterator] === "function" || typeof obj[SymbolIterator] === "function";
|
|
763
|
+
}
|
|
764
|
+
function isDestroyed(stream) {
|
|
765
|
+
if (!isNodeStream(stream)) return null;
|
|
766
|
+
const wState = stream._writableState;
|
|
767
|
+
const rState = stream._readableState;
|
|
768
|
+
const state = wState || rState;
|
|
769
|
+
return !!(stream.destroyed || stream[kIsDestroyed] || state !== null && state !== void 0 && state.destroyed);
|
|
770
|
+
}
|
|
771
|
+
function isWritableEnded(stream) {
|
|
772
|
+
if (!isWritableNodeStream(stream)) return null;
|
|
773
|
+
if (stream.writableEnded === true) return true;
|
|
774
|
+
const wState = stream._writableState;
|
|
775
|
+
if (wState !== null && wState !== void 0 && wState.errored) return false;
|
|
776
|
+
if (typeof (wState === null || wState === void 0 ? void 0 : wState.ended) !== "boolean") return null;
|
|
777
|
+
return wState.ended;
|
|
778
|
+
}
|
|
779
|
+
function isWritableFinished(stream, strict) {
|
|
780
|
+
if (!isWritableNodeStream(stream)) return null;
|
|
781
|
+
if (stream.writableFinished === true) return true;
|
|
782
|
+
const wState = stream._writableState;
|
|
783
|
+
if (wState !== null && wState !== void 0 && wState.errored) return false;
|
|
784
|
+
if (typeof (wState === null || wState === void 0 ? void 0 : wState.finished) !== "boolean") return null;
|
|
785
|
+
return !!(wState.finished || strict === false && wState.ended === true && wState.length === 0);
|
|
786
|
+
}
|
|
787
|
+
function isReadableEnded(stream) {
|
|
788
|
+
if (!isReadableNodeStream(stream)) return null;
|
|
789
|
+
if (stream.readableEnded === true) return true;
|
|
790
|
+
const rState = stream._readableState;
|
|
791
|
+
if (!rState || rState.errored) return false;
|
|
792
|
+
if (typeof (rState === null || rState === void 0 ? void 0 : rState.ended) !== "boolean") return null;
|
|
793
|
+
return rState.ended;
|
|
794
|
+
}
|
|
795
|
+
function isReadableFinished(stream, strict) {
|
|
796
|
+
if (!isReadableNodeStream(stream)) return null;
|
|
797
|
+
const rState = stream._readableState;
|
|
798
|
+
if (rState !== null && rState !== void 0 && rState.errored) return false;
|
|
799
|
+
if (typeof (rState === null || rState === void 0 ? void 0 : rState.endEmitted) !== "boolean") return null;
|
|
800
|
+
return !!(rState.endEmitted || strict === false && rState.ended === true && rState.length === 0);
|
|
801
|
+
}
|
|
802
|
+
function isReadable(stream) {
|
|
803
|
+
if (stream && stream[kIsReadable] != null) return stream[kIsReadable];
|
|
804
|
+
if (typeof (stream === null || stream === void 0 ? void 0 : stream.readable) !== "boolean") return null;
|
|
805
|
+
if (isDestroyed(stream)) return false;
|
|
806
|
+
return isReadableNodeStream(stream) && stream.readable && !isReadableFinished(stream);
|
|
807
|
+
}
|
|
808
|
+
function isWritable(stream) {
|
|
809
|
+
if (stream && stream[kIsWritable] != null) return stream[kIsWritable];
|
|
810
|
+
if (typeof (stream === null || stream === void 0 ? void 0 : stream.writable) !== "boolean") return null;
|
|
811
|
+
if (isDestroyed(stream)) return false;
|
|
812
|
+
return isWritableNodeStream(stream) && stream.writable && !isWritableEnded(stream);
|
|
813
|
+
}
|
|
814
|
+
function isFinished(stream, opts) {
|
|
815
|
+
if (!isNodeStream(stream)) return null;
|
|
816
|
+
if (isDestroyed(stream)) return true;
|
|
817
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.readable) !== false && isReadable(stream)) return false;
|
|
818
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.writable) !== false && isWritable(stream)) return false;
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
821
|
+
function isWritableErrored(stream) {
|
|
822
|
+
var _stream$_writableStat, _stream$_writableStat2;
|
|
823
|
+
if (!isNodeStream(stream)) return null;
|
|
824
|
+
if (stream.writableErrored) return stream.writableErrored;
|
|
825
|
+
return (_stream$_writableStat = (_stream$_writableStat2 = stream._writableState) === null || _stream$_writableStat2 === void 0 ? void 0 : _stream$_writableStat2.errored) !== null && _stream$_writableStat !== void 0 ? _stream$_writableStat : null;
|
|
826
|
+
}
|
|
827
|
+
function isReadableErrored(stream) {
|
|
828
|
+
var _stream$_readableStat, _stream$_readableStat2;
|
|
829
|
+
if (!isNodeStream(stream)) return null;
|
|
830
|
+
if (stream.readableErrored) return stream.readableErrored;
|
|
831
|
+
return (_stream$_readableStat = (_stream$_readableStat2 = stream._readableState) === null || _stream$_readableStat2 === void 0 ? void 0 : _stream$_readableStat2.errored) !== null && _stream$_readableStat !== void 0 ? _stream$_readableStat : null;
|
|
832
|
+
}
|
|
833
|
+
function isClosed(stream) {
|
|
834
|
+
if (!isNodeStream(stream)) return null;
|
|
835
|
+
if (typeof stream.closed === "boolean") return stream.closed;
|
|
836
|
+
const wState = stream._writableState;
|
|
837
|
+
const rState = stream._readableState;
|
|
838
|
+
if (typeof (wState === null || wState === void 0 ? void 0 : wState.closed) === "boolean" || typeof (rState === null || rState === void 0 ? void 0 : rState.closed) === "boolean") return (wState === null || wState === void 0 ? void 0 : wState.closed) || (rState === null || rState === void 0 ? void 0 : rState.closed);
|
|
839
|
+
if (typeof stream._closed === "boolean" && isOutgoingMessage(stream)) return stream._closed;
|
|
840
|
+
return null;
|
|
841
|
+
}
|
|
842
|
+
function isOutgoingMessage(stream) {
|
|
843
|
+
return typeof stream._closed === "boolean" && typeof stream._defaultKeepAlive === "boolean" && typeof stream._removedConnection === "boolean" && typeof stream._removedContLen === "boolean";
|
|
844
|
+
}
|
|
845
|
+
function isServerResponse(stream) {
|
|
846
|
+
return typeof stream._sent100 === "boolean" && isOutgoingMessage(stream);
|
|
847
|
+
}
|
|
848
|
+
function isServerRequest(stream) {
|
|
849
|
+
var _stream$req;
|
|
850
|
+
return typeof stream._consuming === "boolean" && typeof stream._dumped === "boolean" && ((_stream$req = stream.req) === null || _stream$req === void 0 ? void 0 : _stream$req.upgradeOrConnect) === void 0;
|
|
851
|
+
}
|
|
852
|
+
function willEmitClose(stream) {
|
|
853
|
+
if (!isNodeStream(stream)) return null;
|
|
854
|
+
const wState = stream._writableState;
|
|
855
|
+
const rState = stream._readableState;
|
|
856
|
+
const state = wState || rState;
|
|
857
|
+
return !state && isServerResponse(stream) || !!(state && state.autoDestroy && state.emitClose && state.closed === false);
|
|
858
|
+
}
|
|
859
|
+
function isDisturbed(stream) {
|
|
860
|
+
var _stream$kIsDisturbed;
|
|
861
|
+
return !!(stream && ((_stream$kIsDisturbed = stream[kIsDisturbed]) !== null && _stream$kIsDisturbed !== void 0 ? _stream$kIsDisturbed : stream.readableDidRead || stream.readableAborted));
|
|
862
|
+
}
|
|
863
|
+
function isErrored(stream) {
|
|
864
|
+
var _ref, _ref2, _ref3, _ref4, _ref5, _stream$kIsErrored, _stream$_readableStat3, _stream$_writableStat3, _stream$_readableStat4, _stream$_writableStat4;
|
|
865
|
+
return !!(stream && ((_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_stream$kIsErrored = stream[kIsErrored]) !== null && _stream$kIsErrored !== void 0 ? _stream$kIsErrored : stream.readableErrored) !== null && _ref5 !== void 0 ? _ref5 : stream.writableErrored) !== null && _ref4 !== void 0 ? _ref4 : (_stream$_readableStat3 = stream._readableState) === null || _stream$_readableStat3 === void 0 ? void 0 : _stream$_readableStat3.errorEmitted) !== null && _ref3 !== void 0 ? _ref3 : (_stream$_writableStat3 = stream._writableState) === null || _stream$_writableStat3 === void 0 ? void 0 : _stream$_writableStat3.errorEmitted) !== null && _ref2 !== void 0 ? _ref2 : (_stream$_readableStat4 = stream._readableState) === null || _stream$_readableStat4 === void 0 ? void 0 : _stream$_readableStat4.errored) !== null && _ref !== void 0 ? _ref : (_stream$_writableStat4 = stream._writableState) === null || _stream$_writableStat4 === void 0 ? void 0 : _stream$_writableStat4.errored));
|
|
866
|
+
}
|
|
867
|
+
module.exports = {
|
|
868
|
+
isDestroyed,
|
|
869
|
+
kIsDestroyed,
|
|
870
|
+
isDisturbed,
|
|
871
|
+
kIsDisturbed,
|
|
872
|
+
isErrored,
|
|
873
|
+
kIsErrored,
|
|
874
|
+
isReadable,
|
|
875
|
+
kIsReadable,
|
|
876
|
+
kIsClosedPromise,
|
|
877
|
+
kControllerErrorFunction,
|
|
878
|
+
kIsWritable,
|
|
879
|
+
isClosed,
|
|
880
|
+
isDuplexNodeStream,
|
|
881
|
+
isFinished,
|
|
882
|
+
isIterable,
|
|
883
|
+
isReadableNodeStream,
|
|
884
|
+
isReadableStream,
|
|
885
|
+
isReadableEnded,
|
|
886
|
+
isReadableFinished,
|
|
887
|
+
isReadableErrored,
|
|
888
|
+
isNodeStream,
|
|
889
|
+
isWebStream,
|
|
890
|
+
isWritable,
|
|
891
|
+
isWritableNodeStream,
|
|
892
|
+
isWritableStream,
|
|
893
|
+
isWritableEnded,
|
|
894
|
+
isWritableFinished,
|
|
895
|
+
isWritableErrored,
|
|
896
|
+
isServerRequest,
|
|
897
|
+
isServerResponse,
|
|
898
|
+
willEmitClose,
|
|
899
|
+
isTransformStream
|
|
900
|
+
};
|
|
901
|
+
}));
|
|
902
|
+
//#endregion
|
|
903
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/end-of-stream.js
|
|
904
|
+
var require_end_of_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
905
|
+
const process = require_process();
|
|
906
|
+
const { AbortError, codes } = require_errors();
|
|
907
|
+
const { ERR_INVALID_ARG_TYPE, ERR_STREAM_PREMATURE_CLOSE } = codes;
|
|
908
|
+
const { kEmptyObject, once } = require_util();
|
|
909
|
+
const { validateAbortSignal, validateFunction, validateObject, validateBoolean } = require_validators();
|
|
910
|
+
const { Promise, PromisePrototypeThen, SymbolDispose } = require_primordials();
|
|
911
|
+
const { isClosed, isReadable, isReadableNodeStream, isReadableStream, isReadableFinished, isReadableErrored, isWritable, isWritableNodeStream, isWritableStream, isWritableFinished, isWritableErrored, isNodeStream, willEmitClose: _willEmitClose, kIsClosedPromise } = require_utils();
|
|
912
|
+
let addAbortListener;
|
|
913
|
+
function isRequest(stream) {
|
|
914
|
+
return stream.setHeader && typeof stream.abort === "function";
|
|
915
|
+
}
|
|
916
|
+
const nop = () => {};
|
|
917
|
+
function eos(stream, options, callback) {
|
|
918
|
+
var _options$readable, _options$writable;
|
|
919
|
+
if (arguments.length === 2) {
|
|
920
|
+
callback = options;
|
|
921
|
+
options = kEmptyObject;
|
|
922
|
+
} else if (options == null) options = kEmptyObject;
|
|
923
|
+
else validateObject(options, "options");
|
|
924
|
+
validateFunction(callback, "callback");
|
|
925
|
+
validateAbortSignal(options.signal, "options.signal");
|
|
926
|
+
callback = once(callback);
|
|
927
|
+
if (isReadableStream(stream) || isWritableStream(stream)) return eosWeb(stream, options, callback);
|
|
928
|
+
if (!isNodeStream(stream)) throw new ERR_INVALID_ARG_TYPE("stream", [
|
|
929
|
+
"ReadableStream",
|
|
930
|
+
"WritableStream",
|
|
931
|
+
"Stream"
|
|
932
|
+
], stream);
|
|
933
|
+
const readable = (_options$readable = options.readable) !== null && _options$readable !== void 0 ? _options$readable : isReadableNodeStream(stream);
|
|
934
|
+
const writable = (_options$writable = options.writable) !== null && _options$writable !== void 0 ? _options$writable : isWritableNodeStream(stream);
|
|
935
|
+
const wState = stream._writableState;
|
|
936
|
+
const rState = stream._readableState;
|
|
937
|
+
const onlegacyfinish = () => {
|
|
938
|
+
if (!stream.writable) onfinish();
|
|
939
|
+
};
|
|
940
|
+
let willEmitClose = _willEmitClose(stream) && isReadableNodeStream(stream) === readable && isWritableNodeStream(stream) === writable;
|
|
941
|
+
let writableFinished = isWritableFinished(stream, false);
|
|
942
|
+
const onfinish = () => {
|
|
943
|
+
writableFinished = true;
|
|
944
|
+
if (stream.destroyed) willEmitClose = false;
|
|
945
|
+
if (willEmitClose && (!stream.readable || readable)) return;
|
|
946
|
+
if (!readable || readableFinished) callback.call(stream);
|
|
947
|
+
};
|
|
948
|
+
let readableFinished = isReadableFinished(stream, false);
|
|
949
|
+
const onend = () => {
|
|
950
|
+
readableFinished = true;
|
|
951
|
+
if (stream.destroyed) willEmitClose = false;
|
|
952
|
+
if (willEmitClose && (!stream.writable || writable)) return;
|
|
953
|
+
if (!writable || writableFinished) callback.call(stream);
|
|
954
|
+
};
|
|
955
|
+
const onerror = (err) => {
|
|
956
|
+
callback.call(stream, err);
|
|
957
|
+
};
|
|
958
|
+
let closed = isClosed(stream);
|
|
959
|
+
const onclose = () => {
|
|
960
|
+
closed = true;
|
|
961
|
+
const errored = isWritableErrored(stream) || isReadableErrored(stream);
|
|
962
|
+
if (errored && typeof errored !== "boolean") return callback.call(stream, errored);
|
|
963
|
+
if (readable && !readableFinished && isReadableNodeStream(stream, true)) {
|
|
964
|
+
if (!isReadableFinished(stream, false)) return callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE());
|
|
965
|
+
}
|
|
966
|
+
if (writable && !writableFinished) {
|
|
967
|
+
if (!isWritableFinished(stream, false)) return callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE());
|
|
968
|
+
}
|
|
969
|
+
callback.call(stream);
|
|
970
|
+
};
|
|
971
|
+
const onclosed = () => {
|
|
972
|
+
closed = true;
|
|
973
|
+
const errored = isWritableErrored(stream) || isReadableErrored(stream);
|
|
974
|
+
if (errored && typeof errored !== "boolean") return callback.call(stream, errored);
|
|
975
|
+
callback.call(stream);
|
|
976
|
+
};
|
|
977
|
+
const onrequest = () => {
|
|
978
|
+
stream.req.on("finish", onfinish);
|
|
979
|
+
};
|
|
980
|
+
if (isRequest(stream)) {
|
|
981
|
+
stream.on("complete", onfinish);
|
|
982
|
+
if (!willEmitClose) stream.on("abort", onclose);
|
|
983
|
+
if (stream.req) onrequest();
|
|
984
|
+
else stream.on("request", onrequest);
|
|
985
|
+
} else if (writable && !wState) {
|
|
986
|
+
stream.on("end", onlegacyfinish);
|
|
987
|
+
stream.on("close", onlegacyfinish);
|
|
988
|
+
}
|
|
989
|
+
if (!willEmitClose && typeof stream.aborted === "boolean") stream.on("aborted", onclose);
|
|
990
|
+
stream.on("end", onend);
|
|
991
|
+
stream.on("finish", onfinish);
|
|
992
|
+
if (options.error !== false) stream.on("error", onerror);
|
|
993
|
+
stream.on("close", onclose);
|
|
994
|
+
if (closed) process.nextTick(onclose);
|
|
995
|
+
else if (wState !== null && wState !== void 0 && wState.errorEmitted || rState !== null && rState !== void 0 && rState.errorEmitted) {
|
|
996
|
+
if (!willEmitClose) process.nextTick(onclosed);
|
|
997
|
+
} else if (!readable && (!willEmitClose || isReadable(stream)) && (writableFinished || isWritable(stream) === false)) process.nextTick(onclosed);
|
|
998
|
+
else if (!writable && (!willEmitClose || isWritable(stream)) && (readableFinished || isReadable(stream) === false)) process.nextTick(onclosed);
|
|
999
|
+
else if (rState && stream.req && stream.aborted) process.nextTick(onclosed);
|
|
1000
|
+
const cleanup = () => {
|
|
1001
|
+
callback = nop;
|
|
1002
|
+
stream.removeListener("aborted", onclose);
|
|
1003
|
+
stream.removeListener("complete", onfinish);
|
|
1004
|
+
stream.removeListener("abort", onclose);
|
|
1005
|
+
stream.removeListener("request", onrequest);
|
|
1006
|
+
if (stream.req) stream.req.removeListener("finish", onfinish);
|
|
1007
|
+
stream.removeListener("end", onlegacyfinish);
|
|
1008
|
+
stream.removeListener("close", onlegacyfinish);
|
|
1009
|
+
stream.removeListener("finish", onfinish);
|
|
1010
|
+
stream.removeListener("end", onend);
|
|
1011
|
+
stream.removeListener("error", onerror);
|
|
1012
|
+
stream.removeListener("close", onclose);
|
|
1013
|
+
};
|
|
1014
|
+
if (options.signal && !closed) {
|
|
1015
|
+
const abort = () => {
|
|
1016
|
+
const endCallback = callback;
|
|
1017
|
+
cleanup();
|
|
1018
|
+
endCallback.call(stream, new AbortError(void 0, { cause: options.signal.reason }));
|
|
1019
|
+
};
|
|
1020
|
+
if (options.signal.aborted) process.nextTick(abort);
|
|
1021
|
+
else {
|
|
1022
|
+
addAbortListener = addAbortListener || require_util().addAbortListener;
|
|
1023
|
+
const disposable = addAbortListener(options.signal, abort);
|
|
1024
|
+
const originalCallback = callback;
|
|
1025
|
+
callback = once((...args) => {
|
|
1026
|
+
disposable[SymbolDispose]();
|
|
1027
|
+
originalCallback.apply(stream, args);
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return cleanup;
|
|
1032
|
+
}
|
|
1033
|
+
function eosWeb(stream, options, callback) {
|
|
1034
|
+
let isAborted = false;
|
|
1035
|
+
let abort = nop;
|
|
1036
|
+
if (options.signal) {
|
|
1037
|
+
abort = () => {
|
|
1038
|
+
isAborted = true;
|
|
1039
|
+
callback.call(stream, new AbortError(void 0, { cause: options.signal.reason }));
|
|
1040
|
+
};
|
|
1041
|
+
if (options.signal.aborted) process.nextTick(abort);
|
|
1042
|
+
else {
|
|
1043
|
+
addAbortListener = addAbortListener || require_util().addAbortListener;
|
|
1044
|
+
const disposable = addAbortListener(options.signal, abort);
|
|
1045
|
+
const originalCallback = callback;
|
|
1046
|
+
callback = once((...args) => {
|
|
1047
|
+
disposable[SymbolDispose]();
|
|
1048
|
+
originalCallback.apply(stream, args);
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
const resolverFn = (...args) => {
|
|
1053
|
+
if (!isAborted) process.nextTick(() => callback.apply(stream, args));
|
|
1054
|
+
};
|
|
1055
|
+
PromisePrototypeThen(stream[kIsClosedPromise].promise, resolverFn, resolverFn);
|
|
1056
|
+
return nop;
|
|
1057
|
+
}
|
|
1058
|
+
function finished(stream, opts) {
|
|
1059
|
+
var _opts;
|
|
1060
|
+
let autoCleanup = false;
|
|
1061
|
+
if (opts === null) opts = kEmptyObject;
|
|
1062
|
+
if ((_opts = opts) !== null && _opts !== void 0 && _opts.cleanup) {
|
|
1063
|
+
validateBoolean(opts.cleanup, "cleanup");
|
|
1064
|
+
autoCleanup = opts.cleanup;
|
|
1065
|
+
}
|
|
1066
|
+
return new Promise((resolve, reject) => {
|
|
1067
|
+
const cleanup = eos(stream, opts, (err) => {
|
|
1068
|
+
if (autoCleanup) cleanup();
|
|
1069
|
+
if (err) reject(err);
|
|
1070
|
+
else resolve();
|
|
1071
|
+
});
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
module.exports = eos;
|
|
1075
|
+
module.exports.finished = finished;
|
|
1076
|
+
}));
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/destroy.js
|
|
1079
|
+
var require_destroy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1080
|
+
const process = require_process();
|
|
1081
|
+
const { aggregateTwoErrors, codes: { ERR_MULTIPLE_CALLBACK }, AbortError } = require_errors();
|
|
1082
|
+
const { Symbol } = require_primordials();
|
|
1083
|
+
const { kIsDestroyed, isDestroyed, isFinished, isServerRequest } = require_utils();
|
|
1084
|
+
const kDestroy = Symbol("kDestroy");
|
|
1085
|
+
const kConstruct = Symbol("kConstruct");
|
|
1086
|
+
function checkError(err, w, r) {
|
|
1087
|
+
if (err) {
|
|
1088
|
+
err.stack;
|
|
1089
|
+
if (w && !w.errored) w.errored = err;
|
|
1090
|
+
if (r && !r.errored) r.errored = err;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
function destroy(err, cb) {
|
|
1094
|
+
const r = this._readableState;
|
|
1095
|
+
const w = this._writableState;
|
|
1096
|
+
const s = w || r;
|
|
1097
|
+
if (w !== null && w !== void 0 && w.destroyed || r !== null && r !== void 0 && r.destroyed) {
|
|
1098
|
+
if (typeof cb === "function") cb();
|
|
1099
|
+
return this;
|
|
1100
|
+
}
|
|
1101
|
+
checkError(err, w, r);
|
|
1102
|
+
if (w) w.destroyed = true;
|
|
1103
|
+
if (r) r.destroyed = true;
|
|
1104
|
+
if (!s.constructed) this.once(kDestroy, function(er) {
|
|
1105
|
+
_destroy(this, aggregateTwoErrors(er, err), cb);
|
|
1106
|
+
});
|
|
1107
|
+
else _destroy(this, err, cb);
|
|
1108
|
+
return this;
|
|
1109
|
+
}
|
|
1110
|
+
function _destroy(self, err, cb) {
|
|
1111
|
+
let called = false;
|
|
1112
|
+
function onDestroy(err) {
|
|
1113
|
+
if (called) return;
|
|
1114
|
+
called = true;
|
|
1115
|
+
const r = self._readableState;
|
|
1116
|
+
const w = self._writableState;
|
|
1117
|
+
checkError(err, w, r);
|
|
1118
|
+
if (w) w.closed = true;
|
|
1119
|
+
if (r) r.closed = true;
|
|
1120
|
+
if (typeof cb === "function") cb(err);
|
|
1121
|
+
if (err) process.nextTick(emitErrorCloseNT, self, err);
|
|
1122
|
+
else process.nextTick(emitCloseNT, self);
|
|
1123
|
+
}
|
|
1124
|
+
try {
|
|
1125
|
+
self._destroy(err || null, onDestroy);
|
|
1126
|
+
} catch (err) {
|
|
1127
|
+
onDestroy(err);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
function emitErrorCloseNT(self, err) {
|
|
1131
|
+
emitErrorNT(self, err);
|
|
1132
|
+
emitCloseNT(self);
|
|
1133
|
+
}
|
|
1134
|
+
function emitCloseNT(self) {
|
|
1135
|
+
const r = self._readableState;
|
|
1136
|
+
const w = self._writableState;
|
|
1137
|
+
if (w) w.closeEmitted = true;
|
|
1138
|
+
if (r) r.closeEmitted = true;
|
|
1139
|
+
if (w !== null && w !== void 0 && w.emitClose || r !== null && r !== void 0 && r.emitClose) self.emit("close");
|
|
1140
|
+
}
|
|
1141
|
+
function emitErrorNT(self, err) {
|
|
1142
|
+
const r = self._readableState;
|
|
1143
|
+
const w = self._writableState;
|
|
1144
|
+
if (w !== null && w !== void 0 && w.errorEmitted || r !== null && r !== void 0 && r.errorEmitted) return;
|
|
1145
|
+
if (w) w.errorEmitted = true;
|
|
1146
|
+
if (r) r.errorEmitted = true;
|
|
1147
|
+
self.emit("error", err);
|
|
1148
|
+
}
|
|
1149
|
+
function undestroy() {
|
|
1150
|
+
const r = this._readableState;
|
|
1151
|
+
const w = this._writableState;
|
|
1152
|
+
if (r) {
|
|
1153
|
+
r.constructed = true;
|
|
1154
|
+
r.closed = false;
|
|
1155
|
+
r.closeEmitted = false;
|
|
1156
|
+
r.destroyed = false;
|
|
1157
|
+
r.errored = null;
|
|
1158
|
+
r.errorEmitted = false;
|
|
1159
|
+
r.reading = false;
|
|
1160
|
+
r.ended = r.readable === false;
|
|
1161
|
+
r.endEmitted = r.readable === false;
|
|
1162
|
+
}
|
|
1163
|
+
if (w) {
|
|
1164
|
+
w.constructed = true;
|
|
1165
|
+
w.destroyed = false;
|
|
1166
|
+
w.closed = false;
|
|
1167
|
+
w.closeEmitted = false;
|
|
1168
|
+
w.errored = null;
|
|
1169
|
+
w.errorEmitted = false;
|
|
1170
|
+
w.finalCalled = false;
|
|
1171
|
+
w.prefinished = false;
|
|
1172
|
+
w.ended = w.writable === false;
|
|
1173
|
+
w.ending = w.writable === false;
|
|
1174
|
+
w.finished = w.writable === false;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
function errorOrDestroy(stream, err, sync) {
|
|
1178
|
+
const r = stream._readableState;
|
|
1179
|
+
const w = stream._writableState;
|
|
1180
|
+
if (w !== null && w !== void 0 && w.destroyed || r !== null && r !== void 0 && r.destroyed) return this;
|
|
1181
|
+
if (r !== null && r !== void 0 && r.autoDestroy || w !== null && w !== void 0 && w.autoDestroy) stream.destroy(err);
|
|
1182
|
+
else if (err) {
|
|
1183
|
+
err.stack;
|
|
1184
|
+
if (w && !w.errored) w.errored = err;
|
|
1185
|
+
if (r && !r.errored) r.errored = err;
|
|
1186
|
+
if (sync) process.nextTick(emitErrorNT, stream, err);
|
|
1187
|
+
else emitErrorNT(stream, err);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
function construct(stream, cb) {
|
|
1191
|
+
if (typeof stream._construct !== "function") return;
|
|
1192
|
+
const r = stream._readableState;
|
|
1193
|
+
const w = stream._writableState;
|
|
1194
|
+
if (r) r.constructed = false;
|
|
1195
|
+
if (w) w.constructed = false;
|
|
1196
|
+
stream.once(kConstruct, cb);
|
|
1197
|
+
if (stream.listenerCount(kConstruct) > 1) return;
|
|
1198
|
+
process.nextTick(constructNT, stream);
|
|
1199
|
+
}
|
|
1200
|
+
function constructNT(stream) {
|
|
1201
|
+
let called = false;
|
|
1202
|
+
function onConstruct(err) {
|
|
1203
|
+
if (called) {
|
|
1204
|
+
errorOrDestroy(stream, err !== null && err !== void 0 ? err : new ERR_MULTIPLE_CALLBACK());
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
called = true;
|
|
1208
|
+
const r = stream._readableState;
|
|
1209
|
+
const w = stream._writableState;
|
|
1210
|
+
const s = w || r;
|
|
1211
|
+
if (r) r.constructed = true;
|
|
1212
|
+
if (w) w.constructed = true;
|
|
1213
|
+
if (s.destroyed) stream.emit(kDestroy, err);
|
|
1214
|
+
else if (err) errorOrDestroy(stream, err, true);
|
|
1215
|
+
else process.nextTick(emitConstructNT, stream);
|
|
1216
|
+
}
|
|
1217
|
+
try {
|
|
1218
|
+
stream._construct((err) => {
|
|
1219
|
+
process.nextTick(onConstruct, err);
|
|
1220
|
+
});
|
|
1221
|
+
} catch (err) {
|
|
1222
|
+
process.nextTick(onConstruct, err);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
function emitConstructNT(stream) {
|
|
1226
|
+
stream.emit(kConstruct);
|
|
1227
|
+
}
|
|
1228
|
+
function isRequest(stream) {
|
|
1229
|
+
return (stream === null || stream === void 0 ? void 0 : stream.setHeader) && typeof stream.abort === "function";
|
|
1230
|
+
}
|
|
1231
|
+
function emitCloseLegacy(stream) {
|
|
1232
|
+
stream.emit("close");
|
|
1233
|
+
}
|
|
1234
|
+
function emitErrorCloseLegacy(stream, err) {
|
|
1235
|
+
stream.emit("error", err);
|
|
1236
|
+
process.nextTick(emitCloseLegacy, stream);
|
|
1237
|
+
}
|
|
1238
|
+
function destroyer(stream, err) {
|
|
1239
|
+
if (!stream || isDestroyed(stream)) return;
|
|
1240
|
+
if (!err && !isFinished(stream)) err = new AbortError();
|
|
1241
|
+
if (isServerRequest(stream)) {
|
|
1242
|
+
stream.socket = null;
|
|
1243
|
+
stream.destroy(err);
|
|
1244
|
+
} else if (isRequest(stream)) stream.abort();
|
|
1245
|
+
else if (isRequest(stream.req)) stream.req.abort();
|
|
1246
|
+
else if (typeof stream.destroy === "function") stream.destroy(err);
|
|
1247
|
+
else if (typeof stream.close === "function") stream.close();
|
|
1248
|
+
else if (err) process.nextTick(emitErrorCloseLegacy, stream, err);
|
|
1249
|
+
else process.nextTick(emitCloseLegacy, stream);
|
|
1250
|
+
if (!stream.destroyed) stream[kIsDestroyed] = true;
|
|
1251
|
+
}
|
|
1252
|
+
module.exports = {
|
|
1253
|
+
construct,
|
|
1254
|
+
destroyer,
|
|
1255
|
+
destroy,
|
|
1256
|
+
undestroy,
|
|
1257
|
+
errorOrDestroy
|
|
1258
|
+
};
|
|
1259
|
+
}));
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/legacy.js
|
|
1262
|
+
var require_legacy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1263
|
+
const { ArrayIsArray, ObjectSetPrototypeOf } = require_primordials();
|
|
1264
|
+
const { EventEmitter: EE } = require__require_as_import_events();
|
|
1265
|
+
function Stream(opts) {
|
|
1266
|
+
EE.call(this, opts);
|
|
1267
|
+
}
|
|
1268
|
+
ObjectSetPrototypeOf(Stream.prototype, EE.prototype);
|
|
1269
|
+
ObjectSetPrototypeOf(Stream, EE);
|
|
1270
|
+
Stream.prototype.pipe = function(dest, options) {
|
|
1271
|
+
const source = this;
|
|
1272
|
+
function ondata(chunk) {
|
|
1273
|
+
if (dest.writable && dest.write(chunk) === false && source.pause) source.pause();
|
|
1274
|
+
}
|
|
1275
|
+
source.on("data", ondata);
|
|
1276
|
+
function ondrain() {
|
|
1277
|
+
if (source.readable && source.resume) source.resume();
|
|
1278
|
+
}
|
|
1279
|
+
dest.on("drain", ondrain);
|
|
1280
|
+
if (!dest._isStdio && (!options || options.end !== false)) {
|
|
1281
|
+
source.on("end", onend);
|
|
1282
|
+
source.on("close", onclose);
|
|
1283
|
+
}
|
|
1284
|
+
let didOnEnd = false;
|
|
1285
|
+
function onend() {
|
|
1286
|
+
if (didOnEnd) return;
|
|
1287
|
+
didOnEnd = true;
|
|
1288
|
+
dest.end();
|
|
1289
|
+
}
|
|
1290
|
+
function onclose() {
|
|
1291
|
+
if (didOnEnd) return;
|
|
1292
|
+
didOnEnd = true;
|
|
1293
|
+
if (typeof dest.destroy === "function") dest.destroy();
|
|
1294
|
+
}
|
|
1295
|
+
function onerror(er) {
|
|
1296
|
+
var _this$listenerCount;
|
|
1297
|
+
cleanup();
|
|
1298
|
+
if (((_this$listenerCount = this.listenerCount) === null || _this$listenerCount === void 0 ? void 0 : _this$listenerCount.call(this, "error")) === 0) this.emit("error", er);
|
|
1299
|
+
}
|
|
1300
|
+
prependListener(source, "error", onerror);
|
|
1301
|
+
prependListener(dest, "error", onerror);
|
|
1302
|
+
function cleanup() {
|
|
1303
|
+
source.removeListener("data", ondata);
|
|
1304
|
+
dest.removeListener("drain", ondrain);
|
|
1305
|
+
source.removeListener("end", onend);
|
|
1306
|
+
source.removeListener("close", onclose);
|
|
1307
|
+
source.removeListener("error", onerror);
|
|
1308
|
+
dest.removeListener("error", onerror);
|
|
1309
|
+
source.removeListener("end", cleanup);
|
|
1310
|
+
source.removeListener("close", cleanup);
|
|
1311
|
+
dest.removeListener("close", cleanup);
|
|
1312
|
+
}
|
|
1313
|
+
source.on("end", cleanup);
|
|
1314
|
+
source.on("close", cleanup);
|
|
1315
|
+
dest.on("close", cleanup);
|
|
1316
|
+
dest.emit("pipe", source);
|
|
1317
|
+
return dest;
|
|
1318
|
+
};
|
|
1319
|
+
function prependListener(emitter, event, fn) {
|
|
1320
|
+
if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
|
|
1321
|
+
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
|
|
1322
|
+
else if (ArrayIsArray(emitter._events[event])) emitter._events[event].unshift(fn);
|
|
1323
|
+
else emitter._events[event] = [fn, emitter._events[event]];
|
|
1324
|
+
}
|
|
1325
|
+
module.exports = {
|
|
1326
|
+
Stream,
|
|
1327
|
+
prependListener
|
|
1328
|
+
};
|
|
1329
|
+
}));
|
|
1330
|
+
//#endregion
|
|
1331
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js
|
|
1332
|
+
var require_add_abort_signal = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1333
|
+
const { SymbolDispose } = require_primordials();
|
|
1334
|
+
const { AbortError, codes } = require_errors();
|
|
1335
|
+
const { isNodeStream, isWebStream, kControllerErrorFunction } = require_utils();
|
|
1336
|
+
const eos = require_end_of_stream();
|
|
1337
|
+
const { ERR_INVALID_ARG_TYPE } = codes;
|
|
1338
|
+
let addAbortListener;
|
|
1339
|
+
const validateAbortSignal = (signal, name) => {
|
|
1340
|
+
if (typeof signal !== "object" || !("aborted" in signal)) throw new ERR_INVALID_ARG_TYPE(name, "AbortSignal", signal);
|
|
1341
|
+
};
|
|
1342
|
+
module.exports.addAbortSignal = function addAbortSignal(signal, stream) {
|
|
1343
|
+
validateAbortSignal(signal, "signal");
|
|
1344
|
+
if (!isNodeStream(stream) && !isWebStream(stream)) throw new ERR_INVALID_ARG_TYPE("stream", [
|
|
1345
|
+
"ReadableStream",
|
|
1346
|
+
"WritableStream",
|
|
1347
|
+
"Stream"
|
|
1348
|
+
], stream);
|
|
1349
|
+
return module.exports.addAbortSignalNoValidate(signal, stream);
|
|
1350
|
+
};
|
|
1351
|
+
module.exports.addAbortSignalNoValidate = function(signal, stream) {
|
|
1352
|
+
if (typeof signal !== "object" || !("aborted" in signal)) return stream;
|
|
1353
|
+
const onAbort = isNodeStream(stream) ? () => {
|
|
1354
|
+
stream.destroy(new AbortError(void 0, { cause: signal.reason }));
|
|
1355
|
+
} : () => {
|
|
1356
|
+
stream[kControllerErrorFunction](new AbortError(void 0, { cause: signal.reason }));
|
|
1357
|
+
};
|
|
1358
|
+
if (signal.aborted) onAbort();
|
|
1359
|
+
else {
|
|
1360
|
+
addAbortListener = addAbortListener || require_util().addAbortListener;
|
|
1361
|
+
const disposable = addAbortListener(signal, onAbort);
|
|
1362
|
+
eos(stream, disposable[SymbolDispose]);
|
|
1363
|
+
}
|
|
1364
|
+
return stream;
|
|
1365
|
+
};
|
|
1366
|
+
}));
|
|
1367
|
+
//#endregion
|
|
1368
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/buffer_list.js
|
|
1369
|
+
var require_buffer_list = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1370
|
+
const { StringPrototypeSlice, SymbolIterator, TypedArrayPrototypeSet, Uint8Array } = require_primordials();
|
|
1371
|
+
const { Buffer } = require__require_as_import_buffer();
|
|
1372
|
+
const { inspect } = require_util();
|
|
1373
|
+
module.exports = class BufferList {
|
|
1374
|
+
constructor() {
|
|
1375
|
+
this.head = null;
|
|
1376
|
+
this.tail = null;
|
|
1377
|
+
this.length = 0;
|
|
1378
|
+
}
|
|
1379
|
+
push(v) {
|
|
1380
|
+
const entry = {
|
|
1381
|
+
data: v,
|
|
1382
|
+
next: null
|
|
1383
|
+
};
|
|
1384
|
+
if (this.length > 0) this.tail.next = entry;
|
|
1385
|
+
else this.head = entry;
|
|
1386
|
+
this.tail = entry;
|
|
1387
|
+
++this.length;
|
|
1388
|
+
}
|
|
1389
|
+
unshift(v) {
|
|
1390
|
+
const entry = {
|
|
1391
|
+
data: v,
|
|
1392
|
+
next: this.head
|
|
1393
|
+
};
|
|
1394
|
+
if (this.length === 0) this.tail = entry;
|
|
1395
|
+
this.head = entry;
|
|
1396
|
+
++this.length;
|
|
1397
|
+
}
|
|
1398
|
+
shift() {
|
|
1399
|
+
if (this.length === 0) return;
|
|
1400
|
+
const ret = this.head.data;
|
|
1401
|
+
if (this.length === 1) this.head = this.tail = null;
|
|
1402
|
+
else this.head = this.head.next;
|
|
1403
|
+
--this.length;
|
|
1404
|
+
return ret;
|
|
1405
|
+
}
|
|
1406
|
+
clear() {
|
|
1407
|
+
this.head = this.tail = null;
|
|
1408
|
+
this.length = 0;
|
|
1409
|
+
}
|
|
1410
|
+
join(s) {
|
|
1411
|
+
if (this.length === 0) return "";
|
|
1412
|
+
let p = this.head;
|
|
1413
|
+
let ret = "" + p.data;
|
|
1414
|
+
while ((p = p.next) !== null) ret += s + p.data;
|
|
1415
|
+
return ret;
|
|
1416
|
+
}
|
|
1417
|
+
concat(n) {
|
|
1418
|
+
if (this.length === 0) return Buffer.alloc(0);
|
|
1419
|
+
const ret = Buffer.allocUnsafe(n >>> 0);
|
|
1420
|
+
let p = this.head;
|
|
1421
|
+
let i = 0;
|
|
1422
|
+
while (p) {
|
|
1423
|
+
TypedArrayPrototypeSet(ret, p.data, i);
|
|
1424
|
+
i += p.data.length;
|
|
1425
|
+
p = p.next;
|
|
1426
|
+
}
|
|
1427
|
+
return ret;
|
|
1428
|
+
}
|
|
1429
|
+
consume(n, hasStrings) {
|
|
1430
|
+
const data = this.head.data;
|
|
1431
|
+
if (n < data.length) {
|
|
1432
|
+
const slice = data.slice(0, n);
|
|
1433
|
+
this.head.data = data.slice(n);
|
|
1434
|
+
return slice;
|
|
1435
|
+
}
|
|
1436
|
+
if (n === data.length) return this.shift();
|
|
1437
|
+
return hasStrings ? this._getString(n) : this._getBuffer(n);
|
|
1438
|
+
}
|
|
1439
|
+
first() {
|
|
1440
|
+
return this.head.data;
|
|
1441
|
+
}
|
|
1442
|
+
*[SymbolIterator]() {
|
|
1443
|
+
for (let p = this.head; p; p = p.next) yield p.data;
|
|
1444
|
+
}
|
|
1445
|
+
_getString(n) {
|
|
1446
|
+
let ret = "";
|
|
1447
|
+
let p = this.head;
|
|
1448
|
+
let c = 0;
|
|
1449
|
+
do {
|
|
1450
|
+
const str = p.data;
|
|
1451
|
+
if (n > str.length) {
|
|
1452
|
+
ret += str;
|
|
1453
|
+
n -= str.length;
|
|
1454
|
+
} else {
|
|
1455
|
+
if (n === str.length) {
|
|
1456
|
+
ret += str;
|
|
1457
|
+
++c;
|
|
1458
|
+
if (p.next) this.head = p.next;
|
|
1459
|
+
else this.head = this.tail = null;
|
|
1460
|
+
} else {
|
|
1461
|
+
ret += StringPrototypeSlice(str, 0, n);
|
|
1462
|
+
this.head = p;
|
|
1463
|
+
p.data = StringPrototypeSlice(str, n);
|
|
1464
|
+
}
|
|
1465
|
+
break;
|
|
1466
|
+
}
|
|
1467
|
+
++c;
|
|
1468
|
+
} while ((p = p.next) !== null);
|
|
1469
|
+
this.length -= c;
|
|
1470
|
+
return ret;
|
|
1471
|
+
}
|
|
1472
|
+
_getBuffer(n) {
|
|
1473
|
+
const ret = Buffer.allocUnsafe(n);
|
|
1474
|
+
const retLen = n;
|
|
1475
|
+
let p = this.head;
|
|
1476
|
+
let c = 0;
|
|
1477
|
+
do {
|
|
1478
|
+
const buf = p.data;
|
|
1479
|
+
if (n > buf.length) {
|
|
1480
|
+
TypedArrayPrototypeSet(ret, buf, retLen - n);
|
|
1481
|
+
n -= buf.length;
|
|
1482
|
+
} else {
|
|
1483
|
+
if (n === buf.length) {
|
|
1484
|
+
TypedArrayPrototypeSet(ret, buf, retLen - n);
|
|
1485
|
+
++c;
|
|
1486
|
+
if (p.next) this.head = p.next;
|
|
1487
|
+
else this.head = this.tail = null;
|
|
1488
|
+
} else {
|
|
1489
|
+
TypedArrayPrototypeSet(ret, new Uint8Array(buf.buffer, buf.byteOffset, n), retLen - n);
|
|
1490
|
+
this.head = p;
|
|
1491
|
+
p.data = buf.slice(n);
|
|
1492
|
+
}
|
|
1493
|
+
break;
|
|
1494
|
+
}
|
|
1495
|
+
++c;
|
|
1496
|
+
} while ((p = p.next) !== null);
|
|
1497
|
+
this.length -= c;
|
|
1498
|
+
return ret;
|
|
1499
|
+
}
|
|
1500
|
+
[Symbol.for("nodejs.util.inspect.custom")](_, options) {
|
|
1501
|
+
return inspect(this, {
|
|
1502
|
+
...options,
|
|
1503
|
+
depth: 0,
|
|
1504
|
+
customInspect: false
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
}));
|
|
1509
|
+
//#endregion
|
|
1510
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/state.js
|
|
1511
|
+
var require_state = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1512
|
+
const { MathFloor, NumberIsInteger } = require_primordials();
|
|
1513
|
+
const { validateInteger } = require_validators();
|
|
1514
|
+
const { ERR_INVALID_ARG_VALUE } = require_errors().codes;
|
|
1515
|
+
let defaultHighWaterMarkBytes = 16384;
|
|
1516
|
+
let defaultHighWaterMarkObjectMode = 16;
|
|
1517
|
+
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
|
1518
|
+
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
|
1519
|
+
}
|
|
1520
|
+
function getDefaultHighWaterMark(objectMode) {
|
|
1521
|
+
return objectMode ? defaultHighWaterMarkObjectMode : defaultHighWaterMarkBytes;
|
|
1522
|
+
}
|
|
1523
|
+
function setDefaultHighWaterMark(objectMode, value) {
|
|
1524
|
+
validateInteger(value, "value", 0);
|
|
1525
|
+
if (objectMode) defaultHighWaterMarkObjectMode = value;
|
|
1526
|
+
else defaultHighWaterMarkBytes = value;
|
|
1527
|
+
}
|
|
1528
|
+
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
|
1529
|
+
const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
|
1530
|
+
if (hwm != null) {
|
|
1531
|
+
if (!NumberIsInteger(hwm) || hwm < 0) {
|
|
1532
|
+
const name = isDuplex ? `options.${duplexKey}` : "options.highWaterMark";
|
|
1533
|
+
throw new ERR_INVALID_ARG_VALUE(name, hwm);
|
|
1534
|
+
}
|
|
1535
|
+
return MathFloor(hwm);
|
|
1536
|
+
}
|
|
1537
|
+
return getDefaultHighWaterMark(state.objectMode);
|
|
1538
|
+
}
|
|
1539
|
+
module.exports = {
|
|
1540
|
+
getHighWaterMark,
|
|
1541
|
+
getDefaultHighWaterMark,
|
|
1542
|
+
setDefaultHighWaterMark
|
|
1543
|
+
};
|
|
1544
|
+
}));
|
|
1545
|
+
//#endregion
|
|
1546
|
+
//#region \0require-as-import:string_decoder
|
|
1547
|
+
var require__require_as_import_string_decoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1548
|
+
module.exports = m.default;
|
|
1549
|
+
}));
|
|
1550
|
+
//#endregion
|
|
1551
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/from.js
|
|
1552
|
+
var require_from = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1553
|
+
const process = require_process();
|
|
1554
|
+
const { PromisePrototypeThen, SymbolAsyncIterator, SymbolIterator } = require_primordials();
|
|
1555
|
+
const { Buffer } = require__require_as_import_buffer();
|
|
1556
|
+
const { ERR_INVALID_ARG_TYPE, ERR_STREAM_NULL_VALUES } = require_errors().codes;
|
|
1557
|
+
function from(Readable, iterable, opts) {
|
|
1558
|
+
let iterator;
|
|
1559
|
+
if (typeof iterable === "string" || iterable instanceof Buffer) return new Readable({
|
|
1560
|
+
objectMode: true,
|
|
1561
|
+
...opts,
|
|
1562
|
+
read() {
|
|
1563
|
+
this.push(iterable);
|
|
1564
|
+
this.push(null);
|
|
1565
|
+
}
|
|
1566
|
+
});
|
|
1567
|
+
let isAsync;
|
|
1568
|
+
if (iterable && iterable[SymbolAsyncIterator]) {
|
|
1569
|
+
isAsync = true;
|
|
1570
|
+
iterator = iterable[SymbolAsyncIterator]();
|
|
1571
|
+
} else if (iterable && iterable[SymbolIterator]) {
|
|
1572
|
+
isAsync = false;
|
|
1573
|
+
iterator = iterable[SymbolIterator]();
|
|
1574
|
+
} else throw new ERR_INVALID_ARG_TYPE("iterable", ["Iterable"], iterable);
|
|
1575
|
+
const readable = new Readable({
|
|
1576
|
+
objectMode: true,
|
|
1577
|
+
highWaterMark: 1,
|
|
1578
|
+
...opts
|
|
1579
|
+
});
|
|
1580
|
+
let reading = false;
|
|
1581
|
+
readable._read = function() {
|
|
1582
|
+
if (!reading) {
|
|
1583
|
+
reading = true;
|
|
1584
|
+
next();
|
|
1585
|
+
}
|
|
1586
|
+
};
|
|
1587
|
+
readable._destroy = function(error, cb) {
|
|
1588
|
+
PromisePrototypeThen(close(error), () => process.nextTick(cb, error), (e) => process.nextTick(cb, e || error));
|
|
1589
|
+
};
|
|
1590
|
+
async function close(error) {
|
|
1591
|
+
const hadError = error !== void 0 && error !== null;
|
|
1592
|
+
const hasThrow = typeof iterator.throw === "function";
|
|
1593
|
+
if (hadError && hasThrow) {
|
|
1594
|
+
const { value, done } = await iterator.throw(error);
|
|
1595
|
+
await value;
|
|
1596
|
+
if (done) return;
|
|
1597
|
+
}
|
|
1598
|
+
if (typeof iterator.return === "function") {
|
|
1599
|
+
const { value } = await iterator.return();
|
|
1600
|
+
await value;
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
async function next() {
|
|
1604
|
+
for (;;) {
|
|
1605
|
+
try {
|
|
1606
|
+
const { value, done } = isAsync ? await iterator.next() : iterator.next();
|
|
1607
|
+
if (done) readable.push(null);
|
|
1608
|
+
else {
|
|
1609
|
+
const res = value && typeof value.then === "function" ? await value : value;
|
|
1610
|
+
if (res === null) {
|
|
1611
|
+
reading = false;
|
|
1612
|
+
throw new ERR_STREAM_NULL_VALUES();
|
|
1613
|
+
} else if (readable.push(res)) continue;
|
|
1614
|
+
else reading = false;
|
|
1615
|
+
}
|
|
1616
|
+
} catch (err) {
|
|
1617
|
+
readable.destroy(err);
|
|
1618
|
+
}
|
|
1619
|
+
break;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
return readable;
|
|
1623
|
+
}
|
|
1624
|
+
module.exports = from;
|
|
1625
|
+
}));
|
|
1626
|
+
//#endregion
|
|
1627
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/readable.js
|
|
1628
|
+
var require_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1629
|
+
const process = require_process();
|
|
1630
|
+
const { ArrayPrototypeIndexOf, NumberIsInteger, NumberIsNaN, NumberParseInt, ObjectDefineProperties, ObjectKeys, ObjectSetPrototypeOf, Promise, SafeSet, SymbolAsyncDispose, SymbolAsyncIterator, Symbol } = require_primordials();
|
|
1631
|
+
module.exports = Readable;
|
|
1632
|
+
Readable.ReadableState = ReadableState;
|
|
1633
|
+
const { EventEmitter: EE } = require__require_as_import_events();
|
|
1634
|
+
const { Stream, prependListener } = require_legacy();
|
|
1635
|
+
const { Buffer } = require__require_as_import_buffer();
|
|
1636
|
+
const { addAbortSignal } = require_add_abort_signal();
|
|
1637
|
+
const eos = require_end_of_stream();
|
|
1638
|
+
let debug = require_util().debuglog("stream", (fn) => {
|
|
1639
|
+
debug = fn;
|
|
1640
|
+
});
|
|
1641
|
+
const BufferList = require_buffer_list();
|
|
1642
|
+
const destroyImpl = require_destroy();
|
|
1643
|
+
const { getHighWaterMark, getDefaultHighWaterMark } = require_state();
|
|
1644
|
+
const { aggregateTwoErrors, codes: { ERR_INVALID_ARG_TYPE, ERR_METHOD_NOT_IMPLEMENTED, ERR_OUT_OF_RANGE, ERR_STREAM_PUSH_AFTER_EOF, ERR_STREAM_UNSHIFT_AFTER_END_EVENT }, AbortError } = require_errors();
|
|
1645
|
+
const { validateObject } = require_validators();
|
|
1646
|
+
const kPaused = Symbol("kPaused");
|
|
1647
|
+
const { StringDecoder } = require__require_as_import_string_decoder();
|
|
1648
|
+
const from = require_from();
|
|
1649
|
+
ObjectSetPrototypeOf(Readable.prototype, Stream.prototype);
|
|
1650
|
+
ObjectSetPrototypeOf(Readable, Stream);
|
|
1651
|
+
const nop = () => {};
|
|
1652
|
+
const { errorOrDestroy } = destroyImpl;
|
|
1653
|
+
const kObjectMode = 1;
|
|
1654
|
+
const kEnded = 2;
|
|
1655
|
+
const kEndEmitted = 4;
|
|
1656
|
+
const kReading = 8;
|
|
1657
|
+
const kConstructed = 16;
|
|
1658
|
+
const kSync = 32;
|
|
1659
|
+
const kNeedReadable = 64;
|
|
1660
|
+
const kEmittedReadable = 128;
|
|
1661
|
+
const kReadableListening = 256;
|
|
1662
|
+
const kResumeScheduled = 512;
|
|
1663
|
+
const kErrorEmitted = 1024;
|
|
1664
|
+
const kEmitClose = 2048;
|
|
1665
|
+
const kAutoDestroy = 4096;
|
|
1666
|
+
const kDestroyed = 8192;
|
|
1667
|
+
const kClosed = 16384;
|
|
1668
|
+
const kCloseEmitted = 32768;
|
|
1669
|
+
const kMultiAwaitDrain = 65536;
|
|
1670
|
+
const kReadingMore = 1 << 17;
|
|
1671
|
+
const kDataEmitted = 1 << 18;
|
|
1672
|
+
function makeBitMapDescriptor(bit) {
|
|
1673
|
+
return {
|
|
1674
|
+
enumerable: false,
|
|
1675
|
+
get() {
|
|
1676
|
+
return (this.state & bit) !== 0;
|
|
1677
|
+
},
|
|
1678
|
+
set(value) {
|
|
1679
|
+
if (value) this.state |= bit;
|
|
1680
|
+
else this.state &= ~bit;
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
ObjectDefineProperties(ReadableState.prototype, {
|
|
1685
|
+
objectMode: makeBitMapDescriptor(kObjectMode),
|
|
1686
|
+
ended: makeBitMapDescriptor(kEnded),
|
|
1687
|
+
endEmitted: makeBitMapDescriptor(kEndEmitted),
|
|
1688
|
+
reading: makeBitMapDescriptor(kReading),
|
|
1689
|
+
constructed: makeBitMapDescriptor(kConstructed),
|
|
1690
|
+
sync: makeBitMapDescriptor(kSync),
|
|
1691
|
+
needReadable: makeBitMapDescriptor(kNeedReadable),
|
|
1692
|
+
emittedReadable: makeBitMapDescriptor(kEmittedReadable),
|
|
1693
|
+
readableListening: makeBitMapDescriptor(kReadableListening),
|
|
1694
|
+
resumeScheduled: makeBitMapDescriptor(kResumeScheduled),
|
|
1695
|
+
errorEmitted: makeBitMapDescriptor(kErrorEmitted),
|
|
1696
|
+
emitClose: makeBitMapDescriptor(kEmitClose),
|
|
1697
|
+
autoDestroy: makeBitMapDescriptor(kAutoDestroy),
|
|
1698
|
+
destroyed: makeBitMapDescriptor(kDestroyed),
|
|
1699
|
+
closed: makeBitMapDescriptor(kClosed),
|
|
1700
|
+
closeEmitted: makeBitMapDescriptor(kCloseEmitted),
|
|
1701
|
+
multiAwaitDrain: makeBitMapDescriptor(kMultiAwaitDrain),
|
|
1702
|
+
readingMore: makeBitMapDescriptor(kReadingMore),
|
|
1703
|
+
dataEmitted: makeBitMapDescriptor(kDataEmitted)
|
|
1704
|
+
});
|
|
1705
|
+
function ReadableState(options, stream, isDuplex) {
|
|
1706
|
+
if (typeof isDuplex !== "boolean") isDuplex = stream instanceof require_duplex();
|
|
1707
|
+
this.state = 6192;
|
|
1708
|
+
if (options && options.objectMode) this.state |= kObjectMode;
|
|
1709
|
+
if (isDuplex && options && options.readableObjectMode) this.state |= kObjectMode;
|
|
1710
|
+
this.highWaterMark = options ? getHighWaterMark(this, options, "readableHighWaterMark", isDuplex) : getDefaultHighWaterMark(false);
|
|
1711
|
+
this.buffer = new BufferList();
|
|
1712
|
+
this.length = 0;
|
|
1713
|
+
this.pipes = [];
|
|
1714
|
+
this.flowing = null;
|
|
1715
|
+
this[kPaused] = null;
|
|
1716
|
+
if (options && options.emitClose === false) this.state &= -2049;
|
|
1717
|
+
if (options && options.autoDestroy === false) this.state &= -4097;
|
|
1718
|
+
this.errored = null;
|
|
1719
|
+
this.defaultEncoding = options && options.defaultEncoding || "utf8";
|
|
1720
|
+
this.awaitDrainWriters = null;
|
|
1721
|
+
this.decoder = null;
|
|
1722
|
+
this.encoding = null;
|
|
1723
|
+
if (options && options.encoding) {
|
|
1724
|
+
this.decoder = new StringDecoder(options.encoding);
|
|
1725
|
+
this.encoding = options.encoding;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
function Readable(options) {
|
|
1729
|
+
if (!(this instanceof Readable)) return new Readable(options);
|
|
1730
|
+
const isDuplex = this instanceof require_duplex();
|
|
1731
|
+
this._readableState = new ReadableState(options, this, isDuplex);
|
|
1732
|
+
if (options) {
|
|
1733
|
+
if (typeof options.read === "function") this._read = options.read;
|
|
1734
|
+
if (typeof options.destroy === "function") this._destroy = options.destroy;
|
|
1735
|
+
if (typeof options.construct === "function") this._construct = options.construct;
|
|
1736
|
+
if (options.signal && !isDuplex) addAbortSignal(options.signal, this);
|
|
1737
|
+
}
|
|
1738
|
+
Stream.call(this, options);
|
|
1739
|
+
destroyImpl.construct(this, () => {
|
|
1740
|
+
if (this._readableState.needReadable) maybeReadMore(this, this._readableState);
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
Readable.prototype.destroy = destroyImpl.destroy;
|
|
1744
|
+
Readable.prototype._undestroy = destroyImpl.undestroy;
|
|
1745
|
+
Readable.prototype._destroy = function(err, cb) {
|
|
1746
|
+
cb(err);
|
|
1747
|
+
};
|
|
1748
|
+
Readable.prototype[EE.captureRejectionSymbol] = function(err) {
|
|
1749
|
+
this.destroy(err);
|
|
1750
|
+
};
|
|
1751
|
+
Readable.prototype[SymbolAsyncDispose] = function() {
|
|
1752
|
+
let error;
|
|
1753
|
+
if (!this.destroyed) {
|
|
1754
|
+
error = this.readableEnded ? null : new AbortError();
|
|
1755
|
+
this.destroy(error);
|
|
1756
|
+
}
|
|
1757
|
+
return new Promise((resolve, reject) => eos(this, (err) => err && err !== error ? reject(err) : resolve(null)));
|
|
1758
|
+
};
|
|
1759
|
+
Readable.prototype.push = function(chunk, encoding) {
|
|
1760
|
+
return readableAddChunk(this, chunk, encoding, false);
|
|
1761
|
+
};
|
|
1762
|
+
Readable.prototype.unshift = function(chunk, encoding) {
|
|
1763
|
+
return readableAddChunk(this, chunk, encoding, true);
|
|
1764
|
+
};
|
|
1765
|
+
function readableAddChunk(stream, chunk, encoding, addToFront) {
|
|
1766
|
+
debug("readableAddChunk", chunk);
|
|
1767
|
+
const state = stream._readableState;
|
|
1768
|
+
let err;
|
|
1769
|
+
if ((state.state & kObjectMode) === 0) {
|
|
1770
|
+
if (typeof chunk === "string") {
|
|
1771
|
+
encoding = encoding || state.defaultEncoding;
|
|
1772
|
+
if (state.encoding !== encoding) {
|
|
1773
|
+
if (addToFront && state.encoding) chunk = Buffer.from(chunk, encoding).toString(state.encoding);
|
|
1774
|
+
else {
|
|
1775
|
+
chunk = Buffer.from(chunk, encoding);
|
|
1776
|
+
encoding = "";
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
} else if (chunk instanceof Buffer) encoding = "";
|
|
1780
|
+
else if (Stream._isUint8Array(chunk)) {
|
|
1781
|
+
chunk = Stream._uint8ArrayToBuffer(chunk);
|
|
1782
|
+
encoding = "";
|
|
1783
|
+
} else if (chunk != null) err = new ERR_INVALID_ARG_TYPE("chunk", [
|
|
1784
|
+
"string",
|
|
1785
|
+
"Buffer",
|
|
1786
|
+
"Uint8Array"
|
|
1787
|
+
], chunk);
|
|
1788
|
+
}
|
|
1789
|
+
if (err) errorOrDestroy(stream, err);
|
|
1790
|
+
else if (chunk === null) {
|
|
1791
|
+
state.state &= -9;
|
|
1792
|
+
onEofChunk(stream, state);
|
|
1793
|
+
} else if ((state.state & kObjectMode) !== 0 || chunk && chunk.length > 0) {
|
|
1794
|
+
if (addToFront) {
|
|
1795
|
+
if ((state.state & kEndEmitted) !== 0) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());
|
|
1796
|
+
else if (state.destroyed || state.errored) return false;
|
|
1797
|
+
else addChunk(stream, state, chunk, true);
|
|
1798
|
+
} else if (state.ended) errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
|
|
1799
|
+
else if (state.destroyed || state.errored) return false;
|
|
1800
|
+
else {
|
|
1801
|
+
state.state &= -9;
|
|
1802
|
+
if (state.decoder && !encoding) {
|
|
1803
|
+
chunk = state.decoder.write(chunk);
|
|
1804
|
+
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);
|
|
1805
|
+
else maybeReadMore(stream, state);
|
|
1806
|
+
} else addChunk(stream, state, chunk, false);
|
|
1807
|
+
}
|
|
1808
|
+
} else if (!addToFront) {
|
|
1809
|
+
state.state &= -9;
|
|
1810
|
+
maybeReadMore(stream, state);
|
|
1811
|
+
}
|
|
1812
|
+
return !state.ended && (state.length < state.highWaterMark || state.length === 0);
|
|
1813
|
+
}
|
|
1814
|
+
function addChunk(stream, state, chunk, addToFront) {
|
|
1815
|
+
if (state.flowing && state.length === 0 && !state.sync && stream.listenerCount("data") > 0) {
|
|
1816
|
+
if ((state.state & kMultiAwaitDrain) !== 0) state.awaitDrainWriters.clear();
|
|
1817
|
+
else state.awaitDrainWriters = null;
|
|
1818
|
+
state.dataEmitted = true;
|
|
1819
|
+
stream.emit("data", chunk);
|
|
1820
|
+
} else {
|
|
1821
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
1822
|
+
if (addToFront) state.buffer.unshift(chunk);
|
|
1823
|
+
else state.buffer.push(chunk);
|
|
1824
|
+
if ((state.state & kNeedReadable) !== 0) emitReadable(stream);
|
|
1825
|
+
}
|
|
1826
|
+
maybeReadMore(stream, state);
|
|
1827
|
+
}
|
|
1828
|
+
Readable.prototype.isPaused = function() {
|
|
1829
|
+
const state = this._readableState;
|
|
1830
|
+
return state[kPaused] === true || state.flowing === false;
|
|
1831
|
+
};
|
|
1832
|
+
Readable.prototype.setEncoding = function(enc) {
|
|
1833
|
+
const decoder = new StringDecoder(enc);
|
|
1834
|
+
this._readableState.decoder = decoder;
|
|
1835
|
+
this._readableState.encoding = this._readableState.decoder.encoding;
|
|
1836
|
+
const buffer = this._readableState.buffer;
|
|
1837
|
+
let content = "";
|
|
1838
|
+
for (const data of buffer) content += decoder.write(data);
|
|
1839
|
+
buffer.clear();
|
|
1840
|
+
if (content !== "") buffer.push(content);
|
|
1841
|
+
this._readableState.length = content.length;
|
|
1842
|
+
return this;
|
|
1843
|
+
};
|
|
1844
|
+
const MAX_HWM = 1073741824;
|
|
1845
|
+
function computeNewHighWaterMark(n) {
|
|
1846
|
+
if (n > MAX_HWM) throw new ERR_OUT_OF_RANGE("size", "<= 1GiB", n);
|
|
1847
|
+
else {
|
|
1848
|
+
n--;
|
|
1849
|
+
n |= n >>> 1;
|
|
1850
|
+
n |= n >>> 2;
|
|
1851
|
+
n |= n >>> 4;
|
|
1852
|
+
n |= n >>> 8;
|
|
1853
|
+
n |= n >>> 16;
|
|
1854
|
+
n++;
|
|
1855
|
+
}
|
|
1856
|
+
return n;
|
|
1857
|
+
}
|
|
1858
|
+
function howMuchToRead(n, state) {
|
|
1859
|
+
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
1860
|
+
if ((state.state & kObjectMode) !== 0) return 1;
|
|
1861
|
+
if (NumberIsNaN(n)) {
|
|
1862
|
+
if (state.flowing && state.length) return state.buffer.first().length;
|
|
1863
|
+
return state.length;
|
|
1864
|
+
}
|
|
1865
|
+
if (n <= state.length) return n;
|
|
1866
|
+
return state.ended ? state.length : 0;
|
|
1867
|
+
}
|
|
1868
|
+
Readable.prototype.read = function(n) {
|
|
1869
|
+
debug("read", n);
|
|
1870
|
+
if (n === void 0) n = NaN;
|
|
1871
|
+
else if (!NumberIsInteger(n)) n = NumberParseInt(n, 10);
|
|
1872
|
+
const state = this._readableState;
|
|
1873
|
+
const nOrig = n;
|
|
1874
|
+
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
|
1875
|
+
if (n !== 0) state.state &= -129;
|
|
1876
|
+
if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
|
|
1877
|
+
debug("read: emitReadable", state.length, state.ended);
|
|
1878
|
+
if (state.length === 0 && state.ended) endReadable(this);
|
|
1879
|
+
else emitReadable(this);
|
|
1880
|
+
return null;
|
|
1881
|
+
}
|
|
1882
|
+
n = howMuchToRead(n, state);
|
|
1883
|
+
if (n === 0 && state.ended) {
|
|
1884
|
+
if (state.length === 0) endReadable(this);
|
|
1885
|
+
return null;
|
|
1886
|
+
}
|
|
1887
|
+
let doRead = (state.state & kNeedReadable) !== 0;
|
|
1888
|
+
debug("need readable", doRead);
|
|
1889
|
+
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
1890
|
+
doRead = true;
|
|
1891
|
+
debug("length less than watermark", doRead);
|
|
1892
|
+
}
|
|
1893
|
+
if (state.ended || state.reading || state.destroyed || state.errored || !state.constructed) {
|
|
1894
|
+
doRead = false;
|
|
1895
|
+
debug("reading, ended or constructing", doRead);
|
|
1896
|
+
} else if (doRead) {
|
|
1897
|
+
debug("do read");
|
|
1898
|
+
state.state |= 40;
|
|
1899
|
+
if (state.length === 0) state.state |= kNeedReadable;
|
|
1900
|
+
try {
|
|
1901
|
+
this._read(state.highWaterMark);
|
|
1902
|
+
} catch (err) {
|
|
1903
|
+
errorOrDestroy(this, err);
|
|
1904
|
+
}
|
|
1905
|
+
state.state &= -33;
|
|
1906
|
+
if (!state.reading) n = howMuchToRead(nOrig, state);
|
|
1907
|
+
}
|
|
1908
|
+
let ret;
|
|
1909
|
+
if (n > 0) ret = fromList(n, state);
|
|
1910
|
+
else ret = null;
|
|
1911
|
+
if (ret === null) {
|
|
1912
|
+
state.needReadable = state.length <= state.highWaterMark;
|
|
1913
|
+
n = 0;
|
|
1914
|
+
} else {
|
|
1915
|
+
state.length -= n;
|
|
1916
|
+
if (state.multiAwaitDrain) state.awaitDrainWriters.clear();
|
|
1917
|
+
else state.awaitDrainWriters = null;
|
|
1918
|
+
}
|
|
1919
|
+
if (state.length === 0) {
|
|
1920
|
+
if (!state.ended) state.needReadable = true;
|
|
1921
|
+
if (nOrig !== n && state.ended) endReadable(this);
|
|
1922
|
+
}
|
|
1923
|
+
if (ret !== null && !state.errorEmitted && !state.closeEmitted) {
|
|
1924
|
+
state.dataEmitted = true;
|
|
1925
|
+
this.emit("data", ret);
|
|
1926
|
+
}
|
|
1927
|
+
return ret;
|
|
1928
|
+
};
|
|
1929
|
+
function onEofChunk(stream, state) {
|
|
1930
|
+
debug("onEofChunk");
|
|
1931
|
+
if (state.ended) return;
|
|
1932
|
+
if (state.decoder) {
|
|
1933
|
+
const chunk = state.decoder.end();
|
|
1934
|
+
if (chunk && chunk.length) {
|
|
1935
|
+
state.buffer.push(chunk);
|
|
1936
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
state.ended = true;
|
|
1940
|
+
if (state.sync) emitReadable(stream);
|
|
1941
|
+
else {
|
|
1942
|
+
state.needReadable = false;
|
|
1943
|
+
state.emittedReadable = true;
|
|
1944
|
+
emitReadable_(stream);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
function emitReadable(stream) {
|
|
1948
|
+
const state = stream._readableState;
|
|
1949
|
+
debug("emitReadable", state.needReadable, state.emittedReadable);
|
|
1950
|
+
state.needReadable = false;
|
|
1951
|
+
if (!state.emittedReadable) {
|
|
1952
|
+
debug("emitReadable", state.flowing);
|
|
1953
|
+
state.emittedReadable = true;
|
|
1954
|
+
process.nextTick(emitReadable_, stream);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
function emitReadable_(stream) {
|
|
1958
|
+
const state = stream._readableState;
|
|
1959
|
+
debug("emitReadable_", state.destroyed, state.length, state.ended);
|
|
1960
|
+
if (!state.destroyed && !state.errored && (state.length || state.ended)) {
|
|
1961
|
+
stream.emit("readable");
|
|
1962
|
+
state.emittedReadable = false;
|
|
1963
|
+
}
|
|
1964
|
+
state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
|
|
1965
|
+
flow(stream);
|
|
1966
|
+
}
|
|
1967
|
+
function maybeReadMore(stream, state) {
|
|
1968
|
+
if (!state.readingMore && state.constructed) {
|
|
1969
|
+
state.readingMore = true;
|
|
1970
|
+
process.nextTick(maybeReadMore_, stream, state);
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
function maybeReadMore_(stream, state) {
|
|
1974
|
+
while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
|
|
1975
|
+
const len = state.length;
|
|
1976
|
+
debug("maybeReadMore read 0");
|
|
1977
|
+
stream.read(0);
|
|
1978
|
+
if (len === state.length) break;
|
|
1979
|
+
}
|
|
1980
|
+
state.readingMore = false;
|
|
1981
|
+
}
|
|
1982
|
+
Readable.prototype._read = function(n) {
|
|
1983
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("_read()");
|
|
1984
|
+
};
|
|
1985
|
+
Readable.prototype.pipe = function(dest, pipeOpts) {
|
|
1986
|
+
const src = this;
|
|
1987
|
+
const state = this._readableState;
|
|
1988
|
+
if (state.pipes.length === 1) {
|
|
1989
|
+
if (!state.multiAwaitDrain) {
|
|
1990
|
+
state.multiAwaitDrain = true;
|
|
1991
|
+
state.awaitDrainWriters = new SafeSet(state.awaitDrainWriters ? [state.awaitDrainWriters] : []);
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
state.pipes.push(dest);
|
|
1995
|
+
debug("pipe count=%d opts=%j", state.pipes.length, pipeOpts);
|
|
1996
|
+
const endFn = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr ? onend : unpipe;
|
|
1997
|
+
if (state.endEmitted) process.nextTick(endFn);
|
|
1998
|
+
else src.once("end", endFn);
|
|
1999
|
+
dest.on("unpipe", onunpipe);
|
|
2000
|
+
function onunpipe(readable, unpipeInfo) {
|
|
2001
|
+
debug("onunpipe");
|
|
2002
|
+
if (readable === src) {
|
|
2003
|
+
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
2004
|
+
unpipeInfo.hasUnpiped = true;
|
|
2005
|
+
cleanup();
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
function onend() {
|
|
2010
|
+
debug("onend");
|
|
2011
|
+
dest.end();
|
|
2012
|
+
}
|
|
2013
|
+
let ondrain;
|
|
2014
|
+
let cleanedUp = false;
|
|
2015
|
+
function cleanup() {
|
|
2016
|
+
debug("cleanup");
|
|
2017
|
+
dest.removeListener("close", onclose);
|
|
2018
|
+
dest.removeListener("finish", onfinish);
|
|
2019
|
+
if (ondrain) dest.removeListener("drain", ondrain);
|
|
2020
|
+
dest.removeListener("error", onerror);
|
|
2021
|
+
dest.removeListener("unpipe", onunpipe);
|
|
2022
|
+
src.removeListener("end", onend);
|
|
2023
|
+
src.removeListener("end", unpipe);
|
|
2024
|
+
src.removeListener("data", ondata);
|
|
2025
|
+
cleanedUp = true;
|
|
2026
|
+
if (ondrain && state.awaitDrainWriters && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
2027
|
+
}
|
|
2028
|
+
function pause() {
|
|
2029
|
+
if (!cleanedUp) {
|
|
2030
|
+
if (state.pipes.length === 1 && state.pipes[0] === dest) {
|
|
2031
|
+
debug("false write response, pause", 0);
|
|
2032
|
+
state.awaitDrainWriters = dest;
|
|
2033
|
+
state.multiAwaitDrain = false;
|
|
2034
|
+
} else if (state.pipes.length > 1 && state.pipes.includes(dest)) {
|
|
2035
|
+
debug("false write response, pause", state.awaitDrainWriters.size);
|
|
2036
|
+
state.awaitDrainWriters.add(dest);
|
|
2037
|
+
}
|
|
2038
|
+
src.pause();
|
|
2039
|
+
}
|
|
2040
|
+
if (!ondrain) {
|
|
2041
|
+
ondrain = pipeOnDrain(src, dest);
|
|
2042
|
+
dest.on("drain", ondrain);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
src.on("data", ondata);
|
|
2046
|
+
function ondata(chunk) {
|
|
2047
|
+
debug("ondata");
|
|
2048
|
+
const ret = dest.write(chunk);
|
|
2049
|
+
debug("dest.write", ret);
|
|
2050
|
+
if (ret === false) pause();
|
|
2051
|
+
}
|
|
2052
|
+
function onerror(er) {
|
|
2053
|
+
debug("onerror", er);
|
|
2054
|
+
unpipe();
|
|
2055
|
+
dest.removeListener("error", onerror);
|
|
2056
|
+
if (dest.listenerCount("error") === 0) {
|
|
2057
|
+
const s = dest._writableState || dest._readableState;
|
|
2058
|
+
if (s && !s.errorEmitted) errorOrDestroy(dest, er);
|
|
2059
|
+
else dest.emit("error", er);
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
prependListener(dest, "error", onerror);
|
|
2063
|
+
function onclose() {
|
|
2064
|
+
dest.removeListener("finish", onfinish);
|
|
2065
|
+
unpipe();
|
|
2066
|
+
}
|
|
2067
|
+
dest.once("close", onclose);
|
|
2068
|
+
function onfinish() {
|
|
2069
|
+
debug("onfinish");
|
|
2070
|
+
dest.removeListener("close", onclose);
|
|
2071
|
+
unpipe();
|
|
2072
|
+
}
|
|
2073
|
+
dest.once("finish", onfinish);
|
|
2074
|
+
function unpipe() {
|
|
2075
|
+
debug("unpipe");
|
|
2076
|
+
src.unpipe(dest);
|
|
2077
|
+
}
|
|
2078
|
+
dest.emit("pipe", src);
|
|
2079
|
+
if (dest.writableNeedDrain === true) pause();
|
|
2080
|
+
else if (!state.flowing) {
|
|
2081
|
+
debug("pipe resume");
|
|
2082
|
+
src.resume();
|
|
2083
|
+
}
|
|
2084
|
+
return dest;
|
|
2085
|
+
};
|
|
2086
|
+
function pipeOnDrain(src, dest) {
|
|
2087
|
+
return function pipeOnDrainFunctionResult() {
|
|
2088
|
+
const state = src._readableState;
|
|
2089
|
+
if (state.awaitDrainWriters === dest) {
|
|
2090
|
+
debug("pipeOnDrain", 1);
|
|
2091
|
+
state.awaitDrainWriters = null;
|
|
2092
|
+
} else if (state.multiAwaitDrain) {
|
|
2093
|
+
debug("pipeOnDrain", state.awaitDrainWriters.size);
|
|
2094
|
+
state.awaitDrainWriters.delete(dest);
|
|
2095
|
+
}
|
|
2096
|
+
if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) && src.listenerCount("data")) src.resume();
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
Readable.prototype.unpipe = function(dest) {
|
|
2100
|
+
const state = this._readableState;
|
|
2101
|
+
const unpipeInfo = { hasUnpiped: false };
|
|
2102
|
+
if (state.pipes.length === 0) return this;
|
|
2103
|
+
if (!dest) {
|
|
2104
|
+
const dests = state.pipes;
|
|
2105
|
+
state.pipes = [];
|
|
2106
|
+
this.pause();
|
|
2107
|
+
for (let i = 0; i < dests.length; i++) dests[i].emit("unpipe", this, { hasUnpiped: false });
|
|
2108
|
+
return this;
|
|
2109
|
+
}
|
|
2110
|
+
const index = ArrayPrototypeIndexOf(state.pipes, dest);
|
|
2111
|
+
if (index === -1) return this;
|
|
2112
|
+
state.pipes.splice(index, 1);
|
|
2113
|
+
if (state.pipes.length === 0) this.pause();
|
|
2114
|
+
dest.emit("unpipe", this, unpipeInfo);
|
|
2115
|
+
return this;
|
|
2116
|
+
};
|
|
2117
|
+
Readable.prototype.on = function(ev, fn) {
|
|
2118
|
+
const res = Stream.prototype.on.call(this, ev, fn);
|
|
2119
|
+
const state = this._readableState;
|
|
2120
|
+
if (ev === "data") {
|
|
2121
|
+
state.readableListening = this.listenerCount("readable") > 0;
|
|
2122
|
+
if (state.flowing !== false) this.resume();
|
|
2123
|
+
} else if (ev === "readable") {
|
|
2124
|
+
if (!state.endEmitted && !state.readableListening) {
|
|
2125
|
+
state.readableListening = state.needReadable = true;
|
|
2126
|
+
state.flowing = false;
|
|
2127
|
+
state.emittedReadable = false;
|
|
2128
|
+
debug("on readable", state.length, state.reading);
|
|
2129
|
+
if (state.length) emitReadable(this);
|
|
2130
|
+
else if (!state.reading) process.nextTick(nReadingNextTick, this);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
return res;
|
|
2134
|
+
};
|
|
2135
|
+
Readable.prototype.addListener = Readable.prototype.on;
|
|
2136
|
+
Readable.prototype.removeListener = function(ev, fn) {
|
|
2137
|
+
const res = Stream.prototype.removeListener.call(this, ev, fn);
|
|
2138
|
+
if (ev === "readable") process.nextTick(updateReadableListening, this);
|
|
2139
|
+
return res;
|
|
2140
|
+
};
|
|
2141
|
+
Readable.prototype.off = Readable.prototype.removeListener;
|
|
2142
|
+
Readable.prototype.removeAllListeners = function(ev) {
|
|
2143
|
+
const res = Stream.prototype.removeAllListeners.apply(this, arguments);
|
|
2144
|
+
if (ev === "readable" || ev === void 0) process.nextTick(updateReadableListening, this);
|
|
2145
|
+
return res;
|
|
2146
|
+
};
|
|
2147
|
+
function updateReadableListening(self) {
|
|
2148
|
+
const state = self._readableState;
|
|
2149
|
+
state.readableListening = self.listenerCount("readable") > 0;
|
|
2150
|
+
if (state.resumeScheduled && state[kPaused] === false) state.flowing = true;
|
|
2151
|
+
else if (self.listenerCount("data") > 0) self.resume();
|
|
2152
|
+
else if (!state.readableListening) state.flowing = null;
|
|
2153
|
+
}
|
|
2154
|
+
function nReadingNextTick(self) {
|
|
2155
|
+
debug("readable nexttick read 0");
|
|
2156
|
+
self.read(0);
|
|
2157
|
+
}
|
|
2158
|
+
Readable.prototype.resume = function() {
|
|
2159
|
+
const state = this._readableState;
|
|
2160
|
+
if (!state.flowing) {
|
|
2161
|
+
debug("resume");
|
|
2162
|
+
state.flowing = !state.readableListening;
|
|
2163
|
+
resume(this, state);
|
|
2164
|
+
}
|
|
2165
|
+
state[kPaused] = false;
|
|
2166
|
+
return this;
|
|
2167
|
+
};
|
|
2168
|
+
function resume(stream, state) {
|
|
2169
|
+
if (!state.resumeScheduled) {
|
|
2170
|
+
state.resumeScheduled = true;
|
|
2171
|
+
process.nextTick(resume_, stream, state);
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
function resume_(stream, state) {
|
|
2175
|
+
debug("resume", state.reading);
|
|
2176
|
+
if (!state.reading) stream.read(0);
|
|
2177
|
+
state.resumeScheduled = false;
|
|
2178
|
+
stream.emit("resume");
|
|
2179
|
+
flow(stream);
|
|
2180
|
+
if (state.flowing && !state.reading) stream.read(0);
|
|
2181
|
+
}
|
|
2182
|
+
Readable.prototype.pause = function() {
|
|
2183
|
+
debug("call pause flowing=%j", this._readableState.flowing);
|
|
2184
|
+
if (this._readableState.flowing !== false) {
|
|
2185
|
+
debug("pause");
|
|
2186
|
+
this._readableState.flowing = false;
|
|
2187
|
+
this.emit("pause");
|
|
2188
|
+
}
|
|
2189
|
+
this._readableState[kPaused] = true;
|
|
2190
|
+
return this;
|
|
2191
|
+
};
|
|
2192
|
+
function flow(stream) {
|
|
2193
|
+
const state = stream._readableState;
|
|
2194
|
+
debug("flow", state.flowing);
|
|
2195
|
+
while (state.flowing && stream.read() !== null);
|
|
2196
|
+
}
|
|
2197
|
+
Readable.prototype.wrap = function(stream) {
|
|
2198
|
+
let paused = false;
|
|
2199
|
+
stream.on("data", (chunk) => {
|
|
2200
|
+
if (!this.push(chunk) && stream.pause) {
|
|
2201
|
+
paused = true;
|
|
2202
|
+
stream.pause();
|
|
2203
|
+
}
|
|
2204
|
+
});
|
|
2205
|
+
stream.on("end", () => {
|
|
2206
|
+
this.push(null);
|
|
2207
|
+
});
|
|
2208
|
+
stream.on("error", (err) => {
|
|
2209
|
+
errorOrDestroy(this, err);
|
|
2210
|
+
});
|
|
2211
|
+
stream.on("close", () => {
|
|
2212
|
+
this.destroy();
|
|
2213
|
+
});
|
|
2214
|
+
stream.on("destroy", () => {
|
|
2215
|
+
this.destroy();
|
|
2216
|
+
});
|
|
2217
|
+
this._read = () => {
|
|
2218
|
+
if (paused && stream.resume) {
|
|
2219
|
+
paused = false;
|
|
2220
|
+
stream.resume();
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
const streamKeys = ObjectKeys(stream);
|
|
2224
|
+
for (let j = 1; j < streamKeys.length; j++) {
|
|
2225
|
+
const i = streamKeys[j];
|
|
2226
|
+
if (this[i] === void 0 && typeof stream[i] === "function") this[i] = stream[i].bind(stream);
|
|
2227
|
+
}
|
|
2228
|
+
return this;
|
|
2229
|
+
};
|
|
2230
|
+
Readable.prototype[SymbolAsyncIterator] = function() {
|
|
2231
|
+
return streamToAsyncIterator(this);
|
|
2232
|
+
};
|
|
2233
|
+
Readable.prototype.iterator = function(options) {
|
|
2234
|
+
if (options !== void 0) validateObject(options, "options");
|
|
2235
|
+
return streamToAsyncIterator(this, options);
|
|
2236
|
+
};
|
|
2237
|
+
function streamToAsyncIterator(stream, options) {
|
|
2238
|
+
if (typeof stream.read !== "function") stream = Readable.wrap(stream, { objectMode: true });
|
|
2239
|
+
const iter = createAsyncIterator(stream, options);
|
|
2240
|
+
iter.stream = stream;
|
|
2241
|
+
return iter;
|
|
2242
|
+
}
|
|
2243
|
+
async function* createAsyncIterator(stream, options) {
|
|
2244
|
+
let callback = nop;
|
|
2245
|
+
function next(resolve) {
|
|
2246
|
+
if (this === stream) {
|
|
2247
|
+
callback();
|
|
2248
|
+
callback = nop;
|
|
2249
|
+
} else callback = resolve;
|
|
2250
|
+
}
|
|
2251
|
+
stream.on("readable", next);
|
|
2252
|
+
let error;
|
|
2253
|
+
const cleanup = eos(stream, { writable: false }, (err) => {
|
|
2254
|
+
error = err ? aggregateTwoErrors(error, err) : null;
|
|
2255
|
+
callback();
|
|
2256
|
+
callback = nop;
|
|
2257
|
+
});
|
|
2258
|
+
try {
|
|
2259
|
+
while (true) {
|
|
2260
|
+
const chunk = stream.destroyed ? null : stream.read();
|
|
2261
|
+
if (chunk !== null) yield chunk;
|
|
2262
|
+
else if (error) throw error;
|
|
2263
|
+
else if (error === null) return;
|
|
2264
|
+
else await new Promise(next);
|
|
2265
|
+
}
|
|
2266
|
+
} catch (err) {
|
|
2267
|
+
error = aggregateTwoErrors(error, err);
|
|
2268
|
+
throw error;
|
|
2269
|
+
} finally {
|
|
2270
|
+
if ((error || (options === null || options === void 0 ? void 0 : options.destroyOnReturn) !== false) && (error === void 0 || stream._readableState.autoDestroy)) destroyImpl.destroyer(stream, null);
|
|
2271
|
+
else {
|
|
2272
|
+
stream.off("readable", next);
|
|
2273
|
+
cleanup();
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
ObjectDefineProperties(Readable.prototype, {
|
|
2278
|
+
readable: {
|
|
2279
|
+
__proto__: null,
|
|
2280
|
+
get() {
|
|
2281
|
+
const r = this._readableState;
|
|
2282
|
+
return !!r && r.readable !== false && !r.destroyed && !r.errorEmitted && !r.endEmitted;
|
|
2283
|
+
},
|
|
2284
|
+
set(val) {
|
|
2285
|
+
if (this._readableState) this._readableState.readable = !!val;
|
|
2286
|
+
}
|
|
2287
|
+
},
|
|
2288
|
+
readableDidRead: {
|
|
2289
|
+
__proto__: null,
|
|
2290
|
+
enumerable: false,
|
|
2291
|
+
get: function() {
|
|
2292
|
+
return this._readableState.dataEmitted;
|
|
2293
|
+
}
|
|
2294
|
+
},
|
|
2295
|
+
readableAborted: {
|
|
2296
|
+
__proto__: null,
|
|
2297
|
+
enumerable: false,
|
|
2298
|
+
get: function() {
|
|
2299
|
+
return !!(this._readableState.readable !== false && (this._readableState.destroyed || this._readableState.errored) && !this._readableState.endEmitted);
|
|
2300
|
+
}
|
|
2301
|
+
},
|
|
2302
|
+
readableHighWaterMark: {
|
|
2303
|
+
__proto__: null,
|
|
2304
|
+
enumerable: false,
|
|
2305
|
+
get: function() {
|
|
2306
|
+
return this._readableState.highWaterMark;
|
|
2307
|
+
}
|
|
2308
|
+
},
|
|
2309
|
+
readableBuffer: {
|
|
2310
|
+
__proto__: null,
|
|
2311
|
+
enumerable: false,
|
|
2312
|
+
get: function() {
|
|
2313
|
+
return this._readableState && this._readableState.buffer;
|
|
2314
|
+
}
|
|
2315
|
+
},
|
|
2316
|
+
readableFlowing: {
|
|
2317
|
+
__proto__: null,
|
|
2318
|
+
enumerable: false,
|
|
2319
|
+
get: function() {
|
|
2320
|
+
return this._readableState.flowing;
|
|
2321
|
+
},
|
|
2322
|
+
set: function(state) {
|
|
2323
|
+
if (this._readableState) this._readableState.flowing = state;
|
|
2324
|
+
}
|
|
2325
|
+
},
|
|
2326
|
+
readableLength: {
|
|
2327
|
+
__proto__: null,
|
|
2328
|
+
enumerable: false,
|
|
2329
|
+
get() {
|
|
2330
|
+
return this._readableState.length;
|
|
2331
|
+
}
|
|
2332
|
+
},
|
|
2333
|
+
readableObjectMode: {
|
|
2334
|
+
__proto__: null,
|
|
2335
|
+
enumerable: false,
|
|
2336
|
+
get() {
|
|
2337
|
+
return this._readableState ? this._readableState.objectMode : false;
|
|
2338
|
+
}
|
|
2339
|
+
},
|
|
2340
|
+
readableEncoding: {
|
|
2341
|
+
__proto__: null,
|
|
2342
|
+
enumerable: false,
|
|
2343
|
+
get() {
|
|
2344
|
+
return this._readableState ? this._readableState.encoding : null;
|
|
2345
|
+
}
|
|
2346
|
+
},
|
|
2347
|
+
errored: {
|
|
2348
|
+
__proto__: null,
|
|
2349
|
+
enumerable: false,
|
|
2350
|
+
get() {
|
|
2351
|
+
return this._readableState ? this._readableState.errored : null;
|
|
2352
|
+
}
|
|
2353
|
+
},
|
|
2354
|
+
closed: {
|
|
2355
|
+
__proto__: null,
|
|
2356
|
+
get() {
|
|
2357
|
+
return this._readableState ? this._readableState.closed : false;
|
|
2358
|
+
}
|
|
2359
|
+
},
|
|
2360
|
+
destroyed: {
|
|
2361
|
+
__proto__: null,
|
|
2362
|
+
enumerable: false,
|
|
2363
|
+
get() {
|
|
2364
|
+
return this._readableState ? this._readableState.destroyed : false;
|
|
2365
|
+
},
|
|
2366
|
+
set(value) {
|
|
2367
|
+
if (!this._readableState) return;
|
|
2368
|
+
this._readableState.destroyed = value;
|
|
2369
|
+
}
|
|
2370
|
+
},
|
|
2371
|
+
readableEnded: {
|
|
2372
|
+
__proto__: null,
|
|
2373
|
+
enumerable: false,
|
|
2374
|
+
get() {
|
|
2375
|
+
return this._readableState ? this._readableState.endEmitted : false;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
});
|
|
2379
|
+
ObjectDefineProperties(ReadableState.prototype, {
|
|
2380
|
+
pipesCount: {
|
|
2381
|
+
__proto__: null,
|
|
2382
|
+
get() {
|
|
2383
|
+
return this.pipes.length;
|
|
2384
|
+
}
|
|
2385
|
+
},
|
|
2386
|
+
paused: {
|
|
2387
|
+
__proto__: null,
|
|
2388
|
+
get() {
|
|
2389
|
+
return this[kPaused] !== false;
|
|
2390
|
+
},
|
|
2391
|
+
set(value) {
|
|
2392
|
+
this[kPaused] = !!value;
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
});
|
|
2396
|
+
Readable._fromList = fromList;
|
|
2397
|
+
function fromList(n, state) {
|
|
2398
|
+
if (state.length === 0) return null;
|
|
2399
|
+
let ret;
|
|
2400
|
+
if (state.objectMode) ret = state.buffer.shift();
|
|
2401
|
+
else if (!n || n >= state.length) {
|
|
2402
|
+
if (state.decoder) ret = state.buffer.join("");
|
|
2403
|
+
else if (state.buffer.length === 1) ret = state.buffer.first();
|
|
2404
|
+
else ret = state.buffer.concat(state.length);
|
|
2405
|
+
state.buffer.clear();
|
|
2406
|
+
} else ret = state.buffer.consume(n, state.decoder);
|
|
2407
|
+
return ret;
|
|
2408
|
+
}
|
|
2409
|
+
function endReadable(stream) {
|
|
2410
|
+
const state = stream._readableState;
|
|
2411
|
+
debug("endReadable", state.endEmitted);
|
|
2412
|
+
if (!state.endEmitted) {
|
|
2413
|
+
state.ended = true;
|
|
2414
|
+
process.nextTick(endReadableNT, state, stream);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
function endReadableNT(state, stream) {
|
|
2418
|
+
debug("endReadableNT", state.endEmitted, state.length);
|
|
2419
|
+
if (!state.errored && !state.closeEmitted && !state.endEmitted && state.length === 0) {
|
|
2420
|
+
state.endEmitted = true;
|
|
2421
|
+
stream.emit("end");
|
|
2422
|
+
if (stream.writable && stream.allowHalfOpen === false) process.nextTick(endWritableNT, stream);
|
|
2423
|
+
else if (state.autoDestroy) {
|
|
2424
|
+
const wState = stream._writableState;
|
|
2425
|
+
if (!wState || wState.autoDestroy && (wState.finished || wState.writable === false)) stream.destroy();
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
function endWritableNT(stream) {
|
|
2430
|
+
if (stream.writable && !stream.writableEnded && !stream.destroyed) stream.end();
|
|
2431
|
+
}
|
|
2432
|
+
Readable.from = function(iterable, opts) {
|
|
2433
|
+
return from(Readable, iterable, opts);
|
|
2434
|
+
};
|
|
2435
|
+
let webStreamsAdapters;
|
|
2436
|
+
function lazyWebStreams() {
|
|
2437
|
+
if (webStreamsAdapters === void 0) webStreamsAdapters = {};
|
|
2438
|
+
return webStreamsAdapters;
|
|
2439
|
+
}
|
|
2440
|
+
Readable.fromWeb = function(readableStream, options) {
|
|
2441
|
+
return lazyWebStreams().newStreamReadableFromReadableStream(readableStream, options);
|
|
2442
|
+
};
|
|
2443
|
+
Readable.toWeb = function(streamReadable, options) {
|
|
2444
|
+
return lazyWebStreams().newReadableStreamFromStreamReadable(streamReadable, options);
|
|
2445
|
+
};
|
|
2446
|
+
Readable.wrap = function(src, options) {
|
|
2447
|
+
var _ref, _src$readableObjectMo;
|
|
2448
|
+
return new Readable({
|
|
2449
|
+
objectMode: (_ref = (_src$readableObjectMo = src.readableObjectMode) !== null && _src$readableObjectMo !== void 0 ? _src$readableObjectMo : src.objectMode) !== null && _ref !== void 0 ? _ref : true,
|
|
2450
|
+
...options,
|
|
2451
|
+
destroy(err, callback) {
|
|
2452
|
+
destroyImpl.destroyer(src, err);
|
|
2453
|
+
callback(err);
|
|
2454
|
+
}
|
|
2455
|
+
}).wrap(src);
|
|
2456
|
+
};
|
|
2457
|
+
}));
|
|
2458
|
+
//#endregion
|
|
2459
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/writable.js
|
|
2460
|
+
var require_writable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2461
|
+
const process = require_process();
|
|
2462
|
+
const { ArrayPrototypeSlice, Error, FunctionPrototypeSymbolHasInstance, ObjectDefineProperty, ObjectDefineProperties, ObjectSetPrototypeOf, StringPrototypeToLowerCase, Symbol, SymbolHasInstance } = require_primordials();
|
|
2463
|
+
module.exports = Writable;
|
|
2464
|
+
Writable.WritableState = WritableState;
|
|
2465
|
+
const { EventEmitter: EE } = require__require_as_import_events();
|
|
2466
|
+
const Stream = require_legacy().Stream;
|
|
2467
|
+
const { Buffer } = require__require_as_import_buffer();
|
|
2468
|
+
const destroyImpl = require_destroy();
|
|
2469
|
+
const { addAbortSignal } = require_add_abort_signal();
|
|
2470
|
+
const { getHighWaterMark, getDefaultHighWaterMark } = require_state();
|
|
2471
|
+
const { ERR_INVALID_ARG_TYPE, ERR_METHOD_NOT_IMPLEMENTED, ERR_MULTIPLE_CALLBACK, ERR_STREAM_CANNOT_PIPE, ERR_STREAM_DESTROYED, ERR_STREAM_ALREADY_FINISHED, ERR_STREAM_NULL_VALUES, ERR_STREAM_WRITE_AFTER_END, ERR_UNKNOWN_ENCODING } = require_errors().codes;
|
|
2472
|
+
const { errorOrDestroy } = destroyImpl;
|
|
2473
|
+
ObjectSetPrototypeOf(Writable.prototype, Stream.prototype);
|
|
2474
|
+
ObjectSetPrototypeOf(Writable, Stream);
|
|
2475
|
+
function nop() {}
|
|
2476
|
+
const kOnFinished = Symbol("kOnFinished");
|
|
2477
|
+
function WritableState(options, stream, isDuplex) {
|
|
2478
|
+
if (typeof isDuplex !== "boolean") isDuplex = stream instanceof require_duplex();
|
|
2479
|
+
this.objectMode = !!(options && options.objectMode);
|
|
2480
|
+
if (isDuplex) this.objectMode = this.objectMode || !!(options && options.writableObjectMode);
|
|
2481
|
+
this.highWaterMark = options ? getHighWaterMark(this, options, "writableHighWaterMark", isDuplex) : getDefaultHighWaterMark(false);
|
|
2482
|
+
this.finalCalled = false;
|
|
2483
|
+
this.needDrain = false;
|
|
2484
|
+
this.ending = false;
|
|
2485
|
+
this.ended = false;
|
|
2486
|
+
this.finished = false;
|
|
2487
|
+
this.destroyed = false;
|
|
2488
|
+
const noDecode = !!(options && options.decodeStrings === false);
|
|
2489
|
+
this.decodeStrings = !noDecode;
|
|
2490
|
+
this.defaultEncoding = options && options.defaultEncoding || "utf8";
|
|
2491
|
+
this.length = 0;
|
|
2492
|
+
this.writing = false;
|
|
2493
|
+
this.corked = 0;
|
|
2494
|
+
this.sync = true;
|
|
2495
|
+
this.bufferProcessing = false;
|
|
2496
|
+
this.onwrite = onwrite.bind(void 0, stream);
|
|
2497
|
+
this.writecb = null;
|
|
2498
|
+
this.writelen = 0;
|
|
2499
|
+
this.afterWriteTickInfo = null;
|
|
2500
|
+
resetBuffer(this);
|
|
2501
|
+
this.pendingcb = 0;
|
|
2502
|
+
this.constructed = true;
|
|
2503
|
+
this.prefinished = false;
|
|
2504
|
+
this.errorEmitted = false;
|
|
2505
|
+
this.emitClose = !options || options.emitClose !== false;
|
|
2506
|
+
this.autoDestroy = !options || options.autoDestroy !== false;
|
|
2507
|
+
this.errored = null;
|
|
2508
|
+
this.closed = false;
|
|
2509
|
+
this.closeEmitted = false;
|
|
2510
|
+
this[kOnFinished] = [];
|
|
2511
|
+
}
|
|
2512
|
+
function resetBuffer(state) {
|
|
2513
|
+
state.buffered = [];
|
|
2514
|
+
state.bufferedIndex = 0;
|
|
2515
|
+
state.allBuffers = true;
|
|
2516
|
+
state.allNoop = true;
|
|
2517
|
+
}
|
|
2518
|
+
WritableState.prototype.getBuffer = function getBuffer() {
|
|
2519
|
+
return ArrayPrototypeSlice(this.buffered, this.bufferedIndex);
|
|
2520
|
+
};
|
|
2521
|
+
ObjectDefineProperty(WritableState.prototype, "bufferedRequestCount", {
|
|
2522
|
+
__proto__: null,
|
|
2523
|
+
get() {
|
|
2524
|
+
return this.buffered.length - this.bufferedIndex;
|
|
2525
|
+
}
|
|
2526
|
+
});
|
|
2527
|
+
function Writable(options) {
|
|
2528
|
+
const isDuplex = this instanceof require_duplex();
|
|
2529
|
+
if (!isDuplex && !FunctionPrototypeSymbolHasInstance(Writable, this)) return new Writable(options);
|
|
2530
|
+
this._writableState = new WritableState(options, this, isDuplex);
|
|
2531
|
+
if (options) {
|
|
2532
|
+
if (typeof options.write === "function") this._write = options.write;
|
|
2533
|
+
if (typeof options.writev === "function") this._writev = options.writev;
|
|
2534
|
+
if (typeof options.destroy === "function") this._destroy = options.destroy;
|
|
2535
|
+
if (typeof options.final === "function") this._final = options.final;
|
|
2536
|
+
if (typeof options.construct === "function") this._construct = options.construct;
|
|
2537
|
+
if (options.signal) addAbortSignal(options.signal, this);
|
|
2538
|
+
}
|
|
2539
|
+
Stream.call(this, options);
|
|
2540
|
+
destroyImpl.construct(this, () => {
|
|
2541
|
+
const state = this._writableState;
|
|
2542
|
+
if (!state.writing) clearBuffer(this, state);
|
|
2543
|
+
finishMaybe(this, state);
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
ObjectDefineProperty(Writable, SymbolHasInstance, {
|
|
2547
|
+
__proto__: null,
|
|
2548
|
+
value: function(object) {
|
|
2549
|
+
if (FunctionPrototypeSymbolHasInstance(this, object)) return true;
|
|
2550
|
+
if (this !== Writable) return false;
|
|
2551
|
+
return object && object._writableState instanceof WritableState;
|
|
2552
|
+
}
|
|
2553
|
+
});
|
|
2554
|
+
Writable.prototype.pipe = function() {
|
|
2555
|
+
errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
|
|
2556
|
+
};
|
|
2557
|
+
function _write(stream, chunk, encoding, cb) {
|
|
2558
|
+
const state = stream._writableState;
|
|
2559
|
+
if (typeof encoding === "function") {
|
|
2560
|
+
cb = encoding;
|
|
2561
|
+
encoding = state.defaultEncoding;
|
|
2562
|
+
} else {
|
|
2563
|
+
if (!encoding) encoding = state.defaultEncoding;
|
|
2564
|
+
else if (encoding !== "buffer" && !Buffer.isEncoding(encoding)) throw new ERR_UNKNOWN_ENCODING(encoding);
|
|
2565
|
+
if (typeof cb !== "function") cb = nop;
|
|
2566
|
+
}
|
|
2567
|
+
if (chunk === null) throw new ERR_STREAM_NULL_VALUES();
|
|
2568
|
+
else if (!state.objectMode) {
|
|
2569
|
+
if (typeof chunk === "string") {
|
|
2570
|
+
if (state.decodeStrings !== false) {
|
|
2571
|
+
chunk = Buffer.from(chunk, encoding);
|
|
2572
|
+
encoding = "buffer";
|
|
2573
|
+
}
|
|
2574
|
+
} else if (chunk instanceof Buffer) encoding = "buffer";
|
|
2575
|
+
else if (Stream._isUint8Array(chunk)) {
|
|
2576
|
+
chunk = Stream._uint8ArrayToBuffer(chunk);
|
|
2577
|
+
encoding = "buffer";
|
|
2578
|
+
} else throw new ERR_INVALID_ARG_TYPE("chunk", [
|
|
2579
|
+
"string",
|
|
2580
|
+
"Buffer",
|
|
2581
|
+
"Uint8Array"
|
|
2582
|
+
], chunk);
|
|
2583
|
+
}
|
|
2584
|
+
let err;
|
|
2585
|
+
if (state.ending) err = new ERR_STREAM_WRITE_AFTER_END();
|
|
2586
|
+
else if (state.destroyed) err = new ERR_STREAM_DESTROYED("write");
|
|
2587
|
+
if (err) {
|
|
2588
|
+
process.nextTick(cb, err);
|
|
2589
|
+
errorOrDestroy(stream, err, true);
|
|
2590
|
+
return err;
|
|
2591
|
+
}
|
|
2592
|
+
state.pendingcb++;
|
|
2593
|
+
return writeOrBuffer(stream, state, chunk, encoding, cb);
|
|
2594
|
+
}
|
|
2595
|
+
Writable.prototype.write = function(chunk, encoding, cb) {
|
|
2596
|
+
return _write(this, chunk, encoding, cb) === true;
|
|
2597
|
+
};
|
|
2598
|
+
Writable.prototype.cork = function() {
|
|
2599
|
+
this._writableState.corked++;
|
|
2600
|
+
};
|
|
2601
|
+
Writable.prototype.uncork = function() {
|
|
2602
|
+
const state = this._writableState;
|
|
2603
|
+
if (state.corked) {
|
|
2604
|
+
state.corked--;
|
|
2605
|
+
if (!state.writing) clearBuffer(this, state);
|
|
2606
|
+
}
|
|
2607
|
+
};
|
|
2608
|
+
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
2609
|
+
if (typeof encoding === "string") encoding = StringPrototypeToLowerCase(encoding);
|
|
2610
|
+
if (!Buffer.isEncoding(encoding)) throw new ERR_UNKNOWN_ENCODING(encoding);
|
|
2611
|
+
this._writableState.defaultEncoding = encoding;
|
|
2612
|
+
return this;
|
|
2613
|
+
};
|
|
2614
|
+
function writeOrBuffer(stream, state, chunk, encoding, callback) {
|
|
2615
|
+
const len = state.objectMode ? 1 : chunk.length;
|
|
2616
|
+
state.length += len;
|
|
2617
|
+
const ret = state.length < state.highWaterMark;
|
|
2618
|
+
if (!ret) state.needDrain = true;
|
|
2619
|
+
if (state.writing || state.corked || state.errored || !state.constructed) {
|
|
2620
|
+
state.buffered.push({
|
|
2621
|
+
chunk,
|
|
2622
|
+
encoding,
|
|
2623
|
+
callback
|
|
2624
|
+
});
|
|
2625
|
+
if (state.allBuffers && encoding !== "buffer") state.allBuffers = false;
|
|
2626
|
+
if (state.allNoop && callback !== nop) state.allNoop = false;
|
|
2627
|
+
} else {
|
|
2628
|
+
state.writelen = len;
|
|
2629
|
+
state.writecb = callback;
|
|
2630
|
+
state.writing = true;
|
|
2631
|
+
state.sync = true;
|
|
2632
|
+
stream._write(chunk, encoding, state.onwrite);
|
|
2633
|
+
state.sync = false;
|
|
2634
|
+
}
|
|
2635
|
+
return ret && !state.errored && !state.destroyed;
|
|
2636
|
+
}
|
|
2637
|
+
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
2638
|
+
state.writelen = len;
|
|
2639
|
+
state.writecb = cb;
|
|
2640
|
+
state.writing = true;
|
|
2641
|
+
state.sync = true;
|
|
2642
|
+
if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED("write"));
|
|
2643
|
+
else if (writev) stream._writev(chunk, state.onwrite);
|
|
2644
|
+
else stream._write(chunk, encoding, state.onwrite);
|
|
2645
|
+
state.sync = false;
|
|
2646
|
+
}
|
|
2647
|
+
function onwriteError(stream, state, er, cb) {
|
|
2648
|
+
--state.pendingcb;
|
|
2649
|
+
cb(er);
|
|
2650
|
+
errorBuffer(state);
|
|
2651
|
+
errorOrDestroy(stream, er);
|
|
2652
|
+
}
|
|
2653
|
+
function onwrite(stream, er) {
|
|
2654
|
+
const state = stream._writableState;
|
|
2655
|
+
const sync = state.sync;
|
|
2656
|
+
const cb = state.writecb;
|
|
2657
|
+
if (typeof cb !== "function") {
|
|
2658
|
+
errorOrDestroy(stream, new ERR_MULTIPLE_CALLBACK());
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2661
|
+
state.writing = false;
|
|
2662
|
+
state.writecb = null;
|
|
2663
|
+
state.length -= state.writelen;
|
|
2664
|
+
state.writelen = 0;
|
|
2665
|
+
if (er) {
|
|
2666
|
+
er.stack;
|
|
2667
|
+
if (!state.errored) state.errored = er;
|
|
2668
|
+
if (stream._readableState && !stream._readableState.errored) stream._readableState.errored = er;
|
|
2669
|
+
if (sync) process.nextTick(onwriteError, stream, state, er, cb);
|
|
2670
|
+
else onwriteError(stream, state, er, cb);
|
|
2671
|
+
} else {
|
|
2672
|
+
if (state.buffered.length > state.bufferedIndex) clearBuffer(stream, state);
|
|
2673
|
+
if (sync) {
|
|
2674
|
+
if (state.afterWriteTickInfo !== null && state.afterWriteTickInfo.cb === cb) state.afterWriteTickInfo.count++;
|
|
2675
|
+
else {
|
|
2676
|
+
state.afterWriteTickInfo = {
|
|
2677
|
+
count: 1,
|
|
2678
|
+
cb,
|
|
2679
|
+
stream,
|
|
2680
|
+
state
|
|
2681
|
+
};
|
|
2682
|
+
process.nextTick(afterWriteTick, state.afterWriteTickInfo);
|
|
2683
|
+
}
|
|
2684
|
+
} else afterWrite(stream, state, 1, cb);
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
function afterWriteTick({ stream, state, count, cb }) {
|
|
2688
|
+
state.afterWriteTickInfo = null;
|
|
2689
|
+
return afterWrite(stream, state, count, cb);
|
|
2690
|
+
}
|
|
2691
|
+
function afterWrite(stream, state, count, cb) {
|
|
2692
|
+
if (!state.ending && !stream.destroyed && state.length === 0 && state.needDrain) {
|
|
2693
|
+
state.needDrain = false;
|
|
2694
|
+
stream.emit("drain");
|
|
2695
|
+
}
|
|
2696
|
+
while (count-- > 0) {
|
|
2697
|
+
state.pendingcb--;
|
|
2698
|
+
cb();
|
|
2699
|
+
}
|
|
2700
|
+
if (state.destroyed) errorBuffer(state);
|
|
2701
|
+
finishMaybe(stream, state);
|
|
2702
|
+
}
|
|
2703
|
+
function errorBuffer(state) {
|
|
2704
|
+
if (state.writing) return;
|
|
2705
|
+
for (let n = state.bufferedIndex; n < state.buffered.length; ++n) {
|
|
2706
|
+
var _state$errored;
|
|
2707
|
+
const { chunk, callback } = state.buffered[n];
|
|
2708
|
+
const len = state.objectMode ? 1 : chunk.length;
|
|
2709
|
+
state.length -= len;
|
|
2710
|
+
callback((_state$errored = state.errored) !== null && _state$errored !== void 0 ? _state$errored : new ERR_STREAM_DESTROYED("write"));
|
|
2711
|
+
}
|
|
2712
|
+
const onfinishCallbacks = state[kOnFinished].splice(0);
|
|
2713
|
+
for (let i = 0; i < onfinishCallbacks.length; i++) {
|
|
2714
|
+
var _state$errored2;
|
|
2715
|
+
onfinishCallbacks[i]((_state$errored2 = state.errored) !== null && _state$errored2 !== void 0 ? _state$errored2 : new ERR_STREAM_DESTROYED("end"));
|
|
2716
|
+
}
|
|
2717
|
+
resetBuffer(state);
|
|
2718
|
+
}
|
|
2719
|
+
function clearBuffer(stream, state) {
|
|
2720
|
+
if (state.corked || state.bufferProcessing || state.destroyed || !state.constructed) return;
|
|
2721
|
+
const { buffered, bufferedIndex, objectMode } = state;
|
|
2722
|
+
const bufferedLength = buffered.length - bufferedIndex;
|
|
2723
|
+
if (!bufferedLength) return;
|
|
2724
|
+
let i = bufferedIndex;
|
|
2725
|
+
state.bufferProcessing = true;
|
|
2726
|
+
if (bufferedLength > 1 && stream._writev) {
|
|
2727
|
+
state.pendingcb -= bufferedLength - 1;
|
|
2728
|
+
const callback = state.allNoop ? nop : (err) => {
|
|
2729
|
+
for (let n = i; n < buffered.length; ++n) buffered[n].callback(err);
|
|
2730
|
+
};
|
|
2731
|
+
const chunks = state.allNoop && i === 0 ? buffered : ArrayPrototypeSlice(buffered, i);
|
|
2732
|
+
chunks.allBuffers = state.allBuffers;
|
|
2733
|
+
doWrite(stream, state, true, state.length, chunks, "", callback);
|
|
2734
|
+
resetBuffer(state);
|
|
2735
|
+
} else {
|
|
2736
|
+
do {
|
|
2737
|
+
const { chunk, encoding, callback } = buffered[i];
|
|
2738
|
+
buffered[i++] = null;
|
|
2739
|
+
doWrite(stream, state, false, objectMode ? 1 : chunk.length, chunk, encoding, callback);
|
|
2740
|
+
} while (i < buffered.length && !state.writing);
|
|
2741
|
+
if (i === buffered.length) resetBuffer(state);
|
|
2742
|
+
else if (i > 256) {
|
|
2743
|
+
buffered.splice(0, i);
|
|
2744
|
+
state.bufferedIndex = 0;
|
|
2745
|
+
} else state.bufferedIndex = i;
|
|
2746
|
+
}
|
|
2747
|
+
state.bufferProcessing = false;
|
|
2748
|
+
}
|
|
2749
|
+
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
2750
|
+
if (this._writev) this._writev([{
|
|
2751
|
+
chunk,
|
|
2752
|
+
encoding
|
|
2753
|
+
}], cb);
|
|
2754
|
+
else throw new ERR_METHOD_NOT_IMPLEMENTED("_write()");
|
|
2755
|
+
};
|
|
2756
|
+
Writable.prototype._writev = null;
|
|
2757
|
+
Writable.prototype.end = function(chunk, encoding, cb) {
|
|
2758
|
+
const state = this._writableState;
|
|
2759
|
+
if (typeof chunk === "function") {
|
|
2760
|
+
cb = chunk;
|
|
2761
|
+
chunk = null;
|
|
2762
|
+
encoding = null;
|
|
2763
|
+
} else if (typeof encoding === "function") {
|
|
2764
|
+
cb = encoding;
|
|
2765
|
+
encoding = null;
|
|
2766
|
+
}
|
|
2767
|
+
let err;
|
|
2768
|
+
if (chunk !== null && chunk !== void 0) {
|
|
2769
|
+
const ret = _write(this, chunk, encoding);
|
|
2770
|
+
if (ret instanceof Error) err = ret;
|
|
2771
|
+
}
|
|
2772
|
+
if (state.corked) {
|
|
2773
|
+
state.corked = 1;
|
|
2774
|
+
this.uncork();
|
|
2775
|
+
}
|
|
2776
|
+
if (err) {} else if (!state.errored && !state.ending) {
|
|
2777
|
+
state.ending = true;
|
|
2778
|
+
finishMaybe(this, state, true);
|
|
2779
|
+
state.ended = true;
|
|
2780
|
+
} else if (state.finished) err = new ERR_STREAM_ALREADY_FINISHED("end");
|
|
2781
|
+
else if (state.destroyed) err = new ERR_STREAM_DESTROYED("end");
|
|
2782
|
+
if (typeof cb === "function") {
|
|
2783
|
+
if (err || state.finished) process.nextTick(cb, err);
|
|
2784
|
+
else state[kOnFinished].push(cb);
|
|
2785
|
+
}
|
|
2786
|
+
return this;
|
|
2787
|
+
};
|
|
2788
|
+
function needFinish(state) {
|
|
2789
|
+
return state.ending && !state.destroyed && state.constructed && state.length === 0 && !state.errored && state.buffered.length === 0 && !state.finished && !state.writing && !state.errorEmitted && !state.closeEmitted;
|
|
2790
|
+
}
|
|
2791
|
+
function callFinal(stream, state) {
|
|
2792
|
+
let called = false;
|
|
2793
|
+
function onFinish(err) {
|
|
2794
|
+
if (called) {
|
|
2795
|
+
errorOrDestroy(stream, err !== null && err !== void 0 ? err : ERR_MULTIPLE_CALLBACK());
|
|
2796
|
+
return;
|
|
2797
|
+
}
|
|
2798
|
+
called = true;
|
|
2799
|
+
state.pendingcb--;
|
|
2800
|
+
if (err) {
|
|
2801
|
+
const onfinishCallbacks = state[kOnFinished].splice(0);
|
|
2802
|
+
for (let i = 0; i < onfinishCallbacks.length; i++) onfinishCallbacks[i](err);
|
|
2803
|
+
errorOrDestroy(stream, err, state.sync);
|
|
2804
|
+
} else if (needFinish(state)) {
|
|
2805
|
+
state.prefinished = true;
|
|
2806
|
+
stream.emit("prefinish");
|
|
2807
|
+
state.pendingcb++;
|
|
2808
|
+
process.nextTick(finish, stream, state);
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
state.sync = true;
|
|
2812
|
+
state.pendingcb++;
|
|
2813
|
+
try {
|
|
2814
|
+
stream._final(onFinish);
|
|
2815
|
+
} catch (err) {
|
|
2816
|
+
onFinish(err);
|
|
2817
|
+
}
|
|
2818
|
+
state.sync = false;
|
|
2819
|
+
}
|
|
2820
|
+
function prefinish(stream, state) {
|
|
2821
|
+
if (!state.prefinished && !state.finalCalled) {
|
|
2822
|
+
if (typeof stream._final === "function" && !state.destroyed) {
|
|
2823
|
+
state.finalCalled = true;
|
|
2824
|
+
callFinal(stream, state);
|
|
2825
|
+
} else {
|
|
2826
|
+
state.prefinished = true;
|
|
2827
|
+
stream.emit("prefinish");
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
function finishMaybe(stream, state, sync) {
|
|
2832
|
+
if (needFinish(state)) {
|
|
2833
|
+
prefinish(stream, state);
|
|
2834
|
+
if (state.pendingcb === 0) {
|
|
2835
|
+
if (sync) {
|
|
2836
|
+
state.pendingcb++;
|
|
2837
|
+
process.nextTick((stream, state) => {
|
|
2838
|
+
if (needFinish(state)) finish(stream, state);
|
|
2839
|
+
else state.pendingcb--;
|
|
2840
|
+
}, stream, state);
|
|
2841
|
+
} else if (needFinish(state)) {
|
|
2842
|
+
state.pendingcb++;
|
|
2843
|
+
finish(stream, state);
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
function finish(stream, state) {
|
|
2849
|
+
state.pendingcb--;
|
|
2850
|
+
state.finished = true;
|
|
2851
|
+
const onfinishCallbacks = state[kOnFinished].splice(0);
|
|
2852
|
+
for (let i = 0; i < onfinishCallbacks.length; i++) onfinishCallbacks[i]();
|
|
2853
|
+
stream.emit("finish");
|
|
2854
|
+
if (state.autoDestroy) {
|
|
2855
|
+
const rState = stream._readableState;
|
|
2856
|
+
if (!rState || rState.autoDestroy && (rState.endEmitted || rState.readable === false)) stream.destroy();
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
ObjectDefineProperties(Writable.prototype, {
|
|
2860
|
+
closed: {
|
|
2861
|
+
__proto__: null,
|
|
2862
|
+
get() {
|
|
2863
|
+
return this._writableState ? this._writableState.closed : false;
|
|
2864
|
+
}
|
|
2865
|
+
},
|
|
2866
|
+
destroyed: {
|
|
2867
|
+
__proto__: null,
|
|
2868
|
+
get() {
|
|
2869
|
+
return this._writableState ? this._writableState.destroyed : false;
|
|
2870
|
+
},
|
|
2871
|
+
set(value) {
|
|
2872
|
+
if (this._writableState) this._writableState.destroyed = value;
|
|
2873
|
+
}
|
|
2874
|
+
},
|
|
2875
|
+
writable: {
|
|
2876
|
+
__proto__: null,
|
|
2877
|
+
get() {
|
|
2878
|
+
const w = this._writableState;
|
|
2879
|
+
return !!w && w.writable !== false && !w.destroyed && !w.errored && !w.ending && !w.ended;
|
|
2880
|
+
},
|
|
2881
|
+
set(val) {
|
|
2882
|
+
if (this._writableState) this._writableState.writable = !!val;
|
|
2883
|
+
}
|
|
2884
|
+
},
|
|
2885
|
+
writableFinished: {
|
|
2886
|
+
__proto__: null,
|
|
2887
|
+
get() {
|
|
2888
|
+
return this._writableState ? this._writableState.finished : false;
|
|
2889
|
+
}
|
|
2890
|
+
},
|
|
2891
|
+
writableObjectMode: {
|
|
2892
|
+
__proto__: null,
|
|
2893
|
+
get() {
|
|
2894
|
+
return this._writableState ? this._writableState.objectMode : false;
|
|
2895
|
+
}
|
|
2896
|
+
},
|
|
2897
|
+
writableBuffer: {
|
|
2898
|
+
__proto__: null,
|
|
2899
|
+
get() {
|
|
2900
|
+
return this._writableState && this._writableState.getBuffer();
|
|
2901
|
+
}
|
|
2902
|
+
},
|
|
2903
|
+
writableEnded: {
|
|
2904
|
+
__proto__: null,
|
|
2905
|
+
get() {
|
|
2906
|
+
return this._writableState ? this._writableState.ending : false;
|
|
2907
|
+
}
|
|
2908
|
+
},
|
|
2909
|
+
writableNeedDrain: {
|
|
2910
|
+
__proto__: null,
|
|
2911
|
+
get() {
|
|
2912
|
+
const wState = this._writableState;
|
|
2913
|
+
if (!wState) return false;
|
|
2914
|
+
return !wState.destroyed && !wState.ending && wState.needDrain;
|
|
2915
|
+
}
|
|
2916
|
+
},
|
|
2917
|
+
writableHighWaterMark: {
|
|
2918
|
+
__proto__: null,
|
|
2919
|
+
get() {
|
|
2920
|
+
return this._writableState && this._writableState.highWaterMark;
|
|
2921
|
+
}
|
|
2922
|
+
},
|
|
2923
|
+
writableCorked: {
|
|
2924
|
+
__proto__: null,
|
|
2925
|
+
get() {
|
|
2926
|
+
return this._writableState ? this._writableState.corked : 0;
|
|
2927
|
+
}
|
|
2928
|
+
},
|
|
2929
|
+
writableLength: {
|
|
2930
|
+
__proto__: null,
|
|
2931
|
+
get() {
|
|
2932
|
+
return this._writableState && this._writableState.length;
|
|
2933
|
+
}
|
|
2934
|
+
},
|
|
2935
|
+
errored: {
|
|
2936
|
+
__proto__: null,
|
|
2937
|
+
enumerable: false,
|
|
2938
|
+
get() {
|
|
2939
|
+
return this._writableState ? this._writableState.errored : null;
|
|
2940
|
+
}
|
|
2941
|
+
},
|
|
2942
|
+
writableAborted: {
|
|
2943
|
+
__proto__: null,
|
|
2944
|
+
enumerable: false,
|
|
2945
|
+
get: function() {
|
|
2946
|
+
return !!(this._writableState.writable !== false && (this._writableState.destroyed || this._writableState.errored) && !this._writableState.finished);
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
});
|
|
2950
|
+
const destroy = destroyImpl.destroy;
|
|
2951
|
+
Writable.prototype.destroy = function(err, cb) {
|
|
2952
|
+
const state = this._writableState;
|
|
2953
|
+
if (!state.destroyed && (state.bufferedIndex < state.buffered.length || state[kOnFinished].length)) process.nextTick(errorBuffer, state);
|
|
2954
|
+
destroy.call(this, err, cb);
|
|
2955
|
+
return this;
|
|
2956
|
+
};
|
|
2957
|
+
Writable.prototype._undestroy = destroyImpl.undestroy;
|
|
2958
|
+
Writable.prototype._destroy = function(err, cb) {
|
|
2959
|
+
cb(err);
|
|
2960
|
+
};
|
|
2961
|
+
Writable.prototype[EE.captureRejectionSymbol] = function(err) {
|
|
2962
|
+
this.destroy(err);
|
|
2963
|
+
};
|
|
2964
|
+
let webStreamsAdapters;
|
|
2965
|
+
function lazyWebStreams() {
|
|
2966
|
+
if (webStreamsAdapters === void 0) webStreamsAdapters = {};
|
|
2967
|
+
return webStreamsAdapters;
|
|
2968
|
+
}
|
|
2969
|
+
Writable.fromWeb = function(writableStream, options) {
|
|
2970
|
+
return lazyWebStreams().newStreamWritableFromWritableStream(writableStream, options);
|
|
2971
|
+
};
|
|
2972
|
+
Writable.toWeb = function(streamWritable) {
|
|
2973
|
+
return lazyWebStreams().newWritableStreamFromStreamWritable(streamWritable);
|
|
2974
|
+
};
|
|
2975
|
+
}));
|
|
2976
|
+
//#endregion
|
|
2977
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/duplexify.js
|
|
2978
|
+
var require_duplexify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2979
|
+
const process = require_process();
|
|
2980
|
+
const bufferModule = require__require_as_import_buffer();
|
|
2981
|
+
const { isReadable, isWritable, isIterable, isNodeStream, isReadableNodeStream, isWritableNodeStream, isDuplexNodeStream, isReadableStream, isWritableStream } = require_utils();
|
|
2982
|
+
const eos = require_end_of_stream();
|
|
2983
|
+
const { AbortError, codes: { ERR_INVALID_ARG_TYPE, ERR_INVALID_RETURN_VALUE } } = require_errors();
|
|
2984
|
+
const { destroyer } = require_destroy();
|
|
2985
|
+
const Duplex = require_duplex();
|
|
2986
|
+
const Readable = require_readable();
|
|
2987
|
+
const Writable = require_writable();
|
|
2988
|
+
const { createDeferredPromise } = require_util();
|
|
2989
|
+
const from = require_from();
|
|
2990
|
+
const Blob = globalThis.Blob || bufferModule.Blob;
|
|
2991
|
+
const isBlob = typeof Blob !== "undefined" ? function isBlob(b) {
|
|
2992
|
+
return b instanceof Blob;
|
|
2993
|
+
} : function isBlob(b) {
|
|
2994
|
+
return false;
|
|
2995
|
+
};
|
|
2996
|
+
const AbortController = globalThis.AbortController || require__empty_module().AbortController;
|
|
2997
|
+
const { FunctionPrototypeCall } = require_primordials();
|
|
2998
|
+
var Duplexify = class extends Duplex {
|
|
2999
|
+
constructor(options) {
|
|
3000
|
+
super(options);
|
|
3001
|
+
if ((options === null || options === void 0 ? void 0 : options.readable) === false) {
|
|
3002
|
+
this._readableState.readable = false;
|
|
3003
|
+
this._readableState.ended = true;
|
|
3004
|
+
this._readableState.endEmitted = true;
|
|
3005
|
+
}
|
|
3006
|
+
if ((options === null || options === void 0 ? void 0 : options.writable) === false) {
|
|
3007
|
+
this._writableState.writable = false;
|
|
3008
|
+
this._writableState.ending = true;
|
|
3009
|
+
this._writableState.ended = true;
|
|
3010
|
+
this._writableState.finished = true;
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
};
|
|
3014
|
+
module.exports = function duplexify(body, name) {
|
|
3015
|
+
if (isDuplexNodeStream(body)) return body;
|
|
3016
|
+
if (isReadableNodeStream(body)) return _duplexify({ readable: body });
|
|
3017
|
+
if (isWritableNodeStream(body)) return _duplexify({ writable: body });
|
|
3018
|
+
if (isNodeStream(body)) return _duplexify({
|
|
3019
|
+
writable: false,
|
|
3020
|
+
readable: false
|
|
3021
|
+
});
|
|
3022
|
+
if (isReadableStream(body)) return _duplexify({ readable: Readable.fromWeb(body) });
|
|
3023
|
+
if (isWritableStream(body)) return _duplexify({ writable: Writable.fromWeb(body) });
|
|
3024
|
+
if (typeof body === "function") {
|
|
3025
|
+
const { value, write, final, destroy } = fromAsyncGen(body);
|
|
3026
|
+
if (isIterable(value)) return from(Duplexify, value, {
|
|
3027
|
+
objectMode: true,
|
|
3028
|
+
write,
|
|
3029
|
+
final,
|
|
3030
|
+
destroy
|
|
3031
|
+
});
|
|
3032
|
+
const then = value === null || value === void 0 ? void 0 : value.then;
|
|
3033
|
+
if (typeof then === "function") {
|
|
3034
|
+
let d;
|
|
3035
|
+
const promise = FunctionPrototypeCall(then, value, (val) => {
|
|
3036
|
+
if (val != null) throw new ERR_INVALID_RETURN_VALUE("nully", "body", val);
|
|
3037
|
+
}, (err) => {
|
|
3038
|
+
destroyer(d, err);
|
|
3039
|
+
});
|
|
3040
|
+
return d = new Duplexify({
|
|
3041
|
+
objectMode: true,
|
|
3042
|
+
readable: false,
|
|
3043
|
+
write,
|
|
3044
|
+
final(cb) {
|
|
3045
|
+
final(async () => {
|
|
3046
|
+
try {
|
|
3047
|
+
await promise;
|
|
3048
|
+
process.nextTick(cb, null);
|
|
3049
|
+
} catch (err) {
|
|
3050
|
+
process.nextTick(cb, err);
|
|
3051
|
+
}
|
|
3052
|
+
});
|
|
3053
|
+
},
|
|
3054
|
+
destroy
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
3057
|
+
throw new ERR_INVALID_RETURN_VALUE("Iterable, AsyncIterable or AsyncFunction", name, value);
|
|
3058
|
+
}
|
|
3059
|
+
if (isBlob(body)) return duplexify(body.arrayBuffer());
|
|
3060
|
+
if (isIterable(body)) return from(Duplexify, body, {
|
|
3061
|
+
objectMode: true,
|
|
3062
|
+
writable: false
|
|
3063
|
+
});
|
|
3064
|
+
if (isReadableStream(body === null || body === void 0 ? void 0 : body.readable) && isWritableStream(body === null || body === void 0 ? void 0 : body.writable)) return Duplexify.fromWeb(body);
|
|
3065
|
+
if (typeof (body === null || body === void 0 ? void 0 : body.writable) === "object" || typeof (body === null || body === void 0 ? void 0 : body.readable) === "object") return _duplexify({
|
|
3066
|
+
readable: body !== null && body !== void 0 && body.readable ? isReadableNodeStream(body === null || body === void 0 ? void 0 : body.readable) ? body === null || body === void 0 ? void 0 : body.readable : duplexify(body.readable) : void 0,
|
|
3067
|
+
writable: body !== null && body !== void 0 && body.writable ? isWritableNodeStream(body === null || body === void 0 ? void 0 : body.writable) ? body === null || body === void 0 ? void 0 : body.writable : duplexify(body.writable) : void 0
|
|
3068
|
+
});
|
|
3069
|
+
const then = body === null || body === void 0 ? void 0 : body.then;
|
|
3070
|
+
if (typeof then === "function") {
|
|
3071
|
+
let d;
|
|
3072
|
+
FunctionPrototypeCall(then, body, (val) => {
|
|
3073
|
+
if (val != null) d.push(val);
|
|
3074
|
+
d.push(null);
|
|
3075
|
+
}, (err) => {
|
|
3076
|
+
destroyer(d, err);
|
|
3077
|
+
});
|
|
3078
|
+
return d = new Duplexify({
|
|
3079
|
+
objectMode: true,
|
|
3080
|
+
writable: false,
|
|
3081
|
+
read() {}
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
throw new ERR_INVALID_ARG_TYPE(name, [
|
|
3085
|
+
"Blob",
|
|
3086
|
+
"ReadableStream",
|
|
3087
|
+
"WritableStream",
|
|
3088
|
+
"Stream",
|
|
3089
|
+
"Iterable",
|
|
3090
|
+
"AsyncIterable",
|
|
3091
|
+
"Function",
|
|
3092
|
+
"{ readable, writable } pair",
|
|
3093
|
+
"Promise"
|
|
3094
|
+
], body);
|
|
3095
|
+
};
|
|
3096
|
+
function fromAsyncGen(fn) {
|
|
3097
|
+
let { promise, resolve } = createDeferredPromise();
|
|
3098
|
+
const ac = new AbortController();
|
|
3099
|
+
const signal = ac.signal;
|
|
3100
|
+
return {
|
|
3101
|
+
value: fn((async function* () {
|
|
3102
|
+
while (true) {
|
|
3103
|
+
const _promise = promise;
|
|
3104
|
+
promise = null;
|
|
3105
|
+
const { chunk, done, cb } = await _promise;
|
|
3106
|
+
process.nextTick(cb);
|
|
3107
|
+
if (done) return;
|
|
3108
|
+
if (signal.aborted) throw new AbortError(void 0, { cause: signal.reason });
|
|
3109
|
+
({promise, resolve} = createDeferredPromise());
|
|
3110
|
+
yield chunk;
|
|
3111
|
+
}
|
|
3112
|
+
})(), { signal }),
|
|
3113
|
+
write(chunk, encoding, cb) {
|
|
3114
|
+
const _resolve = resolve;
|
|
3115
|
+
resolve = null;
|
|
3116
|
+
_resolve({
|
|
3117
|
+
chunk,
|
|
3118
|
+
done: false,
|
|
3119
|
+
cb
|
|
3120
|
+
});
|
|
3121
|
+
},
|
|
3122
|
+
final(cb) {
|
|
3123
|
+
const _resolve = resolve;
|
|
3124
|
+
resolve = null;
|
|
3125
|
+
_resolve({
|
|
3126
|
+
done: true,
|
|
3127
|
+
cb
|
|
3128
|
+
});
|
|
3129
|
+
},
|
|
3130
|
+
destroy(err, cb) {
|
|
3131
|
+
ac.abort();
|
|
3132
|
+
cb(err);
|
|
3133
|
+
}
|
|
3134
|
+
};
|
|
3135
|
+
}
|
|
3136
|
+
function _duplexify(pair) {
|
|
3137
|
+
const r = pair.readable && typeof pair.readable.read !== "function" ? Readable.wrap(pair.readable) : pair.readable;
|
|
3138
|
+
const w = pair.writable;
|
|
3139
|
+
let readable = !!isReadable(r);
|
|
3140
|
+
let writable = !!isWritable(w);
|
|
3141
|
+
let ondrain;
|
|
3142
|
+
let onfinish;
|
|
3143
|
+
let onreadable;
|
|
3144
|
+
let onclose;
|
|
3145
|
+
let d;
|
|
3146
|
+
function onfinished(err) {
|
|
3147
|
+
const cb = onclose;
|
|
3148
|
+
onclose = null;
|
|
3149
|
+
if (cb) cb(err);
|
|
3150
|
+
else if (err) d.destroy(err);
|
|
3151
|
+
}
|
|
3152
|
+
d = new Duplexify({
|
|
3153
|
+
readableObjectMode: !!(r !== null && r !== void 0 && r.readableObjectMode),
|
|
3154
|
+
writableObjectMode: !!(w !== null && w !== void 0 && w.writableObjectMode),
|
|
3155
|
+
readable,
|
|
3156
|
+
writable
|
|
3157
|
+
});
|
|
3158
|
+
if (writable) {
|
|
3159
|
+
eos(w, (err) => {
|
|
3160
|
+
writable = false;
|
|
3161
|
+
if (err) destroyer(r, err);
|
|
3162
|
+
onfinished(err);
|
|
3163
|
+
});
|
|
3164
|
+
d._write = function(chunk, encoding, callback) {
|
|
3165
|
+
if (w.write(chunk, encoding)) callback();
|
|
3166
|
+
else ondrain = callback;
|
|
3167
|
+
};
|
|
3168
|
+
d._final = function(callback) {
|
|
3169
|
+
w.end();
|
|
3170
|
+
onfinish = callback;
|
|
3171
|
+
};
|
|
3172
|
+
w.on("drain", function() {
|
|
3173
|
+
if (ondrain) {
|
|
3174
|
+
const cb = ondrain;
|
|
3175
|
+
ondrain = null;
|
|
3176
|
+
cb();
|
|
3177
|
+
}
|
|
3178
|
+
});
|
|
3179
|
+
w.on("finish", function() {
|
|
3180
|
+
if (onfinish) {
|
|
3181
|
+
const cb = onfinish;
|
|
3182
|
+
onfinish = null;
|
|
3183
|
+
cb();
|
|
3184
|
+
}
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
if (readable) {
|
|
3188
|
+
eos(r, (err) => {
|
|
3189
|
+
readable = false;
|
|
3190
|
+
if (err) destroyer(r, err);
|
|
3191
|
+
onfinished(err);
|
|
3192
|
+
});
|
|
3193
|
+
r.on("readable", function() {
|
|
3194
|
+
if (onreadable) {
|
|
3195
|
+
const cb = onreadable;
|
|
3196
|
+
onreadable = null;
|
|
3197
|
+
cb();
|
|
3198
|
+
}
|
|
3199
|
+
});
|
|
3200
|
+
r.on("end", function() {
|
|
3201
|
+
d.push(null);
|
|
3202
|
+
});
|
|
3203
|
+
d._read = function() {
|
|
3204
|
+
while (true) {
|
|
3205
|
+
const buf = r.read();
|
|
3206
|
+
if (buf === null) {
|
|
3207
|
+
onreadable = d._read;
|
|
3208
|
+
return;
|
|
3209
|
+
}
|
|
3210
|
+
if (!d.push(buf)) return;
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3214
|
+
d._destroy = function(err, callback) {
|
|
3215
|
+
if (!err && onclose !== null) err = new AbortError();
|
|
3216
|
+
onreadable = null;
|
|
3217
|
+
ondrain = null;
|
|
3218
|
+
onfinish = null;
|
|
3219
|
+
if (onclose === null) callback(err);
|
|
3220
|
+
else {
|
|
3221
|
+
onclose = callback;
|
|
3222
|
+
destroyer(w, err);
|
|
3223
|
+
destroyer(r, err);
|
|
3224
|
+
}
|
|
3225
|
+
};
|
|
3226
|
+
return d;
|
|
3227
|
+
}
|
|
3228
|
+
}));
|
|
3229
|
+
//#endregion
|
|
3230
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/duplex.js
|
|
3231
|
+
var require_duplex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3232
|
+
const { ObjectDefineProperties, ObjectGetOwnPropertyDescriptor, ObjectKeys, ObjectSetPrototypeOf } = require_primordials();
|
|
3233
|
+
module.exports = Duplex;
|
|
3234
|
+
const Readable = require_readable();
|
|
3235
|
+
const Writable = require_writable();
|
|
3236
|
+
ObjectSetPrototypeOf(Duplex.prototype, Readable.prototype);
|
|
3237
|
+
ObjectSetPrototypeOf(Duplex, Readable);
|
|
3238
|
+
{
|
|
3239
|
+
const keys = ObjectKeys(Writable.prototype);
|
|
3240
|
+
for (let i = 0; i < keys.length; i++) {
|
|
3241
|
+
const method = keys[i];
|
|
3242
|
+
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
function Duplex(options) {
|
|
3246
|
+
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
3247
|
+
Readable.call(this, options);
|
|
3248
|
+
Writable.call(this, options);
|
|
3249
|
+
if (options) {
|
|
3250
|
+
this.allowHalfOpen = options.allowHalfOpen !== false;
|
|
3251
|
+
if (options.readable === false) {
|
|
3252
|
+
this._readableState.readable = false;
|
|
3253
|
+
this._readableState.ended = true;
|
|
3254
|
+
this._readableState.endEmitted = true;
|
|
3255
|
+
}
|
|
3256
|
+
if (options.writable === false) {
|
|
3257
|
+
this._writableState.writable = false;
|
|
3258
|
+
this._writableState.ending = true;
|
|
3259
|
+
this._writableState.ended = true;
|
|
3260
|
+
this._writableState.finished = true;
|
|
3261
|
+
}
|
|
3262
|
+
} else this.allowHalfOpen = true;
|
|
3263
|
+
}
|
|
3264
|
+
ObjectDefineProperties(Duplex.prototype, {
|
|
3265
|
+
writable: {
|
|
3266
|
+
__proto__: null,
|
|
3267
|
+
...ObjectGetOwnPropertyDescriptor(Writable.prototype, "writable")
|
|
3268
|
+
},
|
|
3269
|
+
writableHighWaterMark: {
|
|
3270
|
+
__proto__: null,
|
|
3271
|
+
...ObjectGetOwnPropertyDescriptor(Writable.prototype, "writableHighWaterMark")
|
|
3272
|
+
},
|
|
3273
|
+
writableObjectMode: {
|
|
3274
|
+
__proto__: null,
|
|
3275
|
+
...ObjectGetOwnPropertyDescriptor(Writable.prototype, "writableObjectMode")
|
|
3276
|
+
},
|
|
3277
|
+
writableBuffer: {
|
|
3278
|
+
__proto__: null,
|
|
3279
|
+
...ObjectGetOwnPropertyDescriptor(Writable.prototype, "writableBuffer")
|
|
3280
|
+
},
|
|
3281
|
+
writableLength: {
|
|
3282
|
+
__proto__: null,
|
|
3283
|
+
...ObjectGetOwnPropertyDescriptor(Writable.prototype, "writableLength")
|
|
3284
|
+
},
|
|
3285
|
+
writableFinished: {
|
|
3286
|
+
__proto__: null,
|
|
3287
|
+
...ObjectGetOwnPropertyDescriptor(Writable.prototype, "writableFinished")
|
|
3288
|
+
},
|
|
3289
|
+
writableCorked: {
|
|
3290
|
+
__proto__: null,
|
|
3291
|
+
...ObjectGetOwnPropertyDescriptor(Writable.prototype, "writableCorked")
|
|
3292
|
+
},
|
|
3293
|
+
writableEnded: {
|
|
3294
|
+
__proto__: null,
|
|
3295
|
+
...ObjectGetOwnPropertyDescriptor(Writable.prototype, "writableEnded")
|
|
3296
|
+
},
|
|
3297
|
+
writableNeedDrain: {
|
|
3298
|
+
__proto__: null,
|
|
3299
|
+
...ObjectGetOwnPropertyDescriptor(Writable.prototype, "writableNeedDrain")
|
|
3300
|
+
},
|
|
3301
|
+
destroyed: {
|
|
3302
|
+
__proto__: null,
|
|
3303
|
+
get() {
|
|
3304
|
+
if (this._readableState === void 0 || this._writableState === void 0) return false;
|
|
3305
|
+
return this._readableState.destroyed && this._writableState.destroyed;
|
|
3306
|
+
},
|
|
3307
|
+
set(value) {
|
|
3308
|
+
if (this._readableState && this._writableState) {
|
|
3309
|
+
this._readableState.destroyed = value;
|
|
3310
|
+
this._writableState.destroyed = value;
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
});
|
|
3315
|
+
let webStreamsAdapters;
|
|
3316
|
+
function lazyWebStreams() {
|
|
3317
|
+
if (webStreamsAdapters === void 0) webStreamsAdapters = {};
|
|
3318
|
+
return webStreamsAdapters;
|
|
3319
|
+
}
|
|
3320
|
+
Duplex.fromWeb = function(pair, options) {
|
|
3321
|
+
return lazyWebStreams().newStreamDuplexFromReadableWritablePair(pair, options);
|
|
3322
|
+
};
|
|
3323
|
+
Duplex.toWeb = function(duplex) {
|
|
3324
|
+
return lazyWebStreams().newReadableWritablePairFromDuplex(duplex);
|
|
3325
|
+
};
|
|
3326
|
+
let duplexify;
|
|
3327
|
+
Duplex.from = function(body) {
|
|
3328
|
+
if (!duplexify) duplexify = require_duplexify();
|
|
3329
|
+
return duplexify(body, "body");
|
|
3330
|
+
};
|
|
3331
|
+
}));
|
|
3332
|
+
//#endregion
|
|
3333
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/transform.js
|
|
3334
|
+
var require_transform = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3335
|
+
const { ObjectSetPrototypeOf, Symbol } = require_primordials();
|
|
3336
|
+
module.exports = Transform;
|
|
3337
|
+
const { ERR_METHOD_NOT_IMPLEMENTED } = require_errors().codes;
|
|
3338
|
+
const Duplex = require_duplex();
|
|
3339
|
+
const { getHighWaterMark } = require_state();
|
|
3340
|
+
ObjectSetPrototypeOf(Transform.prototype, Duplex.prototype);
|
|
3341
|
+
ObjectSetPrototypeOf(Transform, Duplex);
|
|
3342
|
+
const kCallback = Symbol("kCallback");
|
|
3343
|
+
function Transform(options) {
|
|
3344
|
+
if (!(this instanceof Transform)) return new Transform(options);
|
|
3345
|
+
const readableHighWaterMark = options ? getHighWaterMark(this, options, "readableHighWaterMark", true) : null;
|
|
3346
|
+
if (readableHighWaterMark === 0) options = {
|
|
3347
|
+
...options,
|
|
3348
|
+
highWaterMark: null,
|
|
3349
|
+
readableHighWaterMark,
|
|
3350
|
+
writableHighWaterMark: options.writableHighWaterMark || 0
|
|
3351
|
+
};
|
|
3352
|
+
Duplex.call(this, options);
|
|
3353
|
+
this._readableState.sync = false;
|
|
3354
|
+
this[kCallback] = null;
|
|
3355
|
+
if (options) {
|
|
3356
|
+
if (typeof options.transform === "function") this._transform = options.transform;
|
|
3357
|
+
if (typeof options.flush === "function") this._flush = options.flush;
|
|
3358
|
+
}
|
|
3359
|
+
this.on("prefinish", prefinish);
|
|
3360
|
+
}
|
|
3361
|
+
function final(cb) {
|
|
3362
|
+
if (typeof this._flush === "function" && !this.destroyed) this._flush((er, data) => {
|
|
3363
|
+
if (er) {
|
|
3364
|
+
if (cb) cb(er);
|
|
3365
|
+
else this.destroy(er);
|
|
3366
|
+
return;
|
|
3367
|
+
}
|
|
3368
|
+
if (data != null) this.push(data);
|
|
3369
|
+
this.push(null);
|
|
3370
|
+
if (cb) cb();
|
|
3371
|
+
});
|
|
3372
|
+
else {
|
|
3373
|
+
this.push(null);
|
|
3374
|
+
if (cb) cb();
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
function prefinish() {
|
|
3378
|
+
if (this._final !== final) final.call(this);
|
|
3379
|
+
}
|
|
3380
|
+
Transform.prototype._final = final;
|
|
3381
|
+
Transform.prototype._transform = function(chunk, encoding, callback) {
|
|
3382
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("_transform()");
|
|
3383
|
+
};
|
|
3384
|
+
Transform.prototype._write = function(chunk, encoding, callback) {
|
|
3385
|
+
const rState = this._readableState;
|
|
3386
|
+
const wState = this._writableState;
|
|
3387
|
+
const length = rState.length;
|
|
3388
|
+
this._transform(chunk, encoding, (err, val) => {
|
|
3389
|
+
if (err) {
|
|
3390
|
+
callback(err);
|
|
3391
|
+
return;
|
|
3392
|
+
}
|
|
3393
|
+
if (val != null) this.push(val);
|
|
3394
|
+
if (wState.ended || length === rState.length || rState.length < rState.highWaterMark) callback();
|
|
3395
|
+
else this[kCallback] = callback;
|
|
3396
|
+
});
|
|
3397
|
+
};
|
|
3398
|
+
Transform.prototype._read = function() {
|
|
3399
|
+
if (this[kCallback]) {
|
|
3400
|
+
const callback = this[kCallback];
|
|
3401
|
+
this[kCallback] = null;
|
|
3402
|
+
callback();
|
|
3403
|
+
}
|
|
3404
|
+
};
|
|
3405
|
+
}));
|
|
3406
|
+
//#endregion
|
|
3407
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/passthrough.js
|
|
3408
|
+
var require_passthrough = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3409
|
+
const { ObjectSetPrototypeOf } = require_primordials();
|
|
3410
|
+
module.exports = PassThrough;
|
|
3411
|
+
const Transform = require_transform();
|
|
3412
|
+
ObjectSetPrototypeOf(PassThrough.prototype, Transform.prototype);
|
|
3413
|
+
ObjectSetPrototypeOf(PassThrough, Transform);
|
|
3414
|
+
function PassThrough(options) {
|
|
3415
|
+
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
|
3416
|
+
Transform.call(this, options);
|
|
3417
|
+
}
|
|
3418
|
+
PassThrough.prototype._transform = function(chunk, encoding, cb) {
|
|
3419
|
+
cb(null, chunk);
|
|
3420
|
+
};
|
|
3421
|
+
}));
|
|
3422
|
+
//#endregion
|
|
3423
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/pipeline.js
|
|
3424
|
+
var require_pipeline = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3425
|
+
const process = require_process();
|
|
3426
|
+
const { ArrayIsArray, Promise, SymbolAsyncIterator, SymbolDispose } = require_primordials();
|
|
3427
|
+
const eos = require_end_of_stream();
|
|
3428
|
+
const { once } = require_util();
|
|
3429
|
+
const destroyImpl = require_destroy();
|
|
3430
|
+
const Duplex = require_duplex();
|
|
3431
|
+
const { aggregateTwoErrors, codes: { ERR_INVALID_ARG_TYPE, ERR_INVALID_RETURN_VALUE, ERR_MISSING_ARGS, ERR_STREAM_DESTROYED, ERR_STREAM_PREMATURE_CLOSE }, AbortError } = require_errors();
|
|
3432
|
+
const { validateFunction, validateAbortSignal } = require_validators();
|
|
3433
|
+
const { isIterable, isReadable, isReadableNodeStream, isNodeStream, isTransformStream, isWebStream, isReadableStream, isReadableFinished } = require_utils();
|
|
3434
|
+
const AbortController = globalThis.AbortController || require__empty_module().AbortController;
|
|
3435
|
+
let PassThrough;
|
|
3436
|
+
let Readable;
|
|
3437
|
+
let addAbortListener;
|
|
3438
|
+
function destroyer(stream, reading, writing) {
|
|
3439
|
+
let finished = false;
|
|
3440
|
+
stream.on("close", () => {
|
|
3441
|
+
finished = true;
|
|
3442
|
+
});
|
|
3443
|
+
return {
|
|
3444
|
+
destroy: (err) => {
|
|
3445
|
+
if (finished) return;
|
|
3446
|
+
finished = true;
|
|
3447
|
+
destroyImpl.destroyer(stream, err || new ERR_STREAM_DESTROYED("pipe"));
|
|
3448
|
+
},
|
|
3449
|
+
cleanup: eos(stream, {
|
|
3450
|
+
readable: reading,
|
|
3451
|
+
writable: writing
|
|
3452
|
+
}, (err) => {
|
|
3453
|
+
finished = !err;
|
|
3454
|
+
})
|
|
3455
|
+
};
|
|
3456
|
+
}
|
|
3457
|
+
function popCallback(streams) {
|
|
3458
|
+
validateFunction(streams[streams.length - 1], "streams[stream.length - 1]");
|
|
3459
|
+
return streams.pop();
|
|
3460
|
+
}
|
|
3461
|
+
function makeAsyncIterable(val) {
|
|
3462
|
+
if (isIterable(val)) return val;
|
|
3463
|
+
else if (isReadableNodeStream(val)) return fromReadable(val);
|
|
3464
|
+
throw new ERR_INVALID_ARG_TYPE("val", [
|
|
3465
|
+
"Readable",
|
|
3466
|
+
"Iterable",
|
|
3467
|
+
"AsyncIterable"
|
|
3468
|
+
], val);
|
|
3469
|
+
}
|
|
3470
|
+
async function* fromReadable(val) {
|
|
3471
|
+
if (!Readable) Readable = require_readable();
|
|
3472
|
+
yield* Readable.prototype[SymbolAsyncIterator].call(val);
|
|
3473
|
+
}
|
|
3474
|
+
async function pumpToNode(iterable, writable, finish, { end }) {
|
|
3475
|
+
let error;
|
|
3476
|
+
let onresolve = null;
|
|
3477
|
+
const resume = (err) => {
|
|
3478
|
+
if (err) error = err;
|
|
3479
|
+
if (onresolve) {
|
|
3480
|
+
const callback = onresolve;
|
|
3481
|
+
onresolve = null;
|
|
3482
|
+
callback();
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
const wait = () => new Promise((resolve, reject) => {
|
|
3486
|
+
if (error) reject(error);
|
|
3487
|
+
else onresolve = () => {
|
|
3488
|
+
if (error) reject(error);
|
|
3489
|
+
else resolve();
|
|
3490
|
+
};
|
|
3491
|
+
});
|
|
3492
|
+
writable.on("drain", resume);
|
|
3493
|
+
const cleanup = eos(writable, { readable: false }, resume);
|
|
3494
|
+
try {
|
|
3495
|
+
if (writable.writableNeedDrain) await wait();
|
|
3496
|
+
for await (const chunk of iterable) if (!writable.write(chunk)) await wait();
|
|
3497
|
+
if (end) {
|
|
3498
|
+
writable.end();
|
|
3499
|
+
await wait();
|
|
3500
|
+
}
|
|
3501
|
+
finish();
|
|
3502
|
+
} catch (err) {
|
|
3503
|
+
finish(error !== err ? aggregateTwoErrors(error, err) : err);
|
|
3504
|
+
} finally {
|
|
3505
|
+
cleanup();
|
|
3506
|
+
writable.off("drain", resume);
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
async function pumpToWeb(readable, writable, finish, { end }) {
|
|
3510
|
+
if (isTransformStream(writable)) writable = writable.writable;
|
|
3511
|
+
const writer = writable.getWriter();
|
|
3512
|
+
try {
|
|
3513
|
+
for await (const chunk of readable) {
|
|
3514
|
+
await writer.ready;
|
|
3515
|
+
writer.write(chunk).catch(() => {});
|
|
3516
|
+
}
|
|
3517
|
+
await writer.ready;
|
|
3518
|
+
if (end) await writer.close();
|
|
3519
|
+
finish();
|
|
3520
|
+
} catch (err) {
|
|
3521
|
+
try {
|
|
3522
|
+
await writer.abort(err);
|
|
3523
|
+
finish(err);
|
|
3524
|
+
} catch (err) {
|
|
3525
|
+
finish(err);
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
function pipeline(...streams) {
|
|
3530
|
+
return pipelineImpl(streams, once(popCallback(streams)));
|
|
3531
|
+
}
|
|
3532
|
+
function pipelineImpl(streams, callback, opts) {
|
|
3533
|
+
if (streams.length === 1 && ArrayIsArray(streams[0])) streams = streams[0];
|
|
3534
|
+
if (streams.length < 2) throw new ERR_MISSING_ARGS("streams");
|
|
3535
|
+
const ac = new AbortController();
|
|
3536
|
+
const signal = ac.signal;
|
|
3537
|
+
const outerSignal = opts === null || opts === void 0 ? void 0 : opts.signal;
|
|
3538
|
+
const lastStreamCleanup = [];
|
|
3539
|
+
validateAbortSignal(outerSignal, "options.signal");
|
|
3540
|
+
function abort() {
|
|
3541
|
+
finishImpl(new AbortError());
|
|
3542
|
+
}
|
|
3543
|
+
addAbortListener = addAbortListener || require_util().addAbortListener;
|
|
3544
|
+
let disposable;
|
|
3545
|
+
if (outerSignal) disposable = addAbortListener(outerSignal, abort);
|
|
3546
|
+
let error;
|
|
3547
|
+
let value;
|
|
3548
|
+
const destroys = [];
|
|
3549
|
+
let finishCount = 0;
|
|
3550
|
+
function finish(err) {
|
|
3551
|
+
finishImpl(err, --finishCount === 0);
|
|
3552
|
+
}
|
|
3553
|
+
function finishImpl(err, final) {
|
|
3554
|
+
var _disposable;
|
|
3555
|
+
if (err && (!error || error.code === "ERR_STREAM_PREMATURE_CLOSE")) error = err;
|
|
3556
|
+
if (!error && !final) return;
|
|
3557
|
+
while (destroys.length) destroys.shift()(error);
|
|
3558
|
+
(_disposable = disposable) === null || _disposable === void 0 || _disposable[SymbolDispose]();
|
|
3559
|
+
ac.abort();
|
|
3560
|
+
if (final) {
|
|
3561
|
+
if (!error) lastStreamCleanup.forEach((fn) => fn());
|
|
3562
|
+
process.nextTick(callback, error, value);
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
let ret;
|
|
3566
|
+
for (let i = 0; i < streams.length; i++) {
|
|
3567
|
+
const stream = streams[i];
|
|
3568
|
+
const reading = i < streams.length - 1;
|
|
3569
|
+
const writing = i > 0;
|
|
3570
|
+
const end = reading || (opts === null || opts === void 0 ? void 0 : opts.end) !== false;
|
|
3571
|
+
const isLastStream = i === streams.length - 1;
|
|
3572
|
+
if (isNodeStream(stream)) {
|
|
3573
|
+
if (end) {
|
|
3574
|
+
const { destroy, cleanup } = destroyer(stream, reading, writing);
|
|
3575
|
+
destroys.push(destroy);
|
|
3576
|
+
if (isReadable(stream) && isLastStream) lastStreamCleanup.push(cleanup);
|
|
3577
|
+
}
|
|
3578
|
+
function onError(err) {
|
|
3579
|
+
if (err && err.name !== "AbortError" && err.code !== "ERR_STREAM_PREMATURE_CLOSE") finish(err);
|
|
3580
|
+
}
|
|
3581
|
+
stream.on("error", onError);
|
|
3582
|
+
if (isReadable(stream) && isLastStream) lastStreamCleanup.push(() => {
|
|
3583
|
+
stream.removeListener("error", onError);
|
|
3584
|
+
});
|
|
3585
|
+
}
|
|
3586
|
+
if (i === 0) {
|
|
3587
|
+
if (typeof stream === "function") {
|
|
3588
|
+
ret = stream({ signal });
|
|
3589
|
+
if (!isIterable(ret)) throw new ERR_INVALID_RETURN_VALUE("Iterable, AsyncIterable or Stream", "source", ret);
|
|
3590
|
+
} else if (isIterable(stream) || isReadableNodeStream(stream) || isTransformStream(stream)) ret = stream;
|
|
3591
|
+
else ret = Duplex.from(stream);
|
|
3592
|
+
} else if (typeof stream === "function") {
|
|
3593
|
+
if (isTransformStream(ret)) {
|
|
3594
|
+
var _ret;
|
|
3595
|
+
ret = makeAsyncIterable((_ret = ret) === null || _ret === void 0 ? void 0 : _ret.readable);
|
|
3596
|
+
} else ret = makeAsyncIterable(ret);
|
|
3597
|
+
ret = stream(ret, { signal });
|
|
3598
|
+
if (reading) {
|
|
3599
|
+
if (!isIterable(ret, true)) throw new ERR_INVALID_RETURN_VALUE("AsyncIterable", `transform[${i - 1}]`, ret);
|
|
3600
|
+
} else {
|
|
3601
|
+
var _ret2;
|
|
3602
|
+
if (!PassThrough) PassThrough = require_passthrough();
|
|
3603
|
+
const pt = new PassThrough({ objectMode: true });
|
|
3604
|
+
const then = (_ret2 = ret) === null || _ret2 === void 0 ? void 0 : _ret2.then;
|
|
3605
|
+
if (typeof then === "function") {
|
|
3606
|
+
finishCount++;
|
|
3607
|
+
then.call(ret, (val) => {
|
|
3608
|
+
value = val;
|
|
3609
|
+
if (val != null) pt.write(val);
|
|
3610
|
+
if (end) pt.end();
|
|
3611
|
+
process.nextTick(finish);
|
|
3612
|
+
}, (err) => {
|
|
3613
|
+
pt.destroy(err);
|
|
3614
|
+
process.nextTick(finish, err);
|
|
3615
|
+
});
|
|
3616
|
+
} else if (isIterable(ret, true)) {
|
|
3617
|
+
finishCount++;
|
|
3618
|
+
pumpToNode(ret, pt, finish, { end });
|
|
3619
|
+
} else if (isReadableStream(ret) || isTransformStream(ret)) {
|
|
3620
|
+
const toRead = ret.readable || ret;
|
|
3621
|
+
finishCount++;
|
|
3622
|
+
pumpToNode(toRead, pt, finish, { end });
|
|
3623
|
+
} else throw new ERR_INVALID_RETURN_VALUE("AsyncIterable or Promise", "destination", ret);
|
|
3624
|
+
ret = pt;
|
|
3625
|
+
const { destroy, cleanup } = destroyer(ret, false, true);
|
|
3626
|
+
destroys.push(destroy);
|
|
3627
|
+
if (isLastStream) lastStreamCleanup.push(cleanup);
|
|
3628
|
+
}
|
|
3629
|
+
} else if (isNodeStream(stream)) {
|
|
3630
|
+
if (isReadableNodeStream(ret)) {
|
|
3631
|
+
finishCount += 2;
|
|
3632
|
+
const cleanup = pipe(ret, stream, finish, { end });
|
|
3633
|
+
if (isReadable(stream) && isLastStream) lastStreamCleanup.push(cleanup);
|
|
3634
|
+
} else if (isTransformStream(ret) || isReadableStream(ret)) {
|
|
3635
|
+
const toRead = ret.readable || ret;
|
|
3636
|
+
finishCount++;
|
|
3637
|
+
pumpToNode(toRead, stream, finish, { end });
|
|
3638
|
+
} else if (isIterable(ret)) {
|
|
3639
|
+
finishCount++;
|
|
3640
|
+
pumpToNode(ret, stream, finish, { end });
|
|
3641
|
+
} else throw new ERR_INVALID_ARG_TYPE("val", [
|
|
3642
|
+
"Readable",
|
|
3643
|
+
"Iterable",
|
|
3644
|
+
"AsyncIterable",
|
|
3645
|
+
"ReadableStream",
|
|
3646
|
+
"TransformStream"
|
|
3647
|
+
], ret);
|
|
3648
|
+
ret = stream;
|
|
3649
|
+
} else if (isWebStream(stream)) {
|
|
3650
|
+
if (isReadableNodeStream(ret)) {
|
|
3651
|
+
finishCount++;
|
|
3652
|
+
pumpToWeb(makeAsyncIterable(ret), stream, finish, { end });
|
|
3653
|
+
} else if (isReadableStream(ret) || isIterable(ret)) {
|
|
3654
|
+
finishCount++;
|
|
3655
|
+
pumpToWeb(ret, stream, finish, { end });
|
|
3656
|
+
} else if (isTransformStream(ret)) {
|
|
3657
|
+
finishCount++;
|
|
3658
|
+
pumpToWeb(ret.readable, stream, finish, { end });
|
|
3659
|
+
} else throw new ERR_INVALID_ARG_TYPE("val", [
|
|
3660
|
+
"Readable",
|
|
3661
|
+
"Iterable",
|
|
3662
|
+
"AsyncIterable",
|
|
3663
|
+
"ReadableStream",
|
|
3664
|
+
"TransformStream"
|
|
3665
|
+
], ret);
|
|
3666
|
+
ret = stream;
|
|
3667
|
+
} else ret = Duplex.from(stream);
|
|
3668
|
+
}
|
|
3669
|
+
if (signal !== null && signal !== void 0 && signal.aborted || outerSignal !== null && outerSignal !== void 0 && outerSignal.aborted) process.nextTick(abort);
|
|
3670
|
+
return ret;
|
|
3671
|
+
}
|
|
3672
|
+
function pipe(src, dst, finish, { end }) {
|
|
3673
|
+
let ended = false;
|
|
3674
|
+
dst.on("close", () => {
|
|
3675
|
+
if (!ended) finish(new ERR_STREAM_PREMATURE_CLOSE());
|
|
3676
|
+
});
|
|
3677
|
+
src.pipe(dst, { end: false });
|
|
3678
|
+
if (end) {
|
|
3679
|
+
function endFn() {
|
|
3680
|
+
ended = true;
|
|
3681
|
+
dst.end();
|
|
3682
|
+
}
|
|
3683
|
+
if (isReadableFinished(src)) process.nextTick(endFn);
|
|
3684
|
+
else src.once("end", endFn);
|
|
3685
|
+
} else finish();
|
|
3686
|
+
eos(src, {
|
|
3687
|
+
readable: true,
|
|
3688
|
+
writable: false
|
|
3689
|
+
}, (err) => {
|
|
3690
|
+
const rState = src._readableState;
|
|
3691
|
+
if (err && err.code === "ERR_STREAM_PREMATURE_CLOSE" && rState && rState.ended && !rState.errored && !rState.errorEmitted) src.once("end", finish).once("error", finish);
|
|
3692
|
+
else finish(err);
|
|
3693
|
+
});
|
|
3694
|
+
return eos(dst, {
|
|
3695
|
+
readable: false,
|
|
3696
|
+
writable: true
|
|
3697
|
+
}, finish);
|
|
3698
|
+
}
|
|
3699
|
+
module.exports = {
|
|
3700
|
+
pipelineImpl,
|
|
3701
|
+
pipeline
|
|
3702
|
+
};
|
|
3703
|
+
}));
|
|
3704
|
+
//#endregion
|
|
3705
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/compose.js
|
|
3706
|
+
var require_compose = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3707
|
+
const { pipeline } = require_pipeline();
|
|
3708
|
+
const Duplex = require_duplex();
|
|
3709
|
+
const { destroyer } = require_destroy();
|
|
3710
|
+
const { isNodeStream, isReadable, isWritable, isWebStream, isTransformStream, isWritableStream, isReadableStream } = require_utils();
|
|
3711
|
+
const { AbortError, codes: { ERR_INVALID_ARG_VALUE, ERR_MISSING_ARGS } } = require_errors();
|
|
3712
|
+
const eos = require_end_of_stream();
|
|
3713
|
+
module.exports = function compose(...streams) {
|
|
3714
|
+
if (streams.length === 0) throw new ERR_MISSING_ARGS("streams");
|
|
3715
|
+
if (streams.length === 1) return Duplex.from(streams[0]);
|
|
3716
|
+
const orgStreams = [...streams];
|
|
3717
|
+
if (typeof streams[0] === "function") streams[0] = Duplex.from(streams[0]);
|
|
3718
|
+
if (typeof streams[streams.length - 1] === "function") {
|
|
3719
|
+
const idx = streams.length - 1;
|
|
3720
|
+
streams[idx] = Duplex.from(streams[idx]);
|
|
3721
|
+
}
|
|
3722
|
+
for (let n = 0; n < streams.length; ++n) {
|
|
3723
|
+
if (!isNodeStream(streams[n]) && !isWebStream(streams[n])) continue;
|
|
3724
|
+
if (n < streams.length - 1 && !(isReadable(streams[n]) || isReadableStream(streams[n]) || isTransformStream(streams[n]))) throw new ERR_INVALID_ARG_VALUE(`streams[${n}]`, orgStreams[n], "must be readable");
|
|
3725
|
+
if (n > 0 && !(isWritable(streams[n]) || isWritableStream(streams[n]) || isTransformStream(streams[n]))) throw new ERR_INVALID_ARG_VALUE(`streams[${n}]`, orgStreams[n], "must be writable");
|
|
3726
|
+
}
|
|
3727
|
+
let ondrain;
|
|
3728
|
+
let onfinish;
|
|
3729
|
+
let onreadable;
|
|
3730
|
+
let onclose;
|
|
3731
|
+
let d;
|
|
3732
|
+
function onfinished(err) {
|
|
3733
|
+
const cb = onclose;
|
|
3734
|
+
onclose = null;
|
|
3735
|
+
if (cb) cb(err);
|
|
3736
|
+
else if (err) d.destroy(err);
|
|
3737
|
+
else if (!readable && !writable) d.destroy();
|
|
3738
|
+
}
|
|
3739
|
+
const head = streams[0];
|
|
3740
|
+
const tail = pipeline(streams, onfinished);
|
|
3741
|
+
const writable = !!(isWritable(head) || isWritableStream(head) || isTransformStream(head));
|
|
3742
|
+
const readable = !!(isReadable(tail) || isReadableStream(tail) || isTransformStream(tail));
|
|
3743
|
+
d = new Duplex({
|
|
3744
|
+
writableObjectMode: !!(head !== null && head !== void 0 && head.writableObjectMode),
|
|
3745
|
+
readableObjectMode: !!(tail !== null && tail !== void 0 && tail.readableObjectMode),
|
|
3746
|
+
writable,
|
|
3747
|
+
readable
|
|
3748
|
+
});
|
|
3749
|
+
if (writable) {
|
|
3750
|
+
if (isNodeStream(head)) {
|
|
3751
|
+
d._write = function(chunk, encoding, callback) {
|
|
3752
|
+
if (head.write(chunk, encoding)) callback();
|
|
3753
|
+
else ondrain = callback;
|
|
3754
|
+
};
|
|
3755
|
+
d._final = function(callback) {
|
|
3756
|
+
head.end();
|
|
3757
|
+
onfinish = callback;
|
|
3758
|
+
};
|
|
3759
|
+
head.on("drain", function() {
|
|
3760
|
+
if (ondrain) {
|
|
3761
|
+
const cb = ondrain;
|
|
3762
|
+
ondrain = null;
|
|
3763
|
+
cb();
|
|
3764
|
+
}
|
|
3765
|
+
});
|
|
3766
|
+
} else if (isWebStream(head)) {
|
|
3767
|
+
const writer = (isTransformStream(head) ? head.writable : head).getWriter();
|
|
3768
|
+
d._write = async function(chunk, encoding, callback) {
|
|
3769
|
+
try {
|
|
3770
|
+
await writer.ready;
|
|
3771
|
+
writer.write(chunk).catch(() => {});
|
|
3772
|
+
callback();
|
|
3773
|
+
} catch (err) {
|
|
3774
|
+
callback(err);
|
|
3775
|
+
}
|
|
3776
|
+
};
|
|
3777
|
+
d._final = async function(callback) {
|
|
3778
|
+
try {
|
|
3779
|
+
await writer.ready;
|
|
3780
|
+
writer.close().catch(() => {});
|
|
3781
|
+
onfinish = callback;
|
|
3782
|
+
} catch (err) {
|
|
3783
|
+
callback(err);
|
|
3784
|
+
}
|
|
3785
|
+
};
|
|
3786
|
+
}
|
|
3787
|
+
const toRead = isTransformStream(tail) ? tail.readable : tail;
|
|
3788
|
+
eos(toRead, () => {
|
|
3789
|
+
if (onfinish) {
|
|
3790
|
+
const cb = onfinish;
|
|
3791
|
+
onfinish = null;
|
|
3792
|
+
cb();
|
|
3793
|
+
}
|
|
3794
|
+
});
|
|
3795
|
+
}
|
|
3796
|
+
if (readable) {
|
|
3797
|
+
if (isNodeStream(tail)) {
|
|
3798
|
+
tail.on("readable", function() {
|
|
3799
|
+
if (onreadable) {
|
|
3800
|
+
const cb = onreadable;
|
|
3801
|
+
onreadable = null;
|
|
3802
|
+
cb();
|
|
3803
|
+
}
|
|
3804
|
+
});
|
|
3805
|
+
tail.on("end", function() {
|
|
3806
|
+
d.push(null);
|
|
3807
|
+
});
|
|
3808
|
+
d._read = function() {
|
|
3809
|
+
while (true) {
|
|
3810
|
+
const buf = tail.read();
|
|
3811
|
+
if (buf === null) {
|
|
3812
|
+
onreadable = d._read;
|
|
3813
|
+
return;
|
|
3814
|
+
}
|
|
3815
|
+
if (!d.push(buf)) return;
|
|
3816
|
+
}
|
|
3817
|
+
};
|
|
3818
|
+
} else if (isWebStream(tail)) {
|
|
3819
|
+
const reader = (isTransformStream(tail) ? tail.readable : tail).getReader();
|
|
3820
|
+
d._read = async function() {
|
|
3821
|
+
while (true) try {
|
|
3822
|
+
const { value, done } = await reader.read();
|
|
3823
|
+
if (!d.push(value)) return;
|
|
3824
|
+
if (done) {
|
|
3825
|
+
d.push(null);
|
|
3826
|
+
return;
|
|
3827
|
+
}
|
|
3828
|
+
} catch {
|
|
3829
|
+
return;
|
|
3830
|
+
}
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
d._destroy = function(err, callback) {
|
|
3835
|
+
if (!err && onclose !== null) err = new AbortError();
|
|
3836
|
+
onreadable = null;
|
|
3837
|
+
ondrain = null;
|
|
3838
|
+
onfinish = null;
|
|
3839
|
+
if (onclose === null) callback(err);
|
|
3840
|
+
else {
|
|
3841
|
+
onclose = callback;
|
|
3842
|
+
if (isNodeStream(tail)) destroyer(tail, err);
|
|
3843
|
+
}
|
|
3844
|
+
};
|
|
3845
|
+
return d;
|
|
3846
|
+
};
|
|
3847
|
+
}));
|
|
3848
|
+
//#endregion
|
|
3849
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/internal/streams/operators.js
|
|
3850
|
+
var require_operators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3851
|
+
const AbortController = globalThis.AbortController || require__empty_module().AbortController;
|
|
3852
|
+
const { codes: { ERR_INVALID_ARG_VALUE, ERR_INVALID_ARG_TYPE, ERR_MISSING_ARGS, ERR_OUT_OF_RANGE }, AbortError } = require_errors();
|
|
3853
|
+
const { validateAbortSignal, validateInteger, validateObject } = require_validators();
|
|
3854
|
+
const kWeakHandler = require_primordials().Symbol("kWeak");
|
|
3855
|
+
const kResistStopPropagation = require_primordials().Symbol("kResistStopPropagation");
|
|
3856
|
+
const { finished } = require_end_of_stream();
|
|
3857
|
+
const staticCompose = require_compose();
|
|
3858
|
+
const { addAbortSignalNoValidate } = require_add_abort_signal();
|
|
3859
|
+
const { isWritable, isNodeStream } = require_utils();
|
|
3860
|
+
const { deprecate } = require_util();
|
|
3861
|
+
const { ArrayPrototypePush, Boolean, MathFloor, Number, NumberIsNaN, Promise, PromiseReject, PromiseResolve, PromisePrototypeThen, Symbol } = require_primordials();
|
|
3862
|
+
const kEmpty = Symbol("kEmpty");
|
|
3863
|
+
const kEof = Symbol("kEof");
|
|
3864
|
+
function compose(stream, options) {
|
|
3865
|
+
if (options != null) validateObject(options, "options");
|
|
3866
|
+
if ((options === null || options === void 0 ? void 0 : options.signal) != null) validateAbortSignal(options.signal, "options.signal");
|
|
3867
|
+
if (isNodeStream(stream) && !isWritable(stream)) throw new ERR_INVALID_ARG_VALUE("stream", stream, "must be writable");
|
|
3868
|
+
const composedStream = staticCompose(this, stream);
|
|
3869
|
+
if (options !== null && options !== void 0 && options.signal) addAbortSignalNoValidate(options.signal, composedStream);
|
|
3870
|
+
return composedStream;
|
|
3871
|
+
}
|
|
3872
|
+
function map(fn, options) {
|
|
3873
|
+
if (typeof fn !== "function") throw new ERR_INVALID_ARG_TYPE("fn", ["Function", "AsyncFunction"], fn);
|
|
3874
|
+
if (options != null) validateObject(options, "options");
|
|
3875
|
+
if ((options === null || options === void 0 ? void 0 : options.signal) != null) validateAbortSignal(options.signal, "options.signal");
|
|
3876
|
+
let concurrency = 1;
|
|
3877
|
+
if ((options === null || options === void 0 ? void 0 : options.concurrency) != null) concurrency = MathFloor(options.concurrency);
|
|
3878
|
+
let highWaterMark = concurrency - 1;
|
|
3879
|
+
if ((options === null || options === void 0 ? void 0 : options.highWaterMark) != null) highWaterMark = MathFloor(options.highWaterMark);
|
|
3880
|
+
validateInteger(concurrency, "options.concurrency", 1);
|
|
3881
|
+
validateInteger(highWaterMark, "options.highWaterMark", 0);
|
|
3882
|
+
highWaterMark += concurrency;
|
|
3883
|
+
return async function* map() {
|
|
3884
|
+
const signal = require_util().AbortSignalAny([options === null || options === void 0 ? void 0 : options.signal].filter(Boolean));
|
|
3885
|
+
const stream = this;
|
|
3886
|
+
const queue = [];
|
|
3887
|
+
const signalOpt = { signal };
|
|
3888
|
+
let next;
|
|
3889
|
+
let resume;
|
|
3890
|
+
let done = false;
|
|
3891
|
+
let cnt = 0;
|
|
3892
|
+
function onCatch() {
|
|
3893
|
+
done = true;
|
|
3894
|
+
afterItemProcessed();
|
|
3895
|
+
}
|
|
3896
|
+
function afterItemProcessed() {
|
|
3897
|
+
cnt -= 1;
|
|
3898
|
+
maybeResume();
|
|
3899
|
+
}
|
|
3900
|
+
function maybeResume() {
|
|
3901
|
+
if (resume && !done && cnt < concurrency && queue.length < highWaterMark) {
|
|
3902
|
+
resume();
|
|
3903
|
+
resume = null;
|
|
3904
|
+
}
|
|
3905
|
+
}
|
|
3906
|
+
async function pump() {
|
|
3907
|
+
try {
|
|
3908
|
+
for await (let val of stream) {
|
|
3909
|
+
if (done) return;
|
|
3910
|
+
if (signal.aborted) throw new AbortError();
|
|
3911
|
+
try {
|
|
3912
|
+
val = fn(val, signalOpt);
|
|
3913
|
+
if (val === kEmpty) continue;
|
|
3914
|
+
val = PromiseResolve(val);
|
|
3915
|
+
} catch (err) {
|
|
3916
|
+
val = PromiseReject(err);
|
|
3917
|
+
}
|
|
3918
|
+
cnt += 1;
|
|
3919
|
+
PromisePrototypeThen(val, afterItemProcessed, onCatch);
|
|
3920
|
+
queue.push(val);
|
|
3921
|
+
if (next) {
|
|
3922
|
+
next();
|
|
3923
|
+
next = null;
|
|
3924
|
+
}
|
|
3925
|
+
if (!done && (queue.length >= highWaterMark || cnt >= concurrency)) await new Promise((resolve) => {
|
|
3926
|
+
resume = resolve;
|
|
3927
|
+
});
|
|
3928
|
+
}
|
|
3929
|
+
queue.push(kEof);
|
|
3930
|
+
} catch (err) {
|
|
3931
|
+
const val = PromiseReject(err);
|
|
3932
|
+
PromisePrototypeThen(val, afterItemProcessed, onCatch);
|
|
3933
|
+
queue.push(val);
|
|
3934
|
+
} finally {
|
|
3935
|
+
done = true;
|
|
3936
|
+
if (next) {
|
|
3937
|
+
next();
|
|
3938
|
+
next = null;
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
pump();
|
|
3943
|
+
try {
|
|
3944
|
+
while (true) {
|
|
3945
|
+
while (queue.length > 0) {
|
|
3946
|
+
const val = await queue[0];
|
|
3947
|
+
if (val === kEof) return;
|
|
3948
|
+
if (signal.aborted) throw new AbortError();
|
|
3949
|
+
if (val !== kEmpty) yield val;
|
|
3950
|
+
queue.shift();
|
|
3951
|
+
maybeResume();
|
|
3952
|
+
}
|
|
3953
|
+
await new Promise((resolve) => {
|
|
3954
|
+
next = resolve;
|
|
3955
|
+
});
|
|
3956
|
+
}
|
|
3957
|
+
} finally {
|
|
3958
|
+
done = true;
|
|
3959
|
+
if (resume) {
|
|
3960
|
+
resume();
|
|
3961
|
+
resume = null;
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
}.call(this);
|
|
3965
|
+
}
|
|
3966
|
+
function asIndexedPairs(options = void 0) {
|
|
3967
|
+
if (options != null) validateObject(options, "options");
|
|
3968
|
+
if ((options === null || options === void 0 ? void 0 : options.signal) != null) validateAbortSignal(options.signal, "options.signal");
|
|
3969
|
+
return async function* asIndexedPairs() {
|
|
3970
|
+
let index = 0;
|
|
3971
|
+
for await (const val of this) {
|
|
3972
|
+
var _options$signal;
|
|
3973
|
+
if (options !== null && options !== void 0 && (_options$signal = options.signal) !== null && _options$signal !== void 0 && _options$signal.aborted) throw new AbortError({ cause: options.signal.reason });
|
|
3974
|
+
yield [index++, val];
|
|
3975
|
+
}
|
|
3976
|
+
}.call(this);
|
|
3977
|
+
}
|
|
3978
|
+
async function some(fn, options = void 0) {
|
|
3979
|
+
for await (const unused of filter.call(this, fn, options)) return true;
|
|
3980
|
+
return false;
|
|
3981
|
+
}
|
|
3982
|
+
async function every(fn, options = void 0) {
|
|
3983
|
+
if (typeof fn !== "function") throw new ERR_INVALID_ARG_TYPE("fn", ["Function", "AsyncFunction"], fn);
|
|
3984
|
+
return !await some.call(this, async (...args) => {
|
|
3985
|
+
return !await fn(...args);
|
|
3986
|
+
}, options);
|
|
3987
|
+
}
|
|
3988
|
+
async function find(fn, options) {
|
|
3989
|
+
for await (const result of filter.call(this, fn, options)) return result;
|
|
3990
|
+
}
|
|
3991
|
+
async function forEach(fn, options) {
|
|
3992
|
+
if (typeof fn !== "function") throw new ERR_INVALID_ARG_TYPE("fn", ["Function", "AsyncFunction"], fn);
|
|
3993
|
+
async function forEachFn(value, options) {
|
|
3994
|
+
await fn(value, options);
|
|
3995
|
+
return kEmpty;
|
|
3996
|
+
}
|
|
3997
|
+
for await (const unused of map.call(this, forEachFn, options));
|
|
3998
|
+
}
|
|
3999
|
+
function filter(fn, options) {
|
|
4000
|
+
if (typeof fn !== "function") throw new ERR_INVALID_ARG_TYPE("fn", ["Function", "AsyncFunction"], fn);
|
|
4001
|
+
async function filterFn(value, options) {
|
|
4002
|
+
if (await fn(value, options)) return value;
|
|
4003
|
+
return kEmpty;
|
|
4004
|
+
}
|
|
4005
|
+
return map.call(this, filterFn, options);
|
|
4006
|
+
}
|
|
4007
|
+
var ReduceAwareErrMissingArgs = class extends ERR_MISSING_ARGS {
|
|
4008
|
+
constructor() {
|
|
4009
|
+
super("reduce");
|
|
4010
|
+
this.message = "Reduce of an empty stream requires an initial value";
|
|
4011
|
+
}
|
|
4012
|
+
};
|
|
4013
|
+
async function reduce(reducer, initialValue, options) {
|
|
4014
|
+
var _options$signal2;
|
|
4015
|
+
if (typeof reducer !== "function") throw new ERR_INVALID_ARG_TYPE("reducer", ["Function", "AsyncFunction"], reducer);
|
|
4016
|
+
if (options != null) validateObject(options, "options");
|
|
4017
|
+
if ((options === null || options === void 0 ? void 0 : options.signal) != null) validateAbortSignal(options.signal, "options.signal");
|
|
4018
|
+
let hasInitialValue = arguments.length > 1;
|
|
4019
|
+
if (options !== null && options !== void 0 && (_options$signal2 = options.signal) !== null && _options$signal2 !== void 0 && _options$signal2.aborted) {
|
|
4020
|
+
const err = new AbortError(void 0, { cause: options.signal.reason });
|
|
4021
|
+
this.once("error", () => {});
|
|
4022
|
+
await finished(this.destroy(err));
|
|
4023
|
+
throw err;
|
|
4024
|
+
}
|
|
4025
|
+
const ac = new AbortController();
|
|
4026
|
+
const signal = ac.signal;
|
|
4027
|
+
if (options !== null && options !== void 0 && options.signal) {
|
|
4028
|
+
const opts = {
|
|
4029
|
+
once: true,
|
|
4030
|
+
[kWeakHandler]: this,
|
|
4031
|
+
[kResistStopPropagation]: true
|
|
4032
|
+
};
|
|
4033
|
+
options.signal.addEventListener("abort", () => ac.abort(), opts);
|
|
4034
|
+
}
|
|
4035
|
+
let gotAnyItemFromStream = false;
|
|
4036
|
+
try {
|
|
4037
|
+
for await (const value of this) {
|
|
4038
|
+
var _options$signal3;
|
|
4039
|
+
gotAnyItemFromStream = true;
|
|
4040
|
+
if (options !== null && options !== void 0 && (_options$signal3 = options.signal) !== null && _options$signal3 !== void 0 && _options$signal3.aborted) throw new AbortError();
|
|
4041
|
+
if (!hasInitialValue) {
|
|
4042
|
+
initialValue = value;
|
|
4043
|
+
hasInitialValue = true;
|
|
4044
|
+
} else initialValue = await reducer(initialValue, value, { signal });
|
|
4045
|
+
}
|
|
4046
|
+
if (!gotAnyItemFromStream && !hasInitialValue) throw new ReduceAwareErrMissingArgs();
|
|
4047
|
+
} finally {
|
|
4048
|
+
ac.abort();
|
|
4049
|
+
}
|
|
4050
|
+
return initialValue;
|
|
4051
|
+
}
|
|
4052
|
+
async function toArray(options) {
|
|
4053
|
+
if (options != null) validateObject(options, "options");
|
|
4054
|
+
if ((options === null || options === void 0 ? void 0 : options.signal) != null) validateAbortSignal(options.signal, "options.signal");
|
|
4055
|
+
const result = [];
|
|
4056
|
+
for await (const val of this) {
|
|
4057
|
+
var _options$signal4;
|
|
4058
|
+
if (options !== null && options !== void 0 && (_options$signal4 = options.signal) !== null && _options$signal4 !== void 0 && _options$signal4.aborted) throw new AbortError(void 0, { cause: options.signal.reason });
|
|
4059
|
+
ArrayPrototypePush(result, val);
|
|
4060
|
+
}
|
|
4061
|
+
return result;
|
|
4062
|
+
}
|
|
4063
|
+
function flatMap(fn, options) {
|
|
4064
|
+
const values = map.call(this, fn, options);
|
|
4065
|
+
return async function* flatMap() {
|
|
4066
|
+
for await (const val of values) yield* val;
|
|
4067
|
+
}.call(this);
|
|
4068
|
+
}
|
|
4069
|
+
function toIntegerOrInfinity(number) {
|
|
4070
|
+
number = Number(number);
|
|
4071
|
+
if (NumberIsNaN(number)) return 0;
|
|
4072
|
+
if (number < 0) throw new ERR_OUT_OF_RANGE("number", ">= 0", number);
|
|
4073
|
+
return number;
|
|
4074
|
+
}
|
|
4075
|
+
function drop(number, options = void 0) {
|
|
4076
|
+
if (options != null) validateObject(options, "options");
|
|
4077
|
+
if ((options === null || options === void 0 ? void 0 : options.signal) != null) validateAbortSignal(options.signal, "options.signal");
|
|
4078
|
+
number = toIntegerOrInfinity(number);
|
|
4079
|
+
return async function* drop() {
|
|
4080
|
+
var _options$signal5;
|
|
4081
|
+
if (options !== null && options !== void 0 && (_options$signal5 = options.signal) !== null && _options$signal5 !== void 0 && _options$signal5.aborted) throw new AbortError();
|
|
4082
|
+
for await (const val of this) {
|
|
4083
|
+
var _options$signal6;
|
|
4084
|
+
if (options !== null && options !== void 0 && (_options$signal6 = options.signal) !== null && _options$signal6 !== void 0 && _options$signal6.aborted) throw new AbortError();
|
|
4085
|
+
if (number-- <= 0) yield val;
|
|
4086
|
+
}
|
|
4087
|
+
}.call(this);
|
|
4088
|
+
}
|
|
4089
|
+
function take(number, options = void 0) {
|
|
4090
|
+
if (options != null) validateObject(options, "options");
|
|
4091
|
+
if ((options === null || options === void 0 ? void 0 : options.signal) != null) validateAbortSignal(options.signal, "options.signal");
|
|
4092
|
+
number = toIntegerOrInfinity(number);
|
|
4093
|
+
return async function* take() {
|
|
4094
|
+
var _options$signal7;
|
|
4095
|
+
if (options !== null && options !== void 0 && (_options$signal7 = options.signal) !== null && _options$signal7 !== void 0 && _options$signal7.aborted) throw new AbortError();
|
|
4096
|
+
for await (const val of this) {
|
|
4097
|
+
var _options$signal8;
|
|
4098
|
+
if (options !== null && options !== void 0 && (_options$signal8 = options.signal) !== null && _options$signal8 !== void 0 && _options$signal8.aborted) throw new AbortError();
|
|
4099
|
+
if (number-- > 0) yield val;
|
|
4100
|
+
if (number <= 0) return;
|
|
4101
|
+
}
|
|
4102
|
+
}.call(this);
|
|
4103
|
+
}
|
|
4104
|
+
module.exports.streamReturningOperators = {
|
|
4105
|
+
asIndexedPairs: deprecate(asIndexedPairs, "readable.asIndexedPairs will be removed in a future version."),
|
|
4106
|
+
drop,
|
|
4107
|
+
filter,
|
|
4108
|
+
flatMap,
|
|
4109
|
+
map,
|
|
4110
|
+
take,
|
|
4111
|
+
compose
|
|
4112
|
+
};
|
|
4113
|
+
module.exports.promiseReturningOperators = {
|
|
4114
|
+
every,
|
|
4115
|
+
forEach,
|
|
4116
|
+
reduce,
|
|
4117
|
+
toArray,
|
|
4118
|
+
some,
|
|
4119
|
+
find
|
|
4120
|
+
};
|
|
4121
|
+
}));
|
|
4122
|
+
//#endregion
|
|
4123
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/stream/promises.js
|
|
4124
|
+
var require_promises = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4125
|
+
const { ArrayPrototypePop, Promise } = require_primordials();
|
|
4126
|
+
const { isIterable, isNodeStream, isWebStream } = require_utils();
|
|
4127
|
+
const { pipelineImpl: pl } = require_pipeline();
|
|
4128
|
+
const { finished } = require_end_of_stream();
|
|
4129
|
+
require_stream();
|
|
4130
|
+
function pipeline(...streams) {
|
|
4131
|
+
return new Promise((resolve, reject) => {
|
|
4132
|
+
let signal;
|
|
4133
|
+
let end;
|
|
4134
|
+
const lastArg = streams[streams.length - 1];
|
|
4135
|
+
if (lastArg && typeof lastArg === "object" && !isNodeStream(lastArg) && !isIterable(lastArg) && !isWebStream(lastArg)) {
|
|
4136
|
+
const options = ArrayPrototypePop(streams);
|
|
4137
|
+
signal = options.signal;
|
|
4138
|
+
end = options.end;
|
|
4139
|
+
}
|
|
4140
|
+
pl(streams, (err, value) => {
|
|
4141
|
+
if (err) reject(err);
|
|
4142
|
+
else resolve(value);
|
|
4143
|
+
}, {
|
|
4144
|
+
signal,
|
|
4145
|
+
end
|
|
4146
|
+
});
|
|
4147
|
+
});
|
|
4148
|
+
}
|
|
4149
|
+
module.exports = {
|
|
4150
|
+
finished,
|
|
4151
|
+
pipeline
|
|
4152
|
+
};
|
|
4153
|
+
}));
|
|
4154
|
+
//#endregion
|
|
4155
|
+
//#region ../../node_modules/.pnpm/readable-stream@4.8.0/node_modules/readable-stream/lib/stream.js
|
|
4156
|
+
var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4157
|
+
const { Buffer } = require__require_as_import_buffer();
|
|
4158
|
+
const { ObjectDefineProperty, ObjectKeys, ReflectApply } = require_primordials();
|
|
4159
|
+
const { promisify: { custom: customPromisify } } = require_util();
|
|
4160
|
+
const { streamReturningOperators, promiseReturningOperators } = require_operators();
|
|
4161
|
+
const { codes: { ERR_ILLEGAL_CONSTRUCTOR } } = require_errors();
|
|
4162
|
+
const compose = require_compose();
|
|
4163
|
+
const { setDefaultHighWaterMark, getDefaultHighWaterMark } = require_state();
|
|
4164
|
+
const { pipeline } = require_pipeline();
|
|
4165
|
+
const { destroyer } = require_destroy();
|
|
4166
|
+
const eos = require_end_of_stream();
|
|
4167
|
+
const promises = require_promises();
|
|
4168
|
+
const utils = require_utils();
|
|
4169
|
+
const Stream = module.exports = require_legacy().Stream;
|
|
4170
|
+
Stream.isDestroyed = utils.isDestroyed;
|
|
4171
|
+
Stream.isDisturbed = utils.isDisturbed;
|
|
4172
|
+
Stream.isErrored = utils.isErrored;
|
|
4173
|
+
Stream.isReadable = utils.isReadable;
|
|
4174
|
+
Stream.isWritable = utils.isWritable;
|
|
4175
|
+
Stream.Readable = require_readable();
|
|
4176
|
+
for (const key of ObjectKeys(streamReturningOperators)) {
|
|
4177
|
+
const op = streamReturningOperators[key];
|
|
4178
|
+
function fn(...args) {
|
|
4179
|
+
if (new.target) throw ERR_ILLEGAL_CONSTRUCTOR();
|
|
4180
|
+
return Stream.Readable.from(ReflectApply(op, this, args));
|
|
4181
|
+
}
|
|
4182
|
+
ObjectDefineProperty(fn, "name", {
|
|
4183
|
+
__proto__: null,
|
|
4184
|
+
value: op.name
|
|
4185
|
+
});
|
|
4186
|
+
ObjectDefineProperty(fn, "length", {
|
|
4187
|
+
__proto__: null,
|
|
4188
|
+
value: op.length
|
|
4189
|
+
});
|
|
4190
|
+
ObjectDefineProperty(Stream.Readable.prototype, key, {
|
|
4191
|
+
__proto__: null,
|
|
4192
|
+
value: fn,
|
|
4193
|
+
enumerable: false,
|
|
4194
|
+
configurable: true,
|
|
4195
|
+
writable: true
|
|
4196
|
+
});
|
|
4197
|
+
}
|
|
4198
|
+
for (const key of ObjectKeys(promiseReturningOperators)) {
|
|
4199
|
+
const op = promiseReturningOperators[key];
|
|
4200
|
+
function fn(...args) {
|
|
4201
|
+
if (new.target) throw ERR_ILLEGAL_CONSTRUCTOR();
|
|
4202
|
+
return ReflectApply(op, this, args);
|
|
4203
|
+
}
|
|
4204
|
+
ObjectDefineProperty(fn, "name", {
|
|
4205
|
+
__proto__: null,
|
|
4206
|
+
value: op.name
|
|
4207
|
+
});
|
|
4208
|
+
ObjectDefineProperty(fn, "length", {
|
|
4209
|
+
__proto__: null,
|
|
4210
|
+
value: op.length
|
|
4211
|
+
});
|
|
4212
|
+
ObjectDefineProperty(Stream.Readable.prototype, key, {
|
|
4213
|
+
__proto__: null,
|
|
4214
|
+
value: fn,
|
|
4215
|
+
enumerable: false,
|
|
4216
|
+
configurable: true,
|
|
4217
|
+
writable: true
|
|
4218
|
+
});
|
|
4219
|
+
}
|
|
4220
|
+
Stream.Writable = require_writable();
|
|
4221
|
+
Stream.Duplex = require_duplex();
|
|
4222
|
+
Stream.Transform = require_transform();
|
|
4223
|
+
Stream.PassThrough = require_passthrough();
|
|
4224
|
+
Stream.pipeline = pipeline;
|
|
4225
|
+
const { addAbortSignal } = require_add_abort_signal();
|
|
4226
|
+
Stream.addAbortSignal = addAbortSignal;
|
|
4227
|
+
Stream.finished = eos;
|
|
4228
|
+
Stream.destroy = destroyer;
|
|
4229
|
+
Stream.compose = compose;
|
|
4230
|
+
Stream.setDefaultHighWaterMark = setDefaultHighWaterMark;
|
|
4231
|
+
Stream.getDefaultHighWaterMark = getDefaultHighWaterMark;
|
|
4232
|
+
ObjectDefineProperty(Stream, "promises", {
|
|
4233
|
+
__proto__: null,
|
|
4234
|
+
configurable: true,
|
|
4235
|
+
enumerable: true,
|
|
4236
|
+
get() {
|
|
4237
|
+
return promises;
|
|
4238
|
+
}
|
|
4239
|
+
});
|
|
4240
|
+
ObjectDefineProperty(pipeline, customPromisify, {
|
|
4241
|
+
__proto__: null,
|
|
4242
|
+
enumerable: true,
|
|
4243
|
+
get() {
|
|
4244
|
+
return promises.pipeline;
|
|
4245
|
+
}
|
|
4246
|
+
});
|
|
4247
|
+
ObjectDefineProperty(eos, customPromisify, {
|
|
4248
|
+
__proto__: null,
|
|
4249
|
+
enumerable: true,
|
|
4250
|
+
get() {
|
|
4251
|
+
return promises.finished;
|
|
4252
|
+
}
|
|
4253
|
+
});
|
|
4254
|
+
Stream.Stream = Stream;
|
|
4255
|
+
Stream._isUint8Array = function isUint8Array(value) {
|
|
4256
|
+
return value instanceof Uint8Array;
|
|
4257
|
+
};
|
|
4258
|
+
Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) {
|
|
4259
|
+
return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
4260
|
+
};
|
|
4261
|
+
}));
|
|
4262
|
+
//#endregion
|
|
4263
|
+
//#region src/node/stream.ts
|
|
4264
|
+
var import_browser = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4265
|
+
const CustomStream = require_stream();
|
|
4266
|
+
const promises = require_promises();
|
|
4267
|
+
const originalDestroy = CustomStream.Readable.destroy;
|
|
4268
|
+
module.exports = CustomStream.Readable;
|
|
4269
|
+
module.exports._uint8ArrayToBuffer = CustomStream._uint8ArrayToBuffer;
|
|
4270
|
+
module.exports._isUint8Array = CustomStream._isUint8Array;
|
|
4271
|
+
module.exports.isDisturbed = CustomStream.isDisturbed;
|
|
4272
|
+
module.exports.isErrored = CustomStream.isErrored;
|
|
4273
|
+
module.exports.isReadable = CustomStream.isReadable;
|
|
4274
|
+
module.exports.Readable = CustomStream.Readable;
|
|
4275
|
+
module.exports.Writable = CustomStream.Writable;
|
|
4276
|
+
module.exports.Duplex = CustomStream.Duplex;
|
|
4277
|
+
module.exports.Transform = CustomStream.Transform;
|
|
4278
|
+
module.exports.PassThrough = CustomStream.PassThrough;
|
|
4279
|
+
module.exports.addAbortSignal = CustomStream.addAbortSignal;
|
|
4280
|
+
module.exports.finished = CustomStream.finished;
|
|
4281
|
+
module.exports.destroy = CustomStream.destroy;
|
|
4282
|
+
module.exports.destroy = originalDestroy;
|
|
4283
|
+
module.exports.pipeline = CustomStream.pipeline;
|
|
4284
|
+
module.exports.compose = CustomStream.compose;
|
|
4285
|
+
Object.defineProperty(CustomStream, "promises", {
|
|
4286
|
+
configurable: true,
|
|
4287
|
+
enumerable: true,
|
|
4288
|
+
get() {
|
|
4289
|
+
return promises;
|
|
4290
|
+
}
|
|
4291
|
+
});
|
|
4292
|
+
module.exports.Stream = CustomStream.Stream;
|
|
4293
|
+
module.exports.default = module.exports;
|
|
4294
|
+
})))();
|
|
4295
|
+
const { Readable, Writable, Duplex, Transform, PassThrough, finished, pipeline, promises, addAbortSignal, compose, destroy, isDisturbed, isErrored, isReadable, isWritable, isDestroyed, getDefaultHighWaterMark, setDefaultHighWaterMark, _isUint8Array, _uint8ArrayToBuffer } = import_browser.Stream;
|
|
4296
|
+
const readable = Readable;
|
|
4297
|
+
readable.toWeb = (source) => new ReadableStream({
|
|
4298
|
+
start(controller) {
|
|
4299
|
+
source.on("data", (chunk) => controller.enqueue(typeof chunk === "string" ? new TextEncoder().encode(chunk) : new Uint8Array(chunk)));
|
|
4300
|
+
source.on("end", () => controller.close());
|
|
4301
|
+
source.on("error", (error) => controller.error(error));
|
|
4302
|
+
},
|
|
4303
|
+
cancel: (reason) => void source.destroy(reason)
|
|
4304
|
+
});
|
|
4305
|
+
readable.fromWeb = (web) => {
|
|
4306
|
+
const reader = web.getReader();
|
|
4307
|
+
return new Readable({ read() {
|
|
4308
|
+
reader.read().then(({ done, value }) => void this.push(done ? null : Buffer.from(value)), (error) => this.destroy(error));
|
|
4309
|
+
} });
|
|
4310
|
+
};
|
|
4311
|
+
const missing = (name) => function() {
|
|
4312
|
+
throw new Error(`vitest-plugin-rsc: stream.${name} of Node.js is not there in the browser`);
|
|
4313
|
+
};
|
|
4314
|
+
const duplexPair = missing("duplexPair");
|
|
4315
|
+
const _isArrayBufferView = (value) => ArrayBuffer.isView(value);
|
|
4316
|
+
for (const kind of [Writable, Duplex]) {
|
|
4317
|
+
kind.toWeb = missing(`${kind.name}.toWeb`);
|
|
4318
|
+
kind.fromWeb = missing(`${kind.name}.fromWeb`);
|
|
4319
|
+
}
|
|
4320
|
+
var stream_default = import_browser.Stream;
|
|
4321
|
+
//#endregion
|
|
4322
|
+
var Stream = import_browser.Stream;
|
|
4323
|
+
export { Duplex, PassThrough, Readable, Stream, Transform, Writable, _isArrayBufferView, _isUint8Array, _uint8ArrayToBuffer, addAbortSignal, compose, stream_default as default, destroy, duplexPair, finished, getDefaultHighWaterMark, isDestroyed, isDisturbed, isErrored, isReadable, isWritable, pipeline, promises, setDefaultHighWaterMark };
|