@slidev/cli 0.35.4 → 0.36.0

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
@@ -216,7 +218,10 @@ import { basename, dirname as dirname2, join as join2, resolve as resolve3 } fro
216
218
  import fs2 from "fs-extra";
217
219
  import fg from "fast-glob";
218
220
  function resolveDrawingsDir(options) {
219
- return options.data.config.drawings.persist ? resolve3(dirname2(options.entry), options.data.config.drawings.persist) : void 0;
221
+ return options.data.config.drawings.persist ? resolve3(
222
+ dirname2(options.entry),
223
+ options.data.config.drawings.persist
224
+ ) : void 0;
220
225
  }
221
226
  async function loadDrawings(options) {
222
227
  const dir = resolveDrawingsDir(options);
@@ -247,14 +252,16 @@ async function writeDrawings(options, drawing) {
247
252
  const height = Math.round(width / options.data.config.aspectRatio);
248
253
  const SVG_HEAD = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
249
254
  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}
255
+ return Promise.all(
256
+ Object.entries(drawing).map(async ([key, value]) => {
257
+ if (!value)
258
+ return;
259
+ const svg = `${SVG_HEAD}
254
260
  ${value}
255
261
  </svg>`;
256
- await fs2.writeFile(join2(dir, `${key}.svg`), svg, "utf-8");
257
- }));
262
+ await fs2.writeFile(join2(dir, `${key}.svg`), svg, "utf-8");
263
+ })
264
+ );
258
265
  }
259
266
 
260
267
  // node/plugins/extendConfig.ts
@@ -269,28 +276,28 @@ var dependencies = {
269
276
  "@antfu/utils": "^0.5.2",
270
277
  "@slidev/parser": "workspace:*",
271
278
  "@slidev/types": "workspace:*",
272
- "@unocss/reset": "^0.45.1",
273
- "@vueuse/core": "^9.0.1",
274
- "@vueuse/head": "^0.7.8",
275
- "@vueuse/math": "^9.0.1",
276
- "@vueuse/motion": "^2.0.0-beta.18",
279
+ "@unocss/reset": "^0.45.20",
280
+ "@vueuse/core": "^9.2.0",
281
+ "@vueuse/head": "^0.7.10",
282
+ "@vueuse/math": "^9.2.0",
283
+ "@vueuse/motion": "^2.0.0-beta.22",
277
284
  codemirror: "^5.65.5",
278
- defu: "^6.0.0",
279
- drauu: "^0.3.0",
285
+ defu: "^6.1.0",
286
+ drauu: "^0.3.1",
280
287
  "file-saver": "^2.0.5",
281
288
  "js-base64": "^3.7.2",
282
289
  "js-yaml": "^4.1.0",
283
- katex: "^0.16.0",
284
- mermaid: "^9.1.3",
290
+ katex: "^0.16.2",
291
+ mermaid: "^9.1.6",
285
292
  "monaco-editor": "^0.33.0",
286
293
  nanoid: "^4.0.0",
287
294
  prettier: "^2.7.1",
288
295
  recordrtc: "^5.6.2",
289
296
  resolve: "^1.22.1",
290
- unocss: "^0.45.1",
291
- "vite-plugin-windicss": "^1.8.7",
292
- vue: "^3.2.37",
293
- "vue-router": "^4.1.3",
297
+ unocss: "^0.45.20",
298
+ "vite-plugin-windicss": "^1.8.8",
299
+ vue: "^3.2.39",
300
+ "vue-router": "^4.1.5",
294
301
  "vue-starport": "^0.3.0",
295
302
  windicss: "^3.5.6"
296
303
  };
