Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/KermanX/slidev into optiona…
Browse files Browse the repository at this point in the history
…l-localtunnel
  • Loading branch information
KermanX committed Feb 13, 2024
2 parents 9fb4ee5 + ac5d489 commit e9fcdb4
Show file tree
Hide file tree
Showing 14 changed files with 375 additions and 294 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "module",
"version": "0.47.4",
"version": "0.47.5",
"private": true,
"packageManager": "pnpm@8.15.1",
"engines": {
Expand All @@ -26,7 +26,7 @@
"@antfu/eslint-config": "^2.6.4",
"@antfu/ni": "^0.21.12",
"@antfu/utils": "^0.7.7",
"@shikijs/markdown-it": "^1.0.0-rc.0",
"@shikijs/markdown-it": "^1.1.1",
"@slidev/cli": "workspace:*",
"@slidev/parser": "workspace:*",
"@slidev/types": "workspace:*",
Expand All @@ -39,12 +39,12 @@
"@types/js-yaml": "^4.0.9",
"@types/katex": "^0.16.7",
"@types/markdown-it": "^13.0.7",
"@types/node": "^20.11.16",
"@types/node": "^20.11.17",
"@types/prismjs": "^1.26.3",
"@types/prompts": "^2.4.9",
"@types/recordrtc": "^5.6.14",
"@types/resolve": "^1.20.6",
"@types/semver": "^7.5.6",
"@types/semver": "^7.5.7",
"@types/yargs": "^17.0.32",
"@vueuse/core": "^10.7.2",
"bumpp": "^9.3.0",
Expand All @@ -58,12 +58,12 @@
"playwright-chromium": "^1.41.2",
"pnpm": "^8.15.1",
"rimraf": "^5.0.5",
"shiki": "^1.0.0-rc.0",
"shiki": "^1.1.1",
"simple-git-hooks": "^2.9.0",
"taze": "^0.13.3",
"tsup": "^8.0.1",
"tsup": "^8.0.2",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite": "^5.1.1",
"vitest": "^1.2.2",
"vue-tsc": "^1.8.27",
"zx": "^7.2.3"
Expand Down
18 changes: 15 additions & 3 deletions packages/client/builtin/VClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Learn more: https://sli.dev/guide/animations.html#click-animations
*/

import { createVNode, defineComponent } from 'vue'
import type { PropType, VNode } from 'vue'
import { Text, defineComponent, h } from 'vue'
import VClicks from './VClicks'

export default defineComponent({
Expand All @@ -21,17 +22,28 @@ export default defineComponent({
type: Boolean,
default: false,
},
wrapText: {
type: Function as PropType<(text: VNode) => VNode>,
default: (text: VNode) => h('span', text),
},
},
render() {
return createVNode(
return h(
VClicks,
{
every: 99999,
at: this.at,
hide: this.hide,
fade: this.fade,
},
{ default: this.$slots.default },
{
default: () =>
this.$slots.default?.().map(v =>
v.type === Text
? this.wrapText(v)
: v,
),
},
)
},
})
4 changes: 4 additions & 0 deletions packages/client/logic/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export function useSlideInfo(id: number | undefined): UseSlideInfo {
if (payload.id === id)
info.value = payload.data
})
import.meta.hot?.on('slidev-update-note', (payload) => {
if (payload.id === id && info.value.note.trim() !== payload.note.trim())
info.value = { ...info.value, ...payload }
})
}

return {
Expand Down
10 changes: 5 additions & 5 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slidev/client",
"version": "0.47.4",
"version": "0.47.5",
"description": "Presentation slides for developers",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand All @@ -20,9 +20,9 @@
},
"dependencies": {
"@antfu/utils": "^0.7.7",
"@iconify-json/carbon": "^1.1.28",
"@iconify-json/carbon": "^1.1.30",
"@iconify-json/ph": "^1.1.11",
"@shikijs/vitepress-twoslash": "^1.0.0-beta.5",
"@shikijs/vitepress-twoslash": "^1.1.1",
"@slidev/parser": "workspace:*",
"@slidev/types": "workspace:*",
"@unhead/vue": "^1.8.10",
Expand All @@ -46,10 +46,10 @@
"recordrtc": "^5.6.2",
"resolve": "^1.22.8",
"unocss": "^0.58.5",
"vue": "^3.4.15",
"vue": "^3.4.18",
"vue-router": "^4.2.5"
},
"devDependencies": {
"vite": "^5.0.12"
"vite": "^5.1.1"
}
}
6 changes: 5 additions & 1 deletion packages/client/setup/codemirror.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Ref, WritableComputedRef } from 'vue'
import { watch } from 'vue'
import * as CodeMirror from 'codemirror'
import * as _CodeMirror from 'codemirror'
import 'codemirror/mode/javascript/javascript'
import 'codemirror/mode/css/css'
import 'codemirror/mode/markdown/markdown'
Expand All @@ -9,6 +9,10 @@ import 'codemirror/mode/htmlmixed/htmlmixed'
import 'codemirror/addon/display/placeholder'
import 'codemirror/lib/codemirror.css'

// eslint-disable-next-line ts/ban-ts-comment
// @ts-expect-error
const CodeMirror: typeof _CodeMirror = _CodeMirror.fromTextArea ? _CodeMirror : globalThis.CodeMirror

