@slidev/cli 0.35.4 → 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.
- package/dist/{build-IINHUSXF.mjs → build-3YQL2K7P.mjs} +53 -38
- package/dist/{build-YURLBXT3.js → build-DIGRXRLK.js} +59 -44
- package/dist/{chunk-SQLX75IO.js → chunk-74QPSS6T.js} +12 -7
- package/dist/{chunk-GVA336JI.mjs → chunk-IAMILGBS.mjs} +12 -7
- package/dist/{chunk-CG7FMSNH.mjs → chunk-MTVLPZ5A.mjs} +66 -29
- package/dist/{chunk-54NZDFOD.mjs → chunk-PIEUNXTX.mjs} +133 -105
- package/dist/{chunk-RWZBP7KJ.js → chunk-S3XL4MK5.js} +196 -159
- package/dist/{chunk-2SBR5VZF.js → chunk-S74C6Q74.js} +173 -145
- package/dist/cli.js +291 -247
- package/dist/cli.mjs +286 -242
- package/dist/{export-5OVMZQWE.mjs → export-26FXNM7P.mjs} +6 -3
- package/dist/{export-TH7MNEXN.js → export-WKFHZNBT.js} +9 -6
- package/dist/index.js +6 -6
- package/dist/index.mjs +3 -3
- package/package.json +20 -20
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
resolveImportPath,
|
|
10
10
|
stringifyMarkdownTokens,
|
|
11
11
|
toAtFS
|
|
12
|
-
} from "./chunk-
|
|
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({
|
|
@@ -165,38 +165,40 @@ async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRo
|
|
|
165
165
|
if (config.default)
|
|
166
166
|
config = config.default;
|
|
167
167
|
config = await loadSetups(roots, "windicss.ts", {}, config, true);
|
|
168
|
-
return WindiCSS(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
config2.theme
|
|
174
|
-
|
|
175
|
-
config2.theme.extend
|
|
176
|
-
|
|
177
|
-
config2.theme.extend.fontFamily
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
168
|
+
return WindiCSS(
|
|
169
|
+
{
|
|
170
|
+
configFiles: [configFile],
|
|
171
|
+
config,
|
|
172
|
+
onConfigResolved(config2) {
|
|
173
|
+
if (!config2.theme)
|
|
174
|
+
config2.theme = {};
|
|
175
|
+
if (!config2.theme.extend)
|
|
176
|
+
config2.theme.extend = {};
|
|
177
|
+
if (!config2.theme.extend.fontFamily)
|
|
178
|
+
config2.theme.extend.fontFamily = {};
|
|
179
|
+
const fontFamily = config2.theme.extend.fontFamily;
|
|
180
|
+
fontFamily.sans || (fontFamily.sans = data.config.fonts.sans.join(","));
|
|
181
|
+
fontFamily.mono || (fontFamily.mono = data.config.fonts.mono.join(","));
|
|
182
|
+
fontFamily.serif || (fontFamily.serif = data.config.fonts.serif.join(","));
|
|
183
|
+
return config2;
|
|
184
|
+
},
|
|
185
|
+
onOptionsResolved(config2) {
|
|
186
|
+
themeRoots.forEach((i) => {
|
|
187
|
+
config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
|
|
188
|
+
config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
|
|
189
|
+
});
|
|
190
|
+
addonRoots.forEach((i) => {
|
|
191
|
+
config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
|
|
192
|
+
config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
|
|
193
|
+
});
|
|
194
|
+
config2.scanOptions.include.push(`!${slash(resolve2(userRoot, "node_modules"))}`);
|
|
195
|
+
config2.scanOptions.exclude.push(dirname(resolveImportPath("monaco-editor/package.json", true)));
|
|
196
|
+
config2.scanOptions.exclude.push(dirname(resolveImportPath("katex/package.json", true)));
|
|
197
|
+
config2.scanOptions.exclude.push(dirname(resolveImportPath("prettier/package.json", true)));
|
|
198
|
+
},
|
|
199
|
+
...windiOptions
|
|
200
|
+
}
|
|
201
|
+
);
|
|
200
202
|
}
|
|
201
203
|
|
|
202
204
|
// node/plugins/preset.ts
|
|
@@ -216,7 +218,10 @@ import { basename, dirname as dirname2, join as join2, resolve as resolve3 } fro
|
|
|
216
218
|
import fs2 from "fs-extra";
|
|
217
219
|
import fg from "fast-glob";
|
|
218
220
|
function resolveDrawingsDir(options) {
|
|
219
|
-
return options.data.config.drawings.persist ? resolve3(
|
|
221
|
+
return options.data.config.drawings.persist ? resolve3(
|
|
222
|
+
dirname2(options.entry),
|
|
223
|
+
options.data.config.drawings.persist
|
|
224
|
+
) : void 0;
|
|
220
225
|
}
|
|
221
226
|
async function loadDrawings(options) {
|
|
222
227
|
const dir = resolveDrawingsDir(options);
|
|
@@ -247,14 +252,16 @@ async function writeDrawings(options, drawing) {
|
|
|
247
252
|
const height = Math.round(width / options.data.config.aspectRatio);
|
|
248
253
|
const SVG_HEAD = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
|
|
249
254
|
await fs2.ensureDir(dir);
|
|
250
|
-
return Promise.all(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
255
|
+
return Promise.all(
|
|
256
|
+
Object.entries(drawing).map(async ([key, value]) => {
|
|
257
|
+
if (!value)
|
|
258
|
+
return;
|
|
259
|
+
const svg = `${SVG_HEAD}
|
|
254
260
|
${value}
|
|
255
261
|
</svg>`;
|
|
256
|
-
|
|
257
|
-
|
|
262
|
+
await fs2.writeFile(join2(dir, `${key}.svg`), svg, "utf-8");
|
|
263
|
+
})
|
|
264
|
+
);
|
|
258
265
|
}
|
|
259
266
|
|
|
260
267
|
// node/plugins/extendConfig.ts
|
|
@@ -269,28 +276,28 @@ var dependencies = {
|
|
|
269
276
|
"@antfu/utils": "^0.5.2",
|
|
270
277
|
"@slidev/parser": "workspace:*",
|
|
271
278
|
"@slidev/types": "workspace:*",
|
|
272
|
-
"@unocss/reset": "^0.45.
|
|
273
|
-
"@vueuse/core": "^9.0
|
|
274
|
-
"@vueuse/head": "^0.7.
|
|
275
|
-
"@vueuse/math": "^9.0
|
|
276
|
-
"@vueuse/motion": "^2.0.0-beta.
|
|
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",
|
|
277
284
|
codemirror: "^5.65.5",
|
|
278
|
-
defu: "^6.
|
|
279
|
-
drauu: "^0.3.
|
|
285
|
+
defu: "^6.1.0",
|
|
286
|
+
drauu: "^0.3.1",
|
|
280
287
|
"file-saver": "^2.0.5",
|
|
281
288
|
"js-base64": "^3.7.2",
|
|
282
289
|
"js-yaml": "^4.1.0",
|
|
283
|
-
katex: "^0.16.
|
|
284
|
-
mermaid: "^9.1.
|
|
290
|
+
katex: "^0.16.2",
|
|
291
|
+
mermaid: "^9.1.6",
|
|
285
292
|
"monaco-editor": "^0.33.0",
|
|
286
293
|
nanoid: "^4.0.0",
|
|
287
294
|
prettier: "^2.7.1",
|
|
288
295
|
recordrtc: "^5.6.2",
|
|
289
296
|
resolve: "^1.22.1",
|
|
290
|
-
unocss: "^0.45.
|
|
291
|
-
"vite-plugin-windicss": "^1.8.
|
|
292
|
-
vue: "^3.2.
|
|
293
|
-
"vue-router": "^4.1.
|
|
297
|
+
unocss: "^0.45.20",
|
|
298
|
+
"vite-plugin-windicss": "^1.8.8",
|
|
299
|
+
vue: "^3.2.39",
|
|
300
|
+
"vue-router": "^4.1.5",
|
|
294
301
|
"vue-starport": "^0.3.0",
|
|
295
302
|
windicss: "^3.5.6"
|
|
296
303
|
};
|
|
@@ -342,6 +349,9 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
|
342
349
|
var EXCLUDE = [
|
|
343
350
|
"@slidev/shared",
|
|
344
351
|
"@slidev/types",
|
|
352
|
+
"@slidev/client",
|
|
353
|
+
"@slidev/client/constants",
|
|
354
|
+
"@slidev/client/logic/dark",
|
|
345
355
|
"@vueuse/core",
|
|
346
356
|
"@vueuse/shared",
|
|
347
357
|
"@unocss/reset",
|
|
@@ -552,22 +562,25 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
|
|
|
552
562
|
Object.assign(data, newData);
|
|
553
563
|
if (hmrPages.size > 0)
|
|
554
564
|
moduleIds.add("/@slidev/titles.md");
|
|
555
|
-
const vueModules = (await Promise.all(
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
565
|
+
const vueModules = (await Promise.all(
|
|
566
|
+
Array.from(hmrPages).map(async (i) => {
|
|
567
|
+
var _a2;
|
|
568
|
+
const file = `${slidePrefix}${i + 1}.md`;
|
|
569
|
+
try {
|
|
570
|
+
const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
|
|
571
|
+
const handleHotUpdate = "handler" in VuePlugin.handleHotUpdate ? VuePlugin.handleHotUpdate.handler : VuePlugin.handleHotUpdate;
|
|
572
|
+
return await handleHotUpdate({
|
|
573
|
+
...ctx,
|
|
574
|
+
modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
|
|
575
|
+
file,
|
|
576
|
+
read() {
|
|
577
|
+
return md2;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
} catch {
|
|
581
|
+
}
|
|
582
|
+
})
|
|
583
|
+
)).flatMap((i) => i || []);
|
|
571
584
|
hmrPages.clear();
|
|
572
585
|
const moduleEntries = [
|
|
573
586
|
...vueModules,
|
|
@@ -817,11 +830,22 @@ defineProps<{ no: number | string }>()`);
|
|
|
817
830
|
if (data.features.katex)
|
|
818
831
|
imports.push(`import "${toAtFS(resolveImportPath("katex/dist/katex.min.css", true))}"`);
|
|
819
832
|
if (data.config.css === "unocss") {
|
|
820
|
-
imports.unshift(
|
|
833
|
+
imports.unshift(
|
|
834
|
+
'import "@unocss/reset/tailwind.css"',
|
|
835
|
+
'import "uno:preflights.css"',
|
|
836
|
+
'import "uno:typography.css"',
|
|
837
|
+
'import "uno:shortcuts.css"'
|
|
838
|
+
);
|
|
821
839
|
imports.push('import "uno.css"');
|
|
822
840
|
} else {
|
|
823
|
-
imports.unshift(
|
|
824
|
-
|
|
841
|
+
imports.unshift(
|
|
842
|
+
'import "virtual:windi-components.css"',
|
|
843
|
+
'import "virtual:windi-base.css"'
|
|
844
|
+
);
|
|
845
|
+
imports.push(
|
|
846
|
+
'import "virtual:windi-utilities.css"',
|
|
847
|
+
'import "virtual:windi-devtools"'
|
|
848
|
+
);
|
|
825
849
|
}
|
|
826
850
|
return imports.join("\n");
|
|
827
851
|
}
|
|
@@ -830,10 +854,13 @@ defineProps<{ no: number | string }>()`);
|
|
|
830
854
|
}
|
|
831
855
|
async function generateLayouts() {
|
|
832
856
|
const imports = [];
|
|
833
|
-
const layouts = objectMap(
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
857
|
+
const layouts = objectMap(
|
|
858
|
+
await getLayouts(),
|
|
859
|
+
(k, v) => {
|
|
860
|
+
imports.push(`import __layout_${k} from "${toAtFS(v)}"`);
|
|
861
|
+
return [k, `__layout_${k}`];
|
|
862
|
+
}
|
|
863
|
+
);
|
|
837
864
|
return [
|
|
838
865
|
imports.join("\n"),
|
|
839
866
|
`export default {
|
|
@@ -979,10 +1006,13 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
|
|
|
979
1006
|
enforce: "pre",
|
|
980
1007
|
async transform(code, id) {
|
|
981
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;
|
|
982
1013
|
const name = id.slice(setupEntry.length + 1);
|
|
983
1014
|
const imports = [];
|
|
984
1015
|
const injections = [];
|
|
985
|
-
const asyncInjections = [];
|
|
986
1016
|
const setups = uniq5([
|
|
987
1017
|
...themeRoots,
|
|
988
1018
|
...addonRoots,
|
|
@@ -992,35 +1022,28 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
|
|
|
992
1022
|
if (!existsSync5(path))
|
|
993
1023
|
return;
|
|
994
1024
|
imports.push(`import __n${idx} from '${toAtFS(path)}'`);
|
|
995
|
-
let fn =
|
|
996
|
-
|
|
997
|
-
if (/\binjection_return\b/g.test(code)) {
|
|
1025
|
+
let fn = `:AWAIT:__n${idx}`;
|
|
1026
|
+
if (/\binjection_return\b/g.test(code))
|
|
998
1027
|
fn = `injection_return = ${fn}`;
|
|
999
|
-
awaitFn = `injection_return = ${awaitFn}`;
|
|
1000
|
-
}
|
|
1001
1028
|
if (/\binjection_arg\b/g.test(code)) {
|
|
1002
1029
|
fn += "(";
|
|
1003
|
-
awaitFn += "(";
|
|
1004
1030
|
const matches = Array.from(code.matchAll(/\binjection_arg(_\d+)?\b/g));
|
|
1005
1031
|
const dedupedMatches = Array.from(new Set(matches.map((m) => m[0])));
|
|
1006
|
-
dedupedMatches.
|
|
1007
|
-
|
|
1008
|
-
const arg = key + (isLast ? "" : ",");
|
|
1009
|
-
fn += arg;
|
|
1010
|
-
awaitFn += arg;
|
|
1011
|
-
});
|
|
1012
|
-
fn += ")";
|
|
1013
|
-
awaitFn += ")";
|
|
1032
|
+
fn += dedupedMatches.join(", ");
|
|
1033
|
+
fn += ", :LAST:)";
|
|
1014
1034
|
} else {
|
|
1015
|
-
fn += "()";
|
|
1016
|
-
awaitFn += "()";
|
|
1035
|
+
fn += "(:LAST:)";
|
|
1017
1036
|
}
|
|
1018
|
-
injections.push(
|
|
1019
|
-
|
|
1037
|
+
injections.push(
|
|
1038
|
+
`// ${path}`,
|
|
1039
|
+
fn
|
|
1040
|
+
);
|
|
1020
1041
|
});
|
|
1021
1042
|
code = code.replace("/* __imports__ */", imports.join("\n"));
|
|
1022
|
-
code = code.replace("/* __injections__ */",
|
|
1023
|
-
code = code.replace("/* __async_injections__ */",
|
|
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));
|
|
1024
1047
|
return code;
|
|
1025
1048
|
}
|
|
1026
1049
|
return null;
|
|
@@ -1294,7 +1317,9 @@ var MarkdownItShiki = (markdownit, options = {}) => {
|
|
|
1294
1317
|
const light = _highlighter.codeToHtml(trimmed, { lang: lang || "text", theme: darkModeThemes.light }).replace('<pre class="shiki"', '<pre class="slidev-code shiki shiki-light"');
|
|
1295
1318
|
return escapeVueInCode(`<pre class="shiki-container">${dark}${light}</pre>`);
|
|
1296
1319
|
} else {
|
|
1297
|
-
return escapeVueInCode(
|
|
1320
|
+
return escapeVueInCode(
|
|
1321
|
+
_highlighter.codeToHtml(code, { lang: lang || "text" }).replace('<pre class="shiki"', '<pre class="slidev-code shiki"')
|
|
1322
|
+
);
|
|
1298
1323
|
}
|
|
1299
1324
|
};
|
|
1300
1325
|
};
|
|
@@ -1432,14 +1457,17 @@ function transformPageCSS(md2, id) {
|
|
|
1432
1457
|
if (!page)
|
|
1433
1458
|
return md2;
|
|
1434
1459
|
const { isInsideCodeblocks } = getCodeBlocks(md2);
|
|
1435
|
-
const result = md2.replace(
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1460
|
+
const result = md2.replace(
|
|
1461
|
+
/(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g,
|
|
1462
|
+
(full, start, css, end, index) => {
|
|
1463
|
+
if (index < 0 || isInsideCodeblocks(index))
|
|
1464
|
+
return full;
|
|
1465
|
+
if (!start.includes("scoped"))
|
|
1466
|
+
start = start.replace("<style", "<style scoped");
|
|
1467
|
+
return `${start}
|
|
1441
1468
|
${css}${end}`;
|
|
1442
|
-
|
|
1469
|
+
}
|
|
1470
|
+
);
|
|
1443
1471
|
return result;
|
|
1444
1472
|
}
|
|
1445
1473
|
function transformMermaid(md2) {
|