@poe-platform/safe-bash 0.1.809 → 0.1.810
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/dist/audio-ast/index.d.ts +1 -1
- package/dist/audio-ast/index.js +6 -0
- package/dist/audio-ast/wav-source.d.ts +7 -1
- package/dist/image-ast/index.js +1 -1
- package/dist/pdf-ast/cos/mutable-object-store.d.ts +3 -0
- package/dist/pdf-ast/cos/qpdf-json-document.d.ts +42 -0
- package/dist/pdf-ast/cos/qpdf-json-values.d.ts +7 -0
- package/dist/pdf-ast/index.d.ts +1 -0
- package/dist/pdf-ast/index.js +508 -37
- package/dist/pdf-ast/retained-document.d.ts +3 -1
- package/dist/safe-bash/chunks/{chunk-RQCK77SC.js → chunk-65TFMAZU.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-SOFBGDXG.js → chunk-HHSOUC3Z.js} +32 -0
- package/dist/safe-bash/chunks/{chunk-WAZEELYB.js → chunk-ZA5FQ34E.js} +10 -5
- package/dist/safe-bash/command-chunks/biff-ORSHM4YX-QYPGRDAZ.js +4937 -0
- package/dist/safe-bash/command-chunks/{chunk-62ZAHKFS.js → chunk-2VCKUNDZ.js} +130 -14
- package/dist/safe-bash/command-chunks/{chunk-GLVD3JJG.js → chunk-BYZUOF6X.js} +2858 -2816
- package/dist/safe-bash/command-chunks/{chunk-6OKH4X67.js → chunk-CAXJ4RLF.js} +264 -1
- package/dist/safe-bash/command-chunks/{chunk-YJJBGN7U.js → chunk-CHR2OD2U.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-D7XBUF76.js → chunk-D2ASPM7R.js} +109 -23
- package/dist/safe-bash/command-chunks/chunk-D5AYP2UM.js +816 -0
- package/dist/safe-bash/command-chunks/{chunk-WFDG3N5R.js → chunk-ECDEPKKW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-OQCJGUI6.js → chunk-HARUYHH7.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-NVBUC644.js → chunk-HKGNBH7Z.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-MGBHGZEX.js +12 -0
- package/dist/safe-bash/command-chunks/{chunk-4557HE3J.js → chunk-PMWW7KSB.js} +161 -42
- package/dist/safe-bash/command-chunks/{chunk-JW3KIZU6.js → chunk-RUXY7GN5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KELMIFVV.js → chunk-TI52LKLL.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-JJQ72P3V.js → chunk-VCML4T5D.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5HGEXQVD.js → chunk-WC2OCF4H.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-WH3TIOTS.js +326 -0
- package/dist/safe-bash/command-chunks/{chunk-45FI2IPY.js → chunk-WQ6ABTJU.js} +3 -6
- package/dist/safe-bash/command-chunks/{chunk-NB7JO7FE.js → chunk-YTFWPJ3F.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GKYCV6BU.js → chunk-ZEPDT6I5.js} +482 -168
- package/dist/safe-bash/command-chunks/{command-engine-P5DFM4OU.js → command-engine-BEWABZ75.js} +10 -3
- package/dist/safe-bash/command-chunks/{engine-RU4OFLPO-CPLFYD67.js → engine-MEPOXIXT-WZMRHACG.js} +1 -1
- package/dist/safe-bash/command-chunks/pdf-LOZAXXS6-ERI57IAV.js +557 -0
- package/dist/safe-bash/commands/audio/index.browser.js +2 -14
- package/dist/safe-bash/commands/diff-patch/index.js +0 -2
- package/dist/safe-bash/commands/ffprobe/index.browser.js +2 -5
- package/dist/safe-bash/commands/pandoc/index.browser.js +3 -1
- package/dist/safe-bash/commands/text.js +10 -1
- package/dist/safe-bash/core.d.ts +2 -2
- package/dist/safe-bash/core.js +2 -2
- package/dist/safe-bash/full-core.browser.js +18 -22
- package/dist/safe-bash/lazy-optional.d.ts +9 -0
- package/dist/safe-bash/lazy-optional.js +24 -0
- package/dist/safe-bash/plugins/index.browser.js +5 -3
- package/dist/safe-bash/registry-entry.browser.js +1 -1
- package/dist/safe-bash-command-apply-patch/apply.js +2 -2
- package/dist/safe-bash-command-apply-patch/index.js +2 -2
- package/dist/safe-bash-command-apply-patch/parser.d.ts +20 -1
- package/dist/safe-bash-command-apply-patch/parser.js +1 -1
- package/dist/safe-bash-command-ffprobe/index.js +2 -1
- package/dist/safe-bash-command-ffprobe/media.js +2 -1
- package/dist/safe-bash-command-ffprobe/options.d.ts +15 -0
- package/dist/safe-bash-command-ffprobe/options.js +7 -0
- package/dist/safe-bash-command-media/index.js +2 -2
- package/dist/safe-bash-command-media/plugin.js +1 -1
- package/dist/safe-bash-command-media/remote.js +2 -2
- package/dist/safe-bash-command-pandoc/command.js +6 -6
- package/dist/safe-bash-command-pandoc/index.js +31 -31
- package/dist/safe-bash-command-patch/index.js +2 -2
- package/dist/safe-bash-command-patch/patch-publication.d.ts +2 -2
- package/dist/safe-bash-command-patch/patch-publication.js +1 -1
- package/dist/safe-bash-command-patch/patch.js +2 -2
- package/dist/safe-bash-command-pptx/engine.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +2 -2
- package/dist/safe-bash-command-xmllint/index.js +137 -30
- package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
- package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
- package/dist/safe-bash-compression-engine/files.js +5 -5
- package/dist/safe-bash-compression-engine/index.js +4 -4
- package/dist/safe-bash-compression-engine/operand.js +5 -5
- package/dist/safe-bash-compression-engine/stream.js +4 -4
- package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
- package/dist/safe-bash-media-engine/imagemagick.d.ts +2 -0
- package/dist/safe-bash-media-engine/index.js +162 -72
- package/dist/safe-bash-network-engine/body.d.ts +1 -0
- package/dist/safe-bash-network-engine/body.js +1 -1
- package/dist/safe-bash-network-engine/transfer.js +11 -3
- package/dist/safe-bash-presentation-engine/command-placeholder.js +4 -3
- package/dist/safe-bash-presentation-engine/index.d.ts +1 -1
- package/dist/safe-bash-presentation-engine/index.js +9 -4
- package/dist/safe-bash-presentation-engine/presentation-model.js +3 -2
- package/dist/safe-bash-presentation-engine/retained-text.js +3 -3
- package/dist/safe-bash-presentation-engine/retained-xml-parts.d.ts +26 -0
- package/dist/safe-bash-presentation-engine/xml-parts.d.ts +1 -0
- package/dist/safe-bash-presentation-engine/xml-parts.js +7 -1
- package/dist/safe-bash-xml-engine/document.js +1 -1
- package/dist/safe-bash-xml-engine/index.js +1 -1
- package/dist/spreadsheet-engine/rendering/print/tab-layout.d.ts +11 -0
- package/dist/spreadsheet-engine/rendering/print/tab-layout.js +15 -0
- package/dist/spreadsheet-engine/rendering/print/text-lines.d.ts +2 -2
- package/dist/spreadsheet-engine/rendering/print/text-lines.js +3 -3
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +4 -0
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +137 -56
- package/dist/spreadsheet-format-xls/biff-encryption.d.ts +1 -1
- package/dist/spreadsheet-format-xls/biff-encryption.js +8 -3
- package/dist/spreadsheet-format-xls/biff-property-bytes.d.ts +1 -1
- package/dist/spreadsheet-format-xls/biff-property-bytes.js +2 -2
- package/dist/spreadsheet-format-xls/biff.js +11 -3
- package/package.json +3 -2
- package/dist/safe-bash/chunks/chunk-I2A5ZCPD.js +0 -17
- package/dist/safe-bash/chunks/chunk-PQTT2EZP.js +0 -8
- package/dist/safe-bash/command-chunks/biff-DS263V2K-2GP4GZT7.js +0 -4868
- package/dist/safe-bash/command-chunks/chunk-6ZFYWT3U.js +0 -581
- package/dist/safe-bash/command-chunks/chunk-S244SWDH.js +0 -153
- package/dist/safe-bash/command-chunks/pdf-T7AWYZGQ-KNAYJ7YF.js +0 -552
- /package/dist/safe-bash/command-chunks/{chunk-EMMSXKEJ.js → chunk-4Q4R3VZU.js} +0 -0
|
@@ -61,7 +61,7 @@ async function parse(text, work) {
|
|
|
61
61
|
} };
|
|
62
62
|
} }, work);
|
|
63
63
|
}
|
|
64
|
-
async function parseRecords(lines, work) {
|
|
64
|
+
async function parseRecords(lines, work, collections) {
|
|
65
65
|
if (!lines.length || (await lines.get(0)).prefix !== "*** Begin Patch" || (await lines.get(lines.length - 1)).prefix !== "*** End Patch") throw new PatchError("expected Begin Patch and End Patch envelope", 2);
|
|
66
66
|
const files = [];
|
|
67
67
|
let index = 1;
|
|
@@ -87,8 +87,8 @@ async function parseRecords(lines, work) {
|
|
|
87
87
|
destinationLabel = await (await lines.get(index++)).read(13);
|
|
88
88
|
destination = await targetPath(destinationLabel, work);
|
|
89
89
|
}
|
|
90
|
-
const added = [];
|
|
91
|
-
const hunks = [];
|
|
90
|
+
const added = collections?.texts() ?? [];
|
|
91
|
+
const hunks = collections?.hunks() ?? [];
|
|
92
92
|
let current;
|
|
93
93
|
let finished = false;
|
|
94
94
|
while (index < lines.length - 1) {
|
|
@@ -97,7 +97,7 @@ async function parseRecords(lines, work) {
|
|
|
97
97
|
if (line.prefix.startsWith("*** Add File: ") || line.prefix.startsWith("*** Delete File: ") || line.prefix.startsWith("*** Update File: ")) break;
|
|
98
98
|
if (kind === "add") {
|
|
99
99
|
if (!line.prefix.startsWith("+")) throw new PatchError(`invalid Add body at patch line ${index + 1}`, 2);
|
|
100
|
-
added.push(line.slice(1));
|
|
100
|
+
await added.push(line.slice(1));
|
|
101
101
|
} else if (kind === "delete") throw new PatchError("Delete cannot have a body", 2);
|
|
102
102
|
else if (finished) throw new PatchError("EOF must terminate the file's last hunk", 2);
|
|
103
103
|
else if (line.prefix === "@@" || line.prefix.startsWith("@@ ")) {
|
|
@@ -106,10 +106,10 @@ async function parseRecords(lines, work) {
|
|
|
106
106
|
if (!named || current.anchors.length === 0) throw new PatchError("empty update hunk", 2);
|
|
107
107
|
} else {
|
|
108
108
|
work.count("maxHunks", 1);
|
|
109
|
-
current
|
|
110
|
-
|
|
109
|
+
if (current) await hunks.push(current);
|
|
110
|
+
current = { anchors: collections?.texts() ?? [], lines: collections?.lines() ?? [], eof: false };
|
|
111
111
|
}
|
|
112
|
-
if (named) current.anchors.push(line.slice(3));
|
|
112
|
+
if (named) await current.anchors.push(line.slice(3));
|
|
113
113
|
} else if (line.prefix === "*** End of File") {
|
|
114
114
|
if (!current?.lines.length) throw new PatchError("EOF requires a nonempty hunk", 2);
|
|
115
115
|
current.eof = true;
|
|
@@ -119,13 +119,13 @@ async function parseRecords(lines, work) {
|
|
|
119
119
|
if (prefix !== " " && prefix !== "+" && prefix !== "-") throw new PatchError(`invalid hunk line ${index + 1}`, 2);
|
|
120
120
|
if (!current) {
|
|
121
121
|
work.count("maxHunks", 1);
|
|
122
|
-
current = { anchors: [], lines: [], eof: false };
|
|
123
|
-
hunks.push(current);
|
|
122
|
+
current = { anchors: collections?.texts() ?? [], lines: collections?.lines() ?? [], eof: false };
|
|
124
123
|
}
|
|
125
|
-
current.lines.push({ kind: prefix, text: line.slice(1) });
|
|
124
|
+
await current.lines.push({ kind: prefix, text: line.slice(1) });
|
|
126
125
|
}
|
|
127
126
|
index++;
|
|
128
127
|
}
|
|
128
|
+
if (current) await hunks.push(current);
|
|
129
129
|
if (kind === "update" && (hunks.length === 0 ? destination === void 0 : !current?.lines.length)) throw new PatchError("Update requires a nonempty hunk", 2);
|
|
130
130
|
files.push({ kind, path, label, added, hunks, ...destination === void 0 ? {} : { destination, destinationLabel } });
|
|
131
131
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// packages/safe-bash-command-ffprobe/src/options.ts
|
|
2
|
+
function resolveFfprobeLimits(options) {
|
|
3
|
+
const limits = { maxInputBytes: 32 * 1024 * 1024, maxOutputBytes: 1024 * 1024, ...options };
|
|
4
|
+
for (const value of [limits.maxInputBytes, limits.maxOutputBytes]) {
|
|
5
|
+
if (value !== void 0 && (!Number.isSafeInteger(value) || value < 1)) throw new RangeError("Invalid ffprobe limit");
|
|
6
|
+
}
|
|
7
|
+
return limits;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
resolveFfprobeLimits
|
|
12
|
+
};
|
|
@@ -20,9 +20,83 @@ import {
|
|
|
20
20
|
import { readFileStream } from "../../safe-bash-contracts/filesystem.js";
|
|
21
21
|
import { readBytes } from "../../safe-bash-contracts/index.js";
|
|
22
22
|
import { posixPath as posix } from "../../safe-bash-contracts/path.js";
|
|
23
|
-
import { yieldTurn } from "../../safe-bash-contracts/yield.js";
|
|
23
|
+
import { inheritYieldCheckpoint, yieldTurn as yieldTurn2 } from "../../safe-bash-contracts/yield.js";
|
|
24
24
|
import { decodeBytes, encodeBytes } from "../../safe-bash-io-engine/byte-encoding.js";
|
|
25
25
|
import { pathOf } from "../../safe-bash-io-engine/internal.js";
|
|
26
|
+
|
|
27
|
+
// packages/safe-bash-network-engine/src/replay.ts
|
|
28
|
+
import { FsError } from "../../safe-bash-contracts/index.js";
|
|
29
|
+
import { yieldTurn } from "../../safe-bash-contracts/yield.js";
|
|
30
|
+
function verify(actual, expected) {
|
|
31
|
+
const identity = expected.opaqueIdentity !== void 0 ? actual.opaqueIdentity === expected.opaqueIdentity : expected.dev !== void 0 && expected.ino !== void 0 && actual.dev === expected.dev && actual.ino === expected.ino;
|
|
32
|
+
if (!identity || expected.identityScope === void 0 || actual.identityScope !== expected.identityScope || actual.type !== "file" || actual.size !== expected.size || actual.revision !== expected.revision || actual.opaqueVersion !== expected.opaqueVersion || actual.mtimeMs !== expected.mtimeMs || actual.ctimeMs !== expected.ctimeMs)
|
|
33
|
+
throw new FsError("EBUSY", { message: "Upload replay storage changed" });
|
|
34
|
+
}
|
|
35
|
+
async function createReplay(fs, directory, signal) {
|
|
36
|
+
const parent = await fs.stat(directory, { signal });
|
|
37
|
+
const caps = await fs.capabilitiesFor?.(directory, { signal }) ?? fs.capabilities;
|
|
38
|
+
if (!caps.retainedStagingCleanup || !caps.retainedStagingWrite || !caps.retainedRead || !fs.createStagedFile || !fs.openReadFile)
|
|
39
|
+
throw new FsError("ENOTSUP", { message: "Upload replay requires retained caller storage" });
|
|
40
|
+
const name = Array.from(randomBytes(18), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
41
|
+
const stage = await fs.createStagedFile(`${directory === "/" ? "" : directory}/.curl-replay-${name}`, "upload", { type: "file", data: new Uint8Array() }, { parent, mode: 384, retainCleanup: true, signal });
|
|
42
|
+
const { writer, cleanup } = stage;
|
|
43
|
+
if (!writer || !cleanup) {
|
|
44
|
+
try {
|
|
45
|
+
await cleanup?.remove();
|
|
46
|
+
} finally {
|
|
47
|
+
await cleanup?.close();
|
|
48
|
+
}
|
|
49
|
+
throw new FsError("EIO", { message: "Missing retained upload handles" });
|
|
50
|
+
}
|
|
51
|
+
let size = 0;
|
|
52
|
+
let sealed;
|
|
53
|
+
let reader;
|
|
54
|
+
let closing;
|
|
55
|
+
return {
|
|
56
|
+
async write(bytes) {
|
|
57
|
+
for (let offset = 0; offset < bytes.length; offset += 16384) {
|
|
58
|
+
const chunk = bytes.slice(offset, offset + 16384);
|
|
59
|
+
await writer.write(chunk, { signal });
|
|
60
|
+
size += chunk.length;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
async *read(replaySignal) {
|
|
64
|
+
replaySignal.throwIfAborted();
|
|
65
|
+
sealed ??= await writer.finish({ signal: replaySignal });
|
|
66
|
+
if (sealed.size !== size) throw new FsError("EIO", { message: "Incomplete upload replay storage" });
|
|
67
|
+
reader ??= await fs.openReadFile(stage.file.path, { signal: replaySignal });
|
|
68
|
+
verify(await reader.stat({ signal: replaySignal }), sealed);
|
|
69
|
+
let chunks = 0;
|
|
70
|
+
for (let position = 0; position < size; ) {
|
|
71
|
+
if (++chunks % 256 === 0) await yieldTurn(replaySignal);
|
|
72
|
+
replaySignal.throwIfAborted();
|
|
73
|
+
verify(await reader.stat({ signal: replaySignal }), sealed);
|
|
74
|
+
const count = Math.min(16384, size - position);
|
|
75
|
+
const bytes = await reader.read(position, count, { signal: replaySignal });
|
|
76
|
+
if (!bytes.length || bytes.length > count) throw new FsError("EIO", { message: "Invalid upload replay read" });
|
|
77
|
+
verify(await reader.stat({ signal: replaySignal }), sealed);
|
|
78
|
+
position += bytes.length;
|
|
79
|
+
yield bytes.slice();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
close() {
|
|
83
|
+
closing ??= (async () => {
|
|
84
|
+
try {
|
|
85
|
+
await reader?.close();
|
|
86
|
+
} finally {
|
|
87
|
+
try {
|
|
88
|
+
await cleanup.remove();
|
|
89
|
+
} finally {
|
|
90
|
+
await cleanup.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
})();
|
|
94
|
+
return closing;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// packages/safe-bash-network-engine/src/body.ts
|
|
26
100
|
function multipartBoundary() {
|
|
27
101
|
let boundary = "virtual-bash-";
|
|
28
102
|
for (const byte of randomBytes(18)) boundary += byte.toString(16).padStart(2, "0");
|
|
@@ -214,7 +288,7 @@ async function* transfer(source, encoder, signal) {
|
|
|
214
288
|
yield encode(output);
|
|
215
289
|
output = "";
|
|
216
290
|
}
|
|
217
|
-
await
|
|
291
|
+
await yieldTurn2(signal);
|
|
218
292
|
}
|
|
219
293
|
}
|
|
220
294
|
signal.throwIfAborted();
|
|
@@ -251,8 +325,12 @@ function createBody(context, args, limits) {
|
|
|
251
325
|
let opened = false;
|
|
252
326
|
let replayComplete = false;
|
|
253
327
|
let replayable = true;
|
|
254
|
-
let
|
|
255
|
-
let
|
|
328
|
+
let replay;
|
|
329
|
+
let active = false;
|
|
330
|
+
let activeIterator;
|
|
331
|
+
const lifetime = new AbortController();
|
|
332
|
+
let closing;
|
|
333
|
+
let closed = false;
|
|
256
334
|
let stdinUsed = false;
|
|
257
335
|
const source = async function* (part, signal) {
|
|
258
336
|
if (part.bytes !== void 0) {
|
|
@@ -303,51 +381,90 @@ function createBody(context, args, limits) {
|
|
|
303
381
|
};
|
|
304
382
|
return {
|
|
305
383
|
...contentType === void 0 ? {} : { contentType },
|
|
384
|
+
close() {
|
|
385
|
+
closed = true;
|
|
386
|
+
lifetime.abort();
|
|
387
|
+
closing ??= (async () => {
|
|
388
|
+
try {
|
|
389
|
+
await activeIterator?.return(void 0);
|
|
390
|
+
} finally {
|
|
391
|
+
await replay?.close();
|
|
392
|
+
}
|
|
393
|
+
})();
|
|
394
|
+
return closing;
|
|
395
|
+
},
|
|
306
396
|
open(signal) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
397
|
+
const combined = AbortSignal.any([signal, lifetime.signal]);
|
|
398
|
+
inheritYieldCheckpoint(signal, combined);
|
|
399
|
+
signal = combined;
|
|
400
|
+
async function* generate() {
|
|
401
|
+
signal.throwIfAborted();
|
|
402
|
+
if (closed || active) throw new CurlError(65, "Upload body is closed or in use");
|
|
403
|
+
active = true;
|
|
404
|
+
activeIterator = iterator;
|
|
405
|
+
try {
|
|
406
|
+
if (hasStdin && opened) {
|
|
407
|
+
if (!replayComplete || !replayable || !replay) throw new CurlError(65, "Cannot replay stdin upload from caller storage");
|
|
408
|
+
try {
|
|
409
|
+
yield* replay.read(signal);
|
|
410
|
+
} catch {
|
|
411
|
+
replayable = false;
|
|
412
|
+
signal.throwIfAborted();
|
|
413
|
+
throw new CurlError(65, "Failed reading stdin replay storage");
|
|
414
|
+
}
|
|
415
|
+
return;
|
|
313
416
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
for (const part of parts) {
|
|
320
|
-
if (part.separator && count === 0) continue;
|
|
321
|
-
let prefix = part.prefix;
|
|
322
|
-
for await (const raw of transfer(source(part, signal), part.encoder, signal)) {
|
|
323
|
-
if (++chunks % 256 === 0) await yieldTurn(signal);
|
|
324
|
-
for (let offset = 0; offset < raw.length; offset += 16 * 1024) {
|
|
417
|
+
opened = true;
|
|
418
|
+
if (hasStdin) {
|
|
419
|
+
try {
|
|
420
|
+
replay = await createReplay(context.fs, context.cwd, signal);
|
|
421
|
+
} catch {
|
|
325
422
|
signal.throwIfAborted();
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
423
|
+
replayable = false;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
let count = 0;
|
|
427
|
+
let chunks = 0;
|
|
428
|
+
for (const part of parts) {
|
|
429
|
+
if (part.separator && count === 0) continue;
|
|
430
|
+
let prefix = part.prefix;
|
|
431
|
+
for await (const raw of transfer(source(part, signal), part.encoder, signal)) {
|
|
432
|
+
if (++chunks % 256 === 0) await yieldTurn2(signal);
|
|
433
|
+
for (let offset = 0; offset < raw.length; offset += 16 * 1024) {
|
|
434
|
+
signal.throwIfAborted();
|
|
435
|
+
let chunk = raw.subarray(offset, offset + 16 * 1024);
|
|
436
|
+
if (part.strip) chunk = chunk.filter((byte) => byte !== 0 && byte !== 10 && byte !== 13);
|
|
437
|
+
if (part.urlencode) chunk = percent(chunk);
|
|
438
|
+
count += chunk.length + (prefix?.length ?? 0);
|
|
439
|
+
if (count > limits.maxUploadBytes) throw new CurlError(63, "Upload exceeds host byte limit");
|
|
440
|
+
if (prefix?.length) {
|
|
441
|
+
const prefixed = new Uint8Array(prefix.length + chunk.length);
|
|
442
|
+
prefixed.set(prefix);
|
|
443
|
+
prefixed.set(chunk, prefix.length);
|
|
444
|
+
chunk = prefixed;
|
|
445
|
+
prefix = void 0;
|
|
446
|
+
}
|
|
447
|
+
if (hasStdin && replayable) {
|
|
448
|
+
try {
|
|
449
|
+
await replay.write(chunk);
|
|
450
|
+
} catch {
|
|
451
|
+
signal.throwIfAborted();
|
|
452
|
+
replayable = false;
|
|
453
|
+
await replay.close();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (chunk.length) yield chunk;
|
|
344
457
|
}
|
|
345
|
-
if (chunk.length) yield chunk;
|
|
346
458
|
}
|
|
347
459
|
}
|
|
460
|
+
replayComplete = true;
|
|
461
|
+
} finally {
|
|
462
|
+
active = false;
|
|
463
|
+
activeIterator = void 0;
|
|
348
464
|
}
|
|
349
|
-
|
|
350
|
-
|
|
465
|
+
}
|
|
466
|
+
const iterator = generate();
|
|
467
|
+
return iterator;
|
|
351
468
|
}
|
|
352
469
|
};
|
|
353
470
|
}
|
|
@@ -358,6 +475,8 @@ async function queryData(body, signal, limits) {
|
|
|
358
475
|
signal.throwIfAborted();
|
|
359
476
|
if (error instanceof CurlError) throw error;
|
|
360
477
|
throw new CurlError(63, "Query data exceeds host buffer limit");
|
|
478
|
+
} finally {
|
|
479
|
+
await body.close();
|
|
361
480
|
}
|
|
362
481
|
}
|
|
363
482
|
|