@sveltejs/kit 1.0.0-next.35 → 1.0.0-next.352

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