vantage-md 0.5.8 → 0.5.9
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/dist/index.cjs +185 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +185 -20
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +250 -45
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts.map +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +251 -46
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.cts","names":[],"sources":["../src/MarkdownViewer.tsx","../src/useLineAnchor.ts","../src/MermaidDiagram.tsx","../src/FrontmatterDisplay.tsx","../src/vantageDirectives.ts","../src/vantageFrontmatter.ts","../src/DocumentStatusChip.tsx","../src/renderMarkdown.ts","../../../node_modules/@types/unist/index.d.ts","../../../node_modules/@types/hast/index.d.ts","../src/rehypeSourceLines.ts","../src/pipeline.ts","../src/scrollToLineAnchor.ts","../src/lineAnchor.ts","../src/frontmatter.ts","../src/sanitize.ts","../src/renderMermaidBlocks.ts","../src/resolveLinks.ts"],"x_google_ignoreList":[8,9],"mappings":";;;;UAkBiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,cAAc;;cAuMH,gBAAc,MAAA,qBAAA;;;;;;;;;;;;;;iBCtNX,cACd,cAAc,UAAU,qBACxB;;;;;
|
|
1
|
+
{"version":3,"file":"react.d.cts","names":[],"sources":["../src/MarkdownViewer.tsx","../src/useLineAnchor.ts","../src/MermaidDiagram.tsx","../src/FrontmatterDisplay.tsx","../src/vantageDirectives.ts","../src/vantageFrontmatter.ts","../src/DocumentStatusChip.tsx","../src/renderMarkdown.ts","../../../node_modules/@types/unist/index.d.ts","../../../node_modules/@types/hast/index.d.ts","../src/rehypeSourceLines.ts","../src/pipeline.ts","../src/scrollToLineAnchor.ts","../src/lineAnchor.ts","../src/frontmatter.ts","../src/sanitize.ts","../src/renderMermaidBlocks.ts","../src/resolveLinks.ts"],"x_google_ignoreList":[8,9],"mappings":";;;;UAkBiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,cAAc;;cAuMH,gBAAc,MAAA,qBAAA;;;;;;;;;;;;;;iBCtNX,cACd,cAAc,UAAU,qBACxB;;;;;UC+RQ;EACR;;cAqPW,gBAAc,MAAA,qBAAA;;;UC/gBjB;EACR,aAAa;;cAuIF,oBAAkB,MAAA,qBAAA;;;;;;;;;;cC9GlB;;;;;;;;;;;;;;cCjBA;KAOD,oBAAoB;;cAGnB;;;;;;;;;;cAWA,kBAAkB,SAC7B,OAAO,mBAAmB;;;;;;;;KAehB;EACN;EAAqB;;EACrB;EAAqB;;EACrB;EAAmB;EAAa;EAAgB;;EAChD;EAA4B;;EAC5B;EAA+B,MAAM;EAAW;;UAErC;;EAEf,aAAa;;EAEb,QAAQ;;;iBAWM,YAAY,iBAAiB,SAAS;;;;;;;iBAsBtC,uBACd,aAAa,0BACZ;;;cCjFU,oBAAkB,MAAA;EAZmB,QAAA;;;;;;;;UCXjC;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;;EAEf;;EAEA,aAAa;;EAEb;;;;;;;;;;;;;;;;;;iBAmBoB,eACpB,iBACA,UAAS,gBACR,QAAQ;;;;;;;;;;;;;;;;;;;;;;;UCnCM;;;;UAKA;;;;EAIb;;;;EAKA;;;;EAIA;;;;;;;UAQa;;;;EAIb,OAAO;;;;EAKP,KAAK;;;;;;;;;;;;UA6BQ;;;;EAIb;;;;EAKA,OAAO;;;;;;;EAQP,WAAW;;;;;;;;;;;;;;;;;;;;;;;UChFE,aAAa;;;;UAKb;EACb;EACA,QAAQ;EACR;EACA,SAAS;EACT,gBAAgB;EAChB,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA,kBAAkB;EAClB;EACA;EACA,iBAAiB;EACjB;EACA;EACA,aAAa;EACb;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;EACA;EACA;EACA;EACA;EACA,sBAAsB;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,KAAK;EACL,KAAK;EACL,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX,UAAU;EACV;EACA,WAAW;EACX;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBAAoB;EACpB;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,qBAAqB;EACrB,mBAAmB;EACnB,gBAAgB;EAChB,kBAAkB;EAClB;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBAAkB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;GACC,sEAAsE;;;;;;;;;KAW/D,iBAAiB,wBAAwB;;;;;;UAOpC;EACb,SAAS;EACT,SAAS;EACT,MAAM;;;;;;;;KASE,cAAc,qBAAqB;;;;;;;;;UAU9B;EACb,SAAS;EACT,SAAS;EACT,SAAS;EACT,MAAM;;;;;;;;;;;;;;;;UAsDO,aAAa;;;;EAI1B,OAAO;;;;;;;;;UAUM,gBAAgB;;;;EAI7B;;;;;;;;;UAUa,eAAe;;;;EAI5B,UAAU;;;;;;UAQG,gBAAgB;;;;EAI7B;;;;EAIA,OAAO;;;;;UAMM,oBAAoB;;;;UAKpB,gBAAgB;;;;EAI7B;;;;EAIA,OAAO;;;;;UAMM,oBAAoB;;;;UAKpB,gBAAgB;;;;EAI7B;;;;EAIA;;;;EAIA,YAAY;;;;EAIZ,UAAU;;;;;EAKV,UAAU;;;;EAIV,OAAO;;;;;UAMM,oBAAoB;;;;;;;;UASpB,aAAa;;;;EAI1B;;;;EAIA,UAAU;;;;EAIV,OAAO;;;;;UAMM,iBAAiB;;;;UAKjB,aAAa;;;;EAI1B;;;;EAIA,OAAO;;;;;UAMM,iBAAiB;;;UCl3BjB;;;;;;;EAOf;;cAkBI,mBAAmB,QAAQ,4BAA4B;;;UCf5C;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;EAOA;;UAGe;EACf,eAAe;EACf,eAAe;;;;;;;;iBASD,mBACd,UAAS,kBACR;;;;;;;;;;;;;iBA+Ea,cAAc,UAAS,kBAAuB;;;;;;;;;;;;iBCrJ9C,0BAA0B,WAAW;;;;;;;;iBAarC,mBACd,WAAW,aACX;;;;;;;;;;;;;;;;iBCfc,gBACd;EACG;EAAe;;;;;;;;KCRR;;;;;;;;;;;;;;;;UAiBK;EACf;;EAEA;EACA;EACA;EACA;;UAGe;EACf,aAAa;EACb;EACA,QAAQ;;;;;;;;;;EAUR;;;;;;EAMA,UAAU;;;;;;iBAOI,iBAAiB,kBAAkB;;;KC3C9C,gBAAgB;;;;;;;;;;;;;cAsLR,gBAAgB;;;;;;;;;;;;UC1LZ;;EAEf;;EAEA,WAAW,cAAc,OAAO;;;;;;;;;;;;;;;;;;;iBAoBZ,oBACpB,WAAW,aACX,UAAS,uBACR;;;;;;;;;;UChCc;;EAEf;;;;;;EAMA,YAAY,cAAc;;EAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2Bc,aACd,cACA,UAAS"}
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","names":[],"sources":["../src/MarkdownViewer.tsx","../src/useLineAnchor.ts","../src/MermaidDiagram.tsx","../src/FrontmatterDisplay.tsx","../src/vantageDirectives.ts","../src/vantageFrontmatter.ts","../src/DocumentStatusChip.tsx","../src/renderMarkdown.ts","../../../node_modules/@types/unist/index.d.ts","../../../node_modules/@types/hast/index.d.ts","../src/rehypeSourceLines.ts","../src/pipeline.ts","../src/scrollToLineAnchor.ts","../src/lineAnchor.ts","../src/frontmatter.ts","../src/sanitize.ts","../src/renderMermaidBlocks.ts","../src/resolveLinks.ts"],"x_google_ignoreList":[8,9],"mappings":";;;;UAkBiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,cAAc;;cAuMH,gBAAc,MAAA,qBAAA;;;;;;;;;;;;;;iBCtNX,cACd,cAAc,UAAU,qBACxB;;;;;
|
|
1
|
+
{"version":3,"file":"react.d.ts","names":[],"sources":["../src/MarkdownViewer.tsx","../src/useLineAnchor.ts","../src/MermaidDiagram.tsx","../src/FrontmatterDisplay.tsx","../src/vantageDirectives.ts","../src/vantageFrontmatter.ts","../src/DocumentStatusChip.tsx","../src/renderMarkdown.ts","../../../node_modules/@types/unist/index.d.ts","../../../node_modules/@types/hast/index.d.ts","../src/rehypeSourceLines.ts","../src/pipeline.ts","../src/scrollToLineAnchor.ts","../src/lineAnchor.ts","../src/frontmatter.ts","../src/sanitize.ts","../src/renderMermaidBlocks.ts","../src/resolveLinks.ts"],"x_google_ignoreList":[8,9],"mappings":";;;;UAkBiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,cAAc;;cAuMH,gBAAc,MAAA,qBAAA;;;;;;;;;;;;;;iBCtNX,cACd,cAAc,UAAU,qBACxB;;;;;UC+RQ;EACR;;cAqPW,gBAAc,MAAA,qBAAA;;;UC/gBjB;EACR,aAAa;;cAuIF,oBAAkB,MAAA,qBAAA;;;;;;;;;;cC9GlB;;;;;;;;;;;;;;cCjBA;KAOD,oBAAoB;;cAGnB;;;;;;;;;;cAWA,kBAAkB,SAC7B,OAAO,mBAAmB;;;;;;;;KAehB;EACN;EAAqB;;EACrB;EAAqB;;EACrB;EAAmB;EAAa;EAAgB;;EAChD;EAA4B;;EAC5B;EAA+B,MAAM;EAAW;;UAErC;;EAEf,aAAa;;EAEb,QAAQ;;;iBAWM,YAAY,iBAAiB,SAAS;;;;;;;iBAsBtC,uBACd,aAAa,0BACZ;;;cCjFU,oBAAkB,MAAA;EAZmB,QAAA;;;;;;;;UCXjC;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;;EAEf;;EAEA,aAAa;;EAEb;;;;;;;;;;;;;;;;;;iBAmBoB,eACpB,iBACA,UAAS,gBACR,QAAQ;;;;;;;;;;;;;;;;;;;;;;;UCnCM;;;;UAKA;;;;EAIb;;;;EAKA;;;;EAIA;;;;;;;UAQa;;;;EAIb,OAAO;;;;EAKP,KAAK;;;;;;;;;;;;UA6BQ;;;;EAIb;;;;EAKA,OAAO;;;;;;;EAQP,WAAW;;;;;;;;;;;;;;;;;;;;;;;UChFE,aAAa;;;;UAKb;EACb;EACA,QAAQ;EACR;EACA,SAAS;EACT,gBAAgB;EAChB,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA,kBAAkB;EAClB;EACA;EACA,iBAAiB;EACjB;EACA;EACA,aAAa;EACb;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;EACA;EACA;EACA;EACA;EACA,sBAAsB;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,KAAK;EACL,KAAK;EACL,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV,YAAY;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX,UAAU;EACV;EACA,WAAW;EACX;EACA;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBAAoB;EACpB;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,qBAAqB;EACrB,mBAAmB;EACnB,gBAAgB;EAChB,kBAAkB;EAClB;EACA;EACA;EACA;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBAAkB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;GACC,sEAAsE;;;;;;;;;KAW/D,iBAAiB,wBAAwB;;;;;;UAOpC;EACb,SAAS;EACT,SAAS;EACT,MAAM;;;;;;;;KASE,cAAc,qBAAqB;;;;;;;;;UAU9B;EACb,SAAS;EACT,SAAS;EACT,SAAS;EACT,MAAM;;;;;;;;;;;;;;;;UAsDO,aAAa;;;;EAI1B,OAAO;;;;;;;;;UAUM,gBAAgB;;;;EAI7B;;;;;;;;;UAUa,eAAe;;;;EAI5B,UAAU;;;;;;UAQG,gBAAgB;;;;EAI7B;;;;EAIA,OAAO;;;;;UAMM,oBAAoB;;;;UAKpB,gBAAgB;;;;EAI7B;;;;EAIA,OAAO;;;;;UAMM,oBAAoB;;;;UAKpB,gBAAgB;;;;EAI7B;;;;EAIA;;;;EAIA,YAAY;;;;EAIZ,UAAU;;;;;EAKV,UAAU;;;;EAIV,OAAO;;;;;UAMM,oBAAoB;;;;;;;;UASpB,aAAa;;;;EAI1B;;;;EAIA,UAAU;;;;EAIV,OAAO;;;;;UAMM,iBAAiB;;;;UAKjB,aAAa;;;;EAI1B;;;;EAIA,OAAO;;;;;UAMM,iBAAiB;;;UCl3BjB;;;;;;;EAOf;;cAkBI,mBAAmB,QAAQ,4BAA4B;;;UCf5C;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;EAOA;;UAGe;EACf,eAAe;EACf,eAAe;;;;;;;;iBASD,mBACd,UAAS,kBACR;;;;;;;;;;;;;iBA+Ea,cAAc,UAAS,kBAAuB;;;;;;;;;;;;iBCrJ9C,0BAA0B,WAAW;;;;;;;;iBAarC,mBACd,WAAW,aACX;;;;;;;;;;;;;;;;iBCfc,gBACd;EACG;EAAe;;;;;;;;KCRR;;;;;;;;;;;;;;;;UAiBK;EACf;;EAEA;EACA;EACA;EACA;;UAGe;EACf,aAAa;EACb;EACA,QAAQ;;;;;;;;;;EAUR;;;;;;EAMA,UAAU;;;;;;iBAOI,iBAAiB,kBAAkB;;;KC3C9C,gBAAgB;;;;;;;;;;;;;cAsLR,gBAAgB;;;;;;;;;;;;UC1LZ;;EAEf;;EAEA,WAAW,cAAc,OAAO;;;;;;;;;;;;;;;;;;;iBAoBZ,oBACpB,WAAW,aACX,UAAS,uBACR;;;;;;;;;;UChCc;;EAEf;;;;;;EAMA,YAAY,cAAc;;EAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2Bc,aACd,cACA,UAAS"}
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
1
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
2
2
|
import ReactMarkdown from "react-markdown";
|
|
3
3
|
import remarkGfm from "remark-gfm";
|
|
4
4
|
import remarkMath from "remark-math";
|
|
@@ -15,6 +15,21 @@ import { unified } from "unified";
|
|
|
15
15
|
import remarkParse from "remark-parse";
|
|
16
16
|
import remarkRehype from "remark-rehype";
|
|
17
17
|
import rehypeStringify from "rehype-stringify";
|
|
18
|
+
//#region src/rehypeVantageAnchors.ts
|
|
19
|
+
/** What `rehypeVantageDirectives` stamps, in hast property form. */
|
|
20
|
+
const OQ_ID_PROPERTY$1 = "dataVantageOqId";
|
|
21
|
+
function rehypeVantageAnchors() {
|
|
22
|
+
return (tree) => {
|
|
23
|
+
visit(tree, "element", (node) => {
|
|
24
|
+
const carried = node.properties?.[OQ_ID_PROPERTY$1];
|
|
25
|
+
if (typeof carried !== "string" || carried === "") return;
|
|
26
|
+
delete node.properties[OQ_ID_PROPERTY$1];
|
|
27
|
+
if (typeof node.properties.id === "string" && node.properties.id !== "") return;
|
|
28
|
+
node.properties.id = carried;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
18
33
|
//#region src/rehypeSourceLines.ts
|
|
19
34
|
/**
|
|
20
35
|
* Tags that get a `data-source-line`.
|
|
@@ -241,12 +256,17 @@ const VANTAGE_RUNS = [
|
|
|
241
256
|
"only"
|
|
242
257
|
];
|
|
243
258
|
/**
|
|
244
|
-
* The tags a `section`/`block` directive may
|
|
259
|
+
* The tags a `section`/`block` directive may **target**.
|
|
245
260
|
*
|
|
246
|
-
* Deliberately `rehypeSourceLines`'s `BLOCK_TAGS`: a
|
|
247
|
-
* be a block with a `data-source-line`, so the styling surface and the
|
|
248
|
-
* surface coincide. It also keeps an inline directive from stamping the
|
|
249
|
-
* that happens to follow it inside a paragraph.
|
|
261
|
+
* Deliberately `rehypeSourceLines`'s `BLOCK_TAGS`: a directive's target should
|
|
262
|
+
* also be a block with a `data-source-line`, so the styling surface and the
|
|
263
|
+
* anchor surface coincide. It also keeps an inline directive from stamping the
|
|
264
|
+
* `<em>` that happens to follow it inside a paragraph.
|
|
265
|
+
*
|
|
266
|
+
* It does **not** bound a `section`'s range. Every element in the span is
|
|
267
|
+
* stamped, on the tag list or not, because a member only has to be a box in the
|
|
268
|
+
* flow for the section's vertical rule to cross it — see `styleRange` in
|
|
269
|
+
* `rehypeVantageDirectives.ts` for the hole that restricting the range left.
|
|
250
270
|
*
|
|
251
271
|
* It lives here rather than in the plugin because the CLI checker has to answer
|
|
252
272
|
* "will this directive stamp anything?" from an mdast tree with no hast in
|
|
@@ -296,6 +316,23 @@ const VANTAGE_ANCHOR_TARGETS = [
|
|
|
296
316
|
"table"
|
|
297
317
|
];
|
|
298
318
|
VANTAGE_ANCHOR_TARGETS.filter((tag) => tag !== "pre" && tag !== "table");
|
|
319
|
+
/**
|
|
320
|
+
* The shape of an `oq` directive's `id`: `OQ-` then an optional short uppercase
|
|
321
|
+
* prefix then digits. `OQ-9`, `OQ-TP6` and `OQ-A03` are ids; `OQ-foo`, `OQ-tp6`
|
|
322
|
+
* and a bare `OQ6` are not.
|
|
323
|
+
*
|
|
324
|
+
* The prefix is what keeps ids distinct once one document references another's
|
|
325
|
+
* questions — `trust-paths.md`'s `OQ-4` and a design sketch's `OQ-4` are
|
|
326
|
+
* different questions, and a bare number cannot say which one a cross-document
|
|
327
|
+
* reference means. It is optional because most documents never leave their own
|
|
328
|
+
* file, and requiring it everywhere would fire on every single-doc sketch.
|
|
329
|
+
*
|
|
330
|
+
* Three consumers read it from here and none of them may re-spell it: the
|
|
331
|
+
* plugin that stamps the anchor, the sanitiser that allowlists the value, and
|
|
332
|
+
* the checker's `vantage/oq-id-format`. A fourth copy is how the checker starts
|
|
333
|
+
* calling a working anchor malformed.
|
|
334
|
+
*/
|
|
335
|
+
const VANTAGE_OQ_ID = /^OQ-(?:[A-Z][A-Z0-9]{0,5})?[0-9]+$/;
|
|
299
336
|
const STYLE_KEYS = {
|
|
300
337
|
tone: VANTAGE_TONES,
|
|
301
338
|
emphasis: VANTAGE_EMPHASIS,
|
|
@@ -428,11 +465,13 @@ function parseVantageDirective(comment) {
|
|
|
428
465
|
//#endregion
|
|
429
466
|
//#region src/rehypeVantageDirectives.ts
|
|
430
467
|
/**
|
|
431
|
-
* What a `section`/`block` and an `oq` directive may
|
|
468
|
+
* What a `section`/`block` and an `oq` directive may **target**.
|
|
432
469
|
*
|
|
433
470
|
* Both lists live in `vantageDirectives.ts`, with the reasoning for each tag,
|
|
434
471
|
* because the CLI checker resolves the same question over mdast and must reach
|
|
435
472
|
* the same answer (D5).
|
|
473
|
+
*
|
|
474
|
+
* Neither list bounds a `section`'s range: see `styleRange`.
|
|
436
475
|
*/
|
|
437
476
|
const STYLE_TARGET_TAGS = new Set(VANTAGE_STYLE_TARGETS);
|
|
438
477
|
const ANCHOR_TARGET_TAGS = new Set(VANTAGE_ANCHOR_TARGETS);
|
|
@@ -479,6 +518,18 @@ const RUN_PROPERTY = "dataVantageRun";
|
|
|
479
518
|
const OQ_PROPERTY = "dataVantageOq";
|
|
480
519
|
const LEANING_PROPERTY = "dataVantageLeaning";
|
|
481
520
|
/**
|
|
521
|
+
* The id, carried as a `data-` attribute rather than written straight to `id`.
|
|
522
|
+
*
|
|
523
|
+
* This plugin runs *before* `rehypeSanitize` — it has to, it reads comments and
|
|
524
|
+
* the sanitiser deletes them — and the sanitiser's default schema clobbers `id`
|
|
525
|
+
* with the prefix `user-content-`. A bare `id` set here would reach the page as
|
|
526
|
+
* `user-content-OQ-4`, every `#OQ-4` link in every document would land nowhere,
|
|
527
|
+
* and nothing would error. `rehypeVantageAnchors` promotes this to a real `id`
|
|
528
|
+
* on the other side of the sanitiser, which is the same reason `rehypeSlug` is
|
|
529
|
+
* registered there (`pipeline.ts`).
|
|
530
|
+
*/
|
|
531
|
+
const OQ_ID_PROPERTY = "dataVantageOqId";
|
|
532
|
+
/**
|
|
482
533
|
* The three properties `collapsed=true` stamps across a section.
|
|
483
534
|
*
|
|
484
535
|
* The heading takes a *different* attribute from the blocks it hides, and that
|
|
@@ -551,6 +602,22 @@ function accepts(name, key, value) {
|
|
|
551
602
|
* `section` before anything else degrades to that one block, and `block` is
|
|
552
603
|
* always that one block. A heading nested inside a stamped `blockquote` or
|
|
553
604
|
* `li` does not end the section: the walk never descends.
|
|
605
|
+
*
|
|
606
|
+
* **Every element in the span, not only a `VANTAGE_STYLE_TARGETS` one.** That
|
|
607
|
+
* list gates the *target* and nothing else. Restricting the range to it as well
|
|
608
|
+
* used to leave a raw-HTML `<figure>`, `<dl>` or `<details>` unstamped between
|
|
609
|
+
* two stamped paragraphs — and the section's one continuous vertical rule is
|
|
610
|
+
* drawn per member, so an unstamped member is a hole the height of the block
|
|
611
|
+
* plus its margins. Measured over the real stylesheet: 44px for a one-line
|
|
612
|
+
* `<figure>`, against the 40px a neighbour can bleed upward, and arbitrarily
|
|
613
|
+
* large for anything taller. `collapsed=true` had the same shape of bug the
|
|
614
|
+
* other way round — it hid the paragraphs and left the figure on the page.
|
|
615
|
+
*
|
|
616
|
+
* The two lists answering different questions is the point, not an oversight:
|
|
617
|
+
* a *target* must be a block a review anchor can name, because a directive
|
|
618
|
+
* pointing at something unanchorable is a directive with no addressable effect.
|
|
619
|
+
* A *member* only has to be a box in the flow, because all it does is carry the
|
|
620
|
+
* run's tone across itself.
|
|
554
621
|
*/
|
|
555
622
|
function styleRange(children, targetIndex, name) {
|
|
556
623
|
const range = [targetIndex];
|
|
@@ -560,7 +627,7 @@ function styleRange(children, targetIndex, name) {
|
|
|
560
627
|
const node = children[i];
|
|
561
628
|
const nodeDepth = headingDepth(node);
|
|
562
629
|
if (nodeDepth !== void 0 && nodeDepth <= depth) break;
|
|
563
|
-
if (node.type === "element"
|
|
630
|
+
if (node.type === "element") range.push(i);
|
|
564
631
|
}
|
|
565
632
|
return range;
|
|
566
633
|
}
|
|
@@ -619,6 +686,8 @@ function stampStyle(children, targetIndex, name, pairs, state) {
|
|
|
619
686
|
}
|
|
620
687
|
function stampOq(target, pairs) {
|
|
621
688
|
setProperty(target, OQ_PROPERTY, "true");
|
|
689
|
+
const id = pairs.get("id");
|
|
690
|
+
if (id !== void 0 && id !== "") setProperty(target, OQ_ID_PROPERTY, id);
|
|
622
691
|
const leaning = pairs.get("leaning");
|
|
623
692
|
if (leaning === void 0) return;
|
|
624
693
|
const text = leaning.replace(/\s+/g, " ").trim().slice(0, MAX_LEANING);
|
|
@@ -924,6 +993,7 @@ const sanitizeSchema = {
|
|
|
924
993
|
["dataVantageCollapseToggle", COLLAPSE_GROUP_ID],
|
|
925
994
|
["dataVantageRun", ...VANTAGE_RUNS],
|
|
926
995
|
["dataVantageOq", "true"],
|
|
996
|
+
["dataVantageOqId", VANTAGE_OQ_ID],
|
|
927
997
|
["dataVantageAlert", ...VANTAGE_ALERTS],
|
|
928
998
|
"dataVantageLeaning"
|
|
929
999
|
],
|
|
@@ -973,6 +1043,7 @@ function buildRehypePlugins(options = {}) {
|
|
|
973
1043
|
plugins.push(rehypeVantageAlerts);
|
|
974
1044
|
plugins.push(rehypeVantageDirectives);
|
|
975
1045
|
if (sanitize) plugins.push([rehypeSanitize, sanitizeSchema]);
|
|
1046
|
+
plugins.push(rehypeVantageAnchors);
|
|
976
1047
|
plugins.push(rehypeSlug);
|
|
977
1048
|
if (highlight) plugins.push(rehypeHighlight);
|
|
978
1049
|
if (math) plugins.push(rehypeCaptureMathStamps, rehypeKatex, rehypeRestoreMathStamps);
|
|
@@ -1095,27 +1166,92 @@ function errorPosition(error) {
|
|
|
1095
1166
|
return { message };
|
|
1096
1167
|
}
|
|
1097
1168
|
//#endregion
|
|
1169
|
+
//#region src/mermaidTheme.ts
|
|
1170
|
+
/** Whether the document is asking for the dark palette right now. */
|
|
1171
|
+
function currentMermaidTheme() {
|
|
1172
|
+
return typeof document !== "undefined" && document.documentElement.classList.contains("dark") ? "dark" : "default";
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Theme variables per theme. Mermaid derives most of its palette from these, so
|
|
1176
|
+
* the set is deliberately small: the surfaces, the ink, and the lines.
|
|
1177
|
+
*/
|
|
1178
|
+
const THEME_VARIABLES = {
|
|
1179
|
+
dark: {
|
|
1180
|
+
background: "#1d293d",
|
|
1181
|
+
mainBkg: "#314158",
|
|
1182
|
+
nodeBorder: "#90a1b9",
|
|
1183
|
+
nodeTextColor: "#f1f5f9",
|
|
1184
|
+
lineColor: "#90a1b9",
|
|
1185
|
+
textColor: "#e2e8f0",
|
|
1186
|
+
edgeLabelBackground: "#1d293d"
|
|
1187
|
+
},
|
|
1188
|
+
default: {
|
|
1189
|
+
background: "#f8fafc",
|
|
1190
|
+
mainBkg: "#f1f5f9",
|
|
1191
|
+
nodeBorder: "#62748e",
|
|
1192
|
+
nodeTextColor: "#0f172b",
|
|
1193
|
+
lineColor: "#62748e",
|
|
1194
|
+
textColor: "#1d293d",
|
|
1195
|
+
edgeLabelBackground: "#f8fafc"
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
function mermaidThemeVariables(theme) {
|
|
1199
|
+
return THEME_VARIABLES[theme];
|
|
1200
|
+
}
|
|
1201
|
+
//#endregion
|
|
1098
1202
|
//#region src/mermaidCache.ts
|
|
1099
1203
|
const svgCache = /* @__PURE__ */ new Map();
|
|
1204
|
+
const cacheKey = (code, theme) => `${theme}${code}`;
|
|
1205
|
+
/** The SVG for this fence in the theme the page is currently asking for. */
|
|
1206
|
+
function getCachedSvg(code, theme = currentMermaidTheme()) {
|
|
1207
|
+
return svgCache.get(cacheKey(code, theme));
|
|
1208
|
+
}
|
|
1209
|
+
function setCachedSvg(code, svg, theme = currentMermaidTheme()) {
|
|
1210
|
+
svgCache.set(cacheKey(code, theme), svg);
|
|
1211
|
+
}
|
|
1100
1212
|
//#endregion
|
|
1101
1213
|
//#region src/mermaidLoader.ts
|
|
1102
1214
|
let mermaidInstance = null;
|
|
1103
1215
|
let mermaidLoading = null;
|
|
1104
|
-
|
|
1216
|
+
/** The theme the loaded instance was last configured for, `null` until loaded. */
|
|
1217
|
+
let configuredTheme = null;
|
|
1218
|
+
function configure(m, theme) {
|
|
1219
|
+
m.initialize({
|
|
1220
|
+
startOnLoad: false,
|
|
1221
|
+
theme,
|
|
1222
|
+
themeVariables: mermaidThemeVariables(theme),
|
|
1223
|
+
securityLevel: "strict",
|
|
1224
|
+
suppressErrorRendering: true
|
|
1225
|
+
});
|
|
1226
|
+
configuredTheme = theme;
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* The mermaid module, configured for the theme the page is asking for *now*.
|
|
1230
|
+
*
|
|
1231
|
+
* Re-configuring on a theme change is the point. `initialize` used to run once,
|
|
1232
|
+
* on first import, so every diagram rendered after a light/dark switch still
|
|
1233
|
+
* came out in the palette the session started in — a white slab of a flowchart
|
|
1234
|
+
* on the dark page, or a black one on the light page. `initialize` merges into
|
|
1235
|
+
* mermaid's global config, so calling it again is how the next `render` picks
|
|
1236
|
+
* the new palette up; the cache is keyed by theme so the old SVGs are not
|
|
1237
|
+
* served instead (`mermaidCache.ts`).
|
|
1238
|
+
*/
|
|
1105
1239
|
async function getMermaid() {
|
|
1106
|
-
|
|
1240
|
+
const theme = currentMermaidTheme();
|
|
1241
|
+
if (mermaidInstance) {
|
|
1242
|
+
if (configuredTheme !== theme) configure(mermaidInstance, theme);
|
|
1243
|
+
return mermaidInstance;
|
|
1244
|
+
}
|
|
1107
1245
|
if (!mermaidLoading) mermaidLoading = import("mermaid").then((mod) => {
|
|
1108
1246
|
const m = mod.default;
|
|
1109
|
-
m
|
|
1110
|
-
startOnLoad: false,
|
|
1111
|
-
theme: isDark() ? "dark" : "default",
|
|
1112
|
-
securityLevel: "strict",
|
|
1113
|
-
suppressErrorRendering: true
|
|
1114
|
-
});
|
|
1247
|
+
configure(m, currentMermaidTheme());
|
|
1115
1248
|
mermaidInstance = m;
|
|
1116
1249
|
return m;
|
|
1117
1250
|
});
|
|
1118
|
-
|
|
1251
|
+
const loaded = await mermaidLoading;
|
|
1252
|
+
const wanted = currentMermaidTheme();
|
|
1253
|
+
if (configuredTheme !== wanted) configure(loaded, wanted);
|
|
1254
|
+
return loaded;
|
|
1119
1255
|
}
|
|
1120
1256
|
//#endregion
|
|
1121
1257
|
//#region src/MermaidDiagram.tsx
|
|
@@ -1168,7 +1304,7 @@ const MaximizeIcon = () => /* @__PURE__ */ jsxs("svg", {
|
|
|
1168
1304
|
strokeWidth: "2",
|
|
1169
1305
|
strokeLinecap: "round",
|
|
1170
1306
|
strokeLinejoin: "round",
|
|
1171
|
-
className: "w-4 h-4 text-gray-600",
|
|
1307
|
+
className: "w-4 h-4 text-gray-600 dark:text-slate-200",
|
|
1172
1308
|
children: [
|
|
1173
1309
|
/* @__PURE__ */ jsx("polyline", { points: "15 3 21 3 21 9" }),
|
|
1174
1310
|
/* @__PURE__ */ jsx("polyline", { points: "9 21 3 21 3 15" }),
|
|
@@ -1329,32 +1465,32 @@ function ZoomableSvg({ svg }) {
|
|
|
1329
1465
|
dangerouslySetInnerHTML: { __html: svg }
|
|
1330
1466
|
})
|
|
1331
1467
|
}), /* @__PURE__ */ jsxs("div", {
|
|
1332
|
-
className: "absolute bottom-4 right-4 flex items-center gap-1 rounded-lg bg-white/95 shadow-md border border-gray-200 px-1.5 py-1",
|
|
1468
|
+
className: "absolute bottom-4 right-4 flex items-center gap-1 rounded-lg bg-white/95 dark:bg-slate-800/95 shadow-md border border-gray-200 dark:border-slate-600 px-1.5 py-1",
|
|
1333
1469
|
children: [
|
|
1334
1470
|
/* @__PURE__ */ jsx("button", {
|
|
1335
1471
|
onClick: () => zoomBy(1 / 1.3),
|
|
1336
|
-
className: "p-1.5 rounded hover:bg-gray-100 text-gray-600",
|
|
1472
|
+
className: "p-1.5 rounded hover:bg-gray-100 dark:hover:bg-slate-700 text-gray-600 dark:text-slate-200",
|
|
1337
1473
|
"aria-label": "Zoom out",
|
|
1338
1474
|
title: "Zoom out",
|
|
1339
1475
|
children: /* @__PURE__ */ jsx(MinusIcon, {})
|
|
1340
1476
|
}),
|
|
1341
1477
|
/* @__PURE__ */ jsxs("button", {
|
|
1342
1478
|
onClick: reset,
|
|
1343
|
-
className: "px-2 py-1 text-xs font-medium rounded hover:bg-gray-100 text-gray-600 min-w-[3rem]",
|
|
1479
|
+
className: "px-2 py-1 text-xs font-medium rounded hover:bg-gray-100 dark:hover:bg-slate-700 text-gray-600 dark:text-slate-200 min-w-[3rem]",
|
|
1344
1480
|
title: "Reset zoom (or double-click)",
|
|
1345
1481
|
children: [Math.round(scale * 100), "%"]
|
|
1346
1482
|
}),
|
|
1347
1483
|
/* @__PURE__ */ jsx("button", {
|
|
1348
1484
|
onClick: () => zoomBy(1.3),
|
|
1349
|
-
className: "p-1.5 rounded hover:bg-gray-100 text-gray-600",
|
|
1485
|
+
className: "p-1.5 rounded hover:bg-gray-100 dark:hover:bg-slate-700 text-gray-600 dark:text-slate-200",
|
|
1350
1486
|
"aria-label": "Zoom in",
|
|
1351
1487
|
title: "Zoom in",
|
|
1352
1488
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
1353
1489
|
}),
|
|
1354
|
-
/* @__PURE__ */ jsx("div", { className: "w-px h-5 bg-gray-200 mx-0.5" }),
|
|
1490
|
+
/* @__PURE__ */ jsx("div", { className: "w-px h-5 bg-gray-200 dark:bg-slate-600 mx-0.5" }),
|
|
1355
1491
|
/* @__PURE__ */ jsx("button", {
|
|
1356
1492
|
onClick: reset,
|
|
1357
|
-
className: "p-1.5 rounded hover:bg-gray-100 text-gray-600",
|
|
1493
|
+
className: "p-1.5 rounded hover:bg-gray-100 dark:hover:bg-slate-700 text-gray-600 dark:text-slate-200",
|
|
1358
1494
|
"aria-label": "Reset view",
|
|
1359
1495
|
title: "Reset view",
|
|
1360
1496
|
children: /* @__PURE__ */ jsx(ResetIcon, {})
|
|
@@ -1392,38 +1528,74 @@ function DiagramModal({ isOpen, onClose, children }) {
|
|
|
1392
1528
|
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",
|
|
1393
1529
|
onClick: onClose,
|
|
1394
1530
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1395
|
-
className: "bg-white rounded-lg shadow-xl w-[96vw] h-[94vh] flex flex-col overflow-hidden",
|
|
1531
|
+
className: "bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100 rounded-lg shadow-xl w-[96vw] h-[94vh] flex flex-col overflow-hidden",
|
|
1396
1532
|
role: "dialog",
|
|
1397
1533
|
"aria-modal": "true",
|
|
1398
1534
|
onClick: (e) => e.stopPropagation(),
|
|
1399
1535
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1400
|
-
className: "flex items-center justify-between p-4 border-b shrink-0",
|
|
1536
|
+
className: "flex items-center justify-between p-4 border-b border-gray-200 dark:border-slate-700 shrink-0",
|
|
1401
1537
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
1402
1538
|
className: "text-lg font-semibold",
|
|
1403
1539
|
children: "Mermaid Diagram"
|
|
1404
1540
|
}), /* @__PURE__ */ jsx("button", {
|
|
1405
1541
|
onClick: onClose,
|
|
1406
|
-
className: "p-1 hover:bg-gray-100 rounded-full transition-colors",
|
|
1542
|
+
className: "p-1 hover:bg-gray-100 dark:hover:bg-slate-700 rounded-full transition-colors",
|
|
1407
1543
|
"aria-label": "Close modal",
|
|
1408
1544
|
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
1409
1545
|
})]
|
|
1410
1546
|
}), /* @__PURE__ */ jsx("div", {
|
|
1411
|
-
className: "flex-1 overflow-hidden bg-gray-50",
|
|
1547
|
+
className: "flex-1 overflow-hidden bg-gray-50 dark:bg-slate-800",
|
|
1412
1548
|
children
|
|
1413
1549
|
})]
|
|
1414
1550
|
})
|
|
1415
1551
|
});
|
|
1416
1552
|
}
|
|
1553
|
+
/**
|
|
1554
|
+
* The palette the page is asking for, re-read whenever `<html>`'s class list
|
|
1555
|
+
* changes.
|
|
1556
|
+
*
|
|
1557
|
+
* A diagram is an SVG baked at render time, so unlike everything else on the
|
|
1558
|
+
* page it does not restyle when the theme flips — it has to be drawn again. The
|
|
1559
|
+
* observer is what notices; the effect below is what redraws. Without it a
|
|
1560
|
+
* session that started in light mode kept white boxes with black ink on the
|
|
1561
|
+
* dark page for as long as it lived.
|
|
1562
|
+
*
|
|
1563
|
+
* `useSyncExternalStore` rather than state plus an effect: the class list *is*
|
|
1564
|
+
* an external store, and reading it in an effect would both miss a flip that
|
|
1565
|
+
* landed before the effect ran and set state synchronously inside one.
|
|
1566
|
+
*/
|
|
1567
|
+
function subscribeToTheme(onChange) {
|
|
1568
|
+
if (typeof MutationObserver === "undefined") return () => {};
|
|
1569
|
+
const observer = new MutationObserver(onChange);
|
|
1570
|
+
observer.observe(document.documentElement, {
|
|
1571
|
+
attributes: true,
|
|
1572
|
+
attributeFilter: ["class"]
|
|
1573
|
+
});
|
|
1574
|
+
return () => observer.disconnect();
|
|
1575
|
+
}
|
|
1576
|
+
/** Server render has no `<html>` to read, and no diagram to draw either. */
|
|
1577
|
+
const serverTheme = () => "default";
|
|
1578
|
+
function useMermaidTheme() {
|
|
1579
|
+
return useSyncExternalStore(subscribeToTheme, currentMermaidTheme, serverTheme);
|
|
1580
|
+
}
|
|
1417
1581
|
const MermaidDiagramInner = ({ code }) => {
|
|
1418
|
-
const
|
|
1419
|
-
const [svg, setSvg] = useState(() => svgCache.get(code) || "");
|
|
1420
|
-
const [errorMessage, setErrorMessage] = useState(null);
|
|
1582
|
+
const theme = useMermaidTheme();
|
|
1421
1583
|
const [showSource, setShowSource] = useState(false);
|
|
1422
1584
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
1423
|
-
const [isLoading, setIsLoading] = useState(!hasCached);
|
|
1424
1585
|
const [minHeight, setMinHeight] = useState("auto");
|
|
1425
1586
|
const containerRef = useRef(null);
|
|
1426
1587
|
const lastHeightRef = useRef(null);
|
|
1588
|
+
/**
|
|
1589
|
+
* What this render produced, and which (code, theme) it was for.
|
|
1590
|
+
*
|
|
1591
|
+
* Keyed rather than plain, and read past the cache rather than instead of it,
|
|
1592
|
+
* because a theme flip has to invalidate both: the cache is a miss in the new
|
|
1593
|
+
* palette, and last render's SVG is the wrong palette. Deriving `svg` here
|
|
1594
|
+
* rather than mirroring the cache into state is also what keeps a cache hit
|
|
1595
|
+
* from being a `setState` inside an effect.
|
|
1596
|
+
*/
|
|
1597
|
+
const [rendered, setRendered] = useState(null);
|
|
1598
|
+
const [failure, setFailure] = useState(null);
|
|
1427
1599
|
const stableId = useMemo(() => {
|
|
1428
1600
|
let hash = 0;
|
|
1429
1601
|
for (let i = 0; i < code.length; i++) {
|
|
@@ -1433,9 +1605,14 @@ const MermaidDiagramInner = ({ code }) => {
|
|
|
1433
1605
|
}
|
|
1434
1606
|
return `mermaid-${Math.abs(hash).toString(36)}`;
|
|
1435
1607
|
}, [code]);
|
|
1608
|
+
const attempt = `${theme} ${stableId}`;
|
|
1609
|
+
const svg = getCachedSvg(code, theme) ?? (rendered?.key === attempt ? rendered.svg : "");
|
|
1610
|
+
const errorMessage = failure?.key === attempt ? failure.message : null;
|
|
1611
|
+
const isLoading = svg === "" && errorMessage === null;
|
|
1436
1612
|
useEffect(() => {
|
|
1437
|
-
if (
|
|
1613
|
+
if (getCachedSvg(code, theme) !== void 0) return;
|
|
1438
1614
|
let mounted = true;
|
|
1615
|
+
const key = `${theme} ${stableId}`;
|
|
1439
1616
|
const renderDiagram = async () => {
|
|
1440
1617
|
try {
|
|
1441
1618
|
if (containerRef.current) {
|
|
@@ -1447,17 +1624,18 @@ const MermaidDiagramInner = ({ code }) => {
|
|
|
1447
1624
|
const id = `${stableId}-${Date.now()}`;
|
|
1448
1625
|
const { svg: renderedSvg } = await m.render(id, code);
|
|
1449
1626
|
if (mounted) {
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1627
|
+
setCachedSvg(code, renderedSvg, theme);
|
|
1628
|
+
setRendered({
|
|
1629
|
+
key,
|
|
1630
|
+
svg: renderedSvg
|
|
1631
|
+
});
|
|
1454
1632
|
}
|
|
1455
1633
|
} catch (err) {
|
|
1456
1634
|
console.error("Mermaid render error:", err);
|
|
1457
|
-
if (mounted) {
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
}
|
|
1635
|
+
if (mounted) setFailure({
|
|
1636
|
+
key,
|
|
1637
|
+
message: extractErrorMessage(err)
|
|
1638
|
+
});
|
|
1461
1639
|
}
|
|
1462
1640
|
};
|
|
1463
1641
|
renderDiagram();
|
|
@@ -1467,7 +1645,7 @@ const MermaidDiagramInner = ({ code }) => {
|
|
|
1467
1645
|
}, [
|
|
1468
1646
|
code,
|
|
1469
1647
|
stableId,
|
|
1470
|
-
|
|
1648
|
+
theme
|
|
1471
1649
|
]);
|
|
1472
1650
|
if (errorMessage) return /* @__PURE__ */ jsxs("div", {
|
|
1473
1651
|
"data-testid": "mermaid-container",
|
|
@@ -1507,7 +1685,7 @@ const MermaidDiagramInner = ({ code }) => {
|
|
|
1507
1685
|
dangerouslySetInnerHTML: { __html: svg }
|
|
1508
1686
|
}), svg && /* @__PURE__ */ jsx("button", {
|
|
1509
1687
|
onClick: () => setIsModalOpen(true),
|
|
1510
|
-
className: "absolute top-2 right-2 p-2 bg-white/90 shadow-sm border rounded-md opacity-0 group-hover:opacity-100 transition-opacity hover:bg-gray-50",
|
|
1688
|
+
className: "absolute top-2 right-2 p-2 bg-white/90 dark:bg-slate-800/90 shadow-sm border border-gray-200 dark:border-slate-600 rounded-md opacity-0 group-hover:opacity-100 transition-opacity hover:bg-gray-50 dark:hover:bg-slate-700",
|
|
1511
1689
|
"aria-label": "Maximize diagram",
|
|
1512
1690
|
children: /* @__PURE__ */ jsx(MaximizeIcon, {})
|
|
1513
1691
|
})]
|
|
@@ -2167,18 +2345,20 @@ async function renderMermaidBlocks(container, options = {}) {
|
|
|
2167
2345
|
const { className = "mermaid", onError } = options;
|
|
2168
2346
|
const codeBlocks = container.querySelectorAll("pre > code.language-mermaid, pre > code[class*=\"language-mermaid\"]");
|
|
2169
2347
|
if (codeBlocks.length === 0) return;
|
|
2170
|
-
|
|
2348
|
+
let loading;
|
|
2349
|
+
const mermaidOnce = () => loading ??= getMermaid();
|
|
2171
2350
|
const renderPromises = Array.from(codeBlocks).map(async (codeEl) => {
|
|
2172
2351
|
const preEl = codeEl.parentElement;
|
|
2173
2352
|
if (!preEl) return;
|
|
2174
2353
|
const code = codeEl.textContent || "";
|
|
2175
2354
|
if (!code.trim()) return;
|
|
2176
|
-
const cached =
|
|
2355
|
+
const cached = getCachedSvg(code);
|
|
2177
2356
|
if (cached) {
|
|
2178
2357
|
replaceWithSvg(preEl, cached, className);
|
|
2179
2358
|
return;
|
|
2180
2359
|
}
|
|
2181
2360
|
try {
|
|
2361
|
+
const mermaid = await mermaidOnce();
|
|
2182
2362
|
let hash = 0;
|
|
2183
2363
|
for (let i = 0; i < code.length; i++) {
|
|
2184
2364
|
hash = (hash << 5) - hash + code.charCodeAt(i);
|
|
@@ -2186,7 +2366,7 @@ async function renderMermaidBlocks(container, options = {}) {
|
|
|
2186
2366
|
}
|
|
2187
2367
|
const id = `mermaid-${Math.abs(hash).toString(36)}-${Date.now()}`;
|
|
2188
2368
|
const { svg } = await mermaid.render(id, code);
|
|
2189
|
-
|
|
2369
|
+
setCachedSvg(code, svg);
|
|
2190
2370
|
replaceWithSvg(preEl, svg, className);
|
|
2191
2371
|
} catch (err) {
|
|
2192
2372
|
if (onError) onError(code, err instanceof Error ? err : new Error(String(err)));
|
|
@@ -2194,9 +2374,34 @@ async function renderMermaidBlocks(container, options = {}) {
|
|
|
2194
2374
|
});
|
|
2195
2375
|
await Promise.all(renderPromises);
|
|
2196
2376
|
}
|
|
2377
|
+
/**
|
|
2378
|
+
* Attributes the wrapper inherits from the `<pre>` it replaces.
|
|
2379
|
+
*
|
|
2380
|
+
* The splice is the same shape of problem `rehypeVantageMathStamps` solves for
|
|
2381
|
+
* KaTeX: the pipeline stamped the fence, and swapping the element out throws
|
|
2382
|
+
* the stamps away. A mermaid diagram inside a toned section then drew no slice
|
|
2383
|
+
* of the section's vertical rule, leaving a hole as tall as the diagram; a
|
|
2384
|
+
* collapsed section left the diagram visible under a closed heading; and a
|
|
2385
|
+
* `#L` anchor pointing at the fence resolved to nothing.
|
|
2386
|
+
*
|
|
2387
|
+
* Named individually rather than copied wholesale: `class` is the caller's
|
|
2388
|
+
* (`className`), and `id` would be duplicated onto a second element.
|
|
2389
|
+
*/
|
|
2390
|
+
const CARRIED_ATTRIBUTES = [
|
|
2391
|
+
"data-source-line",
|
|
2392
|
+
"data-vantage-tone",
|
|
2393
|
+
"data-vantage-emphasis",
|
|
2394
|
+
"data-vantage-run",
|
|
2395
|
+
"data-vantage-collapsed",
|
|
2396
|
+
"data-vantage-collapse-group"
|
|
2397
|
+
];
|
|
2197
2398
|
function replaceWithSvg(preEl, svg, className) {
|
|
2198
2399
|
const wrapper = document.createElement("div");
|
|
2199
2400
|
wrapper.className = className;
|
|
2401
|
+
for (const name of CARRIED_ATTRIBUTES) {
|
|
2402
|
+
const value = preEl.getAttribute(name);
|
|
2403
|
+
if (value !== null) wrapper.setAttribute(name, value);
|
|
2404
|
+
}
|
|
2200
2405
|
wrapper.innerHTML = svg;
|
|
2201
2406
|
preEl.replaceWith(wrapper);
|
|
2202
2407
|
}
|