@sveltejs/kit 1.0.0-next.22 → 1.0.0-next.223

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