@plebeiantech/lat.md 0.12.3-fork.13 → 0.12.3-fork.15
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/README.md +24 -0
- package/dist/src/cli/check-context.d.ts +56 -0
- package/dist/src/cli/check-context.js +215 -0
- package/dist/src/cli/check-coverage.js +9 -5
- package/dist/src/cli/check-frontmatter.js +1 -1
- package/dist/src/cli/check-mode.js +1 -1
- package/dist/src/cli/check-status.js +1 -1
- package/dist/src/cli/check.d.ts +19 -12
- package/dist/src/cli/check.js +259 -206
- package/dist/src/cli/context.js +1 -1
- package/dist/src/cli/expand.d.ts +1 -2
- package/dist/src/cli/expand.js +52 -5
- package/dist/src/cli/external.d.ts +11 -0
- package/dist/src/cli/external.js +185 -0
- package/dist/src/cli/fork-instructions.d.ts +1 -0
- package/dist/src/cli/fork-instructions.js +3 -2
- package/dist/src/cli/hook.d.ts +26 -0
- package/dist/src/cli/hook.js +112 -40
- package/dist/src/cli/index.js +55 -3
- package/dist/src/cli/init.d.ts +1 -0
- package/dist/src/cli/init.js +40 -2
- package/dist/src/cli/locate.js +4 -3
- package/dist/src/cli/refs.d.ts +2 -1
- package/dist/src/cli/refs.js +88 -43
- package/dist/src/cli/reindex.js +2 -1
- package/dist/src/cli/search.d.ts +12 -3
- package/dist/src/cli/search.js +45 -49
- package/dist/src/cli/section.d.ts +3 -1
- package/dist/src/cli/section.js +114 -38
- package/dist/src/code-refs.d.ts +17 -5
- package/dist/src/code-refs.js +246 -65
- package/dist/src/context.d.ts +3 -0
- package/dist/src/document-formats.d.ts +7 -0
- package/dist/src/document-formats.js +39 -0
- package/dist/src/extensions/alert-marker.d.ts +25 -0
- package/dist/src/extensions/alert-marker.js +55 -0
- package/dist/src/external-documents.d.ts +56 -0
- package/dist/src/external-documents.js +404 -0
- package/dist/src/external-sources.d.ts +136 -0
- package/dist/src/external-sources.js +1098 -0
- package/dist/src/fork/antigravity-hook.d.ts +47 -0
- package/dist/src/fork/antigravity-hook.js +424 -0
- package/dist/src/fork/antigravity-init.d.ts +17 -0
- package/dist/src/fork/antigravity-init.js +124 -0
- package/dist/src/fork/frontmatter-fields.d.ts +36 -0
- package/dist/src/fork/frontmatter-fields.js +23 -0
- package/dist/src/format.d.ts +5 -2
- package/dist/src/format.js +8 -3
- package/dist/src/graph-export.js +1 -1
- package/dist/src/lattice-model.d.ts +77 -0
- package/dist/src/lattice-model.js +464 -0
- package/dist/src/lattice.d.ts +9 -104
- package/dist/src/lattice.js +69 -516
- package/dist/src/markdown-analysis-cache.d.ts +20 -0
- package/dist/src/markdown-analysis-cache.js +139 -0
- package/dist/src/markdown-analysis-worker.d.ts +16 -0
- package/dist/src/markdown-analysis-worker.js +33 -0
- package/dist/src/markdown-analysis.d.ts +50 -0
- package/dist/src/markdown-analysis.js +139 -0
- package/dist/src/markdown-analyzer-loader.d.ts +4 -0
- package/dist/src/markdown-analyzer-loader.js +13 -0
- package/dist/src/markdown-validation.d.ts +25 -0
- package/dist/src/markdown-validation.js +104 -0
- package/dist/src/mcp/server.js +27 -11
- package/dist/src/parser-cache.d.ts +17 -0
- package/dist/src/parser-cache.js +65 -0
- package/dist/src/parser-import.d.ts +8 -0
- package/dist/src/parser-import.js +1 -0
- package/dist/src/parser.js +80 -5
- package/dist/src/path.d.ts +2 -0
- package/dist/src/path.js +4 -0
- package/dist/src/profiler.d.ts +16 -0
- package/dist/src/profiler.js +81 -0
- package/dist/src/project-analysis.d.ts +59 -0
- package/dist/src/project-analysis.js +233 -0
- package/dist/src/project-discovery.d.ts +6 -0
- package/dist/src/project-discovery.js +30 -0
- package/dist/src/repository-path.d.ts +11 -0
- package/dist/src/repository-path.js +52 -0
- package/dist/src/search/db.d.ts +1 -1
- package/dist/src/search/db.js +2 -2
- package/dist/src/search/embedder.d.ts +2 -1
- package/dist/src/search/embedder.js +6 -5
- package/dist/src/search/index.d.ts +2 -1
- package/dist/src/search/index.js +10 -8
- package/dist/src/search/query.d.ts +20 -0
- package/dist/src/search/query.js +67 -0
- package/dist/src/search/search.d.ts +3 -1
- package/dist/src/search/search.js +5 -2
- package/dist/src/source-formats.d.ts +7 -0
- package/dist/src/source-formats.js +26 -0
- package/dist/src/source-parser.d.ts +44 -4
- package/dist/src/source-parser.js +494 -57
- package/dist/src/view/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/src/view/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/src/view/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/src/view/client/assets/MarkdownEditor-B7quqPb8.js +28 -0
- package/dist/src/view/client/assets/OrbitControls-DwcpQNja.js +1 -0
- package/dist/src/view/client/assets/STLLoader-CLWTKt5i.js +1 -0
- package/dist/src/view/client/assets/abnfDiagram-VCTEODGH-V7-T6qsl.js +1 -0
- package/dist/src/view/client/assets/arc-BnwR8Bu7.js +1 -0
- package/dist/src/view/client/assets/architectureDiagram-5GKGNRK7-u97vDna9.js +36 -0
- package/dist/src/view/client/assets/blockDiagram-I7D4REHJ-DETl8e_H.js +129 -0
- package/dist/src/view/client/assets/c4Diagram-7LVT6UL2-DJRAT1Ve.js +38 -0
- package/dist/src/view/client/assets/channel-BwQbnWCN.js +1 -0
- package/dist/src/view/client/assets/chunk-2Q5K7J3B-C0TmOC1Q.js +1 -0
- package/dist/src/view/client/assets/chunk-5VM5RSS4-dfBOrYE6.js +15 -0
- package/dist/src/view/client/assets/chunk-F27PBJKO-DAnks99K.js +1 -0
- package/dist/src/view/client/assets/chunk-IMKFNOWR-CPjB07if.js +231 -0
- package/dist/src/view/client/assets/chunk-JWPE2WC7-VvU_gZI6.js +1 -0
- package/dist/src/view/client/assets/chunk-POPQ4Y6H-DDUbVF55.js +1 -0
- package/dist/src/view/client/assets/chunk-SVP7TREG-BHROkr6D.js +88 -0
- package/dist/src/view/client/assets/chunk-TICWLB2K-95PzGIOg.js +206 -0
- package/dist/src/view/client/assets/chunk-XXDRQBXY-MdmuLhIs.js +1 -0
- package/dist/src/view/client/assets/classDiagram-ZZMXUADV-HvQKkIS-.js +1 -0
- package/dist/src/view/client/assets/classDiagram-v2-VYDZK3BY-HvQKkIS-.js +1 -0
- package/dist/src/view/client/assets/cose-bilkent-JH36ORCC-CauUf_rN.js +1 -0
- package/dist/src/view/client/assets/cynefin-OW5HDTMX-CeA8IKWo.js +166 -0
- package/dist/src/view/client/assets/cynefinDiagram-5FMLGOSQ-L1rtcT8l.js +62 -0
- package/dist/src/view/client/assets/cytoscape.esm-DzSz-X2X.js +321 -0
- package/dist/src/view/client/assets/dagre-GXQ25YYZ-DLQwTa3H.js +4 -0
- package/dist/src/view/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/src/view/client/assets/diagram-S7CK7UJ4-kbKdIyXG.js +30 -0
- package/dist/src/view/client/assets/diagram-UQ7AKVKN-kmzp92RC.js +41 -0
- package/dist/src/view/client/assets/diagram-VSXAHHWV-EXJTU8qq.js +3 -0
- package/dist/src/view/client/assets/diagram-VX7I27RA-DAiIyMCG.js +24 -0
- package/dist/src/view/client/assets/diagram-Z3DM3KII-G9wz50ZV.js +24 -0
- package/dist/src/view/client/assets/ebnfDiagram-PWID7BFC-D2tVRCNA.js +1 -0
- package/dist/src/view/client/assets/erDiagram-RLTQ6QDP-C925J5A3.js +99 -0
- package/dist/src/view/client/assets/flowDiagram-HODETNUW-DzoCa-Nq.js +168 -0
- package/dist/src/view/client/assets/ganttDiagram-EL5Y4UJY-D2ebbg4p.js +292 -0
- package/dist/src/view/client/assets/gitGraphDiagram-WWUBYQGX-B4QratYy.js +106 -0
- package/dist/src/view/client/assets/index-BnENo9bV.js +1 -0
- package/dist/src/view/client/assets/index-D0ajr_Ja.css +1 -0
- package/dist/src/view/client/assets/index-KZcnpXJH.js +321 -0
- package/dist/src/view/client/assets/infoDiagram-27XIBGKW-DL4mtHkt.js +2 -0
- package/dist/src/view/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/src/view/client/assets/ishikawaDiagram-5VMMS53U-CW4mto2d.js +70 -0
- package/dist/src/view/client/assets/journeyDiagram-3NMN7TZE-8R4eacFW.js +139 -0
- package/dist/src/view/client/assets/kanban-definition-UXKFOSKX-Cy9ioXEJ.js +89 -0
- package/dist/src/view/client/assets/katex-HP8lGamR.js +257 -0
- package/dist/src/view/client/assets/layout-C0MFuhth.js +1 -0
- package/dist/src/view/client/assets/linear-Dv3N4dQR.js +1 -0
- package/dist/src/view/client/assets/logo-small-RR_KBOAT.svg +149 -0
- package/dist/src/view/client/assets/maplibre-gl-DnqZgfUS.js +800 -0
- package/dist/src/view/client/assets/mermaid.core-bds9A7e2.js +310 -0
- package/dist/src/view/client/assets/mindmap-definition-YA3MSWOX-DjmGW355.js +96 -0
- package/dist/src/view/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/src/view/client/assets/pegDiagram-XKGWAZYB-BWsZp0ab.js +1 -0
- package/dist/src/view/client/assets/pieDiagram-E7YTZNPT-CCH2gGR-.js +39 -0
- package/dist/src/view/client/assets/quadrantDiagram-AXDQQJYC-CjocPJFz.js +7 -0
- package/dist/src/view/client/assets/railroadDiagram-O6MQD6OU-BjLeb2KF.js +1 -0
- package/dist/src/view/client/assets/requirementDiagram-BXWQKSXE-Ct6AoXRr.js +84 -0
- package/dist/src/view/client/assets/sankeyDiagram-P5KCCOFB-CIpgGN_w.js +40 -0
- package/dist/src/view/client/assets/sequenceDiagram-WJ2MYXX4-DrmLFj6w.js +162 -0
- package/dist/src/view/client/assets/sizeCapture-INFHLROL-BdFMe2Lr.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-D77RDMKH-Zd9F1goW.js +1 -0
- package/dist/src/view/client/assets/stateDiagram-v2-MP3YSRHH-ByIKCftl.js +1 -0
- package/dist/src/view/client/assets/swimlanes-42K2YHIH-a7VFwi00.js +1 -0
- package/dist/src/view/client/assets/swimlanesDiagram-VR7AAH4N-CzxaUHB-.js +8 -0
- package/dist/src/view/client/assets/three.module-PDSP0dbZ.js +4108 -0
- package/dist/src/view/client/assets/timeline-definition-24CTP7MA-BExPu6X5.js +120 -0
- package/dist/src/view/client/assets/vennDiagram-4TSXK5OY-PC1MU3si.js +34 -0
- package/dist/src/view/client/assets/wardleyDiagram-VM6X3IG4-DNWqU3fa.js +78 -0
- package/dist/src/view/client/assets/xychartDiagram-S5SC5T6Z-E1uA28_D.js +7 -0
- package/dist/src/view/client/index.html +2 -2
- package/dist/src/view/client-shell.d.ts +2 -0
- package/dist/src/view/client-shell.js +5 -0
- package/dist/src/view/diagnostics.d.ts +3 -2
- package/dist/src/view/diagnostics.js +49 -58
- package/dist/src/view/document-edit.d.ts +8 -0
- package/dist/src/view/document-edit.js +25 -0
- package/dist/src/view/document-route.d.ts +12 -0
- package/dist/src/view/document-route.js +93 -0
- package/dist/src/view/document-tree.d.ts +18 -0
- package/dist/src/view/document-tree.js +139 -0
- package/dist/src/view/external-document-tree.d.ts +3 -0
- package/dist/src/view/external-document-tree.js +674 -0
- package/dist/src/view/git-diff.js +187 -0
- package/dist/src/view/git.js +1 -1
- package/dist/src/view/graph.d.ts +3 -2
- package/dist/src/view/graph.js +94 -7
- package/dist/src/view/highlight.d.ts +10 -2
- package/dist/src/view/highlight.js +4540 -1360
- package/dist/src/view/markdown.d.ts +3 -2
- package/dist/src/view/markdown.js +214 -53
- package/dist/src/view/protocol.d.ts +59 -6
- package/dist/src/view/references.d.ts +10 -25
- package/dist/src/view/references.js +117 -107
- package/dist/src/view/repository.d.ts +13 -3
- package/dist/src/view/repository.js +234 -15
- package/dist/src/view/search.d.ts +1 -1
- package/dist/src/view/search.js +3 -7
- package/dist/src/view/server.d.ts +11 -2
- package/dist/src/view/server.js +212 -70
- package/dist/src/view/source-target.js +5 -8
- package/dist/src/view/static-build.d.ts +1 -0
- package/dist/src/view/static-build.js +245 -42
- package/dist/src/view/static-protocol.d.ts +19 -2
- package/dist/src/view/store.d.ts +16 -3
- package/dist/src/view/store.js +228 -36
- package/dist/src/view/table-of-contents.d.ts +2 -2
- package/dist/src/view/table-of-contents.js +2 -22
- package/dist/src/walk.d.ts +5 -3
- package/dist/src/walk.js +102 -8
- package/dist/vendor/lat.md-server/cli.d.ts +2 -0
- package/dist/vendor/lat.md-server/cli.js +12 -0
- package/dist/vendor/lat.md-server/index.d.ts +38 -0
- package/dist/vendor/lat.md-server/index.js +128 -0
- package/package.json +52 -12
- package/plugins/lat-md/README.md +61 -0
- package/plugins/lat-md/hooks.json +38 -0
- package/plugins/lat-md/plugin.json +9 -0
- package/plugins/lat-md/rules/AGENTS.md +118 -0
- package/plugins/lat-md/skills/lat-md/SKILL.md +178 -0
- package/plugins/lat-md/skills/lat-md-conventions/SKILL.md +182 -0
- package/templates/AGENTS.md +15 -3
- package/templates/cursor-rules.md +12 -3
- package/templates/skill/SKILL.md +22 -1
- package/dist/src/view/client/assets/index-C3iaZyYT.css +0 -1
- package/dist/src/view/client/assets/index-KWi67IMz.js +0 -334
- package/dist/src/view/client/assets/logo-CNF8zs47.svg +0 -182
|
@@ -2,10 +2,13 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { cp, lstat, mkdir, mkdtemp, readFile, rename, rm, writeFile, } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join, parse, relative, resolve, sep } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { isDocumentPath } from '../document-formats.js';
|
|
5
6
|
import { DEFAULT_VIEW_LOGO_TEXT } from './protocol.js';
|
|
7
|
+
import { documentTreeUrls, rewriteDocumentTreeUrls } from './document-tree.js';
|
|
6
8
|
import { viewStaticSourceKey, } from './static-protocol.js';
|
|
7
9
|
import { createViewStore } from './store.js';
|
|
8
|
-
|
|
10
|
+
import { rewriteClientAssetUrls } from './client-shell.js';
|
|
11
|
+
import { documentResourcePath, documentPath, documentUrl, rawDocumentPath, } from './document-route.js';
|
|
9
12
|
const defaultClientDir = fileURLToPath(new URL('./client/', import.meta.url));
|
|
10
13
|
function isInside(parent, child) {
|
|
11
14
|
const rel = relative(parent, child);
|
|
@@ -56,7 +59,16 @@ export function staticViewUrl(value, basePath) {
|
|
|
56
59
|
}
|
|
57
60
|
if (url.origin !== 'http://lat.local')
|
|
58
61
|
return value;
|
|
59
|
-
|
|
62
|
+
if (url.pathname.startsWith('/docs/')) {
|
|
63
|
+
const route = url.pathname.slice(1).replace(/\/+$/, '');
|
|
64
|
+
const suffix = `${url.search}${url.hash}`;
|
|
65
|
+
return `${basePath}${route}${suffix}`;
|
|
66
|
+
}
|
|
67
|
+
if (url.pathname.startsWith('/resources/')) {
|
|
68
|
+
const route = url.pathname.slice(1);
|
|
69
|
+
return `${basePath}${route}${url.search}${url.hash}`;
|
|
70
|
+
}
|
|
71
|
+
for (const prefix of ['/code/', '/external/']) {
|
|
60
72
|
if (!url.pathname.startsWith(prefix))
|
|
61
73
|
continue;
|
|
62
74
|
const route = url.pathname.slice(1).replace(/\/+$/, '');
|
|
@@ -68,18 +80,7 @@ export function staticViewUrl(value, basePath) {
|
|
|
68
80
|
return value;
|
|
69
81
|
}
|
|
70
82
|
function documentPathFromUrl(value) {
|
|
71
|
-
|
|
72
|
-
return null;
|
|
73
|
-
try {
|
|
74
|
-
return value.pathname
|
|
75
|
-
.slice('/docs/'.length)
|
|
76
|
-
.split('/')
|
|
77
|
-
.map(decodeURIComponent)
|
|
78
|
-
.join('/');
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
+
return documentPath(value.pathname) ?? rawDocumentPath(value.pathname);
|
|
83
84
|
}
|
|
84
85
|
function rewriteHtmlLink(value, basePath, sourcePath, documentPaths) {
|
|
85
86
|
const direct = staticViewUrl(value, basePath);
|
|
@@ -87,32 +88,37 @@ function rewriteHtmlLink(value, basePath, sourcePath, documentPaths) {
|
|
|
87
88
|
return direct;
|
|
88
89
|
let resolved;
|
|
89
90
|
try {
|
|
90
|
-
const
|
|
91
|
-
|
|
91
|
+
const externalAt = sourcePath.indexOf(':');
|
|
92
|
+
const currentRoute = externalAt > 0 && !documentPaths.has(sourcePath)
|
|
93
|
+
? `/external/${encodeURIComponent(sourcePath.slice(0, externalAt))}/${sourcePath
|
|
94
|
+
.slice(externalAt + 1)
|
|
95
|
+
.split('/')
|
|
96
|
+
.map(encodeURIComponent)
|
|
97
|
+
.join('/')}`
|
|
98
|
+
: documentUrl(sourcePath);
|
|
99
|
+
resolved = new URL(decodeHtmlUrlAttribute(value), `http://lat.local${currentRoute}`);
|
|
92
100
|
}
|
|
93
101
|
catch {
|
|
94
102
|
return value;
|
|
95
103
|
}
|
|
96
104
|
const documentPath = documentPathFromUrl(resolved);
|
|
105
|
+
if (resolved.pathname.startsWith('/external/')) {
|
|
106
|
+
return staticViewUrl(`${resolved.pathname}${resolved.search}${resolved.hash}`, basePath);
|
|
107
|
+
}
|
|
97
108
|
if (resolved.origin !== 'http://lat.local' ||
|
|
98
109
|
!documentPath ||
|
|
99
110
|
!documentPaths.has(documentPath)) {
|
|
100
111
|
return value;
|
|
101
112
|
}
|
|
102
|
-
return staticViewUrl(`${
|
|
113
|
+
return staticViewUrl(`${documentUrl(documentPath)}${resolved.search}${resolved.hash}`, basePath);
|
|
103
114
|
}
|
|
104
|
-
function
|
|
105
|
-
return
|
|
106
|
-
const rewritten = rewriteHtmlLink(value, basePath, sourcePath, documentPaths);
|
|
107
|
-
if (rewritten === value)
|
|
108
|
-
return attribute;
|
|
109
|
-
return `href="${rewritten.replaceAll('&', '&').replaceAll('"', '"')}"`;
|
|
110
|
-
});
|
|
115
|
+
function rewriteDocumentLinks(tree, basePath, sourcePath, documentPaths) {
|
|
116
|
+
return rewriteDocumentTreeUrls(tree, (value) => rewriteHtmlLink(value, basePath, sourcePath, documentPaths));
|
|
111
117
|
}
|
|
112
118
|
function rewriteMarkdownReference(reference, basePath, sourcePath, documentPaths) {
|
|
113
119
|
return {
|
|
114
120
|
...reference,
|
|
115
|
-
|
|
121
|
+
paragraphTree: rewriteDocumentLinks(reference.paragraphTree, basePath, sourcePath, documentPaths),
|
|
116
122
|
url: staticViewUrl(reference.url, basePath),
|
|
117
123
|
};
|
|
118
124
|
}
|
|
@@ -124,8 +130,8 @@ function rewriteBackReference(reference, basePath, sectionPaths, documentPaths)
|
|
|
124
130
|
function rewriteDocument(document, basePath, sectionPaths, documentPaths) {
|
|
125
131
|
return {
|
|
126
132
|
...document,
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
tree: rewriteDocumentLinks(document.tree, basePath, document.path, documentPaths),
|
|
134
|
+
gitTree: null,
|
|
129
135
|
backReferences: document.backReferences.map((section) => ({
|
|
130
136
|
...section,
|
|
131
137
|
references: section.references.map((reference) => rewriteBackReference(reference, basePath, sectionPaths, documentPaths)),
|
|
@@ -136,7 +142,7 @@ function rewriteSourceReference(reference, basePath, sectionPaths, documentPaths
|
|
|
136
142
|
const sectionPath = reference.sectionId.split('#', 1)[0];
|
|
137
143
|
return {
|
|
138
144
|
...reference,
|
|
139
|
-
|
|
145
|
+
paragraphTree: rewriteDocumentLinks(reference.paragraphTree, basePath, sectionPaths.get(sectionPath) ?? null, documentPaths),
|
|
140
146
|
url: staticViewUrl(reference.url, basePath),
|
|
141
147
|
};
|
|
142
148
|
}
|
|
@@ -187,21 +193,103 @@ function sourceRequest(value) {
|
|
|
187
193
|
at: positiveInteger(url.searchParams.get('at')),
|
|
188
194
|
};
|
|
189
195
|
}
|
|
196
|
+
function externalRequest(value, external) {
|
|
197
|
+
let url;
|
|
198
|
+
try {
|
|
199
|
+
url = new URL(decodeHtmlUrlAttribute(value), 'http://lat.local');
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
if (!url.pathname.startsWith('/external/'))
|
|
205
|
+
return null;
|
|
206
|
+
try {
|
|
207
|
+
const parts = url.pathname
|
|
208
|
+
.slice('/external/'.length)
|
|
209
|
+
.split('/')
|
|
210
|
+
.map(decodeURIComponent);
|
|
211
|
+
const handle = parts.shift() ?? '';
|
|
212
|
+
const path = parts.join('/');
|
|
213
|
+
if (!handle || !path)
|
|
214
|
+
return null;
|
|
215
|
+
const fragment = decodeURIComponent(url.hash.slice(1));
|
|
216
|
+
const target = `${handle}:${path}${fragment ? `#${fragment}` : ''}`;
|
|
217
|
+
const parsed = external?.parse(target);
|
|
218
|
+
if (parsed) {
|
|
219
|
+
if (!isDocumentPath(parsed.resolvedPath)) {
|
|
220
|
+
return parsed.identity;
|
|
221
|
+
}
|
|
222
|
+
const hash = parsed.identity.indexOf('#');
|
|
223
|
+
return hash === -1 ? parsed.identity : parsed.identity.slice(0, hash);
|
|
224
|
+
}
|
|
225
|
+
return `${handle}:${path}${isDocumentPath(path) || !fragment ? '' : `#${fragment}`}`;
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function externalRequestsFromDocument(document, requests, external, externalBase) {
|
|
232
|
+
const add = (value) => {
|
|
233
|
+
let candidate = value;
|
|
234
|
+
if (externalBase && !value.startsWith('#')) {
|
|
235
|
+
try {
|
|
236
|
+
const colon = externalBase.indexOf(':');
|
|
237
|
+
const base = `/external/${encodeURIComponent(externalBase.slice(0, colon))}/${externalBase
|
|
238
|
+
.slice(colon + 1)
|
|
239
|
+
.split('/')
|
|
240
|
+
.map(encodeURIComponent)
|
|
241
|
+
.join('/')}`;
|
|
242
|
+
const resolved = new URL(decodeHtmlUrlAttribute(value), `http://lat.local${base}`);
|
|
243
|
+
if (resolved.origin === 'http://lat.local') {
|
|
244
|
+
candidate = `${resolved.pathname}${resolved.hash}`;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// Leave malformed links to the renderer rather than exporting them.
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const request = externalRequest(candidate, external);
|
|
252
|
+
if (request)
|
|
253
|
+
requests.add(request);
|
|
254
|
+
};
|
|
255
|
+
for (const value of documentTreeUrls(document.tree))
|
|
256
|
+
add(value);
|
|
257
|
+
for (const section of document.backReferences) {
|
|
258
|
+
for (const reference of section.references) {
|
|
259
|
+
add(reference.url);
|
|
260
|
+
if (reference.kind === 'markdown') {
|
|
261
|
+
for (const value of documentTreeUrls(reference.paragraphTree))
|
|
262
|
+
add(value);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function externalRequestsFromSource(source, requests, external) {
|
|
268
|
+
for (const reference of [
|
|
269
|
+
...(source.context ? [source.context] : []),
|
|
270
|
+
...source.otherReferences,
|
|
271
|
+
]) {
|
|
272
|
+
for (const value of documentTreeUrls(reference.paragraphTree)) {
|
|
273
|
+
const request = externalRequest(value, external);
|
|
274
|
+
if (request)
|
|
275
|
+
requests.add(request);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
190
279
|
function sourceRequestsFromDocument(document, requests) {
|
|
191
280
|
const add = (value) => {
|
|
192
281
|
const request = sourceRequest(value);
|
|
193
282
|
if (request)
|
|
194
283
|
requests.set(viewStaticSourceKey(request), request);
|
|
195
284
|
};
|
|
196
|
-
for (const
|
|
197
|
-
add(
|
|
285
|
+
for (const value of documentTreeUrls(document.tree))
|
|
286
|
+
add(value);
|
|
198
287
|
for (const section of document.backReferences) {
|
|
199
288
|
for (const reference of section.references) {
|
|
200
289
|
add(reference.url);
|
|
201
290
|
if (reference.kind === 'markdown') {
|
|
202
|
-
for (const
|
|
203
|
-
add(
|
|
204
|
-
}
|
|
291
|
+
for (const value of documentTreeUrls(reference.paragraphTree))
|
|
292
|
+
add(value);
|
|
205
293
|
}
|
|
206
294
|
}
|
|
207
295
|
}
|
|
@@ -212,8 +300,8 @@ function sourceRequestsFromSource(source, requests) {
|
|
|
212
300
|
...source.otherReferences,
|
|
213
301
|
];
|
|
214
302
|
for (const reference of references) {
|
|
215
|
-
for (const
|
|
216
|
-
const request = sourceRequest(
|
|
303
|
+
for (const value of documentTreeUrls(reference.paragraphTree)) {
|
|
304
|
+
const request = sourceRequest(value);
|
|
217
305
|
if (request)
|
|
218
306
|
requests.set(viewStaticSourceKey(request), request);
|
|
219
307
|
}
|
|
@@ -256,7 +344,7 @@ function sectionDocumentPaths(documents) {
|
|
|
256
344
|
return result;
|
|
257
345
|
}
|
|
258
346
|
function clientShell(html, basePath) {
|
|
259
|
-
const assets = html
|
|
347
|
+
const assets = rewriteClientAssetUrls(html, basePath);
|
|
260
348
|
const configValue = JSON.stringify({ basePath }).replaceAll('<', '\\u003c');
|
|
261
349
|
const config = `<script>globalThis.__LAT_STATIC_VIEW__=${configValue}</script>`;
|
|
262
350
|
return assets.includes('</head>')
|
|
@@ -295,6 +383,8 @@ export async function buildStaticView(ctx, requestedOutput, options = {}) {
|
|
|
295
383
|
codeExcludePaths: [outputDir],
|
|
296
384
|
git: false,
|
|
297
385
|
watch: false,
|
|
386
|
+
externalIgnoreLocal: true,
|
|
387
|
+
externalCa: options.externalCa,
|
|
298
388
|
});
|
|
299
389
|
try {
|
|
300
390
|
const clientHtml = await readFile(join(clientDir, 'index.html'), 'utf8');
|
|
@@ -304,11 +394,31 @@ export async function buildStaticView(ctx, requestedOutput, options = {}) {
|
|
|
304
394
|
const shell = clientShell(clientHtml, basePath);
|
|
305
395
|
const index = { ...store.getIndex(), git: null, logoText };
|
|
306
396
|
const documents = new Map();
|
|
397
|
+
const documentResources = new Set();
|
|
307
398
|
const sourceRequests = new Map();
|
|
399
|
+
const externalRequests = new Set();
|
|
400
|
+
for (const file of index.externalFiles) {
|
|
401
|
+
externalRequests.add(file.target);
|
|
402
|
+
}
|
|
308
403
|
for (const path of index.files) {
|
|
309
404
|
const document = await store.getDocument(path);
|
|
310
405
|
documents.set(path, document);
|
|
406
|
+
for (const url of documentTreeUrls(document.tree)) {
|
|
407
|
+
let parsed;
|
|
408
|
+
try {
|
|
409
|
+
parsed = new URL(url, 'http://lat.local');
|
|
410
|
+
}
|
|
411
|
+
catch {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
if (parsed.origin !== 'http://lat.local')
|
|
415
|
+
continue;
|
|
416
|
+
const resourcePath = documentResourcePath(parsed.pathname);
|
|
417
|
+
if (resourcePath)
|
|
418
|
+
documentResources.add(resourcePath);
|
|
419
|
+
}
|
|
311
420
|
sourceRequestsFromDocument(document, sourceRequests);
|
|
421
|
+
externalRequestsFromDocument(document, externalRequests, store.snapshot.external);
|
|
312
422
|
}
|
|
313
423
|
const documentPaths = new Set(documents.keys());
|
|
314
424
|
const sectionPaths = sectionDocumentPaths(documents);
|
|
@@ -317,6 +427,39 @@ export async function buildStaticView(ctx, requestedOutput, options = {}) {
|
|
|
317
427
|
const request = sourceRequest(node.url);
|
|
318
428
|
if (request)
|
|
319
429
|
sourceRequests.set(viewStaticSourceKey(request), request);
|
|
430
|
+
if (node.externalTarget)
|
|
431
|
+
externalRequests.add(node.externalTarget);
|
|
432
|
+
}
|
|
433
|
+
const externals = new Map();
|
|
434
|
+
const pendingExternal = [...externalRequests];
|
|
435
|
+
for (let index = 0; index < pendingExternal.length; index++) {
|
|
436
|
+
const target = pendingExternal[index];
|
|
437
|
+
if (externals.has(target))
|
|
438
|
+
continue;
|
|
439
|
+
let external;
|
|
440
|
+
try {
|
|
441
|
+
external = await store.getExternal(target);
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
throw new Error(`Could not export external source ${target}: ${error.message}`);
|
|
445
|
+
}
|
|
446
|
+
externals.set(target, external);
|
|
447
|
+
const before = externalRequests.size;
|
|
448
|
+
if (external.kind === 'markdown') {
|
|
449
|
+
sourceRequestsFromDocument(external.document, sourceRequests);
|
|
450
|
+
externalRequestsFromDocument(external.document, externalRequests, store.snapshot.external, external.document.path);
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
sourceRequestsFromSource(external.source, sourceRequests);
|
|
454
|
+
externalRequestsFromSource(external.source, externalRequests, store.snapshot.external);
|
|
455
|
+
}
|
|
456
|
+
if (externalRequests.size > before) {
|
|
457
|
+
for (const next of externalRequests) {
|
|
458
|
+
if (!externals.has(next) && !pendingExternal.includes(next)) {
|
|
459
|
+
pendingExternal.push(next);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
320
463
|
}
|
|
321
464
|
const sources = new Map();
|
|
322
465
|
const pending = [...sourceRequests.keys()];
|
|
@@ -352,19 +495,36 @@ export async function buildStaticView(ctx, requestedOutput, options = {}) {
|
|
|
352
495
|
graph: 'data/graph.json',
|
|
353
496
|
documents: {},
|
|
354
497
|
sources: {},
|
|
498
|
+
externals: {},
|
|
355
499
|
};
|
|
356
500
|
await writeJson(join(payloadDir, manifest.graph), rewriteGraph(graph, basePath));
|
|
357
501
|
for (const [path, document] of documents) {
|
|
358
502
|
const dataPath = dataFile('documents', path);
|
|
359
503
|
manifest.documents[path] = dataPath;
|
|
360
504
|
await writeJson(join(payloadDir, dataPath), rewriteDocument(document, basePath, sectionPaths, documentPaths));
|
|
361
|
-
const
|
|
505
|
+
const source = await store.getDocumentSource(path);
|
|
506
|
+
const rawPath = join(payloadDir, 'docs', ...path.split('/'));
|
|
507
|
+
await mkdir(dirname(rawPath), { recursive: true });
|
|
508
|
+
await writeFile(rawPath, source.content);
|
|
509
|
+
const route = `docs/${path.slice(0, -'.md'.length)}`;
|
|
362
510
|
await writeRouteShell(payloadDir, route, shell);
|
|
363
511
|
}
|
|
512
|
+
for (const path of [...documentResources].sort()) {
|
|
513
|
+
let content;
|
|
514
|
+
try {
|
|
515
|
+
content = await store.getDocumentResource(path);
|
|
516
|
+
}
|
|
517
|
+
catch (error) {
|
|
518
|
+
throw new Error(`Could not export document resource ${path}: ${error.message}`);
|
|
519
|
+
}
|
|
520
|
+
const outputPath = join(payloadDir, 'resources', ...path.split('/'));
|
|
521
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
522
|
+
await writeFile(outputPath, content);
|
|
523
|
+
}
|
|
364
524
|
const sourceFiles = new Map();
|
|
365
525
|
for (const [key, source] of sources) {
|
|
366
526
|
const rewritten = rewriteSource(source, basePath, sectionPaths, documentPaths);
|
|
367
|
-
const { path, content,
|
|
527
|
+
const { path, content, highlightedLines, ...view } = rewritten;
|
|
368
528
|
let fileDataPath = sourceFiles.get(path);
|
|
369
529
|
if (!fileDataPath) {
|
|
370
530
|
fileDataPath = dataFile('source-files', path);
|
|
@@ -372,7 +532,7 @@ export async function buildStaticView(ctx, requestedOutput, options = {}) {
|
|
|
372
532
|
await writeJson(join(payloadDir, fileDataPath), {
|
|
373
533
|
path,
|
|
374
534
|
content,
|
|
375
|
-
|
|
535
|
+
highlightedLines,
|
|
376
536
|
});
|
|
377
537
|
}
|
|
378
538
|
const viewDataPath = dataFile('source-views', key);
|
|
@@ -383,19 +543,62 @@ export async function buildStaticView(ctx, requestedOutput, options = {}) {
|
|
|
383
543
|
const route = `code/${path}`;
|
|
384
544
|
await writeRouteShell(payloadDir, route, shell);
|
|
385
545
|
}
|
|
546
|
+
const externalSourceFiles = new Map();
|
|
547
|
+
const externalRoutes = new Set();
|
|
548
|
+
for (const [target, external] of externals) {
|
|
549
|
+
if (external.kind === 'markdown') {
|
|
550
|
+
const dataPath = dataFile('external-documents', target);
|
|
551
|
+
manifest.externals[target] = { kind: 'markdown', document: dataPath };
|
|
552
|
+
await writeJson(join(payloadDir, dataPath), {
|
|
553
|
+
...external,
|
|
554
|
+
document: rewriteDocument(external.document, basePath, sectionPaths, documentPaths),
|
|
555
|
+
});
|
|
556
|
+
const colon = external.document.path.indexOf(':');
|
|
557
|
+
externalRoutes.add(`external/${external.document.path.slice(0, colon)}/${external.document.path.slice(colon + 1)}`);
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
const rewritten = rewriteSource(external.source, basePath, sectionPaths, documentPaths);
|
|
561
|
+
const { path, content, highlightedLines, ...sourceView } = rewritten;
|
|
562
|
+
let fileDataPath = externalSourceFiles.get(path);
|
|
563
|
+
if (!fileDataPath) {
|
|
564
|
+
fileDataPath = dataFile('external-source-files', path);
|
|
565
|
+
externalSourceFiles.set(path, fileDataPath);
|
|
566
|
+
await writeJson(join(payloadDir, fileDataPath), {
|
|
567
|
+
path,
|
|
568
|
+
content,
|
|
569
|
+
highlightedLines,
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
const viewDataPath = dataFile('external-source-views', target);
|
|
573
|
+
manifest.externals[target] = {
|
|
574
|
+
kind: 'source',
|
|
575
|
+
file: fileDataPath,
|
|
576
|
+
view: viewDataPath,
|
|
577
|
+
};
|
|
578
|
+
const view = {
|
|
579
|
+
kind: 'source',
|
|
580
|
+
target: external.target,
|
|
581
|
+
source: sourceView,
|
|
582
|
+
};
|
|
583
|
+
await writeJson(join(payloadDir, viewDataPath), view);
|
|
584
|
+
const colon = path.indexOf(':');
|
|
585
|
+
externalRoutes.add(`external/${path.slice(0, colon)}/${path.slice(colon + 1)}`);
|
|
586
|
+
}
|
|
587
|
+
for (const route of externalRoutes) {
|
|
588
|
+
await writeRouteShell(payloadDir, route, shell);
|
|
589
|
+
}
|
|
386
590
|
await writeRouteShell(payloadDir, 'graph', shell);
|
|
387
591
|
await writeJson(join(payloadDir, 'data/manifest.json'), manifest);
|
|
388
|
-
const entryRedirect = redirectShell(staticViewUrl(
|
|
592
|
+
const entryRedirect = redirectShell(staticViewUrl(documentUrl(index.entry), basePath));
|
|
389
593
|
await writeFile(join(payloadDir, 'index.html'), entryRedirect);
|
|
390
594
|
if (payloadDir !== stagingDir) {
|
|
391
595
|
await writeFile(join(stagingDir, 'index.html'), entryRedirect);
|
|
392
596
|
}
|
|
393
|
-
await writeFile(join(stagingDir, BUILD_MARKER), `${JSON.stringify({ version: 1 })}\n`);
|
|
394
597
|
await rename(stagingDir, outputDir);
|
|
395
598
|
return {
|
|
396
599
|
documents: documents.size,
|
|
397
600
|
outputDir,
|
|
398
|
-
sources: sources.size,
|
|
601
|
+
sources: sources.size + externals.size,
|
|
399
602
|
};
|
|
400
603
|
}
|
|
401
604
|
catch (error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ViewIndex, ViewSourceDocument } from './protocol.js';
|
|
1
|
+
import type { ViewExternalDocument, ViewIndex, ViewSourceDocument } from './protocol.js';
|
|
2
2
|
export type ViewStaticSourceRequest = {
|
|
3
3
|
path: string;
|
|
4
4
|
symbol: string;
|
|
@@ -6,18 +6,35 @@ export type ViewStaticSourceRequest = {
|
|
|
6
6
|
line: number;
|
|
7
7
|
at: number;
|
|
8
8
|
};
|
|
9
|
-
export type ViewStaticSourceFile = Pick<ViewSourceDocument, 'path' | 'content' | '
|
|
9
|
+
export type ViewStaticSourceFile = Pick<ViewSourceDocument, 'path' | 'content' | 'highlightedLines'>;
|
|
10
10
|
export type ViewStaticSourceView = Omit<ViewSourceDocument, keyof ViewStaticSourceFile>;
|
|
11
11
|
export type ViewStaticSourceEntry = {
|
|
12
12
|
file: string;
|
|
13
13
|
view: string;
|
|
14
14
|
};
|
|
15
|
+
export type ViewStaticExternalEntry = {
|
|
16
|
+
kind: 'markdown';
|
|
17
|
+
document: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'source';
|
|
20
|
+
file: string;
|
|
21
|
+
view: string;
|
|
22
|
+
};
|
|
23
|
+
export type ViewStaticExternalSourceView = {
|
|
24
|
+
kind: 'source';
|
|
25
|
+
target: string;
|
|
26
|
+
source: ViewStaticSourceView;
|
|
27
|
+
};
|
|
28
|
+
export type ViewStaticExternalMarkdown = Extract<ViewExternalDocument, {
|
|
29
|
+
kind: 'markdown';
|
|
30
|
+
}>;
|
|
15
31
|
export type ViewStaticManifest = {
|
|
16
32
|
version: 1;
|
|
17
33
|
index: ViewIndex;
|
|
18
34
|
graph: string;
|
|
19
35
|
documents: Record<string, string>;
|
|
20
36
|
sources: Record<string, ViewStaticSourceEntry>;
|
|
37
|
+
externals: Record<string, ViewStaticExternalEntry>;
|
|
21
38
|
};
|
|
22
39
|
/** Stable lookup key shared by the static exporter and browser adapter. */
|
|
23
40
|
export declare function viewStaticSourceKey(request: ViewStaticSourceRequest): string;
|
package/dist/src/view/store.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ExternalResolver } from '../external-sources.js';
|
|
2
|
+
import type { Section } from '../lattice-model.js';
|
|
2
3
|
import { type ViewGitRepository, type ViewGitSnapshot } from './git.js';
|
|
3
|
-
import type { ViewDocument, ViewDocumentError, ViewGraph, ViewIndex,
|
|
4
|
+
import type { ViewDocument, ViewDocumentEditResponse, ViewDocumentError, ViewDocumentSource, ViewExternalDocument, ViewGraph, ViewIndex, ViewProjectGeneration, ViewDocumentTree, ViewSourceDocument } from './protocol.js';
|
|
4
5
|
import { type ViewCodeReferenceFile, type ViewParsedMarkdownFile, type ViewReferenceIndex } from './references.js';
|
|
5
6
|
export type ViewProjectSnapshot = {
|
|
6
7
|
generation: number;
|
|
@@ -12,6 +13,7 @@ export type ViewProjectSnapshot = {
|
|
|
12
13
|
diagnostics: ReadonlyMap<string, readonly ViewDocumentError[]>;
|
|
13
14
|
git: ViewGitSnapshot;
|
|
14
15
|
index: ViewIndex;
|
|
16
|
+
external: ExternalResolver;
|
|
15
17
|
};
|
|
16
18
|
export type ViewStoreOptions = {
|
|
17
19
|
codeExcludePaths?: string[];
|
|
@@ -19,8 +21,10 @@ export type ViewStoreOptions = {
|
|
|
19
21
|
git?: boolean;
|
|
20
22
|
gitPollMs?: number;
|
|
21
23
|
watch?: boolean;
|
|
24
|
+
externalIgnoreLocal?: boolean;
|
|
25
|
+
externalCa?: string | Buffer;
|
|
22
26
|
};
|
|
23
|
-
type ViewStoreListener = (change:
|
|
27
|
+
type ViewStoreListener = (change: ViewProjectGeneration) => void;
|
|
24
28
|
/** Own the immutable, incrementally refreshed project snapshot for `lat ui`. */
|
|
25
29
|
export declare class ViewStore {
|
|
26
30
|
readonly latDir: string;
|
|
@@ -34,24 +38,33 @@ export declare class ViewStore {
|
|
|
34
38
|
private ignoredCodePaths;
|
|
35
39
|
private listeners;
|
|
36
40
|
private watcher;
|
|
41
|
+
private externalWatchers;
|
|
37
42
|
private pendingPaths;
|
|
38
43
|
private debounceTimer;
|
|
39
44
|
private gitPollTimer;
|
|
40
45
|
private gitPollQueued;
|
|
41
46
|
private refreshTail;
|
|
47
|
+
private editTail;
|
|
42
48
|
private closed;
|
|
43
49
|
constructor(latDir: string, projectRoot: string, realLatDir: string, snapshot: ViewProjectSnapshot, codeFiles: Map<string, ViewCodeReferenceFile>, codeScope: Set<string>, gitRepository: ViewGitRepository | null, options: ViewStoreOptions);
|
|
44
50
|
get snapshot(): ViewProjectSnapshot;
|
|
45
51
|
get markdownGeneration(): number;
|
|
46
52
|
startWatching(): void;
|
|
53
|
+
private refreshExternalWatchers;
|
|
47
54
|
subscribe(listener: ViewStoreListener): () => void;
|
|
48
55
|
getIndex(): ViewIndex;
|
|
49
56
|
getGraph(): ViewGraph;
|
|
57
|
+
renderSectionOutput(markdown: string, sectionId: string): Promise<ViewDocumentTree>;
|
|
50
58
|
getDocument(requestedPath: string): Promise<ViewDocument>;
|
|
59
|
+
private editableDocumentPath;
|
|
60
|
+
getDocumentSource(requestedPath: string): Promise<ViewDocumentSource>;
|
|
61
|
+
getDocumentResource(requestedPath: string): Promise<Buffer>;
|
|
62
|
+
editDocument(requestedPath: string, baseContent: string, editedContent: string): Promise<ViewDocumentEditResponse>;
|
|
51
63
|
getSource(requestedPath: string, requestedSymbol?: string, origin?: {
|
|
52
64
|
sectionId: string;
|
|
53
65
|
line: number;
|
|
54
66
|
}, requestedLine?: number): Promise<ViewSourceDocument>;
|
|
67
|
+
getExternal(target: string): Promise<ViewExternalDocument>;
|
|
55
68
|
refresh(paths: string[]): Promise<void>;
|
|
56
69
|
private queueRefresh;
|
|
57
70
|
close(): Promise<void>;
|