vitepress-plugin-diagrams 1.2.2 → 1.3.1
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 +53 -2
- package/dist/build-time.d.ts +36 -0
- package/dist/index.cjs +36 -9
- package/dist/index.d.ts +2 -1
- package/dist/index.js +410 -249
- package/dist/types.d.ts +25 -0
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# VitePress Diagrams Plugin
|
|
2
2
|
|
|
3
|
-
[English](README.md) | [Español](README.es.md) | [中文](README.zh.md) | [Українська](README.uk.md) | [Русский](README.ru.md)
|
|
4
|
-
|
|
5
3
|
A VitePress plugin that adds support for various diagram types using the Kroki service. The plugin automatically converts diagram code blocks into SVG images, caches them locally, and provides a clean, customizable display with optional captions.
|
|
6
4
|
|
|
7
5
|
|
|
@@ -24,6 +22,7 @@ The diagrams are meant to be generated at __DEV time__ because:
|
|
|
24
22
|
- Clean, semantic HTML output
|
|
25
23
|
- Use can use any editor to create diagrams (for example `VS Code` with `Mermaid` extension)
|
|
26
24
|
- **Import diagrams from external files** using `@file:` syntax
|
|
25
|
+
- **Optional build-time generation** for CI/CD pipelines (diagrams generated during `vitepress build`)
|
|
27
26
|
|
|
28
27
|
## Demo
|
|
29
28
|
|
|
@@ -203,6 +202,58 @@ You can customize the `CSS` classes to match your theme.
|
|
|
203
202
|
- For `positionId`, previous files with the same `diagramType` and `positionId` are removed.
|
|
204
203
|
- Without identifiers, older `[diagramType]-[otherHash].svg` files are removed when content changes.
|
|
205
204
|
|
|
205
|
+
## Build-Time Generation (Optional)
|
|
206
|
+
|
|
207
|
+
By default, diagrams are generated at **dev time** (fire-and-forget fetch with a placeholder SVG). For CI/CD pipelines or when you need diagrams to be reliably generated during `vitepress build`, you can use the **build-time generation** mode.
|
|
208
|
+
|
|
209
|
+
In this mode:
|
|
210
|
+
- Diagram HTTP calls are **deferred** and executed during the Vite build (`generateBundle` hook) or dev server request.
|
|
211
|
+
- The build **fails** if a diagram cannot be generated (e.g., Kroki is unreachable), ensuring broken diagrams are caught early.
|
|
212
|
+
- Already-generated SVGs on disk are reused (not re-fetched).
|
|
213
|
+
|
|
214
|
+
### Setup
|
|
215
|
+
|
|
216
|
+
Use `createBuildTimeDiagramsPlugin` instead of `configureDiagramsPlugin`:
|
|
217
|
+
|
|
218
|
+
```ts
|
|
219
|
+
import { defineConfig } from "vitepress";
|
|
220
|
+
import { createBuildTimeDiagramsPlugin } from "vitepress-plugin-diagrams";
|
|
221
|
+
|
|
222
|
+
const { configureMarkdown, vitePlugin } = createBuildTimeDiagramsPlugin({
|
|
223
|
+
diagramsDir: "docs/public/diagrams",
|
|
224
|
+
publicPath: "/diagrams",
|
|
225
|
+
// Optional: emit SVGs as build assets at this path
|
|
226
|
+
diagramsDistDir: "diagrams",
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
export default defineConfig({
|
|
230
|
+
markdown: {
|
|
231
|
+
config: (md) => configureMarkdown(md),
|
|
232
|
+
},
|
|
233
|
+
vite: {
|
|
234
|
+
plugins: [vitePlugin()],
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
All standard options (`krokiServerUrl`, `excludedDiagramTypes`, `enableFileImports`, etc.) are supported.
|
|
240
|
+
|
|
241
|
+
| Additional Option | Type | Default | Description |
|
|
242
|
+
|-------------------|------|---------|-------------|
|
|
243
|
+
| `diagramsDistDir` | `string` | `undefined` | If set, SVG files are emitted as Vite build assets at this path |
|
|
244
|
+
|
|
245
|
+
### Using with a self-hosted Kroki instance
|
|
246
|
+
|
|
247
|
+
For reliable CI builds, you can run [Kroki via Docker](https://docs.kroki.io/kroki/setup/use-docker-or-podman/) and point the plugin to it:
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
const { configureMarkdown, vitePlugin } = createBuildTimeDiagramsPlugin({
|
|
251
|
+
krokiServerUrl: "http://localhost:8000",
|
|
252
|
+
diagramsDir: "docs/public/diagrams",
|
|
253
|
+
publicPath: "/diagrams",
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
206
257
|
## Note
|
|
207
258
|
|
|
208
259
|
When updating a diagram, you may see a placeholder image on the browser page. This is normal, because the svg file is loaded asynchronously and may not be displayed immediately. Just refresh the page.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { BuildTimeDiagramPluginOptions } from "./types.js";
|
|
2
|
+
import type { MarkdownRenderer } from "vitepress";
|
|
3
|
+
/**
|
|
4
|
+
* Create a pair of plugins for build-time diagram generation.
|
|
5
|
+
*
|
|
6
|
+
* Unlike the default dev-time mode (which writes a placeholder SVG and fetches
|
|
7
|
+
* asynchronously), this mode defers all HTTP calls and processes them during the
|
|
8
|
+
* Vite build (`generateBundle`) or dev server request (`configureServer`).
|
|
9
|
+
*
|
|
10
|
+
* This is useful for CI/CD pipelines where diagrams must be generated reliably
|
|
11
|
+
* at build time, and a build failure is expected when a diagram cannot be generated.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { createBuildTimeDiagramsPlugin } from "vitepress-plugin-diagrams";
|
|
16
|
+
*
|
|
17
|
+
* const { configureMarkdown, vitePlugin } = createBuildTimeDiagramsPlugin({
|
|
18
|
+
* diagramsDir: "docs/public/diagrams",
|
|
19
|
+
* diagramsDistDir: "diagrams",
|
|
20
|
+
* publicPath: "/diagrams",
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* export default defineConfig({
|
|
24
|
+
* markdown: { config: (md) => configureMarkdown(md) },
|
|
25
|
+
* vite: { plugins: [vitePlugin()] },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function createBuildTimeDiagramsPlugin(options?: BuildTimeDiagramPluginOptions): {
|
|
30
|
+
configureMarkdown: (md: MarkdownRenderer) => void;
|
|
31
|
+
vitePlugin: () => {
|
|
32
|
+
name: string;
|
|
33
|
+
configureServer(server: any): void;
|
|
34
|
+
generateBundle(this: any): Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,45 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("node:fs"),Y=require("node:path"),X=require("node:crypto"),K=require("node:process");function v(t){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(u,e,s.get?s:{enumerable:!0,get:()=>t[e]})}}return u.default=t,Object.freeze(u)}const E=v(J),l=v(Y),I=v(X),m=v(K),w=["blockdiag","bpmn","bytefield","seqdiag","actdiag","nwdiag","packetdiag","rackdiag","c4plantuml","d2","dbml","ditaa","erd","excalidraw","graphviz","mermaid","nomnoml","pikchr","plantuml","structurizr","svgbob","symbolator","tikz","umlet","vega","vega-lite","wavedrom","wireviz"],Q=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,V=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;function k(t){switch(t){case 9:case 32:return!0}return!1}function P(t){if(t>=8192&&t<=8202)return!0;switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function _(t){return Q.test(t)||V.test(t)}function M(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function d(t,u,e){this.type=t,this.tag=u,this.attrs=null,this.map=null,this.nesting=e,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}d.prototype.attrIndex=function(u){if(!this.attrs)return-1;const e=this.attrs;for(let s=0,r=e.length;s<r;s++)if(e[s][0]===u)return s;return-1};d.prototype.attrPush=function(u){this.attrs?this.attrs.push(u):this.attrs=[u]};d.prototype.attrSet=function(u,e){const s=this.attrIndex(u),r=[u,e];s<0?this.attrPush(r):this.attrs[s]=r};d.prototype.attrGet=function(u){const e=this.attrIndex(u);let s=null;return e>=0&&(s=this.attrs[e][1]),s};d.prototype.attrJoin=function(u,e){const s=this.attrIndex(u);s<0?this.attrPush([u,e]):this.attrs[s][1]=this.attrs[s][1]+" "+e};function uu(t,u,e){this.src=t,this.env=e,this.tokens=[],this.inlineMode=!1,this.md=u}uu.prototype.Token=d;function f(t,u,e,s){this.src=t,this.md=u,this.env=e,this.tokens=s,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const r=this.src;for(let o=0,i=0,D=0,n=0,c=r.length,a=!1;i<c;i++){const F=r.charCodeAt(i);if(!a)if(k(F)){D++,F===9?n+=4-n%4:n++;continue}else a=!0;(F===10||i===c-1)&&(F!==10&&i++,this.bMarks.push(o),this.eMarks.push(i),this.tShift.push(D),this.sCount.push(n),this.bsCount.push(0),a=!1,D=0,n=0,o=i+1)}this.bMarks.push(r.length),this.eMarks.push(r.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}f.prototype.push=function(t,u,e){const s=new d(t,u,e);return s.block=!0,e<0&&this.level--,s.level=this.level,e>0&&this.level++,this.tokens.push(s),s};f.prototype.isEmpty=function(u){return this.bMarks[u]+this.tShift[u]>=this.eMarks[u]};f.prototype.skipEmptyLines=function(u){for(let e=this.lineMax;u<e&&!(this.bMarks[u]+this.tShift[u]<this.eMarks[u]);u++);return u};f.prototype.skipSpaces=function(u){for(let e=this.src.length;u<e;u++){const s=this.src.charCodeAt(u);if(!k(s))break}return u};f.prototype.skipSpacesBack=function(u,e){if(u<=e)return u;for(;u>e;)if(!k(this.src.charCodeAt(--u)))return u+1;return u};f.prototype.skipChars=function(u,e){for(let s=this.src.length;u<s&&this.src.charCodeAt(u)===e;u++);return u};f.prototype.skipCharsBack=function(u,e,s){if(u<=s)return u;for(;u>s;)if(e!==this.src.charCodeAt(--u))return u+1;return u};f.prototype.getLines=function(u,e,s,r){if(u>=e)return"";const o=new Array(e-u);for(let i=0,D=u;D<e;D++,i++){let n=0;const c=this.bMarks[D];let a=c,F;for(D+1<e||r?F=this.eMarks[D]+1:F=this.eMarks[D];a<F&&n<s;){const h=this.src.charCodeAt(a);if(k(h))h===9?n+=4-(n+this.bsCount[D])%4:n++;else if(a-c<this.tShift[D])n++;else break;a++}n>s?o[i]=new Array(n-s+1).join(" ")+this.src.slice(a,F):o[i]=this.src.slice(a,F)}return o.join("")};f.prototype.Token=d;const tu=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],eu="[a-zA-Z_:][a-zA-Z0-9:._-]*",su="[^\"'=<>`\\x00-\\x20]+",ru="'[^']*'",iu='"[^"]*"',nu="(?:"+su+"|"+ru+"|"+iu+")",ou="(?:\\s+"+eu+"(?:\\s*=\\s*"+nu+")?)",Du="<[A-Za-z][A-Za-z0-9\\-]*"+ou+"*\\s*\\/?>",au="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",cu=new RegExp("^(?:"+Du+"|"+au+")");new RegExp("^</?("+tu.join("|")+")(?=(\\s|/?>|$))","i"),new RegExp(cu.source+"\\s*$");function S(t,u,e,s){this.src=t,this.env=e,this.md=u,this.tokens=s,this.tokens_meta=Array(s.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}S.prototype.pushPending=function(){const t=new d("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t};S.prototype.push=function(t,u,e){this.pending&&this.pushPending();const s=new d(t,u,e);let r=null;return e<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),s.level=this.level,e>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],r={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(s),this.tokens_meta.push(r),s};S.prototype.scanDelims=function(t,u){const e=this.posMax,s=this.src.charCodeAt(t),r=t>0?this.src.charCodeAt(t-1):32;let o=t;for(;o<e&&this.src.charCodeAt(o)===s;)o++;const i=o-t,D=o<e?this.src.charCodeAt(o):32,n=M(r)||_(String.fromCharCode(r)),c=M(D)||_(String.fromCharCode(D)),a=P(r),F=P(D),h=!F&&(!c||a||n),C=!a&&(!n||F||c);return{can_open:h&&(u||!C||n),can_close:C&&(u||!h||c),length:i}};S.prototype.Token=d;const L=[];for(let t=0;t<256;t++)L.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t){L[t.charCodeAt(0)]=1});function Fu(t,u){var s,r;const e=t[u+1];if(e&&e.type==="html_block"){const o=e.content.match(/<!--\s*diagram(?:\s+id="([^"]+)")?/),i=e.content.match(/\s+caption="([^"]+)"/);return{id:(s=o==null?void 0:o[1])==null?void 0:s.trim(),caption:((r=i==null?void 0:i[1])==null?void 0:r.trim())||""}}return{caption:"",id:void 0}}function z(t,u,e,s,r){const o=r!==void 0?`${u}${r}`:u,i=I.createHash("md5").update(o).digest("hex");return e?`${t}-${e}-${i}.svg`:s?`${t}-${s}-${i}.svg`:`${t}-${i}.svg`}function lu(t){var e;const u=((e=m==null?void 0:m.cwd)==null?void 0:e.call(m))||m.env.PWD||m.env.INIT_CWD||".";return t?l.resolve(u,t):l.resolve(u,"docs/public/diagrams")}function q(t,u,e,s,r,o){try{const i=E.readdirSync(t);let D=[];if(e)D=i.filter(n=>n.startsWith(`${u}-${e}-`)&&n!==s);else if(o)D=i.filter(n=>n.startsWith(`${u}-${o}-`)&&n!==s);else if(r){const n=I.createHash("md5").update(r).digest("hex"),c=`${u}-${n}.svg`;D=i.filter(a=>{if(!a.startsWith(`${u}-`)||!a.endsWith(".svg")||a===s||a===c)return!1;const h=a.slice(0,-4).split("-");return h.length===2&&h[0]===u})}D.forEach(n=>{const c=l.join(t,n);E.existsSync(c)&&(E.unlinkSync(c),console.log(`Removed old diagram file: ${n}`))})}catch(i){console.warn(`Failed to remove old diagram files: ${i}`)}}const hu=[".exe",".bat",".cmd",".sh",".bash",".ps1",".vbs",".js",".ts",".php",".py",".rb",".pl",".com",".msi",".jar",".pif",".scr",".wsf",".wsc",".wsh",".hta",".cpl",".inf",".reg",".lnk"];function W(t){const u=l.extname(t).toLowerCase();return hu.includes(u)}function j(t){return t.trim().startsWith("@file:")}function R(t){const u=t.trim();return u.startsWith("@file:")&&u.split(`
|
|
2
|
-
`)[0].slice(6).trim()||null}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ut=require("node:fs"),et=require("node:path"),st=require("node:crypto"),rt=require("node:process");function P(u){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>u[e]})}}return t.default=u,Object.freeze(t)}const E=P(ut),d=P(et),J=P(st),k=P(rt),y=["blockdiag","bpmn","bytefield","seqdiag","actdiag","nwdiag","packetdiag","rackdiag","c4plantuml","d2","dbml","ditaa","erd","excalidraw","graphviz","mermaid","nomnoml","pikchr","plantuml","structurizr","svgbob","symbolator","tikz","umlet","vega","vega-lite","wavedrom","wireviz"],it=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,nt=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;function _(u){switch(u){case 9:case 32:return!0}return!1}function T(u){if(u>=8192&&u<=8202)return!0;switch(u){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function Z(u){return it.test(u)||nt.test(u)}function H(u){switch(u){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function C(u,t,e){this.type=u,this.tag=t,this.attrs=null,this.map=null,this.nesting=e,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}C.prototype.attrIndex=function(t){if(!this.attrs)return-1;const e=this.attrs;for(let s=0,a=e.length;s<a;s++)if(e[s][0]===t)return s;return-1};C.prototype.attrPush=function(t){this.attrs?this.attrs.push(t):this.attrs=[t]};C.prototype.attrSet=function(t,e){const s=this.attrIndex(t),a=[t,e];s<0?this.attrPush(a):this.attrs[s]=a};C.prototype.attrGet=function(t){const e=this.attrIndex(t);let s=null;return e>=0&&(s=this.attrs[e][1]),s};C.prototype.attrJoin=function(t,e){const s=this.attrIndex(t);s<0?this.attrPush([t,e]):this.attrs[s][1]=this.attrs[s][1]+" "+e};function at(u,t,e){this.src=u,this.env=e,this.tokens=[],this.inlineMode=!1,this.md=t}at.prototype.Token=C;function x(u,t,e,s){this.src=u,this.md=t,this.env=e,this.tokens=s,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const a=this.src;for(let l=0,r=0,n=0,i=0,D=a.length,o=!1;r<D;r++){const c=a.charCodeAt(r);if(!o)if(_(c)){n++,c===9?i+=4-i%4:i++;continue}else o=!0;(c===10||r===D-1)&&(c!==10&&r++,this.bMarks.push(l),this.eMarks.push(r),this.tShift.push(n),this.sCount.push(i),this.bsCount.push(0),o=!1,n=0,i=0,l=r+1)}this.bMarks.push(a.length),this.eMarks.push(a.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}x.prototype.push=function(u,t,e){const s=new C(u,t,e);return s.block=!0,e<0&&this.level--,s.level=this.level,e>0&&this.level++,this.tokens.push(s),s};x.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]};x.prototype.skipEmptyLines=function(t){for(let e=this.lineMax;t<e&&!(this.bMarks[t]+this.tShift[t]<this.eMarks[t]);t++);return t};x.prototype.skipSpaces=function(t){for(let e=this.src.length;t<e;t++){const s=this.src.charCodeAt(t);if(!_(s))break}return t};x.prototype.skipSpacesBack=function(t,e){if(t<=e)return t;for(;t>e;)if(!_(this.src.charCodeAt(--t)))return t+1;return t};x.prototype.skipChars=function(t,e){for(let s=this.src.length;t<s&&this.src.charCodeAt(t)===e;t++);return t};x.prototype.skipCharsBack=function(t,e,s){if(t<=s)return t;for(;t>s;)if(e!==this.src.charCodeAt(--t))return t+1;return t};x.prototype.getLines=function(t,e,s,a){if(t>=e)return"";const l=new Array(e-t);for(let r=0,n=t;n<e;n++,r++){let i=0;const D=this.bMarks[n];let o=D,c;for(n+1<e||a?c=this.eMarks[n]+1:c=this.eMarks[n];o<c&&i<s;){const F=this.src.charCodeAt(o);if(_(F))F===9?i+=4-(i+this.bsCount[n])%4:i++;else if(o-D<this.tShift[n])i++;else break;o++}i>s?l[r]=new Array(i-s+1).join(" ")+this.src.slice(o,c):l[r]=this.src.slice(o,c)}return l.join("")};x.prototype.Token=C;const ot=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ct="[a-zA-Z_:][a-zA-Z0-9:._-]*",lt="[^\"'=<>`\\x00-\\x20]+",Dt="'[^']*'",Ft='"[^"]*"',ht="(?:"+lt+"|"+Dt+"|"+Ft+")",dt="(?:\\s+"+ct+"(?:\\s*=\\s*"+ht+")?)",ft="<[A-Za-z][A-Za-z0-9\\-]*"+dt+"*\\s*\\/?>",Et="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",mt=new RegExp("^(?:"+ft+"|"+Et+")");new RegExp("^</?("+ot.join("|")+")(?=(\\s|/?>|$))","i"),new RegExp(mt.source+"\\s*$");function M(u,t,e,s){this.src=u,this.env=e,this.md=t,this.tokens=s,this.tokens_meta=Array(s.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}M.prototype.pushPending=function(){const u=new C("text","",0);return u.content=this.pending,u.level=this.pendingLevel,this.tokens.push(u),this.pending="",u};M.prototype.push=function(u,t,e){this.pending&&this.pushPending();const s=new C(u,t,e);let a=null;return e<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),s.level=this.level,e>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],a={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(s),this.tokens_meta.push(a),s};M.prototype.scanDelims=function(u,t){const e=this.posMax,s=this.src.charCodeAt(u),a=u>0?this.src.charCodeAt(u-1):32;let l=u;for(;l<e&&this.src.charCodeAt(l)===s;)l++;const r=l-u,n=l<e?this.src.charCodeAt(l):32,i=H(a)||Z(String.fromCharCode(a)),D=H(n)||Z(String.fromCharCode(n)),o=T(a),c=T(n),F=!c&&(!D||o||i),h=!o&&(!i||c||D);return{can_open:F&&(t||!h||i),can_close:h&&(t||!F||D),length:r}};M.prototype.Token=C;const Y=[];for(let u=0;u<256;u++)Y.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(u){Y[u.charCodeAt(0)]=1});function K(u,t){var s,a;const e=u[t+1];if(e&&e.type==="html_block"){const l=e.content.match(/<!--\s*diagram(?:\s+id="([^"]+)")?/),r=e.content.match(/\s+caption="([^"]+)"/);return{id:(s=l==null?void 0:l[1])==null?void 0:s.trim(),caption:((a=r==null?void 0:r[1])==null?void 0:a.trim())||""}}return{caption:"",id:void 0}}function z(u,t,e,s,a){const l=a!==void 0?`${t}${a}`:t,r=J.createHash("md5").update(l).digest("hex");return e?`${u}-${e}-${r}.svg`:s?`${u}-${s}-${r}.svg`:`${u}-${r}.svg`}function X(u){var e;const t=((e=k==null?void 0:k.cwd)==null?void 0:e.call(k))||k.env.PWD||k.env.INIT_CWD||".";return u?d.resolve(t,u):d.resolve(t,"docs/public/diagrams")}function j(u,t,e,s,a,l){try{const r=E.readdirSync(u);let n=[];if(e)n=r.filter(i=>i.startsWith(`${t}-${e}-`)&&i!==s);else if(l)n=r.filter(i=>i.startsWith(`${t}-${l}-`)&&i!==s);else if(a){const i=J.createHash("md5").update(a).digest("hex"),D=`${t}-${i}.svg`;n=r.filter(o=>{if(!o.startsWith(`${t}-`)||!o.endsWith(".svg")||o===s||o===D)return!1;const F=o.slice(0,-4).split("-");return F.length===2&&F[0]===t})}n.forEach(i=>{const D=d.join(u,i);E.existsSync(D)&&(E.unlinkSync(D),console.log(`Removed old diagram file: ${i}`))})}catch(r){console.warn(`Failed to remove old diagram files: ${r}`)}}const pt=[".exe",".bat",".cmd",".sh",".bash",".ps1",".vbs",".js",".ts",".php",".py",".rb",".pl",".com",".msi",".jar",".pif",".scr",".wsf",".wsc",".wsh",".hta",".cpl",".inf",".reg",".lnk"];function Q(u){const t=d.extname(u).toLowerCase();return pt.includes(t)}function R(u){return u.trim().startsWith("@file:")}function W(u){const t=u.trim();return t.startsWith("@file:")&&t.split(`
|
|
2
|
+
`)[0].slice(6).trim()||null}function U(u,t){if(u.startsWith("/"))return u;const e=d.dirname(t);return d.resolve(e,u)}function G(u,t){if(!t||t.length===0)return!0;try{const e=E.realpathSync(d.resolve(u));for(const s of t){const a=d.resolve(s),l=E.realpathSync(a);if(e.startsWith(l+d.sep)||e===l)return!0}}catch{const s=d.resolve(u);for(const a of t){const l=d.resolve(a);if(s.startsWith(l+d.sep)||s===l)return!0}}return!1}function O(u){try{if(Q(u))throw new Error(`File extension not allowed: ${d.extname(u)}`);const t=E.statSync(u);if(!t.isFile())throw new Error(`Path is not a file: ${u}`);const e=E.realpathSync(u);return{content:E.readFileSync(e,"utf-8"),filePath:e,mtime:t.mtimeMs}}catch(t){const e=t instanceof Error?t.message:String(t);throw new Error(`Failed to read file import: ${e}`)}}function Ct(u={}){const t=[];function e(r){const n=r.renderer.rules.fence;r.renderer.rules.fence=(i,D,o,c,F)=>{const h=i[D],m=h.info.trim().toLowerCase(),f=u.excludedDiagramTypes??[],g=y.includes(m),p=f.includes(m);if(g&&!p){let B=h.content.trim();const{caption:I,id:A}=K(i,D),w=u.enableFileImports??!0;let S;if(w&&R(B))try{const v=W(B);if(v){const b=(c==null?void 0:c.path)||"";if(!b)return'<div class="diagram-error">Cannot resolve file import: markdown file path is not available</div>';const q=U(v,b),tt=u.allowedImportDirs;if(!G(q,tt))return`<div class="diagram-error">File import not allowed: ${v}. Path is outside allowed directories.</div>`;const N=O(q);B=N.content,S=N.mtime}}catch(v){const b=v instanceof Error?v.message:String(v);return`<div class="diagram-error">Error loading diagram file in ${(c==null?void 0:c.path)||"unknown"}: ${b}</div>`}const L=(c==null?void 0:c.path)||"unknown",$=`${d.basename(L,".md")}-${D}`;return s(B,m,I,A,$,S)}return n(i,D,o,c,F)}}function s(r,n,i,D,o,c){try{const F=r.replaceAll(`\r
|
|
3
3
|
`,`
|
|
4
|
-
`);if(!
|
|
4
|
+
`);if(!y.includes(n))throw new Error(`Unsupported diagram type: ${n}`);const h=X(u.diagramsDir);E.mkdirSync(h,{recursive:!0});const m=z(n,F,D,o,c),f=d.join(h,m);!E.existsSync(f)&&!t.some(B=>B.filepath===f)&&t.push(a(n,h,F,m,f,D,o));const p=u.publicPath??"/diagrams";return`<figure
|
|
5
|
+
class="vpd-diagram vpd-diagram--${n}"
|
|
6
|
+
onclick="
|
|
7
|
+
const figure = this;
|
|
8
|
+
const isFullscreen = figure.classList.contains('vpd-diagram--fullscreen');
|
|
9
|
+
|
|
10
|
+
document.querySelectorAll('.vpd-diagram').forEach(diagram => {
|
|
11
|
+
diagram.classList.remove('vpd-diagram--fullscreen');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (!isFullscreen) {
|
|
15
|
+
figure.classList.add('vpd-diagram--fullscreen');
|
|
16
|
+
}
|
|
17
|
+
"
|
|
18
|
+
>
|
|
19
|
+
<img
|
|
20
|
+
:src="\`${p}/${m}\`"
|
|
21
|
+
alt="${n} Diagram"
|
|
22
|
+
class="vpd-diagram-image"
|
|
23
|
+
/>
|
|
24
|
+
${i?`<figcaption class="vpd-diagram-caption">
|
|
25
|
+
${i}
|
|
26
|
+
</figcaption>`:""}
|
|
27
|
+
</figure>`}catch(F){const h=F instanceof Error?F.message:String(F);return console.error(`Error converting ${n} diagram:`,h),`<div class="diagram-error">Error converting diagram: ${h}</div>`}}function a(r,n,i,D,o,c,F){const h=u.krokiServerUrl??"https://kroki.io",m=u.diagramsDistDir;return{filepath:o,getDiagram:async()=>{const f=await fetch(`${h}/${r}`,{method:"POST",headers:{Accept:"image/svg+xml","Content-Type":"text/plain"},body:i});if(!f.ok)throw new Error(`Kroki returned ${f.status} for ${r} diagram (${o}): ${await f.text()}`);const g=await f.text();if(j(n,r,c,D,i,F),E.writeFileSync(o,g),console.log(`✓ Generated diagram: ${o}`),m)return{type:"asset",fileName:`${m}/${D}`,source:g}}}}function l(){return{name:"vitepress-build-time-diagrams",configureServer(r){r.middlewares.use(async(n,i,D)=>{const o=t.splice(0);o.length>0&&await Promise.all(o.map(c=>c.getDiagram())),D()})},async generateBundle(){const r=t.splice(0);r.length!==0&&(console.log(`
|
|
28
|
+
Generating ${r.length} diagram(s) at build time...`),await Promise.all(r.map(async n=>{const i=await n.getDiagram();i&&this.emitFile(i)})),console.log(`✓ All diagrams generated successfully.
|
|
29
|
+
`))}}}return{configureMarkdown:e,vitePlugin:l}}function V(u,t,e,s,a={},l,r){try{const n=u.replaceAll(`\r
|
|
30
|
+
`,`
|
|
31
|
+
`);if(!y.includes(t))throw new Error(`Unsupported diagram type: ${t}`);const i=X(a.diagramsDir);E.mkdirSync(i,{recursive:!0});const D=z(t,n,s,l,r),o=d.join(i,D),c=E.existsSync(o);let F=!1;if(c&&(F=E.readFileSync(o,"utf-8").includes("<!-- vpd-placeholder -->")),!c||F){j(i,t,s,D,n,l);const f=`<?xml version="1.0" encoding="UTF-8"?>
|
|
5
32
|
<svg width="100%" height="120" xmlns="http://www.w3.org/2000/svg">
|
|
6
33
|
<!-- vpd-placeholder -->
|
|
7
34
|
<rect width="100%" height="120" fill="#f5f5f5"/>
|
|
8
35
|
<text x="50%" y="45%" font-family="system-ui" font-size="14" fill="#666" text-anchor="middle" dominant-baseline="middle">
|
|
9
|
-
Generating ${
|
|
36
|
+
Generating ${t} diagram...
|
|
10
37
|
</text>
|
|
11
38
|
<text x="50%" y="65%" font-family="system-ui" font-size="14" fill="#666" text-anchor="middle" dominant-baseline="middle">
|
|
12
39
|
Refresh the page.
|
|
13
40
|
</text>
|
|
14
|
-
</svg>`;E.writeFileSync(
|
|
15
|
-
class="vpd-diagram vpd-diagram--${
|
|
41
|
+
</svg>`;E.writeFileSync(o,f);const g=a.krokiServerUrl??"https://kroki.io";fetch(`${g}/${t}`,{method:"POST",headers:{Accept:"image/svg+xml","Content-Type":"text/plain"},body:n}).then(p=>p.text()).then(p=>(E.writeFileSync(o,p),p))}const m=a.publicPath??"/diagrams";return`<figure
|
|
42
|
+
class="vpd-diagram vpd-diagram--${t}"
|
|
16
43
|
onclick="
|
|
17
44
|
const figure = this;
|
|
18
45
|
const isFullscreen = figure.classList.contains('vpd-diagram--fullscreen');
|
|
@@ -27,11 +54,11 @@
|
|
|
27
54
|
"
|
|
28
55
|
>
|
|
29
56
|
<img
|
|
30
|
-
:src="\`${
|
|
31
|
-
alt="${
|
|
57
|
+
:src="\`${m}/${D}\`"
|
|
58
|
+
alt="${t} Diagram"
|
|
32
59
|
class="vpd-diagram-image"
|
|
33
60
|
/>
|
|
34
61
|
${e?`<figcaption class="vpd-diagram-caption">
|
|
35
62
|
${e}
|
|
36
63
|
</figcaption>`:""}
|
|
37
|
-
</figure>`}catch(
|
|
64
|
+
</figure>`}catch(n){const i=n instanceof Error?n.message:String(n);return console.error(`Error converting ${t} diagram:`,i),`<div class="diagram-error">Error converting diagram: ${i}</div>`}}function gt(u,t={}){const e=u.renderer.rules.fence;u.renderer.rules.fence=(s,a,l,r,n)=>{const i=s[a],D=i.info.trim().toLowerCase(),o=t.excludedDiagramTypes??[],c=y.includes(D),F=o.includes(D);if(c&&!F){let h=i.content.trim();const{caption:m,id:f}=K(s,a),g=t.enableFileImports??!0;let p;if(g&&R(h))try{const A=W(h);if(A){const w=(r==null?void 0:r.path)||"";if(!w)return'<div class="diagram-error">Cannot resolve file import: markdown file path is not available</div>';const S=U(A,w),L=t.allowedImportDirs;if(!G(S,L))return`<div class="diagram-error">File import not allowed: ${A}. Path is outside allowed directories.</div>`;const $=O(S);h=$.content,p=$.mtime}}catch(A){const w=A instanceof Error?A.message:String(A);return`<div class="diagram-error">Error loading diagram file in ${(r==null?void 0:r.path)||"unknown"}: ${w}</div>`}const B=(r==null?void 0:r.path)||"unknown",I=`${d.basename(B,".md")}-${a}`;return V(h,D,m,f,t,I,p)}return e(s,a,l,r,n)}}exports.SUPPORTED_DIAGRAM_TYPES=y;exports.configureDiagramsPlugin=gt;exports.createBuildTimeDiagramsPlugin=Ct;exports.diagramToSvg=V;exports.generateUniqueFilename=z;exports.hasDangerousExtension=Q;exports.isFileImportSyntax=R;exports.parseFileImportPath=W;exports.readFileImport=O;exports.removeOldDiagramFiles=j;exports.resolveFileImportPath=U;exports.validateFileImportPath=G;
|
package/dist/index.d.ts
CHANGED
|
@@ -19,5 +19,6 @@ export declare function diagramToSvg(diagram: string, diagramType: string, capti
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function configureDiagramsPlugin(md: MarkdownRenderer, diagramsPluginOptions?: DiagramPluginOptions): void;
|
|
21
21
|
export { SUPPORTED_DIAGRAM_TYPES } from "./constants";
|
|
22
|
-
export type { DiagramMetadata, DiagramPluginOptions } from "./types";
|
|
22
|
+
export type { DiagramMetadata, DiagramPluginOptions, BuildTimeDiagramPluginOptions } from "./types";
|
|
23
23
|
export { generateUniqueFilename, removeOldDiagramFiles, isFileImportSyntax, parseFileImportPath, resolveFileImportPath, validateFileImportPath, readFileImport, hasDangerousExtension, type FileImportResult, } from "./utils";
|
|
24
|
+
export { createBuildTimeDiagramsPlugin } from "./build-time";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as E from "node:fs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
const
|
|
2
|
+
import * as d from "node:path";
|
|
3
|
+
import * as G from "node:crypto";
|
|
4
|
+
import * as v from "node:process";
|
|
5
|
+
const b = [
|
|
6
6
|
"blockdiag",
|
|
7
7
|
"bpmn",
|
|
8
8
|
"bytefield",
|
|
@@ -31,19 +31,19 @@ const M = [
|
|
|
31
31
|
"vega-lite",
|
|
32
32
|
"wavedrom",
|
|
33
33
|
"wireviz"
|
|
34
|
-
],
|
|
35
|
-
function
|
|
36
|
-
switch (
|
|
34
|
+
], Q = /[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/, V = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;
|
|
35
|
+
function P(u) {
|
|
36
|
+
switch (u) {
|
|
37
37
|
case 9:
|
|
38
38
|
case 32:
|
|
39
39
|
return !0;
|
|
40
40
|
}
|
|
41
41
|
return !1;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
if (
|
|
43
|
+
function W(u) {
|
|
44
|
+
if (u >= 8192 && u <= 8202)
|
|
45
45
|
return !0;
|
|
46
|
-
switch (
|
|
46
|
+
switch (u) {
|
|
47
47
|
case 9:
|
|
48
48
|
// \t
|
|
49
49
|
case 10:
|
|
@@ -64,11 +64,11 @@ function b(t) {
|
|
|
64
64
|
}
|
|
65
65
|
return !1;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
67
|
+
function R(u) {
|
|
68
|
+
return Q.test(u) || V.test(u);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
switch (
|
|
70
|
+
function q(u) {
|
|
71
|
+
switch (u) {
|
|
72
72
|
case 33:
|
|
73
73
|
case 34:
|
|
74
74
|
case 35:
|
|
@@ -106,118 +106,118 @@ function _(t) {
|
|
|
106
106
|
return !1;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
this.type =
|
|
109
|
+
function p(u, t, e) {
|
|
110
|
+
this.type = u, this.tag = t, this.attrs = null, this.map = null, this.nesting = e, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
p.prototype.attrIndex = function(t) {
|
|
113
113
|
if (!this.attrs)
|
|
114
114
|
return -1;
|
|
115
115
|
const e = this.attrs;
|
|
116
|
-
for (let s = 0,
|
|
117
|
-
if (e[s][0] ===
|
|
116
|
+
for (let s = 0, a = e.length; s < a; s++)
|
|
117
|
+
if (e[s][0] === t)
|
|
118
118
|
return s;
|
|
119
119
|
return -1;
|
|
120
120
|
};
|
|
121
|
-
|
|
122
|
-
this.attrs ? this.attrs.push(
|
|
121
|
+
p.prototype.attrPush = function(t) {
|
|
122
|
+
this.attrs ? this.attrs.push(t) : this.attrs = [t];
|
|
123
123
|
};
|
|
124
|
-
|
|
125
|
-
const s = this.attrIndex(
|
|
126
|
-
s < 0 ? this.attrPush(
|
|
124
|
+
p.prototype.attrSet = function(t, e) {
|
|
125
|
+
const s = this.attrIndex(t), a = [t, e];
|
|
126
|
+
s < 0 ? this.attrPush(a) : this.attrs[s] = a;
|
|
127
127
|
};
|
|
128
|
-
|
|
129
|
-
const e = this.attrIndex(
|
|
128
|
+
p.prototype.attrGet = function(t) {
|
|
129
|
+
const e = this.attrIndex(t);
|
|
130
130
|
let s = null;
|
|
131
131
|
return e >= 0 && (s = this.attrs[e][1]), s;
|
|
132
132
|
};
|
|
133
|
-
|
|
134
|
-
const s = this.attrIndex(
|
|
135
|
-
s < 0 ? this.attrPush([
|
|
133
|
+
p.prototype.attrJoin = function(t, e) {
|
|
134
|
+
const s = this.attrIndex(t);
|
|
135
|
+
s < 0 ? this.attrPush([t, e]) : this.attrs[s][1] = this.attrs[s][1] + " " + e;
|
|
136
136
|
};
|
|
137
|
-
function
|
|
138
|
-
this.src =
|
|
137
|
+
function tt(u, t, e) {
|
|
138
|
+
this.src = u, this.env = e, this.tokens = [], this.inlineMode = !1, this.md = t;
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
function
|
|
142
|
-
this.src =
|
|
143
|
-
const
|
|
144
|
-
for (let D = 0,
|
|
145
|
-
const
|
|
146
|
-
if (!
|
|
147
|
-
if (
|
|
148
|
-
|
|
140
|
+
tt.prototype.Token = p;
|
|
141
|
+
function x(u, t, e, s) {
|
|
142
|
+
this.src = u, this.md = t, this.env = e, this.tokens = s, this.bMarks = [], this.eMarks = [], this.tShift = [], this.sCount = [], this.bsCount = [], this.blkIndent = 0, this.line = 0, this.lineMax = 0, this.tight = !1, this.ddIndent = -1, this.listIndent = -1, this.parentType = "root", this.level = 0;
|
|
143
|
+
const a = this.src;
|
|
144
|
+
for (let D = 0, r = 0, n = 0, i = 0, l = a.length, o = !1; r < l; r++) {
|
|
145
|
+
const c = a.charCodeAt(r);
|
|
146
|
+
if (!o)
|
|
147
|
+
if (P(c)) {
|
|
148
|
+
n++, c === 9 ? i += 4 - i % 4 : i++;
|
|
149
149
|
continue;
|
|
150
150
|
} else
|
|
151
|
-
|
|
152
|
-
(
|
|
151
|
+
o = !0;
|
|
152
|
+
(c === 10 || r === l - 1) && (c !== 10 && r++, this.bMarks.push(D), this.eMarks.push(r), this.tShift.push(n), this.sCount.push(i), this.bsCount.push(0), o = !1, n = 0, i = 0, D = r + 1);
|
|
153
153
|
}
|
|
154
|
-
this.bMarks.push(
|
|
154
|
+
this.bMarks.push(a.length), this.eMarks.push(a.length), this.tShift.push(0), this.sCount.push(0), this.bsCount.push(0), this.lineMax = this.bMarks.length - 1;
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
const s = new
|
|
156
|
+
x.prototype.push = function(u, t, e) {
|
|
157
|
+
const s = new p(u, t, e);
|
|
158
158
|
return s.block = !0, e < 0 && this.level--, s.level = this.level, e > 0 && this.level++, this.tokens.push(s), s;
|
|
159
159
|
};
|
|
160
|
-
|
|
161
|
-
return this.bMarks[
|
|
160
|
+
x.prototype.isEmpty = function(t) {
|
|
161
|
+
return this.bMarks[t] + this.tShift[t] >= this.eMarks[t];
|
|
162
162
|
};
|
|
163
|
-
|
|
164
|
-
for (let e = this.lineMax;
|
|
163
|
+
x.prototype.skipEmptyLines = function(t) {
|
|
164
|
+
for (let e = this.lineMax; t < e && !(this.bMarks[t] + this.tShift[t] < this.eMarks[t]); t++)
|
|
165
165
|
;
|
|
166
|
-
return
|
|
166
|
+
return t;
|
|
167
167
|
};
|
|
168
|
-
|
|
169
|
-
for (let e = this.src.length;
|
|
170
|
-
const s = this.src.charCodeAt(
|
|
171
|
-
if (!
|
|
168
|
+
x.prototype.skipSpaces = function(t) {
|
|
169
|
+
for (let e = this.src.length; t < e; t++) {
|
|
170
|
+
const s = this.src.charCodeAt(t);
|
|
171
|
+
if (!P(s))
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
|
-
return
|
|
174
|
+
return t;
|
|
175
175
|
};
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
return
|
|
179
|
-
for (;
|
|
180
|
-
if (!
|
|
181
|
-
return
|
|
182
|
-
return
|
|
176
|
+
x.prototype.skipSpacesBack = function(t, e) {
|
|
177
|
+
if (t <= e)
|
|
178
|
+
return t;
|
|
179
|
+
for (; t > e; )
|
|
180
|
+
if (!P(this.src.charCodeAt(--t)))
|
|
181
|
+
return t + 1;
|
|
182
|
+
return t;
|
|
183
183
|
};
|
|
184
|
-
|
|
185
|
-
for (let s = this.src.length;
|
|
184
|
+
x.prototype.skipChars = function(t, e) {
|
|
185
|
+
for (let s = this.src.length; t < s && this.src.charCodeAt(t) === e; t++)
|
|
186
186
|
;
|
|
187
|
-
return
|
|
187
|
+
return t;
|
|
188
188
|
};
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
return
|
|
192
|
-
for (;
|
|
193
|
-
if (e !== this.src.charCodeAt(--
|
|
194
|
-
return
|
|
195
|
-
return
|
|
189
|
+
x.prototype.skipCharsBack = function(t, e, s) {
|
|
190
|
+
if (t <= s)
|
|
191
|
+
return t;
|
|
192
|
+
for (; t > s; )
|
|
193
|
+
if (e !== this.src.charCodeAt(--t))
|
|
194
|
+
return t + 1;
|
|
195
|
+
return t;
|
|
196
196
|
};
|
|
197
|
-
|
|
198
|
-
if (
|
|
197
|
+
x.prototype.getLines = function(t, e, s, a) {
|
|
198
|
+
if (t >= e)
|
|
199
199
|
return "";
|
|
200
|
-
const D = new Array(e -
|
|
201
|
-
for (let
|
|
202
|
-
let
|
|
203
|
-
const
|
|
204
|
-
let
|
|
205
|
-
for (
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
else if (
|
|
210
|
-
|
|
200
|
+
const D = new Array(e - t);
|
|
201
|
+
for (let r = 0, n = t; n < e; n++, r++) {
|
|
202
|
+
let i = 0;
|
|
203
|
+
const l = this.bMarks[n];
|
|
204
|
+
let o = l, c;
|
|
205
|
+
for (n + 1 < e || a ? c = this.eMarks[n] + 1 : c = this.eMarks[n]; o < c && i < s; ) {
|
|
206
|
+
const F = this.src.charCodeAt(o);
|
|
207
|
+
if (P(F))
|
|
208
|
+
F === 9 ? i += 4 - (i + this.bsCount[n]) % 4 : i++;
|
|
209
|
+
else if (o - l < this.tShift[n])
|
|
210
|
+
i++;
|
|
211
211
|
else
|
|
212
212
|
break;
|
|
213
|
-
|
|
213
|
+
o++;
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
i > s ? D[r] = new Array(i - s + 1).join(" ") + this.src.slice(o, c) : D[r] = this.src.slice(o, c);
|
|
216
216
|
}
|
|
217
217
|
return D.join("");
|
|
218
218
|
};
|
|
219
|
-
|
|
220
|
-
const
|
|
219
|
+
x.prototype.Token = p;
|
|
220
|
+
const ut = [
|
|
221
221
|
"address",
|
|
222
222
|
"article",
|
|
223
223
|
"aside",
|
|
@@ -280,91 +280,91 @@ const j = [
|
|
|
280
280
|
"tr",
|
|
281
281
|
"track",
|
|
282
282
|
"ul"
|
|
283
|
-
],
|
|
284
|
-
new RegExp("^</?(" +
|
|
285
|
-
function
|
|
286
|
-
this.src =
|
|
283
|
+
], et = "[a-zA-Z_:][a-zA-Z0-9:._-]*", st = "[^\"'=<>`\\x00-\\x20]+", rt = "'[^']*'", it = '"[^"]*"', nt = "(?:" + st + "|" + rt + "|" + it + ")", at = "(?:\\s+" + et + "(?:\\s*=\\s*" + nt + ")?)", ot = "<[A-Za-z][A-Za-z0-9\\-]*" + at + "*\\s*\\/?>", ct = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>", Dt = new RegExp("^(?:" + ot + "|" + ct + ")");
|
|
284
|
+
new RegExp("^</?(" + ut.join("|") + ")(?=(\\s|/?>|$))", "i"), new RegExp(Dt.source + "\\s*$");
|
|
285
|
+
function _(u, t, e, s) {
|
|
286
|
+
this.src = u, this.env = e, this.md = t, this.tokens = s, this.tokens_meta = Array(s.length), this.pos = 0, this.posMax = this.src.length, this.level = 0, this.pending = "", this.pendingLevel = 0, this.cache = {}, this.delimiters = [], this._prev_delimiters = [], this.backticks = {}, this.backticksScanned = !1, this.linkLevel = 0;
|
|
287
287
|
}
|
|
288
|
-
|
|
289
|
-
const
|
|
290
|
-
return
|
|
288
|
+
_.prototype.pushPending = function() {
|
|
289
|
+
const u = new p("text", "", 0);
|
|
290
|
+
return u.content = this.pending, u.level = this.pendingLevel, this.tokens.push(u), this.pending = "", u;
|
|
291
291
|
};
|
|
292
|
-
|
|
292
|
+
_.prototype.push = function(u, t, e) {
|
|
293
293
|
this.pending && this.pushPending();
|
|
294
|
-
const s = new
|
|
295
|
-
let
|
|
296
|
-
return e < 0 && (this.level--, this.delimiters = this._prev_delimiters.pop()), s.level = this.level, e > 0 && (this.level++, this._prev_delimiters.push(this.delimiters), this.delimiters = [],
|
|
294
|
+
const s = new p(u, t, e);
|
|
295
|
+
let a = null;
|
|
296
|
+
return e < 0 && (this.level--, this.delimiters = this._prev_delimiters.pop()), s.level = this.level, e > 0 && (this.level++, this._prev_delimiters.push(this.delimiters), this.delimiters = [], a = { delimiters: this.delimiters }), this.pendingLevel = this.level, this.tokens.push(s), this.tokens_meta.push(a), s;
|
|
297
297
|
};
|
|
298
|
-
|
|
299
|
-
const e = this.posMax, s = this.src.charCodeAt(
|
|
300
|
-
let D =
|
|
298
|
+
_.prototype.scanDelims = function(u, t) {
|
|
299
|
+
const e = this.posMax, s = this.src.charCodeAt(u), a = u > 0 ? this.src.charCodeAt(u - 1) : 32;
|
|
300
|
+
let D = u;
|
|
301
301
|
for (; D < e && this.src.charCodeAt(D) === s; )
|
|
302
302
|
D++;
|
|
303
|
-
const
|
|
304
|
-
return { can_open:
|
|
303
|
+
const r = D - u, n = D < e ? this.src.charCodeAt(D) : 32, i = q(a) || R(String.fromCharCode(a)), l = q(n) || R(String.fromCharCode(n)), o = W(a), c = W(n), F = !c && (!l || o || i), h = !o && (!i || c || l);
|
|
304
|
+
return { can_open: F && (t || !h || i), can_close: h && (t || !F || l), length: r };
|
|
305
305
|
};
|
|
306
|
-
|
|
307
|
-
const
|
|
308
|
-
for (let
|
|
309
|
-
|
|
310
|
-
"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(
|
|
311
|
-
|
|
306
|
+
_.prototype.Token = p;
|
|
307
|
+
const U = [];
|
|
308
|
+
for (let u = 0; u < 256; u++)
|
|
309
|
+
U.push(0);
|
|
310
|
+
"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(u) {
|
|
311
|
+
U[u.charCodeAt(0)] = 1;
|
|
312
312
|
});
|
|
313
|
-
function
|
|
314
|
-
var s,
|
|
315
|
-
const e = t
|
|
313
|
+
function j(u, t) {
|
|
314
|
+
var s, a;
|
|
315
|
+
const e = u[t + 1];
|
|
316
316
|
if (e && e.type === "html_block") {
|
|
317
317
|
const D = e.content.match(
|
|
318
318
|
/<!--\s*diagram(?:\s+id="([^"]+)")?/
|
|
319
|
-
),
|
|
319
|
+
), r = e.content.match(/\s+caption="([^"]+)"/);
|
|
320
320
|
return {
|
|
321
321
|
id: (s = D == null ? void 0 : D[1]) == null ? void 0 : s.trim(),
|
|
322
|
-
caption: ((
|
|
322
|
+
caption: ((a = r == null ? void 0 : r[1]) == null ? void 0 : a.trim()) || ""
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
325
|
return { caption: "", id: void 0 };
|
|
326
326
|
}
|
|
327
|
-
function
|
|
328
|
-
const D =
|
|
329
|
-
return e ? `${
|
|
327
|
+
function N(u, t, e, s, a) {
|
|
328
|
+
const D = a !== void 0 ? `${t}${a}` : t, r = G.createHash("md5").update(D).digest("hex");
|
|
329
|
+
return e ? `${u}-${e}-${r}.svg` : s ? `${u}-${s}-${r}.svg` : `${u}-${r}.svg`;
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function Z(u) {
|
|
332
332
|
var e;
|
|
333
|
-
const
|
|
334
|
-
return
|
|
333
|
+
const t = ((e = v == null ? void 0 : v.cwd) == null ? void 0 : e.call(v)) || v.env.PWD || v.env.INIT_CWD || ".";
|
|
334
|
+
return u ? d.resolve(t, u) : d.resolve(t, "docs/public/diagrams");
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function H(u, t, e, s, a, D) {
|
|
337
337
|
try {
|
|
338
|
-
const
|
|
339
|
-
let
|
|
338
|
+
const r = E.readdirSync(u);
|
|
339
|
+
let n = [];
|
|
340
340
|
if (e)
|
|
341
|
-
|
|
342
|
-
(
|
|
341
|
+
n = r.filter(
|
|
342
|
+
(i) => i.startsWith(`${t}-${e}-`) && i !== s
|
|
343
343
|
);
|
|
344
344
|
else if (D)
|
|
345
|
-
|
|
346
|
-
(
|
|
345
|
+
n = r.filter(
|
|
346
|
+
(i) => i.startsWith(`${t}-${D}-`) && i !== s
|
|
347
347
|
);
|
|
348
|
-
else if (
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
(
|
|
352
|
-
if (!
|
|
348
|
+
else if (a) {
|
|
349
|
+
const i = G.createHash("md5").update(a).digest("hex"), l = `${t}-${i}.svg`;
|
|
350
|
+
n = r.filter(
|
|
351
|
+
(o) => {
|
|
352
|
+
if (!o.startsWith(`${t}-`) || !o.endsWith(".svg") || o === s || o === l)
|
|
353
353
|
return !1;
|
|
354
|
-
const
|
|
355
|
-
return
|
|
354
|
+
const F = o.slice(0, -4).split("-");
|
|
355
|
+
return F.length === 2 && F[0] === t;
|
|
356
356
|
}
|
|
357
357
|
);
|
|
358
358
|
}
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
E.existsSync(
|
|
359
|
+
n.forEach((i) => {
|
|
360
|
+
const l = d.join(u, i);
|
|
361
|
+
E.existsSync(l) && (E.unlinkSync(l), console.log(`Removed old diagram file: ${i}`));
|
|
362
362
|
});
|
|
363
|
-
} catch (
|
|
364
|
-
console.warn(`Failed to remove old diagram files: ${
|
|
363
|
+
} catch (r) {
|
|
364
|
+
console.warn(`Failed to remove old diagram files: ${r}`);
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
-
const
|
|
367
|
+
const lt = [
|
|
368
368
|
".exe",
|
|
369
369
|
".bat",
|
|
370
370
|
".cmd",
|
|
@@ -392,115 +392,275 @@ const tu = [
|
|
|
392
392
|
".reg",
|
|
393
393
|
".lnk"
|
|
394
394
|
];
|
|
395
|
-
function
|
|
396
|
-
const
|
|
397
|
-
return
|
|
395
|
+
function Ft(u) {
|
|
396
|
+
const t = d.extname(u).toLowerCase();
|
|
397
|
+
return lt.includes(t);
|
|
398
398
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
399
|
+
function O(u) {
|
|
400
|
+
return u.trim().startsWith("@file:");
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
const
|
|
404
|
-
return
|
|
402
|
+
function T(u) {
|
|
403
|
+
const t = u.trim();
|
|
404
|
+
return t.startsWith("@file:") && t.split(`
|
|
405
405
|
`)[0].slice(6).trim() || null;
|
|
406
406
|
}
|
|
407
|
-
function
|
|
408
|
-
if (
|
|
409
|
-
return
|
|
410
|
-
const e =
|
|
411
|
-
return
|
|
407
|
+
function J(u, t) {
|
|
408
|
+
if (u.startsWith("/"))
|
|
409
|
+
return u;
|
|
410
|
+
const e = d.dirname(t);
|
|
411
|
+
return d.resolve(e, u);
|
|
412
412
|
}
|
|
413
|
-
function
|
|
414
|
-
if (!
|
|
413
|
+
function K(u, t) {
|
|
414
|
+
if (!t || t.length === 0)
|
|
415
415
|
return !0;
|
|
416
416
|
try {
|
|
417
|
-
const e = E.realpathSync(
|
|
418
|
-
for (const s of
|
|
419
|
-
const
|
|
420
|
-
if (e.startsWith(D +
|
|
417
|
+
const e = E.realpathSync(d.resolve(u));
|
|
418
|
+
for (const s of t) {
|
|
419
|
+
const a = d.resolve(s), D = E.realpathSync(a);
|
|
420
|
+
if (e.startsWith(D + d.sep) || e === D)
|
|
421
421
|
return !0;
|
|
422
422
|
}
|
|
423
423
|
} catch {
|
|
424
|
-
const s =
|
|
425
|
-
for (const
|
|
426
|
-
const D =
|
|
427
|
-
if (s.startsWith(D +
|
|
424
|
+
const s = d.resolve(u);
|
|
425
|
+
for (const a of t) {
|
|
426
|
+
const D = d.resolve(a);
|
|
427
|
+
if (s.startsWith(D + d.sep) || s === D)
|
|
428
428
|
return !0;
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
return !1;
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function X(u) {
|
|
434
434
|
try {
|
|
435
|
-
if (
|
|
436
|
-
throw new Error(`File extension not allowed: ${
|
|
437
|
-
const
|
|
438
|
-
if (!
|
|
439
|
-
throw new Error(`Path is not a file: ${
|
|
440
|
-
const e = E.realpathSync(
|
|
435
|
+
if (Ft(u))
|
|
436
|
+
throw new Error(`File extension not allowed: ${d.extname(u)}`);
|
|
437
|
+
const t = E.statSync(u);
|
|
438
|
+
if (!t.isFile())
|
|
439
|
+
throw new Error(`Path is not a file: ${u}`);
|
|
440
|
+
const e = E.realpathSync(u);
|
|
441
441
|
return {
|
|
442
442
|
content: E.readFileSync(e, "utf-8"),
|
|
443
443
|
filePath: e,
|
|
444
|
-
mtime:
|
|
444
|
+
mtime: t.mtimeMs
|
|
445
445
|
};
|
|
446
|
-
} catch (
|
|
447
|
-
const e =
|
|
446
|
+
} catch (t) {
|
|
447
|
+
const e = t instanceof Error ? t.message : String(t);
|
|
448
448
|
throw new Error(`Failed to read file import: ${e}`);
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
function
|
|
451
|
+
function dt(u = {}) {
|
|
452
|
+
const t = [];
|
|
453
|
+
function e(r) {
|
|
454
|
+
const n = r.renderer.rules.fence;
|
|
455
|
+
r.renderer.rules.fence = (i, l, o, c, F) => {
|
|
456
|
+
const h = i[l], m = h.info.trim().toLowerCase(), f = u.excludedDiagramTypes ?? [], A = b.includes(m), C = f.includes(m);
|
|
457
|
+
if (A && !C) {
|
|
458
|
+
let B = h.content.trim();
|
|
459
|
+
const { caption: M, id: g } = j(i, l), w = u.enableFileImports ?? !0;
|
|
460
|
+
let $;
|
|
461
|
+
if (w && O(B))
|
|
462
|
+
try {
|
|
463
|
+
const k = T(B);
|
|
464
|
+
if (k) {
|
|
465
|
+
const y = (c == null ? void 0 : c.path) || "";
|
|
466
|
+
if (!y)
|
|
467
|
+
return '<div class="diagram-error">Cannot resolve file import: markdown file path is not available</div>';
|
|
468
|
+
const I = J(k, y), Y = u.allowedImportDirs;
|
|
469
|
+
if (!K(I, Y))
|
|
470
|
+
return `<div class="diagram-error">File import not allowed: ${k}. Path is outside allowed directories.</div>`;
|
|
471
|
+
const z = X(I);
|
|
472
|
+
B = z.content, $ = z.mtime;
|
|
473
|
+
}
|
|
474
|
+
} catch (k) {
|
|
475
|
+
const y = k instanceof Error ? k.message : String(k);
|
|
476
|
+
return `<div class="diagram-error">Error loading diagram file in ${(c == null ? void 0 : c.path) || "unknown"}: ${y}</div>`;
|
|
477
|
+
}
|
|
478
|
+
const L = (c == null ? void 0 : c.path) || "unknown", S = `${d.basename(L, ".md")}-${l}`;
|
|
479
|
+
return s(
|
|
480
|
+
B,
|
|
481
|
+
m,
|
|
482
|
+
M,
|
|
483
|
+
g,
|
|
484
|
+
S,
|
|
485
|
+
$
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
return n(i, l, o, c, F);
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
function s(r, n, i, l, o, c) {
|
|
492
|
+
try {
|
|
493
|
+
const F = r.replaceAll(`\r
|
|
494
|
+
`, `
|
|
495
|
+
`);
|
|
496
|
+
if (!b.includes(n))
|
|
497
|
+
throw new Error(`Unsupported diagram type: ${n}`);
|
|
498
|
+
const h = Z(u.diagramsDir);
|
|
499
|
+
E.mkdirSync(h, { recursive: !0 });
|
|
500
|
+
const m = N(
|
|
501
|
+
n,
|
|
502
|
+
F,
|
|
503
|
+
l,
|
|
504
|
+
o,
|
|
505
|
+
c
|
|
506
|
+
), f = d.join(h, m);
|
|
507
|
+
!E.existsSync(f) && !t.some((B) => B.filepath === f) && t.push(
|
|
508
|
+
a(
|
|
509
|
+
n,
|
|
510
|
+
h,
|
|
511
|
+
F,
|
|
512
|
+
m,
|
|
513
|
+
f,
|
|
514
|
+
l,
|
|
515
|
+
o
|
|
516
|
+
)
|
|
517
|
+
);
|
|
518
|
+
const C = u.publicPath ?? "/diagrams";
|
|
519
|
+
return `<figure
|
|
520
|
+
class="vpd-diagram vpd-diagram--${n}"
|
|
521
|
+
onclick="
|
|
522
|
+
const figure = this;
|
|
523
|
+
const isFullscreen = figure.classList.contains('vpd-diagram--fullscreen');
|
|
524
|
+
|
|
525
|
+
document.querySelectorAll('.vpd-diagram').forEach(diagram => {
|
|
526
|
+
diagram.classList.remove('vpd-diagram--fullscreen');
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
if (!isFullscreen) {
|
|
530
|
+
figure.classList.add('vpd-diagram--fullscreen');
|
|
531
|
+
}
|
|
532
|
+
"
|
|
533
|
+
>
|
|
534
|
+
<img
|
|
535
|
+
:src="\`${C}/${m}\`"
|
|
536
|
+
alt="${n} Diagram"
|
|
537
|
+
class="vpd-diagram-image"
|
|
538
|
+
/>
|
|
539
|
+
${i ? `<figcaption class="vpd-diagram-caption">
|
|
540
|
+
${i}
|
|
541
|
+
</figcaption>` : ""}
|
|
542
|
+
</figure>`;
|
|
543
|
+
} catch (F) {
|
|
544
|
+
const h = F instanceof Error ? F.message : String(F);
|
|
545
|
+
return console.error(`Error converting ${n} diagram:`, h), `<div class="diagram-error">Error converting diagram: ${h}</div>`;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function a(r, n, i, l, o, c, F) {
|
|
549
|
+
const h = u.krokiServerUrl ?? "https://kroki.io", m = u.diagramsDistDir;
|
|
550
|
+
return {
|
|
551
|
+
filepath: o,
|
|
552
|
+
getDiagram: async () => {
|
|
553
|
+
const f = await fetch(`${h}/${r}`, {
|
|
554
|
+
method: "POST",
|
|
555
|
+
headers: {
|
|
556
|
+
Accept: "image/svg+xml",
|
|
557
|
+
"Content-Type": "text/plain"
|
|
558
|
+
},
|
|
559
|
+
body: i
|
|
560
|
+
});
|
|
561
|
+
if (!f.ok)
|
|
562
|
+
throw new Error(
|
|
563
|
+
`Kroki returned ${f.status} for ${r} diagram (${o}): ${await f.text()}`
|
|
564
|
+
);
|
|
565
|
+
const A = await f.text();
|
|
566
|
+
if (H(
|
|
567
|
+
n,
|
|
568
|
+
r,
|
|
569
|
+
c,
|
|
570
|
+
l,
|
|
571
|
+
i,
|
|
572
|
+
F
|
|
573
|
+
), E.writeFileSync(o, A), console.log(`✓ Generated diagram: ${o}`), m)
|
|
574
|
+
return {
|
|
575
|
+
type: "asset",
|
|
576
|
+
fileName: `${m}/${l}`,
|
|
577
|
+
source: A
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
function D() {
|
|
583
|
+
return {
|
|
584
|
+
name: "vitepress-build-time-diagrams",
|
|
585
|
+
// Dev mode: generate diagrams before serving the page
|
|
586
|
+
configureServer(r) {
|
|
587
|
+
r.middlewares.use(async (n, i, l) => {
|
|
588
|
+
const o = t.splice(0);
|
|
589
|
+
o.length > 0 && await Promise.all(o.map((c) => c.getDiagram())), l();
|
|
590
|
+
});
|
|
591
|
+
},
|
|
592
|
+
// Build mode: generate all diagrams and emit assets
|
|
593
|
+
async generateBundle() {
|
|
594
|
+
const r = t.splice(0);
|
|
595
|
+
r.length !== 0 && (console.log(`
|
|
596
|
+
Generating ${r.length} diagram(s) at build time...`), await Promise.all(
|
|
597
|
+
r.map(async (n) => {
|
|
598
|
+
const i = await n.getDiagram();
|
|
599
|
+
i && this.emitFile(i);
|
|
600
|
+
})
|
|
601
|
+
), console.log(`✓ All diagrams generated successfully.
|
|
602
|
+
`));
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
return {
|
|
607
|
+
configureMarkdown: e,
|
|
608
|
+
vitePlugin: D
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function ht(u, t, e, s, a = {}, D, r) {
|
|
452
612
|
try {
|
|
453
|
-
const
|
|
613
|
+
const n = u.replaceAll(`\r
|
|
454
614
|
`, `
|
|
455
615
|
`);
|
|
456
|
-
if (!
|
|
457
|
-
throw new Error(`Unsupported diagram type: ${
|
|
458
|
-
const
|
|
459
|
-
|
|
616
|
+
if (!b.includes(t))
|
|
617
|
+
throw new Error(`Unsupported diagram type: ${t}`);
|
|
618
|
+
const i = Z(
|
|
619
|
+
a.diagramsDir
|
|
460
620
|
);
|
|
461
|
-
E.mkdirSync(
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
621
|
+
E.mkdirSync(i, { recursive: !0 });
|
|
622
|
+
const l = N(
|
|
623
|
+
t,
|
|
624
|
+
n,
|
|
465
625
|
s,
|
|
466
626
|
D,
|
|
467
|
-
|
|
468
|
-
),
|
|
469
|
-
let
|
|
470
|
-
if (
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
627
|
+
r
|
|
628
|
+
), o = d.join(i, l), c = E.existsSync(o);
|
|
629
|
+
let F = !1;
|
|
630
|
+
if (c && (F = E.readFileSync(o, "utf-8").includes("<!-- vpd-placeholder -->")), !c || F) {
|
|
631
|
+
H(
|
|
632
|
+
i,
|
|
633
|
+
t,
|
|
474
634
|
s,
|
|
475
|
-
|
|
476
|
-
|
|
635
|
+
l,
|
|
636
|
+
n,
|
|
477
637
|
D
|
|
478
638
|
);
|
|
479
|
-
const
|
|
639
|
+
const f = `<?xml version="1.0" encoding="UTF-8"?>
|
|
480
640
|
<svg width="100%" height="120" xmlns="http://www.w3.org/2000/svg">
|
|
481
641
|
<!-- vpd-placeholder -->
|
|
482
642
|
<rect width="100%" height="120" fill="#f5f5f5"/>
|
|
483
643
|
<text x="50%" y="45%" font-family="system-ui" font-size="14" fill="#666" text-anchor="middle" dominant-baseline="middle">
|
|
484
|
-
Generating ${
|
|
644
|
+
Generating ${t} diagram...
|
|
485
645
|
</text>
|
|
486
646
|
<text x="50%" y="65%" font-family="system-ui" font-size="14" fill="#666" text-anchor="middle" dominant-baseline="middle">
|
|
487
647
|
Refresh the page.
|
|
488
648
|
</text>
|
|
489
649
|
</svg>`;
|
|
490
|
-
E.writeFileSync(
|
|
491
|
-
const
|
|
492
|
-
fetch(`${
|
|
650
|
+
E.writeFileSync(o, f);
|
|
651
|
+
const A = a.krokiServerUrl ?? "https://kroki.io";
|
|
652
|
+
fetch(`${A}/${t}`, {
|
|
493
653
|
method: "POST",
|
|
494
654
|
headers: {
|
|
495
655
|
Accept: "image/svg+xml",
|
|
496
656
|
"Content-Type": "text/plain"
|
|
497
657
|
},
|
|
498
|
-
body:
|
|
499
|
-
}).then((
|
|
658
|
+
body: n
|
|
659
|
+
}).then((C) => C.text()).then((C) => (E.writeFileSync(o, C), C));
|
|
500
660
|
}
|
|
501
|
-
const
|
|
661
|
+
const m = a.publicPath ?? "/diagrams";
|
|
502
662
|
return `<figure
|
|
503
|
-
class="vpd-diagram vpd-diagram--${
|
|
663
|
+
class="vpd-diagram vpd-diagram--${t}"
|
|
504
664
|
onclick="
|
|
505
665
|
const figure = this;
|
|
506
666
|
const isFullscreen = figure.classList.contains('vpd-diagram--fullscreen');
|
|
@@ -515,68 +675,69 @@ function ou(t, u, e, s, r = {}, D, i) {
|
|
|
515
675
|
"
|
|
516
676
|
>
|
|
517
677
|
<img
|
|
518
|
-
:src="\`${
|
|
519
|
-
alt="${
|
|
678
|
+
:src="\`${m}/${l}\`"
|
|
679
|
+
alt="${t} Diagram"
|
|
520
680
|
class="vpd-diagram-image"
|
|
521
681
|
/>
|
|
522
682
|
${e ? `<figcaption class="vpd-diagram-caption">
|
|
523
683
|
${e}
|
|
524
684
|
</figcaption>` : ""}
|
|
525
685
|
</figure>`;
|
|
526
|
-
} catch (
|
|
527
|
-
const
|
|
528
|
-
return console.error(`Error converting ${
|
|
686
|
+
} catch (n) {
|
|
687
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
688
|
+
return console.error(`Error converting ${t} diagram:`, i), `<div class="diagram-error">Error converting diagram: ${i}</div>`;
|
|
529
689
|
}
|
|
530
690
|
}
|
|
531
|
-
function
|
|
532
|
-
const e =
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
536
|
-
let
|
|
537
|
-
const { caption:
|
|
538
|
-
let
|
|
539
|
-
if (
|
|
691
|
+
function ft(u, t = {}) {
|
|
692
|
+
const e = u.renderer.rules.fence;
|
|
693
|
+
u.renderer.rules.fence = (s, a, D, r, n) => {
|
|
694
|
+
const i = s[a], l = i.info.trim().toLowerCase(), o = t.excludedDiagramTypes ?? [], c = b.includes(l), F = o.includes(l);
|
|
695
|
+
if (c && !F) {
|
|
696
|
+
let h = i.content.trim();
|
|
697
|
+
const { caption: m, id: f } = j(s, a), A = t.enableFileImports ?? !0;
|
|
698
|
+
let C;
|
|
699
|
+
if (A && O(h))
|
|
540
700
|
try {
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
543
|
-
const
|
|
544
|
-
if (!
|
|
701
|
+
const g = T(h);
|
|
702
|
+
if (g) {
|
|
703
|
+
const w = (r == null ? void 0 : r.path) || "";
|
|
704
|
+
if (!w)
|
|
545
705
|
return '<div class="diagram-error">Cannot resolve file import: markdown file path is not available</div>';
|
|
546
|
-
const
|
|
547
|
-
if (!
|
|
548
|
-
return `<div class="diagram-error">File import not allowed: ${
|
|
549
|
-
const
|
|
550
|
-
|
|
706
|
+
const $ = J(g, w), L = t.allowedImportDirs;
|
|
707
|
+
if (!K($, L))
|
|
708
|
+
return `<div class="diagram-error">File import not allowed: ${g}. Path is outside allowed directories.</div>`;
|
|
709
|
+
const S = X($);
|
|
710
|
+
h = S.content, C = S.mtime;
|
|
551
711
|
}
|
|
552
|
-
} catch (
|
|
553
|
-
const
|
|
554
|
-
return `<div class="diagram-error">Error loading diagram file in ${(
|
|
712
|
+
} catch (g) {
|
|
713
|
+
const w = g instanceof Error ? g.message : String(g);
|
|
714
|
+
return `<div class="diagram-error">Error loading diagram file in ${(r == null ? void 0 : r.path) || "unknown"}: ${w}</div>`;
|
|
555
715
|
}
|
|
556
|
-
const
|
|
557
|
-
return
|
|
716
|
+
const B = (r == null ? void 0 : r.path) || "unknown", M = `${d.basename(B, ".md")}-${a}`;
|
|
717
|
+
return ht(
|
|
718
|
+
h,
|
|
719
|
+
l,
|
|
720
|
+
m,
|
|
558
721
|
f,
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
u,
|
|
563
|
-
z,
|
|
564
|
-
A
|
|
722
|
+
t,
|
|
723
|
+
M,
|
|
724
|
+
C
|
|
565
725
|
);
|
|
566
726
|
}
|
|
567
|
-
return e(s,
|
|
727
|
+
return e(s, a, D, r, n);
|
|
568
728
|
};
|
|
569
729
|
}
|
|
570
730
|
export {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
731
|
+
b as SUPPORTED_DIAGRAM_TYPES,
|
|
732
|
+
ft as configureDiagramsPlugin,
|
|
733
|
+
dt as createBuildTimeDiagramsPlugin,
|
|
734
|
+
ht as diagramToSvg,
|
|
735
|
+
N as generateUniqueFilename,
|
|
736
|
+
Ft as hasDangerousExtension,
|
|
737
|
+
O as isFileImportSyntax,
|
|
738
|
+
T as parseFileImportPath,
|
|
739
|
+
X as readFileImport,
|
|
740
|
+
H as removeOldDiagramFiles,
|
|
741
|
+
J as resolveFileImportPath,
|
|
742
|
+
K as validateFileImportPath
|
|
582
743
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -36,6 +36,31 @@ export interface DiagramPluginOptions {
|
|
|
36
36
|
*/
|
|
37
37
|
allowedImportDirs?: string[];
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Options for build-time diagram generation.
|
|
41
|
+
* Extends the standard plugin options with build-specific settings.
|
|
42
|
+
* Used with `createBuildTimeDiagramsPlugin()`.
|
|
43
|
+
*/
|
|
44
|
+
export interface BuildTimeDiagramPluginOptions extends DiagramPluginOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Directory name where SVG files are emitted in the build output.
|
|
47
|
+
* This is relative to the Vite/Rollup output directory.
|
|
48
|
+
* @example "diagrams"
|
|
49
|
+
*/
|
|
50
|
+
diagramsDistDir?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A deferred diagram generation call, used internally by the build-time plugin.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export interface DeferredDiagramCall {
|
|
57
|
+
filepath: string;
|
|
58
|
+
getDiagram: () => Promise<void | {
|
|
59
|
+
type: 'asset';
|
|
60
|
+
fileName: string;
|
|
61
|
+
source: string;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
39
64
|
/**
|
|
40
65
|
* Extracted diagram metadata from markdown tokens
|
|
41
66
|
*/
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress-plugin-diagrams",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "VitePress plugin for generating diagrams from text (PlantUML, Mermaid, etc.)",
|
|
5
5
|
"author": "Ruslan Makarov <ruslan.makarov@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/vuesence/vitepress-plugin-diagrams.git"
|
|
10
10
|
},
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/
|
|
12
|
+
"url": "https://github.com/vuesence/vitepress-plugin-diagrams/issues"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/
|
|
14
|
+
"homepage": "https://github.com/vuesence/vitepress-plugin-diagrams",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"main": "./dist/index.cjs",
|
|
17
17
|
"module": "./dist/index.js",
|
|
@@ -35,8 +35,9 @@
|
|
|
35
35
|
],
|
|
36
36
|
"bin": "bin/cli.js",
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"commander": "^14.0.0",
|
|
38
39
|
"markdown-it": "^14.1.0",
|
|
39
|
-
"
|
|
40
|
+
"rimraf": "^6.1.3"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@sxzz/eslint-config": "^4.6.0",
|