@slidev/cli 0.27.16 → 0.28.0

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