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