@slidev/cli 51.2.2 → 51.3.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-CKIPRRXN.js → build-ILXZPI57.js} +4 -4
- package/dist/{chunk-T5HJ7VTH.js → chunk-36LVDMJV.js} +1 -1
- package/dist/{chunk-WBOBK5S6.js → chunk-7MVSIUA5.js} +80 -74
- package/dist/cli.js +13 -10
- package/dist/{export-VO32FL6K.js → export-5TR5BGLG.js} +38 -46
- package/dist/index.js +2 -2
- package/package.json +6 -6
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveViteConfigs
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7MVSIUA5.js";
|
|
4
4
|
import "./chunk-TJFRPB4N.js";
|
|
5
5
|
|
|
6
6
|
// node/commands/build.ts
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
import fs from "node:fs/promises";
|
|
9
9
|
import http from "node:http";
|
|
10
|
-
import { resolve } from "node:path";
|
|
10
|
+
import { join, resolve } from "node:path";
|
|
11
11
|
import connect from "connect";
|
|
12
12
|
import sirv from "sirv";
|
|
13
13
|
import { build as viteBuild } from "vite";
|
|
@@ -51,7 +51,7 @@ async function build(options, viteConfig = {}, args) {
|
|
|
51
51
|
await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
|
|
52
52
|
`, "utf-8");
|
|
53
53
|
if ([true, "true", "auto"].includes(options.data.config.download)) {
|
|
54
|
-
const { exportSlides, getExportOptions } = await import("./export-
|
|
54
|
+
const { exportSlides, getExportOptions } = await import("./export-5TR5BGLG.js");
|
|
55
55
|
const port = 12445;
|
|
56
56
|
const app = connect();
|
|
57
57
|
const server = http.createServer(app);
|
|
@@ -67,7 +67,7 @@ async function build(options, viteConfig = {}, args) {
|
|
|
67
67
|
await exportSlides({
|
|
68
68
|
port,
|
|
69
69
|
base: config.base,
|
|
70
|
-
...getExportOptions(args, options, outDir, "slidev-exported.pdf")
|
|
70
|
+
...getExportOptions(args, options, join(outDir, "slidev-exported.pdf"))
|
|
71
71
|
});
|
|
72
72
|
server.close();
|
|
73
73
|
}
|
|
@@ -9,7 +9,80 @@ import {
|
|
|
9
9
|
} from "./chunk-TJFRPB4N.js";
|
|
10
10
|
|
|
11
11
|
// package.json
|
|
12
|
-
var version = "51.
|
|
12
|
+
var version = "51.3.0";
|
|
13
|
+
|
|
14
|
+
// node/utils.ts
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import { createJiti } from "jiti";
|
|
17
|
+
import YAML from "yaml";
|
|
18
|
+
var jiti;
|
|
19
|
+
function loadModule(absolutePath) {
|
|
20
|
+
jiti ??= createJiti(fileURLToPath(import.meta.url), {
|
|
21
|
+
// Allows changes to take effect
|
|
22
|
+
moduleCache: false
|
|
23
|
+
});
|
|
24
|
+
return jiti.import(absolutePath);
|
|
25
|
+
}
|
|
26
|
+
function stringifyMarkdownTokens(tokens) {
|
|
27
|
+
return tokens.map((token) => token.children?.filter((t) => ["text", "code_inline"].includes(t.type) && !t.content.match(/^\s*$/)).map((t) => t.content.trim()).join(" ")).filter(Boolean).join(" ");
|
|
28
|
+
}
|
|
29
|
+
function generateFontParams(options) {
|
|
30
|
+
const weights = options.weights.flatMap((i) => options.italic ? [`0,${i}`, `1,${i}`] : [`${i}`]).sort().join(";");
|
|
31
|
+
const fontParams = options.webfonts.map((i) => `family=${i.replace(/^(['"])(.*)\1$/, "$1").replace(/\s+/g, "+")}:${options.italic ? "ital," : ""}wght@${weights}`).join("&");
|
|
32
|
+
return fontParams;
|
|
33
|
+
}
|
|
34
|
+
function generateGoogleFontsUrl(options) {
|
|
35
|
+
return `https://fonts.googleapis.com/css2?${generateFontParams(options)}&display=swap`;
|
|
36
|
+
}
|
|
37
|
+
function generateCoollabsFontsUrl(options) {
|
|
38
|
+
return `https://api.fonts.coollabs.io/fonts?${generateFontParams(options)}&display=swap`;
|
|
39
|
+
}
|
|
40
|
+
function updateFrontmatterPatch(source, frontmatter) {
|
|
41
|
+
let doc = source.frontmatterDoc;
|
|
42
|
+
if (!doc) {
|
|
43
|
+
source.frontmatterStyle = "frontmatter";
|
|
44
|
+
source.frontmatterDoc = doc = new YAML.Document({});
|
|
45
|
+
}
|
|
46
|
+
for (const [key, value] of Object.entries(frontmatter)) {
|
|
47
|
+
source.frontmatter[key] = value;
|
|
48
|
+
if (value == null) {
|
|
49
|
+
doc.delete(key);
|
|
50
|
+
} else {
|
|
51
|
+
const valueNode = doc.createNode(value);
|
|
52
|
+
let found = false;
|
|
53
|
+
YAML.visit(doc.contents, {
|
|
54
|
+
Pair(_key, node, path4) {
|
|
55
|
+
if (path4.length === 1 && YAML.isScalar(node.key) && node.key.value === key) {
|
|
56
|
+
node.value = valueNode;
|
|
57
|
+
found = true;
|
|
58
|
+
return YAML.visit.BREAK;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (!found) {
|
|
63
|
+
if (!YAML.isMap(doc.contents))
|
|
64
|
+
doc.contents = doc.createNode({});
|
|
65
|
+
doc.contents.add(
|
|
66
|
+
doc.createPair(key, valueNode)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function getBodyJson(req) {
|
|
73
|
+
return new Promise((resolve9, reject) => {
|
|
74
|
+
let body = "";
|
|
75
|
+
req.on("data", (chunk) => body += chunk);
|
|
76
|
+
req.on("error", reject);
|
|
77
|
+
req.on("end", () => {
|
|
78
|
+
try {
|
|
79
|
+
resolve9(JSON.parse(body) || {});
|
|
80
|
+
} catch (e) {
|
|
81
|
+
reject(e);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
13
86
|
|
|
14
87
|
// node/integrations/themes.ts
|
|
15
88
|
import { existsSync } from "node:fs";
|
|
@@ -108,77 +181,6 @@ function MarkdownItLink(md) {
|
|
|
108
181
|
};
|
|
109
182
|
}
|
|
110
183
|
|
|
111
|
-
// node/utils.ts
|
|
112
|
-
import { fileURLToPath } from "node:url";
|
|
113
|
-
import { createJiti } from "jiti";
|
|
114
|
-
import YAML from "yaml";
|
|
115
|
-
var jiti;
|
|
116
|
-
function loadModule(absolutePath) {
|
|
117
|
-
jiti ??= createJiti(fileURLToPath(import.meta.url));
|
|
118
|
-
return jiti.import(absolutePath);
|
|
119
|
-
}
|
|
120
|
-
function stringifyMarkdownTokens(tokens) {
|
|
121
|
-
return tokens.map((token) => token.children?.filter((t) => ["text", "code_inline"].includes(t.type) && !t.content.match(/^\s*$/)).map((t) => t.content.trim()).join(" ")).filter(Boolean).join(" ");
|
|
122
|
-
}
|
|
123
|
-
function generateFontParams(options) {
|
|
124
|
-
const weights = options.weights.flatMap((i) => options.italic ? [`0,${i}`, `1,${i}`] : [`${i}`]).sort().join(";");
|
|
125
|
-
const fontParams = options.webfonts.map((i) => `family=${i.replace(/^(['"])(.*)\1$/, "$1").replace(/\s+/g, "+")}:${options.italic ? "ital," : ""}wght@${weights}`).join("&");
|
|
126
|
-
return fontParams;
|
|
127
|
-
}
|
|
128
|
-
function generateGoogleFontsUrl(options) {
|
|
129
|
-
return `https://fonts.googleapis.com/css2?${generateFontParams(options)}&display=swap`;
|
|
130
|
-
}
|
|
131
|
-
function generateCoollabsFontsUrl(options) {
|
|
132
|
-
return `https://api.fonts.coollabs.io/fonts?${generateFontParams(options)}&display=swap`;
|
|
133
|
-
}
|
|
134
|
-
function updateFrontmatterPatch(slide, frontmatter) {
|
|
135
|
-
const source = slide.source;
|
|
136
|
-
let doc = source.frontmatterDoc;
|
|
137
|
-
if (!doc) {
|
|
138
|
-
source.frontmatterStyle = "frontmatter";
|
|
139
|
-
source.frontmatterDoc = doc = new YAML.Document({});
|
|
140
|
-
}
|
|
141
|
-
for (const [key, value] of Object.entries(frontmatter)) {
|
|
142
|
-
slide.frontmatter[key] = source.frontmatter[key] = value;
|
|
143
|
-
if (value == null) {
|
|
144
|
-
doc.delete(key);
|
|
145
|
-
} else {
|
|
146
|
-
const valueNode = doc.createNode(value);
|
|
147
|
-
let found = false;
|
|
148
|
-
YAML.visit(doc.contents, {
|
|
149
|
-
Pair(_key, node, path4) {
|
|
150
|
-
if (path4.length === 1 && YAML.isScalar(node.key) && node.key.value === key) {
|
|
151
|
-
node.value = valueNode;
|
|
152
|
-
found = true;
|
|
153
|
-
return YAML.visit.BREAK;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
if (!found) {
|
|
158
|
-
if (!YAML.isMap(doc.contents))
|
|
159
|
-
doc.contents = doc.createNode({});
|
|
160
|
-
doc.contents.add(
|
|
161
|
-
doc.createPair(key, valueNode)
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
function getBodyJson(req) {
|
|
168
|
-
return new Promise((resolve9, reject) => {
|
|
169
|
-
let body = "";
|
|
170
|
-
req.on("data", (chunk) => body += chunk);
|
|
171
|
-
req.on("error", reject);
|
|
172
|
-
req.on("end", () => {
|
|
173
|
-
try {
|
|
174
|
-
resolve9(JSON.parse(body) || {});
|
|
175
|
-
} catch (e) {
|
|
176
|
-
reject(e);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
184
|
// node/vite/compilerFlagsVue.ts
|
|
183
185
|
import { objectEntries } from "@antfu/utils";
|
|
184
186
|
function createVueCompilerFlagsPlugin(options) {
|
|
@@ -210,6 +212,7 @@ function createComponentsPlugin({ clientRoot, roots }, pluginOptions) {
|
|
|
210
212
|
join2(clientRoot, "builtin"),
|
|
211
213
|
...roots.map((i) => join2(i, "components"))
|
|
212
214
|
],
|
|
215
|
+
globsExclude: [],
|
|
213
216
|
include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
|
|
214
217
|
exclude: [],
|
|
215
218
|
resolvers: [
|
|
@@ -1182,8 +1185,10 @@ function createSlidesLoader(options, serverOptions) {
|
|
|
1182
1185
|
}
|
|
1183
1186
|
if (body.note)
|
|
1184
1187
|
slide.note = slide.source.note = body.note;
|
|
1185
|
-
if (body.frontmatter)
|
|
1186
|
-
updateFrontmatterPatch(slide, body.frontmatter);
|
|
1188
|
+
if (body.frontmatter) {
|
|
1189
|
+
updateFrontmatterPatch(slide.source, body.frontmatter);
|
|
1190
|
+
Object.assign(slide.frontmatter, body.frontmatter);
|
|
1191
|
+
}
|
|
1187
1192
|
parser2.prettifySlide(slide.source);
|
|
1188
1193
|
const fileContent = await parser2.save(data.markdownFiles[slide.source.filepath]);
|
|
1189
1194
|
if (body.skipHmr) {
|
|
@@ -2703,6 +2708,7 @@ function getDefine(options) {
|
|
|
2703
2708
|
|
|
2704
2709
|
export {
|
|
2705
2710
|
version,
|
|
2711
|
+
updateFrontmatterPatch,
|
|
2706
2712
|
resolveAddons,
|
|
2707
2713
|
resolveTheme,
|
|
2708
2714
|
getThemeMeta,
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-36LVDMJV.js";
|
|
4
4
|
import {
|
|
5
5
|
getThemeMeta,
|
|
6
6
|
loadSetups,
|
|
@@ -8,8 +8,9 @@ import {
|
|
|
8
8
|
resolveAddons,
|
|
9
9
|
resolveOptions,
|
|
10
10
|
resolveTheme,
|
|
11
|
+
updateFrontmatterPatch,
|
|
11
12
|
version
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7MVSIUA5.js";
|
|
13
14
|
import {
|
|
14
15
|
getRoots,
|
|
15
16
|
isInstalledGlobally,
|
|
@@ -210,7 +211,7 @@ cli.command(
|
|
|
210
211
|
name: "r",
|
|
211
212
|
fullname: "restart",
|
|
212
213
|
action() {
|
|
213
|
-
|
|
214
|
+
restartServer();
|
|
214
215
|
}
|
|
215
216
|
},
|
|
216
217
|
{
|
|
@@ -337,7 +338,7 @@ cli.command(
|
|
|
337
338
|
}).strict().help(),
|
|
338
339
|
async (args) => {
|
|
339
340
|
const { entry, theme, base, download, out, inspect } = args;
|
|
340
|
-
const { build } = await import("./build-
|
|
341
|
+
const { build } = await import("./build-ILXZPI57.js");
|
|
341
342
|
for (const entryFile of entry) {
|
|
342
343
|
const options = await resolveOptions({ entry: entryFile, theme, inspect, download, base }, "build");
|
|
343
344
|
printInfo(options);
|
|
@@ -392,16 +393,18 @@ cli.command(
|
|
|
392
393
|
process.exit(1);
|
|
393
394
|
}
|
|
394
395
|
const [name, root] = await resolveTheme(themeRaw, entry);
|
|
396
|
+
await fs.mkdir(path.resolve(dir), { recursive: true });
|
|
395
397
|
await fs.cp(
|
|
396
398
|
root,
|
|
397
399
|
path.resolve(dir),
|
|
398
400
|
{
|
|
399
|
-
|
|
401
|
+
recursive: true,
|
|
402
|
+
filter: (i) => !/node_modules|\.git/.test(path.relative(root, i))
|
|
400
403
|
}
|
|
401
404
|
);
|
|
402
405
|
const dirPath = `./${dir}`;
|
|
403
406
|
const firstSlide = data.entry.slides[0];
|
|
404
|
-
firstSlide
|
|
407
|
+
updateFrontmatterPatch(firstSlide, { theme: dirPath });
|
|
405
408
|
parser.prettifySlide(firstSlide);
|
|
406
409
|
await parser.save(data.entry);
|
|
407
410
|
console.log(`Theme "${name}" ejected successfully to "${dirPath}"`);
|
|
@@ -419,7 +422,7 @@ cli.command(
|
|
|
419
422
|
(args) => exportOptions(commonOptions(args)).strict().help(),
|
|
420
423
|
async (args) => {
|
|
421
424
|
const { entry, theme } = args;
|
|
422
|
-
const { exportSlides, getExportOptions } = await import("./export-
|
|
425
|
+
const { exportSlides, getExportOptions } = await import("./export-5TR5BGLG.js");
|
|
423
426
|
const port = await getPort(12445);
|
|
424
427
|
let warned = false;
|
|
425
428
|
for (const entryFile of entry) {
|
|
@@ -446,7 +449,7 @@ cli.command(
|
|
|
446
449
|
port,
|
|
447
450
|
...getExportOptions({ ...args, entry: entryFile }, options)
|
|
448
451
|
});
|
|
449
|
-
console.log(`${green(" \u2713 ")}${dim("exported to ")}
|
|
452
|
+
console.log(`${green(" \u2713 ")}${dim("exported to ")}${result}
|
|
450
453
|
`);
|
|
451
454
|
server.close();
|
|
452
455
|
}
|
|
@@ -478,7 +481,7 @@ cli.command(
|
|
|
478
481
|
timeout,
|
|
479
482
|
wait
|
|
480
483
|
}) => {
|
|
481
|
-
const { exportNotes } = await import("./export-
|
|
484
|
+
const { exportNotes } = await import("./export-5TR5BGLG.js");
|
|
482
485
|
const port = await getPort(12445);
|
|
483
486
|
for (const entryFile of entry) {
|
|
484
487
|
const options = await resolveOptions({ entry: entryFile }, "export");
|
|
@@ -497,7 +500,7 @@ cli.command(
|
|
|
497
500
|
timeout,
|
|
498
501
|
wait
|
|
499
502
|
});
|
|
500
|
-
console.log(`${green(" \u2713 ")}${dim("exported to ")}
|
|
503
|
+
console.log(`${green(" \u2713 ")}${dim("exported to ")}${result}
|
|
501
504
|
`);
|
|
502
505
|
server.close();
|
|
503
506
|
}
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
// node/commands/export.ts
|
|
6
6
|
import { Buffer } from "node:buffer";
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
|
-
import path from "node:path";
|
|
8
|
+
import path, { dirname, relative } from "node:path";
|
|
9
9
|
import process from "node:process";
|
|
10
|
-
import { clearUndefined, slash } from "@antfu/utils";
|
|
10
|
+
import { clearUndefined, ensureSuffix, slash } from "@antfu/utils";
|
|
11
11
|
import { outlinePdfFactory } from "@lillallol/outline-pdf";
|
|
12
12
|
import { parseRangeString } from "@slidev/parser/core";
|
|
13
13
|
import { blue, cyan, dim, green, yellow } from "ansis";
|
|
@@ -144,6 +144,23 @@ async function exportSlides({
|
|
|
144
144
|
});
|
|
145
145
|
const page = await context.newPage();
|
|
146
146
|
const progress = createSlidevProgress(!perSlide);
|
|
147
|
+
progress.start(pages.length);
|
|
148
|
+
if (format === "pdf") {
|
|
149
|
+
await genPagePdf();
|
|
150
|
+
} else if (format === "png") {
|
|
151
|
+
await genPagePng(output);
|
|
152
|
+
} else if (format === "md") {
|
|
153
|
+
await genPageMd();
|
|
154
|
+
} else if (format === "pptx") {
|
|
155
|
+
const buffers = await genPagePng(false);
|
|
156
|
+
await genPagePptx(buffers);
|
|
157
|
+
} else {
|
|
158
|
+
throw new Error(`[slidev] Unsupported exporting format "${format}"`);
|
|
159
|
+
}
|
|
160
|
+
progress.stop();
|
|
161
|
+
browser.close();
|
|
162
|
+
const relativeOutput = slash(relative(".", output));
|
|
163
|
+
return relativeOutput.startsWith(".") ? relativeOutput : `./${relativeOutput}`;
|
|
147
164
|
async function go(no, clicks) {
|
|
148
165
|
const query = new URLSearchParams();
|
|
149
166
|
if (withClicks)
|
|
@@ -303,8 +320,6 @@ async function exportSlides({
|
|
|
303
320
|
async function genPagePngOnePiece(writeToDisk) {
|
|
304
321
|
const result = [];
|
|
305
322
|
await go("print");
|
|
306
|
-
await fs.rm(output, { force: true, recursive: true });
|
|
307
|
-
await fs.mkdir(output, { recursive: true });
|
|
308
323
|
const slideContainers = page.locator(".print-slide-container");
|
|
309
324
|
const count = await slideContainers.count();
|
|
310
325
|
for (let i = 0; i < count; i++) {
|
|
@@ -314,9 +329,10 @@ async function exportSlides({
|
|
|
314
329
|
const buffer = await slideContainers.nth(i).screenshot({
|
|
315
330
|
omitBackground
|
|
316
331
|
});
|
|
317
|
-
|
|
332
|
+
const filename = `${withClicks ? id : slideNo}.png`;
|
|
333
|
+
result.push({ slideIndex: slideNo - 1, buffer, filename });
|
|
318
334
|
if (writeToDisk)
|
|
319
|
-
await fs.writeFile(path.join(
|
|
335
|
+
await fs.writeFile(path.join(writeToDisk, filename), buffer);
|
|
320
336
|
}
|
|
321
337
|
return result;
|
|
322
338
|
}
|
|
@@ -327,10 +343,11 @@ async function exportSlides({
|
|
|
327
343
|
const buffer = await page.screenshot({
|
|
328
344
|
omitBackground
|
|
329
345
|
});
|
|
330
|
-
|
|
346
|
+
const filename = `${no.toString().padStart(2, "0")}${clicks ? `-${clicks}` : ""}.png`;
|
|
347
|
+
result.push({ slideIndex: no - 1, buffer, filename });
|
|
331
348
|
if (writeToDisk) {
|
|
332
349
|
await fs.writeFile(
|
|
333
|
-
path.join(
|
|
350
|
+
path.join(writeToDisk, filename),
|
|
334
351
|
buffer
|
|
335
352
|
);
|
|
336
353
|
}
|
|
@@ -344,25 +361,23 @@ async function exportSlides({
|
|
|
344
361
|
output = `${output}.pdf`;
|
|
345
362
|
return perSlide ? genPagePdfPerSlide() : genPagePdfOnePiece();
|
|
346
363
|
}
|
|
347
|
-
function genPagePng(writeToDisk
|
|
364
|
+
async function genPagePng(writeToDisk) {
|
|
365
|
+
if (writeToDisk) {
|
|
366
|
+
await fs.rm(writeToDisk, { force: true, recursive: true });
|
|
367
|
+
await fs.mkdir(writeToDisk, { recursive: true });
|
|
368
|
+
}
|
|
348
369
|
return perSlide ? genPagePngPerSlide(writeToDisk) : genPagePngOnePiece(writeToDisk);
|
|
349
370
|
}
|
|
350
371
|
async function genPageMd() {
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
const mdImg = `![${slides[slideIndex]?.title}](./${slash(path.join(output, file))})
|
|
372
|
+
const pngs = await genPagePng(dirname(output));
|
|
373
|
+
const content = slides.map(
|
|
374
|
+
({ title, index, note }) => pngs.filter(({ slideIndex }) => slideIndex === index).map(({ filename }) => `
|
|
355
375
|
|
|
356
|
-
|
|
357
|
-
if ((i + 1 === files2.length || getSlideIndex(files2[i + 1]) !== slideIndex) && slides[slideIndex]?.note)
|
|
358
|
-
return `${mdImg}${slides[slideIndex]?.note}
|
|
376
|
+
`).join("") + (note ? `${note.trim()}
|
|
359
377
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (!output.endsWith(".md"))
|
|
364
|
-
output = `${output}.md`;
|
|
365
|
-
await fs.writeFile(output, mds.join(""));
|
|
378
|
+
` : "")
|
|
379
|
+
).join("---\n\n");
|
|
380
|
+
await fs.writeFile(ensureSuffix(".md", output), content);
|
|
366
381
|
}
|
|
367
382
|
async function genPagePptx(pngs) {
|
|
368
383
|
const { default: PptxGenJS } = await import("pptxgenjs");
|
|
@@ -397,10 +412,6 @@ async function exportSlides({
|
|
|
397
412
|
output = `${output}.pptx`;
|
|
398
413
|
await fs.writeFile(output, buffer);
|
|
399
414
|
}
|
|
400
|
-
function getSlideIndex(file) {
|
|
401
|
-
const slideId = file.substring(0, file.indexOf(".")).split("-")[0];
|
|
402
|
-
return Number(slideId) - 1;
|
|
403
|
-
}
|
|
404
415
|
function addPdfMetadata(pdf) {
|
|
405
416
|
const titleSlide = slides[0];
|
|
406
417
|
if (titleSlide?.title)
|
|
@@ -426,25 +437,8 @@ async function exportSlides({
|
|
|
426
437
|
const outline = makeOutline(tocTree);
|
|
427
438
|
return await outlinePdf({ outline, pdf });
|
|
428
439
|
}
|
|
429
|
-
progress.start(pages.length);
|
|
430
|
-
if (format === "pdf") {
|
|
431
|
-
await genPagePdf();
|
|
432
|
-
} else if (format === "png") {
|
|
433
|
-
await genPagePng();
|
|
434
|
-
} else if (format === "md") {
|
|
435
|
-
await genPagePng();
|
|
436
|
-
await genPageMd();
|
|
437
|
-
} else if (format === "pptx") {
|
|
438
|
-
const buffers = await genPagePng(false);
|
|
439
|
-
await genPagePptx(buffers);
|
|
440
|
-
} else {
|
|
441
|
-
throw new Error(`Unsupported exporting format "${format}"`);
|
|
442
|
-
}
|
|
443
|
-
progress.stop();
|
|
444
|
-
browser.close();
|
|
445
|
-
return output;
|
|
446
440
|
}
|
|
447
|
-
function getExportOptions(args, options,
|
|
441
|
+
function getExportOptions(args, options, outFilename) {
|
|
448
442
|
const config = {
|
|
449
443
|
...options.data.config.export,
|
|
450
444
|
...args,
|
|
@@ -474,8 +468,6 @@ function getExportOptions(args, options, outDir, outFilename) {
|
|
|
474
468
|
omitBackground
|
|
475
469
|
} = config;
|
|
476
470
|
outFilename = output || options.data.config.exportFilename || outFilename || `${path.basename(entry, ".md")}-export`;
|
|
477
|
-
if (outDir)
|
|
478
|
-
outFilename = path.join(outDir, outFilename);
|
|
479
471
|
return {
|
|
480
472
|
output: outFilename,
|
|
481
473
|
slides: options.data.slides,
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-36LVDMJV.js";
|
|
4
4
|
import {
|
|
5
5
|
ViteSlidevPlugin,
|
|
6
6
|
createDataUtils,
|
|
7
7
|
parser,
|
|
8
8
|
resolveOptions
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7MVSIUA5.js";
|
|
10
10
|
import "./chunk-TJFRPB4N.js";
|
|
11
11
|
export {
|
|
12
12
|
ViteSlidevPlugin,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "51.
|
|
4
|
+
"version": "51.3.0",
|
|
5
5
|
"description": "Presentation slides for developers",
|
|
6
6
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@unocss/reset": "^66.0.0",
|
|
56
56
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
57
57
|
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
|
58
|
-
"ansis": "^3.
|
|
58
|
+
"ansis": "^3.16.0",
|
|
59
59
|
"chokidar": "^4.0.3",
|
|
60
60
|
"cli-progress": "^3.12.0",
|
|
61
61
|
"connect": "^3.7.0",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"untun": "^0.1.3",
|
|
101
101
|
"uqr": "^0.1.2",
|
|
102
102
|
"vite": "^6.1.1",
|
|
103
|
-
"vite-plugin-inspect": "^
|
|
103
|
+
"vite-plugin-inspect": "^11.0.0",
|
|
104
104
|
"vite-plugin-remote-assets": "^1.0.0",
|
|
105
105
|
"vite-plugin-static-copy": "^2.2.0",
|
|
106
106
|
"vite-plugin-vue-server-ref": "^1.0.0",
|
|
@@ -108,9 +108,9 @@
|
|
|
108
108
|
"vue": "^3.5.13",
|
|
109
109
|
"yaml": "^2.7.0",
|
|
110
110
|
"yargs": "^17.7.2",
|
|
111
|
-
"@slidev/
|
|
112
|
-
"@slidev/
|
|
113
|
-
"@slidev/types": "51.
|
|
111
|
+
"@slidev/client": "51.3.0",
|
|
112
|
+
"@slidev/parser": "51.3.0",
|
|
113
|
+
"@slidev/types": "51.3.0"
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
116
|
"@hedgedoc/markdown-it-plugins": "^2.1.4",
|