@slidev/cli 0.50.0-beta.3 → 0.50.0-beta.5

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveViteConfigs
3
- } from "./chunk-OBUVLPJZ.js";
3
+ } from "./chunk-HCHIPIOJ.js";
4
4
  import "./chunk-UNQ5DBLZ.js";
5
5
 
6
6
  // node/commands/build.ts
@@ -50,7 +50,7 @@ async function build(options, viteConfig = {}, args) {
50
50
  await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
51
51
  `, "utf-8");
52
52
  if ([true, "true", "auto"].includes(options.data.config.download)) {
53
- const { exportSlides, getExportOptions } = await import("./export-WMRLKOJP.js");
53
+ const { exportSlides, getExportOptions } = await import("./export-I2C456L6.js");
54
54
  const port = 12445;
55
55
  const app = connect();
56
56
  const server = http.createServer(app);
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-UNQ5DBLZ.js";
10
10
 
11
11
  // package.json
12
- var version = "0.50.0-beta.3";
12
+ var version = "0.50.0-beta.5";
13
13
 
14
14
  // node/integrations/themes.ts
15
15
  import { join } from "node:path";
@@ -174,9 +174,118 @@ function getBodyJson(req) {
174
174
 
175
175
  // node/vite/compilerFlagsVue.ts
176
176
  import { objectEntries } from "@antfu/utils";
177
+ function createVueCompilerFlagsPlugin(options) {
178
+ const define = objectEntries(options.utils.define);
179
+ return {
180
+ name: "slidev:flags",
181
+ enforce: "pre",
182
+ transform(code, id) {
183
+ if (!id.match(/\.vue($|\?)/) && !id.includes("?vue&"))
184
+ return;
185
+ const original = code;
186
+ define.forEach(([from, to]) => {
187
+ code = code.replaceAll(from, to);
188
+ });
189
+ if (original !== code)
190
+ return code;
191
+ }
192
+ };
193
+ }
177
194
 
178
- // node/vite/extendConfig.ts
195
+ // node/vite/components.ts
179
196
  import { join as join2 } from "node:path";
197
+ import IconsResolver from "unplugin-icons/resolver";
198
+ import Components from "unplugin-vue-components/vite";
199
+ function createComponentsPlugin({ clientRoot, roots }, pluginOptions) {
200
+ return Components({
201
+ extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
202
+ dirs: [
203
+ join2(clientRoot, "builtin"),
204
+ ...roots.map((i) => join2(i, "components"))
205
+ ],
206
+ include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
207
+ exclude: [],
208
+ resolvers: [
209
+ IconsResolver({
210
+ prefix: "",
211
+ customCollections: Object.keys(pluginOptions.icons?.customCollections || [])
212
+ })
213
+ ],
214
+ dts: false,
215
+ ...pluginOptions.components
216
+ });
217
+ }
218
+
219
+ // node/vite/common.ts
220
+ var regexSlideReqPath = /^\/__slidev\/slides\/(\d+)\.json$/;
221
+ var regexSlideFacadeId = /^\/@slidev\/slides\/(\d+)\/(md|frontmatter)($|\?)/;
222
+ var regexSlideSourceId = /__slidev_(\d+)\.(md|frontmatter)$/;
223
+ var templateInjectionMarker = "/* @slidev-injection */";
224
+ var templateImportContextUtils = `import { useSlideContext as _useSlideContext, frontmatterToProps as _frontmatterToProps } from "@slidev/client/context.ts"`;
225
+ var templateInitContext = `const { $slidev, $nav, $clicksContext, $clicks, $page, $renderContext, $frontmatter } = _useSlideContext()`;
226
+
227
+ // node/vite/contextInjection.ts
228
+ function createContextInjectionPlugin() {
229
+ return {
230
+ name: "slidev:context-injection",
231
+ async transform(code, id) {
232
+ if (!id.endsWith(".vue") || id.includes("/@slidev/client/") || id.includes("/packages/client/"))
233
+ return;
234
+ if (code.includes(templateInjectionMarker) || code.includes("useSlideContext()"))
235
+ return code;
236
+ const imports = [
237
+ templateImportContextUtils,
238
+ templateInitContext,
239
+ templateInjectionMarker
240
+ ];
241
+ const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/);
242
+ if (matchScript && matchScript[2]) {
243
+ return code.replace(/(<script.*>)/g, `$1
244
+ ${imports.join("\n")}
245
+ `);
246
+ } else if (matchScript && !matchScript[2]) {
247
+ const matchExport = code.match(/export\s+default\s+\{/);
248
+ if (matchExport) {
249
+ const exportIndex = (matchExport.index || 0) + matchExport[0].length;
250
+ let component = code.slice(exportIndex);
251
+ component = component.slice(0, component.indexOf("</script>"));
252
+ const scriptIndex = (matchScript.index || 0) + matchScript[0].length;
253
+ const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants.ts"\n';
254
+ code = `${code.slice(0, scriptIndex)}${provideImport}${code.slice(scriptIndex)}`;
255
+ let injectIndex = exportIndex + provideImport.length;
256
+ let injectObject = "$slidev: { from: injectionSlidevContext },";
257
+ const matchInject = component.match(/.*inject\s*:\s*([[{])/);
258
+ if (matchInject) {
259
+ injectIndex += (matchInject.index || 0) + matchInject[0].length;
260
+ if (matchInject[1] === "[") {
261
+ let injects = component.slice((matchInject.index || 0) + matchInject[0].length);
262
+ const injectEndIndex = injects.indexOf("]");
263
+ injects = injects.slice(0, injectEndIndex);
264
+ injectObject += injects.split(",").map((inject) => `${inject}: {from: ${inject}}`).join(",");
265
+ return `${code.slice(0, injectIndex - 1)}{
266
+ ${injectObject}
267
+ }${code.slice(injectIndex + injectEndIndex + 1)}`;
268
+ } else {
269
+ return `${code.slice(0, injectIndex)}
270
+ ${injectObject}
271
+ ${code.slice(injectIndex)}`;
272
+ }
273
+ }
274
+ return `${code.slice(0, injectIndex)}
275
+ inject: { ${injectObject} },
276
+ ${code.slice(injectIndex)}`;
277
+ }
278
+ }
279
+ return `<script setup>
280
+ ${imports.join("\n")}
281
+ </script>
282
+ ${code}`;
283
+ }
284
+ };
285
+ }
286
+
287
+ // node/vite/extendConfig.ts
288
+ import { join as join3 } from "node:path";
180
289
  import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
181
290
  import { slash, uniq } from "@antfu/utils";
182
291
  import { createResolve } from "mlly";
@@ -238,7 +347,7 @@ function createConfigPlugin(options) {
238
347
  name: "slidev:config",
239
348
  async config(config) {
240
349
  const injection = {
241
- define: getDefine(options),
350
+ define: options.utils.define,
242
351
  resolve: {
243
352
  alias: [
244
353
  {
@@ -291,7 +400,7 @@ function createConfigPlugin(options) {
291
400
  ])
292
401
  }
293
402
  },
294
- publicDir: join2(options.userRoot, "public"),
403
+ publicDir: join3(options.userRoot, "public"),
295
404
  build: {
296
405
  rollupOptions: {
297
406
  output: {
@@ -318,15 +427,12 @@ function createConfigPlugin(options) {
318
427
  }
319
428
  }
320
429
  }
321
- }
430
+ },
431
+ cacheDir: isInstalledGlobally.value ? join3(options.cliRoot, "node_modules/.vite") : void 0
322
432
  };
323
433
  function isSlidevClient(id) {
324
434
  return id.includes("/@slidev/") || id.includes("/slidev/packages/client/") || id.includes("/@vueuse/");
325
435
  }
326
- if (isInstalledGlobally.value) {
327
- injection.cacheDir = join2(options.cliRoot, "node_modules/.vite");
328
- injection.root = options.cliRoot;
329
- }
330
436
  return mergeConfig(injection, config);
331
437
  },
332
438
  configureServer(server) {
@@ -344,139 +450,11 @@ function createConfigPlugin(options) {
344
450
  }
345
451
  };
346
452
  }
347
- function getDefine(options) {
348
- return {
349
- __DEV__: options.mode === "dev" ? "true" : "false",
350
- __SLIDEV_CLIENT_ROOT__: JSON.stringify(toAtFS(options.clientRoot)),
351
- __SLIDEV_HASH_ROUTE__: JSON.stringify(options.data.config.routerMode === "hash"),
352
- __SLIDEV_FEATURE_DRAWINGS__: JSON.stringify(options.data.config.drawings.enabled === true || options.data.config.drawings.enabled === options.mode),
353
- __SLIDEV_FEATURE_EDITOR__: JSON.stringify(options.mode === "dev" && options.data.config.editor !== false),
354
- __SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
355
- __SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
356
- __SLIDEV_FEATURE_PRESENTER__: JSON.stringify(options.data.config.presenter === true || options.data.config.presenter === options.mode),
357
- __SLIDEV_FEATURE_PRINT__: JSON.stringify(options.mode === "export" || options.mode === "build" && [true, "true", "auto"].includes(options.data.config.download)),
358
- __SLIDEV_FEATURE_WAKE_LOCK__: JSON.stringify(options.data.config.wakeLock === true || options.data.config.wakeLock === options.mode),
359
- __SLIDEV_HAS_SERVER__: options.mode !== "build" ? "true" : "false"
360
- };
361
- }
362
-
363
- // node/vite/compilerFlagsVue.ts
364
- function createVueCompilerFlagsPlugin(options) {
365
- const define = objectEntries(getDefine(options));
366
- return [
367
- {
368
- name: "slidev:flags",
369
- enforce: "pre",
370
- transform(code, id) {
371
- if (id.match(/\.vue($|\?)/)) {
372
- const original = code;
373
- define.forEach(([from, to]) => {
374
- code = code.replace(new RegExp(from, "g"), to);
375
- });
376
- if (original !== code)
377
- return code;
378
- }
379
- }
380
- }
381
- ];
382
- }
383
-
384
- // node/vite/components.ts
385
- import { join as join3 } from "node:path";
386
- import IconsResolver from "unplugin-icons/resolver";
387
- import Components from "unplugin-vue-components/vite";
388
- function createComponentsPlugin({ clientRoot, roots }, pluginOptions) {
389
- return Components({
390
- extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
391
- dirs: [
392
- join3(clientRoot, "builtin"),
393
- ...roots.map((i) => join3(i, "components"))
394
- ],
395
- include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
396
- exclude: [],
397
- resolvers: [
398
- IconsResolver({
399
- prefix: "",
400
- customCollections: Object.keys(pluginOptions.icons?.customCollections || [])
401
- })
402
- ],
403
- dts: false,
404
- ...pluginOptions.components
405
- });
406
- }
407
-
408
- // node/vite/common.ts
409
- var regexSlideReqPath = /^\/__slidev\/slides\/(\d+)\.json$/;
410
- var regexSlideFacadeId = /^\/@slidev\/slides\/(\d+)\/(md|frontmatter)($|\?)/;
411
- var regexSlideSourceId = /__slidev_(\d+)\.(md|frontmatter)$/;
412
- var templateInjectionMarker = "/* @slidev-injection */";
413
- var templateImportContextUtils = `import { useSlideContext as _useSlideContext, frontmatterToProps as _frontmatterToProps } from "@slidev/client/context.ts"`;
414
- var templateInitContext = `const { $slidev, $nav, $clicksContext, $clicks, $page, $renderContext, $frontmatter } = _useSlideContext()`;
415
-
416
- // node/vite/contextInjection.ts
417
- function createContextInjectionPlugin() {
418
- return {
419
- name: "slidev:context-injection",
420
- async transform(code, id) {
421
- if (!id.endsWith(".vue") || id.includes("/@slidev/client/") || id.includes("/packages/client/"))
422
- return;
423
- if (code.includes(templateInjectionMarker) || code.includes("useSlideContext()"))
424
- return code;
425
- const imports = [
426
- templateImportContextUtils,
427
- templateInitContext,
428
- templateInjectionMarker
429
- ];
430
- const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/);
431
- if (matchScript && matchScript[2]) {
432
- return code.replace(/(<script.*>)/g, `$1
433
- ${imports.join("\n")}
434
- `);
435
- } else if (matchScript && !matchScript[2]) {
436
- const matchExport = code.match(/export\s+default\s+\{/);
437
- if (matchExport) {
438
- const exportIndex = (matchExport.index || 0) + matchExport[0].length;
439
- let component = code.slice(exportIndex);
440
- component = component.slice(0, component.indexOf("</script>"));
441
- const scriptIndex = (matchScript.index || 0) + matchScript[0].length;
442
- const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants.ts"\n';
443
- code = `${code.slice(0, scriptIndex)}${provideImport}${code.slice(scriptIndex)}`;
444
- let injectIndex = exportIndex + provideImport.length;
445
- let injectObject = "$slidev: { from: injectionSlidevContext },";
446
- const matchInject = component.match(/.*inject\s*:\s*([[{])/);
447
- if (matchInject) {
448
- injectIndex += (matchInject.index || 0) + matchInject[0].length;
449
- if (matchInject[1] === "[") {
450
- let injects = component.slice((matchInject.index || 0) + matchInject[0].length);
451
- const injectEndIndex = injects.indexOf("]");
452
- injects = injects.slice(0, injectEndIndex);
453
- injectObject += injects.split(",").map((inject) => `${inject}: {from: ${inject}}`).join(",");
454
- return `${code.slice(0, injectIndex - 1)}{
455
- ${injectObject}
456
- }${code.slice(injectIndex + injectEndIndex + 1)}`;
457
- } else {
458
- return `${code.slice(0, injectIndex)}
459
- ${injectObject}
460
- ${code.slice(injectIndex)}`;
461
- }
462
- }
463
- return `${code.slice(0, injectIndex)}
464
- inject: { ${injectObject} },
465
- ${code.slice(injectIndex)}`;
466
- }
467
- }
468
- return `<script setup>
469
- ${imports.join("\n")}
470
- </script>
471
- ${code}`;
472
- }
473
- };
474
- }
475
453
 
476
454
  // node/vite/hmrPatch.ts
477
455
  function createHmrPatchPlugin() {
478
456
  return {
479
- name: "slidev:slide-transform:post",
457
+ name: "slidev:hmr-patch",
480
458
  transform(code, id) {
481
459
  if (!id.match(regexSlideSourceId))
482
460
  return;
@@ -520,7 +498,7 @@ function createLayoutWrapperPlugin({ data, utils }) {
520
498
  if (type !== "md")
521
499
  return;
522
500
  const index = +no - 1;
523
- const layouts = await utils.getLayouts();
501
+ const layouts = utils.getLayouts();
524
502
  const rawLayoutName = data.slides[index]?.frontmatter?.layout ?? data.slides[0]?.frontmatter?.defaults?.layout;
525
503
  let layoutName = rawLayoutName || (index === 0 ? "cover" : "default");
526
504
  if (!layouts[layoutName]) {
@@ -1000,12 +978,22 @@ function withRenderedNote(data) {
1000
978
  };
1001
979
  }
1002
980
  function createSlidesLoader(options, serverOptions) {
981
+ const { data, mode, utils } = options;
1003
982
  const hmrSlidesIndexes = /* @__PURE__ */ new Set();
1004
983
  let server;
1005
984
  let skipHmr = null;
1006
- const { data, mode, utils } = options;
1007
- function getSourceId(index, type) {
1008
- return `${data.slides[index].source.filepath}__slidev_${index + 1}.${type}`;
985
+ let sourceIds = resolveSourceIds(data);
986
+ function resolveSourceIds(data2) {
987
+ const ids = {
988
+ md: [],
989
+ frontmatter: []
990
+ };
991
+ for (const type of ["md", "frontmatter"]) {
992
+ for (let i = 0; i < data2.slides.length; i++) {
993
+ ids[type].push(`${data2.slides[i].source.filepath}__slidev_${i + 1}.${type}`);
994
+ }
995
+ }
996
+ return ids;
1009
997
  }
1010
998
  function updateServerWatcher() {
1011
999
  if (!server)
@@ -1063,11 +1051,11 @@ function createSlidesLoader(options, serverOptions) {
1063
1051
  fileContent
1064
1052
  };
1065
1053
  server?.moduleGraph.invalidateModule(
1066
- server.moduleGraph.getModuleById(getSourceId(idx, "md"))
1054
+ server.moduleGraph.getModuleById(sourceIds.md[idx])
1067
1055
  );
1068
1056
  if (body.frontmatter) {
1069
1057
  server?.moduleGraph.invalidateModule(
1070
- server.moduleGraph.getModuleById(getSourceId(idx, "frontmatter"))
1058
+ server.moduleGraph.getModuleById(sourceIds.frontmatter[idx])
1071
1059
  );
1072
1060
  }
1073
1061
  }
@@ -1095,9 +1083,19 @@ function createSlidesLoader(options, serverOptions) {
1095
1083
  return [];
1096
1084
  }
1097
1085
  const moduleIds = /* @__PURE__ */ new Set();
1086
+ const newSourceIds = resolveSourceIds(newData);
1087
+ for (const type of ["md", "frontmatter"]) {
1088
+ const old = sourceIds[type];
1089
+ const newIds = newSourceIds[type];
1090
+ for (let i = 0; i < newIds.length; i++) {
1091
+ if (old[i] !== newIds[i]) {
1092
+ moduleIds.add(`${VIRTUAL_SLIDE_PREFIX}${i + 1}/${type}`);
1093
+ }
1094
+ }
1095
+ }
1096
+ sourceIds = newSourceIds;
1098
1097
  if (data.slides.length !== newData.slides.length) {
1099
1098
  moduleIds.add(templateSlides.id);
1100
- range(newData.slides.length).map((i) => hmrSlidesIndexes.add(i));
1101
1099
  }
1102
1100
  if (!equal(data.headmatter.defaults, newData.headmatter.defaults)) {
1103
1101
  moduleIds.add(templateSlides.id);
@@ -1141,8 +1139,8 @@ function createSlidesLoader(options, serverOptions) {
1141
1139
  if (hmrSlidesIndexes.size > 0)
1142
1140
  moduleIds.add(templateTitleRendererMd.id);
1143
1141
  const vueModules = Array.from(hmrSlidesIndexes).flatMap((idx) => {
1144
- const frontmatter = ctx.server.moduleGraph.getModuleById(getSourceId(idx, "frontmatter"));
1145
- const main = ctx.server.moduleGraph.getModuleById(getSourceId(idx, "md"));
1142
+ const frontmatter = ctx.server.moduleGraph.getModuleById(sourceIds.frontmatter[idx]);
1143
+ const main = ctx.server.moduleGraph.getModuleById(sourceIds.md[idx]);
1146
1144
  const styles = main ? [...main.clientImportedModules].find((m) => m.id?.includes(`&type=style`)) : void 0;
1147
1145
  return [
1148
1146
  frontmatter,
@@ -1179,7 +1177,7 @@ function createSlidesLoader(options, serverOptions) {
1179
1177
  if (matchFacade) {
1180
1178
  const [, no, type] = matchFacade;
1181
1179
  const idx = +no - 1;
1182
- const sourceId = JSON.stringify(getSourceId(idx, type));
1180
+ const sourceId = JSON.stringify(sourceIds[type][idx]);
1183
1181
  return [
1184
1182
  `export * from ${sourceId}`,
1185
1183
  `export { default } from ${sourceId}`
@@ -1730,7 +1728,7 @@ async function setupTransformers(roots) {
1730
1728
  }
1731
1729
 
1732
1730
  // node/syntax/transform/code-wrapper.ts
1733
- var reCodeBlock = /^```([\w'-]+)?\s*(?:\{([\w*,|-]+)\}\s*?(\{[^}]*\})?([^\r\n]*))?\r?\n(\S[\s\S]*?)^```$/gm;
1731
+ var reCodeBlock = /^```([\w'-]+)?\s*(?:\{([\w*,|-]+)\}\s*?(\{[^}]*\})?([^\r\n]*))?\r?\n([ \t]*\S[\s\S]*?)^```$/gm;
1734
1732
  function transformCodeWrapper(ctx) {
1735
1733
  ctx.s.replace(
1736
1734
  reCodeBlock,
@@ -1961,40 +1959,41 @@ function dedent(text) {
1961
1959
  return lines.map((x) => x.slice(minIndentLength)).join("\n");
1962
1960
  return text;
1963
1961
  }
1964
- function testLine(line, regexp, regionName, end = false) {
1965
- const [full, tag, name] = regexp.exec(line.trim()) || [];
1966
- return full && tag && name === regionName && tag.match(end ? /^[Ee]nd ?[rR]egion$/ : /^[rR]egion$/);
1967
- }
1968
1962
  function findRegion(lines, regionName) {
1969
1963
  const regionRegexps = [
1970
- /^\/\/ ?#?((?:end)?region) ([\w*-]+)$/,
1971
1964
  // javascript, typescript, java
1972
- /^\/\* ?#((?:end)?region) ([\w*-]+) ?\*\/$/,
1965
+ [/^\/\/ ?#?region ([\w*-]+)$/, /^\/\/ ?#?endregion/],
1973
1966
  // css, less, scss
1974
- /^#pragma ((?:end)?region) ([\w*-]+)$/,
1967
+ [/^\/\* ?#region ([\w*-]+) ?\*\/$/, /^\/\* ?#endregion[\s\w*-]*\*\/$/],
1975
1968
  // C, C++
1976
- /^<!-- #?((?:end)?region) ([\w*-]+) -->$/,
1969
+ [/^#pragma region ([\w*-]+)$/, /^#pragma endregion/],
1977
1970
  // HTML, markdown
1978
- /^#(End Region) ([\w*-]+)$/,
1971
+ [/^<!-- #?region ([\w*-]+) -->$/, /^<!-- #?region[\s\w*-]*-->$/],
1979
1972
  // Visual Basic
1980
- /^::#(endregion) ([\w*-]+)$/,
1973
+ [/^#Region ([\w*-]+)$/, /^#End Region/],
1981
1974
  // Bat
1982
- /^# ?((?:end)?region) ([\w*-]+)$/
1975
+ [/^::#region ([\w*-]+)$/, /^::#endregion/],
1983
1976
  // C#, PHP, Powershell, Python, perl & misc
1977
+ [/^# ?region ([\w*-]+)$/, /^# ?endregion/]
1984
1978
  ];
1985
- let regexp = null;
1979
+ let endReg = null;
1986
1980
  let start = -1;
1987
1981
  for (const [lineId, line] of lines.entries()) {
1988
- if (regexp === null) {
1989
- for (const reg of regionRegexps) {
1990
- if (testLine(line, reg, regionName)) {
1982
+ if (endReg === null) {
1983
+ for (const [startReg, end] of regionRegexps) {
1984
+ const match = line.trim().match(startReg);
1985
+ if (match && match[1] === regionName) {
1991
1986
  start = lineId + 1;
1992
- regexp = reg;
1987
+ endReg = end;
1993
1988
  break;
1994
1989
  }
1995
1990
  }
1996
- } else if (testLine(line, regexp, regionName, true)) {
1997
- return { start, end: lineId, regexp };
1991
+ } else if (endReg.test(line.trim())) {
1992
+ return {
1993
+ start,
1994
+ end: lineId,
1995
+ regexp: endReg
1996
+ };
1998
1997
  }
1999
1998
  }
2000
1999
  return null;
@@ -2409,12 +2408,13 @@ async function createVuePlugin(_options, pluginOptions) {
2409
2408
  exclude: [],
2410
2409
  ...vueOptions,
2411
2410
  template: {
2411
+ ...vueOptions?.template,
2412
2412
  compilerOptions: {
2413
+ ...vueOptions?.template?.compilerOptions,
2413
2414
  isCustomElement(tag) {
2414
2415
  return customElements.has(tag) || vueOptions?.template?.compilerOptions?.isCustomElement?.(tag);
2415
2416
  }
2416
- },
2417
- ...vueOptions?.template
2417
+ }
2418
2418
  }
2419
2419
  });
2420
2420
  const VueJsxPlugin = VueJsx(vuejsxOptions);
@@ -2425,7 +2425,7 @@ async function createVuePlugin(_options, pluginOptions) {
2425
2425
  }
2426
2426
 
2427
2427
  // node/vite/index.ts
2428
- async function ViteSlidevPlugin(options, pluginOptions = {}, serverOptions = {}) {
2428
+ function ViteSlidevPlugin(options, pluginOptions = {}, serverOptions = {}) {
2429
2429
  return Promise.all([
2430
2430
  createSlidesLoader(options, serverOptions),
2431
2431
  createMarkdownPlugin(options, pluginOptions),
@@ -2627,6 +2627,7 @@ async function createDataUtils(resolved) {
2627
2627
  return {
2628
2628
  ...await setupShiki(resolved.roots),
2629
2629
  indexHtml: setupIndexHtml(resolved),
2630
+ define: getDefine(resolved),
2630
2631
  iconsResolvePath: [resolved.clientRoot, ...resolved.roots].reverse(),
2631
2632
  isMonacoTypesIgnored: (pkg) => monacoTypesIgnorePackagesMatches.some((i) => i(pkg)),
2632
2633
  getLayouts: () => {
@@ -2651,6 +2652,21 @@ async function createDataUtils(resolved) {
2651
2652
  }
2652
2653
  };
2653
2654
  }
2655
+ function getDefine(options) {
2656
+ return {
2657
+ __DEV__: options.mode === "dev" ? "true" : "false",
2658
+ __SLIDEV_CLIENT_ROOT__: JSON.stringify(toAtFS(options.clientRoot)),
2659
+ __SLIDEV_HASH_ROUTE__: JSON.stringify(options.data.config.routerMode === "hash"),
2660
+ __SLIDEV_FEATURE_DRAWINGS__: JSON.stringify(options.data.config.drawings.enabled === true || options.data.config.drawings.enabled === options.mode),
2661
+ __SLIDEV_FEATURE_EDITOR__: JSON.stringify(options.mode === "dev" && options.data.config.editor !== false),
2662
+ __SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
2663
+ __SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
2664
+ __SLIDEV_FEATURE_PRESENTER__: JSON.stringify(options.data.config.presenter === true || options.data.config.presenter === options.mode),
2665
+ __SLIDEV_FEATURE_PRINT__: JSON.stringify(options.mode === "export" || options.mode === "build" && [true, "true", "auto"].includes(options.data.config.download)),
2666
+ __SLIDEV_FEATURE_WAKE_LOCK__: JSON.stringify(options.data.config.wakeLock === true || options.data.config.wakeLock === options.mode),
2667
+ __SLIDEV_HAS_SERVER__: options.mode !== "build" ? "true" : "false"
2668
+ };
2669
+ }
2654
2670
 
2655
2671
  export {
2656
2672
  version,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveViteConfigs
3
- } from "./chunk-OBUVLPJZ.js";
3
+ } from "./chunk-HCHIPIOJ.js";
4
4
 
5
5
  // node/commands/serve.ts
6
6
  import { join } from "node:path";
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-22D4K34T.js";
3
+ } from "./chunk-YWCVGITI.js";
4
4
  import {
5
5
  getThemeMeta,
6
6
  loadSetups,
@@ -9,7 +9,7 @@ import {
9
9
  resolveOptions,
10
10
  resolveTheme,
11
11
  version
12
- } from "./chunk-OBUVLPJZ.js";
12
+ } from "./chunk-HCHIPIOJ.js";
13
13
  import {
14
14
  getRoots,
15
15
  isInstalledGlobally,
@@ -33,7 +33,7 @@ import yargs from "yargs";
33
33
  // node/setups/preparser.ts
34
34
  import { uniq } from "@antfu/utils";
35
35
  import { injectPreparserExtensionLoader } from "@slidev/parser/fs";
36
- async function setupPreparser() {
36
+ function setupPreparser() {
37
37
  injectPreparserExtensionLoader(async (headmatter, filepath, mode) => {
38
38
  const addons = headmatter?.addons;
39
39
  if (!addons?.length)
@@ -332,7 +332,7 @@ cli.command(
332
332
  }).strict().help(),
333
333
  async (args) => {
334
334
  const { entry, theme, base, download, out, inspect } = args;
335
- const { build } = await import("./build-ZP4MQTE4.js");
335
+ const { build } = await import("./build-7BIXJ6QW.js");
336
336
  for (const entryFile of entry) {
337
337
  const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
338
338
  if (download && !options.data.config.download)
@@ -412,7 +412,7 @@ cli.command(
412
412
  (args) => exportOptions(commonOptions(args)).strict().help(),
413
413
  async (args) => {
414
414
  const { entry, theme } = args;
415
- const { exportSlides, getExportOptions } = await import("./export-WMRLKOJP.js");
415
+ const { exportSlides, getExportOptions } = await import("./export-I2C456L6.js");
416
416
  const port = await getPort(12445);
417
417
  for (const entryFile of entry) {
418
418
  const options = await resolveOptions({ entry: entryFile, theme }, "export");
@@ -461,7 +461,7 @@ cli.command(
461
461
  timeout,
462
462
  wait
463
463
  }) => {
464
- const { exportNotes } = await import("./export-WMRLKOJP.js");
464
+ const { exportNotes } = await import("./export-I2C456L6.js");
465
465
  const port = await getPort(12445);
466
466
  for (const entryFile of entry) {
467
467
  const options = await resolveOptions({ entry: entryFile }, "export");
@@ -77,8 +77,7 @@ async function exportNotes({
77
77
  base = "/",
78
78
  output = "notes",
79
79
  timeout = 3e4,
80
- wait = 0,
81
- waitUntil
80
+ wait = 0
82
81
  }) {
83
82
  const { chromium } = await importPlaywright();
84
83
  const browser = await chromium.launch();
@@ -88,9 +87,8 @@ async function exportNotes({
88
87
  progress.start(1);
89
88
  if (!output.endsWith(".pdf"))
90
89
  output = `${output}.pdf`;
91
- await page.goto(`http://localhost:${port}${base}presenter/print`, { waitUntil, timeout });
92
- if (waitUntil)
93
- await page.waitForLoadState(waitUntil);
90
+ await page.goto(`http://localhost:${port}${base}presenter/print`, { waitUntil: "networkidle", timeout });
91
+ await page.waitForLoadState("networkidle");
94
92
  await page.emulateMedia({ media: "screen" });
95
93
  if (wait)
96
94
  await page.waitForTimeout(wait);
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-22D4K34T.js";
3
+ } from "./chunk-YWCVGITI.js";
4
4
  import {
5
5
  ViteSlidevPlugin,
6
6
  createDataUtils,
7
7
  parser,
8
8
  resolveOptions
9
- } from "./chunk-OBUVLPJZ.js";
9
+ } from "./chunk-HCHIPIOJ.js";
10
10
  import "./chunk-UNQ5DBLZ.js";
11
11
  export {
12
12
  ViteSlidevPlugin,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
3
  "type": "module",
4
- "version": "0.50.0-beta.3",
4
+ "version": "0.50.0-beta.5",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -44,15 +44,15 @@
44
44
  "dependencies": {
45
45
  "@antfu/ni": "^0.23.0",
46
46
  "@antfu/utils": "^0.7.10",
47
- "@iconify-json/carbon": "^1.2.1",
48
- "@iconify-json/ph": "^1.2.0",
49
- "@iconify-json/svg-spinners": "^1.2.0",
47
+ "@iconify-json/carbon": "^1.2.3",
48
+ "@iconify-json/ph": "^1.2.1",
49
+ "@iconify-json/svg-spinners": "^1.2.1",
50
50
  "@lillallol/outline-pdf": "^4.0.0",
51
- "@shikijs/markdown-it": "^1.21.0",
52
- "@shikijs/twoslash": "^1.21.0",
53
- "@shikijs/vitepress-twoslash": "^1.21.0",
54
- "@unocss/extractor-mdc": "^0.63.2",
55
- "@unocss/reset": "^0.63.2",
51
+ "@shikijs/markdown-it": "^1.22.1",
52
+ "@shikijs/twoslash": "^1.22.1",
53
+ "@shikijs/vitepress-twoslash": "^1.22.1",
54
+ "@unocss/extractor-mdc": "^0.63.6",
55
+ "@unocss/reset": "^0.63.6",
56
56
  "@vitejs/plugin-vue": "^5.1.4",
57
57
  "@vitejs/plugin-vue-jsx": "^4.0.1",
58
58
  "chokidar": "^4.0.1",
@@ -66,18 +66,18 @@
66
66
  "global-directory": "^4.0.1",
67
67
  "htmlparser2": "^9.1.0",
68
68
  "is-installed-globally": "^1.0.0",
69
- "jiti": "^2.1.0",
69
+ "jiti": "^2.3.3",
70
70
  "katex": "^0.16.11",
71
71
  "kolorist": "^1.8.0",
72
72
  "local-pkg": "^0.5.0",
73
73
  "lz-string": "^1.5.0",
74
- "magic-string": "^0.30.11",
74
+ "magic-string": "^0.30.12",
75
75
  "magic-string-stack": "^0.1.1",
76
76
  "markdown-it": "^14.1.0",
77
77
  "markdown-it-footnote": "^4.0.0",
78
78
  "markdown-it-mdc": "^0.2.5",
79
79
  "micromatch": "^4.0.8",
80
- "mlly": "^1.7.1",
80
+ "mlly": "^1.7.2",
81
81
  "monaco-editor": "^0.52.0",
82
82
  "open": "^10.1.0",
83
83
  "pdf-lib": "^1.17.1",
@@ -89,29 +89,29 @@
89
89
  "resolve-from": "^5.0.0",
90
90
  "resolve-global": "^2.0.0",
91
91
  "semver": "^7.6.3",
92
- "shiki": "^1.21.0",
93
- "shiki-magic-move": "^0.4.5",
94
- "sirv": "^2.0.4",
92
+ "shiki": "^1.22.0",
93
+ "shiki-magic-move": "^0.5.0",
94
+ "sirv": "^3.0.0",
95
95
  "source-map-js": "^1.2.1",
96
- "typescript": "^5.6.2",
97
- "unocss": "^0.63.2",
96
+ "typescript": "^5.6.3",
97
+ "unocss": "^0.63.4",
98
98
  "unplugin-icons": "^0.19.3",
99
99
  "unplugin-vue-components": "^0.27.4",
100
100
  "unplugin-vue-markdown": "^0.26.2",
101
101
  "untun": "^0.1.3",
102
102
  "uqr": "^0.1.2",
103
- "vite": "^5.4.8",
103
+ "vite": "^5.4.9",
104
104
  "vite-plugin-inspect": "^0.8.7",
105
105
  "vite-plugin-remote-assets": "^0.5.0",
106
- "vite-plugin-static-copy": "^1.0.6",
106
+ "vite-plugin-static-copy": "^2.0.0",
107
107
  "vite-plugin-vue-server-ref": "^0.4.2",
108
- "vitefu": "^1.0.2",
109
- "vue": "^3.5.10",
110
- "yaml": "^2.5.1",
108
+ "vitefu": "^1.0.3",
109
+ "vue": "^3.5.12",
110
+ "yaml": "^2.6.0",
111
111
  "yargs": "^17.7.2",
112
- "@slidev/client": "0.50.0-beta.3",
113
- "@slidev/types": "0.50.0-beta.3",
114
- "@slidev/parser": "0.50.0-beta.3"
112
+ "@slidev/client": "0.50.0-beta.5",
113
+ "@slidev/types": "0.50.0-beta.5",
114
+ "@slidev/parser": "0.50.0-beta.5"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@hedgedoc/markdown-it-plugins": "^2.1.4",