@slidev/cli 0.49.17 → 0.49.18

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,8 +1,8 @@
1
1
  import {
2
2
  resolveViteConfigs
3
- } from "./chunk-T42M3I2X.mjs";
3
+ } from "./chunk-LY5CYMWF.js";
4
4
 
5
- // node/commands/server.ts
5
+ // node/commands/serve.ts
6
6
  import { join } from "node:path";
7
7
  import process from "node:process";
8
8
  import { createServer as createViteServer } from "vite";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-KRQVQU6O.mjs";
3
+ } from "./chunk-ZVBQP5II.js";
4
4
  import {
5
5
  getThemeMeta,
6
6
  loadSetups,
@@ -9,12 +9,14 @@ import {
9
9
  resolveOptions,
10
10
  resolveTheme,
11
11
  version
12
- } from "./chunk-T42M3I2X.mjs";
12
+ } from "./chunk-LY5CYMWF.js";
13
+ import "./chunk-6DS3IPOB.js";
13
14
  import {
14
15
  getRoots,
15
16
  isInstalledGlobally,
16
17
  resolveEntry
17
- } from "./chunk-27Q2X57X.mjs";
18
+ } from "./chunk-2BABGNMX.js";
19
+ import "./chunk-JSBRDJBE.js";
18
20
 
19
21
  // node/cli.ts
20
22
  import path from "node:path";
@@ -28,9 +30,27 @@ import yargs from "yargs";
28
30
  import { blue, bold, cyan, dim, gray, green, underline, yellow } from "kolorist";
29
31
  import equal from "fast-deep-equal";
30
32
  import { verifyConfig } from "@slidev/parser";
31
- import { injectPreparserExtensionLoader } from "@slidev/parser/fs";
32
- import { uniq } from "@antfu/utils";
33
33
  import { getPort } from "get-port-please";
