@slidev/cli 0.43.7 → 0.43.9

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