@poe-platform/safe-bash 0.1.788 → 0.1.790

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 (342) hide show
  1. package/README.md +1 -1
  2. package/dist/image-ast/index.browser.js +147 -80
  3. package/dist/image-ast/index.js +147 -80
  4. package/dist/mp4-ast/mp4.d.ts +2 -0
  5. package/dist/pdf-ast/cos/parser.d.ts +1 -0
  6. package/dist/pdf-ast/cos/security.d.ts +2 -0
  7. package/dist/pdf-ast/cos/writer.d.ts +1 -0
  8. package/dist/pdf-ast/document.d.ts +3 -0
  9. package/dist/pdf-ast/edit/forms.d.ts +1 -0
  10. package/dist/pdf-ast/index.js +171 -82
  11. package/dist/safe-bash/chunks/{chunk-L5QQLNTO.js → chunk-22PI65AH.js} +2 -2
  12. package/dist/safe-bash/chunks/{chunk-Q3E6C3DX.js → chunk-2TAGYMPK.js} +49 -34
  13. package/dist/safe-bash/chunks/{chunk-Z3HX3ZBA.js → chunk-2W4HTMEK.js} +52 -48
  14. package/dist/safe-bash/chunks/{chunk-FFZXP6ZC.js → chunk-3M7L7XU2.js} +2 -2
  15. package/dist/safe-bash/chunks/{chunk-XNODZRVD.js → chunk-3QAO6UYS.js} +2 -2
  16. package/dist/safe-bash/chunks/{chunk-YPETOVQU.js → chunk-3VKFK3NF.js} +2 -2
  17. package/dist/safe-bash/chunks/chunk-5OST7NOX.js +42 -0
  18. package/dist/safe-bash/chunks/{chunk-KEBSX2AX.js → chunk-6HLURHVU.js} +2 -2
  19. package/dist/safe-bash/chunks/chunk-DYEUZE6Z.js +19 -0
  20. package/dist/safe-bash/chunks/{chunk-T2TGCHKE.js → chunk-FM3WBSZT.js} +2 -2
  21. package/dist/safe-bash/chunks/chunk-GAYRKQM6.js +22 -0
  22. package/dist/safe-bash/chunks/{chunk-Q45QCA4J.js → chunk-I3KSESCR.js} +0 -7
  23. package/dist/safe-bash/chunks/{chunk-OSKDIBQS.js → chunk-JLIMK5TD.js} +1 -1
  24. package/dist/safe-bash/chunks/{chunk-2AYZCT5X.js → chunk-JQ2FAJJT.js} +27 -23
  25. package/dist/safe-bash/chunks/{chunk-QA3NVP43.js → chunk-JRE6Z3T7.js} +2 -2
  26. package/dist/safe-bash/chunks/{chunk-DC5EHLKS.js → chunk-NDIL6T7Y.js} +5 -5
  27. package/dist/safe-bash/chunks/{chunk-747G42FY.js → chunk-OPR4UAIT.js} +2 -2
  28. package/dist/safe-bash/chunks/chunk-OSMQCYSP.js +19 -0
  29. package/dist/safe-bash/chunks/chunk-OYB332PQ.js +17 -0
  30. package/dist/safe-bash/chunks/{chunk-ZMYVCRAF.js → chunk-QTIH2AFE.js} +77 -69
  31. package/dist/safe-bash/chunks/{chunk-PYTLIUST.js → chunk-SBESXWT2.js} +43 -44
  32. package/dist/safe-bash/chunks/{chunk-4FDQJUFW.js → chunk-SDEPGTOF.js} +1 -1
  33. package/dist/safe-bash/chunks/chunk-UZU5BIJI.js +32 -0
  34. package/dist/safe-bash/chunks/{chunk-BI6JV62X.js → chunk-VCCMROTL.js} +7 -10
  35. package/dist/safe-bash/chunks/chunk-W47GHRRF.js +13 -0
  36. package/dist/safe-bash/chunks/{chunk-NPMQWZUZ.js → chunk-WS7KZIUM.js} +2 -2
  37. package/dist/safe-bash/chunks/{chunk-3PZYHMGM.js → chunk-YYAERCWS.js} +7 -7
  38. package/dist/safe-bash/chunks/{chunk-5U7JECDB.js → chunk-ZPGVEUKF.js} +8 -7
  39. package/dist/safe-bash/chunks/{csvkit-K55OYAQC.js → csvkit-USUJG62I.js} +65 -11
  40. package/dist/safe-bash/chunks/{ffmpeg-BEFTQ6DZ.js → ffmpeg-KRGG5DLH.js} +21 -10
  41. package/dist/safe-bash/chunks/{gh-HQWOWLWE.js → gh-UCFDUZCX.js} +16 -8
  42. package/dist/safe-bash/chunks/{git-UFNPAOYZ.js → git-LPAF6KDG.js} +7 -9
  43. package/dist/safe-bash/chunks/{imagemagick-53BMHH6D.js → imagemagick-KGREKK4G.js} +38 -7
  44. package/dist/safe-bash/chunks/{implementation-QUTAAYMT.js → implementation-FXDRYS5A.js} +34 -8
  45. package/dist/safe-bash/chunks/{pdfimages-4OYI6FLG.js → pdfimages-UADCF4G4.js} +12 -8
  46. package/dist/safe-bash/chunks/{pdfinfo-I7U6TQPP.js → pdfinfo-O7UWPF4W.js} +38 -13
  47. package/dist/safe-bash/chunks/{pdftk-SUA6FMHI.js → pdftk-AERXIJTN.js} +13 -8
  48. package/dist/safe-bash/chunks/{pdftoppm-4C5DGEWX.js → pdftoppm-L466JQKI.js} +17 -10
  49. package/dist/safe-bash/chunks/{pdftotext-Y4WI225Y.js → pdftotext-SUSI4WXS.js} +19 -9
  50. package/dist/safe-bash/chunks/{qpdf-IORB4RV5.js → qpdf-YL24KVRH.js} +14 -8
  51. package/dist/safe-bash/chunks/{sips-WHAMJFEU.js → sips-QXEQZERX.js} +14 -7
  52. package/dist/safe-bash/chunks/{soffice-SYEK6WJS.js → soffice-TBITRML3.js} +16 -8
  53. package/dist/safe-bash/chunks/{wkhtmltopdf-ZIICWJLF.js → wkhtmltopdf-NJA2THRC.js} +27 -7
  54. package/dist/safe-bash/command-chunks/chunk-2C5BEBPY.js +1388 -0
  55. package/dist/safe-bash/command-chunks/{chunk-FXYWQ6S4.js → chunk-2EXV2ZLV.js} +2 -2
  56. package/dist/safe-bash/command-chunks/{chunk-PFBJR2PY.js → chunk-2KRKKW5S.js} +2 -2
  57. package/dist/safe-bash/command-chunks/{chunk-4DSJDVBM.js → chunk-32F3RBUW.js} +10 -749
  58. package/dist/safe-bash/command-chunks/{chunk-L3MLMXL4.js → chunk-3ZK5F23O.js} +1 -1
  59. package/dist/safe-bash/command-chunks/{chunk-4QX6XCDD.js → chunk-4RNIZ3RT.js} +79 -0
  60. package/dist/safe-bash/command-chunks/{chunk-D7TADAYG.js → chunk-64LG3EVJ.js} +17 -0
  61. package/dist/safe-bash/command-chunks/{chunk-TOSM3T3A.js → chunk-6EASC5EC.js} +20 -9
  62. package/dist/safe-bash/command-chunks/{chunk-ZF3ZVGQC.js → chunk-7JRITHKW.js} +150 -80
  63. package/dist/safe-bash/command-chunks/{chunk-IJ3FXP4Q.js → chunk-A3ZX6SCY.js} +1 -1
  64. package/dist/safe-bash/{chunks/chunk-LD76P7AG.js → command-chunks/chunk-AKDMCNX4.js} +74 -39
  65. package/dist/safe-bash/command-chunks/{chunk-KSIGF4AG.js → chunk-BK4CMEE6.js} +1 -1
  66. package/dist/safe-bash/command-chunks/{chunk-JUDOV5MJ.js → chunk-CBDVLMJB.js} +1 -1
  67. package/dist/safe-bash/command-chunks/{chunk-XGMWWUHV.js → chunk-CZ5DAK4K.js} +1 -1
  68. package/dist/safe-bash/command-chunks/{chunk-Z57TV6TC.js → chunk-EZ2DTOLI.js} +4 -2
  69. package/dist/safe-bash/command-chunks/{chunk-ADCGH6A7.js → chunk-FH3D75FC.js} +1 -1
  70. package/dist/safe-bash/command-chunks/{chunk-WYJTWJZ5.js → chunk-G3G6W5ZE.js} +1 -1
  71. package/dist/safe-bash/command-chunks/{chunk-3HDIDEUJ.js → chunk-GF54KE2M.js} +1 -1
  72. package/dist/safe-bash/command-chunks/chunk-H4LWTITX.js +169 -0
  73. package/dist/safe-bash/command-chunks/chunk-I2MQNBGR.js +145 -0
  74. package/dist/safe-bash/command-chunks/{chunk-Z7TYZG3A.js → chunk-IHHTTQX6.js} +5 -3
  75. package/dist/safe-bash/command-chunks/{chunk-5GRLAARV.js → chunk-IOXI5ZAJ.js} +1 -1
  76. package/dist/safe-bash/command-chunks/{chunk-INDIFLBW.js → chunk-JTAGNROA.js} +4 -0
  77. package/dist/safe-bash/command-chunks/{chunk-Y5IHIAY3.js → chunk-MDPIOQUD.js} +12 -8
  78. package/dist/safe-bash/command-chunks/chunk-PGEYORBZ.js +25 -0
  79. package/dist/safe-bash/command-chunks/chunk-QI4MGIN6.js +6 -0
  80. package/dist/safe-bash/command-chunks/chunk-QM4UZF3C.js +753 -0
  81. package/dist/safe-bash/command-chunks/chunk-QTYZAWSB.js +91 -0
  82. package/dist/safe-bash/command-chunks/chunk-SNK7K3XW.js +90 -0
  83. package/dist/safe-bash/command-chunks/chunk-T5OLGM43.js +314 -0
  84. package/dist/safe-bash/command-chunks/chunk-TB7IFMUZ.js +802 -0
  85. package/dist/safe-bash/command-chunks/{chunk-YNT4ZJHW.js → chunk-TPPBPIWL.js} +3 -3
  86. package/dist/safe-bash/command-chunks/chunk-VMK4XVKO.js +82 -0
  87. package/dist/safe-bash/command-chunks/chunk-VNSJKXDU.js +130 -0
  88. package/dist/safe-bash/command-chunks/{chunk-2LP3VMPA.js → chunk-WFDW4XXD.js} +1 -17
  89. package/dist/safe-bash/command-chunks/chunk-WR37IS4O.js +318 -0
  90. package/dist/safe-bash/command-chunks/chunk-YFNTMH6Z.js +6 -0
  91. package/dist/safe-bash/commands/basic.js +148 -48
  92. package/dist/safe-bash/commands/bytes/compression/index.js +5 -6
  93. package/dist/safe-bash/commands/cmp.d.ts +2 -3
  94. package/dist/safe-bash/commands/cmp.js +2 -689
  95. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  96. package/dist/safe-bash/commands/docx/index.browser.js +4 -47
  97. package/dist/safe-bash/commands/docx/index.d.ts +2 -24
  98. package/dist/safe-bash/commands/docx/index.js +2 -41
  99. package/dist/safe-bash/commands/docx/io.d.ts +1 -14
  100. package/dist/safe-bash/commands/docx/io.js +1 -15
  101. package/dist/safe-bash/commands/factor/index.browser.js +2 -2
  102. package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
  103. package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
  104. package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
  105. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  106. package/dist/safe-bash/commands/llm/command.d.ts +1 -4
  107. package/dist/safe-bash/commands/llm/command.js +1 -248
  108. package/dist/safe-bash/commands/llm/elevenlabs-stream.d.ts +1 -2
  109. package/dist/safe-bash/commands/llm/elevenlabs-stream.js +1 -117
  110. package/dist/safe-bash/commands/llm/elevenlabs.d.ts +1 -15
  111. package/dist/safe-bash/commands/llm/elevenlabs.js +1 -123
  112. package/dist/safe-bash/commands/llm/index.browser.js +20 -15
  113. package/dist/safe-bash/commands/llm/index.d.ts +1 -6
  114. package/dist/safe-bash/commands/llm/index.js +1 -4
  115. package/dist/safe-bash/commands/llm/mime.d.ts +1 -2
  116. package/dist/safe-bash/commands/llm/mime.js +1 -136
  117. package/dist/safe-bash/commands/llm/openai-http.d.ts +1 -8
  118. package/dist/safe-bash/commands/llm/openai-http.js +1 -143
  119. package/dist/safe-bash/commands/llm/openai-sse.d.ts +1 -3
  120. package/dist/safe-bash/commands/llm/openai-sse.js +1 -78
  121. package/dist/safe-bash/commands/llm/openai.d.ts +1 -14
  122. package/dist/safe-bash/commands/llm/openai.js +1 -288
  123. package/dist/safe-bash/commands/llm/providers/elevenlabs.d.ts +1 -1
  124. package/dist/safe-bash/commands/llm/providers/elevenlabs.js +1 -1
  125. package/dist/safe-bash/commands/llm/providers/index.browser.js +6 -6
  126. package/dist/safe-bash/commands/llm/providers/index.d.ts +1 -3
  127. package/dist/safe-bash/commands/llm/providers/index.js +1 -2
  128. package/dist/safe-bash/commands/llm/providers/openai.d.ts +1 -1
  129. package/dist/safe-bash/commands/llm/providers/openai.js +1 -1
  130. package/dist/safe-bash/commands/llm/providers/shared.d.ts +1 -23
  131. package/dist/safe-bash/commands/llm/providers/shared.js +1 -65
  132. package/dist/safe-bash/commands/llm/service.d.ts +1 -37
  133. package/dist/safe-bash/commands/llm/service.js +1 -151
  134. package/dist/safe-bash/commands/llm/types.d.ts +1 -52
  135. package/dist/safe-bash/commands/llm/types.js +1 -1
  136. package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
  137. package/dist/safe-bash/commands/media/index.browser.js +1 -1
  138. package/dist/safe-bash/commands/network/index.browser.js +9 -9
  139. package/dist/safe-bash/commands/network/types.d.ts +2 -40
  140. package/dist/safe-bash/commands/node/index.browser.js +6 -8
  141. package/dist/safe-bash/commands/op/index.browser.js +3 -3
  142. package/dist/safe-bash/commands/op/index.js +12 -28
  143. package/dist/safe-bash/commands/pptx/index.d.ts +2 -28
  144. package/dist/safe-bash/commands/pptx/index.js +2 -152
  145. package/dist/safe-bash/commands/pr/index.browser.js +2 -2
  146. package/dist/safe-bash/commands/printf-float.d.ts +1 -0
  147. package/dist/safe-bash/commands/printf-float.js +48 -38
  148. package/dist/safe-bash/commands/printf-format.js +9 -6
  149. package/dist/safe-bash/commands/printf-quote.d.ts +3 -0
  150. package/dist/safe-bash/commands/printf-quote.js +62 -0
  151. package/dist/safe-bash/commands/printf-wide.d.ts +5 -0
  152. package/dist/safe-bash/commands/printf-wide.js +41 -0
  153. package/dist/safe-bash/commands/python/index.browser.js +8 -8
  154. package/dist/safe-bash/commands/python/worker.browser.js +2 -2
  155. package/dist/safe-bash/commands/truncate.d.ts +2 -3
  156. package/dist/safe-bash/commands/truncate.js +2 -686
  157. package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
  158. package/dist/safe-bash/commands/xml/index.browser.js +2 -2
  159. package/dist/safe-bash/commands/yq/index.browser.js +3 -3
  160. package/dist/safe-bash/contracts/diagnostics.d.ts +2 -0
  161. package/dist/safe-bash/contracts/diagnostics.js +2 -0
  162. package/dist/safe-bash/contracts/runtime-control.d.ts +2 -0
  163. package/dist/safe-bash/contracts/runtime-control.js +2 -0
  164. package/dist/safe-bash/core.browser.d.ts +1 -1
  165. package/dist/safe-bash/core.browser.js +10645 -14065
  166. package/dist/safe-bash/core.d.ts +10 -1
  167. package/dist/safe-bash/core.js +0 -1
  168. package/dist/safe-bash/jobs.browser.js +5 -4
  169. package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -2
  170. package/dist/safe-bash/opt-in/commands/cmp/index.js +776 -79
  171. package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +0 -12
  172. package/dist/safe-bash/opt-in/commands/cmp/options.js +0 -153
  173. package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +8 -3
  174. package/dist/safe-bash/opt-in/commands/truncate/index.js +790 -272
  175. package/dist/safe-bash/opt-in/commands/truncate/sync.d.ts +1 -0
  176. package/dist/safe-bash/opt-in/commands/truncate/sync.js +60 -0
  177. package/dist/safe-bash/optional-host.browser.js +61 -80
  178. package/dist/safe-bash/optional-host.d.ts +3 -1
  179. package/dist/safe-bash/optional-host.js +3 -1
  180. package/dist/safe-bash/shell/runtime.js +44 -18
  181. package/dist/safe-bash/yq-browser/index.js +1 -1
  182. package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
  183. package/dist/safe-bash-checksum-engine/index.js +14 -2
  184. package/dist/safe-bash-command-bzip2/index.js +2 -1
  185. package/dist/safe-bash-command-cmp/index.d.ts +10 -0
  186. package/dist/safe-bash-command-cmp/index.js +796 -0
  187. package/dist/safe-bash-command-cmp/options.d.ts +12 -0
  188. package/dist/safe-bash-command-cmp/options.js +42 -0
  189. package/dist/safe-bash-command-csvcut/index.js +11 -8
  190. package/dist/safe-bash-command-csvgrep/index.js +35 -7
  191. package/dist/safe-bash-command-csvkit/codecs/python.js +4 -3
  192. package/dist/safe-bash-command-csvkit/codecs/utf8.js +3 -2
  193. package/dist/safe-bash-command-csvkit/index.js +80 -324
  194. package/dist/safe-bash-command-csvkit/python-regex.d.ts +5 -0
  195. package/dist/safe-bash-command-csvkit/python-regex.js +14 -0
  196. package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
  197. package/dist/safe-bash-command-csvkit/sync-support.js +4 -2
  198. package/dist/safe-bash-command-diff3/index.js +3 -0
  199. package/dist/safe-bash-command-docx/LICENSE +21 -0
  200. package/dist/safe-bash-command-docx/index.d.ts +30 -0
  201. package/dist/safe-bash-command-docx/index.js +67 -0
  202. package/dist/safe-bash-command-docx/io.d.ts +14 -0
  203. package/dist/safe-bash-command-docx/io.js +26 -0
  204. package/dist/safe-bash-command-envsubst/index.js +34 -3
  205. package/dist/safe-bash-command-exiftool/index.js +3 -0
  206. package/dist/safe-bash-command-ffmpeg/index.js +8073 -7940
  207. package/dist/safe-bash-command-fold/family.js +1 -1
  208. package/dist/safe-bash-command-fold/index.js +1 -1
  209. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  210. package/dist/safe-bash-command-git/wasm.generated.js +1 -1
  211. package/dist/safe-bash-command-htmlq/index.js +5 -0
  212. package/dist/safe-bash-command-imagemagick/index.d.ts +25 -21
  213. package/dist/safe-bash-command-imagemagick/index.js +671 -273
  214. package/dist/safe-bash-command-llm/LICENSE +21 -0
  215. package/dist/safe-bash-command-llm/command.d.ts +5 -0
  216. package/dist/safe-bash-command-llm/command.js +14 -0
  217. package/dist/safe-bash-command-llm/configuration.d.ts +18 -0
  218. package/dist/safe-bash-command-llm/elevenlabs-stream.d.ts +2 -0
  219. package/dist/safe-bash-command-llm/elevenlabs-stream.js +7 -0
  220. package/dist/safe-bash-command-llm/elevenlabs.d.ts +15 -0
  221. package/dist/safe-bash-command-llm/elevenlabs.js +10 -0
  222. package/dist/safe-bash-command-llm/index.d.ts +10 -0
  223. package/dist/safe-bash-command-llm/index.js +46 -0
  224. package/dist/safe-bash-command-llm/mime.d.ts +2 -0
  225. package/dist/safe-bash-command-llm/mime.js +9 -0
  226. package/dist/safe-bash-command-llm/model-options.d.ts +3 -0
  227. package/dist/safe-bash-command-llm/openai-http.d.ts +8 -0
  228. package/dist/safe-bash-command-llm/openai-http.js +17 -0
  229. package/dist/safe-bash-command-llm/openai-sse.d.ts +3 -0
  230. package/dist/safe-bash-command-llm/openai-sse.js +8 -0
  231. package/dist/safe-bash-command-llm/openai.d.ts +14 -0
  232. package/dist/safe-bash-command-llm/openai.js +12 -0
  233. package/dist/safe-bash-command-llm/providers/elevenlabs.d.ts +1 -0
  234. package/dist/safe-bash-command-llm/providers/elevenlabs.js +11 -0
  235. package/dist/safe-bash-command-llm/providers/index.d.ts +3 -0
  236. package/dist/safe-bash-command-llm/providers/index.js +24 -0
  237. package/dist/safe-bash-command-llm/providers/openai.d.ts +1 -0
  238. package/dist/safe-bash-command-llm/providers/openai.js +13 -0
  239. package/dist/safe-bash-command-llm/providers/shared.d.ts +23 -0
  240. package/dist/safe-bash-command-llm/providers/shared.js +13 -0
  241. package/dist/safe-bash-command-llm/schemas.d.ts +2 -0
  242. package/dist/safe-bash-command-llm/service.d.ts +42 -0
  243. package/dist/safe-bash-command-llm/service.js +9 -0
  244. package/dist/safe-bash-command-llm/templates.d.ts +27 -0
  245. package/dist/safe-bash-command-llm/types.d.ts +87 -0
  246. package/dist/safe-bash-command-llm/types.js +6 -0
  247. package/dist/safe-bash-command-mmdc/command.d.ts +4 -0
  248. package/dist/safe-bash-command-mmdc/index.d.ts +1 -1
  249. package/dist/safe-bash-command-mmdc/index.js +7134 -6699
  250. package/dist/safe-bash-command-mmdc/layout.d.ts +1 -0
  251. package/dist/safe-bash-command-mmdc/parser.d.ts +1 -0
  252. package/dist/safe-bash-command-mmdc/png.d.ts +3 -0
  253. package/dist/safe-bash-command-mmdc/raster.d.ts +1 -0
  254. package/dist/safe-bash-command-mmdc/svg.d.ts +1 -0
  255. package/dist/safe-bash-command-op/index.js +19 -14
  256. package/dist/safe-bash-command-pandoc/command.js +3 -3
  257. package/dist/safe-bash-command-pandoc/index.js +3 -3
  258. package/dist/safe-bash-command-pdfimages/index.d.ts +7 -1
  259. package/dist/safe-bash-command-pdfimages/index.js +210 -113
  260. package/dist/safe-bash-command-pdfinfo/index.d.ts +24 -20
  261. package/dist/safe-bash-command-pdfinfo/index.js +517 -241
  262. package/dist/safe-bash-command-pdftk/index.d.ts +7 -3
  263. package/dist/safe-bash-command-pdftk/index.js +261 -125
  264. package/dist/safe-bash-command-pdftoppm/index.d.ts +15 -7
  265. package/dist/safe-bash-command-pdftoppm/index.js +326 -189
  266. package/dist/safe-bash-command-pdftotext/index.d.ts +9 -5
  267. package/dist/safe-bash-command-pdftotext/index.js +237 -107
  268. package/dist/safe-bash-command-pptx/LICENSE +21 -0
  269. package/dist/safe-bash-command-pptx/index.d.ts +33 -0
  270. package/dist/safe-bash-command-pptx/index.js +168 -0
  271. package/dist/safe-bash-command-qpdf/index.d.ts +9 -3
  272. package/dist/safe-bash-command-qpdf/index.js +254 -130
  273. package/dist/safe-bash-command-sha512sum/index.js +12 -475
  274. package/dist/safe-bash-command-sips/index.d.ts +9 -5
  275. package/dist/safe-bash-command-sips/index.js +65 -46
  276. package/dist/safe-bash-command-soffice/index.d.ts +9 -3
  277. package/dist/safe-bash-command-soffice/index.js +66 -25
  278. package/dist/safe-bash-command-sqlite3/engine.d.ts +9 -0
  279. package/dist/safe-bash-command-sqlite3/index.d.ts +1 -0
  280. package/dist/safe-bash-command-sqlite3/index.js +851 -352
  281. package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
  282. package/dist/safe-bash-command-ssconvert/index.js +147 -80
  283. package/dist/safe-bash-command-timeout/index.js +3 -3
  284. package/dist/safe-bash-command-truncate/index.d.ts +8 -3
  285. package/dist/safe-bash-command-truncate/index.js +790 -272
  286. package/dist/safe-bash-command-truncate/sync.d.ts +1 -0
  287. package/dist/safe-bash-command-truncate/sync.js +60 -0
  288. package/dist/safe-bash-command-wkhtmltopdf/index.js +239 -118
  289. package/dist/safe-bash-command-wkhtmltopdf/pdf-renderer.d.ts +1 -1
  290. package/dist/safe-bash-command-xxd/index.js +78 -20
  291. package/dist/safe-bash-command-xz/command.d.ts +4 -0
  292. package/dist/safe-bash-command-xz/index.d.ts +1 -1
  293. package/dist/safe-bash-command-xz/index.js +1 -1
  294. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  295. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  296. package/dist/safe-bash-compression-engine/files.js +6 -6
  297. package/dist/safe-bash-compression-engine/index.js +5 -5
  298. package/dist/safe-bash-compression-engine/operand.js +6 -6
  299. package/dist/safe-bash-compression-engine/stream.js +5 -5
  300. package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
  301. package/dist/safe-bash-contracts/command.js +3 -3
  302. package/dist/safe-bash-contracts/default-executor.d.ts +5 -0
  303. package/dist/safe-bash-contracts/default-executor.js +37 -0
  304. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  305. package/dist/safe-bash-contracts/escaping.js +9 -9
  306. package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
  307. package/dist/safe-bash-contracts/filesystem-output.js +8 -8
  308. package/dist/safe-bash-contracts/http.d.ts +41 -0
  309. package/dist/safe-bash-contracts/http.js +6 -0
  310. package/dist/safe-bash-contracts/index.js +21 -19
  311. package/dist/safe-bash-contracts/io.d.ts +12 -0
  312. package/dist/safe-bash-contracts/io.js +4 -1
  313. package/dist/safe-bash-contracts/output.js +3 -2
  314. package/dist/safe-bash-contracts/runtime-control.js +2 -2
  315. package/dist/safe-bash-contracts/signals.js +1 -1
  316. package/dist/safe-bash-contracts/yield.d.ts +1 -0
  317. package/dist/safe-bash-contracts/yield.js +3 -1
  318. package/dist/safe-bash-csv-engine/index.d.ts +10 -1
  319. package/dist/safe-bash-csv-engine/index.js +78 -6
  320. package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
  321. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
  322. package/dist/safe-bash-io-engine/gnu-information.d.ts +1 -1
  323. package/dist/safe-bash-io-engine/gnu-information.js +1 -1
  324. package/dist/safe-bash-io-engine/internal.d.ts +1 -1
  325. package/dist/safe-bash-io-engine/internal.js +2 -2
  326. package/dist/safe-bash-query-engine/index.js +5 -5
  327. package/dist/safe-bash-query-engine/interpreter.js +3 -3
  328. package/dist/safe-bash-query-engine/query-core.js +5 -5
  329. package/package.json +2 -2
  330. package/dist/safe-bash/chunks/chunk-2G2T5MEM.js +0 -14
  331. package/dist/safe-bash/chunks/chunk-FJZNUUOQ.js +0 -81
  332. package/dist/safe-bash/chunks/chunk-GJWUEOT6.js +0 -14
  333. package/dist/safe-bash/chunks/chunk-LAPF2XE6.js +0 -14
  334. package/dist/safe-bash/chunks/chunk-O6356Z27.js +0 -37
  335. package/dist/safe-bash/chunks/chunk-S2LSZFZ6.js +0 -758
  336. package/dist/safe-bash/chunks/chunk-T3VDYWKZ.js +0 -21
  337. package/dist/safe-bash/chunks/chunk-VYW4Q6KF.js +0 -12
  338. package/dist/safe-bash/chunks/chunk-WHURJBET.js +0 -409
  339. package/dist/safe-bash/opt-in/commands/cmp/compare.js +0 -95
  340. package/dist/safe-bash/opt-in/commands/cmp/io.js +0 -218
  341. package/dist/safe-bash/command-chunks/{chunk-RTOJNFFL.js → chunk-KNI4GRXF.js} +7 -7
  342. package/dist/safe-bash/command-chunks/{chunk-DEH3CMGL.js → chunk-QJ3ONEBI.js} +3 -3
