@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.
Files changed (109) hide show
  1. package/dist/audio-ast/index.d.ts +1 -1
  2. package/dist/audio-ast/index.js +6 -0
  3. package/dist/audio-ast/wav-source.d.ts +7 -1
  4. package/dist/image-ast/index.js +1 -1
  5. package/dist/pdf-ast/cos/mutable-object-store.d.ts +3 -0
  6. package/dist/pdf-ast/cos/qpdf-json-document.d.ts +42 -0
  7. package/dist/pdf-ast/cos/qpdf-json-values.d.ts +7 -0
  8. package/dist/pdf-ast/index.d.ts +1 -0
  9. package/dist/pdf-ast/index.js +508 -37
  10. package/dist/pdf-ast/retained-document.d.ts +3 -1
  11. package/dist/safe-bash/chunks/{chunk-RQCK77SC.js → chunk-65TFMAZU.js} +2 -2
  12. package/dist/safe-bash/chunks/{chunk-SOFBGDXG.js → chunk-HHSOUC3Z.js} +32 -0
  13. package/dist/safe-bash/chunks/{chunk-WAZEELYB.js → chunk-ZA5FQ34E.js} +10 -5
  14. package/dist/safe-bash/command-chunks/biff-ORSHM4YX-QYPGRDAZ.js +4937 -0
  15. package/dist/safe-bash/command-chunks/{chunk-62ZAHKFS.js → chunk-2VCKUNDZ.js} +130 -14
  16. package/dist/safe-bash/command-chunks/{chunk-GLVD3JJG.js → chunk-BYZUOF6X.js} +2858 -2816
  17. package/dist/safe-bash/command-chunks/{chunk-6OKH4X67.js → chunk-CAXJ4RLF.js} +264 -1
  18. package/dist/safe-bash/command-chunks/{chunk-YJJBGN7U.js → chunk-CHR2OD2U.js} +9 -9
  19. package/dist/safe-bash/command-chunks/{chunk-D7XBUF76.js → chunk-D2ASPM7R.js} +109 -23
  20. package/dist/safe-bash/command-chunks/chunk-D5AYP2UM.js +816 -0
  21. package/dist/safe-bash/command-chunks/{chunk-WFDG3N5R.js → chunk-ECDEPKKW.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-OQCJGUI6.js → chunk-HARUYHH7.js} +10 -10
  23. package/dist/safe-bash/command-chunks/{chunk-NVBUC644.js → chunk-HKGNBH7Z.js} +2 -2
  24. package/dist/safe-bash/command-chunks/chunk-MGBHGZEX.js +12 -0
  25. package/dist/safe-bash/command-chunks/{chunk-4557HE3J.js → chunk-PMWW7KSB.js} +161 -42
  26. package/dist/safe-bash/command-chunks/{chunk-JW3KIZU6.js → chunk-RUXY7GN5.js} +1 -1
  27. package/dist/safe-bash/command-chunks/{chunk-KELMIFVV.js → chunk-TI52LKLL.js} +1 -1
  28. package/dist/safe-bash/command-chunks/{chunk-JJQ72P3V.js → chunk-VCML4T5D.js} +1 -1
  29. package/dist/safe-bash/command-chunks/{chunk-5HGEXQVD.js → chunk-WC2OCF4H.js} +1 -1
  30. package/dist/safe-bash/command-chunks/chunk-WH3TIOTS.js +326 -0
  31. package/dist/safe-bash/command-chunks/{chunk-45FI2IPY.js → chunk-WQ6ABTJU.js} +3 -6
  32. package/dist/safe-bash/command-chunks/{chunk-NB7JO7FE.js → chunk-YTFWPJ3F.js} +1 -1
  33. package/dist/safe-bash/command-chunks/{chunk-GKYCV6BU.js → chunk-ZEPDT6I5.js} +482 -168
  34. package/dist/safe-bash/command-chunks/{command-engine-P5DFM4OU.js → command-engine-BEWABZ75.js} +10 -3
  35. package/dist/safe-bash/command-chunks/{engine-RU4OFLPO-CPLFYD67.js → engine-MEPOXIXT-WZMRHACG.js} +1 -1
  36. package/dist/safe-bash/command-chunks/pdf-LOZAXXS6-ERI57IAV.js +557 -0
  37. package/dist/safe-bash/commands/audio/index.browser.js +2 -14
  38. package/dist/safe-bash/commands/diff-patch/index.js +0 -2
  39. package/dist/safe-bash/commands/ffprobe/index.browser.js +2 -5
  40. package/dist/safe-bash/commands/pandoc/index.browser.js +3 -1
  41. package/dist/safe-bash/commands/text.js +10 -1
  42. package/dist/safe-bash/core.d.ts +2 -2
  43. package/dist/safe-bash/core.js +2 -2
  44. package/dist/safe-bash/full-core.browser.js +18 -22
  45. package/dist/safe-bash/lazy-optional.d.ts +9 -0
  46. package/dist/safe-bash/lazy-optional.js +24 -0
  47. package/dist/safe-bash/plugins/index.browser.js +5 -3
  48. package/dist/safe-bash/registry-entry.browser.js +1 -1
  49. package/dist/safe-bash-command-apply-patch/apply.js +2 -2
  50. package/dist/safe-bash-command-apply-patch/index.js +2 -2
  51. package/dist/safe-bash-command-apply-patch/parser.d.ts +20 -1
  52. package/dist/safe-bash-command-apply-patch/parser.js +1 -1
  53. package/dist/safe-bash-command-ffprobe/index.js +2 -1
  54. package/dist/safe-bash-command-ffprobe/media.js +2 -1
  55. package/dist/safe-bash-command-ffprobe/options.d.ts +15 -0
  56. package/dist/safe-bash-command-ffprobe/options.js +7 -0
  57. package/dist/safe-bash-command-media/index.js +2 -2
  58. package/dist/safe-bash-command-media/plugin.js +1 -1
  59. package/dist/safe-bash-command-media/remote.js +2 -2
  60. package/dist/safe-bash-command-pandoc/command.js +6 -6
  61. package/dist/safe-bash-command-pandoc/index.js +31 -31
  62. package/dist/safe-bash-command-patch/index.js +2 -2
  63. package/dist/safe-bash-command-patch/patch-publication.d.ts +2 -2
  64. package/dist/safe-bash-command-patch/patch-publication.js +1 -1
  65. package/dist/safe-bash-command-patch/patch.js +2 -2
  66. package/dist/safe-bash-command-pptx/engine.js +1 -1
  67. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  68. package/dist/safe-bash-command-xmllint/index.js +137 -30
  69. package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
  70. package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
  71. package/dist/safe-bash-compression-engine/files.js +5 -5
  72. package/dist/safe-bash-compression-engine/index.js +4 -4
  73. package/dist/safe-bash-compression-engine/operand.js +5 -5
  74. package/dist/safe-bash-compression-engine/stream.js +4 -4
  75. package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
  76. package/dist/safe-bash-media-engine/imagemagick.d.ts +2 -0
  77. package/dist/safe-bash-media-engine/index.js +162 -72
  78. package/dist/safe-bash-network-engine/body.d.ts +1 -0
  79. package/dist/safe-bash-network-engine/body.js +1 -1
  80. package/dist/safe-bash-network-engine/transfer.js +11 -3
  81. package/dist/safe-bash-presentation-engine/command-placeholder.js +4 -3
  82. package/dist/safe-bash-presentation-engine/index.d.ts +1 -1
  83. package/dist/safe-bash-presentation-engine/index.js +9 -4
  84. package/dist/safe-bash-presentation-engine/presentation-model.js +3 -2
  85. package/dist/safe-bash-presentation-engine/retained-text.js +3 -3
  86. package/dist/safe-bash-presentation-engine/retained-xml-parts.d.ts +26 -0
  87. package/dist/safe-bash-presentation-engine/xml-parts.d.ts +1 -0
  88. package/dist/safe-bash-presentation-engine/xml-parts.js +7 -1
  89. package/dist/safe-bash-xml-engine/document.js +1 -1
  90. package/dist/safe-bash-xml-engine/index.js +1 -1
  91. package/dist/spreadsheet-engine/rendering/print/tab-layout.d.ts +11 -0
  92. package/dist/spreadsheet-engine/rendering/print/tab-layout.js +15 -0
  93. package/dist/spreadsheet-engine/rendering/print/text-lines.d.ts +2 -2
  94. package/dist/spreadsheet-engine/rendering/print/text-lines.js +3 -3
  95. package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +4 -0
  96. package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +137 -56
  97. package/dist/spreadsheet-format-xls/biff-encryption.d.ts +1 -1
  98. package/dist/spreadsheet-format-xls/biff-encryption.js +8 -3
  99. package/dist/spreadsheet-format-xls/biff-property-bytes.d.ts +1 -1
  100. package/dist/spreadsheet-format-xls/biff-property-bytes.js +2 -2
  101. package/dist/spreadsheet-format-xls/biff.js +11 -3
  102. package/package.json +3 -2
  103. package/dist/safe-bash/chunks/chunk-I2A5ZCPD.js +0 -17
  104. package/dist/safe-bash/chunks/chunk-PQTT2EZP.js +0 -8
  105. package/dist/safe-bash/command-chunks/biff-DS263V2K-2GP4GZT7.js +0 -4868
  106. package/dist/safe-bash/command-chunks/chunk-6ZFYWT3U.js +0 -581
  107. package/dist/safe-bash/command-chunks/chunk-S244SWDH.js +0 -153
  108. package/dist/safe-bash/command-chunks/pdf-T7AWYZGQ-KNAYJ7YF.js +0 -552
  109. /package/dist/safe-bash/command-chunks/{chunk-EMMSXKEJ.js → chunk-4Q4R3VZU.js} +0 -0
