@poe-platform/safe-bash 0.1.814 → 0.1.815

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 (59) hide show
  1. package/dist/mp4-ast/index.d.ts +1 -0
  2. package/dist/mp4-ast/mp4-fragment-source.d.ts +35 -0
  3. package/dist/mp4-ast/mp4-sample-source.d.ts +5 -2
  4. package/dist/mp4-ast/types.d.ts +11 -0
  5. package/dist/pdf-ast/cos/object-reader.d.ts +3 -2
  6. package/dist/pdf-ast/edit/forms.d.ts +1 -0
  7. package/dist/pdf-ast/edit/retained-form-data.d.ts +9 -0
  8. package/dist/pdf-ast/index.d.ts +1 -0
  9. package/dist/pdf-ast/index.js +476 -55
  10. package/dist/safe-bash/command-chunks/{biff-KRHJ63K3-VQPJCVIL.js → biff-A7XPBWAK-DCLG5QKF.js} +1775 -1667
  11. package/dist/safe-bash/command-chunks/{chunk-AVGXFWEB.js → chunk-44F5TOHZ.js} +179 -58
  12. package/dist/safe-bash/command-chunks/{chunk-PIVH35EQ.js → chunk-6CDDKNNA.js} +1 -0
  13. package/dist/safe-bash/command-chunks/{chunk-K4XNUJVJ.js → chunk-6EINUY5G.js} +149 -165
  14. package/dist/safe-bash/command-chunks/{chunk-5BIQWWLB.js → chunk-CFMJXJS5.js} +1 -1
  15. package/dist/safe-bash/command-chunks/{chunk-3JM7E42I.js → chunk-GPGLTWNR.js} +106 -32
  16. package/dist/safe-bash/command-chunks/{chunk-2ETEJOYX.js → chunk-HQ2UN2L2.js} +8 -8
  17. package/dist/safe-bash/command-chunks/{chunk-CK2WFJZN.js → chunk-KASXIRKD.js} +12 -14
  18. package/dist/safe-bash/command-chunks/chunk-KHUT7BB5.js +65 -0
  19. package/dist/safe-bash/command-chunks/{chunk-LAPOMHGY.js → chunk-NEYITAAO.js} +114 -97
  20. package/dist/safe-bash/command-chunks/{chunk-FF7UGJWS.js → chunk-QDVDBN2N.js} +1 -1
  21. package/dist/safe-bash/command-chunks/{chunk-SW37YCBW.js → chunk-U3C6IT2C.js} +44 -30
  22. package/dist/safe-bash/command-chunks/{chunk-G3TAX3CV.js → chunk-WAT2562G.js} +610 -539
  23. package/dist/safe-bash/command-chunks/{chunk-VT7UBPAE.js → chunk-YW2VYN4V.js} +23 -11
  24. package/dist/safe-bash/command-chunks/{chunk-GQGMQMIM.js → chunk-ZIGENXGC.js} +243 -1
  25. package/dist/safe-bash/command-chunks/{command-engine-7V6PZR7G.js → command-engine-M7S4QIXV.js} +12 -4
  26. package/dist/safe-bash/command-chunks/{engine-UYJENSWK-VSCGKSQV.js → engine-YUYZJIB4-NZUDFEHL.js} +1 -1
  27. package/dist/safe-bash-command-ffmpeg/index.js +1 -1
  28. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  29. package/dist/safe-bash-command-ffprobe/media.d.ts +8 -2
  30. package/dist/safe-bash-command-ffprobe/media.js +4 -2
  31. package/dist/safe-bash-command-pandoc/command.js +3 -3
  32. package/dist/safe-bash-command-pandoc/index.js +8 -8
  33. package/dist/safe-bash-command-patch/index.js +7 -6
  34. package/dist/safe-bash-command-patch/patch-formats.d.ts +6 -5
  35. package/dist/safe-bash-command-patch/patch-formats.js +3 -2
  36. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +7 -7
  37. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +1 -1
  38. package/dist/safe-bash-command-patch/patch-gnu-reject.js +3 -2
  39. package/dist/safe-bash-command-patch/patch-publication.js +3 -2
  40. package/dist/safe-bash-command-patch/patch-text.d.ts +13 -0
  41. package/dist/safe-bash-command-patch/patch.js +7 -6
  42. package/dist/safe-bash-command-patch/stored-patch.d.ts +29 -4
  43. package/dist/safe-bash-command-patch/stored-target.d.ts +2 -1
  44. package/dist/safe-bash-command-patch/unified.d.ts +18 -4
  45. package/dist/safe-bash-command-patch/unified.js +2 -1
  46. package/dist/safe-bash-command-pdftk/index.js +30 -20
  47. package/dist/safe-bash-command-pptx/engine.js +1 -1
  48. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  49. package/dist/safe-bash-presentation-engine/index.js +1 -1
  50. package/dist/safe-bash-presentation-engine/notes.d.ts +1 -0
  51. package/dist/safe-bash-presentation-engine/notes.js +7 -1
  52. package/dist/safe-bash-presentation-engine/retained-notes.d.ts +27 -0
  53. package/dist/safe-bash-xml-engine/document.js +2 -2
  54. package/dist/safe-bash-xml-engine/index.js +2 -2
  55. package/dist/safe-bash-xml-engine/stored-document.js +1 -1
  56. package/dist/spreadsheet-format-xls/biff-properties-merge.js +40 -21
  57. package/dist/spreadsheet-format-xls/biff-property-values.d.ts +31 -0
  58. package/dist/spreadsheet-format-xls/biff-property-values.js +158 -0
  59. package/package.json +3 -2
