@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
package/dist/react.js
ADDED
|
@@ -0,0 +1,1157 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { i as createPdfJsEngine, n as createPdfSession, o as linkDestination, r as createPdfProcessor, s as safeLinkUrl, t as pdfMessages } from "./shared/en-BYB_GHqG.js";
|
|
3
|
+
import { createMessages, createShortcutRegistry, createToolRegistry, defineMessages, defineTool, resolveAssetsBase } from "@hussmartinez/sdk-core";
|
|
4
|
+
import { AnnouncerProvider, IconButton, OpenIcon, RedoIcon, RotateLeftIcon, RotateRightIcon, Toolbar, ToolbarGroup, UiMessagesProvider, UndoIcon, useAnnounce, usePlatform } from "@hussmartinez/ui/react";
|
|
5
|
+
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
|
+
import { uiMessages } from "@hussmartinez/ui";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/features/history/history-tools.ts
|
|
9
|
+
var undoTool = /* @__PURE__ */ defineTool({
|
|
10
|
+
id: "pdf.undo",
|
|
11
|
+
label: "tools.undo",
|
|
12
|
+
icon: "undo",
|
|
13
|
+
group: "history",
|
|
14
|
+
isEnabled: ({ snapshot }) => snapshot.canUndo,
|
|
15
|
+
run: ({ session }) => {
|
|
16
|
+
session.undo();
|
|
17
|
+
},
|
|
18
|
+
shortcuts: "undo"
|
|
19
|
+
});
|
|
20
|
+
var redoTool = /* @__PURE__ */ defineTool({
|
|
21
|
+
id: "pdf.redo",
|
|
22
|
+
label: "tools.redo",
|
|
23
|
+
icon: "redo",
|
|
24
|
+
group: "history",
|
|
25
|
+
isEnabled: ({ snapshot }) => snapshot.canRedo,
|
|
26
|
+
run: ({ session }) => {
|
|
27
|
+
session.redo();
|
|
28
|
+
},
|
|
29
|
+
shortcuts: "redo"
|
|
30
|
+
});
|
|
31
|
+
// src/features/open/open-tool.ts
|
|
32
|
+
var openTool = /* @__PURE__ */ defineTool({
|
|
33
|
+
id: "pdf.open",
|
|
34
|
+
label: "tools.open",
|
|
35
|
+
icon: "open",
|
|
36
|
+
group: "file",
|
|
37
|
+
run: ({ chooseFile }) => chooseFile()
|
|
38
|
+
});
|
|
39
|
+
// src/features/tool-types.ts
|
|
40
|
+
var hasDocument = ({ snapshot }) => snapshot.status === "ready";
|
|
41
|
+
// src/features/pages/rotate-tools.ts
|
|
42
|
+
function targetPages(snapshot) {
|
|
43
|
+
if (snapshot.status !== "ready") return [];
|
|
44
|
+
if (snapshot.selection.length > 0) return snapshot.selection;
|
|
45
|
+
return snapshot.currentPage === void 0 ? [] : [snapshot.currentPage];
|
|
46
|
+
}
|
|
47
|
+
function rotate({ session }, angle) {
|
|
48
|
+
const pages = targetPages(session.getSnapshot());
|
|
49
|
+
if (pages.length === 0) return;
|
|
50
|
+
session.execute({
|
|
51
|
+
type: "pdf.rotatePages",
|
|
52
|
+
pages,
|
|
53
|
+
angle
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
var hasTargets = ({ snapshot }) => hasDocument({ snapshot }) && targetPages(snapshot).length > 0;
|
|
57
|
+
// src/features/tools.ts
|
|
58
|
+
var pdfTools = [
|
|
59
|
+
openTool,
|
|
60
|
+
undoTool,
|
|
61
|
+
redoTool,
|
|
62
|
+
/* @__PURE__ */ defineTool({
|
|
63
|
+
id: "pdf.rotate-left",
|
|
64
|
+
label: "tools.rotate-left",
|
|
65
|
+
icon: "rotate-left",
|
|
66
|
+
group: "pages",
|
|
67
|
+
isEnabled: hasTargets,
|
|
68
|
+
run: (context) => rotate(context, -90),
|
|
69
|
+
shortcuts: ["["]
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ defineTool({
|
|
72
|
+
id: "pdf.rotate-right",
|
|
73
|
+
label: "tools.rotate-right",
|
|
74
|
+
icon: "rotate-right",
|
|
75
|
+
group: "pages",
|
|
76
|
+
isEnabled: hasTargets,
|
|
77
|
+
run: (context) => rotate(context, 90),
|
|
78
|
+
shortcuts: ["]"]
|
|
79
|
+
})
|
|
80
|
+
];
|
|
81
|
+
var DEFAULT_TOOLBAR = [
|
|
82
|
+
["pdf.open"],
|
|
83
|
+
["pdf.undo", "pdf.redo"],
|
|
84
|
+
["pdf.rotate-left", "pdf.rotate-right"]
|
|
85
|
+
];
|
|
86
|
+
// src/react/context.ts
|
|
87
|
+
var PdfContext = /* @__PURE__ */ createContext(void 0);
|
|
88
|
+
// src/react/editor-messages.ts
|
|
89
|
+
var pdfEditorMessages = /* @__PURE__ */ defineMessages({
|
|
90
|
+
...pdfMessages,
|
|
91
|
+
...uiMessages
|
|
92
|
+
});
|
|
93
|
+
// src/react/hooks.ts
|
|
94
|
+
function usePdfContext(hook) {
|
|
95
|
+
const value = useContext(PdfContext);
|
|
96
|
+
if (!value) throw new Error(`${hook} must be used inside a PdfSessionProvider.`);
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
function usePdfSession() {
|
|
100
|
+
return usePdfContext("usePdfSession").session;
|
|
101
|
+
}
|
|
102
|
+
function usePdfDocument() {
|
|
103
|
+
const { session } = usePdfContext("usePdfDocument");
|
|
104
|
+
return useSyncExternalStore(session.subscribe, session.getSnapshot, session.getSnapshot);
|
|
105
|
+
}
|
|
106
|
+
function usePdfMessages() {
|
|
107
|
+
return usePdfContext("usePdfMessages").messages;
|
|
108
|
+
}
|
|
109
|
+
// src/react/lazy-ports.ts
|
|
110
|
+
function checkAssetsUrl(assetsUrl) {
|
|
111
|
+
if (assetsUrl === void 0) return;
|
|
112
|
+
if (globalThis.location !== void 0) {
|
|
113
|
+
resolveAssetsBase(assetsUrl);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const parsed = new URL(String(assetsUrl), "https://server.invalid/");
|
|
117
|
+
if (parsed.search || parsed.hash) throw new TypeError("assetsUrl can't have a query or a fragment.");
|
|
118
|
+
}
|
|
119
|
+
function lazyEngine(create) {
|
|
120
|
+
let engine;
|
|
121
|
+
return {
|
|
122
|
+
open: (source, options) => {
|
|
123
|
+
engine ??= create();
|
|
124
|
+
return engine.open(source, options);
|
|
125
|
+
},
|
|
126
|
+
destroy: async () => {
|
|
127
|
+
await engine?.destroy();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function lazyProcessor(create) {
|
|
132
|
+
let processor;
|
|
133
|
+
return {
|
|
134
|
+
build: (job, options) => {
|
|
135
|
+
processor ??= create();
|
|
136
|
+
return processor.build(job, options);
|
|
137
|
+
},
|
|
138
|
+
destroy: async () => {
|
|
139
|
+
await processor?.destroy();
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// src/react/PdfSessionProvider.tsx
|
|
144
|
+
function own(props) {
|
|
145
|
+
const assets = props.assetsUrl === void 0 ? {} : { assetsUrl: props.assetsUrl };
|
|
146
|
+
checkAssetsUrl(props.assetsUrl);
|
|
147
|
+
const engine = props.engine ?? lazyEngine(() => createPdfJsEngine(assets));
|
|
148
|
+
const processor = props.processor ?? lazyProcessor(() => createPdfProcessor(assets));
|
|
149
|
+
const session = createPdfSession({
|
|
150
|
+
engine,
|
|
151
|
+
processor,
|
|
152
|
+
...props.filePolicy ? { filePolicy: props.filePolicy } : {},
|
|
153
|
+
...props.onEvent ? { onEvent: props.onEvent } : {}
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
session,
|
|
157
|
+
dispose() {
|
|
158
|
+
session.close();
|
|
159
|
+
if (!props.engine) engine.destroy();
|
|
160
|
+
if (!props.processor) processor.destroy();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function useProvidedSession(props) {
|
|
165
|
+
const given = props.session;
|
|
166
|
+
const [owned] = useState(() => given ? void 0 : own(props));
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (!owned) return;
|
|
169
|
+
const pending = owned.pending;
|
|
170
|
+
if (pending !== void 0) clearTimeout(pending);
|
|
171
|
+
return () => {
|
|
172
|
+
owned.pending = setTimeout(() => owned.dispose(), 0);
|
|
173
|
+
};
|
|
174
|
+
}, [owned]);
|
|
175
|
+
return given ?? owned.session;
|
|
176
|
+
}
|
|
177
|
+
function PdfSessionProvider(props) {
|
|
178
|
+
const { messages: overrides, locale = "en", children } = props;
|
|
179
|
+
const session = useProvidedSession(props);
|
|
180
|
+
const messages = useMemo(() => createMessages(pdfMessages, {
|
|
181
|
+
locale,
|
|
182
|
+
...overrides ? { overrides } : {}
|
|
183
|
+
}), [locale, overrides]);
|
|
184
|
+
const value = useMemo(() => ({
|
|
185
|
+
session,
|
|
186
|
+
messages
|
|
187
|
+
}), [session, messages]);
|
|
188
|
+
return /* @__PURE__ */ jsx(PdfContext.Provider, {
|
|
189
|
+
value,
|
|
190
|
+
children
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
// src/react/use-near-observer.ts
|
|
194
|
+
function useNearObserver(root) {
|
|
195
|
+
const observer = useRef(void 0);
|
|
196
|
+
const callbacks = useRef(/* @__PURE__ */ new Map());
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
const created = new IntersectionObserver((entries) => {
|
|
199
|
+
for (const entry of entries) callbacks.current.get(entry.target)?.(entry.isIntersecting);
|
|
200
|
+
}, {
|
|
201
|
+
root: root.current,
|
|
202
|
+
rootMargin: "100% 0px"
|
|
203
|
+
});
|
|
204
|
+
observer.current = created;
|
|
205
|
+
for (const element of callbacks.current.keys()) created.observe(element);
|
|
206
|
+
return () => created.disconnect();
|
|
207
|
+
}, [root]);
|
|
208
|
+
return useCallback((element, onNear) => {
|
|
209
|
+
callbacks.current.set(element, onNear);
|
|
210
|
+
observer.current?.observe(element);
|
|
211
|
+
return () => {
|
|
212
|
+
callbacks.current.delete(element);
|
|
213
|
+
observer.current?.unobserve(element);
|
|
214
|
+
};
|
|
215
|
+
}, []);
|
|
216
|
+
}
|
|
217
|
+
function useNear(observe, element, sized) {
|
|
218
|
+
const [near, setNear] = useState(false);
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
const target = element.current;
|
|
221
|
+
if (!sized || !target) return;
|
|
222
|
+
const stop = observe(target, setNear);
|
|
223
|
+
return () => {
|
|
224
|
+
stop();
|
|
225
|
+
setNear(false);
|
|
226
|
+
};
|
|
227
|
+
}, [
|
|
228
|
+
observe,
|
|
229
|
+
element,
|
|
230
|
+
sized
|
|
231
|
+
]);
|
|
232
|
+
return near;
|
|
233
|
+
}
|
|
234
|
+
// src/react/use-page-drawing.ts
|
|
235
|
+
function present(buffer, target) {
|
|
236
|
+
target.width = buffer.width;
|
|
237
|
+
target.height = buffer.height;
|
|
238
|
+
target.style.width = buffer.style.width;
|
|
239
|
+
target.style.height = buffer.style.height;
|
|
240
|
+
target.getContext("2d")?.drawImage(buffer, 0, 0);
|
|
241
|
+
}
|
|
242
|
+
function usePageDrawing(options) {
|
|
243
|
+
const { session, pageKey, rotation, near, displayWidth, queue, onMeasured } = options;
|
|
244
|
+
const canvas = useRef(null);
|
|
245
|
+
const [info, setInfo] = useState();
|
|
246
|
+
const [drawn, setDrawn] = useState(false);
|
|
247
|
+
const [failure, setFailure] = useState();
|
|
248
|
+
const measured = useRef(onMeasured);
|
|
249
|
+
measured.current = onMeasured;
|
|
250
|
+
useEffect(() => {
|
|
251
|
+
if (!near) return;
|
|
252
|
+
const controller = new AbortController();
|
|
253
|
+
session.getPage(pageKey, { signal: controller.signal }).then((read) => {
|
|
254
|
+
setInfo(read);
|
|
255
|
+
measured.current?.(read);
|
|
256
|
+
}, (reason) => {
|
|
257
|
+
if (!controller.signal.aborted) setFailure(reason);
|
|
258
|
+
});
|
|
259
|
+
return () => controller.abort();
|
|
260
|
+
}, [
|
|
261
|
+
near,
|
|
262
|
+
session,
|
|
263
|
+
pageKey,
|
|
264
|
+
rotation
|
|
265
|
+
]);
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
const target = canvas.current;
|
|
268
|
+
if (!near || !info || !target || displayWidth <= 0) return;
|
|
269
|
+
const turned = info.rotation === 90 || info.rotation === 270;
|
|
270
|
+
const scale = displayWidth / (turned ? info.height : info.width);
|
|
271
|
+
const render = queue.schedule(async (signal) => {
|
|
272
|
+
const buffer = document.createElement("canvas");
|
|
273
|
+
try {
|
|
274
|
+
await session.renderPage(pageKey, buffer, {
|
|
275
|
+
scale,
|
|
276
|
+
pixelRatio: globalThis.devicePixelRatio || 1,
|
|
277
|
+
signal
|
|
278
|
+
});
|
|
279
|
+
if (!signal.aborted) {
|
|
280
|
+
present(buffer, target);
|
|
281
|
+
setDrawn(true);
|
|
282
|
+
setFailure(void 0);
|
|
283
|
+
}
|
|
284
|
+
} catch (reason) {
|
|
285
|
+
if (!signal.aborted) setFailure(reason);
|
|
286
|
+
} finally {
|
|
287
|
+
buffer.width = 0;
|
|
288
|
+
buffer.height = 0;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
return () => render.cancel();
|
|
292
|
+
}, [
|
|
293
|
+
near,
|
|
294
|
+
info,
|
|
295
|
+
displayWidth,
|
|
296
|
+
session,
|
|
297
|
+
pageKey,
|
|
298
|
+
queue
|
|
299
|
+
]);
|
|
300
|
+
useEffect(() => {
|
|
301
|
+
if (near) return;
|
|
302
|
+
const target = canvas.current;
|
|
303
|
+
if (target) {
|
|
304
|
+
target.width = 0;
|
|
305
|
+
target.height = 0;
|
|
306
|
+
}
|
|
307
|
+
setDrawn(false);
|
|
308
|
+
}, [near]);
|
|
309
|
+
return {
|
|
310
|
+
canvas,
|
|
311
|
+
info,
|
|
312
|
+
drawn,
|
|
313
|
+
failure
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
// src/react/viewer/geometry.ts
|
|
317
|
+
function pageGeometry(size, rotation, displayWidth) {
|
|
318
|
+
const turned = rotation === 90 || rotation === 270;
|
|
319
|
+
const scale = displayWidth / (turned ? size.height : size.width);
|
|
320
|
+
const pageWidth = size.width * scale;
|
|
321
|
+
const pageHeight = size.height * scale;
|
|
322
|
+
const width = turned ? pageHeight : pageWidth;
|
|
323
|
+
const height = turned ? pageWidth : pageHeight;
|
|
324
|
+
return {
|
|
325
|
+
width,
|
|
326
|
+
height,
|
|
327
|
+
pageWidth,
|
|
328
|
+
pageHeight,
|
|
329
|
+
transform: {
|
|
330
|
+
0: "none",
|
|
331
|
+
90: `translate(${width}px, 0) rotate(90deg)`,
|
|
332
|
+
180: `translate(${width}px, ${height}px) rotate(180deg)`,
|
|
333
|
+
270: `translate(0, ${height}px) rotate(270deg)`
|
|
334
|
+
}[rotation]
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
// src/react/viewer/render-queue.ts
|
|
338
|
+
var RenderQueue = class {
|
|
339
|
+
#limit;
|
|
340
|
+
#running = 0;
|
|
341
|
+
#waiting = [];
|
|
342
|
+
constructor(limit = 2) {
|
|
343
|
+
this.#limit = Math.max(1, limit);
|
|
344
|
+
}
|
|
345
|
+
schedule(task) {
|
|
346
|
+
const entry = {
|
|
347
|
+
task,
|
|
348
|
+
controller: new AbortController()
|
|
349
|
+
};
|
|
350
|
+
this.#waiting.push(entry);
|
|
351
|
+
this.#next();
|
|
352
|
+
return { cancel: () => {
|
|
353
|
+
const index = this.#waiting.indexOf(entry);
|
|
354
|
+
if (index >= 0) this.#waiting.splice(index, 1);
|
|
355
|
+
entry.controller.abort();
|
|
356
|
+
} };
|
|
357
|
+
}
|
|
358
|
+
#next() {
|
|
359
|
+
while (this.#running < this.#limit && this.#waiting.length > 0) {
|
|
360
|
+
const entry = this.#waiting.pop();
|
|
361
|
+
this.#running += 1;
|
|
362
|
+
entry.task(entry.controller.signal).catch(() => {}).finally(() => {
|
|
363
|
+
this.#running -= 1;
|
|
364
|
+
this.#next();
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
// src/react/thumbnails/PdfThumbnails.tsx
|
|
370
|
+
var LETTER$1 = {
|
|
371
|
+
width: 612,
|
|
372
|
+
height: 792
|
|
373
|
+
};
|
|
374
|
+
var join$3 = (...names) => names.filter(Boolean).join(" ");
|
|
375
|
+
function Thumbnail(props) {
|
|
376
|
+
const { page, index, count, id, selected, current, active, displayWidth, classNames } = props;
|
|
377
|
+
const messages = usePdfMessages();
|
|
378
|
+
const element = useRef(null);
|
|
379
|
+
const near = useNear(props.observe, element, displayWidth > 0);
|
|
380
|
+
const { canvas, info, drawn } = usePageDrawing({
|
|
381
|
+
session: props.session,
|
|
382
|
+
pageKey: page.key,
|
|
383
|
+
rotation: page.rotation,
|
|
384
|
+
near,
|
|
385
|
+
displayWidth,
|
|
386
|
+
queue: props.queue,
|
|
387
|
+
onMeasured: props.onMeasured
|
|
388
|
+
});
|
|
389
|
+
const geometry = pageGeometry(info ?? { ...props.estimate }, info?.rotation ?? 0, displayWidth);
|
|
390
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
391
|
+
ref: element,
|
|
392
|
+
id,
|
|
393
|
+
role: "option",
|
|
394
|
+
"aria-selected": selected,
|
|
395
|
+
"aria-current": current ? "true" : void 0,
|
|
396
|
+
"aria-label": messages.t("thumbnails.page", {
|
|
397
|
+
page: index + 1,
|
|
398
|
+
count
|
|
399
|
+
}),
|
|
400
|
+
"aria-busy": near && !drawn,
|
|
401
|
+
tabIndex: active ? 0 : -1,
|
|
402
|
+
className: join$3("hm-pdf-thumbnail", classNames.thumbnail),
|
|
403
|
+
"data-hm-page-key": page.key,
|
|
404
|
+
onClick: (event) => props.onPointer(index, event),
|
|
405
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
406
|
+
className: join$3("hm-pdf-thumbnail-frame", classNames.frame),
|
|
407
|
+
style: {
|
|
408
|
+
width: `${geometry.width}px`,
|
|
409
|
+
height: `${geometry.height}px`
|
|
410
|
+
},
|
|
411
|
+
children: /* @__PURE__ */ jsx("canvas", {
|
|
412
|
+
ref: canvas,
|
|
413
|
+
"aria-hidden": "true",
|
|
414
|
+
className: join$3("hm-pdf-thumbnail-canvas", classNames.canvas)
|
|
415
|
+
})
|
|
416
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
417
|
+
"aria-hidden": "true",
|
|
418
|
+
className: join$3("hm-pdf-thumbnail-number", classNames.number),
|
|
419
|
+
children: messages.t("thumbnails.number", { page: index + 1 })
|
|
420
|
+
})]
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
function PdfThumbnails(props) {
|
|
424
|
+
const { className, classNames = {}, unstyled = false, concurrency = 2 } = props;
|
|
425
|
+
const session = usePdfSession();
|
|
426
|
+
const snapshot = usePdfDocument();
|
|
427
|
+
const messages = usePdfMessages();
|
|
428
|
+
const root = useRef(null);
|
|
429
|
+
const prefix = useId();
|
|
430
|
+
const observe = useNearObserver(root);
|
|
431
|
+
const [queue] = useState(() => new RenderQueue(concurrency));
|
|
432
|
+
const [width, setWidth] = useState(0);
|
|
433
|
+
const [estimate, setEstimate] = useState(LETTER$1);
|
|
434
|
+
const [activeKey, setActiveKey] = useState();
|
|
435
|
+
const anchor = useRef(void 0);
|
|
436
|
+
const { plan, selection, currentPage } = snapshot;
|
|
437
|
+
const keys = plan.pages.map((page) => page.key);
|
|
438
|
+
const active = activeKey && keys.includes(activeKey) ? activeKey : currentPage ?? keys[0];
|
|
439
|
+
const activeIndex = active ? keys.indexOf(active) : -1;
|
|
440
|
+
useEffect(() => {
|
|
441
|
+
const element = root.current;
|
|
442
|
+
if (!element) return;
|
|
443
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
444
|
+
if (entry) setWidth(entry.contentRect.width);
|
|
445
|
+
});
|
|
446
|
+
observer.observe(element);
|
|
447
|
+
return () => observer.disconnect();
|
|
448
|
+
}, []);
|
|
449
|
+
useEffect(() => {
|
|
450
|
+
const element = root.current;
|
|
451
|
+
if (!element || !currentPage || element.contains(document.activeElement)) return;
|
|
452
|
+
element.querySelector(`[data-hm-page-key="${CSS.escape(currentPage)}"]`)?.scrollIntoView({ block: "nearest" });
|
|
453
|
+
}, [currentPage]);
|
|
454
|
+
const onMeasured = useCallback((info) => {
|
|
455
|
+
setEstimate((current) => current === LETTER$1 ? {
|
|
456
|
+
width: info.width,
|
|
457
|
+
height: info.height
|
|
458
|
+
} : current);
|
|
459
|
+
}, []);
|
|
460
|
+
const focus = (index) => {
|
|
461
|
+
const key = keys[index];
|
|
462
|
+
if (!key) return;
|
|
463
|
+
setActiveKey(key);
|
|
464
|
+
root.current?.querySelector(`[data-hm-page-key="${CSS.escape(key)}"]`)?.focus();
|
|
465
|
+
};
|
|
466
|
+
const choose = (index, mode) => {
|
|
467
|
+
const key = keys[index];
|
|
468
|
+
if (!key) return;
|
|
469
|
+
focus(index);
|
|
470
|
+
if (mode === "focus") return;
|
|
471
|
+
if (mode === "toggle") {
|
|
472
|
+
session.select(selection.includes(key) ? selection.filter((k) => k !== key) : [...selection, key]);
|
|
473
|
+
anchor.current = key;
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
if (mode === "range" && anchor.current && keys.includes(anchor.current)) {
|
|
477
|
+
const from = keys.indexOf(anchor.current);
|
|
478
|
+
const [start, end] = from < index ? [from, index] : [index, from];
|
|
479
|
+
session.select(keys.slice(start, end + 1));
|
|
480
|
+
} else {
|
|
481
|
+
session.select([key]);
|
|
482
|
+
anchor.current = key;
|
|
483
|
+
}
|
|
484
|
+
session.goToPage(key);
|
|
485
|
+
};
|
|
486
|
+
const onKeyDown = (event) => {
|
|
487
|
+
if (keys.length === 0) return;
|
|
488
|
+
const modifier = event.ctrlKey || event.metaKey;
|
|
489
|
+
const move = (index) => {
|
|
490
|
+
event.preventDefault();
|
|
491
|
+
const target = Math.max(0, Math.min(keys.length - 1, index));
|
|
492
|
+
choose(target, event.shiftKey ? "range" : modifier ? "focus" : "only");
|
|
493
|
+
};
|
|
494
|
+
switch (event.key) {
|
|
495
|
+
case "ArrowDown":
|
|
496
|
+
case "ArrowRight":
|
|
497
|
+
move(activeIndex + 1);
|
|
498
|
+
break;
|
|
499
|
+
case "ArrowUp":
|
|
500
|
+
case "ArrowLeft":
|
|
501
|
+
move(activeIndex - 1);
|
|
502
|
+
break;
|
|
503
|
+
case "Home":
|
|
504
|
+
move(0);
|
|
505
|
+
break;
|
|
506
|
+
case "End":
|
|
507
|
+
move(keys.length - 1);
|
|
508
|
+
break;
|
|
509
|
+
case " ":
|
|
510
|
+
event.preventDefault();
|
|
511
|
+
if (activeIndex >= 0) choose(activeIndex, "toggle");
|
|
512
|
+
break;
|
|
513
|
+
case "Escape":
|
|
514
|
+
if (active) session.select([active]);
|
|
515
|
+
break;
|
|
516
|
+
case "a":
|
|
517
|
+
case "A": if (modifier) {
|
|
518
|
+
event.preventDefault();
|
|
519
|
+
session.select(keys);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
const onPointer = (index, event) => {
|
|
524
|
+
choose(index, event.shiftKey ? "range" : event.ctrlKey || event.metaKey ? "toggle" : "only");
|
|
525
|
+
};
|
|
526
|
+
return /* @__PURE__ */ jsx("div", {
|
|
527
|
+
ref: root,
|
|
528
|
+
role: "listbox",
|
|
529
|
+
"aria-label": messages.t("thumbnails.label"),
|
|
530
|
+
"aria-multiselectable": "true",
|
|
531
|
+
"aria-orientation": "vertical",
|
|
532
|
+
tabIndex: keys.length === 0 ? 0 : -1,
|
|
533
|
+
onKeyDown,
|
|
534
|
+
className: join$3("hm-pdf-thumbnails", className, classNames.root),
|
|
535
|
+
...unstyled ? { "data-hm-unstyled": "" } : {},
|
|
536
|
+
children: plan.pages.map((page, index) => /* @__PURE__ */ jsx(Thumbnail, {
|
|
537
|
+
page,
|
|
538
|
+
index,
|
|
539
|
+
count: keys.length,
|
|
540
|
+
id: `${prefix}-${page.key}`,
|
|
541
|
+
selected: selection.includes(page.key),
|
|
542
|
+
current: page.key === currentPage,
|
|
543
|
+
active: page.key === active,
|
|
544
|
+
displayWidth: width,
|
|
545
|
+
estimate,
|
|
546
|
+
observe,
|
|
547
|
+
queue,
|
|
548
|
+
session,
|
|
549
|
+
onMeasured,
|
|
550
|
+
onPointer,
|
|
551
|
+
classNames
|
|
552
|
+
}, page.key))
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
// src/react/toolbar/icons.ts
|
|
556
|
+
var pdfIcons = {
|
|
557
|
+
open: OpenIcon,
|
|
558
|
+
undo: UndoIcon,
|
|
559
|
+
redo: RedoIcon,
|
|
560
|
+
"rotate-left": RotateLeftIcon,
|
|
561
|
+
"rotate-right": RotateRightIcon
|
|
562
|
+
};
|
|
563
|
+
// src/react/toolbar/PdfToolbar.tsx
|
|
564
|
+
function PdfToolbar(props) {
|
|
565
|
+
const { registry, shortcuts, context, icons, onRun, className } = props;
|
|
566
|
+
const messages = usePdfMessages();
|
|
567
|
+
const state = { snapshot: usePdfDocument() };
|
|
568
|
+
const t = messages.t;
|
|
569
|
+
const run = onRun ?? ((tool) => void tool.run(context));
|
|
570
|
+
if (registry.toolbar.length === 0) return null;
|
|
571
|
+
return /* @__PURE__ */ jsx(Toolbar, {
|
|
572
|
+
label: messages.t("toolbar.label"),
|
|
573
|
+
...className ? { className } : {},
|
|
574
|
+
children: registry.toolbar.map((group) => /* @__PURE__ */ jsx(ToolbarGroup, {
|
|
575
|
+
label: t(`toolbar.groups.${group[0]?.group ?? "other"}`),
|
|
576
|
+
children: group.filter((tool) => tool.isAvailable?.(state) ?? true).map((tool) => {
|
|
577
|
+
const Icon = icons[tool.icon];
|
|
578
|
+
const keys = shortcuts?.ariaKeyShortcuts(tool.id);
|
|
579
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
580
|
+
"data-hm-tool": tool.id,
|
|
581
|
+
label: t(tool.label),
|
|
582
|
+
icon: Icon ? /* @__PURE__ */ jsx(Icon, {}) : null,
|
|
583
|
+
disabled: !(tool.isEnabled?.(state) ?? true),
|
|
584
|
+
...keys ? { "aria-keyshortcuts": keys } : {},
|
|
585
|
+
onClick: () => run(tool)
|
|
586
|
+
}, tool.id);
|
|
587
|
+
})
|
|
588
|
+
}, group.map((tool) => tool.id).join(" ")))
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
// src/react/viewer/PdfViewerPage.tsx
|
|
592
|
+
var join$2 = (...names) => names.filter(Boolean).join(" ");
|
|
593
|
+
function PdfViewerPage(props) {
|
|
594
|
+
const { page, number, count, displayWidth, estimate, observe, queue, onMeasured, classNames } = props;
|
|
595
|
+
const session = usePdfSession();
|
|
596
|
+
const messages = usePdfMessages();
|
|
597
|
+
const element = useRef(null);
|
|
598
|
+
const textLayer = useRef(null);
|
|
599
|
+
const near = useNear(observe, element, displayWidth > 0);
|
|
600
|
+
const [text, setText] = useState();
|
|
601
|
+
const [links, setLinks] = useState([]);
|
|
602
|
+
const { canvas, info, drawn, failure } = usePageDrawing({
|
|
603
|
+
session,
|
|
604
|
+
pageKey: page.key,
|
|
605
|
+
rotation: page.rotation,
|
|
606
|
+
near,
|
|
607
|
+
displayWidth,
|
|
608
|
+
queue,
|
|
609
|
+
onMeasured
|
|
610
|
+
});
|
|
611
|
+
useEffect(() => {
|
|
612
|
+
if (!near || text) return;
|
|
613
|
+
const controller = new AbortController();
|
|
614
|
+
const signal = controller.signal;
|
|
615
|
+
Promise.all([session.getTextContent(page.key, { signal }), session.getLinks(page.key, { signal })]).then(([content, found]) => {
|
|
616
|
+
setText(content);
|
|
617
|
+
setLinks(found);
|
|
618
|
+
}, () => {});
|
|
619
|
+
return () => controller.abort();
|
|
620
|
+
}, [
|
|
621
|
+
near,
|
|
622
|
+
session,
|
|
623
|
+
page.key,
|
|
624
|
+
text
|
|
625
|
+
]);
|
|
626
|
+
const geometry = pageGeometry(info ?? {
|
|
627
|
+
...estimate,
|
|
628
|
+
rotation: 0
|
|
629
|
+
}, info?.rotation ?? 0, displayWidth);
|
|
630
|
+
useLayoutEffect(() => {
|
|
631
|
+
const layer = textLayer.current;
|
|
632
|
+
if (!layer || !text) return;
|
|
633
|
+
for (const span of layer.querySelectorAll("[data-hm-width]")) {
|
|
634
|
+
span.style.transform = "";
|
|
635
|
+
const natural = span.getBoundingClientRect().width;
|
|
636
|
+
const wanted = Number(span.dataset["hmWidth"]) * geometry.pageWidth;
|
|
637
|
+
if (natural > 0 && wanted > 0) span.style.transform = `scaleX(${wanted / natural})`;
|
|
638
|
+
}
|
|
639
|
+
}, [text, geometry.pageWidth]);
|
|
640
|
+
const overlay = {
|
|
641
|
+
width: `${geometry.pageWidth}px`,
|
|
642
|
+
height: `${geometry.pageHeight}px`,
|
|
643
|
+
transform: geometry.transform
|
|
644
|
+
};
|
|
645
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
646
|
+
ref: element,
|
|
647
|
+
role: "group",
|
|
648
|
+
"aria-label": messages.t("viewer.page", {
|
|
649
|
+
page: number,
|
|
650
|
+
count
|
|
651
|
+
}),
|
|
652
|
+
"aria-busy": near && !drawn && !failure,
|
|
653
|
+
className: join$2("hm-pdf-page", classNames.page),
|
|
654
|
+
"data-hm-page-key": page.key,
|
|
655
|
+
style: {
|
|
656
|
+
width: `${geometry.width}px`,
|
|
657
|
+
height: `${geometry.height}px`
|
|
658
|
+
},
|
|
659
|
+
children: [
|
|
660
|
+
/* @__PURE__ */ jsx("canvas", {
|
|
661
|
+
ref: canvas,
|
|
662
|
+
"aria-hidden": "true",
|
|
663
|
+
className: join$2("hm-pdf-page-canvas", classNames.canvas)
|
|
664
|
+
}),
|
|
665
|
+
failure !== void 0 ? /* @__PURE__ */ jsx("p", {
|
|
666
|
+
role: "alert",
|
|
667
|
+
className: join$2("hm-pdf-page-error", classNames.error),
|
|
668
|
+
children: messages.error(failure)
|
|
669
|
+
}) : null,
|
|
670
|
+
near && text ? /* @__PURE__ */ jsx("div", {
|
|
671
|
+
ref: textLayer,
|
|
672
|
+
className: join$2("hm-pdf-text-layer", classNames.textLayer),
|
|
673
|
+
style: overlay,
|
|
674
|
+
children: text.items.map((item, index) => /* @__PURE__ */ jsxs("span", {
|
|
675
|
+
"data-hm-width": item.rect.width,
|
|
676
|
+
style: {
|
|
677
|
+
left: `${item.rect.x * 100}%`,
|
|
678
|
+
top: `${item.rect.y * 100}%`,
|
|
679
|
+
fontSize: `${item.rect.height * geometry.pageHeight}px`,
|
|
680
|
+
lineHeight: 1
|
|
681
|
+
},
|
|
682
|
+
children: [item.text, item.endOfLine ? "\n" : ""]
|
|
683
|
+
}, index))
|
|
684
|
+
}) : null,
|
|
685
|
+
near && links.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
686
|
+
className: join$2("hm-pdf-link-layer", classNames.linkLayer),
|
|
687
|
+
style: overlay,
|
|
688
|
+
children: links.map((link, index) => {
|
|
689
|
+
const href = safeLinkUrl(link.url);
|
|
690
|
+
const destination = href && linkDestination(href);
|
|
691
|
+
if (!href || !destination) return null;
|
|
692
|
+
const email = href.startsWith("mailto:");
|
|
693
|
+
const label = email ? messages.t("viewer.emailLink", { destination }) : messages.t("viewer.webLink", { destination });
|
|
694
|
+
return /* @__PURE__ */ jsx("a", {
|
|
695
|
+
className: join$2("hm-pdf-link", classNames.link),
|
|
696
|
+
href,
|
|
697
|
+
target: email ? void 0 : "_blank",
|
|
698
|
+
rel: "noopener noreferrer",
|
|
699
|
+
referrerPolicy: "no-referrer",
|
|
700
|
+
title: label,
|
|
701
|
+
style: {
|
|
702
|
+
left: `${link.rect.x * 100}%`,
|
|
703
|
+
top: `${link.rect.y * 100}%`,
|
|
704
|
+
width: `${link.rect.width * 100}%`,
|
|
705
|
+
height: `${link.rect.height * 100}%`
|
|
706
|
+
},
|
|
707
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
708
|
+
className: "hm-pdf-link-label",
|
|
709
|
+
children: label
|
|
710
|
+
})
|
|
711
|
+
}, index);
|
|
712
|
+
})
|
|
713
|
+
}) : null
|
|
714
|
+
]
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
// src/react/viewer/PdfViewer.tsx
|
|
718
|
+
var LETTER = {
|
|
719
|
+
width: 612,
|
|
720
|
+
height: 792
|
|
721
|
+
};
|
|
722
|
+
var join$1 = (...names) => names.filter(Boolean).join(" ");
|
|
723
|
+
function PdfViewer(props) {
|
|
724
|
+
const { className, classNames = {}, unstyled = false, zoom = 1, concurrency = 2 } = props;
|
|
725
|
+
const snapshot = usePdfDocument();
|
|
726
|
+
const messages = usePdfMessages();
|
|
727
|
+
const root = useRef(null);
|
|
728
|
+
const pages = useRef(null);
|
|
729
|
+
const [width, setWidth] = useState(0);
|
|
730
|
+
const [estimate, setEstimate] = useState(LETTER);
|
|
731
|
+
const [queue] = useState(() => new RenderQueue(concurrency));
|
|
732
|
+
const observe = useNearObserver(root);
|
|
733
|
+
const session = usePdfSession();
|
|
734
|
+
const anchor = useRef(void 0);
|
|
735
|
+
const own = useRef(void 0);
|
|
736
|
+
const findPage = useCallback((key) => root.current?.querySelector(`[data-hm-page-key="${CSS.escape(key)}"]`) ?? void 0, []);
|
|
737
|
+
const scrollOwn = useCallback((element, top) => {
|
|
738
|
+
element.scrollTop = top;
|
|
739
|
+
own.current = element.scrollTop;
|
|
740
|
+
}, []);
|
|
741
|
+
useEffect(() => {
|
|
742
|
+
const element = pages.current;
|
|
743
|
+
if (!element) return;
|
|
744
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
745
|
+
if (entry) setWidth(entry.contentRect.width);
|
|
746
|
+
const viewer = root.current;
|
|
747
|
+
const held = anchor.current;
|
|
748
|
+
if (!viewer || !held) return;
|
|
749
|
+
const page = findPage(held.key);
|
|
750
|
+
if (!page) {
|
|
751
|
+
anchor.current = void 0;
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
const top = page.offsetTop - held.offset;
|
|
755
|
+
if (Math.abs(viewer.scrollTop - top) >= 1) scrollOwn(viewer, top);
|
|
756
|
+
});
|
|
757
|
+
observer.observe(element);
|
|
758
|
+
return () => observer.disconnect();
|
|
759
|
+
}, [findPage, scrollOwn]);
|
|
760
|
+
useEffect(() => {
|
|
761
|
+
const element = root.current;
|
|
762
|
+
if (!element) return;
|
|
763
|
+
let frame = 0;
|
|
764
|
+
const measure = () => {
|
|
765
|
+
frame = 0;
|
|
766
|
+
const { scrollTop } = element;
|
|
767
|
+
const line = scrollTop + element.clientHeight / 3;
|
|
768
|
+
const user = own.current === void 0 || Math.abs(scrollTop - own.current) >= 1;
|
|
769
|
+
let current;
|
|
770
|
+
let top;
|
|
771
|
+
for (const page of element.querySelectorAll("[data-hm-page-key]")) {
|
|
772
|
+
if (page.offsetTop > line) break;
|
|
773
|
+
current = page;
|
|
774
|
+
if (page.offsetTop <= scrollTop || !top) top = page;
|
|
775
|
+
}
|
|
776
|
+
if (user) {
|
|
777
|
+
own.current = void 0;
|
|
778
|
+
anchor.current = top && {
|
|
779
|
+
key: top.dataset["hmPageKey"],
|
|
780
|
+
offset: top.offsetTop - scrollTop
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
const key = current?.dataset["hmPageKey"];
|
|
784
|
+
if (key) session.setCurrentPage(key);
|
|
785
|
+
};
|
|
786
|
+
const onScroll = () => {
|
|
787
|
+
frame ||= requestAnimationFrame(measure);
|
|
788
|
+
};
|
|
789
|
+
element.addEventListener("scroll", onScroll, { passive: true });
|
|
790
|
+
return () => {
|
|
791
|
+
element.removeEventListener("scroll", onScroll);
|
|
792
|
+
cancelAnimationFrame(frame);
|
|
793
|
+
};
|
|
794
|
+
}, [session]);
|
|
795
|
+
const sequence = snapshot.navigation?.sequence;
|
|
796
|
+
const target = snapshot.navigation?.page;
|
|
797
|
+
useEffect(() => {
|
|
798
|
+
const element = root.current;
|
|
799
|
+
if (!element || sequence === void 0 || target === void 0) return;
|
|
800
|
+
const page = findPage(target);
|
|
801
|
+
if (!page) return;
|
|
802
|
+
const inset = Number.parseFloat(getComputedStyle(pages.current).paddingTop) || 0;
|
|
803
|
+
anchor.current = {
|
|
804
|
+
key: target,
|
|
805
|
+
offset: inset
|
|
806
|
+
};
|
|
807
|
+
scrollOwn(element, page.offsetTop - inset);
|
|
808
|
+
}, [
|
|
809
|
+
sequence,
|
|
810
|
+
target,
|
|
811
|
+
findPage,
|
|
812
|
+
scrollOwn
|
|
813
|
+
]);
|
|
814
|
+
const onMeasured = useCallback((info) => {
|
|
815
|
+
setEstimate((current) => current === LETTER ? {
|
|
816
|
+
width: info.width,
|
|
817
|
+
height: info.height
|
|
818
|
+
} : current);
|
|
819
|
+
}, []);
|
|
820
|
+
const { plan } = snapshot;
|
|
821
|
+
const displayWidth = Math.max(0, width * zoom);
|
|
822
|
+
return /* @__PURE__ */ jsx("section", {
|
|
823
|
+
ref: root,
|
|
824
|
+
tabIndex: 0,
|
|
825
|
+
"aria-label": messages.t("viewer.label"),
|
|
826
|
+
className: join$1("hm-pdf-viewer", className, classNames.root),
|
|
827
|
+
...unstyled ? { "data-hm-unstyled": "" } : {},
|
|
828
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
829
|
+
ref: pages,
|
|
830
|
+
className: join$1("hm-pdf-viewer-pages", classNames.pages),
|
|
831
|
+
children: plan.pages.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
832
|
+
className: join$1("hm-pdf-viewer-empty", classNames.empty),
|
|
833
|
+
children: messages.t("viewer.empty")
|
|
834
|
+
}) : plan.pages.map((page, index) => /* @__PURE__ */ jsx(PdfViewerPage, {
|
|
835
|
+
page,
|
|
836
|
+
number: index + 1,
|
|
837
|
+
count: plan.pages.length,
|
|
838
|
+
displayWidth,
|
|
839
|
+
estimate,
|
|
840
|
+
observe,
|
|
841
|
+
queue,
|
|
842
|
+
onMeasured,
|
|
843
|
+
classNames
|
|
844
|
+
}, page.key))
|
|
845
|
+
})
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
// src/react/editor/PdfEditorStart.tsx
|
|
849
|
+
var hasFiles = (event) => event.dataTransfer.types.includes("Files");
|
|
850
|
+
function PdfEditorStart(props) {
|
|
851
|
+
const { error, onFile, button, className, alertClassName } = props;
|
|
852
|
+
const messages = usePdfMessages();
|
|
853
|
+
const input = useRef(null);
|
|
854
|
+
const [dragging, setDragging] = useState(false);
|
|
855
|
+
const titleId = useId();
|
|
856
|
+
const hintId = useId();
|
|
857
|
+
const choose = (event) => {
|
|
858
|
+
const [file] = event.target.files ?? [];
|
|
859
|
+
event.target.value = "";
|
|
860
|
+
if (file) onFile(file);
|
|
861
|
+
};
|
|
862
|
+
const onDragOver = (event) => {
|
|
863
|
+
if (!hasFiles(event)) return;
|
|
864
|
+
event.preventDefault();
|
|
865
|
+
event.dataTransfer.dropEffect = "copy";
|
|
866
|
+
setDragging(true);
|
|
867
|
+
};
|
|
868
|
+
const onDragLeave = (event) => {
|
|
869
|
+
if (event.currentTarget.contains(event.relatedTarget)) return;
|
|
870
|
+
setDragging(false);
|
|
871
|
+
};
|
|
872
|
+
const onDrop = (event) => {
|
|
873
|
+
if (!hasFiles(event)) return;
|
|
874
|
+
event.preventDefault();
|
|
875
|
+
setDragging(false);
|
|
876
|
+
const [file] = event.dataTransfer.files;
|
|
877
|
+
if (file) onFile(file);
|
|
878
|
+
};
|
|
879
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
880
|
+
className,
|
|
881
|
+
"data-hm-dragging": dragging ? "" : void 0,
|
|
882
|
+
onDragEnter: onDragOver,
|
|
883
|
+
onDragOver,
|
|
884
|
+
onDragLeave,
|
|
885
|
+
onDrop,
|
|
886
|
+
children: [
|
|
887
|
+
/* @__PURE__ */ jsx("p", {
|
|
888
|
+
id: titleId,
|
|
889
|
+
className: "hm-pdf-editor-start-title",
|
|
890
|
+
children: messages.t(error ? "editor.start.retryTitle" : "editor.start.title")
|
|
891
|
+
}),
|
|
892
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
893
|
+
role: "alert",
|
|
894
|
+
className: alertClassName,
|
|
895
|
+
children: messages.error(error)
|
|
896
|
+
}) : null,
|
|
897
|
+
/* @__PURE__ */ jsx("button", {
|
|
898
|
+
ref: button,
|
|
899
|
+
type: "button",
|
|
900
|
+
className: "hm-pdf-editor-button",
|
|
901
|
+
"aria-describedby": hintId,
|
|
902
|
+
onClick: () => input.current?.click(),
|
|
903
|
+
children: messages.t(error ? "editor.start.retry" : "editor.start.choose")
|
|
904
|
+
}),
|
|
905
|
+
/* @__PURE__ */ jsx("p", {
|
|
906
|
+
id: hintId,
|
|
907
|
+
className: "hm-pdf-editor-start-hint",
|
|
908
|
+
children: messages.t("editor.start.hint")
|
|
909
|
+
}),
|
|
910
|
+
/* @__PURE__ */ jsx("input", {
|
|
911
|
+
ref: input,
|
|
912
|
+
type: "file",
|
|
913
|
+
accept: "application/pdf,.pdf",
|
|
914
|
+
tabIndex: -1,
|
|
915
|
+
"aria-hidden": "true",
|
|
916
|
+
hidden: true,
|
|
917
|
+
onChange: choose
|
|
918
|
+
})
|
|
919
|
+
]
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
// src/react/editor/PdfEditor.tsx
|
|
923
|
+
function warningText(messages, warning) {
|
|
924
|
+
const t = messages.t;
|
|
925
|
+
return t(`warnings.${warning.limit}`, { actual: warning.actual });
|
|
926
|
+
}
|
|
927
|
+
var join = (...names) => names.filter(Boolean).join(" ");
|
|
928
|
+
function resultOf(tool, messages, before) {
|
|
929
|
+
switch (tool.id) {
|
|
930
|
+
case "pdf.undo": return messages.t("editor.undone");
|
|
931
|
+
case "pdf.redo": return messages.t("editor.redone");
|
|
932
|
+
case "pdf.rotate-left":
|
|
933
|
+
case "pdf.rotate-right": return messages.t("editor.rotated", { count: targetPages(before).length });
|
|
934
|
+
default: return;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function changeBetween(before, after) {
|
|
938
|
+
const pageCount = after.plan.pages.length;
|
|
939
|
+
if (after.status === "ready" && after.sources[0]?.id !== before.sources[0]?.id) return {
|
|
940
|
+
reason: "open",
|
|
941
|
+
pageCount
|
|
942
|
+
};
|
|
943
|
+
if (before.sources.length > 0 && after.sources.length === 0) return {
|
|
944
|
+
reason: "close",
|
|
945
|
+
pageCount: 0
|
|
946
|
+
};
|
|
947
|
+
if (after.status === "ready" && after.plan !== before.plan) return {
|
|
948
|
+
reason: "edit",
|
|
949
|
+
pageCount
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
function AnnounceBridge({ target }) {
|
|
953
|
+
const announce = useAnnounce();
|
|
954
|
+
useEffect(() => {
|
|
955
|
+
target.current = announce;
|
|
956
|
+
}, [target, announce]);
|
|
957
|
+
return null;
|
|
958
|
+
}
|
|
959
|
+
function PdfEditorBody(props) {
|
|
960
|
+
const { file, onChange, className, classNames = {}, unstyled = false, handle } = props;
|
|
961
|
+
const session = usePdfSession();
|
|
962
|
+
const snapshot = usePdfDocument();
|
|
963
|
+
const messages = usePdfMessages();
|
|
964
|
+
const announceTo = useRef(() => {});
|
|
965
|
+
const announce = useCallback((message, options) => announceTo.current(message, options), []);
|
|
966
|
+
const platform = usePlatform();
|
|
967
|
+
const root = useRef(null);
|
|
968
|
+
const startButton = useRef(null);
|
|
969
|
+
const input = useRef(null);
|
|
970
|
+
const latestOnChange = useRef(onChange);
|
|
971
|
+
latestOnChange.current = onChange;
|
|
972
|
+
const registry = useMemo(() => createToolRegistry(pdfTools, {
|
|
973
|
+
...props.tools ? { tools: props.tools } : {},
|
|
974
|
+
toolbar: props.toolbar ?? DEFAULT_TOOLBAR.map((group) => group.filter((id) => !props.tools || props.tools.includes(id))).filter((group) => group.length > 0)
|
|
975
|
+
}), [props.tools, props.toolbar]);
|
|
976
|
+
const shortcuts = useMemo(() => createShortcutRegistry({
|
|
977
|
+
platform,
|
|
978
|
+
tools: registry.tools
|
|
979
|
+
}), [platform, registry]);
|
|
980
|
+
const context = useMemo(() => ({
|
|
981
|
+
session,
|
|
982
|
+
chooseFile: () => input.current?.click()
|
|
983
|
+
}), [session]);
|
|
984
|
+
const icons = useMemo(() => ({
|
|
985
|
+
...pdfIcons,
|
|
986
|
+
...props.icons
|
|
987
|
+
}), [props.icons]);
|
|
988
|
+
const runTool = (tool) => {
|
|
989
|
+
const before = session.getSnapshot();
|
|
990
|
+
if (!(tool.isEnabled?.({ snapshot: before }) ?? true)) return;
|
|
991
|
+
Promise.resolve(tool.run(context)).then(() => {
|
|
992
|
+
const result = resultOf(tool, messages, before);
|
|
993
|
+
if (result) announce(result);
|
|
994
|
+
});
|
|
995
|
+
};
|
|
996
|
+
const onKeyDown = (event) => {
|
|
997
|
+
const id = shortcuts.match(event.nativeEvent);
|
|
998
|
+
const tool = id ? registry.get(id) : void 0;
|
|
999
|
+
if (!tool) return;
|
|
1000
|
+
event.preventDefault();
|
|
1001
|
+
runTool(tool);
|
|
1002
|
+
};
|
|
1003
|
+
useImperativeHandle(handle, () => ({
|
|
1004
|
+
session,
|
|
1005
|
+
open: (next) => session.open(next),
|
|
1006
|
+
export: (options) => session.export(options),
|
|
1007
|
+
undo: () => session.undo(),
|
|
1008
|
+
redo: () => session.redo(),
|
|
1009
|
+
close: () => session.close()
|
|
1010
|
+
}), [session]);
|
|
1011
|
+
useEffect(() => {
|
|
1012
|
+
if (file === void 0) return;
|
|
1013
|
+
if (file === null) {
|
|
1014
|
+
session.close();
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
const controller = new AbortController();
|
|
1018
|
+
session.open(file, { signal: controller.signal }).catch(() => {});
|
|
1019
|
+
return () => controller.abort();
|
|
1020
|
+
}, [session, file]);
|
|
1021
|
+
useEffect(() => {
|
|
1022
|
+
let before = session.getSnapshot();
|
|
1023
|
+
return session.subscribe(() => {
|
|
1024
|
+
const after = session.getSnapshot();
|
|
1025
|
+
const change = changeBetween(before, after);
|
|
1026
|
+
before = after;
|
|
1027
|
+
if (!change) return;
|
|
1028
|
+
if (change.reason === "open") announce(messages.t("editor.opened", { count: change.pageCount }));
|
|
1029
|
+
else if (change.reason === "close") announce(messages.t("editor.closed"));
|
|
1030
|
+
latestOnChange.current?.(change);
|
|
1031
|
+
});
|
|
1032
|
+
}, [
|
|
1033
|
+
session,
|
|
1034
|
+
messages,
|
|
1035
|
+
announce
|
|
1036
|
+
]);
|
|
1037
|
+
const { status } = snapshot;
|
|
1038
|
+
const previous = useRef(status);
|
|
1039
|
+
useEffect(() => {
|
|
1040
|
+
if (previous.current === status) return;
|
|
1041
|
+
previous.current = status;
|
|
1042
|
+
const active = document.activeElement;
|
|
1043
|
+
if (!(active === null || active === document.body || root.current?.contains(active))) return;
|
|
1044
|
+
if (status === "ready") root.current?.querySelector(".hm-pdf-viewer")?.focus();
|
|
1045
|
+
if (status === "error") startButton.current?.focus();
|
|
1046
|
+
}, [status]);
|
|
1047
|
+
const open = (chosen) => {
|
|
1048
|
+
session.open(chosen).catch(() => {});
|
|
1049
|
+
};
|
|
1050
|
+
const { error, warnings } = snapshot;
|
|
1051
|
+
const showError = error !== void 0 && error.code !== "ABORTED";
|
|
1052
|
+
let content;
|
|
1053
|
+
if (status === "ready") content = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(PdfThumbnails, {
|
|
1054
|
+
className: join("hm-pdf-editor-sidebar", classNames.sidebar),
|
|
1055
|
+
unstyled
|
|
1056
|
+
}), /* @__PURE__ */ jsx(PdfViewer, { unstyled })] });
|
|
1057
|
+
else if (status === "opening") content = /* @__PURE__ */ jsxs("div", {
|
|
1058
|
+
role: "status",
|
|
1059
|
+
className: join("hm-pdf-editor-loading", classNames.status),
|
|
1060
|
+
children: [/* @__PURE__ */ jsx("progress", {
|
|
1061
|
+
className: "hm-pdf-editor-progress",
|
|
1062
|
+
"aria-hidden": "true"
|
|
1063
|
+
}), /* @__PURE__ */ jsx("p", { children: messages.t("editor.opening") })]
|
|
1064
|
+
});
|
|
1065
|
+
else content = /* @__PURE__ */ jsx(PdfEditorStart, {
|
|
1066
|
+
error: showError ? error : void 0,
|
|
1067
|
+
onFile: open,
|
|
1068
|
+
button: startButton,
|
|
1069
|
+
className: join("hm-pdf-editor-start", classNames.start),
|
|
1070
|
+
alertClassName: join("hm-pdf-editor-alert", classNames.alert)
|
|
1071
|
+
});
|
|
1072
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1073
|
+
ref: root,
|
|
1074
|
+
role: "group",
|
|
1075
|
+
"aria-label": messages.t("editor.label"),
|
|
1076
|
+
"aria-busy": status === "opening" || snapshot.busy,
|
|
1077
|
+
className: join("hm-pdf-editor", className, classNames.root),
|
|
1078
|
+
"data-hm-status": status,
|
|
1079
|
+
onKeyDown,
|
|
1080
|
+
...unstyled ? { "data-hm-unstyled": "" } : {},
|
|
1081
|
+
children: [
|
|
1082
|
+
/* @__PURE__ */ jsx("input", {
|
|
1083
|
+
ref: input,
|
|
1084
|
+
type: "file",
|
|
1085
|
+
accept: "application/pdf,.pdf",
|
|
1086
|
+
tabIndex: -1,
|
|
1087
|
+
"aria-hidden": "true",
|
|
1088
|
+
hidden: true,
|
|
1089
|
+
onChange: (event) => {
|
|
1090
|
+
const [chosen] = event.target.files ?? [];
|
|
1091
|
+
event.target.value = "";
|
|
1092
|
+
if (chosen) open(chosen);
|
|
1093
|
+
}
|
|
1094
|
+
}),
|
|
1095
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1096
|
+
className: join("hm-pdf-editor-header", classNames.header),
|
|
1097
|
+
children: [
|
|
1098
|
+
/* @__PURE__ */ jsx(PdfToolbar, {
|
|
1099
|
+
registry,
|
|
1100
|
+
shortcuts,
|
|
1101
|
+
context,
|
|
1102
|
+
icons,
|
|
1103
|
+
onRun: runTool,
|
|
1104
|
+
className: join("hm-pdf-editor-toolbar", classNames.toolbar)
|
|
1105
|
+
}),
|
|
1106
|
+
status === "ready" && showError ? /* @__PURE__ */ jsx("p", {
|
|
1107
|
+
role: "alert",
|
|
1108
|
+
className: join("hm-pdf-editor-alert", classNames.alert),
|
|
1109
|
+
children: messages.error(error)
|
|
1110
|
+
}) : null,
|
|
1111
|
+
status === "ready" && warnings.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
1112
|
+
role: "status",
|
|
1113
|
+
className: join("hm-pdf-editor-warnings", classNames.status),
|
|
1114
|
+
children: /* @__PURE__ */ jsx("ul", { children: warnings.map((warning) => /* @__PURE__ */ jsx("li", { children: warningText(messages, warning) }, warning.limit)) })
|
|
1115
|
+
}) : null
|
|
1116
|
+
]
|
|
1117
|
+
}),
|
|
1118
|
+
/* @__PURE__ */ jsx("div", {
|
|
1119
|
+
className: join("hm-pdf-editor-body", classNames.body),
|
|
1120
|
+
children: content
|
|
1121
|
+
}),
|
|
1122
|
+
/* @__PURE__ */ jsx(AnnouncerProvider, { children: /* @__PURE__ */ jsx(AnnounceBridge, { target: announceTo }) })
|
|
1123
|
+
]
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
var PdfEditor = /* @__PURE__ */ forwardRef(function PdfEditor(props, handle) {
|
|
1127
|
+
const { file, onChange, className, classNames, unstyled, tools, toolbar, icons, messages: overrides, locale = "en", ...source } = props;
|
|
1128
|
+
const session = useProvidedSession(source);
|
|
1129
|
+
const messages = useMemo(() => createMessages(pdfEditorMessages, {
|
|
1130
|
+
locale,
|
|
1131
|
+
...overrides ? { overrides } : {}
|
|
1132
|
+
}), [locale, overrides]);
|
|
1133
|
+
const value = useMemo(() => ({
|
|
1134
|
+
session,
|
|
1135
|
+
messages
|
|
1136
|
+
}), [session, messages]);
|
|
1137
|
+
return /* @__PURE__ */ jsx(PdfContext.Provider, {
|
|
1138
|
+
value,
|
|
1139
|
+
children: /* @__PURE__ */ jsx(UiMessagesProvider, {
|
|
1140
|
+
messages,
|
|
1141
|
+
children: /* @__PURE__ */ jsx(PdfEditorBody, {
|
|
1142
|
+
handle,
|
|
1143
|
+
...file !== void 0 ? { file } : {},
|
|
1144
|
+
...onChange ? { onChange } : {},
|
|
1145
|
+
...className !== void 0 ? { className } : {},
|
|
1146
|
+
...classNames ? { classNames } : {},
|
|
1147
|
+
...unstyled !== void 0 ? { unstyled } : {},
|
|
1148
|
+
...tools ? { tools } : {},
|
|
1149
|
+
...toolbar ? { toolbar } : {},
|
|
1150
|
+
...icons ? { icons } : {}
|
|
1151
|
+
})
|
|
1152
|
+
})
|
|
1153
|
+
});
|
|
1154
|
+
});
|
|
1155
|
+
export { PdfEditor, PdfSessionProvider, PdfThumbnails, PdfToolbar, PdfViewer, pdfEditorMessages, pdfIcons, pdfTools, usePdfDocument, usePdfMessages, usePdfSession };
|
|
1156
|
+
|
|
1157
|
+
//# sourceMappingURL=react.js.map
|