@@ -10,7 +10,7 @@ import {
10
10
  gt,
11
11
  j,
12
12
  oe
13
- } from "../safe-bash/command-chunks/chunk-YJJBGN7U.js";
13
+ } from "../safe-bash/command-chunks/chunk-CHR2OD2U.js";
14
14
  import {
15
15
  a,
16
16
  g,
@@ -719,7 +719,7 @@ var le;
719
719
  function wr(...u) {
720
720
  return le ??= V({ read: readZipArchiveEntries, write: createStoredZipArchive }), le(...u);
721
721
  }
722
- var H = de(async (u) => (await import("../safe-bash/command-chunks/engine-RU4OFLPO-CPLFYD67.js")).createEngine(u), true, wr);
722
+ var H = de(async (u) => (await import("../safe-bash/command-chunks/engine-MEPOXIXT-WZMRHACG.js")).createEngine(u), true, wr);
723
723
  var Do = H.createSsconvertCommand;
724
724
  var To = H.createSsconvertCommands;
725
725
  var Uo = H.ssconvertCommands;
@@ -6,13 +6,125 @@ import { createXqCommand } from "../safe-bash-command-xq/index.js";
6
6
  import { readXmlChunks, readXmlInput } from "../safe-bash-xml-engine/io.js";
7
7
  import { parseXmlStream, parseXmlSteps, XmlLimitError } from "@poe-platform/safe-fs/core";
8
8
  import {
9
- FsError,
9
+ FsError as FsError2,
10
10
  getCommandArguments,
11
11
  writeBytes
12
12
  } from "../safe-bash-contracts/index.js";
13
13
  import { StoredXPath } from "../safe-bash-xml-engine/stored-evaluate.js";
14
14
  import { StoredXmlDocument } from "../safe-bash-xml-engine/stored-document.js";
15
- import { writeFileOutput } from "../safe-bash-contracts/filesystem-output.js";
15
+
16
+ // packages/safe-bash-command-xmllint/src/file-output.ts
17
+ import { FsError } from "@poe-platform/safe-fs/core";
18
+ import { PagedStorage } from "@poe-platform/safe-fs/storage";
19
+ import { openFileOutput, writeFileOutput } from "../safe-bash-contracts/filesystem-output.js";
20
+ var XmlFileOutput = class {
21
+ constructor(context, path) {
22
+ this.context = context;
23
+ this.path = path;
24
+ context.registerCleanup?.(() => this.close());
25
+ }
26
+ context;
27
+ path;
28
+ staging;
29
+ resolution;
30
+ storage;
31
+ start = 0;
32
+ size = 0;
33
+ closing;
34
+ initialized;
35
+ active;
36
+ async initialize() {
37
+ const { fs, signal } = this.context;
38
+ signal.throwIfAborted();
39
+ const capabilities = await fs.capabilitiesFor?.(this.path, { signal, stagingResolution: true, followFinalSymlink: true }) ?? fs.capabilities;
40
+ if (capabilities.synchronousFollowedStagingResolution && capabilities.guardedStagingPublication && capabilities.atomicFileStaging && capabilities.atomicStagedFileMutation && capabilities.atomicStagingAncestry && capabilities.retainedStagingWrite && capabilities.retainedStagingCleanup && fs.prepareStagingResolution && fs.createStagedFile && fs.publishStagedFile) {
41
+ this.resolution = await fs.prepareStagingResolution(this.path, { signal, followFinalSymlink: true });
42
+ const target = this.resolution;
43
+ target.validate();
44
+ this.staging = await fs.createStagedFile(`${target.ancestors.at(-1).path === "/" ? "" : target.ancestors.at(-1).path}/.xmllint-${crypto.randomUUID()}`, "output", {
45
+ type: "file",
46
+ data: new Uint8Array()
47
+ }, { parent: target.parent, mode: target.destination ? target.destination.mode & 4095 : 438, retainCleanup: true, signal });
48
+ signal.throwIfAborted();
49
+ if (!this.staging.writer || !this.staging.cleanup) throw new FsError("ENOTSUP", { path: this.path, message: "XML output requires retained staging handles" });
50
+ } else {
51
+ this.storage = new PagedStorage(this.context, 4);
52
+ this.start = this.storage.allocate(0);
53
+ }
54
+ }
55
+ write(bytes) {
56
+ if (this.closing) return Promise.reject(new FsError("EBADF", { path: this.path }));
57
+ const task = (async () => {
58
+ await (this.initialized ??= this.initialize());
59
+ this.context.signal.throwIfAborted();
60
+ for (let offset = 0; offset < bytes.length; offset += 16384) {
61
+ const part = bytes.subarray(offset, offset + 16384);
62
+ if (this.staging) await writeFileOutput(this.context, part, (data) => this.staging.writer.write(data, { signal: this.context.signal }));
63
+ else await this.storage.append(part);
64
+ this.size += part.length;
65
+ }
66
+ })();
67
+ this.active = task;
68
+ return task;
69
+ }
70
+ finish() {
71
+ if (this.closing) return Promise.reject(new FsError("EBADF", { path: this.path }));
72
+ const task = (async () => {
73
+ await (this.initialized ??= this.initialize());
74
+ const { fs, signal } = this.context;
75
+ signal.throwIfAborted();
76
+ if (this.staging) {
77
+ const target = this.resolution;
78
+ const stat = await this.staging.writer.finish({ signal });
79
+ signal.throwIfAborted();
80
+ target.validate();
81
+ await fs.publishStagedFile({ ...this.staging, file: { ...this.staging.file, stat } }, target.path, {
82
+ parent: target.parent,
83
+ destination: target.destination,
84
+ ancestors: target.ancestors,
85
+ preserveIdentity: target.destination !== null,
86
+ commitGuard: () => {
87
+ target.validate();
88
+ return true;
89
+ },
90
+ signal
91
+ });
92
+ } else {
93
+ for (let offset = 0; offset < this.size; offset += 16384)
94
+ await writeFileOutput(this.context, await this.storage.read(this.start + offset, Math.min(16384, this.size - offset)), async () => {
95
+ });
96
+ const output = await openFileOutput({ ...this.context, outputBudget: "independent" }, this.path, "w");
97
+ try {
98
+ for (let offset = 0; offset < this.size; offset += 16384)
99
+ await output.sink.write(await this.storage.read(this.start + offset, Math.min(16384, this.size - offset)));
100
+ await output.finish();
101
+ } catch (error) {
102
+ await output.abort(error).catch(() => {
103
+ });
104
+ throw error;
105
+ }
106
+ }
107
+ })();
108
+ this.active = task;
109
+ return task;
110
+ }
111
+ close() {
112
+ return this.closing ??= (async () => {
113
+ await this.active?.catch(() => {
114
+ });
115
+ await this.initialized?.catch(() => {
116
+ });
117
+ if (this.staging?.cleanup) {
118
+ try {
119
+ await this.staging.cleanup.remove();
120
+ } finally {
121
+ await this.staging.cleanup.close();
122
+ }
123
+ } else if (this.staging) await this.context.fs.removeStagedFile?.(this.staging);
124
+ await this.storage?.close();
125
+ })();
126
+ }
127
+ };
16
128
 
17
129
  // packages/safe-bash-command-xmllint/src/output.ts
18
130
  import { XmlQueryError } from "../safe-bash-xml-engine/limits.js";
@@ -226,6 +338,7 @@ async function argumentsFor(context, budget) {
226
338
  async function executeDocument(context, limits, runtime, budget, options, file) {
227
339
  let outputFailed = false;
228
340
  let stored;
341
+ let fileOutput;
229
342
  let completed = false;
230
343
  try {
231
344
  const recoveryMessages = /* @__PURE__ */ new Set();
@@ -267,32 +380,16 @@ async function executeDocument(context, limits, runtime, budget, options, file)
267
380
  await runtime.writeDiagnostic(context.stderr, `xmllint: ${message} (recovered)
268
381
  `, context.signal);
269
382
  const root = await prepareDocument(parsedRoot, options.noblanks ?? false, options.encoding, budget, options.nocdata ?? false);
270
- const documentOutputStart = budget.outputBytes;
271
- const fileChunks = [];
272
- const sink = options.output === void 0 || options.query !== void 0 ? context.stdout : {
273
- async write(bytes) {
274
- fileChunks.push(bytes.slice());
275
- }
276
- };
383
+ if (options.output !== void 0 && options.query === void 0 && !options.noout)
384
+ fileOutput = new XmlFileOutput(context, runtime.pathOf(context, options.output));
277
385
  let encodingStarted = false;
278
386
  async function finish() {
279
387
  await flushWrite();
280
- if (options.output !== void 0 && options.query === void 0 && !options.noout) {
281
- const bytes = new Uint8Array(budget.outputBytes - documentOutputStart);
282
- let offset = 0;
283
- for (const chunk of fileChunks) {
284
- bytes.set(chunk, offset);
285
- offset += chunk.length;
286
- }
287
- const destination = runtime.pathOf(context, options.output);
388
+ if (fileOutput) {
288
389
  try {
289
- await runtime.interruptible(() => writeFileOutput(
290
- context,
291
- bytes,
292
- (data) => context.fs.writeFile(destination, data, { signal: context.signal })
293
- ), context.signal);
390
+ await fileOutput.finish();
294
391
  } catch (error) {
295
- if (error instanceof FsError) throw new XmlQueryError2(error.message, 6);
392
+ if (error instanceof FsError2) throw new XmlQueryError2(error.message, 6);
296
393
  throw error;
297
394
  }
298
395
  }
@@ -306,8 +403,10 @@ async function executeDocument(context, limits, runtime, budget, options, file)
306
403
  outBatchUsed = 0;
307
404
  writesCount++;
308
405
  try {
309
- await writeBytes(sink, slice, context.signal);
406
+ if (fileOutput) await fileOutput.write(slice);
407
+ else await writeBytes(context.stdout, slice, context.signal);
310
408
  } catch (error) {
409
+ if (fileOutput && error instanceof FsError2) throw new XmlQueryError2(error.message, 6);
311
410
  outputFailed = true;
312
411
  throw error;
313
412
  }
@@ -335,8 +434,10 @@ async function executeDocument(context, limits, runtime, budget, options, file)
335
434
  await flushWrite();
336
435
  writesCount++;
337
436
  try {
338
- await writeBytes(sink, bytes, context.signal);
437
+ if (fileOutput) await fileOutput.write(bytes);
438
+ else await writeBytes(context.stdout, bytes, context.signal);
339
439
  } catch (error) {
440
+ if (fileOutput && error instanceof FsError2) throw new XmlQueryError2(error.message, 6);
340
441
  outputFailed = true;
341
442
  throw error;
342
443
  }
@@ -399,15 +500,21 @@ async function executeDocument(context, limits, runtime, budget, options, file)
399
500
  } catch (error) {
400
501
  return reportError(context, runtime, error, outputFailed);
401
502
  } finally {
402
- if (stored) await stored.close().catch((error) => {
403
- if (completed) throw error;
404
- });
503
+ try {
504
+ if (fileOutput) await fileOutput.close().catch((error) => {
505
+ if (completed) throw error;
506
+ });
507
+ } finally {
508
+ if (stored) await stored.close().catch((error) => {
509
+ if (completed) throw error;
510
+ });
511
+ }
405
512
  }
406
513
  }
407
514
  async function reportError(context, runtime, error, outputFailed = false) {
408
515
  context.signal.throwIfAborted();
409
- if (outputFailed || error instanceof FsError && error.code === "EPIPE") throw error;
410
- const status = error instanceof XmlQueryError2 ? error.status : error instanceof XmlLimitError ? 5 : error instanceof SyntaxError || error instanceof FsError ? 1 : void 0;
516
+ if (outputFailed || error instanceof FsError2 && error.code === "EPIPE") throw error;
517
+ const status = error instanceof XmlQueryError2 ? error.status : error instanceof XmlLimitError ? 5 : error instanceof SyntaxError || error instanceof FsError2 ? 1 : void 0;
411
518
  if (status === void 0) throw error;
412
519
  const message = error instanceof Error ? error.message.slice(0, 1e3) : "XML query failed";
413
520
  await runtime.writeDiagnostic(
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  boundedCodec
3
- } from "../safe-bash/command-chunks/chunk-JW3KIZU6.js";
4
- import "../safe-bash/command-chunks/chunk-EMMSXKEJ.js";
3
+ } from "../safe-bash/command-chunks/chunk-RUXY7GN5.js";
4
+ import "../safe-bash/command-chunks/chunk-4Q4R3VZU.js";
5
5
  import "../safe-bash/command-chunks/chunk-5AQAWIYK.js";
6
6
  import "../safe-bash/command-chunks/chunk-5T7WL5CN.js";
7
7
  import "../safe-bash/command-chunks/chunk-V7IP2PFT.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createCodec,
3
3
  loadRawCodecFactory
4
- } from "../safe-bash/command-chunks/chunk-EMMSXKEJ.js";
4
+ } from "../safe-bash/command-chunks/chunk-4Q4R3VZU.js";
5
5
  import "../safe-bash/command-chunks/chunk-5AQAWIYK.js";
6
6
  import "../safe-bash/command-chunks/chunk-5T7WL5CN.js";
7
7
  import "../safe-bash/command-chunks/chunk-V7IP2PFT.js";
@@ -4,12 +4,12 @@ import {
4
4
  unchangedSource,
5
5
  verifyOperandDestinations,
6
6
  writeFileOperand
7
- } from "../safe-bash/command-chunks/chunk-WFDG3N5R.js";
7
+ } from "../safe-bash/command-chunks/chunk-ECDEPKKW.js";
8
8
  import "../safe-bash/command-chunks/chunk-JMTQ4BB6.js";
9
- import "../safe-bash/command-chunks/chunk-NVBUC644.js";
10
- import "../safe-bash/command-chunks/chunk-KELMIFVV.js";
11
- import "../safe-bash/command-chunks/chunk-JW3KIZU6.js";
12
- import "../safe-bash/command-chunks/chunk-EMMSXKEJ.js";
9
+ import "../safe-bash/command-chunks/chunk-HKGNBH7Z.js";
10
+ import "../safe-bash/command-chunks/chunk-TI52LKLL.js";
11
+ import "../safe-bash/command-chunks/chunk-RUXY7GN5.js";
12
+ import "../safe-bash/command-chunks/chunk-4Q4R3VZU.js";
13
13
  import "../safe-bash/command-chunks/chunk-5AQAWIYK.js";
14
14
  import "../safe-bash/command-chunks/chunk-5T7WL5CN.js";
15
15
  import "../safe-bash/command-chunks/chunk-52DDLGBS.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  DecodedBudget,
3
3
  transform
4
- } from "../safe-bash/command-chunks/chunk-NVBUC644.js";
5
- import "../safe-bash/command-chunks/chunk-KELMIFVV.js";
4
+ } from "../safe-bash/command-chunks/chunk-HKGNBH7Z.js";
5
+ import "../safe-bash/command-chunks/chunk-TI52LKLL.js";
6
6
  import {
7
7
  boundedCodec
8
- } from "../safe-bash/command-chunks/chunk-JW3KIZU6.js";
9
- import "../safe-bash/command-chunks/chunk-EMMSXKEJ.js";
8
+ } from "../safe-bash/command-chunks/chunk-RUXY7GN5.js";
9
+ import "../safe-bash/command-chunks/chunk-4Q4R3VZU.js";
10
10
  import "../safe-bash/command-chunks/chunk-5AQAWIYK.js";
