@slidev/cli 0.30.1 → 0.31.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.
@@ -28,6 +28,18 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
28
28
  return require.apply(this, arguments);
29
29
  throw new Error('Dynamic require of "' + x + '" is not supported');
30
30
  });
31
+ var __objRest = (source, exclude) => {
32
+ var target = {};
33
+ for (var prop in source)
34
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
35
+ target[prop] = source[prop];
36
+ if (source != null && __getOwnPropSymbols)
37
+ for (var prop of __getOwnPropSymbols(source)) {
38
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
39
+ target[prop] = source[prop];
40
+ }
41
+ return target;
42
+ };
31
43
  var __esm = (fn, res) => function __init() {
32
44
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
33
45
  };
@@ -47,13 +59,38 @@ var __copyProps = (to, from, except, desc) => {
47
59
  return to;
48
60
  };
49
61
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
62
+ var __accessCheck = (obj, member, msg) => {
63
+ if (!member.has(obj))
64
+ throw TypeError("Cannot " + msg);
65
+ };
66
+ var __privateGet = (obj, member, getter) => {
67
+ __accessCheck(obj, member, "read from private field");
68
+ return getter ? getter.call(obj) : member.get(obj);
69
+ };
70
+ var __privateAdd = (obj, member, value) => {
71
+ if (member.has(obj))
72
+ throw TypeError("Cannot add the same private member more than once");
73
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
74
+ };
75
+ var __privateSet = (obj, member, value, setter) => {
76
+ __accessCheck(obj, member, "write to private field");
77
+ setter ? setter.call(obj, value) : member.set(obj, value);
78
+ return value;
79
+ };
80
+ var __privateWrapper = (obj, member, setter, getter) => {
81
+ return {
82
+ set _(value) {
83
+ __privateSet(obj, member, value, setter);
84
+ },
85
+ get _() {
86
+ return __privateGet(obj, member, getter);
87
+ }
88
+ };
89
+ };
50
90
 
