@slidev/cli 0.29.2 → 0.30.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.
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  ViteSlidevPlugin,
3
3
  getIndexHtml
4
- } from "./chunk-NQIXBLV4.mjs";
4
+ } from "./chunk-4AVLCCHB.mjs";
5
5
  import {
6
6
  __require,
7
7
  __spreadValues,
8
- __toModule,
8
+ __toESM,
9
9
  init_esm_shims
10
- } from "./chunk-VYBQLH2X.mjs";
10
+ } from "./chunk-XMETW2MS.mjs";
11
11
 
12
12
  // node/build.ts
13
13
  init_esm_shims();
@@ -37,7 +37,7 @@ function totalist(dir, callback, pre = "") {
37
37
  }
38
38
  }
39
39
 
40
- // ../../node_modules/.pnpm/@polka+url@1.0.0-next.20/node_modules/@polka/url/build.mjs
40
+ // ../../node_modules/.pnpm/@polka+url@1.0.0-next.21/node_modules/@polka/url/build.mjs
41
41
  init_esm_shims();
42
42
  import * as qs from "querystring";
43
43
  function parse2(req) {
@@ -710,7 +710,7 @@ async function build(options, viteConfig = {}) {
710
710
  await fs2.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
711
711
  `, "utf-8");
712
712
  if ([true, "true", "auto"].includes(options.data.config.download)) {
713
- const { exportSlides } = await Promise.resolve().then(() => __toModule(__require("./export-4MUQJ4DB.mjs")));
713
+ const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-OZQCWKXN.mjs")));
714
714
  const port = 12445;
715
715
  const app = connect();
716
716
  const server = http.createServer(app);
@@ -1,16 +1,16 @@
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 _chunkNPCPO6ETjs = require('./chunk-NPCPO6ET.js');
4
+ var _chunk7FQD47HMjs = require('./chunk-7FQD47HM.js');
5
5
 
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunk7QXPSYEZjs = require('./chunk-7QXPSYEZ.js');
10
+ var _chunkIXNT7VMKjs = require('./chunk-IXNT7VMK.js');
11
11
 
12
12
  // node/build.ts
13
- _chunk7QXPSYEZjs.init_cjs_shims.call(void 0, );
13
+ _chunkIXNT7VMKjs.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
- _chunk7QXPSYEZjs.init_cjs_shims.call(void 0, );
21
+ _chunkIXNT7VMKjs.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
- _chunk7QXPSYEZjs.init_cjs_shims.call(void 0, );
26
+ _chunkIXNT7VMKjs.init_cjs_shims.call(void 0, );
27
27
 
28
28
 
29
29
  function totalist(dir, callback, pre = "") {
@@ -37,8 +37,8 @@ function totalist(dir, callback, pre = "") {
37
37
  }
38
38
  }
39
39
 
40
- // ../../node_modules/.pnpm/@polka+url@1.0.0-next.20/node_modules/@polka/url/build.mjs
41
- _chunk7QXPSYEZjs.init_cjs_shims.call(void 0, );
40
+ // ../../node_modules/.pnpm/@polka+url@1.0.0-next.21/node_modules/@polka/url/build.mjs
41
+ _chunkIXNT7VMKjs.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
- _chunk7QXPSYEZjs.init_cjs_shims.call(void 0, );
65
+ _chunkIXNT7VMKjs.init_cjs_shims.call(void 0, );
66
66
  var mimes = {
67
67
  "ez": "application/andrew-inset",
68
68
  "aw": "application/applixware",
@@ -527,7 +527,7 @@ function is404(req, res) {
527
527
  }
528
528
  function send(req, res, file, stats, headers) {
529
529
  let code = 200, tmp, opts = {};
530
- headers = _chunk7QXPSYEZjs.__spreadValues.call(void 0, {}, headers);
530
+ headers = _chunkIXNT7VMKjs.__spreadValues.call(void 0, {}, headers);
531
531
  for (let key in headers) {
532
532
  tmp = res.getHeader(key);
533
533
  if (tmp)
@@ -655,12 +655,12 @@ 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 _chunkNPCPO6ETjs.getIndexHtml.call(void 0, options), "utf-8");
658
+ await _fsextra2.default.writeFile(indexPath, await _chunk7FQD47HMjs.getIndexHtml.call(void 0, options), "utf-8");
659
659
  let config = void 0;
660
660
  try {
661
661
  const inlineConfig = _vite.mergeConfig.call(void 0, viteConfig, {
662
662
  plugins: [
663
- await _chunkNPCPO6ETjs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
663
+ await _chunk7FQD47HMjs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
664
664
  {
665
665
  name: "resolve-config",
666
666
  configResolved(_config) {
@@ -710,7 +710,7 @@ async function build(options, viteConfig = {}) {
710
710
  await _fsextra2.default.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
711
711
  `, "utf-8");
712
712
  if ([true, "true", "auto"].includes(options.data.config.download)) {
713
- const { exportSlides } = await Promise.resolve().then(() => _chunk7QXPSYEZjs.__toModule.call(void 0, _chunk7QXPSYEZjs.__require.call(void 0, "./export-XA3FQNS5.js")));
713
+ const { exportSlides } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "./export-SQVJKP3A.js")));
714
714
  const port = 12445;
