@poe-platform/safe-bash 0.1.826 → 0.1.828

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 (174) hide show
  1. package/dist/image-ast/index.js +39 -18
  2. package/dist/pdf-ast/image.js +1 -1
  3. package/dist/pdf-ast/index.js +1 -1
  4. package/dist/pdf-ast/vendor/pdfjs-fonts.mjs +9 -3
  5. package/dist/safe-bash/chunks/{chunk-VWLQDZFF.js → chunk-C7RBTLYX.js} +12 -5
  6. package/dist/safe-bash/chunks/{chunk-TZRVK3NU.js → chunk-HWYINF6Y.js} +1 -1
  7. package/dist/safe-bash/chunks/{chunk-AGHV53VF.js → chunk-M6XFU6LQ.js} +3 -1
  8. package/dist/safe-bash/chunks/{chunk-ZJAXMB5M.js → chunk-SGHFQIZB.js} +1 -1
  9. package/dist/safe-bash/chunks/{chunk-363QOIDR.js → chunk-T6FHWSHM.js} +3 -1
  10. package/dist/safe-bash/chunks/{chunk-RAFD5ZAH.js → chunk-Y67A2DE4.js} +1 -1
  11. package/dist/safe-bash/command-chunks/{chunk-VKTM2SOL.js → chunk-2EEIB5O3.js} +192 -489
  12. package/dist/safe-bash/command-chunks/{chunk-FMGNXOMV.js → chunk-2L3NMRLG.js} +7 -3
  13. package/dist/safe-bash/command-chunks/{chunk-DAQO64WC.js → chunk-2YKOJPIW.js} +1 -1
  14. package/dist/safe-bash/command-chunks/{chunk-EPYJSPOY.js → chunk-3QCW4VQF.js} +12 -8
  15. package/dist/safe-bash/command-chunks/{chunk-YRBFNT5B.js → chunk-3YL2TMLA.js} +10 -1
  16. package/dist/safe-bash/command-chunks/{chunk-UWIDPTOB.js → chunk-3ZCABR5P.js} +1 -1
  17. package/dist/safe-bash/command-chunks/{chunk-5H7ZHP7F.js → chunk-43NDRBKY.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-BBOYR6LV.js → chunk-46GA576V.js} +3 -3
  19. package/dist/safe-bash/command-chunks/{chunk-WPT2FCHH.js → chunk-4SLPM2WM.js} +1 -1
  20. package/dist/safe-bash/command-chunks/{chunk-7ZQVMPSB.js → chunk-5CAXR62E.js} +1 -1
  21. package/dist/safe-bash/command-chunks/{chunk-3DTHX5UU.js → chunk-66653AEZ.js} +40 -14
  22. package/dist/safe-bash/command-chunks/{chunk-ETFJ4L7F.js → chunk-6OLE6CLV.js} +1 -1
  23. package/dist/safe-bash/command-chunks/{chunk-2KMNVJB7.js → chunk-A7PKUIJT.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{chunk-O3FTKLWR.js → chunk-BXOBM4HJ.js} +26 -17
  25. package/dist/safe-bash/command-chunks/{chunk-P66Q5F6K.js → chunk-DEQ47SBQ.js} +3 -3
  26. package/dist/safe-bash/command-chunks/{chunk-ZPBL7TYJ.js → chunk-EF3RAQ7M.js} +1 -1
  27. package/dist/safe-bash/command-chunks/{chunk-RQTFK7AV.js → chunk-EOO3NLD5.js} +1 -1
  28. package/dist/safe-bash/command-chunks/{chunk-EV7A5FNN.js → chunk-FFFRLPXU.js} +2 -2
  29. package/dist/safe-bash/command-chunks/{chunk-MQCLG2CT.js → chunk-FMXBLKWO.js} +1 -1
  30. package/dist/safe-bash/command-chunks/{chunk-4MVQE6CT.js → chunk-FYTBEGSY.js} +1 -1
  31. package/dist/safe-bash/command-chunks/chunk-HS2L7I4N.js +219 -0
  32. package/dist/safe-bash/command-chunks/{chunk-NXZJJM4J.js → chunk-IGXH5W5Z.js} +1 -1
  33. package/dist/safe-bash/command-chunks/{chunk-CMJBRGU2.js → chunk-IHQZKUBS.js} +1 -1
  34. package/dist/safe-bash/command-chunks/chunk-JADJ4BMN.js +1519 -0
  35. package/dist/safe-bash/command-chunks/{chunk-5AQAWIYK.js → chunk-JEZC5V3B.js} +4 -0
  36. package/dist/safe-bash/command-chunks/{chunk-YB5TNDY6.js → chunk-K5VJ4NNL.js} +39 -5
  37. package/dist/safe-bash/command-chunks/{chunk-7RQGRFHJ.js → chunk-KHWDEAE4.js} +2 -2
  38. package/dist/safe-bash/command-chunks/chunk-KSCVKF7I.js +604 -0
  39. package/dist/safe-bash/command-chunks/{chunk-3NJETNC2.js → chunk-MBXNG6C3.js} +2 -2
  40. package/dist/safe-bash/command-chunks/{chunk-WKS2PAZL.js → chunk-N63IGO5F.js} +10 -1
  41. package/dist/safe-bash/command-chunks/{chunk-3DID6MQY.js → chunk-OWTQYLID.js} +2 -2
  42. package/dist/safe-bash/command-chunks/{chunk-4EA7WI3L.js → chunk-QOOQD6BD.js} +42 -33
  43. package/dist/safe-bash/command-chunks/{chunk-R3SLT3ZX.js → chunk-R6GON4H3.js} +11 -1
  44. package/dist/safe-bash/command-chunks/{chunk-2GILUQJY.js → chunk-R7ZGDHME.js} +3 -3
  45. package/dist/safe-bash/command-chunks/{chunk-LKAFLJ5L.js → chunk-RWQKX44L.js} +1 -1
  46. package/dist/safe-bash/command-chunks/{chunk-PKH57OIC.js → chunk-SG2KOOD4.js} +2 -2
  47. package/dist/safe-bash/command-chunks/{chunk-HCPEYQKT.js → chunk-SIAN5LI3.js} +286 -307
  48. package/dist/safe-bash/command-chunks/chunk-T4TGJYFV.js +60 -0
  49. package/dist/safe-bash/command-chunks/{chunk-T7RT2BNL.js → chunk-U5TQVW64.js} +191 -146
  50. package/dist/safe-bash/command-chunks/{chunk-NXCJNPL3.js → chunk-UCE77LYV.js} +2 -1
  51. package/dist/safe-bash/command-chunks/{chunk-OT75C5YS.js → chunk-UGDQSGUZ.js} +1 -1
  52. package/dist/safe-bash/command-chunks/{chunk-EWECMOQ5.js → chunk-UIHPHIKI.js} +1 -1
  53. package/dist/safe-bash/command-chunks/{chunk-4XYGJB24.js → chunk-VJXPNNBD.js} +3 -3
  54. package/dist/safe-bash/command-chunks/{chunk-E5CDHXFA.js → chunk-VOR6YDZC.js} +26 -1
  55. package/dist/safe-bash/command-chunks/{chunk-ZIDESNHW.js → chunk-VQINIBCZ.js} +1 -1
  56. package/dist/safe-bash/command-chunks/chunk-VSNVYOK2.js +30 -0
  57. package/dist/safe-bash/command-chunks/{chunk-Q2ACHUTY.js → chunk-WRO3PB2M.js} +1 -1
  58. package/dist/safe-bash/command-chunks/{chunk-RUAGHZNF.js → chunk-X5ODTF3E.js} +7 -5
  59. package/dist/safe-bash/command-chunks/{chunk-LH4VBNF6.js → chunk-XGTSP2CP.js} +84 -16
  60. package/dist/safe-bash/command-chunks/{chunk-J3VS55K4.js → chunk-YHRESVJ7.js} +9 -3
  61. package/dist/safe-bash/command-chunks/{chunk-K576GZED.js → chunk-YK6ZVCA2.js} +2 -2
  62. package/dist/safe-bash/command-chunks/{chunk-W5LH7D23.js → chunk-YR2A2L4J.js} +8 -8
  63. package/dist/safe-bash/command-chunks/{chunk-UYNJF5QN.js → chunk-ZALAWNOE.js} +76 -122
  64. package/dist/safe-bash/command-chunks/{pdf-renderer-346WYKSZ.js → pdf-renderer-5QWOVFA4.js} +1 -1
  65. package/dist/safe-bash/command-chunks/{prompt-tool-debug-3POFNRYP.js → prompt-tool-debug-G7ATE7D5.js} +6 -4
  66. package/dist/safe-bash/commands/bc/index.browser.js +1 -1
  67. package/dist/safe-bash/commands/llm/index.browser.js +5 -1
  68. package/dist/safe-bash/commands/llm/index.js +1 -1
  69. package/dist/safe-bash/commands/python/executor.browser.js +3 -1
  70. package/dist/safe-bash/commands/python/executor.js +1 -1
  71. package/dist/safe-bash/commands/python/index.browser.js +5 -1
  72. package/dist/safe-bash/commands/python/index.js +1 -1
  73. package/dist/safe-bash/core.browser.js +2 -2
  74. package/dist/safe-bash/full-core.browser.js +14 -6
  75. package/dist/safe-bash/plugins/index.browser.js +3 -3
  76. package/dist/safe-bash/registry-entry.browser.js +2 -2
  77. package/dist/safe-bash/search.browser.js +1 -1
  78. package/dist/safe-bash/shell/runtime.js +18 -7
  79. package/dist/safe-bash/shell/sync-extra-evaluators.js +2 -0
  80. package/dist/safe-bash/shell-entry.browser.js +2 -2
  81. package/dist/safe-bash-command-awk/awk-runtime.js +2 -2
  82. package/dist/safe-bash-command-awk/awk-syntax.js +1 -1
  83. package/dist/safe-bash-command-awk/awk.js +3 -3
  84. package/dist/safe-bash-command-awk/index.js +3 -3
  85. package/dist/safe-bash-command-ffmpeg/index.js +15 -12
  86. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  87. package/dist/safe-bash-command-ffprobe/media.js +2 -2
  88. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  89. package/dist/safe-bash-command-gpg/index.js +11 -3
  90. package/dist/safe-bash-command-imagemagick/index.js +45 -12
  91. package/dist/safe-bash-command-llm/collections.js +6 -4
  92. package/dist/safe-bash-command-llm/command.js +4 -4
  93. package/dist/safe-bash-command-llm/import-json-document.d.ts +9 -2
  94. package/dist/safe-bash-command-llm/index.d.ts +2 -1
  95. package/dist/safe-bash-command-llm/index.js +10 -4
  96. package/dist/safe-bash-command-llm/loader-provider.d.ts +5 -0
  97. package/dist/safe-bash-command-mcp/index.js +10 -13
  98. package/dist/safe-bash-command-pdftoppm/index.js +2 -2
  99. package/dist/safe-bash-command-playwright-cli/index.js +2 -2
  100. package/dist/safe-bash-command-playwright-cli/playwright/ability-execution.d.ts +1 -0
  101. package/dist/safe-bash-command-playwright-cli/playwright/ability-execution.js +1 -1
  102. package/dist/safe-bash-command-playwright-cli/playwright/controller.d.ts +2 -0
  103. package/dist/safe-bash-command-playwright-cli/playwright/controller.js +2 -2
  104. package/dist/safe-bash-command-playwright-cli/playwright/index.js +2 -2
  105. package/dist/safe-bash-command-python/build-backend.d.ts +2 -0
  106. package/dist/safe-bash-command-python/cache.d.ts +1 -1
  107. package/dist/safe-bash-command-python/executor.d.ts +5 -2
  108. package/dist/safe-bash-command-python/executor.js +11 -6
  109. package/dist/safe-bash-command-python/host-capabilities.js +1 -1
  110. package/dist/safe-bash-command-python/index.js +11 -6
  111. package/dist/safe-bash-command-python/jspi.js +5 -3
  112. package/dist/safe-bash-command-python/manifest-file.d.ts +44 -0
  113. package/dist/safe-bash-command-python/manifest.d.ts +45 -0
  114. package/dist/safe-bash-command-python/provisioning.d.ts +20 -1
  115. package/dist/safe-bash-command-python/provisioning.js +3 -2
  116. package/dist/safe-bash-command-python/reply.js +7 -11
  117. package/dist/safe-bash-command-python/source-archive.js +2 -2
  118. package/dist/safe-bash-command-python/source-zip.js +2 -2
  119. package/dist/safe-bash-command-python/worker.js +34 -21
  120. package/dist/safe-bash-command-sqlite3/engine.d.ts +4 -0
  121. package/dist/safe-bash-command-sqlite3/index.js +174 -18
  122. package/dist/safe-bash-command-svgo/index.js +1 -1
  123. package/dist/safe-bash-command-tar/create.js +3 -3
  124. package/dist/safe-bash-command-tar/extract.js +3 -3
  125. package/dist/safe-bash-command-tar/index.js +5 -5
  126. package/dist/safe-bash-command-tar/modes.js +5 -5
  127. package/dist/safe-bash-command-tar/options.d.ts +1 -1
  128. package/dist/safe-bash-command-tar/options.js +1 -1
  129. package/dist/safe-bash-command-tar/stream.js +1 -1
  130. package/dist/safe-bash-command-wkhtmltopdf/index.js +1 -1
  131. package/dist/safe-bash-command-xan/argv.js +1 -1
  132. package/dist/safe-bash-command-xan/commands.js +3 -3
  133. package/dist/safe-bash-command-xan/index.js +3 -3
  134. package/dist/safe-bash-command-xan/io.js +2 -2
  135. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  136. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  137. package/dist/safe-bash-compression-engine/files.js +6 -6
  138. package/dist/safe-bash-compression-engine/index.js +5 -5
  139. package/dist/safe-bash-compression-engine/operand.js +6 -6
  140. package/dist/safe-bash-compression-engine/options.js +1 -1
  141. package/dist/safe-bash-compression-engine/stream.js +5 -5
  142. package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
  143. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  144. package/dist/safe-bash-contracts/filesystem-output.js +1 -1
  145. package/dist/safe-bash-csv-engine/index.js +4 -4
  146. package/dist/safe-bash-csv-engine/python-codec-aliases.js +1 -1
  147. package/dist/safe-bash-csv-engine/python-codepages.js +2 -2
  148. package/dist/safe-bash-csv-engine/python-utf16.js +3 -3
  149. package/dist/safe-bash-csv-engine/text-decoder.js +4 -4
  150. package/dist/safe-bash-graphviz-engine/index.js +1 -1
  151. package/dist/safe-bash-pager-engine/index.js +2 -2
  152. package/dist/safe-bash-query-engine/capture.js +3 -3
  153. package/dist/safe-bash-query-engine/delpaths.js +3 -3
  154. package/dist/safe-bash-query-engine/formats.js +2 -2
  155. package/dist/safe-bash-query-engine/index.js +10 -10
  156. package/dist/safe-bash-query-engine/indices.js +3 -3
  157. package/dist/safe-bash-query-engine/input.d.ts +3 -3
  158. package/dist/safe-bash-query-engine/input.js +1 -1
  159. package/dist/safe-bash-query-engine/interpreter.js +9 -9
  160. package/dist/safe-bash-query-engine/query-core.js +10 -10
  161. package/dist/safe-bash-query-engine/regex.js +4 -4
  162. package/dist/safe-bash-query-engine/splits.js +5 -5
  163. package/dist/safe-bash-query-engine/values.js +2 -2
  164. package/dist/safe-playwright-cloudflare/browser-code-executor.js +2 -2
  165. package/dist/safe-playwright-cloudflare/browser-guest-source.d.ts +2 -0
  166. package/dist/safe-playwright-cloudflare/browser-guest-source.js +36 -0
  167. package/dist/safe-playwright-cloudflare/browser-run-code-contract.d.ts +1 -1
  168. package/dist/safe-playwright-cloudflare/browser-run-code-guest.generated.d.ts +1 -2
  169. package/dist/safe-playwright-cloudflare/browser-run-code-guest.generated.js +2 -2
  170. package/dist/safe-playwright-cloudflare/browser-run-code.js +4 -1
  171. package/package.json +4 -3
  172. package/dist/safe-bash/command-chunks/chunk-BKQWFABY.js +0 -960
  173. package/dist/safe-bash/command-chunks/chunk-DV7TCGJR.js +0 -691
  174. package/dist/safe-bash/command-chunks/chunk-ZERCTWUI.js +0 -467
@@ -61,7 +61,7 @@ import {
61
61
  } from "./chunk-D43FDVLM.js";
62
62
  import {
63
63
  executePlaywrightAbility
64
- } from "./chunk-2KMNVJB7.js";
64
+ } from "./chunk-A7PKUIJT.js";
65
65
  import {
66
66
  createPlaywrightCommandBudget
67
67
  } from "./chunk-GYGORRXA.js";