51
- // ../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.3/node_modules/tsup/assets/cjs_shims.js
52
- var getImportMetaUrl, importMetaUrl;
91
+ // ../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.4/node_modules/tsup/assets/cjs_shims.js
53
92
  var init_cjs_shims = __esm({
54
- "../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.3/node_modules/tsup/assets/cjs_shims.js"() {
55
- getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
56
- importMetaUrl = exports.importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
93
+ "../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.4/node_modules/tsup/assets/cjs_shims.js"() {
57
94
  }
58
95
  });
59
96
 
@@ -129,4 +166,8 @@ function generateGoogleFontsUrl(options) {
129
166
 
130
167
 
131
168
 
132
- exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__require = __require; exports.__commonJS = __commonJS; exports.__export = __export; exports.__toESM = __toESM; exports.importMetaUrl = importMetaUrl; exports.init_cjs_shims = init_cjs_shims; exports.toAtFS = toAtFS; exports.resolveImportPath = resolveImportPath; exports.resolveGlobalImportPath = resolveGlobalImportPath; exports.stringifyMarkdownTokens = stringifyMarkdownTokens; exports.generateGoogleFontsUrl = generateGoogleFontsUrl;
169
+
170
+
171
+
172
+
173
+ exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__require = __require; exports.__objRest = __objRest; exports.__commonJS = __commonJS; exports.__export = __export; exports.__toESM = __toESM; exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__privateWrapper = __privateWrapper; exports.init_cjs_shims = init_cjs_shims; exports.toAtFS = toAtFS; exports.resolveImportPath = resolveImportPath; exports.resolveGlobalImportPath = resolveGlobalImportPath; exports.stringifyMarkdownTokens = stringifyMarkdownTokens; exports.generateGoogleFontsUrl = generateGoogleFontsUrl;
@@ -11,7 +11,7 @@ import {
11
11
  resolveImportPath,
12
12
  stringifyMarkdownTokens,
13
13
  toAtFS
14
- } from "./chunk-XMETW2MS.mjs";
14
+ } from "./chunk-D6ZT4BYV.mjs";
15
15
 
16
16
  // ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
17
17
  var require_fast_deep_equal = __commonJS({
@@ -243,26 +243,26 @@ var dependencies = {
243
243
  "@antfu/utils": "^0.5.1",
244
244
  "@slidev/parser": "workspace:*",
245
245
  "@slidev/types": "workspace:*",
246
- "@vueuse/core": "^8.2.5",
247
- "@vueuse/head": "^0.7.5",
246
+ "@vueuse/core": "^8.4.1",
247
+ "@vueuse/head": "^0.7.6",
248
248
  "@vueuse/motion": "^2.0.0-beta.18",
249
- codemirror: "^5.65.2",
249
+ codemirror: "^5.65.3",
250
250
  defu: "^6.0.0",
251
251
  drauu: "^0.3.0",
252
252
  "file-saver": "^2.0.5",
253
253
  "js-base64": "^3.7.2",
254
254
  "js-yaml": "^4.1.0",
255
255
  katex: "^0.15.3",
256
- mermaid: "^9.0.0",
256
+ mermaid: "^9.0.1",
257
257
  "monaco-editor": "^0.33.0",
258
- nanoid: "^3.3.2",
258
+ nanoid: "^3.3.4",
259
259
  prettier: "^2.6.2",
260
260
  recordrtc: "^5.6.2",
261
261
  resolve: "^1.22.0",
262
262
  "vite-plugin-windicss": "^1.8.4",
263
- vue: "^3.2.32",
264
- "vue-router": "^4.0.14",
265
- "vue-starport": "^0.2.4",
263
+ vue: "^3.2.33",
264
+ "vue-router": "^4.0.15",
265
+ "vue-starport": "^0.2.10",
266
266
  windicss: "^3.5.1"
267
267
  };
268
268
 
@@ -388,6 +388,7 @@ function getDefine(options) {
388
388
  __SLIDEV_HASH_ROUTE__: JSON.stringify(options.data.config.routerMode === "hash"),
389
389
  __SLIDEV_FEATURE_DRAWINGS__: JSON.stringify(options.data.config.drawings.enabled === true || options.data.config.drawings.enabled === options.mode),
390
390
  __SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
391
+ __SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
391
392
  __DEV__: options.mode === "dev" ? "true" : "false"
392
393
  };
393
394
  }
@@ -472,7 +473,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
472
473
  });
473
474
  },