@@ -342,6 +349,9 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
342
349
  var EXCLUDE = [
343
350
  "@slidev/shared",
344
351
  "@slidev/types",
352
+ "@slidev/client",
353
+ "@slidev/client/constants",
354
+ "@slidev/client/logic/dark",
345
355
  "@vueuse/core",
346
356
  "@vueuse/shared",
347
357
  "@unocss/reset",
@@ -552,22 +562,25 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
552
562
  Object.assign(data, newData);
553
563
  if (hmrPages.size > 0)
554
564
  moduleIds.add("/@slidev/titles.md");
555
- const vueModules = (await Promise.all(Array.from(hmrPages).map(async (i) => {
556
- var _a2;
557
- const file = `${slidePrefix}${i + 1}.md`;
558
- try {
559
- const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
560
- return await VuePlugin.handleHotUpdate({
561
- ...ctx,
562
- modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
563
- file,
564
- read() {
565
- return md2;
566
- }
567
- });
568
- } catch {
569
- }
570
- }))).flatMap((i) => i || []);
565
+ const vueModules = (await Promise.all(
566
+ Array.from(hmrPages).map(async (i) => {
567
+ var _a2;
568
+ const file = `${slidePrefix}${i + 1}.md`;
569
+ try {
570
+ const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
571
+ const handleHotUpdate = "handler" in VuePlugin.handleHotUpdate ? VuePlugin.handleHotUpdate.handler : VuePlugin.handleHotUpdate;
572
+ return await handleHotUpdate({
573
+ ...ctx,
574
+ modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
575
+ file,
576
+ read() {
577
+ return md2;
578
+ }
579
+ });
580
+ } catch {
581
+ }
582
+ })
583
+ )).flatMap((i) => i || []);
571
584
  hmrPages.clear();
572
585
  const moduleEntries = [
573
586
  ...vueModules,
@@ -817,11 +830,22 @@ defineProps<{ no: number | string }>()`);
817
830
  if (data.features.katex)
818
831
  imports.push(`import "${toAtFS(resolveImportPath("katex/dist/katex.min.css", true))}"`);
819
832
  if (data.config.css === "unocss") {
820
- imports.unshift('import "@unocss/reset/tailwind.css"', 'import "uno:preflights.css"', 'import "uno:typography.css"', 'import "uno:shortcuts.css"');
833
+ imports.unshift(
834
+ 'import "@unocss/reset/tailwind.css"',
835
+ 'import "uno:preflights.css"',
836
+ 'import "uno:typography.css"',
837
+ 'import "uno:shortcuts.css"'
838
+ );
821
839
  imports.push('import "uno.css"');
822
840
  } else {
823
- imports.unshift('import "virtual:windi-components.css"', 'import "virtual:windi-base.css"');
824
- imports.push('import "virtual:windi-utilities.css"', 'import "virtual:windi-devtools"');
841
+ imports.unshift(
842
+ 'import "virtual:windi-components.css"',
843
+ 'import "virtual:windi-base.css"'
844
+ );
845
+ imports.push(
846
+ 'import "virtual:windi-utilities.css"',
847
+ 'import "virtual:windi-devtools"'
848
+ );
825
849
  }
826
850
  return imports.join("\n");
827
851
  }
@@ -830,10 +854,13 @@ defineProps<{ no: number | string }>()`);
830
854
  }
