@slidev/cli 0.49.9 → 0.49.11
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/README.md +2 -2
- package/dist/{build-HVOMXVYS.mjs → build-2HGCTOR5.mjs} +5 -15
- package/dist/{chunk-ZATTXN6U.mjs → chunk-4LA667A3.mjs} +267 -256
- package/dist/chunk-G75DCGK3.mjs +29 -0
- package/dist/cli.mjs +3 -3
- package/dist/index.mjs +2 -2
- package/package.json +4 -4
- package/template.md +15 -15
- package/dist/chunk-DRWYFCYG.mjs +0 -44
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ Install [Node.js >=18](https://nodejs.org/) and run the following command:
|
|
|
67
67
|
npm init slidev
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Documentation:
|
|
71
71
|
**[English](https://sli.dev)** | [中文文档](https://cn.sli.dev) | [Français](https://fr.sli.dev) | [Español](https://es.sli.dev) | [Русский](https://ru.sli.dev) | [Português-BR](https://br.sli.dev)
|
|
72
72
|
|
|
73
73
|
Discord: [chat.sli.dev](https://chat.sli.dev)
|
|
@@ -82,7 +82,7 @@ For a full example, you can check the [demo](https://github.com/slidevjs/slidev/
|
|
|
82
82
|
- [Shiki](https://github.com/shikijs/shiki), [Monaco Editor](https://github.com/Microsoft/monaco-editor) - First-class code snippets support with live coding capability
|
|
83
83
|
- [RecordRTC](https://recordrtc.org) - Built-in recording and camera view
|
|
84
84
|
- [VueUse](https://vueuse.org) family - [`@vueuse/core`](https://github.com/vueuse/vueuse), [`@vueuse/motion`](https://github.com/vueuse/motion), etc.
|
|
85
|
-
- [Iconify](https://iconify.design/) -
|
|
85
|
+
- [Iconify](https://iconify.design/) - Icon sets collection.
|
|
86
86
|
- [Drauu](https://github.com/antfu/drauu) - Drawing and annotations support
|
|
87
87
|
- [KaTeX](https://katex.org/) - LaTeX math rendering.
|
|
88
88
|
- [Mermaid](https://mermaid-js.github.io/mermaid) - Textual Diagrams.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ViteSlidevPlugin,
|
|
3
2
|
getIndexHtml,
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
3
|
+
resolveViteConfigs
|
|
4
|
+
} from "./chunk-4LA667A3.mjs";
|
|
6
5
|
import "./chunk-LOUKLO2C.mjs";
|
|
7
6
|
import "./chunk-RG2EEPCO.mjs";
|
|
8
7
|
import "./chunk-BXO7ZPPU.mjs";
|
|
@@ -11,7 +10,7 @@ import "./chunk-BXO7ZPPU.mjs";
|
|
|
11
10
|
import { resolve } from "node:path";
|
|
12
11
|
import http from "node:http";
|
|
13
12
|
import fs from "fs-extra";
|
|
14
|
-
import {
|
|
13
|
+
import { build as viteBuild } from "vite";
|
|
15
14
|
import connect from "connect";
|
|
16
15
|
import sirv from "sirv";
|
|
17
16
|
async function build(options, viteConfig = {}, args) {
|
|
@@ -22,11 +21,9 @@ async function build(options, viteConfig = {}, args) {
|
|
|
22
21
|
await fs.writeFile(indexPath, await getIndexHtml(options), "utf-8");
|
|
23
22
|
let config = void 0;
|
|
24
23
|
try {
|
|
25
|
-
|
|
24
|
+
const inlineConfig = await resolveViteConfigs(
|
|
26
25
|
options,
|
|
27
|
-
viteConfig,
|
|
28
26
|
{
|
|
29
|
-
root: options.userRoot,
|
|
30
27
|
plugins: [
|
|
31
28
|
{
|
|
32
29
|
name: "resolve-config",
|
|
@@ -39,16 +36,9 @@ async function build(options, viteConfig = {}, args) {
|
|
|
39
36
|
chunkSizeWarningLimit: 2e3
|
|
40
37
|
}
|
|
41
38
|
},
|
|
39
|
+
viteConfig,
|
|
42
40
|
"build"
|
|
43
41
|
);
|
|
44
|
-
inlineConfig = mergeConfig(
|
|
45
|
-
inlineConfig,
|
|
46
|
-
{
|
|
47
|
-
plugins: [
|
|
48
|
-
await ViteSlidevPlugin(options, inlineConfig.slidev || {})
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
42
|
await viteBuild(inlineConfig);
|
|
53
43
|
} finally {
|
|
54
44
|
if (originalIndexHTML != null)
|
|
@@ -7146,14 +7146,14 @@ var require_dist = __commonJS({
|
|
|
7146
7146
|
});
|
|
7147
7147
|
|
|
7148
7148
|
// package.json
|
|
7149
|
-
var version = "0.49.
|
|
7149
|
+
var version = "0.49.11";
|
|
7150
7150
|
|
|
7151
7151
|
// node/commands/shared.ts
|
|
7152
|
-
import { existsSync, promises as
|
|
7153
|
-
import { join } from "node:path";
|
|
7154
|
-
import { loadConfigFromFile, mergeConfig
|
|
7152
|
+
import { existsSync as existsSync6, promises as fs8 } from "node:fs";
|
|
7153
|
+
import { join as join10 } from "node:path";
|
|
7154
|
+
import { loadConfigFromFile, mergeConfig as mergeConfig2 } from "vite";
|
|
7155
7155
|
import MarkdownIt from "markdown-it";
|
|
7156
|
-
import { slash } from "@antfu/utils";
|
|
7156
|
+
import { slash as slash5 } from "@antfu/utils";
|
|
7157
7157
|
|
|
7158
7158
|
// node/syntax/markdown-it/markdown-it-link.ts
|
|
7159
7159
|
function markdownItLink(md) {
|
|
@@ -7223,183 +7223,9 @@ function updateFrontmatterPatch(slide, frontmatter) {
|
|
|
7223
7223
|
}
|
|
7224
7224
|
}
|
|
7225
7225
|
|
|
7226
|
-
// node/commands/shared.ts
|
|
7227
|
-
var sharedMd = MarkdownIt({ html: true });
|
|
7228
|
-
sharedMd.use(markdownItLink);
|
|
7229
|
-
function getSlideTitle(data) {
|
|
7230
|
-
const tokens = sharedMd.parseInline(data.config.title, {});
|
|
7231
|
-
const title = stringifyMarkdownTokens(tokens);
|
|
7232
|
-
const slideTitle = data.config.titleTemplate.replace("%s", title);
|
|
7233
|
-
return slideTitle === "Slidev - Slidev" ? "Slidev" : slideTitle;
|
|
7234
|
-
}
|
|
7235
|
-
function escapeHtml(unsafe) {
|
|
7236
|
-
return JSON.stringify(
|
|
7237
|
-
String(unsafe).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'")
|
|
7238
|
-
);
|
|
7239
|
-
}
|
|
7240
|
-
async function getIndexHtml({ entry, clientRoot, roots, data }) {
|
|
7241
|
-
let main = await fs.readFile(join(clientRoot, "index.html"), "utf-8");
|
|
7242
|
-
let head = "";
|
|
7243
|
-
let body = "";
|
|
7244
|
-
const { info, author, keywords } = data.headmatter;
|
|
7245
|
-
head += [
|
|
7246
|
-
`<meta name="slidev:version" content="${version}">`,
|
|
7247
|
-
`<meta charset="slidev:entry" content="${slash(entry)}">`,
|
|
7248
|
-
`<link rel="icon" href="${data.config.favicon}">`,
|
|
7249
|
-
`<title>${getSlideTitle(data)}</title>`,
|
|
7250
|
-
info && `<meta name="description" content=${escapeHtml(info)}>`,
|
|
7251
|
-
author && `<meta name="author" content=${escapeHtml(author)}>`,
|
|
7252
|
-
keywords && `<meta name="keywords" content=${escapeHtml(Array.isArray(keywords) ? keywords.join(", ") : keywords)}>`
|
|
7253
|
-
].filter(Boolean).join("\n");
|
|
7254
|
-
for (const root of roots) {
|
|
7255
|
-
const path4 = join(root, "index.html");
|
|
7256
|
-
if (!existsSync(path4))
|
|
7257
|
-
continue;
|
|
7258
|
-
const index = await fs.readFile(path4, "utf-8");
|
|
7259
|
-
head += `
|
|
7260
|
-
${(index.match(/<head>([\s\S]*?)<\/head>/i)?.[1] || "").trim()}`;
|
|
7261
|
-
body += `
|
|
7262
|
-
${(index.match(/<body>([\s\S]*?)<\/body>/i)?.[1] || "").trim()}`;
|
|
7263
|
-
}
|
|
7264
|
-
if (data.features.tweet)
|
|
7265
|
-
body += '\n<script async src="https://platform.twitter.com/widgets.js"></script>';
|
|
7266
|
-
if (data.config.fonts.webfonts.length && data.config.fonts.provider !== "none")
|
|
7267
|
-
head += `
|
|
7268
|
-
<link rel="stylesheet" href="${generateGoogleFontsUrl(data.config.fonts)}" type="text/css">`;
|
|
7269
|
-
main = main.replace("__ENTRY__", toAtFS(join(clientRoot, "main.ts"))).replace("<!-- head -->", head).replace("<!-- body -->", body);
|
|
7270
|
-
return main;
|
|
7271
|
-
}
|
|
7272
|
-
async function mergeViteConfigs({ roots, entry }, viteConfig, config, command) {
|
|
7273
|
-
const configEnv = {
|
|
7274
|
-
mode: "development",
|
|
7275
|
-
command
|
|
7276
|
-
};
|
|
7277
|
-
const files = roots.map((i) => join(i, "vite.config.ts"));
|
|
7278
|
-
for await (const file of files) {
|
|
7279
|
-
if (!existsSync(file))
|
|
7280
|
-
continue;
|
|
7281
|
-
const viteConfig2 = await loadConfigFromFile(configEnv, file);
|
|
7282
|
-
if (!viteConfig2?.config)
|
|
7283
|
-
continue;
|
|
7284
|
-
config = mergeConfig(config, viteConfig2.config);
|
|
7285
|
-
}
|
|
7286
|
-
config = mergeConfig(config, viteConfig);
|
|
7287
|
-
const localConfig = await resolveConfig({}, command, entry);
|
|
7288
|
-
config = mergeConfig(config, { slidev: localConfig.slidev || {} });
|
|
7289
|
-
return config;
|
|
7290
|
-
}
|
|
7291
|
-
|
|
7292
|
-
// node/parser.ts
|
|
7293
|
-
import * as parser from "@slidev/parser/fs";
|
|
7294
|
-
|
|
7295
|
-
// node/integrations/themes.ts
|
|
7296
|
-
import { join as join2 } from "node:path";
|
|
7297
|
-
import fs2 from "fs-extra";
|
|
7298
|
-
import { satisfies } from "semver";
|
|
7299
|
-
var officialThemes = {
|
|
7300
|
-
"none": "",
|
|
7301
|
-
"default": "@slidev/theme-default",
|
|
7302
|
-
"seriph": "@slidev/theme-seriph",
|
|
7303
|
-
"apple-basic": "@slidev/theme-apple-basic",
|
|
7304
|
-
"shibainu": "@slidev/theme-shibainu",
|
|
7305
|
-
"bricks": "@slidev/theme-bricks"
|
|
7306
|
-
};
|
|
7307
|
-
var resolveTheme = createResolver("theme", officialThemes);
|
|
7308
|
-
async function getThemeMeta(name, root) {
|
|
7309
|
-
const path4 = join2(root, "package.json");
|
|
7310
|
-
if (!fs2.existsSync(path4))
|
|
7311
|
-
return {};
|
|
7312
|
-
const { slidev = {}, engines = {} } = await fs2.readJSON(path4);
|
|
7313
|
-
if (engines.slidev && !satisfies(version, engines.slidev, { includePrerelease: true }))
|
|
7314
|
-
throw new Error(`[slidev] theme "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
|
|
7315
|
-
return slidev;
|
|
7316
|
-
}
|
|
7317
|
-
|
|
7318
|
-
// node/integrations/addons.ts
|
|
7319
|
-
import { resolve } from "node:path";
|
|
7320
|
-
import fs3 from "fs-extra";
|
|
7321
|
-
import { satisfies as satisfies2 } from "semver";
|
|
7322
|
-
async function resolveAddons(addonsInConfig) {
|
|
7323
|
-
const { userRoot, userPkgJson } = await getRoots();
|
|
7324
|
-
const resolved = [];
|
|
7325
|
-
const resolveAddonNameAndRoot = createResolver("addon", {});
|
|
7326
|
-
async function resolveAddon(name, parent) {
|
|
7327
|
-
const [, pkgRoot] = await resolveAddonNameAndRoot(name, parent);
|
|
7328
|
-
if (!pkgRoot)
|
|
7329
|
-
return;
|
|
7330
|
-
resolved.push(pkgRoot);
|
|
7331
|
-
const { slidev = {}, engines = {} } = await fs3.readJSON(resolve(pkgRoot, "package.json"));
|
|
7332
|
-
if (engines.slidev && !satisfies2(version, engines.slidev, { includePrerelease: true }))
|
|
7333
|
-
throw new Error(`[slidev] addon "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
|
|
7334
|
-
if (Array.isArray(slidev.addons))
|
|
7335
|
-
await Promise.all(slidev.addons.map((addon) => resolveAddon(addon, pkgRoot)));
|
|
7336
|
-
}
|
|
7337
|
-
if (Array.isArray(addonsInConfig))
|
|
7338
|
-
await Promise.all(addonsInConfig.map((addon) => resolveAddon(addon, userRoot)));
|
|
7339
|
-
if (Array.isArray(userPkgJson.slidev?.addons))
|
|
7340
|
-
await Promise.all(userPkgJson.slidev.addons.map((addon) => resolveAddon(addon, userRoot)));
|
|
7341
|
-
return resolved;
|
|
7342
|
-
}
|
|
7343
|
-
|
|
7344
|
-
// node/options.ts
|
|
7345
|
-
import { uniq } from "@antfu/utils";
|
|
7346
|
-
import Debug from "debug";
|
|
7347
|
-
import mm from "micromatch";
|
|
7348
|
-
var debug = Debug("slidev:options");
|
|
7349
|
-
async function resolveOptions(options, mode) {
|
|
7350
|
-
const entry = await resolveEntry(options.entry);
|
|
7351
|
-
const rootsInfo = await getRoots(entry);
|
|
7352
|
-
const loaded = await parser.load(rootsInfo.userRoot, entry, void 0, mode);
|
|
7353
|
-
let themeRaw = options.theme || loaded.headmatter.theme;
|
|
7354
|
-
themeRaw = themeRaw === null ? "none" : themeRaw || "default";
|
|
7355
|
-
const [theme, themeRoot] = await resolveTheme(themeRaw, entry);
|
|
7356
|
-
const themeRoots = themeRoot ? [themeRoot] : [];
|
|
7357
|
-
const themeMeta = themeRoot ? await getThemeMeta(theme, themeRoot) : void 0;
|
|
7358
|
-
const config = parser.resolveConfig(loaded.headmatter, themeMeta, options.entry);
|
|
7359
|
-
const addonRoots = await resolveAddons(config.addons);
|
|
7360
|
-
const roots = uniq([...themeRoots, ...addonRoots, rootsInfo.userRoot]);
|
|
7361
|
-
debug({
|
|
7362
|
-
...rootsInfo,
|
|
7363
|
-
...options,
|
|
7364
|
-
config,
|
|
7365
|
-
mode,
|
|
7366
|
-
entry,
|
|
7367
|
-
themeRaw,
|
|
7368
|
-
theme,
|
|
7369
|
-
themeRoots,
|
|
7370
|
-
addonRoots,
|
|
7371
|
-
roots
|
|
7372
|
-
});
|
|
7373
|
-
const data = {
|
|
7374
|
-
...loaded,
|
|
7375
|
-
config,
|
|
7376
|
-
themeMeta
|
|
7377
|
-
};
|
|
7378
|
-
const resolved = {
|
|
7379
|
-
...rootsInfo,
|
|
7380
|
-
...options,
|
|
7381
|
-
data,
|
|
7382
|
-
mode,
|
|
7383
|
-
entry,
|
|
7384
|
-
themeRaw,
|
|
7385
|
-
theme,
|
|
7386
|
-
themeRoots,
|
|
7387
|
-
addonRoots,
|
|
7388
|
-
roots,
|
|
7389
|
-
utils: createDataUtils(data)
|
|
7390
|
-
};
|
|
7391
|
-
return resolved;
|
|
7392
|
-
}
|
|
7393
|
-
function createDataUtils(data) {
|
|
7394
|
-
const monacoTypesIgnorePackagesMatches = (data.config.monacoTypesIgnorePackages || []).map((i) => mm.matcher(i));
|
|
7395
|
-
return {
|
|
7396
|
-
isMonacoTypesIgnored: (pkg) => monacoTypesIgnorePackagesMatches.some((i) => i(pkg))
|
|
7397
|
-
};
|
|
7398
|
-
}
|
|
7399
|
-
|
|
7400
7226
|
// node/vite/index.ts
|
|
7401
|
-
import { join as
|
|
7402
|
-
import { existsSync as
|
|
7227
|
+
import { join as join9 } from "node:path";
|
|
7228
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
7403
7229
|
import process2 from "node:process";
|
|
7404
7230
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7405
7231
|
import Icons from "unplugin-icons/vite";
|
|
@@ -7409,18 +7235,18 @@ import ServerRef from "vite-plugin-vue-server-ref";
|
|
|
7409
7235
|
import { notNullish as notNullish2 } from "@antfu/utils";
|
|
7410
7236
|
|
|
7411
7237
|
// node/integrations/drawings.ts
|
|
7412
|
-
import { basename, dirname, join
|
|
7413
|
-
import
|
|
7238
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
7239
|
+
import fs from "fs-extra";
|
|
7414
7240
|
import fg from "fast-glob";
|
|
7415
7241
|
function resolveDrawingsDir(options) {
|
|
7416
|
-
return options.data.config.drawings.persist ?
|
|
7242
|
+
return options.data.config.drawings.persist ? resolve(
|
|
7417
7243
|
dirname(options.entry),
|
|
7418
7244
|
options.data.config.drawings.persist
|
|
7419
7245
|
) : void 0;
|
|
7420
7246
|
}
|
|
7421
7247
|
async function loadDrawings(options) {
|
|
7422
7248
|
const dir = resolveDrawingsDir(options);
|
|
7423
|
-
if (!dir || !
|
|
7249
|
+
if (!dir || !fs.existsSync(dir))
|
|
7424
7250
|
return {};
|
|
7425
7251
|
const files = await fg("*.svg", {
|
|
7426
7252
|
onlyFiles: true,
|
|
@@ -7433,7 +7259,7 @@ async function loadDrawings(options) {
|
|
|
7433
7259
|
const num = +basename(path4, ".svg");
|
|
7434
7260
|
if (Number.isNaN(num))
|
|
7435
7261
|
return;
|
|
7436
|
-
const content = await
|
|
7262
|
+
const content = await fs.readFile(path4, "utf8");
|
|
7437
7263
|
const lines = content.split(/\n/g);
|
|
7438
7264
|
obj[num.toString()] = lines.slice(1, -1).join("\n");
|
|
7439
7265
|
}));
|
|
@@ -7446,7 +7272,7 @@ async function writeDrawings(options, drawing) {
|
|
|
7446
7272
|
const width = options.data.config.canvasWidth;
|
|
7447
7273
|
const height = Math.round(width / options.data.config.aspectRatio);
|
|
7448
7274
|
const SVG_HEAD = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
|
|
7449
|
-
await
|
|
7275
|
+
await fs.ensureDir(dir);
|
|
7450
7276
|
return Promise.all(
|
|
7451
7277
|
Object.entries(drawing).map(async ([key, value]) => {
|
|
7452
7278
|
if (!value)
|
|
@@ -7454,16 +7280,16 @@ async function writeDrawings(options, drawing) {
|
|
|
7454
7280
|
const svg = `${SVG_HEAD}
|
|
7455
7281
|
${value}
|
|
7456
7282
|
</svg>`;
|
|
7457
|
-
await
|
|
7283
|
+
await fs.writeFile(join(dir, `${key}.svg`), svg, "utf-8");
|
|
7458
7284
|
})
|
|
7459
7285
|
);
|
|
7460
7286
|
}
|
|
7461
7287
|
|
|
7462
7288
|
// node/vite/extendConfig.ts
|
|
7463
|
-
import { join as
|
|
7289
|
+
import { join as join2 } from "node:path";
|
|
7464
7290
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7465
|
-
import { mergeConfig
|
|
7466
|
-
import { slash
|
|
7291
|
+
import { mergeConfig } from "vite";
|
|
7292
|
+
import { slash, uniq } from "@antfu/utils";
|
|
7467
7293
|
import { createResolve } from "mlly";
|
|
7468
7294
|
var INCLUDE_GLOBAL = [
|
|
7469
7295
|
"@typescript/ata",
|
|
@@ -7574,16 +7400,16 @@ function createConfigPlugin(options) {
|
|
|
7574
7400
|
server: {
|
|
7575
7401
|
fs: {
|
|
7576
7402
|
strict: true,
|
|
7577
|
-
allow:
|
|
7403
|
+
allow: uniq([
|
|
7578
7404
|
options.userWorkspaceRoot,
|
|
7579
7405
|
options.clientRoot,
|
|
7580
7406
|
// Special case for PNPM global installation
|
|
7581
|
-
isInstalledGlobally.value ?
|
|
7407
|
+
isInstalledGlobally.value ? slash(options.cliRoot).replace(/\/\.pnpm\/.*$/gi, "") : options.cliRoot,
|
|
7582
7408
|
...options.roots
|
|
7583
7409
|
])
|
|
7584
7410
|
}
|
|
7585
7411
|
},
|
|
7586
|
-
publicDir:
|
|
7412
|
+
publicDir: join2(options.userRoot, "public"),
|
|
7587
7413
|
build: {
|
|
7588
7414
|
rollupOptions: {
|
|
7589
7415
|
output: {
|
|
@@ -7616,10 +7442,10 @@ function createConfigPlugin(options) {
|
|
|
7616
7442
|
return id.includes("/@slidev/") || id.includes("/slidev/packages/client/") || id.includes("/@vueuse/");
|
|
7617
7443
|
}
|
|
7618
7444
|
if (isInstalledGlobally.value) {
|
|
7619
|
-
injection.cacheDir =
|
|
7445
|
+
injection.cacheDir = join2(options.cliRoot, "node_modules/.vite");
|
|
7620
7446
|
injection.root = options.cliRoot;
|
|
7621
7447
|
}
|
|
7622
|
-
return
|
|
7448
|
+
return mergeConfig(injection, config);
|
|
7623
7449
|
},
|
|
7624
7450
|
configureServer(server) {
|
|
7625
7451
|
return () => {
|
|
@@ -7647,6 +7473,7 @@ function getDefine(options) {
|
|
|
7647
7473
|
__SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
|
|
7648
7474
|
__SLIDEV_FEATURE_PRESENTER__: JSON.stringify(options.data.config.presenter === true || options.data.config.presenter === options.mode),
|
|
7649
7475
|
__SLIDEV_FEATURE_PRINT__: JSON.stringify(options.mode === "export" || options.mode === "build" && [true, "true", "auto"].includes(options.data.config.download)),
|
|
7476
|
+
__SLIDEV_FEATURE_WAKE_LOCK__: JSON.stringify(options.data.config.wakeLock === true || options.data.config.wakeLock === options.mode),
|
|
7650
7477
|
__SLIDEV_HAS_SERVER__: options.mode !== "build" ? "true" : "false"
|
|
7651
7478
|
};
|
|
7652
7479
|
}
|
|
@@ -7701,15 +7528,15 @@ console.warn('/@slidev/titles.md is deprecated, import from #slidev/title-render
|
|
|
7701
7528
|
};
|
|
7702
7529
|
|
|
7703
7530
|
// node/virtual/global-layers.ts
|
|
7704
|
-
import { existsSync
|
|
7705
|
-
import { join as
|
|
7531
|
+
import { existsSync } from "node:fs";
|
|
7532
|
+
import { join as join3 } from "node:path";
|
|
7706
7533
|
var templateGlobalLayers = {
|
|
7707
7534
|
id: `/@slidev/global-layers`,
|
|
7708
7535
|
getContent({ roots }) {
|
|
7709
7536
|
const imports = [];
|
|
7710
7537
|
let n = 0;
|
|
7711
7538
|
function getComponent(names) {
|
|
7712
|
-
const components = roots.flatMap((root) => names.map((name) =>
|
|
7539
|
+
const components = roots.flatMap((root) => names.map((name) => join3(root, name))).filter((i) => existsSync(i));
|
|
7713
7540
|
imports.push(components.map((path4, i) => `import __n${n}_${i} from '${toAtFS(path4)}'`).join("\n"));
|
|
7714
7541
|
const render = components.map((_, i) => `h(__n${n}_${i})`).join(",");
|
|
7715
7542
|
n++;
|
|
@@ -7731,17 +7558,17 @@ var templateGlobalLayers = {
|
|
|
7731
7558
|
};
|
|
7732
7559
|
|
|
7733
7560
|
// node/virtual/nav-controls.ts
|
|
7734
|
-
import { existsSync as
|
|
7735
|
-
import { join as
|
|
7561
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
7562
|
+
import { join as join4 } from "node:path";
|
|
7736
7563
|
var templateNavControls = {
|
|
7737
7564
|
id: "/@slidev/custom-nav-controls",
|
|
7738
7565
|
getContent({ roots }) {
|
|
7739
7566
|
const components = roots.flatMap((root) => {
|
|
7740
7567
|
return [
|
|
7741
|
-
|
|
7742
|
-
|
|
7568
|
+
join4(root, "custom-nav-controls.vue"),
|
|
7569
|
+
join4(root, "CustomNavControls.vue")
|
|
7743
7570
|
];
|
|
7744
|
-
}).filter((i) =>
|
|
7571
|
+
}).filter((i) => existsSync2(i));
|
|
7745
7572
|
const imports = components.map((i, idx) => `import __n${idx} from '${toAtFS(i)}'`).join("\n");
|
|
7746
7573
|
const render = components.map((i, idx) => `h(__n${idx})`).join(",");
|
|
7747
7574
|
return `${imports}
|
|
@@ -7775,15 +7602,15 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
|
|
|
7775
7602
|
};
|
|
7776
7603
|
|
|
7777
7604
|
// node/virtual/monaco-deps.ts
|
|
7778
|
-
import { resolve as
|
|
7779
|
-
import { uniq as
|
|
7605
|
+
import { resolve as resolve2 } from "node:path";
|
|
7606
|
+
import { uniq as uniq2 } from "@antfu/utils";
|
|
7780
7607
|
var templateMonacoRunDeps = {
|
|
7781
7608
|
id: "/@slidev/monaco-run-deps",
|
|
7782
7609
|
getContent: async ({ userRoot, data }, _ctx, pluginCtx) => {
|
|
7783
7610
|
if (!data.features.monaco)
|
|
7784
7611
|
return "";
|
|
7785
|
-
const deps =
|
|
7786
|
-
const importerPath =
|
|
7612
|
+
const deps = uniq2(data.features.monaco.deps.concat(data.config.monacoTypesAdditionalPackages));
|
|
7613
|
+
const importerPath = resolve2(userRoot, "./snippets/__importer__.ts");
|
|
7787
7614
|
let result = "";
|
|
7788
7615
|
for (let i = 0; i < deps.length; i++) {
|
|
7789
7616
|
const specifier = deps[i];
|
|
@@ -7804,19 +7631,19 @@ var templateMonacoRunDeps = {
|
|
|
7804
7631
|
|
|
7805
7632
|
// node/virtual/monaco-types.ts
|
|
7806
7633
|
import { builtinModules } from "node:module";
|
|
7807
|
-
import { join as
|
|
7634
|
+
import { join as join5, resolve as resolve3 } from "node:path";
|
|
7808
7635
|
import fg2 from "fast-glob";
|
|
7809
|
-
import { uniq as
|
|
7636
|
+
import { uniq as uniq3 } from "@antfu/utils";
|
|
7810
7637
|
var templateMonacoTypes = {
|
|
7811
7638
|
id: "/@slidev/monaco-types",
|
|
7812
7639
|
getContent: async ({ userRoot, data, utils }) => {
|
|
7813
7640
|
if (!data.features.monaco)
|
|
7814
7641
|
return "";
|
|
7815
|
-
const typesRoot =
|
|
7642
|
+
const typesRoot = join5(userRoot, "snippets");
|
|
7816
7643
|
const files = await fg2(["**/*.ts", "**/*.mts", "**/*.cts"], { cwd: typesRoot });
|
|
7817
7644
|
let result = 'import { addFile } from "@slidev/client/setup/monaco.ts"\n';
|
|
7818
7645
|
for (const file of files) {
|
|
7819
|
-
const url = `${toAtFS(
|
|
7646
|
+
const url = `${toAtFS(resolve3(typesRoot, file))}?monaco-types&raw`;
|
|
7820
7647
|
result += `addFile(() => import(${JSON.stringify(url)}), ${JSON.stringify(file)})
|
|
7821
7648
|
`;
|
|
7822
7649
|
}
|
|
@@ -7835,7 +7662,7 @@ var templateMonacoTypes = {
|
|
|
7835
7662
|
let deps = [...data.config.monacoTypesAdditionalPackages];
|
|
7836
7663
|
if (data.config.monacoTypesSource === "local")
|
|
7837
7664
|
deps.push(...data.features.monaco.types);
|
|
7838
|
-
deps =
|
|
7665
|
+
deps = uniq3(deps.map((specifier) => {
|
|
7839
7666
|
if (specifier[0] === ".")
|
|
7840
7667
|
return "";
|
|
7841
7668
|
return mapModuleNameToModule(specifier);
|
|
@@ -7850,16 +7677,16 @@ var templateMonacoTypes = {
|
|
|
7850
7677
|
};
|
|
7851
7678
|
|
|
7852
7679
|
// node/virtual/setups.ts
|
|
7853
|
-
import { existsSync as
|
|
7854
|
-
import { join as
|
|
7680
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
7681
|
+
import { join as join6 } from "node:path";
|
|
7855
7682
|
function createSetupTemplate(name) {
|
|
7856
7683
|
return {
|
|
7857
7684
|
id: `/@slidev/setups/${name}`,
|
|
7858
7685
|
getContent({ roots }) {
|
|
7859
7686
|
const setups = roots.flatMap((i) => {
|
|
7860
|
-
const path4 =
|
|
7687
|
+
const path4 = join6(i, "setup", name);
|
|
7861
7688
|
return [".ts", ".mts", ".js", ".mjs"].map((ext) => path4 + ext);
|
|
7862
|
-
}).filter((i) =>
|
|
7689
|
+
}).filter((i) => existsSync3(i));
|
|
7863
7690
|
const imports = [];
|
|
7864
7691
|
setups.forEach((path4, idx) => {
|
|
7865
7692
|
imports.push(`import __n${idx} from '${toAtFS(path4)}'`);
|
|
@@ -7873,7 +7700,7 @@ var setupModules = ["shiki", "code-runners", "monaco", "mermaid", "main", "root"
|
|
|
7873
7700
|
var templateSetups = setupModules.map(createSetupTemplate);
|
|
7874
7701
|
|
|
7875
7702
|
// node/setups/shiki.ts
|
|
7876
|
-
import
|
|
7703
|
+
import fs2 from "node:fs/promises";
|
|
7877
7704
|
async function loadShikiSetups(clientRoot, roots) {
|
|
7878
7705
|
const result = await loadSetups(
|
|
7879
7706
|
clientRoot,
|
|
@@ -7883,7 +7710,7 @@ async function loadShikiSetups(clientRoot, roots) {
|
|
|
7883
7710
|
/** @deprecated */
|
|
7884
7711
|
async loadTheme(path4) {
|
|
7885
7712
|
console.warn("[slidev] `loadTheme` in `setup/shiki.ts` is deprecated. Pass directly the theme name it's supported by Shiki. For custom themes, load it manually via `JSON.parse(fs.readFileSync(path, 'utf-8'))` and pass the raw JSON object instead.");
|
|
7886
|
-
return JSON.parse(await
|
|
7713
|
+
return JSON.parse(await fs2.readFile(path4, "utf-8"));
|
|
7887
7714
|
}
|
|
7888
7715
|
},
|
|
7889
7716
|
{},
|
|
@@ -7996,13 +7823,13 @@ ${slides.join(",\n")}
|
|
|
7996
7823
|
};
|
|
7997
7824
|
|
|
7998
7825
|
// node/virtual/styles.ts
|
|
7999
|
-
import { join as
|
|
8000
|
-
import { existsSync as
|
|
7826
|
+
import { join as join7 } from "node:path";
|
|
7827
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
8001
7828
|
var templateStyle = {
|
|
8002
7829
|
id: "/@slidev/styles",
|
|
8003
7830
|
getContent: async ({ data, clientRoot, roots }) => {
|
|
8004
7831
|
function resolveUrlOfClient(name) {
|
|
8005
|
-
return toAtFS(
|
|
7832
|
+
return toAtFS(join7(clientRoot, name));
|
|
8006
7833
|
}
|
|
8007
7834
|
const imports = [
|
|
8008
7835
|
`import "${resolveUrlOfClient("styles/vars.css")}"`,
|
|
@@ -8013,14 +7840,14 @@ var templateStyle = {
|
|
|
8013
7840
|
];
|
|
8014
7841
|
for (const root of roots) {
|
|
8015
7842
|
const styles = [
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
7843
|
+
join7(root, "styles", "index.ts"),
|
|
7844
|
+
join7(root, "styles", "index.js"),
|
|
7845
|
+
join7(root, "styles", "index.css"),
|
|
7846
|
+
join7(root, "styles.css"),
|
|
7847
|
+
join7(root, "style.css")
|
|
8021
7848
|
];
|
|
8022
7849
|
for (const style of styles) {
|
|
8023
|
-
if (
|
|
7850
|
+
if (existsSync4(style)) {
|
|
8024
7851
|
imports.push(`import "${toAtFS(style)}"`);
|
|
8025
7852
|
continue;
|
|
8026
7853
|
}
|
|
@@ -8094,6 +7921,116 @@ var templates = [
|
|
|
8094
7921
|
templateLegacyTitles
|
|
8095
7922
|
];
|
|
8096
7923
|
|
|
7924
|
+
// node/options.ts
|
|
7925
|
+
import { uniq as uniq4 } from "@antfu/utils";
|
|
7926
|
+
import Debug from "debug";
|
|
7927
|
+
import mm from "micromatch";
|
|
7928
|
+
|
|
7929
|
+
// node/parser.ts
|
|
7930
|
+
import * as parser from "@slidev/parser/fs";
|
|
7931
|
+
|
|
7932
|
+
// node/integrations/themes.ts
|
|
7933
|
+
import { join as join8 } from "node:path";
|
|
7934
|
+
import fs3 from "fs-extra";
|
|
7935
|
+
import { satisfies } from "semver";
|
|
7936
|
+
var officialThemes = {
|
|
7937
|
+
"none": "",
|
|
7938
|
+
"default": "@slidev/theme-default",
|
|
7939
|
+
"seriph": "@slidev/theme-seriph",
|
|
7940
|
+
"apple-basic": "@slidev/theme-apple-basic",
|
|
7941
|
+
"shibainu": "@slidev/theme-shibainu",
|
|
7942
|
+
"bricks": "@slidev/theme-bricks"
|
|
7943
|
+
};
|
|
7944
|
+
var resolveTheme = createResolver("theme", officialThemes);
|
|
7945
|
+
async function getThemeMeta(name, root) {
|
|
7946
|
+
const path4 = join8(root, "package.json");
|
|
7947
|
+
if (!fs3.existsSync(path4))
|
|
7948
|
+
return {};
|
|
7949
|
+
const { slidev = {}, engines = {} } = await fs3.readJSON(path4);
|
|
7950
|
+
if (engines.slidev && !satisfies(version, engines.slidev, { includePrerelease: true }))
|
|
7951
|
+
throw new Error(`[slidev] theme "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
|
|
7952
|
+
return slidev;
|
|
7953
|
+
}
|
|
7954
|
+
|
|
7955
|
+
// node/integrations/addons.ts
|
|
7956
|
+
import { resolve as resolve4 } from "node:path";
|
|
7957
|
+
import fs4 from "fs-extra";
|
|
7958
|
+
import { satisfies as satisfies2 } from "semver";
|
|
7959
|
+
async function resolveAddons(addonsInConfig) {
|
|
7960
|
+
const { userRoot, userPkgJson } = await getRoots();
|
|
7961
|
+
const resolved = [];
|
|
7962
|
+
const resolveAddonNameAndRoot = createResolver("addon", {});
|
|
7963
|
+
async function resolveAddon(name, parent) {
|
|
7964
|
+
const [, pkgRoot] = await resolveAddonNameAndRoot(name, parent);
|
|
7965
|
+
if (!pkgRoot)
|
|
7966
|
+
return;
|
|
7967
|
+
resolved.push(pkgRoot);
|
|
7968
|
+
const { slidev = {}, engines = {} } = await fs4.readJSON(resolve4(pkgRoot, "package.json"));
|
|
7969
|
+
if (engines.slidev && !satisfies2(version, engines.slidev, { includePrerelease: true }))
|
|
7970
|
+
throw new Error(`[slidev] addon "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
|
|
7971
|
+
if (Array.isArray(slidev.addons))
|
|
7972
|
+
await Promise.all(slidev.addons.map((addon) => resolveAddon(addon, pkgRoot)));
|
|
7973
|
+
}
|
|
7974
|
+
if (Array.isArray(addonsInConfig))
|
|
7975
|
+
await Promise.all(addonsInConfig.map((addon) => resolveAddon(addon, userRoot)));
|
|
7976
|
+
if (Array.isArray(userPkgJson.slidev?.addons))
|
|
7977
|
+
await Promise.all(userPkgJson.slidev.addons.map((addon) => resolveAddon(addon, userRoot)));
|
|
7978
|
+
return resolved;
|
|
7979
|
+
}
|
|
7980
|
+
|
|
7981
|
+
// node/options.ts
|
|
7982
|
+
var debug = Debug("slidev:options");
|
|
7983
|
+
async function resolveOptions(options, mode) {
|
|
7984
|
+
const entry = await resolveEntry(options.entry);
|
|
7985
|
+
const rootsInfo = await getRoots(entry);
|
|
7986
|
+
const loaded = await parser.load(rootsInfo.userRoot, entry, void 0, mode);
|
|
7987
|
+
let themeRaw = options.theme || loaded.headmatter.theme;
|
|
7988
|
+
themeRaw = themeRaw === null ? "none" : themeRaw || "default";
|
|
7989
|
+
const [theme, themeRoot] = await resolveTheme(themeRaw, entry);
|
|
7990
|
+
const themeRoots = themeRoot ? [themeRoot] : [];
|
|
7991
|
+
const themeMeta = themeRoot ? await getThemeMeta(theme, themeRoot) : void 0;
|
|
7992
|
+
const config = parser.resolveConfig(loaded.headmatter, themeMeta, options.entry);
|
|
7993
|
+
const addonRoots = await resolveAddons(config.addons);
|
|
7994
|
+
const roots = uniq4([...themeRoots, ...addonRoots, rootsInfo.userRoot]);
|
|
7995
|
+
debug({
|
|
7996
|
+
...rootsInfo,
|
|
7997
|
+
...options,
|
|
7998
|
+
config,
|
|
7999
|
+
mode,
|
|
8000
|
+
entry,
|
|
8001
|
+
themeRaw,
|
|
8002
|
+
theme,
|
|
8003
|
+
themeRoots,
|
|
8004
|
+
addonRoots,
|
|
8005
|
+
roots
|
|
8006
|
+
});
|
|
8007
|
+
const data = {
|
|
8008
|
+
...loaded,
|
|
8009
|
+
config,
|
|
8010
|
+
themeMeta
|
|
8011
|
+
};
|
|
8012
|
+
const resolved = {
|
|
8013
|
+
...rootsInfo,
|
|
8014
|
+
...options,
|
|
8015
|
+
data,
|
|
8016
|
+
mode,
|
|
8017
|
+
entry,
|
|
8018
|
+
themeRaw,
|
|
8019
|
+
theme,
|
|
8020
|
+
themeRoots,
|
|
8021
|
+
addonRoots,
|
|
8022
|
+
roots,
|
|
8023
|
+
utils: createDataUtils(data)
|
|
8024
|
+
};
|
|
8025
|
+
return resolved;
|
|
8026
|
+
}
|
|
8027
|
+
function createDataUtils(data) {
|
|
8028
|
+
const monacoTypesIgnorePackagesMatches = (data.config.monacoTypesIgnorePackages || []).map((i) => mm.matcher(i));
|
|
8029
|
+
return {
|
|
8030
|
+
isMonacoTypesIgnored: (pkg) => monacoTypesIgnorePackagesMatches.some((i) => i(pkg))
|
|
8031
|
+
};
|
|
8032
|
+
}
|
|
8033
|
+
|
|
8097
8034
|
// node/vite/loaders.ts
|
|
8098
8035
|
var regexId = /^\/@slidev\/slide\/(\d+)\.(md|json)(?:\?import)?$/;
|
|
8099
8036
|
var regexIdQuery = /(\d+)\.(md|json|frontmatter)$/;
|
|
@@ -8148,17 +8085,15 @@ function createSlidesLoader(options, pluginOptions, serverOptions) {
|
|
|
8148
8085
|
if (now - _layouts_cache_time < 2e3)
|
|
8149
8086
|
return _layouts_cache;
|
|
8150
8087
|
const layouts = {};
|
|
8151
|
-
for (const root of [...roots
|
|
8088
|
+
for (const root of [clientRoot, ...roots]) {
|
|
8152
8089
|
const layoutPaths = await fg3("layouts/**/*.{vue,ts}", {
|
|
8153
8090
|
cwd: root,
|
|
8154
8091
|
absolute: true,
|
|
8155
8092
|
suppressErrors: true
|
|
8156
8093
|
});
|
|
8157
8094
|
for (const layoutPath of layoutPaths) {
|
|
8158
|
-
const
|
|
8159
|
-
|
|
8160
|
-
continue;
|
|
8161
|
-
layouts[layout] = layoutPath;
|
|
8095
|
+
const layoutName = path.basename(layoutPath).replace(/\.\w+$/, "");
|
|
8096
|
+
layouts[layoutName] = layoutPath;
|
|
8162
8097
|
}
|
|
8163
8098
|
}
|
|
8164
8099
|
_layouts_cache_time = now;
|
|
@@ -8325,6 +8260,7 @@ function createSlidesLoader(options, pluginOptions, serverOptions) {
|
|
|
8325
8260
|
...withRenderedNote(slide),
|
|
8326
8261
|
frontmatter: void 0,
|
|
8327
8262
|
source: void 0,
|
|
8263
|
+
importChain: void 0,
|
|
8328
8264
|
// remove raw content in build, optimize the bundle size
|
|
8329
8265
|
...mode === "build" ? { raw: "", content: "", note: "" } : {}
|
|
8330
8266
|
};
|
|
@@ -8512,7 +8448,7 @@ ${code}`;
|
|
|
8512
8448
|
|
|
8513
8449
|
// node/vite/markdown.ts
|
|
8514
8450
|
import Markdown from "unplugin-vue-markdown/vite";
|
|
8515
|
-
import { isTruthy, slash as
|
|
8451
|
+
import { isTruthy, slash as slash3 } from "@antfu/utils";
|
|
8516
8452
|
|
|
8517
8453
|
// ../../node_modules/.pnpm/@hedgedoc+markdown-it-plugins@2.1.4_patch_hash=tuyuxytl56b2vxulpkzt2wf4o4_markdown-it@14.1.0/node_modules/@hedgedoc/markdown-it-plugins/dist/esm/image-size/specialCharacters.js
|
|
8518
8454
|
var SpecialCharacters;
|
|
@@ -9022,7 +8958,7 @@ function transformMagicMove(shiki, shikiOptions, configLineNumbers) {
|
|
|
9022
8958
|
import lz2 from "lz-string";
|
|
9023
8959
|
function transformMermaid(ctx) {
|
|
9024
8960
|
ctx.s.replace(
|
|
9025
|
-
/^```mermaid *(\{[
|
|
8961
|
+
/^```mermaid *(\{[^\n]*\})?\n([\s\S]+?)\n```/gm,
|
|
9026
8962
|
(full, options = "", code = "") => {
|
|
9027
8963
|
code = code.trim();
|
|
9028
8964
|
options = options.trim() || "{}";
|
|
@@ -9049,11 +8985,11 @@ function transformPlantUml(ctx) {
|
|
|
9049
8985
|
// node/syntax/transform/snippet.ts
|
|
9050
8986
|
import path3 from "node:path";
|
|
9051
8987
|
import lz3 from "lz-string";
|
|
9052
|
-
import
|
|
9053
|
-
import { slash as
|
|
8988
|
+
import fs6 from "fs-extra";
|
|
8989
|
+
import { slash as slash2 } from "@antfu/utils";
|
|
9054
8990
|
|
|
9055
8991
|
// node/vite/monacoWrite.ts
|
|
9056
|
-
import
|
|
8992
|
+
import fs5 from "node:fs/promises";
|
|
9057
8993
|
import path2 from "node:path";
|
|
9058
8994
|
var monacoWriterWhitelist = /* @__PURE__ */ new Set();
|
|
9059
8995
|
function createMonacoWriter({ userRoot }) {
|
|
@@ -9077,7 +9013,7 @@ function createMonacoWriter({ userRoot }) {
|
|
|
9077
9013
|
}
|
|
9078
9014
|
const filepath = path2.join(userRoot, file);
|
|
9079
9015
|
console.log("[Slidev] Writing file:", filepath);
|
|
9080
|
-
await
|
|
9016
|
+
await fs5.writeFile(filepath, content, "utf-8");
|
|
9081
9017
|
}
|
|
9082
9018
|
});
|
|
9083
9019
|
});
|
|
@@ -9149,15 +9085,15 @@ function transformSnippet(ctx) {
|
|
|
9149
9085
|
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
9150
9086
|
/^<<<\s*(\S.*?)(#[\w-]+)?\s*(?:\s(\S+?))?\s*(\{.*)?$/gm,
|
|
9151
9087
|
(full, filepath = "", regionName = "", lang = "", meta = "") => {
|
|
9152
|
-
const src =
|
|
9088
|
+
const src = slash2(
|
|
9153
9089
|
/^@\//.test(filepath) ? path3.resolve(options.userRoot, filepath.slice(2)) : path3.resolve(dir, filepath)
|
|
9154
9090
|
);
|
|
9155
9091
|
data.watchFiles.push(src);
|
|
9156
|
-
const isAFile =
|
|
9157
|
-
if (!
|
|
9092
|
+
const isAFile = fs6.statSync(src).isFile();
|
|
9093
|
+
if (!fs6.existsSync(src) || !isAFile) {
|
|
9158
9094
|
throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
|
|
9159
9095
|
}
|
|
9160
|
-
let content =
|
|
9096
|
+
let content = fs6.readFileSync(src, "utf8");
|
|
9161
9097
|
slideInfo.snippetsUsed ??= {};
|
|
9162
9098
|
slideInfo.snippetsUsed[src] = content;
|
|
9163
9099
|
if (regionName) {
|
|
@@ -9242,7 +9178,7 @@ function transformMonaco(ctx) {
|
|
|
9242
9178
|
return;
|
|
9243
9179
|
}
|
|
9244
9180
|
ctx.s.replace(
|
|
9245
|
-
/^```(\w+) *\{monaco-diff\} *(?:(\{[^\n
|
|
9181
|
+
/^```(\w+) *\{monaco-diff\} *(?:(\{[^\n]*\}) *)?\n([\s\S]+?)^~~~ *\n([\s\S]+?)^```/gm,
|
|
9246
9182
|
(full, lang = "ts", options = "{}", code, diff) => {
|
|
9247
9183
|
lang = lang.trim();
|
|
9248
9184
|
options = options.trim() || "{}";
|
|
@@ -9252,7 +9188,7 @@ function transformMonaco(ctx) {
|
|
|
9252
9188
|
}
|
|
9253
9189
|
);
|
|
9254
9190
|
ctx.s.replace(
|
|
9255
|
-
/^```(\w+) *\{monaco\} *(?:(\{[
|
|
9191
|
+
/^```(\w+) *\{monaco\} *(?:(\{[^\n]*\}) *)?\n([\s\S]+?)^```/gm,
|
|
9256
9192
|
(full, lang = "ts", options = "{}", code) => {
|
|
9257
9193
|
lang = lang.trim();
|
|
9258
9194
|
options = options.trim() || "{}";
|
|
@@ -9261,7 +9197,7 @@ function transformMonaco(ctx) {
|
|
|
9261
9197
|
}
|
|
9262
9198
|
);
|
|
9263
9199
|
ctx.s.replace(
|
|
9264
|
-
/^```(\w+) *\{monaco-run\} *(?:(\{[
|
|
9200
|
+
/^```(\w+) *\{monaco-run\} *(?:(\{[^\n]*\}) *)?\n([\s\S]+?)^```/gm,
|
|
9265
9201
|
(full, lang = "ts", options = "{}", code) => {
|
|
9266
9202
|
lang = lang.trim();
|
|
9267
9203
|
options = options.trim() || "{}";
|
|
@@ -9294,7 +9230,7 @@ $$
|
|
|
9294
9230
|
async function createMarkdownPlugin(options, { markdown: mdOptions }) {
|
|
9295
9231
|
const { data: { config }, roots, mode, entry, clientRoot } = options;
|
|
9296
9232
|
const setups = [];
|
|
9297
|
-
const entryPath =
|
|
9233
|
+
const entryPath = slash3(entry);
|
|
9298
9234
|
let shiki;
|
|
9299
9235
|
let shikiOptions;
|
|
9300
9236
|
if (config.highlighter === "shiki") {
|
|
@@ -9450,9 +9386,9 @@ function createVueCompilerFlagsPlugin(options) {
|
|
|
9450
9386
|
}
|
|
9451
9387
|
|
|
9452
9388
|
// node/vite/monacoTypes.ts
|
|
9453
|
-
import
|
|
9389
|
+
import fs7 from "node:fs/promises";
|
|
9454
9390
|
import { dirname as dirname2, resolve as resolve5 } from "node:path";
|
|
9455
|
-
import { slash as
|
|
9391
|
+
import { slash as slash4 } from "@antfu/utils";
|
|
9456
9392
|
import fg4 from "fast-glob";
|
|
9457
9393
|
import { findDepPkgJsonPath } from "vitefu";
|
|
9458
9394
|
function createMonacoTypesLoader({ userRoot, utils }) {
|
|
@@ -9474,8 +9410,8 @@ function createMonacoTypesLoader({ userRoot, utils }) {
|
|
|
9474
9410
|
const pkgJsonPath = await findDepPkgJsonPath(pkg, importer);
|
|
9475
9411
|
if (!pkgJsonPath)
|
|
9476
9412
|
throw new Error(`Package "${pkg}" not found in "${importer}"`);
|
|
9477
|
-
const root =
|
|
9478
|
-
const pkgJson = JSON.parse(await
|
|
9413
|
+
const root = slash4(dirname2(pkgJsonPath));
|
|
9414
|
+
const pkgJson = JSON.parse(await fs7.readFile(pkgJsonPath, "utf-8"));
|
|
9479
9415
|
let deps = Object.keys(pkgJson.dependencies ?? {});
|
|
9480
9416
|
deps = deps.filter((pkg2) => !utils.isMonacoTypesIgnored(pkg2));
|
|
9481
9417
|
return [
|
|
@@ -9585,7 +9521,7 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
9585
9521
|
data: { config }
|
|
9586
9522
|
} = options;
|
|
9587
9523
|
const drawingData = await loadDrawings(options);
|
|
9588
|
-
const publicRoots = [...themeRoots, ...addonRoots].map((i) =>
|
|
9524
|
+
const publicRoots = [...themeRoots, ...addonRoots].map((i) => join9(i, "public")).filter(existsSync5);
|
|
9589
9525
|
const plugins = [
|
|
9590
9526
|
createMarkdownPlugin(options, pluginOptions),
|
|
9591
9527
|
createVuePlugin(options, pluginOptions),
|
|
@@ -9594,11 +9530,11 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
9594
9530
|
Components({
|
|
9595
9531
|
extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
|
|
9596
9532
|
dirs: [
|
|
9597
|
-
|
|
9598
|
-
...roots.map((i) =>
|
|
9533
|
+
join9(options.clientRoot, "builtin"),
|
|
9534
|
+
...roots.map((i) => join9(i, "components")),
|
|
9599
9535
|
"src/components",
|
|
9600
9536
|
"components",
|
|
9601
|
-
|
|
9537
|
+
join9(process2.cwd(), "components")
|
|
9602
9538
|
],
|
|
9603
9539
|
include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
|
|
9604
9540
|
exclude: [],
|
|
@@ -9667,10 +9603,85 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
9667
9603
|
return (await Promise.all(plugins)).flat().filter(notNullish2);
|
|
9668
9604
|
}
|
|
9669
9605
|
|
|
9606
|
+
// node/commands/shared.ts
|
|
9607
|
+
var sharedMd = MarkdownIt({ html: true });
|
|
9608
|
+
sharedMd.use(markdownItLink);
|
|
9609
|
+
function getSlideTitle(data) {
|
|
9610
|
+
const tokens = sharedMd.parseInline(data.config.title, {});
|
|
9611
|
+
const title = stringifyMarkdownTokens(tokens);
|
|
9612
|
+
const slideTitle = data.config.titleTemplate.replace("%s", title);
|
|
9613
|
+
return slideTitle === "Slidev - Slidev" ? "Slidev" : slideTitle;
|
|
9614
|
+
}
|
|
9615
|
+
function escapeHtml(unsafe) {
|
|
9616
|
+
return JSON.stringify(
|
|
9617
|
+
String(unsafe).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'")
|
|
9618
|
+
);
|
|
9619
|
+
}
|
|
9620
|
+
async function getIndexHtml({ entry, clientRoot, roots, data }) {
|
|
9621
|
+
let main = await fs8.readFile(join10(clientRoot, "index.html"), "utf-8");
|
|
9622
|
+
let head = "";
|
|
9623
|
+
let body = "";
|
|
9624
|
+
const { info, author, keywords } = data.headmatter;
|
|
9625
|
+
head += [
|
|
9626
|
+
`<meta name="slidev:version" content="${version}">`,
|
|
9627
|
+
`<meta charset="slidev:entry" content="${slash5(entry)}">`,
|
|
9628
|
+
`<link rel="icon" href="${data.config.favicon}">`,
|
|
9629
|
+
`<title>${getSlideTitle(data)}</title>`,
|
|
9630
|
+
info && `<meta name="description" content=${escapeHtml(info)}>`,
|
|
9631
|
+
author && `<meta name="author" content=${escapeHtml(author)}>`,
|
|
9632
|
+
keywords && `<meta name="keywords" content=${escapeHtml(Array.isArray(keywords) ? keywords.join(", ") : keywords)}>`
|
|
9633
|
+
].filter(Boolean).join("\n");
|
|
9634
|
+
for (const root of roots) {
|
|
9635
|
+
const path4 = join10(root, "index.html");
|
|
9636
|
+
if (!existsSync6(path4))
|
|
9637
|
+
continue;
|
|
9638
|
+
const index = await fs8.readFile(path4, "utf-8");
|
|
9639
|
+
head += `
|
|
9640
|
+
${(index.match(/<head>([\s\S]*?)<\/head>/i)?.[1] || "").trim()}`;
|
|
9641
|
+
body += `
|
|
9642
|
+
${(index.match(/<body>([\s\S]*?)<\/body>/i)?.[1] || "").trim()}`;
|
|
9643
|
+
}
|
|
9644
|
+
if (data.features.tweet)
|
|
9645
|
+
body += '\n<script async src="https://platform.twitter.com/widgets.js"></script>';
|
|
9646
|
+
if (data.config.fonts.webfonts.length && data.config.fonts.provider !== "none")
|
|
9647
|
+
head += `
|
|
9648
|
+
<link rel="stylesheet" href="${generateGoogleFontsUrl(data.config.fonts)}" type="text/css">`;
|
|
9649
|
+
main = main.replace("__ENTRY__", toAtFS(join10(clientRoot, "main.ts"))).replace("<!-- head -->", head).replace("<!-- body -->", body);
|
|
9650
|
+
return main;
|
|
9651
|
+
}
|
|
9652
|
+
async function resolveViteConfigs(options, baseConfig, overrideConfigs, command, serverOptions) {
|
|
9653
|
+
const configEnv = {
|
|
9654
|
+
mode: command === "build" ? "production" : "development",
|
|
9655
|
+
command
|
|
9656
|
+
};
|
|
9657
|
+
const files = options.roots.map((i) => join10(i, "vite.config.ts"));
|
|
9658
|
+
for (const file of files) {
|
|
9659
|
+
if (!existsSync6(file))
|
|
9660
|
+
continue;
|
|
9661
|
+
const viteConfig = await loadConfigFromFile(configEnv, file);
|
|
9662
|
+
if (!viteConfig?.config)
|
|
9663
|
+
continue;
|
|
9664
|
+
baseConfig = mergeConfig2(baseConfig, viteConfig.config);
|
|
9665
|
+
}
|
|
9666
|
+
baseConfig = mergeConfig2(baseConfig, overrideConfigs);
|
|
9667
|
+
baseConfig = mergeConfig2(baseConfig, {
|
|
9668
|
+
configFile: false,
|
|
9669
|
+
root: options.userRoot,
|
|
9670
|
+
plugins: [
|
|
9671
|
+
await ViteSlidevPlugin(options, baseConfig.slidev || {}, serverOptions)
|
|
9672
|
+
],
|
|
9673
|
+
define: {
|
|
9674
|
+
// Fixes Vue production mode breaking PDF Export #1245
|
|
9675
|
+
__VUE_PROD_DEVTOOLS__: false
|
|
9676
|
+
}
|
|
9677
|
+
});
|
|
9678
|
+
return baseConfig;
|
|
9679
|
+
}
|
|
9680
|
+
|
|
9670
9681
|
export {
|
|
9671
9682
|
version,
|
|
9672
9683
|
getIndexHtml,
|
|
9673
|
-
|
|
9684
|
+
resolveViteConfigs,
|
|
9674
9685
|
parser,
|
|
9675
9686
|
resolveTheme,
|
|
9676
9687
|
getThemeMeta,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveViteConfigs
|
|
3
|
+
} from "./chunk-4LA667A3.mjs";
|
|
4
|
+
|
|
5
|
+
// node/commands/server.ts
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import { createServer as createViteServer } from "vite";
|
|
9
|
+
async function createServer(options, viteConfig = {}, serverOptions) {
|
|
10
|
+
process.env.EDITOR = process.env.EDITOR || "code";
|
|
11
|
+
const inlineConfig = await resolveViteConfigs(
|
|
12
|
+
options,
|
|
13
|
+
{
|
|
14
|
+
optimizeDeps: {
|
|
15
|
+
entries: [
|
|
16
|
+
join(options.clientRoot, "main.ts")
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
viteConfig,
|
|
21
|
+
"serve",
|
|
22
|
+
serverOptions
|
|
23
|
+
);
|
|
24
|
+
return await createViteServer(inlineConfig);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
createServer
|
|
29
|
+
};
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-G75DCGK3.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getThemeMeta,
|
|
6
6
|
parser,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
resolveOptions,
|
|
9
9
|
resolveTheme,
|
|
10
10
|
version
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4LA667A3.mjs";
|
|
12
12
|
import {
|
|
13
13
|
loadSetups
|
|
14
14
|
} from "./chunk-LOUKLO2C.mjs";
|
|
@@ -328,7 +328,7 @@ cli.command(
|
|
|
328
328
|
}).strict().help(),
|
|
329
329
|
async (args) => {
|
|
330
330
|
const { entry, theme, base, download, out, inspect } = args;
|
|
331
|
-
const { build } = await import("./build-
|
|
331
|
+
const { build } = await import("./build-2HGCTOR5.mjs");
|
|
332
332
|
for (const entryFile of entry) {
|
|
333
333
|
const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
|
|
334
334
|
if (download && !options.data.config.download)
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-G75DCGK3.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ViteSlidevPlugin,
|
|
6
6
|
createDataUtils,
|
|
7
7
|
parser,
|
|
8
8
|
resolveOptions
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4LA667A3.mjs";
|
|
10
10
|
import "./chunk-LOUKLO2C.mjs";
|
|
11
11
|
import "./chunk-RG2EEPCO.mjs";
|
|
12
12
|
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.11",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -110,9 +110,9 @@
|
|
|
110
110
|
"vitefu": "^0.2.5",
|
|
111
111
|
"vue": "^3.4.27",
|
|
112
112
|
"yargs": "^17.7.2",
|
|
113
|
-
"@slidev/
|
|
114
|
-
"@slidev/parser": "0.49.
|
|
115
|
-
"@slidev/
|
|
113
|
+
"@slidev/client": "0.49.11",
|
|
114
|
+
"@slidev/parser": "0.49.11",
|
|
115
|
+
"@slidev/types": "0.49.11"
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
118
|
"@hedgedoc/markdown-it-plugins": "^2.1.4",
|
package/template.md
CHANGED
|
@@ -49,23 +49,23 @@ transition: fade-out
|
|
|
49
49
|
|
|
50
50
|
# What is Slidev?
|
|
51
51
|
|
|
52
|
-
Slidev is a
|
|
52
|
+
Slidev is a slide maker and accompanying presentation tool designed for developers. It consists of the following features:
|
|
53
53
|
|
|
54
|
-
- 📝 **Text-based** - focus on the content with Markdown, and
|
|
55
|
-
- 🎨 **Themable** -
|
|
54
|
+
- 📝 **Text-based** - focus on the content with Markdown, and apply styles later
|
|
55
|
+
- 🎨 **Themable** - themes can be shared and used as npm packages
|
|
56
56
|
- 🧑💻 **Developer Friendly** - code highlighting, live coding with autocompletion
|
|
57
|
-
- 🤹 **Interactive** - embedding Vue components to enhance your
|
|
57
|
+
- 🤹 **Interactive** - embedding Vue components to enhance your slides
|
|
58
58
|
- 🎥 **Recording** - built-in recording and camera view
|
|
59
|
-
- 📤 **Portable** - export
|
|
60
|
-
- 🛠 **Hackable** - anything possible on a webpage
|
|
59
|
+
- 📤 **Portable** - export to PDF, PPTX, PNGs, or even a hostable SPA
|
|
60
|
+
- 🛠 **Hackable** - virtually anything that's possible on a webpage is possible in Slidev
|
|
61
61
|
|
|
62
62
|
<br>
|
|
63
63
|
<br>
|
|
64
64
|
|
|
65
|
-
Read more about [Why Slidev?](https://sli.dev/guide/why)
|
|
65
|
+
Read more about Slidev in [Why Slidev?](https://sli.dev/guide/why)
|
|
66
66
|
|
|
67
67
|
<!--
|
|
68
|
-
You can have `style`
|
|
68
|
+
You can have `style` tags in markdown to override the style for the current page.
|
|
69
69
|
Learn more: https://sli.dev/guide/syntax#embedded-styles
|
|
70
70
|
-->
|
|
71
71
|
|
|
@@ -104,7 +104,7 @@ level: 2
|
|
|
104
104
|
|
|
105
105
|
# Navigation
|
|
106
106
|
|
|
107
|
-
Hover on the bottom-left corner to see the navigation's
|
|
107
|
+
Hover on the bottom-left corner to see the navigation's control panel, [learn more](https://sli.dev/guide/navigation.html)
|
|
108
108
|
|
|
109
109
|
## Keyboard Shortcuts
|
|
110
110
|
|
|
@@ -131,7 +131,7 @@ image: https://cover.sli.dev
|
|
|
131
131
|
|
|
132
132
|
# Code
|
|
133
133
|
|
|
134
|
-
Use code snippets and get
|
|
134
|
+
Use code snippets and get automatic highlighting, and even types hover![^1]
|
|
135
135
|
|
|
136
136
|
```ts {all|5|7|7-8|10|all} twoslash
|
|
137
137
|
// TwoSlash enables TypeScript hover information
|
|
@@ -176,7 +176,7 @@ doubled.value = 2
|
|
|
176
176
|
|
|
177
177
|
You can use Vue components directly inside your slides.
|
|
178
178
|
|
|
179
|
-
We have provided a few built-in components like `<Tweet/>` and `<Youtube/>` that you can use directly.
|
|
179
|
+
We have provided a few built-in components like `<Tweet/>` and `<Youtube/>` that you can use directly. Adding your own custom components is also super easy.
|
|
180
180
|
|
|
181
181
|
```html
|
|
182
182
|
<Counter :count="10" />
|
|
@@ -200,7 +200,7 @@ Check out [the guides](https://sli.dev/builtin/components.html) for more.
|
|
|
200
200
|
</div>
|
|
201
201
|
|
|
202
202
|
<!--
|
|
203
|
-
Presenter
|
|
203
|
+
Presenter notes with **bold**, *italic*, and ~~strike~~ text.
|
|
204
204
|
|
|
205
205
|
Also, HTML elements are valid:
|
|
206
206
|
<div class="flex w-full">
|
|
@@ -215,7 +215,7 @@ class: px-20
|
|
|
215
215
|
|
|
216
216
|
# Themes
|
|
217
217
|
|
|
218
|
-
Slidev comes with powerful theming support. Themes can provide styles, layouts, components, or even configurations for tools.
|
|
218
|
+
Slidev comes with powerful theming support. Themes can provide styles, layouts, components, or even configurations for tools. Switch between themes on a per-slide basis with just **one change** in your frontmatter:
|
|
219
219
|
|
|
220
220
|
<div grid="~ cols-2 gap-2" m="t-2">
|
|
221
221
|
|
|
@@ -294,7 +294,7 @@ Animations are powered by [@vueuse/motion](https://motion.vueuse.org/).
|
|
|
294
294
|
</div>
|
|
295
295
|
</div>
|
|
296
296
|
|
|
297
|
-
<!-- vue script setup scripts can be directly used in markdown, and will only
|
|
297
|
+
<!-- vue script setup scripts can be directly used in markdown, and will only affect the current page -->
|
|
298
298
|
<script setup lang="ts">
|
|
299
299
|
const final = {
|
|
300
300
|
x: 0,
|
|
@@ -432,4 +432,4 @@ class: text-center
|
|
|
432
432
|
|
|
433
433
|
# Learn More
|
|
434
434
|
|
|
435
|
-
[
|
|
435
|
+
[Documentation](https://sli.dev) · [GitHub](https://github.com/slidevjs/slidev) · [Showcases](https://sli.dev/showcases.html)
|
package/dist/chunk-DRWYFCYG.mjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ViteSlidevPlugin,
|
|
3
|
-
mergeViteConfigs
|
|
4
|
-
} from "./chunk-ZATTXN6U.mjs";
|
|
5
|
-
|
|
6
|
-
// node/commands/server.ts
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
import process from "node:process";
|
|
9
|
-
import { createServer as createViteServer, mergeConfig } from "vite";
|
|
10
|
-
async function createServer(options, viteConfig = {}, serverOptions = {}) {
|
|
11
|
-
process.env.EDITOR = process.env.EDITOR || "code";
|
|
12
|
-
const config = await mergeViteConfigs(
|
|
13
|
-
options,
|
|
14
|
-
viteConfig,
|
|
15
|
-
{
|
|
16
|
-
root: options.userRoot,
|
|
17
|
-
optimizeDeps: {
|
|
18
|
-
entries: [
|
|
19
|
-
join(options.clientRoot, "main.ts")
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"serve"
|
|
24
|
-
);
|
|
25
|
-
const server = await createViteServer(
|
|
26
|
-
mergeConfig(
|
|
27
|
-
config,
|
|
28
|
-
{
|
|
29
|
-
plugins: [
|
|
30
|
-
await ViteSlidevPlugin(options, config.slidev || {}, serverOptions)
|
|
31
|
-
],
|
|
32
|
-
define: {
|
|
33
|
-
// Fixes Vue production mode breaking PDF Export #1245
|
|
34
|
-
__VUE_PROD_DEVTOOLS__: JSON.stringify(true)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
return server;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
createServer
|
|
44
|
-
};
|