@floless/app 0.166.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.
Files changed (261) hide show
  1. package/autostart.mjs +169 -63
  2. package/desktop-shell.mjs +335 -0
  3. package/dist/floless-server.cjs +20570 -14555
  4. package/dist/schemas/drawing-check.profile.v1.schema.json +1 -1
  5. package/dist/schemas/steel.model.v2.schema.json +4 -2
  6. package/dist/skills/floless-app-onboarding/SKILL.md +13 -4
  7. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +3 -0
  8. package/dist/skills/floless-app-steel-takeoff/SKILL.md +34 -3
  9. package/dist/skills/floless-app-ui/SKILL.md +2 -2
  10. package/dist/skills/floless-app-workflows/SKILL.md +2 -2
  11. package/dist/templates/college-phase-exporter.flo +11 -45
  12. package/dist/web/agents.js +1 -1
  13. package/dist/web/app.css +223 -8
  14. package/dist/web/app.js +53 -13
  15. package/dist/web/aware-update-client.js +13 -5
  16. package/dist/web/aware.js +559 -118
  17. package/dist/web/chat.css +23 -0
  18. package/dist/web/chat.js +1003 -83
  19. package/dist/web/commands-filter.js +28 -5
  20. package/dist/web/commands-shell.js +304 -18
  21. package/dist/web/commands-steel.js +1 -1
  22. package/dist/web/desktop-window.js +435 -0
  23. package/dist/web/drawing-check-editor.js +18 -10
  24. package/dist/web/failure-copy.js +14 -1
  25. package/dist/web/guide.js +75 -9
  26. package/dist/web/index.html +72 -12
  27. package/dist/web/instructor.js +1 -1
  28. package/dist/web/leave-guard.js +347 -14
  29. package/dist/web/pages.js +5 -1
  30. package/dist/web/panels.js +5 -2
  31. package/dist/web/pdf-view.js +421 -0
  32. package/dist/web/project-history.js +133 -11
  33. package/dist/web/project-modules.js +3 -1
  34. package/dist/web/project-rfis.js +3 -1
  35. package/dist/web/project-workflows.js +4 -2
  36. package/dist/web/reference-geometry-worker.js +11 -2
  37. package/dist/web/revit-editor.html +1 -0
  38. package/dist/web/revit-editor.js +37 -8
  39. package/dist/web/shared-prefs.js +364 -0
  40. package/dist/web/steel-ai-marks.js +45 -1
  41. package/dist/web/steel-editor.html +265 -58
  42. package/dist/web/steel-filter-flo.js +243 -23
  43. package/dist/web/steel-filter.html +58 -16
  44. package/dist/web/tab-signal.js +36 -1
  45. package/dist/web/tekla-editor.html +1 -0
  46. package/dist/web/terminal-requests.js +5 -0
  47. package/dist/web/tool-updates.js +220 -54
  48. package/dist/web/vector-3d.html +14 -3
  49. package/dist/web/vector-editor.html +10 -2
  50. package/dist/web/vendor/README.md +23 -0
  51. package/dist/web/vendor/pdfjs/LICENSE +177 -0
  52. package/dist/web/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  53. package/dist/web/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  54. package/dist/web/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  55. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  56. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  57. package/dist/web/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  58. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  59. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  60. package/dist/web/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  61. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  62. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  63. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  64. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  65. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  66. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  67. package/dist/web/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  68. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  69. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  70. package/dist/web/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  71. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  72. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  73. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  74. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  75. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  76. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  77. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  78. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  79. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  80. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  81. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  82. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  83. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  84. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  85. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  86. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  87. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  88. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  89. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  90. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  91. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  92. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  93. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  94. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  95. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  96. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  97. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  98. package/dist/web/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  99. package/dist/web/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  100. package/dist/web/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  101. package/dist/web/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  102. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  103. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  104. package/dist/web/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  105. package/dist/web/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  106. package/dist/web/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  107. package/dist/web/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  108. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  109. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  110. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  111. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  112. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  113. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  114. package/dist/web/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  115. package/dist/web/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  116. package/dist/web/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  117. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  118. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  119. package/dist/web/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  120. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  121. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  122. package/dist/web/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
  123. package/dist/web/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  124. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  125. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  126. package/dist/web/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  127. package/dist/web/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  128. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  129. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  130. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  131. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  132. package/dist/web/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  133. package/dist/web/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  134. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  135. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  136. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  137. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  138. package/dist/web/vendor/pdfjs/cmaps/H.bcmap +0 -0
  139. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  140. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  141. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  142. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  143. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  144. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  145. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  146. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  147. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  148. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  149. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  150. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  151. package/dist/web/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  152. package/dist/web/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  153. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  154. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  155. package/dist/web/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  156. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  157. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  158. package/dist/web/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  159. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  160. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  161. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  162. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  163. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  164. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  165. package/dist/web/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  166. package/dist/web/vendor/pdfjs/cmaps/LICENSE +36 -0
  167. package/dist/web/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  168. package/dist/web/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  169. package/dist/web/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  170. package/dist/web/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  171. package/dist/web/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  172. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  173. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  174. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  175. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  176. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  177. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  178. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  179. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  180. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  181. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  182. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  183. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  184. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  185. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  186. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  187. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  188. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  189. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  190. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  191. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  192. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  193. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  194. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  195. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  196. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  197. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  198. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  199. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  200. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  201. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  202. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  203. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  204. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  205. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  206. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  207. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  208. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  209. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  210. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  211. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  212. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  213. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  214. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  215. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  216. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  217. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  218. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  219. package/dist/web/vendor/pdfjs/cmaps/V.bcmap +0 -0
  220. package/dist/web/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  221. package/dist/web/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  222. package/dist/web/vendor/pdfjs/iccs/LICENSE +116 -0
  223. package/dist/web/vendor/pdfjs/pdf.min.mjs +28 -0
  224. package/dist/web/vendor/pdfjs/pdf.worker.mjs +64908 -0
  225. package/dist/web/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  226. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  227. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  228. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  229. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  230. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  231. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  232. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  233. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  234. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  235. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  236. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  237. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  238. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  239. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  240. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  241. package/dist/web/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  242. package/dist/web/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  243. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  244. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  245. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  246. package/dist/web/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
  247. package/dist/web/vendor/pdfjs/wasm/jbig2.wasm +0 -0
  248. package/dist/web/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +15 -0
  249. package/dist/web/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
  250. package/dist/web/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +17 -0
  251. package/dist/web/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
  252. package/dist/web/workspaces.js +527 -64
  253. package/home-env.mjs +28 -0
  254. package/install-path.mjs +59 -3
  255. package/launch-starting-page.mjs +35 -15
  256. package/launch.mjs +358 -51
  257. package/package.json +2 -1
  258. package/pin-home.mjs +6 -0
  259. package/post-update-marker.mjs +14 -0
  260. package/preferences-file.mjs +289 -0
  261. package/supervisor-lock.mjs +195 -0