11
11
  import "../safe-bash/command-chunks/chunk-5T7WL5CN.js";
12
12
  import "../safe-bash/command-chunks/chunk-52DDLGBS.js";
@@ -2,16 +2,16 @@ import {
2
2
  sourceBytes,
3
3
  unchangedSource,
4
4
  writeFileOperand
5
- } from "../safe-bash/command-chunks/chunk-WFDG3N5R.js";
5
+ } from "../safe-bash/command-chunks/chunk-ECDEPKKW.js";
6
6
  import {
7
7
  FileOperation
8
8
  } from "../safe-bash/command-chunks/chunk-JMTQ4BB6.js";
9
9
  import {
10
10
  transform
11
- } from "../safe-bash/command-chunks/chunk-NVBUC644.js";
12
- import "../safe-bash/command-chunks/chunk-KELMIFVV.js";
13
- import "../safe-bash/command-chunks/chunk-JW3KIZU6.js";
14
- import "../safe-bash/command-chunks/chunk-EMMSXKEJ.js";
11
+ } from "../safe-bash/command-chunks/chunk-HKGNBH7Z.js";
12
+ import "../safe-bash/command-chunks/chunk-TI52LKLL.js";
13
+ import "../safe-bash/command-chunks/chunk-RUXY7GN5.js";
14
+ import "../safe-bash/command-chunks/chunk-4Q4R3VZU.js";
15
15
  import "../safe-bash/command-chunks/chunk-5AQAWIYK.js";
