@sveltejs/kit 1.0.0-next.21 → 1.0.0-next.210

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 (81) hide show
  1. package/README.md +12 -9
  2. package/assets/components/error.svelte +19 -3
  3. package/assets/kit.js +1912 -0
  4. package/assets/runtime/app/env.js +20 -0
  5. package/assets/runtime/app/navigation.js +45 -13
  6. package/assets/runtime/app/paths.js +1 -2
  7. package/assets/runtime/app/stores.js +15 -9
  8. package/assets/runtime/chunks/utils.js +13 -0
  9. package/assets/runtime/env.js +8 -0
  10. package/assets/runtime/internal/singletons.js +5 -11
  11. package/assets/runtime/internal/start.js +979 -355
  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 +21 -0
  16. package/dist/chunks/index.js +4732 -0
  17. package/dist/chunks/index2.js +812 -0
  18. package/dist/chunks/index3.js +624 -0
  19. package/dist/chunks/index4.js +109 -0
  20. package/dist/chunks/index5.js +628 -0
  21. package/dist/chunks/index6.js +827 -0
  22. package/dist/chunks/index7.js +15575 -0
  23. package/dist/chunks/misc.js +3 -0
  24. package/dist/chunks/multipart-parser.js +449 -0
  25. package/dist/chunks/url.js +62 -0
  26. package/dist/cli.js +1012 -67
  27. package/dist/hooks.js +28 -0
  28. package/dist/install-fetch.js +6514 -0
  29. package/dist/node.js +51 -0
  30. package/dist/ssr.js +1842 -0
  31. package/package.json +90 -54
  32. package/svelte-kit.js +2 -0
  33. package/types/ambient-modules.d.ts +181 -0
  34. package/types/app.d.ts +45 -0
  35. package/types/config.d.ts +163 -0
  36. package/types/endpoint.d.ts +18 -0
  37. package/types/helper.d.ts +41 -0
  38. package/types/hooks.d.ts +48 -0
  39. package/types/index.d.ts +17 -0
  40. package/types/internal.d.ts +231 -0
  41. package/types/page.d.ts +71 -0
  42. package/CHANGELOG.md +0 -282
  43. package/assets/runtime/app/navigation.js.map +0 -1
  44. package/assets/runtime/app/paths.js.map +0 -1
  45. package/assets/runtime/app/stores.js.map +0 -1
  46. package/assets/runtime/internal/singletons.js.map +0 -1
  47. package/assets/runtime/internal/start.js.map +0 -1
  48. package/assets/runtime/utils-85ebcc60.js +0 -18
  49. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  50. package/dist/api.js +0 -44
  51. package/dist/api.js.map +0 -1
  52. package/dist/build.js +0 -246
  53. package/dist/build.js.map +0 -1
  54. package/dist/cli.js.map +0 -1
  55. package/dist/colors.js +0 -37
  56. package/dist/colors.js.map +0 -1
  57. package/dist/create_app.js +0 -578
  58. package/dist/create_app.js.map +0 -1
  59. package/dist/index.js +0 -12042
  60. package/dist/index.js.map +0 -1
  61. package/dist/index2.js +0 -544
  62. package/dist/index2.js.map +0 -1
  63. package/dist/index3.js +0 -71
  64. package/dist/index3.js.map +0 -1
  65. package/dist/index4.js +0 -466
  66. package/dist/index4.js.map +0 -1
  67. package/dist/index5.js +0 -729
  68. package/dist/index5.js.map +0 -1
  69. package/dist/index6.js +0 -713
  70. package/dist/index6.js.map +0 -1
  71. package/dist/logging.js +0 -43
  72. package/dist/logging.js.map +0 -1
  73. package/dist/package.js +0 -432
  74. package/dist/package.js.map +0 -1
  75. package/dist/renderer.js +0 -2391
  76. package/dist/renderer.js.map +0 -1
  77. package/dist/standard.js +0 -101
  78. package/dist/standard.js.map +0 -1
  79. package/dist/utils.js +0 -54
  80. package/dist/utils.js.map +0 -1
  81. package/svelte-kit +0 -3
