From cd7f926e7f3650b76bcaa695b14e4699549c1ab4 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Thu, 25 Jul 2024 09:44:49 +0800 Subject: [PATCH 1/3] fix: remove usage of `Array.prototype.toReversed` --- packages/slidev/node/setups/transformers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/slidev/node/setups/transformers.ts b/packages/slidev/node/setups/transformers.ts index 75ed08956a..798e46f7d0 100644 --- a/packages/slidev/node/setups/transformers.ts +++ b/packages/slidev/node/setups/transformers.ts @@ -9,7 +9,7 @@ export default async function setupTransformers(roots: string[]) { postCodeblock: [], post: [], } - for (const r of returns.toReversed()) { + for (const r of [...returns].reverse()) { if (r.pre) result.pre.push(...r.pre) if (r.preCodeblock) From 2256a581a64c00ba5aa32279c6e41cb7e8a75604 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Thu, 25 Jul 2024 11:37:27 +0800 Subject: [PATCH 2/3] chore: release v0.49.22 --- docs/package.json | 2 +- package.json | 2 +- packages/client/package.json | 2 +- packages/create-app/package.json | 2 +- packages/create-app/template/package.json | 2 +- packages/create-theme/package.json | 2 +- packages/create-theme/template/package.json | 4 ++-- packages/parser/package.json | 2 +- packages/slidev/package.json | 2 +- packages/types/package.json | 2 +- packages/vscode/package.json | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/package.json b/docs/package.json index 0a7405458c..f55aef2fb4 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,7 +1,7 @@ { "name": "docs", "type": "module", - "version": "0.49.21", + "version": "0.49.22", "private": true, "packageManager": "pnpm@9.6.0", "scripts": { diff --git a/package.json b/package.json index 486b901492..13fd778f86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "type": "module", - "version": "0.49.21", + "version": "0.49.22", "private": true, "packageManager": "pnpm@9.6.0", "engines": { diff --git a/packages/client/package.json b/packages/client/package.json index aa48ad67b5..e5d08d38d0 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,7 +1,7 @@ { "name": "@slidev/client", "type": "module", - "version": "0.49.21", + "version": "0.49.22", "description": "Presentation slides for developers", "author": "antfu ", "license": "MIT", diff --git a/packages/create-app/package.json b/packages/create-app/package.json index 0c9b9defbe..baf2ede41b 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,7 +1,7 @@ { "name": "create-slidev", "type": "module", - "version": "0.49.21", + "version": "0.49.22", "description": "Create starter template for Slidev", "author": "antfu ", "license": "MIT", diff --git a/packages/create-app/template/package.json b/packages/create-app/template/package.json index c05f1271c1..e77bda9fb1 100644 --- a/packages/create-app/template/package.json +++ b/packages/create-app/template/package.json @@ -8,7 +8,7 @@ "export": "slidev export" }, "dependencies": { - "@slidev/cli": "^0.49.21", + "@slidev/cli": "^0.49.22", "@slidev/theme-default": "latest", "@slidev/theme-seriph": "latest", "vue": "^3.4.33" diff --git a/packages/create-theme/package.json b/packages/create-theme/package.json index 26224ff65a..44f5c54d7b 100644 --- a/packages/create-theme/package.json +++ b/packages/create-theme/package.json @@ -1,7 +1,7 @@ { "name": "create-slidev-theme", "type": "module", - "version": "0.49.21", + "version": "0.49.22", "description": "Create starter theme template for Slidev", "author": "antfu ", "license": "MIT", diff --git a/packages/create-theme/template/package.json b/packages/create-theme/template/package.json index b0ceadd9b8..521ba158d3 100644 --- a/packages/create-theme/template/package.json +++ b/packages/create-theme/template/package.json @@ -14,11 +14,11 @@ "screenshot": "slidev export example.md --format png" }, "dependencies": { - "@slidev/types": "^0.49.21", + "@slidev/types": "^0.49.22", "prism-theme-vars": "^0.2.5" }, "devDependencies": { - "@slidev/cli": "^0.49.21" + "@slidev/cli": "^0.49.22" }, "//": "Learn more: https://sli.dev/guide/write-theme.html", "slidev": { diff --git a/packages/parser/package.json b/packages/parser/package.json index cef4244254..f8d37ca7be 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@slidev/parser", - "version": "0.49.21", + "version": "0.49.22", "description": "Markdown parser for Slidev", "author": "antfu ", "license": "MIT", diff --git a/packages/slidev/package.json b/packages/slidev/package.json index 3d80ff3a27..4ac690998f 100644 --- a/packages/slidev/package.json +++ b/packages/slidev/package.json @@ -1,7 +1,7 @@ { "name": "@slidev/cli", "type": "module", - "version": "0.49.21", + "version": "0.49.22", "description": "Presentation slides for developers", "author": "antfu ", "license": "MIT", diff --git a/packages/types/package.json b/packages/types/package.json index 845a1a0adb..1117bc47a1 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@slidev/types", - "version": "0.49.21", + "version": "0.49.22", "description": "Shared types declarations for Slidev", "author": "antfu ", "license": "MIT", diff --git a/packages/vscode/package.json b/packages/vscode/package.json index d653fa6046..88507d77b2 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -4,7 +4,7 @@ "displayName": "Slidev", "type": "module", "preview": true, - "version": "0.49.21", + "version": "0.49.22", "private": true, "description": "Slidev support for VS Code", "license": "MIT", From f4394e93cb874093f57e41d7db2c59eb480f814a Mon Sep 17 00:00:00 2001 From: _Kerman Date: Thu, 25 Jul 2024 23:08:07 +0800 Subject: [PATCH 3/3] docs: fix twoslash (#1782) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- docs/.vitepress/config.ts | 5 ++++- docs/.vitepress/scripts/prepare.js | 2 +- docs/custom/config-code-runners.md | 8 ++++++++ docs/custom/config-context-menu.md | 7 +++++++ docs/custom/config-highlighter.md | 11 ++++++----- docs/custom/config-parser.md | 4 ++-- docs/custom/config-routes.md | 3 +++ docs/custom/config-vite.md | 8 +++++++- docs/custom/config-vue.md | 5 +++++ docs/package.json | 11 +++++++---- package.json | 2 +- pnpm-lock.yaml | 27 ++++++++++++++++++--------- 12 files changed, 69 insertions(+), 24 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index a21b4d96cd..690e799607 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -65,7 +65,10 @@ export default defineConfig({ transformerTwoslash({ twoslashOptions: { // The @slidev/* installed in docs package are very old and should only be used in the homepage demo - vfsRoot: fileURLToPath(new URL('../../demo/starter/', import.meta.url)), + vfsRoot: fileURLToPath(import.meta.url), + compilerOptions: { + resolveJsonModule: true, + }, }, }), ], diff --git a/docs/.vitepress/scripts/prepare.js b/docs/.vitepress/scripts/prepare.js index 661b2a1962..3597981b4d 100644 --- a/docs/.vitepress/scripts/prepare.js +++ b/docs/.vitepress/scripts/prepare.js @@ -2,7 +2,7 @@ import { copy, remove } from 'fs-extra' async function main() { await remove('.vitepress/@slidev') - await copy('node_modules/@slidev', '.vitepress/@slidev', { dereference: true }) + await copy('node_modules/@slidev-old', '.vitepress/@slidev', { dereference: true }) } main() diff --git a/docs/custom/config-code-runners.md b/docs/custom/config-code-runners.md index a00ec319c9..f373c28493 100644 --- a/docs/custom/config-code-runners.md +++ b/docs/custom/config-code-runners.md @@ -8,7 +8,12 @@ By default, JavaScript, TypeScript runners are supported built-in. They run in t Create `./setup/code-runners.ts` with the following content: + + ```ts twoslash +declare const executePythonCodeRemotely: (code: string) => Promise +declare const sanitizeHtml: (html: string) => string +// ---cut--- import { defineCodeRunnersSetup } from '@slidev/types' export default defineCodeRunnersSetup(() => { @@ -35,6 +40,9 @@ export default defineCodeRunnersSetup(() => { The second argument `ctx` is the runner context, which contains the following properties: ```ts twoslash +import type { CodeRunnerOutputs } from '@slidev/types' +import type { CodeToHastOptions } from 'shiki' +// ---cut--- export interface CodeRunnerContext { /** * Options passed to runner via the `runnerOptions` prop. diff --git a/docs/custom/config-context-menu.md b/docs/custom/config-context-menu.md index 8b4b2b83f8..a8a1b2ccfe 100644 --- a/docs/custom/config-context-menu.md +++ b/docs/custom/config-context-menu.md @@ -6,9 +6,16 @@ Customize the context menu items in Slidev. Create `./setup/context-menu.ts` with the following content: + + ```ts twoslash +// ---cut--- import { defineContextMenuSetup } from '@slidev/types' +import { useNav } from '@slidev/client' import { computed } from 'vue' +// ---cut-start--- +// @ts-expect-error missing types +// ---cut-end--- import Icon3DCursor from '~icons/carbon/3d-cursor' export default defineContextMenuSetup((items) => { diff --git a/docs/custom/config-highlighter.md b/docs/custom/config-highlighter.md index da8cd5ce16..398270c769 100644 --- a/docs/custom/config-highlighter.md +++ b/docs/custom/config-highlighter.md @@ -30,14 +30,15 @@ If you want to add custom theme or language (TextMate grammar/themes in JSON), y ```ts twoslash -declare module '*.tmTheme.json' { - const value: any - export default value -} -// ---cut--- /* ./setup/shiki.ts */ import { defineShikiSetup } from '@slidev/types' +// ---cut-start--- +// @ts-expect-error missing types +// ---cut-end--- import customTheme from './customTheme.tmTheme.json' +// ---cut-start--- +// @ts-expect-error missing types +// ---cut-end--- import customLanguage from './customLanguage.tmLanguage.json' export default defineShikiSetup(() => { diff --git a/docs/custom/config-parser.md b/docs/custom/config-parser.md index 7218fa6796..0725bd3761 100644 --- a/docs/custom/config-parser.md +++ b/docs/custom/config-parser.md @@ -1,7 +1,7 @@ # Configure Pre-Parser ::: info -Custom pre-parsers are not supposed to be used too often. Please only use it if you really want to have your custom syntax. +Custom pre-parsers are not supposed to be used too often. Usually you can use [Transformers](./config-transformers) for custom syntaxes. ::: Slidev parses your presentation file (e.g. `slides.md`) in three steps: @@ -162,7 +162,7 @@ import { definePreparserSetup } from '@slidev/types' export default definePreparserSetup(() => { return [ { - transformSlide(content, frontmatter) { + async transformSlide(content, frontmatter) { if ('_scale' in frontmatter) { return [ ``, diff --git a/docs/custom/config-routes.md b/docs/custom/config-routes.md index 4ec1499d21..f87bccb81e 100644 --- a/docs/custom/config-routes.md +++ b/docs/custom/config-routes.md @@ -16,6 +16,9 @@ export default defineRoutesSetup((routes) => { ...routes, { path: '/my-page', + // ---cut-start--- + // @ts-expect-error missing types + // ---cut-end--- component: () => import('../pages/my-page.vue'), }, ] diff --git a/docs/custom/config-vite.md b/docs/custom/config-vite.md index fac5c8f77e..18fb5ef346 100644 --- a/docs/custom/config-vite.md +++ b/docs/custom/config-vite.md @@ -19,7 +19,13 @@ Slidev internally adds the following plugins to Vite: To configure the built-in plugins listed above, create a `vite.config.ts` with the following content. Please note that Slidev has some [default configurations](https://github.com/slidevjs/slidev/blob/main/packages/slidev/node/vite/index.ts) for those plugins, this usage will override some of them, which may potentially cause the app to break. Please treat this as **an advanced feature**, and make sure you know what you are doing before moving on. + + ```ts twoslash +/// +import type MarkdownIt from 'markdown-it' +declare const MyPlugin: (md: MarkdownIt) => void +// ---cut--- import { defineConfig } from 'vite' export default defineConfig({ @@ -31,7 +37,7 @@ export default defineConfig({ /* markdown-it options */ markdownItSetup(md) { /* custom markdown-it plugins */ - md.use(/* ... */) + md.use(MyPlugin/* ... */) }, }, /* options for other plugins */ diff --git a/docs/custom/config-vue.md b/docs/custom/config-vue.md index 0096963021..ed945fcf43 100644 --- a/docs/custom/config-vue.md +++ b/docs/custom/config-vue.md @@ -6,7 +6,12 @@ Slidev uses [Vue 3](https://v3.vuejs.org/) to render the application on the clie Create `./setup/main.ts` with the following content: + + ```ts twoslash +import type { Plugin } from 'vue' +declare const YourPlugin: Plugin +// ---cut--- import { defineAppSetup } from '@slidev/types' export default defineAppSetup(({ app, router }) => { diff --git a/docs/package.json b/docs/package.json index f55aef2fb4..caef451c8c 100644 --- a/docs/package.json +++ b/docs/package.json @@ -17,10 +17,13 @@ "devDependencies": { "@iconify/json": "^2.2.230", "@shikijs/vitepress-twoslash": "^1.11.1", - "@slidev/client": "0.34.3", - "@slidev/parser": "0.34.3", - "@slidev/theme-default": "0.21.2", - "@slidev/types": "0.34.3", + "@slidev-old/client": "npm:@slidev/client@0.34.3", + "@slidev-old/parser": "npm:@slidev/parser@0.34.3", + "@slidev-old/theme-default": "npm:@slidev/theme-default@0.21.2", + "@slidev-old/types": "npm:@slidev/types@0.34.3", + "@slidev/client": "workspace:*", + "@slidev/parser": "workspace:*", + "@slidev/types": "workspace:*", "@types/fs-extra": "^11.0.4", "@types/node": "^20.14.11", "@unocss/reset": "^0.61.5", diff --git a/package.json b/package.json index 13fd778f86..af92382d43 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "lint:fix": "nr lint --fix", "typecheck": "vue-tsc --noEmit", "docs": "pnpm -C docs run dev", - "docs:build": "pnpm -C docs run build && pnpm demo:build", + "docs:build": "pnpm run --filter {./docs}... build && pnpm demo:build", "release": "bumpp package.json packages/*/package.json docs/package.json --all -x \"zx scripts/update-versions.mjs\"", "test": "vitest test", "prepare": "simple-git-hooks" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d47b210054..99a357a072 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -251,18 +251,27 @@ importers: '@shikijs/vitepress-twoslash': specifier: ^1.11.1 version: 1.11.1(@nuxt/kit@3.11.2(rollup@4.19.0))(typescript@5.5.4) + '@slidev-old/client': + specifier: npm:@slidev/client@0.34.3 + version: '@slidev/client@0.34.3(rollup@4.19.0)(typescript@5.5.4)(vite@5.3.4(@types/node@20.14.11))' + '@slidev-old/parser': + specifier: npm:@slidev/parser@0.34.3 + version: '@slidev/parser@0.34.3' + '@slidev-old/theme-default': + specifier: npm:@slidev/theme-default@0.21.2 + version: '@slidev/theme-default@0.21.2' + '@slidev-old/types': + specifier: npm:@slidev/types@0.34.3 + version: '@slidev/types@0.34.3' '@slidev/client': - specifier: 0.34.3 - version: 0.34.3(rollup@4.19.0)(typescript@5.5.4)(vite@5.3.4(@types/node@20.14.11)) + specifier: workspace:* + version: link:../packages/client '@slidev/parser': - specifier: 0.34.3 - version: 0.34.3 - '@slidev/theme-default': - specifier: 0.21.2 - version: 0.21.2 + specifier: workspace:* + version: link:../packages/parser '@slidev/types': - specifier: 0.34.3 - version: 0.34.3 + specifier: workspace:* + version: link:../packages/types '@types/fs-extra': specifier: ^11.0.4 version: 11.0.4