16
16
  import "../safe-bash/command-chunks/chunk-5T7WL5CN.js";
17
17
  import "../safe-bash/command-chunks/chunk-52DDLGBS.js";
@@ -3,10 +3,10 @@ import {
3
3
  chunkBytes,
4
4
  stagingLimit,
5
5
  transform
6
- } from "../safe-bash/command-chunks/chunk-NVBUC644.js";
7
- import "../safe-bash/command-chunks/chunk-KELMIFVV.js";
8
- import "../safe-bash/command-chunks/chunk-JW3KIZU6.js";
9
- import "../safe-bash/command-chunks/chunk-EMMSXKEJ.js";
6
+ } from "../safe-bash/command-chunks/chunk-HKGNBH7Z.js";
7
+ import "../safe-bash/command-chunks/chunk-TI52LKLL.js";
8
+ import "../safe-bash/command-chunks/chunk-RUXY7GN5.js";
9
+ import "../safe-bash/command-chunks/chunk-4Q4R3VZU.js";
10
10
  import "../safe-bash/command-chunks/chunk-5AQAWIYK.js";
11
11
  import "../safe-bash/command-chunks/chunk-5T7WL5CN.js";
12
12
  import "../safe-bash/command-chunks/chunk-52DDLGBS.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  zstdDecode