@@ -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
- if (!res.ok || body.ok === false) { const err = new Error(body.error || `HTTP ${res.status}`); err.status = res.status; err.body = body; throw err; }
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
  };
@@ -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
- if (!res.ok || body.ok === false) { const err = new Error(body.error || `HTTP ${res.status}`); err.status = res.status; err.body = body; throw err; }
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
- if (!res.ok || body.ok === false) { const err = new Error(body.error || `HTTP ${res.status}`); err.status = res.status; err.body = body; throw err; }
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
- if (!res.ok || answer.ok === false) { const err = new Error(answer.error || `HTTP ${res.status}`); err.status = res.status; err.body = answer; throw err; }
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
- error: response.ok
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
- error: error?.message || 'could not decode reference geometry',
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>
@@ -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
- 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 || `Request failed (${response.status})`), { status: response.status, body: value }); return value; }
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(`Editor state conflict reload failed (${fresh.status})`);
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(value.message || value.error || `Editor state save failed (${response.status})`), { code: value.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, fallback) {
1421
+ function reportEditorStateSaveError(error, action) {
1398
1422
  const refused = editorStateAccessRefused(error);
1399
1423
  if (refused) { if (editorStateAccessWarned === error.message) return; editorStateAccessWarned = error.message; }
1400
- toast(error?.message || fallback, refused ? 8000 : undefined);
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, 'Could not save model view state.')); }, 350);
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(value.message || value.error || `Editor state read failed (${response.status})`); }
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, 'Could not restore model view state.')), 0); }
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) {
@@ -0,0 +1,364 @@
1
+ /*
2
+ * web/shared-prefs.js — the preferences that follow the person across the FloLess window and the browser tab (#2963, epic #2960).
3
+ *
4
+ * Shared through the server's preferences file (server/preferences-file.mjs, routes in server/desktop-routes.ts):
5
+ * theme, last project, "What's new" seen, chat read cursors. Everything else (folded panels, mode, guide notices, ...) stays in
6
+ * this browser's localStorage and never comes through here.
7
+ *
8
+ * localStorage stays a CACHE for the four shared values: first paint (web/frame-theme.js reads the theme key synchronously) and the
9
+ * fallback when the server cannot be reached. The server value wins whenever it is known. An unreachable server is never an error:
10
+ * every page keeps working from the cache, silently.
11
+ *
12
+ * Rules this file keeps (Codex-hardened, see docs/superpowers/specs/2026-11-03-desktop-s2-plan.md):
13
+ * - The legacy browser values are SNAPSHOTTED when this script loads, before anything can write a default into the cache.
14
+ * - The one-time migration runs only when `floless:prefs-migrated` differs from the server's `generation`, and the marker is written
15
+ * only after the server answered 200. A failed migration changes nothing and is tried again on the next load.
16
+ * - Writes go through ONE serial queue (one PUT/POST in flight), so two quick choices cannot arrive reversed.
17
+ * - An answer older than the newest revision already applied is ignored.
18
+ *
19
+ * Plain classic script, one global: window.flolessPrefs.
20
+ */
21
+ (function () {
22
+ 'use strict';
23
+
24
+ var KEYS = {
25
+ theme: { cache: 'floless-demo-theme-v1' }, // must match web/app.js THEME_KEY and web/frame-theme.js
26
+ lastProject: { cache: 'floless:last-project' },
27
+ whatsNewSeen: { cache: 'floless.whatsNew.seen' },
28
+ // Not browser-cached; read from the server only (the tray and the window preference live there).
29
+ client: { cache: null }, tray: { cache: null }, trayExplained: { cache: null },
30
+ };
31
+ var CHAT_PREFIX = 'floless:chat-read:';
32
+ var SEEDED_PREFIX = 'floless:chat-read-seeded:';
33
+ var MARKER = 'floless:prefs-migrated';
34
+ var THEMES = ['dark', 'light'];
35
+ var MAX_BATCH = 500;
36
+ var READY_LIMIT_MS = 5000;
37
+ var FLUSH_MS = 500;
38
+ var CALL_TIMEOUT_MS = 8000; // one hung request must not hold the serial queue (and what waits on it) forever
39
+
40
+ // ── localStorage, never throwing ─────────────────────────────────────────────────────────────────────────────────
41
+ function cacheGet(key) { try { return localStorage.getItem(key); } catch (e) { return null; } }
42
+ function cacheSet(key, value) { try { localStorage.setItem(key, String(value)); } catch (e) { /* private mode: no cache */ } }
43
+ function cacheKeys() {
44
+ var out = [];
45
+ try { for (var i = 0; i < localStorage.length; i++) out.push(localStorage.key(i)); } catch (e) { /* none */ }
46
+ return out;
47
+ }
48
+ function seq(n) { n = Number(n); return Number.isSafeInteger(n) && n >= 0 ? n : 0; }
49
+
50
+ // ── the snapshot: what this browser kept before the server ever held it. Taken NOW, before any cache write. ───────
51
+ var legacy = (function () {
52
+ var out = { theme: null, lastProject: null, whatsNewSeen: null, chatRead: {} };
53
+ var theme = cacheGet(KEYS.theme.cache);
54
+ if (THEMES.indexOf(theme) >= 0) out.theme = theme;
55
+ var project = cacheGet(KEYS.lastProject.cache);
56
+ if (typeof project === 'string' && project.length <= 200) out.lastProject = project;
57
+ var seen = cacheGet(KEYS.whatsNewSeen.cache);
58
+ if (typeof seen === 'string' && seen && seen.length <= 64) out.whatsNewSeen = seen;
59
+ cacheKeys().forEach(function (k) {
60
+ if (typeof k === 'string' && k.indexOf(CHAT_PREFIX) === 0) {
61
+ var n = seq(cacheGet(k));
62
+ if (n > 0) out.chatRead[k.slice(CHAT_PREFIX.length)] = n;
63
+ }
64
+ });
65
+ return out;
66
+ })();
67
+ function hasLegacy() {
68
+ return legacy.theme !== null || legacy.lastProject !== null || legacy.whatsNewSeen !== null || Object.keys(legacy.chatRead).length > 0;
69
+ }
70
+ function legacyBody() {
71
+ var body = {};
72
+ if (legacy.theme !== null) body.theme = legacy.theme;
73
+ if (legacy.lastProject !== null) body.lastProject = legacy.lastProject;
74
+ if (legacy.whatsNewSeen !== null) body.whatsNewSeen = legacy.whatsNewSeen;
75
+ if (Object.keys(legacy.chatRead).length) body.chatRead = legacy.chatRead;
76
+ return body;
77
+ }
78
+
79
+ // ── state ────────────────────────────────────────────────────────────────────────────────────────────────────────
80
+ var view = {}; // shared values as this page sees them (server value, with unacknowledged local choices on top)
81
+ var dirty = {}; // keys the person set that no PUT answer has confirmed yet
82
+ var chat = {}; // chatId -> read cursor, merged by maximum
83
+ var seededOwners = [];
84
+ var generation = null;
85
+ var applied = -1; // the highest revision applied so far
86
+ var hydrated = false;
87
+ var listeners = [];
88
+ var jobs = []; // the serial write queue
89
+ var busy = false;
90
+ var batch = {}; // read cursors waiting to be sent
91
+ var flushTimer = null;
92
+ var migrateTried = false;
93
+ var refetchAfter = false;
94
+ var readyPromise = null;
95
+ var lastFetchAt = 0;
96
+
97
+ Object.keys(legacy.chatRead).forEach(function (id) { chat[id] = legacy.chatRead[id]; });
98
+
99
+ function notify(keys) {
100
+ listeners.slice().forEach(function (cb) { try { cb(keys); } catch (e) { /* a page's listener must not break the others */ } });
101
+ }
102
+
103
+ // ── talking to the server ────────────────────────────────────────────────────────────────────────────────────────
104
+ function call(method, url, body) {
105
+ var init = { method: method, cache: 'no-store', headers: {} };
106
+ if (body !== undefined) { init.headers['Content-Type'] = 'application/json'; init.body = JSON.stringify(body); }
107
+ try {
108
+ var limit = window.flolessPrefs && window.flolessPrefs.callTimeoutMs > 0 ? window.flolessPrefs.callTimeoutMs : CALL_TIMEOUT_MS;
109
+ if (typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function') init.signal = AbortSignal.timeout(limit);
110
+ } catch (e) { /* an environment without it: the request simply has no limit */ }
111
+ return fetch(url, init).then(function (res) {
112
+ return res.json().then(function (json) { return { status: res.status, ok: res.ok && json && json.ok !== false, json: json }; },
113
+ function () { return { status: res.status, ok: false, json: null }; });
114
+ });
115
+ }
116
+
117
+ /** Apply a server answer to the page and the cache. Returns false when it was older than what was already applied. */
118
+ function applyAnswer(ans) {
119
+ if (!ans || typeof ans !== 'object' || !Number.isSafeInteger(ans.revision)) return false;
120
+ // The server could not read its file and answered with defaults: those are not the person's choices. Never write them in.
121
+ if (ans.degraded === true) return false;
122
+ // A different generation means the file was started over: its revisions count from zero again.
123
+ if (ans.generation && generation && ans.generation !== generation) applied = -1;
124
+ if (ans.revision < applied) return false;
125
+ applied = ans.revision;
126
+ if (ans.generation) generation = ans.generation;
127
+ var changed = [];
128
+ Object.keys(KEYS).forEach(function (key) {
129
+ var v = ans[key];
130
+ if (v === undefined || v === null) return; // never set on the server: keep what the page has
131
+ if (Object.prototype.hasOwnProperty.call(dirty, key)) return; // the person chose something newer, not yet saved
132
+ if (view[key] !== v) { view[key] = v; changed.push(key); }
133
+ if (KEYS[key].cache && cacheGet(KEYS[key].cache) !== String(v)) cacheSet(KEYS[key].cache, v);
134
+ });
135
+ if (ans.chatRead && typeof ans.chatRead === 'object') {
136
+ Object.keys(ans.chatRead).forEach(function (id) {
137
+ var n = seq(ans.chatRead[id]);
138
+ if (n > (chat[id] || 0)) { chat[id] = n; changed.push('chatRead'); }
139
+ if (seq(cacheGet(CHAT_PREFIX + id)) < n) cacheSet(CHAT_PREFIX + id, n);
140
+ });
141
+ }
142
+ if (Array.isArray(ans.seededOwners)) seededOwners = ans.seededOwners.slice();
143
+ hydrated = true;
144
+ if (changed.length) notify(changed);
145
+ return true;
146
+ }
147
+
148
+ // ── the serial queue ─────────────────────────────────────────────────────────────────────────────────────────────
149
+ function enqueue(job) {
150
+ if (job.type === 'put') {
151
+ var last = jobs[jobs.length - 1];
152
+ if (last && last.type === 'put') { Object.assign(last.patch, job.patch); return last.done; }
153
+ }
154
+ job.done = new Promise(function (resolve) { job.resolve = resolve; });
155
+ jobs.push(job);
156
+ pump();
157
+ return job.done;
158
+ }
159
+
160
+ function pump() {
161
+ if (busy) return;
162
+ var job = jobs.shift();
163
+ if (!job) {
164
+ // The deferred read. It does NOT re-send unsaved choices: a write that failed waits for the next focus, visibility or online
165
+ // event, so a failing server is never hit in a loop from the queue's own completion.
166
+ if (refetchAfter) { refetchAfter = false; refetch(true, true); }
167
+ return;
168
+ }
169
+ busy = true;
170
+ run(job).then(function (ok) { job.resolve(ok); }, function () { job.resolve(false); }).then(function () { busy = false; pump(); });
171
+ }
172
+
173
+ function run(job) {
174
+ if (job.type === 'put') {
175
+ var patch = job.patch;
176
+ return call('PUT', '/api/preferences', patch).then(function (r) {
177
+ if (r.ok) {
178
+ Object.keys(patch).forEach(function (k) { if (dirty[k] === patch[k]) delete dirty[k]; });
179
+ applyAnswer(r.json);
180
+ return true;
181
+ }
182
+ // A refusal (400) will never succeed: stop holding the value AND stop showing it, then read what the server really holds.
183
+ // A network or server fault keeps the choice for the next try.
184
+ if (r.status >= 400 && r.status < 500) {
185
+ var reverted = [];
186
+ Object.keys(patch).forEach(function (k) { if (dirty[k] === patch[k]) { delete dirty[k]; delete view[k]; reverted.push(k); } });
187
+ if (reverted.length) { refetchAfter = true; notify(reverted); }
188
+ }
189
+ return false;
190
+ }, function () { return false; });
191
+ }
192
+ if (job.type === 'read' || job.type === 'seed') {
193
+ var body = job.type === 'seed' ? { seedOwner: job.owner, cursors: job.cursors } : { cursors: job.cursors };
194
+ return call('POST', '/api/preferences/chat-read', body).then(function (r) {
195
+ if (r.ok) { applyAnswer(r.json); return true; }
196
+ if (job.type === 'read' && !(r.status >= 400 && r.status < 500)) Object.keys(job.cursors).forEach(function (id) { batch[id] = Math.max(batch[id] || 0, job.cursors[id]); });
197
+ return false;
198
+ }, function () {
199
+ if (job.type === 'read') Object.keys(job.cursors).forEach(function (id) { batch[id] = Math.max(batch[id] || 0, job.cursors[id]); });
200
+ return false;
201
+ });
202
+ }
203
+ if (job.type === 'migrate') {
204
+ return call('POST', '/api/preferences/migrate', job.body).then(function (r) {
205
+ // The marker is written ONLY after the server answered 200, and only for an answer that really holds a generation.
206
+ if (r.ok && r.json && r.json.generation && r.json.revision > 0) {
207
+ cacheSet(MARKER, r.json.generation);
208
+ applyAnswer(r.json);
209
+ return true;
210
+ }
211
+ return false;
212
+ }, function () { return false; });
213
+ }
214
+ return Promise.resolve(false);
215
+ }
216
+
217
+ // ── hydration, migration, refetch ────────────────────────────────────────────────────────────────────────────────
218
+ function flushUnsent() {
219
+ var patch = {};
220
+ Object.keys(dirty).forEach(function (k) { patch[k] = dirty[k]; });
221
+ if (Object.keys(patch).length && !jobs.some(function (j) { return j.type === 'put'; })) enqueue({ type: 'put', patch: patch });
222
+ }
223
+
224
+ function maybeMigrate(ans) {
225
+ if (migrateTried) return Promise.resolve();
226
+ var marker = cacheGet(MARKER);
227
+ if (ans.generation && marker === ans.generation) return Promise.resolve();
228
+ migrateTried = true;
229
+ if (!hasLegacy()) {
230
+ // Nothing to hand over: just remember which generation this browser has settled with.
231
+ if (ans.generation) cacheSet(MARKER, ans.generation);
232
+ return Promise.resolve();
233
+ }
234
+ return enqueue({ type: 'migrate', body: legacyBody() });
235
+ }
236
+
237
+ function refetch(force, deferredRead) {
238
+ var now = Date.now();
239
+ if (!force && now - lastFetchAt < 1000) return Promise.resolve();
240
+ if (!deferredRead) flushUnsent(); // a value that never reached the server goes first; the read follows once the queue is quiet
241
+ if (busy || jobs.length) { refetchAfter = true; return Promise.resolve(); }
242
+ lastFetchAt = now;
243
+ // At startup the server may still be recovering its stores: wait for the page's admission gate when there is one (it uses no connection).
244
+ var admit = window.flolessStartupAdmission && typeof window.flolessStartupAdmission.admit === 'function'
245
+ ? Promise.resolve().then(function () { return window.flolessStartupAdmission.admit('/api/preferences'); }).catch(function () { /* try anyway */ })
246
+ : Promise.resolve();
247
+ return admit.then(function () { return call('GET', '/api/preferences'); }).then(function (r) {
248
+ if (!r.ok || (r.json && r.json.degraded === true)) return; // a degraded answer is defaults: neither applied nor migrated onto
249
+ // Writes started while this read was out: its answer may be older than they make the truth. Revisions decide.
250
+ applyAnswer(r.json);
251
+ return maybeMigrate(r.json);
252
+ }, function () { /* offline: the cache keeps the page working */ });
253
+ }
254
+
255
+ function ready() {
256
+ if (readyPromise) return readyPromise;
257
+ var timer;
258
+ var limit = new Promise(function (resolve) { timer = setTimeout(resolve, READY_LIMIT_MS); });
259
+ readyPromise = Promise.race([refetch(true), limit]).then(function () { clearTimeout(timer); }, function () { clearTimeout(timer); });
260
+ return readyPromise;
261
+ }
262
+
263
+ // ── the public side ──────────────────────────────────────────────────────────────────────────────────────────────
264
+ function get(key) {
265
+ if (!Object.prototype.hasOwnProperty.call(KEYS, key)) return null;
266
+ var v = view[key];
267
+ if (v !== undefined && v !== null) return v;
268
+ return KEYS[key].cache ? cacheGet(KEYS[key].cache) : null;
269
+ }
270
+
271
+ /** Shows the choice at once and saves it in the background. Resolves true once the server confirmed it, false when it did not
272
+ * (never rejects): a refusal also takes the choice back off the page, a network or server fault keeps it to send later. */
273
+ function set(key, value) {
274
+ if (!Object.prototype.hasOwnProperty.call(KEYS, key)) return Promise.resolve(false);
275
+ view[key] = value;
276
+ dirty[key] = value;
277
+ if (KEYS[key].cache) cacheSet(KEYS[key].cache, value);
278
+ var patch = {}; patch[key] = value;
279
+ return enqueue({ type: 'put', patch: patch }).then(function (ok) { return ok === true; }, function () { return false; });
280
+ }
281
+
282
+ function flushReads() {
283
+ flushTimer = null;
284
+ var ids = Object.keys(batch);
285
+ if (!ids.length) return;
286
+ for (var i = 0; i < ids.length; i += MAX_BATCH) {
287
+ var cursors = {};
288
+ ids.slice(i, i + MAX_BATCH).forEach(function (id) { cursors[id] = batch[id]; delete batch[id]; });
289
+ enqueue({ type: 'read', cursors: cursors });
290
+ }
291
+ }
292
+
293
+ function markChatRead(chatId, sequence) {
294
+ var id = String(chatId); var n = seq(sequence);
295
+ if (!id || n <= (chat[id] || 0)) return;
296
+ chat[id] = n;
297
+ cacheSet(CHAT_PREFIX + id, n);
298
+ batch[id] = n;
299
+ if (!flushTimer) flushTimer = setTimeout(flushReads, FLUSH_MS);
300
+ }
301
+
302
+ function chatCursor(chatId) { return chat[String(chatId)] || 0; }
303
+
304
+ /**
305
+ * The first-visit baseline of an owner (a project, a workflow, the workspace): chats that already exist are not "unread". Once per owner,
306
+ * across the window and the browser; a client that finds the owner already seeded does nothing, so a chat the server has no cursor for
307
+ * counts as unread. Without a reachable server it falls back to this browser's own one-time baseline.
308
+ */
309
+ function seedOwner(ownerKey, cursors) {
310
+ var marker = SEEDED_PREFIX + ownerKey;
311
+ return ready().then(function () {
312
+ var localSeeded = Boolean(cacheGet(marker));
313
+ if (hydrated) {
314
+ if (seededOwners.indexOf(ownerKey) >= 0) return 'already';
315
+ // This browser seeded the owner before the server held the baseline: tell the server, without a new baseline.
316
+ var send = localSeeded ? {} : cursors;
317
+ return enqueue({ type: 'seed', owner: ownerKey, cursors: send }).then(function (ok) {
318
+ if (ok) return 'server';
319
+ return localSeed(marker, cursors, localSeeded);
320
+ });
321
+ }
322
+ return localSeed(marker, cursors, localSeeded);
323
+ });
324
+ }
325
+
326
+ function localSeed(marker, cursors, already) {
327
+ if (already) return 'local';
328
+ Object.keys(cursors).forEach(function (id) {
329
+ if (chat[id] === undefined) { chat[id] = seq(cursors[id]); cacheSet(CHAT_PREFIX + id, chat[id]); }
330
+ });
331
+ cacheSet(marker, '1');
332
+ return 'local';
333
+ }
334
+
335
+ function onChange(cb) { if (typeof cb === 'function') listeners.push(cb); return function () { listeners = listeners.filter(function (l) { return l !== cb; }); }; }
336
+
337
+ function snapshot() {
338
+ var out = {};
339
+ Object.keys(KEYS).forEach(function (k) { out[k] = get(k); });
340
+ return out;
341
+ }
342
+
343
+ /** Read cursors whose write failed stay in `batch` until the server acknowledges them; the same events that retry a save send them again. */
344
+ function retryReads() { if (Object.keys(batch).length && !flushTimer) flushReads(); }
345
+
346
+ // Refetch when the person comes back to this window or tab: the other client may have changed something meanwhile.
347
+ try {
348
+ window.addEventListener('focus', function () { retryReads(); refetch(false); });
349
+ document.addEventListener('visibilitychange', function () { if (!document.hidden) { retryReads(); refetch(false); } });
350
+ window.addEventListener('online', function () { retryReads(); refetch(true); });
351
+ } catch (e) { /* no events here */ }
352
+
353
+ window.flolessPrefs = {
354
+ get: get, set: set, onChange: onChange, snapshot: snapshot, ready: ready, refetch: refetch,
355
+ markChatRead: markChatRead, chatCursor: chatCursor, flushReads: flushReads,
356
+ seedOwner: seedOwner,
357
+ callTimeoutMs: CALL_TIMEOUT_MS, // tests shorten it
358
+ hydrated: function () { return hydrated; },
359
+ migrationMarkerKey: MARKER,
360
+ };
361
+
362
+ // Start hydrating now; pages that need the answer await ready().
363
+ ready();
364
+ })();
@@ -30,6 +30,7 @@
30
30
  */
31
31
  import { planViewId } from './steel-plan-view-id.js';
32
32
  import { createMemberPresenceIndex, memberPresence } from './steel-model-v2-projection.js';
33
+ import { FT_IN, formatElevation, normalizeDisplayUnits, parseElevationMm } from './display-units.js';
33
34
 
34
35
  const AI_ID = /^[0-9a-f]{12}$/;
35
36
  const DIGEST = /^[0-9a-f]{64}$/;
@@ -67,6 +68,7 @@ export function subjectOk(v) {
67
68
  case 'connection': return only(v, ['channel', 'jointId', 'covers']) && str(v.jointId, ID_MAX) && coversOk(v.covers);
68
69
  case 'unmodelled-detail': return only(v, ['channel', 'sheetId', 'detailRef']) && str(v.sheetId, ID_MAX) && str(v.detailRef, ID_MAX);
69
70
  case 'filter': return only(v, ['channel', 'checkpointDigest']) && typeof v.checkpointDigest === 'string' && DIGEST.test(v.checkpointDigest);
71
+ case 'scope': return only(v, ['channel', 'keptDigest']) && typeof v.keptDigest === 'string' && DIGEST.test(v.keptDigest);
70
72
  default: return false;
71
73
  }
72
74
  }
@@ -83,6 +85,15 @@ export function valueOk(subject, v) {
83
85
  if (v.exclusionDigest !== null && (typeof v.exclusionDigest !== 'string' || !DIGEST.test(v.exclusionDigest))) return false;
84
86
  return nonNegInt(v.valueCount) && !(v.exclusionDigest === null && v.valueCount !== 0);
85
87
  }
88
+ case 'scope': {
89
+ // `parseScopeDecisionValue`'s shape (#2554 kind 2); the server alone wrote it.
90
+ if (!isObj(v) || !only(v, ['keptDigest', 'kept', 'attached', 'leaveOut']) || v.keptDigest !== subject.keptDigest) return false;
91
+ if (!nonNegInt(v.kept) || !nonNegInt(v.attached) || v.kept < 1 || !Array.isArray(v.leaveOut) || v.leaveOut.length < 1) return false;
92
+ return v.kept + v.leaveOut.length === v.attached && new Set(v.leaveOut.map((f) => isObj(f) && f.sha256)).size === v.leaveOut.length
93
+ && v.leaveOut.every((f) => isObj(f) && only(f, ['sha256', 'ext', 'bytes', 'names'])
94
+ && typeof f.sha256 === 'string' && DIGEST.test(f.sha256) && typeof f.ext === 'string' && /^[a-z0-9]{1,8}$/.test(f.ext)
95
+ && Number.isSafeInteger(f.bytes) && f.bytes > 0 && Array.isArray(f.names) && f.names.length > 0 && f.names.every((n) => str(n, 260)));
96
+ }
86
97
  case 'setup':
87
98
  if (!isObj(v)) return false;
88
99
  if (subject.row === 'scale') return only(v, ['mmPerPx']) && finite(v.mmPerPx) && v.mmPerPx > 0;
@@ -99,6 +110,39 @@ function entryOk(entry) {
99
110
  && subjectOk(entry.subject) && entry.subject.channel === entry.channel && valueOk(entry.subject, entry.value);
100
111
  }
101
112
 
113
+ // A length that names its own unit, at the very start of the AI's text: `8359.5 mm`, `8.36 m`, `27'-5 1/8"`, `28'`. It
114
+ // must END there (end of text, a space or punctuation): `28'-0 (top)` is not the length `28'` followed by "-0".
115
+ const LEAD_END = String.raw`(?=$|[\s,.;:()])`;
116
+ const LEAD_METRIC = new RegExp(String.raw`^[+-]?\d+(?:\.\d+)?\s*(?:mm|m)` + LEAD_END, 'i');
117
+ const LEAD_FT_IN = new RegExp(String.raw`^[+-]?\d+(?:\.\d+)?\s*'(?:\s*-?\s*(?:\d+\s+)?\d+(?:\.\d+|\/\d+)?\s*")?` + LEAD_END);
118
+ /** How far a written length may sit from the recorded value and still be that value: 0.5 mm, or 1/16". */
119
+ const LEAD_TOLERANCE_MM = { metric: 0.5, imperial: 1.6 };
120
+
121
+ /**
122
+ * #2998: an AI decision's `chosen` as the person reads it. The AI writes `chosen` in its own words and may give a height
123
+ * in millimetres in a ft-in project ("8359.5 mm, interpolated between the callouts either side"), while the decision
124
+ * also records the exact value (`value.mm`). When the text STARTS with a length in the other unit system that equals
125
+ * that value, the length is shown in the project's units ("27'-5 1/8", interpolated …") and the original is returned
126
+ * as `wrote` for a tooltip. Anything else — no recorded value, a length that does not match it, a length already in the
127
+ * project's units, a length later in the text — is returned exactly as the AI wrote it: only the unit changes, never a
128
+ * number. Display only; the recorded text is untouched.
129
+ *
130
+ * @param {unknown} chosen @param {unknown} value the decision's `value` @param {unknown} units the project's display units
131
+ * @returns {{ text: string, wrote?: string }}
132
+ */
133
+ export function decisionChoiceInUnits(chosen, value, units) {
134
+ const text = typeof chosen === 'string' ? chosen : '';
135
+ if (!isObj(value) || !finite(value.mm)) return { text };
136
+ const shown = normalizeDisplayUnits(units);
137
+ const metric = LEAD_METRIC.exec(text), imperial = metric ? null : LEAD_FT_IN.exec(text);
138
+ const lead = metric || imperial;
139
+ if (!lead || (metric ? shown !== FT_IN : shown === FT_IN)) return { text };
140
+ const mm = parseElevationMm(lead[0], shown);
141
+ if (mm == null || Math.abs(mm - value.mm) > LEAD_TOLERANCE_MM[metric ? 'metric' : 'imperial']) return { text };
142
+ const wrote = lead[0].trim();
143
+ return { text: formatElevation(value.mm, shown) + text.slice(lead[0].length), wrote };
144
+ }
145
+
102
146
  /**
103
147
  * @param {unknown} model a steel.model/v2 document (the editor's `C`)
104
148
  */
@@ -194,7 +238,7 @@ export function aiDecisionMarksOf(model) {
194
238
  }
195
239
  break;
196
240
  }
197
- default: // filter, audit-gap, unmodelled-detail: they bear on the whole model
241
+ default: // filter, scope, audit-gap, unmodelled-detail: they bear on the whole model
198
242
  note.push({ decisionId: id, channel: entry.channel, reason: 'model' });
199
243
  }
200
244
  }