@@ -35098,6 +35098,11 @@ function tokenizeCos(bytes, start = 0, end = bytes.length) {
35098
35098
  }
35099
35099
  return tokens;
35100
35100
  }
35101
+ function drainWork(work) {
35102
+ let step = work.next();
35103
+ while (!step.done) step = work.next();
35104
+ return step.value;
35105
+ }
35101
35106
  function bytesToString3(bytes) {
35102
35107
  if (typeof bytes !== "object" || bytes?.length === void 0) {
35103
35108
  throw new Error("Invalid argument for bytesToString");
@@ -35693,7 +35698,9 @@ function concatByteArrays(chunks) {
35693
35698
  }
35694
35699
  return out;
35695
35700
  }
35696
- function serializeCosDocument(options) {
35701
+ function* serializeCosDocumentSteps(options) {
35702
+ yield;
35703
+ let work = 0;
35697
35704
  const maxOutputBytes = options.maxOutputBytes ?? Infinity;
35698
35705
  const maxObjects = options.maxObjects ?? Infinity;
35699
35706
  const sorted = [...options.objects].sort((a, b) => a.objectNumber - b.objectNumber);
@@ -35716,6 +35723,7 @@ function serializeCosDocument(options) {
35716
35723
  const packable = [];
35717
35724
  const direct = [];
35718
35725
  for (const obj of sorted) {
35726
+ if (++work % 16 === 0) yield;
35719
35727
  const isLinearized = obj.value.kind === "dict" && dictGet(obj.value, "Linearized") !== void 0;
35720
35728
  if (obj.value.kind !== "stream" && obj.generationNumber === 0 && !isLinearized) {
35721
35729
  packable.push(obj);
@@ -35730,6 +35738,7 @@ function serializeCosDocument(options) {
35730
35738
  const headerPairs = [];
35731
35739
  let relOffset = 0;
35732
35740
  for (const pObj of packable) {
35741
+ if (++work % 16 === 0) yield;
35733
35742
  headerPairs.push(`${pObj.objectNumber} ${relOffset}`);
35734
35743
  const bBytes = serializeCosNodeBytes(pObj.value);
35735
35744
  const nl = textEncoder2.encode("\n");
@@ -35755,6 +35764,7 @@ function serializeCosDocument(options) {
35755
35764
  ];
35756
35765
  const directOffsets = /* @__PURE__ */ new Map();
35757
35766
  for (const dObj of allDirect) {
35767
+ if (++work % 16 === 0) yield;
35758
35768
  directOffsets.set(dObj.objectNumber, { offset, generation: dObj.generationNumber });
35759
35769
  const prefix = textEncoder2.encode(`${dObj.objectNumber} ${dObj.generationNumber} obj
35760
35770
  `);
@@ -35765,6 +35775,7 @@ function serializeCosDocument(options) {
35765
35775
  }
35766
35776
  const compressedMap = /* @__PURE__ */ new Map();
35767
35777
  for (let idx = 0; idx < packable.length; idx++) {
35778
+ if (++work % 16 === 0) yield;
35768
35779
  compressedMap.set(packable[idx].objectNumber, idx);
35769
35780
  }
35770
35781
  const xrefOffset2 = offset;
@@ -35782,6 +35793,7 @@ function serializeCosDocument(options) {
35782
35793
  };
35783
35794
  writeEntry7(0, 0, 0, 65535);
35784
35795
  for (let i = 1; i < size2; i++) {
35796
+ if (++work % 16 === 0) yield;
35785
35797
  if (i === xrefStmNum) {
35786
35798
  writeEntry7(i, 1, xrefOffset2, 0);
35787
35799
  } else if (compressedMap.has(i)) {
@@ -35862,6 +35874,7 @@ ${xrefOffset2}
35862
35874
  let pageCount = 0;
35863
35875
  let firstPageObjNum = options.rootRef.objectNumber;
35864
35876
  for (const o of sorted) {
35877
+ if (++work % 16 === 0) yield;
35865
35878
  if (o.value.kind === "dict") {
35866
35879
  const t = dictGet(o.value, "Type");
35867
35880
  if (t?.kind === "name" && t.decoded === "Page") {
@@ -35909,6 +35922,7 @@ ${xrefOffset2}
35909
35922
  }
35910
35923
  const objectOffsets = /* @__PURE__ */ new Map();
35911
35924
  for (const obj of sorted) {
35925
+ if (++work % 16 === 0) yield;
35912
35926
  objectOffsets.set(obj.objectNumber, { offset, generation: obj.generationNumber });
35913
35927
  let value = obj.value;
35914
35928
  if (options.normalizeContent && value.kind === "stream" && value.decodedBytes) {
@@ -35940,6 +35954,7 @@ ${xrefOffset2}
35940
35954
  0000000000 65535 f
35941
35955
  `;
35942
35956
  for (let i = 1; i < size; i++) {
35957
+ if (++work % 16 === 0) yield;
35943
35958
  const entry = objectOffsets.get(i);
35944
35959
  if (entry) {
35945
35960
  xrefText += `${String(entry.offset).padStart(10, "0")} ${String(entry.generation).padStart(5, "0")} n
@@ -35986,6 +36001,7 @@ ${xrefOffset}
35986
36001
  let endFirstPage = xrefOffset;
35987
36002
  const sortedOffsets = [...objectOffsets.entries()].sort((a, b) => a[1].offset - b[1].offset);
35988
36003
  for (let i = 0; i < sortedOffsets.length; i++) {
36004
+ if (++work % 16 === 0) yield;
35989
36005
  const [objNum, info3] = sortedOffsets[i];
35990
36006
  const nextOff = sortedOffsets[i + 1]?.[1].offset ?? xrefOffset;
35991
36007
  if (objNum === hintObjAfter.objectNumber) {
@@ -36019,6 +36035,9 @@ ${xrefOffset}
36019
36035
  }
36020
36036
  return fullBytes;
36021
36037
  }
36038
+ function serializeCosDocument(options) {
36039
+ return drainWork(serializeCosDocumentSteps(options));
36040
+ }
36022
36041
  function appendIncrementalRevision(originalBytes, doc, updatedObjects) {
36023
36042
  const chunks = [originalBytes, textEncoder2.encode("\n")];
36024
36043
  let offset = originalBytes.length + 1;
@@ -36292,48 +36311,30 @@ function encryptPdfBuffer(state, objectNumber, generationNumber, plaintext) {
36292
36311
  const objKey = md5Bytes([state.fileKey, suffix]).subarray(0, Math.min(16, state.fileKey.length + 5));
36293
36312
  return rc4Transform(objKey, plaintext);
36294
36313
  }
36295
- function transformNodeStringsAndStreams(node, transform, transformStream) {
36314
+ function* transformNodeStringsAndStreamsSteps(node, transform, transformStream) {
36315
+ yield;
36296
36316
  switch (node.kind) {
36297
36317
  case "string":
36298
- return {
36299
- kind: "string",
36300
- format: "hex",
36301
- bytes: transform(node.bytes)
36302
- };
36303
- case "array":
36304
- return {
36305
- kind: "array",
36306
- items: node.items.map((item) => transformNodeStringsAndStreams(item, transform, transformStream))
36307
- };
36318
+ return { kind: "string", format: "hex", bytes: transform(node.bytes) };
36319
+ case "array": {
36320
+ const items = [];
36321
+ for (const item of node.items) items.push(yield* transformNodeStringsAndStreamsSteps(item, transform, transformStream));
36322
+ return { kind: "array", items };
36323
+ }
36308
36324
  case "dict": {
36309
- const type = dictGet(node, "Type");
36310
- const fieldType = dictGet(node, "FT");
36311
- const byteRange = dictGet(node, "ByteRange");
36325
+ const type = dictGet(node, "Type"), fieldType = dictGet(node, "FT"), byteRange = dictGet(node, "ByteRange");
36312
36326
  const signature = type?.kind === "name" && type.decoded === "Sig" || fieldType?.kind === "name" && fieldType.decoded === "Sig" || byteRange?.kind === "array" && dictGet(node, "Filter")?.kind === "name";
36313
- return {
36314
- kind: "dict",
36315
- entries: node.entries.map((e) => ({
36316
- key: e.key,
36317
- value: signature && e.key.decoded === "Contents" ? e.value : transformNodeStringsAndStreams(e.value, transform, transformStream)
36318
- }))
36319
- };
36327
+ const entries2 = [];
36328
+ for (const e of node.entries) entries2.push({ key: e.key, value: signature && e.key.decoded === "Contents" ? e.value : yield* transformNodeStringsAndStreamsSteps(e.value, transform, transformStream) });
36329
+ return { kind: "dict", entries: entries2 };
36320
36330
  }
36321
36331
  case "stream": {
36322
36332
  const type = dictGet(node.dict, "Type");
36323
36333
  if (type?.kind === "name" && type.decoded === "XRef") return node;
36324
36334
  const stream = transformStream ? transformStream(node) : { ...node, rawBytes: transform(node.rawBytes) };
36325
- const updatedDict = {
36326
- kind: "dict",
36327
- entries: stream.dict.entries.map((e) => ({
36328
- key: e.key,
36329
- value: e.key.decoded === "Length" ? cosNumber(stream.rawBytes.length) : transformNodeStringsAndStreams(e.value, transform, transformStream)
36330
- }))
36331
- };
36332
- return {
36333
- kind: "stream",
36334
- dict: updatedDict,
36335
- rawBytes: stream.rawBytes
36336
- };
36335
+ const entries2 = [];
36336
+ for (const e of stream.dict.entries) entries2.push({ key: e.key, value: e.key.decoded === "Length" ? cosNumber(stream.rawBytes.length) : yield* transformNodeStringsAndStreamsSteps(e.value, transform, transformStream) });
36337
+ return { kind: "stream", dict: { kind: "dict", entries: entries2 }, rawBytes: stream.rawBytes };
36337
36338
  }
36338
36339
  default:
36339
36340
  return node;
@@ -36402,7 +36403,8 @@ function createR6Encryption(userPassword, ownerPassword, pMask) {
36402
36403
  StrF: cosName("StdCF")
36403
36404
  }) };
36404
36405
  }
36405
- function encryptCosDocument(doc, options = {}) {
36406
+ function* encryptCosDocumentSteps(doc, options = {}) {
36407
+ yield;
36406
36408
  const userPassword = options.userPassword ?? "";
36407
36409
  const ownerPassword = options.ownerPassword ?? userPassword;
36408
36410
  const revision = options.revision ?? 6;
@@ -36424,14 +36426,15 @@ function encryptCosDocument(doc, options = {}) {
36424
36426
  const encryptObjNum = maxObjNum + 1;
36425
36427
  const encryptedObjects = [];
36426
36428
  for (const obj of doc.objects.values()) {
36427
- const transformed = transformNodeStringsAndStreams(
36429
+ yield;
36430
+ const transformed = yield* transformNodeStringsAndStreamsSteps(
36428
36431
  obj.value,
36429
36432
  (plain) => encryptPdfBuffer(state, obj.objectNumber, obj.generationNumber, plain)
36430
36433
  );
36431
36434
  encryptedObjects.push({ objectNumber: obj.objectNumber, generationNumber: obj.generationNumber, value: transformed });
36432
36435
  }
36433
36436
  encryptedObjects.push({ objectNumber: encryptObjNum, generationNumber: 0, value: encryptDict });
36434
- return serializeCosDocument({
36437
+ return yield* serializeCosDocumentSteps({
36435
36438
  objects: encryptedObjects,
36436
36439
  rootRef: doc.rootRef,
36437
36440
  infoRef: doc.infoRef,
@@ -36481,17 +36484,19 @@ function decryptStream(doc, stream, transform) {
36481
36484
  }
36482
36485
  return { kind: "stream", dict, rawBytes: bytes };
36483
36486
  }
36484
- function decryptCosDocument(doc, state) {
36487
+ function* decryptCosDocumentSteps(doc, state) {
36488
+ yield;
36485
36489
  const encryptObjNum = doc.encryptRef?.objectNumber;
36486
36490
  const handler = securityHandlers.get(state);
36487
36491
  for (const [num, obj] of doc.objects.entries()) {
36492
+ yield;
36488
36493
  if (num === encryptObjNum || handler?.plaintextObjects.has(num)) continue;
36489
36494
  if (obj.value.kind === "stream") {
36490
36495
  const type = doc.resolve(dictGet(obj.value.dict, "Type"));
36491
36496
  if (type?.kind === "name" && (type.decoded === "XRef" || type.decoded === "Metadata" && !state.encryptMetadata)) continue;
36492
36497
  }
36493
36498
  const transform = handler?.factory.createCipherTransform(obj.objectNumber, obj.generationNumber);
36494
- const decrypted = transformNodeStringsAndStreams(
36499
+ const decrypted = yield* transformNodeStringsAndStreamsSteps(
36495
36500
  obj.value,
36496
36501
  (cipher) => decryptPdfBuffer(state, obj.objectNumber, obj.generationNumber, cipher),
36497
36502
  transform ? (stream) => decryptStream(doc, stream, transform) : void 0
@@ -36605,9 +36610,12 @@ var ParsedCosDocument = class {
36605
36610
  return void 0;
36606
36611
  }
36607
36612
  };
36608
- function parseNodeFromLexer(lexer, bytes, maxDepth, repair = false) {
36613
+ function* parseNodeFromLexerSteps(lexer, bytes, maxDepth, repair = false) {
36614
+ yield;
36615
+ let work = 0;
36609
36616
  const stack = [];
36610
36617
  while (true) {
36618
+ if (++work % 16 === 0) yield;
36611
36619
  const tok = lexer.nextToken();
36612
36620
  const parent = stack.at(-1);
36613
36621
  if (!tok) {
@@ -36803,7 +36811,8 @@ function parseHeaderVersion(bytes) {
36803
36811
  }
36804
36812
  return head.slice(idx + 5, idx + 8);
36805
36813
  }
36806
- function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
36814
+ function* parseObjectAtOffsetSteps(bytes, offset, maxRecursionDepth, repair = false) {
36815
+ yield;
36807
36816
  const lexer = new CosByteLexer(bytes, offset);
36808
36817
  const objNumTok = lexer.nextToken();
36809
36818
  const genNumTok = lexer.nextToken();
@@ -36811,7 +36820,7 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
36811
36820
  if (objNumTok?.kind !== "number" || genNumTok?.kind !== "number" || objKwTok?.kind !== "keyword" || objKwTok.value !== "obj") {
36812
36821
  throw new PdfError("E_PARSE", `Malformed indirect object header at byte offset ${offset}`);
36813
36822
  }
36814
- const value = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, repair);
36823
+ const value = yield* parseNodeFromLexerSteps(lexer, bytes, maxRecursionDepth, repair);
36815
36824
  if (!value) {
36816
36825
  throw new PdfError("E_PARSE", `Empty indirect object ${objNumTok.value} at offset ${offset}`);
36817
36826
  }
@@ -36822,7 +36831,9 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
36822
36831
  span: { start: objNumTok.span.start, end: lexer.offset }
36823
36832
  };
36824
36833
  }
36825
- function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursionDepth, maxObjects) {
36834
+ function* parseXrefRevisionAtSteps(bytes, xrefOffset, maxDecompressedBytes, maxRecursionDepth, maxObjects) {
36835
+ yield;
36836
+ let work = 0;
36826
36837
  if (xrefOffset < 0 || xrefOffset >= bytes.length) {
36827
36838
  throw new PdfError("E_PARSE", `Invalid xref offset: ${xrefOffset}`);
36828
36839
  }
@@ -36834,6 +36845,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
36834
36845
  if (firstTok.kind === "keyword" && firstTok.value === "xref") {
36835
36846
  const entries22 = /* @__PURE__ */ new Map();
36836
36847
  while (true) {
36848
+ if (++work % 16 === 0) yield;
36837
36849
  const saved = lexer.offset;
36838
36850
  const tok = lexer.nextToken();
36839
36851
  if (!tok) {
@@ -36857,6 +36869,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
36857
36869
  }
36858
36870
  if (count > maxObjects + 1) throw new PdfError("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
36859
36871
  for (let i = 0; i < count; i++) {
36872
+ if (++work % 16 === 0) yield;
36860
36873
  const offTok = lexer.nextToken();
36861
36874
  const genTok = lexer.nextToken();
36862
36875
  const flagTok = lexer.nextToken();
@@ -36882,7 +36895,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
36882
36895
  if (entries22.size > maxObjects + 1) throw new PdfError("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
36883
36896
  }
36884
36897
  }
36885
- const trailerNode = parseNodeFromLexer(lexer, bytes, maxRecursionDepth);
36898
+ const trailerNode = yield* parseNodeFromLexerSteps(lexer, bytes, maxRecursionDepth);
36886
36899
  if (!trailerNode || trailerNode.kind !== "dict") {
36887
36900
  throw new PdfError("E_PARSE", "Missing trailer dictionary after xref table");
36888
36901
  }
@@ -36894,7 +36907,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
36894
36907
  previousXrefOffset: prevNode2?.kind === "number" ? prevNode2.value : void 0
36895
36908
  };
36896
36909
  }
36897
- const xrefObj = parseObjectAtOffset(bytes, xrefOffset, maxRecursionDepth);
36910
+ const xrefObj = yield* parseObjectAtOffsetSteps(bytes, xrefOffset, maxRecursionDepth);
36898
36911
  if (xrefObj.value.kind !== "stream") {
36899
36912
  throw new PdfError("E_PARSE", `Expected xref table or XRef stream at offset ${xrefOffset}`);
36900
36913
  }
@@ -36915,6 +36928,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
36915
36928
  if (indexArray) {
36916
36929
  if (indexArray.kind !== "array" || indexArray.items.length % 2 !== 0) throw new PdfError("E_PARSE", "Invalid XRef range fields");
36917
36930
  for (let i = 0; i < indexArray.items.length; i += 2) {
36931
+ if (++work % 16 === 0) yield;
36918
36932
  const first = indexArray.items[i];
36919
36933
  const count = indexArray.items[i + 1];
36920
36934
  if (first?.kind !== "number" || count?.kind !== "number" || !Number.isSafeInteger(first.value) || first.value < 0 || !Number.isSafeInteger(count.value) || count.value < 0 || !Number.isSafeInteger(first.value + count.value)) {
@@ -36937,9 +36951,11 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
36937
36951
  return v;
36938
36952
  };
36939
36953
  for (const [startObj, count] of subsections) {
36954
+ if (++work % 16 === 0) yield;
36940
36955
  if (count > (decoded.length - pos) / stride) throw new PdfError("E_PARSE", "Truncated XRef stream");
36941
36956
  if (count > maxObjects + 1) throw new PdfError("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
36942
36957
  for (let i = 0; i < count; i++) {
36958
+ if (++work % 16 === 0) yield;
36943
36959
  const objNum = startObj + i;
36944
36960
  const field0 = w0 > 0 ? readInt(w0) : 1;
36945
36961
  const field1 = readInt(w1);
@@ -36985,12 +37001,16 @@ function isAsciiWhitespace(ch3) {
36985
37001
  function isAsciiDigit(ch3) {
36986
37002
  return ch3 >= 48 && ch3 <= 57;
36987
37003
  }
36988
- function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
37004
+ function* repairScanCosDocumentSteps(bytes, maxObjects, maxRecursionDepth) {
37005
+ yield;
37006
+ let work = 0;
36989
37007
  const objects = /* @__PURE__ */ new Map();
36990
37008
  const trailers = [];
36991
37009
  let pos = 0;
36992
37010
  while (pos < bytes.length) {
37011
+ if (++work % 16 === 0) yield;
36993
37012
  while (pos < bytes.length && !isAsciiDigit(bytes[pos])) {
37013
+ if (++work % 16 === 0) yield;
36994
37014
  if (bytes[pos] === 37) {
36995
37015
  while (pos < bytes.length && bytes[pos] !== 10 && bytes[pos] !== 13) pos++;
36996
37016
  continue;
@@ -37000,7 +37020,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
37000
37020
  try {
37001
37021
  const token = lexer.nextToken();
37002
37022
  if (token?.kind === "keyword" && token.value === "trailer") {
37003
- const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, true);
37023
+ const trailer = yield* parseNodeFromLexerSteps(lexer, bytes, maxRecursionDepth, true);
37004
37024
  if (trailer?.kind === "dict") trailers.push(trailer);
37005
37025
  pos = lexer.offset;
37006
37026
  continue;
@@ -37033,7 +37053,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
37033
37053
  bytes[pos + 3] === 40)) {
37034
37054
  pos += 3;
37035
37055
  try {
37036
- const parsed = parseObjectAtOffset(bytes, headerStart, maxRecursionDepth, true);
37056
+ const parsed = yield* parseObjectAtOffsetSteps(bytes, headerStart, maxRecursionDepth, true);
37037
37057
  objects.set(parsed.objectNumber, parsed);
37038
37058
  if (parsed.value.kind === "stream") {
37039
37059
  const type = dictGet(parsed.value.dict, "Type");
@@ -37050,13 +37070,17 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
37050
37070
  }
37051
37071
  return { objects, trailers };
37052
37072
  }
37053
- function unpackRecoveredObjects(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth) {
37073
+ function* unpackRecoveredObjectsSteps(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth) {
37074
+ yield;
37075
+ let work = 0;
37054
37076
  for (const obj of [...objects.values()]) {
37077
+ if (++work % 16 === 0) yield;
37055
37078
  if (obj.value.kind === "stream") {
37056
37079
  const t = dictGet(obj.value.dict, "Type");
37057
37080
  if (t?.kind === "name" && t.decoded === "ObjStm") {
37058
37081
  try {
37059
- for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth, true).entries()) {
37082
+ for (const [unpackedNum, unpackedVal] of (yield* unpackObjectStreamSteps(obj.value, maxDecompressedBytes, maxRecursionDepth, true)).entries()) {
37083
+ if (++work % 16 === 0) yield;
37060
37084
  if (!objects.has(unpackedNum)) {
37061
37085
  objects.set(unpackedNum, {
37062
37086
  objectNumber: unpackedNum,
@@ -37092,7 +37116,9 @@ function recoveredReferences(objects) {
37092
37116
  }
37093
37117
  return { ...rootRef ? { rootRef } : {}, ...infoRef ? { infoRef } : {} };
37094
37118
  }
37095
- function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth, repair = false) {
37119
+ function* unpackObjectStreamSteps(streamObj, maxDecompressedBytes, maxRecursionDepth, repair = false) {
37120
+ yield;
37121
+ let work = 0;
37096
37122
  const nNode = dictGet(streamObj.dict, "N");
37097
37123
  const firstNode = dictGet(streamObj.dict, "First");
37098
37124
  if (nNode?.kind !== "number" || firstNode?.kind !== "number") {
@@ -37102,6 +37128,7 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth,
37102
37128
  const headerLexer = new CosByteLexer(decoded, 0);
37103
37129
  const pairs = [];
37104
37130
  for (let i = 0; i < nNode.value; i++) {
37131
+ if (++work % 16 === 0) yield;
37105
37132
  const numTok = headerLexer.nextToken();
37106
37133
  const offTok = headerLexer.nextToken();
37107
37134
  if (numTok?.kind === "number" && offTok?.kind === "number") {
@@ -37110,9 +37137,10 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth,
37110
37137
  }
37111
37138
  const result = /* @__PURE__ */ new Map();
37112
37139
  for (const pair of pairs) {
37140
+ if (++work % 16 === 0) yield;
37113
37141
  try {
37114
37142
  const valLexer = new CosByteLexer(decoded, firstNode.value + pair.relativeOffset);
37115
- const node = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth, repair);
37143
+ const node = yield* parseNodeFromLexerSteps(valLexer, decoded, maxRecursionDepth, repair);
37116
37144
  if (node) {
37117
37145
  result.set(pair.objectNumber, node);
37118
37146
  }
@@ -37122,7 +37150,9 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth,
37122
37150
  }
37123
37151
  return result;
37124
37152
  }
37125
- function parseCosDocument(bytes, options = {}) {
37153
+ function* parseCosDocumentSteps(bytes, options = {}) {
37154
+ yield;
37155
+ let work = 0;
37126
37156
  const version = parseHeaderVersion(bytes);
37127
37157
  const recovery = options.recovery ?? "strict";
37128
37158
  const maxObjects = options.maxObjects ?? Infinity;
@@ -37157,10 +37187,12 @@ function parseCosDocument(bytes, options = {}) {
37157
37187
  let currentXrefOffset = offsetTok.value;
37158
37188
  const visitedOffsets = /* @__PURE__ */ new Set();
37159
37189
  while (currentXrefOffset !== void 0 && !visitedOffsets.has(currentXrefOffset)) {
37190
+ if (++work % 16 === 0) yield;
37160
37191
  visitedOffsets.add(currentXrefOffset);
37161
- const rev = parseXrefRevisionAt(bytes, currentXrefOffset, maxDecompressedBytes, maxRecursionDepth, maxObjects);
37192
+ const rev = yield* parseXrefRevisionAtSteps(bytes, currentXrefOffset, maxDecompressedBytes, maxRecursionDepth, maxObjects);
37162
37193
  revisions.push(rev);
37163
37194
  for (const [num, entry] of rev.entries.entries()) {
37195
+ if (++work % 16 === 0) yield;
37164
37196
  if (!mergedXref.has(num)) {
37165
37197
  mergedXref.set(num, entry);
37166
37198
  if (mergedXref.size > maxObjects + 1) throw new PdfError("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
@@ -37193,8 +37225,9 @@ function parseCosDocument(bytes, options = {}) {
37193
37225
  if (!useRepair && rootRef) {
37194
37226
  try {
37195
37227
  for (const [objNum, entry] of mergedXref.entries()) {
37228
+ if (++work % 16 === 0) yield;
37196
37229
  if (entry.type !== "uncompressed") continue;
37197
- const parsed = parseObjectAtOffset(bytes, entry.offset ?? 0, maxRecursionDepth, recovery === "repair");
37230
+ const parsed = yield* parseObjectAtOffsetSteps(bytes, entry.offset ?? 0, maxRecursionDepth, recovery === "repair");
37198
37231
  if (parsed.objectNumber !== objNum || parsed.generationNumber !== (entry.generationNumber ?? 0)) {
37199
37232
  throw new PdfError("E_PARSE", `Bad uncompressed XRef entry for object ${objNum}`);
37200
37233
  }
@@ -37212,7 +37245,7 @@ function parseCosDocument(bytes, options = {}) {
37212
37245
  throw new PdfError("E_PARSE", "PDF trailer missing /Root reference");
37213
37246
  }
37214
37247
  useRepair = true;
37215
- const scanned = repairScanCosDocument(bytes, maxObjects, maxRecursionDepth);
37248
+ const scanned = yield* repairScanCosDocumentSteps(bytes, maxObjects, maxRecursionDepth);
37216
37249
  objects = scanned.objects;
37217
37250
  revisions.length = 0;
37218
37251
  mergedXref.clear();
@@ -37247,7 +37280,7 @@ function parseCosDocument(bytes, options = {}) {
37247
37280
  encryptNode = encrypt?.kind === "ref" || encrypt?.kind === "dict" ? encrypt : void 0;
37248
37281
  encryptRef = encrypt?.kind === "ref" ? encrypt : void 0;
37249
37282
  idArray = id?.kind === "array" ? id : void 0;
37250
- if (!rootRef && !encryptNode) unpackRecoveredObjects(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth);
37283
+ if (!rootRef && !encryptNode) yield* unpackRecoveredObjectsSteps(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth);
37251
37284
  const fallback = recoveredReferences(objects);
37252
37285
  rootRef ??= fallback.rootRef;
37253
37286
  infoRef ??= fallback.infoRef;
@@ -37282,20 +37315,21 @@ function parseCosDocument(bytes, options = {}) {
37282
37315
  maxRecursionDepth
37283
37316
  });
37284
37317
  doc.encryption = encState;
37285
- decryptCosDocument(doc, encState);
37318
+ yield* decryptCosDocumentSteps(doc, encState);
37286
37319
  }
37287
37320
  if (useRepair) {
37288
- unpackRecoveredObjects(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth);
37321
+ yield* unpackRecoveredObjectsSteps(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth);
37289
37322
  doc.infoRef ??= recoveredReferences(objects).infoRef;
37290
37323
  }
37291
37324
  const objStmCache = /* @__PURE__ */ new Map();
37292
37325
  for (const [objNum, entry] of mergedXref.entries()) {
37326
+ if (++work % 16 === 0) yield;
37293
37327
  if (entry.type === "compressed" && entry.objectStreamNumber !== void 0) {
37294
37328
  let unpacked = objStmCache.get(entry.objectStreamNumber);
37295
37329
  if (!unpacked) {
37296
37330
  const stmObj = objects.get(entry.objectStreamNumber)?.value;
37297
37331
  if (stmObj?.kind === "stream") {
37298
- unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth, recovery === "repair");
37332
+ unpacked = yield* unpackObjectStreamSteps(stmObj, maxDecompressedBytes, maxRecursionDepth, recovery === "repair");
37299
37333
  objStmCache.set(entry.objectStreamNumber, unpacked);
37300
37334
  }
37301
37335
  }
@@ -37312,6 +37346,9 @@ function parseCosDocument(bytes, options = {}) {
37312
37346
  }
37313
37347
  return doc;
37314
37348
  }
37349
+ function parseCosDocument(bytes, options = {}) {
37350
+ return drainWork(parseCosDocumentSteps(bytes, options));
37351
+ }
37315
37352
  var WIN_ANSI_HIGH_BYTES = {
37316
37353
  128: 8364,
37317
37354
  130: 8218,
@@ -48343,7 +48380,8 @@ function resolveInheritedFieldEntry(doc, dict, key) {
48343
48380
  }
48344
48381
  return void 0;
48345
48382
  }
48346
- function collectFieldDicts(doc, node, prefix = "", out = [], parentFt = "", parentFf = 0, parentQ = 0, parentMaxLen) {
48383
+ function* collectFieldDictsSteps(doc, node, prefix = "", out = [], parentFt = "", parentFf = 0, parentQ = 0, parentMaxLen, yieldState = { work: 0 }) {
48384
+ if (++yieldState.work % 256 === 0) yield;
48347
48385
  const dict = doc.resolveDict(node);
48348
48386
  if (!dict) return out;
48349
48387
  const tNode = doc.resolve(dictGet(dict, "T"));
@@ -48376,7 +48414,8 @@ function collectFieldDicts(doc, node, prefix = "", out = [], parentFt = "", pare
48376
48414
  return out;
48377
48415
  }
48378
48416
  for (const kid of kidsArr.items) {
48379
- collectFieldDicts(doc, kid, fullName, out, currentFt, currentFf, currentQ, currentMaxLen);
48417
+ if (++yieldState.work % 16 === 0) yield;
48418
+ yield* collectFieldDictsSteps(doc, kid, fullName, out, currentFt, currentFf, currentQ, currentMaxLen, yieldState);
48380
48419
  }
48381
48420
  } else if (fullName) {
48382
48421
  out.push({
@@ -48817,6 +48856,9 @@ function escapePdfLiteralString(str) {
48817
48856
  }
48818
48857
  return out;
48819
48858
  }
48859
+ function collectFieldDicts(doc, node, prefix = "", out = [], parentFt = "", parentFf = 0, parentQ = 0, parentMaxLen) {
48860
+ drainWork(collectFieldDictsSteps(doc, node, prefix, out, parentFt, parentFf, parentQ, parentMaxLen));
48861
+ }
48820
48862
  var PdfPage = class {
48821
48863
  cosDoc;
48822
48864
  pageRef;
@@ -51302,14 +51344,18 @@ var PdfDocument = class _PdfDocument {
51302
51344
  });
51303
51345
  return new _PdfDocument(parseCosDocument(rawBytes));
51304
51346
  }
51305
- static load(bytes, options) {
51347
+ static *loadSteps(bytes, options) {
51348
+ yield;
51306
51349
  return new _PdfDocument(
51307
- parseCosDocument(bytes, {
51350
+ yield* parseCosDocumentSteps(bytes, {
51308
51351
  ...options,
51309
51352
  recovery: options?.recovery ?? "repair"
51310
51353
  })
51311
51354
  );
51312
51355
  }
51356
+ static load(bytes, options) {
51357
+ return drainWork(_PdfDocument.loadSteps(bytes, options));
51358
+ }
51313
51359
  rebuildPagesList() {
51314
51360
  const catalog = this.cos.resolveDict(this.cos.rootRef);
51315
51361
  const pagesNode = catalog ? dictGet(catalog, "Pages") : void 0;
@@ -51391,20 +51437,30 @@ var PdfDocument = class _PdfDocument {
51391
51437
  this.pages.splice(index, 1);
51392
51438
  this.syncPageTree();
51393
51439
  }
51394
- copyPagesFrom(sourceDoc, indices) {
51440
+ *copyPagesFromSteps(sourceDoc, indices) {
51441
+ function* cloneItems(items) {
51442
+ const result = [];
51443
+ for (const item of items) result.push(yield* cloneNode(item));
51444
+ return result;
51445
+ }
51446
+ yield;
51447
+ let work = 0;
51395
51448
  const memo = /* @__PURE__ */ new Map();
51396
51449
  const sourcePageObjNums = /* @__PURE__ */ new Set();
51397
51450
  for (let i = 0; i < sourceDoc.getPageCount(); i++) {
51451
+ if (++work % 16 === 0) yield;
51398
51452
  sourcePageObjNums.add(sourceDoc.getPage(i).ref.objectNumber);
51399
51453
  }
51400
51454
  const targetPageRefs = [];
51401
51455
  for (const idx of indices) {
51456
+ if (++work % 16 === 0) yield;
51402
51457
  const srcPage = sourceDoc.getPage(idx);
51403
51458
  const pageRef = this.cos.allocateObject({ kind: "null" });
51404
51459
  targetPageRefs.push(pageRef);
51405
51460
  memo.set(srcPage.ref.objectNumber, pageRef);
51406
51461
  }
51407
- const cloneNode = (node) => {
51462
+ const cloneNode = function* (node) {
51463
+ if (++work % 16 === 0) yield;
51408
51464
  if (node.kind === "ref") {
51409
51465
  const existing = memo.get(node.objectNumber);
51410
51466
  if (existing) return existing;
@@ -51415,12 +51471,12 @@ var PdfDocument = class _PdfDocument {
51415
51471
  if (!target) return cosRef(0);
51416
51472
  const placeholderRef = this.cos.allocateObject({ kind: "null" });
51417
51473
  memo.set(node.objectNumber, placeholderRef);
51418
- const clonedTarget = cloneNode(target);
51474
+ const clonedTarget = yield* cloneNode(target);
51419
51475
  this.cos.setObject(placeholderRef.objectNumber, clonedTarget, 0);
51420
51476
  return placeholderRef;
51421
51477
  }
51422
51478
  if (node.kind === "array") {
51423
- return cosArray(node.items.map(cloneNode));
51479
+ return cosArray(yield* cloneItems(node.items));
51424
51480
  }
51425
51481
  if (node.kind === "dict") {
51426
51482
  const typeEntry = dictGet(node, "Type");
@@ -51430,13 +51486,13 @@ var PdfDocument = class _PdfDocument {
51430
51486
  if (isPageTreeNode && entry.key.decoded === "Parent") continue;
51431
51487
  newEntries.push({
51432
51488
  key: { ...entry.key },
51433
- value: cloneNode(entry.value)
51489
+ value: yield* cloneNode(entry.value)
51434
51490
  });
51435
51491
  }
51436
51492
  return { kind: "dict", entries: newEntries };
51437
51493
  }
51438
51494
  if (node.kind === "stream") {
51439
- const clonedDict = cloneNode(node.dict);
51495
+ const clonedDict = yield* cloneNode(node.dict);
51440
51496
  return {
51441
51497
  kind: "stream",
51442
51498
  dict: clonedDict,
@@ -51445,11 +51501,12 @@ var PdfDocument = class _PdfDocument {
51445
51501
  };
51446
51502
  }
51447
51503
  return node;
51448
- };
51504
+ }.bind(this);
51449
51505
  const copiedPages = [];
51450
51506
  for (const [position, idx] of indices.entries()) {
51507
+ if (++work % 16 === 0) yield;
51451
51508
  const srcPage = sourceDoc.getPage(idx);
51452
- const clonedPageDict = cloneNode(srcPage.pageDict);
51509
+ const clonedPageDict = yield* cloneNode(srcPage.pageDict);
51453
51510
  const size = srcPage.getSize();
51454
51511
  if (!dictGet(clonedPageDict, "MediaBox")) {
51455
51512
  dictSet(
@@ -51459,13 +51516,14 @@ var PdfDocument = class _PdfDocument {
51459
51516
  );
51460
51517
  }
51461
51518
  if (!dictGet(clonedPageDict, "Resources")) {
51462
- dictSet(clonedPageDict, "Resources", cloneNode(srcPage.getResourcesDict()));
51519
+ dictSet(clonedPageDict, "Resources", yield* cloneNode(srcPage.getResourcesDict()));
51463
51520
  }
51464
51521
  if (!dictGet(clonedPageDict, "Rotate") && srcPage.getRotation() !== 0) {
51465
51522
  dictSet(clonedPageDict, "Rotate", cosNumber(srcPage.getRotation()));
51466
51523
  }
51467
51524
  const inheritedBoxKeys = ["CropBox", "BleedBox", "TrimBox", "ArtBox"];
51468
51525
  for (const boxKey of inheritedBoxKeys) {
51526
+ if (++work % 16 === 0) yield;
51469
51527
  if (!dictGet(clonedPageDict, boxKey)) {
51470
51528
  const boxVal = boxKey === "CropBox" ? srcPage.getCropBox() : boxKey === "BleedBox" ? srcPage.getBleedBox() : boxKey === "TrimBox" ? srcPage.getTrimBox() : srcPage.getArtBox();
51471
51529
  if (boxVal[0] !== 0 || boxVal[1] !== 0 || boxVal[2] !== size.width || boxVal[3] !== size.height) {
@@ -51507,8 +51565,9 @@ var PdfDocument = class _PdfDocument {
51507
51565
  };
51508
51566
  const clonedRootFieldRefs = [];
51509
51567
  for (const item of srcFieldsArr.items) {
51568
+ if (++work % 16 === 0) yield;
51510
51569
  if (!hasClonedDescendant(item)) continue;
51511
- const cloned = cloneNode(item);
51570
+ const cloned = yield* cloneNode(item);
51512
51571
  if (cloned.kind === "ref") {
51513
51572
  const clonedDict = this.cos.resolveDict(cloned);
51514
51573
  const kidsArr = clonedDict ? this.cos.resolveArray(dictGet(clonedDict, "Kids")) : void 0;
@@ -51542,6 +51601,7 @@ var PdfDocument = class _PdfDocument {
51542
51601
  dstFields.items.filter((x) => x.kind === "ref").map((x) => x.objectNumber)
51543
51602
  );
51544
51603
  for (const fRef of clonedRootFieldRefs) {
51604
+ if (++work % 16 === 0) yield;
51545
51605
  if (!existingNums.has(fRef.objectNumber)) {
51546
51606
  dstFields.items.push(fRef);
51547
51607
  existingNums.add(fRef.objectNumber);
@@ -51549,11 +51609,11 @@ var PdfDocument = class _PdfDocument {
51549
51609
  }
51550
51610
  const srcDr = dictGet(srcAcroForm, "DR");
51551
51611
  if (srcDr && !dictGet(dstAcroForm, "DR")) {
51552
- dictSet(dstAcroForm, "DR", cloneNode(srcDr));
51612
+ dictSet(dstAcroForm, "DR", yield* cloneNode(srcDr));
51553
51613
  }
51554
51614
  const srcDa = dictGet(srcAcroForm, "DA");
51555
51615
  if (srcDa && !dictGet(dstAcroForm, "DA")) {
51556
- dictSet(dstAcroForm, "DA", cloneNode(srcDa));
51616
+ dictSet(dstAcroForm, "DA", yield* cloneNode(srcDa));
51557
51617
  }
51558
51618
  }
51559
51619
  }
@@ -51562,12 +51622,15 @@ var PdfDocument = class _PdfDocument {
51562
51622
  if (srcOcProps) {
51563
51623
  const dstCatalog = this.cos.resolveDict(this.cos.rootRef);
51564
51624
  if (dstCatalog && !dictGet(dstCatalog, "OCProperties")) {
51565
- dictSet(dstCatalog, "OCProperties", cloneNode(srcOcProps));
51625
+ dictSet(dstCatalog, "OCProperties", yield* cloneNode(srcOcProps));
51566
51626
  }
51567
51627
  }
51568
51628
  this.syncPageTree();
51569
51629
  return copiedPages;
51570
51630
  }
51631
+ copyPagesFrom(sourceDoc, indices) {
51632
+ return drainWork(this.copyPagesFromSteps(sourceDoc, indices));
51633
+ }
51571
51634
  embedStandardFont(fontName) {
51572
51635
  return createStandardFontHandle(fontName);
51573
51636
  }
@@ -51767,14 +51830,15 @@ var PdfDocument = class _PdfDocument {
51767
51830
  });
51768
51831
  return buildSemanticAstFromPages(extractedPages, tablesByPage, displayLists);
51769
51832
  }
51770
- save(options = {}) {
51833
+ *saveSteps(options = {}) {
51834
+ yield;
51771
51835
  this.syncPageTree();
51772
51836
  if (this.cos.requiresFullRewrite) {
51773
51837
  pruneUnusedXObjects(this.cos, this.pages);
51774
51838
  discardUnreachableObjects(this.cos);
51775
51839
  }
51776
51840
  if (options.encrypt) {
51777
- return encryptCosDocument(this.cos, options.encrypt);
51841
+ return yield* encryptCosDocumentSteps(this.cos, options.encrypt);
51778
51842
  }
51779
51843
  const allObjects = [...this.cos.objects.values()].sort(
51780
51844
  (a, b) => a.objectNumber - b.objectNumber
@@ -51782,7 +51846,7 @@ var PdfDocument = class _PdfDocument {
51782
51846
  if (options.incremental && !this.cos.requiresFullRewrite && this.cos.bytes.length > 0) {
51783
51847
  return appendIncrementalRevision(this.cos.bytes, this.cos, allObjects);
51784
51848
  }
51785
- return serializeCosDocument({
51849
+ return yield* serializeCosDocumentSteps({
51786
51850
  objects: allObjects,
51787
51851
  rootRef: this.cos.rootRef,
51788
51852
  infoRef: this.cos.infoRef,
@@ -51793,6 +51857,9 @@ var PdfDocument = class _PdfDocument {
51793
51857
  linearize: options.linearize
51794
51858
  });
51795
51859
  }
51860
+ save(options = {}) {
51861
+ return drainWork(this.saveSteps(options));
51862
+ }
51796
51863
  };
51797
51864
 
51798
51865
  // src/codecs/svg-pdf.ts