@slidev/cli 52.9.1 → 52.10.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,9 +1,9 @@
1
- import { t as resolveViteConfigs } from "./shared-D3BW4vqA.mjs";
2
- import "./resolver-Du-CxvL9.mjs";
3
- import fs from "node:fs/promises";
1
+ import "./resolver-cMXpGVIO.mjs";
2
+ import { t as resolveViteConfigs } from "./shared-raT8P_ce.mjs";
4
3
  import { join, resolve } from "node:path";
5
4
  import { build as build$1 } from "vite";
6
5
  import { existsSync } from "node:fs";
6
+ import fs$1 from "node:fs/promises";
7
7
  import http from "node:http";
8
8
  import connect from "connect";
9
9
  import sirv from "sirv";
@@ -12,8 +12,8 @@ import sirv from "sirv";
12
12
  async function build(options, viteConfig = {}, args) {
13
13
  const indexPath = resolve(options.userRoot, "index.html");
14
14
  let originalIndexHTML;
15
- if (existsSync(indexPath)) originalIndexHTML = await fs.readFile(indexPath, "utf-8");
16
- await fs.writeFile(indexPath, options.utils.indexHtml, "utf-8");
15
+ if (existsSync(indexPath)) originalIndexHTML = await fs$1.readFile(indexPath, "utf-8");
16
+ await fs$1.writeFile(indexPath, options.utils.indexHtml, "utf-8");
17
17
  let config = void 0;
18
18
  try {
19
19
  await build$1(await resolveViteConfigs(options, {
@@ -26,15 +26,15 @@ async function build(options, viteConfig = {}, args) {
26
26
  build: { chunkSizeWarningLimit: 2e3 }
27
27
  }, viteConfig, "build"));
28
28
  } finally {
29
- if (originalIndexHTML != null) await fs.writeFile(indexPath, originalIndexHTML, "utf-8");
30
- else await fs.unlink(indexPath);
29
+ if (originalIndexHTML != null) await fs$1.writeFile(indexPath, originalIndexHTML, "utf-8");
30
+ else await fs$1.unlink(indexPath);
31
31
  }
32
32
  const outDir = resolve(options.userRoot, config.build.outDir);
33
33
  if (options.data.config.seoMeta?.ogImage === "auto" || options.data.config.seoMeta?.ogImage?.startsWith(".")) {
34
34
  const filename = options.data.config.seoMeta?.ogImage === "auto" ? "og-image.png" : options.data.config.seoMeta.ogImage;
35
35
  const projectOgImagePath = resolve(options.userRoot, filename);
36
36
  const outputOgImagePath = resolve(outDir, filename);
37
- if (await fs.access(projectOgImagePath).then(() => true).catch(() => false)) await fs.copyFile(projectOgImagePath, outputOgImagePath);
37
+ if (await fs$1.access(projectOgImagePath).then(() => true).catch(() => false)) await fs$1.copyFile(projectOgImagePath, outputOgImagePath);
38
38
  else if (options.data.config.seoMeta?.ogImage === "auto") {
39
39
  const port = 12445;
40
40
  const app = connect();
@@ -45,9 +45,9 @@ async function build(options, viteConfig = {}, args) {
45
45
  dev: true
46
46
  }));
47
47
  server.listen(port);
48
- const { exportSlides } = await import("./export-snweM1-1.mjs");
48
+ const { exportSlides } = await import("./export-D88qOzFM.mjs");
49
49
  const tempDir = resolve(outDir, "temp");
50
- await fs.mkdir(tempDir, { recursive: true });
50
+ await fs$1.mkdir(tempDir, { recursive: true });
51
51
  await exportSlides({
52
52
  port,
53
53
  base: config.base,
@@ -65,28 +65,28 @@ async function build(options, viteConfig = {}, args) {
65
65
  omitBackground: false,
66
66
  dark: args.dark
67
67
  });
68
- const pngFile = (await fs.readdir(tempDir)).find((file) => file.endsWith(".png"));
68
+ const pngFile = (await fs$1.readdir(tempDir)).find((file) => file.endsWith(".png"));
69
69
  if (pngFile) {
70
70
  const generatedPath = resolve(tempDir, pngFile);
71
- await fs.copyFile(generatedPath, projectOgImagePath);
72
- await fs.copyFile(generatedPath, outputOgImagePath);
71
+ await fs$1.copyFile(generatedPath, projectOgImagePath);
72
+ await fs$1.copyFile(generatedPath, outputOgImagePath);
73
73
  }
74
- await fs.rm(tempDir, {
74
+ await fs$1.rm(tempDir, {
75
75
  recursive: true,
76
76
  force: true
77
77
  });
78
78
  server.close();
79
79
  } else throw new Error(`[Slidev] ogImage: ${filename} not found`);
80
80
  }
81
- await fs.copyFile(resolve(outDir, "index.html"), resolve(outDir, "404.html"));
81
+ await fs$1.copyFile(resolve(outDir, "index.html"), resolve(outDir, "404.html"));
82
82
  const redirectsPath = resolve(outDir, "_redirects");
83
- if (!existsSync(redirectsPath)) await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200\n`, "utf-8");
83
+ if (!existsSync(redirectsPath)) await fs$1.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200\n`, "utf-8");
84
84
  if ([
85
85
  true,
86
86
  "true",
87
87
  "auto"
88
88
  ].includes(options.data.config.download)) {
89
- const { exportSlides, getExportOptions } = await import("./export-snweM1-1.mjs");
89
+ const { exportSlides, getExportOptions } = await import("./export-D88qOzFM.mjs");
90
90
  const port = 12445;
91
91
  const app = connect();
92
92
  const server = http.createServer(app);
package/dist/cli.mjs CHANGED
@@ -1,20 +1,20 @@
1
- import { a as loadSetups, c as resolveTheme, d as version, i as resolveOptions, l as resolveAddons, o as parser, s as getThemeMeta, u as updateFrontmatterPatch } from "./shared-D3BW4vqA.mjs";
2
- import { i as resolveEntry, n as getRoots, r as isInstalledGlobally } from "./resolver-Du-CxvL9.mjs";
3
- import { t as createServer } from "./serve-BrA39NVM.mjs";
4
- import { exec } from "node:child_process";
5
- import fs from "node:fs/promises";
6
- import os from "node:os";
1
+ import { i as resolveEntry, n as getRoots, r as isInstalledGlobally } from "./resolver-cMXpGVIO.mjs";
2
+ import { a as parser, c as resolveAddons, d as updateFrontmatterPatch, i as resolveOptions, l as version, o as getThemeMeta, s as resolveTheme, u as loadSetups } from "./shared-raT8P_ce.mjs";
3
+ import { t as createServer } from "./serve-CPsgix_y.mjs";
7
4
  import path from "node:path";
8
5
  import process from "node:process";
9
- import * as readline from "node:readline";
10
- import { verifyConfig } from "@slidev/parser";
6
+ import fs from "node:fs/promises";
7
+ import { uniq } from "@antfu/utils";
11
8
  import { blue, bold, cyan, cyanBright, dim, gray, green, underline, yellow } from "ansis";
9
+ import { injectPreparserExtensionLoader } from "@slidev/parser/fs";
12
10
  import equal from "fast-deep-equal";
11
+ import { exec } from "node:child_process";
12
+ import os from "node:os";
13
+ import * as readline from "node:readline";
14
+ import { verifyConfig } from "@slidev/parser";
13
15
  import { getPort } from "get-port-please";
14
16
  import openBrowser from "open";
15
17
  import yargs from "yargs";
16
- import { uniq } from "@antfu/utils";
17
- import { injectPreparserExtensionLoader } from "@slidev/parser/fs";
18
18
 
19
19
  //#region node/setups/preparser.ts
20
20
  function setupPreparser() {
@@ -41,21 +41,16 @@ const CONFIG_RESTART_FIELDS = [
41
41
  "theme",
42
42
  "seoMeta"
43
43
  ];
44
- /**
45
- * Files that triggers a restart when added or removed
46
- */
47
- const FILES_CREATE_RESTART = [
48
- "global-bottom.vue",
49
- "global-top.vue",
50
- "uno.config.js",
51
- "uno.config.ts",
52
- "unocss.config.js",
53
- "unocss.config.ts"
54
- ];
55
44
  const FILES_CHANGE_RESTART = [
56
45
  "setup/shiki.ts",
57
46
  "setup/katex.ts",
58
- "setup/preparser.ts"
47
+ "setup/preparser.ts",
48
+ "setup/transformers.ts",
49
+ "setup/unocss.ts",
50
+ "setup/vite-plugins.ts",
51
+ "uno.config.ts",
52
+ "unocss.config.ts",
53
+ "vite.config.{js,ts,mjs,mts}"
59
54
  ];
60
55
  setupPreparser();
61
56
  const cli = yargs(process.argv.slice(2)).scriptName("slidev").usage("$0 [args]").version(version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
@@ -107,7 +102,9 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
107
102
  let port = 3030;
108
103
  let lastRemoteUrl;
109
104
  let restartTimer;
110
- function restartServer() {
105
+ async function restartServer() {
106
+ await server?.close();
107
+ server = void 0;
111
108
  clearTimeout(restartTimer);
112
109
  restartTimer = setTimeout(() => {
113
110
  console.log(yellow("\n restarting...\n"));
@@ -115,7 +112,6 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
115
112
  }, 500);
116
113
  }
117
114
  async function initServer() {
118
- if (server) await server.close();
119
115
  const options = await resolveOptions({
120
116
  entry,
121
117
  remote,
@@ -175,6 +171,7 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
175
171
  let publicIp;
176
172
  if (remote) publicIp = await import("public-ip").then((r) => r.publicIpv4());
177
173
  lastRemoteUrl = printInfo(options, port, base, remote, tunnelUrl, publicIp);
174
+ return options;
178
175
  }
179
176
  async function openTunnel(port$1) {
180
177
  const { startTunnel } = await import("untun");
@@ -252,12 +249,13 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
252
249
  process.stdin.off("keypress", onKeyPress);
253
250
  });
254
251
  }
255
- initServer();
252
+ const { roots } = await initServer();
256
253
  bindShortcut();
257
254
  const { watch } = await import("chokidar");
258
- const watcher = watch([...FILES_CREATE_RESTART, ...FILES_CHANGE_RESTART], {
255
+ const watcher = watch(roots.filter((i) => !i.includes("node_modules")).flatMap((root) => FILES_CHANGE_RESTART.map((i) => path.join(root, i))), {
259
256
  ignored: ["node_modules", ".git"],
260
- ignoreInitial: true
257
+ ignoreInitial: true,
258
+ ignorePermissionErrors: true
261
259
  });
262
260
  watcher.on("unlink", (file) => {
263
261
  console.log(yellow(`\n file ${file} removed, restarting...\n`));
@@ -268,8 +266,6 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
268
266
  restartServer();
269
267
  });
270
268
  watcher.on("change", (file) => {
271
- if (typeof file !== "string") return;
272
- if (FILES_CREATE_RESTART.includes(file)) return;
273
269
  console.log(yellow(`\n file ${file} changed, restarting...\n`));
274
270
  restartServer();
275
271
  });
@@ -286,20 +282,24 @@ cli.command("build [entry..]", "Build hostable SPA", (args) => exportOptions(com
286
282
  alias: "d",
287
283
  type: "boolean",
288
284
  describe: "allow download as PDF"
285
+ }).option("without-notes", {
286
+ type: "boolean",
287
+ describe: "exclude speaker notes from the built output"
289
288
  }).option("inspect", {
290
289
  default: false,
291
290
  type: "boolean",
292
291
  describe: "enable the inspect plugin for debugging"
293
292
  }).strict().help(), async (args) => {
294
- const { entry, theme, base, download, out, inspect } = args;
295
- const { build } = await import("./build-C0y4MWcQ.mjs");
293
+ const { entry, theme, base, download, out, inspect, "without-notes": withoutNotes } = args;
294
+ const { build } = await import("./build-Dq4XSmLE.mjs");
296
295
  for (const entryFile of entry) {
297
296
  const options = await resolveOptions({
298
297
  entry: entryFile,
299
298
  theme,
300
299
  inspect,
301
300
  download,
302
- base
301
+ base,
302
+ withoutNotes
303
303
  }, "build");
304
304
  printInfo(options);
305
305
  await build(options, {
@@ -355,7 +355,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
355
355
  });
356
356
  cli.command("export [entry..]", "Export slides to PDF", (args) => exportOptions(commonOptions(args)).strict().help(), async (args) => {
357
357
  const { entry, theme } = args;
358
- const { exportSlides, getExportOptions } = await import("./export-snweM1-1.mjs");
358
+ const { exportSlides, getExportOptions } = await import("./export-D88qOzFM.mjs");
359
359
  const port = await getPort(12445);
360
360
  let warned = false;
361
361
  for (const entryFile of entry) {
@@ -402,7 +402,7 @@ cli.command("export-notes [entry..]", "Export slide notes to PDF", (args) => arg
402
402
  type: "number",
403
403
  describe: "wait for the specified ms before exporting"
404
404
  }).strict().help(), async ({ entry, output, timeout, wait }) => {
405
- const { exportNotes } = await import("./export-snweM1-1.mjs");
405
+ const { exportNotes } = await import("./export-D88qOzFM.mjs");
406
406
  const port = await getPort(12445);
407
407
  for (const entryFile of entry) {
408
408
  const options = await resolveOptions({ entry: entryFile }, "export");
@@ -1,9 +1,9 @@
1
- import { n as getRoots } from "./resolver-Du-CxvL9.mjs";
2
- import fs from "node:fs/promises";
1
+ import { n as getRoots } from "./resolver-cMXpGVIO.mjs";
3
2
  import path, { dirname, relative } from "node:path";
4
3
  import process from "node:process";
5
- import { blue, cyan, dim, green, yellow } from "ansis";
4
+ import fs from "node:fs/promises";
6
5
  import { clearUndefined, ensureSuffix, slash } from "@antfu/utils";
6
+ import { blue, cyan, dim, green, yellow } from "ansis";
7
7
  import { resolve as resolve$1 } from "mlly";
8
8
  import { Buffer } from "node:buffer";
9
9
  import { outlinePdfFactory } from "@lillallol/outline-pdf";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { i as resolveOptions, n as ViteSlidevPlugin, o as parser, r as createDataUtils } from "./shared-D3BW4vqA.mjs";
2
- import "./resolver-Du-CxvL9.mjs";
3
- import { t as createServer } from "./serve-BrA39NVM.mjs";
1
+ import "./resolver-cMXpGVIO.mjs";
2
+ import { a as parser, i as resolveOptions, n as ViteSlidevPlugin, r as createDataUtils } from "./shared-raT8P_ce.mjs";
3
+ import { t as createServer } from "./serve-CPsgix_y.mjs";
4
4
 
5
5
  export { ViteSlidevPlugin, createDataUtils, createServer, parser, resolveOptions };
@@ -1,11 +1,11 @@
1
- import { copyFile, readFile } from "node:fs/promises";
2
1
  import { dirname, join, relative, resolve } from "node:path";
3
2
  import process from "node:process";
4
- import { underline, yellow } from "ansis";
5
3
  import { existsSync } from "node:fs";
4
+ import { copyFile, readFile } from "node:fs/promises";
6
5
  import { fileURLToPath } from "node:url";
7
6
  import { parseNi, run } from "@antfu/ni";
8
7
  import { ensurePrefix, slash } from "@antfu/utils";
8
+ import { underline, yellow } from "ansis";
9
9
  import globalDirs from "global-directory";
10
10
  import { resolvePath } from "mlly";
11
11
  import prompts from "prompts";
@@ -1,4 +1,4 @@
1
- import { t as resolveViteConfigs } from "./shared-D3BW4vqA.mjs";
1
+ import { t as resolveViteConfigs } from "./shared-raT8P_ce.mjs";
2
2
  import { join } from "node:path";
3
3
  import process from "node:process";
4
4
  import { createServer } from "vite";
@@ -1,14 +1,13 @@
1
- import { a as resolveImportPath, c as toAtFS, i as resolveEntry, n as getRoots, o as resolveImportUrl, r as isInstalledGlobally, s as resolveSourceFiles, t as createResolver } from "./resolver-Du-CxvL9.mjs";
1
+ import { a as resolveImportPath, c as toAtFS, i as resolveEntry, n as getRoots, o as resolveImportUrl, r as isInstalledGlobally, s as resolveSourceFiles, t as createResolver } from "./resolver-cMXpGVIO.mjs";
2
2
  import { builtinModules } from "node:module";
3
- import fs, { readFile } from "node:fs/promises";
4
- import path, { basename, dirname, join, resolve } from "node:path";
5
- import { bold, gray, red, white, yellow } from "ansis";
6
- import equal from "fast-deep-equal";
3
+ import path, { basename, dirname, join, relative, resolve } from "node:path";
7
4
  import { loadConfigFromFile, mergeConfig } from "vite";
8
5
  import MarkdownIt from "markdown-it";
9
- import fs$1, { existsSync } from "node:fs";
6
+ import fs, { existsSync } from "node:fs";
7
+ import fs$1, { readFile } from "node:fs/promises";
10
8
  import { fileURLToPath, pathToFileURL } from "node:url";
11
9
  import { isString, isTruthy, notNullish, objectEntries, objectMap, range, slash, uniq } from "@antfu/utils";
10
+ import { bold, gray, red, white, yellow } from "ansis";
12
11
  import { createResolve } from "mlly";
13
12
  import { findDepPkgJsonPath } from "vitefu";
14
13
  import { createJiti } from "jiti";
@@ -17,6 +16,7 @@ import IconsResolver from "unplugin-icons/resolver";
17
16
  import Components from "unplugin-vue-components/vite";
18
17
  import Icons from "unplugin-icons/vite";
19
18
  import * as parser from "@slidev/parser/fs";
19
+ import equal from "fast-deep-equal";
20
20
  import fg from "fast-glob";
21
21
  import { createDebug } from "obug";
22
22
  import pm from "picomatch";
@@ -43,10 +43,6 @@ import { mergeConfigs, presetIcons } from "unocss";
43
43
  import Vue from "@vitejs/plugin-vue";
44
44
  import VueJsx from "@vitejs/plugin-vue-jsx";
45
45
 
46
- //#region package.json
47
- var version = "52.9.1";
48
-
49
- //#endregion
50
46
  //#region node/syntax/markdown-it/markdown-it-link.ts
51
47
  function MarkdownItLink(md) {
52
48
  const defaultRender = md.renderer.rules.link_open ?? ((tokens, idx, options, _env, self) => self.renderToken(tokens, idx, options));
@@ -130,6 +126,34 @@ function getBodyJson(req) {
130
126
  });
131
127
  });
132
128
  }
129
+ function makeAbsoluteImportGlob(userRoot, globs, options = {}) {
130
+ const relativeGlobs = globs.map((glob) => `./${relative(userRoot, glob)}`);
131
+ const opts = {
132
+ eager: true,
133
+ exhaustive: true,
134
+ base: "/",
135
+ ...options
136
+ };
137
+ return `import.meta.glob(${JSON.stringify(relativeGlobs)}, ${JSON.stringify(opts)})`;
138
+ }
139
+
140
+ //#endregion
141
+ //#region node/setups/load.ts
142
+ async function loadSetups(roots, filename, args, extraLoader) {
143
+ return await Promise.all(roots.flatMap((root) => {
144
+ const tasks = [];
145
+ const path$1 = resolve(root, "setup", filename);
146
+ if (existsSync(path$1)) tasks.push(loadModule(path$1).then((mod) => mod.default(...args)));
147
+ if (extraLoader) tasks.push(...extraLoader(root));
148
+ return tasks;
149
+ }));
150
+ }
151
+
152
+ //#endregion
153
+ //#region node/setups/vite-plugins.ts
154
+ async function setupVitePlugins(options) {
155
+ return await loadSetups(options.roots, "vite-plugins.ts", [options]);
156
+ }
133
157
 
134
158
  //#endregion
135
159
  //#region node/vite/compilerFlagsVue.ts
@@ -251,7 +275,6 @@ const INCLUDE_GLOBAL = [
251
275
  "@typescript/ata",
252
276
  "file-saver",
253
277
  "lz-string",
254
- "prettier",
255
278
  "recordrtc",
256
279
  "typescript",
257
280
  "yaml",
@@ -479,6 +502,10 @@ function createLayoutWrapperPlugin({ data, utils }) {
479
502
  };
480
503
  }
481
504
 
505
+ //#endregion
506
+ //#region package.json
507
+ var version = "52.10.0";
508
+
482
509
  //#endregion
483
510
  //#region node/integrations/addons.ts
484
511
  async function resolveAddons(addonsInConfig) {
@@ -489,7 +516,7 @@ async function resolveAddons(addonsInConfig) {
489
516
  const [, pkgRoot] = await resolveAddonNameAndRoot(name, parent);
490
517
  if (!pkgRoot) return;
491
518
  resolved.push(pkgRoot);
492
- const { slidev = {}, engines = {} } = JSON.parse(await fs.readFile(resolve(pkgRoot, "package.json"), "utf-8"));
519
+ const { slidev = {}, engines = {} } = JSON.parse(await fs$1.readFile(resolve(pkgRoot, "package.json"), "utf-8"));
493
520
  if (engines.slidev && !satisfies(version, engines.slidev, { includePrerelease: true })) throw new Error(`[slidev] addon "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
494
521
  if (Array.isArray(slidev.addons)) await Promise.all(slidev.addons.map((addon) => resolveAddon(addon, pkgRoot)));
495
522
  }
@@ -512,7 +539,7 @@ const resolveTheme = createResolver("theme", officialThemes);
512
539
  async function getThemeMeta(name, root) {
513
540
  const path$1 = join(root, "package.json");
514
541
  if (!existsSync(path$1)) return {};
515
- const { slidev = {}, engines = {} } = JSON.parse(await fs.readFile(path$1, "utf-8"));
542
+ const { slidev = {}, engines = {} } = JSON.parse(await fs$1.readFile(path$1, "utf-8"));
516
543
  if (engines.slidev && !satisfies(version, engines.slidev, { includePrerelease: true })) throw new Error(`[slidev] theme "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
517
544
  return slidev;
518
545
  }
@@ -642,22 +669,6 @@ async function setupIndexHtml({ mode, entry, clientRoot, userRoot, roots, data,
642
669
  return await transformHtmlTemplate(unhead, main);
643
670
  }
644
671
 
645
- //#endregion
646
- //#region node/setups/load.ts
647
- async function loadSetups(roots, filename, args, extraLoader) {
648
- const returns = [];
649
- for (const root of roots) {
650
- const path$1 = resolve(root, "setup", filename);
651
- if (existsSync(path$1)) {
652
- const { default: setup } = await loadModule(path$1);
653
- const ret = await setup(...args);
654
- if (ret) returns.push(ret);
655
- }
656
- if (extraLoader) returns.push(...await extraLoader(root));
657
- }
658
- return returns;
659
- }
660
-
661
672
  //#endregion
662
673
  //#region node/setups/katex.ts
663
674
  async function setupKatex(roots) {
@@ -745,7 +756,7 @@ async function setupShiki(roots) {
745
756
  if (cachedRoots === roots) return cachedShiki;
746
757
  const { options, languageInput, themeInput } = resolveShikiOptions(await loadSetups(roots, "shiki.ts", [{ async loadTheme(path$1) {
747
758
  console.warn("[slidev] `loadTheme` in `setup/shiki.ts` is deprecated. Pass directly the theme name it's supported by Shiki. For custom themes, load it manually via `JSON.parse(fs.readFileSync(path, 'utf-8'))` and pass the raw JSON object instead.");
748
- return JSON.parse(await fs.readFile(path$1, "utf-8"));
759
+ return JSON.parse(await fs$1.readFile(path$1, "utf-8"));
749
760
  } }]));
750
761
  const createHighlighter = createdBundledHighlighter({
751
762
  engine: createJavaScriptRegexEngine,
@@ -1102,32 +1113,29 @@ console.warn('/@slidev/titles.md is deprecated, import from #slidev/title-render
1102
1113
  //#region node/virtual/global-layers.ts
1103
1114
  const templateGlobalLayers = {
1104
1115
  id: `/@slidev/global-layers`,
1105
- getContent({ roots }) {
1106
- const imports = [];
1107
- let n = 0;
1108
- function getComponent(names) {
1109
- const components = roots.flatMap((root) => names.map((name) => join(root, name))).filter((i) => existsSync(i));
1110
- imports.push(components.map((path$1, i) => `import __n${n}_${i} from '${toAtFS(path$1)}'`).join("\n"));
1111
- const render = components.map((_, i) => `h(__n${n}_${i})`).join(",");
1112
- n++;
1113
- return `{ render: () => [${render}] }`;
1116
+ getContent({ userRoot, roots }) {
1117
+ function* getComponent(name, names) {
1118
+ yield `const ${name}Components = [\n`;
1119
+ for (const root of roots) {
1120
+ const globs = names.map((name$1) => join(root, `${name$1}.{ts,js,vue}`));
1121
+ yield " Object.values(";
1122
+ yield makeAbsoluteImportGlob(userRoot, globs, { import: "default" });
1123
+ yield ")[0],\n";
1124
+ }
1125
+ yield `].filter(Boolean)\n`;
1126
+ yield `export const ${name} = { render: () => ${name}Components.map(comp => h(comp)) }\n\n`;
1114
1127
  }
1115
- const globalTop = getComponent([
1116
- "global.vue",
1117
- "global-top.vue",
1118
- "GlobalTop.vue"
1119
- ]);
1120
- const globalBottom = getComponent(["global-bottom.vue", "GlobalBottom.vue"]);
1121
- const slideTop = getComponent(["slide-top.vue", "SlideTop.vue"]);
1122
- const slideBottom = getComponent(["slide-bottom.vue", "SlideBottom.vue"]);
1123
1128
  return [
1124
- imports.join("\n"),
1125
- `import { h } from 'vue'`,
1126
- `export const GlobalTop = ${globalTop}`,
1127
- `export const GlobalBottom = ${globalBottom}`,
1128
- `export const SlideTop = ${slideTop}`,
1129
- `export const SlideBottom = ${slideBottom}`
1130
- ].join("\n");
1129
+ `import { h } from 'vue'\n\n`,
1130
+ ...getComponent("GlobalTop", [
1131
+ "global",
1132
+ "global-top",
1133
+ "GlobalTop"
1134
+ ]),
1135
+ ...getComponent("GlobalBottom", ["global-bottom", "GlobalBottom"]),
1136
+ ...getComponent("SlideTop", ["slide-top", "SlideTop"]),
1137
+ ...getComponent("SlideBottom", ["slide-bottom", "SlideBottom"])
1138
+ ].join("");
1131
1139
  }
1132
1140
  };
1133
1141
 
@@ -1225,14 +1233,10 @@ export default {
1225
1233
  function createSetupTemplate(name) {
1226
1234
  return {
1227
1235
  id: `/@slidev/setups/${name}`,
1228
- getContent({ roots }) {
1229
- const setups = resolveSourceFiles(roots, `setup/${name}`);
1230
- const imports = [];
1231
- setups.forEach((path$1, idx) => {
1232
- imports.push(`import __n${idx} from '${toAtFS(path$1)}'`);
1233
- });
1234
- imports.push(`export default [${setups.map((_, idx) => `__n${idx}`).join(",")}]`);
1235
- return imports.join("\n");
1236
+ getContent({ userRoot, roots }) {
1237
+ return `export default [${roots.map((root) => {
1238
+ return `Object.values(${makeAbsoluteImportGlob(userRoot, [join(root, `setup/${name}.{ts,js,mts,mjs}`)], { import: "default" })})[0]`;
1239
+ }).join(", ")}].filter(Boolean)`;
1236
1240
  }
1237
1241
  };
1238
1242
  }
@@ -1291,7 +1295,7 @@ const templateSlides = {
1291
1295
  //#region node/virtual/styles.ts
1292
1296
  const templateStyle = {
1293
1297
  id: "/@slidev/styles",
1294
- async getContent({ data, clientRoot, roots }) {
1298
+ async getContent({ data, clientRoot, userRoot, roots }) {
1295
1299
  function resolveUrlOfClient(name) {
1296
1300
  return toAtFS(join(clientRoot, name));
1297
1301
  }
@@ -1302,19 +1306,11 @@ const templateStyle = {
1302
1306
  `import "${resolveUrlOfClient("styles/katex.css")}"`,
1303
1307
  `import "${resolveUrlOfClient("styles/transitions.css")}"`
1304
1308
  ];
1305
- for (const root of roots) {
1306
- const styles = [
1307
- join(root, "styles", "index.ts"),
1308
- join(root, "styles", "index.js"),
1309
- join(root, "styles", "index.css"),
1310
- join(root, "styles.css"),
1311
- join(root, "style.css")
1312
- ];
1313
- for (const style of styles) if (existsSync(style)) {
1314
- imports.push(`import "${toAtFS(style)}"`);
1315
- continue;
1316
- }
1317
- }
1309
+ for (const root of roots) imports.push(makeAbsoluteImportGlob(userRoot, [
1310
+ join(root, "styles/index.{ts,js,css}"),
1311
+ join(root, "styles.{ts,js,css}"),
1312
+ join(root, "style.{ts,js,css}")
1313
+ ]));
1318
1314
  if (data.features.katex) imports.push(`import "${await resolveImportUrl("katex/dist/katex.min.css")}"`);
1319
1315
  if (data.config.highlighter === "shiki") imports.push(`import "${await resolveImportUrl("@shikijs/vitepress-twoslash/style.css")}"`, `import "${resolveUrlOfClient("styles/shiki-twoslash.css")}"`, `import "${await resolveImportUrl("shiki-magic-move/style.css")}"`);
1320
1316
  imports.unshift(`import "${await resolveImportUrl("@unocss/reset/tailwind.css")}"`, "import \"uno:preflights.css\"", "import \"uno:typography.css\"", "import \"uno:shortcuts.css\"");
@@ -1361,7 +1357,7 @@ const templates = [
1361
1357
  //#endregion
1362
1358
  //#region node/vite/loaders.ts
1363
1359
  function createSlidesLoader(options, serverOptions) {
1364
- const { data, mode, utils } = options;
1360
+ const { data, mode, utils, withoutNotes } = options;
1365
1361
  const notesMd = MarkdownIt({ html: true });
1366
1362
  notesMd.use(MarkdownItLink);
1367
1363
  if (data.features.katex) notesMd.use(MarkdownItKatex, utils.katexOptions);
@@ -1587,6 +1583,7 @@ function createSlidesLoader(options, serverOptions) {
1587
1583
  }
1588
1584
  };
1589
1585
  function renderNote(text = "") {
1586
+ if (withoutNotes) return "";
1590
1587
  let clickCount = 0;
1591
1588
  const notesAutoRuby = data.headmatter.notesAutoRuby || {};
1592
1589
  let md = text.replace(/\[click(?::(\d+))?\]/gi, (_, count = 1) => {
@@ -1606,6 +1603,7 @@ function createSlidesLoader(options, serverOptions) {
1606
1603
  function withRenderedNote(data$1) {
1607
1604
  return {
1608
1605
  ...data$1,
1606
+ ...withoutNotes && { note: "" },
1609
1607
  noteHTML: renderNote(data$1?.note)
1610
1608
  };
1611
1609
  }
@@ -2054,7 +2052,7 @@ function createMonacoWriterPlugin({ userRoot }) {
2054
2052
  }
2055
2053
  const filepath = path.join(userRoot, file);
2056
2054
  console.log("[Slidev] Writing file:", filepath);
2057
- await fs.writeFile(filepath, content, "utf-8");
2055
+ await fs$1.writeFile(filepath, content, "utf-8");
2058
2056
  }
2059
2057
  });
2060
2058
  });
@@ -2156,9 +2154,9 @@ function transformSnippet({ s, slide, options }) {
2156
2154
  meta = meta.trim();
2157
2155
  lang = lang.trim();
2158
2156
  lang = lang || path.extname(filepath).slice(1);
2159
- const isAFile = fs$1.statSync(src).isFile();
2160
- if (!fs$1.existsSync(src) || !isAFile) throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
2161
- let content = fs$1.readFileSync(src, "utf8");
2157
+ const isAFile = fs.statSync(src).isFile();
2158
+ if (!fs.existsSync(src) || !isAFile) throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
2159
+ let content = fs.readFileSync(src, "utf8");
2162
2160
  if (regionName) {
2163
2161
  const lines = content.split(/\r?\n/);
2164
2162
  const region = findRegion(lines, regionName.slice(1));
@@ -2266,7 +2264,7 @@ function createMonacoTypesLoader({ userRoot, utils }) {
2266
2264
  const pkgJsonPath = await findDepPkgJsonPath(pkg, importer);
2267
2265
  if (!pkgJsonPath) throw new Error(`Package "${pkg}" not found in "${importer}"`);
2268
2266
  const root = slash(dirname(pkgJsonPath));
2269
- const pkgJson = JSON.parse(await fs.readFile(pkgJsonPath, "utf-8"));
2267
+ const pkgJson = JSON.parse(await fs$1.readFile(pkgJsonPath, "utf-8"));
2270
2268
  let deps = Object.keys(pkgJson.dependencies ?? {});
2271
2269
  deps = deps.filter((pkg$1) => !utils.isMonacoTypesIgnored(pkg$1));
2272
2270
  return [`import "/@slidev-monaco-types/load?${new URLSearchParams({
@@ -2356,7 +2354,7 @@ async function loadDrawings(options) {
2356
2354
  await Promise.all(files.map(async (path$1) => {
2357
2355
  const num = +basename(path$1, ".svg");
2358
2356
  if (Number.isNaN(num)) return;
2359
- const lines = (await fs.readFile(path$1, "utf8")).split(/\n/g);
2357
+ const lines = (await fs$1.readFile(path$1, "utf8")).split(/\n/g);
2360
2358
  obj[num.toString()] = lines.slice(1, -1).join("\n");
2361
2359
  }));
2362
2360
  return obj;
@@ -2366,11 +2364,11 @@ async function writeDrawings(options, drawing) {
2366
2364
  if (!dir) return;
2367
2365
  const width = options.data.config.canvasWidth;
2368
2366
  const SVG_HEAD = `<svg width="${width}" height="${Math.round(width / options.data.config.aspectRatio)}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
2369
- await fs.mkdir(dir, { recursive: true });
2367
+ await fs$1.mkdir(dir, { recursive: true });
2370
2368
  return Promise.all(Object.entries(drawing).map(async ([key, value]) => {
2371
2369
  if (!value) return;
2372
2370
  const svg = `${SVG_HEAD}\n${value}\n</svg>`;
2373
- await fs.writeFile(join(dir, `${key}.svg`), svg, "utf-8");
2371
+ await fs$1.writeFile(join(dir, `${key}.svg`), svg, "utf-8");
2374
2372
  }));
2375
2373
  }
2376
2374
 
@@ -2383,13 +2381,13 @@ async function loadSnapshots(options) {
2383
2381
  const dir = resolveSnapshotsDir(options);
2384
2382
  const file = join(dir, "snapshots.json");
2385
2383
  if (!dir || !existsSync(file)) return {};
2386
- return JSON.parse(await fs.readFile(file, "utf8"));
2384
+ return JSON.parse(await fs$1.readFile(file, "utf8"));
2387
2385
  }
2388
2386
  async function writeSnapshots(options, data) {
2389
2387
  const dir = resolveSnapshotsDir(options);
2390
2388
  if (!dir) return;
2391
- await fs.mkdir(dir, { recursive: true });
2392
- await fs.writeFile(join(dir, "snapshots.json"), JSON.stringify(data, null, 2), "utf-8");
2389
+ await fs$1.mkdir(dir, { recursive: true });
2390
+ await fs$1.writeFile(join(dir, "snapshots.json"), JSON.stringify(data, null, 2), "utf-8");
2393
2391
  }
2394
2392
 
2395
2393
  //#endregion
@@ -2440,23 +2438,22 @@ async function createStaticCopyPlugin({ themeRoots, addonRoots }, pluginOptions)
2440
2438
  //#endregion
2441
2439
  //#region node/setups/unocss.ts
2442
2440
  async function setupUnocss({ clientRoot, roots, data, utils }) {
2443
- async function loadFileConfigs(root) {
2444
- return (await Promise.all([resolve(root, "uno.config.ts"), resolve(root, "unocss.config.ts")].map(async (i) => {
2441
+ function loadFileConfigs(root) {
2442
+ return [resolve(root, "uno.config.ts"), resolve(root, "unocss.config.ts")].map(async (i) => {
2445
2443
  if (!existsSync(i)) return void 0;
2446
2444
  const loaded = await loadModule(i);
2447
2445
  return "default" in loaded ? loaded.default : loaded;
2448
- }))).filter((x) => !!x);
2446
+ });
2449
2447
  }
2450
- const tokens = await loadModule(resolve(clientRoot, ".generated/unocss-tokens.ts"));
2451
2448
  const config = mergeConfigs([
2452
2449
  {
2453
2450
  presets: [presetIcons({
2454
2451
  collectionsNodeResolvePath: utils.iconsResolvePath,
2455
2452
  collections: { slidev: { logo: () => readFile(resolve(clientRoot, "assets/logo.svg"), "utf-8") } }
2456
2453
  })],
2457
- safelist: tokens
2454
+ safelist: await loadModule(resolve(clientRoot, ".generated/unocss-tokens.ts"))
2458
2455
  },
2459
- ...await loadFileConfigs(clientRoot),
2456
+ (await loadModule(resolve(clientRoot, "uno.config.ts"))).default,
2460
2457
  ...await loadSetups(roots, "unocss.ts", [], loadFileConfigs)
2461
2458
  ].filter(Boolean));
2462
2459
  config.theme ||= {};
@@ -2477,17 +2474,6 @@ async function createUnocssPlugin(options, pluginOptions) {
2477
2474
  });
2478
2475
  }
2479
2476
 
2480
- //#endregion
2481
- //#region node/vite/userPlugins.ts
2482
- async function createUserVitePlugins(options) {
2483
- const createPluginTasks = options.roots.map(async (root) => {
2484
- const modulePath = path.join(root, "setup", "vite-plugins.ts");
2485
- if (existsSync(modulePath)) return (await loadModule(modulePath)).default(options);
2486
- return [];
2487
- });
2488
- return (await Promise.all(createPluginTasks)).flatMap((p) => p);
2489
- }
2490
-
2491
2477
  //#endregion
2492
2478
  //#region node/vite/vue.ts
2493
2479
  const customElements = new Set([
@@ -2565,8 +2551,8 @@ function ViteSlidevPlugin(options, pluginOptions = {}, serverOptions = {}) {
2565
2551
  createUnocssPlugin(options, pluginOptions),
2566
2552
  createStaticCopyPlugin(options, pluginOptions),
2567
2553
  createInspectPlugin(options, pluginOptions),
2568
- createUserVitePlugins(options),
2569
- createPatchMonacoSourceMapPlugin()
2554
+ createPatchMonacoSourceMapPlugin(),
2555
+ setupVitePlugins(options)
2570
2556
  ]);
2571
2557
  }
2572
2558
 
@@ -2601,4 +2587,4 @@ async function resolveViteConfigs(options, baseConfig, overrideConfigs, command,
2601
2587
  }
2602
2588
 
2603
2589
  //#endregion
2604
- export { loadSetups as a, resolveTheme as c, version as d, resolveOptions as i, resolveAddons as l, ViteSlidevPlugin as n, parser as o, createDataUtils as r, getThemeMeta as s, resolveViteConfigs as t, updateFrontmatterPatch as u };
2590
+ export { parser as a, resolveAddons as c, updateFrontmatterPatch as d, resolveOptions as i, version as l, ViteSlidevPlugin as n, getThemeMeta as o, createDataUtils as r, resolveTheme as s, resolveViteConfigs as t, loadSetups as u };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
3
  "type": "module",
4
- "version": "52.9.1",
4
+ "version": "52.10.0",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -48,13 +48,13 @@
48
48
  "@iconify-json/ph": "^1.2.2",
49
49
  "@iconify-json/svg-spinners": "^1.2.4",
50
50
  "@lillallol/outline-pdf": "^4.0.0",
51
- "@shikijs/markdown-it": "^3.15.0",
52
- "@shikijs/twoslash": "^3.15.0",
53
- "@shikijs/vitepress-twoslash": "^3.15.0",
54
- "@unocss/extractor-mdc": "^66.5.5",
55
- "@unocss/reset": "^66.5.5",
56
- "@vitejs/plugin-vue": "^6.0.1",
57
- "@vitejs/plugin-vue-jsx": "^5.1.1",
51
+ "@shikijs/markdown-it": "^3.17.0",
52
+ "@shikijs/twoslash": "^3.17.0",
53
+ "@shikijs/vitepress-twoslash": "^3.17.0",
54
+ "@unocss/extractor-mdc": "^66.5.9",
55
+ "@unocss/reset": "^66.5.9",
56
+ "@vitejs/plugin-vue": "^6.0.2",
57
+ "@vitejs/plugin-vue-jsx": "^5.1.2",
58
58
  "ansis": "^4.2.0",
59
59
  "chokidar": "^4.0.3",
60
60
  "cli-progress": "^3.12.0",
@@ -75,9 +75,9 @@
75
75
  "markdown-it-footnote": "^4.0.0",
76
76
  "markdown-it-mdc": "^0.2.6",
77
77
  "mlly": "^1.8.0",
78
- "monaco-editor": "^0.54.0",
79
- "obug": "^2.0.0",
80
- "open": "^10.2.0",
78
+ "monaco-editor": "^0.55.1",
79
+ "obug": "^2.1.1",
80
+ "open": "^11.0.0",
81
81
  "pdf-lib": "^1.17.1",
82
82
  "picomatch": "^4.0.3",
83
83
  "plantuml-encoder": "^1.4.0",
@@ -88,30 +88,30 @@
88
88
  "resolve-from": "^5.0.0",
89
89
  "resolve-global": "^2.0.0",
90
90
  "semver": "^7.7.3",
91
- "shiki": "^3.15.0",
91
+ "shiki": "^3.17.0",
92
92
  "shiki-magic-move": "^1.2.1",
93
93
  "sirv": "^3.0.2",
94
94
  "source-map-js": "^1.2.1",
95
95
  "typescript": "^5.9.3",
96
96
  "unhead": "^2.0.19",
97
- "unocss": "^66.5.5",
97
+ "unocss": "^66.5.9",
98
98
  "unplugin-icons": "^22.5.0",
99
99
  "unplugin-vue-components": "^30.0.0",
100
100
  "unplugin-vue-markdown": "^29.2.0",
101
101
  "untun": "^0.1.3",
102
102
  "uqr": "^0.1.2",
103
- "vite": "^7.2.2",
103
+ "vite": "^7.2.4",
104
104
  "vite-plugin-inspect": "^11.3.3",
105
105
  "vite-plugin-remote-assets": "^2.1.0",
106
106
  "vite-plugin-static-copy": "^3.1.4",
107
107
  "vite-plugin-vue-server-ref": "^1.0.0",
108
108
  "vitefu": "^1.1.1",
109
- "vue": "^3.5.24",
109
+ "vue": "^3.5.25",
110
110
  "yaml": "^2.8.1",
111
111
  "yargs": "^18.0.0",
112
- "@slidev/client": "52.9.1",
113
- "@slidev/parser": "52.9.1",
114
- "@slidev/types": "52.9.1"
112
+ "@slidev/client": "52.10.0",
113
+ "@slidev/parser": "52.10.0",
114
+ "@slidev/types": "52.10.0"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@hedgedoc/markdown-it-plugins": "^2.1.4",
@@ -1,24 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- export { };