@floless/app 0.167.0 → 0.169.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/cli-actions.mjs +8 -1
- package/desktop-shell.mjs +335 -0
- package/dist/floless-server.cjs +73121 -55759
- 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-rfi/SKILL.md +4 -2
- 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/templates/college-phase-exporter.flo +7 -2
- package/dist/templates/trimble-list-projects.flo +10 -2
- package/dist/web/agent-steps.js +2 -2
- package/dist/web/agents.js +50 -14
- package/dist/web/app.css +209 -11
- package/dist/web/app.js +99 -16
- package/dist/web/aware-update-client.js +14 -6
- package/dist/web/aware.js +583 -69
- package/dist/web/chat.css +12 -1
- package/dist/web/chat.js +627 -96
- package/dist/web/commands-drawing-check.js +3 -0
- package/dist/web/commands-filter.js +5 -5
- package/dist/web/commands-shell.js +283 -14
- package/dist/web/commands-steel.js +9 -2
- package/dist/web/commands-vector.js +69 -0
- package/dist/web/desktop-window.js +435 -0
- package/dist/web/drawing-check-editor.html +10 -0
- package/dist/web/drawing-check-editor.js +515 -187
- package/dist/web/failure-copy.js +33 -2
- package/dist/web/flo-3d.js +310 -0
- package/dist/web/flo-card.js +72 -0
- package/dist/web/guide.js +78 -10
- package/dist/web/index.html +90 -10
- package/dist/web/instructor.js +4 -1
- package/dist/web/leave-guard.js +347 -14
- package/dist/web/model-editor-steel-adapter.js +41 -1
- package/dist/web/model-viewport-toolbar.js +11 -0
- package/dist/web/pages.js +21 -14
- package/dist/web/panels.js +5 -2
- package/dist/web/pdf-view.js +421 -0
- package/dist/web/project-history.js +3 -2
- package/dist/web/project-modules.js +5 -3
- package/dist/web/project-reconciliation.js +1 -1
- package/dist/web/project-rfis.js +4 -2
- package/dist/web/project-workflows.js +8 -4
- package/dist/web/reference-geometry-worker.js +11 -2
- package/dist/web/renderers.js +6 -0
- package/dist/web/report-csp.js +68 -0
- package/dist/web/revit-editor.html +1 -0
- package/dist/web/revit-editor.js +37 -8
- package/dist/web/run-history.js +2 -3
- package/dist/web/shared-prefs.js +364 -0
- package/dist/web/steel-3d-flo.js +309 -0
- package/dist/web/steel-3d-view.js +159 -0
- package/dist/web/steel-editor.html +329 -47
- 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/terminal-requests.js +78 -0
- package/dist/web/tool-updates.js +160 -38
- package/dist/web/vector-3d.html +14 -3
- package/dist/web/vector-editor.html +60 -10
- 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/workspace-root-management.js +1 -1
- package/dist/web/workspaces.js +792 -165
- package/home-env.mjs +28 -0
- package/install-path.mjs +59 -3
- package/launch-starting-page.mjs +35 -15
- package/launch.mjs +363 -51
- package/package.json +9 -8
- 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
package/autostart.mjs
CHANGED
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
import { execFileSync } from 'node:child_process';
|
|
44
44
|
import { writeFileSync, rmSync, appendFileSync, mkdirSync } from 'node:fs';
|
|
45
45
|
import { tmpdir } from 'node:os';
|
|
46
|
-
import { join } from 'node:path';
|
|
46
|
+
import { dirname, join } from 'node:path';
|
|
47
47
|
import { RUN_KEY, RUN_VALUE } from './teardown.mjs';
|
|
48
|
+
import { homeHasPriorUse, preferencesPath, readAutostartIntent, readAutostartStored, setAutostartIntent, withLock } from './preferences-file.mjs';
|
|
48
49
|
import { logDir, logFilePath } from './log.mjs';
|
|
49
50
|
import { distributionProfile } from './distribution-profile-active.mjs';
|
|
50
51
|
|
|
51
52
|
// Stable per-user task name (root of the user's Task Scheduler namespace: \FloLess).
|
|
52
53
|
export const TASK_NAME = distributionProfile.identity.scheduledTaskName;
|
|
53
54
|
|
|
54
|
-
const isWin = process.platform === 'win32';
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Is autostart a meaningful, writable setting in THIS channel? True only for the
|
|
@@ -178,78 +178,184 @@ function logLine(msg) {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
/** One schtasks.exe call. Never throws: { ok, stdout }. */
|
|
182
|
+
function runSchtasks(args) {
|
|
183
|
+
try {
|
|
184
|
+
const stdout = execFileSync('schtasks', args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true });
|
|
185
|
+
return { ok: true, stdout: String(stdout ?? '') };
|
|
186
|
+
} catch (error) {
|
|
187
|
+
return { ok: false, stdout: String(error?.stdout ?? '') };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const bareName = (name) => String(name).replace(/^\\+/, '').toLowerCase();
|
|
192
|
+
|
|
181
193
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* Windows-only; no-op elsewhere. Also removes the legacy Run-key value (migration).
|
|
185
|
-
*
|
|
186
|
-
* Creates the task with `schtasks.exe /Create /XML` reading a UTF-16LE temp file
|
|
187
|
-
* directly — NOT PowerShell's `Register-ScheduledTask -Xml`. schtasks is a plain
|
|
188
|
-
* Win32 exe (no ScheduledTasks PS module / execution-policy / constrained-language
|
|
189
|
-
* dependency — important on locked-down corporate machines), it reads the UTF-16LE
|
|
190
|
-
* file directly — avoiding PowerShell's `-Xml` STRING round-trip that could silently
|
|
191
|
-
* corrupt the task definition — and makes register/query/delete all one tool.
|
|
192
|
-
* (schtasks REQUIRES the UTF-16 BOM: a BOM-less file is rejected as "the task XML is
|
|
193
|
-
* malformed" — verified 2026-05-30.) Also verified: schtasks /Create of the user's
|
|
194
|
-
* own InteractiveToken logon task succeeds UNELEVATED (SUCCESS, on-demand 0x0).
|
|
195
|
-
*
|
|
196
|
-
* Throws on a schtasks failure (after logging a breadcrumb) so the best-effort
|
|
197
|
-
* callers (the Velopack install hook, ensureAutostart) decide — they swallow it,
|
|
198
|
-
* but the failure is no longer invisible.
|
|
194
|
+
* Is `taskName` in a `schtasks /query /fo CSV /nh` listing? 'present' / 'absent', or 'unknown' when the text holds no task
|
|
195
|
+
* row at all (a listing that lists nothing proves nothing). Pure + exported for the unit test.
|
|
199
196
|
*/
|
|
200
|
-
export function
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
export function taskStateFromListing(csv, taskName) {
|
|
198
|
+
const names = [...String(csv ?? '').matchAll(/^"([^"\r\n]*)"/gm)].map((m) => bareName(m[1]));
|
|
199
|
+
if (names.length === 0) return 'unknown';
|
|
200
|
+
return names.includes(bareName(taskName)) ? 'present' : 'absent';
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Write the task XML to a UTF-16LE temp file (schtasks needs the BOM); returns its path. */
|
|
204
|
+
function writeTaskXml(xml) {
|
|
203
205
|
// pid + timestamp so two registrations in one process can't clobber each other's temp.
|
|
204
206
|
const tmp = join(tmpdir(), `floless-autostart-${process.pid}-${Date.now()}.xml`);
|
|
205
|
-
// BOM is REQUIRED: schtasks /Create rejects a BOM-less file as "the task XML is
|
|
206
|
-
//
|
|
207
|
+
// BOM is REQUIRED: schtasks /Create rejects a BOM-less file as "the task XML is malformed" (it needs the U+FEFF marker
|
|
208
|
+
// to detect UTF-16). Verified 2026-05-30.
|
|
207
209
|
writeFileSync(tmp, '' + xml, { encoding: 'utf16le' });
|
|
208
|
-
|
|
209
|
-
execFileSync('schtasks', ['/Create', '/TN', TASK_NAME, '/XML', tmp, '/F'], {
|
|
210
|
-
stdio: ['ignore', 'ignore', 'ignore'],
|
|
211
|
-
windowsHide: true,
|
|
212
|
-
});
|
|
213
|
-
} catch (err) {
|
|
214
|
-
logLine(`autostart: schtasks /Create failed: ${err && err.message ? err.message : err}`);
|
|
215
|
-
throw err;
|
|
216
|
-
} finally {
|
|
217
|
-
try { rmSync(tmp, { force: true }); } catch { /* temp cleanup best-effort */ }
|
|
218
|
-
}
|
|
219
|
-
removeLegacyRunKey();
|
|
210
|
+
return tmp;
|
|
220
211
|
}
|
|
221
212
|
|
|
222
|
-
/**
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
213
|
+
/**
|
|
214
|
+
* The autostart controller (#3070). Everything that touches the sign-in task goes through one of these, so the person's
|
|
215
|
+
* explicit choice, the task itself and the check of the result are one decision, taken under one lock, and so a test can
|
|
216
|
+
* drive it with a fake `run` (or, for a real proof, a throwaway task name) without ever touching the person's own task.
|
|
217
|
+
*
|
|
218
|
+
* state() 'present' | 'absent' | 'unknown'. Absence is believed only from a listing that was read successfully and
|
|
219
|
+
* lacks the task; a failed query is 'unknown', never "removed".
|
|
220
|
+
* register(exe) create/refresh the task, then check it is there. Throws when Windows did not confirm it.
|
|
221
|
+
* unregister() delete the task (and the old Run-key value), then check it is gone. Throws when it is not.
|
|
222
|
+
* reconcile(exe) what the launcher open and the install/update hooks do: follow the stored choice. 'off' keeps the task
|
|
223
|
+
* away, 'on' (never chosen, or on) puts it back when it is missing, 'unknown' (an unreadable or newer
|
|
224
|
+
* preferences file) changes nothing. Never throws.
|
|
225
|
+
* set(enabled,exe) what the setting does: store the choice FIRST, then change the task and check the result.
|
|
226
|
+
* Returns { saved, enabled, state, ok, busy }; never throws.
|
|
227
|
+
*/
|
|
228
|
+
export function createAutostartController({
|
|
229
|
+
platform = process.platform, taskName = TASK_NAME, run = runSchtasks, writeXml = writeTaskXml,
|
|
230
|
+
userId = currentUserId, removeLegacy = removeLegacyRunKey, log = logLine,
|
|
231
|
+
intent = () => readAutostartIntent(), stored = () => readAutostartStored(), prior = () => homeHasPriorUse(), store = (enabled) => setAutostartIntent(enabled),
|
|
232
|
+
lockPath = () => join(dirname(preferencesPath()), 'autostart'), lockWaitMs = 3000,
|
|
233
|
+
} = {}) {
|
|
234
|
+
const win = platform === 'win32';
|
|
235
|
+
|
|
236
|
+
function state() {
|
|
237
|
+
if (!win) return 'unknown';
|
|
238
|
+
if (run(['/query', '/tn', taskName]).ok) return 'present';
|
|
239
|
+
const listing = run(['/query', '/fo', 'CSV', '/nh']);
|
|
240
|
+
return listing.ok ? taskStateFromListing(listing.stdout, taskName) : 'unknown';
|
|
230
241
|
}
|
|
242
|
+
|
|
243
|
+
function register(exePath) {
|
|
244
|
+
if (!win) return;
|
|
245
|
+
let tmp = null;
|
|
246
|
+
try {
|
|
247
|
+
tmp = writeXml(buildAutostartTaskXml(exePath, userId()));
|
|
248
|
+
if (!run(['/Create', '/TN', taskName, '/XML', tmp, '/F']).ok) {
|
|
249
|
+
log('autostart: schtasks /Create failed');
|
|
250
|
+
throw new Error('Windows would not create the sign-in task.');
|
|
251
|
+
}
|
|
252
|
+
} finally {
|
|
253
|
+
if (tmp) { try { rmSync(tmp, { force: true }); } catch { /* temp cleanup best-effort */ } }
|
|
254
|
+
}
|
|
255
|
+
removeLegacy();
|
|
256
|
+
if (state() !== 'present') {
|
|
257
|
+
log('autostart: the task was created but Windows does not list it');
|
|
258
|
+
throw new Error('Windows did not confirm the sign-in task.');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function unregister() {
|
|
263
|
+
if (!win) return;
|
|
264
|
+
run(['/delete', '/tn', taskName, '/f']); // its result is not trusted: the state below decides
|
|
265
|
+
removeLegacy();
|
|
266
|
+
const after = state();
|
|
267
|
+
if (after === 'absent') return;
|
|
268
|
+
log(`autostart: the task could not be removed (${after})`);
|
|
269
|
+
throw new Error(after === 'present' ? 'Windows kept the sign-in task.' : 'Windows did not confirm the sign-in task was removed.');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const locked = (fn) => withLock(lockPath(), fn, { waitMs: lockWaitMs });
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* context 'install' / 'update' are the Velopack hooks; 'open' is every launcher open. An install that was in use BEFORE this
|
|
276
|
+
* build (an update, or a reinstall over kept data) and has no stored choice is settled once: if the sign-in task is already
|
|
277
|
+
* gone, the person turned it off earlier, so that is stored as Off instead of quietly turning it back on (#3070). A brand new
|
|
278
|
+
* install keeps the default On, which is written down so it cannot later read as unchosen.
|
|
279
|
+
*/
|
|
280
|
+
function reconcile(exePath, context = 'open') {
|
|
281
|
+
if (!win) return { action: 'none' };
|
|
282
|
+
try {
|
|
283
|
+
return locked(() => {
|
|
284
|
+
if ((context === 'install' || context === 'update') && stored() === 'unset') {
|
|
285
|
+
const existing = context === 'update' || prior();
|
|
286
|
+
if (existing) {
|
|
287
|
+
if (state() === 'absent') { try { store(false); } catch { /* unreadable: leave it */ } return { action: 'none', intent: 'off', settled: 'existing-off' }; }
|
|
288
|
+
} else { try { store(true); } catch { /* the default is On anyway */ } }
|
|
289
|
+
}
|
|
290
|
+
const choice = intent();
|
|
291
|
+
if (choice === 'unknown') return { action: 'none', intent: choice };
|
|
292
|
+
const now = state();
|
|
293
|
+
if (choice === 'off') {
|
|
294
|
+
if (now !== 'present') return { action: 'none', intent: choice };
|
|
295
|
+
try { unregister(); return { action: 'removed', intent: choice }; } catch { return { action: 'failed', intent: choice }; }
|
|
296
|
+
}
|
|
297
|
+
if (now === 'present') return { action: 'none', intent: choice };
|
|
298
|
+
try { register(exePath); return { action: 'registered', intent: choice }; } catch { return { action: 'failed', intent: choice }; }
|
|
299
|
+
});
|
|
300
|
+
} catch (error) {
|
|
301
|
+
log(`autostart: not reconciled (${error?.message ?? error})`);
|
|
302
|
+
return { action: 'skipped' };
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function set(enabled, exePath) {
|
|
307
|
+
if (!win) return { saved: false, enabled: false, state: 'unknown', ok: false, busy: false };
|
|
308
|
+
try {
|
|
309
|
+
return locked(() => {
|
|
310
|
+
let saved = true;
|
|
311
|
+
try { store(enabled); } catch (error) { saved = false; log(`autostart: the choice could not be stored (${error?.message ?? error})`); }
|
|
312
|
+
try { if (enabled) register(exePath); else unregister(); } catch { /* the state below says what is true */ }
|
|
313
|
+
const now = state();
|
|
314
|
+
return { saved, enabled: now === 'present', state: now, ok: saved && (enabled ? now === 'present' : now === 'absent'), busy: false };
|
|
315
|
+
});
|
|
316
|
+
} catch (error) {
|
|
317
|
+
log(`autostart: not changed (${error?.message ?? error})`);
|
|
318
|
+
const now = state();
|
|
319
|
+
return { saved: false, enabled: now === 'present', state: now, ok: false, busy: true };
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return { state, register, unregister, reconcile, set };
|
|
231
324
|
}
|
|
232
325
|
|
|
326
|
+
const controller = createAutostartController();
|
|
327
|
+
|
|
328
|
+
/** Register (or refresh) the task to run `"<exe>" --supervise`, then check it is there. Throws when it is not. Win-only. */
|
|
329
|
+
export const registerAutostart = (exePath) => controller.register(exePath);
|
|
330
|
+
|
|
331
|
+
/** True iff Windows lists the autostart task. */
|
|
332
|
+
export const autostartPresent = () => controller.state() === 'present';
|
|
333
|
+
|
|
334
|
+
/** 'present' | 'absent' | 'unknown' (a failed query is never read as absent). */
|
|
335
|
+
export const autostartState = () => controller.state();
|
|
336
|
+
|
|
233
337
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* container, where task registration is reliable), so the task is guaranteed present
|
|
237
|
-
* after the user opens the app even once, regardless of whether the in-container
|
|
238
|
-
* install hook could register it. Best-effort; never throws. Win-only.
|
|
338
|
+
* Follow the person's stored choice (#3070): called on every packaged open and by the install/update hooks. Puts a
|
|
339
|
+
* missing task back, unless they turned Start with Windows off. Never throws. Win-only.
|
|
239
340
|
*/
|
|
240
|
-
export
|
|
241
|
-
|
|
242
|
-
if (autostartPresent()) return;
|
|
243
|
-
try { registerAutostart(exePath); } catch { /* failure already logged in registerAutostart */ }
|
|
244
|
-
}
|
|
341
|
+
export const reconcileAutostart = (exePath, context) => controller.reconcile(exePath, context);
|
|
342
|
+
export const ensureAutostart = reconcileAutostart;
|
|
245
343
|
|
|
246
|
-
/**
|
|
247
|
-
export
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
344
|
+
/** The Start with Windows setting: store the choice, change the task, check the result. */
|
|
345
|
+
export const setAutostart = (enabled, exePath) => controller.set(enabled, exePath);
|
|
346
|
+
|
|
347
|
+
/** Remove the autostart task AND any legacy Run-key value, then check it is gone. Throws when it is not. Win-only. */
|
|
348
|
+
export const unregisterAutostart = () => controller.unregister();
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* What PUT /api/autostart answers for a finished change (#3070), in plain words. enabled is what Windows really has, or null when
|
|
352
|
+
* Windows could not be asked (never a guess that reads as a confirmed Off); saved marks the words as this route's own.
|
|
353
|
+
*/
|
|
354
|
+
export function autostartAnswer(want, result) {
|
|
355
|
+
if (result.ok) return { status: 200, body: { ok: true, supported: true, enabled: result.enabled } };
|
|
356
|
+
const error = result.busy ? 'Another change to Start with Windows is still in progress. Try again in a moment.'
|
|
357
|
+
: !result.saved ? 'FloLess could not remember this choice, so Windows may switch it back. Try again.'
|
|
358
|
+
: want ? 'Windows did not turn Start with Windows on. Try again.'
|
|
359
|
+
: 'FloLess saved your choice, but Windows did not confirm that Start with Windows is off. FloLess will try again the next time it opens.';
|
|
360
|
+
return { status: 500, body: { ok: false, supported: true, enabled: result.state === 'unknown' ? null : result.enabled, state: result.state, saved: result.saved, error } };
|
|
255
361
|
}
|
package/cli-actions.mjs
CHANGED
|
@@ -119,6 +119,13 @@ export function envelope(ok, data, error, meta) {
|
|
|
119
119
|
|
|
120
120
|
const SIGN_IN = 'FloLess needs you to sign in before it can do this. Run "floless-app login", then try again.';
|
|
121
121
|
const SEAT_TAKEN = 'Your FloLess subscription is in use on another computer. Open FloLess there to sign out, or run "floless-app login" here to take it over.';
|
|
122
|
+
// #3134: the subscription gate's reasons that signing in would not fix.
|
|
123
|
+
const GATE_COPY = {
|
|
124
|
+
'seat-taken': SEAT_TAKEN,
|
|
125
|
+
'account-selection-required': 'Your sign-in belongs to more than one FloLess account. Open FloLess and choose the account to use, then try again.',
|
|
126
|
+
'core-unavailable': 'FloLess couldn’t reach floless.io to confirm your subscription. Check your internet connection, then try again.',
|
|
127
|
+
'update-required': 'floless.io no longer accepts this version of FloLess. Install the latest FloLess, then try again.',
|
|
128
|
+
};
|
|
122
129
|
|
|
123
130
|
/** The proposal states after which nothing more will happen. */
|
|
124
131
|
const FINAL = new Set(['done', 'failed', 'cancelled', 'unknown', 'declined', 'expired']);
|
|
@@ -175,7 +182,7 @@ export async function runActionsCli(argv, deps) {
|
|
|
175
182
|
}
|
|
176
183
|
if (res.status === 402) {
|
|
177
184
|
const reason = res.body && typeof res.body === 'object' ? res.body.reason : undefined;
|
|
178
|
-
return { failed: fail('subscription-required', reason === '
|
|
185
|
+
return { failed: fail('subscription-required', (typeof reason === 'string' && Object.hasOwn(GATE_COPY, reason) ? GATE_COPY[reason] : SIGN_IN), { reason: reason ?? null }) };
|
|
179
186
|
}
|
|
180
187
|
return { res };
|
|
181
188
|
};
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
// The launcher's side of the desktop window (Electron shell): where the shell lives, how it is started and
|
|
2
|
+
// how it is asked to close. Dependency-free (Node built-ins only), like launch.mjs, which uses it.
|
|
3
|
+
//
|
|
4
|
+
// The shell is only a window client: the server keeps running without it. Everything here talks to it through
|
|
5
|
+
// small JSON files in ONE stable directory (<~/.floless>/shell), never a pipe or a port:
|
|
6
|
+
//
|
|
7
|
+
// ready-<nonce>.json the shell, once a window is showing: pid=<pid> nonce=<nonce> (launcher -> reads; one per launch)
|
|
8
|
+
// close-request.json the launcher asks the shell to close (runs the leave guard) (launcher -> writes)
|
|
9
|
+
// closing.json the shell: "the guard has started" - the acknowledgement (shell -> writes)
|
|
10
|
+
// closed.json the shell: how it ended (closed | cancelled) (shell -> writes)
|
|
11
|
+
// inventory.json the shell keeps this current: the app pages its windows show (shell -> writes)
|
|
12
|
+
// restore.json what to reopen after an update; claimed by an atomic rename (launcher)
|
|
13
|
+
// updating.json an update is being applied: new windows wait in the restore list (launcher)
|
|
14
|
+
//
|
|
15
|
+
// Every write is atomic (temp file + rename) and every request carries a random nonce, so a stale file is never
|
|
16
|
+
// taken for the current answer. A nonce does not authenticate another program of the same person (same trust
|
|
17
|
+
// model as the browser tab); it only stops old answers being accepted.
|
|
18
|
+
import { spawn } from 'node:child_process';
|
|
19
|
+
import { randomBytes } from 'node:crypto';
|
|
20
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import { homedir } from 'node:os';
|
|
22
|
+
import { dirname, join } from 'node:path';
|
|
23
|
+
|
|
24
|
+
const sleepMs = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
25
|
+
|
|
26
|
+
export const ACK_MS = 5000; // how long the shell has to say "the guard started" before it counts as not responding
|
|
27
|
+
export const PERSON_MS = 10 * 60_000; // how long a person may keep a leave guard open before the update is paused
|
|
28
|
+
export const READY_MS = 20_000; // how long a launch waits before it says the window is slow (it keeps waiting while the shell lives)
|
|
29
|
+
export const HARD_READY_MS = 180_000; // the ceiling: a shell that is alive but has shown nothing for this long is ended
|
|
30
|
+
export const EXIT_GRACE_MS = 3000; // after the process we started exits, how long its hand-off may still be acknowledged
|
|
31
|
+
export const UPDATING_TTL_MS = 10 * 60_000;
|
|
32
|
+
export const STALE_RESTORE_MS = 3 * 60_000;
|
|
33
|
+
|
|
34
|
+
export const shellDir = () => {
|
|
35
|
+
const override = (process.env.FLOLESS_SHELL_DIR ?? '').trim();
|
|
36
|
+
if (override) return override;
|
|
37
|
+
return join(process.env.FLOLESS_HOME ?? join(homedir(), '.floless'), 'shell');
|
|
38
|
+
};
|
|
39
|
+
const file = (name) => join(shellDir(), name);
|
|
40
|
+
|
|
41
|
+
/** Where the shell executable is. The installed layout is current\desktop\FloLess.exe beside FlolessApp.exe. */
|
|
42
|
+
export function shellExe() {
|
|
43
|
+
const override = (process.env.FLOLESS_SHELL_EXE ?? '').trim();
|
|
44
|
+
if (override) return override;
|
|
45
|
+
return join(dirname(process.execPath), 'desktop', 'FloLess.exe');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let infoCache = { at: 0, value: null };
|
|
49
|
+
/** { installed, version } from disk, cached for a few seconds (the health poll runs every 5 s). */
|
|
50
|
+
export function shellInfo({ now = Date.now() } = {}) {
|
|
51
|
+
if (infoCache.value && now - infoCache.at < 5000) return infoCache.value;
|
|
52
|
+
const exe = shellExe();
|
|
53
|
+
let value = { installed: false, version: null };
|
|
54
|
+
try {
|
|
55
|
+
if (existsSync(exe)) {
|
|
56
|
+
let version = null;
|
|
57
|
+
try {
|
|
58
|
+
const meta = JSON.parse(readFileSync(join(dirname(exe), 'floless-shell.json'), 'utf8'));
|
|
59
|
+
if (typeof meta?.shellVersion === 'string' && /^[0-9A-Za-z.+-]{1,40}$/.test(meta.shellVersion)) version = meta.shellVersion;
|
|
60
|
+
} catch { /* a shell without its version file is still a shell */ }
|
|
61
|
+
value = { installed: true, version };
|
|
62
|
+
}
|
|
63
|
+
} catch { /* unreadable disk: not installed, never a failure */ }
|
|
64
|
+
infoCache = { at: now, value };
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
export const resetShellInfoCache = () => { infoCache = { at: 0, value: null }; };
|
|
68
|
+
|
|
69
|
+
export const newNonce = () => randomBytes(8).toString('hex');
|
|
70
|
+
|
|
71
|
+
export function writeAtomic(path, value) {
|
|
72
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
73
|
+
const tmp = `${path}.${process.pid}.${randomBytes(3).toString('hex')}.tmp`;
|
|
74
|
+
writeFileSync(tmp, typeof value === 'string' ? value : JSON.stringify(value));
|
|
75
|
+
renameSync(tmp, path);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function readJson(path) {
|
|
79
|
+
try { return JSON.parse(readFileSync(path, 'utf8')); } catch { return null; }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const APP_PATH = /^\/[A-Za-z0-9._~!$&'()*+,;=:@%/?#-]{0,2047}$/;
|
|
83
|
+
/** An app-relative path the shell may open: one leading slash, no scheme, host or backslash. Mirrors the shell's own check. */
|
|
84
|
+
export const isAppPath = (p) => typeof p === 'string' && APP_PATH.test(p) && !p.startsWith('//') && !p.includes('\\')
|
|
85
|
+
&& !p.startsWith('/api/');
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A window in a restore list: an app path (the main window, or any window in the older shape) or { path, role: 'child' }.
|
|
89
|
+
* The role keeps a child that was open beside a hidden main window a child, so a restore never promotes it (#3073).
|
|
90
|
+
*/
|
|
91
|
+
export const entryPath = (e) => (typeof e === 'string' ? e : e?.path);
|
|
92
|
+
export const isRestoreEntry = (e) => isAppPath(entryPath(e)) && (typeof e === 'string' || e.role === 'child' || e.role === 'main');
|
|
93
|
+
const normEntry = (e) => (typeof e === 'string' ? e : { path: e.path, role: e.role });
|
|
94
|
+
|
|
95
|
+
// ── launching ────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Start the shell showing `windows` (app paths; the first is the main window) and wait for the window-ready
|
|
99
|
+
* acknowledgement. 'shown' | 'no-ack' | 'spawn-failed'. The caller opens the tab only on the last two, so a launch is
|
|
100
|
+
* never left with nothing on screen - and never with a window AND a tab: a SLOW start is not a failed one. While the
|
|
101
|
+
* process we started is alive the launch keeps waiting (the shell already shows its own starting screen); it is
|
|
102
|
+
* 'no-ack' only when that process has exited without an acknowledgement, or, at the hard ceiling, after the shell we
|
|
103
|
+
* started has been ended so the two never coexist.
|
|
104
|
+
*/
|
|
105
|
+
export async function launchShell({ windows = ['/'], starting = false, updating = false, server, waitMs = READY_MS,
|
|
106
|
+
hardMs = HARD_READY_MS, killShell = () => {},
|
|
107
|
+
// verify-windows-hide: allow — the FloLess window is the thing the person asked to see
|
|
108
|
+
spawnShell = (exe, args) => spawn(exe, args, { detached: true, stdio: 'ignore', windowsHide: false }),
|
|
109
|
+
nonce = newNonce(), now = Date.now, sleep = sleepMs, say = () => {} } = {}) {
|
|
110
|
+
const exe = shellExe();
|
|
111
|
+
// One acknowledgement file per launch, named by its nonce: overlapping launches never read or overwrite each other's.
|
|
112
|
+
const ready = file(`ready-${nonce}.json`);
|
|
113
|
+
const paths = windows.filter(isRestoreEntry).map(normEntry);
|
|
114
|
+
sweepStaleAcks({ now });
|
|
115
|
+
try { rmSync(ready, { force: true }); } catch { /* best effort */ }
|
|
116
|
+
const args = [`--server=${server}`, `--ready-file=${ready}`, `--nonce=${nonce}`, `--control-dir=${shellDir()}`];
|
|
117
|
+
if (paths.length > 1 || (paths.length === 1 && (typeof paths[0] !== 'string' || paths[0] !== '/'))) {
|
|
118
|
+
const open = file(`open-${nonce}.json`);
|
|
119
|
+
writeAtomic(open, paths);
|
|
120
|
+
args.push(`--restore-file=${open}`);
|
|
121
|
+
}
|
|
122
|
+
args.push(updating ? '--server-updating' : starting ? '--server-starting' : '--server-ready');
|
|
123
|
+
let child;
|
|
124
|
+
let exitedAt = null;
|
|
125
|
+
try {
|
|
126
|
+
child = spawnShell(exe, args);
|
|
127
|
+
child?.unref?.();
|
|
128
|
+
child?.once?.('error', () => { exitedAt ??= now(); });
|
|
129
|
+
child?.once?.('exit', () => { exitedAt ??= now(); });
|
|
130
|
+
} catch (error) {
|
|
131
|
+
say(`could not start the FloLess window (${error?.code ?? error?.message ?? 'unknown error'})`);
|
|
132
|
+
return 'spawn-failed';
|
|
133
|
+
}
|
|
134
|
+
const started = now();
|
|
135
|
+
let saidSlow = false;
|
|
136
|
+
try {
|
|
137
|
+
for (;;) {
|
|
138
|
+
try { if (readFileSync(ready, 'utf8').includes(`nonce=${nonce}`)) return 'shown'; } catch { /* not yet */ }
|
|
139
|
+
// The process we started is gone and has not acknowledged (a second launch hands over to the running window and
|
|
140
|
+
// exits, so give its acknowledgement a moment): the shell really failed.
|
|
141
|
+
if (exitedAt !== null && now() - exitedAt >= EXIT_GRACE_MS) {
|
|
142
|
+
say('the FloLess window closed before it was showing');
|
|
143
|
+
return 'no-ack';
|
|
144
|
+
}
|
|
145
|
+
const waited = now() - started;
|
|
146
|
+
if (waited >= hardMs) {
|
|
147
|
+
say('the FloLess window has not shown anything for a long time - closing it so FloLess opens in the browser instead');
|
|
148
|
+
try { killShell(); } catch { /* best effort */ }
|
|
149
|
+
return 'no-ack';
|
|
150
|
+
}
|
|
151
|
+
if (!saidSlow && waited >= waitMs) { saidSlow = true; say('the FloLess window is slow to open - still waiting for it'); }
|
|
152
|
+
await sleep(200);
|
|
153
|
+
}
|
|
154
|
+
} finally {
|
|
155
|
+
try { rmSync(ready, { force: true }); } catch { /* best effort */ }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const STALE_ACK_MS = 24 * 60 * 60_000;
|
|
160
|
+
/** Acknowledgement files a launch never cleaned up (a killed launcher) are removed once they are a day old. */
|
|
161
|
+
export function sweepStaleAcks({ now = Date.now, dir = shellDir() } = {}) {
|
|
162
|
+
try {
|
|
163
|
+
for (const name of readdirSync(dir)) {
|
|
164
|
+
if (!/^ready-[0-9a-zA-Z]+\.json$/.test(name)) continue;
|
|
165
|
+
const path = join(dir, name);
|
|
166
|
+
try { if (now() - statSync(path).mtimeMs > STALE_ACK_MS) rmSync(path, { force: true }); } catch { /* raced */ }
|
|
167
|
+
}
|
|
168
|
+
} catch { /* no folder yet */ }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ── closing ──────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
172
|
+
|
|
173
|
+
export function readInventory() {
|
|
174
|
+
const inv = readJson(file('inventory.json'));
|
|
175
|
+
return Array.isArray(inv?.windows) ? inv.windows.filter(isRestoreEntry).map(normEntry) : [];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Ask a running shell to close: it runs its leave guard (the person's choices), acknowledges that it started, then
|
|
180
|
+
* closes or is cancelled. 'closed' | 'cancelled' | 'no-ack' | 'no-shell'.
|
|
181
|
+
* - No acknowledgement within ackMs means the page is hung: the caller may end the process.
|
|
182
|
+
* - After the acknowledgement the PERSON sets the pace; only personMs (a generous cap) ends the wait, as 'cancelled'
|
|
183
|
+
* (the update is paused, never forced over an open guard).
|
|
184
|
+
*/
|
|
185
|
+
export async function closeShellGracefully({ running, ackMs = ACK_MS, personMs = PERSON_MS, now = Date.now, sleep = sleepMs, pollMs = 200 } = {}) {
|
|
186
|
+
if (!(await running())) return 'no-shell';
|
|
187
|
+
const nonce = newNonce();
|
|
188
|
+
for (const f of ['closing.json', 'closed.json']) { try { rmSync(file(f), { force: true }); } catch { /* */ } }
|
|
189
|
+
const start = now();
|
|
190
|
+
writeAtomic(file('close-request.json'), { nonce, expires: start + ackMs + personMs });
|
|
191
|
+
let acked = false;
|
|
192
|
+
const withdraw = () => { try { rmSync(file('close-request.json'), { force: true }); } catch { /* */ } };
|
|
193
|
+
for (;;) {
|
|
194
|
+
const closed = readJson(file('closed.json'));
|
|
195
|
+
if (closed?.nonce === nonce) { withdraw(); return closed.result === 'cancelled' ? 'cancelled' : 'closed'; }
|
|
196
|
+
if (!acked && readJson(file('closing.json'))?.nonce === nonce) acked = true;
|
|
197
|
+
const elapsed = now() - start;
|
|
198
|
+
if (!acked && elapsed >= ackMs) {
|
|
199
|
+
// A shell that was already gone (or answered just now) is not a hung one.
|
|
200
|
+
if (!(await running())) { withdraw(); return 'closed'; }
|
|
201
|
+
withdraw();
|
|
202
|
+
return 'no-ack';
|
|
203
|
+
}
|
|
204
|
+
if (acked && elapsed >= ackMs + personMs) { withdraw(); return 'cancelled'; }
|
|
205
|
+
if (acked && !(await running())) { withdraw(); return 'closed'; }
|
|
206
|
+
await sleep(pollMs);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// ── restore list (after an update) ───────────────────────────────────────────────────────────────────────────────
|
|
211
|
+
|
|
212
|
+
/** Windows to reopen: read from restore.json. Null when there is none. */
|
|
213
|
+
function readRestore() { const r = readJson(file('restore.json')); return Array.isArray(r?.windows) ? r : null; }
|
|
214
|
+
|
|
215
|
+
/** Add windows to the restore list (merged, de-duplicated, order kept; read-modify-write + rename). */
|
|
216
|
+
export function joinRestore(windows, { now = Date.now } = {}) {
|
|
217
|
+
const current = readRestore()?.windows ?? [];
|
|
218
|
+
const seen = new Set();
|
|
219
|
+
const merged = [...current, ...windows.filter(isRestoreEntry)].map(normEntry).filter((e) => !seen.has(entryPath(e)) && seen.add(entryPath(e))).slice(0, 12);
|
|
220
|
+
if (merged.length === 0) return [];
|
|
221
|
+
writeAtomic(file('restore.json'), { windows: merged, savedAt: now() });
|
|
222
|
+
return merged;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Take `windows` back out of the restore list (what one update attempt added); anything else queued stays. */
|
|
226
|
+
export function removeFromRestore(windows) {
|
|
227
|
+
const current = readRestore()?.windows ?? [];
|
|
228
|
+
const drop = new Set(windows.map(entryPath));
|
|
229
|
+
const left = current.filter((w) => !drop.has(entryPath(w)));
|
|
230
|
+
if (left.length === current.length) return left;
|
|
231
|
+
if (left.length === 0) clearRestore();
|
|
232
|
+
else writeAtomic(file('restore.json'), { windows: left, savedAt: Date.now() });
|
|
233
|
+
return left;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function clearRestore() { try { rmSync(file('restore.json'), { force: true }); } catch { /* */ } }
|
|
237
|
+
|
|
238
|
+
/** Claim the restore list: only one caller gets it (atomic rename); everyone else gets []. */
|
|
239
|
+
export function claimRestore() {
|
|
240
|
+
const src = file('restore.json');
|
|
241
|
+
if (!existsSync(src)) return [];
|
|
242
|
+
const claimed = `${src}.claimed.${process.pid}.${randomBytes(3).toString('hex')}`;
|
|
243
|
+
try { renameSync(src, claimed); } catch { return []; }
|
|
244
|
+
const data = readJson(claimed);
|
|
245
|
+
try { rmSync(claimed, { force: true }); } catch { /* */ }
|
|
246
|
+
return Array.isArray(data?.windows) ? data.windows.filter(isRestoreEntry).map(normEntry) : [];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Age of the restore list in ms, or null when there is none (for the supervisor's fallback). */
|
|
250
|
+
export function restoreAgeMs({ now = Date.now } = {}) {
|
|
251
|
+
try { return now() - statSync(file('restore.json')).mtimeMs; } catch { return null; }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ── update admission ─────────────────────────────────────────────────────────────────────────────────────────────
|
|
255
|
+
|
|
256
|
+
export function beginUpdate({ now = Date.now } = {}) { writeAtomic(file('updating.json'), { startedAt: now(), expires: now() + UPDATING_TTL_MS }); }
|
|
257
|
+
export function endUpdate() { try { rmSync(file('updating.json'), { force: true }); } catch { /* */ } }
|
|
258
|
+
/** An expired marker (a crashed update) never holds a launch. */
|
|
259
|
+
export function updateInProgress({ now = Date.now } = {}) {
|
|
260
|
+
const u = readJson(file('updating.json'));
|
|
261
|
+
return !!u && typeof u.expires === 'number' && u.expires > now();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ── teardown admission (update, uninstall) ───────────────────────────────────────────────────────────────────────
|
|
265
|
+
|
|
266
|
+
export const STOPPING_TTL_MS = 2 * 60_000;
|
|
267
|
+
/** Written FIRST by a teardown: nothing may start the tray while FloLess is being taken apart. The teardown removes it when it ends. */
|
|
268
|
+
export function beginTeardown({ now = Date.now } = {}) { writeAtomic(file('stopping.json'), { startedAt: now(), expires: now() + STOPPING_TTL_MS }); }
|
|
269
|
+
export function endTeardown() { try { rmSync(file('stopping.json'), { force: true }); } catch { /* */ } }
|
|
270
|
+
/** An expired marker (a teardown that died) never holds the tray. */
|
|
271
|
+
export function teardownInProgress({ now = Date.now } = {}) {
|
|
272
|
+
const s = readJson(file('stopping.json'));
|
|
273
|
+
return !!s && typeof s.expires === 'number' && s.expires > now();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** The supervisor starts no tray while an update is being applied or FloLess is being taken apart. */
|
|
277
|
+
export const trayHeld = ({ now = Date.now } = {}) => updateInProgress({ now }) || teardownInProgress({ now });
|
|
278
|
+
|
|
279
|
+
// ── the tray (one process with the window; started at logon by the supervisor) ───────────────────────────────────
|
|
280
|
+
|
|
281
|
+
export const TRAY_STALE_MS = 20_000; // a heartbeat older than this means no working tray
|
|
282
|
+
export const TRAY_RESPAWN_MS = 30_000; // never spawn more often than this
|
|
283
|
+
export const TRAY_MAX_TRIES = 3; // spawns without a heartbeat before pausing
|
|
284
|
+
export const TRAY_PAUSE_MS = 10 * 60_000;
|
|
285
|
+
|
|
286
|
+
/** Age of the tray's heartbeat in ms (it writes tray.json only after its icon exists), or null when there is none. */
|
|
287
|
+
export function trayHeartbeatAgeMs({ now = Date.now } = {}) {
|
|
288
|
+
const t = readJson(file('tray.json'));
|
|
289
|
+
return t && typeof t.at === 'number' ? Math.max(0, now() - t.at) : null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Start the tray: the shell with --tray and no window. Detached; the shell's own single-instance lock makes a second one harmless. */
|
|
293
|
+
export function launchTray({ server, say = () => {},
|
|
294
|
+
spawnShell = (exe, args) => spawn(exe, args, { detached: true, stdio: 'ignore', windowsHide: true }) } = {}) {
|
|
295
|
+
try {
|
|
296
|
+
if (!existsSync(shellExe())) { say('the FloLess tray was not started: the window is not installed'); return false; }
|
|
297
|
+
const child = spawnShell(shellExe(), [`--server=${server}`, '--tray', `--control-dir=${shellDir()}`]);
|
|
298
|
+
child?.once?.('error', (error) => say(`the FloLess tray could not start (${error?.code ?? error?.message ?? 'unknown error'})`));
|
|
299
|
+
child?.unref?.();
|
|
300
|
+
return true;
|
|
301
|
+
} catch { return false; }
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The supervisor's tray rule, one decision per tick. It never enumerates processes: a working tray proves itself with a heartbeat
|
|
306
|
+
* that is written only after its icon was created. `tick()` answers what it did, so the rule is testable without a shell.
|
|
307
|
+
* 'off' no tray wanted (not installed, switched off, server not healthy, an update or teardown is running)
|
|
308
|
+
* 'alive' the heartbeat is fresh
|
|
309
|
+
* 'wait' spawned recently, or paused after repeated spawns that never produced a heartbeat
|
|
310
|
+
* 'spawned' started a tray now
|
|
311
|
+
*/
|
|
312
|
+
export function createTrayKeeper({ installed, wanted, healthy, held, spawn: spawnTray, age = trayHeartbeatAgeMs, now = Date.now, say = () => {} }) {
|
|
313
|
+
let lastSpawn = -Infinity;
|
|
314
|
+
let tries = 0;
|
|
315
|
+
let pausedUntil = 0;
|
|
316
|
+
return {
|
|
317
|
+
async tick() {
|
|
318
|
+
if (!installed() || !wanted() || held() || !(await healthy())) { tries = 0; return 'off'; }
|
|
319
|
+
const a = age({ now });
|
|
320
|
+
if (a !== null && a < TRAY_STALE_MS) { tries = 0; return 'alive'; }
|
|
321
|
+
const t = now();
|
|
322
|
+
if (t < pausedUntil || t - lastSpawn < TRAY_RESPAWN_MS) return 'wait';
|
|
323
|
+
if (tries >= TRAY_MAX_TRIES) {
|
|
324
|
+
pausedUntil = t + TRAY_PAUSE_MS;
|
|
325
|
+
tries = 0;
|
|
326
|
+
say('the FloLess tray did not start after several tries - will try again in a few minutes');
|
|
327
|
+
return 'wait';
|
|
328
|
+
}
|
|
329
|
+
tries += 1;
|
|
330
|
+
lastSpawn = t;
|
|
331
|
+
if (!spawnTray()) say('could not start the FloLess tray');
|
|
332
|
+
return 'spawned';
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
}
|