@slidev/cli 51.7.1 → 51.8.0

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.
@@ -1,4 +1,4 @@
1
- import { resolveViteConfigs } from "./shared-RU9XA03U.js";
1
+ import { resolveViteConfigs } from "./shared-CIQE-F_F.js";
2
2
  import "./resolver-BShaA6qw.js";
3
3
  import fs from "node:fs/promises";
4
4
  import { join, resolve } from "node:path";
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
- import { getThemeMeta, loadSetups, parser, resolveAddons, resolveOptions, resolveTheme, updateFrontmatterPatch, version } from "./shared-RU9XA03U.js";
1
+ import { getThemeMeta, loadSetups, parser, resolveAddons, resolveOptions, resolveTheme, updateFrontmatterPatch, version } from "./shared-CIQE-F_F.js";
2
2
  import { getRoots, isInstalledGlobally, resolveEntry } from "./resolver-BShaA6qw.js";
3
- import { createServer } from "./serve-R48bjx01.js";
3
+ import { createServer } from "./serve-DgKBytqU.js";
4
4
  import { exec } from "node:child_process";
5
5
  import fs from "node:fs/promises";
6
6
  import os from "node:os";
@@ -295,7 +295,7 @@ cli.command("build [entry..]", "Build hostable SPA", (args) => exportOptions(com
295
295
  describe: "enable the inspect plugin for debugging"
296
296
  }).strict().help(), async (args) => {
297
297
  const { entry, theme, base, download, out, inspect } = args;
298
- const { build } = await import("./build-DZzwHGen.js");
298
+ const { build } = await import("./build-BCss6wHH.js");
299
299
  for (const entryFile of entry) {
300
300
  const options = await resolveOptions({
301
301
  entry: entryFile,
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ViteSlidevPlugin, createDataUtils, parser, resolveOptions } from "./shared-RU9XA03U.js";
1
+ import { ViteSlidevPlugin, createDataUtils, parser, resolveOptions } from "./shared-CIQE-F_F.js";
2
2
  import "./resolver-BShaA6qw.js";
3
- import { createServer } from "./serve-R48bjx01.js";
3
+ import { createServer } from "./serve-DgKBytqU.js";
4
4
 
5
5
  export { ViteSlidevPlugin, createDataUtils, createServer, parser, resolveOptions };
@@ -1,4 +1,4 @@
1
- import { resolveViteConfigs } from "./shared-RU9XA03U.js";
1
+ import { resolveViteConfigs } from "./shared-CIQE-F_F.js";
2
2
  import { join } from "node:path";
3
3
  import process from "node:process";
4
4
  import { createServer } from "vite";
@@ -43,7 +43,7 @@ import Vue from "@vitejs/plugin-vue";
43
43
  import VueJsx from "@vitejs/plugin-vue-jsx";
44
44
 
45
45
  //#region package.json
46
- var version = "51.7.1";
46
+ var version = "51.8.0";
47
47
 
48
48
  //#endregion
49
49
  //#region node/syntax/markdown-it/markdown-it-link.ts
@@ -615,7 +615,7 @@ async function setupIndexHtml({ mode, entry, clientRoot, userRoot, roots, data,
615
615
  ].filter((x) => x.content)
616
616
  }, ...inputs] });
617
617
  const baseInDev = mode === "dev" && base ? base.slice(0, -1) : "";
618
- main = main.replace("__ENTRY__", baseInDev + toAtFS(join(clientRoot, "main.ts"))).replace("<!-- body -->", body);
618
+ main = main.replace("__ENTRY__", baseInDev + encodeURI(toAtFS(join(clientRoot, "main.ts")))).replace("<!-- body -->", body);
619
619
  const html = await transformHtmlTemplate(unhead, main);
620
620
  return html;
621
621
  }
@@ -1183,14 +1183,7 @@ const templateSlides = {
1183
1183
  ];
1184
1184
  const slides = data.slides.map((_, idx) => {
1185
1185
  const no = idx + 1;
1186
- statements.push(
1187
- `import { meta as f${no} } from '${VIRTUAL_SLIDE_PREFIX}${no}/frontmatter'`,
1188
- // For some unknown reason, import error won't be caught by the error component. Catch it here.
1189
- `const load${no} = async () => {`,
1190
- ` try { return componentsCache[${idx}] ??= await import('${VIRTUAL_SLIDE_PREFIX}${no}/md') }`,
1191
- ` catch (e) { console.error('slide failed to load', e); return SlideError }`,
1192
- `}`
1193
- );
1186
+ statements.push(`import { meta as f${no} } from '${VIRTUAL_SLIDE_PREFIX}${no}/frontmatter'`, `const load${no} = async () => {`, ` try { return componentsCache[${idx}] ??= await import('${VIRTUAL_SLIDE_PREFIX}${no}/md') }`, ` catch (e) { console.error('slide failed to load', e); return SlideError }`, `}`);
1194
1187
  return `{ no: ${no}, meta: f${no}, load: load${no}, component: getAsyncComponent(${idx}, load${no}) }`;
1195
1188
  });
