@slidev/cli 0.42.4 → 0.42.6
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/bin/slidev.js +1 -0
- package/dist/{build-KVCLJMZB.mjs → build-4X66UIV5.mjs} +1 -1
- package/dist/{build-3TQML4LL.js → build-V5TH5VWM.js} +5 -5
- package/dist/{chunk-LNT2WGUR.js → chunk-42FDW3LK.js} +378 -307
- package/dist/{chunk-3JYF6GOD.mjs → chunk-FP2Y7WJ3.mjs} +82 -43
- package/dist/{chunk-X2K32WHH.js → chunk-OFNPVCQ3.js} +83 -44
- package/dist/{chunk-HO4HKNKG.mjs → chunk-T4MW747S.mjs} +375 -304
- package/dist/cli.d.mts +2 -0
- package/dist/cli.js +56 -44
- package/dist/cli.mjs +16 -4
- package/dist/index.d.mts +100 -0
- package/dist/index.js +3 -3
- package/dist/index.mjs +2 -2
- package/package.json +24 -22
|
@@ -116,6 +116,7 @@ async function mergeViteConfigs({ addonRoots, themeRoots }, viteConfig, config,
|
|
|
116
116
|
// node/plugins/preset.ts
|
|
117
117
|
import { join as join8 } from "path";
|
|
118
118
|
import { existsSync as existsSync4 } from "fs";
|
|
119
|
+
import process3 from "process";
|
|
119
120
|
import Vue from "@vitejs/plugin-vue";
|
|
120
121
|
import VueJsx from "@vitejs/plugin-vue-jsx";
|
|
121
122
|
import Icons from "unplugin-icons/vite";
|
|
@@ -183,32 +184,32 @@ import { uniq as uniq2 } from "@antfu/utils";
|
|
|
183
184
|
|
|
184
185
|
// ../client/package.json
|
|
185
186
|
var dependencies = {
|
|
186
|
-
"@antfu/utils": "^0.7.
|
|
187
|
+
"@antfu/utils": "^0.7.5",
|
|
187
188
|
"@slidev/parser": "workspace:*",
|
|
188
189
|
"@slidev/types": "workspace:*",
|
|
189
|
-
"@unocss/reset": "^0.
|
|
190
|
-
"@vueuse/core": "^10.
|
|
190
|
+
"@unocss/reset": "^0.54.1",
|
|
191
|
+
"@vueuse/core": "^10.3.0",
|
|
191
192
|
"@vueuse/head": "^1.1.26",
|
|
192
|
-
"@vueuse/math": "^10.
|
|
193
|
+
"@vueuse/math": "^10.3.0",
|
|
193
194
|
"@vueuse/motion": "^2.0.0",
|
|
194
195
|
codemirror: "^5.65.5",
|
|
195
196
|
defu: "^6.1.2",
|
|
196
|
-
drauu: "^0.3.
|
|
197
|
+
drauu: "^0.3.3",
|
|
197
198
|
"file-saver": "^2.0.5",
|
|
198
199
|
"fuse.js": "^6.6.2",
|
|
199
200
|
"js-base64": "^3.7.5",
|
|
200
201
|
"js-yaml": "^4.1.0",
|
|
201
|
-
katex: "^0.16.
|
|
202
|
-
mermaid: "^10.
|
|
202
|
+
katex: "^0.16.8",
|
|
203
|
+
mermaid: "^10.3.0",
|
|
203
204
|
"monaco-editor": "^0.37.1",
|
|
204
205
|
nanoid: "^4.0.2",
|
|
205
|
-
prettier: "^
|
|
206
|
+
prettier: "^3.0.0",
|
|
206
207
|
recordrtc: "^5.6.2",
|
|
207
208
|
resolve: "^1.22.2",
|
|
208
|
-
unocss: "^0.
|
|
209
|
+
unocss: "^0.54.1",
|
|
209
210
|
"vite-plugin-windicss": "^1.9.0",
|
|
210
211
|
vue: "^3.3.4",
|
|
211
|
-
"vue-router": "^4.2.
|
|
212
|
+
"vue-router": "^4.2.4",
|
|
212
213
|
"vue-starport": "^0.3.0",
|
|
213
214
|
windicss: "^3.5.6"
|
|
214
215
|
};
|
|
@@ -299,9 +300,9 @@ function createConfigPlugin(options) {
|
|
|
299
300
|
"codemirror/mode/xml/xml",
|
|
300
301
|
"codemirror/mode/htmlmixed/htmlmixed",
|
|
301
302
|
"codemirror/addon/display/placeholder",
|
|
302
|
-
"prettier/
|
|
303
|
-
"prettier/
|
|
304
|
-
"prettier/
|
|
303
|
+
"prettier/plugins/babel",
|
|
304
|
+
"prettier/plugins/html",
|
|
305
|
+
"prettier/plugins/typescript",
|
|
305
306
|
"mermaid/dist/mermaid.esm.min.mjs",
|
|
306
307
|
"mermaid/dist/mermaid.esm.mjs",
|
|
307
308
|
"vite-plugin-vue-server-ref/client"
|
|
@@ -365,6 +366,7 @@ function getDefine(options) {
|
|
|
365
366
|
// node/plugins/loaders.ts
|
|
366
367
|
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
|
367
368
|
import { basename as basename2, join as join5 } from "path";
|
|
369
|
+
import process from "process";
|
|
368
370
|
import { isString, notNullish, objectMap, range, slash, uniq as uniq3 } from "@antfu/utils";
|
|
369
371
|
import fg2 from "fast-glob";
|
|
370
372
|
import fs4, { existsSync as existsSync2 } from "fs-extra";
|
|
@@ -418,7 +420,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
|
|
|
418
420
|
if (!match)
|
|
419
421
|
return next();
|
|
420
422
|
const [, no, type] = match;
|
|
421
|
-
const idx = parseInt(no);
|
|
423
|
+
const idx = Number.parseInt(no);
|
|
422
424
|
if (type === "json" && req.method === "GET") {
|
|
423
425
|
res.write(JSON.stringify(prepareSlideInfo(data.slides[idx])));
|
|
424
426
|
return res.end();
|
|
@@ -553,7 +555,7 @@ ${title}
|
|
|
553
555
|
const match = remaning.match(regexIdQuery);
|
|
554
556
|
if (match) {
|
|
555
557
|
const [, no, type] = match;
|
|
556
|
-
const pageNo = parseInt(no) - 1;
|
|
558
|
+
const pageNo = Number.parseInt(no) - 1;
|
|
557
559
|
if (type === "md") {
|
|
558
560
|
return {
|
|
559
561
|
code: (_a = data.slides[pageNo]) == null ? void 0 : _a.content,
|
|
@@ -581,7 +583,7 @@ ${title}
|
|
|
581
583
|
const [, no, type] = match;
|
|
582
584
|
if (type !== "md")
|
|
583
585
|
return;
|
|
584
|
-
const pageNo = parseInt(no) - 1;
|
|
586
|
+
const pageNo = Number.parseInt(no) - 1;
|
|
585
587
|
return transformMarkdown(code, pageNo, data);
|
|
586
588
|
}
|
|
587
589
|
},
|
|
@@ -804,36 +806,37 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
|
|
|
804
806
|
}
|
|
805
807
|
async function generateRoutes() {
|
|
806
808
|
const imports = [];
|
|
809
|
+
const redirects = [];
|
|
807
810
|
const layouts = await getLayouts();
|
|
808
811
|
imports.push(`import __layout__end from '${layouts.end}'`);
|
|
809
812
|
let no = 1;
|
|
810
|
-
const routes =
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
return [route, redirect];
|
|
831
|
-
}).flat().filter(notNullish)
|
|
832
|
-
];
|
|
813
|
+
const routes = data.slides.filter(({ frontmatter }) => !(frontmatter == null ? void 0 : frontmatter.disabled)).map((i, idx) => {
|
|
814
|
+
var _a, _b, _c;
|
|
815
|
+
imports.push(`import n${no} from '${slidePrefix}${idx + 1}.md'`);
|
|
816
|
+
const additions = {
|
|
817
|
+
slide: {
|
|
818
|
+
...prepareSlideInfo(i),
|
|
819
|
+
filepath: ((_a = i.source) == null ? void 0 : _a.filepath) || entry,
|
|
820
|
+
id: idx,
|
|
821
|
+
no
|
|
822
|
+
},
|
|
823
|
+
__clicksElements: [],
|
|
824
|
+
__preloaded: false
|
|
825
|
+
};
|
|
826
|
+
const meta = Object.assign({}, i.frontmatter, additions);
|
|
827
|
+
const route = `{ path: '${no}', name: 'page-${no}', component: n${no}, meta: ${JSON.stringify(meta)} }`;
|
|
828
|
+
if ((_b = i.frontmatter) == null ? void 0 : _b.routeAlias)
|
|
829
|
+
redirects.push(`{ path: '${(_c = i.frontmatter) == null ? void 0 : _c.routeAlias}', redirect: { path: '${no}' } }`);
|
|
830
|
+
no += 1;
|
|
831
|
+
return route;
|
|
832
|
+
});
|
|
833
833
|
const routesStr = `export default [
|
|
834
834
|
${routes.join(",\n")}
|
|
835
835
|
]`;
|
|
836
|
-
|
|
836
|
+
const redirectsStr = `export const redirects = [
|
|
837
|
+
${redirects.join(",\n")}
|
|
838
|
+
]`;
|
|
839
|
+
return [...imports, routesStr, redirectsStr].join("\n");
|
|
837
840
|
}
|
|
838
841
|
function generateConfigs() {
|
|
839
842
|
const config = { ...data.config, remote };
|
|
@@ -895,10 +898,11 @@ export default {
|
|
|
895
898
|
|
|
896
899
|
// node/plugins/monacoTransform.ts
|
|
897
900
|
import { join as join6 } from "path";
|
|
901
|
+
import process2 from "process";
|
|
898
902
|
import { slash as slash2 } from "@antfu/utils";
|
|
899
903
|
async function getPackageData(pkg) {
|
|
900
904
|
const { resolvePackageData } = await eval('import("vite")');
|
|
901
|
-
const info = resolvePackageData(pkg,
|
|
905
|
+
const info = resolvePackageData(pkg, process2.cwd());
|
|
902
906
|
if (!info)
|
|
903
907
|
return;
|
|
904
908
|
const typePath = info.data.types || info.data.typings;
|
|
@@ -1149,6 +1153,19 @@ function math_plugin(md2, options) {
|
|
|
1149
1153
|
// node/plugins/markdown-it-prism.ts
|
|
1150
1154
|
import Prism from "prismjs";
|
|
1151
1155
|
import loadLanguages from "prismjs/components/";
|
|
1156
|
+
import * as htmlparser2 from "htmlparser2";
|
|
1157
|
+
var Tag = class {
|
|
1158
|
+
constructor(tagname, attributes) {
|
|
1159
|
+
this.tagname = tagname;
|
|
1160
|
+
this.attributes = attributes;
|
|
1161
|
+
}
|
|
1162
|
+
asOpen() {
|
|
1163
|
+
return `<${this.tagname} ${Object.entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(" ")}>`;
|
|
1164
|
+
}
|
|
1165
|
+
asClosed() {
|
|
1166
|
+
return `</${this.tagname}>`;
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1152
1169
|
var DEFAULTS = {
|
|
1153
1170
|
plugins: [],
|
|
1154
1171
|
init: () => {
|
|
@@ -1187,10 +1204,32 @@ function selectLanguage(options, lang) {
|
|
|
1187
1204
|
}
|
|
1188
1205
|
function highlight(markdownit, options, text, lang) {
|
|
1189
1206
|
const [langToUse, prismLang] = selectLanguage(options, lang);
|
|
1190
|
-
|
|
1207
|
+
let code = text.trimEnd();
|
|
1208
|
+
code = prismLang ? highlightPrism(code, prismLang, langToUse) : markdownit.utils.escapeHtml(code);
|
|
1209
|
+
code = code.split(/\r?\n/g).map((line) => `<span class="line">${line}</span>`).join("\n");
|
|
1191
1210
|
const classAttribute = langToUse ? ` class="slidev-code ${markdownit.options.langPrefix}${markdownit.utils.escapeHtml(langToUse)}"` : "";
|
|
1192
1211
|
return escapeVueInCode(`<pre${classAttribute}><code>${code}</code></pre>`);
|
|
1193
1212
|
}
|
|
1213
|
+
function highlightPrism(code, prismLang, langToUse) {
|
|
1214
|
+
const openTags = [];
|
|
1215
|
+
const parser2 = new htmlparser2.Parser({
|
|
1216
|
+
onopentag(tagname, attributes) {
|
|
1217
|
+
openTags.push(new Tag(tagname, attributes));
|
|
1218
|
+
},
|
|
1219
|
+
onclosetag() {
|
|
1220
|
+
openTags.pop();
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
code = Prism.highlight(code, prismLang, langToUse);
|
|
1224
|
+
code = code.split(/\r?\n/g).map((line) => {
|
|
1225
|
+
const prefix = openTags.map((tag) => tag.asOpen()).join("");
|
|
1226
|
+
parser2.write(line);
|
|
1227
|
+
const postfix = openTags.reverse().map((tag) => tag.asClosed()).join("");
|
|
1228
|
+
return prefix + line + postfix;
|
|
1229
|
+
}).join("\n");
|
|
1230
|
+
parser2.end();
|
|
1231
|
+
return code;
|
|
1232
|
+
}
|
|
1194
1233
|
function checkLanguageOption(options, optionName) {
|
|
1195
1234
|
const language = options[optionName];
|
|
1196
1235
|
if (language !== void 0 && loadPrismLang(language) === void 0)
|
|
@@ -1564,7 +1603,7 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1564
1603
|
...remoteAssetsOptions
|
|
1565
1604
|
})) : null,
|
|
1566
1605
|
ServerRef({
|
|
1567
|
-
debug:
|
|
1606
|
+
debug: process3.env.NODE_ENV === "development",
|
|
1568
1607
|
state: {
|
|
1569
1608
|
sync: false,
|
|
1570
1609
|
nav: {
|
|
@@ -116,6 +116,7 @@ async function mergeViteConfigs({ addonRoots, themeRoots }, viteConfig, config,
|
|
|
116
116
|
// node/plugins/preset.ts
|
|
117
117
|
|
|
118
118
|
|
|
119
|
+
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
119
120
|
var _pluginvue = require('@vitejs/plugin-vue'); var _pluginvue2 = _interopRequireDefault(_pluginvue);
|
|
120
121
|
var _pluginvuejsx = require('@vitejs/plugin-vue-jsx'); var _pluginvuejsx2 = _interopRequireDefault(_pluginvuejsx);
|
|
121
122
|
var _vite3 = require('unplugin-icons/vite'); var _vite4 = _interopRequireDefault(_vite3);
|
|
@@ -183,32 +184,32 @@ var _isinstalledglobally = require('is-installed-globally'); var _isinstalledglo
|
|
|
183
184
|
|
|
184
185
|
// ../client/package.json
|
|
185
186
|
var dependencies = {
|
|
186
|
-
"@antfu/utils": "^0.7.
|
|
187
|
+
"@antfu/utils": "^0.7.5",
|
|
187
188
|
"@slidev/parser": "workspace:*",
|
|
188
189
|
"@slidev/types": "workspace:*",
|
|
189
|
-
"@unocss/reset": "^0.
|
|
190
|
-
"@vueuse/core": "^10.
|
|
190
|
+
"@unocss/reset": "^0.54.1",
|
|
191
|
+
"@vueuse/core": "^10.3.0",
|
|
191
192
|
"@vueuse/head": "^1.1.26",
|
|
192
|
-
"@vueuse/math": "^10.
|
|
193
|
+
"@vueuse/math": "^10.3.0",
|
|
193
194
|
"@vueuse/motion": "^2.0.0",
|
|
194
195
|
codemirror: "^5.65.5",
|
|
195
196
|
defu: "^6.1.2",
|
|
196
|
-
drauu: "^0.3.
|
|
197
|
+
drauu: "^0.3.3",
|
|
197
198
|
"file-saver": "^2.0.5",
|
|
198
199
|
"fuse.js": "^6.6.2",
|
|
199
200
|
"js-base64": "^3.7.5",
|
|
200
201
|
"js-yaml": "^4.1.0",
|
|
201
|
-
katex: "^0.16.
|
|
202
|
-
mermaid: "^10.
|
|
202
|
+
katex: "^0.16.8",
|
|
203
|
+
mermaid: "^10.3.0",
|
|
203
204
|
"monaco-editor": "^0.37.1",
|
|
204
205
|
nanoid: "^4.0.2",
|
|
205
|
-
prettier: "^
|
|
206
|
+
prettier: "^3.0.0",
|
|
206
207
|
recordrtc: "^5.6.2",
|
|
207
208
|
resolve: "^1.22.2",
|
|
208
|
-
unocss: "^0.
|
|
209
|
+
unocss: "^0.54.1",
|
|
209
210
|
"vite-plugin-windicss": "^1.9.0",
|
|
210
211
|
vue: "^3.3.4",
|
|
211
|
-
"vue-router": "^4.2.
|
|
212
|
+
"vue-router": "^4.2.4",
|
|
212
213
|
"vue-starport": "^0.3.0",
|
|
213
214
|
windicss: "^3.5.6"
|
|
214
215
|
};
|
|
@@ -299,9 +300,9 @@ function createConfigPlugin(options) {
|
|
|
299
300
|
"codemirror/mode/xml/xml",
|
|
300
301
|
"codemirror/mode/htmlmixed/htmlmixed",
|
|
301
302
|
"codemirror/addon/display/placeholder",
|
|
302
|
-
"prettier/
|
|
303
|
-
"prettier/
|
|
304
|
-
"prettier/
|
|
303
|
+
"prettier/plugins/babel",
|
|
304
|
+
"prettier/plugins/html",
|
|
305
|
+
"prettier/plugins/typescript",
|
|
305
306
|
"mermaid/dist/mermaid.esm.min.mjs",
|
|
306
307
|
"mermaid/dist/mermaid.esm.mjs",
|
|
307
308
|
"vite-plugin-vue-server-ref/client"
|
|
@@ -368,6 +369,7 @@ var import_fast_deep_equal = _chunkMJQETB73js.__toESM.call(void 0, require_fast_
|
|
|
368
369
|
|
|
369
370
|
|
|
370
371
|
|
|
372
|
+
|
|
371
373
|
var _markdownit = require('markdown-it'); var _markdownit2 = _interopRequireDefault(_markdownit);
|
|
372
374
|
var _markdownitlinkattributes = require('markdown-it-link-attributes'); var _markdownitlinkattributes2 = _interopRequireDefault(_markdownitlinkattributes);
|
|
373
375
|
var _fs3 = require('@slidev/parser/fs'); var parser = _interopRequireWildcard(_fs3);
|
|
@@ -418,7 +420,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
|
|
|
418
420
|
if (!match)
|
|
419
421
|
return next();
|
|
420
422
|
const [, no, type] = match;
|
|
421
|
-
const idx = parseInt(no);
|
|
423
|
+
const idx = Number.parseInt(no);
|
|
422
424
|
if (type === "json" && req.method === "GET") {
|
|
423
425
|
res.write(JSON.stringify(prepareSlideInfo(data.slides[idx])));
|
|
424
426
|
return res.end();
|
|
@@ -553,7 +555,7 @@ ${title}
|
|
|
553
555
|
const match = remaning.match(regexIdQuery);
|
|
554
556
|
if (match) {
|
|
555
557
|
const [, no, type] = match;
|
|
556
|
-
const pageNo = parseInt(no) - 1;
|
|
558
|
+
const pageNo = Number.parseInt(no) - 1;
|
|
557
559
|
if (type === "md") {
|
|
558
560
|
return {
|
|
559
561
|
code: (_a = data.slides[pageNo]) == null ? void 0 : _a.content,
|
|
@@ -581,7 +583,7 @@ ${title}
|
|
|
581
583
|
const [, no, type] = match;
|
|
582
584
|
if (type !== "md")
|
|
583
585
|
return;
|
|
584
|
-
const pageNo = parseInt(no) - 1;
|
|
586
|
+
const pageNo = Number.parseInt(no) - 1;
|
|
585
587
|
return transformMarkdown(code, pageNo, data);
|
|
586
588
|
}
|
|
587
589
|
},
|
|
@@ -778,7 +780,7 @@ defineProps<{ no: number | string }>()`);
|
|
|
778
780
|
'import "virtual:windi-base.css"'
|
|
779
781
|
);
|
|
780
782
|
imports.push('import "virtual:windi-utilities.css"');
|
|
781
|
-
if (
|
|
783
|
+
if (_process2.default.env.NODE_ENV !== "production")
|
|
782
784
|
imports.push('import "virtual:windi-devtools"');
|
|
783
785
|
}
|
|
784
786
|
return imports.join("\n");
|
|
@@ -804,36 +806,37 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
|
|
|
804
806
|
}
|
|
805
807
|
async function generateRoutes() {
|
|
806
808
|
const imports = [];
|
|
809
|
+
const redirects = [];
|
|
807
810
|
const layouts = await getLayouts();
|
|
808
811
|
imports.push(`import __layout__end from '${layouts.end}'`);
|
|
809
812
|
let no = 1;
|
|
810
|
-
const routes =
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
return [route, redirect];
|
|
831
|
-
}).flat().filter(_utils.notNullish)
|
|
832
|
-
];
|
|
813
|
+
const routes = data.slides.filter(({ frontmatter }) => !(frontmatter == null ? void 0 : frontmatter.disabled)).map((i, idx) => {
|
|
814
|
+
var _a, _b, _c;
|
|
815
|
+
imports.push(`import n${no} from '${slidePrefix}${idx + 1}.md'`);
|
|
816
|
+
const additions = {
|
|
817
|
+
slide: {
|
|
818
|
+
...prepareSlideInfo(i),
|
|
819
|
+
filepath: ((_a = i.source) == null ? void 0 : _a.filepath) || entry,
|
|
820
|
+
id: idx,
|
|
821
|
+
no
|
|
822
|
+
},
|
|
823
|
+
__clicksElements: [],
|
|
824
|
+
__preloaded: false
|
|
825
|
+
};
|
|
826
|
+
const meta = Object.assign({}, i.frontmatter, additions);
|
|
827
|
+
const route = `{ path: '${no}', name: 'page-${no}', component: n${no}, meta: ${JSON.stringify(meta)} }`;
|
|
828
|
+
if ((_b = i.frontmatter) == null ? void 0 : _b.routeAlias)
|
|
829
|
+
redirects.push(`{ path: '${(_c = i.frontmatter) == null ? void 0 : _c.routeAlias}', redirect: { path: '${no}' } }`);
|
|
830
|
+
no += 1;
|
|
831
|
+
return route;
|
|
832
|
+
});
|
|
833
833
|
const routesStr = `export default [
|
|
834
834
|
${routes.join(",\n")}
|
|
835
835
|
]`;
|
|
836
|
-
|
|
836
|
+
const redirectsStr = `export const redirects = [
|
|
837
|
+
${redirects.join(",\n")}
|
|
838
|
+
]`;
|
|
839
|
+
return [...imports, routesStr, redirectsStr].join("\n");
|
|
837
840
|
}
|
|
838
841
|
function generateConfigs() {
|
|
839
842
|
const config = { ...data.config, remote };
|
|
@@ -896,9 +899,10 @@ export default {
|
|
|
896
899
|
// node/plugins/monacoTransform.ts
|
|
897
900
|
|
|
898
901
|
|
|
902
|
+
|
|
899
903
|
async function getPackageData(pkg) {
|
|
900
904
|
const { resolvePackageData } = await eval('import("vite")');
|
|
901
|
-
const info = resolvePackageData(pkg,
|
|
905
|
+
const info = resolvePackageData(pkg, _process2.default.cwd());
|
|
902
906
|
if (!info)
|
|
903
907
|
return;
|
|
904
908
|
const typePath = info.data.types || info.data.typings;
|
|
@@ -1149,6 +1153,19 @@ function math_plugin(md2, options) {
|
|
|
1149
1153
|
// node/plugins/markdown-it-prism.ts
|
|
1150
1154
|
var _prismjs = require('prismjs'); var _prismjs2 = _interopRequireDefault(_prismjs);
|
|
1151
1155
|
var _ = require('prismjs/components/'); var _2 = _interopRequireDefault(_);
|
|
1156
|
+
var _htmlparser2 = require('htmlparser2'); var htmlparser2 = _interopRequireWildcard(_htmlparser2);
|
|
1157
|
+
var Tag = class {
|
|
1158
|
+
constructor(tagname, attributes) {
|
|
1159
|
+
this.tagname = tagname;
|
|
1160
|
+
this.attributes = attributes;
|
|
1161
|
+
}
|
|
1162
|
+
asOpen() {
|
|
1163
|
+
return `<${this.tagname} ${Object.entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(" ")}>`;
|
|
1164
|
+
}
|
|
1165
|
+
asClosed() {
|
|
1166
|
+
return `</${this.tagname}>`;
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1152
1169
|
var DEFAULTS = {
|
|
1153
1170
|
plugins: [],
|
|
1154
1171
|
init: () => {
|
|
@@ -1187,10 +1204,32 @@ function selectLanguage(options, lang) {
|
|
|
1187
1204
|
}
|
|
1188
1205
|
function highlight(markdownit, options, text, lang) {
|
|
1189
1206
|
const [langToUse, prismLang] = selectLanguage(options, lang);
|
|
1190
|
-
|
|
1207
|
+
let code = text.trimEnd();
|
|
1208
|
+
code = prismLang ? highlightPrism(code, prismLang, langToUse) : markdownit.utils.escapeHtml(code);
|
|
1209
|
+
code = code.split(/\r?\n/g).map((line) => `<span class="line">${line}</span>`).join("\n");
|
|
1191
1210
|
const classAttribute = langToUse ? ` class="slidev-code ${markdownit.options.langPrefix}${markdownit.utils.escapeHtml(langToUse)}"` : "";
|
|
1192
1211
|
return escapeVueInCode(`<pre${classAttribute}><code>${code}</code></pre>`);
|
|
1193
1212
|
}
|
|
1213
|
+
function highlightPrism(code, prismLang, langToUse) {
|
|
1214
|
+
const openTags = [];
|
|
1215
|
+
const parser2 = new htmlparser2.Parser({
|
|
1216
|
+
onopentag(tagname, attributes) {
|
|
1217
|
+
openTags.push(new Tag(tagname, attributes));
|
|
1218
|
+
},
|
|
1219
|
+
onclosetag() {
|
|
1220
|
+
openTags.pop();
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
code = _prismjs2.default.highlight(code, prismLang, langToUse);
|
|
1224
|
+
code = code.split(/\r?\n/g).map((line) => {
|
|
1225
|
+
const prefix = openTags.map((tag) => tag.asOpen()).join("");
|
|
1226
|
+
parser2.write(line);
|
|
1227
|
+
const postfix = openTags.reverse().map((tag) => tag.asClosed()).join("");
|
|
1228
|
+
return prefix + line + postfix;
|
|
1229
|
+
}).join("\n");
|
|
1230
|
+
parser2.end();
|
|
1231
|
+
return code;
|
|
1232
|
+
}
|
|
1194
1233
|
function checkLanguageOption(options, optionName) {
|
|
1195
1234
|
const language = options[optionName];
|
|
1196
1235
|
if (language !== void 0 && loadPrismLang(language) === void 0)
|
|
@@ -1564,7 +1603,7 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1564
1603
|
...remoteAssetsOptions
|
|
1565
1604
|
})) : null,
|
|
1566
1605
|
_vitepluginvueserverref2.default.call(void 0, {
|
|
1567
|
-
debug:
|
|
1606
|
+
debug: _process2.default.env.NODE_ENV === "development",
|
|
1568
1607
|
state: {
|
|
1569
1608
|
sync: false,
|
|
1570
1609
|
nav: {
|