@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.
@@ -1,399 +0,0 @@
1
- import {
2
- ViteSlidevPlugin,
3
- getIndexHtml
4
- } from "./chunk-L7QFSRQN.mjs";
5
- import {
6
- __commonJS,
7
- __require,
8
- __spreadValues,
9
- __toModule
10
- } from "./chunk-QQD2JVXL.mjs";
11
-
12
- // ../../node_modules/.pnpm/@polka+url@1.0.0-next.20/node_modules/@polka/url/build.js
13
- var require_build = __commonJS({
14
- "../../node_modules/.pnpm/@polka+url@1.0.0-next.20/node_modules/@polka/url/build.js"(exports) {
15
- var qs = __require("querystring");
16
- function parse(req) {
17
- let raw = req.url;
18
- if (raw == null)
19
- return;
20
- let prev = req._parsedUrl;
21
- if (prev && prev.raw === raw)
22
- return prev;
23
- let pathname = raw, search = "", query;
24
- if (raw.length > 1) {
25
- let idx = raw.indexOf("?", 1);
26
- if (idx !== -1) {
27
- search = raw.substring(idx);
28
- pathname = raw.substring(0, idx);
29
- if (search.length > 1) {
30
- query = qs.parse(search.substring(1));
31
- }
32
- }
33
- }
34
- return req._parsedUrl = { pathname, search, query, raw };
35
- }
36
- exports.parse = parse;
37
- }
38
- });
39
-
40
- // ../../node_modules/.pnpm/totalist@1.1.0/node_modules/totalist/sync/index.js
41
- var require_sync = __commonJS({
42
- "../../node_modules/.pnpm/totalist@1.1.0/node_modules/totalist/sync/index.js"(exports, module) {
43
- var { join: join2, resolve: resolve2 } = __require("path");
44
- var { readdirSync, statSync } = __require("fs");
45
- module.exports = function list(dir, callback, pre = "") {
46
- dir = resolve2(".", dir);
47
- let arr = readdirSync(dir);
48
- let i = 0, abs, stats;
49
- for (; i < arr.length; i++) {
50
- abs = join2(dir, arr[i]);
51
- stats = statSync(abs);
52
- stats.isDirectory() ? list(abs, callback, join2(pre, arr[i])) : callback(join2(pre, arr[i]), abs, stats);
53
- }
54
- };
55
- }
56
- });
57
-
58
- // ../../node_modules/.pnpm/mime@2.5.2/node_modules/mime/Mime.js
59
- var require_Mime = __commonJS({
60
- "../../node_modules/.pnpm/mime@2.5.2/node_modules/mime/Mime.js"(exports, module) {
61
- "use strict";
62
- function Mime() {
63
- this._types = Object.create(null);
64
- this._extensions = Object.create(null);
65
- for (let i = 0; i < arguments.length; i++) {
66
- this.define(arguments[i]);
67
- }
68
- this.define = this.define.bind(this);
69
- this.getType = this.getType.bind(this);
70
- this.getExtension = this.getExtension.bind(this);
71
- }
72
- Mime.prototype.define = function(typeMap, force) {
73
- for (let type in typeMap) {
74
- let extensions = typeMap[type].map(function(t) {
75
- return t.toLowerCase();
76
- });
77
- type = type.toLowerCase();
78
- for (let i = 0; i < extensions.length; i++) {
79
- const ext = extensions[i];
80
- if (ext[0] === "*") {
81
- continue;
82
- }
83
- if (!force && ext in this._types) {
84
- throw new Error('Attempt to change mapping for "' + ext + '" extension from "' + this._types[ext] + '" to "' + type + '". Pass `force=true` to allow this, otherwise remove "' + ext + '" from the list of extensions for "' + type + '".');
85
- }
86
- this._types[ext] = type;
87
- }
88
- if (force || !this._extensions[type]) {
89
- const ext = extensions[0];
90
- this._extensions[type] = ext[0] !== "*" ? ext : ext.substr(1);
91
- }
92
- }
93
- };
94
- Mime.prototype.getType = function(path) {
95
- path = String(path);
96
- let last = path.replace(/^.*[/\\]/, "").toLowerCase();
97
- let ext = last.replace(/^.*\./, "").toLowerCase();
98
- let hasPath = last.length < path.length;
99
- let hasDot = ext.length < last.length - 1;
100
- return (hasDot || !hasPath) && this._types[ext] || null;
101
- };
102
- Mime.prototype.getExtension = function(type) {
103
- type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
104
- return type && this._extensions[type.toLowerCase()] || null;
105
- };
106
- module.exports = Mime;
107
- }
108
- });
109
-
110
- // ../../node_modules/.pnpm/mime@2.5.2/node_modules/mime/types/standard.js
111
- var require_standard = __commonJS({
112
- "../../node_modules/.pnpm/mime@2.5.2/node_modules/mime/types/standard.js"(exports, module) {
113
- module.exports = { "application/andrew-inset": ["ez"], "application/applixware": ["aw"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cu-seeme": ["cu"], "application/dash+xml": ["mpd"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma", "es"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["js", "mjs"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["mp4s", "m4p"], "application/mrb-consumer+xml": ["*xdf"], "application/mrb-publish+xml": ["*xdf"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["*xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-signature": ["asc", "sig"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-error+xml": ["xer"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avif": ["avif"], "image/bmp": ["bmp"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/stl": ["stl"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["markdown", "md"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
114
- }
115
- });
116
-
117
- // ../../node_modules/.pnpm/mime@2.5.2/node_modules/mime/lite.js
118
- var require_lite = __commonJS({
119
- "../../node_modules/.pnpm/mime@2.5.2/node_modules/mime/lite.js"(exports, module) {
120
- "use strict";
121
- var Mime = require_Mime();
122
- module.exports = new Mime(require_standard());
123
- }
124
- });
125
-
126
- // ../../node_modules/.pnpm/sirv@1.0.18/node_modules/sirv/build.js
127
- var require_build2 = __commonJS({
128
- "../../node_modules/.pnpm/sirv@1.0.18/node_modules/sirv/build.js"(exports, module) {
129
- var fs2 = __require("fs");
130
- var { join: join2, normalize, resolve: resolve2 } = __require("path");
131
- var { parse } = require_build();
132
- var list = require_sync();
133
- var mime = require_lite();
134
- var noop = () => {
135
- };
136
- function isMatch(uri, arr) {
137
- for (let i = 0; i < arr.length; i++) {
138
- if (arr[i].test(uri))
139
- return true;
140
- }
141
- }
142
- function toAssume(uri, extns) {
143
- let i = 0, x, len = uri.length - 1;
144
- if (uri.charCodeAt(len) === 47) {
145
- uri = uri.substring(0, len);
146
- }
147
- let arr = [], tmp = `${uri}/index`;
148
- for (; i < extns.length; i++) {
149
- x = extns[i] ? `.${extns[i]}` : "";
150
- if (uri)
151
- arr.push(uri + x);
152
- arr.push(tmp + x);
153
- }
154
- return arr;
155
- }
156
- function viaCache(cache, uri, extns) {
157
- let i = 0, data, arr = toAssume(uri, extns);
158
- for (; i < arr.length; i++) {
159
- if (data = cache[arr[i]])
160
- return data;
161
- }
162
- }
163
- function viaLocal(dir, isEtag, uri, extns) {
164
- let i = 0, arr = toAssume(uri, extns);
165
- let abs, stats, name, headers;
166
- for (; i < arr.length; i++) {
167
- abs = normalize(join2(dir, name = arr[i]));
168
- if (abs.startsWith(dir) && fs2.existsSync(abs)) {
169
- stats = fs2.statSync(abs);
170
- if (stats.isDirectory())
171
- continue;
172
- headers = toHeaders(name, stats, isEtag);
173
- headers["Cache-Control"] = isEtag ? "no-cache" : "no-store";
174
- return { abs, stats, headers };
175
- }
176
- }
177
- }
178
- function is404(req, res) {
179
- return res.statusCode = 404, res.end();
180
- }
181
- function send(req, res, file, stats, headers) {
182
- let code = 200, tmp, opts = {};
183
- headers = __spreadValues({}, headers);
184
- for (let key in headers) {
185
- tmp = res.getHeader(key);
186
- if (tmp)
187
- headers[key] = tmp;
188
- }
189
- if (tmp = res.getHeader("content-type")) {
190
- headers["Content-Type"] = tmp;
191
- }
192
- if (req.headers.range) {
193
- code = 206;
194
- let [x, y] = req.headers.range.replace("bytes=", "").split("-");
195
- let end = opts.end = parseInt(y, 10) || stats.size - 1;
196
- let start = opts.start = parseInt(x, 10) || 0;
197
- if (start >= stats.size || end >= stats.size) {
198
- res.setHeader("Content-Range", `bytes */${stats.size}`);
199
- res.statusCode = 416;
200
- return res.end();
201
- }
202
- headers["Content-Range"] = `bytes ${start}-${end}/${stats.size}`;
203
- headers["Content-Length"] = end - start + 1;
204
- headers["Accept-Ranges"] = "bytes";
205
- }
206
- res.writeHead(code, headers);
207
- fs2.createReadStream(file, opts).pipe(res);
208
- }
209
- var ENCODING = {
210
- ".br": "br",
211
- ".gz": "gzip"
212
- };
213
- function toHeaders(name, stats, isEtag) {
214
- let enc = ENCODING[name.slice(-3)];
215
- let ctype = mime.getType(name.slice(0, enc && -3)) || "";
216
- if (ctype === "text/html")
217
- ctype += ";charset=utf-8";
218
- let headers = {
219
- "Content-Length": stats.size,
220
- "Content-Type": ctype,
221
- "Last-Modified": stats.mtime.toUTCString()
222
- };
223
- if (enc)
224
- headers["Content-Encoding"] = enc;
225
- if (isEtag)
226
- headers["ETag"] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
227
- return headers;
228
- }
229
- module.exports = function(dir, opts = {}) {
230
- dir = resolve2(dir || ".");
231
- let isNotFound = opts.onNoMatch || is404;
232
- let setHeaders = opts.setHeaders || noop;
233
- let extensions = opts.extensions || ["html", "htm"];
234
- let gzips = opts.gzip && extensions.map((x) => `${x}.gz`).concat("gz");
235
- let brots = opts.brotli && extensions.map((x) => `${x}.br`).concat("br");
236
- const FILES = {};
237
- let fallback = "/";
238
- let isEtag = !!opts.etag;
239
- let isSPA = !!opts.single;
240
- if (typeof opts.single === "string") {
241
- let idx = opts.single.lastIndexOf(".");
242
- fallback += !!~idx ? opts.single.substring(0, idx) : opts.single;
243
- }
244
- let ignores = [];
245
- if (opts.ignores !== false) {
246
- ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/);
247
- if (opts.dotfiles)
248
- ignores.push(/\/\.\w/);
249
- else
250
- ignores.push(/\/\.well-known/);
251
- [].concat(opts.ignores || []).forEach((x) => {
252
- ignores.push(new RegExp(x, "i"));
253
- });
254
- }
255
- let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
256
- if (cc && opts.immutable)
257
- cc += ",immutable";
258
- else if (cc && opts.maxAge === 0)
259
- cc += ",must-revalidate";
260
- if (!opts.dev) {
261
- list(dir, (name, abs, stats) => {
262
- if (/\.well-known[\\+\/]/.test(name)) {
263
- } else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name))
264
- return;
265
- let headers = toHeaders(name, stats, isEtag);
266
- if (cc)
267
- headers["Cache-Control"] = cc;
268
- FILES["/" + name.normalize().replace(/\\+/g, "/")] = { abs, stats, headers };
269
- });
270
- }
271
- let lookup = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES);
272
- return function(req, res, next) {
273
- let extns = [""];
274
- let pathname = parse(req).pathname;
275
- let val = req.headers["accept-encoding"] || "";
276
- if (gzips && val.includes("gzip"))
277
- extns.unshift(...gzips);
278
- if (brots && /(br|brotli)/i.test(val))
279
- extns.unshift(...brots);
280
- extns.push(...extensions);
281
- if (pathname.indexOf("%") !== -1) {
282
- try {
283
- pathname = decodeURIComponent(pathname);
284
- } catch (err) {
285
- }
286
- }
287
- let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns);
288
- if (!data)
289
- return next ? next() : isNotFound(req, res);
290
- if (isEtag && req.headers["if-none-match"] === data.headers["ETag"]) {
291
- res.writeHead(304);
292
- return res.end();
293
- }
294
- if (gzips || brots) {
295
- res.setHeader("Vary", "Accept-Encoding");
296
- }
297
- setHeaders(res, pathname, data.stats);
298
- send(req, res, data.abs, data.stats, data.headers);
299
- };
300
- };
301
- }
302
- });
303
-
304
- // node/build.ts
305
- var import_sirv = __toModule(require_build2());
306
- import { resolve, join } from "path";
307
- import http from "http";
308
- import fs from "fs-extra";
309
- import { build as viteBuild, mergeConfig, resolveConfig } from "vite";
310
- import connect from "connect";
311
- import { blue, yellow } from "kolorist";
312
- async function build(options, viteConfig = {}) {
313
- const indexPath = resolve(options.userRoot, "index.html");
314
- const rawConfig = await resolveConfig({}, "build");
315
- const pluginOptions = rawConfig.slidev || {};
316
- let originalIndexHTML;
317
- if (fs.existsSync(indexPath))
318
- originalIndexHTML = await fs.readFile(indexPath, "utf-8");
319
- await fs.writeFile(indexPath, await getIndexHtml(options), "utf-8");
320
- let config = void 0;
321
- try {
322
- const inlineConfig = mergeConfig(viteConfig, {
323
- plugins: [
324
- await ViteSlidevPlugin(options, pluginOptions),
325
- {
326
- name: "resolve-config",
327
- configResolved(_config) {
328
- config = _config;
329
- }
330
- }
331
- ],
332
- build: {
333
- chunkSizeWarningLimit: 2e3
334
- }
335
- });
336
- await viteBuild(inlineConfig);
337
- if (options.data.features.monaco) {
338
- if (options.data.config.monaco === "dev") {
339
- console.log(yellow(" Monaco is disabled in the build, to enabled it, set `monaco: true` in the frontmatter"));
340
- } else {
341
- console.log(blue(" building for Monaco...\n"));
342
- await viteBuild(mergeConfig(inlineConfig, {
343
- root: join(options.clientRoot, "iframes/monaco"),
344
- base: `${config.base}iframes/monaco/`,
345
- build: {
346
- outDir: resolve(config.build.outDir, "iframes/monaco"),
347
- rollupOptions: {
348
- output: {
349
- manualChunks: {
350
- jsonWorker: ["monaco-editor/esm/vs/language/json/json.worker"],
351
- cssWorker: ["monaco-editor/esm/vs/language/css/css.worker"],
352
- htmlWorker: ["monaco-editor/esm/vs/language/html/html.worker"],
353
- tsWorker: ["monaco-editor/esm/vs/language/typescript/ts.worker"],
354
- editorWorker: ["monaco-editor/esm/vs/editor/editor.worker"]
355
- }
356
- }
357
- }
358
- }
359
- }));
360
- }
361
- }
362
- } finally {
363
- if (originalIndexHTML != null)
364
- await fs.writeFile(indexPath, originalIndexHTML, "utf-8");
365
- else
366
- await fs.unlink(indexPath);
367
- }
368
- await fs.copyFile(resolve(config.build.outDir, "index.html"), resolve(config.build.outDir, "404.html"));
369
- const redirectsPath = resolve(config.build.outDir, "_redirects");
370
- if (!fs.existsSync(redirectsPath))
371
- await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
372
- `, "utf-8");
373
- if ([true, "true", "auto"].includes(options.data.config.download)) {
374
- const { exportSlides } = await Promise.resolve().then(() => __toModule(__require("./export-Y4JCWLGL.mjs")));
375
- const port = 12445;
376
- const app = connect();
377
- const server = http.createServer(app);
378
- app.use(config.base, (0, import_sirv.default)(config.build.outDir, {
379
- etag: true,
380
- single: true,
381
- dev: true
382
- }));
383
- server.listen(port);
384
- await exportSlides({
385
- port,
386
- total: options.data.slides.length,
387
- format: "pdf",
388
- output: join(config.build.outDir, "slidev-exported.pdf"),
389
- base: config.base,
390
- dark: options.data.config.colorSchema === "dark",
391
- width: 1920,
392
- height: Math.round(1920 / options.data.config.aspectRatio)
393
- });
394
- server.close();
395
- }
396
- }
397
- export {
398
- build
399
- };