@@ -0,0 +1,628 @@
1
+ import { m as mkdirp, r as rimraf, d as copy, $, l as logger } from '../cli.js';
2
+ import { S as SVELTE_KIT } from './constants.js';
3
+ import { readFileSync, writeFileSync } from 'fs';
4
+ import { resolve, join, dirname } from 'path';
5
+ import { pathToFileURL, URL } from 'url';
6
+ import { __fetch_polyfill } from '../install-fetch.js';
7
+ import { g as get_single_valued_header, r as resolve$1, i as is_root_relative } from './url.js';
8
+ import { g as generate_manifest } from './index4.js';
9
+ import 'sade';
10
+ import 'child_process';
11
+ import 'net';
12
+ import 'os';
13
+ import './error.js';
14
+ import 'node:http';
15
+ import 'node:https';
16
+ import 'node:zlib';
17
+ import 'node:stream';
18
+ import 'node:util';
19
+ import 'node:url';
20
+ import './misc.js';
21
+
22
+ /** @typedef {{
23
+ * fn: () => Promise<any>,
24
+ * fulfil: (value: any) => void,
25
+ * reject: (error: Error) => void
26
+ * }} Task */
27
+
28
+ /** @param {number} concurrency */
29
+ function queue(concurrency) {
30
+ /** @type {Task[]} */
31
+ const tasks = [];
32
+
33
+ let current = 0;
34
+
35
+ /** @type {(value?: any) => void} */
36
+ let fulfil;
37
+
38
+ /** @type {(error: Error) => void} */
39
+ let reject;
40
+
41
+ let closed = false;
42
+
43
+ const done = new Promise((f, r) => {
44
+ fulfil = f;
45
+ reject = r;
46
+ });
47
+
48
+ done.catch(() => {
49
+ // this is necessary in case a catch handler is never added
50
+ // to the done promise by the user
51
+ });
52
+
53
+ function dequeue() {
54
+ if (current < concurrency) {
55
+ const task = tasks.shift();
56
+
57
+ if (task) {
58
+ current += 1;
59
+ const promise = Promise.resolve(task.fn());
60
+
61
+ promise
62
+ .then(task.fulfil, (err) => {
63
+ task.reject(err);
64
+ reject(err);
65
+ })
66
+ .then(() => {
67
+ current -= 1;
68
+ dequeue();
69
+ });
70
+ } else if (current === 0) {
71
+ closed = true;
72
+ fulfil();
73
+ }
74
+ }
75
+ }
76
+
77
+ return {
78
+ /** @param {() => any} fn */
79
+ add: (fn) => {
80
+ if (closed) throw new Error('Cannot add tasks to a queue that has ended');
81
+
82
+ const promise = new Promise((fulfil, reject) => {
83
+ tasks.push({ fn, fulfil, reject });
84
+ });
85
+
86
+ dequeue();
87
+ return promise;
88
+ },
89
+
90
+ done: () => {
91
+ if (current === 0) {
92
+ closed = true;
93
+ fulfil();
94
+ }
95
+
96
+ return done;
97
+ }
98
+ };
99
+ }
100
+
101
+ /**
102
+ * @typedef {import('types/config').PrerenderErrorHandler} PrerenderErrorHandler
103
+ * @typedef {import('types/config').PrerenderOnErrorValue} OnError
104
+ * @typedef {import('types/internal').Logger} Logger
105
+ */
106
+
107
+ /** @param {string} html */
108
+ function clean_html(html) {
109
+ return html
110
+ .replace(/<!\[CDATA\[[\s\S]*?\]\]>/gm, '')
111
+ .replace(/(<script[\s\S]*?>)[\s\S]*?<\/script>/gm, '$1</' + 'script>')
112
+ .replace(/(<style[\s\S]*?>)[\s\S]*?<\/style>/gm, '$1</' + 'style>')
113
+ .replace(/<!--[\s\S]*?-->/gm, '');
114
+ }
115
+
116
+ /** @param {string} attrs */
117
+ function get_href(attrs) {
118
+ const match = /(?:[\s'"]|^)href\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/.exec(attrs);
119
+ return match && (match[1] || match[2] || match[3]);
120
+ }
121
+
122
+ /** @param {string} attrs */
123
+ function get_src(attrs) {
124
+ const match = /(?:[\s'"]|^)src\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/.exec(attrs);
125
+ return match && (match[1] || match[2] || match[3]);
126
+ }
127
+
128
+ /** @param {string} attrs */
129
+ function is_rel_external(attrs) {
130
+ const match = /rel\s*=\s*(?:["'][^>]*(external)[^>]*["']|(external))/.exec(attrs);
131
+ return !!match;
132
+ }
133
+
134
+ /** @param {string} attrs */
135
+ function get_srcset_urls(attrs) {
136
+ const results = [];
137
+ // Note that the srcset allows any ASCII whitespace, including newlines.
138
+ const match = /([\s'"]|^)srcset\s*=\s*(?:"(.*?)"|'(.*?)'|([^\s>]*))/s.exec(attrs);
139
+ if (match) {
140
+ const attr_content = match[1] || match[2] || match[3];
141
+ // Parse the content of the srcset attribute.
142
+ // The regexp is modelled after the srcset specs (https://html.spec.whatwg.org/multipage/images.html#srcset-attribute)
143
+ // and should cover most reasonable cases.
144
+ const regex = /\s*([^\s,]\S+[^\s,])\s*((?:\d+w)|(?:-?\d+(?:\.\d+)?(?:[eE]-?\d+)?x))?/gm;
145
+ let sub_matches;
146
+ while ((sub_matches = regex.exec(attr_content))) {
147
+ results.push(sub_matches[1]);
148
+ }
149
+ }
150
+ return results;
151
+ }
152
+
153
+ /** @type {(errorDetails: Parameters<PrerenderErrorHandler>[0] ) => string} */
154
+ function errorDetailsToString({ status, path, referrer, referenceType }) {
155
+ return `${status} ${path}${referrer ? ` (${referenceType} from ${referrer})` : ''}`;
156
+ }
157
+
158
+ /** @type {(log: Logger, onError: OnError) => PrerenderErrorHandler} */
159
+ function chooseErrorHandler(log, onError) {
160
+ switch (onError) {
161
+ case 'continue':
162
+ return (errorDetails) => {
163
+ log.error(errorDetailsToString(errorDetails));
164
+ };
165
+ case 'fail':
166
+ return (errorDetails) => {
167
+ throw new Error(errorDetailsToString(errorDetails));
168
+ };
169
+ default:
170
+ return onError;
171
+ }
172
+ }
173
+
174
+ const OK = 2;
175
+ const REDIRECT = 3;
176
+
177
+ /**
178
+ * @param {{
179
+ * cwd: string;
180
+ * out: string;
181
+ * log: Logger;
182
+ * config: import('types/config').ValidatedConfig;
183
+ * build_data: import('types/internal').BuildData;
184
+ * fallback?: string;
185
+ * all: boolean; // disregard `export const prerender = true`
186
+ * }} opts
187
+ * @returns {Promise<{ paths: string[] }>} returns a promise that resolves to an array of paths corresponding to the files that have been prerendered.
188
+ */
189
+ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
190
+ if (!config.kit.prerender.enabled && !fallback) {
191
+ return { paths: [] };
192
+ }
193
+
194
+ __fetch_polyfill();
195
+
196
+ mkdirp(out);
197
+
198
+ const dir = resolve(cwd, `${SVELTE_KIT}/output`);
199
+
200
+ const seen = new Set();
201
+
202
+ const server_root = resolve(dir);
203
+
204
+ /** @type {import('types/internal').AppModule} */
205
+ const { App, override } = await import(pathToFileURL(`${server_root}/server/app.js`).href);
206
+
207
+ override({
208
+ paths: config.kit.paths,
209
+ prerendering: true,
210
+ read: (file) => readFileSync(join(config.kit.files.assets, file))
211
+ });
212
+
213
+ const { manifest } = await import(pathToFileURL(`${server_root}/server/manifest.js`).href);
214
+
215
+ const app = new App(manifest);
216
+
217
+ const error = chooseErrorHandler(log, config.kit.prerender.onError);
218
+
219
+ const files = new Set([
220
+ ...build_data.static,
221
+ ...build_data.client.chunks.map((chunk) => `${config.kit.appDir}/${chunk.fileName}`),
222
+ ...build_data.client.assets.map((chunk) => `${config.kit.appDir}/${chunk.fileName}`)
223
+ ]);
224
+
225
+ /** @type {string[]} */
226
+ const paths = [];
227
+
228
+ build_data.static.forEach((file) => {
229
+ if (file.endsWith('/index.html')) {
230
+ files.add(file.slice(0, -11));
231
+ }
232
+ });
233
+
234
+ /**
235
+ * @param {string} path
236
+ */
237
+ function normalize(path) {
238
+ if (config.kit.trailingSlash === 'always') {
239
+ return path.endsWith('/') ? path : `${path}/`;
240
+ } else if (config.kit.trailingSlash === 'never') {
241
+ return !path.endsWith('/') || path === '/' ? path : path.slice(0, -1);
242
+ }
243
+
244
+ return path;
245
+ }
246
+
247
+ const q = queue(config.kit.prerender.concurrency);
248
+
249
+ /**
250
+ * @param {string} decoded_path
251
+ * @param {string?} referrer
252
+ */
253
+ function enqueue(decoded_path, referrer) {
254
+ const path = encodeURI(normalize(decoded_path));
255
+
256
+ if (seen.has(path)) return;
257
+ seen.add(path);
258
+
259
+ return q.add(() => visit(path, decoded_path, referrer));
260
+ }
261
+
262
+ /**
263
+ * @param {string} path
264
+ * @param {string} decoded_path
265
+ * @param {string?} referrer
266
+ */
267
+ async function visit(path, decoded_path, referrer) {
268
+ /** @type {Map<string, import('types/hooks').ServerResponse>} */
269
+ const dependencies = new Map();
270
+
271
+ const rendered = await app.render(
272
+ {
273
+ url: `${config.kit.protocol || 'sveltekit'}://${config.kit.host || 'prerender'}${path}`,
274
+ method: 'GET',
275
+ headers: {},
276
+ rawBody: null
277
+ },
278
+ {
279
+ prerender: {
280
+ all,
281
+ dependencies
282
+ }
283
+ }
284
+ );
285
+
286
+ if (rendered) {
287
+ const response_type = Math.floor(rendered.status / 100);
288
+ const headers = rendered.headers;
289
+ const type = headers && headers['content-type'];
290
+ const is_html = response_type === REDIRECT || type === 'text/html';
291
+
292
+ const parts = decoded_path.split('/');
293
+ if (is_html && parts[parts.length - 1] !== 'index.html') {
294
+ parts.push('index.html');
295
+ }
296
+
297
+ const file = `${out}${parts.join('/')}`;
298
+
299
+ if (response_type === REDIRECT) {
300
+ const location = get_single_valued_header(headers, 'location');
301
+
302
+ if (location) {
303
+ mkdirp(dirname(file));
304
+
305
+ log.warn(`${rendered.status} ${decoded_path} -> ${location}`);
306
+ writeFileSync(file, `<meta http-equiv="refresh" content="0;url=${encodeURI(location)}">`);
307
+
308
+ const resolved = resolve$1(path, location);
309
+ if (is_root_relative(resolved)) {
310
+ enqueue(resolved, path);
311
+ }
312
+ } else {
313
+ log.warn(`location header missing on redirect received from ${decoded_path}`);
314
+ }
315
+
316
+ return;
317
+ }
318
+
319
+ if (rendered.status === 200) {
320
+ mkdirp(dirname(file));
321
+
322
+ log.info(`${rendered.status} ${decoded_path}`);
323
+ writeFileSync(file, rendered.body || '');
324
+ paths.push(normalize(decoded_path));
325
+ } else if (response_type !== OK) {
326
+ error({ status: rendered.status, path, referrer, referenceType: 'linked' });
327
+ }
328
+
329
+ dependencies.forEach((result, dependency_path) => {
330
+ const response_type = Math.floor(result.status / 100);
331
+
332
+ const is_html = result.headers['content-type'] === 'text/html';
333
+
334
+ const parts = dependency_path.split('/');
335
+ if (is_html && parts[parts.length - 1] !== 'index.html') {
336
+ parts.push('index.html');
337
+ }
338
+
339
+ const file = `${out}${parts.join('/')}`;
340
+ mkdirp(dirname(file));
341
+
342
+ if (result.body) {
343
+ writeFileSync(file, result.body);
344
+ paths.push(dependency_path);
345
+ }
346
+
347
+ if (response_type === OK) {
348
+ log.info(`${result.status} ${dependency_path}`);
349
+ } else {
350
+ error({
351
+ status: result.status,
352
+ path: dependency_path,
353
+ referrer: path,
354
+ referenceType: 'fetched'
355
+ });
356
+ }
357
+ });
358
+
359
+ if (is_html && config.kit.prerender.crawl) {
360
+ const cleaned = clean_html(/** @type {string} */ (rendered.body));
361
+
362
+ let match;
363
+ const pattern = /<(a|img|link|source)\s+([\s\S]+?)>/gm;
364
+
365
+ const hrefs = [];
366
+
367
+ while ((match = pattern.exec(cleaned))) {
368
+ const element = match[1];
369
+ const attrs = match[2];
370
+
371
+ if (element === 'a' || element === 'link') {
372
+ if (is_rel_external(attrs)) continue;
373
+
374
+ hrefs.push(get_href(attrs));
375
+ } else {
376
+ if (element === 'img') {
377
+ hrefs.push(get_src(attrs));
378
+ }
379
+ hrefs.push(...get_srcset_urls(attrs));
380
+ }
381
+ }
382
+
383
+ for (const href of hrefs) {
384
+ if (!href) continue;
385
+
386
+ const resolved = resolve$1(path, href);
387
+ if (!is_root_relative(resolved)) continue;
388
+
389
+ const parsed = new URL(resolved, 'http://localhost');
390
+ const pathname = decodeURI(parsed.pathname).replace(config.kit.paths.base, '');
391
+
392
+ const file = pathname.slice(1);
393
+ if (files.has(file)) continue;
394
+
395
+ if (parsed.search) ;
396
+
397
+ enqueue(pathname, path);
398
+ }
399
+ }
400
+ }
401
+ }
402
+
403
+ if (config.kit.prerender.enabled) {
404
+ for (const entry of config.kit.prerender.entries) {
405
+ if (entry === '*') {
406
+ for (const entry of build_data.entries) {
407
+ enqueue(entry, null);
408
+ }
409
+ } else {
410
+ enqueue(entry, null);
411
+ }
412
+ }
413
+
414
+ await q.done();
415
+ }
416
+
417
+ if (fallback) {
418
+ const rendered = await app.render(
419
+ {
420
+ url: `${config.kit.host || 'sveltekit'}://${config.kit.host || 'prerender'}/[fallback]`,
421
+ method: 'GET',
422
+ headers: {},
423
+ rawBody: null
424
+ },
425
+ {
426
+ prerender: {
427
+ fallback,
428
+ all: false,
429
+ dependencies: new Map()
430
+ }
431
+ }
432
+ );
433
+
434
+ const file = join(out, fallback);
435
+ mkdirp(dirname(file));
436
+ writeFileSync(file, rendered.body || '');
437
+ }
438
+
439
+ return {
440
+ paths
441
+ };
442
+ }
443
+
444
+ /**
445
+ * @param {{
446
+ * cwd: string;
447
+ * config: import('types/config').ValidatedConfig;
448
+ * build_data: import('types/internal').BuildData;
449
+ * log: import('types/internal').Logger;
450
+ * }} opts
451
+ * @returns {import('types/config').Builder}
452
+ */
453
+ function create_builder({ cwd, config, build_data, log }) {
454
+ /** @type {Set<string>} */
455
+ const prerendered_paths = new Set();
456
+ let generated_manifest = false;
457
+
458
+ /** @param {import('types/internal').RouteData} route */
459
+ function not_prerendered(route) {
460
+ if (route.type === 'page' && route.path) {
461
+ return !prerendered_paths.has(route.path);
462
+ }
463
+
464
+ return true;
465
+ }
466
+
467
+ return {
468
+ log,
469
+ rimraf,
470
+ mkdirp,
471
+ copy,
472
+
473
+ createEntries(fn) {
474
+ generated_manifest = true;
475
+
476
+ const { routes } = build_data.manifest_data;
477
+
478
+ /** @type {import('types/config').RouteDefinition[]} */
479
+ const facades = routes.map((route) => ({
480
+ type: route.type,
481
+ segments: route.segments,
482
+ pattern: route.pattern,
483
+ methods: route.type === 'page' ? ['get'] : build_data.server.methods[route.file]
484
+ }));
485
+
486
+ const seen = new Set();
487
+
488
+ for (let i = 0; i < routes.length; i += 1) {
489
+ const route = routes[i];
490
+ const { id, filter, complete } = fn(facades[i]);
491
+
492
+ if (seen.has(id)) continue;
493
+ seen.add(id);
494
+
495
+ const group = [route];
496
+
497
+ // figure out which lower priority routes should be considered fallbacks
498
+ for (let j = i + 1; j < routes.length; j += 1) {
499
+ if (filter(facades[j])) {
500
+ group.push(routes[j]);
501
+ }
502
+ }
503
+
504
+ const filtered = new Set(group.filter(not_prerendered));
505
+
506
+ // heuristic: if /foo/[bar] is included, /foo/[bar].json should
507
+ // also be included, since the page likely needs the endpoint
508
+ filtered.forEach((route) => {
509
+ if (route.type === 'page') {
510
+ const length = route.segments.length;
511
+
512
+ const endpoint = routes.find((candidate) => {
513
+ if (candidate.segments.length !== length) return false;
514
+
515
+ for (let i = 0; i < length; i += 1) {
516
+ const a = route.segments[i];
517
+ const b = candidate.segments[i];
518
+
519
+ if (i === length - 1) {
520
+ return b.content === `${a.content}.json`;
521
+ }
522
+
523
+ if (a.content !== b.content) return false;
524
+ }
525
+ });
526
+
527
+ if (endpoint) {
528
+ filtered.add(endpoint);
529
+ }
530
+ }
531
+ });
532
+
533
+ if (filtered.size > 0) {
534
+ complete({
535
+ generateManifest: ({ relativePath, format }) =>
536
+ generate_manifest(build_data, relativePath, Array.from(filtered), format)
537
+ });
538
+ }
539
+ }
540
+ },
541
+
542
+ generateManifest: ({ relativePath, format }) => {
543
+ generated_manifest = true;
544
+ return generate_manifest(
545
+ build_data,
546
+ relativePath,
547
+ build_data.manifest_data.routes.filter(not_prerendered),
548
+ format
549
+ );
550
+ },
551
+
552
+ getBuildDirectory(name) {
553
+ return `${cwd}/${SVELTE_KIT}/${name}`;
554
+ },
555
+
556
+ getClientDirectory() {
557
+ return `${cwd}/${SVELTE_KIT}/output/client`;
558
+ },
559
+
560
+ getServerDirectory() {
561
+ return `${cwd}/${SVELTE_KIT}/output/server`;
562
+ },
563
+
564
+ getStaticDirectory() {
565
+ return config.kit.files.assets;
566
+ },
567
+
568
+ writeClient(dest) {
569
+ return copy(`${cwd}/${SVELTE_KIT}/output/client`, dest, {
570
+ filter: (file) => file[0] !== '.'
571
+ });
572
+ },
573
+
574
+ writeServer(dest) {
575
+ return copy(`${cwd}/${SVELTE_KIT}/output/server`, dest, {
576
+ filter: (file) => file[0] !== '.'
577
+ });
578
+ },
579
+
580
+ writeStatic(dest) {
581
+ return copy(config.kit.files.assets, dest);
582
+ },
583
+
584
+ async prerender({ all = false, dest, fallback }) {
585
+ if (generated_manifest) {
586
+ throw new Error(
587
+ 'Adapters must call prerender(...) before createEntries(...) or generateManifest(...)'
588
+ );
589
+ }
590
+
591
+ const prerendered = await prerender({
592
+ out: dest,
593
+ all,
594
+ cwd,
595
+ config,
596
+ build_data,
597
+ fallback,
598
+ log
599
+ });
600
+
601
+ prerendered.paths.forEach((path) => {
602
+ prerendered_paths.add(path);
603
+ prerendered_paths.add(path + '/');
604
+ });
605
+
606
+ return prerendered;
607
+ }
608
+ };
609
+ }
610
+
611
+ /**
612
+ * @param {import('types/config').ValidatedConfig} config
613
+ * @param {import('types/internal').BuildData} build_data
614
+ * @param {{ cwd?: string, verbose: boolean }} opts
615
+ */
616
+ async function adapt(config, build_data, { cwd = process.cwd(), verbose }) {
617
+ const { name, adapt } = config.kit.adapter;
618
+
619
+ console.log($.bold().cyan(`\n> Using ${name}`));
620
+
621
+ const log = logger({ verbose });
622
+ const builder = create_builder({ cwd, config, build_data, log });
623
+ await adapt(builder);
624
+
625
+ log.success('done');
626
+ }
627
+
628
+ export { adapt };