@slidev/parser 0.22.5 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-USVNQBX5.mjs → chunk-3PVKGM3Z.mjs} +179 -117
- package/dist/{chunk-SDUAGQ4T.js → chunk-DWI67SEL.js} +179 -117
- package/dist/core.d.ts +5 -3
- package/dist/core.js +4 -2
- package/dist/core.mjs +3 -1
- package/dist/fs.d.ts +1 -1
- package/dist/fs.js +12 -10
- package/dist/fs.mjs +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -2
- package/dist/index.mjs +3 -1
- package/package.json +45 -45
|
@@ -37,9 +37,9 @@ var __toModule = (module) => {
|
|
|
37
37
|
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
// ../../node_modules/.pnpm/@antfu+utils@0.
|
|
40
|
+
// ../../node_modules/.pnpm/@antfu+utils@0.3.0/node_modules/@antfu/utils/dist/index.js
|
|
41
41
|
var require_dist = __commonJS({
|
|
42
|
-
"../../node_modules/.pnpm/@antfu+utils@0.
|
|
42
|
+
"../../node_modules/.pnpm/@antfu+utils@0.3.0/node_modules/@antfu/utils/dist/index.js"(exports) {
|
|
43
43
|
"use strict";
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
function clamp(n, min, max) {
|
|
@@ -60,11 +60,20 @@ var require_dist = __commonJS({
|
|
|
60
60
|
function mergeArrayable(...args) {
|
|
61
61
|
return args.flatMap((i) => toArray2(i));
|
|
62
62
|
}
|
|
63
|
-
function partition(array,
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
function partition(array, ...filters) {
|
|
64
|
+
const result = new Array(filters.length + 1).fill(null).map(() => []);
|
|
65
|
+
array.forEach((e, idx, arr) => {
|
|
66
|
+
let i = 0;
|
|
67
|
+
for (const filter of filters) {
|
|
68
|
+
if (filter(e, idx, arr)) {
|
|
69
|
+
result[i].push(e);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
i += 1;
|
|
73
|
+
}
|
|
74
|
+
result[i].push(e);
|
|
75
|
+
});
|
|
76
|
+
return result;
|
|
68
77
|
}
|
|
69
78
|
function uniq3(array) {
|
|
70
79
|
return Array.from(new Set(array));
|
|
@@ -118,7 +127,7 @@ var require_dist = __commonJS({
|
|
|
118
127
|
if (!condition)
|
|
119
128
|
throw new Error(message);
|
|
120
129
|
};
|
|
121
|
-
var toString2 = Object.prototype.toString;
|
|
130
|
+
var toString2 = (v) => Object.prototype.toString.call(v);
|
|
122
131
|
var noop = () => {
|
|
123
132
|
};
|
|
124
133
|
function notNullish(v) {
|
|
@@ -149,6 +158,14 @@ var require_dist = __commonJS({
|
|
|
149
158
|
return prefix + str;
|
|
150
159
|
return str;
|
|
151
160
|
}
|
|
161
|
+
function template(str, ...args) {
|
|
162
|
+
return str.replace(/{(\d+)}/g, (match, key) => {
|
|
163
|
+
const index = Number(key);
|
|
164
|
+
if (Number.isNaN(index))
|
|
165
|
+
return match;
|
|
166
|
+
return args[index];
|
|
167
|
+
});
|
|
168
|
+
}
|
|
152
169
|
var timestamp = () => +Date.now();
|
|
153
170
|
function batchInvoke(functions) {
|
|
154
171
|
functions.forEach((fn) => fn && fn());
|
|
@@ -233,6 +250,29 @@ var require_dist = __commonJS({
|
|
|
233
250
|
resolve();
|
|
234
251
|
}, ms));
|
|
235
252
|
}
|
|
253
|
+
function createPromiseLock() {
|
|
254
|
+
const locks = [];
|
|
255
|
+
return {
|
|
256
|
+
async run(fn) {
|
|
257
|
+
const p = fn();
|
|
258
|
+
locks.push(p);
|
|
259
|
+
try {
|
|
260
|
+
return await p;
|
|
261
|
+
} finally {
|
|
262
|
+
remove(locks, p);
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
async wait() {
|
|
266
|
+
await Promise.allSettled(locks);
|
|
267
|
+
},
|
|
268
|
+
isWaiting() {
|
|
269
|
+
return Boolean(locks.length);
|
|
270
|
+
},
|
|
271
|
+
clear() {
|
|
272
|
+
locks.length = 0;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
236
276
|
function throttle(delay, noTrailing, callback, debounceMode) {
|
|
237
277
|
var timeoutID;
|
|
238
278
|
var cancelled = false;
|
|
@@ -289,6 +329,7 @@ var require_dist = __commonJS({
|
|
|
289
329
|
exports.clamp = clamp;
|
|
290
330
|
exports.clampArrayRange = clampArrayRange;
|
|
291
331
|
exports.clearUndefined = clearUndefined;
|
|
332
|
+
exports.createPromiseLock = createPromiseLock;
|
|
292
333
|
exports.createSingletonPromise = createSingletonPromise;
|
|
293
334
|
exports.debounce = debounce;
|
|
294
335
|
exports.deepMerge = deepMerge;
|
|
@@ -324,6 +365,7 @@ var require_dist = __commonJS({
|
|
|
324
365
|
exports.sleep = sleep;
|
|
325
366
|
exports.sum = sum;
|
|
326
367
|
exports.tap = tap;
|
|
368
|
+
exports.template = template;
|
|
327
369
|
exports.throttle = throttle;
|
|
328
370
|
exports.timestamp = timestamp;
|
|
329
371
|
exports.toArray = toArray2;
|
|
@@ -333,9 +375,12 @@ var require_dist = __commonJS({
|
|
|
333
375
|
});
|
|
334
376
|
|
|
335
377
|
// src/core.ts
|
|
336
|
-
var
|
|
378
|
+
var import_utils4 = __toModule(require_dist());
|
|
337
379
|
import YAML from "js-yaml";
|
|
338
380
|
|
|
381
|
+
// src/config.ts
|
|
382
|
+
var import_utils2 = __toModule(require_dist());
|
|
383
|
+
|
|
339
384
|
// src/utils.ts
|
|
340
385
|
var import_utils = __toModule(require_dist());
|
|
341
386
|
function parseRangeString(total, rangeStr) {
|
|
@@ -365,6 +410,126 @@ function parseAspectRatio(str) {
|
|
|
365
410
|
return w / h;
|
|
366
411
|
}
|
|
367
412
|
|
|
413
|
+
// src/config.ts
|
|
414
|
+
function resolveConfig(headmatter, themeMeta = {}) {
|
|
415
|
+
var _a, _b;
|
|
416
|
+
const themeHightlighter = ["prism", "shiki"].includes(themeMeta.highlighter || "") ? themeMeta.highlighter : void 0;
|
|
417
|
+
const themeColorSchema = ["light", "dark"].includes(themeMeta.colorSchema || "") ? themeMeta.colorSchema : void 0;
|
|
418
|
+
const defaultConfig = {
|
|
419
|
+
theme: "default",
|
|
420
|
+
title: "Slidev",
|
|
421
|
+
titleTemplate: "%s - Slidev",
|
|
422
|
+
remoteAssets: true,
|
|
423
|
+
monaco: "dev",
|
|
424
|
+
download: false,
|
|
425
|
+
info: false,
|
|
426
|
+
highlighter: themeHightlighter || "prism",
|
|
427
|
+
lineNumbers: false,
|
|
428
|
+
colorSchema: themeColorSchema || "auto",
|
|
429
|
+
routerMode: "history",
|
|
430
|
+
aspectRatio: 16 / 9,
|
|
431
|
+
canvasWidth: 980,
|
|
432
|
+
selectable: false,
|
|
433
|
+
themeConfig: {},
|
|
434
|
+
fonts: {},
|
|
435
|
+
drawings: {}
|
|
436
|
+
};
|
|
437
|
+
const config = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultConfig), themeMeta.defaults), headmatter.config), headmatter), {
|
|
438
|
+
fonts: resolveFonts(__spreadValues(__spreadValues(__spreadValues({}, (_a = themeMeta.defaults) == null ? void 0 : _a.fonts), (_b = headmatter.config) == null ? void 0 : _b.fonts), headmatter == null ? void 0 : headmatter.fonts)),
|
|
439
|
+
drawings: resolveDarwings(headmatter.drawings)
|
|
440
|
+
});
|
|
441
|
+
if (config.colorSchema !== "dark" && config.colorSchema !== "light")
|
|
442
|
+
config.colorSchema = "auto";
|
|
443
|
+
if (themeColorSchema && config.colorSchema === "auto")
|
|
444
|
+
config.colorSchema = themeColorSchema;
|
|
445
|
+
config.aspectRatio = parseAspectRatio(config.aspectRatio);
|
|
446
|
+
if (themeColorSchema && config.colorSchema !== themeColorSchema)
|
|
447
|
+
console.warn(`[slidev] Color schema "${config.colorSchema}" does not supported by the theme`);
|
|
448
|
+
if (themeHightlighter && config.highlighter !== themeHightlighter)
|
|
449
|
+
console.warn(`[slidev] Syntax highlighter "${config.highlighter}" does not supported by the theme`);
|
|
450
|
+
return config;
|
|
451
|
+
}
|
|
452
|
+
function resolveFonts(fonts = {}) {
|
|
453
|
+
const {
|
|
454
|
+
fallbacks = true,
|
|
455
|
+
italic = false,
|
|
456
|
+
provider = "google"
|
|
457
|
+
} = fonts;
|
|
458
|
+
let sans = (0, import_utils2.toArray)(fonts.sans).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
459
|
+
let serif = (0, import_utils2.toArray)(fonts.serif).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
460
|
+
let mono = (0, import_utils2.toArray)(fonts.mono).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
461
|
+
const weights = (0, import_utils2.toArray)(fonts.weights || "200,400,600").flatMap((i) => i.toString().split(/,\s*/g)).map((i) => i.trim());
|
|
462
|
+
const custom = (0, import_utils2.toArray)(fonts.custom).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
463
|
+
const local = (0, import_utils2.toArray)(fonts.local).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
464
|
+
const webfonts = fonts.webfonts ? fonts.webfonts : fallbacks ? (0, import_utils2.uniq)([...sans, ...serif, ...mono, ...custom]) : [];
|
|
465
|
+
webfonts.filter((i) => local.includes(i));
|
|
466
|
+
function toQuoted(font) {
|
|
467
|
+
if (/^(['"]).*\1$/.test(font))
|
|
468
|
+
return font;
|
|
469
|
+
return `"${font}"`;
|
|
470
|
+
}
|
|
471
|
+
if (fallbacks) {
|
|
472
|
+
sans = (0, import_utils2.uniq)([
|
|
473
|
+
...sans.map(toQuoted),
|
|
474
|
+
"ui-sans-serif",
|
|
475
|
+
"system-ui",
|
|
476
|
+
"-apple-system",
|
|
477
|
+
"BlinkMacSystemFont",
|
|
478
|
+
'"Segoe UI"',
|
|
479
|
+
"Roboto",
|
|
480
|
+
'"Helvetica Neue"',
|
|
481
|
+
"Arial",
|
|
482
|
+
'"Noto Sans"',
|
|
483
|
+
"sans-serif",
|
|
484
|
+
'"Apple Color Emoji"',
|
|
485
|
+
'"Segoe UI Emoji"',
|
|
486
|
+
'"Segoe UI Symbol"',
|
|
487
|
+
'"Noto Color Emoji"'
|
|
488
|
+
]);
|
|
489
|
+
serif = (0, import_utils2.uniq)([
|
|
490
|
+
...serif.map(toQuoted),
|
|
491
|
+
"ui-serif",
|
|
492
|
+
"Georgia",
|
|
493
|
+
"Cambria",
|
|
494
|
+
'"Times New Roman"',
|
|
495
|
+
"Times",
|
|
496
|
+
"serif"
|
|
497
|
+
]);
|
|
498
|
+
mono = (0, import_utils2.uniq)([
|
|
499
|
+
...mono.map(toQuoted),
|
|
500
|
+
"ui-monospace",
|
|
501
|
+
"SFMono-Regular",
|
|
502
|
+
"Menlo",
|
|
503
|
+
"Monaco",
|
|
504
|
+
"Consolas",
|
|
505
|
+
'"Liberation Mono"',
|
|
506
|
+
'"Courier New"',
|
|
507
|
+
"monospace"
|
|
508
|
+
]);
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
sans,
|
|
512
|
+
serif,
|
|
513
|
+
mono,
|
|
514
|
+
webfonts,
|
|
515
|
+
provider,
|
|
516
|
+
local,
|
|
517
|
+
italic,
|
|
518
|
+
weights
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
function resolveDarwings(options = {}) {
|
|
522
|
+
const {
|
|
523
|
+
enabled = true,
|
|
524
|
+
persist = false
|
|
525
|
+
} = options;
|
|
526
|
+
const persistPath = typeof persist === "string" ? persist : persist ? ".slidev/drawings" : false;
|
|
527
|
+
return {
|
|
528
|
+
enabled,
|
|
529
|
+
persist: persistPath
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
368
533
|
// src/core.ts
|
|
369
534
|
function stringify(data) {
|
|
370
535
|
return `${data.slides.map((slide, idx) => stringifySlide(slide.inline || slide, idx)).join("\n").trim()}
|
|
@@ -410,7 +575,7 @@ function matter(code) {
|
|
|
410
575
|
let data = {};
|
|
411
576
|
const content = code.replace(/^---.*\r?\n([\s\S]*?)---/, (_, d) => {
|
|
412
577
|
data = YAML.load(d);
|
|
413
|
-
if (!(0,
|
|
578
|
+
if (!(0, import_utils4.isObject)(data))
|
|
414
579
|
data = {};
|
|
415
580
|
return "";
|
|
416
581
|
});
|
|
@@ -493,112 +658,8 @@ function parse(markdown, filepath, themeMeta) {
|
|
|
493
658
|
themeMeta
|
|
494
659
|
};
|
|
495
660
|
}
|
|
496
|
-
function resolveFonts(fonts = {}) {
|
|
497
|
-
const {
|
|
498
|
-
fallbacks = true,
|
|
499
|
-
italic = false,
|
|
500
|
-
provider = "google"
|
|
501
|
-
} = fonts;
|
|
502
|
-
let sans = (0, import_utils2.toArray)(fonts.sans).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
503
|
-
let serif = (0, import_utils2.toArray)(fonts.serif).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
504
|
-
let mono = (0, import_utils2.toArray)(fonts.mono).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
505
|
-
const weights = (0, import_utils2.toArray)(fonts.weights || "200,400,600").flatMap((i) => i.toString().split(/,\s*/g)).map((i) => i.trim());
|
|
506
|
-
const custom = (0, import_utils2.toArray)(fonts.custom).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
507
|
-
const local = (0, import_utils2.toArray)(fonts.local).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
508
|
-
const webfonts = fonts.webfonts ? fonts.webfonts : fallbacks ? (0, import_utils2.uniq)([...sans, ...serif, ...mono, ...custom]) : [];
|
|
509
|
-
webfonts.filter((i) => local.includes(i));
|
|
510
|
-
function toQuoted(font) {
|
|
511
|
-
if (/^(['"]).*\1$/.test(font))
|
|
512
|
-
return font;
|
|
513
|
-
return `"${font}"`;
|
|
514
|
-
}
|
|
515
|
-
if (fallbacks) {
|
|
516
|
-
sans = (0, import_utils2.uniq)([
|
|
517
|
-
...sans.map(toQuoted),
|
|
518
|
-
"ui-sans-serif",
|
|
519
|
-
"system-ui",
|
|
520
|
-
"-apple-system",
|
|
521
|
-
"BlinkMacSystemFont",
|
|
522
|
-
'"Segoe UI"',
|
|
523
|
-
"Roboto",
|
|
524
|
-
'"Helvetica Neue"',
|
|
525
|
-
"Arial",
|
|
526
|
-
'"Noto Sans"',
|
|
527
|
-
"sans-serif",
|
|
528
|
-
'"Apple Color Emoji"',
|
|
529
|
-
'"Segoe UI Emoji"',
|
|
530
|
-
'"Segoe UI Symbol"',
|
|
531
|
-
'"Noto Color Emoji"'
|
|
532
|
-
]);
|
|
533
|
-
serif = (0, import_utils2.uniq)([
|
|
534
|
-
...serif.map(toQuoted),
|
|
535
|
-
"ui-serif",
|
|
536
|
-
"Georgia",
|
|
537
|
-
"Cambria",
|
|
538
|
-
'"Times New Roman"',
|
|
539
|
-
"Times",
|
|
540
|
-
"serif"
|
|
541
|
-
]);
|
|
542
|
-
mono = (0, import_utils2.uniq)([
|
|
543
|
-
...mono.map(toQuoted),
|
|
544
|
-
"ui-monospace",
|
|
545
|
-
"SFMono-Regular",
|
|
546
|
-
"Menlo",
|
|
547
|
-
"Monaco",
|
|
548
|
-
"Consolas",
|
|
549
|
-
'"Liberation Mono"',
|
|
550
|
-
'"Courier New"',
|
|
551
|
-
"monospace"
|
|
552
|
-
]);
|
|
553
|
-
}
|
|
554
|
-
return {
|
|
555
|
-
sans,
|
|
556
|
-
serif,
|
|
557
|
-
mono,
|
|
558
|
-
webfonts,
|
|
559
|
-
provider,
|
|
560
|
-
local,
|
|
561
|
-
italic,
|
|
562
|
-
weights
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
function resolveConfig(headmatter, themeMeta = {}) {
|
|
566
|
-
var _a, _b;
|
|
567
|
-
const themeHightlighter = ["prism", "shiki"].includes(themeMeta.highlighter || "") ? themeMeta.highlighter : void 0;
|
|
568
|
-
const themeColorSchema = ["light", "dark"].includes(themeMeta.colorSchema || "") ? themeMeta.colorSchema : void 0;
|
|
569
|
-
const defaultConfig = {
|
|
570
|
-
theme: "default",
|
|
571
|
-
title: "Slidev",
|
|
572
|
-
titleTemplate: "%s - Slidev",
|
|
573
|
-
remoteAssets: true,
|
|
574
|
-
monaco: "dev",
|
|
575
|
-
download: false,
|
|
576
|
-
info: false,
|
|
577
|
-
highlighter: themeHightlighter || "prism",
|
|
578
|
-
colorSchema: themeColorSchema || "auto",
|
|
579
|
-
routerMode: "history",
|
|
580
|
-
aspectRatio: 16 / 9,
|
|
581
|
-
canvasWidth: 980,
|
|
582
|
-
selectable: false,
|
|
583
|
-
themeConfig: {},
|
|
584
|
-
fonts: {}
|
|
585
|
-
};
|
|
586
|
-
const config = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultConfig), themeMeta.defaults), headmatter.config), headmatter), {
|
|
587
|
-
fonts: resolveFonts(__spreadValues(__spreadValues(__spreadValues({}, (_a = themeMeta.defaults) == null ? void 0 : _a.fonts), (_b = headmatter.config) == null ? void 0 : _b.fonts), headmatter == null ? void 0 : headmatter.fonts))
|
|
588
|
-
});
|
|
589
|
-
if (config.colorSchema !== "dark" && config.colorSchema !== "light")
|
|
590
|
-
config.colorSchema = "auto";
|
|
591
|
-
if (themeColorSchema && config.colorSchema === "auto")
|
|
592
|
-
config.colorSchema = themeColorSchema;
|
|
593
|
-
config.aspectRatio = parseAspectRatio(config.aspectRatio);
|
|
594
|
-
if (themeColorSchema && config.colorSchema !== themeColorSchema)
|
|
595
|
-
console.warn(`[slidev] Color schema "${config.colorSchema}" does not supported by the theme`);
|
|
596
|
-
if (themeHightlighter && config.highlighter !== themeHightlighter)
|
|
597
|
-
console.warn(`[slidev] Syntax highlighter "${config.highlighter}" does not supported by the theme`);
|
|
598
|
-
return config;
|
|
599
|
-
}
|
|
600
661
|
function mergeFeatureFlags(a, b) {
|
|
601
|
-
return (0,
|
|
662
|
+
return (0, import_utils4.objectMap)(a, (k, v) => [k, v || b[k]]);
|
|
602
663
|
}
|
|
603
664
|
function scanMonacoModules(md) {
|
|
604
665
|
const typeModules = new Set();
|
|
@@ -606,7 +667,7 @@ function scanMonacoModules(md) {
|
|
|
606
667
|
options = options || "";
|
|
607
668
|
lang = lang.trim();
|
|
608
669
|
if (lang === "ts" || lang === "typescript") {
|
|
609
|
-
Array.from(code.matchAll(/\s+from\s+(["'])([\/\w@-]+)\1/g)).map((i) => i[2]).filter(
|
|
670
|
+
Array.from(code.matchAll(/\s+from\s+(["'])([\/\w@-]+)\1/g)).map((i) => i[2]).filter(import_utils4.isTruthy).map((i) => typeModules.add(i));
|
|
610
671
|
}
|
|
611
672
|
return "";
|
|
612
673
|
});
|
|
@@ -617,6 +678,8 @@ export {
|
|
|
617
678
|
__spreadValues,
|
|
618
679
|
parseRangeString,
|
|
619
680
|
parseAspectRatio,
|
|
681
|
+
resolveConfig,
|
|
682
|
+
resolveFonts,
|
|
620
683
|
stringify,
|
|
621
684
|
filterDisabled,
|
|
622
685
|
stringifySlide,
|
|
@@ -625,7 +688,6 @@ export {
|
|
|
625
688
|
detectFeatures,
|
|
626
689
|
parseSlide,
|
|
627
690
|
parse,
|
|
628
|
-
resolveConfig,
|
|
629
691
|
mergeFeatureFlags,
|
|
630
692
|
scanMonacoModules
|
|
631
693
|
};
|
|
@@ -37,9 +37,9 @@ var __toModule = (module) => {
|
|
|
37
37
|
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
// ../../node_modules/.pnpm/@antfu+utils@0.
|
|
40
|
+
// ../../node_modules/.pnpm/@antfu+utils@0.3.0/node_modules/@antfu/utils/dist/index.js
|
|
41
41
|
var require_dist = __commonJS({
|
|
42
|
-
"../../node_modules/.pnpm/@antfu+utils@0.
|
|
42
|
+
"../../node_modules/.pnpm/@antfu+utils@0.3.0/node_modules/@antfu/utils/dist/index.js"(exports) {
|
|
43
43
|
"use strict";
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
function clamp(n, min, max) {
|
|
@@ -60,11 +60,20 @@ var require_dist = __commonJS({
|
|
|
60
60
|
function mergeArrayable(...args) {
|
|
61
61
|
return args.flatMap((i) => toArray2(i));
|
|
62
62
|
}
|
|
63
|
-
function partition(array,
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
function partition(array, ...filters) {
|
|
64
|
+
const result = new Array(filters.length + 1).fill(null).map(() => []);
|
|
65
|
+
array.forEach((e, idx, arr) => {
|
|
66
|
+
let i = 0;
|
|
67
|
+
for (const filter of filters) {
|
|
68
|
+
if (filter(e, idx, arr)) {
|
|
69
|
+
result[i].push(e);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
i += 1;
|
|
73
|
+
}
|
|
74
|
+
result[i].push(e);
|
|
75
|
+
});
|
|
76
|
+
return result;
|
|
68
77
|
}
|
|
69
78
|
function uniq3(array) {
|
|
70
79
|
return Array.from(new Set(array));
|
|
@@ -118,7 +127,7 @@ var require_dist = __commonJS({
|
|
|
118
127
|
if (!condition)
|
|
119
128
|
throw new Error(message);
|
|
120
129
|
};
|
|
121
|
-
var toString2 = Object.prototype.toString;
|
|
130
|
+
var toString2 = (v) => Object.prototype.toString.call(v);
|
|
122
131
|
var noop = () => {
|
|
123
132
|
};
|
|
124
133
|
function notNullish(v) {
|
|
@@ -149,6 +158,14 @@ var require_dist = __commonJS({
|
|
|
149
158
|
return prefix + str;
|
|
150
159
|
return str;
|
|
151
160
|
}
|
|
161
|
+
function template(str, ...args) {
|
|
162
|
+
return str.replace(/{(\d+)}/g, (match, key) => {
|
|
163
|
+
const index = Number(key);
|
|
164
|
+
if (Number.isNaN(index))
|
|
165
|
+
return match;
|
|
166
|
+
return args[index];
|
|
167
|
+
});
|
|
168
|
+
}
|
|
152
169
|
var timestamp = () => +Date.now();
|
|
153
170
|
function batchInvoke(functions) {
|
|
154
171
|
functions.forEach((fn) => fn && fn());
|
|
@@ -233,6 +250,29 @@ var require_dist = __commonJS({
|
|
|
233
250
|
resolve();
|
|
234
251
|
}, ms));
|
|
235
252
|
}
|
|
253
|
+
function createPromiseLock() {
|
|
254
|
+
const locks = [];
|
|
255
|
+
return {
|
|
256
|
+
async run(fn) {
|
|
257
|
+
const p = fn();
|
|
258
|
+
locks.push(p);
|
|
259
|
+
try {
|
|
260
|
+
return await p;
|
|
261
|
+
} finally {
|
|
262
|
+
remove(locks, p);
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
async wait() {
|
|
266
|
+
await Promise.allSettled(locks);
|
|
267
|
+
},
|
|
268
|
+
isWaiting() {
|
|
269
|
+
return Boolean(locks.length);
|
|
270
|
+
},
|
|
271
|
+
clear() {
|
|
272
|
+
locks.length = 0;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
236
276
|
function throttle(delay, noTrailing, callback, debounceMode) {
|
|
237
277
|
var timeoutID;
|
|
238
278
|
var cancelled = false;
|
|
@@ -289,6 +329,7 @@ var require_dist = __commonJS({
|
|
|
289
329
|
exports.clamp = clamp;
|
|
290
330
|
exports.clampArrayRange = clampArrayRange;
|
|
291
331
|
exports.clearUndefined = clearUndefined;
|
|
332
|
+
exports.createPromiseLock = createPromiseLock;
|
|
292
333
|
exports.createSingletonPromise = createSingletonPromise;
|
|
293
334
|
exports.debounce = debounce;
|
|
294
335
|
exports.deepMerge = deepMerge;
|
|
@@ -324,6 +365,7 @@ var require_dist = __commonJS({
|
|
|
324
365
|
exports.sleep = sleep;
|
|
325
366
|
exports.sum = sum;
|
|
326
367
|
exports.tap = tap;
|
|
368
|
+
exports.template = template;
|
|
327
369
|
exports.throttle = throttle;
|
|
328
370
|
exports.timestamp = timestamp;
|
|
329
371
|
exports.toArray = toArray2;
|
|
@@ -333,9 +375,12 @@ var require_dist = __commonJS({
|
|
|
333
375
|
});
|
|
334
376
|
|
|
335
377
|
// src/core.ts
|
|
336
|
-
var
|
|
378
|
+
var import_utils4 = __toModule(require_dist());
|
|
337
379
|
var _jsyaml = require('js-yaml'); var _jsyaml2 = _interopRequireDefault(_jsyaml);
|
|
338
380
|
|
|
381
|
+
// src/config.ts
|
|
382
|
+
var import_utils2 = __toModule(require_dist());
|
|
383
|
+
|
|
339
384
|
// src/utils.ts
|
|
340
385
|
var import_utils = __toModule(require_dist());
|
|
341
386
|
function parseRangeString(total, rangeStr) {
|
|
@@ -365,6 +410,126 @@ function parseAspectRatio(str) {
|
|
|
365
410
|
return w / h;
|
|
366
411
|
}
|
|
367
412
|
|
|
413
|
+
// src/config.ts
|
|
414
|
+
function resolveConfig(headmatter, themeMeta = {}) {
|
|
415
|
+
var _a, _b;
|
|
416
|
+
const themeHightlighter = ["prism", "shiki"].includes(themeMeta.highlighter || "") ? themeMeta.highlighter : void 0;
|
|
417
|
+
const themeColorSchema = ["light", "dark"].includes(themeMeta.colorSchema || "") ? themeMeta.colorSchema : void 0;
|
|
418
|
+
const defaultConfig = {
|
|
419
|
+
theme: "default",
|
|
420
|
+
title: "Slidev",
|
|
421
|
+
titleTemplate: "%s - Slidev",
|
|
422
|
+
remoteAssets: true,
|
|
423
|
+
monaco: "dev",
|
|
424
|
+
download: false,
|
|
425
|
+
info: false,
|
|
426
|
+
highlighter: themeHightlighter || "prism",
|
|
427
|
+
lineNumbers: false,
|
|
428
|
+
colorSchema: themeColorSchema || "auto",
|
|
429
|
+
routerMode: "history",
|
|
430
|
+
aspectRatio: 16 / 9,
|
|
431
|
+
canvasWidth: 980,
|
|
432
|
+
selectable: false,
|
|
433
|
+
themeConfig: {},
|
|
434
|
+
fonts: {},
|
|
435
|
+
drawings: {}
|
|
436
|
+
};
|
|
437
|
+
const config = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultConfig), themeMeta.defaults), headmatter.config), headmatter), {
|
|
438
|
+
fonts: resolveFonts(__spreadValues(__spreadValues(__spreadValues({}, (_a = themeMeta.defaults) == null ? void 0 : _a.fonts), (_b = headmatter.config) == null ? void 0 : _b.fonts), headmatter == null ? void 0 : headmatter.fonts)),
|
|
439
|
+
drawings: resolveDarwings(headmatter.drawings)
|
|
440
|
+
});
|
|
441
|
+
if (config.colorSchema !== "dark" && config.colorSchema !== "light")
|
|
442
|
+
config.colorSchema = "auto";
|
|
443
|
+
if (themeColorSchema && config.colorSchema === "auto")
|
|
444
|
+
config.colorSchema = themeColorSchema;
|
|
445
|
+
config.aspectRatio = parseAspectRatio(config.aspectRatio);
|
|
446
|
+
if (themeColorSchema && config.colorSchema !== themeColorSchema)
|
|
447
|
+
console.warn(`[slidev] Color schema "${config.colorSchema}" does not supported by the theme`);
|
|
448
|
+
if (themeHightlighter && config.highlighter !== themeHightlighter)
|
|
449
|
+
console.warn(`[slidev] Syntax highlighter "${config.highlighter}" does not supported by the theme`);
|
|
450
|
+
return config;
|
|
451
|
+
}
|
|
452
|
+
function resolveFonts(fonts = {}) {
|
|
453
|
+
const {
|
|
454
|
+
fallbacks = true,
|
|
455
|
+
italic = false,
|
|
456
|
+
provider = "google"
|
|
457
|
+
} = fonts;
|
|
458
|
+
let sans = (0, import_utils2.toArray)(fonts.sans).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
459
|
+
let serif = (0, import_utils2.toArray)(fonts.serif).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
460
|
+
let mono = (0, import_utils2.toArray)(fonts.mono).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
461
|
+
const weights = (0, import_utils2.toArray)(fonts.weights || "200,400,600").flatMap((i) => i.toString().split(/,\s*/g)).map((i) => i.trim());
|
|
462
|
+
const custom = (0, import_utils2.toArray)(fonts.custom).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
463
|
+
const local = (0, import_utils2.toArray)(fonts.local).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
464
|
+
const webfonts = fonts.webfonts ? fonts.webfonts : fallbacks ? (0, import_utils2.uniq)([...sans, ...serif, ...mono, ...custom]) : [];
|
|
465
|
+
webfonts.filter((i) => local.includes(i));
|
|
466
|
+
function toQuoted(font) {
|
|
467
|
+
if (/^(['"]).*\1$/.test(font))
|
|
468
|
+
return font;
|
|
469
|
+
return `"${font}"`;
|
|
470
|
+
}
|
|
471
|
+
if (fallbacks) {
|
|
472
|
+
sans = (0, import_utils2.uniq)([
|
|
473
|
+
...sans.map(toQuoted),
|
|
474
|
+
"ui-sans-serif",
|
|
475
|
+
"system-ui",
|
|
476
|
+
"-apple-system",
|
|
477
|
+
"BlinkMacSystemFont",
|
|
478
|
+
'"Segoe UI"',
|
|
479
|
+
"Roboto",
|
|
480
|
+
'"Helvetica Neue"',
|
|
481
|
+
"Arial",
|
|
482
|
+
'"Noto Sans"',
|
|
483
|
+
"sans-serif",
|
|
484
|
+
'"Apple Color Emoji"',
|
|
485
|
+
'"Segoe UI Emoji"',
|
|
486
|
+
'"Segoe UI Symbol"',
|
|
487
|
+
'"Noto Color Emoji"'
|
|
488
|
+
]);
|
|
489
|
+
serif = (0, import_utils2.uniq)([
|
|
490
|
+
...serif.map(toQuoted),
|
|
491
|
+
"ui-serif",
|
|
492
|
+
"Georgia",
|
|
493
|
+
"Cambria",
|
|
494
|
+
'"Times New Roman"',
|
|
495
|
+
"Times",
|
|
496
|
+
"serif"
|
|
497
|
+
]);
|
|
498
|
+
mono = (0, import_utils2.uniq)([
|
|
499
|
+
...mono.map(toQuoted),
|
|
500
|
+
"ui-monospace",
|
|
501
|
+
"SFMono-Regular",
|
|
502
|
+
"Menlo",
|
|
503
|
+
"Monaco",
|
|
504
|
+
"Consolas",
|
|
505
|
+
'"Liberation Mono"',
|
|
506
|
+
'"Courier New"',
|
|
507
|
+
"monospace"
|
|
508
|
+
]);
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
sans,
|
|
512
|
+
serif,
|
|
513
|
+
mono,
|
|
514
|
+
webfonts,
|
|
515
|
+
provider,
|
|
516
|
+
local,
|
|
517
|
+
italic,
|
|
518
|
+
weights
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
function resolveDarwings(options = {}) {
|
|
522
|
+
const {
|
|
523
|
+
enabled = true,
|
|
524
|
+
persist = false
|
|
525
|
+
} = options;
|
|
526
|
+
const persistPath = typeof persist === "string" ? persist : persist ? ".slidev/drawings" : false;
|
|
527
|
+
return {
|
|
528
|
+
enabled,
|
|
529
|
+
persist: persistPath
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
368
533
|
// src/core.ts
|
|
369
534
|
function stringify(data) {
|
|
370
535
|
return `${data.slides.map((slide, idx) => stringifySlide(slide.inline || slide, idx)).join("\n").trim()}
|
|
@@ -410,7 +575,7 @@ function matter(code) {
|
|
|
410
575
|
let data = {};
|
|
411
576
|
const content = code.replace(/^---.*\r?\n([\s\S]*?)---/, (_, d) => {
|
|
412
577
|
data = _jsyaml2.default.load(d);
|
|
413
|
-
if (!(0,
|
|
578
|
+
if (!(0, import_utils4.isObject)(data))
|
|
414
579
|
data = {};
|
|
415
580
|
return "";
|
|
416
581
|
});
|
|
@@ -493,112 +658,8 @@ function parse(markdown, filepath, themeMeta) {
|
|
|
493
658
|
themeMeta
|
|
494
659
|
};
|
|
495
660
|
}
|
|
496
|
-
function resolveFonts(fonts = {}) {
|
|
497
|
-
const {
|
|
498
|
-
fallbacks = true,
|
|
499
|
-
italic = false,
|
|
500
|
-
provider = "google"
|
|
501
|
-
} = fonts;
|
|
502
|
-
let sans = (0, import_utils2.toArray)(fonts.sans).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
503
|
-
let serif = (0, import_utils2.toArray)(fonts.serif).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
504
|
-
let mono = (0, import_utils2.toArray)(fonts.mono).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
505
|
-
const weights = (0, import_utils2.toArray)(fonts.weights || "200,400,600").flatMap((i) => i.toString().split(/,\s*/g)).map((i) => i.trim());
|
|
506
|
-
const custom = (0, import_utils2.toArray)(fonts.custom).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
507
|
-
const local = (0, import_utils2.toArray)(fonts.local).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
508
|
-
const webfonts = fonts.webfonts ? fonts.webfonts : fallbacks ? (0, import_utils2.uniq)([...sans, ...serif, ...mono, ...custom]) : [];
|
|
509
|
-
webfonts.filter((i) => local.includes(i));
|
|
510
|
-
function toQuoted(font) {
|
|
511
|
-
if (/^(['"]).*\1$/.test(font))
|
|
512
|
-
return font;
|
|
513
|
-
return `"${font}"`;
|
|
514
|
-
}
|
|
515
|
-
if (fallbacks) {
|
|
516
|
-
sans = (0, import_utils2.uniq)([
|
|
517
|
-
...sans.map(toQuoted),
|
|
518
|
-
"ui-sans-serif",
|
|
519
|
-
"system-ui",
|
|
520
|
-
"-apple-system",
|
|
521
|
-
"BlinkMacSystemFont",
|
|
522
|
-
'"Segoe UI"',
|
|
523
|
-
"Roboto",
|
|
524
|
-
'"Helvetica Neue"',
|
|
525
|
-
"Arial",
|
|
526
|
-
'"Noto Sans"',
|
|
527
|
-
"sans-serif",
|
|
528
|
-
'"Apple Color Emoji"',
|
|
529
|
-
'"Segoe UI Emoji"',
|
|
530
|
-
'"Segoe UI Symbol"',
|
|
531
|
-
'"Noto Color Emoji"'
|
|
532
|
-
]);
|
|
533
|
-
serif = (0, import_utils2.uniq)([
|
|
534
|
-
...serif.map(toQuoted),
|
|
535
|
-
"ui-serif",
|
|
536
|
-
"Georgia",
|
|
537
|
-
"Cambria",
|
|
538
|
-
'"Times New Roman"',
|
|
539
|
-
"Times",
|
|
540
|
-
"serif"
|
|
541
|
-
]);
|
|
542
|
-
mono = (0, import_utils2.uniq)([
|
|
543
|
-
...mono.map(toQuoted),
|
|
544
|
-
"ui-monospace",
|
|
545
|
-
"SFMono-Regular",
|
|
546
|
-
"Menlo",
|
|
547
|
-
"Monaco",
|
|
548
|
-
"Consolas",
|
|
549
|
-
'"Liberation Mono"',
|
|
550
|
-
'"Courier New"',
|
|
551
|
-
"monospace"
|
|
552
|
-
]);
|
|
553
|
-
}
|
|
554
|
-
return {
|
|
555
|
-
sans,
|
|
556
|
-
serif,
|
|
557
|
-
mono,
|
|
558
|
-
webfonts,
|
|
559
|
-
provider,
|
|
560
|
-
local,
|
|
561
|
-
italic,
|
|
562
|
-
weights
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
function resolveConfig(headmatter, themeMeta = {}) {
|
|
566
|
-
var _a, _b;
|
|
567
|
-
const themeHightlighter = ["prism", "shiki"].includes(themeMeta.highlighter || "") ? themeMeta.highlighter : void 0;
|
|
568
|
-
const themeColorSchema = ["light", "dark"].includes(themeMeta.colorSchema || "") ? themeMeta.colorSchema : void 0;
|
|
569
|
-
const defaultConfig = {
|
|
570
|
-
theme: "default",
|
|
571
|
-
title: "Slidev",
|
|
572
|
-
titleTemplate: "%s - Slidev",
|
|
573
|
-
remoteAssets: true,
|
|
574
|
-
monaco: "dev",
|
|
575
|
-
download: false,
|
|
576
|
-
info: false,
|
|
577
|
-
highlighter: themeHightlighter || "prism",
|
|
578
|
-
colorSchema: themeColorSchema || "auto",
|
|
579
|
-
routerMode: "history",
|
|
580
|
-
aspectRatio: 16 / 9,
|
|
581
|
-
canvasWidth: 980,
|
|
582
|
-
selectable: false,
|
|
583
|
-
themeConfig: {},
|
|
584
|
-
fonts: {}
|
|
585
|
-
};
|
|
586
|
-
const config = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultConfig), themeMeta.defaults), headmatter.config), headmatter), {
|
|
587
|
-
fonts: resolveFonts(__spreadValues(__spreadValues(__spreadValues({}, (_a = themeMeta.defaults) == null ? void 0 : _a.fonts), (_b = headmatter.config) == null ? void 0 : _b.fonts), headmatter == null ? void 0 : headmatter.fonts))
|
|
588
|
-
});
|
|
589
|
-
if (config.colorSchema !== "dark" && config.colorSchema !== "light")
|
|
590
|
-
config.colorSchema = "auto";
|
|
591
|
-
if (themeColorSchema && config.colorSchema === "auto")
|
|
592
|
-
config.colorSchema = themeColorSchema;
|
|
593
|
-
config.aspectRatio = parseAspectRatio(config.aspectRatio);
|
|
594
|
-
if (themeColorSchema && config.colorSchema !== themeColorSchema)
|
|
595
|
-
console.warn(`[slidev] Color schema "${config.colorSchema}" does not supported by the theme`);
|
|
596
|
-
if (themeHightlighter && config.highlighter !== themeHightlighter)
|
|
597
|
-
console.warn(`[slidev] Syntax highlighter "${config.highlighter}" does not supported by the theme`);
|
|
598
|
-
return config;
|
|
599
|
-
}
|
|
600
661
|
function mergeFeatureFlags(a, b) {
|
|
601
|
-
return (0,
|
|
662
|
+
return (0, import_utils4.objectMap)(a, (k, v) => [k, v || b[k]]);
|
|
602
663
|
}
|
|
603
664
|
function scanMonacoModules(md) {
|
|
604
665
|
const typeModules = new Set();
|
|
@@ -606,7 +667,7 @@ function scanMonacoModules(md) {
|
|
|
606
667
|
options = options || "";
|
|
607
668
|
lang = lang.trim();
|
|
608
669
|
if (lang === "ts" || lang === "typescript") {
|
|
609
|
-
Array.from(code.matchAll(/\s+from\s+(["'])([\/\w@-]+)\1/g)).map((i) => i[2]).filter(
|
|
670
|
+
Array.from(code.matchAll(/\s+from\s+(["'])([\/\w@-]+)\1/g)).map((i) => i[2]).filter(import_utils4.isTruthy).map((i) => typeModules.add(i));
|
|
610
671
|
}
|
|
611
672
|
return "";
|
|
612
673
|
});
|
|
@@ -628,4 +689,5 @@ function scanMonacoModules(md) {
|
|
|
628
689
|
|
|
629
690
|
|
|
630
691
|
|
|
631
|
-
|
|
692
|
+
|
|
693
|
+
exports.__spreadValues = __spreadValues; exports.parseRangeString = parseRangeString; exports.parseAspectRatio = parseAspectRatio; exports.resolveConfig = resolveConfig; exports.resolveFonts = resolveFonts; exports.stringify = stringify; exports.filterDisabled = filterDisabled; exports.stringifySlide = stringifySlide; exports.prettifySlide = prettifySlide; exports.prettify = prettify; exports.detectFeatures = detectFeatures; exports.parseSlide = parseSlide; exports.parse = parse; exports.mergeFeatureFlags = mergeFeatureFlags; exports.scanMonacoModules = scanMonacoModules;
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SlidevThemeMeta, SlidevConfig, FontOptions, ResolvedFontOptions, SlidevMarkdown, SlideInfoBase, SlidevFeatureFlags } from '@slidev/types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 1,3-5,8 => [1, 3, 4, 5, 8]
|
|
@@ -9,6 +9,9 @@ declare function parseRangeString(total: number, rangeStr?: string): number[];
|
|
|
9
9
|
*/
|
|
10
10
|
declare function parseAspectRatio(str: string | number): number;
|
|
11
11
|
|
|
12
|
+
declare function resolveConfig(headmatter: any, themeMeta?: SlidevThemeMeta): SlidevConfig;
|
|
13
|
+
declare function resolveFonts(fonts?: FontOptions): ResolvedFontOptions;
|
|
14
|
+
|
|
12
15
|
declare function stringify(data: SlidevMarkdown): string;
|
|
13
16
|
declare function filterDisabled(data: SlidevMarkdown): SlidevMarkdown;
|
|
14
17
|
declare function stringifySlide(data: SlideInfoBase, idx?: number): string;
|
|
@@ -17,8 +20,7 @@ declare function prettify(data: SlidevMarkdown): SlidevMarkdown;
|
|
|
17
20
|
declare function detectFeatures(code: string): SlidevFeatureFlags;
|
|
18
21
|
declare function parseSlide(raw: string): SlideInfoBase;
|
|
19
22
|
declare function parse(markdown: string, filepath?: string, themeMeta?: SlidevThemeMeta): SlidevMarkdown;
|
|
20
|
-
declare function resolveConfig(headmatter: any, themeMeta?: SlidevThemeMeta): SlidevConfig;
|
|
21
23
|
declare function mergeFeatureFlags(a: SlidevFeatureFlags, b: SlidevFeatureFlags): SlidevFeatureFlags;
|
|
22
24
|
declare function scanMonacoModules(md: string): string[];
|
|
23
25
|
|
|
24
|
-
export { detectFeatures, filterDisabled, mergeFeatureFlags, parse, parseAspectRatio, parseRangeString, parseSlide, prettify, prettifySlide, resolveConfig, scanMonacoModules, stringify, stringifySlide };
|
|
26
|
+
export { detectFeatures, filterDisabled, mergeFeatureFlags, parse, parseAspectRatio, parseRangeString, parseSlide, prettify, prettifySlide, resolveConfig, resolveFonts, scanMonacoModules, stringify, stringifySlide };
|
package/dist/core.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var _chunkSDUAGQ4Tjs = require('./chunk-SDUAGQ4T.js');
|
|
16
15
|
|
|
16
|
+
var _chunkDWI67SELjs = require('./chunk-DWI67SEL.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -27,4 +27,6 @@ var _chunkSDUAGQ4Tjs = require('./chunk-SDUAGQ4T.js');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.detectFeatures = _chunkDWI67SELjs.detectFeatures; exports.filterDisabled = _chunkDWI67SELjs.filterDisabled; exports.mergeFeatureFlags = _chunkDWI67SELjs.mergeFeatureFlags; exports.parse = _chunkDWI67SELjs.parse; exports.parseAspectRatio = _chunkDWI67SELjs.parseAspectRatio; exports.parseRangeString = _chunkDWI67SELjs.parseRangeString; exports.parseSlide = _chunkDWI67SELjs.parseSlide; exports.prettify = _chunkDWI67SELjs.prettify; exports.prettifySlide = _chunkDWI67SELjs.prettifySlide; exports.resolveConfig = _chunkDWI67SELjs.resolveConfig; exports.resolveFonts = _chunkDWI67SELjs.resolveFonts; exports.scanMonacoModules = _chunkDWI67SELjs.scanMonacoModules; exports.stringify = _chunkDWI67SELjs.stringify; exports.stringifySlide = _chunkDWI67SELjs.stringifySlide;
|
package/dist/core.mjs
CHANGED
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
prettify,
|
|
10
10
|
prettifySlide,
|
|
11
11
|
resolveConfig,
|
|
12
|
+
resolveFonts,
|
|
12
13
|
scanMonacoModules,
|
|
13
14
|
stringify,
|
|
14
15
|
stringifySlide
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-3PVKGM3Z.mjs";
|
|
16
17
|
export {
|
|
17
18
|
detectFeatures,
|
|
18
19
|
filterDisabled,
|
|
@@ -24,6 +25,7 @@ export {
|
|
|
24
25
|
prettify,
|
|
25
26
|
prettifySlide,
|
|
26
27
|
resolveConfig,
|
|
28
|
+
resolveFonts,
|
|
27
29
|
scanMonacoModules,
|
|
28
30
|
stringify,
|
|
29
31
|
stringifySlide
|
package/dist/fs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SlidevThemeMeta, SlidevMarkdown, SlideInfoWithPath } from '@slidev/types';
|
|
2
|
-
export { detectFeatures, filterDisabled, mergeFeatureFlags, parse, parseAspectRatio, parseRangeString, parseSlide, prettify, prettifySlide, resolveConfig, scanMonacoModules, stringify, stringifySlide } from './core';
|
|
2
|
+
export { detectFeatures, filterDisabled, mergeFeatureFlags, parse, parseAspectRatio, parseRangeString, parseSlide, prettify, prettifySlide, resolveConfig, resolveFonts, scanMonacoModules, stringify, stringifySlide } from './core';
|
|
3
3
|
|
|
4
4
|
declare function load(filepath: string, themeMeta?: SlidevThemeMeta, content?: string): Promise<SlidevMarkdown>;
|
|
5
5
|
declare function save(data: SlidevMarkdown, filepath?: string): Promise<void>;
|
package/dist/fs.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
var _chunkDWI67SELjs = require('./chunk-DWI67SEL.js');
|
|
17
18
|
|
|
18
19
|
// src/fs.ts
|
|
19
20
|
var _fs = require('fs');
|
|
@@ -21,7 +22,7 @@ var _path = require('path');
|
|
|
21
22
|
async function load(filepath, themeMeta, content) {
|
|
22
23
|
const dir = _path.dirname.call(void 0, filepath);
|
|
23
24
|
const markdown = content != null ? content : await _fs.promises.readFile(filepath, "utf-8");
|
|
24
|
-
const data =
|
|
25
|
+
const data = _chunkDWI67SELjs.parse.call(void 0, markdown, filepath, themeMeta);
|
|
25
26
|
const entries = new Set([
|
|
26
27
|
filepath
|
|
27
28
|
]);
|
|
@@ -30,15 +31,15 @@ async function load(filepath, themeMeta, content) {
|
|
|
30
31
|
continue;
|
|
31
32
|
const path = _path.resolve.call(void 0, dir, slide.frontmatter.src);
|
|
32
33
|
const raw = await _fs.promises.readFile(path, "utf-8");
|
|
33
|
-
const source =
|
|
34
|
-
const inline =
|
|
35
|
-
slide.source =
|
|
34
|
+
const source = _chunkDWI67SELjs.parseSlide.call(void 0, raw);
|
|
35
|
+
const inline = _chunkDWI67SELjs.__spreadValues.call(void 0, {}, slide);
|
|
36
|
+
slide.source = _chunkDWI67SELjs.__spreadValues.call(void 0, {
|
|
36
37
|
filepath: path
|
|
37
38
|
}, source);
|
|
38
39
|
slide.inline = inline;
|
|
39
40
|
Object.assign(slide, slide.source);
|
|
40
|
-
slide.frontmatter =
|
|
41
|
-
data.features =
|
|
41
|
+
slide.frontmatter = _chunkDWI67SELjs.__spreadValues.call(void 0, _chunkDWI67SELjs.__spreadValues.call(void 0, {}, slide.source.frontmatter), inline.frontmatter);
|
|
42
|
+
data.features = _chunkDWI67SELjs.mergeFeatureFlags.call(void 0, data.features, _chunkDWI67SELjs.detectFeatures.call(void 0, raw));
|
|
42
43
|
entries.add(path);
|
|
43
44
|
}
|
|
44
45
|
data.entries = Array.from(entries);
|
|
@@ -46,10 +47,10 @@ async function load(filepath, themeMeta, content) {
|
|
|
46
47
|
}
|
|
47
48
|
async function save(data, filepath) {
|
|
48
49
|
filepath = filepath || data.filepath;
|
|
49
|
-
await _fs.promises.writeFile(filepath,
|
|
50
|
+
await _fs.promises.writeFile(filepath, _chunkDWI67SELjs.stringify.call(void 0, data), "utf-8");
|
|
50
51
|
}
|
|
51
52
|
async function saveExternalSlide(slide) {
|
|
52
|
-
await _fs.promises.writeFile(slide.filepath,
|
|
53
|
+
await _fs.promises.writeFile(slide.filepath, _chunkDWI67SELjs.stringifySlide.call(void 0, slide), "utf-8");
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
|
|
@@ -68,4 +69,5 @@ async function saveExternalSlide(slide) {
|
|
|
68
69
|
|
|
69
70
|
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
|
|
73
|
+
exports.detectFeatures = _chunkDWI67SELjs.detectFeatures; exports.filterDisabled = _chunkDWI67SELjs.filterDisabled; exports.load = load; exports.mergeFeatureFlags = _chunkDWI67SELjs.mergeFeatureFlags; exports.parse = _chunkDWI67SELjs.parse; exports.parseAspectRatio = _chunkDWI67SELjs.parseAspectRatio; exports.parseRangeString = _chunkDWI67SELjs.parseRangeString; exports.parseSlide = _chunkDWI67SELjs.parseSlide; exports.prettify = _chunkDWI67SELjs.prettify; exports.prettifySlide = _chunkDWI67SELjs.prettifySlide; exports.resolveConfig = _chunkDWI67SELjs.resolveConfig; exports.resolveFonts = _chunkDWI67SELjs.resolveFonts; exports.save = save; exports.saveExternalSlide = saveExternalSlide; exports.scanMonacoModules = _chunkDWI67SELjs.scanMonacoModules; exports.stringify = _chunkDWI67SELjs.stringify; exports.stringifySlide = _chunkDWI67SELjs.stringifySlide;
|
package/dist/fs.mjs
CHANGED
|
@@ -10,10 +10,11 @@ import {
|
|
|
10
10
|
prettify,
|
|
11
11
|
prettifySlide,
|
|
12
12
|
resolveConfig,
|
|
13
|
+
resolveFonts,
|
|
13
14
|
scanMonacoModules,
|
|
14
15
|
stringify,
|
|
15
16
|
stringifySlide
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-3PVKGM3Z.mjs";
|
|
17
18
|
|
|
18
19
|
// src/fs.ts
|
|
19
20
|
import { promises as fs } from "fs";
|
|
@@ -63,6 +64,7 @@ export {
|
|
|
63
64
|
prettify,
|
|
64
65
|
prettifySlide,
|
|
65
66
|
resolveConfig,
|
|
67
|
+
resolveFonts,
|
|
66
68
|
save,
|
|
67
69
|
saveExternalSlide,
|
|
68
70
|
scanMonacoModules,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { detectFeatures, filterDisabled, mergeFeatureFlags, parse, parseAspectRatio, parseRangeString, parseSlide, prettify, prettifySlide, resolveConfig, scanMonacoModules, stringify, stringifySlide } from './core';
|
|
1
|
+
export { detectFeatures, filterDisabled, mergeFeatureFlags, parse, parseAspectRatio, parseRangeString, parseSlide, prettify, prettifySlide, resolveConfig, resolveFonts, scanMonacoModules, stringify, stringifySlide } from './core';
|
|
2
2
|
import '@slidev/types';
|
package/dist/index.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var _chunkSDUAGQ4Tjs = require('./chunk-SDUAGQ4T.js');
|
|
16
15
|
|
|
16
|
+
var _chunkDWI67SELjs = require('./chunk-DWI67SEL.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -27,4 +27,6 @@ var _chunkSDUAGQ4Tjs = require('./chunk-SDUAGQ4T.js');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.detectFeatures = _chunkDWI67SELjs.detectFeatures; exports.filterDisabled = _chunkDWI67SELjs.filterDisabled; exports.mergeFeatureFlags = _chunkDWI67SELjs.mergeFeatureFlags; exports.parse = _chunkDWI67SELjs.parse; exports.parseAspectRatio = _chunkDWI67SELjs.parseAspectRatio; exports.parseRangeString = _chunkDWI67SELjs.parseRangeString; exports.parseSlide = _chunkDWI67SELjs.parseSlide; exports.prettify = _chunkDWI67SELjs.prettify; exports.prettifySlide = _chunkDWI67SELjs.prettifySlide; exports.resolveConfig = _chunkDWI67SELjs.resolveConfig; exports.resolveFonts = _chunkDWI67SELjs.resolveFonts; exports.scanMonacoModules = _chunkDWI67SELjs.scanMonacoModules; exports.stringify = _chunkDWI67SELjs.stringify; exports.stringifySlide = _chunkDWI67SELjs.stringifySlide;
|
package/dist/index.mjs
CHANGED
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
prettify,
|
|
10
10
|
prettifySlide,
|
|
11
11
|
resolveConfig,
|
|
12
|
+
resolveFonts,
|
|
12
13
|
scanMonacoModules,
|
|
13
14
|
stringify,
|
|
14
15
|
stringifySlide
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-3PVKGM3Z.mjs";
|
|
16
17
|
export {
|
|
17
18
|
detectFeatures,
|
|
18
19
|
filterDisabled,
|
|
@@ -24,6 +25,7 @@ export {
|
|
|
24
25
|
prettify,
|
|
25
26
|
prettifySlide,
|
|
26
27
|
resolveConfig,
|
|
28
|
+
resolveFonts,
|
|
27
29
|
scanMonacoModules,
|
|
28
30
|
stringify,
|
|
29
31
|
stringifySlide
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
2
|
+
"name": "@slidev/parser",
|
|
3
|
+
"version": "0.23.1",
|
|
4
|
+
"description": "Markdown parser for Slidev",
|
|
5
|
+
"homepage": "https://sli.dev",
|
|
6
|
+
"bugs": "https://github.com/slidevjs/slidev/issues",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/slidevjs/slidev"
|
|
11
|
+
},
|
|
12
|
+
"funding": "https://github.com/sponsors/antfu",
|
|
13
|
+
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"index.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./dist/index.mjs",
|
|
21
|
+
"require": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./core": {
|
|
24
|
+
"import": "./dist/core.mjs",
|
|
25
|
+
"require": "./dist/core.js"
|
|
26
|
+
},
|
|
27
|
+
"./fs": {
|
|
28
|
+
"import": "./dist/fs.mjs",
|
|
29
|
+
"require": "./dist/fs.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"main": "dist/index.js",
|
|
33
|
+
"module": "dist/index.mjs",
|
|
34
|
+
"types": "dist/index.d.ts",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@slidev/types": "0.23.1",
|
|
37
|
+
"js-yaml": "^4.1.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=14.0.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "rimraf dist && tsup src/index.ts src/core.ts src/fs.ts --format cjs,esm --dts",
|
|
44
|
+
"dev": "nr build --watch"
|
|
45
|
+
}
|
|
46
|
+
}
|