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

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-ADTW2LD4.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);
@@ -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.22";
11
11
 
12
12
  // node/common.ts
13
13
  import { existsSync, promises as fs } from "node:fs";
@@ -146,15 +146,16 @@ import { uniq } from "@antfu/utils";
146
146
  // ../client/package.json
147
147
  var dependencies = {
148
148
  "@antfu/utils": "^0.7.7",
149
- "@iconify-json/carbon": "^1.1.30",
149
+ "@iconify-json/carbon": "^1.1.31",
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:*",
154
155
  "@slidev/rough-notation": "^0.1.0",
155
156
  "@slidev/types": "workspace:*",
156
157
  "@typescript/ata": "^0.9.4",
157
- "@unhead/vue": "^1.8.10",
158
+ "@unhead/vue": "^1.8.11",
158
159
  "@unocss/reset": "^0.58.5",
159
160
  "@vueuse/core": "^10.9.0",
160
161
  "@vueuse/math": "^10.9.0",
@@ -172,22 +173,29 @@ var dependencies = {
172
173
  prettier: "^3.2.5",
173
174
  recordrtc: "^5.6.2",
174
175
  shiki: "^1.1.7",
175
- "shiki-magic-move": "^0.1.0",
176
+ "shiki-magic-move": "^0.3.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
 
182
183
  // node/plugins/extendConfig.ts
183
184
  var INCLUDE = [
184
185
  ...Object.keys(dependencies),
186
+ // CodeMirror
185
187
  "codemirror/mode/javascript/javascript",
186
188
  "codemirror/mode/css/css",
187
189
  "codemirror/mode/markdown/markdown",
188
190
  "codemirror/mode/xml/xml",
189
191
  "codemirror/mode/htmlmixed/htmlmixed",
190
- "codemirror/addon/display/placeholder"
192
+ "codemirror/addon/display/placeholder",
193
+ // Monaco
194
+ "monaco-editor/esm/vs/editor/standalone/browser/standaloneServices",
195
+ "monaco-editor/esm/vs/platform/contextview/browser/contextViewService",
196
+ "monaco-editor/esm/vs/platform/instantiation/common/descriptors",
197
+ // Others
198
+ "shiki-magic-move/vue"
191
199
  ];
192
200
  var EXCLUDE = [
193
201
  "@slidev/shared",
@@ -454,13 +462,10 @@ function startsWithTodoMarkdown(token) {
454
462
  return checkboxRegex.test(token.content);
455
463
  }
456
464
 
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
465
  // node/plugins/markdown.ts
461
466
  import { encode as encodePlantUml } from "plantuml-encoder";
462
467
  import Mdc from "markdown-it-mdc";
463
- import { codeToKeyedTokens, createMagicMoveMachine } from "shiki-magic-move/core";
468
+ import { codeToKeyedTokens } from "shiki-magic-move/core";
464
469
  import mila from "markdown-it-link-attributes";
465
470
  import mif from "markdown-it-footnote";
466
471
  import lz from "lz-string";
@@ -981,30 +986,26 @@ function transformSlotSugar(md2) {
981
986
  lines[lines.length - 1] += "\n\n</template>";
982
987
  return lines.join("\n");
983
988
  }
984
- var reMagicMoveBlock = /^````(?:md|markdown) magic-move(?:[ ]*?({.*?})?([^\n]*?))?\n([\s\S]+?)^````$/mg;
989
+ var reMagicMoveBlock = /^````(?:md|markdown) magic-move(?:[ ]*(\{.*?\})?([^\n]*?))?\n([\s\S]+?)^````$/mg;
985
990
  var reCodeBlock = /^```(\w+?)(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?(.*?))?\n([\s\S]+?)^```$/mg;
986
991
  function transformMagicMove(md2, shiki2, shikiOptions2) {
987
992
  return md2.replace(
988
993
  reMagicMoveBlock,
989
- (full, _options = "", _attrs = "", body) => {
994
+ (full, options = "{}", _attrs = "", body) => {
990
995
  if (!shiki2 || !shikiOptions2)
991
996
  throw new Error("Shiki is required for Magic Move. You may need to set `highlighter: shiki` in your Slidev config.");
992
997
  const matches = Array.from(body.matchAll(reCodeBlock));
993
998
  if (!matches.length)
994
999
  throw new Error("Magic Move block must contain at least one code block");
995
- const langs = new Set(matches.map((i) => i[1]));
996
- if (langs.size > 1)
997
- throw new Error(`Magic Move block must contain code blocks with the same language, got ${Array.from(langs).join(", ")}`);
998
- const lang = Array.from(langs)[0];
999
- const magicMove = createMagicMoveMachine(
1000
- (code) => codeToKeyedTokens(shiki2, code, {
1000
+ const ranges = matches.map((i) => normalizeRangeStr(i[2]));
1001
+ const steps = matches.map(
1002
+ (i) => codeToKeyedTokens(shiki2, i[5].trimEnd(), {
1001
1003
  ...shikiOptions2,
1002
- lang
1004
+ lang: i[1]
1003
1005
  })
1004
1006
  );
1005
- const steps = matches.map((i) => magicMove.commit((i[5] || "").trimEnd()));
1006
1007
  const compressed = lz.compressToBase64(JSON.stringify(steps));
1007
- return `<ShikiMagicMove steps-lz="${compressed}" />`;
1008
+ return `<ShikiMagicMove v-bind="${options}" steps-lz="${compressed}" :step-ranges='${JSON.stringify(ranges)}' />`;
1008
1009
  }
1009
1010
  );
1010
1011
  }
@@ -1012,7 +1013,7 @@ function transformHighlighter(md2) {
1012
1013
  return md2.replace(
1013
1014
  reCodeBlock,
1014
1015
  (full, lang = "", rangeStr = "", options = "", attrs = "", code) => {
1015
- const ranges = !rangeStr.trim() ? [] : rangeStr.trim().split(/\|/g).map((i) => i.trim());
1016
+ const ranges = normalizeRangeStr(rangeStr);
1016
1017
  code = code.trimEnd();
1017
1018
  options = options.trim() || "{}";
1018
1019
  return `
@@ -1026,6 +1027,9 @@ ${code}
1026
1027
  }
1027
1028
  );
1028
1029
  }
1030
+ function normalizeRangeStr(rangeStr = "") {
1031
+ return !rangeStr.trim() ? [] : rangeStr.trim().split(/\|/g).map((i) => i.trim());
1032
+ }
1029
1033
  function getCodeBlocks(md2) {
1030
1034
  const codeblocks = Array.from(md2.matchAll(/^```[\s\S]*?^```/mg)).map((m) => {
1031
1035
  const start = m.index;
@@ -1176,7 +1180,7 @@ function createSlidesLoader({ data, clientRoot, roots, remote, mode, userRoot },
1176
1180
  if (!match)
1177
1181
  return next();
1178
1182
  const [, no, type] = match;
1179
- const idx = Number.parseInt(no);
1183
+ const idx = Number.parseInt(no) - 1;
1180
1184
  if (type === "json" && req.method === "GET") {
1181
1185
  res.write(JSON.stringify(withRenderedNote(data.slides[idx])));
1182
1186
  return res.end();
@@ -1205,25 +1209,25 @@ function createSlidesLoader({ data, clientRoot, roots, remote, mode, userRoot },
1205
1209
  return [];
1206
1210
  const moduleIds = /* @__PURE__ */ new Set();
1207
1211
  if (data.slides.length !== newData.slides.length) {
1208
- moduleIds.add("/@slidev/routes");
1212
+ moduleIds.add("/@slidev/slides");
1209
1213
  range(newData.slides.length).map((i) => hmrPages.add(i));
1210
1214
  }
1211
1215
  if (!equal(data.headmatter.defaults, newData.headmatter.defaults)) {
1212
- moduleIds.add("/@slidev/routes");
1216
+ moduleIds.add("/@slidev/slides");
1213
1217
  range(data.slides.length).map((i) => hmrPages.add(i));
1214
1218
  }
1215
1219
  if (!equal(data.config, newData.config))
1216
1220
  moduleIds.add("/@slidev/configs");
1217
1221
  if (!equal(data.features, newData.features)) {
1218
1222
  setTimeout(() => {
1219
- ctx.server.ws.send({ type: "full-reload" });
1223
+ ctx.server.hot.send({ type: "full-reload" });
1220
1224
  }, 1);
1221
1225
  }
1222
- const length = Math.max(data.slides.length, newData.slides.length);
1226
+ const length = Math.min(data.slides.length, newData.slides.length);
1223
1227
  for (let i = 0; i < length; i++) {
1224
1228
  const a = data.slides[i];
1225
1229
  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]) => {
1230
+ 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
1231
  try {
1228
1232
  const newContent = fs5.readFileSync(file, "utf-8");
1229
1233
  return oldContent === newContent;
@@ -1231,27 +1235,25 @@ function createSlidesLoader({ data, clientRoot, roots, remote, mode, userRoot },
1231
1235
  return false;
1232
1236
  }
1233
1237
  })) {
1234
- if (a?.note !== b?.note) {
1235
- ctx.server.ws.send({
1236
- type: "custom",
1237
- event: "slidev-update-note",
1238
- data: {
1238
+ if (a.note !== b.note) {
1239
+ ctx.server.hot.send(
1240
+ "slidev:update-note",
1241
+ {
1239
1242
  id: i,
1240
1243
  note: b.note || "",
1241
1244
  noteHTML: renderNote(b.note || "")
1242
1245
  }
1243
- });
1246
+ );
1244
1247
  }
1245
1248
  continue;
1246
1249
  }
1247
- ctx.server.ws.send({
1248
- type: "custom",
1249
- event: "slidev-update",
1250
- data: {
1250
+ ctx.server.hot.send(
1251
+ "slidev:update-slide",
1252
+ {
1251
1253
  id: i,
1252
1254
  data: withRenderedNote(newData.slides[i])
1253
1255
  }
1254
- });
1256
+ );
1255
1257
  hmrPages.add(i);
1256
1258
  }
1257
1259
  Object.assign(data, newData);
@@ -1275,8 +1277,10 @@ function createSlidesLoader({ data, clientRoot, roots, remote, mode, userRoot },
1275
1277
  return null;
1276
1278
  },
1277
1279
  load(id) {
1280
+ if (id === "/@slidev/slides")
1281
+ return generateSlideRoutes();
1278
1282
  if (id === "/@slidev/routes")
1279
- return generateRoutes();
1283
+ return generateDummyRoutes();
1280
1284
  if (id === "/@slidev/layouts")
1281
1285
  return generateLayouts();
1282
1286
  if (id === "/@slidev/styles")
@@ -1672,31 +1676,46 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
1672
1676
  }`
1673
1677
  ].join("\n\n");
1674
1678
  }
1675
- async function generateRoutes() {
1676
- const imports = [];
1677
- const redirects = [];
1679
+ async function generateSlideRoutes() {
1678
1680
  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;
1681
+ const imports = [
1682
+ `import { shallowRef } from 'vue'`,
1683
+ `import * as __layout__error from '${layouts.error}'`
1684
+ ];
1685
+ const slides = data.slides.map((_, idx) => {
1686
+ const no = idx + 1;
1687
+ imports.push(`import { meta as f${no} } from '${slidePrefix}${no}.frontmatter'`);
1688
+ return `{
1689
+ no: ${no},
1690
+ meta: f${no},
1691
+ component: async () => {
1692
+ try {
1693
+ return await import('${slidePrefix}${no}.md')
1694
+ }
1695
+ catch {
1696
+ return __layout__error
1697
+ }
1698
+ },
1699
+ }`;
1692
1700
  });
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");
1701
+ return [
1702
+ ...imports,
1703
+ `const data = [
1704
+ ${slides.join(",\n")}
1705
+ ]`,
1706
+ `import.meta.hot.data.slides ??= shallowRef()`,
1707
+ `import.meta.hot.data.slides.value = data`,
1708
+ `export const slides = import.meta.hot.data.slides`,
1709
+ `if (import.meta.hot) {`,
1710
+ ` import.meta.hot.accept()`,
1711
+ `}`
1712
+ ].join("\n");
1713
+ }
1714
+ function generateDummyRoutes() {
1715
+ return [
1716
+ `export { slides } from '#slidev/slides'`,
1717
+ `console.warn('[slidev] #slidev/routes is deprecated, use #slidev/slides instead')`
1718
+ ].join("\n");
1700
1719
  }
1701
1720
  function getTitle() {
1702
1721
  if (isString(data.config.title)) {
@@ -3,7 +3,7 @@ import {
3
3
  checkEngine,
4
4
  mergeViteConfigs,
5
5
  version
6
- } from "./chunk-O56CS6WQ.mjs";
6
+ } from "./chunk-ADTW2LD4.mjs";
7
7
  import {
8
8
  createResolver,
9
9
  getRoots,
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-BUGWF6XJ.mjs";
9
9
  import {
10
10
  version
11
- } from "./chunk-O56CS6WQ.mjs";
11
+ } from "./chunk-ADTW2LD4.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-LKM3MI3R.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-BUGWF6XJ.mjs";
6
6
  import {
7
7
  ViteSlidevPlugin
8
- } from "./chunk-O56CS6WQ.mjs";
8
+ } from "./chunk-ADTW2LD4.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.22",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -44,10 +44,10 @@
44
44
  "dependencies": {
45
45
  "@antfu/ni": "^0.21.12",
46
46
  "@antfu/utils": "^0.7.7",
47
- "@iconify-json/carbon": "^1.1.30",
47
+ "@iconify-json/carbon": "^1.1.31",
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",
@@ -88,7 +88,7 @@
88
88
  "resolve-global": "^2.0.0",
89
89
  "semver": "^7.6.0",
90
90
  "shiki": "^1.1.7",
91
- "shiki-magic-move": "^0.1.0",
91
+ "shiki-magic-move": "^0.3.0",
92
92
  "sirv": "^2.0.4",
93
93
  "typescript": "^5.3.3",
94
94
  "unocss": "^0.58.5",
@@ -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/types": "0.48.0-beta.22",
109
+ "@slidev/parser": "0.48.0-beta.22",
110
+ "@slidev/client": "0.48.0-beta.22"
111
111
  },
112
112
  "devDependencies": {
113
113
  "@hedgedoc/markdown-it-plugins": "^2.1.4",