@slidev/cli 0.32.2 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/slidev.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict'
3
- /* eslint-disable @typescript-eslint/no-var-requires */
3
+
4
4
  const path = require('path')
5
5
  const resolveFrom = require('resolve-from')
6
6
 
@@ -1,16 +1,17 @@
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 _chunkIW3TSLZFjs = require('./chunk-IW3TSLZF.js');
5
4
 
5
+ var _chunkUNBXPUSGjs = require('./chunk-UNBXPUSG.js');
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunkJWGORJY6js = require('./chunk-JWGORJY6.js');
10
+
11
+ var _chunkFFZLS6QKjs = require('./chunk-FFZLS6QK.js');
11
12
 
12
13
  // node/build.ts
13
- _chunkJWGORJY6js.init_cjs_shims.call(void 0, );
14
+ _chunkFFZLS6QKjs.init_cjs_shims.call(void 0, );
14
15
  var _path = require('path');
15
16
  var _http = require('http'); var _http2 = _interopRequireDefault(_http);
16
17
  var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
@@ -18,12 +19,12 @@ var _vite = require('vite');
18
19
  var _connect = require('connect'); var _connect2 = _interopRequireDefault(_connect);
19
20
 
20
21
  // ../../node_modules/.pnpm/sirv@2.0.2/node_modules/sirv/build.mjs
21
- _chunkJWGORJY6js.init_cjs_shims.call(void 0, );
22
+ _chunkFFZLS6QKjs.init_cjs_shims.call(void 0, );
22
23
  var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
23
24
 
24
25
 
25
26
  // ../../node_modules/.pnpm/totalist@3.0.0/node_modules/totalist/sync/index.mjs
26
- _chunkJWGORJY6js.init_cjs_shims.call(void 0, );
27
+ _chunkFFZLS6QKjs.init_cjs_shims.call(void 0, );
27
28
 
28
29
 
