@hussmartinez/pdf-sdk 0.0.0-stage → 0.2.0
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/LICENSE +202 -0
- package/NOTICE +66 -0
- package/README.md +119 -2
- package/dist/assets/pdfjs/build/pdf.worker.min.mjs +28 -0
- package/dist/assets/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/dist/assets/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/assets/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GB-H.bcmap +4 -0
- package/dist/assets/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/LICENSE +36 -0
- package/dist/assets/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/Roman.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/V.bcmap +0 -0
- package/dist/assets/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/assets/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/assets/pdfjs/iccs/LICENSE +116 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/assets/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/assets/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/assets/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/assets/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/assets/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/assets/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/assets/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/assets/processing/processing.worker.js +57 -0
- package/dist/assets/processing/qpdf.wasm +0 -0
- package/dist/element.d.ts +12 -0
- package/dist/element.js +0 -0
- package/dist/index.d.ts +1304 -0
- package/dist/index.js +1 -0
- package/dist/lazy/78-EUC-H.bcmap-sYP3SMNV.js +3 -0
- package/dist/lazy/78-EUC-V.bcmap-w3SY_Y_q.js +3 -0
- package/dist/lazy/78-H.bcmap-CeA2DrtT.js +3 -0
- package/dist/lazy/78-RKSJ-H.bcmap-D4cLhL3_.js +3 -0
- package/dist/lazy/78-RKSJ-V.bcmap-DdK1ZiTU.js +3 -0
- package/dist/lazy/78-V.bcmap-CVoLO4i0.js +3 -0
- package/dist/lazy/78ms-RKSJ-H.bcmap-B20DW4UH.js +3 -0
- package/dist/lazy/78ms-RKSJ-V.bcmap-CLnY5REh.js +3 -0
- package/dist/lazy/83pv-RKSJ-H.bcmap-Ck3Sc38p.js +3 -0
- package/dist/lazy/90ms-RKSJ-H.bcmap-C-vgp7Oe.js +3 -0
- package/dist/lazy/90ms-RKSJ-V.bcmap-CnYvCBfH.js +3 -0
- package/dist/lazy/90msp-RKSJ-H.bcmap-BIx2U_Lw.js +3 -0
- package/dist/lazy/90msp-RKSJ-V.bcmap-LSpKnFnA.js +3 -0
- package/dist/lazy/90pv-RKSJ-H.bcmap-ohvXiazb.js +3 -0
- package/dist/lazy/90pv-RKSJ-V.bcmap-DiMSuPqu.js +3 -0
- package/dist/lazy/Add-H.bcmap-D50q_cPt.js +3 -0
- package/dist/lazy/Add-RKSJ-H.bcmap-DLQ79XiS.js +3 -0
- package/dist/lazy/Add-RKSJ-V.bcmap-DgMvx1Yl.js +3 -0
- package/dist/lazy/Add-V.bcmap-njFd39xE.js +3 -0
- package/dist/lazy/Adobe-CNS1-0.bcmap-DC9aIYc6.js +3 -0
- package/dist/lazy/Adobe-CNS1-1.bcmap-CjXhkA0W.js +3 -0
- package/dist/lazy/Adobe-CNS1-2.bcmap-BfDCyJYh.js +3 -0
- package/dist/lazy/Adobe-CNS1-3.bcmap-C5_dNXD-.js +3 -0
- package/dist/lazy/Adobe-CNS1-4.bcmap-DkB6y9PJ.js +3 -0
- package/dist/lazy/Adobe-CNS1-5.bcmap-13hTC0vp.js +3 -0
- package/dist/lazy/Adobe-CNS1-6.bcmap-CcQ66yT1.js +3 -0
- package/dist/lazy/Adobe-CNS1-UCS2.bcmap-jD7ZNdHN.js +3 -0
- package/dist/lazy/Adobe-GB1-0.bcmap-CwfHCw6h.js +3 -0
- package/dist/lazy/Adobe-GB1-1.bcmap-DRWrCran.js +3 -0
- package/dist/lazy/Adobe-GB1-2.bcmap-0nedEhcq.js +3 -0
- package/dist/lazy/Adobe-GB1-3.bcmap-Cq3lCVsW.js +3 -0
- package/dist/lazy/Adobe-GB1-4.bcmap-BzTb6Nsg.js +3 -0
- package/dist/lazy/Adobe-GB1-5.bcmap-BUHSmz5c.js +3 -0
- package/dist/lazy/Adobe-GB1-UCS2.bcmap-DUfIxWQW.js +3 -0
- package/dist/lazy/Adobe-Japan1-0.bcmap-BjG9GiRM.js +3 -0
- package/dist/lazy/Adobe-Japan1-1.bcmap-DQTj-iQt.js +3 -0
- package/dist/lazy/Adobe-Japan1-2.bcmap-BOsCSmmm.js +3 -0
- package/dist/lazy/Adobe-Japan1-3.bcmap-ChGf7g8t.js +3 -0
- package/dist/lazy/Adobe-Japan1-4.bcmap-CI6iUMgQ.js +3 -0
- package/dist/lazy/Adobe-Japan1-5.bcmap-kbwPceJO.js +3 -0
- package/dist/lazy/Adobe-Japan1-6.bcmap-CAvvqYpW.js +3 -0
- package/dist/lazy/Adobe-Japan1-UCS2.bcmap-DbZiEgfC.js +3 -0
- package/dist/lazy/Adobe-Korea1-0.bcmap-Der5jvBG.js +3 -0
- package/dist/lazy/Adobe-Korea1-1.bcmap-DafpcUyn.js +3 -0
- package/dist/lazy/Adobe-Korea1-2.bcmap-D1nh75yR.js +3 -0
- package/dist/lazy/Adobe-Korea1-UCS2.bcmap-CNeMfPHO.js +3 -0
- package/dist/lazy/B5-H.bcmap-gyhuoKf7.js +3 -0
- package/dist/lazy/B5-V.bcmap-BGqDqEjZ.js +3 -0
- package/dist/lazy/B5pc-H.bcmap-C8B_dVbb.js +3 -0
- package/dist/lazy/B5pc-V.bcmap-ETo7py2B.js +3 -0
- package/dist/lazy/CNS-EUC-H.bcmap-BgwyrNdN.js +3 -0
- package/dist/lazy/CNS-EUC-V.bcmap-BbC68G9k.js +3 -0
- package/dist/lazy/CNS1-H.bcmap-DZIguuvp.js +3 -0
- package/dist/lazy/CNS1-V.bcmap-DjthPwLF.js +3 -0
- package/dist/lazy/CNS2-H.bcmap-CTuiQP8Z.js +3 -0
- package/dist/lazy/CNS2-V.bcmap-BU5ZzL4C.js +3 -0
- package/dist/lazy/ETHK-B5-H.bcmap-AYx-kODg.js +3 -0
- package/dist/lazy/ETHK-B5-V.bcmap-C_2Sxwdm.js +3 -0
- package/dist/lazy/ETen-B5-H.bcmap-BAKuplan.js +3 -0
- package/dist/lazy/ETen-B5-V.bcmap-Dnm6aXlS.js +3 -0
- package/dist/lazy/ETenms-B5-H.bcmap-DZ8Y3Rnc.js +3 -0
- package/dist/lazy/ETenms-B5-V.bcmap-DPnnTEiA.js +3 -0
- package/dist/lazy/EUC-H.bcmap-B1COGDXX.js +3 -0
- package/dist/lazy/EUC-V.bcmap-BRvFq5yx.js +3 -0
- package/dist/lazy/Ext-H.bcmap-CNU3PCfs.js +3 -0
- package/dist/lazy/Ext-RKSJ-H.bcmap-T22CGXk4.js +3 -0
- package/dist/lazy/Ext-RKSJ-V.bcmap-K2DXeZ3P.js +3 -0
- package/dist/lazy/Ext-V.bcmap-3sNuPEfV.js +3 -0
- package/dist/lazy/FoxitDingbats.pfb-DVieKaw5.js +3 -0
- package/dist/lazy/FoxitFixed.pfb-Cxgpn9hN.js +3 -0
- package/dist/lazy/FoxitFixedBold.pfb-SBojmP3G.js +3 -0
- package/dist/lazy/FoxitFixedBoldItalic.pfb-DhsbZ2IP.js +3 -0
- package/dist/lazy/FoxitFixedItalic.pfb-Dm09mdyI.js +3 -0
- package/dist/lazy/FoxitSerif.pfb-DyMzSE_0.js +3 -0
- package/dist/lazy/FoxitSerifBold.pfb-DTzLt76W.js +3 -0
- package/dist/lazy/FoxitSerifBoldItalic.pfb-X3fHgghe.js +3 -0
- package/dist/lazy/FoxitSerifItalic.pfb-Nz1cnSKc.js +3 -0
- package/dist/lazy/FoxitSymbol.pfb-BL-rU8nS.js +3 -0
- package/dist/lazy/GB-EUC-H.bcmap-CsgH6-Rh.js +3 -0
- package/dist/lazy/GB-EUC-V.bcmap-DUouvrJu.js +3 -0
- package/dist/lazy/GB-H.bcmap-CuVli79K.js +3 -0
- package/dist/lazy/GB-V.bcmap-C3uPsDRC.js +3 -0
- package/dist/lazy/GBK-EUC-H.bcmap-BBDA5YUr.js +3 -0
- package/dist/lazy/GBK-EUC-V.bcmap-CjEpjWSW.js +3 -0
- package/dist/lazy/GBK2K-H.bcmap-DEJkj1gN.js +3 -0
- package/dist/lazy/GBK2K-V.bcmap-NYgNeNsu.js +3 -0
- package/dist/lazy/GBKp-EUC-H.bcmap-BIQuHkue.js +3 -0
- package/dist/lazy/GBKp-EUC-V.bcmap-BNBPmQ4v.js +3 -0
- package/dist/lazy/GBT-EUC-H.bcmap-D7OWs_0J.js +3 -0
- package/dist/lazy/GBT-EUC-V.bcmap-D_rNNyCu.js +3 -0
- package/dist/lazy/GBT-H.bcmap-B4SLNj_c.js +3 -0
- package/dist/lazy/GBT-V.bcmap-Cq6Niv8e.js +3 -0
- package/dist/lazy/GBTpc-EUC-H.bcmap-CX8SXrun.js +3 -0
- package/dist/lazy/GBTpc-EUC-V.bcmap-hM7BhuwC.js +3 -0
- package/dist/lazy/GBpc-EUC-H.bcmap-BIEXt7KG.js +3 -0
- package/dist/lazy/GBpc-EUC-V.bcmap-DWeqNOzl.js +3 -0
- package/dist/lazy/H.bcmap-DsMNeuh7.js +3 -0
- package/dist/lazy/HKdla-B5-H.bcmap-CI5u0d4T.js +3 -0
- package/dist/lazy/HKdla-B5-V.bcmap-yk9YM4CN.js +3 -0
- package/dist/lazy/HKdlb-B5-H.bcmap-DenLwP2C.js +3 -0
- package/dist/lazy/HKdlb-B5-V.bcmap-BKFxIrzq.js +3 -0
- package/dist/lazy/HKgccs-B5-H.bcmap-i607pEmt.js +3 -0
- package/dist/lazy/HKgccs-B5-V.bcmap-BA9Nvcnu.js +3 -0
- package/dist/lazy/HKm314-B5-H.bcmap-BamdAWrg.js +3 -0
- package/dist/lazy/HKm314-B5-V.bcmap-JIFeW7D_.js +3 -0
- package/dist/lazy/HKm471-B5-H.bcmap-CIOwD0zn.js +3 -0
- package/dist/lazy/HKm471-B5-V.bcmap-BkDoTPME.js +3 -0
- package/dist/lazy/HKscs-B5-H.bcmap--SdxOf4z.js +3 -0
- package/dist/lazy/HKscs-B5-V.bcmap-DmqMO-Th.js +3 -0
- package/dist/lazy/Hankaku.bcmap-B2fyvO8A.js +3 -0
- package/dist/lazy/Hiragana.bcmap-DP3YLVOE.js +3 -0
- package/dist/lazy/KSC-EUC-H.bcmap-DQ5YvjA7.js +3 -0
- package/dist/lazy/KSC-EUC-V.bcmap-BNvwGfQX.js +3 -0
- package/dist/lazy/KSC-H.bcmap-Ca-HYPS4.js +3 -0
- package/dist/lazy/KSC-Johab-H.bcmap-CfF2UvBc.js +3 -0
- package/dist/lazy/KSC-Johab-V.bcmap-LBN9I8dg.js +3 -0
- package/dist/lazy/KSC-V.bcmap-5U7FPho3.js +3 -0
- package/dist/lazy/KSCms-UHC-H.bcmap-CmoPtsRN.js +3 -0
- package/dist/lazy/KSCms-UHC-HW-H.bcmap-CVBsfTPV.js +3 -0
- package/dist/lazy/KSCms-UHC-HW-V.bcmap-Dv90XUw-.js +3 -0
- package/dist/lazy/KSCms-UHC-V.bcmap-BlaojGc1.js +3 -0
- package/dist/lazy/KSCpc-EUC-H.bcmap-FrupvwaV.js +3 -0
- package/dist/lazy/KSCpc-EUC-V.bcmap-MG3GiZE4.js +3 -0
- package/dist/lazy/Katakana.bcmap-C8Bmgyhi.js +3 -0
- package/dist/lazy/NWP-H.bcmap-CAdIwPDs.js +3 -0
- package/dist/lazy/NWP-V.bcmap-DJ8FpnB4.js +3 -0
- package/dist/lazy/RKSJ-H.bcmap-qGRAHcEF.js +3 -0
- package/dist/lazy/RKSJ-V.bcmap-Dg3ddxaN.js +3 -0
- package/dist/lazy/Roman.bcmap-D4SBc9em.js +3 -0
- package/dist/lazy/UniCNS-UCS2-H.bcmap-CAjdESaO.js +3 -0
- package/dist/lazy/UniCNS-UCS2-V.bcmap-BHZM4Vzw.js +3 -0
- package/dist/lazy/UniCNS-UTF16-H.bcmap-Cm4ZnlrX.js +3 -0
- package/dist/lazy/UniCNS-UTF16-V.bcmap-BP1BFVyb.js +3 -0
- package/dist/lazy/UniCNS-UTF32-H.bcmap-DGLG7zQ_.js +3 -0
- package/dist/lazy/UniCNS-UTF32-V.bcmap-C6v0CIVn.js +3 -0
- package/dist/lazy/UniCNS-UTF8-H.bcmap-97YD5l2o.js +3 -0
- package/dist/lazy/UniCNS-UTF8-V.bcmap-B_zdNm-u.js +3 -0
- package/dist/lazy/UniGB-UCS2-H.bcmap-BcioIbCK.js +3 -0
- package/dist/lazy/UniGB-UCS2-V.bcmap-Cu-XDS3_.js +3 -0
- package/dist/lazy/UniGB-UTF16-H.bcmap-DPDBbQj_.js +3 -0
- package/dist/lazy/UniGB-UTF16-V.bcmap-Bwwxp3b7.js +3 -0
- package/dist/lazy/UniGB-UTF32-H.bcmap-D-uBJmmw.js +3 -0
- package/dist/lazy/UniGB-UTF32-V.bcmap-CLe_N_q5.js +3 -0
- package/dist/lazy/UniGB-UTF8-H.bcmap-CadVYdlJ.js +3 -0
- package/dist/lazy/UniGB-UTF8-V.bcmap-B9mD6Kt7.js +3 -0
- package/dist/lazy/UniJIS-UCS2-H.bcmap-BaCSu9QA.js +3 -0
- package/dist/lazy/UniJIS-UCS2-HW-H.bcmap-CYQj9xSp.js +3 -0
- package/dist/lazy/UniJIS-UCS2-HW-V.bcmap-CDzIwh-J.js +3 -0
- package/dist/lazy/UniJIS-UCS2-V.bcmap-DqCxM_EZ.js +3 -0
- package/dist/lazy/UniJIS-UTF16-H.bcmap-9TPLuUCU.js +3 -0
- package/dist/lazy/UniJIS-UTF16-V.bcmap-D6-nIWTQ.js +3 -0
- package/dist/lazy/UniJIS-UTF32-H.bcmap-CzmUWSLA.js +3 -0
- package/dist/lazy/UniJIS-UTF32-V.bcmap--KhJJEJE.js +3 -0
- package/dist/lazy/UniJIS-UTF8-H.bcmap-BwrhFSFd.js +3 -0
- package/dist/lazy/UniJIS-UTF8-V.bcmap-DGwbFkaL.js +3 -0
- package/dist/lazy/UniJIS2004-UTF16-H.bcmap-CdsS_d3_.js +3 -0
- package/dist/lazy/UniJIS2004-UTF16-V.bcmap-BnlV29Vf.js +3 -0
- package/dist/lazy/UniJIS2004-UTF32-H.bcmap-DSULVyIs.js +3 -0
- package/dist/lazy/UniJIS2004-UTF32-V.bcmap-CzBB970E.js +3 -0
- package/dist/lazy/UniJIS2004-UTF8-H.bcmap-BBuoGqhC.js +3 -0
- package/dist/lazy/UniJIS2004-UTF8-V.bcmap-dXgQhdTV.js +3 -0
- package/dist/lazy/UniJISPro-UCS2-HW-V.bcmap-ePVViljk.js +3 -0
- package/dist/lazy/UniJISPro-UCS2-V.bcmap-b2Oljrl4.js +3 -0
- package/dist/lazy/UniJISPro-UTF8-V.bcmap-CbPXe9gt.js +3 -0
- package/dist/lazy/UniJISX0213-UTF32-H.bcmap-Blmknifg.js +3 -0
- package/dist/lazy/UniJISX0213-UTF32-V.bcmap-Dtggmq9y.js +3 -0
- package/dist/lazy/UniJISX02132004-UTF32-H.bcmap-3YBd8tyQ.js +3 -0
- package/dist/lazy/UniJISX02132004-UTF32-V.bcmap-B8VdB9qS.js +3 -0
- package/dist/lazy/UniKS-UCS2-H.bcmap-CIhkpKgh.js +3 -0
- package/dist/lazy/UniKS-UCS2-V.bcmap-Cg-GDuqq.js +3 -0
- package/dist/lazy/UniKS-UTF16-H.bcmap-EZHb2IFq.js +3 -0
- package/dist/lazy/UniKS-UTF16-V.bcmap-BhqhAhYP.js +3 -0
- package/dist/lazy/UniKS-UTF32-H.bcmap-Cgay0dIp.js +3 -0
- package/dist/lazy/UniKS-UTF32-V.bcmap-DYXyatLV.js +3 -0
- package/dist/lazy/UniKS-UTF8-H.bcmap-BvHYimUT.js +3 -0
- package/dist/lazy/UniKS-UTF8-V.bcmap-DStcP2w0.js +3 -0
- package/dist/lazy/V.bcmap-DuWGSyNm.js +3 -0
- package/dist/lazy/WP-Symbol.bcmap-GltcyRl-.js +3 -0
- package/dist/lazy/_virtual_hm-pdfjs-data-BSzhlxyq.js +194 -0
- package/dist/lazy/jbig2.wasm-CUnHTdWi.js +3 -0
- package/dist/lazy/openjpeg.wasm-bdyxAnqz.js +3 -0
- package/dist/lazy/processing-worker-DU8GEYFs.js +30 -0
- package/dist/lazy/processing-worker-DU8GEYFs.js.map +1 -0
- package/dist/lazy/render-worker-WgnZ-czI.js +30 -0
- package/dist/lazy/render-worker-WgnZ-czI.js.map +1 -0
- package/dist/lazy/runtime-G4hlayVF.js +22652 -0
- package/dist/lazy/runtime-G4hlayVF.js.map +1 -0
- package/dist/react.d.ts +1587 -0
- package/dist/react.js +1157 -0
- package/dist/react.js.map +1 -0
- package/dist/shared/en-BYB_GHqG.js +1265 -0
- package/dist/shared/en-BYB_GHqG.js.map +1 -0
- package/dist/styles.css +337 -0
- package/package.json +111 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en-BYB_GHqG.js","names":["unknown"],"sources":["../../src/core/errors/pdf-error.ts","../../src/core/errors/abort.ts","../../src/core/errors/pdf-limits.ts","../../src/core/model/bytes.ts","../../src/core/model/geometry.ts","../../src/core/model/links.ts","../../src/core/ports/pdf-engine.ts","../../src/adapters/pdfjs/binary-data.ts","../../src/adapters/pdfjs/errors.ts","../../src/adapters/pdfjs/pdfjs-engine.ts","../../src/adapters/qpdf/qpdf-processor.ts","../../src/core/model/plan.ts","../../src/core/operations/commands.ts","../../src/core/session/history.ts","../../src/core/session/session.ts","../../src/messages/en.ts"],"sourcesContent":["import { isSdkError, type SdkCoreErrorCode, SdkError } from \"@hussmartinez/sdk-core\";\n\n/**\n * Error codes of `@hussmartinez/pdf-sdk`: sdk-core's own codes, such as\n * `ABORTED`, `WORKER_CRASHED` and `FILE_TOO_LARGE`, plus the PDF SDK's. They\n * never change meaning once released.\n *\n * - `INVALID_PDF`: the file isn't a PDF, or is too damaged to open.\n * - `PASSWORD_REQUIRED`: the PDF is encrypted, and opening it needs a\n * password.\n * - `PROCESSING_FAILED`: a PDF engine failed in a way no other code\n * describes. `cause` holds the engine's error.\n * - `TOO_MANY_PAGES`: a document, or the pages after an insert, exceed the\n * `maxPages` limit.\n * - `SESSION_TOO_LARGE`: the documents the session holds exceed the\n * `maxSessionSize` limit.\n * - `IMAGE_TOO_LARGE`: an image exceeds the `maxImagePixels` limit. It's\n * reported as a warning, because the image is skipped rather than the\n * document failing (ADR 0004).\n *\n * Limit codes carry `details` with the `limit`, its `maximum`, the `actual`\n * value and the `unit`.\n *\n * @public\n */\nexport type PdfErrorCode =\n | SdkCoreErrorCode\n | \"INVALID_PDF\"\n | \"PASSWORD_REQUIRED\"\n | \"PROCESSING_FAILED\"\n | \"TOO_MANY_PAGES\"\n | \"SESSION_TOO_LARGE\"\n | \"IMAGE_TOO_LARGE\";\n\n/**\n * The error `@hussmartinez/pdf-sdk` throws and rejects with, with a stable\n * `code`, structured `details` and the engine's error as `cause`. Show users\n * the text for its code from {@link pdfMessages}, never its `message`, which\n * is for developers and may contain text from the file.\n *\n * @example\n * ```ts\n * try {\n * await session.open(file);\n * } catch (error) {\n * if (isPdfError(error, \"PASSWORD_REQUIRED\")) {\n * askForPassword();\n * } else {\n * show(messages.error(error));\n * }\n * }\n * ```\n *\n * @public\n */\nexport class PdfError extends SdkError<PdfErrorCode> {\n /** Always `\"PdfError\"`, which survives minification and worker boundaries. */\n override readonly name = \"PdfError\";\n}\n\n/**\n * Checks whether a value is a {@link PdfError}, optionally with a given code.\n *\n * Unlike `instanceof`, it recognises errors from another copy of this\n * package or another realm, and errors rebuilt after crossing a worker\n * boundary.\n *\n * @param value - Any thrown value.\n * @param code - When given, the error must also have this code.\n * @public\n */\nexport function isPdfError<Code extends PdfErrorCode = PdfErrorCode>(\n value: unknown,\n code?: Code,\n): value is PdfError & { readonly code: Code } {\n return isSdkError(value, code) && value.name === \"PdfError\";\n}\n","import { createErrorHelpers } from \"@hussmartinez/sdk-core\";\nimport { PdfError } from \"./pdf-error.js\";\n\n/**\n * The family's error helpers, bound to `PdfError` (sdk-core ADR 0034), so\n * every port and the session make failures `PdfError`s the same way.\n */\nconst helpers = /* @__PURE__ */ createErrorHelpers(PdfError, {\n fallbackCode: \"PROCESSING_FAILED\",\n fallbackMessage: \"PDF processing failed.\",\n});\n\n/**\n * Makes any failure a `PdfError`, as every port promises: a `PdfError` as\n * it is, another `SdkError`, such as the worker client's own `ABORTED` or\n * `WORKER_CRASHED`, with its code, details and message kept, and anything\n * else as `PROCESSING_FAILED`. The original is kept as `cause`.\n *\n * @internal\n */\nexport const asPdfError: (reason: unknown, message?: string) => PdfError = helpers.adapt;\n\n/**\n * The error an aborted call rejects with, as the family's worker client does\n * (ADR 0018, ADR 0020): the reason itself when it's an `SdkError`, such as a\n * file policy's `PROCESSING_TIME_EXCEEDED`, `TIMEOUT` for a timeout, and\n * `ABORTED` otherwise. The reason is kept as `cause`.\n *\n * @internal\n */\nexport const abortError: (signal: AbortSignal) => PdfError = helpers.abortError;\n\n/**\n * Throws {@link abortError} if the signal has been aborted.\n *\n * @internal\n */\nexport const throwIfAborted: (signal: AbortSignal | undefined) => void = helpers.throwIfAborted;\n","import {\n coreLimits,\n defineLimits,\n type FilePolicy,\n type FilePolicyOverrides,\n type Limits,\n} from \"@hussmartinez/sdk-core\";\nimport { PdfError } from \"./pdf-error.js\";\n\n/**\n * The PDF SDK's limit definitions: sdk-core's core limits plus three for PDFs\n * (ADR 0004).\n *\n * | Limit | Code | Default maximum | Default warning |\n * |---|---|---|---|\n * | `maxFileSize` | `FILE_TOO_LARGE` | 100 MB | 50 MB |\n * | `maxFiles` | `TOO_MANY_FILES` | 20 | none |\n * | `maxDecodedSize` | `DECODED_SIZE_TOO_LARGE` | 500 MB | none |\n * | `maxProcessingTime` | `PROCESSING_TIME_EXCEEDED` | 120 s | none |\n * | `maxPages` | `TOO_MANY_PAGES` | 5,000 | 1,000 |\n * | `maxSessionSize` | `SESSION_TOO_LARGE` | 300 MB | 150 MB |\n * | `maxImagePixels` | `IMAGE_TOO_LARGE` | 100 megapixels | none |\n *\n * Sizes are decimal: 1 MB is 1,000,000 bytes.\n *\n * @public\n */\nexport const pdfLimitDefinitions = {\n ...coreLimits,\n maxPages: { code: \"TOO_MANY_PAGES\", unit: \"count\", default: 5_000, warning: 1_000 },\n maxSessionSize: {\n code: \"SESSION_TOO_LARGE\",\n unit: \"bytes\",\n default: 300_000_000,\n warning: 150_000_000,\n },\n maxImagePixels: { code: \"IMAGE_TOO_LARGE\", unit: \"pixels\", default: 100_000_000 },\n} as const;\n\n/**\n * The type of {@link pdfLimitDefinitions}.\n *\n * @public\n */\nexport type PdfLimitDefinitions = typeof pdfLimitDefinitions;\n\n/**\n * The names of the PDF SDK's limits.\n *\n * @public\n */\nexport type PdfLimitName = keyof PdfLimitDefinitions;\n\n/**\n * A host's `filePolicy`: a new maximum, or `{ maximum, warning }`, for any of\n * the PDF SDK's limits. `Infinity` disables a maximum, which removes a\n * protection against hostile files, or disables a warning. Unknown limit\n * names throw `TypeError` when the policy is resolved.\n *\n * @example\n * ```ts\n * const filePolicy: PdfFilePolicyOverrides = {\n * maxFileSize: { maximum: 300e6, warning: 100e6 },\n * maxSessionSize: 600e6,\n * };\n * ```\n *\n * @public\n */\nexport type PdfFilePolicyOverrides = FilePolicyOverrides<PdfLimitDefinitions>;\n\n/**\n * A resolved file policy for the PDF SDK. Violations throw {@link PdfError}.\n *\n * @public\n */\nexport type PdfFilePolicy = FilePolicy<PdfLimitDefinitions>;\n\n/**\n * The PDF SDK's limits, ready to resolve a host's `filePolicy`. Violations\n * are thrown as {@link PdfError}, with `details` naming the limit.\n *\n * @example\n * ```ts\n * const policy = pdfLimits.resolve(props.filePolicy);\n * policy.check(\"maxPages\", pageCount); // throws PdfError(\"TOO_MANY_PAGES\") above 5,000\n * ```\n *\n * @public\n */\nexport const pdfLimits: Limits<PdfLimitDefinitions> = /* @__PURE__ */ defineLimits(\n pdfLimitDefinitions,\n {\n errorClass: PdfError,\n },\n);\n","import type { PdfBytes } from \"./document.js\";\n\n/**\n * Copies PDF bytes into a new buffer that holds exactly them, so a caller's\n * buffer is never detached or changed, and a view into a larger buffer never\n * sends the rest of it (ADR 0002).\n *\n * @internal\n */\nexport function copyBytes(source: PdfBytes): Uint8Array<ArrayBuffer> {\n const view = source instanceof Uint8Array ? source : new Uint8Array(source);\n return new Uint8Array(view);\n}\n\n/**\n * Checks that a zero-based page index exists in a document.\n *\n * @throws `RangeError` otherwise.\n * @internal\n */\nexport function assertPageIndex(pageIndex: number, pageCount: number): void {\n if (!Number.isInteger(pageIndex) || pageIndex < 0 || pageIndex >= pageCount) {\n throw new RangeError(\n `Page index ${pageIndex} is outside the document, which has ${pageCount} pages.`,\n );\n }\n}\n","/**\n * A point on a page, as fractions of the page's unrotated media box: `x`\n * from the left edge and `y` from the top edge, each from 0 to 1. Fractions\n * keep positions independent of zoom and of the rotation the page is shown\n * with (ADR 0003).\n *\n * @public\n */\nexport interface PdfPoint {\n readonly x: number;\n readonly y: number;\n}\n\n/**\n * A rectangle on a page, in the same fractions as {@link PdfPoint}: its\n * top-left corner, width and height.\n *\n * @public\n */\nexport interface PdfRect {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * A rotation in degrees, clockwise.\n *\n * @public\n */\nexport type PdfRotation = 0 | 90 | 180 | 270;\n\n/**\n * Adds two rotations, such as a page's own `/Rotate` and the rotation the\n * page plan adds to it.\n *\n * @example\n * ```ts\n * addRotation(270, 180); // 90\n * addRotation(90, -90); // 0\n * ```\n *\n * @param rotation - The current rotation.\n * @param angle - The angle to add, positive clockwise, in multiples of 90.\n * @throws `RangeError` if `angle` isn't a multiple of 90.\n * @public\n */\nexport function addRotation(rotation: PdfRotation, angle: number): PdfRotation {\n if (!Number.isInteger(angle) || angle % 90 !== 0) {\n throw new RangeError(`A rotation must be a multiple of 90 degrees, received ${angle}.`);\n }\n return ((((rotation + angle) % 360) + 360) % 360) as PdfRotation;\n}\n","const SAFE_PROTOCOLS = new Set([\"http:\", \"https:\", \"mailto:\"]);\n\n/**\n * The URL, normalised, if it's an absolute `http`, `https` or `mailto` URL\n * without credentials (ADR 0012), and otherwise undefined. Every engine\n * adapter filters links with it, and the viewer checks again before\n * rendering one.\n *\n * URLs with a user name or password are refused: in\n * `https://bank.example@evil.example/`, the part a reader notices is a user\n * name, and the link goes to `evil.example`, a common phishing shape.\n *\n * @public\n */\nexport function safeLinkUrl(url: string): string | undefined {\n if (typeof url !== \"string\" || url.length > 2048) return undefined;\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return undefined;\n }\n if (!SAFE_PROTOCOLS.has(parsed.protocol)) return undefined;\n if (parsed.username !== \"\" || parsed.password !== \"\") return undefined;\n return parsed.href;\n}\n\n/**\n * What a link really leads to, for people to check before following it: the\n * host of a web link, without `www.`, or the address of an email link.\n * Undefined for a URL `safeLinkUrl` refuses.\n *\n * @public\n */\nexport function linkDestination(url: string): string | undefined {\n const safe = safeLinkUrl(url);\n if (!safe) return undefined;\n const parsed = new URL(safe);\n if (parsed.protocol === \"mailto:\") {\n return decodeURIComponent(parsed.pathname) || undefined;\n }\n return parsed.hostname.replace(/^www\\./, \"\");\n}\n","import type {\n PdfBytes,\n PdfFormField,\n PdfLink,\n PdfPageInfo,\n PdfTextContent,\n} from \"../model/document.js\";\nimport type { PdfRotation } from \"../model/geometry.js\";\nimport type { PdfCallOptions, PdfTransferOptions } from \"./options.js\";\n\n/**\n * The most pixels an engine draws into one canvas. Larger renders are drawn\n * at a lower resolution instead, because iOS Safari, the strictest\n * supported browser, refuses larger canvases (ADR 0004).\n *\n * @public\n */\nexport const PDF_MAX_CANVAS_PIXELS = 16_777_216;\n\n/**\n * How to render a page.\n *\n * @public\n */\nexport interface PdfRenderOptions extends PdfCallOptions {\n /** CSS pixels per PDF point. `1` renders a US Letter page 612 CSS pixels wide. */\n readonly scale: number;\n /**\n * Device pixels per CSS pixel, usually `window.devicePixelRatio`. Defaults\n * to 1. The engine lowers it as needed to stay within\n * {@link PDF_MAX_CANVAS_PIXELS}.\n */\n readonly pixelRatio?: number;\n /** Rotation added to the page's own, for the page plan (ADR 0003). Defaults to 0. */\n readonly rotation?: PdfRotation;\n}\n\n/**\n * An open document. Pages are addressed by zero-based index.\n *\n * @public\n */\nexport interface PdfDocumentHandle {\n /** The number of pages. */\n readonly pageCount: number;\n /**\n * Reads a page's size and rotation.\n *\n * @throws `RangeError` for an index outside the document.\n */\n getPage(pageIndex: number, options?: PdfCallOptions): Promise<PdfPageInfo>;\n /**\n * Draws a page into a canvas, sizing the canvas's pixel dimensions and its\n * CSS `width` and `height`.\n *\n * @throws `RangeError` for an index outside the document.\n */\n renderPage(\n pageIndex: number,\n canvas: HTMLCanvasElement,\n options: PdfRenderOptions,\n ): Promise<void>;\n /**\n * Reads a page's text, for the text layer and search.\n *\n * @throws `RangeError` for an index outside the document.\n */\n getTextContent(pageIndex: number, options?: PdfCallOptions): Promise<PdfTextContent>;\n /**\n * Reads the form fields on a page.\n *\n * @throws `RangeError` for an index outside the document.\n */\n getFormFields(pageIndex: number, options?: PdfCallOptions): Promise<readonly PdfFormField[]>;\n /**\n * Reads the links on a page to web pages and email addresses, filtered\n * with `safeLinkUrl` (ADR 0012).\n *\n * @throws `RangeError` for an index outside the document.\n */\n getLinks(pageIndex: number, options?: PdfCallOptions): Promise<readonly PdfLink[]>;\n /** Releases the document. Pending calls reject, and later calls throw. */\n destroy(): Promise<void>;\n}\n\n/**\n * The port for viewing PDFs: open a document, then read and render its pages\n * (ADR 0008). The SDK's pdf.js adapter implements it; hosts can pass their\n * own to the editor's `engine` prop, and every implementation must pass the\n * engine's contract tests.\n *\n * Failures reject with `PdfError`: `INVALID_PDF` for a file that can't be\n * parsed, `PASSWORD_REQUIRED` for an encrypted one, and sdk-core's codes for\n * cancellation and worker failures.\n *\n * @public\n */\nexport interface PdfEngine {\n /**\n * Opens a document. The bytes are copied unless `transfer` is set.\n */\n open(source: PdfBytes, options?: PdfTransferOptions): Promise<PdfDocumentHandle>;\n /** Releases the engine and its worker. Open documents are destroyed. */\n destroy(): Promise<void>;\n}\n","/** The kinds of data pdf.js asks the page for when `useWorkerFetch` is off. */\nexport type PdfJsDataKind = \"cMapUrl\" | \"standardFontDataUrl\" | \"wasmUrl\";\n\n/** Called for every data file pdf.js asks for. */\nexport type PdfJsDataListener = (kind: PdfJsDataKind, filename: string) => void;\n\n/**\n * The prefix pdf.js puts before the file name of a JavaScript decoder it\n * imports when a WebAssembly decoder can't start, for example under a\n * Content Security Policy without 'wasm-unsafe-eval'. It isn't a fetchable\n * scheme, so that import fails without a request (docs/adr/0002).\n */\nexport const NO_NETWORK_URL = \"hm-pdf-no-network:/\";\n\nfunction decodeBase64(base64: string): Uint8Array {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let index = 0; index < binary.length; index += 1) {\n bytes[index] = binary.charCodeAt(index);\n }\n return bytes;\n}\n\n/**\n * A `BinaryDataFactory` for pdf.js that serves the bundled CMaps, standard\n * fonts and WebAssembly decoders from lazy chunks, without the network\n * (docs/adr/0002). Only those files are served: any other kind or name,\n * such as a path, is refused.\n */\nexport function createInlineDataFactory(listener?: PdfJsDataListener) {\n return class InlineDataFactory {\n async fetch({\n kind,\n filename,\n }: {\n kind: PdfJsDataKind;\n filename: string;\n }): Promise<Uint8Array> {\n listener?.(kind, filename);\n const { pdfJsData } = await import(\"virtual:hm-pdfjs-data\");\n const files = Object.hasOwn(pdfJsData, kind) ? pdfJsData[kind] : undefined;\n const load = files && Object.hasOwn(files, filename) ? files[filename] : undefined;\n if (!load) {\n throw new Error(`The PDF SDK doesn't serve ${kind} data named ${filename}.`);\n }\n return decodeBase64(await load());\n }\n };\n}\n","import { isPdfError, PdfError } from \"../../core/errors/pdf-error.js\";\n\nconst INVALID = new Set([\"InvalidPDFException\", \"FormatError\", \"MissingPDFException\"]);\n\n/**\n * Turns whatever pdf.js rejected with into a `PdfError`, keeping it as\n * `cause`. pdf.js's exceptions cross its worker boundary as plain objects\n * with a `name`, so they're recognised by name.\n */\nexport function fromPdfJsError(reason: unknown, message: string): PdfError | RangeError {\n if (isPdfError(reason) || reason instanceof RangeError) {\n return reason;\n }\n const name = typeof reason === \"object\" && reason !== null ? (reason as Error).name : undefined;\n if (name === \"PasswordException\") {\n return new PdfError(\"PASSWORD_REQUIRED\", \"The PDF is encrypted.\", { cause: reason });\n }\n if (name !== undefined && INVALID.has(name)) {\n return new PdfError(\"INVALID_PDF\", \"The file isn't a readable PDF.\", { cause: reason });\n }\n return new PdfError(\"PROCESSING_FAILED\", message, { cause: reason });\n}\n","import { resolveAssetsBase } from \"@hussmartinez/sdk-core\";\nimport type { PDFDocumentLoadingTask, PDFDocumentProxy, PDFPageProxy, PDFWorker } from \"pdfjs-dist\";\nimport { abortError, throwIfAborted } from \"../../core/errors/abort.js\";\nimport { PdfError } from \"../../core/errors/pdf-error.js\";\nimport { pdfLimitDefinitions } from \"../../core/errors/pdf-limits.js\";\nimport { assertPageIndex, copyBytes } from \"../../core/model/bytes.js\";\nimport type {\n PdfBytes,\n PdfFormField,\n PdfLink,\n PdfPageInfo,\n PdfTextContent,\n PdfTextItem,\n} from \"../../core/model/document.js\";\nimport { addRotation, type PdfRect, type PdfRotation } from \"../../core/model/geometry.js\";\nimport { safeLinkUrl } from \"../../core/model/links.js\";\nimport type { PdfCallOptions, PdfTransferOptions } from \"../../core/ports/options.js\";\nimport {\n PDF_MAX_CANVAS_PIXELS,\n type PdfDocumentHandle,\n type PdfEngine,\n type PdfRenderOptions,\n} from \"../../core/ports/pdf-engine.js\";\nimport { createInlineDataFactory, NO_NETWORK_URL } from \"./binary-data.js\";\nimport { fromPdfJsError } from \"./errors.js\";\n\ntype PdfJs = typeof import(\"pdfjs-dist\");\ntype PageViewport = ReturnType<PDFPageProxy[\"getViewport\"]>;\n\n/** The fields of pdf.js's text items this adapter reads. */\ninterface PdfJsTextItem {\n readonly str: string;\n readonly transform: readonly number[];\n readonly width: number;\n readonly hasEOL: boolean;\n}\n\n/**\n * Converts a rectangle in PDF user space to fractions of the unrotated page,\n * from the top-left corner, clamped to the page (ADR 0003).\n */\nfunction toPageRect(viewport: PageViewport, box: readonly number[]): PdfRect {\n const [x1 = 0, y1 = 0, x2 = 0, y2 = 0] = box;\n const [ax = 0, ay = 0] = viewport.convertToViewportPoint(x1, y1) as number[];\n const [bx = 0, by = 0] = viewport.convertToViewportPoint(x2, y2) as number[];\n const left = clamp(Math.min(ax, bx) / viewport.width);\n const top = clamp(Math.min(ay, by) / viewport.height);\n return {\n x: left,\n y: top,\n width: clamp(Math.max(ax, bx) / viewport.width) - left,\n height: clamp(Math.max(ay, by) / viewport.height) - top,\n };\n}\n\n/**\n * Options for {@link createPdfJsEngine}.\n *\n * @public\n */\nexport interface PdfJsEngineOptions {\n /**\n * Where your application serves the package's `dist/assets/` directory,\n * on its own origin, such as `\"/pdf-sdk/\"`. pdf.js then loads its worker\n * and its data files from its `pdfjs/` subdirectory, rather than from the\n * inlined copies. Use it for Content Security Policies without\n * `worker-src blob:`, and for accurate ICC colour, which only this mode\n * supports (docs/adr/0006, docs/adr/0007). Pass the same URL to\n * `createPdfProcessor`.\n */\n readonly assetsUrl?: string | URL;\n /**\n * The largest image pdf.js decodes, in pixels. Larger images are left\n * unpainted. Defaults to the `maxImagePixels` limit, 100 megapixels.\n */\n readonly maxImagePixels?: number;\n /**\n * Called for every data file pdf.js asks for. For tests.\n *\n * @internal\n */\n readonly _onDataRequest?: (\n kind: \"cMapUrl\" | \"standardFontDataUrl\" | \"wasmUrl\",\n filename: string,\n ) => void;\n}\n\n/** How long a cancelled open may take to stop before its worker is terminated (ADR 0018). */\nconst CANCEL_TIMEOUT = 1_000;\n\n/**\n * Creates the SDK's {@link PdfEngine}, backed by pdf.js (ADR 0001, ADR 0002).\n *\n * Nothing loads until the first `open()`: then pdf.js's display layer is\n * imported, and its worker starts. Every document the engine opens shares one\n * worker, and pdf.js runs without scripting or XFA (docs/adr/0001).\n *\n * By default everything is inlined: the worker, and the CMaps, standard\n * fonts and image decoders that some documents need, each loaded only when a\n * document needs it, with no network request. With `assetsUrl`, they load\n * from your own origin instead (docs/adr/0002, docs/adr/0006).\n *\n * @example\n * ```ts\n * const engine = createPdfJsEngine();\n * const document = await engine.open(await file.arrayBuffer(), { signal });\n * await document.renderPage(0, canvas, { scale: 1.5, pixelRatio: devicePixelRatio });\n * ```\n *\n * @public\n */\nexport function createPdfJsEngine(options: PdfJsEngineOptions = {}): PdfEngine {\n return new PdfJsEngine(options);\n}\n\n/**\n * One worker, and everything that fails with it. When the worker crashes or\n * has to be terminated, every call waiting on it rejects, and the engine\n * starts a new one on the next open.\n */\nclass WorkerHost {\n readonly pdfWorker: PDFWorker;\n #worker: Worker;\n #waiting = new Set<(error: PdfError) => void>();\n #failure: PdfError | undefined;\n\n constructor(worker: Worker, pdfWorker: PDFWorker) {\n this.#worker = worker;\n this.pdfWorker = pdfWorker;\n const crash = (event: Event) => {\n // Handled here, so the error isn't also reported to the console.\n event.preventDefault();\n this.fail(new PdfError(\"WORKER_CRASHED\", \"The PDF render worker failed.\"));\n };\n worker.addEventListener(\"error\", crash);\n worker.addEventListener(\"messageerror\", crash);\n }\n\n get failure(): PdfError | undefined {\n return this.#failure;\n }\n\n /** Rejects with the worker's failure, if it fails while the returned function hasn't been called. */\n watch(reject: (error: PdfError) => void): () => void {\n if (this.#failure) {\n reject(this.#failure);\n return () => {};\n }\n this.#waiting.add(reject);\n return () => this.#waiting.delete(reject);\n }\n\n fail(error: PdfError): void {\n if (this.#failure) return;\n this.#failure = error;\n this.#worker.terminate();\n this.pdfWorker.destroy();\n for (const reject of this.#waiting) reject(error);\n this.#waiting.clear();\n }\n}\n\n/**\n * Waits for a pdf.js promise, rejecting at once when the signal aborts or the\n * worker fails, and mapping pdf.js's errors to `PdfError`.\n */\nfunction settle<Value>(\n host: WorkerHost,\n promise: Promise<Value>,\n options: { signal?: AbortSignal | undefined; onAbort?: () => void; message: string },\n): Promise<Value> {\n const { signal } = options;\n return new Promise<Value>((resolve, reject) => {\n if (signal?.aborted) {\n options.onAbort?.();\n reject(abortError(signal));\n return;\n }\n const abort = () => {\n options.onAbort?.();\n reject(abortError(signal as AbortSignal));\n };\n signal?.addEventListener(\"abort\", abort, { once: true });\n const unwatch = host.watch(reject);\n promise.then(resolve, (reason: unknown) => reject(fromPdfJsError(reason, options.message)));\n // Settling twice is harmless; the first outcome wins.\n void promise\n .catch(() => {})\n .finally(() => {\n signal?.removeEventListener(\"abort\", abort);\n unwatch();\n });\n });\n}\n\nconst VERSION_MISMATCH = /The API version \"([^\"]+)\" does not match the Worker version \"([^\"]+)\"/;\n\n/**\n * pdf.js refuses a worker from another pdf.js version, such as a self-hosted\n * copy left over from before an upgrade. That's a start failure, not a\n * problem with the document, so it's reported as one, with the same details\n * as sdk-core's worker client gives (sdk-core ADR 0038).\n */\nfunction workerVersionMismatch(error: unknown, base: string | undefined): PdfError | undefined {\n for (let reason = error; reason instanceof Error; reason = reason.cause) {\n const match = VERSION_MISMATCH.exec(reason.message);\n if (match) {\n return new PdfError(\"WORKER_START_FAILED\", \"The PDF render worker is another version.\", {\n details: {\n asset: base === undefined ? null : `${base}build/pdf.worker.min.mjs`,\n expected: match[1] ?? null,\n actual: match[2] ?? null,\n },\n cause: error,\n });\n }\n }\n return undefined;\n}\n\n/** pdf.js transfers the bytes it's given, so it gets a copy unless the caller transfers. */\nfunction takeBytes(source: PdfBytes, transfer: boolean | undefined): Uint8Array {\n if (transfer) {\n const view = source instanceof Uint8Array ? source : new Uint8Array(source);\n const whole = view.byteOffset === 0 && view.byteLength === view.buffer.byteLength;\n if (whole && view.buffer instanceof ArrayBuffer) return view;\n }\n return copyBytes(source);\n}\n\nfunction normalizeRotation(rotation: number): PdfRotation {\n return addRotation(0, Number.isInteger(rotation) && rotation % 90 === 0 ? rotation : 0);\n}\n\nconst clamp = (value: number) => Math.min(1, Math.max(0, value));\n\nclass PdfJsEngine implements PdfEngine {\n #options: PdfJsEngineOptions;\n /** pdf.js's directory under `assetsUrl`, if it's set. */\n readonly #pdfJsBase: string | undefined;\n #runtime: Promise<PdfJs> | undefined;\n #host: WorkerHost | undefined;\n #documents = new Set<PdfJsDocument>();\n #destroyed = false;\n\n constructor(options: PdfJsEngineOptions) {\n this.#options = options;\n // Resolved now, so a URL that can't be, such as a relative one during\n // server rendering, throws TypeError here rather than on the first open\n // (sdk-core ADR 0038).\n this.#pdfJsBase =\n options.assetsUrl === undefined ? undefined : `${resolveAssetsBase(options.assetsUrl)}pdfjs/`;\n }\n\n async open(source: PdfBytes, options: PdfTransferOptions = {}): Promise<PdfDocumentHandle> {\n if (this.#destroyed) {\n throw new PdfError(\"WORKER_TERMINATED\", \"The PDF engine was destroyed.\");\n }\n throwIfAborted(options.signal);\n const data = takeBytes(source, options.transfer);\n this.#runtime ??= import(\"./runtime.js\").then((module) => module.pdfjs as PdfJs);\n const pdfjs = await this.#runtime;\n throwIfAborted(options.signal);\n const host = await this.#ensureHost(pdfjs);\n\n const base = this.#assetsBase();\n const task = pdfjs.getDocument({\n data,\n worker: host.pdfWorker,\n // Hardening (docs/adr/0001, docs/adr/0002): no XFA, and data files only\n // from the bundle or the application's own origin, never elsewhere.\n enableXfa: false,\n maxImageSize: this.#options.maxImagePixels ?? pdfLimitDefinitions.maxImagePixels.default,\n stopAtErrors: false,\n verbosity: pdfjs.VerbosityLevel.ERRORS,\n useWasm: true,\n ...(base\n ? {\n // Self-hosted: pdf.js fetches from the application's origin, which\n // also enables ICC colour (docs/adr/0006).\n useWorkerFetch: true,\n cMapUrl: `${base}cmaps/`,\n standardFontDataUrl: `${base}standard_fonts/`,\n wasmUrl: `${base}wasm/`,\n iccUrl: `${base}iccs/`,\n }\n : {\n // Inline: every file comes from the bundle, through the factory.\n useWorkerFetch: false,\n BinaryDataFactory: createInlineDataFactory(this.#options._onDataRequest),\n wasmUrl: NO_NETWORK_URL,\n }),\n });\n try {\n const proxy = await settle(host, task.promise, {\n signal: options.signal,\n onAbort: () => this.#cancel(task, host),\n message: \"The PDF couldn't be opened.\",\n });\n const document = new PdfJsDocument(pdfjs, proxy, task, host, () =>\n this.#documents.delete(document),\n );\n this.#documents.add(document);\n return document;\n } catch (error) {\n void task.destroy().catch(() => {});\n const mismatch = workerVersionMismatch(error, base);\n if (mismatch) {\n // The worker is unusable; the next open starts a new one.\n host.fail(mismatch);\n throw mismatch;\n }\n throw error;\n }\n }\n\n async destroy(): Promise<void> {\n if (this.#destroyed) return;\n this.#destroyed = true;\n await Promise.all([...this.#documents].map((document) => document.destroy()));\n this.#host?.fail(new PdfError(\"WORKER_TERMINATED\", \"The PDF engine was destroyed.\"));\n this.#host = undefined;\n }\n\n async #ensureHost(pdfjs: PdfJs): Promise<WorkerHost> {\n if (this.#host && !this.#host.failure) return this.#host;\n let worker: Worker;\n try {\n const base = this.#assetsBase();\n worker = base\n ? new Worker(`${base}build/pdf.worker.min.mjs`, { type: \"module\", name: \"hm-pdf-render\" })\n : (await import(\"./render-worker.js\")).createInlineWorker();\n } catch (cause) {\n throw new PdfError(\"WORKER_START_FAILED\", \"The PDF render worker couldn't start.\", {\n cause,\n });\n }\n this.#host = new WorkerHost(worker, pdfjs.PDFWorker.create({ port: worker }));\n return this.#host;\n }\n\n /** pdf.js's directory under `assetsUrl`, if it's set. */\n #assetsBase(): string | undefined {\n return this.#pdfJsBase;\n }\n\n /** Stops a cancelled open, and terminates the worker if pdf.js doesn't stop in time. */\n #cancel(task: PDFDocumentLoadingTask, host: WorkerHost): void {\n const timer = setTimeout(\n () =>\n host.fail(\n new PdfError(\"WORKER_TERMINATED\", \"The worker was stopped to cancel an operation.\"),\n ),\n CANCEL_TIMEOUT,\n );\n void task\n .destroy()\n .catch(() => {})\n .finally(() => clearTimeout(timer));\n }\n}\n\nclass PdfJsDocument implements PdfDocumentHandle {\n readonly pageCount: number;\n #pdfjs: PdfJs;\n #proxy: PDFDocumentProxy;\n #task: PDFDocumentLoadingTask;\n #host: WorkerHost;\n #onDestroy: () => void;\n #destroyed = false;\n\n constructor(\n pdfjs: PdfJs,\n proxy: PDFDocumentProxy,\n task: PDFDocumentLoadingTask,\n host: WorkerHost,\n onDestroy: () => void,\n ) {\n this.#pdfjs = pdfjs;\n this.#proxy = proxy;\n this.#task = task;\n this.#host = host;\n this.#onDestroy = onDestroy;\n this.pageCount = proxy.numPages;\n }\n\n async getPage(pageIndex: number, options: PdfCallOptions = {}): Promise<PdfPageInfo> {\n const page = await this.#page(pageIndex, options);\n const { width, height } = page.getViewport({ scale: 1, rotation: 0 });\n return { width, height, rotation: normalizeRotation(page.rotate) };\n }\n\n async renderPage(\n pageIndex: number,\n canvas: HTMLCanvasElement,\n options: PdfRenderOptions,\n ): Promise<void> {\n if (!(options.scale > 0) || !Number.isFinite(options.scale)) {\n throw new RangeError(\n `The render scale must be a positive number, received ${options.scale}.`,\n );\n }\n const page = await this.#page(pageIndex, options);\n const rotation = addRotation(normalizeRotation(page.rotate), options.rotation ?? 0);\n const viewport = page.getViewport({ scale: options.scale, rotation });\n const area = viewport.width * viewport.height;\n const wanted = Math.max(options.pixelRatio ?? 1, Number.MIN_VALUE);\n // Lower the resolution, never the CSS size, to stay within the canvas cap (ADR 0004).\n const ratio = Math.min(wanted, Math.sqrt(PDF_MAX_CANVAS_PIXELS / Math.max(area, 1)));\n canvas.width = Math.max(1, Math.floor(viewport.width * ratio));\n canvas.height = Math.max(1, Math.floor(viewport.height * ratio));\n canvas.style.width = `${viewport.width}px`;\n canvas.style.height = `${viewport.height}px`;\n const context = canvas.getContext(\"2d\", { alpha: false });\n if (!context) {\n throw new PdfError(\"UNSUPPORTED_ENVIRONMENT\", \"The browser can't draw on a canvas.\", {\n details: { feature: \"CanvasRenderingContext2D\" },\n });\n }\n const task = page.render({\n canvas,\n canvasContext: context,\n viewport,\n transform: [canvas.width / viewport.width, 0, 0, canvas.height / viewport.height, 0, 0],\n annotationMode: this.#pdfjs.AnnotationMode.ENABLE,\n });\n try {\n await settle(this.#host, task.promise, {\n signal: options.signal,\n onAbort: () => task.cancel(),\n message: \"The page couldn't be drawn.\",\n });\n } finally {\n page.cleanup();\n }\n }\n\n async getTextContent(pageIndex: number, options: PdfCallOptions = {}): Promise<PdfTextContent> {\n const page = await this.#page(pageIndex, options);\n const content = await settle(this.#host, page.getTextContent(), {\n signal: options.signal,\n message: \"The page's text couldn't be read.\",\n });\n const viewport = page.getViewport({ scale: 1, rotation: 0 });\n const items: PdfTextItem[] = [];\n for (const item of content.items) {\n if (!(\"str\" in item)) continue;\n const { str, transform, width, hasEOL } = item as PdfJsTextItem;\n const [a = 1, b = 0, c = 0, d = 1, e = 0, f = 0] = transform;\n const fontHeight = Math.hypot(c, d);\n items.push({\n text: str,\n rect: toPageRect(viewport, [e, f, e + width, f + fontHeight]),\n angle: (Math.atan2(b, a) * 180) / Math.PI,\n endOfLine: hasEOL,\n });\n }\n return { items };\n }\n\n async getFormFields(\n pageIndex: number,\n options: PdfCallOptions = {},\n ): Promise<readonly PdfFormField[]> {\n const page = await this.#page(pageIndex, options);\n const annotations = (await settle(this.#host, page.getAnnotations({ intent: \"display\" }), {\n signal: options.signal,\n message: \"The page's form fields couldn't be read.\",\n })) as Array<Record<string, unknown>>;\n const viewport = page.getViewport({ scale: 1, rotation: 0 });\n const fields = new Map<string, PdfFormField>();\n for (const annotation of annotations) {\n const name = annotation[\"fieldName\"];\n if (annotation[\"subtype\"] !== \"Widget\" || typeof name !== \"string\" || fields.has(name)) {\n continue;\n }\n const value = annotation[\"fieldValue\"];\n const type =\n annotation[\"fieldType\"] === \"Tx\"\n ? \"text\"\n : annotation[\"fieldType\"] === \"Btn\" && annotation[\"checkBox\"]\n ? \"checkbox\"\n : undefined;\n if (!type) continue;\n fields.set(name, {\n name,\n type,\n rect: toPageRect(viewport, annotation[\"rect\"] as number[]),\n value:\n type === \"text\"\n ? typeof value === \"string\"\n ? value\n : \"\"\n : typeof value === \"string\" && value !== \"\" && value !== \"Off\",\n readOnly: annotation[\"readOnly\"] === true,\n });\n }\n return [...fields.values()];\n }\n\n async getLinks(pageIndex: number, options: PdfCallOptions = {}): Promise<readonly PdfLink[]> {\n const page = await this.#page(pageIndex, options);\n const annotations = (await settle(this.#host, page.getAnnotations({ intent: \"display\" }), {\n signal: options.signal,\n message: \"The page's links couldn't be read.\",\n })) as Array<Record<string, unknown>>;\n const viewport = page.getViewport({ scale: 1, rotation: 0 });\n const links: PdfLink[] = [];\n for (const annotation of annotations) {\n if (annotation[\"subtype\"] !== \"Link\" || typeof annotation[\"url\"] !== \"string\") continue;\n // pdf.js also allows ftp: and tel:, and turns some scripts into URLs;\n // the SDK keeps only http, https and mailto (ADR 0012).\n const url = safeLinkUrl(annotation[\"url\"]);\n if (url) links.push({ rect: toPageRect(viewport, annotation[\"rect\"] as number[]), url });\n }\n return links;\n }\n\n async destroy(): Promise<void> {\n if (this.#destroyed) return;\n this.#destroyed = true;\n this.#onDestroy();\n await this.#task.destroy().catch(() => {});\n }\n\n async #page(pageIndex: number, options: PdfCallOptions): Promise<PDFPageProxy> {\n if (this.#destroyed) {\n throw new PdfError(\"WORKER_TERMINATED\", \"The document was destroyed.\");\n }\n assertPageIndex(pageIndex, this.pageCount);\n throwIfAborted(options.signal);\n return settle(this.#host, this.#proxy.getPage(pageIndex + 1), {\n signal: options.signal,\n message: \"The page couldn't be read.\",\n });\n }\n}\n","import { createWorkerClient, resolveAssetsBase, type WorkerClient } from \"@hussmartinez/sdk-core\";\nimport { asPdfError } from \"../../core/errors/abort.js\";\nimport { PdfError } from \"../../core/errors/pdf-error.js\";\nimport type { PdfBuildJob } from \"../../core/model/build-job.js\";\nimport type { PdfBuildOptions, PdfProcessor } from \"../../core/ports/pdf-processor.js\";\nimport type { ProcessingContract } from \"./contract.js\";\n\n/**\n * Options for {@link createPdfProcessor}.\n *\n * @public\n */\nexport interface PdfProcessorOptions {\n /**\n * Where your application serves the package's `dist/assets/` directory,\n * on its own origin, such as `\"/pdf-sdk/\"`, the same URL as the engine's.\n * The worker then loads from `processing/processing.worker.js`, and\n * fetches `processing/qpdf.wasm`, which it checks against this version's\n * hash before using it. Use it for Content Security Policies without\n * `worker-src blob:` (docs/adr/0007). By default the worker is inlined.\n */\n readonly assetsUrl?: string | URL;\n}\n\n/**\n * Creates the SDK's {@link PdfProcessor}, backed by qpdf and pdf-lib in a\n * worker (docs/adr/0001, docs/adr/0002).\n *\n * Nothing starts until the first `build()`. By default the worker is\n * inlined, which needs `worker-src blob:` and `script-src 'wasm-unsafe-eval'`\n * in a Content Security Policy, and it never fetches anything. With\n * `assetsUrl`, it loads from your own origin instead. A build that can't stop\n * when cancelled terminates its worker, which starts again on the next build.\n *\n * @example\n * ```ts\n * const processor = createPdfProcessor();\n * const protectedPdf = await processor.build({\n * sources: [{ id: \"a\", bytes }],\n * pages: [{ source: \"a\", pageIndex: 0 }, { source: \"a\", pageIndex: 1, rotation: 90 }],\n * encrypt: { userPassword: \"correct horse\" },\n * });\n * ```\n *\n * @public\n */\nexport function createPdfProcessor(options: PdfProcessorOptions = {}): PdfProcessor {\n // Throws TypeError now for a URL that can't be resolved, such as a relative\n // one during server rendering, rather than on the first build.\n const base = options.assetsUrl === undefined ? undefined : resolveAssetsBase(options.assetsUrl);\n let client: WorkerClient<ProcessingContract> | undefined;\n let destroyed = false;\n\n const start = (): WorkerClient<ProcessingContract> => {\n client ??= createWorkerClient<ProcessingContract>({\n // The worker's chunk loads on the first build, not with this module.\n createWorker: () => {\n if (base) {\n return new Worker(`${base}processing/processing.worker.js`, {\n type: \"module\",\n name: \"hm-pdf-processing\",\n });\n }\n if (!inlineWorker) {\n throw new PdfError(\"WORKER_START_FAILED\", \"The processing worker hasn't loaded.\");\n }\n return inlineWorker();\n },\n errorClasses: { PdfError },\n // A worker from another version of the package is refused with\n // WORKER_START_FAILED, naming the file to copy again (sdk-core ADR 0038).\n packageVersion: __PDF_SDK_VERSION__,\n ...(base ? { workerAsset: `${base}processing/processing.worker.js` } : {}),\n });\n return client;\n };\n let inlineWorker: (() => Worker) | undefined;\n\n return {\n async build(job: PdfBuildJob, options: PdfBuildOptions = {}): Promise<Uint8Array> {\n if (destroyed) {\n throw new PdfError(\"WORKER_TERMINATED\", \"The PDF processor was destroyed.\");\n }\n if (!base) {\n inlineWorker ??= (await import(\"./processing-worker.js\")).createInlineWorker;\n }\n let outcome: Awaited<ReturnType<WorkerClient<ProcessingContract>[\"call\"]>>;\n try {\n outcome = await start().call(\"build\", job, {\n ...(options.signal ? { signal: options.signal } : {}),\n ...(options.onProgress ? { onProgress: options.onProgress } : {}),\n ...(options.transfer ? { transfer: true } : {}),\n });\n } catch (error) {\n // The client's own failures, such as ABORTED or WORKER_CRASHED, are\n // SdkErrors; the port promises PdfError.\n throw asPdfError(error, \"The PDF couldn't be built.\");\n }\n if (!outcome.ok) {\n throw outcome.error === \"RangeError\"\n ? new RangeError(outcome.message)\n : new TypeError(outcome.message);\n }\n return outcome.bytes;\n },\n async destroy(): Promise<void> {\n destroyed = true;\n client?.destroy();\n client = undefined;\n },\n };\n}\n","import type { PdfAnnotation } from \"./annotations.js\";\nimport type { PdfFieldValue } from \"./document.js\";\nimport type { PdfRotation } from \"./geometry.js\";\n\n/**\n * One page of the page plan (docs/adr/0003): a page of a source document,\n * with a rotation added to its own, and the annotations drawn on it. The key\n * is stable while the page moves, so annotations, thumbnails and the\n * selection follow it.\n *\n * @public\n */\nexport interface PdfPlanPage {\n /** Unique within the session, and never reused. */\n readonly key: string;\n /** The ID of the source document the page comes from. */\n readonly source: string;\n /** The page's zero-based index in its source. */\n readonly pageIndex: number;\n /** Rotation added to the page's own `/Rotate`. */\n readonly rotation: PdfRotation;\n /** Annotations drawn on the page, in drawing order. */\n readonly annotations: readonly PdfAnnotation[];\n}\n\n/**\n * The document being edited, as a plan over immutable sources\n * (docs/adr/0003): the pages in order, and form values per source. Bytes\n * are only built from it on export.\n *\n * @public\n */\nexport interface PdfPlan {\n readonly pages: readonly PdfPlanPage[];\n /** Form values set in the session, by source ID, then field name. */\n readonly formValues: Readonly<Record<string, Readonly<Record<string, PdfFieldValue>>>>;\n}\n\n/** An empty plan. @internal */\nexport const EMPTY_PLAN: PdfPlan = Object.freeze({\n pages: Object.freeze([]),\n formValues: Object.freeze({}),\n});\n","import type { PdfAnnotation } from \"../model/annotations.js\";\nimport type { PdfFieldValue } from \"../model/document.js\";\nimport { addRotation } from \"../model/geometry.js\";\nimport type { PdfPlan, PdfPlanPage } from \"../model/plan.js\";\n\n/**\n * Rotates pages by an angle, added to their current rotation.\n *\n * @public\n */\nexport interface PdfRotatePagesCommand {\n readonly type: \"pdf.rotatePages\";\n /** The keys of the pages to rotate. */\n readonly pages: readonly string[];\n /** Degrees, clockwise, in multiples of 90. Negative turns anticlockwise. */\n readonly angle: number;\n}\n\n/**\n * Removes pages from the plan. Their sources stay, so undo can bring them back.\n *\n * @public\n */\nexport interface PdfDeletePagesCommand {\n readonly type: \"pdf.deletePages\";\n readonly pages: readonly string[];\n}\n\n/**\n * Puts deleted pages back at their positions. It's what undoing a delete\n * runs, and it can be used directly.\n *\n * @public\n */\nexport interface PdfRestorePagesCommand {\n readonly type: \"pdf.restorePages\";\n /** Each page, and the index it takes in the resulting plan, in increasing order. */\n readonly entries: readonly { readonly index: number; readonly page: PdfPlanPage }[];\n}\n\n/**\n * Moves pages, keeping their relative order, so that the first of them ends\n * up at position `to` of the resulting plan.\n *\n * @public\n */\nexport interface PdfMovePagesCommand {\n readonly type: \"pdf.movePages\";\n readonly pages: readonly string[];\n /** The zero-based position of the first moved page in the resulting plan. */\n readonly to: number;\n}\n\n/**\n * Puts every page in a new order, given as every key exactly once. It's what\n * undoing a move runs.\n *\n * @public\n */\nexport interface PdfReorderPagesCommand {\n readonly type: \"pdf.reorderPages\";\n readonly order: readonly string[];\n}\n\n/**\n * Inserts pages of a registered source document. The session registers the\n * source and fills in `keys`, so redo inserts the same pages.\n *\n * @public\n */\nexport interface PdfInsertPagesCommand {\n readonly type: \"pdf.insertPages\";\n /** The source's ID. */\n readonly source: string;\n /** Zero-based indexes of the source's pages to insert, in order. */\n readonly pageIndexes: readonly number[];\n /** The zero-based position of the first inserted page in the resulting plan. */\n readonly at: number;\n /** The keys of the new pages, one per index. */\n readonly keys: readonly string[];\n}\n\n/**\n * Sets a form field's value in one source, or clears the session's value with\n * `null`, so the document's own value applies again.\n *\n * @public\n */\nexport interface PdfSetFieldValueCommand {\n readonly type: \"pdf.setFieldValue\";\n readonly source: string;\n readonly field: string;\n readonly value: PdfFieldValue | null;\n}\n\n/**\n * Adds an annotation to a page.\n *\n * @public\n */\nexport interface PdfAddAnnotationCommand {\n readonly type: \"pdf.addAnnotation\";\n /** The page's key. */\n readonly page: string;\n readonly annotation: PdfAnnotation;\n /** Its position among the page's annotations. Defaults to the end. */\n readonly index?: number;\n}\n\n/**\n * Removes an annotation from a page.\n *\n * @public\n */\nexport interface PdfRemoveAnnotationCommand {\n readonly type: \"pdf.removeAnnotation\";\n readonly page: string;\n /** The annotation's ID. */\n readonly id: string;\n}\n\n/**\n * An edit to the page plan (docs/adr/0003). Commands are plain,\n * structured-cloneable data, never carry bytes, and each has an exact\n * inverse, which is how undo works (ADR 0010).\n *\n * @public\n */\nexport type PdfCommand =\n | PdfRotatePagesCommand\n | PdfDeletePagesCommand\n | PdfRestorePagesCommand\n | PdfMovePagesCommand\n | PdfReorderPagesCommand\n | PdfInsertPagesCommand\n | PdfSetFieldValueCommand\n | PdfAddAnnotationCommand\n | PdfRemoveAnnotationCommand;\n\n/**\n * A command's result: the new plan, and the command that undoes it.\n *\n * @internal\n */\nexport interface Applied {\n readonly plan: PdfPlan;\n readonly inverse: PdfCommand;\n}\n\n/** The positions of the given keys, in plan order, failing on unknown or repeated keys. */\nfunction positions(plan: PdfPlan, keys: readonly string[]): number[] {\n if (keys.length === 0) throw new TypeError(\"A command needs at least one page.\");\n const wanted = new Set(keys);\n if (wanted.size !== keys.length) throw new TypeError(\"A page appears twice in the command.\");\n const found = plan.pages.flatMap((page, index) => (wanted.has(page.key) ? [index] : []));\n if (found.length !== wanted.size) {\n const known = new Set(plan.pages.map((page) => page.key));\n const missing = keys.filter((key) => !known.has(key));\n throw new TypeError(`The plan has no page ${missing.join(\", \")}.`);\n }\n return found;\n}\n\nfunction withPages(plan: PdfPlan, pages: readonly PdfPlanPage[]): PdfPlan {\n return { pages, formValues: plan.formValues };\n}\n\nfunction updatePage(\n plan: PdfPlan,\n key: string,\n update: (page: PdfPlanPage) => PdfPlanPage,\n): PdfPlan {\n const [index] = positions(plan, [key]);\n const pages = [...plan.pages];\n pages[index as number] = update(plan.pages[index as number] as PdfPlanPage);\n return withPages(plan, pages);\n}\n\n/**\n * Applies a command to a plan, without changing it, and returns the new\n * plan with the command's inverse. Invalid commands, such as ones naming a\n * page the plan doesn't have, throw `TypeError` or `RangeError` and change\n * nothing.\n *\n * @internal\n */\nexport function applyCommand(plan: PdfPlan, command: PdfCommand): Applied {\n switch (command.type) {\n case \"pdf.rotatePages\": {\n const at = new Set(positions(plan, command.pages));\n addRotation(0, command.angle);\n const pages = plan.pages.map((page, index) =>\n at.has(index) ? { ...page, rotation: addRotation(page.rotation, command.angle) } : page,\n );\n return {\n plan: withPages(plan, pages),\n inverse: { type: \"pdf.rotatePages\", pages: command.pages, angle: -command.angle },\n };\n }\n\n case \"pdf.deletePages\": {\n const at = positions(plan, command.pages);\n if (at.length === plan.pages.length) {\n throw new RangeError(\"A document needs at least one page.\");\n }\n const removed = new Set(at);\n return {\n plan: withPages(\n plan,\n plan.pages.filter((_, index) => !removed.has(index)),\n ),\n inverse: {\n type: \"pdf.restorePages\",\n entries: at.map((index) => ({ index, page: plan.pages[index] as PdfPlanPage })),\n },\n };\n }\n\n case \"pdf.restorePages\": {\n const known = new Set(plan.pages.map((page) => page.key));\n const pages = [...plan.pages];\n let previous = -1;\n for (const { index, page } of command.entries) {\n if (known.has(page.key)) throw new TypeError(`The plan already has page ${page.key}.`);\n if (!Number.isInteger(index) || index <= previous || index > pages.length) {\n throw new RangeError(`Page ${page.key} can't be restored at position ${index}.`);\n }\n pages.splice(index, 0, page);\n known.add(page.key);\n previous = index;\n }\n if (command.entries.length === 0) throw new TypeError(\"A command needs at least one page.\");\n return {\n plan: withPages(plan, pages),\n inverse: { type: \"pdf.deletePages\", pages: command.entries.map(({ page }) => page.key) },\n };\n }\n\n case \"pdf.movePages\": {\n const moved = new Set(positions(plan, command.pages));\n const block = plan.pages.filter((_, index) => moved.has(index));\n const rest = plan.pages.filter((_, index) => !moved.has(index));\n if (!Number.isInteger(command.to) || command.to < 0 || command.to > rest.length) {\n throw new RangeError(`Pages can't be moved to position ${command.to}.`);\n }\n const pages = [...rest.slice(0, command.to), ...block, ...rest.slice(command.to)];\n return {\n plan: withPages(plan, pages),\n inverse: { type: \"pdf.reorderPages\", order: plan.pages.map((page) => page.key) },\n };\n }\n\n case \"pdf.reorderPages\": {\n const byKey = new Map(plan.pages.map((page) => [page.key, page]));\n if (\n command.order.length !== plan.pages.length ||\n new Set(command.order).size !== command.order.length ||\n command.order.some((key) => !byKey.has(key))\n ) {\n throw new TypeError(\"A new order must list every page of the plan exactly once.\");\n }\n return {\n plan: withPages(\n plan,\n command.order.map((key) => byKey.get(key) as PdfPlanPage),\n ),\n inverse: { type: \"pdf.reorderPages\", order: plan.pages.map((page) => page.key) },\n };\n }\n\n case \"pdf.insertPages\": {\n const { pageIndexes, keys, at } = command;\n if (pageIndexes.length === 0 || keys.length !== pageIndexes.length) {\n throw new TypeError(\"An insert needs one key for each of at least one page.\");\n }\n if (!Number.isInteger(at) || at < 0 || at > plan.pages.length) {\n throw new RangeError(`Pages can't be inserted at position ${at}.`);\n }\n const known = new Set(plan.pages.map((page) => page.key));\n if (new Set(keys).size !== keys.length || keys.some((key) => known.has(key))) {\n throw new TypeError(\"Inserted pages need keys the plan doesn't have.\");\n }\n const inserted = pageIndexes.map(\n (pageIndex, index): PdfPlanPage => ({\n key: keys[index] as string,\n source: command.source,\n pageIndex,\n rotation: 0,\n annotations: [],\n }),\n );\n return {\n plan: withPages(plan, [...plan.pages.slice(0, at), ...inserted, ...plan.pages.slice(at)]),\n inverse: { type: \"pdf.deletePages\", pages: keys },\n };\n }\n\n case \"pdf.setFieldValue\": {\n const { source, field, value } = command;\n const current = plan.formValues[source] ?? {};\n const previous = Object.hasOwn(current, field) ? (current[field] as PdfFieldValue) : null;\n const next: Record<string, PdfFieldValue> = { ...current };\n if (value === null) delete next[field];\n else next[field] = value;\n const formValues: Record<string, Readonly<Record<string, PdfFieldValue>>> = {\n ...plan.formValues,\n [source]: next,\n };\n if (Object.keys(next).length === 0) delete formValues[source];\n return {\n plan: { pages: plan.pages, formValues },\n inverse: { type: \"pdf.setFieldValue\", source, field, value: previous },\n };\n }\n\n case \"pdf.addAnnotation\": {\n const { annotation } = command;\n const next = updatePage(plan, command.page, (page) => {\n if (page.annotations.some((existing) => existing.id === annotation.id)) {\n throw new TypeError(`Page ${page.key} already has annotation ${annotation.id}.`);\n }\n const index = command.index ?? page.annotations.length;\n if (!Number.isInteger(index) || index < 0 || index > page.annotations.length) {\n throw new RangeError(`The annotation can't go at position ${index}.`);\n }\n const annotations = [...page.annotations];\n annotations.splice(index, 0, annotation);\n return { ...page, annotations };\n });\n return {\n plan: next,\n inverse: { type: \"pdf.removeAnnotation\", page: command.page, id: annotation.id },\n };\n }\n\n case \"pdf.removeAnnotation\": {\n let removed: { annotation: PdfAnnotation; index: number } | undefined;\n const next = updatePage(plan, command.page, (page) => {\n const index = page.annotations.findIndex((annotation) => annotation.id === command.id);\n if (index < 0) throw new TypeError(`Page ${page.key} has no annotation ${command.id}.`);\n removed = { annotation: page.annotations[index] as PdfAnnotation, index };\n return { ...page, annotations: page.annotations.filter((_, at) => at !== index) };\n });\n const { annotation, index } = removed as { annotation: PdfAnnotation; index: number };\n return {\n plan: next,\n inverse: { type: \"pdf.addAnnotation\", page: command.page, annotation, index },\n };\n }\n\n default: {\n const unknown: never = command;\n throw new TypeError(`Unknown command ${(unknown as { type?: unknown }).type}.`);\n }\n }\n}\n\n/**\n * Applies several commands as one step, all or nothing, and returns the\n * inverse of the whole step: the inverses in reverse order.\n *\n * @internal\n */\nexport function applyCommands(\n plan: PdfPlan,\n commands: readonly PdfCommand[],\n): { plan: PdfPlan; inverses: PdfCommand[] } {\n let current = plan;\n const inverses: PdfCommand[] = [];\n for (const command of commands) {\n const applied = applyCommand(current, command);\n current = applied.plan;\n inverses.unshift(applied.inverse);\n }\n return { plan: current, inverses };\n}\n","import type { PdfCommand } from \"../operations/commands.js\";\n\n/** One undoable step: the commands it ran, and the commands that undo them. */\nexport interface HistoryStep {\n readonly commands: readonly PdfCommand[];\n readonly inverses: readonly PdfCommand[];\n}\n\n/**\n * Undo and redo stacks of command steps (ADR 0010). Steps are small plain\n * data, because edits change the plan, not bytes (docs/adr/0003). The\n * session drops steps when the documents they refer to need too much memory\n * (docs/adr/0004).\n *\n * @internal\n */\nexport class History {\n #past: HistoryStep[] = [];\n #future: HistoryStep[] = [];\n #trimmed = false;\n\n get canUndo(): boolean {\n return this.#past.length > 0;\n }\n\n get canRedo(): boolean {\n return this.#future.length > 0;\n }\n\n /** Whether steps were dropped to save memory since the history was cleared. */\n get trimmed(): boolean {\n return this.#trimmed;\n }\n\n /** Every step, undoable and redoable. */\n get steps(): readonly HistoryStep[] {\n return [...this.#past, ...this.#future];\n }\n\n /**\n * The order steps are dropped in to save memory, so the steps that remain\n * can always still be applied: first the redo steps, from the one redo\n * would reach last, then the undo steps, oldest first.\n */\n get dropOrder(): readonly HistoryStep[] {\n // Both stacks keep their far end, the step reached last, at index 0.\n return [...this.#future, ...this.#past];\n }\n\n /** Records a new step. Anything that could be redone is dropped. */\n push(step: HistoryStep): void {\n this.#past.push(step);\n this.#future = [];\n }\n\n /** The step to undo, moved to the redo stack, if there is one. */\n undo(): HistoryStep | undefined {\n const step = this.#past.pop();\n if (step) this.#future.push(step);\n return step;\n }\n\n /** The step to redo, moved back to the undo stack, if there is one. */\n redo(): HistoryStep | undefined {\n const step = this.#future.pop();\n if (step) this.#past.push(step);\n return step;\n }\n\n /** Puts a step back after it failed to apply. */\n restore(direction: \"undo\" | \"redo\"): void {\n if (direction === \"undo\") {\n const step = this.#future.pop();\n if (step) this.#past.push(step);\n } else {\n const step = this.#past.pop();\n if (step) this.#future.push(step);\n }\n }\n\n /** Drops the first `count` steps of {@link History.dropOrder}. */\n drop(count: number): void {\n if (count <= 0) return;\n const fromFuture = Math.min(count, this.#future.length);\n this.#future.splice(0, fromFuture);\n this.#past.splice(0, count - fromFuture);\n this.#trimmed = true;\n }\n\n clear(): void {\n this.#past = [];\n this.#future = [];\n this.#trimmed = false;\n }\n}\n","import { checkFile, withProcessingTime } from \"@hussmartinez/sdk-core\";\nimport { asPdfError, throwIfAborted } from \"../errors/abort.js\";\nimport { PdfError } from \"../errors/pdf-error.js\";\nimport { type PdfFilePolicyOverrides, type PdfLimitName, pdfLimits } from \"../errors/pdf-limits.js\";\nimport type { PdfBuildJob, PdfCompression, PdfEncryption } from \"../model/build-job.js\";\nimport { copyBytes } from \"../model/bytes.js\";\nimport type {\n PdfBytes,\n PdfFormField,\n PdfLink,\n PdfPageInfo,\n PdfTextContent,\n} from \"../model/document.js\";\nimport { addRotation } from \"../model/geometry.js\";\nimport { EMPTY_PLAN, type PdfPlan, type PdfPlanPage } from \"../model/plan.js\";\nimport { applyCommands, type PdfCommand } from \"../operations/commands.js\";\nimport type { PdfCallOptions } from \"../ports/options.js\";\nimport type { PdfDocumentHandle, PdfEngine, PdfRenderOptions } from \"../ports/pdf-engine.js\";\nimport type { PdfBuildOptions, PdfProcessor } from \"../ports/pdf-processor.js\";\nimport { History, type HistoryStep } from \"./history.js\";\n\n/**\n * A source document the session holds: opened or inserted, never changed.\n *\n * @public\n */\nexport interface PdfSourceInfo {\n /** Unique within the session, and never reused. */\n readonly id: string;\n readonly pageCount: number;\n /** The size of its bytes. */\n readonly byteLength: number;\n}\n\n/**\n * A file policy warning: a value at or above a limit's warning threshold,\n * but within its maximum (ADR 0020). Show its text from\n * `warnings.<limit>` in the message catalogue, with `actual` as a parameter.\n *\n * @public\n */\nexport interface PdfWarning {\n readonly limit: PdfLimitName;\n readonly actual: number;\n}\n\n/**\n * What the session is doing.\n *\n * - `empty`: no document is open.\n * - `opening`: a document is being opened, replacing any other.\n * - `ready`: a document is open.\n * - `error`: no document is open, because the last open failed; `error`\n * says why. A failed open while a document is open keeps that document,\n * with the status `ready` and `error` set.\n *\n * @public\n */\nexport type PdfSessionStatus = \"empty\" | \"opening\" | \"ready\" | \"error\";\n\n/**\n * The session's state at one moment. Snapshots are immutable: every change\n * makes a new one, so `useSyncExternalStore` and other subscribers can\n * compare them by identity.\n *\n * @public\n */\nexport interface PdfSessionSnapshot {\n readonly status: PdfSessionStatus;\n /** The document being edited: its pages, in order, and form values. */\n readonly plan: PdfPlan;\n /** The source documents the session holds. */\n readonly sources: readonly PdfSourceInfo[];\n readonly canUndo: boolean;\n readonly canRedo: boolean;\n /** Whether a document is being opened or inserted. */\n readonly busy: boolean;\n /** Why the last open or insert failed. Show its text by its code. */\n readonly error: PdfError | undefined;\n /** Limits the open documents are close to. */\n readonly warnings: readonly PdfWarning[];\n /**\n * The bytes of every document the session holds, which the\n * `maxSessionSize` limit counts: those the plan uses, and those the undo\n * and redo history can bring back (docs/adr/0004).\n */\n readonly sessionBytes: number;\n /**\n * Whether undo steps were dropped since the document opened, to make room\n * for an insert within `maxSessionSize`. Editors say so, because the\n * earliest edits can no longer be undone (ADR 0010).\n */\n readonly historyTrimmed: boolean;\n /**\n * The keys of the selected pages, in plan order. Tools act on them, such as\n * rotating the selection. View state: not undoable, and never in events.\n */\n readonly selection: readonly string[];\n /** The key of the page the user is looking at, if a document is open. */\n readonly currentPage: string | undefined;\n /**\n * The latest request to bring a page into view, from `goToPage`. Viewers\n * scroll to `page` each time `sequence` changes.\n */\n readonly navigation: { readonly page: string; readonly sequence: number } | undefined;\n}\n\n/**\n * Anonymous usage events, for a host's analytics (ADR 0010). They never\n * contain file names, contents, form values or annotation text.\n *\n * @public\n */\nexport type PdfSessionEvent =\n | { readonly type: \"document_opened\"; readonly pageCount: number }\n | { readonly type: \"document_closed\" }\n | { readonly type: \"pages_inserted\"; readonly pageCount: number }\n | { readonly type: \"command\"; readonly commands: readonly PdfCommand[\"type\"][] }\n | { readonly type: \"undo\" }\n | { readonly type: \"redo\" }\n | {\n readonly type: \"document_exported\";\n readonly pageCount: number;\n readonly compressed: boolean;\n readonly encrypted: boolean;\n }\n | {\n readonly type: \"failed\";\n readonly operation: \"open\" | \"insert\" | \"export\";\n readonly code: string;\n };\n\n/**\n * Options for {@link createPdfSession}.\n *\n * @public\n */\nexport interface PdfSessionOptions {\n /** Opens, reads and renders documents, such as `createPdfJsEngine()`. */\n readonly engine: PdfEngine;\n /** Builds exported documents, such as `createPdfProcessor()`. Needed for `export()`. */\n readonly processor?: PdfProcessor;\n /** Limits for untrusted files (docs/adr/0004). Unknown names throw. */\n readonly filePolicy?: PdfFilePolicyOverrides;\n /** Receives anonymous usage events. Errors it throws are ignored. */\n readonly onEvent?: (event: PdfSessionEvent) => void;\n}\n\n/**\n * Options for {@link PdfSession.insert}.\n *\n * @public\n */\nexport interface PdfInsertOptions extends PdfCallOptions {\n /** The position of the first inserted page. Defaults to the end. */\n readonly at?: number;\n /** Zero-based indexes of the pages to insert. Defaults to every page. */\n readonly pageIndexes?: readonly number[];\n}\n\n/**\n * Options for {@link PdfSession.export}.\n *\n * @public\n */\nexport interface PdfExportOptions extends PdfCallOptions {\n /** Compress the result, losslessly unless `images` is set. */\n readonly compress?: PdfCompression;\n /** Encrypt the result with AES-256. */\n readonly encrypt?: PdfEncryption;\n /** Called as the export moves through its steps. */\n readonly onProgress?: PdfBuildOptions[\"onProgress\"];\n}\n\n/**\n * The document being edited, as a framework-agnostic store (ADR 0008): a\n * page plan over the documents opened and inserted, edited with commands,\n * with undo and redo (ADR 0010, docs/adr/0003). React binds to it with\n * `useSyncExternalStore`, and the element binds to the same store.\n *\n * @public\n */\nexport interface PdfSession {\n /** The current snapshot, the same object until something changes. */\n getSnapshot(): PdfSessionSnapshot;\n /** Calls the listener after every change. Returns a function that unsubscribes. */\n subscribe(listener: () => void): () => void;\n /**\n * Opens a document, replacing the current one and its history once it has\n * opened. The file is checked against the file policy before it's read.\n * Rejects with a `PdfError`, which the snapshot also holds; the current\n * document, if any, stays open.\n */\n open(file: Blob | PdfBytes, options?: PdfCallOptions): Promise<void>;\n /**\n * Inserts the pages of another document, as one undoable step. If the\n * documents held would then exceed `maxSessionSize`, the session first\n * drops the redo steps, then the oldest undo steps, as far as needed to\n * release documents only they refer to, and sets `historyTrimmed`. If even\n * that isn't enough, it rejects with `SESSION_TOO_LARGE` and changes\n * nothing.\n */\n insert(file: Blob | PdfBytes, options?: PdfInsertOptions): Promise<void>;\n /**\n * Runs one command, or several as one undoable step. Throws `TypeError`\n * or `RangeError` for a command that doesn't fit the plan, and changes\n * nothing then.\n */\n execute(commands: PdfCommand | readonly PdfCommand[]): void;\n undo(): void;\n redo(): void;\n /** A plan page's size, and its rotation as shown: its own plus the plan's. */\n getPage(key: string, options?: PdfCallOptions): Promise<PdfPageInfo>;\n /** Renders a plan page with its rotation. */\n renderPage(\n key: string,\n canvas: HTMLCanvasElement,\n options: Omit<PdfRenderOptions, \"rotation\">,\n ): Promise<void>;\n /** A plan page's text, positioned on the unrotated page. */\n getTextContent(key: string, options?: PdfCallOptions): Promise<PdfTextContent>;\n /** A plan page's form fields, with the session's values applied. */\n getFormFields(key: string, options?: PdfCallOptions): Promise<readonly PdfFormField[]>;\n /** A plan page's web and email links, positioned on the unrotated page. */\n getLinks(key: string, options?: PdfCallOptions): Promise<readonly PdfLink[]>;\n /**\n * Builds the document as it is now: its pages in plan order, with their\n * rotations, form values and annotations, compressed or encrypted if asked.\n * An unchanged document with no options is returned as its original bytes,\n * without the processor. The result is a new buffer the caller owns.\n */\n export(options?: PdfExportOptions): Promise<Uint8Array>;\n /**\n * Selects pages, by key, replacing the selection. Keys the plan doesn't\n * have are ignored.\n */\n select(keys: readonly string[]): void;\n /** Records the page the user is looking at, as a viewer scrolls. */\n setCurrentPage(key: string): void;\n /** Makes a page current and asks viewers to bring it into view. */\n goToPage(key: string): void;\n /** Closes the document and releases its sources. */\n close(): Promise<void>;\n}\n\ninterface Source extends PdfSourceInfo {\n readonly bytes: Uint8Array;\n readonly document: PdfDocumentHandle;\n}\n\n/**\n * Creates a {@link PdfSession}. Pass the engine to use; the headless core\n * doesn't choose one, so it can't pull pdf.js into applications that don't\n * want it.\n *\n * @example\n * ```ts\n * const session = createPdfSession({ engine: createPdfJsEngine() });\n * await session.open(file);\n * const [first] = session.getSnapshot().plan.pages;\n * session.execute({ type: \"pdf.rotatePages\", pages: [first.key], angle: 90 });\n * session.undo();\n * ```\n *\n * @public\n */\nexport function createPdfSession(options: PdfSessionOptions): PdfSession {\n const { engine } = options;\n const policy = pdfLimits.resolve(options.filePolicy);\n const history = new History();\n const listeners = new Set<() => void>();\n const sources = new Map<string, Source>();\n let plan: PdfPlan = EMPTY_PLAN;\n let status: PdfSessionStatus = \"empty\";\n let error: PdfError | undefined;\n let warnings: PdfWarning[] = [];\n let busy = 0;\n let selection: readonly string[] = [];\n let currentPage: string | undefined;\n let navigation: { page: string; sequence: number } | undefined;\n let nextKey = 0;\n let nextSource = 0;\n /** Cancels the load in progress when a newer open replaces it. */\n let loading: AbortController | undefined;\n const heldBytes = (): number =>\n [...sources.values()].reduce((total, source) => total + source.byteLength, 0);\n\n /** The sources the plan and the given history steps refer to: only pages need bytes. */\n function referenced(steps: readonly HistoryStep[]): Set<string> {\n const ids = new Set(plan.pages.map((page) => page.source));\n for (const { commands, inverses } of steps) {\n for (const command of [...commands, ...inverses]) {\n if (command.type === \"pdf.insertPages\") ids.add(command.source);\n if (command.type === \"pdf.restorePages\") {\n for (const { page } of command.entries) ids.add(page.source);\n }\n }\n }\n return ids;\n }\n\n /** Releases the sources nothing refers to any more, and their engine documents. */\n function collect(): void {\n const keep = referenced(history.steps);\n for (const [id, source] of sources) {\n if (keep.has(id)) continue;\n sources.delete(id);\n void source.document.destroy().catch(() => {});\n }\n }\n\n /**\n * How many history steps must be dropped, in drop order, for the held\n * sources plus `extra` bytes to fit `maxSessionSize`, or undefined if\n * dropping every step isn't enough.\n */\n function stepsToDrop(extra: number): number | undefined {\n const { maximum } = policy.limits.maxSessionSize;\n const order = history.dropOrder;\n for (let count = 0; count <= order.length; count += 1) {\n const kept = new Set(order.slice(count));\n const ids = referenced(history.steps.filter((entry) => kept.has(entry)));\n const total = [...ids].reduce((sum, id) => sum + (sources.get(id)?.byteLength ?? 0), 0);\n if (total + extra <= maximum) return count;\n }\n return undefined;\n }\n\n let snapshot = makeSnapshot();\n\n /** The load warnings, and the session size warning, which follows every change. */\n function sessionWarnings(): PdfWarning[] {\n const bytes = heldBytes();\n const sessionWarning =\n bytes > 0 && bytes >= policy.limits.maxSessionSize.warning\n ? [{ limit: \"maxSessionSize\" as const, actual: bytes }]\n : [];\n return [...warnings, ...sessionWarning];\n }\n\n function makeSnapshot(): PdfSessionSnapshot {\n return Object.freeze({\n status,\n plan,\n sources: Object.freeze(\n [...sources.values()].map(({ id, pageCount, byteLength }) =>\n Object.freeze({ id, pageCount, byteLength }),\n ),\n ),\n canUndo: history.canUndo,\n canRedo: history.canRedo,\n busy: busy > 0,\n error,\n warnings: Object.freeze(sessionWarnings()),\n sessionBytes: heldBytes(),\n historyTrimmed: history.trimmed,\n selection: Object.freeze([...selection]),\n currentPage,\n navigation: navigation ? Object.freeze({ ...navigation }) : undefined,\n });\n }\n\n function changed(): void {\n // View state follows the plan: pages that left it can't be selected or current.\n const keys = new Set(plan.pages.map((page) => page.key));\n if (selection.some((key) => !keys.has(key))) {\n selection = selection.filter((key) => keys.has(key));\n }\n if (currentPage !== undefined && !keys.has(currentPage)) {\n currentPage = plan.pages[0]?.key;\n }\n if (currentPage === undefined && plan.pages.length > 0) currentPage = plan.pages[0]?.key;\n if (navigation && !keys.has(navigation.page)) navigation = undefined;\n snapshot = makeSnapshot();\n for (const listener of [...listeners]) listener();\n }\n\n function emit(event: PdfSessionEvent): void {\n try {\n options.onEvent?.(event);\n } catch {\n // A host's analytics must never break editing.\n }\n }\n\n /** Reads, checks and opens one file as a source, without registering it. */\n async function load(file: Blob | PdfBytes, signal: AbortSignal): Promise<Source> {\n const found: PdfWarning[] = [];\n const warnAt = (limit: PdfLimitName, actual: number) => {\n if (policy.check(limit, actual) === \"warning\") found.push({ limit, actual });\n };\n // The file size, before anything is read (ADR 0020).\n if (file instanceof Blob) {\n if (checkFile(policy, file) === \"warning\")\n found.push({ limit: \"maxFileSize\", actual: file.size });\n } else {\n warnAt(\"maxFileSize\", file.byteLength);\n }\n const bytes = file instanceof Blob ? new Uint8Array(await file.arrayBuffer()) : copyBytes(file);\n throwIfAborted(signal);\n const document = await withProcessingTime(\n policy,\n (limited) => engine.open(bytes, { signal: limited }),\n { signal },\n ).catch((reason: unknown) => {\n throw asPdfError(reason, \"The PDF couldn't be opened.\");\n });\n try {\n throwIfAborted(signal);\n warnAt(\"maxPages\", document.pageCount);\n } catch (reason) {\n await document.destroy();\n throw reason;\n }\n warnings = [...warnings.filter((warning) => warning.limit !== \"maxFileSize\"), ...found];\n nextSource += 1;\n return {\n id: `s${nextSource}`,\n pageCount: document.pageCount,\n byteLength: bytes.byteLength,\n bytes,\n document,\n };\n }\n\n /** Runs a load, marking the session busy, and cancelling it if a newer open starts. */\n async function track<Value>(\n signal: AbortSignal | undefined,\n replaces: boolean,\n run: (signal: AbortSignal) => Promise<Value>,\n ): Promise<Value> {\n if (replaces) loading?.abort(new PdfError(\"ABORTED\", \"A newer document replaced this one.\"));\n const controller = new AbortController();\n if (replaces) loading = controller;\n const combined = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;\n busy += 1;\n changed();\n try {\n return await run(combined);\n } finally {\n busy -= 1;\n if (loading === controller) loading = undefined;\n changed();\n }\n }\n\n async function release(): Promise<void> {\n const documents = [...sources.values()].map((source) => source.document);\n sources.clear();\n await Promise.all(documents.map((document) => document.destroy().catch(() => {})));\n }\n\n function pageFor(key: string): { page: PdfPlanPage; source: Source } {\n const page = plan.pages.find((entry) => entry.key === key);\n const source = page && sources.get(page.source);\n if (!page || !source) throw new TypeError(`The plan has no page ${key}.`);\n return { page, source };\n }\n\n function step(commands: readonly PdfCommand[]): void {\n const result = applyCommands(plan, commands);\n plan = result.plan;\n history.push({ commands, inverses: result.inverses });\n // A new step drops the redo steps, and the documents only they held.\n collect();\n }\n\n return {\n getSnapshot: () => snapshot,\n\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n\n async open(file, callOptions = {}) {\n status = \"opening\";\n error = undefined;\n try {\n const source = await track(callOptions.signal, true, async (signal) => {\n // The open document is released once this one opens, so this one\n // must fit on its own.\n policy.check(\"maxSessionSize\", file instanceof Blob ? file.size : file.byteLength);\n return load(file, signal);\n });\n await release();\n sources.set(source.id, source);\n history.clear();\n plan = {\n pages: Array.from({ length: source.pageCount }, (_, pageIndex) => {\n nextKey += 1;\n return {\n key: `p${nextKey}`,\n source: source.id,\n pageIndex,\n rotation: 0,\n annotations: [],\n };\n }),\n formValues: {},\n };\n status = \"ready\";\n changed();\n emit({ type: \"document_opened\", pageCount: source.pageCount });\n } catch (reason) {\n const failure = asPdfError(reason, \"The PDF couldn't be opened.\");\n // A newer open replaced this one; it reports its own outcome.\n if (failure.code === \"ABORTED\" && loading !== undefined) throw failure;\n // A failed open keeps the document that was already open, and its\n // history, so a bad file never costs the user their work.\n status = sources.size > 0 ? \"ready\" : \"error\";\n error = failure;\n changed();\n emit({ type: \"failed\", operation: \"open\", code: failure.code });\n throw failure;\n }\n },\n\n async insert(file, insertOptions = {}) {\n if (status !== \"ready\") {\n throw new PdfError(\"PROCESSING_FAILED\", \"Open a document before inserting another.\");\n }\n error = undefined;\n try {\n const source = await track(insertOptions.signal, false, async (signal) => {\n policy.check(\"maxFiles\", sources.size + 1);\n return load(file, signal);\n });\n try {\n const pageIndexes =\n insertOptions.pageIndexes ??\n Array.from({ length: source.pageCount }, (_, index) => index);\n for (const index of pageIndexes) {\n if (!Number.isInteger(index) || index < 0 || index >= source.pageCount) {\n throw new RangeError(`The inserted document has no page index ${index}.`);\n }\n }\n if (policy.check(\"maxPages\", plan.pages.length + pageIndexes.length) === \"warning\") {\n warnings = [\n ...warnings.filter((warning) => warning.limit !== \"maxPages\"),\n { limit: \"maxPages\", actual: plan.pages.length + pageIndexes.length },\n ];\n }\n const keys = pageIndexes.map(() => {\n nextKey += 1;\n return `p${nextKey}`;\n });\n const drop = stepsToDrop(source.byteLength);\n if (drop === undefined) {\n throw policy.error(\"maxSessionSize\", heldBytes() + source.byteLength);\n }\n history.drop(drop);\n collect();\n sources.set(source.id, source);\n step([\n {\n type: \"pdf.insertPages\",\n source: source.id,\n pageIndexes,\n at: insertOptions.at ?? plan.pages.length,\n keys,\n },\n ]);\n changed();\n emit({ type: \"pages_inserted\", pageCount: pageIndexes.length });\n } catch (reason) {\n sources.delete(source.id);\n await source.document.destroy().catch(() => {});\n throw reason;\n }\n } catch (reason) {\n if (reason instanceof TypeError || reason instanceof RangeError) throw reason;\n const failure = asPdfError(reason, \"The PDF couldn't be inserted.\");\n error = failure;\n changed();\n emit({ type: \"failed\", operation: \"insert\", code: failure.code });\n throw failure;\n }\n },\n\n execute(commands) {\n const list = Array.isArray(commands) ? commands : [commands as PdfCommand];\n if (list.length === 0) return;\n step(list);\n changed();\n emit({ type: \"command\", commands: list.map((command) => command.type) });\n },\n\n undo() {\n const entry = history.undo();\n if (!entry) return;\n try {\n plan = applyCommands(plan, entry.inverses).plan;\n } catch (reason) {\n history.restore(\"undo\");\n throw reason;\n }\n changed();\n emit({ type: \"undo\" });\n },\n\n redo() {\n const entry = history.redo();\n if (!entry) return;\n try {\n plan = applyCommands(plan, entry.commands).plan;\n } catch (reason) {\n history.restore(\"redo\");\n throw reason;\n }\n changed();\n emit({ type: \"redo\" });\n },\n\n async getPage(key, callOptions) {\n const { page, source } = pageFor(key);\n const info = await source.document.getPage(page.pageIndex, callOptions);\n return { ...info, rotation: addRotation(info.rotation, page.rotation) };\n },\n\n async renderPage(key, canvas, renderOptions) {\n const { page, source } = pageFor(key);\n await source.document.renderPage(page.pageIndex, canvas, {\n ...renderOptions,\n rotation: page.rotation,\n });\n },\n\n async getTextContent(key, callOptions) {\n const { page, source } = pageFor(key);\n return source.document.getTextContent(page.pageIndex, callOptions);\n },\n\n async getFormFields(key, callOptions) {\n const { page, source } = pageFor(key);\n const fields = await source.document.getFormFields(page.pageIndex, callOptions);\n const values = plan.formValues[source.id] ?? {};\n return fields.map((field) =>\n Object.hasOwn(values, field.name)\n ? { ...field, value: values[field.name] as typeof field.value }\n : field,\n );\n },\n\n async getLinks(key, callOptions) {\n const { page, source } = pageFor(key);\n return source.document.getLinks(page.pageIndex, callOptions);\n },\n\n async export(exportOptions = {}) {\n if (status !== \"ready\" && sources.size === 0) {\n throw new PdfError(\"PROCESSING_FAILED\", \"Open a document before exporting it.\");\n }\n const pages = plan.pages;\n const used = [...new Set(pages.map((page) => page.source))];\n const job: PdfBuildJob = {\n sources: used.map((id) => {\n const values = plan.formValues[id];\n return {\n id,\n bytes: (sources.get(id) as Source).bytes,\n ...(values && Object.keys(values).length > 0 ? { formValues: values } : {}),\n };\n }),\n pages: pages.map((page) => ({\n source: page.source,\n pageIndex: page.pageIndex,\n ...(page.rotation === 0 ? {} : { rotation: page.rotation }),\n ...(page.annotations.length === 0 ? {} : { annotations: page.annotations }),\n })),\n ...(exportOptions.compress ? { compress: exportOptions.compress } : {}),\n ...(exportOptions.encrypt ? { encrypt: exportOptions.encrypt } : {}),\n };\n const done = () =>\n emit({\n type: \"document_exported\",\n pageCount: pages.length,\n compressed: Boolean(exportOptions.compress),\n encrypted: Boolean(exportOptions.encrypt),\n });\n\n // An unchanged document with no options is its original bytes.\n const [only] = job.sources;\n const source = only && sources.get(only.id);\n if (\n job.sources.length === 1 &&\n !only?.formValues &&\n !job.compress &&\n !job.encrypt &&\n source &&\n job.pages.length === source.pageCount &&\n job.pages.every(\n (page, index) => page.pageIndex === index && !page.rotation && !page.annotations,\n )\n ) {\n throwIfAborted(exportOptions.signal);\n done();\n return copyBytes(source.bytes);\n }\n\n const { processor } = options;\n if (!processor) {\n throw new TypeError(\"Exporting an edited document needs a processor in createPdfSession.\");\n }\n busy += 1;\n changed();\n try {\n const output = await withProcessingTime(\n policy,\n (signal) =>\n processor.build(job, {\n signal,\n ...(exportOptions.onProgress ? { onProgress: exportOptions.onProgress } : {}),\n }),\n exportOptions.signal ? { signal: exportOptions.signal } : {},\n );\n done();\n return output;\n } catch (reason) {\n if (reason instanceof TypeError || reason instanceof RangeError) throw reason;\n const failure = asPdfError(reason, \"The PDF couldn't be exported.\");\n emit({ type: \"failed\", operation: \"export\", code: failure.code });\n throw failure;\n } finally {\n busy -= 1;\n changed();\n }\n },\n\n select(keys) {\n const wanted = new Set(keys);\n const next = plan.pages.filter((page) => wanted.has(page.key)).map((page) => page.key);\n if (\n next.length === selection.length &&\n next.every((key, index) => key === selection[index])\n ) {\n return;\n }\n selection = next;\n changed();\n },\n\n setCurrentPage(key) {\n if (key === currentPage || !plan.pages.some((page) => page.key === key)) return;\n currentPage = key;\n changed();\n },\n\n goToPage(key) {\n if (!plan.pages.some((page) => page.key === key)) {\n throw new TypeError(`The plan has no page ${key}.`);\n }\n currentPage = key;\n navigation = { page: key, sequence: (navigation?.sequence ?? 0) + 1 };\n changed();\n },\n\n async close() {\n loading?.abort(new PdfError(\"ABORTED\", \"The document was closed.\"));\n const hadDocument = status === \"ready\";\n await release();\n plan = EMPTY_PLAN;\n history.clear();\n warnings = [];\n error = undefined;\n status = \"empty\";\n changed();\n if (hadDocument) emit({ type: \"document_closed\" });\n },\n };\n}\n","import { defineMessages, type MessageValue, plural, sdkCoreMessages } from \"@hussmartinez/sdk-core\";\nimport type { PdfErrorCode } from \"../core/errors/pdf-error.js\";\nimport type { PdfLimitName } from \"../core/errors/pdf-limits.js\";\n\n/**\n * The PDF SDK's English message catalogue: sdk-core's messages, and text for\n * every {@link PdfErrorCode} and every limit's warning. Pass it to\n * `createMessages` from `@hussmartinez/sdk-core`, with the host's locale and\n * overrides.\n *\n * Error text is looked up by code, with the error's `details` as\n * parameters, and never taken from `error.message` (ADR 0019).\n *\n * @example\n * ```ts\n * const messages = createMessages(pdfMessages, { locale: \"en\", overrides: props.messages });\n * messages.error(error); // \"This document has 6,200 pages, which is over the 5,000-page limit.\"\n * messages.t(\"warnings.maxPages\", { actual: 1_200 });\n * ```\n *\n * @public\n */\nexport const pdfMessages = /* @__PURE__ */ defineMessages({\n ...sdkCoreMessages,\n \"errors.INVALID_PDF\": \"This file isn't a PDF, or it's too damaged to open.\",\n \"errors.PASSWORD_REQUIRED\": \"This PDF is protected with a password.\",\n \"errors.PROCESSING_FAILED\": \"Something went wrong while processing this PDF. Please try again.\",\n \"errors.TOO_MANY_PAGES\":\n \"This document has {actual, number} pages, which is over the {maximum, number}-page limit.\",\n \"errors.SESSION_TOO_LARGE\":\n \"The open documents would use {actual, fileSize}, which is over the {maximum, fileSize} limit. Close a document, or clear the undo history, and try again.\",\n \"errors.IMAGE_TOO_LARGE\":\n \"Some images are too large to show. They're kept unchanged in the document.\",\n \"warnings.maxPages\": /* @__PURE__ */ plural(\"actual\", {\n one: \"This document has {actual} page. Large documents may be slow.\",\n other: \"This document has {actual} pages. Large documents may be slow.\",\n }),\n \"warnings.maxSessionSize\":\n \"The open documents use {actual, fileSize}. Clearing the undo history frees memory.\",\n \"warnings.maxImagePixels\": \"Some images are very large and may be slow to show.\",\n \"viewer.label\": \"Document\",\n \"viewer.empty\": \"No document is open.\",\n \"viewer.page\": \"Page {page} of {count}\",\n \"viewer.webLink\": \"Link to {destination}, opens in a new tab\",\n \"viewer.emailLink\": \"Email {destination}\",\n \"thumbnails.label\": \"Pages\",\n \"thumbnails.page\": \"Page {page} of {count}\",\n \"thumbnails.number\": \"{page}\",\n \"editor.label\": \"PDF editor\",\n \"editor.start.title\": \"Open a PDF to get started\",\n \"editor.start.retryTitle\": \"Try another PDF\",\n \"editor.start.choose\": \"Choose a PDF\",\n \"editor.start.retry\": \"Choose another PDF\",\n \"editor.start.hint\": \"Or drop one here. Your file stays on this device and is never uploaded.\",\n \"editor.opening\": \"Opening the PDF…\",\n \"editor.opened\": /* @__PURE__ */ plural(\"count\", {\n one: \"Opened a PDF with {count} page.\",\n other: \"Opened a PDF with {count} pages.\",\n }),\n \"editor.closed\": \"The PDF was closed.\",\n \"editor.undone\": \"Undone.\",\n \"editor.redone\": \"Redone.\",\n \"editor.rotated\": /* @__PURE__ */ plural(\"count\", {\n one: \"Rotated {count} page.\",\n other: \"Rotated {count} pages.\",\n }),\n \"toolbar.label\": \"PDF tools\",\n \"toolbar.groups.file\": \"File\",\n \"toolbar.groups.history\": \"History\",\n \"toolbar.groups.pages\": \"Pages\",\n \"toolbar.groups.other\": \"More tools\",\n \"tools.open\": \"Open a PDF\",\n \"tools.undo\": \"Undo\",\n \"tools.redo\": \"Redo\",\n \"tools.rotate-left\": \"Rotate left\",\n \"tools.rotate-right\": \"Rotate right\",\n}) satisfies Record<`errors.${PdfErrorCode}`, MessageValue> &\n Record<`warnings.${PdfLimitName}`, MessageValue>;\n\n/**\n * The type of {@link pdfMessages}, for typing a host's overrides with\n * `MessageOverrides<PdfMessageCatalogue>`.\n *\n * @public\n */\nexport type PdfMessageCatalogue = typeof pdfMessages;\n"],"mappings":";;AAuDA,IAAa,WAAb,cAA8B,SAAuB;CAEnD,OAAyB;AAC3B;AAaA,SAAgB,WACd,OACA,MAC6C;CAC7C,OAAO,WAAW,OAAO,IAAI,KAAK,MAAM,SAAS;AACnD;;ACrEA,IAAM,UAA0B,mCAAmB,UAAU;CAC3D,cAAc;CACd,iBAAiB;AACnB,CAAC;AAUD,IAAa,aAA8D,QAAQ;AAUnF,IAAa,aAAgD,QAAQ;AAOrE,IAAa,iBAA4D,QAAQ;;ACVjF,IAAa,sBAAsB;CACjC,GAAG;CACH,UAAU;EAAE,MAAM;EAAkB,MAAM;EAAS,SAAS;EA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AEA,MAAM,QAAQ;GACZ,SAAS,MAAM,IAAI,SAAS,WAAW,0BAA0B,CAAC;GAClE,MAAM,cAAc,WAAW;GAC/B,MAAM,QAAQ;GACd,OAAO;GACP,QAAQ,MAAM;GACd,WAAW,CAAC;GACZ,QAAQ,KAAA;GACR,SAAS;GACT,QAAQ;GACR,IAAI,aAAa,KAAK,EAAE,MAAM,kBAAkB,CAAC;EACnD;CACF;AACF;;AC5uBA,IAAa,cAA8B,+BAAe;CACxD,GAAG;CACH,sBAAsB;CACtB,4BAA4B;CAC5B,4BAA4B;CAC5B,yBACE;CACF,4BACE;CACF,0BACE;CACF,qBAAqC,uBAAO,UAAU;EACpD,KAAK;EACL,OAAO;CACT,CAAC;CACD,2BACE;CACF,2BAA2B;CAC3B,gBAAgB;CAChB,gBAAgB;CAChB,eAAe;CACf,kBAAkB;CAClB,oBAAoB;CACpB,oBAAoB;CACpB,mBAAmB;CACnB,qBAAqB;CACrB,gBAAgB;CAChB,sBAAsB;CACtB,2BAA2B;CAC3B,uBAAuB;CACvB,sBAAsB;CACtB,qBAAqB;CACrB,kBAAkB;CAClB,iBAAiC,uBAAO,SAAS;EAC/C,KAAK;EACL,OAAO;CACT,CAAC;CACD,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CACjB,kBAAkC,uBAAO,SAAS;EAChD,KAAK;EACL,OAAO;CACT,CAAC;CACD,iBAAiB;CACjB,uBAAuB;CACvB,0BAA0B;CAC1B,wBAAwB;CACxB,wBAAwB;CACxB,cAAc;CACd,cAAc;CACd,cAAc;CACd,qBAAqB;CACrB,sBAAsB;AACxB,CAAC"}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
|
|
2
|
+
@layer hm.tokens, hm.base, hm.components, hm.sdk;
|
|
3
|
+
/*
|
|
4
|
+
* All styles of @hussmartinez/pdf-sdk. Applications import this file once;
|
|
5
|
+
* library code never imports CSS (ADR 0004).
|
|
6
|
+
*
|
|
7
|
+
* The layer order comes first, so it holds whichever stylesheet loads first,
|
|
8
|
+
* this one or @hussmartinez/ui's. The SDK writes only into hm.sdk, and a
|
|
9
|
+
* host's unlayered CSS beats every hm layer without !important (ADR 0005).
|
|
10
|
+
*/
|
|
11
|
+
/*
|
|
12
|
+
* PdfViewer (ADR 0003 in sdk-core, docs/adr/0003). Every value comes from a
|
|
13
|
+
* --hm-pdf-* component token, falling back to ui's semantic tokens. Layout,
|
|
14
|
+
* focus and the text and link layers stay with `unstyled`; colours and
|
|
15
|
+
* shadows don't.
|
|
16
|
+
*/
|
|
17
|
+
@layer hm.sdk {
|
|
18
|
+
.hm-pdf-viewer {
|
|
19
|
+
overflow: auto;
|
|
20
|
+
/* The viewer anchors scrolling itself, the same in every engine. */
|
|
21
|
+
overflow-anchor: none;
|
|
22
|
+
position: relative;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.hm-pdf-viewer:not([data-hm-unstyled]) {
|
|
26
|
+
background: var(--hm-pdf-viewer-bg, var(--hm-color-surface-sunken));
|
|
27
|
+
color: var(--hm-pdf-viewer-text, var(--hm-color-text));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.hm-pdf-viewer:focus-visible {
|
|
31
|
+
outline: var(--hm-focus-ring);
|
|
32
|
+
outline-offset: calc(-1 * var(--hm-focus-ring-width));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.hm-pdf-viewer-pages {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: var(--hm-pdf-page-gap, var(--hm-gap-loose));
|
|
40
|
+
padding: var(--hm-pdf-viewer-inset, var(--hm-inset-normal));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.hm-pdf-page {
|
|
44
|
+
position: relative;
|
|
45
|
+
flex: none;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.hm-pdf-viewer:not([data-hm-unstyled]) .hm-pdf-page {
|
|
50
|
+
background: var(--hm-pdf-page-bg, var(--hm-color-surface));
|
|
51
|
+
box-shadow: var(--hm-pdf-page-shadow, var(--hm-shadow-raised));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.hm-pdf-page-canvas {
|
|
55
|
+
display: block;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.hm-pdf-text-layer,
|
|
59
|
+
.hm-pdf-link-layer {
|
|
60
|
+
position: absolute;
|
|
61
|
+
top: 0;
|
|
62
|
+
left: 0;
|
|
63
|
+
transform-origin: 0 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Invisible, but selectable and read by screen readers. */
|
|
67
|
+
.hm-pdf-text-layer span {
|
|
68
|
+
position: absolute;
|
|
69
|
+
color: transparent;
|
|
70
|
+
white-space: pre;
|
|
71
|
+
transform-origin: 0 0;
|
|
72
|
+
cursor: text;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.hm-pdf-viewer:not([data-hm-unstyled]) .hm-pdf-text-layer ::selection {
|
|
76
|
+
background: var(--hm-pdf-selection-bg, var(--hm-color-accent-subtle));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.hm-pdf-link {
|
|
80
|
+
position: absolute;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* Read by screen readers, never shown: the page shows the link's text. */
|
|
84
|
+
.hm-pdf-link-label {
|
|
85
|
+
position: absolute;
|
|
86
|
+
inset: 0;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
white-space: nowrap;
|
|
89
|
+
clip-path: inset(50%);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.hm-pdf-link:focus-visible {
|
|
93
|
+
outline: var(--hm-focus-ring);
|
|
94
|
+
outline-offset: var(--hm-focus-ring-offset);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.hm-pdf-page-error {
|
|
98
|
+
position: absolute;
|
|
99
|
+
inset: 0;
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
padding: var(--hm-pdf-viewer-inset, var(--hm-inset-normal));
|
|
104
|
+
text-align: center;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.hm-pdf-viewer:not([data-hm-unstyled]) .hm-pdf-page-error {
|
|
108
|
+
color: var(--hm-pdf-error-text, var(--hm-color-danger-text));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.hm-pdf-viewer-empty {
|
|
112
|
+
margin: 0;
|
|
113
|
+
padding: var(--hm-pdf-viewer-inset, var(--hm-inset-loose));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.hm-pdf-viewer:not([data-hm-unstyled]) .hm-pdf-viewer-empty {
|
|
117
|
+
color: var(--hm-pdf-viewer-muted, var(--hm-color-text-muted));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/*
|
|
121
|
+
* PdfThumbnails. Every value is a --hm-pdf-thumbnail-* token, falling back to
|
|
122
|
+
* ui's semantic tokens. States come from ARIA attributes (ADR 0003 in
|
|
123
|
+
* sdk-core): aria-selected, aria-current and focus.
|
|
124
|
+
*/
|
|
125
|
+
@layer hm.sdk {
|
|
126
|
+
.hm-pdf-thumbnails {
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-direction: column;
|
|
129
|
+
gap: var(--hm-pdf-thumbnail-gap, var(--hm-gap-normal));
|
|
130
|
+
padding: var(--hm-pdf-thumbnails-inset, var(--hm-inset-normal));
|
|
131
|
+
overflow: auto;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.hm-pdf-thumbnails:not([data-hm-unstyled]) {
|
|
135
|
+
background: var(--hm-pdf-thumbnails-bg, var(--hm-color-surface-sunken));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* Thumbnails keep their size in the scrolling column: a flex item with a
|
|
140
|
+
* min-height, such as the target size, would otherwise shrink to it.
|
|
141
|
+
*/
|
|
142
|
+
.hm-pdf-thumbnail {
|
|
143
|
+
flex: none;
|
|
144
|
+
display: flex;
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
align-items: center;
|
|
147
|
+
gap: var(--hm-pdf-thumbnail-label-gap, var(--hm-gap-tight));
|
|
148
|
+
min-height: var(--hm-target-size);
|
|
149
|
+
cursor: pointer;
|
|
150
|
+
border-radius: var(--hm-pdf-thumbnail-radius, var(--hm-radius-control));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.hm-pdf-thumbnail:focus-visible {
|
|
154
|
+
outline: var(--hm-focus-ring);
|
|
155
|
+
outline-offset: var(--hm-focus-ring-offset);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.hm-pdf-thumbnail-frame {
|
|
159
|
+
flex: none;
|
|
160
|
+
position: relative;
|
|
161
|
+
overflow: hidden;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.hm-pdf-thumbnails:not([data-hm-unstyled]) .hm-pdf-thumbnail-frame {
|
|
165
|
+
background: var(--hm-pdf-thumbnail-bg, var(--hm-color-surface));
|
|
166
|
+
box-shadow: var(--hm-pdf-thumbnail-shadow, var(--hm-shadow-raised));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.hm-pdf-thumbnails:not([data-hm-unstyled])
|
|
170
|
+
.hm-pdf-thumbnail[aria-selected="true"]
|
|
171
|
+
.hm-pdf-thumbnail-frame {
|
|
172
|
+
outline: var(--hm-border-width-2) solid var(--hm-pdf-thumbnail-selected, var(--hm-color-accent));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.hm-pdf-thumbnail-canvas {
|
|
176
|
+
display: block;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.hm-pdf-thumbnails:not([data-hm-unstyled]) .hm-pdf-thumbnail-number {
|
|
180
|
+
color: var(--hm-pdf-thumbnail-number, var(--hm-color-text-muted));
|
|
181
|
+
font-size: var(--hm-font-size-small);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.hm-pdf-thumbnails:not([data-hm-unstyled])
|
|
185
|
+
.hm-pdf-thumbnail[aria-current="true"]
|
|
186
|
+
.hm-pdf-thumbnail-number {
|
|
187
|
+
color: var(--hm-pdf-thumbnail-current, var(--hm-color-text));
|
|
188
|
+
font-weight: var(--hm-pdf-thumbnail-current-weight, var(--hm-font-weight-strong));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/*
|
|
192
|
+
* PdfEditor. Every value is a --hm-pdf-editor-* token, falling back to ui's
|
|
193
|
+
* semantic tokens. States come from attributes: data-hm-status on the root,
|
|
194
|
+
* data-hm-dragging on the drop zone, and focus. The editor fills the height
|
|
195
|
+
* its host gives it; its viewer and thumbnails scroll within it.
|
|
196
|
+
*/
|
|
197
|
+
@layer hm.sdk {
|
|
198
|
+
.hm-pdf-editor {
|
|
199
|
+
container: hm-pdf-editor / inline-size;
|
|
200
|
+
display: grid;
|
|
201
|
+
grid-template-rows: auto minmax(0, 1fr);
|
|
202
|
+
position: relative;
|
|
203
|
+
min-height: 0;
|
|
204
|
+
height: 100%;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.hm-pdf-editor:not([data-hm-unstyled]) {
|
|
208
|
+
background: var(--hm-pdf-editor-bg, var(--hm-color-surface));
|
|
209
|
+
color: var(--hm-pdf-editor-text, var(--hm-color-text));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.hm-pdf-editor-header {
|
|
213
|
+
display: flex;
|
|
214
|
+
flex-direction: column;
|
|
215
|
+
gap: var(--hm-pdf-editor-header-gap, var(--hm-gap-tight));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.hm-pdf-editor-body {
|
|
219
|
+
display: grid;
|
|
220
|
+
grid-template-columns: minmax(0, 1fr);
|
|
221
|
+
min-height: 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/*
|
|
225
|
+
* A missing token makes a whole declaration invalid, so layout reads its
|
|
226
|
+
* semantic tokens with a percentage fallback: without ui's stylesheet the
|
|
227
|
+
* editor loses its looks, never its layout. The sidebar is five control
|
|
228
|
+
* heights wide, so it follows ui's density, from about 140 to 220 pixels;
|
|
229
|
+
* without ui it's a fifth of the editor's width.
|
|
230
|
+
*/
|
|
231
|
+
.hm-pdf-editor[data-hm-status="ready"] .hm-pdf-editor-body {
|
|
232
|
+
grid-template-columns:
|
|
233
|
+
var(--hm-pdf-editor-sidebar-width, calc(var(--hm-control-height, 4%) * 5))
|
|
234
|
+
minmax(0, 1fr);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/* On narrow screens the document gets the width; pages are still a tab away. */
|
|
238
|
+
@container hm-pdf-editor (width < 32rem) {
|
|
239
|
+
.hm-pdf-editor[data-hm-status="ready"] .hm-pdf-editor-body {
|
|
240
|
+
grid-template-columns: minmax(0, 1fr);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.hm-pdf-editor-sidebar {
|
|
244
|
+
display: none;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.hm-pdf-editor-start,
|
|
249
|
+
.hm-pdf-editor-loading {
|
|
250
|
+
display: flex;
|
|
251
|
+
flex-direction: column;
|
|
252
|
+
align-items: center;
|
|
253
|
+
justify-content: center;
|
|
254
|
+
gap: var(--hm-pdf-editor-start-gap, var(--hm-gap-normal));
|
|
255
|
+
margin: var(--hm-pdf-editor-inset, var(--hm-inset-loose));
|
|
256
|
+
padding: var(--hm-pdf-editor-inset, var(--hm-inset-loose));
|
|
257
|
+
text-align: center;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.hm-pdf-editor-start p,
|
|
261
|
+
.hm-pdf-editor-loading p {
|
|
262
|
+
margin: 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.hm-pdf-editor:not([data-hm-unstyled]) .hm-pdf-editor-start {
|
|
266
|
+
border: var(--hm-border-width-2) dashed
|
|
267
|
+
var(--hm-pdf-editor-drop-border, var(--hm-color-text-muted));
|
|
268
|
+
border-radius: var(--hm-pdf-editor-drop-radius, var(--hm-radius-control));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.hm-pdf-editor:not([data-hm-unstyled]) .hm-pdf-editor-start[data-hm-dragging] {
|
|
272
|
+
border-color: var(--hm-pdf-editor-drop-active, var(--hm-color-accent));
|
|
273
|
+
background: var(--hm-pdf-editor-drop-active-bg, var(--hm-color-accent-subtle));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.hm-pdf-editor:not([data-hm-unstyled]) .hm-pdf-editor-start-title {
|
|
277
|
+
font-weight: var(--hm-font-weight-strong);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.hm-pdf-editor:not([data-hm-unstyled]) .hm-pdf-editor-start-hint {
|
|
281
|
+
color: var(--hm-pdf-editor-muted, var(--hm-color-text-muted));
|
|
282
|
+
font-size: var(--hm-font-size-small);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.hm-pdf-editor-button {
|
|
286
|
+
min-height: var(--hm-target-size);
|
|
287
|
+
padding-inline: var(--hm-pdf-editor-button-inset, var(--hm-inset-normal));
|
|
288
|
+
font: inherit;
|
|
289
|
+
cursor: pointer;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.hm-pdf-editor:not([data-hm-unstyled]) .hm-pdf-editor-button {
|
|
293
|
+
border: 0;
|
|
294
|
+
border-radius: var(--hm-radius-control);
|
|
295
|
+
background: var(--hm-pdf-editor-button-bg, var(--hm-color-accent));
|
|
296
|
+
color: var(--hm-pdf-editor-button-text, var(--hm-color-surface));
|
|
297
|
+
font-weight: var(--hm-font-weight-strong);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.hm-pdf-editor-button:focus-visible {
|
|
301
|
+
outline: var(--hm-focus-ring);
|
|
302
|
+
outline-offset: var(--hm-focus-ring-offset);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.hm-pdf-editor-alert {
|
|
306
|
+
margin: 0;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.hm-pdf-editor-header > .hm-pdf-editor-alert,
|
|
310
|
+
.hm-pdf-editor-warnings {
|
|
311
|
+
padding-inline: var(--hm-pdf-editor-inset, var(--hm-inset-normal));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.hm-pdf-editor:not([data-hm-unstyled]) .hm-pdf-editor-alert {
|
|
315
|
+
color: var(--hm-pdf-editor-error-text, var(--hm-color-danger-text));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.hm-pdf-editor-warnings ul {
|
|
319
|
+
margin: 0;
|
|
320
|
+
padding: 0;
|
|
321
|
+
list-style: none;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.hm-pdf-editor:not([data-hm-unstyled]) .hm-pdf-editor-warnings {
|
|
325
|
+
color: var(--hm-pdf-editor-muted, var(--hm-color-text-muted));
|
|
326
|
+
font-size: var(--hm-font-size-small);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* Read by screen readers, never shown. */
|
|
330
|
+
.hm-pdf-editor-announcer {
|
|
331
|
+
position: absolute;
|
|
332
|
+
margin: 0;
|
|
333
|
+
overflow: hidden;
|
|
334
|
+
white-space: nowrap;
|
|
335
|
+
clip-path: inset(50%);
|
|
336
|
+
}
|
|
337
|
+
}
|