@slidev/cli 0.48.0-beta.12 → 0.48.0-beta.14

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.
@@ -2,7 +2,7 @@ import {
2
2
  ViteSlidevPlugin,
3
3
  getIndexHtml,
4
4
  mergeViteConfigs
5
- } from "./chunk-E34YDWCY.mjs";
5
+ } from "./chunk-6NOVKCAJ.mjs";
6
6
  import "./chunk-O6TYYGU6.mjs";
7
7
  import {
8
8
  findPkgRoot
@@ -2496,7 +2496,7 @@ var require_semver2 = __commonJS({
2496
2496
  });
2497
2497
 
2498
2498
  // package.json
2499
- var version = "0.48.0-beta.12";
2499
+ var version = "0.48.0-beta.14";
2500
2500
 
2501
2501
  // node/common.ts
2502
2502
  import { existsSync, promises as fs } from "node:fs";
@@ -3448,6 +3448,7 @@ import fs6 from "node:fs/promises";
3448
3448
  import Markdown2 from "unplugin-vue-markdown/vite";
3449
3449
  import * as base64 from "js-base64";
3450
3450
  import { slash as slash3 } from "@antfu/utils";
3451
+ import { hash as getHash } from "ohash";
3451
3452
  import mila2 from "markdown-it-link-attributes";
3452
3453
  import mif from "markdown-it-footnote";
3453
3454
 
@@ -3582,6 +3583,7 @@ import { Optional } from "@mrdrogdrog/optional";
3582
3583
  // node/plugins/markdown.ts
3583
3584
  import { encode as encode2 } from "plantuml-encoder";
3584
3585
  import Mdc from "markdown-it-mdc";
3586
+ import { codeToKeyedTokens, createMagicMoveMachine } from "shiki-magic-move/core";
3585
3587
 
3586
3588
  // node/plugins/markdown-it-katex.ts
3587
3589
  import katex from "katex";
@@ -3922,36 +3924,53 @@ ${content}
3922
3924
  }
3923
3925
 
3924
3926
  // node/plugins/markdown.ts