3
- } from "../safe-bash/command-chunks/chunk-KELMIFVV.js";
4
- import "../safe-bash/command-chunks/chunk-JW3KIZU6.js";
5
- import "../safe-bash/command-chunks/chunk-EMMSXKEJ.js";
3
+ } from "../safe-bash/command-chunks/chunk-TI52LKLL.js";
4
+ import "../safe-bash/command-chunks/chunk-RUXY7GN5.js";
5
+ import "../safe-bash/command-chunks/chunk-4Q4R3VZU.js";
6
6
  import "../safe-bash/command-chunks/chunk-5AQAWIYK.js";
7
7
  import "../safe-bash/command-chunks/chunk-5T7WL5CN.js";
8
8
  import "../safe-bash/command-chunks/chunk-52DDLGBS.js";
@@ -10,6 +10,8 @@ export interface ImageMagickDiscoveryContext {
10
10
  /** Native IsPathDirectory/stat classification at filename expansion sites.
11
11
  * Unknown results remain advisory; existence/accessibility cannot infer this. */
12
12
  isDirectory?(path: Uint8Array): Promise<boolean | undefined>;
13
+ /** Streaming advisory read. Chunks may be borrowed until the next pull. */
14
+ readStream?(path: Uint8Array): AsyncIterable<Uint8Array>;
13
15
  /** Optional advisory content read. Native must read again at execution time. */
14
16
  read?(path: Uint8Array): Promise<Uint8Array | undefined>;
15
17
  }