export async function useCodeMirror(
textarea: Ref<HTMLTextAreaElement | null | undefined>,
input: Ref<string> | WritableComputedRef<string>,
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-slidev",
"type": "module",
"version": "0.47.4",
"version": "0.47.5",
"description": "Create starter template for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"export": "slidev export"
},
"dependencies": {
"@slidev/cli": "^0.47.4",
"@slidev/cli": "^0.47.5",
"@slidev/theme-default": "latest",
"@slidev/theme-seriph": "latest",
"vue": "^3.4.15"
"vue": "^3.4.18"
}
}
2 changes: 1 addition & 1 deletion packages/create-theme/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-slidev-theme",
"type": "module",
"version": "0.47.4",
"version": "0.47.5",
"description": "Create starter theme template for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-theme/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"screenshot": "slidev export example.md --format png"
},
"dependencies": {
"@slidev/types": "^0.47.4",
"@slidev/types": "^0.47.5",
"codemirror-theme-vars": "^0.1.2",
"prism-theme-vars": "^0.2.4"
},
"devDependencies": {
"@slidev/cli": "^0.47.4"
"@slidev/cli": "^0.47.5"
},
"//": "Learn more: https://sli.dev/themes/write-a-theme.html",
"slidev": {
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slidev/parser",
"version": "0.47.4",
"version": "0.47.5",
"description": "Markdown parser for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
21 changes: 18 additions & 3 deletions packages/slidev/node/plugins/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ export function createSlidesLoader(
if (type === 'json' && req.method === 'POST') {
const body = await getBodyJson(req)
const slide = data.slides[idx]
hmrPages.add(idx)

const onlyNoteChanged = Object.keys(body).length === 2
&& 'note' in body && body.raw === null
if (!onlyNoteChanged)
hmrPages.add(idx)

if (slide.source) {
Object.assign(slide.source, body)
Expand Down Expand Up @@ -173,7 +177,6 @@ export function createSlidesLoader(
if (
a?.content.trim() === b?.content.trim()
&& a?.title?.trim() === b?.title?.trim()
&& a?.note === b?.note
&& equal(a.frontmatter, b.frontmatter)
&& Object.entries(a.snippetsUsed ?? {}).every(([file, oldContent]) => {
try {
Expand All @@ -184,8 +187,20 @@ export function createSlidesLoader(
return false
}
})
)
) {
if (a?.note !== b?.note) {
ctx.server.ws.send({
type: 'custom',
event: 'slidev-update-note',
data: {
id: i,
note: b!.note || '',
noteHTML: md.render(b!.note || ''),
},
})
}
continue
}

ctx.server.ws.send({
type: 'custom',
Expand Down
22 changes: 11 additions & 11 deletions packages/slidev/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slidev/cli",
"version": "0.47.4",
"version": "0.47.5",
"description": "Presentation slides for developers",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down Expand Up @@ -49,19 +49,19 @@
},
"dependencies": {
"@antfu/utils": "^0.7.7",
"@iconify-json/carbon": "^1.1.28",
"@iconify-json/carbon": "^1.1.30",
"@iconify-json/ph": "^1.1.11",
"@lillallol/outline-pdf": "^4.0.0",
"@mrdrogdrog/optional": "^1.2.1",
"@shikijs/markdown-it": "^1.0.0-beta.5",
"@shikijs/twoslash": "^1.0.0-beta.5",
"@shikijs/vitepress-twoslash": "^1.0.0-beta.5",
"@shikijs/markdown-it": "^1.1.1",
"@shikijs/twoslash": "^1.1.1",
"@shikijs/vitepress-twoslash": "^1.1.1",
"@slidev/client": "workspace:*",
"@slidev/parser": "workspace:*",
"@slidev/types": "workspace:*",
"@unocss/extractor-mdc": "^0.58.5",
"@unocss/reset": "^0.58.5",
"@vitejs/plugin-vue": "^5.0.3",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"cli-progress": "^3.12.0",
"codemirror": "^5.65.5",
Expand All @@ -82,7 +82,7 @@
"markdown-it": "^14.0.0",
"markdown-it-footnote": "^4.0.0",
"markdown-it-link-attributes": "^4.0.1",
"markdown-it-mdc": "^0.2.1",
"markdown-it-mdc": "^0.2.3",
"mlly": "^1.5.0",
"monaco-editor": "^0.37.1",
"nanoid": "^5.0.5",
Expand All @@ -96,7 +96,7 @@
"resolve": "^1.22.8",
"resolve-from": "^5.0.0",
"resolve-global": "^2.0.0",
"shiki": "^1.0.0-beta.5",
"shiki": "^1.1.1",
"sirv": "^2.0.4",
"typescript": "^5.3.3",
"unocss": "^0.58.5",
Expand All @@ -105,18 +105,18 @@
"unplugin-vue-markdown": "^0.26.0",
"untun": "^0.1.3",
"uqr": "^0.1.2",
"vite": "^5.0.12",
"vite": "^5.1.1",
"vite-plugin-inspect": "^0.8.3",
"vite-plugin-remote-assets": "^0.4.1",
"vite-plugin-static-copy": "^1.0.1",
"vite-plugin-vue-server-ref": "^0.4.2",
"vitefu": "^0.2.5",
"vue": "^3.4.15",
"vue": "^3.4.18",
"yargs": "^17.7.2"
},
"devDependencies": {
"@hedgedoc/markdown-it-plugins": "^2.1.4",
"@types/plantuml-encoder": "^1.4.2",
"semver": "^7.5.4"
"semver": "^7.6.0"
}
}
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@slidev/types",
"version": "0.47.4",
"version": "0.47.5",
"description": "Shared types declarations for Slidev",
"author": "antfu <anthonyfu117@hotmail.com>",
"license": "MIT",
Expand Down
Loading

0 comments on commit e9fcdb4

Please sign in to comment.