@slidev/cli 0.49.7 → 0.49.9

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.
@@ -2,7 +2,7 @@ import {
2
2
  ViteSlidevPlugin,
3
3
  getIndexHtml,
4
4
  mergeViteConfigs
5
- } from "./chunk-USRVNGYC.mjs";
5
+ } from "./chunk-ZATTXN6U.mjs";
6
6
  import "./chunk-LOUKLO2C.mjs";
7
7
  import "./chunk-RG2EEPCO.mjs";
8
8
  import "./chunk-BXO7ZPPU.mjs";
@@ -63,7 +63,7 @@ async function build(options, viteConfig = {}, args) {
63
63
  await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
64
64
  `, "utf-8");
65
65
  if ([true, "true", "auto"].includes(options.data.config.download)) {
66
- const { exportSlides, getExportOptions } = await import("./export-Q4LURPEZ.mjs");
66
+ const { exportSlides, getExportOptions } = await import("./export-BSOHDR2A.mjs");
67
67
  const port = 12445;
68
68
  const app = connect();
69
69
  const server = http.createServer(app);
@@ -0,0 +1,44 @@
1
+ import {
2
+ ViteSlidevPlugin,
3
+ mergeViteConfigs
4
+ } from "./chunk-ZATTXN6U.mjs";
5
+
6
+ // node/commands/server.ts
7
+ import { join } from "node:path";
8
+ import process from "node:process";
9
+ import { createServer as createViteServer, mergeConfig } from "vite";
10
+ async function createServer(options, viteConfig = {}, serverOptions = {}) {
11
+ process.env.EDITOR = process.env.EDITOR || "code";
12
+ const config = await mergeViteConfigs(
13
+ options,
14
+ viteConfig,
15
+ {
16
+ root: options.userRoot,
17
+ optimizeDeps: {
18
+ entries: [
19
+ join(options.clientRoot, "main.ts")
20
+ ]
21
+ }
22
+ },
23
+ "serve"
24
+ );
25
+ const server = await createViteServer(
26
+ mergeConfig(
27
+ config,
28
+ {
29
+ plugins: [
30
+ await ViteSlidevPlugin(options, config.slidev || {}, serverOptions)
31
+ ],
32
+ define: {
33
+ // Fixes Vue production mode breaking PDF Export #1245
34
+ __VUE_PROD_DEVTOOLS__: JSON.stringify(true)
35
+ }
36
+ }
37
+ )
38
+ );
39
+ return server;
40
+ }
41
+
42
+ export {
43
+ createServer
44
+ };
@@ -2,7 +2,10 @@ import {
2
2
  loadSetups
3
3
  } from "./chunk-LOUKLO2C.mjs";
4
4
  import {
5
+ createResolver,
6
+ getRoots,
5
7
  isInstalledGlobally,
8
+ resolveEntry,
6
9
  resolveImportPath,
7
10
  resolveImportUrl,
8
11
  toAtFS
@@ -1624,7 +1627,7 @@ ${ctx.indent}`;
1624
1627
  var require_log = __commonJS({
1625
1628
  "../../node_modules/.pnpm/yaml@2.4.2/node_modules/yaml/dist/log.js"(exports) {
1626
1629
  "use strict";
1627
- function debug(logLevel, ...messages) {
1630
+ function debug2(logLevel, ...messages) {
1628
1631
  if (logLevel === "debug")
1629
1632
  console.log(...messages);
1630
1633
  }
@@ -1636,7 +1639,7 @@ var require_log = __commonJS({
1636
1639
  console.warn(warning);
1637
1640
  }
1638
1641
  }
1639
- exports.debug = debug;
1642
+ exports.debug = debug2;
1640
1643
  exports.warn = warn;
1641
1644
  }
1642
1645
  });
@@ -6707,14 +6710,14 @@ var require_parser = __commonJS({
6707
6710
  case "scalar":
6708
6711
  case "single-quoted-scalar":
6709
6712
  case "double-quoted-scalar": {
6710
- const fs7 = this.flowScalar(this.type);
6713
+ const fs9 = this.flowScalar(this.type);
6711
6714
  if (atNextItem || it.value) {
6712
- map.items.push({ start, key: fs7, sep: [] });
6715
+ map.items.push({ start, key: fs9, sep: [] });
6713
6716
  this.onKeyLine = true;
6714
6717
  } else if (it.sep) {
6715
- this.stack.push(fs7);
6718
+ this.stack.push(fs9);
6716
6719
  } else {
6717
- Object.assign(it, { key: fs7, sep: [] });
6720
+ Object.assign(it, { key: fs9, sep: [] });
6718
6721
  this.onKeyLine = true;
6719
6722
  }
6720
6723
  return;
@@ -6832,13 +6835,13 @@ var require_parser = __commonJS({
6832
6835
  case "scalar":
6833
6836
  case "single-quoted-scalar":
6834
6837
  case "double-quoted-scalar": {
6835
- const fs7 = this.flowScalar(this.type);
6838
+ const fs9 = this.flowScalar(this.type);
6836
6839
  if (!it || it.value)
6837
- fc.items.push({ start: [], key: fs7, sep: [] });
6840
+ fc.items.push({ start: [], key: fs9, sep: [] });
6838
6841
  else if (it.sep)
6839
- this.stack.push(fs7);
6842
+ this.stack.push(fs9);
6840
6843
  else
6841
- Object.assign(it, { key: fs7, sep: [] });
6844
+ Object.assign(it, { key: fs9, sep: [] });
6842
6845
  return;
6843
6846
  }
6844
6847
  case "flow-map-end":
@@ -7005,7 +7008,7 @@ var require_public_api = __commonJS({
7005
7008
  var errors = require_errors();
7006
7009
  var log = require_log();
7007
7010
  var lineCounter = require_line_counter();
7008
- var parser2 = require_parser();
7011
+ var parser3 = require_parser();
7009
7012
  function parseOptions(options) {
7010
7013
  const prettyErrors = options.prettyErrors !== false;
7011
7014
  const lineCounter$1 = options.lineCounter || prettyErrors && new lineCounter.LineCounter() || null;
@@ -7013,7 +7016,7 @@ var require_public_api = __commonJS({
7013
7016
  }
7014
7017
  function parseAllDocuments(source, options = {}) {
7015
7018
  const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
7016
- const parser$1 = new parser2.Parser(lineCounter2?.addNewLine);
7019
+ const parser$1 = new parser3.Parser(lineCounter2?.addNewLine);
7017
7020
  const composer$1 = new composer.Composer(options);
7018
7021
  const docs = Array.from(composer$1.compose(parser$1.parse(source)));
7019
7022
  if (prettyErrors && lineCounter2)
@@ -7027,7 +7030,7 @@ var require_public_api = __commonJS({
7027
7030
  }
7028
7031
  function parseDocument(source, options = {}) {
7029
7032
  const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
7030
- const parser$1 = new parser2.Parser(lineCounter2?.addNewLine);
7033
+ const parser$1 = new parser3.Parser(lineCounter2?.addNewLine);
7031
7034
  const composer$1 = new composer.Composer(options);
7032
7035
  let doc = null;
7033
7036
  for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {
@@ -7107,7 +7110,7 @@ var require_dist = __commonJS({
7107
7110
  var cst = require_cst();
7108
7111
  var lexer = require_lexer();
7109
7112
  var lineCounter = require_line_counter();
7110
- var parser2 = require_parser();
7113
+ var parser3 = require_parser();
7111
7114
  var publicApi = require_public_api();
7112
7115
  var visit = require_visit();
7113
7116
  exports.Composer = composer.Composer;
@@ -7132,7 +7135,7 @@ var require_dist = __commonJS({
7132
7135
  exports.CST = cst;
7133
7136
  exports.Lexer = lexer.Lexer;
7134
7137
  exports.LineCounter = lineCounter.LineCounter;
7135
- exports.Parser = parser2.Parser;
7138
+ exports.Parser = parser3.Parser;
7136
7139
  exports.parse = publicApi.parse;
7137
7140
  exports.parseAllDocuments = publicApi.parseAllDocuments;
7138
7141
  exports.parseDocument = publicApi.parseDocument;
@@ -7143,7 +7146,7 @@ var require_dist = __commonJS({
7143
7146
  });
7144
7147
 
7145
7148
  // package.json
7146
- var version = "0.49.7";
7149
+ var version = "0.49.9";
7147
7150
 
7148
7151
  // node/commands/shared.ts
7149
7152
  import { existsSync, promises as fs } from "node:fs";
@@ -7286,8 +7289,116 @@ async function mergeViteConfigs({ roots, entry }, viteConfig, config, command) {
7286
7289
  return config;
7287
7290
  }
7288
7291
 
7292
+ // node/parser.ts
7293
+ import * as parser from "@slidev/parser/fs";
7294
+
7295
+ // node/integrations/themes.ts
7296
+ import { join as join2 } from "node:path";
7297
+ import fs2 from "fs-extra";
7298
+ import { satisfies } from "semver";
7299
+ var officialThemes = {
7300
+ "none": "",
7301
+ "default": "@slidev/theme-default",
7302
+ "seriph": "@slidev/theme-seriph",
7303
+ "apple-basic": "@slidev/theme-apple-basic",
7304
+ "shibainu": "@slidev/theme-shibainu",
7305
+ "bricks": "@slidev/theme-bricks"
7306
+ };
7307
+ var resolveTheme = createResolver("theme", officialThemes);
7308
+ async function getThemeMeta(name, root) {
7309
+ const path4 = join2(root, "package.json");
7310
+ if (!fs2.existsSync(path4))
7311
+ return {};
7312
+ const { slidev = {}, engines = {} } = await fs2.readJSON(path4);
7313
+ if (engines.slidev && !satisfies(version, engines.slidev, { includePrerelease: true }))
7314
+ throw new Error(`[slidev] theme "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
7315
+ return slidev;
7316
+ }
7317
+
7318
+ // node/integrations/addons.ts
7319
+ import { resolve } from "node:path";
7320
+ import fs3 from "fs-extra";
7321
+ import { satisfies as satisfies2 } from "semver";
7322
+ async function resolveAddons(addonsInConfig) {
7323
+ const { userRoot, userPkgJson } = await getRoots();
7324
+ const resolved = [];
7325
+ const resolveAddonNameAndRoot = createResolver("addon", {});
7326
+ async function resolveAddon(name, parent) {
7327
+ const [, pkgRoot] = await resolveAddonNameAndRoot(name, parent);
7328
+ if (!pkgRoot)
7329
+ return;
7330
+ resolved.push(pkgRoot);
7331
+ const { slidev = {}, engines = {} } = await fs3.readJSON(resolve(pkgRoot, "package.json"));
7332
+ if (engines.slidev && !satisfies2(version, engines.slidev, { includePrerelease: true }))
7333
+ throw new Error(`[slidev] addon "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
7334
+ if (Array.isArray(slidev.addons))
7335
+ await Promise.all(slidev.addons.map((addon) => resolveAddon(addon, pkgRoot)));
7336
+ }
7337
+ if (Array.isArray(addonsInConfig))
7338
+ await Promise.all(addonsInConfig.map((addon) => resolveAddon(addon, userRoot)));
7339
+ if (Array.isArray(userPkgJson.slidev?.addons))
7340
+ await Promise.all(userPkgJson.slidev.addons.map((addon) => resolveAddon(addon, userRoot)));
7341
+ return resolved;
7342
+ }
7343
+
7344
+ // node/options.ts
7345
+ import { uniq } from "@antfu/utils";
7346
+ import Debug from "debug";
7347
+ import mm from "micromatch";
7348
+ var debug = Debug("slidev:options");
7349
+ async function resolveOptions(options, mode) {
7350
+ const entry = await resolveEntry(options.entry);
7351
+ const rootsInfo = await getRoots(entry);
7352
+ const loaded = await parser.load(rootsInfo.userRoot, entry, void 0, mode);
7353
+ let themeRaw = options.theme || loaded.headmatter.theme;
7354
+ themeRaw = themeRaw === null ? "none" : themeRaw || "default";
7355
+ const [theme, themeRoot] = await resolveTheme(themeRaw, entry);
7356
+ const themeRoots = themeRoot ? [themeRoot] : [];
7357
+ const themeMeta = themeRoot ? await getThemeMeta(theme, themeRoot) : void 0;
7358
+ const config = parser.resolveConfig(loaded.headmatter, themeMeta, options.entry);
7359
+ const addonRoots = await resolveAddons(config.addons);
7360
+ const roots = uniq([...themeRoots, ...addonRoots, rootsInfo.userRoot]);
7361
+ debug({
7362
+ ...rootsInfo,
7363
+ ...options,
7364
+ config,
7365
+ mode,
7366
+ entry,
7367
+ themeRaw,
7368
+ theme,
7369
+ themeRoots,
7370
+ addonRoots,
7371
+ roots
7372
+ });
7373
+ const data = {
7374
+ ...loaded,
7375
+ config,
7376
+ themeMeta
7377
+ };
7378
+ const resolved = {
7379
+ ...rootsInfo,
7380
+ ...options,
7381
+ data,
7382
+ mode,
7383
+ entry,
7384
+ themeRaw,
7385
+ theme,
7386
+ themeRoots,
7387
+ addonRoots,
7388
+ roots,
7389
+ utils: createDataUtils(data)
7390
+ };
7391
+ return resolved;
7392
+ }
7393
+ function createDataUtils(data) {
7394
+ const monacoTypesIgnorePackagesMatches = (data.config.monacoTypesIgnorePackages || []).map((i) => mm.matcher(i));
7395
+ return {
7396
+ isMonacoTypesIgnored: (pkg) => monacoTypesIgnorePackagesMatches.some((i) => i(pkg))
7397
+ };
7398
+ }
7399
+
7289
7400
  // node/vite/index.ts
7290
- import { join as join9 } from "node:path";
7401
+ import { join as join10 } from "node:path";
7291
7402
  import { existsSync as existsSync6 } from "node:fs";
7292
7403
  import process2 from "node:process";
7293
7404
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -7298,18 +7409,18 @@ import ServerRef from "vite-plugin-vue-server-ref";
7298
7409
  import { notNullish as notNullish2 } from "@antfu/utils";
7299
7410
 
7300
7411
  // node/integrations/drawings.ts
7301
- import { basename, dirname, join as join2, resolve } from "node:path";
7302
- import fs2 from "fs-extra";
7412
+ import { basename, dirname, join as join3, resolve as resolve2 } from "node:path";
7413
+ import fs4 from "fs-extra";
7303
7414
  import fg from "fast-glob";
7304
7415
  function resolveDrawingsDir(options) {
7305
- return options.data.config.drawings.persist ? resolve(
7416
+ return options.data.config.drawings.persist ? resolve2(
7306
7417
  dirname(options.entry),
7307
7418
  options.data.config.drawings.persist
7308
7419
  ) : void 0;
7309
7420
  }
7310
7421
  async function loadDrawings(options) {
7311
7422
  const dir = resolveDrawingsDir(options);
7312
- if (!dir || !fs2.existsSync(dir))
7423
+ if (!dir || !fs4.existsSync(dir))
7313
7424
  return {};
7314
7425
  const files = await fg("*.svg", {
7315
7426
  onlyFiles: true,
@@ -7322,7 +7433,7 @@ async function loadDrawings(options) {
7322
7433
  const num = +basename(path4, ".svg");
7323
7434
  if (Number.isNaN(num))
7324
7435
  return;
7325
- const content = await fs2.readFile(path4, "utf8");
7436
+ const content = await fs4.readFile(path4, "utf8");
7326
7437
  const lines = content.split(/\n/g);
7327
7438
  obj[num.toString()] = lines.slice(1, -1).join("\n");
7328
7439
  }));
@@ -7335,7 +7446,7 @@ async function writeDrawings(options, drawing) {
7335
7446
  const width = options.data.config.canvasWidth;
7336
7447
  const height = Math.round(width / options.data.config.aspectRatio);
7337
7448
  const SVG_HEAD = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
7338
- await fs2.ensureDir(dir);
7449
+ await fs4.ensureDir(dir);
7339
7450
  return Promise.all(
7340
7451
  Object.entries(drawing).map(async ([key, value]) => {
7341
7452
  if (!value)
@@ -7343,34 +7454,25 @@ async function writeDrawings(options, drawing) {
7343
7454
  const svg = `${SVG_HEAD}
7344
7455
  ${value}
7345
7456
  </svg>`;
7346
- await fs2.writeFile(join2(dir, `${key}.svg`), svg, "utf-8");
7457
+ await fs4.writeFile(join3(dir, `${key}.svg`), svg, "utf-8");
7347
7458
  })
7348
7459
  );
7349
7460
  }
7350
7461
 
7351
7462
  // node/vite/extendConfig.ts
7352
- import { join as join3 } from "node:path";
7463
+ import { join as join4 } from "node:path";
7353
7464
  import { fileURLToPath, pathToFileURL } from "node:url";
7354
7465
  import { mergeConfig as mergeConfig2 } from "vite";
7355
- import { slash as slash2, uniq } from "@antfu/utils";
7466
+ import { slash as slash2, uniq as uniq2 } from "@antfu/utils";
7356
7467
  import { createResolve } from "mlly";
7357
7468
  var INCLUDE_GLOBAL = [
7358
- "@shikijs/monaco",
7359
- "@shikijs/vitepress-twoslash/client",
7360
- "@slidev/rough-notation",
7361
7469
  "@typescript/ata",
7362
- "@unhead/vue",
7363
- "drauu",
7364
7470
  "file-saver",
7365
- "floating-vue",
7366
- "fuse.js",
7367
7471
  "lz-string",
7368
7472
  "prettier",
7369
7473
  "recordrtc",
7370
7474
  "typescript",
7371
- "vue-router",
7372
- "yaml",
7373
- "shiki-magic-move/vue"
7475
+ "yaml"
7374
7476
  ];
7375
7477
  var INCLUDE_LOCAL = [
7376
7478
  ...INCLUDE_GLOBAL,
@@ -7380,45 +7482,39 @@ var INCLUDE_LOCAL = [
7380
7482
  "codemirror/mode/markdown/markdown",
7381
7483
  "codemirror/mode/xml/xml",
7382
7484
  "codemirror/mode/htmlmixed/htmlmixed",
7383
- "codemirror/addon/display/placeholder",
7384
- "monaco-editor",
7385
- "monaco-editor/esm/vs/platform/contextview/browser/contextViewService",
7386
- "monaco-editor/esm/vs/platform/instantiation/common/descriptors",
7387
- "monaco-editor/esm/vs/editor/standalone/browser/standaloneServices"
7485
+ "codemirror/addon/display/placeholder"
7388
7486
  ].map((i) => `@slidev/cli > @slidev/client > ${i}`);
7389
7487
  var EXCLUDE_GLOBAL = [
7390
- "@slidev/types",
7488
+ "@antfu/utils",
7489
+ "@shikijs/monaco",
7490
+ "@shikijs/vitepress-twoslash/client",
7391
7491
  "@slidev/client",
7392
7492
  "@slidev/client/constants",
7493
+ "@slidev/client/context",
7393
7494
  "@slidev/client/logic/dark",
7394
- "@antfu/utils",
7495
+ "@slidev/parser",
7496
+ "@slidev/parser/core",
7497
+ "@slidev/rough-notation",
7498
+ "@slidev/types",
7499
+ "@unhead/vue",
7500
+ "@unocss/reset",
7395
7501
  "@vueuse/core",
7396
7502
  "@vueuse/math",
7397
- "@vueuse/shared",
7398
7503
  "@vueuse/motion",
7399
- "@unocss/reset",
7504
+ "@vueuse/shared",
7505
+ "drauu",
7506
+ "floating-vue",
7507
+ "fuse.js",
7400
7508
  "mermaid",
7509
+ "monaco-editor",
7510
+ "shiki-magic-move/vue",
7511
+ "shiki",
7512
+ "shiki/core",
7401
7513
  "vue-demi",
7514
+ "vue-router",
7402
7515
  "vue"
7403
7516
  ];
7404
- var EXCLUDE_LOCAL = [
7405
- ...EXCLUDE_GLOBAL,
7406
- ...[
7407
- "@slidev/client",
7408
- "@slidev/client/constants",
7409
- "@slidev/client/logic/dark",
7410
- "@slidev/client > @antfu/utils",
7411
- "@slidev/client > @slidev/types",
7412
- "@slidev/client > @vueuse/core",
7413
- "@slidev/client > @vueuse/math",
7414
- "@slidev/client > @vueuse/shared",
7415
- "@slidev/client > @vueuse/motion",
7416
- "@slidev/client > @unocss/reset",
7417
- "@slidev/client > mermaid",
7418
- "@slidev/client > vue-demi",
7419
- "@slidev/client > vue"
7420
- ].map((i) => `@slidev/cli > ${i}`)
7421
- ];
7517
+ var EXCLUDE_LOCAL = EXCLUDE_GLOBAL;
7422
7518
  var ASYNC_MODULES = [
7423
7519
  "file-saver",
7424
7520
  "vue",
@@ -7478,7 +7574,7 @@ function createConfigPlugin(options) {
7478
7574
  server: {
7479
7575
  fs: {
7480
7576
  strict: true,
7481
- allow: uniq([
7577
+ allow: uniq2([
7482
7578
  options.userWorkspaceRoot,
7483
7579
  options.clientRoot,
7484
7580
  // Special case for PNPM global installation
@@ -7487,7 +7583,7 @@ function createConfigPlugin(options) {
7487
7583
  ])
7488
7584
  }
7489
7585
  },
7490
- publicDir: join3(options.userRoot, "public"),
7586
+ publicDir: join4(options.userRoot, "public"),
7491
7587
  build: {
7492
7588
  rollupOptions: {
7493
7589
  output: {
@@ -7520,7 +7616,7 @@ function createConfigPlugin(options) {
7520
7616
  return id.includes("/@slidev/") || id.includes("/slidev/packages/client/") || id.includes("/@vueuse/");
7521
7617
  }
7522
7618
  if (isInstalledGlobally.value) {
7523
- injection.cacheDir = join3(options.cliRoot, "node_modules/.vite");
7619
+ injection.cacheDir = join4(options.cliRoot, "node_modules/.vite");
7524
7620
  injection.root = options.cliRoot;
7525
7621
  }
7526
7622
  return mergeConfig2(injection, config);
@@ -7560,7 +7656,7 @@ import path from "node:path";
7560
7656
  import { notNullish, range } from "@antfu/utils";
7561
7657
  import fg3 from "fast-glob";
7562
7658
  import { bold, gray, red, yellow } from "kolorist";
7563
- import * as parser from "@slidev/parser/fs";
7659
+ import * as parser2 from "@slidev/parser/fs";
7564
7660
  import equal from "fast-deep-equal";
7565
7661
 
7566
7662
  // node/virtual/configs.ts
@@ -7606,14 +7702,14 @@ console.warn('/@slidev/titles.md is deprecated, import from #slidev/title-render
7606
7702
 
7607
7703
  // node/virtual/global-layers.ts
7608
7704
  import { existsSync as existsSync2 } from "node:fs";
7609
- import { join as join4 } from "node:path";
7705
+ import { join as join5 } from "node:path";
7610
7706
  var templateGlobalLayers = {
7611
7707
  id: `/@slidev/global-layers`,
7612
7708
  getContent({ roots }) {
7613
7709
  const imports = [];
7614
7710
  let n = 0;
7615
7711
  function getComponent(names) {
7616
- const components = roots.flatMap((root) => names.map((name) => join4(root, name))).filter((i) => existsSync2(i));
7712
+ const components = roots.flatMap((root) => names.map((name) => join5(root, name))).filter((i) => existsSync2(i));
7617
7713
  imports.push(components.map((path4, i) => `import __n${n}_${i} from '${toAtFS(path4)}'`).join("\n"));
7618
7714
  const render = components.map((_, i) => `h(__n${n}_${i})`).join(",");
7619
7715
  n++;
@@ -7636,14 +7732,14 @@ var templateGlobalLayers = {
7636
7732
 
7637
7733
  // node/virtual/nav-controls.ts
7638
7734
  import { existsSync as existsSync3 } from "node:fs";
7639
- import { join as join5 } from "node:path";
7735
+ import { join as join6 } from "node:path";
7640
7736
  var templateNavControls = {
7641
7737
  id: "/@slidev/custom-nav-controls",
7642
7738
  getContent({ roots }) {
7643
7739
  const components = roots.flatMap((root) => {
7644
7740
  return [
7645
- join5(root, "custom-nav-controls.vue"),
7646
- join5(root, "CustomNavControls.vue")
7741
+ join6(root, "custom-nav-controls.vue"),
7742
+ join6(root, "CustomNavControls.vue")
7647
7743
  ];
7648
7744
  }).filter((i) => existsSync3(i));
7649
7745
  const imports = components.map((i, idx) => `import __n${idx} from '${toAtFS(i)}'`).join("\n");
@@ -7679,15 +7775,15 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
7679
7775
  };
7680
7776
 
7681
7777
  // node/virtual/monaco-deps.ts
7682
- import { resolve as resolve2 } from "node:path";
7683
- import { uniq as uniq2 } from "@antfu/utils";
7778
+ import { resolve as resolve3 } from "node:path";
7779
+ import { uniq as uniq3 } from "@antfu/utils";
7684
7780
  var templateMonacoRunDeps = {
7685
7781
  id: "/@slidev/monaco-run-deps",
7686
7782
  getContent: async ({ userRoot, data }, _ctx, pluginCtx) => {
7687
7783
  if (!data.features.monaco)
7688
7784
  return "";
7689
- const deps = uniq2(data.features.monaco.deps.concat(data.config.monacoTypesAdditionalPackages));
7690
- const importerPath = resolve2(userRoot, "./snippets/__importer__.ts");
7785
+ const deps = uniq3(data.features.monaco.deps.concat(data.config.monacoTypesAdditionalPackages));
7786
+ const importerPath = resolve3(userRoot, "./snippets/__importer__.ts");
7691
7787
  let result = "";
7692
7788
  for (let i = 0; i < deps.length; i++) {
7693
7789
  const specifier = deps[i];
@@ -7708,25 +7804,22 @@ var templateMonacoRunDeps = {
7708
7804
 
7709
7805
  // node/virtual/monaco-types.ts
7710
7806
  import { builtinModules } from "node:module";
7711
- import { join as join6, resolve as resolve3 } from "node:path";
7807
+ import { join as join7, resolve as resolve4 } from "node:path";
7712
7808
  import fg2 from "fast-glob";
7713
- import { uniq as uniq3 } from "@antfu/utils";
7809
+ import { uniq as uniq4 } from "@antfu/utils";
7714
7810
  var templateMonacoTypes = {
7715
7811
  id: "/@slidev/monaco-types",
7716
- getContent: async ({ userRoot, data }) => {
7812
+ getContent: async ({ userRoot, data, utils }) => {
7717
7813
  if (!data.features.monaco)
7718
7814
  return "";
7719
- const typesRoot = join6(userRoot, "snippets");
7815
+ const typesRoot = join7(userRoot, "snippets");
7720
7816
  const files = await fg2(["**/*.ts", "**/*.mts", "**/*.cts"], { cwd: typesRoot });
7721
7817
  let result = 'import { addFile } from "@slidev/client/setup/monaco.ts"\n';
7722
7818
  for (const file of files) {
7723
- const url = `${toAtFS(resolve3(typesRoot, file))}?monaco-types&raw`;
7724
- result += `addFile(import(${JSON.stringify(url)}), ${JSON.stringify(file)})
7819
+ const url = `${toAtFS(resolve4(typesRoot, file))}?monaco-types&raw`;
7820
+ result += `addFile(() => import(${JSON.stringify(url)}), ${JSON.stringify(file)})
7725
7821
  `;
7726
7822
  }
7727
- const deps = [...data.config.monacoTypesAdditionalPackages];
7728
- if (data.config.monacoTypesSource === "local")
7729
- deps.push(...data.features.monaco.types);
7730
7823
  function mapModuleNameToModule(moduleSpecifier) {
7731
7824
  if (moduleSpecifier.startsWith("node:"))
7732
7825
  return "node";
@@ -7739,11 +7832,17 @@ var templateMonacoTypes = {
7739
7832
  const moduleName = a.startsWith("@") ? `${a}/${b}` : a;
7740
7833
  return moduleName;
7741
7834
  }
7742
- for (const specifier of uniq3(deps)) {
7835
+ let deps = [...data.config.monacoTypesAdditionalPackages];
7836
+ if (data.config.monacoTypesSource === "local")
7837
+ deps.push(...data.features.monaco.types);
7838
+ deps = uniq4(deps.map((specifier) => {
7743
7839
  if (specifier[0] === ".")
7744
- continue;
7745
- const moduleName = mapModuleNameToModule(specifier);
7746
- result += `import(${JSON.stringify(`/@slidev-monaco-types/resolve?pkg=${moduleName}`)})
7840
+ return "";
7841
+ return mapModuleNameToModule(specifier);
7842
+ }).filter(Boolean));
7843
+ deps = deps.filter((pkg) => !utils.isMonacoTypesIgnored(pkg));
7844
+ for (const pkg of deps) {
7845
+ result += `import(${JSON.stringify(`/@slidev-monaco-types/resolve?${new URLSearchParams({ pkg })}`)})
7747
7846
  `;
7748
7847
  }
7749
7848
  return result;
@@ -7752,13 +7851,13 @@ var templateMonacoTypes = {
7752
7851
 
7753
7852
  // node/virtual/setups.ts
7754
7853
  import { existsSync as existsSync4 } from "node:fs";
7755
- import { join as join7 } from "node:path";
7854
+ import { join as join8 } from "node:path";
7756
7855
  function createSetupTemplate(name) {
7757
7856
  return {
7758
7857
  id: `/@slidev/setups/${name}`,
7759
7858
  getContent({ roots }) {
7760
7859
  const setups = roots.flatMap((i) => {
7761
- const path4 = join7(i, "setup", name);
7860
+ const path4 = join8(i, "setup", name);
7762
7861
  return [".ts", ".mts", ".js", ".mjs"].map((ext) => path4 + ext);
7763
7862
  }).filter((i) => existsSync4(i));
7764
7863
  const imports = [];
@@ -7774,7 +7873,7 @@ var setupModules = ["shiki", "code-runners", "monaco", "mermaid", "main", "root"
7774
7873
  var templateSetups = setupModules.map(createSetupTemplate);
7775
7874
 
7776
7875
  // node/setups/shiki.ts
7777
- import fs3 from "node:fs/promises";
7876
+ import fs5 from "node:fs/promises";
7778
7877
  async function loadShikiSetups(clientRoot, roots) {
7779
7878
  const result = await loadSetups(
7780
7879
  clientRoot,
@@ -7784,7 +7883,7 @@ async function loadShikiSetups(clientRoot, roots) {
7784
7883
  /** @deprecated */
7785
7884
  async loadTheme(path4) {
7786
7885
  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.");
7787
- return JSON.parse(await fs3.readFile(path4, "utf-8"));
7886
+ return JSON.parse(await fs5.readFile(path4, "utf-8"));
7788
7887
  }
7789
7888
  },
7790
7889
  {},
@@ -7815,10 +7914,10 @@ var templateShiki = {
7815
7914
  const langs = await resolveLangs(options.langs || ["javascript", "typescript", "html", "css"]);
7816
7915
  const resolvedThemeOptions = "themes" in options ? {
7817
7916
  themes: Object.fromEntries(await Promise.all(
7818
- Object.entries(options.themes).map(async ([name, value]) => [name, await resolveTheme(value)])
7917
+ Object.entries(options.themes).map(async ([name, value]) => [name, await resolveTheme2(value)])
7819
7918
  ))
7820
7919
  } : {
7821
- theme: await resolveTheme(options.theme || "vitesse-dark")
7920
+ theme: await resolveTheme2(options.theme || "vitesse-dark")
7822
7921
  };
7823
7922
  const themes = resolvedThemeOptions.themes ? Object.values(resolvedThemeOptions.themes) : [resolvedThemeOptions.theme];
7824
7923
  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 };
@@ -7830,7 +7929,7 @@ var templateShiki = {
7830
7929
  langs2.map(async (lang) => await normalizeGetter(lang).then((r) => Array.isArray(r) ? r : [r]))
7831
7930
  )).flat()));
7832
7931
  }
7833
- async function resolveTheme(theme) {
7932
+ async function resolveTheme2(theme) {
7834
7933
  return typeof theme === "string" ? theme : await normalizeGetter(theme);
7835
7934
  }
7836
7935
  const langsInit = await Promise.all(
@@ -7897,13 +7996,13 @@ ${slides.join(",\n")}
7897
7996
  };
7898
7997
 
7899
7998
  // node/virtual/styles.ts
7900
- import { join as join8 } from "node:path";
7999
+ import { join as join9 } from "node:path";
7901
8000
  import { existsSync as existsSync5 } from "node:fs";
7902
8001
  var templateStyle = {
7903
8002
  id: "/@slidev/styles",
7904
8003
  getContent: async ({ data, clientRoot, roots }) => {
7905
8004
  function resolveUrlOfClient(name) {
7906
- return toAtFS(join8(clientRoot, name));
8005
+ return toAtFS(join9(clientRoot, name));
7907
8006
  }
7908
8007
  const imports = [
7909
8008
  `import "${resolveUrlOfClient("styles/vars.css")}"`,
@@ -7914,11 +8013,11 @@ var templateStyle = {
7914
8013
  ];
7915
8014
  for (const root of roots) {
7916
8015
  const styles = [
7917
- join8(root, "styles", "index.ts"),
7918
- join8(root, "styles", "index.js"),
7919
- join8(root, "styles", "index.css"),
7920
- join8(root, "styles.css"),
7921
- join8(root, "style.css")
8016
+ join9(root, "styles", "index.ts"),
8017
+ join9(root, "styles", "index.js"),
8018
+ join9(root, "styles", "index.css"),
8019
+ join9(root, "styles.css"),
8020
+ join9(root, "style.css")
7922
8021
  ];
7923
8022
  for (const style of styles) {
7924
8023
  if (existsSync5(style)) {
@@ -8006,13 +8105,13 @@ var templateImportContextUtils = `import {
8006
8105
  } from "@slidev/client/context.ts"`.replace(/\n\s*/g, " ");
8007
8106
  var templateInitContext = `const { $slidev, $nav, $clicksContext, $clicks, $page, $renderContext, $frontmatter } = useSlideContext()`;
8008
8107
  function getBodyJson(req) {
8009
- return new Promise((resolve5, reject) => {
8108
+ return new Promise((resolve6, reject) => {
8010
8109
  let body = "";
8011
8110
  req.on("data", (chunk) => body += chunk);
8012
8111
  req.on("error", reject);
8013
8112
  req.on("end", () => {
8014
8113
  try {
8015
- resolve5(JSON.parse(body) || {});
8114
+ resolve6(JSON.parse(body) || {});
8016
8115
  } catch (e) {
8017
8116
  reject(e);
8018
8117
  }
@@ -8041,7 +8140,7 @@ function createSlidesLoader(options, pluginOptions, serverOptions) {
8041
8140
  let _layouts_cache_time = 0;
8042
8141
  let _layouts_cache = {};
8043
8142
  let skipHmr = null;
8044
- const { data, clientRoot, roots, mode } = options;
8143
+ const { data, clientRoot, roots, mode, utils } = options;
8045
8144
  const templateCtx = {
8046
8145
  md: sharedMd,
8047
8146
  async getLayouts() {
@@ -8094,8 +8193,8 @@ function createSlidesLoader(options, pluginOptions, serverOptions) {
8094
8193
  slide.note = slide.source.note = body.note;
8095
8194
  if (body.frontmatter)
8096
8195
  updateFrontmatterPatch(slide, body.frontmatter);
8097
- parser.prettifySlide(slide.source);
8098
- const fileContent = await parser.save(data.markdownFiles[slide.source.filepath]);
8196
+ parser2.prettifySlide(slide.source);
8197
+ const fileContent = await parser2.save(data.markdownFiles[slide.source.filepath]);
8099
8198
  if (body.skipHmr) {
8100
8199
  skipHmr = {
8101
8200
  filePath: slide.source.filepath,
@@ -8171,6 +8270,7 @@ function createSlidesLoader(options, pluginOptions, serverOptions) {
8171
8270
  hmrPages.add(i);
8172
8271
  }
8173
8272
  Object.assign(data, newData);
8273
+ Object.assign(utils, createDataUtils(newData));
8174
8274
  if (hmrPages.size > 0)
8175
8275
  moduleIds.add(templateTitleRendererMd.id);
8176
8276
  const vueModules = Array.from(hmrPages).flatMap((i) => {
@@ -8785,7 +8885,7 @@ function highlight(markdownit, options, text, lang) {
8785
8885
  }
8786
8886
  function highlightPrism(code, prismLang, langToUse) {
8787
8887
  const openTags = [];
8788
- const parser2 = new htmlparser2.Parser({
8888
+ const parser3 = new htmlparser2.Parser({
8789
8889
  onopentag(tagname, attributes) {
8790
8890
  openTags.push(new Tag(tagname, attributes));
8791
8891
  },
@@ -8796,11 +8896,11 @@ function highlightPrism(code, prismLang, langToUse) {
8796
8896
  code = Prism.highlight(code, prismLang, langToUse);
8797
8897
  code = code.split(/\r?\n/g).map((line) => {
8798
8898
  const prefix = openTags.map((tag) => tag.asOpen()).join("");
8799
- parser2.write(line);
8899
+ parser3.write(line);
8800
8900
  const postfix = openTags.reverse().map((tag) => tag.asClosed()).join("");
8801
8901
  return prefix + line + postfix;
8802
8902
  }).join("\n");
8803
- parser2.end();
8903
+ parser3.end();
8804
8904
  return code;
8805
8905
  }
8806
8906
  function checkLanguageOption(options, optionName) {
@@ -8949,11 +9049,11 @@ function transformPlantUml(ctx) {
8949
9049
  // node/syntax/transform/snippet.ts
8950
9050
  import path3 from "node:path";
8951
9051
  import lz3 from "lz-string";
8952
- import fs5 from "fs-extra";
9052
+ import fs7 from "fs-extra";
8953
9053
  import { slash as slash3 } from "@antfu/utils";
8954
9054
 
8955
9055
  // node/vite/monacoWrite.ts
8956
- import fs4 from "node:fs/promises";
9056
+ import fs6 from "node:fs/promises";
8957
9057
  import path2 from "node:path";
8958
9058
  var monacoWriterWhitelist = /* @__PURE__ */ new Set();
8959
9059
  function createMonacoWriter({ userRoot }) {
@@ -8977,7 +9077,7 @@ function createMonacoWriter({ userRoot }) {
8977
9077
  }
8978
9078
  const filepath = path2.join(userRoot, file);
8979
9079
  console.log("[Slidev] Writing file:", filepath);
8980
- await fs4.writeFile(filepath, content, "utf-8");
9080
+ await fs6.writeFile(filepath, content, "utf-8");
8981
9081
  }
8982
9082
  });
8983
9083
  });
@@ -9053,11 +9153,11 @@ function transformSnippet(ctx) {
9053
9153
  /^@\//.test(filepath) ? path3.resolve(options.userRoot, filepath.slice(2)) : path3.resolve(dir, filepath)
9054
9154
  );
9055
9155
  data.watchFiles.push(src);
9056
- const isAFile = fs5.statSync(src).isFile();
9057
- if (!fs5.existsSync(src) || !isAFile) {
9156
+ const isAFile = fs7.statSync(src).isFile();
9157
+ if (!fs7.existsSync(src) || !isAFile) {
9058
9158
  throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
9059
9159
  }
9060
- let content = fs5.readFileSync(src, "utf8");
9160
+ let content = fs7.readFileSync(src, "utf8");
9061
9161
  slideInfo.snippetsUsed ??= {};
9062
9162
  slideInfo.snippetsUsed[src] = content;
9063
9163
  if (regionName) {
@@ -9350,13 +9450,12 @@ function createVueCompilerFlagsPlugin(options) {
9350
9450
  }
9351
9451
 
9352
9452
  // node/vite/monacoTypes.ts
9353
- import fs6 from "node:fs/promises";
9354
- import { dirname as dirname2, resolve as resolve4 } from "node:path";
9453
+ import fs8 from "node:fs/promises";
9454
+ import { dirname as dirname2, resolve as resolve5 } from "node:path";
9355
9455
  import { slash as slash5 } from "@antfu/utils";
9356
9456
  import fg4 from "fast-glob";
9357
9457
  import { findDepPkgJsonPath } from "vitefu";
9358
- function createMonacoTypesLoader({ userRoot }) {
9359
- const resolvedDepsMap = {};
9458
+ function createMonacoTypesLoader({ userRoot, utils }) {
9360
9459
  return {
9361
9460
  name: "slidev:monaco-types-loader",
9362
9461
  resolveId(id) {
@@ -9365,27 +9464,29 @@ function createMonacoTypesLoader({ userRoot }) {
9365
9464
  return null;
9366
9465
  },
9367
9466
  async load(id) {
9368
- const matchResolve = id.match(/^\/@slidev-monaco-types\/resolve\?pkg=(.*?)(?:&importer=(.*))?$/);
9369
- if (matchResolve) {
9370
- const [_, pkg, importer = userRoot] = matchResolve;
9371
- const resolvedDeps = resolvedDepsMap[importer] ??= /* @__PURE__ */ new Set();
9372
- if (resolvedDeps.has(pkg))
9373
- return "";
9374
- resolvedDeps.add(pkg);
9467
+ if (!id.startsWith("/@slidev-monaco-types/"))
9468
+ return null;
9469
+ const url = new URL(id, "http://localhost");
9470
+ if (url.pathname === "/@slidev-monaco-types/resolve") {
9471
+ const query = new URLSearchParams(url.search);
9472
+ const pkg = query.get("pkg");
9473
+ const importer = query.get("importer") ?? userRoot;
9375
9474
  const pkgJsonPath = await findDepPkgJsonPath(pkg, importer);
9376
9475
  if (!pkgJsonPath)
9377
9476
  throw new Error(`Package "${pkg}" not found in "${importer}"`);
9378
- const root = dirname2(pkgJsonPath);
9379
- const pkgJson = JSON.parse(await fs6.readFile(pkgJsonPath, "utf-8"));
9380
- const deps = pkgJson.dependencies ?? {};
9477
+ const root = slash5(dirname2(pkgJsonPath));
9478
+ const pkgJson = JSON.parse(await fs8.readFile(pkgJsonPath, "utf-8"));
9479
+ let deps = Object.keys(pkgJson.dependencies ?? {});
9480
+ deps = deps.filter((pkg2) => !utils.isMonacoTypesIgnored(pkg2));
9381
9481
  return [
9382
- `import "/@slidev-monaco-types/load?root=${slash5(root)}&name=${pkgJson.name}"`,
9383
- ...Object.keys(deps).map((dep) => `import "/@slidev-monaco-types/resolve?pkg=${dep}&importer=${slash5(root)}"`)
9482
+ `import "/@slidev-monaco-types/load?${new URLSearchParams({ root, name: pkgJson.name })}"`,
9483
+ ...deps.map((dep) => `import "/@slidev-monaco-types/resolve?${new URLSearchParams({ pkg: dep, importer: root })}"`)
9384
9484
  ].join("\n");
9385
9485
  }
9386
- const matchLoad = id.match(/^\/@slidev-monaco-types\/load\?root=(.*?)&name=(.*)$/);
9387
- if (matchLoad) {
9388
- const [_, root, name] = matchLoad;
9486
+ if (url.pathname === "/@slidev-monaco-types/load") {
9487
+ const query = new URLSearchParams(url.search);
9488
+ const root = query.get("root");
9489
+ const name = query.get("name");
9389
9490
  const files = await fg4(
9390
9491
  [
9391
9492
  "**/*.ts",
@@ -9400,10 +9501,10 @@ function createMonacoTypesLoader({ userRoot }) {
9400
9501
  }
9401
9502
  );
9402
9503
  if (!files.length)
9403
- return "";
9504
+ return "/** No files found **/";
9404
9505
  return [
9405
9506
  'import { addFile } from "@slidev/client/setup/monaco.ts"',
9406
- ...files.map((file) => `addFile(import(${JSON.stringify(`${toAtFS(resolve4(root, file))}?monaco-types&raw`)}), ${JSON.stringify(`node_modules/${name}/${file}`)})`)
9507
+ ...files.map((file) => `addFile(() => import(${JSON.stringify(`${toAtFS(resolve5(root, file))}?monaco-types&raw`)}), ${JSON.stringify(`node_modules/${name}/${file}`)})`)
9407
9508
  ].join("\n");
9408
9509
  }
9409
9510
  }
@@ -9484,7 +9585,7 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
9484
9585
  data: { config }
9485
9586
  } = options;
9486
9587
  const drawingData = await loadDrawings(options);
9487
- const publicRoots = [...themeRoots, ...addonRoots].map((i) => join9(i, "public")).filter(existsSync6);
9588
+ const publicRoots = [...themeRoots, ...addonRoots].map((i) => join10(i, "public")).filter(existsSync6);
9488
9589
  const plugins = [
9489
9590
  createMarkdownPlugin(options, pluginOptions),
9490
9591
  createVuePlugin(options, pluginOptions),
@@ -9493,11 +9594,11 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
9493
9594
  Components({
9494
9595
  extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
9495
9596
  dirs: [
9496
- join9(options.clientRoot, "builtin"),
9497
- ...roots.map((i) => join9(i, "components")),
9597
+ join10(options.clientRoot, "builtin"),
9598
+ ...roots.map((i) => join10(i, "components")),
9498
9599
  "src/components",
9499
9600
  "components",
9500
- join9(process2.cwd(), "components")
9601
+ join10(process2.cwd(), "components")
9501
9602
  ],
9502
9603
  include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
9503
9604
  exclude: [],
@@ -9570,5 +9671,11 @@ export {
9570
9671
  version,
9571
9672
  getIndexHtml,
9572
9673
  mergeViteConfigs,
9674
+ parser,
9675
+ resolveTheme,
9676
+ getThemeMeta,
9677
+ resolveAddons,
9678
+ resolveOptions,
9679
+ createDataUtils,
9573
9680
  ViteSlidevPlugin
9574
9681
  };
package/dist/cli.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
- createServer,
2
+ createServer
3
+ } from "./chunk-DRWYFCYG.mjs";
4
+ import {
3
5
  getThemeMeta,
4
6
  parser,
5
7
  resolveAddons,
6
8
  resolveOptions,
7
- resolveTheme
8
- } from "./chunk-GVANDJX7.mjs";
9
- import {
9
+ resolveTheme,
10
10
  version
11
- } from "./chunk-USRVNGYC.mjs";
11
+ } from "./chunk-ZATTXN6U.mjs";
12
12
  import {
13
13
  loadSetups
14
14
  } from "./chunk-LOUKLO2C.mjs";
@@ -328,7 +328,7 @@ cli.command(
328
328
  }).strict().help(),
329
329
  async (args) => {
330
330
  const { entry, theme, base, download, out, inspect } = args;
331
- const { build } = await import("./build-KCQ3YTFV.mjs");
331
+ const { build } = await import("./build-HVOMXVYS.mjs");
332
332
  for (const entryFile of entry) {
333
333
  const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
334
334
  if (download && !options.data.config.download)
@@ -408,7 +408,7 @@ cli.command(
408
408
  (args) => exportOptions(commonOptions(args)).strict().help(),
409
409
  async (args) => {
410
410
  const { entry, theme } = args;
411
- const { exportSlides, getExportOptions } = await import("./export-Q4LURPEZ.mjs");
411
+ const { exportSlides, getExportOptions } = await import("./export-BSOHDR2A.mjs");
412
412
  const port = await getPort(12445);
413
413
  for (const entryFile of entry) {
414
414
  const options = await resolveOptions({ entry: entryFile, theme }, "export");
@@ -457,7 +457,7 @@ cli.command(
457
457
  timeout,
458
458
  wait
459
459
  }) => {
460
- const { exportNotes } = await import("./export-Q4LURPEZ.mjs");
460
+ const { exportNotes } = await import("./export-BSOHDR2A.mjs");
461
461
  const port = await getPort(12445);
462
462
  for (const entryFile of entry) {
463
463
  const options = await resolveOptions({ entry: entryFile }, "export");
@@ -18,13 +18,14 @@ import { PDFDocument } from "pdf-lib";
18
18
  import { resolve } from "mlly";
19
19
  function addToTree(tree, info, slideIndexes, level = 1) {
20
20
  const titleLevel = info.level;
21
- if (titleLevel && titleLevel > level && tree.length > 0) {
21
+ if (titleLevel && titleLevel > level && tree.length > 0 && tree[tree.length - 1].titleLevel < titleLevel) {
22
22
  addToTree(tree[tree.length - 1].children, info, slideIndexes, level + 1);
23
23
  } else {
24
24
  tree.push({
25
25
  no: info.index,
26
26
  children: [],
27
27
  level,
28
+ titleLevel: titleLevel ?? level,
28
29
  path: String(slideIndexes[info.index + 1]),
29
30
  hideInToc: Boolean(info.frontmatter?.hideInToc),
30
31
  title: info.title
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
2
  import { Plugin, InlineConfig } from 'vite';
3
- import { ResolvedSlidevOptions, SlidevPluginOptions, SlidevServerOptions, SlidevEntryOptions } from '@slidev/types';
3
+ import { ResolvedSlidevOptions, SlidevPluginOptions, SlidevServerOptions, SlidevEntryOptions, SlidevData, ResolvedSlidevUtils } from '@slidev/types';
4
4
  import * as fs from '@slidev/parser/fs';
5
5
  export { fs as parser };
6
6
 
@@ -9,5 +9,6 @@ declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions:
9
9
  declare function createServer(options: ResolvedSlidevOptions, viteConfig?: InlineConfig, serverOptions?: SlidevServerOptions): Promise<vite.ViteDevServer>;
10
10
 
11
11
  declare function resolveOptions(options: SlidevEntryOptions, mode: ResolvedSlidevOptions['mode']): Promise<ResolvedSlidevOptions>;
12
+ declare function createDataUtils(data: SlidevData): ResolvedSlidevUtils;
12
13
 
13
- export { ViteSlidevPlugin, createServer, resolveOptions };
14
+ export { ViteSlidevPlugin, createDataUtils, createServer, resolveOptions };
package/dist/index.mjs CHANGED
@@ -1,16 +1,18 @@
1
1
  import {
2
- createServer,
2
+ createServer
3
+ } from "./chunk-DRWYFCYG.mjs";
4
+ import {
5
+ ViteSlidevPlugin,
6
+ createDataUtils,
3
7
  parser,
4
8
  resolveOptions
5
- } from "./chunk-GVANDJX7.mjs";
6
- import {
7
- ViteSlidevPlugin
8
- } from "./chunk-USRVNGYC.mjs";
9
+ } from "./chunk-ZATTXN6U.mjs";
9
10
  import "./chunk-LOUKLO2C.mjs";
10
11
  import "./chunk-RG2EEPCO.mjs";
11
12
  import "./chunk-BXO7ZPPU.mjs";
12
13
  export {
13
14
  ViteSlidevPlugin,
15
+ createDataUtils,
14
16
  createServer,
15
17
  parser,
16
18
  resolveOptions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
- "version": "0.49.7",
3
+ "version": "0.49.9",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -51,15 +51,15 @@
51
51
  "@shikijs/markdown-it": "^1.6.1",
52
52
  "@shikijs/twoslash": "^1.6.1",
53
53
  "@shikijs/vitepress-twoslash": "^1.6.1",
54
- "@unocss/extractor-mdc": "^0.60.3",
55
- "@unocss/reset": "^0.60.3",
56
- "@vitejs/plugin-vue": "^5.0.4",
54
+ "@unocss/extractor-mdc": "^0.60.4",
55
+ "@unocss/reset": "^0.60.4",
56
+ "@vitejs/plugin-vue": "^5.0.5",
57
57
  "@vitejs/plugin-vue-jsx": "^3.1.0",
58
58
  "chokidar": "^3.6.0",
59
59
  "cli-progress": "^3.12.0",
60
60
  "codemirror": "^5.65.16",
61
61
  "connect": "^3.7.0",
62
- "debug": "^4.3.4",
62
+ "debug": "^4.3.5",
63
63
  "fast-deep-equal": "^3.1.3",
64
64
  "fast-glob": "^3.3.2",
65
65
  "fs-extra": "^11.2.0",
@@ -76,7 +76,8 @@
76
76
  "magic-string-stack": "^0.1.1",
77
77
  "markdown-it": "^14.1.0",
78
78
  "markdown-it-footnote": "^4.0.0",
79
- "markdown-it-mdc": "^0.2.3",
79
+ "markdown-it-mdc": "^0.2.5",
80
+ "micromatch": "^4.0.7",
80
81
  "mlly": "^1.7.0",
81
82
  "monaco-editor": "^0.49.0",
82
83
  "open": "^10.1.0",
@@ -95,7 +96,7 @@
95
96
  "sirv": "^2.0.4",
96
97
  "source-map-js": "^1.2.0",
97
98
  "typescript": "^5.4.5",
98
- "unocss": "^0.60.3",
99
+ "unocss": "^0.60.4",
99
100
  "unplugin-icons": "^0.19.0",
100
101
  "unplugin-vue-components": "^0.27.0",
101
102
  "unplugin-vue-markdown": "^0.26.2",
@@ -109,12 +110,13 @@
109
110
  "vitefu": "^0.2.5",
110
111
  "vue": "^3.4.27",
111
112
  "yargs": "^17.7.2",
112
- "@slidev/client": "0.49.7",
113
- "@slidev/parser": "0.49.7",
114
- "@slidev/types": "0.49.7"
113
+ "@slidev/types": "0.49.9",
114
+ "@slidev/parser": "0.49.9",
115
+ "@slidev/client": "0.49.9"
115
116
  },
116
117
  "devDependencies": {
117
118
  "@hedgedoc/markdown-it-plugins": "^2.1.4",
119
+ "@types/micromatch": "^4.0.7",
118
120
  "@types/plantuml-encoder": "^1.4.2"
119
121
  },
120
122
  "scripts": {
@@ -1,153 +0,0 @@
1
- import {
2
- ViteSlidevPlugin,
3
- mergeViteConfigs,
4
- version
5
- } from "./chunk-USRVNGYC.mjs";
6
- import {
7
- createResolver,
8
- getRoots,
9
- resolveEntry
10
- } from "./chunk-RG2EEPCO.mjs";
11
-
12
- // node/commands/server.ts
13
- import { join } from "node:path";
14
- import process from "node:process";
15
- import { createServer as createViteServer, mergeConfig } from "vite";
16
- async function createServer(options, viteConfig = {}, serverOptions = {}) {
17
- process.env.EDITOR = process.env.EDITOR || "code";
18
- const config = await mergeViteConfigs(
19
- options,
20
- viteConfig,
21
- {
22
- root: options.userRoot,
23
- optimizeDeps: {
24
- entries: [
25
- join(options.clientRoot, "main.ts")
26
- ]
27
- }
28
- },
29
- "serve"
30
- );
31
- const server = await createViteServer(
32
- mergeConfig(
33
- config,
34
- {
35
- plugins: [
36
- await ViteSlidevPlugin(options, config.slidev || {}, serverOptions)
37
- ],
38
- define: {
39
- // Fixes Vue production mode breaking PDF Export #1245
40
- __VUE_PROD_DEVTOOLS__: JSON.stringify(true)
41
- }
42
- }
43
- )
44
- );
45
- return server;
46
- }
47
-
48
- // node/parser.ts
49
- import * as parser from "@slidev/parser/fs";
50
-
51
- // node/integrations/themes.ts
52
- import { join as join2 } from "node:path";
53
- import fs from "fs-extra";
54
- import { satisfies } from "semver";
55
- var officialThemes = {
56
- "none": "",
57
- "default": "@slidev/theme-default",
58
- "seriph": "@slidev/theme-seriph",
59
- "apple-basic": "@slidev/theme-apple-basic",
60
- "shibainu": "@slidev/theme-shibainu",
61
- "bricks": "@slidev/theme-bricks"
62
- };
63
- var resolveTheme = createResolver("theme", officialThemes);
64
- async function getThemeMeta(name, root) {
65
- const path = join2(root, "package.json");
66
- if (!fs.existsSync(path))
67
- return {};
68
- const { slidev = {}, engines = {} } = await fs.readJSON(path);
69
- if (engines.slidev && !satisfies(version, engines.slidev, { includePrerelease: true }))
70
- throw new Error(`[slidev] theme "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
71
- return slidev;
72
- }
73
-
74
- // node/integrations/addons.ts
75
- import { resolve } from "node:path";
76
- import fs2 from "fs-extra";
77
- import { satisfies as satisfies2 } from "semver";
78
- async function resolveAddons(addonsInConfig) {
79
- const { userRoot, userPkgJson } = await getRoots();
80
- const resolved = [];
81
- const resolveAddonNameAndRoot = createResolver("addon", {});
82
- async function resolveAddon(name, parent) {
83
- const [, pkgRoot] = await resolveAddonNameAndRoot(name, parent);
84
- if (!pkgRoot)
85
- return;
86
- resolved.push(pkgRoot);
87
- const { slidev = {}, engines = {} } = await fs2.readJSON(resolve(pkgRoot, "package.json"));
88
- if (engines.slidev && !satisfies2(version, engines.slidev, { includePrerelease: true }))
89
- throw new Error(`[slidev] addon "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
90
- if (Array.isArray(slidev.addons))
91
- await Promise.all(slidev.addons.map((addon) => resolveAddon(addon, pkgRoot)));
92
- }
93
- if (Array.isArray(addonsInConfig))
94
- await Promise.all(addonsInConfig.map((addon) => resolveAddon(addon, userRoot)));
95
- if (Array.isArray(userPkgJson.slidev?.addons))
96
- await Promise.all(userPkgJson.slidev.addons.map((addon) => resolveAddon(addon, userRoot)));
97
- return resolved;
98
- }
99
-
100
- // node/options.ts
101
- import { uniq } from "@antfu/utils";
102
- import Debug from "debug";
103
- var debug = Debug("slidev:options");
104
- async function resolveOptions(options, mode) {
105
- const entry = await resolveEntry(options.entry);
106
- const rootsInfo = await getRoots(entry);
107
- const loaded = await parser.load(rootsInfo.userRoot, entry, void 0, mode);
108
- let themeRaw = options.theme || loaded.headmatter.theme;
109
- themeRaw = themeRaw === null ? "none" : themeRaw || "default";
110
- const [theme, themeRoot] = await resolveTheme(themeRaw, entry);
111
- const themeRoots = themeRoot ? [themeRoot] : [];
112
- const themeMeta = themeRoot ? await getThemeMeta(theme, themeRoot) : void 0;
113
- const config = parser.resolveConfig(loaded.headmatter, themeMeta, options.entry);
114
- const addonRoots = await resolveAddons(config.addons);
115
- const roots = uniq([...themeRoots, ...addonRoots, rootsInfo.userRoot]);
116
- debug({
117
- ...rootsInfo,
118
- ...options,
119
- config,
120
- mode,
121
- entry,
122
- themeRaw,
123
- theme,
124
- themeRoots,
125
- addonRoots,
126
- roots
127
- });
128
- return {
129
- ...rootsInfo,
130
- ...options,
131
- data: {
132
- ...loaded,
133
- config,
134
- themeMeta
135
- },
136
- mode,
137
- entry,
138
- themeRaw,
139
- theme,
140
- themeRoots,
141
- addonRoots,
142
- roots
143
- };
144
- }
145
-
146
- export {
147
- createServer,
148
- parser,
149
- resolveTheme,
150
- getThemeMeta,
151
- resolveAddons,
152
- resolveOptions
153
- };