@slidev/cli 0.48.0-beta.20 → 0.48.0-beta.21

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-O56CS6WQ.mjs";
5
+ } from "./chunk-NSAYO3FG.mjs";
6
6
  import "./chunk-O6TYYGU6.mjs";
7
7
  import "./chunk-CV7OWJOF.mjs";
8
8
 
@@ -62,7 +62,7 @@ async function build(options, viteConfig = {}, args) {
62
62
  await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
63
63
  `, "utf-8");
64
64
  if ([true, "true", "auto"].includes(options.data.config.download)) {
65
- const { exportSlides, getExportOptions } = await import("./export-65BQ7S5F.mjs");
65
+ const { exportSlides, getExportOptions } = await import("./export-QZQV5HQF.mjs");
66
66
  const port = 12445;
67
67
  const app = connect();
68
68
  const server = http.createServer(app);
@@ -3,7 +3,7 @@ import {
3
3
  checkEngine,
4
4
  mergeViteConfigs,
5
5
  version
6
- } from "./chunk-O56CS6WQ.mjs";
6
+ } from "./chunk-NSAYO3FG.mjs";
7
7
  import {
8
8
  createResolver,
9
9
  getRoots,
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-CV7OWJOF.mjs";
8
8
 
9
9
  // package.json
10
- var version = "0.48.0-beta.20";
10
+ var version = "0.48.0-beta.21";
11
11
 
12
12
  // node/common.ts
13
13
  import { existsSync, promises as fs } from "node:fs";
@@ -148,6 +148,7 @@ var dependencies = {
148
148
  "@antfu/utils": "^0.7.7",
149
149
  "@iconify-json/carbon": "^1.1.30",
150
150
  "@iconify-json/ph": "^1.1.11",
151
+ "@iconify-json/svg-spinners": "^1.1.2",
151
152
  "@shikijs/monaco": "^1.1.7",
152
153
  "@shikijs/vitepress-twoslash": "^1.1.7",
153
154
  "@slidev/parser": "workspace:*",
@@ -175,7 +176,7 @@ var dependencies = {
175
176
  "shiki-magic-move": "^0.1.0",
176
177
  typescript: "^5.3.3",
177
178
  unocss: "^0.58.5",
178
- vue: "^3.4.20",
179
+ vue: "^3.4.21",
179
180
  "vue-router": "^4.3.0"
180
181
  };
181
182
 
@@ -454,9 +455,6 @@ function startsWithTodoMarkdown(token) {
454
455
  return checkboxRegex.test(token.content);
455
456
  }
456
457
 
457
- // ../../node_modules/.pnpm/@hedgedoc+markdown-it-plugins@2.1.4_patch_hash=tuyuxytl56b2vxulpkzt2wf4o4_markdown-it@14.0.0/node_modules/@hedgedoc/markdown-it-plugins/dist/esm/toc/plugin.js
458
- import { Optional } from "@mrdrogdrog/optional";
459
-
460
458
  // node/plugins/markdown.ts
461
459
  import { encode as encodePlantUml } from "plantuml-encoder";
462
460
  import Mdc from "markdown-it-mdc";
@@ -1205,25 +1203,25 @@ function createSlidesLoader({ data, clientRoot, roots, remote, mode, userRoot },
1205
1203
  return [];
1206
1204
  const moduleIds = /* @__PURE__ */ new Set();
1207
1205
  if (data.slides.length !== newData.slides.length) {
1208
- moduleIds.add("/@slidev/routes");
1206
+ moduleIds.add("/@slidev/slides");
1209
1207
  range(newData.slides.length).map((i) => hmrPages.add(i));
1210
1208
  }
1211
1209
  if (!equal(data.headmatter.defaults, newData.headmatter.defaults)) {
1212
- moduleIds.add("/@slidev/routes");
1210
+ moduleIds.add("/@slidev/slides");
1213
1211
  range(data.slides.length).map((i) => hmrPages.add(i));
1214
1212
  }
1215
1213
  if (!equal(data.config, newData.config))
1216
1214
  moduleIds.add("/@slidev/configs");
1217
1215
  if (!equal(data.features, newData.features)) {
1218
1216
  setTimeout(() => {
1219
- ctx.server.ws.send({ type: "full-reload" });
1217
+ ctx.server.hot.send({ type: "full-reload" });
1220
1218
  }, 1);
1221
1219
  }
1222
- const length = Math.max(data.slides.length, newData.slides.length);
1220
+ const length = Math.min(data.slides.length, newData.slides.length);
1223
1221
  for (let i = 0; i < length; i++) {
1224
1222
  const a = data.slides[i];
1225
1223
  const b = newData.slides[i];
1226
- if (a?.content.trim() === b?.content.trim() && a?.title?.trim() === b?.title?.trim() && equal(a.frontmatter, b.frontmatter) && Object.entries(a.snippetsUsed ?? {}).every(([file, oldContent]) => {
1224
+ if (a.content.trim() === b.content.trim() && a.title?.trim() === b.title?.trim() && equal(a.frontmatter, b.frontmatter) && Object.entries(a.snippetsUsed ?? {}).every(([file, oldContent]) => {
1227
1225
  try {
1228
1226
  const newContent = fs5.readFileSync(file, "utf-8");
1229
1227
  return oldContent === newContent;
@@ -1231,27 +1229,25 @@ function createSlidesLoader({ data, clientRoot, roots, remote, mode, userRoot },
1231
1229
  return false;
1232
1230
  }
1233
1231
  })) {
1234
- if (a?.note !== b?.note) {
1235
- ctx.server.ws.send({
1236
- type: "custom",
1237
- event: "slidev-update-note",
1238
- data: {
1232
+ if (a.note !== b.note) {
1233
+ ctx.server.hot.send(
1234
+ "slidev:update-note",
1235
+ {
1239
1236
  id: i,
1240
1237
  note: b.note || "",
1241
1238
  noteHTML: renderNote(b.note || "")
1242
1239
  }
1243
- });
1240
+ );
1244
1241
  }
1245
1242
  continue;
1246
1243
  }
1247
- ctx.server.ws.send({
1248
- type: "custom",
1249
- event: "slidev-update",
1250
- data: {
1244
+ ctx.server.hot.send(
1245
+ "slidev:update-slide",
1246
+ {
1251
1247
  id: i,
1252
1248
  data: withRenderedNote(newData.slides[i])
1253
1249
  }
1254
- });
1250
+ );
1255
1251
  hmrPages.add(i);
1256
1252
  }
1257
1253
  Object.assign(data, newData);
@@ -1275,8 +1271,10 @@ function createSlidesLoader({ data, clientRoot, roots, remote, mode, userRoot },
1275
1271
  return null;
1276
1272
  },
1277
1273
  load(id) {
1274
+ if (id === "/@slidev/slides")
1275
+ return generateSlideRoutes();
1278
1276
  if (id === "/@slidev/routes")
1279
- return generateRoutes();
1277
+ return generateDummyRoutes();
1280
1278
  if (id === "/@slidev/layouts")
1281
1279
  return generateLayouts();
1282
1280
  if (id === "/@slidev/styles")
@@ -1672,31 +1670,51 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
1672
1670
  }`
1673
1671
  ].join("\n\n");
