@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.
- package/README.md +1 -1
- package/dist/image-ast/index.browser.js +147 -80
- package/dist/image-ast/index.js +147 -80
- package/dist/mp4-ast/mp4.d.ts +2 -0
- package/dist/pdf-ast/cos/parser.d.ts +1 -0
- package/dist/pdf-ast/cos/security.d.ts +2 -0
- package/dist/pdf-ast/cos/writer.d.ts +1 -0
- package/dist/pdf-ast/document.d.ts +3 -0
- package/dist/pdf-ast/edit/forms.d.ts +1 -0
- package/dist/pdf-ast/index.js +171 -82
- package/dist/safe-bash/chunks/{chunk-L5QQLNTO.js → chunk-22PI65AH.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-Q3E6C3DX.js → chunk-2TAGYMPK.js} +49 -34
- package/dist/safe-bash/chunks/{chunk-Z3HX3ZBA.js → chunk-2W4HTMEK.js} +52 -48
- package/dist/safe-bash/chunks/{chunk-FFZXP6ZC.js → chunk-3M7L7XU2.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-XNODZRVD.js → chunk-3QAO6UYS.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-YPETOVQU.js → chunk-3VKFK3NF.js} +2 -2
- package/dist/safe-bash/chunks/chunk-5OST7NOX.js +42 -0
- package/dist/safe-bash/chunks/{chunk-KEBSX2AX.js → chunk-6HLURHVU.js} +2 -2
- package/dist/safe-bash/chunks/chunk-DYEUZE6Z.js +19 -0
- package/dist/safe-bash/chunks/{chunk-T2TGCHKE.js → chunk-FM3WBSZT.js} +2 -2
- package/dist/safe-bash/chunks/chunk-GAYRKQM6.js +22 -0
- package/dist/safe-bash/chunks/{chunk-Q45QCA4J.js → chunk-I3KSESCR.js} +0 -7
- package/dist/safe-bash/chunks/{chunk-OSKDIBQS.js → chunk-JLIMK5TD.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-2AYZCT5X.js → chunk-JQ2FAJJT.js} +27 -23
- package/dist/safe-bash/chunks/{chunk-QA3NVP43.js → chunk-JRE6Z3T7.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-DC5EHLKS.js → chunk-NDIL6T7Y.js} +5 -5
- package/dist/safe-bash/chunks/{chunk-747G42FY.js → chunk-OPR4UAIT.js} +2 -2
- package/dist/safe-bash/chunks/chunk-OSMQCYSP.js +19 -0
- package/dist/safe-bash/chunks/chunk-OYB332PQ.js +17 -0
- package/dist/safe-bash/chunks/{chunk-ZMYVCRAF.js → chunk-QTIH2AFE.js} +77 -69
- package/dist/safe-bash/chunks/{chunk-PYTLIUST.js → chunk-SBESXWT2.js} +43 -44
- package/dist/safe-bash/chunks/{chunk-4FDQJUFW.js → chunk-SDEPGTOF.js} +1 -1
- package/dist/safe-bash/chunks/chunk-UZU5BIJI.js +32 -0
- package/dist/safe-bash/chunks/{chunk-BI6JV62X.js → chunk-VCCMROTL.js} +7 -10
- package/dist/safe-bash/chunks/chunk-W47GHRRF.js +13 -0
- package/dist/safe-bash/chunks/{chunk-NPMQWZUZ.js → chunk-WS7KZIUM.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-3PZYHMGM.js → chunk-YYAERCWS.js} +7 -7
- package/dist/safe-bash/chunks/{chunk-5U7JECDB.js → chunk-ZPGVEUKF.js} +8 -7
- package/dist/safe-bash/chunks/{csvkit-K55OYAQC.js → csvkit-USUJG62I.js} +65 -11
- package/dist/safe-bash/chunks/{ffmpeg-BEFTQ6DZ.js → ffmpeg-KRGG5DLH.js} +21 -10
- package/dist/safe-bash/chunks/{gh-HQWOWLWE.js → gh-UCFDUZCX.js} +16 -8
- package/dist/safe-bash/chunks/{git-UFNPAOYZ.js → git-LPAF6KDG.js} +7 -9
- package/dist/safe-bash/chunks/{imagemagick-53BMHH6D.js → imagemagick-KGREKK4G.js} +38 -7
- package/dist/safe-bash/chunks/{implementation-QUTAAYMT.js → implementation-FXDRYS5A.js} +34 -8
- package/dist/safe-bash/chunks/{pdfimages-4OYI6FLG.js → pdfimages-UADCF4G4.js} +12 -8
- package/dist/safe-bash/chunks/{pdfinfo-I7U6TQPP.js → pdfinfo-O7UWPF4W.js} +38 -13
- package/dist/safe-bash/chunks/{pdftk-SUA6FMHI.js → pdftk-AERXIJTN.js} +13 -8
- package/dist/safe-bash/chunks/{pdftoppm-4C5DGEWX.js → pdftoppm-L466JQKI.js} +17 -10
- package/dist/safe-bash/chunks/{pdftotext-Y4WI225Y.js → pdftotext-SUSI4WXS.js} +19 -9
- package/dist/safe-bash/chunks/{qpdf-IORB4RV5.js → qpdf-YL24KVRH.js} +14 -8
- package/dist/safe-bash/chunks/{sips-WHAMJFEU.js → sips-QXEQZERX.js} +14 -7
- package/dist/safe-bash/chunks/{soffice-SYEK6WJS.js → soffice-TBITRML3.js} +16 -8
- package/dist/safe-bash/chunks/{wkhtmltopdf-ZIICWJLF.js → wkhtmltopdf-NJA2THRC.js} +27 -7
- package/dist/safe-bash/command-chunks/chunk-2C5BEBPY.js +1388 -0
- package/dist/safe-bash/command-chunks/{chunk-FXYWQ6S4.js → chunk-2EXV2ZLV.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-PFBJR2PY.js → chunk-2KRKKW5S.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4DSJDVBM.js → chunk-32F3RBUW.js} +10 -749
- package/dist/safe-bash/command-chunks/{chunk-L3MLMXL4.js → chunk-3ZK5F23O.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4QX6XCDD.js → chunk-4RNIZ3RT.js} +79 -0
- package/dist/safe-bash/command-chunks/{chunk-D7TADAYG.js → chunk-64LG3EVJ.js} +17 -0
- package/dist/safe-bash/command-chunks/{chunk-TOSM3T3A.js → chunk-6EASC5EC.js} +20 -9
- package/dist/safe-bash/command-chunks/{chunk-ZF3ZVGQC.js → chunk-7JRITHKW.js} +150 -80
- package/dist/safe-bash/command-chunks/{chunk-IJ3FXP4Q.js → chunk-A3ZX6SCY.js} +1 -1
- package/dist/safe-bash/{chunks/chunk-LD76P7AG.js → command-chunks/chunk-AKDMCNX4.js} +74 -39
- package/dist/safe-bash/command-chunks/{chunk-KSIGF4AG.js → chunk-BK4CMEE6.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-JUDOV5MJ.js → chunk-CBDVLMJB.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XGMWWUHV.js → chunk-CZ5DAK4K.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Z57TV6TC.js → chunk-EZ2DTOLI.js} +4 -2
- package/dist/safe-bash/command-chunks/{chunk-ADCGH6A7.js → chunk-FH3D75FC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-WYJTWJZ5.js → chunk-G3G6W5ZE.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3HDIDEUJ.js → chunk-GF54KE2M.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-H4LWTITX.js +169 -0
- package/dist/safe-bash/command-chunks/chunk-I2MQNBGR.js +145 -0
- package/dist/safe-bash/command-chunks/{chunk-Z7TYZG3A.js → chunk-IHHTTQX6.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-5GRLAARV.js → chunk-IOXI5ZAJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-INDIFLBW.js → chunk-JTAGNROA.js} +4 -0
- package/dist/safe-bash/command-chunks/{chunk-Y5IHIAY3.js → chunk-MDPIOQUD.js} +12 -8
- package/dist/safe-bash/command-chunks/chunk-PGEYORBZ.js +25 -0
- package/dist/safe-bash/command-chunks/chunk-QI4MGIN6.js +6 -0
- package/dist/safe-bash/command-chunks/chunk-QM4UZF3C.js +753 -0
- package/dist/safe-bash/command-chunks/chunk-QTYZAWSB.js +91 -0
- package/dist/safe-bash/command-chunks/chunk-SNK7K3XW.js +90 -0
- package/dist/safe-bash/command-chunks/chunk-T5OLGM43.js +314 -0
- package/dist/safe-bash/command-chunks/chunk-TB7IFMUZ.js +802 -0
- package/dist/safe-bash/command-chunks/{chunk-YNT4ZJHW.js → chunk-TPPBPIWL.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-VMK4XVKO.js +82 -0
- package/dist/safe-bash/command-chunks/chunk-VNSJKXDU.js +130 -0
- package/dist/safe-bash/command-chunks/{chunk-2LP3VMPA.js → chunk-WFDW4XXD.js} +1 -17
- package/dist/safe-bash/command-chunks/chunk-WR37IS4O.js +318 -0
- package/dist/safe-bash/command-chunks/chunk-YFNTMH6Z.js +6 -0
- package/dist/safe-bash/commands/basic.js +148 -48
- package/dist/safe-bash/commands/bytes/compression/index.js +5 -6
- package/dist/safe-bash/commands/cmp.d.ts +2 -3
- package/dist/safe-bash/commands/cmp.js +2 -689
- package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
- package/dist/safe-bash/commands/docx/index.browser.js +4 -47
- package/dist/safe-bash/commands/docx/index.d.ts +2 -24
- package/dist/safe-bash/commands/docx/index.js +2 -41
- package/dist/safe-bash/commands/docx/io.d.ts +1 -14
- package/dist/safe-bash/commands/docx/io.js +1 -15
- package/dist/safe-bash/commands/factor/index.browser.js +2 -2
- package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
- package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
- package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
- package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
- package/dist/safe-bash/commands/llm/command.d.ts +1 -4
- package/dist/safe-bash/commands/llm/command.js +1 -248
- package/dist/safe-bash/commands/llm/elevenlabs-stream.d.ts +1 -2
- package/dist/safe-bash/commands/llm/elevenlabs-stream.js +1 -117
- package/dist/safe-bash/commands/llm/elevenlabs.d.ts +1 -15
- package/dist/safe-bash/commands/llm/elevenlabs.js +1 -123
- package/dist/safe-bash/commands/llm/index.browser.js +20 -15
- package/dist/safe-bash/commands/llm/index.d.ts +1 -6
- package/dist/safe-bash/commands/llm/index.js +1 -4
- package/dist/safe-bash/commands/llm/mime.d.ts +1 -2
- package/dist/safe-bash/commands/llm/mime.js +1 -136
- package/dist/safe-bash/commands/llm/openai-http.d.ts +1 -8
- package/dist/safe-bash/commands/llm/openai-http.js +1 -143
- package/dist/safe-bash/commands/llm/openai-sse.d.ts +1 -3
- package/dist/safe-bash/commands/llm/openai-sse.js +1 -78
- package/dist/safe-bash/commands/llm/openai.d.ts +1 -14
- package/dist/safe-bash/commands/llm/openai.js +1 -288
- package/dist/safe-bash/commands/llm/providers/elevenlabs.d.ts +1 -1
- package/dist/safe-bash/commands/llm/providers/elevenlabs.js +1 -1
- package/dist/safe-bash/commands/llm/providers/index.browser.js +6 -6
- package/dist/safe-bash/commands/llm/providers/index.d.ts +1 -3
- package/dist/safe-bash/commands/llm/providers/index.js +1 -2
- package/dist/safe-bash/commands/llm/providers/openai.d.ts +1 -1
- package/dist/safe-bash/commands/llm/providers/openai.js +1 -1
- package/dist/safe-bash/commands/llm/providers/shared.d.ts +1 -23
- package/dist/safe-bash/commands/llm/providers/shared.js +1 -65
- package/dist/safe-bash/commands/llm/service.d.ts +1 -37
- package/dist/safe-bash/commands/llm/service.js +1 -151
- package/dist/safe-bash/commands/llm/types.d.ts +1 -52
- package/dist/safe-bash/commands/llm/types.js +1 -1
- package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
- package/dist/safe-bash/commands/media/index.browser.js +1 -1
- package/dist/safe-bash/commands/network/index.browser.js +9 -9
- package/dist/safe-bash/commands/network/types.d.ts +2 -40
- package/dist/safe-bash/commands/node/index.browser.js +6 -8
- package/dist/safe-bash/commands/op/index.browser.js +3 -3
- package/dist/safe-bash/commands/op/index.js +12 -28
- package/dist/safe-bash/commands/pptx/index.d.ts +2 -28
- package/dist/safe-bash/commands/pptx/index.js +2 -152
- package/dist/safe-bash/commands/pr/index.browser.js +2 -2
- package/dist/safe-bash/commands/printf-float.d.ts +1 -0
- package/dist/safe-bash/commands/printf-float.js +48 -38
- package/dist/safe-bash/commands/printf-format.js +9 -6
- package/dist/safe-bash/commands/printf-quote.d.ts +3 -0
- package/dist/safe-bash/commands/printf-quote.js +62 -0
- package/dist/safe-bash/commands/printf-wide.d.ts +5 -0
- package/dist/safe-bash/commands/printf-wide.js +41 -0
- package/dist/safe-bash/commands/python/index.browser.js +8 -8
- package/dist/safe-bash/commands/python/worker.browser.js +2 -2
- package/dist/safe-bash/commands/truncate.d.ts +2 -3
- package/dist/safe-bash/commands/truncate.js +2 -686
- package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
- package/dist/safe-bash/commands/xml/index.browser.js +2 -2
- package/dist/safe-bash/commands/yq/index.browser.js +3 -3
- package/dist/safe-bash/contracts/diagnostics.d.ts +2 -0
- package/dist/safe-bash/contracts/diagnostics.js +2 -0
- package/dist/safe-bash/contracts/runtime-control.d.ts +2 -0
- package/dist/safe-bash/contracts/runtime-control.js +2 -0
- package/dist/safe-bash/core.browser.d.ts +1 -1
- package/dist/safe-bash/core.browser.js +10645 -14065
- package/dist/safe-bash/core.d.ts +10 -1
- package/dist/safe-bash/core.js +0 -1
- package/dist/safe-bash/jobs.browser.js +5 -4
- package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -2
- package/dist/safe-bash/opt-in/commands/cmp/index.js +776 -79
- package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +0 -12
- package/dist/safe-bash/opt-in/commands/cmp/options.js +0 -153
- package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +8 -3
- package/dist/safe-bash/opt-in/commands/truncate/index.js +790 -272
- package/dist/safe-bash/opt-in/commands/truncate/sync.d.ts +1 -0
- package/dist/safe-bash/opt-in/commands/truncate/sync.js +60 -0
- package/dist/safe-bash/optional-host.browser.js +61 -80
- package/dist/safe-bash/optional-host.d.ts +3 -1
- package/dist/safe-bash/optional-host.js +3 -1
- package/dist/safe-bash/shell/runtime.js +44 -18
- package/dist/safe-bash/yq-browser/index.js +1 -1
- package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
- package/dist/safe-bash-checksum-engine/index.js +14 -2
- package/dist/safe-bash-command-bzip2/index.js +2 -1
- package/dist/safe-bash-command-cmp/index.d.ts +10 -0
- package/dist/safe-bash-command-cmp/index.js +796 -0
- package/dist/safe-bash-command-cmp/options.d.ts +12 -0
- package/dist/safe-bash-command-cmp/options.js +42 -0
- package/dist/safe-bash-command-csvcut/index.js +11 -8
- package/dist/safe-bash-command-csvgrep/index.js +35 -7
- package/dist/safe-bash-command-csvkit/codecs/python.js +4 -3
- package/dist/safe-bash-command-csvkit/codecs/utf8.js +3 -2
- package/dist/safe-bash-command-csvkit/index.js +80 -324
- package/dist/safe-bash-command-csvkit/python-regex.d.ts +5 -0
- package/dist/safe-bash-command-csvkit/python-regex.js +14 -0
- package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
- package/dist/safe-bash-command-csvkit/sync-support.js +4 -2
- package/dist/safe-bash-command-diff3/index.js +3 -0
- package/dist/safe-bash-command-docx/LICENSE +21 -0
- package/dist/safe-bash-command-docx/index.d.ts +30 -0
- package/dist/safe-bash-command-docx/index.js +67 -0
- package/dist/safe-bash-command-docx/io.d.ts +14 -0
- package/dist/safe-bash-command-docx/io.js +26 -0
- package/dist/safe-bash-command-envsubst/index.js +34 -3
- package/dist/safe-bash-command-exiftool/index.js +3 -0
- package/dist/safe-bash-command-ffmpeg/index.js +8073 -7940
- package/dist/safe-bash-command-fold/family.js +1 -1
- package/dist/safe-bash-command-fold/index.js +1 -1
- package/dist/safe-bash-command-git/git_rust.wasm +0 -0
- package/dist/safe-bash-command-git/wasm.generated.js +1 -1
- package/dist/safe-bash-command-htmlq/index.js +5 -0
- package/dist/safe-bash-command-imagemagick/index.d.ts +25 -21
- package/dist/safe-bash-command-imagemagick/index.js +671 -273
- package/dist/safe-bash-command-llm/LICENSE +21 -0
- package/dist/safe-bash-command-llm/command.d.ts +5 -0
- package/dist/safe-bash-command-llm/command.js +14 -0
- package/dist/safe-bash-command-llm/configuration.d.ts +18 -0
- package/dist/safe-bash-command-llm/elevenlabs-stream.d.ts +2 -0
- package/dist/safe-bash-command-llm/elevenlabs-stream.js +7 -0
- package/dist/safe-bash-command-llm/elevenlabs.d.ts +15 -0
- package/dist/safe-bash-command-llm/elevenlabs.js +10 -0
- package/dist/safe-bash-command-llm/index.d.ts +10 -0
- package/dist/safe-bash-command-llm/index.js +46 -0
- package/dist/safe-bash-command-llm/mime.d.ts +2 -0
- package/dist/safe-bash-command-llm/mime.js +9 -0
- package/dist/safe-bash-command-llm/model-options.d.ts +3 -0
- package/dist/safe-bash-command-llm/openai-http.d.ts +8 -0
- package/dist/safe-bash-command-llm/openai-http.js +17 -0
- package/dist/safe-bash-command-llm/openai-sse.d.ts +3 -0
- package/dist/safe-bash-command-llm/openai-sse.js +8 -0
- package/dist/safe-bash-command-llm/openai.d.ts +14 -0
- package/dist/safe-bash-command-llm/openai.js +12 -0
- package/dist/safe-bash-command-llm/providers/elevenlabs.d.ts +1 -0
- package/dist/safe-bash-command-llm/providers/elevenlabs.js +11 -0
- package/dist/safe-bash-command-llm/providers/index.d.ts +3 -0
- package/dist/safe-bash-command-llm/providers/index.js +24 -0
- package/dist/safe-bash-command-llm/providers/openai.d.ts +1 -0
- package/dist/safe-bash-command-llm/providers/openai.js +13 -0
- package/dist/safe-bash-command-llm/providers/shared.d.ts +23 -0
- package/dist/safe-bash-command-llm/providers/shared.js +13 -0
- package/dist/safe-bash-command-llm/schemas.d.ts +2 -0
- package/dist/safe-bash-command-llm/service.d.ts +42 -0
- package/dist/safe-bash-command-llm/service.js +9 -0
- package/dist/safe-bash-command-llm/templates.d.ts +27 -0
- package/dist/safe-bash-command-llm/types.d.ts +87 -0
- package/dist/safe-bash-command-llm/types.js +6 -0
- package/dist/safe-bash-command-mmdc/command.d.ts +4 -0
- package/dist/safe-bash-command-mmdc/index.d.ts +1 -1
- package/dist/safe-bash-command-mmdc/index.js +7134 -6699
- package/dist/safe-bash-command-mmdc/layout.d.ts +1 -0
- package/dist/safe-bash-command-mmdc/parser.d.ts +1 -0
- package/dist/safe-bash-command-mmdc/png.d.ts +3 -0
- package/dist/safe-bash-command-mmdc/raster.d.ts +1 -0
- package/dist/safe-bash-command-mmdc/svg.d.ts +1 -0
- package/dist/safe-bash-command-op/index.js +19 -14
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/index.js +3 -3
- package/dist/safe-bash-command-pdfimages/index.d.ts +7 -1
- package/dist/safe-bash-command-pdfimages/index.js +210 -113
- package/dist/safe-bash-command-pdfinfo/index.d.ts +24 -20
- package/dist/safe-bash-command-pdfinfo/index.js +517 -241
- package/dist/safe-bash-command-pdftk/index.d.ts +7 -3
- package/dist/safe-bash-command-pdftk/index.js +261 -125
- package/dist/safe-bash-command-pdftoppm/index.d.ts +15 -7
- package/dist/safe-bash-command-pdftoppm/index.js +326 -189
- package/dist/safe-bash-command-pdftotext/index.d.ts +9 -5
- package/dist/safe-bash-command-pdftotext/index.js +237 -107
- package/dist/safe-bash-command-pptx/LICENSE +21 -0
- package/dist/safe-bash-command-pptx/index.d.ts +33 -0
- package/dist/safe-bash-command-pptx/index.js +168 -0
- package/dist/safe-bash-command-qpdf/index.d.ts +9 -3
- package/dist/safe-bash-command-qpdf/index.js +254 -130
- package/dist/safe-bash-command-sha512sum/index.js +12 -475
- package/dist/safe-bash-command-sips/index.d.ts +9 -5
- package/dist/safe-bash-command-sips/index.js +65 -46
- package/dist/safe-bash-command-soffice/index.d.ts +9 -3
- package/dist/safe-bash-command-soffice/index.js +66 -25
- package/dist/safe-bash-command-sqlite3/engine.d.ts +9 -0
- package/dist/safe-bash-command-sqlite3/index.d.ts +1 -0
- package/dist/safe-bash-command-sqlite3/index.js +851 -352
- package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
- package/dist/safe-bash-command-ssconvert/index.js +147 -80
- package/dist/safe-bash-command-timeout/index.js +3 -3
- package/dist/safe-bash-command-truncate/index.d.ts +8 -3
- package/dist/safe-bash-command-truncate/index.js +790 -272
- package/dist/safe-bash-command-truncate/sync.d.ts +1 -0
- package/dist/safe-bash-command-truncate/sync.js +60 -0
- package/dist/safe-bash-command-wkhtmltopdf/index.js +239 -118
- package/dist/safe-bash-command-wkhtmltopdf/pdf-renderer.d.ts +1 -1
- package/dist/safe-bash-command-xxd/index.js +78 -20
- package/dist/safe-bash-command-xz/command.d.ts +4 -0
- package/dist/safe-bash-command-xz/index.d.ts +1 -1
- package/dist/safe-bash-command-xz/index.js +1 -1
- package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
- package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
- package/dist/safe-bash-compression-engine/files.js +6 -6
- package/dist/safe-bash-compression-engine/index.js +5 -5
- package/dist/safe-bash-compression-engine/operand.js +6 -6
- package/dist/safe-bash-compression-engine/stream.js +5 -5
- package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
- package/dist/safe-bash-contracts/command.js +3 -3
- package/dist/safe-bash-contracts/default-executor.d.ts +5 -0
- package/dist/safe-bash-contracts/default-executor.js +37 -0
- package/dist/safe-bash-contracts/diagnostics.js +3 -3
- package/dist/safe-bash-contracts/escaping.js +9 -9
- package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
- package/dist/safe-bash-contracts/filesystem-output.js +8 -8
- package/dist/safe-bash-contracts/http.d.ts +41 -0
- package/dist/safe-bash-contracts/http.js +6 -0
- package/dist/safe-bash-contracts/index.js +21 -19
- package/dist/safe-bash-contracts/io.d.ts +12 -0
- package/dist/safe-bash-contracts/io.js +4 -1
- package/dist/safe-bash-contracts/output.js +3 -2
- package/dist/safe-bash-contracts/runtime-control.js +2 -2
- package/dist/safe-bash-contracts/signals.js +1 -1
- package/dist/safe-bash-contracts/yield.d.ts +1 -0
- package/dist/safe-bash-contracts/yield.js +3 -1
- package/dist/safe-bash-csv-engine/index.d.ts +10 -1
- package/dist/safe-bash-csv-engine/index.js +78 -6
- package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
- package/dist/safe-bash-io-engine/gnu-information.d.ts +1 -1
- package/dist/safe-bash-io-engine/gnu-information.js +1 -1
- package/dist/safe-bash-io-engine/internal.d.ts +1 -1
- package/dist/safe-bash-io-engine/internal.js +2 -2
- package/dist/safe-bash-query-engine/index.js +5 -5
- package/dist/safe-bash-query-engine/interpreter.js +3 -3
- package/dist/safe-bash-query-engine/query-core.js +5 -5
- package/package.json +2 -2
- package/dist/safe-bash/chunks/chunk-2G2T5MEM.js +0 -14
- package/dist/safe-bash/chunks/chunk-FJZNUUOQ.js +0 -81
- package/dist/safe-bash/chunks/chunk-GJWUEOT6.js +0 -14
- package/dist/safe-bash/chunks/chunk-LAPF2XE6.js +0 -14
- package/dist/safe-bash/chunks/chunk-O6356Z27.js +0 -37
- package/dist/safe-bash/chunks/chunk-S2LSZFZ6.js +0 -758
- package/dist/safe-bash/chunks/chunk-T3VDYWKZ.js +0 -21
- package/dist/safe-bash/chunks/chunk-VYW4Q6KF.js +0 -12
- package/dist/safe-bash/chunks/chunk-WHURJBET.js +0 -409
- package/dist/safe-bash/opt-in/commands/cmp/compare.js +0 -95
- package/dist/safe-bash/opt-in/commands/cmp/io.js +0 -218
- package/dist/safe-bash/command-chunks/{chunk-RTOJNFFL.js → chunk-KNI4GRXF.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-DEH3CMGL.js → chunk-QJ3ONEBI.js} +3 -3
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// packages/safe-bash-command-pdfimages/dist/index.js
|
|
6
6
|
init_buffer();
|
|
7
|
+
import { yieldTurn, drainCooperativeSteps as drainSteps } from "../safe-bash-contracts/yield.js";
|
|
8
|
+
import { InputByteBudget } from "../safe-bash-contracts/io.js";
|
|
7
9
|
import { writeFileOutput } from "../safe-bash-contracts/filesystem-output-budget.js";
|
|
8
10
|
import {
|
|
9
11
|
commandRuntimeIdentity,
|
|
@@ -27100,6 +27102,11 @@ function tokenizeCos(bytes, start = 0, end = bytes.length) {
|
|
|
27100
27102
|
}
|
|
27101
27103
|
return tokens;
|
|
27102
27104
|
}
|
|
27105
|
+
function drainWork(work) {
|
|
27106
|
+
let step = work.next();
|
|
27107
|
+
while (!step.done) step = work.next();
|
|
27108
|
+
return step.value;
|
|
27109
|
+
}
|
|
27103
27110
|
function bytesToString3(bytes) {
|
|
27104
27111
|
if (typeof bytes !== "object" || bytes?.length === void 0) {
|
|
27105
27112
|
throw new Error("Invalid argument for bytesToString");
|
|
@@ -27695,7 +27702,9 @@ function concatByteArrays(chunks) {
|
|
|
27695
27702
|
}
|
|
27696
27703
|
return out;
|
|
27697
27704
|
}
|
|
27698
|
-
function
|
|
27705
|
+
function* serializeCosDocumentSteps(options) {
|
|
27706
|
+
yield;
|
|
27707
|
+
let work = 0;
|
|
27699
27708
|
const maxOutputBytes = options.maxOutputBytes ?? Infinity;
|
|
27700
27709
|
const maxObjects = options.maxObjects ?? Infinity;
|
|
27701
27710
|
const sorted = [...options.objects].sort((a, b) => a.objectNumber - b.objectNumber);
|
|
@@ -27718,6 +27727,7 @@ function serializeCosDocument(options) {
|
|
|
27718
27727
|
const packable = [];
|
|
27719
27728
|
const direct = [];
|
|
27720
27729
|
for (const obj of sorted) {
|
|
27730
|
+
if (++work % 16 === 0) yield;
|
|
27721
27731
|
const isLinearized = obj.value.kind === "dict" && dictGet(obj.value, "Linearized") !== void 0;
|
|
27722
27732
|
if (obj.value.kind !== "stream" && obj.generationNumber === 0 && !isLinearized) {
|
|
27723
27733
|
packable.push(obj);
|
|
@@ -27732,6 +27742,7 @@ function serializeCosDocument(options) {
|
|
|
27732
27742
|
const headerPairs = [];
|
|
27733
27743
|
let relOffset = 0;
|
|
27734
27744
|
for (const pObj of packable) {
|
|
27745
|
+
if (++work % 16 === 0) yield;
|
|
27735
27746
|
headerPairs.push(`${pObj.objectNumber} ${relOffset}`);
|
|
27736
27747
|
const bBytes = serializeCosNodeBytes(pObj.value);
|
|
27737
27748
|
const nl = textEncoder2.encode("\n");
|
|
@@ -27757,6 +27768,7 @@ function serializeCosDocument(options) {
|
|
|
27757
27768
|
];
|
|
27758
27769
|
const directOffsets = /* @__PURE__ */ new Map();
|
|
27759
27770
|
for (const dObj of allDirect) {
|
|
27771
|
+
if (++work % 16 === 0) yield;
|
|
27760
27772
|
directOffsets.set(dObj.objectNumber, { offset, generation: dObj.generationNumber });
|
|
27761
27773
|
const prefix = textEncoder2.encode(`${dObj.objectNumber} ${dObj.generationNumber} obj
|
|
27762
27774
|
`);
|
|
@@ -27767,6 +27779,7 @@ function serializeCosDocument(options) {
|
|
|
27767
27779
|
}
|
|
27768
27780
|
const compressedMap = /* @__PURE__ */ new Map();
|
|
27769
27781
|
for (let idx = 0; idx < packable.length; idx++) {
|
|
27782
|
+
if (++work % 16 === 0) yield;
|
|
27770
27783
|
compressedMap.set(packable[idx].objectNumber, idx);
|
|
27771
27784
|
}
|
|
27772
27785
|
const xrefOffset2 = offset;
|
|
@@ -27784,6 +27797,7 @@ function serializeCosDocument(options) {
|
|
|
27784
27797
|
};
|
|
27785
27798
|
writeEntry7(0, 0, 0, 65535);
|
|
27786
27799
|
for (let i = 1; i < size2; i++) {
|
|
27800
|
+
if (++work % 16 === 0) yield;
|
|
27787
27801
|
if (i === xrefStmNum) {
|
|
27788
27802
|
writeEntry7(i, 1, xrefOffset2, 0);
|
|
27789
27803
|
} else if (compressedMap.has(i)) {
|
|
@@ -27864,6 +27878,7 @@ ${xrefOffset2}
|
|
|
27864
27878
|
let pageCount = 0;
|
|
27865
27879
|
let firstPageObjNum = options.rootRef.objectNumber;
|
|
27866
27880
|
for (const o of sorted) {
|
|
27881
|
+
if (++work % 16 === 0) yield;
|
|
27867
27882
|
if (o.value.kind === "dict") {
|
|
27868
27883
|
const t = dictGet(o.value, "Type");
|
|
27869
27884
|
if (t?.kind === "name" && t.decoded === "Page") {
|
|
@@ -27911,6 +27926,7 @@ ${xrefOffset2}
|
|
|
27911
27926
|
}
|
|
27912
27927
|
const objectOffsets = /* @__PURE__ */ new Map();
|
|
27913
27928
|
for (const obj of sorted) {
|
|
27929
|
+
if (++work % 16 === 0) yield;
|
|
27914
27930
|
objectOffsets.set(obj.objectNumber, { offset, generation: obj.generationNumber });
|
|
27915
27931
|
let value = obj.value;
|
|
27916
27932
|
if (options.normalizeContent && value.kind === "stream" && value.decodedBytes) {
|
|
@@ -27942,6 +27958,7 @@ ${xrefOffset2}
|
|
|
27942
27958
|
0000000000 65535 f
|
|
27943
27959
|
`;
|
|
27944
27960
|
for (let i = 1; i < size; i++) {
|
|
27961
|
+
if (++work % 16 === 0) yield;
|
|
27945
27962
|
const entry = objectOffsets.get(i);
|
|
27946
27963
|
if (entry) {
|
|
27947
27964
|
xrefText += `${String(entry.offset).padStart(10, "0")} ${String(entry.generation).padStart(5, "0")} n
|
|
@@ -27988,6 +28005,7 @@ ${xrefOffset}
|
|
|
27988
28005
|
let endFirstPage = xrefOffset;
|
|
27989
28006
|
const sortedOffsets = [...objectOffsets.entries()].sort((a, b) => a[1].offset - b[1].offset);
|
|
27990
28007
|
for (let i = 0; i < sortedOffsets.length; i++) {
|
|
28008
|
+
if (++work % 16 === 0) yield;
|
|
27991
28009
|
const [objNum, info3] = sortedOffsets[i];
|
|
27992
28010
|
const nextOff = sortedOffsets[i + 1]?.[1].offset ?? xrefOffset;
|
|
27993
28011
|
if (objNum === hintObjAfter.objectNumber) {
|
|
@@ -28021,6 +28039,9 @@ ${xrefOffset}
|
|
|
28021
28039
|
}
|
|
28022
28040
|
return fullBytes;
|
|
28023
28041
|
}
|
|
28042
|
+
function serializeCosDocument(options) {
|
|
28043
|
+
return drainWork(serializeCosDocumentSteps(options));
|
|
28044
|
+
}
|
|
28024
28045
|
function appendIncrementalRevision(originalBytes, doc, updatedObjects) {
|
|
28025
28046
|
const chunks = [originalBytes, textEncoder2.encode("\n")];
|
|
28026
28047
|
let offset = originalBytes.length + 1;
|
|
@@ -28294,48 +28315,30 @@ function encryptPdfBuffer(state, objectNumber, generationNumber, plaintext) {
|
|
|
28294
28315
|
const objKey = md5Bytes([state.fileKey, suffix]).subarray(0, Math.min(16, state.fileKey.length + 5));
|
|
28295
28316
|
return rc4Transform(objKey, plaintext);
|
|
28296
28317
|
}
|
|
28297
|
-
function
|
|
28318
|
+
function* transformNodeStringsAndStreamsSteps(node, transform, transformStream) {
|
|
28319
|
+
yield;
|
|
28298
28320
|
switch (node.kind) {
|
|
28299
28321
|
case "string":
|
|
28300
|
-
return {
|
|
28301
|
-
|
|
28302
|
-
|
|
28303
|
-
|
|
28304
|
-
};
|
|
28305
|
-
|
|
28306
|
-
return {
|
|
28307
|
-
kind: "array",
|
|
28308
|
-
items: node.items.map((item) => transformNodeStringsAndStreams(item, transform, transformStream))
|
|
28309
|
-
};
|
|
28322
|
+
return { kind: "string", format: "hex", bytes: transform(node.bytes) };
|
|
28323
|
+
case "array": {
|
|
28324
|
+
const items = [];
|
|
28325
|
+
for (const item of node.items) items.push(yield* transformNodeStringsAndStreamsSteps(item, transform, transformStream));
|
|
28326
|
+
return { kind: "array", items };
|
|
28327
|
+
}
|
|
28310
28328
|
case "dict": {
|
|
28311
|
-
const type = dictGet(node, "Type");
|
|
28312
|
-
const fieldType = dictGet(node, "FT");
|
|
28313
|
-
const byteRange = dictGet(node, "ByteRange");
|
|
28329
|
+
const type = dictGet(node, "Type"), fieldType = dictGet(node, "FT"), byteRange = dictGet(node, "ByteRange");
|
|
28314
28330
|
const signature = type?.kind === "name" && type.decoded === "Sig" || fieldType?.kind === "name" && fieldType.decoded === "Sig" || byteRange?.kind === "array" && dictGet(node, "Filter")?.kind === "name";
|
|
28315
|
-
|
|
28316
|
-
|
|
28317
|
-
|
|
28318
|
-
key: e.key,
|
|
28319
|
-
value: signature && e.key.decoded === "Contents" ? e.value : transformNodeStringsAndStreams(e.value, transform, transformStream)
|
|
28320
|
-
}))
|
|
28321
|
-
};
|
|
28331
|
+
const entries = [];
|
|
28332
|
+
for (const e of node.entries) entries.push({ key: e.key, value: signature && e.key.decoded === "Contents" ? e.value : yield* transformNodeStringsAndStreamsSteps(e.value, transform, transformStream) });
|
|
28333
|
+
return { kind: "dict", entries };
|
|
28322
28334
|
}
|
|
28323
28335
|
case "stream": {
|
|
28324
28336
|
const type = dictGet(node.dict, "Type");
|
|
28325
28337
|
if (type?.kind === "name" && type.decoded === "XRef") return node;
|
|
28326
28338
|
const stream = transformStream ? transformStream(node) : { ...node, rawBytes: transform(node.rawBytes) };
|
|
28327
|
-
const
|
|
28328
|
-
|
|
28329
|
-
|
|
28330
|
-
key: e.key,
|
|
28331
|
-
value: e.key.decoded === "Length" ? cosNumber(stream.rawBytes.length) : transformNodeStringsAndStreams(e.value, transform, transformStream)
|
|
28332
|
-
}))
|
|
28333
|
-
};
|
|
28334
|
-
return {
|
|
28335
|
-
kind: "stream",
|
|
28336
|
-
dict: updatedDict,
|
|
28337
|
-
rawBytes: stream.rawBytes
|
|
28338
|
-
};
|
|
28339
|
+
const entries = [];
|
|
28340
|
+
for (const e of stream.dict.entries) entries.push({ key: e.key, value: e.key.decoded === "Length" ? cosNumber(stream.rawBytes.length) : yield* transformNodeStringsAndStreamsSteps(e.value, transform, transformStream) });
|
|
28341
|
+
return { kind: "stream", dict: { kind: "dict", entries }, rawBytes: stream.rawBytes };
|
|
28339
28342
|
}
|
|
28340
28343
|
default:
|
|
28341
28344
|
return node;
|
|
@@ -28404,7 +28407,8 @@ function createR6Encryption(userPassword, ownerPassword, pMask) {
|
|
|
28404
28407
|
StrF: cosName("StdCF")
|
|
28405
28408
|
}) };
|
|
28406
28409
|
}
|
|
28407
|
-
function
|
|
28410
|
+
function* encryptCosDocumentSteps(doc, options = {}) {
|
|
28411
|
+
yield;
|
|
28408
28412
|
const userPassword = options.userPassword ?? "";
|
|
28409
28413
|
const ownerPassword = options.ownerPassword ?? userPassword;
|
|
28410
28414
|
const revision = options.revision ?? 6;
|
|
@@ -28426,14 +28430,15 @@ function encryptCosDocument(doc, options = {}) {
|
|
|
28426
28430
|
const encryptObjNum = maxObjNum + 1;
|
|
28427
28431
|
const encryptedObjects = [];
|
|
28428
28432
|
for (const obj of doc.objects.values()) {
|
|
28429
|
-
|
|
28433
|
+
yield;
|
|
28434
|
+
const transformed = yield* transformNodeStringsAndStreamsSteps(
|
|
28430
28435
|
obj.value,
|
|
28431
28436
|
(plain) => encryptPdfBuffer(state, obj.objectNumber, obj.generationNumber, plain)
|
|
28432
28437
|
);
|
|
28433
28438
|
encryptedObjects.push({ objectNumber: obj.objectNumber, generationNumber: obj.generationNumber, value: transformed });
|
|
28434
28439
|
}
|
|
28435
28440
|
encryptedObjects.push({ objectNumber: encryptObjNum, generationNumber: 0, value: encryptDict });
|
|
28436
|
-
return
|
|
28441
|
+
return yield* serializeCosDocumentSteps({
|
|
28437
28442
|
objects: encryptedObjects,
|
|
28438
28443
|
rootRef: doc.rootRef,
|
|
28439
28444
|
infoRef: doc.infoRef,
|
|
@@ -28483,17 +28488,19 @@ function decryptStream(doc, stream, transform) {
|
|
|
28483
28488
|
}
|
|
28484
28489
|
return { kind: "stream", dict, rawBytes: bytes };
|
|
28485
28490
|
}
|
|
28486
|
-
function
|
|
28491
|
+
function* decryptCosDocumentSteps(doc, state) {
|
|
28492
|
+
yield;
|
|
28487
28493
|
const encryptObjNum = doc.encryptRef?.objectNumber;
|
|
28488
28494
|
const handler = securityHandlers.get(state);
|
|
28489
28495
|
for (const [num, obj] of doc.objects.entries()) {
|
|
28496
|
+
yield;
|
|
28490
28497
|
if (num === encryptObjNum || handler?.plaintextObjects.has(num)) continue;
|
|
28491
28498
|
if (obj.value.kind === "stream") {
|
|
28492
28499
|
const type = doc.resolve(dictGet(obj.value.dict, "Type"));
|
|
28493
28500
|
if (type?.kind === "name" && (type.decoded === "XRef" || type.decoded === "Metadata" && !state.encryptMetadata)) continue;
|
|
28494
28501
|
}
|
|
28495
28502
|
const transform = handler?.factory.createCipherTransform(obj.objectNumber, obj.generationNumber);
|
|
28496
|
-
const decrypted =
|
|
28503
|
+
const decrypted = yield* transformNodeStringsAndStreamsSteps(
|
|
28497
28504
|
obj.value,
|
|
28498
28505
|
(cipher) => decryptPdfBuffer(state, obj.objectNumber, obj.generationNumber, cipher),
|
|
28499
28506
|
transform ? (stream) => decryptStream(doc, stream, transform) : void 0
|
|
@@ -28607,9 +28614,12 @@ var ParsedCosDocument = class {
|
|
|
28607
28614
|
return void 0;
|
|
28608
28615
|
}
|
|
28609
28616
|
};
|
|
28610
|
-
function
|
|
28617
|
+
function* parseNodeFromLexerSteps(lexer, bytes, maxDepth, repair = false) {
|
|
28618
|
+
yield;
|
|
28619
|
+
let work = 0;
|
|
28611
28620
|
const stack = [];
|
|
28612
28621
|
while (true) {
|
|
28622
|
+
if (++work % 16 === 0) yield;
|
|
28613
28623
|
const tok = lexer.nextToken();
|
|
28614
28624
|
const parent = stack.at(-1);
|
|
28615
28625
|
if (!tok) {
|
|
@@ -28805,7 +28815,8 @@ function parseHeaderVersion(bytes) {
|
|
|
28805
28815
|
}
|
|
28806
28816
|
return head.slice(idx + 5, idx + 8);
|
|
28807
28817
|
}
|
|
28808
|
-
function
|
|
28818
|
+
function* parseObjectAtOffsetSteps(bytes, offset, maxRecursionDepth, repair = false) {
|
|
28819
|
+
yield;
|
|
28809
28820
|
const lexer = new CosByteLexer(bytes, offset);
|
|
28810
28821
|
const objNumTok = lexer.nextToken();
|
|
28811
28822
|
const genNumTok = lexer.nextToken();
|
|
@@ -28813,7 +28824,7 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
|
|
|
28813
28824
|
if (objNumTok?.kind !== "number" || genNumTok?.kind !== "number" || objKwTok?.kind !== "keyword" || objKwTok.value !== "obj") {
|
|
28814
28825
|
throw new PdfError("E_PARSE", `Malformed indirect object header at byte offset ${offset}`);
|
|
28815
28826
|
}
|
|
28816
|
-
const value =
|
|
28827
|
+
const value = yield* parseNodeFromLexerSteps(lexer, bytes, maxRecursionDepth, repair);
|
|
28817
28828
|
if (!value) {
|
|
28818
28829
|
throw new PdfError("E_PARSE", `Empty indirect object ${objNumTok.value} at offset ${offset}`);
|
|
28819
28830
|
}
|
|
@@ -28824,7 +28835,9 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
|
|
|
28824
28835
|
span: { start: objNumTok.span.start, end: lexer.offset }
|
|
28825
28836
|
};
|
|
28826
28837
|
}
|
|
28827
|
-
function
|
|
28838
|
+
function* parseXrefRevisionAtSteps(bytes, xrefOffset, maxDecompressedBytes, maxRecursionDepth, maxObjects) {
|
|
28839
|
+
yield;
|
|
28840
|
+
let work = 0;
|
|
28828
28841
|
if (xrefOffset < 0 || xrefOffset >= bytes.length) {
|
|
28829
28842
|
throw new PdfError("E_PARSE", `Invalid xref offset: ${xrefOffset}`);
|
|
28830
28843
|
}
|
|
@@ -28836,6 +28849,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
28836
28849
|
if (firstTok.kind === "keyword" && firstTok.value === "xref") {
|
|
28837
28850
|
const entries2 = /* @__PURE__ */ new Map();
|
|
28838
28851
|
while (true) {
|
|
28852
|
+
if (++work % 16 === 0) yield;
|
|
28839
28853
|
const saved = lexer.offset;
|
|
28840
28854
|
const tok = lexer.nextToken();
|
|
28841
28855
|
if (!tok) {
|
|
@@ -28859,6 +28873,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
28859
28873
|
}
|
|
28860
28874
|
if (count > maxObjects + 1) throw new PdfError("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
|
|
28861
28875
|
for (let i = 0; i < count; i++) {
|
|
28876
|
+
if (++work % 16 === 0) yield;
|
|
28862
28877
|
const offTok = lexer.nextToken();
|
|
28863
28878
|
const genTok = lexer.nextToken();
|
|
28864
28879
|
const flagTok = lexer.nextToken();
|
|
@@ -28884,7 +28899,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
28884
28899
|
if (entries2.size > maxObjects + 1) throw new PdfError("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
|
|
28885
28900
|
}
|
|
28886
28901
|
}
|
|
28887
|
-
const trailerNode =
|
|
28902
|
+
const trailerNode = yield* parseNodeFromLexerSteps(lexer, bytes, maxRecursionDepth);
|
|
28888
28903
|
if (!trailerNode || trailerNode.kind !== "dict") {
|
|
28889
28904
|
throw new PdfError("E_PARSE", "Missing trailer dictionary after xref table");
|
|
28890
28905
|
}
|
|
@@ -28896,7 +28911,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
28896
28911
|
previousXrefOffset: prevNode2?.kind === "number" ? prevNode2.value : void 0
|
|
28897
28912
|
};
|
|
28898
28913
|
}
|
|
28899
|
-
const xrefObj =
|
|
28914
|
+
const xrefObj = yield* parseObjectAtOffsetSteps(bytes, xrefOffset, maxRecursionDepth);
|
|
28900
28915
|
if (xrefObj.value.kind !== "stream") {
|
|
28901
28916
|
throw new PdfError("E_PARSE", `Expected xref table or XRef stream at offset ${xrefOffset}`);
|
|
28902
28917
|
}
|
|
@@ -28917,6 +28932,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
28917
28932
|
if (indexArray) {
|
|
28918
28933
|
if (indexArray.kind !== "array" || indexArray.items.length % 2 !== 0) throw new PdfError("E_PARSE", "Invalid XRef range fields");
|
|
28919
28934
|
for (let i = 0; i < indexArray.items.length; i += 2) {
|
|
28935
|
+
if (++work % 16 === 0) yield;
|
|
28920
28936
|
const first = indexArray.items[i];
|
|
28921
28937
|
const count = indexArray.items[i + 1];
|
|
28922
28938
|
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)) {
|
|
@@ -28939,9 +28955,11 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
28939
28955
|
return v;
|
|
28940
28956
|
};
|
|
28941
28957
|
for (const [startObj, count] of subsections) {
|
|
28958
|
+
if (++work % 16 === 0) yield;
|
|
28942
28959
|
if (count > (decoded.length - pos) / stride) throw new PdfError("E_PARSE", "Truncated XRef stream");
|
|
28943
28960
|
if (count > maxObjects + 1) throw new PdfError("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
|
|
28944
28961
|
for (let i = 0; i < count; i++) {
|
|
28962
|
+
if (++work % 16 === 0) yield;
|
|
28945
28963
|
const objNum = startObj + i;
|
|
28946
28964
|
const field0 = w0 > 0 ? readInt(w0) : 1;
|
|
28947
28965
|
const field1 = readInt(w1);
|
|
@@ -28987,12 +29005,16 @@ function isAsciiWhitespace(ch3) {
|
|
|
28987
29005
|
function isAsciiDigit(ch3) {
|
|
28988
29006
|
return ch3 >= 48 && ch3 <= 57;
|
|
28989
29007
|
}
|
|
28990
|
-
function
|
|
29008
|
+
function* repairScanCosDocumentSteps(bytes, maxObjects, maxRecursionDepth) {
|
|
29009
|
+
yield;
|
|
29010
|
+
let work = 0;
|
|
28991
29011
|
const objects = /* @__PURE__ */ new Map();
|
|
28992
29012
|
const trailers = [];
|
|
28993
29013
|
let pos = 0;
|
|
28994
29014
|
while (pos < bytes.length) {
|
|
29015
|
+
if (++work % 16 === 0) yield;
|
|
28995
29016
|
while (pos < bytes.length && !isAsciiDigit(bytes[pos])) {
|
|
29017
|
+
if (++work % 16 === 0) yield;
|
|
28996
29018
|
if (bytes[pos] === 37) {
|
|
28997
29019
|
while (pos < bytes.length && bytes[pos] !== 10 && bytes[pos] !== 13) pos++;
|
|
28998
29020
|
continue;
|
|
@@ -29002,7 +29024,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
|
|
|
29002
29024
|
try {
|
|
29003
29025
|
const token = lexer.nextToken();
|
|
29004
29026
|
if (token?.kind === "keyword" && token.value === "trailer") {
|
|
29005
|
-
const trailer =
|
|
29027
|
+
const trailer = yield* parseNodeFromLexerSteps(lexer, bytes, maxRecursionDepth, true);
|
|
29006
29028
|
if (trailer?.kind === "dict") trailers.push(trailer);
|
|
29007
29029
|
pos = lexer.offset;
|
|
29008
29030
|
continue;
|
|
@@ -29035,7 +29057,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
|
|
|
29035
29057
|
bytes[pos + 3] === 40)) {
|
|
29036
29058
|
pos += 3;
|
|
29037
29059
|
try {
|
|
29038
|
-
const parsed =
|
|
29060
|
+
const parsed = yield* parseObjectAtOffsetSteps(bytes, headerStart, maxRecursionDepth, true);
|
|
29039
29061
|
objects.set(parsed.objectNumber, parsed);
|
|
29040
29062
|
if (parsed.value.kind === "stream") {
|
|
29041
29063
|
const type = dictGet(parsed.value.dict, "Type");
|
|
@@ -29052,13 +29074,17 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
|
|
|
29052
29074
|
}
|
|
29053
29075
|
return { objects, trailers };
|
|
29054
29076
|
}
|
|
29055
|
-
function
|
|
29077
|
+
function* unpackRecoveredObjectsSteps(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth) {
|
|
29078
|
+
yield;
|
|
29079
|
+
let work = 0;
|
|
29056
29080
|
for (const obj of [...objects.values()]) {
|
|
29081
|
+
if (++work % 16 === 0) yield;
|
|
29057
29082
|
if (obj.value.kind === "stream") {
|
|
29058
29083
|
const t = dictGet(obj.value.dict, "Type");
|
|
29059
29084
|
if (t?.kind === "name" && t.decoded === "ObjStm") {
|
|
29060
29085
|
try {
|
|
29061
|
-
for (const [unpackedNum, unpackedVal] of
|
|
29086
|
+
for (const [unpackedNum, unpackedVal] of (yield* unpackObjectStreamSteps(obj.value, maxDecompressedBytes, maxRecursionDepth, true)).entries()) {
|
|
29087
|
+
if (++work % 16 === 0) yield;
|
|
29062
29088
|
if (!objects.has(unpackedNum)) {
|
|
29063
29089
|
objects.set(unpackedNum, {
|
|
29064
29090
|
objectNumber: unpackedNum,
|
|
@@ -29094,7 +29120,9 @@ function recoveredReferences(objects) {
|
|
|
29094
29120
|
}
|
|
29095
29121
|
return { ...rootRef ? { rootRef } : {}, ...infoRef ? { infoRef } : {} };
|
|
29096
29122
|
}
|
|
29097
|
-
function
|
|
29123
|
+
function* unpackObjectStreamSteps(streamObj, maxDecompressedBytes, maxRecursionDepth, repair = false) {
|
|
29124
|
+
yield;
|
|
29125
|
+
let work = 0;
|
|
29098
29126
|
const nNode = dictGet(streamObj.dict, "N");
|
|
29099
29127
|
const firstNode = dictGet(streamObj.dict, "First");
|
|
29100
29128
|
if (nNode?.kind !== "number" || firstNode?.kind !== "number") {
|
|
@@ -29104,6 +29132,7 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth,
|
|
|
29104
29132
|
const headerLexer = new CosByteLexer(decoded, 0);
|
|
29105
29133
|
const pairs = [];
|
|
29106
29134
|
for (let i = 0; i < nNode.value; i++) {
|
|
29135
|
+
if (++work % 16 === 0) yield;
|
|
29107
29136
|
const numTok = headerLexer.nextToken();
|
|
29108
29137
|
const offTok = headerLexer.nextToken();
|
|
29109
29138
|
if (numTok?.kind === "number" && offTok?.kind === "number") {
|
|
@@ -29112,9 +29141,10 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth,
|
|
|
29112
29141
|
}
|
|
29113
29142
|
const result = /* @__PURE__ */ new Map();
|
|
29114
29143
|
for (const pair of pairs) {
|
|
29144
|
+
if (++work % 16 === 0) yield;
|
|
29115
29145
|
try {
|
|
29116
29146
|
const valLexer = new CosByteLexer(decoded, firstNode.value + pair.relativeOffset);
|
|
29117
|
-
const node =
|
|
29147
|
+
const node = yield* parseNodeFromLexerSteps(valLexer, decoded, maxRecursionDepth, repair);
|
|
29118
29148
|
if (node) {
|
|
29119
29149
|
result.set(pair.objectNumber, node);
|
|
29120
29150
|
}
|
|
@@ -29124,7 +29154,9 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth,
|
|
|
29124
29154
|
}
|
|
29125
29155
|
return result;
|
|
29126
29156
|
}
|
|
29127
|
-
function
|
|
29157
|
+
function* parseCosDocumentSteps(bytes, options = {}) {
|
|
29158
|
+
yield;
|
|
29159
|
+
let work = 0;
|
|
29128
29160
|
const version = parseHeaderVersion(bytes);
|
|
29129
29161
|
const recovery = options.recovery ?? "strict";
|
|
29130
29162
|
const maxObjects = options.maxObjects ?? Infinity;
|
|
@@ -29159,10 +29191,12 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
29159
29191
|
let currentXrefOffset = offsetTok.value;
|
|
29160
29192
|
const visitedOffsets = /* @__PURE__ */ new Set();
|
|
29161
29193
|
while (currentXrefOffset !== void 0 && !visitedOffsets.has(currentXrefOffset)) {
|
|
29194
|
+
if (++work % 16 === 0) yield;
|
|
29162
29195
|
visitedOffsets.add(currentXrefOffset);
|
|
29163
|
-
const rev =
|
|
29196
|
+
const rev = yield* parseXrefRevisionAtSteps(bytes, currentXrefOffset, maxDecompressedBytes, maxRecursionDepth, maxObjects);
|
|
29164
29197
|
revisions.push(rev);
|
|
29165
29198
|
for (const [num, entry] of rev.entries.entries()) {
|
|
29199
|
+
if (++work % 16 === 0) yield;
|
|
29166
29200
|
if (!mergedXref.has(num)) {
|
|
29167
29201
|
mergedXref.set(num, entry);
|
|
29168
29202
|
if (mergedXref.size > maxObjects + 1) throw new PdfError("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
|
|
@@ -29195,8 +29229,9 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
29195
29229
|
if (!useRepair && rootRef) {
|
|
29196
29230
|
try {
|
|
29197
29231
|
for (const [objNum, entry] of mergedXref.entries()) {
|
|
29232
|
+
if (++work % 16 === 0) yield;
|
|
29198
29233
|
if (entry.type !== "uncompressed") continue;
|
|
29199
|
-
const parsed =
|
|
29234
|
+
const parsed = yield* parseObjectAtOffsetSteps(bytes, entry.offset ?? 0, maxRecursionDepth, recovery === "repair");
|
|
29200
29235
|
if (parsed.objectNumber !== objNum || parsed.generationNumber !== (entry.generationNumber ?? 0)) {
|
|
29201
29236
|
throw new PdfError("E_PARSE", `Bad uncompressed XRef entry for object ${objNum}`);
|
|
29202
29237
|
}
|
|
@@ -29214,7 +29249,7 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
29214
29249
|
throw new PdfError("E_PARSE", "PDF trailer missing /Root reference");
|
|
29215
29250
|
}
|
|
29216
29251
|
useRepair = true;
|
|
29217
|
-
const scanned =
|
|
29252
|
+
const scanned = yield* repairScanCosDocumentSteps(bytes, maxObjects, maxRecursionDepth);
|
|
29218
29253
|
objects = scanned.objects;
|
|
29219
29254
|
revisions.length = 0;
|
|
29220
29255
|
mergedXref.clear();
|
|
@@ -29249,7 +29284,7 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
29249
29284
|
encryptNode = encrypt?.kind === "ref" || encrypt?.kind === "dict" ? encrypt : void 0;
|
|
29250
29285
|
encryptRef = encrypt?.kind === "ref" ? encrypt : void 0;
|
|
29251
29286
|
idArray = id?.kind === "array" ? id : void 0;
|
|
29252
|
-
if (!rootRef && !encryptNode)
|
|
29287
|
+
if (!rootRef && !encryptNode) yield* unpackRecoveredObjectsSteps(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth);
|
|
29253
29288
|
const fallback = recoveredReferences(objects);
|
|
29254
29289
|
rootRef ??= fallback.rootRef;
|
|
29255
29290
|
infoRef ??= fallback.infoRef;
|
|
@@ -29284,20 +29319,21 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
29284
29319
|
maxRecursionDepth
|
|
29285
29320
|
});
|
|
29286
29321
|
doc.encryption = encState;
|
|
29287
|
-
|
|
29322
|
+
yield* decryptCosDocumentSteps(doc, encState);
|
|
29288
29323
|
}
|
|
29289
29324
|
if (useRepair) {
|
|
29290
|
-
|
|
29325
|
+
yield* unpackRecoveredObjectsSteps(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth);
|
|
29291
29326
|
doc.infoRef ??= recoveredReferences(objects).infoRef;
|
|
29292
29327
|
}
|
|
29293
29328
|
const objStmCache = /* @__PURE__ */ new Map();
|
|
29294
29329
|
for (const [objNum, entry] of mergedXref.entries()) {
|
|
29330
|
+
if (++work % 16 === 0) yield;
|
|
29295
29331
|
if (entry.type === "compressed" && entry.objectStreamNumber !== void 0) {
|
|
29296
29332
|
let unpacked = objStmCache.get(entry.objectStreamNumber);
|
|
29297
29333
|
if (!unpacked) {
|
|
29298
29334
|
const stmObj = objects.get(entry.objectStreamNumber)?.value;
|
|
29299
29335
|
if (stmObj?.kind === "stream") {
|
|
29300
|
-
unpacked =
|
|
29336
|
+
unpacked = yield* unpackObjectStreamSteps(stmObj, maxDecompressedBytes, maxRecursionDepth, recovery === "repair");
|
|
29301
29337
|
objStmCache.set(entry.objectStreamNumber, unpacked);
|
|
29302
29338
|
}
|
|
29303
29339
|
}
|
|
@@ -29314,6 +29350,9 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
29314
29350
|
}
|
|
29315
29351
|
return doc;
|
|
29316
29352
|
}
|
|
29353
|
+
function parseCosDocument(bytes, options = {}) {
|
|
29354
|
+
return drainWork(parseCosDocumentSteps(bytes, options));
|
|
29355
|
+
}
|
|
29317
29356
|
var WIN_ANSI_HIGH_BYTES = {
|
|
29318
29357
|
128: 8364,
|
|
29319
29358
|
130: 8218,
|
|
@@ -40689,7 +40728,8 @@ function resolveInheritedFieldEntry(doc, dict, key) {
|
|
|
40689
40728
|
}
|
|
40690
40729
|
return void 0;
|
|
40691
40730
|
}
|
|
40692
|
-
function
|
|
40731
|
+
function* collectFieldDictsSteps(doc, node, prefix = "", out = [], parentFt = "", parentFf = 0, parentQ = 0, parentMaxLen, yieldState = { work: 0 }) {
|
|
40732
|
+
if (++yieldState.work % 256 === 0) yield;
|
|
40693
40733
|
const dict = doc.resolveDict(node);
|
|
40694
40734
|
if (!dict) return out;
|
|
40695
40735
|
const tNode = doc.resolve(dictGet(dict, "T"));
|
|
@@ -40722,7 +40762,8 @@ function collectFieldDicts(doc, node, prefix = "", out = [], parentFt = "", pare
|
|
|
40722
40762
|
return out;
|
|
40723
40763
|
}
|
|
40724
40764
|
for (const kid of kidsArr.items) {
|
|
40725
|
-
|
|
40765
|
+
if (++yieldState.work % 16 === 0) yield;
|
|
40766
|
+
yield* collectFieldDictsSteps(doc, kid, fullName, out, currentFt, currentFf, currentQ, currentMaxLen, yieldState);
|
|
40726
40767
|
}
|
|
40727
40768
|
} else if (fullName) {
|
|
40728
40769
|
out.push({
|
|
@@ -41163,6 +41204,9 @@ function escapePdfLiteralString(str) {
|
|
|
41163
41204
|
}
|
|
41164
41205
|
return out;
|
|
41165
41206
|
}
|
|
41207
|
+
function collectFieldDicts(doc, node, prefix = "", out = [], parentFt = "", parentFf = 0, parentQ = 0, parentMaxLen) {
|
|
41208
|
+
drainWork(collectFieldDictsSteps(doc, node, prefix, out, parentFt, parentFf, parentQ, parentMaxLen));
|
|
41209
|
+
}
|
|
41166
41210
|
var PdfPage = class {
|
|
41167
41211
|
cosDoc;
|
|
41168
41212
|
pageRef;
|
|
@@ -43770,14 +43814,18 @@ var PdfDocument = class _PdfDocument {
|
|
|
43770
43814
|
});
|
|
43771
43815
|
return new _PdfDocument(parseCosDocument(rawBytes));
|
|
43772
43816
|
}
|
|
43773
|
-
static
|
|
43817
|
+
static *loadSteps(bytes, options) {
|
|
43818
|
+
yield;
|
|
43774
43819
|
return new _PdfDocument(
|
|
43775
|
-
|
|
43820
|
+
yield* parseCosDocumentSteps(bytes, {
|
|
43776
43821
|
...options,
|
|
43777
43822
|
recovery: options?.recovery ?? "repair"
|
|
43778
43823
|
})
|
|
43779
43824
|
);
|
|
43780
43825
|
}
|
|
43826
|
+
static load(bytes, options) {
|
|
43827
|
+
return drainWork(_PdfDocument.loadSteps(bytes, options));
|
|
43828
|
+
}
|
|
43781
43829
|
rebuildPagesList() {
|
|
43782
43830
|
const catalog = this.cos.resolveDict(this.cos.rootRef);
|
|
43783
43831
|
const pagesNode = catalog ? dictGet(catalog, "Pages") : void 0;
|
|
@@ -43859,20 +43907,30 @@ var PdfDocument = class _PdfDocument {
|
|
|
43859
43907
|
this.pages.splice(index, 1);
|
|
43860
43908
|
this.syncPageTree();
|
|
43861
43909
|
}
|
|
43862
|
-
|
|
43910
|
+
*copyPagesFromSteps(sourceDoc, indices) {
|
|
43911
|
+
function* cloneItems(items) {
|
|
43912
|
+
const result = [];
|
|
43913
|
+
for (const item of items) result.push(yield* cloneNode(item));
|
|
43914
|
+
return result;
|
|
43915
|
+
}
|
|
43916
|
+
yield;
|
|
43917
|
+
let work = 0;
|
|
43863
43918
|
const memo = /* @__PURE__ */ new Map();
|
|
43864
43919
|
const sourcePageObjNums = /* @__PURE__ */ new Set();
|
|
43865
43920
|
for (let i = 0; i < sourceDoc.getPageCount(); i++) {
|
|
43921
|
+
if (++work % 16 === 0) yield;
|
|
43866
43922
|
sourcePageObjNums.add(sourceDoc.getPage(i).ref.objectNumber);
|
|
43867
43923
|
}
|
|
43868
43924
|
const targetPageRefs = [];
|
|
43869
43925
|
for (const idx of indices) {
|
|
43926
|
+
if (++work % 16 === 0) yield;
|
|
43870
43927
|
const srcPage = sourceDoc.getPage(idx);
|
|
43871
43928
|
const pageRef = this.cos.allocateObject({ kind: "null" });
|
|
43872
43929
|
targetPageRefs.push(pageRef);
|
|
43873
43930
|
memo.set(srcPage.ref.objectNumber, pageRef);
|
|
43874
43931
|
}
|
|
43875
|
-
const cloneNode = (node)
|
|
43932
|
+
const cloneNode = function* (node) {
|
|
43933
|
+
if (++work % 16 === 0) yield;
|
|
43876
43934
|
if (node.kind === "ref") {
|
|
43877
43935
|
const existing = memo.get(node.objectNumber);
|
|
43878
43936
|
if (existing) return existing;
|
|
@@ -43883,12 +43941,12 @@ var PdfDocument = class _PdfDocument {
|
|
|
43883
43941
|
if (!target) return cosRef(0);
|
|
43884
43942
|
const placeholderRef = this.cos.allocateObject({ kind: "null" });
|
|
43885
43943
|
memo.set(node.objectNumber, placeholderRef);
|
|
43886
|
-
const clonedTarget = cloneNode(target);
|
|
43944
|
+
const clonedTarget = yield* cloneNode(target);
|
|
43887
43945
|
this.cos.setObject(placeholderRef.objectNumber, clonedTarget, 0);
|
|
43888
43946
|
return placeholderRef;
|
|
43889
43947
|
}
|
|
43890
43948
|
if (node.kind === "array") {
|
|
43891
|
-
return cosArray(node.items
|
|
43949
|
+
return cosArray(yield* cloneItems(node.items));
|
|
43892
43950
|
}
|
|
43893
43951
|
if (node.kind === "dict") {
|
|
43894
43952
|
const typeEntry = dictGet(node, "Type");
|
|
@@ -43898,13 +43956,13 @@ var PdfDocument = class _PdfDocument {
|
|
|
43898
43956
|
if (isPageTreeNode && entry.key.decoded === "Parent") continue;
|
|
43899
43957
|
newEntries.push({
|
|
43900
43958
|
key: { ...entry.key },
|
|
43901
|
-
value: cloneNode(entry.value)
|
|
43959
|
+
value: yield* cloneNode(entry.value)
|
|
43902
43960
|
});
|
|
43903
43961
|
}
|
|
43904
43962
|
return { kind: "dict", entries: newEntries };
|
|
43905
43963
|
}
|
|
43906
43964
|
if (node.kind === "stream") {
|
|
43907
|
-
const clonedDict = cloneNode(node.dict);
|
|
43965
|
+
const clonedDict = yield* cloneNode(node.dict);
|
|
43908
43966
|
return {
|
|
43909
43967
|
kind: "stream",
|
|
43910
43968
|
dict: clonedDict,
|
|
@@ -43913,11 +43971,12 @@ var PdfDocument = class _PdfDocument {
|
|
|
43913
43971
|
};
|
|
43914
43972
|
}
|
|
43915
43973
|
return node;
|
|
43916
|
-
};
|
|
43974
|
+
}.bind(this);
|
|
43917
43975
|
const copiedPages = [];
|
|
43918
43976
|
for (const [position, idx] of indices.entries()) {
|
|
43977
|
+
if (++work % 16 === 0) yield;
|
|
43919
43978
|
const srcPage = sourceDoc.getPage(idx);
|
|
43920
|
-
const clonedPageDict = cloneNode(srcPage.pageDict);
|
|
43979
|
+
const clonedPageDict = yield* cloneNode(srcPage.pageDict);
|
|
43921
43980
|
const size = srcPage.getSize();
|
|
43922
43981
|
if (!dictGet(clonedPageDict, "MediaBox")) {
|
|
43923
43982
|
dictSet(
|
|
@@ -43927,13 +43986,14 @@ var PdfDocument = class _PdfDocument {
|
|
|
43927
43986
|
);
|
|
43928
43987
|
}
|
|
43929
43988
|
if (!dictGet(clonedPageDict, "Resources")) {
|
|
43930
|
-
dictSet(clonedPageDict, "Resources", cloneNode(srcPage.getResourcesDict()));
|
|
43989
|
+
dictSet(clonedPageDict, "Resources", yield* cloneNode(srcPage.getResourcesDict()));
|
|
43931
43990
|
}
|
|
43932
43991
|
if (!dictGet(clonedPageDict, "Rotate") && srcPage.getRotation() !== 0) {
|
|
43933
43992
|
dictSet(clonedPageDict, "Rotate", cosNumber(srcPage.getRotation()));
|
|
43934
43993
|
}
|
|
43935
43994
|
const inheritedBoxKeys = ["CropBox", "BleedBox", "TrimBox", "ArtBox"];
|
|
43936
43995
|
for (const boxKey of inheritedBoxKeys) {
|
|
43996
|
+
if (++work % 16 === 0) yield;
|
|
43937
43997
|
if (!dictGet(clonedPageDict, boxKey)) {
|
|
43938
43998
|
const boxVal = boxKey === "CropBox" ? srcPage.getCropBox() : boxKey === "BleedBox" ? srcPage.getBleedBox() : boxKey === "TrimBox" ? srcPage.getTrimBox() : srcPage.getArtBox();
|
|
43939
43999
|
if (boxVal[0] !== 0 || boxVal[1] !== 0 || boxVal[2] !== size.width || boxVal[3] !== size.height) {
|
|
@@ -43975,8 +44035,9 @@ var PdfDocument = class _PdfDocument {
|
|
|
43975
44035
|
};
|
|
43976
44036
|
const clonedRootFieldRefs = [];
|
|
43977
44037
|
for (const item of srcFieldsArr.items) {
|
|
44038
|
+
if (++work % 16 === 0) yield;
|
|
43978
44039
|
if (!hasClonedDescendant(item)) continue;
|
|
43979
|
-
const cloned = cloneNode(item);
|
|
44040
|
+
const cloned = yield* cloneNode(item);
|
|
43980
44041
|
if (cloned.kind === "ref") {
|
|
43981
44042
|
const clonedDict = this.cos.resolveDict(cloned);
|
|
43982
44043
|
const kidsArr = clonedDict ? this.cos.resolveArray(dictGet(clonedDict, "Kids")) : void 0;
|
|
@@ -44010,6 +44071,7 @@ var PdfDocument = class _PdfDocument {
|
|
|
44010
44071
|
dstFields.items.filter((x) => x.kind === "ref").map((x) => x.objectNumber)
|
|
44011
44072
|
);
|
|
44012
44073
|
for (const fRef of clonedRootFieldRefs) {
|
|
44074
|
+
if (++work % 16 === 0) yield;
|
|
44013
44075
|
if (!existingNums.has(fRef.objectNumber)) {
|
|
44014
44076
|
dstFields.items.push(fRef);
|
|
44015
44077
|
existingNums.add(fRef.objectNumber);
|
|
@@ -44017,11 +44079,11 @@ var PdfDocument = class _PdfDocument {
|
|
|
44017
44079
|
}
|
|
44018
44080
|
const srcDr = dictGet(srcAcroForm, "DR");
|
|
44019
44081
|
if (srcDr && !dictGet(dstAcroForm, "DR")) {
|
|
44020
|
-
dictSet(dstAcroForm, "DR", cloneNode(srcDr));
|
|
44082
|
+
dictSet(dstAcroForm, "DR", yield* cloneNode(srcDr));
|
|
44021
44083
|
}
|
|
44022
44084
|
const srcDa = dictGet(srcAcroForm, "DA");
|
|
44023
44085
|
if (srcDa && !dictGet(dstAcroForm, "DA")) {
|
|
44024
|
-
dictSet(dstAcroForm, "DA", cloneNode(srcDa));
|
|
44086
|
+
dictSet(dstAcroForm, "DA", yield* cloneNode(srcDa));
|
|
44025
44087
|
}
|
|
44026
44088
|
}
|
|
44027
44089
|
}
|
|
@@ -44030,12 +44092,15 @@ var PdfDocument = class _PdfDocument {
|
|
|
44030
44092
|
if (srcOcProps) {
|
|
44031
44093
|
const dstCatalog = this.cos.resolveDict(this.cos.rootRef);
|
|
44032
44094
|
if (dstCatalog && !dictGet(dstCatalog, "OCProperties")) {
|
|
44033
|
-
dictSet(dstCatalog, "OCProperties", cloneNode(srcOcProps));
|
|
44095
|
+
dictSet(dstCatalog, "OCProperties", yield* cloneNode(srcOcProps));
|
|
44034
44096
|
}
|
|
44035
44097
|
}
|
|
44036
44098
|
this.syncPageTree();
|
|
44037
44099
|
return copiedPages;
|
|
44038
44100
|
}
|
|
44101
|
+
copyPagesFrom(sourceDoc, indices) {
|
|
44102
|
+
return drainWork(this.copyPagesFromSteps(sourceDoc, indices));
|
|
44103
|
+
}
|
|
44039
44104
|
embedStandardFont(fontName) {
|
|
44040
44105
|
return createStandardFontHandle(fontName);
|
|
44041
44106
|
}
|
|
@@ -44235,14 +44300,15 @@ var PdfDocument = class _PdfDocument {
|
|
|
44235
44300
|
});
|
|
44236
44301
|
return buildSemanticAstFromPages(extractedPages, tablesByPage, displayLists);
|
|
44237
44302
|
}
|
|
44238
|
-
|
|
44303
|
+
*saveSteps(options = {}) {
|
|
44304
|
+
yield;
|
|
44239
44305
|
this.syncPageTree();
|
|
44240
44306
|
if (this.cos.requiresFullRewrite) {
|
|
44241
44307
|
pruneUnusedXObjects(this.cos, this.pages);
|
|
44242
44308
|
discardUnreachableObjects(this.cos);
|
|
44243
44309
|
}
|
|
44244
44310
|
if (options.encrypt) {
|
|
44245
|
-
return
|
|
44311
|
+
return yield* encryptCosDocumentSteps(this.cos, options.encrypt);
|
|
44246
44312
|
}
|
|
44247
44313
|
const allObjects = [...this.cos.objects.values()].sort(
|
|
44248
44314
|
(a, b) => a.objectNumber - b.objectNumber
|
|
@@ -44250,7 +44316,7 @@ var PdfDocument = class _PdfDocument {
|
|
|
44250
44316
|
if (options.incremental && !this.cos.requiresFullRewrite && this.cos.bytes.length > 0) {
|
|
44251
44317
|
return appendIncrementalRevision(this.cos.bytes, this.cos, allObjects);
|
|
44252
44318
|
}
|
|
44253
|
-
return
|
|
44319
|
+
return yield* serializeCosDocumentSteps({
|
|
44254
44320
|
objects: allObjects,
|
|
44255
44321
|
rootRef: this.cos.rootRef,
|
|
44256
44322
|
infoRef: this.cos.infoRef,
|
|
@@ -44261,6 +44327,9 @@ var PdfDocument = class _PdfDocument {
|
|
|
44261
44327
|
linearize: options.linearize
|
|
44262
44328
|
});
|
|
44263
44329
|
}
|
|
44330
|
+
save(options = {}) {
|
|
44331
|
+
return drainWork(this.saveSteps(options));
|
|
44332
|
+
}
|
|
44264
44333
|
};
|
|
44265
44334
|
function formatPopplerSize(byteLength) {
|
|
44266
44335
|
if (byteLength >= 1024 * 1024) {
|
|
@@ -44292,10 +44361,8 @@ function extractPdfimagesPositionals(argv) {
|
|
|
44292
44361
|
}
|
|
44293
44362
|
return pos;
|
|
44294
44363
|
}
|
|
44295
|
-
|
|
44296
|
-
|
|
44297
|
-
}
|
|
44298
|
-
function runPdfimagesCliSync(argv, files, options = {}) {
|
|
44364
|
+
function* runPdfimagesCliSteps(argv, files, options = {}) {
|
|
44365
|
+
let cooperativeWork = 63;
|
|
44299
44366
|
let listOnly = false;
|
|
44300
44367
|
let usePng = false;
|
|
44301
44368
|
let useJpeg = false;
|
|
@@ -44312,6 +44379,8 @@ function runPdfimagesCliSync(argv, files, options = {}) {
|
|
|
44312
44379
|
let password = "";
|
|
44313
44380
|
const positionals = [];
|
|
44314
44381
|
for (let i = 0; i < argv.length; i++) {
|
|
44382
|
+
if (++cooperativeWork % 64 === 0)
|
|
44383
|
+
yield;
|
|
44315
44384
|
const arg = argv[i];
|
|
44316
44385
|
if (arg === "-v" || arg === "--version") {
|
|
44317
44386
|
return { exitCode: 0, stdout: "pdfimages version 24.08.0\n", stderr: "" };
|
|
@@ -44323,23 +44392,34 @@ function runPdfimagesCliSync(argv, files, options = {}) {
|
|
|
44323
44392
|
stderr: ""
|
|
44324
44393
|
};
|
|
44325
44394
|
}
|
|
44326
|
-
if (arg === "-list")
|
|
44327
|
-
|
|
44328
|
-
else if (arg === "-
|
|
44329
|
-
|
|
44330
|
-
else if (arg === "-
|
|
44331
|
-
|
|
44332
|
-
else if (arg === "-
|
|
44395
|
+
if (arg === "-list")
|
|
44396
|
+
listOnly = true;
|
|
44397
|
+
else if (arg === "-png")
|
|
44398
|
+
usePng = true;
|
|
44399
|
+
else if (arg === "-j")
|
|
44400
|
+
useJpeg = true;
|
|
44401
|
+
else if (arg === "-tiff")
|
|
44402
|
+
useTiff = true;
|
|
44403
|
+
else if (arg === "-jp2")
|
|
44404
|
+
useJp2 = true;
|
|
44405
|
+
else if (arg === "-jbig2")
|
|
44406
|
+
useJbig2 = true;
|
|
44407
|
+
else if (arg === "-ccitt")
|
|
44408
|
+
useCcitt = true;
|
|
44333
44409
|
else if (arg === "-all") {
|
|
44334
44410
|
usePng = true;
|
|
44335
44411
|
useJpeg = true;
|
|
44336
44412
|
useJp2 = true;
|
|
44337
44413
|
useJbig2 = true;
|
|
44338
44414
|
useCcitt = true;
|
|
44339
|
-
} else if (arg === "-p")
|
|
44340
|
-
|
|
44341
|
-
else if (arg === "-
|
|
44342
|
-
|
|
44415
|
+
} else if (arg === "-p")
|
|
44416
|
+
includePage = true;
|
|
44417
|
+
else if (arg === "-u")
|
|
44418
|
+
uniqueOnly = true;
|
|
44419
|
+
else if (arg === "-print-filenames")
|
|
44420
|
+
printFilenames = true;
|
|
44421
|
+
else if (arg === "-q")
|
|
44422
|
+
quiet = true;
|
|
44343
44423
|
else if (arg === "-f") {
|
|
44344
44424
|
firstPage = Math.max(1, Number.parseInt(argv[++i] ?? "1", 10) || 1);
|
|
44345
44425
|
} else if (arg === "-l") {
|
|
@@ -44382,9 +44462,11 @@ function runPdfimagesCliSync(argv, files, options = {}) {
|
|
|
44382
44462
|
});
|
|
44383
44463
|
const seenObjectIds = /* @__PURE__ */ new Set();
|
|
44384
44464
|
const extracted = uniqueOnly ? allExtracted.filter((img) => {
|
|
44385
|
-
if (img.inline || !img.objectId)
|
|
44465
|
+
if (img.inline || !img.objectId)
|
|
44466
|
+
return true;
|
|
44386
44467
|
const key = `${img.objectId.objNum}:${img.objectId.genNum}`;
|
|
44387
|
-
if (seenObjectIds.has(key))
|
|
44468
|
+
if (seenObjectIds.has(key))
|
|
44469
|
+
return false;
|
|
44388
44470
|
seenObjectIds.add(key);
|
|
44389
44471
|
return true;
|
|
44390
44472
|
}) : allExtracted;
|
|
@@ -44395,22 +44477,16 @@ function runPdfimagesCliSync(argv, files, options = {}) {
|
|
|
44395
44477
|
const root = positionals[1] ?? "image";
|
|
44396
44478
|
const printedFilenames = [];
|
|
44397
44479
|
for (let idx = 0; idx < extracted.length; idx++) {
|
|
44480
|
+
if (++cooperativeWork % 64 === 0)
|
|
44481
|
+
yield;
|
|
44398
44482
|
const img = extracted[idx];
|
|
44399
44483
|
const numStr = String(idx).padStart(3, "0");
|
|
44400
44484
|
const objField = img.inline || !img.objectId ? " [inline]" : `${String(img.objectId.objNum).padStart(6)} ${String(img.objectId.genNum).padStart(2)}`;
|
|
44401
44485
|
const sizeStr = formatPopplerSize(img.byteLength).padStart(5);
|
|
44402
|
-
const ratioStr = formatPopplerRatio(
|
|
44403
|
-
img.byteLength,
|
|
44404
|
-
img.width,
|
|
44405
|
-
img.height,
|
|
44406
|
-
img.components,
|
|
44407
|
-
img.bitsPerComponent
|
|
44408
|
-
).padStart(5);
|
|
44486
|
+
const ratioStr = formatPopplerRatio(img.byteLength, img.width, img.height, img.components, img.bitsPerComponent).padStart(5);
|
|
44409
44487
|
const interpStr = (img.interpolate ? "yes" : "no").padStart(6);
|
|
44410
44488
|
const colorCol = (img.colorSpaceLabel ?? img.colorSpace).padEnd(5);
|
|
44411
|
-
listLines.push(
|
|
44412
|
-
`${String(img.pageNumber).padStart(4)} ${String(idx).padStart(5)} ${img.type.padEnd(6)} ${String(img.width).padStart(5)} ${String(img.height).padStart(6)} ${colorCol} ${String(img.components).padStart(4)} ${String(img.bitsPerComponent).padStart(3)} ${img.encoding.padEnd(5)} ${interpStr} ${objField} ${String(img.xPpi).padStart(5)} ${String(img.yPpi).padStart(5)} ${sizeStr} ${ratioStr}`
|
|
44413
|
-
);
|
|
44489
|
+
listLines.push(`${String(img.pageNumber).padStart(4)} ${String(idx).padStart(5)} ${img.type.padEnd(6)} ${String(img.width).padStart(5)} ${String(img.height).padStart(6)} ${colorCol} ${String(img.components).padStart(4)} ${String(img.bitsPerComponent).padStart(3)} ${img.encoding.padEnd(5)} ${interpStr} ${objField} ${String(img.xPpi).padStart(5)} ${String(img.yPpi).padStart(5)} ${sizeStr} ${ratioStr}`);
|
|
44414
44490
|
if (!listOnly) {
|
|
44415
44491
|
let ext;
|
|
44416
44492
|
let outBytes;
|
|
@@ -44445,7 +44521,8 @@ function runPdfimagesCliSync(argv, files, options = {}) {
|
|
|
44445
44521
|
if (ext === "jb2e" && img.jbig2GlobalsBytes) {
|
|
44446
44522
|
const jb2gName = includePage ? `${root}-${String(img.pageNumber).padStart(3, "0")}-${numStr}.jb2g` : `${root}-${numStr}.jb2g`;
|
|
44447
44523
|
files.set(jb2gName, img.jbig2GlobalsBytes);
|
|
44448
|
-
if (printFilenames)
|
|
44524
|
+
if (printFilenames)
|
|
44525
|
+
printedFilenames.push(jb2gName);
|
|
44449
44526
|
}
|
|
44450
44527
|
if (ext === "ccitt") {
|
|
44451
44528
|
const paramsBase = includePage ? `${root}-${String(img.pageNumber).padStart(3, "0")}-${numStr}.params` : `${root}-${numStr}.params`;
|
|
@@ -44460,9 +44537,11 @@ function runPdfimagesCliSync(argv, files, options = {}) {
|
|
|
44460
44537
|
].join(" ");
|
|
44461
44538
|
files.set(paramsBase, new TextEncoder().encode(`${extraFlags}
|
|
44462
44539
|
`));
|
|
44463
|
-
if (printFilenames)
|
|
44540
|
+
if (printFilenames)
|
|
44541
|
+
printedFilenames.push(paramsBase);
|
|
44464
44542
|
}
|
|
44465
|
-
if (printFilenames)
|
|
44543
|
+
if (printFilenames)
|
|
44544
|
+
printedFilenames.push(outName);
|
|
44466
44545
|
}
|
|
44467
44546
|
}
|
|
44468
44547
|
if (listOnly) {
|
|
@@ -44473,7 +44552,19 @@ function runPdfimagesCliSync(argv, files, options = {}) {
|
|
|
44473
44552
|
}
|
|
44474
44553
|
return { exitCode: 0, stdout: "", stderr: "" };
|
|
44475
44554
|
}
|
|
44555
|
+
async function runPdfimagesCli(argv, files, options = {}) {
|
|
44556
|
+
return drainSteps(runPdfimagesCliSteps(argv, files, options), options.signal);
|
|
44557
|
+
}
|
|
44558
|
+
function runPdfimagesCliSync(argv, files, options = {}) {
|
|
44559
|
+
const steps = runPdfimagesCliSteps(argv, files, options);
|
|
44560
|
+
let next = steps.next();
|
|
44561
|
+
while (!next.done) {
|
|
44562
|
+
next = steps.next();
|
|
44563
|
+
}
|
|
44564
|
+
return next.value;
|
|
44565
|
+
}
|
|
44476
44566
|
async function executePdfimages(context) {
|
|
44567
|
+
let cooperativeWork = 63;
|
|
44477
44568
|
const invocation = createOutputOperation(context, { write: async () => {
|
|
44478
44569
|
} });
|
|
44479
44570
|
try {
|
|
@@ -44493,6 +44584,7 @@ async function executePdfimages(context) {
|
|
|
44493
44584
|
const chunks = [];
|
|
44494
44585
|
let total = 0;
|
|
44495
44586
|
for await (const chunk of readBytes(context.stdin, invocation.signal)) {
|
|
44587
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
44496
44588
|
chunks.push(chunk);
|
|
44497
44589
|
total += chunk.byteLength;
|
|
44498
44590
|
chargeBytes(chunk.byteLength);
|
|
@@ -44501,6 +44593,7 @@ async function executePdfimages(context) {
|
|
|
44501
44593
|
const buf = new Uint8Array(total);
|
|
44502
44594
|
let off = 0;
|
|
44503
44595
|
for (const c of chunks) {
|
|
44596
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
44504
44597
|
buf.set(c, off);
|
|
44505
44598
|
off += c.byteLength;
|
|
44506
44599
|
}
|
|
@@ -44508,6 +44601,7 @@ async function executePdfimages(context) {
|
|
|
44508
44601
|
}
|
|
44509
44602
|
}
|
|
44510
44603
|
for (const token of positionals) {
|
|
44604
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
44511
44605
|
if (token === "-") continue;
|
|
44512
44606
|
try {
|
|
44513
44607
|
const bytes = await context.fs.readFile(resolveVfsPath(token), { signal: invocation.signal });
|
|
@@ -44516,8 +44610,9 @@ async function executePdfimages(context) {
|
|
|
44516
44610
|
} catch {
|
|
44517
44611
|
}
|
|
44518
44612
|
}
|
|
44613
|
+
context.inputBudget?.check(0);
|
|
44519
44614
|
const existingSnap = new Map(vfsFiles);
|
|
44520
|
-
const res = await runPdfimagesCli(argv, vfsFiles, { onAllocateBytes: chargeBytes });
|
|
44615
|
+
const res = await runPdfimagesCli(argv, vfsFiles, { onAllocateBytes: chargeBytes, signal: invocation.signal });
|
|
44521
44616
|
if (res.stderr) {
|
|
44522
44617
|
await writeBytes(context.stderr, new TextEncoder().encode(res.stderr), invocation.signal);
|
|
44523
44618
|
}
|
|
@@ -44526,6 +44621,7 @@ async function executePdfimages(context) {
|
|
|
44526
44621
|
await writeBytes(stdout.output, new TextEncoder().encode(res.stdout), invocation.signal);
|
|
44527
44622
|
}
|
|
44528
44623
|
for (const [key, val] of vfsFiles.entries()) {
|
|
44624
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
44529
44625
|
if (key !== "-" && existingSnap.get(key) !== val) {
|
|
44530
44626
|
const abs = resolveVfsPath(key);
|
|
44531
44627
|
const parentDir = abs.slice(0, abs.lastIndexOf("/")) || "/";
|
|
@@ -44541,13 +44637,14 @@ async function executePdfimages(context) {
|
|
|
44541
44637
|
await invocation.close();
|
|
44542
44638
|
}
|
|
44543
44639
|
}
|
|
44544
|
-
function createPdfimagesCommand(
|
|
44640
|
+
function createPdfimagesCommand(options = {}) {
|
|
44641
|
+
const maxInputBytes = InputByteBudget.limit(options.limits?.maxInputBytes);
|
|
44545
44642
|
return Object.freeze({
|
|
44546
44643
|
name: "pdfimages",
|
|
44547
44644
|
runtimeIdentity: commandRuntimeIdentity,
|
|
44548
44645
|
description: "List and extract embedded images from PDF pages via @poe-code/pdf-ast",
|
|
44549
44646
|
execute(context) {
|
|
44550
|
-
return
|
|
44647
|
+
return new InputByteBudget(maxInputBytes).run(context, executePdfimages);
|
|
44551
44648
|
}
|
|
44552
44649
|
});
|
|
44553
44650
|
}
|