@slidev/cli 0.45.0 → 0.46.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,124 @@
1
+ import {
2
+ ViteSlidevPlugin,
3
+ getIndexHtml,
4
+ mergeViteConfigs
5
+ } from "./chunk-HJK7CHXL.mjs";
6
+ import "./chunk-CTBVOVLQ.mjs";
7
+ import "./chunk-5L3XKTHL.mjs";
8
+ import "./chunk-BXO7ZPPU.mjs";
9
+
10
+ // node/build.ts
11
+ import { join, resolve } from "node:path";
12
+ import http from "node:http";
13
+ import fs from "fs-extra";
14
+ import { mergeConfig, build as viteBuild } from "vite";
15
+ import connect from "connect";
16
+ import sirv from "sirv";
17
+ import { blue, yellow } from "kolorist";
18
+ async function build(options, viteConfig = {}, args) {
19
+ const indexPath = resolve(options.userRoot, "index.html");
20
+ let originalIndexHTML;
21
+ if (fs.existsSync(indexPath))
22
+ originalIndexHTML = await fs.readFile(indexPath, "utf-8");
23
+ await fs.writeFile(indexPath, await getIndexHtml(options), "utf-8");
24
+ let config = void 0;
25
+ try {
26
+ let inlineConfig = await mergeViteConfigs(
27
+ options,
28
+ viteConfig,
29
+ {
30
+ root: options.userRoot,
31
+ plugins: [
32
+ {
33
+ name: "resolve-config",
34
+ configResolved(_config) {
35
+ config = _config;
36
+ }
37
+ }
38
+ ],
39
+ build: {
40
+ chunkSizeWarningLimit: 2e3
41
+ }
42
+ },
43
+ "build"
44
+ );
45
+ inlineConfig = mergeConfig(
46
+ inlineConfig,
47
+ {
48
+ plugins: [
49
+ await ViteSlidevPlugin(options, inlineConfig.slidev || {})
50
+ ]
51
+ }
52
+ );
53
+ await viteBuild(inlineConfig);
54
+ if (options.data.features.monaco) {
55
+ if (options.data.config.monaco === "dev") {
56
+ console.log(yellow(" Monaco is disabled in the build, to enabled it, set `monaco: true` in the frontmatter"));
57
+ } else {
58
+ console.log(blue(" building for Monaco...\n"));
59
+ await viteBuild(
60
+ await mergeViteConfigs(
61
+ options,
62
+ inlineConfig,
63
+ {
64
+ root: join(options.clientRoot, "iframes/monaco"),
65
+ base: `${config.base}iframes/monaco/`,
66
+ build: {
67
+ outDir: resolve(config.build.outDir, "iframes/monaco"),
68
+ // fix for monaco workers
69
+ // https://github.com/vitejs/vite/issues/1927#issuecomment-805803918
70
+ rollupOptions: {
71
+ output: {
72
+ manualChunks: {
73
+ jsonWorker: ["monaco-editor/esm/vs/language/json/json.worker"],
74
+ cssWorker: ["monaco-editor/esm/vs/language/css/css.worker"],
75
+ htmlWorker: ["monaco-editor/esm/vs/language/html/html.worker"],
76
+ tsWorker: ["monaco-editor/esm/vs/language/typescript/ts.worker"],
77
+ editorWorker: ["monaco-editor/esm/vs/editor/editor.worker"]
78
+ }
79
+ }
80
+ }
81
+ }
82
+ },
83
+ "build"
84
+ )
85
+ );
86
+ }
87
+ }
88
+ } finally {
89
+ if (originalIndexHTML != null)
90
+ await fs.writeFile(indexPath, originalIndexHTML, "utf-8");
91
+ else
92
+ await fs.unlink(indexPath);
93
+ }
94
+ const outDir = resolve(options.userRoot, config.build.outDir);
95
+ await fs.copyFile(resolve(outDir, "index.html"), resolve(outDir, "404.html"));
96
+ const redirectsPath = resolve(outDir, "_redirects");
97
+ if (!fs.existsSync(redirectsPath))
98
+ await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
99
+ `, "utf-8");
100
+ if ([true, "true", "auto"].includes(options.data.config.download)) {
101
+ const { exportSlides, getExportOptions } = await import("./export-T7HYPK5J.mjs");
102
+ const port = 12445;
103
+ const app = connect();
104
+ const server = http.createServer(app);
105
+ app.use(
106
+ config.base,
107
+ sirv(outDir, {
108
+ etag: true,
109
+ single: true,
110
+ dev: true
111
+ })
112
+ );
113
+ server.listen(port);
114
+ await exportSlides({
115
+ port,
116
+ base: config.base,
117
+ ...getExportOptions(args, options, outDir, "slidev-exported.pdf")
118
+ });
119
+ server.close();
120
+ }
121
+ }
122
+ export {
123
+ build
124
+ };
@@ -20,7 +20,7 @@ async function loadSetups(roots, name, arg, initial, merge = true) {
20
20
  let returns = initial;
21
21
  for (const root of roots) {
22
22
  const path = resolve(root, "setup", name);
23
- if (await fs.pathExists(path)) {
23
+ if (fs.existsSync(path)) {
24
24
  const { default: setup } = jiti(fileURLToPath(import.meta.url))(path);
25
25
  const result = await setup(arg);
26
26
  if (result !== null) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadSetups
3
- } from "./chunk-CYLMMBRG.mjs";
3
+ } from "./chunk-CTBVOVLQ.mjs";
4
4
  import {
5
5
  resolveImportPath
6
6
  } from "./chunk-5L3XKTHL.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadSetups
3
- } from "./chunk-CYLMMBRG.mjs";
3
+ } from "./chunk-CTBVOVLQ.mjs";
4
4
  import {
5
5
  generateGoogleFontsUrl,
6
6
  resolveGlobalImportPath,
@@ -8,61 +8,12 @@ import {
8
8
  stringifyMarkdownTokens,
9
9
  toAtFS
10
10
  } from "./chunk-5L3XKTHL.mjs";
11
- import {
12
- __commonJS,
13
- __toESM
14
- } from "./chunk-BXO7ZPPU.mjs";
15
-
16
- // ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
17
- var require_fast_deep_equal = __commonJS({
18
- "../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js"(exports, module) {
19
- "use strict";
20
- module.exports = function equal2(a, b) {
21
- if (a === b)
22
- return true;
23
- if (a && b && typeof a == "object" && typeof b == "object") {
24
- if (a.constructor !== b.constructor)
25
- return false;
26
- var length, i, keys;
27
- if (Array.isArray(a)) {
28
- length = a.length;
29
- if (length != b.length)
30
- return false;
31
- for (i = length; i-- !== 0; )
32
- if (!equal2(a[i], b[i]))
33
- return false;
34
- return true;
35
- }
36
- if (a.constructor === RegExp)
37
- return a.source === b.source && a.flags === b.flags;
38
- if (a.valueOf !== Object.prototype.valueOf)
39
- return a.valueOf() === b.valueOf();
40
- if (a.toString !== Object.prototype.toString)
41
- return a.toString() === b.toString();
42
- keys = Object.keys(a);
43
- length = keys.length;
44
- if (length !== Object.keys(b).length)
45
- return false;
46
- for (i = length; i-- !== 0; )
47
- if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
48
- return false;
49
- for (i = length; i-- !== 0; ) {
50
- var key = keys[i];
51
- if (!equal2(a[key], b[key]))
52
- return false;
53
- }
54
- return true;
55
- }
56
- return a !== a && b !== b;
57
- };
58
- }
59
- });
60
11
 
61
12
  // node/common.ts
62
13
  import { existsSync, promises as fs } from "node:fs";
63
14
  import { join } from "node:path";
64
15
  import { uniq } from "@antfu/utils";
65
- import { loadConfigFromFile, mergeConfig } from "vite";
16
+ import { loadConfigFromFile, mergeConfig, resolveConfig } from "vite";
66
17
  async function getIndexHtml({ clientRoot, themeRoots, addonRoots, data, userRoot }) {
67
18
  let main = await fs.readFile(join(clientRoot, "index.html"), "utf-8");
68
19
  let head = "";
@@ -91,7 +42,7 @@ ${(index.match(/<body>([\s\S]*?)<\/body>/im)?.[1] || "").trim()}`;
91
42
  main = main.replace("__ENTRY__", toAtFS(join(clientRoot, "main.ts"))).replace("<!-- head -->", head).replace("<!-- body -->", body);
92
43
  return main;
93
44
  }
