@sveltejs/kit 1.0.0-next.43 → 1.0.0-next.430

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.
Files changed (104) hide show
  1. package/README.md +12 -9
  2. package/package.json +95 -63
  3. package/src/cli.js +112 -0
  4. package/src/core/adapt/builder.js +207 -0
  5. package/src/core/adapt/index.js +19 -0
  6. package/src/core/config/index.js +86 -0
  7. package/src/core/config/options.js +488 -0
  8. package/src/core/config/types.d.ts +1 -0
  9. package/src/core/constants.js +5 -0
  10. package/src/core/env.js +97 -0
  11. package/src/core/generate_manifest/index.js +99 -0
  12. package/src/core/prerender/crawl.js +194 -0
  13. package/src/core/prerender/prerender.js +378 -0
  14. package/src/core/prerender/queue.js +80 -0
  15. package/src/core/sync/create_manifest_data/index.js +506 -0
  16. package/src/core/sync/create_manifest_data/types.d.ts +40 -0
  17. package/src/core/sync/sync.js +59 -0
  18. package/src/core/sync/utils.js +44 -0
  19. package/src/core/sync/write_ambient.js +27 -0
  20. package/src/core/sync/write_client_manifest.js +82 -0
  21. package/src/core/sync/write_matchers.js +25 -0
  22. package/src/core/sync/write_root.js +91 -0
  23. package/src/core/sync/write_tsconfig.js +195 -0
  24. package/src/core/sync/write_types.js +775 -0
  25. package/src/core/utils.js +70 -0
  26. package/src/hooks.js +26 -0
  27. package/src/index/index.js +45 -0
  28. package/src/index/private.js +33 -0
  29. package/src/node/index.js +145 -0
  30. package/src/node/polyfills.js +40 -0
  31. package/src/runtime/app/env.js +11 -0
  32. package/src/runtime/app/navigation.js +22 -0
  33. package/src/runtime/app/paths.js +1 -0
  34. package/src/runtime/app/stores.js +102 -0
  35. package/src/runtime/client/ambient.d.ts +17 -0
  36. package/src/runtime/client/client.js +1289 -0
  37. package/src/runtime/client/fetcher.js +60 -0
  38. package/src/runtime/client/parse.js +36 -0
  39. package/src/runtime/client/singletons.js +21 -0
  40. package/src/runtime/client/start.js +46 -0
  41. package/src/runtime/client/types.d.ts +105 -0
  42. package/src/runtime/client/utils.js +113 -0
  43. package/src/runtime/components/error.svelte +16 -0
  44. package/{assets → src/runtime}/components/layout.svelte +0 -0
  45. package/src/runtime/env/dynamic/private.js +1 -0
  46. package/src/runtime/env/dynamic/public.js +1 -0
  47. package/src/runtime/env-private.js +7 -0
  48. package/src/runtime/env-public.js +7 -0
  49. package/src/runtime/env.js +6 -0
  50. package/src/runtime/hash.js +16 -0
  51. package/src/runtime/paths.js +11 -0
  52. package/src/runtime/server/endpoint.js +58 -0
  53. package/src/runtime/server/index.js +448 -0
  54. package/src/runtime/server/page/cookie.js +25 -0
  55. package/src/runtime/server/page/crypto.js +239 -0
  56. package/src/runtime/server/page/csp.js +249 -0
  57. package/src/runtime/server/page/fetch.js +266 -0
  58. package/src/runtime/server/page/index.js +416 -0
  59. package/src/runtime/server/page/load_data.js +135 -0
  60. package/src/runtime/server/page/render.js +362 -0
  61. package/src/runtime/server/page/respond_with_error.js +94 -0
  62. package/src/runtime/server/page/types.d.ts +44 -0
  63. package/src/runtime/server/utils.js +116 -0
  64. package/src/utils/error.js +22 -0
  65. package/src/utils/escape.js +104 -0
  66. package/src/utils/filesystem.js +108 -0
  67. package/src/utils/http.js +55 -0
  68. package/src/utils/misc.js +1 -0
  69. package/src/utils/routing.js +108 -0
  70. package/src/utils/url.js +97 -0
  71. package/src/vite/build/build_server.js +337 -0
  72. package/src/vite/build/build_service_worker.js +90 -0
  73. package/src/vite/build/utils.js +160 -0
  74. package/src/vite/dev/index.js +551 -0
  75. package/src/vite/index.js +574 -0
  76. package/src/vite/preview/index.js +186 -0
  77. package/src/vite/types.d.ts +3 -0
  78. package/src/vite/utils.js +345 -0
  79. package/svelte-kit.js +1 -1
  80. package/types/ambient.d.ts +357 -0
  81. package/types/index.d.ts +343 -0
  82. package/types/internal.d.ts +308 -0
  83. package/types/private.d.ts +209 -0
  84. package/CHANGELOG.md +0 -431
  85. package/assets/components/error.svelte +0 -13
  86. package/assets/runtime/app/env.js +0 -5
  87. package/assets/runtime/app/navigation.js +0 -41
  88. package/assets/runtime/app/paths.js +0 -1
  89. package/assets/runtime/app/stores.js +0 -93
  90. package/assets/runtime/chunks/utils.js +0 -19
  91. package/assets/runtime/internal/singletons.js +0 -23
  92. package/assets/runtime/internal/start.js +0 -770
  93. package/assets/runtime/paths.js +0 -12
  94. package/dist/.DS_Store +0 -0
  95. package/dist/chunks/index.js +0 -3521
  96. package/dist/chunks/index2.js +0 -587
  97. package/dist/chunks/index3.js +0 -246
  98. package/dist/chunks/index4.js +0 -538
  99. package/dist/chunks/index5.js +0 -761
  100. package/dist/chunks/index6.js +0 -322
  101. package/dist/chunks/standard.js +0 -99
  102. package/dist/chunks/utils.js +0 -83
  103. package/dist/cli.js +0 -546
  104. package/dist/ssr.js +0 -2581