34
+
35
+ // node/setups/preparser.ts
36
+ import { uniq } from "@antfu/utils";
37
+ import { injectPreparserExtensionLoader } from "@slidev/parser/fs";
38
+ async function setupPreparser() {
39
+ injectPreparserExtensionLoader(async (headmatter, filepath, mode) => {
40
+ const addons = headmatter?.addons;
41
+ if (!addons?.length)
42
+ return [];
43
+ const { userRoot } = await getRoots();
44
+ const roots = uniq([
45
+ ...await resolveAddons(addons),
46
+ userRoot
47
+ ]);
48
+ const returns = await loadSetups(roots, "preparser.ts", [{ filepath, headmatter, mode }]);
49
+ return returns.flat();
50
+ });
51
+ }
52
+
53
+ // node/cli.ts
34
54
  var CONFIG_RESTART_FIELDS = [
35
55
  "highlighter",
36
56
  "monaco",
@@ -54,17 +74,7 @@ var FILES_CHANGE_RESTART_GLOBS = [
54
74
  "setup/katex.ts",
55
75
  "setup/preparser.ts"
56
76
  ];
57
- injectPreparserExtensionLoader(async (headmatter, filepath, mode) => {
58
- const addons = headmatter?.addons ?? [];
59
- const { clientRoot, userRoot } = await getRoots();
60
- const roots = uniq([
61
- clientRoot,
62
- userRoot,
63
- ...await resolveAddons(addons)
64
- ]);
65
- const mergeArrays = (a, b) => a.concat(b);
66
- return await loadSetups(clientRoot, roots, "preparser.ts", { filepath, headmatter, mode }, [], mergeArrays);
67
- });
77
+ setupPreparser();
68
78
  var cli = yargs(process.argv.slice(2)).scriptName("slidev").usage("$0 [args]").version(version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
69
79
  cli.command(
70
80
  "* [entry]",
@@ -325,7 +335,7 @@ cli.command(
325
335
  }).strict().help(),
326
336
  async (args) => {
327
337
  const { entry, theme, base, download, out, inspect } = args;
328
- const { build } = await import("./build-OXWIETNK.mjs");
338
+ const { build } = await import("./build-WV74WRXR.js");
329
339
  for (const entryFile of entry) {
330
340
  const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
331
341
  if (download && !options.data.config.download)
@@ -405,7 +415,7 @@ cli.command(
405
415
  (args) => exportOptions(commonOptions(args)).strict().help(),
406
416
  async (args) => {
407
417
  const { entry, theme } = args;
408
- const { exportSlides, getExportOptions } = await import("./export-ZRMOIVNM.mjs");
418
+ const { exportSlides, getExportOptions } = await import("./export-TPYQNCSS.js");
409
419
  const port = await getPort(12445);
410
420
  for (const entryFile of entry) {
411
421
  const options = await resolveOptions({ entry: entryFile, theme }, "export");
@@ -454,7 +464,7 @@ cli.command(
454
464
  timeout,
455
465
  wait
456
466
  }) => {
457
- const { exportNotes } = await import("./export-ZRMOIVNM.mjs");
467
+ const { exportNotes } = await import("./export-TPYQNCSS.js");
458
468
  const port = await getPort(12445);
459
469
  for (const entryFile of entry) {
460
470
  const options = await resolveOptions({ entry: entryFile }, "export");
@@ -543,7 +553,7 @@ function printInfo(options, port, remote, tunnelUrl, publicIp) {
543
553
  verifyConfig(options.data.config, options.data.themeMeta, (v) => console.warn(yellow(` ! ${v}`)));
544
554
  console.log(dim(" theme ") + (options.theme ? green(options.theme) : gray("none")));
545
555
  console.log(dim(" css engine ") + blue("unocss"));
546
- console.log(dim(" entry ") + dim(path.dirname(options.entry) + path.sep) + path.basename(options.entry));
556
+ console.log(dim(" entry ") + dim(path.normalize(path.dirname(options.entry)) + path.sep) + path.basename(options.entry));
547
557
  if (port) {
548
558
  const query = remote ? `?password=${remote}` : "";
549
559
  const presenterPath = `${options.data.config.routerMode === "hash" ? "/#/" : "/"}presenter/${query}`;
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  getRoots
3
- } from "./chunk-27Q2X57X.mjs";
3
+ } from "./chunk-2BABGNMX.js";
4
+ import "./chunk-JSBRDJBE.js";
4
5
 
5
6
  // node/commands/export.ts
6
7
  import path from "node:path";
@@ -1,14 +1,14 @@
1
- import * as vite from 'vite';
2
- import { Plugin, InlineConfig } from 'vite';
3
1
  import { ResolvedSlidevOptions, SlidevPluginOptions, SlidevServerOptions, SlidevEntryOptions, SlidevData, ResolvedSlidevUtils } from '@slidev/types';
2
+ import * as vite from 'vite';
3
+ import { PluginOption, InlineConfig } from 'vite';
4
4
  import * as fs from '@slidev/parser/fs';
5
5
  export { fs as parser };
6
6
 
7
- declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions: SlidevPluginOptions, serverOptions?: SlidevServerOptions): Promise<Plugin[]>;
7
+ declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions?: SlidevPluginOptions, serverOptions?: SlidevServerOptions): Promise<PluginOption[]>;
8
8
 
9
9
  declare function createServer(options: ResolvedSlidevOptions, viteConfig?: InlineConfig, serverOptions?: SlidevServerOptions): Promise<vite.ViteDevServer>;
10
10
 
11
- declare function resolveOptions(options: SlidevEntryOptions, mode: ResolvedSlidevOptions['mode']): Promise<ResolvedSlidevOptions>;
12
- declare function createDataUtils(data: SlidevData, clientRoot: string, roots: string[]): ResolvedSlidevUtils;
11
+ declare function resolveOptions(entryOptions: SlidevEntryOptions, mode: ResolvedSlidevOptions['mode']): Promise<ResolvedSlidevOptions>;
12
+ declare function createDataUtils(data: SlidevData, clientRoot: string, roots: string[]): Promise<ResolvedSlidevUtils>;
13
13
 
14
14
  export { ViteSlidevPlugin, createDataUtils, createServer, resolveOptions };
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-KRQVQU6O.mjs";
3
+ } from "./chunk-ZVBQP5II.js";
4
4
  import {
5
5
  ViteSlidevPlugin,
6
6
  createDataUtils,
7
7
  parser,
8
8
  resolveOptions
9
- } from "./chunk-T42M3I2X.mjs";
10
- import "./chunk-27Q2X57X.mjs";
9
+ } from "./chunk-LY5CYMWF.js";
10
+ import "./chunk-6DS3IPOB.js";
11
+ import "./chunk-2BABGNMX.js";
12
+ import "./chunk-JSBRDJBE.js";
11
13
  export {
12
14
  ViteSlidevPlugin,
13
15
  createDataUtils,
@@ -0,0 +1,108 @@
1
+ import {
2
+ escapeVueInCode
3
+ } from "./chunk-6DS3IPOB.js";
4
+ import "./chunk-JSBRDJBE.js";
5
+
6
+ // node/syntax/markdown-it/markdown-it-prism.ts
7
+ import { createRequire } from "node:module";
8
+ import Prism from "prismjs";
9
+ import loadLanguages from "prismjs/components/index.js";
10
+ import * as htmlparser2 from "htmlparser2";
11
+ var require2 = createRequire(import.meta.url);
12
+ var Tag = class {
13
+ tagname;
14
+ attributes;
15
+ constructor(tagname, attributes) {
16
+ this.tagname = tagname;
17
+ this.attributes = attributes;
18
+ }
19
+ asOpen() {
20
+ return `<${this.tagname} ${Object.entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(" ")}>`;
21
+ }
22
+ asClosed() {
23
+ return `</${this.tagname}>`;
24
+ }
25
+ };
26
+ var DEFAULTS = {
27
+ plugins: [],
28
+ init: () => {
29
+ },
30
+ defaultLanguageForUnknown: void 0,
31
+ defaultLanguageForUnspecified: void 0,
32
+ defaultLanguage: void 0
33
+ };
34
+ function loadPrismLang(lang) {
35
+ if (!lang)
36
+ return void 0;
37
+ let langObject = Prism.languages[lang];
38
+ if (langObject === void 0) {
39
+ loadLanguages([lang]);
40
+ langObject = Prism.languages[lang];
41
+ }
42
+ return langObject;
43
+ }
44
+ function loadPrismPlugin(name) {
45
+ try {
46
+ require2(`prismjs/plugins/${name}/prism-${name}`);
47
+ } catch (e) {
48
+ throw new Error(`Cannot load Prism plugin "${name}". Please check the spelling.`, { cause: e });
49
+ }
50
+ }
51
+ function selectLanguage(options, lang) {
52
+ let langToUse = lang;
53
+ if (langToUse === "" && options.defaultLanguageForUnspecified !== void 0)
54
+ langToUse = options.defaultLanguageForUnspecified;
55
+ let prismLang = loadPrismLang(langToUse);
56
+ if (prismLang === void 0 && options.defaultLanguageForUnknown !== void 0) {
57
+ langToUse = options.defaultLanguageForUnknown;
58
+ prismLang = loadPrismLang(langToUse);
59
+ }
60
+ return [langToUse, prismLang];
61
+ }
62
+ function highlight(markdownit, options, text, lang) {
63
+ const [langToUse, prismLang] = selectLanguage(options, lang);
64
+ let code = text.trimEnd();
65
+ code = prismLang ? highlightPrism(code, prismLang, langToUse) : markdownit.utils.escapeHtml(code);
66
+ code = code.split(/\r?\n/g).map((line) => `<span class="line">${line}</span>`).join("\n");
67
+ const classAttribute = langToUse ? ` class="slidev-code ${markdownit.options.langPrefix}${markdownit.utils.escapeHtml(langToUse)}"` : "";
68
+ return escapeVueInCode(`<pre${classAttribute}><code>${code}</code></pre>`);
69
+ }
70
+ function highlightPrism(code, prismLang, langToUse) {
71
+ const openTags = [];
72
+ const parser = new htmlparser2.Parser({
73
+ onopentag(tagname, attributes) {
74
+ openTags.push(new Tag(tagname, attributes));
75
+ },
76
+ onclosetag() {
77
+ openTags.pop();
78
+ }
79
+ });
80
+ code = Prism.highlight(code, prismLang, langToUse);
81
+ code = code.split(/\r?\n/g).map((line) => {
82
+ const prefix = openTags.map((tag) => tag.asOpen()).join("");
83
+ parser.write(line);
84
+ const postfix = openTags.reverse().map((tag) => tag.asClosed()).join("");
85
+ return prefix + line + postfix;
86
+ }).join("\n");
87
+ parser.end();
88
+ return code;
89
+ }
90
+ function checkLanguageOption(options, optionName) {
91
+ const language = options[optionName];
92
+ if (language !== void 0 && loadPrismLang(language) === void 0)
93
+ throw new Error(`Bad option ${optionName}: There is no Prism language '${language}'.`);
94
+ }
95
+ function MarkdownItPrism(markdownit, useroptions) {
96
+ const options = Object.assign({}, DEFAULTS, useroptions);
97
+ checkLanguageOption(options, "defaultLanguage");
98
+ checkLanguageOption(options, "defaultLanguageForUnknown");
99
+ checkLanguageOption(options, "defaultLanguageForUnspecified");
100
+ options.defaultLanguageForUnknown = options.defaultLanguageForUnknown || options.defaultLanguage;
101
+ options.defaultLanguageForUnspecified = options.defaultLanguageForUnspecified || options.defaultLanguage;
102
+ options.plugins.forEach(loadPrismPlugin);
103
+ options.init(Prism);
104
+ markdownit.options.highlight = (text, lang) => highlight(markdownit, options, text, lang);
105
+ }
106
+ export {
107
+ MarkdownItPrism as default
108
+ };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/cli",
3
- "version": "0.49.17",
3
+ "type": "module",
4
+ "version": "0.49.18",
4
5
  "description": "Presentation slides for developers",
5
6
  "author": "antfu <anthonyfu117@hotmail.com>",
6
7
  "license": "MIT",
@@ -13,20 +14,19 @@
13
14
  "bugs": "https://github.com/slidevjs/slidev/issues",
14
15
  "exports": {
15
16
  ".": {
16
- "import": "./dist/index.mjs",
17
- "require": "./dist/index.js"
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
18
19
  },
19
20
  "./*": "./*"
20
21
  },
21
22
  "main": "dist/index.js",
22
- "module": "dist/index.mjs",
23
+ "module": "dist/index.js",
23
24
  "types": "dist/index.d.ts",
24
25
  "bin": {
25
26
  "slidev": "./bin/slidev.mjs"
26
27
  },
27
28
  "files": [
28
29
  "bin",
29
- "client",
30
30
  "dist",
31
31
  "template.md"
32
32
  ],
@@ -51,8 +51,8 @@
51
51
  "@shikijs/markdown-it": "^1.10.3",
52
52
  "@shikijs/twoslash": "^1.10.3",
53
53
  "@shikijs/vitepress-twoslash": "^1.10.3",
54
- "@unocss/extractor-mdc": "^0.61.3",
55
- "@unocss/reset": "^0.61.3",
54
+ "@unocss/extractor-mdc": "^0.61.5",
55
+ "@unocss/reset": "^0.61.5",
56
56
  "@vitejs/plugin-vue": "^5.0.5",
57
57
  "@vitejs/plugin-vue-jsx": "^4.0.0",
58
58
  "chokidar": "^3.6.0",
@@ -82,36 +82,36 @@
82
82
  "open": "^10.1.0",
83
83
  "pdf-lib": "^1.17.1",
84
84
  "plantuml-encoder": "^1.4.0",
85
- "postcss-nested": "^6.0.1",
85
+ "postcss-nested": "^6.2.0",
86
86
  "pptxgenjs": "^3.12.0",
87
87
  "prismjs": "^1.29.0",
88
88
  "prompts": "^2.4.2",
89
89
  "public-ip": "^6.0.2",
90
90
  "resolve-from": "^5.0.0",
91
91
  "resolve-global": "^2.0.0",
92
- "semver": "^7.6.2",
92
+ "semver": "^7.6.3",
93
93
  "shiki": "^1.10.3",
94
- "shiki-magic-move": "^0.4.2",
94
+ "shiki-magic-move": "^0.4.3",
95
95
  "sirv": "^2.0.4",
96
96
  "source-map-js": "^1.2.0",
97
97
  "typescript": "^5.5.3",
98
- "unocss": "^0.61.3",
98
+ "unocss": "^0.61.5",
99
99
  "unplugin-icons": "^0.19.0",
100
- "unplugin-vue-components": "^0.27.2",
100
+ "unplugin-vue-components": "^0.27.3",
101
101
  "unplugin-vue-markdown": "^0.26.2",
102
102
  "untun": "^0.1.3",
103
103
  "uqr": "^0.1.2",
104
- "vite": "^5.3.3",
105
- "vite-plugin-inspect": "^0.8.4",
104
+ "vite": "^5.3.4",
105
+ "vite-plugin-inspect": "^0.8.5",
106
106
  "vite-plugin-remote-assets": "^0.5.0",
107
107
  "vite-plugin-static-copy": "^1.0.6",
108
108
  "vite-plugin-vue-server-ref": "^0.4.2",
109
109
  "vitefu": "^0.2.5",
110
- "vue": "^3.4.32",
110
+ "vue": "^3.4.33",
111
111
  "yargs": "^17.7.2",
112
- "@slidev/parser": "0.49.17",
113
- "@slidev/types": "0.49.17",
114
- "@slidev/client": "0.49.17"
112
+ "@slidev/client": "0.49.18",
113
+ "@slidev/parser": "0.49.18",
114
+ "@slidev/types": "0.49.18"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@hedgedoc/markdown-it-plugins": "^2.1.4",
File without changes