@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.
- package/CONTRIBUTING.md +2 -2
- package/README.md +21 -6
- package/dist/assets/{abnfDiagram-VCTEODGH-BnTGKKaL.js → abnfDiagram-VCTEODGH-YtlnkH6t.js} +1 -1
- package/dist/assets/{ar-SA-G6X2FPQ2-LY3czoz9.js → ar-SA-G6X2FPQ2-BH5AlOAp.js} +1 -1
- package/dist/assets/{architectureDiagram-5GKGNRK7-BG9h9KRx.js → architectureDiagram-5GKGNRK7-DKYw7IM8.js} +1 -1
- package/dist/assets/{az-AZ-76LH7QW2-Brv6kuM6.js → az-AZ-76LH7QW2-DoI4xcyq.js} +1 -1
- package/dist/assets/{bg-BG-XCXSNQG7-tsQwwvMW.js → bg-BG-XCXSNQG7-CS9_2dp-.js} +1 -1
- package/dist/assets/{blockDiagram-I7D4REHJ-V9bUuR63.js → blockDiagram-I7D4REHJ-FelDwD1I.js} +1 -1
- package/dist/assets/{bn-BD-2XOGV67Q-0Cou5nNv.js → bn-BD-2XOGV67Q-CoIu5tTK.js} +1 -1
- package/dist/assets/{c4Diagram-7LVT6UL2-BmCtzbrY.js → c4Diagram-7LVT6UL2-Bh7h9IHP.js} +1 -1
- package/dist/assets/{ca-ES-6MX7JW3Y-pZF7WJUL.js → ca-ES-6MX7JW3Y-DAEHzf3H.js} +1 -1
- package/dist/assets/channel-DXsl7ag_.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-D2iTDmHh.js → chunk-2Q5K7J3B-CgUOCDxa.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-CTxdXZIx.js → chunk-5VM5RSS4-B97oha-s.js} +1 -1
- package/dist/assets/{chunk-F27PBJKO-Hic1X1pm.js → chunk-F27PBJKO-BQGqI2Ej.js} +1 -1
- package/dist/assets/{chunk-IMKFNOWR-DhLW1JVb.js → chunk-IMKFNOWR-C_sOeFT_.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-_g5twKlC.js → chunk-JWPE2WC7-DG5n2owX.js} +1 -1
- package/dist/assets/{chunk-POPQ4Y6H-DMV4qmkd.js → chunk-POPQ4Y6H-Y-h3THrr.js} +1 -1
- package/dist/assets/{chunk-SVP7TREG-BWg83oEL.js → chunk-SVP7TREG-Dn6yBHtF.js} +1 -1
- package/dist/assets/{chunk-TICWLB2K-CPmkpa7J.js → chunk-TICWLB2K-Cb_yWOVI.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-KnXvIZ_8.js → chunk-XXDRQBXY-QE51OqTj.js} +1 -1
- package/dist/assets/classDiagram-ZZMXUADV-DLyWZtYF.js +1 -0
- package/dist/assets/classDiagram-v2-VYDZK3BY-Cb3mb68m.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-BChK_CGh.js → cose-bilkent-JH36ORCC-Bt7ZI9S1.js} +1 -1
- package/dist/assets/{cs-CZ-2BRQDIVT-CtAC2Qjy.js → cs-CZ-2BRQDIVT-BKZzkx2M.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-CdsltaMX.js → cynefin-OW5HDTMX-n6-BmECj.js} +1 -1
- package/dist/assets/{cynefinDiagram-5FMLGOSQ-bXvXX3Fx.js → cynefinDiagram-5FMLGOSQ-Bq2km1fZ.js} +1 -1
- package/dist/assets/{d3-scale-sM87TD1Z.js → d3-scale-C9oJHYFk.js} +1 -1
- package/dist/assets/{da-DK-5WZEPLOC-DyWwaclV.js → da-DK-5WZEPLOC-DWJm1_Yl.js} +1 -1
- package/dist/assets/{dagre-GXQ25YYZ-CTmiZZVO.js → dagre-GXQ25YYZ-D9EJj_nK.js} +1 -1
- package/dist/assets/{de-DE-XR44H4JA-BDXUBHki.js → de-DE-XR44H4JA-D-5dMJXD.js} +1 -1
- package/dist/assets/{diagram-S7CK7UJ4-Bm8Fy0R_.js → diagram-S7CK7UJ4-DX3qZf_H.js} +1 -1
- package/dist/assets/{diagram-UQ7AKVKN-BU_AmM_A.js → diagram-UQ7AKVKN-lODsxrZ9.js} +1 -1
- package/dist/assets/{diagram-VSXAHHWV-B78LUoXq.js → diagram-VSXAHHWV-B48xz8Xq.js} +1 -1
- package/dist/assets/{diagram-VX7I27RA-DNvWjMlf.js → diagram-VX7I27RA-Dms2AfBa.js} +1 -1
- package/dist/assets/{diagram-Z3DM3KII-DmFVt1fa.js → diagram-Z3DM3KII-BnwZBeJA.js} +1 -1
- package/dist/assets/{ebnfDiagram-PWID7BFC-CpDna0Jp.js → ebnfDiagram-PWID7BFC-OtcCvaIU.js} +1 -1
- package/dist/assets/{el-GR-BZB4AONW-CNhF7oN2.js → el-GR-BZB4AONW-BZVA3YVN.js} +1 -1
- package/dist/assets/{engines-a8mi_N6S.js → engines-DPbXorS1.js} +1 -1
- package/dist/assets/{erDiagram-RLTQ6QDP-BGD-9OAS.js → erDiagram-RLTQ6QDP-Cnh8Gn9f.js} +1 -1
- package/dist/assets/{es-ES-U4NZUMDT-DXMrJcKL.js → es-ES-U4NZUMDT-DKJIfS-2.js} +1 -1
- package/dist/assets/{eu-ES-A7QVB2H4-BTkMEwMi.js → eu-ES-A7QVB2H4-LHCF7lHc.js} +1 -1
- package/dist/assets/{fa-IR-HGAKTJCU-CgkknSS7.js → fa-IR-HGAKTJCU-CMtLvHxY.js} +1 -1
- package/dist/assets/{fi-FI-Z5N7JZ37-B1K83nId.js → fi-FI-Z5N7JZ37-CUIzm5UM.js} +1 -1
- package/dist/assets/{flowDiagram-HODETNUW-CjU1yR1F.js → flowDiagram-HODETNUW-lneiCvFi.js} +1 -1
- package/dist/assets/{fr-FR-RHASNOE6-CBFZBGMr.js → fr-FR-RHASNOE6-DTJ2WS73.js} +1 -1
- package/dist/assets/{ganttDiagram-EL5Y4UJY-bvb8BjSh.js → ganttDiagram-EL5Y4UJY-B2aJ2MDb.js} +1 -1
- package/dist/assets/{gitGraphDiagram-WWUBYQGX-DZXQ_x8t.js → gitGraphDiagram-WWUBYQGX-C74V3MFm.js} +1 -1
- package/dist/assets/{gl-ES-HMX3MZ6V-CON98Mma.js → gl-ES-HMX3MZ6V-BP8M0fQQ.js} +1 -1
- package/dist/assets/{he-IL-6SHJWFNN-CBoFaEdB.js → he-IL-6SHJWFNN-BMd-Q0PW.js} +1 -1
- package/dist/assets/{hi-IN-IWLTKZ5I-BJuoh3dl.js → hi-IN-IWLTKZ5I-Ct52OkX5.js} +1 -1
- package/dist/assets/{hu-HU-A5ZG7DT2-CQruu8XR.js → hu-HU-A5ZG7DT2-NfIL6Jfo.js} +1 -1
- package/dist/assets/{id-ID-SAP4L64H-VhaoENjR.js → id-ID-SAP4L64H-Osl6P1wb.js} +1 -1
- package/dist/assets/index-CyQSsku0.js +624 -0
- package/dist/assets/{index-CDNl17QJ.css → index-DR6sd54W.css} +1 -1
- package/dist/assets/{index-CboxqaL5.js → index-VfiAlFSM.js} +5 -5
- package/dist/assets/{infoDiagram-27XIBGKW-CM9Hap0f.js → infoDiagram-27XIBGKW-BjDMKD-X.js} +1 -1
- package/dist/assets/{ishikawaDiagram-5VMMS53U-i8pQztJI.js → ishikawaDiagram-5VMMS53U-DjrBmz8f.js} +1 -1
- package/dist/assets/{it-IT-JPQ66NNP-Dj9BkXfh.js → it-IT-JPQ66NNP-vT-EYZw5.js} +1 -1
- package/dist/assets/{ja-JP-DBVTYXUO-CB2BlfIS.js → ja-JP-DBVTYXUO-DexyPC4p.js} +1 -1
- package/dist/assets/{journeyDiagram-3NMN7TZE-PxcdqONT.js → journeyDiagram-3NMN7TZE-Bs5RL4Ef.js} +1 -1
- package/dist/assets/{kaa-6HZHGXH3-CLnR_zY5.js → kaa-6HZHGXH3-0BLUFlXY.js} +1 -1
- package/dist/assets/{kab-KAB-ZGHBKWFO-8TJr4nPf.js → kab-KAB-ZGHBKWFO-ByGN5_Fc.js} +1 -1
- package/dist/assets/{kanban-definition-UXKFOSKX-B2p5NBhO.js → kanban-definition-UXKFOSKX-DgcopnbA.js} +1 -1
- package/dist/assets/{kk-KZ-P5N5QNE5-5uZYjZ2e.js → kk-KZ-P5N5QNE5-DlK-wQWu.js} +1 -1
- package/dist/assets/{km-KH-HSX4SM5Z-D54aOpMd.js → km-KH-HSX4SM5Z-BZ75967_.js} +1 -1
- package/dist/assets/{ko-KR-MTYHY66A-Bnm0G6eo.js → ko-KR-MTYHY66A-C-copauZ.js} +1 -1
- package/dist/assets/{ku-TR-6OUDTVRD-CtGCn_eB.js → ku-TR-6OUDTVRD-CNqY-Uj4.js} +1 -1
- package/dist/assets/{layout-BBV3_Svw.js → layout-B8D2HGrb.js} +1 -1
- package/dist/assets/{lt-LT-XHIRWOB4-Bl8G0yv6.js → lt-LT-XHIRWOB4-BopE_XJX.js} +1 -1
- package/dist/assets/{lv-LV-5QDEKY6T-Cax93Eua.js → lv-LV-5QDEKY6T--7hU3JSZ.js} +1 -1
- package/dist/assets/{mindmap-definition-YA3MSWOX-CsOezwmE.js → mindmap-definition-YA3MSWOX-DYOVTEyE.js} +1 -1
- package/dist/assets/{mr-IN-CRQNXWMA-Br7GVyJH.js → mr-IN-CRQNXWMA-DydjVI2G.js} +1 -1
- package/dist/assets/{my-MM-5M5IBNSE-xC6lzTDV.js → my-MM-5M5IBNSE-D6ewM-EV.js} +1 -1
- package/dist/assets/{nb-NO-T6EIAALU-B0i5THqA.js → nb-NO-T6EIAALU--iqOwj15.js} +1 -1
- package/dist/assets/{nl-NL-IS3SIHDZ-CqYhUjP3.js → nl-NL-IS3SIHDZ-Bnhl_SmS.js} +1 -1
- package/dist/assets/{nn-NO-6E72VCQL-rpjr_9Z5.js → nn-NO-6E72VCQL-CIx7sLAQ.js} +1 -1
- package/dist/assets/{oc-FR-POXYY2M6-BlhQ99Ty.js → oc-FR-POXYY2M6-DWt5a8Ow.js} +1 -1
- package/dist/assets/{pa-IN-N4M65BXN-N2XbQgZ_.js → pa-IN-N4M65BXN-BW3LNure.js} +1 -1
- package/dist/assets/{pegDiagram-XKGWAZYB-C2iSJgYQ.js → pegDiagram-XKGWAZYB-ixSY_9-e.js} +1 -1
- package/dist/assets/{pica-DvYcrBvx.js → pica-Dn0N8xAP.js} +1 -1
- package/dist/assets/{pieDiagram-E7YTZNPT-CUjgOGBw.js → pieDiagram-E7YTZNPT-BbCRV6Qi.js} +1 -1
- package/dist/assets/{pl-PL-T2D74RX3-CnMxn1dA.js → pl-PL-T2D74RX3-7nXJ8SiV.js} +1 -1
- package/dist/assets/{pt-BR-5N22H2LF-Di-jnHb3.js → pt-BR-5N22H2LF-DKGGof4J.js} +1 -1
- package/dist/assets/{pt-PT-UZXXM6DQ-BaAKq8Sh.js → pt-PT-UZXXM6DQ-DCLEXuhk.js} +1 -1
- package/dist/assets/{quadrantDiagram-AXDQQJYC-DwwqgJXZ.js → quadrantDiagram-AXDQQJYC-Bvh_H4wg.js} +1 -1
- package/dist/assets/{railroadDiagram-O6MQD6OU-DyRgYGPF.js → railroadDiagram-O6MQD6OU-DHC3neQ8.js} +1 -1
- package/dist/assets/{requirementDiagram-BXWQKSXE-C3ixXeHJ.js → requirementDiagram-BXWQKSXE-DuCkl3u1.js} +1 -1
- package/dist/assets/{ro-RO-JPDTUUEW-BWrclVyo.js → ro-RO-JPDTUUEW-Cwf4k3Ou.js} +1 -1
- package/dist/assets/{ru-RU-B4JR7IUQ-_z0DINaG.js → ru-RU-B4JR7IUQ-sZF6fySs.js} +1 -1
- package/dist/assets/{sankeyDiagram-P5KCCOFB-mKpKYI_w.js → sankeyDiagram-P5KCCOFB-1ELTqwtI.js} +1 -1
- package/dist/assets/{sequenceDiagram-WJ2MYXX4-ZkNd0Wnj.js → sequenceDiagram-WJ2MYXX4-BK8Ou8Dz.js} +1 -1
- package/dist/assets/{si-LK-N5RQ5JYF-CdKOb383.js → si-LK-N5RQ5JYF-DmYhXIqO.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-hQLGO-0z.js → sizeCapture-INFHLROL-BKwx3lxX.js} +1 -1
- package/dist/assets/{sk-SK-C5VTKIMK-MHJC6ZIe.js → sk-SK-C5VTKIMK-BRLu35YX.js} +1 -1
- package/dist/assets/{sl-SI-NN7IZMDC-BF9YWbZx.js → sl-SI-NN7IZMDC-CMjfvJTr.js} +1 -1
- package/dist/assets/{stateDiagram-D77RDMKH-CRWj3j-B.js → stateDiagram-D77RDMKH-CDwJ9XLN.js} +1 -1
- package/dist/assets/stateDiagram-v2-MP3YSRHH-BZjKARGY.js +1 -0
- package/dist/assets/{subset-shared.chunk-DtxXjVIA.js → subset-shared.chunk-DngAvf0H.js} +1 -1
- package/dist/assets/{subset-worker.chunk-DONNSbUF.js → subset-worker.chunk-DkH_mqr5.js} +1 -1
- package/dist/assets/{sv-SE-XGPEYMSR-DkaTkfUY.js → sv-SE-XGPEYMSR-G4S06sbd.js} +1 -1
- package/dist/assets/{swimlanes-42K2YHIH-CFf6j7jO.js → swimlanes-42K2YHIH-Z9u8PDi-.js} +1 -1
- package/dist/assets/swimlanesDiagram-VR7AAH4N-D0kM5xmS.js +8 -0
- package/dist/assets/{ta-IN-2NMHFXQM-BfxqXEDI.js → ta-IN-2NMHFXQM-DgBbCQ8S.js} +1 -1
- package/dist/assets/{th-TH-HPSO5L25-DT3vLA39.js → th-TH-HPSO5L25-o9u4fVfq.js} +1 -1
- package/dist/assets/{timeline-definition-24CTP7MA-BGP2Dq8M.js → timeline-definition-24CTP7MA-BNgrm1r_.js} +1 -1
- package/dist/assets/{tr-TR-DEFEU3FU-CdfsG7py.js → tr-TR-DEFEU3FU-BqqSdzoL.js} +1 -1
- package/dist/assets/{uk-UA-QMV73CPH-CZrQuC1S.js → uk-UA-QMV73CPH-Dna46aia.js} +1 -1
- package/dist/assets/{vennDiagram-4TSXK5OY-CaxGPIab.js → vennDiagram-4TSXK5OY-CHwUI40M.js} +1 -1
- package/dist/assets/{vi-VN-M7AON7JQ-DQJk1_KV.js → vi-VN-M7AON7JQ-CbKRBQPB.js} +1 -1
- package/dist/assets/{wardleyDiagram-VM6X3IG4-DQxQ-zXH.js → wardleyDiagram-VM6X3IG4-KB0xBjXX.js} +1 -1
- package/dist/assets/{xychartDiagram-S5SC5T6Z-DoxdZQ6R.js → xychartDiagram-S5SC5T6Z-B3LOQLL-.js} +1 -1
- package/dist/assets/{zh-CN-LNUGB5OW-DRVBfkOy.js → zh-CN-LNUGB5OW-BFjA6n_2.js} +1 -1
- package/dist/assets/{zh-HK-E62DVLB3-BJHrltss.js → zh-HK-E62DVLB3-BoTU6iS7.js} +1 -1
- package/dist/assets/{zh-TW-RAJ6MFWO-DpMZ5m2x.js → zh-TW-RAJ6MFWO-DB4kdpOS.js} +1 -1
- package/dist/index.html +2 -2
- package/docs/BUNDLE-FORMAT.md +18 -5
- package/docs/DIAGRAM-SOURCE.md +59 -12
- package/docs/LOCAL-DOCUMENT.md +42 -86
- package/docs/MODEL-CONTRACT.md +7 -4
- package/docs/PLANTUML-SOURCE.md +3 -2
- package/docs/VIEWER-LAUNCH.md +29 -22
- package/docs/VIEWER.md +93 -26
- package/docs/adr/ADR-002-2026-12-03-project-selector/ADR-002-2026-12-03-project-selector.md +1 -1
- package/docs/adr/ADR-005-2026-12-04-named-libraries/ADR-005-2026-12-04-named-libraries.md +1 -1
- package/docs/capabilities.json +21 -3
- package/package.json +2 -1
- package/scripts/build-map.mjs +1 -1
- package/scripts/lib/library-directory.mjs +1 -1
- package/scripts/lib/map-build-invocation.mjs +5 -1
- package/scripts/lib/map-viewer-server.mjs +195 -43
- package/scripts/lib/original-materials.mjs +1 -1
- package/scripts/lib/original-report-server.mjs +7 -3
- package/scripts/lib/project-catalog.mjs +264 -97
- package/scripts/lib/project-map-inputs.mjs +1 -1
- package/scripts/lib/project-registry.mjs +151 -47
- package/scripts/lib/sketch-publication.mjs +1 -1
- package/scripts/lib/task-map-build.mjs +1 -1
- package/scripts/lib/view-args.mjs +163 -0
- package/scripts/lib/workflow/reader-surface.mjs +29 -11
- package/scripts/locus-map.mjs +18 -23
- package/scripts/open-map.mjs +96 -51
- package/skills/README.md +2 -1
- package/skills/locus-map/SKILL.md +30 -26
- package/skills/locus-map/assets/artifact-handoff.md +2 -1
- package/skills/locus-map/references/build-environment.md +11 -7
- package/skills/locus-map/references/checks.md +16 -4
- package/skills/locus-map/references/component-checkpoint.md +35 -0
- package/skills/locus-map/references/draw-skill.md +2 -1
- package/skills/locus-map/references/folder.md +2 -2
- package/skills/locus-map/references/selection.md +36 -13
- package/skills/locus-map/references/task-maps.md +5 -0
- package/skills/locus-map/references/visual-composition.md +69 -0
- package/skills/locus-map-draft/SKILL.md +95 -0
- package/skills/locus-map-draft/assets/chosen-direction.md +47 -0
- package/skills/locus-map-draft/references/divergence-and-formats.md +78 -0
- package/skills/locus-map-primitives/SKILL.md +11 -10
- package/skills/locus-map-primitives/assets/batch/README.md +2 -2
- package/skills/locus-map-primitives/assets/batch/build.mjs +1 -1
- package/skills/locus-map-primitives/assets/batch/{project.json → topic.json} +13 -20
- package/skills/locus-map-primitives/references/card-presentation.md +57 -3
- package/skills/locus-map-primitives/references/reading-files.md +1 -1
- package/src/adapter/areas.js +1 -0
- package/src/adapter/semanticAdmission.js +118 -5
- package/src/authoring/buildDiagram.mjs +99 -19
- package/src/authoring/canvas-source-worker.mjs +96 -0
- package/src/authoring/canvasSource.mjs +41 -0
- package/src/authoring/diagramChecks.js +143 -1
- package/src/authoring/diagramSource.js +31 -5
- package/src/authoring/printPlantumlSource.js +13 -2
- package/src/authoring/readDetailsFiles.mjs +100 -19
- package/src/bundle/chain.js +129 -32
- package/src/bundle/chainBrowser.js +26 -2
- package/src/bundle/localDocument.mjs +87 -22
- package/src/bundle/localDocumentClient.js +5 -1
- package/src/bundle/projectClient.js +64 -21
- package/src/chain/validation.js +7 -1
- package/src/contract/readingMaterials.js +18 -2
- package/src/contract/readingTable.js +66 -0
- package/src/main.jsx +25 -1
- package/src/viewer/ControlIcon.jsx +3 -0
- package/src/viewer/DiagramViewer.jsx +70 -30
- package/src/viewer/EmbeddedExcalidrawEditor.jsx +305 -0
- package/src/viewer/HighlightOverlay.jsx +53 -25
- package/src/viewer/Inspector.jsx +109 -39
- package/src/viewer/ProjectLocation.jsx +25 -7
- package/src/viewer/ProjectRail.jsx +20 -7
- package/src/viewer/ProjectViewChainViewer.jsx +254 -83
- package/src/viewer/ReadingTable.jsx +151 -0
- package/src/viewer/SketchCanvas.jsx +133 -84
- package/src/viewer/ViewChainViewer.jsx +557 -57
- package/src/viewer/ViewerSettings.jsx +208 -0
- package/src/viewer/camera.js +50 -18
- package/src/viewer/chainEditorSession.js +160 -35
- package/src/viewer/chainInstallation.js +3 -3
- package/src/viewer/details/CanvasPreview.jsx +303 -0
- package/src/viewer/details/InspectorReadingSettings.jsx +50 -13
- package/src/viewer/details/ReadingFiles.jsx +32 -4
- package/src/viewer/details/details.css +65 -26
- package/src/viewer/diagramControls.css +1 -1
- package/src/viewer/fileError.js +53 -0
- package/src/viewer/geometry.js +12 -0
- package/src/viewer/inspectorPosition.js +54 -31
- package/src/viewer/projectContents.js +248 -55
- package/src/viewer/projectNavigation.js +27 -3
- package/src/viewer/readingTable.css +47 -0
- package/src/viewer/sketchSettling.js +71 -0
- package/src/viewer/useInspectorPosition.js +116 -35
- package/src/viewer/viewChain.css +92 -5
- package/src/viewer/viewer.css +23 -12
- package/dist/assets/channel-Dx9OTBrx.js +0 -1
- package/dist/assets/classDiagram-ZZMXUADV-Da4s894j.js +0 -1
- package/dist/assets/classDiagram-v2-VYDZK3BY--H9NrCfO.js +0 -1
- package/dist/assets/index-DBGHN_5E.js +0 -624
- package/dist/assets/stateDiagram-v2-MP3YSRHH-B2DcVJGG.js +0 -1
- package/dist/assets/swimlanesDiagram-VR7AAH4N-DO_W2uN2.js +0 -8
|
@@ -11,15 +11,14 @@ import { bindMapInputs, parseMapSources } from './project-map-inputs.mjs';
|
|
|
11
11
|
import { originalMaterials } from './original-materials.mjs';
|
|
12
12
|
|
|
13
13
|
function parse(text, file, home) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (legacy && (config?.version !== 1 || !Array.isArray(config.projects))) {
|
|
17
|
-
throw new Error('Expected version 1 and a projects array.');
|
|
14
|
+
if (path.extname(file).toLowerCase() !== '.toml') {
|
|
15
|
+
throw new Error('Legacy projects.json registries are no longer supported. Migrate to ~/.locus-map/projects.toml.');
|
|
18
16
|
}
|
|
19
|
-
|
|
17
|
+
const config = parseToml(text);
|
|
18
|
+
if (Object.keys(config).some(key => !['port', 'projects'].includes(key))) {
|
|
20
19
|
throw new Error('Expected port and projects settings.');
|
|
21
20
|
}
|
|
22
|
-
const { port } =
|
|
21
|
+
const { port } = config;
|
|
23
22
|
if (port !== undefined && (!Number.isInteger(port) || port < 0 || port > 65535)) {
|
|
24
23
|
throw new Error('Port must be an integer from 0 to 65535.');
|
|
25
24
|
}
|
|
@@ -33,99 +32,198 @@ function parse(text, file, home) {
|
|
|
33
32
|
function directory(key) {
|
|
34
33
|
const value = entry[key];
|
|
35
34
|
if (typeof value !== 'string' || !value.trim() || value.includes('\0')) throw new Error(`Invalid ${key} for "${name}".`);
|
|
36
|
-
return
|
|
35
|
+
return value.startsWith('~/') ? path.resolve(home, value.slice(2)) : path.resolve(path.dirname(file), value);
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
if (!legacy && Object.keys(entry).some(key => !['name', 'folder', sourceKey, 'mapSources', 'taskSources'].includes(key))) {
|
|
37
|
+
if (Object.keys(entry).some(key => !['name', 'folder', 'source_root', 'mapSources', 'taskSources'].includes(key))) {
|
|
40
38
|
throw new Error(`Unexpected setting for "${name}".`);
|
|
41
39
|
}
|
|
42
40
|
const mapSources = parseMapSources(entry.mapSources);
|
|
43
41
|
const taskSources = parseTaskSources(entry.taskSources);
|
|
44
|
-
const sourceRoot = Object.hasOwn(entry,
|
|
45
|
-
if (
|
|
42
|
+
const sourceRoot = Object.hasOwn(entry, 'source_root') ? directory('source_root') : undefined;
|
|
43
|
+
if ((mapSources.length || taskSources.length) && !sourceRoot) {
|
|
46
44
|
throw new Error(`Set source_root for "${name}" before registering source inputs or tasks.`);
|
|
47
45
|
}
|
|
48
|
-
return { name,
|
|
46
|
+
return { name, folder: directory('folder'), sourceRoot, mapSources, taskSources };
|
|
49
47
|
});
|
|
50
48
|
return { projects, port };
|
|
51
49
|
}
|
|
52
50
|
|
|
51
|
+
function directoryMatchDepth(candidate, root) {
|
|
52
|
+
if (!root || !candidate) return -1;
|
|
53
|
+
if (candidate === root) return root.length + 1_000_000;
|
|
54
|
+
const relative = path.relative(root, candidate);
|
|
55
|
+
if (!relative || relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) return -1;
|
|
56
|
+
return root.length;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function matchProject(all, resolvedDir, resolvedLib) {
|
|
60
|
+
let best = null;
|
|
61
|
+
let bestScore = -1;
|
|
62
|
+
for (const item of all) {
|
|
63
|
+
const libExact = item.library.path === resolvedDir || item.library.path === resolvedLib;
|
|
64
|
+
if (libExact) return item;
|
|
65
|
+
const score = Math.max(
|
|
66
|
+
directoryMatchDepth(resolvedDir, item.library.path),
|
|
67
|
+
directoryMatchDepth(resolvedDir, item.source?.path),
|
|
68
|
+
);
|
|
69
|
+
if (score > bestScore) {
|
|
70
|
+
bestScore = score;
|
|
71
|
+
best = item;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return bestScore >= 0 ? best : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function inspectDirectoryStatus(dir) {
|
|
78
|
+
if (!dir) return null;
|
|
79
|
+
if (dir.identity) {
|
|
80
|
+
const current = await captureDirectory(dir.path, false);
|
|
81
|
+
if (!current.identity) return current.missing ? 'missing' : 'inaccessible';
|
|
82
|
+
return current.identity === dir.identity ? 'available' : 'replaced';
|
|
83
|
+
}
|
|
84
|
+
if (dir.missing && dir.admitMissing) return 'creatable';
|
|
85
|
+
return dir.missing ? 'missing' : 'inaccessible';
|
|
86
|
+
}
|
|
87
|
+
|
|
53
88
|
/** Read the selected config. A launch without configured tabs adds its own defaults. */
|
|
54
89
|
export async function readProjectRegistry(cwd, file) {
|
|
55
90
|
return loadRegistry(cwd, file, false);
|
|
56
91
|
}
|
|
57
92
|
|
|
58
|
-
export async function readWorkspaceRegistry(cwd) {
|
|
59
|
-
return loadRegistry(cwd,
|
|
93
|
+
export async function readWorkspaceRegistry(cwd, file) {
|
|
94
|
+
return loadRegistry(cwd, file, true);
|
|
60
95
|
}
|
|
61
96
|
|
|
62
97
|
async function loadRegistry(cwd, file, workspace) {
|
|
63
98
|
const home = os.homedir();
|
|
64
99
|
const override = process.env.LOCUS_MAP_PROJECTS_FILE;
|
|
65
|
-
const
|
|
66
|
-
|
|
100
|
+
const defaultToml = path.join(home, '.locus-map', 'projects.toml');
|
|
101
|
+
const candidate = file ? path.resolve(cwd, file)
|
|
102
|
+
: override ? path.resolve(cwd, override)
|
|
103
|
+
: defaultToml;
|
|
67
104
|
let config = { projects: [] };
|
|
68
105
|
let selectedFile;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
106
|
+
let text;
|
|
107
|
+
try { text = await fs.readFile(candidate, 'utf8'); }
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (error.code === 'ENOENT' && !file && !override) {
|
|
110
|
+
const legacyJson = path.join(home, '.locus-map', 'projects.json');
|
|
111
|
+
const hasLegacy = await fs.access(legacyJson).then(() => true, () => false);
|
|
112
|
+
if (hasLegacy) {
|
|
113
|
+
throw new Error(`Found legacy ${legacyJson} without ${defaultToml}. Migrate your entries to ~/.locus-map/projects.toml.`);
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
74
116
|
throw new Error(`Cannot read ${candidate}. Use locus-map view --local for the current project.`, { cause: error });
|
|
75
117
|
}
|
|
118
|
+
}
|
|
119
|
+
if (text !== undefined) {
|
|
76
120
|
try { config = parse(text, candidate, home); }
|
|
77
121
|
catch (error) {
|
|
78
122
|
throw new Error(`Invalid project registry ${candidate}: ${error.message} Use locus-map view --local for the current project.`, { cause: error });
|
|
79
123
|
}
|
|
80
124
|
selectedFile = candidate;
|
|
81
|
-
break;
|
|
82
125
|
}
|
|
83
126
|
if (!workspace && !config.projects.length) return null;
|
|
127
|
+
const configSource = file ? 'explicit-file' : override ? 'env-override' : selectedFile ? 'home-toml' : 'defaults';
|
|
84
128
|
try {
|
|
129
|
+
const realHome = await fs.realpath(home).catch(() => path.resolve(home));
|
|
85
130
|
const current = await fs.realpath(cwd);
|
|
86
131
|
const conventional = path.join(current, '.locus-map');
|
|
87
132
|
const currentLibrary = await fs.realpath(conventional).catch(() => conventional);
|
|
88
|
-
const entries = config.projects;
|
|
133
|
+
const entries = [...config.projects];
|
|
134
|
+
const personalMaps = path.join(realHome, '.locus-map', 'maps');
|
|
135
|
+
const homePersonalMaps = path.join(home, '.locus-map', 'maps');
|
|
89
136
|
if (!entries.length) {
|
|
90
|
-
entries.push({ name: 'Personal', folder:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
137
|
+
entries.push({ name: 'Personal', folder: personalMaps, mapSources: [], taskSources: [] });
|
|
138
|
+
if (current !== realHome) {
|
|
139
|
+
const present = await captureDirectory(conventional, false);
|
|
140
|
+
if (present.identity) {
|
|
141
|
+
const name = path.basename(current) || current;
|
|
142
|
+
entries.push({ name: name === 'Personal' ? 'Personal (.locus-map)' : name, folder: currentLibrary, sourceRoot: current, mapSources: [], taskSources: [] });
|
|
143
|
+
}
|
|
95
144
|
}
|
|
96
145
|
}
|
|
97
146
|
const libraries = new Set(), identities = new Set();
|
|
98
147
|
const projects = new Map();
|
|
99
148
|
for (const entry of entries) {
|
|
100
|
-
const
|
|
101
|
-
const library =
|
|
102
|
-
|
|
103
|
-
|
|
149
|
+
const isPersonalFolder = entry.folder === personalMaps || entry.folder === homePersonalMaps;
|
|
150
|
+
const library = isPersonalFolder ? await bindPersonalLibrary(home) : await captureDirectory(entry.folder);
|
|
151
|
+
if (libraries.has(library.path) || (library.identity && identities.has(library.identity))) {
|
|
152
|
+
throw new Error(`Duplicate folder for "${entry.name}".`);
|
|
153
|
+
}
|
|
104
154
|
libraries.add(library.path);
|
|
105
155
|
if (library.identity) identities.add(library.identity);
|
|
106
156
|
const source = entry.sourceRoot ? await captureDirectory(entry.sourceRoot) : null;
|
|
107
|
-
const repository = source ??
|
|
157
|
+
const repository = source ?? library;
|
|
108
158
|
const id = 'library-' + randomUUID();
|
|
109
|
-
const readTasks = await bindTaskSources(
|
|
159
|
+
const readTasks = await bindTaskSources(library, repository, entry.taskSources);
|
|
110
160
|
const mapInputs = await bindMapInputs(repository, library, entry.mapSources, selectedFile);
|
|
111
|
-
projects.set(id, { id, name: entry.name,
|
|
161
|
+
projects.set(id, { id, name: entry.name, library, source, taskSources: entry.taskSources, inputMaps: entry.mapSources.map(row => row.document), mapInputs, readTasks });
|
|
112
162
|
}
|
|
113
163
|
const all = [...projects.values()];
|
|
114
|
-
const
|
|
115
|
-
const selected =
|
|
164
|
+
const matched = matchProject(all, current, currentLibrary);
|
|
165
|
+
const selected = matched ?? all[0];
|
|
166
|
+
const currentHasLibrary = !matched && current !== realHome && Boolean((await captureDirectory(conventional, false)).identity);
|
|
116
167
|
let closing = false;
|
|
117
168
|
return {
|
|
118
|
-
file: selectedFile,
|
|
169
|
+
file: selectedFile,
|
|
170
|
+
configSource,
|
|
171
|
+
configPath: selectedFile ?? defaultToml,
|
|
172
|
+
configExists: Boolean(selectedFile),
|
|
173
|
+
port: config.port,
|
|
119
174
|
entry: selected.id,
|
|
175
|
+
matchedCurrent: Boolean(matched),
|
|
176
|
+
unregisteredHint: currentHasLibrary ? {
|
|
177
|
+
name: path.basename(current) || current,
|
|
178
|
+
folder: conventional,
|
|
179
|
+
sourceRoot: current,
|
|
180
|
+
} : null,
|
|
181
|
+
async resolveEntry({ cwd: requestedCwd, tab } = {}) {
|
|
182
|
+
if (typeof tab === 'string' && tab.trim()) {
|
|
183
|
+
const normalized = tab.trim();
|
|
184
|
+
const byName = all.find(item => item.name === normalized)
|
|
185
|
+
?? all.find(item => item.name.toLowerCase() === normalized.toLowerCase());
|
|
186
|
+
if (byName) return byName.id;
|
|
187
|
+
}
|
|
188
|
+
if (typeof requestedCwd === 'string' && requestedCwd.trim() && !requestedCwd.includes('\0') && path.isAbsolute(requestedCwd)) {
|
|
189
|
+
const resolved = await fs.realpath(requestedCwd).catch(() => path.resolve(requestedCwd));
|
|
190
|
+
const requestedConventional = path.join(resolved, '.locus-map');
|
|
191
|
+
const resolvedLib = await fs.realpath(requestedConventional).catch(() => requestedConventional);
|
|
192
|
+
const found = matchProject(all, resolved, resolvedLib);
|
|
193
|
+
if (found) return found.id;
|
|
194
|
+
}
|
|
195
|
+
return selected.id;
|
|
196
|
+
},
|
|
120
197
|
get list() {
|
|
121
|
-
return all.map(({ id, name,
|
|
122
|
-
|
|
198
|
+
return all.map(({ id, name, library, taskSources, inputMaps }) => ({
|
|
199
|
+
id, name,
|
|
200
|
+
...(inputMaps.length && { inputMaps }),
|
|
201
|
+
...(taskSources.length && { taskSources }),
|
|
202
|
+
available: Boolean(library.identity || (library.missing && library.admitMissing)),
|
|
203
|
+
}));
|
|
204
|
+
},
|
|
205
|
+
async runtimeProjects() {
|
|
206
|
+
return Promise.all(all.map(async item => {
|
|
207
|
+
const folderStatus = await inspectDirectoryStatus(item.library);
|
|
208
|
+
const sourceStatus = item.source ? await inspectDirectoryStatus(item.source) : null;
|
|
209
|
+
return {
|
|
210
|
+
id: item.id,
|
|
211
|
+
name: item.name,
|
|
212
|
+
folder: item.library.path,
|
|
213
|
+
folderStatus,
|
|
214
|
+
sourceRoot: item.source?.path ?? null,
|
|
215
|
+
sourceStatus,
|
|
216
|
+
available: folderStatus === 'available' || folderStatus === 'creatable',
|
|
217
|
+
mapSourcesCount: item.inputMaps.length,
|
|
218
|
+
taskSourcesCount: item.taskSources.length,
|
|
219
|
+
};
|
|
220
|
+
}));
|
|
123
221
|
},
|
|
124
222
|
hasOriginals: all.some(item => item.source?.identity),
|
|
125
223
|
async startMapInputRecord(document, options) {
|
|
126
|
-
const matches = all.filter(item =>
|
|
127
|
-
if (matches.length !== 1) throw new Error('Run from the
|
|
128
|
-
return matches[0].mapInputs.startRecording(document, options,
|
|
224
|
+
const matches = all.filter(item => item.source?.path === current && item.inputMaps.includes(document));
|
|
225
|
+
if (matches.length !== 1) throw new Error('Run from the declared source_root directory with one matching mapSources entry.');
|
|
226
|
+
return matches[0].mapInputs.startRecording(document, options, 'source');
|
|
129
227
|
},
|
|
130
228
|
async readMapInputs(id, document) {
|
|
131
229
|
const item = projects.get(id);
|
|
@@ -147,12 +245,18 @@ async function loadRegistry(cwd, file, workspace) {
|
|
|
147
245
|
async get(id) {
|
|
148
246
|
const item = projects.get(id);
|
|
149
247
|
if (!item) throw new DocumentError('PROJECT_ADDRESS_NOT_FOUND', 'Unknown project for this launch.');
|
|
150
|
-
const check = () => checkLibraryDirectory(item.library,
|
|
248
|
+
const check = () => checkLibraryDirectory(item.library, null);
|
|
151
249
|
await check();
|
|
152
250
|
if (closing) throw new DocumentError('OWNER_CLOSED', 'The viewer is closing.');
|
|
153
251
|
item.opening ??= (async () => {
|
|
154
|
-
const project = await openProjectLibrary({
|
|
155
|
-
|
|
252
|
+
const project = await openProjectLibrary({
|
|
253
|
+
id,
|
|
254
|
+
binding: { root: null, library: item.library },
|
|
255
|
+
name: item.name,
|
|
256
|
+
sourceRoot: item.source?.path,
|
|
257
|
+
workspaceIdentity: item.source?.identity,
|
|
258
|
+
sketches: true,
|
|
259
|
+
});
|
|
156
260
|
try {
|
|
157
261
|
const originals = item.source && await originalMaterials(item.source.path, item.source.identity);
|
|
158
262
|
await check();
|
|
@@ -175,6 +279,6 @@ async function loadRegistry(cwd, file, workspace) {
|
|
|
175
279
|
},
|
|
176
280
|
};
|
|
177
281
|
} catch (error) {
|
|
178
|
-
throw new Error(`Invalid project registry ${selectedFile ??
|
|
282
|
+
throw new Error(`Invalid project registry ${selectedFile ?? 'defaults'}: ${error.message} Use locus-map view --local for the current project.`, { cause: error });
|
|
179
283
|
}
|
|
180
284
|
}
|
|
@@ -18,7 +18,7 @@ export async function publishSketch({ library, map, text, check, io = fs }) {
|
|
|
18
18
|
await io.access(library.path, constants.W_OK);
|
|
19
19
|
const filename = path.join(library.path, map);
|
|
20
20
|
const parentCheck = () => check(false);
|
|
21
|
-
const lock = await acquireDocumentLock(filename, { io, checkParents: parentCheck }).catch(error => {
|
|
21
|
+
const lock = await acquireDocumentLock(filename, { io, checkParents: parentCheck, role: 'sketch-create' }).catch(error => {
|
|
22
22
|
if (error.code === 'DOCUMENT_LOCKED') throw collision();
|
|
23
23
|
throw error;
|
|
24
24
|
});
|
|
@@ -59,7 +59,7 @@ export async function buildTaskDocument({ root = '.', tasksDir, map, includeArch
|
|
|
59
59
|
throw new Error('Task facts or the project author module changed during the build. Rebuild the map.');
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
const lock = await acquireDocumentLock(dest, { checkParents: checkParent });
|
|
62
|
+
const lock = await acquireDocumentLock(dest, { checkParents: checkParent, role: 'task-build' });
|
|
63
63
|
async function publishTaskDocument(stage, out, { last, bundleName }) {
|
|
64
64
|
await lock.check();
|
|
65
65
|
const temp = join(parent, '.locus-map-' + randomUUID() + '.tmp');
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { realpath, stat } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
async function statKind(filePath) {
|
|
5
|
+
try {
|
|
6
|
+
const info = await stat(filePath);
|
|
7
|
+
if (info.isFile()) return 'file';
|
|
8
|
+
if (info.isDirectory()) return 'dir';
|
|
9
|
+
return null;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
if (['ENOENT', 'ENOTDIR'].includes(error.code)) return null;
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function canonicalPath(filePath) {
|
|
17
|
+
let current = path.resolve(filePath);
|
|
18
|
+
const suffix = [];
|
|
19
|
+
while (true) {
|
|
20
|
+
try {
|
|
21
|
+
const resolved = await realpath(current);
|
|
22
|
+
return suffix.length ? path.join(resolved, ...suffix.reverse()) : resolved;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (!['ENOENT', 'ENOTDIR'].includes(error.code)) throw error;
|
|
25
|
+
const parent = path.dirname(current);
|
|
26
|
+
if (parent === current) return path.resolve(filePath);
|
|
27
|
+
suffix.push(path.basename(current));
|
|
28
|
+
current = parent;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isBareTopicName(value) {
|
|
34
|
+
return typeof value === 'string' && value.length > 0
|
|
35
|
+
&& !value.includes('/') && !value.includes('\\') && !value.includes('\0')
|
|
36
|
+
&& value !== '.' && value !== '..' && path.basename(value) === value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function enclosingLibraryRoot(targetPath) {
|
|
40
|
+
let directory = path.dirname(targetPath);
|
|
41
|
+
while (true) {
|
|
42
|
+
const parent = path.dirname(directory);
|
|
43
|
+
if (path.basename(directory) === '.locus-map' && parent !== directory) return parent;
|
|
44
|
+
if (parent === directory) return undefined;
|
|
45
|
+
directory = parent;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isInsideDirectory(candidate, directory) {
|
|
50
|
+
const relative = path.relative(directory, candidate);
|
|
51
|
+
return Boolean(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function inferSourceRoot(mode, targetPath, cwd) {
|
|
55
|
+
const [realTarget, realCwd] = await Promise.all([canonicalPath(targetPath), canonicalPath(cwd)]);
|
|
56
|
+
if (mode === 'library') return realTarget;
|
|
57
|
+
const fromLibrary = enclosingLibraryRoot(realTarget);
|
|
58
|
+
if (fromLibrary) return fromLibrary;
|
|
59
|
+
if (isInsideDirectory(realTarget, realCwd)) return realCwd;
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function resolveTopicTarget(target, cwd) {
|
|
64
|
+
const direct = path.resolve(cwd, target);
|
|
65
|
+
const directKind = await statKind(direct);
|
|
66
|
+
if (directKind === 'file') {
|
|
67
|
+
const base = path.basename(direct);
|
|
68
|
+
if (base === 'topic.json' || base.toLowerCase().endsWith('.excalidraw')) {
|
|
69
|
+
return { mode: 'topic', targetPath: path.dirname(direct) };
|
|
70
|
+
}
|
|
71
|
+
return { mode: 'document', targetPath: direct };
|
|
72
|
+
}
|
|
73
|
+
if (directKind === 'dir') {
|
|
74
|
+
if (path.basename(direct) === '.locus-map') {
|
|
75
|
+
return { mode: 'library', targetPath: path.dirname(direct) };
|
|
76
|
+
}
|
|
77
|
+
return { mode: 'topic', targetPath: direct };
|
|
78
|
+
}
|
|
79
|
+
if (isBareTopicName(target)) {
|
|
80
|
+
const topicDir = path.resolve(cwd, '.locus-map', target);
|
|
81
|
+
const topicDirKind = await statKind(topicDir);
|
|
82
|
+
if (topicDirKind === 'dir') {
|
|
83
|
+
return { mode: 'topic', targetPath: topicDir };
|
|
84
|
+
}
|
|
85
|
+
const directDoc = path.resolve(cwd, '.locus-map', `${target}.locus-map.json`);
|
|
86
|
+
if (await statKind(directDoc) === 'file') {
|
|
87
|
+
return { mode: 'document', targetPath: directDoc };
|
|
88
|
+
}
|
|
89
|
+
throw new Error(
|
|
90
|
+
`Cannot find topic or diagram "${target}". `
|
|
91
|
+
+ `Checked "${target}", ".locus-map/${target}/", and ".locus-map/${target}.locus-map.json".`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
return { mode: 'document', targetPath: direct };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Parse `locus-map view` CLI arguments, resolve topic/document shorthands relative
|
|
99
|
+
* to `cwd`, and return the canonical `open-map.mjs` argument list.
|
|
100
|
+
*/
|
|
101
|
+
export async function resolveViewArgs(args, { cwd = process.cwd(), usage }) {
|
|
102
|
+
const resolvedCwd = path.resolve(cwd);
|
|
103
|
+
const seen = new Set();
|
|
104
|
+
let local = false;
|
|
105
|
+
let positional;
|
|
106
|
+
let sourceRoot;
|
|
107
|
+
let noSourceRoot = false;
|
|
108
|
+
let readOnly = false;
|
|
109
|
+
let port;
|
|
110
|
+
let previousDocument;
|
|
111
|
+
|
|
112
|
+
for (let index = 0; index < args.length; index++) {
|
|
113
|
+
const token = args[index];
|
|
114
|
+
if (token === '--document') throw new Error('Pass the document as the first argument to view.');
|
|
115
|
+
if (token === '--project') throw new Error('The --project flag was removed. Pass a topic directory, topic.json, or use "locus-map view --local".');
|
|
116
|
+
if (!token.startsWith('-')) {
|
|
117
|
+
if (positional !== undefined) throw new Error(usage);
|
|
118
|
+
positional = token;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (seen.has(token)) throw new Error(usage);
|
|
122
|
+
seen.add(token);
|
|
123
|
+
if (token === '--local') { local = true; continue; }
|
|
124
|
+
if (token === '--read-only') { readOnly = true; continue; }
|
|
125
|
+
if (token === '--no-source-root') { noSourceRoot = true; continue; }
|
|
126
|
+
const value = args[++index];
|
|
127
|
+
if (!value || value.startsWith('-')) throw new Error(usage);
|
|
128
|
+
if (token === '--source-root') sourceRoot = path.resolve(resolvedCwd, value);
|
|
129
|
+
else if (token === '--previous-document') previousDocument = path.resolve(resolvedCwd, value);
|
|
130
|
+
else if (token === '--port') {
|
|
131
|
+
if (!/^[0-9]+$/.test(value)) throw new Error(usage);
|
|
132
|
+
const parsed = Number(value);
|
|
133
|
+
if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65535) throw new Error(usage);
|
|
134
|
+
port = value;
|
|
135
|
+
} else throw new Error(usage);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (sourceRoot !== undefined && noSourceRoot) throw new Error(usage);
|
|
139
|
+
if (local && positional !== undefined) throw new Error(usage);
|
|
140
|
+
|
|
141
|
+
let mode;
|
|
142
|
+
let targetPath;
|
|
143
|
+
if (positional !== undefined) {
|
|
144
|
+
({ mode, targetPath } = await resolveTopicTarget(positional, resolvedCwd));
|
|
145
|
+
} else {
|
|
146
|
+
const isolated = local || sourceRoot !== undefined || noSourceRoot;
|
|
147
|
+
mode = isolated ? 'library' : 'user-projects';
|
|
148
|
+
targetPath = resolvedCwd;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (previousDocument !== undefined && mode !== 'document') throw new Error(usage);
|
|
152
|
+
|
|
153
|
+
const effectiveSourceRoot = mode === 'user-projects'
|
|
154
|
+
? undefined
|
|
155
|
+
: sourceRoot ?? (noSourceRoot ? undefined : await inferSourceRoot(mode, targetPath, resolvedCwd));
|
|
156
|
+
|
|
157
|
+
const openArgs = [`--${mode}`, targetPath];
|
|
158
|
+
if (previousDocument !== undefined) openArgs.push('--previous-document', previousDocument);
|
|
159
|
+
if (effectiveSourceRoot !== undefined) openArgs.push('--source-root', effectiveSourceRoot);
|
|
160
|
+
if (readOnly) openArgs.push('--read-only');
|
|
161
|
+
if (port !== undefined) openArgs.push('--port', port);
|
|
162
|
+
return { mode, targetPath, sourceRoot: effectiveSourceRoot, openArgs };
|
|
163
|
+
}
|
|
@@ -7,15 +7,16 @@ import { startMapViewer } from '../map-viewer-server.mjs';
|
|
|
7
7
|
const self = fileURLToPath(import.meta.url);
|
|
8
8
|
const fail = (code, message) => Object.assign(new Error(message), { code });
|
|
9
9
|
|
|
10
|
-
async function publishSurface(recordPath, record) {
|
|
11
|
-
const temporary = recordPath + '.' + randomUUID() + '.tmp';
|
|
10
|
+
async function publishSurface(recordPath, record, temporary = recordPath + '.' + randomUUID() + '.tmp') {
|
|
12
11
|
const file = await open(temporary, 'wx', 0o600);
|
|
12
|
+
let closed = false;
|
|
13
13
|
try {
|
|
14
14
|
await file.writeFile(JSON.stringify(record) + '\n');
|
|
15
|
+
closed = true;
|
|
15
16
|
await file.close();
|
|
16
17
|
await rename(temporary, recordPath);
|
|
17
18
|
} finally {
|
|
18
|
-
await file.close();
|
|
19
|
+
if (!closed) await file.close().catch(() => {});
|
|
19
20
|
await rm(temporary, { force: true });
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -36,8 +37,9 @@ export async function startReaderSurface(config) {
|
|
|
36
37
|
throw fail('READER_ALREADY_STARTED', 'This reader call already owns a surface attempt.');
|
|
37
38
|
throw error;
|
|
38
39
|
});
|
|
40
|
+
const runningTempPath = config.recordPath + '.' + randomUUID() + '.tmp';
|
|
39
41
|
return new Promise((resolveReady, reject) => {
|
|
40
|
-
const child = fork(self, ['--worker', JSON.stringify(config)], {
|
|
42
|
+
const child = fork(self, ['--worker', JSON.stringify({ ...config, runningTempPath })], {
|
|
41
43
|
stdio: ['ignore', 'ignore', 'ignore', 'ipc'],
|
|
42
44
|
execArgv: [],
|
|
43
45
|
});
|
|
@@ -51,6 +53,7 @@ export async function startReaderSurface(config) {
|
|
|
51
53
|
? Promise.resolve() : new Promise(resolve => child.once('close', resolve));
|
|
52
54
|
child.kill('SIGKILL');
|
|
53
55
|
await stopped;
|
|
56
|
+
await rm(runningTempPath, { force: true }).catch(() => {});
|
|
54
57
|
let failure = error;
|
|
55
58
|
try {
|
|
56
59
|
await publishSurface(
|
|
@@ -94,11 +97,12 @@ async function worker(config) {
|
|
|
94
97
|
const began = Date.now();
|
|
95
98
|
let viewer,
|
|
96
99
|
closing = false,
|
|
100
|
+
ready = false,
|
|
97
101
|
watcher,
|
|
98
102
|
deadline,
|
|
99
103
|
hardStop;
|
|
100
104
|
let writing = Promise.resolve();
|
|
101
|
-
const write = (value) => {
|
|
105
|
+
const write = (value, temporary) => {
|
|
102
106
|
const next = writing.then(() => publishSurface(config.recordPath, {
|
|
103
107
|
schemaVersion: 1,
|
|
104
108
|
runId: config.runId,
|
|
@@ -107,7 +111,7 @@ async function worker(config) {
|
|
|
107
111
|
startedAt: new Date(began).toISOString(),
|
|
108
112
|
expiresAt: new Date(began + config.timeoutMs + 5000).toISOString(),
|
|
109
113
|
...value,
|
|
110
|
-
}));
|
|
114
|
+
}, temporary));
|
|
111
115
|
writing = next.catch(() => {});
|
|
112
116
|
return next;
|
|
113
117
|
};
|
|
@@ -118,11 +122,13 @@ async function worker(config) {
|
|
|
118
122
|
clearTimeout(deadline);
|
|
119
123
|
try {
|
|
120
124
|
await viewer?.close({ force: true });
|
|
121
|
-
await write({ state: 'closed', reason, url: viewer?.url ?? null });
|
|
125
|
+
if (ready) await write({ state: 'closed', reason, url: viewer?.url ?? null });
|
|
126
|
+
else await writing;
|
|
122
127
|
clearTimeout(hardStop);
|
|
123
128
|
process.exitCode = 0;
|
|
124
129
|
} catch (error) {
|
|
125
|
-
await write({ state: 'failed', reason: error.message }).catch(() => {});
|
|
130
|
+
if (ready) await write({ state: 'failed', reason: error.message }).catch(() => {});
|
|
131
|
+
clearTimeout(hardStop);
|
|
126
132
|
process.exitCode = 1;
|
|
127
133
|
}
|
|
128
134
|
};
|
|
@@ -136,9 +142,10 @@ async function worker(config) {
|
|
|
136
142
|
await viewer.close({ force: true });
|
|
137
143
|
return;
|
|
138
144
|
}
|
|
139
|
-
await write({ state: 'running', url: viewer.url });
|
|
145
|
+
await write({ state: 'running', url: viewer.url }, config.runningTempPath);
|
|
140
146
|
if (closing) return;
|
|
141
147
|
process.send?.({ kind: 'ready', url: viewer.url, pid: process.pid });
|
|
148
|
+
ready = true;
|
|
142
149
|
let inspecting = false;
|
|
143
150
|
watcher = setInterval(async () => {
|
|
144
151
|
if (inspecting || closing) return;
|
|
@@ -175,8 +182,19 @@ async function worker(config) {
|
|
|
175
182
|
}
|
|
176
183
|
}, 250);
|
|
177
184
|
} catch (error) {
|
|
178
|
-
|
|
179
|
-
|
|
185
|
+
// Before readiness, the parent owns failure publication and immediately SIGKILLs the worker.
|
|
186
|
+
closing = true;
|
|
187
|
+
clearInterval(watcher);
|
|
188
|
+
clearTimeout(deadline);
|
|
189
|
+
clearTimeout(hardStop);
|
|
190
|
+
await viewer?.close({ force: true }).catch(() => {});
|
|
191
|
+
await writing;
|
|
192
|
+
if (process.connected) {
|
|
193
|
+
try {
|
|
194
|
+
process.send?.({ kind: 'error', message: error.message });
|
|
195
|
+
} catch {}
|
|
196
|
+
}
|
|
197
|
+
process.exitCode = 1;
|
|
180
198
|
}
|
|
181
199
|
}
|
|
182
200
|
if (process.argv[1] && resolve(process.argv[1]) === self && process.argv[2] === '--worker')
|
package/scripts/locus-map.mjs
CHANGED
|
@@ -11,18 +11,24 @@ const usage = `Usage:
|
|
|
11
11
|
locus-map build [build-map options]
|
|
12
12
|
locus-map tasks export [--root DIR] [--dir .tasks] [--include-archived]
|
|
13
13
|
locus-map view --help
|
|
14
|
-
locus-map view [--local] [--read-only] [--port N]
|
|
15
|
-
locus-map view
|
|
16
|
-
locus-map view --project FILE [--source-root DIR] [--read-only] [--port N]`;
|
|
14
|
+
locus-map view [--local] [--source-root DIR | --no-source-root] [--read-only] [--port N]
|
|
15
|
+
locus-map view TARGET [--source-root DIR | --no-source-root] [--read-only] [--port N] [--previous-document FILE]`;
|
|
17
16
|
|
|
18
17
|
const viewHelp = `${usage.slice(usage.indexOf(' locus-map view [--local]'))}
|
|
19
18
|
|
|
20
19
|
Start one local viewer and open the URL it prints. Keep its process running.
|
|
21
|
-
Register named folders in ~/.
|
|
20
|
+
Register named folders in ~/.locus-map/projects.toml.
|
|
22
21
|
Without a registry, view opens Personal and any library in the launch directory.
|
|
23
|
-
--local skips the home registry. Explicit
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
--local skips the home registry. Explicit targets and --source-root launches also skip it.
|
|
23
|
+
TARGET may be a .locus-map.json file, topic.json, topic directory, or bare topic name under
|
|
24
|
+
.locus-map/ (.locus-map/<name>/ or .locus-map/<name>.locus-map.json). Isolated launches default
|
|
25
|
+
--source-root to the enclosing project directory when the target lives under .locus-map/ or the
|
|
26
|
+
launch directory; pass --no-source-root to disable original-file links.
|
|
27
|
+
Workspace launches default to 127.0.0.1:8181 or the configured port. Visiting http://127.0.0.1:8181/
|
|
28
|
+
redirects to the default tab; /?cwd=DIR or /?tab=NAME (with optional &map=…&view=…&node=…) selects
|
|
29
|
+
a matching tab on a running viewer.
|
|
30
|
+
--port N overrides the configured port. Isolated launches choose a free port automatically.
|
|
31
|
+
--read-only disables file saves and write locks process-wide.
|
|
26
32
|
Launch and configuration guide: ${join(root, 'docs', 'VIEWER-LAUNCH.md')}`;
|
|
27
33
|
|
|
28
34
|
async function doctor(json) {
|
|
@@ -31,6 +37,7 @@ async function doctor(json) {
|
|
|
31
37
|
productRoot: root,
|
|
32
38
|
docsRoot: join(root, 'docs'),
|
|
33
39
|
mapSkillPath: join(root, 'skills/locus-map/SKILL.md'),
|
|
40
|
+
draftSkillPath: join(root, 'skills/locus-map-draft/SKILL.md'),
|
|
34
41
|
primitivesSkillPath: join(root, 'skills/locus-map-primitives/SKILL.md'),
|
|
35
42
|
researchSkillPath: join(root, 'skills/locus-map-research/SKILL.md'),
|
|
36
43
|
drawSkillPath: null,
|
|
@@ -56,7 +63,7 @@ async function doctor(json) {
|
|
|
56
63
|
} catch (error) { result.reasons.push(error.message); }
|
|
57
64
|
|
|
58
65
|
try {
|
|
59
|
-
await Promise.all([join(result.docsRoot, 'DIAGRAM-SOURCE.md'), result.mapSkillPath, result.primitivesSkillPath, result.researchSkillPath]
|
|
66
|
+
await Promise.all([join(result.docsRoot, 'DIAGRAM-SOURCE.md'), result.mapSkillPath, result.draftSkillPath, result.primitivesSkillPath, result.researchSkillPath]
|
|
60
67
|
.map(async path => {
|
|
61
68
|
if (!(await stat(path)).isFile()) throw new Error(`Expected a file at ${path}.`);
|
|
62
69
|
}));
|
|
@@ -126,22 +133,10 @@ async function main([command, ...args]) {
|
|
|
126
133
|
return 0;
|
|
127
134
|
}
|
|
128
135
|
if (command === 'build') return run('build-map.mjs', args);
|
|
129
|
-
if (command === 'view' && args[0] === '--project' && args[1] && !args[1].startsWith('--')) {
|
|
130
|
-
return run('open-map.mjs', ['--project', resolve(args[1]), ...args.slice(2)]);
|
|
131
|
-
}
|
|
132
|
-
if (command === 'view' && args[0] && !args[0].startsWith('--')) {
|
|
133
|
-
const [file, ...options] = args;
|
|
134
|
-
for (let index = 0; index < options.length; index++) {
|
|
135
|
-
if (options[index] === '--document') throw new Error('Pass the document as the first argument to view.');
|
|
136
|
-
if (options[index] === '--previous-document' && options[index + 1] && !options[index + 1].startsWith('--')) {
|
|
137
|
-
options[++index] = resolve(options[index]);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return run('open-map.mjs', ['--document', resolve(file), ...options]);
|
|
141
|
-
}
|
|
142
136
|
if (command === 'view') {
|
|
143
|
-
const
|
|
144
|
-
|
|
137
|
+
const { resolveViewArgs } = await import('./lib/view-args.mjs');
|
|
138
|
+
const { openArgs } = await resolveViewArgs(args, { cwd: process.cwd(), usage });
|
|
139
|
+
return run('open-map.mjs', openArgs);
|
|
145
140
|
}
|
|
146
141
|
throw new Error(usage);
|
|
147
142
|
}
|