@slidev/cli 52.14.2 → 52.15.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-DvtR2mFf.mjs → build-yk6Ejluk.mjs} +29 -21
- package/dist/cli.mjs +15 -9
- package/dist/{export-C4evmDwN.mjs → export-DA_9kPXd.mjs} +4 -3
- package/dist/index.mjs +3 -3
- package/dist/{resolver-B4CxEjJF.mjs → resolver-XedCEhxI.mjs} +2 -1
- package/dist/{serve-D_ugeQhq.mjs → serve-CYSWeFFN.mjs} +1 -1
- package/dist/{shared-ZIXcnTKJ.mjs → shared-ClfjhvJo.mjs} +486 -450
- package/package.json +32 -31
- package/skills/slidev/references/api-slide-hooks.md +2 -2
- package/skills/slidev/references/core-global-context.md +2 -2
- /package/skills/slidev/references/{syntax-mdc.md → syntax-comark.md} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./resolver-
|
|
2
|
-
import { t as resolveViteConfigs } from "./shared-
|
|
1
|
+
import "./resolver-XedCEhxI.mjs";
|
|
2
|
+
import { t as resolveViteConfigs } from "./shared-ClfjhvJo.mjs";
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import { build as build$1 } from "vite";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
@@ -10,25 +10,33 @@ import sirv from "sirv";
|
|
|
10
10
|
|
|
11
11
|
//#region node/commands/build.ts
|
|
12
12
|
async function build(options, viteConfig = {}, args) {
|
|
13
|
-
const
|
|
14
|
-
let originalIndexHTML;
|
|
15
|
-
if (existsSync(indexPath)) originalIndexHTML = await fs$1.readFile(indexPath, "utf-8");
|
|
16
|
-
await fs$1.writeFile(indexPath, options.utils.indexHtml, "utf-8");
|
|
13
|
+
const indexHtmlId = resolve(options.userRoot, "index.html");
|
|
17
14
|
let config = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
await build$1(await resolveViteConfigs(options, {
|
|
16
|
+
plugins: [{
|
|
17
|
+
name: "slidev:build",
|
|
18
|
+
configResolved(_config) {
|
|
19
|
+
config = _config;
|
|
20
|
+
},
|
|
21
|
+
resolveId: {
|
|
22
|
+
order: "pre",
|
|
23
|
+
handler(id) {
|
|
24
|
+
if (id === indexHtmlId) return id;
|
|
25
|
+
return null;
|
|
24
26
|
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
},
|
|
28
|
+
load: {
|
|
29
|
+
order: "pre",
|
|
30
|
+
handler(id) {
|
|
31
|
+
if (id === indexHtmlId) return options.utils.indexHtml;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}],
|
|
35
|
+
build: {
|
|
36
|
+
chunkSizeWarningLimit: 2e3,
|
|
37
|
+
rollupOptions: { input: { index: indexHtmlId } }
|
|
38
|
+
}
|
|
39
|
+
}, viteConfig, "build"));
|
|
32
40
|
const outDir = resolve(options.userRoot, config.build.outDir);
|
|
33
41
|
if (options.data.config.seoMeta?.ogImage === "auto" || options.data.config.seoMeta?.ogImage?.startsWith(".")) {
|
|
34
42
|
const filename = options.data.config.seoMeta?.ogImage === "auto" ? "og-image.png" : options.data.config.seoMeta.ogImage;
|
|
@@ -45,7 +53,7 @@ async function build(options, viteConfig = {}, args) {
|
|
|
45
53
|
dev: true
|
|
46
54
|
}));
|
|
47
55
|
server.listen(port);
|
|
48
|
-
const { exportSlides } = await import("./export-
|
|
56
|
+
const { exportSlides } = await import("./export-DA_9kPXd.mjs");
|
|
49
57
|
const tempDir = resolve(outDir, "temp");
|
|
50
58
|
await fs$1.mkdir(tempDir, { recursive: true });
|
|
51
59
|
await exportSlides({
|
|
@@ -86,7 +94,7 @@ async function build(options, viteConfig = {}, args) {
|
|
|
86
94
|
"true",
|
|
87
95
|
"auto"
|
|
88
96
|
].includes(options.data.config.download)) {
|
|
89
|
-
const { exportSlides, getExportOptions } = await import("./export-
|
|
97
|
+
const { exportSlides, getExportOptions } = await import("./export-DA_9kPXd.mjs");
|
|
90
98
|
const port = 12445;
|
|
91
99
|
const app = connect();
|
|
92
100
|
const server = http.createServer(app);
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as resolveEntry, n as getRoots, r as isInstalledGlobally } from "./resolver-
|
|
2
|
-
import { a as parser, c as resolveAddons, d as updateFrontmatterPatch, i as resolveOptions, l as version, o as getThemeMeta, s as resolveTheme, u as loadSetups } from "./shared-
|
|
3
|
-
import { t as createServer } from "./serve-
|
|
1
|
+
import { i as resolveEntry, n as getRoots, r as isInstalledGlobally } from "./resolver-XedCEhxI.mjs";
|
|
2
|
+
import { a as parser, c as resolveAddons, d as updateFrontmatterPatch, i as resolveOptions, l as version, o as getThemeMeta, s as resolveTheme, u as loadSetups } from "./shared-ClfjhvJo.mjs";
|
|
3
|
+
import { t as createServer } from "./serve-CYSWeFFN.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import fs from "node:fs/promises";
|
|
@@ -31,6 +31,7 @@ function setupPreparser() {
|
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region node/cli.ts
|
|
34
|
+
const RE_NODE_MODULES_OR_GIT = /node_modules|\.git/;
|
|
34
35
|
const CONFIG_RESTART_FIELDS = [
|
|
35
36
|
"monaco",
|
|
36
37
|
"routerMode",
|
|
@@ -283,13 +284,17 @@ cli.command("build [entry..]", "Build hostable SPA", (args) => exportOptions(com
|
|
|
283
284
|
}).option("without-notes", {
|
|
284
285
|
type: "boolean",
|
|
285
286
|
describe: "exclude speaker notes from the built output"
|
|
287
|
+
}).option("router-mode", {
|
|
288
|
+
type: "string",
|
|
289
|
+
choices: ["hash", "history"],
|
|
290
|
+
describe: "override routerMode in the built output (hash for subdirectory deploys like GitHub Pages)"
|
|
286
291
|
}).option("inspect", {
|
|
287
292
|
default: false,
|
|
288
293
|
type: "boolean",
|
|
289
294
|
describe: "enable the inspect plugin for debugging"
|
|
290
295
|
}).strict().help(), async (args) => {
|
|
291
|
-
const { entry, theme, base, download, out, inspect, "without-notes": withoutNotes } = args;
|
|
292
|
-
const { build } = await import("./build-
|
|
296
|
+
const { entry, theme, base, download, out, inspect, "without-notes": withoutNotes, "router-mode": routerMode } = args;
|
|
297
|
+
const { build } = await import("./build-yk6Ejluk.mjs");
|
|
293
298
|
for (const entryFile of entry) {
|
|
294
299
|
const options = await resolveOptions({
|
|
295
300
|
entry: entryFile,
|
|
@@ -297,7 +302,8 @@ cli.command("build [entry..]", "Build hostable SPA", (args) => exportOptions(com
|
|
|
297
302
|
inspect,
|
|
298
303
|
download,
|
|
299
304
|
base,
|
|
300
|
-
withoutNotes
|
|
305
|
+
withoutNotes,
|
|
306
|
+
routerMode
|
|
301
307
|
}, "build");
|
|
302
308
|
printInfo(options);
|
|
303
309
|
await build(options, {
|
|
@@ -338,7 +344,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
|
|
|
338
344
|
await fs.mkdir(path.resolve(dir), { recursive: true });
|
|
339
345
|
await fs.cp(root, path.resolve(dir), {
|
|
340
346
|
recursive: true,
|
|
341
|
-
filter: (i) =>
|
|
347
|
+
filter: (i) => !RE_NODE_MODULES_OR_GIT.test(path.relative(root, i))
|
|
342
348
|
});
|
|
343
349
|
const dirPath = `./${dir}`;
|
|
344
350
|
const firstSlide = data.entry.slides[0];
|
|
@@ -353,7 +359,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
|
|
|
353
359
|
});
|
|
354
360
|
cli.command("export [entry..]", "Export slides to PDF", (args) => exportOptions(commonOptions(args)).strict().help(), async (args) => {
|
|
355
361
|
const { entry, theme } = args;
|
|
356
|
-
const { exportSlides, getExportOptions } = await import("./export-
|
|
362
|
+
const { exportSlides, getExportOptions } = await import("./export-DA_9kPXd.mjs");
|
|
357
363
|
const candidatePort = await getPort(12445);
|
|
358
364
|
let warned = false;
|
|
359
365
|
for (const entryFile of entry) {
|
|
@@ -405,7 +411,7 @@ cli.command("export-notes [entry..]", "Export slide notes to PDF", (args) => arg
|
|
|
405
411
|
type: "number",
|
|
406
412
|
describe: "wait for the specified ms before exporting"
|
|
407
413
|
}).strict().help(), async ({ entry, output, timeout, wait }) => {
|
|
408
|
-
const { exportNotes } = await import("./export-
|
|
414
|
+
const { exportNotes } = await import("./export-DA_9kPXd.mjs");
|
|
409
415
|
const candidatePort = await getPort(12445);
|
|
410
416
|
for (const entryFile of entry) {
|
|
411
417
|
const options = await resolveOptions({ entry: entryFile }, "export");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as getRoots } from "./resolver-
|
|
1
|
+
import { n as getRoots } from "./resolver-XedCEhxI.mjs";
|
|
2
2
|
import path, { dirname, relative } from "node:path";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
@@ -13,6 +13,7 @@ import * as pdfLib from "pdf-lib";
|
|
|
13
13
|
import { PDFDocument } from "pdf-lib";
|
|
14
14
|
|
|
15
15
|
//#region node/commands/export.ts
|
|
16
|
+
const RE_CLICKS_PARAM = /clicks=([1-9]\d*)/;
|
|
16
17
|
function addToTree(tree, info, slideIndexes, level = 1) {
|
|
17
18
|
const titleLevel = info.level;
|
|
18
19
|
if (titleLevel && titleLevel > level && tree.length > 0 && tree[tree.length - 1].titleLevel < titleLevel) addToTree(tree[tree.length - 1].children, info, slideIndexes, level + 1);
|
|
@@ -159,7 +160,7 @@ async function exportSlides({ port = 18724, total = 0, range: range$1, format =
|
|
|
159
160
|
}
|
|
160
161
|
{
|
|
161
162
|
const frames = page.frames();
|
|
162
|
-
await Promise.all(frames.map((frame) => frame.waitForLoadState()));
|
|
163
|
+
await Promise.all(frames.map((frame) => frame.waitForLoadState(void 0, { timeout })));
|
|
163
164
|
}
|
|
164
165
|
{
|
|
165
166
|
const container = slide.locator("#mermaid-rendering-container");
|
|
@@ -194,7 +195,7 @@ async function exportSlides({ port = 18724, total = 0, range: range$1, format =
|
|
|
194
195
|
}, []));
|
|
195
196
|
}
|
|
196
197
|
function getClicksFromUrl(url) {
|
|
197
|
-
return url.match(
|
|
198
|
+
return url.match(RE_CLICKS_PARAM)?.[1];
|
|
198
199
|
}
|
|
199
200
|
async function genPageWithClicks(fn, no, clicks) {
|
|
200
201
|
await fn(no, clicks);
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./resolver-
|
|
2
|
-
import { a as parser, i as resolveOptions, n as ViteSlidevPlugin, r as createDataUtils } from "./shared-
|
|
3
|
-
import { t as createServer } from "./serve-
|
|
1
|
+
import "./resolver-XedCEhxI.mjs";
|
|
2
|
+
import { a as parser, i as resolveOptions, n as ViteSlidevPlugin, r as createDataUtils } from "./shared-ClfjhvJo.mjs";
|
|
3
|
+
import { t as createServer } from "./serve-CYSWeFFN.mjs";
|
|
4
4
|
|
|
5
5
|
export { ViteSlidevPlugin, createDataUtils, createServer, parser, resolveOptions };
|
|
@@ -13,6 +13,7 @@ import { resolveGlobal } from "resolve-global";
|
|
|
13
13
|
import { findClosestPkgJsonPath, findDepPkgJsonPath } from "vitefu";
|
|
14
14
|
|
|
15
15
|
//#region node/resolver.ts
|
|
16
|
+
const RE_PATH_SEPARATOR = /[/\\]/;
|
|
16
17
|
const cliRoot = fileURLToPath(new URL("..", import.meta.url));
|
|
17
18
|
const isInstalledGlobally = {};
|
|
18
19
|
/**
|
|
@@ -49,7 +50,7 @@ async function findGlobalPkgRoot(name, ensure = false) {
|
|
|
49
50
|
if (ensure) throw new Error(`Failed to resolve global package "${name}"`);
|
|
50
51
|
}
|
|
51
52
|
async function resolveEntry(entryRaw) {
|
|
52
|
-
if (!existsSync(entryRaw) && !entryRaw.endsWith(".md") &&
|
|
53
|
+
if (!existsSync(entryRaw) && !entryRaw.endsWith(".md") && !RE_PATH_SEPARATOR.test(entryRaw)) entryRaw += ".md";
|
|
53
54
|
const entry = resolve(entryRaw);
|
|
54
55
|
if (!existsSync(entry)) {
|
|
55
56
|
if (!process.stdin.isTTY) {
|