@sveltejs/kit 1.0.0-next.266 → 1.0.0-next.267

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.
@@ -6,6 +6,22 @@ import { writable } from 'svelte/store';
6
6
  import { base, set_paths } from '../paths.js';
7
7
  import { init } from './singletons.js';
8
8
 
9
+ /**
10
+ * @param {string} path
11
+ * @param {'always' | 'never' | 'ignore'} trailing_slash
12
+ */
13
+ function normalize_path(path, trailing_slash) {
14
+ if (path === '/' || trailing_slash === 'ignore') return path;
15
+
16
+ if (trailing_slash === 'never') {
17
+ return path.endsWith('/') ? path.slice(0, -1) : path;
18
+ } else if (trailing_slash === 'always' && /\/[^./]+$/.test(path)) {
19
+ return path + '/';
20
+ }
21
+
22
+ return path;
23
+ }
24
+
9
25
  function scroll_state() {
10
26
  return {
11
27
  x: pageXOffset,
@@ -396,14 +412,7 @@ class Router {
396
412
  }
397
413
  this.navigating++;
398
414
 
399
- let { pathname } = url;
400
-
401
- if (this.trailing_slash === 'never') {
402
- if (pathname !== '/' && pathname.endsWith('/')) pathname = pathname.slice(0, -1);
403
- } else if (this.trailing_slash === 'always') {
404
- const is_file = /** @type {string} */ (url.pathname.split('/').pop()).includes('.');
405
- if (!is_file && !pathname.endsWith('/')) pathname += '/';
406
- }
415
+ const pathname = normalize_path(url.pathname, this.trailing_slash);
407
416
 
408
417
  info.url = new URL(url.origin + pathname + url.search + url.hash);
409
418
 
@@ -1498,6 +1498,22 @@ function is_root_relative(path) {
1498
1498
  return path[0] === '/' && path[1] !== '/';
1499
1499
  }
1500
1500
 
1501
+ /**
1502
+ * @param {string} path
1503
+ * @param {'always' | 'never' | 'ignore'} trailing_slash
1504
+ */
1505
+ function normalize_path(path, trailing_slash) {
1506
+ if (path === '/' || trailing_slash === 'ignore') return path;
1507
+
1508
+ if (trailing_slash === 'never') {
1509
+ return path.endsWith('/') ? path.slice(0, -1) : path;
1510
+ } else if (trailing_slash === 'always' && /\/[^./]+$/.test(path)) {
1511
+ return path + '/';
1512
+ }
1513
+
1514
+ return path;
1515
+ }
1516
+
1501
1517
  /**
1502
1518
  * @param {{
1503
1519
  * event: import('types/hooks').RequestEvent;
@@ -1700,9 +1716,7 @@ async function load_node({
1700
1716
  } else {
1701
1717
  // external
1702
1718
  if (resolved.startsWith('//')) {
1703
- throw new Error(
1704
- `Cannot request protocol-relative URL (${requested}) in server-side fetch`
1705
- );
1719
+ requested = event.url.protocol + requested;
1706
1720
  }
1707
1721
 
1708
1722
  // external fetch
@@ -1889,22 +1903,21 @@ async function load_shadow_data(route, event, prerender) {
1889
1903
  if (result.fallthrough) return result;
1890
1904
 
1891
1905
  const { status, headers, body } = validate_shadow_output(result);
1906
+ data.status = status;
1907
+
1892
1908
  add_cookies(/** @type {string[]} */ (data.cookies), headers);
1893
1909
 
1894
1910
  // Redirects are respected...
1895
1911
  if (status >= 300 && status < 400) {
1896
- return {
1897
- status,
1898
- redirect: /** @type {string} */ (
1899
- headers instanceof Headers ? headers.get('location') : headers.location
1900
- )
1901
- };
1912
+ data.redirect = /** @type {string} */ (
1913
+ headers instanceof Headers ? headers.get('location') : headers.location
1914
+ );
1915
+ return data;
1902
1916
  }
1903
1917
 
1904
1918
  // ...but 4xx and 5xx status codes _don't_ result in the error page
1905
1919
  // rendering for non-GET requests — instead, we allow the page
1906
1920
  // to render with any validation errors etc that were returned
1907
- data.status = status;
1908
1921
  data.body = body;
1909
1922
  }
1910
1923
 
