@locus-forge/locus-map 0.2.0 → 0.3.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 (216) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/README.md +21 -6
  3. package/dist/assets/{abnfDiagram-VCTEODGH-BnTGKKaL.js → abnfDiagram-VCTEODGH-YtlnkH6t.js} +1 -1
  4. package/dist/assets/{ar-SA-G6X2FPQ2-LY3czoz9.js → ar-SA-G6X2FPQ2-BH5AlOAp.js} +1 -1
  5. package/dist/assets/{architectureDiagram-5GKGNRK7-BG9h9KRx.js → architectureDiagram-5GKGNRK7-DKYw7IM8.js} +1 -1
  6. package/dist/assets/{az-AZ-76LH7QW2-Brv6kuM6.js → az-AZ-76LH7QW2-DoI4xcyq.js} +1 -1
  7. package/dist/assets/{bg-BG-XCXSNQG7-tsQwwvMW.js → bg-BG-XCXSNQG7-CS9_2dp-.js} +1 -1
  8. package/dist/assets/{blockDiagram-I7D4REHJ-V9bUuR63.js → blockDiagram-I7D4REHJ-FelDwD1I.js} +1 -1
  9. package/dist/assets/{bn-BD-2XOGV67Q-0Cou5nNv.js → bn-BD-2XOGV67Q-CoIu5tTK.js} +1 -1
  10. package/dist/assets/{c4Diagram-7LVT6UL2-BmCtzbrY.js → c4Diagram-7LVT6UL2-Bh7h9IHP.js} +1 -1
  11. package/dist/assets/{ca-ES-6MX7JW3Y-pZF7WJUL.js → ca-ES-6MX7JW3Y-DAEHzf3H.js} +1 -1
  12. package/dist/assets/channel-DXsl7ag_.js +1 -0
  13. package/dist/assets/{chunk-2Q5K7J3B-D2iTDmHh.js → chunk-2Q5K7J3B-CgUOCDxa.js} +1 -1
  14. package/dist/assets/{chunk-5VM5RSS4-CTxdXZIx.js → chunk-5VM5RSS4-B97oha-s.js} +1 -1
  15. package/dist/assets/{chunk-F27PBJKO-Hic1X1pm.js → chunk-F27PBJKO-BQGqI2Ej.js} +1 -1
  16. package/dist/assets/{chunk-IMKFNOWR-DhLW1JVb.js → chunk-IMKFNOWR-C_sOeFT_.js} +1 -1
  17. package/dist/assets/{chunk-JWPE2WC7-_g5twKlC.js → chunk-JWPE2WC7-DG5n2owX.js} +1 -1
  18. package/dist/assets/{chunk-POPQ4Y6H-DMV4qmkd.js → chunk-POPQ4Y6H-Y-h3THrr.js} +1 -1
  19. package/dist/assets/{chunk-SVP7TREG-BWg83oEL.js → chunk-SVP7TREG-Dn6yBHtF.js} +1 -1
  20. package/dist/assets/{chunk-TICWLB2K-CPmkpa7J.js → chunk-TICWLB2K-Cb_yWOVI.js} +1 -1
  21. package/dist/assets/{chunk-XXDRQBXY-KnXvIZ_8.js → chunk-XXDRQBXY-QE51OqTj.js} +1 -1
  22. package/dist/assets/classDiagram-ZZMXUADV-DLyWZtYF.js +1 -0
  23. package/dist/assets/classDiagram-v2-VYDZK3BY-Cb3mb68m.js +1 -0
  24. package/dist/assets/{cose-bilkent-JH36ORCC-BChK_CGh.js → cose-bilkent-JH36ORCC-Bt7ZI9S1.js} +1 -1
  25. package/dist/assets/{cs-CZ-2BRQDIVT-CtAC2Qjy.js → cs-CZ-2BRQDIVT-BKZzkx2M.js} +1 -1
  26. package/dist/assets/{cynefin-OW5HDTMX-CdsltaMX.js → cynefin-OW5HDTMX-n6-BmECj.js} +1 -1
  27. package/dist/assets/{cynefinDiagram-5FMLGOSQ-bXvXX3Fx.js → cynefinDiagram-5FMLGOSQ-Bq2km1fZ.js} +1 -1
  28. package/dist/assets/{d3-scale-sM87TD1Z.js → d3-scale-C9oJHYFk.js} +1 -1
  29. package/dist/assets/{da-DK-5WZEPLOC-DyWwaclV.js → da-DK-5WZEPLOC-DWJm1_Yl.js} +1 -1
  30. package/dist/assets/{dagre-GXQ25YYZ-CTmiZZVO.js → dagre-GXQ25YYZ-D9EJj_nK.js} +1 -1
  31. package/dist/assets/{de-DE-XR44H4JA-BDXUBHki.js → de-DE-XR44H4JA-D-5dMJXD.js} +1 -1
  32. package/dist/assets/{diagram-S7CK7UJ4-Bm8Fy0R_.js → diagram-S7CK7UJ4-DX3qZf_H.js} +1 -1
  33. package/dist/assets/{diagram-UQ7AKVKN-BU_AmM_A.js → diagram-UQ7AKVKN-lODsxrZ9.js} +1 -1
  34. package/dist/assets/{diagram-VSXAHHWV-B78LUoXq.js → diagram-VSXAHHWV-B48xz8Xq.js} +1 -1
  35. package/dist/assets/{diagram-VX7I27RA-DNvWjMlf.js → diagram-VX7I27RA-Dms2AfBa.js} +1 -1
  36. package/dist/assets/{diagram-Z3DM3KII-DmFVt1fa.js → diagram-Z3DM3KII-BnwZBeJA.js} +1 -1
  37. package/dist/assets/{ebnfDiagram-PWID7BFC-CpDna0Jp.js → ebnfDiagram-PWID7BFC-OtcCvaIU.js} +1 -1
  38. package/dist/assets/{el-GR-BZB4AONW-CNhF7oN2.js → el-GR-BZB4AONW-BZVA3YVN.js} +1 -1
  39. package/dist/assets/{engines-a8mi_N6S.js → engines-DPbXorS1.js} +1 -1
  40. package/dist/assets/{erDiagram-RLTQ6QDP-BGD-9OAS.js → erDiagram-RLTQ6QDP-Cnh8Gn9f.js} +1 -1
  41. package/dist/assets/{es-ES-U4NZUMDT-DXMrJcKL.js → es-ES-U4NZUMDT-DKJIfS-2.js} +1 -1
  42. package/dist/assets/{eu-ES-A7QVB2H4-BTkMEwMi.js → eu-ES-A7QVB2H4-LHCF7lHc.js} +1 -1
  43. package/dist/assets/{fa-IR-HGAKTJCU-CgkknSS7.js → fa-IR-HGAKTJCU-CMtLvHxY.js} +1 -1
  44. package/dist/assets/{fi-FI-Z5N7JZ37-B1K83nId.js → fi-FI-Z5N7JZ37-CUIzm5UM.js} +1 -1
  45. package/dist/assets/{flowDiagram-HODETNUW-CjU1yR1F.js → flowDiagram-HODETNUW-lneiCvFi.js} +1 -1
  46. package/dist/assets/{fr-FR-RHASNOE6-CBFZBGMr.js → fr-FR-RHASNOE6-DTJ2WS73.js} +1 -1
  47. package/dist/assets/{ganttDiagram-EL5Y4UJY-bvb8BjSh.js → ganttDiagram-EL5Y4UJY-B2aJ2MDb.js} +1 -1
  48. package/dist/assets/{gitGraphDiagram-WWUBYQGX-DZXQ_x8t.js → gitGraphDiagram-WWUBYQGX-C74V3MFm.js} +1 -1
  49. package/dist/assets/{gl-ES-HMX3MZ6V-CON98Mma.js → gl-ES-HMX3MZ6V-BP8M0fQQ.js} +1 -1
  50. package/dist/assets/{he-IL-6SHJWFNN-CBoFaEdB.js → he-IL-6SHJWFNN-BMd-Q0PW.js} +1 -1
  51. package/dist/assets/{hi-IN-IWLTKZ5I-BJuoh3dl.js → hi-IN-IWLTKZ5I-Ct52OkX5.js} +1 -1
  52. package/dist/assets/{hu-HU-A5ZG7DT2-CQruu8XR.js → hu-HU-A5ZG7DT2-NfIL6Jfo.js} +1 -1
  53. package/dist/assets/{id-ID-SAP4L64H-VhaoENjR.js → id-ID-SAP4L64H-Osl6P1wb.js} +1 -1
  54. package/dist/assets/index-CyQSsku0.js +624 -0
  55. package/dist/assets/{index-CDNl17QJ.css → index-DR6sd54W.css} +1 -1
  56. package/dist/assets/{index-CboxqaL5.js → index-VfiAlFSM.js} +5 -5
  57. package/dist/assets/{infoDiagram-27XIBGKW-CM9Hap0f.js → infoDiagram-27XIBGKW-BjDMKD-X.js} +1 -1
  58. package/dist/assets/{ishikawaDiagram-5VMMS53U-i8pQztJI.js → ishikawaDiagram-5VMMS53U-DjrBmz8f.js} +1 -1
  59. package/dist/assets/{it-IT-JPQ66NNP-Dj9BkXfh.js → it-IT-JPQ66NNP-vT-EYZw5.js} +1 -1
  60. package/dist/assets/{ja-JP-DBVTYXUO-CB2BlfIS.js → ja-JP-DBVTYXUO-DexyPC4p.js} +1 -1
  61. package/dist/assets/{journeyDiagram-3NMN7TZE-PxcdqONT.js → journeyDiagram-3NMN7TZE-Bs5RL4Ef.js} +1 -1
  62. package/dist/assets/{kaa-6HZHGXH3-CLnR_zY5.js → kaa-6HZHGXH3-0BLUFlXY.js} +1 -1
  63. package/dist/assets/{kab-KAB-ZGHBKWFO-8TJr4nPf.js → kab-KAB-ZGHBKWFO-ByGN5_Fc.js} +1 -1
  64. package/dist/assets/{kanban-definition-UXKFOSKX-B2p5NBhO.js → kanban-definition-UXKFOSKX-DgcopnbA.js} +1 -1
  65. package/dist/assets/{kk-KZ-P5N5QNE5-5uZYjZ2e.js → kk-KZ-P5N5QNE5-DlK-wQWu.js} +1 -1
  66. package/dist/assets/{km-KH-HSX4SM5Z-D54aOpMd.js → km-KH-HSX4SM5Z-BZ75967_.js} +1 -1
  67. package/dist/assets/{ko-KR-MTYHY66A-Bnm0G6eo.js → ko-KR-MTYHY66A-C-copauZ.js} +1 -1
  68. package/dist/assets/{ku-TR-6OUDTVRD-CtGCn_eB.js → ku-TR-6OUDTVRD-CNqY-Uj4.js} +1 -1
  69. package/dist/assets/{layout-BBV3_Svw.js → layout-B8D2HGrb.js} +1 -1
  70. package/dist/assets/{lt-LT-XHIRWOB4-Bl8G0yv6.js → lt-LT-XHIRWOB4-BopE_XJX.js} +1 -1
  71. package/dist/assets/{lv-LV-5QDEKY6T-Cax93Eua.js → lv-LV-5QDEKY6T--7hU3JSZ.js} +1 -1
  72. package/dist/assets/{mindmap-definition-YA3MSWOX-CsOezwmE.js → mindmap-definition-YA3MSWOX-DYOVTEyE.js} +1 -1
  73. package/dist/assets/{mr-IN-CRQNXWMA-Br7GVyJH.js → mr-IN-CRQNXWMA-DydjVI2G.js} +1 -1
  74. package/dist/assets/{my-MM-5M5IBNSE-xC6lzTDV.js → my-MM-5M5IBNSE-D6ewM-EV.js} +1 -1
  75. package/dist/assets/{nb-NO-T6EIAALU-B0i5THqA.js → nb-NO-T6EIAALU--iqOwj15.js} +1 -1
  76. package/dist/assets/{nl-NL-IS3SIHDZ-CqYhUjP3.js → nl-NL-IS3SIHDZ-Bnhl_SmS.js} +1 -1
  77. package/dist/assets/{nn-NO-6E72VCQL-rpjr_9Z5.js → nn-NO-6E72VCQL-CIx7sLAQ.js} +1 -1
  78. package/dist/assets/{oc-FR-POXYY2M6-BlhQ99Ty.js → oc-FR-POXYY2M6-DWt5a8Ow.js} +1 -1
  79. package/dist/assets/{pa-IN-N4M65BXN-N2XbQgZ_.js → pa-IN-N4M65BXN-BW3LNure.js} +1 -1
  80. package/dist/assets/{pegDiagram-XKGWAZYB-C2iSJgYQ.js → pegDiagram-XKGWAZYB-ixSY_9-e.js} +1 -1
  81. package/dist/assets/{pica-DvYcrBvx.js → pica-Dn0N8xAP.js} +1 -1
  82. package/dist/assets/{pieDiagram-E7YTZNPT-CUjgOGBw.js → pieDiagram-E7YTZNPT-BbCRV6Qi.js} +1 -1
  83. package/dist/assets/{pl-PL-T2D74RX3-CnMxn1dA.js → pl-PL-T2D74RX3-7nXJ8SiV.js} +1 -1
  84. package/dist/assets/{pt-BR-5N22H2LF-Di-jnHb3.js → pt-BR-5N22H2LF-DKGGof4J.js} +1 -1
  85. package/dist/assets/{pt-PT-UZXXM6DQ-BaAKq8Sh.js → pt-PT-UZXXM6DQ-DCLEXuhk.js} +1 -1
  86. package/dist/assets/{quadrantDiagram-AXDQQJYC-DwwqgJXZ.js → quadrantDiagram-AXDQQJYC-Bvh_H4wg.js} +1 -1
  87. package/dist/assets/{railroadDiagram-O6MQD6OU-DyRgYGPF.js → railroadDiagram-O6MQD6OU-DHC3neQ8.js} +1 -1
  88. package/dist/assets/{requirementDiagram-BXWQKSXE-C3ixXeHJ.js → requirementDiagram-BXWQKSXE-DuCkl3u1.js} +1 -1
  89. package/dist/assets/{ro-RO-JPDTUUEW-BWrclVyo.js → ro-RO-JPDTUUEW-Cwf4k3Ou.js} +1 -1
  90. package/dist/assets/{ru-RU-B4JR7IUQ-_z0DINaG.js → ru-RU-B4JR7IUQ-sZF6fySs.js} +1 -1
  91. package/dist/assets/{sankeyDiagram-P5KCCOFB-mKpKYI_w.js → sankeyDiagram-P5KCCOFB-1ELTqwtI.js} +1 -1
  92. package/dist/assets/{sequenceDiagram-WJ2MYXX4-ZkNd0Wnj.js → sequenceDiagram-WJ2MYXX4-BK8Ou8Dz.js} +1 -1
  93. package/dist/assets/{si-LK-N5RQ5JYF-CdKOb383.js → si-LK-N5RQ5JYF-DmYhXIqO.js} +1 -1
  94. package/dist/assets/{sizeCapture-INFHLROL-hQLGO-0z.js → sizeCapture-INFHLROL-BKwx3lxX.js} +1 -1
  95. package/dist/assets/{sk-SK-C5VTKIMK-MHJC6ZIe.js → sk-SK-C5VTKIMK-BRLu35YX.js} +1 -1
  96. package/dist/assets/{sl-SI-NN7IZMDC-BF9YWbZx.js → sl-SI-NN7IZMDC-CMjfvJTr.js} +1 -1
  97. package/dist/assets/{stateDiagram-D77RDMKH-CRWj3j-B.js → stateDiagram-D77RDMKH-CDwJ9XLN.js} +1 -1
  98. package/dist/assets/stateDiagram-v2-MP3YSRHH-BZjKARGY.js +1 -0
  99. package/dist/assets/{subset-shared.chunk-DtxXjVIA.js → subset-shared.chunk-DngAvf0H.js} +1 -1
  100. package/dist/assets/{subset-worker.chunk-DONNSbUF.js → subset-worker.chunk-DkH_mqr5.js} +1 -1
  101. package/dist/assets/{sv-SE-XGPEYMSR-DkaTkfUY.js → sv-SE-XGPEYMSR-G4S06sbd.js} +1 -1
  102. package/dist/assets/{swimlanes-42K2YHIH-CFf6j7jO.js → swimlanes-42K2YHIH-Z9u8PDi-.js} +1 -1
  103. package/dist/assets/swimlanesDiagram-VR7AAH4N-D0kM5xmS.js +8 -0
  104. package/dist/assets/{ta-IN-2NMHFXQM-BfxqXEDI.js → ta-IN-2NMHFXQM-DgBbCQ8S.js} +1 -1
  105. package/dist/assets/{th-TH-HPSO5L25-DT3vLA39.js → th-TH-HPSO5L25-o9u4fVfq.js} +1 -1
  106. package/dist/assets/{timeline-definition-24CTP7MA-BGP2Dq8M.js → timeline-definition-24CTP7MA-BNgrm1r_.js} +1 -1
  107. package/dist/assets/{tr-TR-DEFEU3FU-CdfsG7py.js → tr-TR-DEFEU3FU-BqqSdzoL.js} +1 -1
  108. package/dist/assets/{uk-UA-QMV73CPH-CZrQuC1S.js → uk-UA-QMV73CPH-Dna46aia.js} +1 -1
  109. package/dist/assets/{vennDiagram-4TSXK5OY-CaxGPIab.js → vennDiagram-4TSXK5OY-CHwUI40M.js} +1 -1
  110. package/dist/assets/{vi-VN-M7AON7JQ-DQJk1_KV.js → vi-VN-M7AON7JQ-CbKRBQPB.js} +1 -1
  111. package/dist/assets/{wardleyDiagram-VM6X3IG4-DQxQ-zXH.js → wardleyDiagram-VM6X3IG4-KB0xBjXX.js} +1 -1
  112. package/dist/assets/{xychartDiagram-S5SC5T6Z-DoxdZQ6R.js → xychartDiagram-S5SC5T6Z-B3LOQLL-.js} +1 -1
  113. package/dist/assets/{zh-CN-LNUGB5OW-DRVBfkOy.js → zh-CN-LNUGB5OW-BFjA6n_2.js} +1 -1
  114. package/dist/assets/{zh-HK-E62DVLB3-BJHrltss.js → zh-HK-E62DVLB3-BoTU6iS7.js} +1 -1
  115. package/dist/assets/{zh-TW-RAJ6MFWO-DpMZ5m2x.js → zh-TW-RAJ6MFWO-DB4kdpOS.js} +1 -1
  116. package/dist/index.html +2 -2
  117. package/docs/BUNDLE-FORMAT.md +18 -5
  118. package/docs/DIAGRAM-SOURCE.md +59 -12
  119. package/docs/LOCAL-DOCUMENT.md +42 -86
  120. package/docs/MODEL-CONTRACT.md +7 -4
  121. package/docs/PLANTUML-SOURCE.md +3 -2
  122. package/docs/VIEWER-LAUNCH.md +29 -22
  123. package/docs/VIEWER.md +93 -26
  124. package/docs/adr/ADR-002-2026-12-03-project-selector/ADR-002-2026-12-03-project-selector.md +1 -1
  125. package/docs/adr/ADR-005-2026-12-04-named-libraries/ADR-005-2026-12-04-named-libraries.md +1 -1
  126. package/docs/capabilities.json +21 -3
  127. package/package.json +2 -1
  128. package/scripts/build-map.mjs +1 -1
  129. package/scripts/lib/library-directory.mjs +1 -1
  130. package/scripts/lib/map-build-invocation.mjs +5 -1
  131. package/scripts/lib/map-viewer-server.mjs +195 -43
  132. package/scripts/lib/original-materials.mjs +1 -1
  133. package/scripts/lib/original-report-server.mjs +7 -3
  134. package/scripts/lib/project-catalog.mjs +264 -97
  135. package/scripts/lib/project-map-inputs.mjs +1 -1
  136. package/scripts/lib/project-registry.mjs +151 -47
  137. package/scripts/lib/sketch-publication.mjs +1 -1
  138. package/scripts/lib/task-map-build.mjs +1 -1
  139. package/scripts/lib/view-args.mjs +163 -0
  140. package/scripts/lib/workflow/reader-surface.mjs +29 -11
  141. package/scripts/locus-map.mjs +18 -23
  142. package/scripts/open-map.mjs +96 -51
  143. package/skills/README.md +2 -1
  144. package/skills/locus-map/SKILL.md +30 -26
  145. package/skills/locus-map/assets/artifact-handoff.md +2 -1
  146. package/skills/locus-map/references/build-environment.md +11 -7
  147. package/skills/locus-map/references/checks.md +16 -4
  148. package/skills/locus-map/references/component-checkpoint.md +35 -0
  149. package/skills/locus-map/references/draw-skill.md +2 -1
  150. package/skills/locus-map/references/folder.md +2 -2
  151. package/skills/locus-map/references/selection.md +36 -13
  152. package/skills/locus-map/references/task-maps.md +5 -0
  153. package/skills/locus-map/references/visual-composition.md +69 -0
  154. package/skills/locus-map-draft/SKILL.md +95 -0
  155. package/skills/locus-map-draft/assets/chosen-direction.md +47 -0
  156. package/skills/locus-map-draft/references/divergence-and-formats.md +78 -0
  157. package/skills/locus-map-primitives/SKILL.md +11 -10
  158. package/skills/locus-map-primitives/assets/batch/README.md +2 -2
  159. package/skills/locus-map-primitives/assets/batch/build.mjs +1 -1
  160. package/skills/locus-map-primitives/assets/batch/{project.json → topic.json} +13 -20
  161. package/skills/locus-map-primitives/references/card-presentation.md +57 -3
  162. package/skills/locus-map-primitives/references/reading-files.md +1 -1
  163. package/src/adapter/areas.js +1 -0
  164. package/src/adapter/semanticAdmission.js +118 -5
  165. package/src/authoring/buildDiagram.mjs +99 -19
  166. package/src/authoring/canvas-source-worker.mjs +96 -0
  167. package/src/authoring/canvasSource.mjs +41 -0
  168. package/src/authoring/diagramChecks.js +143 -1
  169. package/src/authoring/diagramSource.js +31 -5
  170. package/src/authoring/printPlantumlSource.js +13 -2
  171. package/src/authoring/readDetailsFiles.mjs +100 -19
  172. package/src/bundle/chain.js +129 -32
  173. package/src/bundle/chainBrowser.js +26 -2
  174. package/src/bundle/localDocument.mjs +87 -22
  175. package/src/bundle/localDocumentClient.js +5 -1
  176. package/src/bundle/projectClient.js +64 -21
  177. package/src/chain/validation.js +7 -1
  178. package/src/contract/readingMaterials.js +18 -2
  179. package/src/contract/readingTable.js +66 -0
  180. package/src/main.jsx +25 -1
  181. package/src/viewer/ControlIcon.jsx +3 -0
  182. package/src/viewer/DiagramViewer.jsx +70 -30
  183. package/src/viewer/EmbeddedExcalidrawEditor.jsx +305 -0
  184. package/src/viewer/HighlightOverlay.jsx +53 -25
  185. package/src/viewer/Inspector.jsx +109 -39
  186. package/src/viewer/ProjectLocation.jsx +25 -7
  187. package/src/viewer/ProjectRail.jsx +20 -7
  188. package/src/viewer/ProjectViewChainViewer.jsx +254 -83
  189. package/src/viewer/ReadingTable.jsx +151 -0
  190. package/src/viewer/SketchCanvas.jsx +133 -84
  191. package/src/viewer/ViewChainViewer.jsx +557 -57
  192. package/src/viewer/ViewerSettings.jsx +208 -0
  193. package/src/viewer/camera.js +50 -18
  194. package/src/viewer/chainEditorSession.js +160 -35
  195. package/src/viewer/chainInstallation.js +3 -3
  196. package/src/viewer/details/CanvasPreview.jsx +303 -0
  197. package/src/viewer/details/InspectorReadingSettings.jsx +50 -13
  198. package/src/viewer/details/ReadingFiles.jsx +32 -4
  199. package/src/viewer/details/details.css +65 -26
  200. package/src/viewer/diagramControls.css +1 -1
  201. package/src/viewer/fileError.js +53 -0
  202. package/src/viewer/geometry.js +12 -0
  203. package/src/viewer/inspectorPosition.js +54 -31
  204. package/src/viewer/projectContents.js +248 -55
  205. package/src/viewer/projectNavigation.js +27 -3
  206. package/src/viewer/readingTable.css +47 -0
  207. package/src/viewer/sketchSettling.js +71 -0
  208. package/src/viewer/useInspectorPosition.js +116 -35
  209. package/src/viewer/viewChain.css +92 -5
  210. package/src/viewer/viewer.css +23 -12
  211. package/dist/assets/channel-Dx9OTBrx.js +0 -1
  212. package/dist/assets/classDiagram-ZZMXUADV-Da4s894j.js +0 -1
  213. package/dist/assets/classDiagram-v2-VYDZK3BY--H9NrCfO.js +0 -1
  214. package/dist/assets/index-DBGHN_5E.js +0 -624
  215. package/dist/assets/stateDiagram-v2-MP3YSRHH-B2DcVJGG.js +0 -1
  216. package/dist/assets/swimlanesDiagram-VR7AAH4N-DO_W2uN2.js +0 -8