1196
1189
  return [
@@ -1807,16 +1800,16 @@ async function setupTransformers(roots) {
1807
1800
 
1808
1801
  //#endregion
1809
1802
  //#region node/syntax/transform/code-wrapper.ts
1810
- const reCodeBlock = /^```([\w'-]+)?\s*(?:\{([\w*,|-]+)\}\s*?(\{[^}]*\})?([^\r\n]*))?\r?\n([ \t]*\S[\s\S]*?)^```$/gm;
1803
+ const reCodeBlock = /^```([\w'-]+)?\s*(?:\[(.*?)\])?\s*(?:\{([\w*,|-]+)\}\s*?(\{[^}]*\})?([^\r\n]*))?\r?\n([ \t]*\S[\s\S]*?)^```$/gm;
1811
1804
  /**
1812
1805
  * Transform code block with wrapper
1813
1806
  */
1814
1807
  function transformCodeWrapper(ctx) {
1815
- ctx.s.replace(reCodeBlock, (full, lang = "", rangeStr = "", options = "", attrs = "", code) => {
1808
+ ctx.s.replace(reCodeBlock, (full, lang = "", title = "", rangeStr = "", options = "", attrs = "", code) => {
1816
1809
  const ranges = normalizeRangeStr(rangeStr);
1817
1810
  code = code.trimEnd();
1818
1811
  options = options.trim() || "{}";
1819
- return `\n<CodeBlockWrapper v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>\n\n\`\`\`${lang}${attrs}\n${code}\n\`\`\`\n\n</CodeBlockWrapper>`;
1812
+ return `\n<CodeBlockWrapper v-bind="${options}" :title='${JSON.stringify(title)}' :ranges='${JSON.stringify(ranges)}'>\n\n\`\`\`${lang}${title ? ` [${title}]` : ""}${attrs}\n${code}\n\`\`\`\n\n</CodeBlockWrapper>`;
1820
1813
  });
1821
1814
  }
1822
1815
 
@@ -1862,10 +1855,10 @@ function transformMagicMove(ctx) {
1862
1855
  const matches = Array.from(body.matchAll(reCodeBlock));
1863
1856
  if (!matches.length) throw new Error("Magic Move block must contain at least one code block");
1864
1857
  const defaultLineNumbers = parseLineNumbersOption(options) ?? ctx.options.data.config.lineNumbers;
1865
- const ranges = matches.map((i) => normalizeRangeStr(i[2]));
1858
+ const ranges = matches.map((i) => normalizeRangeStr(i[3]));
1866
1859
  const steps = matches.map((i) => {
1867
- const lineNumbers = parseLineNumbersOption(i[3]) ?? defaultLineNumbers;
1868
- return codeToKeyedTokens(ctx.options.utils.shiki, i[5].trimEnd(), {
1860
+ const lineNumbers = parseLineNumbersOption(i[4]) ?? defaultLineNumbers;
1861
+ return codeToKeyedTokens(ctx.options.utils.shiki, i[6].trimEnd(), {
1869
1862
  ...ctx.options.utils.shikiOptions,
1870
1863
  lang: i[1]
1871
1864
  }, lineNumbers);
@@ -2040,35 +2033,31 @@ const reMonacoWrite = /^\{monaco-write\}/;
2040
2033
  function transformSnippet({ s, slide, options }) {
2041
2034
  const watchFiles = options.data.watchFiles;
2042
2035
  const dir = path.dirname(slide.source?.filepath ?? options.entry ?? options.userRoot);
2043
- s.replace(
2044
- // eslint-disable-next-line regexp/no-super-linear-backtracking
2045
- /^<<<\s*(\S.*?)(#[\w-]+)?\s*(?:\s(\S+?))?\s*(\{.*)?$/gm,
2046
- (full, filepath = "", regionName = "", lang = "", meta = "") => {
2047
- const src = slash(/^@\//.test(filepath) ? path.resolve(options.userRoot, filepath.slice(2)) : path.resolve(dir, filepath));
2048
- meta = meta.trim();
2036
+ s.replace(/^<<<\s*(\S.*?)(#[\w-]+)?\s*(?:\s(\S+?))?\s*(\{.*)?$/gm, (full, filepath = "", regionName = "", lang = "", meta = "") => {
2037
+ const src = slash(/^@\//.test(filepath) ? path.resolve(options.userRoot, filepath.slice(2)) : path.resolve(dir, filepath));
2038
+ meta = meta.trim();
2039
+ lang = lang.trim();
2040
+ lang = lang || path.extname(filepath).slice(1);
2041
+ const isAFile = fs$1.statSync(src).isFile();
2042
+ if (!fs$1.existsSync(src) || !isAFile) throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
2043
+ let content = fs$1.readFileSync(src, "utf8");
2044
+ if (regionName) {
2045
+ const lines = content.split(/\r?\n/);
2046
+ const region = findRegion(lines, regionName.slice(1));
2047
+ if (region) content = dedent(lines.slice(region.start, region.end).filter((line) => !region.regexp.test(line.trim())).join("\n"));
2048
+ }
2049
+ if (meta.match(reMonacoWrite)) {
2050
+ monacoWriterWhitelist.add(filepath);
2049
2051
  lang = lang.trim();
2050
- lang = lang || path.extname(filepath).slice(1);
2051
- const isAFile = fs$1.statSync(src).isFile();
2052
- if (!fs$1.existsSync(src) || !isAFile) throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
2053
- let content = fs$1.readFileSync(src, "utf8");
2054
- if (regionName) {
2055
- const lines = content.split(/\r?\n/);
2056
- const region = findRegion(lines, regionName.slice(1));
2057
- if (region) content = dedent(lines.slice(region.start, region.end).filter((line) => !region.regexp.test(line.trim())).join("\n"));
2058
- }
2059
- if (meta.match(reMonacoWrite)) {
2060
- monacoWriterWhitelist.add(filepath);
2061
- lang = lang.trim();
2062
- meta = meta.replace(reMonacoWrite, "").trim() || "{}";
2063
- const encoded = lz.compressToBase64(content);
2064
- return `<Monaco writable=${JSON.stringify(filepath)} code-lz="${encoded}" lang="${lang}" v-bind="${meta}" />`;
2065
- } else {
2066
- watchFiles[src] ??= new Set();
2067
- watchFiles[src].add(slide.index);
2068
- }
2069
- return `\`\`\`${lang} ${meta}\n${content}\n\`\`\``;
2052
+ meta = meta.replace(reMonacoWrite, "").trim() || "{}";
2053
+ const encoded = lz.compressToBase64(content);
2054
+ return `<Monaco writable=${JSON.stringify(filepath)} code-lz="${encoded}" lang="${lang}" v-bind="${meta}" />`;
2055
+ } else {
2056
+ watchFiles[src] ??= new Set();
2057
+ watchFiles[src].add(slide.index);
2070
2058
  }
2071
- );
2059
+ return `\`\`\`${lang} ${meta}\n${content}\n\`\`\``;
2060
+ });
2072
2061
  }
2073
2062
 
2074
2063
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
3
  "type": "module",
4
- "version": "51.7.1",
4
+ "version": "51.8.0",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -54,7 +54,7 @@
54
54
  "@unocss/extractor-mdc": "^66.1.2",
55
55
  "@unocss/reset": "^66.1.2",
56
56
  "@vitejs/plugin-vue": "^5.2.4",
57
- "@vitejs/plugin-vue-jsx": "^4.1.2",
57
+ "@vitejs/plugin-vue-jsx": "^4.2.0",
58
58
  "ansis": "^4.0.0",
59
59
  "chokidar": "^4.0.3",
60
60
  "cli-progress": "^3.12.0",
@@ -93,7 +93,7 @@
93
93
  "sirv": "^3.0.1",
94
94
  "source-map-js": "^1.2.1",
95
95
  "typescript": "^5.8.3",
96
- "unhead": "^2.0.9",
96
+ "unhead": "^2.0.10",
97
97
  "unocss": "^66.1.2",
98
98
  "unplugin-icons": "^22.1.0",
99
99
  "unplugin-vue-components": "^28.5.0",
@@ -101,7 +101,7 @@
101
101
  "untun": "^0.1.3",
102
102
  "uqr": "^0.1.2",
103
103
  "vite": "^6.3.5",
104
- "vite-plugin-inspect": "^11.0.1",
104
+ "vite-plugin-inspect": "^11.1.0",
105
105
  "vite-plugin-remote-assets": "^2.0.0",
106
106
  "vite-plugin-static-copy": "^3.0.0",
107
107
  "vite-plugin-vue-server-ref": "^1.0.0",
@@ -109,9 +109,9 @@
109
109
  "vue": "^3.5.14",
110
110
  "yaml": "^2.8.0",
111
111
  "yargs": "^17.7.2",
112
- "@slidev/client": "51.7.1",
113
- "@slidev/types": "51.7.1",
114
- "@slidev/parser": "51.7.1"
112
+ "@slidev/types": "51.8.0",
113
+ "@slidev/client": "51.8.0",
114
+ "@slidev/parser": "51.8.0"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@hedgedoc/markdown-it-plugins": "^2.1.4",