@@ -7440,6 +7440,144 @@ function createFFmpegShims(binding) {
7440
7440
  ]));
7441
7441
  }
7442
7442
 
7443
+ // packages/safe-bash-media-engine/src/imagemagick-lex.ts
7444
+ var ImageMagickLexer = class {
7445
+ constructor(kind, bounded = false) {
7446
+ this.kind = kind;
7447
+ this.bounded = bounded;
7448
+ }
7449
+ kind;
7450
+ bounded;
7451
+ tokens = [];
7452
+ incomplete = false;
7453
+ limited = false;
7454
+ tokenBytes = 0;
7455
+ done = false;
7456
+ word = "";
7457
+ quote = "";
7458
+ active = false;
7459
+ column = 0;
7460
+ comment = false;
7461
+ escape = false;
7462
+ cr = false;
7463
+ suffix = false;
7464
+ push(bytes) {
7465
+ for (let index = 0; index < bytes.length && !this.done; index++) {
7466
+ const c = String.fromCharCode(bytes[index]);
7467
+ if (this.kind === "list") {
7468
+ this.list(c);
7469
+ continue;
7470
+ }
7471
+ if (this.cr) {
7472
+ this.cr = false;
7473
+ this.script(c === "\n" ? "\r" : "\n");
7474
+ }
7475
+ if (this.done) break;
7476
+ if (c === "\r") this.cr = true;
7477
+ else this.script(c);
7478
+ }
7479
+ }
7480
+ finish() {
7481
+ if (this.cr && !this.done) this.script("\n");
7482
+ if (!this.done) {
7483
+ if (this.kind === "script" && this.quote) this.incomplete = true;
7484
+ else if (this.active) this.emit();
7485
+ }
7486
+ return { tokens: this.tokens, incomplete: this.incomplete, limited: this.limited };
7487
+ }
7488
+ emit() {
7489
+ this.tokens.push(textBytes(this.word));
7490
+ this.word = "";
7491
+ this.active = false;
7492
+ if (this.bounded && this.tokens.length >= 4096) this.done = this.limited = true;
7493
+ }
7494
+ append(c) {
7495
+ if (this.bounded && this.tokenBytes >= 65536) {
7496
+ this.done = this.limited = true;
7497
+ this.word = "";
7498
+ return;
7499
+ }
7500
+ this.tokenBytes++;
7501
+ this.word += c;
7502
+ }
7503
+ list(c) {
7504
+ if (c === "\0") {
7505
+ if (this.active) this.emit();
7506
+ this.done = true;
7507
+ return;
7508
+ }
7509
+ const whitespace = " \r\n\f\v".includes(c);
7510
+ if (this.suffix) {
7511
+ if (whitespace) this.suffix = false;
7512
+ return;
7513
+ }
7514
+ if (!this.active) {
7515
+ if (whitespace) return;
7516
+ this.active = true;
7517
+ if (c === '"' || c === "'") {
7518
+ this.quote = c;
7519
+ return;
7520
+ }
7521
+ } else if (this.quote ? c === this.quote : whitespace) {
7522
+ this.emit();
7523
+ this.suffix = Boolean(this.quote);
7524
+ this.quote = "";
7525
+ return;
7526
+ }
7527
+ this.append(c);
7528
+ }
7529
+ script(c) {
7530
+ const code = c.charCodeAt(0);
7531
+ if (code < 7 || code > 13 && code < 32 && code !== 27) {
7532
+ this.incomplete = true;
7533
+ this.done = true;
7534
+ return;
7535
+ }
7536
+ if (this.comment) {
7537
+ if (c === "\n") {
7538
+ this.comment = false;
7539
+ this.column = 0;
7540
+ }
7541
+ return;
7542
+ }
7543
+ if (this.escape) {
7544
+ this.escape = false;
7545
+ if (c === "\n") {
7546
+ this.column = 0;
7547
+ return;
7548
+ }
7549
+ if (!this.quote || c === '"' || c === "\\") {
7550
+ this.column++;
7551
+ this.append(c);
7552
+ this.active = true;
7553
+ return;
7554
+ }
7555
+ this.append("\\");
7556
+ }
7557
+ if (!this.quote && !this.active && (c === "#" || this.column === 0 && (c === ":" || c === "@"))) {
7558
+ this.comment = true;
7559
+ return;
7560
+ }
7561
+ this.column = c === "\n" ? 0 : this.column + 1;
7562
+ if (c === "\\" && this.quote !== "'") {
7563
+ this.escape = true;
7564
+ return;
7565
+ }
7566
+ if (this.quote) {
7567
+ if (c === this.quote) this.quote = "";
7568
+ else this.append(c);
7569
+ } else if (c === '"' || c === "'") {
7570
+ this.quote = c;
7571
+ this.active = true;
7572
+ } else if (" \r\n".includes(c)) {
7573
+ if (this.active) this.emit();
7574
+ } else {
7575
+ this.append(c);
7576
+ this.active = true;
7577
+ }
7578
+ }
7579
+ };
7580
+
7443
7581
  // packages/safe-bash-media-engine/src/filename-expression.ts