831
855
  async function generateLayouts() {
832
856
  const imports = [];
833
- const layouts = objectMap(await getLayouts(), (k, v) => {
834
- imports.push(`import __layout_${k} from "${toAtFS(v)}"`);
835
- return [k, `__layout_${k}`];
836
- });
857
+ const layouts = objectMap(
858
+ await getLayouts(),
859
+ (k, v) => {
860
+ imports.push(`import __layout_${k} from "${toAtFS(v)}"`);
861
+ return [k, `__layout_${k}`];
862
+ }
863
+ );
837
864
  return [
838
865
  imports.join("\n"),
839
866
  `export default {
@@ -979,10 +1006,13 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
979
1006
  enforce: "pre",
980
1007
  async transform(code, id) {
981
1008
  if (id.startsWith(setupEntry)) {
1009
+ let getInjections2 = function(isAwait = false, isChained = false) {
1010
+ return injections.join("\n").replace(/:AWAIT:/g, isAwait ? "await " : "").replace(/(,\s*)?:LAST:/g, isChained ? "$1injection_return" : "");
1011
+ };
1012
+ var getInjections = getInjections2;
982
1013
  const name = id.slice(setupEntry.length + 1);
983
1014
  const imports = [];
984
1015
  const injections = [];
985
- const asyncInjections = [];
986
1016
  const setups = uniq5([
987
1017
  ...themeRoots,
988
1018
  ...addonRoots,
@@ -992,35 +1022,28 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
992
1022
  if (!existsSync5(path))
993
1023
  return;
994
1024
  imports.push(`import __n${idx} from '${toAtFS(path)}'`);
995
- let fn = `__n${idx}`;
996
- let awaitFn = `await __n${idx}`;
997
- if (/\binjection_return\b/g.test(code)) {
1025
+ let fn = `:AWAIT:__n${idx}`;
1026
+ if (/\binjection_return\b/g.test(code))
998
1027
  fn = `injection_return = ${fn}`;
999
- awaitFn = `injection_return = ${awaitFn}`;
1000
- }
1001
1028
  if (/\binjection_arg\b/g.test(code)) {
1002
1029
  fn += "(";
1003
- awaitFn += "(";
1004
1030
  const matches = Array.from(code.matchAll(/\binjection_arg(_\d+)?\b/g));
1005
1031
  const dedupedMatches = Array.from(new Set(matches.map((m) => m[0])));
1006
- dedupedMatches.forEach((key, index) => {
1007
- const isLast = index === dedupedMatches.length - 1;
1008
- const arg = key + (isLast ? "" : ",");
1009
- fn += arg;
1010
- awaitFn += arg;
1011
- });
1012
- fn += ")";
1013
- awaitFn += ")";
1032
+ fn += dedupedMatches.join(", ");
1033
+ fn += ", :LAST:)";
1014
1034
  } else {
1015
- fn += "()";
1016
- awaitFn += "()";
1035
+ fn += "(:LAST:)";
1017
1036
  }
1018
- injections.push(`// ${path}`, fn);
1019
- asyncInjections.push(`// ${path}`, awaitFn);
1037
+ injections.push(
1038
+ `// ${path}`,
1039
+ fn
1040
+ );
1020
1041
  });
1021
1042
  code = code.replace("/* __imports__ */", imports.join("\n"));
1022
- code = code.replace("/* __injections__ */", injections.join("\n"));
1023
- code = code.replace("/* __async_injections__ */", asyncInjections.join("\n"));
1043
+ code = code.replace("/* __injections__ */", getInjections2());
1044
+ code = code.replace("/* __async_injections__ */", getInjections2(true));
1045
+ code = code.replace("/* __chained_injections__ */", getInjections2(false, true));
1046
+ code = code.replace("/* __chained_async_injections__ */", getInjections2(true, true));
1024
1047
  return code;
1025
1048
  }
1026
1049
  return null;
@@ -1294,7 +1317,9 @@ var MarkdownItShiki = (markdownit, options = {}) => {
1294
1317
  const light = _highlighter.codeToHtml(trimmed, { lang: lang || "text", theme: darkModeThemes.light }).replace('<pre class="shiki"', '<pre class="slidev-code shiki shiki-light"');
1295
1318
  return escapeVueInCode(`<pre class="shiki-container">${dark}${light}</pre>`);
1296
1319
  } else {
1297
- return escapeVueInCode(_highlighter.codeToHtml(code, { lang: lang || "text" }).replace('<pre class="shiki"', '<pre class="slidev-code shiki"'));
1320
+ return escapeVueInCode(
1321
+ _highlighter.codeToHtml(code, { lang: lang || "text" }).replace('<pre class="shiki"', '<pre class="slidev-code shiki"')
1322
+ );
1298
1323
  }
1299
1324
  };
1300
1325
  };
@@ -1432,14 +1457,17 @@ function transformPageCSS(md2, id) {
1432
1457
  if (!page)
1433
1458
  return md2;
1434
1459
  const { isInsideCodeblocks } = getCodeBlocks(md2);
1435
- const result = md2.replace(/(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g, (full, start, css, end, index) => {
1436
- if (index < 0 || isInsideCodeblocks(index))
1437
- return full;
1438
- if (!start.includes("scoped"))
1439
- start = start.replace("<style", "<style scoped");
1440
- return `${start}
1460
+ const result = md2.replace(
1461
+ /(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g,
1462
+ (full, start, css, end, index) => {
1463
+ if (index < 0 || isInsideCodeblocks(index))
1464
+ return full;
1465
+ if (!start.includes("scoped"))
1466
+ start = start.replace("<style", "<style scoped");
1467
+ return `${start}
1441
1468
  ${css}${end}`;
1442
- });
1469
+ }
1470
+ );
1443
1471
  return result;
1444
1472
  }
1445
1473
  function transformMermaid(md2) {