@slidev/cli 0.38.5 → 0.38.7

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.
@@ -2,7 +2,7 @@ import {
2
2
  ViteSlidevPlugin,
3
3
  getIndexHtml,
4
4
  mergeViteConfigs
5
- } from "./chunk-MDHB5JSE.mjs";
5
+ } from "./chunk-NOJBQ6MT.mjs";
6
6
  import {
7
7
  __require,
8
8
  __toESM,
@@ -648,7 +648,7 @@ function build_default(dir, opts = {}) {
648
648
 
649
649
  // node/build.ts
650
650
  import { blue, yellow } from "kolorist";
651
- async function build(options, viteConfig = {}) {
651
+ async function build(options, viteConfig = {}, args) {
652
652
  const indexPath = resolve3(options.userRoot, "index.html");
653
653
  const rawConfig = await resolveConfig({}, "build", options.entry);
654
654
  const pluginOptions = rawConfig.slidev || {};
@@ -718,14 +718,13 @@ async function build(options, viteConfig = {}) {
718
718
  await fs2.unlink(indexPath);
719
719
  }
720
720
  const outDir = resolve3(options.userRoot, config.build.outDir);
721
- const outFilename = options.data.config.exportFilename || "slidev-exported.pdf";
722
721
  await fs2.copyFile(resolve3(outDir, "index.html"), resolve3(outDir, "404.html"));
723
722
  const redirectsPath = resolve3(outDir, "_redirects");
724
723
  if (!fs2.existsSync(redirectsPath))
725
724
  await fs2.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
726
725
  `, "utf-8");
727
726
  if ([true, "true", "auto"].includes(options.data.config.download)) {
728
- const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-2OSN6D4K.mjs")));
727
+ const { exportSlides, getExportOptions } = await Promise.resolve().then(() => __toESM(__require("./export-LL3DLTJH.mjs")));
729
728
  const port = 12445;
730
729
  const app = connect();
731
730
  const server = http.createServer(app);
@@ -740,15 +739,8 @@ async function build(options, viteConfig = {}) {
740
739
  server.listen(port);
741
740
  await exportSlides({
742
741
  port,
743
- slides: options.data.slides,
744
- total: options.data.slides.length,
745
- format: "pdf",
746
- output: join3(outDir, outFilename),
747
742
  base: config.base,
748
- dark: options.data.config.colorSchema === "dark",
749
- width: options.data.config.canvasWidth,
750
- height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
751
- routerMode: options.data.config.routerMode
743
+ ...getExportOptions(args, options, outDir, "slidev-exported.pdf")
752
744
  });
753
745
  server.close();
754
746
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkSJ7FI34Ejs = require('./chunk-SJ7FI34E.js');
5
+ var _chunkHHR7Q56Zjs = require('./chunk-HHR7Q56Z.js');
6
6
 
7
7
 
8
8
 
@@ -648,23 +648,23 @@ function build_default(dir, opts = {}) {
648
648
 
649
649
  // node/build.ts
650
650
  var _kolorist = require('kolorist');
651
- async function build(options, viteConfig = {}) {
651
+ async function build(options, viteConfig = {}, args) {
652
652
  const indexPath = _path.resolve.call(void 0, options.userRoot, "index.html");
653
653
  const rawConfig = await _vite.resolveConfig.call(void 0, {}, "build", options.entry);
654
654
  const pluginOptions = rawConfig.slidev || {};
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 _chunkSJ7FI34Ejs.getIndexHtml.call(void 0, options), "utf-8");
658
+ await _fsextra2.default.writeFile(indexPath, await _chunkHHR7Q56Zjs.getIndexHtml.call(void 0, options), "utf-8");
659
659
  let config = void 0;
660
660
  try {
661
- const inlineConfig = await _chunkSJ7FI34Ejs.mergeViteConfigs.call(void 0,
661
+ const inlineConfig = await _chunkHHR7Q56Zjs.mergeViteConfigs.call(void 0,
662
662
  options,
663
663
  viteConfig,
664
664
  {
665
665
  root: options.userRoot,
666
666
  plugins: [
667
- await _chunkSJ7FI34Ejs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
667
+ await _chunkHHR7Q56Zjs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
668
668
  {
669
669
  name: "resolve-config",
670
670
  configResolved(_config) {
@@ -685,7 +685,7 @@ async function build(options, viteConfig = {}) {
685
685
  } else {
686
686
  console.log(_kolorist.blue.call(void 0, " building for Monaco...\n"));
687
687
  await _vite.build.call(void 0,
688
- await _chunkSJ7FI34Ejs.mergeViteConfigs.call(void 0,
688
+ await _chunkHHR7Q56Zjs.mergeViteConfigs.call(void 0,
689
689
  options,
690
690
  inlineConfig,
691
691
  {
@@ -718,14 +718,13 @@ async function build(options, viteConfig = {}) {
718
718
  await _fsextra2.default.unlink(indexPath);
719
719
  }
720
720
  const outDir = _path.resolve.call(void 0, options.userRoot, config.build.outDir);
721
- const outFilename = options.data.config.exportFilename || "slidev-exported.pdf";
722
721
  await _fsextra2.default.copyFile(_path.resolve.call(void 0, outDir, "index.html"), _path.resolve.call(void 0, outDir, "404.html"));
723
722
  const redirectsPath = _path.resolve.call(void 0, outDir, "_redirects");
724
723
  if (!_fsextra2.default.existsSync(redirectsPath))
725
724
  await _fsextra2.default.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
726
725
  `, "utf-8");
727
726
  if ([true, "true", "auto"].includes(options.data.config.download)) {
728
- const { exportSlides } = await Promise.resolve().then(() => _chunkOVFYMGU6js.__toESM.call(void 0, _chunkOVFYMGU6js.__require.call(void 0, "./export-RNJ27D27.js")));
727
+ const { exportSlides, getExportOptions } = await Promise.resolve().then(() => _chunkOVFYMGU6js.__toESM.call(void 0, _chunkOVFYMGU6js.__require.call(void 0, "./export-BWNX2QVG.js")));
729
728
  const port = 12445;
730
729
  const app = _connect2.default.call(void 0, );
731
730
  const server = _http2.default.createServer(app);
@@ -740,15 +739,8 @@ async function build(options, viteConfig = {}) {
740
739
  server.listen(port);
741
740
  await exportSlides({
742
741
  port,
743
- slides: options.data.slides,
744
- total: options.data.slides.length,
745
- format: "pdf",
746
- output: _path.join.call(void 0, outDir, outFilename),
747
742
  base: config.base,
748
- dark: options.data.config.colorSchema === "dark",
749
- width: options.data.config.canvasWidth,
750
- height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
751
- routerMode: options.data.config.routerMode
743
+ ...getExportOptions(args, options, outDir, "slidev-exported.pdf")
752
744
  });
753
745
  server.close();
754
746
  }
@@ -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 _chunkSJ7FI34Ejs = require('./chunk-SJ7FI34E.js');
4
+ var _chunkHHR7Q56Zjs = require('./chunk-HHR7Q56Z.js');
5
5
 
6
6
 
7
7
 
@@ -2426,7 +2426,7 @@ async function createServer(options, viteConfig = {}, serverOptions = {}) {
2426
2426
  const pluginOptions = rawConfig.slidev || {};
2427
2427
  process.env.EDITOR = process.env.EDITOR || "code";
2428
2428
  const server = await _vite.createServer.call(void 0,
2429
- await _chunkSJ7FI34Ejs.mergeViteConfigs.call(void 0,
2429
+ await _chunkHHR7Q56Zjs.mergeViteConfigs.call(void 0,
2430
2430
  options,
2431
2431
  viteConfig,
2432
2432
  {
@@ -2436,7 +2436,7 @@ async function createServer(options, viteConfig = {}, serverOptions = {}) {
2436
2436
  ]
2437
2437
  },
2438
2438
  plugins: [
2439
- await _chunkSJ7FI34Ejs.ViteSlidevPlugin.call(void 0, options, pluginOptions, serverOptions)
2439
+ await _chunkHHR7Q56Zjs.ViteSlidevPlugin.call(void 0, options, pluginOptions, serverOptions)
2440
2440
  ]
2441
2441
  },
2442
2442
  "serve"
@@ -2450,7 +2450,7 @@ _chunkOVFYMGU6js.init_cjs_shims.call(void 0, );
2450
2450
  var _fs = require('@slidev/parser/fs'); var parser = _interopRequireWildcard(_fs);
2451
2451
 
2452
2452
  // package.json
2453
- var version = "0.38.5";
2453
+ var version = "0.38.7";
2454
2454
 
2455
2455
  // node/themes.ts
2456
2456
  _chunkOVFYMGU6js.init_cjs_shims.call(void 0, );
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ViteSlidevPlugin,
3
3
  mergeViteConfigs
4
- } from "./chunk-MDHB5JSE.mjs";
4
+ } from "./chunk-NOJBQ6MT.mjs";
5
5
  import {
6
6
  __commonJS,
7
7
  __dirname,
@@ -2451,7 +2451,7 @@ init_esm_shims();
2451
2451
  import * as parser from "@slidev/parser/fs";
2452
2452
 
2453
2453
  // package.json
2454
- var version = "0.38.5";
2454
+ var version = "0.38.7";
2455
2455
 
2456
2456
  // node/themes.ts
2457
2457
  init_esm_shims();
@@ -982,7 +982,6 @@ export default {
982
982
  _chunkOVFYMGU6js.init_cjs_shims.call(void 0, );
983
983
 
984
984
 
985
-
986
985
  function createMonacoTypesLoader() {
987
986
  return {
988
987
  name: "slidev:monaco-types-loader",
@@ -991,11 +990,12 @@ function createMonacoTypesLoader() {
991
990
  return id;
992
991
  return null;
993
992
  },
994
- load(id) {
993
+ async load(id) {
995
994
  const match = id.match(/^\/\@slidev-monaco-types\/(.*)$/);
996
995
  if (match) {
997
996
  const pkg = match[1];
998
- const info = _vite.resolvePackageData.call(void 0, pkg, process.cwd());
997
+ const { resolvePackageData } = await Promise.resolve().then(() => _chunkOVFYMGU6js.__toESM.call(void 0, _chunkOVFYMGU6js.__require.call(void 0, "vite")));
998
+ const info = resolvePackageData(pkg, process.cwd());
999
999
  if (!info)
1000
1000
  return;
1001
1001
  const typePath = info.data.types || info.data.typings;
@@ -1076,7 +1076,7 @@ var _jsbase64 = require('js-base64'); var base64 = _interopRequireWildcard(_jsba
1076
1076
 
1077
1077
 
1078
1078
  var _markdownitfootnote = require('markdown-it-footnote'); var _markdownitfootnote2 = _interopRequireDefault(_markdownitfootnote);
1079
- var _markdownittasklists = require('@hedgedoc/markdown-it-task-lists'); var _markdownittasklists2 = _interopRequireDefault(_markdownittasklists);
1079
+ var _markdownitplugins = require('@hedgedoc/markdown-it-plugins');
1080
1080
  var _shiki = require('shiki'); var Shiki = _interopRequireWildcard(_shiki);
1081
1081
  var _plantumlencoder = require('plantuml-encoder');
1082
1082
 
@@ -1387,7 +1387,7 @@ async function createMarkdownPlugin({ data: { config }, roots, mode, entry }, {
1387
1387
  }
1388
1388
  });
1389
1389
  md2.use(_markdownitfootnote2.default);
1390
- md2.use(_markdownittasklists2.default, { enabled: true, lineNumber: true, label: true });
1390
+ md2.use(_markdownitplugins.taskLists, { enabled: true, lineNumber: true, label: true });
1391
1391
  md2.use(math_plugin, KatexOptions);
1392
1392
  setups.forEach((i) => i(md2));
1393
1393
  (_a = mdOptions == null ? void 0 : mdOptions.markdownItSetup) == null ? void 0 : _a.call(mdOptions, md2);
@@ -983,7 +983,6 @@ export default {
983
983
  init_esm_shims();
984
984
  import { join as join6 } from "path";
985
985
  import { slash as slash3 } from "@antfu/utils";
986
- import { resolvePackageData } from "vite";
987
986
  function createMonacoTypesLoader() {
988
987
  return {
989
988
  name: "slidev:monaco-types-loader",
@@ -992,10 +991,11 @@ function createMonacoTypesLoader() {
992
991
  return id;
993
992
  return null;
994
993
  },
995
- load(id) {
994
+ async load(id) {
996
995
  const match = id.match(/^\/\@slidev-monaco-types\/(.*)$/);
997
996
  if (match) {
998
997
  const pkg = match[1];
998
+ const { resolvePackageData } = await Promise.resolve().then(() => __toESM(__require("vite")));
999
999
  const info = resolvePackageData(pkg, process.cwd());
1000
1000
  if (!info)
1001
1001
  return;
@@ -1077,7 +1077,7 @@ import * as base64 from "js-base64";
1077
1077
  import { slash as slash5 } from "@antfu/utils";
1078
1078
  import mila2 from "markdown-it-link-attributes";
1079
1079
  import mif from "markdown-it-footnote";
1080
- import mitl from "@hedgedoc/markdown-it-task-lists";
1080
+ import { taskLists } from "@hedgedoc/markdown-it-plugins";
1081
1081
  import * as Shiki from "shiki";
1082
1082
  import { encode as encode2 } from "plantuml-encoder";
1083
1083
 
@@ -1388,7 +1388,7 @@ async function createMarkdownPlugin({ data: { config }, roots, mode, entry }, {
1388
1388
  }
1389
1389
  });
1390
1390
  md2.use(mif);
1391
- md2.use(mitl, { enabled: true, lineNumber: true, label: true });
1391
+ md2.use(taskLists, { enabled: true, lineNumber: true, label: true });
1392
1392
  md2.use(math_plugin, KatexOptions);
1393
1393
  setups.forEach((i) => i(md2));
1394
1394
  (_a = mdOptions == null ? void 0 : mdOptions.markdownItSetup) == null ? void 0 : _a.call(mdOptions, md2);
package/dist/cli.js CHANGED
@@ -9,11 +9,11 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkFENLKXMBjs = require('./chunk-FENLKXMB.js');
12
+ var _chunk35GWFKPPjs = require('./chunk-35GWFKPP.js');
13
13
 
14
14
 
15
15
 
16
- var _chunkSJ7FI34Ejs = require('./chunk-SJ7FI34E.js');
16
+ var _chunkHHR7Q56Zjs = require('./chunk-HHR7Q56Z.js');
17
17
 
18
18
 
19
19
 
@@ -22,7 +22,7 @@ var _chunkOVFYMGU6js = require('./chunk-OVFYMGU6.js');
22
22
 
23
23
  // node/cli.ts
24
24
  _chunkOVFYMGU6js.init_cjs_shims.call(void 0, );
25
- var import_fast_deep_equal = _chunkOVFYMGU6js.__toESM.call(void 0, _chunkSJ7FI34Ejs.require_fast_deep_equal.call(void 0, ));
25
+ var import_fast_deep_equal = _chunkOVFYMGU6js.__toESM.call(void 0, _chunkHHR7Q56Zjs.require_fast_deep_equal.call(void 0, ));
26
26
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
27
27
  var _net = require('net'); var _net2 = _interopRequireDefault(_net);
28
28
  var _os = require('os'); var _os2 = _interopRequireDefault(_os);
@@ -47,14 +47,14 @@ _fs.injectPreparserExtensionLoader.call(void 0, async (headmatter, filepath) =>
47
47
  var _a;
48
48
  const addons = (_a = headmatter == null ? void 0 : headmatter.addons) != null ? _a : [];
49
49
  const roots = [
50
- _chunkFENLKXMBjs.getUserRoot.call(void 0, {}).userRoot,
51
- ..._chunkFENLKXMBjs.getAddonRoots.call(void 0, addons, ""),
52
- _chunkFENLKXMBjs.getClientRoot.call(void 0, )
50
+ _chunk35GWFKPPjs.getUserRoot.call(void 0, {}).userRoot,
51
+ ..._chunk35GWFKPPjs.getAddonRoots.call(void 0, addons, ""),
52
+ _chunk35GWFKPPjs.getClientRoot.call(void 0, )
53
53
  ];
54
54
  const mergeArrays = (a, b) => a.concat(b);
55
- return await _chunkSJ7FI34Ejs.loadSetups.call(void 0, roots, "preparser.ts", { filepath, headmatter }, [], false, mergeArrays);
55
+ return await _chunkHHR7Q56Zjs.loadSetups.call(void 0, roots, "preparser.ts", { filepath, headmatter }, [], false, mergeArrays);
56
56
  });
57
- var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunkFENLKXMBjs.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
57
+ var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunk35GWFKPPjs.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
58
58
  cli.command(
59
59
  "* [entry]",
60
60
  "Start a local server for Slidev",
@@ -105,9 +105,9 @@ cli.command(
105
105
  async function initServer() {
106
106
  if (server)
107
107
  await server.close();
108
- const options = await _chunkFENLKXMBjs.resolveOptions.call(void 0, { entry, remote, theme, inspect }, "dev");
108
+ const options = await _chunk35GWFKPPjs.resolveOptions.call(void 0, { entry, remote, theme, inspect }, "dev");
109
109
  port = userPort || await findFreePort(3030);
110
- server = await _chunkFENLKXMBjs.createServer.call(void 0,
110
+ server = await _chunk35GWFKPPjs.createServer.call(void 0,
111
111
  options,
112
112
  {
113
113
  server: {
@@ -121,7 +121,7 @@ cli.command(
121
121
  },
122
122
  {
123
123
  onDataReload(newData, data) {
124
- if (!theme && _chunkFENLKXMBjs.resolveThemeName.call(void 0, newData.config.theme) !== _chunkFENLKXMBjs.resolveThemeName.call(void 0, data.config.theme)) {
124
+ if (!theme && _chunk35GWFKPPjs.resolveThemeName.call(void 0, newData.config.theme) !== _chunk35GWFKPPjs.resolveThemeName.call(void 0, data.config.theme)) {
125
125
  console.log(_kolorist.yellow.call(void 0, "\n restarting on theme change\n"));
126
126
  initServer();
127
127
  } else if (CONFIG_RESTART_FIELDS.some((i) => !(0, import_fast_deep_equal.default)(newData.config[i], data.config[i]))) {
@@ -185,7 +185,7 @@ cli.command(
185
185
  cli.command(
186
186
  "build [entry]",
187
187
  "Build hostable SPA",
188
- (args) => commonOptions(args).option("watch", {
188
+ (args) => exportOptions(commonOptions(args)).option("watch", {
189
189
  alias: "w",
190
190
  default: false,
191
191
  describe: "build watch"
@@ -206,9 +206,10 @@ cli.command(
206
206
  type: "boolean",
207
207
  describe: "enable the inspect plugin for debugging"
208
208
  }).strict().help(),
209
- async ({ entry, theme, watch, base, download, out, inspect }) => {
210
- const { build } = await Promise.resolve().then(() => _chunkOVFYMGU6js.__toESM.call(void 0, _chunkOVFYMGU6js.__require.call(void 0, "./build-MNMMWCV6.js")));
211
- const options = await _chunkFENLKXMBjs.resolveOptions.call(void 0, { entry, theme, inspect }, "build");
209
+ async (args) => {
210
+ const { entry, theme, watch, base, download, out, inspect } = args;
211
+ const { build } = await Promise.resolve().then(() => _chunkOVFYMGU6js.__toESM.call(void 0, _chunkOVFYMGU6js.__require.call(void 0, "./build-S6XIJ3EO.js")));
212
+ const options = await _chunk35GWFKPPjs.resolveOptions.call(void 0, { entry, theme, inspect }, "build");
212
213
  if (download && !options.data.config.download)
213
214
  options.data.config.download = download;
214
215
  printInfo(options);
@@ -218,7 +219,7 @@ cli.command(
218
219
  watch: watch ? {} : void 0,
219
220
  outDir: out
220
221
  }
221
- });
222
+ }, args);
222
223
  }
223
224
  );
224
225
  cli.command(
@@ -226,9 +227,9 @@ cli.command(
226
227
  "Format the markdown file",
227
228
  (args) => commonOptions(args).strict().help(),
228
229
  async ({ entry }) => {
229
- const data = await _chunkFENLKXMBjs.parser.load(entry);
230
- _chunkFENLKXMBjs.parser.prettify(data);
231
- await _chunkFENLKXMBjs.parser.save(data);
230
+ const data = await _chunk35GWFKPPjs.parser.load(entry);
231
+ _chunk35GWFKPPjs.parser.prettify(data);
232
+ await _chunk35GWFKPPjs.parser.save(data);
232
233
  }
233
234
  );
234
235
  cli.command(
@@ -243,17 +244,17 @@ cli.command(
243
244
  default: "theme"
244
245
  }),
245
246
  async ({ entry, dir, theme: themeInput }) => {
246
- const data = await _chunkFENLKXMBjs.parser.load(entry);
247
- const theme = _chunkFENLKXMBjs.resolveThemeName.call(void 0, themeInput || data.config.theme);
247
+ const data = await _chunk35GWFKPPjs.parser.load(entry);
248
+ const theme = _chunk35GWFKPPjs.resolveThemeName.call(void 0, themeInput || data.config.theme);
248
249
  if (theme === "none") {
249
250
  console.error('Cannot eject theme "none"');
250
251
  process.exit(1);
251
252
  }
252
- if (_chunkFENLKXMBjs.isPath.call(void 0, theme)) {
253
+ if (_chunk35GWFKPPjs.isPath.call(void 0, theme)) {
253
254
  console.error("Theme is already ejected");
254
255
  process.exit(1);
255
256
  }
256
- const roots = _chunkFENLKXMBjs.getThemeRoots.call(void 0, theme, entry);
257
+ const roots = _chunk35GWFKPPjs.getThemeRoots.call(void 0, theme, entry);
257
258
  if (!roots.length) {
258
259
  console.error(`Could not find theme "${theme}"`);
259
260
  process.exit(1);
@@ -265,7 +266,7 @@ cli.command(
265
266
  const dirPath = `./${dir}`;
266
267
  data.slides[0].frontmatter.theme = dirPath;
267
268
  data.slides[0].raw = null;
268
- await _chunkFENLKXMBjs.parser.save(data);
269
+ await _chunk35GWFKPPjs.parser.save(data);
269
270
  console.log(`Theme "${theme}" ejected successfully to "${dirPath}"`);
270
271
  }
271
272
  );
@@ -278,56 +279,14 @@ cli.command(
278
279
  cli.command(
279
280
  "export [entry]",
280
281
  "Export slides to PDF",
281
- (args) => commonOptions(args).option("output", {
282
- type: "string",
283
- describe: "path to the output"
284
- }).option("format", {
285
- default: "pdf",
286
- type: "string",
287
- choices: ["pdf", "png", "md"],
288
- describe: "output format"
289
- }).option("timeout", {
290
- default: 3e4,
291
- type: "number",
292
- describe: "timeout for rendering the print page"
293
- }).option("range", {
294
- type: "string",
295
- describe: 'page ranges to export, for example "1,4-5,6"'
296
- }).option("dark", {
297
- default: false,
298
- type: "boolean",
299
- describe: "export as dark theme"
300
- }).option("with-clicks", {
301
- alias: "c",
302
- default: false,
303
- type: "boolean",
304
- describe: "export pages for every clicks"
305
- }).option("executable-path", {
306
- type: "string",
307
- describe: "executable to override playwright bundled browser"
308
- }).option("with-toc", {
309
- default: false,
310
- type: "boolean",
311
- describe: "export pages with outline"
312
- }).strict().help(),
313
- async ({
314
- entry,
315
- theme,
316
- output,
317
- format,
318
- timeout,
319
- range,
320
- dark,
321
- "with-clicks": withClicks,
322
- "executable-path": executablePath,
323
- "with-toc": withTOC
324
- }) => {
282
+ (args) => exportOptions(commonOptions(args)).strict().help(),
283
+ async (args) => {
284
+ const { entry, theme } = args;
325
285
  process.env.NODE_ENV = "production";
326
- const { exportSlides } = await Promise.resolve().then(() => _chunkOVFYMGU6js.__toESM.call(void 0, _chunkOVFYMGU6js.__require.call(void 0, "./export-RNJ27D27.js")));
286
+ const { exportSlides, getExportOptions } = await Promise.resolve().then(() => _chunkOVFYMGU6js.__toESM.call(void 0, _chunkOVFYMGU6js.__require.call(void 0, "./export-BWNX2QVG.js")));
327
287
  const port = await findFreePort(12445);
328
- const options = await _chunkFENLKXMBjs.resolveOptions.call(void 0, { entry, theme }, "export");
329
- output = output || options.data.config.exportFilename || `${_path2.default.basename(entry, ".md")}-export`;
330
- const server = await _chunkFENLKXMBjs.createServer.call(void 0,
288
+ const options = await _chunk35GWFKPPjs.resolveOptions.call(void 0, { entry, theme }, "export");
289
+ const server = await _chunk35GWFKPPjs.createServer.call(void 0,
331
290
  options,
332
291
  {
333
292
  server: { port },
@@ -336,24 +295,10 @@ cli.command(
336
295
  );
337
296
  await server.listen(port);
338
297
  printInfo(options);
339
- _chunkFENLKXMBjs.parser.filterDisabled(options.data);
340
- const width = options.data.config.canvasWidth;
341
- const height = Math.round(width / options.data.config.aspectRatio);
342
- output = await exportSlides({
298
+ _chunk35GWFKPPjs.parser.filterDisabled(options.data);
299
+ const output = await exportSlides({
343
300
  port,
344
- slides: options.data.slides,
345
- total: options.data.slides.length,
346
- range,
347
- format,
348
- output,
349
- timeout,
350
- dark,
351
- routerMode: options.data.config.routerMode,
352
- width,
353
- height,
354
- withClicks,
355
- executablePath,
356
- withTOC
301
+ ...getExportOptions(args, options)
357
302
  });
358
303
  console.log(`${_kolorist.green.call(void 0, " \u2713 ")}${_kolorist.dim.call(void 0, "exported to ")}./${output}
359
304
  `);
@@ -382,12 +327,12 @@ cli.command(
382
327
  timeout
383
328
  }) => {
384
329
  process.env.NODE_ENV = "production";
385
- const { exportNotes } = await Promise.resolve().then(() => _chunkOVFYMGU6js.__toESM.call(void 0, _chunkOVFYMGU6js.__require.call(void 0, "./export-RNJ27D27.js")));
330
+ const { exportNotes } = await Promise.resolve().then(() => _chunkOVFYMGU6js.__toESM.call(void 0, _chunkOVFYMGU6js.__require.call(void 0, "./export-BWNX2QVG.js")));
386
331
  const port = await findFreePort(12445);
387
- const options = await _chunkFENLKXMBjs.resolveOptions.call(void 0, { entry }, "export");
332
+ const options = await _chunk35GWFKPPjs.resolveOptions.call(void 0, { entry }, "export");
388
333
  if (!output)
389
334
  output = options.data.config.exportFilename ? `${options.data.config.exportFilename}-notes` : `${_path2.default.basename(entry, ".md")}-export-notes`;
390
- const server = await _chunkFENLKXMBjs.createServer.call(void 0,
335
+ const server = await _chunk35GWFKPPjs.createServer.call(void 0,
391
336
  options,
392
337
  {
393
338
  server: { port },
@@ -396,7 +341,7 @@ cli.command(
396
341
  );
397
342
  await server.listen(port);
398
343
  printInfo(options);
399
- _chunkFENLKXMBjs.parser.filterDisabled(options.data);
344
+ _chunk35GWFKPPjs.parser.filterDisabled(options.data);
400
345
  output = await exportNotes({
401
346
  port,
402
347
  output,
@@ -420,11 +365,40 @@ function commonOptions(args) {
420
365
  describe: "override theme"
421
366
  });
422
367
  }
368
+ function exportOptions(args) {
369
+ return args.option("output", {
370
+ type: "string",
371
+ describe: "path to the output"
372
+ }).option("format", {
373
+ type: "string",
374
+ choices: ["pdf", "png", "md"],
375
+ describe: "output format"
376
+ }).option("timeout", {
377
+ type: "number",
378
+ describe: "timeout for rendering the print page"
379
+ }).option("range", {
380
+ type: "string",
381
+ describe: 'page ranges to export, for example "1,4-5,6"'
382
+ }).option("dark", {
383
+ type: "boolean",
384
+ describe: "export as dark theme"
385
+ }).option("with-clicks", {
386
+ alias: "c",
387
+ type: "boolean",
388
+ describe: "export pages for every clicks"
389
+ }).option("executable-path", {
390
+ type: "string",
391
+ describe: "executable to override playwright bundled browser"
392
+ }).option("with-toc", {
393
+ type: "boolean",
394
+ describe: "export pages with outline"
395
+ });
396
+ }
423
397
  function printInfo(options, port, remote) {
424
398
  console.log();
425
399
  console.log();
426
400
  console.log(` ${_kolorist.cyan.call(void 0, "\u25CF") + _kolorist.blue.call(void 0, "\u25A0") + _kolorist.yellow.call(void 0, "\u25B2")}`);
427
- console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunkFENLKXMBjs.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
401
+ console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunk35GWFKPPjs.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
428
402
  console.log();
429
403
  console.log(_kolorist.dim.call(void 0, " theme ") + (options.theme ? _kolorist.green.call(void 0, options.theme) : _kolorist.gray.call(void 0, "none")));
430
404
  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
@@ -9,11 +9,11 @@ import {
9
9
  resolveOptions,
10
10
  resolveThemeName,
11
11
  version
12
- } from "./chunk-RWZQGJHC.mjs";
12
+ } from "./chunk-5HOW7RNS.mjs";
13
13
  import {
14
14
  loadSetups,
15
15
  require_fast_deep_equal
16
- } from "./chunk-MDHB5JSE.mjs";
16
+ } from "./chunk-NOJBQ6MT.mjs";
17
17
  import {
18
18
  __dirname,
19
19
  __require,
@@ -186,7 +186,7 @@ cli.command(
186
186
  cli.command(
187
187
  "build [entry]",
188
188
  "Build hostable SPA",
189
- (args) => commonOptions(args).option("watch", {
189
+ (args) => exportOptions(commonOptions(args)).option("watch", {
190
190
  alias: "w",
191
191
  default: false,
192
192
  describe: "build watch"
@@ -207,8 +207,9 @@ cli.command(
207
207
  type: "boolean",
208
208
  describe: "enable the inspect plugin for debugging"
209
209
  }).strict().help(),
210
- async ({ entry, theme, watch, base, download, out, inspect }) => {
211
- const { build } = await Promise.resolve().then(() => __toESM(__require("./build-NROT64YL.mjs")));
210
+ async (args) => {
211
+ const { entry, theme, watch, base, download, out, inspect } = args;
212
+ const { build } = await Promise.resolve().then(() => __toESM(__require("./build-2WSKFKOA.mjs")));
212
213
  const options = await resolveOptions({ entry, theme, inspect }, "build");
213
214
  if (download && !options.data.config.download)
214
215
  options.data.config.download = download;
@@ -219,7 +220,7 @@ cli.command(
219
220
  watch: watch ? {} : void 0,
220
221
  outDir: out
221
222
  }
222
- });
223
+ }, args);
223
224
  }
224
225
  );
225
226
  cli.command(
@@ -279,55 +280,13 @@ cli.command(
279
280
  cli.command(
280
281
  "export [entry]",
281
282
  "Export slides to PDF",
282
- (args) => commonOptions(args).option("output", {
283
- type: "string",
284
- describe: "path to the output"
285
- }).option("format", {
286
- default: "pdf",
287
- type: "string",
288
- choices: ["pdf", "png", "md"],
289
- describe: "output format"
290
- }).option("timeout", {
291
- default: 3e4,
292
- type: "number",
293
- describe: "timeout for rendering the print page"
294
- }).option("range", {
295
- type: "string",
296
- describe: 'page ranges to export, for example "1,4-5,6"'
297
- }).option("dark", {
298
- default: false,
299
- type: "boolean",
300
- describe: "export as dark theme"
301
- }).option("with-clicks", {
302
- alias: "c",
303
- default: false,
304
- type: "boolean",
305
- describe: "export pages for every clicks"
306
- }).option("executable-path", {
307
- type: "string",
308
- describe: "executable to override playwright bundled browser"
309
- }).option("with-toc", {
310
- default: false,
311
- type: "boolean",
312
- describe: "export pages with outline"
313
- }).strict().help(),
314
- async ({
315
- entry,
316
- theme,
317
- output,
318
- format,
319
- timeout,
320
- range,
321
- dark,
322
- "with-clicks": withClicks,
323
- "executable-path": executablePath,
324
- "with-toc": withTOC
325
- }) => {
283
+ (args) => exportOptions(commonOptions(args)).strict().help(),
284
+ async (args) => {
285
+ const { entry, theme } = args;
326
286
  process.env.NODE_ENV = "production";
327
- const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-2OSN6D4K.mjs")));
287
+ const { exportSlides, getExportOptions } = await Promise.resolve().then(() => __toESM(__require("./export-LL3DLTJH.mjs")));
328
288
  const port = await findFreePort(12445);
329
289
  const options = await resolveOptions({ entry, theme }, "export");
330
- output = output || options.data.config.exportFilename || `${path.basename(entry, ".md")}-export`;
331
290
  const server = await createServer(
332
291
  options,
333
292
  {
@@ -338,23 +297,9 @@ cli.command(
338
297
  await server.listen(port);
339
298
  printInfo(options);
340
299
  parser.filterDisabled(options.data);
341
- const width = options.data.config.canvasWidth;
342
- const height = Math.round(width / options.data.config.aspectRatio);
343
- output = await exportSlides({
300
+ const output = await exportSlides({
344
301
  port,
345
- slides: options.data.slides,
346
- total: options.data.slides.length,
347
- range,
348
- format,
349
- output,
350
- timeout,
351
- dark,
352
- routerMode: options.data.config.routerMode,
353
- width,
354
- height,
355
- withClicks,
356
- executablePath,
357
- withTOC
302
+ ...getExportOptions(args, options)
358
303
  });
359
304
  console.log(`${green(" \u2713 ")}${dim("exported to ")}./${output}
360
305
  `);
@@ -383,7 +328,7 @@ cli.command(
383
328
  timeout
384
329
  }) => {
385
330
  process.env.NODE_ENV = "production";
386
- const { exportNotes } = await Promise.resolve().then(() => __toESM(__require("./export-2OSN6D4K.mjs")));
331
+ const { exportNotes } = await Promise.resolve().then(() => __toESM(__require("./export-LL3DLTJH.mjs")));
387
332
  const port = await findFreePort(12445);
388
333
  const options = await resolveOptions({ entry }, "export");
389
334
  if (!output)
@@ -421,6 +366,35 @@ function commonOptions(args) {
421
366
  describe: "override theme"
422
367
  });
423
368
  }
369
+ function exportOptions(args) {
370
+ return args.option("output", {
371
+ type: "string",
372
+ describe: "path to the output"
373
+ }).option("format", {
374
+ type: "string",
375
+ choices: ["pdf", "png", "md"],
376
+ describe: "output format"
377
+ }).option("timeout", {
378
+ type: "number",
379
+ describe: "timeout for rendering the print page"
380
+ }).option("range", {
381
+ type: "string",
382
+ describe: 'page ranges to export, for example "1,4-5,6"'
383
+ }).option("dark", {
384
+ type: "boolean",
385
+ describe: "export as dark theme"
386
+ }).option("with-clicks", {
387
+ alias: "c",
388
+ type: "boolean",
389
+ describe: "export pages for every clicks"
390
+ }).option("executable-path", {
391
+ type: "string",
392
+ describe: "executable to override playwright bundled browser"
393
+ }).option("with-toc", {
394
+ type: "boolean",
395
+ describe: "export pages with outline"
396
+ });
397
+ }
424
398
  function printInfo(options, port, remote) {
425
399
  console.log();
426
400
  console.log();
@@ -122,7 +122,7 @@ async function exportSlides({
122
122
  height = 1080,
123
123
  withClicks = false,
124
124
  executablePath = void 0,
125
- withTOC = false
125
+ withToc = false
126
126
  }) {
127
127
  if (!_chunkOVFYMGU6js.packageExists.call(void 0, "playwright-chromium"))
128
128
  throw new Error("The exporting for Slidev is powered by Playwright, please installed it via `npm i -D playwright-chromium`");
@@ -202,7 +202,7 @@ async function exportSlides({
202
202
  pdf.setTitle(titleSlide.title);
203
203
  if ((_a = titleSlide == null ? void 0 : titleSlide.frontmatter) == null ? void 0 : _a.info)
204
204
  pdf.setSubject(titleSlide.frontmatter.info);
205
- if (withTOC) {
205
+ if (withToc) {
206
206
  const outlinePdf = _outlinepdf.outlinePdfFactory.call(void 0, pdfLib);
207
207
  const tocTree = slides.filter((slide) => slide.title).reduce((acc, slide) => {
208
208
  addToTree(acc, slide, slideIndexes);
@@ -264,7 +264,46 @@ async function exportSlides({
264
264
  browser.close();
265
265
  return output;
266
266
  }
267
+ function getExportOptions(args, options, outDir, outFilename) {
268
+ const config = {
269
+ ...options.data.config.export,
270
+ ...args,
271
+ withClicks: args["with-clicks"],
272
+ executablePath: args["executable-path"],
273
+ withToc: args["with-toc"]
274
+ };
275
+ const {
276
+ entry,
277
+ output,
278
+ format,
279
+ timeout,
280
+ range,
281
+ dark,
282
+ withClicks,
283
+ executablePath,
284
+ withToc
285
+ } = config;
286
+ outFilename = output || options.data.config.exportFilename || outFilename || `${_path2.default.basename(entry, ".md")}-export`;
287
+ if (outDir)
288
+ outFilename = _path2.default.join(outDir, outFilename);
289
+ return {
290
+ output: outFilename,
291
+ slides: options.data.slides,
292
+ total: options.data.slides.length,
293
+ range,
294
+ format: format || "pdf",
295
+ timeout: timeout || 3e4,
296
+ dark: dark || options.data.config.colorSchema === "dark",
297
+ routerMode: options.data.config.routerMode,
298
+ width: options.data.config.canvasWidth,
299
+ height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
300
+ withClicks: withClicks || false,
301
+ executablePath,
302
+ withToc: withToc || false
303
+ };
304
+ }
305
+
267
306
 
268
307
 
269
308
 
270
- exports.exportNotes = exportNotes; exports.exportSlides = exportSlides;
309
+ exports.exportNotes = exportNotes; exports.exportSlides = exportSlides; exports.getExportOptions = getExportOptions;
@@ -122,7 +122,7 @@ async function exportSlides({
122
122
  height = 1080,
123
123
  withClicks = false,
124
124
  executablePath = void 0,
125
- withTOC = false
125
+ withToc = false
126
126
  }) {
127
127
  if (!packageExists("playwright-chromium"))
128
128
  throw new Error("The exporting for Slidev is powered by Playwright, please installed it via `npm i -D playwright-chromium`");
@@ -202,7 +202,7 @@ async function exportSlides({
202
202
  pdf.setTitle(titleSlide.title);
203
203
  if ((_a = titleSlide == null ? void 0 : titleSlide.frontmatter) == null ? void 0 : _a.info)
204
204
  pdf.setSubject(titleSlide.frontmatter.info);
205
- if (withTOC) {
205
+ if (withToc) {
206
206
  const outlinePdf = outlinePdfFactory(pdfLib);
207
207
  const tocTree = slides.filter((slide) => slide.title).reduce((acc, slide) => {
208
208
  addToTree(acc, slide, slideIndexes);
@@ -264,7 +264,46 @@ async function exportSlides({
264
264
  browser.close();
265
265
  return output;
266
266
  }
267
+ function getExportOptions(args, options, outDir, outFilename) {
268
+ const config = {
269
+ ...options.data.config.export,
270
+ ...args,
271
+ withClicks: args["with-clicks"],
272
+ executablePath: args["executable-path"],
273
+ withToc: args["with-toc"]
274
+ };
275
+ const {
276
+ entry,
277
+ output,
278
+ format,
279
+ timeout,
280
+ range,
281
+ dark,
282
+ withClicks,
283
+ executablePath,
284
+ withToc
285
+ } = config;
286
+ outFilename = output || options.data.config.exportFilename || outFilename || `${path.basename(entry, ".md")}-export`;
287
+ if (outDir)
288
+ outFilename = path.join(outDir, outFilename);
289
+ return {
290
+ output: outFilename,
291
+ slides: options.data.slides,
292
+ total: options.data.slides.length,
293
+ range,
294
+ format: format || "pdf",
295
+ timeout: timeout || 3e4,
296
+ dark: dark || options.data.config.colorSchema === "dark",
297
+ routerMode: options.data.config.routerMode,
298
+ width: options.data.config.canvasWidth,
299
+ height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
300
+ withClicks: withClicks || false,
301
+ executablePath,
302
+ withToc: withToc || false
303
+ };
304
+ }
267
305
  export {
268
306
  exportNotes,
269
- exportSlides
307
+ exportSlides,
308
+ getExportOptions
270
309
  };
package/dist/index.js CHANGED
@@ -9,11 +9,11 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkFENLKXMBjs = require('./chunk-FENLKXMB.js');
12
+ var _chunk35GWFKPPjs = require('./chunk-35GWFKPP.js');
13
13
 
14
14
 
15
15
 
16
- var _chunkSJ7FI34Ejs = require('./chunk-SJ7FI34E.js');
16
+ var _chunkHHR7Q56Zjs = require('./chunk-HHR7Q56Z.js');
17
17
 
18
18
 
19
19
  var _chunkOVFYMGU6js = require('./chunk-OVFYMGU6.js');
@@ -36,4 +36,4 @@ _chunkOVFYMGU6js.init_cjs_shims.call(void 0, );
36
36
 
37
37
 
38
38
 
39
- exports.ViteSlidevPlugin = _chunkSJ7FI34Ejs.ViteSlidevPlugin; exports.createServer = _chunkFENLKXMBjs.createServer; exports.createWindiCSSPlugin = _chunkSJ7FI34Ejs.createWindiCSSPlugin; exports.getAddonRoots = _chunkFENLKXMBjs.getAddonRoots; exports.getCLIRoot = _chunkFENLKXMBjs.getCLIRoot; exports.getClientRoot = _chunkFENLKXMBjs.getClientRoot; exports.getRoot = _chunkFENLKXMBjs.getRoot; exports.getThemeRoots = _chunkFENLKXMBjs.getThemeRoots; exports.getUserRoot = _chunkFENLKXMBjs.getUserRoot; exports.isPath = _chunkFENLKXMBjs.isPath; exports.parser = _chunkFENLKXMBjs.parser; exports.resolveOptions = _chunkFENLKXMBjs.resolveOptions;
39
+ exports.ViteSlidevPlugin = _chunkHHR7Q56Zjs.ViteSlidevPlugin; exports.createServer = _chunk35GWFKPPjs.createServer; exports.createWindiCSSPlugin = _chunkHHR7Q56Zjs.createWindiCSSPlugin; exports.getAddonRoots = _chunk35GWFKPPjs.getAddonRoots; exports.getCLIRoot = _chunk35GWFKPPjs.getCLIRoot; exports.getClientRoot = _chunk35GWFKPPjs.getClientRoot; exports.getRoot = _chunk35GWFKPPjs.getRoot; exports.getThemeRoots = _chunk35GWFKPPjs.getThemeRoots; exports.getUserRoot = _chunk35GWFKPPjs.getUserRoot; exports.isPath = _chunk35GWFKPPjs.isPath; exports.parser = _chunk35GWFKPPjs.parser; exports.resolveOptions = _chunk35GWFKPPjs.resolveOptions;
package/dist/index.mjs CHANGED
@@ -9,11 +9,11 @@ import {
9
9
  isPath,
10
10
  parser,
11
11
  resolveOptions
12
- } from "./chunk-RWZQGJHC.mjs";
12
+ } from "./chunk-5HOW7RNS.mjs";
13
13
  import {
14
14
  ViteSlidevPlugin,
15
15
  createWindiCSSPlugin
16
- } from "./chunk-MDHB5JSE.mjs";
16
+ } from "./chunk-NOJBQ6MT.mjs";
17
17
  import {
18
18
  init_esm_shims
19
19
  } from "./chunk-T5WFA52O.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
- "version": "0.38.5",
3
+ "version": "0.38.7",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@antfu/utils": "^0.7.2",
46
- "@hedgedoc/markdown-it-task-lists": "^2.0.1",
46
+ "@hedgedoc/markdown-it-plugins": "^2.0.0",
47
47
  "@iconify-json/carbon": "^1.1.14",
48
48
  "@iconify-json/ph": "^1.1.3",
49
49
  "@lillallol/outline-pdf": "^4.0.0",
@@ -90,9 +90,9 @@
90
90
  "vue": "^3.2.45",
91
91
  "windicss": "^3.5.6",
92
92
  "yargs": "^17.6.2",
93
- "@slidev/client": "0.38.5",
94
- "@slidev/parser": "0.38.5",
95
- "@slidev/types": "0.38.5"
93
+ "@slidev/client": "0.38.7",
94
+ "@slidev/parser": "0.38.7",
95
+ "@slidev/types": "0.38.7"
96
96
  },
97
97
  "devDependencies": {
98
98
  "@types/plantuml-encoder": "^1.4.0",