@poe-platform/safe-bash 0.1.811 → 0.1.812

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 (61) hide show
  1. package/dist/audio-ast/index.d.ts +1 -0
  2. package/dist/audio-ast/index.js +6 -1
  3. package/dist/audio-ast/vorbis.d.ts +14 -0
  4. package/dist/image-ast/index.js +1 -1
  5. package/dist/pdf-ast/cos/value-parser.d.ts +23 -2
  6. package/dist/pdf-ast/extract/retained-form-field-details.d.ts +20 -0
  7. package/dist/pdf-ast/extract/retained-form-fields.d.ts +17 -4
  8. package/dist/pdf-ast/index.d.ts +1 -0
  9. package/dist/pdf-ast/index.js +701 -336
  10. package/dist/pdf-ast/retained-document.d.ts +4 -0
  11. package/dist/safe-bash/audio-ast.browser.js +2 -1
  12. package/dist/safe-bash/command-chunks/{biff-3EFLKBAH-NYWZOYQS.js → biff-YKPDH35C-MVQIWNKV.js} +2309 -2277
  13. package/dist/safe-bash/command-chunks/{chunk-VU3EQF7F.js → chunk-2JSDKQ4J.js} +110 -31
  14. package/dist/safe-bash/command-chunks/{chunk-72C3TZ2U.js → chunk-3Q247UDJ.js} +1 -1
  15. package/dist/safe-bash/command-chunks/{chunk-HARUYHH7.js → chunk-5HUICAWD.js} +1 -1
  16. package/dist/safe-bash/command-chunks/{chunk-2VCKUNDZ.js → chunk-B2C3UPJS.js} +27 -17
  17. package/dist/safe-bash/command-chunks/{chunk-5LI2DLNZ.js → chunk-CJQSAATC.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-ZHRGYR7B.js → chunk-FDCIPJBQ.js} +1 -1
  19. package/dist/safe-bash/command-chunks/{chunk-5MB64DWR.js → chunk-HWQ2UHMT.js} +8 -8
  20. package/dist/safe-bash/command-chunks/{chunk-5OO2P27R.js → chunk-NARD63DY.js} +98 -1
  21. package/dist/safe-bash/command-chunks/{chunk-Z5QOVRVH.js → chunk-SU26FZLJ.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-DPR5CYQV.js → chunk-XITDDJFT.js} +2 -0
  23. package/dist/safe-bash/command-chunks/{chunk-YSY6R6AS.js → chunk-XVLWZTPY.js} +230 -28
  24. package/dist/safe-bash/command-chunks/{chunk-WH3TIOTS.js → chunk-ZEGNRZV2.js} +9 -2
  25. package/dist/safe-bash/command-chunks/{chunk-KL3OIBKB.js → chunk-ZEX53S5I.js} +1892 -1878
  26. package/dist/safe-bash/command-chunks/{command-engine-BEWABZ75.js → command-engine-BCUQGJJ4.js} +58 -21
  27. package/dist/safe-bash/command-chunks/{engine-AXXFTGCL-QBQNBI6K.js → engine-LAUEWYSQ-DQCEI5HE.js} +1 -1
  28. package/dist/safe-bash-command-apply-patch/apply.js +4 -4
  29. package/dist/safe-bash-command-apply-patch/index.js +4 -4
  30. package/dist/safe-bash-command-apply-patch/matcher.js +2 -2
  31. package/dist/safe-bash-command-apply-patch/parser.js +2 -2
  32. package/dist/safe-bash-command-apply-patch/shared.d.ts +2 -0
  33. package/dist/safe-bash-command-apply-patch/shared.js +1 -1
  34. package/dist/safe-bash-command-ffmpeg/index.js +1 -1
  35. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  36. package/dist/safe-bash-command-ffprobe/media.js +2 -2
  37. package/dist/safe-bash-command-pandoc/command.js +1 -1
  38. package/dist/safe-bash-command-pandoc/index.js +1 -1
  39. package/dist/safe-bash-command-patch/index.js +2 -2
  40. package/dist/safe-bash-command-patch/patch-publication.js +1 -1
  41. package/dist/safe-bash-command-patch/patch.js +2 -2
  42. package/dist/safe-bash-command-pdftk/index.js +35 -2
  43. package/dist/safe-bash-command-pptx/command-engine.d.ts +12 -3
  44. package/dist/safe-bash-command-pptx/engine.d.ts +2 -2
  45. package/dist/safe-bash-command-pptx/engine.js +1 -1
  46. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  47. package/dist/safe-bash-diff-engine/document.d.ts +2 -1
  48. package/dist/safe-bash-diff-engine/document.js +7 -4
  49. package/dist/safe-bash-presentation-engine/command-placeholder.js +4 -3
  50. package/dist/safe-bash-presentation-engine/index.d.ts +1 -1
  51. package/dist/safe-bash-presentation-engine/index.js +9 -7
  52. package/dist/safe-bash-presentation-engine/presentation-model.js +3 -2
  53. package/dist/safe-bash-presentation-engine/retained-slide-publication.d.ts +24 -0
  54. package/dist/safe-bash-presentation-engine/slides.d.ts +1 -0
  55. package/dist/safe-bash-presentation-engine/slides.js +6 -3
  56. package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +2 -2
  57. package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +46 -13
  58. package/dist/spreadsheet-format-xls/biff-metadata.d.ts +1 -0
  59. package/dist/spreadsheet-format-xls/biff-metadata.js +2 -2
  60. package/dist/spreadsheet-format-xls/biff-write-metadata.js +10 -1
  61. package/package.json +2 -2
