@slidev/cli 0.33.0 → 0.34.1
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 +2 -3
- package/dist/{build-P4Q57V2J.mjs → build-AZXVYLTZ.mjs} +4 -5
- package/dist/{build-JMQRM5SA.js → build-ONMHHPBT.js} +13 -14
- package/dist/{chunk-C7GPMAIX.mjs → chunk-BQ63PXSA.mjs} +121 -60
- package/dist/{chunk-UNBXPUSG.js → chunk-FD6XUAB4.js} +162 -101
- package/dist/{chunk-ZWCVPYOA.mjs → chunk-GVA336JI.mjs} +2 -34
- package/dist/{chunk-JQEMHC65.js → chunk-PNKOKFFZ.js} +172 -171
- package/dist/{chunk-FFZLS6QK.js → chunk-SQLX75IO.js} +3 -35
- package/dist/{chunk-ORQ3SHUX.mjs → chunk-VO7LIZVO.mjs} +40 -39
- package/dist/cli.js +28 -25
- package/dist/cli.mjs +9 -6
- package/dist/{export-5R6FV775.mjs → export-5OVMZQWE.mjs} +1 -1
- package/dist/{export-LOKLMK66.js → export-TH7MNEXN.js} +4 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +3 -3
- package/package.json +21 -19
package/README.md
CHANGED
|
@@ -27,7 +27,6 @@ Presentation <b>slide</b>s for <b>dev</b>elopers 🧑💻👩💻👨
|
|
|
27
27
|
<tbody>
|
|
28
28
|
<td align="center">
|
|
29
29
|
<img width="2000" height="0"><br>
|
|
30
|
-
Status: <b>Public Beta 🎉</b><br>
|
|
31
30
|
<sub>Made possible by my <a href="https://github.com/sponsors/antfu">Sponsor Program 💖</a></sub><br>
|
|
32
31
|
<img width="2000" height="0">
|
|
33
32
|
</td>
|
|
@@ -40,7 +39,7 @@ Status: <b>Public Beta 🎉</b><br>
|
|
|
40
39
|
- 📝 [**Markdown-based**](https://sli.dev/guide/syntax.html) - use your favorite editors and workflow
|
|
41
40
|
- 🧑💻 [**Developer Friendly**](https://sli.dev/guide/syntax.html#code-blocks) - built-in syntax highlighting, live coding, etc.
|
|
42
41
|
- 🎨 [**Themable**](https://sli.dev/themes/gallery.html) - theme can be shared and used with npm packages.
|
|
43
|
-
- 🌈 [**Stylish**](https://sli.dev/guide/syntax.html#embedded-styles) - [Windi CSS](https://windicss.org/)
|
|
42
|
+
- 🌈 [**Stylish**](https://sli.dev/guide/syntax.html#embedded-styles) - on-demand utilities via [Windi CSS](https://windicss.org/) or [UnoCSS](https://github.com/unocss/unocss).
|
|
44
43
|
- 🤹 [**Interactive**](https://sli.dev/custom/directory-structure.html#components) - embedding Vue components seamlessly.
|
|
45
44
|
- 🎙 [**Presenter Mode**](https://sli.dev/guide/presenter-mode.html) - use another window, or even your phone to control your slides.
|
|
46
45
|
- 🧮 [**LaTeX**](https://sli.dev/guide/syntax.html#latex) - built-in LaTeX math equations support.
|
|
@@ -79,7 +78,7 @@ For a full example, you can check the [demo](https://github.com/slidevjs/slidev/
|
|
|
79
78
|
|
|
80
79
|
- [Vite](https://vitejs.dev) - An extremely fast frontend tooling
|
|
81
80
|
- [Vue 3](https://v3.vuejs.org/) powered [Markdown](https://daringfireball.net/projects/markdown/syntax) - Focus on the content while having the power of HTML and Vue components whenever needed
|
|
82
|
-
- [Windi CSS](https://github.com/windicss/windicss) - On-demand utility-first CSS framework, style your slides at ease
|
|
81
|
+
- [Windi CSS](https://github.com/windicss/windicss) / [UnoCSS](https://github.com/unocss/unocss) - On-demand utility-first CSS framework, style your slides at ease
|
|
83
82
|
- [Prism](https://github.com/PrismJS/prism), [Shiki](https://github.com/shikijs/shiki), [Monaco Editor](https://github.com/Microsoft/monaco-editor) - First-class code snippets support with live coding capability
|
|
84
83
|
- [RecordRTC](https://recordrtc.org) - Built-in recording and camera view
|
|
85
84
|
- [VueUse](https://vueuse.org) family - [`@vueuse/core`](https://github.com/vueuse/vueuse), [`@vueuse/head`](https://github.com/vueuse/head), [`@vueuse/motion`](https://github.com/vueuse/motion), etc.
|
|
@@ -2,13 +2,12 @@ import {
|
|
|
2
2
|
ViteSlidevPlugin,
|
|
3
3
|
getIndexHtml,
|
|
4
4
|
mergeViteConfigs
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BQ63PXSA.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__require,
|
|
8
|
-
__spreadValues,
|
|
9
8
|
__toESM,
|
|
10
9
|
init_esm_shims
|
|
11
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GVA336JI.mjs";
|
|
12
11
|
|
|
13
12
|
// node/build.ts
|
|
14
13
|
init_esm_shims();
|
|
@@ -528,7 +527,7 @@ function is404(req, res) {
|
|
|
528
527
|
}
|
|
529
528
|
function send(req, res, file, stats, headers) {
|
|
530
529
|
let code = 200, tmp, opts = {};
|
|
531
|
-
headers =
|
|
530
|
+
headers = { ...headers };
|
|
532
531
|
for (let key in headers) {
|
|
533
532
|
tmp = res.getHeader(key);
|
|
534
533
|
if (tmp)
|
|
@@ -714,7 +713,7 @@ async function build(options, viteConfig = {}) {
|
|
|
714
713
|
await fs2.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
|
|
715
714
|
`, "utf-8");
|
|
716
715
|
if ([true, "true", "auto"].includes(options.data.config.download)) {
|
|
717
|
-
const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-
|
|
716
|
+
const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-5OVMZQWE.mjs")));
|
|
718
717
|
const port = 12445;
|
|
719
718
|
const app = connect();
|
|
720
719
|
const server = http.createServer(app);
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkFD6XUAB4js = require('./chunk-FD6XUAB4.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
var _chunkFFZLS6QKjs = require('./chunk-FFZLS6QK.js');
|
|
10
|
+
var _chunkSQLX75IOjs = require('./chunk-SQLX75IO.js');
|
|
12
11
|
|
|
13
12
|
// node/build.ts
|
|
14
|
-
|
|
13
|
+
_chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
|
|
15
14
|
var _path = require('path');
|
|
16
15
|
var _http = require('http'); var _http2 = _interopRequireDefault(_http);
|
|
17
16
|
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
@@ -19,12 +18,12 @@ var _vite = require('vite');
|
|
|
19
18
|
var _connect = require('connect'); var _connect2 = _interopRequireDefault(_connect);
|
|
20
19
|
|
|
21
20
|
// ../../node_modules/.pnpm/sirv@2.0.2/node_modules/sirv/build.mjs
|
|
22
|
-
|
|
21
|
+
_chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
|
|
23
22
|
var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
// ../../node_modules/.pnpm/totalist@3.0.0/node_modules/totalist/sync/index.mjs
|
|
27
|
-
|
|
26
|
+
_chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
function totalist(dir, callback, pre = "") {
|
|
@@ -39,7 +38,7 @@ function totalist(dir, callback, pre = "") {
|
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
// ../../node_modules/.pnpm/@polka+url@1.0.0-next.21/node_modules/@polka/url/build.mjs
|
|
42
|
-
|
|
41
|
+
_chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
|
|
43
42
|
var _querystring = require('querystring'); var qs = _interopRequireWildcard(_querystring);
|
|
44
43
|
function parse2(req) {
|
|
45
44
|
let raw = req.url;
|
|
@@ -63,7 +62,7 @@ function parse2(req) {
|
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
// ../../node_modules/.pnpm/mrmime@1.0.0/node_modules/mrmime/index.mjs
|
|
66
|
-
|
|
65
|
+
_chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
|
|
67
66
|
var mimes = {
|
|
68
67
|
"ez": "application/andrew-inset",
|
|
69
68
|
"aw": "application/applixware",
|
|
@@ -528,7 +527,7 @@ function is404(req, res) {
|
|
|
528
527
|
}
|
|
529
528
|
function send(req, res, file, stats, headers) {
|
|
530
529
|
let code = 200, tmp, opts = {};
|
|
531
|
-
headers =
|
|
530
|
+
headers = { ...headers };
|
|
532
531
|
for (let key in headers) {
|
|
533
532
|
tmp = res.getHeader(key);
|
|
534
533
|
if (tmp)
|
|
@@ -656,13 +655,13 @@ async function build(options, viteConfig = {}) {
|
|
|
656
655
|
let originalIndexHTML;
|
|
657
656
|
if (_fsextra2.default.existsSync(indexPath))
|
|
658
657
|
originalIndexHTML = await _fsextra2.default.readFile(indexPath, "utf-8");
|
|
659
|
-
await _fsextra2.default.writeFile(indexPath, await
|
|
658
|
+
await _fsextra2.default.writeFile(indexPath, await _chunkFD6XUAB4js.getIndexHtml.call(void 0, options), "utf-8");
|
|
660
659
|
let config = void 0;
|
|
661
660
|
try {
|
|
662
|
-
const inlineConfig = await
|
|
661
|
+
const inlineConfig = await _chunkFD6XUAB4js.mergeViteConfigs.call(void 0, options, viteConfig, {
|
|
663
662
|
root: options.userRoot,
|
|
664
663
|
plugins: [
|
|
665
|
-
await
|
|
664
|
+
await _chunkFD6XUAB4js.ViteSlidevPlugin.call(void 0, options, pluginOptions),
|
|
666
665
|
{
|
|
667
666
|
name: "resolve-config",
|
|
668
667
|
configResolved(_config) {
|
|
@@ -680,7 +679,7 @@ async function build(options, viteConfig = {}) {
|
|
|
680
679
|
console.log(_kolorist.yellow.call(void 0, " Monaco is disabled in the build, to enabled it, set `monaco: true` in the frontmatter"));
|
|
681
680
|
} else {
|
|
682
681
|
console.log(_kolorist.blue.call(void 0, " building for Monaco...\n"));
|
|
683
|
-
await _vite.build.call(void 0, await
|
|
682
|
+
await _vite.build.call(void 0, await _chunkFD6XUAB4js.mergeViteConfigs.call(void 0, options, inlineConfig, {
|
|
684
683
|
root: _path.join.call(void 0, options.clientRoot, "iframes/monaco"),
|
|
685
684
|
base: `${config.base}iframes/monaco/`,
|
|
686
685
|
build: {
|
|
@@ -714,7 +713,7 @@ async function build(options, viteConfig = {}) {
|
|
|
714
713
|
await _fsextra2.default.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
|
|
715
714
|
`, "utf-8");
|
|
716
715
|
if ([true, "true", "auto"].includes(options.data.config.download)) {
|
|
717
|
-
const { exportSlides } = await Promise.resolve().then(() =>
|
|
716
|
+
const { exportSlides } = await Promise.resolve().then(() => _chunkSQLX75IOjs.__toESM.call(void 0, _chunkSQLX75IOjs.__require.call(void 0, "./export-TH7MNEXN.js")));
|
|
718
717
|
const port = 12445;
|
|
719
718
|
const app = _connect2.default.call(void 0, );
|
|
720
719
|
const server = _http2.default.createServer(app);
|
|
@@ -2,8 +2,6 @@ import {
|
|
|
2
2
|
__commonJS,
|
|
3
3
|
__filename,
|
|
4
4
|
__require,
|
|
5
|
-
__spreadProps,
|
|
6
|
-
__spreadValues,
|
|
7
5
|
__toESM,
|
|
8
6
|
generateGoogleFontsUrl,
|
|
9
7
|
init_esm_shims,
|
|
@@ -11,7 +9,7 @@ import {
|
|
|
11
9
|
resolveImportPath,
|
|
12
10
|
stringifyMarkdownTokens,
|
|
13
11
|
toAtFS
|
|
14
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GVA336JI.mjs";
|
|
15
13
|
|
|
16
14
|
// ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
|
|
17
15
|
var require_fast_deep_equal = __commonJS({
|
|
@@ -118,7 +116,6 @@ init_esm_shims();
|
|
|
118
116
|
import { dirname, resolve as resolve2 } from "path";
|
|
119
117
|
import { existsSync as existsSync3 } from "fs";
|
|
120
118
|
import { slash, uniq as uniq2 } from "@antfu/utils";
|
|
121
|
-
import WindiCSS, { defaultConfigureFiles } from "vite-plugin-windicss";
|
|
122
119
|
import jiti2 from "jiti";
|
|
123
120
|
|
|
124
121
|
// node/plugins/setupNode.ts
|
|
@@ -128,7 +125,7 @@ import { existsSync as existsSync2 } from "fs-extra";
|
|
|
128
125
|
import { isObject } from "@antfu/utils";
|
|
129
126
|
import jiti from "jiti";
|
|
130
127
|
function deepMerge(a, b, rootPath = "") {
|
|
131
|
-
a =
|
|
128
|
+
a = { ...a };
|
|
132
129
|
Object.keys(b).forEach((key) => {
|
|
133
130
|
if (isObject(a[key]))
|
|
134
131
|
a[key] = deepMerge(a[key], b[key], rootPath ? `${rootPath}.${key}` : key);
|
|
@@ -156,6 +153,7 @@ async function loadSetups(roots, name, arg, initial, merge = true) {
|
|
|
156
153
|
|
|
157
154
|
// node/plugins/windicss.ts
|
|
158
155
|
async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRoot, roots, data }, { windicss: windiOptions }) {
|
|
156
|
+
const { default: WindiCSS, defaultConfigureFiles } = await Promise.resolve().then(() => __toESM(__require("vite-plugin-windicss")));
|
|
159
157
|
const configFiles = uniq2([
|
|
160
158
|
...defaultConfigureFiles.map((i) => resolve2(userRoot, i)),
|
|
161
159
|
...themeRoots.map((i) => `${i}/windi.config.ts`),
|
|
@@ -167,7 +165,7 @@ async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRo
|
|
|
167
165
|
if (config.default)
|
|
168
166
|
config = config.default;
|
|
169
167
|
config = await loadSetups(roots, "windicss.ts", {}, config, true);
|
|
170
|
-
return WindiCSS(
|
|
168
|
+
return WindiCSS({
|
|
171
169
|
configFiles: [configFile],
|
|
172
170
|
config,
|
|
173
171
|
onConfigResolved(config2) {
|
|
@@ -196,8 +194,9 @@ async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRo
|
|
|
196
194
|
config2.scanOptions.exclude.push(dirname(resolveImportPath("monaco-editor/package.json", true)));
|
|
197
195
|
config2.scanOptions.exclude.push(dirname(resolveImportPath("katex/package.json", true)));
|
|
198
196
|
config2.scanOptions.exclude.push(dirname(resolveImportPath("prettier/package.json", true)));
|
|
199
|
-
}
|
|
200
|
-
|
|
197
|
+
},
|
|
198
|
+
...windiOptions
|
|
199
|
+
});
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
// node/plugins/preset.ts
|
|
@@ -268,7 +267,8 @@ var dependencies = {
|
|
|
268
267
|
"@antfu/utils": "^0.5.2",
|
|
269
268
|
"@slidev/parser": "workspace:*",
|
|
270
269
|
"@slidev/types": "workspace:*",
|
|
271
|
-
"@
|
|
270
|
+
"@unocss/reset": "^0.42.0",
|
|
271
|
+
"@vueuse/core": "^8.7.5",
|
|
272
272
|
"@vueuse/head": "^0.7.6",
|
|
273
273
|
"@vueuse/motion": "^2.0.0-beta.18",
|
|
274
274
|
codemirror: "^5.65.5",
|
|
@@ -277,18 +277,19 @@ var dependencies = {
|
|
|
277
277
|
"file-saver": "^2.0.5",
|
|
278
278
|
"js-base64": "^3.7.2",
|
|
279
279
|
"js-yaml": "^4.1.0",
|
|
280
|
-
katex: "^0.
|
|
281
|
-
mermaid: "^9.1.
|
|
280
|
+
katex: "^0.16.0",
|
|
281
|
+
mermaid: "^9.1.3",
|
|
282
282
|
"monaco-editor": "^0.33.0",
|
|
283
|
-
nanoid: "^
|
|
284
|
-
prettier: "^2.
|
|
283
|
+
nanoid: "^4.0.0",
|
|
284
|
+
prettier: "^2.7.1",
|
|
285
285
|
recordrtc: "^5.6.2",
|
|
286
|
-
resolve: "^1.22.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
"vue-
|
|
291
|
-
|
|
286
|
+
resolve: "^1.22.1",
|
|
287
|
+
unocss: "^0.42.0",
|
|
288
|
+
"vite-plugin-windicss": "^1.8.6",
|
|
289
|
+
vue: "^3.2.37",
|
|
290
|
+
"vue-router": "^4.0.16",
|
|
291
|
+
"vue-starport": "^0.3.0",
|
|
292
|
+
windicss: "^3.5.5"
|
|
292
293
|
};
|
|
293
294
|
|
|
294
295
|
// node/vite/searchRoot.ts
|
|
@@ -340,6 +341,8 @@ var EXCLUDE = [
|
|
|
340
341
|
"@slidev/types",
|
|
341
342
|
"@vueuse/core",
|
|
342
343
|
"@vueuse/shared",
|
|
344
|
+
"@unocss/reset",
|
|
345
|
+
"unocss",
|
|
343
346
|
"mermaid",
|
|
344
347
|
"vite-plugin-windicss",
|
|
345
348
|
"vue-demi"
|
|
@@ -347,7 +350,7 @@ var EXCLUDE = [
|
|
|
347
350
|
function createConfigPlugin(options) {
|
|
348
351
|
return {
|
|
349
352
|
name: "slidev:config",
|
|
350
|
-
config(config) {
|
|
353
|
+
async config(config) {
|
|
351
354
|
const injection = {
|
|
352
355
|
define: getDefine(options),
|
|
353
356
|
resolve: {
|
|
@@ -373,6 +376,13 @@ function createConfigPlugin(options) {
|
|
|
373
376
|
],
|
|
374
377
|
exclude: EXCLUDE
|
|
375
378
|
},
|
|
379
|
+
css: options.data.config.css === "unocss" ? {
|
|
380
|
+
postcss: {
|
|
381
|
+
plugins: [
|
|
382
|
+
await Promise.resolve().then(() => __toESM(__require("postcss-nested"))).then((r) => r.default())
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
} : {},
|
|
376
386
|
server: {
|
|
377
387
|
fs: {
|
|
378
388
|
strict: true,
|
|
@@ -431,13 +441,13 @@ import * as parser from "@slidev/parser/fs";
|
|
|
431
441
|
var regexId = /^\/\@slidev\/slide\/(\d+)\.(md|json)(?:\?import)?$/;
|
|
432
442
|
var regexIdQuery = /(\d+?)\.(md|json)$/;
|
|
433
443
|
function getBodyJson(req) {
|
|
434
|
-
return new Promise((
|
|
444
|
+
return new Promise((resolve6, reject) => {
|
|
435
445
|
let body = "";
|
|
436
446
|
req.on("data", (chunk) => body += chunk);
|
|
437
447
|
req.on("error", reject);
|
|
438
448
|
req.on("end", () => {
|
|
439
449
|
try {
|
|
440
|
-
|
|
450
|
+
resolve6(JSON.parse(body) || {});
|
|
441
451
|
} catch (e) {
|
|
442
452
|
reject(e);
|
|
443
453
|
}
|
|
@@ -452,9 +462,10 @@ md.use(mila, {
|
|
|
452
462
|
}
|
|
453
463
|
});
|
|
454
464
|
function prepareSlideInfo(data) {
|
|
455
|
-
return
|
|
465
|
+
return {
|
|
466
|
+
...data,
|
|
456
467
|
notesHTML: md.render((data == null ? void 0 : data.note) || "")
|
|
457
|
-
}
|
|
468
|
+
};
|
|
458
469
|
}
|
|
459
470
|
function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, userRoot, roots, remote }, pluginOptions, serverOptions, VuePlugin, MarkdownPlugin) {
|
|
460
471
|
const slidePrefix = "/@slidev/slides/";
|
|
@@ -543,13 +554,14 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
|
|
|
543
554
|
const file = `${slidePrefix}${i + 1}.md`;
|
|
544
555
|
try {
|
|
545
556
|
const md2 = await transformMarkdown(await MarkdownPlugin.transform((_a2 = newData.slides[i]) == null ? void 0 : _a2.content, file), i, newData);
|
|
546
|
-
return await VuePlugin.handleHotUpdate(
|
|
557
|
+
return await VuePlugin.handleHotUpdate({
|
|
558
|
+
...ctx,
|
|
547
559
|
modules: Array.from(ctx.server.moduleGraph.getModulesByFile(file) || []),
|
|
548
560
|
file,
|
|
549
561
|
read() {
|
|
550
562
|
return md2;
|
|
551
563
|
}
|
|
552
|
-
})
|
|
564
|
+
});
|
|
553
565
|
} catch {
|
|
554
566
|
}
|
|
555
567
|
}))).flatMap((i) => i || []);
|
|
@@ -592,7 +604,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
|
|
|
592
604
|
code: data.slides.map(({ title }, i) => {
|
|
593
605
|
return `<template ${i === 0 ? "v-if" : "v-else-if"}="+no === ${i + 1}">${title}</template>`;
|
|
594
606
|
}).join(""),
|
|
595
|
-
map: {}
|
|
607
|
+
map: { mappings: "" }
|
|
596
608
|
};
|
|
597
609
|
}
|
|
598
610
|
if (id.startsWith(slidePrefix)) {
|
|
@@ -604,13 +616,13 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
|
|
|
604
616
|
if (type === "md") {
|
|
605
617
|
return {
|
|
606
618
|
code: (_a = data.slides[pageNo]) == null ? void 0 : _a.content,
|
|
607
|
-
map: {}
|
|
619
|
+
map: { mappings: "" }
|
|
608
620
|
};
|
|
609
621
|
}
|
|
610
622
|
}
|
|
611
623
|
return {
|
|
612
624
|
code: "",
|
|
613
|
-
map: {}
|
|
625
|
+
map: { mappings: "" }
|
|
614
626
|
};
|
|
615
627
|
}
|
|
616
628
|
}
|
|
@@ -660,7 +672,10 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
|
|
|
660
672
|
async function transformMarkdown(code, pageNo, data2) {
|
|
661
673
|
var _a, _b;
|
|
662
674
|
const layouts = await getLayouts();
|
|
663
|
-
const frontmatter =
|
|
675
|
+
const frontmatter = {
|
|
676
|
+
...((_a = data2.headmatter) == null ? void 0 : _a.defaults) || {},
|
|
677
|
+
...((_b = data2.slides[pageNo]) == null ? void 0 : _b.frontmatter) || {}
|
|
678
|
+
};
|
|
664
679
|
const layoutName = (frontmatter == null ? void 0 : frontmatter.layout) || (pageNo === 0 ? "cover" : "default");
|
|
665
680
|
if (!layouts[layoutName])
|
|
666
681
|
throw new Error(`Unknown layout "${layoutName}"`);
|
|
@@ -797,6 +812,13 @@ defineProps<{ no: number | string }>()`);
|
|
|
797
812
|
}
|
|
798
813
|
if (data.features.katex)
|
|
799
814
|
imports.push(`import "${toAtFS(resolveImportPath("katex/dist/katex.min.css", true))}"`);
|
|
815
|
+
if (data.config.css === "unocss") {
|
|
816
|
+
imports.unshift('import "@unocss/reset/tailwind.css"', 'import "uno:preflights.css"', 'import "uno:typography.css"', 'import "uno:shortcuts.css"');
|
|
817
|
+
imports.push('import "uno.css"');
|
|
818
|
+
} else {
|
|
819
|
+
imports.unshift('import "virtual:windi-components.css"', 'import "virtual:windi-base.css"');
|
|
820
|
+
imports.push('import "virtual:windi-utilities.css"', 'import "virtual:windi-devtools"');
|
|
821
|
+
}
|
|
800
822
|
return imports.join("\n");
|
|
801
823
|
}
|
|
802
824
|
async function generateMonacoTypes() {
|
|
@@ -827,11 +849,12 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
|
|
|
827
849
|
return void 0;
|
|
828
850
|
imports.push(`import n${no} from '${slidePrefix}${idx + 1}.md'`);
|
|
829
851
|
const additions = {
|
|
830
|
-
slide:
|
|
852
|
+
slide: {
|
|
853
|
+
...prepareSlideInfo(i),
|
|
831
854
|
filepath: ((_b = i.source) == null ? void 0 : _b.filepath) || entry,
|
|
832
855
|
id: idx,
|
|
833
856
|
no
|
|
834
|
-
}
|
|
857
|
+
},
|
|
835
858
|
__clicksElements: [],
|
|
836
859
|
__preloaded: false
|
|
837
860
|
};
|
|
@@ -849,7 +872,7 @@ ${routes.join(",\n")}
|
|
|
849
872
|
return [...imports, routesStr].join("\n");
|
|
850
873
|
}
|
|
851
874
|
function generateConfigs() {
|
|
852
|
-
const config =
|
|
875
|
+
const config = { ...data.config, remote };
|
|
853
876
|
if (isString(config.title)) {
|
|
854
877
|
const tokens = md.parseInline(config.title, {});
|
|
855
878
|
config.title = stringifyMarkdownTokens(tokens);
|
|
@@ -993,7 +1016,7 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
|
|
|
993
1016
|
|
|
994
1017
|
// node/plugins/markdown.ts
|
|
995
1018
|
init_esm_shims();
|
|
996
|
-
import Markdown2 from "vite-plugin-
|
|
1019
|
+
import Markdown2 from "vite-plugin-vue-markdown";
|
|
997
1020
|
import * as base64 from "js-base64";
|
|
998
1021
|
import { slash as slash5 } from "@antfu/utils";
|
|
999
1022
|
import mila2 from "markdown-it-link-attributes";
|
|
@@ -1234,13 +1257,14 @@ function resolveShikiOptions(options) {
|
|
|
1234
1257
|
themes.push(options.theme);
|
|
1235
1258
|
}
|
|
1236
1259
|
}
|
|
1237
|
-
return
|
|
1260
|
+
return {
|
|
1261
|
+
...options,
|
|
1238
1262
|
themes,
|
|
1239
1263
|
darkModeThemes: darkModeThemes ? {
|
|
1240
1264
|
dark: getThemeName(darkModeThemes.dark),
|
|
1241
1265
|
light: getThemeName(darkModeThemes.light)
|
|
1242
1266
|
} : void 0
|
|
1243
|
-
}
|
|
1267
|
+
};
|
|
1244
1268
|
}
|
|
1245
1269
|
function trimEndNewLine(code) {
|
|
1246
1270
|
return code.replace(/\n$/, "");
|
|
@@ -1281,17 +1305,18 @@ async function createMarkdownPlugin({ data: { config }, roots, mode, entry }, {
|
|
|
1281
1305
|
setups.push((md2) => md2.use(markdownItPrism));
|
|
1282
1306
|
}
|
|
1283
1307
|
const KatexOptions = await loadSetups(roots, "katex.ts", {}, { strict: false }, false);
|
|
1284
|
-
return Markdown2(
|
|
1308
|
+
return Markdown2({
|
|
1285
1309
|
wrapperClasses: "",
|
|
1286
1310
|
headEnabled: false,
|
|
1287
1311
|
frontmatter: false,
|
|
1288
|
-
markdownItOptions:
|
|
1312
|
+
markdownItOptions: {
|
|
1289
1313
|
quotes: `""''`,
|
|
1290
1314
|
html: true,
|
|
1291
1315
|
xhtmlOut: true,
|
|
1292
|
-
linkify: true
|
|
1293
|
-
|
|
1294
|
-
|
|
1316
|
+
linkify: true,
|
|
1317
|
+
...mdOptions == null ? void 0 : mdOptions.markdownItOptions
|
|
1318
|
+
},
|
|
1319
|
+
...mdOptions,
|
|
1295
1320
|
markdownItSetup(md2) {
|
|
1296
1321
|
var _a;
|
|
1297
1322
|
md2.use(mila2, {
|
|
@@ -1319,7 +1344,7 @@ async function createMarkdownPlugin({ data: { config }, roots, mode, entry }, {
|
|
|
1319
1344
|
return code;
|
|
1320
1345
|
}
|
|
1321
1346
|
}
|
|
1322
|
-
})
|
|
1347
|
+
});
|
|
1323
1348
|
}
|
|
1324
1349
|
function transformMarkdownMonaco(md2) {
|
|
1325
1350
|
md2 = md2.replace(/^```(\w+?)\s*{monaco}\s*?({.*?})?\s*?\n([\s\S]+?)^```/mg, (full, lang = "ts", options = "{}", code) => {
|
|
@@ -1441,6 +1466,36 @@ function createFixPlugins(options) {
|
|
|
1441
1466
|
];
|
|
1442
1467
|
}
|
|
1443
1468
|
|
|
1469
|
+
// node/plugins/unocss.ts
|
|
1470
|
+
init_esm_shims();
|
|
1471
|
+
import { resolve as resolve5 } from "path";
|
|
1472
|
+
import { existsSync as existsSync6 } from "fs";
|
|
1473
|
+
import { deepMerge as deepMerge2, uniq as uniq6 } from "@antfu/utils";
|
|
1474
|
+
import jiti3 from "jiti";
|
|
1475
|
+
async function createUnocssPlugin({ themeRoots, addonRoots, clientRoot, roots, data }, { unocss: unoOptions }) {
|
|
1476
|
+
var _a, _b, _c, _d;
|
|
1477
|
+
const UnoCSS = await Promise.resolve().then(() => __toESM(__require("unocss/vite"))).then((r) => r.default);
|
|
1478
|
+
const configFiles = uniq6([
|
|
1479
|
+
...themeRoots.map((i) => `${i}/uno.config.ts`),
|
|
1480
|
+
...addonRoots.map((i) => `${i}/uno.config.ts`),
|
|
1481
|
+
resolve5(clientRoot, "uno.config.ts")
|
|
1482
|
+
]);
|
|
1483
|
+
const configFile = configFiles.find((i) => existsSync6(i));
|
|
1484
|
+
let config = jiti3(__filename)(configFile);
|
|
1485
|
+
if ("default" in config)
|
|
1486
|
+
config = config.default;
|
|
1487
|
+
config = await loadSetups(roots, "unocss.ts", {}, config, true);
|
|
1488
|
+
config.theme || (config.theme = {});
|
|
1489
|
+
(_a = config.theme).fontFamily || (_a.fontFamily = {});
|
|
1490
|
+
(_b = config.theme.fontFamily).sans || (_b.sans = data.config.fonts.sans.join(","));
|
|
1491
|
+
(_c = config.theme.fontFamily).mono || (_c.mono = data.config.fonts.mono.join(","));
|
|
1492
|
+
(_d = config.theme.fontFamily).serif || (_d.serif = data.config.fonts.serif.join(","));
|
|
1493
|
+
return UnoCSS({
|
|
1494
|
+
configFile: false,
|
|
1495
|
+
...deepMerge2(config, unoOptions || {})
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1444
1499
|
// node/plugins/preset.ts
|
|
1445
1500
|
var customElements = /* @__PURE__ */ new Set([
|
|
1446
1501
|
"annotation",
|
|
@@ -1486,25 +1541,27 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1486
1541
|
clientRoot,
|
|
1487
1542
|
data: { config }
|
|
1488
1543
|
} = options;
|
|
1489
|
-
const VuePlugin = Vue(
|
|
1544
|
+
const VuePlugin = Vue({
|
|
1490
1545
|
include: [/\.vue$/, /\.md$/],
|
|
1491
1546
|
exclude: [],
|
|
1492
|
-
template:
|
|
1547
|
+
template: {
|
|
1493
1548
|
compilerOptions: {
|
|
1494
1549
|
isCustomElement(tag) {
|
|
1495
1550
|
return customElements.has(tag);
|
|
1496
1551
|
}
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1552
|
+
},
|
|
1553
|
+
...vueOptions == null ? void 0 : vueOptions.template
|
|
1554
|
+
},
|
|
1555
|
+
...vueOptions
|
|
1556
|
+
});
|
|
1500
1557
|
const MarkdownPlugin = await createMarkdownPlugin(options, pluginOptions);
|
|
1501
1558
|
const drawingData = await loadDrawings(options);
|
|
1502
1559
|
return [
|
|
1503
|
-
await createWindiCSSPlugin(options, pluginOptions),
|
|
1560
|
+
config.css === "unocss" ? await createUnocssPlugin(options, pluginOptions) : await createWindiCSSPlugin(options, pluginOptions),
|
|
1504
1561
|
MarkdownPlugin,
|
|
1505
1562
|
VuePlugin,
|
|
1506
1563
|
createSlidesLoader(options, pluginOptions, serverOptions, VuePlugin, MarkdownPlugin),
|
|
1507
|
-
Components(
|
|
1564
|
+
Components({
|
|
1508
1565
|
extensions: ["vue", "md", "ts"],
|
|
1509
1566
|
dirs: [
|
|
1510
1567
|
`${clientRoot}/builtin`,
|
|
@@ -1521,13 +1578,15 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1521
1578
|
prefix: "",
|
|
1522
1579
|
customCollections: Object.keys(iconsOptions.customCollections || [])
|
|
1523
1580
|
})
|
|
1524
|
-
]
|
|
1525
|
-
|
|
1526
|
-
|
|
1581
|
+
],
|
|
1582
|
+
...componentsOptions
|
|
1583
|
+
}),
|
|
1584
|
+
Icons({
|
|
1527
1585
|
defaultClass: "slidev-icon",
|
|
1528
|
-
autoInstall: true
|
|
1529
|
-
|
|
1530
|
-
|
|
1586
|
+
autoInstall: true,
|
|
1587
|
+
...iconsOptions
|
|
1588
|
+
}),
|
|
1589
|
+
config.remoteAssets === true || config.remoteAssets === mode ? RemoteAssets({
|
|
1531
1590
|
rules: [
|
|
1532
1591
|
...DefaultRules,
|
|
1533
1592
|
{
|
|
@@ -1536,18 +1595,20 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1536
1595
|
}
|
|
1537
1596
|
],
|
|
1538
1597
|
resolveMode: (id) => id.endsWith("index.html") ? "relative" : "@fs",
|
|
1539
|
-
awaitDownload: mode === "build"
|
|
1540
|
-
|
|
1598
|
+
awaitDownload: mode === "build",
|
|
1599
|
+
...remoteAssetsOptions
|
|
1600
|
+
}) : null,
|
|
1541
1601
|
ServerRef({
|
|
1542
1602
|
debug: process.env.NODE_ENV === "development",
|
|
1543
|
-
state:
|
|
1603
|
+
state: {
|
|
1544
1604
|
sync: false,
|
|
1545
1605
|
nav: {
|
|
1546
1606
|
page: 0,
|
|
1547
1607
|
clicks: 0
|
|
1548
1608
|
},
|
|
1549
|
-
drawings: drawingData
|
|
1550
|
-
|
|
1609
|
+
drawings: drawingData,
|
|
1610
|
+
...serverRefOptions.state
|
|
1611
|
+
},
|
|
1551
1612
|
onChanged(key, data, patch, timestamp) {
|
|
1552
1613
|
serverRefOptions.onChanged && serverRefOptions.onChanged(key, data, patch, timestamp);
|
|
1553
1614
|
if (!options.data.config.drawings.persist)
|