@slidev/cli 0.48.0-beta.9 → 0.48.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.
@@ -0,0 +1,2216 @@
1
+ import {
2
+ loadSetups
3
+ } from "./chunk-LOUKLO2C.mjs";
4
+ import {
5
+ resolveImportPath,
6
+ resolveImportUrl,
7
+ toAtFS
8
+ } from "./chunk-AQQIBD5X.mjs";
9
+
10
+ // node/commands/shared.ts
11
+ import { existsSync, promises as fs } from "node:fs";
12
+ import { join } from "node:path";
13
+ import { loadConfigFromFile, mergeConfig, resolveConfig } from "vite";
14
+
15
+ // node/utils.ts
16
+ function stringifyMarkdownTokens(tokens) {
17
+ 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(" ");
18
+ }
19
+ function generateGoogleFontsUrl(options) {
20
+ const weights = options.weights.flatMap((i) => options.italic ? [`0,${i}`, `1,${i}`] : [`${i}`]).sort().join(";");
21
+ const fonts = options.webfonts.map((i) => `family=${i.replace(/^(['"])(.*)\1$/, "$1").replace(/\s+/g, "+")}:${options.italic ? "ital," : ""}wght@${weights}`).join("&");
22
+ return `https://fonts.googleapis.com/css2?${fonts}&display=swap`;
23
+ }
24
+
25
+ // node/commands/shared.ts
26
+ async function getIndexHtml({ clientRoot, roots, data }) {
27
+ let main = await fs.readFile(join(clientRoot, "index.html"), "utf-8");
28
+ let head = "";
29
+ let body = "";
30
+ head += `<link rel="icon" href="${data.config.favicon}">`;
31
+ for (const root of roots) {
32
+ const path2 = join(root, "index.html");
33
+ if (!existsSync(path2))
34
+ continue;
35
+ const index = await fs.readFile(path2, "utf-8");
36
+ head += `
37
+ ${(index.match(/<head>([\s\S]*?)<\/head>/im)?.[1] || "").trim()}`;
38
+ body += `
39
+ ${(index.match(/<body>([\s\S]*?)<\/body>/im)?.[1] || "").trim()}`;
40
+ }
41
+ if (data.features.tweet)
42
+ body += '\n<script async src="https://platform.twitter.com/widgets.js"></script>';
43
+ if (data.config.fonts.webfonts.length && data.config.fonts.provider !== "none")
44
+ head += `
45
+ <link rel="stylesheet" href="${generateGoogleFontsUrl(data.config.fonts)}" type="text/css">`;
46
+ main = main.replace("__ENTRY__", toAtFS(join(clientRoot, "main.ts"))).replace("<!-- head -->", head).replace("<!-- body -->", body);
47
+ return main;
48
+ }
49
+ async function mergeViteConfigs({ roots, entry }, viteConfig, config, command) {
50
+ const configEnv = {
51
+ mode: "development",
52
+ command
53
+ };
54
+ const files = roots.map((i) => join(i, "vite.config.ts"));
55
+ for await (const file of files) {
56
+ if (!existsSync(file))
57
+ continue;
58
+ const viteConfig2 = await loadConfigFromFile(configEnv, file);
59
+ if (!viteConfig2?.config)
60
+ continue;
61
+ config = mergeConfig(config, viteConfig2.config);
62
+ }
63
+ config = mergeConfig(config, viteConfig);
64
+ const localConfig = await resolveConfig({}, command, entry);
65
+ config = mergeConfig(config, { slidev: localConfig.slidev || {} });
66
+ return config;
67
+ }
68
+
69
+ // node/vite/index.ts
70
+ import { join as join8 } from "node:path";
71
+ import { existsSync as existsSync5 } from "node:fs";
72
+ import process from "node:process";
73
+ import { fileURLToPath } from "node:url";
74
+ import Icons from "unplugin-icons/vite";
75
+ import IconsResolver from "unplugin-icons/resolver";
76
+ import Components from "unplugin-vue-components/vite";
77
+ import ServerRef from "vite-plugin-vue-server-ref";
78
+ import { notNullish as notNullish2 } from "@antfu/utils";
79
+
80
+ // node/integrations/drawings.ts
81
+ import { basename, dirname, join as join2, resolve } from "node:path";
82
+ import fs2 from "fs-extra";
83
+ import fg from "fast-glob";
84
+ function resolveDrawingsDir(options) {
85
+ return options.data.config.drawings.persist ? resolve(
86
+ dirname(options.entry),
87
+ options.data.config.drawings.persist
88
+ ) : void 0;
89
+ }
90
+ async function loadDrawings(options) {
91
+ const dir = resolveDrawingsDir(options);
92
+ if (!dir || !fs2.existsSync(dir))
93
+ return {};
94
+ const files = await fg("*.svg", {
95
+ onlyFiles: true,
96
+ cwd: dir,
97
+ absolute: true,
98
+ suppressErrors: true
99
+ });
100
+ const obj = {};
101
+ await Promise.all(files.map(async (path2) => {
102
+ const num = +basename(path2, ".svg");
103
+ if (Number.isNaN(num))
104
+ return;
105
+ const content = await fs2.readFile(path2, "utf8");
106
+ const lines = content.split(/\n/g);
107
+ obj[num.toString()] = lines.slice(1, -1).join("\n");
108
+ }));
109
+ return obj;
110
+ }
111
+ async function writeDrawings(options, drawing) {
112
+ const dir = resolveDrawingsDir(options);
113
+ if (!dir)
114
+ return;
115
+ const width = options.data.config.canvasWidth;
116
+ const height = Math.round(width / options.data.config.aspectRatio);
117
+ const SVG_HEAD = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
118
+ await fs2.ensureDir(dir);
119
+ return Promise.all(
120
+ Object.entries(drawing).map(async ([key, value]) => {
121
+ if (!value)
122
+ return;
123
+ const svg = `${SVG_HEAD}
124
+ ${value}
125
+ </svg>`;
126
+ await fs2.writeFile(join2(dir, `${key}.svg`), svg, "utf-8");
127
+ })
128
+ );
129
+ }
130
+
131
+ // node/vite/extendConfig.ts
132
+ import { join as join3 } from "node:path";
133
+ import { mergeConfig as mergeConfig2 } from "vite";
134
+ import isInstalledGlobally from "is-installed-globally";
135
+ import { uniq } from "@antfu/utils";
136
+
137
+ // ../client/package.json
138
+ var dependencies = {
139
+ "@antfu/utils": "^0.7.7",
140
+ "@iconify-json/carbon": "^1.1.31",
141
+ "@iconify-json/ph": "^1.1.11",
142
+ "@iconify-json/svg-spinners": "^1.1.2",
143
+ "@shikijs/monaco": "^1.1.7",
144
+ "@shikijs/vitepress-twoslash": "^1.1.7",
145
+ "@slidev/parser": "workspace:*",
146
+ "@slidev/rough-notation": "^0.1.0",
147
+ "@slidev/types": "workspace:*",
148
+ "@typescript/ata": "^0.9.4",
149
+ "@unhead/vue": "^1.8.11",
150
+ "@unocss/reset": "^0.58.5",
151
+ "@vueuse/core": "^10.9.0",
152
+ "@vueuse/math": "^10.9.0",
153
+ "@vueuse/motion": "^2.1.0",
154
+ codemirror: "^5.65.16",
155
+ drauu: "^0.4.0",
156
+ "file-saver": "^2.0.5",
157
+ "floating-vue": "^5.2.2",
158
+ "fuse.js": "^7.0.0",
159
+ "js-yaml": "^4.1.0",
160
+ katex: "^0.16.9",
161
+ "lz-string": "^1.5.0",
162
+ mermaid: "^10.9.0",
163
+ "monaco-editor": "^0.46.0",
164
+ prettier: "^3.2.5",
165
+ recordrtc: "^5.6.2",
166
+ shiki: "^1.1.7",
167
+ "shiki-magic-move": "^0.3.4",
168
+ typescript: "^5.4.2",
169
+ unocss: "^0.58.5",
170
+ vue: "^3.4.21",
171
+ "vue-demi": "^0.14.7",
172
+ "vue-router": "^4.3.0"
173
+ };
174
+
175
+ // node/vite/extendConfig.ts
176
+ var INCLUDE = [
177
+ ...Object.keys(dependencies),
178
+ // CodeMirror
179
+ "codemirror/mode/javascript/javascript",
180
+ "codemirror/mode/css/css",
181
+ "codemirror/mode/markdown/markdown",
182
+ "codemirror/mode/xml/xml",
183
+ "codemirror/mode/htmlmixed/htmlmixed",
184
+ "codemirror/addon/display/placeholder",
185
+ // Monaco
186
+ "monaco-editor/esm/vs/editor/standalone/browser/standaloneServices",
187
+ "monaco-editor/esm/vs/platform/contextview/browser/contextViewService",
188
+ "monaco-editor/esm/vs/platform/instantiation/common/descriptors",
189
+ // Others
190
+ "shiki-magic-move/vue"
191
+ ];
192
+ var EXCLUDE = [
193
+ "@slidev/shared",
194
+ "@slidev/types",
195
+ "@slidev/client",
196
+ "@slidev/client/constants",
197
+ "@slidev/client/logic/dark",
198
+ "@vueuse/core",
199
+ "@vueuse/math",
200
+ "@vueuse/shared",
201
+ "@unocss/reset",
202
+ "unocss",
203
+ "mermaid",
204
+ "vue-demi",
205
+ "vue",
206
+ "shiki"
207
+ ];
208
+ var ASYNC_MODULES = [
209
+ "file-saver",
210
+ "vue",
211
+ "@vue"
212
+ ];
213
+ function createConfigPlugin(options) {
214
+ return {
215
+ name: "slidev:config",
216
+ async config(config) {
217
+ const injection = {
218
+ define: getDefine(options),
219
+ resolve: {
220
+ alias: [
221
+ {
222
+ find: /^@slidev\/client$/,
223
+ replacement: `${toAtFS(options.clientRoot)}/index.ts`
224
+ },
225
+ {
226
+ find: /^@slidev\/client\/(.*)/,
227
+ replacement: `${toAtFS(options.clientRoot)}/$1`
228
+ },
229
+ {
230
+ find: /^#slidev\/(.*)/,
231
+ replacement: "/@slidev/$1"
232
+ },
233
+ {
234
+ find: "vue",
235
+ replacement: await resolveImportPath("vue/dist/vue.esm-browser.js", true)
236
+ }
237
+ ],
238
+ dedupe: ["vue"]
239
+ },
240
+ optimizeDeps: {
241
+ exclude: EXCLUDE,
242
+ include: INCLUDE.filter((i) => !EXCLUDE.includes(i)).map((i) => `@slidev/cli > @slidev/client > ${i}`)
243
+ },
244
+ css: options.data.config.css === "unocss" ? {
245
+ postcss: {
246
+ plugins: [
247
+ await import("postcss-nested").then((r) => (r.default || r)())
248
+ ]
249
+ }
250
+ } : {},
251
+ server: {
252
+ fs: {
253
+ strict: true,
254
+ allow: uniq([
255
+ options.userWorkspaceRoot,
256
+ options.cliRoot,
257
+ options.clientRoot,
258
+ ...options.roots
259
+ ])
260
+ }
261
+ },
262
+ publicDir: join3(options.userRoot, "public"),
263
+ build: {
264
+ rollupOptions: {
265
+ output: {
266
+ chunkFileNames(chunkInfo) {
267
+ const DEFAULT = "assets/[name]-[hash].js";
268
+ if (chunkInfo.name.includes("/"))
269
+ return DEFAULT;
270
+ if (chunkInfo.moduleIds.filter((i) => isSlidevClient(i)).length > chunkInfo.moduleIds.length * 0.6)
271
+ return "assets/slidev/[name]-[hash].js";
272
+ if (chunkInfo.moduleIds.filter((i) => i.match(/\/monaco-editor(-core)?\//)).length > chunkInfo.moduleIds.length * 0.6)
273
+ return "assets/monaco/[name]-[hash].js";
274
+ return DEFAULT;
275
+ },
276
+ manualChunks(id) {
277
+ if (id.startsWith("/@slidev-monaco-types/") || id.includes("/@slidev/monaco-types") || id.endsWith("?monaco-types&raw"))
278
+ return "monaco/bundled-types";
279
+ if (id.includes("/shiki/") || id.includes("/@shikijs/"))
280
+ return `modules/shiki`;
281
+ if (id.startsWith("~icons/"))
282
+ return "modules/unplugin-icons";
283
+ const matchedAsyncModule = ASYNC_MODULES.find((i) => id.includes(`/node_modules/${i}`));
284
+ if (matchedAsyncModule)
285
+ return `modules/${matchedAsyncModule.replace("@", "").replace("/", "-")}`;
286
+ }
287
+ }
288
+ }
289
+ }
290
+ };
291
+ function isSlidevClient(id) {
292
+ return id.includes("/@slidev/") || id.includes("/slidev/packages/client/") || id.includes("/@vueuse/");
293
+ }
294
+ if (isInstalledGlobally) {
295
+ injection.cacheDir = join3(options.cliRoot, "node_modules/.vite");
296
+ injection.root = options.cliRoot;
297
+ }
298
+ return mergeConfig2(injection, config);
299
+ },
300
+ configureServer(server) {
301
+ return () => {
302
+ server.middlewares.use(async (req, res, next) => {
303
+ if (req.url.endsWith(".html")) {
304
+ res.setHeader("Content-Type", "text/html");
305
+ res.statusCode = 200;
306
+ res.end(await getIndexHtml(options));
307
+ return;
308
+ }
309
+ next();
310
+ });
311
+ };
312
+ }
313
+ };
314
+ }
315
+ function getDefine(options) {
316
+ return {
317
+ __DEV__: options.mode === "dev" ? "true" : "false",
318
+ __SLIDEV_CLIENT_ROOT__: JSON.stringify(toAtFS(options.clientRoot)),
319
+ __SLIDEV_HASH_ROUTE__: JSON.stringify(options.data.config.routerMode === "hash"),
320
+ __SLIDEV_FEATURE_DRAWINGS__: JSON.stringify(options.data.config.drawings.enabled === true || options.data.config.drawings.enabled === options.mode),
321
+ __SLIDEV_FEATURE_EDITOR__: JSON.stringify(options.mode === "dev" && options.data.config.editor !== false),
322
+ __SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
323
+ __SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
324
+ __SLIDEV_FEATURE_PRESENTER__: JSON.stringify(options.data.config.presenter === true || options.data.config.presenter === options.mode),
325
+ __SLIDEV_HAS_SERVER__: options.mode !== "build" ? "true" : "false"
326
+ };
327
+ }
328
+
329
+ // node/vite/loaders.ts
330
+ import { basename as basename2 } from "node:path";
331
+ import { isString as isString2, isTruthy as isTruthy2, notNullish, range } from "@antfu/utils";
332
+ import fg3 from "fast-glob";
333
+ import fs4 from "fs-extra";
334
+ import Markdown from "markdown-it";
335
+ import { bold, gray, red, yellow } from "kolorist";
336
+ import mila from "markdown-it-link-attributes";
337
+ import * as parser from "@slidev/parser/fs";
338
+ import equal from "fast-deep-equal";
339
+
340
+ // node/virtual/configs.ts
341
+ import { isString } from "@antfu/utils";
342
+ var templateConfigs = {
343
+ id: "/@slidev/configs",
344
+ getContent: async ({ data, remote }, { md: md2 }) => {
345
+ function getTitle() {
346
+ if (isString(data.config.title)) {
347
+ const tokens = md2.parseInline(data.config.title, {});
348
+ return stringifyMarkdownTokens(tokens);
349
+ }
350
+ return data.config.title;
351
+ }
352
+ const config = {
353
+ ...data.config,
354
+ remote,
355
+ title: getTitle()
356
+ };
357
+ if (isString(config.info))
358
+ config.info = md2.render(config.info);
359
+ return `export default ${JSON.stringify(config)}`;
360
+ }
361
+ };
362
+
363
+ // node/virtual/deprecated.ts
364
+ var templateLegacyRoutes = {
365
+ id: "/@slidev/routes",
366
+ getContent() {
367
+ return [
368
+ `export { slides } from '#slidev/slides'`,
369
+ `console.warn('[slidev] #slidev/routes is deprecated, use #slidev/slides instead')`
370
+ ].join("\n");
371
+ }
372
+ };
373
+ var templateLegacyTitles = {
374
+ id: "/@slidev/titles.md",
375
+ async getContent() {
376
+ return `
377
+ <script setup lang="ts">
378
+ import TitleRenderer from '#slidev/title-renderer'
379
+ defineProps<{ no: number | string }>()
380
+ console.warn('/@slidev/titles.md is deprecated, import from #slidev/title-renderer instead')
381
+ </script>
382
+
383
+ <TitleRenderer :no="no" />
384
+ `;
385
+ }
386
+ };
387
+
388
+ // node/virtual/global-components.ts
389
+ import { existsSync as existsSync2 } from "node:fs";
390
+ import { join as join4 } from "node:path";
391
+ function createGlobalComponentTemplate(layer) {
392
+ return {
393
+ id: `/@slidev/global-components/${layer}`,
394
+ getContent({ roots }) {
395
+ const components = roots.flatMap((root) => {
396
+ if (layer === "top") {
397
+ return [
398
+ join4(root, "global.vue"),
399
+ join4(root, "global-top.vue"),
400
+ join4(root, "GlobalTop.vue")
401
+ ];
402
+ } else {
403
+ return [
404
+ join4(root, "global-bottom.vue"),
405
+ join4(root, "GlobalBottom.vue")
406
+ ];
407
+ }
408
+ }).filter((i) => existsSync2(i));
409
+ const imports = components.map((i, idx) => `import __n${idx} from '${toAtFS(i)}'`).join("\n");
410
+ const render = components.map((i, idx) => `h(__n${idx})`).join(",");
411
+ return `
412
+ ${imports}
413
+ import { h } from 'vue'
414
+ export default {
415
+ render() {
416
+ return [${render}]
417
+ }
418
+ }
419
+ `;
420
+ }
421
+ };
422
+ }
423
+ var templateNavControls = {
424
+ id: "/@slidev/custom-nav-controls",
425
+ getContent({ roots }) {
426
+ const components = roots.flatMap((root) => {
427
+ return [
428
+ join4(root, "custom-nav-controls.vue"),
429
+ join4(root, "CustomNavControls.vue")
430
+ ];
431
+ }).filter((i) => existsSync2(i));
432
+ const imports = components.map((i, idx) => `import __n${idx} from '${toAtFS(i)}'`).join("\n");
433
+ const render = components.map((i, idx) => `h(__n${idx})`).join(",");
434
+ return `
435
+ ${imports}
436
+ import { h } from 'vue'
437
+ export default {
438
+ render() {
439
+ return [${render}]
440
+ }
441
+ }
442
+ `;
443
+ }
444
+ };
445
+ var templateGlobalTop = createGlobalComponentTemplate("top");
446
+ var templateGlobalBottom = createGlobalComponentTemplate("bottom");
447
+
448
+ // node/virtual/layouts.ts
449
+ import { objectMap } from "@antfu/utils";
450
+ var templateLayouts = {
451
+ id: "/@slidev/layouts",
452
+ async getContent(_, { getLayouts }) {
453
+ const imports = [];
454
+ const layouts = objectMap(
455
+ await getLayouts(),
456
+ (k, v) => {
457
+ imports.push(`import __layout_${k} from "${toAtFS(v)}"`);
458
+ return [k, `__layout_${k}`];
459
+ }
460
+ );
461
+ return [
462
+ imports.join("\n"),
463
+ `export default {
464
+ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
465
+ }`
466
+ ].join("\n\n");
467
+ }
468
+ };
469
+
470
+ // node/virtual/monaco-types.ts
471
+ import { builtinModules } from "node:module";
472
+ import { join as join5, resolve as resolve2 } from "node:path";
473
+ import fg2 from "fast-glob";
474
+ import { uniq as uniq2 } from "@antfu/utils";
475
+
476
+ // node/syntax/transform/monaco.ts
477
+ import { isTruthy } from "@antfu/utils";
478
+ import lz from "lz-string";
479
+ function transformMonaco(md2, enabled = true) {
480
+ if (!enabled)
481
+ return truncateMancoMark(md2);
482
+ md2 = md2.replace(
483
+ /^```(\w+?)\s*{monaco-diff}\s*?({.*?})?\s*?\n([\s\S]+?)^~~~\s*?\n([\s\S]+?)^```/mg,
484
+ (full, lang = "ts", options = "{}", code, diff) => {
485
+ lang = lang.trim();
486
+ options = options.trim() || "{}";
487
+ const encoded = lz.compressToBase64(code);
488
+ const encodedDiff = lz.compressToBase64(diff);
489
+ return `<Monaco code-lz="${encoded}" diff-lz="${encodedDiff}" lang="${lang}" v-bind="${options}" />`;
490
+ }
491
+ );
492
+ md2 = md2.replace(
493
+ /^```(\w+?)\s*{monaco}\s*?({.*?})?\s*?\n([\s\S]+?)^```/mg,
494
+ (full, lang = "ts", options = "{}", code) => {
495
+ lang = lang.trim();
496
+ options = options.trim() || "{}";
497
+ const encoded = lz.compressToBase64(code);
498
+ return `<Monaco code-lz="${encoded}" lang="${lang}" v-bind="${options}" />`;
499
+ }
500
+ );
501
+ md2 = md2.replace(
502
+ /^```(\w+?)\s*{monaco-run}\s*?({.*?})?\s*?\n([\s\S]+?)^```/mg,
503
+ (full, lang = "ts", options = "{}", code) => {
504
+ lang = lang.trim();
505
+ options = options.trim() || "{}";
506
+ const encoded = lz.compressToBase64(code);
507
+ return `<Monaco runnable code-lz="${encoded}" lang="${lang}" v-bind="${options}" />`;
508
+ }
509
+ );
510
+ return md2;
511
+ }
512
+ function scanMonacoModules(md2) {
513
+ const typeModules = /* @__PURE__ */ new Set();
514
+ md2.replace(
515
+ /^```(\w+?)\s*{monaco([\w:,-]*)}[\s\n]*([\s\S]+?)^```/mg,
516
+ (full, lang = "ts", options, code) => {
517
+ options = options || "";
518
+ lang = lang.trim();
519
+ if (lang === "ts" || lang === "typescript") {
520
+ Array.from(code.matchAll(/\s+from\s+(["'])([\/\w@-]+)\1/g)).map((i) => i[2]).filter(isTruthy).map((i) => typeModules.add(i));
521
+ }
522
+ return "";
523
+ }
524
+ );
525
+ return Array.from(typeModules);
526
+ }
527
+ function truncateMancoMark(md2) {
528
+ return md2.replace(/{monaco([\w:,-]*)}/g, "");
529
+ }
530
+
531
+ // node/virtual/monaco-types.ts
532
+ var templateMonacoTypes = {
533
+ id: "/@slidev/monaco-types",
534
+ getContent: async ({ userRoot, data }) => {
535
+ const typesRoot = join5(userRoot, "snippets");
536
+ const files = await fg2(["**/*.ts", "**/*.mts", "**/*.cts"], { cwd: typesRoot });
537
+ let result = 'import { addFile } from "@slidev/client/setup/monaco.ts"\n';
538
+ for (const file of files) {
539
+ const url = `${toAtFS(resolve2(typesRoot, file))}?monaco-types&raw`;
540
+ result += `addFile(import(${JSON.stringify(url)}), ${JSON.stringify(file)})
541
+ `;
542
+ }
543
+ const deps = [...data.config.monacoTypesAdditionalPackages];
544
+ if (data.config.monacoTypesSource === "local")
545
+ deps.push(...scanMonacoModules(data.slides.map((s) => s.source.raw).join()));
546
+ function mapModuleNameToModule(moduleSpecifier) {
547
+ if (moduleSpecifier.startsWith("node:"))
548
+ return "node";
549
+ if (builtinModules.includes(moduleSpecifier))
550
+ return "node";
551
+ const mainPackageName = moduleSpecifier.split("/")[0];
552
+ if (builtinModules.includes(mainPackageName) && !mainPackageName.startsWith("@"))
553
+ return "node";
554
+ const [a = "", b = ""] = moduleSpecifier.split("/");
555
+ const moduleName = a.startsWith("@") ? `${a}/${b}` : a;
556
+ return moduleName;
557
+ }
558
+ for (const specifier of uniq2(deps)) {
559
+ if (specifier[0] === ".")
560
+ continue;
561
+ const moduleName = mapModuleNameToModule(specifier);
562
+ result += `import(${JSON.stringify(`/@slidev-monaco-types/resolve?pkg=${moduleName}`)})
563
+ `;
564
+ }
565
+ return result;
566
+ }
567
+ };
568
+
569
+ // node/virtual/setups.ts
570
+ import { existsSync as existsSync3 } from "node:fs";
571
+ import { join as join6 } from "node:path";
572
+ function createSetupTemplate(name) {
573
+ return {
574
+ id: `/@slidev/setups/${name}`,
575
+ getContent({ roots }) {
576
+ const setups = roots.flatMap((i) => {
577
+ const path2 = join6(i, "setup", name);
578
+ return [".ts", ".mts", ".js", ".mjs"].map((ext) => path2 + ext);
579
+ }).filter((i) => existsSync3(i));
580
+ const imports = [];
581
+ setups.forEach((path2, idx) => {
582
+ imports.push(`import __n${idx} from '${toAtFS(path2)}'`);
583
+ });
584
+ imports.push(`export default [${setups.map((_, idx) => `__n${idx}`).join(",")}]`);
585
+ return imports.join("\n");
586
+ }
587
+ };
588
+ }
589
+ var setupModules = ["shiki", "code-runners", "monaco", "mermaid", "main", "root", "shortcuts"];
590
+ var templateSetups = setupModules.map(createSetupTemplate);
591
+
592
+ // node/setups/shiki.ts
593
+ import fs3 from "node:fs/promises";
594
+ async function loadShikiSetups(clientRoot, roots) {
595
+ const result = await loadSetups(
596
+ clientRoot,
597
+ roots,
598
+ "shiki.ts",
599
+ {
600
+ /** @deprecated */
601
+ async loadTheme(path2) {
602
+ 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.");
603
+ return JSON.parse(await fs3.readFile(path2, "utf-8"));
604
+ }
605
+ },
606
+ {},
607
+ false
608
+ );
609
+ if ("theme" in result && "themes" in result)
610
+ delete result.theme;
611
+ if (result.theme && typeof result.theme !== "string" && !result.theme.name && !result.theme.tokenColors) {
612
+ result.themes = result.theme;
613
+ delete result.theme;
614
+ }
615
+ if (!result.theme && !result.themes) {
616
+ result.themes = {
617
+ dark: "vitesse-dark",
618
+ light: "vitesse-light"
619
+ };
620
+ }
621
+ if (result.themes)
622
+ result.defaultColor = false;
623
+ return result;
624
+ }
625
+
626
+ // node/virtual/shiki.ts
627
+ var templateShiki = {
628
+ id: "/@slidev/shiki",
629
+ getContent: async ({ clientRoot, roots }) => {
630
+ const options = await loadShikiSetups(clientRoot, roots);
631
+ const langs = await resolveLangs(options.langs || ["javascript", "typescript", "html", "css"]);
632
+ const resolvedThemeOptions = "themes" in options ? {
633
+ themes: Object.fromEntries(await Promise.all(
634
+ Object.entries(options.themes).map(async ([name, value]) => [name, await resolveTheme(value)])
635
+ ))
636
+ } : {
637
+ theme: await resolveTheme(options.theme || "vitesse-dark")
638
+ };
639
+ const themes = resolvedThemeOptions.themes ? Object.values(resolvedThemeOptions.themes) : [resolvedThemeOptions.theme];
640
+ const themeOptionsNames = resolvedThemeOptions.themes ? { themes: Object.fromEntries(Object.entries(resolvedThemeOptions.themes).map(([name, value]) => [name, typeof value === "string" ? value : value.name])) } : { theme: typeof resolvedThemeOptions.theme === "string" ? resolvedThemeOptions.theme : resolvedThemeOptions.theme.name };
641
+ async function normalizeGetter(p) {
642
+ return Promise.resolve(typeof p === "function" ? p() : p).then((r) => r.default || r);
643
+ }
644
+ async function resolveLangs(langs2) {
645
+ return Array.from(new Set((await Promise.all(
646
+ langs2.map(async (lang) => await normalizeGetter(lang).then((r) => Array.isArray(r) ? r : [r]))
647
+ )).flat()));
648
+ }
649
+ async function resolveTheme(theme) {
650
+ return typeof theme === "string" ? theme : await normalizeGetter(theme);
651
+ }
652
+ const langsInit = await Promise.all(
653
+ langs.map(async (lang) => typeof lang === "string" ? `import('${await resolveImportUrl(`shiki/langs/${lang}.mjs`)}')` : JSON.stringify(lang))
654
+ );
655
+ const themesInit = await Promise.all(themes.map(async (theme) => typeof theme === "string" ? `import('${await resolveImportUrl(`shiki/themes/${theme}.mjs`)}')` : JSON.stringify(theme)));
656
+ const langNames = langs.flatMap((lang) => typeof lang === "string" ? lang : lang.name);
657
+ const lines = [];
658
+ lines.push(
659
+ `import { getHighlighterCore } from "${await resolveImportUrl("shiki/core")}"`,
660
+ `export { shikiToMonaco } from "${await resolveImportUrl("@shikijs/monaco")}"`,
661
+ `export const languages = ${JSON.stringify(langNames)}`,
662
+ `export const themes = ${JSON.stringify(themeOptionsNames.themes || themeOptionsNames.theme)}`,
663
+ "export const shiki = getHighlighterCore({",
664
+ ` themes: [${themesInit.join(",")}],`,
665
+ ` langs: [${langsInit.join(",")}],`,
666
+ ` loadWasm: import('${await resolveImportUrl("shiki/wasm")}'),`,
667
+ "})"
668
+ );
669
+ return lines.join("\n");
670
+ }
671
+ };
672
+
673
+ // node/virtual/slides.ts
674
+ var VIRTUAL_SLIDE_PREFIX = "/@slidev/slides/";
675
+ var templateSlides = {
676
+ id: "/@slidev/slides",
677
+ async getContent({ data }, { getLayouts }) {
678
+ const layouts = await getLayouts();
679
+ const imports = [
680
+ `import { shallowRef } from 'vue'`,
681
+ `import * as __layout__error from '${layouts.error}'`
682
+ ];
683
+ const slides = data.slides.map((_, idx) => {
684
+ const no = idx + 1;
685
+ imports.push(`import { meta as f${no} } from '${VIRTUAL_SLIDE_PREFIX}${no}.frontmatter'`);
686
+ return `{
687
+ no: ${no},
688
+ meta: f${no},
689
+ component: async () => {
690
+ try {
691
+ return await import('${VIRTUAL_SLIDE_PREFIX}${no}.md')
692
+ }
693
+ catch {
694
+ return __layout__error
695
+ }
696
+ },
697
+ }`;
698
+ });
699
+ return [
700
+ ...imports,
701
+ `const data = [
702
+ ${slides.join(",\n")}
703
+ ]`,
704
+ `if (import.meta.hot) {`,
705
+ ` import.meta.hot.data.slides ??= shallowRef()`,
706
+ ` import.meta.hot.data.slides.value = data`,
707
+ ` import.meta.hot.accept()`,
708
+ `}`,
709
+ `export const slides = import.meta.hot ? import.meta.hot.data.slides : shallowRef(data)`
710
+ ].join("\n");
711
+ }
712
+ };
713
+
714
+ // node/virtual/styles.ts
715
+ import { join as join7 } from "node:path";
716
+ import { existsSync as existsSync4 } from "node:fs";
717
+ var templateStyle = {
718
+ id: "/@slidev/styles",
719
+ getContent: async ({ data, clientRoot, roots }) => {
720
+ function resolveUrlOfClient(name) {
721
+ return toAtFS(join7(clientRoot, name));
722
+ }
723
+ const imports = [
724
+ `import "${resolveUrlOfClient("styles/vars.css")}"`,
725
+ `import "${resolveUrlOfClient("styles/index.css")}"`,
726
+ `import "${resolveUrlOfClient("styles/code.css")}"`,
727
+ `import "${resolveUrlOfClient("styles/katex.css")}"`,
728
+ `import "${resolveUrlOfClient("styles/transitions.css")}"`
729
+ ];
730
+ for (const root of roots) {
731
+ const styles = [
732
+ join7(root, "styles", "index.ts"),
733
+ join7(root, "styles", "index.js"),
734
+ join7(root, "styles", "index.css"),
735
+ join7(root, "styles.css"),
736
+ join7(root, "style.css")
737
+ ];
738
+ for (const style of styles) {
739
+ if (existsSync4(style)) {
740
+ imports.push(`import "${toAtFS(style)}"`);
741
+ continue;
742
+ }
743
+ }
744
+ }
745
+ if (data.features.katex)
746
+ imports.push(`import "${await resolveImportUrl("katex/dist/katex.min.css")}"`);
747
+ if (data.config.highlighter === "shiki") {
748
+ imports.push(
749
+ `import "${await resolveImportUrl("@shikijs/vitepress-twoslash/style.css")}"`,
750
+ `import "${resolveUrlOfClient("styles/shiki-twoslash.css")}"`
751
+ );
752
+ }
753
+ if (data.config.css === "unocss") {
754
+ imports.unshift(
755
+ `import "${await resolveImportUrl("@unocss/reset/tailwind.css")}"`,
756
+ 'import "uno:preflights.css"',
757
+ 'import "uno:typography.css"',
758
+ 'import "uno:shortcuts.css"'
759
+ );
760
+ imports.push('import "uno.css"');
761
+ }
762
+ return imports.join("\n");
763
+ }
764
+ };
765
+
766
+ // node/virtual/titles.ts
767
+ var templateTitleRendererMd = {
768
+ id: "/@slidev/title-renderer.md",
769
+ async getContent({ data }) {
770
+ const lines = data.slides.map(({ title }, i) => `<template ${i === 0 ? "v-if" : "v-else-if"}="+no === ${i + 1}">
771
+
772
+ ${title}
773
+
774
+ </template>`);
775
+ lines.push(`<script setup lang="ts">defineProps<{ no: number | string }>()</script>`);
776
+ return lines.join("\n");
777
+ }
778
+ };
779
+ var templateTitleRenderer = {
780
+ id: "/@slidev/title-renderer",
781
+ async getContent() {
782
+ return 'export { default } from "/@slidev/title-renderer.md"';
783
+ }
784
+ };
785
+
786
+ // node/virtual/index.ts
787
+ var templates = [
788
+ templateShiki,
789
+ templateMonacoTypes,
790
+ templateConfigs,
791
+ templateStyle,
792
+ templateGlobalBottom,
793
+ templateGlobalTop,
794
+ templateNavControls,
795
+ templateSlides,
796
+ templateLayouts,
797
+ templateTitleRenderer,
798
+ templateTitleRendererMd,
799
+ ...templateSetups,
800
+ // Deprecated
801
+ templateLegacyRoutes,
802
+ templateLegacyTitles
803
+ ];
804
+
805
+ // node/vite/loaders.ts
806
+ var regexId = /^\/\@slidev\/slide\/(\d+)\.(md|json)(?:\?import)?$/;
807
+ var regexIdQuery = /(\d+?)\.(md|json|frontmatter)$/;
808
+ var templateInjectionMarker = "/* @slidev-injection */";
809
+ var templateImportContextUtils = `import {
810
+ useSlideContext,
811
+ provideFrontmatter as _provideFrontmatter,
812
+ frontmatterToProps as _frontmatterToProps,
813
+ } from "@slidev/client/context.ts"`.replace(/\n\s*/g, " ");
814
+ var templateInitContext = `const { $slidev, $nav, $clicksContext, $clicks, $page, $renderContext, $frontmatter } = useSlideContext()`;
815
+ function getBodyJson(req) {
816
+ return new Promise((resolve4, reject) => {
817
+ let body = "";
818
+ req.on("data", (chunk) => body += chunk);
819
+ req.on("error", reject);
820
+ req.on("end", () => {
821
+ try {
822
+ resolve4(JSON.parse(body) || {});
823
+ } catch (e) {
824
+ reject(e);
825
+ }
826
+ });
827
+ });
828
+ }
829
+ var md = Markdown({ html: true });
830
+ md.use(mila, {
831
+ attrs: {
832
+ target: "_blank",
833
+ rel: "noopener"
834
+ }
835
+ });
836
+ function renderNote(text = "") {
837
+ let clickCount = 0;
838
+ const html = md.render(
839
+ text.replace(/\[click(?::(\d+))?\]/gi, (_, count = 1) => {
840
+ clickCount += Number(count);
841
+ return `<span class="slidev-note-click-mark" data-clicks="${clickCount}"></span>`;
842
+ })
843
+ );
844
+ return html;
845
+ }
846
+ function withRenderedNote(data) {
847
+ return {
848
+ ...data,
849
+ noteHTML: renderNote(data?.note)
850
+ };
851
+ }
852
+ function createSlidesLoader(options, pluginOptions, serverOptions) {
853
+ const hmrPages = /* @__PURE__ */ new Set();
854
+ let server;
855
+ let _layouts_cache_time = 0;
856
+ let _layouts_cache = {};
857
+ const { data, clientRoot, roots, mode } = options;
858
+ const templateCtx = {
859
+ md,
860
+ async getLayouts() {
861
+ const now = Date.now();
862
+ if (now - _layouts_cache_time < 2e3)
863
+ return _layouts_cache;
864
+ const layouts = {};
865
+ for (const root of [...roots, clientRoot]) {
866
+ const layoutPaths = await fg3("layouts/**/*.{vue,ts}", {
867
+ cwd: root,
868
+ absolute: true,
869
+ suppressErrors: true
870
+ });
871
+ for (const layoutPath of layoutPaths) {
872
+ const layout = basename2(layoutPath).replace(/\.\w+$/, "");
873
+ if (layouts[layout])
874
+ continue;
875
+ layouts[layout] = layoutPath;
876
+ }
877
+ }
878
+ _layouts_cache_time = now;
879
+ _layouts_cache = layouts;
880
+ return layouts;
881
+ }
882
+ };
883
+ return [
884
+ {
885
+ name: "slidev:loader",
886
+ configureServer(_server) {
887
+ server = _server;
888
+ updateServerWatcher();
889
+ server.middlewares.use(async (req, res, next) => {
890
+ const match = req.url?.match(regexId);
891
+ if (!match)
892
+ return next();
893
+ const [, no, type] = match;
894
+ const idx = Number.parseInt(no) - 1;
895
+ if (type === "json" && req.method === "GET") {
896
+ res.write(JSON.stringify(withRenderedNote(data.slides[idx])));
897
+ return res.end();
898
+ }
899
+ if (type === "json" && req.method === "POST") {
900
+ const body = await getBodyJson(req);
901
+ const slide = data.slides[idx];
902
+ if (body.content && body.content !== slide.source.content)
903
+ hmrPages.add(idx);
904
+ Object.assign(slide.source, body);
905
+ parser.prettifySlide(slide.source);
906
+ await parser.save(data.markdownFiles[slide.source.filepath]);
907
+ res.statusCode = 200;
908
+ res.write(JSON.stringify(withRenderedNote(slide)));
909
+ return res.end();
910
+ }
911
+ next();
912
+ });
913
+ },
914
+ async handleHotUpdate(ctx) {
915
+ if (!data.watchFiles.includes(ctx.file))
916
+ return;
917
+ await ctx.read();
918
+ const newData = await serverOptions.loadData?.();
919
+ if (!newData)
920
+ return [];
921
+ const moduleIds = /* @__PURE__ */ new Set();
922
+ if (data.slides.length !== newData.slides.length) {
923
+ moduleIds.add(templateSlides.id);
924
+ range(newData.slides.length).map((i) => hmrPages.add(i));
925
+ }
926
+ if (!equal(data.headmatter.defaults, newData.headmatter.defaults)) {
927
+ moduleIds.add(templateSlides.id);
928
+ range(data.slides.length).map((i) => hmrPages.add(i));
929
+ }
930
+ if (!equal(data.config, newData.config))
931
+ moduleIds.add(templateConfigs.id);
932
+ if (!equal(data.features, newData.features)) {
933
+ setTimeout(() => {
934
+ ctx.server.hot.send({ type: "full-reload" });
935
+ }, 1);
936
+ }
937
+ const length = Math.min(data.slides.length, newData.slides.length);
938
+ for (let i = 0; i < length; i++) {
939
+ const a = data.slides[i];
940
+ const b = newData.slides[i];
941
+ if (!hmrPages.has(i) && a.content.trim() === b.content.trim() && a.title?.trim() === b.title?.trim() && equal(a.frontmatter, b.frontmatter) && Object.entries(a.snippetsUsed ?? {}).every(([file, oldContent]) => {
942
+ try {
943
+ const newContent = fs4.readFileSync(file, "utf-8");
944
+ return oldContent === newContent;
945
+ } catch {
946
+ return false;
947
+ }
948
+ })) {
949
+ if (a.note !== b.note) {
950
+ ctx.server.hot.send(
951
+ "slidev:update-note",
952
+ {
953
+ no: i + 1,
954
+ note: b.note || "",
955
+ noteHTML: renderNote(b.note || "")
956
+ }
957
+ );
958
+ }
959
+ continue;
960
+ }
961
+ ctx.server.hot.send(
962
+ "slidev:update-slide",
963
+ {
964
+ no: i + 1,
965
+ data: withRenderedNote(newData.slides[i])
966
+ }
967
+ );
968
+ hmrPages.add(i);
969
+ }
970
+ Object.assign(data, newData);
971
+ if (hmrPages.size > 0)
972
+ moduleIds.add(templateTitleRendererMd.id);
973
+ const vueModules = Array.from(hmrPages).flatMap((i) => [
974
+ ctx.server.moduleGraph.getModuleById(`${VIRTUAL_SLIDE_PREFIX}${i + 1}.frontmatter`),
975
+ ctx.server.moduleGraph.getModuleById(`${VIRTUAL_SLIDE_PREFIX}${i + 1}.md`)
976
+ ]);
977
+ hmrPages.clear();
978
+ const moduleEntries = [
979
+ ...vueModules,
980
+ ...Array.from(moduleIds).map((id) => ctx.server.moduleGraph.getModuleById(id))
981
+ ].filter(notNullish).filter((i) => !i.id?.startsWith("/@id/@vite-icons"));
982
+ updateServerWatcher();
983
+ return moduleEntries;
984
+ },
985
+ resolveId(id) {
986
+ if (id.startsWith(VIRTUAL_SLIDE_PREFIX) || id.startsWith("/@slidev/"))
987
+ return id;
988
+ return null;
989
+ },
990
+ async load(id) {
991
+ const template = templates.find((i) => i.id === id);
992
+ if (template) {
993
+ return {
994
+ code: await template.getContent(options, templateCtx),
995
+ map: { mappings: "" }
996
+ };
997
+ }
998
+ if (id.startsWith(VIRTUAL_SLIDE_PREFIX)) {
999
+ const remaning = id.slice(VIRTUAL_SLIDE_PREFIX.length);
1000
+ const match = remaning.match(regexIdQuery);
1001
+ if (match) {
1002
+ const [, no, type] = match;
1003
+ const pageNo = Number.parseInt(no) - 1;
1004
+ const slide = data.slides[pageNo];
1005
+ if (!slide)
1006
+ return;
1007
+ if (type === "md") {
1008
+ return {
1009
+ code: slide?.content,
1010
+ map: { mappings: "" }
1011
+ };
1012
+ } else if (type === "frontmatter") {
1013
+ const slideBase = {
1014
+ ...withRenderedNote(slide),
1015
+ frontmatter: void 0,
1016
+ source: void 0,
1017
+ // remove raw content in build, optimize the bundle size
1018
+ ...mode === "build" ? { raw: "", content: "", note: "" } : {}
1019
+ };
1020
+ const fontmatter = getFrontmatter(pageNo);
1021
+ return {
1022
+ code: [
1023
+ "// @unocss-include",
1024
+ 'import { reactive, computed } from "vue"',
1025
+ `export const frontmatter = reactive(${JSON.stringify(fontmatter)})`,
1026
+ `export const meta = reactive({
1027
+ layout: computed(() => frontmatter.layout),
1028
+ transition: computed(() => frontmatter.transition),
1029
+ class: computed(() => frontmatter.class),
1030
+ clicks: computed(() => frontmatter.clicks),
1031
+ name: computed(() => frontmatter.name),
1032
+ preload: computed(() => frontmatter.preload),
1033
+ slide: {
1034
+ ...(${JSON.stringify(slideBase)}),
1035
+ frontmatter,
1036
+ filepath: ${JSON.stringify(slide.source.filepath)},
1037
+ start: ${JSON.stringify(slide.source.start)},
1038
+ id: ${pageNo},
1039
+ no: ${no},
1040
+ },
1041
+ __clicksContext: null,
1042
+ __preloaded: false,
1043
+ })`,
1044
+ "export default frontmatter",
1045
+ // handle HMR, update frontmatter with update
1046
+ "if (import.meta.hot) {",
1047
+ " import.meta.hot.accept(({ frontmatter: update }) => {",
1048
+ " if(!update) return",
1049
+ " Object.keys(frontmatter).forEach(key => {",
1050
+ " if (!(key in update)) delete frontmatter[key]",
1051
+ " })",
1052
+ " Object.assign(frontmatter, update)",
1053
+ " })",
1054
+ "}"
1055
+ ].join("\n"),
1056
+ map: { mappings: "" }
1057
+ };
1058
+ }
1059
+ }
1060
+ return {
1061
+ code: "",
1062
+ map: { mappings: "" }
1063
+ };
1064
+ }
1065
+ }
1066
+ },
1067
+ {
1068
+ name: "slidev:layout-transform:pre",
1069
+ enforce: "pre",
1070
+ async transform(code, id) {
1071
+ if (!id.startsWith(VIRTUAL_SLIDE_PREFIX))
1072
+ return;
1073
+ const remaning = id.slice(VIRTUAL_SLIDE_PREFIX.length);
1074
+ const match = remaning.match(regexIdQuery);
1075
+ if (!match)
1076
+ return;
1077
+ const [, no, type] = match;
1078
+ if (type !== "md")
1079
+ return;
1080
+ const pageNo = Number.parseInt(no) - 1;
1081
+ return transformMarkdown(code, pageNo);
1082
+ }
1083
+ },
1084
+ {
1085
+ name: "slidev:context-transform:pre",
1086
+ enforce: "pre",
1087
+ async transform(code, id) {
1088
+ if (!id.endsWith(".vue") || id.includes("/@slidev/client/") || id.includes("/packages/client/"))
1089
+ return;
1090
+ return transformVue(code);
1091
+ }
1092
+ },
1093
+ {
1094
+ name: "slidev:slide-transform:post",
1095
+ enforce: "post",
1096
+ transform(code, id) {
1097
+ if (!id.match(/\/@slidev\/slides\/\d+\.md($|\?)/))
1098
+ return;
1099
+ const replaced = code.replace("if (_rerender_only)", "if (false)");
1100
+ if (replaced !== code)
1101
+ return replaced;
1102
+ }
1103
+ },
1104
+ {
1105
+ name: "slidev:index-html-transform",
1106
+ transformIndexHtml() {
1107
+ const { info, author, keywords } = data.headmatter;
1108
+ return [
1109
+ {
1110
+ tag: "title",
1111
+ children: getTitle()
1112
+ },
1113
+ info && {
1114
+ tag: "meta",
1115
+ attrs: {
1116
+ name: "description",
1117
+ content: info
1118
+ }
1119
+ },
1120
+ author && {
1121
+ tag: "meta",
1122
+ attrs: {
1123
+ name: "author",
1124
+ content: author
1125
+ }
1126
+ },
1127
+ keywords && {
1128
+ tag: "meta",
1129
+ attrs: {
1130
+ name: "keywords",
1131
+ content: Array.isArray(keywords) ? keywords.join(", ") : keywords
1132
+ }
1133
+ }
1134
+ ].filter(isTruthy2);
1135
+ }
1136
+ }
1137
+ ];
1138
+ function updateServerWatcher() {
1139
+ if (!server)
1140
+ return;
1141
+ server.watcher.add(data.watchFiles);
1142
+ }
1143
+ function getFrontmatter(pageNo) {
1144
+ return {
1145
+ ...data.headmatter?.defaults || {},
1146
+ ...data.slides[pageNo]?.frontmatter || {}
1147
+ };
1148
+ }
1149
+ async function transformMarkdown(code, pageNo) {
1150
+ const layouts = await templateCtx.getLayouts();
1151
+ const frontmatter = getFrontmatter(pageNo);
1152
+ let layoutName = frontmatter?.layout || (pageNo === 0 ? "cover" : "default");
1153
+ if (!layouts[layoutName]) {
1154
+ console.error(red(`
1155
+ Unknown layout "${bold(layoutName)}".${yellow(" Available layouts are:")}`) + Object.keys(layouts).map((i, idx) => (idx % 3 === 0 ? "\n " : "") + gray(i.padEnd(15, " "))).join(" "));
1156
+ console.error();
1157
+ layoutName = "default";
1158
+ }
1159
+ delete frontmatter.title;
1160
+ const imports = [
1161
+ `import InjectedLayout from "${toAtFS(layouts[layoutName])}"`,
1162
+ `import frontmatter from "${toAtFS(`${VIRTUAL_SLIDE_PREFIX + (pageNo + 1)}.frontmatter`)}"`,
1163
+ templateImportContextUtils,
1164
+ "_provideFrontmatter(frontmatter)",
1165
+ templateInitContext,
1166
+ templateInjectionMarker
1167
+ ];
1168
+ code = code.replace(/(<script setup.*>)/g, `$1
1169
+ ${imports.join("\n")}
1170
+ `);
1171
+ const injectA = code.indexOf("<template>") + "<template>".length;
1172
+ const injectB = code.lastIndexOf("</template>");
1173
+ let body = code.slice(injectA, injectB).trim();
1174
+ if (body.startsWith("<div>") && body.endsWith("</div>"))
1175
+ body = body.slice(5, -6);
1176
+ code = `${code.slice(0, injectA)}
1177
+ <InjectedLayout v-bind="_frontmatterToProps(frontmatter,${pageNo})">
1178
+ ${body}
1179
+ </InjectedLayout>
1180
+ ${code.slice(injectB)}`;
1181
+ return code;
1182
+ }
1183
+ function transformVue(code) {
1184
+ if (code.includes(templateInjectionMarker) || code.includes("useSlideContext()"))
1185
+ return code;
1186
+ const imports = [
1187
+ templateImportContextUtils,
1188
+ templateInitContext,
1189
+ templateInjectionMarker
1190
+ ];
1191
+ const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/);
1192
+ if (matchScript && matchScript[2]) {
1193
+ return code.replace(/(<script.*>)/g, `$1
1194
+ ${imports.join("\n")}
1195
+ `);
1196
+ } else if (matchScript && !matchScript[2]) {
1197
+ const matchExport = code.match(/export\s+default\s+{/);
1198
+ if (matchExport) {
1199
+ const exportIndex = (matchExport.index || 0) + matchExport[0].length;
1200
+ let component = code.slice(exportIndex);
1201
+ component = component.slice(0, component.indexOf("</script>"));
1202
+ const scriptIndex = (matchScript.index || 0) + matchScript[0].length;
1203
+ const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants.ts"\n';
1204
+ code = `${code.slice(0, scriptIndex)}${provideImport}${code.slice(scriptIndex)}`;
1205
+ let injectIndex = exportIndex + provideImport.length;
1206
+ let injectObject = "$slidev: { from: injectionSlidevContext },";
1207
+ const matchInject = component.match(/.*inject\s*:\s*([\[{])/);
1208
+ if (matchInject) {
1209
+ injectIndex += (matchInject.index || 0) + matchInject[0].length;
1210
+ if (matchInject[1] === "[") {
1211
+ let injects = component.slice((matchInject.index || 0) + matchInject[0].length);
1212
+ const injectEndIndex = injects.indexOf("]");
1213
+ injects = injects.slice(0, injectEndIndex);
1214
+ injectObject += injects.split(",").map((inject) => `${inject}: {from: ${inject}}`).join(",");
1215
+ return `${code.slice(0, injectIndex - 1)}{
1216
+ ${injectObject}
1217
+ }${code.slice(injectIndex + injectEndIndex + 1)}`;
1218
+ } else {
1219
+ return `${code.slice(0, injectIndex)}
1220
+ ${injectObject}
1221
+ ${code.slice(injectIndex)}`;
1222
+ }
1223
+ }
1224
+ return `${code.slice(0, injectIndex)}
1225
+ inject: { ${injectObject} },
1226
+ ${code.slice(injectIndex)}`;
1227
+ }
1228
+ }
1229
+ return `<script setup>
1230
+ ${imports.join("\n")}
1231
+ </script>
1232
+ ${code}`;
1233
+ }
1234
+ function getTitle() {
1235
+ if (isString2(data.config.title)) {
1236
+ const tokens = md.parseInline(data.config.title, {});
1237
+ return stringifyMarkdownTokens(tokens);
1238
+ }
1239
+ return data.config.title;
1240
+ }
1241
+ }
1242
+
1243
+ // node/vite/markdown.ts
1244
+ import Markdown2 from "unplugin-vue-markdown/vite";
1245
+ import { slash } from "@antfu/utils";
1246
+
1247
+ // ../../node_modules/.pnpm/@hedgedoc+markdown-it-plugins@2.1.4_patch_hash=tuyuxytl56b2vxulpkzt2wf4o4_markdown-it@14.0.0/node_modules/@hedgedoc/markdown-it-plugins/dist/esm/image-size/specialCharacters.js
1248
+ var SpecialCharacters;
1249
+ (function(SpecialCharacters2) {
1250
+ SpecialCharacters2[SpecialCharacters2["EXCLAMATION_MARK"] = 33] = "EXCLAMATION_MARK";
1251
+ SpecialCharacters2[SpecialCharacters2["OPENING_BRACKET"] = 91] = "OPENING_BRACKET";
1252
+ SpecialCharacters2[SpecialCharacters2["OPENING_PARENTHESIS"] = 40] = "OPENING_PARENTHESIS";
1253
+ SpecialCharacters2[SpecialCharacters2["WHITESPACE"] = 32] = "WHITESPACE";
1254
+ SpecialCharacters2[SpecialCharacters2["NEW_LINE"] = 10] = "NEW_LINE";
1255
+ SpecialCharacters2[SpecialCharacters2["EQUALS"] = 61] = "EQUALS";
1256
+ SpecialCharacters2[SpecialCharacters2["LOWER_CASE_X"] = 120] = "LOWER_CASE_X";
1257
+ SpecialCharacters2[SpecialCharacters2["NUMBER_ZERO"] = 48] = "NUMBER_ZERO";
1258
+ SpecialCharacters2[SpecialCharacters2["NUMBER_NINE"] = 57] = "NUMBER_NINE";
1259
+ SpecialCharacters2[SpecialCharacters2["PERCENTAGE"] = 37] = "PERCENTAGE";
1260
+ SpecialCharacters2[SpecialCharacters2["CLOSING_PARENTHESIS"] = 41] = "CLOSING_PARENTHESIS";
1261
+ })(SpecialCharacters || (SpecialCharacters = {}));
1262
+
1263
+ // ../../node_modules/.pnpm/@hedgedoc+markdown-it-plugins@2.1.4_patch_hash=tuyuxytl56b2vxulpkzt2wf4o4_markdown-it@14.0.0/node_modules/@hedgedoc/markdown-it-plugins/dist/esm/task-lists/index.js
1264
+ import Token from "markdown-it/lib/token.mjs";
1265
+ var checkboxRegex = /^ *\[([\sx])] /i;
1266
+ function taskLists(md2, options = { enabled: false, label: false, lineNumber: false }) {
1267
+ md2.core.ruler.after("inline", "task-lists", (state) => processToken(state, options));
1268
+ md2.renderer.rules.taskListItemCheckbox = (tokens) => {
1269
+ const token = tokens[0];
1270
+ const checkedAttribute = token.attrGet("checked") ? 'checked="" ' : "";
1271
+ const disabledAttribute = token.attrGet("disabled") ? 'disabled="" ' : "";
1272
+ const line = token.attrGet("line");
1273
+ const idAttribute = `id="${token.attrGet("id")}" `;
1274
+ const dataLineAttribute = line && options.lineNumber ? `data-line="${line}" ` : "";
1275
+ return `<input class="task-list-item-checkbox" type="checkbox" ${checkedAttribute}${disabledAttribute}${dataLineAttribute}${idAttribute}/>`;
1276
+ };
1277
+ md2.renderer.rules.taskListItemLabel_close = () => {
1278
+ return "</label>";
1279
+ };
1280
+ md2.renderer.rules.taskListItemLabel_open = (tokens) => {
1281
+ const token = tokens[0];
1282
+ const id = token.attrGet("id");
1283
+ return `<label for="${id}">`;
1284
+ };
1285
+ }
1286
+ function processToken(state, options) {
1287
+ const allTokens = state.tokens;
1288
+ for (let i = 2; i < allTokens.length; i++) {
1289
+ if (!isTodoItem(allTokens, i)) {
1290
+ continue;
1291
+ }
1292
+ todoify(allTokens[i], options);
1293
+ allTokens[i - 2].attrJoin("class", `task-list-item ${options.enabled ? " enabled" : ""}`);
1294
+ const parentToken = findParentToken(allTokens, i - 2);
1295
+ if (parentToken) {
1296
+ const classes = parentToken.attrGet("class") ?? "";
1297
+ if (!classes.match(/(^| )contains-task-list/)) {
1298
+ parentToken.attrJoin("class", "contains-task-list");
1299
+ }
1300
+ }
1301
+ }
1302
+ return false;
1303
+ }
1304
+ function findParentToken(tokens, index) {
1305
+ const targetLevel = tokens[index].level - 1;
1306
+ for (let currentTokenIndex = index - 1; currentTokenIndex >= 0; currentTokenIndex--) {
1307
+ if (tokens[currentTokenIndex].level === targetLevel) {
1308
+ return tokens[currentTokenIndex];
1309
+ }
1310
+ }
1311
+ return void 0;
1312
+ }
1313
+ function isTodoItem(tokens, index) {
1314
+ return isInline(tokens[index]) && isParagraph(tokens[index - 1]) && isListItem(tokens[index - 2]) && startsWithTodoMarkdown(tokens[index]);
1315
+ }
1316
+ function todoify(token, options) {
1317
+ if (token.children == null) {
1318
+ return;
1319
+ }
1320
+ const id = generateIdForToken(token);
1321
+ token.children.splice(0, 0, createCheckboxToken(token, options.enabled, id));
1322
+ token.children[1].content = token.children[1].content.replace(checkboxRegex, "");
1323
+ if (options.label) {
1324
+ token.children.splice(1, 0, createLabelBeginToken(id));
1325
+ token.children.push(createLabelEndToken());
1326
+ }
1327
+ }
1328
+ function generateIdForToken(token) {
1329
+ if (token.map) {
1330
+ return `task-item-${token.map[0]}`;
1331
+ } else {
1332
+ return `task-item-${Math.ceil(Math.random() * (1e4 * 1e3) - 1e3)}`;
1333
+ }
1334
+ }
1335
+ function createCheckboxToken(token, enabled, id) {
1336
+ const checkbox = new Token("taskListItemCheckbox", "", 0);
1337
+ if (!enabled) {
1338
+ checkbox.attrSet("disabled", "true");
1339
+ }
1340
+ if (token.map) {
1341
+ checkbox.attrSet("line", token.map[0].toString());
1342
+ }
1343
+ checkbox.attrSet("id", id);
1344
+ const checkboxRegexResult = checkboxRegex.exec(token.content);
1345
+ const isChecked = checkboxRegexResult?.[1].toLowerCase() === "x";
1346
+ if (isChecked) {
1347
+ checkbox.attrSet("checked", "true");
1348
+ }
1349
+ return checkbox;
1350
+ }
1351
+ function createLabelBeginToken(id) {
1352
+ const labelBeginToken = new Token("taskListItemLabel_open", "", 1);
1353
+ labelBeginToken.attrSet("id", id);
1354
+ return labelBeginToken;
1355
+ }
1356
+ function createLabelEndToken() {
1357
+ return new Token("taskListItemLabel_close", "", -1);
1358
+ }
1359
+ function isInline(token) {
1360
+ return token.type === "inline";
1361
+ }
1362
+ function isParagraph(token) {
1363
+ return token.type === "paragraph_open";
1364
+ }
1365
+ function isListItem(token) {
1366
+ return token.type === "list_item_open";
1367
+ }
1368
+ function startsWithTodoMarkdown(token) {
1369
+ return checkboxRegex.test(token.content);
1370
+ }
1371
+
1372
+ // node/vite/markdown.ts
1373
+ import MarkdownItMdc from "markdown-it-mdc";
1374
+ import MarkdownItAttrs from "markdown-it-link-attributes";
1375
+ import MarkdownItFootnote from "markdown-it-footnote";
1376
+
1377
+ // node/syntax/markdown-it/markdown-it-katex.ts
1378
+ import katex from "katex";
1379
+ function isValidDelim(state, pos) {
1380
+ const max = state.posMax;
1381
+ let can_open = true;
1382
+ let can_close = true;
1383
+ const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
1384
+ const nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1;
1385
+ if (prevChar === 32 || prevChar === 9 || /* \t */
1386
+ nextChar >= 48 && nextChar <= 57)
1387
+ can_close = false;
1388
+ if (nextChar === 32 || nextChar === 9)
1389
+ can_open = false;
1390
+ return {
1391
+ can_open,
1392
+ can_close
1393
+ };
1394
+ }
1395
+ function math_inline(state, silent) {
1396
+ let match, token, res, pos;
1397
+ if (state.src[state.pos] !== "$")
1398
+ return false;
1399
+ res = isValidDelim(state, state.pos);
1400
+ if (!res.can_open) {
1401
+ if (!silent)
1402
+ state.pending += "$";
1403
+ state.pos += 1;
1404
+ return true;
1405
+ }
1406
+ const start = state.pos + 1;
1407
+ match = start;
1408
+ while ((match = state.src.indexOf("$", match)) !== -1) {
1409
+ pos = match - 1;
1410
+ while (state.src[pos] === "\\")
1411
+ pos -= 1;
1412
+ if ((match - pos) % 2 === 1)
1413
+ break;
1414
+ match += 1;
1415
+ }
1416
+ if (match === -1) {
1417
+ if (!silent)
1418
+ state.pending += "$";
1419
+ state.pos = start;
1420
+ return true;
1421
+ }
1422
+ if (match - start === 0) {
1423
+ if (!silent)
1424
+ state.pending += "$$";
1425
+ state.pos = start + 1;
1426
+ return true;
1427
+ }
1428
+ res = isValidDelim(state, match);
1429
+ if (!res.can_close) {
1430
+ if (!silent)
1431
+ state.pending += "$";
1432
+ state.pos = start;
1433
+ return true;
1434
+ }
1435
+ if (!silent) {
1436
+ token = state.push("math_inline", "math", 0);
1437
+ token.markup = "$";
1438
+ token.content = state.src.slice(start, match);
1439
+ }
1440
+ state.pos = match + 1;
1441
+ return true;
1442
+ }
1443
+ function math_block(state, start, end, silent) {
1444
+ let firstLine;
1445
+ let lastLine;
1446
+ let next;
1447
+ let lastPos;
1448
+ let found = false;
1449
+ let pos = state.bMarks[start] + state.tShift[start];
1450
+ let max = state.eMarks[start];
1451
+ if (pos + 2 > max)
1452
+ return false;
1453
+ if (state.src.slice(pos, pos + 2) !== "$$")
1454
+ return false;
1455
+ pos += 2;
1456
+ firstLine = state.src.slice(pos, max);
1457
+ if (silent)
1458
+ return true;
1459
+ if (firstLine.trim().slice(-2) === "$$") {
1460
+ firstLine = firstLine.trim().slice(0, -2);
1461
+ found = true;
1462
+ }
1463
+ for (next = start; !found; ) {
1464
+ next++;
1465
+ if (next >= end)
1466
+ break;
1467
+ pos = state.bMarks[next] + state.tShift[next];
1468
+ max = state.eMarks[next];
1469
+ if (pos < max && state.tShift[next] < state.blkIndent) {
1470
+ break;
1471
+ }
1472
+ if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
1473
+ lastPos = state.src.slice(0, max).lastIndexOf("$$");
1474
+ lastLine = state.src.slice(pos, lastPos);
1475
+ found = true;
1476
+ }
1477
+ }
1478
+ state.line = next + 1;
1479
+ const token = state.push("math_block", "math", 0);
1480
+ token.block = true;
1481
+ token.content = (firstLine && firstLine.trim() ? `${firstLine}
1482
+ ` : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
1483
+ token.map = [start, state.line];
1484
+ token.markup = "$$";
1485
+ return true;
1486
+ }
1487
+ function math_plugin(md2, options) {
1488
+ options = options || {};
1489
+ const katexInline = function(latex) {
1490
+ options.displayMode = false;
1491
+ try {
1492
+ return katex.renderToString(latex, options);
1493
+ } catch (error) {
1494
+ if (options.throwOnError)
1495
+ console.warn(error);
1496
+ return latex;
1497
+ }
1498
+ };
1499
+ const inlineRenderer = function(tokens, idx) {
1500
+ return katexInline(tokens[idx].content);
1501
+ };
1502
+ const katexBlock = function(latex) {
1503
+ options.displayMode = true;
1504
+ try {
1505
+ return `<p>${katex.renderToString(latex, options)}</p>`;
1506
+ } catch (error) {
1507
+ if (options.throwOnError)
1508
+ console.warn(error);
1509
+ return latex;
1510
+ }
1511
+ };
1512
+ const blockRenderer = function(tokens, idx) {
1513
+ return `${katexBlock(tokens[idx].content)}
1514
+ `;
1515
+ };
1516
+ md2.inline.ruler.after("escape", "math_inline", math_inline);
1517
+ md2.block.ruler.after("blockquote", "math_block", math_block, {
1518
+ alt: ["paragraph", "reference", "blockquote", "list"]
1519
+ });
1520
+ md2.renderer.rules.math_inline = inlineRenderer;
1521
+ md2.renderer.rules.math_block = blockRenderer;
1522
+ }
1523
+
1524
+ // node/syntax/markdown-it/markdown-it-prism.ts
1525
+ import { createRequire } from "node:module";
1526
+ import Prism from "prismjs";
1527
+ import loadLanguages from "prismjs/components/index.js";
1528
+ import * as htmlparser2 from "htmlparser2";
1529
+
1530
+ // node/syntax/transform/utils.ts
1531
+ function normalizeRangeStr(rangeStr = "") {
1532
+ return !rangeStr.trim() ? [] : rangeStr.trim().split(/\|/g).map((i) => i.trim());
1533
+ }
1534
+ function getCodeBlocks(md2) {
1535
+ const codeblocks = Array.from(md2.matchAll(/^```[\s\S]*?^```/mg)).map((m) => {
1536
+ const start = m.index;
1537
+ const end = m.index + m[0].length;
1538
+ const startLine = md2.slice(0, start).match(/\n/g)?.length || 0;
1539
+ const endLine = md2.slice(0, end).match(/\n/g)?.length || 0;
1540
+ return [start, end, startLine, endLine];
1541
+ });
1542
+ return {
1543
+ codeblocks,
1544
+ isInsideCodeblocks(idx) {
1545
+ return codeblocks.some(([s, e]) => s <= idx && idx <= e);
1546
+ },
1547
+ isLineInsideCodeblocks(line) {
1548
+ return codeblocks.some(([, , s, e]) => s <= line && line <= e);
1549
+ }
1550
+ };
1551
+ }
1552
+ function escapeVueInCode(md2) {
1553
+ return md2.replace(/{{/g, "&lbrace;&lbrace;");
1554
+ }
1555
+
1556
+ // node/syntax/markdown-it/markdown-it-prism.ts
1557
+ var require2 = createRequire(import.meta.url);
1558
+ var Tag = class {
1559
+ tagname;
1560
+ attributes;
1561
+ constructor(tagname, attributes) {
1562
+ this.tagname = tagname;
1563
+ this.attributes = attributes;
1564
+ }
1565
+ asOpen() {
1566
+ return `<${this.tagname} ${Object.entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(" ")}>`;
1567
+ }
1568
+ asClosed() {
1569
+ return `</${this.tagname}>`;
1570
+ }
1571
+ };
1572
+ var DEFAULTS = {
1573
+ plugins: [],
1574
+ init: () => {
1575
+ },
1576
+ defaultLanguageForUnknown: void 0,
1577
+ defaultLanguageForUnspecified: void 0,
1578
+ defaultLanguage: void 0
1579
+ };
1580
+ function loadPrismLang(lang) {
1581
+ if (!lang)
1582
+ return void 0;
1583
+ let langObject = Prism.languages[lang];
1584
+ if (langObject === void 0) {
1585
+ loadLanguages([lang]);
1586
+ langObject = Prism.languages[lang];
1587
+ }
1588
+ return langObject;
1589
+ }
1590
+ function loadPrismPlugin(name) {
1591
+ try {
1592
+ require2(`prismjs/plugins/${name}/prism-${name}`);
1593
+ } catch (e) {
1594
+ throw new Error(`Cannot load Prism plugin "${name}". Please check the spelling.`);
1595
+ }
1596
+ }
1597
+ function selectLanguage(options, lang) {
1598
+ let langToUse = lang;
1599
+ if (langToUse === "" && options.defaultLanguageForUnspecified !== void 0)
1600
+ langToUse = options.defaultLanguageForUnspecified;
1601
+ let prismLang = loadPrismLang(langToUse);
1602
+ if (prismLang === void 0 && options.defaultLanguageForUnknown !== void 0) {
1603
+ langToUse = options.defaultLanguageForUnknown;
1604
+ prismLang = loadPrismLang(langToUse);
1605
+ }
1606
+ return [langToUse, prismLang];
1607
+ }
1608
+ function highlight(markdownit, options, text, lang) {
1609
+ const [langToUse, prismLang] = selectLanguage(options, lang);
1610
+ let code = text.trimEnd();
1611
+ code = prismLang ? highlightPrism(code, prismLang, langToUse) : markdownit.utils.escapeHtml(code);
1612
+ code = code.split(/\r?\n/g).map((line) => `<span class="line">${line}</span>`).join("\n");
1613
+ const classAttribute = langToUse ? ` class="slidev-code ${markdownit.options.langPrefix}${markdownit.utils.escapeHtml(langToUse)}"` : "";
1614
+ return escapeVueInCode(`<pre${classAttribute}><code>${code}</code></pre>`);
1615
+ }
1616
+ function highlightPrism(code, prismLang, langToUse) {
1617
+ const openTags = [];
1618
+ const parser2 = new htmlparser2.Parser({
1619
+ onopentag(tagname, attributes) {
1620
+ openTags.push(new Tag(tagname, attributes));
1621
+ },
1622
+ onclosetag() {
1623
+ openTags.pop();
1624
+ }
1625
+ });
1626
+ code = Prism.highlight(code, prismLang, langToUse);
1627
+ code = code.split(/\r?\n/g).map((line) => {
1628
+ const prefix = openTags.map((tag) => tag.asOpen()).join("");
1629
+ parser2.write(line);
1630
+ const postfix = openTags.reverse().map((tag) => tag.asClosed()).join("");
1631
+ return prefix + line + postfix;
1632
+ }).join("\n");
1633
+ parser2.end();
1634
+ return code;
1635
+ }
1636
+ function checkLanguageOption(options, optionName) {
1637
+ const language = options[optionName];
1638
+ if (language !== void 0 && loadPrismLang(language) === void 0)
1639
+ throw new Error(`Bad option ${optionName}: There is no Prism language '${language}'.`);
1640
+ }
1641
+ function markdownItPrism(markdownit, useroptions) {
1642
+ const options = Object.assign({}, DEFAULTS, useroptions);
1643
+ checkLanguageOption(options, "defaultLanguage");
1644
+ checkLanguageOption(options, "defaultLanguageForUnknown");
1645
+ checkLanguageOption(options, "defaultLanguageForUnspecified");
1646
+ options.defaultLanguageForUnknown = options.defaultLanguageForUnknown || options.defaultLanguage;
1647
+ options.defaultLanguageForUnspecified = options.defaultLanguageForUnspecified || options.defaultLanguage;
1648
+ options.plugins.forEach(loadPrismPlugin);
1649
+ options.init(Prism);
1650
+ markdownit.options.highlight = (text, lang) => highlight(markdownit, options, text, lang);
1651
+ }
1652
+
1653
+ // node/syntax/transform/code-wrapper.ts
1654
+ var reCodeBlock = /^```([\w'-]+?)(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?(.*?))?\n([\s\S]+?)^```$/mg;
1655
+ function transformCodeWrapper(md2) {
1656
+ return md2.replace(
1657
+ reCodeBlock,
1658
+ (full, lang = "", rangeStr = "", options = "", attrs = "", code) => {
1659
+ const ranges = normalizeRangeStr(rangeStr);
1660
+ code = code.trimEnd();
1661
+ options = options.trim() || "{}";
1662
+ return `
1663
+ <CodeBlockWrapper v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>
1664
+
1665
+ \`\`\`${lang}${attrs}
1666
+ ${code}
1667
+ \`\`\`
1668
+
1669
+ </CodeBlockWrapper>`;
1670
+ }
1671
+ );
1672
+ }
1673
+
1674
+ // node/syntax/transform/magic-move.ts
1675
+ import { codeToKeyedTokens } from "shiki-magic-move/core";
1676
+ import lz2 from "lz-string";
1677
+ var reMagicMoveBlock = /^````(?:md|markdown) magic-move(?:[ ]*(\{.*?\})?([^\n]*?))?\n([\s\S]+?)^````$/mg;
1678
+ function transformMagicMove(md2, shiki2, shikiOptions2) {
1679
+ return md2.replace(
1680
+ reMagicMoveBlock,
1681
+ (full, options = "{}", _attrs = "", body) => {
1682
+ if (!shiki2 || !shikiOptions2)
1683
+ throw new Error("Shiki is required for Magic Move. You may need to set `highlighter: shiki` in your Slidev config.");
1684
+ const matches = Array.from(body.matchAll(reCodeBlock));
1685
+ if (!matches.length)
1686
+ throw new Error("Magic Move block must contain at least one code block");
1687
+ const ranges = matches.map((i) => normalizeRangeStr(i[2]));
1688
+ const steps = matches.map(
1689
+ (i) => codeToKeyedTokens(shiki2, i[5].trimEnd(), {
1690
+ ...shikiOptions2,
1691
+ lang: i[1]
1692
+ })
1693
+ );
1694
+ const compressed = lz2.compressToBase64(JSON.stringify(steps));
1695
+ return `<ShikiMagicMove v-bind="${options}" steps-lz="${compressed}" :step-ranges='${JSON.stringify(ranges)}' />`;
1696
+ }
1697
+ );
1698
+ }
1699
+
1700
+ // node/syntax/transform/mermaid.ts
1701
+ import lz3 from "lz-string";
1702
+ function transformMermaid(md2) {
1703
+ return md2.replace(/^```mermaid\s*?({.*?})?\n([\s\S]+?)\n```/mg, (full, options = "", code = "") => {
1704
+ code = code.trim();
1705
+ options = options.trim() || "{}";
1706
+ const encoded = lz3.compressToBase64(code);
1707
+ return `<Mermaid code-lz="${encoded}" v-bind="${options}" />`;
1708
+ });
1709
+ }
1710
+
1711
+ // node/syntax/transform/plant-uml.ts
1712
+ import { encode as encodePlantUml } from "plantuml-encoder";
1713
+ function transformPlantUml(md2, server) {
1714
+ return md2.replace(/^```plantuml\s*?({.*?})?\n([\s\S]+?)\n```/mg, (full, options = "", content = "") => {
1715
+ const code = encodePlantUml(content.trim());
1716
+ options = options.trim() || "{}";
1717
+ return `<PlantUml :code="'${code}'" :server="'${server}'" v-bind="${options}" />`;
1718
+ });
1719
+ }
1720
+
1721
+ // node/syntax/transform/snippet.ts
1722
+ import path from "node:path";
1723
+ import fs5 from "fs-extra";
1724
+ function dedent(text) {
1725
+ const lines = text.split("\n");
1726
+ const minIndentLength = lines.reduce((acc, line) => {
1727
+ for (let i = 0; i < line.length; i++) {
1728
+ if (line[i] !== " " && line[i] !== " ")
1729
+ return Math.min(i, acc);
1730
+ }
1731
+ return acc;
1732
+ }, Number.POSITIVE_INFINITY);
1733
+ if (minIndentLength < Number.POSITIVE_INFINITY)
1734
+ return lines.map((x) => x.slice(minIndentLength)).join("\n");
1735
+ return text;
1736
+ }
1737
+ function testLine(line, regexp, regionName, end = false) {
1738
+ const [full, tag, name] = regexp.exec(line.trim()) || [];
1739
+ return full && tag && name === regionName && tag.match(end ? /^[Ee]nd ?[rR]egion$/ : /^[rR]egion$/);
1740
+ }
1741
+ function findRegion(lines, regionName) {
1742
+ const regionRegexps = [
1743
+ /^\/\/ ?#?((?:end)?region) ([\w*-]+)$/,
1744
+ // javascript, typescript, java
1745
+ /^\/\* ?#((?:end)?region) ([\w*-]+) ?\*\/$/,
1746
+ // css, less, scss
1747
+ /^#pragma ((?:end)?region) ([\w*-]+)$/,
1748
+ // C, C++
1749
+ /^<!-- #?((?:end)?region) ([\w*-]+) -->$/,
1750
+ // HTML, markdown
1751
+ /^#((?:End )Region) ([\w*-]+)$/,
1752
+ // Visual Basic
1753
+ /^::#((?:end)region) ([\w*-]+)$/,
1754
+ // Bat
1755
+ /^# ?((?:end)?region) ([\w*-]+)$/
1756
+ // C#, PHP, Powershell, Python, perl & misc
1757
+ ];
1758
+ let regexp = null;
1759
+ let start = -1;
1760
+ for (const [lineId, line] of lines.entries()) {
1761
+ if (regexp === null) {
1762
+ for (const reg of regionRegexps) {
1763
+ if (testLine(line, reg, regionName)) {
1764
+ start = lineId + 1;
1765
+ regexp = reg;
1766
+ break;
1767
+ }
1768
+ }
1769
+ } else if (testLine(line, regexp, regionName, true)) {
1770
+ return { start, end: lineId, regexp };
1771
+ }
1772
+ }
1773
+ return null;
1774
+ }
1775
+ function transformSnippet(md2, options, id) {
1776
+ const slideId = id.match(/(\d+)\.md$/)?.[1];
1777
+ if (!slideId)
1778
+ return md2;
1779
+ const data = options.data;
1780
+ const slideInfo = data.slides[+slideId - 1];
1781
+ const dir = path.dirname(slideInfo.source?.filepath ?? options.entry ?? options.userRoot);
1782
+ return md2.replace(
1783
+ /^<<< *(.+?)(#[\w-]+)? *(?: (\S+?))? *(\{.*)?$/mg,
1784
+ (full, filepath = "", regionName = "", lang = "", meta = "") => {
1785
+ const firstLine = `\`\`\`${lang || path.extname(filepath).slice(1)} ${meta}`;
1786
+ const src = /^\@[\/]/.test(filepath) ? path.resolve(options.userRoot, filepath.slice(2)) : path.resolve(dir, filepath);
1787
+ data.watchFiles.push(src);
1788
+ const isAFile = fs5.statSync(src).isFile();
1789
+ if (!fs5.existsSync(src) || !isAFile) {
1790
+ throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
1791
+ }
1792
+ let content = fs5.readFileSync(src, "utf8");
1793
+ slideInfo.snippetsUsed ??= {};
1794
+ slideInfo.snippetsUsed[src] = content;
1795
+ if (regionName) {
1796
+ const lines = content.split(/\r?\n/);
1797
+ const region = findRegion(lines, regionName.slice(1));
1798
+ if (region) {
1799
+ content = dedent(
1800
+ lines.slice(region.start, region.end).filter((line) => !region.regexp.test(line.trim())).join("\n")
1801
+ );
1802
+ }
1803
+ }
1804
+ return `${firstLine}
1805
+ ${content}
1806
+ \`\`\``;
1807
+ }
1808
+ );
1809
+ }
1810
+
1811
+ // node/syntax/transform/slot-sugar.ts
1812
+ function transformSlotSugar(md2) {
1813
+ const lines = md2.split(/\r?\n/g);
1814
+ let prevSlot = false;
1815
+ const { isLineInsideCodeblocks } = getCodeBlocks(md2);
1816
+ lines.forEach((line, idx) => {
1817
+ if (isLineInsideCodeblocks(idx))
1818
+ return;
1819
+ const match = line.trimEnd().match(/^::\s*([\w\.\-\:]+)\s*::$/);
1820
+ if (match) {
1821
+ lines[idx] = `${prevSlot ? "\n\n</template>\n" : "\n"}<template v-slot:${match[1]}="slotProps">
1822
+ `;
1823
+ prevSlot = true;
1824
+ }
1825
+ });
1826
+ if (prevSlot)
1827
+ lines[lines.length - 1] += "\n\n</template>";
1828
+ return lines.join("\n");
1829
+ }
1830
+
1831
+ // node/syntax/transform/in-page-css.ts
1832
+ function transformPageCSS(md2, id) {
1833
+ const page = id.match(/(\d+)\.md$/)?.[1];
1834
+ if (!page)
1835
+ return md2;
1836
+ const { isInsideCodeblocks } = getCodeBlocks(md2);
1837
+ const result = md2.replace(
1838
+ /(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g,
1839
+ (full, start, css, end, index) => {
1840
+ if (index < 0 || isInsideCodeblocks(index))
1841
+ return full;
1842
+ if (!start.includes("scoped"))
1843
+ start = start.replace("<style", "<style scoped");
1844
+ return `${start}
1845
+ ${css}${end}`;
1846
+ }
1847
+ );
1848
+ return result;
1849
+ }
1850
+
1851
+ // node/syntax/transform/katex-wrapper.ts
1852
+ function transformKaTexWrapper(md2) {
1853
+ return md2.replace(
1854
+ /^\$\$(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?\s*?)?\n([\s\S]+?)^\$\$/mg,
1855
+ (full, rangeStr = "", options = "", code) => {
1856
+ const ranges = !rangeStr.trim() ? [] : rangeStr.trim().split(/\|/g).map((i) => i.trim());
1857
+ code = code.trimEnd();
1858
+ options = options.trim() || "{}";
1859
+ return `<KaTexBlockWrapper v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>
1860
+
1861
+ $$
1862
+ ${code}
1863
+ $$
1864
+ </KaTexBlockWrapper>
1865
+ `;
1866
+ }
1867
+ );
1868
+ }
1869
+
1870
+ // node/vite/markdown.ts
1871
+ var shiki;
1872
+ var shikiOptions;
1873
+ async function createMarkdownPlugin(options, { markdown: mdOptions }) {
1874
+ const { data: { config }, roots, mode, entry, clientRoot } = options;
1875
+ const setups = [];
1876
+ const entryPath = slash(entry);
1877
+ if (config.highlighter === "shiki") {
1878
+ const [
1879
+ options2,
1880
+ { getHighlighter, bundledLanguages },
1881
+ markdownItShiki,
1882
+ transformerTwoslash
1883
+ ] = await Promise.all([
1884
+ loadShikiSetups(clientRoot, roots),
1885
+ import("shiki").then(({ getHighlighter: getHighlighter2, bundledLanguages: bundledLanguages2 }) => ({ bundledLanguages: bundledLanguages2, getHighlighter: getHighlighter2 })),
1886
+ import("@shikijs/markdown-it/core").then(({ fromHighlighter }) => fromHighlighter),
1887
+ import("@shikijs/vitepress-twoslash").then(({ transformerTwoslash: transformerTwoslash2 }) => transformerTwoslash2)
1888
+ ]);
1889
+ shikiOptions = options2;
1890
+ shiki = await getHighlighter({
1891
+ ...options2,
1892
+ langs: options2.langs ?? Object.keys(bundledLanguages),
1893
+ themes: "themes" in options2 ? Object.values(options2.themes) : [options2.theme]
1894
+ });
1895
+ const transformers = [
1896
+ ...options2.transformers || [],
1897
+ transformerTwoslash({
1898
+ explicitTrigger: true,
1899
+ twoslashOptions: {
1900
+ handbookOptions: {
1901
+ noErrorValidation: true
1902
+ }
1903
+ }
1904
+ }),
1905
+ {
1906
+ pre(pre) {
1907
+ this.addClassToHast(pre, "slidev-code");
1908
+ delete pre.properties.tabindex;
1909
+ },
1910
+ postprocess(code) {
1911
+ return escapeVueInCode(code);
1912
+ }
1913
+ }
1914
+ ];
1915
+ const plugin = markdownItShiki(shiki, {
1916
+ ...options2,
1917
+ transformers
1918
+ });
1919
+ setups.push((md2) => md2.use(plugin));
1920
+ } else {
1921
+ setups.push((md2) => md2.use(markdownItPrism));
1922
+ }
1923
+ if (config.mdc)
1924
+ setups.push((md2) => md2.use(MarkdownItMdc));
1925
+ const KatexOptions = await loadSetups(options.clientRoot, roots, "katex.ts", {}, { strict: false }, false);
1926
+ return Markdown2({
1927
+ include: [/\.md$/],
1928
+ wrapperClasses: "",
1929
+ headEnabled: false,
1930
+ frontmatter: false,
1931
+ escapeCodeTagInterpolation: false,
1932
+ markdownItOptions: {
1933
+ quotes: `""''`,
1934
+ html: true,
1935
+ xhtmlOut: true,
1936
+ linkify: true,
1937
+ ...mdOptions?.markdownItOptions
1938
+ },
1939
+ ...mdOptions,
1940
+ markdownItSetup(md2) {
1941
+ md2.use(MarkdownItAttrs, {
1942
+ attrs: {
1943
+ target: "_blank",
1944
+ rel: "noopener"
1945
+ }
1946
+ });
1947
+ md2.use(MarkdownItFootnote);
1948
+ md2.use(taskLists, { enabled: true, lineNumber: true, label: true });
1949
+ md2.use(math_plugin, KatexOptions);
1950
+ setups.forEach((i) => i(md2));
1951
+ mdOptions?.markdownItSetup?.(md2);
1952
+ },
1953
+ transforms: {
1954
+ before(code, id) {
1955
+ if (id === entryPath)
1956
+ return "";
1957
+ const monacoEnabled = config.monaco === true || config.monaco === mode;
1958
+ if (config.highlighter === "shiki")
1959
+ code = transformMagicMove(code, shiki, shikiOptions);
1960
+ code = transformSlotSugar(code);
1961
+ code = transformSnippet(code, options, id);
1962
+ code = transformMermaid(code);
1963
+ code = transformPlantUml(code, config.plantUmlServer);
1964
+ code = transformMonaco(code, monacoEnabled);
1965
+ code = transformCodeWrapper(code);
1966
+ code = transformPageCSS(code, id);
1967
+ code = transformKaTexWrapper(code);
1968
+ return code;
1969
+ }
1970
+ }
1971
+ });
1972
+ }
1973
+
1974
+ // node/vite/compilerFlagsVue.ts
1975
+ import { objectEntries } from "@antfu/utils";
1976
+ function createVueCompilerFlagsPlugin(options) {
1977
+ const define = objectEntries(getDefine(options));
1978
+ return [
1979
+ {
1980
+ name: "slidev:flags",
1981
+ enforce: "pre",
1982
+ transform(code, id) {
1983
+ if (id.match(/\.vue($|\?)/)) {
1984
+ const original = code;
1985
+ define.forEach(([from, to]) => {
1986
+ code = code.replace(new RegExp(from, "g"), to);
1987
+ });
1988
+ if (original !== code)
1989
+ return code;
1990
+ }
1991
+ }
1992
+ }
1993
+ ];
1994
+ }
1995
+
1996
+ // node/vite/monacoTypes.ts
1997
+ import fs6 from "node:fs/promises";
1998
+ import { dirname as dirname2, resolve as resolve3 } from "node:path";
1999
+ import { slash as slash2 } from "@antfu/utils";
2000
+ import fg4 from "fast-glob";
2001
+ import { findDepPkgJsonPath } from "vitefu";
2002
+ function createMonacoTypesLoader({ userRoot }) {
2003
+ const resolvedDepsMap = {};
2004
+ return {
2005
+ name: "slidev:monaco-types-loader",
2006
+ resolveId(id) {
2007
+ if (id.startsWith("/@slidev-monaco-types/"))
2008
+ return id;
2009
+ return null;
2010
+ },
2011
+ async load(id) {
2012
+ const matchResolve = id.match(/^\/\@slidev-monaco-types\/resolve\?pkg=(.*?)(?:&importer=(.*))?$/);
2013
+ if (matchResolve) {
2014
+ const [_, pkg, importer = userRoot] = matchResolve;
2015
+ const resolvedDeps = resolvedDepsMap[importer] ??= /* @__PURE__ */ new Set();
2016
+ if (resolvedDeps.has(pkg))
2017
+ return "";
2018
+ resolvedDeps.add(pkg);
2019
+ const pkgJsonPath = await findDepPkgJsonPath(pkg, importer);
2020
+ if (!pkgJsonPath)
2021
+ throw new Error(`Package "${pkg}" not found in "${importer}"`);
2022
+ const root = dirname2(pkgJsonPath);
2023
+ const pkgJson = JSON.parse(await fs6.readFile(pkgJsonPath, "utf-8"));
2024
+ const deps = pkgJson.dependencies ?? {};
2025
+ return [
2026
+ `import "/@slidev-monaco-types/load?root=${slash2(root)}&name=${pkgJson.name}"`,
2027
+ ...Object.keys(deps).map((dep) => `import "/@slidev-monaco-types/resolve?pkg=${dep}&importer=${slash2(root)}"`)
2028
+ ].join("\n");
2029
+ }
2030
+ const matchLoad = id.match(/^\/\@slidev-monaco-types\/load\?root=(.*?)&name=(.*)$/);
2031
+ if (matchLoad) {
2032
+ const [_, root, name] = matchLoad;
2033
+ const files = await fg4(
2034
+ [
2035
+ "**/*.ts",
2036
+ "**/*.mts",
2037
+ "**/*.cts",
2038
+ "package.json"
2039
+ ],
2040
+ {
2041
+ cwd: root,
2042
+ followSymbolicLinks: true,
2043
+ ignore: ["**/node_modules/**"]
2044
+ }
2045
+ );
2046
+ if (!files.length)
2047
+ return "";
2048
+ return [
2049
+ 'import { addFile } from "@slidev/client/setup/monaco.ts"',
2050
+ ...files.map((file) => `addFile(import(${JSON.stringify(`${toAtFS(resolve3(root, file))}?monaco-types&raw`)}), ${JSON.stringify(`node_modules/${name}/${file}`)})`)
2051
+ ].join("\n");
2052
+ }
2053
+ }
2054
+ };
2055
+ }
2056
+
2057
+ // node/vite/vue.ts
2058
+ import Vue from "@vitejs/plugin-vue";
2059
+ import VueJsx from "@vitejs/plugin-vue-jsx";
2060
+ var customElements = /* @__PURE__ */ new Set([
2061
+ // katex
2062
+ "annotation",
2063
+ "math",
2064
+ "menclose",
2065
+ "mfrac",
2066
+ "mglyph",
2067
+ "mi",
2068
+ "mlabeledtr",
2069
+ "mn",
2070
+ "mo",
2071
+ "mover",
2072
+ "mpadded",
2073
+ "mphantom",
2074
+ "mroot",
2075
+ "mrow",
2076
+ "mspace",
2077
+ "msqrt",
2078
+ "mstyle",
2079
+ "msub",
2080
+ "msubsup",
2081
+ "msup",
2082
+ "mtable",
2083
+ "mtd",
2084
+ "mtext",
2085
+ "mtr",
2086
+ "munder",
2087
+ "munderover",
2088
+ "semantics"
2089
+ ]);
2090
+ async function createVuePlugin(options, pluginOptions) {
2091
+ const {
2092
+ vue: vueOptions = {},
2093
+ vuejsx: vuejsxOptions = {}
2094
+ } = pluginOptions;
2095
+ const VuePlugin = Vue({
2096
+ include: [/\.vue$/, /\.md$/],
2097
+ exclude: [],
2098
+ template: {
2099
+ compilerOptions: {
2100
+ isCustomElement(tag) {
2101
+ return customElements.has(tag);
2102
+ }
2103
+ },
2104
+ ...vueOptions?.template
2105
+ },
2106
+ ...vueOptions
2107
+ });
2108
+ const VueJsxPlugin = VueJsx(vuejsxOptions);
2109
+ return [
2110
+ VueJsxPlugin,
2111
+ VuePlugin
2112
+ ];
2113
+ }
2114
+
2115
+ // node/vite/index.ts
2116
+ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
2117
+ const {
2118
+ components: componentsOptions = {},
2119
+ icons: iconsOptions = {},
2120
+ remoteAssets: remoteAssetsOptions = {},
2121
+ serverRef: serverRefOptions = {}
2122
+ } = pluginOptions;
2123
+ const {
2124
+ mode,
2125
+ themeRoots,
2126
+ addonRoots,
2127
+ roots,
2128
+ data: { config }
2129
+ } = options;
2130
+ const drawingData = await loadDrawings(options);
2131
+ const publicRoots = [...themeRoots, ...addonRoots].map((i) => join8(i, "public")).filter(existsSync5);
2132
+ const plugins = [
2133
+ createMarkdownPlugin(options, pluginOptions),
2134
+ createVuePlugin(options, pluginOptions),
2135
+ createSlidesLoader(options, pluginOptions, serverOptions),
2136
+ Components({
2137
+ extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
2138
+ dirs: [
2139
+ join8(options.clientRoot, "builtin"),
2140
+ ...roots.map((i) => join8(i, "components")),
2141
+ "src/components",
2142
+ "components",
2143
+ join8(process.cwd(), "components")
2144
+ ],
2145
+ include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
2146
+ exclude: [],
2147
+ resolvers: [
2148
+ IconsResolver({
2149
+ prefix: "",
2150
+ customCollections: Object.keys(iconsOptions.customCollections || [])
2151
+ })
2152
+ ],
2153
+ dts: false,
2154
+ ...componentsOptions
2155
+ }),
2156
+ Icons({
2157
+ defaultClass: "slidev-icon",
2158
+ collectionsNodeResolvePath: fileURLToPath(import.meta.url),
2159
+ ...iconsOptions
2160
+ }),
2161
+ config.remoteAssets === true || config.remoteAssets === mode ? import("vite-plugin-remote-assets").then((r) => r.VitePluginRemoteAssets({
2162
+ rules: [
2163
+ ...r.DefaultRules,
2164
+ {
2165
+ match: /\b(https?:\/\/image.unsplash\.com.*?)(?=[`'")\]])/ig,
2166
+ ext: ".png"
2167
+ }
2168
+ ],
2169
+ resolveMode: (id) => id.endsWith("index.html") ? "relative" : "@fs",
2170
+ awaitDownload: mode === "build",
2171
+ ...remoteAssetsOptions
2172
+ })) : null,
2173
+ ServerRef({
2174
+ debug: false,
2175
+ // process.env.NODE_ENV === 'development',
2176
+ state: {
2177
+ sync: false,
2178
+ nav: {
2179
+ page: 0,
2180
+ clicks: 0
2181
+ },
2182
+ drawings: drawingData,
2183
+ ...serverRefOptions.state
2184
+ },
2185
+ onChanged(key, data, patch, timestamp) {
2186
+ serverRefOptions.onChanged && serverRefOptions.onChanged(key, data, patch, timestamp);
2187
+ if (!options.data.config.drawings.persist)
2188
+ return;
2189
+ if (key === "drawings")
2190
+ writeDrawings(options, patch ?? data);
2191
+ }
2192
+ }),
2193
+ createConfigPlugin(options),
2194
+ createMonacoTypesLoader(options),
2195
+ createVueCompilerFlagsPlugin(options),
2196
+ publicRoots.length ? import("vite-plugin-static-copy").then((r) => r.viteStaticCopy({
2197
+ silent: true,
2198
+ targets: publicRoots.map((r2) => ({
2199
+ src: `${r2}/*`,
2200
+ dest: "theme"
2201
+ }))
2202
+ })) : null,
2203
+ options.inspect ? import("vite-plugin-inspect").then((r) => (r.default || r)({
2204
+ dev: true,
2205
+ build: true
2206
+ })) : null,
2207
+ config.css === "none" ? null : import("./unocss-AGKZGMYO.mjs").then((r) => r.createUnocssPlugin(options, pluginOptions))
2208
+ ];
2209
+ return (await Promise.all(plugins)).flat().filter(notNullish2);
2210
+ }
2211
+
2212
+ export {
2213
+ getIndexHtml,
2214
+ mergeViteConfigs,
2215
+ ViteSlidevPlugin
2216
+ };