@slidev/cli 0.49.22 → 0.49.23

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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getIndexHtml,
3
3
  resolveViteConfigs
4
- } from "./chunk-S7ZSXMXK.js";
4
+ } from "./chunk-XYLYAM2E.js";
5
5
  import "./chunk-6DS3IPOB.js";
6
- import "./chunk-2BABGNMX.js";
6
+ import "./chunk-HOVIRHCR.js";
7
7
  import "./chunk-JSBRDJBE.js";
8
8
 
9
9
  // node/commands/build.ts
@@ -53,7 +53,7 @@ async function build(options, viteConfig = {}, args) {
53
53
  await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
54
54
  `, "utf-8");
55
55
  if ([true, "true", "auto"].includes(options.data.config.download)) {
56
- const { exportSlides, getExportOptions } = await import("./export-TPYQNCSS.js");
56
+ const { exportSlides, getExportOptions } = await import("./export-F3V7NX5E.js");
57
57
  const port = 12445;
58
58
  const app = connect();
59
59
  const server = http.createServer(app);
@@ -92,9 +92,9 @@ function createResolver(type, officials) {
92
92
  if (name[0] === "/")
93
93
  return [name, name];
94
94
  if (name.startsWith("@/"))
95
- return [name, join(userRoot, name.slice(2))];
95
+ return [name, resolve(userRoot, name.slice(2))];
96
96
  if (name[0] === "." || name[0] !== "@" && name.includes("/"))
97
- return [name, join(dirname(importer), name)];
97
+ return [name, resolve(dirname(importer), name)];
98
98
  if (name.startsWith(`@slidev/${type}-`) || name.startsWith(`slidev-${type}-`)) {
99
99
  const pkgRoot = await findPkgRoot(name, importer);
100
100
  if (!pkgRoot)
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveViteConfigs
3
- } from "./chunk-S7ZSXMXK.js";
3
+ } from "./chunk-XYLYAM2E.js";
4
4
 
5
5
  // node/commands/serve.ts
6
6
  import { join } from "node:path";
@@ -11,7 +11,7 @@ import {
11
11
  resolveImportPath,
12
12
  resolveImportUrl,
13
13
  toAtFS
14
- } from "./chunk-2BABGNMX.js";
14
+ } from "./chunk-HOVIRHCR.js";
15
15
  import {
16
16
  __commonJS,
17
17
  __toESM
@@ -7183,7 +7183,7 @@ var require_dist = __commonJS({
7183
7183
  });
7184
7184
 
7185
7185
  // package.json
7186
- var version = "0.49.22";
7186
+ var version = "0.49.23";
7187
7187
 
7188
7188
  // node/commands/shared.ts
7189
7189
  import { existsSync as existsSync7, promises as fs9 } from "node:fs";
@@ -8174,7 +8174,12 @@ async function loadSetups(roots, filename, args, extraLoader) {
8174
8174
  }
8175
8175
 
8176
8176
  // node/setups/shiki.ts
8177
+ var cachedRoots;
8178
+ var cachedShiki;
8177
8179
  async function setupShiki(roots) {
8180
+ if (cachedRoots === roots)
8181
+ return cachedShiki;
8182
+ cachedShiki?.shiki.dispose();
8178
8183
  const options = await loadSetups(
8179
8184
  roots,
8180
8185
  "shiki.ts",
@@ -8206,7 +8211,8 @@ async function setupShiki(roots) {
8206
8211
  langs: mergedOptions.langs ?? Object.keys(bundledLanguages),
8207
8212
  themes: "themes" in mergedOptions ? Object.values(mergedOptions.themes) : [mergedOptions.theme]
8208
8213
  });
8209
- return {
8214
+ cachedRoots = roots;
8215
+ return cachedShiki = {
8210
8216
  shiki,
8211
8217
  shikiOptions: mergedOptions
8212
8218
  };
@@ -8306,7 +8312,7 @@ function withRenderedNote(data) {
8306
8312
  };
8307
8313
  }
8308
8314
  function createSlidesLoader(options, serverOptions) {
8309
- const hmrPages = /* @__PURE__ */ new Set();
8315
+ const hmrSlidesIndexes = /* @__PURE__ */ new Set();
8310
8316
  let server;
8311
8317
  let skipHmr = null;
8312
8318
  const { data, clientRoot, roots, mode, utils } = options;
@@ -8316,7 +8322,7 @@ function createSlidesLoader(options, serverOptions) {
8316
8322
  function updateServerWatcher() {
8317
8323
  if (!server)
8318
8324
  return;
8319
- server.watcher.add(data.watchFiles);
8325
+ server.watcher.add(Object.keys(data.watchFiles));
8320
8326
  }
8321
8327
  function getFrontmatter(pageNo) {
8322
8328
  return {
@@ -8343,7 +8349,7 @@ function createSlidesLoader(options, serverOptions) {
8343
8349
  const body = await getBodyJson(req);
8344
8350
  const slide = data.slides[idx];
8345
8351
  if (body.content && body.content !== slide.source.content)
8346
- hmrPages.add(idx);
8352
+ hmrSlidesIndexes.add(idx);
8347
8353
  if (body.content)
8348
8354
  slide.content = slide.source.content = body.content;
8349
8355
  if (body.note)
@@ -8374,8 +8380,12 @@ function createSlidesLoader(options, serverOptions) {
8374
8380
  });
8375
8381
  },
8376
8382
  async handleHotUpdate(ctx) {
8377
- if (!data.watchFiles.includes(ctx.file))
8383
+ const forceChangedSlides = data.watchFiles[ctx.file];
8384
+ if (!forceChangedSlides)
8378
8385
  return;
8386
+ for (const index of forceChangedSlides) {
8387
+ hmrSlidesIndexes.add(index);
8388
+ }
8379
8389
  const newData = await serverOptions.loadData?.({
8380
8390
  [ctx.file]: await ctx.read()
8381
8391
  });
@@ -8388,11 +8398,11 @@ function createSlidesLoader(options, serverOptions) {
8388
8398
  const moduleIds = /* @__PURE__ */ new Set();
8389
8399
  if (data.slides.length !== newData.slides.length) {
8390
8400
  moduleIds.add(templateSlides.id);
8391
- range(newData.slides.length).map((i) => hmrPages.add(i));
8401
+ range(newData.slides.length).map((i) => hmrSlidesIndexes.add(i));
8392
8402
  }
8393
8403
  if (!equal(data.headmatter.defaults, newData.headmatter.defaults)) {
8394
8404
  moduleIds.add(templateSlides.id);
8395
- range(data.slides.length).map((i) => hmrPages.add(i));
8405
+ range(data.slides.length).map((i) => hmrSlidesIndexes.add(i));
8396
8406
  }
8397
8407
  if (!equal(data.config, newData.config))
8398
8408
  moduleIds.add(templateConfigs.id);
@@ -8405,7 +8415,7 @@ function createSlidesLoader(options, serverOptions) {
8405
8415
  for (let i = 0; i < length; i++) {
8406
8416
  const a = data.slides[i];
8407
8417
  const b = newData.slides[i];
8408
- if (!hmrPages.has(i) && a.content.trim() === b.content.trim() && a.title?.trim() === b.title?.trim() && equal(a.frontmatter, b.frontmatter)) {
8418
+ if (!hmrSlidesIndexes.has(i) && a.content.trim() === b.content.trim() && a.title?.trim() === b.title?.trim() && equal(a.frontmatter, b.frontmatter)) {
8409
8419
  if (a.note !== b.note) {
8410
8420
  ctx.server.hot.send(
8411
8421
  "slidev:update-note",
@@ -8425,13 +8435,13 @@ function createSlidesLoader(options, serverOptions) {
8425
8435
  data: withRenderedNote(newData.slides[i])
8426
8436
  }
8427
8437
  );
8428
- hmrPages.add(i);
8438
+ hmrSlidesIndexes.add(i);
8429
8439
  }
8430
8440
  Object.assign(data, newData);
8431
8441
  Object.assign(utils, createDataUtils(newData, clientRoot, roots));
8432
- if (hmrPages.size > 0)
8442
+ if (hmrSlidesIndexes.size > 0)
8433
8443
  moduleIds.add(templateTitleRendererMd.id);
8434
- const vueModules = Array.from(hmrPages).flatMap((idx) => {
8444
+ const vueModules = Array.from(hmrSlidesIndexes).flatMap((idx) => {
8435
8445
  const frontmatter = ctx.server.moduleGraph.getModuleById(getSourceId(idx, "frontmatter"));
8436
8446
  const main = ctx.server.moduleGraph.getModuleById(getSourceId(idx, "md"));
8437
8447
  const styles = main ? [...main.clientImportedModules].find((m) => m.id?.includes(`&type=style`)) : void 0;
@@ -8441,7 +8451,7 @@ function createSlidesLoader(options, serverOptions) {
8441
8451
  styles
8442
8452
  ];
8443
8453
  });
8444
- hmrPages.clear();
8454
+ hmrSlidesIndexes.clear();
8445
8455
  const moduleEntries = [
8446
8456
  ...ctx.modules.filter((i) => i.id === templateMonacoRunDeps.id || i.id === templateMonacoTypes.id),
8447
8457
  ...vueModules,
@@ -8847,7 +8857,7 @@ function findRegion(lines, regionName) {
8847
8857
  return null;
8848
8858
  }
8849
8859
  function transformSnippet({ s, slide, options }) {
8850
- const data = options.data;
8860
+ const watchFiles = options.data.watchFiles;
8851
8861
  const dir = path3.dirname(slide.source?.filepath ?? options.entry ?? options.userRoot);
8852
8862
  s.replace(
8853
8863
  // eslint-disable-next-line regexp/no-super-linear-backtracking
@@ -8856,14 +8866,13 @@ function transformSnippet({ s, slide, options }) {
8856
8866
  const src = slash2(
8857
8867
  /^@\//.test(filepath) ? path3.resolve(options.userRoot, filepath.slice(2)) : path3.resolve(dir, filepath)
8858
8868
  );
8859
- data.watchFiles.push(src);
8869
+ watchFiles[src] ??= /* @__PURE__ */ new Set();
8870
+ watchFiles[src].add(slide.index);
8860
8871
  const isAFile = fs6.statSync(src).isFile();
8861
8872
  if (!fs6.existsSync(src) || !isAFile) {
8862
8873
  throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
8863
8874
  }
8864
8875
  let content = fs6.readFileSync(src, "utf8");
8865
- slide.snippetsUsed ??= {};
8866
- slide.snippetsUsed[src] = content;
8867
8876
  if (regionName) {
8868
8877
  const lines = content.split(/\r?\n/);
8869
8878
  const region = findRegion(lines, regionName.slice(1));
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-NOCCM42F.js";
3
+ } from "./chunk-N256MP4I.js";
4
4
  import {
5
5
  getThemeMeta,
6
6
  loadSetups,
@@ -9,13 +9,13 @@ import {
9
9
  resolveOptions,
10
10
  resolveTheme,
11
11
  version
12
- } from "./chunk-S7ZSXMXK.js";
12
+ } from "./chunk-XYLYAM2E.js";
13
13
  import "./chunk-6DS3IPOB.js";
14
14
  import {
15
15
  getRoots,
16
16
  isInstalledGlobally,
17
17
  resolveEntry
18
- } from "./chunk-2BABGNMX.js";
18
+ } from "./chunk-HOVIRHCR.js";
19
19
  import "./chunk-JSBRDJBE.js";
20
20
 
21
21
  // node/cli.ts
@@ -335,7 +335,7 @@ cli.command(
335
335
  }).strict().help(),
336
336
  async (args) => {
337
337
  const { entry, theme, base, download, out, inspect } = args;
338
- const { build } = await import("./build-MVY7TO7V.js");
338
+ const { build } = await import("./build-ZPFNOFW5.js");
339
339
  for (const entryFile of entry) {
340
340
  const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
341
341
  if (download && !options.data.config.download)
@@ -415,7 +415,7 @@ cli.command(
415
415
  (args) => exportOptions(commonOptions(args)).strict().help(),
416
416
  async (args) => {
417
417
  const { entry, theme } = args;
418
- const { exportSlides, getExportOptions } = await import("./export-TPYQNCSS.js");
418
+ const { exportSlides, getExportOptions } = await import("./export-F3V7NX5E.js");
419
419
  const port = await getPort(12445);
420
420
  for (const entryFile of entry) {
421
421
  const options = await resolveOptions({ entry: entryFile, theme }, "export");
@@ -464,7 +464,7 @@ cli.command(
464
464
  timeout,
465
465
  wait
466
466
  }) => {
467
- const { exportNotes } = await import("./export-TPYQNCSS.js");
467
+ const { exportNotes } = await import("./export-F3V7NX5E.js");
468
468
  const port = await getPort(12445);
469
469
  for (const entryFile of entry) {
470
470
  const options = await resolveOptions({ entry: entryFile }, "export");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getRoots
3
- } from "./chunk-2BABGNMX.js";
3
+ } from "./chunk-HOVIRHCR.js";
4
4
  import "./chunk-JSBRDJBE.js";
5
5
 
6
6
  // node/commands/export.ts
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-NOCCM42F.js";
3
+ } from "./chunk-N256MP4I.js";
4
4
  import {
5
5
  ViteSlidevPlugin,
6
6
  createDataUtils,
7
7
  parser,
8
8
  resolveOptions
9
- } from "./chunk-S7ZSXMXK.js";
9
+ } from "./chunk-XYLYAM2E.js";
10
10
  import "./chunk-6DS3IPOB.js";
11
- import "./chunk-2BABGNMX.js";
11
+ import "./chunk-HOVIRHCR.js";
12
12
  import "./chunk-JSBRDJBE.js";
13
13
  export {
14
14
  ViteSlidevPlugin,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
3
  "type": "module",
4
- "version": "0.49.22",
4
+ "version": "0.49.23",
5
5
  "description": "Presentation slides for developers",
6
6
  "author": "antfu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -109,9 +109,9 @@
109
109
  "vitefu": "^0.2.5",
110
110
  "vue": "^3.4.33",
111
111
  "yargs": "^17.7.2",
112
- "@slidev/client": "0.49.22",
113
- "@slidev/parser": "0.49.22",
114
- "@slidev/types": "0.49.22"
112
+ "@slidev/client": "0.49.23",
113
+ "@slidev/types": "0.49.23",
114
+ "@slidev/parser": "0.49.23"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@hedgedoc/markdown-it-plugins": "^2.1.4",