@@ -127,7 +127,7 @@ function createPlaywrightController(options = {}) {
127
127
  if (options.persistence?.close !== void 0 && typeof options.persistence.close !== "function") throw new TypeError("Invalid Playwright persistence close");
128
128
  if (options.persistence?.list !== void 0 && typeof options.persistence.list !== "function") throw new TypeError("Invalid Playwright persistence list");
129
129
  for (const key of ["inspectRecovery", "recordOperation"]) if (options.persistence?.[key] !== void 0 && typeof options.persistence[key] !== "function") throw new TypeError("Invalid Playwright recovery persistence");
130
- if (options.limits !== void 0 && (!options.limits || typeof options.limits !== "object" || Object.keys(options.limits).some((key) => !["maxSessions", "actionTimeoutMs", "codeExecutionTimeoutMs", "maxSnapshotBytes", "maxSnapshotRefs", "maxArtifactBytes", "maxTabs", "maxCommandBytes", ...Object.keys(playwrightStructureDefaults)].includes(key)))) throw new TypeError("Unsupported Playwright limits");
130
+ if (options.limits !== void 0 && (!options.limits || typeof options.limits !== "object" || Object.keys(options.limits).some((key) => !["maxSessions", "actionTimeoutMs", "codeExecutionTimeoutMs", "maxSnapshotBytes", "maxSnapshotRefs", "maxArtifactBytes", "maxTabs", "maxCommandBytes", "maxOutputArtifactBytes", ...Object.keys(playwrightStructureDefaults)].includes(key)))) throw new TypeError("Unsupported Playwright limits");
131
131
  if (options.billing !== void 0) throw new Error("Live billing is not implemented");
132
132
  const maxSessions = options.limits?.maxSessions ?? Infinity;
133
133
  const actionTimeoutMs = options.limits?.actionTimeoutMs ?? Infinity;
@@ -137,9 +137,10 @@ function createPlaywrightController(options = {}) {
137
137
  const maxArtifactBytes = options.limits?.maxArtifactBytes ?? Infinity;
138
138
  const maxTabs = options.limits?.maxTabs ?? Infinity;
139
139
  const maxCommandBytes = options.limits?.maxCommandBytes ?? Infinity;
140
+ const maxOutputArtifactBytes = options.limits?.maxOutputArtifactBytes;
140
141
  const abilities = registerPlaywrightAbilities(options.abilities, options.adapter !== void 0);
141
142
  let refSequence = 0;
142
- for (const value of [options.limits?.maxSessions, options.limits?.maxSnapshotBytes, actionTimeoutMs, codeExecutionTimeoutMs, options.limits?.maxSnapshotRefs, options.limits?.maxArtifactBytes, options.limits?.maxTabs, options.limits?.maxCommandBytes]) if (value !== void 0 && value !== Infinity && (!Number.isSafeInteger(value) || value < 1)) throw new RangeError("Invalid Playwright limit");
143
+ for (const value of [options.limits?.maxSessions, options.limits?.maxSnapshotBytes, actionTimeoutMs, codeExecutionTimeoutMs, options.limits?.maxSnapshotRefs, options.limits?.maxArtifactBytes, options.limits?.maxTabs, options.limits?.maxCommandBytes, maxOutputArtifactBytes]) if (value !== void 0 && value !== Infinity && (!Number.isSafeInteger(value) || value < 1)) throw new RangeError("Invalid Playwright limit");
143
144
  for (const key of Object.keys(playwrightStructureDefaults)) {
144
145
  const value = options.limits?.[key];
145
146
  if (value !== void 0 && value !== Infinity && (!Number.isSafeInteger(value) || value < 0)) throw new RangeError("Invalid Playwright structure limit");
@@ -797,6 +798,7 @@ function createPlaywrightController(options = {}) {
797
798
  };
798
799
  const run = async (invocation) => {
799
800
  const commandBudget = createPlaywrightCommandBudget(maxCommandBytes);
801
+ const artifactBudget = maxOutputArtifactBytes === void 0 ? commandBudget : createPlaywrightCommandBudget(maxOutputArtifactBytes);
800
802
  let reportedError = false;
801
803
  const writtenFiles = /* @__PURE__ */ new Set();
802
804
  const original = invocation;
@@ -890,7 +892,7 @@ function createPlaywrightController(options = {}) {
890
892
  check();
891
893
  if (!invocation.writeArtifact) throw new Error("Artifact byte destination unsupported");
892
894
  if (bytes.byteLength > maxArtifactBytes) throw new PlaywrightResourceLimitError("Artifact byte limit exceeded");
893
- commandBudget.admit(bytes.byteLength);
895
+ artifactBudget.admit(bytes.byteLength);
894
896
  await invocation.writeArtifact(bytes, filename);
895
897
  check();
896
898
  };
@@ -1489,7 +1491,7 @@ function createPlaywrightController(options = {}) {
1489
1491
  }
1490
1492
  });
1491
1493
  }
1492
- const executeAbility = () => executePlaywrightAbility(ability, parsed, invocation, { signal: local.signal, structureLimits: options.limits, maxCommandBytes, maxArtifactBytes, commandBudget, actionTimeoutMs: sessionActionTimeout(active), codeExecutionTimeoutMs, navigationTimeoutMs: sessionNavigationTimeout(active), maxPages: maxTabs, ...browserSession ? { browserSession } : {}, check: () => active ? checkSession(active) : check() });
1494
+ const executeAbility = () => executePlaywrightAbility(ability, parsed, invocation, { signal: local.signal, structureLimits: options.limits, maxCommandBytes, maxArtifactBytes, commandBudget, artifactBudget, actionTimeoutMs: sessionActionTimeout(active), codeExecutionTimeoutMs, navigationTimeoutMs: sessionNavigationTimeout(active), maxPages: maxTabs, ...browserSession ? { browserSession } : {}, check: () => active ? checkSession(active) : check() });
1493
1495
  let result;
1494
1496
  try {
1495
1497
  result = active ? await active.snapshot.withReferences(executeAbility) : await executeAbility();
@@ -1,7 +1,16 @@
1
1
  // packages/safe-bash-command-wkhtmltopdf/src/pdf-renderer.ts
2
2
  import { Parser } from "parse5";
3
3
  import { drainCooperativeSteps } from "../../safe-bash-contracts/yield.js";
4
- import { PdfDocument, decodePng } from "../../pdf-ast/index.js";
4
+ import {
5
+ PdfDocument,
6
+ cosArray,
7
+ cosDict,
8
+ cosName,
9
+ cosNumber,
10
+ cosString,
11
+ decodePng,
12
+ dictSet
13
+ } from "../../pdf-ast/index.js";
5
14
 
6
15
  // packages/safe-bash-command-wkhtmltopdf/src/command.ts
7
16
  import { commandRuntimeIdentity, getCommandArguments } from "../../safe-bash-contracts/command.js";
@@ -1229,7 +1238,7 @@ async function runWkhtmltopdf(context, options = {}) {
1229
1238
  await writeBytes(stdout.output, encoder.encode(text), signal);
1230
1239
  result = { kind: "information", exitCode: 0 };
1231
1240
  } else {
1232
- const renderer = options.renderer ?? (await import("./pdf-renderer-346WYKSZ.js")).pdfAstRenderer;
1241
+ const renderer = options.renderer ?? (await import("./pdf-renderer-5QWOVFA4.js")).pdfAstRenderer;
1233
1242
  requireRendererFeatures(renderer.profile, []);
1234
1243
  let outputBytes = 0;
1235
1244
  let outputChunks = 0;
@@ -1741,6 +1750,7 @@ function* layoutObjectPagesSteps(blocks, box, settings, signal) {
1741
1750
  let cooperativeWork = 0;
1742
1751
  const pages = [];
1743
1752
  let currentActions = [];
1753
+ let currentHeadings = [];
1744
1754
  const headerReserve = settings.header.left || settings.header.center || settings.header.right ? 24 : 0;
1745
1755
  const footerReserve = settings.footer.left || settings.footer.center || settings.footer.right ? 24 : 0;
1746
1756
  const topY = box.height - box.marginTop - headerReserve;
@@ -1748,8 +1758,9 @@ function* layoutObjectPagesSteps(blocks, box, settings, signal) {
1748
1758
  const contentWidth = Math.max(72, box.width - box.marginLeft - box.marginRight);
1749
1759
  let cursorY = topY;
1750
1760
  const flushPage = () => {
1751
- pages.push({ actions: currentActions });
1761
+ pages.push({ actions: currentActions, headings: currentHeadings });
1752
1762
  currentActions = [];
1763
+ currentHeadings = [];
1753
1764
  cursorY = topY;
1754
1765
  };
1755
1766
  const ensureHeight = (needed) => {
@@ -1775,6 +1786,9 @@ function* layoutObjectPagesSteps(blocks, box, settings, signal) {
1775
1786
  const maxChars = Math.max(15, Math.floor(contentWidth / (fontSize * 0.55)));
1776
1787
  const lines = wrapTextLines(block.text ?? "", maxChars);
1777
1788
  ensureHeight(lines.length * lineHeight + 10);
1789
+ if (block.text) {
1790
+ currentHeadings.push({ title: block.text, level });
1791
+ }
1778
1792
  cursorY -= 4;
1779
1793
  const blockTopY = cursorY;
1780
1794
  for (const line of lines) {
@@ -2080,9 +2094,13 @@ function* layoutObjectPagesSteps(blocks, box, settings, signal) {
2080
2094
  }
2081
2095
  return pages;
2082
2096
  }
2083
- function substituteFurnitureTokens(template, tokens) {
2097
+ function substituteFurnitureTokens(template, tokens, replacements = []) {
2084
2098
  const isoDate = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2085
- return template.replace(/\[page\]/g, String(tokens.page)).replace(/\[topage\]/g, String(tokens.topage)).replace(/\[webpage\]/g, tokens.webpage).replace(/\[title\]/g, tokens.title).replace(/\[section\]/g, tokens.section ?? tokens.title).replace(/\[subsection\]/g, tokens.subsection ?? "").replace(/\[isodate\]/g, isoDate).replace(/\[date\]/g, isoDate);
2099
+ let out = template.replace(/\[page\]/g, String(tokens.page)).replace(/\[topage\]/g, String(tokens.topage)).replace(/\[toPage\]/g, String(tokens.topage)).replace(/\[webpage\]/g, tokens.webpage).replace(/\[title\]/g, tokens.title).replace(/\[section\]/g, tokens.section ?? tokens.title).replace(/\[subsection\]/g, tokens.subsection ?? "").replace(/\[isodate\]/g, isoDate).replace(/\[date\]/g, isoDate);
2100
+ for (const [rk, rv] of replacements) {
2101
+ if (rk) out = out.split(`[${rk}]`).join(rv);
2102
+ }
2103
+ return out;
2086
2104
  }
2087
2105
  function* renderPdfAstSteps(request) {
2088
2106
  let cooperativeWork = 0;
@@ -2108,7 +2126,7 @@ function* renderPdfAstSteps(request) {
2108
2126
  const pages = yield* layoutObjectPagesSteps(parsed.blocks, box, obj.settings, signal);
2109
2127
  laidOutPerObject.push(pages);
2110
2128
  objectMeta.push({
2111
- title: parsed.title || inferredDocumentTitle || "Document",
2129
+ title: job.global.documentTitle || parsed.title || inferredDocumentTitle || "Document",
2112
2130
  webpage: obj.input ?? "-",
2113
2131
  settings: obj.settings
2114
2132
  });
@@ -2133,16 +2151,19 @@ function* renderPdfAstSteps(request) {
2133
2151
  creator: "wkhtmltopdf (pdf-ast-static)",
2134
2152
  producer: "@poe-code/pdf-ast"
2135
2153
  });
2154
+ const outlineEntries = [];
2136
2155
  for (const outPage of sequence.pages) {
2137
2156
  yield;
2138
2157
  signal.throwIfAborted();
2139
2158
  const spec = laidOutPerObject[outPage.objectIndex][outPage.pageIndex];
2140
2159
  const meta = objectMeta[outPage.objectIndex];
2141
2160
  const page = doc.addPage({ width: box.width, height: box.height });
2142
- for (const action of spec.actions) {
2143
- if (++cooperativeWork % 64 === 0)
2144
- yield;
2145
- action(page, doc, grayscale);
2161
+ if (job.global.outline && job.global.outlineDepth > 0 && outPage.copyIndex === 0 && meta.settings.includeInOutline) {
2162
+ for (const h of spec.headings ?? []) {
2163
+ if (h.level <= job.global.outlineDepth) {
2164
+ outlineEntries.push({ title: h.title, level: h.level, pageRef: page.ref });
2165
+ }
2166
+ }
2146
2167
  }
2147
2168
  const tokens = {
2148
2169
  page: outPage.logicalPage,
@@ -2150,11 +2171,12 @@ function* renderPdfAstSteps(request) {
2150
2171
  webpage: meta.webpage,
2151
2172
  title: meta.title
2152
2173
  };
2174
+ const repl = meta.settings.replacements;
2153
2175
  const header = meta.settings.header;
2154
2176
  const footer = meta.settings.footer;
2155
2177
  const headerY = box.height - Math.max(18, box.marginTop * 0.6);
2156
2178
  if (header.left) {
2157
- page.drawText(substituteFurnitureTokens(header.left, tokens), {
2179
+ page.drawText(substituteFurnitureTokens(header.left, tokens, repl), {
2158
2180
  x: box.marginLeft,
2159
2181
  y: headerY,
2160
2182
  size: Math.min(10, header.fontSize || 9),
@@ -2163,7 +2185,7 @@ function* renderPdfAstSteps(request) {
2163
2185
  });
2164
2186
  }
2165
2187
  if (header.center) {
2166
- const text = substituteFurnitureTokens(header.center, tokens);
2188
+ const text = substituteFurnitureTokens(header.center, tokens, repl);
2167
2189
  page.drawText(text, {
2168
2190
  x: Math.max(box.marginLeft, (box.width - text.length * 4.5) / 2),
2169
2191
  y: headerY,
@@ -2173,7 +2195,7 @@ function* renderPdfAstSteps(request) {
2173
2195
  });
2174
2196
  }
2175
2197
  if (header.right) {
2176
- const text = substituteFurnitureTokens(header.right, tokens);
2198
+ const text = substituteFurnitureTokens(header.right, tokens, repl);
2177
2199
  page.drawText(text, {
2178
2200
  x: Math.max(box.marginLeft, box.width - box.marginRight - text.length * 4.8),
2179
2201
  y: headerY,
@@ -2192,9 +2214,14 @@ function* renderPdfAstSteps(request) {
2192
2214
  strokeWidth: 0.5
2193
2215
  });
2194
2216
  }
2217
+ for (const action of spec.actions) {
2218
+ if (++cooperativeWork % 64 === 0)
2219
+ yield;
2220
+ action(page, doc, grayscale);
2221
+ }
2195
2222
  const footerY = Math.max(12, box.marginBottom * 0.5);
2196
2223
  if (footer.left) {
2197
- page.drawText(substituteFurnitureTokens(footer.left, tokens), {
2224
+ page.drawText(substituteFurnitureTokens(footer.left, tokens, repl), {
2198
2225
  x: box.marginLeft,
2199
2226
  y: footerY,
2200
2227
  size: Math.min(10, footer.fontSize || 9),
@@ -2203,7 +2230,7 @@ function* renderPdfAstSteps(request) {
2203
2230
  });
2204
2231
  }
2205
2232
  if (footer.center) {
2206
- const text = substituteFurnitureTokens(footer.center, tokens);
2233
+ const text = substituteFurnitureTokens(footer.center, tokens, repl);
2207
2234
  page.drawText(text, {
2208
2235
  x: Math.max(box.marginLeft, (box.width - text.length * 4.5) / 2),
2209
2236
  y: footerY,
@@ -2213,7 +2240,7 @@ function* renderPdfAstSteps(request) {
2213
2240
  });
2214
2241
  }
2215
2242
  if (footer.right) {
2216
- const text = substituteFurnitureTokens(footer.right, tokens);
2243
+ const text = substituteFurnitureTokens(footer.right, tokens, repl);
2217
2244
  page.drawText(text, {
2218
2245
  x: Math.max(box.marginLeft, box.width - box.marginRight - text.length * 4.8),
2219
2246
  y: footerY,
@@ -2233,6 +2260,47 @@ function* renderPdfAstSteps(request) {
2233
2260
  });
2234
2261
  }
2235
2262
  }
2263
+ if (outlineEntries.length > 0 && doc.cos.rootRef) {
2264
+ const catalog = doc.cos.resolveDict(doc.cos.rootRef);
2265
+ if (catalog) {
2266
+ const outlinesDict = cosDict({ Type: cosName("Outlines") });
2267
+ const outlinesRef = doc.cos.allocateObject(outlinesDict);
2268
+ dictSet(catalog, "Outlines", outlinesRef);
2269
+ const stack = [{ ref: outlinesRef, dict: outlinesDict, children: [] }];
2270
+ for (const bm of outlineEntries) {
2271
+ const targetLevel = Math.max(1, bm.level);
2272
+ while (stack.length > targetLevel) {
2273
+ stack.pop();
2274
+ }
2275
+ while (stack.length < targetLevel) {
2276
+ const top = stack[stack.length - 1];
2277
+ const lastChild = top.children[top.children.length - 1];
2278
+ if (lastChild) {
2279
+ stack.push({ ref: lastChild.ref, dict: lastChild.dict, children: [] });
2280
+ } else {
2281
+ break;
2282
+ }
2283
+ }
2284
+ const parentState = stack[stack.length - 1];
2285
+ const itemDict = cosDict({
2286
+ Title: cosString(bm.title),
2287
+ Parent: parentState.ref,
2288
+ Dest: cosArray([bm.pageRef, cosName("XYZ"), { kind: "null" }, { kind: "null" }, { kind: "null" }])
2289
+ });
2290
+ const itemRef = doc.cos.allocateObject(itemDict);
2291
+ const prevSibling = parentState.children[parentState.children.length - 1];
2292
+ if (prevSibling) {
2293
+ dictSet(prevSibling.dict, "Next", itemRef);
2294
+ dictSet(itemDict, "Prev", prevSibling.ref);
2295
+ } else {
2296
+ dictSet(parentState.dict, "First", itemRef);
2297
+ }
2298
+ dictSet(parentState.dict, "Last", itemRef);
2299
+ parentState.children.push({ ref: itemRef, dict: itemDict });
2300
+ dictSet(parentState.dict, "Count", cosNumber(parentState.children.length));
2301
+ }
2302
+ }
2303
+ }
2236
2304
  return doc.save();
2237
2305
  }
2238
2306
  function createPdfAstRenderer() {
@@ -11183,11 +11183,13 @@ var Commands = class {
11183
11183
  this.onAllocation = onAllocation;
11184
11184
  }
11185
11185
  cmds = [];
11186
+ hasPoints = false;
11186
11187
  transformStack = [];
11187
11188
  currentTransform = [1, 0, 0, 1, 0, 0];
11188
11189
  add(cmd, args) {
11189
11190
  this.onAllocation?.(64 + (args?.length ?? 0) * 16);
11190
11191
  if (args) {
11192
+ this.hasPoints = true;
11191
11193
  const { currentTransform } = this;
11192
11194
  for (let i = 0, ii = args.length; i < ii; i += 2) {
11193
11195
  Util.applyTransform(args, currentTransform, i);
@@ -11272,7 +11274,9 @@ var CompiledFont = class _CompiledFont {
11272
11274
  const cmds = new Commands(onAllocation);
11273
11275
  cmds.transform(fontMatrix.slice());
11274
11276
  this.compileGlyphImpl(code, cmds, glyphId);
11275
- cmds.add(DrawOPS.closePath);
11277
+ if (cmds.hasPoints) {
11278
+ cmds.add(DrawOPS.closePath);
11279
+ }
11276
11280
  return cmds.getPath();
11277
11281
  }
11278
11282
  compileGlyphImpl() {
@@ -11312,8 +11316,10 @@ var Type2Compiled = class extends CompiledFont {
11312
11316
  cmds.onFrameAllocation = onAllocation;
11313
11317
  cmds.transform(matrix2.slice());
11314
11318
  yield* compileCharString(code, cmds, this, glyphId);
11315
- cmds.add(DrawOPS.closePath);
11316
- yield cmds.getPath();
11319
+ if (cmds.hasPoints) {
11320
+ cmds.add(DrawOPS.closePath);
11321
+ yield cmds.getPath();
11322
+ }
11317
11323
  }
11318
11324
  compileGlyphImpl(code, cmds, glyphId) {
11319
11325
  for (const ignored of compileCharString(code, cmds, this, glyphId)) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  extendedPattern
3
- } from "./chunk-UWIDPTOB.js";
3
+ } from "./chunk-3ZCABR5P.js";
4
4
  import {
5
5
  describe
6
- } from "./chunk-ZIDESNHW.js";
6
+ } from "./chunk-VQINIBCZ.js";
7
7
  import {
8
8
  JqError,
9
9
  JqLimitError,
@@ -3,15 +3,15 @@ import {
3
3
  } from "./chunk-2IGH6JIP.js";
4
4
  import {
5
5
  splitRegex
6
- } from "./chunk-4XYGJB24.js";
6
+ } from "./chunk-VJXPNNBD.js";
7
7
  import {
8
8
  matchRegex,
9
9
  scanRegex,
10
10
  substituteRegex
11
- } from "./chunk-K576GZED.js";
11
+ } from "./chunk-YK6ZVCA2.js";
12
12
  import {
13
13
  capture
14
- } from "./chunk-UWIDPTOB.js";
14
+ } from "./chunk-3ZCABR5P.js";
15
15
  import {
16
16
  fromDateIso8601,
17
17
  gmtime,
@@ -22,13 +22,13 @@ import {
22
22
  } from "./chunk-BTDSUATE.js";
23
23
  import {
24
24
  delpaths
25
- } from "./chunk-OT75C5YS.js";
25
+ } from "./chunk-UGDQSGUZ.js";
26
26
  import {
27
27
  formatValue
28
- } from "./chunk-WKS2PAZL.js";
28
+ } from "./chunk-N63IGO5F.js";
29
29
  import {
30
30
  indices
31
- } from "./chunk-RQTFK7AV.js";
31
+ } from "./chunk-EOO3NLD5.js";
32
32
  import {
33
33
  binary,
34
34
  compare,
@@ -42,7 +42,7 @@ import {
42
42
  sortedKeys,
43
43
  stableSort,
44
44
  type
45
- } from "./chunk-ZIDESNHW.js";
45
+ } from "./chunk-VQINIBCZ.js";
46
46
  import {
47
47
  splitString
48
48
  } from "./chunk-BOMCPF7N.js";
@@ -51,7 +51,7 @@ import {
51
51
  measureValue,
52
52
  parseJson,
53
53
  stringify
54
- } from "./chunk-HCPEYQKT.js";
54
+ } from "./chunk-SIAN5LI3.js";
55
55
  import {
56
56
  JqError,
57
57
  JqHalt,