@slidev/cli 0.30.1 → 0.30.2

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,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
3
 
4
- var _chunk7FQD47HMjs = require('./chunk-7FQD47HM.js');
4
+ var _chunkRSHUQSN4js = require('./chunk-RSHUQSN4.js');
5
5
 
6
6
 
7
7
 
@@ -655,13 +655,13 @@ async function build(options, viteConfig = {}) {
655
655
  let originalIndexHTML;
656
656
  if (_fsextra2.default.existsSync(indexPath))
657
657
  originalIndexHTML = await _fsextra2.default.readFile(indexPath, "utf-8");
658
- await _fsextra2.default.writeFile(indexPath, await _chunk7FQD47HMjs.getIndexHtml.call(void 0, options), "utf-8");
658
+ await _fsextra2.default.writeFile(indexPath, await _chunkRSHUQSN4js.getIndexHtml.call(void 0, options), "utf-8");
659
659
  let config = void 0;
660
660
  try {
661
661
  const inlineConfig = _vite.mergeConfig.call(void 0, viteConfig, {
662
662
  root: options.userRoot,
663
663
  plugins: [
664
- await _chunk7FQD47HMjs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
664
+ await _chunkRSHUQSN4js.ViteSlidevPlugin.call(void 0, options, pluginOptions),
665
665
  {
666
666
  name: "resolve-config",
667
667
  configResolved(_config) {
@@ -706,13 +706,14 @@ async function build(options, viteConfig = {}) {
706
706
  await _fsextra2.default.unlink(indexPath);
707
707
  }
708
708
  const outDir = _path.resolve.call(void 0, options.userRoot, config.build.outDir);
709
+ const outFilename = options.data.config.exportFilename || "slidev-exported.pdf";
709
710
  await _fsextra2.default.copyFile(_path.resolve.call(void 0, outDir, "index.html"), _path.resolve.call(void 0, outDir, "404.html"));
710
711
  const redirectsPath = _path.resolve.call(void 0, outDir, "_redirects");
711
712
  if (!_fsextra2.default.existsSync(redirectsPath))
712
713
  await _fsextra2.default.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
713
714
  `, "utf-8");
714
715
  if ([true, "true", "auto"].includes(options.data.config.download)) {
715
- const { exportSlides } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "./export-X3EA2DO6.js")));
716
+ const { exportSlides } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "./export-AKEY52VC.js")));
716
717
  const port = 12445;
717
718
  const app = _connect2.default.call(void 0, );
718
719
  const server = _http2.default.createServer(app);
@@ -726,7 +727,7 @@ async function build(options, viteConfig = {}) {
726
727
  port,
727
728
  total: options.data.slides.length,
728
729
  format: "pdf",
729
- output: _path.join.call(void 0, outDir, "slidev-exported.pdf"),
730
+ output: _path.join.call(void 0, outDir, outFilename),
730
731
  base: config.base,
731
732
  dark: options.data.config.colorSchema === "dark",
732
733
  width: 1920,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ViteSlidevPlugin,
3
3
  getIndexHtml
4
- } from "./chunk-4AVLCCHB.mjs";
4
+ } from "./chunk-MBZTOLHN.mjs";
5
5
  import {
6
6
  __require,
7
7
  __spreadValues,
@@ -706,13 +706,14 @@ async function build(options, viteConfig = {}) {
706
706
  await fs2.unlink(indexPath);
707
707
  }
708
708
  const outDir = resolve3(options.userRoot, config.build.outDir);
709
+ const outFilename = options.data.config.exportFilename || "slidev-exported.pdf";
709
710
  await fs2.copyFile(resolve3(outDir, "index.html"), resolve3(outDir, "404.html"));
710
711
  const redirectsPath = resolve3(outDir, "_redirects");
711
712
  if (!fs2.existsSync(redirectsPath))
712
713
  await fs2.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
713
714
  `, "utf-8");
714
715
  if ([true, "true", "auto"].includes(options.data.config.download)) {
715
- const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-2FIFRI4R.mjs")));
716
+ const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-RFCVIBYE.mjs")));
716
717
  const port = 12445;
717
718
  const app = connect();
718
719
  const server = http.createServer(app);
@@ -726,7 +727,7 @@ async function build(options, viteConfig = {}) {
726
727
  port,
727
728
  total: options.data.slides.length,
728
729
  format: "pdf",
729
- output: join3(outDir, "slidev-exported.pdf"),
730
+ output: join3(outDir, outFilename),
730
731
  base: config.base,
731
732
  dark: options.data.config.colorSchema === "dark",
732
733
  width: 1920,
@@ -2392,7 +2392,6 @@ _chunkIXNT7VMKjs.__export.call(void 0, fs_exports, {
2392
2392
  _chunkIXNT7VMKjs.init_cjs_shims.call(void 0, );
2393
2393
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
2394
2394
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
2395
- var _markdownit = require('markdown-it'); var _markdownit2 = _interopRequireDefault(_markdownit);
2396
2395
 
2397
2396
  // ../parser/src/core.ts
2398
2397
  _chunkIXNT7VMKjs.init_cjs_shims.call(void 0, );
@@ -5105,6 +5104,7 @@ function resolveConfig(headmatter, themeMeta = {}) {
5105
5104
  routerMode: "history",
5106
5105
  aspectRatio: 16 / 9,
5107
5106
  canvasWidth: 980,
5107
+ exportFilename: "",
5108
5108
  selectable: false,
5109
5109
  themeConfig: {},
5110
5110
  fonts: {},
@@ -5114,7 +5114,7 @@ function resolveConfig(headmatter, themeMeta = {}) {
5114
5114
  };
5115
5115
  const config2 = _chunkIXNT7VMKjs.__spreadProps.call(void 0, _chunkIXNT7VMKjs.__spreadValues.call(void 0, _chunkIXNT7VMKjs.__spreadValues.call(void 0, _chunkIXNT7VMKjs.__spreadValues.call(void 0, _chunkIXNT7VMKjs.__spreadValues.call(void 0, {}, defaultConfig2), themeMeta.defaults), headmatter.config), headmatter), {
5116
5116
  fonts: resolveFonts(_chunkIXNT7VMKjs.__spreadValues.call(void 0, _chunkIXNT7VMKjs.__spreadValues.call(void 0, _chunkIXNT7VMKjs.__spreadValues.call(void 0, {}, (_a = themeMeta.defaults) == null ? void 0 : _a.fonts), (_b = headmatter.config) == null ? void 0 : _b.fonts), headmatter == null ? void 0 : headmatter.fonts)),
5117
- drawings: resolveDarwings(headmatter.drawings)
5117
+ drawings: resolveDrawings(headmatter.drawings)
5118
5118
  });
5119
5119
  if (config2.colorSchema !== "dark" && config2.colorSchema !== "light")
5120
5120
  config2.colorSchema = "auto";
@@ -5196,7 +5196,7 @@ function resolveFonts(fonts = {}) {
5196
5196
  weights
5197
5197
  };
5198
5198
  }
5199
- function resolveDarwings(options = {}) {
5199
+ function resolveDrawings(options = {}) {
5200
5200
  const {
5201
5201
  enabled = true,
5202
5202
  persist = false,
@@ -5358,9 +5358,9 @@ function parse(markdown, filepath, themeMeta) {
5358
5358
  function mergeFeatureFlags(a, b) {
5359
5359
  return _utils.objectMap.call(void 0, a, (k, v) => [k, v || b[k]]);
5360
5360
  }
5361
- function scanMonacoModules(md2) {
5361
+ function scanMonacoModules(md) {
5362
5362
  const typeModules = /* @__PURE__ */ new Set();
5363
- md2.replace(/^```(\w+?)\s*{monaco([\w:,-]*)}[\s\n]*([\s\S]+?)^```/mg, (full, lang = "ts", options, code) => {
5363
+ md.replace(/^```(\w+?)\s*{monaco([\w:,-]*)}[\s\n]*([\s\S]+?)^```/mg, (full, lang = "ts", options, code) => {
5364
5364
  options = options || "";
5365
5365
  lang = lang.trim();
5366
5366
  if (lang === "ts" || lang === "typescript") {
@@ -5372,7 +5372,6 @@ function scanMonacoModules(md2) {
5372
5372
  }
5373
5373
 
5374
5374
  // ../parser/src/fs.ts
5375
- var md = _markdownit2.default.call(void 0, { html: true });
5376
5375
  async function load2(filepath, themeMeta, content) {
5377
5376
  const dir = _path.dirname.call(void 0, filepath);
5378
5377
  const markdown = content != null ? content : await _fs.promises.readFile(filepath, "utf-8");
@@ -5413,10 +5412,6 @@ async function load2(filepath, themeMeta, content) {
5413
5412
  data.slides.splice(iSlide + offset, 0, slide);
5414
5413
  }
5415
5414
  }
5416
- for (const slide of data.slides) {
5417
- if (slide.title)
5418
- slide.title = md.render(slide.title).trim().replace(/^<p>/, "").replace(/<\/p>$/, "");
5419
- }
5420
5415
  for (let iSlide = 0; iSlide < data.slides.length; iSlide++)
5421
5416
  data.slides[iSlide].index = iSlide === 0 ? 0 : 1 + data.slides[iSlide - 1].index;
5422
5417
  data.entries = Array.from(entries);
@@ -5434,7 +5429,7 @@ async function saveExternalSlide(slide) {
5434
5429
  _chunkIXNT7VMKjs.init_cjs_shims.call(void 0, );
5435
5430
 
5436
5431
  // package.json
5437
- var version = "0.30.1";
5432
+ var version = "0.30.2";
5438
5433
 
5439
5434
  // node/themes.ts
5440
5435
  _chunkIXNT7VMKjs.init_cjs_shims.call(void 0, );
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk7FQD47HMjs = require('./chunk-7FQD47HM.js');
3
+ var _chunkRSHUQSN4js = require('./chunk-RSHUQSN4.js');
4
4
 
5
5
 
6
6
  var _chunkIXNT7VMKjs = require('./chunk-IXNT7VMK.js');
@@ -20,7 +20,7 @@ async function createServer(options, viteConfig = {}, serverOptions = {}) {
20
20
  ]
21
21
  },
22
22
  plugins: [
23
- await _chunk7FQD47HMjs.ViteSlidevPlugin.call(void 0, options, pluginOptions, serverOptions)
23
+ await _chunkRSHUQSN4js.ViteSlidevPlugin.call(void 0, options, pluginOptions, serverOptions)
24
24
  ]
25
25
  }));
26
26
  return server;
@@ -472,7 +472,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
472
472
  });
473
473
  },
474
474
  async handleHotUpdate(ctx) {
475
- var _a;
475
+ var _a, _b, _c;
476
476
  if (!data.entries.some((i) => slash2(i) === ctx.file))
477
477
  return;
478
478
  const newData = await parser.load(entry, data.themeMeta);
@@ -496,7 +496,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
496
496
  for (let i = 0; i < length; i++) {
497
497
  const a = data.slides[i];
498
498
  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))
499
+ 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
500
  continue;
501
501
  ctx.server.ws.send({
502
502
  type: "custom",
@@ -508,13 +508,15 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
508
508
  });
509
509
  hmrPages.add(i);
510
510
  }
511
- (_a = serverOptions.onDataReload) == null ? void 0 : _a.call(serverOptions, newData, data);
511
+ (_c = serverOptions.onDataReload) == null ? void 0 : _c.call(serverOptions, newData, data);
512
512
  Object.assign(data, newData);
513
+ if (hmrPages.size > 0)
514
+ moduleIds.add("/@slidev/titles.md");
513
515
  const vueModules = (await Promise.all(Array.from(hmrPages).map(async (i) => {
514
516
  var _a2;
515
517
  const file = `${slidePrefix}${i + 1}.md`;
516
518
  try {
517
- const md2 = await transformMarkdown(MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
519
+ const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
518
520
  return await VuePlugin.handleHotUpdate(__spreadProps(__spreadValues({}, ctx), {
519
521
  modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
520
522
  file,
@@ -559,6 +561,14 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
559
561
  return generateGlobalComponents("bottom");
560
562
  if (id === "/@slidev/custom-nav-controls")
561
563
  return generateCustomNavControls();
564
+ if (id === "/@slidev/titles.md") {
565
+ return {
566
+ code: data.slides.map(({ title }, i) => {
567
+ return `<template ${i === 0 ? "v-if" : "v-else-if"}="+no === ${i + 1}">${title}</template>`;
568
+ }).join(""),
569
+ map: {}
570
+ };
571
+ }
562
572
  if (id.startsWith(slidePrefix)) {
563
573
  const remaning = id.slice(slidePrefix.length);
564
574
  const match = remaning.match(regexIdQuery);
@@ -604,6 +614,15 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
604
614
  return;
605
615
  return transformVue(code);
606
616
  }
617
+ },
618
+ {
619
+ name: "slidev:title-transform:pre",
620
+ enforce: "pre",
621
+ transform(code, id) {
622
+ if (id !== "/@slidev/titles.md")
623
+ return;
624
+ return transformTitles(code);
625
+ }
607
626
  }
608
627
  ];
609
628
  function updateServerWatcher() {
@@ -694,6 +713,10 @@ ${code.slice(injectIndex)}`;
694
713
  ${imports.join("\n")}
695
714
  <\/script>
696
715
  ${code}`;
716
+ }
717
+ function transformTitles(code) {
718
+ return code.replace(/<template>\s*<div>\s*<p>/, "<template>").replace(/<\/p>\s*<\/div>\s*<\/template>/, "</template>").replace(/<script\ssetup>/, `<script setup lang="ts">
719
+ defineProps<{ no: number | string }>()`);
697
720
  }
698
721
  async function getLayouts() {
699
722
  const now = Date.now();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ViteSlidevPlugin
3
- } from "./chunk-4AVLCCHB.mjs";
3
+ } from "./chunk-MBZTOLHN.mjs";
4
4
  import {
5
5
  init_esm_shims
6
6
  } from "./chunk-XMETW2MS.mjs";
@@ -2392,7 +2392,6 @@ __export(fs_exports, {
2392
2392
  init_esm_shims();
2393
2393
  import { promises as fs } from "fs";
2394
2394
  import { dirname, resolve } from "path";
2395
- import Markdown from "markdown-it";
2396
2395
 
2397
2396
  // ../parser/src/core.ts
2398
2397
  init_esm_shims();
@@ -5105,6 +5104,7 @@ function resolveConfig(headmatter, themeMeta = {}) {
5105
5104
  routerMode: "history",
5106
5105
  aspectRatio: 16 / 9,
5107
5106
  canvasWidth: 980,
5107
+ exportFilename: "",
5108
5108
  selectable: false,
5109
5109
  themeConfig: {},
5110
5110
  fonts: {},
@@ -5114,7 +5114,7 @@ function resolveConfig(headmatter, themeMeta = {}) {
5114
5114
  };
5115
5115
  const config2 = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultConfig2), themeMeta.defaults), headmatter.config), headmatter), {
5116
5116
  fonts: resolveFonts(__spreadValues(__spreadValues(__spreadValues({}, (_a = themeMeta.defaults) == null ? void 0 : _a.fonts), (_b = headmatter.config) == null ? void 0 : _b.fonts), headmatter == null ? void 0 : headmatter.fonts)),
5117
- drawings: resolveDarwings(headmatter.drawings)
5117
+ drawings: resolveDrawings(headmatter.drawings)
5118
5118
  });
5119
5119
  if (config2.colorSchema !== "dark" && config2.colorSchema !== "light")
5120
5120
  config2.colorSchema = "auto";
@@ -5196,7 +5196,7 @@ function resolveFonts(fonts = {}) {
5196
5196
  weights
5197
5197
  };
5198
5198
  }
5199
- function resolveDarwings(options = {}) {
5199
+ function resolveDrawings(options = {}) {
5200
5200
  const {
5201
5201
  enabled = true,
5202
5202
  persist = false,
@@ -5358,9 +5358,9 @@ function parse(markdown, filepath, themeMeta) {
5358
5358
  function mergeFeatureFlags(a, b) {
5359
5359
  return objectMap(a, (k, v) => [k, v || b[k]]);
5360
5360
  }
5361
- function scanMonacoModules(md2) {
5361
+ function scanMonacoModules(md) {
5362
5362
  const typeModules = /* @__PURE__ */ new Set();
5363
- md2.replace(/^```(\w+?)\s*{monaco([\w:,-]*)}[\s\n]*([\s\S]+?)^```/mg, (full, lang = "ts", options, code) => {
5363
+ md.replace(/^```(\w+?)\s*{monaco([\w:,-]*)}[\s\n]*([\s\S]+?)^```/mg, (full, lang = "ts", options, code) => {
5364
5364
  options = options || "";
5365
5365
  lang = lang.trim();
5366
5366
  if (lang === "ts" || lang === "typescript") {
@@ -5372,7 +5372,6 @@ function scanMonacoModules(md2) {
5372
5372
  }
5373
5373
 
5374
5374
  // ../parser/src/fs.ts
5375
- var md = Markdown({ html: true });
5376
5375
  async function load2(filepath, themeMeta, content) {
5377
5376
  const dir = dirname(filepath);
5378
5377
  const markdown = content != null ? content : await fs.readFile(filepath, "utf-8");
@@ -5413,10 +5412,6 @@ async function load2(filepath, themeMeta, content) {
5413
5412
  data.slides.splice(iSlide + offset, 0, slide);
5414
5413
  }
5415
5414
  }
5416
- for (const slide of data.slides) {
5417
- if (slide.title)
5418
- slide.title = md.render(slide.title).trim().replace(/^<p>/, "").replace(/<\/p>$/, "");
5419
- }
5420
5415
  for (let iSlide = 0; iSlide < data.slides.length; iSlide++)
5421
5416
  data.slides[iSlide].index = iSlide === 0 ? 0 : 1 + data.slides[iSlide - 1].index;
5422
5417
  data.entries = Array.from(entries);
@@ -5434,7 +5429,7 @@ async function saveExternalSlide(slide) {
5434
5429
  init_esm_shims();
5435
5430
 
5436
5431
  // package.json
5437
- var version = "0.30.1";
5432
+ var version = "0.30.2";
5438
5433
 
5439
5434
  // node/themes.ts
5440
5435
  init_esm_shims();
@@ -471,7 +471,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
471
471
  });
472
472
  },
473
473
  async handleHotUpdate(ctx) {
474
- var _a;
474
+ var _a, _b, _c;
475
475
  if (!data.entries.some((i) => _utils.slash.call(void 0, i) === ctx.file))
476
476
  return;
477
477
  const newData = await parser.load(entry, data.themeMeta);
@@ -495,7 +495,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
495
495
  for (let i = 0; i < length; i++) {
496
496
  const a = data.slides[i];
497
497
  const b = newData.slides[i];
498
- 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))
498
+ 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))
499
499
  continue;
500
500
  ctx.server.ws.send({
501
501
  type: "custom",
@@ -507,13 +507,15 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
507
507
  });
508
508
  hmrPages.add(i);
509
509
  }
510
- (_a = serverOptions.onDataReload) == null ? void 0 : _a.call(serverOptions, newData, data);
510
+ (_c = serverOptions.onDataReload) == null ? void 0 : _c.call(serverOptions, newData, data);
511
511
  Object.assign(data, newData);
512
+ if (hmrPages.size > 0)
513
+ moduleIds.add("/@slidev/titles.md");
512
514
  const vueModules = (await Promise.all(Array.from(hmrPages).map(async (i) => {
513
515
  var _a2;
514
516
  const file = `${slidePrefix}${i + 1}.md`;
515
517
  try {
516
- const md2 = await transformMarkdown(MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
518
+ const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
517
519
  return await VuePlugin.handleHotUpdate(_chunkIXNT7VMKjs.__spreadProps.call(void 0, _chunkIXNT7VMKjs.__spreadValues.call(void 0, {}, ctx), {
518
520
  modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
519
521
  file,
@@ -558,6 +560,14 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
558
560
  return generateGlobalComponents("bottom");
559
561
  if (id === "/@slidev/custom-nav-controls")
560
562
  return generateCustomNavControls();
563
+ if (id === "/@slidev/titles.md") {
564
+ return {
565
+ code: data.slides.map(({ title }, i) => {
566
+ return `<template ${i === 0 ? "v-if" : "v-else-if"}="+no === ${i + 1}">${title}</template>`;
567
+ }).join(""),
568
+ map: {}
569
+ };
570
+ }
561
571
  if (id.startsWith(slidePrefix)) {
562
572
  const remaning = id.slice(slidePrefix.length);
563
573
  const match = remaning.match(regexIdQuery);
@@ -603,6 +613,15 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
603
613
  return;
604
614
  return transformVue(code);
605
615
  }
616
+ },
617
+ {
618
+ name: "slidev:title-transform:pre",
619
+ enforce: "pre",
620
+ transform(code, id) {
621
+ if (id !== "/@slidev/titles.md")
622
+ return;
623
+ return transformTitles(code);
624
+ }
606
625
  }
607
626
  ];
608
627
  function updateServerWatcher() {
@@ -693,6 +712,10 @@ ${code.slice(injectIndex)}`;
693
712
  ${imports.join("\n")}
694
713
  <\/script>
695
714
  ${code}`;
715
+ }
716
+ function transformTitles(code) {
717
+ return code.replace(/<template>\s*<div>\s*<p>/, "<template>").replace(/<\/p>\s*<\/div>\s*<\/template>/, "</template>").replace(/<script\ssetup>/, `<script setup lang="ts">
718
+ defineProps<{ no: number | string }>()`);
696
719
  }
697
720
  async function getLayouts() {
698
721
  const now = Date.now();
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkHBDQZUZKjs = require('./chunk-HBDQZUZK.js');
3
+ var _chunkE4IOOAKNjs = require('./chunk-E4IOOAKN.js');
4
4
 
5
5
 
6
6
 
@@ -8,10 +8,10 @@ var _chunkHBDQZUZKjs = require('./chunk-HBDQZUZK.js');
8
8
 
9
9
 
10
10
 
11
- var _chunk3GNNQ2GUjs = require('./chunk-3GNNQ2GU.js');
11
+ var _chunk2LNCAUCDjs = require('./chunk-2LNCAUCD.js');
12
12
 
13
13
 
14
- var _chunk7FQD47HMjs = require('./chunk-7FQD47HM.js');
14
+ var _chunkRSHUQSN4js = require('./chunk-RSHUQSN4.js');
15
15
 
16
16
 
17
17
 
@@ -20,7 +20,7 @@ var _chunkIXNT7VMKjs = require('./chunk-IXNT7VMK.js');
20
20
 
21
21
  // node/cli.ts
22
22
  _chunkIXNT7VMKjs.init_cjs_shims.call(void 0, );
23
- var import_fast_deep_equal = _chunkIXNT7VMKjs.__toESM.call(void 0, _chunk7FQD47HMjs.require_fast_deep_equal.call(void 0, ));
23
+ var import_fast_deep_equal = _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkRSHUQSN4js.require_fast_deep_equal.call(void 0, ));
24
24
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
25
25
  var _net = require('net'); var _net2 = _interopRequireDefault(_net);
26
26
  var _os = require('os'); var _os2 = _interopRequireDefault(_os);
@@ -38,7 +38,7 @@ var CONFIG_RESTART_FIELDS = [
38
38
  "routerMode",
39
39
  "fonts"
40
40
  ];
41
- var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunk3GNNQ2GUjs.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
41
+ var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunk2LNCAUCDjs.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
42
42
  cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOptions(args).option("port", {
43
43
  alias: "p",
44
44
  type: "number",
@@ -82,9 +82,9 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
82
82
  async function initServer() {
83
83
  if (server)
84
84
  await server.close();
85
- const options = await _chunk3GNNQ2GUjs.resolveOptions.call(void 0, { entry, theme }, "dev");
85
+ const options = await _chunk2LNCAUCDjs.resolveOptions.call(void 0, { entry, theme }, "dev");
86
86
  port = userPort || await findFreePort(3030);
87
- server = await _chunkHBDQZUZKjs.createServer.call(void 0, options, {
87
+ server = await _chunkE4IOOAKNjs.createServer.call(void 0, options, {
88
88
  server: {
89
89
  port,
90
90
  strictPort: true,
@@ -95,7 +95,7 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
95
95
  logLevel: log
96
96
  }, {
97
97
  onDataReload(newData, data) {
98
- if (!theme && _chunk3GNNQ2GUjs.resolveThemeName.call(void 0, newData.config.theme) !== _chunk3GNNQ2GUjs.resolveThemeName.call(void 0, data.config.theme)) {
98
+ if (!theme && _chunk2LNCAUCDjs.resolveThemeName.call(void 0, newData.config.theme) !== _chunk2LNCAUCDjs.resolveThemeName.call(void 0, data.config.theme)) {
99
99
  console.log(_kolorist.yellow.call(void 0, "\n restarting on theme change\n"));
100
100
  initServer();
101
101
  } else if (CONFIG_RESTART_FIELDS.some((i) => !(0, import_fast_deep_equal.default)(newData.config[i], data.config[i]))) {
@@ -171,8 +171,8 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
171
171
  type: "boolean",
172
172
  describe: "allow download as PDF"
173
173
  }).strict().help(), async ({ entry, theme, watch, base, download, out }) => {
174
- const { build } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "./build-MOXNSJPP.js")));
175
- const options = await _chunk3GNNQ2GUjs.resolveOptions.call(void 0, { entry, theme }, "build");
174
+ const { build } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "./build-23SNLQAJ.js")));
175
+ const options = await _chunk2LNCAUCDjs.resolveOptions.call(void 0, { entry, theme }, "build");
176
176
  if (download && !options.data.config.download)
177
177
  options.data.config.download = download;
178
178
  printInfo(options);
@@ -185,26 +185,26 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
185
185
  });
186
186
  });
187
187
  cli.command("format [entry]", "Format the markdown file", (args) => commonOptions(args).strict().help(), async ({ entry }) => {
188
- const data = await _chunk3GNNQ2GUjs.fs_exports.load(entry);
189
- _chunk3GNNQ2GUjs.fs_exports.prettify(data);
190
- await _chunk3GNNQ2GUjs.fs_exports.save(data);
188
+ const data = await _chunk2LNCAUCDjs.fs_exports.load(entry);
189
+ _chunk2LNCAUCDjs.fs_exports.prettify(data);
190
+ await _chunk2LNCAUCDjs.fs_exports.save(data);
191
191
  });
192
192
  cli.command("theme [subcommand]", "Theme related operations", (command) => {
193
193
  return command.command("eject", "Eject current theme into local file system", (args) => commonOptions(args).option("dir", {
194
194
  type: "string",
195
195
  default: "theme"
196
196
  }), async ({ entry, dir, theme: themeInput }) => {
197
- const data = await _chunk3GNNQ2GUjs.fs_exports.load(entry);
198
- const theme = _chunk3GNNQ2GUjs.resolveThemeName.call(void 0, themeInput || data.config.theme);
197
+ const data = await _chunk2LNCAUCDjs.fs_exports.load(entry);
198
+ const theme = _chunk2LNCAUCDjs.resolveThemeName.call(void 0, themeInput || data.config.theme);
199
199
  if (theme === "none") {
200
200
  console.error('Can not eject theme "none"');
201
201
  process.exit(1);
202
202
  }
203
- if (_chunk3GNNQ2GUjs.isPath.call(void 0, theme)) {
203
+ if (_chunk2LNCAUCDjs.isPath.call(void 0, theme)) {
204
204
  console.error("Theme is already ejected");
205
205
  process.exit(1);
206
206
  }
207
- const roots = _chunk3GNNQ2GUjs.getThemeRoots.call(void 0, theme, entry);
207
+ const roots = _chunk2LNCAUCDjs.getThemeRoots.call(void 0, theme, entry);
208
208
  if (!roots.length) {
209
209
  console.error(`Does not found theme "${theme}"`);
210
210
  process.exit(1);
@@ -216,7 +216,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
216
216
  const dirPath = `./${dir}`;
217
217
  data.slides[0].frontmatter.theme = dirPath;
218
218
  data.slides[0].raw = null;
219
- await _chunk3GNNQ2GUjs.fs_exports.save(data);
219
+ await _chunk2LNCAUCDjs.fs_exports.save(data);
220
220
  console.log(`Theme "${theme}" ejected successfully to "${dirPath}"`);
221
221
  });
222
222
  }, () => {
@@ -257,18 +257,18 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
257
257
  dark,
258
258
  "with-clicks": withClicks
259
259
  }) => {
260
- output = output || `${_path2.default.basename(entry, ".md")}-export`;
261
260
  process.env.NODE_ENV = "production";
262
- const { exportSlides } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "./export-X3EA2DO6.js")));
261
+ const { exportSlides } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "./export-AKEY52VC.js")));
263
262
  const port = await findFreePort(12445);
264
- const options = await _chunk3GNNQ2GUjs.resolveOptions.call(void 0, { entry, theme }, "build");
265
- const server = await _chunkHBDQZUZKjs.createServer.call(void 0, options, {
263
+ const options = await _chunk2LNCAUCDjs.resolveOptions.call(void 0, { entry, theme }, "build");
264
+ output = output || options.data.config.exportFilename || `${_path2.default.basename(entry, ".md")}-export`;
265
+ const server = await _chunkE4IOOAKNjs.createServer.call(void 0, options, {
266
266
  server: { port },
267
267
  clearScreen: false
268
268
  });
269
269
  await server.listen(port);
270
270
  printInfo(options);
271
- _chunk3GNNQ2GUjs.fs_exports.filterDisabled(options.data);
271
+ _chunk2LNCAUCDjs.fs_exports.filterDisabled(options.data);
272
272
  const width = options.data.config.canvasWidth;
273
273
  const height = Math.round(width / options.data.config.aspectRatio);
274
274
  output = await exportSlides({
@@ -306,7 +306,7 @@ function printInfo(options, port, remote) {
306
306
  console.log();
307
307
  console.log();
308
308
  console.log(` ${_kolorist.cyan.call(void 0, "\u25CF") + _kolorist.blue.call(void 0, "\u25A0") + _kolorist.yellow.call(void 0, "\u25B2")}`);
309
- console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunk3GNNQ2GUjs.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
309
+ console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunk2LNCAUCDjs.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
310
310
  console.log();
311
311
  console.log(_kolorist.dim.call(void 0, " theme ") + (options.theme ? _kolorist.green.call(void 0, options.theme) : _kolorist.gray.call(void 0, "none")));
312
312
  console.log(_kolorist.dim.call(void 0, " entry ") + _kolorist.dim.call(void 0, _path2.default.dirname(options.entry) + _path2.default.sep) + _path2.default.basename(options.entry));
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-46RYGQQC.mjs";
3
+ } from "./chunk-O57F34AM.mjs";
4
4
  import {
5
5
  fs_exports,
6
6
  getThemeRoots,
@@ -8,10 +8,10 @@ import {
8
8
  resolveOptions,
9
9
  resolveThemeName,
10
10
  version
11
- } from "./chunk-HJCTB5CG.mjs";
11
+ } from "./chunk-OII7IQD2.mjs";
12
12
  import {
13
13
  require_fast_deep_equal
14
- } from "./chunk-4AVLCCHB.mjs";
14
+ } from "./chunk-MBZTOLHN.mjs";
15
15
  import {
16
16
  __dirname,
17
17
  __require,
@@ -172,7 +172,7 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
172
172
  type: "boolean",
173
173
  describe: "allow download as PDF"
174
174
  }).strict().help(), async ({ entry, theme, watch, base, download, out }) => {
175
- const { build } = await Promise.resolve().then(() => __toESM(__require("./build-SSLWFRFJ.mjs")));
175
+ const { build } = await Promise.resolve().then(() => __toESM(__require("./build-YFDGZUAK.mjs")));
176
176
  const options = await resolveOptions({ entry, theme }, "build");
177
177
  if (download && !options.data.config.download)
178
178
  options.data.config.download = download;
@@ -258,11 +258,11 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
258
258
  dark,
259
259
  "with-clicks": withClicks
260
260
  }) => {
261
- output = output || `${path.basename(entry, ".md")}-export`;
262
261
  process.env.NODE_ENV = "production";
263
- const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-2FIFRI4R.mjs")));
262
+ const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-RFCVIBYE.mjs")));
264
263
  const port = await findFreePort(12445);
265
264
  const options = await resolveOptions({ entry, theme }, "build");
265
+ output = output || options.data.config.exportFilename || `${path.basename(entry, ".md")}-export`;
266
266
  const server = await createServer(options, {
267
267
  server: { port },
268
268
  clearScreen: false
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunk3GNNQ2GUjs = require('./chunk-3GNNQ2GU.js');
3
+ var _chunk2LNCAUCDjs = require('./chunk-2LNCAUCD.js');
4
4
 
5
5
 
6
6
 
@@ -62,7 +62,7 @@ async function exportSlides({
62
62
  height = 1080,
63
63
  withClicks = false
64
64
  }) {
65
- if (!_chunk3GNNQ2GUjs.packageExists.call(void 0, "playwright-chromium"))
65
+ if (!_chunk2LNCAUCDjs.packageExists.call(void 0, "playwright-chromium"))
66
66
  throw new Error("The exporting for Slidev is powered by Playwright, please installed it via `npm i -D playwright-chromium`");
67
67
  const pages = _core.parseRangeString.call(void 0, total, range);
68
68
  const { chromium } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "playwright-chromium")));
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  packageExists
3
- } from "./chunk-HJCTB5CG.mjs";
3
+ } from "./chunk-OII7IQD2.mjs";
4
4
  import {
5
5
  __require,
6
6
  __toESM,
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkHBDQZUZKjs = require('./chunk-HBDQZUZK.js');
3
+ var _chunkE4IOOAKNjs = require('./chunk-E4IOOAKN.js');
4
4
 
5
5
 
6
6
 
@@ -9,11 +9,11 @@ var _chunkHBDQZUZKjs = require('./chunk-HBDQZUZK.js');
9
9
 
10
10
 
11
11
 
12
- var _chunk3GNNQ2GUjs = require('./chunk-3GNNQ2GU.js');
12
+ var _chunk2LNCAUCDjs = require('./chunk-2LNCAUCD.js');
13
13
 
14
14
 
15
15
 
16
- var _chunk7FQD47HMjs = require('./chunk-7FQD47HM.js');
16
+ var _chunkRSHUQSN4js = require('./chunk-RSHUQSN4.js');
17
17
 
18
18
 
19
19
  var _chunkIXNT7VMKjs = require('./chunk-IXNT7VMK.js');
@@ -34,4 +34,4 @@ _chunkIXNT7VMKjs.init_cjs_shims.call(void 0, );
34
34
 
35
35
 
36
36
 
37
- exports.ViteSlidevPlugin = _chunk7FQD47HMjs.ViteSlidevPlugin; exports.createServer = _chunkHBDQZUZKjs.createServer; exports.createWindiCSSPlugin = _chunk7FQD47HMjs.createWindiCSSPlugin; exports.getCLIRoot = _chunk3GNNQ2GUjs.getCLIRoot; exports.getClientRoot = _chunk3GNNQ2GUjs.getClientRoot; exports.getThemeRoots = _chunk3GNNQ2GUjs.getThemeRoots; exports.getUserRoot = _chunk3GNNQ2GUjs.getUserRoot; exports.isPath = _chunk3GNNQ2GUjs.isPath; exports.parser = _chunk3GNNQ2GUjs.fs_exports; exports.resolveOptions = _chunk3GNNQ2GUjs.resolveOptions;
37
+ exports.ViteSlidevPlugin = _chunkRSHUQSN4js.ViteSlidevPlugin; exports.createServer = _chunkE4IOOAKNjs.createServer; exports.createWindiCSSPlugin = _chunkRSHUQSN4js.createWindiCSSPlugin; exports.getCLIRoot = _chunk2LNCAUCDjs.getCLIRoot; exports.getClientRoot = _chunk2LNCAUCDjs.getClientRoot; exports.getThemeRoots = _chunk2LNCAUCDjs.getThemeRoots; exports.getUserRoot = _chunk2LNCAUCDjs.getUserRoot; exports.isPath = _chunk2LNCAUCDjs.isPath; exports.parser = _chunk2LNCAUCDjs.fs_exports; exports.resolveOptions = _chunk2LNCAUCDjs.resolveOptions;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-46RYGQQC.mjs";
3
+ } from "./chunk-O57F34AM.mjs";
4
4
  import {
5
5
  fs_exports,
6
6
  getCLIRoot,
@@ -9,11 +9,11 @@ import {
9
9
  getUserRoot,
10
10
  isPath,
11
11
  resolveOptions
12
- } from "./chunk-HJCTB5CG.mjs";
12
+ } from "./chunk-OII7IQD2.mjs";
13
13
  import {
14
14
  ViteSlidevPlugin,
15
15
  createWindiCSSPlugin
16
- } from "./chunk-4AVLCCHB.mjs";
16
+ } from "./chunk-MBZTOLHN.mjs";
17
17
  import {
18
18
  init_esm_shims
19
19
  } from "./chunk-XMETW2MS.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
- "version": "0.30.1",
3
+ "version": "0.30.2",
4
4
  "description": "Presentation slides for developers",
5
5
  "homepage": "https://sli.dev",
6
6
  "bugs": "https://github.com/slidevjs/slidev/issues",
@@ -42,9 +42,9 @@
42
42
  "@antfu/utils": "^0.5.1",
43
43
  "@iconify-json/carbon": "^1.1.3",
44
44
  "@iconify-json/ph": "^1.1.1",
45
- "@slidev/client": "0.30.1",
46
- "@slidev/parser": "0.30.1",
47
- "@slidev/types": "0.30.1",
45
+ "@slidev/client": "0.30.2",
46
+ "@slidev/parser": "0.30.2",
47
+ "@slidev/types": "0.30.2",
48
48
  "@vitejs/plugin-vue": "^2.3.1",
49
49
  "@vue/compiler-sfc": "^3.2.32",
50
50
  "cli-progress": "^3.10.0",