@slidev/cli 0.35.5 → 0.36.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.
@@ -9,7 +9,7 @@ import {
9
9
  resolveImportPath,
10
10
  stringifyMarkdownTokens,
11
11
  toAtFS
12
- } from "./chunk-GVA336JI.mjs";
12
+ } from "./chunk-IAMILGBS.mjs";
13
13
 
14
14
  // ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
15
15
  var require_fast_deep_equal = __commonJS({
@@ -165,38 +165,40 @@ async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRo
165
165
  if (config.default)
166
166
  config = config.default;
167
167
  config = await loadSetups(roots, "windicss.ts", {}, config, true);
168
- return WindiCSS({
169
- configFiles: [configFile],
170
- config,
171
- onConfigResolved(config2) {
172
- if (!config2.theme)
173
- config2.theme = {};
174
- if (!config2.theme.extend)
175
- config2.theme.extend = {};
176
- if (!config2.theme.extend.fontFamily)
177
- config2.theme.extend.fontFamily = {};
178
- const fontFamily = config2.theme.extend.fontFamily;
179
- fontFamily.sans || (fontFamily.sans = data.config.fonts.sans.join(","));
180
- fontFamily.mono || (fontFamily.mono = data.config.fonts.mono.join(","));
181
- fontFamily.serif || (fontFamily.serif = data.config.fonts.serif.join(","));
182
- return config2;
183
- },
184
- onOptionsResolved(config2) {
185
- themeRoots.forEach((i) => {
186
- config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
187
- config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
188
- });
189
- addonRoots.forEach((i) => {
190
- config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
191
- config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
192
- });
193
- config2.scanOptions.include.push(`!${slash(resolve2(userRoot, "node_modules"))}`);
194
- config2.scanOptions.exclude.push(dirname(resolveImportPath("monaco-editor/package.json", true)));
195
- config2.scanOptions.exclude.push(dirname(resolveImportPath("katex/package.json", true)));
196
- config2.scanOptions.exclude.push(dirname(resolveImportPath("prettier/package.json", true)));
197
- },
198
- ...windiOptions
199
- });
168
+ return WindiCSS(
169
+ {
170
+ configFiles: [configFile],
171
+ config,
172
+ onConfigResolved(config2) {
173
+ if (!config2.theme)
174
+ config2.theme = {};
175
+ if (!config2.theme.extend)
176
+ config2.theme.extend = {};
177
+ if (!config2.theme.extend.fontFamily)
178
+ config2.theme.extend.fontFamily = {};
179
+ const fontFamily = config2.theme.extend.fontFamily;
180
+ fontFamily.sans || (fontFamily.sans = data.config.fonts.sans.join(","));
181
+ fontFamily.mono || (fontFamily.mono = data.config.fonts.mono.join(","));
182
+ fontFamily.serif || (fontFamily.serif = data.config.fonts.serif.join(","));
183
+ return config2;
184
+ },
185
+ onOptionsResolved(config2) {
186
+ themeRoots.forEach((i) => {
187
+ config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
188
+ config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
189
+ });
190
+ addonRoots.forEach((i) => {
191
+ config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
192
+ config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
193
+ });
194
+ config2.scanOptions.include.push(`!${slash(resolve2(userRoot, "node_modules"))}`);
195
+ config2.scanOptions.exclude.push(dirname(resolveImportPath("monaco-editor/package.json", true)));
196
+ config2.scanOptions.exclude.push(dirname(resolveImportPath("katex/package.json", true)));
197
+ config2.scanOptions.exclude.push(dirname(resolveImportPath("prettier/package.json", true)));
198
+ },
199
+ ...windiOptions
200
+ }
201
+ );
200
202
  }
201
203
 
202
204
  // node/plugins/preset.ts
@@ -209,6 +211,7 @@ import Components from "unplugin-vue-components/vite";
209
211
  import RemoteAssets, { DefaultRules } from "vite-plugin-remote-assets";
210
212
  import ServerRef from "vite-plugin-vue-server-ref";
211
213
  import { notNullish as notNullish2 } from "@antfu/utils";
214
+ import Inspect from "vite-plugin-inspect";
212
215
 
213
216
  // node/drawings.ts
214
217
  init_esm_shims();
@@ -216,7 +219,10 @@ import { basename, dirname as dirname2, join as join2, resolve as resolve3 } fro
216
219
  import fs2 from "fs-extra";
217
220
  import fg from "fast-glob";
218
221
  function resolveDrawingsDir(options) {
219
- return options.data.config.drawings.persist ? resolve3(dirname2(options.entry), options.data.config.drawings.persist) : void 0;
222
+ return options.data.config.drawings.persist ? resolve3(
223
+ dirname2(options.entry),
224
+ options.data.config.drawings.persist
225
+ ) : void 0;
220
226
  }
221
227
  async function loadDrawings(options) {
222
228
  const dir = resolveDrawingsDir(options);
@@ -247,14 +253,16 @@ async function writeDrawings(options, drawing) {
247
253
  const height = Math.round(width / options.data.config.aspectRatio);
248
254
  const SVG_HEAD = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
249
255
  await fs2.ensureDir(dir);
250
- return Promise.all(Object.entries(drawing).map(async ([key, value]) => {
251
- if (!value)
252
- return;
253
- const svg = `${SVG_HEAD}
256
+ return Promise.all(
257
+ Object.entries(drawing).map(async ([key, value]) => {
258
+ if (!value)
259
+ return;
260
+ const svg = `${SVG_HEAD}
254
261
  ${value}
255
262
  </svg>`;
256
- await fs2.writeFile(join2(dir, `${key}.svg`), svg, "utf-8");
257
- }));
263
+ await fs2.writeFile(join2(dir, `${key}.svg`), svg, "utf-8");
264
+ })
265
+ );
258
266
  }
259
267
 
260
268
  // node/plugins/extendConfig.ts
@@ -269,28 +277,28 @@ var dependencies = {
269
277
  "@antfu/utils": "^0.5.2",
270
278
  "@slidev/parser": "workspace:*",
271
279
  "@slidev/types": "workspace:*",
272
- "@unocss/reset": "^0.45.6",
273
- "@vueuse/core": "^9.1.0",
274
- "@vueuse/head": "^0.7.9",
275
- "@vueuse/math": "^9.1.0",
276
- "@vueuse/motion": "^2.0.0-beta.18",
280
+ "@unocss/reset": "^0.45.20",
281
+ "@vueuse/core": "^9.2.0",
282
+ "@vueuse/head": "^0.7.10",
283
+ "@vueuse/math": "^9.2.0",
284
+ "@vueuse/motion": "^2.0.0-beta.22",
277
285
  codemirror: "^5.65.5",
278
- defu: "^6.0.0",
279
- drauu: "^0.3.0",
286
+ defu: "^6.1.0",
287
+ drauu: "^0.3.1",
280
288
  "file-saver": "^2.0.5",
281
289
  "js-base64": "^3.7.2",
282
290
  "js-yaml": "^4.1.0",
283
- katex: "^0.16.0",
284
- mermaid: "^9.1.5",
285
- "monaco-editor": "^0.34.0",
291
+ katex: "^0.16.2",
292
+ mermaid: "^9.1.6",
293
+ "monaco-editor": "^0.33.0",
286
294
  nanoid: "^4.0.0",
287
295
  prettier: "^2.7.1",
288
296
  recordrtc: "^5.6.2",
289
297
  resolve: "^1.22.1",
290
- unocss: "^0.45.6",
291
- "vite-plugin-windicss": "^1.8.7",
292
- vue: "^3.2.37",
293
- "vue-router": "^4.1.3",
298
+ unocss: "^0.45.20",
299
+ "vite-plugin-windicss": "^1.8.8",
300
+ vue: "^3.2.39",
301
+ "vue-router": "^4.1.5",
294
302
  "vue-starport": "^0.3.0",
295
303
  windicss: "^3.5.6"
296
304
  };
@@ -555,22 +563,25 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
555
563
  Object.assign(data, newData);
556
564
  if (hmrPages.size > 0)
557
565
  moduleIds.add("/@slidev/titles.md");
558
- const vueModules = (await Promise.all(Array.from(hmrPages).map(async (i) => {
559
- var _a2;
560
- const file = `${slidePrefix}${i + 1}.md`;
561
- try {
562
- const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
563
- return await VuePlugin.handleHotUpdate({
564
- ...ctx,
565
- modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
566
- file,
567
- read() {
568
- return md2;
569
- }
570
- });
571
- } catch {
572
- }
573
- }))).flatMap((i) => i || []);
566
+ const vueModules = (await Promise.all(
567
+ Array.from(hmrPages).map(async (i) => {
568
+ var _a2;
569
+ const file = `${slidePrefix}${i + 1}.md`;
570
+ try {
571
+ const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
572
+ const handleHotUpdate = "handler" in VuePlugin.handleHotUpdate ? VuePlugin.handleHotUpdate.handler : VuePlugin.handleHotUpdate;
573
+ return await handleHotUpdate({
574
+ ...ctx,
575
+ modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
576
+ file,
577
+ read() {
578
+ return md2;
579
+ }
580
+ });
581
+ } catch {
582
+ }
583
+ })
584
+ )).flatMap((i) => i || []);
574
585
  hmrPages.clear();
575
586
  const moduleEntries = [
576
587
  ...vueModules,
@@ -820,11 +831,22 @@ defineProps<{ no: number | string }>()`);
820
831
  if (data.features.katex)
821
832
  imports.push(`import "${toAtFS(resolveImportPath("katex/dist/katex.min.css", true))}"`);
822
833
  if (data.config.css === "unocss") {
823
- imports.unshift('import "@unocss/reset/tailwind.css"', 'import "uno:preflights.css"', 'import "uno:typography.css"', 'import "uno:shortcuts.css"');
834
+ imports.unshift(
835
+ 'import "@unocss/reset/tailwind.css"',
836
+ 'import "uno:preflights.css"',
837
+ 'import "uno:typography.css"',
838
+ 'import "uno:shortcuts.css"'
839
+ );
824
840
  imports.push('import "uno.css"');
825
841
  } else {
826
- imports.unshift('import "virtual:windi-components.css"', 'import "virtual:windi-base.css"');
827
- imports.push('import "virtual:windi-utilities.css"', 'import "virtual:windi-devtools"');
842
+ imports.unshift(
843
+ 'import "virtual:windi-components.css"',
844
+ 'import "virtual:windi-base.css"'
845
+ );
846
+ imports.push(
847
+ 'import "virtual:windi-utilities.css"',
848
+ 'import "virtual:windi-devtools"'
849
+ );
828
850
  }
829
851
  return imports.join("\n");
830
852
  }
@@ -833,10 +855,13 @@ defineProps<{ no: number | string }>()`);
833
855
  }
834
856
  async function generateLayouts() {
835
857
  const imports = [];
836
- const layouts = objectMap(await getLayouts(), (k, v) => {
837
- imports.push(`import __layout_${k} from "${toAtFS(v)}"`);
838
- return [k, `__layout_${k}`];
839
- });
858
+ const layouts = objectMap(
859
+ await getLayouts(),
860
+ (k, v) => {
861
+ imports.push(`import __layout_${k} from "${toAtFS(v)}"`);
862
+ return [k, `__layout_${k}`];
863
+ }
864
+ );
840
865
  return [
841
866
  imports.join("\n"),
842
867
  `export default {
@@ -982,10 +1007,13 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
982
1007
  enforce: "pre",
983
1008
  async transform(code, id) {
984
1009
  if (id.startsWith(setupEntry)) {
1010
+ let getInjections2 = function(isAwait = false, isChained = false) {
1011
+ return injections.join("\n").replace(/:AWAIT:/g, isAwait ? "await " : "").replace(/(,\s*)?:LAST:/g, isChained ? "$1injection_return" : "");
1012
+ };
1013
+ var getInjections = getInjections2;
985
1014
  const name = id.slice(setupEntry.length + 1);
986
1015
  const imports = [];
987
1016
  const injections = [];
988
- const asyncInjections = [];
989
1017
  const setups = uniq5([
990
1018
  ...themeRoots,
991
1019
  ...addonRoots,
@@ -995,35 +1023,28 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
995
1023
  if (!existsSync5(path))
996
1024
  return;
997
1025
  imports.push(`import __n${idx} from '${toAtFS(path)}'`);
998
- let fn = `__n${idx}`;
999
- let awaitFn = `await __n${idx}`;
1000
- if (/\binjection_return\b/g.test(code)) {
1026
+ let fn = `:AWAIT:__n${idx}`;
1027
+ if (/\binjection_return\b/g.test(code))
1001
1028
  fn = `injection_return = ${fn}`;
1002
- awaitFn = `injection_return = ${awaitFn}`;
1003
- }
1004
1029
  if (/\binjection_arg\b/g.test(code)) {
1005
1030
  fn += "(";
1006
- awaitFn += "(";
1007
1031
  const matches = Array.from(code.matchAll(/\binjection_arg(_\d+)?\b/g));
1008
1032
  const dedupedMatches = Array.from(new Set(matches.map((m) => m[0])));
1009
- dedupedMatches.forEach((key, index) => {
1010
- const isLast = index === dedupedMatches.length - 1;
1011
- const arg = key + (isLast ? "" : ",");
1012
- fn += arg;
1013
- awaitFn += arg;
1014
- });
1015
- fn += ")";
1016
- awaitFn += ")";
1033
+ fn += dedupedMatches.join(", ");
1034
+ fn += ", :LAST:)";
1017
1035
  } else {
1018
- fn += "()";
1019
- awaitFn += "()";
1036
+ fn += "(:LAST:)";
1020
1037
  }
1021
- injections.push(`// ${path}`, fn);
1022
- asyncInjections.push(`// ${path}`, awaitFn);
1038
+ injections.push(
1039
+ `// ${path}`,
1040
+ fn
1041
+ );
1023
1042
  });
1024
1043
  code = code.replace("/* __imports__ */", imports.join("\n"));
1025
- code = code.replace("/* __injections__ */", injections.join("\n"));
1026
- code = code.replace("/* __async_injections__ */", asyncInjections.join("\n"));
1044
+ code = code.replace("/* __injections__ */", getInjections2());
1045
+ code = code.replace("/* __async_injections__ */", getInjections2(true));
1046
+ code = code.replace("/* __chained_injections__ */", getInjections2(false, true));
1047
+ code = code.replace("/* __chained_async_injections__ */", getInjections2(true, true));
1027
1048
  return code;
1028
1049
  }
1029
1050
  return null;
@@ -1297,7 +1318,9 @@ var MarkdownItShiki = (markdownit, options = {}) => {
1297
1318
  const light = _highlighter.codeToHtml(trimmed, { lang: lang || "text", theme: darkModeThemes.light }).replace('<pre class="shiki"', '<pre class="slidev-code shiki shiki-light"');
1298
1319
  return escapeVueInCode(`<pre class="shiki-container">${dark}${light}</pre>`);
1299
1320
  } else {
1300
- return escapeVueInCode(_highlighter.codeToHtml(code, { lang: lang || "text" }).replace('<pre class="shiki"', '<pre class="slidev-code shiki"'));
1321
+ return escapeVueInCode(
1322
+ _highlighter.codeToHtml(code, { lang: lang || "text" }).replace('<pre class="shiki"', '<pre class="slidev-code shiki"')
1323
+ );
1301
1324
  }
1302
1325
  };
1303
1326
  };
@@ -1435,14 +1458,17 @@ function transformPageCSS(md2, id) {
1435
1458
  if (!page)
1436
1459
  return md2;
1437
1460
  const { isInsideCodeblocks } = getCodeBlocks(md2);
1438
- const result = md2.replace(/(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g, (full, start, css, end, index) => {
1439
- if (index < 0 || isInsideCodeblocks(index))
1440
- return full;
1441
- if (!start.includes("scoped"))
1442
- start = start.replace("<style", "<style scoped");
1443
- return `${start}
1461
+ const result = md2.replace(
1462
+ /(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g,
1463
+ (full, start, css, end, index) => {
1464
+ if (index < 0 || isInsideCodeblocks(index))
1465
+ return full;
1466
+ if (!start.includes("scoped"))
1467
+ start = start.replace("<style", "<style scoped");
1468
+ return `${start}
1444
1469
  ${css}${end}`;
1445
- });
1470
+ }
1471
+ );
1446
1472
  return result;
1447
1473
  }
1448
1474
  function transformMermaid(md2) {
@@ -1474,11 +1500,13 @@ function createFixPlugins(options) {
1474
1500
  name: "slidev:flags",
1475
1501
  enforce: "pre",
1476
1502
  transform(code, id) {
1477
- if (id.endsWith(".vue")) {
1503
+ if (id.match(/\.vue($|\?)/)) {
1504
+ const original = code;
1478
1505
  define.forEach(([from, to]) => {
1479
1506
  code = code.replace(new RegExp(from, "g"), to);
1480
1507
  });
1481
- return code;
1508
+ if (original !== code)
1509
+ return code;
1482
1510
  }
1483
1511
  }
1484
1512
  }
@@ -1639,7 +1667,11 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
1639
1667
  createConfigPlugin(options),
1640
1668
  createClientSetupPlugin(options),
1641
1669
  createMonacoTypesLoader(),
1642
- createFixPlugins(options)
1670
+ createFixPlugins(options),
1671
+ options.inspect ? Inspect({
1672
+ dev: true,
1673
+ build: true
1674
+ }) : null
1643
1675
  ].flat().filter(notNullish2);
1644
1676
  }
1645
1677
 
@@ -25,7 +25,10 @@ var __copyProps = (to, from, except, desc) => {
25
25
  }
26
26
  return to;
27
27
  };
28
- 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));
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
29
32
  var __accessCheck = (obj, member, msg) => {
30
33
  if (!member.has(obj))
31
34
  throw TypeError("Cannot " + msg);
@@ -55,12 +58,12 @@ var __privateWrapper = (obj, member, setter, getter) => {
55
58
  };
56
59
  };
57
60
 
58
- // ../../node_modules/.pnpm/tsup@5.12.9_typescript@4.7.4/node_modules/tsup/assets/esm_shims.js
61
+ // ../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.3/node_modules/tsup/assets/esm_shims.js
59
62
  import { fileURLToPath } from "url";
60
63
  import path from "path";
61
64
  var getFilename, getDirname, __dirname, __filename;
62
65
  var init_esm_shims = __esm({
63
- "../../node_modules/.pnpm/tsup@5.12.9_typescript@4.7.4/node_modules/tsup/assets/esm_shims.js"() {
66
+ "../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.3/node_modules/tsup/assets/esm_shims.js"() {
64
67
  getFilename = () => fileURLToPath(import.meta.url);
65
68
  getDirname = () => path.dirname(getFilename());
66
69
  __dirname = /* @__PURE__ */ getDirname();
@@ -115,10 +118,12 @@ function resolveGlobalImportPath(importName) {
115
118
  throw new Error(`Failed to resolve global package "${importName}"`);
116
119
  }
117
120
  function stringifyMarkdownTokens(tokens) {
118
- return tokens.map((token) => {
119
- var _a;
120
- return (_a = token.children) == null ? void 0 : _a.filter((t) => ["text", "code_inline"].includes(t.type) && !t.content.match(/^\s*$/)).map((t) => t.content.trim()).join(" ");
121
- }).filter(Boolean).join(" ");
121
+ return tokens.map(
122
+ (token) => {
123
+ var _a;
124
+ return (_a = token.children) == null ? void 0 : _a.filter((t) => ["text", "code_inline"].includes(t.type) && !t.content.match(/^\s*$/)).map((t) => t.content.trim()).join(" ");
125
+ }
126
+ ).filter(Boolean).join(" ");
122
127
  }
123
128
  function generateGoogleFontsUrl(options) {
124
129
  const weights = options.weights.flatMap((i) => options.italic ? [`0,${i}`, `1,${i}`] : [`${i}`]).sort().join(";");