|
1 | | -import { exec } from "child_process"; |
2 | | -// import { randomUUID } from "crypto" |
3 | | -import { unlinkSync, writeFileSync } from "fs"; |
| 1 | +export default {} |
| 2 | +// import { exec } from "child_process"; |
| 3 | +// // import { randomUUID } from "crypto" |
| 4 | +// import { unlinkSync, writeFileSync } from "fs"; |
4 | 5 |
|
5 | | -export async function renderDiagramToBase64URI( |
6 | | - diagram: string |
7 | | -): Promise<string> { |
8 | | - const diagramID = "diagram"; |
9 | | - // ?? randomUUID() |
10 | | - const diagramSourceFileName = `${diagramID}.txt`; |
11 | | - const diagramSVGFileName = `${diagramID}.svg`; |
| 6 | +// export async function renderDiagramToBase64URI( |
| 7 | +// diagram: string |
| 8 | +// ): Promise<string> { |
| 9 | +// const diagramID = "diagram"; |
| 10 | +// // ?? randomUUID() |
| 11 | +// const diagramSourceFileName = `${diagramID}.txt`; |
| 12 | +// const diagramSVGFileName = `${diagramID}.svg`; |
12 | 13 |
|
13 | | - writeFileSync(diagramSourceFileName, diagram); |
| 14 | +// writeFileSync(diagramSourceFileName, diagram); |
14 | 15 |
|
15 | | - await new Promise<void>((resolve, reject) => { |
16 | | - const diagram = exec( |
17 | | - `npx mmdc -i ${diagramSourceFileName} -o ${diagramSVGFileName}`, |
18 | | - { |
19 | | - cwd: process.cwd(), |
20 | | - timeout: 10000, |
21 | | - } |
22 | | - ); |
| 16 | +// await new Promise<void>((resolve, reject) => { |
| 17 | +// const diagram = exec( |
| 18 | +// `npx mmdc -i ${diagramSourceFileName} -o ${diagramSVGFileName}`, |
| 19 | +// { |
| 20 | +// cwd: process.cwd(), |
| 21 | +// timeout: 10000, |
| 22 | +// } |
| 23 | +// ); |
23 | 24 |
|
24 | | - diagram.on("exit", async (code) => { |
25 | | - // unlinkSync(diagramSourceFileName) |
26 | | - if (code === 0) { |
27 | | - resolve(); |
28 | | - } else { |
29 | | - console.log(`Error: ${code}`); |
30 | | - reject(); |
31 | | - } |
32 | | - }); |
33 | | - }); |
| 25 | +// diagram.on("exit", async (code) => { |
| 26 | +// // unlinkSync(diagramSourceFileName) |
| 27 | +// if (code === 0) { |
| 28 | +// resolve(); |
| 29 | +// } else { |
| 30 | +// console.log(`Error: ${code}`); |
| 31 | +// reject(); |
| 32 | +// } |
| 33 | +// }); |
| 34 | +// }); |
34 | 35 |
|
35 | | - const base64 = await new Promise<string>((resolve, reject) => { |
36 | | - exec(`base64 ${diagramSVGFileName}`, async (err, stdout) => { |
37 | | - unlinkSync(diagramSVGFileName); |
38 | | - if (err) reject(err); |
39 | | - resolve(stdout); |
40 | | - }); |
41 | | - }); |
| 36 | +// const base64 = await new Promise<string>((resolve, reject) => { |
| 37 | +// exec(`base64 ${diagramSVGFileName}`, async (err, stdout) => { |
| 38 | +// unlinkSync(diagramSVGFileName); |
| 39 | +// if (err) reject(err); |
| 40 | +// resolve(stdout); |
| 41 | +// }); |
| 42 | +// }); |
42 | 43 |
|
43 | | - const uri = `data:image/svg+xml;base64,${base64.trim()}`; |
| 44 | +// const uri = `data:image/svg+xml;base64,${base64.trim()}`; |
44 | 45 |
|
45 | | - return uri; |
46 | | -} |
| 46 | +// return uri; |
| 47 | +// } |
0 commit comments