@slidev/cli 0.48.0-beta.2 → 0.48.0-beta.3

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-FIXL4WBO.mjs";
5
+ } from "./chunk-JORVSTMS.mjs";
6
6
  import "./chunk-CTBVOVLQ.mjs";
7
7
  import "./chunk-DWXI5WEO.mjs";
8
8
  import "./chunk-BXO7ZPPU.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ViteSlidevPlugin,
3
3
  mergeViteConfigs
4
- } from "./chunk-FIXL4WBO.mjs";
4
+ } from "./chunk-JORVSTMS.mjs";
5
5
  import {
6
6
  packageExists,
7
7
  resolveImportPath
@@ -2536,7 +2536,7 @@ async function createServer(options2, viteConfig = {}, serverOptions = {}) {
2536
2536
  import * as parser from "@slidev/parser/fs";
2537
2537
 
2538
2538
  // package.json
2539
- var version = "0.48.0-beta.2";
2539
+ var version = "0.48.0-beta.3";
2540
2540
 
2541
2541
  // node/themes.ts
2542
2542
  import prompts2 from "prompts";
@@ -8007,7 +8007,7 @@ async function resolveOptions(options2, mode2, promptForInstallation = true) {
8007
8007
  entry,
8008
8008
  userRoot
8009
8009
  } = getUserRoot(options2);
8010
- const data = await parser.load(entry);
8010
+ const data = await parser.load(userRoot, entry);
8011
8011
  const theme = await resolveThemeName(options2.theme || data.config.theme);
8012
8012
  if (promptForInstallation) {
8013
8013
  if (await promptForThemeInstallation(theme) === false)
@@ -276,7 +276,7 @@ function getDefine(options) {
276
276
 
277
277
  // node/plugins/loaders.ts
278
278
  import { basename as basename2, join as join5 } from "node:path";
279
- import { isString, isTruthy, notNullish, objectMap, range, slash, uniq as uniq3 } from "@antfu/utils";
279
+ import { isString, isTruthy, notNullish, objectMap, range, uniq as uniq3 } from "@antfu/utils";
280
280
  import fg2 from "fast-glob";
281
281
  import fs4 from "fs-extra";
282
282
  import Markdown from "markdown-it";
@@ -323,7 +323,7 @@ md.use(mila, {
323
323
  rel: "noopener"
324
324
  }
325
325
  });
326
- function prepareSlideInfo(data) {
326
+ function renderNoteHTML(data) {
327
327
  return {
328
328
  ...data,
329
329
  noteHTML: md.render(data?.note || "")
@@ -348,7 +348,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
348
348
  const [, no, type] = match;
349
349
  const idx = Number.parseInt(no);
350
350
  if (type === "json" && req.method === "GET") {
351
- res.write(JSON.stringify(prepareSlideInfo(data.slides[idx])));
351
+ res.write(JSON.stringify(renderNoteHTML(data.slides[idx])));
352
352
  return res.end();
353
353
  }
354
354
  if (type === "json" && req.method === "POST") {
@@ -357,25 +357,21 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
357
357
  const onlyNoteChanged = Object.keys(body).length === 2 && "note" in body && body.raw === null;
358
358
  if (!onlyNoteChanged)
359
359
  hmrPages.add(idx);
360
- if (slide.source) {
361
- Object.assign(slide.source, body);
362
- await parser.saveExternalSlide(data, slide.source.filepath);
363
- } else {
364
- Object.assign(slide, body);
365
- await parser.save(data, entry);
366
- }
360
+ Object.assign(slide.source, body);
361
+ parser.prettifySlide(slide.source);
362
+ await parser.save(data.markdownFiles[slide.source.filepath]);
367
363
  res.statusCode = 200;
368
- res.write(JSON.stringify(prepareSlideInfo(slide)));
364
+ res.write(JSON.stringify(renderNoteHTML(slide)));
369
365
  return res.end();
370
366
  }
371
367
  next();
372
368
  });
373
369
  },
374
370
  async handleHotUpdate(ctx) {
375
- if (!data.entries.some((i) => slash(i) === ctx.file))
371
+ if (!data.watchFiles.includes(ctx.file))
376
372
  return;
377
373
  await ctx.read();
378
- const newData = await parser.load(entry, data.themeMeta);
374
+ const newData = await parser.load(userRoot, entry, data.themeMeta);
379
375
  const moduleIds = /* @__PURE__ */ new Set();
380
376
  if (data.slides.length !== newData.slides.length) {
381
377
  moduleIds.add("/@slidev/routes");
@@ -422,7 +418,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
422
418
  event: "slidev-update",
423
419
  data: {
424
420
  id: i,
425
- data: prepareSlideInfo(newData.slides[i])
421
+ data: renderNoteHTML(newData.slides[i])
426
422
  }
427
423
  });
428
424
  hmrPages.add(i);
@@ -467,7 +463,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
467
463
  return generateCustomNavControls();
468
464
  if (id === "/@slidev/titles.md") {
469
465
  return {
470
- code: data.slides.filter(({ frontmatter }) => !frontmatter?.disabled).map(({ title }, i) => `<template ${i === 0 ? "v-if" : "v-else-if"}="+no === ${i + 1}">
466
+ code: data.slides.map(({ title }, i) => `<template ${i === 0 ? "v-if" : "v-else-if"}="+no === ${i + 1}">
471
467
 
472
468
  ${title}
473
469
 
@@ -491,7 +487,7 @@ ${title}
491
487
  };
492
488
  } else if (type === "frontmatter") {
493
489
  const slideBase = {
494
- ...prepareSlideInfo(slide),
490
+ ...renderNoteHTML(slide),
495
491
  frontmatter: void 0,
496
492
  // remove raw content in build, optimize the bundle size
497
493
  ...mode === "build" ? { raw: "", content: "", note: "" } : {}
@@ -625,7 +621,7 @@ ${title}
625
621
  function updateServerWatcher() {
626
622
  if (!server)
627
623
  return;
628
- server.watcher.add(data.entries?.map(slash) || []);
624
+ server.watcher.add(data.watchFiles);
629
625
  }
630
626
  function getFrontmatter(pageNo) {
631
627
  return {
@@ -812,7 +808,7 @@ defineProps<{ no: number | string }>()`);
812
808
  return imports.join("\n");
813
809
  }
814
810
  async function generateMonacoTypes() {
815
- return `void 0; ${parser.scanMonacoModules(data.raw).map((i) => `import('/@slidev-monaco-types/${i}')`).join("\n")}`;
811
+ return `void 0; ${parser.scanMonacoModules(data.slides.map((s) => s.source.raw).join()).map((i) => `import('/@slidev-monaco-types/${i}')`).join("\n")}`;
816
812
  }
817
813
  async function generateLayouts() {
818
814
  const imports = [];
@@ -836,7 +832,7 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
836
832
  const layouts = await getLayouts();
837
833
  imports.push(`import __layout__end from '${layouts.end}'`);
838
834
  let no = 1;
839
- const routes = data.slides.filter(({ frontmatter }) => !frontmatter?.disabled).map((i, idx) => {
835
+ const routes = data.slides.map((i, idx) => {
840
836
  imports.push(`import n${no} from '${slidePrefix}${idx + 1}.md'`);
841
837
  imports.push(`import { meta as f${no} } from '${slidePrefix}${idx + 1}.frontmatter'`);
842
838
  const route = `{ path: '${no}', name: 'page-${no}', component: n${no}, meta: f${no} }`;
@@ -922,7 +918,7 @@ export default {
922
918
  import { dirname as dirname4, join as join6 } from "node:path";
923
919
  import fs5 from "node:fs/promises";
924
920
  import process from "node:process";
925
- import { slash as slash2 } from "@antfu/utils";
921
+ import { slash } from "@antfu/utils";
926
922
  import { findDepPkgJsonPath } from "vitefu";
927
923
  async function getPackageData(pkg) {
928
924
  const pkgJsonPath = await findDepPkgJsonPath(pkg, process.cwd());
@@ -952,7 +948,7 @@ function createMonacoTypesLoader() {
952
948
  const [pkgDir, pkgJson, typePath] = packageData;
953
949
  return [
954
950
  "import * as monaco from 'monaco-editor'",
955
- `import Type from "${slash2(join6(pkgDir, typePath))}?raw"`,
951
+ `import Type from "${slash(join6(pkgDir, typePath))}?raw"`,
956
952
  ...Object.keys(pkgJson.dependencies || {}).map((i) => `import "/@slidev-monaco-types/${i}"`),
957
953
  `monaco.languages.typescript.typescriptDefaults.addExtraLib(\`declare module "${pkg}" { \${Type} }\`)`
958
954
  ].join("\n");
@@ -964,9 +960,9 @@ function createMonacoTypesLoader() {
964
960
  // node/plugins/setupClient.ts
965
961
  import { existsSync as existsSync2 } from "node:fs";
966
962
  import { join as join7, resolve as resolve2 } from "node:path";
967
- import { slash as slash3, uniq as uniq4 } from "@antfu/utils";
963
+ import { slash as slash2, uniq as uniq4 } from "@antfu/utils";
968
964
  function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot }) {
969
- const setupEntry = slash3(resolve2(clientRoot, "setup"));
965
+ const setupEntry = slash2(resolve2(clientRoot, "setup"));
970
966
  return {
971
967
  name: "slidev:setup",
972
968
  enforce: "pre",
@@ -1021,7 +1017,7 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
1021
1017
  import fs7 from "node:fs/promises";
1022
1018
  import Markdown2 from "unplugin-vue-markdown/vite";
1023
1019
  import * as base64 from "js-base64";
1024
- import { slash as slash4 } from "@antfu/utils";
1020
+ import { slash as slash3 } from "@antfu/utils";
1025
1021
  import mila2 from "markdown-it-link-attributes";
1026
1022
  import mif from "markdown-it-footnote";
1027
1023
 
@@ -1471,7 +1467,7 @@ function transformSnippet(md2, options, id) {
1471
1467
  (full, filepath = "", regionName = "", lang = "", meta = "") => {
1472
1468
  const firstLine = `\`\`\`${lang || path.extname(filepath).slice(1)} ${meta}`;
1473
1469
  const src = /^\@[\/]/.test(filepath) ? path.resolve(options.userRoot, filepath.slice(2)) : path.resolve(dir, filepath);
1474
- data.entries.push(src);
1470
+ data.watchFiles.push(src);
1475
1471
  const isAFile = fs6.statSync(src).isFile();
1476
1472
  if (!fs6.existsSync(src) || !isAFile) {
1477
1473
  throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
@@ -1499,7 +1495,7 @@ ${content}
1499
1495
  async function createMarkdownPlugin(options, { markdown: mdOptions }) {
1500
1496
  const { data: { config }, roots, mode, entry } = options;
1501
1497
  const setups = [];
1502
- const entryPath = slash4(entry);
1498
+ const entryPath = slash3(entry);
1503
1499
  if (config.highlighter === "shiki") {
1504
1500
  const MarkdownItShiki = await import("@shikijs/markdown-it").then((r) => r.default);
1505
1501
  const { transformerTwoslash } = await import("@shikijs/vitepress-twoslash");
package/dist/cli.mjs CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  resolveOptions,
10
10
  resolveThemeName,
11
11
  version
12
- } from "./chunk-PDMXU2K7.mjs";
13
- import "./chunk-FIXL4WBO.mjs";
12
+ } from "./chunk-HESHEOWV.mjs";
13
+ import "./chunk-JORVSTMS.mjs";
14
14
  import {
15
15
  loadSetups
16
16
  } from "./chunk-CTBVOVLQ.mjs";
@@ -89,8 +89,12 @@ cli.command(
89
89
  default: false,
90
90
  type: "boolean",
91
91
  describe: "force the optimizer to ignore the cache and re-bundle "
92
+ }).option("bind", {
93
+ type: "string",
94
+ default: "0.0.0.0",
95
+ describe: "specify which IP addresses the server should listen on in remote mode"
92
96
  }).strict().help(),
93
- async ({ entry, theme, port: userPort, open, log, remote, tunnel, force, inspect }) => {
97
+ async ({ entry, theme, port: userPort, open, log, remote, tunnel, force, inspect, bind }) => {
94
98
  if (!fs.existsSync(entry) && !entry.endsWith(".md"))
95
99
  entry = `${entry}.md`;
96
100
  if (!fs.existsSync(entry)) {
@@ -120,7 +124,7 @@ cli.command(
120
124
  port,
121
125
  strictPort: true,
122
126
  open,
123
- host: remote !== void 0 ? "0.0.0.0" : "localhost",
127
+ host: remote !== void 0 ? bind : "localhost",
124
128
  // @ts-expect-error Vite <= 4
125
129
  force
126
130
  },
@@ -269,7 +273,7 @@ cli.command(
269
273
  }).strict().help(),
270
274
  async (args) => {
271
275
  const { entry, theme, watch, base, download, out, inspect } = args;
272
- const { build } = await import("./build-BVDM4ZAC.mjs");
276
+ const { build } = await import("./build-VKH7FQSN.mjs");
273
277
  for (const entryFile of entry) {
274
278
  const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
275
279
  if (download && !options.data.config.download)
@@ -291,9 +295,9 @@ cli.command(
291
295
  (args) => commonOptions(args).strict().help(),
292
296
  async ({ entry }) => {
293
297
  for (const entryFile of entry) {
294
- const data = await parser.load(entryFile);
295
- parser.prettify(data);
296
- await parser.save(data);
298
+ const md = await parser.parse(await fs.readFile(entryFile, "utf-8"), entryFile);
299
+ parser.prettify(md);
300
+ await parser.save(md);
297
301
  }
298
302
  }
299
303
  );
@@ -309,7 +313,8 @@ cli.command(
309
313
  default: "theme"
310
314
  }),
311
315
  async ({ entry, dir, theme: themeInput }) => {
312
- const data = await parser.load(entry);
316
+ const { userRoot } = getUserRoot({ entry });
317
+ const data = await parser.load(userRoot, entry);
313
318
  const theme = await resolveThemeName(themeInput || data.config.theme);
314
319
  if (theme === "none") {
315
320
  console.error('Cannot eject theme "none"');
@@ -329,9 +334,10 @@ cli.command(
329
334
  filter: (i) => !/node_modules|.git/.test(path.relative(root, i))
330
335
  });
331
336
  const dirPath = `./${dir}`;
332
- data.slides[0].frontmatter.theme = dirPath;
333
- data.slides[0].raw = null;
334
- await parser.save(data);
337
+ const firstSlide = data.entry.slides[0];
338
+ firstSlide.frontmatter.theme = dirPath;
339
+ parser.prettifySlide(firstSlide);
340
+ await parser.save(data.entry);
335
341
  console.log(`Theme "${theme}" ejected successfully to "${dirPath}"`);
336
342
  }
337
343
  );
@@ -360,7 +366,6 @@ cli.command(
360
366
  );
361
367
  await server.listen(port);
362
368
  printInfo(options);
363
- parser.filterDisabled(options.data);
364
369
  const result = await exportSlides({
365
370
  port,
366
371
  ...getExportOptions({ ...args, entry: entryFile }, options)
@@ -405,7 +410,6 @@ cli.command(
405
410
  );
406
411
  await server.listen(port);
407
412
  printInfo(options);
408
- parser.filterDisabled(options.data);
409
413
  const result = await exportNotes({
410
414
  port,
411
415
  output: output || (options.data.config.exportFilename ? `${options.data.config.exportFilename}-notes` : `${path.basename(entryFile, ".md")}-export-notes`),
package/dist/index.d.mts CHANGED
@@ -7,7 +7,7 @@ import { VitePluginConfig } from 'unocss/vite';
7
7
  import RemoteAssets from 'vite-plugin-remote-assets';
8
8
  import ServerRef from 'vite-plugin-vue-server-ref';
9
9
  import { ArgumentsType } from '@antfu/utils';
10
- import { SlidevMarkdown } from '@slidev/types';
10
+ import { SlidevData } from '@slidev/types';
11
11
  import * as vite from 'vite';
12
12
  import { InlineConfig, Plugin } from 'vite';
13
13
  import * as fs from '@slidev/parser/fs';
@@ -40,7 +40,7 @@ interface SlidevEntryOptions {
40
40
  inspect?: boolean;
41
41
  }
42
42
  interface ResolvedSlidevOptions {
43
- data: SlidevMarkdown;
43
+ data: SlidevData;
44
44
  entry: string;
45
45
  userRoot: string;
46
46
  cliRoot: string;
@@ -64,7 +64,7 @@ interface SlidevPluginOptions extends SlidevEntryOptions {
64
64
  unocss?: VitePluginConfig;
65
65
  }
66
66
  interface SlidevServerOptions {
67
- onDataReload?: (newData: SlidevMarkdown, data: SlidevMarkdown) => void;
67
+ onDataReload?: (newData: SlidevData, data: SlidevData) => void;
68
68
  }
69
69
  declare function getClientRoot(): Promise<string>;
70
70
  declare function getCLIRoot(): string;
package/dist/index.mjs CHANGED
@@ -9,10 +9,10 @@ import {
9
9
  isPath,
10
10
  parser,
11
11
  resolveOptions
12
- } from "./chunk-PDMXU2K7.mjs";
12
+ } from "./chunk-HESHEOWV.mjs";
13
13
  import {
14
14
  ViteSlidevPlugin
15
- } from "./chunk-FIXL4WBO.mjs";
15
+ } from "./chunk-JORVSTMS.mjs";
16
16
  import "./chunk-CTBVOVLQ.mjs";
17
17
  import "./chunk-DWXI5WEO.mjs";
18
18
  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.2",
3
+ "version": "0.48.0-beta.3",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -47,9 +47,9 @@
47
47
  "@iconify-json/ph": "^1.1.11",
48
48
  "@lillallol/outline-pdf": "^4.0.0",
49
49
  "@mrdrogdrog/optional": "^1.2.1",
50
- "@shikijs/markdown-it": "^1.1.3",
51
- "@shikijs/twoslash": "^1.1.3",
52
- "@shikijs/vitepress-twoslash": "^1.1.3",
50
+ "@shikijs/markdown-it": "^1.1.5",
51
+ "@shikijs/twoslash": "^1.1.5",
52
+ "@shikijs/vitepress-twoslash": "^1.1.5",
53
53
  "@unocss/extractor-mdc": "^0.58.5",
54
54
  "@unocss/reset": "^0.58.5",
55
55
  "@vitejs/plugin-vue": "^5.0.4",
@@ -87,7 +87,7 @@
87
87
  "resolve": "^1.22.8",
88
88
  "resolve-from": "^5.0.0",
89
89
  "resolve-global": "^2.0.0",
90
- "shiki": "^1.1.3",
90
+ "shiki": "^1.1.5",
91
91
  "sirv": "^2.0.4",
92
92
  "typescript": "^5.3.3",
93
93
  "unocss": "^0.58.5",
@@ -104,9 +104,9 @@
104
104
  "vitefu": "^0.2.5",
105
105
  "vue": "^3.4.19",
106
106
  "yargs": "^17.7.2",
107
- "@slidev/client": "0.48.0-beta.2",
108
- "@slidev/types": "0.48.0-beta.2",
109
- "@slidev/parser": "0.48.0-beta.2"
107
+ "@slidev/client": "0.48.0-beta.3",
108
+ "@slidev/parser": "0.48.0-beta.3",
109
+ "@slidev/types": "0.48.0-beta.3"
110
110
  },
111
111
  "devDependencies": {
112
112
  "@hedgedoc/markdown-it-plugins": "^2.1.4",