@slidev/cli 0.49.29 → 0.50.0-beta.10
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.
- package/README.md +1 -1
- package/dist/{build-2WDSCT4J.js → build-E2JY62WB.js} +6 -7
- package/dist/{chunk-YP37OZJY.js → chunk-Q74EQR62.js} +1147 -1086
- package/dist/{chunk-IVWMFGB5.js → chunk-T7CH4MWU.js} +1 -1
- package/dist/cli.js +21 -27
- package/dist/{export-FTRUCBWA.js → export-I2C456L6.js} +10 -12
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -4
- package/package.json +39 -40
- package/template.md +5 -7
- package/dist/chunk-6DS3IPOB.js +0 -31
- package/dist/markdown-it-prism-P475G4NP.js +0 -107
- package/dist/{chunk-HOVIRHCR.js → chunk-UNQ5DBLZ.js} +6 -6
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-T7CH4MWU.js";
|
|
4
4
|
import {
|
|
5
5
|
getThemeMeta,
|
|
6
6
|
loadSetups,
|
|
@@ -9,36 +9,33 @@ import {
|
|
|
9
9
|
resolveOptions,
|
|
10
10
|
resolveTheme,
|
|
11
11
|
version
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-6DS3IPOB.js";
|
|
12
|
+
} from "./chunk-Q74EQR62.js";
|
|
14
13
|
import {
|
|
15
14
|
getRoots,
|
|
16
15
|
isInstalledGlobally,
|
|
17
16
|
resolveEntry
|
|
18
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-UNQ5DBLZ.js";
|
|
19
18
|
|
|
20
19
|
// node/cli.ts
|
|
21
|
-
import path from "node:path";
|
|
22
|
-
import os from "node:os";
|
|
23
20
|
import { exec } from "node:child_process";
|
|
24
|
-
import
|
|
21
|
+
import os from "node:os";
|
|
22
|
+
import path from "node:path";
|
|
25
23
|
import process from "node:process";
|
|
24
|
+
import * as readline from "node:readline";
|
|
25
|
+
import { verifyConfig } from "@slidev/parser";
|
|
26
|
+
import equal from "fast-deep-equal";
|
|
26
27
|
import fs from "fs-extra";
|
|
28
|
+
import { getPort } from "get-port-please";
|
|
29
|
+
import { blue, bold, cyan, dim, gray, green, underline, yellow } from "kolorist";
|
|
27
30
|
import openBrowser from "open";
|
|
28
31
|
import yargs from "yargs";
|
|
29
|
-
import { blue, bold, cyan, dim, gray, green, underline, yellow } from "kolorist";
|
|
30
|
-
import equal from "fast-deep-equal";
|
|
31
|
-
import { verifyConfig } from "@slidev/parser";
|
|
32
|
-
import { getPort } from "get-port-please";
|
|
33
32
|
|
|
34
33
|
// node/setups/preparser.ts
|
|
35
34
|
import { uniq } from "@antfu/utils";
|
|
36
35
|
import { injectPreparserExtensionLoader } from "@slidev/parser/fs";
|
|
37
|
-
|
|
36
|
+
function setupPreparser() {
|
|
38
37
|
injectPreparserExtensionLoader(async (headmatter, filepath, mode) => {
|
|
39
|
-
const addons = headmatter?.addons;
|
|
40
|
-
if (!addons?.length)
|
|
41
|
-
return [];
|
|
38
|
+
const addons = Array.isArray(headmatter?.addons) ? headmatter.addons : [];
|
|
42
39
|
const { userRoot } = await getRoots();
|
|
43
40
|
const roots = uniq([
|
|
44
41
|
...await resolveAddons(addons),
|
|
@@ -51,7 +48,6 @@ async function setupPreparser() {
|
|
|
51
48
|
|
|
52
49
|
// node/cli.ts
|
|
53
50
|
var CONFIG_RESTART_FIELDS = [
|
|
54
|
-
"highlighter",
|
|
55
51
|
"monaco",
|
|
56
52
|
"routerMode",
|
|
57
53
|
"fonts",
|
|
@@ -60,7 +56,7 @@ var CONFIG_RESTART_FIELDS = [
|
|
|
60
56
|
"editor",
|
|
61
57
|
"theme"
|
|
62
58
|
];
|
|
63
|
-
var
|
|
59
|
+
var FILES_CREATE_RESTART = [
|
|
64
60
|
"global-bottom.vue",
|
|
65
61
|
"global-top.vue",
|
|
66
62
|
"uno.config.js",
|
|
@@ -68,7 +64,7 @@ var FILES_CREATE_RESTART_GLOBS = [
|
|
|
68
64
|
"unocss.config.js",
|
|
69
65
|
"unocss.config.ts"
|
|
70
66
|
];
|
|
71
|
-
var
|
|
67
|
+
var FILES_CHANGE_RESTART = [
|
|
72
68
|
"setup/shiki.ts",
|
|
73
69
|
"setup/katex.ts",
|
|
74
70
|
"setup/preparser.ts"
|
|
@@ -284,8 +280,8 @@ ${dim(" Public IP: ")} ${blue(publicIp)}
|
|
|
284
280
|
bindShortcut();
|
|
285
281
|
const { watch } = await import("chokidar");
|
|
286
282
|
const watcher = watch([
|
|
287
|
-
...
|
|
288
|
-
...
|
|
283
|
+
...FILES_CREATE_RESTART,
|
|
284
|
+
...FILES_CHANGE_RESTART
|
|
289
285
|
], {
|
|
290
286
|
ignored: ["node_modules", ".git"],
|
|
291
287
|
ignoreInitial: true
|
|
@@ -303,7 +299,7 @@ ${dim(" Public IP: ")} ${blue(publicIp)}
|
|
|
303
299
|
restartServer();
|
|
304
300
|
});
|
|
305
301
|
watcher.on("change", (file) => {
|
|
306
|
-
if (
|
|
302
|
+
if (FILES_CREATE_RESTART.includes(file))
|
|
307
303
|
return;
|
|
308
304
|
console.log(yellow(`
|
|
309
305
|
file ${file} changed, restarting...
|
|
@@ -334,11 +330,9 @@ cli.command(
|
|
|
334
330
|
}).strict().help(),
|
|
335
331
|
async (args) => {
|
|
336
332
|
const { entry, theme, base, download, out, inspect } = args;
|
|
337
|
-
const { build } = await import("./build-
|
|
333
|
+
const { build } = await import("./build-E2JY62WB.js");
|
|
338
334
|
for (const entryFile of entry) {
|
|
339
|
-
const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
|
|
340
|
-
if (download && !options.data.config.download)
|
|
341
|
-
options.data.config.download = download;
|
|
335
|
+
const options = await resolveOptions({ entry: entryFile, theme, inspect, download }, "build");
|
|
342
336
|
printInfo(options);
|
|
343
337
|
await build(
|
|
344
338
|
options,
|
|
@@ -414,7 +408,7 @@ cli.command(
|
|
|
414
408
|
(args) => exportOptions(commonOptions(args)).strict().help(),
|
|
415
409
|
async (args) => {
|
|
416
410
|
const { entry, theme } = args;
|
|
417
|
-
const { exportSlides, getExportOptions } = await import("./export-
|
|
411
|
+
const { exportSlides, getExportOptions } = await import("./export-I2C456L6.js");
|
|
418
412
|
const port = await getPort(12445);
|
|
419
413
|
for (const entryFile of entry) {
|
|
420
414
|
const options = await resolveOptions({ entry: entryFile, theme }, "export");
|
|
@@ -463,7 +457,7 @@ cli.command(
|
|
|
463
457
|
timeout,
|
|
464
458
|
wait
|
|
465
459
|
}) => {
|
|
466
|
-
const { exportNotes } = await import("./export-
|
|
460
|
+
const { exportNotes } = await import("./export-I2C456L6.js");
|
|
467
461
|
const port = await getPort(12445);
|
|
468
462
|
for (const entryFile of entry) {
|
|
469
463
|
const options = await resolveOptions({ entry: entryFile }, "export");
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getRoots
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UNQ5DBLZ.js";
|
|
4
4
|
|
|
5
5
|
// node/commands/export.ts
|
|
6
|
-
import path from "node:path";
|
|
7
6
|
import { Buffer } from "node:buffer";
|
|
7
|
+
import path from "node:path";
|
|
8
8
|
import process from "node:process";
|
|
9
|
-
import fs from "fs-extra";
|
|
10
|
-
import { blue, cyan, dim, green, yellow } from "kolorist";
|
|
11
|
-
import { Presets, SingleBar } from "cli-progress";
|
|
12
9
|
import { clearUndefined, slash } from "@antfu/utils";
|
|
13
|
-
import { parseRangeString } from "@slidev/parser/core";
|
|
14
10
|
import { outlinePdfFactory } from "@lillallol/outline-pdf";
|
|
11
|
+
import { parseRangeString } from "@slidev/parser/core";
|
|
12
|
+
import { Presets, SingleBar } from "cli-progress";
|
|
13
|
+
import fs from "fs-extra";
|
|
14
|
+
import { blue, cyan, dim, green, yellow } from "kolorist";
|
|
15
|
+
import { resolve } from "mlly";
|
|
15
16
|
import * as pdfLib from "pdf-lib";
|
|
16
17
|
import { PDFDocument } from "pdf-lib";
|
|
17
|
-
import { resolve } from "mlly";
|
|
18
18
|
function addToTree(tree, info, slideIndexes, level = 1) {
|
|
19
19
|
const titleLevel = info.level;
|
|
20
20
|
if (titleLevel && titleLevel > level && tree.length > 0 && tree[tree.length - 1].titleLevel < titleLevel) {
|
|
@@ -77,8 +77,7 @@ async function exportNotes({
|
|
|
77
77
|
base = "/",
|
|
78
78
|
output = "notes",
|
|
79
79
|
timeout = 3e4,
|
|
80
|
-
wait = 0
|
|
81
|
-
waitUntil
|
|
80
|
+
wait = 0
|
|
82
81
|
}) {
|
|
83
82
|
const { chromium } = await importPlaywright();
|
|
84
83
|
const browser = await chromium.launch();
|
|
@@ -88,9 +87,8 @@ async function exportNotes({
|
|
|
88
87
|
progress.start(1);
|
|
89
88
|
if (!output.endsWith(".pdf"))
|
|
90
89
|
output = `${output}.pdf`;
|
|
91
|
-
await page.goto(`http://localhost:${port}${base}presenter/print`, { waitUntil, timeout });
|
|
92
|
-
|
|
93
|
-
await page.waitForLoadState(waitUntil);
|
|
90
|
+
await page.goto(`http://localhost:${port}${base}presenter/print`, { waitUntil: "networkidle", timeout });
|
|
91
|
+
await page.waitForLoadState("networkidle");
|
|
94
92
|
await page.emulateMedia({ media: "screen" });
|
|
95
93
|
if (wait)
|
|
96
94
|
await page.waitForTimeout(wait);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ResolvedSlidevOptions, SlidevPluginOptions, SlidevServerOptions, SlidevEntryOptions, ResolvedSlidevUtils } from '@slidev/types';
|
|
2
1
|
import * as vite from 'vite';
|
|
3
|
-
import {
|
|
2
|
+
import { InlineConfig, PluginOption } from 'vite';
|
|
3
|
+
import { ResolvedSlidevOptions, SlidevServerOptions, SlidevEntryOptions, ResolvedSlidevUtils, SlidevPluginOptions } from '@slidev/types';
|
|
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<PluginOption[]>;
|
|
8
|
-
|
|
9
7
|
declare function createServer(options: ResolvedSlidevOptions, viteConfig?: InlineConfig, serverOptions?: SlidevServerOptions): Promise<vite.ViteDevServer>;
|
|
10
8
|
|
|
11
9
|
declare function resolveOptions(entryOptions: SlidevEntryOptions, mode: ResolvedSlidevOptions['mode']): Promise<ResolvedSlidevOptions>;
|
|
12
10
|
declare function createDataUtils(resolved: Omit<ResolvedSlidevOptions, 'utils'>): Promise<ResolvedSlidevUtils>;
|
|
13
11
|
|
|
12
|
+
declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions?: SlidevPluginOptions, serverOptions?: SlidevServerOptions): Promise<PluginOption[]>;
|
|
13
|
+
|
|
14
14
|
export { ViteSlidevPlugin, createDataUtils, createServer, resolveOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-T7CH4MWU.js";
|
|
4
4
|
import {
|
|
5
5
|
ViteSlidevPlugin,
|
|
6
6
|
createDataUtils,
|
|
7
7
|
parser,
|
|
8
8
|
resolveOptions
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-HOVIRHCR.js";
|
|
9
|
+
} from "./chunk-Q74EQR62.js";
|
|
10
|
+
import "./chunk-UNQ5DBLZ.js";
|
|
12
11
|
export {
|
|
13
12
|
ViteSlidevPlugin,
|
|
14
13
|
createDataUtils,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.50.0-beta.10",
|
|
5
5
|
"description": "Presentation slides for developers",
|
|
6
6
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -42,23 +42,23 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@antfu/ni": "^0.
|
|
45
|
+
"@antfu/ni": "^0.23.1",
|
|
46
46
|
"@antfu/utils": "^0.7.10",
|
|
47
|
-
"@iconify-json/carbon": "^1.
|
|
48
|
-
"@iconify-json/ph": "^1.1
|
|
49
|
-
"@iconify-json/svg-spinners": "^1.1
|
|
47
|
+
"@iconify-json/carbon": "^1.2.4",
|
|
48
|
+
"@iconify-json/ph": "^1.2.1",
|
|
49
|
+
"@iconify-json/svg-spinners": "^1.2.1",
|
|
50
50
|
"@lillallol/outline-pdf": "^4.0.0",
|
|
51
|
-
"@shikijs/markdown-it": "^1.
|
|
52
|
-
"@shikijs/twoslash": "^1.
|
|
53
|
-
"@shikijs/vitepress-twoslash": "^1.
|
|
54
|
-
"@unocss/extractor-mdc": "^0.
|
|
55
|
-
"@unocss/reset": "^0.
|
|
56
|
-
"@vitejs/plugin-vue": "^5.1
|
|
57
|
-
"@vitejs/plugin-vue-jsx": "^4.
|
|
58
|
-
"chokidar": "^
|
|
51
|
+
"@shikijs/markdown-it": "^1.24.0",
|
|
52
|
+
"@shikijs/twoslash": "^1.24.0",
|
|
53
|
+
"@shikijs/vitepress-twoslash": "^1.24.0",
|
|
54
|
+
"@unocss/extractor-mdc": "^0.65.0",
|
|
55
|
+
"@unocss/reset": "^0.65.0",
|
|
56
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
57
|
+
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
|
58
|
+
"chokidar": "^4.0.1",
|
|
59
59
|
"cli-progress": "^3.12.0",
|
|
60
60
|
"connect": "^3.7.0",
|
|
61
|
-
"debug": "^4.3.
|
|
61
|
+
"debug": "^4.3.7",
|
|
62
62
|
"fast-deep-equal": "^3.1.3",
|
|
63
63
|
"fast-glob": "^3.3.2",
|
|
64
64
|
"fs-extra": "^11.2.0",
|
|
@@ -66,53 +66,52 @@
|
|
|
66
66
|
"global-directory": "^4.0.1",
|
|
67
67
|
"htmlparser2": "^9.1.0",
|
|
68
68
|
"is-installed-globally": "^1.0.0",
|
|
69
|
-
"jiti": "^
|
|
69
|
+
"jiti": "^2.4.1",
|
|
70
70
|
"katex": "^0.16.11",
|
|
71
71
|
"kolorist": "^1.8.0",
|
|
72
|
-
"local-pkg": "^0.5.
|
|
72
|
+
"local-pkg": "^0.5.1",
|
|
73
73
|
"lz-string": "^1.5.0",
|
|
74
|
-
"magic-string": "^0.30.
|
|
74
|
+
"magic-string": "^0.30.14",
|
|
75
75
|
"magic-string-stack": "^0.1.1",
|
|
76
76
|
"markdown-it": "^14.1.0",
|
|
77
77
|
"markdown-it-footnote": "^4.0.0",
|
|
78
78
|
"markdown-it-mdc": "^0.2.5",
|
|
79
79
|
"micromatch": "^4.0.8",
|
|
80
|
-
"mlly": "^1.7.
|
|
81
|
-
"monaco-editor": "
|
|
80
|
+
"mlly": "^1.7.3",
|
|
81
|
+
"monaco-editor": "0.51.0",
|
|
82
82
|
"open": "^10.1.0",
|
|
83
83
|
"pdf-lib": "^1.17.1",
|
|
84
84
|
"plantuml-encoder": "^1.4.0",
|
|
85
|
-
"postcss-nested": "^
|
|
85
|
+
"postcss-nested": "^7.0.2",
|
|
86
86
|
"pptxgenjs": "^3.12.0",
|
|
87
|
-
"prismjs": "^1.29.0",
|
|
88
87
|
"prompts": "^2.4.2",
|
|
89
88
|
"public-ip": "^7.0.1",
|
|
90
89
|
"resolve-from": "^5.0.0",
|
|
91
90
|
"resolve-global": "^2.0.0",
|
|
92
91
|
"semver": "^7.6.3",
|
|
93
|
-
"shiki": "^1.
|
|
94
|
-
"shiki-magic-move": "^0.
|
|
95
|
-
"sirv": "^
|
|
96
|
-
"source-map-js": "^1.2.
|
|
97
|
-
"typescript": "
|
|
98
|
-
"unocss": "^0.
|
|
99
|
-
"unplugin-icons": "^0.
|
|
100
|
-
"unplugin-vue-components": "^0.27.
|
|
101
|
-
"unplugin-vue-markdown": "^0.
|
|
92
|
+
"shiki": "^1.24.0",
|
|
93
|
+
"shiki-magic-move": "^0.5.0",
|
|
94
|
+
"sirv": "^3.0.0",
|
|
95
|
+
"source-map-js": "^1.2.1",
|
|
96
|
+
"typescript": "5.6.3",
|
|
97
|
+
"unocss": "^0.65.0",
|
|
98
|
+
"unplugin-icons": "^0.20.2",
|
|
99
|
+
"unplugin-vue-components": "^0.27.5",
|
|
100
|
+
"unplugin-vue-markdown": "^0.27.1",
|
|
102
101
|
"untun": "^0.1.3",
|
|
103
102
|
"uqr": "^0.1.2",
|
|
104
|
-
"vite": "^
|
|
105
|
-
"vite-plugin-inspect": "^0.
|
|
106
|
-
"vite-plugin-remote-assets": "^0.
|
|
107
|
-
"vite-plugin-static-copy": "^
|
|
103
|
+
"vite": "^6.0.2",
|
|
104
|
+
"vite-plugin-inspect": "^0.10.2",
|
|
105
|
+
"vite-plugin-remote-assets": "^0.6.0",
|
|
106
|
+
"vite-plugin-static-copy": "^2.2.0",
|
|
108
107
|
"vite-plugin-vue-server-ref": "^0.4.2",
|
|
109
|
-
"vitefu": "^1.0.
|
|
110
|
-
"vue": "^3.
|
|
111
|
-
"yaml": "^2.
|
|
108
|
+
"vitefu": "^1.0.4",
|
|
109
|
+
"vue": "^3.5.13",
|
|
110
|
+
"yaml": "^2.6.1",
|
|
112
111
|
"yargs": "^17.7.2",
|
|
113
|
-
"@slidev/client": "0.
|
|
114
|
-
"@slidev/
|
|
115
|
-
"@slidev/
|
|
112
|
+
"@slidev/client": "0.50.0-beta.10",
|
|
113
|
+
"@slidev/types": "0.50.0-beta.10",
|
|
114
|
+
"@slidev/parser": "0.50.0-beta.10"
|
|
116
115
|
},
|
|
117
116
|
"devDependencies": {
|
|
118
117
|
"@hedgedoc/markdown-it-plugins": "^2.1.4",
|
package/template.md
CHANGED
|
@@ -6,8 +6,6 @@ theme: seriph
|
|
|
6
6
|
background: https://cover.sli.dev
|
|
7
7
|
# apply any unocss classes to the current slide
|
|
8
8
|
class: 'text-center'
|
|
9
|
-
# https://sli.dev/custom/config-highlighter.html
|
|
10
|
-
highlighter: shiki
|
|
11
9
|
# some information about the slides, markdown enabled
|
|
12
10
|
info: |
|
|
13
11
|
## Slidev Starter Template
|
|
@@ -24,14 +22,14 @@ mdc: true
|
|
|
24
22
|
Presentation slides for developers
|
|
25
23
|
|
|
26
24
|
<div class="pt-12">
|
|
27
|
-
<span @click="$slidev.nav.next" class="px-2 py-1 rounded cursor-pointer" hover="bg-white bg-opacity-10">
|
|
28
|
-
Press Space for next page <carbon:arrow-right
|
|
25
|
+
<span @click="$slidev.nav.next" class="px-2 py-1 rounded cursor-pointer" flex="~ justify-center items-center gap-2" hover="bg-white bg-opacity-10">
|
|
26
|
+
Press Space for next page <div class="i-carbon:arrow-right inline-block"/>
|
|
29
27
|
</span>
|
|
30
28
|
</div>
|
|
31
29
|
|
|
32
30
|
<div class="abs-br m-6 flex gap-2">
|
|
33
31
|
<button @click="$slidev.nav.openInEditor()" title="Open in Editor" class="text-xl slidev-icon-btn opacity-50 !border-none !hover:text-white">
|
|
34
|
-
<carbon:edit />
|
|
32
|
+
<div class="i-carbon:edit" />
|
|
35
33
|
</button>
|
|
36
34
|
<a href="https://github.com/slidevjs/slidev" target="_blank" alt="GitHub" title="Open in GitHub"
|
|
37
35
|
class="text-xl slidev-icon-btn opacity-50 !border-none !hover:text-white">
|
|
@@ -237,8 +235,8 @@ theme: seriph
|
|
|
237
235
|
|
|
238
236
|
</div>
|
|
239
237
|
|
|
240
|
-
Read more about [How to use a theme](https://sli.dev/
|
|
241
|
-
check out the [Awesome Themes Gallery](https://sli.dev/
|
|
238
|
+
Read more about [How to use a theme](https://sli.dev/guide/theme-addon#use-theme) and
|
|
239
|
+
check out the [Awesome Themes Gallery](https://sli.dev/resources/theme-gallery).
|
|
242
240
|
|
|
243
241
|
---
|
|
244
242
|
preload: false
|
package/dist/chunk-6DS3IPOB.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// node/syntax/transform/utils.ts
|
|
2
|
-
function normalizeRangeStr(rangeStr = "") {
|
|
3
|
-
return !rangeStr.trim() ? [] : rangeStr.trim().split(/\|/g).map((i) => i.trim());
|
|
4
|
-
}
|
|
5
|
-
function getCodeBlocks(md) {
|
|
6
|
-
const codeblocks = Array.from(md.matchAll(/^```[\s\S]*?^```/gm)).map((m) => {
|
|
7
|
-
const start = m.index;
|
|
8
|
-
const end = m.index + m[0].length;
|
|
9
|
-
const startLine = md.slice(0, start).match(/\n/g)?.length || 0;
|
|
10
|
-
const endLine = md.slice(0, end).match(/\n/g)?.length || 0;
|
|
11
|
-
return [start, end, startLine, endLine];
|
|
12
|
-
});
|
|
13
|
-
return {
|
|
14
|
-
codeblocks,
|
|
15
|
-
isInsideCodeblocks(idx) {
|
|
16
|
-
return codeblocks.some(([s, e]) => s <= idx && idx <= e);
|
|
17
|
-
},
|
|
18
|
-
isLineInsideCodeblocks(line) {
|
|
19
|
-
return codeblocks.some(([, , s, e]) => s <= line && line <= e);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function escapeVueInCode(md) {
|
|
24
|
-
return md.replace(/\{\{/g, "{{");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
normalizeRangeStr,
|
|
29
|
-
getCodeBlocks,
|
|
30
|
-
escapeVueInCode
|
|
31
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
escapeVueInCode
|
|
3
|
-
} from "./chunk-6DS3IPOB.js";
|
|
4
|
-
|
|
5
|
-
// node/syntax/markdown-it/markdown-it-prism.ts
|
|
6
|
-
import { createRequire } from "node:module";
|
|
7
|
-
import Prism from "prismjs";
|
|
8
|
-
import loadLanguages from "prismjs/components/index.js";
|
|
9
|
-
import * as htmlparser2 from "htmlparser2";
|
|
10
|
-
var require2 = createRequire(import.meta.url);
|
|
11
|
-
var Tag = class {
|
|
12
|
-
tagname;
|
|
13
|
-
attributes;
|
|
14
|
-
constructor(tagname, attributes) {
|
|
15
|
-
this.tagname = tagname;
|
|
16
|
-
this.attributes = attributes;
|
|
17
|
-
}
|
|
18
|
-
asOpen() {
|
|
19
|
-
return `<${this.tagname} ${Object.entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(" ")}>`;
|
|
20
|
-
}
|
|
21
|
-
asClosed() {
|
|
22
|
-
return `</${this.tagname}>`;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
var DEFAULTS = {
|
|
26
|
-
plugins: [],
|
|
27
|
-
init: () => {
|
|
28
|
-
},
|
|
29
|
-
defaultLanguageForUnknown: void 0,
|
|
30
|
-
defaultLanguageForUnspecified: void 0,
|
|
31
|
-
defaultLanguage: void 0
|
|
32
|
-
};
|
|
33
|
-
function loadPrismLang(lang) {
|
|
34
|
-
if (!lang)
|
|
35
|
-
return void 0;
|
|
36
|
-
let langObject = Prism.languages[lang];
|
|
37
|
-
if (langObject === void 0) {
|
|
38
|
-
loadLanguages([lang]);
|
|
39
|
-
langObject = Prism.languages[lang];
|
|
40
|
-
}
|
|
41
|
-
return langObject;
|
|
42
|
-
}
|
|
43
|
-
function loadPrismPlugin(name) {
|
|
44
|
-
try {
|
|
45
|
-
require2(`prismjs/plugins/${name}/prism-${name}`);
|
|
46
|
-
} catch (e) {
|
|
47
|
-
throw new Error(`Cannot load Prism plugin "${name}". Please check the spelling.`, { cause: e });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function selectLanguage(options, lang) {
|
|
51
|
-
let langToUse = lang;
|
|
52
|
-
if (langToUse === "" && options.defaultLanguageForUnspecified !== void 0)
|
|
53
|
-
langToUse = options.defaultLanguageForUnspecified;
|
|
54
|
-
let prismLang = loadPrismLang(langToUse);
|
|
55
|
-
if (prismLang === void 0 && options.defaultLanguageForUnknown !== void 0) {
|
|
56
|
-
langToUse = options.defaultLanguageForUnknown;
|
|
57
|
-
prismLang = loadPrismLang(langToUse);
|
|
58
|
-
}
|
|
59
|
-
return [langToUse, prismLang];
|
|
60
|
-
}
|
|
61
|
-
function highlight(markdownit, options, text, lang) {
|
|
62
|
-
const [langToUse, prismLang] = selectLanguage(options, lang);
|
|
63
|
-
let code = text.trimEnd();
|
|
64
|
-
code = prismLang ? highlightPrism(code, prismLang, langToUse) : markdownit.utils.escapeHtml(code);
|
|
65
|
-
code = code.split(/\r?\n/g).map((line) => `<span class="line">${line}</span>`).join("\n");
|
|
66
|
-
const classAttribute = langToUse ? ` class="slidev-code ${markdownit.options.langPrefix}${markdownit.utils.escapeHtml(langToUse)}"` : "";
|
|
67
|
-
return escapeVueInCode(`<pre${classAttribute}><code>${code}</code></pre>`);
|
|
68
|
-
}
|
|
69
|
-
function highlightPrism(code, prismLang, langToUse) {
|
|
70
|
-
const openTags = [];
|
|
71
|
-
const parser = new htmlparser2.Parser({
|
|
72
|
-
onopentag(tagname, attributes) {
|
|
73
|
-
openTags.push(new Tag(tagname, attributes));
|
|
74
|
-
},
|
|
75
|
-
onclosetag() {
|
|
76
|
-
openTags.pop();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
code = Prism.highlight(code, prismLang, langToUse);
|
|
80
|
-
code = code.split(/\r?\n/g).map((line) => {
|
|
81
|
-
const prefix = openTags.map((tag) => tag.asOpen()).join("");
|
|
82
|
-
parser.write(line);
|
|
83
|
-
const postfix = openTags.reverse().map((tag) => tag.asClosed()).join("");
|
|
84
|
-
return prefix + line + postfix;
|
|
85
|
-
}).join("\n");
|
|
86
|
-
parser.end();
|
|
87
|
-
return code;
|
|
88
|
-
}
|
|
89
|
-
function checkLanguageOption(options, optionName) {
|
|
90
|
-
const language = options[optionName];
|
|
91
|
-
if (language !== void 0 && loadPrismLang(language) === void 0)
|
|
92
|
-
throw new Error(`Bad option ${optionName}: There is no Prism language '${language}'.`);
|
|
93
|
-
}
|
|
94
|
-
function MarkdownItPrism(markdownit, useroptions) {
|
|
95
|
-
const options = Object.assign({}, DEFAULTS, useroptions);
|
|
96
|
-
checkLanguageOption(options, "defaultLanguage");
|
|
97
|
-
checkLanguageOption(options, "defaultLanguageForUnknown");
|
|
98
|
-
checkLanguageOption(options, "defaultLanguageForUnspecified");
|
|
99
|
-
options.defaultLanguageForUnknown = options.defaultLanguageForUnknown || options.defaultLanguage;
|
|
100
|
-
options.defaultLanguageForUnspecified = options.defaultLanguageForUnspecified || options.defaultLanguage;
|
|
101
|
-
options.plugins.forEach(loadPrismPlugin);
|
|
102
|
-
options.init(Prism);
|
|
103
|
-
markdownit.options.highlight = (text, lang) => highlight(markdownit, options, text, lang);
|
|
104
|
-
}
|
|
105
|
-
export {
|
|
106
|
-
MarkdownItPrism as default
|
|
107
|
-
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// node/resolver.ts
|
|
2
|
-
import { dirname, join, relative, resolve } from "node:path";
|
|
3
2
|
import * as fs from "node:fs";
|
|
3
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { parseNi, run } from "@antfu/ni";
|
|
6
7
|
import { ensurePrefix, slash } from "@antfu/utils";
|
|
7
|
-
import { resolveGlobal } from "resolve-global";
|
|
8
|
-
import { findClosestPkgJsonPath, findDepPkgJsonPath } from "vitefu";
|
|
9
|
-
import { resolvePath } from "mlly";
|
|
10
8
|
import globalDirs from "global-directory";
|
|
11
|
-
import prompts from "prompts";
|
|
12
|
-
import { parseNi, run } from "@antfu/ni";
|
|
13
9
|
import { underline, yellow } from "kolorist";
|
|
10
|
+
import { resolvePath } from "mlly";
|
|
11
|
+
import prompts from "prompts";
|
|
12
|
+
import { resolveGlobal } from "resolve-global";
|
|
13
|
+
import { findClosestPkgJsonPath, findDepPkgJsonPath } from "vitefu";
|
|
14
14
|
var cliRoot = fileURLToPath(new URL("..", import.meta.url));
|
|
15
15
|
var isInstalledGlobally = {};
|
|
16
16
|
async function resolveImportUrl(id) {
|