@slidev/cli 51.7.1 → 51.8.1

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-jWq2eLu4.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-jWq2eLu4.js";
2
2
  import { getRoots, isInstalledGlobally, resolveEntry } from "./resolver-BShaA6qw.js";
3
- import { createServer } from "./serve-R48bjx01.js";
3
+ import { createServer } from "./serve-BlpmhsWk.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-CRBvV9Bi.js");
299
299
  for (const entryFile of entry) {
300
300
  const options = await resolveOptions({
301
301
  entry: entryFile,
package/dist/index.d.ts CHANGED
@@ -5,15 +5,12 @@ import { ResolvedSlidevOptions, ResolvedSlidevUtils, SlidevEntryOptions, SlidevP
5
5
 
6
6
  //#region node/commands/serve.d.ts
7
7
  declare function createServer(options: ResolvedSlidevOptions, viteConfig?: InlineConfig, serverOptions?: SlidevServerOptions): Promise<vite0.ViteDevServer>;
8
-
9
8
  //#endregion
10
9
  //#region node/options.d.ts
11
10
  declare function resolveOptions(entryOptions: SlidevEntryOptions, mode: ResolvedSlidevOptions['mode']): Promise<ResolvedSlidevOptions>;
12
11
  declare function createDataUtils(resolved: Omit<ResolvedSlidevOptions, 'utils'>): Promise<ResolvedSlidevUtils>;
13
-
14
12
  //#endregion
15
13
  //#region node/vite/index.d.ts
16
14
  declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions?: SlidevPluginOptions, serverOptions?: SlidevServerOptions): Promise<PluginOption[]>;
17
-
18
15
  //#endregion
19
16
  export { ViteSlidevPlugin, createDataUtils, createServer, parser, resolveOptions };
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-jWq2eLu4.js";
2
2
  import "./resolver-BShaA6qw.js";
3
- import { createServer } from "./serve-R48bjx01.js";
3
+ import { createServer } from "./serve-BlpmhsWk.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-jWq2eLu4.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.1";
47
47
 
48
48
  //#endregion
49
49
  //#region node/syntax/markdown-it/markdown-it-link.ts
@@ -374,6 +374,8 @@ function createConfigPlugin(options) {
374
374
  return () => {
375
375
  server.middlewares.use(async (req, res, next) => {
376
376
  if (req.url === "/index.html") {
377
+ const headers = server.config.server.headers ?? {};
378
+ for (const header in headers) res.setHeader(header, headers[header]);
377
379
  res.setHeader("Content-Type", "text/html");
378
380
  res.statusCode = 200;
379
381
  res.end(options.utils.indexHtml);
@@ -615,7 +617,7 @@ async function setupIndexHtml({ mode, entry, clientRoot, userRoot, roots, data,
615
617
  ].filter((x) => x.content)
616
618
  }, ...inputs] });
617
619
  const baseInDev = mode === "dev" && base ? base.slice(0, -1) : "";
618
- main = main.replace("__ENTRY__", baseInDev + toAtFS(join(clientRoot, "main.ts"))).replace("<!-- body -->", body);
620
+ main = main.replace("__ENTRY__", baseInDev + encodeURI(toAtFS(join(clientRoot, "main.ts")))).replace("<!-- body -->", body);
619
621
  const html = await transformHtmlTemplate(unhead, main);
620
622
  return html;
621
623
  }
@@ -1183,14 +1185,7 @@ const templateSlides = {
1183
1185
  ];
1184
1186
  const slides = data.slides.map((_, idx) => {
1185
1187
  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
- );
1188
+ 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
1189
  return `{ no: ${no}, meta: f${no}, load: load${no}, component: getAsyncComponent(${idx}, load${no}) }`;
1195
1190
  });
1196
1191
  return [
@@ -1286,7 +1281,7 @@ function createSlidesLoader(options, serverOptions) {
1286
1281
  const notesMd = MarkdownIt({ html: true });
1287
1282
  notesMd.use(MarkdownItLink);
1288
1283
  if (data.features.katex) notesMd.use(MarkdownItKatex, utils.katexOptions);
1289
- const hmrSlidesIndexes = new Set();
1284
+ const hmrSlidesIndexes = /* @__PURE__ */ new Set();
1290
1285
  let server;
1291
1286
  let skipHmr = null;
1292
1287
  let sourceIds = resolveSourceIds(data);
@@ -1365,7 +1360,7 @@ function createSlidesLoader(options, serverOptions) {
1365
1360
  skipHmr = null;
1366
1361
  return [];
1367
1362
  }
1368
- const moduleIds = new Set();
1363
+ const moduleIds = /* @__PURE__ */ new Set();
1369
1364
  const newSourceIds = resolveSourceIds(newData);
1370
1365
  for (const type of ["md", "frontmatter"]) {
1371
1366
  const old = sourceIds[type];
@@ -1712,8 +1707,8 @@ async function MarkdownItShiki({ data: { config }, mode, utils }) {
1712
1707
  const dragComponentRegex = /<(v-?drag-?\w*)([\s>])/i;
1713
1708
  const dragDirectiveRegex = /(?<![</\w])v-drag(=".*?")?/i;
1714
1709
  function MarkdownItVDrag(md, markdownTransformMap) {
1715
- const visited = new WeakSet();
1716
- const sourceMapConsumers = new WeakMap();
1710
+ const visited = /* @__PURE__ */ new WeakSet();
1711
+ const sourceMapConsumers = /* @__PURE__ */ new WeakMap();
1717
1712
  function getSourceMapConsumer(id) {
1718
1713
  const s = markdownTransformMap.get(id);
1719
1714
  if (!s) return void 0;
@@ -1807,16 +1802,16 @@ async function setupTransformers(roots) {
1807
1802
 
1808
1803
  //#endregion
1809
1804
  //#region node/syntax/transform/code-wrapper.ts
1810
- const reCodeBlock = /^```([\w'-]+)?\s*(?:\{([\w*,|-]+)\}\s*?(\{[^}]*\})?([^\r\n]*))?\r?\n([ \t]*\S[\s\S]*?)^```$/gm;
1805
+ const reCodeBlock = /^```([\w'-]+)?\s*(?:\[(.*?)\])?\s*(?:\{([\w*,|-]+)\}\s*?(\{[^}]*\})?([^\r\n]*))?\r?\n([ \t]*\S[\s\S]*?)^```$/gm;
1811
1806
  /**
1812
1807
  * Transform code block with wrapper
1813
1808
  */
1814
1809
  function transformCodeWrapper(ctx) {
1815
- ctx.s.replace(reCodeBlock, (full, lang = "", rangeStr = "", options = "", attrs = "", code) => {
1810
+ ctx.s.replace(reCodeBlock, (full, lang = "", title = "", rangeStr = "", options = "", attrs = "", code) => {
1816
1811
  const ranges = normalizeRangeStr(rangeStr);
1817
1812
  code = code.trimEnd();
1818
1813
  options = options.trim() || "{}";
1819
- return `\n<CodeBlockWrapper v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>\n\n\`\`\`${lang}${attrs}\n${code}\n\`\`\`\n\n</CodeBlockWrapper>`;
1814
+ 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
1815
  });
1821
1816
  }
1822
1817
 
@@ -1850,7 +1845,7 @@ function transformKaTexWrapper(ctx) {
1850
1845
 
1851
1846
  //#endregion
1852
1847
  //#region node/syntax/transform/magic-move.ts
1853
- const reMagicMoveBlock = /^````(?:md|markdown) magic-move *(\{[^}]*\})?([^ \n]*)\n([\s\S]+?)^````$/gm;
1848
+ const reMagicMoveBlock = /^````(?:md|markdown) magic-move(?: *\[([^\]]*)\])?(?: *(\{[^}]*\}))? *([^ \n]*)\n([\s\S]+?)^````$/gm;
1854
1849
  function parseLineNumbersOption(options) {
1855
1850
  return /lines: *true/.test(options) ? true : /lines: *false/.test(options) ? false : void 0;
1856
1851
  }
@@ -1858,20 +1853,20 @@ function parseLineNumbersOption(options) {
1858
1853
  * Transform magic-move code blocks
1859
1854
  */
1860
1855
  function transformMagicMove(ctx) {
1861
- ctx.s.replace(reMagicMoveBlock, (full, options = "{}", _attrs = "", body) => {
1856
+ ctx.s.replace(reMagicMoveBlock, (full, title = "", options = "{}", _attrs = "", body) => {
1862
1857
  const matches = Array.from(body.matchAll(reCodeBlock));
1863
1858
  if (!matches.length) throw new Error("Magic Move block must contain at least one code block");
1864
1859
  const defaultLineNumbers = parseLineNumbersOption(options) ?? ctx.options.data.config.lineNumbers;
1865
- const ranges = matches.map((i) => normalizeRangeStr(i[2]));
1860
+ const ranges = matches.map((i) => normalizeRangeStr(i[3]));
1866
1861
  const steps = matches.map((i) => {
1867
- const lineNumbers = parseLineNumbersOption(i[3]) ?? defaultLineNumbers;
1868
- return codeToKeyedTokens(ctx.options.utils.shiki, i[5].trimEnd(), {
1862
+ const lineNumbers = parseLineNumbersOption(i[4]) ?? defaultLineNumbers;
1863
+ return codeToKeyedTokens(ctx.options.utils.shiki, i[6].trimEnd(), {
1869
1864
  ...ctx.options.utils.shikiOptions,
1870
1865
  lang: i[1]
1871
1866
  }, lineNumbers);
1872
1867
  });
1873
1868
  const compressed = lz.compressToBase64(JSON.stringify(steps));
1874
- return `<ShikiMagicMove v-bind="${options}" steps-lz="${compressed}" :step-ranges='${JSON.stringify(ranges)}' />`;
1869
+ return `<ShikiMagicMove v-bind="${options}" steps-lz="${compressed}" :title='${JSON.stringify(title)}' :step-ranges='${JSON.stringify(ranges)}' />`;
1875
1870
  });
1876
1871
  }
1877
1872
 
@@ -1957,7 +1952,7 @@ function transformSlotSugar(ctx) {
1957
1952
 
1958
1953
  //#endregion
1959
1954
  //#region node/vite/monacoWrite.ts
1960
- const monacoWriterWhitelist = new Set();
1955
+ const monacoWriterWhitelist = /* @__PURE__ */ new Set();
1961
1956
  function createMonacoWriterPlugin({ userRoot }) {
1962
1957
  return {
1963
1958
  name: "slidev:monaco-write",
@@ -2040,35 +2035,31 @@ const reMonacoWrite = /^\{monaco-write\}/;
2040
2035
  function transformSnippet({ s, slide, options }) {
2041
2036
  const watchFiles = options.data.watchFiles;
2042
2037
  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();
2038
+ s.replace(/^<<<[ \t]*(\S.*?)(#[\w-]+)?[ \t]*(?:[ \t](\S+?))?[ \t]*(\{.*)?$/gm, (full, filepath = "", regionName = "", lang = "", meta = "") => {
2039
+ const src = slash(/^@\//.test(filepath) ? path.resolve(options.userRoot, filepath.slice(2)) : path.resolve(dir, filepath));
2040
+ meta = meta.trim();
2041
+ lang = lang.trim();
2042
+ lang = lang || path.extname(filepath).slice(1);
2043
+ const isAFile = fs$1.statSync(src).isFile();
2044
+ if (!fs$1.existsSync(src) || !isAFile) throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
2045
+ let content = fs$1.readFileSync(src, "utf8");
2046
+ if (regionName) {
2047
+ const lines = content.split(/\r?\n/);
2048
+ const region = findRegion(lines, regionName.slice(1));
2049
+ if (region) content = dedent(lines.slice(region.start, region.end).filter((line) => !region.regexp.test(line.trim())).join("\n"));
2050
+ }
2051
+ if (meta.match(reMonacoWrite)) {
2052
+ monacoWriterWhitelist.add(filepath);
2049
2053
  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\`\`\``;
2054
+ meta = meta.replace(reMonacoWrite, "").trim() || "{}";
2055
+ const encoded = lz.compressToBase64(content);
2056
+ return `<Monaco writable=${JSON.stringify(filepath)} code-lz="${encoded}" lang="${lang}" v-bind="${meta}" />`;
2057
+ } else {
2058
+ watchFiles[src] ??= /* @__PURE__ */ new Set();
2059
+ watchFiles[src].add(slide.index);
2070
2060
  }
2071
- );
2061
+ return `\`\`\`${lang} ${meta}\n${content}\n\`\`\``;
2062
+ });
2072
2063
  }
2073
2064
 
2074
2065
  //#endregion
@@ -2095,7 +2086,7 @@ async function getMarkdownTransformers(options) {
2095
2086
  //#endregion
2096
2087
  //#region node/vite/markdown.ts
2097
2088
  async function createMarkdownPlugin(options, { markdown: mdOptions }) {
2098
- const markdownTransformMap = new Map();
2089
+ const markdownTransformMap = /* @__PURE__ */ new Map();
2099
2090
  const transformers = await getMarkdownTransformers(options);
2100
2091
  return Markdown({
2101
2092
  include: [/\.md$/],
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.1",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -51,11 +51,11 @@
51
51
  "@shikijs/markdown-it": "^3.4.2",
52
52
  "@shikijs/twoslash": "^3.4.2",
53
53
  "@shikijs/vitepress-twoslash": "^3.4.2",
54
- "@unocss/extractor-mdc": "^66.1.2",
55
- "@unocss/reset": "^66.1.2",
54
+ "@unocss/extractor-mdc": "^66.1.3",
55
+ "@unocss/reset": "^66.1.3",
56
56
  "@vitejs/plugin-vue": "^5.2.4",
57
- "@vitejs/plugin-vue-jsx": "^4.1.2",
58
- "ansis": "^4.0.0",
57
+ "@vitejs/plugin-vue-jsx": "^4.2.0",
58
+ "ansis": "^4.1.0",
59
59
  "chokidar": "^4.0.3",
60
60
  "cli-progress": "^3.12.0",
61
61
  "connect": "^3.7.0",
@@ -93,25 +93,25 @@
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",
97
- "unocss": "^66.1.2",
96
+ "unhead": "^2.0.10",
97
+ "unocss": "^66.1.3",
98
98
  "unplugin-icons": "^22.1.0",
99
- "unplugin-vue-components": "^28.5.0",
99
+ "unplugin-vue-components": "^28.7.0",
100
100
  "unplugin-vue-markdown": "^28.3.1",
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",
108
108
  "vitefu": "^1.0.6",
109
- "vue": "^3.5.14",
109
+ "vue": "^3.5.16",
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/client": "51.8.1",
113
+ "@slidev/parser": "51.8.1",
114
+ "@slidev/types": "51.8.1"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@hedgedoc/markdown-it-plugins": "^2.1.4",