@slidev/client 0.40.6 → 0.40.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builtin/Mermaid.vue +19 -9
- package/modules/mermaid.ts +3 -3
- package/package.json +8 -8
- package/shim.d.ts +5 -0
package/builtin/Mermaid.vue
CHANGED
|
@@ -13,7 +13,7 @@ pie
|
|
|
13
13
|
-->
|
|
14
14
|
|
|
15
15
|
<script setup lang="ts">
|
|
16
|
-
import {
|
|
16
|
+
import { getCurrentInstance, ref, watch, watchEffect } from 'vue'
|
|
17
17
|
import { renderMermaid } from '../modules/mermaid'
|
|
18
18
|
import ShadowRoot from '../internals/ShadowRoot.vue'
|
|
19
19
|
import { isDark } from '../logic/dark'
|
|
@@ -26,14 +26,24 @@ const props = defineProps<{
|
|
|
26
26
|
|
|
27
27
|
const vm = getCurrentInstance()
|
|
28
28
|
const el = ref<HTMLDivElement>()
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
const
|
|
29
|
+
const html = ref('')
|
|
30
|
+
|
|
31
|
+
watchEffect(async (onCleanup) => {
|
|
32
|
+
let disposed = false
|
|
33
|
+
onCleanup(() => {
|
|
34
|
+
disposed = true
|
|
35
|
+
})
|
|
36
|
+
const svg = await renderMermaid(
|
|
37
|
+
props.code || '',
|
|
38
|
+
{
|
|
39
|
+
theme: props.theme || (isDark.value ? 'dark' : undefined),
|
|
40
|
+
...vm!.attrs,
|
|
41
|
+
},
|
|
42
|
+
)
|
|
43
|
+
if (!disposed)
|
|
44
|
+
html.value = svg
|
|
45
|
+
})
|
|
46
|
+
|
|
37
47
|
const actualHeight = ref<number>()
|
|
38
48
|
|
|
39
49
|
watch(html, () => {
|
package/modules/mermaid.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import mermaid from 'mermaid/dist/mermaid'
|
|
1
|
+
import mermaid from 'mermaid/dist/mermaid.esm.mjs'
|
|
2
2
|
import { customAlphabet } from 'nanoid'
|
|
3
3
|
import { decode } from 'js-base64'
|
|
4
4
|
import { clearUndefined } from '@antfu/utils'
|
|
@@ -10,7 +10,7 @@ mermaid.initialize({ startOnLoad: false })
|
|
|
10
10
|
const nanoid = customAlphabet('abcedfghicklmn', 10)
|
|
11
11
|
const cache = new Map<string, string>()
|
|
12
12
|
|
|
13
|
-
export function renderMermaid(encoded: string, options: any) {
|
|
13
|
+
export async function renderMermaid(encoded: string, options: any) {
|
|
14
14
|
const key = encoded + JSON.stringify(options)
|
|
15
15
|
const _cache = cache.get(key)
|
|
16
16
|
if (_cache)
|
|
@@ -23,7 +23,7 @@ export function renderMermaid(encoded: string, options: any) {
|
|
|
23
23
|
})
|
|
24
24
|
const code = decode(encoded)
|
|
25
25
|
const id = nanoid()
|
|
26
|
-
const svg = mermaid.render(id, code)
|
|
26
|
+
const { svg } = await mermaid.render(id, code)
|
|
27
27
|
cache.set(key, svg)
|
|
28
28
|
return svg
|
|
29
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/client",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.9",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@antfu/utils": "^0.7.2",
|
|
19
|
-
"@unocss/reset": "^0.
|
|
19
|
+
"@unocss/reset": "^0.51.0",
|
|
20
20
|
"@vueuse/core": "^9.13.0",
|
|
21
21
|
"@vueuse/head": "^1.1.23",
|
|
22
22
|
"@vueuse/math": "^9.13.0",
|
|
@@ -29,20 +29,20 @@
|
|
|
29
29
|
"js-base64": "^3.7.5",
|
|
30
30
|
"js-yaml": "^4.1.0",
|
|
31
31
|
"katex": "^0.16.4",
|
|
32
|
-
"mermaid": "^
|
|
33
|
-
"monaco-editor": "^0.
|
|
32
|
+
"mermaid": "^10.1.0",
|
|
33
|
+
"monaco-editor": "^0.37.1",
|
|
34
34
|
"nanoid": "^4.0.2",
|
|
35
35
|
"prettier": "^2.8.7",
|
|
36
36
|
"recordrtc": "^5.6.2",
|
|
37
|
-
"resolve": "^1.22.
|
|
38
|
-
"unocss": "^0.
|
|
37
|
+
"resolve": "^1.22.2",
|
|
38
|
+
"unocss": "^0.51.0",
|
|
39
39
|
"vite-plugin-windicss": "^1.8.10",
|
|
40
40
|
"vue": "^3.2.47",
|
|
41
41
|
"vue-router": "^4.1.6",
|
|
42
42
|
"vue-starport": "^0.3.0",
|
|
43
43
|
"windicss": "^3.5.6",
|
|
44
|
-
"@slidev/parser": "0.40.
|
|
45
|
-
"@slidev/types": "0.40.
|
|
44
|
+
"@slidev/parser": "0.40.9",
|
|
45
|
+
"@slidev/types": "0.40.9"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"vite": "^4.2.1"
|
package/shim.d.ts
CHANGED