@@ -26,12 +26,13 @@
26
26
  "description": "Ordinary packet-free Draw source build. PlantUML is the text input; schema-v1 .map.json is the compatibility input. Both use the same Map compiler.",
27
27
  "limits": [
28
28
  "Draw bounds actual label placement work. A label-search refusal identifies the exhausted resource, the relationship being processed and diagram-wide label counts; see the source guide linked below.",
29
- "The optional --details-files index assigns local Markdown and static HTML to nodes or relations. The document packages reading text, tables and raster figures with the associated view. A {sourcePath} item links a repository original without packaging its content. Optional sourcePaths record the origins of embedded files. With --source-root, the bound local viewer opens an available original in Zed and assigned HTML on an isolated read-only report origin. The optional authored note precedes the first assigned document. Markdown renders pipe tables and LaTeX formulas and hides leading YAML metadata in the reader.",
29
+ "The optional --details-files index assigns local Markdown, static HTML, and depth-1 canvas files (.locus-map.json, .excalidraw, .puml, .map.json, .mjs; up to 16 distinct canvases) to nodes or relations. The document packages reading text, tables, raster figures, and admitted canvas payloads with the associated view. A {sourcePath} item links a repository original without packaging its content. Optional sourcePaths record the origins of embedded files. With --source-root, the bound local viewer opens an available original in Zed and assigned HTML on an isolated read-only report origin. Build-time .mjs canvas sources execute once from admitted bytes as trusted authoring code. The optional authored note precedes the first assigned document. Markdown renders pipe tables and LaTeX formulas and hides leading YAML metadata in the reader.",
30
30
  "Handwritten text and optional hatched card fill are independent of the semantics and relationship strokes.",
31
31
  "Draw owns the source language, source profiles and examples. Resolve @locus-forge/locus-draw/skill using the linked PlantUML guide rather than copying its catalog.",
32
32
  "Title-first editorial-v4 and c4-modern-v2 cards admit decision nodes, as do editorial-v3 and c4-modern-v1. These profiles and editorial-v2 support per-node catalog icons, shapes and badges. The viewer hydrates installed Draw artwork by full file ID, including the role ink of architecture icons, after v4 admission and exports standalone images.",
33
33
  "In editorial-v2 an author can omit the accent and repeat negative, caution or positive tones. Native legend samples follow the corresponding cards.",
34
34
  "The opt-in task-card-v1 profile displays header metadata, a complete title, description and optional expected outcome. These are authored source fields, not verified completion claims or inferred dependencies.",
35
+ "A JSON source can declare a readingTable with ordered rows, filter options and cells. The viewer shares node details between table and canvas.",
35
36
  "An optional readingTree declares ordered ownership edges for a foldable View projection. Edit and Save retain the full admitted drawing.",
36
37
  "The compiler creates one semantic view. C4 Component notation selects vocabulary and appearance; source areas are reading areas, not canonical contains ownership.",
37
38
  "The source subset has flow/data/call/dependency relations, without canonical contains or sequence/order. Do not infer a different family from a profile name.",
@@ -42,7 +43,7 @@
42
43
  { "path": "docs/PLANTUML-SOURCE.md" }
43
44
  ],
