@slidev/cli 52.16.0 → 52.17.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ Presentation <b>slide</b>s for <b>dev</b>elopers 🧑‍💻👩‍💻👨‍
19
19
  </p>
20
20
 
21
21
  <p align="center">
22
- <a href="https://twitter.com/antfu7/status/1389604687502995457">Video Preview</a> | <a href="https://sli.dev">Documentation</a>
22
+ <a href="https://x.com/antfu7/status/1389604687502995457">Video Preview</a> | <a href="https://sli.dev">Documentation</a>
23
23
  </p>
24
24
 
25
25
  <div align="center">
@@ -1,4 +1,4 @@
1
- import { n as resolveViteConfigs } from "./serve-bnzg299W.mjs";
1
+ import { n as resolveViteConfigs } from "./serve-bAegrEOc.mjs";
2
2
  import { join, resolve } from "node:path";
3
3
  import { build as build$1 } from "vite";
4
4
  import { existsSync } from "node:fs";
@@ -51,7 +51,7 @@ async function build(options, viteConfig = {}, args) {
51
51
  dev: true
52
52
  }));
53
53
  server.listen(port);
54
- const { exportSlides } = await import("./export-BHxAO7pf.mjs");
54
+ const { exportSlides } = await import("./export-_6QaMWg2.mjs");
55
55
  const tempDir = resolve(outDir, "temp");
56
56
  await fs$1.mkdir(tempDir, { recursive: true });