474
475
  async handleHotUpdate(ctx) {
475
- var _a;
476
+ var _a, _b, _c;
476
477
  if (!data.entries.some((i) => slash2(i) === ctx.file))
477
478
  return;
478
479
  const newData = await parser.load(entry, data.themeMeta);
@@ -496,7 +497,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
496
497
  for (let i = 0; i < length; i++) {
497
498
  const a = data.slides[i];
498
499
  const b = newData.slides[i];
499
- if ((a == null ? void 0 : a.content.trim()) === (b == null ? void 0 : b.content.trim()) && (a == null ? void 0 : a.note) === (b == null ? void 0 : b.note) && (0, import_fast_deep_equal.default)(a.frontmatter, b.frontmatter))
500
+ if ((a == null ? void 0 : a.content.trim()) === (b == null ? void 0 : b.content.trim()) && ((_a = a == null ? void 0 : a.title) == null ? void 0 : _a.trim()) === ((_b = b == null ? void 0 : b.title) == null ? void 0 : _b.trim()) && (a == null ? void 0 : a.note) === (b == null ? void 0 : b.note) && (0, import_fast_deep_equal.default)(a.frontmatter, b.frontmatter))
500
501
  continue;
501
502
  ctx.server.ws.send({
502
503
  type: "custom",
@@ -508,13 +509,15 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
508
509
  });
509
510
  hmrPages.add(i);
510
511
  }
511
- (_a = serverOptions.onDataReload) == null ? void 0 : _a.call(serverOptions, newData, data);
512
+ (_c = serverOptions.onDataReload) == null ? void 0 : _c.call(serverOptions, newData, data);
512
513
  Object.assign(data, newData);
514
+ if (hmrPages.size > 0)
515
+ moduleIds.add("/@slidev/titles.md");
513
516
  const vueModules = (await Promise.all(Array.from(hmrPages).map(async (i) => {
514
517
  var _a2;
515
518
  const file = `${slidePrefix}${i + 1}.md`;
516
519
  try {
517
- const md2 = await transformMarkdown(MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
520
+ const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
518
521
  return await VuePlugin.handleHotUpdate(__spreadProps(__spreadValues({}, ctx), {
519
522
  modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
520
523
  file,
@@ -559,6 +562,14 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
559
562
  return generateGlobalComponents("bottom");
560
563
  if (id === "/@slidev/custom-nav-controls")
561
564
  return generateCustomNavControls();
565
+ if (id === "/@slidev/titles.md") {
566
+ return {
567
+ code: data.slides.map(({ title }, i) => {
568
+ return `<template ${i === 0 ? "v-if" : "v-else-if"}="+no === ${i + 1}">${title}</template>`;
569
+ }).join(""),
570
+ map: {}
571
+ };
572
+ }
562
573
  if (id.startsWith(slidePrefix)) {
563
574
  const remaning = id.slice(slidePrefix.length);
564
575
  const match = remaning.match(regexIdQuery);
@@ -604,6 +615,15 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
604
615
  return;
605
616
  return transformVue(code);
606
617
  }
618
+ },
619
+ {
620
+ name: "slidev:title-transform:pre",
621
+ enforce: "pre",
622
+ transform(code, id) {
623
+ if (id !== "/@slidev/titles.md")
624
+ return;
625
+ return transformTitles(code);
626
+ }
607
627
  }
608
628
  ];
609
629
  function updateServerWatcher() {
@@ -694,6 +714,10 @@ ${code.slice(injectIndex)}`;
694
714
  ${imports.join("\n")}
695
715
  <\/script>
696
716
  ${code}`;
717
+ }
718
+ function transformTitles(code) {
719
+ return code.replace(/<template>\s*<div>\s*<p>/, "<template>").replace(/<\/p>\s*<\/div>\s*<\/template>/, "</template>").replace(/<script\ssetup>/, `<script setup lang="ts">
720
+ defineProps<{ no: number | string }>()`);
697
721
  }
698
722
  async function getLayouts() {
699
723
  const now = Date.now();
@@ -773,7 +797,7 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
773
797
  let no = 1;
774
798
  const routes = [
775
799
  ...data.slides.map((i, idx) => {
776
- var _a, _b;
800
+ var _a, _b, _c, _d;
777
801
  if ((_a = i.frontmatter) == null ? void 0 : _a.disabled)
778
802
  return void 0;
779
803
  imports.push(`import n${no} from '${slidePrefix}${idx + 1}.md'`);
@@ -793,9 +817,10 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
793
817
  };
794
818
  const meta = Object.assign({}, i.frontmatter, additions);
795
819
  const route = `{ path: '${no}', name: 'page-${no}', component: n${no}, meta: ${JSON.stringify(meta)} }`;
820
+ const redirect = ((_c = i.frontmatter) == null ? void 0 : _c.routeAlias) ? `{ path: '${(_d = i.frontmatter) == null ? void 0 : _d.routeAlias}', redirect: { path: '${no}' } }` : null;
796
821
  no += 1;
797
- return route;
798
- }).filter(notNullish),
822
+ return [route, redirect];
823
+ }).flat().filter(notNullish),
799
824
  `{ path: "${no}", component: __layout__end, meta: { layout: "end" } }`
800
825
  ];
801
826
  const routesStr = `export default [
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ViteSlidevPlugin
3
- } from "./chunk-4AVLCCHB.mjs";
3
+ } from "./chunk-SJH4ZSSX.mjs";
4
4
  import {
5
5
  init_esm_shims
6
- } from "./chunk-XMETW2MS.mjs";
6
+ } from "./chunk-D6ZT4BYV.mjs";
7
7
 
8
8
  // node/server.ts
9
9
  init_esm_shims();