44
45
  "implementation": [
45
- { "path": "src/authoring/diagramSource.js", "line": 31 },
46
+ { "path": "src/authoring/diagramSource.js", "line": 51 },
46
47
  { "path": "src/authoring/buildDiagram.mjs", "line": 62 }
47
48
  ],
48
49
  "examples": [
@@ -142,6 +143,23 @@
142
143
  ],
143
144
  "docs": [{ "path": "docs/LOCAL-DOCUMENT.md" }]
144
145
  },
146
+ {
147
+ "text": "The Inspector renders attached depth-1 canvas diagrams (.locus-map.json, .excalidraw, and compiled sources) and linked ↘ detail targets inline via the official view-only Excalidraw preview (fetching cross-document project previews read-only without acquiring a write lock). Full-screen ↗ pop-out editing, internal child view return, and child SceneEditPrompt provenance save through the outer document's single file lock and revision while keeping parent camera and located-card state intact and placing the compact ← return pill in the existing location or breadcrumb row.",
148
+ "implementation": [
149
+ { "path": "src/contract/readingMaterials.js" },
150
+ { "path": "src/authoring/readDetailsFiles.mjs" },
151
+ { "path": "src/bundle/chain.js" },
152
+ { "path": "src/bundle/localDocument.mjs" },
153
+ { "path": "src/viewer/Inspector.jsx" },
154
+ { "path": "src/viewer/ViewChainViewer.jsx" },
155
+ { "path": "src/viewer/SceneEditPrompt.jsx" }
156
+ ],
157
+ "docs": [
158
+ { "path": "docs/DIAGRAM-SOURCE.md" },
159
+ { "path": "docs/BUNDLE-FORMAT.md" },
160
+ { "path": "docs/VIEWER.md" }
161
+ ]
162
+ },
145
163
  {
146
164
  "text": "Explicit positions and routes are admitted only for semantic/decision. component/sequence retain family placement; presentation areas do not create contains relations.",
147
165
  "implementation": [
@@ -210,7 +228,7 @@
210
228
  ],
211
229
  "implementation": [
212
230
  { "path": "src/contract/validation.js", "line": 23 },
213
- { "path": "src/authoring/diagramSource.js", "line": 102 },
231
+ { "path": "src/authoring/diagramSource.js", "line": 118 },
214
232
  { "path": "src/authoring/excalidrawDsl.js", "line": 28 }
215
233
  ],
216
234
  "evidence": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locus-forge/locus-map",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "author": "Locus Forge contributors",
6
6
  "private": false,
@@ -59,6 +59,7 @@
59
59
  "exports": {
60
60
  "./package.json": "./package.json",
61
61
  "./skill": "./skills/locus-map/SKILL.md",
62
+ "./draft-skill": "./skills/locus-map-draft/SKILL.md",
62
63
  "./primitives-skill": "./skills/locus-map-primitives/SKILL.md",
63
64
  "./research-skill": "./skills/locus-map-research/SKILL.md"
64
65
  },
@@ -23,7 +23,7 @@ Result file paths in stdout JSON (outputDir, bundlePath, pngPath, checkPath, sou
23
23
  current working directory; API paths are absolute. Pass an absolute path, e.g. "$PWD/<bundlePath>", to open-map --document
24
24
  and --previous-document. Import diagnostics may still carry the absolute source path.
25
25
  The separate research Pi workflow still requires chromiumPath.
26
- --details-files is only for --source. Each element lists packaged Markdown or HTML paths, or {sourcePath} entries for originals.
26
+ --details-files is only for --source. Each element lists packaged Markdown, HTML or canvas (.locus-map.json, .excalidraw, .puml, .map.json, .mjs) paths, or {sourcePath} entries for originals.
27
27
  Open an original in Zed by starting the viewer with --source-root DIR.
28
28
  --citation-bindings is only for --source: exact citation keys map to local source scopes.
29
29
  API/stdout and check.json include citationChecks; omitted bindings are unbound. Valid ranges never verify meaning.
@@ -16,7 +16,7 @@ export async function captureDirectory(directory, resolveAlias = true) {
16
16
 
17
17
  export async function bindPersonalLibrary(home) {
18
18
  const root = await fs.realpath(home);
19
- const filename = path.join(root, '.locusmap', 'maps');
19
+ const filename = path.join(root, '.locus-map', 'maps');
20
20
  const library = await captureDirectory(filename, false);
21
21
  if (library.identity) return library;
22
22
  const parent = await captureDirectory(path.dirname(filename), false);
@@ -1,3 +1,4 @@
1
+ import os from 'node:os';
1
2
  import path from 'node:path';
2
3
  import { isPortablePath } from '../../src/contract/safety.js';
3
4
 
@@ -46,5 +47,8 @@ export function rebuildCommand({ recipe, inputs, document }, repository, documen
46
47
  args.push('--' + key + '=' + argument);
47
48
  }
48
49
  args.push('--out-dir=' + out, '--record-for=' + document);
49
- return 'cd ' + shellArg(workingDirectory) + ' && LOCUS_MAP_PROJECTS_FILE=' + shellArg(registryFile) + ' locus-map build ' + args.map(shellArg).join(' ');
50
+ const defaultRegistry = path.join(os.homedir(), '.locus-map', 'projects.toml');
51
+ const envPrefix = registryFile && path.resolve(registryFile) !== path.resolve(defaultRegistry)
52
+ ? 'LOCUS_MAP_PROJECTS_FILE=' + shellArg(registryFile) + ' ' : '';
53
+ return 'cd ' + shellArg(workingDirectory) + ' && ' + envPrefix + 'locus-map build ' + args.map(shellArg).join(' ');
50
54
  }
@@ -7,7 +7,7 @@ import { openLocalDocument, openLocalDocumentForComparison, DocumentError } from
7
7
  import { loadChainBundle } from '../../src/bundle/chain.js';
8
8
  import { compareMapDocuments } from '../../src/authoring/sceneComparison.mjs';
9
9
  import { BUNDLE_LIMITS } from '../../src/bundle/safety.js';
10
- import { openProjectCatalog, openProjectLibrary, projectDiagnostic } from './project-catalog.mjs';
10
+ import { openProjectLibrary, projectDiagnostic } from './project-catalog.mjs';
11
11
  import { startOriginalReportServer } from './original-report-server.mjs';
12
12
  import { originalMaterials } from './original-materials.mjs';
13
13
  import { findZed, openInZed } from './zed.mjs';
@@ -76,16 +76,16 @@ async function saveInput(request) {
76
76
  return { revision, text: await jsonBody(request) };
77
77
  }
78
78
 
79
- /** Serves the assigned file or project, alongside a snapshot of compiled assets. */
80
- export async function startMapViewer({ filePath, projectPath, libraryRoot, registry, previousDocumentPath, sourceRoot, readOnly = false, port = 0, distDir = defaultDist }) {
81
- if ([filePath, projectPath, libraryRoot, registry].filter(Boolean).length !== 1 || (!filePath && previousDocumentPath !== undefined)) {
82
- throw new DocumentError('INVALID_PATH', 'Choose one document, project catalog, or project library.');
79
+ /** Serves the assigned file, topic folder, or workspace registry alongside compiled assets. */
80
+ export async function startMapViewer({ filePath, topicPath, libraryRoot, registry, previousDocumentPath, sourceRoot, readOnly = false, port = 0, distDir = defaultDist }) {
81
+ if ([filePath, topicPath, libraryRoot, registry].filter(Boolean).length !== 1 || (!filePath && previousDocumentPath !== undefined)) {
82
+ throw new DocumentError('INVALID_PATH', 'Choose one document, topic directory, or project library.');
83
83
  }
84
84
  const singleOriginals = await originalMaterials(sourceRoot);
85
85
  let reports;
86
86
  const assets = await staticFiles(distDir);
87
- const singleProject = libraryRoot ? await openProjectLibrary({ directory: libraryRoot, sourceRoot })
88
- : projectPath ? await openProjectCatalog({ projectPath, sourceRoot }) : null;
87
+ const singleProject = libraryRoot ? await openProjectLibrary({ directory: libraryRoot, sourceRoot, sketches: true })
88
+ : topicPath ? await openProjectLibrary({ libraryDirectory: topicPath, sourceRoot, sketches: true, scoped: true }) : null;
89
89
  const zed = registry || singleProject?.editorPaths ? await findZed() : null;
90
90
  const previous = previousDocumentPath === undefined ? null : await openLocalDocumentForComparison({ filePath: previousDocumentPath });
91
91
  let document;
@@ -101,24 +101,88 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
101
101
  const previousRevision = randomBytes(16).toString('hex');
102
102
  const capability = randomBytes(32).toString('hex');
103
103
  const discovery = registry && randomBytes(32).toString('hex');
104
+ const readOnlyWorkspaceLocation = (entryId, route) => {
105
+ const params = new URLSearchParams({ project: entryId });
106
+ if (route?.map) params.set('map', route.map);
107
+ if (route?.view) params.set('view', route.view);
108
+ if (route?.node) params.set('node', route.node);
109
+ return `/?${params.toString()}#workspace=${encodeURIComponent(discovery)}`;
110
+ };
104
111
  const singleContext = { project: singleProject, originals: singleOriginals };
105
112
  const projectMode = Boolean(singleProject || registry);
106
113
  const describe = (snapshot, originals) => originals && snapshot.kind !== 'sketch' ? originals.describe(snapshot, reports) : snapshot;
107
114
  let origin;
115
+ let boundPort = port;
116
+ let allowedHosts;
108
117
  const canWrite = request => !readOnly && authenticated(request.headers['x-locus-write'], capability);
118
+ const isWorkspaceOperator = request => Boolean(registry && authenticated(request.headers['x-locus-workspace'], discovery));
119
+
120
+ async function buildRuntimeInfo(request) {
121
+ const base = {
122
+ version: 1,
123
+ host: '127.0.0.1',
124
+ port: boundPort,
125
+ requestedPort: port,
126
+ pid: process.pid,
127
+ serverReadOnly: readOnly,
128
+ sessionWritable: canWrite(request),
129
+ zedAvailable: Boolean(zed),
130
+ };
131
+ if (registry) {
132
+ if (!isWorkspaceOperator(request)) {
133
+ return {
134
+ ...base,
135
+ launchMode: 'shared',
136
+ zedAvailable: false,
137
+ config: null,
138
+ target: null,
139
+ sourceRoot: null,
140
+ projects: [],
141
+ };
142
+ }
143
+ return {
144
+ ...base,
145
+ launchMode: 'workspace',
146
+ config: {
147
+ source: registry.configSource,
148
+ path: registry.configPath,
149
+ exists: registry.configExists,
150
+ },
151
+ target: null,
152
+ sourceRoot: null,
153
+ projects: await registry.runtimeProjects(),
154
+ };
155
+ }
156
+ return {
157
+ ...base,
158
+ launchMode: singleProject ? (singleProject.library?.scoped ? 'topic' : 'local-library') : 'single-document',
159
+ config: {
160
+ source: 'cli-target',
161
+ path: null,
162
+ exists: false,
163
+ },
164
+ target: singleProject?.library?.path ?? document?.path ?? null,
165
+ sourceRoot: sourceRoot ?? null,
166
+ projects: [],
167
+ };
168
+ }
169
+
109
170
  // A comparison failure never changes the confirmation of the main read/save.
110
- async function withComparison(saved) {
171
+ async function withComparison(saved, requestOrigin = origin) {
111
172
  if (!previous) return saved;
112
173
  let comparison;
113
174
  try {
114
175
  const snapshot = await previous.read();
115
- comparison = { status: 'available', scope: 'saved-documents',
116
- previous: { path: previous.path, url: snapshot.loaded.scenes ? `${origin}/?document=${encodeURIComponent(previous.path)}` : null },
176
+ comparison = {
177
+ status: 'available', scope: 'saved-documents',
178
+ previous: { path: previous.path, url: snapshot.loaded.scenes ? `${requestOrigin}/?document=${encodeURIComponent(previous.path)}` : null },
117
179
  report: compareMapDocuments({ previous: snapshot.loaded, candidate: await loadChainBundle(JSON.stringify(saved.bundle)) }),
118
180
  };
119
181
  } catch (error) {
120
- comparison = { status: 'unavailable', scope: 'saved-documents', code: error.code ?? 'COMPARISON_ERROR',
121
- message: 'Comparison unavailable; open it again. ' + error.message, previous: { path: previous.path, url: null } };
182
+ comparison = {
183
+ status: 'unavailable', scope: 'saved-documents', code: error.code ?? 'COMPARISON_ERROR',
184
+ message: 'Comparison unavailable; open it again. ' + error.message, previous: { path: previous.path, url: null },
185
+ };
122
186
  }
123
187
  return { ...saved, comparison };
124
188
  }
@@ -133,23 +197,54 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
133
197
  response.end(JSON.stringify(value));
134
198
  };
135
199
  try {
136
- if (request.headers.host !== new URL(origin).host
137
- || (request.headers.origin && request.headers.origin !== origin)) {
200
+ const requestHost = typeof request.headers.host === 'string' ? request.headers.host.toLowerCase() : '';
201
+ const requestOrigin = `http://${requestHost}`;
202
+ if (!allowedHosts.has(requestHost)
203
+ || (request.headers.origin && request.headers.origin !== requestOrigin)) {
138
204
  return json(403, { code: 'ORIGIN_REFUSED', message: 'The request must come from this local viewer.', outcome: 'rejected' });
139
205
  }
140
- const url = new URL(request.url, origin);
206
+ const url = new URL(request.url, requestOrigin);
141
207
  const rawPath = request.url.split('?')[0];
142
208
  if (!rawPath.startsWith('/') || rawPath !== url.pathname || /%(?:2f|5c|2e|25)/i.test(rawPath) || rawPath.includes('\\')) {
143
209
  return json(404, { code: 'PATH_REFUSED', message: 'Unknown asset path.', outcome: 'rejected' });
144
210
  }
211
+ if (url.pathname === '/api/runtime') {
212
+ if (request.method !== 'GET') return json(405, { code: 'METHOD_REFUSED', message: 'Method not supported.' });
213
+ if (request.headers['sec-fetch-site'] === 'cross-site') {
214
+ return json(403, { code: 'ORIGIN_REFUSED', message: 'The request must come from this local viewer.', outcome: 'rejected' });
215
+ }
216
+ return json(200, await buildRuntimeInfo(request));
217
+ }
218
+ if (url.pathname === '/api/runtime/zed') {
219
+ if (request.method !== 'POST' || request.headers.origin !== requestOrigin || request.headers['x-locus-action'] !== 'open-in-zed') {
220
+ return json(403, { message: 'Open Zed from this local viewer.' });
221
+ }
222
+ if (registry && !isWorkspaceOperator(request)) {
223
+ return json(403, { code: 'WORKSPACE_REFUSED', message: 'Open the operator launch address to access configuration.' });
224
+ }
225
+ if (!zed) return json(409, { message: 'The Zed command is unavailable on the viewer host.' });
226
+ if (!registry?.configExists || !registry?.file) {
227
+ return json(404, { message: 'No configuration file exists on disk for this launch.' });
228
+ }
229
+ try { await openInZed(zed, [registry.file]); }
230
+ catch { return json(409, { message: 'Zed could not open the configuration file.' }); }
231
+ return json(200, { opened: true });
232
+ }
233
+ if (registry && url.pathname === '/api/entry') {
234
+ if (request.method !== 'GET') return json(405, { code: 'METHOD_REFUSED', message: 'Method not supported.' });
235
+ if (request.headers['sec-fetch-site'] === 'cross-site') {
236
+ return json(403, { code: 'ORIGIN_REFUSED', message: 'The request must come from this local viewer.', outcome: 'rejected' });
237
+ }
238
+ return json(200, { project: registry.entry, workspace: discovery });
239
+ }
145
240
  if (registry && url.pathname === '/api/projects') {
146
- if (request.method !== 'GET' || !authenticated(request.headers['x-locus-workspace'], discovery)) {
241
+ if (request.method !== 'GET' || !isWorkspaceOperator(request)) {
147
242
  return json(403, { code: 'WORKSPACE_REFUSED', message: 'Open the operator launch address to switch projects.' });
148
243
  }
149
244
  return json(200, { projects: registry.list });
150
245
  }
151
246
  if (registry && url.pathname === '/api/project/map-inputs') {
152
- if (request.method !== 'GET' || !authenticated(request.headers['x-locus-workspace'], discovery)) {
247
+ if (request.method !== 'GET' || !isWorkspaceOperator(request)) {
153
248
  return json(403, { message: 'Open the project from its operator launch address.' });
154
249
  }
155
250
  const query = url.searchParams;
@@ -157,7 +252,7 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
157
252
  return json(200, await registry.readMapInputs(query.get('project'), query.get('map')));
158
253
  }
159
254
  if (registry && url.pathname === '/api/project/tasks') {
160
- if (request.method !== 'GET' || !authenticated(request.headers['x-locus-workspace'], discovery)) {
255
+ if (request.method !== 'GET' || !isWorkspaceOperator(request)) {
161
256
  return json(403, { message: 'Open Tasks from the operator launch address.' });
162
257
  }
163
258
  const query = url.searchParams;
@@ -169,7 +264,7 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
169
264
  }
170
265
  const context = () => registry ? registry.get(url.searchParams.get('project')) : singleContext;
171
266
  if (url.pathname === '/api/original') {
172
- if (request.method !== 'POST' || request.headers.origin !== origin || request.headers['x-locus-action'] !== 'open-in-zed') {
267
+ if (request.method !== 'POST' || request.headers.origin !== requestOrigin || request.headers['x-locus-action'] !== 'open-in-zed') {
173
268
  return json(403, { message: 'Open the source from its local viewer.' });
174
269
  }
175
270
  const query = url.searchParams;
@@ -188,12 +283,16 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
188
283
  return result.opened ? json(200, result) : json(409, { message: result.reason });
189
284
  }
190
285
  if ((registry || singleProject?.editorPaths) && url.pathname === '/api/project/zed') {
191
- if (request.method !== 'POST' || request.headers.origin !== origin || request.headers['x-locus-action'] !== 'open-in-zed') {
286
+ if (request.method !== 'POST' || request.headers.origin !== requestOrigin || request.headers['x-locus-action'] !== 'open-in-zed') {
192
287
  return json(403, { message: 'Open Zed from this local project viewer.' });
193
288
  }
194
289
  const query = url.searchParams;
195
290
  const map = query.get('map');
196
- if (!query.has('project') || query.size !== (map === null ? 1 : 2)) {
291
+ const target = query.get('target') ?? 'document';
292
+ const allowedKeys = new Set(['project', ...(map !== null ? ['map'] : []), ...(query.has('target') ? ['target'] : [])]);
293
+ if (!query.has('project') || !['document', 'source'].includes(target)
294
+ || (target === 'source' && map === null)
295
+ || [...query.keys()].some(key => !allowedKeys.has(key) || query.getAll(key).length !== 1)) {
197
296
  return json(404, { message: 'This address is not assigned to this viewer project.' });
198
297
  }
199
298
  const { project } = await context();
@@ -201,14 +300,14 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
201
300
  return json(404, { message: 'This address is not assigned to this viewer project.' });
202
301
  }
203
302
  if (!zed) return json(409, { message: 'The Zed command is unavailable on the viewer host.' });
204
- const paths = await project.editorPaths(map);
303
+ const paths = await project.editorPaths(map, target);
205
304
  try { await openInZed(zed, paths); }
206
305
  catch { return json(409, { message: 'Zed could not open the requested project or map.' }); }
207
306
  return json(200, { opened: true });
208
307
  }
209
- if (registry && url.pathname === '/api/project/sketch') {
308
+ if ((registry || singleProject?.library?.sketches) && url.pathname === '/api/project/sketch') {
210
309
  if (request.method !== 'POST') return json(405, { code: 'METHOD_REFUSED', message: 'Method not supported.' });
211
- if (request.headers.origin !== origin || !canWrite(request)) {
310
+ if (request.headers.origin !== requestOrigin || !canWrite(request)) {
212
311
  return json(403, { code: 'READ_ONLY', message: 'No permission to create a drawing.', outcome: 'rejected' });
213
312
  }
214
313
  const query = url.searchParams;
@@ -230,7 +329,7 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
230
329
  if (!reading && (request.method !== 'POST' || catalogRequest)) {
231
330
  return json(405, { code: 'METHOD_REFUSED', message: 'Method not supported.', outcome: 'rejected' });
232
331
  }
233
- if (!reading && (request.headers.origin !== origin || !canWrite(request))) {
332
+ if (!reading && (request.headers.origin !== requestOrigin || !canWrite(request))) {
234
333
  return json(403, { code: 'READ_ONLY', message: 'No permission to write this document.', outcome: 'rejected' });
235
334
  }
236
335
  const { project, originals } = await context();
@@ -240,7 +339,8 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
240
339
  if (reading) {
241
340
  if (!catalogRequest) return json(200, await describe(await project.read(map, canWrite(request)), originals));
242
341
  const catalog = await project.catalog(refresh);
243
- return json(200, { ...catalog,
342
+ return json(200, {
343
+ ...catalog,
244
344
  ...(project.library && { library: { ...project.library, zedAvailable: Boolean(zed) } }),
245
345
  ...(catalog.workspace && { workspace: { ...catalog.workspace, zedAvailable: Boolean(zed) } }),
246
346
  });
@@ -258,28 +358,65 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
258
358
  if (!snapshot.loaded.scenes) throw new DocumentError('UNSUPPORTED_MAPPING_VERSION', 'The presentation of the previous version is not supported; only a limited mapping is available.');
259
359
  return json(200, { path: previous.path, revision: previousRevision, readOnly: true, bundle: snapshot.loaded.bundle });
260
360
  }
261
- if (request.method === 'GET') return json(200, await describe(await withComparison(await document.read()), singleOriginals));
361
+ if (request.method === 'GET') return json(200, await describe(await withComparison(await document.read(), requestOrigin), singleOriginals));
262
362
  if (request.method !== 'POST') return json(405, { code: 'METHOD_REFUSED', message: 'Method not supported.', outcome: 'rejected' });
263
- if (request.headers.origin !== origin || !canWrite(request)) {
363
+ if (request.headers.origin !== requestOrigin || !canWrite(request)) {
264
364
  return json(403, { code: 'READ_ONLY', message: 'No permission to write this document.', outcome: 'rejected' });
265
365
  }
266
366
  const confirmed = await document.save(await saveInput(request));
267
- return json(200, await withComparison(confirmed));
367
+ return json(200, await withComparison(confirmed, requestOrigin));
268
368
  }
269
369
  if (!['GET', 'HEAD'].includes(request.method)) return json(405, { code: 'METHOD_REFUSED', message: 'Method not supported.' });
370
+ if (registry && url.pathname === '/' && url.search !== '') {
371
+ const keys = [...url.searchParams.keys()];
372
+ const hasSelector = keys.includes('cwd') || keys.includes('tab');
373
+ const allowedKeys = new Set(['cwd', 'tab', 'map', 'view', 'node']);
374
+ const validSelector = hasSelector && keys.every(key => allowedKeys.has(key) && url.searchParams.getAll(key).length === 1);
375
+ if (validSelector) {
376
+ const targetId = await registry.resolveEntry({ cwd: url.searchParams.get('cwd'), tab: url.searchParams.get('tab') });
377
+ const requestedMap = url.searchParams.get('map');
378
+ let requestedView = url.searchParams.get('view');
379
+ const requestedNode = url.searchParams.get('node');
380
+ let route;
381
+ if (requestedMap) {
382
+ try {
383
+ const { project } = await registry.get(targetId);
384
+ const catalog = await project.catalog(!project.includes(requestedMap));
385
+ const member = catalog.documents.find(doc => doc.id === requestedMap);
386
+ if (member?.views?.length) {
387
+ requestedView ??= member.views[0].id;
388
+ if (member.views.some(view => view.id === requestedView)) {
389
+ route = { map: requestedMap, view: requestedView, ...(requestedNode && { node: requestedNode }) };
390
+ }
391
+ }
392
+ } catch { /* Fall back to selecting the tab entry when deep-link map is unavailable. */ }
393
+ }
394
+ response.writeHead(302, { Location: readOnlyWorkspaceLocation(targetId, route) });
395
+ response.end();
396
+ return;
397
+ }
398
+ }
270
399
  const asset = assets.get(url.pathname);
271
400
  if (!asset) return json(404, { code: 'NOT_FOUND', message: 'The asset is not assigned to the viewer.' });
272
401
  response.writeHead(200, { 'Content-Type': asset.type, 'Content-Length': asset.bytes.length });
273
402
  response.end(request.method === 'HEAD' ? undefined : asset.bytes);
274
403
  } catch (error) {
275
404
  const problem = (singleProject || registry) ? projectDiagnostic(error) : { code: error.code ?? 'DOCUMENT_ERROR', message: error.message };
276
- const status = { BODY_LIMIT: 413, CONTENT_TYPE: 415, DOCUMENT_CHANGED: 409, NAME_CONFLICT: 409, SKETCH_CREATE_UNCONFIRMED: 409,
277
- ...((singleProject || registry) && { DOCUMENT_MISSING: 404, PROJECT_UNAVAILABLE: 409, PROJECT_ADDRESS_NOT_FOUND: 404, READ_ONLY: 403 }) };
405
+ const status = {
406
+ BODY_LIMIT: 413, CONTENT_TYPE: 415, DOCUMENT_CHANGED: 409, NAME_CONFLICT: 409, SKETCH_CREATE_UNCONFIRMED: 409,
407
+ ...((singleProject || registry) && { DOCUMENT_MISSING: 404, PROJECT_UNAVAILABLE: 409, PROJECT_ADDRESS_NOT_FOUND: 404, READ_ONLY: 403 }),
408
+ };
278
409
  json(status[problem.code] ?? 400, { ...problem, outcome: error.outcome ?? 'rejected' });
279
410
  }
280
411
  });
281
412
  const sockets = new Set();
282
- server.on('connection', socket => { sockets.add(socket); socket.once('close', () => sockets.delete(socket)); });
413
+ let closing;
414
+ let serverClosed = false;
415
+ server.on('connection', socket => {
416
+ if (closing) { socket.destroy(); return; }
417
+ sockets.add(socket);
418
+ socket.once('close', () => sockets.delete(socket));
419
+ });
283
420
  server.requestTimeout = 30000;
284
421
  server.headersTimeout = 10000;
285
422
  try {
@@ -292,7 +429,9 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
292
429
  server.once('error', reject);
293
430
  server.listen(port, '127.0.0.1', resolve);
294
431
  });
295
- origin = `http://127.0.0.1:${server.address().port}`;
432
+ boundPort = server.address().port;
433
+ origin = `http://127.0.0.1:${boundPort}`;
434
+ allowedHosts = new Set([`127.0.0.1:${boundPort}`, `localhost:${boundPort}`]);
296
435
  } catch (error) { await reports?.close(); await document?.close(); await previous?.close(); await singleProject?.close(); await registry?.close(); throw error; }
297
436
  const launch = new URL('/', origin);
298
437
  if (registry) launch.searchParams.set('project', registry.entry);
@@ -303,20 +442,33 @@ export async function startMapViewer({ filePath, projectPath, libraryRoot, regis
303
442
  if (registry) fragment.set('workspace', discovery);
304
443
  launch.hash = fragment.toString();
305
444
  const url = launch.href;
306
- let closing;
445
+ const destroyConnections = () => {
446
+ server.closeAllConnections?.();
447
+ for (const socket of sockets) socket.destroy();
448
+ };
307
449
  return {
308
450
  url,
309
451
  documentPath: document?.path,
310
452
  previousDocumentPath: previous?.path,
311
- close: ({ force = false } = {}) => closing ??= (async () => {
312
- const closed = new Promise((resolve, reject) => server.close(error => error ? reject(error) : resolve()));
313
- if (force) for (const socket of sockets) socket.destroy();
314
- try { await Promise.all([closed, reports?.close()]); }
315
- finally {
316
- if (registry) await registry.close();
317
- else if (singleProject) await singleProject.close();
318
- else try { await document.close(); } finally { await previous?.close(); }
453
+ close: ({ force = false } = {}) => {
454
+ if (!closing) {
455
+ closing = (async () => {
456
+ const closed = new Promise((resolve, reject) => server.close(error => error ? reject(error) : resolve()));
457
+ server.closeIdleConnections?.();
458
+ for (const socket of sockets) if (socket.bytesRead === 0 && !socket._httpMessage) socket.destroy();
459
+ if (force) destroyConnections();
460
+ try { await Promise.all([closed, reports?.close()]); }
461
+ finally {
462
+ serverClosed = true;
463
+ if (registry) await registry.close();
464
+ else if (singleProject) await singleProject.close();
465
+ else try { await document.close(); } finally { await previous?.close(); }
466
+ }
467
+ })();
468
+ } else if (force && !serverClosed) {
469
+ destroyConnections();
319
470
  }
320
- })(),
471
+ return closing;
472
+ },
321
473
  };
322
474
  }
@@ -24,7 +24,7 @@ export async function originalMaterials(sourceRoot, expectedIdentity) {
24
24
 
25
25
  async function locate(file) {
26
26
  if (!projectRoot) return { reason: 'The declared source root is unavailable. Restart the viewer with its repository directory.' };
27
- if (!isPortablePath(file?.sourcePath) || !['markdown', 'report', 'original'].includes(file.kind)) {
27
+ if (!isPortablePath(file?.sourcePath) || !['markdown', 'report', 'original', 'canvas'].includes(file.kind)) {
28
28
  return { reason: unavailable };
29
29
  }
30
30
  const candidate = path.join(root, file.sourcePath);
@@ -36,6 +36,7 @@ export async function startOriginalReportServer(readOriginal) {
36
36
  server.listen(0, '127.0.0.1', resolve);
37
37
  });
38
38
  const host = '127.0.0.1:' + server.address().port;
39
+ let closing;
39
40
  return {
40
41
  links(map, files, project) {
41
42
  return Object.fromEntries(files.map(([id, sourcePath]) => {
@@ -44,9 +45,12 @@ export async function startOriginalReportServer(readOriginal) {
44
45
  }));
45
46
  },
46
47
  close() {
47
- const closed = new Promise((resolve, reject) => server.close(error => error ? reject(error) : resolve()));
48
- server.closeAllConnections();
49
- return closed;
48
+ return closing ??= (() => {
49
+ const closed = new Promise((resolve, reject) => server.close(error => error ? reject(error) : resolve()));
50
+ server.closeIdleConnections?.();
51
+ server.closeAllConnections?.();
52
+ return closed;
53
+ })();
50
54
  },
51
55
  };
52
56
  }