@kubb/agent 4.28.1 → 4.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +378 -642
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +4 -6
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +4 -6
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@kubb/fabric-core/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
- package/.output/server/node_modules/@kubb/fabric-core/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
- package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +8 -9
- package/.output/server/node_modules/@kubb/fabric-core/dist/{Root-BQX3eHqb.js → onProcessExit-CF200hsz.js} +109 -190
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +3 -4
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +2 -3
- package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +58 -298
- package/.output/server/node_modules/@kubb/fabric-core/package.json +8 -18
- package/.output/server/node_modules/@kubb/react-fabric/dist/{chunk-DbZtQ4qb.js → chunk-Cnw5r_-A.js} +1 -5
- package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +39 -41
- package/.output/server/node_modules/@kubb/react-fabric/dist/{jsx-runtime-CQFBnRKx.js → jsx-runtime-Dm7PKVbc.js} +6 -24
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +5 -4
- package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +3 -3
- package/.output/server/node_modules/@kubb/react-fabric/dist/{react--draJ5Pm.js → react-D652OKii.js} +31 -91
- package/.output/server/node_modules/@kubb/react-fabric/dist/{reactPlugin-DqJsInTf.js → reactPlugin-BkDkx1cs.js} +410 -1650
- package/.output/server/node_modules/@kubb/react-fabric/package.json +8 -11
- package/.output/server/node_modules/empathic/access.js +39 -0
- package/.output/server/node_modules/empathic/access.mjs +34 -0
- package/.output/server/node_modules/empathic/find.js +81 -0
- package/.output/server/node_modules/empathic/find.mjs +76 -0
- package/.output/server/node_modules/empathic/package.json +49 -0
- package/.output/server/node_modules/empathic/package.mjs +52 -0
- package/.output/server/node_modules/empathic/resolve.js +31 -0
- package/.output/server/node_modules/empathic/resolve.mjs +27 -0
- package/.output/server/node_modules/empathic/walk.js +22 -0
- package/.output/server/node_modules/empathic/walk.mjs +20 -0
- package/.output/server/node_modules/tinyexec/dist/main.js +633 -0
- package/.output/server/node_modules/tinyexec/package.json +61 -0
- package/.output/server/package.json +6 -44
- package/package.json +19 -21
- package/.output/server/node_modules/.nitro/path-key@3.1.1/index.js +0 -16
- package/.output/server/node_modules/.nitro/path-key@3.1.1/package.json +0 -39
- package/.output/server/node_modules/.nitro/path-key@4.0.0/index.js +0 -12
- package/.output/server/node_modules/.nitro/path-key@4.0.0/package.json +0 -41
- package/.output/server/node_modules/.nitro/path-to-regexp@3.3.0/index.js +0 -421
- package/.output/server/node_modules/.nitro/path-to-regexp@3.3.0/package.json +0 -46
- package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-BVHe6Par.js +0 -22
- package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/asyncIterator.js +0 -89
- package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/fromAnyIterable.js +0 -34
- package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/index.js +0 -6
- package/.output/server/node_modules/@sec-ant/readable-stream/package.json +0 -98
- package/.output/server/node_modules/@sindresorhus/merge-streams/index.js +0 -265
- package/.output/server/node_modules/@sindresorhus/merge-streams/package.json +0 -49
- package/.output/server/node_modules/balanced-match/index.js +0 -62
- package/.output/server/node_modules/balanced-match/package.json +0 -48
- package/.output/server/node_modules/brace-expansion/index.js +0 -201
- package/.output/server/node_modules/brace-expansion/package.json +0 -50
- package/.output/server/node_modules/bytes/index.js +0 -159
- package/.output/server/node_modules/bytes/package.json +0 -39
- package/.output/server/node_modules/concat-map/index.js +0 -13
- package/.output/server/node_modules/concat-map/package.json +0 -59
- package/.output/server/node_modules/content-disposition/index.js +0 -445
- package/.output/server/node_modules/content-disposition/package.json +0 -39
- package/.output/server/node_modules/cross-spawn/index.js +0 -39
- package/.output/server/node_modules/cross-spawn/lib/enoent.js +0 -59
- package/.output/server/node_modules/cross-spawn/lib/parse.js +0 -91
- package/.output/server/node_modules/cross-spawn/lib/util/escape.js +0 -47
- package/.output/server/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
- package/.output/server/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
- package/.output/server/node_modules/cross-spawn/package.json +0 -73
- package/.output/server/node_modules/execa/index.js +0 -28
- package/.output/server/node_modules/execa/lib/arguments/command.js +0 -20
- package/.output/server/node_modules/execa/lib/arguments/cwd.js +0 -39
- package/.output/server/node_modules/execa/lib/arguments/encoding-option.js +0 -50
- package/.output/server/node_modules/execa/lib/arguments/escape.js +0 -88
- package/.output/server/node_modules/execa/lib/arguments/fd-options.js +0 -108
- package/.output/server/node_modules/execa/lib/arguments/file-url.js +0 -25
- package/.output/server/node_modules/execa/lib/arguments/options.js +0 -96
- package/.output/server/node_modules/execa/lib/arguments/shell.js +0 -11
- package/.output/server/node_modules/execa/lib/arguments/specific.js +0 -111
- package/.output/server/node_modules/execa/lib/convert/add.js +0 -15
- package/.output/server/node_modules/execa/lib/convert/concurrent.js +0 -33
- package/.output/server/node_modules/execa/lib/convert/duplex.js +0 -69
- package/.output/server/node_modules/execa/lib/convert/iterable.js +0 -34
- package/.output/server/node_modules/execa/lib/convert/readable.js +0 -113
- package/.output/server/node_modules/execa/lib/convert/shared.js +0 -46
- package/.output/server/node_modules/execa/lib/convert/writable.js +0 -90
- package/.output/server/node_modules/execa/lib/io/contents.js +0 -116
- package/.output/server/node_modules/execa/lib/io/input-sync.js +0 -44
- package/.output/server/node_modules/execa/lib/io/iterate.js +0 -110
- package/.output/server/node_modules/execa/lib/io/max-buffer.js +0 -89
- package/.output/server/node_modules/execa/lib/io/output-async.js +0 -80
- package/.output/server/node_modules/execa/lib/io/output-sync.js +0 -135
- package/.output/server/node_modules/execa/lib/io/pipeline.js +0 -48
- package/.output/server/node_modules/execa/lib/io/strip-newline.js +0 -12
- package/.output/server/node_modules/execa/lib/ipc/array.js +0 -4
- package/.output/server/node_modules/execa/lib/ipc/buffer-messages.js +0 -47
- package/.output/server/node_modules/execa/lib/ipc/forward.js +0 -56
- package/.output/server/node_modules/execa/lib/ipc/get-each.js +0 -89
- package/.output/server/node_modules/execa/lib/ipc/get-one.js +0 -69
- package/.output/server/node_modules/execa/lib/ipc/graceful.js +0 -72
- package/.output/server/node_modules/execa/lib/ipc/incoming.js +0 -79
- package/.output/server/node_modules/execa/lib/ipc/ipc-input.js +0 -44
- package/.output/server/node_modules/execa/lib/ipc/methods.js +0 -49
- package/.output/server/node_modules/execa/lib/ipc/outgoing.js +0 -47
- package/.output/server/node_modules/execa/lib/ipc/reference.js +0 -44
- package/.output/server/node_modules/execa/lib/ipc/send.js +0 -91
- package/.output/server/node_modules/execa/lib/ipc/strict.js +0 -113
- package/.output/server/node_modules/execa/lib/ipc/validation.js +0 -111
- package/.output/server/node_modules/execa/lib/methods/bind.js +0 -23
- package/.output/server/node_modules/execa/lib/methods/command.js +0 -43
- package/.output/server/node_modules/execa/lib/methods/create.js +0 -65
- package/.output/server/node_modules/execa/lib/methods/main-async.js +0 -194
- package/.output/server/node_modules/execa/lib/methods/main-sync.js +0 -163
- package/.output/server/node_modules/execa/lib/methods/node.js +0 -51
- package/.output/server/node_modules/execa/lib/methods/parameters.js +0 -31
- package/.output/server/node_modules/execa/lib/methods/promise.js +0 -15
- package/.output/server/node_modules/execa/lib/methods/script.js +0 -22
- package/.output/server/node_modules/execa/lib/methods/template.js +0 -153
- package/.output/server/node_modules/execa/lib/pipe/abort.js +0 -20
- package/.output/server/node_modules/execa/lib/pipe/pipe-arguments.js +0 -91
- package/.output/server/node_modules/execa/lib/pipe/sequence.js +0 -24
- package/.output/server/node_modules/execa/lib/pipe/setup.js +0 -72
- package/.output/server/node_modules/execa/lib/pipe/streaming.js +0 -51
- package/.output/server/node_modules/execa/lib/pipe/throw.js +0 -58
- package/.output/server/node_modules/execa/lib/resolve/all-async.js +0 -46
- package/.output/server/node_modules/execa/lib/resolve/all-sync.js +0 -33
- package/.output/server/node_modules/execa/lib/resolve/exit-async.js +0 -54
- package/.output/server/node_modules/execa/lib/resolve/exit-sync.js +0 -25
- package/.output/server/node_modules/execa/lib/resolve/stdio.js +0 -47
- package/.output/server/node_modules/execa/lib/resolve/wait-stream.js +0 -96
- package/.output/server/node_modules/execa/lib/resolve/wait-subprocess.js +0 -146
- package/.output/server/node_modules/execa/lib/return/duration.js +0 -8
- package/.output/server/node_modules/execa/lib/return/early-error.js +0 -60
- package/.output/server/node_modules/execa/lib/return/final-error.js +0 -40
- package/.output/server/node_modules/execa/lib/return/message.js +0 -157
- package/.output/server/node_modules/execa/lib/return/reject.js +0 -13
- package/.output/server/node_modules/execa/lib/return/result.js +0 -186
- package/.output/server/node_modules/execa/lib/stdio/direction.js +0 -76
- package/.output/server/node_modules/execa/lib/stdio/duplicate.js +0 -116
- package/.output/server/node_modules/execa/lib/stdio/handle-async.js +0 -52
- package/.output/server/node_modules/execa/lib/stdio/handle-sync.js +0 -57
- package/.output/server/node_modules/execa/lib/stdio/handle.js +0 -214
- package/.output/server/node_modules/execa/lib/stdio/input-option.js +0 -50
- package/.output/server/node_modules/execa/lib/stdio/native.js +0 -106
- package/.output/server/node_modules/execa/lib/stdio/stdio-option.js +0 -60
- package/.output/server/node_modules/execa/lib/stdio/type.js +0 -173
- package/.output/server/node_modules/execa/lib/terminate/cancel.js +0 -20
- package/.output/server/node_modules/execa/lib/terminate/cleanup.js +0 -16
- package/.output/server/node_modules/execa/lib/terminate/graceful.js +0 -71
- package/.output/server/node_modules/execa/lib/terminate/kill.js +0 -93
- package/.output/server/node_modules/execa/lib/terminate/signal.js +0 -70
- package/.output/server/node_modules/execa/lib/terminate/timeout.js +0 -21
- package/.output/server/node_modules/execa/lib/transform/encoding-transform.js +0 -51
- package/.output/server/node_modules/execa/lib/transform/generator.js +0 -107
- package/.output/server/node_modules/execa/lib/transform/normalize.js +0 -111
- package/.output/server/node_modules/execa/lib/transform/object-mode.js +0 -41
- package/.output/server/node_modules/execa/lib/transform/run-async.js +0 -60
- package/.output/server/node_modules/execa/lib/transform/run-sync.js +0 -50
- package/.output/server/node_modules/execa/lib/transform/split.js +0 -110
- package/.output/server/node_modules/execa/lib/transform/validate.js +0 -43
- package/.output/server/node_modules/execa/lib/utils/abort-signal.js +0 -8
- package/.output/server/node_modules/execa/lib/utils/deferred.js +0 -7
- package/.output/server/node_modules/execa/lib/utils/max-listeners.js +0 -14
- package/.output/server/node_modules/execa/lib/utils/standard-stream.js +0 -6
- package/.output/server/node_modules/execa/lib/utils/uint-array.js +0 -69
- package/.output/server/node_modules/execa/lib/verbose/complete.js +0 -24
- package/.output/server/node_modules/execa/lib/verbose/custom.js +0 -26
- package/.output/server/node_modules/execa/lib/verbose/default.js +0 -54
- package/.output/server/node_modules/execa/lib/verbose/error.js +0 -13
- package/.output/server/node_modules/execa/lib/verbose/info.js +0 -39
- package/.output/server/node_modules/execa/lib/verbose/ipc.js +0 -15
- package/.output/server/node_modules/execa/lib/verbose/log.js +0 -54
- package/.output/server/node_modules/execa/lib/verbose/output.js +0 -60
- package/.output/server/node_modules/execa/lib/verbose/start.js +0 -15
- package/.output/server/node_modules/execa/lib/verbose/values.js +0 -33
- package/.output/server/node_modules/execa/package.json +0 -105
- package/.output/server/node_modules/figures/index.js +0 -292
- package/.output/server/node_modules/figures/package.json +0 -49
- package/.output/server/node_modules/fs-extra/lib/copy/copy-sync.js +0 -176
- package/.output/server/node_modules/fs-extra/lib/copy/copy.js +0 -180
- package/.output/server/node_modules/fs-extra/lib/copy/index.js +0 -7
- package/.output/server/node_modules/fs-extra/lib/empty/index.js +0 -39
- package/.output/server/node_modules/fs-extra/lib/ensure/file.js +0 -66
- package/.output/server/node_modules/fs-extra/lib/ensure/index.js +0 -23
- package/.output/server/node_modules/fs-extra/lib/ensure/link.js +0 -64
- package/.output/server/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -101
- package/.output/server/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -34
- package/.output/server/node_modules/fs-extra/lib/ensure/symlink.js +0 -67
- package/.output/server/node_modules/fs-extra/lib/fs/index.js +0 -146
- package/.output/server/node_modules/fs-extra/lib/index.js +0 -16
- package/.output/server/node_modules/fs-extra/lib/json/index.js +0 -16
- package/.output/server/node_modules/fs-extra/lib/json/jsonfile.js +0 -11
- package/.output/server/node_modules/fs-extra/lib/json/output-json-sync.js +0 -12
- package/.output/server/node_modules/fs-extra/lib/json/output-json.js +0 -12
- package/.output/server/node_modules/fs-extra/lib/mkdirs/index.js +0 -14
- package/.output/server/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -27
- package/.output/server/node_modules/fs-extra/lib/mkdirs/utils.js +0 -21
- package/.output/server/node_modules/fs-extra/lib/move/index.js +0 -7
- package/.output/server/node_modules/fs-extra/lib/move/move-sync.js +0 -55
- package/.output/server/node_modules/fs-extra/lib/move/move.js +0 -59
- package/.output/server/node_modules/fs-extra/lib/output-file/index.js +0 -31
- package/.output/server/node_modules/fs-extra/lib/path-exists/index.js +0 -12
- package/.output/server/node_modules/fs-extra/lib/remove/index.js +0 -17
- package/.output/server/node_modules/fs-extra/lib/util/async.js +0 -29
- package/.output/server/node_modules/fs-extra/lib/util/stat.js +0 -159
- package/.output/server/node_modules/fs-extra/lib/util/utimes.js +0 -36
- package/.output/server/node_modules/fs-extra/package.json +0 -71
- package/.output/server/node_modules/get-stream/package.json +0 -60
- package/.output/server/node_modules/get-stream/source/array-buffer.js +0 -84
- package/.output/server/node_modules/get-stream/source/array.js +0 -32
- package/.output/server/node_modules/get-stream/source/buffer.js +0 -19
- package/.output/server/node_modules/get-stream/source/contents.js +0 -121
- package/.output/server/node_modules/get-stream/source/exports.js +0 -5
- package/.output/server/node_modules/get-stream/source/index.js +0 -13
- package/.output/server/node_modules/get-stream/source/stream.js +0 -65
- package/.output/server/node_modules/get-stream/source/string.js +0 -41
- package/.output/server/node_modules/get-stream/source/utils.js +0 -11
- package/.output/server/node_modules/graceful-fs/clone.js +0 -23
- package/.output/server/node_modules/graceful-fs/graceful-fs.js +0 -448
- package/.output/server/node_modules/graceful-fs/legacy-streams.js +0 -118
- package/.output/server/node_modules/graceful-fs/package.json +0 -53
- package/.output/server/node_modules/graceful-fs/polyfills.js +0 -355
- package/.output/server/node_modules/human-signals/build/src/core.js +0 -273
- package/.output/server/node_modules/human-signals/build/src/main.js +0 -70
- package/.output/server/node_modules/human-signals/build/src/realtime.js +0 -16
- package/.output/server/node_modules/human-signals/build/src/signals.js +0 -34
- package/.output/server/node_modules/human-signals/package.json +0 -66
- package/.output/server/node_modules/is-plain-obj/index.js +0 -8
- package/.output/server/node_modules/is-plain-obj/package.json +0 -41
- package/.output/server/node_modules/is-stream/index.js +0 -37
- package/.output/server/node_modules/is-stream/package.json +0 -48
- package/.output/server/node_modules/is-unicode-supported/index.js +0 -21
- package/.output/server/node_modules/is-unicode-supported/package.json +0 -47
- package/.output/server/node_modules/isexe/index.js +0 -57
- package/.output/server/node_modules/isexe/mode.js +0 -41
- package/.output/server/node_modules/isexe/package.json +0 -31
- package/.output/server/node_modules/isexe/windows.js +0 -42
- package/.output/server/node_modules/js-runtime/dist/index.js +0 -5
- package/.output/server/node_modules/js-runtime/package.json +0 -72
- package/.output/server/node_modules/jsonfile/index.js +0 -88
- package/.output/server/node_modules/jsonfile/package.json +0 -40
- package/.output/server/node_modules/jsonfile/utils.js +0 -14
- package/.output/server/node_modules/mime-db/db.json +0 -7088
- package/.output/server/node_modules/mime-db/index.js +0 -11
- package/.output/server/node_modules/mime-db/package.json +0 -57
- package/.output/server/node_modules/mime-types/index.js +0 -188
- package/.output/server/node_modules/mime-types/package.json +0 -43
- package/.output/server/node_modules/minimatch/minimatch.js +0 -947
- package/.output/server/node_modules/minimatch/package.json +0 -33
- package/.output/server/node_modules/natural-orderby/dist/main.js +0 -19
- package/.output/server/node_modules/natural-orderby/dist/umd/natural-orderby.development.js +0 -420
- package/.output/server/node_modules/natural-orderby/dist/umd/natural-orderby.production.min.js +0 -11
- package/.output/server/node_modules/natural-orderby/package.json +0 -119
- package/.output/server/node_modules/npm-run-path/index.js +0 -55
- package/.output/server/node_modules/npm-run-path/package.json +0 -52
- package/.output/server/node_modules/parse-ms/index.js +0 -45
- package/.output/server/node_modules/parse-ms/package.json +0 -47
- package/.output/server/node_modules/path-is-inside/lib/path-is-inside.js +0 -28
- package/.output/server/node_modules/path-is-inside/package.json +0 -27
- package/.output/server/node_modules/pretty-ms/index.js +0 -149
- package/.output/server/node_modules/pretty-ms/package.json +0 -55
- package/.output/server/node_modules/range-parser/index.js +0 -158
- package/.output/server/node_modules/range-parser/package.json +0 -40
- package/.output/server/node_modules/serve-handler/package.json +0 -68
- package/.output/server/node_modules/serve-handler/src/directory.js +0 -16
- package/.output/server/node_modules/serve-handler/src/error.js +0 -10
- package/.output/server/node_modules/serve-handler/src/glob-slash.js +0 -9
- package/.output/server/node_modules/serve-handler/src/index.js +0 -769
- package/.output/server/node_modules/shebang-command/index.js +0 -19
- package/.output/server/node_modules/shebang-command/package.json +0 -34
- package/.output/server/node_modules/shebang-regex/index.js +0 -2
- package/.output/server/node_modules/shebang-regex/package.json +0 -35
- package/.output/server/node_modules/signal-exit/dist/mjs/index.js +0 -275
- package/.output/server/node_modules/signal-exit/dist/mjs/package.json +0 -3
- package/.output/server/node_modules/signal-exit/dist/mjs/signals.js +0 -39
- package/.output/server/node_modules/signal-exit/package.json +0 -106
- package/.output/server/node_modules/string-argv/index.js +0 -41
- package/.output/server/node_modules/string-argv/package.json +0 -51
- package/.output/server/node_modules/strip-final-newline/index.js +0 -26
- package/.output/server/node_modules/strip-final-newline/package.json +0 -49
- package/.output/server/node_modules/unicorn-magic/default.js +0 -14
- package/.output/server/node_modules/unicorn-magic/node.js +0 -49
- package/.output/server/node_modules/unicorn-magic/package.json +0 -62
- package/.output/server/node_modules/universalify/index.js +0 -24
- package/.output/server/node_modules/universalify/package.json +0 -34
- package/.output/server/node_modules/which/package.json +0 -43
- package/.output/server/node_modules/which/which.js +0 -125
- package/.output/server/node_modules/yoctocolors/base.js +0 -94
- package/.output/server/node_modules/yoctocolors/index.js +0 -2
- package/.output/server/node_modules/yoctocolors/package.json +0 -69
- /package/.output/server/node_modules/{.nitro/path-to-regexp@8.3.0 → path-to-regexp}/dist/index.js +0 -0
- /package/.output/server/node_modules/{.nitro/path-to-regexp@8.3.0 → path-to-regexp}/package.json +0 -0
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {on} from 'node:events';
|
|
2
|
-
import {getDefaultHighWaterMark} from 'node:stream';
|
|
3
|
-
import {getEncodingTransformGenerator} from '../transform/encoding-transform.js';
|
|
4
|
-
import {getSplitLinesGenerator} from '../transform/split.js';
|
|
5
|
-
import {transformChunkSync, finalChunksSync} from '../transform/run-sync.js';
|
|
6
|
-
|
|
7
|
-
// Iterate over lines of `subprocess.stdout`, used by `subprocess.readable|duplex|iterable()`
|
|
8
|
-
export const iterateOnSubprocessStream = ({subprocessStdout, subprocess, binary, shouldEncode, encoding, preserveNewlines}) => {
|
|
9
|
-
const controller = new AbortController();
|
|
10
|
-
stopReadingOnExit(subprocess, controller);
|
|
11
|
-
return iterateOnStream({
|
|
12
|
-
stream: subprocessStdout,
|
|
13
|
-
controller,
|
|
14
|
-
binary,
|
|
15
|
-
shouldEncode: !subprocessStdout.readableObjectMode && shouldEncode,
|
|
16
|
-
encoding,
|
|
17
|
-
shouldSplit: !subprocessStdout.readableObjectMode,
|
|
18
|
-
preserveNewlines,
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const stopReadingOnExit = async (subprocess, controller) => {
|
|
23
|
-
try {
|
|
24
|
-
await subprocess;
|
|
25
|
-
} catch {} finally {
|
|
26
|
-
controller.abort();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// Iterate over lines of `subprocess.stdout`, used by `result.stdout` and the `verbose: 'full'` option.
|
|
31
|
-
// Applies the `lines` and `encoding` options.
|
|
32
|
-
export const iterateForResult = ({stream, onStreamEnd, lines, encoding, stripFinalNewline, allMixed}) => {
|
|
33
|
-
const controller = new AbortController();
|
|
34
|
-
stopReadingOnStreamEnd(onStreamEnd, controller, stream);
|
|
35
|
-
const objectMode = stream.readableObjectMode && !allMixed;
|
|
36
|
-
return iterateOnStream({
|
|
37
|
-
stream,
|
|
38
|
-
controller,
|
|
39
|
-
binary: encoding === 'buffer',
|
|
40
|
-
shouldEncode: !objectMode,
|
|
41
|
-
encoding,
|
|
42
|
-
shouldSplit: !objectMode && lines,
|
|
43
|
-
preserveNewlines: !stripFinalNewline,
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const stopReadingOnStreamEnd = async (onStreamEnd, controller, stream) => {
|
|
48
|
-
try {
|
|
49
|
-
await onStreamEnd;
|
|
50
|
-
} catch {
|
|
51
|
-
stream.destroy();
|
|
52
|
-
} finally {
|
|
53
|
-
controller.abort();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const iterateOnStream = ({stream, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines}) => {
|
|
58
|
-
const onStdoutChunk = on(stream, 'data', {
|
|
59
|
-
signal: controller.signal,
|
|
60
|
-
highWaterMark: HIGH_WATER_MARK,
|
|
61
|
-
// Backward compatibility with older name for this option
|
|
62
|
-
// See https://github.com/nodejs/node/pull/52080#discussion_r1525227861
|
|
63
|
-
// @todo Remove after removing support for Node 21
|
|
64
|
-
highWatermark: HIGH_WATER_MARK,
|
|
65
|
-
});
|
|
66
|
-
return iterateOnData({
|
|
67
|
-
onStdoutChunk,
|
|
68
|
-
controller,
|
|
69
|
-
binary,
|
|
70
|
-
shouldEncode,
|
|
71
|
-
encoding,
|
|
72
|
-
shouldSplit,
|
|
73
|
-
preserveNewlines,
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const DEFAULT_OBJECT_HIGH_WATER_MARK = getDefaultHighWaterMark(true);
|
|
78
|
-
|
|
79
|
-
// The `highWaterMark` of `events.on()` is measured in number of events, not in bytes.
|
|
80
|
-
// Not knowing the average amount of bytes per `data` event, we use the same heuristic as streams in objectMode, since they have the same issue.
|
|
81
|
-
// Therefore, we use the value of `getDefaultHighWaterMark(true)`.
|
|
82
|
-
// Note: this option does not exist on Node 18, but this is ok since the logic works without it. It just consumes more memory.
|
|
83
|
-
const HIGH_WATER_MARK = DEFAULT_OBJECT_HIGH_WATER_MARK;
|
|
84
|
-
|
|
85
|
-
const iterateOnData = async function * ({onStdoutChunk, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines}) {
|
|
86
|
-
const generators = getGenerators({
|
|
87
|
-
binary,
|
|
88
|
-
shouldEncode,
|
|
89
|
-
encoding,
|
|
90
|
-
shouldSplit,
|
|
91
|
-
preserveNewlines,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
for await (const [chunk] of onStdoutChunk) {
|
|
96
|
-
yield * transformChunkSync(chunk, generators, 0);
|
|
97
|
-
}
|
|
98
|
-
} catch (error) {
|
|
99
|
-
if (!controller.signal.aborted) {
|
|
100
|
-
throw error;
|
|
101
|
-
}
|
|
102
|
-
} finally {
|
|
103
|
-
yield * finalChunksSync(generators);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const getGenerators = ({binary, shouldEncode, encoding, shouldSplit, preserveNewlines}) => [
|
|
108
|
-
getEncodingTransformGenerator(binary, encoding, !shouldEncode),
|
|
109
|
-
getSplitLinesGenerator(binary, preserveNewlines, !shouldSplit, {}),
|
|
110
|
-
].filter(Boolean);
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {MaxBufferError} from 'get-stream';
|
|
2
|
-
import {getStreamName} from '../utils/standard-stream.js';
|
|
3
|
-
import {getFdSpecificValue} from '../arguments/specific.js';
|
|
4
|
-
|
|
5
|
-
// When the `maxBuffer` option is hit, a MaxBufferError is thrown.
|
|
6
|
-
// The stream is aborted, then specific information is kept for the error message.
|
|
7
|
-
export const handleMaxBuffer = ({error, stream, readableObjectMode, lines, encoding, fdNumber}) => {
|
|
8
|
-
if (!(error instanceof MaxBufferError)) {
|
|
9
|
-
throw error;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (fdNumber === 'all') {
|
|
13
|
-
return error;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const unit = getMaxBufferUnit(readableObjectMode, lines, encoding);
|
|
17
|
-
error.maxBufferInfo = {fdNumber, unit};
|
|
18
|
-
stream.destroy();
|
|
19
|
-
throw error;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const getMaxBufferUnit = (readableObjectMode, lines, encoding) => {
|
|
23
|
-
if (readableObjectMode) {
|
|
24
|
-
return 'objects';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (lines) {
|
|
28
|
-
return 'lines';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (encoding === 'buffer') {
|
|
32
|
-
return 'bytes';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return 'characters';
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// Check the `maxBuffer` option with `result.ipcOutput`
|
|
39
|
-
export const checkIpcMaxBuffer = (subprocess, ipcOutput, maxBuffer) => {
|
|
40
|
-
if (ipcOutput.length !== maxBuffer) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const error = new MaxBufferError();
|
|
45
|
-
error.maxBufferInfo = {fdNumber: 'ipc'};
|
|
46
|
-
throw error;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Error message when `maxBuffer` is hit
|
|
50
|
-
export const getMaxBufferMessage = (error, maxBuffer) => {
|
|
51
|
-
const {streamName, threshold, unit} = getMaxBufferInfo(error, maxBuffer);
|
|
52
|
-
return `Command's ${streamName} was larger than ${threshold} ${unit}`;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const getMaxBufferInfo = (error, maxBuffer) => {
|
|
56
|
-
if (error?.maxBufferInfo === undefined) {
|
|
57
|
-
return {streamName: 'output', threshold: maxBuffer[1], unit: 'bytes'};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const {maxBufferInfo: {fdNumber, unit}} = error;
|
|
61
|
-
delete error.maxBufferInfo;
|
|
62
|
-
|
|
63
|
-
const threshold = getFdSpecificValue(maxBuffer, fdNumber);
|
|
64
|
-
if (fdNumber === 'ipc') {
|
|
65
|
-
return {streamName: 'IPC output', threshold, unit: 'messages'};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {streamName: getStreamName(fdNumber), threshold, unit};
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// The only way to apply `maxBuffer` with `spawnSync()` is to use the native `maxBuffer` option Node.js provides.
|
|
72
|
-
// However, this has multiple limitations, and cannot behave the exact same way as the async behavior.
|
|
73
|
-
// When the `maxBuffer` is hit, a `ENOBUFS` error is thrown.
|
|
74
|
-
export const isMaxBufferSync = (resultError, output, maxBuffer) => resultError?.code === 'ENOBUFS'
|
|
75
|
-
&& output !== null
|
|
76
|
-
&& output.some(result => result !== null && result.length > getMaxBufferSync(maxBuffer));
|
|
77
|
-
|
|
78
|
-
// When `maxBuffer` is hit, ensure the result is truncated
|
|
79
|
-
export const truncateMaxBufferSync = (result, isMaxBuffer, maxBuffer) => {
|
|
80
|
-
if (!isMaxBuffer) {
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const maxBufferValue = getMaxBufferSync(maxBuffer);
|
|
85
|
-
return result.length > maxBufferValue ? result.slice(0, maxBufferValue) : result;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// `spawnSync()` does not allow differentiating `maxBuffer` per file descriptor, so we always use `stdout`
|
|
89
|
-
export const getMaxBufferSync = ([, stdoutMaxBuffer]) => stdoutMaxBuffer;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import mergeStreams from '@sindresorhus/merge-streams';
|
|
2
|
-
import {isStandardStream} from '../utils/standard-stream.js';
|
|
3
|
-
import {incrementMaxListeners} from '../utils/max-listeners.js';
|
|
4
|
-
import {TRANSFORM_TYPES} from '../stdio/type.js';
|
|
5
|
-
import {pipeStreams} from './pipeline.js';
|
|
6
|
-
|
|
7
|
-
// Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, after spawning, in async mode
|
|
8
|
-
// When multiple input streams are used, we merge them to ensure the output stream ends only once each input stream has ended
|
|
9
|
-
export const pipeOutputAsync = (subprocess, fileDescriptors, controller) => {
|
|
10
|
-
const pipeGroups = new Map();
|
|
11
|
-
|
|
12
|
-
for (const [fdNumber, {stdioItems, direction}] of Object.entries(fileDescriptors)) {
|
|
13
|
-
for (const {stream} of stdioItems.filter(({type}) => TRANSFORM_TYPES.has(type))) {
|
|
14
|
-
pipeTransform(subprocess, stream, direction, fdNumber);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
for (const {stream} of stdioItems.filter(({type}) => !TRANSFORM_TYPES.has(type))) {
|
|
18
|
-
pipeStdioItem({
|
|
19
|
-
subprocess,
|
|
20
|
-
stream,
|
|
21
|
-
direction,
|
|
22
|
-
fdNumber,
|
|
23
|
-
pipeGroups,
|
|
24
|
-
controller,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
for (const [outputStream, inputStreams] of pipeGroups.entries()) {
|
|
30
|
-
const inputStream = inputStreams.length === 1 ? inputStreams[0] : mergeStreams(inputStreams);
|
|
31
|
-
pipeStreams(inputStream, outputStream);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// When using transforms, `subprocess.stdin|stdout|stderr|stdio` is directly mutated
|
|
36
|
-
const pipeTransform = (subprocess, stream, direction, fdNumber) => {
|
|
37
|
-
if (direction === 'output') {
|
|
38
|
-
pipeStreams(subprocess.stdio[fdNumber], stream);
|
|
39
|
-
} else {
|
|
40
|
-
pipeStreams(stream, subprocess.stdio[fdNumber]);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const streamProperty = SUBPROCESS_STREAM_PROPERTIES[fdNumber];
|
|
44
|
-
if (streamProperty !== undefined) {
|
|
45
|
-
subprocess[streamProperty] = stream;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
subprocess.stdio[fdNumber] = stream;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const SUBPROCESS_STREAM_PROPERTIES = ['stdin', 'stdout', 'stderr'];
|
|
52
|
-
|
|
53
|
-
// Most `std*` option values involve piping `subprocess.std*` to a stream.
|
|
54
|
-
// The stream is either passed by the user or created internally.
|
|
55
|
-
const pipeStdioItem = ({subprocess, stream, direction, fdNumber, pipeGroups, controller}) => {
|
|
56
|
-
if (stream === undefined) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
setStandardStreamMaxListeners(stream, controller);
|
|
61
|
-
|
|
62
|
-
const [inputStream, outputStream] = direction === 'output'
|
|
63
|
-
? [stream, subprocess.stdio[fdNumber]]
|
|
64
|
-
: [subprocess.stdio[fdNumber], stream];
|
|
65
|
-
const outputStreams = pipeGroups.get(inputStream) ?? [];
|
|
66
|
-
pipeGroups.set(inputStream, [...outputStreams, outputStream]);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Multiple subprocesses might be piping from/to `process.std*` at the same time.
|
|
70
|
-
// This is not necessarily an error and should not print a `maxListeners` warning.
|
|
71
|
-
const setStandardStreamMaxListeners = (stream, {signal}) => {
|
|
72
|
-
if (isStandardStream(stream)) {
|
|
73
|
-
incrementMaxListeners(stream, MAX_LISTENERS_INCREMENT, signal);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// `source.pipe(destination)` adds at most 1 listener for each event.
|
|
78
|
-
// If `stdin` option is an array, the values might be combined with `merge-streams`.
|
|
79
|
-
// That library also listens for `source` end, which adds 1 more listener.
|
|
80
|
-
const MAX_LISTENERS_INCREMENT = 2;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import {writeFileSync, appendFileSync} from 'node:fs';
|
|
2
|
-
import {shouldLogOutput, logLinesSync} from '../verbose/output.js';
|
|
3
|
-
import {runGeneratorsSync} from '../transform/generator.js';
|
|
4
|
-
import {splitLinesSync} from '../transform/split.js';
|
|
5
|
-
import {joinToString, joinToUint8Array, bufferToUint8Array} from '../utils/uint-array.js';
|
|
6
|
-
import {FILE_TYPES} from '../stdio/type.js';
|
|
7
|
-
import {truncateMaxBufferSync} from './max-buffer.js';
|
|
8
|
-
|
|
9
|
-
// Apply `stdout`/`stderr` options, after spawning, in sync mode
|
|
10
|
-
export const transformOutputSync = ({fileDescriptors, syncResult: {output}, options, isMaxBuffer, verboseInfo}) => {
|
|
11
|
-
if (output === null) {
|
|
12
|
-
return {output: Array.from({length: 3})};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const state = {};
|
|
16
|
-
const outputFiles = new Set([]);
|
|
17
|
-
const transformedOutput = output.map((result, fdNumber) =>
|
|
18
|
-
transformOutputResultSync({
|
|
19
|
-
result,
|
|
20
|
-
fileDescriptors,
|
|
21
|
-
fdNumber,
|
|
22
|
-
state,
|
|
23
|
-
outputFiles,
|
|
24
|
-
isMaxBuffer,
|
|
25
|
-
verboseInfo,
|
|
26
|
-
}, options));
|
|
27
|
-
return {output: transformedOutput, ...state};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const transformOutputResultSync = (
|
|
31
|
-
{result, fileDescriptors, fdNumber, state, outputFiles, isMaxBuffer, verboseInfo},
|
|
32
|
-
{buffer, encoding, lines, stripFinalNewline, maxBuffer},
|
|
33
|
-
) => {
|
|
34
|
-
if (result === null) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const truncatedResult = truncateMaxBufferSync(result, isMaxBuffer, maxBuffer);
|
|
39
|
-
const uint8ArrayResult = bufferToUint8Array(truncatedResult);
|
|
40
|
-
const {stdioItems, objectMode} = fileDescriptors[fdNumber];
|
|
41
|
-
const chunks = runOutputGeneratorsSync([uint8ArrayResult], stdioItems, encoding, state);
|
|
42
|
-
const {serializedResult, finalResult = serializedResult} = serializeChunks({
|
|
43
|
-
chunks,
|
|
44
|
-
objectMode,
|
|
45
|
-
encoding,
|
|
46
|
-
lines,
|
|
47
|
-
stripFinalNewline,
|
|
48
|
-
fdNumber,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
logOutputSync({
|
|
52
|
-
serializedResult,
|
|
53
|
-
fdNumber,
|
|
54
|
-
state,
|
|
55
|
-
verboseInfo,
|
|
56
|
-
encoding,
|
|
57
|
-
stdioItems,
|
|
58
|
-
objectMode,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const returnedResult = buffer[fdNumber] ? finalResult : undefined;
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
if (state.error === undefined) {
|
|
65
|
-
writeToFiles(serializedResult, stdioItems, outputFiles);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return returnedResult;
|
|
69
|
-
} catch (error) {
|
|
70
|
-
state.error = error;
|
|
71
|
-
return returnedResult;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// Applies transform generators to `stdout`/`stderr`
|
|
76
|
-
const runOutputGeneratorsSync = (chunks, stdioItems, encoding, state) => {
|
|
77
|
-
try {
|
|
78
|
-
return runGeneratorsSync(chunks, stdioItems, encoding, false);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
state.error = error;
|
|
81
|
-
return chunks;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// The contents is converted to three stages:
|
|
86
|
-
// - serializedResult: used when the target is a file path/URL or a file descriptor (including 'inherit')
|
|
87
|
-
// - finalResult/returnedResult: returned as `result.std*`
|
|
88
|
-
const serializeChunks = ({chunks, objectMode, encoding, lines, stripFinalNewline, fdNumber}) => {
|
|
89
|
-
if (objectMode) {
|
|
90
|
-
return {serializedResult: chunks};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (encoding === 'buffer') {
|
|
94
|
-
return {serializedResult: joinToUint8Array(chunks)};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const serializedResult = joinToString(chunks, encoding);
|
|
98
|
-
if (lines[fdNumber]) {
|
|
99
|
-
return {serializedResult, finalResult: splitLinesSync(serializedResult, !stripFinalNewline[fdNumber], objectMode)};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return {serializedResult};
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const logOutputSync = ({serializedResult, fdNumber, state, verboseInfo, encoding, stdioItems, objectMode}) => {
|
|
106
|
-
if (!shouldLogOutput({
|
|
107
|
-
stdioItems,
|
|
108
|
-
encoding,
|
|
109
|
-
verboseInfo,
|
|
110
|
-
fdNumber,
|
|
111
|
-
})) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const linesArray = splitLinesSync(serializedResult, false, objectMode);
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
logLinesSync(linesArray, fdNumber, verboseInfo);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
state.error ??= error;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// When the `std*` target is a file path/URL or a file descriptor
|
|
125
|
-
const writeToFiles = (serializedResult, stdioItems, outputFiles) => {
|
|
126
|
-
for (const {path, append} of stdioItems.filter(({type}) => FILE_TYPES.has(type))) {
|
|
127
|
-
const pathString = typeof path === 'string' ? path : path.toString();
|
|
128
|
-
if (append || outputFiles.has(pathString)) {
|
|
129
|
-
appendFileSync(path, serializedResult);
|
|
130
|
-
} else {
|
|
131
|
-
outputFiles.add(pathString);
|
|
132
|
-
writeFileSync(path, serializedResult);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {finished} from 'node:stream/promises';
|
|
2
|
-
import {isStandardStream} from '../utils/standard-stream.js';
|
|
3
|
-
|
|
4
|
-
// Similar to `Stream.pipeline(source, destination)`, but does not destroy standard streams
|
|
5
|
-
export const pipeStreams = (source, destination) => {
|
|
6
|
-
source.pipe(destination);
|
|
7
|
-
onSourceFinish(source, destination);
|
|
8
|
-
onDestinationFinish(source, destination);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// `source.pipe(destination)` makes `destination` end when `source` ends.
|
|
12
|
-
// But it does not propagate aborts or errors. This function does it.
|
|
13
|
-
const onSourceFinish = async (source, destination) => {
|
|
14
|
-
if (isStandardStream(source) || isStandardStream(destination)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
await finished(source, {cleanup: true, readable: true, writable: false});
|
|
20
|
-
} catch {}
|
|
21
|
-
|
|
22
|
-
endDestinationStream(destination);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const endDestinationStream = destination => {
|
|
26
|
-
if (destination.writable) {
|
|
27
|
-
destination.end();
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// We do the same thing in the other direction as well.
|
|
32
|
-
const onDestinationFinish = async (source, destination) => {
|
|
33
|
-
if (isStandardStream(source) || isStandardStream(destination)) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
await finished(destination, {cleanup: true, readable: false, writable: true});
|
|
39
|
-
} catch {}
|
|
40
|
-
|
|
41
|
-
abortSourceStream(source);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const abortSourceStream = source => {
|
|
45
|
-
if (source.readable) {
|
|
46
|
-
source.destroy();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import stripFinalNewlineFunction from 'strip-final-newline';
|
|
2
|
-
|
|
3
|
-
// Apply `stripFinalNewline` option, which applies to `result.stdout|stderr|all|stdio[*]`.
|
|
4
|
-
// If the `lines` option is used, it is applied on each line, but using a different function.
|
|
5
|
-
export const stripNewline = (value, {stripFinalNewline}, fdNumber) => getStripFinalNewline(stripFinalNewline, fdNumber) && value !== undefined && !Array.isArray(value)
|
|
6
|
-
? stripFinalNewlineFunction(value)
|
|
7
|
-
: value;
|
|
8
|
-
|
|
9
|
-
// Retrieve `stripFinalNewline` option value, including with `subprocess.all`
|
|
10
|
-
export const getStripFinalNewline = (stripFinalNewline, fdNumber) => fdNumber === 'all'
|
|
11
|
-
? stripFinalNewline[1] || stripFinalNewline[2]
|
|
12
|
-
: stripFinalNewline[fdNumber];
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {checkIpcMaxBuffer} from '../io/max-buffer.js';
|
|
2
|
-
import {shouldLogIpc, logIpcOutput} from '../verbose/ipc.js';
|
|
3
|
-
import {getFdSpecificValue} from '../arguments/specific.js';
|
|
4
|
-
import {loopOnMessages} from './get-each.js';
|
|
5
|
-
|
|
6
|
-
// Iterate through IPC messages sent by the subprocess
|
|
7
|
-
export const waitForIpcOutput = async ({
|
|
8
|
-
subprocess,
|
|
9
|
-
buffer: bufferArray,
|
|
10
|
-
maxBuffer: maxBufferArray,
|
|
11
|
-
ipc,
|
|
12
|
-
ipcOutput,
|
|
13
|
-
verboseInfo,
|
|
14
|
-
}) => {
|
|
15
|
-
if (!ipc) {
|
|
16
|
-
return ipcOutput;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const isVerbose = shouldLogIpc(verboseInfo);
|
|
20
|
-
const buffer = getFdSpecificValue(bufferArray, 'ipc');
|
|
21
|
-
const maxBuffer = getFdSpecificValue(maxBufferArray, 'ipc');
|
|
22
|
-
|
|
23
|
-
for await (const message of loopOnMessages({
|
|
24
|
-
anyProcess: subprocess,
|
|
25
|
-
channel: subprocess.channel,
|
|
26
|
-
isSubprocess: false,
|
|
27
|
-
ipc,
|
|
28
|
-
shouldAwait: false,
|
|
29
|
-
reference: true,
|
|
30
|
-
})) {
|
|
31
|
-
if (buffer) {
|
|
32
|
-
checkIpcMaxBuffer(subprocess, ipcOutput, maxBuffer);
|
|
33
|
-
ipcOutput.push(message);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (isVerbose) {
|
|
37
|
-
logIpcOutput(message, verboseInfo);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return ipcOutput;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const getBufferedIpcOutput = async (ipcOutputPromise, ipcOutput) => {
|
|
45
|
-
await Promise.allSettled([ipcOutputPromise]);
|
|
46
|
-
return ipcOutput;
|
|
47
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {EventEmitter} from 'node:events';
|
|
2
|
-
import {onMessage, onDisconnect} from './incoming.js';
|
|
3
|
-
import {undoAddedReferences} from './reference.js';
|
|
4
|
-
|
|
5
|
-
// Forward the `message` and `disconnect` events from the process and subprocess to a proxy emitter.
|
|
6
|
-
// This prevents the `error` event from stopping IPC.
|
|
7
|
-
// This also allows debouncing the `message` event.
|
|
8
|
-
export const getIpcEmitter = (anyProcess, channel, isSubprocess) => {
|
|
9
|
-
if (IPC_EMITTERS.has(anyProcess)) {
|
|
10
|
-
return IPC_EMITTERS.get(anyProcess);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Use an `EventEmitter`, like the `process` that is being proxied
|
|
14
|
-
// eslint-disable-next-line unicorn/prefer-event-target
|
|
15
|
-
const ipcEmitter = new EventEmitter();
|
|
16
|
-
ipcEmitter.connected = true;
|
|
17
|
-
IPC_EMITTERS.set(anyProcess, ipcEmitter);
|
|
18
|
-
forwardEvents({
|
|
19
|
-
ipcEmitter,
|
|
20
|
-
anyProcess,
|
|
21
|
-
channel,
|
|
22
|
-
isSubprocess,
|
|
23
|
-
});
|
|
24
|
-
return ipcEmitter;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const IPC_EMITTERS = new WeakMap();
|
|
28
|
-
|
|
29
|
-
// The `message` and `disconnect` events are buffered in the subprocess until the first listener is setup.
|
|
30
|
-
// However, unbuffering happens after one tick, so this give enough time for the caller to setup the listener on the proxy emitter first.
|
|
31
|
-
// See https://github.com/nodejs/node/blob/2aaeaa863c35befa2ebaa98fb7737ec84df4d8e9/lib/internal/child_process.js#L721
|
|
32
|
-
const forwardEvents = ({ipcEmitter, anyProcess, channel, isSubprocess}) => {
|
|
33
|
-
const boundOnMessage = onMessage.bind(undefined, {
|
|
34
|
-
anyProcess,
|
|
35
|
-
channel,
|
|
36
|
-
isSubprocess,
|
|
37
|
-
ipcEmitter,
|
|
38
|
-
});
|
|
39
|
-
anyProcess.on('message', boundOnMessage);
|
|
40
|
-
anyProcess.once('disconnect', onDisconnect.bind(undefined, {
|
|
41
|
-
anyProcess,
|
|
42
|
-
channel,
|
|
43
|
-
isSubprocess,
|
|
44
|
-
ipcEmitter,
|
|
45
|
-
boundOnMessage,
|
|
46
|
-
}));
|
|
47
|
-
undoAddedReferences(channel, isSubprocess);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// Check whether there might still be some `message` events to receive
|
|
51
|
-
export const isConnected = anyProcess => {
|
|
52
|
-
const ipcEmitter = IPC_EMITTERS.get(anyProcess);
|
|
53
|
-
return ipcEmitter === undefined
|
|
54
|
-
? anyProcess.channel !== null
|
|
55
|
-
: ipcEmitter.connected;
|
|
56
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {once, on} from 'node:events';
|
|
2
|
-
import {validateIpcMethod, disconnect, getStrictResponseError} from './validation.js';
|
|
3
|
-
import {getIpcEmitter, isConnected} from './forward.js';
|
|
4
|
-
import {addReference, removeReference} from './reference.js';
|
|
5
|
-
|
|
6
|
-
// Like `[sub]process.on('message')` but promise-based
|
|
7
|
-
export const getEachMessage = ({anyProcess, channel, isSubprocess, ipc}, {reference = true} = {}) => loopOnMessages({
|
|
8
|
-
anyProcess,
|
|
9
|
-
channel,
|
|
10
|
-
isSubprocess,
|
|
11
|
-
ipc,
|
|
12
|
-
shouldAwait: !isSubprocess,
|
|
13
|
-
reference,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// Same but used internally
|
|
17
|
-
export const loopOnMessages = ({anyProcess, channel, isSubprocess, ipc, shouldAwait, reference}) => {
|
|
18
|
-
validateIpcMethod({
|
|
19
|
-
methodName: 'getEachMessage',
|
|
20
|
-
isSubprocess,
|
|
21
|
-
ipc,
|
|
22
|
-
isConnected: isConnected(anyProcess),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
addReference(channel, reference);
|
|
26
|
-
const ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);
|
|
27
|
-
const controller = new AbortController();
|
|
28
|
-
const state = {};
|
|
29
|
-
stopOnDisconnect(anyProcess, ipcEmitter, controller);
|
|
30
|
-
abortOnStrictError({
|
|
31
|
-
ipcEmitter,
|
|
32
|
-
isSubprocess,
|
|
33
|
-
controller,
|
|
34
|
-
state,
|
|
35
|
-
});
|
|
36
|
-
return iterateOnMessages({
|
|
37
|
-
anyProcess,
|
|
38
|
-
channel,
|
|
39
|
-
ipcEmitter,
|
|
40
|
-
isSubprocess,
|
|
41
|
-
shouldAwait,
|
|
42
|
-
controller,
|
|
43
|
-
state,
|
|
44
|
-
reference,
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const stopOnDisconnect = async (anyProcess, ipcEmitter, controller) => {
|
|
49
|
-
try {
|
|
50
|
-
await once(ipcEmitter, 'disconnect', {signal: controller.signal});
|
|
51
|
-
controller.abort();
|
|
52
|
-
} catch {}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const abortOnStrictError = async ({ipcEmitter, isSubprocess, controller, state}) => {
|
|
56
|
-
try {
|
|
57
|
-
const [error] = await once(ipcEmitter, 'strict:error', {signal: controller.signal});
|
|
58
|
-
state.error = getStrictResponseError(error, isSubprocess);
|
|
59
|
-
controller.abort();
|
|
60
|
-
} catch {}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const iterateOnMessages = async function * ({anyProcess, channel, ipcEmitter, isSubprocess, shouldAwait, controller, state, reference}) {
|
|
64
|
-
try {
|
|
65
|
-
for await (const [message] of on(ipcEmitter, 'message', {signal: controller.signal})) {
|
|
66
|
-
throwIfStrictError(state);
|
|
67
|
-
yield message;
|
|
68
|
-
}
|
|
69
|
-
} catch {
|
|
70
|
-
throwIfStrictError(state);
|
|
71
|
-
} finally {
|
|
72
|
-
controller.abort();
|
|
73
|
-
removeReference(channel, reference);
|
|
74
|
-
|
|
75
|
-
if (!isSubprocess) {
|
|
76
|
-
disconnect(anyProcess);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (shouldAwait) {
|
|
80
|
-
await anyProcess;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const throwIfStrictError = ({error}) => {
|
|
86
|
-
if (error) {
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
};
|