@vuepress/plugin-markdown-chart 2.0.0-rc.123 → 2.0.0-rc.125

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.
Files changed (60) hide show
  1. package/dist/client/components/ChartJS.d.ts +59 -0
  2. package/dist/client/components/ChartJS.js +9 -0
  3. package/dist/client/components/ChartJS.js.map +1 -0
  4. package/dist/client/components/ECharts.d.ts +59 -0
  5. package/dist/client/components/ECharts.js +9 -0
  6. package/dist/client/components/ECharts.js.map +1 -0
  7. package/dist/client/components/FlowChart.d.ts +47 -0
  8. package/dist/client/components/FlowChart.js +2 -0
  9. package/dist/client/components/FlowChart.js.map +1 -0
  10. package/dist/client/components/MarkMap.d.ts +27 -0
  11. package/dist/client/components/MarkMap.js +2 -0
  12. package/dist/client/components/MarkMap.js.map +1 -0
  13. package/dist/client/components/Mermaid.d.ts +39 -0
  14. package/dist/client/components/Mermaid.js +2 -0
  15. package/dist/client/components/Mermaid.js.map +1 -0
  16. package/dist/client/index.d.ts +166 -0
  17. package/dist/client/index.js +1 -0
  18. package/dist/echarts-C9C0qkV9.js +2 -0
  19. package/dist/echarts-C9C0qkV9.js.map +1 -0
  20. package/dist/mermaid-mwYgrO0I.js +2 -0
  21. package/dist/mermaid-mwYgrO0I.js.map +1 -0
  22. package/dist/node/index.d.ts +247 -0
  23. package/dist/node/index.js +33 -0
  24. package/dist/node/index.js.map +1 -0
  25. package/package.json +19 -12
  26. package/lib/client/components/ChartJS.d.ts +0 -58
  27. package/lib/client/components/ChartJS.js +0 -7
  28. package/lib/client/components/ChartJS.js.map +0 -1
  29. package/lib/client/components/ECharts.d.ts +0 -58
  30. package/lib/client/components/ECharts.js +0 -8
  31. package/lib/client/components/ECharts.js.map +0 -1
  32. package/lib/client/components/FlowChart.d.ts +0 -46
  33. package/lib/client/components/FlowChart.js +0 -2
  34. package/lib/client/components/FlowChart.js.map +0 -1
  35. package/lib/client/components/MarkMap.d.ts +0 -26
  36. package/lib/client/components/MarkMap.js +0 -2
  37. package/lib/client/components/MarkMap.js.map +0 -1
  38. package/lib/client/components/Mermaid.d.ts +0 -38
  39. package/lib/client/components/Mermaid.js +0 -2
  40. package/lib/client/components/Mermaid.js.map +0 -1
  41. package/lib/client/echarts-C40_Ts42.js +0 -2
  42. package/lib/client/echarts-C40_Ts42.js.map +0 -1
  43. package/lib/client/index.d.ts +0 -163
  44. package/lib/client/index.js +0 -2
  45. package/lib/client/index.js.map +0 -1
  46. package/lib/client/mermaid-D26-9yYy.js +0 -2
  47. package/lib/client/mermaid-D26-9yYy.js.map +0 -1
  48. package/lib/node/index.d.ts +0 -234
  49. package/lib/node/index.js +0 -25
  50. package/lib/node/index.js.map +0 -1
  51. /package/{lib → dist}/client/styles/chartjs.css +0 -0
  52. /package/{lib → dist}/client/styles/chartjs.css.map +0 -0
  53. /package/{lib → dist}/client/styles/echarts.css +0 -0
  54. /package/{lib → dist}/client/styles/echarts.css.map +0 -0
  55. /package/{lib → dist}/client/styles/flowchart.css +0 -0
  56. /package/{lib → dist}/client/styles/flowchart.css.map +0 -0
  57. /package/{lib → dist}/client/styles/markmap.css +0 -0
  58. /package/{lib → dist}/client/styles/markmap.css.map +0 -0
  59. /package/{lib → dist}/client/styles/mermaid.css +0 -0
  60. /package/{lib → dist}/client/styles/mermaid.css.map +0 -0
