@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
|
@@ -200604,6 +200604,11 @@ function tokenizeCos(bytes, start = 0, end2 = bytes.length) {
|
|
|
200604
200604
|
}
|
|
200605
200605
|
return tokens3;
|
|
200606
200606
|
}
|
|
200607
|
+
function drainWork(work) {
|
|
200608
|
+
let step = work.next();
|
|
200609
|
+
while (!step.done) step = work.next();
|
|
200610
|
+
return step.value;
|
|
200611
|
+
}
|
|
200607
200612
|
function bytesToString3(bytes) {
|
|
200608
200613
|
if (typeof bytes !== "object" || bytes?.length === void 0) {
|
|
200609
200614
|
throw new Error("Invalid argument for bytesToString");
|
|
@@ -201199,7 +201204,9 @@ function concatByteArrays(chunks) {
|
|
|
201199
201204
|
}
|
|
201200
201205
|
return out;
|
|
201201
201206
|
}
|
|
201202
|
-
function
|
|
201207
|
+
function* serializeCosDocumentSteps(options) {
|
|
201208
|
+
yield;
|
|
201209
|
+
let work = 0;
|
|
201203
201210
|
const maxOutputBytes = options.maxOutputBytes ?? Infinity;
|
|
201204
201211
|
const maxObjects = options.maxObjects ?? Infinity;
|
|
201205
201212
|
const sorted = [...options.objects].sort((a3, b3) => a3.objectNumber - b3.objectNumber);
|
|
@@ -201222,6 +201229,7 @@ function serializeCosDocument(options) {
|
|
|
201222
201229
|
const packable = [];
|
|
201223
201230
|
const direct = [];
|
|
201224
201231
|
for (const obj of sorted) {
|
|
201232
|
+
if (++work % 16 === 0) yield;
|
|
201225
201233
|
const isLinearized = obj.value.kind === "dict" && dictGet(obj.value, "Linearized") !== void 0;
|
|
201226
201234
|
if (obj.value.kind !== "stream" && obj.generationNumber === 0 && !isLinearized) {
|
|
201227
201235
|
packable.push(obj);
|
|
@@ -201236,6 +201244,7 @@ function serializeCosDocument(options) {
|
|
|
201236
201244
|
const headerPairs = [];
|
|
201237
201245
|
let relOffset = 0;
|
|
201238
201246
|
for (const pObj of packable) {
|
|
201247
|
+
if (++work % 16 === 0) yield;
|
|
201239
201248
|
headerPairs.push(`${pObj.objectNumber} ${relOffset}`);
|
|
201240
201249
|
const bBytes = serializeCosNodeBytes(pObj.value);
|
|
201241
201250
|
const nl = textEncoder2.encode("\n");
|
|
@@ -201261,6 +201270,7 @@ function serializeCosDocument(options) {
|
|
|
201261
201270
|
];
|
|
201262
201271
|
const directOffsets = /* @__PURE__ */ new Map();
|
|
201263
201272
|
for (const dObj of allDirect) {
|
|
201273
|
+
if (++work % 16 === 0) yield;
|
|
201264
201274
|
directOffsets.set(dObj.objectNumber, { offset, generation: dObj.generationNumber });
|
|
201265
201275
|
const prefix = textEncoder2.encode(`${dObj.objectNumber} ${dObj.generationNumber} obj
|
|
201266
201276
|
`);
|
|
@@ -201271,6 +201281,7 @@ function serializeCosDocument(options) {
|
|
|
201271
201281
|
}
|
|
201272
201282
|
const compressedMap = /* @__PURE__ */ new Map();
|
|
201273
201283
|
for (let idx = 0; idx < packable.length; idx++) {
|
|
201284
|
+
if (++work % 16 === 0) yield;
|
|
201274
201285
|
compressedMap.set(packable[idx].objectNumber, idx);
|
|
201275
201286
|
}
|
|
201276
201287
|
const xrefOffset2 = offset;
|
|
@@ -201288,6 +201299,7 @@ function serializeCosDocument(options) {
|
|
|
201288
201299
|
};
|
|
201289
201300
|
writeEntry7(0, 0, 0, 65535);
|
|
201290
201301
|
for (let i = 1; i < size2; i++) {
|
|
201302
|
+
if (++work % 16 === 0) yield;
|
|
201291
201303
|
if (i === xrefStmNum) {
|
|
201292
201304
|
writeEntry7(i, 1, xrefOffset2, 0);
|
|
201293
201305
|
} else if (compressedMap.has(i)) {
|
|
@@ -201368,6 +201380,7 @@ ${xrefOffset2}
|
|
|
201368
201380
|
let pageCount = 0;
|
|
201369
201381
|
let firstPageObjNum = options.rootRef.objectNumber;
|
|
201370
201382
|
for (const o of sorted) {
|
|
201383
|
+
if (++work % 16 === 0) yield;
|
|
201371
201384
|
if (o.value.kind === "dict") {
|
|
201372
201385
|
const t = dictGet(o.value, "Type");
|
|
201373
201386
|
if (t?.kind === "name" && t.decoded === "Page") {
|
|
@@ -201415,6 +201428,7 @@ ${xrefOffset2}
|
|
|
201415
201428
|
}
|
|
201416
201429
|
const objectOffsets = /* @__PURE__ */ new Map();
|
|
201417
201430
|
for (const obj of sorted) {
|
|
201431
|
+
if (++work % 16 === 0) yield;
|
|
201418
201432
|
objectOffsets.set(obj.objectNumber, { offset, generation: obj.generationNumber });
|
|
201419
201433
|
let value3 = obj.value;
|
|
201420
201434
|
if (options.normalizeContent && value3.kind === "stream" && value3.decodedBytes) {
|
|
@@ -201446,6 +201460,7 @@ ${xrefOffset2}
|
|
|
201446
201460
|
0000000000 65535 f
|
|
201447
201461
|
`;
|
|
201448
201462
|
for (let i = 1; i < size; i++) {
|
|
201463
|
+
if (++work % 16 === 0) yield;
|
|
201449
201464
|
const entry2 = objectOffsets.get(i);
|
|
201450
201465
|
if (entry2) {
|
|
201451
201466
|
xrefText += `${String(entry2.offset).padStart(10, "0")} ${String(entry2.generation).padStart(5, "0")} n
|
|
@@ -201492,6 +201507,7 @@ ${xrefOffset}
|
|
|
201492
201507
|
let endFirstPage = xrefOffset;
|
|
201493
201508
|
const sortedOffsets = [...objectOffsets.entries()].sort((a3, b3) => a3[1].offset - b3[1].offset);
|
|
201494
201509
|
for (let i = 0; i < sortedOffsets.length; i++) {
|
|
201510
|
+
if (++work % 16 === 0) yield;
|
|
201495
201511
|
const [objNum, info3] = sortedOffsets[i];
|
|
201496
201512
|
const nextOff = sortedOffsets[i + 1]?.[1].offset ?? xrefOffset;
|
|
201497
201513
|
if (objNum === hintObjAfter.objectNumber) {
|
|
@@ -201525,6 +201541,9 @@ ${xrefOffset}
|
|
|
201525
201541
|
}
|
|
201526
201542
|
return fullBytes;
|
|
201527
201543
|
}
|
|
201544
|
+
function serializeCosDocument(options) {
|
|
201545
|
+
return drainWork(serializeCosDocumentSteps(options));
|
|
201546
|
+
}
|
|
201528
201547
|
function appendIncrementalRevision(originalBytes, doc, updatedObjects) {
|
|
201529
201548
|
const chunks = [originalBytes, textEncoder2.encode("\n")];
|
|
201530
201549
|
let offset = originalBytes.length + 1;
|
|
@@ -201798,48 +201817,30 @@ function encryptPdfBuffer(state, objectNumber, generationNumber, plaintext) {
|
|
|
201798
201817
|
const objKey = md5Bytes([state.fileKey, suffix]).subarray(0, Math.min(16, state.fileKey.length + 5));
|
|
201799
201818
|
return rc4Transform(objKey, plaintext);
|
|
201800
201819
|
}
|
|
201801
|
-
function
|
|
201820
|
+
function* transformNodeStringsAndStreamsSteps(node3, transform2, transformStream) {
|
|
201821
|
+
yield;
|
|
201802
201822
|
switch (node3.kind) {
|
|
201803
201823
|
case "string":
|
|
201804
|
-
return {
|
|
201805
|
-
|
|
201806
|
-
|
|
201807
|
-
|
|
201808
|
-
};
|
|
201809
|
-
|
|
201810
|
-
return {
|
|
201811
|
-
kind: "array",
|
|
201812
|
-
items: node3.items.map((item) => transformNodeStringsAndStreams(item, transform2, transformStream))
|
|
201813
|
-
};
|
|
201824
|
+
return { kind: "string", format: "hex", bytes: transform2(node3.bytes) };
|
|
201825
|
+
case "array": {
|
|
201826
|
+
const items = [];
|
|
201827
|
+
for (const item of node3.items) items.push(yield* transformNodeStringsAndStreamsSteps(item, transform2, transformStream));
|
|
201828
|
+
return { kind: "array", items };
|
|
201829
|
+
}
|
|
201814
201830
|
case "dict": {
|
|
201815
|
-
const type = dictGet(node3, "Type");
|
|
201816
|
-
const fieldType = dictGet(node3, "FT");
|
|
201817
|
-
const byteRange = dictGet(node3, "ByteRange");
|
|
201831
|
+
const type = dictGet(node3, "Type"), fieldType = dictGet(node3, "FT"), byteRange = dictGet(node3, "ByteRange");
|
|
201818
201832
|
const signature2 = type?.kind === "name" && type.decoded === "Sig" || fieldType?.kind === "name" && fieldType.decoded === "Sig" || byteRange?.kind === "array" && dictGet(node3, "Filter")?.kind === "name";
|
|
201819
|
-
|
|
201820
|
-
|
|
201821
|
-
|
|
201822
|
-
key: e.key,
|
|
201823
|
-
value: signature2 && e.key.decoded === "Contents" ? e.value : transformNodeStringsAndStreams(e.value, transform2, transformStream)
|
|
201824
|
-
}))
|
|
201825
|
-
};
|
|
201833
|
+
const entries2 = [];
|
|
201834
|
+
for (const e of node3.entries) entries2.push({ key: e.key, value: signature2 && e.key.decoded === "Contents" ? e.value : yield* transformNodeStringsAndStreamsSteps(e.value, transform2, transformStream) });
|
|
201835
|
+
return { kind: "dict", entries: entries2 };
|
|
201826
201836
|
}
|
|
201827
201837
|
case "stream": {
|
|
201828
201838
|
const type = dictGet(node3.dict, "Type");
|
|
201829
201839
|
if (type?.kind === "name" && type.decoded === "XRef") return node3;
|
|
201830
201840
|
const stream = transformStream ? transformStream(node3) : { ...node3, rawBytes: transform2(node3.rawBytes) };
|
|
201831
|
-
const
|
|
201832
|
-
|
|
201833
|
-
|
|
201834
|
-
key: e.key,
|
|
201835
|
-
value: e.key.decoded === "Length" ? cosNumber(stream.rawBytes.length) : transformNodeStringsAndStreams(e.value, transform2, transformStream)
|
|
201836
|
-
}))
|
|
201837
|
-
};
|
|
201838
|
-
return {
|
|
201839
|
-
kind: "stream",
|
|
201840
|
-
dict: updatedDict,
|
|
201841
|
-
rawBytes: stream.rawBytes
|
|
201842
|
-
};
|
|
201841
|
+
const entries2 = [];
|
|
201842
|
+
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, transform2, transformStream) });
|
|
201843
|
+
return { kind: "stream", dict: { kind: "dict", entries: entries2 }, rawBytes: stream.rawBytes };
|
|
201843
201844
|
}
|
|
201844
201845
|
default:
|
|
201845
201846
|
return node3;
|
|
@@ -201908,7 +201909,8 @@ function createR6Encryption(userPassword, ownerPassword, pMask) {
|
|
|
201908
201909
|
StrF: cosName("StdCF")
|
|
201909
201910
|
}) };
|
|
201910
201911
|
}
|
|
201911
|
-
function
|
|
201912
|
+
function* encryptCosDocumentSteps(doc, options = {}) {
|
|
201913
|
+
yield;
|
|
201912
201914
|
const userPassword = options.userPassword ?? "";
|
|
201913
201915
|
const ownerPassword = options.ownerPassword ?? userPassword;
|
|
201914
201916
|
const revision2 = options.revision ?? 6;
|
|
@@ -201930,14 +201932,15 @@ function encryptCosDocument(doc, options = {}) {
|
|
|
201930
201932
|
const encryptObjNum = maxObjNum + 1;
|
|
201931
201933
|
const encryptedObjects = [];
|
|
201932
201934
|
for (const obj of doc.objects.values()) {
|
|
201933
|
-
|
|
201935
|
+
yield;
|
|
201936
|
+
const transformed = yield* transformNodeStringsAndStreamsSteps(
|
|
201934
201937
|
obj.value,
|
|
201935
201938
|
(plain) => encryptPdfBuffer(state, obj.objectNumber, obj.generationNumber, plain)
|
|
201936
201939
|
);
|
|
201937
201940
|
encryptedObjects.push({ objectNumber: obj.objectNumber, generationNumber: obj.generationNumber, value: transformed });
|
|
201938
201941
|
}
|
|
201939
201942
|
encryptedObjects.push({ objectNumber: encryptObjNum, generationNumber: 0, value: encryptDict });
|
|
201940
|
-
return
|
|
201943
|
+
return yield* serializeCosDocumentSteps({
|
|
201941
201944
|
objects: encryptedObjects,
|
|
201942
201945
|
rootRef: doc.rootRef,
|
|
201943
201946
|
infoRef: doc.infoRef,
|
|
@@ -201987,17 +201990,19 @@ function decryptStream(doc, stream, transform2) {
|
|
|
201987
201990
|
}
|
|
201988
201991
|
return { kind: "stream", dict, rawBytes: bytes };
|
|
201989
201992
|
}
|
|
201990
|
-
function
|
|
201993
|
+
function* decryptCosDocumentSteps(doc, state) {
|
|
201994
|
+
yield;
|
|
201991
201995
|
const encryptObjNum = doc.encryptRef?.objectNumber;
|
|
201992
201996
|
const handler = securityHandlers.get(state);
|
|
201993
201997
|
for (const [num, obj] of doc.objects.entries()) {
|
|
201998
|
+
yield;
|
|
201994
201999
|
if (num === encryptObjNum || handler?.plaintextObjects.has(num)) continue;
|
|
201995
202000
|
if (obj.value.kind === "stream") {
|
|
201996
202001
|
const type = doc.resolve(dictGet(obj.value.dict, "Type"));
|
|
201997
202002
|
if (type?.kind === "name" && (type.decoded === "XRef" || type.decoded === "Metadata" && !state.encryptMetadata)) continue;
|
|
201998
202003
|
}
|
|
201999
202004
|
const transform2 = handler?.factory.createCipherTransform(obj.objectNumber, obj.generationNumber);
|
|
202000
|
-
const decrypted =
|
|
202005
|
+
const decrypted = yield* transformNodeStringsAndStreamsSteps(
|
|
202001
202006
|
obj.value,
|
|
202002
202007
|
(cipher) => decryptPdfBuffer(state, obj.objectNumber, obj.generationNumber, cipher),
|
|
202003
202008
|
transform2 ? (stream) => decryptStream(doc, stream, transform2) : void 0
|
|
@@ -202111,9 +202116,12 @@ var ParsedCosDocument = class {
|
|
|
202111
202116
|
return void 0;
|
|
202112
202117
|
}
|
|
202113
202118
|
};
|
|
202114
|
-
function
|
|
202119
|
+
function* parseNodeFromLexerSteps(lexer, bytes, maxDepth, repair = false) {
|
|
202120
|
+
yield;
|
|
202121
|
+
let work = 0;
|
|
202115
202122
|
const stack = [];
|
|
202116
202123
|
while (true) {
|
|
202124
|
+
if (++work % 16 === 0) yield;
|
|
202117
202125
|
const tok = lexer.nextToken();
|
|
202118
202126
|
const parent = stack.at(-1);
|
|
202119
202127
|
if (!tok) {
|
|
@@ -202309,7 +202317,8 @@ function parseHeaderVersion(bytes) {
|
|
|
202309
202317
|
}
|
|
202310
202318
|
return head.slice(idx + 5, idx + 8);
|
|
202311
202319
|
}
|
|
202312
|
-
function
|
|
202320
|
+
function* parseObjectAtOffsetSteps(bytes, offset, maxRecursionDepth, repair = false) {
|
|
202321
|
+
yield;
|
|
202313
202322
|
const lexer = new CosByteLexer(bytes, offset);
|
|
202314
202323
|
const objNumTok = lexer.nextToken();
|
|
202315
202324
|
const genNumTok = lexer.nextToken();
|
|
@@ -202317,7 +202326,7 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
|
|
|
202317
202326
|
if (objNumTok?.kind !== "number" || genNumTok?.kind !== "number" || objKwTok?.kind !== "keyword" || objKwTok.value !== "obj") {
|
|
202318
202327
|
throw new PdfError2("E_PARSE", `Malformed indirect object header at byte offset ${offset}`);
|
|
202319
202328
|
}
|
|
202320
|
-
const value3 =
|
|
202329
|
+
const value3 = yield* parseNodeFromLexerSteps(lexer, bytes, maxRecursionDepth, repair);
|
|
202321
202330
|
if (!value3) {
|
|
202322
202331
|
throw new PdfError2("E_PARSE", `Empty indirect object ${objNumTok.value} at offset ${offset}`);
|
|
202323
202332
|
}
|
|
@@ -202328,7 +202337,9 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
|
|
|
202328
202337
|
span: { start: objNumTok.span.start, end: lexer.offset }
|
|
202329
202338
|
};
|
|
202330
202339
|
}
|
|
202331
|
-
function
|
|
202340
|
+
function* parseXrefRevisionAtSteps(bytes, xrefOffset, maxDecompressedBytes, maxRecursionDepth, maxObjects) {
|
|
202341
|
+
yield;
|
|
202342
|
+
let work = 0;
|
|
202332
202343
|
if (xrefOffset < 0 || xrefOffset >= bytes.length) {
|
|
202333
202344
|
throw new PdfError2("E_PARSE", `Invalid xref offset: ${xrefOffset}`);
|
|
202334
202345
|
}
|
|
@@ -202340,6 +202351,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
202340
202351
|
if (firstTok.kind === "keyword" && firstTok.value === "xref") {
|
|
202341
202352
|
const entries22 = /* @__PURE__ */ new Map();
|
|
202342
202353
|
while (true) {
|
|
202354
|
+
if (++work % 16 === 0) yield;
|
|
202343
202355
|
const saved = lexer.offset;
|
|
202344
202356
|
const tok = lexer.nextToken();
|
|
202345
202357
|
if (!tok) {
|
|
@@ -202363,6 +202375,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
202363
202375
|
}
|
|
202364
202376
|
if (count > maxObjects + 1) throw new PdfError2("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
|
|
202365
202377
|
for (let i = 0; i < count; i++) {
|
|
202378
|
+
if (++work % 16 === 0) yield;
|
|
202366
202379
|
const offTok = lexer.nextToken();
|
|
202367
202380
|
const genTok = lexer.nextToken();
|
|
202368
202381
|
const flagTok = lexer.nextToken();
|
|
@@ -202388,7 +202401,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
202388
202401
|
if (entries22.size > maxObjects + 1) throw new PdfError2("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
|
|
202389
202402
|
}
|
|
202390
202403
|
}
|
|
202391
|
-
const trailerNode =
|
|
202404
|
+
const trailerNode = yield* parseNodeFromLexerSteps(lexer, bytes, maxRecursionDepth);
|
|
202392
202405
|
if (!trailerNode || trailerNode.kind !== "dict") {
|
|
202393
202406
|
throw new PdfError2("E_PARSE", "Missing trailer dictionary after xref table");
|
|
202394
202407
|
}
|
|
@@ -202400,7 +202413,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
202400
202413
|
previousXrefOffset: prevNode2?.kind === "number" ? prevNode2.value : void 0
|
|
202401
202414
|
};
|
|
202402
202415
|
}
|
|
202403
|
-
const xrefObj =
|
|
202416
|
+
const xrefObj = yield* parseObjectAtOffsetSteps(bytes, xrefOffset, maxRecursionDepth);
|
|
202404
202417
|
if (xrefObj.value.kind !== "stream") {
|
|
202405
202418
|
throw new PdfError2("E_PARSE", `Expected xref table or XRef stream at offset ${xrefOffset}`);
|
|
202406
202419
|
}
|
|
@@ -202421,6 +202434,7 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
202421
202434
|
if (indexArray) {
|
|
202422
202435
|
if (indexArray.kind !== "array" || indexArray.items.length % 2 !== 0) throw new PdfError2("E_PARSE", "Invalid XRef range fields");
|
|
202423
202436
|
for (let i = 0; i < indexArray.items.length; i += 2) {
|
|
202437
|
+
if (++work % 16 === 0) yield;
|
|
202424
202438
|
const first = indexArray.items[i];
|
|
202425
202439
|
const count = indexArray.items[i + 1];
|
|
202426
202440
|
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)) {
|
|
@@ -202443,9 +202457,11 @@ function parseXrefRevisionAt(bytes, xrefOffset, maxDecompressedBytes, maxRecursi
|
|
|
202443
202457
|
return v;
|
|
202444
202458
|
};
|
|
202445
202459
|
for (const [startObj, count] of subsections) {
|
|
202460
|
+
if (++work % 16 === 0) yield;
|
|
202446
202461
|
if (count > (decoded.length - pos) / stride) throw new PdfError2("E_PARSE", "Truncated XRef stream");
|
|
202447
202462
|
if (count > maxObjects + 1) throw new PdfError2("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
|
|
202448
202463
|
for (let i = 0; i < count; i++) {
|
|
202464
|
+
if (++work % 16 === 0) yield;
|
|
202449
202465
|
const objNum = startObj + i;
|
|
202450
202466
|
const field0 = w0 > 0 ? readInt(w0) : 1;
|
|
202451
202467
|
const field1 = readInt(w1);
|
|
@@ -202491,12 +202507,16 @@ function isAsciiWhitespace(ch3) {
|
|
|
202491
202507
|
function isAsciiDigit(ch3) {
|
|
202492
202508
|
return ch3 >= 48 && ch3 <= 57;
|
|
202493
202509
|
}
|
|
202494
|
-
function
|
|
202510
|
+
function* repairScanCosDocumentSteps(bytes, maxObjects, maxRecursionDepth) {
|
|
202511
|
+
yield;
|
|
202512
|
+
let work = 0;
|
|
202495
202513
|
const objects = /* @__PURE__ */ new Map();
|
|
202496
202514
|
const trailers = [];
|
|
202497
202515
|
let pos = 0;
|
|
202498
202516
|
while (pos < bytes.length) {
|
|
202517
|
+
if (++work % 16 === 0) yield;
|
|
202499
202518
|
while (pos < bytes.length && !isAsciiDigit(bytes[pos])) {
|
|
202519
|
+
if (++work % 16 === 0) yield;
|
|
202500
202520
|
if (bytes[pos] === 37) {
|
|
202501
202521
|
while (pos < bytes.length && bytes[pos] !== 10 && bytes[pos] !== 13) pos++;
|
|
202502
202522
|
continue;
|
|
@@ -202506,7 +202526,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
|
|
|
202506
202526
|
try {
|
|
202507
202527
|
const token = lexer.nextToken();
|
|
202508
202528
|
if (token?.kind === "keyword" && token.value === "trailer") {
|
|
202509
|
-
const trailer =
|
|
202529
|
+
const trailer = yield* parseNodeFromLexerSteps(lexer, bytes, maxRecursionDepth, true);
|
|
202510
202530
|
if (trailer?.kind === "dict") trailers.push(trailer);
|
|
202511
202531
|
pos = lexer.offset;
|
|
202512
202532
|
continue;
|
|
@@ -202539,7 +202559,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
|
|
|
202539
202559
|
bytes[pos + 3] === 40)) {
|
|
202540
202560
|
pos += 3;
|
|
202541
202561
|
try {
|
|
202542
|
-
const parsed =
|
|
202562
|
+
const parsed = yield* parseObjectAtOffsetSteps(bytes, headerStart, maxRecursionDepth, true);
|
|
202543
202563
|
objects.set(parsed.objectNumber, parsed);
|
|
202544
202564
|
if (parsed.value.kind === "stream") {
|
|
202545
202565
|
const type = dictGet(parsed.value.dict, "Type");
|
|
@@ -202556,13 +202576,17 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
|
|
|
202556
202576
|
}
|
|
202557
202577
|
return { objects, trailers };
|
|
202558
202578
|
}
|
|
202559
|
-
function
|
|
202579
|
+
function* unpackRecoveredObjectsSteps(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth) {
|
|
202580
|
+
yield;
|
|
202581
|
+
let work = 0;
|
|
202560
202582
|
for (const obj of [...objects.values()]) {
|
|
202583
|
+
if (++work % 16 === 0) yield;
|
|
202561
202584
|
if (obj.value.kind === "stream") {
|
|
202562
202585
|
const t = dictGet(obj.value.dict, "Type");
|
|
202563
202586
|
if (t?.kind === "name" && t.decoded === "ObjStm") {
|
|
202564
202587
|
try {
|
|
202565
|
-
for (const [unpackedNum, unpackedVal] of
|
|
202588
|
+
for (const [unpackedNum, unpackedVal] of (yield* unpackObjectStreamSteps(obj.value, maxDecompressedBytes, maxRecursionDepth, true)).entries()) {
|
|
202589
|
+
if (++work % 16 === 0) yield;
|
|
202566
202590
|
if (!objects.has(unpackedNum)) {
|
|
202567
202591
|
objects.set(unpackedNum, {
|
|
202568
202592
|
objectNumber: unpackedNum,
|
|
@@ -202598,7 +202622,9 @@ function recoveredReferences(objects) {
|
|
|
202598
202622
|
}
|
|
202599
202623
|
return { ...rootRef ? { rootRef } : {}, ...infoRef ? { infoRef } : {} };
|
|
202600
202624
|
}
|
|
202601
|
-
function
|
|
202625
|
+
function* unpackObjectStreamSteps(streamObj, maxDecompressedBytes, maxRecursionDepth, repair = false) {
|
|
202626
|
+
yield;
|
|
202627
|
+
let work = 0;
|
|
202602
202628
|
const nNode = dictGet(streamObj.dict, "N");
|
|
202603
202629
|
const firstNode = dictGet(streamObj.dict, "First");
|
|
202604
202630
|
if (nNode?.kind !== "number" || firstNode?.kind !== "number") {
|
|
@@ -202608,6 +202634,7 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth,
|
|
|
202608
202634
|
const headerLexer = new CosByteLexer(decoded, 0);
|
|
202609
202635
|
const pairs = [];
|
|
202610
202636
|
for (let i = 0; i < nNode.value; i++) {
|
|
202637
|
+
if (++work % 16 === 0) yield;
|
|
202611
202638
|
const numTok = headerLexer.nextToken();
|
|
202612
202639
|
const offTok = headerLexer.nextToken();
|
|
202613
202640
|
if (numTok?.kind === "number" && offTok?.kind === "number") {
|
|
@@ -202616,9 +202643,10 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth,
|
|
|
202616
202643
|
}
|
|
202617
202644
|
const result2 = /* @__PURE__ */ new Map();
|
|
202618
202645
|
for (const pair of pairs) {
|
|
202646
|
+
if (++work % 16 === 0) yield;
|
|
202619
202647
|
try {
|
|
202620
202648
|
const valLexer = new CosByteLexer(decoded, firstNode.value + pair.relativeOffset);
|
|
202621
|
-
const node3 =
|
|
202649
|
+
const node3 = yield* parseNodeFromLexerSteps(valLexer, decoded, maxRecursionDepth, repair);
|
|
202622
202650
|
if (node3) {
|
|
202623
202651
|
result2.set(pair.objectNumber, node3);
|
|
202624
202652
|
}
|
|
@@ -202628,7 +202656,9 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth,
|
|
|
202628
202656
|
}
|
|
202629
202657
|
return result2;
|
|
202630
202658
|
}
|
|
202631
|
-
function
|
|
202659
|
+
function* parseCosDocumentSteps(bytes, options = {}) {
|
|
202660
|
+
yield;
|
|
202661
|
+
let work = 0;
|
|
202632
202662
|
const version = parseHeaderVersion(bytes);
|
|
202633
202663
|
const recovery = options.recovery ?? "strict";
|
|
202634
202664
|
const maxObjects = options.maxObjects ?? Infinity;
|
|
@@ -202663,10 +202693,12 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
202663
202693
|
let currentXrefOffset = offsetTok.value;
|
|
202664
202694
|
const visitedOffsets = /* @__PURE__ */ new Set();
|
|
202665
202695
|
while (currentXrefOffset !== void 0 && !visitedOffsets.has(currentXrefOffset)) {
|
|
202696
|
+
if (++work % 16 === 0) yield;
|
|
202666
202697
|
visitedOffsets.add(currentXrefOffset);
|
|
202667
|
-
const rev =
|
|
202698
|
+
const rev = yield* parseXrefRevisionAtSteps(bytes, currentXrefOffset, maxDecompressedBytes, maxRecursionDepth, maxObjects);
|
|
202668
202699
|
revisions.push(rev);
|
|
202669
202700
|
for (const [num, entry2] of rev.entries.entries()) {
|
|
202701
|
+
if (++work % 16 === 0) yield;
|
|
202670
202702
|
if (!mergedXref.has(num)) {
|
|
202671
202703
|
mergedXref.set(num, entry2);
|
|
202672
202704
|
if (mergedXref.size > maxObjects + 1) throw new PdfError2("E_LIMIT", "PDF object count limit exceeded while reading xref entries");
|
|
@@ -202699,8 +202731,9 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
202699
202731
|
if (!useRepair && rootRef) {
|
|
202700
202732
|
try {
|
|
202701
202733
|
for (const [objNum, entry2] of mergedXref.entries()) {
|
|
202734
|
+
if (++work % 16 === 0) yield;
|
|
202702
202735
|
if (entry2.type !== "uncompressed") continue;
|
|
202703
|
-
const parsed =
|
|
202736
|
+
const parsed = yield* parseObjectAtOffsetSteps(bytes, entry2.offset ?? 0, maxRecursionDepth, recovery === "repair");
|
|
202704
202737
|
if (parsed.objectNumber !== objNum || parsed.generationNumber !== (entry2.generationNumber ?? 0)) {
|
|
202705
202738
|
throw new PdfError2("E_PARSE", `Bad uncompressed XRef entry for object ${objNum}`);
|
|
202706
202739
|
}
|
|
@@ -202718,7 +202751,7 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
202718
202751
|
throw new PdfError2("E_PARSE", "PDF trailer missing /Root reference");
|
|
202719
202752
|
}
|
|
202720
202753
|
useRepair = true;
|
|
202721
|
-
const scanned =
|
|
202754
|
+
const scanned = yield* repairScanCosDocumentSteps(bytes, maxObjects, maxRecursionDepth);
|
|
202722
202755
|
objects = scanned.objects;
|
|
202723
202756
|
revisions.length = 0;
|
|
202724
202757
|
mergedXref.clear();
|
|
@@ -202753,7 +202786,7 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
202753
202786
|
encryptNode = encrypt2?.kind === "ref" || encrypt2?.kind === "dict" ? encrypt2 : void 0;
|
|
202754
202787
|
encryptRef = encrypt2?.kind === "ref" ? encrypt2 : void 0;
|
|
202755
202788
|
idArray = id?.kind === "array" ? id : void 0;
|
|
202756
|
-
if (!rootRef && !encryptNode)
|
|
202789
|
+
if (!rootRef && !encryptNode) yield* unpackRecoveredObjectsSteps(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth);
|
|
202757
202790
|
const fallback = recoveredReferences(objects);
|
|
202758
202791
|
rootRef ??= fallback.rootRef;
|
|
202759
202792
|
infoRef ??= fallback.infoRef;
|
|
@@ -202788,20 +202821,21 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
202788
202821
|
maxRecursionDepth
|
|
202789
202822
|
});
|
|
202790
202823
|
doc.encryption = encState;
|
|
202791
|
-
|
|
202824
|
+
yield* decryptCosDocumentSteps(doc, encState);
|
|
202792
202825
|
}
|
|
202793
202826
|
if (useRepair) {
|
|
202794
|
-
|
|
202827
|
+
yield* unpackRecoveredObjectsSteps(objects, maxObjects, maxDecompressedBytes, maxRecursionDepth);
|
|
202795
202828
|
doc.infoRef ??= recoveredReferences(objects).infoRef;
|
|
202796
202829
|
}
|
|
202797
202830
|
const objStmCache = /* @__PURE__ */ new Map();
|
|
202798
202831
|
for (const [objNum, entry2] of mergedXref.entries()) {
|
|
202832
|
+
if (++work % 16 === 0) yield;
|
|
202799
202833
|
if (entry2.type === "compressed" && entry2.objectStreamNumber !== void 0) {
|
|
202800
202834
|
let unpacked = objStmCache.get(entry2.objectStreamNumber);
|
|
202801
202835
|
if (!unpacked) {
|
|
202802
202836
|
const stmObj = objects.get(entry2.objectStreamNumber)?.value;
|
|
202803
202837
|
if (stmObj?.kind === "stream") {
|
|
202804
|
-
unpacked =
|
|
202838
|
+
unpacked = yield* unpackObjectStreamSteps(stmObj, maxDecompressedBytes, maxRecursionDepth, recovery === "repair");
|
|
202805
202839
|
objStmCache.set(entry2.objectStreamNumber, unpacked);
|
|
202806
202840
|
}
|
|
202807
202841
|
}
|
|
@@ -202818,6 +202852,9 @@ function parseCosDocument(bytes, options = {}) {
|
|
|
202818
202852
|
}
|
|
202819
202853
|
return doc;
|
|
202820
202854
|
}
|
|
202855
|
+
function parseCosDocument(bytes, options = {}) {
|
|
202856
|
+
return drainWork(parseCosDocumentSteps(bytes, options));
|
|
202857
|
+
}
|
|
202821
202858
|
var WIN_ANSI_HIGH_BYTES = {
|
|
202822
202859
|
128: 8364,
|
|
202823
202860
|
130: 8218,
|
|
@@ -213848,7 +213885,8 @@ function resolveInheritedFieldEntry(doc, dict, key) {
|
|
|
213848
213885
|
}
|
|
213849
213886
|
return void 0;
|
|
213850
213887
|
}
|
|
213851
|
-
function
|
|
213888
|
+
function* collectFieldDictsSteps(doc, node3, prefix = "", out = [], parentFt = "", parentFf = 0, parentQ = 0, parentMaxLen, yieldState = { work: 0 }) {
|
|
213889
|
+
if (++yieldState.work % 256 === 0) yield;
|
|
213852
213890
|
const dict = doc.resolveDict(node3);
|
|
213853
213891
|
if (!dict) return out;
|
|
213854
213892
|
const tNode = doc.resolve(dictGet(dict, "T"));
|
|
@@ -213881,7 +213919,8 @@ function collectFieldDicts(doc, node3, prefix = "", out = [], parentFt = "", par
|
|
|
213881
213919
|
return out;
|
|
213882
213920
|
}
|
|
213883
213921
|
for (const kid of kidsArr.items) {
|
|
213884
|
-
|
|
213922
|
+
if (++yieldState.work % 16 === 0) yield;
|
|
213923
|
+
yield* collectFieldDictsSteps(doc, kid, fullName, out, currentFt, currentFf, currentQ, currentMaxLen, yieldState);
|
|
213885
213924
|
}
|
|
213886
213925
|
} else if (fullName) {
|
|
213887
213926
|
out.push({
|
|
@@ -214322,6 +214361,9 @@ function escapePdfLiteralString(str2) {
|
|
|
214322
214361
|
}
|
|
214323
214362
|
return out;
|
|
214324
214363
|
}
|
|
214364
|
+
function collectFieldDicts(doc, node3, prefix = "", out = [], parentFt = "", parentFf = 0, parentQ = 0, parentMaxLen) {
|
|
214365
|
+
drainWork(collectFieldDictsSteps(doc, node3, prefix, out, parentFt, parentFf, parentQ, parentMaxLen));
|
|
214366
|
+
}
|
|
214325
214367
|
var PdfPage = class {
|
|
214326
214368
|
cosDoc;
|
|
214327
214369
|
pageRef;
|
|
@@ -216807,14 +216849,18 @@ var PdfDocument = class _PdfDocument {
|
|
|
216807
216849
|
});
|
|
216808
216850
|
return new _PdfDocument(parseCosDocument(rawBytes));
|
|
216809
216851
|
}
|
|
216810
|
-
static
|
|
216852
|
+
static *loadSteps(bytes, options) {
|
|
216853
|
+
yield;
|
|
216811
216854
|
return new _PdfDocument(
|
|
216812
|
-
|
|
216855
|
+
yield* parseCosDocumentSteps(bytes, {
|
|
216813
216856
|
...options,
|
|
216814
216857
|
recovery: options?.recovery ?? "repair"
|
|
216815
216858
|
})
|
|
216816
216859
|
);
|
|
216817
216860
|
}
|
|
216861
|
+
static load(bytes, options) {
|
|
216862
|
+
return drainWork(_PdfDocument.loadSteps(bytes, options));
|
|
216863
|
+
}
|
|
216818
216864
|
rebuildPagesList() {
|
|
216819
216865
|
const catalog = this.cos.resolveDict(this.cos.rootRef);
|
|
216820
216866
|
const pagesNode = catalog ? dictGet(catalog, "Pages") : void 0;
|
|
@@ -216896,20 +216942,30 @@ var PdfDocument = class _PdfDocument {
|
|
|
216896
216942
|
this.pages.splice(index2, 1);
|
|
216897
216943
|
this.syncPageTree();
|
|
216898
216944
|
}
|
|
216899
|
-
|
|
216945
|
+
*copyPagesFromSteps(sourceDoc, indices) {
|
|
216946
|
+
function* cloneItems(items) {
|
|
216947
|
+
const result2 = [];
|
|
216948
|
+
for (const item of items) result2.push(yield* cloneNode(item));
|
|
216949
|
+
return result2;
|
|
216950
|
+
}
|
|
216951
|
+
yield;
|
|
216952
|
+
let work = 0;
|
|
216900
216953
|
const memo = /* @__PURE__ */ new Map();
|
|
216901
216954
|
const sourcePageObjNums = /* @__PURE__ */ new Set();
|
|
216902
216955
|
for (let i = 0; i < sourceDoc.getPageCount(); i++) {
|
|
216956
|
+
if (++work % 16 === 0) yield;
|
|
216903
216957
|
sourcePageObjNums.add(sourceDoc.getPage(i).ref.objectNumber);
|
|
216904
216958
|
}
|
|
216905
216959
|
const targetPageRefs = [];
|
|
216906
216960
|
for (const idx of indices) {
|
|
216961
|
+
if (++work % 16 === 0) yield;
|
|
216907
216962
|
const srcPage = sourceDoc.getPage(idx);
|
|
216908
216963
|
const pageRef = this.cos.allocateObject({ kind: "null" });
|
|
216909
216964
|
targetPageRefs.push(pageRef);
|
|
216910
216965
|
memo.set(srcPage.ref.objectNumber, pageRef);
|
|
216911
216966
|
}
|
|
216912
|
-
const cloneNode = (node3)
|
|
216967
|
+
const cloneNode = function* (node3) {
|
|
216968
|
+
if (++work % 16 === 0) yield;
|
|
216913
216969
|
if (node3.kind === "ref") {
|
|
216914
216970
|
const existing = memo.get(node3.objectNumber);
|
|
216915
216971
|
if (existing) return existing;
|
|
@@ -216920,12 +216976,12 @@ var PdfDocument = class _PdfDocument {
|
|
|
216920
216976
|
if (!target) return cosRef(0);
|
|
216921
216977
|
const placeholderRef = this.cos.allocateObject({ kind: "null" });
|
|
216922
216978
|
memo.set(node3.objectNumber, placeholderRef);
|
|
216923
|
-
const clonedTarget = cloneNode(target);
|
|
216979
|
+
const clonedTarget = yield* cloneNode(target);
|
|
216924
216980
|
this.cos.setObject(placeholderRef.objectNumber, clonedTarget, 0);
|
|
216925
216981
|
return placeholderRef;
|
|
216926
216982
|
}
|
|
216927
216983
|
if (node3.kind === "array") {
|
|
216928
|
-
return cosArray(node3.items
|
|
216984
|
+
return cosArray(yield* cloneItems(node3.items));
|
|
216929
216985
|
}
|
|
216930
216986
|
if (node3.kind === "dict") {
|
|
216931
216987
|
const typeEntry = dictGet(node3, "Type");
|
|
@@ -216935,13 +216991,13 @@ var PdfDocument = class _PdfDocument {
|
|
|
216935
216991
|
if (isPageTreeNode && entry2.key.decoded === "Parent") continue;
|
|
216936
216992
|
newEntries.push({
|
|
216937
216993
|
key: { ...entry2.key },
|
|
216938
|
-
value: cloneNode(entry2.value)
|
|
216994
|
+
value: yield* cloneNode(entry2.value)
|
|
216939
216995
|
});
|
|
216940
216996
|
}
|
|
216941
216997
|
return { kind: "dict", entries: newEntries };
|
|
216942
216998
|
}
|
|
216943
216999
|
if (node3.kind === "stream") {
|
|
216944
|
-
const clonedDict = cloneNode(node3.dict);
|
|
217000
|
+
const clonedDict = yield* cloneNode(node3.dict);
|
|
216945
217001
|
return {
|
|
216946
217002
|
kind: "stream",
|
|
216947
217003
|
dict: clonedDict,
|
|
@@ -216950,11 +217006,12 @@ var PdfDocument = class _PdfDocument {
|
|
|
216950
217006
|
};
|
|
216951
217007
|
}
|
|
216952
217008
|
return node3;
|
|
216953
|
-
};
|
|
217009
|
+
}.bind(this);
|
|
216954
217010
|
const copiedPages = [];
|
|
216955
217011
|
for (const [position, idx] of indices.entries()) {
|
|
217012
|
+
if (++work % 16 === 0) yield;
|
|
216956
217013
|
const srcPage = sourceDoc.getPage(idx);
|
|
216957
|
-
const clonedPageDict = cloneNode(srcPage.pageDict);
|
|
217014
|
+
const clonedPageDict = yield* cloneNode(srcPage.pageDict);
|
|
216958
217015
|
const size = srcPage.getSize();
|
|
216959
217016
|
if (!dictGet(clonedPageDict, "MediaBox")) {
|
|
216960
217017
|
dictSet(
|
|
@@ -216964,13 +217021,14 @@ var PdfDocument = class _PdfDocument {
|
|
|
216964
217021
|
);
|
|
216965
217022
|
}
|
|
216966
217023
|
if (!dictGet(clonedPageDict, "Resources")) {
|
|
216967
|
-
dictSet(clonedPageDict, "Resources", cloneNode(srcPage.getResourcesDict()));
|
|
217024
|
+
dictSet(clonedPageDict, "Resources", yield* cloneNode(srcPage.getResourcesDict()));
|
|
216968
217025
|
}
|
|
216969
217026
|
if (!dictGet(clonedPageDict, "Rotate") && srcPage.getRotation() !== 0) {
|
|
216970
217027
|
dictSet(clonedPageDict, "Rotate", cosNumber(srcPage.getRotation()));
|
|
216971
217028
|
}
|
|
216972
217029
|
const inheritedBoxKeys = ["CropBox", "BleedBox", "TrimBox", "ArtBox"];
|
|
216973
217030
|
for (const boxKey of inheritedBoxKeys) {
|
|
217031
|
+
if (++work % 16 === 0) yield;
|
|
216974
217032
|
if (!dictGet(clonedPageDict, boxKey)) {
|
|
216975
217033
|
const boxVal = boxKey === "CropBox" ? srcPage.getCropBox() : boxKey === "BleedBox" ? srcPage.getBleedBox() : boxKey === "TrimBox" ? srcPage.getTrimBox() : srcPage.getArtBox();
|
|
216976
217034
|
if (boxVal[0] !== 0 || boxVal[1] !== 0 || boxVal[2] !== size.width || boxVal[3] !== size.height) {
|
|
@@ -217012,8 +217070,9 @@ var PdfDocument = class _PdfDocument {
|
|
|
217012
217070
|
};
|
|
217013
217071
|
const clonedRootFieldRefs = [];
|
|
217014
217072
|
for (const item of srcFieldsArr.items) {
|
|
217073
|
+
if (++work % 16 === 0) yield;
|
|
217015
217074
|
if (!hasClonedDescendant(item)) continue;
|
|
217016
|
-
const cloned = cloneNode(item);
|
|
217075
|
+
const cloned = yield* cloneNode(item);
|
|
217017
217076
|
if (cloned.kind === "ref") {
|
|
217018
217077
|
const clonedDict = this.cos.resolveDict(cloned);
|
|
217019
217078
|
const kidsArr = clonedDict ? this.cos.resolveArray(dictGet(clonedDict, "Kids")) : void 0;
|
|
@@ -217047,6 +217106,7 @@ var PdfDocument = class _PdfDocument {
|
|
|
217047
217106
|
dstFields.items.filter((x) => x.kind === "ref").map((x) => x.objectNumber)
|
|
217048
217107
|
);
|
|
217049
217108
|
for (const fRef of clonedRootFieldRefs) {
|
|
217109
|
+
if (++work % 16 === 0) yield;
|
|
217050
217110
|
if (!existingNums.has(fRef.objectNumber)) {
|
|
217051
217111
|
dstFields.items.push(fRef);
|
|
217052
217112
|
existingNums.add(fRef.objectNumber);
|
|
@@ -217054,11 +217114,11 @@ var PdfDocument = class _PdfDocument {
|
|
|
217054
217114
|
}
|
|
217055
217115
|
const srcDr = dictGet(srcAcroForm, "DR");
|
|
217056
217116
|
if (srcDr && !dictGet(dstAcroForm, "DR")) {
|
|
217057
|
-
dictSet(dstAcroForm, "DR", cloneNode(srcDr));
|
|
217117
|
+
dictSet(dstAcroForm, "DR", yield* cloneNode(srcDr));
|
|
217058
217118
|
}
|
|
217059
217119
|
const srcDa = dictGet(srcAcroForm, "DA");
|
|
217060
217120
|
if (srcDa && !dictGet(dstAcroForm, "DA")) {
|
|
217061
|
-
dictSet(dstAcroForm, "DA", cloneNode(srcDa));
|
|
217121
|
+
dictSet(dstAcroForm, "DA", yield* cloneNode(srcDa));
|
|
217062
217122
|
}
|
|
217063
217123
|
}
|
|
217064
217124
|
}
|
|
@@ -217067,12 +217127,15 @@ var PdfDocument = class _PdfDocument {
|
|
|
217067
217127
|
if (srcOcProps) {
|
|
217068
217128
|
const dstCatalog = this.cos.resolveDict(this.cos.rootRef);
|
|
217069
217129
|
if (dstCatalog && !dictGet(dstCatalog, "OCProperties")) {
|
|
217070
|
-
dictSet(dstCatalog, "OCProperties", cloneNode(srcOcProps));
|
|
217130
|
+
dictSet(dstCatalog, "OCProperties", yield* cloneNode(srcOcProps));
|
|
217071
217131
|
}
|
|
217072
217132
|
}
|
|
217073
217133
|
this.syncPageTree();
|
|
217074
217134
|
return copiedPages;
|
|
217075
217135
|
}
|
|
217136
|
+
copyPagesFrom(sourceDoc, indices) {
|
|
217137
|
+
return drainWork(this.copyPagesFromSteps(sourceDoc, indices));
|
|
217138
|
+
}
|
|
217076
217139
|
embedStandardFont(fontName) {
|
|
217077
217140
|
return createStandardFontHandle(fontName);
|
|
217078
217141
|
}
|
|
@@ -217272,14 +217335,15 @@ var PdfDocument = class _PdfDocument {
|
|
|
217272
217335
|
});
|
|
217273
217336
|
return buildSemanticAstFromPages(extractedPages, tablesByPage, displayLists);
|
|
217274
217337
|
}
|
|
217275
|
-
|
|
217338
|
+
*saveSteps(options = {}) {
|
|
217339
|
+
yield;
|
|
217276
217340
|
this.syncPageTree();
|
|
217277
217341
|
if (this.cos.requiresFullRewrite) {
|
|
217278
217342
|
pruneUnusedXObjects(this.cos, this.pages);
|
|
217279
217343
|
discardUnreachableObjects(this.cos);
|
|
217280
217344
|
}
|
|
217281
217345
|
if (options.encrypt) {
|
|
217282
|
-
return
|
|
217346
|
+
return yield* encryptCosDocumentSteps(this.cos, options.encrypt);
|
|
217283
217347
|
}
|
|
217284
217348
|
const allObjects = [...this.cos.objects.values()].sort(
|
|
217285
217349
|
(a3, b3) => a3.objectNumber - b3.objectNumber
|
|
@@ -217287,7 +217351,7 @@ var PdfDocument = class _PdfDocument {
|
|
|
217287
217351
|
if (options.incremental && !this.cos.requiresFullRewrite && this.cos.bytes.length > 0) {
|
|
217288
217352
|
return appendIncrementalRevision(this.cos.bytes, this.cos, allObjects);
|
|
217289
217353
|
}
|
|
217290
|
-
return
|
|
217354
|
+
return yield* serializeCosDocumentSteps({
|
|
217291
217355
|
objects: allObjects,
|
|
217292
217356
|
rootRef: this.cos.rootRef,
|
|
217293
217357
|
infoRef: this.cos.infoRef,
|
|
@@ -217298,6 +217362,9 @@ var PdfDocument = class _PdfDocument {
|
|
|
217298
217362
|
linearize: options.linearize
|
|
217299
217363
|
});
|
|
217300
217364
|
}
|
|
217365
|
+
save(options = {}) {
|
|
217366
|
+
return drainWork(this.saveSteps(options));
|
|
217367
|
+
}
|
|
217301
217368
|
};
|
|
217302
217369
|
function isPdfBytes(bytes) {
|
|
217303
217370
|
if (bytes.length < 5) return false;
|