@floless/app 0.167.0 → 0.168.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/autostart.mjs +169 -63
- package/desktop-shell.mjs +335 -0
- package/dist/floless-server.cjs +14518 -11361
- package/dist/schemas/steel.model.v2.schema.json +2 -1
- package/dist/skills/floless-app-onboarding/SKILL.md +13 -4
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +3 -0
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +21 -2
- package/dist/skills/floless-app-ui/SKILL.md +2 -2
- package/dist/skills/floless-app-workflows/SKILL.md +2 -2
- package/dist/web/agents.js +1 -1
- package/dist/web/app.css +165 -8
- package/dist/web/app.js +53 -13
- package/dist/web/aware-update-client.js +13 -5
- package/dist/web/aware.js +183 -39
- package/dist/web/chat.css +2 -1
- package/dist/web/chat.js +410 -80
- package/dist/web/commands-filter.js +5 -5
- package/dist/web/commands-shell.js +172 -10
- package/dist/web/commands-steel.js +1 -1
- package/dist/web/desktop-window.js +435 -0
- package/dist/web/drawing-check-editor.js +18 -10
- package/dist/web/failure-copy.js +14 -1
- package/dist/web/guide.js +75 -9
- package/dist/web/index.html +64 -6
- package/dist/web/instructor.js +1 -1
- package/dist/web/leave-guard.js +347 -14
- package/dist/web/pages.js +5 -1
- package/dist/web/panels.js +5 -2
- package/dist/web/pdf-view.js +421 -0
- package/dist/web/project-history.js +2 -1
- package/dist/web/project-modules.js +3 -1
- package/dist/web/project-rfis.js +3 -1
- package/dist/web/project-workflows.js +4 -2
- package/dist/web/reference-geometry-worker.js +11 -2
- package/dist/web/revit-editor.html +1 -0
- package/dist/web/revit-editor.js +37 -8
- package/dist/web/shared-prefs.js +364 -0
- package/dist/web/steel-editor.html +204 -43
- package/dist/web/steel-filter-flo.js +74 -18
- package/dist/web/steel-filter.html +22 -6
- package/dist/web/tab-signal.js +36 -1
- package/dist/web/tekla-editor.html +1 -0
- package/dist/web/tool-updates.js +159 -38
- package/dist/web/vector-3d.html +14 -3
- package/dist/web/vector-editor.html +10 -2
- package/dist/web/vendor/README.md +23 -0
- package/dist/web/vendor/pdfjs/LICENSE +177 -0
- package/dist/web/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
- package/dist/web/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/LICENSE +36 -0
- package/dist/web/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/dist/web/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/web/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/web/vendor/pdfjs/iccs/LICENSE +116 -0
- package/dist/web/vendor/pdfjs/pdf.min.mjs +28 -0
- package/dist/web/vendor/pdfjs/pdf.worker.mjs +64908 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/web/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/web/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/web/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/web/vendor/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/web/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +15 -0
- package/dist/web/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/web/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +17 -0
- package/dist/web/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/web/workspaces.js +167 -26
- package/home-env.mjs +28 -0
- package/install-path.mjs +59 -3
- package/launch-starting-page.mjs +35 -15
- package/launch.mjs +358 -51
- package/package.json +2 -1
- package/pin-home.mjs +6 -0
- package/post-update-marker.mjs +14 -0
- package/preferences-file.mjs +289 -0
- package/supervisor-lock.mjs +195 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
// FloLess's own PDF viewer (#3018). A PDF used to be put in an <iframe>, so the browser's own viewer drew it: a separate
|
|
2
|
+
// page FloLess's CSS cannot reach, with a light OS scrollbar and the blob's random id as its title in the dark theme. This
|
|
3
|
+
// draws the pages itself with the vendored pdf.js (web/vendor/pdfjs/, loaded only when a PDF first opens), inside a
|
|
4
|
+
// themed toolbar and scroll area, in both themes.
|
|
5
|
+
//
|
|
6
|
+
// It draws ONLY the bytes it is handed. The caller passes the bytes its own route verified (#3002) and nothing here
|
|
7
|
+
// fetches the PDF again, by path or URL: pdf.js gets `data`, never `url`, and Download saves those same bytes.
|
|
8
|
+
//
|
|
9
|
+
// mount(host, { bytes, name, showName, library }) → { el, ready, destroy } — the one entry point. `library` stands in for
|
|
10
|
+
// pdf.js in a test; FloLess itself never passes it.
|
|
11
|
+
// A plain script (no import/export); its one global is `flolessPdfView`.
|
|
12
|
+
|
|
13
|
+
(function () {
|
|
14
|
+
const VENDOR = new URL('vendor/pdfjs/', document.currentScript?.src || document.baseURI).href;
|
|
15
|
+
// 100% is the page at its real size: one PDF point is 96/72 CSS pixels.
|
|
16
|
+
const PT = 96 / 72;
|
|
17
|
+
const MIN_ZOOM = 0.25;
|
|
18
|
+
const FIT_MIN = 0.05; // Fit width may go below MIN_ZOOM: a large sheet in a narrow preview must still fit
|
|
19
|
+
const MAX_ZOOM = 5;
|
|
20
|
+
const STEPS = [0.25, 0.33, 0.5, 0.67, 0.75, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5];
|
|
21
|
+
// Pages this far outside the visible area are drawn ahead of the scroll, and dropped again further out.
|
|
22
|
+
const AHEAD = '600px 0px';
|
|
23
|
+
// The most pixels one page's picture may hold (about 64 MB of RGBA). Only visible pages hold one at all.
|
|
24
|
+
const MAX_PIXELS = 16_000_000;
|
|
25
|
+
|
|
26
|
+
let library = null;
|
|
27
|
+
function loadLibrary() {
|
|
28
|
+
if (!library) {
|
|
29
|
+
library = import(`${VENDOR}pdf.min.mjs`).then((lib) => {
|
|
30
|
+
lib.GlobalWorkerOptions.workerSrc = `${VENDOR}pdf.worker.mjs`;
|
|
31
|
+
return lib;
|
|
32
|
+
});
|
|
33
|
+
library.catch(() => { library = null; });
|
|
34
|
+
}
|
|
35
|
+
return library;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function el(tag, className, props) {
|
|
39
|
+
const node = document.createElement(tag);
|
|
40
|
+
if (className) node.className = className;
|
|
41
|
+
if (props) Object.assign(node, props);
|
|
42
|
+
return node;
|
|
43
|
+
}
|
|
44
|
+
function control(label, commandId, tip, className = '') {
|
|
45
|
+
const node = el('button', `pdf-view-btn ${className}`.trim(), { type: 'button', textContent: label });
|
|
46
|
+
node.dataset.commandId = commandId;
|
|
47
|
+
if (tip) node.dataset.tip = tip;
|
|
48
|
+
return node;
|
|
49
|
+
}
|
|
50
|
+
const clamp = (n, lo, hi) => Math.min(hi, Math.max(lo, n));
|
|
51
|
+
|
|
52
|
+
/** What a failure to draw is, in words for the person. Download stays offered whatever it is. */
|
|
53
|
+
function failureWords(error) {
|
|
54
|
+
const name = error && error.name;
|
|
55
|
+
if (name === 'PasswordException') return 'This PDF is locked with a password, so FloLess cannot show it here. Download it and open it with the password.';
|
|
56
|
+
if (name === 'InvalidPDFException') return 'FloLess could not draw this PDF: the file is not a readable PDF. You can still download it.';
|
|
57
|
+
return 'FloLess could not draw this PDF. You can still download it.';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function mount(host, options) {
|
|
61
|
+
const bytes = options.bytes instanceof Uint8Array ? options.bytes : new Uint8Array(options.bytes);
|
|
62
|
+
const name = String(options.name || 'document.pdf');
|
|
63
|
+
let destroyed = false;
|
|
64
|
+
let doc = null;
|
|
65
|
+
let task = null;
|
|
66
|
+
let scale = 1;
|
|
67
|
+
let fitting = true; // re-fit on resize until the person zooms themselves
|
|
68
|
+
let current = 1;
|
|
69
|
+
let pages = []; // { box, canvas, text, base: {w,h} | null, drawn: scale | 0, render, layer }
|
|
70
|
+
let downloadUrl = null;
|
|
71
|
+
let pdfLib = null;
|
|
72
|
+
|
|
73
|
+
const root = el('div', 'pdf-view');
|
|
74
|
+
root.dataset.state = 'loading';
|
|
75
|
+
const bar = el('div', 'pdf-view-bar');
|
|
76
|
+
bar.setAttribute('role', 'toolbar');
|
|
77
|
+
bar.setAttribute('aria-label', `${name} — pages, zoom and download`);
|
|
78
|
+
const title = el('span', 'pdf-view-name', { textContent: name });
|
|
79
|
+
if (options.showName === false) title.hidden = true;
|
|
80
|
+
|
|
81
|
+
const nav = el('div', 'pdf-view-group pdf-view-nav');
|
|
82
|
+
nav.setAttribute('role', 'group'); nav.setAttribute('aria-label', 'Pages');
|
|
83
|
+
const prev = control('‹', 'shell.pdf-view-prev', 'Previous page (Page Up)');
|
|
84
|
+
prev.setAttribute('aria-label', 'Previous page');
|
|
85
|
+
const pageField = el('input', 'pdf-view-page', { type: 'text', inputMode: 'numeric', autocomplete: 'off', value: '1' });
|
|
86
|
+
pageField.setAttribute('aria-label', 'Page number');
|
|
87
|
+
pageField.dataset.commandId = 'shell.pdf-view-page';
|
|
88
|
+
pageField.dataset.tip = 'Type a page number and press Enter to go to it';
|
|
89
|
+
const total = el('span', 'pdf-view-total', { textContent: 'of –' });
|
|
90
|
+
const next = control('›', 'shell.pdf-view-next', 'Next page (Page Down)');
|
|
91
|
+
next.setAttribute('aria-label', 'Next page');
|
|
92
|
+
nav.append(prev, pageField, total, next);
|
|
93
|
+
|
|
94
|
+
const zoom = el('div', 'pdf-view-group pdf-view-zoom');
|
|
95
|
+
zoom.setAttribute('role', 'group'); zoom.setAttribute('aria-label', 'Zoom');
|
|
96
|
+
const zoomOut = control('−', 'shell.pdf-view-zoom-out', 'Zoom out (or press -)');
|
|
97
|
+
zoomOut.setAttribute('aria-label', 'Zoom out');
|
|
98
|
+
const level = el('span', 'pdf-view-level', { textContent: '100%' });
|
|
99
|
+
level.setAttribute('aria-hidden', 'true');
|
|
100
|
+
const zoomIn = control('+', 'shell.pdf-view-zoom-in', 'Zoom in (or press +, or Ctrl and scroll)');
|
|
101
|
+
zoomIn.setAttribute('aria-label', 'Zoom in');
|
|
102
|
+
const fit = control('Fit width', 'shell.pdf-view-fit', 'Fit the page to the width of the viewer (or press 0)', 'pdf-view-fit');
|
|
103
|
+
zoom.append(zoomOut, level, zoomIn, fit);
|
|
104
|
+
|
|
105
|
+
downloadUrl = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }));
|
|
106
|
+
const download = el('a', 'pdf-view-btn pdf-view-download', { href: downloadUrl, download: name, textContent: 'Download' });
|
|
107
|
+
download.dataset.commandId = 'shell.pdf-view-download';
|
|
108
|
+
download.dataset.tip = `Save ${name} as it is shown here`;
|
|
109
|
+
|
|
110
|
+
bar.append(title, nav, zoom, download);
|
|
111
|
+
const stage = el('div', 'pdf-view-stage');
|
|
112
|
+
stage.tabIndex = 0;
|
|
113
|
+
stage.setAttribute('role', 'document');
|
|
114
|
+
stage.setAttribute('aria-label', `${name}`);
|
|
115
|
+
const status = el('p', 'pdf-view-status', { textContent: 'Opening the PDF…' });
|
|
116
|
+
status.setAttribute('role', 'status');
|
|
117
|
+
const live = el('span', 'pdf-view-live');
|
|
118
|
+
live.setAttribute('aria-live', 'polite');
|
|
119
|
+
stage.append(status);
|
|
120
|
+
root.append(bar, stage, live);
|
|
121
|
+
host.append(root);
|
|
122
|
+
|
|
123
|
+
const showControls = (on) => { nav.hidden = !on || !doc || doc.numPages < 2; zoom.hidden = !on; };
|
|
124
|
+
showControls(false);
|
|
125
|
+
|
|
126
|
+
function setLevel() {
|
|
127
|
+
level.textContent = `${Math.round(scale * 100)}%`;
|
|
128
|
+
zoomOut.disabled = scale <= MIN_ZOOM + 1e-9;
|
|
129
|
+
zoomIn.disabled = scale >= MAX_ZOOM - 1e-9;
|
|
130
|
+
fit.setAttribute('aria-pressed', String(fitting));
|
|
131
|
+
}
|
|
132
|
+
function setCurrent(n, announce) {
|
|
133
|
+
if (!doc) return;
|
|
134
|
+
current = clamp(n, 1, doc.numPages);
|
|
135
|
+
pageField.value = String(current);
|
|
136
|
+
prev.disabled = current <= 1;
|
|
137
|
+
next.disabled = current >= doc.numPages;
|
|
138
|
+
stage.setAttribute('aria-label', `${name}, page ${current} of ${doc.numPages}`);
|
|
139
|
+
if (announce) live.textContent = `Page ${current} of ${doc.numPages}`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ── drawing ────────────────────────────────────────────────────────────────
|
|
143
|
+
const first = () => pages.find((p) => p.base)?.base;
|
|
144
|
+
function sizeBox(page) {
|
|
145
|
+
const base = page.base || first();
|
|
146
|
+
if (!base) return;
|
|
147
|
+
page.box.style.width = `${Math.floor(base.w * scale * PT)}px`;
|
|
148
|
+
page.box.style.height = `${Math.floor(base.h * scale * PT)}px`;
|
|
149
|
+
}
|
|
150
|
+
/** Drop a page's picture and text, and make any drawing of it still on its way stale, so it never fills a picture
|
|
151
|
+
* for a page that has left the view. */
|
|
152
|
+
function forget(page) {
|
|
153
|
+
page.ticket += 1;
|
|
154
|
+
if (page.render) { page.render.cancel(); page.render = null; }
|
|
155
|
+
if (page.layer) { page.layer.cancel?.(); page.layer = null; }
|
|
156
|
+
page.canvas.width = 0; page.canvas.height = 0;
|
|
157
|
+
page.text.replaceChildren();
|
|
158
|
+
page.drawn = 0;
|
|
159
|
+
}
|
|
160
|
+
/** A page pdf.js could not draw says so on the page itself, and is not tried again until the zoom changes. */
|
|
161
|
+
function failPage(page, error) {
|
|
162
|
+
page.failed = true;
|
|
163
|
+
page.box.dataset.failed = 'true';
|
|
164
|
+
forget(page);
|
|
165
|
+
if (!page.box.querySelector('.pdf-view-sheet-failed')) {
|
|
166
|
+
const note = el('p', 'pdf-view-sheet-failed', { textContent: `FloLess could not draw page ${page.number}. The other pages are not affected, and Download still saves the whole PDF.` });
|
|
167
|
+
note.setAttribute('role', 'note');
|
|
168
|
+
page.box.append(note);
|
|
169
|
+
}
|
|
170
|
+
console.warn(`[pdf-view] page ${page.number} of ${name} could not be drawn`, error);
|
|
171
|
+
}
|
|
172
|
+
/** A page that has left the view gives back what pdf.js holds for it too (its drawing instructions and decoded
|
|
173
|
+
* images), not only its picture. pdf.js defers that until a drawing still running has stopped. */
|
|
174
|
+
function release(page) {
|
|
175
|
+
forget(page);
|
|
176
|
+
page.proxy?.cleanup();
|
|
177
|
+
}
|
|
178
|
+
function unfail(page) {
|
|
179
|
+
page.failed = false;
|
|
180
|
+
delete page.box.dataset.failed;
|
|
181
|
+
page.box.querySelector('.pdf-view-sheet-failed')?.remove();
|
|
182
|
+
}
|
|
183
|
+
async function draw(page) {
|
|
184
|
+
if (destroyed || !doc || !page.visible || page.failed || page.drawn === scale || page.busy) return;
|
|
185
|
+
page.busy = true;
|
|
186
|
+
const at = scale;
|
|
187
|
+
const ticket = page.ticket;
|
|
188
|
+
// Scrolled away, zoomed, or closed since this drawing began: it stops, and paints nothing.
|
|
189
|
+
const stale = () => destroyed || at !== scale || ticket !== page.ticket || !page.visible;
|
|
190
|
+
let failure = null;
|
|
191
|
+
try {
|
|
192
|
+
const pdfPage = await doc.getPage(page.number);
|
|
193
|
+
page.proxy = pdfPage;
|
|
194
|
+
if (stale()) return;
|
|
195
|
+
const one = pdfPage.getViewport({ scale: 1 });
|
|
196
|
+
page.base = { w: one.width, h: one.height };
|
|
197
|
+
sizeBox(page);
|
|
198
|
+
const viewport = pdfPage.getViewport({ scale: at * PT });
|
|
199
|
+
// A large sheet zoomed in on a high-density screen is drawn sharper only up to MAX_PIXELS; past it, a little softer.
|
|
200
|
+
const dpr = window.devicePixelRatio || 1;
|
|
201
|
+
const ratio = Math.min(dpr, Math.sqrt(MAX_PIXELS / Math.max(1, viewport.width * viewport.height)));
|
|
202
|
+
const canvas = page.canvas;
|
|
203
|
+
canvas.width = Math.floor(viewport.width * ratio);
|
|
204
|
+
canvas.height = Math.floor(viewport.height * ratio);
|
|
205
|
+
canvas.style.width = `${Math.floor(viewport.width)}px`;
|
|
206
|
+
canvas.style.height = `${Math.floor(viewport.height)}px`;
|
|
207
|
+
page.render = pdfPage.render({ canvas, viewport, transform: ratio !== 1 ? [ratio, 0, 0, ratio, 0, 0] : undefined });
|
|
208
|
+
await page.render.promise;
|
|
209
|
+
page.render = null;
|
|
210
|
+
if (stale()) return;
|
|
211
|
+
page.box.style.setProperty('--total-scale-factor', String(viewport.scale));
|
|
212
|
+
page.text.replaceChildren();
|
|
213
|
+
page.layer = new pdfLib.TextLayer({ textContentSource: pdfPage.streamTextContent(), container: page.text, viewport });
|
|
214
|
+
await page.layer.render();
|
|
215
|
+
page.layer = null;
|
|
216
|
+
if (stale()) return;
|
|
217
|
+
page.drawn = at;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
// A drawing stopped on purpose (scrolled away, zoomed, closed) rejects with pdf.js's cancellation error; each of
|
|
220
|
+
// those goes through forget() or destroy(), so it is stale, and only an error on live work is a failure.
|
|
221
|
+
if (!stale()) failure = error;
|
|
222
|
+
} finally {
|
|
223
|
+
page.busy = false;
|
|
224
|
+
if (failure) failPage(page, failure);
|
|
225
|
+
// Zoomed while this page was being drawn: draw it again at the new size if it is still in view.
|
|
226
|
+
else if (!destroyed && page.visible && page.drawn !== scale) void draw(page);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let observer = null;
|
|
231
|
+
let tracker = null;
|
|
232
|
+
function watch() {
|
|
233
|
+
observer = new IntersectionObserver((entries) => {
|
|
234
|
+
for (const entry of entries) {
|
|
235
|
+
const page = pages[Number(entry.target.dataset.page) - 1];
|
|
236
|
+
if (!page) continue;
|
|
237
|
+
page.visible = entry.isIntersecting;
|
|
238
|
+
if (entry.isIntersecting) void draw(page); else release(page);
|
|
239
|
+
}
|
|
240
|
+
}, { root: stage, rootMargin: AHEAD });
|
|
241
|
+
for (const page of pages) observer.observe(page.box);
|
|
242
|
+
stage.addEventListener('scroll', track, { passive: true });
|
|
243
|
+
}
|
|
244
|
+
function track() {
|
|
245
|
+
if (tracker) return;
|
|
246
|
+
tracker = requestAnimationFrame(() => {
|
|
247
|
+
tracker = null;
|
|
248
|
+
const middle = stage.scrollTop + stage.clientHeight / 3;
|
|
249
|
+
let n = 1;
|
|
250
|
+
for (const page of pages) { if (page.box.offsetTop <= middle) n = page.number; else break; }
|
|
251
|
+
if (n !== current) setCurrent(n, false);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function fitScale() {
|
|
256
|
+
const base = first();
|
|
257
|
+
if (!base) return 1;
|
|
258
|
+
const room = stage.clientWidth - 24 - 2;
|
|
259
|
+
// A stage not laid out yet has no width to fit: 100% until it has (the resize watcher fits it then).
|
|
260
|
+
if (!(room > 0)) return 1;
|
|
261
|
+
return clamp(room / (base.w * PT), FIT_MIN, MAX_ZOOM);
|
|
262
|
+
}
|
|
263
|
+
function rescale(nextScale, manual) {
|
|
264
|
+
// A zoom that is not a number would make every drawing stale forever, and draw() would retry it without end.
|
|
265
|
+
if (!doc || !Number.isFinite(nextScale)) return;
|
|
266
|
+
if (manual) fitting = false;
|
|
267
|
+
// A manual zoom stops at MIN_ZOOM, and never jumps up to it from a smaller fitted size; Fit width goes to FIT_MIN.
|
|
268
|
+
nextScale = clamp(nextScale, manual ? Math.min(MIN_ZOOM, scale) : FIT_MIN, MAX_ZOOM);
|
|
269
|
+
// Keep the same place on the same page in view.
|
|
270
|
+
const page = pages[current - 1];
|
|
271
|
+
const into = page ? (stage.scrollTop - page.box.offsetTop) / Math.max(1, page.box.offsetHeight) : 0;
|
|
272
|
+
scale = nextScale;
|
|
273
|
+
// Every picture is redrawn at the new size, any drawing still running is stopped, and a page that failed is tried again.
|
|
274
|
+
for (const p of pages) { sizeBox(p); unfail(p); if (p.drawn || p.busy) forget(p); }
|
|
275
|
+
if (page) stage.scrollTop = page.box.offsetTop + into * page.box.offsetHeight;
|
|
276
|
+
setLevel();
|
|
277
|
+
for (const p of pages) if (p.visible) void draw(p);
|
|
278
|
+
}
|
|
279
|
+
const step = (dir) => {
|
|
280
|
+
if (dir < 0 && scale <= MIN_ZOOM + 1e-9) return; // already at (or fitted below) the smallest zoom
|
|
281
|
+
const near = dir > 0 ? STEPS.find((s) => s > scale + 1e-6) : [...STEPS].reverse().find((s) => s < scale - 1e-6);
|
|
282
|
+
rescale(near ?? (dir > 0 ? MAX_ZOOM : MIN_ZOOM), true);
|
|
283
|
+
};
|
|
284
|
+
function goTo(n) {
|
|
285
|
+
if (!doc) return;
|
|
286
|
+
setCurrent(n, true);
|
|
287
|
+
const page = pages[current - 1];
|
|
288
|
+
if (page) stage.scrollTop = page.box.offsetTop - 12;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
prev.addEventListener('click', () => goTo(current - 1));
|
|
292
|
+
next.addEventListener('click', () => goTo(current + 1));
|
|
293
|
+
pageField.addEventListener('keydown', (event) => {
|
|
294
|
+
if (event.key !== 'Enter') return;
|
|
295
|
+
event.preventDefault();
|
|
296
|
+
const n = Number.parseInt(pageField.value, 10);
|
|
297
|
+
goTo(Number.isFinite(n) ? n : current); // out of range goes to the nearest page, never an error
|
|
298
|
+
});
|
|
299
|
+
pageField.addEventListener('blur', () => { pageField.value = String(current); });
|
|
300
|
+
zoomOut.addEventListener('click', () => step(-1));
|
|
301
|
+
zoomIn.addEventListener('click', () => step(1));
|
|
302
|
+
fit.addEventListener('click', () => { fitting = true; rescale(fitScale(), false); });
|
|
303
|
+
stage.addEventListener('wheel', (event) => {
|
|
304
|
+
if (!event.ctrlKey || !doc) return; // a plain wheel scrolls the document
|
|
305
|
+
event.preventDefault();
|
|
306
|
+
rescale(scale * (event.deltaY < 0 ? 1.1 : 1 / 1.1), true);
|
|
307
|
+
}, { passive: false });
|
|
308
|
+
stage.addEventListener('keydown', (event) => {
|
|
309
|
+
if (!doc || event.altKey || event.metaKey || (event.ctrlKey && !['+', '=', '-', '0'].includes(event.key))) return;
|
|
310
|
+
const keys = {
|
|
311
|
+
PageDown: () => goTo(current + 1), PageUp: () => goTo(current - 1),
|
|
312
|
+
Home: () => goTo(1), End: () => goTo(doc.numPages),
|
|
313
|
+
'+': () => step(1), '=': () => step(1), '-': () => step(-1),
|
|
314
|
+
'0': () => { fitting = true; rescale(fitScale(), false); },
|
|
315
|
+
};
|
|
316
|
+
const act = keys[event.key];
|
|
317
|
+
if (!act) return;
|
|
318
|
+
event.preventDefault();
|
|
319
|
+
act();
|
|
320
|
+
});
|
|
321
|
+
const resized = new ResizeObserver(() => { if (fitting && doc) rescale(fitScale(), false); });
|
|
322
|
+
|
|
323
|
+
let passwordForm = null;
|
|
324
|
+
function askPassword(answer, wrong) {
|
|
325
|
+
if (destroyed) return;
|
|
326
|
+
passwordForm?.remove();
|
|
327
|
+
status.textContent = wrong
|
|
328
|
+
? 'That password did not open this PDF. Try again, or download it.'
|
|
329
|
+
: 'This PDF is locked with a password. Type it to open the PDF here, or download it.';
|
|
330
|
+
passwordForm = el('form', 'pdf-view-password');
|
|
331
|
+
const field = el('input', 'pdf-view-password-field', { type: 'password', autocomplete: 'off' });
|
|
332
|
+
field.setAttribute('aria-label', `Password for ${name}`);
|
|
333
|
+
field.dataset.commandId = 'shell.pdf-view-password';
|
|
334
|
+
field.dataset.tip = 'The password of this PDF. FloLess uses it to open the PDF here and does not keep it';
|
|
335
|
+
const submit = el('button', 'pdf-view-btn', { type: 'submit', textContent: 'Open' });
|
|
336
|
+
submit.dataset.commandId = 'shell.pdf-view-password-open';
|
|
337
|
+
submit.dataset.tip = 'Open the PDF with this password';
|
|
338
|
+
passwordForm.append(field, submit);
|
|
339
|
+
passwordForm.addEventListener('submit', (event) => {
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
status.textContent = 'Opening the PDF…';
|
|
342
|
+
passwordForm.hidden = true;
|
|
343
|
+
answer(field.value);
|
|
344
|
+
});
|
|
345
|
+
status.after(passwordForm);
|
|
346
|
+
field.focus({ preventScroll: true });
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async function open() {
|
|
350
|
+
const lib = pdfLib = options.library || await loadLibrary();
|
|
351
|
+
if (destroyed) return;
|
|
352
|
+
// `data` is a copy: pdf.js hands its buffer to the worker, and Download keeps the original.
|
|
353
|
+
task = lib.getDocument({
|
|
354
|
+
data: bytes.slice(),
|
|
355
|
+
cMapUrl: `${VENDOR}cmaps/`, cMapPacked: true,
|
|
356
|
+
standardFontDataUrl: `${VENDOR}standard_fonts/`,
|
|
357
|
+
wasmUrl: `${VENDOR}wasm/`, iccUrl: `${VENDOR}iccs/`,
|
|
358
|
+
enableXfa: false,
|
|
359
|
+
stopAtErrors: false,
|
|
360
|
+
});
|
|
361
|
+
// A locked PDF asks for its password here, and asks again when it was wrong. The password goes to pdf.js only, for
|
|
362
|
+
// this viewer, and is never kept or sent anywhere.
|
|
363
|
+
task.onPassword = (answer, reason) => askPassword(answer, reason === lib.PasswordResponses.INCORRECT_PASSWORD);
|
|
364
|
+
doc = await task.promise;
|
|
365
|
+
if (destroyed) return; // destroy() has already ended the loading task, and the document with it
|
|
366
|
+
passwordForm?.remove();
|
|
367
|
+
if (!doc.numPages) { status.textContent = 'This PDF has no pages to show.'; root.dataset.state = 'empty'; return; }
|
|
368
|
+
status.remove();
|
|
369
|
+
const firstPage = await doc.getPage(1);
|
|
370
|
+
if (destroyed) return;
|
|
371
|
+
const one = firstPage.getViewport({ scale: 1 });
|
|
372
|
+
for (let n = 1; n <= doc.numPages; n += 1) {
|
|
373
|
+
const box = el('div', 'pdf-view-sheet');
|
|
374
|
+
box.dataset.page = String(n);
|
|
375
|
+
const canvas = el('canvas', 'pdf-view-canvas');
|
|
376
|
+
canvas.setAttribute('aria-hidden', 'true');
|
|
377
|
+
const text = el('div', 'textLayer pdf-view-text');
|
|
378
|
+
box.append(canvas, text);
|
|
379
|
+
stage.append(box);
|
|
380
|
+
pages.push({ number: n, box, canvas, text, base: n === 1 ? { w: one.width, h: one.height } : null, drawn: 0, render: null, layer: null, visible: false, busy: false, ticket: 0, failed: false, proxy: null });
|
|
381
|
+
}
|
|
382
|
+
total.textContent = `of ${doc.numPages}`;
|
|
383
|
+
root.dataset.state = 'ready';
|
|
384
|
+
showControls(true);
|
|
385
|
+
scale = fitScale();
|
|
386
|
+
for (const page of pages) sizeBox(page);
|
|
387
|
+
setLevel();
|
|
388
|
+
setCurrent(1, false);
|
|
389
|
+
watch();
|
|
390
|
+
resized.observe(stage);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const ready = open().catch((error) => {
|
|
394
|
+
if (destroyed) return;
|
|
395
|
+
root.dataset.state = 'failed';
|
|
396
|
+
showControls(false);
|
|
397
|
+
passwordForm?.remove();
|
|
398
|
+
status.textContent = failureWords(error);
|
|
399
|
+
status.setAttribute('role', 'alert');
|
|
400
|
+
if (!status.isConnected) stage.prepend(status);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
function destroy() {
|
|
404
|
+
if (destroyed) return;
|
|
405
|
+
destroyed = true;
|
|
406
|
+
observer?.disconnect();
|
|
407
|
+
resized.disconnect();
|
|
408
|
+
if (tracker) cancelAnimationFrame(tracker);
|
|
409
|
+
for (const page of pages) forget(page);
|
|
410
|
+
// pdf.js 6 releases a document through its loading task: that ends the worker and every page with it.
|
|
411
|
+
if (task) void task.destroy();
|
|
412
|
+
if (downloadUrl) URL.revokeObjectURL(downloadUrl);
|
|
413
|
+
downloadUrl = null;
|
|
414
|
+
root.remove();
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return { el: root, ready, destroy };
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
window.flolessPdfView = { mount };
|
|
421
|
+
})();
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
if (typeof bridge().api === 'function') return bridge().api(path);
|
|
12
12
|
return fetch(path).then(async (res) => {
|
|
13
13
|
const body = await res.json().catch(() => ({}));
|
|
14
|
-
|
|
14
|
+
// #3097: the server's own sentence when it wrote one, else the shared one (this only reads); never "HTTP <status>".
|
|
15
|
+
if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
|
|
15
16
|
return body;
|
|
16
17
|
});
|
|
17
18
|
};
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
if (typeof bridge().api === 'function') return bridge().api(path, init);
|
|
16
16
|
return fetch(path, { headers: { 'Content-Type': 'application/json' }, ...init }).then(async (res) => {
|
|
17
17
|
const body = await res.json().catch(() => ({}));
|
|
18
|
-
|
|
18
|
+
// #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
|
|
19
|
+
const readOnly = /^(GET|HEAD)$/.test(String(init?.method || 'GET').toUpperCase());
|
|
20
|
+
if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
|
|
19
21
|
return body;
|
|
20
22
|
});
|
|
21
23
|
};
|
package/dist/web/project-rfis.js
CHANGED
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
if (typeof bridge().api === 'function') return bridge().api(path, init);
|
|
20
20
|
return fetch(path, { headers: { 'Content-Type': 'application/json' }, ...init }).then(async (res) => {
|
|
21
21
|
const body = await res.json().catch(() => ({}));
|
|
22
|
-
|
|
22
|
+
// #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
|
|
23
|
+
const readOnly = /^(GET|HEAD)$/.test(String(init?.method || 'GET').toUpperCase());
|
|
24
|
+
if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text); err.status = res.status; err.body = body; throw err; }
|
|
23
25
|
return body;
|
|
24
26
|
});
|
|
25
27
|
};
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
if (typeof bridge().api === 'function') return bridge().api(path);
|
|
14
14
|
return fetch(path).then(async (res) => {
|
|
15
15
|
const body = await res.json().catch(() => ({}));
|
|
16
|
-
|
|
16
|
+
// #3097: the server's own sentence when it wrote one, else the shared one (this only reads); never "HTTP <status>".
|
|
17
|
+
if (!res.ok || body.ok === false) { const err = new Error(body.error || failureCopy({ status: res.status, body }, { retrySafe: true }).text); err.status = res.status; err.body = body; throw err; }
|
|
17
18
|
return body;
|
|
18
19
|
});
|
|
19
20
|
};
|
|
@@ -308,7 +309,8 @@
|
|
|
308
309
|
const post = (path, body) => fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
|
|
309
310
|
.then(async (res) => {
|
|
310
311
|
const answer = await res.json().catch(() => ({}));
|
|
311
|
-
|
|
312
|
+
// #3097: a POST, so the shared sentence never tells the person to retry blindly; never "HTTP <status>".
|
|
313
|
+
if (!res.ok || answer.ok === false) { const err = new Error(answer.error || failureCopy({ status: res.status, body: answer }, { retrySafe: false }).text); err.status = res.status; err.body = answer; throw err; }
|
|
312
314
|
return answer;
|
|
313
315
|
});
|
|
314
316
|
|
|
@@ -171,9 +171,13 @@ self.onmessage = async (event) => {
|
|
|
171
171
|
try {
|
|
172
172
|
const response = await fetch(message.url, { signal: controller.signal });
|
|
173
173
|
const contentType = (response.headers.get('content-type') || '').split(';')[0].trim().toLowerCase();
|
|
174
|
+
// #3097: a worker cannot load failure-copy.js, so it never writes the sentence a person reads. It posts FACTS —
|
|
175
|
+
// the status, the server's own JSON when there is some, or a `failure` kind — and the page says them in FloLess
|
|
176
|
+
// words (steel-editor.html referenceFailureReason). What a developer needs rides in `diagnostic`, for the console.
|
|
174
177
|
if (!response.ok || contentType !== TYPE) {
|
|
175
178
|
const data = await response.json().catch(() => ({
|
|
176
|
-
|
|
179
|
+
failure: 'unreadable',
|
|
180
|
+
diagnostic: response.ok
|
|
177
181
|
? `reference geometry had content type “${contentType || 'missing'}”, expected “${TYPE}”`
|
|
178
182
|
: `the server answered ${response.status} without a readable error`,
|
|
179
183
|
}));
|
|
@@ -186,9 +190,14 @@ self.onmessage = async (event) => {
|
|
|
186
190
|
self.postMessage({ id: message.id, ok: true, data: decoded }, transfer);
|
|
187
191
|
} catch (error) {
|
|
188
192
|
const corrupt = decoding || error?.referenceBinaryCorrupt === true;
|
|
193
|
+
// No answer at all (the fetch was refused or stopped) is a lost connection; bytes that arrived but could not be
|
|
194
|
+
// read whole (a cut-off body, an unknown layout) are an unreadable answer; complete bytes that fail their own
|
|
195
|
+
// checks are a corrupt cache, the one case the page rebuilds.
|
|
196
|
+
const lost = !corrupt && (error?.name === 'AbortError' || (error?.name === 'TypeError' && /fetch|network|load failed/i.test(String(error?.message))));
|
|
189
197
|
self.postMessage({ id: message.id, ok: false, status: corrupt ? 422 : 0, data: {
|
|
190
198
|
...(corrupt ? { code: 'reference-binary-corrupt' } : {}),
|
|
191
|
-
|
|
199
|
+
failure: corrupt ? 'corrupt' : lost ? 'connection' : 'unreadable',
|
|
200
|
+
diagnostic: error?.message || 'could not decode reference geometry',
|
|
192
201
|
} });
|
|
193
202
|
} finally { controllers.delete(message.id); }
|
|
194
203
|
};
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
<button id="inspectorToggle" class="model-inspector-toggle" type="button" data-command-id="revit.inspector-toggle" data-tip="Collapse Properties" aria-label="Collapse Properties" aria-controls="inspectorPanel" aria-expanded="true"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m6 3 5 5-5 5"/></svg></button>
|
|
66
66
|
</main>
|
|
67
67
|
<div id="toast" role="status" aria-live="polite"></div>
|
|
68
|
+
<script src="failure-copy.js"></script>
|
|
68
69
|
<script src="commands.js"></script>
|
|
69
70
|
<script src="commands-revit.js"></script>
|
|
70
71
|
<script src="instructor-reporter.js"></script>
|
package/dist/web/revit-editor.js
CHANGED
|
@@ -213,7 +213,14 @@ function fail(failure = null) {
|
|
|
213
213
|
state.replaceChildren(); const strong = document.createElement('strong'); strong.textContent = 'Model unavailable'; const copy = document.createElement('span'); copy.textContent = modelUnavailableCopy(); state.append(strong, copy);
|
|
214
214
|
}
|
|
215
215
|
// Any answer that is not ok rides on the error (`status`, `body`), so a failure can say what the server wrote for a person.
|
|
216
|
-
|
|
216
|
+
// #3097: the message is the server's own sentence when it wrote one, else the shared one (failure-copy.js); never "(<status>)".
|
|
217
|
+
function sharedFailureText(response, value, ctx, thrown) {
|
|
218
|
+
const copy = globalThis.failureCopy;
|
|
219
|
+
// `thrown`: a fetch that never got an answer (TypeError/AbortError) is passed through so it reads as a lost connection.
|
|
220
|
+
if (typeof copy === 'function') return copy(thrown && !thrown.status ? thrown : { status: response.status, body: value }, ctx).text;
|
|
221
|
+
return `Couldn’t ${ctx?.action || 'finish that'}. Reload this window, then try again.`;
|
|
222
|
+
}
|
|
223
|
+
async function json(url, options) { const response = await fetch(url, { credentials: 'same-origin', ...options }); const value = await response.json().catch(() => ({})); if (!response.ok || value.ok === false) throw Object.assign(new Error(value.message || value.error || sharedFailureText(response, value, { retrySafe: /^(GET|HEAD)$/.test(String(options?.method || 'GET').toUpperCase()) })), { status: response.status, body: value }); return value; }
|
|
217
224
|
|
|
218
225
|
function propertySection(heading, rows) {
|
|
219
226
|
return { id: heading.toLowerCase().replace(/\W+/g, '-'), heading, editable: false, render(host) {
|
|
@@ -1354,20 +1361,37 @@ function payloadOnly(state) {
|
|
|
1354
1361
|
return payload;
|
|
1355
1362
|
}
|
|
1356
1363
|
|
|
1364
|
+
// #3097: the editor-state route answers `{ error: <code>, message }`. The message is shown as written; a code that came
|
|
1365
|
+
// without one is said in words, and anything else gets the shared sentence. A bare code or a status is never shown.
|
|
1366
|
+
const EDITOR_STATE_CODE_WORDS = {
|
|
1367
|
+
'state-access-unconfirmed': 'FloLess couldn’t confirm your access to this model.',
|
|
1368
|
+
model_module_unavailable: 'This model is open for viewing only here, so its view settings aren’t saved.',
|
|
1369
|
+
'state-conflict': 'The view settings were changed in another window.',
|
|
1370
|
+
'state-binding-mismatch': 'The saved view settings belong to a different version of this model.',
|
|
1371
|
+
'state-pin-unavailable': 'This version of the model is no longer available.',
|
|
1372
|
+
};
|
|
1373
|
+
function editorStateFailureText(response, value, action, retrySafe) {
|
|
1374
|
+
if (typeof value?.message === 'string' && value.message.trim()) return value.message;
|
|
1375
|
+
console.warn('[model] editor state request failed', action, response?.status, value?.error);
|
|
1376
|
+
const words = EDITOR_STATE_CODE_WORDS[value?.error];
|
|
1377
|
+
if (words) return `Couldn’t ${action}. ${words}`;
|
|
1378
|
+
return sharedFailureText(response, value, retrySafe ? { action, retrySafe: true } : { action, unsure: 'Change the view again to save it once more.' });
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1357
1381
|
async function putEditorState({ binding, token, payload, etag }) {
|
|
1358
1382
|
const request = async (body, currentEtag) => fetch(editorStateUrl(binding), { method: 'PUT', credentials: 'same-origin',
|
|
1359
1383
|
headers: { 'content-type': 'application/json', ...(currentEtag ? { 'if-match': currentEtag } : { 'if-none-match': '*' }) }, body: JSON.stringify(body) });
|
|
1360
1384
|
let sentPayload = payload; let response = await request(sentPayload, etag);
|
|
1361
1385
|
if (response.status === 412) {
|
|
1362
1386
|
const fresh = await fetch(editorStateUrl(binding), { credentials: 'same-origin' });
|
|
1363
|
-
if (!fresh.ok) throw new Error(
|
|
1387
|
+
if (!fresh.ok) throw Object.assign(new Error(editorStateFailureText(fresh, await fresh.json().catch(() => ({})), 'save this model view')), { forPerson: true });
|
|
1364
1388
|
const freshValue = await fresh.json(); const freshPayload = payloadOnly(freshValue.state) || {};
|
|
1365
1389
|
sentPayload = { ...freshPayload, namedViews: payload.namedViews, coordinateFrames: payload.coordinateFrames, sections: payload.sections,
|
|
1366
1390
|
...(payload.gridVisibility ? { gridVisibility: payload.gridVisibility } : {}) };
|
|
1367
1391
|
response = await request(sentPayload, fresh.headers.get('etag') || freshValue.state?.etag || null);
|
|
1368
1392
|
}
|
|
1369
1393
|
const value = await response.json().catch(() => ({}));
|
|
1370
|
-
if (!response.ok || value.ok === false) throw Object.assign(new Error(
|
|
1394
|
+
if (!response.ok || value.ok === false) throw Object.assign(new Error(editorStateFailureText(response, value, 'save this model view')), { code: value.error, forPerson: true });
|
|
1371
1395
|
if (token !== editorStateBindingToken) return;
|
|
1372
1396
|
editorStateAccessWarned = null;
|
|
1373
1397
|
editorStateEtag = response.headers.get('etag') || value.state?.etag || editorStateEtag;
|
|
@@ -1394,10 +1418,15 @@ function drainEditorStateSaves() {
|
|
|
1394
1418
|
// change is kept in this browser (retainEditorStateRecovery) and retried on the next open, best-effort, so the copy
|
|
1395
1419
|
// promises nothing. `state-access-unconfirmed` is the server failing to confirm access for this save at all.
|
|
1396
1420
|
const editorStateAccessRefused = (error) => error?.code === 'model_module_unavailable' || error?.code === 'state-access-unconfirmed';
|
|
1397
|
-
function reportEditorStateSaveError(error,
|
|
1421
|
+
function reportEditorStateSaveError(error, action) {
|
|
1398
1422
|
const refused = editorStateAccessRefused(error);
|
|
1399
1423
|
if (refused) { if (editorStateAccessWarned === error.message) return; editorStateAccessWarned = error.message; }
|
|
1400
|
-
|
|
1424
|
+
// #3097: only a sentence written for the person (editorStateFailureText) is shown as is; a lost connection
|
|
1425
|
+
// ("Failed to fetch") or an unreadable answer gets the shared sentence, and the raw error goes to the console.
|
|
1426
|
+
if (!error?.forPerson) console.warn('[model] editor state save failed', error);
|
|
1427
|
+
const text = error?.forPerson ? error.message
|
|
1428
|
+
: sharedFailureText(error || {}, error?.body || {}, { action: action || 'save this model view', unsure: 'Change the view again to save it once more.' }, error);
|
|
1429
|
+
toast(text, refused ? 8000 : undefined);
|
|
1401
1430
|
}
|
|
1402
1431
|
|
|
1403
1432
|
async function flushEditorStateSave() {
|
|
@@ -1418,7 +1447,7 @@ function scheduleEditorStateSave(reason) {
|
|
|
1418
1447
|
editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration += 1;
|
|
1419
1448
|
retainEditorStateRecovery();
|
|
1420
1449
|
clearTimeout(editorStateSaveTimer);
|
|
1421
|
-
editorStateSaveTimer = setTimeout(() => { editorStateSaveTimer = null; drainEditorStateSaves().catch((error) => reportEditorStateSaveError(error, '
|
|
1450
|
+
editorStateSaveTimer = setTimeout(() => { editorStateSaveTimer = null; drainEditorStateSaves().catch((error) => reportEditorStateSaveError(error, 'save this model view')); }, 350);
|
|
1422
1451
|
}
|
|
1423
1452
|
|
|
1424
1453
|
async function prepareSpatialForRevision(state, handle) {
|
|
@@ -1437,7 +1466,7 @@ async function prepareSpatialForRevision(state, handle) {
|
|
|
1437
1466
|
// geometry so a stale/mismatched authority cannot replace the last good scene.
|
|
1438
1467
|
const url = editorStateUrl(binding);
|
|
1439
1468
|
const response = await fetch(url, { credentials: 'same-origin' }); let stored = null;
|
|
1440
|
-
if (!response.ok) { const value = await response.json().catch(() => ({})); throw new Error(
|
|
1469
|
+
if (!response.ok) { const value = await response.json().catch(() => ({})); throw new Error(editorStateFailureText(response, value, 'read this model’s saved view', true)); }
|
|
1441
1470
|
const value = await response.json(); stored = value.state;
|
|
1442
1471
|
const etag = response.headers.get('etag') || stored?.etag || null;
|
|
1443
1472
|
const recovered = readEditorStateRecovery(binding, etag);
|
|
@@ -1477,7 +1506,7 @@ function commitSpatialForRevision(candidate) {
|
|
|
1477
1506
|
spatialPanel = mountModelSpatialPanel({ tools: spatialTools, trigger: $('modelFrameStatus'), onBeforeOpen: () => { closeSpatialDialog(); toolbarChrome?.closeMenus(); selectionFilterChrome?.close(); lightingPanel?.close({ restoreFocus: false }); },
|
|
1478
1507
|
lengthDisplay: { format: (mm) => formatLength(mm, displayUnitControl.units()), parse: (text) => parseLengthMm(text, displayUnitControl.units()), unitLabel: () => displayUnitControl.units() },
|
|
1479
1508
|
onError: (error) => toast(error.message || 'That spatial action is unavailable.') });
|
|
1480
|
-
if (candidate.recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) => reportEditorStateSaveError(error, '
|
|
1509
|
+
if (candidate.recovered) { editorStateDirtyPayload = editorStatePayload(); editorStateDirtyGeneration = 1; retainEditorStateRecovery(); editorStateSaveTimer = setTimeout(() => drainEditorStateSaves().catch((error) => reportEditorStateSaveError(error, 'restore this model view')), 0); }
|
|
1481
1510
|
}
|
|
1482
1511
|
|
|
1483
1512
|
function positionDialog(panel, anchor) {
|