@@ -0,0 +1,247 @@
1
+ import { MarkdownItPlantumlOptions } from "@mdit/plugin-plantuml";
2
+ import { PluginSimple, PluginWithOptions } from "markdown-it";
3
+ import { Plugin } from "vuepress/core";
4
+
5
+ //#region src/node/markdown-it-plugins/chartjs.d.ts
6
+ interface ChartJSPluginOptions {
7
+ /**
8
+ * Allow executing custom scripts inside Chart.js blocks.
9
+ *
10
+ * 允许在 Chart.js 块内执行自定义脚本。
11
+ *
12
+ * @default false
13
+ */
14
+ allowScripts?: boolean;
15
+ /**
16
+ * Allow all scripts to be executed inside Chart.js blocks.
17
+ *
18
+ * 允许在 Chart.js 块内执行所有脚本。
19
+ *
20
+ * @default false
21
+ */
22
+ allowAll?: boolean;
23
+ /**
24
+ * List of files allowed to execute scripts inside Chart.js blocks.
25
+ *
26
+ * 允许在 Chart.js 块内执行脚本的文件列表。
27
+ *
28
+ * @default new Set()
29
+ */
30
+ allowList?: Set<string>;
31
+ }
32
+ /**
33
+ * Chart.js markdown-it plugin
34
+ *
35
+ * Chart.js markdown-it 插件
36
+ *
37
+ * @param md - MarkdownIt instance / MarkdownIt 实例
38
+ * @param options - Plugin options / 插件选项
39
+ */
40
+ declare const chartjs: PluginWithOptions<ChartJSPluginOptions>;
41
+ //#endregion
42
+ //#region src/node/markdown-it-plugins/echarts.d.ts
43
+ interface EChartsPluginOptions {
44
+ /**
45
+ * Allow executing custom scripts inside ECharts blocks.
46
+ *
47
+ * 允许在 ECharts 块内执行自定义脚本。
48
+ *
49
+ * @default false
50
+ */
51
+ allowScripts?: boolean;
52
+ /**
53
+ * Allow all scripts to be executed inside ECharts blocks.
54
+ *
55
+ * 允许在 ECharts 块内执行所有脚本。
56
+ *
57
+ * @default false
58
+ */
59
+ allowAll?: boolean;
60
+ /**
61
+ * List of files allowed to execute scripts inside ECharts blocks.
62
+ *
63
+ * 允许在 ECharts 块内执行脚本的文件列表。
64
+ *
65
+ * @default new Set()
66
+ */
67
+ allowList?: Set<string>;
68
+ }
69
+ /**
70
+ * ECharts markdown-it plugin
71
+ *
72
+ * ECharts markdown-it 插件
73
+ *
74
+ * @param md - MarkdownIt instance / MarkdownIt 实例
75
+ * @param options - Plugin options / 插件选项
76
+ */
77
+ declare const echarts: PluginWithOptions<EChartsPluginOptions>;
78
+ //#endregion
79
+ //#region src/node/markdown-it-plugins/flowchart.d.ts
80
+ /**
81
+ * Flowchart markdown-it plugin
82
+ *
83
+ * Flowchart markdown-it 插件
84
+ *
85
+ * @param md - MarkdownIt instance / MarkdownIt 实例
86
+ */
87
+ declare const flowchart: PluginSimple;
88
+ //#endregion
89
+ //#region src/node/markdown-it-plugins/markmap.d.ts
90
+ /**
91
+ * Markmap markdown-it plugin
92
+ *
93
+ * Markmap markdown-it 插件
94
+ *
95
+ * @param md - MarkdownIt instance / MarkdownIt 实例
96
+ */
97
+ declare const markmap: PluginSimple;
98
+ //#endregion
99
+ //#region src/node/markdown-it-plugins/mermaid.d.ts
100
+ interface MermaidOptions {
101
+ content: string;
102
+ diagram?: string;
103
+ title?: string;
104
+ indent?: boolean;
105
+ }
106
+ /**
107
+ * Get Mermaid content with proper formatting
108
+ *
109
+ * 获取格式化的 Mermaid 内容
110
+ *
111
+ * @param options - Mermaid options / Mermaid 选项
112
+ *
113
+ * @returns Formatted Mermaid content / 格式化的 Mermaid 内容
114
+ */
115
+ declare const getMermaidContent: ({
116
+ diagram,
117
+ content,
118
+ title,
119
+ indent
120
+ }: MermaidOptions) => string;
121
+ /**
122
+ * Mermaid markdown-it plugin
123
+ *
124
+ * Mermaid markdown-it 插件
125
+ *
126
+ * @param md - MarkdownIt instance / MarkdownIt 实例
127
+ */
128
+ declare const mermaid: PluginSimple;
129
+ //#endregion
130
+ //#region src/node/markdown-it-plugins/plantuml.d.ts
131
+ /**
132
+ * PlantUML markdown-it plugin
133
+ *
134
+ * PlantUML markdown-it 插件
135
+ *
136
+ * @param md - MarkdownIt instance / MarkdownIt 实例
137
+ * @param options - PlantUML options / PlantUML 选项
138
+ */
139
+ declare const plantuml: PluginWithOptions<MarkdownItPlantumlOptions[]>;
140
+ //#endregion
141
+ //#region src/node/options.d.ts
142
+ interface MarkdownChartPluginOptions {
143
+ /**
144
+ * Whether to enable chart support
145
+ *
146
+ * 是否启用 chart 图表支持
147
+ *
148
+ * @default false
149
+ */
150
+ chartjs?: boolean;
151
+ /**
152
+ * Whether to enable echarts support
153
+ *
154
+ * 是否启用 echarts 图表支持
155
+ *
156
+ * @default false
157
+ */
158
+ echarts?: boolean;
159
+ /**
160
+ * Whether to enable flowchart support
161
+ *
162
+ * 是否启用 flowchart 流程图支持
163
+ *
164
+ * @default false
165
+ */
166
+ flowchart?: boolean;
167
+ /**
168
+ * Whether to enable markmap support
169
+ *
170
+ * 是否启用 markmap 流程图支持
171
+ *
172
+ * @default false
173
+ */
174
+ markmap?: boolean;
175
+ /**
176
+ * Whether to enable mermaid support
177
+ *
178
+ * 是否启用 Mermaid 流程图支持
179
+ *
180
+ * @default false
181
+ */
182
+ mermaid?: boolean;
183
+ /**
184
+ * Whether enable plantuml support
185
+ *
186
+ * 是否启用 plantuml 支持
187
+ *
188
+ * @default false
189
+ */
190
+ plantuml?: MarkdownItPlantumlOptions[] | boolean;
191
+ /**
192
+ * Allow executing custom scripts inside chart blocks.
193
+ *
194
+ * 允许在图表代码块中执行自定义脚本。
195
+ *
196
+ * # Caution! Enabling this may introduce XSS or remote code risks.
197
+ *
198
+ * # 注意!启用可能带来 XSS 或远程代码风险。
199
+ *
200
+ * @default false
201
+ */
202
+ DANGEROUS_ALLOW_SCRIPT_EXECUTION?: boolean;
203
+ /**
204
+ * Allowlist of source files permitted to run chart scripts.
205
+ *
206
+ * 允许执行图表脚本的源文件列表(允许清单)。
207
+ *
208
+ * @description Only effective when `DANGEROUS_ALLOW_SCRIPT_EXECUTION` is set; paths must match real files.
209
+ *
210
+ * 仅在 `DANGEROUS_ALLOW_SCRIPT_EXECUTION` 被设置后生效;路径需与实际文件匹配。
211
+ */
212
+ DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST?: string[] | '*';
213
+ }
214
+ //#endregion
215
+ //#region src/node/markdownChartPlugin.d.ts
216
+ declare module 'vuepress/markdown' {
217
+ interface MarkdownOptions {
218
+ chart?: MarkdownChartPluginOptions;
219
+ }
220
+ }
221
+ /**
222
+ * Markdown chart plugin
223
+ *
224
+ * Markdown 图表插件
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * import { markdownChartPlugin } from '@vuepress/plugin-markdown-chart'
229
+ *
230
+ * export default {
231
+ * plugins: [
232
+ * markdownChartPlugin({
233
+ * chartjs: true,
234
+ * echarts: true,
235
+ * flowchart: true,
236
+ * markmap: true,
237
+ * mermaid: true,
238
+ * plantuml: true,
239
+ * }),
240
+ * ],
241
+ * }
242
+ * ```
243
+ */
244
+ declare const markdownChartPlugin: (options?: MarkdownChartPluginOptions) => Plugin;
245
+ //#endregion
246
+ export { ChartJSPluginOptions, EChartsPluginOptions, MarkdownChartPluginOptions, chartjs, echarts, flowchart, getMermaidContent, markdownChartPlugin, markmap, mermaid, plantuml };
247
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,33 @@
1
+ import{container as e}from"@mdit/plugin-container";import{Logger as t,addViteOptimizeDepsExclude as n,addViteOptimizeDepsInclude as r,addViteSsrExternal as i,addViteSsrNoExternal as a,deepAssign as o,encodeData as s,ensureEndingSlash as c,isArray as l,isModuleAvailable as u}from"@vuepress/helper";import{colors as d,getDirname as f,path as p}from"vuepress/utils";import{plantuml as m}from"@mdit/plugin-plantuml";const h=(t,n)=>{let{allowScripts:r,allowAll:i,allowList:a=new Set}=n??{};e(t,{name:`chartjs`,openRender:(e,t,n,o)=>{let c=e[t].info.trimStart().slice(7).trim(),l=`{}`,u=!1,f=!1,p=o?.filePathRelative??``;for(let n=t;n<e.length;n++){let{type:t,content:o,info:c}=e[n];if(t===`container_chartjs_close`){u&&!f&&(console.warn(`\
2
+ ${d.magenta(`chartjs`)}: JavaScript in Chart.js block is found in ${d.cyan(p)}, ${d.red(`it is ignored for security reasons`)}.
3
+ To enable the chart, you must manually add it to allowlist, see https://vuepress.vuejs.org/plugin/markdown/markdown-charts/chartjs.html for details.
4
+ `),e[n].hidden=!0);break}o&&(t===`fence`&&(c===`json`?l=s(o):(c===`js`||c===`javascript`)&&(l=s(o),u=!0,r&&(i||a.has(p))&&(f=!0))),e[n].type=`chartjs_empty`,e[n].hidden=!0)}return u&&!f?``:`<ChartJS config="${l}"${c?` title="${encodeURIComponent(c)}"`:``}${u?` type="js"`:``}>`},closeRender:(e,t)=>e[t].hidden?``:`</ChartJS>`})},g=(e,t)=>{let{content:n,info:r}=e[t],[,i]=r.trim().split(`:`,2);return`<ECharts config="${s(n)}"${i?` title="${encodeURIComponent(i)}"`:``}></ECharts>`},_=(t,n)=>{let{allowScripts:r,allowAll:i,allowList:a=new Set}=n??{},{fence:o}=t.renderer.rules;t.renderer.rules.fence=(...e)=>{let[t,n]=e,{info:r}=t[n],[i]=r.split(`:`,2);return i===`echarts`?g(t,n):o(...e)},t.renderer.rules.echarts=g,e(t,{name:`echarts`,openRender:(e,t,n,o)=>{let c=e[t].info.trimStart().slice(7).trim(),l=`{}`,u=!1,f=!1,p=o?.filePathRelative??``;for(let n=t;n<e.length;n++){let{type:t,content:o,info:s}=e[n];if(t===`container_echarts_close`){u&&!f&&(console.warn(`\
5
+ ${d.magenta(`[echarts]`)}: JavaScript in echarts block is found in ${d.cyan(p)}, ${d.red(`it is ignored for security reasons`)}.
6
+ To enable the chart, you must manually add it to allowlist, see https://vuepress.vuejs.org/plugin/markdown/markdown-chart/echarts.html for details.
7
+ `),e[n].hidden=!0);break}o&&(t===`fence`&&(s===`json`?l=o:(s===`js`||s===`javascript`)&&(l=o,u=!0,r&&(i||a.has(p))&&(f=!0))),e[n].type=`echarts_empty`,e[n].hidden=!0)}return u&&!f?``:`<ECharts config="${s(l)}"${c?` title="${encodeURIComponent(c)}"`:``}${u?` type="js"`:``}>`},closeRender:(e,t)=>e[t].hidden?``:`</ECharts>`})},v=new Set([`ant`,`pie`,`vue`]),y=(e,t)=>{let{content:n,info:r}=e[t],[,i]=r.trim().split(`:`,2);return`<FlowChart code="${s(n)}" preset="${v.has(i)?i:`vue`}"></FlowChart>`},b=e=>{let{fence:t}=e.renderer.rules;e.renderer.rules.fence=(...e)=>{let[n,r]=e,{info:i}=n[r],[a]=i.split(`:`,2);return a===`flow`||a===`flowchart`?y(n,r):t(...e)},e.renderer.rules.flowchart=y},x=(e,t)=>`<MarkMap content="${s(e[t].content)}"></MarkMap>`,S=e=>{let{fence:t}=e.renderer.rules;e.renderer.rules.fence=(...e)=>{let[n,r]=e,{info:i}=n[r],[a]=i.split(`:`,2);return a===`markmap`?x(n,r):t(...e)},e.renderer.rules.markmap=x},C=(e,t)=>`<Mermaid code="${s(e[t].content)}"></Mermaid>`,w=({diagram:e=`mermaid`,content:t,title:n=``,indent:r=e!==`mermaid`})=>{let[,i,a]=/^\s*---\n([^]*?)\n---\n\n([\s\S]*)\s*$/m.exec(t)??[null,``,t],o=(!n||/^title:\s*(.*)/m.test(i)?i:`title: ${n}\n${i}`).trim();return`\
8
+ ${o?`\
9
+ ---
10
+ ${o}
11
+ ---
12
+
13
+ `:``}\
14
+ ${e===`mermaid`?``:`\
15
+ ${e}
16
+ `}\
17
+ ${r?a.split(`
18
+ `).map(e=>e?` ${e}`:``).join(`
19
+ `):a}\
20
+ `},T=e=>`<Mermaid code="${s(w(e))}"${e.title?` title="${s(e.title)}"`:``}></Mermaid>`,E={class:[`classDiagram`],c4c:[`C4Context`],er:[`erDiagram`],gantt:[``],"git-graph":[`gitGraph`],journey:[``],mindmap:[``],kanban:[``],pie:[``],quadrant:[`quadrantChart`],requirement:[`requirementDiagram`],sequence:[`sequenceDiagram`],state:[`stateDiagram-v2`],timeline:[``],architecture:[`architecture-beta`],block:[`block-beta`,!1],packet:[`packet-beta`,!1],sankey:[`sankey-beta`,!1],xy:[`xychart-beta`,!1],treemap:[`treemap-beta`,!1],radar:[`radar-beta`]},D=e=>{let{fence:t}=e.renderer.rules;e.renderer.rules.fence=(...e)=>{let[n,r]=e,{content:i,info:a}=n[r],o=a.trim();if(o===`mermaid`)return T({content:i,indent:!1});let[s,...c]=o.split(` `);return s in E?T({diagram:E[s][0]||s,title:c.join(` `),content:i,indent:E[s][1]??!0}):t(...e)},e.renderer.rules.mermaid=C},O=(e,t=[`chronology`,`gantt`,`json`,`latex`,`math`,`mindmap`,`regex`,`salt`,`uml`,`wbs`,`yaml`].map(e=>({name:e})))=>{t.forEach(t=>{e.use(m,t)})},k=f(import.meta.url),A=`@vuepress/plugin-markdown-chart`,j=new t(A),M=c(p.resolve(k,`../client`)),N=(e,t=!0)=>{let n=u(e,import.meta);return t&&!n&&j.error(`Package ${e} is not installed, please install it manually!`),n},P=async(e,t)=>{let n=new Set,r=new Set;return t.chartjs&&(n.add(`import ChartJS from "${M}components/ChartJS.js";`),r.add(`app.component("ChartJS", ChartJS)`)),t.echarts&&(n.add(`import ECharts from "${M}components/ECharts.js";`),r.add(`app.component("ECharts", ECharts);`)),t.flowchart&&(n.add(`import FlowChart from "${M}components/FlowChart.js";`),r.add(`app.component("FlowChart", FlowChart);`)),t.markmap&&(n.add(`import MarkMap from "${M}components/MarkMap.js";`),r.add(`app.component("MarkMap", MarkMap);`)),t.mermaid&&(n.add(`import Mermaid from "${M}components/Mermaid.js";`),r.add(`app.component("Mermaid", Mermaid);`)),e.writeTemp(`markdown-chart/config.js`,`\
21
+ import { defineClientConfig } from "vuepress/client";
22
+ ${[...n.values()].join(`
23
+ `)}
24
+
25
+ export default defineClientConfig({
26
+ enhance: ({ app }) => {
27
+ ${Array.from(r.values(),e=>e.split(`
28
+ `).map(e=>` ${e}`)).flat().join(`
29
+ `)}
30
+ },
31
+ });
32
+ `)},F=(e={})=>t=>{let s=o({},t.options.markdown.chart,e);t.options.markdown.chart=s,t.env.isDebug&&j.info(`Options:`,s);let c=(e,t=[])=>{let n=!!s[e],r=t.every(t=>N(t,!!s[e]));return n&&r},u={chartjs:c(`chartjs`,[`chart.js`]),echarts:c(`echarts`,[`echarts`]),flowchart:c(`flowchart`,[`flowchart.ts`]),markmap:c(`markmap`,[`markmap-lib`,`markmap-toolbar`,`markmap-view`]),mermaid:c(`mermaid`,[`mermaid`])};return{name:A,extendsMarkdown:e=>{let{DANGEROUS_ALLOW_SCRIPT_EXECUTION:t,DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST:n}=s,r={allowScripts:t??!1,allowAll:n===`*`,allowList:new Set(l(n)?n.map(e=>{let t=e.replaceAll(`\\`,`/`).replace(/^\//,``);return t.endsWith(`.md`)?t:`${t}.md`}):[])};u.chartjs&&e.use(h,r),u.echarts&&e.use(_,r),u.flowchart&&e.use(b),l(s.plantuml)?e.use(O,s.plantuml):s.plantuml&&e.use(O),u.markmap&&e.use(S),u.mermaid&&e.use(D)},extendsBundlerOptions:e=>{a(e,t,[`@vuepress/helper`,`fflate`]),u.chartjs&&(n(e,t,`chart.js/auto/auto.mjs`),i(e,t,`chart.js`)),u.echarts&&(n(e,t,`echarts`),i(e,t,`echarts`)),u.flowchart&&(n(e,t,`flowchart.ts`),i(e,t,`flowchart.ts`)),u.markmap&&(r(e,t,[`markmap-lib`,`markmap-toolbar`,`markmap-view`]),i(e,t,[`markmap-lib`,`markmap-toolbar`,`markmap-view`])),u.mermaid&&(n(e,t,`mermaid/dist/mermaid.esm.min.mjs`),i(e,t,`mermaid`))},clientConfigFile:()=>P(t,u)}};export{h as chartjs,_ as echarts,b as flowchart,w as getMermaidContent,F as markdownChartPlugin,S as markmap,D as mermaid,O as plantuml};
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_plantuml"],"sources":["../../src/node/markdown-it-plugins/chartjs.ts","../../src/node/markdown-it-plugins/echarts.ts","../../src/node/markdown-it-plugins/flowchart.ts","../../src/node/markdown-it-plugins/markmap.ts","../../src/node/markdown-it-plugins/mermaid.ts","../../src/node/markdown-it-plugins/plantuml.ts","../../src/node/utils.ts","../../src/node/prepareConfigFile.ts","../../src/node/markdownChartPlugin.ts"],"sourcesContent":["import { container } from '@mdit/plugin-container'\nimport { encodeData } from '@vuepress/helper'\nimport type { PluginWithOptions } from 'markdown-it'\nimport { colors } from 'vuepress/utils'\n\nexport interface ChartJSPluginOptions {\n /**\n * Allow executing custom scripts inside Chart.js blocks.\n *\n * 允许在 Chart.js 块内执行自定义脚本。\n *\n * @default false\n */\n allowScripts?: boolean\n\n /**\n * Allow all scripts to be executed inside Chart.js blocks.\n *\n * 允许在 Chart.js 块内执行所有脚本。\n *\n * @default false\n */\n allowAll?: boolean\n\n /**\n * List of files allowed to execute scripts inside Chart.js blocks.\n *\n * 允许在 Chart.js 块内执行脚本的文件列表。\n *\n * @default new Set()\n */\n allowList?: Set<string>\n}\n\n/**\n * Chart.js markdown-it plugin\n *\n * Chart.js markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n * @param options - Plugin options / 插件选项\n */\nexport const chartjs: PluginWithOptions<ChartJSPluginOptions> = (\n md,\n options,\n) => {\n const { allowScripts, allowAll, allowList = new Set() } = options ?? {}\n\n container(md, {\n name: 'chartjs',\n openRender: (tokens, index, _options, env) => {\n const title = tokens[index].info\n .trimStart()\n // \"chartjs\" length\n .slice(7)\n .trim()\n\n let config = '{}'\n let isJavaScript = false\n let isInAllowList = false\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const filePathRelative: string = env?.filePathRelative ?? ''\n\n for (let i = index; i < tokens.length; i++) {\n const { type, content, info } = tokens[i]\n\n if (type === 'container_chartjs_close') {\n if (isJavaScript && !isInAllowList) {\n // eslint-disable-next-line no-console\n console.warn(\n `\\\n${colors.magenta('chartjs')}: JavaScript in Chart.js block is found in ${colors.cyan(filePathRelative)}, ${colors.red('it is ignored for security reasons')}.\nTo enable the chart, you must manually add it to allowlist, see https://vuepress.vuejs.org/plugin/markdown/markdown-charts/chartjs.html for details.\n`,\n )\n tokens[i].hidden = true\n }\n break\n }\n\n if (!content) continue\n if (type === 'fence') {\n if (info === 'json') {\n config = encodeData(content)\n } else if (info === 'js' || info === 'javascript') {\n config = encodeData(content)\n isJavaScript = true\n\n if (allowScripts && (allowAll || allowList.has(filePathRelative)))\n isInAllowList = true\n }\n }\n\n // Set to an unknown token type\n tokens[i].type = 'chartjs_empty'\n // Hide token\n tokens[i].hidden = true\n }\n\n if (isJavaScript && !isInAllowList) return ''\n\n return `<ChartJS config=\"${config}\"${\n title ? ` title=\"${encodeURIComponent(title)}\"` : ''\n }${isJavaScript ? ' type=\"js\"' : ''}>`\n },\n closeRender: (tokens, index) => (tokens[index].hidden ? '' : '</ChartJS>'),\n })\n}\n","import { container } from '@mdit/plugin-container'\nimport { encodeData } from '@vuepress/helper'\nimport type { PluginWithOptions } from 'markdown-it'\nimport type Token from 'markdown-it/lib/token.mjs'\nimport { colors } from 'vuepress/utils'\n\nconst echartsRender = (tokens: Token[], index: number): string => {\n const { content, info } = tokens[index]\n const [, title] = info.trim().split(':', 2)\n\n return `<ECharts config=\"${encodeData(content)}\"${\n title ? ` title=\"${encodeURIComponent(title)}\"` : ''\n }></ECharts>`\n}\n\nexport interface EChartsPluginOptions {\n /**\n * Allow executing custom scripts inside ECharts blocks.\n *\n * 允许在 ECharts 块内执行自定义脚本。\n *\n * @default false\n */\n allowScripts?: boolean\n\n /**\n * Allow all scripts to be executed inside ECharts blocks.\n *\n * 允许在 ECharts 块内执行所有脚本。\n *\n * @default false\n */\n allowAll?: boolean\n\n /**\n * List of files allowed to execute scripts inside ECharts blocks.\n *\n * 允许在 ECharts 块内执行脚本的文件列表。\n *\n * @default new Set()\n */\n allowList?: Set<string>\n}\n\n/**\n * ECharts markdown-it plugin\n *\n * ECharts markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n * @param options - Plugin options / 插件选项\n */\nexport const echarts: PluginWithOptions<EChartsPluginOptions> = (\n md,\n options,\n) => {\n const { allowScripts, allowAll, allowList = new Set() } = options ?? {}\n\n // Handle ```echarts blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { info } = tokens[index]\n const [realInfo] = info.split(':', 2)\n\n if (realInfo === 'echarts') return echartsRender(tokens, index)\n\n return fence!(...args)\n }\n\n md.renderer.rules.echarts = echartsRender\n\n container(md, {\n name: 'echarts',\n\n openRender: (tokens, index, _options, env) => {\n const title = tokens[index].info\n .trimStart()\n // 'echarts' length\n .slice(7)\n .trim()\n\n let config = '{}'\n let isJavaScript = false\n let isInAllowList = false\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const filePathRelative: string = env?.filePathRelative ?? ''\n\n for (let i = index; i < tokens.length; i++) {\n const { type, content, info } = tokens[i]\n\n if (type === 'container_echarts_close') {\n if (isJavaScript && !isInAllowList) {\n // eslint-disable-next-line no-console\n console.warn(\n `\\\n${colors.magenta('[echarts]')}: JavaScript in echarts block is found in ${colors.cyan(filePathRelative)}, ${colors.red('it is ignored for security reasons')}.\nTo enable the chart, you must manually add it to allowlist, see https://vuepress.vuejs.org/plugin/markdown/markdown-chart/echarts.html for details.\n`,\n )\n tokens[i].hidden = true\n }\n break\n }\n\n if (!content) continue\n if (type === 'fence') {\n if (info === 'json') {\n config = content\n } else if (info === 'js' || info === 'javascript') {\n config = content\n isJavaScript = true\n\n if (allowScripts && (allowAll || allowList.has(filePathRelative)))\n isInAllowList = true\n }\n }\n\n // Set to an unknown token type\n tokens[i].type = 'echarts_empty'\n // Hide token\n tokens[i].hidden = true\n }\n\n if (isJavaScript && !isInAllowList) return ''\n\n return `<ECharts config=\"${encodeData(config)}\"${\n title ? ` title=\"${encodeURIComponent(title)}\"` : ''\n }${isJavaScript ? ' type=\"js\"' : ''}>`\n },\n closeRender: (tokens, index) => (tokens[index].hidden ? '' : '</ECharts>'),\n })\n}\n","import { encodeData } from '@vuepress/helper'\nimport type { PluginSimple } from 'markdown-it'\nimport type Token from 'markdown-it/lib/token.mjs'\n\nconst SUPPORTED_PRESETS = new Set(['ant', 'pie', 'vue'])\n\nconst flowchartRender = (tokens: Token[], index: number): string => {\n const token = tokens[index]\n const { content, info } = token\n const [, preset] = info.trim().split(':', 2)\n\n return `<FlowChart code=\"${encodeData(content)}\" preset=\"${\n SUPPORTED_PRESETS.has(preset) ? preset : 'vue'\n }\"></FlowChart>`\n}\n\n/**\n * Flowchart markdown-it plugin\n *\n * Flowchart markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n */\nexport const flowchart: PluginSimple = (md) => {\n // Handle ```flow and ```flowchart blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { info } = tokens[index]\n const [realInfo] = info.split(':', 2)\n\n if (realInfo === 'flow' || realInfo === 'flowchart')\n return flowchartRender(tokens, index)\n\n return fence!(...args)\n }\n\n md.renderer.rules.flowchart = flowchartRender\n}\n","import { encodeData } from '@vuepress/helper'\nimport type { PluginSimple } from 'markdown-it'\nimport type Token from 'markdown-it/lib/token.mjs'\n\nconst markmapRender = (tokens: Token[], index: number): string =>\n `<MarkMap content=\"${encodeData(tokens[index].content)}\"></MarkMap>`\n\n/**\n * Markmap markdown-it plugin\n *\n * Markmap markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n */\nexport const markmap: PluginSimple = (md) => {\n // Handle ```markmap blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { info } = tokens[index]\n const [realInfo] = info.split(':', 2)\n\n if (realInfo === 'markmap') return markmapRender(tokens, index)\n\n return fence!(...args)\n }\n\n md.renderer.rules.markmap = markmapRender\n}\n","import { encodeData } from '@vuepress/helper'\nimport type { PluginSimple } from 'markdown-it'\nimport type { RenderRule } from 'markdown-it/lib/renderer.mjs'\n\nconst mermaidRenderer: RenderRule = (tokens, index) =>\n `<Mermaid code=\"${encodeData(tokens[index].content)}\"></Mermaid>`\n\ninterface MermaidOptions {\n content: string\n diagram?: string\n title?: string\n indent?: boolean\n}\n\n/**\n * Get Mermaid content with proper formatting\n *\n * 获取格式化的 Mermaid 内容\n *\n * @param options - Mermaid options / Mermaid 选项\n *\n * @returns Formatted Mermaid content / 格式化的 Mermaid 内容\n */\nexport const getMermaidContent = ({\n diagram = 'mermaid',\n content,\n title = '',\n indent = diagram !== 'mermaid',\n}: MermaidOptions): string => {\n const [, originalFrontmatter, rest] =\n /^\\s*---\\n([^]*?)\\n---\\n\\n([\\s\\S]*)\\s*$/m.exec(content) ?? [\n null,\n '',\n content,\n ]\n\n const frontmatter = (\n !title || /^title:\\s*(.*)/m.test(originalFrontmatter)\n ? originalFrontmatter\n : `title: ${title}\\n${originalFrontmatter}`\n ).trim()\n\n return `\\\n${\n frontmatter\n ? `\\\n---\n${frontmatter}\n---\n\n`\n : ''\n}\\\n${\n diagram === 'mermaid'\n ? ''\n : `\\\n${diagram}\n`\n}\\\n${\n indent\n ? rest\n .split('\\n')\n .map((line) => (line ? ` ${line}` : ''))\n .join('\\n')\n : rest\n}\\\n`\n}\n\nconst getMermaid = (options: MermaidOptions): string =>\n `<Mermaid code=\"${encodeData(getMermaidContent(options))}\"${\n options.title ? ` title=\"${encodeData(options.title)}\"` : ''\n }></Mermaid>`\n\nconst DIAGRAM_MAP: Record<string, [diagramName: string, indent?: boolean]> = {\n 'class': ['classDiagram'],\n 'c4c': ['C4Context'],\n 'er': ['erDiagram'],\n 'gantt': [''],\n 'git-graph': ['gitGraph'],\n 'journey': [''],\n 'mindmap': [''],\n 'kanban': [''],\n 'pie': [''],\n 'quadrant': ['quadrantChart'],\n 'requirement': ['requirementDiagram'],\n 'sequence': ['sequenceDiagram'],\n 'state': ['stateDiagram-v2'],\n 'timeline': [''],\n\n // beta diagrams\n 'architecture': ['architecture-beta'],\n 'block': ['block-beta', false],\n 'packet': ['packet-beta', false],\n 'sankey': ['sankey-beta', false],\n 'xy': ['xychart-beta', false],\n 'treemap': ['treemap-beta', false],\n 'radar': ['radar-beta'],\n}\n\n/**\n * Mermaid markdown-it plugin\n *\n * Mermaid markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n */\nexport const mermaid: PluginSimple = (md) => {\n // Handle ```mermaid blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { content, info } = tokens[index]\n\n const fenceInfo = info.trim()\n\n if (fenceInfo === 'mermaid') return getMermaid({ content, indent: false })\n\n const [name, ...rest] = fenceInfo.split(' ')\n\n if (name in DIAGRAM_MAP) {\n return getMermaid({\n diagram: DIAGRAM_MAP[name][0] || name,\n title: rest.join(' '),\n content,\n indent: DIAGRAM_MAP[name][1] ?? true,\n })\n }\n\n return fence!(...args)\n }\n\n md.renderer.rules.mermaid = mermaidRenderer\n}\n","import type { MarkdownItPlantumlOptions } from '@mdit/plugin-plantuml'\nimport { plantuml as _plantuml } from '@mdit/plugin-plantuml'\nimport type { PluginWithOptions } from 'markdown-it'\n\n/**\n * PlantUML markdown-it plugin\n *\n * PlantUML markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n * @param options - PlantUML options / PlantUML 选项\n */\nexport const plantuml: PluginWithOptions<MarkdownItPlantumlOptions[]> = (\n md,\n options = [\n 'chronology',\n 'gantt',\n 'json',\n 'latex',\n 'math',\n 'mindmap',\n 'regex',\n 'salt',\n 'uml',\n 'wbs',\n 'yaml',\n ].map((name) => ({ name })),\n) => {\n options.forEach((option) => {\n md.use(_plantuml, option)\n })\n}\n","import { Logger, ensureEndingSlash, isModuleAvailable } from '@vuepress/helper'\nimport { getDirname, path } from 'vuepress/utils'\n\nconst __dirname = getDirname(import.meta.url)\n\nexport const PLUGIN_NAME = '@vuepress/plugin-markdown-chart'\n\nexport const logger = new Logger(PLUGIN_NAME)\n\nexport const CLIENT_FOLDER = ensureEndingSlash(\n path.resolve(__dirname, '../client'),\n)\n\nexport const isInstalled = (pkg: string, hint = true): boolean => {\n const status = isModuleAvailable(pkg, import.meta)\n\n if (hint && !status)\n logger.error(`Package ${pkg} is not installed, please install it manually!`)\n\n return status\n}\n","import type { App } from 'vuepress/core'\n\nimport { CLIENT_FOLDER } from './utils.js'\n\nexport const prepareConfigFile = async (\n app: App,\n status: Record<string, boolean>,\n): Promise<string> => {\n const imports = new Set<string>()\n const enhances = new Set<string>()\n\n if (status.chartjs) {\n imports.add(`import ChartJS from \"${CLIENT_FOLDER}components/ChartJS.js\";`)\n enhances.add(`app.component(\"ChartJS\", ChartJS)`)\n }\n\n if (status.echarts) {\n imports.add(`import ECharts from \"${CLIENT_FOLDER}components/ECharts.js\";`)\n enhances.add(`app.component(\"ECharts\", ECharts);`)\n }\n\n if (status.flowchart) {\n imports.add(\n `import FlowChart from \"${CLIENT_FOLDER}components/FlowChart.js\";`,\n )\n\n enhances.add(`app.component(\"FlowChart\", FlowChart);`)\n }\n\n if (status.markmap) {\n imports.add(`import MarkMap from \"${CLIENT_FOLDER}components/MarkMap.js\";`)\n enhances.add(`app.component(\"MarkMap\", MarkMap);`)\n }\n\n if (status.mermaid) {\n imports.add(`import Mermaid from \"${CLIENT_FOLDER}components/Mermaid.js\";`)\n enhances.add(`app.component(\"Mermaid\", Mermaid);`)\n }\n\n return app.writeTemp(\n `markdown-chart/config.js`,\n `\\\nimport { defineClientConfig } from \"vuepress/client\";\n${[...imports.values()].join('\\n')}\n\nexport default defineClientConfig({\n enhance: ({ app }) => {\n${Array.from(enhances.values(), (item) =>\n item.split('\\n').map((line) => ` ${line}`),\n)\n .flat()\n .join('\\n')}\n },\n});\n`,\n )\n}\n","import {\n addViteOptimizeDepsExclude,\n addViteOptimizeDepsInclude,\n addViteSsrExternal,\n addViteSsrNoExternal,\n deepAssign,\n isArray,\n} from '@vuepress/helper'\nimport type { Plugin } from 'vuepress/core'\nimport {\n chartjs,\n echarts,\n flowchart,\n markmap,\n mermaid,\n plantuml,\n} from './markdown-it-plugins/index.js'\nimport type { MarkdownChartPluginOptions } from './options.js'\nimport { prepareConfigFile } from './prepareConfigFile.js'\nimport { PLUGIN_NAME, isInstalled, logger } from './utils.js'\n\ndeclare module 'vuepress/markdown' {\n interface MarkdownOptions {\n chart?: MarkdownChartPluginOptions\n }\n}\n\n/**\n * Markdown chart plugin\n *\n * Markdown 图表插件\n *\n * @example\n * ```ts\n * import { markdownChartPlugin } from '@vuepress/plugin-markdown-chart'\n *\n * export default {\n * plugins: [\n * markdownChartPlugin({\n * chartjs: true,\n * echarts: true,\n * flowchart: true,\n * markmap: true,\n * mermaid: true,\n * plantuml: true,\n * }),\n * ],\n * }\n * ```\n */\nexport const markdownChartPlugin =\n (options: MarkdownChartPluginOptions = {}): Plugin =>\n (app) => {\n const mergedOptions = deepAssign({}, app.options.markdown.chart, options)\n app.options.markdown.chart = mergedOptions\n\n if (app.env.isDebug) logger.info('Options:', mergedOptions)\n\n const getStatus = (\n key: keyof MarkdownChartPluginOptions,\n pkgs: string[] = [],\n ): boolean => {\n const enabled = Boolean(mergedOptions[key])\n const pkgInstalled = pkgs.every((pkg) =>\n isInstalled(pkg, Boolean(mergedOptions[key])),\n )\n\n return enabled && pkgInstalled\n }\n\n const status = {\n chartjs: getStatus('chartjs', ['chart.js']),\n echarts: getStatus('echarts', ['echarts']),\n flowchart: getStatus('flowchart', ['flowchart.ts']),\n markmap: getStatus('markmap', [\n 'markmap-lib',\n 'markmap-toolbar',\n 'markmap-view',\n ]),\n mermaid: getStatus('mermaid', ['mermaid']),\n }\n\n return {\n name: PLUGIN_NAME,\n\n extendsMarkdown: (md) => {\n const {\n DANGEROUS_ALLOW_SCRIPT_EXECUTION,\n DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST,\n } = mergedOptions\n\n const scriptOptions = {\n allowScripts: DANGEROUS_ALLOW_SCRIPT_EXECUTION ?? false,\n allowAll: DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST === '*',\n allowList: new Set<string>(\n isArray(DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST)\n ? DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST.map((file) => {\n const result = file\n // normalize `\\` to `/` on Windows\n .replaceAll('\\\\', '/')\n // remove any leading slash\n .replace(/^\\//, '')\n\n // ensure markdown extension\n return result.endsWith('.md') ? result : `${result}.md`\n })\n : [],\n ),\n }\n\n if (status.chartjs) md.use(chartjs, scriptOptions)\n if (status.echarts) md.use(echarts, scriptOptions)\n if (status.flowchart) md.use(flowchart)\n if (isArray(mergedOptions.plantuml))\n md.use(plantuml, mergedOptions.plantuml)\n else if (mergedOptions.plantuml) md.use(plantuml)\n if (status.markmap) md.use(markmap)\n if (status.mermaid) md.use(mermaid)\n },\n\n extendsBundlerOptions: (bundlerOptions: unknown) => {\n addViteSsrNoExternal(bundlerOptions, app, [\n '@vuepress/helper',\n 'fflate',\n ])\n\n if (status.chartjs) {\n addViteOptimizeDepsExclude(\n bundlerOptions,\n app,\n 'chart.js/auto/auto.mjs',\n )\n addViteSsrExternal(bundlerOptions, app, 'chart.js')\n }\n\n if (status.echarts) {\n addViteOptimizeDepsExclude(bundlerOptions, app, 'echarts')\n addViteSsrExternal(bundlerOptions, app, 'echarts')\n }\n\n if (status.flowchart) {\n addViteOptimizeDepsExclude(bundlerOptions, app, 'flowchart.ts')\n addViteSsrExternal(bundlerOptions, app, 'flowchart.ts')\n }\n\n if (status.markmap) {\n addViteOptimizeDepsInclude(bundlerOptions, app, [\n 'markmap-lib',\n 'markmap-toolbar',\n 'markmap-view',\n ])\n addViteSsrExternal(bundlerOptions, app, [\n 'markmap-lib',\n 'markmap-toolbar',\n 'markmap-view',\n ])\n }\n\n if (status.mermaid) {\n addViteOptimizeDepsExclude(\n bundlerOptions,\n app,\n 'mermaid/dist/mermaid.esm.min.mjs',\n )\n addViteSsrExternal(bundlerOptions, app, 'mermaid')\n }\n },\n\n clientConfigFile: () => prepareConfigFile(app, status),\n }\n }\n"],"mappings":"6ZA0CA,MAAa,GACX,EACA,IACG,CACH,GAAM,CAAE,eAAc,WAAU,YAAY,IAAI,KAAU,GAAW,EAAE,CAEvE,EAAU,EAAI,CACZ,KAAM,UACN,YAAa,EAAQ,EAAO,EAAU,IAAQ,CAC5C,IAAM,EAAQ,EAAO,GAAO,KACzB,WAAW,CAEX,MAAM,EAAE,CACR,MAAM,CAEL,EAAS,KACT,EAAe,GACf,EAAgB,GAGd,EAA2B,GAAK,kBAAoB,GAE1D,IAAK,IAAI,EAAI,EAAO,EAAI,EAAO,OAAQ,IAAK,CAC1C,GAAM,CAAE,OAAM,UAAS,QAAS,EAAO,GAEvC,GAAI,IAAS,0BAA2B,CAClC,GAAgB,CAAC,IAEnB,QAAQ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EAAgB,EAAK,CAC9C,cACA,kBACA,eACD,CAAC,CACF,EAAmB,EAAgB,EAAK,CACtC,cACA,kBACA,eACD,CAAC,EAGA,EAAO,UACT,EACE,EACA,EACA,mCACD,CACD,EAAmB,EAAgB,EAAK,UAAU,GAItD,qBAAwB,EAAkB,EAAK,EAAO,CACvD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/plugin-markdown-chart",
3
- "version": "2.0.0-rc.123",
3
+ "version": "2.0.0-rc.125",
4
4
  "description": "VuePress plugin - markdown chart",
5
5
  "keywords": [
6
6
  "chart",
@@ -30,26 +30,33 @@
30
30
  "directory": "plugins/markdown/plugin-markdown-chart"
31
31
  },
32
32
  "files": [
33
- "lib"
33
+ "dist"
34
34
  ],
35
35
  "type": "module",
36
- "main": "./lib/node/index.js",
37
- "types": "./lib/node/index.d.ts",
36
+ "sideEffects": [
37
+ "./dist/client/styles/**/*.css"
38
+ ],
38
39
  "exports": {
39
- ".": "./lib/node/index.js",
40
- "./client": "./lib/client/index.js",
41
- "./client/*": "./lib/client/*",
40
+ ".": {
41
+ "types": "./dist/node/index.d.ts",
42
+ "default": "./dist/node/index.js"
43
+ },
44
+ "./client": {
45
+ "types": "./dist/client/index.d.ts",
46
+ "default": "./dist/client/index.js"
47
+ },
48
+ "./client/components/*": "./dist/client/components/*",
42
49
  "./package.json": "./package.json"
43
50
  },
44
51
  "publishConfig": {
45
52
  "access": "public"
46
53
  },
47
54
  "dependencies": {
48
- "@mdit/plugin-container": "^0.22.3",
49
- "@mdit/plugin-plantuml": "^0.23.1",
50
- "@vuepress/helper": "2.0.0-rc.123",
55
+ "@mdit/plugin-container": "^0.23.1",
56
+ "@mdit/plugin-plantuml": "^0.24.1",
57
+ "@vuepress/helper": "2.0.0-rc.125",
51
58
  "@vueuse/core": "^14.2.1",
52
- "vue": "^3.5.28"
59
+ "vue": "^3.5.29"
53
60
  },
54
61
  "devDependencies": {
55
62
  "@types/markdown-it": "^14.1.2",
@@ -89,5 +96,5 @@
89
96
  "optional": true
90
97
  }
91
98
  },
92
- "gitHead": "4d944d5826c6ed0487caa973516f9db0194dc934"
99
+ "gitHead": "58e660bb7138f1883e5440a08903d09cdbabcdc8"
93
100
  }
@@ -1,58 +0,0 @@
1
- import * as vue from 'vue';
2
- import { PropType, VNode } from 'vue';
3
-
4
- declare const _default: vue.DefineComponent<vue.ExtractPropTypes<{
5
- /**
6
- * Chart config
7
- *
8
- * 图表配置
9
- */
10
- config: {
11
- type: StringConstructor;
12
- required: true;
13
- };
14
- /**
15
- * Chart title
16
- *
17
- * 图表标题
18
- */
19
- title: StringConstructor;
20
- /**
21
- * Chart config type
22
- *
23
- * 图表配置类型
24
- */
25
- type: {
26
- type: PropType<"js" | "json">;
27
- default: string;
28
- };
29
- }>, () => (VNode | null)[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
30
- /**
31
- * Chart config
32
- *
33
- * 图表配置
34
- */
35
- config: {
36
- type: StringConstructor;
37
- required: true;
38
- };
39
- /**
40
- * Chart title
41
- *
42
- * 图表标题
43
- */
44
- title: StringConstructor;
45
- /**
46
- * Chart config type
47
- *
48
- * 图表配置类型
49
- */
50
- type: {
51
- type: PropType<"js" | "json">;
52
- default: string;
53
- };
54
- }>> & Readonly<{}>, {
55
- type: "js" | "json";
56
- }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
57
-
58
- export { _default as default };
@@ -1,7 +0,0 @@
1
- import{useDarkMode as _,LoadingIcon as d,decodeData as p}from"@vuepress/helper/client";import{watchImmediate as h}from"@vueuse/core";import{defineComponent as g,shallowRef as m,useId as S,ref as v,onMounted as w,nextTick as y,onUnmounted as j,h as n}from"vue";import"../styles/chartjs.css";const E=(e,t)=>t==="json"?JSON.parse(e):new Function(`let config,__chart_js_config__;
2
- {
3
- ${e}
4
- __chart_js_config__=config;
5
- }
6
- return __chart_js_config__;`)();var R=g({name:"ChartJS",props:{config:{type:String,required:!0},title:String,type:{type:String,default:"json"}},setup(e){const t=_(),c=m(),i=S(),o=v(!1);let r;const s=()=>{r?.destroy(),r=null},l=async()=>{if(__VUEPRESS_SSR__)return;const{default:a}=await import("chart.js/auto");a.defaults.borderColor=t.value?"#ccc":"#36A2EB",a.defaults.color=t.value?"#fff":"#000",a.defaults.maintainAspectRatio=!1;const f=p(e.config),u=E(f,e.type);r=new a(i,u)};return w(()=>{h(__VUEPRESS_DEV__?[()=>e.config,t]:t,async()=>{s(),await y(),await l(),o.value=!0},{flush:"post"})}),j(s),()=>[e.title?n("div",{class:"chartjs-title"},decodeURIComponent(e.title)):null,o.value?null:n(d,{class:"chartjs-loading",height:192}),n("div",{ref:c,class:"chartjs-wrapper",style:{display:o.value?"block":"none"}},n("canvas",{id:i,height:400}))]}});export{R as default};
7
- //# sourceMappingURL=ChartJS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChartJS.js","sources":["../../../src/client/components/ChartJS.ts"],"sourcesContent":["import { LoadingIcon, decodeData, useDarkMode } from '@vuepress/helper/client'\nimport { watchImmediate } from '@vueuse/core'\nimport type { Chart, ChartConfiguration } from 'chart.js'\nimport type { PropType, VNode } from 'vue'\nimport {\n defineComponent,\n h,\n nextTick,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n useId,\n} from 'vue'\n\nimport '../styles/chartjs.css'\n\nconst parseChartConfig = (\n config: string,\n type: 'js' | 'json',\n): ChartConfiguration => {\n if (type === 'json') return JSON.parse(config) as ChartConfiguration\n\n // oxlint-disable-next-line no-new-func, typescript/no-implied-eval\n const runner = new Function(\n `\\\nlet config,__chart_js_config__;\n{\n${config}\n__chart_js_config__=config;\n}\nreturn __chart_js_config__;\\\n`,\n ) as () => ChartConfiguration\n\n return runner()\n}\n\nexport default defineComponent({\n name: 'ChartJS',\n\n props: {\n /**\n * Chart config\n *\n * 图表配置\n */\n config: {\n type: String,\n required: true,\n },\n\n /**\n * Chart title\n *\n * 图表标题\n */\n title: String,\n\n /**\n * Chart config type\n *\n * 图表配置类型\n */\n type: {\n type: String as PropType<'js' | 'json'>,\n default: 'json',\n },\n },\n\n setup(props) {\n const isDarkMode = useDarkMode()\n const chartElement = shallowRef<HTMLElement>()\n const id = useId()\n const loaded = ref(false)\n\n let chartjs: Chart | null\n\n const destroyChart = (): void => {\n chartjs?.destroy()\n chartjs = null\n }\n\n const renderChart = async (): Promise<void> => {\n if (__VUEPRESS_SSR__) return\n\n const { default: ChartJs } = await import(\n /* webpackChunkName: \"chart\" */ 'chart.js/auto'\n )\n\n ChartJs.defaults.borderColor = isDarkMode.value ? '#ccc' : '#36A2EB'\n ChartJs.defaults.color = isDarkMode.value ? '#fff' : '#000'\n ChartJs.defaults.maintainAspectRatio = false\n\n const chartConfig = decodeData(props.config)\n const data = parseChartConfig(chartConfig, props.type)\n\n chartjs = new ChartJs(id, data)\n }\n\n onMounted(() => {\n watchImmediate(\n __VUEPRESS_DEV__\n ? // config must be changed if type is changed, so no need to watch type\n [(): string => props.config, isDarkMode]\n : isDarkMode,\n async () => {\n destroyChart()\n await nextTick()\n await renderChart()\n loaded.value = true\n },\n { flush: 'post' },\n )\n })\n\n onUnmounted(destroyChart)\n\n return (): (VNode | null)[] => [\n props.title\n ? h('div', { class: 'chartjs-title' }, decodeURIComponent(props.title))\n : null,\n loaded.value\n ? null\n : h(LoadingIcon, { class: 'chartjs-loading', height: 192 }),\n h(\n 'div',\n {\n ref: chartElement,\n class: 'chartjs-wrapper',\n style: {\n display: loaded.value ? 'block' : 'none',\n },\n },\n h('canvas', {\n id,\n height: 400,\n }),\n ),\n ]\n },\n})\n"],"names":["parseChartConfig","config","type","ChartJS","defineComponent","props","isDarkMode","useDarkMode","chartElement","shallowRef","id","useId","loaded","ref","chartjs","destroyChart","renderChart","ChartJs","chartConfig","decodeData","data","onMounted","watchImmediate","nextTick","onUnmounted","h","LoadingIcon"],"mappings":"kSAiBA,MAAMA,EAAmB,CACvBC,EACAC,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B,EACL,MAAO,kBACP,MAAO,CACL,QAASI,EAAO,MAAQ,QAAU,MACpC,CACF,EACAa,EAAE,SAAU,CACV,GAAAf,EACA,OAAQ,GACV,CAAC,CACH,CACF,CACF,CACF,CAAC"}
@@ -1,58 +0,0 @@
1
- import * as vue from 'vue';
2
- import { PropType, VNode } from 'vue';
3
-
4
- declare const _default: vue.DefineComponent<vue.ExtractPropTypes<{
5
- /**
6
- * ECharts config
7
- *
8
- * 图表配置
9
- */
10
- config: {
11
- type: StringConstructor;
12
- required: true;
13
- };
14
- /**
15
- * Chart title
16
- *
17
- * 图表标题
18
- */
19
- title: StringConstructor;
20
- /**
21
- * Chart config type
22
- *
23
- * 图表配置类型
24
- */
25
- type: {
26
- type: PropType<"js" | "json">;
27
- default: string;
28
- };
29
- }>, () => (VNode | null)[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
30
- /**
31
- * ECharts config
32
- *
33
- * 图表配置
34
- */
35
- config: {
36
- type: StringConstructor;
37
- required: true;
38
- };
39
- /**
40
- * Chart title
41
- *
42
- * 图表标题
43
- */
44
- title: StringConstructor;
45
- /**
46
- * Chart config type
47
- *
48
- * 图表配置类型
49
- */
50
- type: {
51
- type: PropType<"js" | "json">;
52
- default: string;
53
- };
54
- }>> & Readonly<{}>, {
55
- type: "js" | "json";
56
- }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
57
-
58
- export { _default as default };
@@ -1,8 +0,0 @@
1
- import{LoadingIcon as l,decodeData as h}from"@vuepress/helper/client";import{useEventListener as _,useDebounceFn as d}from"@vueuse/core";import{defineComponent as f,shallowRef as m,ref as g,onMounted as S,watch as w,nextTick as v,onUnmounted as y,h as s}from"vue";import{onContentUpdated as E}from"vuepress/client";import"../styles/echarts.css";import{u as C}from"../echarts-C40_Ts42.js";const R=(async()=>{}).constructor,U=(t,o,n,i)=>o==="js"?R("echarts","myChart",`let width,height,option,__echarts_config__;
2
- {
3
- ${t}
4
- __echarts_config__={width,height,option};
5
- }
6
- return __echarts_config__;
7
- `)(n,i):Promise.resolve({option:JSON.parse(t)});var P=f({name:"ECharts",props:{config:{type:String,required:!0},title:String,type:{type:String,default:"json"}},setup(t){const o=C(),n=m(),i=g(!1);let e=null;_("resize",d(()=>{e?.resize()},100));const a=()=>{e?.dispose(),e=null},c=async()=>{if(__VUEPRESS_SSR__)return;const r=await import("echarts");o.isSetup||(await o.setup?.(),o.isSetup=!0),e=r.init(n.value);const{option:p,...u}=await U(h(t.config),t.type,r,e);e.resize(u),e.setOption({...o.option,...p})};return E(async r=>{r==="mounted"&&(await c(),i.value=!0)}),S(()=>{__VUEPRESS_DEV__&&w(()=>t.config,async()=>{a(),await v(),await c()},{flush:"post"})}),y(a),()=>[t.title?s("div",{class:"echarts-title"},decodeURIComponent(t.title)):null,s("div",{class:"echarts-wrapper"},[s("div",{ref:n,class:"echarts-container"}),i.value?null:s(l,{class:"echarts-loading",height:360})])]}});export{P as default};
8
- //# sourceMappingURL=ECharts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ECharts.js","sources":["../../../src/client/components/ECharts.ts"],"sourcesContent":["import { LoadingIcon, decodeData } from '@vuepress/helper/client'\nimport { useDebounceFn, useEventListener } from '@vueuse/core'\nimport type { EChartsOption, EChartsType } from 'echarts'\n// oxlint-disable-next-line import/no-namespace\nimport type * as ECharts from 'echarts'\nimport type { PropType, VNode } from 'vue'\nimport {\n defineComponent,\n h,\n nextTick,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n watch,\n} from 'vue'\nimport { onContentUpdated } from 'vuepress/client'\n\nimport { useEChartsConfig } from '../helpers/index.js'\nimport '../styles/echarts.css'\n\ninterface EChartsConfig {\n width?: number\n height?: number\n option: EChartsOption\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst AsyncFunction = (async (): Promise<void> => {}).constructor\n\nconst parseEChartsConfig = (\n config: string,\n type: 'js' | 'json',\n echarts: typeof ECharts,\n instance: EChartsType,\n): Promise<EChartsConfig> => {\n if (type === 'js') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, new-cap\n const runner = AsyncFunction(\n 'echarts',\n 'myChart',\n `\\\nlet width,height,option,__echarts_config__;\n{\n${config}\n__echarts_config__={width,height,option};\n}\nreturn __echarts_config__;\n`,\n )\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return runner(echarts, instance) as Promise<EChartsConfig>\n }\n\n return Promise.resolve({ option: JSON.parse(config) as EChartsOption })\n}\n\nexport default defineComponent({\n name: 'ECharts',\n\n props: {\n /**\n * ECharts config\n *\n * 图表配置\n */\n config: {\n type: String,\n required: true,\n },\n\n /**\n * Chart title\n *\n * 图表标题\n */\n title: String,\n\n /**\n * Chart config type\n *\n * 图表配置类型\n */\n type: {\n type: String as PropType<'js' | 'json'>,\n default: 'json',\n },\n },\n\n setup(props) {\n const echartsConfig = useEChartsConfig()\n const echartsContainer = shallowRef<HTMLElement>()\n\n const loaded = ref(false)\n\n let instance: EChartsType | null = null\n\n useEventListener(\n 'resize',\n useDebounceFn(() => {\n instance?.resize()\n }, 100),\n )\n\n const destroyECharts = (): void => {\n instance?.dispose()\n instance = null\n }\n\n const renderECharts = async (): Promise<void> => {\n if (__VUEPRESS_SSR__) return\n\n const echarts = await import(/* webpackChunkName: \"echarts\" */ 'echarts')\n\n if (!echartsConfig.isSetup) {\n await echartsConfig.setup?.()\n echartsConfig.isSetup = true\n }\n\n instance = echarts.init(echartsContainer.value)\n\n const { option, ...size } = await parseEChartsConfig(\n decodeData(props.config),\n props.type,\n echarts,\n instance,\n )\n\n instance.resize(size)\n instance.setOption({ ...echartsConfig.option, ...option })\n }\n\n onContentUpdated(async (reason) => {\n if (reason === 'mounted') {\n await renderECharts()\n loaded.value = true\n }\n })\n\n onMounted(() => {\n if (!__VUEPRESS_DEV__) return\n\n // config must be changed if type is changed, so no need to watch it\n watch(\n () => props.config,\n async () => {\n destroyECharts()\n await nextTick()\n await renderECharts()\n },\n { flush: 'post' },\n )\n })\n\n onUnmounted(destroyECharts)\n\n return (): (VNode | null)[] => [\n props.title\n ? h('div', { class: 'echarts-title' }, decodeURIComponent(props.title))\n : null,\n h('div', { class: 'echarts-wrapper' }, [\n h('div', {\n ref: echartsContainer,\n class: 'echarts-container',\n }),\n loaded.value\n ? null\n : h(LoadingIcon, { class: 'echarts-loading', height: 360 }),\n ]),\n ]\n },\n})\n"],"names":["AsyncFunction","parseEChartsConfig","config","type","echarts","instance","ECharts","defineComponent","props","echartsConfig","useEChartsConfig","echartsContainer","shallowRef","loaded","ref","useEventListener","useDebounceFn","destroyECharts","renderECharts","option","size","decodeData","onContentUpdated","reason","onMounted","watch","nextTick","onUnmounted","h","LoadingIcon"],"mappings":"oYA4BA,MAAMA,GAAiB,SAA2B,CAAC,GAAG,YAEhDC,EAAqB,CACzBC,EACAC,EACAC,EACAC,IAEIF,IAAS,KAEIH,EACb,UACA,UACA;AAAA;AAAA,EAGJE,CAAM;AAAA;AAAA;AAAA;AAAA,CAKJ,EAGcE,EAASC,CAAQ,EAG1B,QAAQ,QAAQ,CAAE,OAAQ,KAAK,MAAMH,CAAM,CAAmB,CAAC,EAGxE,IAAAI,EAAeC,EAAgB,CAC7B,KAAM,UAEN,MAAO,CAML,OAAQ,CACN,KAAM,OACN,SAAU,EACZ,EAOA,MAAO,OAOP,KAAM,CACJ,KAAM,OACN,QAAS,MACX,CACF,EAEA,MAAMC,EAAO,CACX,MAAMC,EAAgBC,EAAAA,EAChBC,EAAmBC,IAEnBC,EAASC,EAAI,EAAK,EAExB,IAAIT,EAA+B,KAEnCU,EACE,SACAC,EAAc,IAAM,CAClBX,GAAU,OAAA,CACZ,EAAG,GAAG,CACR,EAEA,MAAMY,EAAiB,IAAY,CACjCZ,GAAU,UACVA,EAAW,IACb,EAEMa,EAAgB,SAA2B,CAC/C,GAAI,iBAAkB,OAEtB,MAAMd,EAAU,KAAM,QAAyC,SAAS,EAEnEK,EAAc,UACjB,MAAMA,EAAc,QAAA,EACpBA,EAAc,QAAU,IAG1BJ,EAAWD,EAAQ,KAAKO,EAAiB,KAAK,EAE9C,KAAM,CAAE,OAAAQ,EAAQ,GAAGC,CAAK,EAAI,MAAMnB,EAChCoB,EAAWb,EAAM,MAAM,EACvBA,EAAM,KACNJ,EACAC,CACF,EAEAA,EAAS,OAAOe,CAAI,EACpBf,EAAS,UAAU,CAAE,GAAGI,EAAc,OAAQ,GAAGU,CAAO,CAAC,CAC3D,EAEA,OAAAG,EAAiB,MAAOC,GAAW,CAC7BA,IAAW,YACb,MAAML,EAAAA,EACNL,EAAO,MAAQ,GAEnB,CAAC,EAEDW,EAAU,IAAM,CACT,kBAGLC,EACE,IAAMjB,EAAM,OACZ,SAAY,CACVS,IACA,MAAMS,EAAAA,EACN,MAAMR,EAAAA,CACR,EACA,CAAE,MAAO,MAAO,CAClB,CACF,CAAC,EAEDS,EAAYV,CAAc,EAEnB,IAAwB,CAC7BT,EAAM,MACFoB,EAAE,MAAO,CAAE,MAAO,eAAgB,EAAG,mBAAmBpB,EAAM,KAAK,CAAC,EACpE,KACJoB,EAAE,MAAO,CAAE,MAAO,iBAAkB,EAAG,CACrCA,EAAE,MAAO,CACP,IAAKjB,EACL,MAAO,mBACT,CAAC,EACDE,EAAO,MACH,KACAe,EAAEC,EAAa,CAAE,MAAO,kBAAmB,OAAQ,GAAI,CAAC,CAC9D,CAAC,CACH,CACF,CACF,CAAC"}
@@ -1,46 +0,0 @@
1
- import * as vue from 'vue';
2
- import { PropType, VNode } from 'vue';
3
-
4
- declare const _default: vue.DefineComponent<vue.ExtractPropTypes<{
5
- /**
6
- * Flowchart code content
7
- *
8
- * 流程图代码内容
9
- */
10
- code: {
11
- type: StringConstructor;
12
- required: true;
13
- };
14
- /**
15
- * Flowchart preset
16
- *
17
- * 流程图预设
18
- */
19
- preset: {
20
- type: PropType<"ant" | "pie" | "vue">;
21
- default: string;
22
- };
23
- }>, () => (VNode | null)[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
24
- /**
25
- * Flowchart code content
26
- *
27
- * 流程图代码内容
28
- */
29
- code: {
30
- type: StringConstructor;
31
- required: true;
32
- };
33
- /**
34
- * Flowchart preset
35
- *
36
- * 流程图预设
37
- */
38
- preset: {
39
- type: PropType<"ant" | "pie" | "vue">;
40
- default: string;
41
- };
42
- }>> & Readonly<{}>, {
43
- preset: "ant" | "pie" | "vue";
44
- }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
45
-
46
- export { _default as default };
@@ -1,2 +0,0 @@
1
- import{LoadingIcon as h,decodeData as v}from"@vuepress/helper/client";import{useEventListener as F,useDebounceFn as b}from"@vueuse/core";import{defineComponent as y,useId as _,toRefs as E,shallowRef as C,ref as s,onMounted as D,watch as S,nextTick as g,onUnmounted as x,h as u}from"vue";import{onContentUpdated as A}from"vuepress/client";import"../styles/flowchart.css";var i={x:0,y:0,"line-width":2,"line-length":40,"text-margin":8,"font-size":14,"font-color":"#8DA1AC","line-color":"#8DA1AC","element-color":"black",fill:"white","yes-text":"Yes","no-text":"No","arrow-end":"block",scale:1},R={...i,symbols:{start:{class:"start-element","font-color":"#fff",fill:"#595959","line-width":0},end:{class:"end-element","font-color":"#fff",fill:"#595959","line-width":0},operation:{class:"operation-element","font-color":"#fff",fill:"#1890ff","line-width":0},inputoutput:{class:"inputoutput-element","font-color":"#fff",fill:"#1890ff","line-width":0},subroutine:{class:"subroutine-element","font-color":"#fff",fill:"#FF485E","element-color":"#fff","line-color":"red"},condition:{class:"condition-element","font-color":"#fff",fill:"#FF485E","line-width":0},parallel:{class:"parallel-element","font-color":"#fff",fill:"#1890ff","line-width":0}}},k={...i,"line-width":1,symbols:{start:{class:"start-element",fill:"#ccc","line-color":"#5c6ac4","font-color":"#000"},end:{class:"end-element",fill:"#ccc","line-color":"#5c6ac4","font-color":"#000"},operation:{class:"operation-element",fill:"#f1f1f1","line-color":"#5c6ac4","font-color":"#000"},inputoutput:{class:"inputoutput-element",fill:"#f1f1f1","line-color":"#5c6ac4","font-color":"#000"},subroutine:{class:"subroutine-element",fill:"#f1f1f1","line-color":"#5c6ac4","font-color":"#000"},condition:{class:"condition-element",fill:"#f1f1f1","line-color":"#5c6ac4","font-color":"#000"},parallel:{class:"parallel-element",fill:"#f1f1f1","line-color":"#5c6ac4","font-color":"#000"}}},U={...i,symbols:{start:{class:"start-element","font-color":"#fff",fill:"#2F495F","line-width":0},end:{class:"end-element","font-color":"#fff",fill:"#2F495F","line-width":0},operation:{class:"operation-element","font-color":"#fff",fill:"#00BC7D","line-width":0},inputoutput:{class:"inputoutput-element","font-color":"#fff",fill:"#EB4D5D","line-width":0},subroutine:{class:"subroutine-element","font-color":"#fff",fill:"#937AC4","element-color":"#fff","line-color":"red"},condition:{class:"condition-element","font-color":"#fff",fill:"#FFB500","line-width":0},parallel:{class:"parallel-element","font-color":"#fff",fill:"#2F495F","line-width":0}}};const d={ant:R,vue:U,pie:k},p=l=>l<419?.8:l>1280?1:.9;var B=y({name:"FlowChart",props:{code:{type:String,required:!0},preset:{type:String,default:"vue"}},setup(l){const n=_(),{code:r,preset:m}=E(l),w=C(),f=s(!1),t=s(1);let o=null;F("resize",b(()=>{if(o){const e=p(window.innerWidth);t.value!==e&&(t.value=e,o.draw(n,{...d[l.preset],scale:e}))}},100));const c=()=>{o?.clean(),o=null},a=async()=>{if(__VUEPRESS_SSR__)return;const{parse:e}=await import("flowchart.ts");o=e(v(r.value)),t.value=p(window.innerWidth),f.value=!0,o.draw(n,{...d[l.preset],scale:t.value})};return A(async e=>{e==="mounted"&&await a()}),D(()=>{__VUEPRESS_DEV__&&S([r,m],async()=>{c(),await g(),await a()},{flush:"post"})}),x(c),()=>[f.value?null:u(h,{class:"flowchart-loading",height:192}),u("div",{ref:w,class:["flowchart-wrapper",l.preset],id:n,style:{display:f.value?"block":"none"}})]}});export{B as default};
2
- //# sourceMappingURL=FlowChart.js.map