29
30
  function totalist(dir, callback, pre = "") {
@@ -38,7 +39,7 @@ function totalist(dir, callback, pre = "") {
38
39
  }
39
40
 
40
41
  // ../../node_modules/.pnpm/@polka+url@1.0.0-next.21/node_modules/@polka/url/build.mjs
41
- _chunkJWGORJY6js.init_cjs_shims.call(void 0, );
42
+ _chunkFFZLS6QKjs.init_cjs_shims.call(void 0, );
42
43
  var _querystring = require('querystring'); var qs = _interopRequireWildcard(_querystring);
43
44
  function parse2(req) {
44
45
  let raw = req.url;
@@ -62,7 +63,7 @@ function parse2(req) {
62
63
  }
63
64
 
64
65
  // ../../node_modules/.pnpm/mrmime@1.0.0/node_modules/mrmime/index.mjs
65
- _chunkJWGORJY6js.init_cjs_shims.call(void 0, );
66
+ _chunkFFZLS6QKjs.init_cjs_shims.call(void 0, );
66
67
  var mimes = {
67
68
  "ez": "application/andrew-inset",
68
69
  "aw": "application/applixware",
@@ -527,7 +528,7 @@ function is404(req, res) {
527
528
  }
528
529
  function send(req, res, file, stats, headers) {
529
530
  let code = 200, tmp, opts = {};
530
- headers = _chunkJWGORJY6js.__spreadValues.call(void 0, {}, headers);
531
+ headers = _chunkFFZLS6QKjs.__spreadValues.call(void 0, {}, headers);
531
532
  for (let key in headers) {
532
533
  tmp = res.getHeader(key);
533
534
  if (tmp)
@@ -655,13 +656,13 @@ async function build(options, viteConfig = {}) {
655
656
  let originalIndexHTML;
656
657
  if (_fsextra2.default.existsSync(indexPath))
657
658
  originalIndexHTML = await _fsextra2.default.readFile(indexPath, "utf-8");
658
- await _fsextra2.default.writeFile(indexPath, await _chunkIW3TSLZFjs.getIndexHtml.call(void 0, options), "utf-8");
659
+ await _fsextra2.default.writeFile(indexPath, await _chunkUNBXPUSGjs.getIndexHtml.call(void 0, options), "utf-8");
659
660
  let config = void 0;
660
661
  try {
661
- const inlineConfig = _vite.mergeConfig.call(void 0, viteConfig, {
662
+ const inlineConfig = await _chunkUNBXPUSGjs.mergeViteConfigs.call(void 0, options, viteConfig, {
662
663
  root: options.userRoot,
663
664
  plugins: [
664
- await _chunkIW3TSLZFjs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
665
+ await _chunkUNBXPUSGjs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
665
666
  {
666
667
  name: "resolve-config",
667
668
  configResolved(_config) {
@@ -672,14 +673,14 @@ async function build(options, viteConfig = {}) {
672
673
  build: {
673
674
  chunkSizeWarningLimit: 2e3
674
675
  }
675
- });
676
+ }, "build");
676
677
  await _vite.build.call(void 0, inlineConfig);
677
678
  if (options.data.features.monaco) {
678
679
  if (options.data.config.monaco === "dev") {
679
680
  console.log(_kolorist.yellow.call(void 0, " Monaco is disabled in the build, to enabled it, set `monaco: true` in the frontmatter"));
680
681
  } else {
681
682
  console.log(_kolorist.blue.call(void 0, " building for Monaco...\n"));
682
- await _vite.build.call(void 0, _vite.mergeConfig.call(void 0, inlineConfig, {
683
+ await _vite.build.call(void 0, await _chunkUNBXPUSGjs.mergeViteConfigs.call(void 0, options, inlineConfig, {
683
684
  root: _path.join.call(void 0, options.clientRoot, "iframes/monaco"),
684
685
  base: `${config.base}iframes/monaco/`,
685
686
  build: {
@@ -696,7 +697,7 @@ async function build(options, viteConfig = {}) {
696
697
  }
697
698
  }
698
699
  }
699
- }));
700
+ }, "build"));
700
701
  }
701
702
  }
702
703
  } finally {
@@ -713,7 +714,7 @@ async function build(options, viteConfig = {}) {
713
714
  await _fsextra2.default.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
714
715
  `, "utf-8");
715
716
  if ([true, "true", "auto"].includes(options.data.config.download)) {
716
- const { exportSlides } = await Promise.resolve().then(() => _chunkJWGORJY6js.__toESM.call(void 0, _chunkJWGORJY6js.__require.call(void 0, "./export-M6HJUIFY.js")));
717
+ const { exportSlides } = await Promise.resolve().then(() => _chunkFFZLS6QKjs.__toESM.call(void 0, _chunkFFZLS6QKjs.__require.call(void 0, "./export-LOKLMK66.js")));
717
718
  const port = 12445;
718
719
  const app = _connect2.default.call(void 0, );
719
720
  const server = _http2.default.createServer(app);
@@ -725,13 +726,14 @@ async function build(options, viteConfig = {}) {
725
726
  server.listen(port);
726
727
  await exportSlides({
727
728
  port,
729
+ slides: options.data.slides,
728
730
  total: options.data.slides.length,
729
731
  format: "pdf",
730
732
  output: _path.join.call(void 0, outDir, outFilename),
731
733
  base: config.base,
732
734
  dark: options.data.config.colorSchema === "dark",
733
- width: 1920,
734
- height: Math.round(1920 / options.data.config.aspectRatio),
735
+ width: options.data.config.canvasWidth,
736
+ height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
735
737
  routerMode: options.data.config.routerMode
736
738
  });
737
739
  server.close();
@@ -1,20 +1,21 @@
1
1
  import {
2
2
  ViteSlidevPlugin,
3
- getIndexHtml
4
- } from "./chunk-WZ6OPJJF.mjs";
3
+ getIndexHtml,
4
+ mergeViteConfigs
5
+ } from "./chunk-C7GPMAIX.mjs";
5
6
  import {
6
7
  __require,
7
8
  __spreadValues,
8
9
  __toESM,
9
10
  init_esm_shims
10
- } from "./chunk-NOFZO6W4.mjs";
11
+ } from "./chunk-ZWCVPYOA.mjs";
11
12
 
12
13
  // node/build.ts
13
14
  init_esm_shims();
14
15
  import { join as join3, resolve as resolve3 } from "path";
15
16
  import http from "http";
16
17
  import fs2 from "fs-extra";
17
- import { mergeConfig, resolveConfig, build as viteBuild } from "vite";
18
+ import { resolveConfig, build as viteBuild } from "vite";
18
19
  import connect from "connect";
19
20
 
20
21
  // ../../node_modules/.pnpm/sirv@2.0.2/node_modules/sirv/build.mjs
@@ -658,7 +659,7 @@ async function build(options, viteConfig = {}) {
658
659
  await fs2.writeFile(indexPath, await getIndexHtml(options), "utf-8");
659
660
  let config = void 0;
660
661
  try {
661
- const inlineConfig = mergeConfig(viteConfig, {
662
+ const inlineConfig = await mergeViteConfigs(options, viteConfig, {
662
663
  root: options.userRoot,
663
664
  plugins: [
664
665
  await ViteSlidevPlugin(options, pluginOptions),
@@ -672,14 +673,14 @@ async function build(options, viteConfig = {}) {
672
673
  build: {
673
674
  chunkSizeWarningLimit: 2e3
674
675
  }
675
- });
676
+ }, "build");
676
677
  await viteBuild(inlineConfig);
677
678
  if (options.data.features.monaco) {
678
679
  if (options.data.config.monaco === "dev") {
679
680
  console.log(yellow(" Monaco is disabled in the build, to enabled it, set `monaco: true` in the frontmatter"));
680
681
  } else {
681
682
  console.log(blue(" building for Monaco...\n"));
682
- await viteBuild(mergeConfig(inlineConfig, {
683
+ await viteBuild(await mergeViteConfigs(options, inlineConfig, {
683
684
  root: join3(options.clientRoot, "iframes/monaco"),
684
685
  base: `${config.base}iframes/monaco/`,
685
686
  build: {
@@ -696,7 +697,7 @@ async function build(options, viteConfig = {}) {
696
697
  }
697
698
  }
698
699
  }
699
- }));
700
+ }, "build"));
700
701
  }
701
702
  }
702
703
  } finally {
@@ -713,7 +714,7 @@ async function build(options, viteConfig = {}) {
713
714
  await fs2.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
714
715
  `, "utf-8");
715
716
  if ([true, "true", "auto"].includes(options.data.config.download)) {
716
- const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-GIPHUNUX.mjs")));
717
+ const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-5R6FV775.mjs")));
717
718
  const port = 12445;
718
719
  const app = connect();
719
720
  const server = http.createServer(app);
@@ -725,13 +726,14 @@ async function build(options, viteConfig = {}) {
725
726
  server.listen(port);
726
727
  await exportSlides({
727
728
  port,
729
+ slides: options.data.slides,
728
730
  total: options.data.slides.length,
729
731
  format: "pdf",
730
732
  output: join3(outDir, outFilename),
731
733
  base: config.base,
732
734
  dark: options.data.config.colorSchema === "dark",
733
- width: 1920,
734
- height: Math.round(1920 / options.data.config.aspectRatio),
735
+ width: options.data.config.canvasWidth,
736
+ height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
735
737
  routerMode: options.data.config.routerMode
736
738
  });
737
739
  server.close();
@@ -11,7 +11,7 @@ import {
11
11
  resolveImportPath,
12
12
  stringifyMarkdownTokens,
13
13
  toAtFS
14
- } from "./chunk-NOFZO6W4.mjs";
14
+ } from "./chunk-ZWCVPYOA.mjs";
15
15
 
16
16
  // ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
17
17
  var require_fast_deep_equal = __commonJS({
@@ -64,6 +64,7 @@ init_esm_shims();
64
64
  import { existsSync, promises as fs } from "fs";
65
65
  import { join } from "path";
66
66
  import { uniq } from "@antfu/utils";
67
+ import { loadConfigFromFile, mergeConfig } from "vite";
67
68
  async function getIndexHtml({ clientRoot, themeRoots, data, userRoot }) {
68
69
  var _a, _b;
69
70
  let main = await fs.readFile(join(clientRoot, "index.html"), "utf-8");
@@ -92,6 +93,25 @@ ${(((_b = index.match(/<body>([\s\S]*?)<\/body>/im)) == null ? void 0 : _b[1]) |
92
93
  main = main.replace("__ENTRY__", toAtFS(join(clientRoot, "main.ts"))).replace("<!-- head -->", head).replace("<!-- body -->", body);
93
94
  return main;
94
95
  }
96
+ async function mergeViteConfigs({ addonRoots, themeRoots }, viteConfig, config, command) {
97
+ const configEnv = {
98
+ mode: "development",
99
+ command
100
+ };
101
+ const files = uniq([
102
+ ...themeRoots,
103
+ ...addonRoots
104
+ ]).map((i) => join(i, "vite.config.ts"));
105
+ for await (const file of files) {
106
+ if (!existsSync(file))
107
+ continue;
108
+ const viteConfig2 = await loadConfigFromFile(configEnv, file);
109
+ if (!(viteConfig2 == null ? void 0 : viteConfig2.config))
110
+ continue;
111
+ config = mergeConfig(config, viteConfig2.config);
112
+ }
113
+ return mergeConfig(viteConfig, config);
114
+ }
95
115
 
96
116
  // node/plugins/windicss.ts
97
117
  init_esm_shims();
@@ -165,12 +185,12 @@ async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRo
165
185
  },
166
186
  onOptionsResolved(config2) {
167
187
  themeRoots.forEach((i) => {
168
- config2.scanOptions.include.push(`${i}/components/*.{vue,ts}`);
169
- config2.scanOptions.include.push(`${i}/layouts/*.{vue,ts}`);
188
+ config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
189
+ config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
170
190
  });
171
191
  addonRoots.forEach((i) => {
172
- config2.scanOptions.include.push(`${i}/components/*.{vue,ts}`);
173
- config2.scanOptions.include.push(`${i}/layouts/*.{vue,ts}`);
192
+ config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
193
+ config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
174
194
  });
175
195
  config2.scanOptions.include.push(`!${slash(resolve2(userRoot, "node_modules"))}`);
176
196
  config2.scanOptions.exclude.push(dirname(resolveImportPath("monaco-editor/package.json", true)));
@@ -239,7 +259,7 @@ ${value}
239
259
  // node/plugins/extendConfig.ts
240
260
  init_esm_shims();
241
261
  import { dirname as dirname4, join as join4 } from "path";
242
- import { mergeConfig } from "vite";
262
+ import { mergeConfig as mergeConfig2 } from "vite";
243
263
  import isInstalledGlobally from "is-installed-globally";
244
264
  import { uniq as uniq3 } from "@antfu/utils";
245
265
 
@@ -248,10 +268,10 @@ var dependencies = {
248
268
  "@antfu/utils": "^0.5.2",
249
269
  "@slidev/parser": "workspace:*",
250
270
  "@slidev/types": "workspace:*",
251
- "@vueuse/core": "^8.5.0",
271
+ "@vueuse/core": "^8.6.0",
252
272
  "@vueuse/head": "^0.7.6",
253
273
  "@vueuse/motion": "^2.0.0-beta.18",
254
- codemirror: "^5.65.4",
274
+ codemirror: "^5.65.5",
255
275
  defu: "^6.0.0",
256
276
  drauu: "^0.3.0",
257
277
  "file-saver": "^2.0.5",
@@ -265,9 +285,9 @@ var dependencies = {
265
285
  recordrtc: "^5.6.2",
266
286
  resolve: "^1.22.0",
267
287
  "vite-plugin-windicss": "^1.8.4",
268
- vue: "^3.2.35",
288
+ vue: "^3.2.36",
269
289
  "vue-router": "^4.0.15",
270
- "vue-starport": "^0.2.10",
290
+ "vue-starport": "^0.2.11",
271
291
  windicss: "^3.5.4"
272
292
  };
273
293
 
@@ -370,7 +390,7 @@ function createConfigPlugin(options) {
370
390
  injection.root = options.cliRoot;
371
391
  injection.resolve.alias.vue = `${resolveImportPath("vue/dist/vue.esm-browser.js", true)}`;
372
392
  }
373
- return mergeConfig(config, injection);
393
+ return mergeConfig2(config, injection);
374
394
  },
375
395
  configureServer(server) {
376
396
  return () => {
@@ -734,7 +754,7 @@ defineProps<{ no: number | string }>()`);
734
754
  clientRoot
735
755
  ]);
736
756
  for (const root of roots2) {
737
- const layoutPaths = await fg2("layouts/*.{vue,ts}", {
757
+ const layoutPaths = await fg2("layouts/**/*.{vue,ts}", {
738
758
  cwd: root,
739
759
  absolute: true
740
760
  });
@@ -807,16 +827,11 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
807
827
  return void 0;
808
828
  imports.push(`import n${no} from '${slidePrefix}${idx + 1}.md'`);
809
829
  const additions = {
810
- slide: {
811
- start: i.start,
812
- end: i.end,
813
- note: i.note,
830
+ slide: __spreadProps(__spreadValues({}, prepareSlideInfo(i)), {
814
831
  filepath: ((_b = i.source) == null ? void 0 : _b.filepath) || entry,
815
832
  id: idx,
816
- no,
817
- title: i.title,
818
- level: i.level
819
- },
833
+ no
834
+ }),
820
835
  __clicksElements: [],
821
836
  __preloaded: false
822
837
  };
@@ -1550,6 +1565,7 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
1550
1565
 
1551
1566
  export {
1552
1567
  getIndexHtml,
1568
+ mergeViteConfigs,
1553
1569
  require_fast_deep_equal,
1554
1570
  createWindiCSSPlugin,
1555
1571
  ViteSlidevPlugin
@@ -84,9 +84,9 @@ var __privateWrapper = (obj, member, setter, getter) => {
84
84
  };
85
85
  };
86
86
 
87
- // ../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.4/node_modules/tsup/assets/cjs_shims.js
87
+ // ../../node_modules/.pnpm/tsup@5.12.9_typescript@4.7.2/node_modules/tsup/assets/cjs_shims.js
88
88
  var init_cjs_shims = __esm({
89
- "../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.4/node_modules/tsup/assets/cjs_shims.js"() {
89
+ "../../node_modules/.pnpm/tsup@5.12.9_typescript@4.7.2/node_modules/tsup/assets/cjs_shims.js"() {
90
90
  }
91
91
  });
92
92