@slidev/cli 0.36.11 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import {
2
2
  ViteSlidevPlugin,
3
3
  getIndexHtml,
4
4
  mergeViteConfigs
5
- } from "./chunk-UZJHUT3S.mjs";
5
+ } from "./chunk-ZONFWCC6.mjs";
6
6
  import {
7
7
  __require,
8
8
  __toESM,
@@ -725,7 +725,7 @@ async function build(options, viteConfig = {}) {
725
725
  await fs2.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
726
726
  `, "utf-8");
727
727
  if ([true, "true", "auto"].includes(options.data.config.download)) {
728
- const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-2HDTZ4BF.mjs")));
728
+ const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-Q5J3CD5U.mjs")));
729
729
  const port = 12445;
730
730
  const app = connect();
731
731
  const server = http.createServer(app);
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk5LIGFQWWjs = require('./chunk-5LIGFQWW.js');
5
+ var _chunk4KNSRSYAjs = require('./chunk-4KNSRSYA.js');
6
6
 
7
7
 
8
8
 
@@ -655,16 +655,16 @@ 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 _chunk5LIGFQWWjs.getIndexHtml.call(void 0, options), "utf-8");
658
+ await _fsextra2.default.writeFile(indexPath, await _chunk4KNSRSYAjs.getIndexHtml.call(void 0, options), "utf-8");
659
659
  let config = void 0;
660
660
  try {
661
- const inlineConfig = await _chunk5LIGFQWWjs.mergeViteConfigs.call(void 0,
661
+ const inlineConfig = await _chunk4KNSRSYAjs.mergeViteConfigs.call(void 0,
662
662
  options,
663
663
  viteConfig,
664
664
  {
665
665
  root: options.userRoot,
666
666
  plugins: [
667
- await _chunk5LIGFQWWjs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
667
+ await _chunk4KNSRSYAjs.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 _chunk5LIGFQWWjs.mergeViteConfigs.call(void 0,
688
+ await _chunk4KNSRSYAjs.mergeViteConfigs.call(void 0,
689
689
  options,
690
690
  inlineConfig,
691
691
  {
@@ -725,7 +725,7 @@ async function build(options, viteConfig = {}) {
725
725
  await _fsextra2.default.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
726
726
  `, "utf-8");
727
727
  if ([true, "true", "auto"].includes(options.data.config.download)) {
728
- const { exportSlides } = await Promise.resolve().then(() => _chunkN6L4BUFDjs.__toESM.call(void 0, _chunkN6L4BUFDjs.__require.call(void 0, "./export-YW4ZBY3A.js")));
728
+ const { exportSlides } = await Promise.resolve().then(() => _chunkN6L4BUFDjs.__toESM.call(void 0, _chunkN6L4BUFDjs.__require.call(void 0, "./export-6T6GAVB2.js")));
729
729
  const port = 12445;
730
730
  const app = _connect2.default.call(void 0, );
731
731
  const server = _http2.default.createServer(app);
@@ -62,7 +62,7 @@ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
62
62
  var _path = require('path');
63
63
  var _utils = require('@antfu/utils');
64
64
  var _vite = require('vite');
65
- async function getIndexHtml({ clientRoot, themeRoots, data, userRoot }) {
65
+ async function getIndexHtml({ clientRoot, themeRoots, addonRoots, data, userRoot }) {
66
66
  var _a, _b;
67
67
  let main = await _fs.promises.readFile(_path.join.call(void 0, clientRoot, "index.html"), "utf-8");
68
68
  let head = "";
@@ -70,6 +70,7 @@ async function getIndexHtml({ clientRoot, themeRoots, data, userRoot }) {
70
70
  head += `<link rel="icon" href="${data.config.favicon}">`;
71
71
  const roots = _utils.uniq.call(void 0, [
72
72
  ...themeRoots,
73
+ ...addonRoots,
73
74
  userRoot
74
75
  ]);
75
76
  for (const root of roots) {
@@ -110,19 +111,12 @@ async function mergeViteConfigs({ addonRoots, themeRoots }, viteConfig, config,
110
111
  return _vite.mergeConfig.call(void 0, viteConfig, config);
111
112
  }
112
113
 
113
- // node/plugins/windicss.ts
114
- _chunkN6L4BUFDjs.init_cjs_shims.call(void 0, );
115
-
116
-
117
-
118
- var _jiti = require('jiti'); var _jiti2 = _interopRequireDefault(_jiti);
119
-
120
114
  // node/plugins/setupNode.ts
121
115
  _chunkN6L4BUFDjs.init_cjs_shims.call(void 0, );
122
116
 
123
117
  var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
124
118
 
125
-
119
+ var _jiti = require('jiti'); var _jiti2 = _interopRequireDefault(_jiti);
126
120
  function deepMerge(a, b, rootPath = "") {
127
121
  a = { ...a };
128
122
  Object.keys(b).forEach((key) => {
@@ -135,15 +129,15 @@ function deepMerge(a, b, rootPath = "") {
135
129
  });
136
130
  return a;
137
131
  }
138
- async function loadSetups(roots, name, arg, initial, merge = true) {
132
+ async function loadSetups(roots, name, arg, initial, merge = true, accumulate = void 0) {
139
133
  let returns = initial;
140
134
  for (const root of roots) {
141
135
  const path = _path.resolve.call(void 0, root, "setup", name);
142
- if (_fsextra.existsSync.call(void 0, path)) {
136
+ if (await _fsextra.pathExists.call(void 0, path)) {
143
137
  const { default: setup } = _jiti2.default.call(void 0, __filename)(path);
144
138
  const result = await setup(arg);
145
139
  if (result !== null) {
146
- returns = merge ? deepMerge(returns, result) : result;
140
+ returns = merge ? deepMerge(returns, result) : accumulate ? accumulate(returns, result) : result;
147
141
  }
148
142
  }
149
143
  }
@@ -151,6 +145,11 @@ async function loadSetups(roots, name, arg, initial, merge = true) {
151
145
  }
152
146
 
153
147
  // node/plugins/windicss.ts
148
+ _chunkN6L4BUFDjs.init_cjs_shims.call(void 0, );
149
+
150
+
151
+
152
+
154
153
  async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRoot, roots, data }, { windicss: windiOptions }) {
155
154
  const { default: WindiCSS, defaultConfigureFiles } = await Promise.resolve().then(() => _chunkN6L4BUFDjs.__toESM.call(void 0, _chunkN6L4BUFDjs.__require.call(void 0, "vite-plugin-windicss")));
156
155
  const configFiles = _utils.uniq.call(void 0, [
@@ -1689,4 +1688,5 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
1689
1688
 
1690
1689
 
1691
1690
 
1692
- exports.getIndexHtml = getIndexHtml; exports.mergeViteConfigs = mergeViteConfigs; exports.require_fast_deep_equal = require_fast_deep_equal; exports.createWindiCSSPlugin = createWindiCSSPlugin; exports.ViteSlidevPlugin = ViteSlidevPlugin;
1691
+
1692
+ exports.getIndexHtml = getIndexHtml; exports.mergeViteConfigs = mergeViteConfigs; exports.require_fast_deep_equal = require_fast_deep_equal; exports.loadSetups = loadSetups; exports.createWindiCSSPlugin = createWindiCSSPlugin; exports.ViteSlidevPlugin = ViteSlidevPlugin;
@@ -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 _chunk5LIGFQWWjs = require('./chunk-5LIGFQWW.js');
4
+ var _chunk4KNSRSYAjs = require('./chunk-4KNSRSYA.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 _chunk5LIGFQWWjs.mergeViteConfigs.call(void 0,
2429
+ await _chunk4KNSRSYAjs.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 _chunk5LIGFQWWjs.ViteSlidevPlugin.call(void 0, options, pluginOptions, serverOptions)
2439
+ await _chunk4KNSRSYAjs.ViteSlidevPlugin.call(void 0, options, pluginOptions, serverOptions)
2440
2440
  ]
2441
2441
  },
2442
2442
  "serve"
@@ -2450,7 +2450,7 @@ _chunkN6L4BUFDjs.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.36.11";
2453
+ var version = "0.37.1";
2454
2454
 
2455
2455
  // node/themes.ts
2456
2456
  _chunkN6L4BUFDjs.init_cjs_shims.call(void 0, );
@@ -10297,7 +10297,7 @@ async function resolveOptions(options, mode2, promptForInstallation = true) {
10297
10297
  const themeRoots = getThemeRoots(theme, entry);
10298
10298
  const addons = await getAddons(userRoot, data.config);
10299
10299
  const addonRoots = getAddonRoots(addons, entry);
10300
- const roots = _utils.uniq.call(void 0, [clientRoot, ...themeRoots, userRoot]);
10300
+ const roots = _utils.uniq.call(void 0, [clientRoot, ...themeRoots, ...addonRoots, userRoot]);
10301
10301
  if (themeRoots.length) {
10302
10302
  const themeMeta = await getThemeMeta(theme, _path.join.call(void 0, themeRoots[0], "package.json"));
10303
10303
  data.themeMeta = themeMeta;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ViteSlidevPlugin,
3
3
  mergeViteConfigs
4
- } from "./chunk-UZJHUT3S.mjs";
4
+ } from "./chunk-ZONFWCC6.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.36.11";
2454
+ var version = "0.37.1";
2455
2455
 
2456
2456
  // node/themes.ts
2457
2457
  init_esm_shims();
@@ -10289,7 +10289,7 @@ async function resolveOptions(options, mode2, promptForInstallation = true) {
10289
10289
  const themeRoots = getThemeRoots(theme, entry);
10290
10290
  const addons = await getAddons(userRoot, data.config);
10291
10291
  const addonRoots = getAddonRoots(addons, entry);
10292
- const roots = uniq([clientRoot, ...themeRoots, userRoot]);
10292
+ const roots = uniq([clientRoot, ...themeRoots, ...addonRoots, userRoot]);
10293
10293
  if (themeRoots.length) {
10294
10294
  const themeMeta = await getThemeMeta(theme, join2(themeRoots[0], "package.json"));
10295
10295
  data.themeMeta = themeMeta;
@@ -63,7 +63,7 @@ import { existsSync, promises as fs } from "fs";
63
63
  import { join } from "path";
64
64
  import { uniq } from "@antfu/utils";
65
65
  import { loadConfigFromFile, mergeConfig } from "vite";
66
- async function getIndexHtml({ clientRoot, themeRoots, data, userRoot }) {
66
+ async function getIndexHtml({ clientRoot, themeRoots, addonRoots, data, userRoot }) {
67
67
  var _a, _b;
68
68
  let main = await fs.readFile(join(clientRoot, "index.html"), "utf-8");
69
69
  let head = "";
@@ -71,6 +71,7 @@ async function getIndexHtml({ clientRoot, themeRoots, data, userRoot }) {
71
71
  head += `<link rel="icon" href="${data.config.favicon}">`;
72
72
  const roots = uniq([
73
73
  ...themeRoots,
74
+ ...addonRoots,
74
75
  userRoot
75
76
  ]);
76
77
  for (const root of roots) {
@@ -111,17 +112,10 @@ async function mergeViteConfigs({ addonRoots, themeRoots }, viteConfig, config,
111
112
  return mergeConfig(viteConfig, config);
112
113
  }
113
114
 
114
- // node/plugins/windicss.ts
115
- init_esm_shims();
116
- import { dirname, resolve as resolve2 } from "path";
117
- import { existsSync as existsSync3 } from "fs";
118
- import { slash, uniq as uniq2 } from "@antfu/utils";
119
- import jiti2 from "jiti";
120
-
121
115
  // node/plugins/setupNode.ts
122
116
  init_esm_shims();
123
117
  import { resolve } from "path";
124
- import { existsSync as existsSync2 } from "fs-extra";
118
+ import { pathExists } from "fs-extra";
125
119
  import { isObject } from "@antfu/utils";
126
120
  import jiti from "jiti";
127
121
  function deepMerge(a, b, rootPath = "") {
@@ -136,15 +130,15 @@ function deepMerge(a, b, rootPath = "") {
136
130
  });
137
131
  return a;
138
132
  }
139
- async function loadSetups(roots, name, arg, initial, merge = true) {
133
+ async function loadSetups(roots, name, arg, initial, merge = true, accumulate = void 0) {
140
134
  let returns = initial;
141
135
  for (const root of roots) {
142
136
  const path = resolve(root, "setup", name);
143
- if (existsSync2(path)) {
137
+ if (await pathExists(path)) {
144
138
  const { default: setup } = jiti(__filename)(path);
145
139
  const result = await setup(arg);
146
140
  if (result !== null) {
147
- returns = merge ? deepMerge(returns, result) : result;
141
+ returns = merge ? deepMerge(returns, result) : accumulate ? accumulate(returns, result) : result;
148
142
  }
149
143
  }
150
144
  }
@@ -152,6 +146,11 @@ async function loadSetups(roots, name, arg, initial, merge = true) {
152
146
  }
153
147
 
154
148
  // node/plugins/windicss.ts
149
+ init_esm_shims();
150
+ import { dirname, resolve as resolve2 } from "path";
151
+ import { existsSync as existsSync2 } from "fs";
152
+ import { slash, uniq as uniq2 } from "@antfu/utils";
153
+ import jiti2 from "jiti";
155
154
  async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRoot, roots, data }, { windicss: windiOptions }) {
156
155
  const { default: WindiCSS, defaultConfigureFiles } = await Promise.resolve().then(() => __toESM(__require("vite-plugin-windicss")));
157
156
  const configFiles = uniq2([
@@ -160,7 +159,7 @@ async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRo
160
159
  ...addonRoots.map((i) => `${i}/windi.config.ts`),
161
160
  resolve2(clientRoot, "windi.config.ts")
162
161
  ]);
163
- const configFile = configFiles.find((i) => existsSync3(i));
162
+ const configFile = configFiles.find((i) => existsSync2(i));
164
163
  let config = jiti2(__filename)(configFile);
165
164
  if (config.default)
166
165
  config = config.default;
@@ -448,7 +447,7 @@ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
448
447
  import { basename as basename2, join as join5 } from "path";
449
448
  import { isString, notNullish, objectMap, range, slash as slash2, uniq as uniq4 } from "@antfu/utils";
450
449
  import fg2 from "fast-glob";
451
- import fs4, { existsSync as existsSync4 } from "fs-extra";
450
+ import fs4, { existsSync as existsSync3 } from "fs-extra";
452
451
  import Markdown from "markdown-it";
453
452
  import mila from "markdown-it-link-attributes";
454
453
  import * as parser from "@slidev/parser/fs";
@@ -831,7 +830,7 @@ defineProps<{ no: number | string }>()`);
831
830
  join5(root, "style.css")
832
831
  ];
833
832
  for (const style of styles) {
834
- if (existsSync4(style)) {
833
+ if (existsSync3(style)) {
835
834
  imports.push(`import "${toAtFS(style)}"`);
836
835
  continue;
837
836
  }
@@ -1006,7 +1005,7 @@ function createMonacoTypesLoader() {
1006
1005
 
1007
1006
  // node/plugins/setupClient.ts
1008
1007
  init_esm_shims();
1009
- import { existsSync as existsSync5 } from "fs";
1008
+ import { existsSync as existsSync4 } from "fs";
1010
1009
  import { join as join7, resolve as resolve4 } from "path";
1011
1010
  import { slash as slash4, uniq as uniq5 } from "@antfu/utils";
1012
1011
  function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot }) {
@@ -1029,7 +1028,7 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
1029
1028
  userRoot
1030
1029
  ]).map((i) => join7(i, "setup", name));
1031
1030
  setups.forEach((path, idx) => {
1032
- if (!existsSync5(path))
1031
+ if (!existsSync4(path))
1033
1032
  return;
1034
1033
  imports.push(`import __n${idx} from '${toAtFS(path)}'`);
1035
1034
  let fn = `:AWAIT:__n${idx}`;
@@ -1525,7 +1524,7 @@ function createFixPlugins(options) {
1525
1524
  // node/plugins/unocss.ts
1526
1525
  init_esm_shims();
1527
1526
  import { resolve as resolve5 } from "path";
1528
- import { existsSync as existsSync6 } from "fs";
1527
+ import { existsSync as existsSync5 } from "fs";
1529
1528
  import { deepMerge as deepMerge2, uniq as uniq6 } from "@antfu/utils";
1530
1529
  import jiti3 from "jiti";
1531
1530
  async function createUnocssPlugin({ themeRoots, addonRoots, clientRoot, roots, data }, { unocss: unoOptions }) {
@@ -1536,7 +1535,7 @@ async function createUnocssPlugin({ themeRoots, addonRoots, clientRoot, roots, d
1536
1535
  ...addonRoots.map((i) => `${i}/uno.config.ts`),
1537
1536
  resolve5(clientRoot, "uno.config.ts")
1538
1537
  ]);
1539
- const configFile = configFiles.find((i) => existsSync6(i));
1538
+ const configFile = configFiles.find((i) => existsSync5(i));
1540
1539
  let config = jiti3(__filename)(configFile);
1541
1540
  if ("default" in config)
1542
1541
  config = config.default;
@@ -1688,6 +1687,7 @@ export {
1688
1687
  getIndexHtml,
1689
1688
  mergeViteConfigs,
1690
1689
  require_fast_deep_equal,
1690
+ loadSetups,
1691
1691
  createWindiCSSPlugin,
1692
1692
  ViteSlidevPlugin
1693
1693
  };
package/dist/cli.js CHANGED
@@ -6,10 +6,14 @@
6
6
 
7
7
 
8
8
 
9
- var _chunkC4IMTHZNjs = require('./chunk-C4IMTHZN.js');
10
9
 
11
10
 
12
- var _chunk5LIGFQWWjs = require('./chunk-5LIGFQWW.js');
11
+
12
+ var _chunkORMJVCP4js = require('./chunk-ORMJVCP4.js');
13
+
14
+
15
+
16
+ var _chunk4KNSRSYAjs = require('./chunk-4KNSRSYA.js');
13
17
 
14
18
 
15
19
 
@@ -18,7 +22,7 @@ var _chunkN6L4BUFDjs = require('./chunk-N6L4BUFD.js');
18
22
 
19
23
  // node/cli.ts
20
24
  _chunkN6L4BUFDjs.init_cjs_shims.call(void 0, );
21
- var import_fast_deep_equal = _chunkN6L4BUFDjs.__toESM.call(void 0, _chunk5LIGFQWWjs.require_fast_deep_equal.call(void 0, ));
25
+ var import_fast_deep_equal = _chunkN6L4BUFDjs.__toESM.call(void 0, _chunk4KNSRSYAjs.require_fast_deep_equal.call(void 0, ));
22
26
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
23
27
  var _net = require('net'); var _net2 = _interopRequireDefault(_net);
24
28
  var _os = require('os'); var _os2 = _interopRequireDefault(_os);
@@ -31,6 +35,7 @@ var _prompts = require('prompts'); var _prompts2 = _interopRequireDefault(_promp
31
35
  var _kolorist = require('kolorist');
32
36
  var _isinstalledglobally = require('is-installed-globally'); var _isinstalledglobally2 = _interopRequireDefault(_isinstalledglobally);
33
37
  var _parser = require('@slidev/parser');
38
+ var _fs = require('@slidev/parser/fs');
34
39
  var CONFIG_RESTART_FIELDS = [
35
40
  "highlighter",
36
41
  "monaco",
@@ -38,7 +43,16 @@ var CONFIG_RESTART_FIELDS = [
38
43
  "fonts",
39
44
  "css"
40
45
  ];
41
- var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunkC4IMTHZNjs.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
46
+ _fs.injectPreparserExtensionLoader.call(void 0, async (addons, filepath) => {
47
+ const roots = [
48
+ _chunkORMJVCP4js.getUserRoot.call(void 0, {}).userRoot,
49
+ ..._chunkORMJVCP4js.getAddonRoots.call(void 0, addons, ""),
50
+ _chunkORMJVCP4js.getClientRoot.call(void 0, )
51
+ ];
52
+ const mergeArrays = (a, b) => a.concat(b);
53
+ return await _chunk4KNSRSYAjs.loadSetups.call(void 0, roots, "preparser.ts", filepath, [], false, mergeArrays);
54
+ });
55
+ var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunkORMJVCP4js.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
42
56
  cli.command(
43
57
  "* [entry]",
44
58
  "Start a local server for Slidev",
@@ -89,9 +103,9 @@ cli.command(
89
103
  async function initServer() {
90
104
  if (server)
91
105
  await server.close();
92
- const options = await _chunkC4IMTHZNjs.resolveOptions.call(void 0, { entry, remote, theme, inspect }, "dev");
106
+ const options = await _chunkORMJVCP4js.resolveOptions.call(void 0, { entry, remote, theme, inspect }, "dev");
93
107
  port = userPort || await findFreePort(3030);
94
- server = await _chunkC4IMTHZNjs.createServer.call(void 0,
108
+ server = await _chunkORMJVCP4js.createServer.call(void 0,
95
109
  options,
96
110
  {
97
111
  server: {
@@ -105,7 +119,7 @@ cli.command(
105
119
  },
106
120
  {
107
121
  onDataReload(newData, data) {
108
- if (!theme && _chunkC4IMTHZNjs.resolveThemeName.call(void 0, newData.config.theme) !== _chunkC4IMTHZNjs.resolveThemeName.call(void 0, data.config.theme)) {
122
+ if (!theme && _chunkORMJVCP4js.resolveThemeName.call(void 0, newData.config.theme) !== _chunkORMJVCP4js.resolveThemeName.call(void 0, data.config.theme)) {
109
123
  console.log(_kolorist.yellow.call(void 0, "\n restarting on theme change\n"));
110
124
  initServer();
111
125
  } else if (CONFIG_RESTART_FIELDS.some((i) => !(0, import_fast_deep_equal.default)(newData.config[i], data.config[i]))) {
@@ -191,8 +205,8 @@ cli.command(
191
205
  describe: "enable the inspect plugin for debugging"
192
206
  }).strict().help(),
193
207
  async ({ entry, theme, watch, base, download, out, inspect }) => {
194
- const { build } = await Promise.resolve().then(() => _chunkN6L4BUFDjs.__toESM.call(void 0, _chunkN6L4BUFDjs.__require.call(void 0, "./build-JVW2OZQD.js")));
195
- const options = await _chunkC4IMTHZNjs.resolveOptions.call(void 0, { entry, theme, inspect }, "build");
208
+ const { build } = await Promise.resolve().then(() => _chunkN6L4BUFDjs.__toESM.call(void 0, _chunkN6L4BUFDjs.__require.call(void 0, "./build-VHSIFE6E.js")));
209
+ const options = await _chunkORMJVCP4js.resolveOptions.call(void 0, { entry, theme, inspect }, "build");
196
210
  if (download && !options.data.config.download)
197
211
  options.data.config.download = download;
198
212
  printInfo(options);
@@ -210,9 +224,9 @@ cli.command(
210
224
  "Format the markdown file",
211
225
  (args) => commonOptions(args).strict().help(),
212
226
  async ({ entry }) => {
213
- const data = await _chunkC4IMTHZNjs.parser.load(entry);
214
- _chunkC4IMTHZNjs.parser.prettify(data);
215
- await _chunkC4IMTHZNjs.parser.save(data);
227
+ const data = await _chunkORMJVCP4js.parser.load(entry);
228
+ _chunkORMJVCP4js.parser.prettify(data);
229
+ await _chunkORMJVCP4js.parser.save(data);
216
230
  }
217
231
  );
218
232
  cli.command(
@@ -227,19 +241,19 @@ cli.command(
227
241
  default: "theme"
228
242
  }),
229
243
  async ({ entry, dir, theme: themeInput }) => {
230
- const data = await _chunkC4IMTHZNjs.parser.load(entry);
231
- const theme = _chunkC4IMTHZNjs.resolveThemeName.call(void 0, themeInput || data.config.theme);
244
+ const data = await _chunkORMJVCP4js.parser.load(entry);
245
+ const theme = _chunkORMJVCP4js.resolveThemeName.call(void 0, themeInput || data.config.theme);
232
246
  if (theme === "none") {
233
- console.error('Can not eject theme "none"');
247
+ console.error('Cannot eject theme "none"');
234
248
  process.exit(1);
235
249
  }
236
- if (_chunkC4IMTHZNjs.isPath.call(void 0, theme)) {
250
+ if (_chunkORMJVCP4js.isPath.call(void 0, theme)) {
237
251
  console.error("Theme is already ejected");
238
252
  process.exit(1);
239
253
  }
240
- const roots = _chunkC4IMTHZNjs.getThemeRoots.call(void 0, theme, entry);
254
+ const roots = _chunkORMJVCP4js.getThemeRoots.call(void 0, theme, entry);
241
255
  if (!roots.length) {
242
- console.error(`Does not found theme "${theme}"`);
256
+ console.error(`Could not find theme "${theme}"`);
243
257
  process.exit(1);
244
258
  }
245
259
  const root = roots[0];
@@ -249,7 +263,7 @@ cli.command(
249
263
  const dirPath = `./${dir}`;
250
264
  data.slides[0].frontmatter.theme = dirPath;
251
265
  data.slides[0].raw = null;
252
- await _chunkC4IMTHZNjs.parser.save(data);
266
+ await _chunkORMJVCP4js.parser.save(data);
253
267
  console.log(`Theme "${theme}" ejected successfully to "${dirPath}"`);
254
268
  }
255
269
  );
@@ -307,11 +321,11 @@ cli.command(
307
321
  "with-toc": withTOC
308
322
  }) => {
309
323
  process.env.NODE_ENV = "production";
310
- const { exportSlides } = await Promise.resolve().then(() => _chunkN6L4BUFDjs.__toESM.call(void 0, _chunkN6L4BUFDjs.__require.call(void 0, "./export-YW4ZBY3A.js")));
324
+ const { exportSlides } = await Promise.resolve().then(() => _chunkN6L4BUFDjs.__toESM.call(void 0, _chunkN6L4BUFDjs.__require.call(void 0, "./export-6T6GAVB2.js")));
311
325
  const port = await findFreePort(12445);
312
- const options = await _chunkC4IMTHZNjs.resolveOptions.call(void 0, { entry, theme }, "build");
326
+ const options = await _chunkORMJVCP4js.resolveOptions.call(void 0, { entry, theme }, "build");
313
327
  output = output || options.data.config.exportFilename || `${_path2.default.basename(entry, ".md")}-export`;
314
- const server = await _chunkC4IMTHZNjs.createServer.call(void 0,
328
+ const server = await _chunkORMJVCP4js.createServer.call(void 0,
315
329
  options,
316
330
  {
317
331
  server: { port },
@@ -320,7 +334,7 @@ cli.command(
320
334
  );
321
335
  await server.listen(port);
322
336
  printInfo(options);
323
- _chunkC4IMTHZNjs.parser.filterDisabled(options.data);
337
+ _chunkORMJVCP4js.parser.filterDisabled(options.data);
324
338
  const width = options.data.config.canvasWidth;
325
339
  const height = Math.round(width / options.data.config.aspectRatio);
326
340
  output = await exportSlides({
@@ -361,12 +375,12 @@ cli.command(
361
375
  output
362
376
  }) => {
363
377
  process.env.NODE_ENV = "production";
364
- const { exportNotes } = await Promise.resolve().then(() => _chunkN6L4BUFDjs.__toESM.call(void 0, _chunkN6L4BUFDjs.__require.call(void 0, "./export-YW4ZBY3A.js")));
378
+ const { exportNotes } = await Promise.resolve().then(() => _chunkN6L4BUFDjs.__toESM.call(void 0, _chunkN6L4BUFDjs.__require.call(void 0, "./export-6T6GAVB2.js")));
365
379
  const port = await findFreePort(12445);
366
- const options = await _chunkC4IMTHZNjs.resolveOptions.call(void 0, { entry }, "build");
380
+ const options = await _chunkORMJVCP4js.resolveOptions.call(void 0, { entry }, "build");
367
381
  if (!output)
368
382
  output = options.data.config.exportFilename ? `${options.data.config.exportFilename}-notes` : `${_path2.default.basename(entry, ".md")}-export-notes`;
369
- const server = await _chunkC4IMTHZNjs.createServer.call(void 0,
383
+ const server = await _chunkORMJVCP4js.createServer.call(void 0,
370
384
  options,
371
385
  {
372
386
  server: { port },
@@ -375,7 +389,7 @@ cli.command(
375
389
  );
376
390
  await server.listen(port);
377
391
  printInfo(options);
378
- _chunkC4IMTHZNjs.parser.filterDisabled(options.data);
392
+ _chunkORMJVCP4js.parser.filterDisabled(options.data);
379
393
  output = await exportNotes({
380
394
  port,
381
395
  output
@@ -402,7 +416,7 @@ function printInfo(options, port, remote) {
402
416
  console.log();
403
417
  console.log();
404
418
  console.log(` ${_kolorist.cyan.call(void 0, "\u25CF") + _kolorist.blue.call(void 0, "\u25A0") + _kolorist.yellow.call(void 0, "\u25B2")}`);
405
- console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunkC4IMTHZNjs.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
419
+ console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunkORMJVCP4js.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
406
420
  console.log();
407
421
  console.log(_kolorist.dim.call(void 0, " theme ") + (options.theme ? _kolorist.green.call(void 0, options.theme) : _kolorist.gray.call(void 0, "none")));
408
422
  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,15 +1,19 @@
1
1
  import {
2
2
  createServer,
3
+ getAddonRoots,
4
+ getClientRoot,
3
5
  getThemeRoots,
6
+ getUserRoot,
4
7
  isPath,
5
8
  parser,
6
9
  resolveOptions,
7
10
  resolveThemeName,
8
11
  version
9
- } from "./chunk-6HNIQLKX.mjs";
12
+ } from "./chunk-XRKGEREL.mjs";
10
13
  import {
14
+ loadSetups,
11
15
  require_fast_deep_equal
12
- } from "./chunk-UZJHUT3S.mjs";
16
+ } from "./chunk-ZONFWCC6.mjs";
13
17
  import {
14
18
  __dirname,
15
19
  __require,
@@ -32,6 +36,7 @@ import prompts from "prompts";
32
36
  import { blue, bold, cyan, dim, gray, green, underline, yellow } from "kolorist";
33
37
  import isInstalledGlobally from "is-installed-globally";
34
38
  import { verifyConfig } from "@slidev/parser";
39
+ import { injectPreparserExtensionLoader } from "@slidev/parser/fs";
35
40
  var CONFIG_RESTART_FIELDS = [
36
41
  "highlighter",
37
42
  "monaco",
@@ -39,6 +44,15 @@ var CONFIG_RESTART_FIELDS = [
39
44
  "fonts",
40
45
  "css"
41
46
  ];
47
+ injectPreparserExtensionLoader(async (addons, filepath) => {
48
+ const roots = [
49
+ getUserRoot({}).userRoot,
50
+ ...getAddonRoots(addons, ""),
51
+ getClientRoot()
52
+ ];
53
+ const mergeArrays = (a, b) => a.concat(b);
54
+ return await loadSetups(roots, "preparser.ts", filepath, [], false, mergeArrays);
55
+ });
42
56
  var cli = yargs.scriptName("slidev").usage("$0 [args]").version(version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
43
57
  cli.command(
44
58
  "* [entry]",
@@ -192,7 +206,7 @@ cli.command(
192
206
  describe: "enable the inspect plugin for debugging"
193
207
  }).strict().help(),
194
208
  async ({ entry, theme, watch, base, download, out, inspect }) => {
195
- const { build } = await Promise.resolve().then(() => __toESM(__require("./build-GWSX3VJC.mjs")));
209
+ const { build } = await Promise.resolve().then(() => __toESM(__require("./build-SWYXOHDR.mjs")));
196
210
  const options = await resolveOptions({ entry, theme, inspect }, "build");
197
211
  if (download && !options.data.config.download)
198
212
  options.data.config.download = download;
@@ -231,7 +245,7 @@ cli.command(
231
245
  const data = await parser.load(entry);
232
246
  const theme = resolveThemeName(themeInput || data.config.theme);
233
247
  if (theme === "none") {
234
- console.error('Can not eject theme "none"');
248
+ console.error('Cannot eject theme "none"');
235
249
  process.exit(1);
236
250
  }
237
251
  if (isPath(theme)) {
@@ -240,7 +254,7 @@ cli.command(
240
254
  }
241
255
  const roots = getThemeRoots(theme, entry);
242
256
  if (!roots.length) {
243
- console.error(`Does not found theme "${theme}"`);
257
+ console.error(`Could not find theme "${theme}"`);
244
258
  process.exit(1);
245
259
  }
246
260
  const root = roots[0];
@@ -308,7 +322,7 @@ cli.command(
308
322
  "with-toc": withTOC
309
323
  }) => {
310
324
  process.env.NODE_ENV = "production";
311
- const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-2HDTZ4BF.mjs")));
325
+ const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-Q5J3CD5U.mjs")));
312
326
  const port = await findFreePort(12445);
313
327
  const options = await resolveOptions({ entry, theme }, "build");
314
328
  output = output || options.data.config.exportFilename || `${path.basename(entry, ".md")}-export`;
@@ -362,7 +376,7 @@ cli.command(
362
376
  output
363
377
  }) => {
364
378
  process.env.NODE_ENV = "production";
365
- const { exportNotes } = await Promise.resolve().then(() => __toESM(__require("./export-2HDTZ4BF.mjs")));
379
+ const { exportNotes } = await Promise.resolve().then(() => __toESM(__require("./export-Q5J3CD5U.mjs")));
366
380
  const port = await findFreePort(12445);
367
381
  const options = await resolveOptions({ entry }, "build");
368
382
  if (!output)
@@ -14,6 +14,7 @@ var _cliprogress = require('cli-progress');
14
14
  var _core = require('@slidev/parser/core');
15
15
  var _outlinepdf = require('@lillallol/outline-pdf');
16
16
  var _pdflib = require('pdf-lib'); var pdfLib = _interopRequireWildcard(_pdflib);
17
+
17
18
  function addToTree(tree, info, level = 1) {
18
19
  const titleLevel = info.level;
19
20
  if (titleLevel && titleLevel > level && tree.length > 0) {
@@ -157,6 +158,7 @@ async function exportSlides({
157
158
  await Promise.all(frames.map((frame) => frame.waitForLoadState()));
158
159
  }
159
160
  async function genPagePdf() {
161
+ var _a;
160
162
  if (!output.endsWith(".pdf"))
161
163
  output = `${output}.pdf`;
162
164
  await go("print");
@@ -173,18 +175,24 @@ async function exportSlides({
173
175
  printBackground: true,
174
176
  preferCSSPageSize: true
175
177
  });
178
+ let pdfData = await _fsextra2.default.readFile(output);
179
+ let pdf = await _pdflib.PDFDocument.load(pdfData);
180
+ const titleSlide = slides[0];
181
+ if (titleSlide == null ? void 0 : titleSlide.title)
182
+ pdf.setTitle(titleSlide.title);
183
+ if ((_a = titleSlide == null ? void 0 : titleSlide.frontmatter) == null ? void 0 : _a.info)
184
+ pdf.setSubject(titleSlide.frontmatter.info);
176
185
  if (withTOC) {
177
186
  const outlinePdf = _outlinepdf.outlinePdfFactory.call(void 0, pdfLib);
178
- const pdf = _fsextra2.default.readFileSync(output, { encoding: "base64" });
179
187
  const tocTree = slides.filter((slide) => slide.title).reduce((acc, slide) => {
180
188
  addToTree(acc, slide);
181
189
  return acc;
182
190
  }, []);
183
191
  const outline = makeOutline(tocTree);
184
- const outlinedPdfDocument = await outlinePdf({ outline, pdf });
185
- const outlinedPdf = await outlinedPdfDocument.save();
186
- _fsextra2.default.writeFileSync(output, outlinedPdf);
192
+ pdf = await outlinePdf({ outline, pdf });
187
193
  }
194
+ pdfData = Buffer.from(await pdf.save());
195
+ await _fsextra2.default.writeFile(output, pdfData);
188
196
  }
189
197
  async function genPagePng() {
190
198
  await go("print");
@@ -14,6 +14,7 @@ import { Presets, SingleBar } from "cli-progress";
14
14
  import { parseRangeString } from "@slidev/parser/core";
15
15
  import { outlinePdfFactory } from "@lillallol/outline-pdf";
16
16
  import * as pdfLib from "pdf-lib";
17
+ import { PDFDocument } from "pdf-lib";
17
18
  function addToTree(tree, info, level = 1) {
18
19
  const titleLevel = info.level;
19
20
  if (titleLevel && titleLevel > level && tree.length > 0) {
@@ -157,6 +158,7 @@ async function exportSlides({
157
158
  await Promise.all(frames.map((frame) => frame.waitForLoadState()));
158
159
  }
159
160
  async function genPagePdf() {
161
+ var _a;
160
162
  if (!output.endsWith(".pdf"))
161
163
  output = `${output}.pdf`;
162
164
  await go("print");
@@ -173,18 +175,24 @@ async function exportSlides({
173
175
  printBackground: true,
174
176
  preferCSSPageSize: true
175
177
  });
178
+ let pdfData = await fs.readFile(output);
179
+ let pdf = await PDFDocument.load(pdfData);
180
+ const titleSlide = slides[0];
181
+ if (titleSlide == null ? void 0 : titleSlide.title)
182
+ pdf.setTitle(titleSlide.title);
183
+ if ((_a = titleSlide == null ? void 0 : titleSlide.frontmatter) == null ? void 0 : _a.info)
184
+ pdf.setSubject(titleSlide.frontmatter.info);
176
185
  if (withTOC) {
177
186
  const outlinePdf = outlinePdfFactory(pdfLib);
178
- const pdf = fs.readFileSync(output, { encoding: "base64" });
179
187
  const tocTree = slides.filter((slide) => slide.title).reduce((acc, slide) => {
180
188
  addToTree(acc, slide);
181
189
  return acc;
182
190
  }, []);
183
191
  const outline = makeOutline(tocTree);
184
- const outlinedPdfDocument = await outlinePdf({ outline, pdf });
185
- const outlinedPdf = await outlinedPdfDocument.save();
186
- fs.writeFileSync(output, outlinedPdf);
192
+ pdf = await outlinePdf({ outline, pdf });
187
193
  }
194
+ pdfData = Buffer.from(await pdf.save());
195
+ await fs.writeFile(output, pdfData);
188
196
  }
189
197
  async function genPagePng() {
190
198
  await go("print");
package/dist/index.js CHANGED
@@ -9,11 +9,11 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkC4IMTHZNjs = require('./chunk-C4IMTHZN.js');
12
+ var _chunkORMJVCP4js = require('./chunk-ORMJVCP4.js');
13
13
 
14
14
 
15
15
 
16
- var _chunk5LIGFQWWjs = require('./chunk-5LIGFQWW.js');
16
+ var _chunk4KNSRSYAjs = require('./chunk-4KNSRSYA.js');
17
17
 
18
18
 
19
19
  var _chunkN6L4BUFDjs = require('./chunk-N6L4BUFD.js');
@@ -36,4 +36,4 @@ _chunkN6L4BUFDjs.init_cjs_shims.call(void 0, );
36
36
 
37
37
 
38
38
 
39
- exports.ViteSlidevPlugin = _chunk5LIGFQWWjs.ViteSlidevPlugin; exports.createServer = _chunkC4IMTHZNjs.createServer; exports.createWindiCSSPlugin = _chunk5LIGFQWWjs.createWindiCSSPlugin; exports.getAddonRoots = _chunkC4IMTHZNjs.getAddonRoots; exports.getCLIRoot = _chunkC4IMTHZNjs.getCLIRoot; exports.getClientRoot = _chunkC4IMTHZNjs.getClientRoot; exports.getRoot = _chunkC4IMTHZNjs.getRoot; exports.getThemeRoots = _chunkC4IMTHZNjs.getThemeRoots; exports.getUserRoot = _chunkC4IMTHZNjs.getUserRoot; exports.isPath = _chunkC4IMTHZNjs.isPath; exports.parser = _chunkC4IMTHZNjs.parser; exports.resolveOptions = _chunkC4IMTHZNjs.resolveOptions;
39
+ exports.ViteSlidevPlugin = _chunk4KNSRSYAjs.ViteSlidevPlugin; exports.createServer = _chunkORMJVCP4js.createServer; exports.createWindiCSSPlugin = _chunk4KNSRSYAjs.createWindiCSSPlugin; exports.getAddonRoots = _chunkORMJVCP4js.getAddonRoots; exports.getCLIRoot = _chunkORMJVCP4js.getCLIRoot; exports.getClientRoot = _chunkORMJVCP4js.getClientRoot; exports.getRoot = _chunkORMJVCP4js.getRoot; exports.getThemeRoots = _chunkORMJVCP4js.getThemeRoots; exports.getUserRoot = _chunkORMJVCP4js.getUserRoot; exports.isPath = _chunkORMJVCP4js.isPath; exports.parser = _chunkORMJVCP4js.parser; exports.resolveOptions = _chunkORMJVCP4js.resolveOptions;
package/dist/index.mjs CHANGED
@@ -9,11 +9,11 @@ import {
9
9
  isPath,
10
10
  parser,
11
11
  resolveOptions
12
- } from "./chunk-6HNIQLKX.mjs";
12
+ } from "./chunk-XRKGEREL.mjs";
13
13
  import {
14
14
  ViteSlidevPlugin,
15
15
  createWindiCSSPlugin
16
- } from "./chunk-UZJHUT3S.mjs";
16
+ } from "./chunk-ZONFWCC6.mjs";
17
17
  import {
18
18
  init_esm_shims
19
19
  } from "./chunk-XNT34UVI.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
- "version": "0.36.11",
3
+ "version": "0.37.1",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -47,9 +47,9 @@
47
47
  "@iconify-json/carbon": "^1.1.9",
48
48
  "@iconify-json/ph": "^1.1.2",
49
49
  "@lillallol/outline-pdf": "^4.0.0",
50
- "@slidev/client": "0.36.11",
51
- "@slidev/parser": "0.36.11",
52
- "@slidev/types": "0.36.11",
50
+ "@slidev/client": "0.37.1",
51
+ "@slidev/parser": "0.37.1",
52
+ "@slidev/types": "0.37.1",
53
53
  "@vitejs/plugin-vue": "^3.2.0",
54
54
  "cli-progress": "^3.11.2",
55
55
  "codemirror": "^5.65.5",