@slidev/cli 0.29.1 → 0.30.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.
- package/dist/{build-DYW4YDUF.js → build-MOXNSJPP.js} +18 -16
- package/dist/{build-MKWMU6W4.mjs → build-SSLWFRFJ.mjs} +11 -9
- package/dist/{chunk-NLYVEPP6.js → chunk-3GNNQ2GU.js} +1962 -1989
- package/dist/{chunk-G22DGVU7.mjs → chunk-46RYGQQC.mjs} +2 -2
- package/dist/{chunk-UEIFQWPY.mjs → chunk-4AVLCCHB.mjs} +81 -15
- package/dist/{chunk-7F2QYO53.js → chunk-7FQD47HM.js} +133 -67
- package/dist/{chunk-5BL2KALH.js → chunk-HBDQZUZK.js} +4 -4
- package/dist/{chunk-OJT6Z67R.mjs → chunk-HJCTB5CG.mjs} +1868 -1896
- package/dist/{chunk-7QXPSYEZ.js → chunk-IXNT7VMK.js} +16 -16
- package/dist/{chunk-VYBQLH2X.mjs → chunk-XMETW2MS.mjs} +12 -16
- package/dist/cli.js +30 -29
- package/dist/cli.mjs +13 -12
- package/dist/{export-GXF6EY3F.mjs → export-2FIFRI4R.mjs} +71 -66
- package/dist/{export-7OOFII75.js → export-X3EA2DO6.js} +71 -66
- package/dist/index.js +7 -7
- package/dist/index.mjs +4 -4
- package/package.json +17 -18
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
__require,
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues,
|
|
7
|
-
|
|
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-
|
|
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.
|
|
243
|
+
"@antfu/utils": "^0.5.1",
|
|
244
244
|
"@slidev/parser": "workspace:*",
|
|
245
245
|
"@slidev/types": "workspace:*",
|
|
246
|
-
"@vueuse/core": "^8.
|
|
246
|
+
"@vueuse/core": "^8.2.5",
|
|
247
247
|
"@vueuse/head": "^0.7.5",
|
|
248
|
-
"@vueuse/motion": "^2.0.0-beta.
|
|
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: "^
|
|
256
|
+
mermaid: "^9.0.0",
|
|
256
257
|
"monaco-editor": "^0.33.0",
|
|
257
|
-
nanoid: "^3.3.
|
|
258
|
-
prettier: "^2.6.
|
|
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.
|
|
262
|
-
vue: "^3.2.
|
|
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 =
|
|
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
|
-
|
|
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(() =>
|
|
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 });
|
|
@@ -1278,8 +1345,7 @@ function transformPageCSS(md2, id) {
|
|
|
1278
1345
|
if (!page)
|
|
1279
1346
|
return md2;
|
|
1280
1347
|
const { isInsideCodeblocks } = getCodeBlocks(md2);
|
|
1281
|
-
const result = md2.replace(/(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g, (full, start, css, end) => {
|
|
1282
|
-
const index = md2.indexOf(full);
|
|
1348
|
+
const result = md2.replace(/(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g, (full, start, css, end, index) => {
|
|
1283
1349
|
if (index < 0 || isInsideCodeblocks(index))
|
|
1284
1350
|
return full;
|
|
1285
1351
|
if (!start.includes("scoped"))
|