94
- async function mergeViteConfigs({ addonRoots, themeRoots }, viteConfig, config, command) {
45
+ async function mergeViteConfigs({ addonRoots, themeRoots, entry }, viteConfig, config, command) {
95
46
  const configEnv = {
96
47
  mode: "development",
97
48
  command
@@ -108,7 +59,10 @@ async function mergeViteConfigs({ addonRoots, themeRoots }, viteConfig, config,
108
59
  continue;
109
60
  config = mergeConfig(config, viteConfig2.config);
110
61
  }
111
- return mergeConfig(viteConfig, config);
62
+ config = mergeConfig(config, viteConfig);
63
+ const localConfig = await resolveConfig({}, command, entry);
64
+ config = mergeConfig(config, { slidev: localConfig.slidev || {} });
65
+ return config;
112
66
  }
113
67
 
114
68
  // node/plugins/preset.ts
@@ -182,13 +136,13 @@ import { uniq as uniq2 } from "@antfu/utils";
182
136
 
183
137
  // ../client/package.json
184
138
  var dependencies = {
185
- "@antfu/utils": "^0.7.6",
139
+ "@antfu/utils": "^0.7.7",
186
140
  "@slidev/parser": "workspace:*",
187
141
  "@slidev/types": "workspace:*",
188
- "@unhead/vue": "^1.8.8",
142
+ "@unhead/vue": "^1.8.9",
189
143
  "@unocss/reset": "^0.58.0",
190
- "@vueuse/core": "^10.6.1",
191
- "@vueuse/math": "^10.6.1",
144
+ "@vueuse/core": "^10.7.0",
145
+ "@vueuse/math": "^10.7.0",
192
146
  "@vueuse/motion": "^2.0.0",
193
147
  codemirror: "^5.65.5",
194
148
  defu: "^6.1.3",
@@ -201,12 +155,12 @@ var dependencies = {
201
155
  mermaid: "^10.6.1",
202
156
  "monaco-editor": "^0.37.1",
203
157
  nanoid: "^5.0.4",
204
- prettier: "^3.1.0",
158
+ prettier: "^3.1.1",
205
159
  recordrtc: "^5.6.2",
206
160
  resolve: "^1.22.8",
207
161
  unocss: "^0.58.0",
208
162
  "vite-plugin-windicss": "^1.9.2",
209
- vue: "^3.3.9",
163
+ vue: "^3.3.11",
210
164
  "vue-router": "^4.2.5",
211
165
  "vue-starport": "^0.4.0",
212
166
  windicss: "^3.5.6"
@@ -363,7 +317,6 @@ function getDefine(options) {
363
317
  }
364
318
 
365
319
  // node/plugins/loaders.ts
366
- var import_fast_deep_equal = __toESM(require_fast_deep_equal());
367
320
  import { basename as basename2, join as join5 } from "node:path";
368
321
  import process from "node:process";
369
322
  import { isString, notNullish, objectMap, range, slash, uniq as uniq3 } from "@antfu/utils";
@@ -373,6 +326,7 @@ import Markdown from "markdown-it";
373
326
  import { bold, gray, red, yellow } from "kolorist";
374
327
  import mila from "markdown-it-link-attributes";
375
328
  import * as parser from "@slidev/parser/fs";
329
+ import equal from "fast-deep-equal";
376
330
  var regexId = /^\/\@slidev\/slide\/(\d+)\.(md|json)(?:\?import)?$/;
377
331
  var regexIdQuery = /(\d+?)\.(md|json|frontmatter)$/;
378
332
  var vueContextImports = [
@@ -391,13 +345,13 @@ var vueContextImports = [
391
345
  "const $renderContext = _vueInject(_injectionRenderContext)"
392
346
  ];
393
347
  function getBodyJson(req) {
394
- return new Promise((resolve3, reject) => {
348
+ return new Promise((resolve4, reject) => {
395
349
  let body = "";
396
350
  req.on("data", (chunk) => body += chunk);
397
351
  req.on("error", reject);
398
352
  req.on("end", () => {
399
353
  try {
400
- resolve3(JSON.parse(body) || {});
354
+ resolve4(JSON.parse(body) || {});
401
355
  } catch (e) {
402
356
  reject(e);
403
357
  }
@@ -467,13 +421,13 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
467
421
  moduleIds.add("/@slidev/routes");
468
422
  range(newData.slides.length).map((i) => hmrPages.add(i));
469
423
  }
470
- if (!(0, import_fast_deep_equal.default)(data.headmatter.defaults, newData.headmatter.defaults)) {
424
+ if (!equal(data.headmatter.defaults, newData.headmatter.defaults)) {
471
425
  moduleIds.add("/@slidev/routes");
472
426
  range(data.slides.length).map((i) => hmrPages.add(i));
473
427
  }
474
- if (!(0, import_fast_deep_equal.default)(data.config, newData.config))
428
+ if (!equal(data.config, newData.config))
475
429
  moduleIds.add("/@slidev/configs");
476
- if (!(0, import_fast_deep_equal.default)(data.features, newData.features)) {
430
+ if (!equal(data.features, newData.features)) {
477
431
  setTimeout(() => {
478
432
  ctx.server.ws.send({ type: "full-reload" });
479
433
  }, 1);
@@ -482,7 +436,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
482
436
  for (let i = 0; i < length; i++) {
483
437
  const a = data.slides[i];
484
438
  const b = newData.slides[i];
485
- if (a?.content.trim() === b?.content.trim() && a?.title?.trim() === b?.title?.trim() && a?.note === b?.note && (0, import_fast_deep_equal.default)(a.frontmatter, b.frontmatter))
439
+ if (a?.content.trim() === b?.content.trim() && a?.title?.trim() === b?.title?.trim() && a?.note === b?.note && equal(a.frontmatter, b.frontmatter))
486
440
  continue;
487
441
  ctx.server.ws.send({
488
442
  type: "custom",
@@ -817,6 +771,8 @@ defineProps<{ no: number | string }>()`);
817
771
  }
818
772
  if (data.features.katex)
819
773
  imports.push(`import "${toAtFS(resolveImportPath("katex/dist/katex.min.css", true))}"`);
774
+ if (data.config.highlighter === "shikiji")
775
+ imports.push(`import "${toAtFS(resolveImportPath("shikiji-twoslash/style-rich.css", true))}"`);
820
776
  if (data.config.css === "unocss") {
821
777
  imports.unshift(
822
778
  'import "@unocss/reset/tailwind.css"',
@@ -1036,14 +992,146 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
1036
992
  }
1037
993
 
1038
994
  // node/plugins/markdown.ts
995
+ import { resolve as resolve3 } from "node:path";
1039
996
  import Markdown2 from "unplugin-vue-markdown/vite";
1040
997
  import * as base64 from "js-base64";
1041
998
  import { slash as slash4 } from "@antfu/utils";
1042
999
  import mila2 from "markdown-it-link-attributes";
1043
1000
  import mif from "markdown-it-footnote";
1044
- import { taskLists } from "@hedgedoc/markdown-it-plugins";
1001
+
1002
+ // ../../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
1003
+ var SpecialCharacters;
1004
+ (function(SpecialCharacters2) {
1005
+ SpecialCharacters2[SpecialCharacters2["EXCLAMATION_MARK"] = 33] = "EXCLAMATION_MARK";
1006
+ SpecialCharacters2[SpecialCharacters2["OPENING_BRACKET"] = 91] = "OPENING_BRACKET";
1007
+ SpecialCharacters2[SpecialCharacters2["OPENING_PARENTHESIS"] = 40] = "OPENING_PARENTHESIS";
1008
+ SpecialCharacters2[SpecialCharacters2["WHITESPACE"] = 32] = "WHITESPACE";
1009
+ SpecialCharacters2[SpecialCharacters2["NEW_LINE"] = 10] = "NEW_LINE";
1010
+ SpecialCharacters2[SpecialCharacters2["EQUALS"] = 61] = "EQUALS";
1011
+ SpecialCharacters2[SpecialCharacters2["LOWER_CASE_X"] = 120] = "LOWER_CASE_X";
1012
+ SpecialCharacters2[SpecialCharacters2["NUMBER_ZERO"] = 48] = "NUMBER_ZERO";
1013
+ SpecialCharacters2[SpecialCharacters2["NUMBER_NINE"] = 57] = "NUMBER_NINE";
1014
+ SpecialCharacters2[SpecialCharacters2["PERCENTAGE"] = 37] = "PERCENTAGE";
1015
+ SpecialCharacters2[SpecialCharacters2["CLOSING_PARENTHESIS"] = 41] = "CLOSING_PARENTHESIS";
1016
+ })(SpecialCharacters || (SpecialCharacters = {}));
1017
+
1018
+ // ../../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
1019
+ import Token from "markdown-it/lib/token.mjs";
1020
+ var checkboxRegex = /^ *\[([\sx])] /i;
1021
+ function taskLists(md2, options = { enabled: false, label: false, lineNumber: false }) {
1022
+ md2.core.ruler.after("inline", "task-lists", (state) => processToken(state, options));
1023
+ md2.renderer.rules.taskListItemCheckbox = (tokens) => {
1024
+ const token = tokens[0];
1025
+ const checkedAttribute = token.attrGet("checked") ? 'checked="" ' : "";
1026
+ const disabledAttribute = token.attrGet("disabled") ? 'disabled="" ' : "";
1027
+ const line = token.attrGet("line");
1028
+ const idAttribute = `id="${token.attrGet("id")}" `;
1029
+ const dataLineAttribute = line && options.lineNumber ? `data-line="${line}" ` : "";
1030
+ return `<input class="task-list-item-checkbox" type="checkbox" ${checkedAttribute}${disabledAttribute}${dataLineAttribute}${idAttribute}/>`;
1031
+ };
1032
+ md2.renderer.rules.taskListItemLabel_close = () => {
1033
+ return "</label>";
1034
+ };
1035
+ md2.renderer.rules.taskListItemLabel_open = (tokens) => {
1036
+ const token = tokens[0];
1037
+ const id = token.attrGet("id");
1038
+ return `<label for="${id}">`;
1039
+ };
1040
+ }
1041
+ function processToken(state, options) {
1042
+ const allTokens = state.tokens;
1043
+ for (let i = 2; i < allTokens.length; i++) {
1044
+ if (!isTodoItem(allTokens, i)) {
1045
+ continue;
1046
+ }
1047
+ todoify(allTokens[i], options);
1048
+ allTokens[i - 2].attrJoin("class", `task-list-item ${options.enabled ? " enabled" : ""}`);
1049
+ const parentToken = findParentToken(allTokens, i - 2);
1050
+ if (parentToken) {
1051
+ const classes = parentToken.attrGet("class") ?? "";
1052
+ if (!classes.match(/(^| )contains-task-list/)) {
1053
+ parentToken.attrJoin("class", "contains-task-list");
1054
+ }
1055
+ }
1056
+ }
1057
+ return false;
1058
+ }
1059
+ function findParentToken(tokens, index) {
1060
+ const targetLevel = tokens[index].level - 1;
1061
+ for (let currentTokenIndex = index - 1; currentTokenIndex >= 0; currentTokenIndex--) {
1062
+ if (tokens[currentTokenIndex].level === targetLevel) {
1063
+ return tokens[currentTokenIndex];
1064
+ }
1065
+ }
1066
+ return void 0;
1067
+ }
1068
+ function isTodoItem(tokens, index) {
1069
+ return isInline(tokens[index]) && isParagraph(tokens[index - 1]) && isListItem(tokens[index - 2]) && startsWithTodoMarkdown(tokens[index]);
1070
+ }
1071
+ function todoify(token, options) {
1072
+ if (token.children == null) {
1073
+ return;
1074
+ }
1075
+ const id = generateIdForToken(token);
1076
+ token.children.splice(0, 0, createCheckboxToken(token, options.enabled, id));
1077
+ token.children[1].content = token.children[1].content.replace(checkboxRegex, "");
1078
+ if (options.label) {
1079
+ token.children.splice(1, 0, createLabelBeginToken(id));
1080
+ token.children.push(createLabelEndToken());
1081
+ }
1082
+ }
1083
+ function generateIdForToken(token) {
1084
+ if (token.map) {
1085
+ return `task-item-${token.map[0]}`;
1086
+ } else {
1087
+ return `task-item-${Math.ceil(Math.random() * (1e4 * 1e3) - 1e3)}`;
1088
+ }
1089
+ }
1090
+ function createCheckboxToken(token, enabled, id) {
1091
+ const checkbox = new Token("taskListItemCheckbox", "", 0);
1092
+ if (!enabled) {
1093
+ checkbox.attrSet("disabled", "true");
1094
+ }
1095
+ if (token.map) {
1096
+ checkbox.attrSet("line", token.map[0].toString());
1097
+ }
1098
+ checkbox.attrSet("id", id);
1099
+ const checkboxRegexResult = checkboxRegex.exec(token.content);
1100
+ const isChecked = checkboxRegexResult?.[1].toLowerCase() === "x";
1101
+ if (isChecked) {
1102
+ checkbox.attrSet("checked", "true");
1103
+ }
1104
+ return checkbox;
1105
+ }
1106
+ function createLabelBeginToken(id) {
1107
+ const labelBeginToken = new Token("taskListItemLabel_open", "", 1);
1108
+ labelBeginToken.attrSet("id", id);
1109
+ return labelBeginToken;
1110
+ }
1111
+ function createLabelEndToken() {
1112
+ return new Token("taskListItemLabel_close", "", -1);
1113
+ }
1114
+ function isInline(token) {
1115
+ return token.type === "inline";
1116
+ }
1117
+ function isParagraph(token) {
1118
+ return token.type === "paragraph_open";
1119
+ }
1120
+ function isListItem(token) {
1121
+ return token.type === "list_item_open";
1122
+ }
1123
+ function startsWithTodoMarkdown(token) {
1124
+ return checkboxRegex.test(token.content);
1125
+ }
1126
+
1127
+ // ../../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/toc/plugin.js
1128
+ import { Optional } from "@mrdrogdrog/optional";
1129
+
1130
+ // node/plugins/markdown.ts
1045
1131
  import { encode as encode2 } from "plantuml-encoder";
1046
1132
  import Mdc from "markdown-it-mdc";
1133
+ import { addClassToHast } from "shikiji";
1134
+ import fs6 from "fs-extra";
1047
1135
 
1048
1136
  // node/plugins/markdown-it-katex.ts
1049
1137
  import katex from "katex";
@@ -1364,6 +1452,29 @@ async function createMarkdownPlugin({ data: { config }, roots, mode, entry }, {
1364
1452
  const { langs, themes } = resolveShikiOptions(shikiOptions);
1365
1453
  shikiOptions.highlighter = await Shiki.getHighlighter({ themes, langs });
1366
1454
  setups.push((md2) => md2.use(markdown_it_shiki_default, shikiOptions));
1455
+ } else if (config.highlighter === "shikiji") {
1456
+ const MarkdownItShikiji = await import("markdown-it-shikiji").then((r) => r.default);
1457
+ const { transformerTwoSlash, rendererRich } = await import("shikiji-twoslash");
1458
+ const options = await loadShikijiSetups(roots);
1459
+ const plugin = await MarkdownItShikiji({
1460
+ ...options,
1461
+ transformers: [
1462
+ ...options.transformers || [],
1463
+ transformerTwoSlash({
1464
+ explicitTrigger: true,
1465
+ renderer: rendererRich
1466
+ }),
1467
+ {
1468
+ pre(pre) {
1469
+ addClassToHast(pre, "slidev-code shikiji");
1470
+ },
1471
+ postprocess(code) {
1472
+ return escapeVueInCode(code);
1473
+ }
1474
+ }
1475
+ ]
1476
+ });
1477
+ setups.push((md2) => md2.use(plugin));
1367
1478
  } else {
1368
1479
  setups.push((md2) => md2.use(markdownItPrism));
1369
1480
  }
@@ -1452,7 +1563,7 @@ function transformSlotSugar(md2) {
1452
1563
  lines.forEach((line, idx) => {
1453
1564
  if (isLineInsideCodeblocks(idx))
1454
1565
  return;
1455
- const match = line.trimEnd().match(/^::\s*(\w+)\s*::$/);
1566
+ const match = line.trimEnd().match(/^::\s*([\w\.\-\:]+)\s*::$/);
1456
1567
  if (match) {
1457
1568
  lines[idx] = `${prevSlot ? "\n\n</template>\n" : "\n"}<template v-slot:${match[1]}="slotProps">
1458
1569
  `;
@@ -1464,14 +1575,14 @@ function transformSlotSugar(md2) {
1464
1575
  return lines.join("\n");
1465
1576
  }
1466
1577
  function transformHighlighter(md2) {
1467
- return md2.replace(/^```(\w+?)(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?\s*?)?\n([\s\S]+?)^```/mg, (full, lang = "", rangeStr = "", options = "", code) => {
1578
+ return md2.replace(/^```(\w+?)(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?(.*?))?\n([\s\S]+?)^```/mg, (full, lang = "", rangeStr = "", options = "", attrs = "", code) => {
1468
1579
  const ranges = rangeStr.split(/\|/g).map((i) => i.trim());
1469
1580
  code = code.trimEnd();
1470
1581
  options = options.trim() || "{}";
1471
1582
  return `
1472
1583
  <CodeBlockWrapper v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>
1473
1584
 
1474
- \`\`\`${lang}
1585
+ \`\`\`${lang}${attrs}
1475
1586
  ${code}
1476
1587
  \`\`\`
1477
1588
 
@@ -1532,6 +1643,25 @@ function transformPlantUml(md2, server) {
1532
1643
  function escapeVueInCode(md2) {
1533
1644
  return md2.replace(/{{(.*?)}}/g, "&lbrace;&lbrace;$1&rbrace;&rbrace;");
1534
1645
  }
1646
+ async function loadShikijiSetups(roots) {
1647
+ const anyShikiji = roots.some((root) => fs6.existsSync(resolve3(root, "setup", "shikiji.ts")));
1648
+ const result = anyShikiji ? await loadSetups(roots, "shikiji.ts", void 0, {}, false) : await loadSetups(roots, "shiki.ts", await import("shiki"), {}, false);
1649
+ if ("theme" in result && "themes" in result)
1650
+ delete result.theme;
1651
+ if (result.theme && typeof result.theme !== "string") {
1652
+ result.themes = result.theme;
1653
+ delete result.theme;
1654
+ }
1655
+ if (!result.theme && !result.themes) {
1656
+ result.themes = {
1657
+ dark: "vitesse-dark",
1658
+ light: "vitesse-light"
1659
+ };
1660
+ }
1661
+ if (result.themes)
1662
+ result.defaultColor = false;
1663
+ return result;
1664
+ }
1535
1665
 
1536
1666
  // node/plugins/patchTransform.ts
1537
1667
  import { objectEntries } from "@antfu/utils";
@@ -1697,7 +1827,7 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
1697
1827
  dev: true,
1698
1828
  build: true
1699
1829
  })) : null,
1700
- config.css === "none" ? null : config.css === "windicss" ? import("./windicss-SDUK26CZ.mjs").then((r) => r.createWindiCSSPlugin(options, pluginOptions)) : import("./unocss-GHP27KVT.mjs").then((r) => r.createUnocssPlugin(options, pluginOptions))
1830
+ config.css === "none" ? null : config.css === "windicss" ? import("./windicss-V4JJMSQI.mjs").then((r) => r.createWindiCSSPlugin(options, pluginOptions)) : import("./unocss-6IVIFJMZ.mjs").then((r) => r.createUnocssPlugin(options, pluginOptions))
1701
1831
  ];
1702
1832
  return (await Promise.all(plugins)).flat().filter(notNullish2);
1703
1833
  }
@@ -1705,6 +1835,5 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
1705
1835
  export {
1706
1836
  getIndexHtml,
1707
1837
  mergeViteConfigs,
1708
- require_fast_deep_equal,
1709
1838
  ViteSlidevPlugin
1710
1839
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ViteSlidevPlugin,
3
3
  mergeViteConfigs
4
- } from "./chunk-VHBBQ77F.mjs";
4
+ } from "./chunk-HJK7CHXL.mjs";
5
5
  import {
6
6
  packageExists,
7
7
  resolveImportPath
@@ -2490,27 +2490,30 @@ var require_semver2 = __commonJS({
2490
2490
  // node/server.ts
2491
2491
  import { join } from "node:path";
2492
2492
  import process2 from "node:process";
2493
- import { createServer as createViteServer, resolveConfig } from "vite";
2493
+ import { createServer as createViteServer, mergeConfig } from "vite";
2494
2494
  async function createServer(options2, viteConfig = {}, serverOptions = {}) {
2495
- const rawConfig = await resolveConfig({}, "serve", options2.entry);
2496
- const pluginOptions = rawConfig.slidev || {};
2497
2495
  process2.env.EDITOR = process2.env.EDITOR || "code";
2496
+ const config2 = await mergeViteConfigs(
2497
+ options2,
2498
+ viteConfig,
2499
+ {
2500
+ root: options2.userRoot,
2501
+ optimizeDeps: {
2502
+ entries: [
2503
+ join(options2.clientRoot, "main.ts")
2504
+ ]
2505
+ }
2506
+ },
2507
+ "serve"
2508
+ );
2498
2509
  const server = await createViteServer(
2499
- await mergeViteConfigs(
2500
- options2,
2501
- viteConfig,
2510
+ mergeConfig(
2511
+ config2,
2502
2512
  {
2503
- root: options2.userRoot,
2504
- optimizeDeps: {
2505
- entries: [
2506
- join(options2.clientRoot, "main.ts")
2507
- ]
2508
- },
2509
2513
  plugins: [
2510
- await ViteSlidevPlugin(options2, pluginOptions, serverOptions)
2514
+ await ViteSlidevPlugin(options2, config2.slidev || {}, serverOptions)
2511
2515
  ]
2512
- },
2513
- "serve"
2516
+ }
2514
2517
  )
2515
2518
  );
2516
2519
  return server;
@@ -2520,7 +2523,7 @@ async function createServer(options2, viteConfig = {}, serverOptions = {}) {
2520
2523
  import * as parser from "@slidev/parser/fs";
2521
2524
 
2522
2525
  // package.json
2523
- var version = "0.45.0";
2526
+ var version = "0.46.0";
2524
2527
 
2525
2528
  // node/themes.ts
2526
2529
  import prompts2 from "prompts";