@sveltejs/kit 1.0.0-next.31 → 1.0.0-next.310

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