vantage-md 0.5.7 → 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 +196 -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 +196 -20
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +261 -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 +262 -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,7 +15,31 @@ 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
|
|
34
|
+
/**
|
|
35
|
+
* Tags that get a `data-source-line`.
|
|
36
|
+
*
|
|
37
|
+
* `td`/`th` are here for review mode: a comment anchors to the cell it was
|
|
38
|
+
* written on, so the cell needs a line of its own to be found again. Every cell
|
|
39
|
+
* in a row reports the *row's* start line — a GFM row is one source line — so a
|
|
40
|
+
* line no longer names at most one anchorable element, and whatever resolves an
|
|
41
|
+
* anchor has to break the tie by block hash (`useReviewHighlights`).
|
|
42
|
+
*/
|
|
19
43
|
const BLOCK_TAGS = /* @__PURE__ */ new Set([
|
|
20
44
|
"p",
|
|
21
45
|
"h1",
|
|
@@ -28,6 +52,8 @@ const BLOCK_TAGS = /* @__PURE__ */ new Set([
|
|
|
28
52
|
"blockquote",
|
|
29
53
|
"pre",
|
|
30
54
|
"table",
|
|
55
|
+
"td",
|
|
56
|
+
"th",
|
|
31
57
|
"tr",
|
|
32
58
|
"ul",
|
|
33
59
|
"ol",
|
|
@@ -230,12 +256,17 @@ const VANTAGE_RUNS = [
|
|
|
230
256
|
"only"
|
|
231
257
|
];
|
|
232
258
|
/**
|
|
233
|
-
* The tags a `section`/`block` directive may
|
|
259
|
+
* The tags a `section`/`block` directive may **target**.
|
|
234
260
|
*
|
|
235
|
-
* Deliberately `rehypeSourceLines`'s `BLOCK_TAGS`: a
|
|
236
|
-
* be a block with a `data-source-line`, so the styling surface and the
|
|
237
|
-
* surface coincide. It also keeps an inline directive from stamping the
|
|
238
|
-
* 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.
|
|
239
270
|
*
|
|
240
271
|
* It lives here rather than in the plugin because the CLI checker has to answer
|
|
241
272
|
* "will this directive stamp anything?" from an mdast tree with no hast in
|
|
@@ -285,6 +316,23 @@ const VANTAGE_ANCHOR_TARGETS = [
|
|
|
285
316
|
"table"
|
|
286
317
|
];
|
|
287
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]+$/;
|
|
288
336
|
const STYLE_KEYS = {
|
|
289
337
|
tone: VANTAGE_TONES,
|
|
290
338
|
emphasis: VANTAGE_EMPHASIS,
|
|
@@ -417,11 +465,13 @@ function parseVantageDirective(comment) {
|
|
|
417
465
|
//#endregion
|
|
418
466
|
//#region src/rehypeVantageDirectives.ts
|
|
419
467
|
/**
|
|
420
|
-
* What a `section`/`block` and an `oq` directive may
|
|
468
|
+
* What a `section`/`block` and an `oq` directive may **target**.
|
|
421
469
|
*
|
|
422
470
|
* Both lists live in `vantageDirectives.ts`, with the reasoning for each tag,
|
|
423
471
|
* because the CLI checker resolves the same question over mdast and must reach
|
|
424
472
|
* the same answer (D5).
|
|
473
|
+
*
|
|
474
|
+
* Neither list bounds a `section`'s range: see `styleRange`.
|
|
425
475
|
*/
|
|
426
476
|
const STYLE_TARGET_TAGS = new Set(VANTAGE_STYLE_TARGETS);
|
|
427
477
|
const ANCHOR_TARGET_TAGS = new Set(VANTAGE_ANCHOR_TARGETS);
|
|
@@ -468,6 +518,18 @@ const RUN_PROPERTY = "dataVantageRun";
|
|
|
468
518
|
const OQ_PROPERTY = "dataVantageOq";
|
|
469
519
|
const LEANING_PROPERTY = "dataVantageLeaning";
|
|
470
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
|
+
/**
|
|
471
533
|
* The three properties `collapsed=true` stamps across a section.
|
|
472
534
|
*
|
|
473
535
|
* The heading takes a *different* attribute from the blocks it hides, and that
|
|
@@ -540,6 +602,22 @@ function accepts(name, key, value) {
|
|
|
540
602
|
* `section` before anything else degrades to that one block, and `block` is
|
|
541
603
|
* always that one block. A heading nested inside a stamped `blockquote` or
|
|
542
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.
|
|
543
621
|
*/
|
|
544
622
|
function styleRange(children, targetIndex, name) {
|
|
545
623
|
const range = [targetIndex];
|
|
@@ -549,7 +627,7 @@ function styleRange(children, targetIndex, name) {
|
|
|
549
627
|
const node = children[i];
|
|
550
628
|
const nodeDepth = headingDepth(node);
|
|
551
629
|
if (nodeDepth !== void 0 && nodeDepth <= depth) break;
|
|
552
|
-
if (node.type === "element"
|
|
630
|
+
if (node.type === "element") range.push(i);
|
|
553
631
|
}
|
|
554
632
|
return range;
|
|
555
633
|
}
|
|
@@ -608,6 +686,8 @@ function stampStyle(children, targetIndex, name, pairs, state) {
|
|
|
608
686
|
}
|
|
609
687
|
function stampOq(target, pairs) {
|
|
610
688
|
setProperty(target, OQ_PROPERTY, "true");
|
|
689
|
+
const id = pairs.get("id");
|
|
690
|
+
if (id !== void 0 && id !== "") setProperty(target, OQ_ID_PROPERTY, id);
|
|
611
691
|
const leaning = pairs.get("leaning");
|
|
612
692
|
if (leaning === void 0) return;
|
|
613
693
|
const text = leaning.replace(/\s+/g, " ").trim().slice(0, MAX_LEANING);
|
|
@@ -913,6 +993,7 @@ const sanitizeSchema = {
|
|
|
913
993
|
["dataVantageCollapseToggle", COLLAPSE_GROUP_ID],
|
|
914
994
|
["dataVantageRun", ...VANTAGE_RUNS],
|
|
915
995
|
["dataVantageOq", "true"],
|
|
996
|
+
["dataVantageOqId", VANTAGE_OQ_ID],
|
|
916
997
|
["dataVantageAlert", ...VANTAGE_ALERTS],
|
|
917
998
|
"dataVantageLeaning"
|
|
918
999
|
],
|
|
@@ -962,6 +1043,7 @@ function buildRehypePlugins(options = {}) {
|
|
|
962
1043
|
plugins.push(rehypeVantageAlerts);
|
|
963
1044
|
plugins.push(rehypeVantageDirectives);
|
|
964
1045
|
if (sanitize) plugins.push([rehypeSanitize, sanitizeSchema]);
|
|
1046
|
+
plugins.push(rehypeVantageAnchors);
|
|
965
1047
|
plugins.push(rehypeSlug);
|
|
966
1048
|
if (highlight) plugins.push(rehypeHighlight);
|
|
967
1049
|
if (math) plugins.push(rehypeCaptureMathStamps, rehypeKatex, rehypeRestoreMathStamps);
|
|
@@ -1084,27 +1166,92 @@ function errorPosition(error) {
|
|
|
1084
1166
|
return { message };
|
|
1085
1167
|
}
|
|
1086
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
|
|
1087
1202
|
//#region src/mermaidCache.ts
|
|
1088
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
|
+
}
|
|
1089
1212
|
//#endregion
|
|
1090
1213
|
//#region src/mermaidLoader.ts
|
|
1091
1214
|
let mermaidInstance = null;
|
|
1092
1215
|
let mermaidLoading = null;
|
|
1093
|
-
|
|
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
|
+
*/
|
|
1094
1239
|
async function getMermaid() {
|
|
1095
|
-
|
|
1240
|
+
const theme = currentMermaidTheme();
|
|
1241
|
+
if (mermaidInstance) {
|
|
1242
|
+
if (configuredTheme !== theme) configure(mermaidInstance, theme);
|
|
1243
|
+
return mermaidInstance;
|
|
1244
|
+
}
|
|
1096
1245
|
if (!mermaidLoading) mermaidLoading = import("mermaid").then((mod) => {
|
|
1097
1246
|
const m = mod.default;
|
|
1098
|
-
m
|
|
1099
|
-
startOnLoad: false,
|
|
1100
|
-
theme: isDark() ? "dark" : "default",
|
|
1101
|
-
securityLevel: "strict",
|
|
1102
|
-
suppressErrorRendering: true
|
|
1103
|
-
});
|
|
1247
|
+
configure(m, currentMermaidTheme());
|
|
1104
1248
|
mermaidInstance = m;
|
|
1105
1249
|
return m;
|
|
1106
1250
|
});
|
|
1107
|
-
|
|
1251
|
+
const loaded = await mermaidLoading;
|
|
1252
|
+
const wanted = currentMermaidTheme();
|
|
1253
|
+
if (configuredTheme !== wanted) configure(loaded, wanted);
|
|
1254
|
+
return loaded;
|
|
1108
1255
|
}
|
|
1109
1256
|
//#endregion
|
|
1110
1257
|
//#region src/MermaidDiagram.tsx
|
|
@@ -1157,7 +1304,7 @@ const MaximizeIcon = () => /* @__PURE__ */ jsxs("svg", {
|
|
|
1157
1304
|
strokeWidth: "2",
|
|
1158
1305
|
strokeLinecap: "round",
|
|
1159
1306
|
strokeLinejoin: "round",
|
|
1160
|
-
className: "w-4 h-4 text-gray-600",
|
|
1307
|
+
className: "w-4 h-4 text-gray-600 dark:text-slate-200",
|
|
1161
1308
|
children: [
|
|
1162
1309
|
/* @__PURE__ */ jsx("polyline", { points: "15 3 21 3 21 9" }),
|
|
1163
1310
|
/* @__PURE__ */ jsx("polyline", { points: "9 21 3 21 3 15" }),
|
|
@@ -1318,32 +1465,32 @@ function ZoomableSvg({ svg }) {
|
|
|
1318
1465
|
dangerouslySetInnerHTML: { __html: svg }
|
|
1319
1466
|
})
|
|
1320
1467
|
}), /* @__PURE__ */ jsxs("div", {
|
|
1321
|
-
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",
|
|
1322
1469
|
children: [
|
|
1323
1470
|
/* @__PURE__ */ jsx("button", {
|
|
1324
1471
|
onClick: () => zoomBy(1 / 1.3),
|
|
1325
|
-
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",
|
|
1326
1473
|
"aria-label": "Zoom out",
|
|
1327
1474
|
title: "Zoom out",
|
|
1328
1475
|
children: /* @__PURE__ */ jsx(MinusIcon, {})
|
|
1329
1476
|
}),
|
|
1330
1477
|
/* @__PURE__ */ jsxs("button", {
|
|
1331
1478
|
onClick: reset,
|
|
1332
|
-
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]",
|
|
1333
1480
|
title: "Reset zoom (or double-click)",
|
|
1334
1481
|
children: [Math.round(scale * 100), "%"]
|
|
1335
1482
|
}),
|
|
1336
1483
|
/* @__PURE__ */ jsx("button", {
|
|
1337
1484
|
onClick: () => zoomBy(1.3),
|
|
1338
|
-
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",
|
|
1339
1486
|
"aria-label": "Zoom in",
|
|
1340
1487
|
title: "Zoom in",
|
|
1341
1488
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
1342
1489
|
}),
|
|
1343
|
-
/* @__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" }),
|
|
1344
1491
|
/* @__PURE__ */ jsx("button", {
|
|
1345
1492
|
onClick: reset,
|
|
1346
|
-
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",
|
|
1347
1494
|
"aria-label": "Reset view",
|
|
1348
1495
|
title: "Reset view",
|
|
1349
1496
|
children: /* @__PURE__ */ jsx(ResetIcon, {})
|
|
@@ -1381,38 +1528,74 @@ function DiagramModal({ isOpen, onClose, children }) {
|
|
|
1381
1528
|
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",
|
|
1382
1529
|
onClick: onClose,
|
|
1383
1530
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1384
|
-
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",
|
|
1385
1532
|
role: "dialog",
|
|
1386
1533
|
"aria-modal": "true",
|
|
1387
1534
|
onClick: (e) => e.stopPropagation(),
|
|
1388
1535
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1389
|
-
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",
|
|
1390
1537
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
1391
1538
|
className: "text-lg font-semibold",
|
|
1392
1539
|
children: "Mermaid Diagram"
|
|
1393
1540
|
}), /* @__PURE__ */ jsx("button", {
|
|
1394
1541
|
onClick: onClose,
|
|
1395
|
-
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",
|
|
1396
1543
|
"aria-label": "Close modal",
|
|
1397
1544
|
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
1398
1545
|
})]
|
|
1399
1546
|
}), /* @__PURE__ */ jsx("div", {
|
|
1400
|
-
className: "flex-1 overflow-hidden bg-gray-50",
|
|
1547
|
+
className: "flex-1 overflow-hidden bg-gray-50 dark:bg-slate-800",
|
|
1401
1548
|
children
|
|
1402
1549
|
})]
|
|
1403
1550
|
})
|
|
1404
1551
|
});
|
|
1405
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
|
+
}
|
|
1406
1581
|
const MermaidDiagramInner = ({ code }) => {
|
|
1407
|
-
const
|
|
1408
|
-
const [svg, setSvg] = useState(() => svgCache.get(code) || "");
|
|
1409
|
-
const [errorMessage, setErrorMessage] = useState(null);
|
|
1582
|
+
const theme = useMermaidTheme();
|
|
1410
1583
|
const [showSource, setShowSource] = useState(false);
|
|
1411
1584
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
1412
|
-
const [isLoading, setIsLoading] = useState(!hasCached);
|
|
1413
1585
|
const [minHeight, setMinHeight] = useState("auto");
|
|
1414
1586
|
const containerRef = useRef(null);
|
|
1415
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);
|
|
1416
1599
|
const stableId = useMemo(() => {
|
|
1417
1600
|
let hash = 0;
|
|
1418
1601
|
for (let i = 0; i < code.length; i++) {
|
|
@@ -1422,9 +1605,14 @@ const MermaidDiagramInner = ({ code }) => {
|
|
|
1422
1605
|
}
|
|
1423
1606
|
return `mermaid-${Math.abs(hash).toString(36)}`;
|
|
1424
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;
|
|
1425
1612
|
useEffect(() => {
|
|
1426
|
-
if (
|
|
1613
|
+
if (getCachedSvg(code, theme) !== void 0) return;
|
|
1427
1614
|
let mounted = true;
|
|
1615
|
+
const key = `${theme} ${stableId}`;
|
|
1428
1616
|
const renderDiagram = async () => {
|
|
1429
1617
|
try {
|
|
1430
1618
|
if (containerRef.current) {
|
|
@@ -1436,17 +1624,18 @@ const MermaidDiagramInner = ({ code }) => {
|
|
|
1436
1624
|
const id = `${stableId}-${Date.now()}`;
|
|
1437
1625
|
const { svg: renderedSvg } = await m.render(id, code);
|
|
1438
1626
|
if (mounted) {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1627
|
+
setCachedSvg(code, renderedSvg, theme);
|
|
1628
|
+
setRendered({
|
|
1629
|
+
key,
|
|
1630
|
+
svg: renderedSvg
|
|
1631
|
+
});
|
|
1443
1632
|
}
|
|
1444
1633
|
} catch (err) {
|
|
1445
1634
|
console.error("Mermaid render error:", err);
|
|
1446
|
-
if (mounted) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
}
|
|
1635
|
+
if (mounted) setFailure({
|
|
1636
|
+
key,
|
|
1637
|
+
message: extractErrorMessage(err)
|
|
1638
|
+
});
|
|
1450
1639
|
}
|
|
1451
1640
|
};
|
|
1452
1641
|
renderDiagram();
|
|
@@ -1456,7 +1645,7 @@ const MermaidDiagramInner = ({ code }) => {
|
|
|
1456
1645
|
}, [
|
|
1457
1646
|
code,
|
|
1458
1647
|
stableId,
|
|
1459
|
-
|
|
1648
|
+
theme
|
|
1460
1649
|
]);
|
|
1461
1650
|
if (errorMessage) return /* @__PURE__ */ jsxs("div", {
|
|
1462
1651
|
"data-testid": "mermaid-container",
|
|
@@ -1496,7 +1685,7 @@ const MermaidDiagramInner = ({ code }) => {
|
|
|
1496
1685
|
dangerouslySetInnerHTML: { __html: svg }
|
|
1497
1686
|
}), svg && /* @__PURE__ */ jsx("button", {
|
|
1498
1687
|
onClick: () => setIsModalOpen(true),
|
|
1499
|
-
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",
|
|
1500
1689
|
"aria-label": "Maximize diagram",
|
|
1501
1690
|
children: /* @__PURE__ */ jsx(MaximizeIcon, {})
|
|
1502
1691
|
})]
|
|
@@ -2156,18 +2345,20 @@ async function renderMermaidBlocks(container, options = {}) {
|
|
|
2156
2345
|
const { className = "mermaid", onError } = options;
|
|
2157
2346
|
const codeBlocks = container.querySelectorAll("pre > code.language-mermaid, pre > code[class*=\"language-mermaid\"]");
|
|
2158
2347
|
if (codeBlocks.length === 0) return;
|
|
2159
|
-
|
|
2348
|
+
let loading;
|
|
2349
|
+
const mermaidOnce = () => loading ??= getMermaid();
|
|
2160
2350
|
const renderPromises = Array.from(codeBlocks).map(async (codeEl) => {
|
|
2161
2351
|
const preEl = codeEl.parentElement;
|
|
2162
2352
|
if (!preEl) return;
|
|
2163
2353
|
const code = codeEl.textContent || "";
|
|
2164
2354
|
if (!code.trim()) return;
|
|
2165
|
-
const cached =
|
|
2355
|
+
const cached = getCachedSvg(code);
|
|
2166
2356
|
if (cached) {
|
|
2167
2357
|
replaceWithSvg(preEl, cached, className);
|
|
2168
2358
|
return;
|
|
2169
2359
|
}
|
|
2170
2360
|
try {
|
|
2361
|
+
const mermaid = await mermaidOnce();
|
|
2171
2362
|
let hash = 0;
|
|
2172
2363
|
for (let i = 0; i < code.length; i++) {
|
|
2173
2364
|
hash = (hash << 5) - hash + code.charCodeAt(i);
|
|
@@ -2175,7 +2366,7 @@ async function renderMermaidBlocks(container, options = {}) {
|
|
|
2175
2366
|
}
|
|
2176
2367
|
const id = `mermaid-${Math.abs(hash).toString(36)}-${Date.now()}`;
|
|
2177
2368
|
const { svg } = await mermaid.render(id, code);
|
|
2178
|
-
|
|
2369
|
+
setCachedSvg(code, svg);
|
|
2179
2370
|
replaceWithSvg(preEl, svg, className);
|
|
2180
2371
|
} catch (err) {
|
|
2181
2372
|
if (onError) onError(code, err instanceof Error ? err : new Error(String(err)));
|
|
@@ -2183,9 +2374,34 @@ async function renderMermaidBlocks(container, options = {}) {
|
|
|
2183
2374
|
});
|
|
2184
2375
|
await Promise.all(renderPromises);
|
|
2185
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
|
+
];
|
|
2186
2398
|
function replaceWithSvg(preEl, svg, className) {
|
|
2187
2399
|
const wrapper = document.createElement("div");
|
|
2188
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
|
+
}
|
|
2189
2405
|
wrapper.innerHTML = svg;
|
|
2190
2406
|
preEl.replaceWith(wrapper);
|
|
2191
2407
|
}
|