@slidev/cli 0.48.0-beta.24 → 0.48.0-beta.26

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.
@@ -12,6 +12,9 @@ import globalDirs from "global-directory";
12
12
  import prompts from "prompts";
13
13
  import { parseNi, run } from "@antfu/ni";
14
14
  import { underline, yellow } from "kolorist";
15
+ async function resolveImportUrl(id) {
16
+ return toAtFS(await resolveImportPath(id, true));
17
+ }
15
18
  function toAtFS(path) {
16
19
  return `/@fs${ensurePrefix("/", slash(path))}`;
17
20
  }
@@ -33,7 +36,7 @@ async function resolveImportPath(importName, ensure = false) {
33
36
  }
34
37
  async function findPkgRoot(dep, parent, ensure = false) {
35
38
  const pkgJsonPath = await findDepPkgJsonPath(dep, parent);
36
- const path = pkgJsonPath ? dirname(pkgJsonPath) : isInstalledGlobally ? findGlobalPkgRoot(dep, false) : void 0;
39
+ const path = pkgJsonPath ? dirname(pkgJsonPath) : isInstalledGlobally ? await findGlobalPkgRoot(dep, false) : void 0;
37
40
  if (ensure && !path)
38
41
  throw new Error(`Failed to resolve package "${dep}"`);
39
42
  return path;
@@ -177,6 +180,7 @@ async function getRoots() {
177
180
  }
178
181
 
179
182
  export {
183
+ resolveImportUrl,
180
184
  toAtFS,
181
185
  resolveImportPath,
182
186
  resolveEntry,
@@ -1,4 +1,4 @@
1
- // node/plugins/setupNode.ts
1
+ // node/setups/load.ts
2
2
  import { resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import fs from "fs-extra";
@@ -1,16 +1,14 @@
1
1
  import {
2
2
  ViteSlidevPlugin,
3
- checkEngine,
4
- mergeViteConfigs,
5
- version
6
- } from "./chunk-4HUKWYZE.mjs";
3
+ mergeViteConfigs
4
+ } from "./chunk-4QV6VXGP.mjs";
7
5
  import {
8
6
  createResolver,
9
7
  getRoots,
10
8
  resolveEntry
11
- } from "./chunk-CV7OWJOF.mjs";
9
+ } from "./chunk-HKSSAKUU.mjs";
12
10
 
13
- // node/server.ts
11
+ // node/commands/server.ts
14
12
  import { join } from "node:path";
15
13
  import process from "node:process";
16
14
  import { createServer as createViteServer, mergeConfig } from "vite";
@@ -49,7 +47,10 @@ async function createServer(options, viteConfig = {}, serverOptions = {}) {
49
47
  // node/parser.ts
50
48
  import * as parser from "@slidev/parser/fs";
51
49
 
52
- // node/themes.ts
50
+ // package.json
51
+ var version = "0.48.0-beta.26";
52
+
53
+ // node/integrations/themes.ts
53
54
  import { join as join2 } from "node:path";
54
55
  import fs from "fs-extra";
55
56
  import { satisfies } from "semver";
@@ -72,9 +73,10 @@ async function getThemeMeta(name, root) {
72
73
  return slidev;
73
74
  }
74
75
 
75
- // node/addons.ts
76
+ // node/integrations/addons.ts
76
77
  import { resolve } from "node:path";
77
78
  import fs2 from "fs-extra";
79
+ import { satisfies as satisfies2 } from "semver";
78
80
  async function resolveAddons(addonsInConfig) {
79
81
  const { userRoot, userPkgJson } = await getRoots();
80
82
  const resolved = [];
@@ -85,7 +87,8 @@ async function resolveAddons(addonsInConfig) {
85
87
  return;
86
88
  resolved.push(pkgRoot);
87
89
  const { slidev, engines } = await fs2.readJSON(resolve(pkgRoot, "package.json"));
88
- checkEngine(name, engines);
90
+ if (engines.slidev && !satisfies2(version, engines.slidev, { includePrerelease: true }))
91
+ throw new Error(`[slidev] addon "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
89
92
  if (Array.isArray(slidev?.addons))
90
93
  await Promise.all(slidev.addons.map((addon) => resolveAddon(addon, pkgRoot)));
91
94
  }
@@ -98,8 +101,8 @@ async function resolveAddons(addonsInConfig) {
98
101
 
99
102
  // node/options.ts
100
103
  import { uniq } from "@antfu/utils";
101
- import _debug from "debug";
102
- var debug = _debug("slidev:options");
104
+ import Debug from "debug";
105
+ var debug = Debug("slidev:options");
103
106
  async function resolveOptions(options, mode) {
104
107
  const rootsInfo = await getRoots();
105
108
  const entry = await resolveEntry(options.entry || "slides.md", rootsInfo);
@@ -144,6 +147,7 @@ async function resolveOptions(options, mode) {
144
147
  export {
145
148
  createServer,
146
149
  parser,
150
+ version,
147
151
  resolveTheme,
148
152
  getThemeMeta,
149
153
  resolveAddons,
package/dist/cli.mjs CHANGED
@@ -4,17 +4,16 @@ import {
4
4
  parser,
5
5
  resolveAddons,
6
6
  resolveOptions,
7
- resolveTheme
8
- } from "./chunk-C5FCGW35.mjs";
9
- import {
7
+ resolveTheme,
10
8
  version
11
- } from "./chunk-4HUKWYZE.mjs";
9
+ } from "./chunk-VF6CY2LH.mjs";
10
+ import "./chunk-4QV6VXGP.mjs";
12
11
  import {
13
12
  loadSetups
14
- } from "./chunk-O6TYYGU6.mjs";
13
+ } from "./chunk-LOUKLO2C.mjs";
15
14
  import {
16
15
  getRoots
17
- } from "./chunk-CV7OWJOF.mjs";
16
+ } from "./chunk-HKSSAKUU.mjs";
18
17
 
19
18
  // node/cli.ts
20
19
  import path from "node:path";
@@ -51,7 +50,6 @@ var FILES_CREATE_RESTART_GLOBS = [
51
50
  "unocss.config.ts"
52
51
  ];
53
52
  var FILES_CHANGE_RESTART_GLOBS = [
54
- "vite.config.*",
55
53
  "setup/shiki.ts",
56
54
  "setup/katex.ts",
57
55
  "setup/preparser.ts"
@@ -326,7 +324,7 @@ cli.command(
326
324
  }).strict().help(),
327
325
  async (args) => {
328
326
  const { entry, theme, watch, base, download, out, inspect } = args;
329
- const { build } = await import("./build-DPVTCX6R.mjs");
327
+ const { build } = await import("./build-Z4EJ6D37.mjs");
330
328
  for (const entryFile of entry) {
331
329
  const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
332
330
  if (download && !options.data.config.download)
@@ -401,7 +399,7 @@ cli.command(
401
399
  (args) => exportOptions(commonOptions(args)).strict().help(),
402
400
  async (args) => {
403
401
  const { entry, theme } = args;
404
- const { exportSlides, getExportOptions } = await import("./export-2XPAFE22.mjs");
402
+ const { exportSlides, getExportOptions } = await import("./export-RHB5HDXR.mjs");
405
403
  const port = await getPort(12445);
406
404
  for (const entryFile of entry) {
407
405
  const options = await resolveOptions({ entry: entryFile, theme }, "export");
@@ -445,7 +443,7 @@ cli.command(
445
443
  output,
446
444
  timeout
447
445
  }) => {
448
- const { exportNotes } = await import("./export-2XPAFE22.mjs");
446
+ const { exportNotes } = await import("./export-RHB5HDXR.mjs");
449
447
  const port = await getPort(12445);
450
448
  for (const entryFile of entry) {
451
449
  const options = await resolveOptions({ entry: entryFile }, "export");
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getRoots
3
- } from "./chunk-CV7OWJOF.mjs";
3
+ } from "./chunk-HKSSAKUU.mjs";
4
4
 
5
- // node/export.ts
5
+ // node/commands/export.ts
6
6
  import path from "node:path";
7
7
  import { Buffer } from "node:buffer";
8
8
  import fs from "fs-extra";
package/dist/index.d.mts CHANGED
@@ -1,92 +1,13 @@
1
- import Vue from '@vitejs/plugin-vue';
2
- import VueJsx from '@vitejs/plugin-vue-jsx';
3
- import Icons from 'unplugin-icons/vite';
4
- import Components from 'unplugin-vue-components/vite';
5
- import Markdown from 'unplugin-vue-markdown/vite';
6
- import { VitePluginConfig } from 'unocss/vite';
7
- import RemoteAssets from 'vite-plugin-remote-assets';
8
- import ServerRef from 'vite-plugin-vue-server-ref';
9
- import { ArgumentsType } from '@antfu/utils';
10
- import { SlidevData } from '@slidev/types';
11
1
  import * as vite from 'vite';
12
- import { InlineConfig, Plugin } from 'vite';
2
+ import { Plugin, InlineConfig } from 'vite';
3
+ import { ResolvedSlidevOptions, SlidevPluginOptions, SlidevServerOptions, SlidevEntryOptions } from '@slidev/types';
13
4
  import * as fs from '@slidev/parser/fs';
14
5
  export { fs as parser };
15
6
 
16
- interface RootsInfo {
17
- cliRoot: string;
18
- clientRoot: string;
19
- userRoot: string;
20
- userPkgJson: Record<string, any>;
21
- userWorkspaceRoot: string;
22
- }
23
-
24
- interface SlidevEntryOptions {
25
- /**
26
- * Markdown entry
27
- *
28
- * @default 'slides.md'
29
- */
30
- entry?: string;
31
- /**
32
- * Theme id
33
- */
34
- theme?: string;
35
- /**
36
- * Remote password
37
- */
38
- remote?: string;
39
- /**
40
- * Enable inspect plugin
41
- */
42
- inspect?: boolean;
43
- }
44
- interface ResolvedSlidevOptions extends RootsInfo {
45
- data: SlidevData;
46
- entry: string;
47
- themeRaw: string;
48
- theme: string;
49
- themeRoots: string[];
50
- addonRoots: string[];
51
- /**
52
- * =`[...themeRoots, ...addonRoots, userRoot]` (`clientRoot` excluded)
53
- */
54
- roots: string[];
55
- mode: 'dev' | 'build' | 'export';
56
- remote?: string;
57
- inspect?: boolean;
58
- }
59
- interface SlidevPluginOptions extends SlidevEntryOptions {
60
- vue?: ArgumentsType<typeof Vue>[0];
61
- vuejsx?: ArgumentsType<typeof VueJsx>[0];
62
- markdown?: ArgumentsType<typeof Markdown>[0];
63
- components?: ArgumentsType<typeof Components>[0];
64
- icons?: ArgumentsType<typeof Icons>[0];
65
- remoteAssets?: ArgumentsType<typeof RemoteAssets>[0];
66
- serverRef?: ArgumentsType<typeof ServerRef>[0];
67
- unocss?: VitePluginConfig;
68
- }
69
- interface SlidevServerOptions {
70
- /**
71
- * @returns `false` if server should be restarted
72
- */
73
- loadData?: () => Promise<SlidevData | false>;
74
- }
75
- declare function resolveOptions(options: SlidevEntryOptions, mode: ResolvedSlidevOptions['mode']): Promise<ResolvedSlidevOptions>;
76
-
77
- declare module 'vite' {
78
- interface UserConfig {
79
- /**
80
- * Custom internal plugin options for Slidev (advanced)
81
- *
82
- * @see https://github.com/slidevjs/slidev/blob/main/packages/slidev/node/options.ts#L50
83
- */
84
- slidev?: SlidevPluginOptions;
85
- }
86
- }
7
+ declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions: SlidevPluginOptions, serverOptions?: SlidevServerOptions): Promise<Plugin[]>;
87
8
 
88
9
  declare function createServer(options: ResolvedSlidevOptions, viteConfig?: InlineConfig, serverOptions?: SlidevServerOptions): Promise<vite.ViteDevServer>;
89
10
 
90
- declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions: SlidevPluginOptions, serverOptions?: SlidevServerOptions): Promise<Plugin[]>;
11
+ declare function resolveOptions(options: SlidevEntryOptions, mode: ResolvedSlidevOptions['mode']): Promise<ResolvedSlidevOptions>;
91
12
 
92
- export { type ResolvedSlidevOptions, type SlidevEntryOptions, type SlidevPluginOptions, type SlidevServerOptions, ViteSlidevPlugin, createServer, resolveOptions };
13
+ export { ViteSlidevPlugin, createServer, resolveOptions };
package/dist/index.mjs CHANGED
@@ -2,12 +2,12 @@ import {
2
2
  createServer,
3
3
  parser,
4
4
  resolveOptions
5
- } from "./chunk-C5FCGW35.mjs";
5
+ } from "./chunk-VF6CY2LH.mjs";
6
6
  import {
7
7
  ViteSlidevPlugin
8
- } from "./chunk-4HUKWYZE.mjs";
9
- import "./chunk-O6TYYGU6.mjs";
10
- import "./chunk-CV7OWJOF.mjs";
8
+ } from "./chunk-4QV6VXGP.mjs";
9
+ import "./chunk-LOUKLO2C.mjs";
10
+ import "./chunk-HKSSAKUU.mjs";
11
11
  export {
12
12
  ViteSlidevPlugin,
13
13
  createServer,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  loadSetups
3
- } from "./chunk-O6TYYGU6.mjs";
3
+ } from "./chunk-LOUKLO2C.mjs";
4
4
 
5
- // node/plugins/unocss.ts
5
+ // node/vite/unocss.ts
6
6
  import { resolve } from "node:path";
7
7
  import { existsSync } from "node:fs";
8
8
  import { fileURLToPath } from "node:url";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
- "version": "0.48.0-beta.24",
3
+ "version": "0.48.0-beta.26",
4
4
  "description": "Presentation slides for developers",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -106,9 +106,9 @@
106
106
  "vitefu": "^0.2.5",
107
107
  "vue": "^3.4.21",
108
108
  "yargs": "^17.7.2",
109
- "@slidev/client": "0.48.0-beta.24",
110
- "@slidev/parser": "0.48.0-beta.24",
111
- "@slidev/types": "0.48.0-beta.24"
109
+ "@slidev/client": "0.48.0-beta.26",
110
+ "@slidev/types": "0.48.0-beta.26",
111
+ "@slidev/parser": "0.48.0-beta.26"
112
112
  },
113
113
  "devDependencies": {
114
114
  "@hedgedoc/markdown-it-plugins": "^2.1.4",