@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
|
@@ -9,70 +9,133 @@ import { isSketchPath, loadSketch, sketchFilename, sketchNameError, sketchView }
|
|
|
9
9
|
import { captureDirectory, directoryIdentity, checkLibraryDirectory } from './library-directory.mjs';
|
|
10
10
|
import { publishSketch } from './sketch-publication.mjs';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
const limits = { bytes: 256 * 1024, documents: 128, links: 512, libraryEntries: 10_000 };
|
|
12
|
+
const limits = { bytes: 256 * 1024, documents: 128, links: 512, libraryEntries: 10_000, maxDepth: 8 };
|
|
14
13
|
const validId = value => typeof value === 'string' && value.length <= 128
|
|
15
14
|
&& /^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(value) && !isReservedKey(value);
|
|
15
|
+
const isMapPath = value => isPortablePath(value) && value.endsWith('.locus-map.json');
|
|
16
|
+
const isTopicDocPath = value => isMapPath(value) || isSketchPath(value);
|
|
17
|
+
const isChildName = value => typeof value === 'string' && value.length > 0 && value.length <= 128
|
|
18
|
+
&& !value.includes('/') && !value.includes('\\') && !value.startsWith('.') && value !== '.' && value !== '..' && !isReservedKey(value);
|
|
16
19
|
const linkKey = ({ map, view, trigger }) => `${map}\0${view}\0${trigger}`;
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
const allowedTopicKeys = ['version', 'title', 'entry', 'order', 'models', 'sources', 'links', 'navigation'];
|
|
22
|
+
|
|
23
|
+
export function parseTopicManifest(text) {
|
|
24
|
+
const requireManifest = (condition, message) => {
|
|
20
25
|
if (!condition) throw new DocumentError('INVALID_PROJECT', message);
|
|
21
26
|
};
|
|
22
|
-
const
|
|
27
|
+
const manifest = JSON.parse(text);
|
|
23
28
|
rejectDuplicateJsonKeys(text);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
requireManifest(manifest && typeof manifest === 'object' && !Array.isArray(manifest), 'Topic manifest must be a JSON object.');
|
|
30
|
+
const presentKeys = allowedTopicKeys.filter(key => Object.hasOwn(manifest, key));
|
|
31
|
+
exactKeys(manifest, ['version', ...presentKeys.filter(key => key !== 'version')], 'Topic manifest');
|
|
32
|
+
requireManifest(manifest.version === 1, 'Expected a version 1 topic manifest.');
|
|
33
|
+
|
|
34
|
+
let title;
|
|
35
|
+
if (Object.hasOwn(manifest, 'title')) {
|
|
36
|
+
requireManifest(typeof manifest.title === 'string' && manifest.title.trim() && manifest.title.length <= 256, 'Topic title must be a non-empty string.');
|
|
37
|
+
title = manifest.title.trim();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const checkAddress = (address, fields, label, pathCheck = isMapPath) => {
|
|
41
|
+
requireManifest(address && typeof address === 'object' && !Array.isArray(address), `${label} must be an object.`);
|
|
27
42
|
exactKeys(address, fields, label);
|
|
28
|
-
|
|
43
|
+
for (const field of fields) {
|
|
44
|
+
if (field === 'map') requireManifest(pathCheck(address.map), `${label} must use a portable relative document path.`);
|
|
45
|
+
else requireManifest(validId(address[field]), `${label} must use stable IDs.`);
|
|
46
|
+
}
|
|
29
47
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
|
|
49
|
+
let entry;
|
|
50
|
+
if (Object.hasOwn(manifest, 'entry')) {
|
|
51
|
+
checkAddress(manifest.entry, ['map', 'view'], 'Topic entry', isTopicDocPath);
|
|
52
|
+
entry = manifest.entry;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let order;
|
|
56
|
+
if (Object.hasOwn(manifest, 'order')) {
|
|
57
|
+
requireManifest(Array.isArray(manifest.order) && manifest.order.length > 0 && manifest.order.length <= limits.documents,
|
|
58
|
+
'Topic order must be a non-empty list of child names.');
|
|
59
|
+
const seen = new Set();
|
|
60
|
+
for (const name of manifest.order) {
|
|
61
|
+
requireManifest(isChildName(name) && !seen.has(name), 'Topic order entries must be unique child folder or file names.');
|
|
62
|
+
seen.add(name);
|
|
63
|
+
}
|
|
64
|
+
order = manifest.order;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const models = new Map();
|
|
68
|
+
if (Object.hasOwn(manifest, 'models')) {
|
|
69
|
+
requireManifest(manifest.models && typeof manifest.models === 'object' && !Array.isArray(manifest.models),
|
|
70
|
+
'Topic models must map relative map paths to model IDs.');
|
|
71
|
+
const entries = Object.entries(manifest.models);
|
|
72
|
+
requireManifest(entries.length <= limits.documents, `Expected at most ${limits.documents} model pins.`);
|
|
73
|
+
for (const [docPath, modelId] of entries) {
|
|
74
|
+
requireManifest(isMapPath(docPath) && validId(modelId), 'Topic models must map portable .locus-map.json paths to stable model IDs.');
|
|
75
|
+
models.set(docPath, modelId);
|
|
76
|
+
}
|
|
42
77
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
|
|
79
|
+
const sources = new Map();
|
|
80
|
+
if (Object.hasOwn(manifest, 'sources')) {
|
|
81
|
+
requireManifest(manifest.sources && typeof manifest.sources === 'object' && !Array.isArray(manifest.sources),
|
|
82
|
+
'Topic sources must map relative map paths to relative source files.');
|
|
83
|
+
const entries = Object.entries(manifest.sources);
|
|
84
|
+
requireManifest(entries.length <= limits.documents, `Expected at most ${limits.documents} source bindings.`);
|
|
85
|
+
for (const [docPath, sourcePath] of entries) {
|
|
86
|
+
requireManifest(isMapPath(docPath) && isPortablePath(sourcePath), 'Topic sources must use portable relative paths.');
|
|
87
|
+
sources.set(docPath, sourcePath);
|
|
88
|
+
}
|
|
48
89
|
}
|
|
49
|
-
|
|
90
|
+
|
|
91
|
+
const links = [];
|
|
92
|
+
if (Object.hasOwn(manifest, 'links')) {
|
|
93
|
+
requireManifest(Array.isArray(manifest.links) && manifest.links.length <= limits.links, `Expected at most ${limits.links} topic links.`);
|
|
94
|
+
for (const link of manifest.links) {
|
|
95
|
+
exactKeys(link, ['from', 'to'], 'Topic link');
|
|
96
|
+
checkAddress(link.from, ['map', 'view', 'trigger'], 'Topic link source', isMapPath);
|
|
97
|
+
checkAddress(link.to, Object.hasOwn(link.to ?? {}, 'node') ? ['map', 'view', 'node'] : ['map', 'view'], 'Topic link target', isMapPath);
|
|
98
|
+
links.push(link);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let navigation;
|
|
103
|
+
if (Object.hasOwn(manifest, 'navigation')) {
|
|
50
104
|
const targets = new Set();
|
|
51
105
|
let count = 0;
|
|
52
106
|
const visit = (items, depth) => {
|
|
53
|
-
|
|
107
|
+
requireManifest(Array.isArray(items) && items.length && depth <= limits.maxDepth, 'Navigation needs nonempty groups within eight levels.');
|
|
54
108
|
for (const item of items) {
|
|
55
|
-
|
|
109
|
+
requireManifest(++count <= 2048 && item && typeof item === 'object', 'Invalid or oversized topic navigation.');
|
|
56
110
|
if (Object.hasOwn(item, 'children')) {
|
|
57
111
|
exactKeys(item, ['title', 'children'], 'Navigation group');
|
|
58
|
-
|
|
112
|
+
requireManifest(typeof item.title === 'string' && item.title.trim() && item.title.length <= 256, 'Navigation groups need a title.');
|
|
59
113
|
visit(item.children, depth + 1);
|
|
60
114
|
} else {
|
|
61
|
-
checkAddress(item, Object.hasOwn(item, 'node') ? ['map', 'view', 'node'] : ['map', 'view'], 'Navigation destination');
|
|
115
|
+
checkAddress(item, Object.hasOwn(item, 'node') ? ['map', 'view', 'node'] : ['map', 'view'], 'Navigation destination', isTopicDocPath);
|
|
62
116
|
const key = JSON.stringify([item.map, item.view, item.node]);
|
|
63
|
-
|
|
117
|
+
requireManifest(!targets.has(key), 'Navigation needs one location per destination.');
|
|
64
118
|
targets.add(key);
|
|
65
119
|
}
|
|
66
120
|
}
|
|
67
121
|
};
|
|
68
|
-
visit(
|
|
122
|
+
visit(manifest.navigation, 1);
|
|
123
|
+
navigation = manifest.navigation;
|
|
69
124
|
}
|
|
70
|
-
|
|
125
|
+
|
|
126
|
+
return { version: 1, title, entry, order, models, sources, links, navigation };
|
|
71
127
|
}
|
|
72
128
|
|
|
73
129
|
const diagnostic = (code, message) => ({ code, message });
|
|
74
130
|
const writeLimit = error => {
|
|
75
|
-
if (error.code === 'DOCUMENT_LOCKED')
|
|
131
|
+
if (error.code === 'DOCUMENT_LOCKED') {
|
|
132
|
+
const reason = diagnostic('DOCUMENT_LOCKED', 'The document is open for writing in another viewer.');
|
|
133
|
+
if (error.lock) {
|
|
134
|
+
const { pid, role, createdAt, stale } = error.lock;
|
|
135
|
+
reason.lock = { pid, role, createdAt, stale };
|
|
136
|
+
}
|
|
137
|
+
return reason;
|
|
138
|
+
}
|
|
76
139
|
if (['READ_ONLY', 'EACCES', 'EPERM', 'EROFS'].includes(error.code)) {
|
|
77
140
|
return diagnostic('READ_ONLY', 'The document or its directory is read-only.');
|
|
78
141
|
}
|
|
@@ -181,27 +244,46 @@ async function editorWorkspace(directory, sourceDeclared, expectedIdentity) {
|
|
|
181
244
|
};
|
|
182
245
|
}
|
|
183
246
|
|
|
184
|
-
|
|
185
|
-
if (!
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
247
|
+
async function resolveSafeSourceFile(libraryPath, relativeSourcePath) {
|
|
248
|
+
if (!isPortablePath(relativeSourcePath)) return null;
|
|
249
|
+
const fullPath = path.join(libraryPath, ...relativeSourcePath.split('/'));
|
|
250
|
+
try {
|
|
251
|
+
const stat = await fs.lstat(fullPath);
|
|
252
|
+
if (!stat.isFile()) return null;
|
|
253
|
+
const real = await fs.realpath(fullPath);
|
|
254
|
+
const rel = path.relative(libraryPath, real);
|
|
255
|
+
if (!rel || rel === '..' || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel)) return null;
|
|
256
|
+
return real;
|
|
257
|
+
} catch {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function findSiblingSource(libraryPath, docRelativePath) {
|
|
263
|
+
const dir = path.posix.dirname(docRelativePath);
|
|
264
|
+
const stem = path.posix.basename(docRelativePath, '.locus-map.json');
|
|
265
|
+
const candidates = [`${stem}.mjs`, `${stem}.puml`, `${stem}.map.json`, 'gen.mjs', 'build.mjs'];
|
|
266
|
+
for (const name of candidates) {
|
|
267
|
+
const rel = dir === '.' ? name : `${dir}/${name}`;
|
|
268
|
+
const full = await resolveSafeSourceFile(libraryPath, rel);
|
|
269
|
+
if (full) return rel;
|
|
270
|
+
}
|
|
271
|
+
return null;
|
|
196
272
|
}
|
|
197
273
|
|
|
198
|
-
const excludedLibraryDirectories = new Set(['archive', 'artifacts', 'builds', 'preflight', 'viewer-check']);
|
|
274
|
+
const excludedLibraryDirectories = new Set(['archive', 'artifacts', 'builds', 'materials', 'preflight', 'viewer-check']);
|
|
199
275
|
const libraryWorkDirectory = name => excludedLibraryDirectories.has(name.toLowerCase()) || /^build-\d+$/i.test(name);
|
|
200
276
|
|
|
201
|
-
export async function openProjectLibrary({ directory, sourceRoot, workspaceIdentity, binding, name, sketches = false, id = `library-${randomUUID()}` }) {
|
|
202
|
-
if (!binding && !path.isAbsolute(directory))
|
|
203
|
-
|
|
204
|
-
|
|
277
|
+
export async function openProjectLibrary({ directory, libraryDirectory, sourceRoot, workspaceIdentity, binding, name, sketches = true, scoped = false, id = `library-${randomUUID()}` }) {
|
|
278
|
+
if (!binding && !libraryDirectory && !path.isAbsolute(directory)) {
|
|
279
|
+
throw new DocumentError('INVALID_PROJECT', 'An absolute project directory is required.');
|
|
280
|
+
}
|
|
281
|
+
if (libraryDirectory && !path.isAbsolute(libraryDirectory)) {
|
|
282
|
+
throw new DocumentError('INVALID_PROJECT', 'An absolute library directory is required.');
|
|
283
|
+
}
|
|
284
|
+
const root = binding ? binding.root : libraryDirectory ? null : await captureDirectory(directory);
|
|
285
|
+
const library = binding?.library
|
|
286
|
+
?? (libraryDirectory ? await captureDirectory(libraryDirectory) : await captureDirectory(path.join(root.path, '.locus-map'), false));
|
|
205
287
|
if (!binding && !library.identity && !library.missing) {
|
|
206
288
|
throw new DocumentError('INVALID_PROJECT', 'The project library must be a regular directory.');
|
|
207
289
|
}
|
|
@@ -217,9 +299,19 @@ export async function openProjectLibrary({ directory, sourceRoot, workspaceIdent
|
|
|
217
299
|
return result;
|
|
218
300
|
};
|
|
219
301
|
return openProject({
|
|
220
|
-
projectRoot: library,
|
|
221
|
-
|
|
222
|
-
|
|
302
|
+
projectRoot: library,
|
|
303
|
+
catalog: { id, documents: [], links: [] },
|
|
304
|
+
library: {
|
|
305
|
+
name: name ?? path.basename(root?.path ?? library.path),
|
|
306
|
+
folder: path.basename(library.path),
|
|
307
|
+
path: library.path,
|
|
308
|
+
sketches,
|
|
309
|
+
scoped: Boolean(scoped || libraryDirectory),
|
|
310
|
+
},
|
|
311
|
+
workspace,
|
|
312
|
+
scan,
|
|
313
|
+
check,
|
|
314
|
+
publish: sketches ? (map, text) => publishSketch({ library, map, text, check }) : undefined,
|
|
223
315
|
});
|
|
224
316
|
}
|
|
225
317
|
|
|
@@ -228,7 +320,9 @@ async function discoverLibrary(projectRoot, sketches) {
|
|
|
228
320
|
const documents = [];
|
|
229
321
|
const manifests = [];
|
|
230
322
|
let entriesSeen = 0;
|
|
323
|
+
|
|
231
324
|
async function discover(parts = []) {
|
|
325
|
+
if (parts.length > limits.maxDepth) return;
|
|
232
326
|
const folder = path.join(libraryPath, ...parts);
|
|
233
327
|
if (await fs.realpath(folder) !== folder) return;
|
|
234
328
|
const entries = await fs.readdir(folder, { withFileTypes: true });
|
|
@@ -242,7 +336,7 @@ async function discoverLibrary(projectRoot, sketches) {
|
|
|
242
336
|
const relativePath = child.join('/');
|
|
243
337
|
if (!isPortablePath(relativePath)) continue;
|
|
244
338
|
if (item.isDirectory() && !libraryWorkDirectory(item.name)) await discover(child);
|
|
245
|
-
else if (
|
|
339
|
+
else if (item.isFile() && item.name === 'topic.json') manifests.push({ folder: parts.join('/'), relativePath });
|
|
246
340
|
else if (item.isFile() && (item.name.endsWith('.locus-map.json') || (sketches && isSketchPath(relativePath)))) {
|
|
247
341
|
if (documents.length === limits.documents) throw new DocumentError('INVALID_PROJECT', `Expected at most ${limits.documents} library documents.`);
|
|
248
342
|
documents.push({ id: relativePath, path: relativePath, sketch: isSketchPath(relativePath) });
|
|
@@ -250,35 +344,59 @@ async function discoverLibrary(projectRoot, sketches) {
|
|
|
250
344
|
}
|
|
251
345
|
}
|
|
252
346
|
if (identity !== null) await discover();
|
|
253
|
-
|
|
254
|
-
const
|
|
347
|
+
|
|
348
|
+
const sections = [];
|
|
349
|
+
const diagnostics = [];
|
|
350
|
+
const explicitSources = new Map();
|
|
351
|
+
const folderDepth = folder => (folder ? folder.split('/').length : 0);
|
|
352
|
+
// Process shallower manifests first so deeper (more specific) topic.json overrides source bindings cleanly.
|
|
353
|
+
manifests.sort((a, b) => folderDepth(a.folder) - folderDepth(b.folder));
|
|
354
|
+
|
|
255
355
|
for (const { folder, relativePath } of manifests) {
|
|
256
|
-
|
|
356
|
+
const prefix = folder ? folder + '/' : '';
|
|
357
|
+
const hasMembers = documents.some(doc => !folder || doc.path.startsWith(prefix));
|
|
358
|
+
if (!hasMembers) continue;
|
|
257
359
|
try {
|
|
258
360
|
const file = await openStableDocumentFile({ filePath: path.join(libraryPath, relativePath), projectRoot, maxBytes: limits.bytes });
|
|
259
|
-
const authored =
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
const qualify = address => {
|
|
263
|
-
const map = paths.get(address.map);
|
|
264
|
-
return map ? { ...address, map } : null;
|
|
265
|
-
};
|
|
361
|
+
const authored = parseTopicManifest((await file.read()).text);
|
|
362
|
+
const qualifyPath = rel => prefix + rel;
|
|
363
|
+
const qualify = address => ({ ...address, map: qualifyPath(address.map) });
|
|
266
364
|
const qualifyItem = item => item.children ? { ...item, children: item.children.map(qualifyItem) } : qualify(item);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
.
|
|
271
|
-
|
|
272
|
-
sections.push({
|
|
365
|
+
|
|
366
|
+
const identities = [...authored.models.entries()].map(([rel, modelId]) => [qualifyPath(rel), modelId]);
|
|
367
|
+
for (const [docRel, sourceRel] of authored.sources.entries()) {
|
|
368
|
+
explicitSources.set(qualifyPath(docRel), qualifyPath(sourceRel));
|
|
369
|
+
}
|
|
370
|
+
sections.push({
|
|
371
|
+
folder,
|
|
372
|
+
...(authored.title && { title: authored.title }),
|
|
373
|
+
...(authored.entry && { entry: qualify(authored.entry) }),
|
|
374
|
+
...(authored.order && { order: authored.order }),
|
|
375
|
+
...(authored.navigation && { navigation: authored.navigation.map(qualifyItem) }),
|
|
376
|
+
identities,
|
|
377
|
+
links: authored.links.map(link => ({ from: qualify(link.from), to: qualify(link.to) })),
|
|
378
|
+
});
|
|
273
379
|
} catch {
|
|
274
|
-
diagnostics.push({ code: 'FOLDER_CATALOG_UNAVAILABLE', message: 'Could not use the
|
|
380
|
+
diagnostics.push({ code: 'FOLDER_CATALOG_UNAVAILABLE', message: 'Could not use the topic manifest.', folder });
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
for (const doc of documents) {
|
|
385
|
+
if (doc.sketch) continue;
|
|
386
|
+
const declared = explicitSources.get(doc.path);
|
|
387
|
+
if (declared) {
|
|
388
|
+
const full = await resolveSafeSourceFile(libraryPath, declared);
|
|
389
|
+
if (full) { doc.sourcePath = declared; continue; }
|
|
275
390
|
}
|
|
391
|
+
const sibling = await findSiblingSource(libraryPath, doc.path);
|
|
392
|
+
if (sibling) doc.sourcePath = sibling;
|
|
276
393
|
}
|
|
394
|
+
|
|
277
395
|
return { documents, sections, diagnostics };
|
|
278
396
|
}
|
|
279
397
|
|
|
280
398
|
async function openProject({ projectRoot, catalog: { id: project, entry, documents, links, navigation }, manifestIdentity,
|
|
281
|
-
library, workspace, folder, scan, publish }) {
|
|
399
|
+
library, workspace, folder, scan, check, publish }) {
|
|
282
400
|
let members = new Map();
|
|
283
401
|
const identities = new Set(manifestIdentity ? [manifestIdentity] : []);
|
|
284
402
|
let closing = false;
|
|
@@ -293,10 +411,15 @@ async function openProject({ projectRoot, catalog: { id: project, entry, documen
|
|
|
293
411
|
return next;
|
|
294
412
|
}
|
|
295
413
|
const closeWriter = member => member.writer?.close();
|
|
296
|
-
async function register({ id, modelId, path: relativePath, sketch }) {
|
|
414
|
+
async function register({ id, modelId, path: relativePath, sketch, sourcePath }) {
|
|
297
415
|
const retained = members.get(id);
|
|
298
|
-
if (retained?.file)
|
|
299
|
-
|
|
416
|
+
if (retained?.file) {
|
|
417
|
+
retained.document.sourcePath = sourcePath;
|
|
418
|
+
return retained;
|
|
419
|
+
}
|
|
420
|
+
const member = {
|
|
421
|
+
document: { id, modelId, relativePath, ...(sketch && { kind: 'sketch' }), ...(sourcePath && { sourcePath }) },
|
|
422
|
+
};
|
|
300
423
|
try {
|
|
301
424
|
member.file = await openStableDocumentFile({ filePath: path.join(projectRoot.path, relativePath), projectRoot });
|
|
302
425
|
} catch (error) { member.registrationError = error; return member; }
|
|
@@ -332,9 +455,15 @@ async function openProject({ projectRoot, catalog: { id: project, entry, documen
|
|
|
332
455
|
return member;
|
|
333
456
|
}
|
|
334
457
|
function scoped(map, member, { revision, readOnly, bundle, outcome }) {
|
|
335
|
-
const { document: { relativePath, kind }, file } = member;
|
|
336
|
-
return {
|
|
337
|
-
|
|
458
|
+
const { document: { relativePath, kind, sourcePath }, file } = member;
|
|
459
|
+
return {
|
|
460
|
+
project, map, relativePath,
|
|
461
|
+
...(kind && { kind }),
|
|
462
|
+
...(sourcePath && { sourcePath }),
|
|
463
|
+
...(workspace && { documentPath: file.path }),
|
|
464
|
+
revision, readOnly, bundle,
|
|
465
|
+
...(outcome && { outcome }),
|
|
466
|
+
};
|
|
338
467
|
}
|
|
339
468
|
async function read(map, authorized = false) {
|
|
340
469
|
const member = memberFor(map);
|
|
@@ -364,12 +493,15 @@ async function openProject({ projectRoot, catalog: { id: project, entry, documen
|
|
|
364
493
|
const title = path.posix.basename(map, sketch ? '.excalidraw' : '.locus-map.json');
|
|
365
494
|
try {
|
|
366
495
|
const { bundle } = await read(map);
|
|
367
|
-
summaries.set(map, sketch ? {
|
|
368
|
-
views: [{ id: sketchView, title, family: sketchView, depth: 0 }] },
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
496
|
+
summaries.set(map, sketch ? {
|
|
497
|
+
row: { ...member.document, title, status: 'available', views: [{ id: sketchView, title, family: sketchView, depth: 0 }] },
|
|
498
|
+
triggers: new Map(), internal: new Set(),
|
|
499
|
+
} : summarize(member.document, bundle));
|
|
500
|
+
} catch (error) {
|
|
501
|
+
summaries.set(map, {
|
|
502
|
+
row: { ...member.document, title: library ? title : map, status: 'unavailable', views: [], diagnostic: projectDiagnostic(error) },
|
|
503
|
+
triggers: new Map(), internal: new Set(),
|
|
504
|
+
});
|
|
373
505
|
}
|
|
374
506
|
}
|
|
375
507
|
const resolveNavigation = item => {
|
|
@@ -382,18 +514,31 @@ async function openProject({ projectRoot, catalog: { id: project, entry, documen
|
|
|
382
514
|
return { ...item, title: title || item.node || item.view, available: Boolean(title) };
|
|
383
515
|
};
|
|
384
516
|
const rows = [...summaries.values()].map(summary => summary.row);
|
|
385
|
-
const
|
|
517
|
+
const isDraftDoc = row => /(?:^|\/)drafts\//i.test(row.relativePath ?? '');
|
|
518
|
+
const first = library && (
|
|
519
|
+
rows.find(row => row.status === 'available' && row.kind !== 'sketch' && !isDraftDoc(row))
|
|
520
|
+
?? rows.find(row => row.status === 'available' && row.kind !== 'sketch')
|
|
521
|
+
?? rows.find(row => row.status === 'available')
|
|
522
|
+
);
|
|
386
523
|
const sectionDiagnostics = [...diagnostics];
|
|
387
524
|
const qualifiedLinks = [...links];
|
|
525
|
+
let rootEntry = null;
|
|
388
526
|
const qualified = sections?.map(section => {
|
|
389
527
|
const unavailable = new Set(section.identities.filter(([map, modelId]) => {
|
|
390
528
|
const row = summaries.get(map)?.row;
|
|
391
529
|
return !row || row.status !== 'available' || row.modelId !== modelId;
|
|
392
530
|
}).map(([map]) => map));
|
|
393
|
-
const rootUnavailable =
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
531
|
+
const rootUnavailable = Boolean(section.entry && (
|
|
532
|
+
unavailable.has(section.entry.map)
|
|
533
|
+
|| !summaries.get(section.entry.map)?.row.views.some(view => view.id === section.entry.view)
|
|
534
|
+
));
|
|
535
|
+
if (unavailable.size || rootUnavailable) {
|
|
536
|
+
sectionDiagnostics.push({
|
|
537
|
+
code: 'FOLDER_CONTENTS_INCOMPLETE',
|
|
538
|
+
message: 'Some topic destinations are missing or no longer match their declared model.',
|
|
539
|
+
folder: section.folder,
|
|
540
|
+
});
|
|
541
|
+
}
|
|
397
542
|
const retain = item => {
|
|
398
543
|
if (item.children) {
|
|
399
544
|
const children = item.children.flatMap(retain);
|
|
@@ -407,17 +552,27 @@ async function openProject({ projectRoot, catalog: { id: project, entry, documen
|
|
|
407
552
|
if (unavailable.has(link.from.map) || (unavailable.has(link.to.map) && summaries.has(link.to.map))) continue;
|
|
408
553
|
qualifiedLinks.push(link);
|
|
409
554
|
}
|
|
410
|
-
|
|
411
|
-
|
|
555
|
+
if (section.folder === '' && section.entry && !rootUnavailable) rootEntry = section.entry;
|
|
556
|
+
return {
|
|
557
|
+
folder: section.folder,
|
|
558
|
+
...(section.title && { title: section.title }),
|
|
559
|
+
...(section.entry && { entry: section.entry }),
|
|
560
|
+
...(section.order && { order: section.order }),
|
|
561
|
+
...(section.navigation && { navigation: section.navigation.flatMap(retain) }),
|
|
562
|
+
...(rootUnavailable && { rootUnavailable }),
|
|
563
|
+
};
|
|
412
564
|
});
|
|
413
565
|
const admitted = admitLinks(qualifiedLinks, summaries);
|
|
414
566
|
return {
|
|
415
567
|
...(folder && { folder }),
|
|
416
568
|
...(workspace && { workspace: (await workspace()).info }),
|
|
417
569
|
...(qualified && { sections: qualified }),
|
|
418
|
-
project,
|
|
570
|
+
project,
|
|
571
|
+
entry: entry ?? rootEntry ?? (first ? { map: first.id, view: first.views[0].id } : null),
|
|
419
572
|
...(navigation && { navigation: navigation.map(resolveNavigation) }),
|
|
420
|
-
documents: rows,
|
|
573
|
+
documents: rows,
|
|
574
|
+
links: admitted.links,
|
|
575
|
+
diagnostics: [...admitted.diagnostics, ...sectionDiagnostics],
|
|
421
576
|
};
|
|
422
577
|
}
|
|
423
578
|
|
|
@@ -447,9 +602,16 @@ async function openProject({ projectRoot, catalog: { id: project, entry, documen
|
|
|
447
602
|
}),
|
|
448
603
|
...(workspace && {
|
|
449
604
|
workspace: (await workspace()).info,
|
|
450
|
-
editorPaths: map => serial(async () => {
|
|
605
|
+
editorPaths: (map, target = 'document') => serial(async () => {
|
|
451
606
|
if (map === null) return [await (await workspace()).openProjectPath()];
|
|
452
607
|
const member = memberFor(map);
|
|
608
|
+
if (target === 'source') {
|
|
609
|
+
if (check) await check();
|
|
610
|
+
if (!member.document.sourcePath) throw new DocumentError('DOCUMENT_MISSING', 'No authored source file is bound to this map.');
|
|
611
|
+
const verified = await resolveSafeSourceFile(projectRoot.path, member.document.sourcePath);
|
|
612
|
+
if (!verified) throw new DocumentError('DOCUMENT_MISSING', 'The authored source file is unavailable.');
|
|
613
|
+
return [verified];
|
|
614
|
+
}
|
|
453
615
|
await member.file.read();
|
|
454
616
|
return [member.file.path];
|
|
455
617
|
}),
|
|
@@ -460,11 +622,16 @@ async function openProject({ projectRoot, catalog: { id: project, entry, documen
|
|
|
460
622
|
if (!sketch && !member.document.modelId) await read(map);
|
|
461
623
|
if (closing) throw new DocumentError('OWNER_CLOSED', 'The project viewer is closing.');
|
|
462
624
|
try {
|
|
463
|
-
member.writer ??= await (sketch ? openSketchWriter(member.file)
|
|
625
|
+
member.writer ??= await (sketch ? openSketchWriter(member.file)
|
|
626
|
+
: openLocalDocument({ projectFile: member.file, modelId: member.document.modelId, role: 'viewer' }));
|
|
464
627
|
return scoped(map, member, await member.writer.read({ requireWrite: true }));
|
|
465
628
|
} catch (error) {
|
|
466
629
|
const readOnlyReason = writeLimit(error);
|
|
467
630
|
if (!readOnlyReason) throw error;
|
|
631
|
+
if (error.code === 'DOCUMENT_LOCKED' && member.writer) {
|
|
632
|
+
await closeWriter(member);
|
|
633
|
+
member.writer = undefined;
|
|
634
|
+
}
|
|
468
635
|
return { ...await read(map), readOnlyReason };
|
|
469
636
|
}
|
|
470
637
|
}),
|
|
@@ -131,7 +131,7 @@ export async function bindMapInputs(repository, library, entries, registryFile)
|
|
|
131
131
|
if (!artifactPath(document, artifact) || path.dirname(path.resolve(bundlePath)) !== path.resolve(outputDir)) throw new Error('Unexpected candidate for the build input record.');
|
|
132
132
|
const artifactVersion = await localFileVersion(library.path, artifact);
|
|
133
133
|
if (!artifactVersion) throw new Error('The verified build output is missing.');
|
|
134
|
-
const lock = await acquireDocumentLock(record, { checkParents: guard });
|
|
134
|
+
const lock = await acquireDocumentLock(record, { checkParents: guard, role: 'build' });
|
|
135
135
|
try {
|
|
136
136
|
const data = { format: 'locus-map.build-inputs', version: 1, document, artifact, artifactVersion, workingRoot, recipe, inputs: source.inputs, versions: before };
|
|
137
137
|
const text = JSON.stringify(data) + '\n';
|