@sveltejs/kit 1.0.0-next.33 → 1.0.0-next.330

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 (75) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -0
  3. package/assets/app/navigation.js +24 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/app/stores.js +97 -0
  6. package/assets/client/singletons.js +13 -0
  7. package/assets/client/start.js +1689 -0
  8. package/assets/components/error.svelte +18 -2
  9. package/assets/env.js +8 -0
  10. package/assets/paths.js +13 -0
  11. package/assets/server/index.js +3408 -0
  12. package/dist/chunks/amp_hook.js +56 -0
  13. package/dist/chunks/cert.js +28154 -0
  14. package/dist/chunks/constants.js +663 -0
  15. package/dist/chunks/filesystem.js +110 -0
  16. package/dist/chunks/index.js +514 -0
  17. package/dist/chunks/index2.js +1384 -0
  18. package/dist/chunks/index3.js +118 -0
  19. package/dist/chunks/index4.js +182 -0
  20. package/dist/chunks/index5.js +252 -0
  21. package/dist/chunks/index6.js +15741 -0
  22. package/dist/chunks/index7.js +4207 -0
  23. package/dist/chunks/misc.js +78 -0
  24. package/dist/chunks/multipart-parser.js +449 -0
  25. package/dist/chunks/object.js +83 -0
  26. package/dist/chunks/sync.js +848 -0
  27. package/dist/chunks/write_tsconfig.js +150 -0
  28. package/dist/cli.js +1025 -65
  29. package/dist/hooks.js +28 -0
  30. package/dist/install-fetch.js +6518 -0
  31. package/dist/node.js +94 -0
  32. package/package.json +96 -62
  33. package/svelte-kit.js +0 -1
  34. package/types/ambient.d.ts +298 -0
  35. package/types/index.d.ts +279 -0
  36. package/types/internal.d.ts +320 -0
  37. package/types/private.d.ts +246 -0
  38. package/CHANGELOG.md +0 -356
  39. package/assets/runtime/app/navigation.js +0 -23
  40. package/assets/runtime/app/navigation.js.map +0 -1
  41. package/assets/runtime/app/paths.js +0 -2
  42. package/assets/runtime/app/paths.js.map +0 -1
  43. package/assets/runtime/app/stores.js +0 -78
  44. package/assets/runtime/app/stores.js.map +0 -1
  45. package/assets/runtime/internal/singletons.js +0 -15
  46. package/assets/runtime/internal/singletons.js.map +0 -1
  47. package/assets/runtime/internal/start.js +0 -591
  48. package/assets/runtime/internal/start.js.map +0 -1
  49. package/assets/runtime/utils-85ebcc60.js +0 -18
  50. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  51. package/dist/api.js +0 -32
  52. package/dist/api.js.map +0 -1
  53. package/dist/cli.js.map +0 -1
  54. package/dist/create_app.js +0 -577
  55. package/dist/create_app.js.map +0 -1
  56. package/dist/index.js +0 -329
  57. package/dist/index.js.map +0 -1
  58. package/dist/index2.js +0 -14368
  59. package/dist/index2.js.map +0 -1
  60. package/dist/index3.js +0 -544
  61. package/dist/index3.js.map +0 -1
  62. package/dist/index4.js +0 -71
  63. package/dist/index4.js.map +0 -1
  64. package/dist/index5.js +0 -465
  65. package/dist/index5.js.map +0 -1
  66. package/dist/index6.js +0 -727
  67. package/dist/index6.js.map +0 -1
  68. package/dist/renderer.js +0 -2413
  69. package/dist/renderer.js.map +0 -1
  70. package/dist/standard.js +0 -100
  71. package/dist/standard.js.map +0 -1
  72. package/dist/utils.js +0 -57
  73. package/dist/utils.js.map +0 -1
  74. package/dist/vite.js +0 -317
  75. package/dist/vite.js.map +0 -1
