@slidev/cli 0.49.4 → 0.49.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.
|
@@ -89,17 +89,17 @@ var require_visit = __commonJS({
|
|
|
89
89
|
visit.BREAK = BREAK;
|
|
90
90
|
visit.SKIP = SKIP;
|
|
91
91
|
visit.REMOVE = REMOVE;
|
|
92
|
-
function visit_(key, node, visitor,
|
|
93
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
92
|
+
function visit_(key, node, visitor, path4) {
|
|
93
|
+
const ctrl = callVisitor(key, node, visitor, path4);
|
|
94
94
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
95
|
-
replaceNode(key,
|
|
96
|
-
return visit_(key, ctrl, visitor,
|
|
95
|
+
replaceNode(key, path4, ctrl);
|
|
96
|
+
return visit_(key, ctrl, visitor, path4);
|
|
97
97
|
}
|
|
98
98
|
if (typeof ctrl !== "symbol") {
|
|
99
99
|
if (identity.isCollection(node)) {
|
|
100
|
-
|
|
100
|
+
path4 = Object.freeze(path4.concat(node));
|
|
101
101
|
for (let i = 0; i < node.items.length; ++i) {
|
|
102
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
102
|
+
const ci = visit_(i, node.items[i], visitor, path4);
|
|
103
103
|
if (typeof ci === "number")
|
|
104
104
|
i = ci - 1;
|
|
105
105
|
else if (ci === BREAK)
|
|
@@ -110,13 +110,13 @@ var require_visit = __commonJS({
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
} else if (identity.isPair(node)) {
|
|
113
|
-
|
|
114
|
-
const ck = visit_("key", node.key, visitor,
|
|
113
|
+
path4 = Object.freeze(path4.concat(node));
|
|
114
|
+
const ck = visit_("key", node.key, visitor, path4);
|
|
115
115
|
if (ck === BREAK)
|
|
116
116
|
return BREAK;
|
|
117
117
|
else if (ck === REMOVE)
|
|
118
118
|
node.key = null;
|
|
119
|
-
const cv = visit_("value", node.value, visitor,
|
|
119
|
+
const cv = visit_("value", node.value, visitor, path4);
|
|
120
120
|
if (cv === BREAK)
|
|
121
121
|
return BREAK;
|
|
122
122
|
else if (cv === REMOVE)
|
|
@@ -137,17 +137,17 @@ var require_visit = __commonJS({
|
|
|
137
137
|
visitAsync.BREAK = BREAK;
|
|
138
138
|
visitAsync.SKIP = SKIP;
|
|
139
139
|
visitAsync.REMOVE = REMOVE;
|
|
140
|
-
async function visitAsync_(key, node, visitor,
|
|
141
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
140
|
+
async function visitAsync_(key, node, visitor, path4) {
|
|
141
|
+
const ctrl = await callVisitor(key, node, visitor, path4);
|
|
142
142
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
143
|
-
replaceNode(key,
|
|
144
|
-
return visitAsync_(key, ctrl, visitor,
|
|
143
|
+
replaceNode(key, path4, ctrl);
|
|
144
|
+
return visitAsync_(key, ctrl, visitor, path4);
|
|
145
145
|
}
|
|
146
146
|
if (typeof ctrl !== "symbol") {
|
|
147
147
|
if (identity.isCollection(node)) {
|
|
148
|
-
|
|
148
|
+
path4 = Object.freeze(path4.concat(node));
|
|
149
149
|
for (let i = 0; i < node.items.length; ++i) {
|
|
150
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
150
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path4);
|
|
151
151
|
if (typeof ci === "number")
|
|
152
152
|
i = ci - 1;
|
|
153
153
|
else if (ci === BREAK)
|
|
@@ -158,13 +158,13 @@ var require_visit = __commonJS({
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
} else if (identity.isPair(node)) {
|
|
161
|
-
|
|
162
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
161
|
+
path4 = Object.freeze(path4.concat(node));
|
|
162
|
+
const ck = await visitAsync_("key", node.key, visitor, path4);
|
|
163
163
|
if (ck === BREAK)
|
|
164
164
|
return BREAK;
|
|
165
165
|
else if (ck === REMOVE)
|
|
166
166
|
node.key = null;
|
|
167
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
167
|
+
const cv = await visitAsync_("value", node.value, visitor, path4);
|
|
168
168
|
if (cv === BREAK)
|
|
169
169
|
return BREAK;
|
|
170
170
|
else if (cv === REMOVE)
|
|
@@ -191,23 +191,23 @@ var require_visit = __commonJS({
|
|
|
191
191
|
}
|
|
192
192
|
return visitor;
|
|
193
193
|
}
|
|
194
|
-
function callVisitor(key, node, visitor,
|
|
194
|
+
function callVisitor(key, node, visitor, path4) {
|
|
195
195
|
if (typeof visitor === "function")
|
|
196
|
-
return visitor(key, node,
|
|
196
|
+
return visitor(key, node, path4);
|
|
197
197
|
if (identity.isMap(node))
|
|
198
|
-
return visitor.Map?.(key, node,
|
|
198
|
+
return visitor.Map?.(key, node, path4);
|
|
199
199
|
if (identity.isSeq(node))
|
|
200
|
-
return visitor.Seq?.(key, node,
|
|
200
|
+
return visitor.Seq?.(key, node, path4);
|
|
201
201
|
if (identity.isPair(node))
|
|
202
|
-
return visitor.Pair?.(key, node,
|
|
202
|
+
return visitor.Pair?.(key, node, path4);
|
|
203
203
|
if (identity.isScalar(node))
|
|
204
|
-
return visitor.Scalar?.(key, node,
|
|
204
|
+
return visitor.Scalar?.(key, node, path4);
|
|
205
205
|
if (identity.isAlias(node))
|
|
206
|
-
return visitor.Alias?.(key, node,
|
|
206
|
+
return visitor.Alias?.(key, node, path4);
|
|
207
207
|
return void 0;
|
|
208
208
|
}
|
|
209
|
-
function replaceNode(key,
|
|
210
|
-
const parent =
|
|
209
|
+
function replaceNode(key, path4, node) {
|
|
210
|
+
const parent = path4[path4.length - 1];
|
|
211
211
|
if (identity.isCollection(parent)) {
|
|
212
212
|
parent.items[key] = node;
|
|
213
213
|
} else if (identity.isPair(parent)) {
|
|
@@ -805,10 +805,10 @@ var require_Collection = __commonJS({
|
|
|
805
805
|
var createNode = require_createNode();
|
|
806
806
|
var identity = require_identity();
|
|
807
807
|
var Node = require_Node();
|
|
808
|
-
function collectionFromPath(schema,
|
|
808
|
+
function collectionFromPath(schema, path4, value) {
|
|
809
809
|
let v = value;
|
|
810
|
-
for (let i =
|
|
811
|
-
const k =
|
|
810
|
+
for (let i = path4.length - 1; i >= 0; --i) {
|
|
811
|
+
const k = path4[i];
|
|
812
812
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
813
813
|
const a = [];
|
|
814
814
|
a[k] = v;
|
|
@@ -827,7 +827,7 @@ var require_Collection = __commonJS({
|
|
|
827
827
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
828
828
|
});
|
|
829
829
|
}
|
|
830
|
-
var isEmptyPath = (
|
|
830
|
+
var isEmptyPath = (path4) => path4 == null || typeof path4 === "object" && !!path4[Symbol.iterator]().next().done;
|
|
831
831
|
var Collection = class extends Node.NodeBase {
|
|
832
832
|
constructor(type, schema) {
|
|
833
833
|
super(type);
|
|
@@ -857,11 +857,11 @@ var require_Collection = __commonJS({
|
|
|
857
857
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
858
858
|
* that already exists in the map.
|
|
859
859
|
*/
|
|
860
|
-
addIn(
|
|
861
|
-
if (isEmptyPath(
|
|
860
|
+
addIn(path4, value) {
|
|
861
|
+
if (isEmptyPath(path4))
|
|
862
862
|
this.add(value);
|
|
863
863
|
else {
|
|
864
|
-
const [key, ...rest] =
|
|
864
|
+
const [key, ...rest] = path4;
|
|
865
865
|
const node = this.get(key, true);
|
|
866
866
|
if (identity.isCollection(node))
|
|
867
867
|
node.addIn(rest, value);
|
|
@@ -875,8 +875,8 @@ var require_Collection = __commonJS({
|
|
|
875
875
|
* Removes a value from the collection.
|
|
876
876
|
* @returns `true` if the item was found and removed.
|
|
877
877
|
*/
|
|
878
|
-
deleteIn(
|
|
879
|
-
const [key, ...rest] =
|
|
878
|
+
deleteIn(path4) {
|
|
879
|
+
const [key, ...rest] = path4;
|
|
880
880
|
if (rest.length === 0)
|
|
881
881
|
return this.delete(key);
|
|
882
882
|
const node = this.get(key, true);
|
|
@@ -890,8 +890,8 @@ var require_Collection = __commonJS({
|
|
|
890
890
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
891
891
|
* `true` (collections are always returned intact).
|
|
892
892
|
*/
|
|
893
|
-
getIn(
|
|
894
|
-
const [key, ...rest] =
|
|
893
|
+
getIn(path4, keepScalar) {
|
|
894
|
+
const [key, ...rest] = path4;
|
|
895
895
|
const node = this.get(key, true);
|
|
896
896
|
if (rest.length === 0)
|
|
897
897
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -909,8 +909,8 @@ var require_Collection = __commonJS({
|
|
|
909
909
|
/**
|
|
910
910
|
* Checks if the collection includes a value with the key `key`.
|
|
911
911
|
*/
|
|
912
|
-
hasIn(
|
|
913
|
-
const [key, ...rest] =
|
|
912
|
+
hasIn(path4) {
|
|
913
|
+
const [key, ...rest] = path4;
|
|
914
914
|
if (rest.length === 0)
|
|
915
915
|
return this.has(key);
|
|
916
916
|
const node = this.get(key, true);
|
|
@@ -920,8 +920,8 @@ var require_Collection = __commonJS({
|
|
|
920
920
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
921
921
|
* boolean to add/remove the item from the set.
|
|
922
922
|
*/
|
|
923
|
-
setIn(
|
|
924
|
-
const [key, ...rest] =
|
|
923
|
+
setIn(path4, value) {
|
|
924
|
+
const [key, ...rest] = path4;
|
|
925
925
|
if (rest.length === 0) {
|
|
926
926
|
this.set(key, value);
|
|
927
927
|
} else {
|
|
@@ -3369,9 +3369,9 @@ var require_Document = __commonJS({
|
|
|
3369
3369
|
this.contents.add(value);
|
|
3370
3370
|
}
|
|
3371
3371
|
/** Adds a value to the document. */
|
|
3372
|
-
addIn(
|
|
3372
|
+
addIn(path4, value) {
|
|
3373
3373
|
if (assertCollection(this.contents))
|
|
3374
|
-
this.contents.addIn(
|
|
3374
|
+
this.contents.addIn(path4, value);
|
|
3375
3375
|
}
|
|
3376
3376
|
/**
|
|
3377
3377
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -3446,14 +3446,14 @@ var require_Document = __commonJS({
|
|
|
3446
3446
|
* Removes a value from the document.
|
|
3447
3447
|
* @returns `true` if the item was found and removed.
|
|
3448
3448
|
*/
|
|
3449
|
-
deleteIn(
|
|
3450
|
-
if (Collection.isEmptyPath(
|
|
3449
|
+
deleteIn(path4) {
|
|
3450
|
+
if (Collection.isEmptyPath(path4)) {
|
|
3451
3451
|
if (this.contents == null)
|
|
3452
3452
|
return false;
|
|
3453
3453
|
this.contents = null;
|
|
3454
3454
|
return true;
|
|
3455
3455
|
}
|
|
3456
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
3456
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path4) : false;
|
|
3457
3457
|
}
|
|
3458
3458
|
/**
|
|
3459
3459
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -3468,10 +3468,10 @@ var require_Document = __commonJS({
|
|
|
3468
3468
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
3469
3469
|
* `true` (collections are always returned intact).
|
|
3470
3470
|
*/
|
|
3471
|
-
getIn(
|
|
3472
|
-
if (Collection.isEmptyPath(
|
|
3471
|
+
getIn(path4, keepScalar) {
|
|
3472
|
+
if (Collection.isEmptyPath(path4))
|
|
3473
3473
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3474
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3474
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path4, keepScalar) : void 0;
|
|
3475
3475
|
}
|
|
3476
3476
|
/**
|
|
3477
3477
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -3482,10 +3482,10 @@ var require_Document = __commonJS({
|
|
|
3482
3482
|
/**
|
|
3483
3483
|
* Checks if the document includes a value at `path`.
|
|
3484
3484
|
*/
|
|
3485
|
-
hasIn(
|
|
3486
|
-
if (Collection.isEmptyPath(
|
|
3485
|
+
hasIn(path4) {
|
|
3486
|
+
if (Collection.isEmptyPath(path4))
|
|
3487
3487
|
return this.contents !== void 0;
|
|
3488
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3488
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path4) : false;
|
|
3489
3489
|
}
|
|
3490
3490
|
/**
|
|
3491
3491
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -3502,13 +3502,13 @@ var require_Document = __commonJS({
|
|
|
3502
3502
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
3503
3503
|
* boolean to add/remove the item from the set.
|
|
3504
3504
|
*/
|
|
3505
|
-
setIn(
|
|
3506
|
-
if (Collection.isEmptyPath(
|
|
3505
|
+
setIn(path4, value) {
|
|
3506
|
+
if (Collection.isEmptyPath(path4)) {
|
|
3507
3507
|
this.contents = value;
|
|
3508
3508
|
} else if (this.contents == null) {
|
|
3509
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3509
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path4), value);
|
|
3510
3510
|
} else if (assertCollection(this.contents)) {
|
|
3511
|
-
this.contents.setIn(
|
|
3511
|
+
this.contents.setIn(path4, value);
|
|
3512
3512
|
}
|
|
3513
3513
|
}
|
|
3514
3514
|
/**
|
|
@@ -5403,9 +5403,9 @@ var require_cst_visit = __commonJS({
|
|
|
5403
5403
|
visit.BREAK = BREAK;
|
|
5404
5404
|
visit.SKIP = SKIP;
|
|
5405
5405
|
visit.REMOVE = REMOVE;
|
|
5406
|
-
visit.itemAtPath = (cst,
|
|
5406
|
+
visit.itemAtPath = (cst, path4) => {
|
|
5407
5407
|
let item = cst;
|
|
5408
|
-
for (const [field, index] of
|
|
5408
|
+
for (const [field, index] of path4) {
|
|
5409
5409
|
const tok = item?.[field];
|
|
5410
5410
|
if (tok && "items" in tok) {
|
|
5411
5411
|
item = tok.items[index];
|
|
@@ -5414,23 +5414,23 @@ var require_cst_visit = __commonJS({
|
|
|
5414
5414
|
}
|
|
5415
5415
|
return item;
|
|
5416
5416
|
};
|
|
5417
|
-
visit.parentCollection = (cst,
|
|
5418
|
-
const parent = visit.itemAtPath(cst,
|
|
5419
|
-
const field =
|
|
5417
|
+
visit.parentCollection = (cst, path4) => {
|
|
5418
|
+
const parent = visit.itemAtPath(cst, path4.slice(0, -1));
|
|
5419
|
+
const field = path4[path4.length - 1][0];
|
|
5420
5420
|
const coll = parent?.[field];
|
|
5421
5421
|
if (coll && "items" in coll)
|
|
5422
5422
|
return coll;
|
|
5423
5423
|
throw new Error("Parent collection not found");
|
|
5424
5424
|
};
|
|
5425
|
-
function _visit(
|
|
5426
|
-
let ctrl = visitor(item,
|
|
5425
|
+
function _visit(path4, item, visitor) {
|
|
5426
|
+
let ctrl = visitor(item, path4);
|
|
5427
5427
|
if (typeof ctrl === "symbol")
|
|
5428
5428
|
return ctrl;
|
|
5429
5429
|
for (const field of ["key", "value"]) {
|
|
5430
5430
|
const token = item[field];
|
|
5431
5431
|
if (token && "items" in token) {
|
|
5432
5432
|
for (let i = 0; i < token.items.length; ++i) {
|
|
5433
|
-
const ci = _visit(Object.freeze(
|
|
5433
|
+
const ci = _visit(Object.freeze(path4.concat([[field, i]])), token.items[i], visitor);
|
|
5434
5434
|
if (typeof ci === "number")
|
|
5435
5435
|
i = ci - 1;
|
|
5436
5436
|
else if (ci === BREAK)
|
|
@@ -5441,10 +5441,10 @@ var require_cst_visit = __commonJS({
|
|
|
5441
5441
|
}
|
|
5442
5442
|
}
|
|
5443
5443
|
if (typeof ctrl === "function" && field === "key")
|
|
5444
|
-
ctrl = ctrl(item,
|
|
5444
|
+
ctrl = ctrl(item, path4);
|
|
5445
5445
|
}
|
|
5446
5446
|
}
|
|
5447
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5447
|
+
return typeof ctrl === "function" ? ctrl(item, path4) : ctrl;
|
|
5448
5448
|
}
|
|
5449
5449
|
exports.visit = visit;
|
|
5450
5450
|
}
|
|
@@ -6707,14 +6707,14 @@ var require_parser = __commonJS({
|
|
|
6707
6707
|
case "scalar":
|
|
6708
6708
|
case "single-quoted-scalar":
|
|
6709
6709
|
case "double-quoted-scalar": {
|
|
6710
|
-
const
|
|
6710
|
+
const fs7 = this.flowScalar(this.type);
|
|
6711
6711
|
if (atNextItem || it.value) {
|
|
6712
|
-
map.items.push({ start, key:
|
|
6712
|
+
map.items.push({ start, key: fs7, sep: [] });
|
|
6713
6713
|
this.onKeyLine = true;
|
|
6714
6714
|
} else if (it.sep) {
|
|
6715
|
-
this.stack.push(
|
|
6715
|
+
this.stack.push(fs7);
|
|
6716
6716
|
} else {
|
|
6717
|
-
Object.assign(it, { key:
|
|
6717
|
+
Object.assign(it, { key: fs7, sep: [] });
|
|
6718
6718
|
this.onKeyLine = true;
|
|
6719
6719
|
}
|
|
6720
6720
|
return;
|
|
@@ -6832,13 +6832,13 @@ var require_parser = __commonJS({
|
|
|
6832
6832
|
case "scalar":
|
|
6833
6833
|
case "single-quoted-scalar":
|
|
6834
6834
|
case "double-quoted-scalar": {
|
|
6835
|
-
const
|
|
6835
|
+
const fs7 = this.flowScalar(this.type);
|
|
6836
6836
|
if (!it || it.value)
|
|
6837
|
-
fc.items.push({ start: [], key:
|
|
6837
|
+
fc.items.push({ start: [], key: fs7, sep: [] });
|
|
6838
6838
|
else if (it.sep)
|
|
6839
|
-
this.stack.push(
|
|
6839
|
+
this.stack.push(fs7);
|
|
6840
6840
|
else
|
|
6841
|
-
Object.assign(it, { key:
|
|
6841
|
+
Object.assign(it, { key: fs7, sep: [] });
|
|
6842
6842
|
return;
|
|
6843
6843
|
}
|
|
6844
6844
|
case "flow-map-end":
|
|
@@ -7143,13 +7143,12 @@ var require_dist = __commonJS({
|
|
|
7143
7143
|
});
|
|
7144
7144
|
|
|
7145
7145
|
// package.json
|
|
7146
|
-
var version = "0.49.
|
|
7146
|
+
var version = "0.49.6";
|
|
7147
7147
|
|
|
7148
7148
|
// node/commands/shared.ts
|
|
7149
7149
|
import { existsSync, promises as fs } from "node:fs";
|
|
7150
7150
|
import { join } from "node:path";
|
|
7151
7151
|
import { loadConfigFromFile, mergeConfig, resolveConfig } from "vite";
|
|
7152
|
-
import { isString } from "unocss";
|
|
7153
7152
|
import MarkdownIt from "markdown-it";
|
|
7154
7153
|
import { slash } from "@antfu/utils";
|
|
7155
7154
|
|
|
@@ -7202,8 +7201,8 @@ function updateFrontmatterPatch(slide, frontmatter) {
|
|
|
7202
7201
|
const valueNode = doc.createNode(value);
|
|
7203
7202
|
let found = false;
|
|
7204
7203
|
import_yaml.default.visit(doc.contents, {
|
|
7205
|
-
Pair(_key, node,
|
|
7206
|
-
if (
|
|
7204
|
+
Pair(_key, node, path4) {
|
|
7205
|
+
if (path4.length === 1 && import_yaml.default.isScalar(node.key) && node.key.value === key) {
|
|
7207
7206
|
node.value = valueNode;
|
|
7208
7207
|
found = true;
|
|
7209
7208
|
return import_yaml.default.visit.BREAK;
|
|
@@ -7224,12 +7223,11 @@ function updateFrontmatterPatch(slide, frontmatter) {
|
|
|
7224
7223
|
// node/commands/shared.ts
|
|
7225
7224
|
var sharedMd = MarkdownIt({ html: true });
|
|
7226
7225
|
sharedMd.use(markdownItLink);
|
|
7227
|
-
function
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
return data.config.title;
|
|
7226
|
+
function getSlideTitle(data) {
|
|
7227
|
+
const tokens = sharedMd.parseInline(data.config.title, {});
|
|
7228
|
+
const title = stringifyMarkdownTokens(tokens);
|
|
7229
|
+
const slideTitle = data.config.titleTemplate.replace("%s", title);
|
|
7230
|
+
return slideTitle === "Slidev - Slidev" ? "Slidev" : slideTitle;
|
|
7233
7231
|
}
|
|
7234
7232
|
function escapeHtml(unsafe) {
|
|
7235
7233
|
return JSON.stringify(
|
|
@@ -7245,16 +7243,16 @@ async function getIndexHtml({ entry, clientRoot, roots, data }) {
|
|
|
7245
7243
|
`<meta name="slidev:version" content="${version}">`,
|
|
7246
7244
|
`<meta charset="slidev:entry" content="${slash(entry)}">`,
|
|
7247
7245
|
`<link rel="icon" href="${data.config.favicon}">`,
|
|
7248
|
-
`<title>${
|
|
7246
|
+
`<title>${getSlideTitle(data)}</title>`,
|
|
7249
7247
|
info && `<meta name="description" content=${escapeHtml(info)}>`,
|
|
7250
7248
|
author && `<meta name="author" content=${escapeHtml(author)}>`,
|
|
7251
7249
|
keywords && `<meta name="keywords" content=${escapeHtml(Array.isArray(keywords) ? keywords.join(", ") : keywords)}>`
|
|
7252
7250
|
].filter(Boolean).join("\n");
|
|
7253
7251
|
for (const root of roots) {
|
|
7254
|
-
const
|
|
7255
|
-
if (!existsSync(
|
|
7252
|
+
const path4 = join(root, "index.html");
|
|
7253
|
+
if (!existsSync(path4))
|
|
7256
7254
|
continue;
|
|
7257
|
-
const index = await fs.readFile(
|
|
7255
|
+
const index = await fs.readFile(path4, "utf-8");
|
|
7258
7256
|
head += `
|
|
7259
7257
|
${(index.match(/<head>([\s\S]*?)<\/head>/i)?.[1] || "").trim()}`;
|
|
7260
7258
|
body += `
|
|
@@ -7289,8 +7287,8 @@ async function mergeViteConfigs({ roots, entry }, viteConfig, config, command) {
|
|
|
7289
7287
|
}
|
|
7290
7288
|
|
|
7291
7289
|
// node/vite/index.ts
|
|
7292
|
-
import { join as
|
|
7293
|
-
import { existsSync as
|
|
7290
|
+
import { join as join9 } from "node:path";
|
|
7291
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
7294
7292
|
import process2 from "node:process";
|
|
7295
7293
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7296
7294
|
import Icons from "unplugin-icons/vite";
|
|
@@ -7320,11 +7318,11 @@ async function loadDrawings(options) {
|
|
|
7320
7318
|
suppressErrors: true
|
|
7321
7319
|
});
|
|
7322
7320
|
const obj = {};
|
|
7323
|
-
await Promise.all(files.map(async (
|
|
7324
|
-
const num = +basename(
|
|
7321
|
+
await Promise.all(files.map(async (path4) => {
|
|
7322
|
+
const num = +basename(path4, ".svg");
|
|
7325
7323
|
if (Number.isNaN(num))
|
|
7326
7324
|
return;
|
|
7327
|
-
const content = await fs2.readFile(
|
|
7325
|
+
const content = await fs2.readFile(path4, "utf8");
|
|
7328
7326
|
const lines = content.split(/\n/g);
|
|
7329
7327
|
obj[num.toString()] = lines.slice(1, -1).join("\n");
|
|
7330
7328
|
}));
|
|
@@ -7552,6 +7550,7 @@ function getDefine(options) {
|
|
|
7552
7550
|
__SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
|
|
7553
7551
|
__SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
|
|
7554
7552
|
__SLIDEV_FEATURE_PRESENTER__: JSON.stringify(options.data.config.presenter === true || options.data.config.presenter === options.mode),
|
|
7553
|
+
__SLIDEV_FEATURE_PRINT__: JSON.stringify(options.mode === "export" || options.mode === "build" && [true, "true", "auto"].includes(options.data.config.download)),
|
|
7555
7554
|
__SLIDEV_HAS_SERVER__: options.mode !== "build" ? "true" : "false"
|
|
7556
7555
|
};
|
|
7557
7556
|
}
|
|
@@ -7565,23 +7564,16 @@ import * as parser from "@slidev/parser/fs";
|
|
|
7565
7564
|
import equal from "fast-deep-equal";
|
|
7566
7565
|
|
|
7567
7566
|
// node/virtual/configs.ts
|
|
7568
|
-
import { isString
|
|
7567
|
+
import { isString } from "@antfu/utils";
|
|
7569
7568
|
var templateConfigs = {
|
|
7570
7569
|
id: "/@slidev/configs",
|
|
7571
7570
|
getContent: async ({ data, remote }, { md }) => {
|
|
7572
|
-
function getTitle2() {
|
|
7573
|
-
if (isString2(data.config.title)) {
|
|
7574
|
-
const tokens = md.parseInline(data.config.title, {});
|
|
7575
|
-
return stringifyMarkdownTokens(tokens);
|
|
7576
|
-
}
|
|
7577
|
-
return data.config.title;
|
|
7578
|
-
}
|
|
7579
7571
|
const config = {
|
|
7580
7572
|
...data.config,
|
|
7581
7573
|
remote,
|
|
7582
|
-
|
|
7574
|
+
slidesTitle: getSlideTitle(data)
|
|
7583
7575
|
};
|
|
7584
|
-
if (
|
|
7576
|
+
if (isString(config.info))
|
|
7585
7577
|
config.info = md.render(config.info);
|
|
7586
7578
|
return `export default ${JSON.stringify(config)}`;
|
|
7587
7579
|
}
|
|
@@ -7612,65 +7604,57 @@ console.warn('/@slidev/titles.md is deprecated, import from #slidev/title-render
|
|
|
7612
7604
|
}
|
|
7613
7605
|
};
|
|
7614
7606
|
|
|
7615
|
-
// node/virtual/global-
|
|
7607
|
+
// node/virtual/global-layers.ts
|
|
7616
7608
|
import { existsSync as existsSync2 } from "node:fs";
|
|
7617
7609
|
import { join as join4 } from "node:path";
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
const
|
|
7638
|
-
|
|
7639
|
-
${
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
};
|
|
7649
|
-
}
|
|
7610
|
+
var templateGlobalLayers = {
|
|
7611
|
+
id: `/@slidev/global-layers`,
|
|
7612
|
+
getContent({ roots }) {
|
|
7613
|
+
const imports = [];
|
|
7614
|
+
let n = 0;
|
|
7615
|
+
function getComponent(names) {
|
|
7616
|
+
const components = roots.flatMap((root) => names.map((name) => join4(root, name))).filter((i) => existsSync2(i));
|
|
7617
|
+
imports.push(components.map((path4, i) => `import __n${n}_${i} from '${toAtFS(path4)}'`).join("\n"));
|
|
7618
|
+
const render = components.map((_, i) => `h(__n${n}_${i})`).join(",");
|
|
7619
|
+
n++;
|
|
7620
|
+
return `{ render: () => [${render}] }`;
|
|
7621
|
+
}
|
|
7622
|
+
const globalTop = getComponent(["global.vue", "global-top.vue", "GlobalTop.vue"]);
|
|
7623
|
+
const globalBottom = getComponent(["global-bottom.vue", "GlobalBottom.vue"]);
|
|
7624
|
+
const slideTop = getComponent(["slide-top.vue", "SlideTop.vue"]);
|
|
7625
|
+
const slideBottom = getComponent(["slide-bottom.vue", "SlideBottom.vue"]);
|
|
7626
|
+
return [
|
|
7627
|
+
imports.join("\n"),
|
|
7628
|
+
`import { h } from 'vue'`,
|
|
7629
|
+
`export const GlobalTop = ${globalTop}`,
|
|
7630
|
+
`export const GlobalBottom = ${globalBottom}`,
|
|
7631
|
+
`export const SlideTop = ${slideTop}`,
|
|
7632
|
+
`export const SlideBottom = ${slideBottom}`
|
|
7633
|
+
].join("\n");
|
|
7634
|
+
}
|
|
7635
|
+
};
|
|
7636
|
+
|
|
7637
|
+
// node/virtual/nav-controls.ts
|
|
7638
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
7639
|
+
import { join as join5 } from "node:path";
|
|
7650
7640
|
var templateNavControls = {
|
|
7651
7641
|
id: "/@slidev/custom-nav-controls",
|
|
7652
7642
|
getContent({ roots }) {
|
|
7653
7643
|
const components = roots.flatMap((root) => {
|
|
7654
7644
|
return [
|
|
7655
|
-
|
|
7656
|
-
|
|
7645
|
+
join5(root, "custom-nav-controls.vue"),
|
|
7646
|
+
join5(root, "CustomNavControls.vue")
|
|
7657
7647
|
];
|
|
7658
|
-
}).filter((i) =>
|
|
7648
|
+
}).filter((i) => existsSync3(i));
|
|
7659
7649
|
const imports = components.map((i, idx) => `import __n${idx} from '${toAtFS(i)}'`).join("\n");
|
|
7660
7650
|
const render = components.map((i, idx) => `h(__n${idx})`).join(",");
|
|
7661
|
-
return
|
|
7662
|
-
${imports}
|
|
7651
|
+
return `${imports}
|
|
7663
7652
|
import { h } from 'vue'
|
|
7664
7653
|
export default {
|
|
7665
|
-
render() {
|
|
7666
|
-
|
|
7667
|
-
}
|
|
7668
|
-
}
|
|
7669
|
-
`;
|
|
7654
|
+
render: () => [${render}],
|
|
7655
|
+
}`;
|
|
7670
7656
|
}
|
|
7671
7657
|
};
|
|
7672
|
-
var templateGlobalTop = createGlobalComponentTemplate("top");
|
|
7673
|
-
var templateGlobalBottom = createGlobalComponentTemplate("bottom");
|
|
7674
7658
|
|
|
7675
7659
|
// node/virtual/layouts.ts
|
|
7676
7660
|
import { objectMap } from "@antfu/utils";
|
|
@@ -7724,7 +7708,7 @@ var templateMonacoRunDeps = {
|
|
|
7724
7708
|
|
|
7725
7709
|
// node/virtual/monaco-types.ts
|
|
7726
7710
|
import { builtinModules } from "node:module";
|
|
7727
|
-
import { join as
|
|
7711
|
+
import { join as join6, resolve as resolve3 } from "node:path";
|
|
7728
7712
|
import fg2 from "fast-glob";
|
|
7729
7713
|
import { uniq as uniq3 } from "@antfu/utils";
|
|
7730
7714
|
var templateMonacoTypes = {
|
|
@@ -7732,7 +7716,7 @@ var templateMonacoTypes = {
|
|
|
7732
7716
|
getContent: async ({ userRoot, data }) => {
|
|
7733
7717
|
if (!data.features.monaco)
|
|
7734
7718
|
return "";
|
|
7735
|
-
const typesRoot =
|
|
7719
|
+
const typesRoot = join6(userRoot, "snippets");
|
|
7736
7720
|
const files = await fg2(["**/*.ts", "**/*.mts", "**/*.cts"], { cwd: typesRoot });
|
|
7737
7721
|
let result = 'import { addFile } from "@slidev/client/setup/monaco.ts"\n';
|
|
7738
7722
|
for (const file of files) {
|
|
@@ -7767,19 +7751,19 @@ var templateMonacoTypes = {
|
|
|
7767
7751
|
};
|
|
7768
7752
|
|
|
7769
7753
|
// node/virtual/setups.ts
|
|
7770
|
-
import { existsSync as
|
|
7771
|
-
import { join as
|
|
7754
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
7755
|
+
import { join as join7 } from "node:path";
|
|
7772
7756
|
function createSetupTemplate(name) {
|
|
7773
7757
|
return {
|
|
7774
7758
|
id: `/@slidev/setups/${name}`,
|
|
7775
7759
|
getContent({ roots }) {
|
|
7776
7760
|
const setups = roots.flatMap((i) => {
|
|
7777
|
-
const
|
|
7778
|
-
return [".ts", ".mts", ".js", ".mjs"].map((ext) =>
|
|
7779
|
-
}).filter((i) =>
|
|
7761
|
+
const path4 = join7(i, "setup", name);
|
|
7762
|
+
return [".ts", ".mts", ".js", ".mjs"].map((ext) => path4 + ext);
|
|
7763
|
+
}).filter((i) => existsSync4(i));
|
|
7780
7764
|
const imports = [];
|
|
7781
|
-
setups.forEach((
|
|
7782
|
-
imports.push(`import __n${idx} from '${toAtFS(
|
|
7765
|
+
setups.forEach((path4, idx) => {
|
|
7766
|
+
imports.push(`import __n${idx} from '${toAtFS(path4)}'`);
|
|
7783
7767
|
});
|
|
7784
7768
|
imports.push(`export default [${setups.map((_, idx) => `__n${idx}`).join(",")}]`);
|
|
7785
7769
|
return imports.join("\n");
|
|
@@ -7798,9 +7782,9 @@ async function loadShikiSetups(clientRoot, roots) {
|
|
|
7798
7782
|
"shiki.ts",
|
|
7799
7783
|
{
|
|
7800
7784
|
/** @deprecated */
|
|
7801
|
-
async loadTheme(
|
|
7785
|
+
async loadTheme(path4) {
|
|
7802
7786
|
console.warn("[slidev] `loadTheme` in `setup/shiki.ts` is deprecated. Pass directly the theme name it's supported by Shiki. For custom themes, load it manually via `JSON.parse(fs.readFileSync(path, 'utf-8'))` and pass the raw JSON object instead.");
|
|
7803
|
-
return JSON.parse(await fs3.readFile(
|
|
7787
|
+
return JSON.parse(await fs3.readFile(path4, "utf-8"));
|
|
7804
7788
|
}
|
|
7805
7789
|
},
|
|
7806
7790
|
{},
|
|
@@ -7913,13 +7897,13 @@ ${slides.join(",\n")}
|
|
|
7913
7897
|
};
|
|
7914
7898
|
|
|
7915
7899
|
// node/virtual/styles.ts
|
|
7916
|
-
import { join as
|
|
7917
|
-
import { existsSync as
|
|
7900
|
+
import { join as join8 } from "node:path";
|
|
7901
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
7918
7902
|
var templateStyle = {
|
|
7919
7903
|
id: "/@slidev/styles",
|
|
7920
7904
|
getContent: async ({ data, clientRoot, roots }) => {
|
|
7921
7905
|
function resolveUrlOfClient(name) {
|
|
7922
|
-
return toAtFS(
|
|
7906
|
+
return toAtFS(join8(clientRoot, name));
|
|
7923
7907
|
}
|
|
7924
7908
|
const imports = [
|
|
7925
7909
|
`import "${resolveUrlOfClient("styles/vars.css")}"`,
|
|
@@ -7930,14 +7914,14 @@ var templateStyle = {
|
|
|
7930
7914
|
];
|
|
7931
7915
|
for (const root of roots) {
|
|
7932
7916
|
const styles = [
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7917
|
+
join8(root, "styles", "index.ts"),
|
|
7918
|
+
join8(root, "styles", "index.js"),
|
|
7919
|
+
join8(root, "styles", "index.css"),
|
|
7920
|
+
join8(root, "styles.css"),
|
|
7921
|
+
join8(root, "style.css")
|
|
7938
7922
|
];
|
|
7939
7923
|
for (const style of styles) {
|
|
7940
|
-
if (
|
|
7924
|
+
if (existsSync5(style)) {
|
|
7941
7925
|
imports.push(`import "${toAtFS(style)}"`);
|
|
7942
7926
|
continue;
|
|
7943
7927
|
}
|
|
@@ -7999,8 +7983,7 @@ var templates = [
|
|
|
7999
7983
|
templateMonacoRunDeps,
|
|
8000
7984
|
templateConfigs,
|
|
8001
7985
|
templateStyle,
|
|
8002
|
-
|
|
8003
|
-
templateGlobalTop,
|
|
7986
|
+
templateGlobalLayers,
|
|
8004
7987
|
templateNavControls,
|
|
8005
7988
|
templateSlides,
|
|
8006
7989
|
templateLayouts,
|
|
@@ -8866,11 +8849,11 @@ function markdownItVDrag(md, markdownTransformMap) {
|
|
|
8866
8849
|
return `[${toOriginalPos(start)},${toOriginalPos(end)},${idx}]`;
|
|
8867
8850
|
}
|
|
8868
8851
|
return _parse.call(this, src, env).map((token) => {
|
|
8869
|
-
if (token.type
|
|
8852
|
+
if (!["html_block", "html_inline"].includes(token.type) || !token.content.includes("v-drag") || visited.has(token))
|
|
8870
8853
|
return token;
|
|
8871
8854
|
token.content = token.content.replace(
|
|
8872
|
-
/<v
|
|
8873
|
-
(_, space, idx) =>
|
|
8855
|
+
/<(v-?drag-?\w*)([\s>])/gi,
|
|
8856
|
+
(_, tag, space, idx) => `<${tag} :markdownSource="${toMarkdownSource(token.map, idx)}"${space}`
|
|
8874
8857
|
).replace(
|
|
8875
8858
|
/(?<![</\w])v-drag(=".*?")?/g,
|
|
8876
8859
|
(_, value, idx) => `v-drag${value ?? ""} :markdownSource="[${token.map[0]},${token.map[1]},${idx}]"`
|
|
@@ -8906,7 +8889,10 @@ ${code}
|
|
|
8906
8889
|
import { codeToKeyedTokens } from "shiki-magic-move/core";
|
|
8907
8890
|
import lz from "lz-string";
|
|
8908
8891
|
var reMagicMoveBlock = /^````(?:md|markdown) magic-move(?: *(\{[^}]*\})?([^\n]*))?\n([\s\S]+?)^````$/gm;
|
|
8909
|
-
function
|
|
8892
|
+
function parseLineNumbersOption(options) {
|
|
8893
|
+
return /lines: *true/.test(options) ? true : /lines: *false/.test(options) ? false : void 0;
|
|
8894
|
+
}
|
|
8895
|
+
function transformMagicMove(shiki, shikiOptions, configLineNumbers) {
|
|
8910
8896
|
return (ctx) => {
|
|
8911
8897
|
ctx.s.replace(
|
|
8912
8898
|
reMagicMoveBlock,
|
|
@@ -8916,13 +8902,15 @@ function transformMagicMove(shiki, shikiOptions) {
|
|
|
8916
8902
|
const matches = Array.from(body.matchAll(reCodeBlock));
|
|
8917
8903
|
if (!matches.length)
|
|
8918
8904
|
throw new Error("Magic Move block must contain at least one code block");
|
|
8905
|
+
const defaultLineNumbers = parseLineNumbersOption(options) ?? configLineNumbers;
|
|
8919
8906
|
const ranges = matches.map((i) => normalizeRangeStr(i[2]));
|
|
8920
|
-
const steps = matches.map(
|
|
8921
|
-
|
|
8907
|
+
const steps = matches.map((i) => {
|
|
8908
|
+
const lineNumbers = parseLineNumbersOption(i[3]) ?? defaultLineNumbers;
|
|
8909
|
+
return codeToKeyedTokens(shiki, i[5].trimEnd(), {
|
|
8922
8910
|
...shikiOptions,
|
|
8923
8911
|
lang: i[1]
|
|
8924
|
-
})
|
|
8925
|
-
);
|
|
8912
|
+
}, lineNumbers);
|
|
8913
|
+
});
|
|
8926
8914
|
const compressed = lz.compressToBase64(JSON.stringify(steps));
|
|
8927
8915
|
return `<ShikiMagicMove v-bind="${options}" steps-lz="${compressed}" :step-ranges='${JSON.stringify(ranges)}' />`;
|
|
8928
8916
|
}
|
|
@@ -8959,9 +8947,45 @@ function transformPlantUml(ctx) {
|
|
|
8959
8947
|
}
|
|
8960
8948
|
|
|
8961
8949
|
// node/syntax/transform/snippet.ts
|
|
8962
|
-
import
|
|
8963
|
-
import
|
|
8950
|
+
import path3 from "node:path";
|
|
8951
|
+
import lz3 from "lz-string";
|
|
8952
|
+
import fs5 from "fs-extra";
|
|
8964
8953
|
import { slash as slash3 } from "@antfu/utils";
|
|
8954
|
+
|
|
8955
|
+
// node/vite/monacoWrite.ts
|
|
8956
|
+
import fs4 from "node:fs/promises";
|
|
8957
|
+
import path2 from "node:path";
|
|
8958
|
+
var monacoWriterWhitelist = /* @__PURE__ */ new Set();
|
|
8959
|
+
function createMonacoWriter({ userRoot }) {
|
|
8960
|
+
return {
|
|
8961
|
+
name: "slidev:monaco-write",
|
|
8962
|
+
apply: "serve",
|
|
8963
|
+
configureServer(server) {
|
|
8964
|
+
server.ws.on("connection", (socket) => {
|
|
8965
|
+
socket.on("message", async (data) => {
|
|
8966
|
+
let json;
|
|
8967
|
+
try {
|
|
8968
|
+
json = JSON.parse(data.toString());
|
|
8969
|
+
} catch (e) {
|
|
8970
|
+
return;
|
|
8971
|
+
}
|
|
8972
|
+
if (json.type === "custom" && json.event === "slidev:monaco-write") {
|
|
8973
|
+
const { file, content } = json.data;
|
|
8974
|
+
if (!monacoWriterWhitelist.has(file)) {
|
|
8975
|
+
console.error(`[Slidev] Unauthorized file write: ${file}`);
|
|
8976
|
+
return;
|
|
8977
|
+
}
|
|
8978
|
+
const filepath = path2.join(userRoot, file);
|
|
8979
|
+
console.log("[Slidev] Writing file:", filepath);
|
|
8980
|
+
await fs4.writeFile(filepath, content, "utf-8");
|
|
8981
|
+
}
|
|
8982
|
+
});
|
|
8983
|
+
});
|
|
8984
|
+
}
|
|
8985
|
+
};
|
|
8986
|
+
}
|
|
8987
|
+
|
|
8988
|
+
// node/syntax/transform/snippet.ts
|
|
8965
8989
|
function dedent(text) {
|
|
8966
8990
|
const lines = text.split("\n");
|
|
8967
8991
|
const minIndentLength = lines.reduce((acc, line) => {
|
|
@@ -9020,21 +9044,20 @@ function transformSnippet(ctx) {
|
|
|
9020
9044
|
return;
|
|
9021
9045
|
const data = options.data;
|
|
9022
9046
|
const slideInfo = data.slides[+slideId - 1];
|
|
9023
|
-
const dir =
|
|
9047
|
+
const dir = path3.dirname(slideInfo.source?.filepath ?? options.entry ?? options.userRoot);
|
|
9024
9048
|
ctx.s.replace(
|
|
9025
9049
|
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
9026
9050
|
/^<<<\s*(\S.*?)(#[\w-]+)?\s*(?:\s(\S+?))?\s*(\{.*)?$/gm,
|
|
9027
9051
|
(full, filepath = "", regionName = "", lang = "", meta = "") => {
|
|
9028
|
-
const firstLine = `\`\`\`${lang || path2.extname(filepath).slice(1)} ${meta}`;
|
|
9029
9052
|
const src = slash3(
|
|
9030
|
-
/^@\//.test(filepath) ?
|
|
9053
|
+
/^@\//.test(filepath) ? path3.resolve(options.userRoot, filepath.slice(2)) : path3.resolve(dir, filepath)
|
|
9031
9054
|
);
|
|
9032
9055
|
data.watchFiles.push(src);
|
|
9033
|
-
const isAFile =
|
|
9034
|
-
if (!
|
|
9056
|
+
const isAFile = fs5.statSync(src).isFile();
|
|
9057
|
+
if (!fs5.existsSync(src) || !isAFile) {
|
|
9035
9058
|
throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
|
|
9036
9059
|
}
|
|
9037
|
-
let content =
|
|
9060
|
+
let content = fs5.readFileSync(src, "utf8");
|
|
9038
9061
|
slideInfo.snippetsUsed ??= {};
|
|
9039
9062
|
slideInfo.snippetsUsed[src] = content;
|
|
9040
9063
|
if (regionName) {
|
|
@@ -9046,7 +9069,17 @@ function transformSnippet(ctx) {
|
|
|
9046
9069
|
);
|
|
9047
9070
|
}
|
|
9048
9071
|
}
|
|
9049
|
-
|
|
9072
|
+
meta = meta.trim();
|
|
9073
|
+
lang = lang.trim();
|
|
9074
|
+
lang = lang || path3.extname(filepath).slice(1);
|
|
9075
|
+
if (meta.match(/^\{monaco-write\}/)) {
|
|
9076
|
+
monacoWriterWhitelist.add(filepath);
|
|
9077
|
+
lang = lang.trim();
|
|
9078
|
+
meta = meta.replace(/^\{monaco-write\}/, "").trim() || "{}";
|
|
9079
|
+
const encoded = lz3.compressToBase64(content);
|
|
9080
|
+
return `<Monaco writable=${JSON.stringify(filepath)} code-lz="${encoded}" lang="${lang}" v-bind="${meta}" />`;
|
|
9081
|
+
}
|
|
9082
|
+
return `\`\`\`${lang} ${meta}
|
|
9050
9083
|
${content}
|
|
9051
9084
|
\`\`\``;
|
|
9052
9085
|
}
|
|
@@ -9101,7 +9134,7 @@ ${css}${end}`;
|
|
|
9101
9134
|
}
|
|
9102
9135
|
|
|
9103
9136
|
// node/syntax/transform/monaco.ts
|
|
9104
|
-
import
|
|
9137
|
+
import lz4 from "lz-string";
|
|
9105
9138
|
function transformMonaco(ctx) {
|
|
9106
9139
|
const enabled = ctx.options.data.config.monaco === true || ctx.options.data.config.monaco === ctx.options.mode;
|
|
9107
9140
|
if (!enabled) {
|
|
@@ -9113,8 +9146,8 @@ function transformMonaco(ctx) {
|
|
|
9113
9146
|
(full, lang = "ts", options = "{}", code, diff) => {
|
|
9114
9147
|
lang = lang.trim();
|
|
9115
9148
|
options = options.trim() || "{}";
|
|
9116
|
-
const encoded =
|
|
9117
|
-
const encodedDiff =
|
|
9149
|
+
const encoded = lz4.compressToBase64(code);
|
|
9150
|
+
const encodedDiff = lz4.compressToBase64(diff);
|
|
9118
9151
|
return `<Monaco code-lz="${encoded}" diff-lz="${encodedDiff}" lang="${lang}" v-bind="${options}" />`;
|
|
9119
9152
|
}
|
|
9120
9153
|
);
|
|
@@ -9123,7 +9156,7 @@ function transformMonaco(ctx) {
|
|
|
9123
9156
|
(full, lang = "ts", options = "{}", code) => {
|
|
9124
9157
|
lang = lang.trim();
|
|
9125
9158
|
options = options.trim() || "{}";
|
|
9126
|
-
const encoded =
|
|
9159
|
+
const encoded = lz4.compressToBase64(code);
|
|
9127
9160
|
return `<Monaco code-lz="${encoded}" lang="${lang}" v-bind="${options}" />`;
|
|
9128
9161
|
}
|
|
9129
9162
|
);
|
|
@@ -9132,7 +9165,7 @@ function transformMonaco(ctx) {
|
|
|
9132
9165
|
(full, lang = "ts", options = "{}", code) => {
|
|
9133
9166
|
lang = lang.trim();
|
|
9134
9167
|
options = options.trim() || "{}";
|
|
9135
|
-
const encoded =
|
|
9168
|
+
const encoded = lz4.compressToBase64(code);
|
|
9136
9169
|
return `<Monaco runnable code-lz="${encoded}" lang="${lang}" v-bind="${options}" />`;
|
|
9137
9170
|
}
|
|
9138
9171
|
);
|
|
@@ -9275,7 +9308,7 @@ function MarkdownItEscapeInlineCode(md) {
|
|
|
9275
9308
|
function applyMarkdownTransform(ctx, shiki, shikiOptions) {
|
|
9276
9309
|
const transformers = [
|
|
9277
9310
|
transformSnippet,
|
|
9278
|
-
ctx.options.data.config.highlighter ? transformMagicMove(shiki, shikiOptions) : void 0,
|
|
9311
|
+
ctx.options.data.config.highlighter ? transformMagicMove(shiki, shikiOptions, ctx.options.data.config.lineNumbers) : void 0,
|
|
9279
9312
|
transformMermaid,
|
|
9280
9313
|
transformPlantUml,
|
|
9281
9314
|
transformMonaco,
|
|
@@ -9317,7 +9350,7 @@ function createVueCompilerFlagsPlugin(options) {
|
|
|
9317
9350
|
}
|
|
9318
9351
|
|
|
9319
9352
|
// node/vite/monacoTypes.ts
|
|
9320
|
-
import
|
|
9353
|
+
import fs6 from "node:fs/promises";
|
|
9321
9354
|
import { dirname as dirname2, resolve as resolve4 } from "node:path";
|
|
9322
9355
|
import { slash as slash5 } from "@antfu/utils";
|
|
9323
9356
|
import fg4 from "fast-glob";
|
|
@@ -9343,7 +9376,7 @@ function createMonacoTypesLoader({ userRoot }) {
|
|
|
9343
9376
|
if (!pkgJsonPath)
|
|
9344
9377
|
throw new Error(`Package "${pkg}" not found in "${importer}"`);
|
|
9345
9378
|
const root = dirname2(pkgJsonPath);
|
|
9346
|
-
const pkgJson = JSON.parse(await
|
|
9379
|
+
const pkgJson = JSON.parse(await fs6.readFile(pkgJsonPath, "utf-8"));
|
|
9347
9380
|
const deps = pkgJson.dependencies ?? {};
|
|
9348
9381
|
return [
|
|
9349
9382
|
`import "/@slidev-monaco-types/load?root=${slash5(root)}&name=${pkgJson.name}"`,
|
|
@@ -9451,19 +9484,20 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
9451
9484
|
data: { config }
|
|
9452
9485
|
} = options;
|
|
9453
9486
|
const drawingData = await loadDrawings(options);
|
|
9454
|
-
const publicRoots = [...themeRoots, ...addonRoots].map((i) =>
|
|
9487
|
+
const publicRoots = [...themeRoots, ...addonRoots].map((i) => join9(i, "public")).filter(existsSync6);
|
|
9455
9488
|
const plugins = [
|
|
9456
9489
|
createMarkdownPlugin(options, pluginOptions),
|
|
9457
9490
|
createVuePlugin(options, pluginOptions),
|
|
9458
9491
|
createSlidesLoader(options, pluginOptions, serverOptions),
|
|
9492
|
+
createMonacoWriter(options),
|
|
9459
9493
|
Components({
|
|
9460
9494
|
extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
|
|
9461
9495
|
dirs: [
|
|
9462
|
-
|
|
9463
|
-
...roots.map((i) =>
|
|
9496
|
+
join9(options.clientRoot, "builtin"),
|
|
9497
|
+
...roots.map((i) => join9(i, "components")),
|
|
9464
9498
|
"src/components",
|
|
9465
9499
|
"components",
|
|
9466
|
-
|
|
9500
|
+
join9(process2.cwd(), "components")
|
|
9467
9501
|
],
|
|
9468
9502
|
include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
|
|
9469
9503
|
exclude: [],
|
package/dist/cli.mjs
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
resolveAddons,
|
|
6
6
|
resolveOptions,
|
|
7
7
|
resolveTheme
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-UFFECLAV.mjs";
|
|
9
9
|
import {
|
|
10
10
|
version
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4Y3EWPMH.mjs";
|
|
12
12
|
import {
|
|
13
13
|
loadSetups
|
|
14
14
|
} from "./chunk-LOUKLO2C.mjs";
|
|
@@ -328,7 +328,7 @@ cli.command(
|
|
|
328
328
|
}).strict().help(),
|
|
329
329
|
async (args) => {
|
|
330
330
|
const { entry, theme, base, download, out, inspect } = args;
|
|
331
|
-
const { build } = await import("./build-
|
|
331
|
+
const { build } = await import("./build-F3OEADD3.mjs");
|
|
332
332
|
for (const entryFile of entry) {
|
|
333
333
|
const options = await resolveOptions({ entry: entryFile, theme, inspect }, "build");
|
|
334
334
|
if (download && !options.data.config.download)
|
package/dist/index.mjs
CHANGED
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
createServer,
|
|
3
3
|
parser,
|
|
4
4
|
resolveOptions
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UFFECLAV.mjs";
|
|
6
6
|
import {
|
|
7
7
|
ViteSlidevPlugin
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4Y3EWPMH.mjs";
|
|
9
9
|
import "./chunk-LOUKLO2C.mjs";
|
|
10
10
|
import "./chunk-RG2EEPCO.mjs";
|
|
11
11
|
import "./chunk-BXO7ZPPU.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/cli",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.6",
|
|
4
4
|
"description": "Presentation slides for developers",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@iconify-json/ph": "^1.1.13",
|
|
49
49
|
"@iconify-json/svg-spinners": "^1.1.2",
|
|
50
50
|
"@lillallol/outline-pdf": "^4.0.0",
|
|
51
|
-
"@shikijs/markdown-it": "^1.6.
|
|
52
|
-
"@shikijs/twoslash": "^1.6.
|
|
53
|
-
"@shikijs/vitepress-twoslash": "^1.6.
|
|
51
|
+
"@shikijs/markdown-it": "^1.6.1",
|
|
52
|
+
"@shikijs/twoslash": "^1.6.1",
|
|
53
|
+
"@shikijs/vitepress-twoslash": "^1.6.1",
|
|
54
54
|
"@unocss/extractor-mdc": "^0.60.3",
|
|
55
55
|
"@unocss/reset": "^0.60.3",
|
|
56
56
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"resolve-from": "^5.0.0",
|
|
91
91
|
"resolve-global": "^2.0.0",
|
|
92
92
|
"semver": "^7.6.2",
|
|
93
|
-
"shiki": "^1.6.
|
|
93
|
+
"shiki": "^1.6.1",
|
|
94
94
|
"shiki-magic-move": "^0.4.2",
|
|
95
95
|
"sirv": "^2.0.4",
|
|
96
96
|
"source-map-js": "^1.2.0",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"unplugin-vue-markdown": "^0.26.2",
|
|
102
102
|
"untun": "^0.1.3",
|
|
103
103
|
"uqr": "^0.1.2",
|
|
104
|
-
"vite": "^5.2.
|
|
104
|
+
"vite": "^5.2.12",
|
|
105
105
|
"vite-plugin-inspect": "^0.8.4",
|
|
106
106
|
"vite-plugin-remote-assets": "^0.4.1",
|
|
107
107
|
"vite-plugin-static-copy": "^1.0.5",
|
|
@@ -109,9 +109,9 @@
|
|
|
109
109
|
"vitefu": "^0.2.5",
|
|
110
110
|
"vue": "^3.4.27",
|
|
111
111
|
"yargs": "^17.7.2",
|
|
112
|
-
"@slidev/client": "0.49.
|
|
113
|
-
"@slidev/types": "0.49.
|
|
114
|
-
"@slidev/parser": "0.49.
|
|
112
|
+
"@slidev/client": "0.49.6",
|
|
113
|
+
"@slidev/types": "0.49.6",
|
|
114
|
+
"@slidev/parser": "0.49.6"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
117
|
"@hedgedoc/markdown-it-plugins": "^2.1.4",
|