@@ -1915,21 +1928,18 @@ async function load_shadow_data(route, event, prerender) {
1915
1928
 
1916
1929
  const { status, headers, body } = validate_shadow_output(result);
1917
1930
  add_cookies(/** @type {string[]} */ (data.cookies), headers);
1931
+ data.status = status;
1918
1932
 
1919
1933
  if (status >= 400) {
1920
- return {
1921
- status,
1922
- error: new Error('Failed to load data')
1923
- };
1934
+ data.error = new Error('Failed to load data');
1935
+ return data;
1924
1936
  }
1925
1937
 
1926
1938
  if (status >= 300) {
1927
- return {
1928
- status,
1929
- redirect: /** @type {string} */ (
1930
- headers instanceof Headers ? headers.get('location') : headers.location
1931
- )
1932
- };
1939
+ data.redirect = /** @type {string} */ (
1940
+ headers instanceof Headers ? headers.get('location') : headers.location
1941
+ );
1942
+ return data;
1933
1943
  }
1934
1944
 
1935
1945
  data.body = { ...body, ...data.body };
@@ -2448,26 +2458,15 @@ const DATA_SUFFIX = '/__data.json';
2448
2458
  async function respond(request, options, state = {}) {
2449
2459
  const url = new URL(request.url);
2450
2460
 
2451
- if (url.pathname !== '/' && options.trailing_slash !== 'ignore') {
2452
- const has_trailing_slash = url.pathname.endsWith('/');
2461
+ const normalized = normalize_path(url.pathname, options.trailing_slash);
2453
2462
 
2454
- if (
2455
- (has_trailing_slash && options.trailing_slash === 'never') ||
2456
- (!has_trailing_slash &&
2457
- options.trailing_slash === 'always' &&
2458
- !(url.pathname.split('/').pop() || '').includes('.'))
2459
- ) {
2460
- url.pathname = has_trailing_slash ? url.pathname.slice(0, -1) : url.pathname + '/';
2461
-
2462
- if (url.search === '?') url.search = '';
2463
-
2464
- return new Response(undefined, {
2465
- status: 301,
2466
- headers: {
2467
- location: url.pathname + url.search
2468
- }
2469
- });
2470
- }
2463
+ if (normalized !== url.pathname) {
2464
+ return new Response(undefined, {
2465
+ status: 301,
2466
+ headers: {
2467
+ location: normalized + (url.search === '?' ? '' : url.search)
2468
+ }
2469
+ });
2471
2470
  }
2472
2471
 
2473
2472
  const { parameter, allowed } = options.method_override;
@@ -2596,11 +2595,11 @@ async function respond(request, options, state = {}) {
2596
2595
  const location = response.headers.get('location');
2597
2596
 
2598
2597
  if (location) {
2598
+ const headers = new Headers(response.headers);
2599
+ headers.set('x-sveltekit-location', location);
2599
2600
  response = new Response(undefined, {
2600
2601
  status: 204,
2601
- headers: {
2602
- 'x-sveltekit-location': location
2603
- }
2602
+ headers
2604
2603
  });
2605
2604
  }
2606
2605
  }
@@ -1,4 +1,4 @@
1
- import { m as mkdirp, b as SVELTE_KIT, h as rimraf, i as copy, $, j as logger } from '../cli.js';
1
+ import { b as SVELTE_KIT, m as mkdirp, h as rimraf, i as copy, $, j as logger } from '../cli.js';
2
2
  import { readFileSync, writeFileSync } from 'fs';
3
3
  import { resolve as resolve$1, join, dirname } from 'path';
4
4
  import { pathToFileURL, URL } from 'url';
@@ -55,6 +55,22 @@ function is_root_relative(path) {
55
55
  return path[0] === '/' && path[1] !== '/';
56
56
  }
57
57
 
58
+ /**
59
+ * @param {string} path
60
+ * @param {'always' | 'never' | 'ignore'} trailing_slash
61
+ */
62
+ function normalize_path(path, trailing_slash) {
63
+ if (path === '/' || trailing_slash === 'ignore') return path;
64
+
65
+ if (trailing_slash === 'never') {
66
+ return path.endsWith('/') ? path.slice(0, -1) : path;
67
+ } else if (trailing_slash === 'always' && /\/[^./]+$/.test(path)) {
68
+ return path + '/';
69
+ }
70
+
71
+ return path;
72
+ }
73
+
58
74
  /** @typedef {{
59
75
  * fn: () => Promise<any>,
60
76
  * fulfil: (value: any) => void,
@@ -425,25 +441,27 @@ const REDIRECT = 3;
425
441
  * fallback?: string;
426
442
  * all: boolean; // disregard `export const prerender = true`
427
443
  * }} opts
428
- * @returns {Promise<{ paths: string[] }>} returns a promise that resolves to an array of paths corresponding to the files that have been prerendered.
429
444
  */
430
445
  async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
446
+ /** @type {import('types/config').Prerendered} */
447
+ const prerendered = {
448
+ pages: new Map(),
449
+ assets: new Map(),
450
+ redirects: new Map(),
451
+ paths: []
452
+ };
453
+
431
454
  if (!config.kit.prerender.enabled && !fallback) {
432
- return { paths: [] };
455
+ return prerendered;
433
456
  }
434
457
 
435
458
  __fetch_polyfill();
436
459
 
437
- mkdirp(out);
438
-
439
- const dir = resolve$1(cwd, `${SVELTE_KIT}/output`);
440
-
441
- const seen = new Set();
442
-
443
- const server_root = resolve$1(dir);
460
+ const server_root = resolve$1(cwd, `${SVELTE_KIT}/output`);
444
461
 
445
462
  /** @type {import('types/internal').AppModule} */
446
463
  const { App, override } = await import(pathToFileURL(`${server_root}/server/app.js`).href);
464
+ const { manifest } = await import(pathToFileURL(`${server_root}/server/manifest.js`).href);
447
465
 
448
466
  override({
449
467
  paths: config.kit.paths,
@@ -451,8 +469,6 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
451
469
  read: (file) => readFileSync(join(config.kit.files.assets, file))
452
470
  });
453
471
 
454
- const { manifest } = await import(pathToFileURL(`${server_root}/server/manifest.js`).href);
455
-
456
472
  const app = new App(manifest);
457
473
 
458
474
  const error = normalise_error_handler(log, config.kit.prerender.onError);
@@ -463,28 +479,12 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
463
479
  ...build_data.client.assets.map((chunk) => `${config.kit.appDir}/${chunk.fileName}`)
464
480
  ]);
465
481
 
466
- /** @type {string[]} */
467
- const paths = [];
468
-
469
482
  build_data.static.forEach((file) => {
470
483
  if (file.endsWith('/index.html')) {
471
484
  files.add(file.slice(0, -11));
472
485
  }
473
486
  });
474
487
 
475
- /**
476
- * @param {string} path
477
- */
478
- function normalize(path) {
479
- if (config.kit.trailingSlash === 'always') {
480
- return path.endsWith('/') ? path : `${path}/`;
481
- } else if (config.kit.trailingSlash === 'never') {
482
- return !path.endsWith('/') || path === '/' ? path : path.slice(0, -1);
483
- }
484
-
485
- return path;
486
- }
487
-
488
488
  const q = queue(config.kit.prerender.concurrency);
489
489
 
490
490
  /**
@@ -492,150 +492,168 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
492
492
  * @param {boolean} is_html
493
493
  */
494
494
  function output_filename(path, is_html) {
495
- path = path.slice(config.kit.paths.base.length) || '/';
495
+ const file = path.slice(config.kit.paths.base.length + 1);
496
496
 
497
- if (path === '/') {
498
- return '/index.html';
497
+ if (file === '') {
498
+ return 'index.html';
499
499
  }
500
500
 
501
- const parts = path.split('/');
502
- if (is_html && parts[parts.length - 1] !== 'index.html') {
503
- if (config.kit.trailingSlash === 'always') {
504
- parts.push('index.html');
505
- } else {
506
- parts[parts.length - 1] += '.html';
507
- }
501
+ if (is_html && !file.endsWith('.html')) {
502
+ return file + (config.kit.trailingSlash === 'always' ? 'index.html' : '.html');
508
503
  }
509
- return parts.join('/');
504
+
505
+ return file;
510
506
  }
511
507
 
508
+ const seen = new Set();
509
+ const written = new Set();
510
+
512
511
  /**
513
- * @param {string} decoded_path
514
- * @param {string?} referrer
512
+ * @param {string | null} referrer
513
+ * @param {string} decoded
514
+ * @param {string} [encoded]
515
515
  */
516
- function enqueue(decoded_path, referrer) {
517
- const path = encodeURI(normalize(decoded_path));
516
+ function enqueue(referrer, decoded, encoded) {
517
+ if (seen.has(decoded)) return;
518
+ seen.add(decoded);
518
519
 
519
- if (seen.has(path)) return;
520
- seen.add(path);
520
+ const file = decoded.slice(config.kit.paths.base.length + 1);
521
+ if (files.has(file)) return;
521
522
 
522
- return q.add(() => visit(path, decoded_path, referrer));
523
+ return q.add(() => visit(decoded, encoded || encodeURI(decoded), referrer));
523
524
  }
524
525
 
525
526
  /**
526
- * @param {string} path
527
- * @param {string} decoded_path
527
+ * @param {string} decoded
528
+ * @param {string} encoded
528
529
  * @param {string?} referrer
529
530
  */
530
- async function visit(path, decoded_path, referrer) {
531
- if (!path.startsWith(config.kit.paths.base)) {
532
- error({ status: 404, path, referrer, referenceType: 'linked' });
531
+ async function visit(decoded, encoded, referrer) {
532
+ if (!decoded.startsWith(config.kit.paths.base)) {
533
+ error({ status: 404, path: decoded, referrer, referenceType: 'linked' });
533
534
  return;
534
535
  }
535
536
 
536
537
  /** @type {Map<string, import('types/internal').PrerenderDependency>} */
537
538
  const dependencies = new Map();
538
539
 
539
- const rendered = await app.render(new Request(`http://sveltekit-prerender${path}`), {
540
+ const response = await app.render(new Request(`http://sveltekit-prerender${encoded}`), {
540
541
  prerender: {
541
542
  all,
542
543
  dependencies
543
544
  }
544
545
  });
545
546
 
546
- const response_type = Math.floor(rendered.status / 100);
547
- const type = rendered.headers.get('content-type');
547
+ const text = await response.text();
548
+
549
+ save(response, text, decoded, encoded, referrer, 'linked');
550
+
551
+ for (const [dependency_path, result] of dependencies) {
552
+ // this seems circuitous, but using new URL allows us to not care
553
+ // whether dependency_path is encoded or not
554
+ const encoded_dependency_path = new URL(dependency_path, 'http://localhost').pathname;
555
+ const decoded_dependency_path = decodeURI(encoded_dependency_path);
556
+
557
+ const body = result.body ?? new Uint8Array(await result.response.arrayBuffer());
558
+ save(
559
+ result.response,
560
+ body,
561
+ decoded_dependency_path,
562
+ encoded_dependency_path,
563
+ decoded,
564
+ 'fetched'
565
+ );
566
+ }
567
+
568
+ if (config.kit.prerender.crawl && response.headers.get('content-type') === 'text/html') {
569
+ for (const href of crawl(text)) {
570
+ if (href.startsWith('data:') || href.startsWith('#')) continue;
571
+
572
+ const resolved = resolve(encoded, href);
573
+ if (!is_root_relative(resolved)) continue;
574
+
575
+ const parsed = new URL(resolved, 'http://localhost');
576
+
577
+ if (parsed.search) ;
578
+
579
+ const pathname = normalize_path(parsed.pathname, config.kit.trailingSlash);
580
+ enqueue(decoded, decodeURI(pathname), pathname);
581
+ }
582
+ }
583
+ }
584
+
585
+ /**
586
+ * @param {Response} response
587
+ * @param {string | Uint8Array} body
588
+ * @param {string} decoded
589
+ * @param {string} encoded
590
+ * @param {string | null} referrer
591
+ * @param {'linked' | 'fetched'} referenceType
592
+ */
593
+ function save(response, body, decoded, encoded, referrer, referenceType) {
594
+ const response_type = Math.floor(response.status / 100);
595
+ const type = /** @type {string} */ (response.headers.get('content-type'));
548
596
  const is_html = response_type === REDIRECT || type === 'text/html';
549
597
 
550
- const file = `${out}${output_filename(decoded_path, is_html)}`;
598
+ const file = output_filename(decoded, is_html);
599
+ const dest = `${out}/${file}`;
600
+
601
+ if (written.has(file)) return;
602
+ written.add(file);
551
603
 
552
604
  if (response_type === REDIRECT) {
553
- const location = rendered.headers.get('location');
605
+ const location = response.headers.get('location');
554
606
 
555
607
  if (location) {
556
- mkdirp(dirname(file));
608
+ mkdirp(dirname(dest));
557
609
 
558
- log.warn(`${rendered.status} ${decoded_path} -> ${location}`);
610
+ log.warn(`${response.status} ${decoded} -> ${location}`);
559
611
 
560
612
  writeFileSync(
561
- file,
613
+ dest,
562
614
  `<meta http-equiv="refresh" content=${escape_html_attr(`0;url=${location}`)}>`
563
615
  );
564
616
 
565
- const resolved = resolve(path, location);
617
+ let resolved = resolve(encoded, location);
566
618
  if (is_root_relative(resolved)) {
567
- enqueue(resolved, path);
619
+ resolved = normalize_path(resolved, config.kit.trailingSlash);
620
+ enqueue(decoded, decodeURI(resolved), resolved);
621
+ }
622
+
623
+ if (!prerendered.redirects.has(decoded)) {
624
+ prerendered.redirects.set(decoded, {
625
+ status: response.status,
626
+ location: resolved
627
+ });
628
+
629
+ prerendered.paths.push(normalize_path(decoded, 'never'));
568
630
  }
569
631
  } else {
570
- log.warn(`location header missing on redirect received from ${decoded_path}`);
632
+ log.warn(`location header missing on redirect received from ${decoded}`);
571
633
  }
572
634
 
573
635
  return;
574
636
  }
575
637
 
576
- const text = await rendered.text();
577
-
578
- if (rendered.status === 200) {
579
- mkdirp(dirname(file));
580
-
581
- log.info(`${rendered.status} ${decoded_path}`);
582
- writeFileSync(file, text);
583
- paths.push(normalize(decoded_path));
584
- } else if (response_type !== OK) {
585
- error({ status: rendered.status, path, referrer, referenceType: 'linked' });
586
- }
638
+ if (response.status === 200) {
639
+ mkdirp(dirname(dest));
587
640
 
588
- for (const [dependency_path, result] of dependencies) {
589
- const { status, headers } = result.response;
590
-
591
- const response_type = Math.floor(status / 100);
592
-
593
- const is_html = headers.get('content-type') === 'text/html';
594
-
595
- const file = `${out}${output_filename(dependency_path, is_html)}`;
596
- mkdirp(dirname(file));
597
-
598
- writeFileSync(
599
- file,
600
- result.body === null ? new Uint8Array(await result.response.arrayBuffer()) : result.body
601
- );
602
- paths.push(dependency_path);
641
+ log.info(`${response.status} ${decoded}`);
642
+ writeFileSync(dest, body);
603
643
 
604
- if (response_type === OK) {
605
- log.info(`${status} ${dependency_path}`);
644
+ if (is_html) {
645
+ prerendered.pages.set(decoded, {
646
+ file
647
+ });
606
648
  } else {
607
- error({
608
- status,
609
- path: dependency_path,
610
- referrer: path,
611
- referenceType: 'fetched'
649
+ prerendered.assets.set(decoded, {
650
+ type
612
651
  });
613
652
  }
614
- }
615
-
616
- if (is_html && config.kit.prerender.crawl) {
617
- for (const href of crawl(text)) {
618
- if (href.startsWith('data:') || href.startsWith('#')) continue;
619
-
620
- const resolved = resolve(path, href);
621
- if (!is_root_relative(resolved)) continue;
622
-
623
- const parsed = new URL(resolved, 'http://localhost');
624
-
625
- let pathname = decodeURI(parsed.pathname);
626
-
627
- if (config.kit.paths.base) {
628
- if (!pathname.startsWith(config.kit.paths.base)) continue;
629
- pathname = pathname.slice(config.kit.paths.base.length) || '/';
630
- }
631
-
632
- const file = pathname.slice(1);
633
- if (files.has(file)) continue;
634
-
635
- if (parsed.search) ;
636
653
 
637
- enqueue(pathname, path);
638
- }
654
+ prerendered.paths.push(normalize_path(decoded, 'never'));
655
+ } else if (response_type !== OK) {
656
+ error({ status: response.status, path: decoded, referrer, referenceType });
639
657
  }
640
658
  }
641
659
 
@@ -643,10 +661,10 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
643
661
  for (const entry of config.kit.prerender.entries) {
644
662
  if (entry === '*') {
645
663
  for (const entry of build_data.entries) {
646
- enqueue(config.kit.paths.base + entry, null);
664
+ enqueue(null, normalize_path(config.kit.paths.base + entry, config.kit.trailingSlash)); // TODO can we pre-normalize these?
647
665
  }
648
666
  } else {
649
- enqueue(config.kit.paths.base + entry, null);
667
+ enqueue(null, normalize_path(config.kit.paths.base + entry, config.kit.trailingSlash));
650
668
  }
651
669
  }
652
670
 
@@ -667,9 +685,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
667
685
  writeFileSync(file, await rendered.text());
668
686
  }
669
687
 
670
- return {
671
- paths
672
- };
688
+ return prerendered;
673
689
  }
674
690
 
675
691
  /**
@@ -683,11 +699,14 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
683
699
  */
684
700
  function create_builder({ cwd, config, build_data, log }) {
685
701
  /** @type {Set<string>} */
686
- const prerendered_paths = new Set();
702
+ let prerendered_paths;
703
+
687
704
  let generated_manifest = false;
688
705
 
689
706
  /** @param {import('types/internal').RouteData} route */
690
707
  function not_prerendered(route) {
708
+ if (!prerendered_paths) return true;
709
+
691
710
  if (route.type === 'page' && route.path) {
692
711
  return !prerendered_paths.has(route.path);
693
712
  }
@@ -832,10 +851,7 @@ function create_builder({ cwd, config, build_data, log }) {
832
851
  log
833
852
  });
834
853
 
835
- prerendered.paths.forEach((path) => {
836
- prerendered_paths.add(path);
837
- prerendered_paths.add(path + '/');
838
- });
854
+ prerendered_paths = new Set(prerendered.paths);
839
855
 
840
856
  return prerendered;
841
857
  }
package/dist/cli.js CHANGED
@@ -998,7 +998,7 @@ async function launch(port, https) {
998
998
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
999
999
  }
1000
1000
 
1001
- const prog = sade('svelte-kit').version('1.0.0-next.266');
1001
+ const prog = sade('svelte-kit').version('1.0.0-next.267');
1002
1002
 
1003
1003
  prog
1004
1004
  .command('dev')
@@ -1156,7 +1156,7 @@ async function check_port(port) {
1156
1156
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1157
1157
  if (open) launch(port, https);
1158
1158
 
1159
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.266'}\n`));
1159
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.267'}\n`));
1160
1160
 
1161
1161
  const protocol = https ? 'https:' : 'http:';
1162
1162
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.266",
3
+ "version": "1.0.0-next.267",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
package/types/config.d.ts CHANGED
@@ -35,6 +35,32 @@ export interface AdapterEntry {
35
35
  }) => void;
36
36
  }
37
37
 
38
+ export interface Prerendered {
39
+ pages: Map<
40
+ string,
41
+ {
42
+ /** The location of the .html file relative to the output directory */
43
+ file: string;
44
+ }
45
+ >;
46
+ assets: Map<
47
+ string,
48
+ {
49
+ /** The MIME type of the asset */
50
+ type: string;
51
+ }
52
+ >;
53
+ redirects: Map<
54
+ string,
55
+ {
56
+ status: number;
57
+ location: string;
58
+ }
59
+ >;
60
+ /** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */
61
+ paths: string[];
62
+ }
63
+
38
64
  export interface Builder {
39
65
  log: Logger;
40
66
  rimraf(dir: string): void;
@@ -87,9 +113,7 @@ export interface Builder {
87
113
  }
88
114
  ): string[];
89
115
 
90
- prerender(options: { all?: boolean; dest: string; fallback?: string }): Promise<{
91
- paths: string[];
92
- }>;
116
+ prerender(options: { all?: boolean; dest: string; fallback?: string }): Promise<Prerendered>;
93
117
  }
94
118
 
95
119
  export interface Adapter {
package/types/index.d.ts CHANGED
@@ -4,7 +4,14 @@
4
4
  import './ambient-modules';
5
5
 
6
6
  export { App, SSRManifest } from './app';
7
- export { Adapter, Builder, Config, PrerenderErrorHandler, ValidatedConfig } from './config';
7
+ export {
8
+ Adapter,
9
+ Builder,
10
+ Config,
11
+ Prerendered,
12
+ PrerenderErrorHandler,
13
+ ValidatedConfig
14
+ } from './config';
8
15
  export { EndpointOutput, RequestHandler } from './endpoint';
9
16
  export { ErrorLoad, ErrorLoadInput, Load, LoadInput, LoadOutput } from './page';
10
17
  export { ExternalFetch, GetSession, Handle, HandleError, RequestEvent, ResolveOpts } from './hooks';