@slidev/cli 0.35.6 → 0.36.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.
@@ -2,12 +2,12 @@ import {
2
2
  ViteSlidevPlugin,
3
3
  getIndexHtml,
4
4
  mergeViteConfigs
5
- } from "./chunk-IY7QSYZ2.mjs";
5
+ } from "./chunk-PIEUNXTX.mjs";
6
6
  import {
7
7
  __require,
8
8
  __toESM,
9
9
  init_esm_shims
10
- } from "./chunk-57E5R3IA.mjs";
10
+ } from "./chunk-IAMILGBS.mjs";
11
11
 
12
12
  // node/build.ts
13
13
  init_esm_shims();
@@ -650,7 +650,7 @@ function build_default(dir, opts = {}) {
650
650
  import { blue, yellow } from "kolorist";
651
651
  async function build(options, viteConfig = {}) {
652
652
  const indexPath = resolve3(options.userRoot, "index.html");
653
- const rawConfig = await resolveConfig({}, "build");
653
+ const rawConfig = await resolveConfig({}, "build", options.entry);
654
654
  const pluginOptions = rawConfig.slidev || {};
655
655
  let originalIndexHTML;
656
656
  if (fs2.existsSync(indexPath))
@@ -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-I2KYMDHO.mjs")));
728
+ const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-26FXNM7P.mjs")));
729
729
  const port = 12445;
730
730
  const app = connect();
731
731
  const server = http.createServer(app);
@@ -2,15 +2,15 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkYUXTNPKAjs = require('./chunk-YUXTNPKA.js');
5
+ var _chunkS74C6Q74js = require('./chunk-S74C6Q74.js');
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunkAW7KQET4js = require('./chunk-AW7KQET4.js');
10
+ var _chunk74QPSS6Tjs = require('./chunk-74QPSS6T.js');
11
11
 
12
12
  // node/build.ts
13
- _chunkAW7KQET4js.init_cjs_shims.call(void 0, );
13
+ _chunk74QPSS6Tjs.init_cjs_shims.call(void 0, );
14
14
  var _path = require('path');
15
15
  var _http = require('http'); var _http2 = _interopRequireDefault(_http);
16
16
  var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
@@ -18,12 +18,12 @@ var _vite = require('vite');
18
18
  var _connect = require('connect'); var _connect2 = _interopRequireDefault(_connect);
19
19
 
20
20
  // ../../node_modules/.pnpm/sirv@2.0.2/node_modules/sirv/build.mjs
21
- _chunkAW7KQET4js.init_cjs_shims.call(void 0, );
21
+ _chunk74QPSS6Tjs.init_cjs_shims.call(void 0, );
22
22
  var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
23
23
 
24
24
 
25
25
  // ../../node_modules/.pnpm/totalist@3.0.0/node_modules/totalist/sync/index.mjs
26
- _chunkAW7KQET4js.init_cjs_shims.call(void 0, );
26
+ _chunk74QPSS6Tjs.init_cjs_shims.call(void 0, );
27
27
 
28
28
 
29
29
  function totalist(dir, callback, pre = "") {
@@ -38,7 +38,7 @@ function totalist(dir, callback, pre = "") {
38
38
  }
39
39
 
40
40
  // ../../node_modules/.pnpm/@polka+url@1.0.0-next.21/node_modules/@polka/url/build.mjs
41
- _chunkAW7KQET4js.init_cjs_shims.call(void 0, );
41
+ _chunk74QPSS6Tjs.init_cjs_shims.call(void 0, );
42
42
  var _querystring = require('querystring'); var qs = _interopRequireWildcard(_querystring);
43
43
  function parse2(req) {
44
44
  let raw = req.url;
@@ -62,7 +62,7 @@ function parse2(req) {
62
62
  }
63
63
 
64
64
  // ../../node_modules/.pnpm/mrmime@1.0.0/node_modules/mrmime/index.mjs
65
- _chunkAW7KQET4js.init_cjs_shims.call(void 0, );
65
+ _chunk74QPSS6Tjs.init_cjs_shims.call(void 0, );
66
66
  var mimes = {
67
67
  "ez": "application/andrew-inset",
68
68
  "aw": "application/applixware",
@@ -650,21 +650,21 @@ function build_default(dir, opts = {}) {
650
650
  var _kolorist = require('kolorist');
651
651
  async function build(options, viteConfig = {}) {
652
652
  const indexPath = _path.resolve.call(void 0, options.userRoot, "index.html");
653
- const rawConfig = await _vite.resolveConfig.call(void 0, {}, "build");
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 _chunkYUXTNPKAjs.getIndexHtml.call(void 0, options), "utf-8");
658
+ await _fsextra2.default.writeFile(indexPath, await _chunkS74C6Q74js.getIndexHtml.call(void 0, options), "utf-8");
659
659
  let config = void 0;
660
660
  try {
661
- const inlineConfig = await _chunkYUXTNPKAjs.mergeViteConfigs.call(void 0,
661
+ const inlineConfig = await _chunkS74C6Q74js.mergeViteConfigs.call(void 0,
662
662
  options,
663
663
  viteConfig,
664
664
  {
665
665
  root: options.userRoot,
666
666
  plugins: [
667
- await _chunkYUXTNPKAjs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
667
+ await _chunkS74C6Q74js.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 _chunkYUXTNPKAjs.mergeViteConfigs.call(void 0,
688
+ await _chunkS74C6Q74js.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(() => _chunkAW7KQET4js.__toESM.call(void 0, _chunkAW7KQET4js.__require.call(void 0, "./export-3CTBMUMP.js")));
728
+ const { exportSlides } = await Promise.resolve().then(() => _chunk74QPSS6Tjs.__toESM.call(void 0, _chunk74QPSS6Tjs.__require.call(void 0, "./export-WKFHZNBT.js")));
729
729
  const port = 12445;
730
730
  const app = _connect2.default.call(void 0, );
731
731
  const server = _http2.default.createServer(app);
@@ -58,9 +58,9 @@ var __privateWrapper = (obj, member, setter, getter) => {
58
58
  };
59
59
  };
60
60
 
61
- // ../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.2/node_modules/tsup/assets/cjs_shims.js
61
+ // ../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.3/node_modules/tsup/assets/cjs_shims.js
62
62
  var init_cjs_shims = __esm({
63
- "../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.2/node_modules/tsup/assets/cjs_shims.js"() {
63
+ "../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.3/node_modules/tsup/assets/cjs_shims.js"() {
64
64
  }
65
65
  });
66
66
 
@@ -58,12 +58,12 @@ var __privateWrapper = (obj, member, setter, getter) => {
58
58
  };
59
59
  };
60
60
 
61
- // ../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.2/node_modules/tsup/assets/esm_shims.js
61
+ // ../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.3/node_modules/tsup/assets/esm_shims.js
62
62
  import { fileURLToPath } from "url";
63
63
  import path from "path";
64
64
  var getFilename, getDirname, __dirname, __filename;
65
65
  var init_esm_shims = __esm({
66
- "../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.2/node_modules/tsup/assets/esm_shims.js"() {
66
+ "../../node_modules/.pnpm/tsup@5.12.9_typescript@4.8.3/node_modules/tsup/assets/esm_shims.js"() {
67
67
  getFilename = () => fileURLToPath(import.meta.url);
68
68
  getDirname = () => path.dirname(getFilename());
69
69
  __dirname = /* @__PURE__ */ getDirname();
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ViteSlidevPlugin,
3
3
  mergeViteConfigs
4
- } from "./chunk-IY7QSYZ2.mjs";
4
+ } from "./chunk-PIEUNXTX.mjs";
5
5
  import {
6
6
  __commonJS,
7
7
  __dirname,
@@ -13,7 +13,7 @@ import {
13
13
  init_esm_shims,
14
14
  packageExists,
15
15
  resolveImportPath
16
- } from "./chunk-57E5R3IA.mjs";
16
+ } from "./chunk-IAMILGBS.mjs";
17
17
 
18
18
  // ../../node_modules/.pnpm/semver@7.3.7/node_modules/semver/internal/constants.js
19
19
  var require_constants = __commonJS({
@@ -2383,7 +2383,7 @@ init_esm_shims();
2383
2383
  import { join } from "path";
2384
2384
  import { createServer as createViteServer, resolveConfig } from "vite";
2385
2385
  async function createServer(options, viteConfig = {}, serverOptions = {}) {
2386
- const rawConfig = await resolveConfig({}, "serve");
2386
+ const rawConfig = await resolveConfig({}, "serve", options.entry);
2387
2387
  const pluginOptions = rawConfig.slidev || {};
2388
2388
  process.env.EDITOR = process.env.EDITOR || "code";
2389
2389
  const server = await createViteServer(
@@ -2411,7 +2411,7 @@ init_esm_shims();
2411
2411
  import * as parser from "@slidev/parser/fs";
2412
2412
 
2413
2413
  // package.json
2414
- var version = "0.35.6";
2414
+ var version = "0.36.0";
2415
2415
 
2416
2416
  // node/themes.ts
2417
2417
  init_esm_shims();
@@ -9660,7 +9660,7 @@ async function resolveOptions(options, mode2, promptForInstallation = true) {
9660
9660
  const themeMeta = await getThemeMeta(theme, join2(themeRoots[0], "package.json"));
9661
9661
  data.themeMeta = themeMeta;
9662
9662
  if (themeMeta)
9663
- data.config = parser.resolveConfig(data.headmatter, themeMeta);
9663
+ data.config = parser.resolveConfig(data.headmatter, themeMeta, options.entry);
9664
9664
  }
9665
9665
  debug({
9666
9666
  config: data.config,
@@ -9,7 +9,7 @@ import {
9
9
  resolveImportPath,
10
10
  stringifyMarkdownTokens,
11
11
  toAtFS
12
- } from "./chunk-57E5R3IA.mjs";
12
+ } from "./chunk-IAMILGBS.mjs";
13
13
 
14
14
  // ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
15
15
  var require_fast_deep_equal = __commonJS({
@@ -218,7 +218,10 @@ import { basename, dirname as dirname2, join as join2, resolve as resolve3 } fro
218
218
  import fs2 from "fs-extra";
219
219
  import fg from "fast-glob";
220
220
  function resolveDrawingsDir(options) {
221
- return options.data.config.drawings.persist ? resolve3(dirname2(options.entry), options.data.config.drawings.persist) : void 0;
221
+ return options.data.config.drawings.persist ? resolve3(
222
+ dirname2(options.entry),
223
+ options.data.config.drawings.persist
224
+ ) : void 0;
222
225
  }
223
226
  async function loadDrawings(options) {
224
227
  const dir = resolveDrawingsDir(options);
@@ -273,11 +276,11 @@ var dependencies = {
273
276
  "@antfu/utils": "^0.5.2",
274
277
  "@slidev/parser": "workspace:*",
275
278
  "@slidev/types": "workspace:*",
276
- "@unocss/reset": "^0.45.14",
277
- "@vueuse/core": "^9.1.1",
278
- "@vueuse/head": "^0.7.9",
279
- "@vueuse/math": "^9.1.1",
280
- "@vueuse/motion": "^2.0.0-beta.18",
279
+ "@unocss/reset": "^0.45.20",
280
+ "@vueuse/core": "^9.2.0",
281
+ "@vueuse/head": "^0.7.10",
282
+ "@vueuse/math": "^9.2.0",
283
+ "@vueuse/motion": "^2.0.0-beta.22",
281
284
  codemirror: "^5.65.5",
282
285
  defu: "^6.1.0",
283
286
  drauu: "^0.3.1",
@@ -291,9 +294,9 @@ var dependencies = {
291
294
  prettier: "^2.7.1",
292
295
  recordrtc: "^5.6.2",
293
296
  resolve: "^1.22.1",
294
- unocss: "^0.45.14",
295
- "vite-plugin-windicss": "^1.8.7",
296
- vue: "^3.2.38",
297
+ unocss: "^0.45.20",
298
+ "vite-plugin-windicss": "^1.8.8",
299
+ vue: "^3.2.39",
297
300
  "vue-router": "^4.1.5",
298
301
  "vue-starport": "^0.3.0",
299
302
  windicss: "^3.5.6"
@@ -565,7 +568,8 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
565
568
  const file = `${slidePrefix}${i + 1}.md`;
566
569
  try {
567
570
  const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
568
- return await VuePlugin.handleHotUpdate({
571
+ const handleHotUpdate = "handler" in VuePlugin.handleHotUpdate ? VuePlugin.handleHotUpdate.handler : VuePlugin.handleHotUpdate;
572
+ return await handleHotUpdate({
569
573
  ...ctx,
570
574
  modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
571
575
  file,
@@ -1002,10 +1006,13 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
1002
1006
  enforce: "pre",
1003
1007
  async transform(code, id) {
1004
1008
  if (id.startsWith(setupEntry)) {
1009
+ let getInjections2 = function(isAwait = false, isChained = false) {
1010
+ return injections.join("\n").replace(/:AWAIT:/g, isAwait ? "await " : "").replace(/(,\s*)?:LAST:/g, isChained ? "$1injection_return" : "");
1011
+ };
1012
+ var getInjections = getInjections2;
1005
1013
  const name = id.slice(setupEntry.length + 1);
1006
1014
  const imports = [];
1007
1015
  const injections = [];
1008
- const asyncInjections = [];
1009
1016
  const setups = uniq5([
1010
1017
  ...themeRoots,
1011
1018
  ...addonRoots,
@@ -1015,41 +1022,28 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
1015
1022
  if (!existsSync5(path))
1016
1023
  return;
1017
1024
  imports.push(`import __n${idx} from '${toAtFS(path)}'`);
1018
- let fn = `__n${idx}`;
1019
- let awaitFn = `await __n${idx}`;
1020
- if (/\binjection_return\b/g.test(code)) {
1025
+ let fn = `:AWAIT:__n${idx}`;
1026
+ if (/\binjection_return\b/g.test(code))
1021
1027
  fn = `injection_return = ${fn}`;
1022
- awaitFn = `injection_return = ${awaitFn}`;
1023
- }
1024
1028
  if (/\binjection_arg\b/g.test(code)) {
1025
1029
  fn += "(";
1026
- awaitFn += "(";
1027
1030
  const matches = Array.from(code.matchAll(/\binjection_arg(_\d+)?\b/g));
1028
1031
  const dedupedMatches = Array.from(new Set(matches.map((m) => m[0])));
1029
- dedupedMatches.forEach((key, index) => {
1030
- const isLast = index === dedupedMatches.length - 1;
1031
- const arg = key + (isLast ? "" : ",");
1032
- fn += arg;
1033
- awaitFn += arg;
1034
- });
1035
- fn += ")";
1036
- awaitFn += ")";
1032
+ fn += dedupedMatches.join(", ");
1033
+ fn += ", :LAST:)";
1037
1034
  } else {
1038
- fn += "()";
1039
- awaitFn += "()";
1035
+ fn += "(:LAST:)";
1040
1036
  }
1041
1037
  injections.push(
1042
1038
  `// ${path}`,
1043
1039
  fn
1044
1040
  );
1045
- asyncInjections.push(
1046
- `// ${path}`,
1047
- awaitFn
1048
- );
1049
1041
  });
1050
1042
  code = code.replace("/* __imports__ */", imports.join("\n"));
1051
- code = code.replace("/* __injections__ */", injections.join("\n"));
1052
- code = code.replace("/* __async_injections__ */", asyncInjections.join("\n"));
1043
+ code = code.replace("/* __injections__ */", getInjections2());
1044
+ code = code.replace("/* __async_injections__ */", getInjections2(true));
1045
+ code = code.replace("/* __chained_injections__ */", getInjections2(false, true));
1046
+ code = code.replace("/* __chained_async_injections__ */", getInjections2(true, true));
1053
1047
  return code;
1054
1048
  }
1055
1049
  return null;