@slidev/cli 0.50.0-beta.4 → 0.50.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-UNQ5DBLZ.js";
|
|
10
10
|
|
|
11
11
|
// package.json
|
|
12
|
-
var version = "0.50.0-beta.
|
|
12
|
+
var version = "0.50.0-beta.6";
|
|
13
13
|
|
|
14
14
|
// node/integrations/themes.ts
|
|
15
15
|
import { join } from "node:path";
|
|
@@ -174,9 +174,118 @@ function getBodyJson(req) {
|
|
|
174
174
|
|
|
175
175
|
// node/vite/compilerFlagsVue.ts
|
|
176
176
|
import { objectEntries } from "@antfu/utils";
|
|
177
|
+
function createVueCompilerFlagsPlugin(options) {
|
|
178
|
+
const define = objectEntries(options.utils.define);
|
|
179
|
+
return {
|
|
180
|
+
name: "slidev:flags",
|
|
181
|
+
enforce: "pre",
|
|
182
|
+
transform(code, id) {
|
|
183
|
+
if (!id.match(/\.vue($|\?)/) && !id.includes("?vue&"))
|
|
184
|
+
return;
|
|
185
|
+
const original = code;
|
|
186
|
+
define.forEach(([from, to]) => {
|
|
187
|
+
code = code.replaceAll(from, to);
|
|
188
|
+
});
|
|
189
|
+
if (original !== code)
|
|
190
|
+
return code;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
177
194
|
|
|
178
|
-
// node/vite/
|
|
195
|
+
// node/vite/components.ts
|
|
179
196
|
import { join as join2 } from "node:path";
|
|
197
|
+
import IconsResolver from "unplugin-icons/resolver";
|
|
198
|
+
import Components from "unplugin-vue-components/vite";
|
|
199
|
+
function createComponentsPlugin({ clientRoot, roots }, pluginOptions) {
|
|
200
|
+
return Components({
|
|
201
|
+
extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
|
|
202
|
+
dirs: [
|
|
203
|
+
join2(clientRoot, "builtin"),
|
|
204
|
+
...roots.map((i) => join2(i, "components"))
|
|
205
|
+
],
|
|
206
|
+
include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
|
|
207
|
+
exclude: [],
|
|
208
|
+
resolvers: [
|
|
209
|
+
IconsResolver({
|
|
210
|
+
prefix: "",
|
|
211
|
+
customCollections: Object.keys(pluginOptions.icons?.customCollections || [])
|
|
212
|
+
})
|
|
213
|
+
],
|
|
214
|
+
dts: false,
|
|
215
|
+
...pluginOptions.components
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// node/vite/common.ts
|
|
220
|
+
var regexSlideReqPath = /^\/__slidev\/slides\/(\d+)\.json$/;
|
|
221
|
+
var regexSlideFacadeId = /^\/@slidev\/slides\/(\d+)\/(md|frontmatter)($|\?)/;
|
|
222
|
+
var regexSlideSourceId = /__slidev_(\d+)\.(md|frontmatter)$/;
|
|
223
|
+
var templateInjectionMarker = "/* @slidev-injection */";
|
|
224
|
+
var templateImportContextUtils = `import { useSlideContext as _useSlideContext, frontmatterToProps as _frontmatterToProps } from "@slidev/client/context.ts"`;
|
|
225
|
+
var templateInitContext = `const { $slidev, $nav, $clicksContext, $clicks, $page, $renderContext, $frontmatter } = _useSlideContext()`;
|
|
226
|
+
|
|
227
|
+
// node/vite/contextInjection.ts
|
|
228
|
+
function createContextInjectionPlugin() {
|
|
229
|
+
return {
|
|
230
|
+
name: "slidev:context-injection",
|
|
231
|
+
async transform(code, id) {
|
|
232
|
+
if (!id.endsWith(".vue") || id.includes("/@slidev/client/") || id.includes("/packages/client/"))
|
|
233
|
+
return;
|
|
234
|
+
if (code.includes(templateInjectionMarker) || code.includes("useSlideContext()"))
|
|
235
|
+
return code;
|
|
236
|
+
const imports = [
|
|
237
|
+
templateImportContextUtils,
|
|
238
|
+
templateInitContext,
|
|
239
|
+
templateInjectionMarker
|
|
240
|
+
];
|
|
241
|
+
const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/);
|
|
242
|
+
if (matchScript && matchScript[2]) {
|
|
243
|
+
return code.replace(/(<script.*>)/g, `$1
|
|
244
|
+
${imports.join("\n")}
|
|
245
|
+
`);
|
|
246
|
+
} else if (matchScript && !matchScript[2]) {
|
|
247
|
+
const matchExport = code.match(/export\s+default\s+\{/);
|
|
248
|
+
if (matchExport) {
|
|
249
|
+
const exportIndex = (matchExport.index || 0) + matchExport[0].length;
|
|
250
|
+
let component = code.slice(exportIndex);
|
|
251
|
+
component = component.slice(0, component.indexOf("</script>"));
|
|
252
|
+
const scriptIndex = (matchScript.index || 0) + matchScript[0].length;
|
|
253
|
+
const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants.ts"\n';
|
|
254
|
+
code = `${code.slice(0, scriptIndex)}${provideImport}${code.slice(scriptIndex)}`;
|
|
255
|
+
let injectIndex = exportIndex + provideImport.length;
|
|
256
|
+
let injectObject = "$slidev: { from: injectionSlidevContext },";
|
|
257
|
+
const matchInject = component.match(/.*inject\s*:\s*([[{])/);
|
|
258
|
+
if (matchInject) {
|
|
259
|
+
injectIndex += (matchInject.index || 0) + matchInject[0].length;
|
|
260
|
+
if (matchInject[1] === "[") {
|
|
261
|
+
let injects = component.slice((matchInject.index || 0) + matchInject[0].length);
|
|
262
|
+
const injectEndIndex = injects.indexOf("]");
|
|
263
|
+
injects = injects.slice(0, injectEndIndex);
|
|
264
|
+
injectObject += injects.split(",").map((inject) => `${inject}: {from: ${inject}}`).join(",");
|
|
265
|
+
return `${code.slice(0, injectIndex - 1)}{
|
|
266
|
+
${injectObject}
|
|
267
|
+
}${code.slice(injectIndex + injectEndIndex + 1)}`;
|
|
268
|
+
} else {
|
|
269
|
+
return `${code.slice(0, injectIndex)}
|
|
270
|
+
${injectObject}
|
|
271
|
+
${code.slice(injectIndex)}`;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return `${code.slice(0, injectIndex)}
|
|
275
|
+
inject: { ${injectObject} },
|
|
276
|
+
${code.slice(injectIndex)}`;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return `<script setup>
|
|
280
|
+
${imports.join("\n")}
|
|
281
|
+
</script>
|
|
282
|
+
${code}`;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// node/vite/extendConfig.ts
|
|
288
|
+
import { join as join3 } from "node:path";
|
|
180
289
|
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
181
290
|
import { slash, uniq } from "@antfu/utils";
|
|
182
291
|
import { createResolve } from "mlly";
|
|
@@ -238,7 +347,7 @@ function createConfigPlugin(options) {
|
|
|
238
347
|
name: "slidev:config",
|
|
239
348
|
async config(config) {
|
|
240
349
|
const injection = {
|
|
241
|
-
define:
|
|
350
|
+
define: options.utils.define,
|
|
242
351
|
resolve: {
|
|
243
352
|
alias: [
|
|
244
353
|
{
|
|
@@ -291,7 +400,7 @@ function createConfigPlugin(options) {
|
|
|
291
400
|
])
|
|
292
401
|
}
|
|
293
402
|
},
|
|
294
|
-
publicDir:
|
|
403
|
+
publicDir: join3(options.userRoot, "public"),
|
|
295
404
|
build: {
|
|
296
405
|
rollupOptions: {
|
|
297
406
|
output: {
|
|
@@ -318,21 +427,18 @@ function createConfigPlugin(options) {
|
|
|
318
427
|
}
|
|
319
428
|
}
|
|
320
429
|
}
|
|
321
|
-
}
|
|
430
|
+
},
|
|
431
|
+
cacheDir: isInstalledGlobally.value ? join3(options.cliRoot, "node_modules/.vite") : void 0
|
|
322
432
|
};
|
|
323
433
|
function isSlidevClient(id) {
|
|
324
434
|
return id.includes("/@slidev/") || id.includes("/slidev/packages/client/") || id.includes("/@vueuse/");
|
|
325
435
|
}
|
|
326
|
-
if (isInstalledGlobally.value) {
|
|
327
|
-
injection.cacheDir = join2(options.cliRoot, "node_modules/.vite");
|
|
328
|
-
injection.root = options.cliRoot;
|
|
329
|
-
}
|
|
330
436
|
return mergeConfig(injection, config);
|
|
331
437
|
},
|
|
332
438
|
configureServer(server) {
|
|
333
439
|
return () => {
|
|
334
440
|
server.middlewares.use(async (req, res, next) => {
|
|
335
|
-
if (req.url
|
|
441
|
+
if (req.url === "/index.html") {
|
|
336
442
|
res.setHeader("Content-Type", "text/html");
|
|
337
443
|
res.statusCode = 200;
|
|
338
444
|
res.end(options.utils.indexHtml);
|
|
@@ -344,139 +450,11 @@ function createConfigPlugin(options) {
|
|
|
344
450
|
}
|
|
345
451
|
};
|
|
346
452
|
}
|
|
347
|
-
function getDefine(options) {
|
|
348
|
-
return {
|
|
349
|
-
__DEV__: options.mode === "dev" ? "true" : "false",
|
|
350
|
-
__SLIDEV_CLIENT_ROOT__: JSON.stringify(toAtFS(options.clientRoot)),
|
|
351
|
-
__SLIDEV_HASH_ROUTE__: JSON.stringify(options.data.config.routerMode === "hash"),
|
|
352
|
-
__SLIDEV_FEATURE_DRAWINGS__: JSON.stringify(options.data.config.drawings.enabled === true || options.data.config.drawings.enabled === options.mode),
|
|
353
|
-
__SLIDEV_FEATURE_EDITOR__: JSON.stringify(options.mode === "dev" && options.data.config.editor !== false),
|
|
354
|
-
__SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
|
|
355
|
-
__SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
|
|
356
|
-
__SLIDEV_FEATURE_PRESENTER__: JSON.stringify(options.data.config.presenter === true || options.data.config.presenter === options.mode),
|
|
357
|
-
__SLIDEV_FEATURE_PRINT__: JSON.stringify(options.mode === "export" || options.mode === "build" && [true, "true", "auto"].includes(options.data.config.download)),
|
|
358
|
-
__SLIDEV_FEATURE_WAKE_LOCK__: JSON.stringify(options.data.config.wakeLock === true || options.data.config.wakeLock === options.mode),
|
|
359
|
-
__SLIDEV_HAS_SERVER__: options.mode !== "build" ? "true" : "false"
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// node/vite/compilerFlagsVue.ts
|
|
364
|
-
function createVueCompilerFlagsPlugin(options) {
|
|
365
|
-
const define = objectEntries(getDefine(options));
|
|
366
|
-
return [
|
|
367
|
-
{
|
|
368
|
-
name: "slidev:flags",
|
|
369
|
-
enforce: "pre",
|
|
370
|
-
transform(code, id) {
|
|
371
|
-
if (id.match(/\.vue($|\?)/)) {
|
|
372
|
-
const original = code;
|
|
373
|
-
define.forEach(([from, to]) => {
|
|
374
|
-
code = code.replace(new RegExp(from, "g"), to);
|
|
375
|
-
});
|
|
376
|
-
if (original !== code)
|
|
377
|
-
return code;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
];
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
// node/vite/components.ts
|
|
385
|
-
import { join as join3 } from "node:path";
|
|
386
|
-
import IconsResolver from "unplugin-icons/resolver";
|
|
387
|
-
import Components from "unplugin-vue-components/vite";
|
|
388
|
-
function createComponentsPlugin({ clientRoot, roots }, pluginOptions) {
|
|
389
|
-
return Components({
|
|
390
|
-
extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
|
|
391
|
-
dirs: [
|
|
392
|
-
join3(clientRoot, "builtin"),
|
|
393
|
-
...roots.map((i) => join3(i, "components"))
|
|
394
|
-
],
|
|
395
|
-
include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
|
|
396
|
-
exclude: [],
|
|
397
|
-
resolvers: [
|
|
398
|
-
IconsResolver({
|
|
399
|
-
prefix: "",
|
|
400
|
-
customCollections: Object.keys(pluginOptions.icons?.customCollections || [])
|
|
401
|
-
})
|
|
402
|
-
],
|
|
403
|
-
dts: false,
|
|
404
|
-
...pluginOptions.components
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// node/vite/common.ts
|
|
409
|
-
var regexSlideReqPath = /^\/__slidev\/slides\/(\d+)\.json$/;
|
|
410
|
-
var regexSlideFacadeId = /^\/@slidev\/slides\/(\d+)\/(md|frontmatter)($|\?)/;
|
|
411
|
-
var regexSlideSourceId = /__slidev_(\d+)\.(md|frontmatter)$/;
|
|
412
|
-
var templateInjectionMarker = "/* @slidev-injection */";
|
|
413
|
-
var templateImportContextUtils = `import { useSlideContext as _useSlideContext, frontmatterToProps as _frontmatterToProps } from "@slidev/client/context.ts"`;
|
|
414
|
-
var templateInitContext = `const { $slidev, $nav, $clicksContext, $clicks, $page, $renderContext, $frontmatter } = _useSlideContext()`;
|
|
415
|
-
|
|
416
|
-
// node/vite/contextInjection.ts
|
|
417
|
-
function createContextInjectionPlugin() {
|
|
418
|
-
return {
|
|
419
|
-
name: "slidev:context-injection",
|
|
420
|
-
async transform(code, id) {
|
|
421
|
-
if (!id.endsWith(".vue") || id.includes("/@slidev/client/") || id.includes("/packages/client/"))
|
|
422
|
-
return;
|
|
423
|
-
if (code.includes(templateInjectionMarker) || code.includes("useSlideContext()"))
|
|
424
|
-
return code;
|
|
425
|
-
const imports = [
|
|
426
|
-
templateImportContextUtils,
|
|
427
|
-
templateInitContext,
|
|
428
|
-
templateInjectionMarker
|
|
429
|
-
];
|
|
430
|
-
const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/);
|
|
431
|
-
if (matchScript && matchScript[2]) {
|
|
432
|
-
return code.replace(/(<script.*>)/g, `$1
|
|
433
|
-
${imports.join("\n")}
|
|
434
|
-
`);
|
|
435
|
-
} else if (matchScript && !matchScript[2]) {
|
|
436
|
-
const matchExport = code.match(/export\s+default\s+\{/);
|
|
437
|
-
if (matchExport) {
|
|
438
|
-
const exportIndex = (matchExport.index || 0) + matchExport[0].length;
|
|
439
|
-
let component = code.slice(exportIndex);
|
|
440
|
-
component = component.slice(0, component.indexOf("</script>"));
|
|
441
|
-
const scriptIndex = (matchScript.index || 0) + matchScript[0].length;
|
|
442
|
-
const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants.ts"\n';
|
|
443
|
-
code = `${code.slice(0, scriptIndex)}${provideImport}${code.slice(scriptIndex)}`;
|
|
444
|
-
let injectIndex = exportIndex + provideImport.length;
|
|
445
|
-
let injectObject = "$slidev: { from: injectionSlidevContext },";
|
|
446
|
-
const matchInject = component.match(/.*inject\s*:\s*([[{])/);
|
|
447
|
-
if (matchInject) {
|
|
448
|
-
injectIndex += (matchInject.index || 0) + matchInject[0].length;
|
|
449
|
-
if (matchInject[1] === "[") {
|
|
450
|
-
let injects = component.slice((matchInject.index || 0) + matchInject[0].length);
|
|
451
|
-
const injectEndIndex = injects.indexOf("]");
|
|
452
|
-
injects = injects.slice(0, injectEndIndex);
|
|
453
|
-
injectObject += injects.split(",").map((inject) => `${inject}: {from: ${inject}}`).join(",");
|
|
454
|
-
return `${code.slice(0, injectIndex - 1)}{
|
|
455
|
-
${injectObject}
|
|
456
|
-
}${code.slice(injectIndex + injectEndIndex + 1)}`;
|
|
457
|
-
} else {
|
|
458
|
-
return `${code.slice(0, injectIndex)}
|
|
459
|
-
${injectObject}
|
|
460
|
-
${code.slice(injectIndex)}`;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
return `${code.slice(0, injectIndex)}
|
|
464
|
-
inject: { ${injectObject} },
|
|
465
|
-
${code.slice(injectIndex)}`;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
return `<script setup>
|
|
469
|
-
${imports.join("\n")}
|
|
470
|
-
</script>
|
|
471
|
-
${code}`;
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
453
|
|
|
476
454
|
// node/vite/hmrPatch.ts
|
|
477
455
|
function createHmrPatchPlugin() {
|
|
478
456
|
return {
|
|
479
|
-
name: "slidev:
|
|
457
|
+
name: "slidev:hmr-patch",
|
|
480
458
|
transform(code, id) {
|
|
481
459
|
if (!id.match(regexSlideSourceId))
|
|
482
460
|
return;
|
|
@@ -520,7 +498,7 @@ function createLayoutWrapperPlugin({ data, utils }) {
|
|
|
520
498
|
if (type !== "md")
|
|
521
499
|
return;
|
|
522
500
|
const index = +no - 1;
|
|
523
|
-
const layouts =
|
|
501
|
+
const layouts = utils.getLayouts();
|
|
524
502
|
const rawLayoutName = data.slides[index]?.frontmatter?.layout ?? data.slides[0]?.frontmatter?.defaults?.layout;
|
|
525
503
|
let layoutName = rawLayoutName || (index === 0 ? "cover" : "default");
|
|
526
504
|
if (!layouts[layoutName]) {
|
|
@@ -1000,12 +978,22 @@ function withRenderedNote(data) {
|
|
|
1000
978
|
};
|
|
1001
979
|
}
|
|
1002
980
|
function createSlidesLoader(options, serverOptions) {
|
|
981
|
+
const { data, mode, utils } = options;
|
|
1003
982
|
const hmrSlidesIndexes = /* @__PURE__ */ new Set();
|
|
1004
983
|
let server;
|
|
1005
984
|
let skipHmr = null;
|
|
1006
|
-
|
|
1007
|
-
function
|
|
1008
|
-
|
|
985
|
+
let sourceIds = resolveSourceIds(data);
|
|
986
|
+
function resolveSourceIds(data2) {
|
|
987
|
+
const ids = {
|
|
988
|
+
md: [],
|
|
989
|
+
frontmatter: []
|
|
990
|
+
};
|
|
991
|
+
for (const type of ["md", "frontmatter"]) {
|
|
992
|
+
for (let i = 0; i < data2.slides.length; i++) {
|
|
993
|
+
ids[type].push(`${data2.slides[i].source.filepath}__slidev_${i + 1}.${type}`);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
return ids;
|
|
1009
997
|
}
|
|
1010
998
|
function updateServerWatcher() {
|
|
1011
999
|
if (!server)
|
|
@@ -1063,11 +1051,11 @@ function createSlidesLoader(options, serverOptions) {
|
|
|
1063
1051
|
fileContent
|
|
1064
1052
|
};
|
|
1065
1053
|
server?.moduleGraph.invalidateModule(
|
|
1066
|
-
server.moduleGraph.getModuleById(
|
|
1054
|
+
server.moduleGraph.getModuleById(sourceIds.md[idx])
|
|
1067
1055
|
);
|
|
1068
1056
|
if (body.frontmatter) {
|
|
1069
1057
|
server?.moduleGraph.invalidateModule(
|
|
1070
|
-
server.moduleGraph.getModuleById(
|
|
1058
|
+
server.moduleGraph.getModuleById(sourceIds.frontmatter[idx])
|
|
1071
1059
|
);
|
|
1072
1060
|
}
|
|
1073
1061
|
}
|
|
@@ -1095,9 +1083,19 @@ function createSlidesLoader(options, serverOptions) {
|
|
|
1095
1083
|
return [];
|
|
1096
1084
|
}
|
|
1097
1085
|
const moduleIds = /* @__PURE__ */ new Set();
|
|
1086
|
+
const newSourceIds = resolveSourceIds(newData);
|
|
1087
|
+
for (const type of ["md", "frontmatter"]) {
|
|
1088
|
+
const old = sourceIds[type];
|
|
1089
|
+
const newIds = newSourceIds[type];
|
|
1090
|
+
for (let i = 0; i < newIds.length; i++) {
|
|
1091
|
+
if (old[i] !== newIds[i]) {
|
|
1092
|
+
moduleIds.add(`${VIRTUAL_SLIDE_PREFIX}${i + 1}/${type}`);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
sourceIds = newSourceIds;
|
|
1098
1097
|
if (data.slides.length !== newData.slides.length) {
|
|
1099
1098
|
moduleIds.add(templateSlides.id);
|
|
1100
|
-
range(newData.slides.length).map((i) => hmrSlidesIndexes.add(i));
|
|
1101
1099
|
}
|
|
1102
1100
|
if (!equal(data.headmatter.defaults, newData.headmatter.defaults)) {
|
|
1103
1101
|
moduleIds.add(templateSlides.id);
|
|
@@ -1141,8 +1139,8 @@ function createSlidesLoader(options, serverOptions) {
|
|
|
1141
1139
|
if (hmrSlidesIndexes.size > 0)
|
|
1142
1140
|
moduleIds.add(templateTitleRendererMd.id);
|
|
1143
1141
|
const vueModules = Array.from(hmrSlidesIndexes).flatMap((idx) => {
|
|
1144
|
-
const frontmatter = ctx.server.moduleGraph.getModuleById(
|
|
1145
|
-
const main = ctx.server.moduleGraph.getModuleById(
|
|
1142
|
+
const frontmatter = ctx.server.moduleGraph.getModuleById(sourceIds.frontmatter[idx]);
|
|
1143
|
+
const main = ctx.server.moduleGraph.getModuleById(sourceIds.md[idx]);
|
|
1146
1144
|
const styles = main ? [...main.clientImportedModules].find((m) => m.id?.includes(`&type=style`)) : void 0;
|
|
1147
1145
|
return [
|
|
1148
1146
|
frontmatter,
|
|
@@ -1179,7 +1177,7 @@ function createSlidesLoader(options, serverOptions) {
|
|
|
1179
1177
|
if (matchFacade) {
|
|
1180
1178
|
const [, no, type] = matchFacade;
|
|
1181
1179
|
const idx = +no - 1;
|
|
1182
|
-
const sourceId = JSON.stringify(
|
|
1180
|
+
const sourceId = JSON.stringify(sourceIds[type][idx]);
|
|
1183
1181
|
return [
|
|
1184
1182
|
`export * from ${sourceId}`,
|
|
1185
1183
|
`export { default } from ${sourceId}`
|
|
@@ -1730,7 +1728,7 @@ async function setupTransformers(roots) {
|
|
|
1730
1728
|
}
|
|
1731
1729
|
|
|
1732
1730
|
// node/syntax/transform/code-wrapper.ts
|
|
1733
|
-
var reCodeBlock = /^```([\w'-]+)?\s*(?:\{([\w*,|-]+)\}\s*?(\{[^}]*\})?([^\r\n]*))?\r?\n(\S[\s\S]*?)^```$/gm;
|
|
1731
|
+
var reCodeBlock = /^```([\w'-]+)?\s*(?:\{([\w*,|-]+)\}\s*?(\{[^}]*\})?([^\r\n]*))?\r?\n([ \t]*\S[\s\S]*?)^```$/gm;
|
|
1734
1732
|
function transformCodeWrapper(ctx) {
|
|
1735
1733
|
ctx.s.replace(
|
|
1736
1734
|
reCodeBlock,
|
|
@@ -1961,40 +1959,41 @@ function dedent(text) {
|
|
|
1961
1959
|
return lines.map((x) => x.slice(minIndentLength)).join("\n");
|
|
1962
1960
|
return text;
|
|
1963
1961
|
}
|
|
1964
|
-
function testLine(line, regexp, regionName, end = false) {
|
|
1965
|
-
const [full, tag, name] = regexp.exec(line.trim()) || [];
|
|
1966
|
-
return full && tag && name === regionName && tag.match(end ? /^[Ee]nd ?[rR]egion$/ : /^[rR]egion$/);
|
|
1967
|
-
}
|
|
1968
1962
|
function findRegion(lines, regionName) {
|
|
1969
1963
|
const regionRegexps = [
|
|
1970
|
-
/^\/\/ ?#?((?:end)?region) ([\w*-]+)$/,
|
|
1971
1964
|
// javascript, typescript, java
|
|
1972
|
-
|
|
1965
|
+
[/^\/\/ ?#?region ([\w*-]+)$/, /^\/\/ ?#?endregion/],
|
|
1973
1966
|
// css, less, scss
|
|
1974
|
-
|
|
1967
|
+
[/^\/\* ?#region ([\w*-]+) ?\*\/$/, /^\/\* ?#endregion[\s\w*-]*\*\/$/],
|
|
1975
1968
|
// C, C++
|
|
1976
|
-
|
|
1969
|
+
[/^#pragma region ([\w*-]+)$/, /^#pragma endregion/],
|
|
1977
1970
|
// HTML, markdown
|
|
1978
|
-
|
|
1971
|
+
[/^<!-- #?region ([\w*-]+) -->$/, /^<!-- #?region[\s\w*-]*-->$/],
|
|
1979
1972
|
// Visual Basic
|
|
1980
|
-
|
|
1973
|
+
[/^#Region ([\w*-]+)$/, /^#End Region/],
|
|
1981
1974
|
// Bat
|
|
1982
|
-
|
|
1975
|
+
[/^::#region ([\w*-]+)$/, /^::#endregion/],
|
|
1983
1976
|
// C#, PHP, Powershell, Python, perl & misc
|
|
1977
|
+
[/^# ?region ([\w*-]+)$/, /^# ?endregion/]
|
|
1984
1978
|
];
|
|
1985
|
-
let
|
|
1979
|
+
let endReg = null;
|
|
1986
1980
|
let start = -1;
|
|
1987
1981
|
for (const [lineId, line] of lines.entries()) {
|
|
1988
|
-
if (
|
|
1989
|
-
for (const
|
|
1990
|
-
|
|
1982
|
+
if (endReg === null) {
|
|
1983
|
+
for (const [startReg, end] of regionRegexps) {
|
|
1984
|
+
const match = line.trim().match(startReg);
|
|
1985
|
+
if (match && match[1] === regionName) {
|
|
1991
1986
|
start = lineId + 1;
|
|
1992
|
-
|
|
1987
|
+
endReg = end;
|
|
1993
1988
|
break;
|
|
1994
1989
|
}
|
|
1995
1990
|
}
|
|
1996
|
-
} else if (
|
|
1997
|
-
return {
|
|
1991
|
+
} else if (endReg.test(line.trim())) {
|
|
1992
|
+
return {
|
|
1993
|
+
start,
|
|
1994
|
+
end: lineId,
|
|
1995
|
+
regexp: endReg
|
|
1996
|
+
};
|
|
1998
1997
|
}
|
|
1999
1998
|
}
|
|
2000
1999
|
return null;
|
|
@@ -2409,12 +2408,13 @@ async function createVuePlugin(_options, pluginOptions) {
|
|
|
2409
2408
|
exclude: [],
|
|
2410
2409
|
...vueOptions,
|
|
2411
2410
|
template: {
|
|
2411
|
+
...vueOptions?.template,
|
|
2412
2412
|
compilerOptions: {
|
|
2413
|
+
...vueOptions?.template?.compilerOptions,
|
|
2413
2414
|
isCustomElement(tag) {
|
|
2414
2415
|
return customElements.has(tag) || vueOptions?.template?.compilerOptions?.isCustomElement?.(tag);
|
|
2415
2416
|
}
|
|
2416
|
-
}
|
|
2417
|
-
...vueOptions?.template
|
|
2417
|
+
}
|
|
2418
2418
|
}
|
|
2419
2419
|
});
|
|
2420
2420
|
const VueJsxPlugin = VueJsx(vuejsxOptions);
|
|
@@ -2425,7 +2425,7 @@ async function createVuePlugin(_options, pluginOptions) {
|
|
|
2425
2425
|
}
|
|
2426
2426
|
|
|
2427
2427
|
// node/vite/index.ts
|
|
2428
|
-
|
|
2428
|
+
function ViteSlidevPlugin(options, pluginOptions = {}, serverOptions = {}) {
|
|
2429
2429
|
return Promise.all([
|
|
2430
2430
|
createSlidesLoader(options, serverOptions),
|
|
2431
2431
|
createMarkdownPlugin(options, pluginOptions),
|
|
@@ -2586,6 +2586,8 @@ async function resolveOptions(entryOptions, mode) {
|
|
|
2586
2586
|
const config = parser.resolveConfig(loaded.headmatter, themeMeta, entryOptions.entry);
|
|
2587
2587
|
const addonRoots = await resolveAddons(config.addons);
|
|
2588
2588
|
const roots = uniq5([...themeRoots, ...addonRoots, rootsInfo.userRoot]);
|
|
2589
|
+
if (entryOptions.download)
|
|
2590
|
+
config.download ||= entryOptions.download;
|
|
2589
2591
|
debug({
|
|
2590
2592
|
...rootsInfo,
|
|
2591
2593
|
...entryOptions,
|
|
@@ -2627,6 +2629,7 @@ async function createDataUtils(resolved) {
|
|
|
2627
2629
|
return {
|
|
2628
2630
|
...await setupShiki(resolved.roots),
|
|
2629
2631
|
indexHtml: setupIndexHtml(resolved),
|
|
2632
|
+
define: getDefine(resolved),
|
|
2630
2633
|
iconsResolvePath: [resolved.clientRoot, ...resolved.roots].reverse(),
|
|
2631
2634
|
isMonacoTypesIgnored: (pkg) => monacoTypesIgnorePackagesMatches.some((i) => i(pkg)),
|
|
2632
2635
|
getLayouts: () => {
|
|
@@ -2651,6 +2654,21 @@ async function createDataUtils(resolved) {
|
|
|
2651
2654
|
}
|
|
2652
2655
|
};
|
|
2653
2656
|
}
|
|
2657
|
+
function getDefine(options) {
|
|
2658
|
+
return {
|
|
2659
|
+
__DEV__: options.mode === "dev" ? "true" : "false",
|
|
2660
|
+
__SLIDEV_CLIENT_ROOT__: JSON.stringify(toAtFS(options.clientRoot)),
|
|
2661
|
+
__SLIDEV_HASH_ROUTE__: JSON.stringify(options.data.config.routerMode === "hash"),
|
|
2662
|
+
__SLIDEV_FEATURE_DRAWINGS__: JSON.stringify(options.data.config.drawings.enabled === true || options.data.config.drawings.enabled === options.mode),
|
|
2663
|
+
__SLIDEV_FEATURE_EDITOR__: JSON.stringify(options.mode === "dev" && options.data.config.editor !== false),
|
|
2664
|
+
__SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
|
|
2665
|
+
__SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
|
|
2666
|
+
__SLIDEV_FEATURE_PRESENTER__: JSON.stringify(options.data.config.presenter === true || options.data.config.presenter === options.mode),
|
|
2667
|
+
__SLIDEV_FEATURE_PRINT__: JSON.stringify(options.mode === "export" || options.mode === "build" && [true, "true", "auto"].includes(options.data.config.download)),
|
|
2668
|
+
__SLIDEV_FEATURE_WAKE_LOCK__: JSON.stringify(options.data.config.wakeLock === true || options.data.config.wakeLock === options.mode),
|
|
2669
|
+
__SLIDEV_HAS_SERVER__: options.mode !== "build" ? "true" : "false"
|
|
2670
|
+
};
|
|
2671
|
+
}
|
|
2654
2672
|
|
|
2655
2673
|
export {
|
|
2656
2674
|
version,
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W7262TA2.js";
|
|
4
4
|
import {
|
|
5
5
|
getThemeMeta,
|
|
6
6
|
loadSetups,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
resolveOptions,
|
|
10
10
|
resolveTheme,
|
|
11
11
|
version
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-4HBHIHYH.js";
|
|
13
13
|
import {
|
|
14
14
|
getRoots,
|
|
15
15
|
isInstalledGlobally,
|
|
@@ -332,11 +332,9 @@ cli.command(
|
|
|
332
332
|
}).strict().help(),
|
|
333
333
|
async (args) => {
|
|
334
334
|
const { entry, theme, base, download, out, inspect } = args;
|
|
335
|
-
const { build } = await import("./build-
|
|
335
|
+
const { build } = await import("./build-62NZDFIC.js");
|
|
336
336
|
for (const entryFile of entry) {
|
|
337
|
-
const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
|
|
338
|
-
if (download && !options.data.config.download)
|
|
339
|
-
options.data.config.download = download;
|
|
337
|
+
const options = await resolveOptions({ entry: entryFile, theme, inspect, download }, "build");
|
|
340
338
|
printInfo(options);
|
|
341
339
|
await build(
|
|
342
340
|
options,
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W7262TA2.js";
|
|
4
4
|
import {
|
|
5
5
|
ViteSlidevPlugin,
|
|
6
6
|
createDataUtils,
|
|
7
7
|
parser,
|
|
8
8
|
resolveOptions
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4HBHIHYH.js";
|
|
10
10
|
import "./chunk-UNQ5DBLZ.js";
|
|
11
11
|
export {
|
|
12
12
|
ViteSlidevPlugin,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.50.0-beta.
|
|
4
|
+
"version": "0.50.0-beta.6",
|
|
5
5
|
"description": "Presentation slides for developers",
|
|
6
6
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"@iconify-json/ph": "^1.2.1",
|
|
49
49
|
"@iconify-json/svg-spinners": "^1.2.1",
|
|
50
50
|
"@lillallol/outline-pdf": "^4.0.0",
|
|
51
|
-
"@shikijs/markdown-it": "^1.22.
|
|
52
|
-
"@shikijs/twoslash": "^1.22.
|
|
53
|
-
"@shikijs/vitepress-twoslash": "^1.22.
|
|
54
|
-
"@unocss/extractor-mdc": "^0.63.
|
|
55
|
-
"@unocss/reset": "^0.63.
|
|
51
|
+
"@shikijs/markdown-it": "^1.22.1",
|
|
52
|
+
"@shikijs/twoslash": "^1.22.1",
|
|
53
|
+
"@shikijs/vitepress-twoslash": "^1.22.1",
|
|
54
|
+
"@unocss/extractor-mdc": "^0.63.6",
|
|
55
|
+
"@unocss/reset": "^0.63.6",
|
|
56
56
|
"@vitejs/plugin-vue": "^5.1.4",
|
|
57
57
|
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
|
58
58
|
"chokidar": "^4.0.1",
|
|
@@ -109,9 +109,9 @@
|
|
|
109
109
|
"vue": "^3.5.12",
|
|
110
110
|
"yaml": "^2.6.0",
|
|
111
111
|
"yargs": "^17.7.2",
|
|
112
|
-
"@slidev/parser": "0.50.0-beta.
|
|
113
|
-
"@slidev/types": "0.50.0-beta.
|
|
114
|
-
"@slidev/client": "0.50.0-beta.
|
|
112
|
+
"@slidev/parser": "0.50.0-beta.6",
|
|
113
|
+
"@slidev/types": "0.50.0-beta.6",
|
|
114
|
+
"@slidev/client": "0.50.0-beta.6"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
117
|
"@hedgedoc/markdown-it-plugins": "^2.1.4",
|