715
715
  const app = _connect2.default.call(void 0, );
716
716
  const server = _http2.default.createServer(app);
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ViteSlidevPlugin
3
- } from "./chunk-NQIXBLV4.mjs";
3
+ } from "./chunk-4AVLCCHB.mjs";
4
4
  import {
5
5
  init_esm_shims
6
- } from "./chunk-VYBQLH2X.mjs";
6
+ } from "./chunk-XMETW2MS.mjs";
7
7
 
8
8
  // node/server.ts
9
9
  init_esm_shims();
@@ -4,14 +4,14 @@ import {
4
4
  __require,
5
5
  __spreadProps,
6
6
  __spreadValues,
7
- __toModule,
7
+ __toESM,
8
8
  generateGoogleFontsUrl,
9
9
  init_esm_shims,
10
10
  resolveGlobalImportPath,
11
11
  resolveImportPath,
12
12
  stringifyMarkdownTokens,
13
13
  toAtFS
14
- } from "./chunk-VYBQLH2X.mjs";
14
+ } from "./chunk-XMETW2MS.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({
@@ -240,27 +240,29 @@ import { uniq as uniq3 } from "@antfu/utils";
240
240
 
241
241
  // ../client/package.json
242
242
  var dependencies = {
243
- "@antfu/utils": "^0.5.0",
243
+ "@antfu/utils": "^0.5.1",
244
244
  "@slidev/parser": "workspace:*",
245
245
  "@slidev/types": "workspace:*",
246
- "@vueuse/core": "^8.1.2",
246
+ "@vueuse/core": "^8.2.5",
247
247
  "@vueuse/head": "^0.7.5",
248
- "@vueuse/motion": "^2.0.0-beta.12",
248
+ "@vueuse/motion": "^2.0.0-beta.18",
249
249
  codemirror: "^5.65.2",
250
+ defu: "^6.0.0",
250
251
  drauu: "^0.3.0",
251
252
  "file-saver": "^2.0.5",
252
253
  "js-base64": "^3.7.2",
253
254
  "js-yaml": "^4.1.0",
254
255
  katex: "^0.15.3",
255
- mermaid: "^8.14.0",
256
+ mermaid: "^9.0.0",
256
257
  "monaco-editor": "^0.33.0",
257
- nanoid: "^3.3.1",
258
- prettier: "^2.6.0",
258
+ nanoid: "^3.3.2",
259
+ prettier: "^2.6.2",
259
260
  recordrtc: "^5.6.2",
260
261
  resolve: "^1.22.0",
261
- "vite-plugin-windicss": "^1.8.3",
262
- vue: "^3.2.31",
262
+ "vite-plugin-windicss": "^1.8.4",
263
+ vue: "^3.2.32",
263
264
  "vue-router": "^4.0.14",
265
+ "vue-starport": "^0.2.4",
264
266
  windicss: "^3.5.1"
265
267
  };
266
268
 
@@ -392,7 +394,7 @@ function getDefine(options) {
392
394
 
393
395
  // node/plugins/loaders.ts
394
396
  init_esm_shims();
395
- var import_fast_deep_equal = __toModule(require_fast_deep_equal());
397
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
396
398
  import { basename as basename2, join as join5 } from "path";
397
399
  import { isString, notNullish, objectMap, range, slash as slash2, uniq as uniq4 } from "@antfu/utils";
398
400
  import fg2 from "fast-glob";
@@ -593,6 +595,15 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
593
595
  const pageNo = parseInt(no) - 1;
594
596
  return transformMarkdown(code, pageNo, data);
595
597
  }
598
+ },
599
+ {
600
+ name: "slidev:context-transform:pre",
601
+ enforce: "pre",
602
+ async transform(code, id) {
603
+ if (!id.endsWith(".vue"))
604
+ return;
605
+ return transformVue(code);
606
+ }
596
607
  }
