pdfjs_viewer 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +230 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +67 -0
- data/LICENSE +204 -0
- data/README.md +128 -0
- data/Rakefile +6 -0
- data/app/controllers/pdfjs_viewer/assets_controller.rb +27 -0
- data/app/controllers/pdfjs_viewer/viewer_controller.rb +11 -0
- data/app/helpers/pdfjs_viewer/application_helper.rb +20 -0
- data/app/views/pdfjs_viewer/viewer/show.html.erb +775 -0
- data/bin/build_pdfjs +24 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/routes.rb +11 -0
- data/lib/generators/pdfjs_viewer/install_generator.rb +20 -0
- data/lib/generators/pdfjs_viewer/templates/README +20 -0
- data/lib/generators/pdfjs_viewer/templates/pdfjs_viewer.rb +30 -0
- data/lib/pdfjs_viewer/configuration.rb +21 -0
- data/lib/pdfjs_viewer/engine.rb +19 -0
- data/lib/pdfjs_viewer/version.rb +7 -0
- data/lib/pdfjs_viewer.rb +22 -0
- data/pdfjs_viewer.gemspec +54 -0
- data/public/build/pdf.mjs +23371 -0
- data/public/build/pdf.mjs.map +1 -0
- data/public/build/pdf.sandbox.mjs +218 -0
- data/public/build/pdf.sandbox.mjs.map +1 -0
- data/public/build/pdf.worker.mjs +58148 -0
- data/public/build/pdf.worker.mjs.map +1 -0
- data/public/web/cmaps/78-EUC-H.bcmap +0 -0
- data/public/web/cmaps/78-EUC-V.bcmap +0 -0
- data/public/web/cmaps/78-H.bcmap +0 -0
- data/public/web/cmaps/78-RKSJ-H.bcmap +0 -0
- data/public/web/cmaps/78-RKSJ-V.bcmap +0 -0
- data/public/web/cmaps/78-V.bcmap +0 -0
- data/public/web/cmaps/78ms-RKSJ-H.bcmap +0 -0
- data/public/web/cmaps/78ms-RKSJ-V.bcmap +0 -0
- data/public/web/cmaps/83pv-RKSJ-H.bcmap +0 -0
- data/public/web/cmaps/90ms-RKSJ-H.bcmap +0 -0
- data/public/web/cmaps/90ms-RKSJ-V.bcmap +0 -0
- data/public/web/cmaps/90msp-RKSJ-H.bcmap +0 -0
- data/public/web/cmaps/90msp-RKSJ-V.bcmap +0 -0
- data/public/web/cmaps/90pv-RKSJ-H.bcmap +0 -0
- data/public/web/cmaps/90pv-RKSJ-V.bcmap +0 -0
- data/public/web/cmaps/Add-H.bcmap +0 -0
- data/public/web/cmaps/Add-RKSJ-H.bcmap +0 -0
- data/public/web/cmaps/Add-RKSJ-V.bcmap +0 -0
- data/public/web/cmaps/Add-V.bcmap +0 -0
- data/public/web/cmaps/Adobe-CNS1-0.bcmap +0 -0
- data/public/web/cmaps/Adobe-CNS1-1.bcmap +0 -0
- data/public/web/cmaps/Adobe-CNS1-2.bcmap +0 -0
- data/public/web/cmaps/Adobe-CNS1-3.bcmap +0 -0
- data/public/web/cmaps/Adobe-CNS1-4.bcmap +0 -0
- data/public/web/cmaps/Adobe-CNS1-5.bcmap +0 -0
- data/public/web/cmaps/Adobe-CNS1-6.bcmap +0 -0
- data/public/web/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- data/public/web/cmaps/Adobe-GB1-0.bcmap +0 -0
- data/public/web/cmaps/Adobe-GB1-1.bcmap +0 -0
- data/public/web/cmaps/Adobe-GB1-2.bcmap +0 -0
- data/public/web/cmaps/Adobe-GB1-3.bcmap +0 -0
- data/public/web/cmaps/Adobe-GB1-4.bcmap +0 -0
- data/public/web/cmaps/Adobe-GB1-5.bcmap +0 -0
- data/public/web/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- data/public/web/cmaps/Adobe-Japan1-0.bcmap +0 -0
- data/public/web/cmaps/Adobe-Japan1-1.bcmap +0 -0
- data/public/web/cmaps/Adobe-Japan1-2.bcmap +0 -0
- data/public/web/cmaps/Adobe-Japan1-3.bcmap +0 -0
- data/public/web/cmaps/Adobe-Japan1-4.bcmap +0 -0
- data/public/web/cmaps/Adobe-Japan1-5.bcmap +0 -0
- data/public/web/cmaps/Adobe-Japan1-6.bcmap +0 -0
- data/public/web/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- data/public/web/cmaps/Adobe-Korea1-0.bcmap +0 -0
- data/public/web/cmaps/Adobe-Korea1-1.bcmap +0 -0
- data/public/web/cmaps/Adobe-Korea1-2.bcmap +0 -0
- data/public/web/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- data/public/web/cmaps/B5-H.bcmap +0 -0
- data/public/web/cmaps/B5-V.bcmap +0 -0
- data/public/web/cmaps/B5pc-H.bcmap +0 -0
- data/public/web/cmaps/B5pc-V.bcmap +0 -0
- data/public/web/cmaps/CNS-EUC-H.bcmap +0 -0
- data/public/web/cmaps/CNS-EUC-V.bcmap +0 -0
- data/public/web/cmaps/CNS1-H.bcmap +0 -0
- data/public/web/cmaps/CNS1-V.bcmap +0 -0
- data/public/web/cmaps/CNS2-H.bcmap +0 -0
- data/public/web/cmaps/CNS2-V.bcmap +3 -0
- data/public/web/cmaps/ETHK-B5-H.bcmap +0 -0
- data/public/web/cmaps/ETHK-B5-V.bcmap +0 -0
- data/public/web/cmaps/ETen-B5-H.bcmap +0 -0
- data/public/web/cmaps/ETen-B5-V.bcmap +0 -0
- data/public/web/cmaps/ETenms-B5-H.bcmap +3 -0
- data/public/web/cmaps/ETenms-B5-V.bcmap +0 -0
- data/public/web/cmaps/EUC-H.bcmap +0 -0
- data/public/web/cmaps/EUC-V.bcmap +0 -0
- data/public/web/cmaps/Ext-H.bcmap +0 -0
- data/public/web/cmaps/Ext-RKSJ-H.bcmap +0 -0
- data/public/web/cmaps/Ext-RKSJ-V.bcmap +0 -0
- data/public/web/cmaps/Ext-V.bcmap +0 -0
- data/public/web/cmaps/GB-EUC-H.bcmap +0 -0
- data/public/web/cmaps/GB-EUC-V.bcmap +0 -0
- data/public/web/cmaps/GB-H.bcmap +4 -0
- data/public/web/cmaps/GB-V.bcmap +0 -0
- data/public/web/cmaps/GBK-EUC-H.bcmap +0 -0
- data/public/web/cmaps/GBK-EUC-V.bcmap +0 -0
- data/public/web/cmaps/GBK2K-H.bcmap +0 -0
- data/public/web/cmaps/GBK2K-V.bcmap +0 -0
- data/public/web/cmaps/GBKp-EUC-H.bcmap +0 -0
- data/public/web/cmaps/GBKp-EUC-V.bcmap +0 -0
- data/public/web/cmaps/GBT-EUC-H.bcmap +0 -0
- data/public/web/cmaps/GBT-EUC-V.bcmap +0 -0
- data/public/web/cmaps/GBT-H.bcmap +0 -0
- data/public/web/cmaps/GBT-V.bcmap +0 -0
- data/public/web/cmaps/GBTpc-EUC-H.bcmap +0 -0
- data/public/web/cmaps/GBTpc-EUC-V.bcmap +0 -0
- data/public/web/cmaps/GBpc-EUC-H.bcmap +0 -0
- data/public/web/cmaps/GBpc-EUC-V.bcmap +0 -0
- data/public/web/cmaps/H.bcmap +0 -0
- data/public/web/cmaps/HKdla-B5-H.bcmap +0 -0
- data/public/web/cmaps/HKdla-B5-V.bcmap +0 -0
- data/public/web/cmaps/HKdlb-B5-H.bcmap +0 -0
- data/public/web/cmaps/HKdlb-B5-V.bcmap +0 -0
- data/public/web/cmaps/HKgccs-B5-H.bcmap +0 -0
- data/public/web/cmaps/HKgccs-B5-V.bcmap +0 -0
- data/public/web/cmaps/HKm314-B5-H.bcmap +0 -0
- data/public/web/cmaps/HKm314-B5-V.bcmap +0 -0
- data/public/web/cmaps/HKm471-B5-H.bcmap +0 -0
- data/public/web/cmaps/HKm471-B5-V.bcmap +0 -0
- data/public/web/cmaps/HKscs-B5-H.bcmap +0 -0
- data/public/web/cmaps/HKscs-B5-V.bcmap +0 -0
- data/public/web/cmaps/Hankaku.bcmap +0 -0
- data/public/web/cmaps/Hiragana.bcmap +0 -0
- data/public/web/cmaps/KSC-EUC-H.bcmap +0 -0
- data/public/web/cmaps/KSC-EUC-V.bcmap +0 -0
- data/public/web/cmaps/KSC-H.bcmap +0 -0
- data/public/web/cmaps/KSC-Johab-H.bcmap +0 -0
- data/public/web/cmaps/KSC-Johab-V.bcmap +0 -0
- data/public/web/cmaps/KSC-V.bcmap +0 -0
- data/public/web/cmaps/KSCms-UHC-H.bcmap +0 -0
- data/public/web/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- data/public/web/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- data/public/web/cmaps/KSCms-UHC-V.bcmap +0 -0
- data/public/web/cmaps/KSCpc-EUC-H.bcmap +0 -0
- data/public/web/cmaps/KSCpc-EUC-V.bcmap +0 -0
- data/public/web/cmaps/Katakana.bcmap +0 -0
- data/public/web/cmaps/LICENSE +36 -0
- data/public/web/cmaps/NWP-H.bcmap +0 -0
- data/public/web/cmaps/NWP-V.bcmap +0 -0
- data/public/web/cmaps/RKSJ-H.bcmap +0 -0
- data/public/web/cmaps/RKSJ-V.bcmap +0 -0
- data/public/web/cmaps/Roman.bcmap +0 -0
- data/public/web/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- data/public/web/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- data/public/web/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- data/public/web/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- data/public/web/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- data/public/web/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- data/public/web/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- data/public/web/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- data/public/web/cmaps/UniGB-UCS2-H.bcmap +0 -0
- data/public/web/cmaps/UniGB-UCS2-V.bcmap +0 -0
- data/public/web/cmaps/UniGB-UTF16-H.bcmap +0 -0
- data/public/web/cmaps/UniGB-UTF16-V.bcmap +0 -0
- data/public/web/cmaps/UniGB-UTF32-H.bcmap +0 -0
- data/public/web/cmaps/UniGB-UTF32-V.bcmap +0 -0
- data/public/web/cmaps/UniGB-UTF8-H.bcmap +0 -0
- data/public/web/cmaps/UniGB-UTF8-V.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- data/public/web/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- data/public/web/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- data/public/web/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- data/public/web/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- data/public/web/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- data/public/web/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- data/public/web/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- data/public/web/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- data/public/web/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- data/public/web/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- data/public/web/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- data/public/web/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- data/public/web/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- data/public/web/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- data/public/web/cmaps/UniKS-UCS2-H.bcmap +0 -0
- data/public/web/cmaps/UniKS-UCS2-V.bcmap +0 -0
- data/public/web/cmaps/UniKS-UTF16-H.bcmap +0 -0
- data/public/web/cmaps/UniKS-UTF16-V.bcmap +0 -0
- data/public/web/cmaps/UniKS-UTF32-H.bcmap +0 -0
- data/public/web/cmaps/UniKS-UTF32-V.bcmap +0 -0
- data/public/web/cmaps/UniKS-UTF8-H.bcmap +0 -0
- data/public/web/cmaps/UniKS-UTF8-V.bcmap +0 -0
- data/public/web/cmaps/V.bcmap +0 -0
- data/public/web/cmaps/WP-Symbol.bcmap +0 -0
- data/public/web/compressed.tracemonkey-pldi-09.pdf +0 -0
- data/public/web/debugger.css +114 -0
- data/public/web/debugger.mjs +627 -0
- data/public/web/iccs/CGATS001Compat-v2-micro.icc +0 -0
- data/public/web/iccs/LICENSE +116 -0
- data/public/web/images/altText_add.svg +3 -0
- data/public/web/images/altText_disclaimer.svg +3 -0
- data/public/web/images/altText_done.svg +3 -0
- data/public/web/images/altText_spinner.svg +30 -0
- data/public/web/images/altText_warning.svg +3 -0
- data/public/web/images/annotation-check.svg +11 -0
- data/public/web/images/annotation-comment.svg +16 -0
- data/public/web/images/annotation-help.svg +26 -0
- data/public/web/images/annotation-insert.svg +10 -0
- data/public/web/images/annotation-key.svg +11 -0
- data/public/web/images/annotation-newparagraph.svg +11 -0
- data/public/web/images/annotation-noicon.svg +7 -0
- data/public/web/images/annotation-note.svg +42 -0
- data/public/web/images/annotation-paperclip.svg +6 -0
- data/public/web/images/annotation-paragraph.svg +16 -0
- data/public/web/images/annotation-pushpin.svg +7 -0
- data/public/web/images/comment-actionsButton.svg +3 -0
- data/public/web/images/comment-closeButton.svg +3 -0
- data/public/web/images/comment-editButton.svg +3 -0
- data/public/web/images/cursor-editorFreeHighlight.svg +6 -0
- data/public/web/images/cursor-editorFreeText.svg +3 -0
- data/public/web/images/cursor-editorInk.svg +4 -0
- data/public/web/images/cursor-editorTextHighlight.svg +8 -0
- data/public/web/images/editor-toolbar-delete.svg +5 -0
- data/public/web/images/editor-toolbar-edit.svg +3 -0
- data/public/web/images/findbarButton-next.svg +3 -0
- data/public/web/images/findbarButton-previous.svg +3 -0
- data/public/web/images/gv-toolbarButton-download.svg +3 -0
- data/public/web/images/loading-icon.gif +0 -0
- data/public/web/images/loading.svg +1 -0
- data/public/web/images/messageBar_closingButton.svg +3 -0
- data/public/web/images/messageBar_info.svg +3 -0
- data/public/web/images/messageBar_warning.svg +3 -0
- data/public/web/images/secondaryToolbarButton-documentProperties.svg +3 -0
- data/public/web/images/secondaryToolbarButton-firstPage.svg +3 -0
- data/public/web/images/secondaryToolbarButton-handTool.svg +3 -0
- data/public/web/images/secondaryToolbarButton-lastPage.svg +3 -0
- data/public/web/images/secondaryToolbarButton-rotateCcw.svg +3 -0
- data/public/web/images/secondaryToolbarButton-rotateCw.svg +3 -0
- data/public/web/images/secondaryToolbarButton-scrollHorizontal.svg +3 -0
- data/public/web/images/secondaryToolbarButton-scrollPage.svg +3 -0
- data/public/web/images/secondaryToolbarButton-scrollVertical.svg +3 -0
- data/public/web/images/secondaryToolbarButton-scrollWrapped.svg +3 -0
- data/public/web/images/secondaryToolbarButton-selectTool.svg +3 -0
- data/public/web/images/secondaryToolbarButton-spreadEven.svg +3 -0
- data/public/web/images/secondaryToolbarButton-spreadNone.svg +3 -0
- data/public/web/images/secondaryToolbarButton-spreadOdd.svg +3 -0
- data/public/web/images/toolbarButton-bookmark.svg +3 -0
- data/public/web/images/toolbarButton-currentOutlineItem.svg +3 -0
- data/public/web/images/toolbarButton-download.svg +4 -0
- data/public/web/images/toolbarButton-editorFreeText.svg +5 -0
- data/public/web/images/toolbarButton-editorHighlight.svg +6 -0
- data/public/web/images/toolbarButton-editorInk.svg +4 -0
- data/public/web/images/toolbarButton-editorSignature.svg +6 -0
- data/public/web/images/toolbarButton-editorStamp.svg +8 -0
- data/public/web/images/toolbarButton-menuArrow.svg +3 -0
- data/public/web/images/toolbarButton-openFile.svg +3 -0
- data/public/web/images/toolbarButton-pageDown.svg +3 -0
- data/public/web/images/toolbarButton-pageUp.svg +3 -0
- data/public/web/images/toolbarButton-presentationMode.svg +3 -0
- data/public/web/images/toolbarButton-print.svg +3 -0
- data/public/web/images/toolbarButton-search.svg +3 -0
- data/public/web/images/toolbarButton-secondaryToolbarToggle.svg +3 -0
- data/public/web/images/toolbarButton-sidebarToggle.svg +3 -0
- data/public/web/images/toolbarButton-viewAttachments.svg +3 -0
- data/public/web/images/toolbarButton-viewLayers.svg +3 -0
- data/public/web/images/toolbarButton-viewOutline.svg +3 -0
- data/public/web/images/toolbarButton-viewThumbnail.svg +3 -0
- data/public/web/images/toolbarButton-zoomIn.svg +3 -0
- data/public/web/images/toolbarButton-zoomOut.svg +3 -0
- data/public/web/images/treeitem-collapsed.svg +1 -0
- data/public/web/images/treeitem-expanded.svg +1 -0
- data/public/web/locale/ach/viewer.ftl +275 -0
- data/public/web/locale/af/viewer.ftl +262 -0
- data/public/web/locale/an/viewer.ftl +307 -0
- data/public/web/locale/ar/viewer.ftl +627 -0
- data/public/web/locale/ast/viewer.ftl +251 -0
- data/public/web/locale/az/viewer.ftl +307 -0
- data/public/web/locale/be/viewer.ftl +618 -0
- data/public/web/locale/bg/viewer.ftl +451 -0
- data/public/web/locale/bn/viewer.ftl +297 -0
- data/public/web/locale/bo/viewer.ftl +297 -0
- data/public/web/locale/br/viewer.ftl +382 -0
- data/public/web/locale/brx/viewer.ftl +268 -0
- data/public/web/locale/bs/viewer.ftl +618 -0
- data/public/web/locale/ca/viewer.ftl +343 -0
- data/public/web/locale/cak/viewer.ftl +341 -0
- data/public/web/locale/ckb/viewer.ftl +292 -0
- data/public/web/locale/cs/viewer.ftl +621 -0
- data/public/web/locale/cy/viewer.ftl +627 -0
- data/public/web/locale/da/viewer.ftl +615 -0
- data/public/web/locale/de/viewer.ftl +615 -0
- data/public/web/locale/dsb/viewer.ftl +621 -0
- data/public/web/locale/el/viewer.ftl +615 -0
- data/public/web/locale/en-CA/viewer.ftl +615 -0
- data/public/web/locale/en-GB/viewer.ftl +615 -0
- data/public/web/locale/en-US/viewer.ftl +667 -0
- data/public/web/locale/eo/viewer.ftl +615 -0
- data/public/web/locale/es-AR/viewer.ftl +615 -0
- data/public/web/locale/es-CL/viewer.ftl +615 -0
- data/public/web/locale/es-ES/viewer.ftl +615 -0
- data/public/web/locale/es-MX/viewer.ftl +580 -0
- data/public/web/locale/et/viewer.ftl +319 -0
- data/public/web/locale/eu/viewer.ftl +619 -0
- data/public/web/locale/fa/viewer.ftl +378 -0
- data/public/web/locale/ff/viewer.ftl +297 -0
- data/public/web/locale/fi/viewer.ftl +615 -0
- data/public/web/locale/fr/viewer.ftl +611 -0
- data/public/web/locale/fur/viewer.ftl +615 -0
- data/public/web/locale/fy-NL/viewer.ftl +615 -0
- data/public/web/locale/ga-IE/viewer.ftl +263 -0
- data/public/web/locale/gd/viewer.ftl +343 -0
- data/public/web/locale/gl/viewer.ftl +615 -0
- data/public/web/locale/gn/viewer.ftl +614 -0
- data/public/web/locale/gu-IN/viewer.ftl +297 -0
- data/public/web/locale/he/viewer.ftl +615 -0
- data/public/web/locale/hi-IN/viewer.ftl +297 -0
- data/public/web/locale/hr/viewer.ftl +618 -0
- data/public/web/locale/hsb/viewer.ftl +621 -0
- data/public/web/locale/hu/viewer.ftl +615 -0
- data/public/web/locale/hy-AM/viewer.ftl +314 -0
- data/public/web/locale/hye/viewer.ftl +318 -0
- data/public/web/locale/ia/viewer.ftl +615 -0
- data/public/web/locale/id/viewer.ftl +603 -0
- data/public/web/locale/is/viewer.ftl +600 -0
- data/public/web/locale/it/viewer.ftl +623 -0
- data/public/web/locale/ja/viewer.ftl +603 -0
- data/public/web/locale/ka/viewer.ftl +615 -0
- data/public/web/locale/kab/viewer.ftl +595 -0
- data/public/web/locale/kk/viewer.ftl +603 -0
- data/public/web/locale/km/viewer.ftl +273 -0
- data/public/web/locale/kn/viewer.ftl +263 -0
- data/public/web/locale/ko/viewer.ftl +603 -0
- data/public/web/locale/lij/viewer.ftl +297 -0
- data/public/web/locale/lo/viewer.ftl +343 -0
- data/public/web/locale/locale.json +1 -0
- data/public/web/locale/lt/viewer.ftl +318 -0
- data/public/web/locale/ltg/viewer.ftl +296 -0
- data/public/web/locale/lv/viewer.ftl +297 -0
- data/public/web/locale/meh/viewer.ftl +137 -0
- data/public/web/locale/mk/viewer.ftl +265 -0
- data/public/web/locale/ml/viewer.ftl +524 -0
- data/public/web/locale/mr/viewer.ftl +289 -0
- data/public/web/locale/ms/viewer.ftl +297 -0
- data/public/web/locale/my/viewer.ftl +256 -0
- data/public/web/locale/nb-NO/viewer.ftl +615 -0
- data/public/web/locale/ne-NP/viewer.ftl +284 -0
- data/public/web/locale/nl/viewer.ftl +615 -0
- data/public/web/locale/nn-NO/viewer.ftl +609 -0
- data/public/web/locale/oc/viewer.ftl +436 -0
- data/public/web/locale/pa-IN/viewer.ftl +615 -0
- data/public/web/locale/pl/viewer.ftl +618 -0
- data/public/web/locale/pt-BR/viewer.ftl +615 -0
- data/public/web/locale/pt-PT/viewer.ftl +615 -0
- data/public/web/locale/rm/viewer.ftl +615 -0
- data/public/web/locale/ro/viewer.ftl +302 -0
- data/public/web/locale/ru/viewer.ftl +618 -0
- data/public/web/locale/sat/viewer.ftl +355 -0
- data/public/web/locale/sc/viewer.ftl +394 -0
- data/public/web/locale/scn/viewer.ftl +124 -0
- data/public/web/locale/sco/viewer.ftl +314 -0
- data/public/web/locale/si/viewer.ftl +301 -0
- data/public/web/locale/sk/viewer.ftl +621 -0
- data/public/web/locale/skr/viewer.ftl +524 -0
- data/public/web/locale/sl/viewer.ftl +621 -0
- data/public/web/locale/son/viewer.ftl +256 -0
- data/public/web/locale/sq/viewer.ftl +606 -0
- data/public/web/locale/sr/viewer.ftl +451 -0
- data/public/web/locale/sv-SE/viewer.ftl +615 -0
- data/public/web/locale/szl/viewer.ftl +307 -0
- data/public/web/locale/ta/viewer.ftl +273 -0
- data/public/web/locale/te/viewer.ftl +289 -0
- data/public/web/locale/tg/viewer.ftl +615 -0
- data/public/web/locale/th/viewer.ftl +603 -0
- data/public/web/locale/tl/viewer.ftl +307 -0
- data/public/web/locale/tr/viewer.ftl +615 -0
- data/public/web/locale/trs/viewer.ftl +247 -0
- data/public/web/locale/uk/viewer.ftl +618 -0
- data/public/web/locale/ur/viewer.ftl +298 -0
- data/public/web/locale/uz/viewer.ftl +237 -0
- data/public/web/locale/vi/viewer.ftl +603 -0
- data/public/web/locale/wo/viewer.ftl +177 -0
- data/public/web/locale/xh/viewer.ftl +262 -0
- data/public/web/locale/zh-CN/viewer.ftl +603 -0
- data/public/web/locale/zh-TW/viewer.ftl +603 -0
- data/public/web/standard_fonts/FoxitDingbats.pfb +0 -0
- data/public/web/standard_fonts/FoxitFixed.pfb +0 -0
- data/public/web/standard_fonts/FoxitFixedBold.pfb +0 -0
- data/public/web/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- data/public/web/standard_fonts/FoxitFixedItalic.pfb +0 -0
- data/public/web/standard_fonts/FoxitSerif.pfb +0 -0
- data/public/web/standard_fonts/FoxitSerifBold.pfb +0 -0
- data/public/web/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- data/public/web/standard_fonts/FoxitSerifItalic.pfb +0 -0
- data/public/web/standard_fonts/FoxitSymbol.pfb +0 -0
- data/public/web/standard_fonts/LICENSE_FOXIT +27 -0
- data/public/web/standard_fonts/LICENSE_LIBERATION +102 -0
- data/public/web/standard_fonts/LiberationSans-Bold.ttf +0 -0
- data/public/web/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- data/public/web/standard_fonts/LiberationSans-Italic.ttf +0 -0
- data/public/web/standard_fonts/LiberationSans-Regular.ttf +0 -0
- data/public/web/viewer.css +6766 -0
- data/public/web/viewer.html +768 -0
- data/public/web/viewer.mjs +17445 -0
- data/public/web/viewer.mjs.map +1 -0
- data/public/web/wasm/LICENSE_OPENJPEG +39 -0
- data/public/web/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- data/public/web/wasm/LICENSE_PDFJS_QCMS +22 -0
- data/public/web/wasm/LICENSE_QCMS +21 -0
- data/public/web/wasm/openjpeg.wasm +0 -0
- data/public/web/wasm/openjpeg_nowasm_fallback.js +29 -0
- data/public/web/wasm/qcms_bg.wasm +0 -0
- metadata +526 -0
@@ -0,0 +1,627 @@
|
|
1
|
+
/* Copyright 2012 Mozilla Foundation
|
2
|
+
*
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
* you may not use this file except in compliance with the License.
|
5
|
+
* You may obtain a copy of the License at
|
6
|
+
*
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
*
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
* See the License for the specific language governing permissions and
|
13
|
+
* limitations under the License.
|
14
|
+
*/
|
15
|
+
|
16
|
+
const { OPS } = globalThis.pdfjsLib || (await import("pdfjs-lib"));
|
17
|
+
|
18
|
+
const opMap = Object.create(null);
|
19
|
+
for (const key in OPS) {
|
20
|
+
opMap[OPS[key]] = key;
|
21
|
+
}
|
22
|
+
|
23
|
+
const FontInspector = (function FontInspectorClosure() {
|
24
|
+
let fonts;
|
25
|
+
let active = false;
|
26
|
+
const fontAttribute = "data-font-name";
|
27
|
+
function removeSelection() {
|
28
|
+
const divs = document.querySelectorAll(`span[${fontAttribute}]`);
|
29
|
+
for (const div of divs) {
|
30
|
+
div.className = "";
|
31
|
+
}
|
32
|
+
}
|
33
|
+
function resetSelection() {
|
34
|
+
const divs = document.querySelectorAll(`span[${fontAttribute}]`);
|
35
|
+
for (const div of divs) {
|
36
|
+
div.className = "debuggerHideText";
|
37
|
+
}
|
38
|
+
}
|
39
|
+
function selectFont(fontName, show) {
|
40
|
+
const divs = document.querySelectorAll(
|
41
|
+
`span[${fontAttribute}=${fontName}]`
|
42
|
+
);
|
43
|
+
for (const div of divs) {
|
44
|
+
div.className = show ? "debuggerShowText" : "debuggerHideText";
|
45
|
+
}
|
46
|
+
}
|
47
|
+
function textLayerClick(e) {
|
48
|
+
if (
|
49
|
+
!e.target.dataset.fontName ||
|
50
|
+
e.target.tagName.toUpperCase() !== "SPAN"
|
51
|
+
) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
const fontName = e.target.dataset.fontName;
|
55
|
+
const selects = document.getElementsByTagName("input");
|
56
|
+
for (const select of selects) {
|
57
|
+
if (select.dataset.fontName !== fontName) {
|
58
|
+
continue;
|
59
|
+
}
|
60
|
+
select.checked = !select.checked;
|
61
|
+
selectFont(fontName, select.checked);
|
62
|
+
select.scrollIntoView();
|
63
|
+
}
|
64
|
+
}
|
65
|
+
return {
|
66
|
+
// Properties/functions needed by PDFBug.
|
67
|
+
id: "FontInspector",
|
68
|
+
name: "Font Inspector",
|
69
|
+
panel: null,
|
70
|
+
manager: null,
|
71
|
+
init() {
|
72
|
+
const panel = this.panel;
|
73
|
+
const tmp = document.createElement("button");
|
74
|
+
tmp.addEventListener("click", resetSelection);
|
75
|
+
tmp.textContent = "Refresh";
|
76
|
+
panel.append(tmp);
|
77
|
+
|
78
|
+
fonts = document.createElement("div");
|
79
|
+
panel.append(fonts);
|
80
|
+
},
|
81
|
+
cleanup() {
|
82
|
+
fonts.textContent = "";
|
83
|
+
},
|
84
|
+
enabled: false,
|
85
|
+
get active() {
|
86
|
+
return active;
|
87
|
+
},
|
88
|
+
set active(value) {
|
89
|
+
active = value;
|
90
|
+
if (active) {
|
91
|
+
document.body.addEventListener("click", textLayerClick, true);
|
92
|
+
resetSelection();
|
93
|
+
} else {
|
94
|
+
document.body.removeEventListener("click", textLayerClick, true);
|
95
|
+
removeSelection();
|
96
|
+
}
|
97
|
+
},
|
98
|
+
// FontInspector specific functions.
|
99
|
+
fontAdded(fontObj, url) {
|
100
|
+
function properties(obj, list) {
|
101
|
+
const moreInfo = document.createElement("table");
|
102
|
+
for (const entry of list) {
|
103
|
+
const tr = document.createElement("tr");
|
104
|
+
const td1 = document.createElement("td");
|
105
|
+
td1.textContent = entry;
|
106
|
+
tr.append(td1);
|
107
|
+
const td2 = document.createElement("td");
|
108
|
+
td2.textContent = obj[entry].toString();
|
109
|
+
tr.append(td2);
|
110
|
+
moreInfo.append(tr);
|
111
|
+
}
|
112
|
+
return moreInfo;
|
113
|
+
}
|
114
|
+
|
115
|
+
const moreInfo = fontObj.css
|
116
|
+
? properties(fontObj, ["baseFontName"])
|
117
|
+
: properties(fontObj, ["name", "type"]);
|
118
|
+
|
119
|
+
const fontName = fontObj.loadedName;
|
120
|
+
const font = document.createElement("div");
|
121
|
+
const name = document.createElement("span");
|
122
|
+
name.textContent = fontName;
|
123
|
+
let download;
|
124
|
+
if (!fontObj.css) {
|
125
|
+
download = document.createElement("a");
|
126
|
+
if (url) {
|
127
|
+
url = /url\(['"]?([^)"']+)/.exec(url);
|
128
|
+
download.href = url[1];
|
129
|
+
} else if (fontObj.data) {
|
130
|
+
download.href = URL.createObjectURL(
|
131
|
+
new Blob([fontObj.data], { type: fontObj.mimetype })
|
132
|
+
);
|
133
|
+
}
|
134
|
+
download.textContent = "Download";
|
135
|
+
}
|
136
|
+
|
137
|
+
const logIt = document.createElement("a");
|
138
|
+
logIt.href = "";
|
139
|
+
logIt.textContent = "Log";
|
140
|
+
logIt.addEventListener("click", function (event) {
|
141
|
+
event.preventDefault();
|
142
|
+
console.log(fontObj);
|
143
|
+
});
|
144
|
+
const select = document.createElement("input");
|
145
|
+
select.setAttribute("type", "checkbox");
|
146
|
+
select.dataset.fontName = fontName;
|
147
|
+
select.addEventListener("click", function () {
|
148
|
+
selectFont(fontName, select.checked);
|
149
|
+
});
|
150
|
+
if (download) {
|
151
|
+
font.append(select, name, " ", download, " ", logIt, moreInfo);
|
152
|
+
} else {
|
153
|
+
font.append(select, name, " ", logIt, moreInfo);
|
154
|
+
}
|
155
|
+
fonts.append(font);
|
156
|
+
// Somewhat of a hack, should probably add a hook for when the text layer
|
157
|
+
// is done rendering.
|
158
|
+
setTimeout(() => {
|
159
|
+
if (this.active) {
|
160
|
+
resetSelection();
|
161
|
+
}
|
162
|
+
}, 2000);
|
163
|
+
},
|
164
|
+
};
|
165
|
+
})();
|
166
|
+
|
167
|
+
// Manages all the page steppers.
|
168
|
+
const StepperManager = (function StepperManagerClosure() {
|
169
|
+
let steppers = [];
|
170
|
+
let stepperDiv = null;
|
171
|
+
let stepperControls = null;
|
172
|
+
let stepperChooser = null;
|
173
|
+
let breakPoints = Object.create(null);
|
174
|
+
return {
|
175
|
+
// Properties/functions needed by PDFBug.
|
176
|
+
id: "Stepper",
|
177
|
+
name: "Stepper",
|
178
|
+
panel: null,
|
179
|
+
manager: null,
|
180
|
+
init() {
|
181
|
+
const self = this;
|
182
|
+
stepperControls = document.createElement("div");
|
183
|
+
stepperChooser = document.createElement("select");
|
184
|
+
stepperChooser.addEventListener("change", function (event) {
|
185
|
+
self.selectStepper(this.value);
|
186
|
+
});
|
187
|
+
stepperControls.append(stepperChooser);
|
188
|
+
stepperDiv = document.createElement("div");
|
189
|
+
this.panel.append(stepperControls, stepperDiv);
|
190
|
+
if (sessionStorage.getItem("pdfjsBreakPoints")) {
|
191
|
+
breakPoints = JSON.parse(sessionStorage.getItem("pdfjsBreakPoints"));
|
192
|
+
}
|
193
|
+
},
|
194
|
+
cleanup() {
|
195
|
+
stepperChooser.textContent = "";
|
196
|
+
stepperDiv.textContent = "";
|
197
|
+
steppers = [];
|
198
|
+
},
|
199
|
+
enabled: false,
|
200
|
+
active: false,
|
201
|
+
// Stepper specific functions.
|
202
|
+
create(pageIndex) {
|
203
|
+
const debug = document.createElement("div");
|
204
|
+
debug.id = "stepper" + pageIndex;
|
205
|
+
debug.hidden = true;
|
206
|
+
debug.className = "stepper";
|
207
|
+
stepperDiv.append(debug);
|
208
|
+
const b = document.createElement("option");
|
209
|
+
b.textContent = "Page " + (pageIndex + 1);
|
210
|
+
b.value = pageIndex;
|
211
|
+
stepperChooser.append(b);
|
212
|
+
const initBreakPoints = breakPoints[pageIndex] || [];
|
213
|
+
const stepper = new Stepper(debug, pageIndex, initBreakPoints);
|
214
|
+
steppers.push(stepper);
|
215
|
+
if (steppers.length === 1) {
|
216
|
+
this.selectStepper(pageIndex, false);
|
217
|
+
}
|
218
|
+
return stepper;
|
219
|
+
},
|
220
|
+
selectStepper(pageIndex, selectPanel) {
|
221
|
+
pageIndex |= 0;
|
222
|
+
if (selectPanel) {
|
223
|
+
this.manager.selectPanel(this);
|
224
|
+
}
|
225
|
+
for (const stepper of steppers) {
|
226
|
+
stepper.panel.hidden = stepper.pageIndex !== pageIndex;
|
227
|
+
}
|
228
|
+
for (const option of stepperChooser.options) {
|
229
|
+
option.selected = (option.value | 0) === pageIndex;
|
230
|
+
}
|
231
|
+
},
|
232
|
+
saveBreakPoints(pageIndex, bps) {
|
233
|
+
breakPoints[pageIndex] = bps;
|
234
|
+
sessionStorage.setItem("pdfjsBreakPoints", JSON.stringify(breakPoints));
|
235
|
+
},
|
236
|
+
};
|
237
|
+
})();
|
238
|
+
|
239
|
+
// The stepper for each page's operatorList.
|
240
|
+
class Stepper {
|
241
|
+
// Shorter way to create element and optionally set textContent.
|
242
|
+
#c(tag, textContent) {
|
243
|
+
const d = document.createElement(tag);
|
244
|
+
if (textContent) {
|
245
|
+
d.textContent = textContent;
|
246
|
+
}
|
247
|
+
return d;
|
248
|
+
}
|
249
|
+
|
250
|
+
#simplifyArgs(args) {
|
251
|
+
if (typeof args === "string") {
|
252
|
+
const MAX_STRING_LENGTH = 75;
|
253
|
+
return args.length <= MAX_STRING_LENGTH
|
254
|
+
? args
|
255
|
+
: args.substring(0, MAX_STRING_LENGTH) + "...";
|
256
|
+
}
|
257
|
+
if (typeof args !== "object" || args === null) {
|
258
|
+
return args;
|
259
|
+
}
|
260
|
+
if ("length" in args) {
|
261
|
+
// array
|
262
|
+
const MAX_ITEMS = 10,
|
263
|
+
simpleArgs = [];
|
264
|
+
let i, ii;
|
265
|
+
for (i = 0, ii = Math.min(MAX_ITEMS, args.length); i < ii; i++) {
|
266
|
+
simpleArgs.push(this.#simplifyArgs(args[i]));
|
267
|
+
}
|
268
|
+
if (i < args.length) {
|
269
|
+
simpleArgs.push("...");
|
270
|
+
}
|
271
|
+
return simpleArgs;
|
272
|
+
}
|
273
|
+
const simpleObj = {};
|
274
|
+
for (const key in args) {
|
275
|
+
simpleObj[key] = this.#simplifyArgs(args[key]);
|
276
|
+
}
|
277
|
+
return simpleObj;
|
278
|
+
}
|
279
|
+
|
280
|
+
constructor(panel, pageIndex, initialBreakPoints) {
|
281
|
+
this.panel = panel;
|
282
|
+
this.breakPoint = 0;
|
283
|
+
this.nextBreakPoint = null;
|
284
|
+
this.pageIndex = pageIndex;
|
285
|
+
this.breakPoints = initialBreakPoints;
|
286
|
+
this.currentIdx = -1;
|
287
|
+
this.operatorListIdx = 0;
|
288
|
+
this.indentLevel = 0;
|
289
|
+
}
|
290
|
+
|
291
|
+
init(operatorList) {
|
292
|
+
const panel = this.panel;
|
293
|
+
const content = this.#c("div", "c=continue, s=step");
|
294
|
+
const table = this.#c("table");
|
295
|
+
content.append(table);
|
296
|
+
table.cellSpacing = 0;
|
297
|
+
const headerRow = this.#c("tr");
|
298
|
+
table.append(headerRow);
|
299
|
+
headerRow.append(
|
300
|
+
this.#c("th", "Break"),
|
301
|
+
this.#c("th", "Idx"),
|
302
|
+
this.#c("th", "fn"),
|
303
|
+
this.#c("th", "args")
|
304
|
+
);
|
305
|
+
panel.append(content);
|
306
|
+
this.table = table;
|
307
|
+
this.updateOperatorList(operatorList);
|
308
|
+
}
|
309
|
+
|
310
|
+
updateOperatorList(operatorList) {
|
311
|
+
const self = this;
|
312
|
+
|
313
|
+
function cboxOnClick() {
|
314
|
+
const x = +this.dataset.idx;
|
315
|
+
if (this.checked) {
|
316
|
+
self.breakPoints.push(x);
|
317
|
+
} else {
|
318
|
+
self.breakPoints.splice(self.breakPoints.indexOf(x), 1);
|
319
|
+
}
|
320
|
+
StepperManager.saveBreakPoints(self.pageIndex, self.breakPoints);
|
321
|
+
}
|
322
|
+
|
323
|
+
const MAX_OPERATORS_COUNT = 15000;
|
324
|
+
if (this.operatorListIdx > MAX_OPERATORS_COUNT) {
|
325
|
+
return;
|
326
|
+
}
|
327
|
+
|
328
|
+
const chunk = document.createDocumentFragment();
|
329
|
+
const operatorsToDisplay = Math.min(
|
330
|
+
MAX_OPERATORS_COUNT,
|
331
|
+
operatorList.fnArray.length
|
332
|
+
);
|
333
|
+
for (let i = this.operatorListIdx; i < operatorsToDisplay; i++) {
|
334
|
+
const line = this.#c("tr");
|
335
|
+
line.className = "line";
|
336
|
+
line.dataset.idx = i;
|
337
|
+
chunk.append(line);
|
338
|
+
const checked = this.breakPoints.includes(i);
|
339
|
+
const args = operatorList.argsArray[i] || [];
|
340
|
+
|
341
|
+
const breakCell = this.#c("td");
|
342
|
+
const cbox = this.#c("input");
|
343
|
+
cbox.type = "checkbox";
|
344
|
+
cbox.className = "points";
|
345
|
+
cbox.checked = checked;
|
346
|
+
cbox.dataset.idx = i;
|
347
|
+
cbox.onclick = cboxOnClick;
|
348
|
+
|
349
|
+
breakCell.append(cbox);
|
350
|
+
line.append(breakCell, this.#c("td", i.toString()));
|
351
|
+
const fn = opMap[operatorList.fnArray[i]];
|
352
|
+
let decArgs = args;
|
353
|
+
if (fn === "showText") {
|
354
|
+
const glyphs = args[0];
|
355
|
+
const charCodeRow = this.#c("tr");
|
356
|
+
const fontCharRow = this.#c("tr");
|
357
|
+
const unicodeRow = this.#c("tr");
|
358
|
+
for (const glyph of glyphs) {
|
359
|
+
if (typeof glyph === "object" && glyph !== null) {
|
360
|
+
charCodeRow.append(this.#c("td", glyph.originalCharCode));
|
361
|
+
fontCharRow.append(this.#c("td", glyph.fontChar));
|
362
|
+
unicodeRow.append(this.#c("td", glyph.unicode));
|
363
|
+
} else {
|
364
|
+
// null or number
|
365
|
+
const advanceEl = this.#c("td", glyph);
|
366
|
+
advanceEl.classList.add("advance");
|
367
|
+
charCodeRow.append(advanceEl);
|
368
|
+
fontCharRow.append(this.#c("td"));
|
369
|
+
unicodeRow.append(this.#c("td"));
|
370
|
+
}
|
371
|
+
}
|
372
|
+
decArgs = this.#c("td");
|
373
|
+
const table = this.#c("table");
|
374
|
+
table.classList.add("showText");
|
375
|
+
decArgs.append(table);
|
376
|
+
table.append(charCodeRow, fontCharRow, unicodeRow);
|
377
|
+
} else if (fn === "constructPath") {
|
378
|
+
const [op, [path], minMax] = args;
|
379
|
+
decArgs = this.#c("td");
|
380
|
+
decArgs.append(JSON.stringify(this.#simplifyArgs(path)));
|
381
|
+
decArgs.append(this.#c("br"));
|
382
|
+
decArgs.append(`minMax: ${JSON.stringify(this.#simplifyArgs(minMax))}`);
|
383
|
+
decArgs.append(this.#c("br"));
|
384
|
+
decArgs.append(`→ ${opMap[op]}`);
|
385
|
+
} else if (fn === "restore" && this.indentLevel > 0) {
|
386
|
+
this.indentLevel--;
|
387
|
+
}
|
388
|
+
line.append(this.#c("td", " ".repeat(this.indentLevel * 2) + fn));
|
389
|
+
if (fn === "save") {
|
390
|
+
this.indentLevel++;
|
391
|
+
}
|
392
|
+
|
393
|
+
if (decArgs instanceof HTMLElement) {
|
394
|
+
line.append(decArgs);
|
395
|
+
} else {
|
396
|
+
line.append(this.#c("td", JSON.stringify(this.#simplifyArgs(decArgs))));
|
397
|
+
}
|
398
|
+
}
|
399
|
+
if (operatorsToDisplay < operatorList.fnArray.length) {
|
400
|
+
const lastCell = this.#c("td", "...");
|
401
|
+
lastCell.colspan = 4;
|
402
|
+
chunk.append(lastCell);
|
403
|
+
}
|
404
|
+
this.operatorListIdx = operatorList.fnArray.length;
|
405
|
+
this.table.append(chunk);
|
406
|
+
}
|
407
|
+
|
408
|
+
getNextBreakPoint() {
|
409
|
+
this.breakPoints.sort((a, b) => a - b);
|
410
|
+
for (const breakPoint of this.breakPoints) {
|
411
|
+
if (breakPoint > this.currentIdx) {
|
412
|
+
return breakPoint;
|
413
|
+
}
|
414
|
+
}
|
415
|
+
return null;
|
416
|
+
}
|
417
|
+
|
418
|
+
breakIt(idx, callback) {
|
419
|
+
StepperManager.selectStepper(this.pageIndex, true);
|
420
|
+
this.currentIdx = idx;
|
421
|
+
|
422
|
+
const listener = evt => {
|
423
|
+
switch (evt.keyCode) {
|
424
|
+
case 83: // step
|
425
|
+
document.removeEventListener("keydown", listener);
|
426
|
+
this.nextBreakPoint = this.currentIdx + 1;
|
427
|
+
this.goTo(-1);
|
428
|
+
callback();
|
429
|
+
break;
|
430
|
+
case 67: // continue
|
431
|
+
document.removeEventListener("keydown", listener);
|
432
|
+
this.nextBreakPoint = this.getNextBreakPoint();
|
433
|
+
this.goTo(-1);
|
434
|
+
callback();
|
435
|
+
break;
|
436
|
+
}
|
437
|
+
};
|
438
|
+
document.addEventListener("keydown", listener);
|
439
|
+
this.goTo(idx);
|
440
|
+
}
|
441
|
+
|
442
|
+
goTo(idx) {
|
443
|
+
const allRows = this.panel.getElementsByClassName("line");
|
444
|
+
for (const row of allRows) {
|
445
|
+
if ((row.dataset.idx | 0) === idx) {
|
446
|
+
row.style.backgroundColor = "rgb(251,250,207)";
|
447
|
+
row.scrollIntoView();
|
448
|
+
} else {
|
449
|
+
row.style.backgroundColor = null;
|
450
|
+
}
|
451
|
+
}
|
452
|
+
}
|
453
|
+
}
|
454
|
+
|
455
|
+
const Stats = (function Stats() {
|
456
|
+
let stats = [];
|
457
|
+
function clear(node) {
|
458
|
+
node.textContent = ""; // Remove any `node` contents from the DOM.
|
459
|
+
}
|
460
|
+
function getStatIndex(pageNumber) {
|
461
|
+
for (const [i, stat] of stats.entries()) {
|
462
|
+
if (stat.pageNumber === pageNumber) {
|
463
|
+
return i;
|
464
|
+
}
|
465
|
+
}
|
466
|
+
return false;
|
467
|
+
}
|
468
|
+
return {
|
469
|
+
// Properties/functions needed by PDFBug.
|
470
|
+
id: "Stats",
|
471
|
+
name: "Stats",
|
472
|
+
panel: null,
|
473
|
+
manager: null,
|
474
|
+
init() {},
|
475
|
+
enabled: false,
|
476
|
+
active: false,
|
477
|
+
// Stats specific functions.
|
478
|
+
add(pageNumber, stat) {
|
479
|
+
if (!stat) {
|
480
|
+
return;
|
481
|
+
}
|
482
|
+
const statsIndex = getStatIndex(pageNumber);
|
483
|
+
if (statsIndex !== false) {
|
484
|
+
stats[statsIndex].div.remove();
|
485
|
+
stats.splice(statsIndex, 1);
|
486
|
+
}
|
487
|
+
const wrapper = document.createElement("div");
|
488
|
+
wrapper.className = "stats";
|
489
|
+
const title = document.createElement("div");
|
490
|
+
title.className = "title";
|
491
|
+
title.textContent = "Page: " + pageNumber;
|
492
|
+
const statsDiv = document.createElement("div");
|
493
|
+
statsDiv.textContent = stat.toString();
|
494
|
+
wrapper.append(title, statsDiv);
|
495
|
+
stats.push({ pageNumber, div: wrapper });
|
496
|
+
stats.sort((a, b) => a.pageNumber - b.pageNumber);
|
497
|
+
clear(this.panel);
|
498
|
+
for (const entry of stats) {
|
499
|
+
this.panel.append(entry.div);
|
500
|
+
}
|
501
|
+
},
|
502
|
+
cleanup() {
|
503
|
+
stats = [];
|
504
|
+
clear(this.panel);
|
505
|
+
},
|
506
|
+
};
|
507
|
+
})();
|
508
|
+
|
509
|
+
// Manages all the debugging tools.
|
510
|
+
class PDFBug {
|
511
|
+
static #buttons = [];
|
512
|
+
|
513
|
+
static #activePanel = null;
|
514
|
+
|
515
|
+
static tools = [FontInspector, StepperManager, Stats];
|
516
|
+
|
517
|
+
static enable(ids) {
|
518
|
+
const all = ids.length === 1 && ids[0] === "all";
|
519
|
+
const tools = this.tools;
|
520
|
+
for (const tool of tools) {
|
521
|
+
if (all || ids.includes(tool.id)) {
|
522
|
+
tool.enabled = true;
|
523
|
+
}
|
524
|
+
}
|
525
|
+
if (!all) {
|
526
|
+
// Sort the tools by the order they are enabled.
|
527
|
+
tools.sort(function (a, b) {
|
528
|
+
let indexA = ids.indexOf(a.id);
|
529
|
+
indexA = indexA < 0 ? tools.length : indexA;
|
530
|
+
let indexB = ids.indexOf(b.id);
|
531
|
+
indexB = indexB < 0 ? tools.length : indexB;
|
532
|
+
return indexA - indexB;
|
533
|
+
});
|
534
|
+
}
|
535
|
+
}
|
536
|
+
|
537
|
+
static init(container, ids) {
|
538
|
+
this.loadCSS();
|
539
|
+
this.enable(ids);
|
540
|
+
/*
|
541
|
+
* Basic Layout:
|
542
|
+
* PDFBug
|
543
|
+
* Controls
|
544
|
+
* Panels
|
545
|
+
* Panel
|
546
|
+
* Panel
|
547
|
+
* ...
|
548
|
+
*/
|
549
|
+
const ui = document.createElement("div");
|
550
|
+
ui.id = "PDFBug";
|
551
|
+
|
552
|
+
const controls = document.createElement("div");
|
553
|
+
controls.setAttribute("class", "controls");
|
554
|
+
ui.append(controls);
|
555
|
+
|
556
|
+
const panels = document.createElement("div");
|
557
|
+
panels.setAttribute("class", "panels");
|
558
|
+
ui.append(panels);
|
559
|
+
|
560
|
+
container.append(ui);
|
561
|
+
container.style.right = "var(--panel-width)";
|
562
|
+
|
563
|
+
// Initialize all the debugging tools.
|
564
|
+
for (const tool of this.tools) {
|
565
|
+
const panel = document.createElement("div");
|
566
|
+
const panelButton = document.createElement("button");
|
567
|
+
panelButton.textContent = tool.name;
|
568
|
+
panelButton.addEventListener("click", event => {
|
569
|
+
event.preventDefault();
|
570
|
+
this.selectPanel(tool);
|
571
|
+
});
|
572
|
+
controls.append(panelButton);
|
573
|
+
panels.append(panel);
|
574
|
+
tool.panel = panel;
|
575
|
+
tool.manager = this;
|
576
|
+
if (tool.enabled) {
|
577
|
+
tool.init();
|
578
|
+
} else {
|
579
|
+
panel.textContent =
|
580
|
+
`${tool.name} is disabled. To enable add "${tool.id}" to ` +
|
581
|
+
"the pdfBug parameter and refresh (separate multiple by commas).";
|
582
|
+
}
|
583
|
+
this.#buttons.push(panelButton);
|
584
|
+
}
|
585
|
+
this.selectPanel(0);
|
586
|
+
}
|
587
|
+
|
588
|
+
static loadCSS() {
|
589
|
+
const { url } = import.meta;
|
590
|
+
|
591
|
+
const link = document.createElement("link");
|
592
|
+
link.rel = "stylesheet";
|
593
|
+
link.href = url.replace(/\.mjs$/, ".css");
|
594
|
+
|
595
|
+
document.head.append(link);
|
596
|
+
}
|
597
|
+
|
598
|
+
static cleanup() {
|
599
|
+
for (const tool of this.tools) {
|
600
|
+
if (tool.enabled) {
|
601
|
+
tool.cleanup();
|
602
|
+
}
|
603
|
+
}
|
604
|
+
}
|
605
|
+
|
606
|
+
static selectPanel(index) {
|
607
|
+
if (typeof index !== "number") {
|
608
|
+
index = this.tools.indexOf(index);
|
609
|
+
}
|
610
|
+
if (index === this.#activePanel) {
|
611
|
+
return;
|
612
|
+
}
|
613
|
+
this.#activePanel = index;
|
614
|
+
for (const [j, tool] of this.tools.entries()) {
|
615
|
+
const isActive = j === index;
|
616
|
+
this.#buttons[j].classList.toggle("active", isActive);
|
617
|
+
tool.active = isActive;
|
618
|
+
tool.panel.hidden = !isActive;
|
619
|
+
}
|
620
|
+
}
|
621
|
+
}
|
622
|
+
|
623
|
+
globalThis.FontInspector = FontInspector;
|
624
|
+
globalThis.StepperManager = StepperManager;
|
625
|
+
globalThis.Stats = Stats;
|
626
|
+
|
627
|
+
export { PDFBug };
|
Binary file
|