1674
1672
  }
1675
- async function generateRoutes() {
1676
- const imports = [];
1677
- const redirects = [];
1673
+ async function generateSlideRoutes() {
1678
1674
  const layouts = await getLayouts();
1679
- imports.push(
1680
- `import { markRaw } from 'vue'`,
1681
- `import __layout__end from '${layouts.end}'`
1682
- );
1683
- let no = 1;
1684
- const routes = data.slides.map((i, idx) => {
1685
- imports.push(`import n${no} from '${slidePrefix}${idx + 1}.md'`);
1686
- imports.push(`import { meta as f${no} } from '${slidePrefix}${idx + 1}.frontmatter'`);
1687
- const route = `{ path: '${no}', name: 'page-${no}', component: n${no}, meta: f${no} }`;
1688
- if (i.frontmatter?.routeAlias)
1689
- redirects.push(`{ path: '${i.frontmatter?.routeAlias}', redirect: { path: '${no}' } }`);
1690
- no += 1;
1691
- return route;
1675
+ const imports = [
1676
+ `import { shallowRef } from 'vue'`,
1677
+ `import * as __layout__error from '${layouts.error}'`
1678
+ ];
1679
+ const slides = data.slides.map((_, idx) => {
1680
+ const no = idx + 1;
1681
+ imports.push(`import { meta as f${no} } from '${slidePrefix}${no}.frontmatter'`);
1682
+ return `{
1683
+ no: ${no},
1684
+ meta: f${no},
1685
+ component: async () => {
1686
+ try {
1687
+ return await import('${slidePrefix}${no}.md')
1688
+ }
1689
+ catch {
1690
+ return __layout__error
1691
+ }
1692
+ },
1693
+ }`;
1692
1694
  });
1693
- const routesStr = `export const rawRoutes = [
1694
- ${routes.join(",\n")}
1695
- ].map(markRaw)`;
1696
- const redirectsStr = `export const redirects = [
1697
- ${redirects.join(",\n")}
1698
- ].map(markRaw)`;
1699
- return [...imports, routesStr, redirectsStr].join("\n");
1695
+ return [
1696
+ ...imports,
1697
+ `const data = [
1698
+ ${slides.join(",\n")}
1699
+ ]`,
1700
+ `export const slides = shallowRef([...data])`,
1701
+ `let oldRef = slides`,
1702
+ `export function update(old) {`,
1703
+ ` oldRef = old`,
1704
+ ` old.value = data`,
1705
+ `}`,
1706
+ `if (import.meta.hot) {`,
1707
+ ` import.meta.hot.accept(({ update }) => {`,
1708
+ ` update(oldRef)`,
1709
+ ` })`,
1710
+ `}`
1711
+ ].join("\n");
1712
+ }
1713
+ function generateDummyRoutes() {
1714
+ return [
1715
+ `export { slides } from '#slidev/slides'`,
1716
+ `console.warn('[slidev] #slidev/routes is deprecated, use #slidev/slides instead')`
1717
+ ].join("\n");
1700
1718
  }
1701
1719
  function getTitle() {
1702
1720
  if (isString(data.config.title)) {
package/dist/cli.mjs CHANGED
@@ -5,10 +5,10 @@ import {
5
5
  resolveAddons,
6
6
  resolveOptions,
7
7
  resolveTheme
8
- } from "./chunk-KNY3KC45.mjs";
8
+ } from "./chunk-AUSTPPCJ.mjs";
9
9
  import {
10
10
  version
11
- } from "./chunk-O56CS6WQ.mjs";
11
+ } from "./chunk-NSAYO3FG.mjs";
12
12
  import {
13
13
  loadSetups
14
14
  } from "./chunk-O6TYYGU6.mjs";
@@ -276,7 +276,7 @@ cli.command(
276
276
  }).strict().help(),
277
277
  async (args) => {
278
278
  const { entry, theme, watch, base, download, out, inspect } = args;
279
- const { build } = await import("./build-5AFXNUEB.mjs");
279
+ const { build } = await import("./build-LAWVABFK.mjs");
280
280
  for (const entryFile of entry) {
281
281
  const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
282
282
  if (download && !options.data.config.download)
@@ -351,7 +351,7 @@ cli.command(
351
351
  (args) => exportOptions(commonOptions(args)).strict().help(),
352
352
  async (args) => {
353
353
  const { entry, theme } = args;
354
- const { exportSlides, getExportOptions } = await import("./export-65BQ7S5F.mjs");
354
+ const { exportSlides, getExportOptions } = await import("./export-QZQV5HQF.mjs");
355
355
  const port = await getPort(12445);
356
356
  for (const entryFile of entry) {
357
357
  const options = await resolveOptions({ entry: entryFile, theme }, "export");
@@ -395,7 +395,7 @@ cli.command(
395
395
  output,
396
396
  timeout
397
397
  }) => {
398
- const { exportNotes } = await import("./export-65BQ7S5F.mjs");
398
+ const { exportNotes } = await import("./export-QZQV5HQF.mjs");
399
399
  const port = await getPort(12445);
400
400
  for (const entryFile of entry) {
401
401
  const options = await resolveOptions({ entry: entryFile }, "export");
@@ -19,6 +19,7 @@ function addToTree(tree, info, slideIndexes, level = 1) {
19
19
  addToTree(tree[tree.length - 1].children, info, slideIndexes, level + 1);
20
20
  } else {
21
21
  tree.push({
22
+ no: info.index,
22
23
  children: [],
23
24
  level,
24
25
  path: String(slideIndexes[info.index + 1]),
package/dist/index.mjs CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  createServer,
3
3
  parser,
4
4
  resolveOptions
5
- } from "./chunk-KNY3KC45.mjs";
5
+ } from "./chunk-AUSTPPCJ.mjs";
6
6
  import {
7
7
  ViteSlidevPlugin
8
- } from "./chunk-O56CS6WQ.mjs";
8
+ } from "./chunk-NSAYO3FG.mjs";
9
9
  import "./chunk-O6TYYGU6.mjs";
10
10
  import "./chunk-CV7OWJOF.mjs";
11
11
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
- "version": "0.48.0-beta.20",
3
+ "version": "0.48.0-beta.21",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -46,8 +46,8 @@
46
46
  "@antfu/utils": "^0.7.7",
47
47
  "@iconify-json/carbon": "^1.1.30",
48
48
  "@iconify-json/ph": "^1.1.11",
49
+ "@iconify-json/svg-spinners": "^1.1.2",
49
50
  "@lillallol/outline-pdf": "^4.0.0",
50
- "@mrdrogdrog/optional": "^1.2.1",
51
51
  "@shikijs/markdown-it": "^1.1.7",
52
52
  "@shikijs/twoslash": "^1.1.7",
53
53
  "@shikijs/vitepress-twoslash": "^1.1.7",
@@ -103,11 +103,11 @@
103
103
  "vite-plugin-static-copy": "^1.0.1",
104
104
  "vite-plugin-vue-server-ref": "^0.4.2",
105
105
  "vitefu": "^0.2.5",
106
- "vue": "^3.4.20",
106
+ "vue": "^3.4.21",
107
107
  "yargs": "^17.7.2",
108
- "@slidev/client": "0.48.0-beta.20",
109
- "@slidev/parser": "0.48.0-beta.20",
110
- "@slidev/types": "0.48.0-beta.20"
108
+ "@slidev/parser": "0.48.0-beta.21",
109
+ "@slidev/client": "0.48.0-beta.21",
110
+ "@slidev/types": "0.48.0-beta.21"
111
111
  },
112
112
  "devDependencies": {
113
113
  "@hedgedoc/markdown-it-plugins": "^2.1.4",