597
608
  ];
598
609
  function updateServerWatcher() {
@@ -610,8 +621,11 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
610
621
  throw new Error(`Unknown layout "${layoutName}"`);
611
622
  delete frontmatter.title;
612
623
  const imports = [
624
+ 'import { inject as vueInject } from "vue"',
613
625
  `import InjectedLayout from "${toAtFS(layouts[layoutName])}"`,
614
- `const frontmatter = ${JSON.stringify(frontmatter)}`
626
+ 'import { injectionSlidevContext } from "@slidev/client/constants"',
627
+ `const frontmatter = ${JSON.stringify(frontmatter)}`,
628
+ "const $slidev = vueInject(injectionSlidevContext)"
615
629
  ];
616
630
  code = code.replace(/(<script setup.*>)/g, `$1
617
631
  ${imports.join("\n")}
@@ -628,6 +642,59 @@ ${body}
628
642
  ${code.slice(injectB)}`;
629
643
  return code;
630
644
  }
645
+ function transformVue(code) {
646
+ if (code.includes("injectionSlidevContext"))
647
+ return code;
648
+ const imports = [
649
+ 'import { inject as vueInject } from "vue"',
650
+ 'import { injectionSlidevContext } from "@slidev/client/constants"',
651
+ "const $slidev = vueInject(injectionSlidevContext)"
652
+ ];
653
+ const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/);
654
+ if (matchScript && matchScript[2]) {
655
+ return code.replace(/(<script.*>)/g, `$1
656
+ ${imports.join("\n")}
657
+ `);
658
+ } else if (matchScript && !matchScript[2]) {
659
+ const matchExport = code.match(/export\s+default\s+[^{]*{/);
660
+ if (matchExport) {
661
+ const exportIndex = (matchExport.index || 0) + matchExport[0].length;
662
+ let component = code.slice(exportIndex);
663
+ component = component.slice(0, component.indexOf("<\/script>"));
664
+ if (component.match(/setup\s*\(/)) {
665
+ const scriptIndex = (matchScript.index || 0) + matchScript[0].length;
666
+ const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants"\n';
667
+ code = `${code.slice(0, scriptIndex)}${provideImport}${code.slice(scriptIndex)}`;
668
+ let injectIndex = exportIndex + provideImport.length;
669
+ let injectObject = "$slidev: { from: injectionSlidevContext },";
670
+ const matchInject = component.match(/.*inject\s*:\s*([\[{])/);
671
+ if (matchInject) {
672
+ injectIndex += (matchInject.index || 0) + matchInject[0].length;
673
+ if (matchInject[1] === "[") {
674
+ let injects = component.slice((matchInject.index || 0) + matchInject[0].length);
675
+ const injectEndIndex = injects.indexOf("]");
676
+ injects = injects.slice(0, injectEndIndex);
677
+ injectObject += injects.split(",").map((inject) => `${inject}: {from: ${inject}}`).join(",");
678
+ return `${code.slice(0, injectIndex - 1)}{
679
+ ${injectObject}
680
+ }${code.slice(injectIndex + injectEndIndex + 1)}`;
681
+ } else {
682
+ return `${code.slice(0, injectIndex)}
683
+ ${injectObject}
684
+ ${code.slice(injectIndex)}`;
685
+ }
686
+ }
687
+ return `${code.slice(0, injectIndex)}
688
+ inject: { ${injectObject} },
689
+ ${code.slice(injectIndex)}`;
690
+ }
691
+ }
692
+ }
693
+ return `<script setup>
694
+ ${imports.join("\n")}
695
+ <\/script>
696
+ ${code}`;
697
+ }
631
698
  async function getLayouts() {
632
699
  const now = Date.now();
633
700
  if (now - _layouts_cache_time < 2e3)
@@ -1159,7 +1226,7 @@ async function createMarkdownPlugin({ data: { config }, roots, mode, entry }, {
1159
1226
  const setups = [];
1160
1227
  const entryPath = slash5(entry);
1161
1228
  if (config.highlighter === "shiki") {
1162
- const { getHighlighter } = await Promise.resolve().then(() => __toModule(__require("shiki")));
1229
+ const { getHighlighter } = await Promise.resolve().then(() => __toESM(__require("shiki")));
1163
1230
  const shikiOptions = await loadSetups(roots, "shiki.ts", Shiki, DEFAULT_SHIKI_OPTIONS, false);
1164
1231
  const { langs, themes } = resolveShikiOptions(shikiOptions);
1165
1232
  shikiOptions.highlighter = await getHighlighter({ themes, langs });