@@ -1,322 +0,0 @@
1
- import fs, { readdirSync, statSync, existsSync, createReadStream } from 'fs';
2
- import http from 'http';
3
- import { pathToFileURL, parse as parse$1, URLSearchParams } from 'url';
4
- import { resolve, join, normalize } from 'path';
5
- import { M as Mime_1, s as standard } from './standard.js';
6
- import { g as get_body } from './index3.js';
7
-
8
- function list(dir, callback, pre='') {
9
- dir = resolve('.', dir);
10
- let arr = readdirSync(dir);
11
- let i=0, abs, stats;
12
- for (; i < arr.length; i++) {
13
- abs = join(dir, arr[i]);
14
- stats = statSync(abs);
15
- stats.isDirectory()
16
- ? list(abs, callback, join(pre, arr[i]))
17
- : callback(join(pre, arr[i]), abs, stats);
18
- }
19
- }
20
-
21
- function parse(str) {
22
- let i=0, j=0, k, v;
23
- let out={}, arr=str.split('&');
24
- for (; i < arr.length; i++) {
25
- j = arr[i].indexOf('=');
26
- v = !!~j && arr[i].substring(j+1) || '';
27
- k = !!~j ? arr[i].substring(0, j) : arr[i];
28
- out[k] = out[k] !== void 0 ? [].concat(out[k], v) : v;
29
- }
30
- return out;
31
- }
32
-
33
- function parser (req, toDecode) {
34
- let url = req.url;
35
- if (url == null) return;
36
-
37
- let obj = req._parsedUrl;
38
- if (obj && obj._raw === url) return obj;
39
-
40
- obj = {
41
- path: url,
42
- pathname: url,
43
- search: null,
44
- query: null,
45
- href: url,
46
- _raw: url
47
- };
48
-
49
- if (url.length > 1) {
50
- if (toDecode && !req._decoded && !!~url.indexOf('%', 1)) {
51
- let nxt = url;
52
- try { nxt = decodeURIComponent(url); } catch (e) {/* bad */}
53
- url = req.url = obj.href = obj.path = obj.pathname = obj._raw = nxt;
54
- req._decoded = true;
55
- }
56
-
57
- let idx = url.indexOf('?', 1);
58
-
59
- if (idx !== -1) {
60
- obj.search = url.substring(idx);
61
- obj.query = obj.search.substring(1);
62
- obj.pathname = url.substring(0, idx);
63
- if (toDecode && obj.query.length > 0) {
64
- obj.query = parse(obj.query);
65
- }
66
- }
67
- }
68
-
69
- return (req._parsedUrl = obj);
70
- }
71
-
72
- var lite = new Mime_1(standard);
73
-
74
- const noop = () => {};
75
-
76
- function isMatch(uri, arr) {
77
- for (let i=0; i < arr.length; i++) {
78
- if (arr[i].test(uri)) return true;
79
- }
80
- }
81
-
82
- function toAssume(uri, extns) {
83
- let i=0, x, len=uri.length - 1;
84
- if (uri.charCodeAt(len) === 47) {
85
- uri = uri.substring(0, len);
86
- }
87
-
88
- let arr=[], tmp=`${uri}/index`;
89
- for (; i < extns.length; i++) {
90
- x = extns[i] ? `.${extns[i]}` : '';
91
- if (uri) arr.push(uri + x);
92
- arr.push(tmp + x);
93
- }
94
-
95
- return arr;
96
- }
97
-
98
- function viaCache(cache, uri, extns) {
99
- let i=0, data, arr=toAssume(uri, extns);
100
- for (; i < arr.length; i++) {
101
- if (data = cache[arr[i]]) return data;
102
- }
103
- }
104
-
105
- function viaLocal(dir, isEtag, uri, extns) {
106
- let i=0, arr=toAssume(uri, extns);
107
- let abs, stats, name, headers;
108
- for (; i < arr.length; i++) {
109
- abs = normalize(join(dir, name=arr[i]));
110
- if (abs.startsWith(dir) && existsSync(abs)) {
111
- stats = statSync(abs);
112
- if (stats.isDirectory()) continue;
113
- headers = toHeaders(name, stats, isEtag);
114
- headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
115
- return { abs, stats, headers };
116
- }
117
- }
118
- }
119
-
120
- function is404(req, res) {
121
- return (res.statusCode=404,res.end());
122
- }
123
-
124
- function send(req, res, file, stats, headers) {
125
- let code=200, tmp, opts={};
126
- headers = { ...headers };
127
-
128
- for (let key in headers) {
129
- tmp = res.getHeader(key);
130
- if (tmp) headers[key] = tmp;
131
- }
132
-
133
- if (tmp = res.getHeader('content-type')) {
134
- headers['Content-Type'] = tmp;
135
- }
136
-
137
- if (req.headers.range) {
138
- code = 206;
139
- let [x, y] = req.headers.range.replace('bytes=', '').split('-');
140
- let end = opts.end = parseInt(y, 10) || stats.size - 1;
141
- let start = opts.start = parseInt(x, 10) || 0;
142
-
143
- if (start >= stats.size || end >= stats.size) {
144
- res.setHeader('Content-Range', `bytes */${stats.size}`);
145
- res.statusCode = 416;
146
- return res.end();
147
- }
148
-
149
- headers['Content-Range'] = `bytes ${start}-${end}/${stats.size}`;
150
- headers['Content-Length'] = (end - start + 1);
151
- headers['Accept-Ranges'] = 'bytes';
152
- }
153
-
154
- res.writeHead(code, headers);
155
- createReadStream(file, opts).pipe(res);
156
- }
157
-
158
- function isEncoding(name, type, headers) {
159
- headers['Content-Encoding'] = type;
160
- headers['Content-Type'] = lite.getType(name.replace(/\.([^.]*)$/, '')) || '';
161
- }
162
-
163
- function toHeaders(name, stats, isEtag) {
164
- let headers = {
165
- 'Content-Length': stats.size,
166
- 'Content-Type': lite.getType(name) || '',
167
- 'Last-Modified': stats.mtime.toUTCString(),
168
- };
169
- if (isEtag) headers['ETag'] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
170
- if (/\.br$/.test(name)) isEncoding(name, 'br', headers);
171
- if (/\.gz$/.test(name)) isEncoding(name, 'gzip', headers);
172
- return headers;
173
- }
174
-
175
- function sirv (dir, opts={}) {
176
- dir = resolve(dir || '.');
177
-
178
- let isNotFound = opts.onNoMatch || is404;
179
- let setHeaders = opts.setHeaders || noop;
180
-
181
- let extensions = opts.extensions || ['html', 'htm'];
182
- let gzips = opts.gzip && extensions.map(x => `${x}.gz`).concat('gz');
183
- let brots = opts.brotli && extensions.map(x => `${x}.br`).concat('br');
184
-
185
- const FILES = {};
186
-
187
- let fallback = '/';
188
- let isEtag = !!opts.etag;
189
- let isSPA = !!opts.single;
190
- if (typeof opts.single === 'string') {
191
- let idx = opts.single.lastIndexOf('.');
192
- fallback += !!~idx ? opts.single.substring(0, idx) : opts.single;
193
- }
194
-
195
- let ignores = [];
196
- if (opts.ignores !== false) {
197
- ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/); // any extn
198
- if (opts.dotfiles) ignores.push(/\/\.\w/);
199
- else ignores.push(/\/\.well-known/);
200
- [].concat(opts.ignores || []).forEach(x => {
201
- ignores.push(new RegExp(x, 'i'));
202
- });
203
- }
204
-
205
- let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
206
- if (cc && opts.immutable) cc += ',immutable';
207
- else if (cc && opts.maxAge === 0) cc += ',must-revalidate';
208
-
209
- if (!opts.dev) {
210
- list(dir, (name, abs, stats) => {
211
- if (/\.well-known[\\+\/]/.test(name)) ; // keep
212
- else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name)) return;
213
-
214
- let headers = toHeaders(name, stats, isEtag);
215
- if (cc) headers['Cache-Control'] = cc;
216
-
217
- FILES['/' + name.normalize().replace(/\\+/g, '/')] = { abs, stats, headers };
218
- });
219
- }
220
-
221
- let lookup = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES);
222
-
223
- return function (req, res, next) {
224
- let extns = [''];
225
- let val = req.headers['accept-encoding'] || '';
226
- if (gzips && val.includes('gzip')) extns.unshift(...gzips);
227
- if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots);
228
- extns.push(...extensions); // [...br, ...gz, orig, ...exts]
229
-
230
- let pathname = req.path || parser(req, true).pathname;
231
- let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns);
232
- if (!data) return next ? next() : isNotFound(req, res);
233
-
234
- if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {
235
- res.writeHead(304);
236
- return res.end();
237
- }
238
-
239
- if (gzips || brots) {
240
- res.setHeader('Vary', 'Accept-Encoding');
241
- }
242
-
243
- setHeaders(res, pathname, data.stats);
244
- send(req, res, data.abs, data.stats, data.headers);
245
- };
246
- }
247
-
248
- /** @param {string} dir */
249
- const mutable = (dir) =>
250
- sirv(dir, {
251
- etag: true,
252
- maxAge: 0
253
- });
254
-
255
- /**
256
- * @param {{
257
- * port: number;
258
- * config: import('../../types').ValidatedConfig;
259
- * cwd?: string;
260
- * }} opts
261
- * @returns {Promise<import('http').Server>}
262
- */
263
- async function start({ port, config, cwd = process.cwd() }) {
264
- const app_file = resolve(cwd, '.svelte/output/server/app.js');
265
-
266
- /** @type {import('../../types').App} */
267
- const app = await import(pathToFileURL(app_file).href);
268
-
269
- /** @type {import('sirv').RequestHandler} */
270
- const static_handler = fs.existsSync(config.kit.files.assets)
271
- ? mutable(config.kit.files.assets)
272
- : (_req, _res, next) => next();
273
-
274
- const assets_handler = sirv(resolve(cwd, '.svelte/output/client'), {
275
- maxAge: 31536000,
276
- immutable: true
277
- });
278
-
279
- return new Promise((fulfil) => {
280
- const server = http.createServer((req, res) => {
281
- const parsed = parse$1(req.url || '');
282
-
283
- assets_handler(req, res, () => {
284
- static_handler(req, res, async () => {
285
- const rendered = await app.render(
286
- {
287
- method: req.method,
288
- headers: req.headers,
289
- path: parsed.pathname,
290
- body: await get_body(req),
291
- query: new URLSearchParams(parsed.query || '')
292
- },
293
- {
294
- paths: {
295
- base: '',
296
- assets: '/.'
297
- },
298
- get_stack: (error) => error.stack, // TODO should this return a sourcemapped stacktrace?
299
- get_static_file: (file) => fs.readFileSync(join(config.kit.files.assets, file))
300
- }
301
- );
302
-
303
- if (rendered) {
304
- res.writeHead(rendered.status, rendered.headers);
305
- res.end(rendered.body);
306
- } else {
307
- res.statusCode = 404;
308
- res.end('Not found');
309
- }
310
- });
311
- });
312
- });
313
-
314
- server.listen(port, () => {
315
- fulfil(server);
316
- });
317
-
318
- return server;
319
- });
320
- }
321
-
322
- export { start };
@@ -1,99 +0,0 @@
1
- /**
2
- * @param typeMap [Object] Map of MIME type -> Array[extensions]
3
- * @param ...
4
- */
5
- function Mime() {
6
- this._types = Object.create(null);
7
- this._extensions = Object.create(null);
8
-
9
- for (let i = 0; i < arguments.length; i++) {
10
- this.define(arguments[i]);
11
- }
12
-
13
- this.define = this.define.bind(this);
14
- this.getType = this.getType.bind(this);
15
- this.getExtension = this.getExtension.bind(this);
16
- }
17
-
18
- /**
19
- * Define mimetype -> extension mappings. Each key is a mime-type that maps
20
- * to an array of extensions associated with the type. The first extension is
21
- * used as the default extension for the type.
22
- *
23
- * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
24
- *
25
- * If a type declares an extension that has already been defined, an error will
26
- * be thrown. To suppress this error and force the extension to be associated
27
- * with the new type, pass `force`=true. Alternatively, you may prefix the
28
- * extension with "*" to map the type to extension, without mapping the
29
- * extension to the type.
30
- *
31
- * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
32
- *
33
- *
34
- * @param map (Object) type definitions
35
- * @param force (Boolean) if true, force overriding of existing definitions
36
- */
37
- Mime.prototype.define = function(typeMap, force) {
38
- for (let type in typeMap) {
39
- let extensions = typeMap[type].map(function(t) {
40
- return t.toLowerCase();
41
- });
42
- type = type.toLowerCase();
43
-
44
- for (let i = 0; i < extensions.length; i++) {
45
- const ext = extensions[i];
46
-
47
- // '*' prefix = not the preferred type for this extension. So fixup the
48
- // extension, and skip it.
49
- if (ext[0] === '*') {
50
- continue;
51
- }
52
-
53
- if (!force && (ext in this._types)) {
54
- throw new Error(
55
- 'Attempt to change mapping for "' + ext +
56
- '" extension from "' + this._types[ext] + '" to "' + type +
57
- '". Pass `force=true` to allow this, otherwise remove "' + ext +
58
- '" from the list of extensions for "' + type + '".'
59
- );
60
- }
61
-
62
- this._types[ext] = type;
63
- }
64
-
65
- // Use first extension as default
66
- if (force || !this._extensions[type]) {
67
- const ext = extensions[0];
68
- this._extensions[type] = (ext[0] !== '*') ? ext : ext.substr(1);
69
- }
70
- }
71
- };
72
-
73
- /**
74
- * Lookup a mime type based on extension
75
- */
76
- Mime.prototype.getType = function(path) {
77
- path = String(path);
78
- let last = path.replace(/^.*[/\\]/, '').toLowerCase();
79
- let ext = last.replace(/^.*\./, '').toLowerCase();
80
-
81
- let hasPath = last.length < path.length;
82
- let hasDot = ext.length < last.length - 1;
83
-
84
- return (hasDot || !hasPath) && this._types[ext] || null;
85
- };
86
-
87
- /**
88
- * Return file extension associated with a mime type
89
- */
90
- Mime.prototype.getExtension = function(type) {
91
- type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
92
- return type && this._extensions[type.toLowerCase()] || null;
93
- };
94
-
95
- var Mime_1 = Mime;
96
-
97
- var standard = {"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"]};
98
-
99
- export { Mime_1 as M, standard as s };
@@ -1,83 +0,0 @@
1
- import path, { dirname, resolve } from 'path';
2
- import { $ } from '../cli.js';
3
- import fs, { existsSync } from 'fs';
4
- import { fileURLToPath } from 'url';
5
-
6
- /** @param {string} dir */
7
- function mkdirp(dir) {
8
- try {
9
- fs.mkdirSync(dir, { recursive: true });
10
- } catch (e) {
11
- if (e.code === 'EEXIST') return;
12
- throw e;
13
- }
14
- }
15
-
16
- /** @param {string} path */
17
- function rimraf(path) {
18
- (fs.rmSync || fs.rmdirSync)(path, { recursive: true, force: true });
19
- }
20
-
21
- /**
22
- * @param {string} from
23
- * @param {string} to
24
- * @param {(basename: string) => boolean} filter
25
- */
26
- function copy(from, to, filter = () => true) {
27
- if (!fs.existsSync(from)) return [];
28
- if (!filter(path.basename(from))) return [];
29
-
30
- const files = [];
31
- const stats = fs.statSync(from);
32
-
33
- if (stats.isDirectory()) {
34
- fs.readdirSync(from).forEach((file) => {
35
- files.push(...copy(path.join(from, file), path.join(to, file)));
36
- });
37
- } else {
38
- mkdirp(path.dirname(to));
39
- fs.copyFileSync(from, to);
40
- files.push(to);
41
- }
42
-
43
- return files;
44
- }
45
-
46
- const __filename = fileURLToPath(import.meta.url);
47
- const __dirname = dirname(__filename);
48
-
49
- /** @param {string} dest */
50
- function copy_assets(dest) {
51
- let prefix = '..';
52
- do {
53
- // we jump through these hoops so that this function
54
- // works whether or not it's been bundled
55
- const resolved = resolve(__dirname, `${prefix}/assets`);
56
-
57
- if (existsSync(resolved)) {
58
- copy(resolved, dest);
59
- return;
60
- }
61
-
62
- prefix = `../${prefix}`;
63
- } while (true); // eslint-disable-line
64
- }
65
-
66
- function noop() {}
67
-
68
- /** @param {{ verbose: boolean }} opts */
69
- function logger({ verbose }) {
70
- /** @type {import('../types').Logger} */
71
- const log = (msg) => console.log(msg.replace(/^/gm, ' '));
72
-
73
- log.success = (msg) => log($.green(`✔ ${msg}`));
74
- log.error = (msg) => log($.bold().red(msg));
75
- log.warn = (msg) => log($.bold().yellow(msg));
76
-
77
- log.minor = verbose ? (msg) => log($.grey(msg)) : noop;
78
- log.info = verbose ? log : noop;
79
-
80
- return log;
81
- }
82
-
83
- export { copy as a, copy_assets as c, logger as l, mkdirp as m, rimraf as r };