@slidev/cli 0.43.7 → 0.43.9
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.mjs +3 -0
- package/dist/{build-E7VPPALW.mjs → build-O4767R4S.mjs} +5 -5
- package/dist/{chunk-CPYGYVJ2.mjs → chunk-2ZQP2W7X.mjs} +17 -13
- package/dist/{chunk-QHOBBTS4.mjs → chunk-65ITIFTL.mjs} +1 -9
- package/dist/{chunk-PZQGSMNY.mjs → chunk-AA5PR2W4.mjs} +4 -3
- package/dist/{chunk-PNMZABHE.mjs → chunk-CNR3FZCA.mjs} +36 -33
- package/dist/{chunk-43ON36K4.mjs → chunk-CYLMMBRG.mjs} +4 -3
- package/dist/{chunk-7MRMXJYO.mjs → chunk-P35Z4724.mjs} +6 -4
- package/dist/cli.mjs +27 -14
- package/dist/{export-GFE5VFSA.mjs → export-HQUH6WSD.mjs} +2 -2
- package/dist/index.mjs +6 -6
- package/dist/{unocss-EBBZWMQM.mjs → unocss-BTVZWCXM.mjs} +4 -3
- package/dist/windicss-GLRSRVVQ.mjs +9 -0
- package/package.json +18 -16
- package/bin/slidev.js +0 -15
- package/dist/build-BMXGJSEG.js +0 -748
- package/dist/chunk-CGJOXW6I.js +0 -71
- package/dist/chunk-CPRFICJ7.js +0 -65
- package/dist/chunk-GD5JWUM3.js +0 -1703
- package/dist/chunk-IJ6NBA73.js +0 -7836
- package/dist/chunk-UWTQKD35.js +0 -35
- package/dist/chunk-YUG22S6W.js +0 -38
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -500
- package/dist/export-EYYLD3O6.js +0 -381
- package/dist/index.d.ts +0 -100
- package/dist/index.js +0 -35
- package/dist/unocss-E5M4APXD.js +0 -45
- package/dist/windicss-5I6DSVQN.mjs +0 -9
- package/dist/windicss-G7ISUN5H.js +0 -9
package/dist/chunk-GD5JWUM3.js
DELETED
|
@@ -1,1703 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
var _chunkUWTQKD35js = require('./chunk-UWTQKD35.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunkCGJOXW6Ijs = require('./chunk-CGJOXW6I.js');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _chunkYUG22S6Wjs = require('./chunk-YUG22S6W.js');
|
|
16
|
-
|
|
17
|
-
// ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
|
|
18
|
-
var require_fast_deep_equal = _chunkYUG22S6Wjs.__commonJS.call(void 0, {
|
|
19
|
-
"../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js"(exports, module) {
|
|
20
|
-
"use strict";
|
|
21
|
-
module.exports = function equal2(a, b) {
|
|
22
|
-
if (a === b)
|
|
23
|
-
return true;
|
|
24
|
-
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
25
|
-
if (a.constructor !== b.constructor)
|
|
26
|
-
return false;
|
|
27
|
-
var length, i, keys;
|
|
28
|
-
if (Array.isArray(a)) {
|
|
29
|
-
length = a.length;
|
|
30
|
-
if (length != b.length)
|
|
31
|
-
return false;
|
|
32
|
-
for (i = length; i-- !== 0; )
|
|
33
|
-
if (!equal2(a[i], b[i]))
|
|
34
|
-
return false;
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
if (a.constructor === RegExp)
|
|
38
|
-
return a.source === b.source && a.flags === b.flags;
|
|
39
|
-
if (a.valueOf !== Object.prototype.valueOf)
|
|
40
|
-
return a.valueOf() === b.valueOf();
|
|
41
|
-
if (a.toString !== Object.prototype.toString)
|
|
42
|
-
return a.toString() === b.toString();
|
|
43
|
-
keys = Object.keys(a);
|
|
44
|
-
length = keys.length;
|
|
45
|
-
if (length !== Object.keys(b).length)
|
|
46
|
-
return false;
|
|
47
|
-
for (i = length; i-- !== 0; )
|
|
48
|
-
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
49
|
-
return false;
|
|
50
|
-
for (i = length; i-- !== 0; ) {
|
|
51
|
-
var key = keys[i];
|
|
52
|
-
if (!equal2(a[key], b[key]))
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return a !== a && b !== b;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// node/common.ts
|
|
63
|
-
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
64
|
-
var _path = require('path');
|
|
65
|
-
var _utils = require('@antfu/utils');
|
|
66
|
-
var _vite = require('vite');
|
|
67
|
-
async function getIndexHtml({ clientRoot, themeRoots, addonRoots, data, userRoot }) {
|
|
68
|
-
let main = await _fs.promises.readFile(_path.join.call(void 0, clientRoot, "index.html"), "utf-8");
|
|
69
|
-
let head = "";
|
|
70
|
-
let body = "";
|
|
71
|
-
head += `<link rel="icon" href="${data.config.favicon}">`;
|
|
72
|
-
const roots = _utils.uniq.call(void 0, [
|
|
73
|
-
...themeRoots,
|
|
74
|
-
...addonRoots,
|
|
75
|
-
userRoot
|
|
76
|
-
]);
|
|
77
|
-
for (const root of roots) {
|
|
78
|
-
const path = _path.join.call(void 0, root, "index.html");
|
|
79
|
-
if (!_fs.existsSync.call(void 0, path))
|
|
80
|
-
continue;
|
|
81
|
-
const index = await _fs.promises.readFile(path, "utf-8");
|
|
82
|
-
head += `
|
|
83
|
-
${(_optionalChain([index, 'access', _4 => _4.match, 'call', _5 => _5(/<head>([\s\S]*?)<\/head>/im), 'optionalAccess', _6 => _6[1]]) || "").trim()}`;
|
|
84
|
-
body += `
|
|
85
|
-
${(_optionalChain([index, 'access', _7 => _7.match, 'call', _8 => _8(/<body>([\s\S]*?)<\/body>/im), 'optionalAccess', _9 => _9[1]]) || "").trim()}`;
|
|
86
|
-
}
|
|
87
|
-
if (data.features.tweet)
|
|
88
|
-
body += '\n<script async src="https://platform.twitter.com/widgets.js"></script>';
|
|
89
|
-
if (data.config.fonts.webfonts.length && data.config.fonts.provider !== "none")
|
|
90
|
-
head += `
|
|
91
|
-
<link rel="stylesheet" href="${_chunkCGJOXW6Ijs.generateGoogleFontsUrl.call(void 0, data.config.fonts)}" type="text/css">`;
|
|
92
|
-
main = main.replace("__ENTRY__", _chunkCGJOXW6Ijs.toAtFS.call(void 0, _path.join.call(void 0, clientRoot, "main.ts"))).replace("<!-- head -->", head).replace("<!-- body -->", body);
|
|
93
|
-
return main;
|
|
94
|
-
}
|
|
95
|
-
async function mergeViteConfigs({ addonRoots, themeRoots }, viteConfig, config, command) {
|
|
96
|
-
const configEnv = {
|
|
97
|
-
mode: "development",
|
|
98
|
-
command
|
|
99
|
-
};
|
|
100
|
-
const files = _utils.uniq.call(void 0, [
|
|
101
|
-
...themeRoots,
|
|
102
|
-
...addonRoots
|
|
103
|
-
]).map((i) => _path.join.call(void 0, i, "vite.config.ts"));
|
|
104
|
-
for await (const file of files) {
|
|
105
|
-
if (!_fs.existsSync.call(void 0, file))
|
|
106
|
-
continue;
|
|
107
|
-
const viteConfig2 = await _vite.loadConfigFromFile.call(void 0, configEnv, file);
|
|
108
|
-
if (!_optionalChain([viteConfig2, 'optionalAccess', _10 => _10.config]))
|
|
109
|
-
continue;
|
|
110
|
-
config = _vite.mergeConfig.call(void 0, config, viteConfig2.config);
|
|
111
|
-
}
|
|
112
|
-
return _vite.mergeConfig.call(void 0, viteConfig, config);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// node/plugins/preset.ts
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
119
|
-
var _pluginvue = require('@vitejs/plugin-vue'); var _pluginvue2 = _interopRequireDefault(_pluginvue);
|
|
120
|
-
var _pluginvuejsx = require('@vitejs/plugin-vue-jsx'); var _pluginvuejsx2 = _interopRequireDefault(_pluginvuejsx);
|
|
121
|
-
var _vite3 = require('unplugin-icons/vite'); var _vite4 = _interopRequireDefault(_vite3);
|
|
122
|
-
var _resolver = require('unplugin-icons/resolver'); var _resolver2 = _interopRequireDefault(_resolver);
|
|
123
|
-
var _vite5 = require('unplugin-vue-components/vite'); var _vite6 = _interopRequireDefault(_vite5);
|
|
124
|
-
var _vitepluginvueserverref = require('vite-plugin-vue-server-ref'); var _vitepluginvueserverref2 = _interopRequireDefault(_vitepluginvueserverref);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// node/drawings.ts
|
|
128
|
-
|
|
129
|
-
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
130
|
-
var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
|
|
131
|
-
function resolveDrawingsDir(options) {
|
|
132
|
-
return options.data.config.drawings.persist ? _path.resolve.call(void 0,
|
|
133
|
-
_path.dirname.call(void 0, options.entry),
|
|
134
|
-
options.data.config.drawings.persist
|
|
135
|
-
) : void 0;
|
|
136
|
-
}
|
|
137
|
-
async function loadDrawings(options) {
|
|
138
|
-
const dir = resolveDrawingsDir(options);
|
|
139
|
-
if (!dir || !_fsextra2.default.existsSync(dir))
|
|
140
|
-
return {};
|
|
141
|
-
const files = await _fastglob2.default.call(void 0, "*.svg", {
|
|
142
|
-
onlyFiles: true,
|
|
143
|
-
cwd: dir,
|
|
144
|
-
absolute: true,
|
|
145
|
-
suppressErrors: true
|
|
146
|
-
});
|
|
147
|
-
const obj = {};
|
|
148
|
-
await Promise.all(files.map(async (path) => {
|
|
149
|
-
const num = +_path.basename.call(void 0, path, ".svg");
|
|
150
|
-
if (Number.isNaN(num))
|
|
151
|
-
return;
|
|
152
|
-
const content = await _fsextra2.default.readFile(path, "utf8");
|
|
153
|
-
const lines = content.split(/\n/g);
|
|
154
|
-
obj[num.toString()] = lines.slice(1, -1).join("\n");
|
|
155
|
-
}));
|
|
156
|
-
return obj;
|
|
157
|
-
}
|
|
158
|
-
async function writeDrawings(options, drawing) {
|
|
159
|
-
const dir = resolveDrawingsDir(options);
|
|
160
|
-
if (!dir)
|
|
161
|
-
return;
|
|
162
|
-
const width = options.data.config.canvasWidth;
|
|
163
|
-
const height = Math.round(width / options.data.config.aspectRatio);
|
|
164
|
-
const SVG_HEAD = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
|
|
165
|
-
await _fsextra2.default.ensureDir(dir);
|
|
166
|
-
return Promise.all(
|
|
167
|
-
Object.entries(drawing).map(async ([key, value]) => {
|
|
168
|
-
if (!value)
|
|
169
|
-
return;
|
|
170
|
-
const svg = `${SVG_HEAD}
|
|
171
|
-
${value}
|
|
172
|
-
</svg>`;
|
|
173
|
-
await _fsextra2.default.writeFile(_path.join.call(void 0, dir, `${key}.svg`), svg, "utf-8");
|
|
174
|
-
})
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// node/plugins/extendConfig.ts
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
var _isinstalledglobally = require('is-installed-globally'); var _isinstalledglobally2 = _interopRequireDefault(_isinstalledglobally);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// ../client/package.json
|
|
185
|
-
var dependencies = {
|
|
186
|
-
"@antfu/utils": "^0.7.6",
|
|
187
|
-
"@slidev/parser": "workspace:*",
|
|
188
|
-
"@slidev/types": "workspace:*",
|
|
189
|
-
"@unocss/reset": "^0.56.5",
|
|
190
|
-
"@vueuse/core": "^10.5.0",
|
|
191
|
-
"@vueuse/head": "^2.0.0",
|
|
192
|
-
"@vueuse/math": "^10.5.0",
|
|
193
|
-
"@vueuse/motion": "^2.0.0",
|
|
194
|
-
codemirror: "^5.65.5",
|
|
195
|
-
defu: "^6.1.2",
|
|
196
|
-
drauu: "^0.3.7",
|
|
197
|
-
"file-saver": "^2.0.5",
|
|
198
|
-
"fuse.js": "^6.6.2",
|
|
199
|
-
"js-base64": "^3.7.5",
|
|
200
|
-
"js-yaml": "^4.1.0",
|
|
201
|
-
katex: "^0.16.9",
|
|
202
|
-
mermaid: "^10.5.0",
|
|
203
|
-
"monaco-editor": "^0.37.1",
|
|
204
|
-
nanoid: "^5.0.1",
|
|
205
|
-
prettier: "^3.0.3",
|
|
206
|
-
recordrtc: "^5.6.2",
|
|
207
|
-
resolve: "^1.22.6",
|
|
208
|
-
unocss: "^0.56.5",
|
|
209
|
-
"vite-plugin-windicss": "^1.9.1",
|
|
210
|
-
vue: "^3.3.4",
|
|
211
|
-
"vue-router": "^4.2.5",
|
|
212
|
-
"vue-starport": "^0.4.0",
|
|
213
|
-
windicss: "^3.5.6"
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
// node/vite/searchRoot.ts
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
var ROOT_FILES = [
|
|
220
|
-
// '.git',
|
|
221
|
-
// https://pnpm.js.org/workspaces/
|
|
222
|
-
"pnpm-workspace.yaml"
|
|
223
|
-
// https://rushjs.io/pages/advanced/config_files/
|
|
224
|
-
// 'rush.json',
|
|
225
|
-
// https://nx.dev/latest/react/getting-started/nx-setup
|
|
226
|
-
// 'workspace.json',
|
|
227
|
-
// 'nx.json'
|
|
228
|
-
];
|
|
229
|
-
function hasWorkspacePackageJSON(root) {
|
|
230
|
-
const path = _path.join.call(void 0, root, "package.json");
|
|
231
|
-
try {
|
|
232
|
-
_fs2.default.accessSync(path, _fs2.default.constants.R_OK);
|
|
233
|
-
} catch (e2) {
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
const content = JSON.parse(_fs2.default.readFileSync(path, "utf-8")) || {};
|
|
237
|
-
return !!content.workspaces;
|
|
238
|
-
}
|
|
239
|
-
function hasRootFile(root) {
|
|
240
|
-
return ROOT_FILES.some((file) => _fs2.default.existsSync(_path.join.call(void 0, root, file)));
|
|
241
|
-
}
|
|
242
|
-
function hasPackageJSON(root) {
|
|
243
|
-
const path = _path.join.call(void 0, root, "package.json");
|
|
244
|
-
return _fs2.default.existsSync(path);
|
|
245
|
-
}
|
|
246
|
-
function searchForPackageRoot(current, root = current) {
|
|
247
|
-
if (hasPackageJSON(current))
|
|
248
|
-
return current;
|
|
249
|
-
const dir = _path.dirname.call(void 0, current);
|
|
250
|
-
if (!dir || dir === current)
|
|
251
|
-
return root;
|
|
252
|
-
return searchForPackageRoot(dir, root);
|
|
253
|
-
}
|
|
254
|
-
function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
255
|
-
if (hasRootFile(current))
|
|
256
|
-
return current;
|
|
257
|
-
if (hasWorkspacePackageJSON(current))
|
|
258
|
-
return current;
|
|
259
|
-
const dir = _path.dirname.call(void 0, current);
|
|
260
|
-
if (!dir || dir === current)
|
|
261
|
-
return root;
|
|
262
|
-
return searchForWorkspaceRoot(dir, root);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// node/plugins/extendConfig.ts
|
|
266
|
-
var EXCLUDE = [
|
|
267
|
-
"@slidev/shared",
|
|
268
|
-
"@slidev/types",
|
|
269
|
-
"@slidev/client",
|
|
270
|
-
"@slidev/client/constants",
|
|
271
|
-
"@slidev/client/logic/dark",
|
|
272
|
-
"@vueuse/core",
|
|
273
|
-
"@vueuse/shared",
|
|
274
|
-
"@unocss/reset",
|
|
275
|
-
"unocss",
|
|
276
|
-
"mermaid",
|
|
277
|
-
"vite-plugin-windicss",
|
|
278
|
-
"vue-demi",
|
|
279
|
-
"vue"
|
|
280
|
-
];
|
|
281
|
-
function createConfigPlugin(options) {
|
|
282
|
-
return {
|
|
283
|
-
name: "slidev:config",
|
|
284
|
-
async config(config) {
|
|
285
|
-
const injection = {
|
|
286
|
-
define: getDefine(options),
|
|
287
|
-
resolve: {
|
|
288
|
-
alias: {
|
|
289
|
-
"@slidev/client/": `${_chunkCGJOXW6Ijs.toAtFS.call(void 0, options.clientRoot)}/`
|
|
290
|
-
},
|
|
291
|
-
dedupe: ["vue"]
|
|
292
|
-
},
|
|
293
|
-
optimizeDeps: {
|
|
294
|
-
include: [
|
|
295
|
-
...Object.keys(dependencies).filter((i) => !EXCLUDE.includes(i)),
|
|
296
|
-
"codemirror/mode/javascript/javascript",
|
|
297
|
-
"codemirror/mode/css/css",
|
|
298
|
-
"codemirror/mode/markdown/markdown",
|
|
299
|
-
"codemirror/mode/xml/xml",
|
|
300
|
-
"codemirror/mode/htmlmixed/htmlmixed",
|
|
301
|
-
"codemirror/addon/display/placeholder",
|
|
302
|
-
"prettier/plugins/babel",
|
|
303
|
-
"prettier/plugins/html",
|
|
304
|
-
"prettier/plugins/typescript",
|
|
305
|
-
"mermaid/dist/mermaid.esm.min.mjs",
|
|
306
|
-
"mermaid/dist/mermaid.esm.mjs",
|
|
307
|
-
"vite-plugin-vue-server-ref/client"
|
|
308
|
-
],
|
|
309
|
-
exclude: EXCLUDE
|
|
310
|
-
},
|
|
311
|
-
css: options.data.config.css === "unocss" ? {
|
|
312
|
-
postcss: {
|
|
313
|
-
plugins: [
|
|
314
|
-
await Promise.resolve().then(() => require("postcss-nested")).then((r) => (r.default || r)())
|
|
315
|
-
]
|
|
316
|
-
}
|
|
317
|
-
} : {},
|
|
318
|
-
server: {
|
|
319
|
-
fs: {
|
|
320
|
-
strict: true,
|
|
321
|
-
allow: _utils.uniq.call(void 0, [
|
|
322
|
-
searchForWorkspaceRoot(options.userRoot),
|
|
323
|
-
searchForWorkspaceRoot(options.cliRoot),
|
|
324
|
-
..._isinstalledglobally2.default ? [_path.dirname.call(void 0, _chunkCGJOXW6Ijs.resolveGlobalImportPath.call(void 0, "@slidev/client/package.json")), _path.dirname.call(void 0, _chunkCGJOXW6Ijs.resolveGlobalImportPath.call(void 0, "katex/package.json"))] : []
|
|
325
|
-
])
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
publicDir: _path.join.call(void 0, options.userRoot, "public")
|
|
329
|
-
};
|
|
330
|
-
if (_isinstalledglobally2.default) {
|
|
331
|
-
injection.cacheDir = _path.join.call(void 0, options.cliRoot, "node_modules/.vite");
|
|
332
|
-
injection.root = options.cliRoot;
|
|
333
|
-
injection.resolve.alias.vue = `${_chunkCGJOXW6Ijs.resolveImportPath.call(void 0, "vue/dist/vue.esm-browser.js", true)}`;
|
|
334
|
-
}
|
|
335
|
-
return _vite.mergeConfig.call(void 0, injection, config);
|
|
336
|
-
},
|
|
337
|
-
configureServer(server) {
|
|
338
|
-
return () => {
|
|
339
|
-
server.middlewares.use(async (req, res, next) => {
|
|
340
|
-
if (req.url.endsWith(".html")) {
|
|
341
|
-
res.setHeader("Content-Type", "text/html");
|
|
342
|
-
res.statusCode = 200;
|
|
343
|
-
res.end(await getIndexHtml(options));
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
next();
|
|
347
|
-
});
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
function getDefine(options) {
|
|
353
|
-
return {
|
|
354
|
-
__DEV__: options.mode === "dev" ? "true" : "false",
|
|
355
|
-
__SLIDEV_CLIENT_ROOT__: JSON.stringify(_chunkCGJOXW6Ijs.toAtFS.call(void 0, options.clientRoot)),
|
|
356
|
-
__SLIDEV_HASH_ROUTE__: JSON.stringify(options.data.config.routerMode === "hash"),
|
|
357
|
-
__SLIDEV_FEATURE_DRAWINGS__: JSON.stringify(options.data.config.drawings.enabled === true || options.data.config.drawings.enabled === options.mode),
|
|
358
|
-
__SLIDEV_FEATURE_EDITOR__: JSON.stringify(options.mode === "dev" && options.data.config.editor !== false),
|
|
359
|
-
__SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
|
|
360
|
-
__SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
|
|
361
|
-
__SLIDEV_FEATURE_PRESENTER__: JSON.stringify(options.data.config.presenter === true || options.data.config.presenter === options.mode),
|
|
362
|
-
__SLIDEV_HAS_SERVER__: options.mode !== "build" ? "true" : "false"
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// node/plugins/loaders.ts
|
|
367
|
-
var import_fast_deep_equal = _chunkYUG22S6Wjs.__toESM.call(void 0, require_fast_deep_equal());
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
var _markdownit = require('markdown-it'); var _markdownit2 = _interopRequireDefault(_markdownit);
|
|
374
|
-
var _kolorist = require('kolorist');
|
|
375
|
-
var _markdownitlinkattributes = require('markdown-it-link-attributes'); var _markdownitlinkattributes2 = _interopRequireDefault(_markdownitlinkattributes);
|
|
376
|
-
var _fs3 = require('@slidev/parser/fs'); var parser = _interopRequireWildcard(_fs3);
|
|
377
|
-
var regexId = /^\/\@slidev\/slide\/(\d+)\.(md|json)(?:\?import)?$/;
|
|
378
|
-
var regexIdQuery = /(\d+?)\.(md|json|frontmatter)$/;
|
|
379
|
-
var vueContextImports = [
|
|
380
|
-
'import { inject as _vueInject, provide as _vueProvide, toRef as _vueToRef } from "vue"',
|
|
381
|
-
`import {
|
|
382
|
-
injectionSlidevContext as _injectionSlidevContext,
|
|
383
|
-
injectionClicks as _injectionClicks,
|
|
384
|
-
injectionCurrentPage as _injectionCurrentPage,
|
|
385
|
-
injectionRenderContext as _injectionRenderContext,
|
|
386
|
-
injectionFrontmatter as _injectionFrontmatter,
|
|
387
|
-
} from "@slidev/client/constants.ts"`.replace(/\n\s+/g, "\n"),
|
|
388
|
-
"const $slidev = _vueInject(_injectionSlidevContext)",
|
|
389
|
-
'const $nav = _vueToRef($slidev, "nav")',
|
|
390
|
-
"const $clicks = _vueInject(_injectionClicks)",
|
|
391
|
-
"const $page = _vueInject(_injectionCurrentPage)",
|
|
392
|
-
"const $renderContext = _vueInject(_injectionRenderContext)"
|
|
393
|
-
];
|
|
394
|
-
function getBodyJson(req) {
|
|
395
|
-
return new Promise((resolve3, reject) => {
|
|
396
|
-
let body = "";
|
|
397
|
-
req.on("data", (chunk) => body += chunk);
|
|
398
|
-
req.on("error", reject);
|
|
399
|
-
req.on("end", () => {
|
|
400
|
-
try {
|
|
401
|
-
resolve3(JSON.parse(body) || {});
|
|
402
|
-
} catch (e) {
|
|
403
|
-
reject(e);
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
var md = _markdownit2.default.call(void 0, { html: true });
|
|
409
|
-
md.use(_markdownitlinkattributes2.default, {
|
|
410
|
-
attrs: {
|
|
411
|
-
target: "_blank",
|
|
412
|
-
rel: "noopener"
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
function prepareSlideInfo(data) {
|
|
416
|
-
return {
|
|
417
|
-
...data,
|
|
418
|
-
noteHTML: md.render(_optionalChain([data, 'optionalAccess', _11 => _11.note]) || "")
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, userRoot, roots, remote, mode }, pluginOptions, serverOptions) {
|
|
422
|
-
const slidePrefix = "/@slidev/slides/";
|
|
423
|
-
const hmrPages = /* @__PURE__ */ new Set();
|
|
424
|
-
let server;
|
|
425
|
-
let _layouts_cache_time = 0;
|
|
426
|
-
let _layouts_cache = {};
|
|
427
|
-
return [
|
|
428
|
-
{
|
|
429
|
-
name: "slidev:loader",
|
|
430
|
-
configureServer(_server) {
|
|
431
|
-
server = _server;
|
|
432
|
-
updateServerWatcher();
|
|
433
|
-
server.middlewares.use(async (req, res, next) => {
|
|
434
|
-
const match = _optionalChain([req, 'access', _12 => _12.url, 'optionalAccess', _13 => _13.match, 'call', _14 => _14(regexId)]);
|
|
435
|
-
if (!match)
|
|
436
|
-
return next();
|
|
437
|
-
const [, no, type] = match;
|
|
438
|
-
const idx = Number.parseInt(no);
|
|
439
|
-
if (type === "json" && req.method === "GET") {
|
|
440
|
-
res.write(JSON.stringify(prepareSlideInfo(data.slides[idx])));
|
|
441
|
-
return res.end();
|
|
442
|
-
}
|
|
443
|
-
if (type === "json" && req.method === "POST") {
|
|
444
|
-
const body = await getBodyJson(req);
|
|
445
|
-
const slide = data.slides[idx];
|
|
446
|
-
hmrPages.add(idx);
|
|
447
|
-
if (slide.source) {
|
|
448
|
-
Object.assign(slide.source, body);
|
|
449
|
-
await parser.saveExternalSlide(slide.source);
|
|
450
|
-
} else {
|
|
451
|
-
Object.assign(slide, body);
|
|
452
|
-
await parser.save(data, entry);
|
|
453
|
-
}
|
|
454
|
-
res.statusCode = 200;
|
|
455
|
-
res.write(JSON.stringify(prepareSlideInfo(slide)));
|
|
456
|
-
return res.end();
|
|
457
|
-
}
|
|
458
|
-
next();
|
|
459
|
-
});
|
|
460
|
-
},
|
|
461
|
-
async handleHotUpdate(ctx) {
|
|
462
|
-
if (!data.entries.some((i) => _utils.slash.call(void 0, i) === ctx.file))
|
|
463
|
-
return;
|
|
464
|
-
await ctx.read();
|
|
465
|
-
const newData = await parser.load(entry, data.themeMeta);
|
|
466
|
-
const moduleIds = /* @__PURE__ */ new Set();
|
|
467
|
-
if (data.slides.length !== newData.slides.length) {
|
|
468
|
-
moduleIds.add("/@slidev/routes");
|
|
469
|
-
_utils.range.call(void 0, newData.slides.length).map((i) => hmrPages.add(i));
|
|
470
|
-
}
|
|
471
|
-
if (!(0, import_fast_deep_equal.default)(data.headmatter.defaults, newData.headmatter.defaults)) {
|
|
472
|
-
moduleIds.add("/@slidev/routes");
|
|
473
|
-
_utils.range.call(void 0, data.slides.length).map((i) => hmrPages.add(i));
|
|
474
|
-
}
|
|
475
|
-
if (!(0, import_fast_deep_equal.default)(data.config, newData.config))
|
|
476
|
-
moduleIds.add("/@slidev/configs");
|
|
477
|
-
if (!(0, import_fast_deep_equal.default)(data.features, newData.features)) {
|
|
478
|
-
setTimeout(() => {
|
|
479
|
-
ctx.server.ws.send({ type: "full-reload" });
|
|
480
|
-
}, 1);
|
|
481
|
-
}
|
|
482
|
-
const length = Math.max(data.slides.length, newData.slides.length);
|
|
483
|
-
for (let i = 0; i < length; i++) {
|
|
484
|
-
const a = data.slides[i];
|
|
485
|
-
const b = newData.slides[i];
|
|
486
|
-
if (_optionalChain([a, 'optionalAccess', _15 => _15.content, 'access', _16 => _16.trim, 'call', _17 => _17()]) === _optionalChain([b, 'optionalAccess', _18 => _18.content, 'access', _19 => _19.trim, 'call', _20 => _20()]) && _optionalChain([a, 'optionalAccess', _21 => _21.title, 'optionalAccess', _22 => _22.trim, 'call', _23 => _23()]) === _optionalChain([b, 'optionalAccess', _24 => _24.title, 'optionalAccess', _25 => _25.trim, 'call', _26 => _26()]) && _optionalChain([a, 'optionalAccess', _27 => _27.note]) === _optionalChain([b, 'optionalAccess', _28 => _28.note]) && (0, import_fast_deep_equal.default)(a.frontmatter, b.frontmatter))
|
|
487
|
-
continue;
|
|
488
|
-
ctx.server.ws.send({
|
|
489
|
-
type: "custom",
|
|
490
|
-
event: "slidev-update",
|
|
491
|
-
data: {
|
|
492
|
-
id: i,
|
|
493
|
-
data: prepareSlideInfo(newData.slides[i])
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
hmrPages.add(i);
|
|
497
|
-
}
|
|
498
|
-
_optionalChain([serverOptions, 'access', _29 => _29.onDataReload, 'optionalCall', _30 => _30(newData, data)]);
|
|
499
|
-
Object.assign(data, newData);
|
|
500
|
-
if (hmrPages.size > 0)
|
|
501
|
-
moduleIds.add("/@slidev/titles.md");
|
|
502
|
-
const vueModules = Array.from(hmrPages).flatMap((i) => [
|
|
503
|
-
ctx.server.moduleGraph.getModuleById(`${slidePrefix}${i + 1}.frontmatter`),
|
|
504
|
-
ctx.server.moduleGraph.getModuleById(`${slidePrefix}${i + 1}.md`)
|
|
505
|
-
]);
|
|
506
|
-
hmrPages.clear();
|
|
507
|
-
const moduleEntries = [
|
|
508
|
-
...vueModules,
|
|
509
|
-
...Array.from(moduleIds).map((id) => ctx.server.moduleGraph.getModuleById(id))
|
|
510
|
-
].filter(_utils.notNullish).filter((i) => !_optionalChain([i, 'access', _31 => _31.id, 'optionalAccess', _32 => _32.startsWith, 'call', _33 => _33("/@id/@vite-icons")]));
|
|
511
|
-
updateServerWatcher();
|
|
512
|
-
return moduleEntries;
|
|
513
|
-
},
|
|
514
|
-
resolveId(id) {
|
|
515
|
-
if (id.startsWith(slidePrefix) || id.startsWith("/@slidev/"))
|
|
516
|
-
return id;
|
|
517
|
-
return null;
|
|
518
|
-
},
|
|
519
|
-
load(id) {
|
|
520
|
-
if (id === "/@slidev/routes")
|
|
521
|
-
return generateRoutes();
|
|
522
|
-
if (id === "/@slidev/layouts")
|
|
523
|
-
return generateLayouts();
|
|
524
|
-
if (id === "/@slidev/styles")
|
|
525
|
-
return generateUserStyles();
|
|
526
|
-
if (id === "/@slidev/monaco-types")
|
|
527
|
-
return generateMonacoTypes();
|
|
528
|
-
if (id === "/@slidev/configs")
|
|
529
|
-
return generateConfigs();
|
|
530
|
-
if (id === "/@slidev/global-components/top")
|
|
531
|
-
return generateGlobalComponents("top");
|
|
532
|
-
if (id === "/@slidev/global-components/bottom")
|
|
533
|
-
return generateGlobalComponents("bottom");
|
|
534
|
-
if (id === "/@slidev/custom-nav-controls")
|
|
535
|
-
return generateCustomNavControls();
|
|
536
|
-
if (id === "/@slidev/titles.md") {
|
|
537
|
-
return {
|
|
538
|
-
code: data.slides.filter(({ frontmatter }) => !_optionalChain([frontmatter, 'optionalAccess', _34 => _34.disabled])).map(({ title }, i) => `<template ${i === 0 ? "v-if" : "v-else-if"}="+no === ${i + 1}">
|
|
539
|
-
|
|
540
|
-
${title}
|
|
541
|
-
|
|
542
|
-
</template>`).join(""),
|
|
543
|
-
map: { mappings: "" }
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
if (id.startsWith(slidePrefix)) {
|
|
547
|
-
const remaning = id.slice(slidePrefix.length);
|
|
548
|
-
const match = remaning.match(regexIdQuery);
|
|
549
|
-
if (match) {
|
|
550
|
-
const [, no, type] = match;
|
|
551
|
-
const pageNo = Number.parseInt(no) - 1;
|
|
552
|
-
const slide = data.slides[pageNo];
|
|
553
|
-
if (!slide)
|
|
554
|
-
return;
|
|
555
|
-
if (type === "md") {
|
|
556
|
-
return {
|
|
557
|
-
code: _optionalChain([slide, 'optionalAccess', _35 => _35.content]),
|
|
558
|
-
map: { mappings: "" }
|
|
559
|
-
};
|
|
560
|
-
} else if (type === "frontmatter") {
|
|
561
|
-
return {
|
|
562
|
-
code: [
|
|
563
|
-
"// @unocss-include",
|
|
564
|
-
'import { reactive, computed } from "vue"',
|
|
565
|
-
`export const frontmatter = reactive(${JSON.stringify(slide.frontmatter)})`,
|
|
566
|
-
`export const meta = reactive({
|
|
567
|
-
layout: computed(() => frontmatter.layout),
|
|
568
|
-
transition: computed(() => frontmatter.transition),
|
|
569
|
-
class: computed(() => frontmatter.class),
|
|
570
|
-
clicks: computed(() => frontmatter.clicks),
|
|
571
|
-
name: computed(() => frontmatter.name),
|
|
572
|
-
slide: {
|
|
573
|
-
...(${JSON.stringify({
|
|
574
|
-
...prepareSlideInfo(slide),
|
|
575
|
-
frontmatter: void 0,
|
|
576
|
-
// remove raw content in build, optimize the bundle size
|
|
577
|
-
...mode === "build" ? { raw: "", content: "", note: "" } : {}
|
|
578
|
-
})}),
|
|
579
|
-
frontmatter,
|
|
580
|
-
filepath: ${JSON.stringify(_optionalChain([slide, 'access', _36 => _36.source, 'optionalAccess', _37 => _37.filepath]) || entry)},
|
|
581
|
-
id: ${pageNo},
|
|
582
|
-
no: ${no},
|
|
583
|
-
},
|
|
584
|
-
__clicksElements: [],
|
|
585
|
-
__preloaded: false,
|
|
586
|
-
})`,
|
|
587
|
-
"export default frontmatter",
|
|
588
|
-
// handle HMR, update frontmatter with update
|
|
589
|
-
"if (import.meta.hot) {",
|
|
590
|
-
" import.meta.hot.accept(({ frontmatter: update }) => {",
|
|
591
|
-
" if(!update) return",
|
|
592
|
-
" Object.keys(frontmatter).forEach(key => {",
|
|
593
|
-
" if (!(key in update)) delete frontmatter[key]",
|
|
594
|
-
" })",
|
|
595
|
-
" Object.assign(frontmatter, update)",
|
|
596
|
-
" })",
|
|
597
|
-
"}"
|
|
598
|
-
].join("\n"),
|
|
599
|
-
map: { mappings: "" }
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
return {
|
|
604
|
-
code: "",
|
|
605
|
-
map: { mappings: "" }
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
},
|
|
610
|
-
{
|
|
611
|
-
name: "slidev:layout-transform:pre",
|
|
612
|
-
enforce: "pre",
|
|
613
|
-
async transform(code, id) {
|
|
614
|
-
if (!id.startsWith(slidePrefix))
|
|
615
|
-
return;
|
|
616
|
-
const remaning = id.slice(slidePrefix.length);
|
|
617
|
-
const match = remaning.match(regexIdQuery);
|
|
618
|
-
if (!match)
|
|
619
|
-
return;
|
|
620
|
-
const [, no, type] = match;
|
|
621
|
-
if (type !== "md")
|
|
622
|
-
return;
|
|
623
|
-
const pageNo = Number.parseInt(no) - 1;
|
|
624
|
-
return transformMarkdown(code, pageNo, data);
|
|
625
|
-
}
|
|
626
|
-
},
|
|
627
|
-
{
|
|
628
|
-
name: "slidev:context-transform:pre",
|
|
629
|
-
enforce: "pre",
|
|
630
|
-
async transform(code, id) {
|
|
631
|
-
if (!id.endsWith(".vue") || id.includes("/@slidev/client/") || id.includes("/packages/client/"))
|
|
632
|
-
return;
|
|
633
|
-
return transformVue(code);
|
|
634
|
-
}
|
|
635
|
-
},
|
|
636
|
-
{
|
|
637
|
-
name: "slidev:title-transform:pre",
|
|
638
|
-
enforce: "pre",
|
|
639
|
-
transform(code, id) {
|
|
640
|
-
if (id !== "/@slidev/titles.md")
|
|
641
|
-
return;
|
|
642
|
-
return transformTitles(code);
|
|
643
|
-
}
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
name: "slidev:slide-transform:post",
|
|
647
|
-
enforce: "post",
|
|
648
|
-
transform(code, id) {
|
|
649
|
-
if (!id.match(/\/@slidev\/slides\/\d+\.md($|\?)/))
|
|
650
|
-
return;
|
|
651
|
-
const replaced = code.replace("if (_rerender_only)", "if (false)");
|
|
652
|
-
if (replaced !== code)
|
|
653
|
-
return replaced;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
];
|
|
657
|
-
function updateServerWatcher() {
|
|
658
|
-
if (!server)
|
|
659
|
-
return;
|
|
660
|
-
server.watcher.add(_optionalChain([data, 'access', _38 => _38.entries, 'optionalAccess', _39 => _39.map, 'call', _40 => _40(_utils.slash)]) || []);
|
|
661
|
-
}
|
|
662
|
-
async function transformMarkdown(code, pageNo, data2) {
|
|
663
|
-
const layouts = await getLayouts();
|
|
664
|
-
const frontmatter = {
|
|
665
|
-
..._optionalChain([data2, 'access', _41 => _41.headmatter, 'optionalAccess', _42 => _42.defaults]) || {},
|
|
666
|
-
..._optionalChain([data2, 'access', _43 => _43.slides, 'access', _44 => _44[pageNo], 'optionalAccess', _45 => _45.frontmatter]) || {}
|
|
667
|
-
};
|
|
668
|
-
let layoutName = _optionalChain([frontmatter, 'optionalAccess', _46 => _46.layout]) || (pageNo === 0 ? "cover" : "default");
|
|
669
|
-
if (!layouts[layoutName]) {
|
|
670
|
-
console.error(_kolorist.red.call(void 0, `
|
|
671
|
-
Unknown layout "${_kolorist.bold.call(void 0, layoutName)}".${_kolorist.yellow.call(void 0, " Available layouts are:")}`) + Object.keys(layouts).map((i, idx) => (idx % 3 === 0 ? "\n " : "") + _kolorist.gray.call(void 0, i.padEnd(15, " "))).join(" "));
|
|
672
|
-
console.error();
|
|
673
|
-
layoutName = "default";
|
|
674
|
-
}
|
|
675
|
-
delete frontmatter.title;
|
|
676
|
-
const imports = [
|
|
677
|
-
...vueContextImports,
|
|
678
|
-
`import InjectedLayout from "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, layouts[layoutName])}"`,
|
|
679
|
-
`import frontmatter from "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, `${slidePrefix + (pageNo + 1)}.frontmatter`)}"`,
|
|
680
|
-
"const $frontmatter = frontmatter",
|
|
681
|
-
"_vueProvide(_injectionFrontmatter, frontmatter)",
|
|
682
|
-
// update frontmatter in router
|
|
683
|
-
";(() => {",
|
|
684
|
-
" const route = $slidev.nav.rawRoutes.find(i => i.path === String($page.value))",
|
|
685
|
-
" if (route?.meta?.slide?.frontmatter) {",
|
|
686
|
-
" Object.keys(route.meta.slide.frontmatter).forEach(key => {",
|
|
687
|
-
" if (!(key in $frontmatter)) delete route.meta.slide.frontmatter[key]",
|
|
688
|
-
" })",
|
|
689
|
-
" Object.assign(route.meta.slide.frontmatter, frontmatter)",
|
|
690
|
-
" }",
|
|
691
|
-
"})();"
|
|
692
|
-
];
|
|
693
|
-
code = code.replace(/(<script setup.*>)/g, `$1
|
|
694
|
-
${imports.join("\n")}
|
|
695
|
-
`);
|
|
696
|
-
const injectA = code.indexOf("<template>") + "<template>".length;
|
|
697
|
-
const injectB = code.lastIndexOf("</template>");
|
|
698
|
-
let body = code.slice(injectA, injectB).trim();
|
|
699
|
-
if (body.startsWith("<div>") && body.endsWith("</div>"))
|
|
700
|
-
body = body.slice(5, -6);
|
|
701
|
-
code = `${code.slice(0, injectA)}
|
|
702
|
-
<InjectedLayout v-bind="frontmatter">
|
|
703
|
-
${body}
|
|
704
|
-
</InjectedLayout>
|
|
705
|
-
${code.slice(injectB)}`;
|
|
706
|
-
return code;
|
|
707
|
-
}
|
|
708
|
-
function transformVue(code) {
|
|
709
|
-
if (code.includes("injectionSlidevContext") || code.includes("injectionClicks") || code.includes("const $slidev"))
|
|
710
|
-
return code;
|
|
711
|
-
const imports = [
|
|
712
|
-
...vueContextImports,
|
|
713
|
-
"const $frontmatter = _vueInject(_injectionFrontmatter)"
|
|
714
|
-
];
|
|
715
|
-
const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/);
|
|
716
|
-
if (matchScript && matchScript[2]) {
|
|
717
|
-
return code.replace(/(<script.*>)/g, `$1
|
|
718
|
-
${imports.join("\n")}
|
|
719
|
-
`);
|
|
720
|
-
} else if (matchScript && !matchScript[2]) {
|
|
721
|
-
const matchExport = code.match(/export\s+default\s+{/);
|
|
722
|
-
if (matchExport) {
|
|
723
|
-
const exportIndex = (matchExport.index || 0) + matchExport[0].length;
|
|
724
|
-
let component = code.slice(exportIndex);
|
|
725
|
-
component = component.slice(0, component.indexOf("</script>"));
|
|
726
|
-
const scriptIndex = (matchScript.index || 0) + matchScript[0].length;
|
|
727
|
-
const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants.ts"\n';
|
|
728
|
-
code = `${code.slice(0, scriptIndex)}${provideImport}${code.slice(scriptIndex)}`;
|
|
729
|
-
let injectIndex = exportIndex + provideImport.length;
|
|
730
|
-
let injectObject = "$slidev: { from: injectionSlidevContext },";
|
|
731
|
-
const matchInject = component.match(/.*inject\s*:\s*([\[{])/);
|
|
732
|
-
if (matchInject) {
|
|
733
|
-
injectIndex += (matchInject.index || 0) + matchInject[0].length;
|
|
734
|
-
if (matchInject[1] === "[") {
|
|
735
|
-
let injects = component.slice((matchInject.index || 0) + matchInject[0].length);
|
|
736
|
-
const injectEndIndex = injects.indexOf("]");
|
|
737
|
-
injects = injects.slice(0, injectEndIndex);
|
|
738
|
-
injectObject += injects.split(",").map((inject) => `${inject}: {from: ${inject}}`).join(",");
|
|
739
|
-
return `${code.slice(0, injectIndex - 1)}{
|
|
740
|
-
${injectObject}
|
|
741
|
-
}${code.slice(injectIndex + injectEndIndex + 1)}`;
|
|
742
|
-
} else {
|
|
743
|
-
return `${code.slice(0, injectIndex)}
|
|
744
|
-
${injectObject}
|
|
745
|
-
${code.slice(injectIndex)}`;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
return `${code.slice(0, injectIndex)}
|
|
749
|
-
inject: { ${injectObject} },
|
|
750
|
-
${code.slice(injectIndex)}`;
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
return `<script setup>
|
|
754
|
-
${imports.join("\n")}
|
|
755
|
-
</script>
|
|
756
|
-
${code}`;
|
|
757
|
-
}
|
|
758
|
-
function transformTitles(code) {
|
|
759
|
-
return code.replace(/<template>\s*<div>\s*<p>/, "<template>").replace(/<\/p>\s*<\/div>\s*<\/template>/, "</template>").replace(/<script\ssetup>/, `<script setup lang="ts">
|
|
760
|
-
defineProps<{ no: number | string }>()`);
|
|
761
|
-
}
|
|
762
|
-
async function getLayouts() {
|
|
763
|
-
const now = Date.now();
|
|
764
|
-
if (now - _layouts_cache_time < 2e3)
|
|
765
|
-
return _layouts_cache;
|
|
766
|
-
const layouts = {};
|
|
767
|
-
const roots2 = _utils.uniq.call(void 0, [
|
|
768
|
-
userRoot,
|
|
769
|
-
...themeRoots,
|
|
770
|
-
...addonRoots,
|
|
771
|
-
clientRoot
|
|
772
|
-
]);
|
|
773
|
-
for (const root of roots2) {
|
|
774
|
-
const layoutPaths = await _fastglob2.default.call(void 0, "layouts/**/*.{vue,ts}", {
|
|
775
|
-
cwd: root,
|
|
776
|
-
absolute: true,
|
|
777
|
-
suppressErrors: true
|
|
778
|
-
});
|
|
779
|
-
for (const layoutPath of layoutPaths) {
|
|
780
|
-
const layout = _path.basename.call(void 0, layoutPath).replace(/\.\w+$/, "");
|
|
781
|
-
if (layouts[layout])
|
|
782
|
-
continue;
|
|
783
|
-
layouts[layout] = layoutPath;
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
_layouts_cache_time = now;
|
|
787
|
-
_layouts_cache = layouts;
|
|
788
|
-
return layouts;
|
|
789
|
-
}
|
|
790
|
-
async function generateUserStyles() {
|
|
791
|
-
const imports = [
|
|
792
|
-
`import "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, _path.join.call(void 0, clientRoot, "styles/vars.css"))}"`,
|
|
793
|
-
`import "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, _path.join.call(void 0, clientRoot, "styles/index.css"))}"`,
|
|
794
|
-
`import "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, _path.join.call(void 0, clientRoot, "styles/code.css"))}"`,
|
|
795
|
-
`import "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, _path.join.call(void 0, clientRoot, "styles/katex.css"))}"`,
|
|
796
|
-
`import "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, _path.join.call(void 0, clientRoot, "styles/transitions.css"))}"`
|
|
797
|
-
];
|
|
798
|
-
const roots2 = _utils.uniq.call(void 0, [
|
|
799
|
-
...themeRoots,
|
|
800
|
-
...addonRoots,
|
|
801
|
-
userRoot
|
|
802
|
-
]);
|
|
803
|
-
for (const root of roots2) {
|
|
804
|
-
const styles = [
|
|
805
|
-
_path.join.call(void 0, root, "styles", "index.ts"),
|
|
806
|
-
_path.join.call(void 0, root, "styles", "index.js"),
|
|
807
|
-
_path.join.call(void 0, root, "styles", "index.css"),
|
|
808
|
-
_path.join.call(void 0, root, "styles.css"),
|
|
809
|
-
_path.join.call(void 0, root, "style.css")
|
|
810
|
-
];
|
|
811
|
-
for (const style of styles) {
|
|
812
|
-
if (_fsextra.existsSync.call(void 0, style)) {
|
|
813
|
-
imports.push(`import "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, style)}"`);
|
|
814
|
-
continue;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
if (data.features.katex)
|
|
819
|
-
imports.push(`import "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, _chunkCGJOXW6Ijs.resolveImportPath.call(void 0, "katex/dist/katex.min.css", true))}"`);
|
|
820
|
-
if (data.config.css === "unocss") {
|
|
821
|
-
imports.unshift(
|
|
822
|
-
'import "@unocss/reset/tailwind.css"',
|
|
823
|
-
'import "uno:preflights.css"',
|
|
824
|
-
'import "uno:typography.css"',
|
|
825
|
-
'import "uno:shortcuts.css"'
|
|
826
|
-
);
|
|
827
|
-
imports.push('import "uno.css"');
|
|
828
|
-
} else {
|
|
829
|
-
imports.unshift(
|
|
830
|
-
'import "virtual:windi-components.css"',
|
|
831
|
-
'import "virtual:windi-base.css"'
|
|
832
|
-
);
|
|
833
|
-
imports.push('import "virtual:windi-utilities.css"');
|
|
834
|
-
if (_process2.default.env.NODE_ENV !== "production")
|
|
835
|
-
imports.push('import "virtual:windi-devtools"');
|
|
836
|
-
}
|
|
837
|
-
return imports.join("\n");
|
|
838
|
-
}
|
|
839
|
-
async function generateMonacoTypes() {
|
|
840
|
-
return `void 0; ${parser.scanMonacoModules(data.raw).map((i) => `import('/@slidev-monaco-types/${i}')`).join("\n")}`;
|
|
841
|
-
}
|
|
842
|
-
async function generateLayouts() {
|
|
843
|
-
const imports = [];
|
|
844
|
-
const layouts = _utils.objectMap.call(void 0,
|
|
845
|
-
await getLayouts(),
|
|
846
|
-
(k, v) => {
|
|
847
|
-
imports.push(`import __layout_${k} from "${_chunkCGJOXW6Ijs.toAtFS.call(void 0, v)}"`);
|
|
848
|
-
return [k, `__layout_${k}`];
|
|
849
|
-
}
|
|
850
|
-
);
|
|
851
|
-
return [
|
|
852
|
-
imports.join("\n"),
|
|
853
|
-
`export default {
|
|
854
|
-
${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
|
|
855
|
-
}`
|
|
856
|
-
].join("\n\n");
|
|
857
|
-
}
|
|
858
|
-
async function generateRoutes() {
|
|
859
|
-
const imports = [];
|
|
860
|
-
const redirects = [];
|
|
861
|
-
const layouts = await getLayouts();
|
|
862
|
-
imports.push(`import __layout__end from '${layouts.end}'`);
|
|
863
|
-
let no = 1;
|
|
864
|
-
const routes = data.slides.filter(({ frontmatter }) => !_optionalChain([frontmatter, 'optionalAccess', _47 => _47.disabled])).map((i, idx) => {
|
|
865
|
-
imports.push(`import n${no} from '${slidePrefix}${idx + 1}.md'`);
|
|
866
|
-
imports.push(`import { meta as f${no} } from '${slidePrefix}${idx + 1}.frontmatter'`);
|
|
867
|
-
const route = `{ path: '${no}', name: 'page-${no}', component: n${no}, meta: f${no} }`;
|
|
868
|
-
if (_optionalChain([i, 'access', _48 => _48.frontmatter, 'optionalAccess', _49 => _49.routeAlias]))
|
|
869
|
-
redirects.push(`{ path: '${_optionalChain([i, 'access', _50 => _50.frontmatter, 'optionalAccess', _51 => _51.routeAlias])}', redirect: { path: '${no}' } }`);
|
|
870
|
-
no += 1;
|
|
871
|
-
return route;
|
|
872
|
-
});
|
|
873
|
-
const routesStr = `export default [
|
|
874
|
-
${routes.join(",\n")}
|
|
875
|
-
]`;
|
|
876
|
-
const redirectsStr = `export const redirects = [
|
|
877
|
-
${redirects.join(",\n")}
|
|
878
|
-
]`;
|
|
879
|
-
return [...imports, routesStr, redirectsStr].join("\n");
|
|
880
|
-
}
|
|
881
|
-
function generateConfigs() {
|
|
882
|
-
const config = { ...data.config, remote };
|
|
883
|
-
if (_utils.isString.call(void 0, config.title)) {
|
|
884
|
-
const tokens = md.parseInline(config.title, {});
|
|
885
|
-
config.title = _chunkCGJOXW6Ijs.stringifyMarkdownTokens.call(void 0, tokens);
|
|
886
|
-
}
|
|
887
|
-
if (_utils.isString.call(void 0, config.info))
|
|
888
|
-
config.info = md.render(config.info);
|
|
889
|
-
return `export default ${JSON.stringify(config)}`;
|
|
890
|
-
}
|
|
891
|
-
async function generateGlobalComponents(layer) {
|
|
892
|
-
const components = roots.flatMap((root) => {
|
|
893
|
-
if (layer === "top") {
|
|
894
|
-
return [
|
|
895
|
-
_path.join.call(void 0, root, "global.vue"),
|
|
896
|
-
_path.join.call(void 0, root, "global-top.vue"),
|
|
897
|
-
_path.join.call(void 0, root, "GlobalTop.vue")
|
|
898
|
-
];
|
|
899
|
-
} else {
|
|
900
|
-
return [
|
|
901
|
-
_path.join.call(void 0, root, "global-bottom.vue"),
|
|
902
|
-
_path.join.call(void 0, root, "GlobalBottom.vue")
|
|
903
|
-
];
|
|
904
|
-
}
|
|
905
|
-
}).filter((i) => _fsextra2.default.existsSync(i));
|
|
906
|
-
const imports = components.map((i, idx) => `import __n${idx} from '${_chunkCGJOXW6Ijs.toAtFS.call(void 0, i)}'`).join("\n");
|
|
907
|
-
const render = components.map((i, idx) => `h(__n${idx})`).join(",");
|
|
908
|
-
return `
|
|
909
|
-
${imports}
|
|
910
|
-
import { h } from 'vue'
|
|
911
|
-
export default {
|
|
912
|
-
render() {
|
|
913
|
-
return [${render}]
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
`;
|
|
917
|
-
}
|
|
918
|
-
async function generateCustomNavControls() {
|
|
919
|
-
const components = roots.flatMap((root) => {
|
|
920
|
-
return [
|
|
921
|
-
_path.join.call(void 0, root, "custom-nav-controls.vue"),
|
|
922
|
-
_path.join.call(void 0, root, "CustomNavControls.vue")
|
|
923
|
-
];
|
|
924
|
-
}).filter((i) => _fsextra2.default.existsSync(i));
|
|
925
|
-
const imports = components.map((i, idx) => `import __n${idx} from '${_chunkCGJOXW6Ijs.toAtFS.call(void 0, i)}'`).join("\n");
|
|
926
|
-
const render = components.map((i, idx) => `h(__n${idx})`).join(",");
|
|
927
|
-
return `
|
|
928
|
-
${imports}
|
|
929
|
-
import { h } from 'vue'
|
|
930
|
-
export default {
|
|
931
|
-
render() {
|
|
932
|
-
return [${render}]
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
`;
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
// node/plugins/monacoTransform.ts
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
async function getPackageData(pkg) {
|
|
944
|
-
const { resolvePackageData } = await eval('import("vite")');
|
|
945
|
-
const info = resolvePackageData(pkg, _process2.default.cwd());
|
|
946
|
-
if (!info)
|
|
947
|
-
return;
|
|
948
|
-
const typePath = info.data.types || info.data.typings;
|
|
949
|
-
if (!typePath)
|
|
950
|
-
return;
|
|
951
|
-
return [info, typePath];
|
|
952
|
-
}
|
|
953
|
-
function createMonacoTypesLoader() {
|
|
954
|
-
return {
|
|
955
|
-
name: "slidev:monaco-types-loader",
|
|
956
|
-
resolveId(id) {
|
|
957
|
-
if (id.startsWith("/@slidev-monaco-types/"))
|
|
958
|
-
return id;
|
|
959
|
-
return null;
|
|
960
|
-
},
|
|
961
|
-
async load(id) {
|
|
962
|
-
const match = id.match(/^\/\@slidev-monaco-types\/(.*)$/);
|
|
963
|
-
if (match) {
|
|
964
|
-
const pkg2 = match[1];
|
|
965
|
-
const packageData = await getPackageData(pkg2) || await getPackageData(`@types/${pkg2}`);
|
|
966
|
-
if (!packageData)
|
|
967
|
-
return;
|
|
968
|
-
const [info2, typePath2] = packageData;
|
|
969
|
-
return [
|
|
970
|
-
"import * as monaco from 'monaco-editor'",
|
|
971
|
-
`import Type from "${_utils.slash.call(void 0, _path.join.call(void 0, info2.dir, typePath2))}?raw"`,
|
|
972
|
-
...Object.keys(info2.data.dependencies || {}).map((i) => `import "/@slidev-monaco-types/${i}"`),
|
|
973
|
-
`monaco.languages.typescript.typescriptDefaults.addExtraLib(\`declare module "${pkg2}" { \${Type} }\`)`
|
|
974
|
-
].join("\n");
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
// node/plugins/setupClient.ts
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot }) {
|
|
985
|
-
const setupEntry = _utils.slash.call(void 0, _path.resolve.call(void 0, clientRoot, "setup"));
|
|
986
|
-
return {
|
|
987
|
-
name: "slidev:setup",
|
|
988
|
-
enforce: "pre",
|
|
989
|
-
async transform(code, id) {
|
|
990
|
-
if (id.startsWith(setupEntry)) {
|
|
991
|
-
let getInjections2 = function(isAwait = false, isChained = false) {
|
|
992
|
-
return injections.join("\n").replace(/:AWAIT:/g, isAwait ? "await " : "").replace(/(,\s*)?:LAST:/g, isChained ? "$1injection_return" : "");
|
|
993
|
-
};
|
|
994
|
-
var getInjections = getInjections2;
|
|
995
|
-
const name = id.slice(setupEntry.length + 1).replace(/\?.*$/, "");
|
|
996
|
-
const imports = [];
|
|
997
|
-
const injections = [];
|
|
998
|
-
const setups = _utils.uniq.call(void 0, [
|
|
999
|
-
...themeRoots,
|
|
1000
|
-
...addonRoots,
|
|
1001
|
-
userRoot
|
|
1002
|
-
]).map((i) => _path.join.call(void 0, i, "setup", name));
|
|
1003
|
-
setups.forEach((path, idx) => {
|
|
1004
|
-
if (!_fs.existsSync.call(void 0, path))
|
|
1005
|
-
return;
|
|
1006
|
-
imports.push(`import __n${idx} from '${_chunkCGJOXW6Ijs.toAtFS.call(void 0, path)}'`);
|
|
1007
|
-
let fn = `:AWAIT:__n${idx}`;
|
|
1008
|
-
if (/\binjection_return\b/g.test(code))
|
|
1009
|
-
fn = `injection_return = ${fn}`;
|
|
1010
|
-
if (/\binjection_arg\b/g.test(code)) {
|
|
1011
|
-
fn += "(";
|
|
1012
|
-
const matches = Array.from(code.matchAll(/\binjection_arg(_\d+)?\b/g));
|
|
1013
|
-
const dedupedMatches = Array.from(new Set(matches.map((m) => m[0])));
|
|
1014
|
-
fn += dedupedMatches.join(", ");
|
|
1015
|
-
fn += ", :LAST:)";
|
|
1016
|
-
} else {
|
|
1017
|
-
fn += "(:LAST:)";
|
|
1018
|
-
}
|
|
1019
|
-
injections.push(
|
|
1020
|
-
`// ${path}`,
|
|
1021
|
-
fn
|
|
1022
|
-
);
|
|
1023
|
-
});
|
|
1024
|
-
code = code.replace("/* __imports__ */", imports.join("\n"));
|
|
1025
|
-
code = code.replace("/* __injections__ */", getInjections2());
|
|
1026
|
-
code = code.replace("/* __async_injections__ */", getInjections2(true));
|
|
1027
|
-
code = code.replace("/* __chained_injections__ */", getInjections2(false, true));
|
|
1028
|
-
code = code.replace("/* __chained_async_injections__ */", getInjections2(true, true));
|
|
1029
|
-
return code;
|
|
1030
|
-
}
|
|
1031
|
-
return null;
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
// node/plugins/markdown.ts
|
|
1037
|
-
var _vite7 = require('unplugin-vue-markdown/vite'); var _vite8 = _interopRequireDefault(_vite7);
|
|
1038
|
-
var _jsbase64 = require('js-base64'); var base64 = _interopRequireWildcard(_jsbase64);
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
var _markdownitfootnote = require('markdown-it-footnote'); var _markdownitfootnote2 = _interopRequireDefault(_markdownitfootnote);
|
|
1042
|
-
var _markdownitplugins = require('@hedgedoc/markdown-it-plugins');
|
|
1043
|
-
var _plantumlencoder = require('plantuml-encoder');
|
|
1044
|
-
var _markdownitmdc = require('markdown-it-mdc'); var _markdownitmdc2 = _interopRequireDefault(_markdownitmdc);
|
|
1045
|
-
|
|
1046
|
-
// node/plugins/markdown-it-katex.ts
|
|
1047
|
-
var _katex = require('katex'); var _katex2 = _interopRequireDefault(_katex);
|
|
1048
|
-
function isValidDelim(state, pos) {
|
|
1049
|
-
const max = state.posMax;
|
|
1050
|
-
let can_open = true;
|
|
1051
|
-
let can_close = true;
|
|
1052
|
-
const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
|
|
1053
|
-
const nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1;
|
|
1054
|
-
if (prevChar === 32 || prevChar === 9 || /* \t */
|
|
1055
|
-
nextChar >= 48 && nextChar <= 57)
|
|
1056
|
-
can_close = false;
|
|
1057
|
-
if (nextChar === 32 || nextChar === 9)
|
|
1058
|
-
can_open = false;
|
|
1059
|
-
return {
|
|
1060
|
-
can_open,
|
|
1061
|
-
can_close
|
|
1062
|
-
};
|
|
1063
|
-
}
|
|
1064
|
-
function math_inline(state, silent) {
|
|
1065
|
-
let match, token, res, pos;
|
|
1066
|
-
if (state.src[state.pos] !== "$")
|
|
1067
|
-
return false;
|
|
1068
|
-
res = isValidDelim(state, state.pos);
|
|
1069
|
-
if (!res.can_open) {
|
|
1070
|
-
if (!silent)
|
|
1071
|
-
state.pending += "$";
|
|
1072
|
-
state.pos += 1;
|
|
1073
|
-
return true;
|
|
1074
|
-
}
|
|
1075
|
-
const start = state.pos + 1;
|
|
1076
|
-
match = start;
|
|
1077
|
-
while ((match = state.src.indexOf("$", match)) !== -1) {
|
|
1078
|
-
pos = match - 1;
|
|
1079
|
-
while (state.src[pos] === "\\")
|
|
1080
|
-
pos -= 1;
|
|
1081
|
-
if ((match - pos) % 2 === 1)
|
|
1082
|
-
break;
|
|
1083
|
-
match += 1;
|
|
1084
|
-
}
|
|
1085
|
-
if (match === -1) {
|
|
1086
|
-
if (!silent)
|
|
1087
|
-
state.pending += "$";
|
|
1088
|
-
state.pos = start;
|
|
1089
|
-
return true;
|
|
1090
|
-
}
|
|
1091
|
-
if (match - start === 0) {
|
|
1092
|
-
if (!silent)
|
|
1093
|
-
state.pending += "$$";
|
|
1094
|
-
state.pos = start + 1;
|
|
1095
|
-
return true;
|
|
1096
|
-
}
|
|
1097
|
-
res = isValidDelim(state, match);
|
|
1098
|
-
if (!res.can_close) {
|
|
1099
|
-
if (!silent)
|
|
1100
|
-
state.pending += "$";
|
|
1101
|
-
state.pos = start;
|
|
1102
|
-
return true;
|
|
1103
|
-
}
|
|
1104
|
-
if (!silent) {
|
|
1105
|
-
token = state.push("math_inline", "math", 0);
|
|
1106
|
-
token.markup = "$";
|
|
1107
|
-
token.content = state.src.slice(start, match);
|
|
1108
|
-
}
|
|
1109
|
-
state.pos = match + 1;
|
|
1110
|
-
return true;
|
|
1111
|
-
}
|
|
1112
|
-
function math_block(state, start, end, silent) {
|
|
1113
|
-
let firstLine;
|
|
1114
|
-
let lastLine;
|
|
1115
|
-
let next;
|
|
1116
|
-
let lastPos;
|
|
1117
|
-
let found = false;
|
|
1118
|
-
let pos = state.bMarks[start] + state.tShift[start];
|
|
1119
|
-
let max = state.eMarks[start];
|
|
1120
|
-
if (pos + 2 > max)
|
|
1121
|
-
return false;
|
|
1122
|
-
if (state.src.slice(pos, pos + 2) !== "$$")
|
|
1123
|
-
return false;
|
|
1124
|
-
pos += 2;
|
|
1125
|
-
firstLine = state.src.slice(pos, max);
|
|
1126
|
-
if (silent)
|
|
1127
|
-
return true;
|
|
1128
|
-
if (firstLine.trim().slice(-2) === "$$") {
|
|
1129
|
-
firstLine = firstLine.trim().slice(0, -2);
|
|
1130
|
-
found = true;
|
|
1131
|
-
}
|
|
1132
|
-
for (next = start; !found; ) {
|
|
1133
|
-
next++;
|
|
1134
|
-
if (next >= end)
|
|
1135
|
-
break;
|
|
1136
|
-
pos = state.bMarks[next] + state.tShift[next];
|
|
1137
|
-
max = state.eMarks[next];
|
|
1138
|
-
if (pos < max && state.tShift[next] < state.blkIndent) {
|
|
1139
|
-
break;
|
|
1140
|
-
}
|
|
1141
|
-
if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
|
|
1142
|
-
lastPos = state.src.slice(0, max).lastIndexOf("$$");
|
|
1143
|
-
lastLine = state.src.slice(pos, lastPos);
|
|
1144
|
-
found = true;
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
state.line = next + 1;
|
|
1148
|
-
const token = state.push("math_block", "math", 0);
|
|
1149
|
-
token.block = true;
|
|
1150
|
-
token.content = (firstLine && firstLine.trim() ? `${firstLine}
|
|
1151
|
-
` : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
1152
|
-
token.map = [start, state.line];
|
|
1153
|
-
token.markup = "$$";
|
|
1154
|
-
return true;
|
|
1155
|
-
}
|
|
1156
|
-
function math_plugin(md2, options) {
|
|
1157
|
-
options = options || {};
|
|
1158
|
-
const katexInline = function(latex) {
|
|
1159
|
-
options.displayMode = false;
|
|
1160
|
-
try {
|
|
1161
|
-
return _katex2.default.renderToString(latex, options);
|
|
1162
|
-
} catch (error) {
|
|
1163
|
-
if (options.throwOnError)
|
|
1164
|
-
console.warn(error);
|
|
1165
|
-
return latex;
|
|
1166
|
-
}
|
|
1167
|
-
};
|
|
1168
|
-
const inlineRenderer = function(tokens, idx) {
|
|
1169
|
-
return katexInline(tokens[idx].content);
|
|
1170
|
-
};
|
|
1171
|
-
const katexBlock = function(latex) {
|
|
1172
|
-
options.displayMode = true;
|
|
1173
|
-
try {
|
|
1174
|
-
return `<p>${_katex2.default.renderToString(latex, options)}</p>`;
|
|
1175
|
-
} catch (error) {
|
|
1176
|
-
if (options.throwOnError)
|
|
1177
|
-
console.warn(error);
|
|
1178
|
-
return latex;
|
|
1179
|
-
}
|
|
1180
|
-
};
|
|
1181
|
-
const blockRenderer = function(tokens, idx) {
|
|
1182
|
-
return `${katexBlock(tokens[idx].content)}
|
|
1183
|
-
`;
|
|
1184
|
-
};
|
|
1185
|
-
md2.inline.ruler.after("escape", "math_inline", math_inline);
|
|
1186
|
-
md2.block.ruler.after("blockquote", "math_block", math_block, {
|
|
1187
|
-
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
1188
|
-
});
|
|
1189
|
-
md2.renderer.rules.math_inline = inlineRenderer;
|
|
1190
|
-
md2.renderer.rules.math_block = blockRenderer;
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
// node/plugins/markdown-it-prism.ts
|
|
1194
|
-
var _prismjs = require('prismjs'); var _prismjs2 = _interopRequireDefault(_prismjs);
|
|
1195
|
-
var _2 = require('prismjs/components/'); var _3 = _interopRequireDefault(_2);
|
|
1196
|
-
var _htmlparser2 = require('htmlparser2'); var htmlparser2 = _interopRequireWildcard(_htmlparser2);
|
|
1197
|
-
var Tag = class {
|
|
1198
|
-
constructor(tagname, attributes) {
|
|
1199
|
-
this.tagname = tagname;
|
|
1200
|
-
this.attributes = attributes;
|
|
1201
|
-
}
|
|
1202
|
-
asOpen() {
|
|
1203
|
-
return `<${this.tagname} ${Object.entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(" ")}>`;
|
|
1204
|
-
}
|
|
1205
|
-
asClosed() {
|
|
1206
|
-
return `</${this.tagname}>`;
|
|
1207
|
-
}
|
|
1208
|
-
};
|
|
1209
|
-
var DEFAULTS = {
|
|
1210
|
-
plugins: [],
|
|
1211
|
-
init: () => {
|
|
1212
|
-
},
|
|
1213
|
-
defaultLanguageForUnknown: void 0,
|
|
1214
|
-
defaultLanguageForUnspecified: void 0,
|
|
1215
|
-
defaultLanguage: void 0
|
|
1216
|
-
};
|
|
1217
|
-
function loadPrismLang(lang) {
|
|
1218
|
-
if (!lang)
|
|
1219
|
-
return void 0;
|
|
1220
|
-
let langObject = _prismjs2.default.languages[lang];
|
|
1221
|
-
if (langObject === void 0) {
|
|
1222
|
-
_3.default.call(void 0, [lang]);
|
|
1223
|
-
langObject = _prismjs2.default.languages[lang];
|
|
1224
|
-
}
|
|
1225
|
-
return langObject;
|
|
1226
|
-
}
|
|
1227
|
-
function loadPrismPlugin(name) {
|
|
1228
|
-
try {
|
|
1229
|
-
_chunkYUG22S6Wjs.__require.call(void 0, `prismjs/plugins/${name}/prism-${name}`);
|
|
1230
|
-
} catch (e) {
|
|
1231
|
-
throw new Error(`Cannot load Prism plugin "${name}". Please check the spelling.`);
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
function selectLanguage(options, lang) {
|
|
1235
|
-
let langToUse = lang;
|
|
1236
|
-
if (langToUse === "" && options.defaultLanguageForUnspecified !== void 0)
|
|
1237
|
-
langToUse = options.defaultLanguageForUnspecified;
|
|
1238
|
-
let prismLang = loadPrismLang(langToUse);
|
|
1239
|
-
if (prismLang === void 0 && options.defaultLanguageForUnknown !== void 0) {
|
|
1240
|
-
langToUse = options.defaultLanguageForUnknown;
|
|
1241
|
-
prismLang = loadPrismLang(langToUse);
|
|
1242
|
-
}
|
|
1243
|
-
return [langToUse, prismLang];
|
|
1244
|
-
}
|
|
1245
|
-
function highlight(markdownit, options, text, lang) {
|
|
1246
|
-
const [langToUse, prismLang] = selectLanguage(options, lang);
|
|
1247
|
-
let code = text.trimEnd();
|
|
1248
|
-
code = prismLang ? highlightPrism(code, prismLang, langToUse) : markdownit.utils.escapeHtml(code);
|
|
1249
|
-
code = code.split(/\r?\n/g).map((line) => `<span class="line">${line}</span>`).join("\n");
|
|
1250
|
-
const classAttribute = langToUse ? ` class="slidev-code ${markdownit.options.langPrefix}${markdownit.utils.escapeHtml(langToUse)}"` : "";
|
|
1251
|
-
return escapeVueInCode(`<pre${classAttribute}><code>${code}</code></pre>`);
|
|
1252
|
-
}
|
|
1253
|
-
function highlightPrism(code, prismLang, langToUse) {
|
|
1254
|
-
const openTags = [];
|
|
1255
|
-
const parser2 = new htmlparser2.Parser({
|
|
1256
|
-
onopentag(tagname, attributes) {
|
|
1257
|
-
openTags.push(new Tag(tagname, attributes));
|
|
1258
|
-
},
|
|
1259
|
-
onclosetag() {
|
|
1260
|
-
openTags.pop();
|
|
1261
|
-
}
|
|
1262
|
-
});
|
|
1263
|
-
code = _prismjs2.default.highlight(code, prismLang, langToUse);
|
|
1264
|
-
code = code.split(/\r?\n/g).map((line) => {
|
|
1265
|
-
const prefix = openTags.map((tag) => tag.asOpen()).join("");
|
|
1266
|
-
parser2.write(line);
|
|
1267
|
-
const postfix = openTags.reverse().map((tag) => tag.asClosed()).join("");
|
|
1268
|
-
return prefix + line + postfix;
|
|
1269
|
-
}).join("\n");
|
|
1270
|
-
parser2.end();
|
|
1271
|
-
return code;
|
|
1272
|
-
}
|
|
1273
|
-
function checkLanguageOption(options, optionName) {
|
|
1274
|
-
const language = options[optionName];
|
|
1275
|
-
if (language !== void 0 && loadPrismLang(language) === void 0)
|
|
1276
|
-
throw new Error(`Bad option ${optionName}: There is no Prism language '${language}'.`);
|
|
1277
|
-
}
|
|
1278
|
-
function markdownItPrism(markdownit, useroptions) {
|
|
1279
|
-
const options = Object.assign({}, DEFAULTS, useroptions);
|
|
1280
|
-
checkLanguageOption(options, "defaultLanguage");
|
|
1281
|
-
checkLanguageOption(options, "defaultLanguageForUnknown");
|
|
1282
|
-
checkLanguageOption(options, "defaultLanguageForUnspecified");
|
|
1283
|
-
options.defaultLanguageForUnknown = options.defaultLanguageForUnknown || options.defaultLanguage;
|
|
1284
|
-
options.defaultLanguageForUnspecified = options.defaultLanguageForUnspecified || options.defaultLanguage;
|
|
1285
|
-
options.plugins.forEach(loadPrismPlugin);
|
|
1286
|
-
options.init(_prismjs2.default);
|
|
1287
|
-
markdownit.options.highlight = (text, lang) => highlight(markdownit, options, text, lang);
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
// node/plugins/markdown-it-shiki.ts
|
|
1291
|
-
function getThemeName(theme) {
|
|
1292
|
-
if (typeof theme === "string")
|
|
1293
|
-
return theme;
|
|
1294
|
-
return theme.name;
|
|
1295
|
-
}
|
|
1296
|
-
function isShikiDarkModeThemes(theme) {
|
|
1297
|
-
return typeof theme === "object" && ("dark" in theme || "light" in theme);
|
|
1298
|
-
}
|
|
1299
|
-
function resolveShikiOptions(options) {
|
|
1300
|
-
const themes = [];
|
|
1301
|
-
let darkModeThemes;
|
|
1302
|
-
if (!options.theme) {
|
|
1303
|
-
themes.push("nord");
|
|
1304
|
-
} else if (typeof options.theme === "string") {
|
|
1305
|
-
themes.push(options.theme);
|
|
1306
|
-
} else {
|
|
1307
|
-
if (isShikiDarkModeThemes(options.theme)) {
|
|
1308
|
-
darkModeThemes = options.theme;
|
|
1309
|
-
themes.push(options.theme.dark);
|
|
1310
|
-
themes.push(options.theme.light);
|
|
1311
|
-
} else {
|
|
1312
|
-
themes.push(options.theme);
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
return {
|
|
1316
|
-
...options,
|
|
1317
|
-
themes,
|
|
1318
|
-
darkModeThemes: darkModeThemes ? {
|
|
1319
|
-
dark: getThemeName(darkModeThemes.dark),
|
|
1320
|
-
light: getThemeName(darkModeThemes.light)
|
|
1321
|
-
} : void 0
|
|
1322
|
-
};
|
|
1323
|
-
}
|
|
1324
|
-
function trimEndNewLine(code) {
|
|
1325
|
-
return code.replace(/\n$/, "");
|
|
1326
|
-
}
|
|
1327
|
-
var MarkdownItShiki = (markdownit, options = {}) => {
|
|
1328
|
-
const _highlighter = options.highlighter;
|
|
1329
|
-
const { darkModeThemes } = resolveShikiOptions(options);
|
|
1330
|
-
markdownit.options.highlight = (code, lang) => {
|
|
1331
|
-
if (darkModeThemes) {
|
|
1332
|
-
const trimmed = trimEndNewLine(code);
|
|
1333
|
-
const dark = _highlighter.codeToHtml(trimmed, { lang: lang || "text", theme: darkModeThemes.dark }).replace('<pre class="shiki', '<pre class="slidev-code shiki shiki-dark');
|
|
1334
|
-
const light = _highlighter.codeToHtml(trimmed, { lang: lang || "text", theme: darkModeThemes.light }).replace('<pre class="shiki', '<pre class="slidev-code shiki shiki-light');
|
|
1335
|
-
return escapeVueInCode(`<pre class="shiki-container">${dark}${light}</pre>`);
|
|
1336
|
-
} else {
|
|
1337
|
-
return escapeVueInCode(
|
|
1338
|
-
_highlighter.codeToHtml(code, { lang: lang || "text" }).replace('<pre class="shiki"', '<pre class="slidev-code shiki"')
|
|
1339
|
-
);
|
|
1340
|
-
}
|
|
1341
|
-
};
|
|
1342
|
-
};
|
|
1343
|
-
var markdown_it_shiki_default = MarkdownItShiki;
|
|
1344
|
-
|
|
1345
|
-
// node/plugins/markdown.ts
|
|
1346
|
-
var DEFAULT_SHIKI_OPTIONS = {
|
|
1347
|
-
theme: {
|
|
1348
|
-
dark: "min-dark",
|
|
1349
|
-
light: "min-light"
|
|
1350
|
-
}
|
|
1351
|
-
};
|
|
1352
|
-
async function createMarkdownPlugin({ data: { config }, roots, mode, entry }, { markdown: mdOptions }) {
|
|
1353
|
-
const setups = [];
|
|
1354
|
-
const entryPath = _utils.slash.call(void 0, entry);
|
|
1355
|
-
if (config.highlighter === "shiki") {
|
|
1356
|
-
const Shiki = await Promise.resolve().then(() => require("shiki"));
|
|
1357
|
-
const shikiOptions = await _chunkUWTQKD35js.loadSetups.call(void 0, roots, "shiki.ts", Shiki, DEFAULT_SHIKI_OPTIONS, false);
|
|
1358
|
-
const { langs, themes } = resolveShikiOptions(shikiOptions);
|
|
1359
|
-
shikiOptions.highlighter = await Shiki.getHighlighter({ themes, langs });
|
|
1360
|
-
setups.push((md2) => md2.use(markdown_it_shiki_default, shikiOptions));
|
|
1361
|
-
} else {
|
|
1362
|
-
setups.push((md2) => md2.use(markdownItPrism));
|
|
1363
|
-
}
|
|
1364
|
-
if (config.mdc)
|
|
1365
|
-
setups.push((md2) => md2.use(_markdownitmdc2.default));
|
|
1366
|
-
const KatexOptions = await _chunkUWTQKD35js.loadSetups.call(void 0, roots, "katex.ts", {}, { strict: false }, false);
|
|
1367
|
-
return _vite8.default.call(void 0, {
|
|
1368
|
-
include: [/\.md$/],
|
|
1369
|
-
wrapperClasses: "",
|
|
1370
|
-
headEnabled: false,
|
|
1371
|
-
frontmatter: false,
|
|
1372
|
-
markdownItOptions: {
|
|
1373
|
-
quotes: `""''`,
|
|
1374
|
-
html: true,
|
|
1375
|
-
xhtmlOut: true,
|
|
1376
|
-
linkify: true,
|
|
1377
|
-
..._optionalChain([mdOptions, 'optionalAccess', _52 => _52.markdownItOptions])
|
|
1378
|
-
},
|
|
1379
|
-
...mdOptions,
|
|
1380
|
-
markdownItSetup(md2) {
|
|
1381
|
-
md2.use(_markdownitlinkattributes2.default, {
|
|
1382
|
-
attrs: {
|
|
1383
|
-
target: "_blank",
|
|
1384
|
-
rel: "noopener"
|
|
1385
|
-
}
|
|
1386
|
-
});
|
|
1387
|
-
md2.use(_markdownitfootnote2.default);
|
|
1388
|
-
md2.use(_markdownitplugins.taskLists, { enabled: true, lineNumber: true, label: true });
|
|
1389
|
-
md2.use(math_plugin, KatexOptions);
|
|
1390
|
-
setups.forEach((i) => i(md2));
|
|
1391
|
-
_optionalChain([mdOptions, 'optionalAccess', _53 => _53.markdownItSetup, 'optionalCall', _54 => _54(md2)]);
|
|
1392
|
-
},
|
|
1393
|
-
transforms: {
|
|
1394
|
-
before(code, id) {
|
|
1395
|
-
if (id === entryPath)
|
|
1396
|
-
return "";
|
|
1397
|
-
const monaco = config.monaco === true || config.monaco === mode ? transformMarkdownMonaco : truncateMancoMark;
|
|
1398
|
-
code = transformSlotSugar(code);
|
|
1399
|
-
code = transformMermaid(code);
|
|
1400
|
-
code = transformPlantUml(code, config.plantUmlServer);
|
|
1401
|
-
code = monaco(code);
|
|
1402
|
-
code = transformHighlighter(code);
|
|
1403
|
-
code = transformPageCSS(code, id);
|
|
1404
|
-
code = transformKaTex(code);
|
|
1405
|
-
return code;
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
|
-
}
|
|
1410
|
-
function transformKaTex(md2) {
|
|
1411
|
-
return md2.replace(/^\$\$(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?\s*?)?\n([\s\S]+?)^\$\$/mg, (full, rangeStr = "", _, code) => {
|
|
1412
|
-
const ranges = rangeStr.split(/\|/g).map((i) => i.trim());
|
|
1413
|
-
code = code.trimEnd();
|
|
1414
|
-
return `<KaTexBlockWrapper :ranges='${JSON.stringify(ranges)}'>
|
|
1415
|
-
|
|
1416
|
-
$$
|
|
1417
|
-
${code}
|
|
1418
|
-
$$
|
|
1419
|
-
</KaTexBlockWrapper>
|
|
1420
|
-
`;
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
function transformMarkdownMonaco(md2) {
|
|
1424
|
-
md2 = md2.replace(/^```(\w+?)\s*{monaco-diff}\s*?({.*?})?\s*?\n([\s\S]+?)^~~~\s*?\n([\s\S]+?)^```/mg, (full, lang = "ts", options = "{}", code, diff) => {
|
|
1425
|
-
lang = lang.trim();
|
|
1426
|
-
options = options.trim() || "{}";
|
|
1427
|
-
const encoded = base64.encode(code, true);
|
|
1428
|
-
const encodedDiff = base64.encode(diff, true);
|
|
1429
|
-
return `<Monaco :code="'${encoded}'" :diff="'${encodedDiff}'" lang="${lang}" v-bind="${options}" />`;
|
|
1430
|
-
});
|
|
1431
|
-
md2 = md2.replace(/^```(\w+?)\s*{monaco}\s*?({.*?})?\s*?\n([\s\S]+?)^```/mg, (full, lang = "ts", options = "{}", code) => {
|
|
1432
|
-
lang = lang.trim();
|
|
1433
|
-
options = options.trim() || "{}";
|
|
1434
|
-
const encoded = base64.encode(code, true);
|
|
1435
|
-
return `<Monaco :code="'${encoded}'" lang="${lang}" v-bind="${options}" />`;
|
|
1436
|
-
});
|
|
1437
|
-
return md2;
|
|
1438
|
-
}
|
|
1439
|
-
function truncateMancoMark(md2) {
|
|
1440
|
-
return md2.replace(/{monaco.*?}/g, "");
|
|
1441
|
-
}
|
|
1442
|
-
function transformSlotSugar(md2) {
|
|
1443
|
-
const lines = md2.split(/\r?\n/g);
|
|
1444
|
-
let prevSlot = false;
|
|
1445
|
-
const { isLineInsideCodeblocks } = getCodeBlocks(md2);
|
|
1446
|
-
lines.forEach((line, idx) => {
|
|
1447
|
-
if (isLineInsideCodeblocks(idx))
|
|
1448
|
-
return;
|
|
1449
|
-
const match = line.trimEnd().match(/^::\s*(\w+)\s*::$/);
|
|
1450
|
-
if (match) {
|
|
1451
|
-
lines[idx] = `${prevSlot ? "\n\n</template>\n" : "\n"}<template v-slot:${match[1]}="slotProps">
|
|
1452
|
-
`;
|
|
1453
|
-
prevSlot = true;
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
if (prevSlot)
|
|
1457
|
-
lines[lines.length - 1] += "\n\n</template>";
|
|
1458
|
-
return lines.join("\n");
|
|
1459
|
-
}
|
|
1460
|
-
function transformHighlighter(md2) {
|
|
1461
|
-
return md2.replace(/^```(\w+?)(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?\s*?)?\n([\s\S]+?)^```/mg, (full, lang = "", rangeStr = "", options = "", code) => {
|
|
1462
|
-
const ranges = rangeStr.split(/\|/g).map((i) => i.trim());
|
|
1463
|
-
code = code.trimEnd();
|
|
1464
|
-
options = options.trim() || "{}";
|
|
1465
|
-
return `
|
|
1466
|
-
<CodeBlockWrapper v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>
|
|
1467
|
-
|
|
1468
|
-
\`\`\`${lang}
|
|
1469
|
-
${code}
|
|
1470
|
-
\`\`\`
|
|
1471
|
-
|
|
1472
|
-
</CodeBlockWrapper>`;
|
|
1473
|
-
});
|
|
1474
|
-
}
|
|
1475
|
-
function getCodeBlocks(md2) {
|
|
1476
|
-
const codeblocks = Array.from(md2.matchAll(/^```[\s\S]*?^```/mg)).map((m) => {
|
|
1477
|
-
const start = m.index;
|
|
1478
|
-
const end = m.index + m[0].length;
|
|
1479
|
-
const startLine = _optionalChain([md2, 'access', _55 => _55.slice, 'call', _56 => _56(0, start), 'access', _57 => _57.match, 'call', _58 => _58(/\n/g), 'optionalAccess', _59 => _59.length]) || 0;
|
|
1480
|
-
const endLine = _optionalChain([md2, 'access', _60 => _60.slice, 'call', _61 => _61(0, end), 'access', _62 => _62.match, 'call', _63 => _63(/\n/g), 'optionalAccess', _64 => _64.length]) || 0;
|
|
1481
|
-
return [start, end, startLine, endLine];
|
|
1482
|
-
});
|
|
1483
|
-
return {
|
|
1484
|
-
codeblocks,
|
|
1485
|
-
isInsideCodeblocks(idx) {
|
|
1486
|
-
return codeblocks.some(([s, e]) => s <= idx && idx <= e);
|
|
1487
|
-
},
|
|
1488
|
-
isLineInsideCodeblocks(line) {
|
|
1489
|
-
return codeblocks.some(([, , s, e]) => s <= line && line <= e);
|
|
1490
|
-
}
|
|
1491
|
-
};
|
|
1492
|
-
}
|
|
1493
|
-
function transformPageCSS(md2, id) {
|
|
1494
|
-
const page = _optionalChain([id, 'access', _65 => _65.match, 'call', _66 => _66(/(\d+)\.md$/), 'optionalAccess', _67 => _67[1]]);
|
|
1495
|
-
if (!page)
|
|
1496
|
-
return md2;
|
|
1497
|
-
const { isInsideCodeblocks } = getCodeBlocks(md2);
|
|
1498
|
-
const result = md2.replace(
|
|
1499
|
-
/(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g,
|
|
1500
|
-
(full, start, css, end, index) => {
|
|
1501
|
-
if (index < 0 || isInsideCodeblocks(index))
|
|
1502
|
-
return full;
|
|
1503
|
-
if (!start.includes("scoped"))
|
|
1504
|
-
start = start.replace("<style", "<style scoped");
|
|
1505
|
-
return `${start}
|
|
1506
|
-
${css}${end}`;
|
|
1507
|
-
}
|
|
1508
|
-
);
|
|
1509
|
-
return result;
|
|
1510
|
-
}
|
|
1511
|
-
function transformMermaid(md2) {
|
|
1512
|
-
return md2.replace(/^```mermaid\s*?({.*?})?\n([\s\S]+?)\n```/mg, (full, options = "", code = "") => {
|
|
1513
|
-
code = code.trim();
|
|
1514
|
-
options = options.trim() || "{}";
|
|
1515
|
-
const encoded = base64.encode(code, true);
|
|
1516
|
-
return `<Mermaid :code="'${encoded}'" v-bind="${options}" />`;
|
|
1517
|
-
});
|
|
1518
|
-
}
|
|
1519
|
-
function transformPlantUml(md2, server) {
|
|
1520
|
-
return md2.replace(/^```plantuml\s*?({.*?})?\n([\s\S]+?)\n```/mg, (full, options = "", content = "") => {
|
|
1521
|
-
const code = _plantumlencoder.encode.call(void 0, content.trim());
|
|
1522
|
-
options = options.trim() || "{}";
|
|
1523
|
-
return `<PlantUml :code="'${code}'" :server="'${server}'" v-bind="${options}" />`;
|
|
1524
|
-
});
|
|
1525
|
-
}
|
|
1526
|
-
function escapeVueInCode(md2) {
|
|
1527
|
-
return md2.replace(/{{(.*?)}}/g, "{{$1}}");
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
// node/plugins/patchTransform.ts
|
|
1531
|
-
|
|
1532
|
-
function createFixPlugins(options) {
|
|
1533
|
-
const define = _utils.objectEntries.call(void 0, getDefine(options));
|
|
1534
|
-
return [
|
|
1535
|
-
{
|
|
1536
|
-
name: "slidev:flags",
|
|
1537
|
-
enforce: "pre",
|
|
1538
|
-
transform(code, id) {
|
|
1539
|
-
if (id.match(/\.vue($|\?)/)) {
|
|
1540
|
-
const original = code;
|
|
1541
|
-
define.forEach(([from, to]) => {
|
|
1542
|
-
code = code.replace(new RegExp(from, "g"), to);
|
|
1543
|
-
});
|
|
1544
|
-
if (original !== code)
|
|
1545
|
-
return code;
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
];
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
// node/plugins/preset.ts
|
|
1553
|
-
var customElements = /* @__PURE__ */ new Set([
|
|
1554
|
-
// katex
|
|
1555
|
-
"annotation",
|
|
1556
|
-
"math",
|
|
1557
|
-
"menclose",
|
|
1558
|
-
"mfrac",
|
|
1559
|
-
"mglyph",
|
|
1560
|
-
"mi",
|
|
1561
|
-
"mlabeledtr",
|
|
1562
|
-
"mn",
|
|
1563
|
-
"mo",
|
|
1564
|
-
"mover",
|
|
1565
|
-
"mpadded",
|
|
1566
|
-
"mphantom",
|
|
1567
|
-
"mroot",
|
|
1568
|
-
"mrow",
|
|
1569
|
-
"mspace",
|
|
1570
|
-
"msqrt",
|
|
1571
|
-
"mstyle",
|
|
1572
|
-
"msub",
|
|
1573
|
-
"msubsup",
|
|
1574
|
-
"msup",
|
|
1575
|
-
"mtable",
|
|
1576
|
-
"mtd",
|
|
1577
|
-
"mtext",
|
|
1578
|
-
"mtr",
|
|
1579
|
-
"munder",
|
|
1580
|
-
"munderover",
|
|
1581
|
-
"semantics"
|
|
1582
|
-
]);
|
|
1583
|
-
async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
1584
|
-
const {
|
|
1585
|
-
vue: vueOptions = {},
|
|
1586
|
-
vuejsx: vuejsxOptions = {},
|
|
1587
|
-
components: componentsOptions = {},
|
|
1588
|
-
icons: iconsOptions = {},
|
|
1589
|
-
remoteAssets: remoteAssetsOptions = {},
|
|
1590
|
-
serverRef: serverRefOptions = {}
|
|
1591
|
-
} = pluginOptions;
|
|
1592
|
-
const {
|
|
1593
|
-
mode,
|
|
1594
|
-
themeRoots,
|
|
1595
|
-
addonRoots,
|
|
1596
|
-
clientRoot,
|
|
1597
|
-
data: { config }
|
|
1598
|
-
} = options;
|
|
1599
|
-
const VuePlugin = _pluginvue2.default.call(void 0, {
|
|
1600
|
-
include: [/\.vue$/, /\.md$/],
|
|
1601
|
-
exclude: [],
|
|
1602
|
-
template: {
|
|
1603
|
-
compilerOptions: {
|
|
1604
|
-
isCustomElement(tag) {
|
|
1605
|
-
return customElements.has(tag);
|
|
1606
|
-
}
|
|
1607
|
-
},
|
|
1608
|
-
..._optionalChain([vueOptions, 'optionalAccess', _68 => _68.template])
|
|
1609
|
-
},
|
|
1610
|
-
...vueOptions
|
|
1611
|
-
});
|
|
1612
|
-
const VueJsxPlugin = _pluginvuejsx2.default.call(void 0, vuejsxOptions);
|
|
1613
|
-
const MarkdownPlugin = await createMarkdownPlugin(options, pluginOptions);
|
|
1614
|
-
const drawingData = await loadDrawings(options);
|
|
1615
|
-
const publicRoots = themeRoots.map((i) => _path.join.call(void 0, i, "public")).filter(_fs.existsSync);
|
|
1616
|
-
const plugins = [
|
|
1617
|
-
MarkdownPlugin,
|
|
1618
|
-
VueJsxPlugin,
|
|
1619
|
-
VuePlugin,
|
|
1620
|
-
createSlidesLoader(options, pluginOptions, serverOptions),
|
|
1621
|
-
_vite6.default.call(void 0, {
|
|
1622
|
-
extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
|
|
1623
|
-
dirs: [
|
|
1624
|
-
_path.join.call(void 0, clientRoot, "builtin"),
|
|
1625
|
-
_path.join.call(void 0, clientRoot, "components"),
|
|
1626
|
-
...themeRoots.map((i) => _path.join.call(void 0, i, "components")),
|
|
1627
|
-
...addonRoots.map((i) => _path.join.call(void 0, i, "components")),
|
|
1628
|
-
"src/components",
|
|
1629
|
-
"components"
|
|
1630
|
-
],
|
|
1631
|
-
include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/],
|
|
1632
|
-
exclude: [],
|
|
1633
|
-
resolvers: [
|
|
1634
|
-
_resolver2.default.call(void 0, {
|
|
1635
|
-
prefix: "",
|
|
1636
|
-
customCollections: Object.keys(iconsOptions.customCollections || [])
|
|
1637
|
-
})
|
|
1638
|
-
],
|
|
1639
|
-
dts: false,
|
|
1640
|
-
...componentsOptions
|
|
1641
|
-
}),
|
|
1642
|
-
_vite4.default.call(void 0, {
|
|
1643
|
-
defaultClass: "slidev-icon",
|
|
1644
|
-
autoInstall: true,
|
|
1645
|
-
...iconsOptions
|
|
1646
|
-
}),
|
|
1647
|
-
config.remoteAssets === true || config.remoteAssets === mode ? Promise.resolve().then(() => require("vite-plugin-remote-assets")).then((r) => r.default({
|
|
1648
|
-
rules: [
|
|
1649
|
-
...r.DefaultRules,
|
|
1650
|
-
{
|
|
1651
|
-
match: /\b(https?:\/\/image.unsplash\.com.*?)(?=[`'")\]])/ig,
|
|
1652
|
-
ext: ".png"
|
|
1653
|
-
}
|
|
1654
|
-
],
|
|
1655
|
-
resolveMode: (id) => id.endsWith("index.html") ? "relative" : "@fs",
|
|
1656
|
-
awaitDownload: mode === "build",
|
|
1657
|
-
...remoteAssetsOptions
|
|
1658
|
-
})) : null,
|
|
1659
|
-
_vitepluginvueserverref2.default.call(void 0, {
|
|
1660
|
-
debug: _process2.default.env.NODE_ENV === "development",
|
|
1661
|
-
state: {
|
|
1662
|
-
sync: false,
|
|
1663
|
-
nav: {
|
|
1664
|
-
page: 0,
|
|
1665
|
-
clicks: 0
|
|
1666
|
-
},
|
|
1667
|
-
drawings: drawingData,
|
|
1668
|
-
...serverRefOptions.state
|
|
1669
|
-
},
|
|
1670
|
-
onChanged(key, data, patch, timestamp) {
|
|
1671
|
-
serverRefOptions.onChanged && serverRefOptions.onChanged(key, data, patch, timestamp);
|
|
1672
|
-
if (!options.data.config.drawings.persist)
|
|
1673
|
-
return;
|
|
1674
|
-
if (key === "drawings")
|
|
1675
|
-
writeDrawings(options, _nullishCoalesce(patch, () => ( data)));
|
|
1676
|
-
}
|
|
1677
|
-
}),
|
|
1678
|
-
createConfigPlugin(options),
|
|
1679
|
-
createClientSetupPlugin(options),
|
|
1680
|
-
createMonacoTypesLoader(),
|
|
1681
|
-
createFixPlugins(options),
|
|
1682
|
-
publicRoots.length ? Promise.resolve().then(() => require("vite-plugin-static-copy")).then((r) => r.viteStaticCopy({
|
|
1683
|
-
silent: true,
|
|
1684
|
-
targets: publicRoots.map((r2) => ({
|
|
1685
|
-
src: `${r2}/*`,
|
|
1686
|
-
dest: "theme"
|
|
1687
|
-
}))
|
|
1688
|
-
})) : null,
|
|
1689
|
-
options.inspect ? Promise.resolve().then(() => require("vite-plugin-inspect")).then((r) => (r.default || r)({
|
|
1690
|
-
dev: true,
|
|
1691
|
-
build: true
|
|
1692
|
-
})) : null,
|
|
1693
|
-
config.css === "none" ? null : config.css === "windicss" ? Promise.resolve().then(() => require("./windicss-G7ISUN5H.js")).then((r) => r.createWindiCSSPlugin(options, pluginOptions)) : Promise.resolve().then(() => require("./unocss-E5M4APXD.js")).then((r) => r.createUnocssPlugin(options, pluginOptions))
|
|
1694
|
-
];
|
|
1695
|
-
return (await Promise.all(plugins)).flat().filter(_utils.notNullish);
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
exports.getIndexHtml = getIndexHtml; exports.mergeViteConfigs = mergeViteConfigs; exports.require_fast_deep_equal = require_fast_deep_equal; exports.ViteSlidevPlugin = ViteSlidevPlugin;
|