3927
+ var shiki;
3928
+ var shikiOptions;
3925
3929
  async function createMarkdownPlugin(options, { markdown: mdOptions }) {
3926
3930
  const { data: { config }, roots, mode, entry, clientRoot } = options;
3927
3931
  const setups = [];
3928
3932
  const entryPath = slash3(entry);
3929
3933
  if (config.highlighter === "shiki") {
3930
- const MarkdownItShiki = await import("@shikijs/markdown-it").then((r) => r.default);
3931
- const { transformerTwoslash } = await import("@shikijs/vitepress-twoslash");
3932
- const options2 = await loadShikiSetups(clientRoot, roots);
3933
- const plugin = await MarkdownItShiki({
3934
+ const [
3935
+ options2,
3936
+ { getHighlighter, bundledLanguages },
3937
+ markdownItShiki,
3938
+ transformerTwoslash
3939
+ ] = await Promise.all([
3940
+ loadShikiSetups(clientRoot, roots),
3941
+ import("shiki").then(({ getHighlighter: getHighlighter2, bundledLanguages: bundledLanguages2 }) => ({ bundledLanguages: bundledLanguages2, getHighlighter: getHighlighter2 })),
3942
+ import("@shikijs/markdown-it/core").then(({ fromHighlighter }) => fromHighlighter),
3943
+ import("@shikijs/vitepress-twoslash").then(({ transformerTwoslash: transformerTwoslash2 }) => transformerTwoslash2)
3944
+ ]);
3945
+ shikiOptions = options2;
3946
+ shiki = await getHighlighter({
3934
3947
  ...options2,
3935
- transformers: [
3936
- ...options2.transformers || [],
3937
- transformerTwoslash({
3938
- explicitTrigger: true,
3939
- twoslashOptions: {
3940
- handbookOptions: {
3941
- noErrorValidation: true
3942
- }
3943
- }
3944
- }),
3945
- {
3946
- pre(pre) {
3947
- this.addClassToHast(pre, "slidev-code");
3948
- delete pre.properties.tabindex;
3949
- },
3950
- postprocess(code) {
3951
- return escapeVueInCode(code);
3948
+ langs: options2.langs ?? Object.keys(bundledLanguages),
3949
+ themes: "themes" in options2 ? Object.values(options2.themes) : [options2.theme]
3950
+ });
3951
+ const transformers = [
3952
+ ...options2.transformers || [],
3953
+ transformerTwoslash({
3954
+ explicitTrigger: true,
3955
+ twoslashOptions: {
3956
+ handbookOptions: {
3957
+ noErrorValidation: true
3952
3958
  }
3953
3959
  }
3954
- ]
3960
+ }),
3961
+ {
3962
+ pre(pre) {
3963
+ this.addClassToHast(pre, "slidev-code");
3964
+ delete pre.properties.tabindex;
3965
+ },
3966
+ postprocess(code) {
3967
+ return escapeVueInCode(code);
3968
+ }
3969
+ }
3970
+ ];
3971
+ const plugin = markdownItShiki(shiki, {
3972
+ ...options2,
3973
+ transformers
3955
3974
  });
3956
3975
  setups.push((md2) => md2.use(plugin));
3957
3976
  } else {
@@ -3992,6 +4011,8 @@ async function createMarkdownPlugin(options, { markdown: mdOptions }) {
3992
4011
  if (id === entryPath)
3993
4012
  return "";
3994
4013
  const monaco = config.monaco === true || config.monaco === mode ? transformMarkdownMonaco : truncateMancoMark;
4014
+ if (config.highlighter === "shiki")
4015
+ code = transformMagicMove(code, shiki, shikiOptions);
3995
4016
  code = transformSlotSugar(code);
3996
4017
  code = transformSnippet(code, options, id);
3997
4018
  code = transformMermaid(code);
@@ -4056,12 +4077,50 @@ function transformSlotSugar(md2) {
4056
4077
  lines[lines.length - 1] += "\n\n</template>";
4057
4078
  return lines.join("\n");
4058
4079
  }
4080
+ var reMagicMoveBlock = /^````(?:md|markdown) magic-move(?:[ ]*?({.*?})?([^\n]*?))?\n([\s\S]+?)^````$/mg;
4081
+ var reCodeBlock = /^```(\w+?)(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?(.*?))?\n([\s\S]+?)^```$/mg;
4082
+ function transformMagicMove(md2, shiki2, shikiOptions2) {
4083
+ const scripts = [];
4084
+ let count = 0;
4085
+ md2 = md2.replace(
4086
+ reMagicMoveBlock,
4087
+ (full, _options = "", _attrs = "", body) => {
4088
+ if (!shiki2 || !shikiOptions2)
4089
+ throw new Error("Shiki is required for Magic Move. You may need to set `highlighter: shiki` in your Slidev config.");
4090
+ const matches = Array.from(body.matchAll(reCodeBlock));
4091
+ if (!matches.length)
4092
+ throw new Error("Magic Move block must contain at least one code block");
4093
+ const langs = new Set(matches.map((i) => i[1]));
4094
+ if (langs.size > 1)
4095
+ throw new Error(`Magic Move block must contain code blocks with the same language, got ${Array.from(langs).join(", ")}`);
4096
+ const lang = Array.from(langs)[0];
4097
+ const magicMove = createMagicMoveMachine(
4098
+ (code) => codeToKeyedTokens(shiki2, code, {
4099
+ ...shikiOptions2,
4100
+ lang
4101
+ })
4102
+ );
4103
+ const steps = matches.map((i) => magicMove.commit((i[5] || "").trimEnd()));
4104
+ const id = `__magicMoveSteps_${getHash(body)}_${count++}`;
4105
+ scripts.push(`const ${id} = Object.freeze(${JSON.stringify(steps)})`);
4106
+ return `<ShikiMagicMove :steps='${id}' />`;
4107
+ }
4108
+ );
4109
+ if (scripts.length)
4110
+ md2 = `<script setup>
4111
+ ${scripts.join("\n")}</script>
4112
+
4113
+ ${md2}`;
4114
+ return md2;
4115
+ }
4059
4116
  function transformHighlighter(md2) {
4060
- return md2.replace(/^```(\w+?)(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?(.*?))?\n([\s\S]+?)^```/mg, (full, lang = "", rangeStr = "", options = "", attrs = "", code) => {
4061
- const ranges = rangeStr.split(/\|/g).map((i) => i.trim());
4062
- code = code.trimEnd();
4063
- options = options.trim() || "{}";
4064
- return `
4117
+ return md2.replace(
4118
+ reCodeBlock,
4119
+ (full, lang = "", rangeStr = "", options = "", attrs = "", code) => {
4120
+ const ranges = rangeStr.split(/\|/g).map((i) => i.trim());
4121
+ code = code.trimEnd();
4122
+ options = options.trim() || "{}";
4123
+ return `
4065
4124
  <CodeBlockWrapper v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>
4066
4125
 
4067
4126
  \`\`\`${lang}${attrs}
@@ -4069,7 +4128,8 @@ ${code}
4069
4128
  \`\`\`
4070
4129
 
4071
4130
  </CodeBlockWrapper>`;
4072
- });
4131
+ }
4132
+ );
4073
4133
  }
4074
4134
  function getCodeBlocks(md2) {
4075
4135
  const codeblocks = Array.from(md2.matchAll(/^```[\s\S]*?^```/mg)).map((m) => {
@@ -4,7 +4,7 @@ import {
4
4
  mergeViteConfigs,
5
5
  require_semver,
6
6
  version
7
- } from "./chunk-E34YDWCY.mjs";
7
+ } from "./chunk-6NOVKCAJ.mjs";
8
8
  import {
9
9
  createResolver,
10
10
  getRoots,
package/dist/cli.mjs CHANGED
@@ -5,10 +5,10 @@ import {
5
5
  resolveAddons,
6
6
  resolveOptions,
7
7
  resolveTheme
8
- } from "./chunk-YLK3KG3T.mjs";
8
+ } from "./chunk-CNK7IOIE.mjs";
9
9
  import {
10
10
  version
11
- } from "./chunk-E34YDWCY.mjs";
11
+ } from "./chunk-6NOVKCAJ.mjs";
12
12
  import {
13
13
  loadSetups
14
14
  } from "./chunk-O6TYYGU6.mjs";
@@ -277,7 +277,7 @@ cli.command(
277
277
  }).strict().help(),
278
278
  async (args) => {
279
279
  const { entry, theme, watch, base, download, out, inspect } = args;
280
- const { build } = await import("./build-CLZFYNH7.mjs");
280
+ const { build } = await import("./build-YCAT4XDK.mjs");
281
281
  for (const entryFile of entry) {
282
282
  const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
283
283
  if (download && !options.data.config.download)
@@ -482,13 +482,15 @@ function printInfo(options, port, remote, tunnelUrl, publicIp) {
482
482
  const query = remote ? `?password=${remote}` : "";
483
483
  const presenterPath = `${options.data.config.routerMode === "hash" ? "/#/" : "/"}presenter/${query}`;
484
484
  const entryPath = `${options.data.config.routerMode === "hash" ? "/#/" : "/"}entry${query}/`;
485
+ const overviewPath = `${options.data.config.routerMode === "hash" ? "/#/" : "/"}overview${query}/`;
485
486
  console.log();
486
487
  console.log(`${dim(" public slide show ")} > ${cyan(`http://localhost:${bold(port)}/`)}`);
487
488
  if (query)
488
489
  console.log(`${dim(" private slide show ")} > ${cyan(`http://localhost:${bold(port)}/${query}`)}`);
489
490
  console.log(`${dim(" presenter mode ")} > ${blue(`http://localhost:${bold(port)}${presenterPath}`)}`);
491
+ console.log(`${dim(" slides overview ")} > ${blue(`http://localhost:${bold(port)}${overviewPath}`)}`);
490
492
  if (options.inspect)
491
- console.log(`${dim(" inspector")} > ${yellow(`http://localhost:${bold(port)}/__inspect/`)}`);
493
+ console.log(`${dim(" vite inspector")} > ${yellow(`http://localhost:${bold(port)}/__inspect/`)}`);
492
494
  let lastRemoteUrl = "";
493
495
  if (remote !== void 0) {
494
496
  Object.values(os.networkInterfaces()).forEach((v) => (v || []).filter((details) => String(details.family).slice(-1) === "4" && !details.address.includes("127.0.0.1")).forEach(({ address }) => {
package/dist/index.mjs CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  createServer,
3
3
  parser,
4
4
  resolveOptions
5
- } from "./chunk-YLK3KG3T.mjs";
5
+ } from "./chunk-CNK7IOIE.mjs";
6
6
  import {
7
7
  ViteSlidevPlugin
8
- } from "./chunk-E34YDWCY.mjs";
8
+ } from "./chunk-6NOVKCAJ.mjs";
9
9
  import "./chunk-O6TYYGU6.mjs";
10
10
  import "./chunk-7HOZGSL4.mjs";
11
11
  import "./chunk-BXO7ZPPU.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
- "version": "0.48.0-beta.12",
3
+ "version": "0.48.0-beta.14",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -77,7 +77,8 @@
77
77
  "mlly": "^1.6.1",
78
78
  "monaco-editor": "^0.37.1",
79
79
  "nanoid": "^5.0.6",
80
- "open": "^10.0.3",
80
+ "ohash": "^1.1.3",
81
+ "open": "^10.0.4",
81
82
  "pdf-lib": "^1.17.1",
82
83
  "plantuml-encoder": "^1.4.0",
83
84
  "postcss-nested": "^6.0.1",
@@ -88,6 +89,7 @@
88
89
  "resolve-from": "^5.0.0",
89
90
  "resolve-global": "^2.0.0",
90
91
  "shiki": "^1.1.7",
92
+ "shiki-magic-move": "^0.1.0",
91
93
  "sirv": "^2.0.4",
92
94
  "typescript": "^5.3.3",
93
95
  "unocss": "^0.58.5",
@@ -102,11 +104,11 @@
102
104
  "vite-plugin-static-copy": "^1.0.1",
103
105
  "vite-plugin-vue-server-ref": "^0.4.2",
104
106
  "vitefu": "^0.2.5",
105
- "vue": "^3.4.19",
107
+ "vue": "^3.4.20",
106
108
  "yargs": "^17.7.2",
107
- "@slidev/parser": "0.48.0-beta.12",
108
- "@slidev/types": "0.48.0-beta.12",
109
- "@slidev/client": "0.48.0-beta.12"
109
+ "@slidev/client": "0.48.0-beta.14",
110
+ "@slidev/types": "0.48.0-beta.14",
111
+ "@slidev/parser": "0.48.0-beta.14"
110
112
  },
111
113
  "devDependencies": {
112
114
  "@hedgedoc/markdown-it-plugins": "^2.1.4",