@locus-forge/locus-map 0.2.0 → 0.2.2-dev.20261206.g5e970d2
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-JiCO6vo-.js} +1 -1
- package/dist/assets/{ar-SA-G6X2FPQ2-LY3czoz9.js → ar-SA-G6X2FPQ2-BdzEBmp3.js} +1 -1
- package/dist/assets/{architectureDiagram-5GKGNRK7-BG9h9KRx.js → architectureDiagram-5GKGNRK7-D7T_vJwe.js} +1 -1
- package/dist/assets/{az-AZ-76LH7QW2-Brv6kuM6.js → az-AZ-76LH7QW2-BQ_SoVB7.js} +1 -1
- package/dist/assets/{bg-BG-XCXSNQG7-tsQwwvMW.js → bg-BG-XCXSNQG7-DlH1olUf.js} +1 -1
- package/dist/assets/{blockDiagram-I7D4REHJ-V9bUuR63.js → blockDiagram-I7D4REHJ-DPz0LEjY.js} +1 -1
- package/dist/assets/{bn-BD-2XOGV67Q-0Cou5nNv.js → bn-BD-2XOGV67Q-CFIZU06C.js} +1 -1
- package/dist/assets/{c4Diagram-7LVT6UL2-BmCtzbrY.js → c4Diagram-7LVT6UL2-B6uCi0Ol.js} +1 -1
- package/dist/assets/{ca-ES-6MX7JW3Y-pZF7WJUL.js → ca-ES-6MX7JW3Y-Bpe3kOti.js} +1 -1
- package/dist/assets/channel-DB3atv5o.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-D2iTDmHh.js → chunk-2Q5K7J3B-DTWRWhpx.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-CTxdXZIx.js → chunk-5VM5RSS4-Dfr1HUAN.js} +1 -1
- package/dist/assets/{chunk-F27PBJKO-Hic1X1pm.js → chunk-F27PBJKO-D_IVoCIK.js} +1 -1
- package/dist/assets/{chunk-IMKFNOWR-DhLW1JVb.js → chunk-IMKFNOWR-Boa_chn8.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-_g5twKlC.js → chunk-JWPE2WC7-RaK8jzc2.js} +1 -1
- package/dist/assets/{chunk-POPQ4Y6H-DMV4qmkd.js → chunk-POPQ4Y6H-D7xOpv6O.js} +1 -1
- package/dist/assets/{chunk-SVP7TREG-BWg83oEL.js → chunk-SVP7TREG-XvJsx1jt.js} +1 -1
- package/dist/assets/{chunk-TICWLB2K-CPmkpa7J.js → chunk-TICWLB2K-DZCVWmZG.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-KnXvIZ_8.js → chunk-XXDRQBXY-Djk-REAy.js} +1 -1
- package/dist/assets/classDiagram-ZZMXUADV-CzvsXoj_.js +1 -0
- package/dist/assets/classDiagram-v2-VYDZK3BY-HxwJpdPt.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-BChK_CGh.js → cose-bilkent-JH36ORCC-D6XaIbtG.js} +1 -1
- package/dist/assets/{cs-CZ-2BRQDIVT-CtAC2Qjy.js → cs-CZ-2BRQDIVT-BdzgSHdJ.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-CdsltaMX.js → cynefin-OW5HDTMX-BMTkMDG1.js} +1 -1
- package/dist/assets/{cynefinDiagram-5FMLGOSQ-bXvXX3Fx.js → cynefinDiagram-5FMLGOSQ-C2s5i9h9.js} +1 -1
- package/dist/assets/{d3-scale-sM87TD1Z.js → d3-scale-BMIMKl27.js} +1 -1
- package/dist/assets/{da-DK-5WZEPLOC-DyWwaclV.js → da-DK-5WZEPLOC-Bj-GFWHU.js} +1 -1
- package/dist/assets/{dagre-GXQ25YYZ-CTmiZZVO.js → dagre-GXQ25YYZ-CMT8wlz0.js} +1 -1
- package/dist/assets/{de-DE-XR44H4JA-BDXUBHki.js → de-DE-XR44H4JA-JmpondAB.js} +1 -1
- package/dist/assets/{diagram-S7CK7UJ4-Bm8Fy0R_.js → diagram-S7CK7UJ4-DU1blS3M.js} +1 -1
- package/dist/assets/{diagram-UQ7AKVKN-BU_AmM_A.js → diagram-UQ7AKVKN-0lWi4KDV.js} +1 -1
- package/dist/assets/{diagram-VSXAHHWV-B78LUoXq.js → diagram-VSXAHHWV-CrseWrhn.js} +1 -1
- package/dist/assets/{diagram-VX7I27RA-DNvWjMlf.js → diagram-VX7I27RA-C5BMS8Ql.js} +1 -1
- package/dist/assets/{diagram-Z3DM3KII-DmFVt1fa.js → diagram-Z3DM3KII-Cc3vq6b8.js} +1 -1
- package/dist/assets/{ebnfDiagram-PWID7BFC-CpDna0Jp.js → ebnfDiagram-PWID7BFC-ZF78imma.js} +1 -1
- package/dist/assets/{el-GR-BZB4AONW-CNhF7oN2.js → el-GR-BZB4AONW-BFslUpdm.js} +1 -1
- package/dist/assets/{engines-a8mi_N6S.js → engines-BtEtIBXt.js} +1 -1
- package/dist/assets/{erDiagram-RLTQ6QDP-BGD-9OAS.js → erDiagram-RLTQ6QDP-CjPjDn2i.js} +1 -1
- package/dist/assets/{es-ES-U4NZUMDT-DXMrJcKL.js → es-ES-U4NZUMDT-B0ezBTxQ.js} +1 -1
- package/dist/assets/{eu-ES-A7QVB2H4-BTkMEwMi.js → eu-ES-A7QVB2H4-DP_gx2kf.js} +1 -1
- package/dist/assets/{fa-IR-HGAKTJCU-CgkknSS7.js → fa-IR-HGAKTJCU-BuT1ELty.js} +1 -1
- package/dist/assets/{fi-FI-Z5N7JZ37-B1K83nId.js → fi-FI-Z5N7JZ37-BAu_Cj7n.js} +1 -1
- package/dist/assets/{flowDiagram-HODETNUW-CjU1yR1F.js → flowDiagram-HODETNUW-yqPGWNdd.js} +1 -1
- package/dist/assets/{fr-FR-RHASNOE6-CBFZBGMr.js → fr-FR-RHASNOE6-OF1CpgtN.js} +1 -1
- package/dist/assets/{ganttDiagram-EL5Y4UJY-bvb8BjSh.js → ganttDiagram-EL5Y4UJY-zUY5je2K.js} +1 -1
- package/dist/assets/{gitGraphDiagram-WWUBYQGX-DZXQ_x8t.js → gitGraphDiagram-WWUBYQGX-oWrs7wy0.js} +1 -1
- package/dist/assets/{gl-ES-HMX3MZ6V-CON98Mma.js → gl-ES-HMX3MZ6V-CkJ47l98.js} +1 -1
- package/dist/assets/{he-IL-6SHJWFNN-CBoFaEdB.js → he-IL-6SHJWFNN-D7CecRlh.js} +1 -1
- package/dist/assets/{hi-IN-IWLTKZ5I-BJuoh3dl.js → hi-IN-IWLTKZ5I-CGlW2X-h.js} +1 -1
- package/dist/assets/{hu-HU-A5ZG7DT2-CQruu8XR.js → hu-HU-A5ZG7DT2-Dq_n_tbp.js} +1 -1
- package/dist/assets/{id-ID-SAP4L64H-VhaoENjR.js → id-ID-SAP4L64H-CotwO_06.js} +1 -1
- package/dist/assets/index-CdVc9Lmz.js +624 -0
- package/dist/assets/{index-CDNl17QJ.css → index-Cv-tTxNC.css} +1 -1
- package/dist/assets/{index-CboxqaL5.js → index-VaWCb9bx.js} +5 -5
- package/dist/assets/{infoDiagram-27XIBGKW-CM9Hap0f.js → infoDiagram-27XIBGKW-CYzIkNFW.js} +1 -1
- package/dist/assets/{ishikawaDiagram-5VMMS53U-i8pQztJI.js → ishikawaDiagram-5VMMS53U-DkgUsuk5.js} +1 -1
- package/dist/assets/{it-IT-JPQ66NNP-Dj9BkXfh.js → it-IT-JPQ66NNP-h97o81us.js} +1 -1
- package/dist/assets/{ja-JP-DBVTYXUO-CB2BlfIS.js → ja-JP-DBVTYXUO-M6EVfh0o.js} +1 -1
- package/dist/assets/{journeyDiagram-3NMN7TZE-PxcdqONT.js → journeyDiagram-3NMN7TZE-CuKkNrJy.js} +1 -1
- package/dist/assets/{kaa-6HZHGXH3-CLnR_zY5.js → kaa-6HZHGXH3-DUy85zzz.js} +1 -1
- package/dist/assets/{kab-KAB-ZGHBKWFO-8TJr4nPf.js → kab-KAB-ZGHBKWFO-ChL-fKtk.js} +1 -1
- package/dist/assets/{kanban-definition-UXKFOSKX-B2p5NBhO.js → kanban-definition-UXKFOSKX-DkOxt3kf.js} +1 -1
- package/dist/assets/{kk-KZ-P5N5QNE5-5uZYjZ2e.js → kk-KZ-P5N5QNE5-DY6ucSGD.js} +1 -1
- package/dist/assets/{km-KH-HSX4SM5Z-D54aOpMd.js → km-KH-HSX4SM5Z-BAaS4014.js} +1 -1
- package/dist/assets/{ko-KR-MTYHY66A-Bnm0G6eo.js → ko-KR-MTYHY66A-D-r3mJ1R.js} +1 -1
- package/dist/assets/{ku-TR-6OUDTVRD-CtGCn_eB.js → ku-TR-6OUDTVRD-Dk1GCoOP.js} +1 -1
- package/dist/assets/{layout-BBV3_Svw.js → layout-DtNEGI4_.js} +1 -1
- package/dist/assets/{lt-LT-XHIRWOB4-Bl8G0yv6.js → lt-LT-XHIRWOB4-3Z2Ui1VZ.js} +1 -1
- package/dist/assets/{lv-LV-5QDEKY6T-Cax93Eua.js → lv-LV-5QDEKY6T-Bg59rOkR.js} +1 -1
- package/dist/assets/{mindmap-definition-YA3MSWOX-CsOezwmE.js → mindmap-definition-YA3MSWOX-Dcs8eV7p.js} +1 -1
- package/dist/assets/{mr-IN-CRQNXWMA-Br7GVyJH.js → mr-IN-CRQNXWMA-DepTOG29.js} +1 -1
- package/dist/assets/{my-MM-5M5IBNSE-xC6lzTDV.js → my-MM-5M5IBNSE-4KqL4Tav.js} +1 -1
- package/dist/assets/{nb-NO-T6EIAALU-B0i5THqA.js → nb-NO-T6EIAALU-5YWO_l3W.js} +1 -1
- package/dist/assets/{nl-NL-IS3SIHDZ-CqYhUjP3.js → nl-NL-IS3SIHDZ-QlAndkM2.js} +1 -1
- package/dist/assets/{nn-NO-6E72VCQL-rpjr_9Z5.js → nn-NO-6E72VCQL-BscwhEDW.js} +1 -1
- package/dist/assets/{oc-FR-POXYY2M6-BlhQ99Ty.js → oc-FR-POXYY2M6-k7bYbSQj.js} +1 -1
- package/dist/assets/{pa-IN-N4M65BXN-N2XbQgZ_.js → pa-IN-N4M65BXN-jxBFwrWj.js} +1 -1
- package/dist/assets/{pegDiagram-XKGWAZYB-C2iSJgYQ.js → pegDiagram-XKGWAZYB-zM-VZA3r.js} +1 -1
- package/dist/assets/{pica-DvYcrBvx.js → pica-CsWQ4DPU.js} +1 -1
- package/dist/assets/{pieDiagram-E7YTZNPT-CUjgOGBw.js → pieDiagram-E7YTZNPT-C60FE0D8.js} +1 -1
- package/dist/assets/{pl-PL-T2D74RX3-CnMxn1dA.js → pl-PL-T2D74RX3-be8atU_l.js} +1 -1
- package/dist/assets/{pt-BR-5N22H2LF-Di-jnHb3.js → pt-BR-5N22H2LF-CSE0O2fj.js} +1 -1
- package/dist/assets/{pt-PT-UZXXM6DQ-BaAKq8Sh.js → pt-PT-UZXXM6DQ-5rnYJhy1.js} +1 -1
- package/dist/assets/{quadrantDiagram-AXDQQJYC-DwwqgJXZ.js → quadrantDiagram-AXDQQJYC-DyH84hx6.js} +1 -1
- package/dist/assets/{railroadDiagram-O6MQD6OU-DyRgYGPF.js → railroadDiagram-O6MQD6OU-DCrJgP9s.js} +1 -1
- package/dist/assets/{requirementDiagram-BXWQKSXE-C3ixXeHJ.js → requirementDiagram-BXWQKSXE-C78-QlFo.js} +1 -1
- package/dist/assets/{ro-RO-JPDTUUEW-BWrclVyo.js → ro-RO-JPDTUUEW-Gh6EgC27.js} +1 -1
- package/dist/assets/{ru-RU-B4JR7IUQ-_z0DINaG.js → ru-RU-B4JR7IUQ-BUWESZhq.js} +1 -1
- package/dist/assets/{sankeyDiagram-P5KCCOFB-mKpKYI_w.js → sankeyDiagram-P5KCCOFB-D_MOkKEs.js} +1 -1
- package/dist/assets/{sequenceDiagram-WJ2MYXX4-ZkNd0Wnj.js → sequenceDiagram-WJ2MYXX4-BeQbHZRB.js} +1 -1
- package/dist/assets/{si-LK-N5RQ5JYF-CdKOb383.js → si-LK-N5RQ5JYF-C9pnvQMf.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-hQLGO-0z.js → sizeCapture-INFHLROL-DUn-Mus_.js} +1 -1
- package/dist/assets/{sk-SK-C5VTKIMK-MHJC6ZIe.js → sk-SK-C5VTKIMK-FnkPBibb.js} +1 -1
- package/dist/assets/{sl-SI-NN7IZMDC-BF9YWbZx.js → sl-SI-NN7IZMDC-Cwrqj_B9.js} +1 -1
- package/dist/assets/{stateDiagram-D77RDMKH-CRWj3j-B.js → stateDiagram-D77RDMKH-C3EF3jQ3.js} +1 -1
- package/dist/assets/stateDiagram-v2-MP3YSRHH-CVQHmIvK.js +1 -0
- package/dist/assets/{subset-shared.chunk-DtxXjVIA.js → subset-shared.chunk-8ifLcT_D.js} +1 -1
- package/dist/assets/{subset-worker.chunk-DONNSbUF.js → subset-worker.chunk-DrNTybDR.js} +1 -1
- package/dist/assets/{sv-SE-XGPEYMSR-DkaTkfUY.js → sv-SE-XGPEYMSR-Btz80pGx.js} +1 -1
- package/dist/assets/{swimlanes-42K2YHIH-CFf6j7jO.js → swimlanes-42K2YHIH-B2_kGhPA.js} +1 -1
- package/dist/assets/swimlanesDiagram-VR7AAH4N-C1rOmrkT.js +8 -0
- package/dist/assets/{ta-IN-2NMHFXQM-BfxqXEDI.js → ta-IN-2NMHFXQM-B0bWtgu1.js} +1 -1
- package/dist/assets/{th-TH-HPSO5L25-DT3vLA39.js → th-TH-HPSO5L25-DgC0yFw3.js} +1 -1
- package/dist/assets/{timeline-definition-24CTP7MA-BGP2Dq8M.js → timeline-definition-24CTP7MA-Bu0W3Mcy.js} +1 -1
- package/dist/assets/{tr-TR-DEFEU3FU-CdfsG7py.js → tr-TR-DEFEU3FU-C9Mmy6ri.js} +1 -1
- package/dist/assets/{uk-UA-QMV73CPH-CZrQuC1S.js → uk-UA-QMV73CPH-rxEnqB_i.js} +1 -1
- package/dist/assets/{vennDiagram-4TSXK5OY-CaxGPIab.js → vennDiagram-4TSXK5OY-63JTeOph.js} +1 -1
- package/dist/assets/{vi-VN-M7AON7JQ-DQJk1_KV.js → vi-VN-M7AON7JQ-DOVa-vAT.js} +1 -1
- package/dist/assets/{wardleyDiagram-VM6X3IG4-DQxQ-zXH.js → wardleyDiagram-VM6X3IG4-Bct0TRuC.js} +1 -1
- package/dist/assets/{xychartDiagram-S5SC5T6Z-DoxdZQ6R.js → xychartDiagram-S5SC5T6Z-C21zgvSM.js} +1 -1
- package/dist/assets/{zh-CN-LNUGB5OW-DRVBfkOy.js → zh-CN-LNUGB5OW-MyifsmQ8.js} +1 -1
- package/dist/assets/{zh-HK-E62DVLB3-BJHrltss.js → zh-HK-E62DVLB3-Cp55UViv.js} +1 -1
- package/dist/assets/{zh-TW-RAJ6MFWO-DpMZ5m2x.js → zh-TW-RAJ6MFWO-DMy6SZap.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 +17 -14
- package/docs/MODEL-CONTRACT.md +7 -4
- package/docs/PLANTUML-SOURCE.md +3 -2
- package/docs/VIEWER-LAUNCH.md +13 -3
- package/docs/VIEWER.md +93 -26
- package/docs/capabilities.json +21 -3
- package/package.json +2 -1
- package/scripts/build-map.mjs +1 -1
- package/scripts/lib/map-viewer-server.mjs +48 -24
- package/scripts/lib/original-materials.mjs +1 -1
- package/scripts/lib/original-report-server.mjs +7 -3
- package/scripts/lib/project-catalog.mjs +14 -2
- package/scripts/lib/project-map-inputs.mjs +1 -1
- package/scripts/lib/sketch-publication.mjs +1 -1
- package/scripts/lib/task-map-build.mjs +1 -1
- package/scripts/lib/view-args.mjs +183 -0
- package/scripts/lib/workflow/reader-surface.mjs +29 -11
- package/scripts/locus-map.mjs +14 -20
- package/scripts/open-map.mjs +84 -49
- package/skills/README.md +2 -1
- package/skills/locus-map/SKILL.md +27 -25
- 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/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 +127 -0
- package/skills/locus-map-primitives/SKILL.md +6 -2
- 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 +59 -18
- package/src/chain/validation.js +7 -1
- package/src/contract/readingMaterials.js +18 -2
- package/src/contract/readingTable.js +66 -0
- package/src/viewer/ControlIcon.jsx +1 -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/ProjectRail.jsx +11 -5
- package/src/viewer/ProjectViewChainViewer.jsx +222 -70
- package/src/viewer/ReadingTable.jsx +151 -0
- package/src/viewer/SketchCanvas.jsx +15 -75
- package/src/viewer/ViewChainViewer.jsx +543 -52
- 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/readingTable.css +47 -0
- package/src/viewer/sketchSettling.js +71 -0
- package/src/viewer/useInspectorPosition.js +116 -35
- package/src/viewer/viewChain.css +40 -4
- 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
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { presentation as drawPresentation } from '@locus-forge/locus-draw/scene';
|
|
1
2
|
import { isModernProfile } from '@locus-forge/locus-draw/source';
|
|
2
3
|
import { inspectDiagramLayout } from './diagramLayoutChecks.js';
|
|
3
|
-
import { inspectAreaLayout, ROUTE_DETOUR_WARN_RATIO } from '../adapter/areas.js';
|
|
4
|
+
import { ADJACENT_DETOUR_WARN_RATIO, inspectAreaLayout, ROUTE_DETOUR_WARN_RATIO } from '../adapter/areas.js';
|
|
4
5
|
import { inspectPageLayout } from '../adapter/page.js';
|
|
6
|
+
import { savedCardTemplate, supportedCardPresentation } from '../adapter/cards/template.js';
|
|
5
7
|
import { C4_REFERENCE_PROFILE, isDiagramPresentationProfile, isEditorialPresentationProfile, relationPresentation } from '../contract/diagramPresentation.js';
|
|
6
8
|
|
|
7
9
|
export const DIAGRAM_READABILITY = Object.freeze({
|
|
@@ -88,6 +90,124 @@ function conditionInLabel(edge) {
|
|
|
88
90
|
return pattern.test(normalizedConditionText(edge.label ?? ''));
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
const TITLE_ORPHAN_LINE_RATIO = 0.35;
|
|
94
|
+
const TITLE_SINGLE_WORD_BALANCE_RATIO = 0.55;
|
|
95
|
+
const TITLE_NAME_ROLES = new Set(['name', 'label']);
|
|
96
|
+
const COMPOSITE_CARD_ROLES = new Set(['card-outline', 'card-fold', 'card-cap']);
|
|
97
|
+
|
|
98
|
+
function profileWiderCardOption(profile) {
|
|
99
|
+
if (!profile || !supportedCardPresentation(profile)) return null;
|
|
100
|
+
const template = savedCardTemplate(profile);
|
|
101
|
+
const baseWidth = template?.card?.width;
|
|
102
|
+
if (!Number.isFinite(baseWidth)) return null;
|
|
103
|
+
if (Number.isFinite(template?.extraWide?.width) && template.extraWide.width > baseWidth) {
|
|
104
|
+
return { size: 'extra-wide', width: template.extraWide.width };
|
|
105
|
+
}
|
|
106
|
+
if (Number.isFinite(template?.card?.wideWidth) && template.card.wideWidth > baseWidth) {
|
|
107
|
+
return { size: 'wide', width: template.card.wideWidth };
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Flag awkward automatic title wraps without nagging over intentional breaks or balanced two-line titles. */
|
|
113
|
+
export function inspectTitleWraps(model, scene) {
|
|
114
|
+
const elements = Array.isArray(scene?.elements) ? scene.elements : [];
|
|
115
|
+
const shapesById = new Map();
|
|
116
|
+
const compositeIds = new Set();
|
|
117
|
+
const outlinesById = new Map();
|
|
118
|
+
const foldsById = new Set();
|
|
119
|
+
const glyphIds = new Set();
|
|
120
|
+
for (const element of elements) {
|
|
121
|
+
const mapping = element?.customData?.locusMap;
|
|
122
|
+
if (element?.isDeleted || mapping?.kind !== 'node') continue;
|
|
123
|
+
if (mapping.role === 'shape') shapesById.set(mapping.semanticId, element);
|
|
124
|
+
if (COMPOSITE_CARD_ROLES.has(mapping.role)) compositeIds.add(mapping.semanticId);
|
|
125
|
+
if (mapping.role === 'card-outline') outlinesById.set(mapping.semanticId, element);
|
|
126
|
+
if (mapping.role === 'card-fold') foldsById.add(mapping.semanticId);
|
|
127
|
+
if (typeof mapping.role === 'string' && mapping.role.startsWith('icon-')) glyphIds.add(mapping.semanticId);
|
|
128
|
+
}
|
|
129
|
+
const nodesById = new Map((model?.nodes ?? []).map(node => [node.id, node]));
|
|
130
|
+
const profile = model?.presentationProfile;
|
|
131
|
+
const widerOption = profileWiderCardOption(profile);
|
|
132
|
+
const templateCard = profile && supportedCardPresentation(profile) ? savedCardTemplate(profile)?.card : null;
|
|
133
|
+
const findings = [];
|
|
134
|
+
for (const element of elements) {
|
|
135
|
+
const mapping = element?.customData?.locusMap;
|
|
136
|
+
if (element?.type !== 'text' || element.isDeleted || mapping?.kind !== 'node' || !TITLE_NAME_ROLES.has(mapping.role)) continue;
|
|
137
|
+
if (typeof element.text !== 'string' || !Number.isFinite(element.fontSize) || element.fontSize <= 0) continue;
|
|
138
|
+
const lines = element.text.replace(/\r\n?/gu, '\n').split('\n').map(line => line.trim()).filter(Boolean);
|
|
139
|
+
if (lines.length <= 1) continue;
|
|
140
|
+
const modelNode = nodesById.get(mapping.semanticId);
|
|
141
|
+
const explicitBreak = (typeof modelNode?.label === 'string' && /[\r\n]/u.test(modelNode.label))
|
|
142
|
+
|| (typeof element.originalText === 'string' && /[\r\n]/u.test(element.originalText));
|
|
143
|
+
if (explicitBreak) continue;
|
|
144
|
+
|
|
145
|
+
const rawSingleLine = typeof element.originalText === 'string' && element.originalText.trim()
|
|
146
|
+
? element.originalText
|
|
147
|
+
: typeof modelNode?.label === 'string' && modelNode.label.trim()
|
|
148
|
+
? modelNode.label
|
|
149
|
+
: lines.join(' ');
|
|
150
|
+
const singleLineText = rawSingleLine.replace(/\s+/gu, ' ').trim();
|
|
151
|
+
const singleLineWidth = drawPresentation.renderedTextWidth(singleLineText, element.fontSize, element.fontFamily);
|
|
152
|
+
const lineWidths = lines.map(line => drawPresentation.renderedTextWidth(line, element.fontSize, element.fontFamily));
|
|
153
|
+
const firstLineWidth = Math.max(1, lineWidths[0] ?? 0);
|
|
154
|
+
const lastLine = lines.at(-1) ?? '';
|
|
155
|
+
const lastLineWords = lastLine ? lastLine.split(/\s+/u) : [];
|
|
156
|
+
const lastLineWidth = lineWidths.at(-1) ?? 0;
|
|
157
|
+
|
|
158
|
+
const shape = shapesById.get(mapping.semanticId);
|
|
159
|
+
const cardWidth = Number.isFinite(shape?.width) ? shape.width : null;
|
|
160
|
+
let recoveredSlotWidth = 0;
|
|
161
|
+
const needsSlotRecovery = (element.textAlign === 'center' && drawPresentation.isTitleFirstProfile(profile))
|
|
162
|
+
|| (Boolean(profile) && !isDiagramPresentationProfile(profile));
|
|
163
|
+
if (needsSlotRecovery && cardWidth !== null && templateCard && Number.isFinite(templateCard.padding)) {
|
|
164
|
+
const cut = Math.min(24, cardWidth * 0.12);
|
|
165
|
+
const outline = outlinesById.get(mapping.semanticId);
|
|
166
|
+
const hasFold = foldsById.has(mapping.semanticId);
|
|
167
|
+
const isHexagon = Boolean(outline && Number.isFinite(shape?.x) && outline.x > shape.x + 0.5);
|
|
168
|
+
const iconSpace = glyphIds.has(mapping.semanticId) && Number.isFinite(templateCard.glyphSize)
|
|
169
|
+
? templateCard.glyphSize + (templateCard.glyphGap ?? 0)
|
|
170
|
+
: 0;
|
|
171
|
+
recoveredSlotWidth = Math.max(0, cardWidth - 2 * (templateCard.padding + (isHexagon ? cut : 0)) - (hasFold ? cut : 0) - iconSpace);
|
|
172
|
+
}
|
|
173
|
+
const allocatedWidth = Math.max(
|
|
174
|
+
Number.isFinite(element.width) && element.width > 0 ? element.width : 0,
|
|
175
|
+
recoveredSlotWidth,
|
|
176
|
+
firstLineWidth,
|
|
177
|
+
);
|
|
178
|
+
const extraWidthPx = Math.max(1, Math.ceil(singleLineWidth - allocatedWidth));
|
|
179
|
+
|
|
180
|
+
const isStandardRect = shape?.type === 'rectangle'
|
|
181
|
+
&& shape.strokeColor !== 'transparent'
|
|
182
|
+
&& !compositeIds.has(mapping.semanticId);
|
|
183
|
+
const hasWiderOption = Boolean(widerOption && isStandardRect && cardWidth !== null && widerOption.width > cardWidth + 1);
|
|
184
|
+
const widerSizeFits = hasWiderOption && extraWidthPx <= widerOption.width - cardWidth;
|
|
185
|
+
|
|
186
|
+
const referenceWidth = Math.max(allocatedWidth, firstLineWidth);
|
|
187
|
+
const slotRatio = lastLineWidth / referenceWidth;
|
|
188
|
+
const singleWordOrphan = lastLineWords.length === 1
|
|
189
|
+
&& lastLineWidth / firstLineWidth < TITLE_SINGLE_WORD_BALANCE_RATIO;
|
|
190
|
+
|
|
191
|
+
const reasons = [];
|
|
192
|
+
if (lines.length >= 3) reasons.push('many-lines');
|
|
193
|
+
if (lines.length === 2 && widerSizeFits) reasons.push('wider-size-fits');
|
|
194
|
+
if (lines.length === 2 && (singleWordOrphan || slotRatio < TITLE_ORPHAN_LINE_RATIO)) {
|
|
195
|
+
reasons.push('orphan-wrap');
|
|
196
|
+
}
|
|
197
|
+
if (!reasons.length) continue;
|
|
198
|
+
|
|
199
|
+
findings.push({
|
|
200
|
+
id: mapping.semanticId,
|
|
201
|
+
lines: lines.length,
|
|
202
|
+
reasons,
|
|
203
|
+
cardWidth: cardWidth === null ? null : Math.round(cardWidth),
|
|
204
|
+
extraWidthPx,
|
|
205
|
+
...(hasWiderOption ? { suggestedSize: widerOption.size } : {}),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return findings;
|
|
209
|
+
}
|
|
210
|
+
|
|
91
211
|
/** Fixed reader-facing checks over the official restored scene and browser measurements. */
|
|
92
212
|
export function evaluateDiagramChecks({ model, scene, browserMeasurement, layoutDiagnostics = [], officialBrowser, mainPath, multiScreen = false }) {
|
|
93
213
|
const checks = mainPathChecks(model, scene, mainPath);
|
|
@@ -120,6 +240,23 @@ export function evaluateDiagramChecks({ model, scene, browserMeasurement, layout
|
|
|
120
240
|
const overflows = browserMeasurement?.overflows ?? [];
|
|
121
241
|
checks.push(check('CARD_TEXT_OVERFLOW', 'error', overflows.length === 0, overflows.map(row => row.id), overflows.length, 0));
|
|
122
242
|
|
|
243
|
+
const titleWraps = inspectTitleWraps(model, scene);
|
|
244
|
+
checks.push({
|
|
245
|
+
...check(
|
|
246
|
+
'TITLE_WRAP_WARNING',
|
|
247
|
+
'warning',
|
|
248
|
+
titleWraps.length === 0,
|
|
249
|
+
titleWraps.map(row => row.id),
|
|
250
|
+
{
|
|
251
|
+
count: titleWraps.length,
|
|
252
|
+
maxLines: titleWraps.length ? Math.max(...titleWraps.map(row => row.lines)) : 1,
|
|
253
|
+
maxExtraWidthPx: titleWraps.length ? Math.max(...titleWraps.map(row => row.extraWidthPx)) : 0,
|
|
254
|
+
},
|
|
255
|
+
{ maxCount: 0 },
|
|
256
|
+
),
|
|
257
|
+
...(titleWraps.length ? { details: titleWraps } : {}),
|
|
258
|
+
});
|
|
259
|
+
|
|
123
260
|
if (isDiagramPresentationProfile(model.presentationProfile)) {
|
|
124
261
|
const missingDetails = [
|
|
125
262
|
...model.nodes.filter(node => node.technical?.external !== true && node.body === (node.technical?.responsibility ?? '')).map(node => node.id),
|
|
@@ -164,6 +301,11 @@ export function evaluateDiagramChecks({ model, scene, browserMeasurement, layout
|
|
|
164
301
|
checks.push(check('EDGE_ROUTE_DETOUR', 'warning', detours.length === 0, detours.flatMap(item => item.ids ?? []),
|
|
165
302
|
{ count: detours.length, maxRatio: detours.length ? Math.max(...detours.map(item => item.value)) : 0 },
|
|
166
303
|
{ maxRatio: ROUTE_DETOUR_WARN_RATIO }));
|
|
304
|
+
const adjacentDetours = areaDiagnostics.filter(item => item.code === 'ADJACENT_EDGE_DETOUR');
|
|
305
|
+
checks.push(check('ADJACENT_EDGE_DETOUR', 'warning', adjacentDetours.length === 0,
|
|
306
|
+
adjacentDetours.flatMap(item => item.ids ?? []),
|
|
307
|
+
{ count: adjacentDetours.length, maxRatio: adjacentDetours.length ? Math.max(...adjacentDetours.map(item => item.value)) : 0 },
|
|
308
|
+
{ maxRatio: adjacentDetours[0]?.limit ?? ADJACENT_DETOUR_WARN_RATIO }));
|
|
167
309
|
const pageCollisions = inspectPageLayout(model, scene.elements);
|
|
168
310
|
checks.push(check('PAGE_GRAPH_COLLISION', 'error', pageCollisions.length === 0,
|
|
169
311
|
pageCollisions.flatMap(item => item.ids ?? []), pageCollisions.length, 0));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DrawSourceError,
|
|
3
|
+
copyJson,
|
|
3
4
|
toDrawing,
|
|
4
5
|
parseDiagramSourceText as parseSourceText,
|
|
5
6
|
validateDiagramSource as validateSource,
|
|
@@ -8,6 +9,9 @@ import {
|
|
|
8
9
|
import { parseAndValidate } from '../contract/index.js';
|
|
9
10
|
import { parseAndValidateChain } from '../chain/index.js';
|
|
10
11
|
import { DIAGRAM_CARD_PRESENTATION } from '../contract/diagramPresentation.js';
|
|
12
|
+
import { deepFreeze } from '../contract/safety.js';
|
|
13
|
+
import { validateReadingTable } from '../contract/readingTable.js';
|
|
14
|
+
|
|
11
15
|
import { MapAuthoringError } from './mapAuthoring.js';
|
|
12
16
|
|
|
13
17
|
export { REGISTERED_SOURCE_PRESENTATION_PROFILES };
|
|
@@ -23,10 +27,27 @@ export function withMapSourceErrors(operation) {
|
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
export function parseDiagramSourceText(text) {
|
|
31
|
+
try {
|
|
32
|
+
return withMapSourceErrors(() => parseSourceText(text));
|
|
33
|
+
} catch (error) {
|
|
34
|
+
// Draw reports unknown root fields only after its JSON limits and duplicate-key check.
|
|
35
|
+
if (!error.diagnostics?.some(item => item.code === 'UNKNOWN_FIELD' && item.path === '/readingTable')) throw error;
|
|
36
|
+
return validateDiagramSource(JSON.parse(text));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function validateDiagramSource(input) {
|
|
41
|
+
if (!input || !Object.hasOwn(input, 'readingTable')) return withMapSourceErrors(() => validateSource(input));
|
|
42
|
+
const diagnostics = [];
|
|
43
|
+
const copy = copyJson(input, (code, path, message) => diagnostics.push({ code, path, message }));
|
|
44
|
+
if (diagnostics.length) throw new MapAuthoringError(diagnostics);
|
|
45
|
+
const { readingTable, ...drawingSource } = copy;
|
|
46
|
+
const source = withMapSourceErrors(() => validateSource(drawingSource));
|
|
47
|
+
const table = validateReadingTable(readingTable, source.nodes.map(node => node.id));
|
|
48
|
+
if (!table.valid) throw new MapAuthoringError(table.diagnostics);
|
|
49
|
+
return deepFreeze({ ...source, readingTable });
|
|
50
|
+
}
|
|
30
51
|
|
|
31
52
|
export function compileDiagramSource(
|
|
32
53
|
source,
|
|
@@ -35,6 +56,10 @@ export function compileDiagramSource(
|
|
|
35
56
|
REGISTERED_SOURCE_PRESENTATION_PROFILES[profile],
|
|
36
57
|
} = {},
|
|
37
58
|
) {
|
|
59
|
+
let readingTable;
|
|
60
|
+
if (Object.hasOwn(source, 'readingTable')) {
|
|
61
|
+
({ readingTable, ...source } = validateDiagramSource(source));
|
|
62
|
+
}
|
|
38
63
|
const presentationProfile = profileResolver(source.profile);
|
|
39
64
|
if (typeof presentationProfile !== 'string')
|
|
40
65
|
throw new MapAuthoringError([
|
|
@@ -44,7 +69,7 @@ export function compileDiagramSource(
|
|
|
44
69
|
message: `Profile ${source.profile} is admitted but unavailable in this compiler installation.`,
|
|
45
70
|
},
|
|
46
71
|
]);
|
|
47
|
-
const drawing = toDrawing(source);
|
|
72
|
+
const drawing = withMapSourceErrors(() => toDrawing(source));
|
|
48
73
|
const authoredNodes = new Map(source.nodes.map((node) => [node.id, node]));
|
|
49
74
|
const nodes = drawing.nodes.map((node) => {
|
|
50
75
|
const authored = authoredNodes.get(node.id);
|
|
@@ -106,6 +131,7 @@ export function compileDiagramSource(
|
|
|
106
131
|
maxNodes: nodes.length,
|
|
107
132
|
nodeIds: nodes.map((node) => node.id),
|
|
108
133
|
edgeIds: edges.map((edge) => edge.id),
|
|
134
|
+
...(readingTable && { readingTable }),
|
|
109
135
|
...(source.readingTree && { readingTree: source.readingTree }),
|
|
110
136
|
...(Object.keys(layout).length > 1
|
|
111
137
|
? {
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { printPlantumlSource as printSource } from '@locus-forge/locus-draw/source';
|
|
2
|
-
import { withMapSourceErrors } from './diagramSource.js';
|
|
2
|
+
import { validateDiagramSource, withMapSourceErrors } from './diagramSource.js';
|
|
3
|
+
import { MapAuthoringError } from './mapAuthoring.js';
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export function printPlantumlSource(input) {
|
|
6
|
+
if (input && typeof input === 'object' && Object.hasOwn(input, 'readingTable')) {
|
|
7
|
+
validateDiagramSource(input);
|
|
8
|
+
throw new MapAuthoringError([{
|
|
9
|
+
code: 'TEXT_NOT_REPRESENTABLE',
|
|
10
|
+
path: '/readingTable',
|
|
11
|
+
message: 'Keep a source with readingTable in JSON to preserve its structured table declaration.',
|
|
12
|
+
}]);
|
|
13
|
+
}
|
|
14
|
+
return withMapSourceErrors(() => printSource(input));
|
|
15
|
+
}
|
|
@@ -3,8 +3,11 @@ import { parse } from 'parse5';
|
|
|
3
3
|
import { parseReadingMarkdown, readingTokenLimit } from '../contract/readingMarkdown.js';
|
|
4
4
|
import { duplicateJsonKeys } from '@locus-forge/locus-draw/source';
|
|
5
5
|
import { isPortablePath } from '../contract/index.js';
|
|
6
|
-
import { readingLimits, reportTags } from '../contract/readingMaterials.js';
|
|
6
|
+
import { readingLimits, reportTags, validateReadingMaterials } from '../contract/readingMaterials.js';
|
|
7
7
|
import { inspectImage } from '../bundle/assets.js';
|
|
8
|
+
import { compileCanvasSourceFile } from './canvasSource.mjs';
|
|
9
|
+
import { createChainBundle, loadChainBundle } from '../bundle/chain.js';
|
|
10
|
+
import { loadSketch, sketchSettings } from '../bundle/sketch.js';
|
|
8
11
|
import { BUNDLE_LIMITS } from '../bundle/safety.js';
|
|
9
12
|
import { localRoot, readLocalBytes } from '../freshness/local.js';
|
|
10
13
|
import { MapAuthoringError } from './mapAuthoring.js';
|
|
@@ -91,7 +94,7 @@ async function importReport(html, name, image) {
|
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
/** Local build input only. Bundle readers receive documents and validated asset bytes, never a filesystem resolver. */
|
|
94
|
-
export async function readDetailsFiles(indexPath, model) {
|
|
97
|
+
export async function readDetailsFiles(indexPath, model, { buildCanvas, deferCanvasBuilds = false } = {}) {
|
|
95
98
|
const indexFile = resolve(indexPath), root = await localRoot(dirname(indexFile));
|
|
96
99
|
let remaining = 32 * 1024 * 1024;
|
|
97
100
|
async function read(name, limit) {
|
|
@@ -168,30 +171,68 @@ export async function readDetailsFiles(indexPath, model) {
|
|
|
168
171
|
originals.set(path, id);
|
|
169
172
|
return id;
|
|
170
173
|
}
|
|
174
|
+
const canvases = new Map();
|
|
175
|
+
const pending = [];
|
|
176
|
+
const canvasExtensions = [
|
|
177
|
+
['.locus-map.json', 'locus-map'], ['.map.json', 'map-json'], ['.excalidraw', 'excalidraw'],
|
|
178
|
+
['.puml', 'puml'], ['.mjs', 'mjs'],
|
|
179
|
+
];
|
|
180
|
+
async function addCanvas(id, name, extension, sourceFormat) {
|
|
181
|
+
const n = canvases.size + pending.length + 1;
|
|
182
|
+
if (n > readingLimits.canvases) fail(name, 'Too many canvas attachments.');
|
|
183
|
+
const canvasId = 'canvas-' + n;
|
|
184
|
+
const bytes = await read(name, BUNDLE_LIMITS.bundleBytes);
|
|
185
|
+
const format = sourceFormat === 'excalidraw' ? 'excalidraw' : 'locus-map';
|
|
186
|
+
let title;
|
|
187
|
+
if (sourceFormat === 'locus-map') {
|
|
188
|
+
const loaded = await loadChainBundle(bytes, { nested: true });
|
|
189
|
+
title = loaded.model.title;
|
|
190
|
+
canvases.set(canvasId, { format, bundle: loaded.bundle });
|
|
191
|
+
} else if (sourceFormat === 'excalidraw') {
|
|
192
|
+
const drawing = loadSketch(decodeText(bytes, name));
|
|
193
|
+
drawing.appState = sketchSettings(drawing.appState);
|
|
194
|
+
title = basename(name).slice(0, -extension.length).trim() || 'Drawing';
|
|
195
|
+
canvases.set(canvasId, { format, drawing });
|
|
196
|
+
} else {
|
|
197
|
+
const compiled = await compileCanvasSourceFile({ filePath: resolve(root, name), bytes, sourceFormat });
|
|
198
|
+
title = compiled.title;
|
|
199
|
+
pending.push({ name, canvasId, sourceFormat, source: compiled.source, model: compiled.model, chain: compiled.chain });
|
|
200
|
+
}
|
|
201
|
+
files[id] = { kind: 'canvas', name, canvasId, format, title, sourceFormat };
|
|
202
|
+
}
|
|
171
203
|
async function addFile(request) {
|
|
172
204
|
const name = relativeMaterialPath('.', request);
|
|
173
205
|
if (name.length > 256) fail(name, 'Reading file path exceeds 256 characters.');
|
|
174
206
|
if (documents.has(name)) return documents.get(name);
|
|
175
207
|
const id = nextFileId(name);
|
|
176
208
|
const ext = extname(name).toLowerCase();
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (extendedMarkdownTokens > readingTokenLimit) fail(name, 'Markdown documents exceed the reading structure limit.');
|
|
184
|
-
const images = Object.create(null);
|
|
185
|
-
for (const node of parsed.images) {
|
|
186
|
-
images[node.destination] = await image(name, node.destination, node.alt);
|
|
209
|
+
const canvas = canvasExtensions.find(([suffix]) => name.toLowerCase().endsWith(suffix));
|
|
210
|
+
if (canvas) {
|
|
211
|
+
try { await addCanvas(id, name, ...canvas); }
|
|
212
|
+
catch (error) {
|
|
213
|
+
if (error instanceof MapAuthoringError) throw error;
|
|
214
|
+
fail(name, error.message);
|
|
187
215
|
}
|
|
188
|
-
textSize += source.length;
|
|
189
|
-
files[id] = { kind: 'markdown', name, text: source, images };
|
|
190
216
|
} else {
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
217
|
+
if (!['.md', '.html', '.htm'].includes(ext)) fail(name, 'Unsupported reading file extension.');
|
|
218
|
+
const source = decodeText(await read(name, ext === '.md' ? readingLimits.text * 4 : 4 * 1024 * 1024), name);
|
|
219
|
+
if (ext === '.md') {
|
|
220
|
+
const parsed = parseReadingMarkdown(source);
|
|
221
|
+
if (!parsed || !source.trim()) fail(name, 'Invalid or oversized Markdown document.');
|
|
222
|
+
if (source.length > 16_384) extendedMarkdownTokens += parsed.count;
|
|
223
|
+
if (extendedMarkdownTokens > readingTokenLimit) fail(name, 'Markdown documents exceed the reading structure limit.');
|
|
224
|
+
const images = Object.create(null);
|
|
225
|
+
for (const node of parsed.images) {
|
|
226
|
+
images[node.destination] = await image(name, node.destination, node.alt);
|
|
227
|
+
}
|
|
228
|
+
textSize += source.length;
|
|
229
|
+
files[id] = { kind: 'markdown', name, text: source, images };
|
|
230
|
+
} else {
|
|
231
|
+
const content = await importReport(source, name, image);
|
|
232
|
+
const count = n => { ++reportNodes; if (typeof n === 'string') textSize += n.length; else n.children?.forEach(count); };
|
|
233
|
+
content.forEach(count);
|
|
234
|
+
files[id] = { kind: 'report', name, content };
|
|
235
|
+
}
|
|
195
236
|
}
|
|
196
237
|
if (reportNodes > readingLimits.nodes || textSize > readingLimits.text) fail(name, 'Reading collection exceeds the content limit.');
|
|
197
238
|
if (Object.hasOwn(sourcePaths, name)) files[id].sourcePath = sourcePaths[name];
|
|
@@ -211,5 +252,45 @@ export async function readDetailsFiles(indexPath, model) {
|
|
|
211
252
|
for (const name of Object.keys(sourcePaths)) {
|
|
212
253
|
if (!documents.has(name)) fail(name, 'Source path refers to an unassigned material.');
|
|
213
254
|
}
|
|
214
|
-
|
|
255
|
+
const reading = { items, files };
|
|
256
|
+
validateReadingMaterials(reading, { ...model, assets: { ...model.assets, ...metadata } },
|
|
257
|
+
(_code, path, message) => fail(path, message));
|
|
258
|
+
async function buildAll(builder) {
|
|
259
|
+
if (pending.length && typeof builder !== 'function') fail(indexFile, 'Canvas sources require a canvas builder.');
|
|
260
|
+
for (const entry of pending) {
|
|
261
|
+
try {
|
|
262
|
+
const result = await builder(entry);
|
|
263
|
+
const bundle = result.bundle ?? await createChainBundle(result, { nested: true });
|
|
264
|
+
const loaded = await loadChainBundle(typeof bundle === 'string' ? bundle : JSON.stringify(bundle), { nested: true });
|
|
265
|
+
canvases.set(entry.canvasId, { format: 'locus-map', bundle: loaded.bundle });
|
|
266
|
+
} catch (error) {
|
|
267
|
+
const prefix = `/canvases/${entry.name}`;
|
|
268
|
+
if (error instanceof MapAuthoringError && error.diagnostics.length
|
|
269
|
+
&& error.diagnostics.every(item => typeof item.path === 'string' && (item.path === prefix || item.path.startsWith(`${prefix}/`)))) {
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
const diagnostics = error instanceof MapAuthoringError && error.diagnostics.length
|
|
273
|
+
? error.diagnostics.map(item => {
|
|
274
|
+
const path = String(item.path ?? '/');
|
|
275
|
+
const suffix = path !== '/' ? (path.startsWith('/') ? path : `/${path}`) : '';
|
|
276
|
+
const message = String(item.message ?? '');
|
|
277
|
+
return {
|
|
278
|
+
...item,
|
|
279
|
+
path: path === prefix || path.startsWith(`${prefix}/`) ? path : `${prefix}${suffix}`,
|
|
280
|
+
message: message.startsWith(`[${entry.name}`) ? message : `[${entry.name}] ${message}`,
|
|
281
|
+
};
|
|
282
|
+
})
|
|
283
|
+
: [{
|
|
284
|
+
code: String(error?.code ?? 'INVALID_DETAILS_FILE'),
|
|
285
|
+
path: prefix,
|
|
286
|
+
message: `[${entry.name}] ${error?.message ?? 'Child canvas build failed.'}`,
|
|
287
|
+
}];
|
|
288
|
+
throw new MapAuthoringError(diagnostics);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
let building;
|
|
293
|
+
const buildPendingCanvases = builder => building ??= buildAll(builder);
|
|
294
|
+
if (!deferCanvasBuilds) await buildPendingCanvases(buildCanvas);
|
|
295
|
+
return { reading, metadata, assets, canvases, pendingCanvases: pending, buildPendingCanvases };
|
|
215
296
|
}
|