7444
7582
  function parseFilenameExpression(value, dialect, multipleCounters = true) {
7445
7583
  const input = byteText(value), tokens = [];
@@ -7723,59 +7861,10 @@ function imageMagickPropertyReference(value, cwd) {
7723
7861
 
7724
7862
  // packages/safe-bash-media-engine/src/imagemagick.ts
7725
7863
  function imageMagickScriptTokens(bytes) {
7726
- const input = byteText(bytes);
7727
- const tokens = [];
7728
- let word = "", quote = "", active = false, column = 0;
7729
- for (let i = 0; i < input.length; i++) {
7730
- const c = input[i] === "\r" && input[i + 1] !== "\n" ? "\n" : input[i];
7731
- const code = c.charCodeAt(0);
7732
- if (code < 7 || code > 13 && code < 32 && code !== 27) return { tokens, incomplete: true };
7733
- if (!quote && !active && (c === "#" || column === 0 && (c === ":" || c === "@"))) {
7734
- while (i < input.length && input[i] !== "\n" && !(input[i] === "\r" && input[i + 1] !== "\n")) {
7735
- const code2 = input.charCodeAt(i);
7736
- if (code2 < 7 || code2 > 13 && code2 < 32 && code2 !== 27) return { tokens, incomplete: true };
7737
- i++;
7738
- }
7739
- column = 0;
7740
- continue;
7741
- }
7742
- column = c === "\n" ? 0 : column + 1;
7743
- if (c === "\\" && quote !== "'") {
7744
- const next = input[i + 1] === "\r" && input[i + 2] !== "\n" ? "\n" : input[i + 1];
7745
- if (next === void 0) break;
7746
- const code2 = next.charCodeAt(0);
7747
- if (code2 < 7 || code2 > 13 && code2 < 32 && code2 !== 27) return { tokens, incomplete: true };
7748
- if (next === "\n") {
7749
- i++;
7750
- column = 0;
7751
- continue;
7752
- }
7753
- if (!quote || next === '"' || next === "\\") {
7754
- i++;
7755
- column++;
7756
- word += next;
7757
- active = true;
7758
- continue;
7759
- }
7760
- }
7761
- if (quote) {
7762
- if (c === quote) quote = "";
7763
- else word += c;
7764
- } else if (c === "'" || c === '"') {
7765
- quote = c;
7766
- active = true;
7767
- } else if (" \r\n".includes(c)) {
7768
- if (active) tokens.push(textBytes(word));
7769
- word = "";
7770
- active = false;
7771
- } else {
7772
- word += c;
7773
- active = true;
7774
- }
7775
- }
7776
- if (quote) return { tokens, incomplete: true };
7777
- if (active) tokens.push(textBytes(word));
7778
- return { tokens, incomplete: false };
7864
+ const lexer = new ImageMagickLexer("script");
7865
+ lexer.push(bytes);
7866
+ const { tokens, incomplete } = lexer.finish();
7867
+ return { tokens, incomplete };
7779
7868
  }
7780
7869
  var noFinalOutput = /* @__PURE__ */ new Set(["identify", "mogrify", "conjure", "animate", "display"]);
7781
7870
  var imageOperands = /* @__PURE__ */ new Set(["-read", "--", "-mask", "-read-mask", "-write-mask", "-clip-mask", "-texture", "-tile", "-affinity", "-remap", "-map"]);
@@ -7813,9 +7902,20 @@ async function discoverImageMagick(tool, args, context = {}) {
7813
7902
  let literalFilenames = false;
7814
7903
  let pedantic = false;
7815
7904
  const visited = /* @__PURE__ */ new Set();
7816
- const read = async (name) => {
7905
+ const read = async (name, kind) => {
7906
+ const lexer = new ImageMagickLexer(kind, Boolean(context.readStream));
7817
7907
  try {
7818
- return await context.read?.(textBytes(name));
7908
+ if (context.readStream) {
7909
+ for await (const chunk of context.readStream(textBytes(name))) {
7910
+ lexer.push(chunk);
7911
+ if (lexer.done) break;
7912
+ }
7913
+ } else {
7914
+ const bytes = await context.read?.(textBytes(name));
7915
+ if (!bytes) return void 0;
7916
+ lexer.push(bytes);
7917
+ }
7918
+ return lexer.finish();
7819
7919
  } catch {
7820
7920
  return void 0;
7821
7921
  }
@@ -7865,20 +7965,10 @@ async function discoverImageMagick(tool, args, context = {}) {
7865
7965
  const membersStart = resources.length;
7866
7966
  if (visited.has("list:" + list) || visited.size < 32) {
7867
7967
  visited.add("list:" + list);
7868
- const bytes = await read(list);
7869
- if (bytes) {
7870
- const contents = byteText(bytes).split("\0")[0];
7871
- const members = [];
7872
- let offset = 0;
7873
- while (offset < contents.length) {
7874
- while (" \r\n\f\v".includes(contents[offset] ?? "\0")) offset++;
7875
- if (offset >= contents.length) break;
7876
- const quote = ['"', "'"].includes(contents[offset]) ? contents[offset++] : void 0;
7877
- const start2 = offset;
7878
- while (offset < contents.length && (quote ? contents[offset] !== quote : !" \r\n\f\v".includes(contents[offset]))) offset++;
7879
- members.push(textBytes(contents.slice(start2, offset)));
7880
- while (offset < contents.length && !" \r\n\f\v".includes(contents[offset])) offset++;
7881
- }
7968
+ const lexed = await read(list, "list");
7969
+ if (lexed) {
7970
+ if (lexed.limited) defer(index, list, "advisory prediction budget; native expands complete input");
7971
+ const members = lexed.tokens;
7882
7972
  const directories = [];
7883
7973
  for (const member of members) {
7884
7974
  let directory;
@@ -7914,9 +8004,9 @@ async function discoverImageMagick(tool, args, context = {}) {
7914
8004
  if (path === "-" || path.toLowerCase().startsWith("fd:")) return;
7915
8005
  if (visited.has("script:" + path) || visited.size >= 32) return;
7916
8006
  visited.add("script:" + path);
7917
- const bytes = await read(path);
7918
- if (!bytes) return;
7919
- const lexed = imageMagickScriptTokens(bytes);
8007
+ const lexed = await read(path, "script");
8008
+ if (!lexed) return;
8009
+ if (lexed.limited) defer(index, path, "advisory prediction budget; native executes complete script");
7920
8010
  if (lexed.incomplete) defer(index, path, "incomplete script token");
7921
8011
  await scan(lexed.tokens, 0, path, true);
7922
8012
  }
@@ -4,6 +4,7 @@ import { type NetworkLimits } from "./types.js";
4
4
  export interface RequestBody {
5
5
  readonly contentType?: string;
6
6
  open(signal: AbortSignal): ByteSource;
7
+ close(): Promise<void>;
7
8
  }
8
9
  export declare function createBody(context: CommandContext, args: CurlArguments, limits: NetworkLimits): RequestBody | undefined;
9
10
  export declare function queryData(body: RequestBody, signal: AbortSignal, limits: NetworkLimits): Promise<string>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createBody,
3
3
  queryData
4
- } from "../safe-bash/command-chunks/chunk-4557HE3J.js";
4
+ } from "../safe-bash/command-chunks/chunk-PMWW7KSB.js";
5
5
  import "../safe-bash/command-chunks/chunk-CYIHFBEH.js";
6
6
  import "../safe-bash/command-chunks/chunk-ZGXSETAX.js";
7
7
  import "../safe-bash/command-chunks/chunk-YBRXG5S6.js";