@@ -7,12 +7,13 @@ import {
7
7
  createMediaAstRegistry,
8
8
  encodeUtf8,
9
9
  parseStreamingManifest
10
- } from "./chunk-VU3EQF7F.js";
10
+ } from "./chunk-2JSDKQ4J.js";
11
11
 
12
- // packages/safe-bash-command-ffprobe/src/wav-tags.ts
12
+ // packages/safe-bash-command-ffprobe/src/flac-tags.ts
13
13
  import { IntegerTable, PagedStorage } from "@poe-platform/safe-fs/storage";
14
+ import { normalizeVorbisCommentKey } from "../../audio-ast/index.js";
14
15
  import { yieldTurn } from "../../safe-bash-contracts/yield.js";
15
- var WavTags = class {
16
+ var FlacTags = class {
16
17
  constructor(source, context) {
17
18
  this.source = source;
18
19
  this.context = context;
@@ -28,6 +29,168 @@ var WavTags = class {
28
29
  numeric;
29
30
  head = 0;
30
31
  tail = 0;
32
+ work = 0;
33
+ count = 0;
34
+ close;
35
+ async read(offset, length) {
36
+ this.context.signal.throwIfAborted();
37
+ const bytes = await this.source.read(offset, length);
38
+ this.context.signal.throwIfAborted();
39
+ if (bytes.length !== length) throw new Error("Truncated FLAC comment");
40
+ return bytes;
41
+ }
42
+ async *decoded(offset, length, ignoreBOM) {
43
+ const decoder = new TextDecoder("utf-8", { ignoreBOM });
44
+ let steps = 0;
45
+ for (let at = 0; at < length; at += 16384) {
46
+ yield decoder.decode(await this.read(offset + at, Math.min(16384, length - at)), { stream: true });
47
+ if (++steps % 256 === 0) await yieldTurn(this.context.signal);
48
+ }
49
+ yield decoder.decode();
50
+ }
51
+ async record(position) {
52
+ const bytes = await this.storage.read(position, 64), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
53
+ return Array.from({ length: 8 }, (_, i) => view.getFloat64(i * 8, true));
54
+ }
55
+ async write(position, values) {
56
+ const bytes = new Uint8Array(values.length * 8), view = new DataView(bytes.buffer);
57
+ values.forEach((value, i) => view.setFloat64(i * 8, value, true));
58
+ await this.storage.write(position, bytes);
59
+ }
60
+ async equal(a, b, units) {
61
+ for (let at = 0; at < units * 2; at += 16384) {
62
+ const size = Math.min(16384, units * 2 - at), left = await this.storage.read(a + at, size), right = await this.storage.read(b + at, size);
63
+ if (!left.every((value, i) => value === right[i])) return false;
64
+ }
65
+ return true;
66
+ }
67
+ async *keyText(position, units) {
68
+ let pending = "";
69
+ for (let at = 0; at < units; at += 8192) {
70
+ const bytes = await this.storage.read(position + at * 2, Math.min(8192, units - at) * 2), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
71
+ let text = pending;
72
+ pending = "";
73
+ for (let i = 0; i < bytes.length; i += 2) text += String.fromCharCode(view.getUint16(i, true));
74
+ const last = text.charCodeAt(text.length - 1);
75
+ if (last >= 55296 && last <= 56319) {
76
+ pending = text.slice(-1);
77
+ text = text.slice(0, -1);
78
+ }
79
+ if (text) yield text;
80
+ }
81
+ if (pending) yield pending;
82
+ }
83
+ async add(span) {
84
+ if (++this.work % 256 === 0) await yieldTurn(this.context.signal);
85
+ let split = -1;
86
+ for (let at = 0; at < span.length; at += 16384) {
87
+ const bytes = await this.read(span.offset + at, Math.min(16384, span.length - at)), found = bytes.indexOf(61);
88
+ if (found >= 0) {
89
+ split = at + found;
90
+ break;
91
+ }
92
+ if ((at / 16384 + 1) % 256 === 0) await yieldTurn(this.context.signal);
93
+ }
94
+ if (split <= 0) return;
95
+ let keyPosition = this.storage.allocate(0), units = 0, hash = 2166136261, short = "";
96
+ const appendKey = async (text) => {
97
+ for (let at = 0; at < text.length; at += 8192) {
98
+ const part = text.slice(at, at + 8192), bytes = new Uint8Array(part.length * 2), view = new DataView(bytes.buffer);
99
+ for (let i = 0; i < part.length; i++) {
100
+ const code = part.charCodeAt(i);
101
+ view.setUint16(i * 2, code, true);
102
+ hash = Math.imul(hash ^ code, 16777619) >>> 0;
103
+ }
104
+ await this.storage.append(bytes);
105
+ units += part.length;
106
+ if (short.length <= 12) short += part.slice(0, 13 - short.length);
107
+ }
108
+ };
109
+ for await (const part of this.decoded(span.offset, split, false)) await appendKey(part.toUpperCase());
110
+ if (!units) return;
111
+ if (units <= 12) {
112
+ const normalized = normalizeVorbisCommentKey(short);
113
+ if (normalized !== short) {
114
+ keyPosition = this.storage.allocate(0);
115
+ units = 0;
116
+ hash = 2166136261;
117
+ short = "";
118
+ await appendKey(normalized);
119
+ }
120
+ }
121
+ const first = await this.keys.get(BigInt(hash));
122
+ let existing = 0, row;
123
+ for (let position2 = Number(first ?? 0n); position2; ) {
124
+ const candidate = await this.record(position2);
125
+ if (candidate[3] === units && await this.equal(candidate[2], keyPosition, units)) {
126
+ existing = position2;
127
+ row = candidate;
128
+ break;
129
+ }
130
+ position2 = candidate[1];
131
+ }
132
+ const position = existing || this.storage.allocate(64);
133
+ row ??= [0, Number(first ?? 0n), keyPosition, units, span.block, 0, 0, 0];
134
+ const append = row[4] === span.block && !!row[7], value = this.storage.allocate(32), offset = span.offset + split + 1, length = span.length - split - 1;
135
+ await this.write(value, [0, offset, length, append ? 1 : 0]);
136
+ if (append) await this.write(row[6], [value]);
137
+ else row[5] = value;
138
+ row[4] = span.block;
139
+ row[6] = value;
140
+ row[7] = append || length > 0 ? 1 : 0;
141
+ await this.write(position, row);
142
+ if (existing) return;
143
+ await this.keys.set(BigInt(hash), BigInt(position));
144
+ this.count++;
145
+ const numeric = units <= 10 ? Number(short) : NaN;
146
+ if (Number.isInteger(numeric) && numeric >= 0 && numeric < 4294967295 && String(numeric) === short) await this.numeric.set(BigInt(numeric), BigInt(position));
147
+ else {
148
+ if (this.tail) await this.write(this.tail, [position]);
149
+ else this.head = position;
150
+ this.tail = position;
151
+ }
152
+ }
153
+ async *valueText(value) {
154
+ while (value) {
155
+ const bytes = await this.storage.read(value, 32), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
156
+ if (view.getFloat64(24, true)) yield "\n";
157
+ yield* this.decoded(view.getFloat64(8, true), view.getFloat64(16, true), true);
158
+ value = view.getFloat64(0, true);
159
+ }
160
+ }
161
+ async entry(position) {
162
+ const row = await this.record(position);
163
+ return { next: row[0], key: () => this.keyText(row[2], row[3]), text: () => this.valueText(row[5]) };
164
+ }
165
+ async *entries() {
166
+ for await (const [, position] of this.numeric.entries()) yield await this.entry(Number(position));
167
+ for (let position = this.head; position; ) {
168
+ const entry = await this.entry(position);
169
+ position = entry.next;
170
+ yield entry;
171
+ }
172
+ }
173
+ };
174
+
175
+ // packages/safe-bash-command-ffprobe/src/wav-tags.ts
176
+ import { IntegerTable as IntegerTable2, PagedStorage as PagedStorage2 } from "@poe-platform/safe-fs/storage";
177
+ import { yieldTurn as yieldTurn2 } from "../../safe-bash-contracts/yield.js";
178
+ var WavTags = class {
179
+ constructor(source, context) {
180
+ this.source = source;
181
+ this.context = context;
182
+ this.storage = new PagedStorage2(context, 4);
183
+ this.close = this.storage.close.bind(this.storage);
184
+ this.keys = new IntegerTable2(this.storage, 128);
185
+ this.numeric = new IntegerTable2(this.storage, 128);
186
+ }
187
+ source;
188
+ context;
189
+ storage;
190
+ keys;
191
+ numeric;
192
+ head = 0;
193
+ tail = 0;
31
194
  count = 0;
32
195
  close;
33
196
  async *decoded(offset, length) {
@@ -39,7 +202,7 @@ var WavTags = class {
39
202
  this.context.signal.throwIfAborted();
40
203
  if (bytes.length !== Math.min(16384, length - at)) throw new Error("Truncated WAV tag");
41
204
  yield decoder.decode(bytes, { stream: true });
42
- if (++steps % 256 === 0) await yieldTurn(this.context.signal);
205
+ if (++steps % 256 === 0) await yieldTurn2(this.context.signal);
43
206
  }
44
207
  yield decoder.decode();
45
208
  }
@@ -287,8 +450,7 @@ function formatAudioProbe(audio, size, parsed) {
287
450
  }
288
451
 
289
452
  // packages/safe-bash-command-ffprobe/src/tag-format.ts
290
- async function* parts(value, prefix = "") {
291
- if (prefix) yield prefix;
453
+ async function* parts(value) {
292
454
  if (typeof value === "function") yield* value();
293
455
  else yield String(value);
294
456
  }
@@ -347,7 +509,24 @@ async function* formatTaggedAudio(audio, size, args, tags) {
347
509
  const rows = audioProbeRows({ ...audio, nodes: [] }, size, parsed, tags.count > 0);
348
510
  async function* tagFields(section) {
349
511
  const selected = sections.get(section + "_tags");
350
- for await (const entry of tags.entries()) if (selected === void 0 || selected.includes(entry.key)) yield { key: entry.key, value: entry.text };
512
+ for await (const entry of tags.entries()) {
513
+ let included = selected === void 0;
514
+ for (const wanted of selected ?? []) {
515
+ let at = 0, matches = true;
516
+ for await (const part of parts(entry.key)) {
517
+ if (wanted.slice(at, at + part.length) !== part) {
518
+ matches = false;
519
+ break;
520
+ }
521
+ at += part.length;
522
+ }
523
+ if (matches && at === wanted.length) {
524
+ included = true;
525
+ break;
526
+ }
527
+ }
528
+ if (included) yield { key: entry.key, value: entry.text };
529
+ }
351
530
  }
352
531
  async function* jsonRow(row, section, indent) {
353
532
  yield "{";
@@ -359,8 +538,10 @@ async function* formatTaggedAudio(audio, size, args, tags) {
359
538
  yield "{";
360
539
  let firstTag = true;
361
540
  for await (const field of tagFields(section)) {
362
- yield (firstTag ? "\n" : ",\n") + " ".repeat(indent + 8) + JSON.stringify(field.key) + ": ";
541
+ yield (firstTag ? "\n" : ",\n") + " ".repeat(indent + 8);
363
542
  firstTag = false;
543
+ yield* jsonString(parts(field.key));
544
+ yield ": ";
364
545
  yield* jsonString(parts(field.value));
365
546
  }
366
547
  yield (firstTag ? "" : "\n" + " ".repeat(indent + 4)) + "}";
@@ -400,7 +581,7 @@ async function* formatTaggedAudio(audio, size, args, tags) {
400
581
  async function* fields() {
401
582
  for (const [key, value] of Object.entries(row)) {
402
583
  if (typeof value === "object") {
403
- for await (const tag of tagFields(section)) yield { key: "tag:" + tag.key, value: tag.value };
584
+ for await (const tag of tagFields(section)) yield { key: tag.key, value: tag.value, tag: true };
404
585
  } else yield { key, value };
405
586
  }
406
587
  }
@@ -414,19 +595,28 @@ async function* formatTaggedAudio(audio, size, args, tags) {
414
595
  for await (const field of fields()) {
415
596
  if (!first) yield separator;
416
597
  first = false;
417
- const prefix = enabled("nokey", "nk", format === "csv") ? "" : field.key + "=";
598
+ async function* value() {
599
+ if (!enabled("nokey", "nk", format === "csv")) {
600
+ if (field.tag) yield "tag:";
601
+ yield* parts(field.key);
602
+ yield "=";
603
+ }
604
+ yield* parts(field.value);
605
+ }
418
606
  if (format === "csv") {
419
- const quote = await needsQuotes(parts(field.value, prefix), separator);
607
+ const quote = await needsQuotes(value(), separator);
420
608
  if (quote) yield '"';
421
- yield* quote ? replace(parts(field.value, prefix), '"', '""') : parts(field.value, prefix);
609
+ yield* quote ? replace(value(), '"', '""') : value();
422
610
  if (quote) yield '"';
423
- } else yield* replace(replace(replace(replace(parts(field.value, prefix), "\\", "\\\\"), "\n", "\\n"), "\r", "\\r"), separator, "\\" + separator);
611
+ } else yield* replace(replace(replace(replace(value(), "\\", "\\\\"), "\n", "\\n"), "\r", "\\r"), separator, "\\" + separator);
424
612
  }
425
613
  yield "\n";
426
614
  } else if (format === "flat") {
427
615
  const prefix = section === "stream" ? `streams.stream.${streamIndex++}` : "format";
428
616
  for await (const field of fields()) {
429
- yield prefix + "." + (field.key.startsWith("tag:") ? "tags." + field.key.slice(4) : field.key) + "=";
617
+ yield prefix + "." + (field.tag ? "tags." : "");
618
+ yield* parts(field.key);
619
+ yield "=";
430
620
  if (typeof field.value === "number") yield String(field.value);
431
621
  else yield* jsonString(parts(field.value));
432
622
  yield "\n";
@@ -434,7 +624,11 @@ async function* formatTaggedAudio(audio, size, args, tags) {
434
624
  } else {
435
625
  if (!enabled("noprint_wrappers", "nw", false)) yield "[" + section.toUpperCase() + "]\n";
436
626
  for await (const field of fields()) {
437
- if (!enabled("nokey", "nk", false)) yield (field.key.startsWith("tag:") ? "TAG:" + field.key.slice(4) : field.key) + "=";
627
+ if (!enabled("nokey", "nk", false)) {
628
+ if (field.tag) yield "TAG:";
629
+ yield* parts(field.key);
630
+ yield "=";
631
+ }
438
632
  yield* parts(field.value);
439
633
  yield "\n";
440
634
  }
@@ -444,9 +638,9 @@ async function* formatTaggedAudio(audio, size, args, tags) {
444
638
  }
445
639
 
446
640
  // packages/safe-bash-command-ffprobe/src/probe-output.ts
447
- import { PagedStorage as PagedStorage2 } from "@poe-platform/safe-fs/storage";
641
+ import { PagedStorage as PagedStorage3 } from "@poe-platform/safe-fs/storage";
448
642
  import { writeBytes } from "../../safe-bash-contracts/io.js";
449
- import { yieldTurn as yieldTurn2 } from "../../safe-bash-contracts/yield.js";
643
+ import { yieldTurn as yieldTurn3 } from "../../safe-bash-contracts/yield.js";
450
644
  async function* encodeParts(parts2, signal) {
451
645
  const encoder = new TextEncoder();
452
646
  let high = "", steps = 0;
@@ -462,13 +656,13 @@ async function* encodeParts(parts2, signal) {
462
656
  text = text.slice(0, -1);
463
657
  }
464
658
  if (text) yield encoder.encode(text);
465
- if (++steps % 256 === 0) await yieldTurn2(signal);
659
+ if (++steps % 256 === 0) await yieldTurn3(signal);
466
660
  }
467
661
  }
468
662
  if (high) yield encoder.encode(high);
469
663
  }
470
664
  async function writeProbeOutput(context, parts2, check, beforePublish) {
471
- const storage = new PagedStorage2(context, 4), start = storage.allocate(0);
665
+ const storage = new PagedStorage3(context, 4), start = storage.allocate(0);
472
666
  let size = 0, failed = true;
473
667
  try {
474
668
  for await (const bytes of encodeParts(parts2, context.signal)) {
@@ -494,10 +688,10 @@ async function writeProbeOutput(context, parts2, check, beforePublish) {
494
688
  }
495
689
 
496
690
  // packages/safe-bash-command-ffprobe/src/stream-input.ts
497
- import { PagedStorage as PagedStorage3 } from "@poe-platform/safe-fs/storage";
691
+ import { PagedStorage as PagedStorage4 } from "@poe-platform/safe-fs/storage";
498
692
  import { readBytes } from "../../safe-bash-contracts/io.js";
499
693
  import { readFileStream } from "../../safe-bash-contracts/filesystem.js";
500
- import { yieldTurn as yieldTurn3 } from "../../safe-bash-contracts/yield.js";
694
+ import { yieldTurn as yieldTurn4 } from "../../safe-bash-contracts/yield.js";
501
695
  async function openProbeStream(context, path) {
502
696
  context.signal.throwIfAborted();
503
697
  if (path === void 0) return readBytes(context.stdin, context.signal);
@@ -569,7 +763,7 @@ async function sniffMediaStream(source, signal, account) {
569
763
  return { prefix: prefix.subarray(0, size), stream: replay() };
570
764
  }
571
765
  async function withStagedProbeSource(context, input, probe2, retain) {
572
- const storage = new PagedStorage3(context, 4);
766
+ const storage = new PagedStorage4(context, 4);
573
767
  retain?.(storage.close.bind(storage));
574
768
  let start;
575
769
  let size = 0, steps = 0, failed = true;
@@ -579,7 +773,7 @@ async function withStagedProbeSource(context, input, probe2, retain) {
579
773
  size += chunk.length;
580
774
  start ??= storage.allocate(0);
581
775
  await storage.append(chunk);
582
- if (++steps % 256 === 0) await yieldTurn3(context.signal);
776
+ if (++steps % 256 === 0) await yieldTurn4(context.signal);
583
777
  }
584
778
  context.signal.throwIfAborted();
585
779
  start ??= storage.allocate(0);
@@ -601,7 +795,7 @@ async function withStagedProbeSource(context, input, probe2, retain) {
601
795
  }
602
796
 
603
797
  // packages/safe-bash-command-ffprobe/src/media.ts
604
- import { probeWavSource } from "../../audio-ast/index.js";
798
+ import { probeWavSource, probeFlacSource } from "../../audio-ast/index.js";
605
799
  import { commandRuntimeIdentity, getCommandArguments } from "../../safe-bash-contracts/command.js";
606
800
  import { readBytes as readBytes2, writeBytes as writeBytes2 } from "../../safe-bash-contracts/io.js";
607
801
  function isStdin(path) {
@@ -1127,17 +1321,25 @@ async function probeSourceMetadata(context, plugins, input, filename, budget, re
1127
1321
  if (!plugin) return void 0;
1128
1322
  const result = await plugin.probeMetadata(source, { ...records, filename, signal: context.signal, budget, limits: budget.limits });
1129
1323
  if (onAudio) {
1130
- const tags = new WavTags(source, context);
1324
+ const tags = plugin.formatName === "flac" ? new FlacTags(source, context) : new WavTags(source, context);
1131
1325
  retain(tags.close);
1132
1326
  try {
1133
- onAudio(await probeWavSource(source, { signal: context.signal, onTag: async (span) => {
1327
+ const audio = tags instanceof FlacTags ? await probeFlacSource(source, { signal: context.signal, onComment: async (span) => {
1328
+ try {
1329
+ await tags.add(span);
1330
+ } catch (error) {
1331
+ sourceFailed = true;
1332
+ throw error;
1333
+ }
1334
+ } }) : await probeWavSource(source, { signal: context.signal, onTag: async (span) => {
1134
1335
  try {
1135
1336
  await tags.add(span);
1136
1337
  } catch (error) {
1137
1338
  sourceFailed = true;
1138
1339
  throw error;
1139
1340
  }
1140
- } }), input.size, tags);
1341
+ } });
1342
+ onAudio(audio, input.size, tags);
1141
1343
  } catch (error) {
1142
1344
  context.signal.throwIfAborted();
1143
1345
  if (sourceFailed) throw error;
@@ -1282,7 +1484,7 @@ function createFfprobeCommand(options = {}) {
1282
1484
  automaticAudio = false;
1283
1485
  }
1284
1486
  }
1285
- const automaticPlugins = !options.asts && !explicitFormat ? astPlugins.filter((plugin) => plugin.canDemux && plugin.probeMetadata && (!automaticAudio || plugin === registry.findByFormatName("wav"))) : [];
1487
+ const automaticPlugins = !options.asts && !explicitFormat ? astPlugins.filter((plugin) => plugin.canDemux && plugin.probeMetadata && (!automaticAudio || plugin === registry.findByFormatName("wav") || plugin === registry.findByFormatName("flac"))) : [];
1286
1488
  const explicitPlugin = explicitFormat ? registry.findByFormatName(explicitFormat) : void 0;
1287
1489
  const retainedPlugins = explicitPlugin ? explicitPlugin.canDemux && explicitPlugin.probeMetadata ? [explicitPlugin] : [] : automaticPlugins;
1288
1490
  let probeResult = retainedPlugins.length && !isStdin(inputTarget) ? await probeRetainedMetadata(context, retainedPlugins, resolvePath(context.cwd, inputTarget), inputTarget, budget, { showPackets, showFrames }, automaticAudio ? (audio, size, tags) => {
@@ -5,7 +5,7 @@ import { dirname, FsError, isFsError } from "../../safe-bash-contracts/index.js"
5
5
  import { host as host2, ToolError as ToolError2 } from "../../safe-bash-diff-engine/shared.js";
6
6
 
7
7
  // packages/safe-bash-command-patch/src/stored-target.ts
8
- import { PagedStorage } from "@poe-platform/safe-fs/storage";
8
+ import { PagedStorage, PagedStorageCache } from "@poe-platform/safe-fs/storage";
9
9
  import { IndexedDocument, closeDocumentResources } from "../../safe-bash-diff-engine/document.js";
10
10
  import { ToolError, host } from "../../safe-bash-diff-engine/shared.js";
11
11
  async function* targetBytes(line) {
@@ -84,11 +84,18 @@ async function equalTargetLines(left, right, budget, whitespace = false) {
84
84
  var TargetDocuments = class {
85
85
  constructor(budget) {
86
86
  this.budget = budget;
87
+ this.documentBudget = {
88
+ context: budget.context,
89
+ documentCache: new PagedStorageCache(16),
90
+ step: budget.step.bind(budget),
91
+ checkpoint: budget.checkpoint.bind(budget)
92
+ };
87
93
  }
88
94
  budget;
89
95
  documents = /* @__PURE__ */ new Set();
96
+ documentBudget;
90
97
  async load(source) {
91
- const document = new IndexedDocument(this.budget, 2);
98
+ const document = new IndexedDocument(this.documentBudget, 2);
92
99
  this.documents.add(document);
93
100
  await document.load(source);
94
101
  if (document.binary) throw new ToolError("binary input is unsupported (NUL byte)");