@slidev/cli 0.49.3 → 0.49.4
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-B7KZ5KHE.mjs → build-6VAW6JNE.mjs} +2 -2
- package/dist/{chunk-OL3F2SCP.mjs → chunk-R4VWCFXW.mjs} +1 -1
- package/dist/{chunk-NQBDNZ65.mjs → chunk-UUONTUWJ.mjs} +1 -1
- package/dist/cli.mjs +11 -6
- package/dist/{export-WUI5C4U3.mjs → export-Q4LURPEZ.mjs} +75 -33
- package/dist/index.mjs +2 -2
- package/package.json +15 -14
- package/template.md +1 -1
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
ViteSlidevPlugin,
|
|
3
3
|
getIndexHtml,
|
|
4
4
|
mergeViteConfigs
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UUONTUWJ.mjs";
|
|
6
6
|
import "./chunk-LOUKLO2C.mjs";
|
|
7
7
|
import "./chunk-RG2EEPCO.mjs";
|
|
8
8
|
import "./chunk-BXO7ZPPU.mjs";
|
|
@@ -63,7 +63,7 @@ async function build(options, viteConfig = {}, args) {
|
|
|
63
63
|
await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
|
|
64
64
|
`, "utf-8");
|
|
65
65
|
if ([true, "true", "auto"].includes(options.data.config.download)) {
|
|
66
|
-
const { exportSlides, getExportOptions } = await import("./export-
|
|
66
|
+
const { exportSlides, getExportOptions } = await import("./export-Q4LURPEZ.mjs");
|
|
67
67
|
const port = 12445;
|
|
68
68
|
const app = connect();
|
|
69
69
|
const server = http.createServer(app);
|
package/dist/cli.mjs
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
resolveAddons,
|
|
6
6
|
resolveOptions,
|
|
7
7
|
resolveTheme
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-R4VWCFXW.mjs";
|
|
9
9
|
import {
|
|
10
10
|
version
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-UUONTUWJ.mjs";
|
|
12
12
|
import {
|
|
13
13
|
loadSetups
|
|
14
14
|
} from "./chunk-LOUKLO2C.mjs";
|
|
@@ -168,6 +168,11 @@ cli.command(
|
|
|
168
168
|
restartServer();
|
|
169
169
|
return false;
|
|
170
170
|
}
|
|
171
|
+
if (newData.features.katex && !oldData.features.katex || newData.features.monaco && !oldData.features.monaco) {
|
|
172
|
+
console.log(yellow("\n restarting on feature change\n"));
|
|
173
|
+
restartServer();
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
171
176
|
return newData;
|
|
172
177
|
}
|
|
173
178
|
}
|
|
@@ -323,7 +328,7 @@ cli.command(
|
|
|
323
328
|
}).strict().help(),
|
|
324
329
|
async (args) => {
|
|
325
330
|
const { entry, theme, base, download, out, inspect } = args;
|
|
326
|
-
const { build } = await import("./build-
|
|
331
|
+
const { build } = await import("./build-6VAW6JNE.mjs");
|
|
327
332
|
for (const entryFile of entry) {
|
|
328
333
|
const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
|
|
329
334
|
if (download && !options.data.config.download)
|
|
@@ -403,7 +408,7 @@ cli.command(
|
|
|
403
408
|
(args) => exportOptions(commonOptions(args)).strict().help(),
|
|
404
409
|
async (args) => {
|
|
405
410
|
const { entry, theme } = args;
|
|
406
|
-
const { exportSlides, getExportOptions } = await import("./export-
|
|
411
|
+
const { exportSlides, getExportOptions } = await import("./export-Q4LURPEZ.mjs");
|
|
407
412
|
const port = await getPort(12445);
|
|
408
413
|
for (const entryFile of entry) {
|
|
409
414
|
const options = await resolveOptions({ entry: entryFile, theme }, "export");
|
|
@@ -452,7 +457,7 @@ cli.command(
|
|
|
452
457
|
timeout,
|
|
453
458
|
wait
|
|
454
459
|
}) => {
|
|
455
|
-
const { exportNotes } = await import("./export-
|
|
460
|
+
const { exportNotes } = await import("./export-Q4LURPEZ.mjs");
|
|
456
461
|
const port = await getPort(12445);
|
|
457
462
|
for (const entryFile of entry) {
|
|
458
463
|
const options = await resolveOptions({ entry: entryFile }, "export");
|
|
@@ -496,7 +501,7 @@ function exportOptions(args) {
|
|
|
496
501
|
describe: "path to the output"
|
|
497
502
|
}).option("format", {
|
|
498
503
|
type: "string",
|
|
499
|
-
choices: ["pdf", "png", "md"],
|
|
504
|
+
choices: ["pdf", "png", "pptx", "md"],
|
|
500
505
|
describe: "output format"
|
|
501
506
|
}).option("timeout", {
|
|
502
507
|
type: "number",
|
|
@@ -152,8 +152,7 @@ async function exportSlides({
|
|
|
152
152
|
query.set("range", range);
|
|
153
153
|
if (clicks)
|
|
154
154
|
query.set("clicks", clicks);
|
|
155
|
-
const
|
|
156
|
-
const url = routerMode === "hash" ? `http://localhost:${port}${base}#${path2}` : `http://localhost:${port}${base}${path2}`;
|
|
155
|
+
const url = routerMode === "hash" ? `http://localhost:${port}${base}?${query}#${no}` : `http://localhost:${port}${base}${no}?${query}`;
|
|
157
156
|
await page.goto(url, {
|
|
158
157
|
waitUntil: "networkidle",
|
|
159
158
|
timeout
|
|
@@ -228,13 +227,13 @@ async function exportSlides({
|
|
|
228
227
|
function getClicksFromUrl(url) {
|
|
229
228
|
return url.match(/clicks=([1-9]\d*)/)?.[1];
|
|
230
229
|
}
|
|
231
|
-
async function genPageWithClicks(fn,
|
|
232
|
-
await fn(
|
|
230
|
+
async function genPageWithClicks(fn, no, clicks) {
|
|
231
|
+
await fn(no, clicks);
|
|
233
232
|
if (withClicks) {
|
|
234
233
|
await page.keyboard.press("ArrowRight", { delay: 100 });
|
|
235
234
|
const _clicks = getClicksFromUrl(page.url());
|
|
236
235
|
if (_clicks && clicks !== _clicks)
|
|
237
|
-
await genPageWithClicks(fn,
|
|
236
|
+
await genPageWithClicks(fn, no, _clicks);
|
|
238
237
|
}
|
|
239
238
|
}
|
|
240
239
|
async function genPagePdfPerSlide() {
|
|
@@ -298,50 +297,57 @@ async function exportSlides({
|
|
|
298
297
|
pdfData = Buffer.from(await pdf.save());
|
|
299
298
|
await fs.writeFile(output, pdfData);
|
|
300
299
|
}
|
|
301
|
-
async function genPagePngOnePiece() {
|
|
300
|
+
async function genPagePngOnePiece(writeToDisk) {
|
|
301
|
+
const result = [];
|
|
302
302
|
await go("print");
|
|
303
303
|
await fs.emptyDir(output);
|
|
304
|
-
const
|
|
305
|
-
const count = await
|
|
304
|
+
const slideContainers = page.locator(".print-slide-container");
|
|
305
|
+
const count = await slideContainers.count();
|
|
306
306
|
for (let i = 0; i < count; i++) {
|
|
307
307
|
progress.update(i + 1);
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const buffer = await
|
|
311
|
-
|
|
308
|
+
const id = await slideContainers.nth(i).getAttribute("id") || "";
|
|
309
|
+
const slideNo = +id.split("-")[0];
|
|
310
|
+
const buffer = await slideContainers.nth(i).screenshot();
|
|
311
|
+
result.push({ slideIndex: slideNo - 1, buffer });
|
|
312
|
+
if (writeToDisk)
|
|
313
|
+
await fs.writeFile(path.join(output, `${withClicks ? id : slideNo}.png`), buffer);
|
|
312
314
|
}
|
|
315
|
+
return result;
|
|
313
316
|
}
|
|
314
|
-
async function genPagePngPerSlide() {
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
await
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
317
|
+
async function genPagePngPerSlide(writeToDisk) {
|
|
318
|
+
const result = [];
|
|
319
|
+
const genScreenshot = async (no, clicks) => {
|
|
320
|
+
await go(no, clicks);
|
|
321
|
+
const buffer = await page.screenshot();
|
|
322
|
+
result.push({ slideIndex: no - 1, buffer });
|
|
323
|
+
if (writeToDisk) {
|
|
324
|
+
await fs.writeFile(
|
|
325
|
+
path.join(output, `${no.toString().padStart(2, "0")}${clicks ? `-${clicks}` : ""}.png`),
|
|
326
|
+
buffer
|
|
327
|
+
);
|
|
328
|
+
}
|
|
324
329
|
};
|
|
325
|
-
for (const
|
|
326
|
-
await genPageWithClicks(genScreenshot,
|
|
330
|
+
for (const no of pages)
|
|
331
|
+
await genPageWithClicks(genScreenshot, no);
|
|
332
|
+
return result;
|
|
327
333
|
}
|
|
328
334
|
function genPagePdf() {
|
|
329
335
|
if (!output.endsWith(".pdf"))
|
|
330
336
|
output = `${output}.pdf`;
|
|
331
337
|
return perSlide ? genPagePdfPerSlide() : genPagePdfOnePiece();
|
|
332
338
|
}
|
|
333
|
-
function genPagePng() {
|
|
334
|
-
return perSlide ? genPagePngPerSlide() : genPagePngOnePiece();
|
|
339
|
+
function genPagePng(writeToDisk = true) {
|
|
340
|
+
return perSlide ? genPagePngPerSlide(writeToDisk) : genPagePngOnePiece(writeToDisk);
|
|
335
341
|
}
|
|
336
|
-
async function genPageMd(
|
|
342
|
+
async function genPageMd() {
|
|
337
343
|
const files = await fs.readdir(output);
|
|
338
344
|
const mds = files.map((file, i, files2) => {
|
|
339
345
|
const slideIndex = getSlideIndex(file);
|
|
340
|
-
const mdImg = `![${
|
|
346
|
+
const mdImg = `![${slides[slideIndex]?.title}](./${path.join(output, file)})
|
|
341
347
|
|
|
342
348
|
`;
|
|
343
|
-
if ((i + 1 === files2.length || getSlideIndex(files2[i + 1]) !== slideIndex) &&
|
|
344
|
-
return `${mdImg}${
|
|
349
|
+
if ((i + 1 === files2.length || getSlideIndex(files2[i + 1]) !== slideIndex) && slides[slideIndex]?.note)
|
|
350
|
+
return `${mdImg}${slides[slideIndex]?.note}
|
|
345
351
|
|
|
346
352
|
`;
|
|
347
353
|
return mdImg;
|
|
@@ -350,6 +356,39 @@ async function exportSlides({
|
|
|
350
356
|
output = `${output}.md`;
|
|
351
357
|
await fs.writeFile(output, mds.join(""));
|
|
352
358
|
}
|
|
359
|
+
async function genPagePptx(pngs) {
|
|
360
|
+
const { default: PptxGenJS } = await import("pptxgenjs");
|
|
361
|
+
const pptx = new PptxGenJS();
|
|
362
|
+
const layoutName = `${width}x${height}`;
|
|
363
|
+
pptx.defineLayout({
|
|
364
|
+
name: layoutName,
|
|
365
|
+
width: width / 96,
|
|
366
|
+
height: height / 96
|
|
367
|
+
});
|
|
368
|
+
pptx.layout = layoutName;
|
|
369
|
+
const titleSlide = slides[0];
|
|
370
|
+
pptx.author = titleSlide?.frontmatter?.author;
|
|
371
|
+
pptx.company = "Created using Slidev";
|
|
372
|
+
if (titleSlide?.title)
|
|
373
|
+
pptx.title = titleSlide?.title;
|
|
374
|
+
if (titleSlide?.frontmatter?.info)
|
|
375
|
+
pptx.subject = titleSlide?.frontmatter?.info;
|
|
376
|
+
pngs.forEach(({ slideIndex, buffer: buffer2 }) => {
|
|
377
|
+
const slide = pptx.addSlide();
|
|
378
|
+
slide.background = {
|
|
379
|
+
data: `data:image/png;base64,${buffer2.toString("base64")}`
|
|
380
|
+
};
|
|
381
|
+
const note = slides[slideIndex].note;
|
|
382
|
+
if (note)
|
|
383
|
+
slide.addNotes(note);
|
|
384
|
+
});
|
|
385
|
+
const buffer = await pptx.write({
|
|
386
|
+
outputType: "nodebuffer"
|
|
387
|
+
});
|
|
388
|
+
if (!output.endsWith(".pptx"))
|
|
389
|
+
output = `${output}.pptx`;
|
|
390
|
+
await fs.writeFile(output, buffer);
|
|
391
|
+
}
|
|
353
392
|
function getSlideIndex(file) {
|
|
354
393
|
const slideId = file.substring(0, file.indexOf(".")).split("-")[0];
|
|
355
394
|
return Number(slideId) - 1;
|
|
@@ -386,7 +425,10 @@ async function exportSlides({
|
|
|
386
425
|
await genPagePng();
|
|
387
426
|
} else if (format === "md") {
|
|
388
427
|
await genPagePng();
|
|
389
|
-
await genPageMd(
|
|
428
|
+
await genPageMd();
|
|
429
|
+
} else if (format === "pptx") {
|
|
430
|
+
const buffers = await genPagePng(false);
|
|
431
|
+
await genPagePptx(buffers);
|
|
390
432
|
} else {
|
|
391
433
|
throw new Error(`Unsupported exporting format "${format}"`);
|
|
392
434
|
}
|
|
@@ -434,11 +476,11 @@ function getExportOptions(args, options, outDir, outFilename) {
|
|
|
434
476
|
routerMode: options.data.config.routerMode,
|
|
435
477
|
width: options.data.config.canvasWidth,
|
|
436
478
|
height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
|
|
437
|
-
withClicks: withClicks
|
|
479
|
+
withClicks: withClicks ?? format === "pptx",
|
|
438
480
|
executablePath,
|
|
439
481
|
withToc: withToc || false,
|
|
440
482
|
perSlide: perSlide || false,
|
|
441
|
-
scale: scale ||
|
|
483
|
+
scale: scale || 2
|
|
442
484
|
};
|
|
443
485
|
}
|
|
444
486
|
async function importPlaywright() {
|
package/dist/index.mjs
CHANGED
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
createServer,
|
|
3
3
|
parser,
|
|
4
4
|
resolveOptions
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-R4VWCFXW.mjs";
|
|
6
6
|
import {
|
|
7
7
|
ViteSlidevPlugin
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-UUONTUWJ.mjs";
|
|
9
9
|
import "./chunk-LOUKLO2C.mjs";
|
|
10
10
|
import "./chunk-RG2EEPCO.mjs";
|
|
11
11
|
import "./chunk-BXO7ZPPU.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/cli",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.4",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@antfu/ni": "^0.21.12",
|
|
46
46
|
"@antfu/utils": "^0.7.8",
|
|
47
|
-
"@iconify-json/carbon": "^1.1.
|
|
47
|
+
"@iconify-json/carbon": "^1.1.34",
|
|
48
48
|
"@iconify-json/ph": "^1.1.13",
|
|
49
49
|
"@iconify-json/svg-spinners": "^1.1.2",
|
|
50
50
|
"@lillallol/outline-pdf": "^4.0.0",
|
|
51
|
-
"@shikijs/markdown-it": "^1.
|
|
52
|
-
"@shikijs/twoslash": "^1.
|
|
53
|
-
"@shikijs/vitepress-twoslash": "^1.
|
|
54
|
-
"@unocss/extractor-mdc": "^0.60.
|
|
55
|
-
"@unocss/reset": "^0.60.
|
|
51
|
+
"@shikijs/markdown-it": "^1.6.0",
|
|
52
|
+
"@shikijs/twoslash": "^1.6.0",
|
|
53
|
+
"@shikijs/vitepress-twoslash": "^1.6.0",
|
|
54
|
+
"@unocss/extractor-mdc": "^0.60.3",
|
|
55
|
+
"@unocss/reset": "^0.60.3",
|
|
56
56
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
57
57
|
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
|
58
58
|
"chokidar": "^3.6.0",
|
|
@@ -78,23 +78,24 @@
|
|
|
78
78
|
"markdown-it-footnote": "^4.0.0",
|
|
79
79
|
"markdown-it-mdc": "^0.2.3",
|
|
80
80
|
"mlly": "^1.7.0",
|
|
81
|
-
"monaco-editor": "^0.
|
|
81
|
+
"monaco-editor": "^0.49.0",
|
|
82
82
|
"open": "^10.1.0",
|
|
83
83
|
"pdf-lib": "^1.17.1",
|
|
84
84
|
"plantuml-encoder": "^1.4.0",
|
|
85
85
|
"postcss-nested": "^6.0.1",
|
|
86
|
+
"pptxgenjs": "^3.12.0",
|
|
86
87
|
"prismjs": "^1.29.0",
|
|
87
88
|
"prompts": "^2.4.2",
|
|
88
89
|
"public-ip": "^6.0.2",
|
|
89
90
|
"resolve-from": "^5.0.0",
|
|
90
91
|
"resolve-global": "^2.0.0",
|
|
91
92
|
"semver": "^7.6.2",
|
|
92
|
-
"shiki": "^1.
|
|
93
|
+
"shiki": "^1.6.0",
|
|
93
94
|
"shiki-magic-move": "^0.4.2",
|
|
94
95
|
"sirv": "^2.0.4",
|
|
95
96
|
"source-map-js": "^1.2.0",
|
|
96
97
|
"typescript": "^5.4.5",
|
|
97
|
-
"unocss": "^0.60.
|
|
98
|
+
"unocss": "^0.60.3",
|
|
98
99
|
"unplugin-icons": "^0.19.0",
|
|
99
100
|
"unplugin-vue-components": "^0.27.0",
|
|
100
101
|
"unplugin-vue-markdown": "^0.26.2",
|
|
@@ -103,14 +104,14 @@
|
|
|
103
104
|
"vite": "^5.2.11",
|
|
104
105
|
"vite-plugin-inspect": "^0.8.4",
|
|
105
106
|
"vite-plugin-remote-assets": "^0.4.1",
|
|
106
|
-
"vite-plugin-static-copy": "^1.0.
|
|
107
|
+
"vite-plugin-static-copy": "^1.0.5",
|
|
107
108
|
"vite-plugin-vue-server-ref": "^0.4.2",
|
|
108
109
|
"vitefu": "^0.2.5",
|
|
109
110
|
"vue": "^3.4.27",
|
|
110
111
|
"yargs": "^17.7.2",
|
|
111
|
-
"@slidev/client": "0.49.
|
|
112
|
-
"@slidev/
|
|
113
|
-
"@slidev/
|
|
112
|
+
"@slidev/client": "0.49.4",
|
|
113
|
+
"@slidev/types": "0.49.4",
|
|
114
|
+
"@slidev/parser": "0.49.4"
|
|
114
115
|
},
|
|
115
116
|
"devDependencies": {
|
|
116
117
|
"@hedgedoc/markdown-it-plugins": "^2.1.4",
|
package/template.md
CHANGED
|
@@ -56,7 +56,7 @@ Slidev is a slides maker and presenter designed for developers, consist of the f
|
|
|
56
56
|
- 🧑💻 **Developer Friendly** - code highlighting, live coding with autocompletion
|
|
57
57
|
- 🤹 **Interactive** - embedding Vue components to enhance your expressions
|
|
58
58
|
- 🎥 **Recording** - built-in recording and camera view
|
|
59
|
-
- 📤 **Portable** - export into PDF, PNGs, or even a hostable SPA
|
|
59
|
+
- 📤 **Portable** - export into PDF, PPTX, PNGs, or even a hostable SPA
|
|
60
60
|
- 🛠 **Hackable** - anything possible on a webpage
|
|
61
61
|
|
|
62
62
|
<br>
|