package/dist/index6.js DELETED
@@ -1,727 +0,0 @@
1
- import { $ } from './index.js';
2
- import { URLSearchParams, resolve as resolve$2, parse, pathToFileURL } from 'url';
3
- import { m as mkdirp, a as copy, l as logger } from './utils.js';
4
- import fs, { readFileSync } from 'fs';
5
- import path, { resolve as resolve$1, join as join$1, dirname } from 'path';
6
- import os from 'os';
7
-
8
- const isWin = process.platform === 'win32';
9
- const SEP = isWin ? `\\\\+` : `\\/`;
10
- const SEP_ESC = isWin ? `\\\\` : `/`;
11
- const GLOBSTAR = `((?:[^/]*(?:/|$))*)`;
12
- const WILDCARD = `([^/]*)`;
13
- const GLOBSTAR_SEGMENT = `((?:[^${SEP_ESC}]*(?:${SEP_ESC}|$))*)`;
14
- const WILDCARD_SEGMENT = `([^${SEP_ESC}]*)`;
15
-
16
- /**
17
- * Convert any glob pattern to a JavaScript Regexp object
18
- * @param {String} glob Glob pattern to convert
19
- * @param {Object} opts Configuration object
20
- * @param {Boolean} [opts.extended=false] Support advanced ext globbing
21
- * @param {Boolean} [opts.globstar=false] Support globstar
22
- * @param {Boolean} [opts.strict=true] be laissez faire about mutiple slashes
23
- * @param {Boolean} [opts.filepath=''] Parse as filepath for extra path related features
24
- * @param {String} [opts.flags=''] RegExp globs
25
- * @returns {Object} converted object with string, segments and RegExp object
26
- */
27
- function globrex(glob, {extended = false, globstar = false, strict = false, filepath = false, flags = ''} = {}) {
28
- let regex = '';
29
- let segment = '';
30
- let path = { regex: '', segments: [] };
31
-
32
- // If we are doing extended matching, this boolean is true when we are inside
33
- // a group (eg {*.html,*.js}), and false otherwise.
34
- let inGroup = false;
35
- let inRange = false;
36
-
37
- // extglob stack. Keep track of scope
38
- const ext = [];
39
-
40
- // Helper function to build string and segments
41
- function add(str, {split, last, only}={}) {
42
- if (only !== 'path') regex += str;
43
- if (filepath && only !== 'regex') {
44
- path.regex += (str === '\\/' ? SEP : str);
45
- if (split) {
46
- if (last) segment += str;
47
- if (segment !== '') {
48
- if (!flags.includes('g')) segment = `^${segment}$`; // change it 'includes'
49
- path.segments.push(new RegExp(segment, flags));
50
- }
51
- segment = '';
52
- } else {
53
- segment += str;
54
- }
55
- }
56
- }
57
-
58
- let c, n;
59
- for (let i = 0; i < glob.length; i++) {
60
- c = glob[i];
61
- n = glob[i + 1];
62
-
63
- if (['\\', '$', '^', '.', '='].includes(c)) {
64
- add(`\\${c}`);
65
- continue;
66
- }
67
-
68
- if (c === '/') {
69
- add(`\\${c}`, {split: true});
70
- if (n === '/' && !strict) regex += '?';
71
- continue;
72
- }
73
-
74
- if (c === '(') {
75
- if (ext.length) {
76
- add(c);
77
- continue;
78
- }
79
- add(`\\${c}`);
80
- continue;
81
- }
82
-
83
- if (c === ')') {
84
- if (ext.length) {
85
- add(c);
86
- let type = ext.pop();
87
- if (type === '@') {
88
- add('{1}');
89
- } else if (type === '!') {
90
- add('([^\/]*)');
91
- } else {
92
- add(type);
93
- }
94
- continue;
95
- }
96
- add(`\\${c}`);
97
- continue;
98
- }
99
-
100
- if (c === '|') {
101
- if (ext.length) {
102
- add(c);
103
- continue;
104
- }
105
- add(`\\${c}`);
106
- continue;
107
- }
108
-
109
- if (c === '+') {
110
- if (n === '(' && extended) {
111
- ext.push(c);
112
- continue;
113
- }
114
- add(`\\${c}`);
115
- continue;
116
- }
117
-
118
- if (c === '@' && extended) {
119
- if (n === '(') {
120
- ext.push(c);
121
- continue;
122
- }
123
- }
124
-
125
- if (c === '!') {
126
- if (extended) {
127
- if (inRange) {
128
- add('^');
129
- continue
130
- }
131
- if (n === '(') {
132
- ext.push(c);
133
- add('(?!');
134
- i++;
135
- continue;
136
- }
137
- add(`\\${c}`);
138
- continue;
139
- }
140
- add(`\\${c}`);
141
- continue;
142
- }
143
-
144
- if (c === '?') {
145
- if (extended) {
146
- if (n === '(') {
147
- ext.push(c);
148
- } else {
149
- add('.');
150
- }
151
- continue;
152
- }
153
- add(`\\${c}`);
154
- continue;
155
- }
156
-
157
- if (c === '[') {
158
- if (inRange && n === ':') {
159
- i++; // skip [
160
- let value = '';
161
- while(glob[++i] !== ':') value += glob[i];
162
- if (value === 'alnum') add('(\\w|\\d)');
163
- else if (value === 'space') add('\\s');
164
- else if (value === 'digit') add('\\d');
165
- i++; // skip last ]
166
- continue;
167
- }
168
- if (extended) {
169
- inRange = true;
170
- add(c);
171
- continue;
172
- }
173
- add(`\\${c}`);
174
- continue;
175
- }
176
-
177
- if (c === ']') {
178
- if (extended) {
179
- inRange = false;
180
- add(c);
181
- continue;
182
- }
183
- add(`\\${c}`);
184
- continue;
185
- }
186
-
187
- if (c === '{') {
188
- if (extended) {
189
- inGroup = true;
190
- add('(');
191
- continue;
192
- }
193
- add(`\\${c}`);
194
- continue;
195
- }
196
-
197
- if (c === '}') {
198
- if (extended) {
199
- inGroup = false;
200
- add(')');
201
- continue;
202
- }
203
- add(`\\${c}`);
204
- continue;
205
- }
206
-
207
- if (c === ',') {
208
- if (inGroup) {
209
- add('|');
210
- continue;
211
- }
212
- add(`\\${c}`);
213
- continue;
214
- }
215
-
216
- if (c === '*') {
217
- if (n === '(' && extended) {
218
- ext.push(c);
219
- continue;
220
- }
221
- // Move over all consecutive "*"'s.
222
- // Also store the previous and next characters
223
- let prevChar = glob[i - 1];
224
- let starCount = 1;
225
- while (glob[i + 1] === '*') {
226
- starCount++;
227
- i++;
228
- }
229
- let nextChar = glob[i + 1];
230
- if (!globstar) {
231
- // globstar is disabled, so treat any number of "*" as one
232
- add('.*');
233
- } else {
234
- // globstar is enabled, so determine if this is a globstar segment
235
- let isGlobstar =
236
- starCount > 1 && // multiple "*"'s
237
- (prevChar === '/' || prevChar === undefined) && // from the start of the segment
238
- (nextChar === '/' || nextChar === undefined); // to the end of the segment
239
- if (isGlobstar) {
240
- // it's a globstar, so match zero or more path segments
241
- add(GLOBSTAR, {only:'regex'});
242
- add(GLOBSTAR_SEGMENT, {only:'path', last:true, split:true});
243
- i++; // move over the "/"
244
- } else {
245
- // it's not a globstar, so only match one path segment
246
- add(WILDCARD, {only:'regex'});
247
- add(WILDCARD_SEGMENT, {only:'path'});
248
- }
249
- }
250
- continue;
251
- }
252
-
253
- add(c);
254
- }
255
-
256
-
257
- // When regexp 'g' flag is specified don't
258
- // constrain the regular expression with ^ & $
259
- if (!flags.includes('g')) {
260
- regex = `^${regex}$`;
261
- segment = `^${segment}$`;
262
- if (filepath) path.regex = `^${path.regex}$`;
263
- }
264
-
265
- const result = {regex: new RegExp(regex, flags)};
266
-
267
- // Push the last segment
268
- if (filepath) {
269
- path.segments.push(new RegExp(segment, flags));
270
- path.regex = new RegExp(path.regex, flags);
271
- path.globstar = new RegExp(!flags.includes('g') ? `^${GLOBSTAR_SEGMENT}$` : GLOBSTAR_SEGMENT, flags);
272
- result.path = path;
273
- }
274
-
275
- return result;
276
- }
277
-
278
- var globrex_1 = globrex;
279
-
280
- const isWin$1 = os.platform() === 'win32';
281
-
282
- const CHARS = { '{': '}', '(': ')', '[': ']'};
283
- const STRICT = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\)|(\\).|([@?!+*]\(.*\)))/;
284
- const RELAXED = /\\(.)|(^!|[*?{}()[\]]|\(\?)/;
285
-
286
- /**
287
- * Detect if a string cointains glob
288
- * @param {String} str Input string
289
- * @param {Object} [options] Configuration object
290
- * @param {Boolean} [options.strict=true] Use relaxed regex if true
291
- * @returns {Boolean} true if string contains glob
292
- */
293
- function isglob(str, { strict = true } = {}) {
294
- if (str === '') return false;
295
- let match, rgx = strict ? STRICT : RELAXED;
296
-
297
- while ((match = rgx.exec(str))) {
298
- if (match[2]) return true;
299
- let idx = match.index + match[0].length;
300
-
301
- // if an open bracket/brace/paren is escaped,
302
- // set the index to the next closing character
303
- let open = match[1];
304
- let close = open ? CHARS[open] : null;
305
- if (open && close) {
306
- let n = str.indexOf(close, idx);
307
- if (n !== -1) idx = n + 1;
308
- }
309
-
310
- str = str.slice(idx);
311
- }
312
- return false;
313
- }
314
-
315
-
316
- /**
317
- * Find the static part of a glob-path,
318
- * split path and return path part
319
- * @param {String} str Path/glob string
320
- * @returns {String} static path section of glob
321
- */
322
- function parent(str, { strict = false } = {}) {
323
- if (isWin$1 && str.includes('/'))
324
- str = str.split('\\').join('/');
325
-
326
- // special case for strings ending in enclosure containing path separator
327
- if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += '/';
328
-
329
- // preserves full path in case of trailing path separator
330
- str += 'a';
331
-
332
- do {str = path.dirname(str);}
333
- while (isglob(str, {strict}) || /(^|[^\\])([\{\[]|\([^\)]+$)/.test(str));
334
-
335
- // remove escape chars and return result
336
- return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, '$1');
337
- }
338
-
339
- /**
340
- * Parse a glob path, and split it by static/glob part
341
- * @param {String} pattern String path
342
- * @param {Object} [opts] Options
343
- * @param {Object} [opts.strict=false] Use strict parsing
344
- * @returns {Object} object with parsed path
345
- */
346
- function globalyzer(pattern, opts = {}) {
347
- let base = parent(pattern, opts);
348
- let isGlob = isglob(pattern, opts);
349
- let glob;
350
-
351
- if (base != '.') {
352
- glob = pattern.substr(base.length);
353
- if (glob.startsWith('/')) glob = glob.substr(1);
354
- } else {
355
- glob = pattern;
356
- }
357
-
358
- if (!isGlob) {
359
- base = path.dirname(pattern);
360
- glob = base !== '.' ? pattern.substr(base.length) : pattern;
361
- }
362
-
363
- if (glob.startsWith('./')) glob = glob.substr(2);
364
- if (glob.startsWith('/')) glob = glob.substr(1);
365
-
366
- return { base, glob, isGlob };
367
- }
368
-
369
-
370
- var src = globalyzer;
371
-
372
- const { join, resolve, relative } = path;
373
- const isHidden = /(^|[\\\/])\.[^\\\/\.]/g;
374
-
375
- let CACHE = {};
376
-
377
- function walk(output, prefix, lexer, opts, dirname='', level=0) {
378
- const rgx = lexer.segments[level];
379
- const dir = resolve(opts.cwd, prefix, dirname);
380
- const files = fs.readdirSync(dir);
381
- const { dot, filesOnly } = opts;
382
-
383
- let i=0, len=files.length, file;
384
- let fullpath, relpath, stats, isMatch;
385
-
386
- for (; i < len; i++) {
387
- fullpath = join(dir, file=files[i]);
388
- relpath = dirname ? join(dirname, file) : file;
389
- if (!dot && isHidden.test(relpath)) continue;
390
- isMatch = lexer.regex.test(relpath);
391
-
392
- if ((stats=CACHE[relpath]) === void 0) {
393
- CACHE[relpath] = stats = fs.lstatSync(fullpath);
394
- }
395
-
396
- if (!stats.isDirectory()) {
397
- isMatch && output.push(relative(opts.cwd, fullpath));
398
- continue;
399
- }
400
-
401
- if (rgx && !rgx.test(file)) continue;
402
- !filesOnly && isMatch && output.push(join(prefix, relpath));
403
-
404
- walk(output, prefix, lexer, opts, relpath, rgx && rgx.toString() !== lexer.globstar && level + 1);
405
- }
406
- }
407
-
408
- /**
409
- * Find files using bash-like globbing.
410
- * All paths are normalized compared to node-glob.
411
- * @param {String} str Glob string
412
- * @param {String} [options.cwd='.'] Current working directory
413
- * @param {Boolean} [options.dot=false] Include dotfile matches
414
- * @param {Boolean} [options.absolute=false] Return absolute paths
415
- * @param {Boolean} [options.filesOnly=false] Do not include folders if true
416
- * @param {Boolean} [options.flush=false] Reset cache object
417
- * @returns {Array} array containing matching files
418
- */
419
- var sync = function (str, opts={}) {
420
- if (!str) return [];
421
-
422
- let glob = src(str);
423
-
424
- opts.cwd = opts.cwd || '.';
425
-
426
- if (!glob.isGlob) {
427
- try {
428
- let resolved = resolve(opts.cwd, str);
429
- let dirent = fs.statSync(resolved);
430
- if (opts.filesOnly && !dirent.isFile()) return [];
431
-
432
- return opts.absolute ? [resolved] : [str];
433
- } catch (err) {
434
- if (err.code != 'ENOENT') throw err;
435
-
436
- return [];
437
- }
438
- }
439
-
440
- if (opts.flush) CACHE = {};
441
-
442
- let matches = [];
443
- const { path } = globrex_1(glob.glob, { filepath:true, globstar:true, extended:true });
444
-
445
- path.globstar = path.globstar.toString();
446
- walk(matches, glob.base, path, opts, '.', 0);
447
-
448
- return opts.absolute ? matches.map(x => resolve(opts.cwd, x)) : matches;
449
- };
450
-
451
- function clean_html(html) {
452
- return html
453
- .replace(/<!\[CDATA\[[\s\S]*?\]\]>/gm, '')
454
- .replace(/(<script[\s\S]*?>)[\s\S]*?<\/script>/gm, '$1</' + 'script>')
455
- .replace(/(<style[\s\S]*?>)[\s\S]*?<\/style>/gm, '$1</' + 'style>')
456
- .replace(/<!--[\s\S]*?-->/gm, '');
457
- }
458
-
459
- function get_href(attrs) {
460
- const match = /href\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/.exec(attrs);
461
- return match && (match[1] || match[2] || match[3]);
462
- }
463
-
464
- function get_src(attrs) {
465
- const match = /src\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/.exec(attrs);
466
- return match && (match[1] || match[2] || match[3]);
467
- }
468
-
469
- function get_srcset_urls(attrs) {
470
- const results = [];
471
- // Note that the srcset allows any ASCII whitespace, including newlines.
472
- const match = /srcset\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/s.exec(attrs);
473
- if (match) {
474
- const attr_content = match[1] || match[2] || match[3];
475
- // Parse the content of the srcset attribute.
476
- // The regexp is modelled after the srcset specs (https://html.spec.whatwg.org/multipage/images.html#srcset-attribute)
477
- // and should cover most reasonable cases.
478
- const regex = /\s*([^\s,]\S+[^\s,])\s*((?:\d+w)|(?:-?\d+(?:\.\d+)?(?:[eE]-?\d+)?x))?/gm;
479
- let sub_matches;
480
- while ((sub_matches = regex.exec(attr_content))) {
481
- results.push(sub_matches[1]);
482
- }
483
- }
484
- return results;
485
- }
486
-
487
- const OK = 2;
488
- const REDIRECT = 3;
489
-
490
- async function prerender({ dir, out, log, config, force }) {
491
- const seen = new Set();
492
-
493
- const server_root = resolve$1(dir);
494
- const app = await import(`${server_root}/server/app.js`);
495
-
496
- app.init({
497
- paths: config.paths
498
- });
499
-
500
- const error = config.prerender.force
501
- ? (status, path) => {
502
- log.error(`${status} ${path}`);
503
- }
504
- : (status, path) => {
505
- throw new Error(`${status} ${path}`);
506
- };
507
-
508
- async function visit(path) {
509
- if (seen.has(path)) return;
510
- seen.add(path);
511
-
512
- const rendered = await app.render(
513
- {
514
- host: config.host,
515
- method: 'GET',
516
- headers: {},
517
- path,
518
- body: null,
519
- query: new URLSearchParams()
520
- },
521
- {
522
- local: true,
523
- only_prerender: !force,
524
- get_static_file: (file) => readFileSync(join$1(config.files.assets, file))
525
- }
526
- );
527
-
528
- if (rendered) {
529
- const response_type = Math.floor(rendered.status / 100);
530
- const headers = rendered.headers;
531
- const type = headers && headers['content-type'];
532
- const is_html = response_type === REDIRECT || type === 'text/html';
533
-
534
- const parts = path.split('/');
535
- if (is_html && parts[parts.length - 1] !== 'index.html') {
536
- parts.push('index.html');
537
- }
538
-
539
- const file = `${out}${parts.join('/')}`;
540
- mkdirp(dirname(file));
541
-
542
- if (response_type === REDIRECT) {
543
- const { location } = headers;
544
-
545
- log.warn(`${rendered.status} ${path} -> ${location}`);
546
- fs.writeFileSync(
547
- file,
548
- `<meta http-equiv="refresh" content="0;url=${encodeURI(location)}">`
549
- );
550
-
551
- return;
552
- }
553
-
554
- if (response_type === OK) {
555
- log.info(`${rendered.status} ${path}`);
556
- fs.writeFileSync(file, rendered.body); // TODO minify where possible?
557
- } else {
558
- error(rendered.status, path);
559
- }
560
-
561
- const { dependencies } = rendered;
562
-
563
- if (dependencies) {
564
- for (const path in dependencies) {
565
- const result = dependencies[path];
566
- const response_type = Math.floor(result.status / 100);
567
-
568
- const is_html = result.headers['content-type'] === 'text/html';
569
-
570
- const parts = path.split('/');
571
- if (is_html && parts[parts.length - 1] !== 'index.html') {
572
- parts.push('index.html');
573
- }
574
-
575
- const file = `${out}${parts.join('/')}`;
576
- mkdirp(dirname(file));
577
-
578
- fs.writeFileSync(file, result.body);
579
-
580
- if (response_type === OK) {
581
- log.info(`${result.status} ${path}`);
582
- } else {
583
- error(result.status, path);
584
- }
585
- }
586
- }
587
-
588
- if (is_html && config.prerender.crawl) {
589
- const cleaned = clean_html(rendered.body);
590
-
591
- let match;
592
- const pattern = /<(a|img|link|source)\s+([\s\S]+?)>/gm;
593
-
594
- while ((match = pattern.exec(cleaned))) {
595
- let hrefs = [];
596
- const element = match[1];
597
- const attrs = match[2];
598
-
599
- if (element === 'a' || element === 'link') {
600
- hrefs.push(get_href(attrs));
601
- } else {
602
- if (element === 'img') {
603
- hrefs.push(get_src(attrs));
604
- }
605
- hrefs.push(...get_srcset_urls(attrs));
606
- }
607
-
608
- hrefs = hrefs.filter(Boolean);
609
-
610
- for (const href of hrefs) {
611
- const resolved = resolve$2(path, href);
612
- if (resolved[0] !== '/') continue;
613
-
614
- const parsed = parse(resolved);
615
-
616
- const file = parsed.pathname.replace(config.paths.assets, '');
617
-
618
- const file_exists =
619
- (file.startsWith(`/${config.appDir}/`) && fs.existsSync(`${dir}/client/${file}`)) ||
620
- fs.existsSync(`${out}/${file}`) ||
621
- fs.existsSync(`${config.files.static}/${file}`) ||
622
- fs.existsSync(`${config.files.static}/${file}/index.html`);
623
-
624
- if (file_exists) continue;
625
-
626
- if (parsed.query) ;
627
-
628
- await visit(parsed.pathname.replace(config.paths.base, ''));
629
- }
630
- }
631
- }
632
- }
633
- }
634
-
635
- for (const entry of config.prerender.pages) {
636
- if (entry === '*') {
637
- // TODO support other extensions, e.g. .svelte.md?
638
- const entries = sync('**/*.svelte', { cwd: config.files.routes })
639
- .map((file) => {
640
- const parts = file.split('/'); // TODO is this true for glob results on windows?
641
-
642
- if (parts.some((part) => part[0] === '_' || /\[/.test(part))) {
643
- return null;
644
- }
645
-
646
- parts[parts.length - 1] = parts[parts.length - 1].replace(/\.svelte$/, '');
647
- if (parts[parts.length - 1] === 'index') parts.pop();
648
-
649
- if (parts[parts.length - 1] === '$layout' || parts[parts.length - 1] == '$error') {
650
- return null;
651
- }
652
-
653
- return `/${parts.join('/')}`;
654
- })
655
- .filter(Boolean);
656
-
657
- for (const entry of entries) {
658
- await visit(entry);
659
- }
660
- } else {
661
- await visit(entry);
662
- }
663
- }
664
- }
665
-
666
- class Builder {
667
- #generated_files;
668
- #config;
669
-
670
- constructor({ generated_files, config, log }) {
671
- this.#generated_files = generated_files;
672
- this.#config = config;
673
-
674
- this.log = log;
675
- }
676
-
677
- copy_client_files(dest) {
678
- copy(`${this.#generated_files}/client`, dest, (file) => file[0] !== '.');
679
- }
680
-
681
- copy_server_files(dest) {
682
- copy(`${this.#generated_files}/server`, dest, (file) => file[0] !== '.');
683
- }
684
-
685
- copy_static_files(dest) {
686
- copy(this.#config.files.assets, dest);
687
- }
688
-
689
- async prerender({ force = false, dest }) {
690
- if (this.#config.prerender.enabled) {
691
- await prerender({
692
- out: dest,
693
- force,
694
- dir: this.#generated_files,
695
- config: this.#config,
696
- log: this.log
697
- });
698
- }
699
- }
700
- }
701
-
702
- async function adapt(config, { verbose }) {
703
- const [adapter, options] = config.adapter;
704
-
705
- if (!adapter) {
706
- throw new Error('No adapter specified');
707
- }
708
-
709
- const log = logger({ verbose });
710
-
711
- console.log($.bold().cyan(`\n> Using ${adapter}`));
712
-
713
- const builder = new Builder({
714
- generated_files: '.svelte/build/optimized',
715
- config,
716
- log
717
- });
718
-
719
- const resolved = await import.meta.resolve(adapter, pathToFileURL(process.cwd()));
720
- const fn = await import(resolved);
721
- await fn(builder, options);
722
-
723
- log.success('done');
724
- }
725
-
726
- export { adapt };
727
- //# sourceMappingURL=index6.js.map