@slidev/cli 0.34.0 → 0.34.3

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.
@@ -0,0 +1,743 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+
4
+
5
+ var _chunk4MU7RGP4js = require('./chunk-4MU7RGP4.js');
6
+
7
+
8
+
9
+
10
+ var _chunkSQLX75IOjs = require('./chunk-SQLX75IO.js');
11
+
12
+ // node/build.ts
13
+ _chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
14
+ var _path = require('path');
15
+ var _http = require('http'); var _http2 = _interopRequireDefault(_http);
16
+ var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
17
+ var _vite = require('vite');
18
+ var _connect = require('connect'); var _connect2 = _interopRequireDefault(_connect);
19
+
20
+ // ../../node_modules/.pnpm/sirv@2.0.2/node_modules/sirv/build.mjs
21
+ _chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
22
+ var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
23
+
24
+
25
+ // ../../node_modules/.pnpm/totalist@3.0.0/node_modules/totalist/sync/index.mjs
26
+ _chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
27
+
28
+
29
+ function totalist(dir, callback, pre = "") {
30
+ dir = _path.resolve.call(void 0, ".", dir);
31
+ let arr = _fs.readdirSync.call(void 0, dir);
32
+ let i = 0, abs, stats;
33
+ for (; i < arr.length; i++) {
34
+ abs = _path.join.call(void 0, dir, arr[i]);
35
+ stats = _fs.statSync.call(void 0, abs);
36
+ stats.isDirectory() ? totalist(abs, callback, _path.join.call(void 0, pre, arr[i])) : callback(_path.join.call(void 0, pre, arr[i]), abs, stats);
37
+ }
38
+ }
39
+
40
+ // ../../node_modules/.pnpm/@polka+url@1.0.0-next.21/node_modules/@polka/url/build.mjs
41
+ _chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
42
+ var _querystring = require('querystring'); var qs = _interopRequireWildcard(_querystring);
43
+ function parse2(req) {
44
+ let raw = req.url;
45
+ if (raw == null)
46
+ return;
47
+ let prev = req._parsedUrl;
48
+ if (prev && prev.raw === raw)
49
+ return prev;
50
+ let pathname = raw, search = "", query;
51
+ if (raw.length > 1) {
52
+ let idx = raw.indexOf("?", 1);
53
+ if (idx !== -1) {
54
+ search = raw.substring(idx);
55
+ pathname = raw.substring(0, idx);
56
+ if (search.length > 1) {
57
+ query = qs.parse(search.substring(1));
58
+ }
59
+ }
60
+ }
61
+ return req._parsedUrl = { pathname, search, query, raw };
62
+ }
63
+
64
+ // ../../node_modules/.pnpm/mrmime@1.0.0/node_modules/mrmime/index.mjs
65
+ _chunkSQLX75IOjs.init_cjs_shims.call(void 0, );
66
+ var mimes = {
67
+ "ez": "application/andrew-inset",
68
+ "aw": "application/applixware",
69
+ "atom": "application/atom+xml",
70
+ "atomcat": "application/atomcat+xml",
71
+ "atomdeleted": "application/atomdeleted+xml",
72
+ "atomsvc": "application/atomsvc+xml",
73
+ "dwd": "application/atsc-dwd+xml",
74
+ "held": "application/atsc-held+xml",
75
+ "rsat": "application/atsc-rsat+xml",
76
+ "bdoc": "application/bdoc",
77
+ "xcs": "application/calendar+xml",
78
+ "ccxml": "application/ccxml+xml",
79
+ "cdfx": "application/cdfx+xml",
80
+ "cdmia": "application/cdmi-capability",
81
+ "cdmic": "application/cdmi-container",
82
+ "cdmid": "application/cdmi-domain",
83
+ "cdmio": "application/cdmi-object",
84
+ "cdmiq": "application/cdmi-queue",
85
+ "cu": "application/cu-seeme",
86
+ "mpd": "application/dash+xml",
87
+ "davmount": "application/davmount+xml",
88
+ "dbk": "application/docbook+xml",
89
+ "dssc": "application/dssc+der",
90
+ "xdssc": "application/dssc+xml",
91
+ "es": "application/ecmascript",
92
+ "ecma": "application/ecmascript",
93
+ "emma": "application/emma+xml",
94
+ "emotionml": "application/emotionml+xml",
95
+ "epub": "application/epub+zip",
96
+ "exi": "application/exi",
97
+ "fdt": "application/fdt+xml",
98
+ "pfr": "application/font-tdpfr",
99
+ "geojson": "application/geo+json",
100
+ "gml": "application/gml+xml",
101
+ "gpx": "application/gpx+xml",
102
+ "gxf": "application/gxf",
103
+ "gz": "application/gzip",
104
+ "hjson": "application/hjson",
105
+ "stk": "application/hyperstudio",
106
+ "ink": "application/inkml+xml",
107
+ "inkml": "application/inkml+xml",
108
+ "ipfix": "application/ipfix",
109
+ "its": "application/its+xml",
110
+ "jar": "application/java-archive",
111
+ "war": "application/java-archive",
112
+ "ear": "application/java-archive",
113
+ "ser": "application/java-serialized-object",
114
+ "class": "application/java-vm",
115
+ "js": "application/javascript",
116
+ "mjs": "application/javascript",
117
+ "json": "application/json",
118
+ "map": "application/json",
119
+ "json5": "application/json5",
120
+ "jsonml": "application/jsonml+json",
121
+ "jsonld": "application/ld+json",
122
+ "lgr": "application/lgr+xml",
123
+ "lostxml": "application/lost+xml",
124
+ "hqx": "application/mac-binhex40",
125
+ "cpt": "application/mac-compactpro",
126
+ "mads": "application/mads+xml",
127
+ "webmanifest": "application/manifest+json",
128
+ "mrc": "application/marc",
129
+ "mrcx": "application/marcxml+xml",
130
+ "ma": "application/mathematica",
131
+ "nb": "application/mathematica",
132
+ "mb": "application/mathematica",
133
+ "mathml": "application/mathml+xml",
134
+ "mbox": "application/mbox",
135
+ "mscml": "application/mediaservercontrol+xml",
136
+ "metalink": "application/metalink+xml",
137
+ "meta4": "application/metalink4+xml",
138
+ "mets": "application/mets+xml",
139
+ "maei": "application/mmt-aei+xml",
140
+ "musd": "application/mmt-usd+xml",
141
+ "mods": "application/mods+xml",
142
+ "m21": "application/mp21",
143
+ "mp21": "application/mp21",
144
+ "mp4s": "application/mp4",
145
+ "m4p": "application/mp4",
146
+ "doc": "application/msword",
147
+ "dot": "application/msword",
148
+ "mxf": "application/mxf",
149
+ "nq": "application/n-quads",
150
+ "nt": "application/n-triples",
151
+ "cjs": "application/node",
152
+ "bin": "application/octet-stream",
153
+ "dms": "application/octet-stream",
154
+ "lrf": "application/octet-stream",
155
+ "mar": "application/octet-stream",
156
+ "so": "application/octet-stream",
157
+ "dist": "application/octet-stream",
158
+ "distz": "application/octet-stream",
159
+ "pkg": "application/octet-stream",
160
+ "bpk": "application/octet-stream",
161
+ "dump": "application/octet-stream",
162
+ "elc": "application/octet-stream",
163
+ "deploy": "application/octet-stream",
164
+ "exe": "application/octet-stream",
165
+ "dll": "application/octet-stream",
166
+ "deb": "application/octet-stream",
167
+ "dmg": "application/octet-stream",
168
+ "iso": "application/octet-stream",
169
+ "img": "application/octet-stream",
170
+ "msi": "application/octet-stream",
171
+ "msp": "application/octet-stream",
172
+ "msm": "application/octet-stream",
173
+ "buffer": "application/octet-stream",
174
+ "oda": "application/oda",
175
+ "opf": "application/oebps-package+xml",
176
+ "ogx": "application/ogg",
177
+ "omdoc": "application/omdoc+xml",
178
+ "onetoc": "application/onenote",
179
+ "onetoc2": "application/onenote",
180
+ "onetmp": "application/onenote",
181
+ "onepkg": "application/onenote",
182
+ "oxps": "application/oxps",
183
+ "relo": "application/p2p-overlay+xml",
184
+ "xer": "application/patch-ops-error+xml",
185
+ "pdf": "application/pdf",
186
+ "pgp": "application/pgp-encrypted",
187
+ "asc": "application/pgp-signature",
188
+ "sig": "application/pgp-signature",
189
+ "prf": "application/pics-rules",
190
+ "p10": "application/pkcs10",
191
+ "p7m": "application/pkcs7-mime",
192
+ "p7c": "application/pkcs7-mime",
193
+ "p7s": "application/pkcs7-signature",
194
+ "p8": "application/pkcs8",
195
+ "ac": "application/pkix-attr-cert",
196
+ "cer": "application/pkix-cert",
197
+ "crl": "application/pkix-crl",
198
+ "pkipath": "application/pkix-pkipath",
199
+ "pki": "application/pkixcmp",
200
+ "pls": "application/pls+xml",
201
+ "ai": "application/postscript",
202
+ "eps": "application/postscript",
203
+ "ps": "application/postscript",
204
+ "provx": "application/provenance+xml",
205
+ "cww": "application/prs.cww",
206
+ "pskcxml": "application/pskc+xml",
207
+ "raml": "application/raml+yaml",
208
+ "rdf": "application/rdf+xml",
209
+ "owl": "application/rdf+xml",
210
+ "rif": "application/reginfo+xml",
211
+ "rnc": "application/relax-ng-compact-syntax",
212
+ "rl": "application/resource-lists+xml",
213
+ "rld": "application/resource-lists-diff+xml",
214
+ "rs": "application/rls-services+xml",
215
+ "rapd": "application/route-apd+xml",
216
+ "sls": "application/route-s-tsid+xml",
217
+ "rusd": "application/route-usd+xml",
218
+ "gbr": "application/rpki-ghostbusters",
219
+ "mft": "application/rpki-manifest",
220
+ "roa": "application/rpki-roa",
221
+ "rsd": "application/rsd+xml",
222
+ "rss": "application/rss+xml",
223
+ "rtf": "application/rtf",
224
+ "sbml": "application/sbml+xml",
225
+ "scq": "application/scvp-cv-request",
226
+ "scs": "application/scvp-cv-response",
227
+ "spq": "application/scvp-vp-request",
228
+ "spp": "application/scvp-vp-response",
229
+ "sdp": "application/sdp",
230
+ "senmlx": "application/senml+xml",
231
+ "sensmlx": "application/sensml+xml",
232
+ "setpay": "application/set-payment-initiation",
233
+ "setreg": "application/set-registration-initiation",
234
+ "shf": "application/shf+xml",
235
+ "siv": "application/sieve",
236
+ "sieve": "application/sieve",
237
+ "smi": "application/smil+xml",
238
+ "smil": "application/smil+xml",
239
+ "rq": "application/sparql-query",
240
+ "srx": "application/sparql-results+xml",
241
+ "gram": "application/srgs",
242
+ "grxml": "application/srgs+xml",
243
+ "sru": "application/sru+xml",
244
+ "ssdl": "application/ssdl+xml",
245
+ "ssml": "application/ssml+xml",
246
+ "swidtag": "application/swid+xml",
247
+ "tei": "application/tei+xml",
248
+ "teicorpus": "application/tei+xml",
249
+ "tfi": "application/thraud+xml",
250
+ "tsd": "application/timestamped-data",
251
+ "toml": "application/toml",
252
+ "trig": "application/trig",
253
+ "ttml": "application/ttml+xml",
254
+ "ubj": "application/ubjson",
255
+ "rsheet": "application/urc-ressheet+xml",
256
+ "td": "application/urc-targetdesc+xml",
257
+ "vxml": "application/voicexml+xml",
258
+ "wasm": "application/wasm",
259
+ "wgt": "application/widget",
260
+ "hlp": "application/winhlp",
261
+ "wsdl": "application/wsdl+xml",
262
+ "wspolicy": "application/wspolicy+xml",
263
+ "xaml": "application/xaml+xml",
264
+ "xav": "application/xcap-att+xml",
265
+ "xca": "application/xcap-caps+xml",
266
+ "xdf": "application/xcap-diff+xml",
267
+ "xel": "application/xcap-el+xml",
268
+ "xns": "application/xcap-ns+xml",
269
+ "xenc": "application/xenc+xml",
270
+ "xhtml": "application/xhtml+xml",
271
+ "xht": "application/xhtml+xml",
272
+ "xlf": "application/xliff+xml",
273
+ "xml": "application/xml",
274
+ "xsl": "application/xml",
275
+ "xsd": "application/xml",
276
+ "rng": "application/xml",
277
+ "dtd": "application/xml-dtd",
278
+ "xop": "application/xop+xml",
279
+ "xpl": "application/xproc+xml",
280
+ "xslt": "application/xml",
281
+ "xspf": "application/xspf+xml",
282
+ "mxml": "application/xv+xml",
283
+ "xhvml": "application/xv+xml",
284
+ "xvml": "application/xv+xml",
285
+ "xvm": "application/xv+xml",
286
+ "yang": "application/yang",
287
+ "yin": "application/yin+xml",
288
+ "zip": "application/zip",
289
+ "3gpp": "video/3gpp",
290
+ "adp": "audio/adpcm",
291
+ "amr": "audio/amr",
292
+ "au": "audio/basic",
293
+ "snd": "audio/basic",
294
+ "mid": "audio/midi",
295
+ "midi": "audio/midi",
296
+ "kar": "audio/midi",
297
+ "rmi": "audio/midi",
298
+ "mxmf": "audio/mobile-xmf",
299
+ "mp3": "audio/mpeg",
300
+ "m4a": "audio/mp4",
301
+ "mp4a": "audio/mp4",
302
+ "mpga": "audio/mpeg",
303
+ "mp2": "audio/mpeg",
304
+ "mp2a": "audio/mpeg",
305
+ "m2a": "audio/mpeg",
306
+ "m3a": "audio/mpeg",
307
+ "oga": "audio/ogg",
308
+ "ogg": "audio/ogg",
309
+ "spx": "audio/ogg",
310
+ "opus": "audio/ogg",
311
+ "s3m": "audio/s3m",
312
+ "sil": "audio/silk",
313
+ "wav": "audio/wav",
314
+ "weba": "audio/webm",
315
+ "xm": "audio/xm",
316
+ "ttc": "font/collection",
317
+ "otf": "font/otf",
318
+ "ttf": "font/ttf",
319
+ "woff": "font/woff",
320
+ "woff2": "font/woff2",
321
+ "exr": "image/aces",
322
+ "apng": "image/apng",
323
+ "avif": "image/avif",
324
+ "bmp": "image/bmp",
325
+ "cgm": "image/cgm",
326
+ "drle": "image/dicom-rle",
327
+ "emf": "image/emf",
328
+ "fits": "image/fits",
329
+ "g3": "image/g3fax",
330
+ "gif": "image/gif",
331
+ "heic": "image/heic",
332
+ "heics": "image/heic-sequence",
333
+ "heif": "image/heif",
334
+ "heifs": "image/heif-sequence",
335
+ "hej2": "image/hej2k",
336
+ "hsj2": "image/hsj2",
337
+ "ief": "image/ief",
338
+ "jls": "image/jls",
339
+ "jp2": "image/jp2",
340
+ "jpg2": "image/jp2",
341
+ "jpeg": "image/jpeg",
342
+ "jpg": "image/jpeg",
343
+ "jpe": "image/jpeg",
344
+ "jph": "image/jph",
345
+ "jhc": "image/jphc",
346
+ "jpm": "image/jpm",
347
+ "jpx": "image/jpx",
348
+ "jpf": "image/jpx",
349
+ "jxr": "image/jxr",
350
+ "jxra": "image/jxra",
351
+ "jxrs": "image/jxrs",
352
+ "jxs": "image/jxs",
353
+ "jxsc": "image/jxsc",
354
+ "jxsi": "image/jxsi",
355
+ "jxss": "image/jxss",
356
+ "ktx": "image/ktx",
357
+ "ktx2": "image/ktx2",
358
+ "png": "image/png",
359
+ "btif": "image/prs.btif",
360
+ "pti": "image/prs.pti",
361
+ "sgi": "image/sgi",
362
+ "svg": "image/svg+xml",
363
+ "svgz": "image/svg+xml",
364
+ "t38": "image/t38",
365
+ "tif": "image/tiff",
366
+ "tiff": "image/tiff",
367
+ "tfx": "image/tiff-fx",
368
+ "webp": "image/webp",
369
+ "wmf": "image/wmf",
370
+ "disposition-notification": "message/disposition-notification",
371
+ "u8msg": "message/global",
372
+ "u8dsn": "message/global-delivery-status",
373
+ "u8mdn": "message/global-disposition-notification",
374
+ "u8hdr": "message/global-headers",
375
+ "eml": "message/rfc822",
376
+ "mime": "message/rfc822",
377
+ "3mf": "model/3mf",
378
+ "gltf": "model/gltf+json",
379
+ "glb": "model/gltf-binary",
380
+ "igs": "model/iges",
381
+ "iges": "model/iges",
382
+ "msh": "model/mesh",
383
+ "mesh": "model/mesh",
384
+ "silo": "model/mesh",
385
+ "mtl": "model/mtl",
386
+ "obj": "model/obj",
387
+ "stpz": "model/step+zip",
388
+ "stpxz": "model/step-xml+zip",
389
+ "stl": "model/stl",
390
+ "wrl": "model/vrml",
391
+ "vrml": "model/vrml",
392
+ "x3db": "model/x3d+fastinfoset",
393
+ "x3dbz": "model/x3d+binary",
394
+ "x3dv": "model/x3d-vrml",
395
+ "x3dvz": "model/x3d+vrml",
396
+ "x3d": "model/x3d+xml",
397
+ "x3dz": "model/x3d+xml",
398
+ "appcache": "text/cache-manifest",
399
+ "manifest": "text/cache-manifest",
400
+ "ics": "text/calendar",
401
+ "ifb": "text/calendar",
402
+ "coffee": "text/coffeescript",
403
+ "litcoffee": "text/coffeescript",
404
+ "css": "text/css",
405
+ "csv": "text/csv",
406
+ "html": "text/html",
407
+ "htm": "text/html",
408
+ "shtml": "text/html",
409
+ "jade": "text/jade",
410
+ "jsx": "text/jsx",
411
+ "less": "text/less",
412
+ "markdown": "text/markdown",
413
+ "md": "text/markdown",
414
+ "mml": "text/mathml",
415
+ "mdx": "text/mdx",
416
+ "n3": "text/n3",
417
+ "txt": "text/plain",
418
+ "text": "text/plain",
419
+ "conf": "text/plain",
420
+ "def": "text/plain",
421
+ "list": "text/plain",
422
+ "log": "text/plain",
423
+ "in": "text/plain",
424
+ "ini": "text/plain",
425
+ "dsc": "text/prs.lines.tag",
426
+ "rtx": "text/richtext",
427
+ "sgml": "text/sgml",
428
+ "sgm": "text/sgml",
429
+ "shex": "text/shex",
430
+ "slim": "text/slim",
431
+ "slm": "text/slim",
432
+ "spdx": "text/spdx",
433
+ "stylus": "text/stylus",
434
+ "styl": "text/stylus",
435
+ "tsv": "text/tab-separated-values",
436
+ "t": "text/troff",
437
+ "tr": "text/troff",
438
+ "roff": "text/troff",
439
+ "man": "text/troff",
440
+ "me": "text/troff",
441
+ "ms": "text/troff",
442
+ "ttl": "text/turtle",
443
+ "uri": "text/uri-list",
444
+ "uris": "text/uri-list",
445
+ "urls": "text/uri-list",
446
+ "vcard": "text/vcard",
447
+ "vtt": "text/vtt",
448
+ "yaml": "text/yaml",
449
+ "yml": "text/yaml",
450
+ "3gp": "video/3gpp",
451
+ "3g2": "video/3gpp2",
452
+ "h261": "video/h261",
453
+ "h263": "video/h263",
454
+ "h264": "video/h264",
455
+ "m4s": "video/iso.segment",
456
+ "jpgv": "video/jpeg",
457
+ "jpgm": "image/jpm",
458
+ "mj2": "video/mj2",
459
+ "mjp2": "video/mj2",
460
+ "ts": "video/mp2t",
461
+ "mp4": "video/mp4",
462
+ "mp4v": "video/mp4",
463
+ "mpg4": "video/mp4",
464
+ "mpeg": "video/mpeg",
465
+ "mpg": "video/mpeg",
466
+ "mpe": "video/mpeg",
467
+ "m1v": "video/mpeg",
468
+ "m2v": "video/mpeg",
469
+ "ogv": "video/ogg",
470
+ "qt": "video/quicktime",
471
+ "mov": "video/quicktime",
472
+ "webm": "video/webm"
473
+ };
474
+ function lookup(extn) {
475
+ let tmp = ("" + extn).trim().toLowerCase();
476
+ let idx = tmp.lastIndexOf(".");
477
+ return mimes[!~idx ? tmp : tmp.substring(++idx)];
478
+ }
479
+
480
+ // ../../node_modules/.pnpm/sirv@2.0.2/node_modules/sirv/build.mjs
481
+ var noop = () => {
482
+ };
483
+ function isMatch(uri, arr) {
484
+ for (let i = 0; i < arr.length; i++) {
485
+ if (arr[i].test(uri))
486
+ return true;
487
+ }
488
+ }
489
+ function toAssume(uri, extns) {
490
+ let i = 0, x, len = uri.length - 1;
491
+ if (uri.charCodeAt(len) === 47) {
492
+ uri = uri.substring(0, len);
493
+ }
494
+ let arr = [], tmp = `${uri}/index`;
495
+ for (; i < extns.length; i++) {
496
+ x = extns[i] ? `.${extns[i]}` : "";
497
+ if (uri)
498
+ arr.push(uri + x);
499
+ arr.push(tmp + x);
500
+ }
501
+ return arr;
502
+ }
503
+ function viaCache(cache, uri, extns) {
504
+ let i = 0, data, arr = toAssume(uri, extns);
505
+ for (; i < arr.length; i++) {
506
+ if (data = cache[arr[i]])
507
+ return data;
508
+ }
509
+ }
510
+ function viaLocal(dir, isEtag, uri, extns) {
511
+ let i = 0, arr = toAssume(uri, extns);
512
+ let abs, stats, name, headers;
513
+ for (; i < arr.length; i++) {
514
+ abs = _path.normalize.call(void 0, _path.join.call(void 0, dir, name = arr[i]));
515
+ if (abs.startsWith(dir) && fs.existsSync(abs)) {
516
+ stats = fs.statSync(abs);
517
+ if (stats.isDirectory())
518
+ continue;
519
+ headers = toHeaders(name, stats, isEtag);
520
+ headers["Cache-Control"] = isEtag ? "no-cache" : "no-store";
521
+ return { abs, stats, headers };
522
+ }
523
+ }
524
+ }
525
+ function is404(req, res) {
526
+ return res.statusCode = 404, res.end();
527
+ }
528
+ function send(req, res, file, stats, headers) {
529
+ let code = 200, tmp, opts = {};
530
+ headers = { ...headers };
531
+ for (let key in headers) {
532
+ tmp = res.getHeader(key);
533
+ if (tmp)
534
+ headers[key] = tmp;
535
+ }
536
+ if (tmp = res.getHeader("content-type")) {
537
+ headers["Content-Type"] = tmp;
538
+ }
539
+ if (req.headers.range) {
540
+ code = 206;
541
+ let [x, y] = req.headers.range.replace("bytes=", "").split("-");
542
+ let end = opts.end = parseInt(y, 10) || stats.size - 1;
543
+ let start = opts.start = parseInt(x, 10) || 0;
544
+ if (start >= stats.size || end >= stats.size) {
545
+ res.setHeader("Content-Range", `bytes */${stats.size}`);
546
+ res.statusCode = 416;
547
+ return res.end();
548
+ }
549
+ headers["Content-Range"] = `bytes ${start}-${end}/${stats.size}`;
550
+ headers["Content-Length"] = end - start + 1;
551
+ headers["Accept-Ranges"] = "bytes";
552
+ }
553
+ res.writeHead(code, headers);
554
+ fs.createReadStream(file, opts).pipe(res);
555
+ }
556
+ var ENCODING = {
557
+ ".br": "br",
558
+ ".gz": "gzip"
559
+ };
560
+ function toHeaders(name, stats, isEtag) {
561
+ let enc = ENCODING[name.slice(-3)];
562
+ let ctype = lookup(name.slice(0, enc && -3)) || "";
563
+ if (ctype === "text/html")
564
+ ctype += ";charset=utf-8";
565
+ let headers = {
566
+ "Content-Length": stats.size,
567
+ "Content-Type": ctype,
568
+ "Last-Modified": stats.mtime.toUTCString()
569
+ };
570
+ if (enc)
571
+ headers["Content-Encoding"] = enc;
572
+ if (isEtag)
573
+ headers["ETag"] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
574
+ return headers;
575
+ }
576
+ function build_default(dir, opts = {}) {
577
+ dir = _path.resolve.call(void 0, dir || ".");
578
+ let isNotFound = opts.onNoMatch || is404;
579
+ let setHeaders = opts.setHeaders || noop;
580
+ let extensions = opts.extensions || ["html", "htm"];
581
+ let gzips = opts.gzip && extensions.map((x) => `${x}.gz`).concat("gz");
582
+ let brots = opts.brotli && extensions.map((x) => `${x}.br`).concat("br");
583
+ const FILES = {};
584
+ let fallback = "/";
585
+ let isEtag = !!opts.etag;
586
+ let isSPA = !!opts.single;
587
+ if (typeof opts.single === "string") {
588
+ let idx = opts.single.lastIndexOf(".");
589
+ fallback += !!~idx ? opts.single.substring(0, idx) : opts.single;
590
+ }
591
+ let ignores = [];
592
+ if (opts.ignores !== false) {
593
+ ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/);
594
+ if (opts.dotfiles)
595
+ ignores.push(/\/\.\w/);
596
+ else
597
+ ignores.push(/\/\.well-known/);
598
+ [].concat(opts.ignores || []).forEach((x) => {
599
+ ignores.push(new RegExp(x, "i"));
600
+ });
601
+ }
602
+ let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
603
+ if (cc && opts.immutable)
604
+ cc += ",immutable";
605
+ else if (cc && opts.maxAge === 0)
606
+ cc += ",must-revalidate";
607
+ if (!opts.dev) {
608
+ totalist(dir, (name, abs, stats) => {
609
+ if (/\.well-known[\\+\/]/.test(name)) {
610
+ } else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name))
611
+ return;
612
+ let headers = toHeaders(name, stats, isEtag);
613
+ if (cc)
614
+ headers["Cache-Control"] = cc;
615
+ FILES["/" + name.normalize().replace(/\\+/g, "/")] = { abs, stats, headers };
616
+ });
617
+ }
618
+ let lookup2 = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES);
619
+ return function(req, res, next) {
620
+ let extns = [""];
621
+ let pathname = parse2(req).pathname;
622
+ let val = req.headers["accept-encoding"] || "";
623
+ if (gzips && val.includes("gzip"))
624
+ extns.unshift(...gzips);
625
+ if (brots && /(br|brotli)/i.test(val))
626
+ extns.unshift(...brots);
627
+ extns.push(...extensions);
628
+ if (pathname.indexOf("%") !== -1) {
629
+ try {
630
+ pathname = decodeURIComponent(pathname);
631
+ } catch (err) {
632
+ }
633
+ }
634
+ let data = lookup2(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup2(fallback, extns);
635
+ if (!data)
636
+ return next ? next() : isNotFound(req, res);
637
+ if (isEtag && req.headers["if-none-match"] === data.headers["ETag"]) {
638
+ res.writeHead(304);
639
+ return res.end();
640
+ }
641
+ if (gzips || brots) {
642
+ res.setHeader("Vary", "Accept-Encoding");
643
+ }
644
+ setHeaders(res, pathname, data.stats);
645
+ send(req, res, data.abs, data.stats, data.headers);
646
+ };
647
+ }
648
+
649
+ // node/build.ts
650
+ var _kolorist = require('kolorist');
651
+ async function build(options, viteConfig = {}) {
652
+ const indexPath = _path.resolve.call(void 0, options.userRoot, "index.html");
653
+ const rawConfig = await _vite.resolveConfig.call(void 0, {}, "build");
654
+ const pluginOptions = rawConfig.slidev || {};
655
+ let originalIndexHTML;
656
+ if (_fsextra2.default.existsSync(indexPath))
657
+ originalIndexHTML = await _fsextra2.default.readFile(indexPath, "utf-8");
658
+ await _fsextra2.default.writeFile(indexPath, await _chunk4MU7RGP4js.getIndexHtml.call(void 0, options), "utf-8");
659
+ let config = void 0;
660
+ try {
661
+ const inlineConfig = await _chunk4MU7RGP4js.mergeViteConfigs.call(void 0, options, viteConfig, {
662
+ root: options.userRoot,
663
+ plugins: [
664
+ await _chunk4MU7RGP4js.ViteSlidevPlugin.call(void 0, options, pluginOptions),
665
+ {
666
+ name: "resolve-config",
667
+ configResolved(_config) {
668
+ config = _config;
669
+ }
670
+ }
671
+ ],
672
+ build: {
673
+ chunkSizeWarningLimit: 2e3
674
+ }
675
+ }, "build");
676
+ await _vite.build.call(void 0, inlineConfig);
677
+ if (options.data.features.monaco) {
678
+ if (options.data.config.monaco === "dev") {
679
+ console.log(_kolorist.yellow.call(void 0, " Monaco is disabled in the build, to enabled it, set `monaco: true` in the frontmatter"));
680
+ } else {
681
+ console.log(_kolorist.blue.call(void 0, " building for Monaco...\n"));
682
+ await _vite.build.call(void 0, await _chunk4MU7RGP4js.mergeViteConfigs.call(void 0, options, inlineConfig, {
683
+ root: _path.join.call(void 0, options.clientRoot, "iframes/monaco"),
684
+ base: `${config.base}iframes/monaco/`,
685
+ build: {
686
+ outDir: _path.resolve.call(void 0, config.build.outDir, "iframes/monaco"),
687
+ rollupOptions: {
688
+ output: {
689
+ manualChunks: {
690
+ jsonWorker: ["monaco-editor/esm/vs/language/json/json.worker"],
691
+ cssWorker: ["monaco-editor/esm/vs/language/css/css.worker"],
692
+ htmlWorker: ["monaco-editor/esm/vs/language/html/html.worker"],
693
+ tsWorker: ["monaco-editor/esm/vs/language/typescript/ts.worker"],
694
+ editorWorker: ["monaco-editor/esm/vs/editor/editor.worker"]
695
+ }
696
+ }
697
+ }
698
+ }
699
+ }, "build"));
700
+ }
701
+ }
702
+ } finally {
703
+ if (originalIndexHTML != null)
704
+ await _fsextra2.default.writeFile(indexPath, originalIndexHTML, "utf-8");
705
+ else
706
+ await _fsextra2.default.unlink(indexPath);
707
+ }
708
+ const outDir = _path.resolve.call(void 0, options.userRoot, config.build.outDir);
709
+ const outFilename = options.data.config.exportFilename || "slidev-exported.pdf";
710
+ await _fsextra2.default.copyFile(_path.resolve.call(void 0, outDir, "index.html"), _path.resolve.call(void 0, outDir, "404.html"));
711
+ const redirectsPath = _path.resolve.call(void 0, outDir, "_redirects");
712
+ if (!_fsextra2.default.existsSync(redirectsPath))
713
+ await _fsextra2.default.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
714
+ `, "utf-8");
715
+ if ([true, "true", "auto"].includes(options.data.config.download)) {
716
+ const { exportSlides } = await Promise.resolve().then(() => _chunkSQLX75IOjs.__toESM.call(void 0, _chunkSQLX75IOjs.__require.call(void 0, "./export-TH7MNEXN.js")));
717
+ const port = 12445;
718
+ const app = _connect2.default.call(void 0, );
719
+ const server = _http2.default.createServer(app);
720
+ app.use(config.base, build_default(outDir, {
721
+ etag: true,
722
+ single: true,
723
+ dev: true
724
+ }));
725
+ server.listen(port);
726
+ await exportSlides({
727
+ port,
728
+ slides: options.data.slides,
729
+ total: options.data.slides.length,
730
+ format: "pdf",
731
+ output: _path.join.call(void 0, outDir, outFilename),
732
+ base: config.base,
733
+ dark: options.data.config.colorSchema === "dark",
734
+ width: options.data.config.canvasWidth,
735
+ height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
736
+ routerMode: options.data.config.routerMode
737
+ });
738
+ server.close();
739
+ }
740
+ }
741
+
742
+
743
+ exports.build = build;