@@ -9,7 +9,7 @@ import {
9
9
  parseStreamingManifest,
10
10
  probeOggFlacSource,
11
11
  probeOggStreamMetadata
12
- } from "./chunk-LAPOMHGY.js";
12
+ } from "./chunk-NEYITAAO.js";
13
13
 
14
14
  // packages/safe-bash-command-ffprobe/src/ogg-probe.ts
15
15
  import { probeOggStreamSource } from "../../audio-ast/index.js";
@@ -1350,47 +1350,74 @@ function formatIntrospectionOutput(flag, plugins, command = "ffmpeg") {
1350
1350
  function formatFfprobeResult(probe2, opts, audioInput) {
1351
1351
  return Array.from(formatFfprobeResultChunks(probe2, opts, audioInput)).join("");
1352
1352
  }
1353
- function* formatFfprobeResultChunks(probe2, opts, audioInput) {
1354
- if (audioInput && !opts.showPackets && !opts.showFrames && !opts.showChapters && !opts.showPrograms && !opts.countFrames && !opts.countPackets && probe2.streams.length > 0 && probe2.streams.every((stream) => stream.codec_type === "audio")) {
1353
+ function formatQualifiedAudio(probe2, opts, audioInput) {
1354
+ if (audioInput && !opts.showPackets && !opts.showFrames && !opts.showChapters && !opts.showPrograms && !opts.countFrames && !opts.countPackets && Array.isArray(probe2.streams) && probe2.streams.length > 0 && probe2.streams.every((stream) => stream.codec_type === "audio")) {
1355
1355
  let formatted;
1356
1356
  try {
1357
1357
  formatted = "bytes" in audioInput ? probe(audioInput.bytes, audioInput.args) : formatAudioProbe({ ...audioInput.audio, nodes: audioInput.audio.nodes ?? [] }, audioInput.size, parseArguments(audioInput.args));
1358
1358
  } catch {
1359
1359
  }
1360
- if (formatted !== void 0) {
1361
- yield formatted;
1362
- return;
1360
+ return formatted;
1361
+ }
1362
+ }
1363
+ function* formatFfprobeResultChunks(probe2, opts, audioInput) {
1364
+ const audio = formatQualifiedAudio(probe2, opts, audioInput);
1365
+ if (audio !== void 0) {
1366
+ yield audio;
1367
+ return;
1368
+ }
1369
+ for (const step of formatProbeSteps(probe2, opts)) {
1370
+ if (typeof step === "string") {
1371
+ yield step;
1372
+ continue;
1363
1373
  }
1374
+ let index = 0;
1375
+ for (const row of step.rows) yield* step.render(row, index++);
1376
+ }
1377
+ }
1378
+ async function* formatFfprobeSourceChunks(probe2, opts, audioInput, signal) {
1379
+ signal?.throwIfAborted();
1380
+ const audio = formatQualifiedAudio(probe2, opts, audioInput);
1381
+ if (audio !== void 0) {
1382
+ yield audio;
1383
+ return;
1364
1384
  }
1365
- let filteredStreams = [...probe2.streams];
1366
- if (opts.selectStreams) {
1367
- const spec = opts.selectStreams.toLowerCase();
1368
- if (spec === "v") {
1369
- filteredStreams = filteredStreams.filter((s) => s.codec_type === "video");
1370
- } else if (spec === "a") {
1371
- filteredStreams = filteredStreams.filter((s) => s.codec_type === "audio");
1372
- } else if (spec === "s") {
1373
- filteredStreams = filteredStreams.filter((s) => s.codec_type === "subtitle");
1374
- } else if (spec.startsWith("v:")) {
1375
- const ord = parseInt(spec.slice(2), 10) || 0;
1376
- const vList = filteredStreams.filter((s) => s.codec_type === "video");
1377
- filteredStreams = vList[ord] ? [vList[ord]] : [];
1378
- } else if (spec.startsWith("a:")) {
1379
- const ord = parseInt(spec.slice(2), 10) || 0;
1380
- const aList = filteredStreams.filter((s) => s.codec_type === "audio");
1381
- filteredStreams = aList[ord] ? [aList[ord]] : [];
1382
- } else if (/^\d+$/.test(spec)) {
1383
- const idx = parseInt(spec, 10);
1384
- filteredStreams = filteredStreams.filter((s) => s.index === idx);
1385
- }
1386
- }
1387
- if (opts.countFrames || opts.countPackets) {
1388
- filteredStreams = filteredStreams.map((s) => ({
1389
- ...s,
1390
- ...opts.countFrames ? { nb_read_frames: s.nb_frames ?? "0" } : {},
1391
- ...opts.countPackets ? { nb_read_packets: s.nb_frames ?? "0" } : {}
1392
- }));
1385
+ for (const step of formatProbeSteps(probe2, opts)) {
1386
+ signal?.throwIfAborted();
1387
+ if (typeof step === "string") {
1388
+ yield step;
1389
+ continue;
1390
+ }
1391
+ const iterator = Symbol.asyncIterator in step.rows ? step.rows[Symbol.asyncIterator]() : step.rows[Symbol.iterator]();
1392
+ let index = 0, ended = false, failed = false;
1393
+ try {
1394
+ for (; ; ) {
1395
+ signal?.throwIfAborted();
1396
+ const next = await iterator.next();
1397
+ signal?.throwIfAborted();
1398
+ if (next.done) {
1399
+ ended = true;
1400
+ break;
1401
+ }
1402
+ yield* step.render(next.value, index++);
1403
+ if (index % 256 === 0) await yieldTurn6(signal);
1404
+ }
1405
+ } catch (error) {
1406
+ failed = true;
1407
+ throw error;
1408
+ } finally {
1409
+ if (!ended) {
1410
+ if (failed) {
1411
+ try {
1412
+ await iterator.return?.();
1413
+ } catch {
1414
+ }
1415
+ } else await iterator.return?.();
1416
+ }
1417
+ }
1393
1418
  }
1419
+ }
1420
+ function* formatProbeSteps(probe2, opts) {
1394
1421
  const entryFilter = /* @__PURE__ */ new Map();
1395
1422
  if (opts.showEntries) {
1396
1423
  for (const secSpec of opts.showEntries.split(":")) {
@@ -1440,9 +1467,23 @@ function* formatFfprobeResultChunks(probe2, opts, audioInput) {
1440
1467
  const includeFrames = opts.showFrames || entryFilter.has("frame");
1441
1468
  const includeChapters = opts.showChapters || entryFilter.has("chapter");
1442
1469
  const includePrograms = opts.showPrograms || entryFilter.has("program");
1443
- const finalStreams = includeStreams ? filteredStreams.map(
1444
- (s) => filterObject(s, "stream", "stream_tags")
1445
- ) : void 0;
1470
+ let typeOrdinal = 0;
1471
+ const prepareStream = (row) => {
1472
+ const stream = row, spec = opts.selectStreams?.toLowerCase();
1473
+ if (spec) {
1474
+ const type = spec[0] === "v" ? "video" : spec[0] === "a" ? "audio" : spec[0] === "s" ? "subtitle" : void 0;
1475
+ if ((spec === "v" || spec === "a" || spec === "s") && stream.codec_type !== type) return;
1476
+ if (spec.startsWith("v:") || spec.startsWith("a:")) {
1477
+ if (stream.codec_type !== type) return;
1478
+ if (typeOrdinal++ !== (parseInt(spec.slice(2), 10) || 0)) return;
1479
+ } else if ([...spec].every((c) => c >= "0" && c <= "9") && stream.index !== parseInt(spec, 10)) return;
1480
+ }
1481
+ return filterObject({
1482
+ ...stream,
1483
+ ...opts.countFrames ? { nb_read_frames: stream.nb_frames ?? "0" } : {},
1484
+ ...opts.countPackets ? { nb_read_packets: stream.nb_frames ?? "0" } : {}
1485
+ }, "stream", "stream_tags");
1486
+ };
1446
1487
  const finalFormat = includeFormat ? filterObject(probe2.format, "format", "format_tags") : void 0;
1447
1488
  const [fmtNameRaw, ...fmtParams] = opts.printFormat.split(":");
1448
1489
  const rawHead = fmtNameRaw ?? "default";
@@ -1463,7 +1504,7 @@ function* formatFfprobeResultChunks(probe2, opts, audioInput) {
1463
1504
  if (includePrograms) sections.push({ name: "programs", rows: [] });
1464
1505
  if (includePackets && probe2.packets) sections.push({ name: "packets", rows: probe2.packets });
1465
1506
  if (includeFrames && probe2.frames) sections.push({ name: "frames", rows: probe2.frames });
1466
- if (finalStreams !== void 0) sections.push({ name: "streams", rows: finalStreams });
1507
+ if (includeStreams) sections.push({ name: "streams", rows: probe2.streams });
1467
1508
  if (includeChapters) sections.push({ name: "chapters", rows: probe2.chapters });
1468
1509
  if (finalFormat !== void 0) sections.push({ name: "format", value: finalFormat });
1469
1510
  const compact = paramMap.c === "1" || paramMap.compact === "1";
@@ -1475,12 +1516,16 @@ function* formatFfprobeResultChunks(probe2, opts, audioInput) {
1475
1516
  if (section.rows) {
1476
1517
  yield "[";
1477
1518
  let firstRow = true;
1478
- for (const row of section.rows) {
1519
+ yield { rows: section.rows, *render(row) {
1520
+ if (section.name === "streams") {
1521
+ row = prepareStream(row);
1522
+ if (row === void 0) return;
1523
+ }
1479
1524
  yield (firstRow ? "" : ",") + (compact ? "" : "\n ");
1480
1525
  firstRow = false;
1481
1526
  const text = JSON.stringify(row, null, compact ? void 0 : 2) ?? "null";
1482
1527
  yield compact ? text : text.replaceAll("\n", "\n ");
1483
- }
1528
+ } };
1484
1529
  yield (compact || firstRow ? "" : "\n ") + "]";
1485
1530
  } else {
1486
1531
  const text = JSON.stringify(section.value, null, compact ? void 0 : 2);
@@ -1512,103 +1557,53 @@ function* formatFfprobeResultChunks(probe2, opts, audioInput) {
1512
1557
  }
1513
1558
  return fmt === "flat" ? '"' + escaped + '"' : escaped;
1514
1559
  }
1515
- if (fmt === "csv" || fmt === "compact") {
1516
- const sep = fmt === "csv" ? paramMap.s ?? "," : paramMap.s ?? "|";
1517
- const printSection = paramMap.p !== "0" && paramMap.print_section !== "0";
1518
- const lines2 = [];
1519
- if (finalStreams) {
1520
- for (const s of finalStreams) {
1521
- const vals = [];
1522
- if (printSection) vals.push("stream");
1523
- for (const [k, v] of probeEntries(s, "tag:")) {
1524
- if (v === void 0 || typeof v === "object") continue;
1525
- vals.push(noKey || fmt === "csv" ? probeText(v, sep) : `${k}=${probeText(v, sep)}`);
1526
- }
1527
- lines2.push(vals.join(sep));
1528
- }
1529
- }
1530
- if (finalFormat) {
1531
- const vals = [];
1532
- if (printSection) vals.push("format");
1533
- for (const [k, v] of probeEntries(finalFormat, "tag:")) {
1534
- if (v === void 0 || typeof v === "object") continue;
1535
- vals.push(noKey || fmt === "csv" ? probeText(v, sep) : `${k}=${probeText(v, sep)}`);
1536
- }
1537
- lines2.push(vals.join(sep));
1538
- }
1539
- yield lines2.join("\n") + (lines2.length > 0 ? "\n" : "");
1540
- return;
1541
- }
1542
- if (fmt === "flat") {
1543
- const sep = paramMap.s ?? ".";
1544
- const lines2 = [];
1545
- if (finalStreams) {
1546
- finalStreams.forEach((s, idx) => {
1547
- for (const [k, v] of probeEntries(s, `tags${sep}`)) {
1548
- if (v === void 0 || typeof v === "object") continue;
1549
- lines2.push(`streams${sep}stream${sep}${idx}${sep}${k}=${probeText(v)}`);
1550
- }
1551
- });
1552
- }
1553
- if (finalFormat) {
1554
- for (const [k, v] of probeEntries(finalFormat, `tags${sep}`)) {
1555
- if (v === void 0 || typeof v === "object") continue;
1556
- lines2.push(`format${sep}${k}=${probeText(v)}`);
1560
+ let streamIndex = 0;
1561
+ function* render(section, name, index = 0) {
1562
+ if (fmt === "csv" || fmt === "compact") {
1563
+ const sep = fmt === "csv" ? paramMap.s ?? "," : paramMap.s ?? "|";
1564
+ const printSection = paramMap.p !== "0" && paramMap.print_section !== "0";
1565
+ let first = true;
1566
+ if (printSection) {
1567
+ yield name;
1568
+ first = false;
1557
1569
  }
1558
- }
1559
- yield lines2.join("\n") + (lines2.length > 0 ? "\n" : "");
1560
- return;
1561
- }
1562
- const lines = [];
1563
- if (finalStreams) {
1564
- for (const s of finalStreams) {
1565
- if (!noWrappers) lines.push("[STREAM]");
1566
- for (const [k, v] of Object.entries(s)) {
1567
- if (v === void 0) continue;
1568
- if (k === "tags" && v && typeof v === "object") {
1569
- for (const [tk, tv] of Object.entries(v)) {
1570
- lines.push(noKey ? String(tv) : `TAG:${tk}=${String(tv)}`);
1571
- }
1572
- continue;
1573
- }
1574
- if (typeof v === "object") continue;
1575
- lines.push(noKey ? String(v) : `${k}=${String(v)}`);
1570
+ for (const [key, value] of probeEntries(section, "tag:")) {
1571
+ if (value === void 0 || typeof value === "object") continue;
1572
+ if (!first) yield sep;
1573
+ first = false;
1574
+ yield noKey || fmt === "csv" ? probeText(value, sep) : `${key}=${probeText(value, sep)}`;
1576
1575
  }
1577
- if (!noWrappers) lines.push("[/STREAM]");
1578
- }
1579
- }
1580
- if (includeChapters && probe2.chapters.length > 0) {
1581
- for (const ch of probe2.chapters) {
1582
- if (!noWrappers) lines.push("[CHAPTER]");
1583
- lines.push(noKey ? String(ch.id) : `id=${ch.id}`);
1584
- lines.push(noKey ? ch.time_base : `time_base=${ch.time_base}`);
1585
- lines.push(noKey ? String(ch.start) : `start=${ch.start}`);
1586
- lines.push(noKey ? ch.start_time : `start_time=${ch.start_time}`);
1587
- lines.push(noKey ? String(ch.end) : `end=${ch.end}`);
1588
- lines.push(noKey ? ch.end_time : `end_time=${ch.end_time}`);
1589
- for (const [tk, tv] of Object.entries(ch.tags)) {
1590
- lines.push(noKey ? String(tv) : `TAG:${tk}=${tv}`);
1576
+ yield "\n";
1577
+ } else if (fmt === "flat") {
1578
+ const sep = paramMap.s ?? ".", prefix = name === "stream" ? `streams${sep}stream${sep}${index}${sep}` : `format${sep}`;
1579
+ for (const [key, value] of probeEntries(section, `tags${sep}`)) {
1580
+ if (value === void 0 || typeof value === "object") continue;
1581
+ yield `${prefix}${key}=${probeText(value)}
1582
+ `;
1591
1583
  }
1592
- if (!noWrappers) lines.push("[/CHAPTER]");
1593
- }
1594
- }
1595
- if (finalFormat) {
1596
- if (!noWrappers) lines.push("[FORMAT]");
1597
- for (const [k, v] of Object.entries(finalFormat)) {
1598
- if (v === void 0) continue;
1599
- if (k === "tags" && v && typeof v === "object") {
1600
- for (const [tk, tv] of Object.entries(v)) {
1601
- lines.push(noKey ? String(tv) : `TAG:${tk}=${String(tv)}`);
1602
- }
1603
- continue;
1584
+ } else {
1585
+ const wrapper = name.toUpperCase();
1586
+ if (!noWrappers) yield `[${wrapper}]
1587
+ `;
1588
+ for (const [key, value] of Object.entries(section)) {
1589
+ if (value === void 0) continue;
1590
+ if (key === "tags" && value && typeof value === "object") {
1591
+ for (const [tag, text] of Object.entries(value)) yield (noKey ? String(text) : `TAG:${tag}=${String(text)}`) + "\n";
1592
+ } else if (typeof value !== "object") yield (noKey ? String(value) : `${key}=${String(value)}`) + "\n";
1604
1593
  }
1605
- if (typeof v === "object") continue;
1606
- lines.push(noKey ? String(v) : `${k}=${String(v)}`);
1594
+ if (!noWrappers) yield `[/${wrapper}]
1595
+ `;
1607
1596
  }
1608
- if (!noWrappers) lines.push("[/FORMAT]");
1609
1597
  }
1610
- yield lines.join("\n") + (lines.length > 0 ? "\n" : "");
1611
- return;
1598
+ if (includeStreams) yield { rows: probe2.streams, *render(row) {
1599
+ const stream = prepareStream(row);
1600
+ if (stream !== void 0) yield* render(stream, "stream", streamIndex++);
1601
+ } };
1602
+ if (includeChapters && fmt !== "csv" && fmt !== "compact" && fmt !== "flat") yield { rows: probe2.chapters, *render(row) {
1603
+ const chapter = row;
1604
+ yield* render({ id: chapter.id, time_base: chapter.time_base, start: chapter.start, start_time: chapter.start_time, end: chapter.end, end_time: chapter.end_time, tags: chapter.tags }, "chapter");
1605
+ } };
1606
+ if (finalFormat) yield* render(finalFormat, "format");
1612
1607
  }
1613
1608
  var defaultAstPluginsCache;
1614
1609
  var defaultRegistryCache;
@@ -1700,14 +1695,15 @@ async function probeSourceMetadata(context, plugins, input, filename, budget, re
1700
1695
  plugin = plugins.find((candidate) => candidate.detect(header, filename));
1701
1696
  }
1702
1697
  if (!plugin) return void 0;
1703
- if (plugin.formatName === "ogg" && !plugin.probeMetadata) {
1698
+ if (plugin.formatName === "ogg" && !plugin.probeRecords && !plugin.probeMetadata) {
1704
1699
  const probeOptions = { ...records, filename, signal: context.signal, budget, limits: budget.limits, checkpoint: () => yieldTurn6(context.signal) };
1705
1700
  const flac = await probeOggFlacSource(source, probeOptions);
1706
1701
  if (flac) return flac;
1707
1702
  const ogg = await probeStoredOgg(source, context, retain);
1708
1703
  return onAudio ? { oggRows: ogg.rows } : probeOggStreamMetadata(ogg.first, source.size, probeOptions);
1709
1704
  }
1710
- const result = await plugin.probeMetadata(source, { ...records, filename, signal: context.signal, budget, limits: budget.limits });
1705
+ const result = await (plugin.probeRecords ?? plugin.probeMetadata).call(plugin, source, { ...records, filename, signal: context.signal, budget, limits: budget.limits });
1706
+ if (result.close) retain(result.close.bind(result));
1711
1707
  if (onAudio) {
1712
1708
  const tags = plugin.formatName === "flac" ? new FlacTags(source, context) : new SourceAudioTags(source, context);
1713
1709
  retain(tags.close);
@@ -1752,35 +1748,22 @@ async function probeRetainedMetadata(context, plugins, path, filename, budget, r
1752
1748
  context.signal.throwIfAborted();
1753
1749
  if (capabilities.retainedRead !== true) return void 0;
1754
1750
  const handle = await context.fs.openReadFile(path, { signal: context.signal });
1755
- if (onAudio) retain(handle.close.bind(handle));
1756
- let failed = true;
1757
- try {
1758
- context.signal.throwIfAborted();
1759
- const stat = await handle.stat({ signal: context.signal });
1760
- context.signal.throwIfAborted();
1761
- if (!Number.isSafeInteger(stat.size) || stat.size < 0) throw new Error("Invalid media source size");
1762
- context.inputBudget?.check(stat.size);
1763
- budget.checkInputBytes(stat.size);
1764
- const result = await probeSourceMetadata(context, plugins, {
1765
- size: stat.size,
1766
- read: (offset, length) => handle.read(offset, length, { signal: context.signal })
1767
- }, filename, budget, records, onAudio, retain, detect);
1768
- context.signal.throwIfAborted();
1769
- failed = false;
1770
- return result;
1771
- } finally {
1772
- if (!onAudio) {
1773
- if (failed) {
1774
- try {
1775
- await handle.close();
1776
- } catch {
1777
- }
1778
- } else await handle.close();
1779
- }
1780
- }
1751
+ retain(handle.close.bind(handle));
1752
+ context.signal.throwIfAborted();
1753
+ const stat = await handle.stat({ signal: context.signal });
1754
+ context.signal.throwIfAborted();
1755
+ if (!Number.isSafeInteger(stat.size) || stat.size < 0) throw new Error("Invalid media source size");
1756
+ context.inputBudget?.check(stat.size);
1757
+ budget.checkInputBytes(stat.size);
1758
+ const result = await probeSourceMetadata(context, plugins, {
1759
+ size: stat.size,
1760
+ read: (offset, length) => handle.read(offset, length, { signal: context.signal })
1761
+ }, filename, budget, records, onAudio, retain, detect);
1762
+ context.signal.throwIfAborted();
1763
+ return result;
1781
1764
  }
1782
1765
  async function probeStreamMetadata(context, plugin, filename, budget, records) {
1783
- if (!plugin.canDemux || !plugin.probeMetadataStream) return void 0;
1766
+ if (!plugin.canDemux || plugin.probeRecords || !plugin.probeMetadataStream) return void 0;
1784
1767
  context.signal.throwIfAborted();
1785
1768
  const source = await openProbeStream(context, isStdin(filename) ? void 0 : resolvePath(context.cwd, filename));
1786
1769
  if (!source) return void 0;
@@ -1882,9 +1865,9 @@ function createFfprobeCommand(options = {}) {
1882
1865
  automaticAudio = false;
1883
1866
  }
1884
1867
  }
1885
- const automaticPlugins = !options.asts && !explicitFormat ? astPlugins.filter((plugin) => plugin.canDemux && (plugin.probeMetadata || plugin === registry.findByFormatName("ogg")) && (!automaticAudio || ["wav", "flac", "mp3", "ogg"].some((format) => plugin === registry.findByFormatName(format)))) : [];
1868
+ const automaticPlugins = !explicitFormat ? astPlugins.filter((plugin) => plugin.canDemux && (plugin.probeRecords || plugin.probeMetadata || !options.asts && plugin === registry.findByFormatName("ogg")) && (!automaticAudio || ["wav", "flac", "mp3", "ogg"].some((format) => plugin === registry.findByFormatName(format)))) : [];
1886
1869
  const explicitPlugin = explicitFormat ? registry.findByFormatName(explicitFormat) : void 0;
1887
- const retainedPlugins = explicitPlugin ? explicitPlugin.canDemux && (explicitPlugin.probeMetadata || !options.asts && explicitPlugin === registry.findByFormatName("ogg")) ? [explicitPlugin] : [] : automaticPlugins;
1870
+ const retainedPlugins = explicitPlugin ? explicitPlugin.canDemux && (explicitPlugin.probeRecords || explicitPlugin.probeMetadata || !options.asts && explicitPlugin === registry.findByFormatName("ogg")) ? [explicitPlugin] : [] : automaticPlugins;
1888
1871
  let probeResult = retainedPlugins.length && !isStdin(inputTarget) ? await probeRetainedMetadata(context, retainedPlugins, resolvePath(context.cwd, inputTarget), inputTarget, budget, { showPackets, showFrames }, automaticAudio ? (audio, size, tags) => {
1889
1872
  audioInput = { audio, size, args };
1890
1873
  storedTags = tags;
@@ -1902,7 +1885,7 @@ function createFfprobeCommand(options = {}) {
1902
1885
  });
1903
1886
  const automaticPlugin = explicitPlugin ?? streamPlugins.find((plugin) => plugin.detect(sniffed.prefix, inputTarget));
1904
1887
  if (automaticPlugin) {
1905
- if (!automaticAudio && automaticPlugin.probeMetadataStream) {
1888
+ if (!automaticAudio && !automaticPlugin.probeRecords && automaticPlugin.probeMetadataStream) {
1906
1889
  probeResult = await automaticPlugin.probeMetadataStream(sniffed.stream, {
1907
1890
  showPackets,
1908
1891
  showFrames,
@@ -1943,7 +1926,7 @@ function createFfprobeCommand(options = {}) {
1943
1926
  });
1944
1927
  if (!options.asts && !explicitFormat) audioInput = { bytes, args };
1945
1928
  }
1946
- const formatted = "oggRows" in probeResult ? formatTaggedRows(probeResult.oggRows(args), args) : storedTags && audioInput && "audio" in audioInput ? formatTaggedAudio(audioInput.audio, audioInput.size, audioInput.args, storedTags) : formatFfprobeResultChunks(probeResult, {
1929
+ const formatted = "oggRows" in probeResult ? formatTaggedRows(probeResult.oggRows(args), args) : storedTags && audioInput && "audio" in audioInput ? formatTaggedAudio(audioInput.audio, audioInput.size, audioInput.args, storedTags) : formatFfprobeSourceChunks(probeResult, {
1947
1930
  printFormat,
1948
1931
  showFormat,
1949
1932
  showStreams,
@@ -1955,7 +1938,7 @@ function createFfprobeCommand(options = {}) {
1955
1938
  showEntries,
1956
1939
  countFrames,
1957
1940
  countPackets
1958
- }, audioInput);
1941
+ }, audioInput, context.signal);
1959
1942
  await writeProbeOutput(context, formatted, (total) => budget.checkOutputBytes(total), closeInputs);
1960
1943
  options.onMetrics?.(budget.getStats());
1961
1944
  return { exitCode: 0 };
@@ -2044,6 +2027,7 @@ export {
2044
2027
  formatIntrospectionOutput,
2045
2028
  formatFfprobeResult,
2046
2029
  formatFfprobeResultChunks,
2030
+ formatFfprobeSourceChunks,
2047
2031
  getDefaultMediaRegistry,
2048
2032
  createFfprobeCommand,
2049
2033
  evalSyncFfprobe
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  targetBytes
3
- } from "./chunk-CK2WFJZN.js";
3
+ } from "./chunk-KASXIRKD.js";
4
4
 
5
5
  // packages/safe-bash-command-patch/src/patch-publication.ts
6
6
  import { compareCopyIdentity } from "../../safe-bash-contracts/filesystem-identity.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  targetBytes
3
- } from "./chunk-CK2WFJZN.js";
3
+ } from "./chunk-KASXIRKD.js";
4
4
 
5
5
  // packages/safe-bash-command-patch/src/stored-patch.ts
6
6
  import { PagedStorage } from "@poe-platform/safe-fs/storage";
@@ -8,33 +8,48 @@ import { closeDocumentResources } from "../../safe-bash-diff-engine/document.js"
8
8
  async function patchLine(hunk, index) {
9
9
  return Array.isArray(hunk.lines) ? hunk.lines[index] : hunk.lines.read(index);
10
10
  }
11
+ async function patchHunk(patch, index) {
12
+ return Array.isArray(patch.hunks) ? patch.hunks[index] : patch.hunks.read(index);
13
+ }
14
+ async function* patchHunks(patch) {
15
+ for (let index = 0; index < patch.hunks.length; index++) yield [index, await patchHunk(patch, index)];
16
+ }
17
+ var BodyLines = class {
18
+ constructor(start, records, data) {
19
+ this.start = start;
20
+ this.records = records;
21
+ this.data = data;
22
+ }
23
+ start;
24
+ records;
25
+ data;
26
+ length = 0;
27
+ async read(index) {
28
+ if (!Number.isSafeInteger(index) || index < 0 || index >= this.length) throw new RangeError("Invalid patch line");
29
+ const bytes = await this.records.read(this.start + index * 24, 24);
30
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
31
+ return {
32
+ kind: String.fromCharCode(bytes[16]),
33
+ text: { storage: this.data, start: view.getFloat64(0, true), end: view.getFloat64(8, true) }
34
+ };
35
+ }
36
+ };
11
37
  var PatchBodyStore = class {
12
38
  data;
13
39
  records;
40
+ hunks;
14
41
  dataEnd = 8;
15
42
  recordEnd = 8;
43
+ hunkEnd = 8;
16
44
  constructor(documents) {
17
45
  this.data = new PagedStorage(documents.budget.context, 16, documents.cache);
18
46
  this.records = new PagedStorage(documents.budget.context, 16, documents.cache);
47
+ this.hunks = new PagedStorage(documents.budget.context, 16, documents.cache);
19
48
  }
20
49
  begin() {
21
- const start = this.recordEnd;
22
- let length = 0;
50
+ const lines = new BodyLines(this.recordEnd, this.records, this.data);
23
51
  return {
24
- lines: {
25
- get length() {
26
- return length;
27
- },
28
- read: async (index) => {
29
- if (!Number.isSafeInteger(index) || index < 0 || index >= length) throw new RangeError("Invalid patch line");
30
- const bytes = await this.records.read(start + index * 24, 24);
31
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
32
- return {
33
- kind: String.fromCharCode(bytes[16]),
34
- text: { storage: this.data, start: view.getFloat64(0, true), end: view.getFloat64(8, true) }
35
- };
36
- }
37
- },
52
+ lines,
38
53
  append: async (line) => {
39
54
  const textStart = this.dataEnd;
40
55
  for await (const bytes of targetBytes(line.text)) {
@@ -47,12 +62,66 @@ var PatchBodyStore = class {
47
62
  cell[16] = line.kind.charCodeAt(0);
48
63
  await this.records.append(cell);
49
64
  this.recordEnd += 24;
65
+ lines.length++;
66
+ }
67
+ };
68
+ }
69
+ beginHunks() {
70
+ const start = this.hunkEnd;
71
+ let length = 0;
72
+ return {
73
+ hunks: {
74
+ get length() {
75
+ return length;
76
+ },
77
+ read: async (index) => {
78
+ if (!Number.isSafeInteger(index) || index < 0 || index >= length) throw new RangeError("Invalid patch hunk");
79
+ const bytes = await this.hunks.read(start + index * 64, 64), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
80
+ const lines = new BodyLines(view.getFloat64(32, true), this.records, this.data);
81
+ lines.length = view.getFloat64(40, true);
82
+ const decoder = new TextDecoder();
83
+ let section = "";
84
+ for (let position = view.getFloat64(48, true), end = view.getFloat64(56, true); position < end; ) {
85
+ const part = await this.data.read(position, Math.min(16384, end - position));
86
+ section += decoder.decode(part, { stream: true });
87
+ position += part.length;
88
+ }
89
+ section += decoder.decode();
90
+ return {
91
+ oldStart: view.getFloat64(0, true),
92
+ oldCount: view.getFloat64(8, true),
93
+ newStart: view.getFloat64(16, true),
94
+ newCount: view.getFloat64(24, true),
95
+ lines,
96
+ section
97
+ };
98
+ }
99
+ },
100
+ append: async (hunk) => {
101
+ const sectionStart = this.dataEnd;
102
+ for await (const bytes of targetBytes(hunk.section ?? "")) {
103
+ await this.data.append(bytes);
104
+ this.dataEnd += bytes.length;
105
+ }
106
+ const cell = new Uint8Array(64), view = new DataView(cell.buffer);
107
+ for (const [index, value] of [
108
+ hunk.oldStart,
109
+ hunk.oldCount,
110
+ hunk.newStart,
111
+ hunk.newCount,
112
+ hunk.lines.start,
113
+ hunk.lines.length,
114
+ sectionStart,
115
+ this.dataEnd
116
+ ].entries()) view.setFloat64(index * 8, value, true);
117
+ await this.hunks.append(cell);
118
+ this.hunkEnd += 64;
50
119
  length++;
51
120
  }
52
121
  };
53
122
  }
54
123
  close() {
55
- return closeDocumentResources([this.data, this.records]);
124
+ return closeDocumentResources([this.data, this.records, this.hunks]);
56
125
  }
57
126
  };
58
127
  function reverseStoredPatch(patch) {
@@ -62,20 +131,23 @@ function reverseStoredPatch(patch) {
62
131
  newPath: patch.oldPath,
63
132
  oldEpoch: patch.newEpoch,
64
133
  newEpoch: patch.oldEpoch,
65
- hunks: patch.hunks.map((hunk) => ({
66
- ...hunk,
67
- oldStart: hunk.newStart,
68
- oldCount: hunk.newCount,
69
- newStart: hunk.oldStart,
70
- newCount: hunk.oldCount,
71
- lines: {
72
- length: hunk.lines.length,
73
- async read(index) {
74
- const line = await patchLine(hunk, index);
75
- return { kind: line.kind === "+" ? "-" : line.kind === "-" ? "+" : " ", text: line.text };
134
+ hunks: { length: patch.hunks.length, async read(index) {
135
+ const hunk = await patchHunk(patch, index);
136
+ return {
137
+ ...hunk,
138
+ oldStart: hunk.newStart,
139
+ oldCount: hunk.newCount,
140
+ newStart: hunk.oldStart,
141
+ newCount: hunk.oldCount,
142
+ lines: {
143
+ length: hunk.lines.length,
144
+ async read(index2) {
145
+ const line = await patchLine(hunk, index2);
146
+ return { kind: line.kind === "+" ? "-" : line.kind === "-" ? "+" : " ", text: line.text };
147
+ }
76
148
  }
77
- }
78
- }))
149
+ };
150
+ } }
79
151
  };
80
152
  }
81
153
 
@@ -111,7 +183,7 @@ async function* rejectBytes(patch, outcomes, oldName, newName, indexName, revers
111
183
  yield* add(`${context ? "***" : "---"} ${names[0]}${times[0]}
112
184
  ${context ? "---" : "+++"} ${names[1]}${times[1]}
113
185
  `);
114
- for (const outcome of outcomes) {
186
+ for await (const outcome of outcomes) {
115
187
  if (!outcome.failed) continue;
116
188
  budget.step();
117
189
  {
@@ -191,6 +263,8 @@ ${context ? "---" : "+++"} ${names[1]}${times[1]}
191
263
 
192
264
  export {
193
265
  patchLine,
266
+ patchHunk,
267
+ patchHunks,
194
268
  PatchBodyStore,
195
269
  reverseStoredPatch,
196
270
  rejectBytes