@slidev/client 52.14.0 → 52.14.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/modules/mermaid.ts +14 -1
- package/package.json +12 -12
- package/setup/code-runners.ts +5 -5
package/modules/mermaid.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import mermaidRenderers from '#slidev/setups/mermaid-renderer'
|
|
1
2
|
import { clearUndefined } from '@antfu/utils'
|
|
2
3
|
import lz from 'lz-string'
|
|
3
4
|
import mermaid from 'mermaid/dist/mermaid.esm.mjs'
|
|
@@ -17,12 +18,24 @@ export async function renderMermaid(lzEncoded: string, options: any) {
|
|
|
17
18
|
if (_cache)
|
|
18
19
|
return _cache
|
|
19
20
|
|
|
21
|
+
const code = lz.decompressFromBase64(lzEncoded)
|
|
22
|
+
|
|
23
|
+
// custom renderer
|
|
24
|
+
for (const setup of mermaidRenderers) {
|
|
25
|
+
const renderer = await setup()
|
|
26
|
+
if (renderer) {
|
|
27
|
+
const svg = await renderer(code, options)
|
|
28
|
+
cache.set(key, svg)
|
|
29
|
+
return svg
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// fallback: existing mermaid
|
|
20
34
|
mermaid.initialize({
|
|
21
35
|
startOnLoad: false,
|
|
22
36
|
...clearUndefined(await setupMermaid() || {}),
|
|
23
37
|
...clearUndefined(options),
|
|
24
38
|
})
|
|
25
|
-
const code = lz.decompressFromBase64(lzEncoded)
|
|
26
39
|
const id = makeId()
|
|
27
40
|
const { svg } = await mermaid.render(id, code, containerElement)
|
|
28
41
|
cache.set(key, svg)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "52.14.
|
|
4
|
+
"version": "52.14.1",
|
|
5
5
|
"description": "Presentation slides for developers",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,18 +29,18 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@antfu/utils": "^9.3.0",
|
|
32
|
-
"@iconify-json/carbon": "^1.2.
|
|
32
|
+
"@iconify-json/carbon": "^1.2.19",
|
|
33
33
|
"@iconify-json/ph": "^1.2.2",
|
|
34
34
|
"@iconify-json/svg-spinners": "^1.2.4",
|
|
35
|
-
"@shikijs/engine-javascript": "^4.0.
|
|
36
|
-
"@shikijs/monaco": "^4.0.
|
|
37
|
-
"@shikijs/vitepress-twoslash": "^4.0.
|
|
35
|
+
"@shikijs/engine-javascript": "^4.0.1",
|
|
36
|
+
"@shikijs/monaco": "^4.0.1",
|
|
37
|
+
"@shikijs/vitepress-twoslash": "^4.0.1",
|
|
38
38
|
"@slidev/rough-notation": "^0.1.0",
|
|
39
39
|
"@typescript/ata": "^0.9.8",
|
|
40
|
-
"@unhead/vue": "^2.1.
|
|
41
|
-
"@unocss/extractor-mdc": "^66.6.
|
|
42
|
-
"@unocss/preset-mini": "^66.6.
|
|
43
|
-
"@unocss/reset": "^66.6.
|
|
40
|
+
"@unhead/vue": "^2.1.10",
|
|
41
|
+
"@unocss/extractor-mdc": "^66.6.3",
|
|
42
|
+
"@unocss/preset-mini": "^66.6.3",
|
|
43
|
+
"@unocss/reset": "^66.6.3",
|
|
44
44
|
"@vueuse/core": "^14.2.1",
|
|
45
45
|
"@vueuse/math": "^14.2.1",
|
|
46
46
|
"@vueuse/motion": "^3.0.3",
|
|
@@ -56,15 +56,15 @@
|
|
|
56
56
|
"nanotar": "^0.3.0",
|
|
57
57
|
"pptxgenjs": "^4.0.1",
|
|
58
58
|
"recordrtc": "^5.6.2",
|
|
59
|
-
"shiki": "^4.0.
|
|
59
|
+
"shiki": "^4.0.1",
|
|
60
60
|
"shiki-magic-move": "^1.2.1",
|
|
61
61
|
"typescript": "^5.9.3",
|
|
62
62
|
"unocss": "^66.6.2",
|
|
63
63
|
"vue": "^3.5.29",
|
|
64
64
|
"vue-router": "^5.0.3",
|
|
65
65
|
"yaml": "^2.8.2",
|
|
66
|
-
"@slidev/parser": "52.14.
|
|
67
|
-
"@slidev/types": "52.14.
|
|
66
|
+
"@slidev/parser": "52.14.1",
|
|
67
|
+
"@slidev/types": "52.14.1"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"vite": "^7.3.1"
|
package/setup/code-runners.ts
CHANGED
|
@@ -71,16 +71,16 @@ function runJavaScript(code: string): CodeRunnerOutputs {
|
|
|
71
71
|
vmConsole.info = vmConsole.log = vmConsole.debug = vmConsole.warn = vmConsole.error = logger
|
|
72
72
|
vmConsole.clear = () => result.value.length = 0
|
|
73
73
|
try {
|
|
74
|
-
const
|
|
74
|
+
const wrappedCode = `return async (console, __slidev_import, __slidev_on_error) => {
|
|
75
75
|
${configs.monacoRunUseStrict ? `"use strict";` : ''}
|
|
76
76
|
try {
|
|
77
|
-
${
|
|
77
|
+
${fixupCode(code)}
|
|
78
78
|
} catch (e) {
|
|
79
79
|
__slidev_on_error(e)
|
|
80
80
|
}
|
|
81
81
|
}`
|
|
82
82
|
// eslint-disable-next-line no-new-func
|
|
83
|
-
;(new Function(
|
|
83
|
+
;(new Function(wrappedCode)())(vmConsole, (specifier: string) => {
|
|
84
84
|
const mod = deps[specifier]
|
|
85
85
|
if (!mod)
|
|
86
86
|
throw new Error(`Module not found: ${specifier}.\nAvailable modules: ${Object.keys(deps).join(', ')}. Please refer to https://sli.dev/custom/config-code-runners#additional-runner-dependencies`)
|
|
@@ -154,7 +154,7 @@ function runJavaScript(code: string): CodeRunnerOutputs {
|
|
|
154
154
|
return textRep
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
function
|
|
157
|
+
function fixupCode(code: string) {
|
|
158
158
|
// The reflect-metadata runtime is available, so allow that to go through
|
|
159
159
|
code = code.replace(`import "reflect-metadata"`, '').replace(`require("reflect-metadata")`, '')
|
|
160
160
|
// Transpiled typescript sometimes contains an empty export, remove it.
|
|
@@ -181,7 +181,7 @@ export async function runTypeScript(code: string) {
|
|
|
181
181
|
},
|
|
182
182
|
}).outputText
|
|
183
183
|
|
|
184
|
-
const importRegex =
|
|
184
|
+
const importRegex = /\bimport\s*\((.+)\)/g
|
|
185
185
|
code = code.replace(importRegex, (_full, specifier) => `__slidev_import(${specifier})`)
|
|
186
186
|
|
|
187
187
|
return runJavaScript(code)
|