57
57
  await exportSlides({
@@ -64,7 +64,7 @@ async function build(options, viteConfig = {}, args) {
64
64
  range: "1",
65
65
  width: options.data.config.canvasWidth,
66
66
  height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
67
- routerMode: options.data.config.routerMode,
67
+ routerMode: options.data.config.routerMode === "memory" ? "history" : options.data.config.routerMode,
68
68
  waitUntil: "networkidle",
69
69
  timeout: args.timeout || 3e4,
70
70
  perSlide: true,
@@ -92,7 +92,7 @@ async function build(options, viteConfig = {}, args) {
92
92
  "true",
93
93
  "auto"
94
94
  ].includes(options.data.config.download)) {
95
- const { exportSlides, getExportOptions } = await import("./export-BHxAO7pf.mjs");
95
+ const { exportSlides, getExportOptions } = await import("./export-_6QaMWg2.mjs");
96
96
  const port = 12445;
97
97
  const app = connect();
98
98
  const server = http.createServer(app);
package/dist/cli.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { i as resolveEntry, r as isInstalledGlobally } from "./resolver-CZx9LFrt.mjs";
2
- import { a as resolveOptions, c as resolveTheme, d as updateFrontmatterPatch, l as version, o as parser, s as getThemeMeta, t as createServer, u as loadSetups } from "./serve-bnzg299W.mjs";
1
+ import { i as resolveEntry, r as isInstalledGlobally } from "./resolver-BBT539iz.mjs";
2
+ import { c as getThemeMeta, d as loadSetups, f as updateFrontmatterPatch, l as resolveTheme, o as resolveOptions, s as parser, t as createServer, u as version } from "./serve-bAegrEOc.mjs";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
5
5
  import fs from "node:fs/promises";
6
6
  import { blue, bold, cyan, cyanBright, dim, gray, green, underline, yellow } from "ansis";
7
7
  import { injectPreparserExtensionLoader } from "@slidev/parser/fs";
8
8
  import equal from "fast-deep-equal";
9
- import { exec } from "node:child_process";
9
+ import { execFile } from "node:child_process";
10
10
  import os from "node:os";
11
11
  import * as readline from "node:readline";
12
12
  import { verifyConfig } from "@slidev/parser";
@@ -202,7 +202,7 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
202
202
  name: "e",
203
203
  fullname: "edit",
204
204
  action() {
205
- exec(`code "${entry}"`);
205
+ execFile(process.env.EDITOR || "code", [entry]);
206
206
  }
207
207
  },
208
208
  {
@@ -288,15 +288,19 @@ cli.command("build [entry..]", "Build hostable SPA", (args) => exportOptions(com
288
288
  describe: "exclude speaker notes from the built output"
289
289
  }).option("router-mode", {
290
290
  type: "string",
291
- choices: ["hash", "history"],
292
- describe: "override routerMode in the built output (hash for subdirectory deploys like GitHub Pages)"
291
+ choices: [
292
+ "hash",
293
+ "history",
294
+ "memory"
295
+ ],
296
+ describe: "override routerMode in the built output (hash for subdirectory deploys like GitHub Pages; memory keeps the slide number out of the URL, for kiosk/follower decks)"
293
297
  }).option("inspect", {
294
298
  default: false,
295
299
  type: "boolean",
296
300
  describe: "enable the inspect plugin for debugging"
297
301
  }).strict().help(), async (args) => {
298
302
  const { entry, theme, base, download, out, inspect, "without-notes": withoutNotes, "router-mode": routerMode } = args;
299
- const { build } = await import("./build-BtXN8hyb.mjs");
303
+ const { build } = await import("./build-CsQUCdtJ.mjs");
300
304
  for (const entryFile of entry) {
301
305
  const options = await resolveOptions({
302
306
  entry: entryFile,
@@ -324,6 +328,10 @@ cli.command("format [entry..]", "Format the markdown file", (args) => commonOpti
324
328
  await parser.save(md);
325
329
  }
326
330
  });
331
+ cli.command("mcp [entry]", "Start an MCP (Model Context Protocol) server over stdio for AI agents to inspect and edit the slides", (args) => commonOptions(args).strict().help(), async ({ entry }) => {
332
+ const { startMcpStdioServer } = await import("./stdio-CjXw2-ks.mjs");
333
+ await startMcpStdioServer(await resolveEntry(entry));
334
+ });
327
335
  cli.command("theme [subcommand]", "Theme related operations", (command) => {
328
336
  return command.command("eject", "Eject current theme into local file system", (args) => commonOptions(args).option("dir", {
329
337
  type: "string",
@@ -361,7 +369,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
361
369
  });
362
370
  cli.command("export [entry..]", "Export slides to PDF", (args) => exportOptions(commonOptions(args)).strict().help(), async (args) => {
363
371
  const { entry, theme } = args;
364
- const { exportSlides, getExportOptions } = await import("./export-BHxAO7pf.mjs");
372
+ const { exportSlides, getExportOptions } = await import("./export-_6QaMWg2.mjs");
365
373
  const candidatePort = await getPort(12445);
366
374
  let warned = false;
367
375
  for (const entryFile of entry) {
@@ -413,7 +421,7 @@ cli.command("export-notes [entry..]", "Export slide notes to PDF", (args) => arg
413
421
  type: "number",
414
422
  describe: "wait for the specified ms before exporting"
415
423
  }).strict().help(), async ({ entry, output, timeout, wait }) => {
416
- const { exportNotes } = await import("./export-BHxAO7pf.mjs");
424
+ const { exportNotes } = await import("./export-_6QaMWg2.mjs");
417
425
  const candidatePort = await getPort(12445);
418
426
  for (const entryFile of entry) {
419
427
  const options = await resolveOptions({ entry: entryFile }, "export");
@@ -539,6 +547,7 @@ function printInfo(options, port, base, remote, tunnelUrl, publicIp) {
539
547
  if (options.utils.define.__SLIDEV_FEATURE_PRESENTER__) console.log(`${dim(" presenter mode ")} > ${blue(`${baseUrl}${presenterPath}`)}`);
540
548
  console.log(`${dim(" slides overview ")} > ${blue(`${baseUrl}${overviewPath}`)}`);
541
549
  if (options.utils.define.__SLIDEV_FEATURE_BROWSER_EXPORTER__) console.log(`${dim(" export slides")} > ${blue(`${baseUrl}/export/`)}`);
550
+ if (options.mode === "dev" && options.data.config.mcp !== false) console.log(`${dim(" mcp server (ai)")} > ${blue(`http://localhost:${bold(port)}/__mcp`)}`);
542
551
  if (options.inspect) console.log(`${dim(" vite inspector")} > ${yellow(`${baseUrl}/__inspect/`)}`);
543
552
  let lastRemoteUrl = "";
544
553
  if (remote !== void 0) {
@@ -1,4 +1,4 @@
1
- import { n as getRoots } from "./resolver-CZx9LFrt.mjs";
1
+ import { n as getRoots } from "./resolver-BBT539iz.mjs";
2
2
  import path, { dirname, relative } from "node:path";
3
3
  import process from "node:process";
4
4
  import fs from "node:fs/promises";
@@ -78,26 +78,29 @@ async function exportNotes({ port = 18724, base = "/", output = "notes", timeout
78
78
  const progress = createSlidevProgress(true);
79
79
  progress.start(1);
80
80
  if (!output.endsWith(".pdf")) output = `${output}.pdf`;
81
- await page.goto(`http://localhost:${port}${base}presenter/print`, {
82
- waitUntil: "networkidle",
83
- timeout
84
- });
85
- await page.waitForLoadState("networkidle");
86
- await page.emulateMedia({ media: "screen" });
87
- if (wait) await page.waitForTimeout(wait);
88
- await page.pdf({
89
- path: output,
90
- margin: {
91
- left: 0,
92
- top: 0,
93
- right: 0,
94
- bottom: 0
95
- },
96
- printBackground: true,
97
- preferCSSPageSize: true
98
- });
99
- progress.stop();
100
- browser.close();
81
+ try {
82
+ await page.goto(`http://localhost:${port}${base}presenter/print`, {
83
+ waitUntil: "networkidle",
84
+ timeout
85
+ });
86
+ await page.waitForLoadState("networkidle");
87
+ await page.emulateMedia({ media: "screen" });
88
+ if (wait) await page.waitForTimeout(wait);
89
+ await page.pdf({
90
+ path: output,
91
+ margin: {
92
+ left: 0,
93
+ top: 0,
94
+ right: 0,
95
+ bottom: 0
96
+ },
97
+ printBackground: true,
98
+ preferCSSPageSize: true
99
+ });
100
+ } finally {
101
+ progress.stop();
102
+ await browser.close();
103
+ }
101
104
  return output;
102
105
  }
103
106
  async function exportSlides({ port = 18724, total = 0, range, format = "pdf", output = "slides", slides, base = "/", timeout = 3e4, wait = 0, dark = false, routerMode = "history", width = 1920, height = 1080, withClicks = false, executablePath = void 0, withToc = false, perSlide = false, scale = 1, waitUntil, omitBackground = false }) {
@@ -113,13 +116,16 @@ async function exportSlides({ port = 18724, total = 0, range, format = "pdf", ou
113
116
  })).newPage();
114
117
  const progress = createSlidevProgress(!perSlide);
115
118
  progress.start(pages.length);
116
- if (format === "pdf") await genPagePdf();
117
- else if (format === "png") await genPagePng(output);
118
- else if (format === "md") await genPageMd();
119
- else if (format === "pptx") await genPagePptx(await genPagePng(false));
120
- else throw new Error(`[slidev] Unsupported exporting format "${format}"`);
121
- progress.stop();
122
- browser.close();
119
+ try {
120
+ if (format === "pdf") await genPagePdf();
121
+ else if (format === "png") await genPagePng(output);
122
+ else if (format === "md") await genPageMd();
123
+ else if (format === "pptx") await genPagePptx(await genPagePng(false));
124
+ else throw new Error(`[slidev] Unsupported exporting format "${format}"`);
125
+ } finally {
126
+ progress.stop();
127
+ await browser.close();
128
+ }
123
129
  const relativeOutput = slash(relative(".", output));
124
130
  return relativeOutput.startsWith(".") ? relativeOutput : `./${relativeOutput}`;
125
131
  async function go(no, clicks) {
@@ -387,7 +393,7 @@ function getExportOptions(args, options, outFilename) {
387
393
  wait: wait ?? 0,
388
394
  waitUntil: waitUntil === "none" ? void 0 : waitUntil ?? "networkidle",
389
395
  dark: dark || options.data.config.colorSchema === "dark",
390
- routerMode: options.data.config.routerMode,
396
+ routerMode: options.data.config.routerMode === "memory" ? "history" : options.data.config.routerMode,
391
397
  width: options.data.config.canvasWidth,
392
398
  height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
393
399
  withClicks: withClicks ?? format === "pptx",
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { InlineConfig, PluginOption } from "vite";
2
2
  import * as parser from "@slidev/parser/fs";
3
3
  import { ResolvedSlidevOptions, ResolvedSlidevUtils, SlidevEntryOptions, SlidevPluginOptions, SlidevServerOptions } from "@slidev/types";
4
-
5
4
  //#region node/commands/serve.d.ts
6
5
  declare function createServer(options: ResolvedSlidevOptions, viteConfig?: InlineConfig, serverOptions?: SlidevServerOptions): Promise<import("vite").ViteDevServer>;
7
6
  //#endregion
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as resolveOptions, i as createDataUtils, o as parser, r as ViteSlidevPlugin, t as createServer } from "./serve-bnzg299W.mjs";
1
+ import { a as createDataUtils, o as resolveOptions, r as ViteSlidevPlugin, s as parser, t as createServer } from "./serve-bAegrEOc.mjs";
2
2
  export { ViteSlidevPlugin, createDataUtils, createServer, parser, resolveOptions };
@@ -229,12 +229,14 @@ async function getRoots(entry) {
229
229
  isInstalledGlobally.value = slash(relative(userRoot, process.argv[1])).includes("/.pnpm/") || invocationNodeModules != null && slash(relative(userRoot, invocationNodeModules)).startsWith("..") || (await import("is-installed-globally")).default;
230
230
  const clientRoot = await findPkgRoot("@slidev/client", cliRoot, true);
231
231
  const closestPkgRoot = dirname(await findClosestPkgJsonPath(userRoot) || userRoot);
232
+ const userPkgJson = await getUserPkgJson(closestPkgRoot);
233
+ const userWorkspaceRoot = await searchForWorkspaceRoot(closestPkgRoot);
232
234
  rootsInfo = {
233
235
  cliRoot,
234
236
  clientRoot,
235
237
  userRoot,
236
- userPkgJson: await getUserPkgJson(closestPkgRoot),
237
- userWorkspaceRoot: await searchForWorkspaceRoot(closestPkgRoot)
238
+ userPkgJson,
239
+ userWorkspaceRoot
238
240
  };
239
241
  return rootsInfo;
240
242
  }